onairos 1.0.0 → 1.0.2

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 n="object"==typeof exports?e(require("react")):e(t.React);for(var r in n)("object"==typeof exports?exports:t)[r]=n[r]}}(this,(t=>(()=>{var e,n,r,o,i={837:(t,e,n)=>{"use strict";var r=n(639),o=Symbol.for("react.element"),i=Symbol.for("react.fragment"),s=Object.prototype.hasOwnProperty,a=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,c={key:!0,ref:!0,__self:!0,__source:!0};function l(t,e,n){var r,i={},l=null,u=null;for(r in void 0!==n&&(l=""+n),void 0!==e.key&&(l=""+e.key),void 0!==e.ref&&(u=e.ref),e)s.call(e,r)&&!c.hasOwnProperty(r)&&(i[r]=e[r]);if(t&&t.defaultProps)for(r in e=t.defaultProps)void 0===i[r]&&(i[r]=e[r]);return{$$typeof:o,type:t,key:l,ref:u,props:i,_owner:a.current}}e.Fragment=i,e.jsx=l,e.jsxs=l},322:(t,e,n)=>{"use strict";t.exports=n(837)},317:(t,e,n)=>{"use strict";n.r(e),n.d(e,{default:()=>r});const r={}},586:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const r=n(431);e.default=class{BigNum;constructor(){this.BigNum=(t,e)=>new(r.BigNumber.clone({DECIMAL_PLACES:e}))(t)}winstonToAr(t,{formatted:e=!1,decimals:n=12,trim:r=!0}={}){let o=this.stringToBigNum(t,n).shiftedBy(-12);return e?o.toFormat(n):o.toFixed(n)}arToWinston(t,{formatted:e=!1}={}){let n=this.stringToBigNum(t).shiftedBy(12);return e?n.toFormat():n.toFixed(0)}compare(t,e){let n=this.stringToBigNum(t),r=this.stringToBigNum(e);return n.comparedTo(r)}isEqual(t,e){return 0===this.compare(t,e)}isLessThan(t,e){let n=this.stringToBigNum(t),r=this.stringToBigNum(e);return n.isLessThan(r)}isGreaterThan(t,e){let n=this.stringToBigNum(t),r=this.stringToBigNum(e);return n.isGreaterThan(r)}add(t,e){let n=this.stringToBigNum(t);this.stringToBigNum(e);return n.plus(e).toFixed(0)}sub(t,e){let n=this.stringToBigNum(t);this.stringToBigNum(e);return n.minus(e).toFixed(0)}stringToBigNum(t,e=12){return this.BigNum(t,e)}}},759:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const r=n(498);n(317);class o{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(`${o.HASH_ENDPOINT}${t}`);if(200===e.status)return e.data;throw 404===e.status?new r.default("BLOCK_NOT_FOUND"):new Error(`Error while loading block data: ${e}`)}async getByHeight(t){const e=await this.api.get(`${o.HEIGHT_ENDPOINT}${t}`);if(200===e.status)return e.data;throw 404===e.status?new r.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=o},879:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const r=n(498),o=n(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,r.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,r.getError)(e)}`)}async getChunkData(t){const e=await this.getChunk(t);return o.b64UrlToBuffer(e.chunk)}firstChunkOffset(t){return parseInt(t.offset)-parseInt(t.size)+1}async downloadChunkedData(t){const e=await this.getTransactionOffset(t),n=parseInt(e.size),r=parseInt(e.offset)-n+1,o=new Uint8Array(n);let i=0;for(;i<n;){let t;this.api.config.logging&&console.log(`[chunk] ${i}/${n}`);try{t=await this.getChunkData(r+i)}catch(t){console.error(`[chunk] Failed to fetch chunk at offset ${r+i}`),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 ${i}/${n}`);o.set(t,i),i+=t.length}return o}}},536:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const r=n(586),o=n(874),i=n(363),s=n(248),a=n(935),c=n(927),l=n(825),u=n(244),h=n(243),d=n(879),f=n(759);class p{api;wallets;transactions;network;blocks;ar;silo;chunks;static init;static crypto=new i.default;static utils=u;constructor(t){this.api=new o.default(t),this.wallets=new c.default(this.api,p.crypto),this.chunks=new d.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 f.default(this.api,this.network),this.ar=new r.default}get crypto(){return p.crypto}get utils(){return p.utils}getConfig(){return{api:this.api.getConfig(),crypto:null}}async createTransaction(t,e){const n={};if(Object.assign(n,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&&(n.owner=e.n),null==t.last_tx&&(n.last_tx=await this.transactions.getTransactionAnchor()),"string"==typeof t.data&&(t.data=u.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;n.reward=await this.transactions.getPrice(e,n.target)}n.data_root="",n.data_size=t.data?t.data.byteLength.toString():"0",n.data=t.data||new Uint8Array(0);const r=new l.default(n);return await r.getSignatureData(),r}async createSiloTransaction(t,e,n){const r={};if(Object.assign(r,t),!t.data)throw new Error("Silo transactions must have a 'data' value");if(!n)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.");r.owner=e.n}null==t.last_tx&&(r.last_tx=await this.transactions.getTransactionAnchor());const o=await this.silo.parseUri(n);if("string"==typeof t.data){const e=await this.crypto.encrypt(u.stringToBuffer(t.data),o.getEncryptionKey());r.reward=await this.transactions.getPrice(e.byteLength),r.data=u.bufferTob64Url(e)}if(t.data instanceof Uint8Array){const e=await this.crypto.encrypt(t.data,o.getEncryptionKey());r.reward=await this.transactions.getPrice(e.byteLength),r.data=u.bufferTob64Url(e)}const i=new l.default(r);return i.addTag("Silo-Name",o.getAccessKey()),i.addTag("Silo-Version","0.1.0"),i}arql(t){return this.api.post("/arql",t).then((t=>t.data||[]))}}e.default=p},386:function(t,e,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(e,n);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,o)}:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]}),o=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||Object.prototype.hasOwnProperty.call(e,n)||r(e,t,n)};Object.defineProperty(e,"__esModule",{value:!0});const i=n(536),s=n(118);i.default.init=function(t={}){const e={host:"arweave.net",port:443,protocol:"https"};if("object"!=typeof location||!location.protocol||!location.hostname)return new i.default({...t,...e});const n=location.protocol.replace(":",""),r=location.hostname,o=location.port?parseInt(location.port):"https"==n?443:80,a=(0,s.getDefaultConfig)(n,r),c=t.protocol||a.protocol,l=t.host||a.host,u=t.port||a.port||o;return new i.default({...t,host:l,protocol:c,port:u})},"object"==typeof globalThis?globalThis.Arweave=i.default:"object"==typeof self&&(self.Arweave=i.default),o(n(536),e),e.default=i.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",n=t.port||("https"===e?443:80);return{host:t.host||"127.0.0.1",protocol:e,port:n,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,n){const r=new Headers(n?.headers||{});return r.get("content-type")?.includes("application/json")||r.append("content-type","application/json"),r.append("accept","application/json, text/plain, */*"),await this.request(t,{...n,method:this.METHOD_POST,body:"string"!=typeof e?JSON.stringify(e):e,headers:r})}async request(t,e){const r=new Headers(e?.headers||{}),o=`${this.config.protocol}://${this.config.host}:${this.config.port}`,i=e?.responseType;delete e?.responseType,t.startsWith("/")&&(t=t.slice(1)),this.config.network&&r.append("x-network",this.config.network),this.config.logging&&this.config.logger(`Requesting: ${o}/${t}`);let s=await fetch(`${o}/${t}`,{...e||{},headers:r});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],l=s,u=async()=>{if(c)try{l.data=new TextDecoder(c).decode(await s.arrayBuffer())}catch(t){l.data=await s.text()}else l.data=await s.text()};if("arraybuffer"===i)l.data=await s.arrayBuffer();else if("text"===i)await u();else if("webstream"===i)l.data=n(s.body);else try{let t=await s.clone().json();"object"!=typeof t?await u():l.data=await s.json(),t=null}catch{await u()}return l}};const n=t=>{const e=t;return void 0===e[Symbol.asyncIterator]?(e[Symbol.asyncIterator]=r(t),e):t},r=function(t){return async function*(){const e=t.getReader();try{for(;;){const{done:t,value:n}=await e.read();if(t)return;yield n}}finally{e.releaseLock()}}}},363:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const r=n(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:n}={}){let r=await this.driver.sign({name:"RSA-PSS",saltLength:32},await this.jwkToCryptoKey(t),e);return new Uint8Array(r)}async hash(t,e="SHA-256"){let n=await this.driver.digest(e,t);return new Uint8Array(n)}async verify(t,e,n){const r={kty:"RSA",e:"AQAB",n:t},o=await this.jwkToPublicCryptoKey(r),i=await this.driver.digest("SHA-256",e),s=await this.driver.verify({name:"RSA-PSS",saltLength:0},o,n,e),a=await this.driver.verify({name:"RSA-PSS",saltLength:32},o,n,e),c=await this.driver.verify({name:"RSA-PSS",saltLength:Math.ceil((o.algorithm.modulusLength-1)/8)-i.byteLength-2},o,n,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,n){const o=await this.driver.importKey("raw","string"==typeof e?r.stringToBuffer(e):e,{name:"PBKDF2",length:32},!1,["deriveKey"]),i=await this.driver.deriveKey({name:"PBKDF2",salt:n?r.stringToBuffer(n):r.stringToBuffer("salt"),iterations:1e5,hash:"SHA-256"},o,{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},i,t);return r.concatBuffers([s,a])}async decrypt(t,e,n){const o=await this.driver.importKey("raw","string"==typeof e?r.stringToBuffer(e):e,{name:"PBKDF2",length:32},!1,["deriveKey"]),i=await this.driver.deriveKey({name:"PBKDF2",salt:n?r.stringToBuffer(n):r.stringToBuffer("salt"),iterations:1e5,hash:"SHA-256"},o,{name:"AES-CBC",length:256},!1,["encrypt","decrypt"]),s=t.slice(0,16),a=await this.driver.decrypt({name:"AES-CBC",iv:s},i,t.slice(16));return r.concatBuffers([a])}}},921:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const r=n(536);async function o(t){if(Array.isArray(t)){const e=r.default.utils.concatBuffers([r.default.utils.stringToBuffer("list"),r.default.utils.stringToBuffer(t.length.toString())]);return await i(t,await r.default.crypto.hash(e,"SHA-384"))}const e=r.default.utils.concatBuffers([r.default.utils.stringToBuffer("blob"),r.default.utils.stringToBuffer(t.byteLength.toString())]),n=r.default.utils.concatBuffers([await r.default.crypto.hash(e,"SHA-384"),await r.default.crypto.hash(t,"SHA-384")]);return await r.default.crypto.hash(n,"SHA-384")}async function i(t,e){if(t.length<1)return e;const n=r.default.utils.concatBuffers([e,await o(t[0])]),s=await r.default.crypto.hash(n,"SHA-384");return await i(t.slice(1),s)}e.default=o},498:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.getError=void 0;class n 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=n,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,n)=>{"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 r=n(536),o=n(244);e.MAX_CHUNK_SIZE=262144,e.MIN_CHUNK_SIZE=32768;const i=32,s=32;async function a(t){let n=[],o=t,i=0;for(;o.byteLength>=e.MAX_CHUNK_SIZE;){let t=e.MAX_CHUNK_SIZE,s=o.byteLength-e.MAX_CHUNK_SIZE;s>0&&s<e.MIN_CHUNK_SIZE&&(t=Math.ceil(o.byteLength/2));const a=o.slice(0,t),c=await r.default.crypto.hash(a);i+=a.byteLength,n.push({dataHash:c,minByteRange:i-a.byteLength,maxByteRange:i}),o=o.slice(t)}return n.push({dataHash:await r.default.crypto.hash(o),minByteRange:i,maxByteRange:i+o.byteLength}),n}async function c(t){return Promise.all(t.map((async({dataHash:t,minByteRange:e,maxByteRange:n})=>({type:"leaf",id:await m(await Promise.all([m(t),m(g(n))])),dataHash:t,minByteRange:e,maxByteRange:n}))))}async function l(t){return await u(await c(await a(t)))}async function u(t,e=0){if(t.length<2){return t[0]}const n=[];for(let e=0;e<t.length;e+=2)n.push(await p(t[e],t[e+1]));return u(n,e+1)}function h(t){const e=d(t);return Array.isArray(e)?f(e):[e]}function d(t,e=new Uint8Array,n=0){if("leaf"==t.type)return{offset:t.maxByteRange-1,proof:(0,o.concatBuffers)([e,t.dataHash,g(t.maxByteRange)])};if("branch"==t.type){const r=(0,o.concatBuffers)([e,t.leftChild.id,t.rightChild.id,g(t.byteRange)]);return[d(t.leftChild,r,n+1),d(t.rightChild,r,n+1)]}throw new Error("Unexpected node type")}function f(t){const e=[];return t.forEach((t=>{Array.isArray(t)?e.push(...f(t)):e.push(t)})),e}async function p(t,e){if(!e)return t;return{type:"branch",id:await m([await m(t.id),await m(e.id),await m(g(t.maxByteRange))]),byteRange:t.maxByteRange,maxByteRange:e.maxByteRange,leftChild:t,rightChild:e}}async function m(t){return Array.isArray(t)&&(t=r.default.utils.concatBuffers(t)),new Uint8Array(await r.default.crypto.hash(t))}function g(t){const e=new Uint8Array(i);for(var n=e.length-1;n>=0;n--){var r=t%256;e[n]=r,t=(t-r)/256}return e}function y(t){let e=0;for(var n=0;n<t.length;n++)e*=256,e+=t[n];return e}e.chunkData=a,e.generateLeaves=c,e.computeRootHash=async function(t){return(await l(t)).id},e.generateTree=l,e.generateTransactionChunks=async function(t){const e=await a(t),n=await c(e),r=await u(n),o=await h(r),i=e.slice(-1)[0];return i.maxByteRange-i.minByteRange==0&&(e.splice(e.length-1,1),o.splice(o.length-1,1)),{data_root:r.id,chunks:e,proofs:o}},e.buildLayers=u,e.generateProofs=h,e.arrayFlatten=f,e.intToBuffer=g,e.bufferToInt=y;e.arrayCompare=(t,e)=>t.every(((t,n)=>e[n]===t)),e.validatePath=async function t(n,r,o,a,c){if(a<=0)return!1;if(r>=a)return t(n,0,a-1,a,c);if(r<0)return t(n,0,0,a,c);if(c.length==s+i){const t=c.slice(0,s),r=c.slice(t.length,t.length+i),l=await m([await m(t),await m(r)]);return!!(0,e.arrayCompare)(n,l)&&{offset:a-1,leftBound:o,rightBound:a,chunkSize:a-o}}const l=c.slice(0,s),u=c.slice(l.length,l.length+s),h=c.slice(l.length+u.length,l.length+u.length+i),d=y(h),f=c.slice(l.length+u.length+h.length),p=await m([await m(l),await m(u),await m(h)]);return!!(0,e.arrayCompare)(n,p)&&(r<d?await t(l,r,o,Math.min(a,d),f):await t(u,r,Math.max(o,d),a,f))},e.debug=async function t(e,n=""){if(e.byteLength<1)return n;const r=e.slice(0,s),o=e.slice(r.length,r.length+s),a=e.slice(r.length+o.length,r.length+o.length+i),c=y(a),l=e.slice(r.length+o.length+a.length),u=await m([await m(r),await m(o),await m(a)]);return t(l,`${n}\n${JSON.stringify(Buffer.from(r))},${JSON.stringify(Buffer.from(o))},${c} => ${JSON.stringify(u)}`)}},246:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.TransactionUploader=void 0;const r=n(825),o=n(244),i=n(498),s=n(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 r.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 n=this.transaction.getChunk(t||this.chunkIndex,this.data);if(!await(0,s.validatePath)(this.transaction.chunks.data_root,parseInt(n.offset),0,parseInt(n.data_size),o.b64UrlToBuffer(n.data_path)))throw new Error(`Unable to validate chunk ${this.chunkIndex}`);const r=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=r.status,200==this.lastResponseStatus)this.chunkIndex++;else if(this.lastResponseError=(0,i.getError)(r),a.includes(this.lastResponseError))throw new Error(`Fatal error uploading chunk ${this.chunkIndex}: ${this.lastResponseError}`)}static async fromSerialized(t,e,n){if(!e||"number"!=typeof e.chunkIndex||"object"!=typeof e.transaction)throw new Error("Serialized object does not match expected format.");var o=new r.default(e.transaction);o.chunks||await o.prepareChunks(n);const i=new c(t,o);if(i.chunkIndex=e.chunkIndex,i.lastRequestTimeEnd=e.lastRequestTimeEnd,i.lastResponseError=e.lastResponseError,i.lastResponseStatus=e.lastResponseStatus,i.txPosted=e.txPosted,i.data=n,i.transaction.data_root!==e.transaction.data_root)throw new Error("Data mismatch: Uploader doesn't match provided data.");return i}static async fromTransactionId(t,e){const n=await t.get(`tx/${e}`);if(200!==n.status)throw new Error(`Tx ${e} not found: ${n.status}`);const r=n.data;r.data=new Uint8Array(0);return{txPosted:!0,chunkIndex:0,lastResponseError:"",lastRequestTimeEnd:0,lastResponseStatus:0,transaction:r}}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,i.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,i.getError)(t),new Error(`Unable to upload transaction: ${t.status}, ${this.lastResponseError}`);this.txPosted=!0}}e.TransactionUploader=c},825:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Tag=void 0;const r=n(244),o=n(921),i=n(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?r.bufferToString(this[t]):e&&e.decode&&!e.string?this[t]:r.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?r.b64UrlToString(this[t]):r.b64UrlToBuffer(this[t]):this[t]}}class a extends s{name;value;constructor(t,e,n=!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=r.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(r.stringToB64Url(t),r.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:r.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:n,tags:r,signature:o}){this.id=t,this.owner=e,n&&(this.reward=n),r&&(this.tags=r),this.signature=o}async prepareChunks(t){!this.chunks&&t.byteLength>0&&(this.chunks=await(0,i.generateTransactionChunks)(t),this.data_root=r.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 n=this.chunks.proofs[t],o=this.chunks.chunks[t];return{data_root:this.data_root,data_size:this.data_size,data_path:r.bufferTob64Url(n.proof),offset:n.offset.toString(),chunk:r.bufferTob64Url(e.slice(o.minByteRange,o.maxByteRange))}}async getSignatureData(){switch(this.format){case 1:let t=this.tags.reduce(((t,e)=>r.concatBuffers([t,e.get("name",{decode:!0,string:!1}),e.get("value",{decode:!0,string:!1})])),new Uint8Array);return r.concatBuffers([this.get("owner",{decode:!0,string:!1}),this.get("target",{decode:!0,string:!1}),this.get("data",{decode:!0,string:!1}),r.stringToBuffer(this.quantity),r.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,o.default)([r.stringToBuffer(this.format.toString()),this.get("owner",{decode:!0,string:!1}),this.get("target",{decode:!0,string:!1}),r.stringToBuffer(this.quantity),r.stringToBuffer(this.reward),this.get("last_tx",{decode:!0,string:!1}),e,r.stringToBuffer(this.data_size),this.get("data_root",{decode:!0,string:!1})]);default:throw new Error(`Unexpected transaction format: ${this.format}`)}}}},244:(t,e,n)=>{"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 r=n(742);function o(t){return new TextDecoder("utf-8",{fatal:!0}).decode(t)}function i(t){return(new TextEncoder).encode(t)}function s(t){return new Uint8Array(r.toByteArray(u(t)))}function a(t){return r.fromByteArray(new Uint8Array(t))}function c(t){return l(a(t))}function l(t){try{return t.replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"")}catch(t){throw new Error("Failed to encode string",{cause:t})}}function u(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 n=0;n<t.length;n++)e+=t[n].byteLength;let n=new Uint8Array(e),r=0;n.set(new Uint8Array(t[0]),r),r+=t[0].byteLength;for(let e=1;e<t.length;e++)n.set(new Uint8Array(t[e]),r),r+=t[e].byteLength;return n},e.b64UrlToString=function(t){return o(s(t))},e.bufferToString=o,e.stringToBuffer=i,e.stringToB64Url=function(t){return c(i(t))},e.b64UrlToBuffer=s,e.bufferTob64=a,e.bufferTob64Url=c,e.b64UrlEncode=l,e.b64UrlDecode=u},118:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.getDefaultConfig=void 0;e.getDefaultConfig=(t,e)=>{if(((t,e)=>{const n=/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/,r=e.split("."),o=r[r.length-1],i=["localhost","[::1]"];return i.includes(e)||"file"==t||i.includes(o)||!!e.match(n)||!!o.match(n)})(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 n=e.split(".");if(n.length>=3){n.shift();return{protocol:t,host:n.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,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.SiloResource=void 0;const r=n(244);e.default=class{api;crypto;transactions;constructor(t,e,n){this.api=t,this.crypto=e,this.transactions=n}async get(t){if(!t)throw new Error("No Silo URI specified");const e=await this.parseUri(t),n=await this.transactions.search("Silo-Name",e.getAccessKey());if(0==n.length)throw new Error(`No data could be found for the Silo URI: ${t}`);const r=await this.transactions.get(n[0]);if(!r)throw new Error(`No data could be found for the Silo URI: ${t}`);const o=r.get("data",{decode:!0,string:!1});return this.crypto.decrypt(o,e.getEncryptionKey())}async readTransactionData(t,e){if(!e)throw new Error("No Silo URI specified");const n=await this.parseUri(e),r=t.get("data",{decode:!0,string:!1});return this.crypto.decrypt(r,n.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 n=e[1],i=Math.pow(2,parseInt(e[2])),s=await this.hash(r.stringToBuffer(n),i),a=r.bufferTob64(s.slice(0,15)),c=await this.hash(s.slice(16,31),1);return new o(t,a,c)}async hash(t,e){let n=await this.crypto.hash(t);for(let t=0;t<e-1;t++)n=await this.crypto.hash(n);return n}};class o{uri;accessKey;encryptionKey;constructor(t,e,n){this.uri=t,this.accessKey=e,this.encryptionKey=n}getUri(){return this.uri}getAccessKey(){return this.accessKey}getEncryptionKey(){return this.encryptionKey}}e.SiloResource=o},935:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const r=n(498),o=n(825),i=n(244),s=n(246);n(317);e.default=class{api;crypto;chunks;constructor(t,e,n){this.api=t,this.crypto=e,this.chunks=n}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 n=e?`price/${t}/${e}`:`price/${t}`;const r=await this.api.get(n);if(!/^\d+$/.test(r.data)||!r.ok)throw new Error(`Could not getPrice. Received: ${r.data}. Status: ${r.status}, ${r.statusText}`);return r.data}async get(t){const e=await this.api.get(`tx/${t}`);if(200==e.status){const n=parseInt(e.data.data_size);if(e.data.format>=2&&n>0&&n<=12582912){const n=await this.getData(t);return new o.default({...e.data,data:n})}return new o.default({...e.data,format:e.data.format||1})}if(404==e.status)throw new r.default("TX_NOT_FOUND");if(410==e.status)throw new r.default("TX_FAILED");throw new r.default("TX_INVALID")}fromRaw(t){return new o.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 n;try{n=await this.chunks.downloadChunkedData(t)}catch(e){console.error(`Error while trying to download chunked data for ${t}`),console.error(e)}if(!n){console.warn(`Falling back to gateway cache for ${t}`);try{const{data:e,ok:r,status:o,statusText:i}=await this.api.get(`/${t}`,{responseType:"arraybuffer"});if(!r)throw new Error("Bad http status code",{cause:{status:o,statusText:i}});n=e}catch(e){console.error(`Error while trying to download contiguous data from gateway cache for ${t}`),console.error(e)}}if(!n)throw new Error(`${t} data was not found!`);return e&&e.decode&&!e.string?n:e&&e.decode&&e.string?i.bufferToString(n):i.bufferTob64Url(n)}async sign(t,e,n){const r="object"==typeof e&&(t=>{let e=!0;return["n","e","d","p","q","dp","dq","qi"].map((n=>!(n in t)&&(e=!1))),e})(e),o="object"==typeof arweaveWallet;if(!r&&!o)throw new Error("No valid JWK or external wallet found to sign transaction.");if(r){t.setOwner(e.n);let r=await t.getSignatureData(),o=await this.crypto.sign(e,r,n),s=await this.crypto.hash(o);t.setSignature({id:i.bufferTob64Url(s),owner:e.n,signature:i.bufferTob64Url(o)})}else{if(!o)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,n);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(),n=t.get("signature",{decode:!0,string:!1}),r=i.bufferTob64Url(await this.crypto.hash(n));if(t.id!==r)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,n)}async post(t){if("string"==typeof t?t=new o.default(JSON.parse(t)):"function"==typeof t.readInt32BE?t=new o.default(JSON.parse(t.toString())):"object"!=typeof t||t instanceof o.default||(t=new o.default(t)),!(t instanceof o.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 n;if(e instanceof ArrayBuffer&&(e=new Uint8Array(e)),t instanceof o.default){if(e||(e=t.data),!(e instanceof Uint8Array))throw new Error("Data format is invalid");t.chunks||await t.prepareChunks(e),n=new s.TransactionUploader(this.api,t),n.data&&0!==n.data.length||(n.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");n=await s.TransactionUploader.fromSerialized(this.api,t,e)}return n}async*upload(t,e){const n=await this.getUploader(t,e);for(;!n.isComplete;)await n.uploadChunk(),yield n;return n}}},927:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const r=n(244);n(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 r.bufferTob64Url(await this.crypto.hash(r.b64UrlToBuffer(t)))}}},742:(t,e)=>{"use strict";e.byteLength=function(t){var e=a(t),n=e[0],r=e[1];return 3*(n+r)/4-r},e.toByteArray=function(t){var e,n,i=a(t),s=i[0],c=i[1],l=new o(function(t,e,n){return 3*(e+n)/4-n}(0,s,c)),u=0,h=c>0?s-4:s;for(n=0;n<h;n+=4)e=r[t.charCodeAt(n)]<<18|r[t.charCodeAt(n+1)]<<12|r[t.charCodeAt(n+2)]<<6|r[t.charCodeAt(n+3)],l[u++]=e>>16&255,l[u++]=e>>8&255,l[u++]=255&e;2===c&&(e=r[t.charCodeAt(n)]<<2|r[t.charCodeAt(n+1)]>>4,l[u++]=255&e);1===c&&(e=r[t.charCodeAt(n)]<<10|r[t.charCodeAt(n+1)]<<4|r[t.charCodeAt(n+2)]>>2,l[u++]=e>>8&255,l[u++]=255&e);return l},e.fromByteArray=function(t){for(var e,r=t.length,o=r%3,i=[],s=16383,a=0,l=r-o;a<l;a+=s)i.push(c(t,a,a+s>l?l:a+s));1===o?(e=t[r-1],i.push(n[e>>2]+n[e<<4&63]+"==")):2===o&&(e=(t[r-2]<<8)+t[r-1],i.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return i.join("")};for(var n=[],r=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0;s<64;++s)n[s]=i[s],r[i.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 n=t.indexOf("=");return-1===n&&(n=e),[n,n===e?0:4-n%4]}function c(t,e,r){for(var o,i,s=[],a=e;a<r;a+=3)o=(t[a]<<16&16711680)+(t[a+1]<<8&65280)+(255&t[a+2]),s.push(n[(i=o)>>18&63]+n[i>>12&63]+n[i>>6&63]+n[63&i]);return s.join("")}r["-".charCodeAt(0)]=62,r["_".charCodeAt(0)]=63},431:function(t,e,n){var r;!function(o){"use strict";var i,s=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,a=Math.ceil,c=Math.floor,l="[BigNumber Error] ",u=l+"Number primitive has more than 15 significant digits: ",h=1e14,d=14,f=9007199254740991,p=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],m=1e7,g=1e9;function y(t){var e=0|t;return t>0||t===e?e:e-1}function w(t){for(var e,n,r=1,o=t.length,i=t[0]+"";r<o;){for(e=t[r++]+"",n=d-e.length;n--;e="0"+e);i+=e}for(o=i.length;48===i.charCodeAt(--o););return i.slice(0,o+1||1)}function v(t,e){var n,r,o=t.c,i=e.c,s=t.s,a=e.s,c=t.e,l=e.e;if(!s||!a)return null;if(n=o&&!o[0],r=i&&!i[0],n||r)return n?r?0:-a:s;if(s!=a)return s;if(n=s<0,r=c==l,!o||!i)return r?0:!o^n?1:-1;if(!r)return c>l^n?1:-1;for(a=(c=o.length)<(l=i.length)?c:l,s=0;s<a;s++)if(o[s]!=i[s])return o[s]>i[s]^n?1:-1;return c==l?0:c>l^n?1:-1}function b(t,e,n,r){if(t<e||t>n||t!==c(t))throw Error(l+(r||"Argument")+("number"==typeof t?t<e||t>n?" out of range: ":" not an integer: ":" not a primitive number: ")+String(t))}function E(t){var e=t.c.length-1;return y(t.e/d)==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 x(t,e,n){var r,o;if(e<0){for(o=n+".";++e;o+=n);t=o+t}else if(++e>(r=t.length)){for(o=n,e-=r;--e;o+=n);t+=o}else e<r&&(t=t.slice(0,e)+"."+t.slice(e));return t}i=function t(e){var n,r,o,i,T,A,_,k,R,C,P=W.prototype={constructor:W,toString:null,valueOf:null},I=new W(1),O=20,N=4,B=-7,U=21,L=-1e7,j=1e7,D=!1,M=1,V=0,F={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},K="0123456789abcdefghijklmnopqrstuvwxyz",$=!0;function W(t,e){var n,i,a,l,h,p,m,g,y=this;if(!(y instanceof W))return new W(t,e);if(null==e){if(t&&!0===t._isBigNumber)return y.s=t.s,void(!t.c||t.e>j?y.c=y.e=null:t.e<L?y.c=[y.e=0]:(y.e=t.e,y.c=t.c.slice()));if((p="number"==typeof t)&&0*t==0){if(y.s=1/t<0?(t=-t,-1):1,t===~~t){for(l=0,h=t;h>=10;h/=10,l++);return void(l>j?y.c=y.e=null:(y.e=l,y.c=[t]))}g=String(t)}else{if(!s.test(g=String(t)))return o(y,g,p);y.s=45==g.charCodeAt(0)?(g=g.slice(1),-1):1}(l=g.indexOf("."))>-1&&(g=g.replace(".","")),(h=g.search(/e/i))>0?(l<0&&(l=h),l+=+g.slice(h+1),g=g.substring(0,h)):l<0&&(l=g.length)}else{if(b(e,2,K.length,"Base"),10==e&&$)return Z(y=new W(t),O+y.e+1,N);if(g=String(t),p="number"==typeof t){if(0*t!=0)return o(y,g,p,e);if(y.s=1/t<0?(g=g.slice(1),-1):1,W.DEBUG&&g.replace(/^0\.0*|\./,"").length>15)throw Error(u+t)}else y.s=45===g.charCodeAt(0)?(g=g.slice(1),-1):1;for(n=K.slice(0,e),l=h=0,m=g.length;h<m;h++)if(n.indexOf(i=g.charAt(h))<0){if("."==i){if(h>l){l=m;continue}}else if(!a&&(g==g.toUpperCase()&&(g=g.toLowerCase())||g==g.toLowerCase()&&(g=g.toUpperCase()))){a=!0,h=-1,l=0;continue}return o(y,String(t),p,e)}p=!1,(l=(g=r(g,e,10,y.s)).indexOf("."))>-1?g=g.replace(".",""):l=g.length}for(h=0;48===g.charCodeAt(h);h++);for(m=g.length;48===g.charCodeAt(--m););if(g=g.slice(h,++m)){if(m-=h,p&&W.DEBUG&&m>15&&(t>f||t!==c(t)))throw Error(u+y.s*t);if((l=l-h-1)>j)y.c=y.e=null;else if(l<L)y.c=[y.e=0];else{if(y.e=l,y.c=[],h=(l+1)%d,l<0&&(h+=d),h<m){for(h&&y.c.push(+g.slice(0,h)),m-=d;h<m;)y.c.push(+g.slice(h,h+=d));h=d-(g=g.slice(h)).length}else h-=m;for(;h--;g+="0");y.c.push(+g)}}else y.c=[y.e=0]}function z(t,e,n,r){var o,i,s,a,c;if(null==n?n=N:b(n,0,8),!t.c)return t.toString();if(o=t.c[0],s=t.e,null==e)c=w(t.c),c=1==r||2==r&&(s<=B||s>=U)?S(c,s):x(c,s,"0");else if(i=(t=Z(new W(t),e,n)).e,a=(c=w(t.c)).length,1==r||2==r&&(e<=i||i<=B)){for(;a<e;c+="0",a++);c=S(c,i)}else if(e-=s,c=x(c,i,"0"),i+1>a){if(--e>0)for(c+=".";e--;c+="0");}else if((e+=i-a)>0)for(i+1==a&&(c+=".");e--;c+="0");return t.s<0&&o?"-"+c:c}function H(t,e){for(var n,r,o=1,i=new W(t[0]);o<t.length;o++)(!(r=new W(t[o])).s||(n=v(i,r))===e||0===n&&i.s===e)&&(i=r);return i}function q(t,e,n){for(var r=1,o=e.length;!e[--o];e.pop());for(o=e[0];o>=10;o/=10,r++);return(n=r+n*d-1)>j?t.c=t.e=null:n<L?t.c=[t.e=0]:(t.e=n,t.c=e),t}function Z(t,e,n,r){var o,i,s,l,u,f,m,g=t.c,y=p;if(g){t:{for(o=1,l=g[0];l>=10;l/=10,o++);if((i=e-o)<0)i+=d,s=e,u=g[f=0],m=c(u/y[o-s-1]%10);else if((f=a((i+1)/d))>=g.length){if(!r)break t;for(;g.length<=f;g.push(0));u=m=0,o=1,s=(i%=d)-d+1}else{for(u=l=g[f],o=1;l>=10;l/=10,o++);m=(s=(i%=d)-d+o)<0?0:c(u/y[o-s-1]%10)}if(r=r||e<0||null!=g[f+1]||(s<0?u:u%y[o-s-1]),r=n<4?(m||r)&&(0==n||n==(t.s<0?3:2)):m>5||5==m&&(4==n||r||6==n&&(i>0?s>0?u/y[o-s]:0:g[f-1])%10&1||n==(t.s<0?8:7)),e<1||!g[0])return g.length=0,r?(e-=t.e+1,g[0]=y[(d-e%d)%d],t.e=-e||0):g[0]=t.e=0,t;if(0==i?(g.length=f,l=1,f--):(g.length=f+1,l=y[d-i],g[f]=s>0?c(u/y[o-s]%y[s])*l:0),r)for(;;){if(0==f){for(i=1,s=g[0];s>=10;s/=10,i++);for(s=g[0]+=l,l=1;s>=10;s/=10,l++);i!=l&&(t.e++,g[0]==h&&(g[0]=1));break}if(g[f]+=l,g[f]!=h)break;g[f--]=0,l=1}for(i=g.length;0===g[--i];g.pop());}t.e>j?t.c=t.e=null:t.e<L&&(t.c=[t.e=0])}return t}function X(t){var e,n=t.e;return null===n?t.toString():(e=w(t.c),e=n<=B||n>=U?S(e,n):x(e,n,"0"),t.s<0?"-"+e:e)}return W.clone=t,W.ROUND_UP=0,W.ROUND_DOWN=1,W.ROUND_CEIL=2,W.ROUND_FLOOR=3,W.ROUND_HALF_UP=4,W.ROUND_HALF_DOWN=5,W.ROUND_HALF_EVEN=6,W.ROUND_HALF_CEIL=7,W.ROUND_HALF_FLOOR=8,W.EUCLID=9,W.config=W.set=function(t){var e,n;if(null!=t){if("object"!=typeof t)throw Error(l+"Object expected: "+t);if(t.hasOwnProperty(e="DECIMAL_PLACES")&&(b(n=t[e],0,g,e),O=n),t.hasOwnProperty(e="ROUNDING_MODE")&&(b(n=t[e],0,8,e),N=n),t.hasOwnProperty(e="EXPONENTIAL_AT")&&((n=t[e])&&n.pop?(b(n[0],-g,0,e),b(n[1],0,g,e),B=n[0],U=n[1]):(b(n,-g,g,e),B=-(U=n<0?-n:n))),t.hasOwnProperty(e="RANGE"))if((n=t[e])&&n.pop)b(n[0],-g,-1,e),b(n[1],1,g,e),L=n[0],j=n[1];else{if(b(n,-g,g,e),!n)throw Error(l+e+" cannot be zero: "+n);L=-(j=n<0?-n:n)}if(t.hasOwnProperty(e="CRYPTO")){if((n=t[e])!==!!n)throw Error(l+e+" not true or false: "+n);if(n){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw D=!n,Error(l+"crypto unavailable");D=n}else D=n}if(t.hasOwnProperty(e="MODULO_MODE")&&(b(n=t[e],0,9,e),M=n),t.hasOwnProperty(e="POW_PRECISION")&&(b(n=t[e],0,g,e),V=n),t.hasOwnProperty(e="FORMAT")){if("object"!=typeof(n=t[e]))throw Error(l+e+" not an object: "+n);F=n}if(t.hasOwnProperty(e="ALPHABET")){if("string"!=typeof(n=t[e])||/^.?$|[+\-.\s]|(.).*\1/.test(n))throw Error(l+e+" invalid: "+n);$="0123456789"==n.slice(0,10),K=n}}return{DECIMAL_PLACES:O,ROUNDING_MODE:N,EXPONENTIAL_AT:[B,U],RANGE:[L,j],CRYPTO:D,MODULO_MODE:M,POW_PRECISION:V,FORMAT:F,ALPHABET:K}},W.isBigNumber=function(t){if(!t||!0!==t._isBigNumber)return!1;if(!W.DEBUG)return!0;var e,n,r=t.c,o=t.e,i=t.s;t:if("[object Array]"=={}.toString.call(r)){if((1===i||-1===i)&&o>=-g&&o<=g&&o===c(o)){if(0===r[0]){if(0===o&&1===r.length)return!0;break t}if((e=(o+1)%d)<1&&(e+=d),String(r[0]).length==e){for(e=0;e<r.length;e++)if((n=r[e])<0||n>=h||n!==c(n))break t;if(0!==n)return!0}}}else if(null===r&&null===o&&(null===i||1===i||-1===i))return!0;throw Error(l+"Invalid BigNumber: "+t)},W.maximum=W.max=function(){return H(arguments,-1)},W.minimum=W.min=function(){return H(arguments,1)},W.random=(i=9007199254740992,T=Math.random()*i&2097151?function(){return c(Math.random()*i)}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)},function(t){var e,n,r,o,i,s=0,u=[],h=new W(I);if(null==t?t=O:b(t,0,g),o=a(t/d),D)if(crypto.getRandomValues){for(e=crypto.getRandomValues(new Uint32Array(o*=2));s<o;)(i=131072*e[s]+(e[s+1]>>>11))>=9e15?(n=crypto.getRandomValues(new Uint32Array(2)),e[s]=n[0],e[s+1]=n[1]):(u.push(i%1e14),s+=2);s=o/2}else{if(!crypto.randomBytes)throw D=!1,Error(l+"crypto unavailable");for(e=crypto.randomBytes(o*=7);s<o;)(i=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):(u.push(i%1e14),s+=7);s=o/7}if(!D)for(;s<o;)(i=T())<9e15&&(u[s++]=i%1e14);for(o=u[--s],t%=d,o&&t&&(i=p[d-t],u[s]=c(o/i)*i);0===u[s];u.pop(),s--);if(s<0)u=[r=0];else{for(r=-1;0===u[0];u.splice(0,1),r-=d);for(s=1,i=u[0];i>=10;i/=10,s++);s<d&&(r-=d-s)}return h.e=r,h.c=u,h}),W.sum=function(){for(var t=1,e=arguments,n=new W(e[0]);t<e.length;)n=n.plus(e[t++]);return n},r=function(){var t="0123456789";function e(t,e,n,r){for(var o,i,s=[0],a=0,c=t.length;a<c;){for(i=s.length;i--;s[i]*=e);for(s[0]+=r.indexOf(t.charAt(a++)),o=0;o<s.length;o++)s[o]>n-1&&(null==s[o+1]&&(s[o+1]=0),s[o+1]+=s[o]/n|0,s[o]%=n)}return s.reverse()}return function(r,o,i,s,a){var c,l,u,h,d,f,p,m,g=r.indexOf("."),y=O,v=N;for(g>=0&&(h=V,V=0,r=r.replace(".",""),f=(m=new W(o)).pow(r.length-g),V=h,m.c=e(x(w(f.c),f.e,"0"),10,i,t),m.e=m.c.length),u=h=(p=e(r,o,i,a?(c=K,t):(c=t,K))).length;0==p[--h];p.pop());if(!p[0])return c.charAt(0);if(g<0?--u:(f.c=p,f.e=u,f.s=s,p=(f=n(f,m,y,v,i)).c,d=f.r,u=f.e),g=p[l=u+y+1],h=i/2,d=d||l<0||null!=p[l+1],d=v<4?(null!=g||d)&&(0==v||v==(f.s<0?3:2)):g>h||g==h&&(4==v||d||6==v&&1&p[l-1]||v==(f.s<0?8:7)),l<1||!p[0])r=d?x(c.charAt(1),-y,c.charAt(0)):c.charAt(0);else{if(p.length=l,d)for(--i;++p[--l]>i;)p[l]=0,l||(++u,p=[1].concat(p));for(h=p.length;!p[--h];);for(g=0,r="";g<=h;r+=c.charAt(p[g++]));r=x(r,u,c.charAt(0))}return r}}(),n=function(){function t(t,e,n){var r,o,i,s,a=0,c=t.length,l=e%m,u=e/m|0;for(t=t.slice();c--;)a=((o=l*(i=t[c]%m)+(r=u*i+(s=t[c]/m|0)*l)%m*m+a)/n|0)+(r/m|0)+u*s,t[c]=o%n;return a&&(t=[a].concat(t)),t}function e(t,e,n,r){var o,i;if(n!=r)i=n>r?1:-1;else for(o=i=0;o<n;o++)if(t[o]!=e[o]){i=t[o]>e[o]?1:-1;break}return i}function n(t,e,n,r){for(var o=0;n--;)t[n]-=o,o=t[n]<e[n]?1:0,t[n]=o*r+t[n]-e[n];for(;!t[0]&&t.length>1;t.splice(0,1));}return function(r,o,i,s,a){var l,u,f,p,m,g,w,v,b,E,S,x,T,A,_,k,R,C=r.s==o.s?1:-1,P=r.c,I=o.c;if(!(P&&P[0]&&I&&I[0]))return new W(r.s&&o.s&&(P?!I||P[0]!=I[0]:I)?P&&0==P[0]||!I?0*C:C/0:NaN);for(b=(v=new W(C)).c=[],C=i+(u=r.e-o.e)+1,a||(a=h,u=y(r.e/d)-y(o.e/d),C=C/d|0),f=0;I[f]==(P[f]||0);f++);if(I[f]>(P[f]||0)&&u--,C<0)b.push(1),p=!0;else{for(A=P.length,k=I.length,f=0,C+=2,(m=c(a/(I[0]+1)))>1&&(I=t(I,m,a),P=t(P,m,a),k=I.length,A=P.length),T=k,S=(E=P.slice(0,k)).length;S<k;E[S++]=0);R=I.slice(),R=[0].concat(R),_=I[0],I[1]>=a/2&&_++;do{if(m=0,(l=e(I,E,k,S))<0){if(x=E[0],k!=S&&(x=x*a+(E[1]||0)),(m=c(x/_))>1)for(m>=a&&(m=a-1),w=(g=t(I,m,a)).length,S=E.length;1==e(g,E,w,S);)m--,n(g,k<w?R:I,w,a),w=g.length,l=1;else 0==m&&(l=m=1),w=(g=I.slice()).length;if(w<S&&(g=[0].concat(g)),n(E,g,S,a),S=E.length,-1==l)for(;e(I,E,k,S)<1;)m++,n(E,k<S?R:I,S,a),S=E.length}else 0===l&&(m++,E=[0]);b[f++]=m,E[0]?E[S++]=P[T]||0:(E=[P[T]],S=1)}while((T++<A||null!=E[0])&&C--);p=null!=E[0],b[0]||b.splice(0,1)}if(a==h){for(f=1,C=b[0];C>=10;C/=10,f++);Z(v,i+(v.e=f+u*d-1)+1,s,p)}else v.e=u,v.r=+p;return v}}(),A=/^(-?)0([xbo])(?=\w[\w.]*$)/i,_=/^([^.]+)\.$/,k=/^\.([^.]+)$/,R=/^-?(Infinity|NaN)$/,C=/^\s*\+(?=[\w.])|^\s+|\s+$/g,o=function(t,e,n,r){var o,i=n?e:e.replace(C,"");if(R.test(i))t.s=isNaN(i)?null:i<0?-1:1;else{if(!n&&(i=i.replace(A,(function(t,e,n){return o="x"==(n=n.toLowerCase())?16:"b"==n?2:8,r&&r!=o?t:e})),r&&(o=r,i=i.replace(_,"$1").replace(k,"0.$1")),e!=i))return new W(i,o);if(W.DEBUG)throw Error(l+"Not a"+(r?" base "+r:"")+" number: "+e);t.s=null}t.c=t.e=null},P.absoluteValue=P.abs=function(){var t=new W(this);return t.s<0&&(t.s=1),t},P.comparedTo=function(t,e){return v(this,new W(t,e))},P.decimalPlaces=P.dp=function(t,e){var n,r,o,i=this;if(null!=t)return b(t,0,g),null==e?e=N:b(e,0,8),Z(new W(i),t+i.e+1,e);if(!(n=i.c))return null;if(r=((o=n.length-1)-y(this.e/d))*d,o=n[o])for(;o%10==0;o/=10,r--);return r<0&&(r=0),r},P.dividedBy=P.div=function(t,e){return n(this,new W(t,e),O,N)},P.dividedToIntegerBy=P.idiv=function(t,e){return n(this,new W(t,e),0,1)},P.exponentiatedBy=P.pow=function(t,e){var n,r,o,i,s,u,h,f,p=this;if((t=new W(t)).c&&!t.isInteger())throw Error(l+"Exponent not an integer: "+X(t));if(null!=e&&(e=new W(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 f=new W(Math.pow(+X(p),s?t.s*(2-E(t)):+X(t))),e?f.mod(e):f;if(u=t.s<0,e){if(e.c?!e.c[0]:!e.s)return new W(NaN);(r=!u&&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 i=p.s<0&&E(t)?-0:0,p.e>-1&&(i=1/i),new W(u?1/i:i);V&&(i=a(V/d+2))}for(s?(n=new W(.5),u&&(t.s=1),h=E(t)):h=(o=Math.abs(+X(t)))%2,f=new W(I);;){if(h){if(!(f=f.times(p)).c)break;i?f.c.length>i&&(f.c.length=i):r&&(f=f.mod(e))}if(o){if(0===(o=c(o/2)))break;h=o%2}else if(Z(t=t.times(n),t.e+1,1),t.e>14)h=E(t);else{if(0===(o=+X(t)))break;h=o%2}p=p.times(p),i?p.c&&p.c.length>i&&(p.c.length=i):r&&(p=p.mod(e))}return r?f:(u&&(f=I.div(f)),e?f.mod(e):i?Z(f,V,N,undefined):f)},P.integerValue=function(t){var e=new W(this);return null==t?t=N:b(t,0,8),Z(e,e.e+1,t)},P.isEqualTo=P.eq=function(t,e){return 0===v(this,new W(t,e))},P.isFinite=function(){return!!this.c},P.isGreaterThan=P.gt=function(t,e){return v(this,new W(t,e))>0},P.isGreaterThanOrEqualTo=P.gte=function(t,e){return 1===(e=v(this,new W(t,e)))||0===e},P.isInteger=function(){return!!this.c&&y(this.e/d)>this.c.length-2},P.isLessThan=P.lt=function(t,e){return v(this,new W(t,e))<0},P.isLessThanOrEqualTo=P.lte=function(t,e){return-1===(e=v(this,new W(t,e)))||0===e},P.isNaN=function(){return!this.s},P.isNegative=function(){return this.s<0},P.isPositive=function(){return this.s>0},P.isZero=function(){return!!this.c&&0==this.c[0]},P.minus=function(t,e){var n,r,o,i,s=this,a=s.s;if(e=(t=new W(t,e)).s,!a||!e)return new W(NaN);if(a!=e)return t.s=-e,s.plus(t);var c=s.e/d,l=t.e/d,u=s.c,f=t.c;if(!c||!l){if(!u||!f)return u?(t.s=-e,t):new W(f?s:NaN);if(!u[0]||!f[0])return f[0]?(t.s=-e,t):new W(u[0]?s:3==N?-0:0)}if(c=y(c),l=y(l),u=u.slice(),a=c-l){for((i=a<0)?(a=-a,o=u):(l=c,o=f),o.reverse(),e=a;e--;o.push(0));o.reverse()}else for(r=(i=(a=u.length)<(e=f.length))?a:e,a=e=0;e<r;e++)if(u[e]!=f[e]){i=u[e]<f[e];break}if(i&&(o=u,u=f,f=o,t.s=-t.s),(e=(r=f.length)-(n=u.length))>0)for(;e--;u[n++]=0);for(e=h-1;r>a;){if(u[--r]<f[r]){for(n=r;n&&!u[--n];u[n]=e);--u[n],u[r]+=h}u[r]-=f[r]}for(;0==u[0];u.splice(0,1),--l);return u[0]?q(t,u,l):(t.s=3==N?-1:1,t.c=[t.e=0],t)},P.modulo=P.mod=function(t,e){var r,o,i=this;return t=new W(t,e),!i.c||!t.s||t.c&&!t.c[0]?new W(NaN):!t.c||i.c&&!i.c[0]?new W(i):(9==M?(o=t.s,t.s=1,r=n(i,t,0,3),t.s=o,r.s*=o):r=n(i,t,0,M),(t=i.minus(r.times(t))).c[0]||1!=M||(t.s=i.s),t)},P.multipliedBy=P.times=function(t,e){var n,r,o,i,s,a,c,l,u,f,p,g,w,v,b,E=this,S=E.c,x=(t=new W(t,e)).c;if(!(S&&x&&S[0]&&x[0]))return!E.s||!t.s||S&&!S[0]&&!x||x&&!x[0]&&!S?t.c=t.e=t.s=null:(t.s*=E.s,S&&x?(t.c=[0],t.e=0):t.c=t.e=null),t;for(r=y(E.e/d)+y(t.e/d),t.s*=E.s,(c=S.length)<(f=x.length)&&(w=S,S=x,x=w,o=c,c=f,f=o),o=c+f,w=[];o--;w.push(0));for(v=h,b=m,o=f;--o>=0;){for(n=0,p=x[o]%b,g=x[o]/b|0,i=o+(s=c);i>o;)n=((l=p*(l=S[--s]%b)+(a=g*l+(u=S[s]/b|0)*p)%b*b+w[i]+n)/v|0)+(a/b|0)+g*u,w[i--]=l%v;w[i]=n}return n?++r:w.splice(0,1),q(t,w,r)},P.negated=function(){var t=new W(this);return t.s=-t.s||null,t},P.plus=function(t,e){var n,r=this,o=r.s;if(e=(t=new W(t,e)).s,!o||!e)return new W(NaN);if(o!=e)return t.s=-e,r.minus(t);var i=r.e/d,s=t.e/d,a=r.c,c=t.c;if(!i||!s){if(!a||!c)return new W(o/0);if(!a[0]||!c[0])return c[0]?t:new W(a[0]?r:0*o)}if(i=y(i),s=y(s),a=a.slice(),o=i-s){for(o>0?(s=i,n=c):(o=-o,n=a),n.reverse();o--;n.push(0));n.reverse()}for((o=a.length)-(e=c.length)<0&&(n=c,c=a,a=n,e=o),o=0;e;)o=(a[--e]=a[e]+c[e]+o)/h|0,a[e]=h===a[e]?0:a[e]%h;return o&&(a=[o].concat(a),++s),q(t,a,s)},P.precision=P.sd=function(t,e){var n,r,o,i=this;if(null!=t&&t!==!!t)return b(t,1,g),null==e?e=N:b(e,0,8),Z(new W(i),t,e);if(!(n=i.c))return null;if(r=(o=n.length-1)*d+1,o=n[o]){for(;o%10==0;o/=10,r--);for(o=n[0];o>=10;o/=10,r++);}return t&&i.e+1>r&&(r=i.e+1),r},P.shiftedBy=function(t){return b(t,-9007199254740991,f),this.times("1e"+t)},P.squareRoot=P.sqrt=function(){var t,e,r,o,i,s=this,a=s.c,c=s.s,l=s.e,u=O+4,h=new W("0.5");if(1!==c||!a||!a[0])return new W(!c||c<0&&(!a||a[0])?NaN:a?s:1/0);if(0==(c=Math.sqrt(+X(s)))||c==1/0?(((e=w(a)).length+l)%2==0&&(e+="0"),c=Math.sqrt(+e),l=y((l+1)/2)-(l<0||l%2),r=new W(e=c==1/0?"5e"+l:(e=c.toExponential()).slice(0,e.indexOf("e")+1)+l)):r=new W(c+""),r.c[0])for((c=(l=r.e)+u)<3&&(c=0);;)if(i=r,r=h.times(i.plus(n(s,i,u,1))),w(i.c).slice(0,c)===(e=w(r.c)).slice(0,c)){if(r.e<l&&--c,"9999"!=(e=e.slice(c-3,c+1))&&(o||"4999"!=e)){+e&&(+e.slice(1)||"5"!=e.charAt(0))||(Z(r,r.e+O+2,1),t=!r.times(r).eq(s));break}if(!o&&(Z(i,i.e+O+2,0),i.times(i).eq(s))){r=i;break}u+=4,c+=4,o=1}return Z(r,r.e+O+1,N,t)},P.toExponential=function(t,e){return null!=t&&(b(t,0,g),t++),z(this,t,e,1)},P.toFixed=function(t,e){return null!=t&&(b(t,0,g),t=t+this.e+1),z(this,t,e)},P.toFormat=function(t,e,n){var r,o=this;if(null==n)null!=t&&e&&"object"==typeof e?(n=e,e=null):t&&"object"==typeof t?(n=t,t=e=null):n=F;else if("object"!=typeof n)throw Error(l+"Argument not an object: "+n);if(r=o.toFixed(t,e),o.c){var i,s=r.split("."),a=+n.groupSize,c=+n.secondaryGroupSize,u=n.groupSeparator||"",h=s[0],d=s[1],f=o.s<0,p=f?h.slice(1):h,m=p.length;if(c&&(i=a,a=c,c=i,m-=i),a>0&&m>0){for(i=m%a||a,h=p.substr(0,i);i<m;i+=a)h+=u+p.substr(i,a);c>0&&(h+=u+p.slice(i)),f&&(h="-"+h)}r=d?h+(n.decimalSeparator||"")+((c=+n.fractionGroupSize)?d.replace(new RegExp("\\d{"+c+"}\\B","g"),"$&"+(n.fractionGroupSeparator||"")):d):h}return(n.prefix||"")+r+(n.suffix||"")},P.toFraction=function(t){var e,r,o,i,s,a,c,u,h,f,m,g,y=this,v=y.c;if(null!=t&&(!(c=new W(t)).isInteger()&&(c.c||1!==c.s)||c.lt(I)))throw Error(l+"Argument "+(c.isInteger()?"out of range: ":"not an integer: ")+X(c));if(!v)return new W(y);for(e=new W(I),h=r=new W(I),o=u=new W(I),g=w(v),s=e.e=g.length-y.e-1,e.c[0]=p[(a=s%d)<0?d+a:a],t=!t||c.comparedTo(e)>0?s>0?e:h:c,a=j,j=1/0,c=new W(g),u.c[0]=0;f=n(c,e,0,1),1!=(i=r.plus(f.times(o))).comparedTo(t);)r=o,o=i,h=u.plus(f.times(i=h)),u=i,e=c.minus(f.times(i=e)),c=i;return i=n(t.minus(r),o,0,1),u=u.plus(i.times(h)),r=r.plus(i.times(o)),u.s=h.s=y.s,m=n(h,o,s*=2,N).minus(y).abs().comparedTo(n(u,r,s,N).minus(y).abs())<1?[h,o]:[u,r],j=a,m},P.toNumber=function(){return+X(this)},P.toPrecision=function(t,e){return null!=t&&b(t,1,g),z(this,t,e,2)},P.toString=function(t){var e,n=this,o=n.s,i=n.e;return null===i?o?(e="Infinity",o<0&&(e="-"+e)):e="NaN":(null==t?e=i<=B||i>=U?S(w(n.c),i):x(w(n.c),i,"0"):10===t&&$?e=x(w((n=Z(new W(n),O+i+1,N)).c),n.e,"0"):(b(t,2,K.length,"Base"),e=r(x(w(n.c),i,"0"),10,t,o,!0)),o<0&&n.c[0]&&(e="-"+e)),e},P.valueOf=P.toJSON=function(){return X(this)},P._isBigNumber=!0,null!=e&&W.set(e),W}(),i.default=i.BigNumber=i,void 0===(r=function(){return i}.call(e,n,e,t))||(t.exports=r)}()},764:(t,e,n)=>{"use strict";const r=n(742),o=n(645),i="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,n){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 l(t,e,n)}function l(t,e,n){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 n=0|m(t,e);let r=a(n);const o=r.write(t,e);o!==n&&(r=r.slice(0,o));return r}(t,e);if(ArrayBuffer.isView(t))return function(t){if(X(t,Uint8Array)){const e=new Uint8Array(t);return f(e.buffer,e.byteOffset,e.byteLength)}return d(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(X(t,ArrayBuffer)||t&&X(t.buffer,ArrayBuffer))return f(t,e,n);if("undefined"!=typeof SharedArrayBuffer&&(X(t,SharedArrayBuffer)||t&&X(t.buffer,SharedArrayBuffer)))return f(t,e,n);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const r=t.valueOf&&t.valueOf();if(null!=r&&r!==t)return c.from(r,e,n);const o=function(t){if(c.isBuffer(t)){const e=0|p(t.length),n=a(e);return 0===n.length||t.copy(n,0,0,e),n}if(void 0!==t.length)return"number"!=typeof t.length||G(t.length)?a(0):d(t);if("Buffer"===t.type&&Array.isArray(t.data))return d(t.data)}(t);if(o)return o;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return c.from(t[Symbol.toPrimitive]("string"),e,n);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function u(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 u(t),a(t<0?0:0|p(t))}function d(t){const e=t.length<0?0:0|p(t.length),n=a(e);for(let r=0;r<e;r+=1)n[r]=255&t[r];return n}function f(t,e,n){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(n||0))throw new RangeError('"length" is outside of buffer bounds');let r;return r=void 0===e&&void 0===n?new Uint8Array(t):void 0===n?new Uint8Array(t,e):new Uint8Array(t,e,n),Object.setPrototypeOf(r,c.prototype),r}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 m(t,e){if(c.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||X(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 n=t.length,r=arguments.length>2&&!0===arguments[2];if(!r&&0===n)return 0;let o=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return H(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return q(t).length;default:if(o)return r?-1:H(t).length;e=(""+e).toLowerCase(),o=!0}}function g(t,e,n){let r=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return P(this,e,n);case"utf8":case"utf-8":return _(this,e,n);case"ascii":return R(this,e,n);case"latin1":case"binary":return C(this,e,n);case"base64":return A(this,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return I(this,e,n);default:if(r)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),r=!0}}function y(t,e,n){const r=t[e];t[e]=t[n],t[n]=r}function w(t,e,n,r,o){if(0===t.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),G(n=+n)&&(n=o?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(o)return-1;n=t.length-1}else if(n<0){if(!o)return-1;n=0}if("string"==typeof e&&(e=c.from(e,r)),c.isBuffer(e))return 0===e.length?-1:v(t,e,n,r,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,n):Uint8Array.prototype.lastIndexOf.call(t,e,n):v(t,[e],n,r,o);throw new TypeError("val must be string, number or Buffer")}function v(t,e,n,r,o){let i,s=1,a=t.length,c=e.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(t.length<2||e.length<2)return-1;s=2,a/=2,c/=2,n/=2}function l(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(o){let r=-1;for(i=n;i<a;i++)if(l(t,i)===l(e,-1===r?0:i-r)){if(-1===r&&(r=i),i-r+1===c)return r*s}else-1!==r&&(i-=i-r),r=-1}else for(n+c>a&&(n=a-c),i=n;i>=0;i--){let n=!0;for(let r=0;r<c;r++)if(l(t,i+r)!==l(e,r)){n=!1;break}if(n)return i}return-1}function b(t,e,n,r){n=Number(n)||0;const o=t.length-n;r?(r=Number(r))>o&&(r=o):r=o;const i=e.length;let s;for(r>i/2&&(r=i/2),s=0;s<r;++s){const r=parseInt(e.substr(2*s,2),16);if(G(r))return s;t[n+s]=r}return s}function E(t,e,n,r){return Z(H(e,t.length-n),t,n,r)}function S(t,e,n,r){return Z(function(t){const e=[];for(let n=0;n<t.length;++n)e.push(255&t.charCodeAt(n));return e}(e),t,n,r)}function x(t,e,n,r){return Z(q(e),t,n,r)}function T(t,e,n,r){return Z(function(t,e){let n,r,o;const i=[];for(let s=0;s<t.length&&!((e-=2)<0);++s)n=t.charCodeAt(s),r=n>>8,o=n%256,i.push(o),i.push(r);return i}(e,t.length-n),t,n,r)}function A(t,e,n){return 0===e&&n===t.length?r.fromByteArray(t):r.fromByteArray(t.slice(e,n))}function _(t,e,n){n=Math.min(t.length,n);const r=[];let o=e;for(;o<n;){const e=t[o];let i=null,s=e>239?4:e>223?3:e>191?2:1;if(o+s<=n){let n,r,a,c;switch(s){case 1:e<128&&(i=e);break;case 2:n=t[o+1],128==(192&n)&&(c=(31&e)<<6|63&n,c>127&&(i=c));break;case 3:n=t[o+1],r=t[o+2],128==(192&n)&&128==(192&r)&&(c=(15&e)<<12|(63&n)<<6|63&r,c>2047&&(c<55296||c>57343)&&(i=c));break;case 4:n=t[o+1],r=t[o+2],a=t[o+3],128==(192&n)&&128==(192&r)&&128==(192&a)&&(c=(15&e)<<18|(63&n)<<12|(63&r)<<6|63&a,c>65535&&c<1114112&&(i=c))}}null===i?(i=65533,s=1):i>65535&&(i-=65536,r.push(i>>>10&1023|55296),i=56320|1023&i),r.push(i),o+=s}return function(t){const e=t.length;if(e<=k)return String.fromCharCode.apply(String,t);let n="",r=0;for(;r<e;)n+=String.fromCharCode.apply(String,t.slice(r,r+=k));return n}(r)}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,n){return l(t,e,n)},Object.setPrototypeOf(c.prototype,Uint8Array.prototype),Object.setPrototypeOf(c,Uint8Array),c.alloc=function(t,e,n){return function(t,e,n){return u(t),t<=0?a(t):void 0!==e?"string"==typeof n?a(t).fill(e,n):a(t).fill(e):a(t)}(t,e,n)},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(X(t,Uint8Array)&&(t=c.from(t,t.offset,t.byteLength)),X(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 n=t.length,r=e.length;for(let o=0,i=Math.min(n,r);o<i;++o)if(t[o]!==e[o]){n=t[o],r=e[o];break}return n<r?-1:r<n?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 n;if(void 0===e)for(e=0,n=0;n<t.length;++n)e+=t[n].length;const r=c.allocUnsafe(e);let o=0;for(n=0;n<t.length;++n){let e=t[n];if(X(e,Uint8Array))o+e.length>r.length?(c.isBuffer(e)||(e=c.from(e)),e.copy(r,o)):Uint8Array.prototype.set.call(r,e,o);else{if(!c.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(r,o)}o+=e.length}return r},c.byteLength=m,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)y(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)y(this,e,e+3),y(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)y(this,e,e+7),y(this,e+1,e+6),y(this,e+2,e+5),y(this,e+3,e+4);return this},c.prototype.toString=function(){const t=this.length;return 0===t?"":0===arguments.length?_(this,0,t):g.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 n=e.h2;return t=this.toString("hex",0,n).replace(/(.{2})/g,"$1 ").trim(),this.length>n&&(t+=" ... "),"<Buffer "+t+">"},i&&(c.prototype[i]=c.prototype.inspect),c.prototype.compare=function(t,e,n,r,o){if(X(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===n&&(n=t?t.length:0),void 0===r&&(r=0),void 0===o&&(o=this.length),e<0||n>t.length||r<0||o>this.length)throw new RangeError("out of range index");if(r>=o&&e>=n)return 0;if(r>=o)return-1;if(e>=n)return 1;if(this===t)return 0;let i=(o>>>=0)-(r>>>=0),s=(n>>>=0)-(e>>>=0);const a=Math.min(i,s),l=this.slice(r,o),u=t.slice(e,n);for(let t=0;t<a;++t)if(l[t]!==u[t]){i=l[t],s=u[t];break}return i<s?-1:s<i?1:0},c.prototype.includes=function(t,e,n){return-1!==this.indexOf(t,e,n)},c.prototype.indexOf=function(t,e,n){return w(this,t,e,n,!0)},c.prototype.lastIndexOf=function(t,e,n){return w(this,t,e,n,!1)},c.prototype.write=function(t,e,n,r){if(void 0===e)r="utf8",n=this.length,e=0;else if(void 0===n&&"string"==typeof e)r=e,n=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e>>>=0,isFinite(n)?(n>>>=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}const o=this.length-e;if((void 0===n||n>o)&&(n=o),t.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");let i=!1;for(;;)switch(r){case"hex":return b(this,t,e,n);case"utf8":case"utf-8":return E(this,t,e,n);case"ascii":case"latin1":case"binary":return S(this,t,e,n);case"base64":return x(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,t,e,n);default:if(i)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),i=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const k=4096;function R(t,e,n){let r="";n=Math.min(t.length,n);for(let o=e;o<n;++o)r+=String.fromCharCode(127&t[o]);return r}function C(t,e,n){let r="";n=Math.min(t.length,n);for(let o=e;o<n;++o)r+=String.fromCharCode(t[o]);return r}function P(t,e,n){const r=t.length;(!e||e<0)&&(e=0),(!n||n<0||n>r)&&(n=r);let o="";for(let r=e;r<n;++r)o+=Y[t[r]];return o}function I(t,e,n){const r=t.slice(e,n);let o="";for(let t=0;t<r.length-1;t+=2)o+=String.fromCharCode(r[t]+256*r[t+1]);return o}function O(t,e,n){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>n)throw new RangeError("Trying to access beyond buffer length")}function N(t,e,n,r,o,i){if(!c.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||e<i)throw new RangeError('"value" argument is out of bounds');if(n+r>t.length)throw new RangeError("Index out of range")}function B(t,e,n,r,o){K(e,r,o,t,n,7);let i=Number(e&BigInt(4294967295));t[n++]=i,i>>=8,t[n++]=i,i>>=8,t[n++]=i,i>>=8,t[n++]=i;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[n++]=s,s>>=8,t[n++]=s,s>>=8,t[n++]=s,s>>=8,t[n++]=s,n}function U(t,e,n,r,o){K(e,r,o,t,n,7);let i=Number(e&BigInt(4294967295));t[n+7]=i,i>>=8,t[n+6]=i,i>>=8,t[n+5]=i,i>>=8,t[n+4]=i;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[n+3]=s,s>>=8,t[n+2]=s,s>>=8,t[n+1]=s,s>>=8,t[n]=s,n+8}function L(t,e,n,r,o,i){if(n+r>t.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function j(t,e,n,r,i){return e=+e,n>>>=0,i||L(t,0,n,4),o.write(t,e,n,r,23,4),n+4}function D(t,e,n,r,i){return e=+e,n>>>=0,i||L(t,0,n,8),o.write(t,e,n,r,52,8),n+8}c.prototype.slice=function(t,e){const n=this.length;(t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(e=void 0===e?n:~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),e<t&&(e=t);const r=this.subarray(t,e);return Object.setPrototypeOf(r,c.prototype),r},c.prototype.readUintLE=c.prototype.readUIntLE=function(t,e,n){t>>>=0,e>>>=0,n||O(t,e,this.length);let r=this[t],o=1,i=0;for(;++i<e&&(o*=256);)r+=this[t+i]*o;return r},c.prototype.readUintBE=c.prototype.readUIntBE=function(t,e,n){t>>>=0,e>>>=0,n||O(t,e,this.length);let r=this[t+--e],o=1;for(;e>0&&(o*=256);)r+=this[t+--e]*o;return r},c.prototype.readUint8=c.prototype.readUInt8=function(t,e){return t>>>=0,e||O(t,1,this.length),this[t]},c.prototype.readUint16LE=c.prototype.readUInt16LE=function(t,e){return t>>>=0,e||O(t,2,this.length),this[t]|this[t+1]<<8},c.prototype.readUint16BE=c.prototype.readUInt16BE=function(t,e){return t>>>=0,e||O(t,2,this.length),this[t]<<8|this[t+1]},c.prototype.readUint32LE=c.prototype.readUInt32LE=function(t,e){return t>>>=0,e||O(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||O(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},c.prototype.readBigUInt64LE=J((function(t){$(t>>>=0,"offset");const e=this[t],n=this[t+7];void 0!==e&&void 0!==n||W(t,this.length-8);const r=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,o=this[++t]+256*this[++t]+65536*this[++t]+n*2**24;return BigInt(r)+(BigInt(o)<<BigInt(32))})),c.prototype.readBigUInt64BE=J((function(t){$(t>>>=0,"offset");const e=this[t],n=this[t+7];void 0!==e&&void 0!==n||W(t,this.length-8);const r=e*2**24+65536*this[++t]+256*this[++t]+this[++t],o=this[++t]*2**24+65536*this[++t]+256*this[++t]+n;return(BigInt(r)<<BigInt(32))+BigInt(o)})),c.prototype.readIntLE=function(t,e,n){t>>>=0,e>>>=0,n||O(t,e,this.length);let r=this[t],o=1,i=0;for(;++i<e&&(o*=256);)r+=this[t+i]*o;return o*=128,r>=o&&(r-=Math.pow(2,8*e)),r},c.prototype.readIntBE=function(t,e,n){t>>>=0,e>>>=0,n||O(t,e,this.length);let r=e,o=1,i=this[t+--r];for(;r>0&&(o*=256);)i+=this[t+--r]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*e)),i},c.prototype.readInt8=function(t,e){return t>>>=0,e||O(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},c.prototype.readInt16LE=function(t,e){t>>>=0,e||O(t,2,this.length);const n=this[t]|this[t+1]<<8;return 32768&n?4294901760|n:n},c.prototype.readInt16BE=function(t,e){t>>>=0,e||O(t,2,this.length);const n=this[t+1]|this[t]<<8;return 32768&n?4294901760|n:n},c.prototype.readInt32LE=function(t,e){return t>>>=0,e||O(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||O(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},c.prototype.readBigInt64LE=J((function(t){$(t>>>=0,"offset");const e=this[t],n=this[t+7];void 0!==e&&void 0!==n||W(t,this.length-8);const r=this[t+4]+256*this[t+5]+65536*this[t+6]+(n<<24);return(BigInt(r)<<BigInt(32))+BigInt(e+256*this[++t]+65536*this[++t]+this[++t]*2**24)})),c.prototype.readBigInt64BE=J((function(t){$(t>>>=0,"offset");const e=this[t],n=this[t+7];void 0!==e&&void 0!==n||W(t,this.length-8);const r=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(r)<<BigInt(32))+BigInt(this[++t]*2**24+65536*this[++t]+256*this[++t]+n)})),c.prototype.readFloatLE=function(t,e){return t>>>=0,e||O(t,4,this.length),o.read(this,t,!0,23,4)},c.prototype.readFloatBE=function(t,e){return t>>>=0,e||O(t,4,this.length),o.read(this,t,!1,23,4)},c.prototype.readDoubleLE=function(t,e){return t>>>=0,e||O(t,8,this.length),o.read(this,t,!0,52,8)},c.prototype.readDoubleBE=function(t,e){return t>>>=0,e||O(t,8,this.length),o.read(this,t,!1,52,8)},c.prototype.writeUintLE=c.prototype.writeUIntLE=function(t,e,n,r){if(t=+t,e>>>=0,n>>>=0,!r){N(this,t,e,n,Math.pow(2,8*n)-1,0)}let o=1,i=0;for(this[e]=255&t;++i<n&&(o*=256);)this[e+i]=t/o&255;return e+n},c.prototype.writeUintBE=c.prototype.writeUIntBE=function(t,e,n,r){if(t=+t,e>>>=0,n>>>=0,!r){N(this,t,e,n,Math.pow(2,8*n)-1,0)}let o=n-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+n},c.prototype.writeUint8=c.prototype.writeUInt8=function(t,e,n){return t=+t,e>>>=0,n||N(this,t,e,1,255,0),this[e]=255&t,e+1},c.prototype.writeUint16LE=c.prototype.writeUInt16LE=function(t,e,n){return t=+t,e>>>=0,n||N(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,n){return t=+t,e>>>=0,n||N(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,n){return t=+t,e>>>=0,n||N(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,n){return t=+t,e>>>=0,n||N(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=J((function(t,e=0){return B(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),c.prototype.writeBigUInt64BE=J((function(t,e=0){return U(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),c.prototype.writeIntLE=function(t,e,n,r){if(t=+t,e>>>=0,!r){const r=Math.pow(2,8*n-1);N(this,t,e,n,r-1,-r)}let o=0,i=1,s=0;for(this[e]=255&t;++o<n&&(i*=256);)t<0&&0===s&&0!==this[e+o-1]&&(s=1),this[e+o]=(t/i>>0)-s&255;return e+n},c.prototype.writeIntBE=function(t,e,n,r){if(t=+t,e>>>=0,!r){const r=Math.pow(2,8*n-1);N(this,t,e,n,r-1,-r)}let o=n-1,i=1,s=0;for(this[e+o]=255&t;--o>=0&&(i*=256);)t<0&&0===s&&0!==this[e+o+1]&&(s=1),this[e+o]=(t/i>>0)-s&255;return e+n},c.prototype.writeInt8=function(t,e,n){return t=+t,e>>>=0,n||N(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},c.prototype.writeInt16LE=function(t,e,n){return t=+t,e>>>=0,n||N(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},c.prototype.writeInt16BE=function(t,e,n){return t=+t,e>>>=0,n||N(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},c.prototype.writeInt32LE=function(t,e,n){return t=+t,e>>>=0,n||N(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,n){return t=+t,e>>>=0,n||N(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=J((function(t,e=0){return B(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),c.prototype.writeBigInt64BE=J((function(t,e=0){return U(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),c.prototype.writeFloatLE=function(t,e,n){return j(this,t,e,!0,n)},c.prototype.writeFloatBE=function(t,e,n){return j(this,t,e,!1,n)},c.prototype.writeDoubleLE=function(t,e,n){return D(this,t,e,!0,n)},c.prototype.writeDoubleBE=function(t,e,n){return D(this,t,e,!1,n)},c.prototype.copy=function(t,e,n,r){if(!c.isBuffer(t))throw new TypeError("argument should be a Buffer");if(n||(n=0),r||0===r||(r=this.length),e>=t.length&&(e=t.length),e||(e=0),r>0&&r<n&&(r=n),r===n)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),t.length-e<r-n&&(r=t.length-e+n);const o=r-n;return this===t&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(e,n,r):Uint8Array.prototype.set.call(t,this.subarray(n,r),e),o},c.prototype.fill=function(t,e,n,r){if("string"==typeof t){if("string"==typeof e?(r=e,e=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!c.isEncoding(r))throw new TypeError("Unknown encoding: "+r);if(1===t.length){const e=t.charCodeAt(0);("utf8"===r&&e<128||"latin1"===r)&&(t=e)}}else"number"==typeof t?t&=255:"boolean"==typeof t&&(t=Number(t));if(e<0||this.length<e||this.length<n)throw new RangeError("Out of range index");if(n<=e)return this;let o;if(e>>>=0,n=void 0===n?this.length:n>>>0,t||(t=0),"number"==typeof t)for(o=e;o<n;++o)this[o]=t;else{const i=c.isBuffer(t)?t:c.from(t,r),s=i.length;if(0===s)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(o=0;o<n-e;++o)this[o+e]=i[o%s]}return this};const M={};function V(t,e,n){M[t]=class extends n{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 F(t){let e="",n=t.length;const r="-"===t[0]?1:0;for(;n>=r+4;n-=3)e=`_${t.slice(n-3,n)}${e}`;return`${t.slice(0,n)}${e}`}function K(t,e,n,r,o,i){if(t>n||t<e){const r="bigint"==typeof e?"n":"";let o;throw o=i>3?0===e||e===BigInt(0)?`>= 0${r} and < 2${r} ** ${8*(i+1)}${r}`:`>= -(2${r} ** ${8*(i+1)-1}${r}) and < 2 ** ${8*(i+1)-1}${r}`:`>= ${e}${r} and <= ${n}${r}`,new M.ERR_OUT_OF_RANGE("value",o,t)}!function(t,e,n){$(e,"offset"),void 0!==t[e]&&void 0!==t[e+n]||W(e,t.length-(n+1))}(r,o,i)}function $(t,e){if("number"!=typeof t)throw new M.ERR_INVALID_ARG_TYPE(e,"number",t)}function W(t,e,n){if(Math.floor(t)!==t)throw $(t,n),new M.ERR_OUT_OF_RANGE(n||"offset","an integer",t);if(e<0)throw new M.ERR_BUFFER_OUT_OF_BOUNDS;throw new M.ERR_OUT_OF_RANGE(n||"offset",`>= ${n?1:0} and <= ${e}`,t)}V("ERR_BUFFER_OUT_OF_BOUNDS",(function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),V("ERR_INVALID_ARG_TYPE",(function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`}),TypeError),V("ERR_OUT_OF_RANGE",(function(t,e,n){let r=`The value of "${t}" is out of range.`,o=n;return Number.isInteger(n)&&Math.abs(n)>2**32?o=F(String(n)):"bigint"==typeof n&&(o=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(o=F(o)),o+="n"),r+=` It must be ${e}. Received ${o}`,r}),RangeError);const z=/[^+/0-9A-Za-z-_]/g;function H(t,e){let n;e=e||1/0;const r=t.length;let o=null;const i=[];for(let s=0;s<r;++s){if(n=t.charCodeAt(s),n>55295&&n<57344){if(!o){if(n>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(s+1===r){(e-=3)>-1&&i.push(239,191,189);continue}o=n;continue}if(n<56320){(e-=3)>-1&&i.push(239,191,189),o=n;continue}n=65536+(o-55296<<10|n-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,n<128){if((e-=1)<0)break;i.push(n)}else if(n<2048){if((e-=2)<0)break;i.push(n>>6|192,63&n|128)}else if(n<65536){if((e-=3)<0)break;i.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return i}function q(t){return r.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 Z(t,e,n,r){let o;for(o=0;o<r&&!(o+n>=e.length||o>=t.length);++o)e[o+n]=t[o];return o}function X(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function G(t){return t!=t}const Y=function(){const t="0123456789abcdef",e=new Array(256);for(let n=0;n<16;++n){const r=16*n;for(let o=0;o<16;++o)e[r+o]=t[n]+t[o]}return e}();function J(t){return"undefined"==typeof BigInt?Q:t}function Q(){throw new Error("BigInt not supported")}},470:t=>{"use strict";var e=Object.prototype.hasOwnProperty,n=Object.prototype.toString,r=Object.defineProperty,o=Object.getOwnPropertyDescriptor,i=function(t){return"function"==typeof Array.isArray?Array.isArray(t):"[object Array]"===n.call(t)},s=function(t){if(!t||"[object Object]"!==n.call(t))return!1;var r,o=e.call(t,"constructor"),i=t.constructor&&t.constructor.prototype&&e.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!o&&!i)return!1;for(r in t);return void 0===r||e.call(t,r)},a=function(t,e){r&&"__proto__"===e.name?r(t,e.name,{enumerable:!0,configurable:!0,value:e.newValue,writable:!0}):t[e.name]=e.newValue},c=function(t,n){if("__proto__"===n){if(!e.call(t,n))return;if(o)return o(t,n).value}return t[n]};t.exports=function t(){var e,n,r,o,l,u,h=arguments[0],d=1,f=arguments.length,p=!1;for("boolean"==typeof h&&(p=h,h=arguments[1]||{},d=2),(null==h||"object"!=typeof h&&"function"!=typeof h)&&(h={});d<f;++d)if(null!=(e=arguments[d]))for(n in e)r=c(h,n),h!==(o=c(e,n))&&(p&&o&&(s(o)||(l=i(o)))?(l?(l=!1,u=r&&i(r)?r:[]):u=r&&s(r)?r:{},a(h,{name:n,newValue:t(p,u,o)})):void 0!==o&&a(h,{name:n,newValue:o}));return h}},645:(t,e)=>{e.read=function(t,e,n,r,o){var i,s,a=8*o-r-1,c=(1<<a)-1,l=c>>1,u=-7,h=n?o-1:0,d=n?-1:1,f=t[e+h];for(h+=d,i=f&(1<<-u)-1,f>>=-u,u+=a;u>0;i=256*i+t[e+h],h+=d,u-=8);for(s=i&(1<<-u)-1,i>>=-u,u+=r;u>0;s=256*s+t[e+h],h+=d,u-=8);if(0===i)i=1-l;else{if(i===c)return s?NaN:1/0*(f?-1:1);s+=Math.pow(2,r),i-=l}return(f?-1:1)*s*Math.pow(2,i-r)},e.write=function(t,e,n,r,o,i){var s,a,c,l=8*i-o-1,u=(1<<l)-1,h=u>>1,d=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,f=r?0:i-1,p=r?1:-1,m=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=u):(s=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-s))<1&&(s--,c*=2),(e+=s+h>=1?d/c:d*Math.pow(2,1-h))*c>=2&&(s++,c/=2),s+h>=u?(a=0,s=u):s+h>=1?(a=(e*c-1)*Math.pow(2,o),s+=h):(a=e*Math.pow(2,h-1)*Math.pow(2,o),s=0));o>=8;t[n+f]=255&a,f+=p,a/=256,o-=8);for(s=s<<o|a,l+=o;l>0;t[n+f]=255&s,f+=p,s/=256,l-=8);t[n+f-p]|=128*m}},703:(t,e,n)=>{"use strict";var r=n(414);function o(){}function i(){}i.resetWarningCache=o,t.exports=function(){function t(t,e,n,o,i,s){if(s!==r){var a=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw a.name="Invariant Violation",a}}function e(){return t}t.isRequired=t;var n={array:t,bigint:t,bool:t,func:t,number:t,object:t,string:t,symbol:t,any:t,arrayOf:e,element:t,elementType:t,instanceOf:e,node:t,objectOf:e,oneOf:e,oneOfType:e,shape:e,exact:e,checkPropTypes:i,resetWarningCache:o};return n.PropTypes=n,n}},697:(t,e,n)=>{t.exports=n(703)()},414:t=>{"use strict";t.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},639:e=>{"use strict";e.exports=t}},s={};function a(t){var e=s[t];if(void 0!==e)return e.exports;var n=s[t]={exports:{}};return i[t].call(n.exports,n,n.exports,a),n.exports}a.m=i,a.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return a.d(e,{a:e}),e},n=Object.getPrototypeOf?t=>Object.getPrototypeOf(t):t=>t.__proto__,a.t=function(t,r){if(1&r&&(t=this(t)),8&r)return t;if("object"==typeof t&&t){if(4&r&&t.__esModule)return t;if(16&r&&"function"==typeof t.then)return t}var o=Object.create(null);a.r(o);var i={};e=e||[null,n({}),n([]),n(n)];for(var s=2&r&&t;"object"==typeof s&&!~e.indexOf(s);s=n(s))Object.getOwnPropertyNames(s).forEach((e=>i[e]=()=>t[e]));return i.default=()=>t,a.d(o,i),o},a.d=(t,e)=>{for(var n in e)a.o(e,n)&&!a.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},a.f={},a.e=t=>Promise.all(Object.keys(a.f).reduce(((e,n)=>(a.f[n](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),r={},o="onairos:",a.l=(t,e,n,i)=>{if(r[t])r[t].push(e);else{var s,c;if(void 0!==n)for(var l=document.getElementsByTagName("script"),u=0;u<l.length;u++){var h=l[u];if(h.getAttribute("src")==t||h.getAttribute("data-webpack")==o+n){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",o+n),s.src=t),r[t]=[e];var d=(e,n)=>{s.onerror=s.onload=null,clearTimeout(f);var o=r[t];if(delete r[t],s.parentNode&&s.parentNode.removeChild(s),o&&o.forEach((t=>t(n))),e)return e(n)},f=setTimeout(d.bind(null,void 0,{type:"timeout",target:s}),12e4);s.onerror=d.bind(null,s.onerror),s.onload=d.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 n=e.getElementsByTagName("script");if(n.length)for(var r=n.length-1;r>-1&&!t;)t=n[r--].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,n)=>{var r=a.o(t,e)?t[e]:void 0;if(0!==r)if(r)n.push(r[2]);else{var o=new Promise(((n,o)=>r=t[e]=[n,o]));n.push(r[2]=o);var i=a.p+a.u(e),s=new Error;a.l(i,(n=>{if(a.o(t,e)&&(0!==(r=t[e])&&(t[e]=void 0),r)){var o=n&&("load"===n.type?"missing":n.type),i=n&&n.target&&n.target.src;s.message="Loading chunk "+e+" failed.\n("+o+": "+i+")",s.name="ChunkLoadError",s.type=o,s.request=i,r[1](s)}}),"chunk-"+e,e)}};var e=(e,n)=>{var r,o,i=n[0],s=n[1],c=n[2],l=0;if(i.some((e=>0!==t[e]))){for(r in s)a.o(s,r)&&(a.m[r]=s[r]);if(c)c(a)}for(e&&e(n);l<i.length;l++)o=i[l],a.o(t,o)&&t[o]&&t[o][0](),t[o]=0},n=this.webpackChunkonairos=this.webpackChunkonairos||[];n.forEach(e.bind(null,0)),n.push=e.bind(null,n.push.bind(n))})();var c={};return(()=>{"use strict";a.r(c),a.d(c,{Onairos:()=>Zv,default:()=>Xv});var t={};a.r(t),a.d(t,{hasBrowserEnv:()=>ee,hasStandardBrowserEnv:()=>ne,hasStandardBrowserWebWorkerEnv:()=>oe});var e=a(639),n=a.n(e),r=a(764);function o(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(t);o<r.length;o++)e.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(t,r[o])&&(n[r[o]]=t[r[o]])}return n}"function"==typeof SuppressedError&&SuppressedError;var i="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 l(t,e){return t(e={exports:{}},e.exports),e.exports}var u=l((function(t,e){Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function t(){var t=this;this.locked=new Map,this.addToLocked=function(e,n){var r=t.locked.get(e);void 0===r?void 0===n?t.locked.set(e,[]):t.locked.set(e,[n]):void 0!==n&&(r.unshift(n),t.locked.set(e,r))},this.isLocked=function(e){return t.locked.has(e)},this.lock=function(e){return new Promise((function(n,r){t.isLocked(e)?t.addToLocked(e,n):(t.addToLocked(e),n())}))},this.unlock=function(e){var n=t.locked.get(e);if(void 0!==n&&0!==n.length){var r=n.pop();t.locked.set(e,n),void 0!==r&&setTimeout(r,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 n.getInstance()}}));s(u);var h=s(l((function(t,e){var n=i&&i.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{c(r.next(t))}catch(t){i(t)}}function a(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){t.done?o(t.value):new n((function(e){e(t.value)})).then(s,a)}c((r=r.apply(t,e||[])).next())}))},r=i&&i.__generator||function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},o=i;Object.defineProperty(e,"__esModule",{value:!0});var s="browser-tabs-lock-key",a={key:function(t){return n(o,void 0,void 0,(function(){return r(this,(function(t){throw new Error("Unsupported")}))}))},getItem:function(t){return n(o,void 0,void 0,(function(){return r(this,(function(t){throw new Error("Unsupported")}))}))},clear:function(){return n(o,void 0,void 0,(function(){return r(this,(function(t){return[2,window.localStorage.clear()]}))}))},removeItem:function(t){return n(o,void 0,void 0,(function(){return r(this,(function(t){throw new Error("Unsupported")}))}))},setItem:function(t,e){return n(o,void 0,void 0,(function(){return r(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 l(t){for(var e="0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz",n="",r=0;r<t;r++)n+=e[Math.floor(61*Math.random())];return n}var h=function(){function t(e){this.acquiredIatSet=new Set,this.storageHandler=void 0,this.id=Date.now().toString()+l(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,o){return void 0===o&&(o=5e3),n(this,void 0,void 0,(function(){var n,i,u,h,d,f,p;return r(this,(function(r){switch(r.label){case 0:n=Date.now()+l(4),i=Date.now()+o,u=s+"-"+e,h=void 0===this.storageHandler?a:this.storageHandler,r.label=1;case 1:return Date.now()<i?[4,c(30)]:[3,8];case 2:return r.sent(),null!==h.getItemSync(u)?[3,5]:(d=this.id+"-"+e+"-"+n,[4,c(Math.floor(25*Math.random()))]);case 3:return r.sent(),h.setItemSync(u,JSON.stringify({id:this.id,iat:n,timeoutKey:d,timeAcquired:Date.now(),timeRefreshed:Date.now()})),[4,c(30)];case 4:return r.sent(),null!==(f=h.getItemSync(u))&&(p=JSON.parse(f)).id===this.id&&p.iat===n?(this.acquiredIatSet.add(n),this.refreshLockWhileAcquired(u,n),[2,!0]):[3,7];case 5:return t.lockCorrector(void 0===this.storageHandler?a:this.storageHandler),[4,this.waitForSomethingToChange(i)];case 6:r.sent(),r.label=7;case 7:return n=Date.now()+l(4),[3,1];case 8:return[2,!1]}}))}))},t.prototype.refreshLockWhileAcquired=function(t,e){return n(this,void 0,void 0,(function(){var o=this;return r(this,(function(i){return setTimeout((function(){return n(o,void 0,void 0,(function(){var n,o,i;return r(this,(function(r){switch(r.label){case 0:return[4,u.default().lock(e)];case 1:return r.sent(),this.acquiredIatSet.has(e)?(n=void 0===this.storageHandler?a:this.storageHandler,null===(o=n.getItemSync(t))?(u.default().unlock(e),[2]):((i=JSON.parse(o)).timeRefreshed=Date.now(),n.setItemSync(t,JSON.stringify(i)),u.default().unlock(e),this.refreshLockWhileAcquired(t,e),[2])):(u.default().unlock(e),[2])}}))}))}),1e3),[2]}))}))},t.prototype.waitForSomethingToChange=function(e){return n(this,void 0,void 0,(function(){return r(this,(function(n){switch(n.label){case 0:return[4,new Promise((function(n){var r=!1,o=Date.now(),i=!1;function s(){if(i||(window.removeEventListener("storage",s),t.removeFromWaiting(s),clearTimeout(a),i=!0),!r){r=!0;var e=50-(Date.now()-o);e>0?setTimeout(n,e):n(null)}}window.addEventListener("storage",s),t.addToWaiting(s);var a=setTimeout(s,Math.max(0,e-Date.now()))}))];case 1:return n.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 n(this,void 0,void 0,(function(){return r(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 n(this,void 0,void 0,(function(){var n,o,i,c;return r(this,(function(r){switch(r.label){case 0:return n=void 0===this.storageHandler?a:this.storageHandler,o=s+"-"+e,null===(i=n.getItemSync(o))?[2]:(c=JSON.parse(i)).id!==this.id?[3,2]:[4,u.default().lock(c.iat)];case 1:r.sent(),this.acquiredIatSet.delete(c.iat),n.removeItemSync(o),u.default().unlock(c.iat),t.notifyWaiters(),r.label=2;case 2:return[2]}}))}))},t.lockCorrector=function(e){for(var n=Date.now()-5e3,r=e,o=[],i=0;;){var a=r.keySync(i);if(null===a)break;o.push(a),i++}for(var c=!1,l=0;l<o.length;l++){var u=o[l];if(u.includes(s)){var h=r.getItemSync(u);if(null!==h){var d=JSON.parse(h);(void 0===d.timeRefreshed&&d.timeAcquired<n||void 0!==d.timeRefreshed&&d.timeRefreshed<n)&&(r.removeItemSync(u),c=!0)}}}c&&t.notifyWaiters()},t.waiters=void 0,t}();e.default=h})));const d={timeoutInSeconds:60},f={name:"auth0-spa-js",version:"2.1.3"},p=()=>Date.now();class m extends Error{constructor(t,e){super(e),this.error=t,this.error_description=e,Object.setPrototypeOf(this,m.prototype)}static fromPayload({error:t,error_description:e}){return new m(t,e)}}class g extends m{constructor(t,e,n,r=null){super(t,e),this.state=n,this.appState=r,Object.setPrototypeOf(this,g.prototype)}}class y extends m{constructor(){super("timeout","Timeout"),Object.setPrototypeOf(this,y.prototype)}}class w extends y{constructor(t){super(),this.popup=t,Object.setPrototypeOf(this,w.prototype)}}class v extends m{constructor(t){super("cancelled","Popup closed"),this.popup=t,Object.setPrototypeOf(this,v.prototype)}}class b extends m{constructor(t,e,n){super(t,e),this.mfa_token=n,Object.setPrototypeOf(this,b.prototype)}}class E extends m{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 x=()=>window.crypto,T=()=>{const t="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_~.";let e="";return Array.from(x().getRandomValues(new Uint8Array(43))).forEach((n=>e+=t[n%66])),e},A=t=>btoa(t),_=t=>{var{clientId:e}=t,n=o(t,["clientId"]);return new URLSearchParams((t=>Object.keys(t).filter((e=>void 0!==t[e])).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:t[n]})),{}))(Object.assign({client_id:e},n))).toString()},k=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 n=await fetch(t,e);return{ok:n.ok,json:await n.json()}},C=async(t,e,n,r,o,i,s=1e4)=>o?(async(t,e,n,r,o,i,s)=>{return a={auth:{audience:e,scope:n},timeout:o,fetchUrl:t,fetchOptions:r,useFormData:s},c=i,new Promise((function(t,e){const n=new MessageChannel;n.port1.onmessage=function(r){r.data.error?e(new Error(r.data.error)):t(r.data),n.port1.close()},c.postMessage(a,[n.port2])}));var a,c})(t,e,n,r,s,o,i):(async(t,e,n)=>{const r=new AbortController;let o;return e.signal=r.signal,Promise.race([R(t,e),new Promise(((t,e)=>{o=setTimeout((()=>{r.abort(),e(new Error("Timeout when executing 'fetch'"))}),n)}))]).finally((()=>{clearTimeout(o)}))})(t,r,s);async function P(t,e){var{baseUrl:n,timeout:r,audience:i,scope:s,auth0Client:a,useFormData:c}=t,l=o(t,["baseUrl","timeout","audience","scope","auth0Client","useFormData"]);const u=c?_(l):JSON.stringify(l);return await async function(t,e,n,r,i,s,a){let c,l=null;for(let o=0;o<3;o++)try{c=await C(t,n,r,i,s,a,e),l=null;break}catch(t){l=t}if(l)throw l;const u=c.json,{error:h,error_description:d}=u,f=o(u,["error","error_description"]),{ok:p}=c;if(!p){const e=d||`HTTP error. Unable to fetch ${t}`;if("mfa_required"===h)throw new b(h,e,f.mfa_token);if("missing_refresh_token"===h)throw new E(n,r);throw new m(h||"request_error",e)}return f}(`${n}/oauth/token`,r,i||"default",s,{method:"POST",body:u,headers:{"Content-Type":c?"application/x-www-form-urlencoded":"application/json","Auth0-Client":btoa(JSON.stringify(a||f))}},e,c)}const I=(...t)=>{return(e=t.filter(Boolean).join(" ").trim().split(/\s+/),Array.from(new Set(e))).join(" ");var e};class O{constructor(t,e="@@auth0spajs@@",n){this.prefix=e,this.suffix=n,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,n,r,o]=t.split("::");return new O({clientId:n,scope:o,audience:r},e)}static fromCacheEntry(t){const{scope:e,audience:n,client_id:r}=t;return new O({scope:e,audience:n,clientId:r})}}class N{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 B{constructor(){this.enclosedCache=function(){let t={};return{set(e,n){t[e]=n},get(e){const n=t[e];if(n)return n},remove(e){delete t[e]},allKeys:()=>Object.keys(t)}}()}}class U{constructor(t,e,n){this.cache=t,this.keyManifest=e,this.nowProvider=n||p}async setIdToken(t,e,n){var r;const o=this.getIdTokenCacheKey(t);await this.cache.set(o,{id_token:e,decodedToken:n}),await(null===(r=this.keyManifest)||void 0===r?void 0:r.add(o))}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 n;let r=await this.cache.get(t.toKey());if(!r){const e=await this.getCacheKeys();if(!e)return;const n=this.matchExistingCacheKey(t,e);n&&(r=await this.cache.get(n))}if(!r)return;const o=await this.nowProvider(),i=Math.floor(o/1e3);return r.expiresAt-e<i?r.body.refresh_token?(r.body={refresh_token:r.body.refresh_token},await this.cache.set(t.toKey(),r),r.body):(await this.cache.remove(t.toKey()),void await(null===(n=this.keyManifest)||void 0===n?void 0:n.remove(t.toKey()))):r.body}async set(t){var e;const n=new O({clientId:t.client_id,scope:t.scope,audience:t.audience}),r=await this.wrapCacheEntry(t);await this.cache.set(n.toKey(),r),await(null===(e=this.keyManifest)||void 0===e?void 0:e.add(n.toKey()))}async clear(t){var e;const n=await this.getCacheKeys();n&&(await n.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 O({clientId:t},"@@auth0spajs@@","@@user@@").toKey()}matchExistingCacheKey(t,e){return e.filter((e=>{var n;const r=O.fromKey(e),o=new Set(r.scope&&r.scope.split(" ")),i=(null===(n=t.scope)||void 0===n?void 0:n.split(" "))||[],s=r.scope&&i.reduce(((t,e)=>t&&o.has(e)),!0);return"@@auth0spajs@@"===r.prefix&&r.clientId===t.clientId&&r.audience===t.audience&&s}))[0]}}class L{constructor(t,e,n){this.storage=t,this.clientId=e,this.cookieDomain=n,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 M=l((function(t,e){var n=i&&i.__assign||function(){return n=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},n.apply(this,arguments)};function r(t,e){if(!e)return"";var n="; "+t;return!0===e?n:n+"="+e}function o(t,e,n){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 r("Expires",t.expires?t.expires.toUTCString():"")+r("Domain",t.domain)+r("Path",t.path)+r("Secure",t.secure)+r("SameSite",t.sameSite)}(n)}function s(t){for(var e={},n=t?t.split("; "):[],r=/(%[\dA-F]{2})+/gi,o=0;o<n.length;o++){var i=n[o].split("="),s=i.slice(1).join("=");'"'===s.charAt(0)&&(s=s.slice(1,-1));try{e[i[0].replace(r,decodeURIComponent)]=s.replace(r,decodeURIComponent)}catch(t){}}return e}function a(){return s(document.cookie)}function c(t,e,r){document.cookie=o(t,e,n({path:"/"},r))}e.__esModule=!0,e.encode=o,e.parse=s,e.getAll=a,e.get=function(t){return a()[t]},e.set=c,e.remove=function(t,e){c(t,"",n(n({},e),{expires:-1}))}}));s(M),M.encode,M.parse,M.getAll;var V=M.get,F=M.set,K=M.remove;const $={get(t){const e=V(t);if(void 0!==e)return JSON.parse(e)},save(t,e,n){let r={};"https:"===window.location.protocol&&(r={secure:!0,sameSite:"none"}),(null==n?void 0:n.daysUntilExpire)&&(r.expires=n.daysUntilExpire),(null==n?void 0:n.cookieDomain)&&(r.domain=n.cookieDomain),F(t,JSON.stringify(e),r)},remove(t,e){let n={};(null==e?void 0:e.cookieDomain)&&(n.domain=e.cookieDomain),K(t,n)}},W={get:t=>$.get(t)||$.get(`_legacy_${t}`),save(t,e,n){let r={};"https:"===window.location.protocol&&(r={secure:!0}),(null==n?void 0:n.daysUntilExpire)&&(r.expires=n.daysUntilExpire),(null==n?void 0:n.cookieDomain)&&(r.domain=n.cookieDomain),F(`_legacy_${t}`,JSON.stringify(e),r),$.save(t,e,n)},remove(t,e){let n={};(null==e?void 0:e.cookieDomain)&&(n.domain=e.cookieDomain),K(t,n),$.remove(t,e),$.remove(`_legacy_${t}`,e)}},z={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 H,q=("Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwohZnVuY3Rpb24oKXsidXNlIHN0cmljdCI7Y2xhc3MgZSBleHRlbmRzIEVycm9ye2NvbnN0cnVjdG9yKHQscil7c3VwZXIociksdGhpcy5lcnJvcj10LHRoaXMuZXJyb3JfZGVzY3JpcHRpb249cixPYmplY3Quc2V0UHJvdG90eXBlT2YodGhpcyxlLnByb3RvdHlwZSl9c3RhdGljIGZyb21QYXlsb2FkKHtlcnJvcjp0LGVycm9yX2Rlc2NyaXB0aW9uOnJ9KXtyZXR1cm4gbmV3IGUodCxyKX19Y2xhc3MgdCBleHRlbmRzIGV7Y29uc3RydWN0b3IoZSxzKXtzdXBlcigibWlzc2luZ19yZWZyZXNoX3Rva2VuIixgTWlzc2luZyBSZWZyZXNoIFRva2VuIChhdWRpZW5jZTogJyR7cihlLFsiZGVmYXVsdCJdKX0nLCBzY29wZTogJyR7cihzKX0nKWApLHRoaXMuYXVkaWVuY2U9ZSx0aGlzLnNjb3BlPXMsT2JqZWN0LnNldFByb3RvdHlwZU9mKHRoaXMsdC5wcm90b3R5cGUpfX1mdW5jdGlvbiByKGUsdD1bXSl7cmV0dXJuIGUmJiF0LmluY2x1ZGVzKGUpP2U6IiJ9ImZ1bmN0aW9uIj09dHlwZW9mIFN1cHByZXNzZWRFcnJvciYmU3VwcHJlc3NlZEVycm9yO2NvbnN0IHM9ZT0+e3ZhcntjbGllbnRJZDp0fT1lLHI9ZnVuY3Rpb24oZSx0KXt2YXIgcj17fTtmb3IodmFyIHMgaW4gZSlPYmplY3QucHJvdG90eXBlLmhhc093blByb3BlcnR5LmNhbGwoZSxzKSYmdC5pbmRleE9mKHMpPDAmJihyW3NdPWVbc10pO2lmKG51bGwhPWUmJiJmdW5jdGlvbiI9PXR5cGVvZiBPYmplY3QuZ2V0T3duUHJvcGVydHlTeW1ib2xzKXt2YXIgbz0wO2ZvcihzPU9iamVjdC5nZXRPd25Qcm9wZXJ0eVN5bWJvbHMoZSk7bzxzLmxlbmd0aDtvKyspdC5pbmRleE9mKHNbb10pPDAmJk9iamVjdC5wcm90b3R5cGUucHJvcGVydHlJc0VudW1lcmFibGUuY2FsbChlLHNbb10pJiYocltzW29dXT1lW3Nbb11dKX1yZXR1cm4gcn0oZSxbImNsaWVudElkIl0pO3JldHVybiBuZXcgVVJMU2VhcmNoUGFyYW1zKChlPT5PYmplY3Qua2V5cyhlKS5maWx0ZXIoKHQ9PnZvaWQgMCE9PWVbdF0pKS5yZWR1Y2UoKCh0LHIpPT5PYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30sdCkse1tyXTplW3JdfSkpLHt9KSkoT2JqZWN0LmFzc2lnbih7Y2xpZW50X2lkOnR9LHIpKSkudG9TdHJpbmcoKX07bGV0IG89e307Y29uc3Qgbj0oZSx0KT0+YCR7ZX18JHt0fWA7YWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsKGFzeW5jKHtkYXRhOnt0aW1lb3V0OmUsYXV0aDpyLGZldGNoVXJsOmksZmV0Y2hPcHRpb25zOmMsdXNlRm9ybURhdGE6YX0scG9ydHM6W3BdfSk9PntsZXQgZjtjb25zdHthdWRpZW5jZTp1LHNjb3BlOmx9PXJ8fHt9O3RyeXtjb25zdCByPWE/KGU9Pntjb25zdCB0PW5ldyBVUkxTZWFyY2hQYXJhbXMoZSkscj17fTtyZXR1cm4gdC5mb3JFYWNoKCgoZSx0KT0+e3JbdF09ZX0pKSxyfSkoYy5ib2R5KTpKU09OLnBhcnNlKGMuYm9keSk7aWYoIXIucmVmcmVzaF90b2tlbiYmInJlZnJlc2hfdG9rZW4iPT09ci5ncmFudF90eXBlKXtjb25zdCBlPSgoZSx0KT0+b1tuKGUsdCldKSh1LGwpO2lmKCFlKXRocm93IG5ldyB0KHUsbCk7Yy5ib2R5PWE/cyhPYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30scikse3JlZnJlc2hfdG9rZW46ZX0pKTpKU09OLnN0cmluZ2lmeShPYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30scikse3JlZnJlc2hfdG9rZW46ZX0pKX1sZXQgaCxnOyJmdW5jdGlvbiI9PXR5cGVvZiBBYm9ydENvbnRyb2xsZXImJihoPW5ldyBBYm9ydENvbnRyb2xsZXIsYy5zaWduYWw9aC5zaWduYWwpO3RyeXtnPWF3YWl0IFByb21pc2UucmFjZShbKGQ9ZSxuZXcgUHJvbWlzZSgoZT0+c2V0VGltZW91dChlLGQpKSkpLGZldGNoKGksT2JqZWN0LmFzc2lnbih7fSxjKSldKX1jYXRjaChlKXtyZXR1cm4gdm9pZCBwLnBvc3RNZXNzYWdlKHtlcnJvcjplLm1lc3NhZ2V9KX1pZighZylyZXR1cm4gaCYmaC5hYm9ydCgpLHZvaWQgcC5wb3N0TWVzc2FnZSh7ZXJyb3I6IlRpbWVvdXQgd2hlbiBleGVjdXRpbmcgJ2ZldGNoJyJ9KTtmPWF3YWl0IGcuanNvbigpLGYucmVmcmVzaF90b2tlbj8oKChlLHQscik9PntvW24odCxyKV09ZX0pKGYucmVmcmVzaF90b2tlbix1LGwpLGRlbGV0ZSBmLnJlZnJlc2hfdG9rZW4pOigoZSx0KT0+e2RlbGV0ZSBvW24oZSx0KV19KSh1LGwpLHAucG9zdE1lc3NhZ2Uoe29rOmcub2ssanNvbjpmfSl9Y2F0Y2goZSl7cC5wb3N0TWVzc2FnZSh7b2s6ITEsanNvbjp7ZXJyb3I6ZS5lcnJvcixlcnJvcl9kZXNjcmlwdGlvbjplLm1lc3NhZ2V9fSl9dmFyIGR9KSl9KCk7Cgo=",null,!1,function(t){return H=H||function(t,e,n){var r=void 0===e?null:e,o=function(t,e){var n=atob(t);if(e){for(var r=new Uint8Array(n.length),o=0,i=n.length;o<i;++o)r[o]=n.charCodeAt(o);return String.fromCharCode.apply(null,new Uint16Array(r.buffer))}return n}(t,void 0!==n&&n),i=o.indexOf("\n",10)+1,s=o.substring(i)+(r?"//# sourceMappingURL="+r:""),a=new Blob([s],{type:"application/javascript"});return URL.createObjectURL(a)}("Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwohZnVuY3Rpb24oKXsidXNlIHN0cmljdCI7Y2xhc3MgZSBleHRlbmRzIEVycm9ye2NvbnN0cnVjdG9yKHQscil7c3VwZXIociksdGhpcy5lcnJvcj10LHRoaXMuZXJyb3JfZGVzY3JpcHRpb249cixPYmplY3Quc2V0UHJvdG90eXBlT2YodGhpcyxlLnByb3RvdHlwZSl9c3RhdGljIGZyb21QYXlsb2FkKHtlcnJvcjp0LGVycm9yX2Rlc2NyaXB0aW9uOnJ9KXtyZXR1cm4gbmV3IGUodCxyKX19Y2xhc3MgdCBleHRlbmRzIGV7Y29uc3RydWN0b3IoZSxzKXtzdXBlcigibWlzc2luZ19yZWZyZXNoX3Rva2VuIixgTWlzc2luZyBSZWZyZXNoIFRva2VuIChhdWRpZW5jZTogJyR7cihlLFsiZGVmYXVsdCJdKX0nLCBzY29wZTogJyR7cihzKX0nKWApLHRoaXMuYXVkaWVuY2U9ZSx0aGlzLnNjb3BlPXMsT2JqZWN0LnNldFByb3RvdHlwZU9mKHRoaXMsdC5wcm90b3R5cGUpfX1mdW5jdGlvbiByKGUsdD1bXSl7cmV0dXJuIGUmJiF0LmluY2x1ZGVzKGUpP2U6IiJ9ImZ1bmN0aW9uIj09dHlwZW9mIFN1cHByZXNzZWRFcnJvciYmU3VwcHJlc3NlZEVycm9yO2NvbnN0IHM9ZT0+e3ZhcntjbGllbnRJZDp0fT1lLHI9ZnVuY3Rpb24oZSx0KXt2YXIgcj17fTtmb3IodmFyIHMgaW4gZSlPYmplY3QucHJvdG90eXBlLmhhc093blByb3BlcnR5LmNhbGwoZSxzKSYmdC5pbmRleE9mKHMpPDAmJihyW3NdPWVbc10pO2lmKG51bGwhPWUmJiJmdW5jdGlvbiI9PXR5cGVvZiBPYmplY3QuZ2V0T3duUHJvcGVydHlTeW1ib2xzKXt2YXIgbz0wO2ZvcihzPU9iamVjdC5nZXRPd25Qcm9wZXJ0eVN5bWJvbHMoZSk7bzxzLmxlbmd0aDtvKyspdC5pbmRleE9mKHNbb10pPDAmJk9iamVjdC5wcm90b3R5cGUucHJvcGVydHlJc0VudW1lcmFibGUuY2FsbChlLHNbb10pJiYocltzW29dXT1lW3Nbb11dKX1yZXR1cm4gcn0oZSxbImNsaWVudElkIl0pO3JldHVybiBuZXcgVVJMU2VhcmNoUGFyYW1zKChlPT5PYmplY3Qua2V5cyhlKS5maWx0ZXIoKHQ9PnZvaWQgMCE9PWVbdF0pKS5yZWR1Y2UoKCh0LHIpPT5PYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30sdCkse1tyXTplW3JdfSkpLHt9KSkoT2JqZWN0LmFzc2lnbih7Y2xpZW50X2lkOnR9LHIpKSkudG9TdHJpbmcoKX07bGV0IG89e307Y29uc3Qgbj0oZSx0KT0+YCR7ZX18JHt0fWA7YWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsKGFzeW5jKHtkYXRhOnt0aW1lb3V0OmUsYXV0aDpyLGZldGNoVXJsOmksZmV0Y2hPcHRpb25zOmMsdXNlRm9ybURhdGE6YX0scG9ydHM6W3BdfSk9PntsZXQgZjtjb25zdHthdWRpZW5jZTp1LHNjb3BlOmx9PXJ8fHt9O3RyeXtjb25zdCByPWE/KGU9Pntjb25zdCB0PW5ldyBVUkxTZWFyY2hQYXJhbXMoZSkscj17fTtyZXR1cm4gdC5mb3JFYWNoKCgoZSx0KT0+e3JbdF09ZX0pKSxyfSkoYy5ib2R5KTpKU09OLnBhcnNlKGMuYm9keSk7aWYoIXIucmVmcmVzaF90b2tlbiYmInJlZnJlc2hfdG9rZW4iPT09ci5ncmFudF90eXBlKXtjb25zdCBlPSgoZSx0KT0+b1tuKGUsdCldKSh1LGwpO2lmKCFlKXRocm93IG5ldyB0KHUsbCk7Yy5ib2R5PWE/cyhPYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30scikse3JlZnJlc2hfdG9rZW46ZX0pKTpKU09OLnN0cmluZ2lmeShPYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30scikse3JlZnJlc2hfdG9rZW46ZX0pKX1sZXQgaCxnOyJmdW5jdGlvbiI9PXR5cGVvZiBBYm9ydENvbnRyb2xsZXImJihoPW5ldyBBYm9ydENvbnRyb2xsZXIsYy5zaWduYWw9aC5zaWduYWwpO3RyeXtnPWF3YWl0IFByb21pc2UucmFjZShbKGQ9ZSxuZXcgUHJvbWlzZSgoZT0+c2V0VGltZW91dChlLGQpKSkpLGZldGNoKGksT2JqZWN0LmFzc2lnbih7fSxjKSldKX1jYXRjaChlKXtyZXR1cm4gdm9pZCBwLnBvc3RNZXNzYWdlKHtlcnJvcjplLm1lc3NhZ2V9KX1pZighZylyZXR1cm4gaCYmaC5hYm9ydCgpLHZvaWQgcC5wb3N0TWVzc2FnZSh7ZXJyb3I6IlRpbWVvdXQgd2hlbiBleGVjdXRpbmcgJ2ZldGNoJyJ9KTtmPWF3YWl0IGcuanNvbigpLGYucmVmcmVzaF90b2tlbj8oKChlLHQscik9PntvW24odCxyKV09ZX0pKGYucmVmcmVzaF90b2tlbix1LGwpLGRlbGV0ZSBmLnJlZnJlc2hfdG9rZW4pOigoZSx0KT0+e2RlbGV0ZSBvW24oZSx0KV19KSh1LGwpLHAucG9zdE1lc3NhZ2Uoe29rOmcub2ssanNvbjpmfSl9Y2F0Y2goZSl7cC5wb3N0TWVzc2FnZSh7b2s6ITEsanNvbjp7ZXJyb3I6ZS5lcnJvcixlcnJvcl9kZXNjcmlwdGlvbjplLm1lc3NhZ2V9fSl9dmFyIGR9KSl9KCk7Cgo=",null,false),new Worker(H,t)});const Z={};class X{constructor(t,e){this.cache=t,this.clientId=e,this.manifestKey=this.createManifestKeyFrom(this.clientId)}async add(t){var e;const n=new Set((null===(e=await this.cache.get(this.manifestKey))||void 0===e?void 0:e.keys)||[]);n.add(t),await this.cache.set(this.manifestKey,{keys:[...n]})}async remove(t){const e=await this.cache.get(this.manifestKey);if(e){const n=new Set(e.keys);return n.delete(t),n.size>0?await this.cache.set(this.manifestKey,{keys:[...n]}):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 G={memory:()=>(new B).enclosedCache,localstorage:()=>new N},Y=t=>G[t],J=t=>{const{openUrl:e,onRedirect:n}=t,r=o(t,["openUrl","onRedirect"]);return Object.assign(Object.assign({},r),{openUrl:!1===e||e?e:n})},Q=new h;class tt{constructor(t){let e,n;if(this.userCache=(new B).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(!x())throw new Error("For security reasons, `window.crypto` is required to run `auth0-spa-js`.");if(void 0===x().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)n=t.cache;else{if(e=t.cacheLocation||"memory",!Y(e))throw new Error(`Invalid cache location "${e}"`);n=Y(e)()}this.httpTimeoutMs=t.httpTimeoutInSeconds?1e3*t.httpTimeoutInSeconds:1e4,this.cookieStorage=!1===t.legacySameSiteCookie?$:W,this.orgHintCookieName=`auth0.${this.options.clientId}.organization_hint`,this.isAuthenticatedCookieName=(t=>`auth0.${this.options.clientId}.is.authenticated`)(),this.sessionCheckExpiryDays=t.sessionCheckExpiryDays||1;const r=t.useCookiesForTransactions?this.cookieStorage:z;var o;this.scope=I("openid",this.options.authorizationParams.scope,this.options.useRefreshTokens?"offline_access":""),this.transactionManager=new L(r,this.options.clientId,this.options.cookieDomain),this.nowProvider=this.options.nowProvider||p,this.cacheManager=new U(n,n.allKeys?void 0:new X(n,this.options.clientId),this.nowProvider),this.domainUrl=(o=this.options.domain,/^https?:\/\//.test(o)?o:`https://${o}`),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 q)}_url(t){const e=encodeURIComponent(btoa(JSON.stringify(this.options.auth0Client||f)));return`${this.domainUrl}${t}&auth0Client=${e}`}_authorizeUrl(t){return this._url(`/authorize?${_(t)}`)}async _verifyIdToken(t,e,n){const r=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("."),[n,r,o]=e;if(3!==e.length||!n||!r||!o)throw new Error("ID token could not be decoded");const i=JSON.parse(k(r)),s={__raw:t},a={};return Object.keys(i).forEach((t=>{s[t]=i[t],D.includes(t)||(a[t]=i[t])})),{encoded:{header:n,payload:r,signature:o},header:JSON.parse(k(n)),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 n=t.leeway||60,r=new Date(t.now||Date.now()),o=new Date(0);if(o.setUTCSeconds(e.claims.exp+n),r>o)throw new Error(`Expiration Time (exp) claim error in the ID token; current time (${r}) is after expiration time (${o})`);if(null!=e.claims.nbf&&j(e.claims.nbf)){const t=new Date(0);if(t.setUTCSeconds(e.claims.nbf-n),r<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 (${r}) is before ${t}`)}if(null!=e.claims.auth_time&&j(e.claims.auth_time)){const o=new Date(0);if(o.setUTCSeconds(parseInt(e.claims.auth_time)+t.max_age+n),r>o)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 (${r}) is after last auth at ${o}`)}if(t.organization){const n=t.organization.trim();if(n.startsWith("org_")){const t=n;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=n.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:n,leeway:this.options.leeway,max_age:(o=this.options.authorizationParams.max_age,"string"!=typeof o?o:parseInt(o,10)||void 0),now:r});var o}_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,n){const r=A(T()),o=A(T()),i=T(),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=x().subtle.digest({name:"SHA-256"},(new TextEncoder).encode(t));return await e})(i)),a=((t,e,n,r,o,i,s,a)=>Object.assign(Object.assign(Object.assign({client_id:t.clientId},t.authorizationParams),n),{scope:I(e,n.scope),response_type:"code",response_mode:a||"query",state:r,nonce:o,redirect_uri:s||t.authorizationParams.redirect_uri,code_challenge:i,code_challenge_method:"S256"}))(this.options,this.scope,t,r,o,s,t.redirect_uri||this.options.authorizationParams.redirect_uri||n,null==e?void 0:e.response_mode),c=this._authorizeUrl(a);return{nonce:o,code_verifier:i,scope:a.scope,audience:a.audience||"default",redirect_uri:a.redirect_uri,state:r,url:c}}async loginWithPopup(t,e){var n;if(t=t||{},!(e=e||{}).popup&&(e.popup=(t=>{const e=window.screenX+(window.innerWidth-400)/2,n=window.screenY+(window.innerHeight-600)/2;return window.open("","auth0:authorize:popup",`left=${e},top=${n},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 r=await this._prepareAuthorizeUrl(t.authorizationParams||{},{response_mode:"web_message"},window.location.origin);e.popup.location.href=r.url;const o=await(t=>new Promise(((e,n)=>{let r;const o=setInterval((()=>{t.popup&&t.popup.closed&&(clearInterval(o),clearTimeout(i),window.removeEventListener("message",r,!1),n(new v(t.popup)))}),1e3),i=setTimeout((()=>{clearInterval(o),n(new w(t.popup)),window.removeEventListener("message",r,!1)}),1e3*(t.timeoutInSeconds||60));r=function(s){if(s.data&&"authorization_response"===s.data.type){if(clearTimeout(i),clearInterval(o),window.removeEventListener("message",r,!1),t.popup.close(),s.data.response.error)return n(m.fromPayload(s.data.response));e(s.data.response)}},window.addEventListener("message",r)})))(Object.assign(Object.assign({},e),{timeoutInSeconds:e.timeoutInSeconds||this.options.authorizeTimeoutInSeconds||60}));if(r.state!==o.state)throw new m("state_mismatch","Invalid state");const i=(null===(n=t.authorizationParams)||void 0===n?void 0:n.organization)||this.options.authorizationParams.organization;await this._requestToken({audience:r.audience,scope:r.scope,code_verifier:r.code_verifier,grant_type:"authorization_code",code:o.code,redirect_uri:r.redirect_uri},{nonceIn:r.nonce,organization:i})}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 n=J(t),{openUrl:r,fragment:i,appState:s}=n,a=o(n,["openUrl","fragment","appState"]),c=(null===(e=a.authorizationParams)||void 0===e?void 0:e.organization)||this.options.authorizationParams.organization,l=await this._prepareAuthorizeUrl(a.authorizationParams||{}),{url:u}=l,h=o(l,["url"]);this.transactionManager.create(Object.assign(Object.assign(Object.assign({},h),{appState:s}),c&&{organization:c}));const d=i?`${u}#${i}`:u;r?await r(d):window.location.assign(d)}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:n,code:r,error:o,error_description:i}=(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 m("missing_transaction","Invalid state");if(this.transactionManager.remove(),o)throw new g(o,i||o,n,s.appState);if(!s.code_verifier||s.state&&s.state!==n)throw new m("state_mismatch","Invalid state");const a=s.organization,c=s.nonce,l=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:r},l?{redirect_uri:l}:{}),{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 n=Object.assign(Object.assign({cacheMode:"on"},t),{authorizationParams:Object.assign(Object.assign(Object.assign({},this.options.authorizationParams),t.authorizationParams),{scope:I(this.scope,null===(e=t.authorizationParams)||void 0===e?void 0:e.scope)})}),r=await((t,e)=>{let n=Z[e];return n||(n=t().finally((()=>{delete Z[e],n=null})),Z[e]=n),n})((()=>this._getTokenSilently(n)),`${this.options.clientId}::${n.authorizationParams.audience}::${n.authorizationParams.scope}`);return t.detailedResponse?r:null==r?void 0:r.access_token}async _getTokenSilently(t){const{cacheMode:e}=t,n=o(t,["cacheMode"]);if("off"!==e){const t=await this._getEntryFromCache({scope:n.authorizationParams.scope,audience:n.authorizationParams.audience||"default",clientId:this.options.clientId});if(t)return t}if("cache-only"!==e){if(!await(async(t,e=3)=>{for(let n=0;n<e;n++)if(await t())return!0;return!1})((()=>Q.acquireLock("auth0.lock.getTokenSilently",5e3)),10))throw new y;try{if(window.addEventListener("pagehide",this._releaseLockOnPageHide),"off"!==e){const t=await this._getEntryFromCache({scope:n.authorizationParams.scope,audience:n.authorizationParams.audience||"default",clientId:this.options.clientId});if(t)return t}const t=this.options.useRefreshTokens?await this._getTokenUsingRefreshToken(n):await this._getTokenFromIFrame(n),{id_token:r,access_token:o,oauthTokenScope:i,expires_in:s}=t;return Object.assign(Object.assign({id_token:r,access_token:o},i?{scope:i}:null),{expires_in:s})}finally{await Q.releaseLock("auth0.lock.getTokenSilently"),window.removeEventListener("pagehide",this._releaseLockOnPageHide)}}}async getTokenWithPopup(t={},e={}){var n;const r=Object.assign(Object.assign({},t),{authorizationParams:Object.assign(Object.assign(Object.assign({},this.options.authorizationParams),t.authorizationParams),{scope:I(this.scope,null===(n=t.authorizationParams)||void 0===n?void 0:n.scope)})});return e=Object.assign(Object.assign({},d),e),await this.loginWithPopup(r,e),(await this.cacheManager.get(new O({scope:r.authorizationParams.scope,audience:r.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:n}=e,r=o(e,["federated"]),i=n?"&federated":"";return this._url(`/v2/logout?${_(Object.assign({clientId:t.clientId},r))}`)+i}async logout(t={}){const e=J(t),{openUrl:n}=e,r=o(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 i=this._buildLogoutUrl(r);n?await n(i):!1!==n&&window.location.assign(i)}async _getTokenFromIFrame(t){const e=Object.assign(Object.assign({},t.authorizationParams),{prompt:"none"}),n=this.cookieStorage.get(this.orgHintCookieName);n&&!e.organization&&(e.organization=n);const{url:r,state:o,nonce:i,code_verifier:s,redirect_uri:a,scope:c,audience:l}=await this._prepareAuthorizeUrl(e,{response_mode:"web_message"},window.location.origin);try{if(window.crossOriginIsolated)throw new m("login_required","The application is running in a Cross-Origin Isolated context, silently retrieving a token without refresh token is not possible.");const n=t.timeoutInSeconds||this.options.authorizeTimeoutInSeconds,u=await((t,e,n=60)=>new Promise(((r,o)=>{const i=window.document.createElement("iframe");i.setAttribute("width","0"),i.setAttribute("height","0"),i.style.display="none";const s=()=>{window.document.body.contains(i)&&(window.document.body.removeChild(i),window.removeEventListener("message",a,!1))};let a;const c=setTimeout((()=>{o(new y),s()}),1e3*n);a=function(t){if(t.origin!=e)return;if(!t.data||"authorization_response"!==t.data.type)return;const n=t.source;n&&n.close(),t.data.response.error?o(m.fromPayload(t.data.response)):r(t.data.response),clearTimeout(c),window.removeEventListener("message",a,!1),setTimeout(s,2e3)},window.addEventListener("message",a,!1),window.document.body.appendChild(i),i.setAttribute("src",t)})))(r,this.domainUrl,n);if(o!==u.state)throw new m("state_mismatch","Invalid state");const h=await this._requestToken(Object.assign(Object.assign({},t.authorizationParams),{code_verifier:s,code:u.code,grant_type:"authorization_code",redirect_uri:a,timeout:t.authorizationParams.timeout||this.httpTimeoutMs}),{nonceIn:i,organization:e.organization});return Object.assign(Object.assign({},h),{scope:c,oauthTokenScope:h.scope,audience:l})}catch(t){throw"login_required"===t.error&&this.logout({openUrl:!1}),t}}async _getTokenUsingRefreshToken(t){const e=await this.cacheManager.get(new O({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 n=t.authorizationParams.redirect_uri||this.options.authorizationParams.redirect_uri||window.location.origin,r="number"==typeof t.timeoutInSeconds?1e3*t.timeoutInSeconds:null;try{const o=await this._requestToken(Object.assign(Object.assign(Object.assign({},t.authorizationParams),{grant_type:"refresh_token",refresh_token:e&&e.refresh_token,redirect_uri:n}),r&&{timeout:r}));return Object.assign(Object.assign({},o),{scope:t.authorizationParams.scope,oauthTokenScope:o.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:n}=t,r=o(t,["id_token","decodedToken"]);this.userCache.set("@@user@@",{id_token:e,decodedToken:n}),await this.cacheManager.setIdToken(this.options.clientId,t.id_token,t.decodedToken),await this.cacheManager.set(r)}async _getIdTokenFromCache(){const t=this.options.authorizationParams.audience||"default",e=await this.cacheManager.getIdToken(new O({clientId:this.options.clientId,audience:t,scope:this.scope})),n=this.userCache.get("@@user@@");return e&&e.id_token===(null==n?void 0:n.id_token)?n:(this.userCache.set("@@user@@",e),e)}async _getEntryFromCache({scope:t,audience:e,clientId:n}){const r=await this.cacheManager.get(new O({scope:t,audience:e,clientId:n}),60);if(r&&r.access_token){const{access_token:t,oauthTokenScope:e,expires_in:n}=r,o=await this._getIdTokenFromCache();return o&&Object.assign(Object.assign({id_token:o.id_token,access_token:t},e?{scope:e}:null),{expires_in:n})}}async _requestToken(t,e){const{nonceIn:n,organization:r}=e||{},o=await P(Object.assign({baseUrl:this.domainUrl,client_id:this.options.clientId,auth0Client:this.options.auth0Client,useFormData:this.options.useFormData,timeout:this.httpTimeoutMs},t),this.worker),i=await this._verifyIdToken(o.id_token,n,r);return await this._saveEntryInCache(Object.assign(Object.assign(Object.assign(Object.assign({},o),{decodedToken:i,scope:t.scope,audience:t.audience||"default"}),o.scope?{oauthTokenScope:o.scope}:null),{client_id:this.options.clientId})),this.cookieStorage.save(this.isAuthenticatedCookieName,!0,{daysUntilExpire:this.sessionCheckExpiryDays,cookieDomain:this.options.cookieDomain}),this._processOrgHint(r||i.claims.org_id),Object.assign(Object.assign({},o),{decodedToken:i})}}var et=a(470);function nt(t,e){return function(){return t.apply(e,arguments)}}const{toString:rt}=Object.prototype,{getPrototypeOf:ot}=Object,it=(st=Object.create(null),t=>{const e=rt.call(t);return st[e]||(st[e]=e.slice(8,-1).toLowerCase())});var st;const at=t=>(t=t.toLowerCase(),e=>it(e)===t),ct=t=>e=>typeof e===t,{isArray:lt}=Array,ut=ct("undefined");const ht=at("ArrayBuffer");const dt=ct("string"),ft=ct("function"),pt=ct("number"),mt=t=>null!==t&&"object"==typeof t,gt=t=>{if("object"!==it(t))return!1;const e=ot(t);return!(null!==e&&e!==Object.prototype&&null!==Object.getPrototypeOf(e)||Symbol.toStringTag in t||Symbol.iterator in t)},yt=at("Date"),wt=at("File"),vt=at("Blob"),bt=at("FileList"),Et=at("URLSearchParams");function St(t,e,{allOwnKeys:n=!1}={}){if(null==t)return;let r,o;if("object"!=typeof t&&(t=[t]),lt(t))for(r=0,o=t.length;r<o;r++)e.call(null,t[r],r,t);else{const o=n?Object.getOwnPropertyNames(t):Object.keys(t),i=o.length;let s;for(r=0;r<i;r++)s=o[r],e.call(null,t[s],s,t)}}function xt(t,e){e=e.toLowerCase();const n=Object.keys(t);let r,o=n.length;for(;o-- >0;)if(r=n[o],e===r.toLowerCase())return r;return null}const Tt="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,At=t=>!ut(t)&&t!==Tt;const _t=(kt="undefined"!=typeof Uint8Array&&ot(Uint8Array),t=>kt&&t instanceof kt);var kt;const Rt=at("HTMLFormElement"),Ct=(({hasOwnProperty:t})=>(e,n)=>t.call(e,n))(Object.prototype),Pt=at("RegExp"),It=(t,e)=>{const n=Object.getOwnPropertyDescriptors(t),r={};St(n,((n,o)=>{let i;!1!==(i=e(n,o,t))&&(r[o]=i||n)})),Object.defineProperties(t,r)},Ot="abcdefghijklmnopqrstuvwxyz",Nt="0123456789",Bt={DIGIT:Nt,ALPHA:Ot,ALPHA_DIGIT:Ot+Ot.toUpperCase()+Nt};const Ut=at("AsyncFunction"),Lt={isArray:lt,isArrayBuffer:ht,isBuffer:function(t){return null!==t&&!ut(t)&&null!==t.constructor&&!ut(t.constructor)&&ft(t.constructor.isBuffer)&&t.constructor.isBuffer(t)},isFormData:t=>{let e;return t&&("function"==typeof FormData&&t instanceof FormData||ft(t.append)&&("formdata"===(e=it(t))||"object"===e&&ft(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:dt,isNumber:pt,isBoolean:t=>!0===t||!1===t,isObject:mt,isPlainObject:gt,isUndefined:ut,isDate:yt,isFile:wt,isBlob:vt,isRegExp:Pt,isFunction:ft,isStream:t=>mt(t)&&ft(t.pipe),isURLSearchParams:Et,isTypedArray:_t,isFileList:bt,forEach:St,merge:function t(){const{caseless:e}=At(this)&&this||{},n={},r=(r,o)=>{const i=e&&xt(n,o)||o;gt(n[i])&&gt(r)?n[i]=t(n[i],r):gt(r)?n[i]=t({},r):lt(r)?n[i]=r.slice():n[i]=r};for(let t=0,e=arguments.length;t<e;t++)arguments[t]&&St(arguments[t],r);return n},extend:(t,e,n,{allOwnKeys:r}={})=>(St(e,((e,r)=>{n&&ft(e)?t[r]=nt(e,n):t[r]=e}),{allOwnKeys:r}),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,n,r)=>{t.prototype=Object.create(e.prototype,r),t.prototype.constructor=t,Object.defineProperty(t,"super",{value:e.prototype}),n&&Object.assign(t.prototype,n)},toFlatObject:(t,e,n,r)=>{let o,i,s;const a={};if(e=e||{},null==t)return e;do{for(o=Object.getOwnPropertyNames(t),i=o.length;i-- >0;)s=o[i],r&&!r(s,t,e)||a[s]||(e[s]=t[s],a[s]=!0);t=!1!==n&&ot(t)}while(t&&(!n||n(t,e))&&t!==Object.prototype);return e},kindOf:it,kindOfTest:at,endsWith:(t,e,n)=>{t=String(t),(void 0===n||n>t.length)&&(n=t.length),n-=e.length;const r=t.indexOf(e,n);return-1!==r&&r===n},toArray:t=>{if(!t)return null;if(lt(t))return t;let e=t.length;if(!pt(e))return null;const n=new Array(e);for(;e-- >0;)n[e]=t[e];return n},forEachEntry:(t,e)=>{const n=(t&&t[Symbol.iterator]).call(t);let r;for(;(r=n.next())&&!r.done;){const n=r.value;e.call(t,n[0],n[1])}},matchAll:(t,e)=>{let n;const r=[];for(;null!==(n=t.exec(e));)r.push(n);return r},isHTMLForm:Rt,hasOwnProperty:Ct,hasOwnProp:Ct,reduceDescriptors:It,freezeMethods:t=>{It(t,((e,n)=>{if(ft(t)&&-1!==["arguments","caller","callee"].indexOf(n))return!1;const r=t[n];ft(r)&&(e.enumerable=!1,"writable"in e?e.writable=!1:e.set||(e.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")}))}))},toObjectSet:(t,e)=>{const n={},r=t=>{t.forEach((t=>{n[t]=!0}))};return lt(t)?r(t):r(String(t).split(e)),n},toCamelCase:t=>t.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,(function(t,e,n){return e.toUpperCase()+n})),noop:()=>{},toFiniteNumber:(t,e)=>(t=+t,Number.isFinite(t)?t:e),findKey:xt,global:Tt,isContextDefined:At,ALPHABET:Bt,generateString:(t=16,e=Bt.ALPHA_DIGIT)=>{let n="";const{length:r}=e;for(;t--;)n+=e[Math.random()*r|0];return n},isSpecCompliantForm:function(t){return!!(t&&ft(t.append)&&"FormData"===t[Symbol.toStringTag]&&t[Symbol.iterator])},toJSONObject:t=>{const e=new Array(10),n=(t,r)=>{if(mt(t)){if(e.indexOf(t)>=0)return;if(!("toJSON"in t)){e[r]=t;const o=lt(t)?[]:{};return St(t,((t,e)=>{const i=n(t,r+1);!ut(i)&&(o[e]=i)})),e[r]=void 0,o}}return t};return n(t,0)},isAsyncFn:Ut,isThenable:t=>t&&(mt(t)||ft(t))&&ft(t.then)&&ft(t.catch)};function jt(t,e,n,r,o){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),n&&(this.config=n),r&&(this.request=r),o&&(this.response=o)}Lt.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:Lt.toJSONObject(this.config),code:this.code,status:this.response&&this.response.status?this.response.status:null}}});const Dt=jt.prototype,Mt={};["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=>{Mt[t]={value:t}})),Object.defineProperties(jt,Mt),Object.defineProperty(Dt,"isAxiosError",{value:!0}),jt.from=(t,e,n,r,o,i)=>{const s=Object.create(Dt);return Lt.toFlatObject(t,s,(function(t){return t!==Error.prototype}),(t=>"isAxiosError"!==t)),jt.call(s,t.message,e,n,r,o),s.cause=t,s.name=t.name,i&&Object.assign(s,i),s};const Vt=jt;function Ft(t){return Lt.isPlainObject(t)||Lt.isArray(t)}function Kt(t){return Lt.endsWith(t,"[]")?t.slice(0,-2):t}function $t(t,e,n){return t?t.concat(e).map((function(t,e){return t=Kt(t),!n&&e?"["+t+"]":t})).join(n?".":""):e}const Wt=Lt.toFlatObject(Lt,{},null,(function(t){return/^is[A-Z]/.test(t)}));const zt=function(t,e,n){if(!Lt.isObject(t))throw new TypeError("target must be an object");e=e||new FormData;const r=(n=Lt.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,(function(t,e){return!Lt.isUndefined(e[t])}))).metaTokens,o=n.visitor||l,i=n.dots,s=n.indexes,a=(n.Blob||"undefined"!=typeof Blob&&Blob)&&Lt.isSpecCompliantForm(e);if(!Lt.isFunction(o))throw new TypeError("visitor must be a function");function c(t){if(null===t)return"";if(Lt.isDate(t))return t.toISOString();if(!a&&Lt.isBlob(t))throw new Vt("Blob is not supported. Use a Buffer instead.");return Lt.isArrayBuffer(t)||Lt.isTypedArray(t)?a&&"function"==typeof Blob?new Blob([t]):Buffer.from(t):t}function l(t,n,o){let a=t;if(t&&!o&&"object"==typeof t)if(Lt.endsWith(n,"{}"))n=r?n:n.slice(0,-2),t=JSON.stringify(t);else if(Lt.isArray(t)&&function(t){return Lt.isArray(t)&&!t.some(Ft)}(t)||(Lt.isFileList(t)||Lt.endsWith(n,"[]"))&&(a=Lt.toArray(t)))return n=Kt(n),a.forEach((function(t,r){!Lt.isUndefined(t)&&null!==t&&e.append(!0===s?$t([n],r,i):null===s?n:n+"[]",c(t))})),!1;return!!Ft(t)||(e.append($t(o,n,i),c(t)),!1)}const u=[],h=Object.assign(Wt,{defaultVisitor:l,convertValue:c,isVisitable:Ft});if(!Lt.isObject(t))throw new TypeError("data must be an object");return function t(n,r){if(!Lt.isUndefined(n)){if(-1!==u.indexOf(n))throw Error("Circular reference detected in "+r.join("."));u.push(n),Lt.forEach(n,(function(n,i){!0===(!(Lt.isUndefined(n)||null===n)&&o.call(e,n,Lt.isString(i)?i.trim():i,r,h))&&t(n,r?r.concat(i):[i])})),u.pop()}}(t),e};function Ht(t){const e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(t).replace(/[!'()~]|%20|%00/g,(function(t){return e[t]}))}function qt(t,e){this._pairs=[],t&&zt(t,this,e)}const Zt=qt.prototype;Zt.append=function(t,e){this._pairs.push([t,e])},Zt.toString=function(t){const e=t?function(e){return t.call(this,e,Ht)}:Ht;return this._pairs.map((function(t){return e(t[0])+"="+e(t[1])}),"").join("&")};const Xt=qt;function Gt(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,n){if(!e)return t;const r=n&&n.encode||Gt,o=n&&n.serialize;let i;if(i=o?o(e,n):Lt.isURLSearchParams(e)?e.toString():new Xt(e,n).toString(r),i){const e=t.indexOf("#");-1!==e&&(t=t.slice(0,e)),t+=(-1===t.indexOf("?")?"?":"&")+i}return t}const Jt=class{constructor(){this.handlers=[]}use(t,e,n){return this.handlers.push({fulfilled:t,rejected:e,synchronous:!!n&&n.synchronous,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){Lt.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:Xt,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,ne=(re="undefined"!=typeof navigator&&navigator.product,ee&&["ReactNative","NativeScript","NS"].indexOf(re)<0);var re;const oe="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,ie={...t,...te};const se=function(t){function e(t,n,r,o){let i=t[o++];if("__proto__"===i)return!0;const s=Number.isFinite(+i),a=o>=t.length;if(i=!i&&Lt.isArray(r)?r.length:i,a)return Lt.hasOwnProp(r,i)?r[i]=[r[i],n]:r[i]=n,!s;r[i]&&Lt.isObject(r[i])||(r[i]=[]);return e(t,n,r[i],o)&&Lt.isArray(r[i])&&(r[i]=function(t){const e={},n=Object.keys(t);let r;const o=n.length;let i;for(r=0;r<o;r++)i=n[r],e[i]=t[i];return e}(r[i])),!s}if(Lt.isFormData(t)&&Lt.isFunction(t.entries)){const n={};return Lt.forEachEntry(t,((t,r)=>{e(function(t){return Lt.matchAll(/\w+|\[(\w*)]/g,t).map((t=>"[]"===t[0]?"":t[1]||t[0]))}(t),r,n,0)})),n}return null};const ae={transitional:Qt,adapter:["xhr","http"],transformRequest:[function(t,e){const n=e.getContentType()||"",r=n.indexOf("application/json")>-1,o=Lt.isObject(t);o&&Lt.isHTMLForm(t)&&(t=new FormData(t));if(Lt.isFormData(t))return r&&r?JSON.stringify(se(t)):t;if(Lt.isArrayBuffer(t)||Lt.isBuffer(t)||Lt.isStream(t)||Lt.isFile(t)||Lt.isBlob(t))return t;if(Lt.isArrayBufferView(t))return t.buffer;if(Lt.isURLSearchParams(t))return e.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let i;if(o){if(n.indexOf("application/x-www-form-urlencoded")>-1)return function(t,e){return zt(t,new ie.classes.URLSearchParams,Object.assign({visitor:function(t,e,n,r){return ie.isNode&&Lt.isBuffer(t)?(this.append(e,t.toString("base64")),!1):r.defaultVisitor.apply(this,arguments)}},e))}(t,this.formSerializer).toString();if((i=Lt.isFileList(t))||n.indexOf("multipart/form-data")>-1){const e=this.env&&this.env.FormData;return zt(i?{"files[]":t}:t,e&&new e,this.formSerializer)}}return o||r?(e.setContentType("application/json",!1),function(t,e,n){if(Lt.isString(t))try{return(e||JSON.parse)(t),Lt.trim(t)}catch(t){if("SyntaxError"!==t.name)throw t}return(n||JSON.stringify)(t)}(t)):t}],transformResponse:[function(t){const e=this.transitional||ae.transitional,n=e&&e.forcedJSONParsing,r="json"===this.responseType;if(t&&Lt.isString(t)&&(n&&!this.responseType||r)){const n=!(e&&e.silentJSONParsing)&&r;try{return JSON.parse(t)}catch(t){if(n){if("SyntaxError"===t.name)throw Vt.from(t,Vt.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:ie.classes.FormData,Blob:ie.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};Lt.forEach(["delete","get","head","post","put","patch"],(t=>{ae.headers[t]={}}));const ce=ae,le=Lt.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"]),ue=Symbol("internals");function he(t){return t&&String(t).trim().toLowerCase()}function de(t){return!1===t||null==t?t:Lt.isArray(t)?t.map(de):String(t)}function fe(t,e,n,r,o){return Lt.isFunction(r)?r.call(this,e,n):(o&&(e=n),Lt.isString(e)?Lt.isString(r)?-1!==e.indexOf(r):Lt.isRegExp(r)?r.test(e):void 0:void 0)}class pe{constructor(t){t&&this.set(t)}set(t,e,n){const r=this;function o(t,e,n){const o=he(e);if(!o)throw new Error("header name must be a non-empty string");const i=Lt.findKey(r,o);(!i||void 0===r[i]||!0===n||void 0===n&&!1!==r[i])&&(r[i||e]=de(t))}const i=(t,e)=>Lt.forEach(t,((t,n)=>o(t,n,e)));return Lt.isPlainObject(t)||t instanceof this.constructor?i(t,e):Lt.isString(t)&&(t=t.trim())&&!/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(t.trim())?i((t=>{const e={};let n,r,o;return t&&t.split("\n").forEach((function(t){o=t.indexOf(":"),n=t.substring(0,o).trim().toLowerCase(),r=t.substring(o+1).trim(),!n||e[n]&&le[n]||("set-cookie"===n?e[n]?e[n].push(r):e[n]=[r]:e[n]=e[n]?e[n]+", "+r:r)})),e})(t),e):null!=t&&o(e,t,n),this}get(t,e){if(t=he(t)){const n=Lt.findKey(this,t);if(n){const t=this[n];if(!e)return t;if(!0===e)return function(t){const e=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=n.exec(t);)e[r[1]]=r[2];return e}(t);if(Lt.isFunction(e))return e.call(this,t,n);if(Lt.isRegExp(e))return e.exec(t);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,e){if(t=he(t)){const n=Lt.findKey(this,t);return!(!n||void 0===this[n]||e&&!fe(0,this[n],n,e))}return!1}delete(t,e){const n=this;let r=!1;function o(t){if(t=he(t)){const o=Lt.findKey(n,t);!o||e&&!fe(0,n[o],o,e)||(delete n[o],r=!0)}}return Lt.isArray(t)?t.forEach(o):o(t),r}clear(t){const e=Object.keys(this);let n=e.length,r=!1;for(;n--;){const o=e[n];t&&!fe(0,this[o],o,t,!0)||(delete this[o],r=!0)}return r}normalize(t){const e=this,n={};return Lt.forEach(this,((r,o)=>{const i=Lt.findKey(n,o);if(i)return e[i]=de(r),void delete e[o];const s=t?function(t){return t.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,((t,e,n)=>e.toUpperCase()+n))}(o):String(o).trim();s!==o&&delete e[o],e[s]=de(r),n[s]=!0})),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const e=Object.create(null);return Lt.forEach(this,((n,r)=>{null!=n&&!1!==n&&(e[r]=t&&Lt.isArray(n)?n.join(", "):n)})),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 n=new this(t);return e.forEach((t=>n.set(t))),n}static accessor(t){const e=(this[ue]=this[ue]={accessors:{}}).accessors,n=this.prototype;function r(t){const r=he(t);e[r]||(!function(t,e){const n=Lt.toCamelCase(" "+e);["get","set","has"].forEach((r=>{Object.defineProperty(t,r+n,{value:function(t,n,o){return this[r].call(this,e,t,n,o)},configurable:!0})}))}(n,t),e[r]=!0)}return Lt.isArray(t)?t.forEach(r):r(t),this}}pe.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),Lt.reduceDescriptors(pe.prototype,(({value:t},e)=>{let n=e[0].toUpperCase()+e.slice(1);return{get:()=>t,set(t){this[n]=t}}})),Lt.freezeMethods(pe);const me=pe;function ge(t,e){const n=this||ce,r=e||n,o=me.from(r.headers);let i=r.data;return Lt.forEach(t,(function(t){i=t.call(n,i,o.normalize(),e?e.status:void 0)})),o.normalize(),i}function ye(t){return!(!t||!t.__CANCEL__)}function we(t,e,n){Vt.call(this,null==t?"canceled":t,Vt.ERR_CANCELED,e,n),this.name="CanceledError"}Lt.inherits(we,Vt,{__CANCEL__:!0});const ve=we;const be=ie.hasStandardBrowserEnv?{write(t,e,n,r,o,i){const s=[t+"="+encodeURIComponent(e)];Lt.isNumber(n)&&s.push("expires="+new Date(n).toGMTString()),Lt.isString(r)&&s.push("path="+r),Lt.isString(o)&&s.push("domain="+o),!0===i&&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=ie.hasStandardBrowserEnv?function(){const t=/(msie|trident)/i.test(navigator.userAgent),e=document.createElement("a");let n;function r(n){let r=n;return t&&(e.setAttribute("href",r),r=e.href),e.setAttribute("href",r),{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 n=r(window.location.href),function(t){const e=Lt.isString(t)?r(t):t;return e.protocol===n.protocol&&e.host===n.host}}():function(){return!0};const xe=function(t,e){t=t||10;const n=new Array(t),r=new Array(t);let o,i=0,s=0;return e=void 0!==e?e:1e3,function(a){const c=Date.now(),l=r[s];o||(o=c),n[i]=a,r[i]=c;let u=s,h=0;for(;u!==i;)h+=n[u++],u%=t;if(i=(i+1)%t,i===s&&(s=(s+1)%t),c-o<e)return;const d=l&&c-l;return d?Math.round(1e3*h/d):void 0}};function Te(t,e){let n=0;const r=xe(50,250);return o=>{const i=o.loaded,s=o.lengthComputable?o.total:void 0,a=i-n,c=r(a);n=i;const l={loaded:i,total:s,progress:s?i/s:void 0,bytes:a,rate:c||void 0,estimated:c&&s&&i<=s?(s-i)/c:void 0,event:o};l[e?"download":"upload"]=!0,t(l)}}const Ae={http:null,xhr:"undefined"!=typeof XMLHttpRequest&&function(t){return new Promise((function(e,n){let r=t.data;const o=me.from(t.headers).normalize();let i,s,{responseType:a,withXSRFToken:c}=t;function l(){t.cancelToken&&t.cancelToken.unsubscribe(i),t.signal&&t.signal.removeEventListener("abort",i)}if(Lt.isFormData(r))if(ie.hasStandardBrowserEnv||ie.hasStandardBrowserWebWorkerEnv)o.setContentType(!1);else if(!1!==(s=o.getContentType())){const[t,...e]=s?s.split(";").map((t=>t.trim())).filter(Boolean):[];o.setContentType([t||"multipart/form-data",...e].join("; "))}let u=new XMLHttpRequest;if(t.auth){const e=t.auth.username||"",n=t.auth.password?unescape(encodeURIComponent(t.auth.password)):"";o.set("Authorization","Basic "+btoa(e+":"+n))}const h=Ee(t.baseURL,t.url);function d(){if(!u)return;const r=me.from("getAllResponseHeaders"in u&&u.getAllResponseHeaders());!function(t,e,n){const r=n.config.validateStatus;n.status&&r&&!r(n.status)?e(new Vt("Request failed with status code "+n.status,[Vt.ERR_BAD_REQUEST,Vt.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n)):t(n)}((function(t){e(t),l()}),(function(t){n(t),l()}),{data:a&&"text"!==a&&"json"!==a?u.response:u.responseText,status:u.status,statusText:u.statusText,headers:r,config:t,request:u}),u=null}if(u.open(t.method.toUpperCase(),Yt(h,t.params,t.paramsSerializer),!0),u.timeout=t.timeout,"onloadend"in u?u.onloadend=d:u.onreadystatechange=function(){u&&4===u.readyState&&(0!==u.status||u.responseURL&&0===u.responseURL.indexOf("file:"))&&setTimeout(d)},u.onabort=function(){u&&(n(new Vt("Request aborted",Vt.ECONNABORTED,t,u)),u=null)},u.onerror=function(){n(new Vt("Network Error",Vt.ERR_NETWORK,t,u)),u=null},u.ontimeout=function(){let e=t.timeout?"timeout of "+t.timeout+"ms exceeded":"timeout exceeded";const r=t.transitional||Qt;t.timeoutErrorMessage&&(e=t.timeoutErrorMessage),n(new Vt(e,r.clarifyTimeoutError?Vt.ETIMEDOUT:Vt.ECONNABORTED,t,u)),u=null},ie.hasStandardBrowserEnv&&(c&&Lt.isFunction(c)&&(c=c(t)),c||!1!==c&&Se(h))){const e=t.xsrfHeaderName&&t.xsrfCookieName&&be.read(t.xsrfCookieName);e&&o.set(t.xsrfHeaderName,e)}void 0===r&&o.setContentType(null),"setRequestHeader"in u&&Lt.forEach(o.toJSON(),(function(t,e){u.setRequestHeader(e,t)})),Lt.isUndefined(t.withCredentials)||(u.withCredentials=!!t.withCredentials),a&&"json"!==a&&(u.responseType=t.responseType),"function"==typeof t.onDownloadProgress&&u.addEventListener("progress",Te(t.onDownloadProgress,!0)),"function"==typeof t.onUploadProgress&&u.upload&&u.upload.addEventListener("progress",Te(t.onUploadProgress)),(t.cancelToken||t.signal)&&(i=e=>{u&&(n(!e||e.type?new ve(null,t,u):e),u.abort(),u=null)},t.cancelToken&&t.cancelToken.subscribe(i),t.signal&&(t.signal.aborted?i():t.signal.addEventListener("abort",i)));const f=function(t){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(t);return e&&e[1]||""}(h);f&&-1===ie.protocols.indexOf(f)?n(new Vt("Unsupported protocol "+f+":",Vt.ERR_BAD_REQUEST,t)):u.send(r||null)}))}};Lt.forEach(Ae,((t,e)=>{if(t){try{Object.defineProperty(t,"name",{value:e})}catch(t){}Object.defineProperty(t,"adapterName",{value:e})}}));const _e=t=>`- ${t}`,ke=t=>Lt.isFunction(t)||null===t||!1===t,Re=t=>{t=Lt.isArray(t)?t:[t];const{length:e}=t;let n,r;const o={};for(let i=0;i<e;i++){let e;if(n=t[i],r=n,!ke(n)&&(r=Ae[(e=String(n)).toLowerCase()],void 0===r))throw new Vt(`Unknown adapter '${e}'`);if(r)break;o[e||"#"+i]=r}if(!r){const t=Object.entries(o).map((([t,e])=>`adapter ${t} `+(!1===e?"is not supported by the environment":"is not available in the build")));let n=e?t.length>1?"since :\n"+t.map(_e).join("\n"):" "+_e(t[0]):"as no adapter specified";throw new Vt("There is no suitable adapter to dispatch the request "+n,"ERR_NOT_SUPPORT")}return r};function Ce(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new ve(null,t)}function Pe(t){Ce(t),t.headers=me.from(t.headers),t.data=ge.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 Ce(t),e.data=ge.call(t,t.transformResponse,e),e.headers=me.from(e.headers),e}),(function(e){return ye(e)||(Ce(t),e&&e.response&&(e.response.data=ge.call(t,t.transformResponse,e.response),e.response.headers=me.from(e.response.headers))),Promise.reject(e)}))}const Ie=t=>t instanceof me?t.toJSON():t;function Oe(t,e){e=e||{};const n={};function r(t,e,n){return Lt.isPlainObject(t)&&Lt.isPlainObject(e)?Lt.merge.call({caseless:n},t,e):Lt.isPlainObject(e)?Lt.merge({},e):Lt.isArray(e)?e.slice():e}function o(t,e,n){return Lt.isUndefined(e)?Lt.isUndefined(t)?void 0:r(void 0,t,n):r(t,e,n)}function i(t,e){if(!Lt.isUndefined(e))return r(void 0,e)}function s(t,e){return Lt.isUndefined(e)?Lt.isUndefined(t)?void 0:r(void 0,t):r(void 0,e)}function a(n,o,i){return i in e?r(n,o):i in t?r(void 0,n):void 0}const c={url:i,method:i,data:i,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)=>o(Ie(t),Ie(e),!0)};return Lt.forEach(Object.keys(Object.assign({},t,e)),(function(r){const i=c[r]||o,s=i(t[r],e[r],r);Lt.isUndefined(s)&&i!==a||(n[r]=s)})),n}const Ne="1.6.5",Be={};["object","boolean","number","function","string","symbol"].forEach(((t,e)=>{Be[t]=function(n){return typeof n===t||"a"+(e<1?"n ":" ")+t}}));const Ue={};Be.transitional=function(t,e,n){function r(t,e){return"[Axios v1.6.5] Transitional option '"+t+"'"+e+(n?". "+n:"")}return(n,o,i)=>{if(!1===t)throw new Vt(r(o," has been removed"+(e?" in "+e:"")),Vt.ERR_DEPRECATED);return e&&!Ue[o]&&(Ue[o]=!0,console.warn(r(o," has been deprecated since v"+e+" and will be removed in the near future"))),!t||t(n,o,i)}};const Le={assertOptions:function(t,e,n){if("object"!=typeof t)throw new Vt("options must be an object",Vt.ERR_BAD_OPTION_VALUE);const r=Object.keys(t);let o=r.length;for(;o-- >0;){const i=r[o],s=e[i];if(s){const e=t[i],n=void 0===e||s(e,i,t);if(!0!==n)throw new Vt("option "+i+" must be "+n,Vt.ERR_BAD_OPTION_VALUE)}else if(!0!==n)throw new Vt("Unknown option "+i,Vt.ERR_BAD_OPTION)}},validators:Be},je=Le.validators;class De{constructor(t){this.defaults=t,this.interceptors={request:new Jt,response:new Jt}}request(t,e){"string"==typeof t?(e=e||{}).url=t:e=t||{},e=Oe(this.defaults,e);const{transitional:n,paramsSerializer:r,headers:o}=e;void 0!==n&&Le.assertOptions(n,{silentJSONParsing:je.transitional(je.boolean),forcedJSONParsing:je.transitional(je.boolean),clarifyTimeoutError:je.transitional(je.boolean)},!1),null!=r&&(Lt.isFunction(r)?e.paramsSerializer={serialize:r}:Le.assertOptions(r,{encode:je.function,serialize:je.function},!0)),e.method=(e.method||this.defaults.method||"get").toLowerCase();let i=o&&Lt.merge(o.common,o[e.method]);o&&Lt.forEach(["delete","get","head","post","put","patch","common"],(t=>{delete o[t]})),e.headers=me.concat(i,o);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 l;this.interceptors.response.forEach((function(t){c.push(t.fulfilled,t.rejected)}));let u,h=0;if(!a){const t=[Pe.bind(this),void 0];for(t.unshift.apply(t,s),t.push.apply(t,c),u=t.length,l=Promise.resolve(e);h<u;)l=l.then(t[h++],t[h++]);return l}u=s.length;let d=e;for(h=0;h<u;){const t=s[h++],e=s[h++];try{d=t(d)}catch(t){e.call(this,t);break}}try{l=Pe.call(this,d)}catch(t){return Promise.reject(t)}for(h=0,u=c.length;h<u;)l=l.then(c[h++],c[h++]);return l}getUri(t){return Yt(Ee((t=Oe(this.defaults,t)).baseURL,t.url),t.params,t.paramsSerializer)}}Lt.forEach(["delete","get","head","options"],(function(t){De.prototype[t]=function(e,n){return this.request(Oe(n||{},{method:t,url:e,data:(n||{}).data}))}})),Lt.forEach(["post","put","patch"],(function(t){function e(e){return function(n,r,o){return this.request(Oe(o||{},{method:t,headers:e?{"Content-Type":"multipart/form-data"}:{},url:n,data:r}))}}De.prototype[t]=e(),De.prototype[t+"Form"]=e(!0)}));const Me=De;class Ve{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 n=this;this.promise.then((t=>{if(!n._listeners)return;let e=n._listeners.length;for(;e-- >0;)n._listeners[e](t);n._listeners=null})),this.promise.then=t=>{let e;const r=new Promise((t=>{n.subscribe(t),e=t})).then(t);return r.cancel=function(){n.unsubscribe(e)},r},t((function(t,r,o){n.reason||(n.reason=new ve(t,r,o),e(n.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 Ve((function(e){t=e}));return{token:e,cancel:t}}}const Fe=Ve;const Ke={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(Ke).forEach((([t,e])=>{Ke[e]=t}));const $e=Ke;const We=function t(e){const n=new Me(e),r=nt(Me.prototype.request,n);return Lt.extend(r,Me.prototype,n,{allOwnKeys:!0}),Lt.extend(r,n,null,{allOwnKeys:!0}),r.create=function(n){return t(Oe(e,n))},r}(ce);We.Axios=Me,We.CanceledError=ve,We.CancelToken=Fe,We.isCancel=ye,We.VERSION=Ne,We.toFormData=zt,We.AxiosError=Vt,We.Cancel=We.CanceledError,We.all=function(t){return Promise.all(t)},We.spread=function(t){return function(e){return t.apply(null,e)}},We.isAxiosError=function(t){return Lt.isObject(t)&&!0===t.isAxiosError},We.mergeConfig=Oe,We.AxiosHeaders=me,We.formToJSON=t=>se(Lt.isHTMLForm(t)?new FormData(t):t),We.getAdapter=Re,We.HttpStatusCode=$e,We.default=We;const ze=We;var He=a(742),qe=Object.create,Ze=Object.defineProperty,Xe=Object.getOwnPropertyDescriptor,Ge=Object.getOwnPropertyNames,Ye=Object.getPrototypeOf,Je=Object.prototype.hasOwnProperty,Qe=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),tn=(t,e,n)=>(n=null!=t?qe(Ye(t)):{},((t,e,n,r)=>{if(e&&"object"==typeof e||"function"==typeof e)for(let o of Ge(e))!Je.call(t,o)&&o!==n&&Ze(t,o,{get:()=>e[o],enumerable:!(r=Xe(e,o))||r.enumerable});return t})(!e&&t&&t.__esModule?n:Ze(n,"default",{value:t,enumerable:!0}),t)),en=Qe((t=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(t){var e=t.length,n=e%4;if(!n)return t;var r=e,o=4-n,i=e+o,s=Buffer.alloc(i);for(s.write(t);o--;)s.write("=",r++);return s.toString()}})),nn=Qe((t=>{Object.defineProperty(t,"__esModule",{value:!0});var e=en();function n(t,e){return void 0===e&&(e="utf8"),Buffer.isBuffer(t)?o(t.toString("base64")):o(Buffer.from(t,e).toString("base64"))}function r(t){return t=t.toString(),e.default(t).replace(/\-/g,"+").replace(/_/g,"/")}function o(t){return t.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}var i=n;i.encode=n,i.decode=function(t,e){return void 0===e&&(e="utf8"),Buffer.from(r(t),"base64").toString(e)},i.toBase64=r,i.fromBase64=o,i.toBuffer=function(t){return Buffer.from(r(t),"base64")},t.default=i})),rn=Qe(((t,e)=>{e.exports=nn().default,e.exports.default=e.exports})),on=Qe((t=>{t.byteLength=function(t){var e=s(t),n=e[0],r=e[1];return 3*(n+r)/4-r},t.toByteArray=function(t){var e,n,i=s(t),a=i[0],c=i[1],l=new o(function(t,e,n){return 3*(e+n)/4-n}(0,a,c)),u=0,h=c>0?a-4:a;for(n=0;n<h;n+=4)e=r[t.charCodeAt(n)]<<18|r[t.charCodeAt(n+1)]<<12|r[t.charCodeAt(n+2)]<<6|r[t.charCodeAt(n+3)],l[u++]=e>>16&255,l[u++]=e>>8&255,l[u++]=255&e;return 2===c&&(e=r[t.charCodeAt(n)]<<2|r[t.charCodeAt(n+1)]>>4,l[u++]=255&e),1===c&&(e=r[t.charCodeAt(n)]<<10|r[t.charCodeAt(n+1)]<<4|r[t.charCodeAt(n+2)]>>2,l[u++]=e>>8&255,l[u++]=255&e),l},t.fromByteArray=function(t){for(var e,r=t.length,o=r%3,i=[],s=16383,a=0,l=r-o;a<l;a+=s)i.push(c(t,a,a+s>l?l:a+s));return 1===o?(e=t[r-1],i.push(n[e>>2]+n[e<<4&63]+"==")):2===o&&(e=(t[r-2]<<8)+t[r-1],i.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"=")),i.join("")};var e,n=[],r=[],o=typeof Uint8Array<"u"?Uint8Array:Array,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(e=0,64;e<64;++e)n[e]=i[e],r[i.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 n=t.indexOf("=");return-1===n&&(n=e),[n,n===e?0:4-n%4]}function a(t){return n[t>>18&63]+n[t>>12&63]+n[t>>6&63]+n[63&t]}function c(t,e,n){for(var r,o=[],i=e;i<n;i+=3)r=(t[i]<<16&16711680)+(t[i+1]<<8&65280)+(255&t[i+2]),o.push(a(r));return o.join("")}r["-".charCodeAt(0)]=62,r["_".charCodeAt(0)]=63})),sn=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=on();function n(t){return new TextDecoder("utf-8",{fatal:!0}).decode(t)}function r(t){return(new TextEncoder).encode(t)}function o(t){return new Uint8Array(e.toByteArray(c(t)))}function i(t){return e.fromByteArray(new Uint8Array(t))}function s(t){return a(i(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 n=0;n<t.length;n++)e+=t[n].byteLength;let n=new Uint8Array(e),r=0;n.set(new Uint8Array(t[0]),r),r+=t[0].byteLength;for(let e=1;e<t.length;e++)n.set(new Uint8Array(t[e]),r),r+=t[e].byteLength;return n},t.b64UrlToString=function(t){return n(o(t))},t.bufferToString=n,t.stringToBuffer=r,t.stringToB64Url=function(t){return s(r(t))},t.b64UrlToBuffer=o,t.bufferTob64=i,t.bufferTob64Url=s,t.b64UrlEncode=a,t.b64UrlDecode=c})),an=Qe((t=>{Object.defineProperty(t,"__esModule",{value:!0});var e=sn();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:n}={}){let r=await this.driver.sign({name:"RSA-PSS",saltLength:32},await this.jwkToCryptoKey(t),e);return new Uint8Array(r)}async hash(t,e="SHA-256"){let n=await this.driver.digest(e,t);return new Uint8Array(n)}async verify(t,e,n){let r={kty:"RSA",e:"AQAB",n:t},o=await this.jwkToPublicCryptoKey(r),i=await this.driver.digest("SHA-256",e),s=await this.driver.verify({name:"RSA-PSS",saltLength:0},o,n,e),a=await this.driver.verify({name:"RSA-PSS",saltLength:32},o,n,e),c=await this.driver.verify({name:"RSA-PSS",saltLength:Math.ceil((o.algorithm.modulusLength-1)/8)-i.byteLength-2},o,n,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,n,r){let o=await this.driver.importKey("raw","string"==typeof n?e.stringToBuffer(n):n,{name:"PBKDF2",length:32},!1,["deriveKey"]),i=await this.driver.deriveKey({name:"PBKDF2",salt:r?e.stringToBuffer(r):e.stringToBuffer("salt"),iterations:1e5,hash:"SHA-256"},o,{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},i,t);return e.concatBuffers([s,a])}async decrypt(t,n,r){let o=await this.driver.importKey("raw","string"==typeof n?e.stringToBuffer(n):n,{name:"PBKDF2",length:32},!1,["deriveKey"]),i=await this.driver.deriveKey({name:"PBKDF2",salt:r?e.stringToBuffer(r):e.stringToBuffer("salt"),iterations:1e5,hash:"SHA-256"},o,{name:"AES-CBC",length:256},!1,["encrypt","decrypt"]),s=t.slice(0,16),a=await this.driver.decrypt({name:"AES-CBC",iv:s},i,t.slice(16));return e.concatBuffers([a])}}})),cn=Qe((t=>{t.read=function(t,e,n,r,o){var i,s,a=8*o-r-1,c=(1<<a)-1,l=c>>1,u=-7,h=n?o-1:0,d=n?-1:1,f=t[e+h];for(h+=d,i=f&(1<<-u)-1,f>>=-u,u+=a;u>0;i=256*i+t[e+h],h+=d,u-=8);for(s=i&(1<<-u)-1,i>>=-u,u+=r;u>0;s=256*s+t[e+h],h+=d,u-=8);if(0===i)i=1-l;else{if(i===c)return s?NaN:1/0*(f?-1:1);s+=Math.pow(2,r),i-=l}return(f?-1:1)*s*Math.pow(2,i-r)},t.write=function(t,e,n,r,o,i){var s,a,c,l=8*i-o-1,u=(1<<l)-1,h=u>>1,d=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,f=r?0:i-1,p=r?1:-1,m=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=u):(s=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-s))<1&&(s--,c*=2),(e+=s+h>=1?d/c:d*Math.pow(2,1-h))*c>=2&&(s++,c/=2),s+h>=u?(a=0,s=u):s+h>=1?(a=(e*c-1)*Math.pow(2,o),s+=h):(a=e*Math.pow(2,h-1)*Math.pow(2,o),s=0));o>=8;t[n+f]=255&a,f+=p,a/=256,o-=8);for(s=s<<o|a,l+=o;l>0;t[n+f]=255&s,f+=p,s/=256,l-=8);t[n+f-p]|=128*m}})),ln=Qe((t=>{var e=on(),n=cn(),r="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 o=2147483647;function i(t){if(t>o)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,n){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return l(t)}return a(t,e,n)}function a(t,e,n){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 n=0|f(t,e),r=i(n),o=r.write(t,e);return o!==n&&(r=r.slice(0,o)),r}(t,e);if(ArrayBuffer.isView(t))return function(t){if(q(t,Uint8Array)){let e=new Uint8Array(t);return h(e.buffer,e.byteOffset,e.byteLength)}return u(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(q(t,ArrayBuffer)||t&&q(t.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(q(t,SharedArrayBuffer)||t&&q(t.buffer,SharedArrayBuffer)))return h(t,e,n);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');let r=t.valueOf&&t.valueOf();if(null!=r&&r!==t)return s.from(r,e,n);let o=function(t){if(s.isBuffer(t)){let e=0|d(t.length),n=i(e);return 0===n.length||t.copy(n,0,0,e),n}if(void 0!==t.length)return"number"!=typeof t.length||Z(t.length)?i(0):u(t);if("Buffer"===t.type&&Array.isArray(t.data))return u(t.data)}(t);if(o)return o;if(typeof Symbol<"u"&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return s.from(t[Symbol.toPrimitive]("string"),e,n);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 l(t){return c(t),i(t<0?0:0|d(t))}function u(t){let e=t.length<0?0:0|d(t.length),n=i(e);for(let r=0;r<e;r+=1)n[r]=255&t[r];return n}function h(t,e,n){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(n||0))throw new RangeError('"length" is outside of buffer bounds');let r;return r=void 0===e&&void 0===n?new Uint8Array(t):void 0===n?new Uint8Array(t,e):new Uint8Array(t,e,n),Object.setPrototypeOf(r,s.prototype),r}function d(t){if(t>=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return 0|t}function f(t,e){if(s.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||q(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 n=t.length,r=arguments.length>2&&!0===arguments[2];if(!r&&0===n)return 0;let o=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return W(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return z(t).length;default:if(o)return r?-1:W(t).length;e=(""+e).toLowerCase(),o=!0}}function p(t,e,n){let r=!1;if((void 0===e||e<0)&&(e=0),e>this.length||((void 0===n||n>this.length)&&(n=this.length),n<=0)||(n>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return R(this,e,n);case"utf8":case"utf-8":return T(this,e,n);case"ascii":return _(this,e,n);case"latin1":case"binary":return k(this,e,n);case"base64":return x(this,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,e,n);default:if(r)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),r=!0}}function m(t,e,n){let r=t[e];t[e]=t[n],t[n]=r}function g(t,e,n,r,o){if(0===t.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),Z(n=+n)&&(n=o?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(o)return-1;n=t.length-1}else if(n<0){if(!o)return-1;n=0}if("string"==typeof e&&(e=s.from(e,r)),s.isBuffer(e))return 0===e.length?-1:y(t,e,n,r,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,n):Uint8Array.prototype.lastIndexOf.call(t,e,n):y(t,[e],n,r,o);throw new TypeError("val must be string, number or Buffer")}function y(t,e,n,r,o){let i,s=1,a=t.length,c=e.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(t.length<2||e.length<2)return-1;s=2,a/=2,c/=2,n/=2}function l(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(o){let r=-1;for(i=n;i<a;i++)if(l(t,i)===l(e,-1===r?0:i-r)){if(-1===r&&(r=i),i-r+1===c)return r*s}else-1!==r&&(i-=i-r),r=-1}else for(n+c>a&&(n=a-c),i=n;i>=0;i--){let n=!0;for(let r=0;r<c;r++)if(l(t,i+r)!==l(e,r)){n=!1;break}if(n)return i}return-1}function w(t,e,n,r){n=Number(n)||0;let o=t.length-n;r?(r=Number(r))>o&&(r=o):r=o;let i,s=e.length;for(r>s/2&&(r=s/2),i=0;i<r;++i){let r=parseInt(e.substr(2*i,2),16);if(Z(r))return i;t[n+i]=r}return i}function v(t,e,n,r){return H(W(e,t.length-n),t,n,r)}function b(t,e,n,r){return H(function(t){let e=[];for(let n=0;n<t.length;++n)e.push(255&t.charCodeAt(n));return e}(e),t,n,r)}function E(t,e,n,r){return H(z(e),t,n,r)}function S(t,e,n,r){return H(function(t,e){let n,r,o,i=[];for(let s=0;s<t.length&&!((e-=2)<0);++s)n=t.charCodeAt(s),r=n>>8,o=n%256,i.push(o),i.push(r);return i}(e,t.length-n),t,n,r)}function x(t,n,r){return 0===n&&r===t.length?e.fromByteArray(t):e.fromByteArray(t.slice(n,r))}function T(t,e,n){n=Math.min(t.length,n);let r=[],o=e;for(;o<n;){let e=t[o],i=null,s=e>239?4:e>223?3:e>191?2:1;if(o+s<=n){let n,r,a,c;switch(s){case 1:e<128&&(i=e);break;case 2:n=t[o+1],128==(192&n)&&(c=(31&e)<<6|63&n,c>127&&(i=c));break;case 3:n=t[o+1],r=t[o+2],128==(192&n)&&128==(192&r)&&(c=(15&e)<<12|(63&n)<<6|63&r,c>2047&&(c<55296||c>57343)&&(i=c));break;case 4:n=t[o+1],r=t[o+2],a=t[o+3],128==(192&n)&&128==(192&r)&&128==(192&a)&&(c=(15&e)<<18|(63&n)<<12|(63&r)<<6|63&a,c>65535&&c<1114112&&(i=c))}}null===i?(i=65533,s=1):i>65535&&(i-=65536,r.push(i>>>10&1023|55296),i=56320|1023&i),r.push(i),o+=s}return function(t){let e=t.length;if(e<=A)return String.fromCharCode.apply(String,t);let n="",r=0;for(;r<e;)n+=String.fromCharCode.apply(String,t.slice(r,r+=A));return n}(r)}t.kMaxLength=o,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,n){return a(t,e,n)},Object.setPrototypeOf(s.prototype,Uint8Array.prototype),Object.setPrototypeOf(s,Uint8Array),s.alloc=function(t,e,n){return function(t,e,n){return c(t),t<=0?i(t):void 0!==e?"string"==typeof n?i(t).fill(e,n):i(t).fill(e):i(t)}(t,e,n)},s.allocUnsafe=function(t){return l(t)},s.allocUnsafeSlow=function(t){return l(t)},s.isBuffer=function(t){return null!=t&&!0===t._isBuffer&&t!==s.prototype},s.compare=function(t,e){if(q(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),q(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 n=t.length,r=e.length;for(let o=0,i=Math.min(n,r);o<i;++o)if(t[o]!==e[o]){n=t[o],r=e[o];break}return n<r?-1:r<n?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 n;if(void 0===e)for(e=0,n=0;n<t.length;++n)e+=t[n].length;let r=s.allocUnsafe(e),o=0;for(n=0;n<t.length;++n){let e=t[n];if(q(e,Uint8Array))o+e.length>r.length?(s.isBuffer(e)||(e=s.from(e)),e.copy(r,o)):Uint8Array.prototype.set.call(r,e,o);else{if(!s.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(r,o)}o+=e.length}return r},s.byteLength=f,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)m(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)m(this,e,e+3),m(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)m(this,e,e+7),m(this,e+1,e+6),m(this,e+2,e+5),m(this,e+3,e+4);return this},s.prototype.toString=function(){let t=this.length;return 0===t?"":0===arguments.length?T(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="",n=t.INSPECT_MAX_BYTES;return e=this.toString("hex",0,n).replace(/(.{2})/g,"$1 ").trim(),this.length>n&&(e+=" ... "),"<Buffer "+e+">"},r&&(s.prototype[r]=s.prototype.inspect),s.prototype.compare=function(t,e,n,r,o){if(q(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===n&&(n=t?t.length:0),void 0===r&&(r=0),void 0===o&&(o=this.length),e<0||n>t.length||r<0||o>this.length)throw new RangeError("out of range index");if(r>=o&&e>=n)return 0;if(r>=o)return-1;if(e>=n)return 1;if(this===t)return 0;let i=(o>>>=0)-(r>>>=0),a=(n>>>=0)-(e>>>=0),c=Math.min(i,a),l=this.slice(r,o),u=t.slice(e,n);for(let t=0;t<c;++t)if(l[t]!==u[t]){i=l[t],a=u[t];break}return i<a?-1:a<i?1:0},s.prototype.includes=function(t,e,n){return-1!==this.indexOf(t,e,n)},s.prototype.indexOf=function(t,e,n){return g(this,t,e,n,!0)},s.prototype.lastIndexOf=function(t,e,n){return g(this,t,e,n,!1)},s.prototype.write=function(t,e,n,r){if(void 0===e)r="utf8",n=this.length,e=0;else if(void 0===n&&"string"==typeof e)r=e,n=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e>>>=0,isFinite(n)?(n>>>=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}let o=this.length-e;if((void 0===n||n>o)&&(n=o),t.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");let i=!1;for(;;)switch(r){case"hex":return w(this,t,e,n);case"utf8":case"utf-8":return v(this,t,e,n);case"ascii":case"latin1":case"binary":return b(this,t,e,n);case"base64":return E(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return S(this,t,e,n);default:if(i)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),i=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var A=4096;function _(t,e,n){let r="";n=Math.min(t.length,n);for(let o=e;o<n;++o)r+=String.fromCharCode(127&t[o]);return r}function k(t,e,n){let r="";n=Math.min(t.length,n);for(let o=e;o<n;++o)r+=String.fromCharCode(t[o]);return r}function R(t,e,n){let r=t.length;(!e||e<0)&&(e=0),(!n||n<0||n>r)&&(n=r);let o="";for(let r=e;r<n;++r)o+=X[t[r]];return o}function C(t,e,n){let r=t.slice(e,n),o="";for(let t=0;t<r.length-1;t+=2)o+=String.fromCharCode(r[t]+256*r[t+1]);return o}function P(t,e,n){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>n)throw new RangeError("Trying to access beyond buffer length")}function I(t,e,n,r,o,i){if(!s.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||e<i)throw new RangeError('"value" argument is out of bounds');if(n+r>t.length)throw new RangeError("Index out of range")}function O(t,e,n,r,o){V(e,r,o,t,n,7);let i=Number(e&BigInt(4294967295));t[n++]=i,i>>=8,t[n++]=i,i>>=8,t[n++]=i,i>>=8,t[n++]=i;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[n++]=s,s>>=8,t[n++]=s,s>>=8,t[n++]=s,s>>=8,t[n++]=s,n}function N(t,e,n,r,o){V(e,r,o,t,n,7);let i=Number(e&BigInt(4294967295));t[n+7]=i,i>>=8,t[n+6]=i,i>>=8,t[n+5]=i,i>>=8,t[n+4]=i;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[n+3]=s,s>>=8,t[n+2]=s,s>>=8,t[n+1]=s,s>>=8,t[n]=s,n+8}function B(t,e,n,r,o,i){if(n+r>t.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function U(t,e,r,o,i){return e=+e,r>>>=0,i||B(t,0,r,4),n.write(t,e,r,o,23,4),r+4}function L(t,e,r,o,i){return e=+e,r>>>=0,i||B(t,0,r,8),n.write(t,e,r,o,52,8),r+8}s.prototype.slice=function(t,e){let n=this.length;(t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(e=void 0===e?n:~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),e<t&&(e=t);let r=this.subarray(t,e);return Object.setPrototypeOf(r,s.prototype),r},s.prototype.readUintLE=s.prototype.readUIntLE=function(t,e,n){t>>>=0,e>>>=0,n||P(t,e,this.length);let r=this[t],o=1,i=0;for(;++i<e&&(o*=256);)r+=this[t+i]*o;return r},s.prototype.readUintBE=s.prototype.readUIntBE=function(t,e,n){t>>>=0,e>>>=0,n||P(t,e,this.length);let r=this[t+--e],o=1;for(;e>0&&(o*=256);)r+=this[t+--e]*o;return r},s.prototype.readUint8=s.prototype.readUInt8=function(t,e){return t>>>=0,e||P(t,1,this.length),this[t]},s.prototype.readUint16LE=s.prototype.readUInt16LE=function(t,e){return t>>>=0,e||P(t,2,this.length),this[t]|this[t+1]<<8},s.prototype.readUint16BE=s.prototype.readUInt16BE=function(t,e){return t>>>=0,e||P(t,2,this.length),this[t]<<8|this[t+1]},s.prototype.readUint32LE=s.prototype.readUInt32LE=function(t,e){return t>>>=0,e||P(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||P(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},s.prototype.readBigUInt64LE=G((function(t){F(t>>>=0,"offset");let e=this[t],n=this[t+7];(void 0===e||void 0===n)&&K(t,this.length-8);let r=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,o=this[++t]+256*this[++t]+65536*this[++t]+n*2**24;return BigInt(r)+(BigInt(o)<<BigInt(32))})),s.prototype.readBigUInt64BE=G((function(t){F(t>>>=0,"offset");let e=this[t],n=this[t+7];(void 0===e||void 0===n)&&K(t,this.length-8);let r=e*2**24+65536*this[++t]+256*this[++t]+this[++t],o=this[++t]*2**24+65536*this[++t]+256*this[++t]+n;return(BigInt(r)<<BigInt(32))+BigInt(o)})),s.prototype.readIntLE=function(t,e,n){t>>>=0,e>>>=0,n||P(t,e,this.length);let r=this[t],o=1,i=0;for(;++i<e&&(o*=256);)r+=this[t+i]*o;return o*=128,r>=o&&(r-=Math.pow(2,8*e)),r},s.prototype.readIntBE=function(t,e,n){t>>>=0,e>>>=0,n||P(t,e,this.length);let r=e,o=1,i=this[t+--r];for(;r>0&&(o*=256);)i+=this[t+--r]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*e)),i},s.prototype.readInt8=function(t,e){return t>>>=0,e||P(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},s.prototype.readInt16LE=function(t,e){t>>>=0,e||P(t,2,this.length);let n=this[t]|this[t+1]<<8;return 32768&n?4294901760|n:n},s.prototype.readInt16BE=function(t,e){t>>>=0,e||P(t,2,this.length);let n=this[t+1]|this[t]<<8;return 32768&n?4294901760|n:n},s.prototype.readInt32LE=function(t,e){return t>>>=0,e||P(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||P(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},s.prototype.readBigInt64LE=G((function(t){F(t>>>=0,"offset");let e=this[t],n=this[t+7];(void 0===e||void 0===n)&&K(t,this.length-8);let r=this[t+4]+256*this[t+5]+65536*this[t+6]+(n<<24);return(BigInt(r)<<BigInt(32))+BigInt(e+256*this[++t]+65536*this[++t]+this[++t]*2**24)})),s.prototype.readBigInt64BE=G((function(t){F(t>>>=0,"offset");let e=this[t],n=this[t+7];(void 0===e||void 0===n)&&K(t,this.length-8);let r=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(r)<<BigInt(32))+BigInt(this[++t]*2**24+65536*this[++t]+256*this[++t]+n)})),s.prototype.readFloatLE=function(t,e){return t>>>=0,e||P(t,4,this.length),n.read(this,t,!0,23,4)},s.prototype.readFloatBE=function(t,e){return t>>>=0,e||P(t,4,this.length),n.read(this,t,!1,23,4)},s.prototype.readDoubleLE=function(t,e){return t>>>=0,e||P(t,8,this.length),n.read(this,t,!0,52,8)},s.prototype.readDoubleBE=function(t,e){return t>>>=0,e||P(t,8,this.length),n.read(this,t,!1,52,8)},s.prototype.writeUintLE=s.prototype.writeUIntLE=function(t,e,n,r){if(t=+t,e>>>=0,n>>>=0,!r){I(this,t,e,n,Math.pow(2,8*n)-1,0)}let o=1,i=0;for(this[e]=255&t;++i<n&&(o*=256);)this[e+i]=t/o&255;return e+n},s.prototype.writeUintBE=s.prototype.writeUIntBE=function(t,e,n,r){if(t=+t,e>>>=0,n>>>=0,!r){I(this,t,e,n,Math.pow(2,8*n)-1,0)}let o=n-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+n},s.prototype.writeUint8=s.prototype.writeUInt8=function(t,e,n){return t=+t,e>>>=0,n||I(this,t,e,1,255,0),this[e]=255&t,e+1},s.prototype.writeUint16LE=s.prototype.writeUInt16LE=function(t,e,n){return t=+t,e>>>=0,n||I(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,n){return t=+t,e>>>=0,n||I(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,n){return t=+t,e>>>=0,n||I(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,n){return t=+t,e>>>=0,n||I(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=G((function(t,e=0){return O(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),s.prototype.writeBigUInt64BE=G((function(t,e=0){return N(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),s.prototype.writeIntLE=function(t,e,n,r){if(t=+t,e>>>=0,!r){let r=Math.pow(2,8*n-1);I(this,t,e,n,r-1,-r)}let o=0,i=1,s=0;for(this[e]=255&t;++o<n&&(i*=256);)t<0&&0===s&&0!==this[e+o-1]&&(s=1),this[e+o]=(t/i>>0)-s&255;return e+n},s.prototype.writeIntBE=function(t,e,n,r){if(t=+t,e>>>=0,!r){let r=Math.pow(2,8*n-1);I(this,t,e,n,r-1,-r)}let o=n-1,i=1,s=0;for(this[e+o]=255&t;--o>=0&&(i*=256);)t<0&&0===s&&0!==this[e+o+1]&&(s=1),this[e+o]=(t/i>>0)-s&255;return e+n},s.prototype.writeInt8=function(t,e,n){return t=+t,e>>>=0,n||I(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},s.prototype.writeInt16LE=function(t,e,n){return t=+t,e>>>=0,n||I(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeInt16BE=function(t,e,n){return t=+t,e>>>=0,n||I(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeInt32LE=function(t,e,n){return t=+t,e>>>=0,n||I(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,n){return t=+t,e>>>=0,n||I(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=G((function(t,e=0){return O(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),s.prototype.writeBigInt64BE=G((function(t,e=0){return N(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),s.prototype.writeFloatLE=function(t,e,n){return U(this,t,e,!0,n)},s.prototype.writeFloatBE=function(t,e,n){return U(this,t,e,!1,n)},s.prototype.writeDoubleLE=function(t,e,n){return L(this,t,e,!0,n)},s.prototype.writeDoubleBE=function(t,e,n){return L(this,t,e,!1,n)},s.prototype.copy=function(t,e,n,r){if(!s.isBuffer(t))throw new TypeError("argument should be a Buffer");if(n||(n=0),!r&&0!==r&&(r=this.length),e>=t.length&&(e=t.length),e||(e=0),r>0&&r<n&&(r=n),r===n||0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),t.length-e<r-n&&(r=t.length-e+n);let o=r-n;return this===t&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(e,n,r):Uint8Array.prototype.set.call(t,this.subarray(n,r),e),o},s.prototype.fill=function(t,e,n,r){if("string"==typeof t){if("string"==typeof e?(r=e,e=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!s.isEncoding(r))throw new TypeError("Unknown encoding: "+r);if(1===t.length){let e=t.charCodeAt(0);("utf8"===r&&e<128||"latin1"===r)&&(t=e)}}else"number"==typeof t?t&=255:"boolean"==typeof t&&(t=Number(t));if(e<0||this.length<e||this.length<n)throw new RangeError("Out of range index");if(n<=e)return this;let o;if(e>>>=0,n=void 0===n?this.length:n>>>0,t||(t=0),"number"==typeof t)for(o=e;o<n;++o)this[o]=t;else{let i=s.isBuffer(t)?t:s.from(t,r),a=i.length;if(0===a)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(o=0;o<n-e;++o)this[o+e]=i[o%a]}return this};var j={};function D(t,e,n){j[t]=class extends n{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 M(t){let e="",n=t.length,r="-"===t[0]?1:0;for(;n>=r+4;n-=3)e=`_${t.slice(n-3,n)}${e}`;return`${t.slice(0,n)}${e}`}function V(t,e,n,r,o,i){if(t>n||t<e){let r,o="bigint"==typeof e?"n":"";throw r=i>3?0===e||e===BigInt(0)?`>= 0${o} and < 2${o} ** ${8*(i+1)}${o}`:`>= -(2${o} ** ${8*(i+1)-1}${o}) and < 2 ** ${8*(i+1)-1}${o}`:`>= ${e}${o} and <= ${n}${o}`,new j.ERR_OUT_OF_RANGE("value",r,t)}!function(t,e,n){F(e,"offset"),(void 0===t[e]||void 0===t[e+n])&&K(e,t.length-(n+1))}(r,o,i)}function F(t,e){if("number"!=typeof t)throw new j.ERR_INVALID_ARG_TYPE(e,"number",t)}function K(t,e,n){throw Math.floor(t)!==t?(F(t,n),new j.ERR_OUT_OF_RANGE(n||"offset","an integer",t)):e<0?new j.ERR_BUFFER_OUT_OF_BOUNDS:new j.ERR_OUT_OF_RANGE(n||"offset",`>= ${n?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,n){let r=`The value of "${t}" is out of range.`,o=n;return Number.isInteger(n)&&Math.abs(n)>2**32?o=M(String(n)):"bigint"==typeof n&&(o=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(o=M(o)),o+="n"),r+=` It must be ${e}. Received ${o}`,r}),RangeError);var $=/[^+/0-9A-Za-z-_]/g;function W(t,e){e=e||1/0;let n,r=t.length,o=null,i=[];for(let s=0;s<r;++s){if(n=t.charCodeAt(s),n>55295&&n<57344){if(!o){if(n>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(s+1===r){(e-=3)>-1&&i.push(239,191,189);continue}o=n;continue}if(n<56320){(e-=3)>-1&&i.push(239,191,189),o=n;continue}n=65536+(o-55296<<10|n-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,n<128){if((e-=1)<0)break;i.push(n)}else if(n<2048){if((e-=2)<0)break;i.push(n>>6|192,63&n|128)}else if(n<65536){if((e-=3)<0)break;i.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return i}function z(t){return e.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace($,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function H(t,e,n,r){let o;for(o=0;o<r&&!(o+n>=e.length||o>=t.length);++o)e[o+n]=t[o];return o}function q(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function Z(t){return t!=t}var X=function(){let t="0123456789abcdef",e=new Array(256);for(let n=0;n<16;++n){let r=16*n;for(let o=0;o<16;++o)e[r+o]=t[n]+t[o]}return e}();function G(t){return typeof BigInt>"u"?Y:t}function Y(){throw new Error("BigInt not supported")}})),un=Qe(((t,e)=>{typeof window<"u"?(window.global=window,global.fetch=window.fetch,e.exports={Buffer:ln().Buffer,Crypto:window.crypto}):e.exports={Buffer:ln().Buffer,Crypto:crypto}})),hn={};((t,e)=>{for(var n in e)Ze(t,n,{get:e[n],enumerable:!0})})(hn,{AVSCTap:()=>Cn,ArweaveSigner:()=>Tn,DataItem:()=>Mn,MAX_TAG_BYTES:()=>jn,MIN_BINARY_SIZE:()=>Dn,SIG_CONFIG:()=>xn,SignatureConfig:()=>wn,Signer:()=>dn,createData:()=>Fn,deserializeTags:()=>On,indexToType:()=>An,serializeTags:()=>Pn,tagsExceedLimit:()=>In});var dn=class{signer;publicKey;signatureType;signatureLength;ownerLength;pem;static verify(t,e,n,r){throw new Error("You must implement verify method on child")}},fn=tn(rn(),1),pn=tn(sn(),1);async function mn(t){if(Array.isArray(t)){let e=(0,pn.concatBuffers)([(0,pn.stringToBuffer)("list"),(0,pn.stringToBuffer)(t.length.toString())]);return await gn(t,await Sn().hash(e,"SHA-384"))}let e=t,n=(0,pn.concatBuffers)([(0,pn.stringToBuffer)("blob"),(0,pn.stringToBuffer)(e.byteLength.toString())]),r=(0,pn.concatBuffers)([await Sn().hash(n,"SHA-384"),await Sn().hash(e,"SHA-384")]);return await Sn().hash(r,"SHA-384")}async function gn(t,e){if(t.length<1)return e;let n=(0,pn.concatBuffers)([e,await mn(t[0])]),r=await Sn().hash(n,"SHA-384");return await gn(t.slice(1),r)}var yn,wn,vn=tn(an(),1),bn=vn.default.default?vn.default.default:vn.default,En=class extends bn{getPublicKey(t){throw new Error("Unimplemented")}};function Sn(){return yn??=new En}!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"}(wn||(wn={}));var xn={[wn.ARWEAVE]:{sigLength:512,pubLength:512,sigName:"arweave"},[wn.ED25519]:{sigLength:64,pubLength:32,sigName:"ed25519"},[wn.ETHEREUM]:{sigLength:65,pubLength:65,sigName:"ethereum"},[wn.SOLANA]:{sigLength:64,pubLength:32,sigName:"solana"},[wn.INJECTEDAPTOS]:{sigLength:64,pubLength:32,sigName:"injectedAptos"},[wn.MULTIAPTOS]:{sigLength:2052,pubLength:1025,sigName:"multiAptos"},[wn.TYPEDETHEREUM]:{sigLength:65,pubLength:42,sigName:"typedEthereum"}},Tn=class{signatureType=1;ownerLength=xn[1].pubLength;signatureLength=xn[1].sigLength;jwk;pk;constructor(t){this.pk=t.n,this.jwk=t}get publicKey(){return fn.default.toBuffer(this.pk)}sign(t){return Sn().sign(this.jwk,t)}static async verify(t,e,n){return await Sn().verify(t,e,n)}},An={1:Tn},_n=tn(rn(),1);async function kn(t){return mn([(0,pn.stringToBuffer)("dataitem"),(0,pn.stringToBuffer)("1"),(0,pn.stringToBuffer)(t.signatureType.toString()),t.rawOwner,t.rawTarget,t.rawAnchor,t.rawTags,t.rawData])}async function Rn(t,e){let{signature:n,id:r}=await async function(t,e){let n=await kn(t),r=await e.sign(n),o=await Sn().hash(r);return{signature:Buffer.from(r),id:Buffer.from(o)}}(t,e);return t.getRaw().set(n,2),r}var Cn=class{buf;pos;constructor(t=Buffer.alloc(jn),e=0){this.buf=t,this.pos=e}writeTags(t){if(!Array.isArray(t))throw new Error("input must be array");let e,n=t.length;if(n)for(this.writeLong(n),e=0;e<n;e++){let n=t[e];if(void 0===n?.name||void 0===n?.value)throw new Error(`Invalid tag format for ${n}, expected {name:string, value: string}`);this.writeString(n.name),this.writeString(n.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,n,r=this.buf;if(t>=-1073741824&&t<1073741824){n=t>=0?t<<1:~t<<1|1;do{r[this.pos]=127&n,n>>=7}while(n&&(r[this.pos++]|=128))}else{e=t>=0?2*t:2*-t-1;do{r[this.pos]=127&e,e/=128}while(e>=1&&(r[this.pos++]|=128))}this.pos++,this.buf=r}writeString(t){let e=Buffer.byteLength(t),n=this.buf;this.writeLong(e);let r=this.pos;if(this.pos+=e,!(this.pos>n.length)){if(e>64)this.buf.write(t,this.pos-e,e,"utf8");else{let o,i,s,a;for(o=0,i=e;o<i;o++)s=t.charCodeAt(o),s<128?n[r++]=s:s<2048?(n[r++]=s>>6|192,n[r++]=63&s|128):55296==(64512&s)&&56320==(64512&(a=t.charCodeAt(o+1)))?(s=65536+((1023&s)<<10)+(1023&a),o++,n[r++]=s>>18|240,n[r++]=s>>12&63|128,n[r++]=s>>6&63|128,n[r++]=63&s|128):(n[r++]=s>>12|224,n[r++]=s>>6&63|128,n[r++]=63&s|128)}this.buf=n}}readLong(){let t,e,n,r,o=0,i=0,s=this.buf;do{t=s[this.pos++],e=128&t,o|=(127&t)<<i,i+=7}while(e&&i<28);if(e){n=o,r=268435456;do{t=s[this.pos++],n+=(127&t)*r,r*=128}while(128&t);return(n%2?-(n+1):n)/2}return o>>1^-(1&o)}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(),n=this.readString();e.push({name:t,value:n})}return e}readString(){let t=this.readLong(),e=this.pos,n=this.buf;if(this.pos+=t,!(this.pos>n.length))return this.buf.slice(e,e+t).toString()}};function Pn(t){let e=new Cn;return e.writeTags(t),e.toBuffer()}function In(t){let e=new Cn;return e.writeTags(t),e.tagsExceedLimit()}function On(t){return new Cn(t).readTags()}function Nn(t){let e=0;for(let n=t.length-1;n>=0;n--)e=256*e+t[n];return e}function Bn(t){let e=[0,0,0,0,0,0,0,0];for(let n=0;n<e.length;n++){let r=255&t;e[n]=r,t=(t-r)/256}return Uint8Array.from(e)}var Un=tn(un(),1),Ln=tn(ln(),1),jn=4096,Dn=80,Mn=class{binary;_id;constructor(t){this.binary=t}static isDataItem(t){return void 0!==t.binary}get signatureType(){let t=Nn(this.binary.subarray(0,2));if(void 0!==wn?.[t])return t;throw new Error("Unknown signature type: "+t)}async isValid(){return Mn.verify(this.binary)}get id(){return(async()=>_n.default.encode(await this.rawId))()}set id(t){this._id=_n.default.toBuffer(t)}get rawId(){return(async()=>Ln.Buffer.from(await Un.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 _n.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 xn[this.signatureType].sigLength}get owner(){return _n.default.encode(this.rawOwner)}get ownerLength(){return xn[this.signatureType].pubLength}get rawTarget(){let t=this.getTargetStart();return 1==this.binary[t]?this.binary.subarray(t+1,t+33):Ln.Buffer.alloc(0)}get target(){return _n.default.encode(this.rawTarget)}get rawAnchor(){let t=this.getAnchorStart();return 1==this.binary[t]?this.binary.subarray(t+1,t+33):Ln.Buffer.alloc(0)}get anchor(){return this.rawAnchor.toString()}get rawTags(){let t=this.getTagsStart(),e=Nn(this.binary.subarray(t+8,t+16));return this.binary.subarray(t+16,t+16+e)}get tags(){let t=this.getTagsStart();if(0==Nn(this.binary.subarray(t,t+8)))return[];let e=Nn(this.binary.subarray(t+8,t+16));return On(Ln.Buffer.from(this.binary.subarray(t+16,t+16+e)))}get tagsB64Url(){return this.tags.map((t=>({name:_n.default.encode(t.name),value:_n.default.encode(t.value)})))}getStartOfData(){let t=this.getTagsStart();return t+16+Nn(this.binary.subarray(t+8,t+16))}get rawData(){let t=this.getTagsStart(),e=t+16+Nn(this.binary.subarray(t+8,t+16));return this.binary.subarray(e,this.binary.length)}get data(){return _n.default.encode(this.rawData)}getRaw(){return this.binary}async sign(t){return this._id=await Rn(this,t),this.rawId}async setSignature(t){this.binary.set(t,2),this._id=Ln.Buffer.from(await Sn().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:_n.default.encode(t.name),value:_n.default.encode(t.value)}))),data:this.data}}static async verify(t){if(t.byteLength<Dn)return!1;let e=new Mn(t),n=e.signatureType,r=e.getTagsStart(),o=Nn(t.subarray(r,r+8)),i=Nn(t.subarray(r+8,r+16));if(i>jn)return!1;if(o>0)try{if(On(Ln.Buffer.from(t.subarray(r+16,r+16+i))).length!==o)return!1}catch{return!1}let s=An[n],a=await kn(e);return await s.verify(e.rawOwner,a,e.rawSignature)}async getSignatureData(){return kn(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}},Vn=tn(rn(),1);function Fn(t,e,n){let r=e.publicKey,o=n?.target?Vn.default.toBuffer(n.target):null,i=1+(o?.byteLength??0),s=n?.anchor?Buffer.from(n.anchor):null,a=1+(s?.byteLength??0),c=(n?.tags?.length??0)>0?Pn(n.tags):null,l=16+(c?c.byteLength:0),u=Buffer.from(t),h=u.byteLength,d=2+e.signatureLength+e.ownerLength+i+a+l+h,f=Buffer.alloc(d);if(f.set(function(t){if(t>29)throw new Error("Short too long");let e=[0,0];for(let n=0;n<e.length;n++){let r=255&t;e[n]=r,t=(t-r)/256}return Uint8Array.from(e)}(e.signatureType),0),f.set(new Uint8Array(e.signatureLength).fill(0),2),r.byteLength!==e.ownerLength)throw new Error(`Owner must be ${e.ownerLength} bytes, but was incorrectly ${r.byteLength}`);f.set(r,2+e.signatureLength);let p=2+e.signatureLength+e.ownerLength;if(f[p]=o?1:0,o){if(32!==o.byteLength)throw new Error(`Target must be 32 bytes but was incorrectly ${o.byteLength}`);f.set(o,p+1)}let m=p+i,g=m+1;if(f[m]=s?1:0,s){if(g+=s.byteLength,32!==s.byteLength)throw new Error("Anchor must be 32 bytes");f.set(s,m+1)}f.set(Bn(n?.tags?.length??0),g);let y=Bn(c?.byteLength??0);f.set(y,g+8),c&&f.set(c,g+16);let w=g+l;return f.set(u,w),new Mn(f)}var Kn={...hn};globalThis.arbundles??=Kn;const{Axios:$n,AxiosError:Wn,CanceledError:zn,isCancel:Hn,CancelToken:qn,VERSION:Zn,all:Xn,Cancel:Gn,isAxiosError:Yn,spread:Jn,toFormData:Qn,AxiosHeaders:tr,HttpStatusCode:er,formToJSON:nr,getAdapter:rr,mergeConfig:or}=ze;var ir=a(386),sr={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:[]},ar={...sr,appName:"",appVersion:"",persistCookie:!1,persistLocalStorage:!1,auth0Cache:"memory"},cr={host:"arweave.net",protocol:"https",port:443},lr="othentUserDetails",ur="Othent KMS",hr="2.0.0-beta.10",dr=[{name:"Client",value:ur},{name:"Client-Version",value:hr}],fr=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,n=e?e(t):t;return JSON.stringify(n,((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:n}=this,r=this.getUpdateId(t),o=n===r;return this.lastEmittedUpdateId=r,this.lastEmittedParams=t,this.listeners.forEach((n=>{if(!o||!e.has(n)){e.add(n);try{n(...t)}catch(t){}}})),o}};function pr(t,e){return et(!0,{},e,t)}var mr={secure:!0,domain:!0,ttlHours:360},gr=class t{constructor(e=mr){this.secureParam=null,this.domainParam=null,this.ttlMs=1296e6;const{secureParam:n,domainParam:r,ttlMs:o}=this.parseCookieOptions(pr(e,mr));return this.secureParam=n,this.domainParam=r,this.ttlMs=o,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:n}={}){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:n?36e5*n:void 0===n?this.ttlMs:0}}getCookieParams(t){const{secureParam:e,domainParam:n,ttlMs:r}=this.parseCookieOptions(t),o=[`expires=${new Date(Date.now()+r).toUTCString()}`,e,n,"path=/"].filter(Boolean).join("; ");return o?` ${o};`:""}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 n=document.cookie.split(t.COOKIE_SEPARATOR).find((n=>n.split(t.COOKIE_VALUE_SEPARATOR)[0]===e));return n&&n.split(t.COOKIE_VALUE_SEPARATOR)[1]||null}setItem(t,e,n){const r=`${t}=${"string"==typeof e?e:JSON.stringify(e)};${this.getCookieParams(n)}`;return document.cookie=r,r}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])}))}};gr.COOKIE_SEPARATOR=/\s*;\s*/,gr.COOKIE_VALUE_SEPARATOR=/\s*=\s*/;var yr=gr,wr=null;var vr=class t{constructor({debug:t,domain:e,clientId:n,strategy:r,cache:o,refreshTokenExpirationMs:i,loginMethod:s,redirectURI:a,returnToURI:c,appInfo:l,initialUserDetails:u,cookieKey:h,localStorageKey:d}){this.debug=!1,this.auth0ClientPromise=Promise.resolve(null),this.authEventListenerHandler=new fr({diffParams:!0,replyOnListen:!0}),this.userDetails=null,this.userDetailsExpirationTimeoutID=0,this.cookieKey=null,this.localStorageKey=null,this.refreshTokenExpirationMs=+sr.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:n,useRefreshTokens:"refresh-tokens"===r,cacheLocation:"string"==typeof o?o:void 0,cache:"object"==typeof o?o:void 0,authorizationParams:{redirect_uri:this.redirectURI}}).then((t=>(this.isReady=!0,t))),this.cookieKey=h,this.localStorageKey=d,this.refreshTokenExpirationMs=i,this.appInfo=l,this.restoreUserDetails(u||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:n="",walletAddress:r}=e,o=e.sub||"",i=o.split("|")[0];let s=await async function(t){try{const e=(await ze.get("https://api.mem.tech/api/state/Tih8T1uESATJNzdwBIY3rpe25kWTzjw8uNiMRYe9I5M",{timeout:2e3})).data.balances.find((e=>e.address===t)),n=e&&(e.primary_domain||e.ownedDomains[0].domain)||null;return n?`${n}.ar`:null}catch(e){return console.warn(`Error resolving ANS domain for ${t} =\n`,e),null}}(r);if(!s){s=`${t.PROVIDER_LABELS[i]||"Unknown Provider"} (${n})`}return{sub:o,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:n,emailVerified:!!e.email_verified,owner:e.owner,walletAddress:e.walletAddress,walletAddressLabel:s,authSystem:e.authSystem,authProvider:i}}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:n}=this;if(e){const n=function(){if(!wr){const t=!1;wr=new yr({secure:!t&&void 0,domain:!t&&void 0})}return wr}();t?n.setItem(e,JSON.stringify(t)):null!==n.getItem(e)&&n.removeItem(e)}if(n)if(t){const e=new Date,r=JSON.stringify({userDetails:t,createdAt:e.toUTCString(),expiredBy:new Date(e.getTime()+this.refreshTokenExpirationMs).toUTCString()});localStorage.setItem(n,r)}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 n=new Date(t.expiredBy).getTime();!isNaN(n)&&n>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 n=e&&t.isIdTokenValidUser(e)?await t.getUserDetails(e):null;return this.setUserDetails(n)}getAuthorizationParams(t={}){const{authorizationParams:e,data:n}=t.hasOwnProperty("keyName")?{authorizationParams:null,data:t}:{authorizationParams:t,data:null},r={othentFunction:"KMS",othentSDKVersion:ur,othentAPIVersion:hr,appName:this.appInfo.name,appVersion:this.appInfo.version};return n&&(r.data=n),{...e,transaction_input:JSON.stringify(r,((t,e)=>{let n=[];if(e instanceof Buffer||e instanceof DataView||ArrayBuffer.isView(e))n=Array.from(new Uint8Array(e.buffer));else{if(!(e instanceof ArrayBuffer))return e;n=Array.from(new Uint8Array(e))}return"data"===t?Object.fromEntries(Object.entries(n)):{type:"Buffer",data:n}}))}}async getTokenSilently(t){const e=await this.auth0ClientPromise;if(!e)throw new Error("Missing Auth0 Client");const n=this.getAuthorizationParams(t);if(this.debug)try{console.log("getTokenSilently() =",{...n,transaction_input:JSON.parse(n.transaction_input)})}catch(t){console.error("Error logging/parsing `authorizationParams`:",t)}try{const t=await e.getTokenSilently({detailedResponse:!0,authorizationParams:n,cacheMode:"off"}),r=await e.getUser();if(!r)throw new Error("Could not get the user's details");const o=await this.updateUserDetails(r);return{...t,idToken:r,userDetails:o}}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 n=await e.getUser();if(!n)throw new Error("Could not get the user's details");return this.updateUserDetails(n)}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}};vr.PROVIDER_LABELS={apple:"Apple",auth0:"E-Mail","google-oauth2":"Google","<LinkedIn>":"LinkedIn","<X>":"X","<Meta>":"Meta","<Twitch>":"Twitch",github:"GitHub"};var br=vr;function Er(t){return"string"==typeof t?Sr(t):t}function Sr(t){return(new TextEncoder).encode(t)}function xr(t){return e=function(t){return He.fromByteArray(new Uint8Array(t))}(t),e.replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"");var e}async function Tr(t,e="SHA-256"){let n=await crypto.subtle.digest(e,t);return new Uint8Array(n)}var Ar=(t=>(t.Unexpected="Unexpected",t.Validation="Validation",t.UserCreation="UserCreation",t.Encryption="Encryption",t.Decryption="Decryption",t.Signing="Signing",t.PublicKey="PublicKey",t))(Ar||{}),_r=class extends Error{constructor(t,e,n,r=!1){super(),this.name=t,this.message=e||"",r?this.stack=`${t} (from server): ${e}\n`:Error.captureStackTrace(this),this.id=t,this.developerMessage=e,n instanceof Error?this.cause=n:"string"!=typeof n&&"number"!=typeof n||(this.cause=new Error(`${n}`))}};function kr(t){var e;if(Yn(t)){const n=null==(e=t.response)?void 0:e.data;if(!function(t){return"object"==typeof t&&!0===t.error&&!!t.id&&!!Ar[t.id]}(n))return t;const{id:r,developerMessage:o,cause:i}=n;let s;return i&&(s=new Error(i.message),s.name=i.name,s.stack=i.stack),new _r(r,o||"",s,!0)}return t instanceof Error?t:new Error("Unknown error")}async function Rr(t,e,n,r){var o;const i=await e.encodeToken({ciphertext:n,keyName:r});let s=null;try{s=null!=(o=(await t.post("/decrypt",{encodedData:i})).data.data)?o:null}catch(t){throw kr(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 Cr=class{constructor(t,e){this.api=ze.create({baseURL:t}),this.auth0=e}async createUser(t){return async function(t,e){let n=!1;try{n=(await t.post("/create-user",{encodedData:e})).data.data}catch(t){throw kr(t)}if(!n)throw new Error("Error creating user on server.");return!0}(this.api,t)}async decrypt(t,e){return Rr(this.api,this.auth0,t,e)}async encrypt(t,e){return async function(t,e,n,r){var o;const i=await e.encodeToken({plaintext:n,keyName:r});let s=null;try{s=null!=(o=(await t.post("/encrypt",{encodedData:i})).data.data)?o:null}catch(t){throw kr(t)}if(null===s)throw new Error("Error encrypting on server.");return"string"==typeof s?Sr(s):new Uint8Array(s.data)}(this.api,this.auth0,t,e)}async sign(t,e){return async function(t,e,n,r){const o=await e.encodeToken({data:n,keyName:r});let i=null;try{i=(await t.post("/sign",{encodedData:o})).data.data}catch(t){throw kr(t)}if(null===i)throw new Error("Error signing data on server.");return"string"==typeof i?Sr(i):new Uint8Array(i.data)}(this.api,this.auth0,t,e)}getSignerSignFn(t){return async e=>await this.sign(e,t)}};function Pr(t,e="utf8"){return r.lW.isBuffer(t)?Or(t.toString("base64")):Or(r.lW.from(t,e).toString("base64"))}function Ir(t){return function(t){let e=t.length,n=e%4;if(!n)return t;let o=e,i=4-n,s=e+i,a=r.lW.alloc(s);for(a.write(t);i--;)a.write("=",o++);return a.toString()}(t=t.toString()).replace(/\-/g,"+").replace(/_/g,"/")}function Or(t){return t.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function Nr(t){return r.lW.from(Ir(t),"base64")}var Br=Pr;function Ur(t){return ir.default.init(t)}Br.encode=Pr,Br.decode=function(t,e="utf8"){return r.lW.from(Ir(t),"base64").toString(e)},Br.toBase64=Ir,Br.fromBase64=Or,Br.toBuffer=Nr;var Lr=class t{constructor(t=ar){this.errorEventListenerHandler=new fr,this.tokens=new Set,this.walletName=ur,this.walletVersion=hr,this.config=sr,this.appInfo={name:"",version:""},this.gatewayConfig=cr;let{appName:e,appVersion:n,persistCookie:r,persistLocalStorage:o,auth0Cache:i=sr.auth0Cache,auth0RedirectURI:s,auth0ReturnToURI:a,gatewayConfig:c,initialUserDetails:l,...u}=t;const h="undefined"==typeof location?null:location.origin;this.config={...pr(u,sr),cookieKey:"string"==typeof r?r:r?lr:null,localStorageKey:"string"==typeof o?o:o?lr:null,auth0Cache:"object"==typeof i?"custom":i,auth0RedirectURI:s||h,auth0ReturnToURI:a||h};const{config:d}=this,{cookieKey:f,localStorageKey:p}=d;if("string"==typeof f&&!f.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(!d.auth0RedirectURI)throw new Error("`auth0RedirectURI` is required.");if(!d.auth0ReturnToURI)throw new Error("`auth0ReturnToURI` is required.");this.appInfo={name:e,version:n},this.gatewayConfig=c||cr;let m=null;if("undefined"!=typeof window)m=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.");m=global.crypto}if(this.crypto=m,"eager"===d.autoConnect&&"popup"===d.auth0LogInMethod&&"refresh-tokens"===d.auth0Strategy&&"memory"===i)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 br({debug:d.debug,domain:d.auth0Domain,clientId:d.auth0ClientId,strategy:d.auth0Strategy,cache:i,refreshTokenExpirationMs:d.auth0RefreshTokenExpirationMs,redirectURI:d.auth0RedirectURI,returnToURI:d.auth0ReturnToURI,loginMethod:d.auth0LogInMethod,appInfo:this.appInfo,initialUserDetails:l,cookieKey:d.cookieKey,localStorageKey:d.localStorageKey}),"eager"===this.config.autoConnect){let t="undefined"==typeof location;if(!t){const e=new URL(location.href),{searchParams:n}=e;n.has("code")||n.has("state")||(t=!0)}t&&this.connect()}if(d.inject&&(window.arweaveWallet=this),!d.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 r=e(...t);return!(n=r)||"object"!=typeof n&&"function"!=typeof n||"function"!=typeof n.then||(r=r.catch((t=>(this.onError(t),null)))),r}catch(t){this.onError(t)}var n;return null})}))}this.api=new Cr(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),n=new URL(e.replace(/.+\.auth0:\/\//,"https://")),{searchParams:r}=n;if(!r.has("code")||!r.has("state")||!e)return null;let o=null;try{o=await this.auth0.handleRedirectCallback(e)}finally{"undefined"!=typeof location&&"undefined"!=typeof history&&(r.delete("code"),r.delete("state"),history.replaceState(null,"",n))}return o}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 n=null;if("auth"===t)n=this.auth0.getAuthEventListenerHandler();else if("error"===t){if(this.config.throwErrors)throw new Error("You can only listen for `error` events if `throwErrors = false`.");n=this.errorEventListenerHandler}if(!n)throw new Error("Unknown event type");return n.add(e),()=>{n.delete(e)}}removeEventListener(t,e){let n=null;if("auth"===t?n=this.auth0.getAuthEventListenerHandler():"error"===t&&(n=this.errorEventListenerHandler),!n)throw new Error("Unknown event type");n.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,n,r){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.");n&&(this.appInfo=n,this.auth0.setAppInfo(n)),this.gatewayConfig=r||cr;let o="",i=null;try{const t=await this.auth0.getTokenSilently();o=t.id_token,i=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(!o)try{const t=await this.auth0.logIn();o=t.id_token,i=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 v||t instanceof w)return t instanceof w&&t.popup.close(),console.warn(t.message),null;throw t}if(o&&!i){await this.api.createUser(o);const t=await this.auth0.getTokenSilently();o=t.id_token,i=t.userDetails}if(o&&i)return i;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,...dr]}for(const{name:e,value:n}of this.config.tags)t.addTag(e,n);t.addTag("App-Name",this.appInfo.name),t.addTag("App-Version",this.appInfo.version);for(const{name:e,value:n}of dr)t.addTag(e,n)}async sign(t){const{sub:e,publicKey:n}=await this.requireUserDataOrThrow(),r=Ur(this.gatewayConfig),o=t.get("tags").map((t=>({name:t.get("name",{decode:!0,string:!0}),value:t.get("value",{decode:!0,string:!0})}))),i=this.addCommonTags(o),s=await r.createTransaction({data:t.data,owner:n,reward:t.reward});i.forEach((t=>{s.addTag(t.name,t.value)}));const a=await s.getSignatureData(),c=await this.api.sign(a,e),l=await Tr(c);return s.setSignature({id:xr(l),owner:n,signature:xr(c),tags:s.tags,reward:s.reward}),s}async dispatch(t,e){var n;const r=t.get("tags").map((t=>({name:t.get("name",{decode:!0,string:!0}),value:t.get("value",{decode:!0,string:!0})}))),o=await this.signDataItem({data:t.data,tags:r,target:t.target}),i=`${(null==e?void 0:e.node)||"https://turbo.ardrive.io"}/tx`;try{const t=await ze.post(i,o,{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(r){console.warn(`Error dispatching transaction to ${i} =\n`,r);const o=await this.sign(t),s=null!=(n=null==e?void 0:e.arweave)?n:Ur(this.gatewayConfig),a=await s.transactions.getUploader(o);for(;!a.isComplete;)await a.uploadChunk();return{id:o.id,signature:o.signature,owner:o.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:n}=await this.requireUserDataOrThrow(),{data:r,tags:o,...i}=t,s={publicKey:Nr(n),signatureType:1,signatureLength:512,ownerLength:512,sign:this.api.getSignerSignFn(e)},a=Fn(r,s,{...i,tags:this.addCommonTags(o)});return await a.sign(s),a.getRaw().buffer}async signMessage(t,e){const{sub:n}=await this.requireUserDataOrThrow(),r=(null==e?void 0:e.hashAlgorithm)||"SHA-256",o=await this.crypto.subtle.digest(r,Er(t));return await this.api.sign(o,n)}async verifyMessage(t,e,n,r={hashAlgorithm:"SHA-256"}){if(!n){const t=await this.requireUserDataOrThrow();n||(n=t.publicKey)}const o=(null==r?void 0:r.hashAlgorithm)||"SHA-256",i=await this.crypto.subtle.digest(o,Er(t)),s={e:"AQAB",ext:!0,kty:"RSA",n},a=await this.crypto.subtle.importKey("jwk",s,{name:"RSA-PSS",hash:r.hashAlgorithm},!1,["verify"]);return await this.crypto.subtle.verify({name:"RSA-PSS",saltLength:32},a,Er(e),i)}async privateHash(t,e){return Tr(Er(t),null==e?void 0:e.hashAlgorithm)}getArweaveConfig(){return Promise.resolve(this.gatewayConfig)}getPermissions(){return Promise.resolve(t.ALL_PERMISSIONS)}addToken(t,e,n){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))}};Lr.walletName=ur,Lr.walletVersion=hr,Lr.ALL_PERMISSIONS=["ACCESS_ADDRESS","ACCESS_ALL_ADDRESSES","ACCESS_ARWEAVE_CONFIG","ACCESS_PUBLIC_KEY","DECRYPT","DISPATCH","ENCRYPT","SIGN_TRANSACTION","SIGNATURE"];var jr=Lr;async function Dr(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=r.lW;const Mr=async()=>{if(!window.PublicKeyCredential)throw new Error("WebAuthn not supported");try{if(!await PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable())throw new Error("Biometric authentication not available");return!!await navigator.credentials.get({publicKey:{challenge:new Uint8Array(32),rpId:window.location.hostname,userVerification:"required"}})}catch(t){return console.error("Biometric authentication failed:",t),!1}};function Vr(t){let{onLoginSuccess:n}=t;const[r,o]=(0,e.useState)(!1);return React.createElement("div",{className:"flex flex-col items-center"},React.createElement("button",{onClick:async()=>{o(!0);try{const t=await(async()=>{const t=localStorage.getItem("onairosCredentials");if(!t)return null;try{const e=JSON.parse(t);return(await fetch("https://api2.onairos.uk/verify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:e.username,token:e.token})})).ok?e:(localStorage.removeItem("onairosCredentials"),null)}catch(t){return console.error("Verification failed:",t),null}})();if(t){if(await Mr())return void await n(t.username)}const e=Date.now(),r=encodeURIComponent(window.location.origin+"/auth/callback"),o="onairos://authenticate?nonce=".concat(e,"&callback=").concat(r,"&appName=google");window.location.href=o,setTimeout((()=>{window.location.href="https://apps.apple.com/app/onairos/id123456789"}),2500)}catch(t){console.error("App login failed:",t)}finally{o(!1)}},disabled:r,className:"w-12 h-12 rounded-full shadow-md hover:shadow-lg transition-shadow duration-200 flex items-center justify-center bg-white"},React.createElement("img",{src:"https://onairos.sirv.com/Images/OnairosBlack.png",alt:"Onairos",className:"w-10 h-6"})),React.createElement("span",{className:"text-xs mt-2 text-gray-600"},"Login with App"))}function Fr(){const[t,r]=(0,e.useState)(null),[o,i]=(0,e.useState)([]),s=t=>{i((e=>[...e,t]))};return n().createElement("div",{className:"flex flex-col items-center p-4"},n().createElement("button",{onClick:()=>{try{s("Opening external browser...");const t=new URLSearchParams({key:"value"}).toString(),e="https://internship.onairos.uk/auth?".concat(t);window.open(e,"_blank")}catch(t){console.error("Failed to open link:",t),s("Failed to open link: ".concat(t.message)),r("Failed to open link: ".concat(t.message))}},className:"flex flex-col items-center justify-center px-4 py-2 border border-gray-300 rounded-full shadow-sm bg-white hover:bg-gray-50"},n().createElement("div",{className:"relative"},n().createElement("img",{src:"google-icon.png",alt:"Google",className:"w-10 h-10 rounded-full"}),n().createElement("svg",{className:"absolute bottom-0 right-0 w-4 h-4",fill:"currentColor",viewBox:"0 0 20 20"},n().createElement("path",{d:"M10 3a1 1 0 011 1v6h6a1 1 0 110 2h-6v6a1 1 0 11-2 0v-6H3a1 1 0 110-2h6V4a1 1 0 011-1z"}))),n().createElement("span",{className:"text-gray-700 mt-2"},"Google")))}function Kr(t){let{onLoginSuccess:n,setOthent:r,setHashedOthentSub:o,setEncryptedPin:i}=t;const[s,a]=(0,e.useState)(!1);(0,e.useEffect)((()=>{c()}),[]);const c=async()=>{const t=localStorage.getItem("onairosCredentials");a(!!t)};return React.createElement("div",{className:"flex flex-row justify-center items-center space-x-4"},React.createElement(Fr,null),React.createElement(Vr,{hasSavedCredentials:s,onSuccess:n}))}var $r=a(697),Wr=a.n($r);function zr(t){let{active:e,title:r,id:o,number:i,descriptions:s,rewards:a,size:c,isChecked:l,onCheckboxChange:u}=t;return n().createElement("div",{className:"bg-white rounded-lg p-4 shadow border border-gray-200"},n().createElement("div",{className:"flex items-center justify-between"},n().createElement("div",{className:"flex items-center space-x-4"},n().createElement("div",{className:"group"},n().createElement("div",null,n().createElement("input",{disabled:!e,type:"checkbox",checked:l,onChange:t=>u(t.target.checked)})))),n().createElement("div",{className:"flex items-center"}),s&&"Avatar"!==r&&n().createElement("p",{className:"text-sm font-medium text-gray-900 dark:text-gray-300"},"Intent: ",s),a&&n().createElement("p",{className:"text-sm font-medium text-gray-900 dark:text-gray-300"},"Rewards: ",a)))}function Hr(t){if("undefined"==typeof Proxy)return t;const e=new Map;return new Proxy(((...e)=>t(...e)),{get:(n,r)=>"create"===r?t:(e.has(r)||e.set(r,t(r)),e.get(r))})}function qr(t){return null!==t&&"object"==typeof t&&"function"==typeof t.start}zr.propTypes={active:Wr().bool.isRequired,title:Wr().string.isRequired,id:Wr().any.isRequired,number:Wr().number.isRequired,descriptions:Wr().string,rewards:Wr().string,size:Wr().string.isRequired,isChecked:Wr().bool.isRequired,onCheckboxChange:Wr().func.isRequired};const Zr=t=>Array.isArray(t);function Xr(t,e){if(!Array.isArray(e))return!1;const n=e.length;if(n!==t.length)return!1;for(let r=0;r<n;r++)if(e[r]!==t[r])return!1;return!0}function Gr(t){return"string"==typeof t||Array.isArray(t)}function Yr(t){const e=[{},{}];return null==t||t.values.forEach(((t,n)=>{e[0][n]=t.get(),e[1][n]=t.getVelocity()})),e}function Jr(t,e,n,r){if("function"==typeof e){const[o,i]=Yr(r);e=e(void 0!==n?n:t.custom,o,i)}if("string"==typeof e&&(e=t.variants&&t.variants[e]),"function"==typeof e){const[o,i]=Yr(r);e=e(void 0!==n?n:t.custom,o,i)}return e}function Qr(t,e,n){const r=t.getProps();return Jr(r,e,void 0!==n?n:r.custom,t)}const to=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],eo=["initial",...to],no=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],ro=new Set(no),oo=t=>1e3*t,io=t=>t/1e3,so={type:"spring",stiffness:500,damping:25,restSpeed:10},ao={type:"keyframes",duration:.8},co={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},lo=(t,{keyframes:e})=>e.length>2?ao:ro.has(t)?t.startsWith("scale")?{type:"spring",stiffness:550,damping:0===e[1]?2*Math.sqrt(550):30,restSpeed:10}:so:co;function uo(t,e){return t?t[e]||t.default||t:void 0}const ho=!1,fo=!1,po=!1,mo=t=>null!==t;function go(t,{repeat:e,repeatType:n="loop"},r){const o=t.filter(mo),i=e&&"loop"!==n&&e%2==1?0:o.length-1;return i&&void 0!==r?r:o[i]}const yo=t=>t;const wo=["read","resolveKeyframes","update","preRender","render","postRender"];function vo(t,e){let n=!1,r=!0;const o={delta:0,timestamp:0,isProcessing:!1},i=()=>n=!0,s=wo.reduce(((t,e)=>(t[e]=function(t){let e=new Set,n=new Set,r=!1,o=!1;const i=new WeakSet;let s={delta:0,timestamp:0,isProcessing:!1};function a(e){i.has(e)&&(c.schedule(e),t()),e(s)}const c={schedule:(t,o=!1,s=!1)=>{const a=s&&r?e:n;return o&&i.add(t),a.has(t)||a.add(t),t},cancel:t=>{n.delete(t),i.delete(t)},process:t=>{s=t,r?o=!0:(r=!0,[e,n]=[n,e],e.forEach(a),e.clear(),r=!1,o&&(o=!1,c.process(t)))}};return c}(i),t)),{}),{read:a,resolveKeyframes:c,update:l,preRender:u,render:h,postRender:d}=s,f=()=>{const i=fo?o.timestamp:performance.now();n=!1,o.delta=r?1e3/60:Math.max(Math.min(i-o.timestamp,40),1),o.timestamp=i,o.isProcessing=!0,a.process(o),c.process(o),l.process(o),u.process(o),h.process(o),d.process(o),o.isProcessing=!1,n&&e&&(r=!1,t(f))};return{schedule:wo.reduce(((e,i)=>{const a=s[i];return e[i]=(e,i=!1,s=!1)=>(n||(n=!0,r=!0,o.isProcessing||t(f)),a.schedule(e,i,s)),e}),{}),cancel:t=>{for(let e=0;e<wo.length;e++)s[wo[e]].cancel(t)},state:o,steps:s}}const{schedule:bo,cancel:Eo,state:So,steps:xo}=vo("undefined"!=typeof requestAnimationFrame?requestAnimationFrame:yo,!0),To=(t,e,n)=>(((1-3*n+3*e)*t+(3*n-6*e))*t+3*e)*t,Ao=1e-7,_o=12;function ko(t,e,n,r){if(t===e&&n===r)return yo;const o=e=>function(t,e,n,r,o){let i,s,a=0;do{s=e+(n-e)/2,i=To(s,r,o)-t,i>0?n=s:e=s}while(Math.abs(i)>Ao&&++a<_o);return s}(e,0,1,t,n);return t=>0===t||1===t?t:To(o(t),e,r)}const Ro=t=>e=>e<=.5?t(2*e)/2:(2-t(2*(1-e)))/2,Co=t=>e=>1-t(1-e),Po=ko(.33,1.53,.69,.99),Io=Co(Po),Oo=Ro(Io),No=t=>(t*=2)<1?.5*Io(t):.5*(2-Math.pow(2,-10*(t-1))),Bo=t=>1-Math.sin(Math.acos(t)),Uo=Co(Bo),Lo=Ro(Bo),jo=t=>/^0[^.\s]+$/u.test(t);let Do=yo,Mo=yo;const Vo=t=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(t),Fo=t=>e=>"string"==typeof e&&e.startsWith(t),Ko=Fo("--"),$o=Fo("var(--"),Wo=t=>!!$o(t)&&zo.test(t.split("/*")[0].trim()),zo=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu,Ho=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function qo(t,e,n=1){Mo(n<=4,`Max CSS variable fallback depth detected in property "${t}". This may indicate a circular fallback dependency.`);const[r,o]=function(t){const e=Ho.exec(t);if(!e)return[,];const[,n,r,o]=e;return[`--${null!=n?n:r}`,o]}(t);if(!r)return;const i=window.getComputedStyle(e).getPropertyValue(r);if(i){const t=i.trim();return Vo(t)?parseFloat(t):t}return Wo(o)?qo(o,e,n+1):o}const Zo=(t,e,n)=>n>e?e:n<t?t:n,Xo={test:t=>"number"==typeof t,parse:parseFloat,transform:t=>t},Go={...Xo,transform:t=>Zo(0,1,t)},Yo={...Xo,default:1},Jo=t=>({test:e=>"string"==typeof e&&e.endsWith(t)&&1===e.split(" ").length,parse:parseFloat,transform:e=>`${e}${t}`}),Qo=Jo("deg"),ti=Jo("%"),ei=Jo("px"),ni=Jo("vh"),ri=Jo("vw"),oi={...ti,parse:t=>ti.parse(t)/100,transform:t=>ti.transform(100*t)},ii=new Set(["width","height","top","left","right","bottom","x","y","translateX","translateY"]),si=t=>t===Xo||t===ei,ai=(t,e)=>parseFloat(t.split(", ")[e]),ci=(t,e)=>(n,{transform:r})=>{if("none"===r||!r)return 0;const o=r.match(/^matrix3d\((.+)\)$/u);if(o)return ai(o[1],e);{const e=r.match(/^matrix\((.+)\)$/u);return e?ai(e[1],t):0}},li=new Set(["x","y","z"]),ui=no.filter((t=>!li.has(t)));const hi={width:({x:t},{paddingLeft:e="0",paddingRight:n="0"})=>t.max-t.min-parseFloat(e)-parseFloat(n),height:({y:t},{paddingTop:e="0",paddingBottom:n="0"})=>t.max-t.min-parseFloat(e)-parseFloat(n),top:(t,{top:e})=>parseFloat(e),left:(t,{left:e})=>parseFloat(e),bottom:({y:t},{top:e})=>parseFloat(e)+(t.max-t.min),right:({x:t},{left:e})=>parseFloat(e)+(t.max-t.min),x:ci(4,13),y:ci(5,14)};hi.translateX=hi.x,hi.translateY=hi.y;const di=t=>e=>e.test(t),fi=[Xo,ei,ti,Qo,ri,ni,{test:t=>"auto"===t,parse:t=>t}],pi=t=>fi.find(di(t)),mi=new Set;let gi=!1,yi=!1;function wi(){if(yi){const t=Array.from(mi).filter((t=>t.needsMeasurement)),e=new Set(t.map((t=>t.element))),n=new Map;e.forEach((t=>{const e=function(t){const e=[];return ui.forEach((n=>{const r=t.getValue(n);void 0!==r&&(e.push([n,r.get()]),r.set(n.startsWith("scale")?1:0))})),e}(t);e.length&&(n.set(t,e),t.render())})),t.forEach((t=>t.measureInitialState())),e.forEach((t=>{t.render();const e=n.get(t);e&&e.forEach((([e,n])=>{var r;null===(r=t.getValue(e))||void 0===r||r.set(n)}))})),t.forEach((t=>t.measureEndState())),t.forEach((t=>{void 0!==t.suspendedScrollY&&window.scrollTo(0,t.suspendedScrollY)}))}yi=!1,gi=!1,mi.forEach((t=>t.complete())),mi.clear()}function vi(){mi.forEach((t=>{t.readKeyframes(),t.needsMeasurement&&(yi=!0)}))}class bi{constructor(t,e,n,r,o,i=!1){this.isComplete=!1,this.isAsync=!1,this.needsMeasurement=!1,this.isScheduled=!1,this.unresolvedKeyframes=[...t],this.onComplete=e,this.name=n,this.motionValue=r,this.element=o,this.isAsync=i}scheduleResolve(){this.isScheduled=!0,this.isAsync?(mi.add(this),gi||(gi=!0,bo.read(vi),bo.resolveKeyframes(wi))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:t,name:e,element:n,motionValue:r}=this;for(let o=0;o<t.length;o++)if(null===t[o])if(0===o){const o=null==r?void 0:r.get(),i=t[t.length-1];if(void 0!==o)t[0]=o;else if(n&&e){const r=n.readValue(e,i);null!=r&&(t[0]=r)}void 0===t[0]&&(t[0]=i),r&&void 0===o&&r.set(t[0])}else t[o]=t[o-1]}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(){this.isComplete=!0,this.onComplete(this.unresolvedKeyframes,this.finalKeyframe),mi.delete(this)}cancel(){this.isComplete||(this.isScheduled=!1,mi.delete(this))}resume(){this.isComplete||this.scheduleResolve()}}const Ei=t=>Math.round(1e5*t)/1e5,Si=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;const xi=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,Ti=(t,e)=>n=>Boolean("string"==typeof n&&xi.test(n)&&n.startsWith(t)||e&&!function(t){return null==t}(n)&&Object.prototype.hasOwnProperty.call(n,e)),Ai=(t,e,n)=>r=>{if("string"!=typeof r)return r;const[o,i,s,a]=r.match(Si);return{[t]:parseFloat(o),[e]:parseFloat(i),[n]:parseFloat(s),alpha:void 0!==a?parseFloat(a):1}},_i={...Xo,transform:t=>Math.round((t=>Zo(0,255,t))(t))},ki={test:Ti("rgb","red"),parse:Ai("red","green","blue"),transform:({red:t,green:e,blue:n,alpha:r=1})=>"rgba("+_i.transform(t)+", "+_i.transform(e)+", "+_i.transform(n)+", "+Ei(Go.transform(r))+")"};const Ri={test:Ti("#"),parse:function(t){let e="",n="",r="",o="";return t.length>5?(e=t.substring(1,3),n=t.substring(3,5),r=t.substring(5,7),o=t.substring(7,9)):(e=t.substring(1,2),n=t.substring(2,3),r=t.substring(3,4),o=t.substring(4,5),e+=e,n+=n,r+=r,o+=o),{red:parseInt(e,16),green:parseInt(n,16),blue:parseInt(r,16),alpha:o?parseInt(o,16)/255:1}},transform:ki.transform},Ci={test:Ti("hsl","hue"),parse:Ai("hue","saturation","lightness"),transform:({hue:t,saturation:e,lightness:n,alpha:r=1})=>"hsla("+Math.round(t)+", "+ti.transform(Ei(e))+", "+ti.transform(Ei(n))+", "+Ei(Go.transform(r))+")"},Pi={test:t=>ki.test(t)||Ri.test(t)||Ci.test(t),parse:t=>ki.test(t)?ki.parse(t):Ci.test(t)?Ci.parse(t):Ri.parse(t),transform:t=>"string"==typeof t?t:t.hasOwnProperty("red")?ki.transform(t):Ci.transform(t)},Ii=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;const Oi="number",Ni="color",Bi="var",Ui="var(",Li="${}",ji=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function Di(t){const e=t.toString(),n=[],r={color:[],number:[],var:[]},o=[];let i=0;const s=e.replace(ji,(t=>(Pi.test(t)?(r.color.push(i),o.push(Ni),n.push(Pi.parse(t))):t.startsWith(Ui)?(r.var.push(i),o.push(Bi),n.push(t)):(r.number.push(i),o.push(Oi),n.push(parseFloat(t))),++i,Li))).split(Li);return{values:n,split:s,indexes:r,types:o}}function Mi(t){return Di(t).values}function Vi(t){const{split:e,types:n}=Di(t),r=e.length;return t=>{let o="";for(let i=0;i<r;i++)if(o+=e[i],void 0!==t[i]){const e=n[i];o+=e===Oi?Ei(t[i]):e===Ni?Pi.transform(t[i]):t[i]}return o}}const Fi=t=>"number"==typeof t?0:t;const Ki={test:function(t){var e,n;return isNaN(t)&&"string"==typeof t&&((null===(e=t.match(Si))||void 0===e?void 0:e.length)||0)+((null===(n=t.match(Ii))||void 0===n?void 0:n.length)||0)>0},parse:Mi,createTransformer:Vi,getAnimatableNone:function(t){const e=Mi(t);return Vi(t)(e.map(Fi))}},$i=new Set(["brightness","contrast","saturate","opacity"]);function Wi(t){const[e,n]=t.slice(0,-1).split("(");if("drop-shadow"===e)return t;const[r]=n.match(Si)||[];if(!r)return t;const o=n.replace(r,"");let i=$i.has(e)?1:0;return r!==n&&(i*=100),e+"("+i+o+")"}const zi=/\b([a-z-]*)\(.*?\)/gu,Hi={...Ki,getAnimatableNone:t=>{const e=t.match(zi);return e?e.map(Wi).join(" "):t}},qi={borderWidth:ei,borderTopWidth:ei,borderRightWidth:ei,borderBottomWidth:ei,borderLeftWidth:ei,borderRadius:ei,radius:ei,borderTopLeftRadius:ei,borderTopRightRadius:ei,borderBottomRightRadius:ei,borderBottomLeftRadius:ei,width:ei,maxWidth:ei,height:ei,maxHeight:ei,top:ei,right:ei,bottom:ei,left:ei,padding:ei,paddingTop:ei,paddingRight:ei,paddingBottom:ei,paddingLeft:ei,margin:ei,marginTop:ei,marginRight:ei,marginBottom:ei,marginLeft:ei,backgroundPositionX:ei,backgroundPositionY:ei},Zi={rotate:Qo,rotateX:Qo,rotateY:Qo,rotateZ:Qo,scale:Yo,scaleX:Yo,scaleY:Yo,scaleZ:Yo,skew:Qo,skewX:Qo,skewY:Qo,distance:ei,translateX:ei,translateY:ei,translateZ:ei,x:ei,y:ei,z:ei,perspective:ei,transformPerspective:ei,opacity:Go,originX:oi,originY:oi,originZ:ei},Xi={...Xo,transform:Math.round},Gi={...qi,...Zi,zIndex:Xi,size:ei,fillOpacity:Go,strokeOpacity:Go,numOctaves:Xi},Yi={...Gi,color:Pi,backgroundColor:Pi,outlineColor:Pi,fill:Pi,stroke:Pi,borderColor:Pi,borderTopColor:Pi,borderRightColor:Pi,borderBottomColor:Pi,borderLeftColor:Pi,filter:Hi,WebkitFilter:Hi},Ji=t=>Yi[t];function Qi(t,e){let n=Ji(t);return n!==Hi&&(n=Ki),n.getAnimatableNone?n.getAnimatableNone(e):void 0}const ts=new Set(["auto","none","0"]);class es extends bi{constructor(t,e,n,r,o){super(t,e,n,r,o,!0)}readKeyframes(){const{unresolvedKeyframes:t,element:e,name:n}=this;if(!e||!e.current)return;super.readKeyframes();for(let n=0;n<t.length;n++){let r=t[n];if("string"==typeof r&&(r=r.trim(),Wo(r))){const o=qo(r,e.current);void 0!==o&&(t[n]=o),n===t.length-1&&(this.finalKeyframe=r)}}if(this.resolveNoneKeyframes(),!ii.has(n)||2!==t.length)return;const[r,o]=t,i=pi(r),s=pi(o);if(i!==s)if(si(i)&&si(s))for(let e=0;e<t.length;e++){const n=t[e];"string"==typeof n&&(t[e]=parseFloat(n))}else this.needsMeasurement=!0}resolveNoneKeyframes(){const{unresolvedKeyframes:t,name:e}=this,n=[];for(let e=0;e<t.length;e++)("number"==typeof(r=t[e])?0===r:null===r||"none"===r||"0"===r||jo(r))&&n.push(e);var r;n.length&&function(t,e,n){let r,o=0;for(;o<t.length&&!r;){const e=t[o];"string"==typeof e&&!ts.has(e)&&Di(e).values.length&&(r=t[o]),o++}if(r&&n)for(const o of e)t[o]=Qi(n,r)}(t,n,e)}measureInitialState(){const{element:t,unresolvedKeyframes:e,name:n}=this;if(!t||!t.current)return;"height"===n&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=hi[n](t.measureViewportBox(),window.getComputedStyle(t.current)),e[0]=this.measuredOrigin;const r=e[e.length-1];void 0!==r&&t.getValue(n,r).jump(r,!1)}measureEndState(){var t;const{element:e,name:n,unresolvedKeyframes:r}=this;if(!e||!e.current)return;const o=e.getValue(n);o&&o.jump(this.measuredOrigin,!1);const i=r.length-1,s=r[i];r[i]=hi[n](e.measureViewportBox(),window.getComputedStyle(e.current)),null!==s&&void 0===this.finalKeyframe&&(this.finalKeyframe=s),(null===(t=this.removedTransforms)||void 0===t?void 0:t.length)&&this.removedTransforms.forEach((([t,n])=>{e.getValue(t).set(n)})),this.resolveNoneKeyframes()}}function ns(t){return"function"==typeof t}let rs;function os(){rs=void 0}const is={now:()=>(void 0===rs&&is.set(So.isProcessing||fo?So.timestamp:performance.now()),rs),set:t=>{rs=t,queueMicrotask(os)}},ss=(t,e)=>"zIndex"!==e&&(!("number"!=typeof t&&!Array.isArray(t))||!("string"!=typeof t||!Ki.test(t)&&"0"!==t||t.startsWith("url(")));function as(t,e,n,r){const o=t[0];if(null===o)return!1;if("display"===e||"visibility"===e)return!0;const i=t[t.length-1],s=ss(o,e),a=ss(i,e);return Do(s===a,`You are trying to animate ${e} from "${o}" to "${i}". ${o} is not an animatable value - to enable this animation set ${o} to a value animatable to ${i} via the \`style\` property.`),!(!s||!a)&&(function(t){const e=t[0];if(1===t.length)return!0;for(let n=0;n<t.length;n++)if(t[n]!==e)return!0}(t)||("spring"===n||ns(n))&&r)}class cs{constructor({autoplay:t=!0,delay:e=0,type:n="keyframes",repeat:r=0,repeatDelay:o=0,repeatType:i="loop",...s}){this.isStopped=!1,this.hasAttemptedResolve=!1,this.createdAt=is.now(),this.options={autoplay:t,delay:e,type:n,repeat:r,repeatDelay:o,repeatType:i,...s},this.updateFinishedPromise()}calcStartTime(){return this.resolvedAt&&this.resolvedAt-this.createdAt>40?this.resolvedAt:this.createdAt}get resolved(){return this._resolved||this.hasAttemptedResolve||(vi(),wi()),this._resolved}onKeyframesResolved(t,e){this.resolvedAt=is.now(),this.hasAttemptedResolve=!0;const{name:n,type:r,velocity:o,delay:i,onComplete:s,onUpdate:a,isGenerator:c}=this.options;if(!c&&!as(t,n,r,o)){if(po||!i)return null==a||a(go(t,this.options,e)),null==s||s(),void this.resolveFinishedPromise();this.options.duration=0}const l=this.initPlayback(t,e);!1!==l&&(this._resolved={keyframes:t,finalKeyframe:e,...l},this.onPostResolved())}onPostResolved(){}then(t,e){return this.currentFinishedPromise.then(t,e)}flatten(){this.options.type="keyframes",this.options.ease="linear"}updateFinishedPromise(){this.currentFinishedPromise=new Promise((t=>{this.resolveFinishedPromise=t}))}}const ls=(t,e,n)=>{const r=e-t;return 0===r?1:(n-t)/r},us=(t,e,n=10)=>{let r="";const o=Math.max(Math.round(e/n),2);for(let e=0;e<o;e++)r+=t(ls(0,o-1,e))+", ";return`linear(${r.substring(0,r.length-2)})`};function hs(t,e){return e?t*(1e3/e):0}const ds=5;function fs(t,e,n){const r=Math.max(e-ds,0);return hs(n-t(r),e-r)}const ps={stiffness:100,damping:10,mass:1,velocity:0,duration:800,bounce:.3,visualDuration:.3,restSpeed:{granular:.01,default:2},restDelta:{granular:.005,default:.5},minDuration:.01,maxDuration:10,minDamping:.05,maxDamping:1},ms=.001;function gs({duration:t=ps.duration,bounce:e=ps.bounce,velocity:n=ps.velocity,mass:r=ps.mass}){let o,i;Do(t<=oo(ps.maxDuration),"Spring duration must be 10 seconds or less");let s=1-e;s=Zo(ps.minDamping,ps.maxDamping,s),t=Zo(ps.minDuration,ps.maxDuration,io(t)),s<1?(o=e=>{const r=e*s,o=r*t,i=r-n,a=ws(e,s),c=Math.exp(-o);return ms-i/a*c},i=e=>{const r=e*s*t,i=r*n+n,a=Math.pow(s,2)*Math.pow(e,2)*t,c=Math.exp(-r),l=ws(Math.pow(e,2),s);return(-o(e)+ms>0?-1:1)*((i-a)*c)/l}):(o=e=>Math.exp(-e*t)*((e-n)*t+1)-ms,i=e=>Math.exp(-e*t)*(t*t*(n-e)));const a=function(t,e,n){let r=n;for(let n=1;n<ys;n++)r-=t(r)/e(r);return r}(o,i,5/t);if(t=oo(t),isNaN(a))return{stiffness:ps.stiffness,damping:ps.damping,duration:t};{const e=Math.pow(a,2)*r;return{stiffness:e,damping:2*s*Math.sqrt(r*e),duration:t}}}const ys=12;function ws(t,e){return t*Math.sqrt(1-e*e)}const vs=2e4;function bs(t){let e=0;let n=t.next(e);for(;!n.done&&e<vs;)e+=50,n=t.next(e);return e>=vs?1/0:e}const Es=["duration","bounce"],Ss=["stiffness","damping","mass"];function xs(t,e){return e.some((e=>void 0!==t[e]))}function Ts(t=ps.visualDuration,e=ps.bounce){const n="object"!=typeof t?{visualDuration:t,keyframes:[0,1],bounce:e}:t;let{restSpeed:r,restDelta:o}=n;const i=n.keyframes[0],s=n.keyframes[n.keyframes.length-1],a={done:!1,value:i},{stiffness:c,damping:l,mass:u,duration:h,velocity:d,isResolvedFromDuration:f}=function(t){let e={velocity:ps.velocity,stiffness:ps.stiffness,damping:ps.damping,mass:ps.mass,isResolvedFromDuration:!1,...t};if(!xs(t,Ss)&&xs(t,Es))if(t.visualDuration){const n=t.visualDuration,r=2*Math.PI/(1.2*n),o=r*r,i=2*Zo(.05,1,1-t.bounce)*Math.sqrt(o);e={...e,mass:ps.mass,stiffness:o,damping:i}}else{const n=gs(t);e={...e,...n,mass:ps.mass},e.isResolvedFromDuration=!0}return e}({...n,velocity:-io(n.velocity||0)}),p=d||0,m=l/(2*Math.sqrt(c*u)),g=s-i,y=io(Math.sqrt(c/u)),w=Math.abs(g)<5;let v;if(r||(r=w?ps.restSpeed.granular:ps.restSpeed.default),o||(o=w?ps.restDelta.granular:ps.restDelta.default),m<1){const t=ws(y,m);v=e=>{const n=Math.exp(-m*y*e);return s-n*((p+m*y*g)/t*Math.sin(t*e)+g*Math.cos(t*e))}}else if(1===m)v=t=>s-Math.exp(-y*t)*(g+(p+y*g)*t);else{const t=y*Math.sqrt(m*m-1);v=e=>{const n=Math.exp(-m*y*e),r=Math.min(t*e,300);return s-n*((p+m*y*g)*Math.sinh(r)+t*g*Math.cosh(r))/t}}const b={calculatedDuration:f&&h||null,next:t=>{const e=v(t);if(f)a.done=t>=h;else{let n=0;m<1&&(n=0===t?oo(p):fs(v,t,e));const i=Math.abs(n)<=r,c=Math.abs(s-e)<=o;a.done=i&&c}return a.value=a.done?s:e,a},toString:()=>{const t=Math.min(bs(b),vs),e=us((e=>b.next(t*e).value),t,30);return t+"ms "+e}};return b}function As({keyframes:t,velocity:e=0,power:n=.8,timeConstant:r=325,bounceDamping:o=10,bounceStiffness:i=500,modifyTarget:s,min:a,max:c,restDelta:l=.5,restSpeed:u}){const h=t[0],d={done:!1,value:h},f=t=>void 0===a?c:void 0===c||Math.abs(a-t)<Math.abs(c-t)?a:c;let p=n*e;const m=h+p,g=void 0===s?m:s(m);g!==m&&(p=g-h);const y=t=>-p*Math.exp(-t/r),w=t=>g+y(t),v=t=>{const e=y(t),n=w(t);d.done=Math.abs(e)<=l,d.value=d.done?g:n};let b,E;const S=t=>{(t=>void 0!==a&&t<a||void 0!==c&&t>c)(d.value)&&(b=t,E=Ts({keyframes:[d.value,f(d.value)],velocity:fs(w,t,d.value),damping:o,stiffness:i,restDelta:l,restSpeed:u}))};return S(0),{calculatedDuration:null,next:t=>{let e=!1;return E||void 0!==b||(e=!0,v(t),S(t)),void 0!==b&&t>=b?E.next(t-b):(!e&&v(t),d)}}}const _s=ko(.42,0,1,1),ks=ko(0,0,.58,1),Rs=ko(.42,0,.58,1),Cs=t=>Array.isArray(t)&&"number"==typeof t[0],Ps={linear:yo,easeIn:_s,easeInOut:Rs,easeOut:ks,circIn:Bo,circInOut:Lo,circOut:Uo,backIn:Io,backInOut:Oo,backOut:Po,anticipate:No},Is=t=>{if(Cs(t)){Mo(4===t.length,"Cubic bezier arrays must contain four numerical values.");const[e,n,r,o]=t;return ko(e,n,r,o)}return"string"==typeof t?(Mo(void 0!==Ps[t],`Invalid easing type '${t}'`),Ps[t]):t},Os=(t,e)=>n=>e(t(n)),Ns=(...t)=>t.reduce(Os),Bs=(t,e,n)=>t+(e-t)*n;function Us(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+6*(e-t)*n:n<.5?e:n<2/3?t+(e-t)*(2/3-n)*6:t}function Ls(t,e){return n=>n>0?e:t}const js=(t,e,n)=>{const r=t*t,o=n*(e*e-r)+r;return o<0?0:Math.sqrt(o)},Ds=[Ri,ki,Ci];function Ms(t){const e=(t=>Ds.find((e=>e.test(t))))(t);if(Do(Boolean(e),`'${t}' is not an animatable color. Use the equivalent color code instead.`),!Boolean(e))return!1;let n=e.parse(t);return e===Ci&&(n=function({hue:t,saturation:e,lightness:n,alpha:r}){t/=360,n/=100;let o=0,i=0,s=0;if(e/=100){const r=n<.5?n*(1+e):n+e-n*e,a=2*n-r;o=Us(a,r,t+1/3),i=Us(a,r,t),s=Us(a,r,t-1/3)}else o=i=s=n;return{red:Math.round(255*o),green:Math.round(255*i),blue:Math.round(255*s),alpha:r}}(n)),n}const Vs=(t,e)=>{const n=Ms(t),r=Ms(e);if(!n||!r)return Ls(t,e);const o={...n};return t=>(o.red=js(n.red,r.red,t),o.green=js(n.green,r.green,t),o.blue=js(n.blue,r.blue,t),o.alpha=Bs(n.alpha,r.alpha,t),ki.transform(o))},Fs=new Set(["none","hidden"]);function Ks(t,e){return n=>Bs(t,e,n)}function $s(t){return"number"==typeof t?Ks:"string"==typeof t?Wo(t)?Ls:Pi.test(t)?Vs:Hs:Array.isArray(t)?Ws:"object"==typeof t?Pi.test(t)?Vs:zs:Ls}function Ws(t,e){const n=[...t],r=n.length,o=t.map(((t,n)=>$s(t)(t,e[n])));return t=>{for(let e=0;e<r;e++)n[e]=o[e](t);return n}}function zs(t,e){const n={...t,...e},r={};for(const o in n)void 0!==t[o]&&void 0!==e[o]&&(r[o]=$s(t[o])(t[o],e[o]));return t=>{for(const e in r)n[e]=r[e](t);return n}}const Hs=(t,e)=>{const n=Ki.createTransformer(e),r=Di(t),o=Di(e);return r.indexes.var.length===o.indexes.var.length&&r.indexes.color.length===o.indexes.color.length&&r.indexes.number.length>=o.indexes.number.length?Fs.has(t)&&!o.values.length||Fs.has(e)&&!r.values.length?function(t,e){return Fs.has(t)?n=>n<=0?t:e:n=>n>=1?e:t}(t,e):Ns(Ws(function(t,e){var n;const r=[],o={color:0,var:0,number:0};for(let i=0;i<e.values.length;i++){const s=e.types[i],a=t.indexes[s][o[s]],c=null!==(n=t.values[a])&&void 0!==n?n:0;r[i]=c,o[s]++}return r}(r,o),o.values),n):(Do(!0,`Complex values '${t}' and '${e}' too different to mix. Ensure all colors are of the same type, and that each contains the same quantity of number and color values. Falling back to instant transition.`),Ls(t,e))};function qs(t,e,n){if("number"==typeof t&&"number"==typeof e&&"number"==typeof n)return Bs(t,e,n);return $s(t)(t,e)}function Zs(t,e,{clamp:n=!0,ease:r,mixer:o}={}){const i=t.length;if(Mo(i===e.length,"Both input and output ranges must be the same length"),1===i)return()=>e[0];if(2===i&&t[0]===t[1])return()=>e[1];t[0]>t[i-1]&&(t=[...t].reverse(),e=[...e].reverse());const s=function(t,e,n){const r=[],o=n||qs,i=t.length-1;for(let n=0;n<i;n++){let i=o(t[n],t[n+1]);if(e){const t=Array.isArray(e)?e[n]||yo:e;i=Ns(t,i)}r.push(i)}return r}(e,r,o),a=s.length,c=e=>{let n=0;if(a>1)for(;n<t.length-2&&!(e<t[n+1]);n++);const r=ls(t[n],t[n+1],e);return s[n](r)};return n?e=>c(Zo(t[0],t[i-1],e)):c}function Xs(t){const e=[0];return function(t,e){const n=t[t.length-1];for(let r=1;r<=e;r++){const o=ls(0,e,r);t.push(Bs(n,1,o))}}(e,t.length-1),e}function Gs({duration:t=300,keyframes:e,times:n,ease:r="easeInOut"}){const o=(t=>Array.isArray(t)&&"number"!=typeof t[0])(r)?r.map(Is):Is(r),i={done:!1,value:e[0]},s=function(t,e){return t.map((t=>t*e))}(n&&n.length===e.length?n:Xs(e),t),a=Zs(s,e,{ease:Array.isArray(o)?o:(c=e,l=o,c.map((()=>l||Rs)).splice(0,c.length-1))});var c,l;return{calculatedDuration:t,next:e=>(i.value=a(e),i.done=e>=t,i)}}const Ys=t=>{const e=({timestamp:e})=>t(e);return{start:()=>bo.update(e,!0),stop:()=>Eo(e),now:()=>So.isProcessing?So.timestamp:is.now()}},Js={decay:As,inertia:As,tween:Gs,keyframes:Gs,spring:Ts},Qs=t=>t/100;class ta extends cs{constructor(t){super(t),this.holdTime=null,this.cancelTime=null,this.currentTime=0,this.playbackSpeed=1,this.pendingPlayState="running",this.startTime=null,this.state="idle",this.stop=()=>{if(this.resolver.cancel(),this.isStopped=!0,"idle"===this.state)return;this.teardown();const{onStop:t}=this.options;t&&t()};const{name:e,motionValue:n,element:r,keyframes:o}=this.options,i=(null==r?void 0:r.KeyframeResolver)||bi;this.resolver=new i(o,((t,e)=>this.onKeyframesResolved(t,e)),e,n,r),this.resolver.scheduleResolve()}flatten(){super.flatten(),this._resolved&&Object.assign(this._resolved,this.initPlayback(this._resolved.keyframes))}initPlayback(t){const{type:e="keyframes",repeat:n=0,repeatDelay:r=0,repeatType:o,velocity:i=0}=this.options,s=ns(e)?e:Js[e]||Gs;let a,c;s!==Gs&&"number"!=typeof t[0]&&(a=Ns(Qs,qs(t[0],t[1])),t=[0,100]);const l=s({...this.options,keyframes:t});"mirror"===o&&(c=s({...this.options,keyframes:[...t].reverse(),velocity:-i})),null===l.calculatedDuration&&(l.calculatedDuration=bs(l));const{calculatedDuration:u}=l,h=u+r;return{generator:l,mirroredGenerator:c,mapPercentToKeyframes:a,calculatedDuration:u,resolvedDuration:h,totalDuration:h*(n+1)-r}}onPostResolved(){const{autoplay:t=!0}=this.options;this.play(),"paused"!==this.pendingPlayState&&t?this.state=this.pendingPlayState:this.pause()}tick(t,e=!1){const{resolved:n}=this;if(!n){const{keyframes:t}=this.options;return{done:!0,value:t[t.length-1]}}const{finalKeyframe:r,generator:o,mirroredGenerator:i,mapPercentToKeyframes:s,keyframes:a,calculatedDuration:c,totalDuration:l,resolvedDuration:u}=n;if(null===this.startTime)return o.next(0);const{delay:h,repeat:d,repeatType:f,repeatDelay:p,onUpdate:m}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,t):this.speed<0&&(this.startTime=Math.min(t-l/this.speed,this.startTime)),e?this.currentTime=t:null!==this.holdTime?this.currentTime=this.holdTime:this.currentTime=Math.round(t-this.startTime)*this.speed;const g=this.currentTime-h*(this.speed>=0?1:-1),y=this.speed>=0?g<0:g>l;this.currentTime=Math.max(g,0),"finished"===this.state&&null===this.holdTime&&(this.currentTime=l);let w=this.currentTime,v=o;if(d){const t=Math.min(this.currentTime,l)/u;let e=Math.floor(t),n=t%1;!n&&t>=1&&(n=1),1===n&&e--,e=Math.min(e,d+1);Boolean(e%2)&&("reverse"===f?(n=1-n,p&&(n-=p/u)):"mirror"===f&&(v=i)),w=Zo(0,1,n)*u}const b=y?{done:!1,value:a[0]}:v.next(w);s&&(b.value=s(b.value));let{done:E}=b;y||null===c||(E=this.speed>=0?this.currentTime>=l:this.currentTime<=0);const S=null===this.holdTime&&("finished"===this.state||"running"===this.state&&E);return S&&void 0!==r&&(b.value=go(a,this.options,r)),m&&m(b.value),S&&this.finish(),b}get duration(){const{resolved:t}=this;return t?io(t.calculatedDuration):0}get time(){return io(this.currentTime)}set time(t){t=oo(t),this.currentTime=t,null!==this.holdTime||0===this.speed?this.holdTime=t:this.driver&&(this.startTime=this.driver.now()-t/this.speed)}get speed(){return this.playbackSpeed}set speed(t){const e=this.playbackSpeed!==t;this.playbackSpeed=t,e&&(this.time=io(this.currentTime))}play(){if(this.resolver.isScheduled||this.resolver.resume(),!this._resolved)return void(this.pendingPlayState="running");if(this.isStopped)return;const{driver:t=Ys,onPlay:e,startTime:n}=this.options;this.driver||(this.driver=t((t=>this.tick(t)))),e&&e();const r=this.driver.now();null!==this.holdTime?this.startTime=r-this.holdTime:this.startTime?"finished"===this.state&&(this.startTime=r):this.startTime=null!=n?n:this.calcStartTime(),"finished"===this.state&&this.updateFinishedPromise(),this.cancelTime=this.startTime,this.holdTime=null,this.state="running",this.driver.start()}pause(){var t;this._resolved?(this.state="paused",this.holdTime=null!==(t=this.currentTime)&&void 0!==t?t:0):this.pendingPlayState="paused"}complete(){"running"!==this.state&&this.play(),this.pendingPlayState=this.state="finished",this.holdTime=null}finish(){this.teardown(),this.state="finished";const{onComplete:t}=this.options;t&&t()}cancel(){null!==this.cancelTime&&this.tick(this.cancelTime),this.teardown(),this.updateFinishedPromise()}teardown(){this.state="idle",this.stopDriver(),this.resolveFinishedPromise(),this.updateFinishedPromise(),this.startTime=this.cancelTime=null,this.resolver.cancel()}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(t){return this.startTime=0,this.tick(t,!0)}}const ea=new Set(["opacity","clipPath","filter","transform"]);function na(t){let e;return()=>(void 0===e&&(e=t()),e)}const ra={linearEasing:void 0};function oa(t,e){const n=na(t);return()=>{var t;return null!==(t=ra[e])&&void 0!==t?t:n()}}const ia=oa((()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch(t){return!1}return!0}),"linearEasing");function sa(t){return Boolean("function"==typeof t&&ia()||!t||"string"==typeof t&&(t in ca||ia())||Cs(t)||Array.isArray(t)&&t.every(sa))}const aa=([t,e,n,r])=>`cubic-bezier(${t}, ${e}, ${n}, ${r})`,ca={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:aa([0,.65,.55,1]),circOut:aa([.55,0,1,.45]),backIn:aa([.31,.01,.66,-.59]),backOut:aa([.33,1.53,.69,.99])};function la(t,e){return t?"function"==typeof t&&ia()?us(t,e):Cs(t)?aa(t):Array.isArray(t)?t.map((t=>la(t,e)||ca.easeOut)):ca[t]:void 0}function ua(t,e,n,{delay:r=0,duration:o=300,repeat:i=0,repeatType:s="loop",ease:a="easeInOut",times:c}={}){const l={[e]:n};c&&(l.offset=c);const u=la(a,o);return Array.isArray(u)&&(l.easing=u),t.animate(l,{delay:r,duration:o,easing:Array.isArray(u)?"linear":u,fill:"both",iterations:i+1,direction:"reverse"===s?"alternate":"normal"})}function ha(t,e){t.timeline=e,t.onfinish=null}const da=na((()=>Object.hasOwnProperty.call(Element.prototype,"animate")));const fa={anticipate:No,backInOut:Oo,circInOut:Lo};class pa extends cs{constructor(t){super(t);const{name:e,motionValue:n,element:r,keyframes:o}=this.options;this.resolver=new es(o,((t,e)=>this.onKeyframesResolved(t,e)),e,n,r),this.resolver.scheduleResolve()}initPlayback(t,e){var n;let{duration:r=300,times:o,ease:i,type:s,motionValue:a,name:c,startTime:l}=this.options;if(!(null===(n=a.owner)||void 0===n?void 0:n.current))return!1;var u;if("string"==typeof i&&ia()&&i in fa&&(i=fa[i]),ns((u=this.options).type)||"spring"===u.type||!sa(u.ease)){const{onComplete:e,onUpdate:n,motionValue:a,element:c,...l}=this.options,u=function(t,e){const n=new ta({...e,keyframes:t,repeat:0,delay:0,isGenerator:!0});let r={done:!1,value:t[0]};const o=[];let i=0;for(;!r.done&&i<2e4;)r=n.sample(i),o.push(r.value),i+=10;return{times:void 0,keyframes:o,duration:i-10,ease:"linear"}}(t,l);1===(t=u.keyframes).length&&(t[1]=t[0]),r=u.duration,o=u.times,i=u.ease,s="keyframes"}const h=ua(a.owner.current,c,t,{...this.options,duration:r,times:o,ease:i});return h.startTime=null!=l?l:this.calcStartTime(),this.pendingTimeline?(ha(h,this.pendingTimeline),this.pendingTimeline=void 0):h.onfinish=()=>{const{onComplete:n}=this.options;a.set(go(t,this.options,e)),n&&n(),this.cancel(),this.resolveFinishedPromise()},{animation:h,duration:r,times:o,type:s,ease:i,keyframes:t}}get duration(){const{resolved:t}=this;if(!t)return 0;const{duration:e}=t;return io(e)}get time(){const{resolved:t}=this;if(!t)return 0;const{animation:e}=t;return io(e.currentTime||0)}set time(t){const{resolved:e}=this;if(!e)return;const{animation:n}=e;n.currentTime=oo(t)}get speed(){const{resolved:t}=this;if(!t)return 1;const{animation:e}=t;return e.playbackRate}set speed(t){const{resolved:e}=this;if(!e)return;const{animation:n}=e;n.playbackRate=t}get state(){const{resolved:t}=this;if(!t)return"idle";const{animation:e}=t;return e.playState}get startTime(){const{resolved:t}=this;if(!t)return null;const{animation:e}=t;return e.startTime}attachTimeline(t){if(this._resolved){const{resolved:e}=this;if(!e)return yo;const{animation:n}=e;ha(n,t)}else this.pendingTimeline=t;return yo}play(){if(this.isStopped)return;const{resolved:t}=this;if(!t)return;const{animation:e}=t;"finished"===e.playState&&this.updateFinishedPromise(),e.play()}pause(){const{resolved:t}=this;if(!t)return;const{animation:e}=t;e.pause()}stop(){if(this.resolver.cancel(),this.isStopped=!0,"idle"===this.state)return;this.resolveFinishedPromise(),this.updateFinishedPromise();const{resolved:t}=this;if(!t)return;const{animation:e,keyframes:n,duration:r,type:o,ease:i,times:s}=t;if("idle"===e.playState||"finished"===e.playState)return;if(this.time){const{motionValue:t,onUpdate:e,onComplete:a,element:c,...l}=this.options,u=new ta({...l,keyframes:n,duration:r,type:o,ease:i,times:s,isGenerator:!0}),h=oo(this.time);t.setWithVelocity(u.sample(h-10).value,u.sample(h).value,10)}const{onStop:a}=this.options;a&&a(),this.cancel()}complete(){const{resolved:t}=this;t&&t.animation.finish()}cancel(){const{resolved:t}=this;t&&t.animation.cancel()}static supports(t){const{motionValue:e,name:n,repeatDelay:r,repeatType:o,damping:i,type:s}=t;return da()&&n&&ea.has(n)&&e&&e.owner&&e.owner.current instanceof HTMLElement&&!e.owner.getProps().onUpdate&&!r&&"mirror"!==o&&0!==i&&"inertia"!==s}}const ma=na((()=>void 0!==window.ScrollTimeline));class ga{constructor(t){this.stop=()=>this.runAll("stop"),this.animations=t.filter(Boolean)}then(t,e){return Promise.all(this.animations).then(t).catch(e)}getAll(t){return this.animations[0][t]}setAll(t,e){for(let n=0;n<this.animations.length;n++)this.animations[n][t]=e}attachTimeline(t,e){const n=this.animations.map((n=>ma()&&n.attachTimeline?n.attachTimeline(t):e(n)));return()=>{n.forEach(((t,e)=>{t&&t(),this.animations[e].stop()}))}}get time(){return this.getAll("time")}set time(t){this.setAll("time",t)}get speed(){return this.getAll("speed")}set speed(t){this.setAll("speed",t)}get startTime(){return this.getAll("startTime")}get duration(){let t=0;for(let e=0;e<this.animations.length;e++)t=Math.max(t,this.animations[e].duration);return t}runAll(t){this.animations.forEach((e=>e[t]()))}flatten(){this.runAll("flatten")}play(){this.runAll("play")}pause(){this.runAll("pause")}cancel(){this.runAll("cancel")}complete(){this.runAll("complete")}}const ya=(t,e,n,r={},o,i)=>s=>{const a=uo(r,t)||{},c=a.delay||r.delay||0;let{elapsed:l=0}=r;l-=oo(c);let u={keyframes:Array.isArray(n)?n:[null,n],ease:"easeOut",velocity:e.getVelocity(),...a,delay:-l,onUpdate:t=>{e.set(t),a.onUpdate&&a.onUpdate(t)},onComplete:()=>{s(),a.onComplete&&a.onComplete()},name:t,motionValue:e,element:i?void 0:o};(function({when:t,delay:e,delayChildren:n,staggerChildren:r,staggerDirection:o,repeat:i,repeatType:s,repeatDelay:a,from:c,elapsed:l,...u}){return!!Object.keys(u).length})(a)||(u={...u,...lo(t,u)}),u.duration&&(u.duration=oo(u.duration)),u.repeatDelay&&(u.repeatDelay=oo(u.repeatDelay)),void 0!==u.from&&(u.keyframes[0]=u.from);let h=!1;if((!1===u.type||0===u.duration&&!u.repeatDelay)&&(u.duration=0,0===u.delay&&(h=!0)),(po||ho)&&(h=!0,u.duration=0,u.delay=0),h&&!i&&void 0!==e.get()){const t=go(u.keyframes,a);if(void 0!==t)return bo.update((()=>{u.onUpdate(t),u.onComplete()})),new ga([])}return!i&&pa.supports(u)?new pa(u):new ta(u)},wa=t=>Boolean(t&&"object"==typeof t&&t.mix&&t.toValue),va=t=>Zr(t)?t[t.length-1]||0:t;function ba(t,e){-1===t.indexOf(e)&&t.push(e)}function Ea(t,e){const n=t.indexOf(e);n>-1&&t.splice(n,1)}class Sa{constructor(){this.subscriptions=[]}add(t){return ba(this.subscriptions,t),()=>Ea(this.subscriptions,t)}notify(t,e,n){const r=this.subscriptions.length;if(r)if(1===r)this.subscriptions[0](t,e,n);else for(let o=0;o<r;o++){const r=this.subscriptions[o];r&&r(t,e,n)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}const xa={current:void 0};class Ta{constructor(t,e={}){this.version="11.15.0",this.canTrackVelocity=null,this.events={},this.updateAndNotify=(t,e=!0)=>{const n=is.now();this.updatedAt!==n&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(t),this.current!==this.prev&&this.events.change&&this.events.change.notify(this.current),e&&this.events.renderRequest&&this.events.renderRequest.notify(this.current)},this.hasAnimated=!1,this.setCurrent(t),this.owner=e.owner}setCurrent(t){var e;this.current=t,this.updatedAt=is.now(),null===this.canTrackVelocity&&void 0!==t&&(this.canTrackVelocity=(e=this.current,!isNaN(parseFloat(e))))}setPrevFrameValue(t=this.current){this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt}onChange(t){return this.on("change",t)}on(t,e){this.events[t]||(this.events[t]=new Sa);const n=this.events[t].add(e);return"change"===t?()=>{n(),bo.read((()=>{this.events.change.getSize()||this.stop()}))}:n}clearListeners(){for(const t in this.events)this.events[t].clear()}attach(t,e){this.passiveEffect=t,this.stopPassiveEffect=e}set(t,e=!0){e&&this.passiveEffect?this.passiveEffect(t,this.updateAndNotify):this.updateAndNotify(t,e)}setWithVelocity(t,e,n){this.set(e),this.prev=void 0,this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt-n}jump(t,e=!0){this.updateAndNotify(t),this.prev=t,this.prevUpdatedAt=this.prevFrameValue=void 0,e&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}get(){return xa.current&&xa.current.push(this),this.current}getPrevious(){return this.prev}getVelocity(){const t=is.now();if(!this.canTrackVelocity||void 0===this.prevFrameValue||t-this.updatedAt>30)return 0;const e=Math.min(this.updatedAt-this.prevUpdatedAt,30);return hs(parseFloat(this.current)-parseFloat(this.prevFrameValue),e)}start(t){return this.stop(),new Promise((e=>{this.hasAnimated=!0,this.animation=t(e),this.events.animationStart&&this.events.animationStart.notify()})).then((()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()}))}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function Aa(t,e){return new Ta(t,e)}function _a(t,e,n){t.hasValue(e)?t.getValue(e).set(n):t.addValue(e,Aa(n))}const ka=t=>t.replace(/([a-z])([A-Z])/gu,"$1-$2").toLowerCase(),Ra="data-"+ka("framerAppearId");function Ca(t){return t.props[Ra]}const Pa=t=>Boolean(t&&t.getVelocity);function Ia(t,e){const n=t.getValue("willChange");if(r=n,Boolean(Pa(r)&&r.add))return n.add(e);var r}function Oa({protectedKeys:t,needsAnimating:e},n){const r=t.hasOwnProperty(n)&&!0!==e[n];return e[n]=!1,r}function Na(t,e,{delay:n=0,transitionOverride:r,type:o}={}){var i;let{transition:s=t.getDefaultTransition(),transitionEnd:a,...c}=e;r&&(s=r);const l=[],u=o&&t.animationState&&t.animationState.getState()[o];for(const e in c){const r=t.getValue(e,null!==(i=t.latestValues[e])&&void 0!==i?i:null),o=c[e];if(void 0===o||u&&Oa(u,e))continue;const a={delay:n,...uo(s||{},e)};let h=!1;if(window.MotionHandoffAnimation){const n=Ca(t);if(n){const t=window.MotionHandoffAnimation(n,e,bo);null!==t&&(a.startTime=t,h=!0)}}Ia(t,e),r.start(ya(e,r,o,t.shouldReduceMotion&&ro.has(e)?{type:!1}:a,t,h));const d=r.animation;d&&l.push(d)}return a&&Promise.all(l).then((()=>{bo.update((()=>{a&&function(t,e){const n=Qr(t,e);let{transitionEnd:r={},transition:o={},...i}=n||{};i={...i,...r};for(const e in i)_a(t,e,va(i[e]))}(t,a)}))})),l}function Ba(t,e,n={}){var r;const o=Qr(t,e,"exit"===n.type?null===(r=t.presenceContext)||void 0===r?void 0:r.custom:void 0);let{transition:i=t.getDefaultTransition()||{}}=o||{};n.transitionOverride&&(i=n.transitionOverride);const s=o?()=>Promise.all(Na(t,o,n)):()=>Promise.resolve(),a=t.variantChildren&&t.variantChildren.size?(r=0)=>{const{delayChildren:o=0,staggerChildren:s,staggerDirection:a}=i;return function(t,e,n=0,r=0,o=1,i){const s=[],a=(t.variantChildren.size-1)*r,c=1===o?(t=0)=>t*r:(t=0)=>a-t*r;return Array.from(t.variantChildren).sort(Ua).forEach(((t,r)=>{t.notify("AnimationStart",e),s.push(Ba(t,e,{...i,delay:n+c(r)}).then((()=>t.notify("AnimationComplete",e))))})),Promise.all(s)}(t,e,o+r,s,a,n)}:()=>Promise.resolve(),{when:c}=i;if(c){const[t,e]="beforeChildren"===c?[s,a]:[a,s];return t().then((()=>e()))}return Promise.all([s(),a(n.delay)])}function Ua(t,e){return t.sortNodePosition(e)}const La=eo.length;function ja(t){if(!t)return;if(!t.isControllingVariants){const e=t.parent&&ja(t.parent)||{};return void 0!==t.props.initial&&(e.initial=t.props.initial),e}const e={};for(let n=0;n<La;n++){const r=eo[n],o=t.props[r];(Gr(o)||!1===o)&&(e[r]=o)}return e}const Da=[...to].reverse(),Ma=to.length;function Va(t){return e=>Promise.all(e.map((({animation:e,options:n})=>function(t,e,n={}){let r;if(t.notify("AnimationStart",e),Array.isArray(e)){const o=e.map((e=>Ba(t,e,n)));r=Promise.all(o)}else if("string"==typeof e)r=Ba(t,e,n);else{const o="function"==typeof e?Qr(t,e,n.custom):e;r=Promise.all(Na(t,o,n))}return r.then((()=>{t.notify("AnimationComplete",e)}))}(t,e,n))))}function Fa(t){let e=Va(t),n=Wa(),r=!0;const o=e=>(n,r)=>{var o;const i=Qr(t,r,"exit"===e?null===(o=t.presenceContext)||void 0===o?void 0:o.custom:void 0);if(i){const{transition:t,transitionEnd:e,...r}=i;n={...n,...r,...e}}return n};function i(i){const{props:s}=t,a=ja(t.parent)||{},c=[],l=new Set;let u={},h=1/0;for(let e=0;e<Ma;e++){const d=Da[e],f=n[d],p=void 0!==s[d]?s[d]:a[d],m=Gr(p),g=d===i?f.isActive:null;!1===g&&(h=e);let y=p===a[d]&&p!==s[d]&&m;if(y&&r&&t.manuallyAnimateOnMount&&(y=!1),f.protectedKeys={...u},!f.isActive&&null===g||!p&&!f.prevProp||qr(p)||"boolean"==typeof p)continue;const w=Ka(f.prevProp,p);let v=w||d===i&&f.isActive&&!y&&m||e>h&&m,b=!1;const E=Array.isArray(p)?p:[p];let S=E.reduce(o(d),{});!1===g&&(S={});const{prevResolvedValues:x={}}=f,T={...x,...S},A=e=>{v=!0,l.has(e)&&(b=!0,l.delete(e)),f.needsAnimating[e]=!0;const n=t.getValue(e);n&&(n.liveStyle=!1)};for(const t in T){const e=S[t],n=x[t];if(u.hasOwnProperty(t))continue;let r=!1;r=Zr(e)&&Zr(n)?!Xr(e,n):e!==n,r?null!=e?A(t):l.add(t):void 0!==e&&l.has(t)?A(t):f.protectedKeys[t]=!0}f.prevProp=p,f.prevResolvedValues=S,f.isActive&&(u={...u,...S}),r&&t.blockInitialAnimation&&(v=!1);v&&(!(y&&w)||b)&&c.push(...E.map((t=>({animation:t,options:{type:d}}))))}if(l.size){const e={};l.forEach((n=>{const r=t.getBaseTarget(n),o=t.getValue(n);o&&(o.liveStyle=!0),e[n]=null!=r?r:null})),c.push({animation:e})}let d=Boolean(c.length);return!r||!1!==s.initial&&s.initial!==s.animate||t.manuallyAnimateOnMount||(d=!1),r=!1,d?e(c):Promise.resolve()}return{animateChanges:i,setActive:function(e,r){var o;if(n[e].isActive===r)return Promise.resolve();null===(o=t.variantChildren)||void 0===o||o.forEach((t=>{var n;return null===(n=t.animationState)||void 0===n?void 0:n.setActive(e,r)})),n[e].isActive=r;const s=i(e);for(const t in n)n[t].protectedKeys={};return s},setAnimateFunction:function(n){e=n(t)},getState:()=>n,reset:()=>{n=Wa(),r=!0}}}function Ka(t,e){return"string"==typeof e?e!==t:!!Array.isArray(e)&&!Xr(e,t)}function $a(t=!1){return{isActive:t,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function Wa(){return{animate:$a(!0),whileInView:$a(),whileHover:$a(),whileTap:$a(),whileDrag:$a(),whileFocus:$a(),exit:$a()}}class za{constructor(t){this.isMounted=!1,this.node=t}update(){}}let Ha=0;const qa={animation:{Feature:class extends za{constructor(t){super(t),t.animationState||(t.animationState=Fa(t))}updateAnimationControlsSubscription(){const{animate:t}=this.node.getProps();qr(t)&&(this.unmountControls=t.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:t}=this.node.getProps(),{animate:e}=this.node.prevProps||{};t!==e&&this.updateAnimationControlsSubscription()}unmount(){var t;this.node.animationState.reset(),null===(t=this.unmountControls)||void 0===t||t.call(this)}}},exit:{Feature:class extends za{constructor(){super(...arguments),this.id=Ha++}update(){if(!this.node.presenceContext)return;const{isPresent:t,onExitComplete:e}=this.node.presenceContext,{isPresent:n}=this.node.prevPresenceContext||{};if(!this.node.animationState||t===n)return;const r=this.node.animationState.setActive("exit",!t);e&&!t&&r.then((()=>e(this.id)))}mount(){const{register:t}=this.node.presenceContext||{};t&&(this.unmount=t(this.id))}unmount(){}}}},Za={x:!1,y:!1};function Xa(){return Za.x||Za.y}function Ga(t,e){const n=function(t,e,n){var r;if(t instanceof Element)return[t];if("string"==typeof t){let o=document;e&&(o=e.current);const i=null!==(r=null==n?void 0:n[t])&&void 0!==r?r:o.querySelectorAll(t);return i?Array.from(i):[]}return Array.from(t)}(t),r=new AbortController;return[n,{passive:!0,...e,signal:r.signal},()=>r.abort()]}function Ya(t){return e=>{"touch"===e.pointerType||Xa()||t(e)}}const Ja=t=>"mouse"===t.pointerType?"number"!=typeof t.button||t.button<=0:!1!==t.isPrimary,Qa=new WeakSet;function tc(t){return e=>{"Enter"===e.key&&t(e)}}function ec(t,e){t.dispatchEvent(new PointerEvent("pointer"+e,{isPrimary:!0,bubbles:!0}))}const nc=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);const rc=(t,e)=>!!e&&(t===e||rc(t,e.parentElement));function oc(t){return Ja(t)&&!Xa()}function ic(t,e,n={}){const[r,o,i]=Ga(t,n),s=t=>{const r=t.currentTarget;if(!oc(t)||Qa.has(r))return;Qa.add(r);const i=e(t),s=(t,e)=>{window.removeEventListener("pointerup",a),window.removeEventListener("pointercancel",c),oc(t)&&Qa.has(r)&&(Qa.delete(r),i&&i(t,{success:e}))},a=t=>{s(t,n.useGlobalTarget||rc(r,t.target))},c=t=>{s(t,!1)};window.addEventListener("pointerup",a,o),window.addEventListener("pointercancel",c,o)};return r.forEach((t=>{(function(t){return nc.has(t.tagName)||-1!==t.tabIndex})(t)||(t.tabIndex=0);(n.useGlobalTarget?window:t).addEventListener("pointerdown",s,o),t.addEventListener("focus",(t=>((t,e)=>{const n=t.currentTarget;if(!n)return;const r=tc((()=>{if(Qa.has(n))return;ec(n,"down");const t=tc((()=>{ec(n,"up")}));n.addEventListener("keyup",t,e),n.addEventListener("blur",(()=>ec(n,"cancel")),e)}));n.addEventListener("keydown",r,e),n.addEventListener("blur",(()=>n.removeEventListener("keydown",r)),e)})(t,o)),o)})),i}function sc(t){return{point:{x:t.pageX,y:t.pageY}}}function ac(t,e,n,r={passive:!0}){return t.addEventListener(e,n,r),()=>t.removeEventListener(e,n)}function cc(t,e,n,r){return ac(t,e,(t=>e=>Ja(e)&&t(e,sc(e)))(n),r)}const lc=(t,e)=>Math.abs(t-e);class uc{constructor(t,e,{transformPagePoint:n,contextWindow:r,dragSnapToOrigin:o=!1}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.updatePoint=()=>{if(!this.lastMoveEvent||!this.lastMoveEventInfo)return;const t=fc(this.lastMoveEventInfo,this.history),e=null!==this.startEvent,n=function(t,e){const n=lc(t.x,e.x),r=lc(t.y,e.y);return Math.sqrt(n**2+r**2)}(t.offset,{x:0,y:0})>=3;if(!e&&!n)return;const{point:r}=t,{timestamp:o}=So;this.history.push({...r,timestamp:o});const{onStart:i,onMove:s}=this.handlers;e||(i&&i(this.lastMoveEvent,t),this.startEvent=this.lastMoveEvent),s&&s(this.lastMoveEvent,t)},this.handlePointerMove=(t,e)=>{this.lastMoveEvent=t,this.lastMoveEventInfo=hc(e,this.transformPagePoint),bo.update(this.updatePoint,!0)},this.handlePointerUp=(t,e)=>{this.end();const{onEnd:n,onSessionEnd:r,resumeAnimation:o}=this.handlers;if(this.dragSnapToOrigin&&o&&o(),!this.lastMoveEvent||!this.lastMoveEventInfo)return;const i=fc("pointercancel"===t.type?this.lastMoveEventInfo:hc(e,this.transformPagePoint),this.history);this.startEvent&&n&&n(t,i),r&&r(t,i)},!Ja(t))return;this.dragSnapToOrigin=o,this.handlers=e,this.transformPagePoint=n,this.contextWindow=r||window;const i=hc(sc(t),this.transformPagePoint),{point:s}=i,{timestamp:a}=So;this.history=[{...s,timestamp:a}];const{onSessionStart:c}=e;c&&c(t,fc(i,this.history)),this.removeListeners=Ns(cc(this.contextWindow,"pointermove",this.handlePointerMove),cc(this.contextWindow,"pointerup",this.handlePointerUp),cc(this.contextWindow,"pointercancel",this.handlePointerUp))}updateHandlers(t){this.handlers=t}end(){this.removeListeners&&this.removeListeners(),Eo(this.updatePoint)}}function hc(t,e){return e?{point:e(t.point)}:t}function dc(t,e){return{x:t.x-e.x,y:t.y-e.y}}function fc({point:t},e){return{point:t,delta:dc(t,mc(e)),offset:dc(t,pc(e)),velocity:gc(e,.1)}}function pc(t){return t[0]}function mc(t){return t[t.length-1]}function gc(t,e){if(t.length<2)return{x:0,y:0};let n=t.length-1,r=null;const o=mc(t);for(;n>=0&&(r=t[n],!(o.timestamp-r.timestamp>oo(e)));)n--;if(!r)return{x:0,y:0};const i=io(o.timestamp-r.timestamp);if(0===i)return{x:0,y:0};const s={x:(o.x-r.x)/i,y:(o.y-r.y)/i};return s.x===1/0&&(s.x=0),s.y===1/0&&(s.y=0),s}function yc(t){return t&&"object"==typeof t&&Object.prototype.hasOwnProperty.call(t,"current")}const wc=.9999,vc=1.0001,bc=-.01,Ec=.01;function Sc(t){return t.max-t.min}function xc(t,e,n,r=.5){t.origin=r,t.originPoint=Bs(e.min,e.max,t.origin),t.scale=Sc(n)/Sc(e),t.translate=Bs(n.min,n.max,t.origin)-t.originPoint,(t.scale>=wc&&t.scale<=vc||isNaN(t.scale))&&(t.scale=1),(t.translate>=bc&&t.translate<=Ec||isNaN(t.translate))&&(t.translate=0)}function Tc(t,e,n,r){xc(t.x,e.x,n.x,r?r.originX:void 0),xc(t.y,e.y,n.y,r?r.originY:void 0)}function Ac(t,e,n){t.min=n.min+e.min,t.max=t.min+Sc(e)}function _c(t,e,n){t.min=e.min-n.min,t.max=t.min+Sc(e)}function kc(t,e,n){_c(t.x,e.x,n.x),_c(t.y,e.y,n.y)}function Rc(t,e,n){return{min:void 0!==e?t.min+e:void 0,max:void 0!==n?t.max+n-(t.max-t.min):void 0}}function Cc(t,e){let n=e.min-t.min,r=e.max-t.max;return e.max-e.min<t.max-t.min&&([n,r]=[r,n]),{min:n,max:r}}const Pc=.35;function Ic(t,e,n){return{min:Oc(t,e),max:Oc(t,n)}}function Oc(t,e){return"number"==typeof t?t:t[e]||0}const Nc=()=>({x:{translate:0,scale:1,origin:0,originPoint:0},y:{translate:0,scale:1,origin:0,originPoint:0}}),Bc=()=>({x:{min:0,max:0},y:{min:0,max:0}});function Uc(t){return[t("x"),t("y")]}function Lc({top:t,left:e,right:n,bottom:r}){return{x:{min:e,max:n},y:{min:t,max:r}}}function jc(t){return void 0===t||1===t}function Dc({scale:t,scaleX:e,scaleY:n}){return!jc(t)||!jc(e)||!jc(n)}function Mc(t){return Dc(t)||Vc(t)||t.z||t.rotate||t.rotateX||t.rotateY||t.skewX||t.skewY}function Vc(t){return Fc(t.x)||Fc(t.y)}function Fc(t){return t&&"0%"!==t}function Kc(t,e,n){return n+e*(t-n)}function $c(t,e,n,r,o){return void 0!==o&&(t=Kc(t,o,r)),Kc(t,n,r)+e}function Wc(t,e=0,n=1,r,o){t.min=$c(t.min,e,n,r,o),t.max=$c(t.max,e,n,r,o)}function zc(t,{x:e,y:n}){Wc(t.x,e.translate,e.scale,e.originPoint),Wc(t.y,n.translate,n.scale,n.originPoint)}const Hc=.999999999999,qc=1.0000000000001;function Zc(t,e){t.min=t.min+e,t.max=t.max+e}function Xc(t,e,n,r,o=.5){Wc(t,e,n,Bs(t.min,t.max,o),r)}function Gc(t,e){Xc(t.x,e.x,e.scaleX,e.scale,e.originX),Xc(t.y,e.y,e.scaleY,e.scale,e.originY)}function Yc(t,e){return Lc(function(t,e){if(!e)return t;const n=e({x:t.left,y:t.top}),r=e({x:t.right,y:t.bottom});return{top:n.y,left:n.x,bottom:r.y,right:r.x}}(t.getBoundingClientRect(),e))}const Jc=({current:t})=>t?t.ownerDocument.defaultView:null,Qc=new WeakMap;class tl{constructor(t){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=Bc(),this.visualElement=t}start(t,{snapToCursor:e=!1}={}){const{presenceContext:n}=this.visualElement;if(n&&!1===n.isPresent)return;const{dragSnapToOrigin:r}=this.getProps();this.panSession=new uc(t,{onSessionStart:t=>{const{dragSnapToOrigin:n}=this.getProps();n?this.pauseAnimation():this.stopAnimation(),e&&this.snapToCursor(sc(t).point)},onStart:(t,e)=>{const{drag:n,dragPropagation:r,onDragStart:o}=this.getProps();if(n&&!r&&(this.openDragLock&&this.openDragLock(),this.openDragLock="x"===(i=n)||"y"===i?Za[i]?null:(Za[i]=!0,()=>{Za[i]=!1}):Za.x||Za.y?null:(Za.x=Za.y=!0,()=>{Za.x=Za.y=!1}),!this.openDragLock))return;var i;this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),Uc((t=>{let e=this.getAxisMotionValue(t).get()||0;if(ti.test(e)){const{projection:n}=this.visualElement;if(n&&n.layout){const r=n.layout.layoutBox[t];if(r){e=Sc(r)*(parseFloat(e)/100)}}}this.originPoint[t]=e})),o&&bo.postRender((()=>o(t,e))),Ia(this.visualElement,"transform");const{animationState:s}=this.visualElement;s&&s.setActive("whileDrag",!0)},onMove:(t,e)=>{const{dragPropagation:n,dragDirectionLock:r,onDirectionLock:o,onDrag:i}=this.getProps();if(!n&&!this.openDragLock)return;const{offset:s}=e;if(r&&null===this.currentDirection)return this.currentDirection=function(t,e=10){let n=null;Math.abs(t.y)>e?n="y":Math.abs(t.x)>e&&(n="x");return n}(s),void(null!==this.currentDirection&&o&&o(this.currentDirection));this.updateAxis("x",e.point,s),this.updateAxis("y",e.point,s),this.visualElement.render(),i&&i(t,e)},onSessionEnd:(t,e)=>this.stop(t,e),resumeAnimation:()=>Uc((t=>{var e;return"paused"===this.getAnimationState(t)&&(null===(e=this.getAxisMotionValue(t).animation)||void 0===e?void 0:e.play())}))},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:r,contextWindow:Jc(this.visualElement)})}stop(t,e){const n=this.isDragging;if(this.cancel(),!n)return;const{velocity:r}=e;this.startAnimation(r);const{onDragEnd:o}=this.getProps();o&&bo.postRender((()=>o(t,e)))}cancel(){this.isDragging=!1;const{projection:t,animationState:e}=this.visualElement;t&&(t.isAnimationBlocked=!1),this.panSession&&this.panSession.end(),this.panSession=void 0;const{dragPropagation:n}=this.getProps();!n&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),e&&e.setActive("whileDrag",!1)}updateAxis(t,e,n){const{drag:r}=this.getProps();if(!n||!el(t,r,this.currentDirection))return;const o=this.getAxisMotionValue(t);let i=this.originPoint[t]+n[t];this.constraints&&this.constraints[t]&&(i=function(t,{min:e,max:n},r){return void 0!==e&&t<e?t=r?Bs(e,t,r.min):Math.max(t,e):void 0!==n&&t>n&&(t=r?Bs(n,t,r.max):Math.min(t,n)),t}(i,this.constraints[t],this.elastic[t])),o.set(i)}resolveConstraints(){var t;const{dragConstraints:e,dragElastic:n}=this.getProps(),r=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):null===(t=this.visualElement.projection)||void 0===t?void 0:t.layout,o=this.constraints;e&&yc(e)?this.constraints||(this.constraints=this.resolveRefConstraints()):this.constraints=!(!e||!r)&&function(t,{top:e,left:n,bottom:r,right:o}){return{x:Rc(t.x,n,o),y:Rc(t.y,e,r)}}(r.layoutBox,e),this.elastic=function(t=Pc){return!1===t?t=0:!0===t&&(t=Pc),{x:Ic(t,"left","right"),y:Ic(t,"top","bottom")}}(n),o!==this.constraints&&r&&this.constraints&&!this.hasMutatedConstraints&&Uc((t=>{!1!==this.constraints&&this.getAxisMotionValue(t)&&(this.constraints[t]=function(t,e){const n={};return void 0!==e.min&&(n.min=e.min-t.min),void 0!==e.max&&(n.max=e.max-t.min),n}(r.layoutBox[t],this.constraints[t]))}))}resolveRefConstraints(){const{dragConstraints:t,onMeasureDragConstraints:e}=this.getProps();if(!t||!yc(t))return!1;const n=t.current;Mo(null!==n,"If `dragConstraints` is set as a React ref, that ref must be passed to another component's `ref` prop.");const{projection:r}=this.visualElement;if(!r||!r.layout)return!1;const o=function(t,e,n){const r=Yc(t,n),{scroll:o}=e;return o&&(Zc(r.x,o.offset.x),Zc(r.y,o.offset.y)),r}(n,r.root,this.visualElement.getTransformPagePoint());let i=function(t,e){return{x:Cc(t.x,e.x),y:Cc(t.y,e.y)}}(r.layout.layoutBox,o);if(e){const t=e(function({x:t,y:e}){return{top:e.min,right:t.max,bottom:e.max,left:t.min}}(i));this.hasMutatedConstraints=!!t,t&&(i=Lc(t))}return i}startAnimation(t){const{drag:e,dragMomentum:n,dragElastic:r,dragTransition:o,dragSnapToOrigin:i,onDragTransitionEnd:s}=this.getProps(),a=this.constraints||{},c=Uc((s=>{if(!el(s,e,this.currentDirection))return;let c=a&&a[s]||{};i&&(c={min:0,max:0});const l=r?200:1e6,u=r?40:1e7,h={type:"inertia",velocity:n?t[s]:0,bounceStiffness:l,bounceDamping:u,timeConstant:750,restDelta:1,restSpeed:10,...o,...c};return this.startAxisValueAnimation(s,h)}));return Promise.all(c).then(s)}startAxisValueAnimation(t,e){const n=this.getAxisMotionValue(t);return Ia(this.visualElement,t),n.start(ya(t,n,0,e,this.visualElement,!1))}stopAnimation(){Uc((t=>this.getAxisMotionValue(t).stop()))}pauseAnimation(){Uc((t=>{var e;return null===(e=this.getAxisMotionValue(t).animation)||void 0===e?void 0:e.pause()}))}getAnimationState(t){var e;return null===(e=this.getAxisMotionValue(t).animation)||void 0===e?void 0:e.state}getAxisMotionValue(t){const e=`_drag${t.toUpperCase()}`,n=this.visualElement.getProps(),r=n[e];return r||this.visualElement.getValue(t,(n.initial?n.initial[t]:void 0)||0)}snapToCursor(t){Uc((e=>{const{drag:n}=this.getProps();if(!el(e,n,this.currentDirection))return;const{projection:r}=this.visualElement,o=this.getAxisMotionValue(e);if(r&&r.layout){const{min:n,max:i}=r.layout.layoutBox[e];o.set(t[e]-Bs(n,i,.5))}}))}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:t,dragConstraints:e}=this.getProps(),{projection:n}=this.visualElement;if(!yc(e)||!n||!this.constraints)return;this.stopAnimation();const r={x:0,y:0};Uc((t=>{const e=this.getAxisMotionValue(t);if(e&&!1!==this.constraints){const n=e.get();r[t]=function(t,e){let n=.5;const r=Sc(t),o=Sc(e);return o>r?n=ls(e.min,e.max-r,t.min):r>o&&(n=ls(t.min,t.max-o,e.min)),Zo(0,1,n)}({min:n,max:n},this.constraints[t])}}));const{transformTemplate:o}=this.visualElement.getProps();this.visualElement.current.style.transform=o?o({},""):"none",n.root&&n.root.updateScroll(),n.updateLayout(),this.resolveConstraints(),Uc((e=>{if(!el(e,t,null))return;const n=this.getAxisMotionValue(e),{min:o,max:i}=this.constraints[e];n.set(Bs(o,i,r[e]))}))}addListeners(){if(!this.visualElement.current)return;Qc.set(this.visualElement,this);const t=cc(this.visualElement.current,"pointerdown",(t=>{const{drag:e,dragListener:n=!0}=this.getProps();e&&n&&this.start(t)})),e=()=>{const{dragConstraints:t}=this.getProps();yc(t)&&t.current&&(this.constraints=this.resolveRefConstraints())},{projection:n}=this.visualElement,r=n.addEventListener("measure",e);n&&!n.layout&&(n.root&&n.root.updateScroll(),n.updateLayout()),bo.read(e);const o=ac(window,"resize",(()=>this.scalePositionWithinConstraints())),i=n.addEventListener("didUpdate",(({delta:t,hasLayoutChanged:e})=>{this.isDragging&&e&&(Uc((e=>{const n=this.getAxisMotionValue(e);n&&(this.originPoint[e]+=t[e].translate,n.set(n.get()+t[e].translate))})),this.visualElement.render())}));return()=>{o(),t(),r(),i&&i()}}getProps(){const t=this.visualElement.getProps(),{drag:e=!1,dragDirectionLock:n=!1,dragPropagation:r=!1,dragConstraints:o=!1,dragElastic:i=Pc,dragMomentum:s=!0}=t;return{...t,drag:e,dragDirectionLock:n,dragPropagation:r,dragConstraints:o,dragElastic:i,dragMomentum:s}}}function el(t,e,n){return!(!0!==e&&e!==t||null!==n&&n!==t)}const nl=t=>(e,n)=>{t&&bo.postRender((()=>t(e,n)))};var rl=a(322);const ol=(0,e.createContext)(null);const il=(0,e.createContext)({}),sl=(0,e.createContext)({}),al={hasAnimatedSinceResize:!0,hasEverUpdated:!1};function cl(t,e){return e.max===e.min?0:t/(e.max-e.min)*100}const ll={correct:(t,e)=>{if(!e.target)return t;if("string"==typeof t){if(!ei.test(t))return t;t=parseFloat(t)}return`${cl(t,e.target.x)}% ${cl(t,e.target.y)}%`}},ul={correct:(t,{treeScale:e,projectionDelta:n})=>{const r=t,o=Ki.parse(t);if(o.length>5)return r;const i=Ki.createTransformer(t),s="number"!=typeof o[0]?1:0,a=n.x.scale*e.x,c=n.y.scale*e.y;o[0+s]/=a,o[1+s]/=c;const l=Bs(a,c,.5);return"number"==typeof o[2+s]&&(o[2+s]/=l),"number"==typeof o[3+s]&&(o[3+s]/=l),i(o)}},hl={};const{schedule:dl,cancel:fl}=vo(queueMicrotask,!1);class pl extends e.Component{componentDidMount(){const{visualElement:t,layoutGroup:e,switchLayoutGroup:n,layoutId:r}=this.props,{projection:o}=t;var i;i=gl,Object.assign(hl,i),o&&(e.group&&e.group.add(o),n&&n.register&&r&&n.register(o),o.root.didUpdate(),o.addEventListener("animationComplete",(()=>{this.safeToRemove()})),o.setOptions({...o.options,onExitComplete:()=>this.safeToRemove()})),al.hasEverUpdated=!0}getSnapshotBeforeUpdate(t){const{layoutDependency:e,visualElement:n,drag:r,isPresent:o}=this.props,i=n.projection;return i?(i.isPresent=o,r||t.layoutDependency!==e||void 0===e?i.willUpdate():this.safeToRemove(),t.isPresent!==o&&(o?i.promote():i.relegate()||bo.postRender((()=>{const t=i.getStack();t&&t.members.length||this.safeToRemove()}))),null):null}componentDidUpdate(){const{projection:t}=this.props.visualElement;t&&(t.root.didUpdate(),dl.postRender((()=>{!t.currentAnimation&&t.isLead()&&this.safeToRemove()})))}componentWillUnmount(){const{visualElement:t,layoutGroup:e,switchLayoutGroup:n}=this.props,{projection:r}=t;r&&(r.scheduleCheckAfterUnmount(),e&&e.group&&e.group.remove(r),n&&n.deregister&&n.deregister(r))}safeToRemove(){const{safeToRemove:t}=this.props;t&&t()}render(){return null}}function ml(t){const[n,r]=function(){const t=(0,e.useContext)(ol);if(null===t)return[!0,null];const{isPresent:n,onExitComplete:r,register:o}=t,i=(0,e.useId)();(0,e.useEffect)((()=>o(i)),[]);const s=(0,e.useCallback)((()=>r&&r(i)),[i,r]);return!n&&r?[!1,s]:[!0]}(),o=(0,e.useContext)(il);return(0,rl.jsx)(pl,{...t,layoutGroup:o,switchLayoutGroup:(0,e.useContext)(sl),isPresent:n,safeToRemove:r})}const gl={borderRadius:{...ll,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:ll,borderTopRightRadius:ll,borderBottomLeftRadius:ll,borderBottomRightRadius:ll,boxShadow:ul},yl=["TopLeft","TopRight","BottomLeft","BottomRight"],wl=yl.length,vl=t=>"string"==typeof t?parseFloat(t):t,bl=t=>"number"==typeof t||ei.test(t);function El(t,e){return void 0!==t[e]?t[e]:t.borderRadius}const Sl=Tl(0,.5,Uo),xl=Tl(.5,.95,yo);function Tl(t,e,n){return r=>r<t?0:r>e?1:n(ls(t,e,r))}function Al(t,e){t.min=e.min,t.max=e.max}function _l(t,e){Al(t.x,e.x),Al(t.y,e.y)}function kl(t,e){t.translate=e.translate,t.scale=e.scale,t.originPoint=e.originPoint,t.origin=e.origin}function Rl(t,e,n,r,o){return t=Kc(t-=e,1/n,r),void 0!==o&&(t=Kc(t,1/o,r)),t}function Cl(t,e,[n,r,o],i,s){!function(t,e=0,n=1,r=.5,o,i=t,s=t){ti.test(e)&&(e=parseFloat(e),e=Bs(s.min,s.max,e/100)-s.min);if("number"!=typeof e)return;let a=Bs(i.min,i.max,r);t===i&&(a-=e),t.min=Rl(t.min,e,n,a,o),t.max=Rl(t.max,e,n,a,o)}(t,e[n],e[r],e[o],e.scale,i,s)}const Pl=["x","scaleX","originX"],Il=["y","scaleY","originY"];function Ol(t,e,n,r){Cl(t.x,e,Pl,n?n.x:void 0,r?r.x:void 0),Cl(t.y,e,Il,n?n.y:void 0,r?r.y:void 0)}function Nl(t){return 0===t.translate&&1===t.scale}function Bl(t){return Nl(t.x)&&Nl(t.y)}function Ul(t,e){return t.min===e.min&&t.max===e.max}function Ll(t,e){return Math.round(t.min)===Math.round(e.min)&&Math.round(t.max)===Math.round(e.max)}function jl(t,e){return Ll(t.x,e.x)&&Ll(t.y,e.y)}function Dl(t){return Sc(t.x)/Sc(t.y)}function Ml(t,e){return t.translate===e.translate&&t.scale===e.scale&&t.originPoint===e.originPoint}class Vl{constructor(){this.members=[]}add(t){ba(this.members,t),t.scheduleRender()}remove(t){if(Ea(this.members,t),t===this.prevLead&&(this.prevLead=void 0),t===this.lead){const t=this.members[this.members.length-1];t&&this.promote(t)}}relegate(t){const e=this.members.findIndex((e=>t===e));if(0===e)return!1;let n;for(let t=e;t>=0;t--){const e=this.members[t];if(!1!==e.isPresent){n=e;break}}return!!n&&(this.promote(n),!0)}promote(t,e){const n=this.lead;if(t!==n&&(this.prevLead=n,this.lead=t,t.show(),n)){n.instance&&n.scheduleRender(),t.scheduleRender(),t.resumeFrom=n,e&&(t.resumeFrom.preserveOpacity=!0),n.snapshot&&(t.snapshot=n.snapshot,t.snapshot.latestValues=n.animationValues||n.latestValues),t.root&&t.root.isUpdating&&(t.isLayoutDirty=!0);const{crossfade:r}=t.options;!1===r&&n.hide()}}exitAnimationComplete(){this.members.forEach((t=>{const{options:e,resumingFrom:n}=t;e.onExitComplete&&e.onExitComplete(),n&&n.options.onExitComplete&&n.options.onExitComplete()}))}scheduleRender(){this.members.forEach((t=>{t.instance&&t.scheduleRender(!1)}))}removeLeadSnapshot(){this.lead&&this.lead.snapshot&&(this.lead.snapshot=void 0)}}const Fl=(t,e)=>t.depth-e.depth;class Kl{constructor(){this.children=[],this.isDirty=!1}add(t){ba(this.children,t),this.isDirty=!0}remove(t){Ea(this.children,t),this.isDirty=!0}forEach(t){this.isDirty&&this.children.sort(Fl),this.isDirty=!1,this.children.forEach(t)}}function $l(t){const e=Pa(t)?t.get():t;return wa(e)?e.toValue():e}function Wl(t,e){const n=is.now(),r=({timestamp:o})=>{const i=o-n;i>=e&&(Eo(r),t(i-e))};return bo.read(r,!0),()=>Eo(r)}const zl={type:"projectionFrame",totalNodes:0,resolvedTargetDeltas:0,recalculatedProjection:0},Hl="undefined"!=typeof window&&void 0!==window.MotionDebug,ql=["","X","Y","Z"],Zl={visibility:"hidden"};let Xl=0;function Gl(t,e,n,r){const{latestValues:o}=e;o[t]&&(n[t]=o[t],e.setStaticValue(t,0),r&&(r[t]=0))}function Yl(t){if(t.hasCheckedOptimisedAppear=!0,t.root===t)return;const{visualElement:e}=t.options;if(!e)return;const n=Ca(e);if(window.MotionHasOptimisedAnimation(n,"transform")){const{layout:e,layoutId:r}=t.options;window.MotionCancelOptimisedAnimation(n,"transform",bo,!(e||r))}const{parent:r}=t;r&&!r.hasCheckedOptimisedAppear&&Yl(r)}function Jl({attachResizeListener:t,defaultParent:e,measureScroll:n,checkIsScrollRoot:r,resetTransform:o}){return class{constructor(t={},n=(null==e?void 0:e())){this.id=Xl++,this.animationId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,Hl&&(zl.totalNodes=zl.resolvedTargetDeltas=zl.recalculatedProjection=0),this.nodes.forEach(eu),this.nodes.forEach(cu),this.nodes.forEach(lu),this.nodes.forEach(nu),Hl&&window.MotionDebug.record(zl)},this.resolvedRelativeTargetAt=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=t,this.root=n?n.root||n:this,this.path=n?[...n.path,n]:[],this.parent=n,this.depth=n?n.depth+1:0;for(let t=0;t<this.path.length;t++)this.path[t].shouldResetTransform=!0;this.root===this&&(this.nodes=new Kl)}addEventListener(t,e){return this.eventHandlers.has(t)||this.eventHandlers.set(t,new Sa),this.eventHandlers.get(t).add(e)}notifyListeners(t,...e){const n=this.eventHandlers.get(t);n&&n.notify(...e)}hasListeners(t){return this.eventHandlers.has(t)}mount(e,n=this.root.hasTreeAnimated){if(this.instance)return;var r;this.isSVG=(r=e)instanceof SVGElement&&"svg"!==r.tagName,this.instance=e;const{layoutId:o,layout:i,visualElement:s}=this.options;if(s&&!s.current&&s.mount(e),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),n&&(i||o)&&(this.isLayoutDirty=!0),t){let n;const r=()=>this.root.updateBlockedByResize=!1;t(e,(()=>{this.root.updateBlockedByResize=!0,n&&n(),n=Wl(r,250),al.hasAnimatedSinceResize&&(al.hasAnimatedSinceResize=!1,this.nodes.forEach(au))}))}o&&this.root.registerSharedNode(o,this),!1!==this.options.animate&&s&&(o||i)&&this.addEventListener("didUpdate",(({delta:t,hasLayoutChanged:e,hasRelativeTargetChanged:n,layout:r})=>{if(this.isTreeAnimationBlocked())return this.target=void 0,void(this.relativeTarget=void 0);const o=this.options.transition||s.getDefaultTransition()||mu,{onLayoutAnimationStart:i,onLayoutAnimationComplete:a}=s.getProps(),c=!this.targetLayout||!jl(this.targetLayout,r)||n,l=!e&&n;if(this.options.layoutRoot||this.resumeFrom&&this.resumeFrom.instance||l||e&&(c||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0),this.setAnimationOrigin(t,l);const e={...uo(o,"layout"),onPlay:i,onComplete:a};(s.shouldReduceMotion||this.options.layoutRoot)&&(e.delay=0,e.type=!1),this.startAnimation(e)}else e||au(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=r}))}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const t=this.getStack();t&&t.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,Eo(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(uu),this.animationId++)}getTransformTemplate(){const{visualElement:t}=this.options;return t&&t.getProps().transformTemplate}willUpdate(t=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked())return void(this.options.onExitComplete&&this.options.onExitComplete());if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&Yl(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let t=0;t<this.path.length;t++){const e=this.path[t];e.shouldResetTransform=!0,e.updateScroll("snapshot"),e.options.layoutRoot&&e.willUpdate(!1)}const{layoutId:e,layout:n}=this.options;if(void 0===e&&!n)return;const r=this.getTransformTemplate();this.prevTransformTemplateValue=r?r(this.latestValues,""):void 0,this.updateSnapshot(),t&&this.notifyListeners("willUpdate")}update(){this.updateScheduled=!1;if(this.isUpdateBlocked())return this.unblockUpdate(),this.clearAllSnapshots(),void this.nodes.forEach(ou);this.isUpdating||this.nodes.forEach(iu),this.isUpdating=!1,this.nodes.forEach(su),this.nodes.forEach(Ql),this.nodes.forEach(tu),this.clearAllSnapshots();const t=is.now();So.delta=Zo(0,1e3/60,t-So.timestamp),So.timestamp=t,So.isProcessing=!0,xo.update.process(So),xo.preRender.process(So),xo.render.process(So),So.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,dl.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(ru),this.sharedNodes.forEach(hu)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,bo.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){bo.postRender((()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()}))}updateSnapshot(){!this.snapshot&&this.instance&&(this.snapshot=this.measure())}updateLayout(){if(!this.instance)return;if(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead()||this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let t=0;t<this.path.length;t++){this.path[t].updateScroll()}const t=this.layout;this.layout=this.measure(!1),this.layoutCorrected=Bc(),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners("measure",this.layout.layoutBox);const{visualElement:e}=this.options;e&&e.notify("LayoutMeasure",this.layout.layoutBox,t?t.layoutBox:void 0)}updateScroll(t="measure"){let e=Boolean(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===t&&(e=!1),e){const e=r(this.instance);this.scroll={animationId:this.root.animationId,phase:t,isRoot:e,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:e}}}resetTransform(){if(!o)return;const t=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,e=this.projectionDelta&&!Bl(this.projectionDelta),n=this.getTransformTemplate(),r=n?n(this.latestValues,""):void 0,i=r!==this.prevTransformTemplateValue;t&&(e||Mc(this.latestValues)||i)&&(o(this.instance,r),this.shouldResetTransform=!1,this.scheduleRender())}measure(t=!0){const e=this.measurePageBox();let n=this.removeElementScroll(e);var r;return t&&(n=this.removeTransform(n)),wu((r=n).x),wu(r.y),{animationId:this.root.animationId,measuredBox:e,layoutBox:n,latestValues:{},source:this.id}}measurePageBox(){var t;const{visualElement:e}=this.options;if(!e)return Bc();const n=e.measureViewportBox();if(!((null===(t=this.scroll)||void 0===t?void 0:t.wasRoot)||this.path.some(bu))){const{scroll:t}=this.root;t&&(Zc(n.x,t.offset.x),Zc(n.y,t.offset.y))}return n}removeElementScroll(t){var e;const n=Bc();if(_l(n,t),null===(e=this.scroll)||void 0===e?void 0:e.wasRoot)return n;for(let e=0;e<this.path.length;e++){const r=this.path[e],{scroll:o,options:i}=r;r!==this.root&&o&&i.layoutScroll&&(o.wasRoot&&_l(n,t),Zc(n.x,o.offset.x),Zc(n.y,o.offset.y))}return n}applyTransform(t,e=!1){const n=Bc();_l(n,t);for(let t=0;t<this.path.length;t++){const r=this.path[t];!e&&r.options.layoutScroll&&r.scroll&&r!==r.root&&Gc(n,{x:-r.scroll.offset.x,y:-r.scroll.offset.y}),Mc(r.latestValues)&&Gc(n,r.latestValues)}return Mc(this.latestValues)&&Gc(n,this.latestValues),n}removeTransform(t){const e=Bc();_l(e,t);for(let t=0;t<this.path.length;t++){const n=this.path[t];if(!n.instance)continue;if(!Mc(n.latestValues))continue;Dc(n.latestValues)&&n.updateSnapshot();const r=Bc();_l(r,n.measurePageBox()),Ol(e,n.latestValues,n.snapshot?n.snapshot.layoutBox:void 0,r)}return Mc(this.latestValues)&&Ol(e,this.latestValues),e}setTargetDelta(t){this.targetDelta=t,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(t){this.options={...this.options,...t,crossfade:void 0===t.crossfade||t.crossfade}}clearMeasurements(){this.scroll=void 0,this.layout=void 0,this.snapshot=void 0,this.prevTransformTemplateValue=void 0,this.targetDelta=void 0,this.target=void 0,this.isLayoutDirty=!1}forceRelativeParentToResolveTarget(){this.relativeParent&&this.relativeParent.resolvedRelativeTargetAt!==So.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(t=!1){var e;const n=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=n.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=n.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=n.isSharedProjectionDirty);const r=Boolean(this.resumingFrom)||this!==n;if(!(t||r&&this.isSharedProjectionDirty||this.isProjectionDirty||(null===(e=this.parent)||void 0===e?void 0:e.isProjectionDirty)||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;const{layout:o,layoutId:i}=this.options;if(this.layout&&(o||i)){if(this.resolvedRelativeTargetAt=So.timestamp,!this.targetDelta&&!this.relativeTarget){const t=this.getClosestProjectingParent();t&&t.layout&&1!==this.animationProgress?(this.relativeParent=t,this.forceRelativeParentToResolveTarget(),this.relativeTarget=Bc(),this.relativeTargetOrigin=Bc(),kc(this.relativeTargetOrigin,this.layout.layoutBox,t.layout.layoutBox),_l(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}if(this.relativeTarget||this.targetDelta){var s,a,c;if(this.target||(this.target=Bc(),this.targetWithTransforms=Bc()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),s=this.target,a=this.relativeTarget,c=this.relativeParent.target,Ac(s.x,a.x,c.x),Ac(s.y,a.y,c.y)):this.targetDelta?(Boolean(this.resumingFrom)?this.target=this.applyTransform(this.layout.layoutBox):_l(this.target,this.layout.layoutBox),zc(this.target,this.targetDelta)):_l(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget){this.attemptToResolveRelativeTarget=!1;const t=this.getClosestProjectingParent();t&&Boolean(t.resumingFrom)===Boolean(this.resumingFrom)&&!t.options.layoutScroll&&t.target&&1!==this.animationProgress?(this.relativeParent=t,this.forceRelativeParentToResolveTarget(),this.relativeTarget=Bc(),this.relativeTargetOrigin=Bc(),kc(this.relativeTargetOrigin,this.target,t.target),_l(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}Hl&&zl.resolvedTargetDeltas++}}}getClosestProjectingParent(){if(this.parent&&!Dc(this.parent.latestValues)&&!Vc(this.parent.latestValues))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return Boolean((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}calcProjection(){var t;const e=this.getLead(),n=Boolean(this.resumingFrom)||this!==e;let r=!0;if((this.isProjectionDirty||(null===(t=this.parent)||void 0===t?void 0:t.isProjectionDirty))&&(r=!1),n&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(r=!1),this.resolvedRelativeTargetAt===So.timestamp&&(r=!1),r)return;const{layout:o,layoutId:i}=this.options;if(this.isTreeAnimating=Boolean(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!o&&!i)return;_l(this.layoutCorrected,this.layout.layoutBox);const s=this.treeScale.x,a=this.treeScale.y;!function(t,e,n,r=!1){const o=n.length;if(!o)return;let i,s;e.x=e.y=1;for(let a=0;a<o;a++){i=n[a],s=i.projectionDelta;const{visualElement:o}=i.options;o&&o.props.style&&"contents"===o.props.style.display||(r&&i.options.layoutScroll&&i.scroll&&i!==i.root&&Gc(t,{x:-i.scroll.offset.x,y:-i.scroll.offset.y}),s&&(e.x*=s.x.scale,e.y*=s.y.scale,zc(t,s)),r&&Mc(i.latestValues)&&Gc(t,i.latestValues))}e.x<qc&&e.x>Hc&&(e.x=1),e.y<qc&&e.y>Hc&&(e.y=1)}(this.layoutCorrected,this.treeScale,this.path,n),!e.layout||e.target||1===this.treeScale.x&&1===this.treeScale.y||(e.target=e.layout.layoutBox,e.targetWithTransforms=Bc());const{target:c}=e;c?(this.projectionDelta&&this.prevProjectionDelta?(kl(this.prevProjectionDelta.x,this.projectionDelta.x),kl(this.prevProjectionDelta.y,this.projectionDelta.y)):this.createProjectionDeltas(),Tc(this.projectionDelta,this.layoutCorrected,c,this.latestValues),this.treeScale.x===s&&this.treeScale.y===a&&Ml(this.projectionDelta.x,this.prevProjectionDelta.x)&&Ml(this.projectionDelta.y,this.prevProjectionDelta.y)||(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",c)),Hl&&zl.recalculatedProjection++):this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender())}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(t=!0){var e;if(null===(e=this.options.visualElement)||void 0===e||e.scheduleRender(),t){const t=this.getStack();t&&t.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=Nc(),this.projectionDelta=Nc(),this.projectionDeltaWithTransform=Nc()}setAnimationOrigin(t,e=!1){const n=this.snapshot,r=n?n.latestValues:{},o={...this.latestValues},i=Nc();this.relativeParent&&this.relativeParent.options.layoutRoot||(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!e;const s=Bc(),a=(n?n.source:void 0)!==(this.layout?this.layout.source:void 0),c=this.getStack(),l=!c||c.members.length<=1,u=Boolean(a&&!l&&!0===this.options.crossfade&&!this.path.some(pu));let h;this.animationProgress=0,this.mixTargetDelta=e=>{const n=e/1e3;du(i.x,t.x,n),du(i.y,t.y,n),this.setTargetDelta(i),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(kc(s,this.layout.layoutBox,this.relativeParent.layout.layoutBox),function(t,e,n,r){fu(t.x,e.x,n.x,r),fu(t.y,e.y,n.y,r)}(this.relativeTarget,this.relativeTargetOrigin,s,n),h&&function(t,e){return Ul(t.x,e.x)&&Ul(t.y,e.y)}(this.relativeTarget,h)&&(this.isProjectionDirty=!1),h||(h=Bc()),_l(h,this.relativeTarget)),a&&(this.animationValues=o,function(t,e,n,r,o,i){o?(t.opacity=Bs(0,void 0!==n.opacity?n.opacity:1,Sl(r)),t.opacityExit=Bs(void 0!==e.opacity?e.opacity:1,0,xl(r))):i&&(t.opacity=Bs(void 0!==e.opacity?e.opacity:1,void 0!==n.opacity?n.opacity:1,r));for(let o=0;o<wl;o++){const i=`border${yl[o]}Radius`;let s=El(e,i),a=El(n,i);void 0===s&&void 0===a||(s||(s=0),a||(a=0),0===s||0===a||bl(s)===bl(a)?(t[i]=Math.max(Bs(vl(s),vl(a),r),0),(ti.test(a)||ti.test(s))&&(t[i]+="%")):t[i]=a)}(e.rotate||n.rotate)&&(t.rotate=Bs(e.rotate||0,n.rotate||0,r))}(o,r,this.latestValues,n,u,l)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=n},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(t){this.notifyListeners("animationStart"),this.currentAnimation&&this.currentAnimation.stop(),this.resumingFrom&&this.resumingFrom.currentAnimation&&this.resumingFrom.currentAnimation.stop(),this.pendingAnimation&&(Eo(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=bo.update((()=>{al.hasAnimatedSinceResize=!0,this.currentAnimation=function(t,e,n){const r=Pa(t)?t:Aa(t);return r.start(ya("",r,e,n)),r.animation}(0,1e3,{...t,onUpdate:e=>{this.mixTargetDelta(e),t.onUpdate&&t.onUpdate(e)},onComplete:()=>{t.onComplete&&t.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0}))}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);const t=this.getStack();t&&t.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(1e3),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const t=this.getLead();let{targetWithTransforms:e,target:n,layout:r,latestValues:o}=t;if(e&&n&&r){if(this!==t&&this.layout&&r&&vu(this.options.animationType,this.layout.layoutBox,r.layoutBox)){n=this.target||Bc();const e=Sc(this.layout.layoutBox.x);n.x.min=t.target.x.min,n.x.max=n.x.min+e;const r=Sc(this.layout.layoutBox.y);n.y.min=t.target.y.min,n.y.max=n.y.min+r}_l(e,n),Gc(e,o),Tc(this.projectionDeltaWithTransform,this.layoutCorrected,e,o)}}registerSharedNode(t,e){this.sharedNodes.has(t)||this.sharedNodes.set(t,new Vl);this.sharedNodes.get(t).add(e);const n=e.options.initialPromotionConfig;e.promote({transition:n?n.transition:void 0,preserveFollowOpacity:n&&n.shouldPreserveFollowOpacity?n.shouldPreserveFollowOpacity(e):void 0})}isLead(){const t=this.getStack();return!t||t.lead===this}getLead(){var t;const{layoutId:e}=this.options;return e&&(null===(t=this.getStack())||void 0===t?void 0:t.lead)||this}getPrevLead(){var t;const{layoutId:e}=this.options;return e?null===(t=this.getStack())||void 0===t?void 0:t.prevLead:void 0}getStack(){const{layoutId:t}=this.options;if(t)return this.root.sharedNodes.get(t)}promote({needsReset:t,transition:e,preserveFollowOpacity:n}={}){const r=this.getStack();r&&r.promote(this,n),t&&(this.projectionDelta=void 0,this.needsReset=!0),e&&this.setOptions({transition:e})}relegate(){const t=this.getStack();return!!t&&t.relegate(this)}resetSkewAndRotation(){const{visualElement:t}=this.options;if(!t)return;let e=!1;const{latestValues:n}=t;if((n.z||n.rotate||n.rotateX||n.rotateY||n.rotateZ||n.skewX||n.skewY)&&(e=!0),!e)return;const r={};n.z&&Gl("z",t,r,this.animationValues);for(let e=0;e<ql.length;e++)Gl(`rotate${ql[e]}`,t,r,this.animationValues),Gl(`skew${ql[e]}`,t,r,this.animationValues);t.render();for(const e in r)t.setStaticValue(e,r[e]),this.animationValues&&(this.animationValues[e]=r[e]);t.scheduleRender()}getProjectionStyles(t){var e,n;if(!this.instance||this.isSVG)return;if(!this.isVisible)return Zl;const r={visibility:""},o=this.getTransformTemplate();if(this.needsReset)return this.needsReset=!1,r.opacity="",r.pointerEvents=$l(null==t?void 0:t.pointerEvents)||"",r.transform=o?o(this.latestValues,""):"none",r;const i=this.getLead();if(!this.projectionDelta||!this.layout||!i.target){const e={};return this.options.layoutId&&(e.opacity=void 0!==this.latestValues.opacity?this.latestValues.opacity:1,e.pointerEvents=$l(null==t?void 0:t.pointerEvents)||""),this.hasProjected&&!Mc(this.latestValues)&&(e.transform=o?o({},""):"none",this.hasProjected=!1),e}const s=i.animationValues||i.latestValues;this.applyTransformsToTarget(),r.transform=function(t,e,n){let r="";const o=t.x.translate/e.x,i=t.y.translate/e.y,s=(null==n?void 0:n.z)||0;if((o||i||s)&&(r=`translate3d(${o}px, ${i}px, ${s}px) `),1===e.x&&1===e.y||(r+=`scale(${1/e.x}, ${1/e.y}) `),n){const{transformPerspective:t,rotate:e,rotateX:o,rotateY:i,skewX:s,skewY:a}=n;t&&(r=`perspective(${t}px) ${r}`),e&&(r+=`rotate(${e}deg) `),o&&(r+=`rotateX(${o}deg) `),i&&(r+=`rotateY(${i}deg) `),s&&(r+=`skewX(${s}deg) `),a&&(r+=`skewY(${a}deg) `)}const a=t.x.scale*e.x,c=t.y.scale*e.y;return 1===a&&1===c||(r+=`scale(${a}, ${c})`),r||"none"}(this.projectionDeltaWithTransform,this.treeScale,s),o&&(r.transform=o(s,r.transform));const{x:a,y:c}=this.projectionDelta;r.transformOrigin=`${100*a.origin}% ${100*c.origin}% 0`,i.animationValues?r.opacity=i===this?null!==(n=null!==(e=s.opacity)&&void 0!==e?e:this.latestValues.opacity)&&void 0!==n?n:1:this.preserveOpacity?this.latestValues.opacity:s.opacityExit:r.opacity=i===this?void 0!==s.opacity?s.opacity:"":void 0!==s.opacityExit?s.opacityExit:0;for(const t in hl){if(void 0===s[t])continue;const{correct:e,applyTo:n}=hl[t],o="none"===r.transform?s[t]:e(s[t],i);if(n){const t=n.length;for(let e=0;e<t;e++)r[n[e]]=o}else r[t]=o}return this.options.layoutId&&(r.pointerEvents=i===this?$l(null==t?void 0:t.pointerEvents)||"":"none"),r}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach((t=>{var e;return null===(e=t.currentAnimation)||void 0===e?void 0:e.stop()})),this.root.nodes.forEach(ou),this.root.sharedNodes.clear()}}}function Ql(t){t.updateLayout()}function tu(t){var e;const n=(null===(e=t.resumeFrom)||void 0===e?void 0:e.snapshot)||t.snapshot;if(t.isLead()&&t.layout&&n&&t.hasListeners("didUpdate")){const{layoutBox:e,measuredBox:r}=t.layout,{animationType:o}=t.options,i=n.source!==t.layout.source;"size"===o?Uc((t=>{const r=i?n.measuredBox[t]:n.layoutBox[t],o=Sc(r);r.min=e[t].min,r.max=r.min+o})):vu(o,n.layoutBox,e)&&Uc((r=>{const o=i?n.measuredBox[r]:n.layoutBox[r],s=Sc(e[r]);o.max=o.min+s,t.relativeTarget&&!t.currentAnimation&&(t.isProjectionDirty=!0,t.relativeTarget[r].max=t.relativeTarget[r].min+s)}));const s=Nc();Tc(s,e,n.layoutBox);const a=Nc();i?Tc(a,t.applyTransform(r,!0),n.measuredBox):Tc(a,e,n.layoutBox);const c=!Bl(s);let l=!1;if(!t.resumeFrom){const r=t.getClosestProjectingParent();if(r&&!r.resumeFrom){const{snapshot:o,layout:i}=r;if(o&&i){const s=Bc();kc(s,n.layoutBox,o.layoutBox);const a=Bc();kc(a,e,i.layoutBox),jl(s,a)||(l=!0),r.options.layoutRoot&&(t.relativeTarget=a,t.relativeTargetOrigin=s,t.relativeParent=r)}}}t.notifyListeners("didUpdate",{layout:e,snapshot:n,delta:a,layoutDelta:s,hasLayoutChanged:c,hasRelativeTargetChanged:l})}else if(t.isLead()){const{onExitComplete:e}=t.options;e&&e()}t.options.transition=void 0}function eu(t){Hl&&zl.totalNodes++,t.parent&&(t.isProjecting()||(t.isProjectionDirty=t.parent.isProjectionDirty),t.isSharedProjectionDirty||(t.isSharedProjectionDirty=Boolean(t.isProjectionDirty||t.parent.isProjectionDirty||t.parent.isSharedProjectionDirty)),t.isTransformDirty||(t.isTransformDirty=t.parent.isTransformDirty))}function nu(t){t.isProjectionDirty=t.isSharedProjectionDirty=t.isTransformDirty=!1}function ru(t){t.clearSnapshot()}function ou(t){t.clearMeasurements()}function iu(t){t.isLayoutDirty=!1}function su(t){const{visualElement:e}=t.options;e&&e.getProps().onBeforeLayoutMeasure&&e.notify("BeforeLayoutMeasure"),t.resetTransform()}function au(t){t.finishAnimation(),t.targetDelta=t.relativeTarget=t.target=void 0,t.isProjectionDirty=!0}function cu(t){t.resolveTargetDelta()}function lu(t){t.calcProjection()}function uu(t){t.resetSkewAndRotation()}function hu(t){t.removeLeadSnapshot()}function du(t,e,n){t.translate=Bs(e.translate,0,n),t.scale=Bs(e.scale,1,n),t.origin=e.origin,t.originPoint=e.originPoint}function fu(t,e,n,r){t.min=Bs(e.min,n.min,r),t.max=Bs(e.max,n.max,r)}function pu(t){return t.animationValues&&void 0!==t.animationValues.opacityExit}const mu={duration:.45,ease:[.4,0,.1,1]},gu=t=>"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(t),yu=gu("applewebkit/")&&!gu("chrome/")?Math.round:yo;function wu(t){t.min=yu(t.min),t.max=yu(t.max)}function vu(t,e,n){return"position"===t||"preserve-aspect"===t&&(r=Dl(e),o=Dl(n),i=.2,!(Math.abs(r-o)<=i));var r,o,i}function bu(t){var e;return t!==t.root&&(null===(e=t.scroll)||void 0===e?void 0:e.wasRoot)}const Eu=Jl({attachResizeListener:(t,e)=>ac(t,"resize",e),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body.scrollLeft,y:document.documentElement.scrollTop||document.body.scrollTop}),checkIsScrollRoot:()=>!0}),Su={current:void 0},xu=Jl({measureScroll:t=>({x:t.scrollLeft,y:t.scrollTop}),defaultParent:()=>{if(!Su.current){const t=new Eu({});t.mount(window),t.setOptions({layoutScroll:!0}),Su.current=t}return Su.current},resetTransform:(t,e)=>{t.style.transform=void 0!==e?e:"none"},checkIsScrollRoot:t=>Boolean("fixed"===window.getComputedStyle(t).position)}),Tu={pan:{Feature:class extends za{constructor(){super(...arguments),this.removePointerDownListener=yo}onPointerDown(t){this.session=new uc(t,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:Jc(this.node)})}createPanHandlers(){const{onPanSessionStart:t,onPanStart:e,onPan:n,onPanEnd:r}=this.node.getProps();return{onSessionStart:nl(t),onStart:nl(e),onMove:n,onEnd:(t,e)=>{delete this.session,r&&bo.postRender((()=>r(t,e)))}}}mount(){this.removePointerDownListener=cc(this.node.current,"pointerdown",(t=>this.onPointerDown(t)))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}},drag:{Feature:class extends za{constructor(t){super(t),this.removeGroupControls=yo,this.removeListeners=yo,this.controls=new tl(t)}mount(){const{dragControls:t}=this.node.getProps();t&&(this.removeGroupControls=t.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||yo}unmount(){this.removeGroupControls(),this.removeListeners()}},ProjectionNode:xu,MeasureLayout:ml}};function Au(t,e,n){const{props:r}=t;t.animationState&&r.whileHover&&t.animationState.setActive("whileHover","Start"===n);const o=r["onHover"+n];o&&bo.postRender((()=>o(e,sc(e))))}function _u(t,e,n){const{props:r}=t;t.animationState&&r.whileTap&&t.animationState.setActive("whileTap","Start"===n);const o=r["onTap"+("End"===n?"":n)];o&&bo.postRender((()=>o(e,sc(e))))}const ku=new WeakMap,Ru=new WeakMap,Cu=t=>{const e=ku.get(t.target);e&&e(t)},Pu=t=>{t.forEach(Cu)};function Iu(t,e,n){const r=function({root:t,...e}){const n=t||document;Ru.has(n)||Ru.set(n,{});const r=Ru.get(n),o=JSON.stringify(e);return r[o]||(r[o]=new IntersectionObserver(Pu,{root:t,...e})),r[o]}(e);return ku.set(t,n),r.observe(t),()=>{ku.delete(t),r.unobserve(t)}}const Ou={some:0,all:1};const Nu={inView:{Feature:class extends za{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();const{viewport:t={}}=this.node.getProps(),{root:e,margin:n,amount:r="some",once:o}=t,i={root:e?e.current:void 0,rootMargin:n,threshold:"number"==typeof r?r:Ou[r]};return Iu(this.node.current,i,(t=>{const{isIntersecting:e}=t;if(this.isInView===e)return;if(this.isInView=e,o&&!e&&this.hasEnteredView)return;e&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",e);const{onViewportEnter:n,onViewportLeave:r}=this.node.getProps(),i=e?n:r;i&&i(t)}))}mount(){this.startObserver()}update(){if("undefined"==typeof IntersectionObserver)return;const{props:t,prevProps:e}=this.node;["amount","margin","root"].some(function({viewport:t={}},{viewport:e={}}={}){return n=>t[n]!==e[n]}(t,e))&&this.startObserver()}unmount(){}}},tap:{Feature:class extends za{mount(){const{current:t}=this.node;t&&(this.unmount=ic(t,(t=>(_u(this.node,t,"Start"),(t,{success:e})=>_u(this.node,t,e?"End":"Cancel"))),{useGlobalTarget:this.node.props.globalTapTarget}))}unmount(){}}},focus:{Feature:class extends za{constructor(){super(...arguments),this.isActive=!1}onFocus(){let t=!1;try{t=this.node.current.matches(":focus-visible")}catch(e){t=!0}t&&this.node.animationState&&(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){this.isActive&&this.node.animationState&&(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=Ns(ac(this.node.current,"focus",(()=>this.onFocus())),ac(this.node.current,"blur",(()=>this.onBlur())))}unmount(){}}},hover:{Feature:class extends za{mount(){const{current:t}=this.node;t&&(this.unmount=function(t,e,n={}){const[r,o,i]=Ga(t,n),s=Ya((t=>{const{target:n}=t,r=e(t);if(!r||!n)return;const i=Ya((t=>{r(t),n.removeEventListener("pointerleave",i)}));n.addEventListener("pointerleave",i,o)}));return r.forEach((t=>{t.addEventListener("pointerenter",s,o)})),i}(t,(t=>(Au(this.node,t,"Start"),t=>Au(this.node,t,"End")))))}unmount(){}}}},Bu={layout:{ProjectionNode:xu,MeasureLayout:ml}},Uu=(0,e.createContext)({transformPagePoint:t=>t,isStatic:!1,reducedMotion:"never"}),Lu=(0,e.createContext)({}),ju="undefined"!=typeof window,Du=ju?e.useLayoutEffect:e.useEffect,Mu=(0,e.createContext)({strict:!1});function Vu(t,n,r,o,i){var s,a;const{visualElement:c}=(0,e.useContext)(Lu),l=(0,e.useContext)(Mu),u=(0,e.useContext)(ol),h=(0,e.useContext)(Uu).reducedMotion,d=(0,e.useRef)(null);o=o||l.renderer,!d.current&&o&&(d.current=o(t,{visualState:n,parent:c,props:r,presenceContext:u,blockInitialAnimation:!!u&&!1===u.initial,reducedMotionConfig:h}));const f=d.current,p=(0,e.useContext)(sl);!f||f.projection||!i||"html"!==f.type&&"svg"!==f.type||function(t,e,n,r){const{layoutId:o,layout:i,drag:s,dragConstraints:a,layoutScroll:c,layoutRoot:l}=e;t.projection=new n(t.latestValues,e["data-framer-portal-id"]?void 0:Fu(t.parent)),t.projection.setOptions({layoutId:o,layout:i,alwaysMeasureLayout:Boolean(s)||a&&yc(a),visualElement:t,animationType:"string"==typeof i?i:"both",initialPromotionConfig:r,layoutScroll:c,layoutRoot:l})}(d.current,r,i,p);const m=(0,e.useRef)(!1);(0,e.useInsertionEffect)((()=>{f&&m.current&&f.update(r,u)}));const g=r[Ra],y=(0,e.useRef)(Boolean(g)&&!(null===(s=window.MotionHandoffIsComplete)||void 0===s?void 0:s.call(window,g))&&(null===(a=window.MotionHasOptimisedAnimation)||void 0===a?void 0:a.call(window,g)));return Du((()=>{f&&(m.current=!0,window.MotionIsMounted=!0,f.updateFeatures(),dl.render(f.render),y.current&&f.animationState&&f.animationState.animateChanges())})),(0,e.useEffect)((()=>{f&&(!y.current&&f.animationState&&f.animationState.animateChanges(),y.current&&(queueMicrotask((()=>{var t;null===(t=window.MotionHandoffMarkAsComplete)||void 0===t||t.call(window,g)})),y.current=!1))})),f}function Fu(t){if(t)return!1!==t.options.allowProjection?t.projection:Fu(t.parent)}function Ku(t,n,r){return(0,e.useCallback)((e=>{e&&t.mount&&t.mount(e),n&&(e?n.mount(e):n.unmount()),r&&("function"==typeof r?r(e):yc(r)&&(r.current=e))}),[n])}function $u(t){return qr(t.animate)||eo.some((e=>Gr(t[e])))}function Wu(t){return Boolean($u(t)||t.variants)}function zu(t){const{initial:n,animate:r}=function(t,e){if($u(t)){const{initial:e,animate:n}=t;return{initial:!1===e||Gr(e)?e:void 0,animate:Gr(n)?n:void 0}}return!1!==t.inherit?e:{}}(t,(0,e.useContext)(Lu));return(0,e.useMemo)((()=>({initial:n,animate:r})),[Hu(n),Hu(r)])}function Hu(t){return Array.isArray(t)?t.join(" "):t}const qu={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]},Zu={};for(const t in qu)Zu[t]={isEnabled:e=>qu[t].some((t=>!!e[t]))};const Xu=Symbol.for("motionComponentSymbol");function Gu({preloadedFeatures:t,createVisualElement:n,useRender:r,useVisualState:o,Component:i}){t&&function(t){for(const e in t)Zu[e]={...Zu[e],...t[e]}}(t);const s=(0,e.forwardRef)((function(t,s){let a;const c={...(0,e.useContext)(Uu),...t,layoutId:Yu(t)},{isStatic:l}=c,u=zu(t),h=o(t,l);if(!l&&ju){!function(t,n){(0,e.useContext)(Mu).strict;0}();const t=function(t){const{drag:e,layout:n}=Zu;if(!e&&!n)return{};const r={...e,...n};return{MeasureLayout:(null==e?void 0:e.isEnabled(t))||(null==n?void 0:n.isEnabled(t))?r.MeasureLayout:void 0,ProjectionNode:r.ProjectionNode}}(c);a=t.MeasureLayout,u.visualElement=Vu(i,h,c,n,t.ProjectionNode)}return(0,rl.jsxs)(Lu.Provider,{value:u,children:[a&&u.visualElement?(0,rl.jsx)(a,{visualElement:u.visualElement,...c}):null,r(i,t,Ku(h,u.visualElement,s),h,l,u.visualElement)]})}));return s[Xu]=i,s}function Yu({layoutId:t}){const n=(0,e.useContext)(il).id;return n&&void 0!==t?n+"-"+t:t}const Ju=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function Qu(t){return"string"==typeof t&&!t.includes("-")&&!!(Ju.indexOf(t)>-1||/[A-Z]/u.test(t))}function th(t,{style:e,vars:n},r,o){Object.assign(t.style,e,o&&o.getProjectionStyles(r));for(const e in n)t.style.setProperty(e,n[e])}const eh=new Set(["baseFrequency","diffuseConstant","kernelMatrix","kernelUnitLength","keySplines","keyTimes","limitingConeAngle","markerHeight","markerWidth","numOctaves","targetX","targetY","surfaceScale","specularConstant","specularExponent","stdDeviation","tableValues","viewBox","gradientTransform","pathLength","startOffset","textLength","lengthAdjust"]);function nh(t,e,n,r){th(t,e,void 0,r);for(const n in e.attrs)t.setAttribute(eh.has(n)?n:ka(n),e.attrs[n])}function rh(t,{layout:e,layoutId:n}){return ro.has(t)||t.startsWith("origin")||(e||void 0!==n)&&(!!hl[t]||"opacity"===t)}function oh(t,e,n){var r;const{style:o}=t,i={};for(const s in o)(Pa(o[s])||e.style&&Pa(e.style[s])||rh(s,t)||void 0!==(null===(r=null==n?void 0:n.getValue(s))||void 0===r?void 0:r.liveStyle))&&(i[s]=o[s]);return i}function ih(t,e,n){const r=oh(t,e,n);for(const n in t)if(Pa(t[n])||Pa(e[n])){r[-1!==no.indexOf(n)?"attr"+n.charAt(0).toUpperCase()+n.substring(1):n]=t[n]}return r}function sh(t){const n=(0,e.useRef)(null);return null===n.current&&(n.current=t()),n.current}const ah=t=>(n,r)=>{const o=(0,e.useContext)(Lu),i=(0,e.useContext)(ol),s=()=>function({scrapeMotionValuesFromProps:t,createRenderState:e,onMount:n},r,o,i){const s={latestValues:ch(r,o,i,t),renderState:e()};return n&&(s.mount=t=>n(r,t,s)),s}(t,n,o,i);return r?s():sh(s)};function ch(t,e,n,r){const o={},i=r(t,{});for(const t in i)o[t]=$l(i[t]);let{initial:s,animate:a}=t;const c=$u(t),l=Wu(t);e&&l&&!c&&!1!==t.inherit&&(void 0===s&&(s=e.initial),void 0===a&&(a=e.animate));let u=!!n&&!1===n.initial;u=u||!1===s;const h=u?a:s;if(h&&"boolean"!=typeof h&&!qr(h)){const e=Array.isArray(h)?h:[h];for(let n=0;n<e.length;n++){const r=Jr(t,e[n]);if(r){const{transitionEnd:t,transition:e,...n}=r;for(const t in n){let e=n[t];if(Array.isArray(e)){e=e[u?e.length-1:0]}null!==e&&(o[t]=e)}for(const e in t)o[e]=t[e]}}}return o}const lh=()=>({style:{},transform:{},transformOrigin:{},vars:{}}),uh=()=>({...lh(),attrs:{}}),hh=(t,e)=>e&&"number"==typeof t?e.transform(t):t,dh={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},fh=no.length;function ph(t,e,n){const{style:r,vars:o,transformOrigin:i}=t;let s=!1,a=!1;for(const t in e){const n=e[t];if(ro.has(t))s=!0;else if(Ko(t))o[t]=n;else{const e=hh(n,Gi[t]);t.startsWith("origin")?(a=!0,i[t]=e):r[t]=e}}if(e.transform||(s||n?r.transform=function(t,e,n){let r="",o=!0;for(let i=0;i<fh;i++){const s=no[i],a=t[s];if(void 0===a)continue;let c=!0;if(c="number"==typeof a?a===(s.startsWith("scale")?1:0):0===parseFloat(a),!c||n){const t=hh(a,Gi[s]);c||(o=!1,r+=`${dh[s]||s}(${t}) `),n&&(e[s]=t)}}return r=r.trim(),n?r=n(e,o?"":r):o&&(r="none"),r}(e,t.transform,n):r.transform&&(r.transform="none")),a){const{originX:t="50%",originY:e="50%",originZ:n=0}=i;r.transformOrigin=`${t} ${e} ${n}`}}function mh(t,e,n){return"string"==typeof t?t:ei.transform(e+n*t)}const gh={offset:"stroke-dashoffset",array:"stroke-dasharray"},yh={offset:"strokeDashoffset",array:"strokeDasharray"};function wh(t,{attrX:e,attrY:n,attrScale:r,originX:o,originY:i,pathLength:s,pathSpacing:a=1,pathOffset:c=0,...l},u,h){if(ph(t,l,h),u)return void(t.style.viewBox&&(t.attrs.viewBox=t.style.viewBox));t.attrs=t.style,t.style={};const{attrs:d,style:f,dimensions:p}=t;d.transform&&(p&&(f.transform=d.transform),delete d.transform),p&&(void 0!==o||void 0!==i||f.transform)&&(f.transformOrigin=function(t,e,n){return`${mh(e,t.x,t.width)} ${mh(n,t.y,t.height)}`}(p,void 0!==o?o:.5,void 0!==i?i:.5)),void 0!==e&&(d.x=e),void 0!==n&&(d.y=n),void 0!==r&&(d.scale=r),void 0!==s&&function(t,e,n=1,r=0,o=!0){t.pathLength=1;const i=o?gh:yh;t[i.offset]=ei.transform(-r);const s=ei.transform(e),a=ei.transform(n);t[i.array]=`${s} ${a}`}(d,s,a,c,!1)}const vh=t=>"string"==typeof t&&"svg"===t.toLowerCase(),bh={useVisualState:ah({scrapeMotionValuesFromProps:ih,createRenderState:uh,onMount:(t,e,{renderState:n,latestValues:r})=>{bo.read((()=>{try{n.dimensions="function"==typeof e.getBBox?e.getBBox():e.getBoundingClientRect()}catch(t){n.dimensions={x:0,y:0,width:0,height:0}}})),bo.render((()=>{wh(n,r,vh(e.tagName),t.transformTemplate),nh(e,n)}))}})},Eh={useVisualState:ah({scrapeMotionValuesFromProps:oh,createRenderState:lh})};function Sh(t,e,n){for(const r in e)Pa(e[r])||rh(r,n)||(t[r]=e[r])}function xh(t,n){const r={};return Sh(r,t.style||{},t),Object.assign(r,function({transformTemplate:t},n){return(0,e.useMemo)((()=>{const e=lh();return ph(e,n,t),Object.assign({},e.vars,e.style)}),[n])}(t,n)),r}function Th(t,e){const n={},r=xh(t,e);return t.drag&&!1!==t.dragListener&&(n.draggable=!1,r.userSelect=r.WebkitUserSelect=r.WebkitTouchCallout="none",r.touchAction=!0===t.drag?"none":"pan-"+("x"===t.drag?"y":"x")),void 0===t.tabIndex&&(t.onTap||t.onTapStart||t.whileTap)&&(n.tabIndex=0),n.style=r,n}const Ah=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","ignoreStrict","viewport"]);function _h(t){return t.startsWith("while")||t.startsWith("drag")&&"draggable"!==t||t.startsWith("layout")||t.startsWith("onTap")||t.startsWith("onPan")||t.startsWith("onLayout")||Ah.has(t)}let kh=t=>!_h(t);try{(Rh=require("@emotion/is-prop-valid").default)&&(kh=t=>t.startsWith("on")?!_h(t):Rh(t))}catch(bm){}var Rh;function Ch(t,n,r,o){const i=(0,e.useMemo)((()=>{const e=uh();return wh(e,n,vh(o),t.transformTemplate),{...e.attrs,style:{...e.style}}}),[n]);if(t.style){const e={};Sh(e,t.style,t),i.style={...e,...i.style}}return i}function Ph(t=!1){return(n,r,o,{latestValues:i},s)=>{const a=(Qu(n)?Ch:Th)(r,i,s,n),c=function(t,e,n){const r={};for(const o in t)"values"===o&&"object"==typeof t.values||(kh(o)||!0===n&&_h(o)||!e&&!_h(o)||t.draggable&&o.startsWith("onDrag"))&&(r[o]=t[o]);return r}(r,"string"==typeof n,t),l=n!==e.Fragment?{...c,...a,ref:o}:{},{children:u}=r,h=(0,e.useMemo)((()=>Pa(u)?u.get():u),[u]);return(0,e.createElement)(n,{...l,children:h})}}function Ih(t,e){return function(n,{forwardMotionProps:r}={forwardMotionProps:!1}){return Gu({...Qu(n)?bh:Eh,preloadedFeatures:t,useRender:Ph(r),createVisualElement:e,Component:n})}}const Oh={current:null},Nh={current:!1};const Bh=new WeakMap,Uh=[...fi,Pi,Ki],Lh=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];class jh{scrapeMotionValuesFromProps(t,e,n){return{}}constructor({parent:t,props:e,presenceContext:n,reducedMotionConfig:r,blockInitialAnimation:o,visualState:i},s={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.values=new Map,this.KeyframeResolver=bi,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify("Update",this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{const t=is.now();this.renderScheduledAt<t&&(this.renderScheduledAt=t,bo.render(this.render,!1,!0))};const{latestValues:a,renderState:c}=i;this.latestValues=a,this.baseTarget={...a},this.initialValues=e.initial?{...a}:{},this.renderState=c,this.parent=t,this.props=e,this.presenceContext=n,this.depth=t?t.depth+1:0,this.reducedMotionConfig=r,this.options=s,this.blockInitialAnimation=Boolean(o),this.isControllingVariants=$u(e),this.isVariantNode=Wu(e),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=Boolean(t&&t.current);const{willChange:l,...u}=this.scrapeMotionValuesFromProps(e,{},this);for(const t in u){const e=u[t];void 0!==a[t]&&Pa(e)&&e.set(a[t],!1)}}mount(t){this.current=t,Bh.set(t,this),this.projection&&!this.projection.instance&&this.projection.mount(t),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach(((t,e)=>this.bindToMotionValue(e,t))),Nh.current||function(){if(Nh.current=!0,ju)if(window.matchMedia){const t=window.matchMedia("(prefers-reduced-motion)"),e=()=>Oh.current=t.matches;t.addListener(e),e()}else Oh.current=!1}(),this.shouldReduceMotion="never"!==this.reducedMotionConfig&&("always"===this.reducedMotionConfig||Oh.current),this.parent&&this.parent.children.add(this),this.update(this.props,this.presenceContext)}unmount(){Bh.delete(this.current),this.projection&&this.projection.unmount(),Eo(this.notifyUpdate),Eo(this.render),this.valueSubscriptions.forEach((t=>t())),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent&&this.parent.children.delete(this);for(const t in this.events)this.events[t].clear();for(const t in this.features){const e=this.features[t];e&&(e.unmount(),e.isMounted=!1)}this.current=null}bindToMotionValue(t,e){this.valueSubscriptions.has(t)&&this.valueSubscriptions.get(t)();const n=ro.has(t),r=e.on("change",(e=>{this.latestValues[t]=e,this.props.onUpdate&&bo.preRender(this.notifyUpdate),n&&this.projection&&(this.projection.isTransformDirty=!0)})),o=e.on("renderRequest",this.scheduleRender);let i;window.MotionCheckAppearSync&&(i=window.MotionCheckAppearSync(this,t,e)),this.valueSubscriptions.set(t,(()=>{r(),o(),i&&i(),e.owner&&e.stop()}))}sortNodePosition(t){return this.current&&this.sortInstanceNodePosition&&this.type===t.type?this.sortInstanceNodePosition(this.current,t.current):0}updateFeatures(){let t="animation";for(t in Zu){const e=Zu[t];if(!e)continue;const{isEnabled:n,Feature:r}=e;if(!this.features[t]&&r&&n(this.props)&&(this.features[t]=new r(this)),this.features[t]){const e=this.features[t];e.isMounted?e.update():(e.mount(),e.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):Bc()}getStaticValue(t){return this.latestValues[t]}setStaticValue(t,e){this.latestValues[t]=e}update(t,e){(t.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=t,this.prevPresenceContext=this.presenceContext,this.presenceContext=e;for(let e=0;e<Lh.length;e++){const n=Lh[e];this.propEventSubscriptions[n]&&(this.propEventSubscriptions[n](),delete this.propEventSubscriptions[n]);const r=t["on"+n];r&&(this.propEventSubscriptions[n]=this.on(n,r))}this.prevMotionValues=function(t,e,n){for(const r in e){const o=e[r],i=n[r];if(Pa(o))t.addValue(r,o);else if(Pa(i))t.addValue(r,Aa(o,{owner:t}));else if(i!==o)if(t.hasValue(r)){const e=t.getValue(r);!0===e.liveStyle?e.jump(o):e.hasAnimated||e.set(o)}else{const e=t.getStaticValue(r);t.addValue(r,Aa(void 0!==e?e:o,{owner:t}))}}for(const r in n)void 0===e[r]&&t.removeValue(r);return e}(this,this.scrapeMotionValuesFromProps(t,this.prevProps,this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue()}getProps(){return this.props}getVariant(t){return this.props.variants?this.props.variants[t]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}getClosestVariantNode(){return this.isVariantNode?this:this.parent?this.parent.getClosestVariantNode():void 0}addVariantChild(t){const e=this.getClosestVariantNode();if(e)return e.variantChildren&&e.variantChildren.add(t),()=>e.variantChildren.delete(t)}addValue(t,e){const n=this.values.get(t);e!==n&&(n&&this.removeValue(t),this.bindToMotionValue(t,e),this.values.set(t,e),this.latestValues[t]=e.get())}removeValue(t){this.values.delete(t);const e=this.valueSubscriptions.get(t);e&&(e(),this.valueSubscriptions.delete(t)),delete this.latestValues[t],this.removeValueFromRenderState(t,this.renderState)}hasValue(t){return this.values.has(t)}getValue(t,e){if(this.props.values&&this.props.values[t])return this.props.values[t];let n=this.values.get(t);return void 0===n&&void 0!==e&&(n=Aa(null===e?void 0:e,{owner:this}),this.addValue(t,n)),n}readValue(t,e){var n;let r=void 0===this.latestValues[t]&&this.current?null!==(n=this.getBaseTargetFromProps(this.props,t))&&void 0!==n?n:this.readValueFromInstance(this.current,t,this.options):this.latestValues[t];return null!=r&&("string"==typeof r&&(Vo(r)||jo(r))?r=parseFloat(r):!(t=>Uh.find(di(t)))(r)&&Ki.test(e)&&(r=Qi(t,e)),this.setBaseTarget(t,Pa(r)?r.get():r)),Pa(r)?r.get():r}setBaseTarget(t,e){this.baseTarget[t]=e}getBaseTarget(t){var e;const{initial:n}=this.props;let r;if("string"==typeof n||"object"==typeof n){const o=Jr(this.props,n,null===(e=this.presenceContext)||void 0===e?void 0:e.custom);o&&(r=o[t])}if(n&&void 0!==r)return r;const o=this.getBaseTargetFromProps(this.props,t);return void 0===o||Pa(o)?void 0!==this.initialValues[t]&&void 0===r?void 0:this.baseTarget[t]:o}on(t,e){return this.events[t]||(this.events[t]=new Sa),this.events[t].add(e)}notify(t,...e){this.events[t]&&this.events[t].notify(...e)}}class Dh extends jh{constructor(){super(...arguments),this.KeyframeResolver=es}sortInstanceNodePosition(t,e){return 2&t.compareDocumentPosition(e)?1:-1}getBaseTargetFromProps(t,e){return t.style?t.style[e]:void 0}removeValueFromRenderState(t,{vars:e,style:n}){delete e[t],delete n[t]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:t}=this.props;Pa(t)&&(this.childSubscription=t.on("change",(t=>{this.current&&(this.current.textContent=`${t}`)})))}}class Mh extends Dh{constructor(){super(...arguments),this.type="html",this.renderInstance=th}readValueFromInstance(t,e){if(ro.has(e)){const t=Ji(e);return t&&t.default||0}{const r=(n=t,window.getComputedStyle(n)),o=(Ko(e)?r.getPropertyValue(e):r[e])||0;return"string"==typeof o?o.trim():o}var n}measureInstanceViewportBox(t,{transformPagePoint:e}){return Yc(t,e)}build(t,e,n){ph(t,e,n.transformTemplate)}scrapeMotionValuesFromProps(t,e,n){return oh(t,e,n)}}class Vh extends Dh{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=Bc}getBaseTargetFromProps(t,e){return t[e]}readValueFromInstance(t,e){if(ro.has(e)){const t=Ji(e);return t&&t.default||0}return e=eh.has(e)?e:ka(e),t.getAttribute(e)}scrapeMotionValuesFromProps(t,e,n){return ih(t,e,n)}build(t,e,n){wh(t,e,this.isSVGTag,n.transformTemplate)}renderInstance(t,e,n,r){nh(t,e,0,r)}mount(t){this.isSVGTag=vh(t.tagName),super.mount(t)}}const Fh=Hr(Ih({...qa,...Nu,...Tu,...Bu},((t,n)=>Qu(t)?new Vh(n):new Mh(n,{allowProjection:t!==e.Fragment}))));function Kh(t){let{onComplete:r}=t;const[o,i]=(0,e.useState)(""),[s,a]=(0,e.useState)(null),[c,l]=(0,e.useState)({length:!1,capital:!1,number:!1,symbol:!1});(0,e.useEffect)((()=>{l({length:o.length>=8,capital:/[A-Z]/.test(o),number:/[0-9]/.test(o),symbol:/[!@#$%^&*(),.?":{}|<>]/.test(o)})}),[o]);const u=Object.values(c).every((t=>t));return n().createElement(Fh.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:"flex flex-col items-center space-y-6 p-6"},n().createElement("h2",{className:"text-xl font-semibold text-gray-900"},"Secure Your Account"),n().createElement("p",{className:"text-gray-600 text-center"},"Choose how you want to secure your data"),s?"pin"===s?n().createElement(Fh.div,{initial:{opacity:0},animate:{opacity:1},className:"w-full max-w-md space-y-4"},n().createElement("input",{type:"password",value:o,onChange:t=>i(t.target.value),placeholder:"Enter your PIN",className:"w-full px-4 py-3 border rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500"}),n().createElement("div",{className:"space-y-2"},Object.entries(c).map((t=>{let[e,r]=t;return n().createElement("div",{key:e,className:"flex items-center"},n().createElement("span",{className:"material-icons text-sm ".concat(r?"text-green-500":"text-gray-400")},r?"check_circle":"radio_button_unchecked"),n().createElement("span",{className:"ml-2 text-sm ".concat(r?"text-green-600":"text-gray-600")},"length"===e?"At least 8 characters":"capital"===e?"One capital letter":"number"===e?"One number":"One special character"))}))),n().createElement("button",{onClick:async()=>{u&&r({method:"pin",value:o})},disabled:!u,className:"w-full py-3 px-4 rounded-lg font-semibold ".concat(u?"bg-blue-500 text-white hover:bg-blue-600":"bg-gray-300 text-gray-500 cursor-not-allowed")},"Set PIN")):n().createElement(Fh.div,{initial:{opacity:0},animate:{opacity:1},className:"w-full max-w-md"},n().createElement("button",{onClick:()=>{r({method:"othent"})},className:"w-full py-3 px-4 rounded-lg font-semibold bg-blue-500 text-white hover:bg-blue-600"},"Continue with Othent")):n().createElement("div",{className:"grid grid-cols-1 gap-4 w-full max-w-md"},n().createElement(Fh.button,{whileHover:{scale:1.02},whileTap:{scale:.98},onClick:()=>a("othent"),className:"flex items-center justify-center p-6 rounded-lg border border-gray-300 hover:border-blue-500 bg-white"},n().createElement("img",{src:"https://onairos.sirv.com/Images/othent-icon.png",alt:"Othent",className:"w-8 h-8 mr-3"}),n().createElement("span",{className:"text-gray-700"},"Secure with Google (Othent)")),n().createElement(Fh.button,{whileHover:{scale:1.02},whileTap:{scale:.98},onClick:()=>a("pin"),className:"flex items-center justify-center p-6 rounded-lg border border-gray-300 hover:border-blue-500 bg-white"},n().createElement("span",{className:"material-icons mr-3"},"lock"),n().createElement("span",{className:"text-gray-700"},"Set up PIN"))))}class $h extends e.Component{getSnapshotBeforeUpdate(t){const e=this.props.childRef.current;if(e&&t.isPresent&&!this.props.isPresent){const t=this.props.sizeRef.current;t.height=e.offsetHeight||0,t.width=e.offsetWidth||0,t.top=e.offsetTop,t.left=e.offsetLeft}return null}componentDidUpdate(){}render(){return this.props.children}}function Wh({children:t,isPresent:n}){const r=(0,e.useId)(),o=(0,e.useRef)(null),i=(0,e.useRef)({width:0,height:0,top:0,left:0}),{nonce:s}=(0,e.useContext)(Uu);return(0,e.useInsertionEffect)((()=>{const{width:t,height:e,top:a,left:c}=i.current;if(n||!o.current||!t||!e)return;o.current.dataset.motionPopId=r;const l=document.createElement("style");return s&&(l.nonce=s),document.head.appendChild(l),l.sheet&&l.sheet.insertRule(`\n [data-motion-pop-id="${r}"] {\n position: absolute !important;\n width: ${t}px !important;\n height: ${e}px !important;\n top: ${a}px !important;\n left: ${c}px !important;\n }\n `),()=>{document.head.removeChild(l)}}),[n]),(0,rl.jsx)($h,{isPresent:n,childRef:o,sizeRef:i,children:e.cloneElement(t,{ref:o})})}const zh=({children:t,initial:n,isPresent:r,onExitComplete:o,custom:i,presenceAffectsLayout:s,mode:a})=>{const c=sh(Hh),l=(0,e.useId)(),u=(0,e.useCallback)((t=>{c.set(t,!0);for(const t of c.values())if(!t)return;o&&o()}),[c,o]),h=(0,e.useMemo)((()=>({id:l,initial:n,isPresent:r,custom:i,onExitComplete:u,register:t=>(c.set(t,!1),()=>c.delete(t))})),s?[Math.random(),u]:[r,u]);return(0,e.useMemo)((()=>{c.forEach(((t,e)=>c.set(e,!1)))}),[r]),e.useEffect((()=>{!r&&!c.size&&o&&o()}),[r]),"popLayout"===a&&(t=(0,rl.jsx)(Wh,{isPresent:r,children:t})),(0,rl.jsx)(ol.Provider,{value:h,children:t})};function Hh(){return new Map}const qh=t=>t.key||"";function Zh(t){const n=[];return e.Children.forEach(t,(t=>{(0,e.isValidElement)(t)&&n.push(t)})),n}const Xh=({children:t,exitBeforeEnter:n,custom:r,initial:o=!0,onExitComplete:i,presenceAffectsLayout:s=!0,mode:a="sync"})=>{Mo(!n,"Replace exitBeforeEnter with mode='wait'");const c=(0,e.useMemo)((()=>Zh(t)),[t]),l=c.map(qh),u=(0,e.useRef)(!0),h=(0,e.useRef)(c),d=sh((()=>new Map)),[f,p]=(0,e.useState)(c),[m,g]=(0,e.useState)(c);Du((()=>{u.current=!1,h.current=c;for(let t=0;t<m.length;t++){const e=qh(m[t]);l.includes(e)?d.delete(e):!0!==d.get(e)&&d.set(e,!1)}}),[m,l.length,l.join("-")]);const y=[];if(c!==f){let t=[...c];for(let e=0;e<m.length;e++){const n=m[e],r=qh(n);l.includes(r)||(t.splice(e,0,n),y.push(n))}return"wait"===a&&y.length&&(t=y),g(Zh(t)),void p(c)}const{forceRender:w}=(0,e.useContext)(il);return(0,rl.jsx)(rl.Fragment,{children:m.map((t=>{const e=qh(t),n=c===m||l.includes(e);return(0,rl.jsx)(zh,{isPresent:n,initial:!(u.current&&!o)&&void 0,custom:n?void 0:r,presenceAffectsLayout:s,mode:a,onExitComplete:n?void 0:()=>{if(!d.has(e))return;d.set(e,!0);let t=!0;d.forEach((e=>{e||(t=!1)})),t&&(null==w||w(),g(h.current),i&&i())},children:t},e)}))})},Gh=t=>{const e=(t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,((t,e,n)=>n?n.toUpperCase():e.toLowerCase())))(t);return e.charAt(0).toUpperCase()+e.slice(1)},Yh=(...t)=>t.filter(((t,e,n)=>Boolean(t)&&""!==t.trim()&&n.indexOf(t)===e)).join(" ").trim(),Jh=t=>{for(const e in t)if(e.startsWith("aria-")||"role"===e||"title"===e)return!0};var Qh={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const td=(0,e.forwardRef)((({color:t="currentColor",size:n=24,strokeWidth:r=2,absoluteStrokeWidth:o,className:i="",children:s,iconNode:a,...c},l)=>(0,e.createElement)("svg",{ref:l,...Qh,width:n,height:n,stroke:t,strokeWidth:o?24*Number(r)/Number(n):r,className:Yh("lucide",i),...!s&&!Jh(c)&&{"aria-hidden":"true"},...c},[...a.map((([t,n])=>(0,e.createElement)(t,n))),...Array.isArray(s)?s:[s]]))),ed=(t,n)=>{const r=(0,e.forwardRef)((({className:r,...o},i)=>{return(0,e.createElement)(td,{ref:i,iconNode:n,className:Yh(`lucide-${s=Gh(t),s.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}`,`lucide-${t}`,r),...o});var s}));return r.displayName=Gh(t),r},nd=ed("shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]]),rd=ed("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]),od=ed("lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]),id=ed("circle-alert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]),sd=ed("send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]]),ad=ed("external-link",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]),cd=()=>void 0!==a.g&&void 0!==a.g.nativeModuleProxy||"undefined"!=typeof navigator&&"ReactNative"===navigator.product,ld=function(t){return ud(t,arguments.length>1&&void 0!==arguments[1]?arguments[1]:{})},ud=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise(((n,r)=>{if(cd())console.log("OAuth in React Native environment would open:",t),setTimeout((()=>{n({success:!0,token:"mock-oauth-token-for-react-native"})}),1e3);else{const o=e.width||600,i=e.height||700,s=window.screen.width/2-o/2,a=window.screen.height/2-i/2;window.open(t,"Auth Window","width=".concat(o,",height=").concat(i,",top=").concat(a,",left=").concat(s))||r(new Error("Could not open auth window")),setTimeout((()=>{n({success:!0,token:"mock-oauth-token-for-web"})}),1e3)}}))},hd=[{name:"YouTube",icon:"https://onairos.sirv.com/Images/youtube-icon.png",connected:!1,color:"#FF0000"},{name:"Reddit",icon:"https://onairos.sirv.com/Images/reddit-icon.png",connected:!1,color:"#FF4500"},{name:"Instagram",icon:"https://onairos.sirv.com/Images/instagram-icon.png",connected:!1,color:"#E1306C"},{name:"Pinterest",icon:"https://onairos.sirv.com/Images/pinterest-icon.png",connected:!1,color:"#E60023"},{name:"TikTok",icon:"https://onairos.sirv.com/Images/tiktok-icon.png",connected:!1,color:"#000000"}],dd={CONNECT:"connect",PASSPHRASE:"passphrase",CONFIRM:"confirm",UNIFYING:"unifying"};function fd(t){let{onComplete:r,appIcon:o}=t;const[i,s]=(0,e.useState)(hd),[a,c]=(0,e.useState)(dd.CONNECT),[l,u]=(0,e.useState)(0),[h,d]=(0,e.useState)(""),[f,p]=(0,e.useState)(""),[m,g]=(0,e.useState)(!1);(0,e.useEffect)((()=>{const t=t=>{t.data&&t.data.platform&&"success"===t.data.status&&s(i.map((e=>e.name.toLowerCase()===t.data.platform.toLowerCase()?{...e,connected:!0}:e)))};return window.addEventListener("message",t),()=>window.removeEventListener("message",t)}),[i]),(0,e.useEffect)((()=>{if(a===dd.UNIFYING){const t=setInterval((()=>{u((e=>e>=100?(clearInterval(t),r(),100):e+2))}),100);return()=>clearInterval(t)}}),[a,r]);const y=()=>{i.some((t=>t.connected))&&c(dd.PASSPHRASE)},w=()=>{(!h||h.length<8?(p("Passphrase must be at least 8 characters"),0):(p(""),1))&&c(dd.CONFIRM)},v=async()=>{c(dd.UNIFYING);try{const t=await fetch("https://api2.onairos.uk/unify",{method:"POST",headers:{Authorization:"Bearer ".concat(localStorage.getItem("onairosToken")),"Content-Type":"application/json"},body:JSON.stringify({platforms:i.filter((t=>t.connected)).map((t=>t.name.toLowerCase())),passphrase:h})});if(!t.ok)throw new Error("Failed to unify data")}catch(t){console.error("Failed to unify data:",t)}};return n().createElement("div",{className:"flex flex-col items-center space-y-6 p-6 w-full"},n().createElement(Xh,{mode:"wait"},a===dd.CONNECT&&n().createElement(Fh.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"flex flex-col items-center space-y-6 w-full"},n().createElement("h2",{className:"text-xl font-semibold text-gray-900"},"Connect Your Accounts"),n().createElement("div",{className:"bg-blue-50 border border-blue-200 rounded-lg p-4 w-full max-w-md"},n().createElement("div",{className:"flex items-start"},n().createElement(nd,{className:"text-blue-500 mr-2 flex-shrink-0 mt-0.5",size:20}),n().createElement("p",{className:"text-sm text-blue-700"},"Your data is never shared with anyone. It's only used to train your personal model and is stored securely."))),n().createElement("div",{className:"grid grid-cols-2 gap-4 w-full max-w-md"},i.map((t=>n().createElement(Fh.button,{key:t.name,onClick:()=>(async t=>{try{g(!0),ld("https://api2.onairos.uk/auth/".concat(t.toLowerCase()),t),g(!1)}catch(e){console.error("Failed to connect to ".concat(t,":"),e),g(!1)}})(t.name),disabled:m||t.connected,whileHover:{scale:t.connected?1:1.03},whileTap:{scale:t.connected?1:.98},className:"flex flex-col items-center justify-center p-4 rounded-lg border ".concat(t.connected?"bg-green-50 border-green-500":"border-gray-300 hover:border-blue-500 hover:shadow-sm")},n().createElement("div",{className:"relative"},n().createElement("img",{src:t.icon,alt:t.name,className:"w-10 h-10 mb-2"}),t.connected&&n().createElement("div",{className:"absolute -top-1 -right-1 bg-green-500 rounded-full p-0.5"},n().createElement(rd,{size:14,className:"text-white"}))),n().createElement("span",{className:"text-sm ".concat(t.connected?"text-green-600":"text-gray-700")},t.connected?"Connected":"Connect"))))),n().createElement("button",{onClick:y,disabled:!i.some((t=>t.connected)),className:"w-full max-w-md py-3 px-4 rounded-lg font-semibold transition-all ".concat(i.some((t=>t.connected))?"bg-blue-500 text-white hover:bg-blue-600":"bg-gray-300 text-gray-500 cursor-not-allowed")},"Continue"),n().createElement("p",{className:"text-xs text-gray-500 max-w-md text-center"},"Connect at least one account to create your personalized AI model")),a===dd.PASSPHRASE&&n().createElement(Fh.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"flex flex-col items-center space-y-6 w-full"},n().createElement("h2",{className:"text-xl font-semibold text-gray-900"},"Create Your Secure Passphrase"),n().createElement("div",{className:"bg-blue-50 border border-blue-200 rounded-lg p-4 w-full max-w-md"},n().createElement("div",{className:"flex items-start"},n().createElement(od,{className:"text-blue-500 mr-2 flex-shrink-0 mt-0.5",size:20}),n().createElement("p",{className:"text-sm text-blue-700"},"Your passphrase is used to secure your model. We don't store it, so please remember it for future access."))),n().createElement("div",{className:"w-full max-w-md"},n().createElement("label",{htmlFor:"passphrase",className:"block text-sm font-medium text-gray-700 mb-1"},"8+ Character Passphrase"),n().createElement("input",{type:"password",id:"passphrase",value:h,onChange:t=>d(t.target.value),placeholder:"Enter your secure passphrase",className:"w-full p-3 border ".concat(f?"border-red-500":"border-gray-300"," rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 outline-none")}),f&&n().createElement("p",{className:"mt-1 text-sm text-red-600 flex items-center"},n().createElement(id,{size:14,className:"mr-1"})," ",f)),n().createElement("div",{className:"flex space-x-3 w-full max-w-md"},n().createElement("button",{onClick:()=>c(dd.CONNECT),className:"flex-1 py-3 px-4 border border-gray-300 rounded-lg font-semibold text-gray-700 hover:bg-gray-50"},"Back"),n().createElement("button",{onClick:w,className:"flex-1 py-3 px-4 bg-blue-500 rounded-lg font-semibold text-white hover:bg-blue-600"},"Continue"))),a===dd.CONFIRM&&n().createElement(Fh.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"flex flex-col items-center space-y-6 w-full"},n().createElement("h2",{className:"text-xl font-semibold text-gray-900"},"Confirm Data Transfer"),n().createElement("div",{className:"flex justify-center items-center w-full max-w-md py-8"},n().createElement("div",{className:"relative flex items-center"},n().createElement("div",{className:"p-3 bg-gray-100 rounded-full"},n().createElement("img",{src:o||"https://onairos.sirv.com/Images/onairos-icon.png",alt:"App",className:"w-16 h-16 rounded-full"})),n().createElement(Fh.div,{animate:{x:[0,10,0]},transition:{repeat:1/0,duration:1.5},className:"mx-4"},n().createElement(sd,{size:24,className:"text-blue-500"})),n().createElement("div",{className:"p-3 bg-blue-100 rounded-full"},n().createElement("img",{src:"https://onairos.sirv.com/Images/onairos-icon.png",alt:"Onairos",className:"w-16 h-16 rounded-full"})))),n().createElement("div",{className:"bg-blue-50 border border-blue-200 rounded-lg p-4 w-full max-w-md"},n().createElement("p",{className:"text-sm text-blue-700"},"You're about to securely send your data to Onairos to train your personal AI model. Your data is end-to-end encrypted with your passphrase and never shared with anyone.")),n().createElement("div",{className:"w-full max-w-md"},n().createElement("h3",{className:"font-medium text-gray-700 mb-2"},"Connected platforms:"),n().createElement("div",{className:"flex flex-wrap gap-2"},i.filter((t=>t.connected)).map((t=>n().createElement("div",{key:t.name,className:"flex items-center bg-green-50 border border-green-200 rounded-full px-3 py-1"},n().createElement("img",{src:t.icon,alt:t.name,className:"w-4 h-4 mr-1"}),n().createElement("span",{className:"text-sm text-green-700"},t.name)))))),n().createElement("div",{className:"flex space-x-3 w-full max-w-md"},n().createElement("button",{onClick:()=>c(dd.PASSPHRASE),className:"flex-1 py-3 px-4 border border-gray-300 rounded-lg font-semibold text-gray-700 hover:bg-gray-50"},"Back"),n().createElement("button",{onClick:v,className:"flex-1 py-3 px-4 bg-blue-500 rounded-lg font-semibold text-white hover:bg-blue-600"},"Confirm & Create Model")),n().createElement("p",{className:"text-xs text-gray-500 max-w-md text-center"},"By proceeding, you agree to Onairos' ",n().createElement("a",{href:"https://onairos.uk/privacy",target:"_blank",rel:"noopener noreferrer",className:"text-blue-500 underline flex items-center inline-flex"},"Privacy Policy ",n().createElement(ad,{size:12,className:"ml-0.5"})))),a===dd.UNIFYING&&n().createElement(Fh.div,{initial:{opacity:0},animate:{opacity:1},className:"flex flex-col items-center justify-center space-y-6 p-6"},n().createElement("h2",{className:"text-xl font-semibold text-gray-900"},"Creating Your Personal AI Model"),n().createElement("p",{className:"text-gray-600 text-center"},"Please wait while we securely process your information"),n().createElement("div",{className:"w-full max-w-md"},n().createElement("div",{className:"relative pt-1"},n().createElement("div",{className:"flex mb-2 items-center justify-between"},n().createElement("div",null,n().createElement("span",{className:"text-xs font-semibold inline-block py-1 px-2 uppercase rounded-full text-blue-600 bg-blue-200"},"Progress")),n().createElement("div",{className:"text-right"},n().createElement("span",{className:"text-xs font-semibold inline-block text-blue-600"},l,"%"))),n().createElement(Fh.div,{className:"overflow-hidden h-2 mb-4 text-xs flex rounded bg-blue-200"},n().createElement(Fh.div,{initial:{width:0},animate:{width:"".concat(l,"%")},transition:{duration:.5},className:"shadow-none flex flex-col text-center whitespace-nowrap text-white justify-center bg-blue-500"})))),n().createElement(Fh.div,{animate:{rotate:360},transition:{duration:2,repeat:1/0,ease:"linear"},className:"w-12 h-12"},n().createElement("svg",{className:"w-full h-full text-blue-500",viewBox:"0 0 24 24"},n().createElement("path",{fill:"currentColor",d:"M12,4V2A10,10 0 0,0 2,12H4A8,8 0 0,1 12,4Z"}))),n().createElement("div",{className:"bg-blue-50 border border-blue-200 rounded-lg p-4 w-full max-w-md"},n().createElement("p",{className:"text-sm text-blue-700"},"Your data is being encrypted with your passphrase and securely processed. This may take a few minutes.")))))}function pd(t){let{onSignUpSuccess:r,setOthent:o,setHashedOthentSub:i,setEncryptedPin:s}=t;const[a,c]=(0,e.useState)({email:"",username:"",password:"",confirmPassword:""}),[l,u]=(0,e.useState)(null),h=t=>{c({...a,[t.target.name]:t.target.value})};return n().createElement("div",{className:"flex flex-col items-center justify-start max-w-sm mx-auto space-y-6 pt-4"},l&&n().createElement("div",{className:"w-full bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded-lg"},l),n().createElement(Kr,{onLoginSuccess:r,setOthent:o,setHashedOthentSub:i,setEncryptedPin:s}),n().createElement("div",{className:"w-full flex items-center justify-center space-x-4"},n().createElement("hr",{className:"flex-grow border-gray-300"}),n().createElement("span",{className:"text-gray-500"},"or"),n().createElement("hr",{className:"flex-grow border-gray-300"})),n().createElement("form",{onSubmit:async t=>{if(t.preventDefault(),a.password===a.confirmPassword)try{const t=await fetch("https://api2.onairos.uk/signup",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:a.email,username:a.username,password:a.password})}),e=await t.json();t.ok?(localStorage.setItem("onairosToken",e.token),localStorage.setItem("username",a.username),r(a.username)):u(e.message||"Sign up failed")}catch(t){u("Sign up failed. Please try again.")}else u("Passwords don't match")},className:"w-full space-y-4"},n().createElement("input",{type:"email",name:"email",value:a.email,onChange:h,placeholder:"Email",className:"w-full px-4 py-3 border rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500",required:!0}),n().createElement("input",{type:"text",name:"username",value:a.username,onChange:h,placeholder:"Username",className:"w-full px-4 py-3 border rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500",required:!0}),n().createElement("input",{type:"password",name:"password",value:a.password,onChange:h,placeholder:"Password",className:"w-full px-4 py-3 border rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500",required:!0}),n().createElement("input",{type:"password",name:"confirmPassword",value:a.confirmPassword,onChange:h,placeholder:"Confirm Password",className:"w-full px-4 py-3 border rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500",required:!0}),n().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 Up")))}function md(t){let{setOthentConnected:n,dataRequester:r,NoAccount:o,NoModel:i,activeModels:s,avatar:a,setAvatar:c,traits:l,setTraits:u,requestData:h,handleConnectionSelection:d,changeGranted:f,granted:p,allowSubmit:m,rejectDataRequest:g,sendDataRequest:y,isAuthenticated:w,onClose:v,onLoginSuccess:b,setOthentUser:E,setHashedOthentSub:S,setEncryptedPin:x,accountInfo:T}=t;const[A,_]=(0,e.useState)(null),[k,R]=(0,e.useState)(!1),C=(0,e.useRef)(null),[P,I]=(0,e.useState)({}),O=(t,e)=>{console.log(t," is being changed check to:",e),I((n=>({...n,[t]:e}))),f(e?1:-1);const n=h[t];d(r,t,n.index,n.type,n.reward,e),console.log(n," Selection registered"),d(r,t,n.index,n.type,n.reward,!0)},[N,B]=(0,e.useState)((()=>{var t;return w?T&&(null===(t=T.models)||void 0===t?void 0:t.length)>0?"datarequests":"onboarding":"login"})),[U,L]=(0,e.useState)({username:"",password:""}),[j,D]=(0,e.useState)(!1);(0,e.useEffect)((()=>{const t=()=>{const t=.01*window.innerHeight;document.documentElement.style.setProperty("--vh","".concat(t,"px"))};return t(),window.addEventListener("resize",t),window.addEventListener("orientationchange",t),()=>{window.removeEventListener("resize",t),window.removeEventListener("orientationchange",t)}}),[]);const M=()=>{v()};(0,e.useEffect)((()=>{const t=t=>{C.current&&!C.current.contains(t.target)&&(null==M||M())};return document.addEventListener("mousedown",t),document.addEventListener("touchstart",t),()=>{document.removeEventListener("mousedown",t),document.removeEventListener("touchstart",t)}}),[M]);const V=t=>{L({...U,[t.target.name]:t.target.value})},F=async t=>{t.preventDefault();try{_(null);const t={details:{username:U.username,password:U.password}},e=await fetch("".concat("https://api2.onairos.uk","/login"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),n=await e.json();if("Accepted"!==n.authentication)throw new Error("Invalid credentials");localStorage.setItem("onairosToken",n.token),localStorage.setItem("username",U.username),await K(U.username)}catch(t){console.error("Login failed:",t),_("Invalid username or password")}},K=async function(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];R(!0);try{await b(t,e);_(null)}catch(t){console.error("Login process failed:",t),_("Failed to complete login process")}finally{R(!1)}},$=()=>{B("security")},W=t=>{"othent"===t.method?E(!0):"pin"===t.method&&x(t.value),B("datarequests")},z=t=>{let{dataRequester:e,granted:n,allowSubmit:r,rejectDataRequest:o,sendDataRequest:i,activeModels:s,requestData:a,handleConnectionSelection:c,changeGranted:l,avatar:u,traits:h}=t;return React.createElement("div",{className:"flex flex-col h-full"},React.createElement("div",{className:"px-6"},React.createElement("h1",{className:"text-lg font-semibold text-gray-900 mb-6"},"Data Requests from ",e),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-full",onClick:o},"Reject All"),React.createElement("button",{disabled:!r||0===n,className:"".concat(r&&n>0?"bg-blue-500 hover:bg-blue-600":"bg-gray-300 cursor-not-allowed"," text-white font-bold py-2 px-8 rounded-full"),onClick:i},"Confirm (",n,")"))),React.createElement("div",{className:"flex-1 overflow-y-auto px-6"},0===s.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 ",e," your data")):React.createElement("div",{className:"space-y-4"},Object.keys(a).sort(((t,e)=>{const n=s.includes(a[t].type),r=s.includes(a[e].type);return"Avatar"===a[t].type?1:"Avatar"===a[e].type?-1:"Traits"===a[e].type?1:"Traits"===a[t].type||n&&!r?-1:r&&!n?1:0})).map(((t,e)=>{const n=a[t],r="Personality"===n.type?s.includes(n.type):"Avatar"===n.type?u:"Traits"===n.type&&h;return React.createElement(zr,{key:t,active:r,title:n.type,id:n,number:e,descriptions:n.descriptions,rewards:n.reward,size:t,isChecked:!!P[t],onCheckboxChange:e=>O(t,e)})})))))};return(0,e.useEffect)((()=>{var t;w&&T&&((null===(t=T.models)||void 0===t?void 0:t.length)>0?B("datarequests"):B("onboarding"))}),[w,T]),(0,e.useEffect)((()=>()=>{D(!1)}),[]),(0,e.useEffect)((()=>{}),[w,T]),React.createElement(React.Fragment,null,React.createElement("div",{className:"fixed inset-0 bg-black bg-opacity-50",onClick:M,style:{touchAction:"none"}}),React.createElement("div",{ref:C,className:"fixed bottom-0 left-0 right-0 w-full bg-white rounded-t-3xl shadow-2xl transform transition-transform duration-300 ease-out flex flex-col",style:{maxHeight:"60vh",minHeight:"45vh",height:"auto",touchAction:"none"}},React.createElement("div",{className:"sticky top-0 bg-white z-10 px-6 pt-3 pb-2"},React.createElement("div",{className:"w-12 h-1.5 bg-gray-300 rounded-full mx-auto"})),React.createElement("div",{className:"flex-1 overflow-y-auto px-6 pb-8",style:{touchAction:"pan-y"}},(()=>{switch(N){case"signup":return React.createElement(pd,{onSignUpSuccess:K,setOthentUser:E,setHashedOthentSub:S,setEncryptedPin:x});case"onboarding":return React.createElement(fd,{onComplete:$});case"security":return React.createElement(Kh,{onComplete:W});case"datarequests":return React.createElement(z,{dataRequester:r,granted:p,allowSubmit:m,rejectDataRequest:g,sendDataRequest:y,activeModels:s,requestData:h,handleConnectionSelection:d,changeGranted:f,avatar:a,traits:l});default:return React.createElement("div",{className:"flex flex-col items-center justify-start max-w-sm mx-auto space-y-6 pt-4"},A&&React.createElement("div",{className:"w-full bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded-lg"},A),React.createElement(Kr,{onLoginSuccess:K,setOthentUser:E,setHashedOthentSub:S,setEncryptedPin:x}),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:F,className:"w-full space-y-4"},React.createElement("input",{type:"text",name:"username",value:U.username,onChange:V,placeholder:"Username",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:U.password,onChange:V,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("button",{onClick:()=>B("signup"),className:"w-full text-center text-blue-500 hover:text-blue-600"},"Don't have an account? Sign up"))}})())))}class gd extends Error{constructor(t,e,n){super("object"==typeof e?e.message:e||t,{cause:"object"==typeof e?e.cause:n}),this.type=t,this.name="TypedError",Object.setPrototypeOf(this,gd.prototype)}}const yd="ERR_INVALID_VALUE",wd="ERR_UNEXPECTED_VALUE",vd="ERR_UNEXPECTED_TYPE",bd="ERR_PARSE";function Ed(t,e){const n={};for(const r in t){const o=t[r];if(!o)continue;let i,s;"function"==typeof o?(i=r,s=o):[i,s]=o;try{const t=s(e(i));void 0!==t&&(n[r]=t)}catch(t){throw new gd(bd,`Parser for "${r}" property failed${i===r?"":`. Source field: "${i}"`}`,t)}}return n}function Sd(t){let e=t;if("string"==typeof e)try{e=JSON.parse(e)}catch(t){throw new gd(yd,{cause:t})}if("object"!=typeof e||!e||Array.isArray(e))throw new gd(wd);return e}function xd(t,e){return n=>{const r=r=>{if(!n||void 0!==r)try{return e(r)}catch(e){throw new gd(bd,{message:`"${t}" transformer failed to parse the value`,cause:e})}};return Object.assign(r,{isValid(t){try{return r(t),!0}catch{return!1}}})}}function Td(t,e){return xd(e||"object",(e=>{const n=Sd(e);return Ed(t,(t=>n[t]))}))}function Ad(t){throw new gd(vd,`Unexpected value received: ${JSON.stringify(t)}`)}xd("boolean",(t=>{if("boolean"==typeof t)return t;const e=String(t);return"1"===e||"true"===e||"0"!==e&&"false"!==e&&void Ad(t)}));const _d=xd("string",(t=>{if("string"==typeof t||"number"==typeof t)return t.toString();Ad(t)})),kd=xd("number",(t=>{if("number"==typeof t)return t;if("string"==typeof t){const e=Number(t);if(!Number.isNaN(e))return e}Ad(t)}));xd("date",(t=>t instanceof Date?t:new Date(1e3*kd()(t))));function Rd(t){return/^#[\da-f]{6}$/i.test(t)}function Cd(t){const e=t.replace(/\s/g,"").toLowerCase();if(Rd(e))return e;if(function(t){return/^#[\da-f]{3}$/i.test(t)}(e)){let t="#";for(let n=0;n<3;n+=1)t+=e[1+n].repeat(2);return t}const n=e.match(/^rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)$/)||e.match(/^rgba\((\d{1,3}),(\d{1,3}),(\d{1,3}),\d{1,3}\)$/);if(!n)throw new Error(`Value "${t}" does not satisfy any of known RGB formats.`);return n.slice(1).reduce(((t,e)=>{const n=parseInt(e,10).toString(16);return t+(1===n.length?"0":"")+n}),"#")}const Pd=xd("rgb",(t=>Cd(_d()(t)))),Id=xd("themeParams",(t=>{const e=Pd(!0);return Object.entries(Sd(t)).reduce(((t,[n,r])=>(t[function(t){return t.replace(/_[a-z]/g,(t=>t[1].toUpperCase()))}(n)]=e(r),t)),{})}));class Od extends Error{constructor(t,e,n){super("object"==typeof e?e.message:e||t,{cause:"object"==typeof e?e.cause:n}),this.type=t,this.name="TypedError",Object.setPrototypeOf(this,Od.prototype)}}function Nd(t){return t.replace(/[A-Z]/g,(t=>`_${t.toLowerCase()}`))}const Bd="ERR_INVALID_VALUE",Ud="ERR_UNEXPECTED_VALUE",Ld="ERR_UNEXPECTED_TYPE",jd="ERR_PARSE";function Dd(t,e){const n={};for(const r in t){const o=t[r];if(!o)continue;let i,s;"function"==typeof o?(i=r,s=o):[i,s]=o;try{const t=s(e(i));void 0!==t&&(n[r]=t)}catch(t){throw new Od(jd,`Parser for "${r}" property failed${i===r?"":`. Source field: "${i}"`}`,t)}}return n}function Md(t){let e=t;if("string"==typeof e)try{e=JSON.parse(e)}catch(t){throw new Od(Bd,{cause:t})}if("object"!=typeof e||!e||Array.isArray(e))throw new Od(Ud);return e}function Vd(t,e){return n=>{const r=r=>{if(!n||void 0!==r)try{return e(r)}catch(e){throw new Od(jd,{message:`"${t}" transformer failed to parse the value`,cause:e})}};return Object.assign(r,{isValid(t){try{return r(t),!0}catch{return!1}}})}}function Fd(t,e){return Vd(e||"object",(e=>{const n=Md(e);return Dd(t,(t=>n[t]))}))}function Kd(t){throw new Od(Ld,`Unexpected value received: ${JSON.stringify(t)}`)}const $d=Vd("boolean",(t=>{if("boolean"==typeof t)return t;const e=String(t);return"1"===e||"true"===e||"0"!==e&&"false"!==e&&void Kd(t)})),Wd=Vd("string",(t=>{if("string"==typeof t||"number"==typeof t)return t.toString();Kd(t)})),zd=Vd("number",(t=>{if("number"==typeof t)return t;if("string"==typeof t){const e=Number(t);if(!Number.isNaN(e))return e}Kd(t)})),Hd=Vd("date",(t=>t instanceof Date?t:new Date(1e3*zd()(t))));function qd(t,e){return Vd(e||"searchParams",(e=>{"string"!=typeof e&&!(e instanceof URLSearchParams)&&Kd(e);const n="string"==typeof e?new URLSearchParams(e):e;return Dd(t,(t=>{const e=n.get(t);return null===e?void 0:e}))}))}function Zd(t){for(const e in t)t[e]=[Nd(e),t[e]];return t}const Xd=t=>{const e=zd(),n=zd(!0),r=Wd(),o=Wd(!0),i=$d(!0),s=Fd(Zd({addedToAttachmentMenu:i,allowsWriteToPm:i,firstName:r,id:e,isBot:i,isPremium:i,languageCode:o,lastName:o,photoUrl:o,username:o}),"User")(!0);return qd(Zd({authDate:Hd(),canSendAfter:n,chat:Fd(Zd({id:e,type:r,title:r,photoUrl:o,username:o}),"Chat")(!0),chatInstance:o,chatType:o,hash:r,queryId:o,receiver:s,startParam:o,signature:r,user:s}),"initData")(t)};const Gd=Vd("rgb",(t=>function(t){const e=t.replace(/\s/g,"").toLowerCase();if(function(t){return/^#[\da-f]{6}$/i.test(t)}(e))return e;if(function(t){return/^#[\da-f]{3}$/i.test(t)}(e)){let t="#";for(let n=0;n<3;n+=1)t+=e[1+n].repeat(2);return t}const n=e.match(/^rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)$/)||e.match(/^rgba\((\d{1,3}),(\d{1,3}),(\d{1,3}),\d{1,3}\)$/);if(!n)throw new Error(`Value "${t}" does not satisfy any of known RGB formats.`);return n.slice(1).reduce(((t,e)=>{const n=parseInt(e,10).toString(16);return t+(1===n.length?"0":"")+n}),"#")}(Wd()(t)))),Yd=Vd("themeParams",(t=>{const e=Gd(!0);return Object.entries(Md(t)).reduce(((t,[n,r])=>(t[function(t){return t.replace(/_[a-z]/g,(t=>t[1].toUpperCase()))}(n)]=e(r),t)),{})}));function Jd(t){return JSON.stringify(Object.fromEntries(Object.entries(t).map((([t,e])=>[Nd(t),e]))))}const Qd=t=>{const e=Wd(),n=Wd(!0),r=$d(!0);return qd({botInline:["tgWebAppBotInline",r],defaultColors:["tgWebAppDefaultColors",Yd(!0)],fullscreen:["tgWebAppFullscreen",r],initData:["tgWebAppData",Xd(!0)],initDataRaw:["tgWebAppData",n],platform:["tgWebAppPlatform",e],showSettings:["tgWebAppShowSettings",r],startParam:["tgWebAppStartParam",n],themeParams:["tgWebAppThemeParams",Yd()],version:["tgWebAppVersion",e]},"launchParams")(t)};function tf(t){const{initDataRaw:e,startParam:n,showSettings:r,botInline:o,fullscreen:i,defaultColors:s}=t,a=new URLSearchParams;return a.set("tgWebAppPlatform",t.platform),a.set("tgWebAppThemeParams",Jd(t.themeParams)),a.set("tgWebAppVersion",t.version),e&&a.set("tgWebAppData",e),n&&a.set("tgWebAppStartParam",n),"boolean"==typeof r&&a.set("tgWebAppShowSettings",r?"1":"0"),"boolean"==typeof o&&a.set("tgWebAppBotInline",o?"1":"0"),"boolean"==typeof i&&a.set("tgWebAppFullscreen",i?"1":"0"),s&&a.set("tgWebAppDefaultColors",Jd(s)),a.toString()}const ef=Fd({eventType:Wd(),eventData:t=>t},"miniAppsMessage"),nf=Vd("fn",(t=>{if("function"==typeof t)return t;Kd(t)}));const rf=Fd({TelegramWebviewProxy:Fd({postEvent:nf()})()});function of(t){return rf().isValid(t)}var sf=Object.defineProperty,af=(t,e,n)=>((t,e,n)=>e in t?sf(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n)(t,"symbol"!=typeof e?e+"":e,n);let cf=class t extends Error{constructor(e,n,r){super("object"==typeof n?n.message:n||e,{cause:"object"==typeof n?n.cause:r}),this.type=e,this.name="TypedError",Object.setPrototypeOf(this,t.prototype)}};function lf(t,e,n){return t.addEventListener(e,n),()=>t.removeEventListener(e,n)}function uf(...t){const e=t.flat(1);return[e.push.bind(e),()=>{e.forEach((t=>{t()}))}]}function hf(t){return e=>function(t,e){return t instanceof cf&&t.type===e}(e,t)}const df="ERR_ABORTED",ff="ERR_CANCELED",pf="ERR_TIMED_OUT";function mf(t){return new cf(df,{cause:t})}hf(pf),hf(df),hf(ff);function gf(t,e){return t.reject=e.reject,t}class yf extends Promise{constructor(t,e){let n,r,o,i;"function"==typeof t?(n=t,r=e):r=t,super(((t,e)=>{r||(r={});const{abortSignal:s}=r;if(s&&s.aborted)return e(mf(s.reason));const[a,c]=uf(),l=t=>(...e)=>(c(),t(...e)),u=new AbortController,{signal:h}=u;i=l((t=>{u.abort(t),e(t)})),o=l(t),s&&a(lf(s,"abort",(()=>{i(mf(s.reason))})));const{timeout:d}=r;if(d){const t=setTimeout((()=>{i(new cf(pf,`Timeout reached: ${d}ms`))}),d);a((()=>{clearTimeout(t)}))}n&&n(o,i,h)})),af(this,"reject"),this.reject=i}static withFn(t,e){return new yf(((e,n,r)=>{try{const o=t(r);return o instanceof Promise?o.then(e,n):e(o)}catch(t){n(t)}}),e)}static resolve(t){return new yf((e=>{e(t)}))}static reject(t){return new yf(((e,n)=>{n(t)}))}cancel(){this.reject(new cf(ff))}catch(t){return this.then(void 0,t)}finally(t){return gf(super.finally(t),this)}then(t,e){return gf(super.then(t,e),this)}}function wf(t,e){return t.resolve=e.resolve,t}let vf=class t extends yf{constructor(t,e){let n,r,o;"function"==typeof t?(n=t,r=e):r=t,super(((t,e,r)=>{o=t,n&&n(t,e,r)}),r),af(this,"resolve"),this.resolve=o}static withFn(e,n){return new t(((t,n,r)=>yf.withFn(e,{abortSignal:r}).then(t,n)),n)}static resolve(e){return new t((t=>{t(e)}))}static reject(e){return new t(((t,n)=>{n(e)}))}catch(t){return this.then(void 0,t)}finally(t){return wf(super.finally(t),this)}then(t,e){return wf(super.then(t,e),this)}};function bf(t){return`tapps/${t}`}function Ef(t,e){sessionStorage.setItem(bf(t),JSON.stringify(e))}function Sf(t){const e=sessionStorage.getItem(bf(t));try{return e?JSON.parse(e):void 0}catch{}}function xf(t){return t.replace(/[A-Z]/g,(t=>`-${t.toLowerCase()}`))}function Tf(t,e){e||(e={});const{textColor:n,bgColor:r,shouldLog:o=!0}=e;function i(e,...i){if(!o||"function"==typeof o&&!o())return;const s="font-weight:bold;padding:0 5px;border-radius:5px";console[e](`%c${Intl.DateTimeFormat("en-GB",{hour:"2-digit",minute:"2-digit",second:"2-digit",fractionalSecondDigits:3,timeZone:"UTC"}).format(new Date)}%c / %c${t}`,`${s};background-color: lightblue;color:black`,"",`${s};${n?`color:${n};`:""}${r?`background-color:${r}`:""}`,...i)}return[function(...t){i("log",...t)},function(...t){i("error",...t)}]}function Af(t,e){document.documentElement.style.setProperty(t,e)}function _f(t){document.documentElement.style.removeProperty(t)}function kf(t,e){e||(e={});const n=e.equals||Object.is;let r=[],o=t;const i=t=>{if(!n(o,t)){const e=o;o=t,function(t,e){e()}(0,(()=>{[...r].forEach((([n,r])=>{n(t,e),r&&a(n,!0)}))}))}};function s(t){const e="object"!=typeof t?{once:t}:t;return{once:e.once||!1,signal:e.signal||!1}}const a=(t,e)=>{const n=s(e),o=r.findIndex((([e,r])=>e===t&&r.once===n.once&&r.signal===n.signal));o>=0&&r.splice(o,1)},c=Object.assign((function(){return function(t){Rf.length&&Rf[Rf.length-1].add(t)}(c),o}),{destroy(){r=[]},set:i,reset(){i(t)},sub:(t,e)=>(r.push([t,s(e)]),()=>a(t,e)),unsub:a,unsubAll(){r=r.filter((t=>t[1].signal))}});return c}const Rf=[];const Cf=kf(!1),[Pf,If]=Tf("Bridge",{bgColor:"#9147ff",textColor:"white",shouldLog:Cf}),Of={clipboard_text_received:Fd({req_id:Wd(),data:t=>null===t?t:Wd(!0)(t)},"clipboard_text_received"),custom_method_invoked:Fd({req_id:Wd(),result:t=>t,error:Wd(!0)},"custom_method_invoked"),popup_closed:Vd("popup_closed",(t=>t?Fd({button_id:t=>null==t?void 0:Wd()(t)})()(t):{})),viewport_changed:Fd({height:zd(),width:t=>null==t?window.innerWidth:zd()(t),is_state_stable:$d(),is_expanded:$d()},"viewport_changed")};const Nf=kf(),Bf=kf();function Uf(){return Bf()||Bf.set(function(t){const e=window,[,n]=uf(lf(e,"message",(n=>{if(n.source!==e.parent)return;let r;try{r=ef()(n.data)}catch{return}const{eventType:o,eventData:i}=r,s=Of[o];try{const e=s?s()(i):i;Pf("Event received:",e?{eventType:o,eventData:e}:{eventType:o}),t([o,e])}catch(t){If([`An error occurred processing the "${o}" event from the Telegram application.`,"Please, file an issue here:","https://github.com/Telegram-Mini-Apps/telegram-apps/issues/new/choose"].join("\n"),r,t)}})));return n}(Nf.set)),Nf}const Lf=kf({});function jf(t){let e=Lf()[t];return e||(e=kf(void 0,{equals:()=>!1}),Uf().sub((n=>{n&&n[0]===t&&e.set(n[1])})),Lf.set({...Lf(),[t]:e})),e}function Df(t,e,n){return jf(t).sub(e,n)}const Mf="ERR_RETRIEVE_LP_FAILED",Vf="ERR_UNKNOWN_ENV",Ff="ERR_INVOKE_CUSTOM_METHOD_RESPONSE",Kf=kf("https://web.telegram.org");function $f(t,e){Pf("Posting event:",e?{eventType:t,eventData:e}:{eventType:t});const n=window;if(of(n))return void n.TelegramWebviewProxy.postEvent(t,JSON.stringify(e));const r=JSON.stringify({eventType:t,eventData:e});if(function(){try{return window.self!==window.top}catch{return!0}}())return n.parent.postMessage(r,Kf());const{external:o}=n;if(!Fd({notify:nf()})().isValid(o))throw new cf(Vf);o.notify(r)}function Wf(t,e,n){n||(n={});const{capture:r}=n,[o,i]=uf();return new yf((i=>{(Array.isArray(e)?e:[e]).forEach((t=>{o(Df(t,(n=>{(!r||(Array.isArray(e)?r({event:t,payload:n}):r(n)))&&i(n)})))})),(n.postEvent||$f)(t,n.params)}),n).finally(i)}function zf(t){return Qd()(t)}function Hf(t){return zf(t.replace(/^[^?#]*[?#]/,"").replace(/[?#]/g,"&"))}function qf(){return Hf(window.location.href)}function Zf(){const t=performance.getEntriesByType("navigation")[0];if(!t)throw new Error("Unable to get first navigation entry.");return Hf(t.name)}const Xf="launchParams";function Gf(){return zf(Sf(Xf)||"")}function Yf(t){Ef("launchParams",tf(t))}function Jf(t){return t instanceof Error?t.message+(t.cause?`\n ${Jf(t.cause)}`:""):JSON.stringify(t)}function Qf(){const t=[];for(const e of[qf,Zf,Gf])try{const t=e();return Yf(t),t}catch(e){t.push(e)}throw new cf(Mf,["Unable to retrieve launch parameters from any known source. Perhaps, you have opened your app outside Telegram?","📖 Refer to docs for more information:","https://docs.telegram-mini-apps.com/packages/telegram-apps-bridge/environment","Collected errors:",...t.map((t=>`— ${Jf(t)}`))].join("\n"))}function tp(t){if("simple"===t)try{return Qf(),!0}catch{return!1}return yf.withFn((async()=>{if(of(window))return!0;try{return await Wf("web_app_request_theme","theme_changed",{timeout:100}),!0}catch{return!1}}),t)}function ep(t,e,n){jf(t).unsub(e,n)}function np(t){return({req_id:e})=>e===t}function rp(t){return t.split(".").map(Number)}function op(t,e){return function(t,e){const n=rp(t),r=rp(e),o=Math.max(n.length,r.length);for(let t=0;t<o;t+=1){const e=n[t]||0,o=r[t]||0;if(e!==o)return e>o?1:-1}return 0}(t,e)<=0}function ip(t,e,n){if("string"==typeof n){if("web_app_open_link"===t){if("try_instant_view"===e)return op("6.4",n);if("try_browser"===e)return op("7.6",n)}if("web_app_set_header_color"===t&&"color"===e)return op("6.9",n);if("web_app_close"===t&&"return_back"===e)return op("7.6",n);if("web_app_setup_main_button"===t&&"has_shine_effect"===e)return op("7.10",n)}switch(t){case"web_app_open_tg_link":case"web_app_open_invoice":case"web_app_setup_back_button":case"web_app_set_background_color":case"web_app_set_header_color":case"web_app_trigger_haptic_feedback":return op("6.1",e);case"web_app_open_popup":return op("6.2",e);case"web_app_close_scan_qr_popup":case"web_app_open_scan_qr_popup":case"web_app_read_text_from_clipboard":return op("6.4",e);case"web_app_switch_inline_query":return op("6.7",e);case"web_app_invoke_custom_method":case"web_app_request_write_access":case"web_app_request_phone":return op("6.9",e);case"web_app_setup_settings_button":return op("6.10",e);case"web_app_biometry_get_info":case"web_app_biometry_open_settings":case"web_app_biometry_request_access":case"web_app_biometry_request_auth":case"web_app_biometry_update_token":return op("7.2",e);case"web_app_setup_swipe_behavior":return op("7.7",e);case"web_app_share_to_story":return op("7.8",e);case"web_app_setup_secondary_button":case"web_app_set_bottom_bar_color":return op("7.10",e);case"web_app_request_safe_area":case"web_app_request_content_safe_area":case"web_app_request_fullscreen":case"web_app_exit_fullscreen":case"web_app_set_emoji_status":case"web_app_add_to_home_screen":case"web_app_check_home_screen":case"web_app_request_emoji_status_access":return op("8.0",e);default:return["iframe_ready","iframe_will_reload","web_app_close","web_app_data_send","web_app_expand","web_app_open_link","web_app_ready","web_app_request_theme","web_app_request_viewport","web_app_setup_main_button","web_app_setup_closing_behavior"].includes(t)}}function sp(){const t=performance.getEntriesByType("navigation")[0];return!!t&&"reload"===t.type}let ap;function cp(t){if(ap)return t();ap=new Map;try{t()}finally{ap.forEach((t=>t())),ap=void 0}}function lp(t,e){e||(e={});const n=e.equals||Object.is;let r=[],o=t;const i=t=>{if(!n(o,t)){const e=o;o=t,function(t,e){ap&&ap.set(t,e)||e()}(c,(()=>{[...r].forEach((([n,r])=>{n(t,e),r&&a(n,!0)}))}))}};function s(t){const e="object"!=typeof t?{once:t}:t;return{once:e.once||!1,signal:e.signal||!1}}const a=(t,e)=>{const n=s(e),o=r.findIndex((([e,r])=>e===t&&r.once===n.once&&r.signal===n.signal));o>=0&&r.splice(o,1)},c=Object.assign((function(){return function(t){up.length&&up[up.length-1].add(t)}(c),o}),{destroy(){r=[]},set:i,reset(){i(t)},sub:(t,e)=>(r.push([t,s(e)]),()=>a(t,e)),unsub:a,unsubAll(){r=r.filter((t=>t[1].signal))}});return c}const up=[];function hp(t,e){let n,r=new Set;function o(){return n||(n=lp(s(),e))}function i(){o().set(s())}function s(){r.forEach((t=>{t.unsub(i,{signal:!0})}));const e=new Set;let n;up.push(e);try{n=t()}finally{up.pop()}return e.forEach((t=>{t.sub(i,{signal:!0})})),r=e,n}return Object.assign((function(){return o()()}),{destroy(){o().destroy()},sub:(...t)=>o().sub(...t),unsub(...t){o().unsub(...t)},unsubAll(...t){o().unsubAll(...t)}})}const dp=lp((()=>{let t=0;return()=>(t+=1).toString()})()),fp=lp($f),pp=lp("0.0");function mp(){return dp()()}function gp(t,e,n){return function(t,e,n,r){return Wf("web_app_invoke_custom_method","custom_method_invoked",{...r||{},params:{method:t,params:e,req_id:n},capture:np(n)}).then((({result:t,error:e})=>{if(e)throw new cf(Ff,e);return t}))}(t,e,mp(),{...n||{},postEvent:wp})}const yp=(t,e,n)=>(n||(n={}),n.postEvent||(n.postEvent=wp),Wf(t,e,n)),wp=(t,e)=>fp()(t,e);function vp(t){return hp((()=>ip(t,pp())))}const bp="ERR_POPUP_INVALID_PARAMS",Ep="ERR_INVALID_URL",Sp="ERR_ALREADY_REQUESTING",xp="ERR_ALREADY_OPENED",Tp="ERR_NOT_INITIALIZED",Ap="ERR_NOT_SUPPORTED",_p="ERR_NOT_MOUNTED";function kp(){return typeof window>"u"}function Rp(t,e,{isSupported:n,isMounted:r,component:o,supports:i}={}){const s=`${o?`${o}.`:""}${t}()`;function a(t){if(i){const e=i[t];return ip(e[0],e[1],pp())}return!0}n=n?Array.isArray(n)||"object"==typeof n&&"any"in n?n:[n]:void 0;const c=()=>{if(!n)return;const t=`it is unsupported in Mini Apps version ${pp()}`;function e(e){return"string"==typeof e?ip(e,pp())?void 0:t:e.fn()?void 0:e.error}if(Array.isArray(n)){for(const t of n){const n=e(t);if(n)return n}return}let r;for(const t of n.any)if(r=e(t),!r)return;return t},l=hp((()=>!c())),u=hp((()=>"0.0"!==pp())),h=hp((()=>!r||r())),d=hp((()=>tp("simple")&&!kp()&&u()&&l()&&h()));let f;if(i){f={};for(const t in i)f[t]=hp((()=>a(t)))}return Object.assign(((...t)=>{const n=`Unable to call the ${s} ${o?"method":"function"}:`;if(kp()||!tp("simple"))throw new cf(Vf,`${n} it can't be called outside Mini Apps`);if(!u())throw new cf(Tp,`${n} the SDK was not initialized. Use the SDK init() function`);const r=c();if(r)throw new cf(Ap,`${n} ${r}`);const l=((...t)=>{if(i)for(const e in i)if(i[e][2](...t)&&!a(e))return`option ${e} is not supported in Mini Apps version ${pp()}`})(...t);if(l)throw new cf(Ap,`${n} ${l}`);if(!h())throw new cf(_p,`${n} the component is not mounted. Use the ${o}.mount() method`);return e(...t)}),e,{isAvailable:d,ifAvailable:(...t)=>d()?e(...t):void 0},n?{isSupported:l}:{},f?{supports:f}:{})}function Cp(t,e){return e||(e={}),(n,r,o,i)=>Rp(n,r,{...e,isSupported:o||e.isSupported,supports:i,component:t})}function Pp(t,e,n){return Cp(t,{isSupported:n,isMounted:e})}function Ip(t,e){return Cp(t,{isSupported:e})}const Op="web_app_setup_back_button",Np="back_button_pressed",Bp="backButton",Up=lp(!1),Lp=lp(!1),jp=vp(Op),Dp=Pp(Bp,Lp,Op),Mp=Ip(Bp,Op),Vp=Dp("hide",(()=>{Kp(!1)})),Fp=Mp("mount",(()=>{Lp()||(Kp(sp()&&Sf(Bp)||!1),Lp.set(!0))}));function Kp(t){t!==Up()&&(wp(Op,{is_visible:t}),Ef(Bp,t),Up.set(t))}const $p=Mp("onClick",(t=>Df(Np,t))),Wp=Mp("offClick",(t=>{ep(Np,t)})),zp=Dp("show",(()=>{Kp(!0)}));Symbol.toStringTag;function Hp(t,e,n,r,o){const i=void 0===o||o?yf:Promise;return Object.assign(((...o)=>i.resolve().then((async()=>{if(n()){const t=e();throw r.set(t),t}let s;cp((()=>{n.set(i.resolve(t(...o))),r.set(void 0)}));try{s=[!0,await n()]}catch(t){s=[!1,t]}if(cp((()=>{n.set(void 0),r.set(s[0]?void 0:s[1])})),!s[0])throw s[1];return s[1]}))),t)}function qp(t,e,n,r,o,i){const s=Hp(e,(()=>new cf("ERR_ALREADY_MOUNTING",`The ${t} component is already mounting`)),o,i);return t=>yf.resolve().then((async()=>{if(!r()){const e=await s(t);cp((()=>{r.set(!0),n(e)}))}}))}const Zp=Cp,Xp=lp({available:!1}),Gp=lp(!1),Yp=lp(!1),Jp=lp(!1),Qp=hp((()=>!!em())),tm=lp(),em=lp(),nm=hp((()=>{const t=Xp();return t&&t.available}));function rm(t){return t.available?{available:!0,tokenSaved:t.token_saved,deviceId:t.device_id,accessRequested:t.access_requested,type:t.type,accessGranted:t.access_granted}:{available:!1}}const om="web_app_biometry_get_info",im=Rp("requestBiometry",(t=>yp(om,"biometry_info_received",t).then(rm)),{isSupported:om}),sm="web_app_biometry_request_auth",am="biometry_info_received",cm="biometry",lm=vp(sm),um=Zp(cm),hm=Ip(cm,sm),dm=Pp(cm,Jp,sm);function fm(){throw new cf("ERR_NOT_AVAILABLE","Biometry is not available")}const pm=dm("authenticate",(t=>yf.withFn((async e=>{if(Gp())throw new cf(Sp,"Authentication is already in progress");const n=Xp();(!n||!n.available)&&fm(),Gp.set(!0);try{const r=await yp(sm,"biometry_auth_requested",{abortSignal:e,params:{reason:((t||{}).reason||"").trim()}}),{token:o}=r;return"string"==typeof o&&vm({...n,token:o}),r}finally{Gp.set(!1)}}),t))),mm=hm("openSettings",(()=>{wp("web_app_biometry_open_settings")})),gm=dm("requestAccess",(t=>yf.withFn((async e=>{if(Yp())throw new cf(Sp,"Access request is already in progress");Yp.set(!0);try{const n=await yp("web_app_biometry_request_access",am,{abortSignal:e,params:{reason:(t||{}).reason||""}}).then(rm);return n.available||fm(),vm(n),n.accessGranted}finally{Yp.set(!1)}}),t))),ym=um("mount",qp(cm,(t=>sp()&&Sf(cm)||im(t)),(t=>{Df(am,wm),vm(t)}),Jp,em,tm)),wm=t=>{vm(rm(t))};function vm(t){Xp.set(t),Ef(cm,t)}const bm=dm("updateToken",(t=>(t||(t={}),yp("web_app_biometry_update_token","biometry_token_updated",{...t,params:{token:t.token||"",reason:t.reason}}).then((t=>t.status)))));Symbol.toStringTag;function Em(t,e){return Cp(t,{isMounted:e})}const Sm="closingBehavior",xm=lp(!1),Tm=lp(!1),Am=Em(Sm,Tm),_m=Zp(Sm),km=Am("disableConfirmation",(()=>{Pm(!1)})),Rm=Am("enableConfirmation",(()=>{Pm(!0)})),Cm=_m("mount",(()=>{Tm()||(Pm(sp()&&Sf(Sm)||!1),Tm.set(!0))}));function Pm(t){t!==xm()&&(wp("web_app_setup_closing_behavior",{need_confirmation:t}),Ef(Sm,t),xm.set(t))}Symbol.toStringTag;const Im="web_app_invoke_custom_method",Om=Ip("cloudStorage",Im),Nm=vp(Im),Bm=Om("deleteItem",((t,e)=>{const n=Array.isArray(t)?t:[t];return n.length?gp("deleteStorageValues",{keys:n},e).then():yf.resolve()}));const Um=Om("getItem",(function(t,e){const n=Array.isArray(t)?t:[t];return n.length?gp("getStorageValues",{keys:n},e).then((e=>{const r=Td(Object.fromEntries(n.map((t=>[t,_d()]))))()(e);return Array.isArray(t)?r:r[t]})):yf.resolve("string"==typeof t?"":{})})),Lm=Om("getKeys",(t=>gp("getStorageKeys",{},t).then(function(t,e){return xd("array",(e=>{let n;if(Array.isArray(e))n=e;else if("string"==typeof e)try{const t=JSON.parse(e);Array.isArray(t)&&(n=t)}catch{}return n||Ad(e),n.map(t)}))}(_d())()))),jm=Om("setItem",((t,e,n)=>gp("saveStorageValue",{key:t,value:e},n).then())),Dm=(Symbol.toStringTag,"web_app_trigger_haptic_feedback"),Mm=Ip("hapticFeedback",Dm),Vm=vp(Dm),Fm=Mm("impactOccurred",(t=>{wp(Dm,{type:"impact",impact_style:t})})),Km=Mm("notificationOccurred",(t=>{wp(Dm,{type:"notification",notification_type:t})})),$m=Mm("selectionChanged",(()=>{wp(Dm,{type:"selection_change"})})),Wm=(Symbol.toStringTag,lp(void 0));function zm(t){return hp((()=>{const e=Wm();return e?e[t]:void 0}))}const Hm=zm("authDate"),qm=zm("canSendAfter"),Zm=hp((()=>{const t=Hm(),e=qm();return e&&t?new Date(t.getTime()+1e3*e):void 0})),Xm=zm("chat"),Gm=zm("chatType"),Ym=zm("chatInstance"),Jm=zm("hash"),Qm=zm("queryId"),tg=lp(),eg=zm("receiver");const ng=zm("startParam"),rg=zm("user");Symbol.toStringTag;const og="web_app_open_invoice",ig=Ip("invoice",og),sg=lp(!1),ag=vp(og);async function cg(t,e,n){if(sg())throw new cf(xp,"An invoice is already opened");let r;if("url"===e){const{hostname:e,pathname:n}=new URL(t,window.location.href);if("t.me"!==e)throw new cf(Ep,`Link has unexpected hostname: ${e}`);const o=n.match(/^\/(\$|invoice\/)([A-Za-z0-9\-_=]+)$/);if(!o)throw new cf("ERR_INVALID_SLUG",'Expected to receive a link with a pathname in format "/invoice/{slug}" or "/${slug}"');[,,r]=o}else r=t,n=e;return sg.set(!0),yp(og,"invoice_closed",{...n,params:{slug:r},capture:t=>r===t.slug}).then((t=>t.status)).finally((()=>{sg.set(!1)}))}const lg=ig("open",cg);Symbol.toStringTag;function ug(t){return Object.fromEntries(Object.entries(t).filter((t=>void 0!==t[1])))}function hg(t){const e=Cd(t);return Math.sqrt([.299,.587,.114].reduce(((t,n,r)=>{const o=parseInt(e.slice(1+2*r,1+2*(r+1)),16);return t+o*o*n}),0))<120}const dg=lp(!1),fg=lp(!1),pg=lp({});function mg(t){return hp((()=>pg()[t]))}const gg=mg("accentTextColor"),yg=mg("bgColor"),wg=mg("buttonColor"),vg=mg("buttonTextColor"),bg=mg("bottomBarBgColor"),Eg=mg("destructiveTextColor"),Sg=mg("headerBgColor"),xg=mg("hintColor"),Tg=hp((()=>{const{bgColor:t}=pg();return!t||hg(t)})),Ag=mg("linkColor"),_g=mg("secondaryBgColor"),kg=mg("sectionBgColor"),Rg=mg("sectionHeaderTextColor"),Cg=mg("sectionSeparatorColor"),Pg=mg("subtitleTextColor"),Ig=mg("textColor");function Og(t){return hp((()=>Bg()[t]))}const Ng=lp({hasShineEffect:!1,isEnabled:!0,isLoaderVisible:!1,isVisible:!1,text:"Continue"}),Bg=hp((()=>{const t=Ng();return{...t,backgroundColor:t.backgroundColor||wg()||"#2481cc",textColor:t.textColor||vg()||"#ffffff"}})),Ug=lp(!1),Lg=Og("backgroundColor"),jg=Og("hasShineEffect"),Dg=Og("isEnabled"),Mg=Og("isLoaderVisible"),Vg=Og("isVisible"),Fg=Og("text"),Kg=Og("textColor"),$g="main_button_pressed",Wg="mainButton",zg=Zp(Wg),Hg=Em(Wg,Ug),qg=zg("mount",(()=>{if(!Ug()){const t=sp()&&Sf(Wg);t&&Ng.set(t),Ug.set(!0)}})),Zg=zg("onClick",(t=>Df($g,t))),Xg=zg("offClick",(t=>{ep($g,t)})),Gg=Hg("setParams",(t=>{Ng.set({...Ng(),...ug(t)}),Ef(Wg,Ng());const e=Bg();e.text&&wp("web_app_setup_main_button",{color:e.backgroundColor,has_shine_effect:e.hasShineEffect,is_active:e.isEnabled,is_progress_visible:e.isLoaderVisible,is_visible:e.isVisible,text:e.text,text_color:e.textColor})}));Symbol.toStringTag;function Yg(){throw new cf("ERR_VARS_ALREADY_BOUND","CSS variables are already bound")}const Jg="themeParams",Qg="theme_changed",ty=Zp(Jg),ey=Em(Jg,dg)("bindCssVars",(t=>{function e(t){Object.entries(pg()).forEach((([e,n])=>{n&&t(e,n)}))}function n(){e(((e,n)=>{Af(t(e),n)}))}return fg()&&Yg(),t||(t=t=>`--tg-theme-${xf(t)}`),n(),pg.sub(n),fg.set(!0),()=>{e(_f),pg.unsub(n),fg.set(!1)}})),ny=ty("mount",(()=>{dg()||(Df(Qg,ry),pg.set(sp()&&Sf(Jg)||Qf().themeParams),dg.set(!0))})),ry=t=>{const e=function(t){return Id()(t)}(t.theme_params);pg.set(e),Ef(Jg,e)};function oy(t){return hp((()=>{const e=t();return Rd(e)?e:"bg_color"===e?yg():_g()}))}const iy=lp("bg_color"),sy=oy(iy),ay=lp("bottom_bar_bg_color"),cy=hp((()=>{const t=ay();return Rd(t)?t:"bottom_bar_bg_color"===t?bg()||_g():"secondary_bg_color"===t?_g():yg()})),ly=lp("bg_color"),uy=oy(ly),hy=lp(!1),dy=lp(!1),fy=hp((()=>{const t=sy();return!!t&&hg(t)})),py=lp(!0),my=hp((()=>({backgroundColor:iy(),bottomBarColor:ay(),headerColor:ly(),isActive:py()}))),gy="web_app_set_background_color",yy="web_app_set_bottom_bar_color",wy="web_app_set_header_color",vy="visibility_changed",by="miniApp",Ey={any:[gy,yy,wy]},Sy=hp((()=>Ey.any.some((t=>ip(t,pp()))))),xy=Zp(by),Ty=Ip(by,Ey),Ay=Pp(by,hy,Ey),_y=Ay("bindCssVars",(t=>{dy()&&Yg();const[e,n]=uf();function r(t,n){function r(){Af(t,n()||null)}r(),e(n.sub(r),_f.bind(null,t))}return t||(t=t=>`--tg-${xf(t)}`),r(t("bgColor"),sy),r(t("bottomBarColor"),cy),r(t("headerColor"),uy),e((()=>{dy.set(!1)})),dy.set(!0),n})),ky=xy("close",(t=>{wp("web_app_close",{return_back:t})})),Ry=t=>{py.set(t.is_visible),Iy()},Cy=Ty("mount",(()=>{if(!hy()){const t=sp()&&Sf(by);ny(),Oy.ifAvailable(t?t.backgroundColor:"bg_color"),Ny.ifAvailable(t?t.bottomBarColor:"bottom_bar_bg_color"),By.ifAvailable(t?t.headerColor:"bg_color"),py.set(!t||t.isActive),Df(vy,Ry),hy.set(!0)}})),Py=xy("ready",(()=>{wp("web_app_ready")}));function Iy(){Ef(by,my())}const Oy=Ay("setBackgroundColor",(t=>{t!==iy()&&(wp(gy,{color:t}),iy.set(t),Iy())}),gy),Ny=Ay("setBottomBarColor",(t=>{t!==ay()&&(wp(yy,{color:t}),ay.set(t),Iy())}),yy),By=Ay("setHeaderColor",(t=>{t!==ly()&&(wp(wy,Rd(t)?{color:t}:{color_key:t}),ly.set(t),Iy())}),wy,{rgb:[wy,"color",Rd]});Symbol.toStringTag;function Uy(t){const e=t.message.trim(),n=(t.title||"").trim(),r=t.buttons||[];if(n.length>64)throw new cf(bp,`Invalid title: ${n}`);if(!e||e.length>256)throw new cf(bp,`Invalid message: ${e}`);if(r.length>3)throw new cf(bp,`Invalid buttons count: ${r.length}`);return{title:n,message:e,buttons:r.length?r.map(((t,e)=>{const n=t.id||"";if(n.length>64)throw new cf(bp,`Button with index ${e} has invalid id: ${n}`);if(!t.type||"default"===t.type||"destructive"===t.type){const r=t.text.trim();if(!r||r.length>64)throw new cf(bp,`Button with index ${e} has invalid text: ${r}`);return{type:t.type,text:r,id:n}}return{type:t.type,id:n}})):[{type:"close",id:""}]}}const Ly="web_app_open_popup",jy=Ip("popup",Ly),Dy=lp(!1),My=vp(Ly),Vy=jy("open",(async t=>{if(Dy())throw new cf(xp,"A popup is already opened");Dy.set(!0);try{const{button_id:e=null}=await yp(Ly,"popup_closed",{...t,params:Uy(t)});return e}finally{Dy.set(!1)}})),Fy=(Symbol.toStringTag,"web_app_open_scan_qr_popup"),Ky=Ip("qrScanner",Fy),$y=Ky("close",(()=>{Wy.set(!1),wp("web_app_close_scan_qr_popup")})),Wy=lp(!1),zy=vp(Fy);const Hy=Ky("open",(function(t){return yf.withFn((e=>{if(Wy())throw new cf(xp,"The QR Scanner is already opened");Wy.set(!0),t||(t={});const{onCaptured:n,text:r,capture:o}=t,[,i]=uf(Wy.sub((()=>{s.resolve()})),Df("scan_qr_popup_closed",(()=>{Wy.set(!1)})),Df("qr_text_received",(t=>{n?n(t.data):(!o||o(t.data))&&(s.resolve(t.data),$y())}))),s=new vf({abortSignal:e}).catch($y).finally(i);return(t.postEvent||wp)(Fy,{text:r}),s}),t)}));Symbol.toStringTag;function qy(t){return hp((()=>Xy()[t]))}const Zy=lp({hasShineEffect:!1,isEnabled:!0,isLoaderVisible:!1,isVisible:!1,position:"left",text:"Cancel"}),Xy=hp((()=>{const t=Zy();return{...t,backgroundColor:t.backgroundColor||cy()||"#000000",textColor:t.textColor||wg()||"#2481cc"}})),Gy=lp(!1),Yy=qy("backgroundColor"),Jy=qy("hasShineEffect"),Qy=qy("isEnabled"),tw=qy("isLoaderVisible"),ew=qy("isVisible"),nw=qy("position"),rw=qy("text"),ow=qy("textColor"),iw="web_app_setup_secondary_button",sw="secondary_button_pressed",aw="secondaryButton",cw=Ip(aw,iw),lw=Pp(aw,Gy,iw),uw=vp(iw),hw=cw("mount",(()=>{if(!Gy()){const t=sp()&&Sf(aw);t&&Zy.set(t),Gy.set(!0)}})),dw=cw("onClick",(t=>Df(sw,t))),fw=cw("offClick",(t=>{ep(sw,t)})),pw=lw("setParams",(t=>{Zy.set({...Zy(),...Object.fromEntries(Object.entries(t).filter((([,t])=>void 0!==t)))}),Ef(aw,Zy());const e=Xy();e.text&&wp(iw,{color:e.backgroundColor,has_shine_effect:e.hasShineEffect,is_active:e.isEnabled,is_progress_visible:e.isLoaderVisible,is_visible:e.isVisible,position:e.position,text:e.text,text_color:e.textColor})}));Symbol.toStringTag;const mw="web_app_setup_settings_button",gw="settings_button_pressed",yw="settingsButton",ww=lp(!1),vw=lp(!1),bw=vp(mw),Ew=Ip(yw,mw),Sw=Pp(yw,vw,mw),xw=Sw("hide",(()=>{Aw(!1)})),Tw=Ew("mount",(()=>{vw()||(Aw(sp()&&Sf(yw)||!1),vw.set(!0))}));function Aw(t){t!==ww()&&(wp(mw,{is_visible:t}),Ef(yw,t),ww.set(t))}const _w=Ew("onClick",(t=>Df(gw,t))),kw=Ew("offClick",(t=>{ep(gw,t)})),Rw=Sw("show",(()=>{Aw(!0)}));Symbol.toStringTag;const Cw="web_app_setup_swipe_behavior",Pw="swipeBehavior",Iw=lp(!1),Ow=vp(Cw),Nw=lp(!0),Bw=Ip(Pw,Cw),Uw=Pp(Pw,Iw,Cw),Lw=Uw("disableVertical",(()=>{Mw(!1)})),jw=Uw("enableVertical",(()=>{Mw(!0)})),Dw=Bw("mount",(()=>{Iw()||(Mw(sp()&&Sf(Pw)||!1,!0),Iw.set(!0))}));function Mw(t,e){(t!==Nw()||e)&&(wp(Cw,{allow_vertical_swipe:t}),Ef(Pw,t),Nw.set(t))}Symbol.toStringTag,Symbol.toStringTag;const Vw="viewport",Fw="web_app_request_fullscreen",Kw="fullscreen_changed",$w="safe_area_changed",Ww="content_safe_area_changed",zw="viewport_changed",Hw="web_app_request_safe_area",qw="web_app_request_content_safe_area",Zw={left:0,top:0,bottom:0,right:0};function Xw(t){return Math.max(t,0)}const Gw=lp({contentSafeAreaInsets:Zw,height:0,isExpanded:!1,isFullscreen:!1,safeAreaInsets:Zw,stableHeight:0,width:0});function Yw(t){return hp((()=>Gw()[t]))}function Jw(t){const{height:e,stableHeight:n,width:r}=t;Gw.set({...Gw(),...ug({...t,height:e?Xw(e):void 0,width:r?Xw(r):void 0,stableHeight:n?Xw(n):void 0})}),Ef(Vw,Gw())}const Qw=Yw("isFullscreen"),tv=lp(),ev=hp((()=>!!tv())),nv=lp(),rv=lp(!1),ov=hp((()=>!!sv())),iv=lp(void 0),sv=lp(),av=Pp(Vw,rv,Fw);function cv(t,e){return av(t,Hp((t=>yp(e,[Kw,"fullscreen_failed"],t).then((t=>{if("error"in t){if("ALREADY_FULLSCREEN"===t.error)return!0;throw new cf("ERR_FULLSCREEN_FAILED","Fullscreen request failed",t.error)}return t.is_fullscreen})).then((t=>{t!==Qw()&&Jw({isFullscreen:t})}))),(()=>new cf(Sp,"Fullscreen mode change is already being requested")),tv,nv))}const lv=cv("requestFullscreen",Fw),uv=cv("exitFullscreen","web_app_exit_fullscreen"),hv=Zp(Vw),dv=Em(Vw,rv);function fv(t){return hp((()=>pv()[t]))}const pv=Yw("safeAreaInsets"),mv=fv("bottom"),gv=fv("left"),yv=fv("right"),wv=fv("top");function vv(t){return hp((()=>bv()[t]))}const bv=Yw("contentSafeAreaInsets"),Ev=vv("bottom"),Sv=vv("left"),xv=vv("right"),Tv=vv("top"),Av=Rp("requestContentSafeAreaInsets",(t=>yp(qw,"content_safe_area_changed",t)),{isSupported:qw}),_v=Rp("requestSafeAreaInsets",(t=>yp(Hw,"safe_area_changed",t)),{isSupported:Hw});const kv=t=>{const{height:e}=t;Jw({isExpanded:t.is_expanded,height:e,width:t.width,stableHeight:t.is_state_stable?e:void 0})},Rv=t=>{Jw({isFullscreen:t.is_fullscreen})},Cv=t=>{Jw({safeAreaInsets:t})},Pv=t=>{Jw({contentSafeAreaInsets:t})},Iv=hv("mount",qp(Vw,(t=>yf.resolve().then((async()=>{const e=sp()&&Sf(Vw);if(e)return e;const[n,r]=await yf.all([_v.ifAvailable(t)||pv(),Av.ifAvailable(t)||bv()]),o=Qf(),i={contentSafeAreaInsets:r,isFullscreen:!!o.fullscreen,safeAreaInsets:n};if(["macos","tdesktop","unigram","webk","weba","web"].includes(o.platform)){const t=window;return{...i,height:t.innerHeight,isExpanded:!0,stableHeight:t.innerHeight,width:t.innerWidth}}return function(t){return yp("web_app_request_viewport","viewport_changed",t).then((t=>({height:t.height,width:t.width,isExpanded:t.is_expanded,isStable:t.is_state_stable})))}(t).then((t=>({...i,height:t.height,isExpanded:t.isExpanded,stableHeight:t.isStable?t.height:0,width:t.width})))}))),(t=>{Df(zw,kv),Df(Kw,Rv),Df($w,Cv),Df(Ww,Pv),Jw(t)}),rv,sv,iv));const Ov=lp(!1),Nv=Yw("height"),Bv=Yw("stableHeight"),Uv=Yw("width"),Lv=dv("bindCssVars",(t=>{Ov()&&Yg(),t||(t=t=>`--tg-viewport-${xf(t)}`);const e=[["height",Nv],["stableHeight",Bv],["width",Uv],["safeAreaInsetTop",wv],["safeAreaInsetBottom",mv],["safeAreaInsetLeft",gv],["safeAreaInsetRight",yv],["contentSafeAreaInsetTop",Tv],["contentSafeAreaInsetBottom",Ev],["contentSafeAreaInsetLeft",Sv],["contentSafeAreaInsetRight",xv]].reduce(((e,[n,r])=>{const o=t(n);if(o){const t=()=>{Af(o,`${r()}px`)};e.push([t,r.sub(t),o])}return e}),[]);return e.forEach((t=>{t[0]()})),Ov.set(!0),()=>{e.forEach((t=>{t[1](),_f(t[2])})),Ov.set(!1)}})),jv=hv("expand",(()=>{wp("web_app_expand")})),Dv=Yw("isExpanded"),Mv=hp((()=>Nv()===Bv())),Vv=(Symbol.toStringTag,Zp()("openLink",((t,e)=>{if("string"==typeof t)try{t=new URL(t)}catch(e){throw new cf(Ep,`"${t.toString()}" is invalid URL`,e)}e||(e={}),wp("web_app_open_link",{url:t.toString(),try_browser:e.tryBrowser,try_instant_view:e.tryInstantView})})),"web_app_open_tg_link"),Fv=Zp()("openTelegramLink",(t=>{const e=t.toString();if(!e.match(/^https:\/\/t.me\/.+/))throw new cf(Ep,`"${e}" is invalid URL`);ip(Vv,pp())?(t=new URL(t),wp(Vv,{path_full:t.pathname+t.search})):window.location.href=e}));Zp()("shareURL",((t,e)=>{Fv("https://t.me/share/url?"+new URLSearchParams({url:t,text:e||""}).toString().replace(/\+/g,"%20"))}));function Kv(t){let{active:e,title:r,id:o,number:i,descriptions:s,rewards:a,size:c,changeGranted:l,onSelectionChange:u}=t;return n().createElement("div",{className:"mobile-connection-container"},n().createElement("div",{className:"mobile-connection-header"},n().createElement("div",{className:"mobile-connection-checkbox-area"},n().createElement("input",{type:"checkbox",disabled:!e,className:"mobile-connection-checkbox",onChange:t=>{return e=t.target.checked,void u(e);var e}}),n().createElement("span",{className:"mobile-connection-title"},r)),a&&n().createElement("div",{className:"mobile-connection-rewards"},"Rewards: ",a)),s&&"Avatar"!==r&&n().createElement("div",{className:"mobile-connection-description"},"Intent: ",s))}const $v=t=>{let{requestData:r={},dataRequester:o="App",proofMode:i=!1,domain:s="",onComplete:a,onCancel:c}=t;const[l,u]=(0,e.useState)(!0),[h,d]=(0,e.useState)([]),[f,p]=(0,e.useState)(0),[m,g]=(0,e.useState)(!1),y=(0,e.useRef)([]);function w(){c&&"function"==typeof c&&c()}function v(t){p((e=>e+t))}return(0,e.useEffect)((()=>{g(f>0)}),[f]),(0,e.useEffect)((()=>{(async()=>{try{await new Promise((t=>setTimeout(t,1e3))),d((null==r?void 0:r.activeModels)||["Personality","Demographics"]),u(!1)}catch(t){console.error("Error loading data:",t),u(!1)}})()}),[r]),l?n().createElement("div",{className:"mobile-loading-container"},n().createElement("div",{className:"mobile-loading-spinner"}),n().createElement("p",{className:"mobile-loading-text"},"Loading...")):n().createElement("div",{className:"mobile-data-request-container",style:{height:"60vh"}},n().createElement("div",{className:"mobile-data-request-header"},n().createElement("h2",{className:"mobile-data-request-title"},"Data Requests from ",o),n().createElement("div",{className:"mobile-data-request-button-row"},n().createElement("button",{className:"mobile-reject-button",onClick:w},"Reject All"),n().createElement("button",{className:"mobile-confirm-button",disabled:!m,onClick:function(){if(0===f)return void w();const t={success:!0,apiUrl:"https://api2.onairos.uk/inferenceTest",approvedRequests:y.current};a&&"function"==typeof a&&a(t)}},"Confirm (",f,")"))),n().createElement("div",{className:"mobile-data-request-content"},0===h.length?n().createElement("div",{className:"mobile-no-models-message"},n().createElement("p",null,"Please connect Onairos Personality to send ",o," your data")):n().createElement("div",{className:"mobile-connections-list"},Object.keys(r).filter((t=>r[t])).map(((t,e)=>{const i=r[t],s=h.includes(i.type);return n().createElement(Kv,{key:t,active:s,title:i.type,id:i,number:e,descriptions:i.descriptions,rewards:i.reward,size:t,changeGranted:v,onSelectionChange:e=>function(t,e,n,r,o,i){const s=new Date,a={requester:t,date:s.toISOString(),name:r,reward:o,data:e};i?y.current.find((n=>n.requester===t&&n.data===e))||(y.current=[...y.current,a]):y.current=y.current.filter((n=>!(n.requester===t&&n.data===e)))}(o,t,0,i.type,i.reward,e)})})))))};function Wv(){return"undefined"!=typeof chrome&&chrome.runtime?chrome.runtime.getURL("data_request_iframe.html"):"/data_request_iframe.html"}function zv(t){if(t&&!t.closed)try{t.close(),window.postMessage({action:"terminalClosed"},"*")}catch(t){console.error("Error closing iframe:",t)}}const Hv=async()=>(await a.e(423).then(a.t.bind(a,153,23))).default;function qv(t){var r,o;let{requestData:i,webpageName:s,inferenceData:c=null,onComplete:l=null,autoFetch:u=!0,proofMode:h=!1,textLayout:d="below",textColor:f="white",login:p=!1,buttonType:m="pill",loginReturn:g=null,loginType:y="signIn",visualType:w="full"}=t;const v=()=>{const t=navigator.userAgent||navigator.vendor||window.opera;return void 0!==window.Telegram&&/telegram/i.test(t)&&/mobile/i.test(navigator.userAgent)},b=()=>void 0!==a.g&&void 0!==a.g.nativeModuleProxy||"undefined"!=typeof navigator&&"ReactNative"===navigator.product,[E,S]=(0,e.useState)(null);(0,e.useEffect)((()=>{let t=!0;if(v()){const n=(0,e.useMemo)(Qf,[]);t&&S(n)}return()=>{t=!1}}),[]),(0,e.useEffect)((()=>{if(E&&(console.log("Launch Params:",E),E.startParam))try{mt("Received parameters: ".concat(E.startParam)),tt({show:!0,type:"callback",data:{startParam:E.startParam}})}catch(t){console.error("Error parsing launch params:",t)}}),[E]),(0,e.useEffect)((()=>{if(v())try{var t;const e=null===(t=window.Telegram)||void 0===t?void 0:t.WebApp;e&&e.ready()}catch(t){console.error("Error initializing Telegram WebApp:",t)}}),[]);const[x,T]=(0,e.useState)(null),[A,_]=(0,e.useState)(!1),[k,R]=(0,e.useState)([]),[C,P]=(0,e.useState)(0),[I,O]=(0,e.useState)({}),[N,B]=(0,e.useState)(!1),[U,L]=(0,e.useState)(!1),[j,D]=(0,e.useState)(!1),[M,V]=(0,e.useState)(!1),F=(0,e.useRef)(!1),K=(0,e.useRef)(!1),[$,W]=(0,e.useState)(!1),[z,H]=(0,e.useState)(null),[q,Z]=(0,e.useState)(!0),[X,G]=(0,e.useState)(null),[Y,J]=(0,e.useState)(null),[Q,tt]=(0,e.useState)({show:!1,type:null,data:null}),[et,nt]=(0,e.useState)(null),[rt,ot]=(0,e.useState)(!1),[it,st]=(0,e.useState)(!1),at=(0,e.useRef)(!1),[ct,lt]=(0,e.useState)(null),[ut,ht]=(0,e.useState)({show:!1,color:null,message:null}),[dt,ft]=(0,e.useState)(null),[pt,mt]=(0,e.useState)("Initializing..."),gt="https://api2.onairos.uk";(0,e.useEffect)((()=>{if(!v())return;(async()=>{const t=new URL(window.location.href),e=t.searchParams.get("code"),n=t.searchParams.get("state");if(e&&n&&!at.current&&!it){at.current=!0,st(!0);try{const t=await fetch("".concat(gt,"/auth/callback"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:e,state:n})});if(!t.ok)throw new Error("Failed to get Othent token");const{sessionId:r}=await t.json();(async()=>{const t=setInterval((async()=>{try{const e=await fetch("".concat(gt,"/auth/token/").concat(r),{method:"GET",headers:{"Content-Type":"application/json"}});if(!e.ok)throw new Error("HTTP error! Status: ".concat(e.status));const n=await e.json();n.othentToken&&(clearInterval(t),await yt(n.othentToken),V(!0),window.history.replaceState({},document.title,window.location.pathname))}catch(e){console.error("Error polling for token:",e),clearInterval(t),lt("Failed to retrieve authentication token"),st(!1)}}),3e3);setTimeout((()=>{clearInterval(t),M||(lt("Authentication timeout"),st(!1))}),12e4)})()}catch(t){console.error("Auth callback processing failed:",t),lt(t.message),st(!1)}}})()}),[]);const yt=async t=>{try{const e=new jr({appInfo:{name:"Onairos",version:"1.0.0",env:"production"},throwErrors:!0,auth0LogInMethod:"redirect",auth0RedirectURI:window.location.href,auth0ReturnToURI:window.location.href}),n=await e.completeConnectionWithToken(t);W(!0);const r=(await Hv())(n.sub).toString();G(r);const o=await Dr(r);J(o.result),H(o.token),await Pt(n.email,!0),_(!0),localStorage.setItem("othentToken",JSON.stringify(n)),localStorage.setItem("onairosToken",n.token)}catch(t){throw ht({show:!0,color:"red",message:"An error has occurred, please try again"}),console.error("Authentication failed:",t),t}finally{st(!1)}};(0,e.useEffect)((()=>{ct&&console.error("Authentication error:",ct)}),[ct]);const wt=()=>{const t=navigator.userAgent||navigator.vendor||window.opera;return/android|iphone|ipad|ipod|windows phone/i.test(t)};(0,e.useEffect)((()=>{if(u&&c&&"function"==typeof l){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:n,accessToken:r}=t.data,o=(t=>{const e={Small:16,Medium:32,Large:64};let n=null,r=0;return t.forEach((t=>{const o=e[t.data];o>r&&(r=o,n=t)})),r})(n),i={Input:c.slice(0,o)};try{const t=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(r)},body:JSON.stringify(i)}),n=await t.json();l(n)}catch(t){console.error(t),l(null,t)}}};return window.addEventListener("message",t),()=>{window.removeEventListener("message",t)}}}),[]);const vt=async()=>{if(wt()||b()){if(b()){console.log("React Native detected - setting up data request overlay");R({hashedOthentSub:"mock-othent-sub-hash",encryptedUserPin:"mock-encrypted-pin",activeModels:["Personality","Demographics"],requestData:i||{data_type:"personality",data_fields:["openness","conscientiousness","extraversion","agreeableness","neuroticism"]}}.activeModels)}_(!0)}},bt=window.location.href,[Et,St]=(0,e.useState)(null),xt=(0,e.useRef)(null);(0,e.useEffect)((()=>()=>{xt.current&&xt.current(),Et&&zv(Et)}),[Et]);const Tt=async t=>{try{console.log("Approved data requests:",t),await _t(t)}catch(t){console.error("Error handling approved request:",t)}finally{St(null)}},At=async()=>{try{console.log("Data request rejected by user"),O({}),P(0)}catch(t){console.error("Error handling rejected request:",t)}finally{St(null)}},_t=async t=>{try{const e="https://api2.onairos.uk/inferenceTest";_(!1),l&&"function"==typeof l&&await l({success:!0,apiUrl:e,approvedRequests:t||["personality"]})}catch(t){throw console.error("Error in handleDataRequestCompletion:",t),t}},kt="flex items-center justify-center font-bold rounded cursor-pointer ".concat("pill"===m?"px-4 py-2":"w-12 h-12"," ").concat(p?"bg-white border border-gray-300":"bg-transparent","\n ").concat(wt()?"":"OnairosConnect","\n "),Rt={flexDirection:"below"===d?"column":"row",backgroundColor:p?"#ffffff":"transparent",color:p?"black":f,border:p?"1px solid #ddd":"1px solid transparent"},Ct={width:"20px",height:"20px",marginRight:"full"===w?"12px":"0"},Pt=async function(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];try{const n=e?{Info:{identifier:t}}:{Info:{userName:t}},r=e?"/getAccountInfo/email":"/getAccountInfo",o=await fetch("".concat(gt).concat(r),{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(localStorage.getItem("onairosToken"))},body:JSON.stringify(n)});if(!o.ok)throw new Error("Failed to fetch account info");const i=await o.json();return"No Account Found"===i.AccountInfo?(F.current=!0,nt(null),null):(nt(i.AccountInfo),i.AccountInfo.models?R(i.AccountInfo.models):K.current=!0,i.AccountInfo.avatar&&B(!0),i.AccountInfo.UserTraits&&L(!0),i.AccountInfo.othent&&D(!0),i.AccountInfo)}catch(t){throw console.error("Error fetching account info:",t),t}};(0,e.useEffect)((()=>{wt()&&(async()=>{try{const t=localStorage.getItem("onairosToken"),e=localStorage.getItem("token"),n=t||e;if(n){const t=await fetch("https://api2.onairos.uk/verifyToken",{headers:{Authorization:"Bearer ".concat(n)}});if(t.ok)if((await t.json()).valid){H(n),W(!0);const t=localStorage.getItem("username");await Pt(t)}else localStorage.removeItem("onairosToken"),localStorage.removeItem("token")}}catch(t){console.error("Token verification failed:",t)}finally{Z(!1)}})()}),[]);(0,e.useEffect)((()=>{const t=localStorage.getItem("onairosToken"),e=localStorage.getItem("username");t&&e&&Pt(e,!1)}),[]);return(0,e.useEffect)((()=>{(async()=>{const t=localStorage.getItem("onairosToken"),e=localStorage.getItem("username"),n=localStorage.getItem("othentToken");if(t)try{if((await fetch("".concat(gt,"/verifyToken"),{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(t)}})).ok){if(W(!0),e)await Pt(e,!1);else if(n){const t=JSON.parse(n);await Pt(t.email,!0)}}else localStorage.removeItem("onairosToken"),localStorage.removeItem("username"),localStorage.removeItem("othentToken")}catch(t){console.error("Token verification failed:",t)}})()}),[]),n().createElement(n().Fragment,null,n().createElement("div",{className:"flex items-center justify-center"},n().createElement("button",{className:kt,onClick:async()=>{if(b())return console.log("React Native environment detected"),void await vt();if(wt())await vt();else{console.log("openTerminal clicked");try{const t=function(){try{const t=document.createElement("iframe");t.setAttribute("src",Wv()),t.setAttribute("title","Onairos Terminal"),t.classList.add("iframe-class"),t.style.width="100%",t.style.height="600px",t.style.border="none",t.style.backgroundColor="transparent";const e=400,n=600,r=10,o=window.innerWidth-e-10,i=window.open(Wv(),"Onairos Terminal","width=".concat(e,",height=").concat(n,",top=").concat(r,",left=").concat(o,",resizable=no"));if(!i)throw new Error("Failed to open window - popup blocked");return i.document.body.style.margin="0",i.document.body.style.padding="0",i.document.body.style.overflow="hidden",i.addEventListener("beforeunload",(()=>{window.postMessage({action:"terminalClosed"},"*")})),i}catch(t){return console.error("Error opening iframe:",t),alert("Unable to open Onairos Terminal. Please ensure popups are allowed for this site."),null}}();if(!t)return void console.error("Failed to open iframe window");St(t);const e=function(t){const e=e=>{e.data&&"onairosIframe"===e.data.source&&t(e.data)};return window.addEventListener("message",e),()=>{window.removeEventListener("message",e)}}((async e=>{try{"iframeReady"===e.action?await function(t,e){return new Promise(((n,r)=>{if(t&&!t.closed)try{t.postMessage(e,"*");const o=setTimeout((()=>{r(new Error("Timeout waiting for iframe response"))}),5e3),i=t=>{t.data&&"dataReceived"===t.data.action&&(clearTimeout(o),window.removeEventListener("message",i),n())};window.addEventListener("message",i)}catch(t){r(t)}else r(new Error("Iframe window is not available"))}))}(t,{type:"initDataRequest",requestData:i,dataRequester:s,activeModels:k,avatar:N,traits:U,domain:bt,proofMode:h,HashedOthentSub:X,EncryptedUserPin:Y}):"dataRequestConfirmed"===e.action?await Tt(e.approvedRequests):"dataRequestRejected"===e.action?await At():"terminalClosed"===e.action&&St(null)}catch(e){console.error("Error handling iframe message:",e),zv(t),St(null)}}));xt.current=e}catch(t){console.error("Error in openTerminal:",t),St(null)}}},style:Rt},("full"===w||"icon"===w)&&n().createElement("img",{src:p?"https://onairos.sirv.com/Images/OnairosWhite.png":"https://onairos.sirv.com/Images/OnairosBlack.png",alt:"Onairos Logo",style:Ct,className:"".concat("pill"===m?"w-6 h-6":"w-8 h-8"," object-contain")}),("full"===w||"textOnly"===w)&&n().createElement("span",{className:"".concat(p||"black"===f?"text-black":"text-white"," ").concat("icon"===w?"sr-only":""," ").concat("right"===d?"ml-2":"left"===d?"mr-2":"")},(()=>{switch(y){case"signUp":return"Sign Up with Onairos";case"signOut":return"Sign Out of Onairos";default:return"Sign In with Onairos"}})()))),A&&b()&&n().createElement(md,{onClose:()=>_(!1)},n().createElement("div",{style:{height:"60vh",overflow:"auto"}},n().createElement($v,{requestData:{personality:{type:"Personality",descriptions:"Access to your personality traits",reward:"Premium features"},demographics:{type:"Demographics",descriptions:"Basic demographic information",reward:"Personalized experience"}},dataRequester:s||"App",activeModels:k,onComplete:_t,onCancel:()=>_(!1)}))),A&&!b()&&n().createElement(md,{onClose:()=>_(!1)},F.current?n().createElement("div",{className:"no-account"},"No Onairos Account Found"):K.current?n().createElement("div",{className:"no-model"},"No Model Found"):n().createElement("div",{className:"data-request-container"},"Data Request")),Q.show&&n().createElement("div",{className:"fixed inset-0 z-50 flex items-center justify-center"},n().createElement("div",{className:"fixed inset-0 bg-black bg-opacity-50",onClick:()=>tt({show:!1,type:null,data:null})}),n().createElement("div",{className:"relative bg-white rounded-lg p-6 max-w-lg w-full mx-4 max-h-[80vh] overflow-y-auto"},n().createElement("button",{onClick:()=>tt({show:!1,type:null,data:null}),className:"absolute top-4 right-4 text-gray-400 hover:text-gray-600"},n().createElement("span",{className:"sr-only"},"Close"),n().createElement("svg",{className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},n().createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"}))),n().createElement("h3",{className:"text-lg font-semibold mb-4"},"callback"===Q.type?"Callback Details":"Authentication Result"),n().createElement("h3",{className:"text-lg font-semibold mb-4"},"debug"===Q.type?"Debug Results":"Authentication Result"),n().createElement("h3",{className:"text-lg font-semibold mb-4"},"apiURL"===Q.type?"API Url Returned":"Authentication Result"),n().createElement("div",{className:"bg-gray-50 rounded p-4 overflow-x-auto"},n().createElement("pre",{className:"text-sm"},JSON.stringify(Q.data,null,2))),"auth"===Q.type&&n().createElement("div",{className:"mt-4 p-3 rounded ".concat(null!==(r=Q.data)&&void 0!==r&&r.success?"bg-green-100 text-green-700":"bg-red-100 text-red-700")},null!==(o=Q.data)&&void 0!==o&&o.success?"Authentication successful!":"Authentication failed"))),rt&&n().createElement("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50"},n().createElement("div",{className:"bg-white p-6 rounded-lg shadow-lg w-80"},n().createElement("div",{className:"flex justify-center mb-4"},n().createElement("div",{className:"animate-spin rounded-full h-10 w-10 border-b-2 border-gray-900"})),n().createElement("p",{className:"text-center text-gray-700"},"Loading..."))),it&&n().createElement("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50"},n().createElement("div",{className:"bg-white p-6 rounded-lg shadow-lg w-80"},n().createElement("div",{className:"flex justify-center mb-4"},n().createElement("div",{className:"animate-spin rounded-full h-10 w-10 border-b-2 border-gray-900"})),n().createElement("p",{className:"text-center text-gray-700"},"Attempting to connect your Onairos Account..."))),et&&n().createElement(md,{onClose:()=>{P(0),_(!1)},userData:x,avatar:N,traits:U,othentUser:j,othentConnected:M,setIsAuthenticated:W,authToken:z,setAuthToken:H,hashedOthentSub:X,setHashedOthentSub:G,encryptedPin:Y,setEncryptedPin:J}))}function Zv(t){return n().createElement(n().Fragment,null,n().createElement(qv,t))}const Xv=Zv})(),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,o,i={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 o=this.stringToBigNum(t,r).shiftedBy(-12);return e?o.toFormat(r):o.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 o{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(`${o.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(`${o.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=o},879:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const n=r(498),o=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 o.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,o=new Uint8Array(r);let i=0;for(;i<r;){let t;this.api.config.logging&&console.log(`[chunk] ${i}/${r}`);try{t=await this.getChunkData(n+i)}catch(t){console.error(`[chunk] Failed to fetch chunk at offset ${n+i}`),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 ${i}/${r}`);o.set(t,i),i+=t.length}return o}}},536:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const n=r(586),o=r(874),i=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 i.default;static utils=l;constructor(t){this.api=new o.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 o=await this.silo.parseUri(r);if("string"==typeof t.data){const e=await this.crypto.encrypt(l.stringToBuffer(t.data),o.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,o.getEncryptionKey());n.reward=await this.transactions.getPrice(e.byteLength),n.data=l.bufferTob64Url(e)}const i=new u.default(n);return i.addTag("Silo-Name",o.getAccessKey()),i.addTag("Silo-Version","0.1.0"),i}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 o=Object.getOwnPropertyDescriptor(e,r);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,o)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),o=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 i=r(536),s=r(118);i.default.init=function(t={}){const e={host:"arweave.net",port:443,protocol:"https"};if("object"!=typeof location||!location.protocol||!location.hostname)return new i.default({...t,...e});const r=location.protocol.replace(":",""),n=location.hostname,o=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||o;return new i.default({...t,host:u,protocol:c,port:l})},"object"==typeof globalThis?globalThis.Arweave=i.default:"object"==typeof self&&(self.Arweave=i.default),o(r(536),e),e.default=i.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||{}),o=`${this.config.protocol}://${this.config.host}:${this.config.port}`,i=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: ${o}/${t}`);let s=await fetch(`${o}/${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"===i)u.data=await s.arrayBuffer();else if("text"===i)await l();else if("webstream"===i)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},o=await this.jwkToPublicCryptoKey(n),i=await this.driver.digest("SHA-256",e),s=await this.driver.verify({name:"RSA-PSS",saltLength:0},o,r,e),a=await this.driver.verify({name:"RSA-PSS",saltLength:32},o,r,e),c=await this.driver.verify({name:"RSA-PSS",saltLength:Math.ceil((o.algorithm.modulusLength-1)/8)-i.byteLength-2},o,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 o=await this.driver.importKey("raw","string"==typeof e?n.stringToBuffer(e):e,{name:"PBKDF2",length:32},!1,["deriveKey"]),i=await this.driver.deriveKey({name:"PBKDF2",salt:r?n.stringToBuffer(r):n.stringToBuffer("salt"),iterations:1e5,hash:"SHA-256"},o,{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},i,t);return n.concatBuffers([s,a])}async decrypt(t,e,r){const o=await this.driver.importKey("raw","string"==typeof e?n.stringToBuffer(e):e,{name:"PBKDF2",length:32},!1,["deriveKey"]),i=await this.driver.deriveKey({name:"PBKDF2",salt:r?n.stringToBuffer(r):n.stringToBuffer("salt"),iterations:1e5,hash:"SHA-256"},o,{name:"AES-CBC",length:256},!1,["encrypt","decrypt"]),s=t.slice(0,16),a=await this.driver.decrypt({name:"AES-CBC",iv:s},i,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 o(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 i(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 i(t,e){if(t.length<1)return e;const r=n.default.utils.concatBuffers([e,await o(t[0])]),s=await n.default.crypto.hash(r,"SHA-384");return await i(t.slice(1),s)}e.default=o},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),o=r(244);e.MAX_CHUNK_SIZE=262144,e.MIN_CHUNK_SIZE=32768;const i=32,s=32;async function a(t){let r=[],o=t,i=0;for(;o.byteLength>=e.MAX_CHUNK_SIZE;){let t=e.MAX_CHUNK_SIZE,s=o.byteLength-e.MAX_CHUNK_SIZE;s>0&&s<e.MIN_CHUNK_SIZE&&(t=Math.ceil(o.byteLength/2));const a=o.slice(0,t),c=await n.default.crypto.hash(a);i+=a.byteLength,r.push({dataHash:c,minByteRange:i-a.byteLength,maxByteRange:i}),o=o.slice(t)}return r.push({dataHash:await n.default.crypto.hash(o),minByteRange:i,maxByteRange:i+o.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,o.concatBuffers)([e,t.dataHash,y(t.maxByteRange)])};if("branch"==t.type){const n=(0,o.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(i);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),o=await h(n),i=e.slice(-1)[0];return i.maxByteRange-i.minByteRange==0&&(e.splice(e.length-1,1),o.splice(o.length-1,1)),{data_root:n.id,chunks:e,proofs:o}},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,o,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+i){const t=c.slice(0,s),n=c.slice(t.length,t.length+i),u=await g([await g(t),await g(n)]);return!!(0,e.arrayCompare)(r,u)&&{offset:a-1,leftBound:o,rightBound:a,chunkSize:a-o}}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+i),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,o,Math.min(a,f),d):await t(l,n,Math.max(o,f),a,d))},e.debug=async function t(e,r=""){if(e.byteLength<1)return r;const n=e.slice(0,s),o=e.slice(n.length,n.length+s),a=e.slice(n.length+o.length,n.length+o.length+i),c=w(a),u=e.slice(n.length+o.length+a.length),l=await g([await g(n),await g(o),await g(a)]);return t(u,`${r}\n${JSON.stringify(Buffer.from(n))},${JSON.stringify(Buffer.from(o))},${c} => ${JSON.stringify(l)}`)}},246:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.TransactionUploader=void 0;const n=r(825),o=r(244),i=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),o.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,i.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 o=new n.default(e.transaction);o.chunks||await o.prepareChunks(r);const i=new c(t,o);if(i.chunkIndex=e.chunkIndex,i.lastRequestTimeEnd=e.lastRequestTimeEnd,i.lastResponseError=e.lastResponseError,i.lastResponseStatus=e.lastResponseStatus,i.txPosted=e.txPosted,i.data=r,i.transaction.data_root!==e.transaction.data_root)throw new Error("Data mismatch: Uploader doesn't match provided data.");return i}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,i.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,i.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),o=r(921),i=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:o}){this.id=t,this.owner=e,r&&(this.reward=r),n&&(this.tags=n),this.signature=o}async prepareChunks(t){!this.chunks&&t.byteLength>0&&(this.chunks=await(0,i.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],o=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(o.minByteRange,o.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,o.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 o(t){return new TextDecoder("utf-8",{fatal:!0}).decode(t)}function i(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 o(s(t))},e.bufferToString=o,e.stringToBuffer=i,e.stringToB64Url=function(t){return c(i(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("."),o=n[n.length-1],i=["localhost","[::1]"];return i.includes(e)||"file"==t||i.includes(o)||!!e.match(r)||!!o.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 o=n.get("data",{decode:!0,string:!1});return this.crypto.decrypt(o,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],i=Math.pow(2,parseInt(e[2])),s=await this.hash(n.stringToBuffer(r),i),a=n.bufferTob64(s.slice(0,15)),c=await this.hash(s.slice(16,31),1);return new o(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 o{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=o},935:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const n=r(498),o=r(825),i=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 o.default({...e.data,data:r})}return new o.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 o.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:o,statusText:i}=await this.api.get(`/${t}`,{responseType:"arraybuffer"});if(!n)throw new Error("Bad http status code",{cause:{status:o,statusText:i}});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?i.bufferToString(r):i.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),o="object"==typeof arweaveWallet;if(!n&&!o)throw new Error("No valid JWK or external wallet found to sign transaction.");if(n){t.setOwner(e.n);let n=await t.getSignatureData(),o=await this.crypto.sign(e,n,r),s=await this.crypto.hash(o);t.setSignature({id:i.bufferTob64Url(s),owner:e.n,signature:i.bufferTob64Url(o)})}else{if(!o)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=i.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 o.default(JSON.parse(t)):"function"==typeof t.readInt32BE?t=new o.default(JSON.parse(t.toString())):"object"!=typeof t||t instanceof o.default||(t=new o.default(t)),!(t instanceof o.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 o.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,i=a(t),s=i[0],c=i[1],u=new o(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,o=n%3,i=[],s=16383,a=0,u=n-o;a<u;a+=s)i.push(c(t,a,a+s>u?u:a+s));1===o?(e=t[n-1],i.push(r[e>>2]+r[e<<4&63]+"==")):2===o&&(e=(t[n-2]<<8)+t[n-1],i.push(r[e>>10]+r[e>>4&63]+r[e<<2&63]+"="));return i.join("")};for(var r=[],n=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0;s<64;++s)r[s]=i[s],n[i.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 o,i,s=[],a=e;a<n;a+=3)o=(t[a]<<16&16711680)+(t[a+1]<<8&65280)+(255&t[a+2]),s.push(r[(i=o)>>18&63]+r[i>>12&63]+r[i>>6&63]+r[63&i]);return s.join("")}n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63},431:function(t,e,r){var n;!function(o){"use strict";var i,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,o=t.length,i=t[0]+"";n<o;){for(e=t[n++]+"",r=f-e.length;r--;e="0"+e);i+=e}for(o=i.length;48===i.charCodeAt(--o););return i.slice(0,o+1||1)}function b(t,e){var r,n,o=t.c,i=e.c,s=t.s,a=e.s,c=t.e,u=e.e;if(!s||!a)return null;if(r=o&&!o[0],n=i&&!i[0],r||n)return r?n?0:-a:s;if(s!=a)return s;if(r=s<0,n=c==u,!o||!i)return n?0:!o^r?1:-1;if(!n)return c>u^r?1:-1;for(a=(c=o.length)<(u=i.length)?c:u,s=0;s<a;s++)if(o[s]!=i[s])return o[s]>i[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 _(t){var e=t.c.length-1;return w(t.e/f)==e&&t.c[e]%2!=0}function E(t,e){return(t.length>1?t.charAt(0)+"."+t.slice(1):t)+(e<0?"e":"e+")+e}function S(t,e,r){var n,o;if(e<0){for(o=r+".";++e;o+=r);t=o+t}else if(++e>(n=t.length)){for(o=r,e-=n;--e;o+=r);t+=o}else e<n&&(t=t.slice(0,e)+"."+t.slice(e));return t}i=function t(e){var r,n,o,i,A,T,k,I,O,R,C=z.prototype={constructor:z,toString:null,valueOf:null},U=new z(1),B=20,P=4,L=-7,x=21,N=-1e7,j=1e7,D=!1,K=1,M=0,$={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},F="0123456789abcdefghijklmnopqrstuvwxyz",W=!0;function z(t,e){var r,i,a,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(!s.test(y=String(t)))return o(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,F.length,"Base"),10==e&&W)return X(w=new z(t),B+w.e+1,P);if(y=String(t),p="number"==typeof t){if(0*t!=0)return o(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=F.slice(0,e),u=h=0,g=y.length;h<g;h++)if(r.indexOf(i=y.charAt(h))<0){if("."==i){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 o(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 Z(t,e,r,n){var o,i,s,a,c;if(null==r?r=P:v(r,0,8),!t.c)return t.toString();if(o=t.c[0],s=t.e,null==e)c=m(t.c),c=1==n||2==n&&(s<=L||s>=x)?E(c,s):S(c,s,"0");else if(i=(t=X(new z(t),e,r)).e,a=(c=m(t.c)).length,1==n||2==n&&(e<=i||i<=L)){for(;a<e;c+="0",a++);c=E(c,i)}else if(e-=s,c=S(c,i,"0"),i+1>a){if(--e>0)for(c+=".";e--;c+="0");}else if((e+=i-a)>0)for(i+1==a&&(c+=".");e--;c+="0");return t.s<0&&o?"-"+c:c}function H(t,e){for(var r,n,o=1,i=new z(t[0]);o<t.length;o++)(!(n=new z(t[o])).s||(r=b(i,n))===e||0===r&&i.s===e)&&(i=n);return i}function V(t,e,r){for(var n=1,o=e.length;!e[--o];e.pop());for(o=e[0];o>=10;o/=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 o,i,s,u,l,d,g,y=t.c,w=p;if(y){t:{for(o=1,u=y[0];u>=10;u/=10,o++);if((i=e-o)<0)i+=f,s=e,l=y[d=0],g=c(l/w[o-s-1]%10);else if((d=a((i+1)/f))>=y.length){if(!n)break t;for(;y.length<=d;y.push(0));l=g=0,o=1,s=(i%=f)-f+1}else{for(l=u=y[d],o=1;u>=10;u/=10,o++);g=(s=(i%=f)-f+o)<0?0:c(l/w[o-s-1]%10)}if(n=n||e<0||null!=y[d+1]||(s<0?l:l%w[o-s-1]),n=r<4?(g||n)&&(0==r||r==(t.s<0?3:2)):g>5||5==g&&(4==r||n||6==r&&(i>0?s>0?l/w[o-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==i?(y.length=d,u=1,d--):(y.length=d+1,u=w[f-i],y[d]=s>0?c(l/w[o-s]%w[s])*u:0),n)for(;;){if(0==d){for(i=1,s=y[0];s>=10;s/=10,i++);for(s=y[0]+=u,u=1;s>=10;s/=10,u++);i!=u&&(t.e++,y[0]==h&&(y[0]=1));break}if(y[d]+=u,y[d]!=h)break;y[d--]=0,u=1}for(i=y.length;0===y[--i];y.pop());}t.e>j?t.c=t.e=null:t.e<N&&(t.c=[t.e=0])}return t}function J(t){var e,r=t.e;return null===r?t.toString():(e=m(t.c),e=r<=L||r>=x?E(e,r):S(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),B=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),L=r[0],x=r[1]):(v(r,-y,y,e),L=-(x=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);$=r}if(t.hasOwnProperty(e="ALPHABET")){if("string"!=typeof(r=t[e])||/^.?$|[+\-.\s]|(.).*\1/.test(r))throw Error(u+e+" invalid: "+r);W="0123456789"==r.slice(0,10),F=r}}return{DECIMAL_PLACES:B,ROUNDING_MODE:P,EXPONENTIAL_AT:[L,x],RANGE:[N,j],CRYPTO:D,MODULO_MODE:K,POW_PRECISION:M,FORMAT:$,ALPHABET:F}},z.isBigNumber=function(t){if(!t||!0!==t._isBigNumber)return!1;if(!z.DEBUG)return!0;var e,r,n=t.c,o=t.e,i=t.s;t:if("[object Array]"=={}.toString.call(n)){if((1===i||-1===i)&&o>=-y&&o<=y&&o===c(o)){if(0===n[0]){if(0===o&&1===n.length)return!0;break t}if((e=(o+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===o&&(null===i||1===i||-1===i))return!0;throw Error(u+"Invalid BigNumber: "+t)},z.maximum=z.max=function(){return H(arguments,-1)},z.minimum=z.min=function(){return H(arguments,1)},z.random=(i=9007199254740992,A=Math.random()*i&2097151?function(){return c(Math.random()*i)}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)},function(t){var e,r,n,o,i,s=0,l=[],h=new z(U);if(null==t?t=B:v(t,0,y),o=a(t/f),D)if(crypto.getRandomValues){for(e=crypto.getRandomValues(new Uint32Array(o*=2));s<o;)(i=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(i%1e14),s+=2);s=o/2}else{if(!crypto.randomBytes)throw D=!1,Error(u+"crypto unavailable");for(e=crypto.randomBytes(o*=7);s<o;)(i=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(i%1e14),s+=7);s=o/7}if(!D)for(;s<o;)(i=A())<9e15&&(l[s++]=i%1e14);for(o=l[--s],t%=f,o&&t&&(i=p[f-t],l[s]=c(o/i)*i);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,i=l[0];i>=10;i/=10,s++);s<f&&(n-=f-s)}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 o,i,s=[0],a=0,c=t.length;a<c;){for(i=s.length;i--;s[i]*=e);for(s[0]+=n.indexOf(t.charAt(a++)),o=0;o<s.length;o++)s[o]>r-1&&(null==s[o+1]&&(s[o+1]=0),s[o+1]+=s[o]/r|0,s[o]%=r)}return s.reverse()}return function(n,o,i,s,a){var c,u,l,h,f,d,p,g,y=n.indexOf("."),w=B,b=P;for(y>=0&&(h=M,M=0,n=n.replace(".",""),d=(g=new z(o)).pow(n.length-y),M=h,g.c=e(S(m(d.c),d.e,"0"),10,i,t),g.e=g.c.length),l=h=(p=e(n,o,i,a?(c=F,t):(c=t,F))).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,i)).c,f=d.r,l=d.e),y=p[u=l+w+1],h=i/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?S(c.charAt(1),-w,c.charAt(0)):c.charAt(0);else{if(p.length=u,f)for(--i;++p[--u]>i;)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=S(n,l,c.charAt(0))}return n}}(),r=function(){function t(t,e,r){var n,o,i,s,a=0,c=t.length,u=e%g,l=e/g|0;for(t=t.slice();c--;)a=((o=u*(i=t[c]%g)+(n=l*i+(s=t[c]/g|0)*u)%g*g+a)/r|0)+(n/g|0)+l*s,t[c]=o%r;return a&&(t=[a].concat(t)),t}function e(t,e,r,n){var o,i;if(r!=n)i=r>n?1:-1;else for(o=i=0;o<r;o++)if(t[o]!=e[o]){i=t[o]>e[o]?1:-1;break}return i}function r(t,e,r,n){for(var o=0;r--;)t[r]-=o,o=t[r]<e[r]?1:0,t[r]=o*n+t[r]-e[r];for(;!t[0]&&t.length>1;t.splice(0,1));}return function(n,o,i,s,a){var u,l,d,p,g,y,m,b,v,_,E,S,A,T,k,I,O,R=n.s==o.s?1:-1,C=n.c,U=o.c;if(!(C&&C[0]&&U&&U[0]))return new z(n.s&&o.s&&(C?!U||C[0]!=U[0]:U)?C&&0==C[0]||!U?0*R:R/0:NaN);for(v=(b=new z(R)).c=[],R=i+(l=n.e-o.e)+1,a||(a=h,l=w(n.e/f)-w(o.e/f),R=R/f|0),d=0;U[d]==(C[d]||0);d++);if(U[d]>(C[d]||0)&&l--,R<0)v.push(1),p=!0;else{for(T=C.length,I=U.length,d=0,R+=2,(g=c(a/(U[0]+1)))>1&&(U=t(U,g,a),C=t(C,g,a),I=U.length,T=C.length),A=I,E=(_=C.slice(0,I)).length;E<I;_[E++]=0);O=U.slice(),O=[0].concat(O),k=U[0],U[1]>=a/2&&k++;do{if(g=0,(u=e(U,_,I,E))<0){if(S=_[0],I!=E&&(S=S*a+(_[1]||0)),(g=c(S/k))>1)for(g>=a&&(g=a-1),m=(y=t(U,g,a)).length,E=_.length;1==e(y,_,m,E);)g--,r(y,I<m?O:U,m,a),m=y.length,u=1;else 0==g&&(u=g=1),m=(y=U.slice()).length;if(m<E&&(y=[0].concat(y)),r(_,y,E,a),E=_.length,-1==u)for(;e(U,_,I,E)<1;)g++,r(_,I<E?O:U,E,a),E=_.length}else 0===u&&(g++,_=[0]);v[d++]=g,_[0]?_[E++]=C[A]||0:(_=[C[A]],E=1)}while((A++<T||null!=_[0])&&R--);p=null!=_[0],v[0]||v.splice(0,1)}if(a==h){for(d=1,R=v[0];R>=10;R/=10,d++);X(b,i+(b.e=d+l*f-1)+1,s,p)}else b.e=l,b.r=+p;return b}}(),T=/^(-?)0([xbo])(?=\w[\w.]*$)/i,k=/^([^.]+)\.$/,I=/^\.([^.]+)$/,O=/^-?(Infinity|NaN)$/,R=/^\s*\+(?=[\w.])|^\s+|\s+$/g,o=function(t,e,r,n){var o,i=r?e:e.replace(R,"");if(O.test(i))t.s=isNaN(i)?null:i<0?-1:1;else{if(!r&&(i=i.replace(T,(function(t,e,r){return o="x"==(r=r.toLowerCase())?16:"b"==r?2:8,n&&n!=o?t:e})),n&&(o=n,i=i.replace(k,"$1").replace(I,"0.$1")),e!=i))return new z(i,o);if(z.DEBUG)throw Error(u+"Not a"+(n?" base "+n:"")+" number: "+e);t.s=null}t.c=t.e=null},C.absoluteValue=C.abs=function(){var t=new z(this);return t.s<0&&(t.s=1),t},C.comparedTo=function(t,e){return b(this,new z(t,e))},C.decimalPlaces=C.dp=function(t,e){var r,n,o,i=this;if(null!=t)return v(t,0,y),null==e?e=P:v(e,0,8),X(new z(i),t+i.e+1,e);if(!(r=i.c))return null;if(n=((o=r.length-1)-w(this.e/f))*f,o=r[o])for(;o%10==0;o/=10,n--);return n<0&&(n=0),n},C.dividedBy=C.div=function(t,e){return r(this,new z(t,e),B,P)},C.dividedToIntegerBy=C.idiv=function(t,e){return r(this,new z(t,e),0,1)},C.exponentiatedBy=C.pow=function(t,e){var r,n,o,i,s,l,h,d,p=this;if((t=new z(t)).c&&!t.isInteger())throw Error(u+"Exponent not an integer: "+J(t));if(null!=e&&(e=new z(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 z(Math.pow(+J(p),s?t.s*(2-_(t)):+J(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||s&&p.c[1]>=24e7:p.c[0]<8e13||s&&p.c[0]<=9999975e7)))return i=p.s<0&&_(t)?-0:0,p.e>-1&&(i=1/i),new z(l?1/i:i);M&&(i=a(M/f+2))}for(s?(r=new z(.5),l&&(t.s=1),h=_(t)):h=(o=Math.abs(+J(t)))%2,d=new z(U);;){if(h){if(!(d=d.times(p)).c)break;i?d.c.length>i&&(d.c.length=i):n&&(d=d.mod(e))}if(o){if(0===(o=c(o/2)))break;h=o%2}else if(X(t=t.times(r),t.e+1,1),t.e>14)h=_(t);else{if(0===(o=+J(t)))break;h=o%2}p=p.times(p),i?p.c&&p.c.length>i&&(p.c.length=i):n&&(p=p.mod(e))}return n?d:(l&&(d=U.div(d)),e?d.mod(e):i?X(d,M,P,undefined):d)},C.integerValue=function(t){var e=new z(this);return null==t?t=P:v(t,0,8),X(e,e.e+1,t)},C.isEqualTo=C.eq=function(t,e){return 0===b(this,new z(t,e))},C.isFinite=function(){return!!this.c},C.isGreaterThan=C.gt=function(t,e){return b(this,new z(t,e))>0},C.isGreaterThanOrEqualTo=C.gte=function(t,e){return 1===(e=b(this,new z(t,e)))||0===e},C.isInteger=function(){return!!this.c&&w(this.e/f)>this.c.length-2},C.isLessThan=C.lt=function(t,e){return b(this,new z(t,e))<0},C.isLessThanOrEqualTo=C.lte=function(t,e){return-1===(e=b(this,new z(t,e)))||0===e},C.isNaN=function(){return!this.s},C.isNegative=function(){return this.s<0},C.isPositive=function(){return this.s>0},C.isZero=function(){return!!this.c&&0==this.c[0]},C.minus=function(t,e){var r,n,o,i,s=this,a=s.s;if(e=(t=new z(t,e)).s,!a||!e)return new z(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 z(d?s:NaN);if(!l[0]||!d[0])return d[0]?(t.s=-e,t):new z(l[0]?s:3==P?-0:0)}if(c=w(c),u=w(u),l=l.slice(),a=c-u){for((i=a<0)?(a=-a,o=l):(u=c,o=d),o.reverse(),e=a;e--;o.push(0));o.reverse()}else for(n=(i=(a=l.length)<(e=d.length))?a:e,a=e=0;e<n;e++)if(l[e]!=d[e]){i=l[e]<d[e];break}if(i&&(o=l,l=d,d=o,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]?V(t,l,u):(t.s=3==P?-1:1,t.c=[t.e=0],t)},C.modulo=C.mod=function(t,e){var n,o,i=this;return t=new z(t,e),!i.c||!t.s||t.c&&!t.c[0]?new z(NaN):!t.c||i.c&&!i.c[0]?new z(i):(9==K?(o=t.s,t.s=1,n=r(i,t,0,3),t.s=o,n.s*=o):n=r(i,t,0,K),(t=i.minus(n.times(t))).c[0]||1!=K||(t.s=i.s),t)},C.multipliedBy=C.times=function(t,e){var r,n,o,i,s,a,c,u,l,d,p,y,m,b,v,_=this,E=_.c,S=(t=new z(t,e)).c;if(!(E&&S&&E[0]&&S[0]))return!_.s||!t.s||E&&!E[0]&&!S||S&&!S[0]&&!E?t.c=t.e=t.s=null:(t.s*=_.s,E&&S?(t.c=[0],t.e=0):t.c=t.e=null),t;for(n=w(_.e/f)+w(t.e/f),t.s*=_.s,(c=E.length)<(d=S.length)&&(m=E,E=S,S=m,o=c,c=d,d=o),o=c+d,m=[];o--;m.push(0));for(b=h,v=g,o=d;--o>=0;){for(r=0,p=S[o]%v,y=S[o]/v|0,i=o+(s=c);i>o;)r=((u=p*(u=E[--s]%v)+(a=y*u+(l=E[s]/v|0)*p)%v*v+m[i]+r)/b|0)+(a/v|0)+y*l,m[i--]=u%b;m[i]=r}return r?++n:m.splice(0,1),V(t,m,n)},C.negated=function(){var t=new z(this);return t.s=-t.s||null,t},C.plus=function(t,e){var r,n=this,o=n.s;if(e=(t=new z(t,e)).s,!o||!e)return new z(NaN);if(o!=e)return t.s=-e,n.minus(t);var i=n.e/f,s=t.e/f,a=n.c,c=t.c;if(!i||!s){if(!a||!c)return new z(o/0);if(!a[0]||!c[0])return c[0]?t:new z(a[0]?n:0*o)}if(i=w(i),s=w(s),a=a.slice(),o=i-s){for(o>0?(s=i,r=c):(o=-o,r=a),r.reverse();o--;r.push(0));r.reverse()}for((o=a.length)-(e=c.length)<0&&(r=c,c=a,a=r,e=o),o=0;e;)o=(a[--e]=a[e]+c[e]+o)/h|0,a[e]=h===a[e]?0:a[e]%h;return o&&(a=[o].concat(a),++s),V(t,a,s)},C.precision=C.sd=function(t,e){var r,n,o,i=this;if(null!=t&&t!==!!t)return v(t,1,y),null==e?e=P:v(e,0,8),X(new z(i),t,e);if(!(r=i.c))return null;if(n=(o=r.length-1)*f+1,o=r[o]){for(;o%10==0;o/=10,n--);for(o=r[0];o>=10;o/=10,n++);}return t&&i.e+1>n&&(n=i.e+1),n},C.shiftedBy=function(t){return v(t,-9007199254740991,d),this.times("1e"+t)},C.squareRoot=C.sqrt=function(){var t,e,n,o,i,s=this,a=s.c,c=s.s,u=s.e,l=B+4,h=new z("0.5");if(1!==c||!a||!a[0])return new z(!c||c<0&&(!a||a[0])?NaN:a?s:1/0);if(0==(c=Math.sqrt(+J(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 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(i=n,n=h.times(i.plus(r(s,i,l,1))),m(i.c).slice(0,c)===(e=m(n.c)).slice(0,c)){if(n.e<u&&--c,"9999"!=(e=e.slice(c-3,c+1))&&(o||"4999"!=e)){+e&&(+e.slice(1)||"5"!=e.charAt(0))||(X(n,n.e+B+2,1),t=!n.times(n).eq(s));break}if(!o&&(X(i,i.e+B+2,0),i.times(i).eq(s))){n=i;break}l+=4,c+=4,o=1}return X(n,n.e+B+1,P,t)},C.toExponential=function(t,e){return null!=t&&(v(t,0,y),t++),Z(this,t,e,1)},C.toFixed=function(t,e){return null!=t&&(v(t,0,y),t=t+this.e+1),Z(this,t,e)},C.toFormat=function(t,e,r){var n,o=this;if(null==r)null!=t&&e&&"object"==typeof e?(r=e,e=null):t&&"object"==typeof t?(r=t,t=e=null):r=$;else if("object"!=typeof r)throw Error(u+"Argument not an object: "+r);if(n=o.toFixed(t,e),o.c){var i,s=n.split("."),a=+r.groupSize,c=+r.secondaryGroupSize,l=r.groupSeparator||"",h=s[0],f=s[1],d=o.s<0,p=d?h.slice(1):h,g=p.length;if(c&&(i=a,a=c,c=i,g-=i),a>0&&g>0){for(i=g%a||a,h=p.substr(0,i);i<g;i+=a)h+=l+p.substr(i,a);c>0&&(h+=l+p.slice(i)),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||"")},C.toFraction=function(t){var e,n,o,i,s,a,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: ")+J(c));if(!b)return new z(w);for(e=new z(U),h=n=new z(U),o=l=new z(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 z(y),l.c[0]=0;d=r(c,e,0,1),1!=(i=n.plus(d.times(o))).comparedTo(t);)n=o,o=i,h=l.plus(d.times(i=h)),l=i,e=c.minus(d.times(i=e)),c=i;return i=r(t.minus(n),o,0,1),l=l.plus(i.times(h)),n=n.plus(i.times(o)),l.s=h.s=w.s,g=r(h,o,s*=2,P).minus(w).abs().comparedTo(r(l,n,s,P).minus(w).abs())<1?[h,o]:[l,n],j=a,g},C.toNumber=function(){return+J(this)},C.toPrecision=function(t,e){return null!=t&&v(t,1,y),Z(this,t,e,2)},C.toString=function(t){var e,r=this,o=r.s,i=r.e;return null===i?o?(e="Infinity",o<0&&(e="-"+e)):e="NaN":(null==t?e=i<=L||i>=x?E(m(r.c),i):S(m(r.c),i,"0"):10===t&&W?e=S(m((r=X(new z(r),B+i+1,P)).c),r.e,"0"):(v(t,2,F.length,"Base"),e=n(S(m(r.c),i,"0"),10,t,o,!0)),o<0&&r.c[0]&&(e="-"+e)),e},C.valueOf=C.toJSON=function(){return J(this)},C._isBigNumber=!0,null!=e&&z.set(e),z}(),i.default=i.BigNumber=i,void 0===(n=function(){return i}.call(e,r,e,t))||(t.exports=n)}()},764:(t,e,r)=>{"use strict";const n=r(742),o=r(645),i="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 o=n.write(t,e);o!==r&&(n=n.slice(0,o));return n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(J(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(J(t,ArrayBuffer)||t&&J(t.buffer,ArrayBuffer))return d(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(J(t,SharedArrayBuffer)||t&&J(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 o=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||q(t.length)?a(0):f(t);if("Buffer"===t.type&&Array.isArray(t.data))return f(t.data)}(t);if(o)return o;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)||J(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 o=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return H(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return V(t).length;default:if(o)return n?-1:H(t).length;e=(""+e).toLowerCase(),o=!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 C(this,e,r);case"utf8":case"utf-8":return k(this,e,r);case"ascii":return O(this,e,r);case"latin1":case"binary":return R(this,e,r);case"base64":return T(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,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),q(r=+r)&&(r=o?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)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,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):b(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function b(t,e,r,n,o){let i,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(o){let n=-1;for(i=r;i<a;i++)if(u(t,i)===u(e,-1===n?0:i-n)){if(-1===n&&(n=i),i-n+1===c)return n*s}else-1!==n&&(i-=i-n),n=-1}else for(r+c>a&&(r=a-c),i=r;i>=0;i--){let r=!0;for(let n=0;n<c;n++)if(u(t,i+n)!==u(e,n)){r=!1;break}if(r)return i}return-1}function v(t,e,r,n){r=Number(r)||0;const o=t.length-r;n?(n=Number(n))>o&&(n=o):n=o;const i=e.length;let s;for(n>i/2&&(n=i/2),s=0;s<n;++s){const n=parseInt(e.substr(2*s,2),16);if(q(n))return s;t[r+s]=n}return s}function _(t,e,r,n){return X(H(e,t.length-r),t,r,n)}function E(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 S(t,e,r,n){return X(V(e),t,r,n)}function A(t,e,r,n){return X(function(t,e){let r,n,o;const i=[];for(let s=0;s<t.length&&!((e-=2)<0);++s)r=t.charCodeAt(s),n=r>>8,o=r%256,i.push(o),i.push(n);return i}(e,t.length-r),t,r,n)}function T(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function k(t,e,r){r=Math.min(t.length,r);const n=[];let o=e;for(;o<r;){const e=t[o];let i=null,s=e>239?4:e>223?3:e>191?2:1;if(o+s<=r){let r,n,a,c;switch(s){case 1:e<128&&(i=e);break;case 2:r=t[o+1],128==(192&r)&&(c=(31&e)<<6|63&r,c>127&&(i=c));break;case 3:r=t[o+1],n=t[o+2],128==(192&r)&&128==(192&n)&&(c=(15&e)<<12|(63&r)<<6|63&n,c>2047&&(c<55296||c>57343)&&(i=c));break;case 4:r=t[o+1],n=t[o+2],a=t[o+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&&(i=c))}}null===i?(i=65533,s=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|1023&i),n.push(i),o+=s}return function(t){const e=t.length;if(e<=I)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=I));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(J(t,Uint8Array)&&(t=c.from(t,t.offset,t.byteLength)),J(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 o=0,i=Math.min(r,n);o<i;++o)if(t[o]!==e[o]){r=t[o],n=e[o];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 o=0;for(r=0;r<t.length;++r){let e=t[r];if(J(e,Uint8Array))o+e.length>n.length?(c.isBuffer(e)||(e=c.from(e)),e.copy(n,o)):Uint8Array.prototype.set.call(n,e,o);else{if(!c.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(n,o)}o+=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?k(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+">"},i&&(c.prototype[i]=c.prototype.inspect),c.prototype.compare=function(t,e,r,n,o){if(J(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===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=r)return 0;if(n>=o)return-1;if(e>=r)return 1;if(this===t)return 0;let i=(o>>>=0)-(n>>>=0),s=(r>>>=0)-(e>>>=0);const a=Math.min(i,s),u=this.slice(n,o),l=t.slice(e,r);for(let t=0;t<a;++t)if(u[t]!==l[t]){i=u[t],s=l[t];break}return i<s?-1:s<i?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 o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let i=!1;for(;;)switch(n){case"hex":return v(this,t,e,r);case"utf8":case"utf-8":return _(this,t,e,r);case"ascii":case"latin1":case"binary":return E(this,t,e,r);case"base64":return S(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const I=4096;function O(t,e,r){let n="";r=Math.min(t.length,r);for(let o=e;o<r;++o)n+=String.fromCharCode(127&t[o]);return n}function R(t,e,r){let n="";r=Math.min(t.length,r);for(let o=e;o<r;++o)n+=String.fromCharCode(t[o]);return n}function C(t,e,r){const n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);let o="";for(let n=e;n<r;++n)o+=G[t[n]];return o}function U(t,e,r){const n=t.slice(e,r);let o="";for(let t=0;t<n.length-1;t+=2)o+=String.fromCharCode(n[t]+256*n[t+1]);return o}function B(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,o,i){if(!c.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||e<i)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}function L(t,e,r,n,o){F(e,n,o,t,r,7);let i=Number(e&BigInt(4294967295));t[r++]=i,i>>=8,t[r++]=i,i>>=8,t[r++]=i,i>>=8,t[r++]=i;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 x(t,e,r,n,o){F(e,n,o,t,r,7);let i=Number(e&BigInt(4294967295));t[r+7]=i,i>>=8,t[r+6]=i,i>>=8,t[r+5]=i,i>>=8,t[r+4]=i;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,o,i){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,i){return e=+e,r>>>=0,i||N(t,0,r,4),o.write(t,e,r,n,23,4),r+4}function D(t,e,r,n,i){return e=+e,r>>>=0,i||N(t,0,r,8),o.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||B(t,e,this.length);let n=this[t],o=1,i=0;for(;++i<e&&(o*=256);)n+=this[t+i]*o;return n},c.prototype.readUintBE=c.prototype.readUIntBE=function(t,e,r){t>>>=0,e>>>=0,r||B(t,e,this.length);let n=this[t+--e],o=1;for(;e>0&&(o*=256);)n+=this[t+--e]*o;return n},c.prototype.readUint8=c.prototype.readUInt8=function(t,e){return t>>>=0,e||B(t,1,this.length),this[t]},c.prototype.readUint16LE=c.prototype.readUInt16LE=function(t,e){return t>>>=0,e||B(t,2,this.length),this[t]|this[t+1]<<8},c.prototype.readUint16BE=c.prototype.readUInt16BE=function(t,e){return t>>>=0,e||B(t,2,this.length),this[t]<<8|this[t+1]},c.prototype.readUint32LE=c.prototype.readUInt32LE=function(t,e){return t>>>=0,e||B(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||B(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},c.prototype.readBigUInt64LE=Y((function(t){W(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,o=this[++t]+256*this[++t]+65536*this[++t]+r*2**24;return BigInt(n)+(BigInt(o)<<BigInt(32))})),c.prototype.readBigUInt64BE=Y((function(t){W(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],o=this[++t]*2**24+65536*this[++t]+256*this[++t]+r;return(BigInt(n)<<BigInt(32))+BigInt(o)})),c.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||B(t,e,this.length);let n=this[t],o=1,i=0;for(;++i<e&&(o*=256);)n+=this[t+i]*o;return o*=128,n>=o&&(n-=Math.pow(2,8*e)),n},c.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||B(t,e,this.length);let n=e,o=1,i=this[t+--n];for(;n>0&&(o*=256);)i+=this[t+--n]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*e)),i},c.prototype.readInt8=function(t,e){return t>>>=0,e||B(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},c.prototype.readInt16LE=function(t,e){t>>>=0,e||B(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||B(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||B(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||B(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},c.prototype.readBigInt64LE=Y((function(t){W(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=Y((function(t){W(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||B(t,4,this.length),o.read(this,t,!0,23,4)},c.prototype.readFloatBE=function(t,e){return t>>>=0,e||B(t,4,this.length),o.read(this,t,!1,23,4)},c.prototype.readDoubleLE=function(t,e){return t>>>=0,e||B(t,8,this.length),o.read(this,t,!0,52,8)},c.prototype.readDoubleBE=function(t,e){return t>>>=0,e||B(t,8,this.length),o.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 o=1,i=0;for(this[e]=255&t;++i<r&&(o*=256);)this[e+i]=t/o&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 o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&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=Y((function(t,e=0){return L(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),c.prototype.writeBigUInt64BE=Y((function(t,e=0){return x(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 o=0,i=1,s=0;for(this[e]=255&t;++o<r&&(i*=256);)t<0&&0===s&&0!==this[e+o-1]&&(s=1),this[e+o]=(t/i>>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 o=r-1,i=1,s=0;for(this[e+o]=255&t;--o>=0&&(i*=256);)t<0&&0===s&&0!==this[e+o+1]&&(s=1),this[e+o]=(t/i>>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=Y((function(t,e=0){return L(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),c.prototype.writeBigInt64BE=Y((function(t,e=0){return x(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 o=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),o},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 o;if(e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o<r;++o)this[o]=t;else{const i=c.isBuffer(t)?t:c.from(t,n),s=i.length;if(0===s)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(o=0;o<r-e;++o)this[o+e]=i[o%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 $(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 F(t,e,r,n,o,i){if(t>r||t<e){const n="bigint"==typeof e?"n":"";let o;throw o=i>3?0===e||e===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(i+1)}${n}`:`>= -(2${n} ** ${8*(i+1)-1}${n}) and < 2 ** ${8*(i+1)-1}${n}`:`>= ${e}${n} and <= ${r}${n}`,new K.ERR_OUT_OF_RANGE("value",o,t)}!function(t,e,r){W(e,"offset"),void 0!==t[e]&&void 0!==t[e+r]||z(e,t.length-(r+1))}(n,o,i)}function W(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 W(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.`,o=r;return Number.isInteger(r)&&Math.abs(r)>2**32?o=$(String(r)):"bigint"==typeof r&&(o=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(o=$(o)),o+="n"),n+=` It must be ${e}. Received ${o}`,n}),RangeError);const Z=/[^+/0-9A-Za-z-_]/g;function H(t,e){let r;e=e||1/0;const n=t.length;let o=null;const i=[];for(let s=0;s<n;++s){if(r=t.charCodeAt(s),r>55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(s+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.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;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function V(t){return n.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 X(t,e,r,n){let o;for(o=0;o<n&&!(o+r>=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function J(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function q(t){return t!=t}const G=function(){const t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){const n=16*r;for(let o=0;o<16;++o)e[n+o]=t[r]+t[o]}return e}();function Y(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,o=Object.getOwnPropertyDescriptor,i=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,o=e.call(t,"constructor"),i=t.constructor&&t.constructor.prototype&&e.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!o&&!i)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(o)return o(t,r).value}return t[r]};t.exports=function t(){var e,r,n,o,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!==(o=c(e,r))&&(p&&o&&(s(o)||(u=i(o)))?(u?(u=!1,l=n&&i(n)?n:[]):l=n&&s(n)?n:{},a(h,{name:r,newValue:t(p,l,o)})):void 0!==o&&a(h,{name:r,newValue:o}));return h}},645:(t,e)=>{e.read=function(t,e,r,n,o){var i,s,a=8*o-n-1,c=(1<<a)-1,u=c>>1,l=-7,h=r?o-1:0,f=r?-1:1,d=t[e+h];for(h+=f,i=d&(1<<-l)-1,d>>=-l,l+=a;l>0;i=256*i+t[e+h],h+=f,l-=8);for(s=i&(1<<-l)-1,i>>=-l,l+=n;l>0;s=256*s+t[e+h],h+=f,l-=8);if(0===i)i=1-u;else{if(i===c)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),i-=u}return(d?-1:1)*s*Math.pow(2,i-n)},e.write=function(t,e,r,n,o,i){var s,a,c,u=8*i-o-1,l=(1<<u)-1,h=l>>1,f=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:i-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,o),s+=h):(a=e*Math.pow(2,h-1)*Math.pow(2,o),s=0));o>=8;t[r+d]=255&a,d+=p,a/=256,o-=8);for(s=s<<o|a,u+=o;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 i[t].call(r.exports,r,r.exports,a),r.exports}a.m=i,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 o=Object.create(null);a.r(o);var i={};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=>i[e]=()=>t[e]));return i.default=()=>t,a.d(o,i),o},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={},o="onairos:",a.l=(t,e,r,i)=>{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")==o+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",o+r),s.src=t),n[t]=[e];var f=(e,r)=>{s.onerror=s.onload=null,clearTimeout(d);var o=n[t];if(delete n[t],s.parentNode&&s.parentNode.removeChild(s),o&&o.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 o=new Promise(((r,o)=>n=t[e]=[r,o]));r.push(n[2]=o);var i=a.p+a.u(e),s=new Error;a.l(i,(r=>{if(a.o(t,e)&&(0!==(n=t[e])&&(t[e]=void 0),n)){var o=r&&("load"===r.type?"missing":r.type),i=r&&r.target&&r.target.src;s.message="Loading chunk "+e+" failed.\n("+o+": "+i+")",s.name="ChunkLoadError",s.type=o,s.request=i,n[1](s)}}),"chunk-"+e,e)}};var e=(e,r)=>{var n,o,i=r[0],s=r[1],c=r[2],u=0;if(i.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<i.length;u++)o=i[u],a.o(t,o)&&t[o]&&t[o][0](),t[o]=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:()=>gh,default:()=>yh});var t={};a.r(t),a.d(t,{hasBrowserEnv:()=>ee,hasStandardBrowserEnv:()=>re,hasStandardBrowserWebWorkerEnv:()=>oe});var e=a(639),r=a.n(e),n=a(764);function o(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 o=0;for(n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(r[n[o]]=t[n[o]])}return r}"function"==typeof SuppressedError&&SuppressedError;var i="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=i&&i.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{c(n.next(t))}catch(t){i(t)}}function a(t){try{c(n.throw(t))}catch(t){i(t)}}function c(t){t.done?o(t.value):new r((function(e){e(t.value)})).then(s,a)}c((n=n.apply(t,e||[])).next())}))},n=i&&i.__generator||function(t,e){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,n=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},o=i;Object.defineProperty(e,"__esModule",{value:!0});var s="browser-tabs-lock-key",a={key:function(t){return r(o,void 0,void 0,(function(){return n(this,(function(t){throw new Error("Unsupported")}))}))},getItem:function(t){return r(o,void 0,void 0,(function(){return n(this,(function(t){throw new Error("Unsupported")}))}))},clear:function(){return r(o,void 0,void 0,(function(){return n(this,(function(t){return[2,window.localStorage.clear()]}))}))},removeItem:function(t){return r(o,void 0,void 0,(function(){return n(this,(function(t){throw new Error("Unsupported")}))}))},setItem:function(t,e){return r(o,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,o){return void 0===o&&(o=5e3),r(this,void 0,void 0,(function(){var r,i,l,h,f,d,p;return n(this,(function(n){switch(n.label){case 0:r=Date.now()+u(4),i=Date.now()+o,l=s+"-"+e,h=void 0===this.storageHandler?a:this.storageHandler,n.label=1;case 1:return Date.now()<i?[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(i)];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 o=this;return n(this,(function(i){return setTimeout((function(){return r(o,void 0,void 0,(function(){var r,o,i;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===(o=r.getItemSync(t))?(l.default().unlock(e),[2]):((i=JSON.parse(o)).timeRefreshed=Date.now(),r.setItemSync(t,JSON.stringify(i)),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,o=Date.now(),i=!1;function s(){if(i||(window.removeEventListener("storage",s),t.removeFromWaiting(s),clearTimeout(a),i=!0),!n){n=!0;var e=50-(Date.now()-o);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,o,i,c;return n(this,(function(n){switch(n.label){case 0:return r=void 0===this.storageHandler?a:this.storageHandler,o=s+"-"+e,null===(i=r.getItemSync(o))?[2]:(c=JSON.parse(i)).id!==this.id?[3,2]:[4,l.default().lock(c.iat)];case 1:n.sent(),this.acquiredIatSet.delete(c.iat),r.removeItemSync(o),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,o=[],i=0;;){var a=n.keySync(i);if(null===a)break;o.push(a),i++}for(var c=!1,u=0;u<o.length;u++){var l=o[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 _ extends g{constructor(t,e){super("missing_refresh_token",`Missing Refresh Token (audience: '${E(t,["default"])}', scope: '${E(e)}')`),this.audience=t,this.scope=e,Object.setPrototypeOf(this,_.prototype)}}function E(t,e=[]){return t&&!e.includes(t)?t:""}const S=()=>window.crypto,A=()=>{const t="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_~.";let e="";return Array.from(S().getRandomValues(new Uint8Array(43))).forEach((r=>e+=t[r%66])),e},T=t=>btoa(t),k=t=>{var{clientId:e}=t,r=o(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()},I=t=>(t=>decodeURIComponent(atob(t).split("").map((t=>"%"+("00"+t.charCodeAt(0).toString(16)).slice(-2))).join("")))(t.replace(/_/g,"/").replace(/-/g,"+")),O=async(t,e)=>{const r=await fetch(t,e);return{ok:r.ok,json:await r.json()}},R=async(t,e,r,n,o,i,s=1e4)=>o?(async(t,e,r,n,o,i,s)=>{return a={auth:{audience:e,scope:r},timeout:o,fetchUrl:t,fetchOptions:n,useFormData:s},c=i,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,o,i):(async(t,e,r)=>{const n=new AbortController;let o;return e.signal=n.signal,Promise.race([O(t,e),new Promise(((t,e)=>{o=setTimeout((()=>{n.abort(),e(new Error("Timeout when executing 'fetch'"))}),r)}))]).finally((()=>{clearTimeout(o)}))})(t,n,s);async function C(t,e){var{baseUrl:r,timeout:n,audience:i,scope:s,auth0Client:a,useFormData:c}=t,u=o(t,["baseUrl","timeout","audience","scope","auth0Client","useFormData"]);const l=c?k(u):JSON.stringify(u);return await async function(t,e,r,n,i,s,a){let c,u=null;for(let o=0;o<3;o++)try{c=await R(t,r,n,i,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=o(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 _(r,n);throw new g(h||"request_error",e)}return d}(`${r}/oauth/token`,n,i||"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 B{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,o]=t.split("::");return new B({clientId:r,scope:o,audience:n},e)}static fromCacheEntry(t){const{scope:e,audience:r,client_id:n}=t;return new B({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 L{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 x{constructor(t,e,r){this.cache=t,this.keyManifest=e,this.nowProvider=r||p}async setIdToken(t,e,r){var n;const o=this.getIdTokenCacheKey(t);await this.cache.set(o,{id_token:e,decodedToken:r}),await(null===(n=this.keyManifest)||void 0===n?void 0:n.add(o))}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 o=await this.nowProvider(),i=Math.floor(o/1e3);return n.expiresAt-e<i?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 B({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 B({clientId:t},"@@auth0spajs@@","@@user@@").toKey()}matchExistingCacheKey(t,e){return e.filter((e=>{var r;const n=B.fromKey(e),o=new Set(n.scope&&n.scope.split(" ")),i=(null===(r=t.scope)||void 0===r?void 0:r.split(" "))||[],s=n.scope&&i.reduce(((t,e)=>t&&o.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=i&&i.__assign||function(){return r=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},r.apply(this,arguments)};function n(t,e){if(!e)return"";var r="; "+t;return!0===e?r:r+"="+e}function o(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,o=0;o<r.length;o++){var i=r[o].split("="),s=i.slice(1).join("=");'"'===s.charAt(0)&&(s=s.slice(1,-1));try{e[i[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=o(t,e,r({path:"/"},n))}e.__esModule=!0,e.encode=o,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,$=K.set,F=K.remove;const W={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),$(t,JSON.stringify(e),n)},remove(t,e){let r={};(null==e?void 0:e.cookieDomain)&&(r.domain=e.cookieDomain),F(t,r)}},z={get:t=>W.get(t)||W.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),$(`_legacy_${t}`,JSON.stringify(e),n),W.save(t,e,r)},remove(t,e){let r={};(null==e?void 0:e.cookieDomain)&&(r.domain=e.cookieDomain),F(t,r),W.remove(t,e),W.remove(`_legacy_${t}`,e)}},Z={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 H,V=("Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwohZnVuY3Rpb24oKXsidXNlIHN0cmljdCI7Y2xhc3MgZSBleHRlbmRzIEVycm9ye2NvbnN0cnVjdG9yKHQscil7c3VwZXIociksdGhpcy5lcnJvcj10LHRoaXMuZXJyb3JfZGVzY3JpcHRpb249cixPYmplY3Quc2V0UHJvdG90eXBlT2YodGhpcyxlLnByb3RvdHlwZSl9c3RhdGljIGZyb21QYXlsb2FkKHtlcnJvcjp0LGVycm9yX2Rlc2NyaXB0aW9uOnJ9KXtyZXR1cm4gbmV3IGUodCxyKX19Y2xhc3MgdCBleHRlbmRzIGV7Y29uc3RydWN0b3IoZSxzKXtzdXBlcigibWlzc2luZ19yZWZyZXNoX3Rva2VuIixgTWlzc2luZyBSZWZyZXNoIFRva2VuIChhdWRpZW5jZTogJyR7cihlLFsiZGVmYXVsdCJdKX0nLCBzY29wZTogJyR7cihzKX0nKWApLHRoaXMuYXVkaWVuY2U9ZSx0aGlzLnNjb3BlPXMsT2JqZWN0LnNldFByb3RvdHlwZU9mKHRoaXMsdC5wcm90b3R5cGUpfX1mdW5jdGlvbiByKGUsdD1bXSl7cmV0dXJuIGUmJiF0LmluY2x1ZGVzKGUpP2U6IiJ9ImZ1bmN0aW9uIj09dHlwZW9mIFN1cHByZXNzZWRFcnJvciYmU3VwcHJlc3NlZEVycm9yO2NvbnN0IHM9ZT0+e3ZhcntjbGllbnRJZDp0fT1lLHI9ZnVuY3Rpb24oZSx0KXt2YXIgcj17fTtmb3IodmFyIHMgaW4gZSlPYmplY3QucHJvdG90eXBlLmhhc093blByb3BlcnR5LmNhbGwoZSxzKSYmdC5pbmRleE9mKHMpPDAmJihyW3NdPWVbc10pO2lmKG51bGwhPWUmJiJmdW5jdGlvbiI9PXR5cGVvZiBPYmplY3QuZ2V0T3duUHJvcGVydHlTeW1ib2xzKXt2YXIgbz0wO2ZvcihzPU9iamVjdC5nZXRPd25Qcm9wZXJ0eVN5bWJvbHMoZSk7bzxzLmxlbmd0aDtvKyspdC5pbmRleE9mKHNbb10pPDAmJk9iamVjdC5wcm90b3R5cGUucHJvcGVydHlJc0VudW1lcmFibGUuY2FsbChlLHNbb10pJiYocltzW29dXT1lW3Nbb11dKX1yZXR1cm4gcn0oZSxbImNsaWVudElkIl0pO3JldHVybiBuZXcgVVJMU2VhcmNoUGFyYW1zKChlPT5PYmplY3Qua2V5cyhlKS5maWx0ZXIoKHQ9PnZvaWQgMCE9PWVbdF0pKS5yZWR1Y2UoKCh0LHIpPT5PYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30sdCkse1tyXTplW3JdfSkpLHt9KSkoT2JqZWN0LmFzc2lnbih7Y2xpZW50X2lkOnR9LHIpKSkudG9TdHJpbmcoKX07bGV0IG89e307Y29uc3Qgbj0oZSx0KT0+YCR7ZX18JHt0fWA7YWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsKGFzeW5jKHtkYXRhOnt0aW1lb3V0OmUsYXV0aDpyLGZldGNoVXJsOmksZmV0Y2hPcHRpb25zOmMsdXNlRm9ybURhdGE6YX0scG9ydHM6W3BdfSk9PntsZXQgZjtjb25zdHthdWRpZW5jZTp1LHNjb3BlOmx9PXJ8fHt9O3RyeXtjb25zdCByPWE/KGU9Pntjb25zdCB0PW5ldyBVUkxTZWFyY2hQYXJhbXMoZSkscj17fTtyZXR1cm4gdC5mb3JFYWNoKCgoZSx0KT0+e3JbdF09ZX0pKSxyfSkoYy5ib2R5KTpKU09OLnBhcnNlKGMuYm9keSk7aWYoIXIucmVmcmVzaF90b2tlbiYmInJlZnJlc2hfdG9rZW4iPT09ci5ncmFudF90eXBlKXtjb25zdCBlPSgoZSx0KT0+b1tuKGUsdCldKSh1LGwpO2lmKCFlKXRocm93IG5ldyB0KHUsbCk7Yy5ib2R5PWE/cyhPYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30scikse3JlZnJlc2hfdG9rZW46ZX0pKTpKU09OLnN0cmluZ2lmeShPYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30scikse3JlZnJlc2hfdG9rZW46ZX0pKX1sZXQgaCxnOyJmdW5jdGlvbiI9PXR5cGVvZiBBYm9ydENvbnRyb2xsZXImJihoPW5ldyBBYm9ydENvbnRyb2xsZXIsYy5zaWduYWw9aC5zaWduYWwpO3RyeXtnPWF3YWl0IFByb21pc2UucmFjZShbKGQ9ZSxuZXcgUHJvbWlzZSgoZT0+c2V0VGltZW91dChlLGQpKSkpLGZldGNoKGksT2JqZWN0LmFzc2lnbih7fSxjKSldKX1jYXRjaChlKXtyZXR1cm4gdm9pZCBwLnBvc3RNZXNzYWdlKHtlcnJvcjplLm1lc3NhZ2V9KX1pZighZylyZXR1cm4gaCYmaC5hYm9ydCgpLHZvaWQgcC5wb3N0TWVzc2FnZSh7ZXJyb3I6IlRpbWVvdXQgd2hlbiBleGVjdXRpbmcgJ2ZldGNoJyJ9KTtmPWF3YWl0IGcuanNvbigpLGYucmVmcmVzaF90b2tlbj8oKChlLHQscik9PntvW24odCxyKV09ZX0pKGYucmVmcmVzaF90b2tlbix1LGwpLGRlbGV0ZSBmLnJlZnJlc2hfdG9rZW4pOigoZSx0KT0+e2RlbGV0ZSBvW24oZSx0KV19KSh1LGwpLHAucG9zdE1lc3NhZ2Uoe29rOmcub2ssanNvbjpmfSl9Y2F0Y2goZSl7cC5wb3N0TWVzc2FnZSh7b2s6ITEsanNvbjp7ZXJyb3I6ZS5lcnJvcixlcnJvcl9kZXNjcmlwdGlvbjplLm1lc3NhZ2V9fSl9dmFyIGR9KSl9KCk7Cgo=",null,!1,function(t){return H=H||function(t,e,r){var n=void 0===e?null:e,o=function(t,e){var r=atob(t);if(e){for(var n=new Uint8Array(r.length),o=0,i=r.length;o<i;++o)n[o]=r.charCodeAt(o);return String.fromCharCode.apply(null,new Uint16Array(n.buffer))}return r}(t,void 0!==r&&r),i=o.indexOf("\n",10)+1,s=o.substring(i)+(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(H,t)});const X={};class J{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 q={memory:()=>(new L).enclosedCache,localstorage:()=>new P},G=t=>q[t],Y=t=>{const{openUrl:e,onRedirect:r}=t,n=o(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 L).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(!S())throw new Error("For security reasons, `window.crypto` is required to run `auth0-spa-js`.");if(void 0===S().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",!G(e))throw new Error(`Invalid cache location "${e}"`);r=G(e)()}this.httpTimeoutMs=t.httpTimeoutInSeconds?1e3*t.httpTimeoutInSeconds:1e4,this.cookieStorage=!1===t.legacySameSiteCookie?W: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:Z;var o;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 x(r,r.allKeys?void 0:new J(r,this.options.clientId),this.nowProvider),this.domainUrl=(o=this.options.domain,/^https?:\/\//.test(o)?o:`https://${o}`),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 V)}_url(t){const e=encodeURIComponent(btoa(JSON.stringify(this.options.auth0Client||d)));return`${this.domainUrl}${t}&auth0Client=${e}`}_authorizeUrl(t){return this._url(`/authorize?${k(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,o]=e;if(3!==e.length||!r||!n||!o)throw new Error("ID token could not be decoded");const i=JSON.parse(I(n)),s={__raw:t},a={};return Object.keys(i).forEach((t=>{s[t]=i[t],D.includes(t)||(a[t]=i[t])})),{encoded:{header:r,payload:n,signature:o},header:JSON.parse(I(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()),o=new Date(0);if(o.setUTCSeconds(e.claims.exp+r),n>o)throw new Error(`Expiration Time (exp) claim error in the ID token; current time (${n}) is after expiration time (${o})`);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 o=new Date(0);if(o.setUTCSeconds(parseInt(e.claims.auth_time)+t.max_age+r),n>o)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 ${o}`)}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:(o=this.options.authorizationParams.max_age,"string"!=typeof o?o:parseInt(o,10)||void 0),now:n});var o}_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=T(A()),o=T(A()),i=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=S().subtle.digest({name:"SHA-256"},(new TextEncoder).encode(t));return await e})(i)),a=((t,e,r,n,o,i,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:o,redirect_uri:s||t.authorizationParams.redirect_uri,code_challenge:i,code_challenge_method:"S256"}))(this.options,this.scope,t,n,o,s,t.redirect_uri||this.options.authorizationParams.redirect_uri||r,null==e?void 0:e.response_mode),c=this._authorizeUrl(a);return{nonce:o,code_verifier:i,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 o=await(t=>new Promise(((e,r)=>{let n;const o=setInterval((()=>{t.popup&&t.popup.closed&&(clearInterval(o),clearTimeout(i),window.removeEventListener("message",n,!1),r(new b(t.popup)))}),1e3),i=setTimeout((()=>{clearInterval(o),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(i),clearInterval(o),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!==o.state)throw new g("state_mismatch","Invalid state");const i=(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:o.code,redirect_uri:n.redirect_uri},{nonceIn:n.nonce,organization:i})}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=Y(t),{openUrl:n,fragment:i,appState:s}=r,a=o(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=o(u,["url"]);this.transactionManager.create(Object.assign(Object.assign(Object.assign({},h),{appState:s}),c&&{organization:c}));const f=i?`${l}#${i}`: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:o,error_description:i}=(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(),o)throw new y(o,i||o,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=o(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:o,oauthTokenScope:i,expires_in:s}=t;return Object.assign(Object.assign({id_token:n,access_token:o},i?{scope:i}: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 B({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=o(e,["federated"]),i=r?"&federated":"";return this._url(`/v2/logout?${k(Object.assign({clientId:t.clientId},n))}`)+i}async logout(t={}){const e=Y(t),{openUrl:r}=e,n=o(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 i=this._buildLogoutUrl(n);r?await r(i):!1!==r&&window.location.assign(i)}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:o,nonce:i,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,o)=>{const i=window.document.createElement("iframe");i.setAttribute("width","0"),i.setAttribute("height","0"),i.style.display="none";const s=()=>{window.document.body.contains(i)&&(window.document.body.removeChild(i),window.removeEventListener("message",a,!1))};let a;const c=setTimeout((()=>{o(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?o(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(i),i.setAttribute("src",t)})))(n,this.domainUrl,r);if(o!==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:i,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 B({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 _(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 o=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({},o),{scope:t.authorizationParams.scope,oauthTokenScope:o.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=o(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 B({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 B({scope:t,audience:e,clientId:r}),60);if(n&&n.access_token){const{access_token:t,oauthTokenScope:e,expires_in:r}=n,o=await this._getIdTokenFromCache();return o&&Object.assign(Object.assign({id_token:o.id_token,access_token:t},e?{scope:e}:null),{expires_in:r})}}async _requestToken(t,e){const{nonceIn:r,organization:n}=e||{},o=await C(Object.assign({baseUrl:this.domainUrl,client_id:this.options.clientId,auth0Client:this.options.auth0Client,useFormData:this.options.useFormData,timeout:this.httpTimeoutMs},t),this.worker),i=await this._verifyIdToken(o.id_token,r,n);return await this._saveEntryInCache(Object.assign(Object.assign(Object.assign(Object.assign({},o),{decodedToken:i,scope:t.scope,audience:t.audience||"default"}),o.scope?{oauthTokenScope:o.scope}:null),{client_id:this.options.clientId})),this.cookieStorage.save(this.isAuthenticatedCookieName,!0,{daysUntilExpire:this.sessionCheckExpiryDays,cookieDomain:this.options.cookieDomain}),this._processOrgHint(n||i.claims.org_id),Object.assign(Object.assign({},o),{decodedToken:i})}}var et=a(470);function rt(t,e){return function(){return t.apply(e,arguments)}}const{toString:nt}=Object.prototype,{getPrototypeOf:ot}=Object,it=(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=>it(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"!==it(t))return!1;const e=ot(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"),_t=at("URLSearchParams");function Et(t,e,{allOwnKeys:r=!1}={}){if(null==t)return;let n,o;if("object"!=typeof t&&(t=[t]),ut(t))for(n=0,o=t.length;n<o;n++)e.call(null,t[n],n,t);else{const o=r?Object.getOwnPropertyNames(t):Object.keys(t),i=o.length;let s;for(n=0;n<i;n++)s=o[n],e.call(null,t[s],s,t)}}function St(t,e){e=e.toLowerCase();const r=Object.keys(t);let n,o=r.length;for(;o-- >0;)if(n=r[o],e===n.toLowerCase())return n;return null}const At="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,Tt=t=>!lt(t)&&t!==At;const kt=(It="undefined"!=typeof Uint8Array&&ot(Uint8Array),t=>It&&t instanceof It);var It;const Ot=at("HTMLFormElement"),Rt=(({hasOwnProperty:t})=>(e,r)=>t.call(e,r))(Object.prototype),Ct=at("RegExp"),Ut=(t,e)=>{const r=Object.getOwnPropertyDescriptors(t),n={};Et(r,((r,o)=>{let i;!1!==(i=e(r,o,t))&&(n[o]=i||r)})),Object.defineProperties(t,n)},Bt="abcdefghijklmnopqrstuvwxyz",Pt="0123456789",Lt={DIGIT:Pt,ALPHA:Bt,ALPHA_DIGIT:Bt+Bt.toUpperCase()+Pt};const xt=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=it(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:Ct,isFunction:dt,isStream:t=>gt(t)&&dt(t.pipe),isURLSearchParams:_t,isTypedArray:kt,isFileList:vt,forEach:Et,merge:function t(){const{caseless:e}=Tt(this)&&this||{},r={},n=(n,o)=>{const i=e&&St(r,o)||o;yt(r[i])&&yt(n)?r[i]=t(r[i],n):yt(n)?r[i]=t({},n):ut(n)?r[i]=n.slice():r[i]=n};for(let t=0,e=arguments.length;t<e;t++)arguments[t]&&Et(arguments[t],n);return r},extend:(t,e,r,{allOwnKeys:n}={})=>(Et(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 o,i,s;const a={};if(e=e||{},null==t)return e;do{for(o=Object.getOwnPropertyNames(t),i=o.length;i-- >0;)s=o[i],n&&!n(s,t,e)||a[s]||(e[s]=t[s],a[s]=!0);t=!1!==r&&ot(t)}while(t&&(!r||r(t,e))&&t!==Object.prototype);return e},kindOf:it,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:Ot,hasOwnProperty:Rt,hasOwnProp:Rt,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:St,global:At,isContextDefined:Tt,ALPHABET:Lt,generateString:(t=16,e=Lt.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 o=ut(t)?[]:{};return Et(t,((t,e)=>{const i=r(t,n+1);!lt(i)&&(o[e]=i)})),e[n]=void 0,o}}return t};return r(t,0)},isAsyncFn:xt,isThenable:t=>t&&(gt(t)||dt(t))&&dt(t.then)&&dt(t.catch)};function jt(t,e,r,n,o){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),o&&(this.response=o)}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,o,i)=>{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,o),s.cause=t,s.name=t.name,i&&Object.assign(s,i),s};const Mt=jt;function $t(t){return Nt.isPlainObject(t)||Nt.isArray(t)}function Ft(t){return Nt.endsWith(t,"[]")?t.slice(0,-2):t}function Wt(t,e,r){return t?t.concat(e).map((function(t,e){return t=Ft(t),!r&&e?"["+t+"]":t})).join(r?".":""):e}const zt=Nt.toFlatObject(Nt,{},null,(function(t){return/^is[A-Z]/.test(t)}));const Zt=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,o=r.visitor||u,i=r.dots,s=r.indexes,a=(r.Blob||"undefined"!=typeof Blob&&Blob)&&Nt.isSpecCompliantForm(e);if(!Nt.isFunction(o))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,o){let a=t;if(t&&!o&&"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($t)}(t)||(Nt.isFileList(t)||Nt.endsWith(r,"[]"))&&(a=Nt.toArray(t)))return r=Ft(r),a.forEach((function(t,n){!Nt.isUndefined(t)&&null!==t&&e.append(!0===s?Wt([r],n,i):null===s?r:r+"[]",c(t))})),!1;return!!$t(t)||(e.append(Wt(o,r,i),c(t)),!1)}const l=[],h=Object.assign(zt,{defaultVisitor:u,convertValue:c,isVisitable:$t});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,i){!0===(!(Nt.isUndefined(r)||null===r)&&o.call(e,r,Nt.isString(i)?i.trim():i,n,h))&&t(r,n?n.concat(i):[i])})),l.pop()}}(t),e};function Ht(t){const e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(t).replace(/[!'()~]|%20|%00/g,(function(t){return e[t]}))}function Vt(t,e){this._pairs=[],t&&Zt(t,this,e)}const Xt=Vt.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,Ht)}:Ht;return this._pairs.map((function(t){return e(t[0])+"="+e(t[1])}),"").join("&")};const Jt=Vt;function qt(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function Gt(t,e,r){if(!e)return t;const n=r&&r.encode||qt,o=r&&r.serialize;let i;if(i=o?o(e,r):Nt.isURLSearchParams(e)?e.toString():new Jt(e,r).toString(n),i){const e=t.indexOf("#");-1!==e&&(t=t.slice(0,e)),t+=(-1===t.indexOf("?")?"?":"&")+i}return t}const Yt=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:Jt,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 oe="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,ie={...t,...te};const se=function(t){function e(t,r,n,o){let i=t[o++];if("__proto__"===i)return!0;const s=Number.isFinite(+i),a=o>=t.length;if(i=!i&&Nt.isArray(n)?n.length:i,a)return Nt.hasOwnProp(n,i)?n[i]=[n[i],r]:n[i]=r,!s;n[i]&&Nt.isObject(n[i])||(n[i]=[]);return e(t,r,n[i],o)&&Nt.isArray(n[i])&&(n[i]=function(t){const e={},r=Object.keys(t);let n;const o=r.length;let i;for(n=0;n<o;n++)i=r[n],e[i]=t[i];return e}(n[i])),!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,o=Nt.isObject(t);o&&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 i;if(o){if(r.indexOf("application/x-www-form-urlencoded")>-1)return function(t,e){return Zt(t,new ie.classes.URLSearchParams,Object.assign({visitor:function(t,e,r,n){return ie.isNode&&Nt.isBuffer(t)?(this.append(e,t.toString("base64")),!1):n.defaultVisitor.apply(this,arguments)}},e))}(t,this.formSerializer).toString();if((i=Nt.isFileList(t))||r.indexOf("multipart/form-data")>-1){const e=this.env&&this.env.FormData;return Zt(i?{"files[]":t}:t,e&&new e,this.formSerializer)}}return o||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:ie.classes.FormData,Blob:ie.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,o){return Nt.isFunction(n)?n.call(this,e,r):(o&&(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 o(t,e,r){const o=he(e);if(!o)throw new Error("header name must be a non-empty string");const i=Nt.findKey(n,o);(!i||void 0===n[i]||!0===r||void 0===r&&!1!==n[i])&&(n[i||e]=fe(t))}const i=(t,e)=>Nt.forEach(t,((t,r)=>o(t,r,e)));return Nt.isPlainObject(t)||t instanceof this.constructor?i(t,e):Nt.isString(t)&&(t=t.trim())&&!/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(t.trim())?i((t=>{const e={};let r,n,o;return t&&t.split("\n").forEach((function(t){o=t.indexOf(":"),r=t.substring(0,o).trim().toLowerCase(),n=t.substring(o+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&&o(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 o(t){if(t=he(t)){const o=Nt.findKey(r,t);!o||e&&!de(0,r[o],o,e)||(delete r[o],n=!0)}}return Nt.isArray(t)?t.forEach(o):o(t),n}clear(t){const e=Object.keys(this);let r=e.length,n=!1;for(;r--;){const o=e[r];t&&!de(0,this[o],o,t,!0)||(delete this[o],n=!0)}return n}normalize(t){const e=this,r={};return Nt.forEach(this,((n,o)=>{const i=Nt.findKey(r,o);if(i)return e[i]=fe(n),void delete e[o];const s=t?function(t){return t.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,((t,e,r)=>e.toUpperCase()+r))}(o):String(o).trim();s!==o&&delete e[o],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,o){return this[n].call(this,e,t,r,o)},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,o=ge.from(n.headers);let i=n.data;return Nt.forEach(t,(function(t){i=t.call(r,i,o.normalize(),e?e.status:void 0)})),o.normalize(),i}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=ie.hasStandardBrowserEnv?{write(t,e,r,n,o,i){const s=[t+"="+encodeURIComponent(e)];Nt.isNumber(r)&&s.push("expires="+new Date(r).toGMTString()),Nt.isString(n)&&s.push("path="+n),Nt.isString(o)&&s.push("domain="+o),!0===i&&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 _e(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 Ee=ie.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 Se=function(t,e){t=t||10;const r=new Array(t),n=new Array(t);let o,i=0,s=0;return e=void 0!==e?e:1e3,function(a){const c=Date.now(),u=n[s];o||(o=c),r[i]=a,n[i]=c;let l=s,h=0;for(;l!==i;)h+=r[l++],l%=t;if(i=(i+1)%t,i===s&&(s=(s+1)%t),c-o<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=Se(50,250);return o=>{const i=o.loaded,s=o.lengthComputable?o.total:void 0,a=i-r,c=n(a);r=i;const u={loaded:i,total:s,progress:s?i/s:void 0,bytes:a,rate:c||void 0,estimated:c&&s&&i<=s?(s-i)/c:void 0,event:o};u[e?"download":"upload"]=!0,t(u)}}const Te={http:null,xhr:"undefined"!=typeof XMLHttpRequest&&function(t){return new Promise((function(e,r){let n=t.data;const o=ge.from(t.headers).normalize();let i,s,{responseType:a,withXSRFToken:c}=t;function u(){t.cancelToken&&t.cancelToken.unsubscribe(i),t.signal&&t.signal.removeEventListener("abort",i)}if(Nt.isFormData(n))if(ie.hasStandardBrowserEnv||ie.hasStandardBrowserWebWorkerEnv)o.setContentType(!1);else if(!1!==(s=o.getContentType())){const[t,...e]=s?s.split(";").map((t=>t.trim())).filter(Boolean):[];o.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)):"";o.set("Authorization","Basic "+btoa(e+":"+r))}const h=_e(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(),Gt(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},ie.hasStandardBrowserEnv&&(c&&Nt.isFunction(c)&&(c=c(t)),c||!1!==c&&Ee(h))){const e=t.xsrfHeaderName&&t.xsrfCookieName&&ve.read(t.xsrfCookieName);e&&o.set(t.xsrfHeaderName,e)}void 0===n&&o.setContentType(null),"setRequestHeader"in l&&Nt.forEach(o.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)&&(i=e=>{l&&(r(!e||e.type?new be(null,t,l):e),l.abort(),l=null)},t.cancelToken&&t.cancelToken.subscribe(i),t.signal&&(t.signal.aborted?i():t.signal.addEventListener("abort",i)));const d=function(t){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(t);return e&&e[1]||""}(h);d&&-1===ie.protocols.indexOf(d)?r(new Mt("Unsupported protocol "+d+":",Mt.ERR_BAD_REQUEST,t)):l.send(n||null)}))}};Nt.forEach(Te,((t,e)=>{if(t){try{Object.defineProperty(t,"name",{value:e})}catch(t){}Object.defineProperty(t,"adapterName",{value:e})}}));const ke=t=>`- ${t}`,Ie=t=>Nt.isFunction(t)||null===t||!1===t,Oe=t=>{t=Nt.isArray(t)?t:[t];const{length:e}=t;let r,n;const o={};for(let i=0;i<e;i++){let e;if(r=t[i],n=r,!Ie(r)&&(n=Te[(e=String(r)).toLowerCase()],void 0===n))throw new Mt(`Unknown adapter '${e}'`);if(n)break;o[e||"#"+i]=n}if(!n){const t=Object.entries(o).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(ke).join("\n"):" "+ke(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 Re(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new be(null,t)}function Ce(t){Re(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 Oe(t.adapter||ce.adapter)(t).then((function(e){return Re(t),e.data=ye.call(t,t.transformResponse,e),e.headers=ge.from(e.headers),e}),(function(e){return we(e)||(Re(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 Be(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 o(t,e,r){return Nt.isUndefined(e)?Nt.isUndefined(t)?void 0:n(void 0,t,r):n(t,e,r)}function i(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,o,i){return i in e?n(r,o):i in t?n(void 0,r):void 0}const c={url:i,method:i,data:i,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)=>o(Ue(t),Ue(e),!0)};return Nt.forEach(Object.keys(Object.assign({},t,e)),(function(n){const i=c[n]||o,s=i(t[n],e[n],n);Nt.isUndefined(s)&&i!==a||(r[n]=s)})),r}const Pe="1.6.5",Le={};["object","boolean","number","function","string","symbol"].forEach(((t,e)=>{Le[t]=function(r){return typeof r===t||"a"+(e<1?"n ":" ")+t}}));const xe={};Le.transitional=function(t,e,r){function n(t,e){return"[Axios v1.6.5] Transitional option '"+t+"'"+e+(r?". "+r:"")}return(r,o,i)=>{if(!1===t)throw new Mt(n(o," has been removed"+(e?" in "+e:"")),Mt.ERR_DEPRECATED);return e&&!xe[o]&&(xe[o]=!0,console.warn(n(o," has been deprecated since v"+e+" and will be removed in the near future"))),!t||t(r,o,i)}};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 o=n.length;for(;o-- >0;){const i=n[o],s=e[i];if(s){const e=t[i],r=void 0===e||s(e,i,t);if(!0!==r)throw new Mt("option "+i+" must be "+r,Mt.ERR_BAD_OPTION_VALUE)}else if(!0!==r)throw new Mt("Unknown option "+i,Mt.ERR_BAD_OPTION)}},validators:Le},je=Ne.validators;class De{constructor(t){this.defaults=t,this.interceptors={request:new Yt,response:new Yt}}request(t,e){"string"==typeof t?(e=e||{}).url=t:e=t||{},e=Be(this.defaults,e);const{transitional:r,paramsSerializer:n,headers:o}=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 i=o&&Nt.merge(o.common,o[e.method]);o&&Nt.forEach(["delete","get","head","post","put","patch","common"],(t=>{delete o[t]})),e.headers=ge.concat(i,o);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=[Ce.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=Ce.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 Gt(_e((t=Be(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(Be(r||{},{method:t,url:e,data:(r||{}).data}))}})),Nt.forEach(["post","put","patch"],(function(t){function e(e){return function(r,n,o){return this.request(Be(o||{},{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,o){r.reason||(r.reason=new be(t,n,o),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 $e=Me;const Fe={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(Fe).forEach((([t,e])=>{Fe[e]=t}));const We=Fe;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(Be(e,r))},n}(ce);ze.Axios=Ke,ze.CanceledError=be,ze.CancelToken=$e,ze.isCancel=we,ze.VERSION=Pe,ze.toFormData=Zt,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=Be,ze.AxiosHeaders=ge,ze.formToJSON=t=>se(Nt.isHTMLForm(t)?new FormData(t):t),ze.getAdapter=Oe,ze.HttpStatusCode=We,ze.default=ze;const Ze=ze;var He=a(742),Ve=Object.create,Xe=Object.defineProperty,Je=Object.getOwnPropertyDescriptor,qe=Object.getOwnPropertyNames,Ge=Object.getPrototypeOf,Ye=Object.prototype.hasOwnProperty,Qe=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),tr=(t,e,r)=>(r=null!=t?Ve(Ge(t)):{},((t,e,r,n)=>{if(e&&"object"==typeof e||"function"==typeof e)for(let o of qe(e))!Ye.call(t,o)&&o!==r&&Xe(t,o,{get:()=>e[o],enumerable:!(n=Je(e,o))||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,o=4-r,i=e+o,s=Buffer.alloc(i);for(s.write(t);o--;)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)?o(t.toString("base64")):o(Buffer.from(t,e).toString("base64"))}function n(t){return t=t.toString(),e.default(t).replace(/\-/g,"+").replace(/_/g,"/")}function o(t){return t.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}var i=r;i.encode=r,i.decode=function(t,e){return void 0===e&&(e="utf8"),Buffer.from(n(t),"base64").toString(e)},i.toBase64=n,i.fromBase64=o,i.toBuffer=function(t){return Buffer.from(n(t),"base64")},t.default=i})),nr=Qe(((t,e)=>{e.exports=rr().default,e.exports.default=e.exports})),or=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,i=s(t),a=i[0],c=i[1],u=new o(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,o=n%3,i=[],s=16383,a=0,u=n-o;a<u;a+=s)i.push(c(t,a,a+s>u?u:a+s));return 1===o?(e=t[n-1],i.push(r[e>>2]+r[e<<4&63]+"==")):2===o&&(e=(t[n-2]<<8)+t[n-1],i.push(r[e>>10]+r[e>>4&63]+r[e<<2&63]+"=")),i.join("")};var e,r=[],n=[],o=typeof Uint8Array<"u"?Uint8Array:Array,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(e=0,64;e<64;++e)r[e]=i[e],n[i.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,o=[],i=e;i<r;i+=3)n=(t[i]<<16&16711680)+(t[i+1]<<8&65280)+(255&t[i+2]),o.push(a(n));return o.join("")}n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63})),ir=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=or();function r(t){return new TextDecoder("utf-8",{fatal:!0}).decode(t)}function n(t){return(new TextEncoder).encode(t)}function o(t){return new Uint8Array(e.toByteArray(c(t)))}function i(t){return e.fromByteArray(new Uint8Array(t))}function s(t){return a(i(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(o(t))},t.bufferToString=r,t.stringToBuffer=n,t.stringToB64Url=function(t){return s(n(t))},t.b64UrlToBuffer=o,t.bufferTob64=i,t.bufferTob64Url=s,t.b64UrlEncode=a,t.b64UrlDecode=c})),sr=Qe((t=>{Object.defineProperty(t,"__esModule",{value:!0});var e=ir();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},o=await this.jwkToPublicCryptoKey(n),i=await this.driver.digest("SHA-256",e),s=await this.driver.verify({name:"RSA-PSS",saltLength:0},o,r,e),a=await this.driver.verify({name:"RSA-PSS",saltLength:32},o,r,e),c=await this.driver.verify({name:"RSA-PSS",saltLength:Math.ceil((o.algorithm.modulusLength-1)/8)-i.byteLength-2},o,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 o=await this.driver.importKey("raw","string"==typeof r?e.stringToBuffer(r):r,{name:"PBKDF2",length:32},!1,["deriveKey"]),i=await this.driver.deriveKey({name:"PBKDF2",salt:n?e.stringToBuffer(n):e.stringToBuffer("salt"),iterations:1e5,hash:"SHA-256"},o,{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},i,t);return e.concatBuffers([s,a])}async decrypt(t,r,n){let o=await this.driver.importKey("raw","string"==typeof r?e.stringToBuffer(r):r,{name:"PBKDF2",length:32},!1,["deriveKey"]),i=await this.driver.deriveKey({name:"PBKDF2",salt:n?e.stringToBuffer(n):e.stringToBuffer("salt"),iterations:1e5,hash:"SHA-256"},o,{name:"AES-CBC",length:256},!1,["encrypt","decrypt"]),s=t.slice(0,16),a=await this.driver.decrypt({name:"AES-CBC",iv:s},i,t.slice(16));return e.concatBuffers([a])}}})),ar=Qe((t=>{t.read=function(t,e,r,n,o){var i,s,a=8*o-n-1,c=(1<<a)-1,u=c>>1,l=-7,h=r?o-1:0,f=r?-1:1,d=t[e+h];for(h+=f,i=d&(1<<-l)-1,d>>=-l,l+=a;l>0;i=256*i+t[e+h],h+=f,l-=8);for(s=i&(1<<-l)-1,i>>=-l,l+=n;l>0;s=256*s+t[e+h],h+=f,l-=8);if(0===i)i=1-u;else{if(i===c)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),i-=u}return(d?-1:1)*s*Math.pow(2,i-n)},t.write=function(t,e,r,n,o,i){var s,a,c,u=8*i-o-1,l=(1<<u)-1,h=l>>1,f=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:i-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,o),s+=h):(a=e*Math.pow(2,h-1)*Math.pow(2,o),s=0));o>=8;t[r+d]=255&a,d+=p,a/=256,o-=8);for(s=s<<o|a,u+=o;u>0;t[r+d]=255&s,d+=p,s/=256,u-=8);t[r+d-p]|=128*g}})),cr=Qe((t=>{var e=or(),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 o=2147483647;function i(t){if(t>o)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=i(r),o=n.write(t,e);return o!==r&&(n=n.slice(0,o)),n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(V(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(V(t,ArrayBuffer)||t&&V(t.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(V(t,SharedArrayBuffer)||t&&V(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 o=function(t){if(s.isBuffer(t)){let e=0|f(t.length),r=i(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)?i(0):l(t);if("Buffer"===t.type&&Array.isArray(t.data))return l(t.data)}(t);if(o)return o;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),i(t<0?0:0|f(t))}function l(t){let e=t.length<0?0:0|f(t.length),r=i(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>=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return 0|t}function d(t,e){if(s.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);let r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;let o=!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 Z(t).length;default:if(o)return n?-1:z(t).length;e=(""+e).toLowerCase(),o=!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 O(this,e,r);case"utf8":case"utf-8":return A(this,e,r);case"ascii":return k(this,e,r);case"latin1":case"binary":return I(this,e,r);case"base64":return S(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return R(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,o){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=o?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)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,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):w(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function w(t,e,r,n,o){let i,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(o){let n=-1;for(i=r;i<a;i++)if(u(t,i)===u(e,-1===n?0:i-n)){if(-1===n&&(n=i),i-n+1===c)return n*s}else-1!==n&&(i-=i-n),n=-1}else for(r+c>a&&(r=a-c),i=r;i>=0;i--){let r=!0;for(let n=0;n<c;n++)if(u(t,i+n)!==u(e,n)){r=!1;break}if(r)return i}return-1}function m(t,e,r,n){r=Number(r)||0;let o=t.length-r;n?(n=Number(n))>o&&(n=o):n=o;let i,s=e.length;for(n>s/2&&(n=s/2),i=0;i<n;++i){let n=parseInt(e.substr(2*i,2),16);if(X(n))return i;t[r+i]=n}return i}function b(t,e,r,n){return H(z(e,t.length-r),t,r,n)}function v(t,e,r,n){return H(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 _(t,e,r,n){return H(Z(e),t,r,n)}function E(t,e,r,n){return H(function(t,e){let r,n,o,i=[];for(let s=0;s<t.length&&!((e-=2)<0);++s)r=t.charCodeAt(s),n=r>>8,o=r%256,i.push(o),i.push(n);return i}(e,t.length-r),t,r,n)}function S(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=[],o=e;for(;o<r;){let e=t[o],i=null,s=e>239?4:e>223?3:e>191?2:1;if(o+s<=r){let r,n,a,c;switch(s){case 1:e<128&&(i=e);break;case 2:r=t[o+1],128==(192&r)&&(c=(31&e)<<6|63&r,c>127&&(i=c));break;case 3:r=t[o+1],n=t[o+2],128==(192&r)&&128==(192&n)&&(c=(15&e)<<12|(63&r)<<6|63&n,c>2047&&(c<55296||c>57343)&&(i=c));break;case 4:r=t[o+1],n=t[o+2],a=t[o+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&&(i=c))}}null===i?(i=65533,s=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|1023&i),n.push(i),o+=s}return function(t){let e=t.length;if(e<=T)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=T));return r}(n)}t.kMaxLength=o,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?i(t):void 0!==e?"string"==typeof r?i(t).fill(e,r):i(t).fill(e):i(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(V(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),V(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 o=0,i=Math.min(r,n);o<i;++o)if(t[o]!==e[o]){r=t[o],n=e[o];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),o=0;for(r=0;r<t.length;++r){let e=t[r];if(V(e,Uint8Array))o+e.length>n.length?(s.isBuffer(e)||(e=s.from(e)),e.copy(n,o)):Uint8Array.prototype.set.call(n,e,o);else{if(!s.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(n,o)}o+=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,o){if(V(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===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=r)return 0;if(n>=o)return-1;if(e>=r)return 1;if(this===t)return 0;let i=(o>>>=0)-(n>>>=0),a=(r>>>=0)-(e>>>=0),c=Math.min(i,a),u=this.slice(n,o),l=t.slice(e,r);for(let t=0;t<c;++t)if(u[t]!==l[t]){i=u[t],a=l[t];break}return i<a?-1:a<i?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 o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let i=!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 _(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return E(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var T=4096;function k(t,e,r){let n="";r=Math.min(t.length,r);for(let o=e;o<r;++o)n+=String.fromCharCode(127&t[o]);return n}function I(t,e,r){let n="";r=Math.min(t.length,r);for(let o=e;o<r;++o)n+=String.fromCharCode(t[o]);return n}function O(t,e,r){let n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);let o="";for(let n=e;n<r;++n)o+=J[t[n]];return o}function R(t,e,r){let n=t.slice(e,r),o="";for(let t=0;t<n.length-1;t+=2)o+=String.fromCharCode(n[t]+256*n[t+1]);return o}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 U(t,e,r,n,o,i){if(!s.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||e<i)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}function B(t,e,r,n,o){M(e,n,o,t,r,7);let i=Number(e&BigInt(4294967295));t[r++]=i,i>>=8,t[r++]=i,i>>=8,t[r++]=i,i>>=8,t[r++]=i;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,o){M(e,n,o,t,r,7);let i=Number(e&BigInt(4294967295));t[r+7]=i,i>>=8,t[r+6]=i,i>>=8,t[r+5]=i,i>>=8,t[r+4]=i;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 L(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function x(t,e,n,o,i){return e=+e,n>>>=0,i||L(t,0,n,4),r.write(t,e,n,o,23,4),n+4}function N(t,e,n,o,i){return e=+e,n>>>=0,i||L(t,0,n,8),r.write(t,e,n,o,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||C(t,e,this.length);let n=this[t],o=1,i=0;for(;++i<e&&(o*=256);)n+=this[t+i]*o;return n},s.prototype.readUintBE=s.prototype.readUIntBE=function(t,e,r){t>>>=0,e>>>=0,r||C(t,e,this.length);let n=this[t+--e],o=1;for(;e>0&&(o*=256);)n+=this[t+--e]*o;return n},s.prototype.readUint8=s.prototype.readUInt8=function(t,e){return t>>>=0,e||C(t,1,this.length),this[t]},s.prototype.readUint16LE=s.prototype.readUInt16LE=function(t,e){return t>>>=0,e||C(t,2,this.length),this[t]|this[t+1]<<8},s.prototype.readUint16BE=s.prototype.readUInt16BE=function(t,e){return t>>>=0,e||C(t,2,this.length),this[t]<<8|this[t+1]},s.prototype.readUint32LE=s.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]},s.prototype.readUint32BE=s.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])},s.prototype.readBigUInt64LE=q((function(t){$(t>>>=0,"offset");let e=this[t],r=this[t+7];(void 0===e||void 0===r)&&F(t,this.length-8);let n=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,o=this[++t]+256*this[++t]+65536*this[++t]+r*2**24;return BigInt(n)+(BigInt(o)<<BigInt(32))})),s.prototype.readBigUInt64BE=q((function(t){$(t>>>=0,"offset");let e=this[t],r=this[t+7];(void 0===e||void 0===r)&&F(t,this.length-8);let n=e*2**24+65536*this[++t]+256*this[++t]+this[++t],o=this[++t]*2**24+65536*this[++t]+256*this[++t]+r;return(BigInt(n)<<BigInt(32))+BigInt(o)})),s.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||C(t,e,this.length);let n=this[t],o=1,i=0;for(;++i<e&&(o*=256);)n+=this[t+i]*o;return o*=128,n>=o&&(n-=Math.pow(2,8*e)),n},s.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||C(t,e,this.length);let n=e,o=1,i=this[t+--n];for(;n>0&&(o*=256);)i+=this[t+--n]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*e)),i},s.prototype.readInt8=function(t,e){return t>>>=0,e||C(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},s.prototype.readInt16LE=function(t,e){t>>>=0,e||C(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||C(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||C(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||C(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},s.prototype.readBigInt64LE=q((function(t){$(t>>>=0,"offset");let e=this[t],r=this[t+7];(void 0===e||void 0===r)&&F(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=q((function(t){$(t>>>=0,"offset");let e=this[t],r=this[t+7];(void 0===e||void 0===r)&&F(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||C(t,4,this.length),r.read(this,t,!0,23,4)},s.prototype.readFloatBE=function(t,e){return t>>>=0,e||C(t,4,this.length),r.read(this,t,!1,23,4)},s.prototype.readDoubleLE=function(t,e){return t>>>=0,e||C(t,8,this.length),r.read(this,t,!0,52,8)},s.prototype.readDoubleBE=function(t,e){return t>>>=0,e||C(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 o=1,i=0;for(this[e]=255&t;++i<r&&(o*=256);)this[e+i]=t/o&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 o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&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=q((function(t,e=0){return B(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),s.prototype.writeBigUInt64BE=q((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 o=0,i=1,s=0;for(this[e]=255&t;++o<r&&(i*=256);)t<0&&0===s&&0!==this[e+o-1]&&(s=1),this[e+o]=(t/i>>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 o=r-1,i=1,s=0;for(this[e+o]=255&t;--o>=0&&(i*=256);)t<0&&0===s&&0!==this[e+o+1]&&(s=1),this[e+o]=(t/i>>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=q((function(t,e=0){return B(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),s.prototype.writeBigInt64BE=q((function(t,e=0){return P(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),s.prototype.writeFloatLE=function(t,e,r){return x(this,t,e,!0,r)},s.prototype.writeFloatBE=function(t,e,r){return x(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 o=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),o},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 o;if(e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o<r;++o)this[o]=t;else{let i=s.isBuffer(t)?t:s.from(t,n),a=i.length;if(0===a)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(o=0;o<r-e;++o)this[o+e]=i[o%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,o,i){if(t>r||t<e){let n,o="bigint"==typeof e?"n":"";throw n=i>3?0===e||e===BigInt(0)?`>= 0${o} and < 2${o} ** ${8*(i+1)}${o}`:`>= -(2${o} ** ${8*(i+1)-1}${o}) and < 2 ** ${8*(i+1)-1}${o}`:`>= ${e}${o} and <= ${r}${o}`,new j.ERR_OUT_OF_RANGE("value",n,t)}!function(t,e,r){$(e,"offset"),(void 0===t[e]||void 0===t[e+r])&&F(e,t.length-(r+1))}(n,o,i)}function $(t,e){if("number"!=typeof t)throw new j.ERR_INVALID_ARG_TYPE(e,"number",t)}function F(t,e,r){throw Math.floor(t)!==t?($(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.`,o=r;return Number.isInteger(r)&&Math.abs(r)>2**32?o=K(String(r)):"bigint"==typeof r&&(o=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(o=K(o)),o+="n"),n+=` It must be ${e}. Received ${o}`,n}),RangeError);var W=/[^+/0-9A-Za-z-_]/g;function z(t,e){e=e||1/0;let r,n=t.length,o=null,i=[];for(let s=0;s<n;++s){if(r=t.charCodeAt(s),r>55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(s+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.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;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function Z(t){return e.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(W,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function H(t,e,r,n){let o;for(o=0;o<n&&!(o+r>=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function V(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 J=function(){let t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){let n=16*r;for(let o=0;o<16;++o)e[n+o]=t[r]+t[o]}return e}();function q(t){return typeof BigInt>"u"?G:t}function G(){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:()=>Or,ArweaveSigner:()=>Sr,DataItem:()=>Dr,MAX_TAG_BYTES:()=>Nr,MIN_BINARY_SIZE:()=>jr,SIG_CONFIG:()=>Er,SignatureConfig:()=>wr,Signer:()=>hr,createData:()=>Mr,deserializeTags:()=>Ur,indexToType:()=>Ar,serializeTags:()=>Rr,tagsExceedLimit:()=>Cr});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(ir(),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 _r().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 _r().hash(r,"SHA-384"),await _r().hash(e,"SHA-384")]);return await _r().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 _r().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 _r(){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 Er={[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"}},Sr=class{signatureType=1;ownerLength=Er[1].pubLength;signatureLength=Er[1].sigLength;jwk;pk;constructor(t){this.pk=t.n,this.jwk=t}get publicKey(){return fr.default.toBuffer(this.pk)}sign(t){return _r().sign(this.jwk,t)}static async verify(t,e,r){return await _r().verify(t,e,r)}},Ar={1:Sr},Tr=tr(nr(),1);async function kr(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 Ir(t,e){let{signature:r,id:n}=await async function(t,e){let r=await kr(t),n=await e.sign(r),o=await _r().hash(n);return{signature:Buffer.from(n),id:Buffer.from(o)}}(t,e);return t.getRaw().set(r,2),n}var Or=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 o,i,s,a;for(o=0,i=e;o<i;o++)s=t.charCodeAt(o),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(o+1)))?(s=65536+((1023&s)<<10)+(1023&a),o++,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,o=0,i=0,s=this.buf;do{t=s[this.pos++],e=128&t,o|=(127&t)<<i,i+=7}while(e&&i<28);if(e){r=o,n=268435456;do{t=s[this.pos++],r+=(127&t)*n,n*=128}while(128&t);return(r%2?-(r+1):r)/2}return o>>1^-(1&o)}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 Rr(t){let e=new Or;return e.writeTags(t),e.toBuffer()}function Cr(t){let e=new Or;return e.writeTags(t),e.tagsExceedLimit()}function Ur(t){return new Or(t).readTags()}function Br(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 Lr=tr(ur(),1),xr=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=Br(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()=>Tr.default.encode(await this.rawId))()}set id(t){this._id=Tr.default.toBuffer(t)}get rawId(){return(async()=>xr.Buffer.from(await Lr.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 Tr.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 Er[this.signatureType].sigLength}get owner(){return Tr.default.encode(this.rawOwner)}get ownerLength(){return Er[this.signatureType].pubLength}get rawTarget(){let t=this.getTargetStart();return 1==this.binary[t]?this.binary.subarray(t+1,t+33):xr.Buffer.alloc(0)}get target(){return Tr.default.encode(this.rawTarget)}get rawAnchor(){let t=this.getAnchorStart();return 1==this.binary[t]?this.binary.subarray(t+1,t+33):xr.Buffer.alloc(0)}get anchor(){return this.rawAnchor.toString()}get rawTags(){let t=this.getTagsStart(),e=Br(this.binary.subarray(t+8,t+16));return this.binary.subarray(t+16,t+16+e)}get tags(){let t=this.getTagsStart();if(0==Br(this.binary.subarray(t,t+8)))return[];let e=Br(this.binary.subarray(t+8,t+16));return Ur(xr.Buffer.from(this.binary.subarray(t+16,t+16+e)))}get tagsB64Url(){return this.tags.map((t=>({name:Tr.default.encode(t.name),value:Tr.default.encode(t.value)})))}getStartOfData(){let t=this.getTagsStart();return t+16+Br(this.binary.subarray(t+8,t+16))}get rawData(){let t=this.getTagsStart(),e=t+16+Br(this.binary.subarray(t+8,t+16));return this.binary.subarray(e,this.binary.length)}get data(){return Tr.default.encode(this.rawData)}getRaw(){return this.binary}async sign(t){return this._id=await Ir(this,t),this.rawId}async setSignature(t){this.binary.set(t,2),this._id=xr.Buffer.from(await _r().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:Tr.default.encode(t.name),value:Tr.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(),o=Br(t.subarray(n,n+8)),i=Br(t.subarray(n+8,n+16));if(i>Nr)return!1;if(o>0)try{if(Ur(xr.Buffer.from(t.subarray(n+16,n+16+i))).length!==o)return!1}catch{return!1}let s=Ar[r],a=await kr(e);return await s.verify(e.rawOwner,a,e.rawSignature)}async getSignatureData(){return kr(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,o=r?.target?Kr.default.toBuffer(r.target):null,i=1+(o?.byteLength??0),s=r?.anchor?Buffer.from(r.anchor):null,a=1+(s?.byteLength??0),c=(r?.tags?.length??0)>0?Rr(r.tags):null,u=16+(c?c.byteLength:0),l=Buffer.from(t),h=l.byteLength,f=2+e.signatureLength+e.ownerLength+i+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]=o?1:0,o){if(32!==o.byteLength)throw new Error(`Target must be 32 bytes but was incorrectly ${o.byteLength}`);d.set(o,p+1)}let g=p+i,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 $r={...lr};globalThis.arbundles??=$r;const{Axios:Fr,AxiosError:Wr,CanceledError:zr,isCancel:Zr,CancelToken:Hr,VERSION:Vr,all:Xr,Cancel:Jr,isAxiosError:qr,spread:Gr,toFormData:Yr,AxiosHeaders:Qr,HttpStatusCode:tn,formToJSON:en,getAdapter:rn,mergeConfig:nn}=Ze;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),o=r===n;return this.lastEmittedUpdateId=n,this.lastEmittedParams=t,this.listeners.forEach((r=>{if(!o||!e.has(r)){e.add(r);try{r(...t)}catch(t){}}})),o}};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:o}=this.parseCookieOptions(pn(e,gn));return this.secureParam=r,this.domainParam=n,this.ttlMs=o,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),o=[`expires=${new Date(Date.now()+n).toUTCString()}`,e,r,"path=/"].filter(Boolean).join("; ");return o?` ${o};`:""}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:o,refreshTokenExpirationMs:i,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 o?o:void 0,cache:"object"==typeof o?o:void 0,authorizationParams:{redirect_uri:this.redirectURI}}).then((t=>(this.isReady=!0,t))),this.cookieKey=h,this.localStorageKey=f,this.refreshTokenExpirationMs=i,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,o=e.sub||"",i=o.split("|")[0];let s=await async function(t){try{const e=(await Ze.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[i]||"Unknown Provider"} (${r})`}return{sub:o,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:i}}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 o=await this.updateUserDetails(n);return{...t,idToken:n,userDetails:o}}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 _n(t){return"string"==typeof t?En(t):t}function En(t){return(new TextEncoder).encode(t)}function Sn(t){return e=function(t){return He.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 Tn=(t=>(t.Unexpected="Unexpected",t.Validation="Validation",t.UserCreation="UserCreation",t.Encryption="Encryption",t.Decryption="Decryption",t.Signing="Signing",t.PublicKey="PublicKey",t))(Tn||{}),kn=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 In(t){var e;if(qr(t)){const r=null==(e=t.response)?void 0:e.data;if(!function(t){return"object"==typeof t&&!0===t.error&&!!t.id&&!!Tn[t.id]}(r))return t;const{id:n,developerMessage:o,cause:i}=r;let s;return i&&(s=new Error(i.message),s.name=i.name,s.stack=i.stack),new kn(n,o||"",s,!0)}return t instanceof Error?t:new Error("Unknown error")}async function On(t,e,r,n){var o;const i=await e.encodeToken({ciphertext:r,keyName:n});let s=null;try{s=null!=(o=(await t.post("/decrypt",{encodedData:i})).data.data)?o:null}catch(t){throw In(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 Rn=class{constructor(t,e){this.api=Ze.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 In(t)}if(!r)throw new Error("Error creating user on server.");return!0}(this.api,t)}async decrypt(t,e){return On(this.api,this.auth0,t,e)}async encrypt(t,e){return async function(t,e,r,n){var o;const i=await e.encodeToken({plaintext:r,keyName:n});let s=null;try{s=null!=(o=(await t.post("/encrypt",{encodedData:i})).data.data)?o:null}catch(t){throw In(t)}if(null===s)throw new Error("Error encrypting on server.");return"string"==typeof s?En(s):new Uint8Array(s.data)}(this.api,this.auth0,t,e)}async sign(t,e){return async function(t,e,r,n){const o=await e.encodeToken({data:r,keyName:n});let i=null;try{i=(await t.post("/sign",{encodedData:o})).data.data}catch(t){throw In(t)}if(null===i)throw new Error("Error signing data on server.");return"string"==typeof i?En(i):new Uint8Array(i.data)}(this.api,this.auth0,t,e)}getSignerSignFn(t){return async e=>await this.sign(e,t)}};function Cn(t,e="utf8"){return n.lW.isBuffer(t)?Bn(t.toString("base64")):Bn(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 o=e,i=4-r,s=e+i,a=n.lW.alloc(s);for(a.write(t);i--;)a.write("=",o++);return a.toString()}(t=t.toString()).replace(/\-/g,"+").replace(/_/g,"/")}function Bn(t){return t.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function Pn(t){return n.lW.from(Un(t),"base64")}var Ln=Cn;function xn(t){return on.default.init(t)}Ln.encode=Cn,Ln.decode=function(t,e="utf8"){return n.lW.from(Un(t),"base64").toString(e)},Ln.toBase64=Un,Ln.fromBase64=Bn,Ln.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:o,auth0Cache:i=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 o?o:o?un:null,auth0Cache:"object"==typeof i?"custom":i,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"===i)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:i,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 Rn(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 o=null;try{o=await this.auth0.handleRedirectCallback(e)}finally{"undefined"!=typeof location&&"undefined"!=typeof history&&(n.delete("code"),n.delete("state"),history.replaceState(null,"",r))}return o}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 o="",i=null;try{const t=await this.auth0.getTokenSilently();o=t.id_token,i=t.userDetails}catch(t){if(!(t instanceof Error))throw t;if("Login required"!==t.message&&!(t instanceof _))throw t;console.warn(t.message)}if(!o)try{const t=await this.auth0.logIn();o=t.id_token,i=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(o&&!i){await this.api.createUser(o);const t=await this.auth0.getTokenSilently();o=t.id_token,i=t.userDetails}if(o&&i)return i;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=xn(this.gatewayConfig),o=t.get("tags").map((t=>({name:t.get("name",{decode:!0,string:!0}),value:t.get("value",{decode:!0,string:!0})}))),i=this.addCommonTags(o),s=await n.createTransaction({data:t.data,owner:r,reward:t.reward});i.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:Sn(u),owner:r,signature:Sn(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})}))),o=await this.signDataItem({data:t.data,tags:n,target:t.target}),i=`${(null==e?void 0:e.node)||"https://turbo.ardrive.io"}/tx`;try{const t=await Ze.post(i,o,{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 ${i} =\n`,n);const o=await this.sign(t),s=null!=(r=null==e?void 0:e.arweave)?r:xn(this.gatewayConfig),a=await s.transactions.getUploader(o);for(;!a.isComplete;)await a.uploadChunk();return{id:o.id,signature:o.signature,owner:o.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:o,...i}=t,s={publicKey:Pn(r),signatureType:1,signatureLength:512,ownerLength:512,sign:this.api.getSignerSignFn(e)},a=Mr(n,s,{...i,tags:this.addCommonTags(o)});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",o=await this.crypto.subtle.digest(n,_n(t));return await this.api.sign(o,r)}async verifyMessage(t,e,r,n={hashAlgorithm:"SHA-256"}){if(!r){const t=await this.requireUserDataOrThrow();r||(r=t.publicKey)}const o=(null==n?void 0:n.hashAlgorithm)||"SHA-256",i=await this.crypto.subtle.digest(o,_n(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,_n(e),i)}async privateHash(t,e){return An(_n(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){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;class Kn extends Error{constructor(t,e,r){super("object"==typeof e?e.message:e||t,{cause:"object"==typeof e?e.cause:r}),this.type=t,this.name="TypedError",Object.setPrototypeOf(this,Kn.prototype)}}const Mn="ERR_INVALID_VALUE",$n="ERR_UNEXPECTED_VALUE",Fn="ERR_UNEXPECTED_TYPE",Wn="ERR_PARSE";function zn(t,e){const r={};for(const n in t){const o=t[n];if(!o)continue;let i,s;"function"==typeof o?(i=n,s=o):[i,s]=o;try{const t=s(e(i));void 0!==t&&(r[n]=t)}catch(t){throw new Kn(Wn,`Parser for "${n}" property failed${i===n?"":`. Source field: "${i}"`}`,t)}}return r}function Zn(t){let e=t;if("string"==typeof e)try{e=JSON.parse(e)}catch(t){throw new Kn(Mn,{cause:t})}if("object"!=typeof e||!e||Array.isArray(e))throw new Kn($n);return e}function Hn(t,e){return r=>{const n=n=>{if(!r||void 0!==n)try{return e(n)}catch(e){throw new Kn(Wn,{message:`"${t}" transformer failed to parse the value`,cause:e})}};return Object.assign(n,{isValid(t){try{return n(t),!0}catch{return!1}}})}}function Vn(t,e){return Hn(e||"object",(e=>{const r=Zn(e);return zn(t,(t=>r[t]))}))}function Xn(t){throw new Kn(Fn,`Unexpected value received: ${JSON.stringify(t)}`)}Hn("boolean",(t=>{if("boolean"==typeof t)return t;const e=String(t);return"1"===e||"true"===e||"0"!==e&&"false"!==e&&void Xn(t)}));const Jn=Hn("string",(t=>{if("string"==typeof t||"number"==typeof t)return t.toString();Xn(t)})),qn=Hn("number",(t=>{if("number"==typeof t)return t;if("string"==typeof t){const e=Number(t);if(!Number.isNaN(e))return e}Xn(t)}));Hn("date",(t=>t instanceof Date?t:new Date(1e3*qn()(t))));function Gn(t){return/^#[\da-f]{6}$/i.test(t)}function Yn(t){const e=t.replace(/\s/g,"").toLowerCase();if(Gn(e))return e;if(function(t){return/^#[\da-f]{3}$/i.test(t)}(e)){let t="#";for(let r=0;r<3;r+=1)t+=e[1+r].repeat(2);return t}const r=e.match(/^rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)$/)||e.match(/^rgba\((\d{1,3}),(\d{1,3}),(\d{1,3}),\d{1,3}\)$/);if(!r)throw new Error(`Value "${t}" does not satisfy any of known RGB formats.`);return r.slice(1).reduce(((t,e)=>{const r=parseInt(e,10).toString(16);return t+(1===r.length?"0":"")+r}),"#")}const Qn=Hn("rgb",(t=>Yn(Jn()(t)))),to=Hn("themeParams",(t=>{const e=Qn(!0);return Object.entries(Zn(t)).reduce(((t,[r,n])=>(t[function(t){return t.replace(/_[a-z]/g,(t=>t[1].toUpperCase()))}(r)]=e(n),t)),{})}));class eo extends Error{constructor(t,e,r){super("object"==typeof e?e.message:e||t,{cause:"object"==typeof e?e.cause:r}),this.type=t,this.name="TypedError",Object.setPrototypeOf(this,eo.prototype)}}function ro(t){return t.replace(/[A-Z]/g,(t=>`_${t.toLowerCase()}`))}const no="ERR_INVALID_VALUE",oo="ERR_UNEXPECTED_VALUE",io="ERR_UNEXPECTED_TYPE",so="ERR_PARSE";function ao(t,e){const r={};for(const n in t){const o=t[n];if(!o)continue;let i,s;"function"==typeof o?(i=n,s=o):[i,s]=o;try{const t=s(e(i));void 0!==t&&(r[n]=t)}catch(t){throw new eo(so,`Parser for "${n}" property failed${i===n?"":`. Source field: "${i}"`}`,t)}}return r}function co(t){let e=t;if("string"==typeof e)try{e=JSON.parse(e)}catch(t){throw new eo(no,{cause:t})}if("object"!=typeof e||!e||Array.isArray(e))throw new eo(oo);return e}function uo(t,e){return r=>{const n=n=>{if(!r||void 0!==n)try{return e(n)}catch(e){throw new eo(so,{message:`"${t}" transformer failed to parse the value`,cause:e})}};return Object.assign(n,{isValid(t){try{return n(t),!0}catch{return!1}}})}}function lo(t,e){return uo(e||"object",(e=>{const r=co(e);return ao(t,(t=>r[t]))}))}function ho(t){throw new eo(io,`Unexpected value received: ${JSON.stringify(t)}`)}const fo=uo("boolean",(t=>{if("boolean"==typeof t)return t;const e=String(t);return"1"===e||"true"===e||"0"!==e&&"false"!==e&&void ho(t)})),po=uo("string",(t=>{if("string"==typeof t||"number"==typeof t)return t.toString();ho(t)})),go=uo("number",(t=>{if("number"==typeof t)return t;if("string"==typeof t){const e=Number(t);if(!Number.isNaN(e))return e}ho(t)})),yo=uo("date",(t=>t instanceof Date?t:new Date(1e3*go()(t))));function wo(t,e){return uo(e||"searchParams",(e=>{"string"!=typeof e&&!(e instanceof URLSearchParams)&&ho(e);const r="string"==typeof e?new URLSearchParams(e):e;return ao(t,(t=>{const e=r.get(t);return null===e?void 0:e}))}))}function mo(t){for(const e in t)t[e]=[ro(e),t[e]];return t}const bo=t=>{const e=go(),r=go(!0),n=po(),o=po(!0),i=fo(!0),s=lo(mo({addedToAttachmentMenu:i,allowsWriteToPm:i,firstName:n,id:e,isBot:i,isPremium:i,languageCode:o,lastName:o,photoUrl:o,username:o}),"User")(!0);return wo(mo({authDate:yo(),canSendAfter:r,chat:lo(mo({id:e,type:n,title:n,photoUrl:o,username:o}),"Chat")(!0),chatInstance:o,chatType:o,hash:n,queryId:o,receiver:s,startParam:o,signature:n,user:s}),"initData")(t)};const vo=uo("rgb",(t=>function(t){const e=t.replace(/\s/g,"").toLowerCase();if(function(t){return/^#[\da-f]{6}$/i.test(t)}(e))return e;if(function(t){return/^#[\da-f]{3}$/i.test(t)}(e)){let t="#";for(let r=0;r<3;r+=1)t+=e[1+r].repeat(2);return t}const r=e.match(/^rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)$/)||e.match(/^rgba\((\d{1,3}),(\d{1,3}),(\d{1,3}),\d{1,3}\)$/);if(!r)throw new Error(`Value "${t}" does not satisfy any of known RGB formats.`);return r.slice(1).reduce(((t,e)=>{const r=parseInt(e,10).toString(16);return t+(1===r.length?"0":"")+r}),"#")}(po()(t)))),_o=uo("themeParams",(t=>{const e=vo(!0);return Object.entries(co(t)).reduce(((t,[r,n])=>(t[function(t){return t.replace(/_[a-z]/g,(t=>t[1].toUpperCase()))}(r)]=e(n),t)),{})}));function Eo(t){return JSON.stringify(Object.fromEntries(Object.entries(t).map((([t,e])=>[ro(t),e]))))}const So=t=>{const e=po(),r=po(!0),n=fo(!0);return wo({botInline:["tgWebAppBotInline",n],defaultColors:["tgWebAppDefaultColors",_o(!0)],fullscreen:["tgWebAppFullscreen",n],initData:["tgWebAppData",bo(!0)],initDataRaw:["tgWebAppData",r],platform:["tgWebAppPlatform",e],showSettings:["tgWebAppShowSettings",n],startParam:["tgWebAppStartParam",r],themeParams:["tgWebAppThemeParams",_o()],version:["tgWebAppVersion",e]},"launchParams")(t)};function Ao(t){const{initDataRaw:e,startParam:r,showSettings:n,botInline:o,fullscreen:i,defaultColors:s}=t,a=new URLSearchParams;return a.set("tgWebAppPlatform",t.platform),a.set("tgWebAppThemeParams",Eo(t.themeParams)),a.set("tgWebAppVersion",t.version),e&&a.set("tgWebAppData",e),r&&a.set("tgWebAppStartParam",r),"boolean"==typeof n&&a.set("tgWebAppShowSettings",n?"1":"0"),"boolean"==typeof o&&a.set("tgWebAppBotInline",o?"1":"0"),"boolean"==typeof i&&a.set("tgWebAppFullscreen",i?"1":"0"),s&&a.set("tgWebAppDefaultColors",Eo(s)),a.toString()}const To=lo({eventType:po(),eventData:t=>t},"miniAppsMessage"),ko=uo("fn",(t=>{if("function"==typeof t)return t;ho(t)}));const Io=lo({TelegramWebviewProxy:lo({postEvent:ko()})()});function Oo(t){return Io().isValid(t)}var Ro=Object.defineProperty,Co=(t,e,r)=>((t,e,r)=>e in t?Ro(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r)(t,"symbol"!=typeof e?e+"":e,r);let Uo=class t extends Error{constructor(e,r,n){super("object"==typeof r?r.message:r||e,{cause:"object"==typeof r?r.cause:n}),this.type=e,this.name="TypedError",Object.setPrototypeOf(this,t.prototype)}};function Bo(t,e,r){return t.addEventListener(e,r),()=>t.removeEventListener(e,r)}function Po(...t){const e=t.flat(1);return[e.push.bind(e),()=>{e.forEach((t=>{t()}))}]}function Lo(t){return e=>function(t,e){return t instanceof Uo&&t.type===e}(e,t)}const xo="ERR_ABORTED",No="ERR_CANCELED",jo="ERR_TIMED_OUT";function Do(t){return new Uo(xo,{cause:t})}Lo(jo),Lo(xo),Lo(No);function Ko(t,e){return t.reject=e.reject,t}class Mo extends Promise{constructor(t,e){let r,n,o,i;"function"==typeof t?(r=t,n=e):n=t,super(((t,e)=>{n||(n={});const{abortSignal:s}=n;if(s&&s.aborted)return e(Do(s.reason));const[a,c]=Po(),u=t=>(...e)=>(c(),t(...e)),l=new AbortController,{signal:h}=l;i=u((t=>{l.abort(t),e(t)})),o=u(t),s&&a(Bo(s,"abort",(()=>{i(Do(s.reason))})));const{timeout:f}=n;if(f){const t=setTimeout((()=>{i(new Uo(jo,`Timeout reached: ${f}ms`))}),f);a((()=>{clearTimeout(t)}))}r&&r(o,i,h)})),Co(this,"reject"),this.reject=i}static withFn(t,e){return new Mo(((e,r,n)=>{try{const o=t(n);return o instanceof Promise?o.then(e,r):e(o)}catch(t){r(t)}}),e)}static resolve(t){return new Mo((e=>{e(t)}))}static reject(t){return new Mo(((e,r)=>{r(t)}))}cancel(){this.reject(new Uo(No))}catch(t){return this.then(void 0,t)}finally(t){return Ko(super.finally(t),this)}then(t,e){return Ko(super.then(t,e),this)}}function $o(t,e){return t.resolve=e.resolve,t}let Fo=class t extends Mo{constructor(t,e){let r,n,o;"function"==typeof t?(r=t,n=e):n=t,super(((t,e,n)=>{o=t,r&&r(t,e,n)}),n),Co(this,"resolve"),this.resolve=o}static withFn(e,r){return new t(((t,r,n)=>Mo.withFn(e,{abortSignal:n}).then(t,r)),r)}static resolve(e){return new t((t=>{t(e)}))}static reject(e){return new t(((t,r)=>{r(e)}))}catch(t){return this.then(void 0,t)}finally(t){return $o(super.finally(t),this)}then(t,e){return $o(super.then(t,e),this)}};function Wo(t){return`tapps/${t}`}function zo(t,e){sessionStorage.setItem(Wo(t),JSON.stringify(e))}function Zo(t){const e=sessionStorage.getItem(Wo(t));try{return e?JSON.parse(e):void 0}catch{}}function Ho(t){return t.replace(/[A-Z]/g,(t=>`-${t.toLowerCase()}`))}function Vo(t,e){e||(e={});const{textColor:r,bgColor:n,shouldLog:o=!0}=e;function i(e,...i){if(!o||"function"==typeof o&&!o())return;const s="font-weight:bold;padding:0 5px;border-radius:5px";console[e](`%c${Intl.DateTimeFormat("en-GB",{hour:"2-digit",minute:"2-digit",second:"2-digit",fractionalSecondDigits:3,timeZone:"UTC"}).format(new Date)}%c / %c${t}`,`${s};background-color: lightblue;color:black`,"",`${s};${r?`color:${r};`:""}${n?`background-color:${n}`:""}`,...i)}return[function(...t){i("log",...t)},function(...t){i("error",...t)}]}function Xo(t,e){document.documentElement.style.setProperty(t,e)}function Jo(t){document.documentElement.style.removeProperty(t)}function qo(t,e){e||(e={});const r=e.equals||Object.is;let n=[],o=t;const i=t=>{if(!r(o,t)){const e=o;o=t,function(t,e){e()}(0,(()=>{[...n].forEach((([r,n])=>{r(t,e),n&&a(r,!0)}))}))}};function s(t){const e="object"!=typeof t?{once:t}:t;return{once:e.once||!1,signal:e.signal||!1}}const a=(t,e)=>{const r=s(e),o=n.findIndex((([e,n])=>e===t&&n.once===r.once&&n.signal===r.signal));o>=0&&n.splice(o,1)},c=Object.assign((function(){return function(t){Go.length&&Go[Go.length-1].add(t)}(c),o}),{destroy(){n=[]},set:i,reset(){i(t)},sub:(t,e)=>(n.push([t,s(e)]),()=>a(t,e)),unsub:a,unsubAll(){n=n.filter((t=>t[1].signal))}});return c}const Go=[];const Yo=qo(!1),[Qo,ti]=Vo("Bridge",{bgColor:"#9147ff",textColor:"white",shouldLog:Yo}),ei={clipboard_text_received:lo({req_id:po(),data:t=>null===t?t:po(!0)(t)},"clipboard_text_received"),custom_method_invoked:lo({req_id:po(),result:t=>t,error:po(!0)},"custom_method_invoked"),popup_closed:uo("popup_closed",(t=>t?lo({button_id:t=>null==t?void 0:po()(t)})()(t):{})),viewport_changed:lo({height:go(),width:t=>null==t?window.innerWidth:go()(t),is_state_stable:fo(),is_expanded:fo()},"viewport_changed")};const ri=qo(),ni=qo();function oi(){return ni()||ni.set(function(t){const e=window,[,r]=Po(Bo(e,"message",(r=>{if(r.source!==e.parent)return;let n;try{n=To()(r.data)}catch{return}const{eventType:o,eventData:i}=n,s=ei[o];try{const e=s?s()(i):i;Qo("Event received:",e?{eventType:o,eventData:e}:{eventType:o}),t([o,e])}catch(t){ti([`An error occurred processing the "${o}" event from the Telegram application.`,"Please, file an issue here:","https://github.com/Telegram-Mini-Apps/telegram-apps/issues/new/choose"].join("\n"),n,t)}})));return r}(ri.set)),ri}const ii=qo({});function si(t){let e=ii()[t];return e||(e=qo(void 0,{equals:()=>!1}),oi().sub((r=>{r&&r[0]===t&&e.set(r[1])})),ii.set({...ii(),[t]:e})),e}function ai(t,e,r){return si(t).sub(e,r)}const ci="ERR_RETRIEVE_LP_FAILED",ui="ERR_UNKNOWN_ENV",li="ERR_INVOKE_CUSTOM_METHOD_RESPONSE",hi=qo("https://web.telegram.org");function fi(t,e){Qo("Posting event:",e?{eventType:t,eventData:e}:{eventType:t});const r=window;if(Oo(r))return void r.TelegramWebviewProxy.postEvent(t,JSON.stringify(e));const n=JSON.stringify({eventType:t,eventData:e});if(function(){try{return window.self!==window.top}catch{return!0}}())return r.parent.postMessage(n,hi());const{external:o}=r;if(!lo({notify:ko()})().isValid(o))throw new Uo(ui);o.notify(n)}function di(t,e,r){r||(r={});const{capture:n}=r,[o,i]=Po();return new Mo((i=>{(Array.isArray(e)?e:[e]).forEach((t=>{o(ai(t,(r=>{(!n||(Array.isArray(e)?n({event:t,payload:r}):n(r)))&&i(r)})))})),(r.postEvent||fi)(t,r.params)}),r).finally(i)}function pi(t){return So()(t)}function gi(t){return pi(t.replace(/^[^?#]*[?#]/,"").replace(/[?#]/g,"&"))}function yi(){return gi(window.location.href)}function wi(){const t=performance.getEntriesByType("navigation")[0];if(!t)throw new Error("Unable to get first navigation entry.");return gi(t.name)}const mi="launchParams";function bi(){return pi(Zo(mi)||"")}function vi(t){zo("launchParams",Ao(t))}function _i(t){return t instanceof Error?t.message+(t.cause?`\n ${_i(t.cause)}`:""):JSON.stringify(t)}function Ei(){const t=[];for(const e of[yi,wi,bi])try{const t=e();return vi(t),t}catch(e){t.push(e)}throw new Uo(ci,["Unable to retrieve launch parameters from any known source. Perhaps, you have opened your app outside Telegram?","📖 Refer to docs for more information:","https://docs.telegram-mini-apps.com/packages/telegram-apps-bridge/environment","Collected errors:",...t.map((t=>`— ${_i(t)}`))].join("\n"))}function Si(t){if("simple"===t)try{return Ei(),!0}catch{return!1}return Mo.withFn((async()=>{if(Oo(window))return!0;try{return await di("web_app_request_theme","theme_changed",{timeout:100}),!0}catch{return!1}}),t)}function Ai(t,e,r){si(t).unsub(e,r)}function Ti(t){return({req_id:e})=>e===t}function ki(t){return t.split(".").map(Number)}function Ii(t,e){return function(t,e){const r=ki(t),n=ki(e),o=Math.max(r.length,n.length);for(let t=0;t<o;t+=1){const e=r[t]||0,o=n[t]||0;if(e!==o)return e>o?1:-1}return 0}(t,e)<=0}function Oi(t,e,r){if("string"==typeof r){if("web_app_open_link"===t){if("try_instant_view"===e)return Ii("6.4",r);if("try_browser"===e)return Ii("7.6",r)}if("web_app_set_header_color"===t&&"color"===e)return Ii("6.9",r);if("web_app_close"===t&&"return_back"===e)return Ii("7.6",r);if("web_app_setup_main_button"===t&&"has_shine_effect"===e)return Ii("7.10",r)}switch(t){case"web_app_open_tg_link":case"web_app_open_invoice":case"web_app_setup_back_button":case"web_app_set_background_color":case"web_app_set_header_color":case"web_app_trigger_haptic_feedback":return Ii("6.1",e);case"web_app_open_popup":return Ii("6.2",e);case"web_app_close_scan_qr_popup":case"web_app_open_scan_qr_popup":case"web_app_read_text_from_clipboard":return Ii("6.4",e);case"web_app_switch_inline_query":return Ii("6.7",e);case"web_app_invoke_custom_method":case"web_app_request_write_access":case"web_app_request_phone":return Ii("6.9",e);case"web_app_setup_settings_button":return Ii("6.10",e);case"web_app_biometry_get_info":case"web_app_biometry_open_settings":case"web_app_biometry_request_access":case"web_app_biometry_request_auth":case"web_app_biometry_update_token":return Ii("7.2",e);case"web_app_setup_swipe_behavior":return Ii("7.7",e);case"web_app_share_to_story":return Ii("7.8",e);case"web_app_setup_secondary_button":case"web_app_set_bottom_bar_color":return Ii("7.10",e);case"web_app_request_safe_area":case"web_app_request_content_safe_area":case"web_app_request_fullscreen":case"web_app_exit_fullscreen":case"web_app_set_emoji_status":case"web_app_add_to_home_screen":case"web_app_check_home_screen":case"web_app_request_emoji_status_access":return Ii("8.0",e);default:return["iframe_ready","iframe_will_reload","web_app_close","web_app_data_send","web_app_expand","web_app_open_link","web_app_ready","web_app_request_theme","web_app_request_viewport","web_app_setup_main_button","web_app_setup_closing_behavior"].includes(t)}}function Ri(){const t=performance.getEntriesByType("navigation")[0];return!!t&&"reload"===t.type}let Ci;function Ui(t){if(Ci)return t();Ci=new Map;try{t()}finally{Ci.forEach((t=>t())),Ci=void 0}}function Bi(t,e){e||(e={});const r=e.equals||Object.is;let n=[],o=t;const i=t=>{if(!r(o,t)){const e=o;o=t,function(t,e){Ci&&Ci.set(t,e)||e()}(c,(()=>{[...n].forEach((([r,n])=>{r(t,e),n&&a(r,!0)}))}))}};function s(t){const e="object"!=typeof t?{once:t}:t;return{once:e.once||!1,signal:e.signal||!1}}const a=(t,e)=>{const r=s(e),o=n.findIndex((([e,n])=>e===t&&n.once===r.once&&n.signal===r.signal));o>=0&&n.splice(o,1)},c=Object.assign((function(){return function(t){Pi.length&&Pi[Pi.length-1].add(t)}(c),o}),{destroy(){n=[]},set:i,reset(){i(t)},sub:(t,e)=>(n.push([t,s(e)]),()=>a(t,e)),unsub:a,unsubAll(){n=n.filter((t=>t[1].signal))}});return c}const Pi=[];function Li(t,e){let r,n=new Set;function o(){return r||(r=Bi(s(),e))}function i(){o().set(s())}function s(){n.forEach((t=>{t.unsub(i,{signal:!0})}));const e=new Set;let r;Pi.push(e);try{r=t()}finally{Pi.pop()}return e.forEach((t=>{t.sub(i,{signal:!0})})),n=e,r}return Object.assign((function(){return o()()}),{destroy(){o().destroy()},sub:(...t)=>o().sub(...t),unsub(...t){o().unsub(...t)},unsubAll(...t){o().unsubAll(...t)}})}const xi=Bi((()=>{let t=0;return()=>(t+=1).toString()})()),Ni=Bi(fi),ji=Bi("0.0");function Di(){return xi()()}function Ki(t,e,r){return function(t,e,r,n){return di("web_app_invoke_custom_method","custom_method_invoked",{...n||{},params:{method:t,params:e,req_id:r},capture:Ti(r)}).then((({result:t,error:e})=>{if(e)throw new Uo(li,e);return t}))}(t,e,Di(),{...r||{},postEvent:$i})}const Mi=(t,e,r)=>(r||(r={}),r.postEvent||(r.postEvent=$i),di(t,e,r)),$i=(t,e)=>Ni()(t,e);function Fi(t){return Li((()=>Oi(t,ji())))}const Wi="ERR_POPUP_INVALID_PARAMS",zi="ERR_INVALID_URL",Zi="ERR_ALREADY_REQUESTING",Hi="ERR_ALREADY_OPENED",Vi="ERR_NOT_INITIALIZED",Xi="ERR_NOT_SUPPORTED",Ji="ERR_NOT_MOUNTED";function qi(){return typeof window>"u"}function Gi(t,e,{isSupported:r,isMounted:n,component:o,supports:i}={}){const s=`${o?`${o}.`:""}${t}()`;function a(t){if(i){const e=i[t];return Oi(e[0],e[1],ji())}return!0}r=r?Array.isArray(r)||"object"==typeof r&&"any"in r?r:[r]:void 0;const c=()=>{if(!r)return;const t=`it is unsupported in Mini Apps version ${ji()}`;function e(e){return"string"==typeof e?Oi(e,ji())?void 0:t:e.fn()?void 0:e.error}if(Array.isArray(r)){for(const t of r){const r=e(t);if(r)return r}return}let n;for(const t of r.any)if(n=e(t),!n)return;return t},u=Li((()=>!c())),l=Li((()=>"0.0"!==ji())),h=Li((()=>!n||n())),f=Li((()=>Si("simple")&&!qi()&&l()&&u()&&h()));let d;if(i){d={};for(const t in i)d[t]=Li((()=>a(t)))}return Object.assign(((...t)=>{const r=`Unable to call the ${s} ${o?"method":"function"}:`;if(qi()||!Si("simple"))throw new Uo(ui,`${r} it can't be called outside Mini Apps`);if(!l())throw new Uo(Vi,`${r} the SDK was not initialized. Use the SDK init() function`);const n=c();if(n)throw new Uo(Xi,`${r} ${n}`);const u=((...t)=>{if(i)for(const e in i)if(i[e][2](...t)&&!a(e))return`option ${e} is not supported in Mini Apps version ${ji()}`})(...t);if(u)throw new Uo(Xi,`${r} ${u}`);if(!h())throw new Uo(Ji,`${r} the component is not mounted. Use the ${o}.mount() method`);return e(...t)}),e,{isAvailable:f,ifAvailable:(...t)=>f()?e(...t):void 0},r?{isSupported:u}:{},d?{supports:d}:{})}function Yi(t,e){return e||(e={}),(r,n,o,i)=>Gi(r,n,{...e,isSupported:o||e.isSupported,supports:i,component:t})}function Qi(t,e,r){return Yi(t,{isSupported:r,isMounted:e})}function ts(t,e){return Yi(t,{isSupported:e})}const es="web_app_setup_back_button",rs="back_button_pressed",ns="backButton",os=Bi(!1),is=Bi(!1),ss=Fi(es),as=Qi(ns,is,es),cs=ts(ns,es),us=as("hide",(()=>{hs(!1)})),ls=cs("mount",(()=>{is()||(hs(Ri()&&Zo(ns)||!1),is.set(!0))}));function hs(t){t!==os()&&($i(es,{is_visible:t}),zo(ns,t),os.set(t))}const fs=cs("onClick",(t=>ai(rs,t))),ds=cs("offClick",(t=>{Ai(rs,t)})),ps=as("show",(()=>{hs(!0)}));Symbol.toStringTag;function gs(t,e,r,n,o){const i=void 0===o||o?Mo:Promise;return Object.assign(((...o)=>i.resolve().then((async()=>{if(r()){const t=e();throw n.set(t),t}let s;Ui((()=>{r.set(i.resolve(t(...o))),n.set(void 0)}));try{s=[!0,await r()]}catch(t){s=[!1,t]}if(Ui((()=>{r.set(void 0),n.set(s[0]?void 0:s[1])})),!s[0])throw s[1];return s[1]}))),t)}function ys(t,e,r,n,o,i){const s=gs(e,(()=>new Uo("ERR_ALREADY_MOUNTING",`The ${t} component is already mounting`)),o,i);return t=>Mo.resolve().then((async()=>{if(!n()){const e=await s(t);Ui((()=>{n.set(!0),r(e)}))}}))}const ws=Yi,ms=Bi({available:!1}),bs=Bi(!1),vs=Bi(!1),_s=Bi(!1),Es=Li((()=>!!As())),Ss=Bi(),As=Bi(),Ts=Li((()=>{const t=ms();return t&&t.available}));function ks(t){return t.available?{available:!0,tokenSaved:t.token_saved,deviceId:t.device_id,accessRequested:t.access_requested,type:t.type,accessGranted:t.access_granted}:{available:!1}}const Is="web_app_biometry_get_info",Os=Gi("requestBiometry",(t=>Mi(Is,"biometry_info_received",t).then(ks)),{isSupported:Is}),Rs="web_app_biometry_request_auth",Cs="biometry_info_received",Us="biometry",Bs=Fi(Rs),Ps=ws(Us),Ls=ts(Us,Rs),xs=Qi(Us,_s,Rs);function Ns(){throw new Uo("ERR_NOT_AVAILABLE","Biometry is not available")}const js=xs("authenticate",(t=>Mo.withFn((async e=>{if(bs())throw new Uo(Zi,"Authentication is already in progress");const r=ms();(!r||!r.available)&&Ns(),bs.set(!0);try{const n=await Mi(Rs,"biometry_auth_requested",{abortSignal:e,params:{reason:((t||{}).reason||"").trim()}}),{token:o}=n;return"string"==typeof o&&Fs({...r,token:o}),n}finally{bs.set(!1)}}),t))),Ds=Ls("openSettings",(()=>{$i("web_app_biometry_open_settings")})),Ks=xs("requestAccess",(t=>Mo.withFn((async e=>{if(vs())throw new Uo(Zi,"Access request is already in progress");vs.set(!0);try{const r=await Mi("web_app_biometry_request_access",Cs,{abortSignal:e,params:{reason:(t||{}).reason||""}}).then(ks);return r.available||Ns(),Fs(r),r.accessGranted}finally{vs.set(!1)}}),t))),Ms=Ps("mount",ys(Us,(t=>Ri()&&Zo(Us)||Os(t)),(t=>{ai(Cs,$s),Fs(t)}),_s,As,Ss)),$s=t=>{Fs(ks(t))};function Fs(t){ms.set(t),zo(Us,t)}const Ws=xs("updateToken",(t=>(t||(t={}),Mi("web_app_biometry_update_token","biometry_token_updated",{...t,params:{token:t.token||"",reason:t.reason}}).then((t=>t.status)))));Symbol.toStringTag;function zs(t,e){return Yi(t,{isMounted:e})}const Zs="closingBehavior",Hs=Bi(!1),Vs=Bi(!1),Xs=zs(Zs,Vs),Js=ws(Zs),qs=Xs("disableConfirmation",(()=>{Qs(!1)})),Gs=Xs("enableConfirmation",(()=>{Qs(!0)})),Ys=Js("mount",(()=>{Vs()||(Qs(Ri()&&Zo(Zs)||!1),Vs.set(!0))}));function Qs(t){t!==Hs()&&($i("web_app_setup_closing_behavior",{need_confirmation:t}),zo(Zs,t),Hs.set(t))}Symbol.toStringTag;const ta="web_app_invoke_custom_method",ea=ts("cloudStorage",ta),ra=Fi(ta),na=ea("deleteItem",((t,e)=>{const r=Array.isArray(t)?t:[t];return r.length?Ki("deleteStorageValues",{keys:r},e).then():Mo.resolve()}));const oa=ea("getItem",(function(t,e){const r=Array.isArray(t)?t:[t];return r.length?Ki("getStorageValues",{keys:r},e).then((e=>{const n=Vn(Object.fromEntries(r.map((t=>[t,Jn()]))))()(e);return Array.isArray(t)?n:n[t]})):Mo.resolve("string"==typeof t?"":{})})),ia=ea("getKeys",(t=>Ki("getStorageKeys",{},t).then(function(t,e){return Hn("array",(e=>{let r;if(Array.isArray(e))r=e;else if("string"==typeof e)try{const t=JSON.parse(e);Array.isArray(t)&&(r=t)}catch{}return r||Xn(e),r.map(t)}))}(Jn())()))),sa=ea("setItem",((t,e,r)=>Ki("saveStorageValue",{key:t,value:e},r).then())),aa=(Symbol.toStringTag,"web_app_trigger_haptic_feedback"),ca=ts("hapticFeedback",aa),ua=Fi(aa),la=ca("impactOccurred",(t=>{$i(aa,{type:"impact",impact_style:t})})),ha=ca("notificationOccurred",(t=>{$i(aa,{type:"notification",notification_type:t})})),fa=ca("selectionChanged",(()=>{$i(aa,{type:"selection_change"})})),da=(Symbol.toStringTag,Bi(void 0));function pa(t){return Li((()=>{const e=da();return e?e[t]:void 0}))}const ga=pa("authDate"),ya=pa("canSendAfter"),wa=Li((()=>{const t=ga(),e=ya();return e&&t?new Date(t.getTime()+1e3*e):void 0})),ma=pa("chat"),ba=pa("chatType"),va=pa("chatInstance"),_a=pa("hash"),Ea=pa("queryId"),Sa=Bi(),Aa=pa("receiver");const Ta=pa("startParam"),ka=pa("user");Symbol.toStringTag;const Ia="web_app_open_invoice",Oa=ts("invoice",Ia),Ra=Bi(!1),Ca=Fi(Ia);async function Ua(t,e,r){if(Ra())throw new Uo(Hi,"An invoice is already opened");let n;if("url"===e){const{hostname:e,pathname:r}=new URL(t,window.location.href);if("t.me"!==e)throw new Uo(zi,`Link has unexpected hostname: ${e}`);const o=r.match(/^\/(\$|invoice\/)([A-Za-z0-9\-_=]+)$/);if(!o)throw new Uo("ERR_INVALID_SLUG",'Expected to receive a link with a pathname in format "/invoice/{slug}" or "/${slug}"');[,,n]=o}else n=t,r=e;return Ra.set(!0),Mi(Ia,"invoice_closed",{...r,params:{slug:n},capture:t=>n===t.slug}).then((t=>t.status)).finally((()=>{Ra.set(!1)}))}const Ba=Oa("open",Ua);Symbol.toStringTag;function Pa(t){return Object.fromEntries(Object.entries(t).filter((t=>void 0!==t[1])))}function La(t){const e=Yn(t);return Math.sqrt([.299,.587,.114].reduce(((t,r,n)=>{const o=parseInt(e.slice(1+2*n,1+2*(n+1)),16);return t+o*o*r}),0))<120}const xa=Bi(!1),Na=Bi(!1),ja=Bi({});function Da(t){return Li((()=>ja()[t]))}const Ka=Da("accentTextColor"),Ma=Da("bgColor"),$a=Da("buttonColor"),Fa=Da("buttonTextColor"),Wa=Da("bottomBarBgColor"),za=Da("destructiveTextColor"),Za=Da("headerBgColor"),Ha=Da("hintColor"),Va=Li((()=>{const{bgColor:t}=ja();return!t||La(t)})),Xa=Da("linkColor"),Ja=Da("secondaryBgColor"),qa=Da("sectionBgColor"),Ga=Da("sectionHeaderTextColor"),Ya=Da("sectionSeparatorColor"),Qa=Da("subtitleTextColor"),tc=Da("textColor");function ec(t){return Li((()=>nc()[t]))}const rc=Bi({hasShineEffect:!1,isEnabled:!0,isLoaderVisible:!1,isVisible:!1,text:"Continue"}),nc=Li((()=>{const t=rc();return{...t,backgroundColor:t.backgroundColor||$a()||"#2481cc",textColor:t.textColor||Fa()||"#ffffff"}})),oc=Bi(!1),ic=ec("backgroundColor"),sc=ec("hasShineEffect"),ac=ec("isEnabled"),cc=ec("isLoaderVisible"),uc=ec("isVisible"),lc=ec("text"),hc=ec("textColor"),fc="main_button_pressed",dc="mainButton",pc=ws(dc),gc=zs(dc,oc),yc=pc("mount",(()=>{if(!oc()){const t=Ri()&&Zo(dc);t&&rc.set(t),oc.set(!0)}})),wc=pc("onClick",(t=>ai(fc,t))),mc=pc("offClick",(t=>{Ai(fc,t)})),bc=gc("setParams",(t=>{rc.set({...rc(),...Pa(t)}),zo(dc,rc());const e=nc();e.text&&$i("web_app_setup_main_button",{color:e.backgroundColor,has_shine_effect:e.hasShineEffect,is_active:e.isEnabled,is_progress_visible:e.isLoaderVisible,is_visible:e.isVisible,text:e.text,text_color:e.textColor})}));Symbol.toStringTag;function vc(){throw new Uo("ERR_VARS_ALREADY_BOUND","CSS variables are already bound")}const _c="themeParams",Ec="theme_changed",Sc=ws(_c),Ac=zs(_c,xa)("bindCssVars",(t=>{function e(t){Object.entries(ja()).forEach((([e,r])=>{r&&t(e,r)}))}function r(){e(((e,r)=>{Xo(t(e),r)}))}return Na()&&vc(),t||(t=t=>`--tg-theme-${Ho(t)}`),r(),ja.sub(r),Na.set(!0),()=>{e(Jo),ja.unsub(r),Na.set(!1)}})),Tc=Sc("mount",(()=>{xa()||(ai(Ec,kc),ja.set(Ri()&&Zo(_c)||Ei().themeParams),xa.set(!0))})),kc=t=>{const e=function(t){return to()(t)}(t.theme_params);ja.set(e),zo(_c,e)};function Ic(t){return Li((()=>{const e=t();return Gn(e)?e:"bg_color"===e?Ma():Ja()}))}const Oc=Bi("bg_color"),Rc=Ic(Oc),Cc=Bi("bottom_bar_bg_color"),Uc=Li((()=>{const t=Cc();return Gn(t)?t:"bottom_bar_bg_color"===t?Wa()||Ja():"secondary_bg_color"===t?Ja():Ma()})),Bc=Bi("bg_color"),Pc=Ic(Bc),Lc=Bi(!1),xc=Bi(!1),Nc=Li((()=>{const t=Rc();return!!t&&La(t)})),jc=Bi(!0),Dc=Li((()=>({backgroundColor:Oc(),bottomBarColor:Cc(),headerColor:Bc(),isActive:jc()}))),Kc="web_app_set_background_color",Mc="web_app_set_bottom_bar_color",$c="web_app_set_header_color",Fc="visibility_changed",Wc="miniApp",zc={any:[Kc,Mc,$c]},Zc=Li((()=>zc.any.some((t=>Oi(t,ji()))))),Hc=ws(Wc),Vc=ts(Wc,zc),Xc=Qi(Wc,Lc,zc),Jc=Xc("bindCssVars",(t=>{xc()&&vc();const[e,r]=Po();function n(t,r){function n(){Xo(t,r()||null)}n(),e(r.sub(n),Jo.bind(null,t))}return t||(t=t=>`--tg-${Ho(t)}`),n(t("bgColor"),Rc),n(t("bottomBarColor"),Uc),n(t("headerColor"),Pc),e((()=>{xc.set(!1)})),xc.set(!0),r})),qc=Hc("close",(t=>{$i("web_app_close",{return_back:t})})),Gc=t=>{jc.set(t.is_visible),tu()},Yc=Vc("mount",(()=>{if(!Lc()){const t=Ri()&&Zo(Wc);Tc(),eu.ifAvailable(t?t.backgroundColor:"bg_color"),ru.ifAvailable(t?t.bottomBarColor:"bottom_bar_bg_color"),nu.ifAvailable(t?t.headerColor:"bg_color"),jc.set(!t||t.isActive),ai(Fc,Gc),Lc.set(!0)}})),Qc=Hc("ready",(()=>{$i("web_app_ready")}));function tu(){zo(Wc,Dc())}const eu=Xc("setBackgroundColor",(t=>{t!==Oc()&&($i(Kc,{color:t}),Oc.set(t),tu())}),Kc),ru=Xc("setBottomBarColor",(t=>{t!==Cc()&&($i(Mc,{color:t}),Cc.set(t),tu())}),Mc),nu=Xc("setHeaderColor",(t=>{t!==Bc()&&($i($c,Gn(t)?{color:t}:{color_key:t}),Bc.set(t),tu())}),$c,{rgb:[$c,"color",Gn]});Symbol.toStringTag;function ou(t){const e=t.message.trim(),r=(t.title||"").trim(),n=t.buttons||[];if(r.length>64)throw new Uo(Wi,`Invalid title: ${r}`);if(!e||e.length>256)throw new Uo(Wi,`Invalid message: ${e}`);if(n.length>3)throw new Uo(Wi,`Invalid buttons count: ${n.length}`);return{title:r,message:e,buttons:n.length?n.map(((t,e)=>{const r=t.id||"";if(r.length>64)throw new Uo(Wi,`Button with index ${e} has invalid id: ${r}`);if(!t.type||"default"===t.type||"destructive"===t.type){const n=t.text.trim();if(!n||n.length>64)throw new Uo(Wi,`Button with index ${e} has invalid text: ${n}`);return{type:t.type,text:n,id:r}}return{type:t.type,id:r}})):[{type:"close",id:""}]}}const iu="web_app_open_popup",su=ts("popup",iu),au=Bi(!1),cu=Fi(iu),uu=su("open",(async t=>{if(au())throw new Uo(Hi,"A popup is already opened");au.set(!0);try{const{button_id:e=null}=await Mi(iu,"popup_closed",{...t,params:ou(t)});return e}finally{au.set(!1)}})),lu=(Symbol.toStringTag,"web_app_open_scan_qr_popup"),hu=ts("qrScanner",lu),fu=hu("close",(()=>{du.set(!1),$i("web_app_close_scan_qr_popup")})),du=Bi(!1),pu=Fi(lu);const gu=hu("open",(function(t){return Mo.withFn((e=>{if(du())throw new Uo(Hi,"The QR Scanner is already opened");du.set(!0),t||(t={});const{onCaptured:r,text:n,capture:o}=t,[,i]=Po(du.sub((()=>{s.resolve()})),ai("scan_qr_popup_closed",(()=>{du.set(!1)})),ai("qr_text_received",(t=>{r?r(t.data):(!o||o(t.data))&&(s.resolve(t.data),fu())}))),s=new Fo({abortSignal:e}).catch(fu).finally(i);return(t.postEvent||$i)(lu,{text:n}),s}),t)}));Symbol.toStringTag;function yu(t){return Li((()=>mu()[t]))}const wu=Bi({hasShineEffect:!1,isEnabled:!0,isLoaderVisible:!1,isVisible:!1,position:"left",text:"Cancel"}),mu=Li((()=>{const t=wu();return{...t,backgroundColor:t.backgroundColor||Uc()||"#000000",textColor:t.textColor||$a()||"#2481cc"}})),bu=Bi(!1),vu=yu("backgroundColor"),_u=yu("hasShineEffect"),Eu=yu("isEnabled"),Su=yu("isLoaderVisible"),Au=yu("isVisible"),Tu=yu("position"),ku=yu("text"),Iu=yu("textColor"),Ou="web_app_setup_secondary_button",Ru="secondary_button_pressed",Cu="secondaryButton",Uu=ts(Cu,Ou),Bu=Qi(Cu,bu,Ou),Pu=Fi(Ou),Lu=Uu("mount",(()=>{if(!bu()){const t=Ri()&&Zo(Cu);t&&wu.set(t),bu.set(!0)}})),xu=Uu("onClick",(t=>ai(Ru,t))),Nu=Uu("offClick",(t=>{Ai(Ru,t)})),ju=Bu("setParams",(t=>{wu.set({...wu(),...Object.fromEntries(Object.entries(t).filter((([,t])=>void 0!==t)))}),zo(Cu,wu());const e=mu();e.text&&$i(Ou,{color:e.backgroundColor,has_shine_effect:e.hasShineEffect,is_active:e.isEnabled,is_progress_visible:e.isLoaderVisible,is_visible:e.isVisible,position:e.position,text:e.text,text_color:e.textColor})}));Symbol.toStringTag;const Du="web_app_setup_settings_button",Ku="settings_button_pressed",Mu="settingsButton",$u=Bi(!1),Fu=Bi(!1),Wu=Fi(Du),zu=ts(Mu,Du),Zu=Qi(Mu,Fu,Du),Hu=Zu("hide",(()=>{Xu(!1)})),Vu=zu("mount",(()=>{Fu()||(Xu(Ri()&&Zo(Mu)||!1),Fu.set(!0))}));function Xu(t){t!==$u()&&($i(Du,{is_visible:t}),zo(Mu,t),$u.set(t))}const Ju=zu("onClick",(t=>ai(Ku,t))),qu=zu("offClick",(t=>{Ai(Ku,t)})),Gu=Zu("show",(()=>{Xu(!0)}));Symbol.toStringTag;const Yu="web_app_setup_swipe_behavior",Qu="swipeBehavior",tl=Bi(!1),el=Fi(Yu),rl=Bi(!0),nl=ts(Qu,Yu),ol=Qi(Qu,tl,Yu),il=ol("disableVertical",(()=>{cl(!1)})),sl=ol("enableVertical",(()=>{cl(!0)})),al=nl("mount",(()=>{tl()||(cl(Ri()&&Zo(Qu)||!1,!0),tl.set(!0))}));function cl(t,e){(t!==rl()||e)&&($i(Yu,{allow_vertical_swipe:t}),zo(Qu,t),rl.set(t))}Symbol.toStringTag,Symbol.toStringTag;const ul="viewport",ll="web_app_request_fullscreen",hl="fullscreen_changed",fl="safe_area_changed",dl="content_safe_area_changed",pl="viewport_changed",gl="web_app_request_safe_area",yl="web_app_request_content_safe_area",wl={left:0,top:0,bottom:0,right:0};function ml(t){return Math.max(t,0)}const bl=Bi({contentSafeAreaInsets:wl,height:0,isExpanded:!1,isFullscreen:!1,safeAreaInsets:wl,stableHeight:0,width:0});function vl(t){return Li((()=>bl()[t]))}function _l(t){const{height:e,stableHeight:r,width:n}=t;bl.set({...bl(),...Pa({...t,height:e?ml(e):void 0,width:n?ml(n):void 0,stableHeight:r?ml(r):void 0})}),zo(ul,bl())}const El=vl("isFullscreen"),Sl=Bi(),Al=Li((()=>!!Sl())),Tl=Bi(),kl=Bi(!1),Il=Li((()=>!!Rl())),Ol=Bi(void 0),Rl=Bi(),Cl=Qi(ul,kl,ll);function Ul(t,e){return Cl(t,gs((t=>Mi(e,[hl,"fullscreen_failed"],t).then((t=>{if("error"in t){if("ALREADY_FULLSCREEN"===t.error)return!0;throw new Uo("ERR_FULLSCREEN_FAILED","Fullscreen request failed",t.error)}return t.is_fullscreen})).then((t=>{t!==El()&&_l({isFullscreen:t})}))),(()=>new Uo(Zi,"Fullscreen mode change is already being requested")),Sl,Tl))}const Bl=Ul("requestFullscreen",ll),Pl=Ul("exitFullscreen","web_app_exit_fullscreen"),Ll=ws(ul),xl=zs(ul,kl);function Nl(t){return Li((()=>jl()[t]))}const jl=vl("safeAreaInsets"),Dl=Nl("bottom"),Kl=Nl("left"),Ml=Nl("right"),$l=Nl("top");function Fl(t){return Li((()=>Wl()[t]))}const Wl=vl("contentSafeAreaInsets"),zl=Fl("bottom"),Zl=Fl("left"),Hl=Fl("right"),Vl=Fl("top"),Xl=Gi("requestContentSafeAreaInsets",(t=>Mi(yl,"content_safe_area_changed",t)),{isSupported:yl}),Jl=Gi("requestSafeAreaInsets",(t=>Mi(gl,"safe_area_changed",t)),{isSupported:gl});const ql=t=>{const{height:e}=t;_l({isExpanded:t.is_expanded,height:e,width:t.width,stableHeight:t.is_state_stable?e:void 0})},Gl=t=>{_l({isFullscreen:t.is_fullscreen})},Yl=t=>{_l({safeAreaInsets:t})},Ql=t=>{_l({contentSafeAreaInsets:t})},th=Ll("mount",ys(ul,(t=>Mo.resolve().then((async()=>{const e=Ri()&&Zo(ul);if(e)return e;const[r,n]=await Mo.all([Jl.ifAvailable(t)||jl(),Xl.ifAvailable(t)||Wl()]),o=Ei(),i={contentSafeAreaInsets:n,isFullscreen:!!o.fullscreen,safeAreaInsets:r};if(["macos","tdesktop","unigram","webk","weba","web"].includes(o.platform)){const t=window;return{...i,height:t.innerHeight,isExpanded:!0,stableHeight:t.innerHeight,width:t.innerWidth}}return function(t){return Mi("web_app_request_viewport","viewport_changed",t).then((t=>({height:t.height,width:t.width,isExpanded:t.is_expanded,isStable:t.is_state_stable})))}(t).then((t=>({...i,height:t.height,isExpanded:t.isExpanded,stableHeight:t.isStable?t.height:0,width:t.width})))}))),(t=>{ai(pl,ql),ai(hl,Gl),ai(fl,Yl),ai(dl,Ql),_l(t)}),kl,Rl,Ol));const eh=Bi(!1),rh=vl("height"),nh=vl("stableHeight"),oh=vl("width"),ih=xl("bindCssVars",(t=>{eh()&&vc(),t||(t=t=>`--tg-viewport-${Ho(t)}`);const e=[["height",rh],["stableHeight",nh],["width",oh],["safeAreaInsetTop",$l],["safeAreaInsetBottom",Dl],["safeAreaInsetLeft",Kl],["safeAreaInsetRight",Ml],["contentSafeAreaInsetTop",Vl],["contentSafeAreaInsetBottom",zl],["contentSafeAreaInsetLeft",Zl],["contentSafeAreaInsetRight",Hl]].reduce(((e,[r,n])=>{const o=t(r);if(o){const t=()=>{Xo(o,`${n()}px`)};e.push([t,n.sub(t),o])}return e}),[]);return e.forEach((t=>{t[0]()})),eh.set(!0),()=>{e.forEach((t=>{t[1](),Jo(t[2])})),eh.set(!1)}})),sh=Ll("expand",(()=>{$i("web_app_expand")})),ah=vl("isExpanded"),ch=Li((()=>rh()===nh())),uh=(Symbol.toStringTag,ws()("openLink",((t,e)=>{if("string"==typeof t)try{t=new URL(t)}catch(e){throw new Uo(zi,`"${t.toString()}" is invalid URL`,e)}e||(e={}),$i("web_app_open_link",{url:t.toString(),try_browser:e.tryBrowser,try_instant_view:e.tryInstantView})})),"web_app_open_tg_link"),lh=ws()("openTelegramLink",(t=>{const e=t.toString();if(!e.match(/^https:\/\/t.me\/.+/))throw new Uo(zi,`"${e}" is invalid URL`);Oi(uh,ji())?(t=new URL(t),$i(uh,{path_full:t.pathname+t.search})):window.location.href=e}));ws()("shareURL",((t,e)=>{lh("https://t.me/share/url?"+new URLSearchParams({url:t,text:e||""}).toString().replace(/\+/g,"%20"))}));function hh(){try{const t=document.createElement("iframe"),e=function(){if("undefined"!=typeof chrome&&chrome.runtime)return chrome.runtime.getURL("data_request_iframe.html");const t=window.location.origin,e="undefined"!=typeof window&&window.__NEXT_DATA__;return"".concat(t,e?"/_next/static/data_request_iframe.html":"/data_request_iframe.html")}();t.setAttribute("src",e),t.setAttribute("title","Onairos Terminal"),t.classList.add("iframe-class"),t.style.width="100%",t.style.height="600px",t.style.border="none",t.style.backgroundColor="transparent";const r=400,n=600,o=10,i=window.innerWidth-r-10,s=window.open(e,"Onairos Terminal","width=".concat(r,",height=").concat(n,",top=").concat(o,",left=").concat(i,",resizable=no"));if(!s)throw new Error("Failed to open window - popup blocked");return s.document.body.style.margin="0",s.document.body.style.padding="0",s.document.body.style.overflow="hidden",s.addEventListener("beforeunload",(()=>{window.postMessage({action:"terminalClosed"},"*")})),s}catch(t){return console.error("Error opening iframe:",t),alert("Unable to open Onairos Terminal. Please ensure popups are allowed for this site."),null}}function fh(t){if(t&&!t.closed)try{t.close(),window.postMessage({action:"terminalClosed"},"*")}catch(t){console.error("Error closing iframe:",t)}}const dh=async()=>(await a.e(423).then(a.t.bind(a,153,23))).default;function ph(t){let{requestData:n,webpageName:o,inferenceData:i=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=()=>{const t=navigator.userAgent||navigator.vendor||window.opera;return void 0!==window.Telegram&&/telegram/i.test(t)&&/mobile/i.test(navigator.userAgent)},[w,m]=(0,e.useState)(null);(0,e.useEffect)((()=>{let t=!0;if(y()){const r=(0,e.useMemo)(Ei,[]);t&&m(r)}return()=>{t=!1}}),[]),(0,e.useEffect)((()=>{if(w&&(console.log("Launch Params:",w),w.startParam))try{ht("Received parameters: ".concat(w.startParam)),q({show:!0,type:"callback",data:{startParam:w.startParam}})}catch(t){console.error("Error parsing launch params:",t)}}),[w]),(0,e.useEffect)((()=>{if(y())try{var t;const e=null===(t=window.Telegram)||void 0===t?void 0:t.WebApp;e&&e.ready()}catch(t){console.error("Error initializing Telegram WebApp:",t)}}),[]);const[b,v]=(0,e.useState)(null),[_,E]=(0,e.useState)(!1),[S,A]=(0,e.useState)([]),[T,k]=(0,e.useState)(0),[I,O]=(0,e.useState)({}),[R,C]=(0,e.useState)(!1),[U,B]=(0,e.useState)(!1),[P,L]=(0,e.useState)(!1),[x,N]=(0,e.useState)(!1),j=(0,e.useRef)(!1),D=(0,e.useRef)(!1),[K,M]=(0,e.useState)(!1),[$,F]=(0,e.useState)(null),[W,z]=(0,e.useState)(!0),[Z,H]=(0,e.useState)(null),[V,X]=(0,e.useState)(null),[J,q]=(0,e.useState)({show:!1,type:null,data:null}),[G,Y]=(0,e.useState)(null),[Q,tt]=(0,e.useState)(!1),[et,rt]=(0,e.useState)(!1),nt=(0,e.useRef)(!1),[ot,it]=(0,e.useState)(null),[st,at]=(0,e.useState)({show:!1,color:null,message:null}),[ct,ut]=(0,e.useState)(null),[lt,ht]=(0,e.useState)("Initializing..."),ft="https://api2.onairos.uk";(0,e.useEffect)((()=>{if(!y())return;(async()=>{const t=new URL(window.location.href),e=t.searchParams.get("code"),r=t.searchParams.get("state");if(e&&r&&!nt.current&&!et){nt.current=!0,rt(!0);try{const t=await fetch("".concat(ft,"/auth/callback"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:e,state:r})});if(!t.ok)throw new Error("Failed to get Othent token");const{sessionId:n}=await t.json();(async()=>{const t=setInterval((async()=>{try{const e=await fetch("".concat(ft,"/auth/token/").concat(n),{method:"GET",headers:{"Content-Type":"application/json"}});if(!e.ok)throw new Error("HTTP error! Status: ".concat(e.status));const r=await e.json();r.othentToken&&(clearInterval(t),await dt(r.othentToken),N(!0),window.history.replaceState({},document.title,window.location.pathname))}catch(e){console.error("Error polling for token:",e),clearInterval(t),it("Failed to retrieve authentication token"),rt(!1)}}),3e3);setTimeout((()=>{clearInterval(t),x||(it("Authentication timeout"),rt(!1))}),12e4)})()}catch(t){console.error("Auth callback processing failed:",t),it(t.message),rt(!1)}}})()}),[]);const dt=async t=>{try{const e=new jn({appInfo:{name:"Onairos",version:"1.0.0",env:"production"},throwErrors:!0,auth0LogInMethod:"redirect",auth0RedirectURI:window.location.href,auth0ReturnToURI:window.location.href}),r=await e.completeConnectionWithToken(t);M(!0);const n=(await dh())(r.sub).toString();H(n);const o=await Dn(n);X(o.result),F(o.token),await _t(r.email,!0),E(!0),localStorage.setItem("othentToken",JSON.stringify(r)),localStorage.setItem("onairosToken",r.token)}catch(t){throw at({show:!0,color:"red",message:"An error has occurred, please try again"}),console.error("Authentication failed:",t),t}finally{rt(!1)}};(0,e.useEffect)((()=>{ot&&console.error("Authentication error:",ot)}),[ot]);const pt=()=>{const t=navigator.userAgent||navigator.vendor||window.opera;return/android|iphone|ipad|ipod|windows phone/i.test(t)};(0,e.useEffect)((()=>{if(a&&i&&"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,o=(t=>{const e={Small:16,Medium:32,Large:64};let r=null,n=0;return t.forEach((t=>{const o=e[t.data];o>n&&(n=o,r=t)})),n})(r),a={Input:i.slice(0,o)};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)}}}),[]);window.location.href;const[gt,yt]=(0,e.useState)(null),wt=(0,e.useRef)(null);(0,e.useEffect)((()=>()=>{wt.current&&wt.current(),gt&&fh(gt)}),[gt]);const mt="flex items-center justify-center font-bold rounded cursor-pointer ".concat("pill"===f?"px-4 py-2":"w-12 h-12"," bg-transparent OnairosConnect"),bt={flexDirection:"below"===u?"column":"row",backgroundColor:"transparent",color:l,border:"1px solid transparent"},vt={width:"20px",height:"20px",marginRight:"full"===g?"12px":"0"},_t=async function(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];try{const r=e?{Info:{identifier:t}}:{Info:{userName:t}},n=e?"/getAccountInfo/email":"/getAccountInfo",o=await fetch("".concat(ft).concat(n),{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(localStorage.getItem("onairosToken"))},body:JSON.stringify(r)});if(!o.ok)throw new Error("Failed to fetch account info");const i=await o.json();return"No Account Found"===i.AccountInfo?(j.current=!0,Y(null),null):(Y(i.AccountInfo),i.AccountInfo.models?A(i.AccountInfo.models):D.current=!0,i.AccountInfo.avatar&&C(!0),i.AccountInfo.UserTraits&&B(!0),i.AccountInfo.othent&&L(!0),i.AccountInfo)}catch(t){throw console.error("Error fetching account info:",t),t}};(0,e.useEffect)((()=>{pt()&&(async()=>{try{const t=localStorage.getItem("onairosToken"),e=localStorage.getItem("token"),r=t||e;if(r){const t=await fetch("https://api2.onairos.uk/verifyToken",{headers:{Authorization:"Bearer ".concat(r)}});if(t.ok)if((await t.json()).valid){F(r),M(!0);const t=localStorage.getItem("username");await _t(t)}else localStorage.removeItem("onairosToken"),localStorage.removeItem("token")}}catch(t){console.error("Token verification failed:",t)}finally{z(!1)}})()}),[]);(0,e.useEffect)((()=>{const t=localStorage.getItem("onairosToken"),e=localStorage.getItem("username");t&&e&&_t(e,!1)}),[]);return(0,e.useEffect)((()=>{(async()=>{const t=localStorage.getItem("onairosToken"),e=localStorage.getItem("username"),r=localStorage.getItem("othentToken");if(t)try{if((await fetch("".concat(ft,"/verifyToken"),{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(t)}})).ok){if(M(!0),e)await _t(e,!1);else if(r){const t=JSON.parse(r);await _t(t.email,!0)}}else localStorage.removeItem("onairosToken"),localStorage.removeItem("username"),localStorage.removeItem("othentToken")}catch(t){console.error("Token verification failed:",t)}})()}),[]),r().createElement("div",{className:"flex items-center justify-center"},r().createElement("button",{className:mt,onClick:async()=>{try{const t=hh();if(!t)return void console.error("Failed to open iframe window");yt(t);const e=function(t){const e=e=>{e.data&&"onairosIframe"===e.data.source&&t(e.data)};return window.addEventListener("message",e),()=>{window.removeEventListener("message",e)}}((async e=>{try{"iframeReady"===e.action?await function(t,e){return new Promise(((r,n)=>{if(t&&!t.closed)try{t.postMessage(e,"*");const o=setTimeout((()=>{n(new Error("Timeout waiting for iframe response"))}),5e3),i=t=>{t.data&&"dataReceived"===t.data.action&&(clearTimeout(o),window.removeEventListener("message",i),r())};window.addEventListener("message",i)}catch(t){n(t)}else n(new Error("Iframe window is not available"))}))}(t,{type:"initDataRequest",requestData:n,dataRequester:o,domain:window.location.href}):"dataRequestConfirmed"===e.action?(s&&await s(e.approvedRequests),yt(null)):"dataRequestRejected"===e.action?(s&&await s(null),yt(null)):"terminalClosed"===e.action&&yt(null)}catch(e){console.error("Error handling iframe message:",e),fh(t),yt(null)}}));wt.current=e}catch(t){console.error("Error in openTerminal:",t),yt(null)}},style:bt},("full"===g||"icon"===g)&&r().createElement("img",{src:"https://onairos.sirv.com/Images/OnairosBlack.png",alt:"Onairos Logo",style:vt,className:"".concat("pill"===f?"w-6 h-6":"w-8 h-8"," object-contain")}),("full"===g||"textOnly"===g)&&r().createElement("span",{className:"".concat("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"}})())))}function gh(t){return r().createElement(r().Fragment,null,r().createElement(ph,t))}const yh=gh})(),c})()));
2
2
  //# sourceMappingURL=onairos.bundle.js.map