@imtbl/sdk 0.4.3 → 0.4.4

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.
@@ -28,5 +28,5 @@ e.exports=r=function(){return n},e.exports.__esModule=!0,e.exports.default=e.exp
28
28
  * @author Chen, Yi-Cyuan [emn178@gmail.com]
29
29
  * @copyright Chen, Yi-Cyuan 2015-2018
30
30
  * @license MIT
31
- */Ck=Pk,function(){var e="input is invalid type",t="object"==typeof window,r=t?window:{};r.JS_SHA3_NO_WINDOW&&(t=!1);var n=!t&&"object"==typeof self;!r.JS_SHA3_NO_NODE_JS&&"object"==typeof process&&process.versions&&process.versions.node?r=AA:n&&(r=self);var i=!r.JS_SHA3_NO_COMMON_JS&&Ck.exports,a=!r.JS_SHA3_NO_ARRAY_BUFFER&&"undefined"!=typeof ArrayBuffer,s="0123456789abcdef".split(""),o=[4,1024,262144,67108864],c=[0,8,16,24],f=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],u=[224,256,384,512],d=[128,256],l=["hex","buffer","arrayBuffer","array","digest"],h={128:168,256:136};!r.JS_SHA3_NO_NODE_JS&&Array.isArray||(Array.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)}),!a||!r.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW&&ArrayBuffer.isView||(ArrayBuffer.isView=function(e){return"object"==typeof e&&e.buffer&&e.buffer.constructor===ArrayBuffer});for(var p=function(e,t,r){return function(n){return new O(e,t,e).update(n)[r]()}},b=function(e,t,r){return function(n,i){return new O(e,t,i).update(n)[r]()}},g=function(e,t,r){return function(t,n,i,a){return _["cshake"+e].update(t,n,i,a)[r]()}},m=function(e,t,r){return function(t,n,i,a){return _["kmac"+e].update(t,n,i,a)[r]()}},y=function(e,t,r,n){for(var i=0;i<l.length;++i){var a=l[i];e[a]=t(r,n,a)}return e},v=function(e,t){var r=p(e,t,"hex");return r.create=function(){return new O(e,t,e)},r.update=function(e){return r.create().update(e)},y(r,p,e,t)},w=[{name:"keccak",padding:[1,256,65536,16777216],bits:u,createMethod:v},{name:"sha3",padding:[6,1536,393216,100663296],bits:u,createMethod:v},{name:"shake",padding:[31,7936,2031616,520093696],bits:d,createMethod:function(e,t){var r=b(e,t,"hex");return r.create=function(r){return new O(e,t,r)},r.update=function(e,t){return r.create(t).update(e)},y(r,b,e,t)}},{name:"cshake",padding:o,bits:d,createMethod:function(e,t){var r=h[e],n=g(e,0,"hex");return n.create=function(n,i,a){return i||a?new O(e,t,n).bytepad([i,a],r):_["shake"+e].create(n)},n.update=function(e,t,r,i){return n.create(t,r,i).update(e)},y(n,g,e,t)}},{name:"kmac",padding:o,bits:d,createMethod:function(e,t){var r=h[e],n=m(e,0,"hex");return n.create=function(n,i,a){return new I(e,t,i).bytepad(["KMAC",a],r).bytepad([n],r)},n.update=function(e,t,r,i){return n.create(e,r,i).update(t)},y(n,m,e,t)}}],_={},E=[],A=0;A<w.length;++A)for(var S=w[A],k=S.bits,x=0;x<k.length;++x){var T=S.name+"_"+k[x];if(E.push(T),_[T]=S.createMethod(k[x],S.padding),"sha3"!==S.name){var R=S.name+k[x];E.push(R),_[R]=_[T]}}function O(e,t,r){this.blocks=[],this.s=[],this.padding=t,this.outputBits=r,this.reset=!0,this.finalized=!1,this.block=0,this.start=0,this.blockCount=1600-(e<<1)>>5,this.byteCount=this.blockCount<<2,this.outputBlocks=r>>5,this.extraBytes=(31&r)>>3;for(var n=0;n<50;++n)this.s[n]=0}function I(e,t,r){O.call(this,e,t,r)}O.prototype.update=function(t){if(this.finalized)throw new Error("finalize already called");var r,n=typeof t;if("string"!==n){if("object"!==n)throw new Error(e);if(null===t)throw new Error(e);if(a&&t.constructor===ArrayBuffer)t=new Uint8Array(t);else if(!(Array.isArray(t)||a&&ArrayBuffer.isView(t)))throw new Error(e);r=!0}for(var i,s,o=this.blocks,f=this.byteCount,u=t.length,d=this.blockCount,l=0,h=this.s;l<u;){if(this.reset)for(this.reset=!1,o[0]=this.block,i=1;i<d+1;++i)o[i]=0;if(r)for(i=this.start;l<u&&i<f;++l)o[i>>2]|=t[l]<<c[3&i++];else for(i=this.start;l<u&&i<f;++l)(s=t.charCodeAt(l))<128?o[i>>2]|=s<<c[3&i++]:s<2048?(o[i>>2]|=(192|s>>6)<<c[3&i++],o[i>>2]|=(128|63&s)<<c[3&i++]):s<55296||s>=57344?(o[i>>2]|=(224|s>>12)<<c[3&i++],o[i>>2]|=(128|s>>6&63)<<c[3&i++],o[i>>2]|=(128|63&s)<<c[3&i++]):(s=65536+((1023&s)<<10|1023&t.charCodeAt(++l)),o[i>>2]|=(240|s>>18)<<c[3&i++],o[i>>2]|=(128|s>>12&63)<<c[3&i++],o[i>>2]|=(128|s>>6&63)<<c[3&i++],o[i>>2]|=(128|63&s)<<c[3&i++]);if(this.lastByteIndex=i,i>=f){for(this.start=i-f,this.block=o[d],i=0;i<d;++i)h[i]^=o[i];M(h),this.reset=!0}else this.start=i}return this},O.prototype.encode=function(e,t){var r=255&e,n=1,i=[r];for(r=255&(e>>=8);r>0;)i.unshift(r),r=255&(e>>=8),++n;return t?i.push(n):i.unshift(n),this.update(i),i.length},O.prototype.encodeString=function(t){var r,n=typeof t;if("string"!==n){if("object"!==n)throw new Error(e);if(null===t)throw new Error(e);if(a&&t.constructor===ArrayBuffer)t=new Uint8Array(t);else if(!(Array.isArray(t)||a&&ArrayBuffer.isView(t)))throw new Error(e);r=!0}var i=0,s=t.length;if(r)i=s;else for(var o=0;o<t.length;++o){var c=t.charCodeAt(o);c<128?i+=1:c<2048?i+=2:c<55296||c>=57344?i+=3:(c=65536+((1023&c)<<10|1023&t.charCodeAt(++o)),i+=4)}return i+=this.encode(8*i),this.update(t),i},O.prototype.bytepad=function(e,t){for(var r=this.encode(t),n=0;n<e.length;++n)r+=this.encodeString(e[n]);var i=t-r%t,a=[];return a.length=i,this.update(a),this},O.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var e=this.blocks,t=this.lastByteIndex,r=this.blockCount,n=this.s;if(e[t>>2]|=this.padding[3&t],this.lastByteIndex===this.byteCount)for(e[0]=e[r],t=1;t<r+1;++t)e[t]=0;for(e[r-1]|=2147483648,t=0;t<r;++t)n[t]^=e[t];M(n)}},O.prototype.toString=O.prototype.hex=function(){this.finalize();for(var e,t=this.blockCount,r=this.s,n=this.outputBlocks,i=this.extraBytes,a=0,o=0,c="";o<n;){for(a=0;a<t&&o<n;++a,++o)e=r[a],c+=s[e>>4&15]+s[15&e]+s[e>>12&15]+s[e>>8&15]+s[e>>20&15]+s[e>>16&15]+s[e>>28&15]+s[e>>24&15];o%t==0&&(M(r),a=0)}return i&&(e=r[a],c+=s[e>>4&15]+s[15&e],i>1&&(c+=s[e>>12&15]+s[e>>8&15]),i>2&&(c+=s[e>>20&15]+s[e>>16&15])),c},O.prototype.arrayBuffer=function(){this.finalize();var e,t=this.blockCount,r=this.s,n=this.outputBlocks,i=this.extraBytes,a=0,s=0,o=this.outputBits>>3;e=i?new ArrayBuffer(n+1<<2):new ArrayBuffer(o);for(var c=new Uint32Array(e);s<n;){for(a=0;a<t&&s<n;++a,++s)c[s]=r[a];s%t==0&&M(r)}return i&&(c[a]=r[a],e=e.slice(0,o)),e},O.prototype.buffer=O.prototype.arrayBuffer,O.prototype.digest=O.prototype.array=function(){this.finalize();for(var e,t,r=this.blockCount,n=this.s,i=this.outputBlocks,a=this.extraBytes,s=0,o=0,c=[];o<i;){for(s=0;s<r&&o<i;++s,++o)e=o<<2,t=n[s],c[e]=255&t,c[e+1]=t>>8&255,c[e+2]=t>>16&255,c[e+3]=t>>24&255;o%r==0&&M(n)}return a&&(e=o<<2,t=n[s],c[e]=255&t,a>1&&(c[e+1]=t>>8&255),a>2&&(c[e+2]=t>>16&255)),c},I.prototype=new O,I.prototype.finalize=function(){return this.encode(this.outputBits,!0),O.prototype.finalize.call(this)};var M=function(e){var t,r,n,i,a,s,o,c,u,d,l,h,p,b,g,m,y,v,w,_,E,A,S,k,x,T,R,O,I,M,C,P,N,B,U,L,j,D,F,q,z,K,H,G,V,W,X,$,J,Y,Q,Z,ee,te,re,ne,ie,ae,se,oe,ce,fe,ue;for(n=0;n<48;n+=2)i=e[0]^e[10]^e[20]^e[30]^e[40],a=e[1]^e[11]^e[21]^e[31]^e[41],s=e[2]^e[12]^e[22]^e[32]^e[42],o=e[3]^e[13]^e[23]^e[33]^e[43],c=e[4]^e[14]^e[24]^e[34]^e[44],u=e[5]^e[15]^e[25]^e[35]^e[45],d=e[6]^e[16]^e[26]^e[36]^e[46],l=e[7]^e[17]^e[27]^e[37]^e[47],t=(h=e[8]^e[18]^e[28]^e[38]^e[48])^(s<<1|o>>>31),r=(p=e[9]^e[19]^e[29]^e[39]^e[49])^(o<<1|s>>>31),e[0]^=t,e[1]^=r,e[10]^=t,e[11]^=r,e[20]^=t,e[21]^=r,e[30]^=t,e[31]^=r,e[40]^=t,e[41]^=r,t=i^(c<<1|u>>>31),r=a^(u<<1|c>>>31),e[2]^=t,e[3]^=r,e[12]^=t,e[13]^=r,e[22]^=t,e[23]^=r,e[32]^=t,e[33]^=r,e[42]^=t,e[43]^=r,t=s^(d<<1|l>>>31),r=o^(l<<1|d>>>31),e[4]^=t,e[5]^=r,e[14]^=t,e[15]^=r,e[24]^=t,e[25]^=r,e[34]^=t,e[35]^=r,e[44]^=t,e[45]^=r,t=c^(h<<1|p>>>31),r=u^(p<<1|h>>>31),e[6]^=t,e[7]^=r,e[16]^=t,e[17]^=r,e[26]^=t,e[27]^=r,e[36]^=t,e[37]^=r,e[46]^=t,e[47]^=r,t=d^(i<<1|a>>>31),r=l^(a<<1|i>>>31),e[8]^=t,e[9]^=r,e[18]^=t,e[19]^=r,e[28]^=t,e[29]^=r,e[38]^=t,e[39]^=r,e[48]^=t,e[49]^=r,b=e[0],g=e[1],W=e[11]<<4|e[10]>>>28,X=e[10]<<4|e[11]>>>28,O=e[20]<<3|e[21]>>>29,I=e[21]<<3|e[20]>>>29,oe=e[31]<<9|e[30]>>>23,ce=e[30]<<9|e[31]>>>23,K=e[40]<<18|e[41]>>>14,H=e[41]<<18|e[40]>>>14,B=e[2]<<1|e[3]>>>31,U=e[3]<<1|e[2]>>>31,m=e[13]<<12|e[12]>>>20,y=e[12]<<12|e[13]>>>20,$=e[22]<<10|e[23]>>>22,J=e[23]<<10|e[22]>>>22,M=e[33]<<13|e[32]>>>19,C=e[32]<<13|e[33]>>>19,fe=e[42]<<2|e[43]>>>30,ue=e[43]<<2|e[42]>>>30,te=e[5]<<30|e[4]>>>2,re=e[4]<<30|e[5]>>>2,L=e[14]<<6|e[15]>>>26,j=e[15]<<6|e[14]>>>26,v=e[25]<<11|e[24]>>>21,w=e[24]<<11|e[25]>>>21,Y=e[34]<<15|e[35]>>>17,Q=e[35]<<15|e[34]>>>17,P=e[45]<<29|e[44]>>>3,N=e[44]<<29|e[45]>>>3,k=e[6]<<28|e[7]>>>4,x=e[7]<<28|e[6]>>>4,ne=e[17]<<23|e[16]>>>9,ie=e[16]<<23|e[17]>>>9,D=e[26]<<25|e[27]>>>7,F=e[27]<<25|e[26]>>>7,_=e[36]<<21|e[37]>>>11,E=e[37]<<21|e[36]>>>11,Z=e[47]<<24|e[46]>>>8,ee=e[46]<<24|e[47]>>>8,G=e[8]<<27|e[9]>>>5,V=e[9]<<27|e[8]>>>5,T=e[18]<<20|e[19]>>>12,R=e[19]<<20|e[18]>>>12,ae=e[29]<<7|e[28]>>>25,se=e[28]<<7|e[29]>>>25,q=e[38]<<8|e[39]>>>24,z=e[39]<<8|e[38]>>>24,A=e[48]<<14|e[49]>>>18,S=e[49]<<14|e[48]>>>18,e[0]=b^~m&v,e[1]=g^~y&w,e[10]=k^~T&O,e[11]=x^~R&I,e[20]=B^~L&D,e[21]=U^~j&F,e[30]=G^~W&$,e[31]=V^~X&J,e[40]=te^~ne&ae,e[41]=re^~ie&se,e[2]=m^~v&_,e[3]=y^~w&E,e[12]=T^~O&M,e[13]=R^~I&C,e[22]=L^~D&q,e[23]=j^~F&z,e[32]=W^~$&Y,e[33]=X^~J&Q,e[42]=ne^~ae&oe,e[43]=ie^~se&ce,e[4]=v^~_&A,e[5]=w^~E&S,e[14]=O^~M&P,e[15]=I^~C&N,e[24]=D^~q&K,e[25]=F^~z&H,e[34]=$^~Y&Z,e[35]=J^~Q&ee,e[44]=ae^~oe&fe,e[45]=se^~ce&ue,e[6]=_^~A&b,e[7]=E^~S&g,e[16]=M^~P&k,e[17]=C^~N&x,e[26]=q^~K&B,e[27]=z^~H&U,e[36]=Y^~Z&G,e[37]=Q^~ee&V,e[46]=oe^~fe&te,e[47]=ce^~ue&re,e[8]=A^~b&m,e[9]=S^~g&y,e[18]=P^~k&T,e[19]=N^~x&R,e[28]=K^~B&L,e[29]=H^~U&j,e[38]=Z^~G&W,e[39]=ee^~V&X,e[48]=fe^~te&ne,e[49]=ue^~re&ie,e[0]^=f[n],e[1]^=f[n+1]};if(i)Ck.exports=_;else for(A=0;A<E.length;++A)r[E[A]]=_[E[A]]}();var Nk=Pk.exports;function Bk(e){return"0x"+Nk.keccak_256(ke(e))}let Uk=!1,Lk=!1;const jk={debug:1,default:2,info:2,warning:3,error:4,off:5};let Dk=jk.default,Fk=null;const qk=function(){try{const e=[];if(["NFD","NFC","NFKD","NFKC"].forEach((t=>{try{if("test"!=="test".normalize(t))throw new Error("bad normalize")}catch(r){e.push(t)}})),e.length)throw new Error("missing "+e.join(", "));if(String.fromCharCode(233).normalize("NFD")!==String.fromCharCode(101,769))throw new Error("broken implementation")}catch(e){return e.message}return null}();var zk,Kk;!function(e){e.DEBUG="DEBUG",e.INFO="INFO",e.WARNING="WARNING",e.ERROR="ERROR",e.OFF="OFF"}(zk||(zk={})),function(e){e.UNKNOWN_ERROR="UNKNOWN_ERROR",e.NOT_IMPLEMENTED="NOT_IMPLEMENTED",e.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",e.NETWORK_ERROR="NETWORK_ERROR",e.SERVER_ERROR="SERVER_ERROR",e.TIMEOUT="TIMEOUT",e.BUFFER_OVERRUN="BUFFER_OVERRUN",e.NUMERIC_FAULT="NUMERIC_FAULT",e.MISSING_NEW="MISSING_NEW",e.INVALID_ARGUMENT="INVALID_ARGUMENT",e.MISSING_ARGUMENT="MISSING_ARGUMENT",e.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",e.CALL_EXCEPTION="CALL_EXCEPTION",e.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",e.NONCE_EXPIRED="NONCE_EXPIRED",e.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",e.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",e.TRANSACTION_REPLACED="TRANSACTION_REPLACED",e.ACTION_REJECTED="ACTION_REJECTED"}(Kk||(Kk={}));const Hk="0123456789abcdef";let Gk=class e{constructor(e){Object.defineProperty(this,"version",{enumerable:!0,value:e,writable:!1})}_log(e,t){const r=e.toLowerCase();null==jk[r]&&this.throwArgumentError("invalid log level name","logLevel",e),Dk>jk[r]||console.log.apply(console,t)}debug(...t){this._log(e.levels.DEBUG,t)}info(...t){this._log(e.levels.INFO,t)}warn(...t){this._log(e.levels.WARNING,t)}makeError(t,r,n){if(Lk)return this.makeError("censored error",r,{});r||(r=e.errors.UNKNOWN_ERROR),n||(n={});const i=[];Object.keys(n).forEach((e=>{const t=n[e];try{if(t instanceof Uint8Array){let r="";for(let e=0;e<t.length;e++)r+=Hk[t[e]>>4],r+=Hk[15&t[e]];i.push(e+"=Uint8Array(0x"+r+")")}else i.push(e+"="+JSON.stringify(t))}catch(t){i.push(e+"="+JSON.stringify(n[e].toString()))}})),i.push(`code=${r}`),i.push(`version=${this.version}`);const a=t;let s="";switch(r){case Kk.NUMERIC_FAULT:{s="NUMERIC_FAULT";const e=t;switch(e){case"overflow":case"underflow":case"division-by-zero":s+="-"+e;break;case"negative-power":case"negative-width":s+="-unsupported";break;case"unbound-bitwise-result":s+="-unbound-result"}break}case Kk.CALL_EXCEPTION:case Kk.INSUFFICIENT_FUNDS:case Kk.MISSING_NEW:case Kk.NONCE_EXPIRED:case Kk.REPLACEMENT_UNDERPRICED:case Kk.TRANSACTION_REPLACED:case Kk.UNPREDICTABLE_GAS_LIMIT:s=r}s&&(t+=" [ See: https://links.ethers.org/v5-errors-"+s+" ]"),i.length&&(t+=" ("+i.join(", ")+")");const o=new Error(t);return o.reason=a,o.code=r,Object.keys(n).forEach((function(e){o[e]=n[e]})),o}throwError(e,t,r){throw this.makeError(e,t,r)}throwArgumentError(t,r,n){return this.throwError(t,e.errors.INVALID_ARGUMENT,{argument:r,value:n})}assert(e,t,r,n){e||this.throwError(t,r,n)}assertArgument(e,t,r,n){e||this.throwArgumentError(t,r,n)}checkNormalize(t){qk&&this.throwError("platform missing String.prototype.normalize",e.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:qk})}checkSafeUint53(t,r){"number"==typeof t&&(null==r&&(r="value not safe"),(t<0||t>=9007199254740991)&&this.throwError(r,e.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:t}),t%1&&this.throwError(r,e.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:t}))}checkArgumentCount(t,r,n){n=n?": "+n:"",t<r&&this.throwError("missing argument"+n,e.errors.MISSING_ARGUMENT,{count:t,expectedCount:r}),t>r&&this.throwError("too many arguments"+n,e.errors.UNEXPECTED_ARGUMENT,{count:t,expectedCount:r})}checkNew(t,r){t!==Object&&null!=t||this.throwError("missing new",e.errors.MISSING_NEW,{name:r.name})}checkAbstract(t,r){t===r?this.throwError("cannot instantiate abstract class "+JSON.stringify(r.name)+" directly; use a sub-class",e.errors.UNSUPPORTED_OPERATION,{name:t.name,operation:"new"}):t!==Object&&null!=t||this.throwError("missing new",e.errors.MISSING_NEW,{name:r.name})}static globalLogger(){return Fk||(Fk=new e("logger/5.7.0")),Fk}static setCensorship(t,r){if(!t&&r&&this.globalLogger().throwError("cannot permanently disable censorship",e.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),Uk){if(!t)return;this.globalLogger().throwError("error censorship permanent",e.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}Lk=!!t,Uk=!!r}static setLogLevel(t){const r=jk[t.toLowerCase()];null!=r?Dk=r:e.globalLogger().warn("invalid log level - "+t)}static from(t){return new e(t)}};Gk.errors=Kk,Gk.levels=zk;var Vk=ce.BN;const Wk=new Gk("bignumber/5.7.0"),Xk={};let $k=!1,Jk=class e{constructor(e,t){e!==Xk&&Wk.throwError("cannot call constructor directly; use BigNumber.from",Gk.errors.UNSUPPORTED_OPERATION,{operation:"new (BigNumber)"}),this._hex=t,this._isBigNumber=!0,Object.freeze(this)}fromTwos(e){return Qk(Zk(this).fromTwos(e))}toTwos(e){return Qk(Zk(this).toTwos(e))}abs(){return"-"===this._hex[0]?e.from(this._hex.substring(1)):this}add(e){return Qk(Zk(this).add(Zk(e)))}sub(e){return Qk(Zk(this).sub(Zk(e)))}div(t){return e.from(t).isZero()&&ex("division-by-zero","div"),Qk(Zk(this).div(Zk(t)))}mul(e){return Qk(Zk(this).mul(Zk(e)))}mod(e){const t=Zk(e);return t.isNeg()&&ex("division-by-zero","mod"),Qk(Zk(this).umod(t))}pow(e){const t=Zk(e);return t.isNeg()&&ex("negative-power","pow"),Qk(Zk(this).pow(t))}and(e){const t=Zk(e);return(this.isNegative()||t.isNeg())&&ex("unbound-bitwise-result","and"),Qk(Zk(this).and(t))}or(e){const t=Zk(e);return(this.isNegative()||t.isNeg())&&ex("unbound-bitwise-result","or"),Qk(Zk(this).or(t))}xor(e){const t=Zk(e);return(this.isNegative()||t.isNeg())&&ex("unbound-bitwise-result","xor"),Qk(Zk(this).xor(t))}mask(e){return(this.isNegative()||e<0)&&ex("negative-width","mask"),Qk(Zk(this).maskn(e))}shl(e){return(this.isNegative()||e<0)&&ex("negative-width","shl"),Qk(Zk(this).shln(e))}shr(e){return(this.isNegative()||e<0)&&ex("negative-width","shr"),Qk(Zk(this).shrn(e))}eq(e){return Zk(this).eq(Zk(e))}lt(e){return Zk(this).lt(Zk(e))}lte(e){return Zk(this).lte(Zk(e))}gt(e){return Zk(this).gt(Zk(e))}gte(e){return Zk(this).gte(Zk(e))}isNegative(){return"-"===this._hex[0]}isZero(){return Zk(this).isZero()}toNumber(){try{return Zk(this).toNumber()}catch(e){ex("overflow","toNumber",this.toString())}return null}toBigInt(){try{return BigInt(this.toString())}catch(e){}return Wk.throwError("this platform does not support BigInt",Gk.errors.UNSUPPORTED_OPERATION,{value:this.toString()})}toString(){return arguments.length>0&&(10===arguments[0]?$k||($k=!0,Wk.warn("BigNumber.toString does not accept any parameters; base-10 is assumed")):16===arguments[0]?Wk.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()",Gk.errors.UNEXPECTED_ARGUMENT,{}):Wk.throwError("BigNumber.toString does not accept parameters",Gk.errors.UNEXPECTED_ARGUMENT,{})),Zk(this).toString(10)}toHexString(){return this._hex}toJSON(e){return{type:"BigNumber",hex:this.toHexString()}}static from(t){if(t instanceof e)return t;if("string"==typeof t)return t.match(/^-?0x[0-9a-f]+$/i)?new e(Xk,Yk(t)):t.match(/^-?[0-9]+$/)?new e(Xk,Yk(new Vk(t))):Wk.throwArgumentError("invalid BigNumber string","value",t);if("number"==typeof t)return t%1&&ex("underflow","BigNumber.from",t),(t>=9007199254740991||t<=-9007199254740991)&&ex("overflow","BigNumber.from",t),e.from(String(t));const r=t;if("bigint"==typeof r)return e.from(r.toString());if(Se(r))return e.from(Me(r));if(r)if(r.toHexString){const t=r.toHexString();if("string"==typeof t)return e.from(t)}else{let t=r._hex;if(null==t&&"BigNumber"===r.type&&(t=r.hex),"string"==typeof t&&(Oe(t)||"-"===t[0]&&Oe(t.substring(1))))return e.from(t)}return Wk.throwArgumentError("invalid BigNumber value","value",t)}static isBigNumber(e){return!(!e||!e._isBigNumber)}};function Yk(e){if("string"!=typeof e)return Yk(e.toString(16));if("-"===e[0])return"-"===(e=e.substring(1))[0]&&Wk.throwArgumentError("invalid hex","value",e),"0x00"===(e=Yk(e))?e:"-"+e;if("0x"!==e.substring(0,2)&&(e="0x"+e),"0x"===e)return"0x00";for(e.length%2&&(e="0x0"+e.substring(2));e.length>4&&"0x00"===e.substring(0,4);)e="0x"+e.substring(4);return e}function Qk(e){return Jk.from(Yk(e))}function Zk(e){const t=Jk.from(e).toHexString();return"-"===t[0]?new Vk("-"+t.substring(3),16):new Vk(t.substring(2),16)}function ex(e,t,r){const n={fault:e,operation:t};return null!=r&&(n.value=r),Wk.throwError(e,Gk.errors.NUMERIC_FAULT,n)}const tx=new Gk("bignumber/5.7.0"),rx={},nx=Jk.from(0),ix=Jk.from(-1);function ax(e,t,r,n){const i={fault:t,operation:r};return void 0!==n&&(i.value=n),tx.throwError(e,Gk.errors.NUMERIC_FAULT,i)}let sx="0";for(;sx.length<256;)sx+=sx;function ox(e){if("number"!=typeof e)try{e=Jk.from(e).toNumber()}catch(e){}return"number"==typeof e&&e>=0&&e<=256&&!(e%1)?"1"+sx.substring(0,e):tx.throwArgumentError("invalid decimal size","decimals",e)}function cx(e,t){null==t&&(t=0);const r=ox(t),n=(e=Jk.from(e)).lt(nx);n&&(e=e.mul(ix));let i=e.mod(r).toString();for(;i.length<r.length-1;)i="0"+i;i=i.match(/^([0-9]*[1-9]|0)(0*)/)[1];const a=e.div(r).toString();return e=1===r.length?a:a+"."+i,n&&(e="-"+e),e}function fx(e,t){null==t&&(t=0);const r=ox(t);"string"==typeof e&&e.match(/^-?[0-9.]+$/)||tx.throwArgumentError("invalid decimal value","value",e);const n="-"===e.substring(0,1);n&&(e=e.substring(1)),"."===e&&tx.throwArgumentError("missing value","value",e);const i=e.split(".");i.length>2&&tx.throwArgumentError("too many decimal points","value",e);let a=i[0],s=i[1];for(a||(a="0"),s||(s="0");"0"===s[s.length-1];)s=s.substring(0,s.length-1);for(s.length>r.length-1&&ax("fractional component exceeds decimals","underflow","parseFixed"),""===s&&(s="0");s.length<r.length-1;)s+="0";const o=Jk.from(a),c=Jk.from(s);let f=o.mul(r).add(c);return n&&(f=f.mul(ix)),f}let ux=class e{constructor(e,t,r,n){e!==rx&&tx.throwError("cannot use FixedFormat constructor; use FixedFormat.from",Gk.errors.UNSUPPORTED_OPERATION,{operation:"new FixedFormat"}),this.signed=t,this.width=r,this.decimals=n,this.name=(t?"":"u")+"fixed"+String(r)+"x"+String(n),this._multiplier=ox(n),Object.freeze(this)}static from(t){if(t instanceof e)return t;"number"==typeof t&&(t=`fixed128x${t}`);let r=!0,n=128,i=18;if("string"==typeof t)if("fixed"===t);else if("ufixed"===t)r=!1;else{const e=t.match(/^(u?)fixed([0-9]+)x([0-9]+)$/);e||tx.throwArgumentError("invalid fixed format","format",t),r="u"!==e[1],n=parseInt(e[2]),i=parseInt(e[3])}else if(t){const e=(e,r,n)=>null==t[e]?n:(typeof t[e]!==r&&tx.throwArgumentError("invalid fixed format ("+e+" not "+r+")","format."+e,t[e]),t[e]);r=e("signed","boolean",r),n=e("width","number",n),i=e("decimals","number",i)}return n%8&&tx.throwArgumentError("invalid fixed format width (not byte aligned)","format.width",n),i>80&&tx.throwArgumentError("invalid fixed format (decimals too large)","format.decimals",i),new e(rx,r,n,i)}},dx=class e{constructor(e,t,r,n){e!==rx&&tx.throwError("cannot use FixedNumber constructor; use FixedNumber.from",Gk.errors.UNSUPPORTED_OPERATION,{operation:"new FixedFormat"}),this.format=n,this._hex=t,this._value=r,this._isFixedNumber=!0,Object.freeze(this)}_checkFormat(e){this.format.name!==e.format.name&&tx.throwArgumentError("incompatible format; use fixedNumber.toFormat","other",e)}addUnsafe(t){this._checkFormat(t);const r=fx(this._value,this.format.decimals),n=fx(t._value,t.format.decimals);return e.fromValue(r.add(n),this.format.decimals,this.format)}subUnsafe(t){this._checkFormat(t);const r=fx(this._value,this.format.decimals),n=fx(t._value,t.format.decimals);return e.fromValue(r.sub(n),this.format.decimals,this.format)}mulUnsafe(t){this._checkFormat(t);const r=fx(this._value,this.format.decimals),n=fx(t._value,t.format.decimals);return e.fromValue(r.mul(n).div(this.format._multiplier),this.format.decimals,this.format)}divUnsafe(t){this._checkFormat(t);const r=fx(this._value,this.format.decimals),n=fx(t._value,t.format.decimals);return e.fromValue(r.mul(this.format._multiplier).div(n),this.format.decimals,this.format)}floor(){const t=this.toString().split(".");1===t.length&&t.push("0");let r=e.from(t[0],this.format);const n=!t[1].match(/^(0*)$/);return this.isNegative()&&n&&(r=r.subUnsafe(lx.toFormat(r.format))),r}ceiling(){const t=this.toString().split(".");1===t.length&&t.push("0");let r=e.from(t[0],this.format);const n=!t[1].match(/^(0*)$/);return!this.isNegative()&&n&&(r=r.addUnsafe(lx.toFormat(r.format))),r}round(t){null==t&&(t=0);const r=this.toString().split(".");if(1===r.length&&r.push("0"),(t<0||t>80||t%1)&&tx.throwArgumentError("invalid decimal count","decimals",t),r[1].length<=t)return this;const n=e.from("1"+sx.substring(0,t),this.format),i=hx.toFormat(this.format);return this.mulUnsafe(n).addUnsafe(i).floor().divUnsafe(n)}isZero(){return"0.0"===this._value||"0"===this._value}isNegative(){return"-"===this._value[0]}toString(){return this._value}toHexString(e){if(null==e)return this._hex;e%8&&tx.throwArgumentError("invalid byte width","width",e);return Ue(Jk.from(this._hex).fromTwos(this.format.width).toTwos(e).toHexString(),e/8)}toUnsafeFloat(){return parseFloat(this.toString())}toFormat(t){return e.fromString(this._value,t)}static fromValue(t,r,n){return null!=n||null==r||function(e){return null!=e&&(Jk.isBigNumber(e)||"number"==typeof e&&e%1==0||"string"==typeof e&&!!e.match(/^-?[0-9]+$/)||Oe(e)||"bigint"==typeof e||Se(e))}(r)||(n=r,r=null),null==r&&(r=0),null==n&&(n="fixed"),e.fromString(cx(t,r),ux.from(n))}static fromString(t,r){null==r&&(r="fixed");const n=ux.from(r),i=fx(t,n.decimals);!n.signed&&i.lt(nx)&&ax("unsigned value cannot be negative","overflow","value",t);let a=null;n.signed?a=i.toTwos(n.width).toHexString():(a=i.toHexString(),a=Ue(a,n.width/8));const s=cx(i,n.decimals);return new e(rx,a,s,n)}static fromBytes(t,r){null==r&&(r="fixed");const n=ux.from(r);if(ke(t).length>n.width/8)throw new Error("overflow");let i=Jk.from(t);n.signed&&(i=i.fromTwos(n.width));const a=i.toTwos((n.signed?0:1)+n.width).toHexString(),s=cx(i,n.decimals);return new e(rx,a,s,n)}static from(t,r){if("string"==typeof t)return e.fromString(t,r);if(Se(t))return e.fromBytes(t,r);try{return e.fromValue(t,0,r)}catch(t){if(t.code!==Gk.errors.INVALID_ARGUMENT)throw t}return tx.throwArgumentError("invalid FixedNumber value","value",t)}static isFixedNumber(e){return!(!e||!e._isFixedNumber)}};const lx=dx.from(1),hx=dx.from("0.5"),px=new Gk("strings/5.7.0");var bx,gx;function mx(e,t=bx.current){t!=bx.current&&(px.checkNormalize(),e=e.normalize(t));let r=[];for(let t=0;t<e.length;t++){const n=e.charCodeAt(t);if(n<128)r.push(n);else if(n<2048)r.push(n>>6|192),r.push(63&n|128);else if(55296==(64512&n)){t++;const i=e.charCodeAt(t);if(t>=e.length||56320!=(64512&i))throw new Error("invalid utf-8 string");const a=65536+((1023&n)<<10)+(1023&i);r.push(a>>18|240),r.push(a>>12&63|128),r.push(a>>6&63|128),r.push(63&a|128)}else r.push(n>>12|224),r.push(n>>6&63|128),r.push(63&n|128)}return ke(r)}function yx(e,t){t||(t=function(e){return[parseInt(e,16)]});let r=0,n={};return e.split(",").forEach((e=>{let i=e.split(":");r+=parseInt(i[0],16),n[r]=t(i[1])})),n}function vx(e){let t=0;return e.split(",").map((e=>{let r=e.split("-");1===r.length?r[1]="0":""===r[1]&&(r[1]="1");let n=t+parseInt(r[0],16);return t=parseInt(r[1],16),{l:n,h:t}}))}function wx(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function _x(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?wx(Object(r),!0).forEach((function(t){rA(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):wx(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function Ex(e,t,r){return Ax.apply(this,arguments)}function Ax(){return(Ax=EA(TA.mark((function e(t,r,n){var i,a,s,o,c,f,u,d;return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=r.users.map((function(e){return{ether_key:e.user,tokens:e.tokens.map((function(e){return _x({id:e.id,blueprint:e.blueprint},e.royalties&&e.royalties.length>0&&{royalties:e.royalties.map((function(e){return{recipient:e.recipient,percentage:e.percentage}}))})}))}})),a=r.royalties,s=_x(_x({contract_address:r.contract_address},a&&a.length>0&&{royalties:a.map((function(e){return{recipient:e.recipient,percentage:e.percentage}}))}),{},{users:i,auth_signature:""}),o=Bk(mx(JSON.stringify(s))),e.next=6,MA(o,t);case 6:return c=e.sent,f=_x(_x({users:s.users.map((function(e){return{user:e.ether_key,tokens:e.tokens}}))},a&&a.length>0&&{royalties:a}),{},{contract_address:r.contract_address,auth_signature:c}),u={mintTokensRequestV2:[f]},e.next=11,n.mintTokens(u);case 11:return d=e.sent,e.abrupt("return",d.data);case 13:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Sx(e){switch(e.type){case"ERC721":return{type:"ERC721",data:{token_id:e.tokenId,token_address:e.tokenAddress}};case"ERC20":return{type:"ERC20",data:{token_address:e.tokenAddress}};case"ETH":return{type:"ETH",data:{decimals:18}}}}function kx(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return xx(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?xx(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,o=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return s=e.done,e},e:function(e){o=!0,a=e},f:function(){try{s||null==r.return||r.return()}finally{if(o)throw a}}}}function xx(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function Tx(e){return Rx.apply(this,arguments)}function Rx(){return(Rx=EA(TA.mark((function e(t){var r,n,i,a,s,o,c,f,u,d,l,h,p,b,g;return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.ethSigner,i=t.starkSigner,a=t.request,s=t.transfersApi,e.next=3,n.getAddress();case 3:return o=e.sent,c="ERC721"===a.type?"1":a.amount,e.next=7,s.getSignableTransferV1({getSignableTransferRequest:{sender:o,token:Sx(a),amount:c,receiver:a.receiver}});case 7:return f=e.sent,u=f.data,d=u.signable_message,l=u.payload_hash,e.next=11,MA(d,n);case 11:return h=e.sent,e.next=14,i.signMessage(l);case 14:return p=e.sent,b={sender_stark_key:f.data.sender_stark_key,sender_vault_id:f.data.sender_vault_id,receiver_stark_key:f.data.receiver_stark_key,receiver_vault_id:f.data.receiver_vault_id,asset_id:f.data.asset_id,amount:f.data.amount,nonce:f.data.nonce,expiration_timestamp:f.data.expiration_timestamp,stark_signature:p},e.next=18,s.createTransferV1({createTransferRequest:b,xImxEthAddress:o,xImxEthSignature:h});case 18:return g=e.sent,e.abrupt("return",{sent_signature:null==g?void 0:g.data.sent_signature,status:null==g||null===(r=g.data.status)||void 0===r?void 0:r.toString(),time:null==g?void 0:g.data.time,transfer_id:null==g?void 0:g.data.transfer_id});case 20:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Ox(e){return Ix.apply(this,arguments)}function Ix(){return(Ix=EA(TA.mark((function e(t){var r,n,i,a,s,o,c,f,u,d,l,h,p,b,g,m,y;return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.ethSigner,n=t.starkSigner,i=t.request,a=t.transfersApi,e.next=3,r.getAddress();case 3:return s=e.sent,o=i.map((function(e){return{amount:"1",token:Sx({type:"ERC721",tokenId:e.tokenId,tokenAddress:e.tokenAddress}),receiver:e.receiver}})),e.next=7,a.getSignableTransfer({getSignableTransferRequestV2:{sender_ether_key:s,signable_requests:o}});case 7:if(c=e.sent,void 0!==(f=c.data.signable_message)){e.next=11;break}throw new Error("Invalid response from Signable registration offchain");case 11:return e.next=13,MA(f,r);case 13:u=e.sent,d=[],l=kx(c.data.signable_responses),e.prev=16,l.s();case 18:if((h=l.n()).done){e.next=27;break}return p=h.value,e.next=22,n.signMessage(p.payload_hash);case 22:b=e.sent,g={sender_vault_id:p.sender_vault_id,receiver_stark_key:p.receiver_stark_key,receiver_vault_id:p.receiver_vault_id,asset_id:p.asset_id,amount:p.amount,nonce:p.nonce,expiration_timestamp:p.expiration_timestamp,stark_signature:b},d.push(g);case 25:e.next=18;break;case 27:e.next=32;break;case 29:e.prev=29,e.t0=e.catch(16),l.e(e.t0);case 32:return e.prev=32,l.f(),e.finish(32);case 35:return m={sender_stark_key:c.data.sender_stark_key,requests:d},e.next=38,a.createTransfer({createTransferRequestV2:m,xImxEthAddress:s,xImxEthSignature:u});case 38:return y=e.sent,e.abrupt("return",{transfer_ids:null==y?void 0:y.data.transfer_ids});case 40:case"end":return e.stop()}}),e,null,[[16,29,32,35]])})))).apply(this,arguments)}!function(e){e.current="",e.NFC="NFC",e.NFD="NFD",e.NFKC="NFKC",e.NFKD="NFKD"}(bx||(bx={})),function(e){e.UNEXPECTED_CONTINUE="unexpected continuation byte",e.BAD_PREFIX="bad codepoint prefix",e.OVERRUN="string overrun",e.MISSING_CONTINUE="missing continuation byte",e.OUT_OF_RANGE="out of UTF-8 range",e.UTF16_SURROGATE="UTF-16 surrogate",e.OVERLONG="overlong representation"}(gx||(gx={})),vx("221,13-1b,5f-,40-10,51-f,11-3,3-3,2-2,2-4,8,2,15,2d,28-8,88,48,27-,3-5,11-20,27-,8,28,3-5,12,18,b-a,1c-4,6-16,2-d,2-2,2,1b-4,17-9,8f-,10,f,1f-2,1c-34,33-14e,4,36-,13-,6-2,1a-f,4,9-,3-,17,8,2-2,5-,2,8-,3-,4-8,2-3,3,6-,16-6,2-,7-3,3-,17,8,3,3,3-,2,6-3,3-,4-a,5,2-6,10-b,4,8,2,4,17,8,3,6-,b,4,4-,2-e,2-4,b-10,4,9-,3-,17,8,3-,5-,9-2,3-,4-7,3-3,3,4-3,c-10,3,7-2,4,5-2,3,2,3-2,3-2,4-2,9,4-3,6-2,4,5-8,2-e,d-d,4,9,4,18,b,6-3,8,4,5-6,3-8,3-3,b-11,3,9,4,18,b,6-3,8,4,5-6,3-6,2,3-3,b-11,3,9,4,18,11-3,7-,4,5-8,2-7,3-3,b-11,3,13-2,19,a,2-,8-2,2-3,7,2,9-11,4-b,3b-3,1e-24,3,2-,3,2-,2-5,5,8,4,2,2-,3,e,4-,6,2,7-,b-,3-21,49,23-5,1c-3,9,25,10-,2-2f,23,6,3,8-2,5-5,1b-45,27-9,2a-,2-3,5b-4,45-4,53-5,8,40,2,5-,8,2,5-,28,2,5-,20,2,5-,8,2,5-,8,8,18,20,2,5-,8,28,14-5,1d-22,56-b,277-8,1e-2,52-e,e,8-a,18-8,15-b,e,4,3-b,5e-2,b-15,10,b-5,59-7,2b-555,9d-3,5b-5,17-,7-,27-,7-,9,2,2,2,20-,36,10,f-,7,14-,4,a,54-3,2-6,6-5,9-,1c-10,13-1d,1c-14,3c-,10-6,32-b,240-30,28-18,c-14,a0,115-,3,66-,b-76,5,5-,1d,24,2,5-2,2,8-,35-2,19,f-10,1d-3,311-37f,1b,5a-b,d7-19,d-3,41,57-,68-4,29-3,5f,29-37,2e-2,25-c,2c-2,4e-3,30,78-3,64-,20,19b7-49,51a7-59,48e-2,38-738,2ba5-5b,222f-,3c-94,8-b,6-4,1b,6,2,3,3,6d-20,16e-f,41-,37-7,2e-2,11-f,5-b,18-,b,14,5-3,6,88-,2,bf-2,7-,7-,7-,4-2,8,8-9,8-2ff,20,5-b,1c-b4,27-,27-cbb1,f7-9,28-2,b5-221,56,48,3-,2-,3-,5,d,2,5,3,42,5-,9,8,1d,5,6,2-2,8,153-3,123-3,33-27fd,a6da-5128,21f-5df,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3,2-1d,61-ff7d"),"ad,34f,1806,180b,180c,180d,200b,200c,200d,2060,feff".split(",").map((e=>parseInt(e,16))),yx("b5:3bc,c3:ff,7:73,2:253,5:254,3:256,1:257,5:259,1:25b,3:260,1:263,2:269,1:268,5:26f,1:272,2:275,7:280,3:283,5:288,3:28a,1:28b,5:292,3f:195,1:1bf,29:19e,125:3b9,8b:3b2,1:3b8,1:3c5,3:3c6,1:3c0,1a:3ba,1:3c1,1:3c3,2:3b8,1:3b5,1bc9:3b9,1c:1f76,1:1f77,f:1f7a,1:1f7b,d:1f78,1:1f79,1:1f7c,1:1f7d,107:63,5:25b,4:68,1:68,1:68,3:69,1:69,1:6c,3:6e,4:70,1:71,1:72,1:72,1:72,7:7a,2:3c9,2:7a,2:6b,1:e5,1:62,1:63,3:65,1:66,2:6d,b:3b3,1:3c0,6:64,1b574:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3"),yx("179:1,2:1,2:1,5:1,2:1,a:4f,a:1,8:1,2:1,2:1,3:1,5:1,3:1,4:1,2:1,3:1,4:1,8:2,1:1,2:2,1:1,2:2,27:2,195:26,2:25,1:25,1:25,2:40,2:3f,1:3f,33:1,11:-6,1:-9,1ac7:-3a,6d:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,b:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,c:-8,2:-8,2:-8,2:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,49:-8,1:-8,1:-4a,1:-4a,d:-56,1:-56,1:-56,1:-56,d:-8,1:-8,f:-8,1:-8,3:-7"),yx("df:00730073,51:00690307,19:02BC006E,a7:006A030C,18a:002003B9,16:03B903080301,20:03C503080301,1d7:05650582,190f:00680331,1:00740308,1:0077030A,1:0079030A,1:006102BE,b6:03C50313,2:03C503130300,2:03C503130301,2:03C503130342,2a:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,3:1F7003B9,1:03B103B9,1:03AC03B9,2:03B10342,1:03B1034203B9,5:03B103B9,6:1F7403B9,1:03B703B9,1:03AE03B9,2:03B70342,1:03B7034203B9,5:03B703B9,6:03B903080300,1:03B903080301,3:03B90342,1:03B903080342,b:03C503080300,1:03C503080301,1:03C10313,2:03C50342,1:03C503080342,b:1F7C03B9,1:03C903B9,1:03CE03B9,2:03C90342,1:03C9034203B9,5:03C903B9,ac:00720073,5b:00B00063,6:00B00066,d:006E006F,a:0073006D,1:00740065006C,1:0074006D,124f:006800700061,2:00610075,2:006F0076,b:00700061,1:006E0061,1:03BC0061,1:006D0061,1:006B0061,1:006B0062,1:006D0062,1:00670062,3:00700066,1:006E0066,1:03BC0066,4:0068007A,1:006B0068007A,1:006D0068007A,1:00670068007A,1:00740068007A,15:00700061,1:006B00700061,1:006D00700061,1:006700700061,8:00700076,1:006E0076,1:03BC0076,1:006D0076,1:006B0076,1:006D0076,1:00700077,1:006E0077,1:03BC0077,1:006D0077,1:006B0077,1:006D0077,1:006B03C9,1:006D03C9,2:00620071,3:00632215006B0067,1:0063006F002E,1:00640062,1:00670079,2:00680070,2:006B006B,1:006B006D,9:00700068,2:00700070006D,1:00700072,2:00730076,1:00770062,c723:00660066,1:00660069,1:0066006C,1:006600660069,1:00660066006C,1:00730074,1:00730074,d:05740576,1:05740565,1:0574056B,1:057E0576,1:0574056D",(function(e){if(e.length%4!=0)throw new Error("bad data");let t=[];for(let r=0;r<e.length;r+=4)t.push(parseInt(e.substring(r,r+4),16));return t})),vx("80-20,2a0-,39c,32,f71,18e,7f2-f,19-7,30-4,7-5,f81-b,5,a800-20ff,4d1-1f,110,fa-6,d174-7,2e84-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,2,1f-5f,ff7f-20001");const Mx=new Gk("units/5.7.0"),Cx=["wei","kwei","mwei","gwei","szabo","finney","ether"];function Px(e,t){if("string"!=typeof e&&Mx.throwArgumentError("value must be a string","value",e),"string"==typeof t){const e=Cx.indexOf(t);-1!==e&&(t=3*e)}return fx(e,null!=t?t:18)}function Nx(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function Bx(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Nx(Object(r),!0).forEach((function(t){rA(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Nx(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function Ux(e,t,r,n,i,a,s){return Lx.apply(this,arguments)}function Lx(){return(Lx=EA(TA.mark((function e(t,r,n,i,a,s,o){var c,f,u;return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.getAddress();case 2:return c=e.sent,e.next=5,Ik(c,i,o);case 5:return f=e.sent,e.next=8,s.populateTransaction.registerAndDepositEth(c,i,f.operator_signature,n,a);case 8:return u=e.sent,e.abrupt("return",t.sendTransaction(Bx(Bx({},u),{},{value:r})));case 10:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function jx(e,t,r,n,i,a){return Dx.apply(this,arguments)}function Dx(){return(Dx=EA(TA.mark((function e(t,r,n,i,a,s){var o;return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,s.populateTransaction["deposit(uint256,uint256,uint256)"](i,n,a);case 2:return o=e.sent,e.abrupt("return",t.sendTransaction(Bx(Bx({},o),{},{value:r})));case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Fx(e,t,r,n,i,a){return qx.apply(this,arguments)}function qx(){return(qx=EA(TA.mark((function e(t,r,n,i,a,s){var o,c,f,u,d,l,h,p,b,g,m;return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.getAddress();case 2:return o=e.sent,c={decimals:18},f=Px(r.amount,"wei"),u={user:o,token:{type:r.type,data:c},amount:f.toString()},e.next=8,n.getSignableDeposit({getSignableDepositRequest:u});case 8:return d=e.sent,e.next=11,a.encodeAsset({assetType:"asset",encodeAssetRequest:{token:{type:r.type}}});case 11:return l=e.sent,h=l.data.asset_type,p=d.data.stark_key,b=d.data.vault_id,g=fA.connect(s.ethConfiguration.coreContractAddress,t),m=vA.connect(s.ethConfiguration.registrationContractAddress,t),e.next=19,Rk(p,m);case 19:if(e.sent){e.next=24;break}return e.abrupt("return",Ux(t,f,h,p,b,g,i));case 24:return e.abrupt("return",jx(t,f,h,p,b,g));case 25:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function zx(e,t,r,n,i,a){return Kx.apply(this,arguments)}function Kx(){return(Kx=EA(TA.mark((function e(t,r,n,i,a,s){var o;return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,s.populateTransaction.depositERC20(i,n,a,r);case 2:return o=e.sent,e.abrupt("return",t.sendTransaction(o));case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Hx(e,t,r,n,i,a,s){return Gx.apply(this,arguments)}function Gx(){return(Gx=EA(TA.mark((function e(t,r,n,i,a,s,o){var c,f,u;return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.getAddress();case 2:return c=e.sent,e.next=5,Ik(c,i,o);case 5:return f=e.sent,e.next=8,s.populateTransaction.registerAndDepositERC20(c,i,f.operator_signature,n,a,r);case 8:return u=e.sent,e.abrupt("return",t.sendTransaction(u));case 10:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Vx(e,t,r,n,i,a,s){return Wx.apply(this,arguments)}function Wx(){return(Wx=EA(TA.mark((function e(t,r,n,i,a,s,o){var c,f,u,d,l,h,p,b,g,m,y,v,w,_,E,A;return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.getAddress();case 2:return c=e.sent,e.next=5,a.getToken({address:r.tokenAddress});case 5:return f=e.sent,u=parseInt(f.data.decimals),d={decimals:u,token_address:r.tokenAddress},l=Px(r.amount,0),h=iA.connect(r.tokenAddress,t),e.next=12,h.populateTransaction.approve(o.ethConfiguration.coreContractAddress,l);case 12:return p=e.sent,e.next=15,t.sendTransaction(p);case 15:return b={user:c,token:{type:r.type,data:d},amount:l.toString()},e.next=18,n.getSignableDeposit({getSignableDepositRequest:b});case 18:return g=e.sent,e.next=21,s.encodeAsset({assetType:"asset",encodeAssetRequest:{token:{type:r.type,data:{token_address:r.tokenAddress}}}});case 21:return m=e.sent,y=m.data.asset_type,v=g.data.stark_key,w=g.data.vault_id,_=Jk.from(g.data.amount),E=fA.connect(o.ethConfiguration.coreContractAddress,t),A=vA.connect(o.ethConfiguration.registrationContractAddress,t),e.next=30,Rk(v,A);case 30:if(e.sent){e.next=35;break}return e.abrupt("return",Hx(t,_,y,v,w,E,i));case 35:return e.abrupt("return",zx(t,_,y,v,w,E));case 36:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Xx(e,t,r,n,i,a){return $x.apply(this,arguments)}function $x(){return($x=EA(TA.mark((function e(t,r,n,i,a,s){var o;return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,s.populateTransaction.depositNft(i,n,a,r);case 2:return o=e.sent,e.abrupt("return",t.sendTransaction(o));case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Jx(e,t,r,n,i,a){return Yx.apply(this,arguments)}function Yx(){return(Yx=EA(TA.mark((function e(t,r,n,i,a,s){var o,c,f,u,d,l,h,p,b,g,m,y,v,w;return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.getAddress();case 2:return o=e.sent,c={token_address:r.tokenAddress,token_id:r.tokenId},f={user:o,token:{type:r.type,data:c},amount:"1".toString()},e.next=8,n.getSignableDeposit({getSignableDepositRequest:f});case 8:return u=e.sent,e.next=11,a.encodeAsset({assetType:"asset",encodeAssetRequest:{token:{type:r.type,data:{token_address:r.tokenAddress,token_id:r.tokenId}}}});case 11:return d=e.sent,l=d.data.asset_type,h=u.data.stark_key,p=u.data.vault_id,b=fA.connect(s.ethConfiguration.coreContractAddress,t),g=vA.connect(s.ethConfiguration.registrationContractAddress,t),e.next=19,Rk(h,g);case 19:return m=e.sent,y=sA.connect(r.tokenAddress,t),v=s.ethConfiguration.coreContractAddress,e.next=24,y.isApprovedForAll(o,v);case 24:if(e.sent){e.next=28;break}return e.next=28,y.setApprovalForAll(v,!0);case 28:if(m){e.next=34;break}return e.next=31,Ik(o,h,i);case 31:return w=e.sent,e.next=34,b.registerUser(o,h,w.operator_signature);case 34:return e.abrupt("return",Xx(t,r.tokenId,l,h,p,b));case 35:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var Qx=function(e){if(void 0!==e)return e;throw new Error("undefined field exception")};function Zx(e){return eT.apply(this,arguments)}function eT(){return(eT=EA(TA.mark((function e(t){var r,n,i,a,s,o,c,f,u,d,l,h,p;return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.ethSigner,n=t.starkSigner,i=t.withdrawalsApi,a="ERC721"===t.type?"1":t.amount,e.t0=i,e.next=5,r.getAddress();case 5:return e.t1=e.sent,e.t2=Sx(t),e.t3=a,e.t4={user:e.t1,token:e.t2,amount:e.t3},e.t5={getSignableWithdrawalRequest:e.t4},e.next=12,e.t0.getSignableWithdrawal.call(e.t0,e.t5);case 12:return s=e.sent,o=s.data,c=o.signable_message,f=o.payload_hash,e.next=16,n.signMessage(f);case 16:return u=e.sent,e.next=19,BA(c,r);case 19:return d=e.sent,l=d.ethAddress,h=d.ethSignature,e.next=24,i.createWithdrawal({createWithdrawalRequest:{stark_key:Qx(s.data.stark_key),amount:a,asset_id:Qx(s.data.asset_id),vault_id:Qx(s.data.vault_id),nonce:Qx(s.data.nonce),stark_signature:u},xImxEthAddress:l,xImxEthSignature:h});case 24:return p=e.sent,e.abrupt("return",p.data);case 26:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function tT(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function rT(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?tT(Object(r),!0).forEach((function(t){rA(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):tT(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function nT(e,t,r,n){return iT.apply(this,arguments)}function iT(){return(iT=EA(TA.mark((function e(t,r,n,i){var a;return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,n.encodeAsset({assetType:t,encodeAssetRequest:{token:rT({type:r},i&&{data:i})}});case 2:return a=e.sent,e.abrupt("return",a.data);case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function aT(e,t,r,n,i){return sT.apply(this,arguments)}function sT(){return(sT=EA(TA.mark((function e(t,r,n,i,a){var s,o,c;return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.getAddress();case 2:return s=e.sent,e.next=5,Ik(s,n,a);case 5:return o=e.sent,e.next=8,i.populateTransaction.registerAndWithdraw(s,n,o.operator_signature,r);case 8:return c=e.sent,e.abrupt("return",t.sendTransaction(c));case 10:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function oT(e,t,r,n){return cT.apply(this,arguments)}function cT(){return(cT=EA(TA.mark((function e(t,r,n,i){var a;return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,i.populateTransaction.withdraw(n,r);case 2:return a=e.sent,e.abrupt("return",t.sendTransaction(a));case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function fT(e,t,r,n,i,a){return uT.apply(this,arguments)}function uT(){return(uT=EA(TA.mark((function e(t,r,n,i,a,s){var o,c,f;return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,nT("asset","ERC20",i,{token_address:n.tokenAddress});case 2:return o=e.sent,c=fA.connect(s.ethConfiguration.coreContractAddress,t),f=vA.connect(s.ethConfiguration.registrationContractAddress,t),e.next=7,Rk(r,f);case 7:if(e.sent){e.next=12;break}return e.abrupt("return",aT(t,o.asset_type,r,f,a));case 12:return e.abrupt("return",oT(t,o.asset_type,r,c));case 13:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function dT(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function lT(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?dT(Object(r),!0).forEach((function(t){rA(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):dT(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function hT(e,t,r,n,i){return pT.apply(this,arguments)}function pT(){return(pT=EA(TA.mark((function e(t,r,n,i,a){var s;return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,a.populateTransaction.withdrawAndMint(n,r,i);case 2:return s=e.sent,e.abrupt("return",t.sendTransaction(s));case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function bT(e,t,r,n,i,a){return gT.apply(this,arguments)}function gT(){return(gT=EA(TA.mark((function e(t,r,n,i,a,s){var o,c,f;return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.getAddress();case 2:return o=e.sent,e.next=5,Ik(o,n,s);case 5:return c=e.sent,e.next=8,a.populateTransaction.regsiterAndWithdrawAndMint(o,n,c.operator_signature,r,i);case 8:return f=e.sent,e.abrupt("return",t.sendTransaction(f));case 10:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function mT(e){var t=e.data.id,r=e.data.blueprint||"";return Xf(kf("{".concat(t,"}:{").concat(r,"}")))}function yT(e,t,r,n,i,a){return vT.apply(this,arguments)}function vT(){return(vT=EA(TA.mark((function e(t,r,n,i,a,s){var o,c,f,u;return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,nT("mintable-asset","ERC721",i,lT({id:n.data.id,token_address:n.data.tokenAddress},n.data.blueprint&&{blueprint:n.data.blueprint}));case 2:return o=e.sent,c=mT(n),f=fA.connect(s.ethConfiguration.coreContractAddress,t),u=vA.connect(s.ethConfiguration.registrationContractAddress,t),e.next=8,Rk(r,u);case 8:if(e.sent){e.next=13;break}return e.abrupt("return",bT(t,o.asset_type,r,c,u,a));case 13:return e.abrupt("return",hT(t,o.asset_type,r,c,f));case 14:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function wT(e,t,r,n,i,a){return _T.apply(this,arguments)}function _T(){return(_T=EA(TA.mark((function e(t,r,n,i,a,s){var o,c,f;return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.getAddress();case 2:return o=e.sent,e.next=5,Ik(o,n,s);case 5:return c=e.sent,e.next=8,a.populateTransaction.registerAndWithdrawNft(o,n,c.operator_signature,r,i);case 8:return f=e.sent,e.abrupt("return",t.sendTransaction(f));case 10:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function ET(e,t,r,n,i){return AT.apply(this,arguments)}function AT(){return(AT=EA(TA.mark((function e(t,r,n,i,a){var s;return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,a.populateTransaction.withdrawNft(n,r,i);case 2:return s=e.sent,e.abrupt("return",t.sendTransaction(s));case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function ST(e,t,r,n,i,a){return kT.apply(this,arguments)}function kT(){return(kT=EA(TA.mark((function e(t,r,n,i,a,s){var o,c,f;return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,nT("asset","ERC721",i,{token_id:n.tokenId,token_address:n.tokenAddress});case 2:return o=e.sent,c=fA.connect(s.ethConfiguration.coreContractAddress,t),f=vA.connect(s.ethConfiguration.registrationContractAddress,t),e.next=7,Rk(r,f);case 7:if(e.sent){e.next=12;break}return e.abrupt("return",wT(t,o.asset_type,r,n.tokenId,f,a));case 12:return e.abrupt("return",ET(t,o.asset_type,r,n.tokenId,c));case 13:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function xT(e,t,r,n,i,a,s){return TT.apply(this,arguments)}function TT(){return(TT=EA(TA.mark((function e(t,r,n,i,a,s,o){var c,f;return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return c=n.tokenAddress,f=n.tokenId,e.next=4,a.getMintableTokenDetailsByClientTokenId({tokenAddress:c,tokenId:f}).then((function(e){return yT(t,r,{type:"ERC721",data:{id:f,tokenAddress:c,blueprint:e.data.blueprint}},i,s,o)})).catch((function(e){var a;if(404===(null===(a=e.response)||void 0===a?void 0:a.status))return ST(t,r,n,i,s,o);throw e}));case 4:return e.abrupt("return",e.sent);case 5:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function RT(e,t,r,n,i){return OT.apply(this,arguments)}function OT(){return(OT=EA(TA.mark((function e(t,r,n,i,a){var s,o,c;return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.getAddress();case 2:return s=e.sent,e.next=5,Ik(s,n,a);case 5:return o=e.sent,e.next=8,i.populateTransaction.registerAndWithdraw(s,n,o.operator_signature,r);case 8:return c=e.sent,e.abrupt("return",t.sendTransaction(c));case 10:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function IT(e,t,r,n){return MT.apply(this,arguments)}function MT(){return(MT=EA(TA.mark((function e(t,r,n,i){var a;return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,i.populateTransaction.withdraw(n,r);case 2:return a=e.sent,e.abrupt("return",t.sendTransaction(a));case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function CT(e,t,r,n,i){return PT.apply(this,arguments)}function PT(){return(PT=EA(TA.mark((function e(t,r,n,i,a){var s,o,c;return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,nT("asset","ETH",n);case 2:return s=e.sent,o=fA.connect(a.ethConfiguration.coreContractAddress,t),c=vA.connect(a.ethConfiguration.registrationContractAddress,t),e.next=7,Rk(r,c);case 7:if(e.sent){e.next=12;break}return e.abrupt("return",RT(t,s.asset_type,r,c,i));case 12:return e.abrupt("return",IT(t,s.asset_type,r,o));case 13:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function NT(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function BT(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?NT(Object(r),!0).forEach((function(t){rA(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):NT(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function UT(e){return LT.apply(this,arguments)}function LT(){return(LT=EA(TA.mark((function e(t){var r,n,i,a,s,o,c,f,u,d,l,h,p,b,g,m,y;return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.ethSigner,n=t.starkSigner,i=t.request,a=t.ordersApi,e.next=3,r.getAddress();case 3:return s=e.sent,o="ERC721"===i.sell.type?"1":i.sell.amount,c="ERC721"===i.buy.type?"1":i.buy.amount,f={user:s,amount_buy:c,token_buy:Sx(i.buy),amount_sell:o,token_sell:Sx(i.sell),fees:i.fees,expiration_timestamp:i.expiration_timestamp,split_fees:!0},e.next=9,a.getSignableOrder({getSignableOrderRequestV3:f});case 9:return u=e.sent,d=u.data,l=d.signable_message,h=d.payload_hash,e.next=13,MA(l,r);case 13:return p=e.sent,e.next=16,n.signMessage(h);case 16:return b=e.sent,g=u.data,m={createOrderRequest:{amount_buy:g.amount_buy,amount_sell:g.amount_sell,asset_id_buy:g.asset_id_buy,asset_id_sell:g.asset_id_sell,expiration_timestamp:g.expiration_timestamp,include_fees:!0,fees:i.fees,nonce:g.nonce,stark_key:g.stark_key,stark_signature:b,vault_id_buy:g.vault_id_buy,vault_id_sell:g.vault_id_sell},xImxEthAddress:s,xImxEthSignature:p},e.next=21,a.createOrderV3(m);case 21:return y=e.sent,e.abrupt("return",BT({},y.data));case 23:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function jT(e){return DT.apply(this,arguments)}function DT(){return(DT=EA(TA.mark((function e(t){var r,n,i,a,s,o,c,f,u,d,l,h;return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.ethSigner,n=t.starkSigner,i=t.request,a=t.ordersApi,e.next=3,a.getSignableCancelOrderV3({getSignableCancelOrderRequest:{order_id:i.order_id}});case 3:return s=e.sent,o=s.data,c=o.signable_message,f=o.payload_hash,e.next=7,MA(c,r);case 7:return u=e.sent,e.next=10,n.signMessage(f);case 10:return d=e.sent,e.next=13,r.getAddress();case 13:return l=e.sent,e.next=16,a.cancelOrderV3({id:i.order_id.toString(),cancelOrderRequest:{order_id:i.order_id,stark_signature:d},xImxEthAddress:l,xImxEthSignature:u});case 16:return h=e.sent,e.abrupt("return",{order_id:h.data.order_id,status:h.data.status});case 18:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function FT(e){return qT.apply(this,arguments)}function qT(){return(qT=EA(TA.mark((function e(t){var r,n,i,a,s,o,c,f,u,d,l,h;return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.ethSigner,n=t.starkSigner,i=t.request,a=t.tradesApi,e.next=3,r.getAddress();case 3:return s=e.sent,e.next=6,a.getSignableTrade({getSignableTradeRequest:{user:s,order_id:i.order_id,fees:i.fees}});case 6:return o=e.sent,c=o.data,f=c.signable_message,u=c.payload_hash,e.next=10,MA(f,r);case 10:return d=e.sent,e.next=13,n.signMessage(u);case 13:return l=e.sent,e.next=16,a.createTradeV3({createTradeRequest:{amount_buy:o.data.amount_buy,amount_sell:o.data.amount_sell,asset_id_buy:o.data.asset_id_buy,asset_id_sell:o.data.asset_id_sell,expiration_timestamp:o.data.expiration_timestamp,fee_info:o.data.fee_info,fees:i.fees,include_fees:!0,nonce:o.data.nonce,order_id:i.order_id,stark_key:o.data.stark_key,vault_id_buy:o.data.vault_id_buy,vault_id_sell:o.data.vault_id_sell,stark_signature:l},xImxEthAddress:s,xImxEthSignature:d});case 16:return h=e.sent,e.abrupt("return",h.data);case 18:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function zT(e){return KT.apply(this,arguments)}function KT(){return(KT=EA(TA.mark((function e(t){var r,n,i,a,s,o,c,f,u,d,l,h,p,b,g;return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.ethSigner,i=t.starkSigner,a=t.request,s=t.exchangesApi,e.next=3,n.getAddress();case 3:return o=e.sent,c=a.amount,e.next=7,s.getExchangeSignableTransfer({id:a.transactionID,getSignableTransferRequest:{sender:o,token:Sx(a),amount:c,receiver:a.receiver}});case 7:return f=e.sent,u=f.data,d=u.signable_message,l=u.payload_hash,e.next=11,MA(d,n);case 11:return h=e.sent,e.next=14,i.signMessage(l);case 14:return p=e.sent,b={sender_stark_key:f.data.sender_stark_key,sender_vault_id:f.data.sender_vault_id,receiver_stark_key:f.data.receiver_stark_key,receiver_vault_id:f.data.receiver_vault_id,asset_id:f.data.asset_id,amount:f.data.amount,nonce:f.data.nonce,expiration_timestamp:f.data.expiration_timestamp,stark_signature:p},e.next=18,s.createExchangeTransfer({id:a.transactionID,createTransferRequest:b,xImxEthAddress:o,xImxEthSignature:h});case 18:return g=e.sent,e.abrupt("return",{sent_signature:null==g?void 0:g.data.sent_signature,status:null==g||null===(r=g.data.status)||void 0===r?void 0:r.toString(),time:null==g?void 0:g.data.time,transfer_id:null==g?void 0:g.data.transfer_id});case 20:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function HT(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function GT(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?HT(Object(r),!0).forEach((function(t){rA(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):HT(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var VT=function(){function e(t){ZE(this,e),this.config=t;var r=t.apiConfiguration;this.config=t,this.depositsApi=new xS(r),this.encodingApi=new IS(r),this.mintsApi=new VS(r),this.ordersApi=new ek(r),this.tokensApi=new ck(r),this.tradesApi=new lk(r),this.transfersApi=new gk(r),this.usersApi=new wk(r),this.withdrawalsApi=new Sk(r),this.projectsApi=new ik(r),this.collectionsApi=new ES(r),this.metadataApi=new jS(r),this.metadataRefreshesApi=new zS(r),this.exchangesApi=new NS(r)}var t,r,n,i,a,s,o,c,f,u,d,l,h,p,b,g,m,y,v,w,_,E,A,S,k,x,T,R;return tA(e,[{key:"isChainValid",value:function(e){return e===this.config.ethConfiguration.chainID}},{key:"validateChain",value:(R=EA(TA.mark((function e(t){var r;return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.getChainId();case 2:if(r=e.sent,this.isChainValid(r)){e.next=5;break}throw new Error("The wallet used for this operation is not from the correct network.");case 5:case"end":return e.stop()}}),e,this)}))),function(e){return R.apply(this,arguments)})},{key:"registerOffchain",value:(T=EA(TA.mark((function e(t){return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.validateChain(t.ethSigner);case 2:return e.abrupt("return",xk(GT(GT({},t),{},{usersApi:this.usersApi})));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return T.apply(this,arguments)})},{key:"isRegisteredOnchain",value:(x=EA(TA.mark((function e(t){var r,n;return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.validateChain(t.ethSigner);case 2:return r=vA.connect(this.config.ethConfiguration.registrationContractAddress,t.ethSigner),e.next=5,t.starkSigner.getAddress();case 5:return n=e.sent,e.abrupt("return",Rk(n,r));case 7:case"end":return e.stop()}}),e,this)}))),function(e){return x.apply(this,arguments)})},{key:"mint",value:(k=EA(TA.mark((function e(t,r){return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.validateChain(t);case 2:return e.abrupt("return",Ex(t,r,this.mintsApi));case 3:case"end":return e.stop()}}),e,this)}))),function(e,t){return k.apply(this,arguments)})},{key:"transfer",value:(S=EA(TA.mark((function e(t,r){return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.validateChain(t.ethSigner);case 2:return e.abrupt("return",Tx(GT(GT({},t),{},{request:r,transfersApi:this.transfersApi})));case 3:case"end":return e.stop()}}),e,this)}))),function(e,t){return S.apply(this,arguments)})},{key:"exchangeTransfer",value:(A=EA(TA.mark((function e(t,r){return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.validateChain(t.ethSigner);case 2:return e.abrupt("return",zT(GT(GT({},t),{},{request:r,exchangesApi:this.exchangesApi})));case 3:case"end":return e.stop()}}),e,this)}))),function(e,t){return A.apply(this,arguments)})},{key:"batchNftTransfer",value:(E=EA(TA.mark((function e(t,r){return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.validateChain(t.ethSigner);case 2:return e.abrupt("return",Ox(GT(GT({},t),{},{request:r,transfersApi:this.transfersApi})));case 3:case"end":return e.stop()}}),e,this)}))),function(e,t){return E.apply(this,arguments)})},{key:"deposit",value:(_=EA(TA.mark((function e(t,r){return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:e.t0=r.type,e.next="ETH"===e.t0?3:"ERC20"===e.t0?4:"ERC721"===e.t0?5:6;break;case 3:return e.abrupt("return",this.depositEth(t,r));case 4:return e.abrupt("return",this.depositERC20(t,r));case 5:return e.abrupt("return",this.depositERC721(t,r));case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return _.apply(this,arguments)})},{key:"depositEth",value:(w=EA(TA.mark((function e(t,r){return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.validateChain(t);case 2:return e.abrupt("return",Fx(t,r,this.depositsApi,this.usersApi,this.encodingApi,this.config));case 3:case"end":return e.stop()}}),e,this)}))),function(e,t){return w.apply(this,arguments)})},{key:"depositERC20",value:(v=EA(TA.mark((function e(t,r){return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.validateChain(t);case 2:return e.abrupt("return",Vx(t,r,this.depositsApi,this.usersApi,this.tokensApi,this.encodingApi,this.config));case 3:case"end":return e.stop()}}),e,this)}))),function(e,t){return v.apply(this,arguments)})},{key:"depositERC721",value:(y=EA(TA.mark((function e(t,r){return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.validateChain(t);case 2:return e.abrupt("return",Jx(t,r,this.depositsApi,this.usersApi,this.encodingApi,this.config));case 3:case"end":return e.stop()}}),e,this)}))),function(e,t){return y.apply(this,arguments)})},{key:"prepareWithdrawal",value:(m=EA(TA.mark((function e(t,r){return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.validateChain(t.ethSigner);case 2:return e.abrupt("return",Zx(GT(GT(GT({},t),r),{},{withdrawalsApi:this.withdrawalsApi})));case 3:case"end":return e.stop()}}),e,this)}))),function(e,t){return m.apply(this,arguments)})},{key:"completeWithdrawal",value:function(e,t,r){switch(r.type){case"ETH":return this.completeEthWithdrawal(e,t);case"ERC20":return this.completeERC20Withdrawal(e,t,r);case"ERC721":return this.completeERC721Withdrawal(e,t,r)}}},{key:"completeEthWithdrawal",value:(g=EA(TA.mark((function e(t,r){return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.validateChain(t);case 2:return e.abrupt("return",CT(t,r,this.encodingApi,this.usersApi,this.config));case 3:case"end":return e.stop()}}),e,this)}))),function(e,t){return g.apply(this,arguments)})},{key:"completeERC20Withdrawal",value:(b=EA(TA.mark((function e(t,r,n){return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.validateChain(t);case 2:return e.abrupt("return",fT(t,r,n,this.encodingApi,this.usersApi,this.config));case 3:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return b.apply(this,arguments)})},{key:"completeERC721Withdrawal",value:function(){var e=EA(TA.mark((function e(t,r,n){return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.validateChain(t);case 2:return e.abrupt("return",xT(t,r,n,this.encodingApi,this.mintsApi,this.usersApi,this.config));case 3:case"end":return e.stop()}}),e,this)})));return function(t,r,n){return e.apply(this,arguments)}}()},{key:"createOrder",value:(p=EA(TA.mark((function e(t,r){return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.validateChain(t.ethSigner);case 2:return e.abrupt("return",UT(GT(GT({},t),{},{request:r,ordersApi:this.ordersApi})));case 3:case"end":return e.stop()}}),e,this)}))),function(e,t){return p.apply(this,arguments)})},{key:"cancelOrder",value:(h=EA(TA.mark((function e(t,r){return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.validateChain(t.ethSigner);case 2:return e.abrupt("return",jT(GT(GT({},t),{},{request:r,ordersApi:this.ordersApi})));case 3:case"end":return e.stop()}}),e,this)}))),function(e,t){return h.apply(this,arguments)})},{key:"createTrade",value:(l=EA(TA.mark((function e(t,r){return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.validateChain(t.ethSigner);case 2:return e.abrupt("return",FT(GT(GT({},t),{},{request:r,tradesApi:this.tradesApi})));case 3:case"end":return e.stop()}}),e,this)}))),function(e,t){return l.apply(this,arguments)})},{key:"createProject",value:(d=EA(TA.mark((function e(t,r){var n;return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,PA(t);case 2:return n=e.sent,e.abrupt("return",this.projectsApi.createProject({iMXSignature:n.signature,iMXTimestamp:n.timestamp,createProjectRequest:r}));case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return d.apply(this,arguments)})},{key:"getProject",value:(u=EA(TA.mark((function e(t,r){var n;return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,PA(t);case 2:return n=e.sent,e.abrupt("return",this.projectsApi.getProject({id:r,iMXSignature:n.signature,iMXTimestamp:n.timestamp}));case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return u.apply(this,arguments)})},{key:"getProjects",value:(f=EA(TA.mark((function e(t,r,n,i,a){var s;return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,PA(t);case 2:return s=e.sent,e.abrupt("return",this.projectsApi.getProjects({iMXSignature:s.signature,iMXTimestamp:s.timestamp,pageSize:r,cursor:n,orderBy:i,direction:a}));case 4:case"end":return e.stop()}}),e,this)}))),function(e,t,r,n,i){return f.apply(this,arguments)})},{key:"createCollection",value:(c=EA(TA.mark((function e(t,r){var n;return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,PA(t);case 2:return n=e.sent,e.abrupt("return",this.collectionsApi.createCollection({iMXSignature:n.signature,iMXTimestamp:n.timestamp,createCollectionRequest:r}));case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return c.apply(this,arguments)})},{key:"updateCollection",value:(o=EA(TA.mark((function e(t,r,n){var i;return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,PA(t);case 2:return i=e.sent,e.abrupt("return",this.collectionsApi.updateCollection({iMXSignature:i.signature,iMXTimestamp:i.timestamp,address:r,updateCollectionRequest:n}));case 4:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return o.apply(this,arguments)})},{key:"addMetadataSchemaToCollection",value:(s=EA(TA.mark((function e(t,r,n){var i;return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,PA(t);case 2:return i=e.sent,e.abrupt("return",this.metadataApi.addMetadataSchemaToCollection({iMXSignature:i.signature,iMXTimestamp:i.timestamp,addMetadataSchemaToCollectionRequest:n,address:r}));case 4:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return s.apply(this,arguments)})},{key:"updateMetadataSchemaByName",value:(a=EA(TA.mark((function e(t,r,n,i){var a;return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,PA(t);case 2:return a=e.sent,e.abrupt("return",this.metadataApi.updateMetadataSchemaByName({iMXSignature:a.signature,iMXTimestamp:a.timestamp,address:r,name:n,metadataSchemaRequest:i}));case 4:case"end":return e.stop()}}),e,this)}))),function(e,t,r,n){return a.apply(this,arguments)})},{key:"listMetadataRefreshes",value:(i=EA(TA.mark((function e(t,r,n,i){var a,s;return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,PA(t);case 2:return a=e.sent,e.next=5,t.getAddress();case 5:return s=e.sent,e.abrupt("return",this.metadataRefreshesApi.getAListOfMetadataRefreshes({xImxEthSignature:a.signature,xImxEthTimestamp:a.timestamp,xImxEthAddress:s,collectionAddress:r,pageSize:n,cursor:i}));case 7:case"end":return e.stop()}}),e,this)}))),function(e,t,r,n){return i.apply(this,arguments)})},{key:"getMetadataRefreshErrors",value:(n=EA(TA.mark((function e(t,r,n,i){var a,s;return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,PA(t);case 2:return a=e.sent,e.next=5,t.getAddress();case 5:return s=e.sent,e.abrupt("return",this.metadataRefreshesApi.getMetadataRefreshErrors({xImxEthSignature:a.signature,xImxEthTimestamp:a.timestamp,xImxEthAddress:s,refreshId:r,pageSize:n,cursor:i}));case 7:case"end":return e.stop()}}),e,this)}))),function(e,t,r,i){return n.apply(this,arguments)})},{key:"getMetadataRefreshResults",value:(r=EA(TA.mark((function e(t,r){var n,i;return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,PA(t);case 2:return n=e.sent,e.next=5,t.getAddress();case 5:return i=e.sent,e.abrupt("return",this.metadataRefreshesApi.getMetadataRefreshResults({xImxEthSignature:n.signature,xImxEthTimestamp:n.timestamp,xImxEthAddress:i,refreshId:r}));case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"createMetadataRefresh",value:(t=EA(TA.mark((function e(t,r){var n,i;return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,PA(t);case 2:return n=e.sent,e.next=5,t.getAddress();case 5:return i=e.sent,e.abrupt("return",this.metadataRefreshesApi.requestAMetadataRefresh({xImxEthSignature:n.signature,xImxEthTimestamp:n.timestamp,xImxEthAddress:i,createMetadataRefreshRequest:r}));case 7:case"end":return e.stop()}}),e,this)}))),function(e,r){return t.apply(this,arguments)})}]),e}();var WT=function(e){hA(r,QA(Error));var t=function(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=uA(e);if(t){var i=uA(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return gA(this,r)}}(r);function r(e){var n,i=e.code,a=e.details,s=e.message;return ZE(this,r),(n=t.call(this,s)).code=i,n.details=a,n}return tA(r)}();function XT(e){if(QE.isAxiosError(e)&&e.response){var t,r,n,i=e.response.data;return i.code&&i.message?new WT({code:i.code,details:i.details,message:i.message}):new WT({code:null!==(t=null!==(r=e.code)&&void 0!==r?r:null===(n=e.response)||void 0===n?void 0:n.status.toString())&&void 0!==t?t:"unknown_error_code",message:String(e)})}return new WT({code:"unknown_error_code",message:String(e)})}var $T=function(){function e(t){ZE(this,e),this.depositsApi=new xS(t.apiConfiguration),this.mintsApi=new VS(t.apiConfiguration),this.ordersApi=new ek(t.apiConfiguration),this.tokensApi=new ck(t.apiConfiguration),this.tradesApi=new lk(t.apiConfiguration),this.transfersApi=new gk(t.apiConfiguration),this.exchangeApi=new NS(t.apiConfiguration),this.usersApi=new wk(t.apiConfiguration),this.withdrawalsApi=new Sk(t.apiConfiguration),this.balanceApi=new yS(t.apiConfiguration),this.assetApi=new pS(t.apiConfiguration),this.collectionApi=new ES(t.apiConfiguration),this.metadataApi=new jS(t.apiConfiguration),this.metadataRefreshesApi=new zS(t.apiConfiguration),this.nftCheckoutPrimaryApi=new JS(t.apiConfiguration),this.projectsApi=new ik(t.apiConfiguration),this.workflows=new VT(t)}var t,r,n;return tA(e,[{key:"deposit",value:function(e,t){return this.workflows.deposit(e,t).catch((function(e){throw XT(e)}))}},{key:"getDeposit",value:function(e){return this.depositsApi.getDeposit(e).then((function(e){return e.data})).catch((function(e){throw XT(e)}))}},{key:"listDeposits",value:function(e){return this.depositsApi.listDeposits(e).then((function(e){return e.data})).catch((function(e){throw XT(e)}))}},{key:"registerOffchain",value:function(e){return this.workflows.registerOffchain(e).catch((function(e){throw XT(e)}))}},{key:"isRegisteredOnchain",value:function(e){return this.workflows.isRegisteredOnchain(e).catch((function(e){throw XT(e)}))}},{key:"getUser",value:function(e){return this.usersApi.getUsers({user:e}).then((function(e){return e.data})).catch((function(e){throw XT(e)}))}},{key:"getAsset",value:function(e){return this.assetApi.getAsset(e).then((function(e){return e.data})).catch((function(e){throw XT(e)}))}},{key:"listAssets",value:function(e){return this.assetApi.listAssets(e).then((function(e){return e.data})).catch((function(e){throw XT(e)}))}},{key:"createCollection",value:function(e,t){return this.workflows.createCollection(e,t).then((function(e){return e.data})).catch((function(e){throw XT(e)}))}},{key:"getCollection",value:function(e){return this.collectionApi.getCollection(e).then((function(e){return e.data})).catch((function(e){throw XT(e)}))}},{key:"listCollectionFilters",value:function(e){return this.collectionApi.listCollectionFilters(e).then((function(e){return e.data})).catch((function(e){throw XT(e)}))}},{key:"listCollections",value:function(e){return this.collectionApi.listCollections(e).then((function(e){return e.data})).catch((function(e){throw XT(e)}))}},{key:"updateCollection",value:function(e,t,r){return this.workflows.updateCollection(e,t,r).then((function(e){return e.data})).catch((function(e){throw XT(e)}))}},{key:"addMetadataSchemaToCollection",value:function(e,t,r){return this.workflows.addMetadataSchemaToCollection(e,t,r).then((function(e){return e.data})).catch((function(e){throw XT(e)}))}},{key:"getMetadataSchema",value:function(e){return this.metadataApi.getMetadataSchema(e).then((function(e){return e.data})).catch((function(e){throw XT(e)}))}},{key:"updateMetadataSchemaByName",value:function(e,t,r,n){return this.workflows.updateMetadataSchemaByName(e,t,r,n).then((function(e){return e.data})).catch((function(e){throw XT(e)}))}},{key:"listMetadataRefreshes",value:function(e,t,r,n){return this.workflows.listMetadataRefreshes(e,t,r,n).then((function(e){return e.data})).catch((function(e){throw XT(e)}))}},{key:"getMetadataRefreshErrors",value:function(e,t,r,n){return this.workflows.getMetadataRefreshErrors(e,t,r,n).then((function(e){return e.data})).catch((function(e){throw XT(e)}))}},{key:"getMetadataRefreshResults",value:function(e,t){return this.workflows.getMetadataRefreshResults(e,t).then((function(e){return e.data})).catch((function(e){throw XT(e)}))}},{key:"createMetadataRefresh",value:function(e,t){return this.workflows.createMetadataRefresh(e,t).then((function(e){return e.data})).catch((function(e){throw XT(e)}))}},{key:"createProject",value:(n=EA(TA.mark((function e(t,r){return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.workflows.createProject(t,r).then((function(e){return e.data})).catch((function(e){throw XT(e)})));case 1:case"end":return e.stop()}}),e,this)}))),function(e,t){return n.apply(this,arguments)})},{key:"getProject",value:(r=EA(TA.mark((function e(t,r){return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.workflows.getProject(t,r).then((function(e){return e.data})).catch((function(e){throw XT(e)})));case 1:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"getProjects",value:(t=EA(TA.mark((function e(t,r,n,i,a){return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.workflows.getProjects(t,r,n,i,a).then((function(e){return e.data})).catch((function(e){throw XT(e)})));case 1:case"end":return e.stop()}}),e,this)}))),function(e,r,n,i,a){return t.apply(this,arguments)})},{key:"getBalance",value:function(e){return this.balanceApi.getBalance(e).then((function(e){return e.data})).catch((function(e){throw XT(e)}))}},{key:"listBalances",value:function(e){return this.balanceApi.listBalances(e).then((function(e){return e.data})).catch((function(e){throw XT(e)}))}},{key:"getMint",value:function(e){return this.mintsApi.getMint(e).then((function(e){return e.data})).catch((function(e){throw XT(e)}))}},{key:"listMints",value:function(e){return this.mintsApi.listMints(e).then((function(e){return e.data})).catch((function(e){throw XT(e)}))}},{key:"mint",value:function(e,t){return this.workflows.mint(e,t).catch((function(e){throw XT(e)}))}},{key:"listWithdrawals",value:function(e){return this.withdrawalsApi.listWithdrawals(e).then((function(e){return e.data})).catch((function(e){throw XT(e)}))}},{key:"getWithdrawal",value:function(e){return this.withdrawalsApi.getWithdrawal(e).then((function(e){return e.data})).catch((function(e){throw XT(e)}))}},{key:"prepareWithdrawal",value:function(e,t){return this.workflows.prepareWithdrawal(e,t).catch((function(e){throw XT(e)}))}},{key:"completeWithdrawal",value:function(e,t,r){return this.workflows.completeWithdrawal(e,t,r).catch((function(e){throw XT(e)}))}},{key:"getOrder",value:function(e){return this.ordersApi.getOrderV3(e).then((function(e){return e.data})).catch((function(e){throw XT(e)}))}},{key:"listOrders",value:function(e){return this.ordersApi.listOrdersV3(e).then((function(e){return e.data})).catch((function(e){throw XT(e)}))}},{key:"createOrder",value:function(e,t){return this.workflows.createOrder(e,t).catch((function(e){throw XT(e)}))}},{key:"cancelOrder",value:function(e,t){return this.workflows.cancelOrder(e,t).catch((function(e){throw XT(e)}))}},{key:"getTrade",value:function(e){return this.tradesApi.getTrade(e).then((function(e){return e.data})).catch((function(e){throw XT(e)}))}},{key:"listTrades",value:function(e){return this.tradesApi.listTradesV3(e).then((function(e){return e.data})).catch((function(e){throw XT(e)}))}},{key:"createTrade",value:function(e,t){return this.workflows.createTrade(e,t).catch((function(e){throw XT(e)}))}},{key:"getToken",value:function(e){return this.tokensApi.getToken(e).then((function(e){return e.data})).catch((function(e){throw XT(e)}))}},{key:"listTokens",value:function(e){return this.tokensApi.listTokens(e).then((function(e){return e.data})).catch((function(e){throw XT(e)}))}},{key:"getTransfer",value:function(e){return this.transfersApi.getTransfer(e).then((function(e){return e.data})).catch((function(e){throw XT(e)}))}},{key:"listTransfers",value:function(e){return this.transfersApi.listTransfers(e).then((function(e){return e.data})).catch((function(e){throw XT(e)}))}},{key:"transfer",value:function(e,t){return this.workflows.transfer(e,t).catch((function(e){throw XT(e)}))}},{key:"batchNftTransfer",value:function(e,t){return this.workflows.batchNftTransfer(e,t).catch((function(e){throw XT(e)}))}},{key:"createExchange",value:function(e){return this.exchangeApi.createExchange(e).catch((function(e){throw XT(e)}))}},{key:"getExchange",value:function(e){return this.exchangeApi.getExchange(e).catch((function(e){throw XT(e)}))}},{key:"getExchanges",value:function(e){return this.exchangeApi.getExchanges(e).catch((function(e){throw XT(e)}))}},{key:"exchangeTransfer",value:function(e,t){return this.workflows.exchangeTransfer(e,t).catch((function(e){throw XT(e)}))}},{key:"createNftPrimary",value:function(e){return this.nftCheckoutPrimaryApi.createNftPrimary(e).catch((function(e){throw XT(e)}))}},{key:"getCurrenciesNFTCheckoutPrimary",value:function(e){return this.nftCheckoutPrimaryApi.getCurrenciesNFTCheckoutPrimary(e).catch((function(e){throw XT(e)}))}},{key:"getNftPrimaryTransaction",value:function(e){return this.nftCheckoutPrimaryApi.getNftPrimaryTransaction(e).catch((function(e){throw XT(e)}))}},{key:"getNftPrimaryTransactions",value:function(e){return this.nftCheckoutPrimaryApi.getNftPrimaryTransactions(e).catch((function(e){throw XT(e)}))}}]),e}();function JT(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function YT(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?JT(Object(r),!0).forEach((function(t){rA(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):JT(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var QT={"x-sdk-version":"imx-core-sdk-ts-".concat("2.0.2")},ZT=function(e){var t=e.coreContractAddress,r=e.registrationContractAddress,n=e.chainID,i=e.basePath,a=e.headers,s=e.sdkVersion;if(!i.trim())throw Error("basePath can not be empty");return s&&(QT["x-sdk-version"]=s),a=YT(YT({},a||{}),QT),{apiConfiguration:new kk({basePath:i,baseOptions:{headers:a}}),ethConfiguration:{coreContractAddress:t,registrationContractAddress:r,chainID:n}}},eR={get PRODUCTION(){return ZT({basePath:"https://api.x.immutable.com",chainID:1,coreContractAddress:"0x5FDCCA53617f4d2b9134B29090C87D01058e27e9",registrationContractAddress:"0x72a06bf2a1CE5e39cBA06c0CAb824960B587d64c"})},get SANDBOX(){return ZT({basePath:"https://api.sandbox.x.immutable.com",chainID:5,coreContractAddress:"0x7917eDb51ecD6CdB3F9854c3cc593F33de10c623",registrationContractAddress:"0x1C97Ada273C9A52253f463042f29117090Cd7D83"})},createConfig:ZT},tR=new ce("08000000 00000010 ffffffff ffffffff b781126d cae7b232 1e66a241 adc64d2f",16);new Yf.ec(new Yf.curves.PresetCurve({type:"short",prime:null,p:"08000000 00000011 00000000 00000000 00000000 00000000 00000000 00000001",a:"00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000001",b:"06f21413 efbe40de 150e596d 72f7a8c5 609ad26c 15c915c1 f4cdfcb9 9cee9e89",n:tR.toString("hex"),hash:Za.sha256,gRed:!1,g:["1ef15c18599971b7beced415a40f0c7deacfd9b0d1819e03d723d8bc943cfca","5668060aa49730b7be4801df46ec62de53ecd11abe43a32873000c36e8dc1f"]}));var rR=function(){var e=new ce("1 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000",16);return e.sub(e.mod(tR))};function nR(e,t){return new ce(Za.sha256().update(vf(Gf(e)+qf(xf(t),2))).digest("hex"),16)}function iR(e){for(var t=rR(),r=nR(e.toString("hex",64),0),n=0;r.gte(t);n++)r=nR(r.toString("hex"),n);return r.umod(tR).toString("hex")}function aR(e){for(var t=rR(),r=nR(e.toString("hex",64),0),n=1;r.gte(t);n++)r=nR(r.toString("hex"),n);return r.umod(tR).toString("hex")}function sR(e){var t=rR();return nR(e.toString("hex",64),0).gte(t)}function oR(e){return cR.apply(this,arguments)}function cR(){return(cR=EA(TA.mark((function e(t){var r,n;return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,r=new $T(eR.PRODUCTION),e.next=4,r.getUser(t);case 4:if(!((n=e.sent).accounts.length>0)){e.next=7;break}return e.abrupt("return",{starkPublicKey:n.accounts[0],accountNotFound:!1});case 7:e.next=14;break;case 9:if(e.prev=9,e.t0=e.catch(0),!(e.t0 instanceof WT&&"account_not_found"==e.t0.code)){e.next=13;break}return e.abrupt("return",{starkPublicKey:"",accountNotFound:!0});case 13:throw e.t0;case 14:case"end":return e.stop()}}),e,null,[[0,9]])})))).apply(this,arguments)}function fR(e,t){var r=h_.hdkey.fromMasterSeed(Buffer.from(e.slice(2),"hex")).derivePath(t).getWallet().getPrivateKey();return new ce(r)}function uR(e,t,r){return dR.apply(this,arguments)}function dR(){return(dR=EA(TA.mark((function e(t,r,n){var i,a,s,o,c,f,u,d;return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=fR(t,r),a=aR(i),sR(i)){e.next=4;break}return e.abrupt("return",a);case 4:return e.next=6,oR(n);case 6:if(void 0!==(s=e.sent)){e.next=9;break}throw new Error("Error fetching stark public key from IMX");case 9:if(!s.accountNotFound){e.next=11;break}return e.abrupt("return",a);case 11:return o=new ce(Gf(s.starkPublicKey),16),e.next=14,JA(a).getAddress();case 14:if(c=e.sent,!o.eq(new ce(Gf(c),16))){e.next=17;break}return e.abrupt("return",a);case 17:return f=iR(i),e.next=20,JA(f).getAddress();case 20:if(c=e.sent,!o.eq(new ce(Gf(c),16))){e.next=23;break}return e.abrupt("return",f);case 23:return u=XA(t,r),d=WA(u),e.next=27,JA(d).getAddress();case 27:if(c=e.sent,!o.eq(new ce(Gf(c),16))){e.next=30;break}return e.abrupt("return",d);case 30:throw new Error("Can not deterministically generate stark private key - please contact support");case 31:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function lR(e){return hR.apply(this,arguments)}function hR(){return(hR=EA(TA.mark((function e(t){var r,n,i,a,s;return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.getAddress();case 2:return r=e.sent.toLowerCase(),e.next=5,t.signMessage("Only sign this request if you’ve initiated an action with Immutable X.");case 5:return n=e.sent,i=Le(n).s,a=GA("starkex","immutablex",r,"1"),e.next=10,uR(i,a,r);case 10:return s=e.sent,e.abrupt("return",s.padStart(64,"0"));case 12:case"end":return e.stop()}}),e)})))).apply(this,arguments)}Gk.errors.INSUFFICIENT_FUNDS,Gk.errors.NONCE_EXPIRED,Gk.errors.REPLACEMENT_UNDERPRICED;const pR=({basePath:e,chainID:t,coreContractAddress:r,registrationContractAddress:n})=>eR.createConfig({basePath:e,chainID:t,coreContractAddress:r,registrationContractAddress:n,sdkVersion:"ts-immutable-sdk-0.0.0"}),bR=()=>pR({basePath:"https://api.sandbox.x.immutable.com",chainID:5,coreContractAddress:"0x7917eDb51ecD6CdB3F9854c3cc593F33de10c623",registrationContractAddress:"0x1C97Ada273C9A52253f463042f29117090Cd7D83"});class gR{immutableXConfig;baseConfig;constructor({baseConfig:t,overrides:r}){if(this.baseConfig=t,r)this.immutableXConfig=r.immutableXConfig;else switch(t.environment){case e.Environment.SANDBOX:this.immutableXConfig=bR();break;case e.Environment.PRODUCTION:this.immutableXConfig=pR({basePath:"https://api.x.immutable.com",chainID:1,coreContractAddress:"0x5FDCCA53617f4d2b9134B29090C87D01058e27e9",registrationContractAddress:"0x72a06bf2a1CE5e39cBA06c0CAb824960B587d64c"});break;default:this.immutableXConfig=bR()}}}class mR{immutableX;depositsApi;mintsApi;ordersApi;tokensApi;tradesApi;transfersApi;exchangeApi;nftCheckoutPrimaryApi;usersApi;withdrawalsApi;balanceApi;assetApi;collectionApi;metadataApi;metadataRefreshesApi;projectsApi;constructor(e){const t=new gR(e);this.immutableX=new $T(t.immutableXConfig),this.depositsApi=this.immutableX.depositsApi,this.mintsApi=this.immutableX.mintsApi,this.ordersApi=this.immutableX.ordersApi,this.tokensApi=this.immutableX.tokensApi,this.tradesApi=this.immutableX.tradesApi,this.transfersApi=this.immutableX.transfersApi,this.exchangeApi=this.immutableX.exchangeApi,this.usersApi=this.immutableX.usersApi,this.withdrawalsApi=this.immutableX.withdrawalsApi,this.balanceApi=this.immutableX.balanceApi,this.assetApi=this.immutableX.assetApi,this.collectionApi=this.immutableX.collectionApi,this.metadataApi=this.immutableX.metadataApi,this.metadataRefreshesApi=this.immutableX.metadataRefreshesApi,this.nftCheckoutPrimaryApi=this.immutableX.nftCheckoutPrimaryApi,this.projectsApi=this.immutableX.projectsApi}getDeposit(e){return this.immutableX.getDeposit(e)}listDeposits(e){return this.immutableX.listDeposits(e)}getUser(e){return this.immutableX.getUser(e)}getAsset(e){return this.immutableX.getAsset(e)}listAssets(e){return this.immutableX.listAssets(e)}createCollection(e,t){return this.immutableX.createCollection(e,t)}getCollection(e){return this.immutableX.getCollection(e)}listCollectionFilters(e){return this.immutableX.listCollectionFilters(e)}listCollections(e){return this.collectionApi.listCollections(e).then((e=>e.data))}updateCollection(e,t,r){return this.immutableX.updateCollection(e,t,r)}addMetadataSchemaToCollection(e,t,r){return this.immutableX.addMetadataSchemaToCollection(e,t,r)}getMetadataSchema(e){return this.immutableX.getMetadataSchema(e)}updateMetadataSchemaByName(e,t,r,n){return this.immutableX.updateMetadataSchemaByName(e,t,r,n)}listMetadataRefreshes(e,t,r,n){return this.immutableX.listMetadataRefreshes(e,t,r,n)}getMetadataRefreshErrors(e,t,r,n){return this.immutableX.getMetadataRefreshErrors(e,t,r,n)}getMetadataRefreshResults(e,t){return this.immutableX.getMetadataRefreshResults(e,t)}createMetadataRefresh(e,t){return this.immutableX.createMetadataRefresh(e,t)}async createProject(e,t){return this.immutableX.createProject(e,t)}async getProject(e,t){return this.immutableX.getProject(e,t)}async getProjects(e,t,r,n,i){return this.immutableX.getProjects(e,t,r,n,i)}getBalance(e){return this.immutableX.getBalance(e)}listBalances(e){return this.immutableX.listBalances(e)}getMint(e){return this.immutableX.getMint(e)}listMints(e){return this.immutableX.listMints(e)}mint(e,t){return this.immutableX.mint(e,t)}listWithdrawals(e){return this.immutableX.listWithdrawals(e)}getWithdrawal(e){return this.immutableX.getWithdrawal(e)}getOrder(e){return this.immutableX.getOrder(e)}listOrders(e){return this.immutableX.listOrders(e)}getTrade(e){return this.immutableX.getTrade(e)}listTrades(e){return this.immutableX.listTrades(e)}getToken(e){return this.immutableX.getToken(e)}listTokens(e){return this.immutableX.listTokens(e)}getTransfer(e){return this.immutableX.getTransfer(e)}listTransfers(e){return this.immutableX.listTransfers(e)}createExchange(e){return this.immutableX.createExchange(e).then((e=>e.data))}getExchange(e){return this.immutableX.getExchange(e).then((e=>e.data))}getExchanges(e){return this.immutableX.getExchanges(e).then((e=>e.data))}exchangeTransfer(e,t){return this.immutableX.exchangeTransfer(e,t)}createNftPrimary(e){return this.immutableX.createNftPrimary(e).then((e=>e.data))}getCurrenciesNFTCheckoutPrimary(e){return this.immutableX.getCurrenciesNFTCheckoutPrimary(e).then((e=>e.data))}getNftPrimaryTransaction(e){return this.immutableX.getNftPrimaryTransaction(e).then((e=>e.data))}getNftPrimaryTransactions(e){return this.immutableX.getNftPrimaryTransactions(e).then((e=>e.data))}}function yR(e,t){return function(){return e.apply(t,arguments)}}const{toString:vR}=Object.prototype,{getPrototypeOf:wR}=Object,_R=(ER=Object.create(null),e=>{const t=vR.call(e);return ER[t]||(ER[t]=t.slice(8,-1).toLowerCase())});var ER;const AR=e=>(e=e.toLowerCase(),t=>_R(t)===e),SR=e=>t=>typeof t===e,{isArray:kR}=Array,xR=SR("undefined");const TR=AR("ArrayBuffer");const RR=SR("string"),OR=SR("function"),IR=SR("number"),MR=e=>null!==e&&"object"==typeof e,CR=e=>{if("object"!==_R(e))return!1;const t=wR(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||Symbol.toStringTag in e||Symbol.iterator in e)},PR=AR("Date"),NR=AR("File"),BR=AR("Blob"),UR=AR("FileList"),LR=AR("URLSearchParams");function jR(e,t,{allOwnKeys:r=!1}={}){if(null==e)return;let n,i;if("object"!=typeof e&&(e=[e]),kR(e))for(n=0,i=e.length;n<i;n++)t.call(null,e[n],n,e);else{const i=r?Object.getOwnPropertyNames(e):Object.keys(e),a=i.length;let s;for(n=0;n<a;n++)s=i[n],t.call(null,e[s],s,e)}}function DR(e,t){t=t.toLowerCase();const r=Object.keys(e);let n,i=r.length;for(;i-- >0;)if(n=r[i],t===n.toLowerCase())return n;return null}const FR="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,qR=e=>!xR(e)&&e!==FR;const zR=(KR="undefined"!=typeof Uint8Array&&wR(Uint8Array),e=>KR&&e instanceof KR);var KR;const HR=AR("HTMLFormElement"),GR=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),VR=AR("RegExp"),WR=(e,t)=>{const r=Object.getOwnPropertyDescriptors(e),n={};jR(r,((r,i)=>{!1!==t(r,i,e)&&(n[i]=r)})),Object.defineProperties(e,n)},XR="abcdefghijklmnopqrstuvwxyz",$R="0123456789",JR={DIGIT:$R,ALPHA:XR,ALPHA_DIGIT:XR+XR.toUpperCase()+$R};const YR=AR("AsyncFunction");var QR={isArray:kR,isArrayBuffer:TR,isBuffer:function(e){return null!==e&&!xR(e)&&null!==e.constructor&&!xR(e.constructor)&&OR(e.constructor.isBuffer)&&e.constructor.isBuffer(e)},isFormData:e=>{let t;return e&&("function"==typeof FormData&&e instanceof FormData||OR(e.append)&&("formdata"===(t=_R(e))||"object"===t&&OR(e.toString)&&"[object FormData]"===e.toString()))},isArrayBufferView:function(e){let t;return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&TR(e.buffer),t},isString:RR,isNumber:IR,isBoolean:e=>!0===e||!1===e,isObject:MR,isPlainObject:CR,isUndefined:xR,isDate:PR,isFile:NR,isBlob:BR,isRegExp:VR,isFunction:OR,isStream:e=>MR(e)&&OR(e.pipe),isURLSearchParams:LR,isTypedArray:zR,isFileList:UR,forEach:jR,merge:function e(){const{caseless:t}=qR(this)&&this||{},r={},n=(n,i)=>{const a=t&&DR(r,i)||i;CR(r[a])&&CR(n)?r[a]=e(r[a],n):CR(n)?r[a]=e({},n):kR(n)?r[a]=n.slice():r[a]=n};for(let e=0,t=arguments.length;e<t;e++)arguments[e]&&jR(arguments[e],n);return r},extend:(e,t,r,{allOwnKeys:n}={})=>(jR(t,((t,n)=>{r&&OR(t)?e[n]=yR(t,r):e[n]=t}),{allOwnKeys:n}),e),trim:e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),stripBOM:e=>(65279===e.charCodeAt(0)&&(e=e.slice(1)),e),inherits:(e,t,r,n)=>{e.prototype=Object.create(t.prototype,n),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},toFlatObject:(e,t,r,n)=>{let i,a,s;const o={};if(t=t||{},null==e)return t;do{for(i=Object.getOwnPropertyNames(e),a=i.length;a-- >0;)s=i[a],n&&!n(s,e,t)||o[s]||(t[s]=e[s],o[s]=!0);e=!1!==r&&wR(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},kindOf:_R,kindOfTest:AR,endsWith:(e,t,r)=>{e=String(e),(void 0===r||r>e.length)&&(r=e.length),r-=t.length;const n=e.indexOf(t,r);return-1!==n&&n===r},toArray:e=>{if(!e)return null;if(kR(e))return e;let t=e.length;if(!IR(t))return null;const r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},forEachEntry:(e,t)=>{const r=(e&&e[Symbol.iterator]).call(e);let n;for(;(n=r.next())&&!n.done;){const r=n.value;t.call(e,r[0],r[1])}},matchAll:(e,t)=>{let r;const n=[];for(;null!==(r=e.exec(t));)n.push(r);return n},isHTMLForm:HR,hasOwnProperty:GR,hasOwnProp:GR,reduceDescriptors:WR,freezeMethods:e=>{WR(e,((t,r)=>{if(OR(e)&&-1!==["arguments","caller","callee"].indexOf(r))return!1;const n=e[r];OR(n)&&(t.enumerable=!1,"writable"in t?t.writable=!1:t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")}))}))},toObjectSet:(e,t)=>{const r={},n=e=>{e.forEach((e=>{r[e]=!0}))};return kR(e)?n(e):n(String(e).split(t)),r},toCamelCase:e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,(function(e,t,r){return t.toUpperCase()+r})),noop:()=>{},toFiniteNumber:(e,t)=>(e=+e,Number.isFinite(e)?e:t),findKey:DR,global:FR,isContextDefined:qR,ALPHABET:JR,generateString:(e=16,t=JR.ALPHA_DIGIT)=>{let r="";const{length:n}=t;for(;e--;)r+=t[Math.random()*n|0];return r},isSpecCompliantForm:function(e){return!!(e&&OR(e.append)&&"FormData"===e[Symbol.toStringTag]&&e[Symbol.iterator])},toJSONObject:e=>{const t=new Array(10),r=(e,n)=>{if(MR(e)){if(t.indexOf(e)>=0)return;if(!("toJSON"in e)){t[n]=e;const i=kR(e)?[]:{};return jR(e,((e,t)=>{const a=r(e,n+1);!xR(a)&&(i[t]=a)})),t[n]=void 0,i}}return e};return r(e,0)},isAsyncFn:YR,isThenable:e=>e&&(MR(e)||OR(e))&&OR(e.then)&&OR(e.catch)};function ZR(e,t,r,n,i){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack,this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),n&&(this.request=n),i&&(this.response=i)}QR.inherits(ZR,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:QR.toJSONObject(this.config),code:this.code,status:this.response&&this.response.status?this.response.status:null}}});const eO=ZR.prototype,tO={};["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((e=>{tO[e]={value:e}})),Object.defineProperties(ZR,tO),Object.defineProperty(eO,"isAxiosError",{value:!0}),ZR.from=(e,t,r,n,i,a)=>{const s=Object.create(eO);return QR.toFlatObject(e,s,(function(e){return e!==Error.prototype}),(e=>"isAxiosError"!==e)),ZR.call(s,e.message,t,r,n,i),s.cause=e,s.name=e.name,a&&Object.assign(s,a),s};function rO(e){return QR.isPlainObject(e)||QR.isArray(e)}function nO(e){return QR.endsWith(e,"[]")?e.slice(0,-2):e}function iO(e,t,r){return e?e.concat(t).map((function(e,t){return e=nO(e),!r&&t?"["+e+"]":e})).join(r?".":""):t}const aO=QR.toFlatObject(QR,{},null,(function(e){return/^is[A-Z]/.test(e)}));function sO(e,t,r){if(!QR.isObject(e))throw new TypeError("target must be an object");t=t||new FormData;const n=(r=QR.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,(function(e,t){return!QR.isUndefined(t[e])}))).metaTokens,i=r.visitor||f,a=r.dots,s=r.indexes,o=(r.Blob||"undefined"!=typeof Blob&&Blob)&&QR.isSpecCompliantForm(t);if(!QR.isFunction(i))throw new TypeError("visitor must be a function");function c(e){if(null===e)return"";if(QR.isDate(e))return e.toISOString();if(!o&&QR.isBlob(e))throw new ZR("Blob is not supported. Use a Buffer instead.");return QR.isArrayBuffer(e)||QR.isTypedArray(e)?o&&"function"==typeof Blob?new Blob([e]):Buffer.from(e):e}function f(e,r,i){let o=e;if(e&&!i&&"object"==typeof e)if(QR.endsWith(r,"{}"))r=n?r:r.slice(0,-2),e=JSON.stringify(e);else if(QR.isArray(e)&&function(e){return QR.isArray(e)&&!e.some(rO)}(e)||(QR.isFileList(e)||QR.endsWith(r,"[]"))&&(o=QR.toArray(e)))return r=nO(r),o.forEach((function(e,n){!QR.isUndefined(e)&&null!==e&&t.append(!0===s?iO([r],n,a):null===s?r:r+"[]",c(e))})),!1;return!!rO(e)||(t.append(iO(i,r,a),c(e)),!1)}const u=[],d=Object.assign(aO,{defaultVisitor:f,convertValue:c,isVisitable:rO});if(!QR.isObject(e))throw new TypeError("data must be an object");return function e(r,n){if(!QR.isUndefined(r)){if(-1!==u.indexOf(r))throw Error("Circular reference detected in "+n.join("."));u.push(r),QR.forEach(r,(function(r,a){!0===(!(QR.isUndefined(r)||null===r)&&i.call(t,r,QR.isString(a)?a.trim():a,n,d))&&e(r,n?n.concat(a):[a])})),u.pop()}}(e),t}function oO(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,(function(e){return t[e]}))}function cO(e,t){this._pairs=[],e&&sO(e,this,t)}const fO=cO.prototype;function uO(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function dO(e,t,r){if(!t)return e;const n=r&&r.encode||uO,i=r&&r.serialize;let a;if(a=i?i(t,r):QR.isURLSearchParams(t)?t.toString():new cO(t,r).toString(n),a){const t=e.indexOf("#");-1!==t&&(e=e.slice(0,t)),e+=(-1===e.indexOf("?")?"?":"&")+a}return e}fO.append=function(e,t){this._pairs.push([e,t])},fO.toString=function(e){const t=e?function(t){return e.call(this,t,oO)}:oO;return this._pairs.map((function(e){return t(e[0])+"="+t(e[1])}),"").join("&")};var lO=class{constructor(){this.handlers=[]}use(e,t,r){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!r&&r.synchronous,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){QR.forEach(this.handlers,(function(t){null!==t&&e(t)}))}},hO={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var pO={isBrowser:!0,classes:{URLSearchParams:"undefined"!=typeof URLSearchParams?URLSearchParams:cO,FormData:"undefined"!=typeof FormData?FormData:null,Blob:"undefined"!=typeof Blob?Blob:null},isStandardBrowserEnv:(()=>{let e;return("undefined"==typeof navigator||"ReactNative"!==(e=navigator.product)&&"NativeScript"!==e&&"NS"!==e)&&("undefined"!=typeof window&&"undefined"!=typeof document)})(),isStandardBrowserWebWorkerEnv:"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,protocols:["http","https","file","blob","url","data"]};function bO(e){function t(e,r,n,i){let a=e[i++];const s=Number.isFinite(+a),o=i>=e.length;if(a=!a&&QR.isArray(n)?n.length:a,o)return QR.hasOwnProp(n,a)?n[a]=[n[a],r]:n[a]=r,!s;n[a]&&QR.isObject(n[a])||(n[a]=[]);return t(e,r,n[a],i)&&QR.isArray(n[a])&&(n[a]=function(e){const t={},r=Object.keys(e);let n;const i=r.length;let a;for(n=0;n<i;n++)a=r[n],t[a]=e[a];return t}(n[a])),!s}if(QR.isFormData(e)&&QR.isFunction(e.entries)){const r={};return QR.forEachEntry(e,((e,n)=>{t(function(e){return QR.matchAll(/\w+|\[(\w*)]/g,e).map((e=>"[]"===e[0]?"":e[1]||e[0]))}(e),n,r,0)})),r}return null}const gO={"Content-Type":void 0};const mO={transitional:hO,adapter:["xhr","http"],transformRequest:[function(e,t){const r=t.getContentType()||"",n=r.indexOf("application/json")>-1,i=QR.isObject(e);i&&QR.isHTMLForm(e)&&(e=new FormData(e));if(QR.isFormData(e))return n&&n?JSON.stringify(bO(e)):e;if(QR.isArrayBuffer(e)||QR.isBuffer(e)||QR.isStream(e)||QR.isFile(e)||QR.isBlob(e))return e;if(QR.isArrayBufferView(e))return e.buffer;if(QR.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let a;if(i){if(r.indexOf("application/x-www-form-urlencoded")>-1)return function(e,t){return sO(e,new pO.classes.URLSearchParams,Object.assign({visitor:function(e,t,r,n){return pO.isNode&&QR.isBuffer(e)?(this.append(t,e.toString("base64")),!1):n.defaultVisitor.apply(this,arguments)}},t))}(e,this.formSerializer).toString();if((a=QR.isFileList(e))||r.indexOf("multipart/form-data")>-1){const t=this.env&&this.env.FormData;return sO(a?{"files[]":e}:e,t&&new t,this.formSerializer)}}return i||n?(t.setContentType("application/json",!1),function(e,t,r){if(QR.isString(e))try{return(t||JSON.parse)(e),QR.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(r||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){const t=this.transitional||mO.transitional,r=t&&t.forcedJSONParsing,n="json"===this.responseType;if(e&&QR.isString(e)&&(r&&!this.responseType||n)){const r=!(t&&t.silentJSONParsing)&&n;try{return JSON.parse(e)}catch(e){if(r){if("SyntaxError"===e.name)throw ZR.from(e,ZR.ERR_BAD_RESPONSE,this,null,this.response);throw e}}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:pO.classes.FormData,Blob:pO.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};QR.forEach(["delete","get","head"],(function(e){mO.headers[e]={}})),QR.forEach(["post","put","patch"],(function(e){mO.headers[e]=QR.merge(gO)}));var yO=mO;const vO=QR.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"]);const wO=Symbol("internals");function _O(e){return e&&String(e).trim().toLowerCase()}function EO(e){return!1===e||null==e?e:QR.isArray(e)?e.map(EO):String(e)}function AO(e,t,r,n,i){return QR.isFunction(n)?n.call(this,t,r):(i&&(t=r),QR.isString(t)?QR.isString(n)?-1!==t.indexOf(n):QR.isRegExp(n)?n.test(t):void 0:void 0)}let SO=class{constructor(e){e&&this.set(e)}set(e,t,r){const n=this;function i(e,t,r){const i=_O(t);if(!i)throw new Error("header name must be a non-empty string");const a=QR.findKey(n,i);(!a||void 0===n[a]||!0===r||void 0===r&&!1!==n[a])&&(n[a||t]=EO(e))}const a=(e,t)=>QR.forEach(e,((e,r)=>i(e,r,t)));return QR.isPlainObject(e)||e instanceof this.constructor?a(e,t):QR.isString(e)&&(e=e.trim())&&!/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim())?a((e=>{const t={};let r,n,i;return e&&e.split("\n").forEach((function(e){i=e.indexOf(":"),r=e.substring(0,i).trim().toLowerCase(),n=e.substring(i+1).trim(),!r||t[r]&&vO[r]||("set-cookie"===r?t[r]?t[r].push(n):t[r]=[n]:t[r]=t[r]?t[r]+", "+n:n)})),t})(e),t):null!=e&&i(t,e,r),this}get(e,t){if(e=_O(e)){const r=QR.findKey(this,e);if(r){const e=this[r];if(!t)return e;if(!0===t)return function(e){const t=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let n;for(;n=r.exec(e);)t[n[1]]=n[2];return t}(e);if(QR.isFunction(t))return t.call(this,e,r);if(QR.isRegExp(t))return t.exec(e);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=_O(e)){const r=QR.findKey(this,e);return!(!r||void 0===this[r]||t&&!AO(0,this[r],r,t))}return!1}delete(e,t){const r=this;let n=!1;function i(e){if(e=_O(e)){const i=QR.findKey(r,e);!i||t&&!AO(0,r[i],i,t)||(delete r[i],n=!0)}}return QR.isArray(e)?e.forEach(i):i(e),n}clear(e){const t=Object.keys(this);let r=t.length,n=!1;for(;r--;){const i=t[r];e&&!AO(0,this[i],i,e,!0)||(delete this[i],n=!0)}return n}normalize(e){const t=this,r={};return QR.forEach(this,((n,i)=>{const a=QR.findKey(r,i);if(a)return t[a]=EO(n),void delete t[i];const s=e?function(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,((e,t,r)=>t.toUpperCase()+r))}(i):String(i).trim();s!==i&&delete t[i],t[s]=EO(n),r[s]=!0})),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return QR.forEach(this,((r,n)=>{null!=r&&!1!==r&&(t[n]=e&&QR.isArray(r)?r.join(", "):r)})),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map((([e,t])=>e+": "+t)).join("\n")}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const r=new this(e);return t.forEach((e=>r.set(e))),r}static accessor(e){const t=(this[wO]=this[wO]={accessors:{}}).accessors,r=this.prototype;function n(e){const n=_O(e);t[n]||(!function(e,t){const r=QR.toCamelCase(" "+t);["get","set","has"].forEach((n=>{Object.defineProperty(e,n+r,{value:function(e,r,i){return this[n].call(this,t,e,r,i)},configurable:!0})}))}(r,e),t[n]=!0)}return QR.isArray(e)?e.forEach(n):n(e),this}};SO.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),QR.freezeMethods(SO.prototype),QR.freezeMethods(SO);var kO=SO;function xO(e,t){const r=this||yO,n=t||r,i=kO.from(n.headers);let a=n.data;return QR.forEach(e,(function(e){a=e.call(r,a,i.normalize(),t?t.status:void 0)})),i.normalize(),a}function TO(e){return!(!e||!e.__CANCEL__)}function RO(e,t,r){ZR.call(this,null==e?"canceled":e,ZR.ERR_CANCELED,t,r),this.name="CanceledError"}QR.inherits(RO,ZR,{__CANCEL__:!0});var OO=pO.isStandardBrowserEnv?{write:function(e,t,r,n,i,a){const s=[];s.push(e+"="+encodeURIComponent(t)),QR.isNumber(r)&&s.push("expires="+new Date(r).toGMTString()),QR.isString(n)&&s.push("path="+n),QR.isString(i)&&s.push("domain="+i),!0===a&&s.push("secure"),document.cookie=s.join("; ")},read:function(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}};function IO(e,t){return e&&!/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)?function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}(e,t):t}var MO=pO.isStandardBrowserEnv?function(){const e=/(msie|trident)/i.test(navigator.userAgent),t=document.createElement("a");let r;function n(r){let n=r;return e&&(t.setAttribute("href",n),n=t.href),t.setAttribute("href",n),{href:t.href,protocol:t.protocol?t.protocol.replace(/:$/,""):"",host:t.host,search:t.search?t.search.replace(/^\?/,""):"",hash:t.hash?t.hash.replace(/^#/,""):"",hostname:t.hostname,port:t.port,pathname:"/"===t.pathname.charAt(0)?t.pathname:"/"+t.pathname}}return r=n(window.location.href),function(e){const t=QR.isString(e)?n(e):e;return t.protocol===r.protocol&&t.host===r.host}}():function(){return!0};function CO(e,t){let r=0;const n=function(e,t){e=e||10;const r=new Array(e),n=new Array(e);let i,a=0,s=0;return t=void 0!==t?t:1e3,function(o){const c=Date.now(),f=n[s];i||(i=c),r[a]=o,n[a]=c;let u=s,d=0;for(;u!==a;)d+=r[u++],u%=e;if(a=(a+1)%e,a===s&&(s=(s+1)%e),c-i<t)return;const l=f&&c-f;return l?Math.round(1e3*d/l):void 0}}(50,250);return i=>{const a=i.loaded,s=i.lengthComputable?i.total:void 0,o=a-r,c=n(o);r=a;const f={loaded:a,total:s,progress:s?a/s:void 0,bytes:o,rate:c||void 0,estimated:c&&s&&a<=s?(s-a)/c:void 0,event:i};f[t?"download":"upload"]=!0,e(f)}}var PO="undefined"!=typeof XMLHttpRequest&&function(e){return new Promise((function(t,r){let n=e.data;const i=kO.from(e.headers).normalize(),a=e.responseType;let s;function o(){e.cancelToken&&e.cancelToken.unsubscribe(s),e.signal&&e.signal.removeEventListener("abort",s)}QR.isFormData(n)&&(pO.isStandardBrowserEnv||pO.isStandardBrowserWebWorkerEnv?i.setContentType(!1):i.setContentType("multipart/form-data;",!1));let c=new XMLHttpRequest;if(e.auth){const t=e.auth.username||"",r=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";i.set("Authorization","Basic "+btoa(t+":"+r))}const f=IO(e.baseURL,e.url);function u(){if(!c)return;const n=kO.from("getAllResponseHeaders"in c&&c.getAllResponseHeaders());!function(e,t,r){const n=r.config.validateStatus;r.status&&n&&!n(r.status)?t(new ZR("Request failed with status code "+r.status,[ZR.ERR_BAD_REQUEST,ZR.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r)):e(r)}((function(e){t(e),o()}),(function(e){r(e),o()}),{data:a&&"text"!==a&&"json"!==a?c.response:c.responseText,status:c.status,statusText:c.statusText,headers:n,config:e,request:c}),c=null}if(c.open(e.method.toUpperCase(),dO(f,e.params,e.paramsSerializer),!0),c.timeout=e.timeout,"onloadend"in c?c.onloadend=u:c.onreadystatechange=function(){c&&4===c.readyState&&(0!==c.status||c.responseURL&&0===c.responseURL.indexOf("file:"))&&setTimeout(u)},c.onabort=function(){c&&(r(new ZR("Request aborted",ZR.ECONNABORTED,e,c)),c=null)},c.onerror=function(){r(new ZR("Network Error",ZR.ERR_NETWORK,e,c)),c=null},c.ontimeout=function(){let t=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded";const n=e.transitional||hO;e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),r(new ZR(t,n.clarifyTimeoutError?ZR.ETIMEDOUT:ZR.ECONNABORTED,e,c)),c=null},pO.isStandardBrowserEnv){const t=(e.withCredentials||MO(f))&&e.xsrfCookieName&&OO.read(e.xsrfCookieName);t&&i.set(e.xsrfHeaderName,t)}void 0===n&&i.setContentType(null),"setRequestHeader"in c&&QR.forEach(i.toJSON(),(function(e,t){c.setRequestHeader(t,e)})),QR.isUndefined(e.withCredentials)||(c.withCredentials=!!e.withCredentials),a&&"json"!==a&&(c.responseType=e.responseType),"function"==typeof e.onDownloadProgress&&c.addEventListener("progress",CO(e.onDownloadProgress,!0)),"function"==typeof e.onUploadProgress&&c.upload&&c.upload.addEventListener("progress",CO(e.onUploadProgress)),(e.cancelToken||e.signal)&&(s=t=>{c&&(r(!t||t.type?new RO(null,e,c):t),c.abort(),c=null)},e.cancelToken&&e.cancelToken.subscribe(s),e.signal&&(e.signal.aborted?s():e.signal.addEventListener("abort",s)));const d=function(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}(f);d&&-1===pO.protocols.indexOf(d)?r(new ZR("Unsupported protocol "+d+":",ZR.ERR_BAD_REQUEST,e)):c.send(n||null)}))};const NO={http:null,xhr:PO};QR.forEach(NO,((e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch(e){}Object.defineProperty(e,"adapterName",{value:t})}}));var BO=e=>{e=QR.isArray(e)?e:[e];const{length:t}=e;let r,n;for(let i=0;i<t&&(r=e[i],!(n=QR.isString(r)?NO[r.toLowerCase()]:r));i++);if(!n){if(!1===n)throw new ZR(`Adapter ${r} is not supported by the environment`,"ERR_NOT_SUPPORT");throw new Error(QR.hasOwnProp(NO,r)?`Adapter '${r}' is not available in the build`:`Unknown adapter '${r}'`)}if(!QR.isFunction(n))throw new TypeError("adapter is not a function");return n};function UO(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new RO(null,e)}function LO(e){UO(e),e.headers=kO.from(e.headers),e.data=xO.call(e,e.transformRequest),-1!==["post","put","patch"].indexOf(e.method)&&e.headers.setContentType("application/x-www-form-urlencoded",!1);return BO(e.adapter||yO.adapter)(e).then((function(t){return UO(e),t.data=xO.call(e,e.transformResponse,t),t.headers=kO.from(t.headers),t}),(function(t){return TO(t)||(UO(e),t&&t.response&&(t.response.data=xO.call(e,e.transformResponse,t.response),t.response.headers=kO.from(t.response.headers))),Promise.reject(t)}))}const jO=e=>e instanceof kO?e.toJSON():e;function DO(e,t){t=t||{};const r={};function n(e,t,r){return QR.isPlainObject(e)&&QR.isPlainObject(t)?QR.merge.call({caseless:r},e,t):QR.isPlainObject(t)?QR.merge({},t):QR.isArray(t)?t.slice():t}function i(e,t,r){return QR.isUndefined(t)?QR.isUndefined(e)?void 0:n(void 0,e,r):n(e,t,r)}function a(e,t){if(!QR.isUndefined(t))return n(void 0,t)}function s(e,t){return QR.isUndefined(t)?QR.isUndefined(e)?void 0:n(void 0,e):n(void 0,t)}function o(r,i,a){return a in t?n(r,i):a in e?n(void 0,r):void 0}const c={url:a,method:a,data:a,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials: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:o,headers:(e,t)=>i(jO(e),jO(t),!0)};return QR.forEach(Object.keys(Object.assign({},e,t)),(function(n){const a=c[n]||i,s=a(e[n],t[n],n);QR.isUndefined(s)&&a!==o||(r[n]=s)})),r}const FO="1.4.0",qO={};["object","boolean","number","function","string","symbol"].forEach(((e,t)=>{qO[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}}));const zO={};qO.transitional=function(e,t,r){function n(e,t){return"[Axios v1.4.0] Transitional option '"+e+"'"+t+(r?". "+r:"")}return(r,i,a)=>{if(!1===e)throw new ZR(n(i," has been removed"+(t?" in "+t:"")),ZR.ERR_DEPRECATED);return t&&!zO[i]&&(zO[i]=!0,console.warn(n(i," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(r,i,a)}};var KO={assertOptions:function(e,t,r){if("object"!=typeof e)throw new ZR("options must be an object",ZR.ERR_BAD_OPTION_VALUE);const n=Object.keys(e);let i=n.length;for(;i-- >0;){const a=n[i],s=t[a];if(s){const t=e[a],r=void 0===t||s(t,a,e);if(!0!==r)throw new ZR("option "+a+" must be "+r,ZR.ERR_BAD_OPTION_VALUE)}else if(!0!==r)throw new ZR("Unknown option "+a,ZR.ERR_BAD_OPTION)}},validators:qO};const HO=KO.validators;let GO=class{constructor(e){this.defaults=e,this.interceptors={request:new lO,response:new lO}}request(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{},t=DO(this.defaults,t);const{transitional:r,paramsSerializer:n,headers:i}=t;let a;void 0!==r&&KO.assertOptions(r,{silentJSONParsing:HO.transitional(HO.boolean),forcedJSONParsing:HO.transitional(HO.boolean),clarifyTimeoutError:HO.transitional(HO.boolean)},!1),null!=n&&(QR.isFunction(n)?t.paramsSerializer={serialize:n}:KO.assertOptions(n,{encode:HO.function,serialize:HO.function},!0)),t.method=(t.method||this.defaults.method||"get").toLowerCase(),a=i&&QR.merge(i.common,i[t.method]),a&&QR.forEach(["delete","get","head","post","put","patch","common"],(e=>{delete i[e]})),t.headers=kO.concat(a,i);const s=[];let o=!0;this.interceptors.request.forEach((function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(o=o&&e.synchronous,s.unshift(e.fulfilled,e.rejected))}));const c=[];let f;this.interceptors.response.forEach((function(e){c.push(e.fulfilled,e.rejected)}));let u,d=0;if(!o){const e=[LO.bind(this),void 0];for(e.unshift.apply(e,s),e.push.apply(e,c),u=e.length,f=Promise.resolve(t);d<u;)f=f.then(e[d++],e[d++]);return f}u=s.length;let l=t;for(d=0;d<u;){const e=s[d++],t=s[d++];try{l=e(l)}catch(e){t.call(this,e);break}}try{f=LO.call(this,l)}catch(e){return Promise.reject(e)}for(d=0,u=c.length;d<u;)f=f.then(c[d++],c[d++]);return f}getUri(e){return dO(IO((e=DO(this.defaults,e)).baseURL,e.url),e.params,e.paramsSerializer)}};QR.forEach(["delete","get","head","options"],(function(e){GO.prototype[e]=function(t,r){return this.request(DO(r||{},{method:e,url:t,data:(r||{}).data}))}})),QR.forEach(["post","put","patch"],(function(e){function t(t){return function(r,n,i){return this.request(DO(i||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:r,data:n}))}}GO.prototype[e]=t(),GO.prototype[e+"Form"]=t(!0)}));var VO=GO;var WO=class e{constructor(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");let t;this.promise=new Promise((function(e){t=e}));const r=this;this.promise.then((e=>{if(!r._listeners)return;let t=r._listeners.length;for(;t-- >0;)r._listeners[t](e);r._listeners=null})),this.promise.then=e=>{let t;const n=new Promise((e=>{r.subscribe(e),t=e})).then(e);return n.cancel=function(){r.unsubscribe(t)},n},e((function(e,n,i){r.reason||(r.reason=new RO(e,n,i),t(r.reason))}))}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}static source(){let t;const r=new e((function(e){t=e}));return{token:r,cancel:t}}};const XO={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(XO).forEach((([e,t])=>{XO[t]=e}));var $O=XO;const JO=function e(t){const r=new VO(t),n=yR(VO.prototype.request,r);return QR.extend(n,VO.prototype,r,{allOwnKeys:!0}),QR.extend(n,r,null,{allOwnKeys:!0}),n.create=function(r){return e(DO(t,r))},n}(yO);JO.Axios=VO,JO.CanceledError=RO,JO.CancelToken=WO,JO.isCancel=TO,JO.VERSION=FO,JO.toFormData=sO,JO.AxiosError=ZR,JO.Cancel=JO.CanceledError,JO.all=function(e){return Promise.all(e)},JO.spread=function(e){return function(t){return e.apply(null,t)}},JO.isAxiosError=function(e){return QR.isObject(e)&&!0===e.isAxiosError},JO.mergeConfig=DO,JO.AxiosHeaders=kO,JO.formToJSON=e=>bO(QR.isHTMLForm(e)?new FormData(e):e),JO.HttpStatusCode=$O,JO.default=JO;var YO=JO;const QO="https://api.sandbox.immutable.com".replace(/\/+$/,"");let ZO=class{basePath;axios;configuration;constructor(e,t=QO,r=YO){this.basePath=t,this.axios=r,e&&(this.configuration=e,this.basePath=e.basePath||this.basePath)}},eI=class extends Error{field;name="RequiredError";constructor(e,t){super(t),this.field=e}};const tI="https://example.com",rI=function(e,t,r){if(null==r)throw new eI(t,`Required parameter ${t} was null or undefined when calling ${e}.`)};function nI(e,t,r=""){"object"==typeof t?Array.isArray(t)?t.forEach((t=>nI(e,t,r))):Object.keys(t).forEach((n=>nI(e,t[n],`${r}${""!==r?".":""}${n}`))):e.has(r)?e.append(r,t):e.set(r,t)}const iI=function(e,...t){const r=new URLSearchParams(e.search);nI(r,t),e.search=r.toString()},aI=function(e,t,r){const n="string"!=typeof e;return(n&&r&&r.isJsonMime?r.isJsonMime(t.headers["Content-Type"]):n)?JSON.stringify(void 0!==e?e:{}):e||""},sI=function(e){return e.pathname+e.search+e.hash},oI=function(e,t,r,n){return(i=t,a=r)=>{const s={...e.options,url:(n?.basePath||a)+e.url};return i.request(s)}},cI=function(e){const t=function(e){return{getActivity:async(t,r,n={})=>{rI("getActivity","chainName",t),rI("getActivity","activityId",r);const i="/v1/chains/{chain_name}/activities/{activity_id}".replace("{chain_name}",encodeURIComponent(String(t))).replace("{activity_id}",encodeURIComponent(String(r))),a=new URL(i,tI);let s;e&&(s=e.baseOptions);const o={method:"GET",...s,...n};iI(a,{});let c=s&&s.headers?s.headers:{};return o.headers={...c,...n.headers},{url:sI(a),options:o}},listActivities:async(t,r,n,i,a,s,o,c,f,u,d={})=>{rI("listActivities","chainName",t);const l="/v1/chains/{chain_name}/activities".replace("{chain_name}",encodeURIComponent(String(t))),h=new URL(l,tI);let p;e&&(p=e.baseOptions);const b={method:"GET",...p,...d},g={};void 0!==r&&(g.contract_address=r),void 0!==n&&(g.token_id=n),void 0!==i&&(g.account_address=i),void 0!==a&&(g.activity_type=a),void 0!==s&&(g.from_indexed_at=s instanceof Date?s.toISOString():s),void 0!==o&&(g.to_indexed_at=o instanceof Date?o.toISOString():o),void 0!==c&&(g.transaction_hash=c),void 0!==f&&(g.page_cursor=f),void 0!==u&&(g.page_size=u),iI(h,g);let m=p&&p.headers?p.headers:{};return b.headers={...m,...d.headers},{url:sI(h),options:b}}}}(e);return{async getActivity(r,n,i){const a=await t.getActivity(r,n,i);return oI(a,YO,QO,e)},async listActivities(r,n,i,a,s,o,c,f,u,d,l){const h=await t.listActivities(r,n,i,a,s,o,c,f,u,d,l);return oI(h,YO,QO,e)}}};class fI extends ZO{getActivity(e,t){return cI(this.configuration).getActivity(e.chainName,e.activityId,t).then((e=>e(this.axios,this.basePath)))}listActivities(e,t){return cI(this.configuration).listActivities(e.chainName,e.contractAddress,e.tokenId,e.accountAddress,e.activityType,e.fromIndexedAt,e.toIndexedAt,e.transactionHash,e.pageCursor,e.pageSize,t).then((e=>e(this.axios,this.basePath)))}}const uI=function(e){const t=function(e){return{listChains:async(t,r,n={})=>{const i=new URL("/v1/chains",tI);let a;e&&(a=e.baseOptions);const s={method:"GET",...a,...n},o={};void 0!==t&&(o.page_cursor=t),void 0!==r&&(o.page_size=r),iI(i,o);let c=a&&a.headers?a.headers:{};return s.headers={...c,...n.headers},{url:sI(i),options:s}}}}(e);return{async listChains(r,n,i){const a=await t.listChains(r,n,i);return oI(a,YO,QO,e)}}};class dI extends ZO{listChains(e={},t){return uI(this.configuration).listChains(e.pageCursor,e.pageSize,t).then((e=>e(this.axios,this.basePath)))}}const lI=function(e){const t=function(e){return{getCollection:async(t,r,n={})=>{rI("getCollection","contractAddress",t),rI("getCollection","chainName",r);const i="/v1/chains/{chain_name}/collections/{contract_address}".replace("{contract_address}",encodeURIComponent(String(t))).replace("{chain_name}",encodeURIComponent(String(r))),a=new URL(i,tI);let s;e&&(s=e.baseOptions);const o={method:"GET",...s,...n};iI(a,{});let c=s&&s.headers?s.headers:{};return o.headers={...c,...n.headers},{url:sI(a),options:o}},listCollections:async(t,r,n,i={})=>{rI("listCollections","chainName",t);const a="/v1/chains/{chain_name}/collections".replace("{chain_name}",encodeURIComponent(String(t))),s=new URL(a,tI);let o;e&&(o=e.baseOptions);const c={method:"GET",...o,...i},f={};void 0!==r&&(f.page_cursor=r),void 0!==n&&(f.page_size=n),iI(s,f);let u=o&&o.headers?o.headers:{};return c.headers={...u,...i.headers},{url:sI(s),options:c}}}}(e);return{async getCollection(r,n,i){const a=await t.getCollection(r,n,i);return oI(a,YO,QO,e)},async listCollections(r,n,i,a){const s=await t.listCollections(r,n,i,a);return oI(s,YO,QO,e)}}};class hI extends ZO{getCollection(e,t){return lI(this.configuration).getCollection(e.contractAddress,e.chainName,t).then((e=>e(this.axios,this.basePath)))}listCollections(e,t){return lI(this.configuration).listCollections(e.chainName,e.pageCursor,e.pageSize,t).then((e=>e(this.axios,this.basePath)))}}const pI=function(e){const t=function(e){return{listNFTOwners:async(t,r,n,i,a,s={})=>{rI("listNFTOwners","contractAddress",t),rI("listNFTOwners","tokenId",r),rI("listNFTOwners","chainName",n);const o="/v1/chains/{chain_name}/collections/{contract_address}/nfts/{token_id}/owners".replace("{contract_address}",encodeURIComponent(String(t))).replace("{token_id}",encodeURIComponent(String(r))).replace("{chain_name}",encodeURIComponent(String(n))),c=new URL(o,tI);let f;e&&(f=e.baseOptions);const u={method:"GET",...f,...s},d={};void 0!==i&&(d.page_cursor=i),void 0!==a&&(d.page_size=a),iI(c,d);let l=f&&f.headers?f.headers:{};return u.headers={...l,...s.headers},{url:sI(c),options:u}}}}(e);return{async listNFTOwners(r,n,i,a,s,o){const c=await t.listNFTOwners(r,n,i,a,s,o);return oI(c,YO,QO,e)}}};class bI extends ZO{listNFTOwners(e,t){return pI(this.configuration).listNFTOwners(e.contractAddress,e.tokenId,e.chainName,e.pageCursor,e.pageSize,t).then((e=>e(this.axios,this.basePath)))}}const gI=function(e){const t=function(e){return{getNFT:async(t,r,n,i={})=>{rI("getNFT","contractAddress",t),rI("getNFT","tokenId",r),rI("getNFT","chainName",n);const a="/v1/chains/{chain_name}/collections/{contract_address}/nfts/{token_id}".replace("{contract_address}",encodeURIComponent(String(t))).replace("{token_id}",encodeURIComponent(String(r))).replace("{chain_name}",encodeURIComponent(String(n))),s=new URL(a,tI);let o;e&&(o=e.baseOptions);const c={method:"GET",...o,...i};iI(s,{});let f=o&&o.headers?o.headers:{};return c.headers={...f,...i.headers},{url:sI(s),options:c}},listNFTs:async(t,r,n,i,a={})=>{rI("listNFTs","contractAddress",t),rI("listNFTs","chainName",r);const s="/v1/chains/{chain_name}/collections/{contract_address}/nfts".replace("{contract_address}",encodeURIComponent(String(t))).replace("{chain_name}",encodeURIComponent(String(r))),o=new URL(s,tI);let c;e&&(c=e.baseOptions);const f={method:"GET",...c,...a},u={};void 0!==n&&(u.page_cursor=n),void 0!==i&&(u.page_size=i),iI(o,u);let d=c&&c.headers?c.headers:{};return f.headers={...d,...a.headers},{url:sI(o),options:f}},listNFTsByAccountAddress:async(t,r,n,i,a,s={})=>{rI("listNFTsByAccountAddress","accountAddress",t),rI("listNFTsByAccountAddress","chainName",r);const o="/v1/chains/{chain_name}/accounts/{account_address}/nfts".replace("{account_address}",encodeURIComponent(String(t))).replace("{chain_name}",encodeURIComponent(String(r))),c=new URL(o,tI);let f;e&&(f=e.baseOptions);const u={method:"GET",...f,...s},d={};void 0!==n&&(d.contract_address=n),void 0!==i&&(d.page_cursor=i),void 0!==a&&(d.page_size=a),iI(c,d);let l=f&&f.headers?f.headers:{};return u.headers={...l,...s.headers},{url:sI(c),options:u}}}}(e);return{async getNFT(r,n,i,a){const s=await t.getNFT(r,n,i,a);return oI(s,YO,QO,e)},async listNFTs(r,n,i,a,s){const o=await t.listNFTs(r,n,i,a,s);return oI(o,YO,QO,e)},async listNFTsByAccountAddress(r,n,i,a,s,o){const c=await t.listNFTsByAccountAddress(r,n,i,a,s,o);return oI(c,YO,QO,e)}}};class mI extends ZO{getNFT(e,t){return gI(this.configuration).getNFT(e.contractAddress,e.tokenId,e.chainName,t).then((e=>e(this.axios,this.basePath)))}listNFTs(e,t){return gI(this.configuration).listNFTs(e.contractAddress,e.chainName,e.pageCursor,e.pageSize,t).then((e=>e(this.axios,this.basePath)))}listNFTsByAccountAddress(e,t){return gI(this.configuration).listNFTsByAccountAddress(e.accountAddress,e.chainName,e.contractAddress,e.pageCursor,e.pageSize,t).then((e=>e(this.axios,this.basePath)))}}const yI=function(e){const t=function(e){return{createListing:async(t,r,n={})=>{rI("createListing","chainName",t),rI("createListing","createListingRequestBody",r);const i="/v1/chains/{chain_name}/orders/listings".replace("{chain_name}",encodeURIComponent(String(t))),a=new URL(i,tI);let s;e&&(s=e.baseOptions);const o={method:"POST",...s,...n},c={"Content-Type":"application/json"};iI(a,{});let f=s&&s.headers?s.headers:{};return o.headers={...c,...f,...n.headers},o.data=aI(r,o,e),{url:sI(a),options:o}},fulfillmentData:async(t,r,n={})=>{rI("fulfillmentData","chainName",t),rI("fulfillmentData","fulfillmentDataRequestInner",r);const i="/v1/chains/{chain_name}/orders/fulfillment_data".replace("{chain_name}",encodeURIComponent(String(t))),a=new URL(i,tI);let s;e&&(s=e.baseOptions);const o={method:"POST",...s,...n},c={"Content-Type":"application/json"};iI(a,{});let f=s&&s.headers?s.headers:{};return o.headers={...c,...f,...n.headers},o.data=aI(r,o,e),{url:sI(a),options:o}},getListing:async(t,r,n={})=>{rI("getListing","chainName",t),rI("getListing","listingId",r);const i="/v1/chains/{chain_name}/orders/listings/{listing_id}".replace("{chain_name}",encodeURIComponent(String(t))).replace("{listing_id}",encodeURIComponent(String(r))),a=new URL(i,tI);let s;e&&(s=e.baseOptions);const o={method:"GET",...s,...n};iI(a,{});let c=s&&s.headers?s.headers:{};return o.headers={...c,...n.headers},{url:sI(a),options:o}},listListings:async(t,r,n,i,a,s,o,c,f,u={})=>{rI("listListings","chainName",t);const d="/v1/chains/{chain_name}/orders/listings".replace("{chain_name}",encodeURIComponent(String(t))),l=new URL(d,tI);let h;e&&(h=e.baseOptions);const p={method:"GET",...h,...u},b={};void 0!==r&&(b.status=r),void 0!==n&&(b.sell_item_contract_address=n),void 0!==i&&(b.buy_item_contract_address=i),void 0!==a&&(b.sell_item_token_id=a),void 0!==s&&(b.page_size=s),void 0!==o&&(b.sort_by=o),void 0!==c&&(b.sort_direction=c),void 0!==f&&(b.page_cursor=f),iI(l,b);let g=h&&h.headers?h.headers:{};return p.headers={...g,...u.headers},{url:sI(l),options:p}}}}(e);return{async createListing(r,n,i){const a=await t.createListing(r,n,i);return oI(a,YO,QO,e)},async fulfillmentData(r,n,i){const a=await t.fulfillmentData(r,n,i);return oI(a,YO,QO,e)},async getListing(r,n,i){const a=await t.getListing(r,n,i);return oI(a,YO,QO,e)},async listListings(r,n,i,a,s,o,c,f,u,d){const l=await t.listListings(r,n,i,a,s,o,c,f,u,d);return oI(l,YO,QO,e)}}};class vI extends ZO{createListing(e,t){return yI(this.configuration).createListing(e.chainName,e.createListingRequestBody,t).then((e=>e(this.axios,this.basePath)))}fulfillmentData(e,t){return yI(this.configuration).fulfillmentData(e.chainName,e.fulfillmentDataRequestInner,t).then((e=>e(this.axios,this.basePath)))}getListing(e,t){return yI(this.configuration).getListing(e.chainName,e.listingId,t).then((e=>e(this.axios,this.basePath)))}listListings(e,t){return yI(this.configuration).listListings(e.chainName,e.status,e.sellItemContractAddress,e.buyItemContractAddress,e.sellItemTokenId,e.pageSize,e.sortBy,e.sortDirection,e.pageCursor,t).then((e=>e(this.axios,this.basePath)))}}const wI=function(e){const t=function(e){return{createCounterfactualAddress:async(t,r={})=>{rI("createCounterfactualAddress","createCounterfactualAddressRequest",t);const n=new URL("/passport-mr/v1/counterfactual-address",tI);let i;e&&(i=e.baseOptions);const a={method:"POST",...i,...r},s={};await async function(e,t){if(t&&t.accessToken){const r="function"==typeof t.accessToken?await t.accessToken():await t.accessToken;e.Authorization="Bearer "+r}}(s,e),s["Content-Type"]="application/json",iI(n,{});let o=i&&i.headers?i.headers:{};return a.headers={...s,...o,...r.headers},a.data=aI(t,a,e),{url:sI(n),options:a}}}}(e);return{async createCounterfactualAddress(r,n){const i=await t.createCounterfactualAddress(r,n);return oI(i,YO,QO,e)}}};class _I extends ZO{createCounterfactualAddress(e,t){return wI(this.configuration).createCounterfactualAddress(e.createCounterfactualAddressRequest,t).then((e=>e(this.axios,this.basePath)))}}class EI{config;activitiesApi;chainsApi;collectionApi;nftOwnersApi;nftsApi;ordersApi;passportApi;constructor(e){this.config=e,this.activitiesApi=new fI(e.indexer),this.chainsApi=new dI(e.indexer),this.collectionApi=new hI(e.indexer),this.nftOwnersApi=new bI(e.indexer),this.nftsApi=new mI(e.indexer),this.ordersApi=new vI(e.orderBook),this.passportApi=new _I(e.passport)}}const AI={"x-sdk-version":"ts-immutable-sdk-0.0.0"},SI=({basePath:e,headers:t})=>{if(!e.trim())throw Error("basePath can not be empty");const r={basePath:e,baseOptions:{headers:{...AI,...t||{}}}};return new class{apiKey;username;password;accessToken;basePath;baseOptions;formDataCtor;constructor(e={}){this.apiKey=e.apiKey,this.username=e.username,this.password=e.password,this.accessToken=e.accessToken,this.basePath=e.basePath,this.baseOptions=e.baseOptions,this.formDataCtor=e.formDataCtor}isJsonMime(e){const t=new RegExp("^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$","i");return null!==e&&(t.test(e)||"application/json-patch+json"===e.toLowerCase())}}(r)},kI=()=>({indexer:SI({basePath:"https://indexer-mr.imtbl.com"}),orderBook:SI({basePath:"https://order-book-mr.imtbl.com"}),passport:SI({basePath:"https://api.immutable.com"})}),xI=()=>({indexer:SI({basePath:"https://indexer-mr.sandbox.imtbl.com"}),orderBook:SI({basePath:"https://order-book-mr.sandbox.imtbl.com"}),passport:SI({basePath:"https://api.sandbox.immutable.com"})});var TI={exports:{}};!function(e,t){e.exports=function(){var e=e||function(e,t){var n;if("undefined"!=typeof window&&window.crypto&&(n=window.crypto),"undefined"!=typeof self&&self.crypto&&(n=self.crypto),"undefined"!=typeof globalThis&&globalThis.crypto&&(n=globalThis.crypto),!n&&"undefined"!=typeof window&&window.msCrypto&&(n=window.msCrypto),!n&&void 0!==r&&r.crypto&&(n=r.crypto),!n)try{n=au}catch(e){}var i=function(){if(n){if("function"==typeof n.getRandomValues)try{return n.getRandomValues(new Uint32Array(1))[0]}catch(e){}if("function"==typeof n.randomBytes)try{return n.randomBytes(4).readInt32LE()}catch(e){}}throw new Error("Native crypto module could not be used to get secure random number.")},a=Object.create||function(){function e(){}return function(t){var r;return e.prototype=t,r=new e,e.prototype=null,r}}(),s={},o=s.lib={},c=o.Base={extend:function(e){var t=a(this);return e&&t.mixIn(e),t.hasOwnProperty("init")&&this.init!==t.init||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},f=o.WordArray=c.extend({init:function(e,r){e=this.words=e||[],this.sigBytes=r!=t?r:4*e.length},toString:function(e){return(e||d).stringify(this)},concat:function(e){var t=this.words,r=e.words,n=this.sigBytes,i=e.sigBytes;if(this.clamp(),n%4)for(var a=0;a<i;a++){var s=r[a>>>2]>>>24-a%4*8&255;t[n+a>>>2]|=s<<24-(n+a)%4*8}else for(var o=0;o<i;o+=4)t[n+o>>>2]=r[o>>>2];return this.sigBytes+=i,this},clamp:function(){var t=this.words,r=this.sigBytes;t[r>>>2]&=4294967295<<32-r%4*8,t.length=e.ceil(r/4)},clone:function(){var e=c.clone.call(this);return e.words=this.words.slice(0),e},random:function(e){for(var t=[],r=0;r<e;r+=4)t.push(i());return new f.init(t,e)}}),u=s.enc={},d=u.Hex={stringify:function(e){for(var t=e.words,r=e.sigBytes,n=[],i=0;i<r;i++){var a=t[i>>>2]>>>24-i%4*8&255;n.push((a>>>4).toString(16)),n.push((15&a).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,r=[],n=0;n<t;n+=2)r[n>>>3]|=parseInt(e.substr(n,2),16)<<24-n%8*4;return new f.init(r,t/2)}},l=u.Latin1={stringify:function(e){for(var t=e.words,r=e.sigBytes,n=[],i=0;i<r;i++){var a=t[i>>>2]>>>24-i%4*8&255;n.push(String.fromCharCode(a))}return n.join("")},parse:function(e){for(var t=e.length,r=[],n=0;n<t;n++)r[n>>>2]|=(255&e.charCodeAt(n))<<24-n%4*8;return new f.init(r,t)}},h=u.Utf8={stringify:function(e){try{return decodeURIComponent(escape(l.stringify(e)))}catch(e){throw new Error("Malformed UTF-8 data")}},parse:function(e){return l.parse(unescape(encodeURIComponent(e)))}},p=o.BufferedBlockAlgorithm=c.extend({reset:function(){this._data=new f.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=h.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var r,n=this._data,i=n.words,a=n.sigBytes,s=this.blockSize,o=a/(4*s),c=(o=t?e.ceil(o):e.max((0|o)-this._minBufferSize,0))*s,u=e.min(4*c,a);if(c){for(var d=0;d<c;d+=s)this._doProcessBlock(i,d);r=i.splice(0,c),n.sigBytes-=u}return new f.init(r,u)},clone:function(){var e=c.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0});o.Hasher=p.extend({cfg:c.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){p.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){return function(t,r){return new e.init(r).finalize(t)}},_createHmacHelper:function(e){return function(t,r){return new b.HMAC.init(e,r).finalize(t)}}});var b=s.algo={};return s}(Math);return e}()}(TI);var RI=TI.exports,OI=n(RI),II={exports:{}};!function(e,t){e.exports=function(e){return function(t){var r=e,n=r.lib,i=n.WordArray,a=n.Hasher,s=r.algo,o=[],c=[];!function(){function e(e){for(var r=t.sqrt(e),n=2;n<=r;n++)if(!(e%n))return!1;return!0}function r(e){return 4294967296*(e-(0|e))|0}for(var n=2,i=0;i<64;)e(n)&&(i<8&&(o[i]=r(t.pow(n,.5))),c[i]=r(t.pow(n,1/3)),i++),n++}();var f=[],u=s.SHA256=a.extend({_doReset:function(){this._hash=new i.init(o.slice(0))},_doProcessBlock:function(e,t){for(var r=this._hash.words,n=r[0],i=r[1],a=r[2],s=r[3],o=r[4],u=r[5],d=r[6],l=r[7],h=0;h<64;h++){if(h<16)f[h]=0|e[t+h];else{var p=f[h-15],b=(p<<25|p>>>7)^(p<<14|p>>>18)^p>>>3,g=f[h-2],m=(g<<15|g>>>17)^(g<<13|g>>>19)^g>>>10;f[h]=b+f[h-7]+m+f[h-16]}var y=n&i^n&a^i&a,v=(n<<30|n>>>2)^(n<<19|n>>>13)^(n<<10|n>>>22),w=l+((o<<26|o>>>6)^(o<<21|o>>>11)^(o<<7|o>>>25))+(o&u^~o&d)+c[h]+f[h];l=d,d=u,u=o,o=s+w|0,s=a,a=i,i=n,n=w+(v+y)|0}r[0]=r[0]+n|0,r[1]=r[1]+i|0,r[2]=r[2]+a|0,r[3]=r[3]+s|0,r[4]=r[4]+o|0,r[5]=r[5]+u|0,r[6]=r[6]+d|0,r[7]=r[7]+l|0},_doFinalize:function(){var e=this._data,r=e.words,n=8*this._nDataBytes,i=8*e.sigBytes;return r[i>>>5]|=128<<24-i%32,r[14+(i+64>>>9<<4)]=t.floor(n/4294967296),r[15+(i+64>>>9<<4)]=n,e.sigBytes=4*r.length,this._process(),this._hash},clone:function(){var e=a.clone.call(this);return e._hash=this._hash.clone(),e}});r.SHA256=a._createHelper(u),r.HmacSHA256=a._createHmacHelper(u)}(Math),e.SHA256}(RI)}(II);var MI=n(II.exports),CI={exports:{}};!function(e,t){e.exports=function(e){return function(){var t=e,r=t.lib.WordArray;function n(e,t,n){for(var i=[],a=0,s=0;s<t;s++)if(s%4){var o=n[e.charCodeAt(s-1)]<<s%4*2|n[e.charCodeAt(s)]>>>6-s%4*2;i[a>>>2]|=o<<24-a%4*8,a++}return r.create(i,a)}t.enc.Base64={stringify:function(e){var t=e.words,r=e.sigBytes,n=this._map;e.clamp();for(var i=[],a=0;a<r;a+=3)for(var s=(t[a>>>2]>>>24-a%4*8&255)<<16|(t[a+1>>>2]>>>24-(a+1)%4*8&255)<<8|t[a+2>>>2]>>>24-(a+2)%4*8&255,o=0;o<4&&a+.75*o<r;o++)i.push(n.charAt(s>>>6*(3-o)&63));var c=n.charAt(64);if(c)for(;i.length%4;)i.push(c);return i.join("")},parse:function(e){var t=e.length,r=this._map,i=this._reverseMap;if(!i){i=this._reverseMap=[];for(var a=0;a<r.length;a++)i[r.charCodeAt(a)]=a}var s=r.charAt(64);if(s){var o=e.indexOf(s);-1!==o&&(t=o)}return n(e,t,i)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),e.enc.Base64}(RI)}(CI);var PI=n(CI.exports),NI={exports:{}};!function(e,t){e.exports=function(e){return e.enc.Utf8}(RI)}(NI);var BI=n(NI.exports);function UI(e){this.message=e}UI.prototype=new Error,UI.prototype.name="InvalidCharacterError";var LI="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(e){var t=String(e).replace(/=+$/,"");if(t.length%4==1)throw new UI("'atob' failed: The string to be decoded is not correctly encoded.");for(var r,n,i=0,a=0,s="";n=t.charAt(a++);~n&&(r=i%4?64*r+n:n,i++%4)?s+=String.fromCharCode(255&r>>(-2*i&6)):0)n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(n);return s};function jI(e){this.message=e}function DI(e,t){if("string"!=typeof e)throw new jI("Invalid token specified");var r=!0===(t=t||{}).header?0:1;try{return JSON.parse(function(e){var t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw"Illegal base64url string!"}try{return function(e){return decodeURIComponent(LI(e).replace(/(.)/g,(function(e,t){var r=t.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r})))}(t)}catch(e){return LI(t)}}(e.split(".")[r]))}catch(e){throw new jI("Invalid token specified: "+e.message)}}jI.prototype=new Error,jI.prototype.name="InvalidTokenError";var FI,qI,zI,KI={debug:()=>{},info:()=>{},warn:()=>{},error:()=>{}},HI=(e=>(e[e.NONE=0]="NONE",e[e.ERROR=1]="ERROR",e[e.WARN=2]="WARN",e[e.INFO=3]="INFO",e[e.DEBUG=4]="DEBUG",e))(HI||{});(zI=HI||(HI={})).reset=function(){FI=3,qI=KI},zI.setLevel=function(e){if(!(0<=e&&e<=4))throw new Error("Invalid log level");FI=e},zI.setLogger=function(e){qI=e};var GI=class{constructor(e){this._name=e}debug(...e){FI>=4&&qI.debug(GI._format(this._name,this._method),...e)}info(...e){FI>=3&&qI.info(GI._format(this._name,this._method),...e)}warn(...e){FI>=2&&qI.warn(GI._format(this._name,this._method),...e)}error(...e){FI>=1&&qI.error(GI._format(this._name,this._method),...e)}throw(e){throw this.error(e),e}create(e){const t=Object.create(this);return t._method=e,t.debug("begin"),t}static createStatic(e,t){const r=new GI(`${e}.${t}`);return r.debug("begin"),r}static _format(e,t){const r=`[${e}]`;return t?`${r} ${t}:`:r}static debug(e,...t){FI>=4&&qI.debug(GI._format(e),...t)}static info(e,...t){FI>=3&&qI.info(GI._format(e),...t)}static warn(e,...t){FI>=2&&qI.warn(GI._format(e),...t)}static error(e,...t){FI>=1&&qI.error(GI._format(e),...t)}};HI.reset();var VI=class{static _randomWord(){return OI.lib.WordArray.random(1).words[0]}static generateUUIDv4(){const e="10000000-1000-4000-8000-100000000000".replace(/[018]/g,(e=>(+e^VI._randomWord()&15>>+e/4).toString(16)));return e.replace(/-/g,"")}static generateCodeVerifier(){return VI.generateUUIDv4()+VI.generateUUIDv4()+VI.generateUUIDv4()}static generateCodeChallenge(e){try{const t=MI(e);return PI.stringify(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}catch(e){throw GI.error("CryptoUtils.generateCodeChallenge",e),e}}static generateBasicAuth(e,t){const r=BI.parse([e,t].join(":"));return PI.stringify(r)}},WI=class{constructor(e){this._name=e,this._logger=new GI(`Event('${this._name}')`),this._callbacks=[]}addHandler(e){return this._callbacks.push(e),()=>this.removeHandler(e)}removeHandler(e){const t=this._callbacks.lastIndexOf(e);t>=0&&this._callbacks.splice(t,1)}raise(...e){this._logger.debug("raise:",...e);for(const t of this._callbacks)t(...e)}},XI=class{static decode(e){try{return DI(e)}catch(e){throw GI.error("JwtUtils.decode",e),e}}},$I=class{static center({...e}){var t;return null==e.width&&(e.width=null!=(t=[800,720,600,480].find((e=>e<=window.outerWidth/1.618)))?t:360),null!=e.left||(e.left=Math.max(0,Math.round(window.screenX+(window.outerWidth-e.width)/2))),null!=e.height&&(null!=e.top||(e.top=Math.max(0,Math.round(window.screenY+(window.outerHeight-e.height)/2)))),e}static serialize(e){return Object.entries(e).filter((([,e])=>null!=e)).map((([e,t])=>`${e}=${"boolean"!=typeof t?t:t?"yes":"no"}`)).join(",")}},JI=class extends WI{constructor(){super(...arguments),this._logger=new GI(`Timer('${this._name}')`),this._timerHandle=null,this._expiration=0,this._callback=()=>{const e=this._expiration-JI.getEpochTime();this._logger.debug("timer completes in",e),this._expiration<=JI.getEpochTime()&&(this.cancel(),super.raise())}}static getEpochTime(){return Math.floor(Date.now()/1e3)}init(e){const t=this._logger.create("init");e=Math.max(Math.floor(e),1);const r=JI.getEpochTime()+e;if(this.expiration===r&&this._timerHandle)return void t.debug("skipping since already initialized for expiration at",this.expiration);this.cancel(),t.debug("using duration",e),this._expiration=r;const n=Math.min(e,5);this._timerHandle=setInterval(this._callback,1e3*n)}get expiration(){return this._expiration}cancel(){this._logger.create("cancel"),this._timerHandle&&(clearInterval(this._timerHandle),this._timerHandle=null)}},YI=class{static readParams(e,t="query"){if(!e)throw new TypeError("Invalid URL");const r=new URL(e,"http://127.0.0.1")["fragment"===t?"hash":"search"];return new URLSearchParams(r.slice(1))}},QI=class extends Error{constructor(e,t){var r,n,i;if(super(e.error_description||e.error||""),this.form=t,this.name="ErrorResponse",!e.error)throw GI.error("ErrorResponse","No error passed"),new Error("No error passed");this.error=e.error,this.error_description=null!=(r=e.error_description)?r:null,this.error_uri=null!=(n=e.error_uri)?n:null,this.state=e.userState,this.session_state=null!=(i=e.session_state)?i:null}},ZI=class extends Error{constructor(e){super(e),this.name="ErrorTimeout"}},eM=class{constructor(e){this._logger=new GI("AccessTokenEvents"),this._expiringTimer=new JI("Access token expiring"),this._expiredTimer=new JI("Access token expired"),this._expiringNotificationTimeInSeconds=e.expiringNotificationTimeInSeconds}load(e){const t=this._logger.create("load");if(e.access_token&&void 0!==e.expires_in){const r=e.expires_in;if(t.debug("access token present, remaining duration:",r),r>0){let e=r-this._expiringNotificationTimeInSeconds;e<=0&&(e=1),t.debug("registering expiring timer, raising in",e,"seconds"),this._expiringTimer.init(e)}else t.debug("canceling existing expiring timer because we're past expiration."),this._expiringTimer.cancel();const n=r+1;t.debug("registering expired timer, raising in",n,"seconds"),this._expiredTimer.init(n)}else this._expiringTimer.cancel(),this._expiredTimer.cancel()}unload(){this._logger.debug("unload: canceling existing access token timers"),this._expiringTimer.cancel(),this._expiredTimer.cancel()}addAccessTokenExpiring(e){return this._expiringTimer.addHandler(e)}removeAccessTokenExpiring(e){this._expiringTimer.removeHandler(e)}addAccessTokenExpired(e){return this._expiredTimer.addHandler(e)}removeAccessTokenExpired(e){this._expiredTimer.removeHandler(e)}},tM=class{constructor(){this._logger=new GI("InMemoryWebStorage"),this._data={}}clear(){this._logger.create("clear"),this._data={}}getItem(e){return this._logger.create(`getItem('${e}')`),this._data[e]}setItem(e,t){this._logger.create(`setItem('${e}')`),this._data[e]=t}removeItem(e){this._logger.create(`removeItem('${e}')`),delete this._data[e]}get length(){return Object.getOwnPropertyNames(this._data).length}key(e){return Object.getOwnPropertyNames(this._data)[e]}},rM=class{constructor(e=[],t=null,r={}){this._jwtHandler=t,this._extraHeaders=r,this._logger=new GI("JsonService"),this._contentTypes=[],this._contentTypes.push(...e,"application/json"),t&&this._contentTypes.push("application/jwt")}async fetchWithTimeout(e,t={}){const{timeoutInSeconds:r,...n}=t;if(!r)return await fetch(e,n);const i=new AbortController,a=setTimeout((()=>i.abort()),1e3*r);try{return await fetch(e,{...t,signal:i.signal})}catch(e){if(e instanceof DOMException&&"AbortError"===e.name)throw new ZI("Network timed out");throw e}finally{clearTimeout(a)}}async getJson(e,{token:t,credentials:r}={}){const n=this._logger.create("getJson"),i={Accept:this._contentTypes.join(", ")};let a;t&&(n.debug("token passed, setting Authorization header"),i.Authorization="Bearer "+t),this.appendExtraHeaders(i);try{n.debug("url:",e),a=await this.fetchWithTimeout(e,{method:"GET",headers:i,credentials:r})}catch(e){throw n.error("Network Error"),e}n.debug("HTTP response received, status",a.status);const s=a.headers.get("Content-Type");if(s&&!this._contentTypes.find((e=>s.startsWith(e)))&&n.throw(new Error(`Invalid response Content-Type: ${null!=s?s:"undefined"}, from URL: ${e}`)),a.ok&&this._jwtHandler&&(null==s?void 0:s.startsWith("application/jwt")))return await this._jwtHandler(await a.text());let o;try{o=await a.json()}catch(e){if(n.error("Error parsing JSON response",e),a.ok)throw e;throw new Error(`${a.statusText} (${a.status})`)}if(!a.ok){if(n.error("Error from server:",o),o.error)throw new QI(o);throw new Error(`${a.statusText} (${a.status}): ${JSON.stringify(o)}`)}return o}async postForm(e,{body:t,basicAuth:r,timeoutInSeconds:n,initCredentials:i}){const a=this._logger.create("postForm"),s={Accept:this._contentTypes.join(", "),"Content-Type":"application/x-www-form-urlencoded"};let o;void 0!==r&&(s.Authorization="Basic "+r),this.appendExtraHeaders(s);try{a.debug("url:",e),o=await this.fetchWithTimeout(e,{method:"POST",headers:s,body:t,timeoutInSeconds:n,credentials:i})}catch(e){throw a.error("Network error"),e}a.debug("HTTP response received, status",o.status);const c=o.headers.get("Content-Type");if(c&&!this._contentTypes.find((e=>c.startsWith(e))))throw new Error(`Invalid response Content-Type: ${null!=c?c:"undefined"}, from URL: ${e}`);const f=await o.text();let u={};if(f)try{u=JSON.parse(f)}catch(e){if(a.error("Error parsing JSON response",e),o.ok)throw e;throw new Error(`${o.statusText} (${o.status})`)}if(!o.ok){if(a.error("Error from server:",u),u.error)throw new QI(u,t);throw new Error(`${o.statusText} (${o.status}): ${JSON.stringify(u)}`)}return u}appendExtraHeaders(e){const t=this._logger.create("appendExtraHeaders"),r=Object.keys(this._extraHeaders),n=["authorization","accept","content-type"];0!==r.length&&r.forEach((r=>{if(n.includes(r.toLocaleLowerCase()))return void t.warn("Protected header could not be overridden",r,n);const i="function"==typeof this._extraHeaders[r]?this._extraHeaders[r]():this._extraHeaders[r];i&&""!==i&&(e[r]=i)}))}},nM=class{constructor({prefix:e="oidc.",store:t=localStorage}={}){this._logger=new GI("WebStorageStateStore"),this._store=t,this._prefix=e}async set(e,t){this._logger.create(`set('${e}')`),e=this._prefix+e,await this._store.setItem(e,t)}async get(e){this._logger.create(`get('${e}')`),e=this._prefix+e;return await this._store.getItem(e)}async remove(e){this._logger.create(`remove('${e}')`),e=this._prefix+e;const t=await this._store.getItem(e);return await this._store.removeItem(e),t}async getAllKeys(){this._logger.create("getAllKeys");const e=await this._store.length,t=[];for(let r=0;r<e;r++){const e=await this._store.key(r);e&&0===e.indexOf(this._prefix)&&t.push(e.substr(this._prefix.length))}return t}},iM=class{constructor({authority:e,metadataUrl:t,metadata:r,signingKeys:n,metadataSeed:i,client_id:a,client_secret:s,response_type:o="code",scope:c="openid",redirect_uri:f,post_logout_redirect_uri:u,client_authentication:d="client_secret_post",prompt:l,display:h,max_age:p,ui_locales:b,acr_values:g,resource:m,response_mode:y="query",filterProtocolClaims:v=!0,loadUserInfo:w=!1,staleStateAgeInSeconds:_=900,clockSkewInSeconds:E=300,userInfoJwtIssuer:A="OP",mergeClaims:S=!1,disablePKCE:k=!1,stateStore:x,refreshTokenCredentials:T,revokeTokenAdditionalContentTypes:R,fetchRequestCredentials:O,refreshTokenAllowedScope:I,extraQueryParams:M={},extraTokenParams:C={},extraHeaders:P={}}){if(this.authority=e,t?this.metadataUrl=t:(this.metadataUrl=e,e&&(this.metadataUrl.endsWith("/")||(this.metadataUrl+="/"),this.metadataUrl+=".well-known/openid-configuration")),this.metadata=r,this.metadataSeed=i,this.signingKeys=n,this.client_id=a,this.client_secret=s,this.response_type=o,this.scope=c,this.redirect_uri=f,this.post_logout_redirect_uri=u,this.client_authentication=d,this.prompt=l,this.display=h,this.max_age=p,this.ui_locales=b,this.acr_values=g,this.resource=m,this.response_mode=y,this.filterProtocolClaims=null==v||v,this.loadUserInfo=!!w,this.staleStateAgeInSeconds=_,this.clockSkewInSeconds=E,this.userInfoJwtIssuer=A,this.mergeClaims=!!S,this.disablePKCE=!!k,this.revokeTokenAdditionalContentTypes=R,O&&T&&console.warn("Both fetchRequestCredentials and refreshTokenCredentials is set. Only fetchRequestCredentials will be used."),this.fetchRequestCredentials=O||(T||"same-origin"),x)this.stateStore=x;else{const e="undefined"!=typeof window?window.localStorage:new tM;this.stateStore=new nM({store:e})}this.refreshTokenAllowedScope=I,this.extraQueryParams=M,this.extraTokenParams=C,this.extraHeaders=P}},aM=class{constructor(e,t){this._settings=e,this._metadataService=t,this._logger=new GI("TokenClient"),this._jsonService=new rM(this._settings.revokeTokenAdditionalContentTypes,null,this._settings.extraHeaders)}async exchangeCode({grant_type:e="authorization_code",redirect_uri:t=this._settings.redirect_uri,client_id:r=this._settings.client_id,client_secret:n=this._settings.client_secret,...i}){const a=this._logger.create("exchangeCode");r||a.throw(new Error("A client_id is required")),t||a.throw(new Error("A redirect_uri is required")),i.code||a.throw(new Error("A code is required"));const s=new URLSearchParams({grant_type:e,redirect_uri:t});for(const[e,t]of Object.entries(i))null!=t&&s.set(e,t);let o;switch(this._settings.client_authentication){case"client_secret_basic":if(!n)throw a.throw(new Error("A client_secret is required")),null;o=VI.generateBasicAuth(r,n);break;case"client_secret_post":s.append("client_id",r),n&&s.append("client_secret",n)}const c=await this._metadataService.getTokenEndpoint(!1);a.debug("got token endpoint");const f=await this._jsonService.postForm(c,{body:s,basicAuth:o,initCredentials:this._settings.fetchRequestCredentials});return a.debug("got response"),f}async exchangeCredentials({grant_type:e="password",client_id:t=this._settings.client_id,client_secret:r=this._settings.client_secret,scope:n=this._settings.scope,...i}){const a=this._logger.create("exchangeCredentials");t||a.throw(new Error("A client_id is required"));const s=new URLSearchParams({grant_type:e,scope:n});for(const[e,t]of Object.entries(i))null!=t&&s.set(e,t);let o;switch(this._settings.client_authentication){case"client_secret_basic":if(!r)throw a.throw(new Error("A client_secret is required")),null;o=VI.generateBasicAuth(t,r);break;case"client_secret_post":s.append("client_id",t),r&&s.append("client_secret",r)}const c=await this._metadataService.getTokenEndpoint(!1);a.debug("got token endpoint");const f=await this._jsonService.postForm(c,{body:s,basicAuth:o,initCredentials:this._settings.fetchRequestCredentials});return a.debug("got response"),f}async exchangeRefreshToken({grant_type:e="refresh_token",client_id:t=this._settings.client_id,client_secret:r=this._settings.client_secret,timeoutInSeconds:n,...i}){const a=this._logger.create("exchangeRefreshToken");t||a.throw(new Error("A client_id is required")),i.refresh_token||a.throw(new Error("A refresh_token is required"));const s=new URLSearchParams({grant_type:e});for(const[e,t]of Object.entries(i))null!=t&&s.set(e,t);let o;switch(this._settings.client_authentication){case"client_secret_basic":if(!r)throw a.throw(new Error("A client_secret is required")),null;o=VI.generateBasicAuth(t,r);break;case"client_secret_post":s.append("client_id",t),r&&s.append("client_secret",r)}const c=await this._metadataService.getTokenEndpoint(!1);a.debug("got token endpoint");const f=await this._jsonService.postForm(c,{body:s,basicAuth:o,timeoutInSeconds:n,initCredentials:this._settings.fetchRequestCredentials});return a.debug("got response"),f}async revoke(e){var t;const r=this._logger.create("revoke");e.token||r.throw(new Error("A token is required"));const n=await this._metadataService.getRevocationEndpoint(!1);r.debug(`got revocation endpoint, revoking ${null!=(t=e.token_type_hint)?t:"default token type"}`);const i=new URLSearchParams;for(const[t,r]of Object.entries(e))null!=r&&i.set(t,r);i.set("client_id",this._settings.client_id),this._settings.client_secret&&i.set("client_secret",this._settings.client_secret),await this._jsonService.postForm(n,{body:i}),r.debug("got response")}},sM=class{constructor(e){this.id=e.id||VI.generateUUIDv4(),this.data=e.data,e.created&&e.created>0?this.created=e.created:this.created=JI.getEpochTime(),this.request_type=e.request_type}toStorageString(){return new GI("State").create("toStorageString"),JSON.stringify({id:this.id,data:this.data,created:this.created,request_type:this.request_type})}static fromStorageString(e){return GI.createStatic("State","fromStorageString"),new sM(JSON.parse(e))}static async clearStaleState(e,t){const r=GI.createStatic("State","clearStaleState"),n=JI.getEpochTime()-t,i=await e.getAllKeys();r.debug("got keys",i);for(let t=0;t<i.length;t++){const a=i[t],s=await e.get(a);let o=!1;if(s)try{const e=sM.fromStorageString(s);r.debug("got item from key:",a,e.created),e.created<=n&&(o=!0)}catch(e){r.error("Error parsing state for key:",a,e),o=!0}else r.debug("no item in storage for key:",a),o=!0;o&&(r.debug("removed item for key:",a),e.remove(a))}}},oM=class extends sM{constructor(e){super(e),!0===e.code_verifier?this.code_verifier=VI.generateCodeVerifier():e.code_verifier&&(this.code_verifier=e.code_verifier),this.code_verifier&&(this.code_challenge=VI.generateCodeChallenge(this.code_verifier)),this.authority=e.authority,this.client_id=e.client_id,this.redirect_uri=e.redirect_uri,this.scope=e.scope,this.client_secret=e.client_secret,this.extraTokenParams=e.extraTokenParams,this.response_mode=e.response_mode,this.skipUserInfo=e.skipUserInfo}toStorageString(){return new GI("SigninState").create("toStorageString"),JSON.stringify({id:this.id,data:this.data,created:this.created,request_type:this.request_type,code_verifier:this.code_verifier,authority:this.authority,client_id:this.client_id,redirect_uri:this.redirect_uri,scope:this.scope,client_secret:this.client_secret,extraTokenParams:this.extraTokenParams,response_mode:this.response_mode,skipUserInfo:this.skipUserInfo})}static fromStorageString(e){GI.createStatic("SigninState","fromStorageString");const t=JSON.parse(e);return new oM(t)}},cM=class{constructor(e){this.access_token="",this.token_type="",this.profile={},this.state=e.get("state"),this.session_state=e.get("session_state"),this.error=e.get("error"),this.error_description=e.get("error_description"),this.error_uri=e.get("error_uri"),this.code=e.get("code")}get expires_in(){if(void 0!==this.expires_at)return this.expires_at-JI.getEpochTime()}set expires_in(e){"string"==typeof e&&(e=Number(e)),void 0!==e&&e>=0&&(this.expires_at=Math.floor(e)+JI.getEpochTime())}get isOpenId(){var e;return(null==(e=this.scope)?void 0:e.split(" ").includes("openid"))||!!this.id_token}},fM=["nbf","jti","auth_time","nonce","acr","amr","azp","at_hash"],uM=["sub","iss","aud","exp","iat"],dM=class{constructor(e){var t;this.id_token=e.id_token,this.session_state=null!=(t=e.session_state)?t:null,this.access_token=e.access_token,this.refresh_token=e.refresh_token,this.token_type=e.token_type,this.scope=e.scope,this.profile=e.profile,this.expires_at=e.expires_at,this.state=e.userState}get expires_in(){if(void 0!==this.expires_at)return this.expires_at-JI.getEpochTime()}set expires_in(e){void 0!==e&&(this.expires_at=Math.floor(e)+JI.getEpochTime())}get expired(){const e=this.expires_in;if(void 0!==e)return e<=0}get scopes(){var e,t;return null!=(t=null==(e=this.scope)?void 0:e.split(" "))?t:[]}toStorageString(){return new GI("User").create("toStorageString"),JSON.stringify({id_token:this.id_token,session_state:this.session_state,access_token:this.access_token,refresh_token:this.refresh_token,token_type:this.token_type,scope:this.scope,profile:this.profile,expires_at:this.expires_at})}static fromStorageString(e){return GI.createStatic("User","fromStorageString"),new dM(JSON.parse(e))}},lM="oidc-client",hM=class{constructor(){this._abort=new WI("Window navigation aborted"),this._disposeHandlers=new Set,this._window=null}async navigate(e){const t=this._logger.create("navigate");if(!this._window)throw new Error("Attempted to navigate on a disposed window");t.debug("setting URL in window"),this._window.location.replace(e.url);const{url:r,keepOpen:n}=await new Promise(((r,n)=>{const i=i=>{var a;const s=i.data,o=null!=(a=e.scriptOrigin)?a:window.location.origin;if(i.origin===o&&(null==s?void 0:s.source)===lM){try{const r=YI.readParams(s.url,e.response_mode).get("state");if(r||t.warn("no state found in response url"),i.source!==this._window&&r!==e.state)return}catch(e){this._dispose(),n(new Error("Invalid response from window"))}r(s)}};window.addEventListener("message",i,!1),this._disposeHandlers.add((()=>window.removeEventListener("message",i,!1))),this._disposeHandlers.add(this._abort.addHandler((e=>{this._dispose(),n(e)})))}));return t.debug("got response from window"),this._dispose(),n||this.close(),{url:r}}_dispose(){this._logger.create("_dispose");for(const e of this._disposeHandlers)e();this._disposeHandlers.clear()}static _notifyParent(e,t,r=!1,n=window.location.origin){e.postMessage({source:lM,url:t,keepOpen:r},n)}},pM={location:!1,toolbar:!1,height:640},bM="_blank",gM=60,mM=2,yM=10,vM=class extends iM{constructor(e){const{popup_redirect_uri:t=e.redirect_uri,popup_post_logout_redirect_uri:r=e.post_logout_redirect_uri,popupWindowFeatures:n=pM,popupWindowTarget:i=bM,redirectMethod:a="assign",redirectTarget:s="self",iframeNotifyParentOrigin:o=e.iframeNotifyParentOrigin,iframeScriptOrigin:c=e.iframeScriptOrigin,silent_redirect_uri:f=e.redirect_uri,silentRequestTimeoutInSeconds:u=yM,automaticSilentRenew:d=!0,validateSubOnSilentRenew:l=!0,includeIdTokenInSilentRenew:h=!1,monitorSession:p=!1,monitorAnonymousSession:b=!1,checkSessionIntervalInSeconds:g=mM,query_status_response_type:m="code",stopCheckSessionOnError:y=!0,revokeTokenTypes:v=["access_token","refresh_token"],revokeTokensOnSignout:w=!1,includeIdTokenInSilentSignout:_=!1,accessTokenExpiringNotificationTimeInSeconds:E=gM,userStore:A}=e;if(super(e),this.popup_redirect_uri=t,this.popup_post_logout_redirect_uri=r,this.popupWindowFeatures=n,this.popupWindowTarget=i,this.redirectMethod=a,this.redirectTarget=s,this.iframeNotifyParentOrigin=o,this.iframeScriptOrigin=c,this.silent_redirect_uri=f,this.silentRequestTimeoutInSeconds=u,this.automaticSilentRenew=d,this.validateSubOnSilentRenew=l,this.includeIdTokenInSilentRenew=h,this.monitorSession=p,this.monitorAnonymousSession=b,this.checkSessionIntervalInSeconds=g,this.stopCheckSessionOnError=y,this.query_status_response_type=m,this.revokeTokenTypes=v,this.revokeTokensOnSignout=w,this.includeIdTokenInSilentSignout=_,this.accessTokenExpiringNotificationTimeInSeconds=E,A)this.userStore=A;else{const e="undefined"!=typeof window?window.sessionStorage:new tM;this.userStore=new nM({store:e})}}},wM=class extends hM{constructor({silentRequestTimeoutInSeconds:e=yM}){super(),this._logger=new GI("IFrameWindow"),this._timeoutInSeconds=e,this._frame=wM.createHiddenIframe(),this._window=this._frame.contentWindow}static createHiddenIframe(){const e=window.document.createElement("iframe");return e.style.visibility="hidden",e.style.position="fixed",e.style.left="-1000px",e.style.top="0",e.width="0",e.height="0",e.setAttribute("sandbox","allow-scripts allow-same-origin allow-forms"),window.document.body.appendChild(e),e}async navigate(e){this._logger.debug("navigate: Using timeout of:",this._timeoutInSeconds);const t=setTimeout((()=>this._abort.raise(new ZI("IFrame timed out without a response"))),1e3*this._timeoutInSeconds);return this._disposeHandlers.add((()=>clearTimeout(t))),await super.navigate(e)}close(){var e;this._frame&&(this._frame.parentNode&&(this._frame.addEventListener("load",(e=>{var t;const r=e.target;null==(t=r.parentNode)||t.removeChild(r),this._abort.raise(new Error("IFrame removed from DOM"))}),!0),null==(e=this._frame.contentWindow)||e.location.replace("about:blank")),this._frame=null),this._window=null}static notifyParent(e,t){return super._notifyParent(window.parent,e,!1,t)}},_M=class extends hM{constructor({popupWindowTarget:e=bM,popupWindowFeatures:t={}}){super(),this._logger=new GI("PopupWindow");const r=$I.center({...pM,...t});this._window=window.open(void 0,e,$I.serialize(r))}async navigate(e){var t;null==(t=this._window)||t.focus();const r=setInterval((()=>{this._window&&!this._window.closed||this._abort.raise(new Error("Popup closed by user"))}),500);return this._disposeHandlers.add((()=>clearInterval(r))),await super.navigate(e)}close(){this._window&&(this._window.closed||(this._window.close(),this._abort.raise(new Error("Popup closed")))),this._window=null}static notifyOpener(e,t){if(!window.opener)throw new Error("No window.opener. Can't complete notification.");return super._notifyParent(window.opener,e,t)}},EM=class extends eM{constructor(e){super({expiringNotificationTimeInSeconds:e.accessTokenExpiringNotificationTimeInSeconds}),this._logger=new GI("UserManagerEvents"),this._userLoaded=new WI("User loaded"),this._userUnloaded=new WI("User unloaded"),this._silentRenewError=new WI("Silent renew error"),this._userSignedIn=new WI("User signed in"),this._userSignedOut=new WI("User signed out"),this._userSessionChanged=new WI("User session changed")}load(e,t=!0){super.load(e),t&&this._userLoaded.raise(e)}unload(){super.unload(),this._userUnloaded.raise()}addUserLoaded(e){return this._userLoaded.addHandler(e)}removeUserLoaded(e){return this._userLoaded.removeHandler(e)}addUserUnloaded(e){return this._userUnloaded.addHandler(e)}removeUserUnloaded(e){return this._userUnloaded.removeHandler(e)}addSilentRenewError(e){return this._silentRenewError.addHandler(e)}removeSilentRenewError(e){return this._silentRenewError.removeHandler(e)}_raiseSilentRenewError(e){this._silentRenewError.raise(e)}addUserSignedIn(e){return this._userSignedIn.addHandler(e)}removeUserSignedIn(e){this._userSignedIn.removeHandler(e)}_raiseUserSignedIn(){this._userSignedIn.raise()}addUserSignedOut(e){return this._userSignedOut.addHandler(e)}removeUserSignedOut(e){this._userSignedOut.removeHandler(e)}_raiseUserSignedOut(){this._userSignedOut.raise()}addUserSessionChanged(e){return this._userSessionChanged.addHandler(e)}removeUserSessionChanged(e){this._userSessionChanged.removeHandler(e)}_raiseUserSessionChanged(){this._userSessionChanged.raise()}},AM=(e=>(e.MissingApiKey="MISSING_API_KEY",e.ModalNotReady="MODAL_NOT_READY",e.MalformedResponse="MALFORMED_RESPONSE",e.InvalidArgument="INVALID_ARGUMENT",e.ExtensionNotInitialized="EXTENSION_NOT_INITIALIZED",e.IncompatibleExtensions="INCOMPATIBLE_EXTENSIONS",e))(AM||{}),SM=(e=>(e.SyncWeb3Method="SYNC_WEB3_METHOD",e.DuplicateIframe="DUPLICATE_IFRAME",e.ReactNativeEndpointConfiguration="REACT_NATIVE_ENDPOINT_CONFIGURATION",e.DeprecationNotice="DEPRECATION_NOTICE",e))(SM||{}),kM=(e=>(e[e.ParseError=-32700]="ParseError",e[e.InvalidRequest=-32600]="InvalidRequest",e[e.MethodNotFound=-32601]="MethodNotFound",e[e.InvalidParams=-32602]="InvalidParams",e[e.InternalError=-32603]="InternalError",e[e.MagicLinkFailedVerification=-1e4]="MagicLinkFailedVerification",e[e.MagicLinkExpired=-10001]="MagicLinkExpired",e[e.MagicLinkRateLimited=-10002]="MagicLinkRateLimited",e[e.MagicLinkInvalidRedirectURL=-10006]="MagicLinkInvalidRedirectURL",e[e.UserAlreadyLoggedIn=-10003]="UserAlreadyLoggedIn",e[e.UpdateEmailFailed=-10004]="UpdateEmailFailed",e[e.UserRequestEditEmail=-10005]="UserRequestEditEmail",e[e.InactiveRecipient=-10010]="InactiveRecipient",e[e.AccessDeniedToUser=-10011]="AccessDeniedToUser",e))(kM||{}),xM=(e=>(e.LoginWithSms="magic_auth_login_with_sms",e.LoginWithEmailOTP="magic_auth_login_with_email_otp",e.LoginWithMagicLink="magic_auth_login_with_magic_link",e.LoginWithCredential="magic_auth_login_with_credential",e.GetIdToken="magic_auth_get_id_token",e.GenerateIdToken="magic_auth_generate_id_token",e.GetMetadata="magic_auth_get_metadata",e.IsLoggedIn="magic_auth_is_logged_in",e.Logout="magic_auth_logout",e.UpdateEmail="magic_auth_update_email",e.UserSettings="magic_auth_settings",e.UserSettingsTestMode="magic_auth_settings_testing_mode",e.LoginWithSmsTestMode="magic_auth_login_with_sms_testing_mode",e.LoginWithEmailOTPTestMode="magic_auth_login_with_email_otp_testing_mode",e.LoginWithMagicLinkTestMode="magic_login_with_magic_link_testing_mode",e.LoginWithCredentialTestMode="magic_auth_login_with_credential_testing_mode",e.GetIdTokenTestMode="magic_auth_get_id_token_testing_mode",e.GenerateIdTokenTestMode="magic_auth_generate_id_token_testing_mode",e.GetMetadataTestMode="magic_auth_get_metadata_testing_mode",e.IsLoggedInTestMode="magic_auth_is_logged_in_testing_mode",e.LogoutTestMode="magic_auth_logout_testing_mode",e.UpdateEmailTestMode="magic_auth_update_email_testing_mode",e.IntermediaryEvent="magic_intermediary_event",e.RequestAccounts="eth_requestAccounts",e.GetInfo="mc_get_wallet_info",e.ShowUI="mc_wallet",e.NFTPurchase="magic_nft_purchase",e.RequestUserInfoWithUI="mc_request_user_info",e.Disconnect="mc_disconnect",e.UpdatePhoneNumber="magic_auth_update_phone_number",e.UpdatePhoneNumberTestMode="magic_auth_update_phone_number_testing_mode",e.RecoverAccount="magic_auth_recover_account",e.RecoverAccountTestMode="magic_auth_recover_account_testing_mode",e))(xM||{}),TM=(e=>(e.MAGIC_HANDLE_RESPONSE="MAGIC_HANDLE_RESPONSE",e.MAGIC_OVERLAY_READY="MAGIC_OVERLAY_READY",e.MAGIC_SHOW_OVERLAY="MAGIC_SHOW_OVERLAY",e.MAGIC_HIDE_OVERLAY="MAGIC_HIDE_OVERLAY",e.MAGIC_HANDLE_EVENT="MAGIC_HANDLE_EVENT",e))(TM||{}),RM=(e=>(e.MAGIC_HANDLE_REQUEST="MAGIC_HANDLE_REQUEST",e))(RM||{}),OM=(e=>(e.Harmony="HARMONY",e))(OM||{}),IM=Object.create,MM=Object.defineProperty,CM=Object.defineProperties,PM=Object.getOwnPropertyDescriptor,NM=Object.getOwnPropertyDescriptors,BM=Object.getOwnPropertyNames,UM=Object.getOwnPropertySymbols,LM=Object.getPrototypeOf,jM=Object.prototype.hasOwnProperty,DM=Object.prototype.propertyIsEnumerable,FM=(e,t,r)=>t in e?MM(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,qM=(e,t)=>{for(var r in t||(t={}))jM.call(t,r)&&FM(e,r,t[r]);if(UM)for(var r of UM(t))DM.call(t,r)&&FM(e,r,t[r]);return e},zM=(e,t,r)=>new Promise(((n,i)=>{var a=e=>{try{o(r.next(e))}catch(e){i(e)}},s=e=>{try{o(r.throw(e))}catch(e){i(e)}},o=e=>e.done?n(e.value):Promise.resolve(e.value).then(a,s);o((r=r.apply(e,t)).next())})),KM=((e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports))(((e,t)=>{var r=Object.prototype.hasOwnProperty,n="~";function i(){}function a(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function s(e,t,r,i,s){if("function"!=typeof r)throw new TypeError("The listener must be a function");var o=new a(r,i||e,s),c=n?n+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],o]:e._events[c].push(o):(e._events[c]=o,e._eventsCount++),e}function o(e,t){0==--e._eventsCount?e._events=new i:delete e._events[t]}function c(){this._events=new i,this._eventsCount=0}Object.create&&(i.prototype=Object.create(null),(new i).__proto__||(n=!1)),c.prototype.eventNames=function(){var e,t,i=[];if(0===this._eventsCount)return i;for(t in e=this._events)r.call(e,t)&&i.push(n?t.slice(1):t);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(e)):i},c.prototype.listeners=function(e){var t=n?n+e:e,r=this._events[t];if(!r)return[];if(r.fn)return[r.fn];for(var i=0,a=r.length,s=new Array(a);i<a;i++)s[i]=r[i].fn;return s},c.prototype.listenerCount=function(e){var t=n?n+e:e,r=this._events[t];return r?r.fn?1:r.length:0},c.prototype.emit=function(e,t,r,i,a,s){var o=n?n+e:e;if(!this._events[o])return!1;var c,f,u=this._events[o],d=arguments.length;if(u.fn){switch(u.once&&this.removeListener(e,u.fn,void 0,!0),d){case 1:return u.fn.call(u.context),!0;case 2:return u.fn.call(u.context,t),!0;case 3:return u.fn.call(u.context,t,r),!0;case 4:return u.fn.call(u.context,t,r,i),!0;case 5:return u.fn.call(u.context,t,r,i,a),!0;case 6:return u.fn.call(u.context,t,r,i,a,s),!0}for(f=1,c=new Array(d-1);f<d;f++)c[f-1]=arguments[f];u.fn.apply(u.context,c)}else{var l,h=u.length;for(f=0;f<h;f++)switch(u[f].once&&this.removeListener(e,u[f].fn,void 0,!0),d){case 1:u[f].fn.call(u[f].context);break;case 2:u[f].fn.call(u[f].context,t);break;case 3:u[f].fn.call(u[f].context,t,r);break;case 4:u[f].fn.call(u[f].context,t,r,i);break;default:if(!c)for(l=1,c=new Array(d-1);l<d;l++)c[l-1]=arguments[l];u[f].fn.apply(u[f].context,c)}}return!0},c.prototype.on=function(e,t,r){return s(this,e,t,r,!1)},c.prototype.once=function(e,t,r){return s(this,e,t,r,!0)},c.prototype.removeListener=function(e,t,r,i){var a=n?n+e:e;if(!this._events[a])return this;if(!t)return o(this,a),this;var s=this._events[a];if(s.fn)s.fn===t&&(!i||s.once)&&(!r||s.context===r)&&o(this,a);else{for(var c=0,f=[],u=s.length;c<u;c++)(s[c].fn!==t||i&&!s[c].once||r&&s[c].context!==r)&&f.push(s[c]);f.length?this._events[a]=1===f.length?f[0]:f:o(this,a)}return this},c.prototype.removeAllListeners=function(e){var t;return e?(t=n?n+e:e,this._events[t]&&o(this,t)):(this._events=new i,this._eventsCount=0),this},c.prototype.off=c.prototype.removeListener,c.prototype.addListener=c.prototype.on,c.prefixed=n,c.EventEmitter=c,typeof t<"u"&&(t.exports=c)}));var HM={SEMVER_SPEC_VERSION:"2.0.0",MAX_LENGTH:256,MAX_SAFE_INTEGER:Number.MAX_SAFE_INTEGER||9007199254740991,MAX_SAFE_COMPONENT_LENGTH:16},GM="object"==typeof process&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...e)=>console.error("SEMVER",...e):()=>{},VM=GM,WM=function(e){let t={exports:{}};return e(t,t.exports),t.exports}((function(e,t){let{MAX_SAFE_COMPONENT_LENGTH:r}=HM,n=(t=e.exports={}).re=[],i=t.src=[],a=t.t={},s=0,o=(e,t,r)=>{let o=s++;VM(o,t),a[e]=o,i[o]=t,n[o]=new RegExp(t,r?"g":void 0)};o("NUMERICIDENTIFIER","0|[1-9]\\d*"),o("NUMERICIDENTIFIERLOOSE","[0-9]+"),o("NONNUMERICIDENTIFIER","\\d*[a-zA-Z-][a-zA-Z0-9-]*"),o("MAINVERSION",`(${i[a.NUMERICIDENTIFIER]})\\.(${i[a.NUMERICIDENTIFIER]})\\.(${i[a.NUMERICIDENTIFIER]})`),o("MAINVERSIONLOOSE",`(${i[a.NUMERICIDENTIFIERLOOSE]})\\.(${i[a.NUMERICIDENTIFIERLOOSE]})\\.(${i[a.NUMERICIDENTIFIERLOOSE]})`),o("PRERELEASEIDENTIFIER",`(?:${i[a.NUMERICIDENTIFIER]}|${i[a.NONNUMERICIDENTIFIER]})`),o("PRERELEASEIDENTIFIERLOOSE",`(?:${i[a.NUMERICIDENTIFIERLOOSE]}|${i[a.NONNUMERICIDENTIFIER]})`),o("PRERELEASE",`(?:-(${i[a.PRERELEASEIDENTIFIER]}(?:\\.${i[a.PRERELEASEIDENTIFIER]})*))`),o("PRERELEASELOOSE",`(?:-?(${i[a.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${i[a.PRERELEASEIDENTIFIERLOOSE]})*))`),o("BUILDIDENTIFIER","[0-9A-Za-z-]+"),o("BUILD",`(?:\\+(${i[a.BUILDIDENTIFIER]}(?:\\.${i[a.BUILDIDENTIFIER]})*))`),o("FULLPLAIN",`v?${i[a.MAINVERSION]}${i[a.PRERELEASE]}?${i[a.BUILD]}?`),o("FULL",`^${i[a.FULLPLAIN]}$`),o("LOOSEPLAIN",`[v=\\s]*${i[a.MAINVERSIONLOOSE]}${i[a.PRERELEASELOOSE]}?${i[a.BUILD]}?`),o("LOOSE",`^${i[a.LOOSEPLAIN]}$`),o("GTLT","((?:<|>)?=?)"),o("XRANGEIDENTIFIERLOOSE",`${i[a.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),o("XRANGEIDENTIFIER",`${i[a.NUMERICIDENTIFIER]}|x|X|\\*`),o("XRANGEPLAIN",`[v=\\s]*(${i[a.XRANGEIDENTIFIER]})(?:\\.(${i[a.XRANGEIDENTIFIER]})(?:\\.(${i[a.XRANGEIDENTIFIER]})(?:${i[a.PRERELEASE]})?${i[a.BUILD]}?)?)?`),o("XRANGEPLAINLOOSE",`[v=\\s]*(${i[a.XRANGEIDENTIFIERLOOSE]})(?:\\.(${i[a.XRANGEIDENTIFIERLOOSE]})(?:\\.(${i[a.XRANGEIDENTIFIERLOOSE]})(?:${i[a.PRERELEASELOOSE]})?${i[a.BUILD]}?)?)?`),o("XRANGE",`^${i[a.GTLT]}\\s*${i[a.XRANGEPLAIN]}$`),o("XRANGELOOSE",`^${i[a.GTLT]}\\s*${i[a.XRANGEPLAINLOOSE]}$`),o("COERCE",`(^|[^\\d])(\\d{1,${r}})(?:\\.(\\d{1,${r}}))?(?:\\.(\\d{1,${r}}))?(?:$|[^\\d])`),o("COERCERTL",i[a.COERCE],!0),o("LONETILDE","(?:~>?)"),o("TILDETRIM",`(\\s*)${i[a.LONETILDE]}\\s+`,!0),t.tildeTrimReplace="$1~",o("TILDE",`^${i[a.LONETILDE]}${i[a.XRANGEPLAIN]}$`),o("TILDELOOSE",`^${i[a.LONETILDE]}${i[a.XRANGEPLAINLOOSE]}$`),o("LONECARET","(?:\\^)"),o("CARETTRIM",`(\\s*)${i[a.LONECARET]}\\s+`,!0),t.caretTrimReplace="$1^",o("CARET",`^${i[a.LONECARET]}${i[a.XRANGEPLAIN]}$`),o("CARETLOOSE",`^${i[a.LONECARET]}${i[a.XRANGEPLAINLOOSE]}$`),o("COMPARATORLOOSE",`^${i[a.GTLT]}\\s*(${i[a.LOOSEPLAIN]})$|^$`),o("COMPARATOR",`^${i[a.GTLT]}\\s*(${i[a.FULLPLAIN]})$|^$`),o("COMPARATORTRIM",`(\\s*)${i[a.GTLT]}\\s*(${i[a.LOOSEPLAIN]}|${i[a.XRANGEPLAIN]})`,!0),t.comparatorTrimReplace="$1$2$3",o("HYPHENRANGE",`^\\s*(${i[a.XRANGEPLAIN]})\\s+-\\s+(${i[a.XRANGEPLAIN]})\\s*$`),o("HYPHENRANGELOOSE",`^\\s*(${i[a.XRANGEPLAINLOOSE]})\\s+-\\s+(${i[a.XRANGEPLAINLOOSE]})\\s*$`),o("STAR","(<|>)?=?\\s*\\*"),o("GTE0","^\\s*>=\\s*0.0.0\\s*$"),o("GTE0PRE","^\\s*>=\\s*0.0.0-0\\s*$")})),XM=/^[0-9]+$/,$M=(e,t)=>{let r=XM.test(e),n=XM.test(t);return r&&n&&(e=+e,t=+t),e===t?0:r&&!n?-1:n&&!r?1:e<t?-1:1},JM={compareIdentifiers:$M,rcompareIdentifiers:(e,t)=>$M(t,e)},{MAX_LENGTH:YM,MAX_SAFE_INTEGER:QM}=HM,{re:ZM,t:eC}=WM,{compareIdentifiers:tC}=JM,rC=class{constructor(e,t){if(t&&"object"==typeof t||(t={loose:!!t,includePrerelease:!1}),e instanceof rC){if(e.loose===!!t.loose&&e.includePrerelease===!!t.includePrerelease)return e;e=e.version}else if("string"!=typeof e)throw new TypeError(`Invalid Version: ${e}`);if(e.length>YM)throw new TypeError(`version is longer than ${YM} characters`);VM("SemVer",e,t),this.options=t,this.loose=!!t.loose,this.includePrerelease=!!t.includePrerelease;let r=e.trim().match(t.loose?ZM[eC.LOOSE]:ZM[eC.FULL]);if(!r)throw new TypeError(`Invalid Version: ${e}`);if(this.raw=e,this.major=+r[1],this.minor=+r[2],this.patch=+r[3],this.major>QM||this.major<0)throw new TypeError("Invalid major version");if(this.minor>QM||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>QM||this.patch<0)throw new TypeError("Invalid patch version");r[4]?this.prerelease=r[4].split(".").map((e=>{if(/^[0-9]+$/.test(e)){let t=+e;if(t>=0&&t<QM)return t}return e})):this.prerelease=[],this.build=r[5]?r[5].split("."):[],this.format()}format(){return this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length&&(this.version+=`-${this.prerelease.join(".")}`),this.version}toString(){return this.version}compare(e){if(VM("SemVer.compare",this.version,this.options,e),!(e instanceof rC)){if("string"==typeof e&&e===this.version)return 0;e=new rC(e,this.options)}return e.version===this.version?0:this.compareMain(e)||this.comparePre(e)}compareMain(e){return e instanceof rC||(e=new rC(e,this.options)),tC(this.major,e.major)||tC(this.minor,e.minor)||tC(this.patch,e.patch)}comparePre(e){if(e instanceof rC||(e=new rC(e,this.options)),this.prerelease.length&&!e.prerelease.length)return-1;if(!this.prerelease.length&&e.prerelease.length)return 1;if(!this.prerelease.length&&!e.prerelease.length)return 0;let t=0;do{let r=this.prerelease[t],n=e.prerelease[t];if(VM("prerelease compare",t,r,n),void 0===r&&void 0===n)return 0;if(void 0===n)return 1;if(void 0===r)return-1;if(r!==n)return tC(r,n)}while(++t)}compareBuild(e){e instanceof rC||(e=new rC(e,this.options));let t=0;do{let r=this.build[t],n=e.build[t];if(VM("prerelease compare",t,r,n),void 0===r&&void 0===n)return 0;if(void 0===n)return 1;if(void 0===r)return-1;if(r!==n)return tC(r,n)}while(++t)}inc(e,t){switch(e){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",t);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",t);break;case"prepatch":this.prerelease.length=0,this.inc("patch",t),this.inc("pre",t);break;case"prerelease":0===this.prerelease.length&&this.inc("patch",t),this.inc("pre",t);break;case"major":0===this.minor&&0===this.patch&&0!==this.prerelease.length||this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case"minor":0===this.patch&&0!==this.prerelease.length||this.minor++,this.patch=0,this.prerelease=[];break;case"patch":0===this.prerelease.length&&this.patch++,this.prerelease=[];break;case"pre":if(0===this.prerelease.length)this.prerelease=[0];else{let e=this.prerelease.length;for(;--e>=0;)"number"==typeof this.prerelease[e]&&(this.prerelease[e]++,e=-2);-1===e&&this.prerelease.push(0)}t&&(this.prerelease[0]===t?isNaN(this.prerelease[1])&&(this.prerelease=[t,0]):this.prerelease=[t,0]);break;default:throw new Error(`invalid increment argument: ${e}`)}return this.format(),this.raw=this.version,this}},nC=(e,t,r)=>new rC(e,r).compare(new rC(t,r)),iC=(e,t,r)=>0===nC(e,t,r),aC=(e,t,r)=>0!==nC(e,t,r),sC=(e,t,r)=>nC(e,t,r)>0,oC=(e,t,r)=>nC(e,t,r)>=0,cC=(e,t,r)=>nC(e,t,r)<0,fC=(e,t,r)=>nC(e,t,r)<=0,uC=(e,t,r,n)=>{switch(t){case"===":return"object"==typeof e&&(e=e.version),"object"==typeof r&&(r=r.version),e===r;case"!==":return"object"==typeof e&&(e=e.version),"object"==typeof r&&(r=r.version),e!==r;case"":case"=":case"==":return iC(e,r,n);case"!=":return aC(e,r,n);case">":return sC(e,r,n);case">=":return oC(e,r,n);case"<":return cC(e,r,n);case"<=":return fC(e,r,n);default:throw new TypeError(`Invalid operator: ${t}`)}},dC=Symbol("SemVer ANY"),lC=class{static get ANY(){return dC}constructor(e,t){if(t&&"object"==typeof t||(t={loose:!!t,includePrerelease:!1}),e instanceof lC){if(e.loose===!!t.loose)return e;e=e.value}VM("comparator",e,t),this.options=t,this.loose=!!t.loose,this.parse(e),this.semver===dC?this.value="":this.value=this.operator+this.semver.version,VM("comp",this)}parse(e){let t=this.options.loose?hC[pC.COMPARATORLOOSE]:hC[pC.COMPARATOR],r=e.match(t);if(!r)throw new TypeError(`Invalid comparator: ${e}`);this.operator=void 0!==r[1]?r[1]:"","="===this.operator&&(this.operator=""),r[2]?this.semver=new rC(r[2],this.options.loose):this.semver=dC}toString(){return this.value}test(e){if(VM("Comparator.test",e,this.options.loose),this.semver===dC||e===dC)return!0;if("string"==typeof e)try{e=new rC(e,this.options)}catch(e){return!1}return uC(e,this.operator,this.semver,this.options)}intersects(e,t){if(!(e instanceof lC))throw new TypeError("a Comparator is required");if(t&&"object"==typeof t||(t={loose:!!t,includePrerelease:!1}),""===this.operator)return""===this.value||new bC(e.value,t).test(this.value);if(""===e.operator)return""===e.value||new bC(this.value,t).test(e.semver);let r=!(">="!==this.operator&&">"!==this.operator||">="!==e.operator&&">"!==e.operator),n=!("<="!==this.operator&&"<"!==this.operator||"<="!==e.operator&&"<"!==e.operator),i=this.semver.version===e.semver.version,a=!(">="!==this.operator&&"<="!==this.operator||">="!==e.operator&&"<="!==e.operator),s=uC(this.semver,"<",e.semver,t)&&(">="===this.operator||">"===this.operator)&&("<="===e.operator||"<"===e.operator),o=uC(this.semver,">",e.semver,t)&&("<="===this.operator||"<"===this.operator)&&(">="===e.operator||">"===e.operator);return r||n||i&&a||s||o}},{re:hC,t:pC}=WM,bC=class{constructor(e,t){if(t&&"object"==typeof t||(t={loose:!!t,includePrerelease:!1}),e instanceof bC)return e.loose===!!t.loose&&e.includePrerelease===!!t.includePrerelease?e:new bC(e.raw,t);if(e instanceof lC)return this.raw=e.value,this.set=[[e]],this.format(),this;if(this.options=t,this.loose=!!t.loose,this.includePrerelease=!!t.includePrerelease,this.raw=e,this.set=e.split(/\s*\|\|\s*/).map((e=>this.parseRange(e.trim()))).filter((e=>e.length)),!this.set.length)throw new TypeError(`Invalid SemVer Range: ${e}`);this.format()}format(){return this.range=this.set.map((e=>e.join(" ").trim())).join("||").trim(),this.range}toString(){return this.range}parseRange(e){let{loose:t}=this.options;e=e.trim();let r=t?gC[mC.HYPHENRANGELOOSE]:gC[mC.HYPHENRANGE];e=e.replace(r,CC(this.options.includePrerelease)),VM("hyphen replace",e),e=e.replace(gC[mC.COMPARATORTRIM],yC),VM("comparator trim",e,gC[mC.COMPARATORTRIM]),e=(e=(e=e.replace(gC[mC.TILDETRIM],vC)).replace(gC[mC.CARETTRIM],wC)).split(/\s+/).join(" ");let n=t?gC[mC.COMPARATORLOOSE]:gC[mC.COMPARATOR];return e.split(" ").map((e=>EC(e,this.options))).join(" ").split(/\s+/).map((e=>MC(e,this.options))).filter(this.options.loose?e=>!!e.match(n):()=>!0).map((e=>new lC(e,this.options)))}intersects(e,t){if(!(e instanceof bC))throw new TypeError("a Range is required");return this.set.some((r=>_C(r,t)&&e.set.some((e=>_C(e,t)&&r.every((r=>e.every((e=>r.intersects(e,t)))))))))}test(e){if(!e)return!1;if("string"==typeof e)try{e=new rC(e,this.options)}catch(e){return!1}for(let t=0;t<this.set.length;t++)if(PC(this.set[t],e,this.options))return!0;return!1}},{re:gC,t:mC,comparatorTrimReplace:yC,tildeTrimReplace:vC,caretTrimReplace:wC}=WM,_C=(e,t)=>{let r=!0,n=e.slice(),i=n.pop();for(;r&&n.length;)r=n.every((e=>i.intersects(e,t))),i=n.pop();return r},EC=(e,t)=>(VM("comp",e,t),e=xC(e,t),VM("caret",e),e=SC(e,t),VM("tildes",e),e=RC(e,t),VM("xrange",e),e=IC(e,t),VM("stars",e),e),AC=e=>!e||"x"===e.toLowerCase()||"*"===e,SC=(e,t)=>e.trim().split(/\s+/).map((e=>kC(e,t))).join(" "),kC=(e,t)=>{let r=t.loose?gC[mC.TILDELOOSE]:gC[mC.TILDE];return e.replace(r,((t,r,n,i,a)=>{let s;return VM("tilde",e,t,r,n,i,a),AC(r)?s="":AC(n)?s=`>=${r}.0.0 <${+r+1}.0.0-0`:AC(i)?s=`>=${r}.${n}.0 <${r}.${+n+1}.0-0`:a?(VM("replaceTilde pr",a),s=`>=${r}.${n}.${i}-${a} <${r}.${+n+1}.0-0`):s=`>=${r}.${n}.${i} <${r}.${+n+1}.0-0`,VM("tilde return",s),s}))},xC=(e,t)=>e.trim().split(/\s+/).map((e=>TC(e,t))).join(" "),TC=(e,t)=>{VM("caret",e,t);let r=t.loose?gC[mC.CARETLOOSE]:gC[mC.CARET],n=t.includePrerelease?"-0":"";return e.replace(r,((t,r,i,a,s)=>{let o;return VM("caret",e,t,r,i,a,s),AC(r)?o="":AC(i)?o=`>=${r}.0.0${n} <${+r+1}.0.0-0`:AC(a)?o="0"===r?`>=${r}.${i}.0${n} <${r}.${+i+1}.0-0`:`>=${r}.${i}.0${n} <${+r+1}.0.0-0`:s?(VM("replaceCaret pr",s),o="0"===r?"0"===i?`>=${r}.${i}.${a}-${s} <${r}.${i}.${+a+1}-0`:`>=${r}.${i}.${a}-${s} <${r}.${+i+1}.0-0`:`>=${r}.${i}.${a}-${s} <${+r+1}.0.0-0`):(VM("no pr"),o="0"===r?"0"===i?`>=${r}.${i}.${a}${n} <${r}.${i}.${+a+1}-0`:`>=${r}.${i}.${a}${n} <${r}.${+i+1}.0-0`:`>=${r}.${i}.${a} <${+r+1}.0.0-0`),VM("caret return",o),o}))},RC=(e,t)=>(VM("replaceXRanges",e,t),e.split(/\s+/).map((e=>OC(e,t))).join(" ")),OC=(e,t)=>{e=e.trim();let r=t.loose?gC[mC.XRANGELOOSE]:gC[mC.XRANGE];return e.replace(r,((r,n,i,a,s,o)=>{VM("xRange",e,r,n,i,a,s,o);let c=AC(i),f=c||AC(a),u=f||AC(s),d=u;return"="===n&&d&&(n=""),o=t.includePrerelease?"-0":"",c?r=">"===n||"<"===n?"<0.0.0-0":"*":n&&d?(f&&(a=0),s=0,">"===n?(n=">=",f?(i=+i+1,a=0,s=0):(a=+a+1,s=0)):"<="===n&&(n="<",f?i=+i+1:a=+a+1),"<"===n&&(o="-0"),r=`${n+i}.${a}.${s}${o}`):f?r=`>=${i}.0.0${o} <${+i+1}.0.0-0`:u&&(r=`>=${i}.${a}.0${o} <${i}.${+a+1}.0-0`),VM("xRange return",r),r}))},IC=(e,t)=>(VM("replaceStars",e,t),e.trim().replace(gC[mC.STAR],"")),MC=(e,t)=>(VM("replaceGTE0",e,t),e.trim().replace(gC[t.includePrerelease?mC.GTE0PRE:mC.GTE0],"")),CC=e=>(t,r,n,i,a,s,o,c,f,u,d,l,h)=>`${r=AC(n)?"":AC(i)?`>=${n}.0.0${e?"-0":""}`:AC(a)?`>=${n}.${i}.0${e?"-0":""}`:s?`>=${r}`:`>=${r}${e?"-0":""}`} ${c=AC(f)?"":AC(u)?`<${+f+1}.0.0-0`:AC(d)?`<${f}.${+u+1}.0-0`:l?`<=${f}.${u}.${d}-${l}`:e?`<${f}.${u}.${+d+1}-0`:`<=${c}`}`.trim(),PC=(e,t,r)=>{for(let r=0;r<e.length;r++)if(!e[r].test(t))return!1;if(t.prerelease.length&&!r.includePrerelease){for(let r=0;r<e.length;r++)if(VM(e[r].semver),e[r].semver!==lC.ANY&&e[r].semver.prerelease.length>0){let n=e[r].semver;if(n.major===t.major&&n.minor===t.minor&&n.patch===t.patch)return!0}return!1}return!0},NC=(e,t,r)=>{try{t=new bC(t,r)}catch(e){return!1}return t.test(e)},{MAX_LENGTH:BC}=HM,{re:UC,t:LC}=WM,jC=(e,t)=>{if(t&&"object"==typeof t||(t={loose:!!t,includePrerelease:!1}),e instanceof rC)return e;if("string"!=typeof e||e.length>BC||!(t.loose?UC[LC.LOOSE]:UC[LC.FULL]).test(e))return null;try{return new rC(e,t)}catch(e){return null}},{re:DC,t:FC}=WM,qC=(e,t)=>{if(e instanceof rC)return e;if("number"==typeof e&&(e=String(e)),"string"!=typeof e)return null;let r=null;if((t=t||{}).rtl){let t;for(;(t=DC[FC.COERCERTL].exec(e))&&(!r||r.index+r[0].length!==e.length);)r&&t.index+t[0].length===r.index+r[0].length||(r=t),DC[FC.COERCERTL].lastIndex=t.index+t[1].length+t[2].length;DC[FC.COERCERTL].lastIndex=-1}else r=e.match(DC[FC.COERCE]);return null===r?null:jC(`${r[2]}.${r[3]||"0"}.${r[4]||"0"}`,t)};function zC(e){return String.fromCharCode(parseInt(e.slice(1),16))}function KC(e){return`%${`00${e.charCodeAt(0).toString(16)}`.slice(-2)}`}function HC(e){return function(e){return btoa(encodeURIComponent(e).replace(/%[0-9A-F]{2}/g,zC))}(JSON.stringify(e))}function GC(e){return JSON.parse(function(e){return decodeURIComponent(Array.from(atob(e),KC).join(""))}(e))}function VC(e){return void 0===e}function WC(e){return function(e){return null===e}(e)||VC(e)}function XC(e){if(!e)return!0;for(let t in e)if(Object.hasOwnProperty.call(e,t))return!1;return!0}var $C={};var JC={"magic-sdk":"magic-sdk","@magic-sdk/react-native":"magic-sdk-rn","@magic-sdk/react-native-bare":"magic-sdk-rn-bare","@magic-sdk/react-native-expo":"magic-sdk-rn-expo"},YC=class extends Error{constructor(e,t){super(`Magic SDK Error: [${e}] ${t}`),this.code=e,this.rawMessage=t,this.__proto__=Error,Object.setPrototypeOf(this,YC.prototype)}},QC=class extends Error{constructor(e){super(),this.__proto__=Error;let t=Number(null==e?void 0:e.code);this.rawMessage=(null==e?void 0:e.message)||"Internal error",this.code=function(e){return!WC(e)&&"number"==typeof e&&Object.values(kM).includes(e)}(t)?t:kM.InternalError,this.message=`Magic RPC Error: [${this.code}] ${this.rawMessage}`,this.data=(null==e?void 0:e.data)||void 0,Object.setPrototypeOf(this,QC.prototype)}},ZC=class{constructor(e,t){this.code=e,this.rawMessage=t,this.message=`Magic SDK Warning: [${e}] ${t}`}log(){console.warn(this.message)}},eP=class extends Error{constructor(e,t,r,n){super(`Magic Extension Error (${e.name}): [${t}] ${r}`),this.code=t,this.rawMessage=r,this.data=n,this.__proto__=Error,Object.setPrototypeOf(this,eP.prototype)}},tP=class{constructor(e,t,r){this.code=t,this.rawMessage=r,this.message=`Magic Extension Warning (${e.name}): [${t}] ${r}`}log(){console.warn(this.message)}};function rP(){return new YC(AM.MissingApiKey,"Please provide an API key that you acquired from the Magic developer dashboard.")}function nP(){return new YC(AM.MalformedResponse,"Response from the Magic iframe is malformed.")}function iP(e){return new YC(AM.ExtensionNotInitialized,`Extensions must be initialized with a Magic SDK instance before \`Extension.${e}\` can be accessed. Do not invoke \`Extension.${e}\` inside an extension constructor.`)}function aP(e){let t=`Some extensions are incompatible with \`${$C.sdkName}@${$C.version}\`:`;return e.filter((e=>void 0!==e.compat&&null!==e.compat)).forEach((e=>{let r=e.compat[$C.sdkName];"string"==typeof r?t+=`\n - Extension \`${e.name}\` supports version(s) \`${r}\``:r||(t+=`\n - Extension \`${e.name}\` does not support ${$C.platform} environments.`)})),new YC(AM.IncompatibleExtensions,t)}function sP(e){return new YC(AM.InvalidArgument,`Invalid ${(e=>{let t=e+1,r=t%10,n=t%100;return 1===r&&11!==n?`${t}st`:2===r&&12!==n?`${t}nd`:3===r&&13!==n?`${t}rd`:`${t}th`})(e.argument)} argument given to \`${e.procedure}\`.\n Expected: \`${e.expected}\`\n Received: \`${e.received}\``)}function oP(){return new ZC(SM.ReactNativeEndpointConfiguration,`CUSTOM DOMAINS ARE NOT SUPPORTED WHEN USING MAGIC SDK WITH REACT NATIVE! The \`endpoint\` parameter SHOULD NOT be provided. The Magic \`<iframe>\` is automatically wrapped by a WebView pointed at \`${$C.defaultEndpoint}\`. Changing this default behavior will lead to unexpected results and potentially security-threatening bugs.`)}var cP=function*(){let e=0;for(;;)e<Number.MAX_SAFE_INTEGER?yield++e:e=0}();function fP(){return cP.next().value}var uP=Symbol("Payload pre-processed by Magic SDK");function dP(e){return Object.defineProperty(e,uP,{value:!0,enumerable:!1}),e}function lP(e){var t,r,n;return function(e){return!!e[uP]}(e)||(e.jsonrpc=null!=(t=e.jsonrpc)?t:"2.0",e.id=fP(),e.method=null!=(r=e.method)?r:"noop",e.params=null!=(n=e.params)?n:[],dP(e)),e}function hP(e,t=[]){return dP({params:t,method:e,jsonrpc:"2.0",id:fP()})}var pP=class{constructor(e){e instanceof pP?(this._jsonrpc=e.payload.jsonrpc,this._id=e.payload.id,this._result=e.payload.result,this._error=e.payload.error):function(e){return!WC(e)&&!(VC(e.jsonrpc)||VC(e.id)||VC(e.result)&&VC(e.error))}(e)?(this._jsonrpc=e.jsonrpc,this._id=e.id,this._result=e.result,this._error=e.error):(this._jsonrpc=e.jsonrpc,this._id=e.id,this._result=void 0,this._error=void 0)}applyError(e){return this._error=e,this}applyResult(e){return this._result=e,this}get hasError(){return void 0!==this._error&&null!==this._error}get hasResult(){return void 0!==this._result}get payload(){return{jsonrpc:this._jsonrpc,id:this._id,result:this._result,error:this._error}}},bP=((e,t,r)=>(r=null!=e?IM(LM(e)):{},((e,t,r,n)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let i of BM(t))!jM.call(e,i)&&i!==r&&MM(e,i,{get:()=>t[i],enumerable:!(n=PM(t,i))||n.enumerable});return e})(!t&&e&&e.__esModule?r:MM(r,"default",{value:e,enumerable:!0}),e)))(KM()),gP=class extends bP.default{};function mP(){let e=new gP;return{emitter:e,createChainingEmitterMethod:(t,r)=>(...n)=>(e[t].apply(e,n),r),createBoundEmitterMethod:t=>(...r)=>e[t].apply(e,r)}}var yP=Symbol("isPromiEvent");function vP(e){return!!e[yP]}function wP(e){let t=_P(e),{createBoundEmitterMethod:r,createChainingEmitterMethod:n}=mP(),i=Symbol("Promise.then"),a=Symbol("Promise.catch"),s=Symbol("Promise.finally"),o=(e,t)=>(...r)=>{let n=t[e].apply(t,r);return c(n)},c=e=>Object.assign(e,{[yP]:!0,[i]:e[i]||e.then,[a]:e[a]||e.catch,[s]:e[s]||e.finally,then:o(i,e),catch:o(a,e),finally:o(s,e),on:n("on",e),once:n("once",e),addListener:n("addListener",e),off:n("off",e),removeListener:n("removeListener",e),removeAllListeners:n("removeAllListeners",e),emit:r("emit"),eventNames:r("eventNames"),listeners:r("listeners"),listenerCount:r("listenerCount")}),f=c(t.then((e=>(f.emit("done",e),f.emit("settled"),e)),(e=>{throw f.emit("error",e),f.emit("settled"),e})));return f}function _P(e){return new Promise(((t,r)=>{let n=e(t,r);Promise.resolve(n).catch(r)}))}var EP,AP=class{constructor(e){this.sdk=e}get overlay(){return this.sdk.overlay}request(e){let t=this.overlay.post(RM.MAGIC_HANDLE_REQUEST,lP(e)),r=wP(((e,r)=>{t.then((t=>{if(n(),t.hasError)r(new QC(t.payload.error));else{if(!t.hasResult)throw nP();e(t.payload.result)}})).catch((e=>{n(),r(e)}))})),n=this.overlay.on(TM.MAGIC_HANDLE_EVENT,(t=>{var n;let{response:i}=t.data;if(i.id===e.id&&(null==(n=i.result)?void 0:n.event)){let{event:e,params:t=[]}=i.result;r.emit(e,...t)}}));return r}createIntermediaryEvent(e,t){return r=>{let n=hP(xM.IntermediaryEvent,[{payloadId:t,eventType:e,args:r}]);this.request(n)}}},SP=class extends AP{loginWithMagicLink(e){let{email:t,showUI:r=!0,redirectURI:n}=e,i=hP(this.sdk.testMode?xM.LoginWithMagicLinkTestMode:xM.LoginWithMagicLink,[{email:t,showUI:r,redirectURI:n}]);return this.request(i)}loginWithSMS(e){let{phoneNumber:t}=e,r=hP(this.sdk.testMode?xM.LoginWithSmsTestMode:xM.LoginWithSms,[{phoneNumber:t,showUI:!0}]);return this.request(r)}loginWithEmailOTP(e){let{email:t,showUI:r}=e,n=hP(this.sdk.testMode?xM.LoginWithEmailOTPTestMode:xM.LoginWithEmailOTP,[{email:t,showUI:r}]);if(!r){let e=this.request(n);return e&&e.on("otp-input-sent",(e=>{this.createIntermediaryEvent("verify-email-otp",n.id)(e)})),e}return this.request(n)}loginWithCredential(e){let t=null!=e?e:"";if(!e&&"web"===$C.platform){t=window.location.search;let e=window.location.origin+window.location.pathname;window.history.replaceState(null,"",e)}let r=hP(this.sdk.testMode?xM.LoginWithCredentialTestMode:xM.LoginWithCredential,[t]);return this.request(r)}},kP={};function xP(e){return(...t)=>zM(this,null,(function*(){return EP||(EP=yield $C.configureStorage()),yield EP.ready(),EP[e](...t)}))}((e,t)=>{for(var r in t)MM(e,r,{get:t[r],enumerable:!0})})(kP,{clear:()=>IP,getItem:()=>TP,iterate:()=>NP,key:()=>CP,keys:()=>PP,length:()=>MP,removeItem:()=>OP,setItem:()=>RP});var TP=xP("getItem"),RP=xP("setItem"),OP=xP("removeItem"),IP=xP("clear"),MP=xP("length"),CP=xP("key"),PP=xP("keys"),NP=xP("iterate");function BP(){let e=window.crypto.getRandomValues(new Uint8Array(16));e[6]=15&e[6]|64,e[8]=191&e[8]|128;let t="";return t+=e[0].toString(16),t+=e[1].toString(16),t+=e[2].toString(16),t+=e[3].toString(16),t+="-",t+=e[4].toString(16),t+=e[5].toString(16),t+="-",t+=e[6].toString(16),t+=e[7].toString(16),t+="-",t+=e[8].toString(16),t+=e[9].toString(16),t+="-",t+=e[10].toString(16),t+=e[11].toString(16),t+=e[12].toString(16),t+=e[13].toString(16),t+=e[14].toString(16),t+=e[15].toString(16),t}var UP="STORE_KEY_PRIVATE_KEY",LP="STORE_KEY_PUBLIC_JWK",jP="ECDSA",DP="P-256",FP={name:jP,namedCurve:DP},qP={name:jP,namedCurve:DP};function zP(){OP(LP),OP(UP)}function KP(){return zM(this,null,(function*(){let e=yield function(){return zM(this,null,(function*(){if(function(){let e="undefined"!=typeof window&&!!window.crypto,t=e&&!!window.crypto.subtle;return e&&t}())return(yield TP(LP))||(yield function(){return zM(this,null,(function*(){let e=null,{subtle:t}=window.crypto,r=yield t.generateKey(FP,!0,["sign"]),n=yield t.exportKey("jwk",r.privateKey);e=yield t.exportKey("jwk",r.publicKey);let i=yield t.importKey("jwk",n,qP,!1,["sign"]);yield RP(UP,i),yield RP(LP,e)}))}()),TP(LP);console.info("webcrypto is not supported")}))}();if(!e)return void console.info("unable to create public key or webcrypto is unsupported");let{subtle:t}=window.crypto,r=yield TP(UP);if(!r||!t)return void console.info("unable to find private key or webcrypto unsupported");let n={iat:Math.floor((new Date).getTime()/1e3),jti:BP()},i={typ:"dpop+jwt",alg:"ES256",jwk:e},a=HP(JSON.stringify(i)),s=HP(JSON.stringify(n)),o=function(e){return(new TextEncoder).encode(e)}(`${a}.${s}`),c={name:jP,hash:{name:"SHA-256"}},f=function(e){let t="";return e.forEach((e=>{t+=String.fromCharCode(e)})),GP(t)}(new Uint8Array(yield t.sign(c,r,o)));return`${a}.${s}.${f}`}))}function HP(e){return GP(function(e){return encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,((e,t)=>String.fromCharCode(parseInt(t,16))))}(e))}function GP(e){return btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+/g,"")}var VP=class extends AP{getIdToken(e){let t=hP(this.sdk.testMode?xM.GetIdTokenTestMode:xM.GetIdToken,[e]);return this.request(t)}generateIdToken(e){let t=hP(this.sdk.testMode?xM.GenerateIdTokenTestMode:xM.GenerateIdToken,[e]);return this.request(t)}getMetadata(){let e=hP(this.sdk.testMode?xM.GetMetadataTestMode:xM.GetMetadata);return this.request(e)}updateEmail(e){let{email:t,showUI:r=!0}=e,n=hP(this.sdk.testMode?xM.UpdateEmailTestMode:xM.UpdateEmail,[{email:t,showUI:r}]);return this.request(n)}isLoggedIn(){let e=hP(this.sdk.testMode?xM.IsLoggedInTestMode:xM.IsLoggedIn);return this.request(e)}logout(){zP();let e=hP(this.sdk.testMode?xM.LogoutTestMode:xM.Logout);return this.request(e)}showSettings(){let e=hP(this.sdk.testMode?xM.UserSettingsTestMode:xM.UserSettings);return this.request(e)}updatePhoneNumber(){let e=hP(this.sdk.testMode?xM.UpdatePhoneNumberTestMode:xM.UpdatePhoneNumber);return this.request(e)}recoverAccount(e){let t=hP(this.sdk.testMode?xM.RecoverAccountTestMode:xM.RecoverAccount,[e]);return this.request(t)}},WP=class extends AP{connectWithUI(){let e=hP(xM.RequestAccounts);return this.request(e)}showUI(){let e=hP(xM.ShowUI);return this.request(e)}getInfo(){let e=hP(xM.GetInfo);return this.request(e)}requestUserInfoWithUI(e){let t=hP(xM.RequestUserInfoWithUI,e?[e]:[]);return this.request(t)}disconnect(){zP();let e=hP(xM.Disconnect);return this.request(e)}},{createBoundEmitterMethod:XP,createChainingEmitterMethod:$P}=mP(),JP=class extends AP{constructor(){super(...arguments),this.isMagic=!0,this.on=$P("on",this),this.once=$P("once",this),this.addListener=$P("addListener",this),this.off=$P("off",this),this.removeListener=$P("removeListener",this),this.removeAllListeners=$P("removeAllListeners",this),this.emit=XP("emit"),this.eventNames=XP("eventNames"),this.listeners=XP("listeners"),this.listenerCount=XP("listenerCount")}sendAsync(e,t){if(!t)throw sP({procedure:"Magic.rpcProvider.sendAsync",argument:1,expected:"function",received:null===t?"null":typeof t});if(Array.isArray(e))this.overlay.post(RM.MAGIC_HANDLE_REQUEST,e.map((e=>{let t=lP(e);return this.prefixPayloadMethodForTestMode(t),t}))).then((e=>{t(null,e.map((e=>((e,t)=>CM(e,NM(t)))(qM({},e.payload),{error:e.hasError?new QC(e.payload.error):null}))))}));else{let r=lP(e);this.prefixPayloadMethodForTestMode(r),this.overlay.post(RM.MAGIC_HANDLE_REQUEST,r).then((e=>{t(e.hasError?new QC(e.payload.error):null,e.payload)}))}}send(e,t){if("string"==typeof e){let r=hP(e,Array.isArray(t)?t:[]);return this.request(r)}if(Array.isArray(e)||t)return void this.sendAsync(e,t);let r=new ZC(SM.SyncWeb3Method,"Non-async web3 methods are deprecated in web3 > 1.0 and are not supported by the Magic web3 provider. Please use an async method instead.");return r.log(),new pP(e).applyError({code:-32603,message:r.rawMessage}).payload}enable(){let e=hP("eth_accounts");return this.request(e)}request(e){return this.prefixPayloadMethodForTestMode(e),super.request(e)}prefixPayloadMethodForTestMode(e){this.sdk.testMode&&(e.method=`testMode/eth/${e.method}`)}};function YP(e,t){return t?new URL(e,t):new URL(e)}var QP=["request","overlay","sdk"];function ZP(e){let t=Object.getPrototypeOf(e),r=[t];for(;t!==AP.prototype;)t=Object.getPrototypeOf(t),r.push(t);return r}var eN=class extends AP{constructor(){super(void 0),this.__sdk_access_field_descriptors__=new Map,this.__is_initialized__=!1,this.utils={createPromiEvent:wP,isPromiEvent:vP,encodeJSON:HC,decodeJSON:GC,createJsonRpcRequestPayload:hP,standardizeJsonRpcRequestPayload:lP,storage:kP};let e=[this,...ZP(this)];QP.forEach((t=>{let r=e.map((e=>Object.getOwnPropertyDescriptor(e,t))),n=r.findIndex((e=>!!e)),i=n>0,a=r[n];a&&(this.__sdk_access_field_descriptors__.set(t,{descriptor:a,isPrototypeField:i}),Object.defineProperty(this,t,{configurable:!0,get:()=>{throw iP(t)}}))}))}init(e){this.__is_initialized__||(QP.forEach((e=>{if(this.__sdk_access_field_descriptors__.has(e)){let{descriptor:t,isPrototypeField:r}=this.__sdk_access_field_descriptors__.get(e);r?delete this[e]:Object.defineProperty(this,e,t)}})),this.sdk=e,this.__is_initialized__=!0)}createDeprecationWarning(e){let{method:t,removalVersion:r,useInstead:n}=e;return new tP(this,"DEPRECATION_NOTICE",`\`${t}\` will be removed from this Extension in version \`${r}\`.${n?` Use \`${n}\` instead.`:""}`)}createWarning(e,t){return new tP(this,e,t)}createError(e,t,r){return new eP(this,e,t,r)}},tN=class extends eN{};tN.Internal=class extends eN{},tN.Anonymous="anonymous extension";var rN=class extends AP{purchase(e){let t=hP(xM.NFTPurchase,[e]);return this.request(t)}};function nN(e){return!e.compat||null==e.compat[$C.sdkName]||("string"==typeof e.compat[$C.sdkName]?NC(qC($C.version),e.compat[$C.sdkName]):!!e.compat[$C.sdkName])}function iN(e){var t;let r=null!=(t=null==e?void 0:e.extensions)?t:[],n={},i=[];if(Array.isArray(r)?r.forEach((e=>{nN(e)?(e.init(this),(e.name||e.name!==tN.Anonymous)&&(this[e.name]=e),e instanceof tN.Internal&&(XC(e.config)||(n[e.name]=e.config))):i.push(e)})):Object.keys(r).forEach((e=>{if(nN(r[e])){r[e].init(this);let t=r[e];this[e]=t,t instanceof tN.Internal&&(XC(t.config)||(n[r[e].name]=t.config))}else i.push(r[e])})),i.length)throw aP(i);return n}var aN=class{constructor(e,t){var r;if(this.apiKey=e,!e)throw rP();"react-native"===$C.platform&&(null==t?void 0:t.endpoint)&&oP().log();let{defaultEndpoint:n,version:i}=$C;this.testMode=!(null==t||!t.testMode),this.endpoint=YP(null!=(r=null==t?void 0:t.endpoint)?r:n).origin,this.auth=new SP(this),this.user=new VP(this),this.wallet=new WP(this),this.nft=new rN(this),this.rpcProvider=new JP(this);let a=iN.call(this,t);this.parameters=HC(qM({API_KEY:this.apiKey,DOMAIN_ORIGIN:window.location?window.location.origin:"",ETH_NETWORK:null==t?void 0:t.network,host:YP(this.endpoint).host,sdk:JC[$C.sdkName],version:i,ext:XC(a)?void 0:a,locale:(null==t?void 0:t.locale)||"en_US"},$C.bundleId?{bundleId:$C.bundleId}:{}))}get overlay(){if(!aN.__overlays__.has(this.parameters)){let e=new $C.ViewController(this.endpoint,this.parameters);e.init(),aN.__overlays__.set(this.parameters,e)}return aN.__overlays__.get(this.parameters)}preload(){return zM(this,null,(function*(){yield this.overlay.ready}))}},sN=aN;function oN(e,t){var r;let n=null==(r=t.data.response)?void 0:r.id,i=function(e,t){return t&&Array.isArray(e)?e.find((e=>e.id===t)):e}(e,n);if(n&&i){return{id:n,response:new pP(i).applyResult(t.data.response.result).applyError(t.data.response.error)}}return{}}sN.__overlays__=new Map;var cN=class{constructor(e,t){this.endpoint=e,this.parameters=t,this.messageHandlers=new Set,this.ready=this.waitForReady(),this.listen()}post(e,t){return zM(this,null,(function*(){return _P((r=>zM(this,null,(function*(){yield this.ready;let n=[],i=Array.isArray(t)?t.map((e=>e.id)):[],a=yield function(e,t){return zM(this,null,(function*(){let r,n=yield TP("rt");if("web"===$C.platform)try{r=yield KP()}catch(e){console.error("webcrypto error",e)}return r?n?{msgType:e,payload:t,jwt:r,rt:n}:{msgType:e,payload:t,jwt:r}:{msgType:e,payload:t}}))}(`${e}-${this.parameters}`,t);yield this._post(a);let s=this.on(TM.MAGIC_HANDLE_RESPONSE,(e=>a=>{let{id:s,response:o}=oN(t,a);(function(e){zM(this,null,(function*(){!e.data.rt||(yield RP("rt",e.data.rt))}))})(a),s&&o&&Array.isArray(t)&&i.includes(s)?(n.push(o),n.length===t.length&&(e(),r(n))):s&&o&&!Array.isArray(t)&&s===t.id&&(e(),r(o))})((()=>s())))}))))}))}on(e,t){let r=t.bind(window),n=t=>{t.data.msgType===`${e}-${this.parameters}`&&r(t)};return this.messageHandlers.add(n),()=>this.messageHandlers.delete(n)}waitForReady(){return new Promise((e=>{this.on(TM.MAGIC_OVERLAY_READY,(()=>e()))}))}listen(){this.on(TM.MAGIC_HIDE_OVERLAY,(()=>{this.hideOverlay()})),this.on(TM.MAGIC_SHOW_OVERLAY,(()=>{this.showOverlay()}))}},fN=Object.create,uN=Object.defineProperty,dN=Object.getOwnPropertyDescriptor,lN=Object.getOwnPropertyNames,hN=Object.getPrototypeOf,pN=Object.prototype.hasOwnProperty,bN=(e=>"undefined"!=typeof require?require:"undefined"!=typeof Proxy?new Proxy(e,{get:(e,t)=>("undefined"!=typeof require?require:e)[t]}):e)((function(e){if("undefined"!=typeof require)return require.apply(this,arguments);throw new Error('Dynamic require of "'+e+'" is not supported')})),gN=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),mN=(e,t,r)=>(r=null!=e?fN(hN(e)):{},((e,t,r,n)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let i of lN(t))!pN.call(e,i)&&i!==r&&uN(e,i,{get:()=>t[i],enumerable:!(n=dN(t,i))||n.enumerable});return e})(!t&&e&&e.__esModule?r:uN(r,"default",{value:e,enumerable:!0}),e)),yN=(e,t,r)=>new Promise(((n,i)=>{var a=e=>{try{o(r.next(e))}catch(e){i(e)}},s=e=>{try{o(r.throw(e))}catch(e){i(e)}},o=e=>e.done?n(e.value):Promise.resolve(e.value).then(a,s);o((r=r.apply(e,t)).next())})),vN=gN(((e,t)=>{!function(r){if("object"==typeof e&&typeof t<"u")t.exports=r();else if("function"==typeof define&&define.amd)define([],r);else{(typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:this).localforage=r()}}((function(){return function e(t,r,n){function i(s,o){if(!r[s]){if(!t[s]){var c="function"==typeof bN&&bN;if(!o&&c)return c(s,!0);if(a)return a(s,!0);var f=new Error("Cannot find module '"+s+"'");throw f.code="MODULE_NOT_FOUND",f}var u=r[s]={exports:{}};t[s][0].call(u.exports,(function(e){return i(t[s][1][e]||e)}),u,u.exports,e,t,r,n)}return r[s].exports}for(var a="function"==typeof bN&&bN,s=0;s<n.length;s++)i(n[s]);return i}({1:[function(e,t,r){(function(e){var r,n=e.MutationObserver||e.WebKitMutationObserver;if(n){var i=0,a=new n(u),s=e.document.createTextNode("");a.observe(s,{characterData:!0}),r=function(){s.data=i=++i%2}}else if(!e.setImmediate&&typeof e.MessageChannel<"u"){var o=new e.MessageChannel;o.port1.onmessage=u,r=function(){o.port2.postMessage(0)}}else r="document"in e&&"onreadystatechange"in e.document.createElement("script")?function(){var t=e.document.createElement("script");t.onreadystatechange=function(){u(),t.onreadystatechange=null,t.parentNode.removeChild(t),t=null},e.document.documentElement.appendChild(t)}:function(){setTimeout(u,0)};var c,f=[];function u(){c=!0;for(var e,t,r=f.length;r;){for(t=f,f=[],e=-1;++e<r;)t[e]();r=f.length}c=!1}t.exports=function(e){1===f.push(e)&&!c&&r()}}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{}],2:[function(e,t,r){var n=e(1);function i(){}var a={},s=["REJECTED"],o=["FULFILLED"],c=["PENDING"];function f(e){if("function"!=typeof e)throw new TypeError("resolver must be a function");this.state=c,this.queue=[],this.outcome=void 0,e!==i&&h(this,e)}function u(e,t,r){this.promise=e,"function"==typeof t&&(this.onFulfilled=t,this.callFulfilled=this.otherCallFulfilled),"function"==typeof r&&(this.onRejected=r,this.callRejected=this.otherCallRejected)}function d(e,t,r){n((function(){var n;try{n=t(r)}catch(t){return a.reject(e,t)}n===e?a.reject(e,new TypeError("Cannot resolve promise with itself")):a.resolve(e,n)}))}function l(e){var t=e&&e.then;if(e&&("object"==typeof e||"function"==typeof e)&&"function"==typeof t)return function(){t.apply(e,arguments)}}function h(e,t){var r=!1;function n(t){r||(r=!0,a.reject(e,t))}function i(t){r||(r=!0,a.resolve(e,t))}var s=p((function(){t(i,n)}));"error"===s.status&&n(s.value)}function p(e,t){var r={};try{r.value=e(t),r.status="success"}catch(e){r.status="error",r.value=e}return r}t.exports=f,f.prototype.catch=function(e){return this.then(null,e)},f.prototype.then=function(e,t){if("function"!=typeof e&&this.state===o||"function"!=typeof t&&this.state===s)return this;var r=new this.constructor(i);this.state!==c?d(r,this.state===o?e:t,this.outcome):this.queue.push(new u(r,e,t));return r},u.prototype.callFulfilled=function(e){a.resolve(this.promise,e)},u.prototype.otherCallFulfilled=function(e){d(this.promise,this.onFulfilled,e)},u.prototype.callRejected=function(e){a.reject(this.promise,e)},u.prototype.otherCallRejected=function(e){d(this.promise,this.onRejected,e)},a.resolve=function(e,t){var r=p(l,t);if("error"===r.status)return a.reject(e,r.value);var n=r.value;if(n)h(e,n);else{e.state=o,e.outcome=t;for(var i=-1,s=e.queue.length;++i<s;)e.queue[i].callFulfilled(t)}return e},a.reject=function(e,t){e.state=s,e.outcome=t;for(var r=-1,n=e.queue.length;++r<n;)e.queue[r].callRejected(t);return e},f.resolve=function(e){return e instanceof this?e:a.resolve(new this(i),e)},f.reject=function(e){var t=new this(i);return a.reject(t,e)},f.all=function(e){var t=this;if("[object Array]"!==Object.prototype.toString.call(e))return this.reject(new TypeError("must be an array"));var r=e.length,n=!1;if(!r)return this.resolve([]);for(var s=new Array(r),o=0,c=-1,f=new this(i);++c<r;)u(e[c],c);return f;function u(e,i){t.resolve(e).then((function(e){s[i]=e,++o===r&&!n&&(n=!0,a.resolve(f,s))}),(function(e){n||(n=!0,a.reject(f,e))}))}},f.race=function(e){var t=this;if("[object Array]"!==Object.prototype.toString.call(e))return this.reject(new TypeError("must be an array"));var r=e.length,n=!1;if(!r)return this.resolve([]);for(var s=-1,o=new this(i);++s<r;)c(e[s]);return o;function c(e){t.resolve(e).then((function(e){n||(n=!0,a.resolve(o,e))}),(function(e){n||(n=!0,a.reject(o,e))}))}}},{1:1}],3:[function(e,t,r){(function(t){"function"!=typeof t.Promise&&(t.Promise=e(2))}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{2:2}],4:[function(e,t,r){var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};var i=function(){try{if(typeof indexedDB<"u")return indexedDB;if(typeof webkitIndexedDB<"u")return webkitIndexedDB;if(typeof mozIndexedDB<"u")return mozIndexedDB;if(typeof OIndexedDB<"u")return OIndexedDB;if(typeof msIndexedDB<"u")return msIndexedDB}catch{return}}();function a(e,t){e=e||[],t=t||{};try{return new Blob(e,t)}catch(i){if("TypeError"!==i.name)throw i;for(var r=new(typeof BlobBuilder<"u"?BlobBuilder:typeof MSBlobBuilder<"u"?MSBlobBuilder:typeof MozBlobBuilder<"u"?MozBlobBuilder:WebKitBlobBuilder),n=0;n<e.length;n+=1)r.append(e[n]);return r.getBlob(t.type)}}typeof Promise>"u"&&e(3);var s=Promise;function o(e,t){t&&e.then((function(e){t(null,e)}),(function(e){t(e)}))}function c(e,t,r){"function"==typeof t&&e.then(t),"function"==typeof r&&e.catch(r)}function f(e){return"string"!=typeof e&&(console.warn(e+" used as a key, but it is not a string."),e=String(e)),e}function u(){if(arguments.length&&"function"==typeof arguments[arguments.length-1])return arguments[arguments.length-1]}var d="local-forage-detect-blob-support",l=void 0,h={},p=Object.prototype.toString,b="readonly",g="readwrite";function m(e){return"boolean"==typeof l?s.resolve(l):function(e){return new s((function(t){var r=e.transaction(d,g),n=a([""]);r.objectStore(d).put(n,"key"),r.onabort=function(e){e.preventDefault(),e.stopPropagation(),t(!1)},r.oncomplete=function(){var e=navigator.userAgent.match(/Chrome\/(\d+)/),r=navigator.userAgent.match(/Edge\//);t(r||!e||parseInt(e[1],10)>=43)}})).catch((function(){return!1}))}(e).then((function(e){return l=e}))}function y(e){var t=h[e.name],r={};r.promise=new s((function(e,t){r.resolve=e,r.reject=t})),t.deferredOperations.push(r),t.dbReady?t.dbReady=t.dbReady.then((function(){return r.promise})):t.dbReady=r.promise}function v(e){var t=h[e.name].deferredOperations.pop();if(t)return t.resolve(),t.promise}function w(e,t){var r=h[e.name].deferredOperations.pop();if(r)return r.reject(t),r.promise}function _(e,t){return new s((function(r,n){if(h[e.name]=h[e.name]||{forages:[],db:null,dbReady:null,deferredOperations:[]},e.db){if(!t)return r(e.db);y(e),e.db.close()}var a=[e.name];t&&a.push(e.version);var s=i.open.apply(i,a);t&&(s.onupgradeneeded=function(t){var r=s.result;try{r.createObjectStore(e.storeName),t.oldVersion<=1&&r.createObjectStore(d)}catch(r){if("ConstraintError"!==r.name)throw r;console.warn('The database "'+e.name+'" has been upgraded from version '+t.oldVersion+" to version "+t.newVersion+', but the storage "'+e.storeName+'" already exists.')}}),s.onerror=function(e){e.preventDefault(),n(s.error)},s.onsuccess=function(){var t=s.result;t.onversionchange=function(e){e.target.close()},r(t),v(e)}}))}function E(e){return _(e,!1)}function A(e){return _(e,!0)}function S(e,t){if(!e.db)return!0;var r=!e.db.objectStoreNames.contains(e.storeName),n=e.version<e.db.version,i=e.version>e.db.version;if(n&&(e.version!==t&&console.warn('The database "'+e.name+"\" can't be downgraded from version "+e.db.version+" to version "+e.version+"."),e.version=e.db.version),i||r){if(r){var a=e.db.version+1;a>e.version&&(e.version=a)}return!0}return!1}function k(e){var t=function(e){for(var t=e.length,r=new ArrayBuffer(t),n=new Uint8Array(r),i=0;i<t;i++)n[i]=e.charCodeAt(i);return r}(atob(e.data));return a([t],{type:e.type})}function x(e){return e&&e.__local_forage_encoded_blob}function T(e){var t=this,r=t._initReady().then((function(){var e=h[t._dbInfo.name];if(e&&e.dbReady)return e.dbReady}));return c(r,e,e),r}function R(e,t,r,n){void 0===n&&(n=1);try{var i=e.db.transaction(e.storeName,t);r(null,i)}catch(i){if(n>0&&(!e.db||"InvalidStateError"===i.name||"NotFoundError"===i.name))return s.resolve().then((function(){if(!e.db||"NotFoundError"===i.name&&!e.db.objectStoreNames.contains(e.storeName)&&e.version<=e.db.version)return e.db&&(e.version=e.db.version+1),A(e)})).then((function(){return function(e){y(e);for(var t=h[e.name],r=t.forages,n=0;n<r.length;n++){var i=r[n];i._dbInfo.db&&(i._dbInfo.db.close(),i._dbInfo.db=null)}return e.db=null,E(e).then((function(t){return e.db=t,S(e)?A(e):t})).then((function(n){e.db=t.db=n;for(var i=0;i<r.length;i++)r[i]._dbInfo.db=n})).catch((function(t){throw w(e,t),t}))}(e).then((function(){R(e,t,r,n-1)}))})).catch(r);r(i)}}var O={_driver:"asyncStorage",_initStorage:function(e){var t=this,r={db:null};if(e)for(var n in e)r[n]=e[n];var i=h[r.name];i||(i={forages:[],db:null,dbReady:null,deferredOperations:[]},h[r.name]=i),i.forages.push(t),t._initReady||(t._initReady=t.ready,t.ready=T);var a=[];function o(){return s.resolve()}for(var c=0;c<i.forages.length;c++){var f=i.forages[c];f!==t&&a.push(f._initReady().catch(o))}var u=i.forages.slice(0);return s.all(a).then((function(){return r.db=i.db,E(r)})).then((function(e){return r.db=e,S(r,t._defaultConfig.version)?A(r):e})).then((function(e){r.db=i.db=e,t._dbInfo=r;for(var n=0;n<u.length;n++){var a=u[n];a!==t&&(a._dbInfo.db=r.db,a._dbInfo.version=r.version)}}))},_support:function(){try{if(!i||!i.open)return!1;var e=typeof openDatabase<"u"&&/(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)&&!/BlackBerry/.test(navigator.platform),t="function"==typeof fetch&&-1!==fetch.toString().indexOf("[native code");return(!e||t)&&typeof indexedDB<"u"&&typeof IDBKeyRange<"u"}catch{return!1}}(),iterate:function(e,t){var r=this,n=new s((function(t,n){r.ready().then((function(){R(r._dbInfo,b,(function(i,a){if(i)return n(i);try{var s=a.objectStore(r._dbInfo.storeName).openCursor(),o=1;s.onsuccess=function(){var r=s.result;if(r){var n=r.value;x(n)&&(n=k(n));var i=e(n,r.key,o++);void 0!==i?t(i):r.continue()}else t()},s.onerror=function(){n(s.error)}}catch(e){n(e)}}))})).catch(n)}));return o(n,t),n},getItem:function(e,t){var r=this;e=f(e);var n=new s((function(t,n){r.ready().then((function(){R(r._dbInfo,b,(function(i,a){if(i)return n(i);try{var s=a.objectStore(r._dbInfo.storeName).get(e);s.onsuccess=function(){var e=s.result;void 0===e&&(e=null),x(e)&&(e=k(e)),t(e)},s.onerror=function(){n(s.error)}}catch(e){n(e)}}))})).catch(n)}));return o(n,t),n},setItem:function(e,t,r){var n=this;e=f(e);var i=new s((function(r,i){var a;n.ready().then((function(){return a=n._dbInfo,"[object Blob]"===p.call(t)?m(a.db).then((function(e){return e?t:function(e){return new s((function(t,r){var n=new FileReader;n.onerror=r,n.onloadend=function(r){var n=btoa(r.target.result||"");t({__local_forage_encoded_blob:!0,data:n,type:e.type})},n.readAsBinaryString(e)}))}(t)})):t})).then((function(t){R(n._dbInfo,g,(function(a,s){if(a)return i(a);try{var o=s.objectStore(n._dbInfo.storeName);null===t&&(t=void 0);var c=o.put(t,e);s.oncomplete=function(){void 0===t&&(t=null),r(t)},s.onabort=s.onerror=function(){var e=c.error?c.error:c.transaction.error;i(e)}}catch(e){i(e)}}))})).catch(i)}));return o(i,r),i},removeItem:function(e,t){var r=this;e=f(e);var n=new s((function(t,n){r.ready().then((function(){R(r._dbInfo,g,(function(i,a){if(i)return n(i);try{var s=a.objectStore(r._dbInfo.storeName).delete(e);a.oncomplete=function(){t()},a.onerror=function(){n(s.error)},a.onabort=function(){var e=s.error?s.error:s.transaction.error;n(e)}}catch(e){n(e)}}))})).catch(n)}));return o(n,t),n},clear:function(e){var t=this,r=new s((function(e,r){t.ready().then((function(){R(t._dbInfo,g,(function(n,i){if(n)return r(n);try{var a=i.objectStore(t._dbInfo.storeName).clear();i.oncomplete=function(){e()},i.onabort=i.onerror=function(){var e=a.error?a.error:a.transaction.error;r(e)}}catch(e){r(e)}}))})).catch(r)}));return o(r,e),r},length:function(e){var t=this,r=new s((function(e,r){t.ready().then((function(){R(t._dbInfo,b,(function(n,i){if(n)return r(n);try{var a=i.objectStore(t._dbInfo.storeName).count();a.onsuccess=function(){e(a.result)},a.onerror=function(){r(a.error)}}catch(e){r(e)}}))})).catch(r)}));return o(r,e),r},key:function(e,t){var r=this,n=new s((function(t,n){e<0?t(null):r.ready().then((function(){R(r._dbInfo,b,(function(i,a){if(i)return n(i);try{var s=a.objectStore(r._dbInfo.storeName),o=!1,c=s.openKeyCursor();c.onsuccess=function(){var r=c.result;r?0===e||o?t(r.key):(o=!0,r.advance(e)):t(null)},c.onerror=function(){n(c.error)}}catch(e){n(e)}}))})).catch(n)}));return o(n,t),n},keys:function(e){var t=this,r=new s((function(e,r){t.ready().then((function(){R(t._dbInfo,b,(function(n,i){if(n)return r(n);try{var a=i.objectStore(t._dbInfo.storeName).openKeyCursor(),s=[];a.onsuccess=function(){var t=a.result;t?(s.push(t.key),t.continue()):e(s)},a.onerror=function(){r(a.error)}}catch(e){r(e)}}))})).catch(r)}));return o(r,e),r},dropInstance:function(e,t){t=u.apply(this,arguments);var r,n=this.config();if((e="function"!=typeof e&&e||{}).name||(e.name=e.name||n.name,e.storeName=e.storeName||n.storeName),e.name){var a=e.name===n.name&&this._dbInfo.db?s.resolve(this._dbInfo.db):E(e).then((function(t){var r=h[e.name],n=r.forages;r.db=t;for(var i=0;i<n.length;i++)n[i]._dbInfo.db=t;return t}));r=e.storeName?a.then((function(t){if(t.objectStoreNames.contains(e.storeName)){var r=t.version+1;y(e);var n=h[e.name],a=n.forages;t.close();for(var o=0;o<a.length;o++){var c=a[o];c._dbInfo.db=null,c._dbInfo.version=r}var f=new s((function(t,n){var a=i.open(e.name,r);a.onerror=function(e){a.result.close(),n(e)},a.onupgradeneeded=function(){a.result.deleteObjectStore(e.storeName)},a.onsuccess=function(){var e=a.result;e.close(),t(e)}}));return f.then((function(e){n.db=e;for(var t=0;t<a.length;t++){var r=a[t];r._dbInfo.db=e,v(r._dbInfo)}})).catch((function(t){throw(w(e,t)||s.resolve()).catch((function(){})),t}))}})):a.then((function(t){y(e);var r=h[e.name],n=r.forages;t.close();for(var a=0;a<n.length;a++){n[a]._dbInfo.db=null}var o=new s((function(t,r){var n=i.deleteDatabase(e.name);n.onerror=function(){var e=n.result;e&&e.close(),r(n.error)},n.onblocked=function(){console.warn('dropInstance blocked for database "'+e.name+'" until all open connections are closed')},n.onsuccess=function(){var e=n.result;e&&e.close(),t(e)}}));return o.then((function(e){r.db=e;for(var t=0;t<n.length;t++){v(n[t]._dbInfo)}})).catch((function(t){throw(w(e,t)||s.resolve()).catch((function(){})),t}))}))}else r=s.reject("Invalid arguments");return o(r,t),r}};var I="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",M=/^~~local_forage_type~([^~]+)~/,C="__lfsc__:",P="arbf",N="blob",B="si08",U="ui08",L="uic8",j="si16",D="si32",F="ur16",q="ui32",z="fl32",K="fl64",H=Object.prototype.toString;function G(e){var t,r,n,i,a,s=.75*e.length,o=e.length,c=0;"="===e[e.length-1]&&(s--,"="===e[e.length-2]&&s--);var f=new ArrayBuffer(s),u=new Uint8Array(f);for(t=0;t<o;t+=4)r=I.indexOf(e[t]),n=I.indexOf(e[t+1]),i=I.indexOf(e[t+2]),a=I.indexOf(e[t+3]),u[c++]=r<<2|n>>4,u[c++]=(15&n)<<4|i>>2,u[c++]=(3&i)<<6|63&a;return f}function V(e){var t,r=new Uint8Array(e),n="";for(t=0;t<r.length;t+=3)n+=I[r[t]>>2],n+=I[(3&r[t])<<4|r[t+1]>>4],n+=I[(15&r[t+1])<<2|r[t+2]>>6],n+=I[63&r[t+2]];return r.length%3==2?n=n.substring(0,n.length-1)+"=":r.length%3==1&&(n=n.substring(0,n.length-2)+"=="),n}var W={serialize:function(e,t){var r="";if(e&&(r=H.call(e)),e&&("[object ArrayBuffer]"===r||e.buffer&&"[object ArrayBuffer]"===H.call(e.buffer))){var n,i=C;e instanceof ArrayBuffer?(n=e,i+=P):(n=e.buffer,"[object Int8Array]"===r?i+=B:"[object Uint8Array]"===r?i+=U:"[object Uint8ClampedArray]"===r?i+=L:"[object Int16Array]"===r?i+=j:"[object Uint16Array]"===r?i+=F:"[object Int32Array]"===r?i+=D:"[object Uint32Array]"===r?i+=q:"[object Float32Array]"===r?i+=z:"[object Float64Array]"===r?i+=K:t(new Error("Failed to get type for BinaryArray"))),t(i+V(n))}else if("[object Blob]"===r){var a=new FileReader;a.onload=function(){var r="~~local_forage_type~"+e.type+"~"+V(this.result);t(C+N+r)},a.readAsArrayBuffer(e)}else try{t(JSON.stringify(e))}catch(r){console.error("Couldn't convert value into a JSON string: ",e),t(null,r)}},deserialize:function(e){if(e.substring(0,9)!==C)return JSON.parse(e);var t,r=e.substring(13),n=e.substring(9,13);if(n===N&&M.test(r)){var i=r.match(M);t=i[1],r=r.substring(i[0].length)}var s=G(r);switch(n){case P:return s;case N:return a([s],{type:t});case B:return new Int8Array(s);case U:return new Uint8Array(s);case L:return new Uint8ClampedArray(s);case j:return new Int16Array(s);case F:return new Uint16Array(s);case D:return new Int32Array(s);case q:return new Uint32Array(s);case z:return new Float32Array(s);case K:return new Float64Array(s);default:throw new Error("Unkown type: "+n)}},stringToBuffer:G,bufferToString:V};function X(e,t,r,n){e.executeSql("CREATE TABLE IF NOT EXISTS "+t.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],r,n)}function $(e,t,r,n,i,a){e.executeSql(r,n,i,(function(e,s){s.code===s.SYNTAX_ERR?e.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[t.storeName],(function(e,o){o.rows.length?a(e,s):X(e,t,(function(){e.executeSql(r,n,i,a)}),a)}),a):a(e,s)}),a)}function J(e,t,r,n){var i=this;e=f(e);var a=new s((function(a,s){i.ready().then((function(){void 0===t&&(t=null);var o=t,c=i._dbInfo;c.serializer.serialize(t,(function(t,f){f?s(f):c.db.transaction((function(r){$(r,c,"INSERT OR REPLACE INTO "+c.storeName+" (key, value) VALUES (?, ?)",[e,t],(function(){a(o)}),(function(e,t){s(t)}))}),(function(t){if(t.code===t.QUOTA_ERR){if(n>0)return void a(J.apply(i,[e,o,r,n-1]));s(t)}}))}))})).catch(s)}));return o(a,r),a}var Y={_driver:"webSQLStorage",_initStorage:function(e){var t=this,r={db:null};if(e)for(var n in e)r[n]="string"!=typeof e[n]?e[n].toString():e[n];var i=new s((function(e,n){try{r.db=openDatabase(r.name,String(r.version),r.description,r.size)}catch(e){return n(e)}r.db.transaction((function(i){X(i,r,(function(){t._dbInfo=r,e()}),(function(e,t){n(t)}))}),n)}));return r.serializer=W,i},_support:"function"==typeof openDatabase,iterate:function(e,t){var r=this,n=new s((function(t,n){r.ready().then((function(){var i=r._dbInfo;i.db.transaction((function(r){$(r,i,"SELECT * FROM "+i.storeName,[],(function(r,n){for(var a=n.rows,s=a.length,o=0;o<s;o++){var c=a.item(o),f=c.value;if(f&&(f=i.serializer.deserialize(f)),void 0!==(f=e(f,c.key,o+1)))return void t(f)}t()}),(function(e,t){n(t)}))}))})).catch(n)}));return o(n,t),n},getItem:function(e,t){var r=this;e=f(e);var n=new s((function(t,n){r.ready().then((function(){var i=r._dbInfo;i.db.transaction((function(r){$(r,i,"SELECT * FROM "+i.storeName+" WHERE key = ? LIMIT 1",[e],(function(e,r){var n=r.rows.length?r.rows.item(0).value:null;n&&(n=i.serializer.deserialize(n)),t(n)}),(function(e,t){n(t)}))}))})).catch(n)}));return o(n,t),n},setItem:function(e,t,r){return J.apply(this,[e,t,r,1])},removeItem:function(e,t){var r=this;e=f(e);var n=new s((function(t,n){r.ready().then((function(){var i=r._dbInfo;i.db.transaction((function(r){$(r,i,"DELETE FROM "+i.storeName+" WHERE key = ?",[e],(function(){t()}),(function(e,t){n(t)}))}))})).catch(n)}));return o(n,t),n},clear:function(e){var t=this,r=new s((function(e,r){t.ready().then((function(){var n=t._dbInfo;n.db.transaction((function(t){$(t,n,"DELETE FROM "+n.storeName,[],(function(){e()}),(function(e,t){r(t)}))}))})).catch(r)}));return o(r,e),r},length:function(e){var t=this,r=new s((function(e,r){t.ready().then((function(){var n=t._dbInfo;n.db.transaction((function(t){$(t,n,"SELECT COUNT(key) as c FROM "+n.storeName,[],(function(t,r){var n=r.rows.item(0).c;e(n)}),(function(e,t){r(t)}))}))})).catch(r)}));return o(r,e),r},key:function(e,t){var r=this,n=new s((function(t,n){r.ready().then((function(){var i=r._dbInfo;i.db.transaction((function(r){$(r,i,"SELECT key FROM "+i.storeName+" WHERE id = ? LIMIT 1",[e+1],(function(e,r){var n=r.rows.length?r.rows.item(0).key:null;t(n)}),(function(e,t){n(t)}))}))})).catch(n)}));return o(n,t),n},keys:function(e){var t=this,r=new s((function(e,r){t.ready().then((function(){var n=t._dbInfo;n.db.transaction((function(t){$(t,n,"SELECT key FROM "+n.storeName,[],(function(t,r){for(var n=[],i=0;i<r.rows.length;i++)n.push(r.rows.item(i).key);e(n)}),(function(e,t){r(t)}))}))})).catch(r)}));return o(r,e),r},dropInstance:function(e,t){t=u.apply(this,arguments);var r=this.config();(e="function"!=typeof e&&e||{}).name||(e.name=e.name||r.name,e.storeName=e.storeName||r.storeName);var n,i=this;return n=e.name?new s((function(t){var n;n=e.name===r.name?i._dbInfo.db:openDatabase(e.name,"","",0),e.storeName?t({db:n,storeNames:[e.storeName]}):t(function(e){return new s((function(t,r){e.transaction((function(n){n.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],(function(r,n){for(var i=[],a=0;a<n.rows.length;a++)i.push(n.rows.item(a).name);t({db:e,storeNames:i})}),(function(e,t){r(t)}))}),(function(e){r(e)}))}))}(n))})).then((function(e){return new s((function(t,r){e.db.transaction((function(n){function i(e){return new s((function(t,r){n.executeSql("DROP TABLE IF EXISTS "+e,[],(function(){t()}),(function(e,t){r(t)}))}))}for(var a=[],o=0,c=e.storeNames.length;o<c;o++)a.push(i(e.storeNames[o]));s.all(a).then((function(){t()})).catch((function(e){r(e)}))}),(function(e){r(e)}))}))})):s.reject("Invalid arguments"),o(n,t),n}};function Q(e,t){var r=e.name+"/";return e.storeName!==t.storeName&&(r+=e.storeName+"/"),r}function Z(){return!function(){var e="_localforage_support_test";try{return localStorage.setItem(e,!0),localStorage.removeItem(e),!1}catch{return!0}}()||localStorage.length>0}var ee={_driver:"localStorageWrapper",_initStorage:function(e){var t={};if(e)for(var r in e)t[r]=e[r];return t.keyPrefix=Q(e,this._defaultConfig),Z()?(this._dbInfo=t,t.serializer=W,s.resolve()):s.reject()},_support:function(){try{return typeof localStorage<"u"&&"setItem"in localStorage&&!!localStorage.setItem}catch{return!1}}(),iterate:function(e,t){var r=this,n=r.ready().then((function(){for(var t=r._dbInfo,n=t.keyPrefix,i=n.length,a=localStorage.length,s=1,o=0;o<a;o++){var c=localStorage.key(o);if(0===c.indexOf(n)){var f=localStorage.getItem(c);if(f&&(f=t.serializer.deserialize(f)),void 0!==(f=e(f,c.substring(i),s++)))return f}}}));return o(n,t),n},getItem:function(e,t){var r=this;e=f(e);var n=r.ready().then((function(){var t=r._dbInfo,n=localStorage.getItem(t.keyPrefix+e);return n&&(n=t.serializer.deserialize(n)),n}));return o(n,t),n},setItem:function(e,t,r){var n=this;e=f(e);var i=n.ready().then((function(){void 0===t&&(t=null);var r=t;return new s((function(i,a){var s=n._dbInfo;s.serializer.serialize(t,(function(t,n){if(n)a(n);else try{localStorage.setItem(s.keyPrefix+e,t),i(r)}catch(e){("QuotaExceededError"===e.name||"NS_ERROR_DOM_QUOTA_REACHED"===e.name)&&a(e),a(e)}}))}))}));return o(i,r),i},removeItem:function(e,t){var r=this;e=f(e);var n=r.ready().then((function(){var t=r._dbInfo;localStorage.removeItem(t.keyPrefix+e)}));return o(n,t),n},clear:function(e){var t=this,r=t.ready().then((function(){for(var e=t._dbInfo.keyPrefix,r=localStorage.length-1;r>=0;r--){var n=localStorage.key(r);0===n.indexOf(e)&&localStorage.removeItem(n)}}));return o(r,e),r},length:function(e){var t=this.keys().then((function(e){return e.length}));return o(t,e),t},key:function(e,t){var r=this,n=r.ready().then((function(){var t,n=r._dbInfo;try{t=localStorage.key(e)}catch{t=null}return t&&(t=t.substring(n.keyPrefix.length)),t}));return o(n,t),n},keys:function(e){var t=this,r=t.ready().then((function(){for(var e=t._dbInfo,r=localStorage.length,n=[],i=0;i<r;i++){var a=localStorage.key(i);0===a.indexOf(e.keyPrefix)&&n.push(a.substring(e.keyPrefix.length))}return n}));return o(r,e),r},dropInstance:function(e,t){if(t=u.apply(this,arguments),!(e="function"!=typeof e&&e||{}).name){var r=this.config();e.name=e.name||r.name,e.storeName=e.storeName||r.storeName}var n,i=this;return n=e.name?new s((function(t){e.storeName?t(Q(e,i._defaultConfig)):t(e.name+"/")})).then((function(e){for(var t=localStorage.length-1;t>=0;t--){var r=localStorage.key(t);0===r.indexOf(e)&&localStorage.removeItem(r)}})):s.reject("Invalid arguments"),o(n,t),n}},te=function(e,t){return e===t||"number"==typeof e&&"number"==typeof t&&isNaN(e)&&isNaN(t)},re=function(e,t){for(var r=e.length,n=0;n<r;){if(te(e[n],t))return!0;n++}return!1},ne=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)},ie={},ae={},se={INDEXEDDB:O,WEBSQL:Y,LOCALSTORAGE:ee},oe=[se.INDEXEDDB._driver,se.WEBSQL._driver,se.LOCALSTORAGE._driver],ce=["dropInstance"],fe=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(ce),ue={description:"",driver:oe.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1};function de(e,t){e[t]=function(){var r=arguments;return e.ready().then((function(){return e[t].apply(e,r)}))}}function le(){for(var e=1;e<arguments.length;e++){var t=arguments[e];if(t)for(var r in t)t.hasOwnProperty(r)&&(ne(t[r])?arguments[0][r]=t[r].slice():arguments[0][r]=t[r])}return arguments[0]}var he=function(){function e(t){for(var r in function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),se)if(se.hasOwnProperty(r)){var n=se[r],i=n._driver;this[r]=i,ie[i]||this.defineDriver(n)}this._defaultConfig=le({},ue),this._config=le({},this._defaultConfig,t),this._driverSet=null,this._initDriver=null,this._ready=!1,this._dbInfo=null,this._wrapLibraryMethodsWithReady(),this.setDriver(this._config.driver).catch((function(){}))}return e.prototype.config=function(e){if("object"===(typeof e>"u"?"undefined":n(e))){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(var t in e){if("storeName"===t&&(e[t]=e[t].replace(/\W/g,"_")),"version"===t&&"number"!=typeof e[t])return new Error("Database version must be a number.");this._config[t]=e[t]}return!("driver"in e)||!e.driver||this.setDriver(this._config.driver)}return"string"==typeof e?this._config[e]:this._config},e.prototype.defineDriver=function(e,t,r){var n=new s((function(t,r){try{var n=e._driver,i=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!e._driver)return void r(i);for(var a=fe.concat("_initStorage"),c=0,f=a.length;c<f;c++){var u=a[c];if((!re(ce,u)||e[u])&&"function"!=typeof e[u])return void r(i)}!function(){for(var t=function(e){return function(){var t=new Error("Method "+e+" is not implemented by the current driver"),r=s.reject(t);return o(r,arguments[arguments.length-1]),r}},r=0,n=ce.length;r<n;r++){var i=ce[r];e[i]||(e[i]=t(i))}}();var d=function(r){ie[n]&&console.info("Redefining LocalForage driver: "+n),ie[n]=e,ae[n]=r,t()};"_support"in e?e._support&&"function"==typeof e._support?e._support().then(d,r):d(!!e._support):d(!0)}catch(e){r(e)}}));return c(n,t,r),n},e.prototype.driver=function(){return this._driver||null},e.prototype.getDriver=function(e,t,r){var n=ie[e]?s.resolve(ie[e]):s.reject(new Error("Driver not found."));return c(n,t,r),n},e.prototype.getSerializer=function(e){var t=s.resolve(W);return c(t,e),t},e.prototype.ready=function(e){var t=this,r=t._driverSet.then((function(){return null===t._ready&&(t._ready=t._initDriver()),t._ready}));return c(r,e,e),r},e.prototype.setDriver=function(e,t,r){var n=this;ne(e)||(e=[e]);var i=this._getSupportedDrivers(e);function a(){n._config.driver=n.driver()}function o(e){return n._extend(e),a(),n._ready=n._initStorage(n._config),n._ready}var f=null!==this._driverSet?this._driverSet.catch((function(){return s.resolve()})):s.resolve();return this._driverSet=f.then((function(){var e=i[0];return n._dbInfo=null,n._ready=null,n.getDriver(e).then((function(e){n._driver=e._driver,a(),n._wrapLibraryMethodsWithReady(),n._initDriver=function(e){return function(){var t=0;return function r(){for(;t<e.length;){var i=e[t];return t++,n._dbInfo=null,n._ready=null,n.getDriver(i).then(o).catch(r)}a();var c=new Error("No available storage method found.");return n._driverSet=s.reject(c),n._driverSet}()}}(i)}))})).catch((function(){a();var e=new Error("No available storage method found.");return n._driverSet=s.reject(e),n._driverSet})),c(this._driverSet,t,r),this._driverSet},e.prototype.supports=function(e){return!!ae[e]},e.prototype._extend=function(e){le(this,e)},e.prototype._getSupportedDrivers=function(e){for(var t=[],r=0,n=e.length;r<n;r++){var i=e[r];this.supports(i)&&t.push(i)}return t},e.prototype._wrapLibraryMethodsWithReady=function(){for(var e=0,t=fe.length;e<t;e++)de(this,fe[e])},e.prototype.createInstance=function(t){return new e(t)},e}(),pe=new he;t.exports=pe},{3:3}]},{},[4])(4)}))})),wN=gN(((e,t)=>{!function(r,n){"object"==typeof e&&typeof t<"u"?n(e):"function"==typeof define&&define.amd?define("localforage-driver-memory",["exports"],n):n(r.LocalforageDriverMemory={})}(typeof self<"u"?self:e,(function(e){var t=/^~~local_forage_type~([^~]+)~/,r=Object.prototype.toString;function n(e){var t=.75*e.length,r=e.length;"="===e[e.length-1]&&(t--,"="===e[e.length-2]&&t--);for(var n=new ArrayBuffer(t),i=new Uint8Array(n),a=0,s=0;a<r;a+=4){var o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(e[a]),c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(e[a+1]),f="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(e[a+2]),u="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(e[a+3]);i[s++]=o<<2|c>>4,i[s++]=(15&c)<<4|f>>2,i[s++]=(3&f)<<6|63&u}return n}function i(e){for(var t=new Uint8Array(e),r="",n=0;n<t.length;n+=3)r+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[t[n]>>2],r+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(3&t[n])<<4|t[n+1]>>4],r+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(15&t[n+1])<<2|t[n+2]>>6],r+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[63&t[n+2]];return t.length%3==2?r=r.substring(0,r.length-1)+"=":t.length%3==1&&(r=r.substring(0,r.length-2)+"=="),r}function a(e){var t,r;if(null===e||"object"!=typeof e||"isActiveClone"in e)return e;var n=e instanceof Date?new Date(e):e.constructor();try{for(var i=function(e){var t="function"==typeof Symbol&&e[Symbol.iterator],r=0;return t?t.call(e):{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}}}(Object.keys(e)),s=i.next();!s.done;s=i.next()){var o=s.value;Object.prototype.hasOwnProperty.call(e,o)&&(e.isActiveClone=null,n[o]=a(e[o]),delete e.isActiveClone)}}catch(e){t={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(t)throw t.error}}return n}function s(e,t){return(e.name||t.name)+"/"+(e.storeName||t.storeName)+"/"}function o(e,t){t&&e.then((function(e){t(null,e)}),(function(e){t(e)}))}function c(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];if(arguments.length&&"function"==typeof arguments[arguments.length-1])return arguments[arguments.length-1]}function f(e,t){var r,n=this;if(t=c.apply(this,arguments),!(e="function"!=typeof e&&e||{}).name){var i=this.config();e.name=e.name||i.name,e.storeName=e.storeName||i.storeName}return r=e.name?new Promise((function(t){e.storeName?t(s(e,n._defaultConfig)):t(e.name+"/")})):Promise.reject("Invalid arguments"),{promise:r,callback:t}}function u(e){return"string"!=typeof e&&(console.warn(e+" used as a key, but it is not a string."),e=String(e)),e}var d={bufferToString:i,deserialize:function(e){if("__lfsc__:"!==e.substring(0,9))return JSON.parse(e);var r,i=e.substring(13),a=e.substring(9,13);if("blob"===a&&t.test(i)){var s=i.match(t);r=s[1],i=i.substring(s[0].length)}var o=n(i);switch(a){case"arbf":return o;case"blob":return function(e,t){e=e||[],t=t||{};try{return new Blob(e,t)}catch(i){if("TypeError"!==i.name)throw i;for(var r=new(typeof BlobBuilder<"u"?BlobBuilder:typeof MSBlobBuilder<"u"?MSBlobBuilder:typeof MozBlobBuilder<"u"?MozBlobBuilder:WebKitBlobBuilder),n=0;n<e.length;n+=1)r.append(e[n]);return r.getBlob(t.type)}}([o],{type:r});case"si08":return new Int8Array(o);case"ui08":return new Uint8Array(o);case"uic8":return new Uint8ClampedArray(o);case"si16":return new Int16Array(o);case"ur16":return new Uint16Array(o);case"si32":return new Int32Array(o);case"ui32":return new Uint32Array(o);case"fl32":return new Float32Array(o);case"fl64":return new Float64Array(o);default:throw new Error("Unkown type: "+a)}},serialize:function(e,t){var n="";if(e&&(n=r.call(e)),e&&("[object ArrayBuffer]"===n||e.buffer&&"[object ArrayBuffer]"===r.call(e.buffer))){var a=void 0,s="__lfsc__:";e instanceof ArrayBuffer?(a=e,s+="arbf"):(a=e.buffer,"[object Int8Array]"===n?s+="si08":"[object Uint8Array]"===n?s+="ui08":"[object Uint8ClampedArray]"===n?s+="uic8":"[object Int16Array]"===n?s+="si16":"[object Uint16Array]"===n?s+="ur16":"[object Int32Array]"===n?s+="si32":"[object Uint32Array]"===n?s+="ui32":"[object Float32Array]"===n?s+="fl32":"[object Float64Array]"===n?s+="fl64":t(new Error("Failed to get type for BinaryArray"))),t(s+i(a))}else if("[object Blob]"===n){var o=new FileReader;o.onload=function(){var r="~~local_forage_type~"+e.type+"~"+i(this.result);t("__lfsc__:blob"+r)},o.readAsArrayBuffer(e)}else try{t(JSON.stringify(e))}catch(r){console.error("Couldn't convert value into a JSON string: ",e),t(null,r)}},stringToBuffer:n},l={},h=function(){function e(e){this.kp=e,this.data={}}return e.resolve=function(t){return l[t]||(l[t]=new e(t)),l[t]},e.prototype.clear=function(){this.data={}},e.prototype.drop=function(){this.clear(),delete l[this.kp]},e.prototype.get=function(e){return this.data[e]},e.prototype.key=function(e){return this.keys()[e]},e.prototype.keys=function(){return Object.keys(this.data)},e.prototype.rm=function(e){delete this.data[e]},e.prototype.set=function(e,t){this.data[e]=t},e}();e._support=!0,e._driver="localforage-driver-memory",e._initStorage=function(e){var t=e?a(e):{},r=s(t,this._defaultConfig),n=h.resolve(r);return this._dbInfo=t,this._dbInfo.serializer=d,this._dbInfo.keyPrefix=r,this._dbInfo.mStore=n,Promise.resolve()},e.clear=function(e){var t=this,r=this.ready().then((function(){t._dbInfo.mStore.clear()}));return o(r,e),r},e.dropInstance=function(e,t){var r=f.apply(this,arguments),n=r.promise,i=r.callback,a=n.then((function(e){h.resolve(e).drop()}));return o(a,i),n},e.getItem=function(e,t){var r=this;e=u(e);var n=this.ready().then((function(){var t=r._dbInfo.mStore.get(e);return null==t?null:r._dbInfo.serializer.deserialize(t)}));return o(n,t),n},e.iterate=function(e,t){var r=this,n=this.ready().then((function(){for(var t=r._dbInfo.mStore,n=t.keys(),i=0;i<n.length;i++){var a=t.get(n[i]);if(a&&(a=r._dbInfo.serializer.deserialize(a)),void 0!==(a=e(a,n[i],i+1)))return a}}));return o(n,t),n},e.key=function(e,t){var r=this,n=this.ready().then((function(){var t;try{void 0===(t=r._dbInfo.mStore.key(e))&&(t=null)}catch{t=null}return t}));return o(n,t),n},e.keys=function(e){var t=this,r=this.ready().then((function(){return t._dbInfo.mStore.keys()}));return o(r,e),r},e.length=function(e){var t=this.keys().then((function(e){return e.length}));return o(t,e),t},e.removeItem=function(e,t){var r=this;e=u(e);var n=this.ready().then((function(){r._dbInfo.mStore.rm(e)}));return o(n,t),n},e.setItem=function(e,t,r){var n=this;e=u(e);var i=this.ready().then((function(){void 0===t&&(t=null);var r=t;return new Promise((function(i,a){n._dbInfo.serializer.serialize(t,(function(t,s){if(s)a(s);else try{n._dbInfo.mStore.set(e,t),i(r)}catch(e){a(e)}}))}))}));return o(i,r),i},Object.defineProperty(e,"__esModule",{value:!0})}))})),_N=mN(vN()),EN=mN(wN()),AN={display:"none",position:"fixed",top:"0",right:"0",width:"100%",height:"100%",borderRadius:"0",border:"none",zIndex:"2147483647"};var SN=function(e,t){return Object.assign($C,t),e}(sN,{platform:"web",sdkName:"magic-sdk",version:"13.6.2",defaultEndpoint:"https://auth.magic.link/",ViewController:class extends cN{constructor(){super(...arguments),this.activeElement=null}init(){this.test="hello",this.iframe=new Promise((e=>{let t=()=>{if(function(e){let t=[].slice.call(document.querySelectorAll(".magic-iframe"));return Boolean(t.find((t=>t.src.includes(e))))}(encodeURIComponent(this.parameters)))new ZC(SM.DuplicateIframe,"Duplicate iframes found.").log();else{let t=document.createElement("iframe");t.classList.add("magic-iframe"),t.dataset.magicIframeLabel=YP(this.endpoint).host,t.title="Secure Modal",t.src=YP(`/send?params=${encodeURIComponent(this.parameters)}`,this.endpoint).href,function(e){for(let[t,r]of Object.entries(AN))e.style[t]=r}(t),document.body.appendChild(t),e(t)}};["loaded","interactive","complete"].includes(document.readyState)?t():window.addEventListener("load",t,!1)})),window.addEventListener("message",(e=>{var t;if(e.origin===this.endpoint&&e.data&&e.data.msgType&&this.messageHandlers.size){e.data.response=null!=(t=e.data.response)?t:{};for(let t of this.messageHandlers.values())t(e)}}))}showOverlay(){return yN(this,null,(function*(){let e=yield this.iframe;e.style.display="block",this.activeElement=document.activeElement,e.focus()}))}hideOverlay(){return yN(this,null,(function*(){var e;(yield this.iframe).style.display="none",null!=(e=this.activeElement)&&e.focus&&this.activeElement.focus(),this.activeElement=null}))}_post(e){return yN(this,null,(function*(){let t=yield this.iframe;if(!t||!t.contentWindow)throw new YC(AM.ModalNotReady,"Modal is not ready.");t.contentWindow.postMessage(e,this.endpoint)}))}},configureStorage:()=>yN(void 0,null,(function*(){let e=_N.default.createInstance({name:"MagicAuthLocalStorageDB",storeName:"MagicAuthLocalStorage"});return yield e.defineDriver(EN),yield e.setDriver([_N.default.INDEXEDDB,_N.default.LOCALSTORAGE,EN._driver]),e}))}),kN=(e=>(e.LoginWithOIDC="magic_auth_login_with_oidc",e))(kN||{}),xN=class extends tN.Internal{constructor(){super(...arguments),this.name="openid",this.config={}}loginWithOIDC(e){let t=this.utils.createJsonRpcRequestPayload("magic_auth_login_with_oidc",[e]);return this.request(t)}};function TN(e,t){return function(){return e.apply(t,arguments)}}const{toString:RN}=Object.prototype,{getPrototypeOf:ON}=Object,IN=(e=>t=>{const r=RN.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),MN=e=>(e=e.toLowerCase(),t=>IN(t)===e),CN=e=>t=>typeof t===e,{isArray:PN}=Array,NN=CN("undefined");const BN=MN("ArrayBuffer");const UN=CN("string"),LN=CN("function"),jN=CN("number"),DN=e=>null!==e&&"object"==typeof e,FN=e=>{if("object"!==IN(e))return!1;const t=ON(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||Symbol.toStringTag in e||Symbol.iterator in e)},qN=MN("Date"),zN=MN("File"),KN=MN("Blob"),HN=MN("FileList"),GN=MN("URLSearchParams");function VN(e,t,{allOwnKeys:r=!1}={}){if(null==e)return;let n,i;if("object"!=typeof e&&(e=[e]),PN(e))for(n=0,i=e.length;n<i;n++)t.call(null,e[n],n,e);else{const i=r?Object.getOwnPropertyNames(e):Object.keys(e),a=i.length;let s;for(n=0;n<a;n++)s=i[n],t.call(null,e[s],s,e)}}function WN(e,t){t=t.toLowerCase();const r=Object.keys(e);let n,i=r.length;for(;i-- >0;)if(n=r[i],t===n.toLowerCase())return n;return null}const XN="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,$N=e=>!NN(e)&&e!==XN;const JN=(e=>t=>e&&t instanceof e)("undefined"!=typeof Uint8Array&&ON(Uint8Array)),YN=MN("HTMLFormElement"),QN=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),ZN=MN("RegExp"),eB=(e,t)=>{const r=Object.getOwnPropertyDescriptors(e),n={};VN(r,((r,i)=>{!1!==t(r,i,e)&&(n[i]=r)})),Object.defineProperties(e,n)},tB="abcdefghijklmnopqrstuvwxyz",rB="0123456789",nB={DIGIT:rB,ALPHA:tB,ALPHA_DIGIT:tB+tB.toUpperCase()+rB};const iB=MN("AsyncFunction");var aB={isArray:PN,isArrayBuffer:BN,isBuffer:function(e){return null!==e&&!NN(e)&&null!==e.constructor&&!NN(e.constructor)&&LN(e.constructor.isBuffer)&&e.constructor.isBuffer(e)},isFormData:e=>{let t;return e&&("function"==typeof FormData&&e instanceof FormData||LN(e.append)&&("formdata"===(t=IN(e))||"object"===t&&LN(e.toString)&&"[object FormData]"===e.toString()))},isArrayBufferView:function(e){let t;return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&BN(e.buffer),t},isString:UN,isNumber:jN,isBoolean:e=>!0===e||!1===e,isObject:DN,isPlainObject:FN,isUndefined:NN,isDate:qN,isFile:zN,isBlob:KN,isRegExp:ZN,isFunction:LN,isStream:e=>DN(e)&&LN(e.pipe),isURLSearchParams:GN,isTypedArray:JN,isFileList:HN,forEach:VN,merge:function e(){const{caseless:t}=$N(this)&&this||{},r={},n=(n,i)=>{const a=t&&WN(r,i)||i;FN(r[a])&&FN(n)?r[a]=e(r[a],n):FN(n)?r[a]=e({},n):PN(n)?r[a]=n.slice():r[a]=n};for(let e=0,t=arguments.length;e<t;e++)arguments[e]&&VN(arguments[e],n);return r},extend:(e,t,r,{allOwnKeys:n}={})=>(VN(t,((t,n)=>{r&&LN(t)?e[n]=TN(t,r):e[n]=t}),{allOwnKeys:n}),e),trim:e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),stripBOM:e=>(65279===e.charCodeAt(0)&&(e=e.slice(1)),e),inherits:(e,t,r,n)=>{e.prototype=Object.create(t.prototype,n),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},toFlatObject:(e,t,r,n)=>{let i,a,s;const o={};if(t=t||{},null==e)return t;do{for(i=Object.getOwnPropertyNames(e),a=i.length;a-- >0;)s=i[a],n&&!n(s,e,t)||o[s]||(t[s]=e[s],o[s]=!0);e=!1!==r&&ON(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},kindOf:IN,kindOfTest:MN,endsWith:(e,t,r)=>{e=String(e),(void 0===r||r>e.length)&&(r=e.length),r-=t.length;const n=e.indexOf(t,r);return-1!==n&&n===r},toArray:e=>{if(!e)return null;if(PN(e))return e;let t=e.length;if(!jN(t))return null;const r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},forEachEntry:(e,t)=>{const r=(e&&e[Symbol.iterator]).call(e);let n;for(;(n=r.next())&&!n.done;){const r=n.value;t.call(e,r[0],r[1])}},matchAll:(e,t)=>{let r;const n=[];for(;null!==(r=e.exec(t));)n.push(r);return n},isHTMLForm:YN,hasOwnProperty:QN,hasOwnProp:QN,reduceDescriptors:eB,freezeMethods:e=>{eB(e,((t,r)=>{if(LN(e)&&-1!==["arguments","caller","callee"].indexOf(r))return!1;const n=e[r];LN(n)&&(t.enumerable=!1,"writable"in t?t.writable=!1:t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")}))}))},toObjectSet:(e,t)=>{const r={},n=e=>{e.forEach((e=>{r[e]=!0}))};return PN(e)?n(e):n(String(e).split(t)),r},toCamelCase:e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,(function(e,t,r){return t.toUpperCase()+r})),noop:()=>{},toFiniteNumber:(e,t)=>(e=+e,Number.isFinite(e)?e:t),findKey:WN,global:XN,isContextDefined:$N,ALPHABET:nB,generateString:(e=16,t=nB.ALPHA_DIGIT)=>{let r="";const{length:n}=t;for(;e--;)r+=t[Math.random()*n|0];return r},isSpecCompliantForm:function(e){return!!(e&&LN(e.append)&&"FormData"===e[Symbol.toStringTag]&&e[Symbol.iterator])},toJSONObject:e=>{const t=new Array(10),r=(e,n)=>{if(DN(e)){if(t.indexOf(e)>=0)return;if(!("toJSON"in e)){t[n]=e;const i=PN(e)?[]:{};return VN(e,((e,t)=>{const a=r(e,n+1);!NN(a)&&(i[t]=a)})),t[n]=void 0,i}}return e};return r(e,0)},isAsyncFn:iB,isThenable:e=>e&&(DN(e)||LN(e))&&LN(e.then)&&LN(e.catch)};function sB(e,t,r,n,i){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack,this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),n&&(this.request=n),i&&(this.response=i)}aB.inherits(sB,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:aB.toJSONObject(this.config),code:this.code,status:this.response&&this.response.status?this.response.status:null}}});const oB=sB.prototype,cB={};["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((e=>{cB[e]={value:e}})),Object.defineProperties(sB,cB),Object.defineProperty(oB,"isAxiosError",{value:!0}),sB.from=(e,t,r,n,i,a)=>{const s=Object.create(oB);return aB.toFlatObject(e,s,(function(e){return e!==Error.prototype}),(e=>"isAxiosError"!==e)),sB.call(s,e.message,t,r,n,i),s.cause=e,s.name=e.name,a&&Object.assign(s,a),s};function fB(e){return aB.isPlainObject(e)||aB.isArray(e)}function uB(e){return aB.endsWith(e,"[]")?e.slice(0,-2):e}function dB(e,t,r){return e?e.concat(t).map((function(e,t){return e=uB(e),!r&&t?"["+e+"]":e})).join(r?".":""):t}const lB=aB.toFlatObject(aB,{},null,(function(e){return/^is[A-Z]/.test(e)}));function hB(e,t,r){if(!aB.isObject(e))throw new TypeError("target must be an object");t=t||new FormData;const n=(r=aB.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,(function(e,t){return!aB.isUndefined(t[e])}))).metaTokens,i=r.visitor||f,a=r.dots,s=r.indexes,o=(r.Blob||"undefined"!=typeof Blob&&Blob)&&aB.isSpecCompliantForm(t);if(!aB.isFunction(i))throw new TypeError("visitor must be a function");function c(e){if(null===e)return"";if(aB.isDate(e))return e.toISOString();if(!o&&aB.isBlob(e))throw new sB("Blob is not supported. Use a Buffer instead.");return aB.isArrayBuffer(e)||aB.isTypedArray(e)?o&&"function"==typeof Blob?new Blob([e]):Buffer.from(e):e}function f(e,r,i){let o=e;if(e&&!i&&"object"==typeof e)if(aB.endsWith(r,"{}"))r=n?r:r.slice(0,-2),e=JSON.stringify(e);else if(aB.isArray(e)&&function(e){return aB.isArray(e)&&!e.some(fB)}(e)||(aB.isFileList(e)||aB.endsWith(r,"[]"))&&(o=aB.toArray(e)))return r=uB(r),o.forEach((function(e,n){!aB.isUndefined(e)&&null!==e&&t.append(!0===s?dB([r],n,a):null===s?r:r+"[]",c(e))})),!1;return!!fB(e)||(t.append(dB(i,r,a),c(e)),!1)}const u=[],d=Object.assign(lB,{defaultVisitor:f,convertValue:c,isVisitable:fB});if(!aB.isObject(e))throw new TypeError("data must be an object");return function e(r,n){if(!aB.isUndefined(r)){if(-1!==u.indexOf(r))throw Error("Circular reference detected in "+n.join("."));u.push(r),aB.forEach(r,(function(r,a){!0===(!(aB.isUndefined(r)||null===r)&&i.call(t,r,aB.isString(a)?a.trim():a,n,d))&&e(r,n?n.concat(a):[a])})),u.pop()}}(e),t}function pB(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,(function(e){return t[e]}))}function bB(e,t){this._pairs=[],e&&hB(e,this,t)}const gB=bB.prototype;function mB(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function yB(e,t,r){if(!t)return e;const n=r&&r.encode||mB,i=r&&r.serialize;let a;if(a=i?i(t,r):aB.isURLSearchParams(t)?t.toString():new bB(t,r).toString(n),a){const t=e.indexOf("#");-1!==t&&(e=e.slice(0,t)),e+=(-1===e.indexOf("?")?"?":"&")+a}return e}gB.append=function(e,t){this._pairs.push([e,t])},gB.toString=function(e){const t=e?function(t){return e.call(this,t,pB)}:pB;return this._pairs.map((function(e){return t(e[0])+"="+t(e[1])}),"").join("&")};var vB=class{constructor(){this.handlers=[]}use(e,t,r){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!r&&r.synchronous,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){aB.forEach(this.handlers,(function(t){null!==t&&e(t)}))}},wB={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var _B={isBrowser:!0,classes:{URLSearchParams:"undefined"!=typeof URLSearchParams?URLSearchParams:bB,FormData:"undefined"!=typeof FormData?FormData:null,Blob:"undefined"!=typeof Blob?Blob:null},isStandardBrowserEnv:(()=>{let e;return("undefined"==typeof navigator||"ReactNative"!==(e=navigator.product)&&"NativeScript"!==e&&"NS"!==e)&&("undefined"!=typeof window&&"undefined"!=typeof document)})(),isStandardBrowserWebWorkerEnv:"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,protocols:["http","https","file","blob","url","data"]};function EB(e){function t(e,r,n,i){let a=e[i++];const s=Number.isFinite(+a),o=i>=e.length;if(a=!a&&aB.isArray(n)?n.length:a,o)return aB.hasOwnProp(n,a)?n[a]=[n[a],r]:n[a]=r,!s;n[a]&&aB.isObject(n[a])||(n[a]=[]);return t(e,r,n[a],i)&&aB.isArray(n[a])&&(n[a]=function(e){const t={},r=Object.keys(e);let n;const i=r.length;let a;for(n=0;n<i;n++)a=r[n],t[a]=e[a];return t}(n[a])),!s}if(aB.isFormData(e)&&aB.isFunction(e.entries)){const r={};return aB.forEachEntry(e,((e,n)=>{t(function(e){return aB.matchAll(/\w+|\[(\w*)]/g,e).map((e=>"[]"===e[0]?"":e[1]||e[0]))}(e),n,r,0)})),r}return null}const AB={"Content-Type":void 0};const SB={transitional:wB,adapter:["xhr","http"],transformRequest:[function(e,t){const r=t.getContentType()||"",n=r.indexOf("application/json")>-1,i=aB.isObject(e);i&&aB.isHTMLForm(e)&&(e=new FormData(e));if(aB.isFormData(e))return n&&n?JSON.stringify(EB(e)):e;if(aB.isArrayBuffer(e)||aB.isBuffer(e)||aB.isStream(e)||aB.isFile(e)||aB.isBlob(e))return e;if(aB.isArrayBufferView(e))return e.buffer;if(aB.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let a;if(i){if(r.indexOf("application/x-www-form-urlencoded")>-1)return function(e,t){return hB(e,new _B.classes.URLSearchParams,Object.assign({visitor:function(e,t,r,n){return _B.isNode&&aB.isBuffer(e)?(this.append(t,e.toString("base64")),!1):n.defaultVisitor.apply(this,arguments)}},t))}(e,this.formSerializer).toString();if((a=aB.isFileList(e))||r.indexOf("multipart/form-data")>-1){const t=this.env&&this.env.FormData;return hB(a?{"files[]":e}:e,t&&new t,this.formSerializer)}}return i||n?(t.setContentType("application/json",!1),function(e,t,r){if(aB.isString(e))try{return(t||JSON.parse)(e),aB.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(r||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){const t=this.transitional||SB.transitional,r=t&&t.forcedJSONParsing,n="json"===this.responseType;if(e&&aB.isString(e)&&(r&&!this.responseType||n)){const r=!(t&&t.silentJSONParsing)&&n;try{return JSON.parse(e)}catch(e){if(r){if("SyntaxError"===e.name)throw sB.from(e,sB.ERR_BAD_RESPONSE,this,null,this.response);throw e}}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:_B.classes.FormData,Blob:_B.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};aB.forEach(["delete","get","head"],(function(e){SB.headers[e]={}})),aB.forEach(["post","put","patch"],(function(e){SB.headers[e]=aB.merge(AB)}));var kB=SB;const xB=aB.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"]);const TB=Symbol("internals");function RB(e){return e&&String(e).trim().toLowerCase()}function OB(e){return!1===e||null==e?e:aB.isArray(e)?e.map(OB):String(e)}function IB(e,t,r,n,i){return aB.isFunction(n)?n.call(this,t,r):(i&&(t=r),aB.isString(t)?aB.isString(n)?-1!==t.indexOf(n):aB.isRegExp(n)?n.test(t):void 0:void 0)}class MB{constructor(e){e&&this.set(e)}set(e,t,r){const n=this;function i(e,t,r){const i=RB(t);if(!i)throw new Error("header name must be a non-empty string");const a=aB.findKey(n,i);(!a||void 0===n[a]||!0===r||void 0===r&&!1!==n[a])&&(n[a||t]=OB(e))}const a=(e,t)=>aB.forEach(e,((e,r)=>i(e,r,t)));return aB.isPlainObject(e)||e instanceof this.constructor?a(e,t):aB.isString(e)&&(e=e.trim())&&!/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim())?a((e=>{const t={};let r,n,i;return e&&e.split("\n").forEach((function(e){i=e.indexOf(":"),r=e.substring(0,i).trim().toLowerCase(),n=e.substring(i+1).trim(),!r||t[r]&&xB[r]||("set-cookie"===r?t[r]?t[r].push(n):t[r]=[n]:t[r]=t[r]?t[r]+", "+n:n)})),t})(e),t):null!=e&&i(t,e,r),this}get(e,t){if(e=RB(e)){const r=aB.findKey(this,e);if(r){const e=this[r];if(!t)return e;if(!0===t)return function(e){const t=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let n;for(;n=r.exec(e);)t[n[1]]=n[2];return t}(e);if(aB.isFunction(t))return t.call(this,e,r);if(aB.isRegExp(t))return t.exec(e);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=RB(e)){const r=aB.findKey(this,e);return!(!r||void 0===this[r]||t&&!IB(0,this[r],r,t))}return!1}delete(e,t){const r=this;let n=!1;function i(e){if(e=RB(e)){const i=aB.findKey(r,e);!i||t&&!IB(0,r[i],i,t)||(delete r[i],n=!0)}}return aB.isArray(e)?e.forEach(i):i(e),n}clear(e){const t=Object.keys(this);let r=t.length,n=!1;for(;r--;){const i=t[r];e&&!IB(0,this[i],i,e,!0)||(delete this[i],n=!0)}return n}normalize(e){const t=this,r={};return aB.forEach(this,((n,i)=>{const a=aB.findKey(r,i);if(a)return t[a]=OB(n),void delete t[i];const s=e?function(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,((e,t,r)=>t.toUpperCase()+r))}(i):String(i).trim();s!==i&&delete t[i],t[s]=OB(n),r[s]=!0})),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return aB.forEach(this,((r,n)=>{null!=r&&!1!==r&&(t[n]=e&&aB.isArray(r)?r.join(", "):r)})),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map((([e,t])=>e+": "+t)).join("\n")}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const r=new this(e);return t.forEach((e=>r.set(e))),r}static accessor(e){const t=(this[TB]=this[TB]={accessors:{}}).accessors,r=this.prototype;function n(e){const n=RB(e);t[n]||(!function(e,t){const r=aB.toCamelCase(" "+t);["get","set","has"].forEach((n=>{Object.defineProperty(e,n+r,{value:function(e,r,i){return this[n].call(this,t,e,r,i)},configurable:!0})}))}(r,e),t[n]=!0)}return aB.isArray(e)?e.forEach(n):n(e),this}}MB.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),aB.freezeMethods(MB.prototype),aB.freezeMethods(MB);var CB=MB;function PB(e,t){const r=this||kB,n=t||r,i=CB.from(n.headers);let a=n.data;return aB.forEach(e,(function(e){a=e.call(r,a,i.normalize(),t?t.status:void 0)})),i.normalize(),a}function NB(e){return!(!e||!e.__CANCEL__)}function BB(e,t,r){sB.call(this,null==e?"canceled":e,sB.ERR_CANCELED,t,r),this.name="CanceledError"}aB.inherits(BB,sB,{__CANCEL__:!0});var UB=_B.isStandardBrowserEnv?{write:function(e,t,r,n,i,a){const s=[];s.push(e+"="+encodeURIComponent(t)),aB.isNumber(r)&&s.push("expires="+new Date(r).toGMTString()),aB.isString(n)&&s.push("path="+n),aB.isString(i)&&s.push("domain="+i),!0===a&&s.push("secure"),document.cookie=s.join("; ")},read:function(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}};function LB(e,t){return e&&!/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)?function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}(e,t):t}var jB=_B.isStandardBrowserEnv?function(){const e=/(msie|trident)/i.test(navigator.userAgent),t=document.createElement("a");let r;function n(r){let n=r;return e&&(t.setAttribute("href",n),n=t.href),t.setAttribute("href",n),{href:t.href,protocol:t.protocol?t.protocol.replace(/:$/,""):"",host:t.host,search:t.search?t.search.replace(/^\?/,""):"",hash:t.hash?t.hash.replace(/^#/,""):"",hostname:t.hostname,port:t.port,pathname:"/"===t.pathname.charAt(0)?t.pathname:"/"+t.pathname}}return r=n(window.location.href),function(e){const t=aB.isString(e)?n(e):e;return t.protocol===r.protocol&&t.host===r.host}}():function(){return!0};function DB(e,t){let r=0;const n=function(e,t){e=e||10;const r=new Array(e),n=new Array(e);let i,a=0,s=0;return t=void 0!==t?t:1e3,function(o){const c=Date.now(),f=n[s];i||(i=c),r[a]=o,n[a]=c;let u=s,d=0;for(;u!==a;)d+=r[u++],u%=e;if(a=(a+1)%e,a===s&&(s=(s+1)%e),c-i<t)return;const l=f&&c-f;return l?Math.round(1e3*d/l):void 0}}(50,250);return i=>{const a=i.loaded,s=i.lengthComputable?i.total:void 0,o=a-r,c=n(o);r=a;const f={loaded:a,total:s,progress:s?a/s:void 0,bytes:o,rate:c||void 0,estimated:c&&s&&a<=s?(s-a)/c:void 0,event:i};f[t?"download":"upload"]=!0,e(f)}}var FB="undefined"!=typeof XMLHttpRequest&&function(e){return new Promise((function(t,r){let n=e.data;const i=CB.from(e.headers).normalize(),a=e.responseType;let s;function o(){e.cancelToken&&e.cancelToken.unsubscribe(s),e.signal&&e.signal.removeEventListener("abort",s)}aB.isFormData(n)&&(_B.isStandardBrowserEnv||_B.isStandardBrowserWebWorkerEnv?i.setContentType(!1):i.setContentType("multipart/form-data;",!1));let c=new XMLHttpRequest;if(e.auth){const t=e.auth.username||"",r=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";i.set("Authorization","Basic "+btoa(t+":"+r))}const f=LB(e.baseURL,e.url);function u(){if(!c)return;const n=CB.from("getAllResponseHeaders"in c&&c.getAllResponseHeaders());!function(e,t,r){const n=r.config.validateStatus;r.status&&n&&!n(r.status)?t(new sB("Request failed with status code "+r.status,[sB.ERR_BAD_REQUEST,sB.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r)):e(r)}((function(e){t(e),o()}),(function(e){r(e),o()}),{data:a&&"text"!==a&&"json"!==a?c.response:c.responseText,status:c.status,statusText:c.statusText,headers:n,config:e,request:c}),c=null}if(c.open(e.method.toUpperCase(),yB(f,e.params,e.paramsSerializer),!0),c.timeout=e.timeout,"onloadend"in c?c.onloadend=u:c.onreadystatechange=function(){c&&4===c.readyState&&(0!==c.status||c.responseURL&&0===c.responseURL.indexOf("file:"))&&setTimeout(u)},c.onabort=function(){c&&(r(new sB("Request aborted",sB.ECONNABORTED,e,c)),c=null)},c.onerror=function(){r(new sB("Network Error",sB.ERR_NETWORK,e,c)),c=null},c.ontimeout=function(){let t=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded";const n=e.transitional||wB;e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),r(new sB(t,n.clarifyTimeoutError?sB.ETIMEDOUT:sB.ECONNABORTED,e,c)),c=null},_B.isStandardBrowserEnv){const t=(e.withCredentials||jB(f))&&e.xsrfCookieName&&UB.read(e.xsrfCookieName);t&&i.set(e.xsrfHeaderName,t)}void 0===n&&i.setContentType(null),"setRequestHeader"in c&&aB.forEach(i.toJSON(),(function(e,t){c.setRequestHeader(t,e)})),aB.isUndefined(e.withCredentials)||(c.withCredentials=!!e.withCredentials),a&&"json"!==a&&(c.responseType=e.responseType),"function"==typeof e.onDownloadProgress&&c.addEventListener("progress",DB(e.onDownloadProgress,!0)),"function"==typeof e.onUploadProgress&&c.upload&&c.upload.addEventListener("progress",DB(e.onUploadProgress)),(e.cancelToken||e.signal)&&(s=t=>{c&&(r(!t||t.type?new BB(null,e,c):t),c.abort(),c=null)},e.cancelToken&&e.cancelToken.subscribe(s),e.signal&&(e.signal.aborted?s():e.signal.addEventListener("abort",s)));const d=function(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}(f);d&&-1===_B.protocols.indexOf(d)?r(new sB("Unsupported protocol "+d+":",sB.ERR_BAD_REQUEST,e)):c.send(n||null)}))};const qB={http:null,xhr:FB};aB.forEach(qB,((e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch(e){}Object.defineProperty(e,"adapterName",{value:t})}}));var zB=e=>{e=aB.isArray(e)?e:[e];const{length:t}=e;let r,n;for(let i=0;i<t&&(r=e[i],!(n=aB.isString(r)?qB[r.toLowerCase()]:r));i++);if(!n){if(!1===n)throw new sB(`Adapter ${r} is not supported by the environment`,"ERR_NOT_SUPPORT");throw new Error(aB.hasOwnProp(qB,r)?`Adapter '${r}' is not available in the build`:`Unknown adapter '${r}'`)}if(!aB.isFunction(n))throw new TypeError("adapter is not a function");return n};function KB(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new BB(null,e)}function HB(e){KB(e),e.headers=CB.from(e.headers),e.data=PB.call(e,e.transformRequest),-1!==["post","put","patch"].indexOf(e.method)&&e.headers.setContentType("application/x-www-form-urlencoded",!1);return zB(e.adapter||kB.adapter)(e).then((function(t){return KB(e),t.data=PB.call(e,e.transformResponse,t),t.headers=CB.from(t.headers),t}),(function(t){return NB(t)||(KB(e),t&&t.response&&(t.response.data=PB.call(e,e.transformResponse,t.response),t.response.headers=CB.from(t.response.headers))),Promise.reject(t)}))}const GB=e=>e instanceof CB?e.toJSON():e;function VB(e,t){t=t||{};const r={};function n(e,t,r){return aB.isPlainObject(e)&&aB.isPlainObject(t)?aB.merge.call({caseless:r},e,t):aB.isPlainObject(t)?aB.merge({},t):aB.isArray(t)?t.slice():t}function i(e,t,r){return aB.isUndefined(t)?aB.isUndefined(e)?void 0:n(void 0,e,r):n(e,t,r)}function a(e,t){if(!aB.isUndefined(t))return n(void 0,t)}function s(e,t){return aB.isUndefined(t)?aB.isUndefined(e)?void 0:n(void 0,e):n(void 0,t)}function o(r,i,a){return a in t?n(r,i):a in e?n(void 0,r):void 0}const c={url:a,method:a,data:a,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials: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:o,headers:(e,t)=>i(GB(e),GB(t),!0)};return aB.forEach(Object.keys(Object.assign({},e,t)),(function(n){const a=c[n]||i,s=a(e[n],t[n],n);aB.isUndefined(s)&&a!==o||(r[n]=s)})),r}const WB="1.4.0",XB={};["object","boolean","number","function","string","symbol"].forEach(((e,t)=>{XB[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}}));const $B={};XB.transitional=function(e,t,r){function n(e,t){return"[Axios v1.4.0] Transitional option '"+e+"'"+t+(r?". "+r:"")}return(r,i,a)=>{if(!1===e)throw new sB(n(i," has been removed"+(t?" in "+t:"")),sB.ERR_DEPRECATED);return t&&!$B[i]&&($B[i]=!0,console.warn(n(i," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(r,i,a)}};var JB={assertOptions:function(e,t,r){if("object"!=typeof e)throw new sB("options must be an object",sB.ERR_BAD_OPTION_VALUE);const n=Object.keys(e);let i=n.length;for(;i-- >0;){const a=n[i],s=t[a];if(s){const t=e[a],r=void 0===t||s(t,a,e);if(!0!==r)throw new sB("option "+a+" must be "+r,sB.ERR_BAD_OPTION_VALUE)}else if(!0!==r)throw new sB("Unknown option "+a,sB.ERR_BAD_OPTION)}},validators:XB};const YB=JB.validators;class QB{constructor(e){this.defaults=e,this.interceptors={request:new vB,response:new vB}}request(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{},t=VB(this.defaults,t);const{transitional:r,paramsSerializer:n,headers:i}=t;let a;void 0!==r&&JB.assertOptions(r,{silentJSONParsing:YB.transitional(YB.boolean),forcedJSONParsing:YB.transitional(YB.boolean),clarifyTimeoutError:YB.transitional(YB.boolean)},!1),null!=n&&(aB.isFunction(n)?t.paramsSerializer={serialize:n}:JB.assertOptions(n,{encode:YB.function,serialize:YB.function},!0)),t.method=(t.method||this.defaults.method||"get").toLowerCase(),a=i&&aB.merge(i.common,i[t.method]),a&&aB.forEach(["delete","get","head","post","put","patch","common"],(e=>{delete i[e]})),t.headers=CB.concat(a,i);const s=[];let o=!0;this.interceptors.request.forEach((function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(o=o&&e.synchronous,s.unshift(e.fulfilled,e.rejected))}));const c=[];let f;this.interceptors.response.forEach((function(e){c.push(e.fulfilled,e.rejected)}));let u,d=0;if(!o){const e=[HB.bind(this),void 0];for(e.unshift.apply(e,s),e.push.apply(e,c),u=e.length,f=Promise.resolve(t);d<u;)f=f.then(e[d++],e[d++]);return f}u=s.length;let l=t;for(d=0;d<u;){const e=s[d++],t=s[d++];try{l=e(l)}catch(e){t.call(this,e);break}}try{f=HB.call(this,l)}catch(e){return Promise.reject(e)}for(d=0,u=c.length;d<u;)f=f.then(c[d++],c[d++]);return f}getUri(e){return yB(LB((e=VB(this.defaults,e)).baseURL,e.url),e.params,e.paramsSerializer)}}aB.forEach(["delete","get","head","options"],(function(e){QB.prototype[e]=function(t,r){return this.request(VB(r||{},{method:e,url:t,data:(r||{}).data}))}})),aB.forEach(["post","put","patch"],(function(e){function t(t){return function(r,n,i){return this.request(VB(i||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:r,data:n}))}}QB.prototype[e]=t(),QB.prototype[e+"Form"]=t(!0)}));var ZB=QB;class eU{constructor(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");let t;this.promise=new Promise((function(e){t=e}));const r=this;this.promise.then((e=>{if(!r._listeners)return;let t=r._listeners.length;for(;t-- >0;)r._listeners[t](e);r._listeners=null})),this.promise.then=e=>{let t;const n=new Promise((e=>{r.subscribe(e),t=e})).then(e);return n.cancel=function(){r.unsubscribe(t)},n},e((function(e,n,i){r.reason||(r.reason=new BB(e,n,i),t(r.reason))}))}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}static source(){let e;const t=new eU((function(t){e=t}));return{token:t,cancel:e}}}var tU=eU;const rU={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(rU).forEach((([e,t])=>{rU[t]=e}));var nU=rU;const iU=function e(t){const r=new ZB(t),n=TN(ZB.prototype.request,r);return aB.extend(n,ZB.prototype,r,{allOwnKeys:!0}),aB.extend(n,r,null,{allOwnKeys:!0}),n.create=function(r){return e(VB(t,r))},n}(kB);iU.Axios=ZB,iU.CanceledError=BB,iU.CancelToken=tU,iU.isCancel=NB,iU.VERSION=WB,iU.toFormData=hB,iU.AxiosError=sB,iU.Cancel=iU.CanceledError,iU.all=function(e){return Promise.all(e)},iU.spread=function(e){return function(t){return e.apply(null,t)}},iU.isAxiosError=function(e){return aB.isObject(e)&&!0===e.isAxiosError},iU.mergeConfig=VB,iU.AxiosHeaders=CB,iU.formToJSON=e=>EB(aB.isHTMLForm(e)?new FormData(e):e),iU.HttpStatusCode=nU,iU.default=iU;var aU=iU;const sU="https://guardian.sandbox.imtbl.com".replace(/\/+$/,"");class oU{basePath;axios;configuration;constructor(e,t=sU,r=aU){this.basePath=t,this.axios=r,e&&(this.configuration=e,this.basePath=e.basePath||this.basePath)}}class cU extends Error{field;constructor(e,t){super(t),this.field=e,this.name="RequiredError"}}const fU="https://example.com",uU=function(e,t,r){if(null==r)throw new cU(t,`Required parameter ${t} was null or undefined when calling ${e}.`)},dU=async function(e,t){if(t&&t.accessToken){const r="function"==typeof t.accessToken?await t.accessToken():await t.accessToken;e.Authorization="Bearer "+r}};function lU(e,t,r=""){null!=t&&("object"==typeof t?Array.isArray(t)?t.forEach((t=>lU(e,t,r))):Object.keys(t).forEach((n=>lU(e,t[n],`${r}${""!==r?".":""}${n}`))):e.has(r)?e.append(r,t):e.set(r,t))}const hU=function(e,...t){const r=new URLSearchParams(e.search);lU(r,t),e.search=r.toString()},pU=function(e,t,r){const n="string"!=typeof e;return(n&&r&&r.isJsonMime?r.isJsonMime(t.headers["Content-Type"]):n)?JSON.stringify(void 0!==e?e:{}):e||""},bU=function(e){return e.pathname+e.search+e.hash},gU=function(e,t,r,n){return(i=t,a=r)=>{const s={...e.options,url:(n?.basePath||a)+e.url};return i.request(s)}},mU=function(e){const t=function(e){return{approvePendingTransaction:async(t,r,n={})=>{uU("approvePendingTransaction","payloadHash",t),uU("approvePendingTransaction","transactionApprovalRequest",r);const i="/guardian/v1/transactions/{payloadHash}/approve".replace("{payloadHash}",encodeURIComponent(String(t))),a=new URL(i,fU);let s;e&&(s=e.baseOptions);const o={method:"POST",...s,...n},c={};await dU(c,e),c["Content-Type"]="application/json",hU(a,{});let f=s&&s.headers?s.headers:{};return o.headers={...c,...f,...n.headers},o.data=pU(r,o,e),{url:bU(a),options:o}},evaluateTransaction:async(t,r,n={})=>{uU("evaluateTransaction","id",t),uU("evaluateTransaction","transactionEvaluationRequest",r);const i="/guardian/v1/transactions/{id}/evaluate".replace("{id}",encodeURIComponent(String(t))),a=new URL(i,fU);let s;e&&(s=e.baseOptions);const o={method:"POST",...s,...n},c={};await dU(c,e),c["Content-Type"]="application/json",hU(a,{});let f=s&&s.headers?s.headers:{};return o.headers={...c,...f,...n.headers},o.data=pU(r,o,e),{url:bU(a),options:o}},getTransactionByID:async(t,r,n,i={})=>{uU("getTransactionByID","transactionID",t),uU("getTransactionByID","chainType",r);const a="/guardian/v1/transactions/{transactionID}".replace("{transactionID}",encodeURIComponent(String(t))),s=new URL(a,fU);let o;e&&(o=e.baseOptions);const c={method:"GET",...o,...i},f={},u={};await dU(f,e),void 0!==r&&(u.chainType=r),void 0!==n&&(u.chainID=n),hU(s,u);let d=o&&o.headers?o.headers:{};return c.headers={...f,...d,...i.headers},{url:bU(s),options:c}}}}(e);return{async approvePendingTransaction(r,n,i){const a=await t.approvePendingTransaction(r,n,i);return gU(a,aU,sU,e)},async evaluateTransaction(r,n,i){const a=await t.evaluateTransaction(r,n,i);return gU(a,aU,sU,e)},async getTransactionByID(r,n,i,a){const s=await t.getTransactionByID(r,n,i,a);return gU(s,aU,sU,e)}}};class yU extends oU{approvePendingTransaction(e,t){return mU(this.configuration).approvePendingTransaction(e.payloadHash,e.transactionApprovalRequest,t).then((e=>e(this.axios,this.basePath)))}evaluateTransaction(e,t){return mU(this.configuration).evaluateTransaction(e.id,e.transactionEvaluationRequest,t).then((e=>e(this.axios,this.basePath)))}getTransactionByID(e,t){return mU(this.configuration).getTransactionByID(e.transactionID,e.chainType,e.chainID,t).then((e=>e(this.axios,this.basePath)))}}class vU{apiKey;username;password;accessToken;basePath;baseOptions;formDataCtor;constructor(e={}){this.apiKey=e.apiKey,this.username=e.username,this.password=e.password,this.accessToken=e.accessToken,this.basePath=e.basePath,this.baseOptions=e.baseOptions,this.formDataCtor=e.formDataCtor}isJsonMime(e){const t=new RegExp("^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$","i");return null!==e&&(t.test(e)||"application/json-patch+json"===e.toLowerCase())}}const wU="starkex",_U="evm";function EU(e){const t=-1!==new ce(e,16).cmp(new ce(27))?new ce(e,16).sub(new ce(27)).toNumber():new ce(e,16).toNumber();return e.trim()?t:void 0}async function AU(e,t){const r=function(e,t=64){const r=Gf(e);return{r:new ce(r.substring(0,t),"hex"),s:new ce(r.substring(t,2*t),"hex"),recoveryParam:EU(r.substring(2*t,2*t+2))}}(await t.signMessage(e));return Wf(Kf((n=r).r.toString(16),64)+Kf(n.s.toString(16),64)+Kf(n.recoveryParam?.toString(16)||"",2));var n}function SU(e){switch(e.type){case"ERC721":return{type:"ERC721",data:{token_id:e.tokenId,token_address:e.tokenAddress}};case"ERC20":return{type:"ERC20",data:{token_address:e.tokenAddress}};default:return{type:"ETH",data:{decimals:18}}}}const kU={erc1271:Object.freeze({__proto__:null,abi:[{type:"function",name:"isValidSignature",constant:!0,inputs:[{type:"bytes32"},{type:"bytes"}],outputs:[{type:"bytes4"}],payable:!1,stateMutability:"view"}],returns:{isValidSignatureBytes32:"0x1626ba7e"}}),factory:Object.freeze({__proto__:null,abi:[{type:"function",name:"deploy",constant:!1,inputs:[{type:"address"},{type:"bytes32"}],outputs:[],payable:!0,stateMutability:"payable"}]}),mainModule:Object.freeze({__proto__:null,abi:[{type:"function",name:"nonce",constant:!0,inputs:[],outputs:[{type:"uint256"}],payable:!1,stateMutability:"view"},{type:"function",name:"readNonce",constant:!0,inputs:[{type:"uint256"}],outputs:[{type:"uint256"}],payable:!1,stateMutability:"view"},{type:"function",name:"updateImplementation",constant:!1,inputs:[{type:"address"}],outputs:[],payable:!1,stateMutability:"nonpayable"},{type:"function",name:"selfExecute",constant:!1,inputs:[{components:[{type:"bool",name:"delegateCall"},{type:"bool",name:"revertOnError"},{type:"uint256",name:"gasLimit"},{type:"address",name:"target"},{type:"uint256",name:"value"},{type:"bytes",name:"data"}],type:"tuple[]"}],outputs:[],payable:!1,stateMutability:"nonpayable"},{type:"function",name:"execute",constant:!1,inputs:[{components:[{type:"bool",name:"delegateCall"},{type:"bool",name:"revertOnError"},{type:"uint256",name:"gasLimit"},{type:"address",name:"target"},{type:"uint256",name:"value"},{type:"bytes",name:"data"}],type:"tuple[]"},{type:"uint256"},{type:"bytes"}],outputs:[],payable:!1,stateMutability:"nonpayable"},{type:"function",name:"createContract",inputs:[{type:"bytes"}],payable:!0,stateMutability:"payable"}]}),mainModuleUpgradable:Object.freeze({__proto__:null,abi:[{type:"function",name:"updateImageHash",constant:!0,inputs:[{type:"bytes32"}],outputs:[],payable:!1,stateMutability:"view"},{type:"function",name:"imageHash",constant:!0,inputs:[],outputs:[{type:"bytes32"}],payable:!1,stateMutability:"view"}]}),sequenceUtils:Object.freeze({__proto__:null,abi:[{inputs:[{internalType:"address",name:"_factory",type:"address"},{internalType:"address",name:"_mainModule",type:"address"}],stateMutability:"nonpayable",type:"constructor"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"_wallet",type:"address"},{indexed:!0,internalType:"bytes32",name:"_imageHash",type:"bytes32"},{indexed:!1,internalType:"uint256",name:"_threshold",type:"uint256"},{indexed:!1,internalType:"bytes",name:"_signers",type:"bytes"}],name:"RequiredConfig",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"_wallet",type:"address"},{indexed:!0,internalType:"address",name:"_signer",type:"address"}],name:"RequiredSigner",type:"event"},{inputs:[{internalType:"address",name:"_addr",type:"address"}],name:"callBalanceOf",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"callBlockNumber",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"_i",type:"uint256"}],name:"callBlockhash",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"callChainId",outputs:[{internalType:"uint256",name:"id",type:"uint256"}],stateMutability:"pure",type:"function"},{inputs:[{internalType:"address",name:"_addr",type:"address"}],name:"callCode",outputs:[{internalType:"bytes",name:"code",type:"bytes"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"_addr",type:"address"}],name:"callCodeHash",outputs:[{internalType:"bytes32",name:"codeHash",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"_addr",type:"address"}],name:"callCodeSize",outputs:[{internalType:"uint256",name:"size",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"callCoinbase",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"callDifficulty",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"callGasLeft",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"callGasLimit",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"callGasPrice",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"callOrigin",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"callTimestamp",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"}],name:"knownImageHashes",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"",type:"bytes32"}],name:"lastImageHashUpdate",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"}],name:"lastSignerUpdate",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"}],name:"lastWalletUpdate",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{components:[{internalType:"bool",name:"delegateCall",type:"bool"},{internalType:"bool",name:"revertOnError",type:"bool"},{internalType:"uint256",name:"gasLimit",type:"uint256"},{internalType:"address",name:"target",type:"address"},{internalType:"uint256",name:"value",type:"uint256"},{internalType:"bytes",name:"data",type:"bytes"}],internalType:"struct IModuleCalls.Transaction[]",name:"_txs",type:"tuple[]"}],name:"multiCall",outputs:[{internalType:"bool[]",name:"_successes",type:"bool[]"},{internalType:"bytes[]",name:"_results",type:"bytes[]"}],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"_wallet",type:"address"},{internalType:"uint256",name:"_threshold",type:"uint256"},{components:[{internalType:"uint256",name:"weight",type:"uint256"},{internalType:"address",name:"signer",type:"address"}],internalType:"struct RequireUtils.Member[]",name:"_members",type:"tuple[]"},{internalType:"bool",name:"_index",type:"bool"}],name:"publishConfig",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"_wallet",type:"address"},{internalType:"bytes32",name:"_hash",type:"bytes32"},{internalType:"uint256",name:"_sizeMembers",type:"uint256"},{internalType:"bytes",name:"_signature",type:"bytes"},{internalType:"bool",name:"_index",type:"bool"}],name:"publishInitialSigners",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"_wallet",type:"address"},{internalType:"uint256",name:"_nonce",type:"uint256"}],name:"requireMinNonce",outputs:[],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"_expiration",type:"uint256"}],name:"requireNonExpired",outputs:[],stateMutability:"view",type:"function"}]}),requireFreshSigner:Object.freeze({__proto__:null,abi:[{inputs:[{internalType:"address",name:"",type:"address"}],name:"requireFreshSigner",outputs:[],stateMutability:"nonpayable",type:"function"}]})};function xU(){return xU=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},xU.apply(this,arguments)}var TU;!function(e){e[e.DEBUG=1]="DEBUG",e[e.INFO=2]="INFO",e[e.WARN=3]="WARN",e[e.ERROR=4]="ERROR",e[e.DISABLED=5]="DISABLED"}(TU||(TU={}));function RU(){return RU=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},RU.apply(this,arguments)}new class{constructor(e){this.config=e,this.logLevel=void 0,this.configure(e)}configure(e){switch(this.config=xU({},this.config,e),this.config.logLevel){case"DEBUG":this.logLevel=TU.DEBUG;break;case"INFO":default:this.logLevel=TU.INFO;break;case"WARN":this.logLevel=TU.WARN;break;case"ERROR":this.logLevel=TU.ERROR;break;case"DISABLED":this.logLevel=TU.DISABLED}void 0===this.config.silence&&(this.config.silence=!1)}debug(e,...t){!0!==this.config.silence&&this.logLevel===TU.DEBUG&&console.log(e,...t)}info(e,...t){!0!==this.config.silence&&this.logLevel<=TU.INFO&&console.log(e,...t)}warn(e,...t){!0!==this.config.silence&&this.logLevel<=TU.WARN&&(console.warn(e,...t),this.config.onwarn&&this.config.onwarn(e,t))}error(e,...t){!0!==this.config.silence&&this.logLevel<=TU.ERROR&&(console.error(e,...t),this.config.onerror&&this.config.onerror(e,t))}}({logLevel:"INFO",silence:!0});const OU=(e,t=!1)=>(((e,t=!1,r=!1)=>{if(!e)throw new Error("invalid network config: empty config");const n=[];if(Array.isArray(e)?n.push(...e):n.push(e),0===n.length){if(t)throw new Error("invalid network config: empty config");return!1}const i=n.map((e=>e.chainId)).sort(),a=i.filter(((e,t)=>i.indexOf(e)!==t));if(a.length>0){if(t)throw new Error(`invalid network config: duplicate chainIds ${a}`);return!1}n.forEach((e=>e.name=e.name.toLowerCase()));const s=n.map((e=>e.name)).sort(),o=s.filter(((e,t)=>s.indexOf(e)!==t));if(o.length>0){if(t)throw new Error(`invalid network config: duplicate network names ${o}`);return!1}let c=!1,f=!1;for(let e=0;e<n.length;e++){const i=n[e];if(!(i.rpcUrl&&""!==i.rpcUrl||i.provider)){if(t)throw new Error(`invalid network config for chainId ${i.chainId}: rpcUrl or provider must be provided`);return!1}if(!r&&!i.relayer){if(t)throw new Error(`invalid network config for chainId ${i.chainId}: relayer must be provided`);return!1}if(i.isDefaultChain){if(c){if(t)throw new Error(`invalid network config for chainId ${i.chainId}: DefaultChain is already set by another config`);return!1}c=!0}if(i.isAuthChain){if(f&&t)throw new Error(`invalid network config for chainId ${i.chainId}: AuthChain is already set by another config`);f=!0}}if(!c){if(t)throw new Error("invalid network config: DefaultChain must be set");return!1}if(!f){if(t)throw new Error("invalid network config: AuthChain must be set");return!1}})(e,!0,t),e),IU=e=>OU(MU(e)),MU=e=>{if(!e)return[];const t=e.sort(((e,t)=>e.chainId===t.chainId?0:e.chainId<t.chainId?-1:1)),r=t.findIndex((e=>e.isDefaultChain));r>0&&t.splice(0,0,t.splice(r,1)[0]);const n=t.findIndex((e=>e.isAuthChain&&!0!==e.isDefaultChain));return n>0&&t.splice(1,0,t.splice(n,1)[0]),t},CU=(e,t)=>"string"==typeof e?(t=t||{},e.replace(/\$\{\s*([$#@\-\d\w]+)\s*\}/gim,(function(e,r){let n=t[r];return n="function"==typeof n?n():null==n?"":"object"==typeof n||"symbol"==typeof n?n.toString():n.valueOf(),n}))):"";let PU;!function(e){e[e.MAINNET=1]="MAINNET",e[e.ROPSTEN=3]="ROPSTEN",e[e.RINKEBY=4]="RINKEBY",e[e.GOERLI=5]="GOERLI",e[e.KOVAN=42]="KOVAN",e[e.POLYGON=137]="POLYGON",e[e.POLYGON_MUMBAI=80001]="POLYGON_MUMBAI",e[e.POLYGON_ZKEVM=1101]="POLYGON_ZKEVM",e[e.BSC=56]="BSC",e[e.BSC_TESTNET=97]="BSC_TESTNET",e[e.OPTIMISM=10]="OPTIMISM",e[e.OPTIMISM_TESTNET=69]="OPTIMISM_TESTNET",e[e.ARBITRUM=42161]="ARBITRUM",e[e.ARBITRUM_GOERLI=421613]="ARBITRUM_GOERLI",e[e.ARBITRUM_NOVA=42170]="ARBITRUM_NOVA",e[e.AVALANCHE=43114]="AVALANCHE",e[e.AVALANCHE_TESTNET=43113]="AVALANCHE_TESTNET",e[e.FANTOM=250]="FANTOM",e[e.FANTOM_TESTNET=4002]="FANTOM_TESTNET",e[e.GNOSIS=100]="GNOSIS",e[e.AURORA=1313161554]="AURORA",e[e.AURORA_TESTNET=1313161556]="AURORA_TESTNET",e[e.BASE_GOERLI=84531]="BASE_GOERLI"}(PU||(PU={}));const NU=e=>CU("https://${network}-indexer.sequence.app",{network:e}),BU=e=>CU("https://${network}-relayer.sequence.app",{network:e}),UU=e=>CU("https://nodes.sequence.app/${network}",{network:e}),LU={[PU.MAINNET]:{chainId:PU.MAINNET,name:"mainnet",title:"Ethereum",blockExplorer:{name:"Etherscan",rootUrl:"https://etherscan.io/"},ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e"},[PU.ROPSTEN]:{chainId:PU.ROPSTEN,name:"ropsten",title:"Ropsten",testnet:!0,blockExplorer:{name:"Etherscan (Ropsten)",rootUrl:"https://ropsten.etherscan.io/"},ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e"},[PU.RINKEBY]:{chainId:PU.RINKEBY,name:"rinkeby",title:"Rinkeby",testnet:!0,blockExplorer:{name:"Etherscan (Rinkeby)",rootUrl:"https://rinkeby.etherscan.io/"},ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",disabled:!0},[PU.GOERLI]:{chainId:PU.GOERLI,name:"goerli",title:"Goerli",testnet:!0,blockExplorer:{name:"Etherscan (Goerli)",rootUrl:"https://goerli.etherscan.io/"},ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e"},[PU.KOVAN]:{chainId:PU.KOVAN,name:"kovan",title:"Kovan",testnet:!0,blockExplorer:{name:"Etherscan (Kovan)",rootUrl:"https://kovan.etherscan.io/"}},[PU.POLYGON]:{chainId:PU.POLYGON,name:"polygon",title:"Polygon",blockExplorer:{name:"Polygonscan",rootUrl:"https://polygonscan.com/"}},[PU.POLYGON_MUMBAI]:{chainId:PU.POLYGON_MUMBAI,name:"mumbai",title:"Polygon Mumbai",testnet:!0,blockExplorer:{name:"Polygonscan (Mumbai)",rootUrl:"https://mumbai.polygonscan.com/"}},[PU.POLYGON_ZKEVM]:{chainId:PU.POLYGON_ZKEVM,name:"polygon-zkevm",title:"Polygon zkEVM",blockExplorer:{name:"Polygonscan (zkEVM)",rootUrl:"https://zkevm.polygonscan.com/"}},[PU.BSC]:{chainId:PU.BSC,name:"bsc",title:"BNB Smart Chain",blockExplorer:{name:"BSCScan",rootUrl:"https://bscscan.com/"}},[PU.BSC_TESTNET]:{chainId:PU.BSC_TESTNET,name:"bsc-testnet",title:"BNB Smart Chain Testnet",testnet:!0,blockExplorer:{name:"BSCScan (Testnet)",rootUrl:"https://testnet.bscscan.com/"}},[PU.OPTIMISM]:{chainId:PU.OPTIMISM,name:"optimism",title:"Optimism",blockExplorer:{name:"Etherscan (Optimism)",rootUrl:"https://optimistic.etherscan.io/"}},[PU.OPTIMISM_TESTNET]:{chainId:PU.OPTIMISM_TESTNET,name:"optimism-testnet",title:"Optimistic Kovan",testnet:!0,blockExplorer:{name:"Etherscan (Optimism Testnet)",rootUrl:"https://kovan-optimistic.etherscan.io/"}},[PU.ARBITRUM]:{chainId:PU.ARBITRUM,name:"arbitrum",title:"Arbitrum One",blockExplorer:{name:"Arbiscan",rootUrl:"https://arbiscan.io/"}},[PU.ARBITRUM_GOERLI]:{chainId:PU.ARBITRUM_GOERLI,name:"arbitrum-goerli",title:"Arbitrum Goerli",testnet:!0,blockExplorer:{name:"Arbiscan (Testnet)",rootUrl:"https://testnet.arbiscan.io/"}},[PU.ARBITRUM_NOVA]:{chainId:PU.ARBITRUM_NOVA,name:"arbitrum-nova",title:"Arbitrum Nova",blockExplorer:{name:"Nova Explorer",rootUrl:"https://nova-explorer.arbitrum.io/"}},[PU.AVALANCHE]:{chainId:PU.AVALANCHE,name:"avalanche",title:"Avalanche",blockExplorer:{name:"Snowtrace",rootUrl:"https://snowtrace.io/"}},[PU.AVALANCHE_TESTNET]:{chainId:PU.AVALANCHE_TESTNET,name:"avalanche-testnet",title:"Avalanche Testnet",testnet:!0,blockExplorer:{name:"Snowtrace (Testnet)",rootUrl:"https://testnet.snowtrace.io/"}},[PU.FANTOM]:{chainId:PU.FANTOM,name:"fantom",title:"Fantom",blockExplorer:{name:"FTMScan",rootUrl:"https://ftmscan.com/"}},[PU.FANTOM_TESTNET]:{chainId:PU.FANTOM_TESTNET,name:"fantom-testnet",title:"Fantom Testnet",testnet:!0,blockExplorer:{name:"FTMScan (Testnet)",rootUrl:"https://testnet.ftmscan.com/"}},[PU.GNOSIS]:{chainId:PU.GNOSIS,name:"gnosis",title:"Gnosis Chain",blockExplorer:{name:"Gnosis Chain Explorer",rootUrl:"https://blockscout.com/xdai/mainnet/"}},[PU.AURORA]:{chainId:PU.AURORA,name:"aurora",title:"Aurora",blockExplorer:{name:"Aurora Explorer",rootUrl:"https://aurorascan.dev/"}},[PU.AURORA_TESTNET]:{chainId:PU.AURORA_TESTNET,name:"aurora-testnet",title:"Aurora Testnet",blockExplorer:{name:"Aurora Explorer (Testnet)",rootUrl:"https://testnet.aurorascan.dev/"}},[PU.BASE_GOERLI]:{chainId:PU.BASE_GOERLI,name:"base-goerli",title:"Base Goerli",blockExplorer:{name:"Base Goerli Explorer",rootUrl:"https://goerli.basescan.org/"}}};IU([RU({},LU[PU.MAINNET],{rpcUrl:UU("mainnet"),relayer:{url:BU("mainnet")},indexerUrl:NU("mainnet")}),RU({},LU[PU.POLYGON],{rpcUrl:UU("polygon"),relayer:{url:BU("polygon")},indexerUrl:NU("polygon"),isDefaultChain:!0,isAuthChain:!0}),RU({},LU[PU.BSC],{rpcUrl:UU("bsc"),indexerUrl:NU("bsc"),relayer:{url:BU("bsc")}}),RU({},LU[PU.AVALANCHE],{rpcUrl:UU("avalanche"),indexerUrl:NU("avalanche"),relayer:{url:BU("avalanche")}}),RU({},LU[PU.ARBITRUM],{rpcUrl:UU("arbitrum"),indexerUrl:NU("arbitrum"),relayer:{url:BU("arbitrum")}}),RU({},LU[PU.ARBITRUM_NOVA],{rpcUrl:UU("arbitrum-nova"),indexerUrl:NU("arbitrum-nova"),relayer:{url:BU("arbitrum-nova")}}),RU({},LU[PU.OPTIMISM],{rpcUrl:UU("optimism"),indexerUrl:NU("optimism"),relayer:{url:BU("optimism")}}),RU({},LU[PU.POLYGON_ZKEVM],{rpcUrl:UU("polygon-zkevm"),indexerUrl:NU("polygon-zkevm"),relayer:{url:BU("polygon-zkevm")}}),RU({},LU[PU.GNOSIS],{rpcUrl:UU("gnosis"),indexerUrl:NU("gnosis"),relayer:{url:BU("gnosis")}})]),IU([RU({},LU[PU.RINKEBY],{rpcUrl:UU("rinkeby"),relayer:{url:BU("rinkeby")},indexerUrl:NU("rinkeby")}),RU({},LU[PU.GOERLI],{rpcUrl:UU("goerli"),relayer:{url:BU("goerli")},indexerUrl:NU("goerli")}),RU({},LU[PU.POLYGON_MUMBAI],{rpcUrl:UU("mumbai"),relayer:{url:BU("mumbai")},indexerUrl:NU("mumbai"),isDefaultChain:!0,isAuthChain:!0}),RU({},LU[PU.BSC_TESTNET],{rpcUrl:UU("bsc-testnet"),relayer:{url:BU("bsc-testnet")},indexerUrl:NU("bsc-testnet")}),RU({},LU[PU.ARBITRUM_GOERLI],{rpcUrl:UU("arbitrum-goerli"),relayer:{url:BU("arbitrum-goerli")},indexerUrl:NU("arbitrum-goerli")}),RU({},LU[PU.BASE_GOERLI],{rpcUrl:UU("base-goerli"),relayer:{url:BU("base-goerli")},indexerUrl:NU("base-goerli")})]);function jU(){return jU=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},jU.apply(this,arguments)}let DU;!function(e){e.ethCall="eth_call",e.ethGetBalance="eth_getBalance",e.ethGetCode="eth_getCode"}(DU||(DU={}));let FU,qU;jU({},{batchSize:50,timeWindow:50,contract:"0xd130B43062D875a4B7aF3f8fc036Bc6e9D3E1B3E",verbose:!1});try{FU=localStorage}catch(e){const t=new Map;FU={getItem:e=>{var r;return null!=(r=t.get(e))?r:null},setItem:(e,r)=>t.set(e,r),removeItem:e=>t.delete(e)}}function zU(e){return void 0!==e.address&&!function(e){return KU(e)||HU(e)||GU(e)}(e)}function KU(e){const t=e;return void 0!==t.signature&&void 0===t.address}function HU(e){const t=e;return void 0!==t.r&&void 0!==t.s&&void 0!==t.v&&void 0!==t.t}function GU(e){const t=e;return void 0!==t.address&&void 0!==t.signature}!function(e){e[e.EOA=0]="EOA",e[e.Address=1]="Address",e[e.Full=2]="Full"}(qU||(qU={}));const VU=e=>{if("string"==typeof e)return VU((e=>{if("string"!=typeof e)return e;const t=e.replace("0x",""),r=He.from(`0x${t.slice(0,4)}`).toNumber(),n=[];for(let e=4;e<t.length;){const r=He.from(t.slice(e,e+2)).toNumber();e+=2;const i=He.from(`0x${t.slice(e,e+2)}`).toNumber();switch(e+=2,r){case qU.Address:const r=cr(t.slice(e,e+40));e+=40,n.push({weight:i,address:r});break;case qU.EOA:const a=ke(`0x${t.slice(e,e+132)}`);e+=132;const s=Le(a.slice(0,65)),o=s.r,c=s.s,f=s.v,u=He.from(a[a.length-1]).toNumber();n.push({weight:i,signature:a,r:o,s:c,v:f,t:u});break;case qU.Full:const d=cr(t.slice(e,e+40));e+=40;const l=He.from(`0x${t.slice(e,e+4)}`).mul(2).toNumber();e+=4;const h=ke(`0x${t.slice(e,e+l)}`);e+=l,n.push({weight:i,address:d,signature:h});break;default:throw Error("Signature type not supported")}}return{threshold:r,signers:n}})(e));const t=e.signers.map((e=>{if(zU(e))return Hc(["uint8","uint8","address"],[qU.Address,e.weight,e.address]);if(HU(e))return Hc(["uint8","uint8","bytes32","bytes32","uint8","uint8"],[qU.EOA,e.weight,e.r,e.s,e.v,e.t]);if(GU(e)){const t=ke(e.signature).length;return Hc(["uint8","uint8","address","uint16","bytes"],[qU.Full,e.weight,e.address,t,e.signature])}if(KU(e))return Hc(["uint8","uint8","bytes"],[qU.EOA,e.weight,e.signature]);throw Error("Unkwnown signature part type")}));return Hc(["uint16",...Array(t.length).fill("bytes")],[e.threshold,...t])};var WU;!function(e){e.AUTHENTICATION_ERROR="AUTHENTICATION_ERROR",e.INVALID_CONFIGURATION="INVALID_CONFIGURATION",e.WALLET_CONNECTION_ERROR="WALLET_CONNECTION_ERROR",e.NOT_LOGGED_IN_ERROR="NOT_LOGGED_IN_ERROR",e.SILENT_LOGIN_ERROR="SILENT_LOGIN_ERROR",e.REFRESH_TOKEN_ERROR="REFRESH_TOKEN_ERROR",e.USER_REGISTRATION_ERROR="USER_REGISTRATION_ERROR",e.LOGOUT_ERROR="LOGOUT_ERROR",e.TRANSFER_ERROR="TRANSFER_ERROR",e.CREATE_ORDER_ERROR="CREATE_ORDER_ERROR",e.CANCEL_ORDER_ERROR="CANCEL_ORDER_ERROR",e.EXCHANGE_TRANSFER_ERROR="EXCHANGE_TRANSFER_ERROR",e.CREATE_TRADE_ERROR="CREATE_TRADE_ERROR",e.OPERATION_NOT_SUPPORTED_ERROR="OPERATION_NOT_SUPPORTED_ERROR"}(WU||(WU={}));class XU extends Error{type;constructor(e,t){super(e),this.type=t}}const $U=async(e,t)=>{try{return await e()}catch(e){const r=`${t}: ${e.message}`||"UnknownError";throw new XU(r,t)}},JU="passport_credentials",YU="pkce_state",QU="pkce_verifier";class ZU{saveCredentials(e){if(!this.areValid(e))throw Error("Invalid credentials.");localStorage.setItem(JU,JSON.stringify(e))}getCredentials(){const e=localStorage.getItem(JU);return e?JSON.parse(e):null}areValid(e){if(e){const t=this.isTokenValid(e.access_token),r=this.isTokenValid(e.id_token);return t&&r}return!1}isTokenValid(e){try{const t=DI(e).exp??0;return t>Date.now()/1e3+3600}catch(e){return!1}}clearCredentials(){localStorage.removeItem(JU)}savePKCEData(e){localStorage.setItem(YU,e.state),localStorage.setItem(QU,e.verifier)}getPKCEData(){const e=localStorage.getItem(YU),t=localStorage.getItem(QU);return e&&t?{state:e,verifier:t}:null}}const eL={headers:{"Content-Type":"application/x-www-form-urlencoded"}};function tL(e){return new Promise((t=>{setTimeout(t,e)}))}class rL{userManager;config;deviceCredentialsManager;logoutMode;constructor(e){this.config=e,this.userManager=new class{constructor(e){this._logger=new GI("UserManager"),this.settings=new vM(e),this._client=new class{constructor(e){this._logger=new GI("OidcClient"),this.settings=new iM(e),this.metadataService=new class{constructor(e){this._settings=e,this._logger=new GI("MetadataService"),this._signingKeys=null,this._metadata=null,this._metadataUrl=this._settings.metadataUrl,this._jsonService=new rM(["application/jwk-set+json"],null,this._settings.extraHeaders),this._settings.signingKeys&&(this._logger.debug("using signingKeys from settings"),this._signingKeys=this._settings.signingKeys),this._settings.metadata&&(this._logger.debug("using metadata from settings"),this._metadata=this._settings.metadata),this._settings.fetchRequestCredentials&&(this._logger.debug("using fetchRequestCredentials from settings"),this._fetchRequestCredentials=this._settings.fetchRequestCredentials)}resetSigningKeys(){this._signingKeys=null}async getMetadata(){const e=this._logger.create("getMetadata");if(this._metadata)return e.debug("using cached values"),this._metadata;if(!this._metadataUrl)throw e.throw(new Error("No authority or metadataUrl configured on settings")),null;e.debug("getting metadata from",this._metadataUrl);const t=await this._jsonService.getJson(this._metadataUrl,{credentials:this._fetchRequestCredentials});return e.debug("merging remote JSON with seed metadata"),this._metadata=Object.assign({},this._settings.metadataSeed,t),this._metadata}getIssuer(){return this._getMetadataProperty("issuer")}getAuthorizationEndpoint(){return this._getMetadataProperty("authorization_endpoint")}getUserInfoEndpoint(){return this._getMetadataProperty("userinfo_endpoint")}getTokenEndpoint(e=!0){return this._getMetadataProperty("token_endpoint",e)}getCheckSessionIframe(){return this._getMetadataProperty("check_session_iframe",!0)}getEndSessionEndpoint(){return this._getMetadataProperty("end_session_endpoint",!0)}getRevocationEndpoint(e=!0){return this._getMetadataProperty("revocation_endpoint",e)}getKeysEndpoint(e=!0){return this._getMetadataProperty("jwks_uri",e)}async _getMetadataProperty(e,t=!1){const r=this._logger.create(`_getMetadataProperty('${e}')`),n=await this.getMetadata();if(r.debug("resolved"),void 0===n[e]){if(!0===t)return void r.warn("Metadata does not contain optional property");r.throw(new Error("Metadata does not contain property "+e))}return n[e]}async getSigningKeys(){const e=this._logger.create("getSigningKeys");if(this._signingKeys)return e.debug("returning signingKeys from cache"),this._signingKeys;const t=await this.getKeysEndpoint(!1);e.debug("got jwks_uri",t);const r=await this._jsonService.getJson(t);if(e.debug("got key set",r),!Array.isArray(r.keys))throw e.throw(new Error("Missing keys on keyset")),null;return this._signingKeys=r.keys,this._signingKeys}}(this.settings),this._claimsService=new class{constructor(e){this._settings=e,this._logger=new GI("ClaimsService")}filterProtocolClaims(e){const t={...e};if(this._settings.filterProtocolClaims){let e;e=Array.isArray(this._settings.filterProtocolClaims)?this._settings.filterProtocolClaims:fM;for(const r of e)uM.includes(r)||delete t[r]}return t}mergeClaims(e,t){const r={...e};for(const[e,n]of Object.entries(t))for(const t of Array.isArray(n)?n:[n]){const n=r[e];n?Array.isArray(n)?n.includes(t)||n.push(t):r[e]!==t&&("object"==typeof t&&this._settings.mergeClaims?r[e]=this.mergeClaims(n,t):r[e]=[n,t]):r[e]=t}return r}}(this.settings),this._validator=new class{constructor(e,t,r){this._settings=e,this._metadataService=t,this._claimsService=r,this._logger=new GI("ResponseValidator"),this._userInfoService=new class{constructor(e,t){this._settings=e,this._metadataService=t,this._logger=new GI("UserInfoService"),this._getClaimsFromJwt=async e=>{const t=this._logger.create("_getClaimsFromJwt");try{const r=XI.decode(e);return t.debug("JWT decoding successful"),r}catch(e){throw t.error("Error parsing JWT response"),e}},this._jsonService=new rM(void 0,this._getClaimsFromJwt,this._settings.extraHeaders)}async getClaims(e){const t=this._logger.create("getClaims");e||this._logger.throw(new Error("No token passed"));const r=await this._metadataService.getUserInfoEndpoint();t.debug("got userinfo url",r);const n=await this._jsonService.getJson(r,{token:e,credentials:this._settings.fetchRequestCredentials});return t.debug("got claims",n),n}}(this._settings,this._metadataService),this._tokenClient=new aM(this._settings,this._metadataService)}async validateSigninResponse(e,t){const r=this._logger.create("validateSigninResponse");this._processSigninState(e,t),r.debug("state processed"),await this._processCode(e,t),r.debug("code processed"),e.isOpenId&&this._validateIdTokenAttributes(e),r.debug("tokens validated"),await this._processClaims(e,null==t?void 0:t.skipUserInfo,e.isOpenId),r.debug("claims processed")}async validateCredentialsResponse(e,t){const r=this._logger.create("validateCredentialsResponse");e.isOpenId&&this._validateIdTokenAttributes(e),r.debug("tokens validated"),await this._processClaims(e,t,e.isOpenId),r.debug("claims processed")}async validateRefreshResponse(e,t){const r=this._logger.create("validateRefreshResponse");e.userState=t.data,null!=e.session_state||(e.session_state=t.session_state),null!=e.scope||(e.scope=t.scope),e.isOpenId&&e.id_token&&(this._validateIdTokenAttributes(e,t.id_token),r.debug("ID Token validated")),e.id_token||(e.id_token=t.id_token,e.profile=t.profile);const n=e.isOpenId&&!!e.id_token;await this._processClaims(e,!1,n),r.debug("claims processed")}validateSignoutResponse(e,t){const r=this._logger.create("validateSignoutResponse");if(t.id!==e.state&&r.throw(new Error("State does not match")),r.debug("state validated"),e.userState=t.data,e.error)throw r.warn("Response was error",e.error),new QI(e)}_processSigninState(e,t){const r=this._logger.create("_processSigninState");if(t.id!==e.state&&r.throw(new Error("State does not match")),t.client_id||r.throw(new Error("No client_id on state")),t.authority||r.throw(new Error("No authority on state")),this._settings.authority!==t.authority&&r.throw(new Error("authority mismatch on settings vs. signin state")),this._settings.client_id&&this._settings.client_id!==t.client_id&&r.throw(new Error("client_id mismatch on settings vs. signin state")),r.debug("state validated"),e.userState=t.data,null!=e.scope||(e.scope=t.scope),e.error)throw r.warn("Response was error",e.error),new QI(e);t.code_verifier&&!e.code&&r.throw(new Error("Expected code in response"))}async _processClaims(e,t=!1,r=!0){const n=this._logger.create("_processClaims");if(e.profile=this._claimsService.filterProtocolClaims(e.profile),t||!this._settings.loadUserInfo||!e.access_token)return void n.debug("not loading user info");n.debug("loading user info");const i=await this._userInfoService.getClaims(e.access_token);n.debug("user info claims received from user info endpoint"),r&&i.sub!==e.profile.sub&&n.throw(new Error("subject from UserInfo response does not match subject in ID Token")),e.profile=this._claimsService.mergeClaims(e.profile,this._claimsService.filterProtocolClaims(i)),n.debug("user info claims received, updated profile:",e.profile)}async _processCode(e,t){const r=this._logger.create("_processCode");if(e.code){r.debug("Validating code");const n=await this._tokenClient.exchangeCode({client_id:t.client_id,client_secret:t.client_secret,code:e.code,redirect_uri:t.redirect_uri,code_verifier:t.code_verifier,...t.extraTokenParams});Object.assign(e,n)}else r.debug("No code to process")}_validateIdTokenAttributes(e,t){var r;const n=this._logger.create("_validateIdTokenAttributes");n.debug("decoding ID Token JWT");const i=XI.decode(null!=(r=e.id_token)?r:"");if(i.sub||n.throw(new Error("ID Token is missing a subject claim")),t){const e=XI.decode(t);i.sub!==e.sub&&n.throw(new Error("sub in id_token does not match current sub")),i.auth_time&&i.auth_time!==e.auth_time&&n.throw(new Error("auth_time in id_token does not match original auth_time")),i.azp&&i.azp!==e.azp&&n.throw(new Error("azp in id_token does not match original azp")),!i.azp&&e.azp&&n.throw(new Error("azp not in id_token, but present in original id_token"))}e.profile=i}}(this.settings,this.metadataService,this._claimsService),this._tokenClient=new aM(this.settings,this.metadataService)}async createSigninRequest({state:e,request:t,request_uri:r,request_type:n,id_token_hint:i,login_hint:a,skipUserInfo:s,nonce:o,response_type:c=this.settings.response_type,scope:f=this.settings.scope,redirect_uri:u=this.settings.redirect_uri,prompt:d=this.settings.prompt,display:l=this.settings.display,max_age:h=this.settings.max_age,ui_locales:p=this.settings.ui_locales,acr_values:b=this.settings.acr_values,resource:g=this.settings.resource,response_mode:m=this.settings.response_mode,extraQueryParams:y=this.settings.extraQueryParams,extraTokenParams:v=this.settings.extraTokenParams}){const w=this._logger.create("createSigninRequest");if("code"!==c)throw new Error("Only the Authorization Code flow (with PKCE) is supported");const _=await this.metadataService.getAuthorizationEndpoint();w.debug("Received authorization endpoint",_);const E=new class{constructor({url:e,authority:t,client_id:r,redirect_uri:n,response_type:i,scope:a,state_data:s,response_mode:o,request_type:c,client_secret:f,nonce:u,resource:d,skipUserInfo:l,extraQueryParams:h,extraTokenParams:p,disablePKCE:b,...g}){if(this._logger=new GI("SigninRequest"),!e)throw this._logger.error("ctor: No url passed"),new Error("url");if(!r)throw this._logger.error("ctor: No client_id passed"),new Error("client_id");if(!n)throw this._logger.error("ctor: No redirect_uri passed"),new Error("redirect_uri");if(!i)throw this._logger.error("ctor: No response_type passed"),new Error("response_type");if(!a)throw this._logger.error("ctor: No scope passed"),new Error("scope");if(!t)throw this._logger.error("ctor: No authority passed"),new Error("authority");this.state=new oM({data:s,request_type:c,code_verifier:!b,client_id:r,authority:t,redirect_uri:n,response_mode:o,client_secret:f,scope:a,extraTokenParams:p,skipUserInfo:l});const m=new URL(e);m.searchParams.append("client_id",r),m.searchParams.append("redirect_uri",n),m.searchParams.append("response_type",i),m.searchParams.append("scope",a),u&&m.searchParams.append("nonce",u),m.searchParams.append("state",this.state.id),this.state.code_challenge&&(m.searchParams.append("code_challenge",this.state.code_challenge),m.searchParams.append("code_challenge_method","S256")),d&&(Array.isArray(d)?d:[d]).forEach((e=>m.searchParams.append("resource",e)));for(const[e,t]of Object.entries({response_mode:o,...g,...h}))null!=t&&m.searchParams.append(e,t.toString());this.url=m.href}}({url:_,authority:this.settings.authority,client_id:this.settings.client_id,redirect_uri:u,response_type:c,scope:f,state_data:e,prompt:d,display:l,max_age:h,ui_locales:p,id_token_hint:i,login_hint:a,acr_values:b,resource:g,request:t,request_uri:r,extraQueryParams:y,extraTokenParams:v,request_type:n,response_mode:m,client_secret:this.settings.client_secret,skipUserInfo:s,nonce:o,disablePKCE:this.settings.disablePKCE});await this.clearStaleState();const A=E.state;return await this.settings.stateStore.set(A.id,A.toStorageString()),E}async readSigninResponseState(e,t=!1){const r=this._logger.create("readSigninResponseState"),n=new cM(YI.readParams(e,this.settings.response_mode));if(!n.state)throw r.throw(new Error("No state in response")),null;const i=await this.settings.stateStore[t?"remove":"get"](n.state);if(!i)throw r.throw(new Error("No matching state found in storage")),null;return{state:oM.fromStorageString(i),response:n}}async processSigninResponse(e){const t=this._logger.create("processSigninResponse"),{state:r,response:n}=await this.readSigninResponseState(e,!0);return t.debug("received state from storage; validating response"),await this._validator.validateSigninResponse(n,r),n}async processResourceOwnerPasswordCredentials({username:e,password:t,skipUserInfo:r=!1,extraTokenParams:n={}}){const i=await this._tokenClient.exchangeCredentials({username:e,password:t,...n}),a=new cM(new URLSearchParams);return Object.assign(a,i),await this._validator.validateCredentialsResponse(a,r),a}async useRefreshToken({state:e,timeoutInSeconds:t}){var r;const n=this._logger.create("useRefreshToken");let i;if(void 0===this.settings.refreshTokenAllowedScope)i=e.scope;else{const t=this.settings.refreshTokenAllowedScope.split(" ");i=((null==(r=e.scope)?void 0:r.split(" "))||[]).filter((e=>t.includes(e))).join(" ")}const a=await this._tokenClient.exchangeRefreshToken({refresh_token:e.refresh_token,scope:i,timeoutInSeconds:t}),s=new cM(new URLSearchParams);return Object.assign(s,a),n.debug("validating response",s),await this._validator.validateRefreshResponse(s,{...e,scope:i}),s}async createSignoutRequest({state:e,id_token_hint:t,request_type:r,post_logout_redirect_uri:n=this.settings.post_logout_redirect_uri,extraQueryParams:i=this.settings.extraQueryParams}={}){const a=this._logger.create("createSignoutRequest"),s=await this.metadataService.getEndSessionEndpoint();if(!s)throw a.throw(new Error("No end session endpoint")),null;a.debug("Received end session endpoint",s);const o=new class{constructor({url:e,state_data:t,id_token_hint:r,post_logout_redirect_uri:n,extraQueryParams:i,request_type:a}){if(this._logger=new GI("SignoutRequest"),!e)throw this._logger.error("ctor: No url passed"),new Error("url");const s=new URL(e);r&&s.searchParams.append("id_token_hint",r),n&&(s.searchParams.append("post_logout_redirect_uri",n),t&&(this.state=new sM({data:t,request_type:a}),s.searchParams.append("state",this.state.id)));for(const[e,t]of Object.entries({...i}))null!=t&&s.searchParams.append(e,t.toString());this.url=s.href}}({url:s,id_token_hint:t,post_logout_redirect_uri:n,state_data:e,extraQueryParams:i,request_type:r});await this.clearStaleState();const c=o.state;return c&&(a.debug("Signout request has state to persist"),await this.settings.stateStore.set(c.id,c.toStorageString())),o}async readSignoutResponseState(e,t=!1){const r=this._logger.create("readSignoutResponseState"),n=new class{constructor(e){this.state=e.get("state"),this.error=e.get("error"),this.error_description=e.get("error_description"),this.error_uri=e.get("error_uri")}}(YI.readParams(e,this.settings.response_mode));if(!n.state){if(r.debug("No state in response"),n.error)throw r.warn("Response was error:",n.error),new QI(n);return{state:void 0,response:n}}const i=await this.settings.stateStore[t?"remove":"get"](n.state);if(!i)throw r.throw(new Error("No matching state found in storage")),null;return{state:sM.fromStorageString(i),response:n}}async processSignoutResponse(e){const t=this._logger.create("processSignoutResponse"),{state:r,response:n}=await this.readSignoutResponseState(e,!0);return r?(t.debug("Received state from storage; validating response"),this._validator.validateSignoutResponse(n,r)):t.debug("No state from storage; skipping response validation"),n}clearStaleState(){return this._logger.create("clearStaleState"),sM.clearStaleState(this.settings.stateStore,this.settings.staleStateAgeInSeconds)}async revokeToken(e,t){return this._logger.create("revokeToken"),await this._tokenClient.revoke({token:e,token_type_hint:t})}}(e),this._redirectNavigator=new class{constructor(e){this._settings=e,this._logger=new GI("RedirectNavigator")}async prepare({redirectMethod:e=this._settings.redirectMethod,redirectTarget:t=this._settings.redirectTarget}){var r;this._logger.create("prepare");let n=window.self;"top"===t&&(n=null!=(r=window.top)?r:window.self);const i=n.location[e].bind(n.location);let a;return{navigate:async e=>{this._logger.create("navigate");const t=new Promise(((e,t)=>{a=t}));return i(e.url),await t},close:()=>{this._logger.create("close"),null==a||a(new Error("Redirect aborted")),n.stop()}}}}(this.settings),this._popupNavigator=new class{constructor(e){this._settings=e,this._logger=new GI("PopupNavigator")}async prepare({popupWindowFeatures:e=this._settings.popupWindowFeatures,popupWindowTarget:t=this._settings.popupWindowTarget}){return new _M({popupWindowFeatures:e,popupWindowTarget:t})}async callback(e,t=!1){this._logger.create("callback"),_M.notifyOpener(e,t)}}(this.settings),this._iframeNavigator=new class{constructor(e){this._settings=e,this._logger=new GI("IFrameNavigator")}async prepare({silentRequestTimeoutInSeconds:e=this._settings.silentRequestTimeoutInSeconds}){return new wM({silentRequestTimeoutInSeconds:e})}async callback(e){this._logger.create("callback"),wM.notifyParent(e,this._settings.iframeNotifyParentOrigin)}}(this.settings),this._events=new EM(this.settings),this._silentRenewService=new class{constructor(e){this._userManager=e,this._logger=new GI("SilentRenewService"),this._isStarted=!1,this._retryTimer=new JI("Retry Silent Renew"),this._tokenExpiring=async()=>{const e=this._logger.create("_tokenExpiring");try{await this._userManager.signinSilent(),e.debug("silent token renewal successful")}catch(t){if(t instanceof ZI)return e.warn("ErrorTimeout from signinSilent:",t,"retry in 5s"),void this._retryTimer.init(5);e.error("Error from signinSilent:",t),this._userManager.events._raiseSilentRenewError(t)}}}async start(){const e=this._logger.create("start");if(!this._isStarted){this._isStarted=!0,this._userManager.events.addAccessTokenExpiring(this._tokenExpiring),this._retryTimer.addHandler(this._tokenExpiring);try{await this._userManager.getUser()}catch(t){e.error("getUser error",t)}}}stop(){this._isStarted&&(this._retryTimer.cancel(),this._retryTimer.removeHandler(this._tokenExpiring),this._userManager.events.removeAccessTokenExpiring(this._tokenExpiring),this._isStarted=!1)}}(this),this.settings.automaticSilentRenew&&this.startSilentRenew(),this._sessionMonitor=null,this.settings.monitorSession&&(this._sessionMonitor=new class{constructor(e){this._userManager=e,this._logger=new GI("SessionMonitor"),this._start=async e=>{const t=e.session_state;if(!t)return;const r=this._logger.create("_start");if(e.profile?(this._sub=e.profile.sub,this._sid=e.profile.sid,r.debug("session_state",t,", sub",this._sub)):(this._sub=void 0,this._sid=void 0,r.debug("session_state",t,", anonymous user")),this._checkSessionIFrame)this._checkSessionIFrame.start(t);else try{const e=await this._userManager.metadataService.getCheckSessionIframe();if(e){r.debug("initializing check session iframe");const n=this._userManager.settings.client_id,i=this._userManager.settings.checkSessionIntervalInSeconds,a=this._userManager.settings.stopCheckSessionOnError,s=new class{constructor(e,t,r,n,i){this._callback=e,this._client_id=t,this._intervalInSeconds=n,this._stopOnError=i,this._logger=new GI("CheckSessionIFrame"),this._timer=null,this._session_state=null,this._message=e=>{e.origin===this._frame_origin&&e.source===this._frame.contentWindow&&("error"===e.data?(this._logger.error("error message from check session op iframe"),this._stopOnError&&this.stop()):"changed"===e.data?(this._logger.debug("changed message from check session op iframe"),this.stop(),this._callback()):this._logger.debug(e.data+" message from check session op iframe"))};const a=new URL(r);this._frame_origin=a.origin,this._frame=window.document.createElement("iframe"),this._frame.style.visibility="hidden",this._frame.style.position="fixed",this._frame.style.left="-1000px",this._frame.style.top="0",this._frame.width="0",this._frame.height="0",this._frame.src=a.href}load(){return new Promise((e=>{this._frame.onload=()=>{e()},window.document.body.appendChild(this._frame),window.addEventListener("message",this._message,!1)}))}start(e){if(this._session_state===e)return;this._logger.create("start"),this.stop(),this._session_state=e;const t=()=>{this._frame.contentWindow&&this._session_state&&this._frame.contentWindow.postMessage(this._client_id+" "+this._session_state,this._frame_origin)};t(),this._timer=setInterval(t,1e3*this._intervalInSeconds)}stop(){this._logger.create("stop"),this._session_state=null,this._timer&&(clearInterval(this._timer),this._timer=null)}}(this._callback,n,e,i,a);await s.load(),this._checkSessionIFrame=s,s.start(t)}else r.warn("no check session iframe found in the metadata")}catch(e){r.error("Error from getCheckSessionIframe:",e instanceof Error?e.message:e)}},this._stop=()=>{const e=this._logger.create("_stop");if(this._sub=void 0,this._sid=void 0,this._checkSessionIFrame&&this._checkSessionIFrame.stop(),this._userManager.settings.monitorAnonymousSession){const t=setInterval((async()=>{clearInterval(t);try{const e=await this._userManager.querySessionStatus();if(e){const t={session_state:e.session_state,profile:e.sub&&e.sid?{sub:e.sub,sid:e.sid}:null};this._start(t)}}catch(t){e.error("error from querySessionStatus",t instanceof Error?t.message:t)}}),1e3)}},this._callback=async()=>{const e=this._logger.create("_callback");try{const t=await this._userManager.querySessionStatus();let r=!0;t&&this._checkSessionIFrame?t.sub===this._sub?(r=!1,this._checkSessionIFrame.start(t.session_state),t.sid===this._sid?e.debug("same sub still logged in at OP, restarting check session iframe; session_state",t.session_state):(e.debug("same sub still logged in at OP, session state has changed, restarting check session iframe; session_state",t.session_state),this._userManager.events._raiseUserSessionChanged())):e.debug("different subject signed into OP",t.sub):e.debug("subject no longer signed into OP"),r?this._sub?this._userManager.events._raiseUserSignedOut():this._userManager.events._raiseUserSignedIn():e.debug("no change in session detected, no event to raise")}catch(t){this._sub&&(e.debug("Error calling queryCurrentSigninSession; raising signed out event",t),this._userManager.events._raiseUserSignedOut())}},e||this._logger.throw(new Error("No user manager passed")),this._userManager.events.addUserLoaded(this._start),this._userManager.events.addUserUnloaded(this._stop),this._init().catch((e=>{this._logger.error(e)}))}async _init(){this._logger.create("_init");const e=await this._userManager.getUser();if(e)this._start(e);else if(this._userManager.settings.monitorAnonymousSession){const e=await this._userManager.querySessionStatus();if(e){const t={session_state:e.session_state,profile:e.sub&&e.sid?{sub:e.sub,sid:e.sid}:null};this._start(t)}}}}(this))}get events(){return this._events}get metadataService(){return this._client.metadataService}async getUser(){const e=this._logger.create("getUser"),t=await this._loadUser();return t?(e.info("user loaded"),this._events.load(t,!1),t):(e.info("user not found in storage"),null)}async removeUser(){const e=this._logger.create("removeUser");await this.storeUser(null),e.info("user removed from storage"),this._events.unload()}async signinRedirect(e={}){this._logger.create("signinRedirect");const{redirectMethod:t,...r}=e,n=await this._redirectNavigator.prepare({redirectMethod:t});await this._signinStart({request_type:"si:r",...r},n)}async signinRedirectCallback(e=window.location.href){const t=this._logger.create("signinRedirectCallback"),r=await this._signinEnd(e);return r.profile&&r.profile.sub?t.info("success, signed in subject",r.profile.sub):t.info("no subject"),r}async signinResourceOwnerCredentials({username:e,password:t,skipUserInfo:r=!1}){const n=this._logger.create("signinResourceOwnerCredential"),i=await this._client.processResourceOwnerPasswordCredentials({username:e,password:t,skipUserInfo:r,extraTokenParams:this.settings.extraTokenParams});n.debug("got signin response");const a=await this._buildUser(i);return a.profile&&a.profile.sub?n.info("success, signed in subject",a.profile.sub):n.info("no subject"),a}async signinPopup(e={}){const t=this._logger.create("signinPopup"),{popupWindowFeatures:r,popupWindowTarget:n,...i}=e,a=this.settings.popup_redirect_uri;a||t.throw(new Error("No popup_redirect_uri configured"));const s=await this._popupNavigator.prepare({popupWindowFeatures:r,popupWindowTarget:n}),o=await this._signin({request_type:"si:p",redirect_uri:a,display:"popup",...i},s);return o&&(o.profile&&o.profile.sub?t.info("success, signed in subject",o.profile.sub):t.info("no subject")),o}async signinPopupCallback(e=window.location.href,t=!1){const r=this._logger.create("signinPopupCallback");await this._popupNavigator.callback(e,t),r.info("success")}async signinSilent(e={}){var t;const r=this._logger.create("signinSilent"),{silentRequestTimeoutInSeconds:n,...i}=e;let a=await this._loadUser();if(null==a?void 0:a.refresh_token){r.debug("using refresh token");const e=new class{constructor(e){this.refresh_token=e.refresh_token,this.id_token=e.id_token,this.session_state=e.session_state,this.scope=e.scope,this.profile=e.profile,this.data=e.state}}(a);return await this._useRefreshToken(e)}const s=this.settings.silent_redirect_uri;let o;s||r.throw(new Error("No silent_redirect_uri configured")),a&&this.settings.validateSubOnSilentRenew&&(r.debug("subject prior to silent renew:",a.profile.sub),o=a.profile.sub);const c=await this._iframeNavigator.prepare({silentRequestTimeoutInSeconds:n});return a=await this._signin({request_type:"si:s",redirect_uri:s,prompt:"none",id_token_hint:this.settings.includeIdTokenInSilentRenew?null==a?void 0:a.id_token:void 0,...i},c,o),a&&((null==(t=a.profile)?void 0:t.sub)?r.info("success, signed in subject",a.profile.sub):r.info("no subject")),a}async _useRefreshToken(e){const t=await this._client.useRefreshToken({state:e,timeoutInSeconds:this.settings.silentRequestTimeoutInSeconds}),r=new dM({...e,...t});return await this.storeUser(r),this._events.load(r),r}async signinSilentCallback(e=window.location.href){const t=this._logger.create("signinSilentCallback");await this._iframeNavigator.callback(e),t.info("success")}async signinCallback(e=window.location.href){const{state:t}=await this._client.readSigninResponseState(e);switch(t.request_type){case"si:r":return await this.signinRedirectCallback(e);case"si:p":return await this.signinPopupCallback(e);case"si:s":return await this.signinSilentCallback(e);default:throw new Error("invalid response_type in state")}}async signoutCallback(e=window.location.href,t=!1){const{state:r}=await this._client.readSignoutResponseState(e);if(r)switch(r.request_type){case"so:r":await this.signoutRedirectCallback(e);break;case"so:p":await this.signoutPopupCallback(e,t);break;case"so:s":await this.signoutSilentCallback(e);break;default:throw new Error("invalid response_type in state")}}async querySessionStatus(e={}){const t=this._logger.create("querySessionStatus"),{silentRequestTimeoutInSeconds:r,...n}=e,i=this.settings.silent_redirect_uri;i||t.throw(new Error("No silent_redirect_uri configured"));const a=await this._loadUser(),s=await this._iframeNavigator.prepare({silentRequestTimeoutInSeconds:r}),o=await this._signinStart({request_type:"si:s",redirect_uri:i,prompt:"none",id_token_hint:this.settings.includeIdTokenInSilentRenew?null==a?void 0:a.id_token:void 0,response_type:this.settings.query_status_response_type,scope:"openid",skipUserInfo:!0,...n},s);try{const e=await this._client.processSigninResponse(o.url);return t.debug("got signin response"),e.session_state&&e.profile.sub?(t.info("success for subject",e.profile.sub),{session_state:e.session_state,sub:e.profile.sub,sid:e.profile.sid}):(t.info("success, user not authenticated"),null)}catch(e){if(this.settings.monitorAnonymousSession&&e instanceof QI)switch(e.error){case"login_required":case"consent_required":case"interaction_required":case"account_selection_required":return t.info("success for anonymous user"),{session_state:e.session_state}}throw e}}async _signin(e,t,r){const n=await this._signinStart(e,t);return await this._signinEnd(n.url,r)}async _signinStart(e,t){const r=this._logger.create("_signinStart");try{const n=await this._client.createSigninRequest(e);return r.debug("got signin request"),await t.navigate({url:n.url,state:n.state.id,response_mode:n.state.response_mode,scriptOrigin:this.settings.iframeScriptOrigin})}catch(e){throw r.debug("error after preparing navigator, closing navigator window"),t.close(),e}}async _signinEnd(e,t){const r=this._logger.create("_signinEnd"),n=await this._client.processSigninResponse(e);return r.debug("got signin response"),await this._buildUser(n,t)}async _buildUser(e,t){const r=this._logger.create("_buildUser"),n=new dM(e);if(t){if(t!==n.profile.sub)throw r.debug("current user does not match user returned from signin. sub from signin:",n.profile.sub),new QI({...e,error:"login_required"});r.debug("current user matches user returned from signin")}return await this.storeUser(n),r.debug("user stored"),this._events.load(n),n}async signoutRedirect(e={}){const t=this._logger.create("signoutRedirect"),{redirectMethod:r,...n}=e,i=await this._redirectNavigator.prepare({redirectMethod:r});await this._signoutStart({request_type:"so:r",post_logout_redirect_uri:this.settings.post_logout_redirect_uri,...n},i),t.info("success")}async signoutRedirectCallback(e=window.location.href){const t=this._logger.create("signoutRedirectCallback"),r=await this._signoutEnd(e);return t.info("success"),r}async signoutPopup(e={}){const t=this._logger.create("signoutPopup"),{popupWindowFeatures:r,popupWindowTarget:n,...i}=e,a=this.settings.popup_post_logout_redirect_uri,s=await this._popupNavigator.prepare({popupWindowFeatures:r,popupWindowTarget:n});await this._signout({request_type:"so:p",post_logout_redirect_uri:a,state:null==a?void 0:{},...i},s),t.info("success")}async signoutPopupCallback(e=window.location.href,t=!1){const r=this._logger.create("signoutPopupCallback");await this._popupNavigator.callback(e,t),r.info("success")}async _signout(e,t){const r=await this._signoutStart(e,t);return await this._signoutEnd(r.url)}async _signoutStart(e={},t){var r;const n=this._logger.create("_signoutStart");try{const i=await this._loadUser();n.debug("loaded current user from storage"),this.settings.revokeTokensOnSignout&&await this._revokeInternal(i);const a=e.id_token_hint||i&&i.id_token;a&&(n.debug("setting id_token_hint in signout request"),e.id_token_hint=a),await this.removeUser(),n.debug("user removed, creating signout request");const s=await this._client.createSignoutRequest(e);return n.debug("got signout request"),await t.navigate({url:s.url,state:null==(r=s.state)?void 0:r.id})}catch(e){throw n.debug("error after preparing navigator, closing navigator window"),t.close(),e}}async _signoutEnd(e){const t=this._logger.create("_signoutEnd"),r=await this._client.processSignoutResponse(e);return t.debug("got signout response"),r}async signoutSilent(e={}){var t;const r=this._logger.create("signoutSilent"),{silentRequestTimeoutInSeconds:n,...i}=e,a=this.settings.includeIdTokenInSilentSignout?null==(t=await this._loadUser())?void 0:t.id_token:void 0,s=this.settings.popup_post_logout_redirect_uri,o=await this._iframeNavigator.prepare({silentRequestTimeoutInSeconds:n});await this._signout({request_type:"so:s",post_logout_redirect_uri:s,id_token_hint:a,...i},o),r.info("success")}async signoutSilentCallback(e=window.location.href){const t=this._logger.create("signoutSilentCallback");await this._iframeNavigator.callback(e),t.info("success")}async revokeTokens(e){const t=await this._loadUser();await this._revokeInternal(t,e)}async _revokeInternal(e,t=this.settings.revokeTokenTypes){const r=this._logger.create("_revokeInternal");if(!e)return;const n=t.filter((t=>"string"==typeof e[t]));if(n.length){for(const t of n)await this._client.revokeToken(e[t],t),r.info(`${t} revoked successfully`),"access_token"!==t&&(e[t]=null);await this.storeUser(e),r.debug("user stored"),this._events.load(e)}else r.debug("no need to revoke due to no token(s)")}startSilentRenew(){this._logger.create("startSilentRenew"),this._silentRenewService.start()}stopSilentRenew(){this._silentRenewService.stop()}get _userStoreKey(){return`user:${this.settings.authority}:${this.settings.client_id}`}async _loadUser(){const e=this._logger.create("_loadUser"),t=await this.settings.userStore.get(this._userStoreKey);return t?(e.debug("user storageString loaded"),dM.fromStorageString(t)):(e.debug("no user storageString"),null)}async storeUser(e){const t=this._logger.create("storeUser");if(e){t.debug("storing user");const r=e.toStorageString();await this.settings.userStore.set(this._userStoreKey,r)}else this._logger.debug("removing user"),await this.settings.userStore.remove(this._userStoreKey)}async clearStaleState(){await this._client.clearStaleState()}}((({oidcConfiguration:e,authenticationDomain:t})=>{const r={authority:t,redirect_uri:e.redirectUri,popup_redirect_uri:e.redirectUri,client_id:e.clientId,metadata:{authorization_endpoint:`${t}/authorize`,token_endpoint:`${t}/oauth/token`,userinfo_endpoint:`${t}/userinfo`,end_session_endpoint:`${t}/v2/logout?returnTo=${encodeURIComponent(e.logoutRedirectUri)}&client_id=${e.clientId}`},mergeClaims:!0,loadUserInfo:!0,scope:e.scope};return e.audience&&(r.extraQueryParams={audience:e.audience}),r})(e)),this.deviceCredentialsManager=new ZU,this.logoutMode=e.oidcConfiguration.logoutMode||"redirect"}static mapOidcUserToDomainModel=e=>{const t=e.profile?.passport,r={expired:e.expired,idToken:e.id_token,accessToken:e.access_token,refreshToken:e.refresh_token,profile:{sub:e.profile.sub,email:e.profile.email,nickname:e.profile.nickname}};return t?.imx_eth_address&&(r.imx={ethAddress:t?.imx_eth_address,starkAddress:t?.imx_stark_address,userAdminAddress:t?.imx_user_admin_address}),t?.zkevm_eth_address&&(r.zkEvm={ethAddress:t?.zkevm_eth_address,userAdminAddress:t?.zkevm_user_admin_address}),r};static mapDeviceTokenResponseToDomainUserModel=e=>{const t=DI(e.id_token),r={idToken:e.id_token,accessToken:e.access_token,refreshToken:e.refresh_token,profile:{sub:t.sub,email:t.email,nickname:t.nickname}};return t?.passport?.imx_eth_address&&(r.imx={ethAddress:t?.passport?.imx_eth_address,starkAddress:t?.passport?.imx_stark_address,userAdminAddress:t?.passport?.imx_user_admin_address}),r};async login(){return $U((async()=>{const e=await this.userManager.signinPopup({popupWindowFeatures:{width:410,height:450}});return rL.mapOidcUserToDomainModel(e)}),WU.AUTHENTICATION_ERROR)}async loginCallback(){return $U((async()=>this.userManager.signinPopupCallback()),WU.AUTHENTICATION_ERROR)}async loginWithDeviceFlow(){return $U((async()=>{const e=await YO.post(`${this.config.authenticationDomain}/oauth/device/code`,{client_id:this.config.oidcConfiguration.clientId,scope:this.config.oidcConfiguration.scope,audience:this.config.oidcConfiguration.audience},eL);return{code:e.data.user_code,deviceCode:e.data.device_code,url:e.data.verification_uri_complete,interval:e.data.interval}}),WU.AUTHENTICATION_ERROR)}async connectImxDeviceFlow(e,t,r){return $U((async()=>{const n=Date.now();for(;;){if(null!=r&&Date.now()-n>r)throw new Error("Timed out");await tL(1e3*t);try{const t=await this.getDeviceFlowToken(e),r=rL.mapDeviceTokenResponseToDomainUserModel(t);return r.imx?.ethAddress&&r.imx?.starkAddress&&r.imx?.userAdminAddress&&this.deviceCredentialsManager.saveCredentials(t),r}catch(e){if(!YO.isAxiosError(e))throw e;{const t=e.response?.data;switch(t.error){case"authorization_pending":case"slow_down":break;case"expired_token":throw new Error("Token expired, please log in again");case"access_denied":throw new Error("User denied access");default:throw new Error("Error getting token")}}}}throw new Error("Failed to get credentials")}),WU.AUTHENTICATION_ERROR)}async getDeviceFlowToken(e){return(await YO.post(`${this.config.authenticationDomain}/oauth/token`,{client_id:this.config.oidcConfiguration.clientId,grant_type:"urn:ietf:params:oauth:grant-type:device_code",device_code:e},eL)).data}static base64URLEncode(e){return e.toString("base64").replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}static sha256(e){return(void 0)("sha256").update(e).digest()}getPKCEAuthorizationUrl(){const e=rL.base64URLEncode((void 0)(32)),t=rL.base64URLEncode(rL.sha256(e)),r=rL.base64URLEncode((void 0)(32));return this.deviceCredentialsManager.savePKCEData({state:r,verifier:e}),`${this.config.authenticationDomain}/authorize?response_type=code&code_challenge=${t}&code_challenge_method=S256&client_id=${this.config.oidcConfiguration.clientId}&redirect_uri=${this.config.oidcConfiguration.redirectUri}&scope=${this.config.oidcConfiguration.scope}&state=${r}&audience=${this.config.oidcConfiguration.audience}`}async connectImxPKCEFlow(e,t){return $U((async()=>{const r=this.deviceCredentialsManager.getPKCEData();if(!r)throw new Error("No code verifier or state for PKCE");if(t!==r.state)throw new Error("Provided state does not match stored state");const n=await this.getPKCEToken(e,r.verifier),i=rL.mapDeviceTokenResponseToDomainUserModel(n);return i.imx?.ethAddress&&i.imx?.starkAddress&&i.imx?.userAdminAddress&&this.deviceCredentialsManager.saveCredentials(n),i}),WU.AUTHENTICATION_ERROR)}async getPKCEToken(e,t){return(await YO.post(`${this.config.authenticationDomain}/oauth/token`,{client_id:this.config.oidcConfiguration.clientId,grant_type:"authorization_code",code_verifier:t,code:e,redirect_uri:this.config.oidcConfiguration.redirectUri},eL)).data}async connectImxWithCredentials(e){return $U((async()=>{if(this.deviceCredentialsManager.areValid(e))return rL.mapDeviceTokenResponseToDomainUserModel(e);const t=e?.refresh_token??null;if(t){const e=await this.refreshToken(t);return rL.mapDeviceTokenResponseToDomainUserModel(e)}return null}),WU.AUTHENTICATION_ERROR)}async refreshToken(e){return(await YO.post(`${this.config.authenticationDomain}/oauth/token`,{client_id:this.config.oidcConfiguration.clientId,grant_type:"refresh_token",refresh_token:e},eL)).data}async logout(){return $U((async()=>"silent"===this.logoutMode?this.userManager.signoutSilent():this.userManager.signoutRedirect()),WU.LOGOUT_ERROR)}async logoutSilentCallback(e){return this.userManager.signoutSilentCallback(e)}async logoutDeviceFlow(){return $U((async()=>{this.deviceCredentialsManager.clearCredentials()}),WU.LOGOUT_ERROR)}async loginSilent(){return $U((async()=>{if(!await this.getUser())return null;const e=await this.userManager.signinSilent();return e?rL.mapOidcUserToDomainModel(e):null}),WU.SILENT_LOGIN_ERROR)}async getUser(){return $U((async()=>{const e=await this.userManager.getUser();if(e)return rL.mapOidcUserToDomainModel(e);const t=this.deviceCredentialsManager.getCredentials();return t?rL.mapDeviceTokenResponseToDomainUserModel(t):null}),WU.NOT_LOGGED_IN_ERROR)}async getUserDeviceFlow(){return $U((async()=>{const e=this.deviceCredentialsManager.getCredentials();return e?rL.mapDeviceTokenResponseToDomainUserModel(e):null}),WU.NOT_LOGGED_IN_ERROR)}checkStoredDeviceFlowCredentials(){return this.deviceCredentialsManager.getCredentials()}}class nL{config;constructor(e){this.config=e}async login(e,t){return $U((async()=>{const r=new SN(this.config.magicPublishableApiKey,{extensions:[new xN],network:t});return await r.openid.loginWithOIDC({jwt:e,providerId:this.config.magicProviderId}),r.rpcProvider}),WU.WALLET_CONNECTION_ERROR)}}const iL=1e3,aL=3,sL=async(e,t)=>{const{retries:r=aL,interval:n=iL,finalErr:i=Error("Retry failed"),finallyFn:a=(()=>{})}=t||{};try{return await e()}catch(t){return r<=0?Promise.reject(i):(await(s=n,new Promise((e=>{setTimeout((()=>e()),s)}))),sL(e,{retries:r-1,finalErr:i,finallyFn:a}))}finally{r<=0&&a()}var s};var oL,cL;e.ProviderErrorCode=void 0,(oL=e.ProviderErrorCode||(e.ProviderErrorCode={}))[oL.USER_REJECTED_REQUEST=4001]="USER_REJECTED_REQUEST",oL[oL.UNAUTHORIZED=4100]="UNAUTHORIZED",oL[oL.UNSUPPORTED_METHOD=4200]="UNSUPPORTED_METHOD",oL[oL.DISCONNECTED=4900]="DISCONNECTED",e.RpcErrorCode=void 0,(cL=e.RpcErrorCode||(e.RpcErrorCode={}))[cL.RPC_SERVER_ERROR=-32e3]="RPC_SERVER_ERROR",cL[cL.INVALID_REQUEST=-32600]="INVALID_REQUEST",cL[cL.METHOD_NOT_FOUND=-32601]="METHOD_NOT_FOUND",cL[cL.INVALID_PARAMS=-32602]="INVALID_PARAMS",cL[cL.INTERNAL_ERROR=-32603]="INTERNAL_ERROR",cL[cL.PARSE_ERROR=-32700]="PARSE_ERROR",cL[cL.USER_REJECTED_REQUEST=-32003]="USER_REJECTED_REQUEST";class fL extends Error{message;code;constructor(e,t){super(t),this.message=t,this.code=e}}const uL=e=>He.from(e).toString();class dL{transactionAPI;confirmationScreen;imxEtherAddress;constructor({imxPublicApiDomain:e,accessToken:t,confirmationScreen:r,imxEtherAddress:n}){this.confirmationScreen=r,this.transactionAPI=new yU(new vU({accessToken:t,basePath:e})),this.imxEtherAddress=n}loading(e){this.confirmationScreen.loading(e)}async validate({payloadHash:e}){if(!(await sL((async()=>this.transactionAPI.getTransactionByID({transactionID:e,chainType:"starkex"})),{finallyFn:()=>{this.confirmationScreen.closeWindow()}})).data.id)throw new Error("Transaction doesn't exists");const t=await this.transactionAPI.evaluateTransaction({id:e,transactionEvaluationRequest:{chainType:"starkex"}}),{confirmationRequired:r}=t.data;if(r){if(!(await this.confirmationScreen.startGuardianTransaction(e,this.imxEtherAddress,wU)).confirmed)throw new Error("Transaction rejected by user")}else this.confirmationScreen.closeWindow()}async evaluateEVMTransaction({chainId:t,nonce:r,user:n,metaTransactions:i}){const a={Authorization:`Bearer ${n.accessToken}`},s=(t=>{try{return t.map((e=>({delegateCall:!0===e.delegateCall,revertOnError:!0===e.revertOnError,gasLimit:e.gasLimit?uL(e.gasLimit):"0",target:e.to??_r,value:e.value?uL(e.value):"0",data:e.data?e.data.toString():"0x"})))}catch(t){const r=t instanceof Error?t.message:String(t);throw new fL(e.RpcErrorCode.INVALID_PARAMS,`Transaction failed to parsing: ${r}`)}})(i);try{return(await this.transactionAPI.evaluateTransaction({id:"evm",transactionEvaluationRequest:{chainType:"evm",chainId:t,transactionData:{nonce:r,userAddress:n.zkEvm.ethAddress,metaTransactions:s}}},{headers:a})).data}catch(t){const r=t instanceof Error?t.message:String(t);throw new fL(e.RpcErrorCode.INTERNAL_ERROR,`Transaction failed to validate with error: ${r}`)}}async validateEVMTransaction({chainId:t,nonce:r,user:n,metaTransactions:i}){const a=await this.evaluateEVMTransaction({chainId:t,nonce:r,user:n,metaTransactions:i}),{confirmationRequired:s,transactionId:o}=a;if(s&&o){if(!(await this.confirmationScreen.startGuardianTransaction(o,this.imxEtherAddress,_U,t)).confirmed)throw new fL(e.RpcErrorCode.USER_REJECTED_REQUEST,"Transaction rejected by user ")}else this.confirmationScreen.closeWindow()}}const lL="ERC721";const hL="ERC721";class pL{user;starkSigner;immutableXClient;confirmationScreen;guardianClient;constructor({user:e,starkSigner:t,immutableXClient:r,imxPublicApiDomain:n,confirmationScreen:i}){this.user=e,this.starkSigner=t,this.immutableXClient=r,this.confirmationScreen=i,this.guardianClient=new dL({imxPublicApiDomain:n,accessToken:e.accessToken,confirmationScreen:i,imxEtherAddress:e.imx.ethAddress})}async transfer(e){return async function({request:e,transfersApi:t,starkSigner:r,user:n,guardianClient:i}){return $U((async()=>{i.loading();const a=e.type===hL?"1":e.amount,s={sender:n.imx.ethAddress,token:SU(e),amount:a,receiver:e.receiver},o={Authorization:`Bearer ${n.accessToken}`},c=await t.getSignableTransferV1({getSignableTransferRequest:s},{headers:o});await i.validate({payloadHash:c.data.payload_hash});const f=c.data,{payload_hash:u}=f,d=await r.signMessage(u),l=await r.getAddress(),h={createTransferRequest:{sender_stark_key:f.sender_stark_key||l,sender_vault_id:f.sender_vault_id,receiver_stark_key:f.receiver_stark_key,receiver_vault_id:f.receiver_vault_id,asset_id:f.asset_id,amount:f.amount,nonce:f.nonce,expiration_timestamp:f.expiration_timestamp,stark_signature:d}},{data:p}=await t.createTransferV1(h,{headers:o});return{sent_signature:p.sent_signature,status:p.status?.toString(),time:p.time,transfer_id:p.transfer_id}}),WU.TRANSFER_ERROR)}({request:e,user:this.user,starkSigner:this.starkSigner,transfersApi:this.immutableXClient.transfersApi,guardianClient:this.guardianClient})}registerOffchain(){throw new XU("Operation not supported",WU.OPERATION_NOT_SUPPORTED_ERROR)}isRegisteredOnchain(){throw new XU("Operation not supported",WU.OPERATION_NOT_SUPPORTED_ERROR)}createOrder(e){return async function({starkSigner:e,user:t,request:r,ordersApi:n,guardianClient:i}){return $U((async()=>{i.loading();const{ethAddress:a}=t.imx,s=r.sell.type===lL?"1":r.sell.amount,o=r.buy.type===lL?"1":r.buy.amount,c={Authorization:`Bearer ${t.accessToken}`},f={user:a,amount_buy:o,token_buy:SU(r.buy),amount_sell:s,token_sell:SU(r.sell),fees:r.fees,split_fees:!0,expiration_timestamp:r.expiration_timestamp},u=await n.getSignableOrder({getSignableOrderRequestV3:f},{headers:c});await i.validate({payloadHash:u.data.payload_hash});const{payload_hash:d}=u.data,l=await e.signMessage(d),h=u.data,p={createOrderRequest:{include_fees:!0,fees:r.fees,stark_signature:l,amount_buy:h.amount_buy,amount_sell:h.amount_sell,asset_id_buy:h.asset_id_buy,asset_id_sell:h.asset_id_sell,expiration_timestamp:h.expiration_timestamp,nonce:h.nonce,stark_key:h.stark_key,vault_id_buy:h.vault_id_buy,vault_id_sell:h.vault_id_sell}};return{...(await n.createOrderV3(p,{headers:c})).data}}),WU.CREATE_ORDER_ERROR)}({request:e,user:this.user,starkSigner:this.starkSigner,ordersApi:this.immutableXClient.ordersApi,guardianClient:this.guardianClient})}cancelOrder(e){return async function({user:e,starkSigner:t,request:r,ordersApi:n,guardianClient:i}){return $U((async()=>{i.loading();const a={order_id:r.order_id},s={Authorization:`Bearer ${e.accessToken}`},o=await n.getSignableCancelOrderV3({getSignableCancelOrderRequest:a},{headers:s});await i.validate({payloadHash:o.data.payload_hash});const{payload_hash:c}=o.data,f=await t.signMessage(c),u=await n.cancelOrderV3({id:r.order_id.toString(),cancelOrderRequest:{order_id:r.order_id,stark_signature:f}},{headers:s});return{order_id:u.data.order_id,status:u.data.status}}),WU.CANCEL_ORDER_ERROR)}({request:e,user:this.user,starkSigner:this.starkSigner,ordersApi:this.immutableXClient.ordersApi,guardianClient:this.guardianClient})}createTrade(e){return async function({request:e,tradesApi:t,user:r,starkSigner:n,guardianClient:i}){return $U((async()=>{i.loading();const{ethAddress:a}=r.imx,s={expiration_timestamp:e.expiration_timestamp,fees:e.fees,order_id:e.order_id,user:a},o={Authorization:`Bearer ${r.accessToken}`},c=await t.getSignableTrade({getSignableTradeRequest:s},{headers:o});await i.validate({payloadHash:c.data.payload_hash});const{payload_hash:f}=c.data,u=await n.signMessage(f),{data:d}=c,l={createTradeRequest:{include_fees:!0,fees:e?.fees,stark_signature:u,order_id:e?.order_id,fee_info:d.fee_info,amount_buy:d.amount_buy,amount_sell:d.amount_sell,asset_id_buy:d.asset_id_buy,asset_id_sell:d.asset_id_sell,expiration_timestamp:d.expiration_timestamp,nonce:d.nonce,stark_key:d.stark_key,vault_id_buy:d.vault_id_buy,vault_id_sell:d.vault_id_sell}},{data:h}=await t.createTradeV3(l,{headers:o});return h}),WU.CREATE_TRADE_ERROR)}({request:e,user:this.user,starkSigner:this.starkSigner,tradesApi:this.immutableXClient.tradesApi,guardianClient:this.guardianClient})}batchNftTransfer(e){return async function({user:e,starkSigner:t,request:r,transfersApi:n,guardianClient:i}){return $U((async()=>{i.loading({width:480,height:784});const{ethAddress:a}=e.imx,s={sender_ether_key:a,signable_requests:r.map((e=>({amount:"1",token:SU({type:hL,tokenId:e.tokenId,tokenAddress:e.tokenAddress}),receiver:e.receiver})))},o={Authorization:`Bearer ${e.accessToken}`},c=await n.getSignableTransfer({getSignableTransferRequestV2:s},{headers:o});await i.validate({payloadHash:c.data.signable_responses[0]?.payload_hash});const f=await Promise.all(c.data.signable_responses.map((async e=>{const r=await t.signMessage(e.payload_hash);return{sender_vault_id:e.sender_vault_id,receiver_stark_key:e.receiver_stark_key,receiver_vault_id:e.receiver_vault_id,asset_id:e.asset_id,amount:e.amount,nonce:e.nonce,expiration_timestamp:e.expiration_timestamp,stark_signature:r}}))),u={sender_stark_key:c.data.sender_stark_key,requests:f},d=await n.createTransfer({createTransferRequestV2:u},{headers:o});return{transfer_ids:d?.data.transfer_ids}}),WU.TRANSFER_ERROR)}({request:e,user:this.user,starkSigner:this.starkSigner,transfersApi:this.immutableXClient.transfersApi,guardianClient:this.guardianClient})}exchangeTransfer(e){return async function({user:e,starkSigner:t,request:r,exchangesApi:n}){return $U((async()=>{const{ethAddress:i}=e.imx,a=r.amount,s=await n.getExchangeSignableTransfer({id:r.transactionID,getSignableTransferRequest:{sender:i,token:SU(r),amount:a,receiver:r.receiver}}),o=await t.getAddress(),{payload_hash:c}=s.data,f=await t.signMessage(c),u={sender_stark_key:s.data.sender_stark_key||o,sender_vault_id:s.data.sender_vault_id,receiver_stark_key:s.data.receiver_stark_key,receiver_vault_id:s.data.receiver_vault_id,asset_id:s.data.asset_id,amount:s.data.amount,nonce:s.data.nonce,expiration_timestamp:s.data.expiration_timestamp,stark_signature:f},d={Authorization:`Bearer ${e.accessToken}`},l=await n.createExchangeTransfer({id:r.transactionID,createTransferRequest:u},{headers:d});return{sent_signature:l?.data.sent_signature,status:l?.data.status?.toString(),time:l?.data.time,transfer_id:l?.data.transfer_id}}),WU.EXCHANGE_TRANSFER_ERROR)}({request:e,user:this.user,starkSigner:this.starkSigner,exchangesApi:this.immutableXClient.exchangeApi})}deposit(e){throw new XU("Operation not supported",WU.OPERATION_NOT_SUPPORTED_ERROR)}prepareWithdrawal(e){throw new XU("Operation not supported",WU.OPERATION_NOT_SUPPORTED_ERROR)}completeWithdrawal(e,t){throw new XU("Operation not supported",WU.OPERATION_NOT_SUPPORTED_ERROR)}getAddress(){return Promise.resolve(this.user.imx.ethAddress)}}class bL{authManager;config;confirmationScreen;immutableXClient;magicAdapter;constructor({authManager:e,config:t,confirmationScreen:r,immutableXClient:n,magicAdapter:i}){this.authManager=e,this.config=t,this.confirmationScreen=r,this.immutableXClient=n,this.magicAdapter=i}async getProvider(){const e=await this.authManager.login();return this.createProviderInstance(e)}async getProviderSilent(){const e=await this.authManager.loginSilent();return e?this.createProviderInstance(e):null}async getProviderWithDeviceFlow(e,t,r){const n=await this.authManager.connectImxDeviceFlow(e,t,r);return this.createProviderInstance(n)}async getProviderWithPKCEFlow(e,t){const r=await this.authManager.connectImxPKCEFlow(e,t);return this.createProviderInstance(r)}async getProviderWithCredentials(e){const t=await this.authManager.connectImxWithCredentials(e);return t?this.createProviderInstance(t):null}async createProviderInstance(e){if(!e.idToken)throw new XU("Failed to initialise",WU.WALLET_CONNECTION_ERROR);const t=await this.magicAdapter.login(e.idToken,this.config.network),r=new Lc(t).getSigner(),n=await(async e=>$U((async()=>JA(await lR(e))),WU.WALLET_CONNECTION_ERROR))(r);if(!e.imx?.ethAddress){const t=await this.registerStarkEx(r,n,e.accessToken);return new pL({user:t,starkSigner:n,immutableXClient:this.immutableXClient,imxPublicApiDomain:this.config.imxPublicApiDomain,confirmationScreen:this.confirmationScreen})}return new pL({user:e,starkSigner:n,immutableXClient:this.immutableXClient,imxPublicApiDomain:this.config.imxPublicApiDomain,confirmationScreen:this.confirmationScreen})}async registerStarkEx(e,t,r){return $U((async()=>{await async function({ethSigner:e,starkSigner:t,usersApi:r},n){return $U((async()=>{const i=await e.getAddress(),a=await t.getAddress(),s=await r.getSignableRegistrationOffchain({getSignableRegistrationRequest:{ether_key:i,stark_key:a}}),{signable_message:o,payload_hash:c}=s.data,f=await AU(o,e),u=await t.signMessage(c);return(await r.registerPassportUser({authorization:`Bearer ${n}`,registerPassportUserRequest:{eth_signature:f,ether_key:i,stark_signature:u,stark_key:a}})).statusText}),WU.USER_REGISTRATION_ERROR)}({ethSigner:e,starkSigner:t,usersApi:this.immutableXClient.usersApi},r);return await sL((async()=>{const e=await this.authManager.loginSilent();return!!e?.imx?e:Promise.reject(new Error("user wallet addresses not exist"))}))}),WU.REFRESH_TOKEN_ERROR)}}var gL;e.Networks=void 0,(gL=e.Networks||(e.Networks={})).PRODUCTION="mainnet",gL.SANDBOX="goerli";const mL=(e,t,r)=>{const n=t.map((t=>!e[t]&&t)).filter((e=>e)).join(", ");if(""!==n){throw new XU(r?`${r} - ${n} cannot be null`:`${n} cannot be null`,WU.INVALID_CONFIGURATION)}};class yL{network;authenticationDomain;passportDomain;imxPublicApiDomain;magicPublishableApiKey;magicProviderId;oidcConfiguration;baseConfig;zkEvmChainId;zkEvmRpcUrl;relayerUrl;multiRollupConfig;constructor({baseConfig:t,overrides:r,...n}){if(mL(n,["clientId","logoutRedirectUri","redirectUri"]),this.oidcConfiguration=n,this.baseConfig=t,r)mL(r,["network","authenticationDomain","passportDomain","magicPublishableApiKey","magicProviderId","zkEvmRpcUrl","zkEvmChainId","relayerUrl","imxPublicApiDomain","indexerMrBasePath","orderBookMrBasePath","passportMrBasePath"],"overrides"),this.network=r.network,this.authenticationDomain=r.authenticationDomain,this.passportDomain=r.passportDomain,this.imxPublicApiDomain=r.imxPublicApiDomain,this.magicPublishableApiKey=r.magicPublishableApiKey,this.magicProviderId=r.magicProviderId,this.zkEvmRpcUrl=r.zkEvmRpcUrl,this.zkEvmChainId=r.zkEvmChainId,this.relayerUrl=r.relayerUrl,this.multiRollupConfig={indexer:SI({basePath:r.indexerMrBasePath}),orderBook:SI({basePath:r.orderBookMrBasePath}),passport:SI({basePath:r.passportMrBasePath})};else switch(t.environment){case e.Environment.PRODUCTION:this.network=e.Networks.PRODUCTION,this.authenticationDomain="https://auth.immutable.com",this.magicPublishableApiKey="pk_live_10F423798A540ED7",this.magicProviderId="fSMzaRQ4O7p4fttl7pCyGVtJS_G70P8SNsLXtPPGHo0=",this.passportDomain="https://passport.immutable.com",this.imxPublicApiDomain="https://api.immutable.com",this.zkEvmRpcUrl="",this.zkEvmChainId="",this.relayerUrl="https://api.immutable.com/relayer-mr",this.multiRollupConfig=kI();break;case e.Environment.SANDBOX:default:this.network=e.Networks.SANDBOX,this.authenticationDomain="https://auth.immutable.com",this.magicPublishableApiKey="pk_live_10F423798A540ED7",this.magicProviderId="fSMzaRQ4O7p4fttl7pCyGVtJS_G70P8SNsLXtPPGHo0=",this.passportDomain="https://passport.sandbox.immutable.com",this.imxPublicApiDomain="https://api.sandbox.immutable.com",this.zkEvmRpcUrl="https://rpc.testnet.immutable.com",this.zkEvmChainId="eip155:13372",this.relayerUrl="https://api.sandbox.immutable.com/relayer-mr",this.multiRollupConfig=xI()}}}var vL,wL,_L;!function(e){e.CONFIRMATION_WINDOW_READY="confirmation_window_ready",e.TRANSACTION_CONFIRMED="transaction_confirmed",e.TRANSACTION_ERROR="transaction_error"}(vL||(vL={})),function(e){e.TRANSACTION_START="transaction_start"}(wL||(wL={})),function(e){e.cancelOrder="delete:v1/orders",e.createOrder="post:v1/orders",e.createTrade="post:v1/trades",e.createTransfer="post:v1/transfers",e.createBatchTransfer="post:v2/transfers"}(_L||(_L={}));const EL="imx_passport_confirmation",AL=({url:e,title:t,width:r,height:n})=>{const i=Math.max(0,Math.round(window.screenX+(window.outerWidth-r)/2)),a=Math.max(0,Math.round(window.screenY+(window.outerHeight-n)/2)),s=window.open(e,t,`\n scrollbars=yes,\n width=${r}, \n height=${n}, \n top=${a}, \n left=${i}\n `);if(!s)throw new Error("Failed to open confirmation screen");return s.focus(),s},SL="Confirm this transaction";class kL{config;confirmationWindow;constructor(e){this.config=e}postMessage(e,t,r){e.postMessage({eventType:EL,accessToken:t,...r},this.config.passportDomain)}startTransaction(e,t,r){return new Promise(((n,i)=>{const a=({data:r,origin:a})=>{if(a===this.config.passportDomain&&r.eventType===EL)switch(r.messageType){case vL.CONFIRMATION_WINDOW_READY:this.postMessage(s,e,{messageType:wL.TRANSACTION_START,messageData:t});break;case vL.TRANSACTION_CONFIRMED:n({confirmed:!0});break;case vL.TRANSACTION_ERROR:i(new Error("Transaction error"));break;default:i(new Error("Unsupported message type"))}};window.addEventListener("message",a);const s=AL({url:`${this.config.passportDomain}/transaction-confirmation`,title:SL,width:r?.width||480,height:r?.height||380}),o=setInterval((()=>{s.closed&&(clearInterval(o),window.removeEventListener("message",a),n({confirmed:!1}))}),1e3)}))}startGuardianTransaction(e,t,r,n){return new Promise(((i,a)=>{const s=({data:e,origin:t})=>{if(t===this.config.passportDomain&&e.eventType===EL)switch(e.messageType){case vL.CONFIRMATION_WINDOW_READY:break;case vL.TRANSACTION_CONFIRMED:i({confirmed:!0});break;case vL.TRANSACTION_ERROR:a(new Error("Transaction error"));break;default:a(new Error("Unsupported message type"))}};if(window.addEventListener("message",s),!this.confirmationWindow)return void i({confirmed:!1});let o="";o=r===wU?`${this.config.passportDomain}/transaction-confirmation/transaction.html?transactionId=${e}&imxEtherAddress=${t}&chainType=starkex`:`${this.config.passportDomain}/transaction-confirmation/zkevm?transactionId=${e}&imxEtherAddress=${t}&chainType=evm&chainId=${n}`,this.confirmationWindow.location.href=o;const c=setInterval((()=>{this.confirmationWindow?.closed&&(clearInterval(c),window.removeEventListener("message",s),i({confirmed:!1}))}),1e3)}))}loading(e){this.confirmationWindow=AL({url:`${this.config.passportDomain}/transaction-confirmation/loading.html`,title:SL,width:e?.width||480,height:e?.height||380})}closeWindow(){this.confirmationWindow?.close()}}var xL;!function(e){e.PENDING="PENDING",e.SUBMITTED="SUBMITTED",e.SUCCESSFUL="SUCCESSFUL",e.REVERTED="REVERTED",e.FAILED="FAILED"}(xL||(xL={})),e.ProviderEvent=void 0,(e.ProviderEvent||(e.ProviderEvent={})).ACCOUNTS_CHANGED="accountsChanged";class TL{emitter=new qp;emit(e,...t){this.emitter.emit(e,...t)}on(e,t){this.emitter.on(e,t)}removeListener(e,t){this.emitter.removeListener(e,t)}}class RL{config;user;constructor({config:e,user:t}){this.config=e,this.user=t}async postToRelayer(e){const t={id:1,jsonrpc:"2.0",...e},r=await fetch(`${this.config.relayerUrl}/v1/transactions`,{method:"POST",headers:{Authorization:`Bearer ${this.user.accessToken}`,"Content-Type":"application/json"},body:JSON.stringify(t)}),n=await r.json();if(n.error)throw n.error;return n}async ethSendTransaction(e,t){const r={method:"eth_sendTransaction",params:[{to:e,data:t,chainId:this.config.zkEvmChainId.toString()}]},{result:n}=await this.postToRelayer(r);return n}async imGetTransactionByHash(e){const t={method:"im_getTransactionByHash",params:[e]},{result:r}=await this.postToRelayer(t);return r}async imGetFeeOptions(e,t){const r={method:"im_getFeeOptions",params:[{userAddress:e,data:t,chainId:this.config.zkEvmChainId.toString()}]},{result:n}=await this.postToRelayer(r);return n}}const OL=async({authManager:t,config:r,magicAdapter:n,multiRollupApiClients:i})=>{const a=await t.getUser()||await t.login();if(!a.idToken)throw new Error("User is missing idToken");const s=await n.login(a.idToken,r.network);if(!a.zkEvm){const r=await async function({authManager:t,magicProvider:r,multiRollupApiClients:n,accessToken:i}){const a=new Lc(r).getSigner(),s=await a.getAddress(),o=await AU("Only sign this message from Immutable Passport",a),c={Authorization:`Bearer ${i}`};try{await n.passportApi.createCounterfactualAddress({createCounterfactualAddressRequest:{ethereumAddress:s,ethereumSignature:o}},{headers:c})}catch(t){throw new fL(e.RpcErrorCode.INTERNAL_ERROR,`Failed to create counterfactual address: ${t}`)}const f=await t.loginSilent();if(!f?.zkEvm)throw new fL(e.RpcErrorCode.INTERNAL_ERROR,"Failed to refresh user details");return f}({authManager:t,magicProvider:s,multiRollupApiClients:i,accessToken:a.accessToken});return{user:r,magicProvider:s}}return{user:a,magicProvider:s}};const IL=async(e,t,r,n,i)=>{const a=e.map((e=>({delegateCall:!0===e.delegateCall,revertOnError:!0===e.revertOnError,gasLimit:e.gasLimit??Ar,target:e.to??_r,value:e.value??Ar,data:e.data??[]})));const s=function(e,t){return $t(Fr.encode(["uint256","tuple(\n bool delegateCall,\n bool revertOnError,\n uint256 gasLimit,\n address target,\n uint256 value,\n bytes data\n)[]"],[e,t]))}(t,a),o=ke($t(Hc(["string","uint256","address","bytes32"],["",r,n,s]))),c=await i.signMessage(o),f=VU({threshold:1,signers:[{weight:1,signature:`${c}02`}]}),u=new zn(kU.mainModule.abi);return u.encodeFunctionData(u.getFunction("execute"),[a,t,f])},ML=async({params:t,magicProvider:r,jsonRpcProvider:n,relayerClient:i,guardianClient:a,config:s,user:o})=>{a.loading({width:480,height:520});const c=t[0];if(!c.to)throw new fL(e.RpcErrorCode.INVALID_PARAMS,'eth_sendTransaction requires a "to" field');const f=(e=>{const t=e.split(":");if(2!==t.length)throw new Error("Invalid configuration, chain ID is not in CAIP-2 format");return He.from(t[1])})(s.zkEvmChainId),u=new Lc(r).getSigner(),d=await(async(e,t)=>{const r=await e.send("eth_getCode",[t,"latest"]);if(r&&"0x"!==r)return new mo(t,kU.mainModule.abi,e).nonce();return 0})(n,o.zkEvm.ethAddress),l={to:c.to,data:c.data,nonce:d,value:c.value,revertOnError:!0},h=await IL([l],d,f,o.zkEvm.ethAddress,u),p=(await i.imGetFeeOptions(o.zkEvm.ethAddress,h)).find((e=>"IMX"===e.tokenSymbol));if(!p)throw new Error("Failed to retrieve fees for IMX token");const b={nonce:d,to:p.recipientAddress,value:p.tokenPrice,revertOnError:!0};await a.validateEVMTransaction({chainId:s.zkEvmChainId,nonce:uL(d),user:o,metaTransactions:[l,b]});const g=await IL([l,b],d,f,o.zkEvm.ethAddress,u),m=await i.ethSendTransaction(o.zkEvm.ethAddress,g),y=await sL((async()=>{const e=await i.imGetTransactionByHash(m);if(e.status===xL.PENDING)throw new Error;return e}),{retries:30,interval:1e3,finalErr:new fL(e.RpcErrorCode.RPC_SERVER_ERROR,"transaction hash not generated in time")});if(![xL.SUBMITTED,xL.SUCCESSFUL].includes(y.status))throw new fL(e.RpcErrorCode.RPC_SERVER_ERROR,`Transaction failed to submit with status ${y.status}`);return y.hash};class CL{authManager;config;confirmationScreen;magicAdapter;transactionAPI;multiRollupApiClients;jsonRpcProvider;eventEmitter;guardianClient;relayerClient;magicProvider;user;constructor({authManager:e,magicAdapter:t,config:r,confirmationScreen:n,multiRollupApiClients:i}){this.authManager=e,this.magicAdapter=t,this.config=r,this.confirmationScreen=n,this.transactionAPI=new yU(new vU({basePath:this.config.imxPublicApiDomain})),this.jsonRpcProvider=new Pc(this.config.zkEvmRpcUrl),this.multiRollupApiClients=i,this.eventEmitter=new TL}isLoggedIn(){return void 0!==this.magicProvider&&void 0!==this.user&&void 0!==this.relayerClient&&void 0!==this.guardianClient}async performRequest(t){switch(t.method){case"eth_requestAccounts":{if(this.isLoggedIn())return[this.user.zkEvm.ethAddress];const{magicProvider:t,user:r}=await OL({authManager:this.authManager,config:this.config,magicAdapter:this.magicAdapter,multiRollupApiClients:this.multiRollupApiClients});return this.user=r,this.magicProvider=t,this.relayerClient=new RL({config:this.config,user:this.user}),this.guardianClient=new dL({imxPublicApiDomain:this.config.imxPublicApiDomain,accessToken:this.user.accessToken,confirmationScreen:this.confirmationScreen,imxEtherAddress:this.user.zkEvm.ethAddress}),this.eventEmitter.emit(e.ProviderEvent.ACCOUNTS_CHANGED,[this.user.zkEvm.ethAddress]),[this.user.zkEvm.ethAddress]}case"eth_sendTransaction":if(!this.isLoggedIn())throw new fL(e.ProviderErrorCode.UNAUTHORIZED,"Unauthorised - call eth_requestAccounts first");return ML({params:t.params||[],magicProvider:this.magicProvider,guardianClient:this.guardianClient,jsonRpcProvider:this.jsonRpcProvider,config:this.config,relayerClient:this.relayerClient,user:this.user});case"eth_accounts":return this.isLoggedIn()?[this.user.zkEvm.ethAddress]:[];case"eth_gasPrice":case"eth_getBalance":case"eth_getStorageAt":case"eth_estimateGas":case"eth_call":case"eth_blockNumber":case"eth_chainId":case"eth_getBlockByHash":case"eth_getBlockByNumber":case"eth_getTransactionByHash":case"eth_getTransactionReceipt":case"eth_getTransactionCount":return this.jsonRpcProvider.send(t.method,t.params||[]);default:throw new fL(e.ProviderErrorCode.UNSUPPORTED_METHOD,"Method not supported")}}async performJsonRpcRequest(t){const{id:r,jsonrpc:n}=t;try{return{id:r,jsonrpc:n,result:await this.performRequest(t)}}catch(t){let i;return i=t instanceof fL?t:t instanceof Error?new fL(e.RpcErrorCode.INTERNAL_ERROR,t.message):new fL(e.RpcErrorCode.INTERNAL_ERROR,"Internal error"),{id:r,jsonrpc:n,error:i}}}async request(t){try{return this.performRequest(t)}catch(t){if(t instanceof fL)throw t;if(t instanceof Error)throw new fL(e.RpcErrorCode.INTERNAL_ERROR,t.message);throw new fL(e.RpcErrorCode.INTERNAL_ERROR,"Internal error")}}sendAsync(e,t){if(!t)throw new Error("No callback provided");Array.isArray(e)?Promise.all(e.map(this.performJsonRpcRequest)).then((e=>{t(null,e)})).catch((e=>{t(e,[])})):this.performJsonRpcRequest(e).then((e=>{t(null,e)})).catch((e=>{t(e,null)}))}async send(t,r,n){if("string"==typeof t)return"function"==typeof r?this.sendAsync({method:t,params:[]},r):n?this.sendAsync({method:t,params:Array.isArray(r)?r:[]},n):this.request({method:t,params:Array.isArray(r)?r:[]});if("function"==typeof r)return this.sendAsync(t,r);if(!Array.isArray(t)&&"object"==typeof t)return this.performJsonRpcRequest(t);throw new fL(e.RpcErrorCode.INVALID_REQUEST,"Invalid request")}on(e,t){this.eventEmitter.on(e,t)}removeListener(e,t){this.eventEmitter.removeListener(e,t)}}var PL=n((function({mustBeMetaMask:e=!1,silent:t=!1,timeout:r=3e3}={}){!function(){if("boolean"!=typeof e)throw new Error("@metamask/detect-provider: Expected option 'mustBeMetaMask' to be a boolean.");if("boolean"!=typeof t)throw new Error("@metamask/detect-provider: Expected option 'silent' to be a boolean.");if("number"!=typeof r)throw new Error("@metamask/detect-provider: Expected option 'timeout' to be a number.")}();let n=!1;return new Promise((i=>{function a(){if(n)return;n=!0,window.removeEventListener("ethereum#initialized",a);const{ethereum:r}=window;if(!r||e&&!r.isMetaMask){const n=e&&r?"Non-MetaMask window.ethereum detected.":"Unable to detect window.ethereum.";!t&&console.error("@metamask/detect-provider:",n),i(null)}else i(r)}window.ethereum?a():(window.addEventListener("ethereum#initialized",a,{once:!0}),setTimeout((()=>{a()}),r))}))}));async function NL(e,t){if(!function(e,t){return e===t.ethConfiguration.chainID}(await e.getChainId(),t))throw new Error("The wallet used for this operation is not connected to the correct network.")}async function BL(e,t,r){await NL(t,r.immutableXConfig);const n=wA.Registration.connect(r.immutableXConfig.ethConfiguration.registrationContractAddress,t);try{return await n.isRegistered(e)}catch(e){if("USER_UNREGISTERED"===e.reason)return!1;throw e}}async function UL(e,t,r){const n=await r.getSignableRegistration({getSignableRegistrationRequest:{ether_key:e,stark_key:t}});return{operator_signature:n.data.operator_signature,payload_hash:n.data.payload_hash}}const LL=e=>{if(void 0!==e)return e;throw new Error("undefined field exception")};async function jL(e){const{signers:{ethSigner:t,starkSigner:r},type:n,config:i}=e;await NL(t,e.config);const a=new Sk(i.apiConfiguration),s="ERC721"===n?"1":e.amount,o=await a.getSignableWithdrawal({getSignableWithdrawalRequest:{user:await t.getAddress(),token:SU(e),amount:s}}),{signable_message:c,payload_hash:f}=o.data,u=await r.signMessage(f),{ethAddress:d,ethSignature:l}=await async function(e,t){return{message:e,ethAddress:await t.getAddress(),ethSignature:await AU(e,t)}}(c,t);return(await a.createWithdrawal({createWithdrawalRequest:{stark_key:LL(o.data.stark_key),amount:s,asset_id:LL(o.data.asset_id),vault_id:LL(o.data.vault_id),nonce:LL(o.data.nonce),stark_signature:u},xImxEthAddress:d,xImxEthSignature:l})).data}async function DL(e,t,r,n){const i=new IS(r.apiConfiguration);return(await i.encodeAsset({assetType:e,encodeAssetRequest:{token:{type:t,...n&&{data:n}}}})).data}async function FL({ethSigner:e,starkPublicKey:t,token:r,config:n}){await NL(e,n.immutableXConfig);const i=n.immutableXConfig,a=await DL("asset","ERC20",i,{token_address:r.tokenAddress});return await BL(t,e,n)?async function(e,t,r,n){const i=wA.Core.connect(n.ethConfiguration.coreContractAddress,e),a=await i.populateTransaction.withdraw(r,t);return e.sendTransaction(a)}(e,a.asset_type,t,i):async function({ethSigner:e,assetType:t,starkPublicKey:r,config:n}){const i=await e.getAddress(),a=n.immutableXConfig,s=new wk(a.apiConfiguration),o=await UL(i,r,s),c=wA.Registration.connect(n.immutableXConfig.ethConfiguration.registrationContractAddress,e),f=await c.populateTransaction.registerAndWithdraw(i,r,o.operator_signature,t);return e.sendTransaction(f)}({ethSigner:e,assetType:a.asset_type,starkPublicKey:t,config:n})}async function qL(e,t,r,n){const i=n.immutableXConfig,a=await DL("mintable-asset","ERC721",i,{id:r.data.id,token_address:r.data.tokenAddress,...r.data.blueprint&&{blueprint:r.data.blueprint}}),s=function(e){const{id:t}=e.data,r=e.data.blueprint||"";return Xf(kf(`{${t}}:{${r}}`))}(r);return await BL(t,e,n)?async function(e,t,r,n,i){const a=wA.Core.connect(i.ethConfiguration.coreContractAddress,e),s=await a.populateTransaction.withdrawAndMint(r,t,n);return e.sendTransaction(s)}(e,a.asset_type,t,s,i):async function(e,t,r,n,i){const a=await e.getAddress(),s=new wk(i.apiConfiguration),o=await UL(a,r,s),c=wA.Registration.connect(i.ethConfiguration.registrationContractAddress,e),f=await c.populateTransaction.regsiterAndWithdrawAndMint(a,r,o.operator_signature,t,n);return e.sendTransaction(f)}(e,a.asset_type,t,s,i)}async function zL(e,t,r,n){const i=n.immutableXConfig,a=await DL("asset","ERC721",i,{token_id:r.tokenId,token_address:r.tokenAddress});return await BL(t,e,n)?async function(e,t,r,n,i){const a=wA.Core.connect(i.ethConfiguration.coreContractAddress,e),s=await a.populateTransaction.withdrawNft(r,t,n);return e.sendTransaction(s)}(e,a.asset_type,t,r.tokenId,i):async function(e,t,r,n,i){const a=await e.getAddress(),s=new wk(i.apiConfiguration),o=await UL(a,r,s),c=wA.Registration.connect(i.ethConfiguration.registrationContractAddress,e),f=await c.populateTransaction.registerAndWithdrawNft(a,r,o.operator_signature,t,n);return e.sendTransaction(f)}(e,a.asset_type,t,r.tokenId,i)}async function KL({ethSigner:e,starkPublicKey:t,config:r}){await NL(e,r.immutableXConfig);const n=r.immutableXConfig,i=await DL("asset","ETH",n);return await BL(t,e,r)?async function(e,t,r,n){const i=wA.Core.connect(n.ethConfiguration.coreContractAddress,e),a=await i.populateTransaction.withdraw(r,t);return e.sendTransaction(a)}(e,i.asset_type,t,n):async function(e,t,r,n){const i=await e.getAddress(),a=new wk(n.apiConfiguration),s=await UL(i,r,a),o=wA.Registration.connect(n.ethConfiguration.registrationContractAddress,e),c=await o.populateTransaction.registerAndWithdraw(i,r,s.operator_signature,t);return e.sendTransaction(c)}(e,i.asset_type,t,n)}async function HL({signers:{ethSigner:e},starkPublicKey:t,token:r,config:n}){switch(r.type){case"ETH":return KL({ethSigner:e,starkPublicKey:t,config:n});case"ERC20":return FL({ethSigner:e,starkPublicKey:t,token:r,config:n});case"ERC721":return async function({ethSigner:e,starkPublicKey:t,token:r,config:n}){await NL(e,n.immutableXConfig);const{tokenAddress:i}=r,{tokenId:a}=r,s=n.immutableXConfig,o=new VS(s.apiConfiguration);return await o.getMintableTokenDetailsByClientTokenId({tokenAddress:i,tokenId:a}).then((r=>qL(e,t,{type:"ERC721",data:{id:a,tokenAddress:i,blueprint:r.data.blueprint}},n))).catch((i=>{if(404===i.response?.status)return zL(e,t,r,n);throw i}))}({ethSigner:e,starkPublicKey:t,token:r,config:n})}}async function GL({signers:{ethSigner:e},deposit:t,config:r}){await NL(e,r.immutableXConfig);const n=await e.getAddress(),i=Wc(t.amount,"wei"),a=r.immutableXConfig,s=new xS(a.apiConfiguration),o=new IS(a.apiConfiguration),c=new wk(a.apiConfiguration),f={user:n,token:{type:t.type,data:{decimals:18}},amount:i.toString()},u=await s.getSignableDeposit({getSignableDepositRequest:f}),d=(await o.encodeAsset({assetType:"asset",encodeAssetRequest:{token:{type:t.type}}})).data.asset_type,l=u.data.stark_key,h=u.data.vault_id;return await BL(l,e,r)?async function(e,t,r,n,i,a){const s=wA.Core.connect(a.ethConfiguration.coreContractAddress,e),o=await s.populateTransaction["deposit(uint256,uint256,uint256)"](n,r,i);return e.sendTransaction({...o,value:t})}(e,i,d,l,h,a):async function(e,t,r,n,i,a,s){const o=await e.getAddress(),c=wA.Core.connect(a.ethConfiguration.coreContractAddress,e),f=await UL(o,n,s),u=await c.populateTransaction.registerAndDepositEth(o,n,f.operator_signature,r,i);return e.sendTransaction({...u,value:t})}(e,i,d,l,h,a,c)}async function VL({signers:{ethSigner:e},deposit:t,config:r}){await NL(e,r.immutableXConfig);const{apiConfiguration:n,ethConfiguration:i}=r.immutableXConfig,a=await e.getAddress(),s=new ck(n),o=new xS(n),c=new IS(n),f=new wk(n),u=await s.getToken({address:t.tokenAddress}),d={decimals:parseInt(u.data.decimals),token_address:t.tokenAddress},l=Wc(t.amount,0),h=wA.IERC20.connect(t.tokenAddress,e),p=await h.populateTransaction.approve(i.coreContractAddress,l);await e.sendTransaction(p);const b={user:a,token:{type:t.type,data:d},amount:l.toString()},g=await o.getSignableDeposit({getSignableDepositRequest:b}),m=(await c.encodeAsset({assetType:"asset",encodeAssetRequest:{token:{type:t.type,data:{token_address:t.tokenAddress}}}})).data.asset_type,y=g.data.stark_key,v=g.data.vault_id,w=He.from(g.data.amount);return await BL(y,e,r)?async function(e,t,r,n,i,a){const s=wA.Core.connect(a.coreContractAddress,e),o=await s.populateTransaction.depositERC20(n,r,i,t);return e.sendTransaction(o)}(e,w,m,y,v,i):async function(e,t,r,n,i,a,s){const o=await e.getAddress(),c=wA.Core.connect(a.coreContractAddress,e),f=await UL(o,n,s),u=await c.populateTransaction.registerAndDepositERC20(o,n,f.operator_signature,r,i,t);return e.sendTransaction(u)}(e,w,m,y,v,i,f)}async function WL({signers:{ethSigner:e},deposit:t,config:r}){await NL(e,r.immutableXConfig);const n=await e.getAddress(),{immutableXConfig:i}=r,a=new xS(i.apiConfiguration),s=new IS(i.apiConfiguration),o=new wk(i.apiConfiguration),c={token_address:t.tokenAddress,token_id:t.tokenId},f={user:n,token:{type:t.type,data:c},amount:"1".toString()},u=await a.getSignableDeposit({getSignableDepositRequest:f}),d=(await s.encodeAsset({assetType:"asset",encodeAssetRequest:{token:{type:t.type,data:{token_address:t.tokenAddress,token_id:t.tokenId}}}})).data.asset_type,l=u.data.stark_key,h=u.data.vault_id,p=await BL(l,e,r),b=wA.IERC721.connect(t.tokenAddress,e),g=i.ethConfiguration.coreContractAddress;if(await b.isApprovedForAll(n,g)||await b.setApprovalForAll(g,!0),!p){const t=await UL(n,l,o),r=wA.Core.connect(i.ethConfiguration.coreContractAddress,e);await r.registerUser(n,l,t.operator_signature)}return async function(e,t,r,n,i,a){const s=wA.Core.connect(a.ethConfiguration.coreContractAddress,e),o=await s.populateTransaction.depositNft(n,r,i,t);return e.sendTransaction(o)}(e,t.tokenId,d,l,h,i)}class XL{config;signers;constructor(e,t,r){this.config=e,this.signers={ethSigner:t,starkSigner:r}}async getAddress(){return await this.signers.ethSigner.getAddress()}registerOffchain(){return async function(e,t){await NL(e.ethSigner,t.immutableXConfig);const r=new wk(t.immutableXConfig.apiConfiguration),n=await e.ethSigner.getAddress(),i=await e.starkSigner.getAddress(),a=await r.getSignableRegistrationOffchain({getSignableRegistrationRequest:{ether_key:n,stark_key:i}}),{signable_message:s,payload_hash:o}=a.data,c=await AU(s,e.ethSigner),f=await e.starkSigner.signMessage(o);return(await r.registerUser({registerUserRequest:{eth_signature:c,ether_key:n,stark_signature:f,stark_key:i}})).data}(this.signers,this.config)}batchNftTransfer(e){return async function({signers:{ethSigner:e,starkSigner:t},request:r,config:n}){await NL(e,n.immutableXConfig);const i=await e.getAddress(),a=new gk(n.immutableXConfig.apiConfiguration),s=r.map((e=>({amount:"1",token:SU({type:"ERC721",tokenId:e.tokenId,tokenAddress:e.tokenAddress}),receiver:e.receiver}))),o=await a.getSignableTransfer({getSignableTransferRequestV2:{sender_ether_key:i,signable_requests:s}}),c=o.data.signable_message;if(void 0===c)throw new Error("Invalid response from Signable registration offchain");const f=await AU(c,e),u=[];for(const e of o.data.signable_responses){const r=await t.signMessage(e.payload_hash),n={sender_vault_id:e.sender_vault_id,receiver_stark_key:e.receiver_stark_key,receiver_vault_id:e.receiver_vault_id,asset_id:e.asset_id,amount:e.amount,nonce:e.nonce,expiration_timestamp:e.expiration_timestamp,stark_signature:r};u.push(n)}const d={sender_stark_key:o.data.sender_stark_key,requests:u},l=await a.createTransfer({createTransferRequestV2:d,xImxEthAddress:i,xImxEthSignature:f});return{transfer_ids:l?.data.transfer_ids}}({signers:this.signers,request:e,config:this.config})}cancelOrder(e){return async function({signers:e,request:t,config:r}){const n=new ek(r.immutableXConfig.apiConfiguration),i=await n.getSignableCancelOrder({getSignableCancelOrderRequest:{order_id:t.order_id}}),{signable_message:a,payload_hash:s}=i.data,o=await AU(a,e.ethSigner),c=await e.starkSigner.signMessage(s),f=await e.ethSigner.getAddress(),u=await n.cancelOrder({id:t.order_id.toString(),cancelOrderRequest:{order_id:t.order_id,stark_signature:c},xImxEthAddress:f,xImxEthSignature:o});return{order_id:u.data.order_id,status:u.data.status}}({signers:this.signers,request:e,config:this.config})}completeWithdrawal(e,t){return HL({config:this.config,signers:this.signers,token:t,starkPublicKey:e})}createOrder(e){return async function({signers:e,request:t,config:r}){await NL(e.ethSigner,r.immutableXConfig);const n=await e.ethSigner.getAddress(),i=new ek(r.immutableXConfig.apiConfiguration),a="ERC721"===t.sell.type?"1":t.sell.amount,s={user:n,amount_buy:"ERC721"===t.buy.type?"1":t.buy.amount,token_buy:SU(t.buy),amount_sell:a,token_sell:SU(t.sell),fees:t.fees,expiration_timestamp:t.expiration_timestamp},o=await i.getSignableOrder({getSignableOrderRequestV3:s}),{signable_message:c,payload_hash:f}=o.data,u=await AU(c,e.ethSigner),d=await e.starkSigner.signMessage(f),l=o.data,h={createOrderRequest:{amount_buy:l.amount_buy,amount_sell:l.amount_sell,asset_id_buy:l.asset_id_buy,asset_id_sell:l.asset_id_sell,expiration_timestamp:l.expiration_timestamp,include_fees:!0,fees:t.fees,nonce:l.nonce,stark_key:l.stark_key,stark_signature:d,vault_id_buy:l.vault_id_buy,vault_id_sell:l.vault_id_sell},xImxEthAddress:n,xImxEthSignature:u};return{...(await i.createOrder(h)).data}}({signers:this.signers,request:e,config:this.config})}createTrade(e){return async function({signers:{ethSigner:e,starkSigner:t},request:r,config:n}){await NL(e,n.immutableXConfig);const i=await e.getAddress(),a=new lk(n.immutableXConfig.apiConfiguration),s=await a.getSignableTrade({getSignableTradeRequest:{user:i,order_id:r.order_id,fees:r.fees}}),{signable_message:o,payload_hash:c}=s.data,f=await AU(o,e),u=await t.signMessage(c);return(await a.createTrade({createTradeRequest:{amount_buy:s.data.amount_buy,amount_sell:s.data.amount_sell,asset_id_buy:s.data.asset_id_buy,asset_id_sell:s.data.asset_id_sell,expiration_timestamp:s.data.expiration_timestamp,fee_info:s.data.fee_info,fees:r.fees,include_fees:!0,nonce:s.data.nonce,order_id:r.order_id,stark_key:s.data.stark_key,vault_id_buy:s.data.vault_id_buy,vault_id_sell:s.data.vault_id_sell,stark_signature:u},xImxEthAddress:i,xImxEthSignature:f})).data}({signers:this.signers,request:e,config:this.config})}deposit(e){return async function({signers:e,deposit:t,config:r}){switch(t.type){case"ETH":return GL({signers:e,deposit:t,config:r});case"ERC20":return VL({signers:e,deposit:t,config:r});case"ERC721":return WL({signers:e,deposit:t,config:r})}}({signers:this.signers,deposit:e,config:this.config})}exchangeTransfer(e){return async function({signers:e,request:t,config:r}){await NL(e.ethSigner,r.immutableXConfig);const n=new NS(r.immutableXConfig.apiConfiguration),i=await e.ethSigner.getAddress(),a=t.amount,s=await n.getExchangeSignableTransfer({id:t.transactionID,getSignableTransferRequest:{sender:i,token:SU(t),amount:a,receiver:t.receiver}}),{signable_message:o,payload_hash:c}=s.data,f=await AU(o,e.ethSigner),u=await e.starkSigner.signMessage(c),d={sender_stark_key:s.data.sender_stark_key,sender_vault_id:s.data.sender_vault_id,receiver_stark_key:s.data.receiver_stark_key,receiver_vault_id:s.data.receiver_vault_id,asset_id:s.data.asset_id,amount:s.data.amount,nonce:s.data.nonce,expiration_timestamp:s.data.expiration_timestamp,stark_signature:u},l=await n.createExchangeTransfer({id:t.transactionID,createTransferRequest:d,xImxEthAddress:i,xImxEthSignature:f});return{sent_signature:l?.data.sent_signature,status:l?.data.status?.toString(),time:l?.data.time,transfer_id:l?.data.transfer_id}}({signers:this.signers,request:e,config:this.config})}async isRegisteredOnchain(){return BL(await this.signers.starkSigner.getAddress(),this.signers.ethSigner,this.config)}prepareWithdrawal(e){return async function({signers:e,withdrawal:t,config:r}){return jL({signers:e,config:r.immutableXConfig,...t})}({signers:this.signers,withdrawal:e,config:this.config})}transfer(e){return async function({signers:{ethSigner:e,starkSigner:t},request:r,config:n}){await NL(e,n.immutableXConfig);const i=await e.getAddress(),a=new gk(n.immutableXConfig.apiConfiguration),s="ERC721"===r.type?"1":r.amount,o=await a.getSignableTransferV1({getSignableTransferRequest:{sender:i,token:SU(r),amount:s,receiver:r.receiver}}),{signable_message:c,payload_hash:f}=o.data,u=await AU(c,e),d=await t.signMessage(f),l={sender_stark_key:o.data.sender_stark_key,sender_vault_id:o.data.sender_vault_id,receiver_stark_key:o.data.receiver_stark_key,receiver_vault_id:o.data.receiver_vault_id,asset_id:o.data.asset_id,amount:o.data.amount,nonce:o.data.nonce,expiration_timestamp:o.data.expiration_timestamp,stark_signature:d},h=await a.createTransferV1({createTransferRequest:l,xImxEthAddress:i,xImxEthSignature:u});return{sent_signature:h?.data.sent_signature,status:h?.data.status?.toString(),time:h?.data.time,transfer_id:h?.data.transfer_id}}({signers:this.signers,request:e,config:this.config})}}const $L={SWITCH_CHAIN:"wallet_switchEthereumChain",CONNECT:"eth_requestAccounts"};const JL="The Metamask provider was not found";async function YL({chainID:e}){const t=await PL();if(!function(e){return!!e?.request}(t))throw new Error(JL);return await async function(e,t){await e.request({method:$L.CONNECT}),t&&await e.request({method:$L.SWITCH_CHAIN,params:[{chainId:`0x${t.toString(16)}`}]})}(t,e),new Lc(t)}const QL="message";var ZL,ej;function tj(e,t){e&&e.contentWindow&&e.contentWindow.postMessage(t,new URL(e.src).origin)}function rj(e,t,r,n){if(e&&t.source!==e.contentWindow)return;const i=t.data;i.type===r&&n(i.details)}!function(e){e.GET_CONNECTION_REQUEST="GET_CONNECTION_REQUEST",e.CONNECT_WALLET_REQUEST="CONNECT_WALLET_REQUEST",e.SIGN_MESSAGE_REQUEST="SIGN_MESSAGE_REQUEST",e.DISCONNECT_WALLET_REQUEST="DISCONNECT_WALLET_REQUEST"}(ZL||(ZL={})),function(e){e.CONNECT_WALLET_RESPONSE="CONNECT_WALLET_RESPONSE",e.SIGN_MESSAGE_RESPONSE="SIGN_MESSAGE_RESPONSE",e.GET_CONNECTION_RESPONSE="GET_CONNECTION_RESPONSE",e.DISCONNECT_WALLET_RESPONSE="DISCONNECT_WALLET_RESPONSE"}(ej||(ej={}));class nj{publicAddress;iframe;constructor(e,t){this.publicAddress=e,this.iframe=t}getAddress(){return this.publicAddress}signMessage(e){return new Promise(((t,r)=>{const n=e=>{rj(this.iframe,e,ej.SIGN_MESSAGE_RESPONSE,(e=>{window.removeEventListener(QL,n),e.success||r(new Error(e.error?.message)),t(e.data.signedMessage)}))};window.addEventListener(QL,n),tj(this.iframe,{type:ZL.SIGN_MESSAGE_REQUEST,details:{starkPublicKey:this.publicAddress,message:e}})}))}getIFrame(){return this.iframe}}const ij="imx-wallet-app",aj={[e.Environment.SANDBOX]:"https://wallets.sandbox.immutable.com",[e.Environment.PRODUCTION]:"https://wallets.immutable.com"},sj="display: none;";async function oj(e){const t=document.querySelector(`iframe#${ij}`);return t||await async function(e){return new Promise((t=>{const r=document.createElement("iframe");r.setAttribute("id",ij),r.setAttribute("src",aj[e]),r.setAttribute("style",sj),document.body.appendChild(r),r.onload=()=>t(r)}))}(e)}var cj;!function(e){e.PROVIDER_CONNECTION_ERROR="PROVIDER_CONNECTION_ERROR",e.WALLET_CONNECTION_ERROR="WALLET_CONNECTION_ERROR"}(cj||(cj={}));class fj extends Error{type;constructor(e,t){super(e),this.type=t}}const uj=async(e,t)=>{try{return await e()}catch(e){const r=t.message||`${e.message}`||"UnknownError";throw new fj(r,t.type)}};class dj extends XL{static imxSigner;static async connect(e){return await uj((async()=>{const t=await YL({chainID:e.immutableXConfig.ethConfiguration.chainID});return this.imxSigner=await async function(e,t){const r=e.getSigner(),n=await r.getAddress(),i=await r.signMessage("Only sign this request if you’ve initiated an action with Immutable X."),a=await oj(t);return new Promise(((e,t)=>{const r=n=>{rj(a,n,ej.CONNECT_WALLET_RESPONSE,(n=>{window.removeEventListener(QL,r),n.success||t(new Error("The L2 IMX Wallet connection has failed")),e(new nj(n.data.starkPublicKey,a))}))};window.addEventListener(QL,r),tj(a,{type:ZL.CONNECT_WALLET_REQUEST,details:{ethAddress:n,signature:i}})}))}(t,e.baseConfig.environment),new dj(e,t.getSigner(),this.imxSigner)}),{type:cj.WALLET_CONNECTION_ERROR})}static async disconnect(){if(!this.imxSigner)throw new fj("Attempted to disconnect from the MetaMask IMX provider without an established connection",cj.PROVIDER_CONNECTION_ERROR);return uj((async()=>{await async function(e){const t=e.getIFrame();return new Promise(((r,n)=>{const i=e=>{rj(t,e,ej.DISCONNECT_WALLET_RESPONSE,(e=>{window.removeEventListener(QL,i),!e.success&&e.error&&n(e.error),t.remove(),r()}))};window.addEventListener(QL,i),tj(t,{type:ZL.DISCONNECT_WALLET_REQUEST,details:{starkPublicKey:e.getAddress()}})}))}(this.imxSigner)}),{type:cj.PROVIDER_CONNECTION_ERROR})}static async signMessage(e){if(!this.imxSigner)throw new fj("Attempted to sign a message with the MetaMask IMX provider without an established connection",cj.PROVIDER_CONNECTION_ERROR);return uj((async()=>await this.imxSigner.signMessage(e)),{type:cj.PROVIDER_CONNECTION_ERROR})}}e.GenericIMXProvider=XL,e.ImmutableConfiguration=class{environment;apiKey;constructor(e){this.environment=e.environment,this.apiKey=e.apiKey}},e.ImmutableXClient=mR,e.JsonRpcError=fL,e.MetaMaskIMXProvider=dj,e.Passport=class{authManager;config;confirmationScreen;immutableXClient;magicAdapter;passportImxProviderFactory;multiRollupApiClients;constructor(e){this.config=new yL(e),this.authManager=new rL(this.config),this.magicAdapter=new nL(this.config),this.confirmationScreen=new kL(this.config),this.immutableXClient=e.overrides?.immutableXClient||new mR({baseConfig:e.baseConfig}),this.multiRollupApiClients=new EI(this.config.multiRollupConfig),this.passportImxProviderFactory=new bL({authManager:this.authManager,config:this.config,confirmationScreen:this.confirmationScreen,immutableXClient:this.immutableXClient,magicAdapter:this.magicAdapter})}async connectImxSilent(){return this.passportImxProviderFactory.getProviderSilent()}async connectImx(){return this.passportImxProviderFactory.getProvider()}async loginWithDeviceFlow(){return this.authManager.loginWithDeviceFlow()}async connectImxDeviceFlow(e,t,r){return this.passportImxProviderFactory.getProviderWithDeviceFlow(e,t,r)}getPKCEAuthorizationUrl(){return this.authManager.getPKCEAuthorizationUrl()}async connectImxPKCEFlow(e,t){return this.passportImxProviderFactory.getProviderWithPKCEFlow(e,t)}checkStoredDeviceFlowCredentials(){return this.authManager.checkStoredDeviceFlowCredentials()}async connectImxWithCredentials(e){return this.passportImxProviderFactory.getProviderWithCredentials(e)}connectEvm(){if(this.config.network===e.Networks.PRODUCTION)throw new Error("EVM is not supported on production network");return new CL({authManager:this.authManager,magicAdapter:this.magicAdapter,config:this.config,confirmationScreen:this.confirmationScreen,multiRollupApiClients:this.multiRollupApiClients})}async loginCallback(){return this.authManager.loginCallback()}async logout(){return this.authManager.logout()}async logoutSilentCallback(e){return this.authManager.logoutSilentCallback(e)}async logoutDeviceFlow(){return this.authManager.logoutDeviceFlow()}async getUserInfo(){const e=await this.authManager.getUser();return e?.profile}async getUserInfoDeviceFlow(){const e=await this.authManager.getUserDeviceFlow();return e?.profile}async getIdToken(){const e=await this.authManager.getUser();return e?.idToken}async getAccessToken(){const e=await this.authManager.getUser();return e?.accessToken}},e.PassportError=XU,e.ProviderConfiguration=class{immutableXConfig;baseConfig;constructor({baseConfig:t,overrides:r}){if(this.baseConfig=t,r)this.immutableXConfig=r.immutableXConfig;else switch(t.environment){case e.Environment.SANDBOX:this.immutableXConfig=eR.SANDBOX;break;case e.Environment.PRODUCTION:this.immutableXConfig=eR.PRODUCTION}}},e.imxClientCreateStarkSigner=JA,e.imxClientGenerateLegacyStarkPrivateKey=lR}));
31
+ */Ck=Pk,function(){var e="input is invalid type",t="object"==typeof window,r=t?window:{};r.JS_SHA3_NO_WINDOW&&(t=!1);var n=!t&&"object"==typeof self;!r.JS_SHA3_NO_NODE_JS&&"object"==typeof process&&process.versions&&process.versions.node?r=AA:n&&(r=self);var i=!r.JS_SHA3_NO_COMMON_JS&&Ck.exports,a=!r.JS_SHA3_NO_ARRAY_BUFFER&&"undefined"!=typeof ArrayBuffer,s="0123456789abcdef".split(""),o=[4,1024,262144,67108864],c=[0,8,16,24],f=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],u=[224,256,384,512],d=[128,256],l=["hex","buffer","arrayBuffer","array","digest"],h={128:168,256:136};!r.JS_SHA3_NO_NODE_JS&&Array.isArray||(Array.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)}),!a||!r.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW&&ArrayBuffer.isView||(ArrayBuffer.isView=function(e){return"object"==typeof e&&e.buffer&&e.buffer.constructor===ArrayBuffer});for(var p=function(e,t,r){return function(n){return new O(e,t,e).update(n)[r]()}},b=function(e,t,r){return function(n,i){return new O(e,t,i).update(n)[r]()}},g=function(e,t,r){return function(t,n,i,a){return _["cshake"+e].update(t,n,i,a)[r]()}},m=function(e,t,r){return function(t,n,i,a){return _["kmac"+e].update(t,n,i,a)[r]()}},y=function(e,t,r,n){for(var i=0;i<l.length;++i){var a=l[i];e[a]=t(r,n,a)}return e},v=function(e,t){var r=p(e,t,"hex");return r.create=function(){return new O(e,t,e)},r.update=function(e){return r.create().update(e)},y(r,p,e,t)},w=[{name:"keccak",padding:[1,256,65536,16777216],bits:u,createMethod:v},{name:"sha3",padding:[6,1536,393216,100663296],bits:u,createMethod:v},{name:"shake",padding:[31,7936,2031616,520093696],bits:d,createMethod:function(e,t){var r=b(e,t,"hex");return r.create=function(r){return new O(e,t,r)},r.update=function(e,t){return r.create(t).update(e)},y(r,b,e,t)}},{name:"cshake",padding:o,bits:d,createMethod:function(e,t){var r=h[e],n=g(e,0,"hex");return n.create=function(n,i,a){return i||a?new O(e,t,n).bytepad([i,a],r):_["shake"+e].create(n)},n.update=function(e,t,r,i){return n.create(t,r,i).update(e)},y(n,g,e,t)}},{name:"kmac",padding:o,bits:d,createMethod:function(e,t){var r=h[e],n=m(e,0,"hex");return n.create=function(n,i,a){return new I(e,t,i).bytepad(["KMAC",a],r).bytepad([n],r)},n.update=function(e,t,r,i){return n.create(e,r,i).update(t)},y(n,m,e,t)}}],_={},E=[],A=0;A<w.length;++A)for(var S=w[A],k=S.bits,x=0;x<k.length;++x){var T=S.name+"_"+k[x];if(E.push(T),_[T]=S.createMethod(k[x],S.padding),"sha3"!==S.name){var R=S.name+k[x];E.push(R),_[R]=_[T]}}function O(e,t,r){this.blocks=[],this.s=[],this.padding=t,this.outputBits=r,this.reset=!0,this.finalized=!1,this.block=0,this.start=0,this.blockCount=1600-(e<<1)>>5,this.byteCount=this.blockCount<<2,this.outputBlocks=r>>5,this.extraBytes=(31&r)>>3;for(var n=0;n<50;++n)this.s[n]=0}function I(e,t,r){O.call(this,e,t,r)}O.prototype.update=function(t){if(this.finalized)throw new Error("finalize already called");var r,n=typeof t;if("string"!==n){if("object"!==n)throw new Error(e);if(null===t)throw new Error(e);if(a&&t.constructor===ArrayBuffer)t=new Uint8Array(t);else if(!(Array.isArray(t)||a&&ArrayBuffer.isView(t)))throw new Error(e);r=!0}for(var i,s,o=this.blocks,f=this.byteCount,u=t.length,d=this.blockCount,l=0,h=this.s;l<u;){if(this.reset)for(this.reset=!1,o[0]=this.block,i=1;i<d+1;++i)o[i]=0;if(r)for(i=this.start;l<u&&i<f;++l)o[i>>2]|=t[l]<<c[3&i++];else for(i=this.start;l<u&&i<f;++l)(s=t.charCodeAt(l))<128?o[i>>2]|=s<<c[3&i++]:s<2048?(o[i>>2]|=(192|s>>6)<<c[3&i++],o[i>>2]|=(128|63&s)<<c[3&i++]):s<55296||s>=57344?(o[i>>2]|=(224|s>>12)<<c[3&i++],o[i>>2]|=(128|s>>6&63)<<c[3&i++],o[i>>2]|=(128|63&s)<<c[3&i++]):(s=65536+((1023&s)<<10|1023&t.charCodeAt(++l)),o[i>>2]|=(240|s>>18)<<c[3&i++],o[i>>2]|=(128|s>>12&63)<<c[3&i++],o[i>>2]|=(128|s>>6&63)<<c[3&i++],o[i>>2]|=(128|63&s)<<c[3&i++]);if(this.lastByteIndex=i,i>=f){for(this.start=i-f,this.block=o[d],i=0;i<d;++i)h[i]^=o[i];M(h),this.reset=!0}else this.start=i}return this},O.prototype.encode=function(e,t){var r=255&e,n=1,i=[r];for(r=255&(e>>=8);r>0;)i.unshift(r),r=255&(e>>=8),++n;return t?i.push(n):i.unshift(n),this.update(i),i.length},O.prototype.encodeString=function(t){var r,n=typeof t;if("string"!==n){if("object"!==n)throw new Error(e);if(null===t)throw new Error(e);if(a&&t.constructor===ArrayBuffer)t=new Uint8Array(t);else if(!(Array.isArray(t)||a&&ArrayBuffer.isView(t)))throw new Error(e);r=!0}var i=0,s=t.length;if(r)i=s;else for(var o=0;o<t.length;++o){var c=t.charCodeAt(o);c<128?i+=1:c<2048?i+=2:c<55296||c>=57344?i+=3:(c=65536+((1023&c)<<10|1023&t.charCodeAt(++o)),i+=4)}return i+=this.encode(8*i),this.update(t),i},O.prototype.bytepad=function(e,t){for(var r=this.encode(t),n=0;n<e.length;++n)r+=this.encodeString(e[n]);var i=t-r%t,a=[];return a.length=i,this.update(a),this},O.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var e=this.blocks,t=this.lastByteIndex,r=this.blockCount,n=this.s;if(e[t>>2]|=this.padding[3&t],this.lastByteIndex===this.byteCount)for(e[0]=e[r],t=1;t<r+1;++t)e[t]=0;for(e[r-1]|=2147483648,t=0;t<r;++t)n[t]^=e[t];M(n)}},O.prototype.toString=O.prototype.hex=function(){this.finalize();for(var e,t=this.blockCount,r=this.s,n=this.outputBlocks,i=this.extraBytes,a=0,o=0,c="";o<n;){for(a=0;a<t&&o<n;++a,++o)e=r[a],c+=s[e>>4&15]+s[15&e]+s[e>>12&15]+s[e>>8&15]+s[e>>20&15]+s[e>>16&15]+s[e>>28&15]+s[e>>24&15];o%t==0&&(M(r),a=0)}return i&&(e=r[a],c+=s[e>>4&15]+s[15&e],i>1&&(c+=s[e>>12&15]+s[e>>8&15]),i>2&&(c+=s[e>>20&15]+s[e>>16&15])),c},O.prototype.arrayBuffer=function(){this.finalize();var e,t=this.blockCount,r=this.s,n=this.outputBlocks,i=this.extraBytes,a=0,s=0,o=this.outputBits>>3;e=i?new ArrayBuffer(n+1<<2):new ArrayBuffer(o);for(var c=new Uint32Array(e);s<n;){for(a=0;a<t&&s<n;++a,++s)c[s]=r[a];s%t==0&&M(r)}return i&&(c[a]=r[a],e=e.slice(0,o)),e},O.prototype.buffer=O.prototype.arrayBuffer,O.prototype.digest=O.prototype.array=function(){this.finalize();for(var e,t,r=this.blockCount,n=this.s,i=this.outputBlocks,a=this.extraBytes,s=0,o=0,c=[];o<i;){for(s=0;s<r&&o<i;++s,++o)e=o<<2,t=n[s],c[e]=255&t,c[e+1]=t>>8&255,c[e+2]=t>>16&255,c[e+3]=t>>24&255;o%r==0&&M(n)}return a&&(e=o<<2,t=n[s],c[e]=255&t,a>1&&(c[e+1]=t>>8&255),a>2&&(c[e+2]=t>>16&255)),c},I.prototype=new O,I.prototype.finalize=function(){return this.encode(this.outputBits,!0),O.prototype.finalize.call(this)};var M=function(e){var t,r,n,i,a,s,o,c,u,d,l,h,p,b,g,m,y,v,w,_,E,A,S,k,x,T,R,O,I,M,C,P,N,B,U,L,j,D,F,q,z,K,H,G,V,W,X,$,J,Y,Q,Z,ee,te,re,ne,ie,ae,se,oe,ce,fe,ue;for(n=0;n<48;n+=2)i=e[0]^e[10]^e[20]^e[30]^e[40],a=e[1]^e[11]^e[21]^e[31]^e[41],s=e[2]^e[12]^e[22]^e[32]^e[42],o=e[3]^e[13]^e[23]^e[33]^e[43],c=e[4]^e[14]^e[24]^e[34]^e[44],u=e[5]^e[15]^e[25]^e[35]^e[45],d=e[6]^e[16]^e[26]^e[36]^e[46],l=e[7]^e[17]^e[27]^e[37]^e[47],t=(h=e[8]^e[18]^e[28]^e[38]^e[48])^(s<<1|o>>>31),r=(p=e[9]^e[19]^e[29]^e[39]^e[49])^(o<<1|s>>>31),e[0]^=t,e[1]^=r,e[10]^=t,e[11]^=r,e[20]^=t,e[21]^=r,e[30]^=t,e[31]^=r,e[40]^=t,e[41]^=r,t=i^(c<<1|u>>>31),r=a^(u<<1|c>>>31),e[2]^=t,e[3]^=r,e[12]^=t,e[13]^=r,e[22]^=t,e[23]^=r,e[32]^=t,e[33]^=r,e[42]^=t,e[43]^=r,t=s^(d<<1|l>>>31),r=o^(l<<1|d>>>31),e[4]^=t,e[5]^=r,e[14]^=t,e[15]^=r,e[24]^=t,e[25]^=r,e[34]^=t,e[35]^=r,e[44]^=t,e[45]^=r,t=c^(h<<1|p>>>31),r=u^(p<<1|h>>>31),e[6]^=t,e[7]^=r,e[16]^=t,e[17]^=r,e[26]^=t,e[27]^=r,e[36]^=t,e[37]^=r,e[46]^=t,e[47]^=r,t=d^(i<<1|a>>>31),r=l^(a<<1|i>>>31),e[8]^=t,e[9]^=r,e[18]^=t,e[19]^=r,e[28]^=t,e[29]^=r,e[38]^=t,e[39]^=r,e[48]^=t,e[49]^=r,b=e[0],g=e[1],W=e[11]<<4|e[10]>>>28,X=e[10]<<4|e[11]>>>28,O=e[20]<<3|e[21]>>>29,I=e[21]<<3|e[20]>>>29,oe=e[31]<<9|e[30]>>>23,ce=e[30]<<9|e[31]>>>23,K=e[40]<<18|e[41]>>>14,H=e[41]<<18|e[40]>>>14,B=e[2]<<1|e[3]>>>31,U=e[3]<<1|e[2]>>>31,m=e[13]<<12|e[12]>>>20,y=e[12]<<12|e[13]>>>20,$=e[22]<<10|e[23]>>>22,J=e[23]<<10|e[22]>>>22,M=e[33]<<13|e[32]>>>19,C=e[32]<<13|e[33]>>>19,fe=e[42]<<2|e[43]>>>30,ue=e[43]<<2|e[42]>>>30,te=e[5]<<30|e[4]>>>2,re=e[4]<<30|e[5]>>>2,L=e[14]<<6|e[15]>>>26,j=e[15]<<6|e[14]>>>26,v=e[25]<<11|e[24]>>>21,w=e[24]<<11|e[25]>>>21,Y=e[34]<<15|e[35]>>>17,Q=e[35]<<15|e[34]>>>17,P=e[45]<<29|e[44]>>>3,N=e[44]<<29|e[45]>>>3,k=e[6]<<28|e[7]>>>4,x=e[7]<<28|e[6]>>>4,ne=e[17]<<23|e[16]>>>9,ie=e[16]<<23|e[17]>>>9,D=e[26]<<25|e[27]>>>7,F=e[27]<<25|e[26]>>>7,_=e[36]<<21|e[37]>>>11,E=e[37]<<21|e[36]>>>11,Z=e[47]<<24|e[46]>>>8,ee=e[46]<<24|e[47]>>>8,G=e[8]<<27|e[9]>>>5,V=e[9]<<27|e[8]>>>5,T=e[18]<<20|e[19]>>>12,R=e[19]<<20|e[18]>>>12,ae=e[29]<<7|e[28]>>>25,se=e[28]<<7|e[29]>>>25,q=e[38]<<8|e[39]>>>24,z=e[39]<<8|e[38]>>>24,A=e[48]<<14|e[49]>>>18,S=e[49]<<14|e[48]>>>18,e[0]=b^~m&v,e[1]=g^~y&w,e[10]=k^~T&O,e[11]=x^~R&I,e[20]=B^~L&D,e[21]=U^~j&F,e[30]=G^~W&$,e[31]=V^~X&J,e[40]=te^~ne&ae,e[41]=re^~ie&se,e[2]=m^~v&_,e[3]=y^~w&E,e[12]=T^~O&M,e[13]=R^~I&C,e[22]=L^~D&q,e[23]=j^~F&z,e[32]=W^~$&Y,e[33]=X^~J&Q,e[42]=ne^~ae&oe,e[43]=ie^~se&ce,e[4]=v^~_&A,e[5]=w^~E&S,e[14]=O^~M&P,e[15]=I^~C&N,e[24]=D^~q&K,e[25]=F^~z&H,e[34]=$^~Y&Z,e[35]=J^~Q&ee,e[44]=ae^~oe&fe,e[45]=se^~ce&ue,e[6]=_^~A&b,e[7]=E^~S&g,e[16]=M^~P&k,e[17]=C^~N&x,e[26]=q^~K&B,e[27]=z^~H&U,e[36]=Y^~Z&G,e[37]=Q^~ee&V,e[46]=oe^~fe&te,e[47]=ce^~ue&re,e[8]=A^~b&m,e[9]=S^~g&y,e[18]=P^~k&T,e[19]=N^~x&R,e[28]=K^~B&L,e[29]=H^~U&j,e[38]=Z^~G&W,e[39]=ee^~V&X,e[48]=fe^~te&ne,e[49]=ue^~re&ie,e[0]^=f[n],e[1]^=f[n+1]};if(i)Ck.exports=_;else for(A=0;A<E.length;++A)r[E[A]]=_[E[A]]}();var Nk=Pk.exports;function Bk(e){return"0x"+Nk.keccak_256(ke(e))}let Uk=!1,Lk=!1;const jk={debug:1,default:2,info:2,warning:3,error:4,off:5};let Dk=jk.default,Fk=null;const qk=function(){try{const e=[];if(["NFD","NFC","NFKD","NFKC"].forEach((t=>{try{if("test"!=="test".normalize(t))throw new Error("bad normalize")}catch(r){e.push(t)}})),e.length)throw new Error("missing "+e.join(", "));if(String.fromCharCode(233).normalize("NFD")!==String.fromCharCode(101,769))throw new Error("broken implementation")}catch(e){return e.message}return null}();var zk,Kk;!function(e){e.DEBUG="DEBUG",e.INFO="INFO",e.WARNING="WARNING",e.ERROR="ERROR",e.OFF="OFF"}(zk||(zk={})),function(e){e.UNKNOWN_ERROR="UNKNOWN_ERROR",e.NOT_IMPLEMENTED="NOT_IMPLEMENTED",e.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",e.NETWORK_ERROR="NETWORK_ERROR",e.SERVER_ERROR="SERVER_ERROR",e.TIMEOUT="TIMEOUT",e.BUFFER_OVERRUN="BUFFER_OVERRUN",e.NUMERIC_FAULT="NUMERIC_FAULT",e.MISSING_NEW="MISSING_NEW",e.INVALID_ARGUMENT="INVALID_ARGUMENT",e.MISSING_ARGUMENT="MISSING_ARGUMENT",e.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",e.CALL_EXCEPTION="CALL_EXCEPTION",e.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",e.NONCE_EXPIRED="NONCE_EXPIRED",e.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",e.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",e.TRANSACTION_REPLACED="TRANSACTION_REPLACED",e.ACTION_REJECTED="ACTION_REJECTED"}(Kk||(Kk={}));const Hk="0123456789abcdef";let Gk=class e{constructor(e){Object.defineProperty(this,"version",{enumerable:!0,value:e,writable:!1})}_log(e,t){const r=e.toLowerCase();null==jk[r]&&this.throwArgumentError("invalid log level name","logLevel",e),Dk>jk[r]||console.log.apply(console,t)}debug(...t){this._log(e.levels.DEBUG,t)}info(...t){this._log(e.levels.INFO,t)}warn(...t){this._log(e.levels.WARNING,t)}makeError(t,r,n){if(Lk)return this.makeError("censored error",r,{});r||(r=e.errors.UNKNOWN_ERROR),n||(n={});const i=[];Object.keys(n).forEach((e=>{const t=n[e];try{if(t instanceof Uint8Array){let r="";for(let e=0;e<t.length;e++)r+=Hk[t[e]>>4],r+=Hk[15&t[e]];i.push(e+"=Uint8Array(0x"+r+")")}else i.push(e+"="+JSON.stringify(t))}catch(t){i.push(e+"="+JSON.stringify(n[e].toString()))}})),i.push(`code=${r}`),i.push(`version=${this.version}`);const a=t;let s="";switch(r){case Kk.NUMERIC_FAULT:{s="NUMERIC_FAULT";const e=t;switch(e){case"overflow":case"underflow":case"division-by-zero":s+="-"+e;break;case"negative-power":case"negative-width":s+="-unsupported";break;case"unbound-bitwise-result":s+="-unbound-result"}break}case Kk.CALL_EXCEPTION:case Kk.INSUFFICIENT_FUNDS:case Kk.MISSING_NEW:case Kk.NONCE_EXPIRED:case Kk.REPLACEMENT_UNDERPRICED:case Kk.TRANSACTION_REPLACED:case Kk.UNPREDICTABLE_GAS_LIMIT:s=r}s&&(t+=" [ See: https://links.ethers.org/v5-errors-"+s+" ]"),i.length&&(t+=" ("+i.join(", ")+")");const o=new Error(t);return o.reason=a,o.code=r,Object.keys(n).forEach((function(e){o[e]=n[e]})),o}throwError(e,t,r){throw this.makeError(e,t,r)}throwArgumentError(t,r,n){return this.throwError(t,e.errors.INVALID_ARGUMENT,{argument:r,value:n})}assert(e,t,r,n){e||this.throwError(t,r,n)}assertArgument(e,t,r,n){e||this.throwArgumentError(t,r,n)}checkNormalize(t){qk&&this.throwError("platform missing String.prototype.normalize",e.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:qk})}checkSafeUint53(t,r){"number"==typeof t&&(null==r&&(r="value not safe"),(t<0||t>=9007199254740991)&&this.throwError(r,e.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:t}),t%1&&this.throwError(r,e.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:t}))}checkArgumentCount(t,r,n){n=n?": "+n:"",t<r&&this.throwError("missing argument"+n,e.errors.MISSING_ARGUMENT,{count:t,expectedCount:r}),t>r&&this.throwError("too many arguments"+n,e.errors.UNEXPECTED_ARGUMENT,{count:t,expectedCount:r})}checkNew(t,r){t!==Object&&null!=t||this.throwError("missing new",e.errors.MISSING_NEW,{name:r.name})}checkAbstract(t,r){t===r?this.throwError("cannot instantiate abstract class "+JSON.stringify(r.name)+" directly; use a sub-class",e.errors.UNSUPPORTED_OPERATION,{name:t.name,operation:"new"}):t!==Object&&null!=t||this.throwError("missing new",e.errors.MISSING_NEW,{name:r.name})}static globalLogger(){return Fk||(Fk=new e("logger/5.7.0")),Fk}static setCensorship(t,r){if(!t&&r&&this.globalLogger().throwError("cannot permanently disable censorship",e.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),Uk){if(!t)return;this.globalLogger().throwError("error censorship permanent",e.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}Lk=!!t,Uk=!!r}static setLogLevel(t){const r=jk[t.toLowerCase()];null!=r?Dk=r:e.globalLogger().warn("invalid log level - "+t)}static from(t){return new e(t)}};Gk.errors=Kk,Gk.levels=zk;var Vk=ce.BN;const Wk=new Gk("bignumber/5.7.0"),Xk={};let $k=!1,Jk=class e{constructor(e,t){e!==Xk&&Wk.throwError("cannot call constructor directly; use BigNumber.from",Gk.errors.UNSUPPORTED_OPERATION,{operation:"new (BigNumber)"}),this._hex=t,this._isBigNumber=!0,Object.freeze(this)}fromTwos(e){return Qk(Zk(this).fromTwos(e))}toTwos(e){return Qk(Zk(this).toTwos(e))}abs(){return"-"===this._hex[0]?e.from(this._hex.substring(1)):this}add(e){return Qk(Zk(this).add(Zk(e)))}sub(e){return Qk(Zk(this).sub(Zk(e)))}div(t){return e.from(t).isZero()&&ex("division-by-zero","div"),Qk(Zk(this).div(Zk(t)))}mul(e){return Qk(Zk(this).mul(Zk(e)))}mod(e){const t=Zk(e);return t.isNeg()&&ex("division-by-zero","mod"),Qk(Zk(this).umod(t))}pow(e){const t=Zk(e);return t.isNeg()&&ex("negative-power","pow"),Qk(Zk(this).pow(t))}and(e){const t=Zk(e);return(this.isNegative()||t.isNeg())&&ex("unbound-bitwise-result","and"),Qk(Zk(this).and(t))}or(e){const t=Zk(e);return(this.isNegative()||t.isNeg())&&ex("unbound-bitwise-result","or"),Qk(Zk(this).or(t))}xor(e){const t=Zk(e);return(this.isNegative()||t.isNeg())&&ex("unbound-bitwise-result","xor"),Qk(Zk(this).xor(t))}mask(e){return(this.isNegative()||e<0)&&ex("negative-width","mask"),Qk(Zk(this).maskn(e))}shl(e){return(this.isNegative()||e<0)&&ex("negative-width","shl"),Qk(Zk(this).shln(e))}shr(e){return(this.isNegative()||e<0)&&ex("negative-width","shr"),Qk(Zk(this).shrn(e))}eq(e){return Zk(this).eq(Zk(e))}lt(e){return Zk(this).lt(Zk(e))}lte(e){return Zk(this).lte(Zk(e))}gt(e){return Zk(this).gt(Zk(e))}gte(e){return Zk(this).gte(Zk(e))}isNegative(){return"-"===this._hex[0]}isZero(){return Zk(this).isZero()}toNumber(){try{return Zk(this).toNumber()}catch(e){ex("overflow","toNumber",this.toString())}return null}toBigInt(){try{return BigInt(this.toString())}catch(e){}return Wk.throwError("this platform does not support BigInt",Gk.errors.UNSUPPORTED_OPERATION,{value:this.toString()})}toString(){return arguments.length>0&&(10===arguments[0]?$k||($k=!0,Wk.warn("BigNumber.toString does not accept any parameters; base-10 is assumed")):16===arguments[0]?Wk.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()",Gk.errors.UNEXPECTED_ARGUMENT,{}):Wk.throwError("BigNumber.toString does not accept parameters",Gk.errors.UNEXPECTED_ARGUMENT,{})),Zk(this).toString(10)}toHexString(){return this._hex}toJSON(e){return{type:"BigNumber",hex:this.toHexString()}}static from(t){if(t instanceof e)return t;if("string"==typeof t)return t.match(/^-?0x[0-9a-f]+$/i)?new e(Xk,Yk(t)):t.match(/^-?[0-9]+$/)?new e(Xk,Yk(new Vk(t))):Wk.throwArgumentError("invalid BigNumber string","value",t);if("number"==typeof t)return t%1&&ex("underflow","BigNumber.from",t),(t>=9007199254740991||t<=-9007199254740991)&&ex("overflow","BigNumber.from",t),e.from(String(t));const r=t;if("bigint"==typeof r)return e.from(r.toString());if(Se(r))return e.from(Me(r));if(r)if(r.toHexString){const t=r.toHexString();if("string"==typeof t)return e.from(t)}else{let t=r._hex;if(null==t&&"BigNumber"===r.type&&(t=r.hex),"string"==typeof t&&(Oe(t)||"-"===t[0]&&Oe(t.substring(1))))return e.from(t)}return Wk.throwArgumentError("invalid BigNumber value","value",t)}static isBigNumber(e){return!(!e||!e._isBigNumber)}};function Yk(e){if("string"!=typeof e)return Yk(e.toString(16));if("-"===e[0])return"-"===(e=e.substring(1))[0]&&Wk.throwArgumentError("invalid hex","value",e),"0x00"===(e=Yk(e))?e:"-"+e;if("0x"!==e.substring(0,2)&&(e="0x"+e),"0x"===e)return"0x00";for(e.length%2&&(e="0x0"+e.substring(2));e.length>4&&"0x00"===e.substring(0,4);)e="0x"+e.substring(4);return e}function Qk(e){return Jk.from(Yk(e))}function Zk(e){const t=Jk.from(e).toHexString();return"-"===t[0]?new Vk("-"+t.substring(3),16):new Vk(t.substring(2),16)}function ex(e,t,r){const n={fault:e,operation:t};return null!=r&&(n.value=r),Wk.throwError(e,Gk.errors.NUMERIC_FAULT,n)}const tx=new Gk("bignumber/5.7.0"),rx={},nx=Jk.from(0),ix=Jk.from(-1);function ax(e,t,r,n){const i={fault:t,operation:r};return void 0!==n&&(i.value=n),tx.throwError(e,Gk.errors.NUMERIC_FAULT,i)}let sx="0";for(;sx.length<256;)sx+=sx;function ox(e){if("number"!=typeof e)try{e=Jk.from(e).toNumber()}catch(e){}return"number"==typeof e&&e>=0&&e<=256&&!(e%1)?"1"+sx.substring(0,e):tx.throwArgumentError("invalid decimal size","decimals",e)}function cx(e,t){null==t&&(t=0);const r=ox(t),n=(e=Jk.from(e)).lt(nx);n&&(e=e.mul(ix));let i=e.mod(r).toString();for(;i.length<r.length-1;)i="0"+i;i=i.match(/^([0-9]*[1-9]|0)(0*)/)[1];const a=e.div(r).toString();return e=1===r.length?a:a+"."+i,n&&(e="-"+e),e}function fx(e,t){null==t&&(t=0);const r=ox(t);"string"==typeof e&&e.match(/^-?[0-9.]+$/)||tx.throwArgumentError("invalid decimal value","value",e);const n="-"===e.substring(0,1);n&&(e=e.substring(1)),"."===e&&tx.throwArgumentError("missing value","value",e);const i=e.split(".");i.length>2&&tx.throwArgumentError("too many decimal points","value",e);let a=i[0],s=i[1];for(a||(a="0"),s||(s="0");"0"===s[s.length-1];)s=s.substring(0,s.length-1);for(s.length>r.length-1&&ax("fractional component exceeds decimals","underflow","parseFixed"),""===s&&(s="0");s.length<r.length-1;)s+="0";const o=Jk.from(a),c=Jk.from(s);let f=o.mul(r).add(c);return n&&(f=f.mul(ix)),f}let ux=class e{constructor(e,t,r,n){e!==rx&&tx.throwError("cannot use FixedFormat constructor; use FixedFormat.from",Gk.errors.UNSUPPORTED_OPERATION,{operation:"new FixedFormat"}),this.signed=t,this.width=r,this.decimals=n,this.name=(t?"":"u")+"fixed"+String(r)+"x"+String(n),this._multiplier=ox(n),Object.freeze(this)}static from(t){if(t instanceof e)return t;"number"==typeof t&&(t=`fixed128x${t}`);let r=!0,n=128,i=18;if("string"==typeof t)if("fixed"===t);else if("ufixed"===t)r=!1;else{const e=t.match(/^(u?)fixed([0-9]+)x([0-9]+)$/);e||tx.throwArgumentError("invalid fixed format","format",t),r="u"!==e[1],n=parseInt(e[2]),i=parseInt(e[3])}else if(t){const e=(e,r,n)=>null==t[e]?n:(typeof t[e]!==r&&tx.throwArgumentError("invalid fixed format ("+e+" not "+r+")","format."+e,t[e]),t[e]);r=e("signed","boolean",r),n=e("width","number",n),i=e("decimals","number",i)}return n%8&&tx.throwArgumentError("invalid fixed format width (not byte aligned)","format.width",n),i>80&&tx.throwArgumentError("invalid fixed format (decimals too large)","format.decimals",i),new e(rx,r,n,i)}},dx=class e{constructor(e,t,r,n){e!==rx&&tx.throwError("cannot use FixedNumber constructor; use FixedNumber.from",Gk.errors.UNSUPPORTED_OPERATION,{operation:"new FixedFormat"}),this.format=n,this._hex=t,this._value=r,this._isFixedNumber=!0,Object.freeze(this)}_checkFormat(e){this.format.name!==e.format.name&&tx.throwArgumentError("incompatible format; use fixedNumber.toFormat","other",e)}addUnsafe(t){this._checkFormat(t);const r=fx(this._value,this.format.decimals),n=fx(t._value,t.format.decimals);return e.fromValue(r.add(n),this.format.decimals,this.format)}subUnsafe(t){this._checkFormat(t);const r=fx(this._value,this.format.decimals),n=fx(t._value,t.format.decimals);return e.fromValue(r.sub(n),this.format.decimals,this.format)}mulUnsafe(t){this._checkFormat(t);const r=fx(this._value,this.format.decimals),n=fx(t._value,t.format.decimals);return e.fromValue(r.mul(n).div(this.format._multiplier),this.format.decimals,this.format)}divUnsafe(t){this._checkFormat(t);const r=fx(this._value,this.format.decimals),n=fx(t._value,t.format.decimals);return e.fromValue(r.mul(this.format._multiplier).div(n),this.format.decimals,this.format)}floor(){const t=this.toString().split(".");1===t.length&&t.push("0");let r=e.from(t[0],this.format);const n=!t[1].match(/^(0*)$/);return this.isNegative()&&n&&(r=r.subUnsafe(lx.toFormat(r.format))),r}ceiling(){const t=this.toString().split(".");1===t.length&&t.push("0");let r=e.from(t[0],this.format);const n=!t[1].match(/^(0*)$/);return!this.isNegative()&&n&&(r=r.addUnsafe(lx.toFormat(r.format))),r}round(t){null==t&&(t=0);const r=this.toString().split(".");if(1===r.length&&r.push("0"),(t<0||t>80||t%1)&&tx.throwArgumentError("invalid decimal count","decimals",t),r[1].length<=t)return this;const n=e.from("1"+sx.substring(0,t),this.format),i=hx.toFormat(this.format);return this.mulUnsafe(n).addUnsafe(i).floor().divUnsafe(n)}isZero(){return"0.0"===this._value||"0"===this._value}isNegative(){return"-"===this._value[0]}toString(){return this._value}toHexString(e){if(null==e)return this._hex;e%8&&tx.throwArgumentError("invalid byte width","width",e);return Ue(Jk.from(this._hex).fromTwos(this.format.width).toTwos(e).toHexString(),e/8)}toUnsafeFloat(){return parseFloat(this.toString())}toFormat(t){return e.fromString(this._value,t)}static fromValue(t,r,n){return null!=n||null==r||function(e){return null!=e&&(Jk.isBigNumber(e)||"number"==typeof e&&e%1==0||"string"==typeof e&&!!e.match(/^-?[0-9]+$/)||Oe(e)||"bigint"==typeof e||Se(e))}(r)||(n=r,r=null),null==r&&(r=0),null==n&&(n="fixed"),e.fromString(cx(t,r),ux.from(n))}static fromString(t,r){null==r&&(r="fixed");const n=ux.from(r),i=fx(t,n.decimals);!n.signed&&i.lt(nx)&&ax("unsigned value cannot be negative","overflow","value",t);let a=null;n.signed?a=i.toTwos(n.width).toHexString():(a=i.toHexString(),a=Ue(a,n.width/8));const s=cx(i,n.decimals);return new e(rx,a,s,n)}static fromBytes(t,r){null==r&&(r="fixed");const n=ux.from(r);if(ke(t).length>n.width/8)throw new Error("overflow");let i=Jk.from(t);n.signed&&(i=i.fromTwos(n.width));const a=i.toTwos((n.signed?0:1)+n.width).toHexString(),s=cx(i,n.decimals);return new e(rx,a,s,n)}static from(t,r){if("string"==typeof t)return e.fromString(t,r);if(Se(t))return e.fromBytes(t,r);try{return e.fromValue(t,0,r)}catch(t){if(t.code!==Gk.errors.INVALID_ARGUMENT)throw t}return tx.throwArgumentError("invalid FixedNumber value","value",t)}static isFixedNumber(e){return!(!e||!e._isFixedNumber)}};const lx=dx.from(1),hx=dx.from("0.5"),px=new Gk("strings/5.7.0");var bx,gx;function mx(e,t=bx.current){t!=bx.current&&(px.checkNormalize(),e=e.normalize(t));let r=[];for(let t=0;t<e.length;t++){const n=e.charCodeAt(t);if(n<128)r.push(n);else if(n<2048)r.push(n>>6|192),r.push(63&n|128);else if(55296==(64512&n)){t++;const i=e.charCodeAt(t);if(t>=e.length||56320!=(64512&i))throw new Error("invalid utf-8 string");const a=65536+((1023&n)<<10)+(1023&i);r.push(a>>18|240),r.push(a>>12&63|128),r.push(a>>6&63|128),r.push(63&a|128)}else r.push(n>>12|224),r.push(n>>6&63|128),r.push(63&n|128)}return ke(r)}function yx(e,t){t||(t=function(e){return[parseInt(e,16)]});let r=0,n={};return e.split(",").forEach((e=>{let i=e.split(":");r+=parseInt(i[0],16),n[r]=t(i[1])})),n}function vx(e){let t=0;return e.split(",").map((e=>{let r=e.split("-");1===r.length?r[1]="0":""===r[1]&&(r[1]="1");let n=t+parseInt(r[0],16);return t=parseInt(r[1],16),{l:n,h:t}}))}function wx(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function _x(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?wx(Object(r),!0).forEach((function(t){rA(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):wx(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function Ex(e,t,r){return Ax.apply(this,arguments)}function Ax(){return(Ax=EA(TA.mark((function e(t,r,n){var i,a,s,o,c,f,u,d;return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=r.users.map((function(e){return{ether_key:e.user,tokens:e.tokens.map((function(e){return _x({id:e.id,blueprint:e.blueprint},e.royalties&&e.royalties.length>0&&{royalties:e.royalties.map((function(e){return{recipient:e.recipient,percentage:e.percentage}}))})}))}})),a=r.royalties,s=_x(_x({contract_address:r.contract_address},a&&a.length>0&&{royalties:a.map((function(e){return{recipient:e.recipient,percentage:e.percentage}}))}),{},{users:i,auth_signature:""}),o=Bk(mx(JSON.stringify(s))),e.next=6,MA(o,t);case 6:return c=e.sent,f=_x(_x({users:s.users.map((function(e){return{user:e.ether_key,tokens:e.tokens}}))},a&&a.length>0&&{royalties:a}),{},{contract_address:r.contract_address,auth_signature:c}),u={mintTokensRequestV2:[f]},e.next=11,n.mintTokens(u);case 11:return d=e.sent,e.abrupt("return",d.data);case 13:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Sx(e){switch(e.type){case"ERC721":return{type:"ERC721",data:{token_id:e.tokenId,token_address:e.tokenAddress}};case"ERC20":return{type:"ERC20",data:{token_address:e.tokenAddress}};case"ETH":return{type:"ETH",data:{decimals:18}}}}function kx(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return xx(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?xx(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,o=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return s=e.done,e},e:function(e){o=!0,a=e},f:function(){try{s||null==r.return||r.return()}finally{if(o)throw a}}}}function xx(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function Tx(e){return Rx.apply(this,arguments)}function Rx(){return(Rx=EA(TA.mark((function e(t){var r,n,i,a,s,o,c,f,u,d,l,h,p,b,g;return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.ethSigner,i=t.starkSigner,a=t.request,s=t.transfersApi,e.next=3,n.getAddress();case 3:return o=e.sent,c="ERC721"===a.type?"1":a.amount,e.next=7,s.getSignableTransferV1({getSignableTransferRequest:{sender:o,token:Sx(a),amount:c,receiver:a.receiver}});case 7:return f=e.sent,u=f.data,d=u.signable_message,l=u.payload_hash,e.next=11,MA(d,n);case 11:return h=e.sent,e.next=14,i.signMessage(l);case 14:return p=e.sent,b={sender_stark_key:f.data.sender_stark_key,sender_vault_id:f.data.sender_vault_id,receiver_stark_key:f.data.receiver_stark_key,receiver_vault_id:f.data.receiver_vault_id,asset_id:f.data.asset_id,amount:f.data.amount,nonce:f.data.nonce,expiration_timestamp:f.data.expiration_timestamp,stark_signature:p},e.next=18,s.createTransferV1({createTransferRequest:b,xImxEthAddress:o,xImxEthSignature:h});case 18:return g=e.sent,e.abrupt("return",{sent_signature:null==g?void 0:g.data.sent_signature,status:null==g||null===(r=g.data.status)||void 0===r?void 0:r.toString(),time:null==g?void 0:g.data.time,transfer_id:null==g?void 0:g.data.transfer_id});case 20:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Ox(e){return Ix.apply(this,arguments)}function Ix(){return(Ix=EA(TA.mark((function e(t){var r,n,i,a,s,o,c,f,u,d,l,h,p,b,g,m,y;return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.ethSigner,n=t.starkSigner,i=t.request,a=t.transfersApi,e.next=3,r.getAddress();case 3:return s=e.sent,o=i.map((function(e){return{amount:"1",token:Sx({type:"ERC721",tokenId:e.tokenId,tokenAddress:e.tokenAddress}),receiver:e.receiver}})),e.next=7,a.getSignableTransfer({getSignableTransferRequestV2:{sender_ether_key:s,signable_requests:o}});case 7:if(c=e.sent,void 0!==(f=c.data.signable_message)){e.next=11;break}throw new Error("Invalid response from Signable registration offchain");case 11:return e.next=13,MA(f,r);case 13:u=e.sent,d=[],l=kx(c.data.signable_responses),e.prev=16,l.s();case 18:if((h=l.n()).done){e.next=27;break}return p=h.value,e.next=22,n.signMessage(p.payload_hash);case 22:b=e.sent,g={sender_vault_id:p.sender_vault_id,receiver_stark_key:p.receiver_stark_key,receiver_vault_id:p.receiver_vault_id,asset_id:p.asset_id,amount:p.amount,nonce:p.nonce,expiration_timestamp:p.expiration_timestamp,stark_signature:b},d.push(g);case 25:e.next=18;break;case 27:e.next=32;break;case 29:e.prev=29,e.t0=e.catch(16),l.e(e.t0);case 32:return e.prev=32,l.f(),e.finish(32);case 35:return m={sender_stark_key:c.data.sender_stark_key,requests:d},e.next=38,a.createTransfer({createTransferRequestV2:m,xImxEthAddress:s,xImxEthSignature:u});case 38:return y=e.sent,e.abrupt("return",{transfer_ids:null==y?void 0:y.data.transfer_ids});case 40:case"end":return e.stop()}}),e,null,[[16,29,32,35]])})))).apply(this,arguments)}!function(e){e.current="",e.NFC="NFC",e.NFD="NFD",e.NFKC="NFKC",e.NFKD="NFKD"}(bx||(bx={})),function(e){e.UNEXPECTED_CONTINUE="unexpected continuation byte",e.BAD_PREFIX="bad codepoint prefix",e.OVERRUN="string overrun",e.MISSING_CONTINUE="missing continuation byte",e.OUT_OF_RANGE="out of UTF-8 range",e.UTF16_SURROGATE="UTF-16 surrogate",e.OVERLONG="overlong representation"}(gx||(gx={})),vx("221,13-1b,5f-,40-10,51-f,11-3,3-3,2-2,2-4,8,2,15,2d,28-8,88,48,27-,3-5,11-20,27-,8,28,3-5,12,18,b-a,1c-4,6-16,2-d,2-2,2,1b-4,17-9,8f-,10,f,1f-2,1c-34,33-14e,4,36-,13-,6-2,1a-f,4,9-,3-,17,8,2-2,5-,2,8-,3-,4-8,2-3,3,6-,16-6,2-,7-3,3-,17,8,3,3,3-,2,6-3,3-,4-a,5,2-6,10-b,4,8,2,4,17,8,3,6-,b,4,4-,2-e,2-4,b-10,4,9-,3-,17,8,3-,5-,9-2,3-,4-7,3-3,3,4-3,c-10,3,7-2,4,5-2,3,2,3-2,3-2,4-2,9,4-3,6-2,4,5-8,2-e,d-d,4,9,4,18,b,6-3,8,4,5-6,3-8,3-3,b-11,3,9,4,18,b,6-3,8,4,5-6,3-6,2,3-3,b-11,3,9,4,18,11-3,7-,4,5-8,2-7,3-3,b-11,3,13-2,19,a,2-,8-2,2-3,7,2,9-11,4-b,3b-3,1e-24,3,2-,3,2-,2-5,5,8,4,2,2-,3,e,4-,6,2,7-,b-,3-21,49,23-5,1c-3,9,25,10-,2-2f,23,6,3,8-2,5-5,1b-45,27-9,2a-,2-3,5b-4,45-4,53-5,8,40,2,5-,8,2,5-,28,2,5-,20,2,5-,8,2,5-,8,8,18,20,2,5-,8,28,14-5,1d-22,56-b,277-8,1e-2,52-e,e,8-a,18-8,15-b,e,4,3-b,5e-2,b-15,10,b-5,59-7,2b-555,9d-3,5b-5,17-,7-,27-,7-,9,2,2,2,20-,36,10,f-,7,14-,4,a,54-3,2-6,6-5,9-,1c-10,13-1d,1c-14,3c-,10-6,32-b,240-30,28-18,c-14,a0,115-,3,66-,b-76,5,5-,1d,24,2,5-2,2,8-,35-2,19,f-10,1d-3,311-37f,1b,5a-b,d7-19,d-3,41,57-,68-4,29-3,5f,29-37,2e-2,25-c,2c-2,4e-3,30,78-3,64-,20,19b7-49,51a7-59,48e-2,38-738,2ba5-5b,222f-,3c-94,8-b,6-4,1b,6,2,3,3,6d-20,16e-f,41-,37-7,2e-2,11-f,5-b,18-,b,14,5-3,6,88-,2,bf-2,7-,7-,7-,4-2,8,8-9,8-2ff,20,5-b,1c-b4,27-,27-cbb1,f7-9,28-2,b5-221,56,48,3-,2-,3-,5,d,2,5,3,42,5-,9,8,1d,5,6,2-2,8,153-3,123-3,33-27fd,a6da-5128,21f-5df,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3,2-1d,61-ff7d"),"ad,34f,1806,180b,180c,180d,200b,200c,200d,2060,feff".split(",").map((e=>parseInt(e,16))),yx("b5:3bc,c3:ff,7:73,2:253,5:254,3:256,1:257,5:259,1:25b,3:260,1:263,2:269,1:268,5:26f,1:272,2:275,7:280,3:283,5:288,3:28a,1:28b,5:292,3f:195,1:1bf,29:19e,125:3b9,8b:3b2,1:3b8,1:3c5,3:3c6,1:3c0,1a:3ba,1:3c1,1:3c3,2:3b8,1:3b5,1bc9:3b9,1c:1f76,1:1f77,f:1f7a,1:1f7b,d:1f78,1:1f79,1:1f7c,1:1f7d,107:63,5:25b,4:68,1:68,1:68,3:69,1:69,1:6c,3:6e,4:70,1:71,1:72,1:72,1:72,7:7a,2:3c9,2:7a,2:6b,1:e5,1:62,1:63,3:65,1:66,2:6d,b:3b3,1:3c0,6:64,1b574:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3"),yx("179:1,2:1,2:1,5:1,2:1,a:4f,a:1,8:1,2:1,2:1,3:1,5:1,3:1,4:1,2:1,3:1,4:1,8:2,1:1,2:2,1:1,2:2,27:2,195:26,2:25,1:25,1:25,2:40,2:3f,1:3f,33:1,11:-6,1:-9,1ac7:-3a,6d:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,b:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,c:-8,2:-8,2:-8,2:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,49:-8,1:-8,1:-4a,1:-4a,d:-56,1:-56,1:-56,1:-56,d:-8,1:-8,f:-8,1:-8,3:-7"),yx("df:00730073,51:00690307,19:02BC006E,a7:006A030C,18a:002003B9,16:03B903080301,20:03C503080301,1d7:05650582,190f:00680331,1:00740308,1:0077030A,1:0079030A,1:006102BE,b6:03C50313,2:03C503130300,2:03C503130301,2:03C503130342,2a:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,3:1F7003B9,1:03B103B9,1:03AC03B9,2:03B10342,1:03B1034203B9,5:03B103B9,6:1F7403B9,1:03B703B9,1:03AE03B9,2:03B70342,1:03B7034203B9,5:03B703B9,6:03B903080300,1:03B903080301,3:03B90342,1:03B903080342,b:03C503080300,1:03C503080301,1:03C10313,2:03C50342,1:03C503080342,b:1F7C03B9,1:03C903B9,1:03CE03B9,2:03C90342,1:03C9034203B9,5:03C903B9,ac:00720073,5b:00B00063,6:00B00066,d:006E006F,a:0073006D,1:00740065006C,1:0074006D,124f:006800700061,2:00610075,2:006F0076,b:00700061,1:006E0061,1:03BC0061,1:006D0061,1:006B0061,1:006B0062,1:006D0062,1:00670062,3:00700066,1:006E0066,1:03BC0066,4:0068007A,1:006B0068007A,1:006D0068007A,1:00670068007A,1:00740068007A,15:00700061,1:006B00700061,1:006D00700061,1:006700700061,8:00700076,1:006E0076,1:03BC0076,1:006D0076,1:006B0076,1:006D0076,1:00700077,1:006E0077,1:03BC0077,1:006D0077,1:006B0077,1:006D0077,1:006B03C9,1:006D03C9,2:00620071,3:00632215006B0067,1:0063006F002E,1:00640062,1:00670079,2:00680070,2:006B006B,1:006B006D,9:00700068,2:00700070006D,1:00700072,2:00730076,1:00770062,c723:00660066,1:00660069,1:0066006C,1:006600660069,1:00660066006C,1:00730074,1:00730074,d:05740576,1:05740565,1:0574056B,1:057E0576,1:0574056D",(function(e){if(e.length%4!=0)throw new Error("bad data");let t=[];for(let r=0;r<e.length;r+=4)t.push(parseInt(e.substring(r,r+4),16));return t})),vx("80-20,2a0-,39c,32,f71,18e,7f2-f,19-7,30-4,7-5,f81-b,5,a800-20ff,4d1-1f,110,fa-6,d174-7,2e84-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,2,1f-5f,ff7f-20001");const Mx=new Gk("units/5.7.0"),Cx=["wei","kwei","mwei","gwei","szabo","finney","ether"];function Px(e,t){if("string"!=typeof e&&Mx.throwArgumentError("value must be a string","value",e),"string"==typeof t){const e=Cx.indexOf(t);-1!==e&&(t=3*e)}return fx(e,null!=t?t:18)}function Nx(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function Bx(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Nx(Object(r),!0).forEach((function(t){rA(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Nx(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function Ux(e,t,r,n,i,a,s){return Lx.apply(this,arguments)}function Lx(){return(Lx=EA(TA.mark((function e(t,r,n,i,a,s,o){var c,f,u;return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.getAddress();case 2:return c=e.sent,e.next=5,Ik(c,i,o);case 5:return f=e.sent,e.next=8,s.populateTransaction.registerAndDepositEth(c,i,f.operator_signature,n,a);case 8:return u=e.sent,e.abrupt("return",t.sendTransaction(Bx(Bx({},u),{},{value:r})));case 10:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function jx(e,t,r,n,i,a){return Dx.apply(this,arguments)}function Dx(){return(Dx=EA(TA.mark((function e(t,r,n,i,a,s){var o;return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,s.populateTransaction["deposit(uint256,uint256,uint256)"](i,n,a);case 2:return o=e.sent,e.abrupt("return",t.sendTransaction(Bx(Bx({},o),{},{value:r})));case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Fx(e,t,r,n,i,a){return qx.apply(this,arguments)}function qx(){return(qx=EA(TA.mark((function e(t,r,n,i,a,s){var o,c,f,u,d,l,h,p,b,g,m;return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.getAddress();case 2:return o=e.sent,c={decimals:18},f=Px(r.amount,"wei"),u={user:o,token:{type:r.type,data:c},amount:f.toString()},e.next=8,n.getSignableDeposit({getSignableDepositRequest:u});case 8:return d=e.sent,e.next=11,a.encodeAsset({assetType:"asset",encodeAssetRequest:{token:{type:r.type}}});case 11:return l=e.sent,h=l.data.asset_type,p=d.data.stark_key,b=d.data.vault_id,g=fA.connect(s.ethConfiguration.coreContractAddress,t),m=vA.connect(s.ethConfiguration.registrationContractAddress,t),e.next=19,Rk(p,m);case 19:if(e.sent){e.next=24;break}return e.abrupt("return",Ux(t,f,h,p,b,g,i));case 24:return e.abrupt("return",jx(t,f,h,p,b,g));case 25:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function zx(e,t,r,n,i,a){return Kx.apply(this,arguments)}function Kx(){return(Kx=EA(TA.mark((function e(t,r,n,i,a,s){var o;return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,s.populateTransaction.depositERC20(i,n,a,r);case 2:return o=e.sent,e.abrupt("return",t.sendTransaction(o));case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Hx(e,t,r,n,i,a,s){return Gx.apply(this,arguments)}function Gx(){return(Gx=EA(TA.mark((function e(t,r,n,i,a,s,o){var c,f,u;return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.getAddress();case 2:return c=e.sent,e.next=5,Ik(c,i,o);case 5:return f=e.sent,e.next=8,s.populateTransaction.registerAndDepositERC20(c,i,f.operator_signature,n,a,r);case 8:return u=e.sent,e.abrupt("return",t.sendTransaction(u));case 10:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Vx(e,t,r,n,i,a,s){return Wx.apply(this,arguments)}function Wx(){return(Wx=EA(TA.mark((function e(t,r,n,i,a,s,o){var c,f,u,d,l,h,p,b,g,m,y,v,w,_,E,A;return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.getAddress();case 2:return c=e.sent,e.next=5,a.getToken({address:r.tokenAddress});case 5:return f=e.sent,u=parseInt(f.data.decimals),d={decimals:u,token_address:r.tokenAddress},l=Px(r.amount,0),h=iA.connect(r.tokenAddress,t),e.next=12,h.populateTransaction.approve(o.ethConfiguration.coreContractAddress,l);case 12:return p=e.sent,e.next=15,t.sendTransaction(p);case 15:return b={user:c,token:{type:r.type,data:d},amount:l.toString()},e.next=18,n.getSignableDeposit({getSignableDepositRequest:b});case 18:return g=e.sent,e.next=21,s.encodeAsset({assetType:"asset",encodeAssetRequest:{token:{type:r.type,data:{token_address:r.tokenAddress}}}});case 21:return m=e.sent,y=m.data.asset_type,v=g.data.stark_key,w=g.data.vault_id,_=Jk.from(g.data.amount),E=fA.connect(o.ethConfiguration.coreContractAddress,t),A=vA.connect(o.ethConfiguration.registrationContractAddress,t),e.next=30,Rk(v,A);case 30:if(e.sent){e.next=35;break}return e.abrupt("return",Hx(t,_,y,v,w,E,i));case 35:return e.abrupt("return",zx(t,_,y,v,w,E));case 36:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Xx(e,t,r,n,i,a){return $x.apply(this,arguments)}function $x(){return($x=EA(TA.mark((function e(t,r,n,i,a,s){var o;return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,s.populateTransaction.depositNft(i,n,a,r);case 2:return o=e.sent,e.abrupt("return",t.sendTransaction(o));case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Jx(e,t,r,n,i,a){return Yx.apply(this,arguments)}function Yx(){return(Yx=EA(TA.mark((function e(t,r,n,i,a,s){var o,c,f,u,d,l,h,p,b,g,m,y,v,w;return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.getAddress();case 2:return o=e.sent,c={token_address:r.tokenAddress,token_id:r.tokenId},f={user:o,token:{type:r.type,data:c},amount:"1".toString()},e.next=8,n.getSignableDeposit({getSignableDepositRequest:f});case 8:return u=e.sent,e.next=11,a.encodeAsset({assetType:"asset",encodeAssetRequest:{token:{type:r.type,data:{token_address:r.tokenAddress,token_id:r.tokenId}}}});case 11:return d=e.sent,l=d.data.asset_type,h=u.data.stark_key,p=u.data.vault_id,b=fA.connect(s.ethConfiguration.coreContractAddress,t),g=vA.connect(s.ethConfiguration.registrationContractAddress,t),e.next=19,Rk(h,g);case 19:return m=e.sent,y=sA.connect(r.tokenAddress,t),v=s.ethConfiguration.coreContractAddress,e.next=24,y.isApprovedForAll(o,v);case 24:if(e.sent){e.next=28;break}return e.next=28,y.setApprovalForAll(v,!0);case 28:if(m){e.next=34;break}return e.next=31,Ik(o,h,i);case 31:return w=e.sent,e.next=34,b.registerUser(o,h,w.operator_signature);case 34:return e.abrupt("return",Xx(t,r.tokenId,l,h,p,b));case 35:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var Qx=function(e){if(void 0!==e)return e;throw new Error("undefined field exception")};function Zx(e){return eT.apply(this,arguments)}function eT(){return(eT=EA(TA.mark((function e(t){var r,n,i,a,s,o,c,f,u,d,l,h,p;return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.ethSigner,n=t.starkSigner,i=t.withdrawalsApi,a="ERC721"===t.type?"1":t.amount,e.t0=i,e.next=5,r.getAddress();case 5:return e.t1=e.sent,e.t2=Sx(t),e.t3=a,e.t4={user:e.t1,token:e.t2,amount:e.t3},e.t5={getSignableWithdrawalRequest:e.t4},e.next=12,e.t0.getSignableWithdrawal.call(e.t0,e.t5);case 12:return s=e.sent,o=s.data,c=o.signable_message,f=o.payload_hash,e.next=16,n.signMessage(f);case 16:return u=e.sent,e.next=19,BA(c,r);case 19:return d=e.sent,l=d.ethAddress,h=d.ethSignature,e.next=24,i.createWithdrawal({createWithdrawalRequest:{stark_key:Qx(s.data.stark_key),amount:a,asset_id:Qx(s.data.asset_id),vault_id:Qx(s.data.vault_id),nonce:Qx(s.data.nonce),stark_signature:u},xImxEthAddress:l,xImxEthSignature:h});case 24:return p=e.sent,e.abrupt("return",p.data);case 26:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function tT(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function rT(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?tT(Object(r),!0).forEach((function(t){rA(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):tT(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function nT(e,t,r,n){return iT.apply(this,arguments)}function iT(){return(iT=EA(TA.mark((function e(t,r,n,i){var a;return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,n.encodeAsset({assetType:t,encodeAssetRequest:{token:rT({type:r},i&&{data:i})}});case 2:return a=e.sent,e.abrupt("return",a.data);case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function aT(e,t,r,n,i){return sT.apply(this,arguments)}function sT(){return(sT=EA(TA.mark((function e(t,r,n,i,a){var s,o,c;return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.getAddress();case 2:return s=e.sent,e.next=5,Ik(s,n,a);case 5:return o=e.sent,e.next=8,i.populateTransaction.registerAndWithdraw(s,n,o.operator_signature,r);case 8:return c=e.sent,e.abrupt("return",t.sendTransaction(c));case 10:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function oT(e,t,r,n){return cT.apply(this,arguments)}function cT(){return(cT=EA(TA.mark((function e(t,r,n,i){var a;return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,i.populateTransaction.withdraw(n,r);case 2:return a=e.sent,e.abrupt("return",t.sendTransaction(a));case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function fT(e,t,r,n,i,a){return uT.apply(this,arguments)}function uT(){return(uT=EA(TA.mark((function e(t,r,n,i,a,s){var o,c,f;return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,nT("asset","ERC20",i,{token_address:n.tokenAddress});case 2:return o=e.sent,c=fA.connect(s.ethConfiguration.coreContractAddress,t),f=vA.connect(s.ethConfiguration.registrationContractAddress,t),e.next=7,Rk(r,f);case 7:if(e.sent){e.next=12;break}return e.abrupt("return",aT(t,o.asset_type,r,f,a));case 12:return e.abrupt("return",oT(t,o.asset_type,r,c));case 13:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function dT(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function lT(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?dT(Object(r),!0).forEach((function(t){rA(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):dT(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function hT(e,t,r,n,i){return pT.apply(this,arguments)}function pT(){return(pT=EA(TA.mark((function e(t,r,n,i,a){var s;return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,a.populateTransaction.withdrawAndMint(n,r,i);case 2:return s=e.sent,e.abrupt("return",t.sendTransaction(s));case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function bT(e,t,r,n,i,a){return gT.apply(this,arguments)}function gT(){return(gT=EA(TA.mark((function e(t,r,n,i,a,s){var o,c,f;return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.getAddress();case 2:return o=e.sent,e.next=5,Ik(o,n,s);case 5:return c=e.sent,e.next=8,a.populateTransaction.regsiterAndWithdrawAndMint(o,n,c.operator_signature,r,i);case 8:return f=e.sent,e.abrupt("return",t.sendTransaction(f));case 10:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function mT(e){var t=e.data.id,r=e.data.blueprint||"";return Xf(kf("{".concat(t,"}:{").concat(r,"}")))}function yT(e,t,r,n,i,a){return vT.apply(this,arguments)}function vT(){return(vT=EA(TA.mark((function e(t,r,n,i,a,s){var o,c,f,u;return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,nT("mintable-asset","ERC721",i,lT({id:n.data.id,token_address:n.data.tokenAddress},n.data.blueprint&&{blueprint:n.data.blueprint}));case 2:return o=e.sent,c=mT(n),f=fA.connect(s.ethConfiguration.coreContractAddress,t),u=vA.connect(s.ethConfiguration.registrationContractAddress,t),e.next=8,Rk(r,u);case 8:if(e.sent){e.next=13;break}return e.abrupt("return",bT(t,o.asset_type,r,c,u,a));case 13:return e.abrupt("return",hT(t,o.asset_type,r,c,f));case 14:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function wT(e,t,r,n,i,a){return _T.apply(this,arguments)}function _T(){return(_T=EA(TA.mark((function e(t,r,n,i,a,s){var o,c,f;return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.getAddress();case 2:return o=e.sent,e.next=5,Ik(o,n,s);case 5:return c=e.sent,e.next=8,a.populateTransaction.registerAndWithdrawNft(o,n,c.operator_signature,r,i);case 8:return f=e.sent,e.abrupt("return",t.sendTransaction(f));case 10:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function ET(e,t,r,n,i){return AT.apply(this,arguments)}function AT(){return(AT=EA(TA.mark((function e(t,r,n,i,a){var s;return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,a.populateTransaction.withdrawNft(n,r,i);case 2:return s=e.sent,e.abrupt("return",t.sendTransaction(s));case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function ST(e,t,r,n,i,a){return kT.apply(this,arguments)}function kT(){return(kT=EA(TA.mark((function e(t,r,n,i,a,s){var o,c,f;return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,nT("asset","ERC721",i,{token_id:n.tokenId,token_address:n.tokenAddress});case 2:return o=e.sent,c=fA.connect(s.ethConfiguration.coreContractAddress,t),f=vA.connect(s.ethConfiguration.registrationContractAddress,t),e.next=7,Rk(r,f);case 7:if(e.sent){e.next=12;break}return e.abrupt("return",wT(t,o.asset_type,r,n.tokenId,f,a));case 12:return e.abrupt("return",ET(t,o.asset_type,r,n.tokenId,c));case 13:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function xT(e,t,r,n,i,a,s){return TT.apply(this,arguments)}function TT(){return(TT=EA(TA.mark((function e(t,r,n,i,a,s,o){var c,f;return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return c=n.tokenAddress,f=n.tokenId,e.next=4,a.getMintableTokenDetailsByClientTokenId({tokenAddress:c,tokenId:f}).then((function(e){return yT(t,r,{type:"ERC721",data:{id:f,tokenAddress:c,blueprint:e.data.blueprint}},i,s,o)})).catch((function(e){var a;if(404===(null===(a=e.response)||void 0===a?void 0:a.status))return ST(t,r,n,i,s,o);throw e}));case 4:return e.abrupt("return",e.sent);case 5:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function RT(e,t,r,n,i){return OT.apply(this,arguments)}function OT(){return(OT=EA(TA.mark((function e(t,r,n,i,a){var s,o,c;return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.getAddress();case 2:return s=e.sent,e.next=5,Ik(s,n,a);case 5:return o=e.sent,e.next=8,i.populateTransaction.registerAndWithdraw(s,n,o.operator_signature,r);case 8:return c=e.sent,e.abrupt("return",t.sendTransaction(c));case 10:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function IT(e,t,r,n){return MT.apply(this,arguments)}function MT(){return(MT=EA(TA.mark((function e(t,r,n,i){var a;return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,i.populateTransaction.withdraw(n,r);case 2:return a=e.sent,e.abrupt("return",t.sendTransaction(a));case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function CT(e,t,r,n,i){return PT.apply(this,arguments)}function PT(){return(PT=EA(TA.mark((function e(t,r,n,i,a){var s,o,c;return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,nT("asset","ETH",n);case 2:return s=e.sent,o=fA.connect(a.ethConfiguration.coreContractAddress,t),c=vA.connect(a.ethConfiguration.registrationContractAddress,t),e.next=7,Rk(r,c);case 7:if(e.sent){e.next=12;break}return e.abrupt("return",RT(t,s.asset_type,r,c,i));case 12:return e.abrupt("return",IT(t,s.asset_type,r,o));case 13:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function NT(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function BT(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?NT(Object(r),!0).forEach((function(t){rA(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):NT(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function UT(e){return LT.apply(this,arguments)}function LT(){return(LT=EA(TA.mark((function e(t){var r,n,i,a,s,o,c,f,u,d,l,h,p,b,g,m,y;return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.ethSigner,n=t.starkSigner,i=t.request,a=t.ordersApi,e.next=3,r.getAddress();case 3:return s=e.sent,o="ERC721"===i.sell.type?"1":i.sell.amount,c="ERC721"===i.buy.type?"1":i.buy.amount,f={user:s,amount_buy:c,token_buy:Sx(i.buy),amount_sell:o,token_sell:Sx(i.sell),fees:i.fees,expiration_timestamp:i.expiration_timestamp,split_fees:!0},e.next=9,a.getSignableOrder({getSignableOrderRequestV3:f});case 9:return u=e.sent,d=u.data,l=d.signable_message,h=d.payload_hash,e.next=13,MA(l,r);case 13:return p=e.sent,e.next=16,n.signMessage(h);case 16:return b=e.sent,g=u.data,m={createOrderRequest:{amount_buy:g.amount_buy,amount_sell:g.amount_sell,asset_id_buy:g.asset_id_buy,asset_id_sell:g.asset_id_sell,expiration_timestamp:g.expiration_timestamp,include_fees:!0,fees:i.fees,nonce:g.nonce,stark_key:g.stark_key,stark_signature:b,vault_id_buy:g.vault_id_buy,vault_id_sell:g.vault_id_sell},xImxEthAddress:s,xImxEthSignature:p},e.next=21,a.createOrderV3(m);case 21:return y=e.sent,e.abrupt("return",BT({},y.data));case 23:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function jT(e){return DT.apply(this,arguments)}function DT(){return(DT=EA(TA.mark((function e(t){var r,n,i,a,s,o,c,f,u,d,l,h;return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.ethSigner,n=t.starkSigner,i=t.request,a=t.ordersApi,e.next=3,a.getSignableCancelOrderV3({getSignableCancelOrderRequest:{order_id:i.order_id}});case 3:return s=e.sent,o=s.data,c=o.signable_message,f=o.payload_hash,e.next=7,MA(c,r);case 7:return u=e.sent,e.next=10,n.signMessage(f);case 10:return d=e.sent,e.next=13,r.getAddress();case 13:return l=e.sent,e.next=16,a.cancelOrderV3({id:i.order_id.toString(),cancelOrderRequest:{order_id:i.order_id,stark_signature:d},xImxEthAddress:l,xImxEthSignature:u});case 16:return h=e.sent,e.abrupt("return",{order_id:h.data.order_id,status:h.data.status});case 18:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function FT(e){return qT.apply(this,arguments)}function qT(){return(qT=EA(TA.mark((function e(t){var r,n,i,a,s,o,c,f,u,d,l,h;return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.ethSigner,n=t.starkSigner,i=t.request,a=t.tradesApi,e.next=3,r.getAddress();case 3:return s=e.sent,e.next=6,a.getSignableTrade({getSignableTradeRequest:{user:s,order_id:i.order_id,fees:i.fees}});case 6:return o=e.sent,c=o.data,f=c.signable_message,u=c.payload_hash,e.next=10,MA(f,r);case 10:return d=e.sent,e.next=13,n.signMessage(u);case 13:return l=e.sent,e.next=16,a.createTradeV3({createTradeRequest:{amount_buy:o.data.amount_buy,amount_sell:o.data.amount_sell,asset_id_buy:o.data.asset_id_buy,asset_id_sell:o.data.asset_id_sell,expiration_timestamp:o.data.expiration_timestamp,fee_info:o.data.fee_info,fees:i.fees,include_fees:!0,nonce:o.data.nonce,order_id:i.order_id,stark_key:o.data.stark_key,vault_id_buy:o.data.vault_id_buy,vault_id_sell:o.data.vault_id_sell,stark_signature:l},xImxEthAddress:s,xImxEthSignature:d});case 16:return h=e.sent,e.abrupt("return",h.data);case 18:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function zT(e){return KT.apply(this,arguments)}function KT(){return(KT=EA(TA.mark((function e(t){var r,n,i,a,s,o,c,f,u,d,l,h,p,b,g;return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.ethSigner,i=t.starkSigner,a=t.request,s=t.exchangesApi,e.next=3,n.getAddress();case 3:return o=e.sent,c=a.amount,e.next=7,s.getExchangeSignableTransfer({id:a.transactionID,getSignableTransferRequest:{sender:o,token:Sx(a),amount:c,receiver:a.receiver}});case 7:return f=e.sent,u=f.data,d=u.signable_message,l=u.payload_hash,e.next=11,MA(d,n);case 11:return h=e.sent,e.next=14,i.signMessage(l);case 14:return p=e.sent,b={sender_stark_key:f.data.sender_stark_key,sender_vault_id:f.data.sender_vault_id,receiver_stark_key:f.data.receiver_stark_key,receiver_vault_id:f.data.receiver_vault_id,asset_id:f.data.asset_id,amount:f.data.amount,nonce:f.data.nonce,expiration_timestamp:f.data.expiration_timestamp,stark_signature:p},e.next=18,s.createExchangeTransfer({id:a.transactionID,createTransferRequest:b,xImxEthAddress:o,xImxEthSignature:h});case 18:return g=e.sent,e.abrupt("return",{sent_signature:null==g?void 0:g.data.sent_signature,status:null==g||null===(r=g.data.status)||void 0===r?void 0:r.toString(),time:null==g?void 0:g.data.time,transfer_id:null==g?void 0:g.data.transfer_id});case 20:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function HT(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function GT(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?HT(Object(r),!0).forEach((function(t){rA(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):HT(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var VT=function(){function e(t){ZE(this,e),this.config=t;var r=t.apiConfiguration;this.config=t,this.depositsApi=new xS(r),this.encodingApi=new IS(r),this.mintsApi=new VS(r),this.ordersApi=new ek(r),this.tokensApi=new ck(r),this.tradesApi=new lk(r),this.transfersApi=new gk(r),this.usersApi=new wk(r),this.withdrawalsApi=new Sk(r),this.projectsApi=new ik(r),this.collectionsApi=new ES(r),this.metadataApi=new jS(r),this.metadataRefreshesApi=new zS(r),this.exchangesApi=new NS(r)}var t,r,n,i,a,s,o,c,f,u,d,l,h,p,b,g,m,y,v,w,_,E,A,S,k,x,T,R;return tA(e,[{key:"isChainValid",value:function(e){return e===this.config.ethConfiguration.chainID}},{key:"validateChain",value:(R=EA(TA.mark((function e(t){var r;return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.getChainId();case 2:if(r=e.sent,this.isChainValid(r)){e.next=5;break}throw new Error("The wallet used for this operation is not from the correct network.");case 5:case"end":return e.stop()}}),e,this)}))),function(e){return R.apply(this,arguments)})},{key:"registerOffchain",value:(T=EA(TA.mark((function e(t){return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.validateChain(t.ethSigner);case 2:return e.abrupt("return",xk(GT(GT({},t),{},{usersApi:this.usersApi})));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return T.apply(this,arguments)})},{key:"isRegisteredOnchain",value:(x=EA(TA.mark((function e(t){var r,n;return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.validateChain(t.ethSigner);case 2:return r=vA.connect(this.config.ethConfiguration.registrationContractAddress,t.ethSigner),e.next=5,t.starkSigner.getAddress();case 5:return n=e.sent,e.abrupt("return",Rk(n,r));case 7:case"end":return e.stop()}}),e,this)}))),function(e){return x.apply(this,arguments)})},{key:"mint",value:(k=EA(TA.mark((function e(t,r){return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.validateChain(t);case 2:return e.abrupt("return",Ex(t,r,this.mintsApi));case 3:case"end":return e.stop()}}),e,this)}))),function(e,t){return k.apply(this,arguments)})},{key:"transfer",value:(S=EA(TA.mark((function e(t,r){return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.validateChain(t.ethSigner);case 2:return e.abrupt("return",Tx(GT(GT({},t),{},{request:r,transfersApi:this.transfersApi})));case 3:case"end":return e.stop()}}),e,this)}))),function(e,t){return S.apply(this,arguments)})},{key:"exchangeTransfer",value:(A=EA(TA.mark((function e(t,r){return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.validateChain(t.ethSigner);case 2:return e.abrupt("return",zT(GT(GT({},t),{},{request:r,exchangesApi:this.exchangesApi})));case 3:case"end":return e.stop()}}),e,this)}))),function(e,t){return A.apply(this,arguments)})},{key:"batchNftTransfer",value:(E=EA(TA.mark((function e(t,r){return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.validateChain(t.ethSigner);case 2:return e.abrupt("return",Ox(GT(GT({},t),{},{request:r,transfersApi:this.transfersApi})));case 3:case"end":return e.stop()}}),e,this)}))),function(e,t){return E.apply(this,arguments)})},{key:"deposit",value:(_=EA(TA.mark((function e(t,r){return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:e.t0=r.type,e.next="ETH"===e.t0?3:"ERC20"===e.t0?4:"ERC721"===e.t0?5:6;break;case 3:return e.abrupt("return",this.depositEth(t,r));case 4:return e.abrupt("return",this.depositERC20(t,r));case 5:return e.abrupt("return",this.depositERC721(t,r));case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return _.apply(this,arguments)})},{key:"depositEth",value:(w=EA(TA.mark((function e(t,r){return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.validateChain(t);case 2:return e.abrupt("return",Fx(t,r,this.depositsApi,this.usersApi,this.encodingApi,this.config));case 3:case"end":return e.stop()}}),e,this)}))),function(e,t){return w.apply(this,arguments)})},{key:"depositERC20",value:(v=EA(TA.mark((function e(t,r){return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.validateChain(t);case 2:return e.abrupt("return",Vx(t,r,this.depositsApi,this.usersApi,this.tokensApi,this.encodingApi,this.config));case 3:case"end":return e.stop()}}),e,this)}))),function(e,t){return v.apply(this,arguments)})},{key:"depositERC721",value:(y=EA(TA.mark((function e(t,r){return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.validateChain(t);case 2:return e.abrupt("return",Jx(t,r,this.depositsApi,this.usersApi,this.encodingApi,this.config));case 3:case"end":return e.stop()}}),e,this)}))),function(e,t){return y.apply(this,arguments)})},{key:"prepareWithdrawal",value:(m=EA(TA.mark((function e(t,r){return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.validateChain(t.ethSigner);case 2:return e.abrupt("return",Zx(GT(GT(GT({},t),r),{},{withdrawalsApi:this.withdrawalsApi})));case 3:case"end":return e.stop()}}),e,this)}))),function(e,t){return m.apply(this,arguments)})},{key:"completeWithdrawal",value:function(e,t,r){switch(r.type){case"ETH":return this.completeEthWithdrawal(e,t);case"ERC20":return this.completeERC20Withdrawal(e,t,r);case"ERC721":return this.completeERC721Withdrawal(e,t,r)}}},{key:"completeEthWithdrawal",value:(g=EA(TA.mark((function e(t,r){return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.validateChain(t);case 2:return e.abrupt("return",CT(t,r,this.encodingApi,this.usersApi,this.config));case 3:case"end":return e.stop()}}),e,this)}))),function(e,t){return g.apply(this,arguments)})},{key:"completeERC20Withdrawal",value:(b=EA(TA.mark((function e(t,r,n){return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.validateChain(t);case 2:return e.abrupt("return",fT(t,r,n,this.encodingApi,this.usersApi,this.config));case 3:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return b.apply(this,arguments)})},{key:"completeERC721Withdrawal",value:function(){var e=EA(TA.mark((function e(t,r,n){return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.validateChain(t);case 2:return e.abrupt("return",xT(t,r,n,this.encodingApi,this.mintsApi,this.usersApi,this.config));case 3:case"end":return e.stop()}}),e,this)})));return function(t,r,n){return e.apply(this,arguments)}}()},{key:"createOrder",value:(p=EA(TA.mark((function e(t,r){return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.validateChain(t.ethSigner);case 2:return e.abrupt("return",UT(GT(GT({},t),{},{request:r,ordersApi:this.ordersApi})));case 3:case"end":return e.stop()}}),e,this)}))),function(e,t){return p.apply(this,arguments)})},{key:"cancelOrder",value:(h=EA(TA.mark((function e(t,r){return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.validateChain(t.ethSigner);case 2:return e.abrupt("return",jT(GT(GT({},t),{},{request:r,ordersApi:this.ordersApi})));case 3:case"end":return e.stop()}}),e,this)}))),function(e,t){return h.apply(this,arguments)})},{key:"createTrade",value:(l=EA(TA.mark((function e(t,r){return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.validateChain(t.ethSigner);case 2:return e.abrupt("return",FT(GT(GT({},t),{},{request:r,tradesApi:this.tradesApi})));case 3:case"end":return e.stop()}}),e,this)}))),function(e,t){return l.apply(this,arguments)})},{key:"createProject",value:(d=EA(TA.mark((function e(t,r){var n;return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,PA(t);case 2:return n=e.sent,e.abrupt("return",this.projectsApi.createProject({iMXSignature:n.signature,iMXTimestamp:n.timestamp,createProjectRequest:r}));case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return d.apply(this,arguments)})},{key:"getProject",value:(u=EA(TA.mark((function e(t,r){var n;return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,PA(t);case 2:return n=e.sent,e.abrupt("return",this.projectsApi.getProject({id:r,iMXSignature:n.signature,iMXTimestamp:n.timestamp}));case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return u.apply(this,arguments)})},{key:"getProjects",value:(f=EA(TA.mark((function e(t,r,n,i,a){var s;return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,PA(t);case 2:return s=e.sent,e.abrupt("return",this.projectsApi.getProjects({iMXSignature:s.signature,iMXTimestamp:s.timestamp,pageSize:r,cursor:n,orderBy:i,direction:a}));case 4:case"end":return e.stop()}}),e,this)}))),function(e,t,r,n,i){return f.apply(this,arguments)})},{key:"createCollection",value:(c=EA(TA.mark((function e(t,r){var n;return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,PA(t);case 2:return n=e.sent,e.abrupt("return",this.collectionsApi.createCollection({iMXSignature:n.signature,iMXTimestamp:n.timestamp,createCollectionRequest:r}));case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return c.apply(this,arguments)})},{key:"updateCollection",value:(o=EA(TA.mark((function e(t,r,n){var i;return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,PA(t);case 2:return i=e.sent,e.abrupt("return",this.collectionsApi.updateCollection({iMXSignature:i.signature,iMXTimestamp:i.timestamp,address:r,updateCollectionRequest:n}));case 4:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return o.apply(this,arguments)})},{key:"addMetadataSchemaToCollection",value:(s=EA(TA.mark((function e(t,r,n){var i;return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,PA(t);case 2:return i=e.sent,e.abrupt("return",this.metadataApi.addMetadataSchemaToCollection({iMXSignature:i.signature,iMXTimestamp:i.timestamp,addMetadataSchemaToCollectionRequest:n,address:r}));case 4:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return s.apply(this,arguments)})},{key:"updateMetadataSchemaByName",value:(a=EA(TA.mark((function e(t,r,n,i){var a;return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,PA(t);case 2:return a=e.sent,e.abrupt("return",this.metadataApi.updateMetadataSchemaByName({iMXSignature:a.signature,iMXTimestamp:a.timestamp,address:r,name:n,metadataSchemaRequest:i}));case 4:case"end":return e.stop()}}),e,this)}))),function(e,t,r,n){return a.apply(this,arguments)})},{key:"listMetadataRefreshes",value:(i=EA(TA.mark((function e(t,r,n,i){var a,s;return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,PA(t);case 2:return a=e.sent,e.next=5,t.getAddress();case 5:return s=e.sent,e.abrupt("return",this.metadataRefreshesApi.getAListOfMetadataRefreshes({xImxEthSignature:a.signature,xImxEthTimestamp:a.timestamp,xImxEthAddress:s,collectionAddress:r,pageSize:n,cursor:i}));case 7:case"end":return e.stop()}}),e,this)}))),function(e,t,r,n){return i.apply(this,arguments)})},{key:"getMetadataRefreshErrors",value:(n=EA(TA.mark((function e(t,r,n,i){var a,s;return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,PA(t);case 2:return a=e.sent,e.next=5,t.getAddress();case 5:return s=e.sent,e.abrupt("return",this.metadataRefreshesApi.getMetadataRefreshErrors({xImxEthSignature:a.signature,xImxEthTimestamp:a.timestamp,xImxEthAddress:s,refreshId:r,pageSize:n,cursor:i}));case 7:case"end":return e.stop()}}),e,this)}))),function(e,t,r,i){return n.apply(this,arguments)})},{key:"getMetadataRefreshResults",value:(r=EA(TA.mark((function e(t,r){var n,i;return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,PA(t);case 2:return n=e.sent,e.next=5,t.getAddress();case 5:return i=e.sent,e.abrupt("return",this.metadataRefreshesApi.getMetadataRefreshResults({xImxEthSignature:n.signature,xImxEthTimestamp:n.timestamp,xImxEthAddress:i,refreshId:r}));case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"createMetadataRefresh",value:(t=EA(TA.mark((function e(t,r){var n,i;return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,PA(t);case 2:return n=e.sent,e.next=5,t.getAddress();case 5:return i=e.sent,e.abrupt("return",this.metadataRefreshesApi.requestAMetadataRefresh({xImxEthSignature:n.signature,xImxEthTimestamp:n.timestamp,xImxEthAddress:i,createMetadataRefreshRequest:r}));case 7:case"end":return e.stop()}}),e,this)}))),function(e,r){return t.apply(this,arguments)})}]),e}();var WT=function(e){hA(r,QA(Error));var t=function(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=uA(e);if(t){var i=uA(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return gA(this,r)}}(r);function r(e){var n,i=e.code,a=e.details,s=e.message;return ZE(this,r),(n=t.call(this,s)).code=i,n.details=a,n}return tA(r)}();function XT(e){if(QE.isAxiosError(e)&&e.response){var t,r,n,i=e.response.data;return i.code&&i.message?new WT({code:i.code,details:i.details,message:i.message}):new WT({code:null!==(t=null!==(r=e.code)&&void 0!==r?r:null===(n=e.response)||void 0===n?void 0:n.status.toString())&&void 0!==t?t:"unknown_error_code",message:String(e)})}return new WT({code:"unknown_error_code",message:String(e)})}var $T=function(){function e(t){ZE(this,e),this.depositsApi=new xS(t.apiConfiguration),this.mintsApi=new VS(t.apiConfiguration),this.ordersApi=new ek(t.apiConfiguration),this.tokensApi=new ck(t.apiConfiguration),this.tradesApi=new lk(t.apiConfiguration),this.transfersApi=new gk(t.apiConfiguration),this.exchangeApi=new NS(t.apiConfiguration),this.usersApi=new wk(t.apiConfiguration),this.withdrawalsApi=new Sk(t.apiConfiguration),this.balanceApi=new yS(t.apiConfiguration),this.assetApi=new pS(t.apiConfiguration),this.collectionApi=new ES(t.apiConfiguration),this.metadataApi=new jS(t.apiConfiguration),this.metadataRefreshesApi=new zS(t.apiConfiguration),this.nftCheckoutPrimaryApi=new JS(t.apiConfiguration),this.projectsApi=new ik(t.apiConfiguration),this.workflows=new VT(t)}var t,r,n;return tA(e,[{key:"deposit",value:function(e,t){return this.workflows.deposit(e,t).catch((function(e){throw XT(e)}))}},{key:"getDeposit",value:function(e){return this.depositsApi.getDeposit(e).then((function(e){return e.data})).catch((function(e){throw XT(e)}))}},{key:"listDeposits",value:function(e){return this.depositsApi.listDeposits(e).then((function(e){return e.data})).catch((function(e){throw XT(e)}))}},{key:"registerOffchain",value:function(e){return this.workflows.registerOffchain(e).catch((function(e){throw XT(e)}))}},{key:"isRegisteredOnchain",value:function(e){return this.workflows.isRegisteredOnchain(e).catch((function(e){throw XT(e)}))}},{key:"getUser",value:function(e){return this.usersApi.getUsers({user:e}).then((function(e){return e.data})).catch((function(e){throw XT(e)}))}},{key:"getAsset",value:function(e){return this.assetApi.getAsset(e).then((function(e){return e.data})).catch((function(e){throw XT(e)}))}},{key:"listAssets",value:function(e){return this.assetApi.listAssets(e).then((function(e){return e.data})).catch((function(e){throw XT(e)}))}},{key:"createCollection",value:function(e,t){return this.workflows.createCollection(e,t).then((function(e){return e.data})).catch((function(e){throw XT(e)}))}},{key:"getCollection",value:function(e){return this.collectionApi.getCollection(e).then((function(e){return e.data})).catch((function(e){throw XT(e)}))}},{key:"listCollectionFilters",value:function(e){return this.collectionApi.listCollectionFilters(e).then((function(e){return e.data})).catch((function(e){throw XT(e)}))}},{key:"listCollections",value:function(e){return this.collectionApi.listCollections(e).then((function(e){return e.data})).catch((function(e){throw XT(e)}))}},{key:"updateCollection",value:function(e,t,r){return this.workflows.updateCollection(e,t,r).then((function(e){return e.data})).catch((function(e){throw XT(e)}))}},{key:"addMetadataSchemaToCollection",value:function(e,t,r){return this.workflows.addMetadataSchemaToCollection(e,t,r).then((function(e){return e.data})).catch((function(e){throw XT(e)}))}},{key:"getMetadataSchema",value:function(e){return this.metadataApi.getMetadataSchema(e).then((function(e){return e.data})).catch((function(e){throw XT(e)}))}},{key:"updateMetadataSchemaByName",value:function(e,t,r,n){return this.workflows.updateMetadataSchemaByName(e,t,r,n).then((function(e){return e.data})).catch((function(e){throw XT(e)}))}},{key:"listMetadataRefreshes",value:function(e,t,r,n){return this.workflows.listMetadataRefreshes(e,t,r,n).then((function(e){return e.data})).catch((function(e){throw XT(e)}))}},{key:"getMetadataRefreshErrors",value:function(e,t,r,n){return this.workflows.getMetadataRefreshErrors(e,t,r,n).then((function(e){return e.data})).catch((function(e){throw XT(e)}))}},{key:"getMetadataRefreshResults",value:function(e,t){return this.workflows.getMetadataRefreshResults(e,t).then((function(e){return e.data})).catch((function(e){throw XT(e)}))}},{key:"createMetadataRefresh",value:function(e,t){return this.workflows.createMetadataRefresh(e,t).then((function(e){return e.data})).catch((function(e){throw XT(e)}))}},{key:"createProject",value:(n=EA(TA.mark((function e(t,r){return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.workflows.createProject(t,r).then((function(e){return e.data})).catch((function(e){throw XT(e)})));case 1:case"end":return e.stop()}}),e,this)}))),function(e,t){return n.apply(this,arguments)})},{key:"getProject",value:(r=EA(TA.mark((function e(t,r){return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.workflows.getProject(t,r).then((function(e){return e.data})).catch((function(e){throw XT(e)})));case 1:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"getProjects",value:(t=EA(TA.mark((function e(t,r,n,i,a){return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.workflows.getProjects(t,r,n,i,a).then((function(e){return e.data})).catch((function(e){throw XT(e)})));case 1:case"end":return e.stop()}}),e,this)}))),function(e,r,n,i,a){return t.apply(this,arguments)})},{key:"getBalance",value:function(e){return this.balanceApi.getBalance(e).then((function(e){return e.data})).catch((function(e){throw XT(e)}))}},{key:"listBalances",value:function(e){return this.balanceApi.listBalances(e).then((function(e){return e.data})).catch((function(e){throw XT(e)}))}},{key:"getMint",value:function(e){return this.mintsApi.getMint(e).then((function(e){return e.data})).catch((function(e){throw XT(e)}))}},{key:"listMints",value:function(e){return this.mintsApi.listMints(e).then((function(e){return e.data})).catch((function(e){throw XT(e)}))}},{key:"mint",value:function(e,t){return this.workflows.mint(e,t).catch((function(e){throw XT(e)}))}},{key:"listWithdrawals",value:function(e){return this.withdrawalsApi.listWithdrawals(e).then((function(e){return e.data})).catch((function(e){throw XT(e)}))}},{key:"getWithdrawal",value:function(e){return this.withdrawalsApi.getWithdrawal(e).then((function(e){return e.data})).catch((function(e){throw XT(e)}))}},{key:"prepareWithdrawal",value:function(e,t){return this.workflows.prepareWithdrawal(e,t).catch((function(e){throw XT(e)}))}},{key:"completeWithdrawal",value:function(e,t,r){return this.workflows.completeWithdrawal(e,t,r).catch((function(e){throw XT(e)}))}},{key:"getOrder",value:function(e){return this.ordersApi.getOrderV3(e).then((function(e){return e.data})).catch((function(e){throw XT(e)}))}},{key:"listOrders",value:function(e){return this.ordersApi.listOrdersV3(e).then((function(e){return e.data})).catch((function(e){throw XT(e)}))}},{key:"createOrder",value:function(e,t){return this.workflows.createOrder(e,t).catch((function(e){throw XT(e)}))}},{key:"cancelOrder",value:function(e,t){return this.workflows.cancelOrder(e,t).catch((function(e){throw XT(e)}))}},{key:"getTrade",value:function(e){return this.tradesApi.getTrade(e).then((function(e){return e.data})).catch((function(e){throw XT(e)}))}},{key:"listTrades",value:function(e){return this.tradesApi.listTradesV3(e).then((function(e){return e.data})).catch((function(e){throw XT(e)}))}},{key:"createTrade",value:function(e,t){return this.workflows.createTrade(e,t).catch((function(e){throw XT(e)}))}},{key:"getToken",value:function(e){return this.tokensApi.getToken(e).then((function(e){return e.data})).catch((function(e){throw XT(e)}))}},{key:"listTokens",value:function(e){return this.tokensApi.listTokens(e).then((function(e){return e.data})).catch((function(e){throw XT(e)}))}},{key:"getTransfer",value:function(e){return this.transfersApi.getTransfer(e).then((function(e){return e.data})).catch((function(e){throw XT(e)}))}},{key:"listTransfers",value:function(e){return this.transfersApi.listTransfers(e).then((function(e){return e.data})).catch((function(e){throw XT(e)}))}},{key:"transfer",value:function(e,t){return this.workflows.transfer(e,t).catch((function(e){throw XT(e)}))}},{key:"batchNftTransfer",value:function(e,t){return this.workflows.batchNftTransfer(e,t).catch((function(e){throw XT(e)}))}},{key:"createExchange",value:function(e){return this.exchangeApi.createExchange(e).catch((function(e){throw XT(e)}))}},{key:"getExchange",value:function(e){return this.exchangeApi.getExchange(e).catch((function(e){throw XT(e)}))}},{key:"getExchanges",value:function(e){return this.exchangeApi.getExchanges(e).catch((function(e){throw XT(e)}))}},{key:"exchangeTransfer",value:function(e,t){return this.workflows.exchangeTransfer(e,t).catch((function(e){throw XT(e)}))}},{key:"createNftPrimary",value:function(e){return this.nftCheckoutPrimaryApi.createNftPrimary(e).catch((function(e){throw XT(e)}))}},{key:"getCurrenciesNFTCheckoutPrimary",value:function(e){return this.nftCheckoutPrimaryApi.getCurrenciesNFTCheckoutPrimary(e).catch((function(e){throw XT(e)}))}},{key:"getNftPrimaryTransaction",value:function(e){return this.nftCheckoutPrimaryApi.getNftPrimaryTransaction(e).catch((function(e){throw XT(e)}))}},{key:"getNftPrimaryTransactions",value:function(e){return this.nftCheckoutPrimaryApi.getNftPrimaryTransactions(e).catch((function(e){throw XT(e)}))}}]),e}();function JT(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function YT(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?JT(Object(r),!0).forEach((function(t){rA(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):JT(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var QT={"x-sdk-version":"imx-core-sdk-ts-".concat("2.0.2")},ZT=function(e){var t=e.coreContractAddress,r=e.registrationContractAddress,n=e.chainID,i=e.basePath,a=e.headers,s=e.sdkVersion;if(!i.trim())throw Error("basePath can not be empty");return s&&(QT["x-sdk-version"]=s),a=YT(YT({},a||{}),QT),{apiConfiguration:new kk({basePath:i,baseOptions:{headers:a}}),ethConfiguration:{coreContractAddress:t,registrationContractAddress:r,chainID:n}}},eR={get PRODUCTION(){return ZT({basePath:"https://api.x.immutable.com",chainID:1,coreContractAddress:"0x5FDCCA53617f4d2b9134B29090C87D01058e27e9",registrationContractAddress:"0x72a06bf2a1CE5e39cBA06c0CAb824960B587d64c"})},get SANDBOX(){return ZT({basePath:"https://api.sandbox.x.immutable.com",chainID:5,coreContractAddress:"0x7917eDb51ecD6CdB3F9854c3cc593F33de10c623",registrationContractAddress:"0x1C97Ada273C9A52253f463042f29117090Cd7D83"})},createConfig:ZT},tR=new ce("08000000 00000010 ffffffff ffffffff b781126d cae7b232 1e66a241 adc64d2f",16);new Yf.ec(new Yf.curves.PresetCurve({type:"short",prime:null,p:"08000000 00000011 00000000 00000000 00000000 00000000 00000000 00000001",a:"00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000001",b:"06f21413 efbe40de 150e596d 72f7a8c5 609ad26c 15c915c1 f4cdfcb9 9cee9e89",n:tR.toString("hex"),hash:Za.sha256,gRed:!1,g:["1ef15c18599971b7beced415a40f0c7deacfd9b0d1819e03d723d8bc943cfca","5668060aa49730b7be4801df46ec62de53ecd11abe43a32873000c36e8dc1f"]}));var rR=function(){var e=new ce("1 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000",16);return e.sub(e.mod(tR))};function nR(e,t){return new ce(Za.sha256().update(vf(Gf(e)+qf(xf(t),2))).digest("hex"),16)}function iR(e){for(var t=rR(),r=nR(e.toString("hex",64),0),n=0;r.gte(t);n++)r=nR(r.toString("hex"),n);return r.umod(tR).toString("hex")}function aR(e){for(var t=rR(),r=nR(e.toString("hex",64),0),n=1;r.gte(t);n++)r=nR(r.toString("hex"),n);return r.umod(tR).toString("hex")}function sR(e){var t=rR();return nR(e.toString("hex",64),0).gte(t)}function oR(e){return cR.apply(this,arguments)}function cR(){return(cR=EA(TA.mark((function e(t){var r,n;return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,r=new $T(eR.PRODUCTION),e.next=4,r.getUser(t);case 4:if(!((n=e.sent).accounts.length>0)){e.next=7;break}return e.abrupt("return",{starkPublicKey:n.accounts[0],accountNotFound:!1});case 7:e.next=14;break;case 9:if(e.prev=9,e.t0=e.catch(0),!(e.t0 instanceof WT&&"account_not_found"==e.t0.code)){e.next=13;break}return e.abrupt("return",{starkPublicKey:"",accountNotFound:!0});case 13:throw e.t0;case 14:case"end":return e.stop()}}),e,null,[[0,9]])})))).apply(this,arguments)}function fR(e,t){var r=h_.hdkey.fromMasterSeed(Buffer.from(e.slice(2),"hex")).derivePath(t).getWallet().getPrivateKey();return new ce(r)}function uR(e,t,r){return dR.apply(this,arguments)}function dR(){return(dR=EA(TA.mark((function e(t,r,n){var i,a,s,o,c,f,u,d;return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=fR(t,r),a=aR(i),sR(i)){e.next=4;break}return e.abrupt("return",a);case 4:return e.next=6,oR(n);case 6:if(void 0!==(s=e.sent)){e.next=9;break}throw new Error("Error fetching stark public key from IMX");case 9:if(!s.accountNotFound){e.next=11;break}return e.abrupt("return",a);case 11:return o=new ce(Gf(s.starkPublicKey),16),e.next=14,JA(a).getAddress();case 14:if(c=e.sent,!o.eq(new ce(Gf(c),16))){e.next=17;break}return e.abrupt("return",a);case 17:return f=iR(i),e.next=20,JA(f).getAddress();case 20:if(c=e.sent,!o.eq(new ce(Gf(c),16))){e.next=23;break}return e.abrupt("return",f);case 23:return u=XA(t,r),d=WA(u),e.next=27,JA(d).getAddress();case 27:if(c=e.sent,!o.eq(new ce(Gf(c),16))){e.next=30;break}return e.abrupt("return",d);case 30:throw new Error("Can not deterministically generate stark private key - please contact support");case 31:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function lR(e){return hR.apply(this,arguments)}function hR(){return(hR=EA(TA.mark((function e(t){var r,n,i,a,s;return TA.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.getAddress();case 2:return r=e.sent.toLowerCase(),e.next=5,t.signMessage("Only sign this request if you’ve initiated an action with Immutable X.");case 5:return n=e.sent,i=Le(n).s,a=GA("starkex","immutablex",r,"1"),e.next=10,uR(i,a,r);case 10:return s=e.sent,e.abrupt("return",s.padStart(64,"0"));case 12:case"end":return e.stop()}}),e)})))).apply(this,arguments)}Gk.errors.INSUFFICIENT_FUNDS,Gk.errors.NONCE_EXPIRED,Gk.errors.REPLACEMENT_UNDERPRICED;const pR=({basePath:e,chainID:t,coreContractAddress:r,registrationContractAddress:n})=>eR.createConfig({basePath:e,chainID:t,coreContractAddress:r,registrationContractAddress:n,sdkVersion:"ts-immutable-sdk-0.0.0"}),bR=()=>pR({basePath:"https://api.sandbox.x.immutable.com",chainID:5,coreContractAddress:"0x7917eDb51ecD6CdB3F9854c3cc593F33de10c623",registrationContractAddress:"0x1C97Ada273C9A52253f463042f29117090Cd7D83"});class gR{immutableXConfig;baseConfig;constructor({baseConfig:t,overrides:r}){if(this.baseConfig=t,r)this.immutableXConfig=r.immutableXConfig;else switch(t.environment){case e.Environment.SANDBOX:this.immutableXConfig=bR();break;case e.Environment.PRODUCTION:this.immutableXConfig=pR({basePath:"https://api.x.immutable.com",chainID:1,coreContractAddress:"0x5FDCCA53617f4d2b9134B29090C87D01058e27e9",registrationContractAddress:"0x72a06bf2a1CE5e39cBA06c0CAb824960B587d64c"});break;default:this.immutableXConfig=bR()}}}class mR{immutableX;depositsApi;mintsApi;ordersApi;tokensApi;tradesApi;transfersApi;exchangeApi;nftCheckoutPrimaryApi;usersApi;withdrawalsApi;balanceApi;assetApi;collectionApi;metadataApi;metadataRefreshesApi;projectsApi;constructor(e){const t=new gR(e);this.immutableX=new $T(t.immutableXConfig),this.depositsApi=this.immutableX.depositsApi,this.mintsApi=this.immutableX.mintsApi,this.ordersApi=this.immutableX.ordersApi,this.tokensApi=this.immutableX.tokensApi,this.tradesApi=this.immutableX.tradesApi,this.transfersApi=this.immutableX.transfersApi,this.exchangeApi=this.immutableX.exchangeApi,this.usersApi=this.immutableX.usersApi,this.withdrawalsApi=this.immutableX.withdrawalsApi,this.balanceApi=this.immutableX.balanceApi,this.assetApi=this.immutableX.assetApi,this.collectionApi=this.immutableX.collectionApi,this.metadataApi=this.immutableX.metadataApi,this.metadataRefreshesApi=this.immutableX.metadataRefreshesApi,this.nftCheckoutPrimaryApi=this.immutableX.nftCheckoutPrimaryApi,this.projectsApi=this.immutableX.projectsApi}getDeposit(e){return this.immutableX.getDeposit(e)}listDeposits(e){return this.immutableX.listDeposits(e)}getUser(e){return this.immutableX.getUser(e)}getAsset(e){return this.immutableX.getAsset(e)}listAssets(e){return this.immutableX.listAssets(e)}createCollection(e,t){return this.immutableX.createCollection(e,t)}getCollection(e){return this.immutableX.getCollection(e)}listCollectionFilters(e){return this.immutableX.listCollectionFilters(e)}listCollections(e){return this.collectionApi.listCollections(e).then((e=>e.data))}updateCollection(e,t,r){return this.immutableX.updateCollection(e,t,r)}addMetadataSchemaToCollection(e,t,r){return this.immutableX.addMetadataSchemaToCollection(e,t,r)}getMetadataSchema(e){return this.immutableX.getMetadataSchema(e)}updateMetadataSchemaByName(e,t,r,n){return this.immutableX.updateMetadataSchemaByName(e,t,r,n)}listMetadataRefreshes(e,t,r,n){return this.immutableX.listMetadataRefreshes(e,t,r,n)}getMetadataRefreshErrors(e,t,r,n){return this.immutableX.getMetadataRefreshErrors(e,t,r,n)}getMetadataRefreshResults(e,t){return this.immutableX.getMetadataRefreshResults(e,t)}createMetadataRefresh(e,t){return this.immutableX.createMetadataRefresh(e,t)}async createProject(e,t){return this.immutableX.createProject(e,t)}async getProject(e,t){return this.immutableX.getProject(e,t)}async getProjects(e,t,r,n,i){return this.immutableX.getProjects(e,t,r,n,i)}getBalance(e){return this.immutableX.getBalance(e)}listBalances(e){return this.immutableX.listBalances(e)}getMint(e){return this.immutableX.getMint(e)}listMints(e){return this.immutableX.listMints(e)}mint(e,t){return this.immutableX.mint(e,t)}listWithdrawals(e){return this.immutableX.listWithdrawals(e)}getWithdrawal(e){return this.immutableX.getWithdrawal(e)}getOrder(e){return this.immutableX.getOrder(e)}listOrders(e){return this.immutableX.listOrders(e)}getTrade(e){return this.immutableX.getTrade(e)}listTrades(e){return this.immutableX.listTrades(e)}getToken(e){return this.immutableX.getToken(e)}listTokens(e){return this.immutableX.listTokens(e)}getTransfer(e){return this.immutableX.getTransfer(e)}listTransfers(e){return this.immutableX.listTransfers(e)}createExchange(e){return this.immutableX.createExchange(e).then((e=>e.data))}getExchange(e){return this.immutableX.getExchange(e).then((e=>e.data))}getExchanges(e){return this.immutableX.getExchanges(e).then((e=>e.data))}exchangeTransfer(e,t){return this.immutableX.exchangeTransfer(e,t)}createNftPrimary(e){return this.immutableX.createNftPrimary(e).then((e=>e.data))}getCurrenciesNFTCheckoutPrimary(e){return this.immutableX.getCurrenciesNFTCheckoutPrimary(e).then((e=>e.data))}getNftPrimaryTransaction(e){return this.immutableX.getNftPrimaryTransaction(e).then((e=>e.data))}getNftPrimaryTransactions(e){return this.immutableX.getNftPrimaryTransactions(e).then((e=>e.data))}}function yR(e,t){return function(){return e.apply(t,arguments)}}const{toString:vR}=Object.prototype,{getPrototypeOf:wR}=Object,_R=(ER=Object.create(null),e=>{const t=vR.call(e);return ER[t]||(ER[t]=t.slice(8,-1).toLowerCase())});var ER;const AR=e=>(e=e.toLowerCase(),t=>_R(t)===e),SR=e=>t=>typeof t===e,{isArray:kR}=Array,xR=SR("undefined");const TR=AR("ArrayBuffer");const RR=SR("string"),OR=SR("function"),IR=SR("number"),MR=e=>null!==e&&"object"==typeof e,CR=e=>{if("object"!==_R(e))return!1;const t=wR(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||Symbol.toStringTag in e||Symbol.iterator in e)},PR=AR("Date"),NR=AR("File"),BR=AR("Blob"),UR=AR("FileList"),LR=AR("URLSearchParams");function jR(e,t,{allOwnKeys:r=!1}={}){if(null==e)return;let n,i;if("object"!=typeof e&&(e=[e]),kR(e))for(n=0,i=e.length;n<i;n++)t.call(null,e[n],n,e);else{const i=r?Object.getOwnPropertyNames(e):Object.keys(e),a=i.length;let s;for(n=0;n<a;n++)s=i[n],t.call(null,e[s],s,e)}}function DR(e,t){t=t.toLowerCase();const r=Object.keys(e);let n,i=r.length;for(;i-- >0;)if(n=r[i],t===n.toLowerCase())return n;return null}const FR="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,qR=e=>!xR(e)&&e!==FR;const zR=(KR="undefined"!=typeof Uint8Array&&wR(Uint8Array),e=>KR&&e instanceof KR);var KR;const HR=AR("HTMLFormElement"),GR=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),VR=AR("RegExp"),WR=(e,t)=>{const r=Object.getOwnPropertyDescriptors(e),n={};jR(r,((r,i)=>{!1!==t(r,i,e)&&(n[i]=r)})),Object.defineProperties(e,n)},XR="abcdefghijklmnopqrstuvwxyz",$R="0123456789",JR={DIGIT:$R,ALPHA:XR,ALPHA_DIGIT:XR+XR.toUpperCase()+$R};const YR=AR("AsyncFunction");var QR={isArray:kR,isArrayBuffer:TR,isBuffer:function(e){return null!==e&&!xR(e)&&null!==e.constructor&&!xR(e.constructor)&&OR(e.constructor.isBuffer)&&e.constructor.isBuffer(e)},isFormData:e=>{let t;return e&&("function"==typeof FormData&&e instanceof FormData||OR(e.append)&&("formdata"===(t=_R(e))||"object"===t&&OR(e.toString)&&"[object FormData]"===e.toString()))},isArrayBufferView:function(e){let t;return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&TR(e.buffer),t},isString:RR,isNumber:IR,isBoolean:e=>!0===e||!1===e,isObject:MR,isPlainObject:CR,isUndefined:xR,isDate:PR,isFile:NR,isBlob:BR,isRegExp:VR,isFunction:OR,isStream:e=>MR(e)&&OR(e.pipe),isURLSearchParams:LR,isTypedArray:zR,isFileList:UR,forEach:jR,merge:function e(){const{caseless:t}=qR(this)&&this||{},r={},n=(n,i)=>{const a=t&&DR(r,i)||i;CR(r[a])&&CR(n)?r[a]=e(r[a],n):CR(n)?r[a]=e({},n):kR(n)?r[a]=n.slice():r[a]=n};for(let e=0,t=arguments.length;e<t;e++)arguments[e]&&jR(arguments[e],n);return r},extend:(e,t,r,{allOwnKeys:n}={})=>(jR(t,((t,n)=>{r&&OR(t)?e[n]=yR(t,r):e[n]=t}),{allOwnKeys:n}),e),trim:e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),stripBOM:e=>(65279===e.charCodeAt(0)&&(e=e.slice(1)),e),inherits:(e,t,r,n)=>{e.prototype=Object.create(t.prototype,n),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},toFlatObject:(e,t,r,n)=>{let i,a,s;const o={};if(t=t||{},null==e)return t;do{for(i=Object.getOwnPropertyNames(e),a=i.length;a-- >0;)s=i[a],n&&!n(s,e,t)||o[s]||(t[s]=e[s],o[s]=!0);e=!1!==r&&wR(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},kindOf:_R,kindOfTest:AR,endsWith:(e,t,r)=>{e=String(e),(void 0===r||r>e.length)&&(r=e.length),r-=t.length;const n=e.indexOf(t,r);return-1!==n&&n===r},toArray:e=>{if(!e)return null;if(kR(e))return e;let t=e.length;if(!IR(t))return null;const r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},forEachEntry:(e,t)=>{const r=(e&&e[Symbol.iterator]).call(e);let n;for(;(n=r.next())&&!n.done;){const r=n.value;t.call(e,r[0],r[1])}},matchAll:(e,t)=>{let r;const n=[];for(;null!==(r=e.exec(t));)n.push(r);return n},isHTMLForm:HR,hasOwnProperty:GR,hasOwnProp:GR,reduceDescriptors:WR,freezeMethods:e=>{WR(e,((t,r)=>{if(OR(e)&&-1!==["arguments","caller","callee"].indexOf(r))return!1;const n=e[r];OR(n)&&(t.enumerable=!1,"writable"in t?t.writable=!1:t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")}))}))},toObjectSet:(e,t)=>{const r={},n=e=>{e.forEach((e=>{r[e]=!0}))};return kR(e)?n(e):n(String(e).split(t)),r},toCamelCase:e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,(function(e,t,r){return t.toUpperCase()+r})),noop:()=>{},toFiniteNumber:(e,t)=>(e=+e,Number.isFinite(e)?e:t),findKey:DR,global:FR,isContextDefined:qR,ALPHABET:JR,generateString:(e=16,t=JR.ALPHA_DIGIT)=>{let r="";const{length:n}=t;for(;e--;)r+=t[Math.random()*n|0];return r},isSpecCompliantForm:function(e){return!!(e&&OR(e.append)&&"FormData"===e[Symbol.toStringTag]&&e[Symbol.iterator])},toJSONObject:e=>{const t=new Array(10),r=(e,n)=>{if(MR(e)){if(t.indexOf(e)>=0)return;if(!("toJSON"in e)){t[n]=e;const i=kR(e)?[]:{};return jR(e,((e,t)=>{const a=r(e,n+1);!xR(a)&&(i[t]=a)})),t[n]=void 0,i}}return e};return r(e,0)},isAsyncFn:YR,isThenable:e=>e&&(MR(e)||OR(e))&&OR(e.then)&&OR(e.catch)};function ZR(e,t,r,n,i){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack,this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),n&&(this.request=n),i&&(this.response=i)}QR.inherits(ZR,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:QR.toJSONObject(this.config),code:this.code,status:this.response&&this.response.status?this.response.status:null}}});const eO=ZR.prototype,tO={};["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((e=>{tO[e]={value:e}})),Object.defineProperties(ZR,tO),Object.defineProperty(eO,"isAxiosError",{value:!0}),ZR.from=(e,t,r,n,i,a)=>{const s=Object.create(eO);return QR.toFlatObject(e,s,(function(e){return e!==Error.prototype}),(e=>"isAxiosError"!==e)),ZR.call(s,e.message,t,r,n,i),s.cause=e,s.name=e.name,a&&Object.assign(s,a),s};function rO(e){return QR.isPlainObject(e)||QR.isArray(e)}function nO(e){return QR.endsWith(e,"[]")?e.slice(0,-2):e}function iO(e,t,r){return e?e.concat(t).map((function(e,t){return e=nO(e),!r&&t?"["+e+"]":e})).join(r?".":""):t}const aO=QR.toFlatObject(QR,{},null,(function(e){return/^is[A-Z]/.test(e)}));function sO(e,t,r){if(!QR.isObject(e))throw new TypeError("target must be an object");t=t||new FormData;const n=(r=QR.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,(function(e,t){return!QR.isUndefined(t[e])}))).metaTokens,i=r.visitor||f,a=r.dots,s=r.indexes,o=(r.Blob||"undefined"!=typeof Blob&&Blob)&&QR.isSpecCompliantForm(t);if(!QR.isFunction(i))throw new TypeError("visitor must be a function");function c(e){if(null===e)return"";if(QR.isDate(e))return e.toISOString();if(!o&&QR.isBlob(e))throw new ZR("Blob is not supported. Use a Buffer instead.");return QR.isArrayBuffer(e)||QR.isTypedArray(e)?o&&"function"==typeof Blob?new Blob([e]):Buffer.from(e):e}function f(e,r,i){let o=e;if(e&&!i&&"object"==typeof e)if(QR.endsWith(r,"{}"))r=n?r:r.slice(0,-2),e=JSON.stringify(e);else if(QR.isArray(e)&&function(e){return QR.isArray(e)&&!e.some(rO)}(e)||(QR.isFileList(e)||QR.endsWith(r,"[]"))&&(o=QR.toArray(e)))return r=nO(r),o.forEach((function(e,n){!QR.isUndefined(e)&&null!==e&&t.append(!0===s?iO([r],n,a):null===s?r:r+"[]",c(e))})),!1;return!!rO(e)||(t.append(iO(i,r,a),c(e)),!1)}const u=[],d=Object.assign(aO,{defaultVisitor:f,convertValue:c,isVisitable:rO});if(!QR.isObject(e))throw new TypeError("data must be an object");return function e(r,n){if(!QR.isUndefined(r)){if(-1!==u.indexOf(r))throw Error("Circular reference detected in "+n.join("."));u.push(r),QR.forEach(r,(function(r,a){!0===(!(QR.isUndefined(r)||null===r)&&i.call(t,r,QR.isString(a)?a.trim():a,n,d))&&e(r,n?n.concat(a):[a])})),u.pop()}}(e),t}function oO(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,(function(e){return t[e]}))}function cO(e,t){this._pairs=[],e&&sO(e,this,t)}const fO=cO.prototype;function uO(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function dO(e,t,r){if(!t)return e;const n=r&&r.encode||uO,i=r&&r.serialize;let a;if(a=i?i(t,r):QR.isURLSearchParams(t)?t.toString():new cO(t,r).toString(n),a){const t=e.indexOf("#");-1!==t&&(e=e.slice(0,t)),e+=(-1===e.indexOf("?")?"?":"&")+a}return e}fO.append=function(e,t){this._pairs.push([e,t])},fO.toString=function(e){const t=e?function(t){return e.call(this,t,oO)}:oO;return this._pairs.map((function(e){return t(e[0])+"="+t(e[1])}),"").join("&")};var lO=class{constructor(){this.handlers=[]}use(e,t,r){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!r&&r.synchronous,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){QR.forEach(this.handlers,(function(t){null!==t&&e(t)}))}},hO={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var pO={isBrowser:!0,classes:{URLSearchParams:"undefined"!=typeof URLSearchParams?URLSearchParams:cO,FormData:"undefined"!=typeof FormData?FormData:null,Blob:"undefined"!=typeof Blob?Blob:null},isStandardBrowserEnv:(()=>{let e;return("undefined"==typeof navigator||"ReactNative"!==(e=navigator.product)&&"NativeScript"!==e&&"NS"!==e)&&("undefined"!=typeof window&&"undefined"!=typeof document)})(),isStandardBrowserWebWorkerEnv:"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,protocols:["http","https","file","blob","url","data"]};function bO(e){function t(e,r,n,i){let a=e[i++];const s=Number.isFinite(+a),o=i>=e.length;if(a=!a&&QR.isArray(n)?n.length:a,o)return QR.hasOwnProp(n,a)?n[a]=[n[a],r]:n[a]=r,!s;n[a]&&QR.isObject(n[a])||(n[a]=[]);return t(e,r,n[a],i)&&QR.isArray(n[a])&&(n[a]=function(e){const t={},r=Object.keys(e);let n;const i=r.length;let a;for(n=0;n<i;n++)a=r[n],t[a]=e[a];return t}(n[a])),!s}if(QR.isFormData(e)&&QR.isFunction(e.entries)){const r={};return QR.forEachEntry(e,((e,n)=>{t(function(e){return QR.matchAll(/\w+|\[(\w*)]/g,e).map((e=>"[]"===e[0]?"":e[1]||e[0]))}(e),n,r,0)})),r}return null}const gO={"Content-Type":void 0};const mO={transitional:hO,adapter:["xhr","http"],transformRequest:[function(e,t){const r=t.getContentType()||"",n=r.indexOf("application/json")>-1,i=QR.isObject(e);i&&QR.isHTMLForm(e)&&(e=new FormData(e));if(QR.isFormData(e))return n&&n?JSON.stringify(bO(e)):e;if(QR.isArrayBuffer(e)||QR.isBuffer(e)||QR.isStream(e)||QR.isFile(e)||QR.isBlob(e))return e;if(QR.isArrayBufferView(e))return e.buffer;if(QR.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let a;if(i){if(r.indexOf("application/x-www-form-urlencoded")>-1)return function(e,t){return sO(e,new pO.classes.URLSearchParams,Object.assign({visitor:function(e,t,r,n){return pO.isNode&&QR.isBuffer(e)?(this.append(t,e.toString("base64")),!1):n.defaultVisitor.apply(this,arguments)}},t))}(e,this.formSerializer).toString();if((a=QR.isFileList(e))||r.indexOf("multipart/form-data")>-1){const t=this.env&&this.env.FormData;return sO(a?{"files[]":e}:e,t&&new t,this.formSerializer)}}return i||n?(t.setContentType("application/json",!1),function(e,t,r){if(QR.isString(e))try{return(t||JSON.parse)(e),QR.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(r||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){const t=this.transitional||mO.transitional,r=t&&t.forcedJSONParsing,n="json"===this.responseType;if(e&&QR.isString(e)&&(r&&!this.responseType||n)){const r=!(t&&t.silentJSONParsing)&&n;try{return JSON.parse(e)}catch(e){if(r){if("SyntaxError"===e.name)throw ZR.from(e,ZR.ERR_BAD_RESPONSE,this,null,this.response);throw e}}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:pO.classes.FormData,Blob:pO.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};QR.forEach(["delete","get","head"],(function(e){mO.headers[e]={}})),QR.forEach(["post","put","patch"],(function(e){mO.headers[e]=QR.merge(gO)}));var yO=mO;const vO=QR.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"]);const wO=Symbol("internals");function _O(e){return e&&String(e).trim().toLowerCase()}function EO(e){return!1===e||null==e?e:QR.isArray(e)?e.map(EO):String(e)}function AO(e,t,r,n,i){return QR.isFunction(n)?n.call(this,t,r):(i&&(t=r),QR.isString(t)?QR.isString(n)?-1!==t.indexOf(n):QR.isRegExp(n)?n.test(t):void 0:void 0)}let SO=class{constructor(e){e&&this.set(e)}set(e,t,r){const n=this;function i(e,t,r){const i=_O(t);if(!i)throw new Error("header name must be a non-empty string");const a=QR.findKey(n,i);(!a||void 0===n[a]||!0===r||void 0===r&&!1!==n[a])&&(n[a||t]=EO(e))}const a=(e,t)=>QR.forEach(e,((e,r)=>i(e,r,t)));return QR.isPlainObject(e)||e instanceof this.constructor?a(e,t):QR.isString(e)&&(e=e.trim())&&!/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim())?a((e=>{const t={};let r,n,i;return e&&e.split("\n").forEach((function(e){i=e.indexOf(":"),r=e.substring(0,i).trim().toLowerCase(),n=e.substring(i+1).trim(),!r||t[r]&&vO[r]||("set-cookie"===r?t[r]?t[r].push(n):t[r]=[n]:t[r]=t[r]?t[r]+", "+n:n)})),t})(e),t):null!=e&&i(t,e,r),this}get(e,t){if(e=_O(e)){const r=QR.findKey(this,e);if(r){const e=this[r];if(!t)return e;if(!0===t)return function(e){const t=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let n;for(;n=r.exec(e);)t[n[1]]=n[2];return t}(e);if(QR.isFunction(t))return t.call(this,e,r);if(QR.isRegExp(t))return t.exec(e);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=_O(e)){const r=QR.findKey(this,e);return!(!r||void 0===this[r]||t&&!AO(0,this[r],r,t))}return!1}delete(e,t){const r=this;let n=!1;function i(e){if(e=_O(e)){const i=QR.findKey(r,e);!i||t&&!AO(0,r[i],i,t)||(delete r[i],n=!0)}}return QR.isArray(e)?e.forEach(i):i(e),n}clear(e){const t=Object.keys(this);let r=t.length,n=!1;for(;r--;){const i=t[r];e&&!AO(0,this[i],i,e,!0)||(delete this[i],n=!0)}return n}normalize(e){const t=this,r={};return QR.forEach(this,((n,i)=>{const a=QR.findKey(r,i);if(a)return t[a]=EO(n),void delete t[i];const s=e?function(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,((e,t,r)=>t.toUpperCase()+r))}(i):String(i).trim();s!==i&&delete t[i],t[s]=EO(n),r[s]=!0})),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return QR.forEach(this,((r,n)=>{null!=r&&!1!==r&&(t[n]=e&&QR.isArray(r)?r.join(", "):r)})),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map((([e,t])=>e+": "+t)).join("\n")}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const r=new this(e);return t.forEach((e=>r.set(e))),r}static accessor(e){const t=(this[wO]=this[wO]={accessors:{}}).accessors,r=this.prototype;function n(e){const n=_O(e);t[n]||(!function(e,t){const r=QR.toCamelCase(" "+t);["get","set","has"].forEach((n=>{Object.defineProperty(e,n+r,{value:function(e,r,i){return this[n].call(this,t,e,r,i)},configurable:!0})}))}(r,e),t[n]=!0)}return QR.isArray(e)?e.forEach(n):n(e),this}};SO.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),QR.freezeMethods(SO.prototype),QR.freezeMethods(SO);var kO=SO;function xO(e,t){const r=this||yO,n=t||r,i=kO.from(n.headers);let a=n.data;return QR.forEach(e,(function(e){a=e.call(r,a,i.normalize(),t?t.status:void 0)})),i.normalize(),a}function TO(e){return!(!e||!e.__CANCEL__)}function RO(e,t,r){ZR.call(this,null==e?"canceled":e,ZR.ERR_CANCELED,t,r),this.name="CanceledError"}QR.inherits(RO,ZR,{__CANCEL__:!0});var OO=pO.isStandardBrowserEnv?{write:function(e,t,r,n,i,a){const s=[];s.push(e+"="+encodeURIComponent(t)),QR.isNumber(r)&&s.push("expires="+new Date(r).toGMTString()),QR.isString(n)&&s.push("path="+n),QR.isString(i)&&s.push("domain="+i),!0===a&&s.push("secure"),document.cookie=s.join("; ")},read:function(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}};function IO(e,t){return e&&!/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)?function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}(e,t):t}var MO=pO.isStandardBrowserEnv?function(){const e=/(msie|trident)/i.test(navigator.userAgent),t=document.createElement("a");let r;function n(r){let n=r;return e&&(t.setAttribute("href",n),n=t.href),t.setAttribute("href",n),{href:t.href,protocol:t.protocol?t.protocol.replace(/:$/,""):"",host:t.host,search:t.search?t.search.replace(/^\?/,""):"",hash:t.hash?t.hash.replace(/^#/,""):"",hostname:t.hostname,port:t.port,pathname:"/"===t.pathname.charAt(0)?t.pathname:"/"+t.pathname}}return r=n(window.location.href),function(e){const t=QR.isString(e)?n(e):e;return t.protocol===r.protocol&&t.host===r.host}}():function(){return!0};function CO(e,t){let r=0;const n=function(e,t){e=e||10;const r=new Array(e),n=new Array(e);let i,a=0,s=0;return t=void 0!==t?t:1e3,function(o){const c=Date.now(),f=n[s];i||(i=c),r[a]=o,n[a]=c;let u=s,d=0;for(;u!==a;)d+=r[u++],u%=e;if(a=(a+1)%e,a===s&&(s=(s+1)%e),c-i<t)return;const l=f&&c-f;return l?Math.round(1e3*d/l):void 0}}(50,250);return i=>{const a=i.loaded,s=i.lengthComputable?i.total:void 0,o=a-r,c=n(o);r=a;const f={loaded:a,total:s,progress:s?a/s:void 0,bytes:o,rate:c||void 0,estimated:c&&s&&a<=s?(s-a)/c:void 0,event:i};f[t?"download":"upload"]=!0,e(f)}}var PO="undefined"!=typeof XMLHttpRequest&&function(e){return new Promise((function(t,r){let n=e.data;const i=kO.from(e.headers).normalize(),a=e.responseType;let s;function o(){e.cancelToken&&e.cancelToken.unsubscribe(s),e.signal&&e.signal.removeEventListener("abort",s)}QR.isFormData(n)&&(pO.isStandardBrowserEnv||pO.isStandardBrowserWebWorkerEnv?i.setContentType(!1):i.setContentType("multipart/form-data;",!1));let c=new XMLHttpRequest;if(e.auth){const t=e.auth.username||"",r=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";i.set("Authorization","Basic "+btoa(t+":"+r))}const f=IO(e.baseURL,e.url);function u(){if(!c)return;const n=kO.from("getAllResponseHeaders"in c&&c.getAllResponseHeaders());!function(e,t,r){const n=r.config.validateStatus;r.status&&n&&!n(r.status)?t(new ZR("Request failed with status code "+r.status,[ZR.ERR_BAD_REQUEST,ZR.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r)):e(r)}((function(e){t(e),o()}),(function(e){r(e),o()}),{data:a&&"text"!==a&&"json"!==a?c.response:c.responseText,status:c.status,statusText:c.statusText,headers:n,config:e,request:c}),c=null}if(c.open(e.method.toUpperCase(),dO(f,e.params,e.paramsSerializer),!0),c.timeout=e.timeout,"onloadend"in c?c.onloadend=u:c.onreadystatechange=function(){c&&4===c.readyState&&(0!==c.status||c.responseURL&&0===c.responseURL.indexOf("file:"))&&setTimeout(u)},c.onabort=function(){c&&(r(new ZR("Request aborted",ZR.ECONNABORTED,e,c)),c=null)},c.onerror=function(){r(new ZR("Network Error",ZR.ERR_NETWORK,e,c)),c=null},c.ontimeout=function(){let t=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded";const n=e.transitional||hO;e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),r(new ZR(t,n.clarifyTimeoutError?ZR.ETIMEDOUT:ZR.ECONNABORTED,e,c)),c=null},pO.isStandardBrowserEnv){const t=(e.withCredentials||MO(f))&&e.xsrfCookieName&&OO.read(e.xsrfCookieName);t&&i.set(e.xsrfHeaderName,t)}void 0===n&&i.setContentType(null),"setRequestHeader"in c&&QR.forEach(i.toJSON(),(function(e,t){c.setRequestHeader(t,e)})),QR.isUndefined(e.withCredentials)||(c.withCredentials=!!e.withCredentials),a&&"json"!==a&&(c.responseType=e.responseType),"function"==typeof e.onDownloadProgress&&c.addEventListener("progress",CO(e.onDownloadProgress,!0)),"function"==typeof e.onUploadProgress&&c.upload&&c.upload.addEventListener("progress",CO(e.onUploadProgress)),(e.cancelToken||e.signal)&&(s=t=>{c&&(r(!t||t.type?new RO(null,e,c):t),c.abort(),c=null)},e.cancelToken&&e.cancelToken.subscribe(s),e.signal&&(e.signal.aborted?s():e.signal.addEventListener("abort",s)));const d=function(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}(f);d&&-1===pO.protocols.indexOf(d)?r(new ZR("Unsupported protocol "+d+":",ZR.ERR_BAD_REQUEST,e)):c.send(n||null)}))};const NO={http:null,xhr:PO};QR.forEach(NO,((e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch(e){}Object.defineProperty(e,"adapterName",{value:t})}}));var BO=e=>{e=QR.isArray(e)?e:[e];const{length:t}=e;let r,n;for(let i=0;i<t&&(r=e[i],!(n=QR.isString(r)?NO[r.toLowerCase()]:r));i++);if(!n){if(!1===n)throw new ZR(`Adapter ${r} is not supported by the environment`,"ERR_NOT_SUPPORT");throw new Error(QR.hasOwnProp(NO,r)?`Adapter '${r}' is not available in the build`:`Unknown adapter '${r}'`)}if(!QR.isFunction(n))throw new TypeError("adapter is not a function");return n};function UO(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new RO(null,e)}function LO(e){UO(e),e.headers=kO.from(e.headers),e.data=xO.call(e,e.transformRequest),-1!==["post","put","patch"].indexOf(e.method)&&e.headers.setContentType("application/x-www-form-urlencoded",!1);return BO(e.adapter||yO.adapter)(e).then((function(t){return UO(e),t.data=xO.call(e,e.transformResponse,t),t.headers=kO.from(t.headers),t}),(function(t){return TO(t)||(UO(e),t&&t.response&&(t.response.data=xO.call(e,e.transformResponse,t.response),t.response.headers=kO.from(t.response.headers))),Promise.reject(t)}))}const jO=e=>e instanceof kO?e.toJSON():e;function DO(e,t){t=t||{};const r={};function n(e,t,r){return QR.isPlainObject(e)&&QR.isPlainObject(t)?QR.merge.call({caseless:r},e,t):QR.isPlainObject(t)?QR.merge({},t):QR.isArray(t)?t.slice():t}function i(e,t,r){return QR.isUndefined(t)?QR.isUndefined(e)?void 0:n(void 0,e,r):n(e,t,r)}function a(e,t){if(!QR.isUndefined(t))return n(void 0,t)}function s(e,t){return QR.isUndefined(t)?QR.isUndefined(e)?void 0:n(void 0,e):n(void 0,t)}function o(r,i,a){return a in t?n(r,i):a in e?n(void 0,r):void 0}const c={url:a,method:a,data:a,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials: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:o,headers:(e,t)=>i(jO(e),jO(t),!0)};return QR.forEach(Object.keys(Object.assign({},e,t)),(function(n){const a=c[n]||i,s=a(e[n],t[n],n);QR.isUndefined(s)&&a!==o||(r[n]=s)})),r}const FO="1.4.0",qO={};["object","boolean","number","function","string","symbol"].forEach(((e,t)=>{qO[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}}));const zO={};qO.transitional=function(e,t,r){function n(e,t){return"[Axios v1.4.0] Transitional option '"+e+"'"+t+(r?". "+r:"")}return(r,i,a)=>{if(!1===e)throw new ZR(n(i," has been removed"+(t?" in "+t:"")),ZR.ERR_DEPRECATED);return t&&!zO[i]&&(zO[i]=!0,console.warn(n(i," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(r,i,a)}};var KO={assertOptions:function(e,t,r){if("object"!=typeof e)throw new ZR("options must be an object",ZR.ERR_BAD_OPTION_VALUE);const n=Object.keys(e);let i=n.length;for(;i-- >0;){const a=n[i],s=t[a];if(s){const t=e[a],r=void 0===t||s(t,a,e);if(!0!==r)throw new ZR("option "+a+" must be "+r,ZR.ERR_BAD_OPTION_VALUE)}else if(!0!==r)throw new ZR("Unknown option "+a,ZR.ERR_BAD_OPTION)}},validators:qO};const HO=KO.validators;let GO=class{constructor(e){this.defaults=e,this.interceptors={request:new lO,response:new lO}}request(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{},t=DO(this.defaults,t);const{transitional:r,paramsSerializer:n,headers:i}=t;let a;void 0!==r&&KO.assertOptions(r,{silentJSONParsing:HO.transitional(HO.boolean),forcedJSONParsing:HO.transitional(HO.boolean),clarifyTimeoutError:HO.transitional(HO.boolean)},!1),null!=n&&(QR.isFunction(n)?t.paramsSerializer={serialize:n}:KO.assertOptions(n,{encode:HO.function,serialize:HO.function},!0)),t.method=(t.method||this.defaults.method||"get").toLowerCase(),a=i&&QR.merge(i.common,i[t.method]),a&&QR.forEach(["delete","get","head","post","put","patch","common"],(e=>{delete i[e]})),t.headers=kO.concat(a,i);const s=[];let o=!0;this.interceptors.request.forEach((function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(o=o&&e.synchronous,s.unshift(e.fulfilled,e.rejected))}));const c=[];let f;this.interceptors.response.forEach((function(e){c.push(e.fulfilled,e.rejected)}));let u,d=0;if(!o){const e=[LO.bind(this),void 0];for(e.unshift.apply(e,s),e.push.apply(e,c),u=e.length,f=Promise.resolve(t);d<u;)f=f.then(e[d++],e[d++]);return f}u=s.length;let l=t;for(d=0;d<u;){const e=s[d++],t=s[d++];try{l=e(l)}catch(e){t.call(this,e);break}}try{f=LO.call(this,l)}catch(e){return Promise.reject(e)}for(d=0,u=c.length;d<u;)f=f.then(c[d++],c[d++]);return f}getUri(e){return dO(IO((e=DO(this.defaults,e)).baseURL,e.url),e.params,e.paramsSerializer)}};QR.forEach(["delete","get","head","options"],(function(e){GO.prototype[e]=function(t,r){return this.request(DO(r||{},{method:e,url:t,data:(r||{}).data}))}})),QR.forEach(["post","put","patch"],(function(e){function t(t){return function(r,n,i){return this.request(DO(i||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:r,data:n}))}}GO.prototype[e]=t(),GO.prototype[e+"Form"]=t(!0)}));var VO=GO;var WO=class e{constructor(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");let t;this.promise=new Promise((function(e){t=e}));const r=this;this.promise.then((e=>{if(!r._listeners)return;let t=r._listeners.length;for(;t-- >0;)r._listeners[t](e);r._listeners=null})),this.promise.then=e=>{let t;const n=new Promise((e=>{r.subscribe(e),t=e})).then(e);return n.cancel=function(){r.unsubscribe(t)},n},e((function(e,n,i){r.reason||(r.reason=new RO(e,n,i),t(r.reason))}))}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}static source(){let t;const r=new e((function(e){t=e}));return{token:r,cancel:t}}};const XO={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(XO).forEach((([e,t])=>{XO[t]=e}));var $O=XO;const JO=function e(t){const r=new VO(t),n=yR(VO.prototype.request,r);return QR.extend(n,VO.prototype,r,{allOwnKeys:!0}),QR.extend(n,r,null,{allOwnKeys:!0}),n.create=function(r){return e(DO(t,r))},n}(yO);JO.Axios=VO,JO.CanceledError=RO,JO.CancelToken=WO,JO.isCancel=TO,JO.VERSION=FO,JO.toFormData=sO,JO.AxiosError=ZR,JO.Cancel=JO.CanceledError,JO.all=function(e){return Promise.all(e)},JO.spread=function(e){return function(t){return e.apply(null,t)}},JO.isAxiosError=function(e){return QR.isObject(e)&&!0===e.isAxiosError},JO.mergeConfig=DO,JO.AxiosHeaders=kO,JO.formToJSON=e=>bO(QR.isHTMLForm(e)?new FormData(e):e),JO.HttpStatusCode=$O,JO.default=JO;var YO=JO;const QO="https://api.sandbox.immutable.com".replace(/\/+$/,"");let ZO=class{basePath;axios;configuration;constructor(e,t=QO,r=YO){this.basePath=t,this.axios=r,e&&(this.configuration=e,this.basePath=e.basePath||this.basePath)}},eI=class extends Error{field;name="RequiredError";constructor(e,t){super(t),this.field=e}};const tI="https://example.com",rI=function(e,t,r){if(null==r)throw new eI(t,`Required parameter ${t} was null or undefined when calling ${e}.`)};function nI(e,t,r=""){"object"==typeof t?Array.isArray(t)?t.forEach((t=>nI(e,t,r))):Object.keys(t).forEach((n=>nI(e,t[n],`${r}${""!==r?".":""}${n}`))):e.has(r)?e.append(r,t):e.set(r,t)}const iI=function(e,...t){const r=new URLSearchParams(e.search);nI(r,t),e.search=r.toString()},aI=function(e,t,r){const n="string"!=typeof e;return(n&&r&&r.isJsonMime?r.isJsonMime(t.headers["Content-Type"]):n)?JSON.stringify(void 0!==e?e:{}):e||""},sI=function(e){return e.pathname+e.search+e.hash},oI=function(e,t,r,n){return(i=t,a=r)=>{const s={...e.options,url:(n?.basePath||a)+e.url};return i.request(s)}},cI=function(e){const t=function(e){return{getActivity:async(t,r,n={})=>{rI("getActivity","chainName",t),rI("getActivity","activityId",r);const i="/v1/chains/{chain_name}/activities/{activity_id}".replace("{chain_name}",encodeURIComponent(String(t))).replace("{activity_id}",encodeURIComponent(String(r))),a=new URL(i,tI);let s;e&&(s=e.baseOptions);const o={method:"GET",...s,...n};iI(a,{});let c=s&&s.headers?s.headers:{};return o.headers={...c,...n.headers},{url:sI(a),options:o}},listActivities:async(t,r,n,i,a,s,o,c,f,u,d={})=>{rI("listActivities","chainName",t);const l="/v1/chains/{chain_name}/activities".replace("{chain_name}",encodeURIComponent(String(t))),h=new URL(l,tI);let p;e&&(p=e.baseOptions);const b={method:"GET",...p,...d},g={};void 0!==r&&(g.contract_address=r),void 0!==n&&(g.token_id=n),void 0!==i&&(g.account_address=i),void 0!==a&&(g.activity_type=a),void 0!==s&&(g.from_indexed_at=s instanceof Date?s.toISOString():s),void 0!==o&&(g.to_indexed_at=o instanceof Date?o.toISOString():o),void 0!==c&&(g.transaction_hash=c),void 0!==f&&(g.page_cursor=f),void 0!==u&&(g.page_size=u),iI(h,g);let m=p&&p.headers?p.headers:{};return b.headers={...m,...d.headers},{url:sI(h),options:b}}}}(e);return{async getActivity(r,n,i){const a=await t.getActivity(r,n,i);return oI(a,YO,QO,e)},async listActivities(r,n,i,a,s,o,c,f,u,d,l){const h=await t.listActivities(r,n,i,a,s,o,c,f,u,d,l);return oI(h,YO,QO,e)}}};class fI extends ZO{getActivity(e,t){return cI(this.configuration).getActivity(e.chainName,e.activityId,t).then((e=>e(this.axios,this.basePath)))}listActivities(e,t){return cI(this.configuration).listActivities(e.chainName,e.contractAddress,e.tokenId,e.accountAddress,e.activityType,e.fromIndexedAt,e.toIndexedAt,e.transactionHash,e.pageCursor,e.pageSize,t).then((e=>e(this.axios,this.basePath)))}}const uI=function(e){const t=function(e){return{listChains:async(t,r,n={})=>{const i=new URL("/v1/chains",tI);let a;e&&(a=e.baseOptions);const s={method:"GET",...a,...n},o={};void 0!==t&&(o.page_cursor=t),void 0!==r&&(o.page_size=r),iI(i,o);let c=a&&a.headers?a.headers:{};return s.headers={...c,...n.headers},{url:sI(i),options:s}}}}(e);return{async listChains(r,n,i){const a=await t.listChains(r,n,i);return oI(a,YO,QO,e)}}};class dI extends ZO{listChains(e={},t){return uI(this.configuration).listChains(e.pageCursor,e.pageSize,t).then((e=>e(this.axios,this.basePath)))}}const lI=function(e){const t=function(e){return{getCollection:async(t,r,n={})=>{rI("getCollection","contractAddress",t),rI("getCollection","chainName",r);const i="/v1/chains/{chain_name}/collections/{contract_address}".replace("{contract_address}",encodeURIComponent(String(t))).replace("{chain_name}",encodeURIComponent(String(r))),a=new URL(i,tI);let s;e&&(s=e.baseOptions);const o={method:"GET",...s,...n};iI(a,{});let c=s&&s.headers?s.headers:{};return o.headers={...c,...n.headers},{url:sI(a),options:o}},listCollections:async(t,r,n,i={})=>{rI("listCollections","chainName",t);const a="/v1/chains/{chain_name}/collections".replace("{chain_name}",encodeURIComponent(String(t))),s=new URL(a,tI);let o;e&&(o=e.baseOptions);const c={method:"GET",...o,...i},f={};void 0!==r&&(f.page_cursor=r),void 0!==n&&(f.page_size=n),iI(s,f);let u=o&&o.headers?o.headers:{};return c.headers={...u,...i.headers},{url:sI(s),options:c}}}}(e);return{async getCollection(r,n,i){const a=await t.getCollection(r,n,i);return oI(a,YO,QO,e)},async listCollections(r,n,i,a){const s=await t.listCollections(r,n,i,a);return oI(s,YO,QO,e)}}};class hI extends ZO{getCollection(e,t){return lI(this.configuration).getCollection(e.contractAddress,e.chainName,t).then((e=>e(this.axios,this.basePath)))}listCollections(e,t){return lI(this.configuration).listCollections(e.chainName,e.pageCursor,e.pageSize,t).then((e=>e(this.axios,this.basePath)))}}const pI=function(e){const t=function(e){return{listNFTOwners:async(t,r,n,i,a,s={})=>{rI("listNFTOwners","contractAddress",t),rI("listNFTOwners","tokenId",r),rI("listNFTOwners","chainName",n);const o="/v1/chains/{chain_name}/collections/{contract_address}/nfts/{token_id}/owners".replace("{contract_address}",encodeURIComponent(String(t))).replace("{token_id}",encodeURIComponent(String(r))).replace("{chain_name}",encodeURIComponent(String(n))),c=new URL(o,tI);let f;e&&(f=e.baseOptions);const u={method:"GET",...f,...s},d={};void 0!==i&&(d.page_cursor=i),void 0!==a&&(d.page_size=a),iI(c,d);let l=f&&f.headers?f.headers:{};return u.headers={...l,...s.headers},{url:sI(c),options:u}}}}(e);return{async listNFTOwners(r,n,i,a,s,o){const c=await t.listNFTOwners(r,n,i,a,s,o);return oI(c,YO,QO,e)}}};class bI extends ZO{listNFTOwners(e,t){return pI(this.configuration).listNFTOwners(e.contractAddress,e.tokenId,e.chainName,e.pageCursor,e.pageSize,t).then((e=>e(this.axios,this.basePath)))}}const gI=function(e){const t=function(e){return{getNFT:async(t,r,n,i={})=>{rI("getNFT","contractAddress",t),rI("getNFT","tokenId",r),rI("getNFT","chainName",n);const a="/v1/chains/{chain_name}/collections/{contract_address}/nfts/{token_id}".replace("{contract_address}",encodeURIComponent(String(t))).replace("{token_id}",encodeURIComponent(String(r))).replace("{chain_name}",encodeURIComponent(String(n))),s=new URL(a,tI);let o;e&&(o=e.baseOptions);const c={method:"GET",...o,...i};iI(s,{});let f=o&&o.headers?o.headers:{};return c.headers={...f,...i.headers},{url:sI(s),options:c}},listNFTs:async(t,r,n,i,a={})=>{rI("listNFTs","contractAddress",t),rI("listNFTs","chainName",r);const s="/v1/chains/{chain_name}/collections/{contract_address}/nfts".replace("{contract_address}",encodeURIComponent(String(t))).replace("{chain_name}",encodeURIComponent(String(r))),o=new URL(s,tI);let c;e&&(c=e.baseOptions);const f={method:"GET",...c,...a},u={};void 0!==n&&(u.page_cursor=n),void 0!==i&&(u.page_size=i),iI(o,u);let d=c&&c.headers?c.headers:{};return f.headers={...d,...a.headers},{url:sI(o),options:f}},listNFTsByAccountAddress:async(t,r,n,i,a,s={})=>{rI("listNFTsByAccountAddress","accountAddress",t),rI("listNFTsByAccountAddress","chainName",r);const o="/v1/chains/{chain_name}/accounts/{account_address}/nfts".replace("{account_address}",encodeURIComponent(String(t))).replace("{chain_name}",encodeURIComponent(String(r))),c=new URL(o,tI);let f;e&&(f=e.baseOptions);const u={method:"GET",...f,...s},d={};void 0!==n&&(d.contract_address=n),void 0!==i&&(d.page_cursor=i),void 0!==a&&(d.page_size=a),iI(c,d);let l=f&&f.headers?f.headers:{};return u.headers={...l,...s.headers},{url:sI(c),options:u}}}}(e);return{async getNFT(r,n,i,a){const s=await t.getNFT(r,n,i,a);return oI(s,YO,QO,e)},async listNFTs(r,n,i,a,s){const o=await t.listNFTs(r,n,i,a,s);return oI(o,YO,QO,e)},async listNFTsByAccountAddress(r,n,i,a,s,o){const c=await t.listNFTsByAccountAddress(r,n,i,a,s,o);return oI(c,YO,QO,e)}}};class mI extends ZO{getNFT(e,t){return gI(this.configuration).getNFT(e.contractAddress,e.tokenId,e.chainName,t).then((e=>e(this.axios,this.basePath)))}listNFTs(e,t){return gI(this.configuration).listNFTs(e.contractAddress,e.chainName,e.pageCursor,e.pageSize,t).then((e=>e(this.axios,this.basePath)))}listNFTsByAccountAddress(e,t){return gI(this.configuration).listNFTsByAccountAddress(e.accountAddress,e.chainName,e.contractAddress,e.pageCursor,e.pageSize,t).then((e=>e(this.axios,this.basePath)))}}const yI=function(e){const t=function(e){return{createListing:async(t,r,n={})=>{rI("createListing","chainName",t),rI("createListing","createListingRequestBody",r);const i="/v1/chains/{chain_name}/orders/listings".replace("{chain_name}",encodeURIComponent(String(t))),a=new URL(i,tI);let s;e&&(s=e.baseOptions);const o={method:"POST",...s,...n},c={"Content-Type":"application/json"};iI(a,{});let f=s&&s.headers?s.headers:{};return o.headers={...c,...f,...n.headers},o.data=aI(r,o,e),{url:sI(a),options:o}},fulfillmentData:async(t,r,n={})=>{rI("fulfillmentData","chainName",t),rI("fulfillmentData","fulfillmentDataRequestInner",r);const i="/v1/chains/{chain_name}/orders/fulfillment_data".replace("{chain_name}",encodeURIComponent(String(t))),a=new URL(i,tI);let s;e&&(s=e.baseOptions);const o={method:"POST",...s,...n},c={"Content-Type":"application/json"};iI(a,{});let f=s&&s.headers?s.headers:{};return o.headers={...c,...f,...n.headers},o.data=aI(r,o,e),{url:sI(a),options:o}},getListing:async(t,r,n={})=>{rI("getListing","chainName",t),rI("getListing","listingId",r);const i="/v1/chains/{chain_name}/orders/listings/{listing_id}".replace("{chain_name}",encodeURIComponent(String(t))).replace("{listing_id}",encodeURIComponent(String(r))),a=new URL(i,tI);let s;e&&(s=e.baseOptions);const o={method:"GET",...s,...n};iI(a,{});let c=s&&s.headers?s.headers:{};return o.headers={...c,...n.headers},{url:sI(a),options:o}},listListings:async(t,r,n,i,a,s,o,c,f,u={})=>{rI("listListings","chainName",t);const d="/v1/chains/{chain_name}/orders/listings".replace("{chain_name}",encodeURIComponent(String(t))),l=new URL(d,tI);let h;e&&(h=e.baseOptions);const p={method:"GET",...h,...u},b={};void 0!==r&&(b.status=r),void 0!==n&&(b.sell_item_contract_address=n),void 0!==i&&(b.buy_item_contract_address=i),void 0!==a&&(b.sell_item_token_id=a),void 0!==s&&(b.page_size=s),void 0!==o&&(b.sort_by=o),void 0!==c&&(b.sort_direction=c),void 0!==f&&(b.page_cursor=f),iI(l,b);let g=h&&h.headers?h.headers:{};return p.headers={...g,...u.headers},{url:sI(l),options:p}}}}(e);return{async createListing(r,n,i){const a=await t.createListing(r,n,i);return oI(a,YO,QO,e)},async fulfillmentData(r,n,i){const a=await t.fulfillmentData(r,n,i);return oI(a,YO,QO,e)},async getListing(r,n,i){const a=await t.getListing(r,n,i);return oI(a,YO,QO,e)},async listListings(r,n,i,a,s,o,c,f,u,d){const l=await t.listListings(r,n,i,a,s,o,c,f,u,d);return oI(l,YO,QO,e)}}};class vI extends ZO{createListing(e,t){return yI(this.configuration).createListing(e.chainName,e.createListingRequestBody,t).then((e=>e(this.axios,this.basePath)))}fulfillmentData(e,t){return yI(this.configuration).fulfillmentData(e.chainName,e.fulfillmentDataRequestInner,t).then((e=>e(this.axios,this.basePath)))}getListing(e,t){return yI(this.configuration).getListing(e.chainName,e.listingId,t).then((e=>e(this.axios,this.basePath)))}listListings(e,t){return yI(this.configuration).listListings(e.chainName,e.status,e.sellItemContractAddress,e.buyItemContractAddress,e.sellItemTokenId,e.pageSize,e.sortBy,e.sortDirection,e.pageCursor,t).then((e=>e(this.axios,this.basePath)))}}const wI=function(e){const t=function(e){return{createCounterfactualAddress:async(t,r={})=>{rI("createCounterfactualAddress","createCounterfactualAddressRequest",t);const n=new URL("/passport-mr/v1/counterfactual-address",tI);let i;e&&(i=e.baseOptions);const a={method:"POST",...i,...r},s={};await async function(e,t){if(t&&t.accessToken){const r="function"==typeof t.accessToken?await t.accessToken():await t.accessToken;e.Authorization="Bearer "+r}}(s,e),s["Content-Type"]="application/json",iI(n,{});let o=i&&i.headers?i.headers:{};return a.headers={...s,...o,...r.headers},a.data=aI(t,a,e),{url:sI(n),options:a}}}}(e);return{async createCounterfactualAddress(r,n){const i=await t.createCounterfactualAddress(r,n);return oI(i,YO,QO,e)}}};class _I extends ZO{createCounterfactualAddress(e,t){return wI(this.configuration).createCounterfactualAddress(e.createCounterfactualAddressRequest,t).then((e=>e(this.axios,this.basePath)))}}class EI{config;activitiesApi;chainsApi;collectionApi;nftOwnersApi;nftsApi;ordersApi;passportApi;constructor(e){this.config=e,this.activitiesApi=new fI(e.indexer),this.chainsApi=new dI(e.indexer),this.collectionApi=new hI(e.indexer),this.nftOwnersApi=new bI(e.indexer),this.nftsApi=new mI(e.indexer),this.ordersApi=new vI(e.orderBook),this.passportApi=new _I(e.passport)}}const AI={"x-sdk-version":"ts-immutable-sdk-0.0.0"},SI=({basePath:e,headers:t})=>{if(!e.trim())throw Error("basePath can not be empty");const r={basePath:e,baseOptions:{headers:{...AI,...t||{}}}};return new class{apiKey;username;password;accessToken;basePath;baseOptions;formDataCtor;constructor(e={}){this.apiKey=e.apiKey,this.username=e.username,this.password=e.password,this.accessToken=e.accessToken,this.basePath=e.basePath,this.baseOptions=e.baseOptions,this.formDataCtor=e.formDataCtor}isJsonMime(e){const t=new RegExp("^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$","i");return null!==e&&(t.test(e)||"application/json-patch+json"===e.toLowerCase())}}(r)},kI=()=>({indexer:SI({basePath:"https://indexer-mr.imtbl.com"}),orderBook:SI({basePath:"https://order-book-mr.imtbl.com"}),passport:SI({basePath:"https://api.immutable.com"})}),xI=()=>({indexer:SI({basePath:"https://indexer-mr.sandbox.imtbl.com"}),orderBook:SI({basePath:"https://order-book-mr.sandbox.imtbl.com"}),passport:SI({basePath:"https://api.sandbox.immutable.com"})});var TI={exports:{}};!function(e,t){e.exports=function(){var e=e||function(e,t){var n;if("undefined"!=typeof window&&window.crypto&&(n=window.crypto),"undefined"!=typeof self&&self.crypto&&(n=self.crypto),"undefined"!=typeof globalThis&&globalThis.crypto&&(n=globalThis.crypto),!n&&"undefined"!=typeof window&&window.msCrypto&&(n=window.msCrypto),!n&&void 0!==r&&r.crypto&&(n=r.crypto),!n)try{n=au}catch(e){}var i=function(){if(n){if("function"==typeof n.getRandomValues)try{return n.getRandomValues(new Uint32Array(1))[0]}catch(e){}if("function"==typeof n.randomBytes)try{return n.randomBytes(4).readInt32LE()}catch(e){}}throw new Error("Native crypto module could not be used to get secure random number.")},a=Object.create||function(){function e(){}return function(t){var r;return e.prototype=t,r=new e,e.prototype=null,r}}(),s={},o=s.lib={},c=o.Base={extend:function(e){var t=a(this);return e&&t.mixIn(e),t.hasOwnProperty("init")&&this.init!==t.init||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},f=o.WordArray=c.extend({init:function(e,r){e=this.words=e||[],this.sigBytes=r!=t?r:4*e.length},toString:function(e){return(e||d).stringify(this)},concat:function(e){var t=this.words,r=e.words,n=this.sigBytes,i=e.sigBytes;if(this.clamp(),n%4)for(var a=0;a<i;a++){var s=r[a>>>2]>>>24-a%4*8&255;t[n+a>>>2]|=s<<24-(n+a)%4*8}else for(var o=0;o<i;o+=4)t[n+o>>>2]=r[o>>>2];return this.sigBytes+=i,this},clamp:function(){var t=this.words,r=this.sigBytes;t[r>>>2]&=4294967295<<32-r%4*8,t.length=e.ceil(r/4)},clone:function(){var e=c.clone.call(this);return e.words=this.words.slice(0),e},random:function(e){for(var t=[],r=0;r<e;r+=4)t.push(i());return new f.init(t,e)}}),u=s.enc={},d=u.Hex={stringify:function(e){for(var t=e.words,r=e.sigBytes,n=[],i=0;i<r;i++){var a=t[i>>>2]>>>24-i%4*8&255;n.push((a>>>4).toString(16)),n.push((15&a).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,r=[],n=0;n<t;n+=2)r[n>>>3]|=parseInt(e.substr(n,2),16)<<24-n%8*4;return new f.init(r,t/2)}},l=u.Latin1={stringify:function(e){for(var t=e.words,r=e.sigBytes,n=[],i=0;i<r;i++){var a=t[i>>>2]>>>24-i%4*8&255;n.push(String.fromCharCode(a))}return n.join("")},parse:function(e){for(var t=e.length,r=[],n=0;n<t;n++)r[n>>>2]|=(255&e.charCodeAt(n))<<24-n%4*8;return new f.init(r,t)}},h=u.Utf8={stringify:function(e){try{return decodeURIComponent(escape(l.stringify(e)))}catch(e){throw new Error("Malformed UTF-8 data")}},parse:function(e){return l.parse(unescape(encodeURIComponent(e)))}},p=o.BufferedBlockAlgorithm=c.extend({reset:function(){this._data=new f.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=h.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var r,n=this._data,i=n.words,a=n.sigBytes,s=this.blockSize,o=a/(4*s),c=(o=t?e.ceil(o):e.max((0|o)-this._minBufferSize,0))*s,u=e.min(4*c,a);if(c){for(var d=0;d<c;d+=s)this._doProcessBlock(i,d);r=i.splice(0,c),n.sigBytes-=u}return new f.init(r,u)},clone:function(){var e=c.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0});o.Hasher=p.extend({cfg:c.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){p.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){return function(t,r){return new e.init(r).finalize(t)}},_createHmacHelper:function(e){return function(t,r){return new b.HMAC.init(e,r).finalize(t)}}});var b=s.algo={};return s}(Math);return e}()}(TI);var RI=TI.exports,OI=n(RI),II={exports:{}};!function(e,t){e.exports=function(e){return function(t){var r=e,n=r.lib,i=n.WordArray,a=n.Hasher,s=r.algo,o=[],c=[];!function(){function e(e){for(var r=t.sqrt(e),n=2;n<=r;n++)if(!(e%n))return!1;return!0}function r(e){return 4294967296*(e-(0|e))|0}for(var n=2,i=0;i<64;)e(n)&&(i<8&&(o[i]=r(t.pow(n,.5))),c[i]=r(t.pow(n,1/3)),i++),n++}();var f=[],u=s.SHA256=a.extend({_doReset:function(){this._hash=new i.init(o.slice(0))},_doProcessBlock:function(e,t){for(var r=this._hash.words,n=r[0],i=r[1],a=r[2],s=r[3],o=r[4],u=r[5],d=r[6],l=r[7],h=0;h<64;h++){if(h<16)f[h]=0|e[t+h];else{var p=f[h-15],b=(p<<25|p>>>7)^(p<<14|p>>>18)^p>>>3,g=f[h-2],m=(g<<15|g>>>17)^(g<<13|g>>>19)^g>>>10;f[h]=b+f[h-7]+m+f[h-16]}var y=n&i^n&a^i&a,v=(n<<30|n>>>2)^(n<<19|n>>>13)^(n<<10|n>>>22),w=l+((o<<26|o>>>6)^(o<<21|o>>>11)^(o<<7|o>>>25))+(o&u^~o&d)+c[h]+f[h];l=d,d=u,u=o,o=s+w|0,s=a,a=i,i=n,n=w+(v+y)|0}r[0]=r[0]+n|0,r[1]=r[1]+i|0,r[2]=r[2]+a|0,r[3]=r[3]+s|0,r[4]=r[4]+o|0,r[5]=r[5]+u|0,r[6]=r[6]+d|0,r[7]=r[7]+l|0},_doFinalize:function(){var e=this._data,r=e.words,n=8*this._nDataBytes,i=8*e.sigBytes;return r[i>>>5]|=128<<24-i%32,r[14+(i+64>>>9<<4)]=t.floor(n/4294967296),r[15+(i+64>>>9<<4)]=n,e.sigBytes=4*r.length,this._process(),this._hash},clone:function(){var e=a.clone.call(this);return e._hash=this._hash.clone(),e}});r.SHA256=a._createHelper(u),r.HmacSHA256=a._createHmacHelper(u)}(Math),e.SHA256}(RI)}(II);var MI=n(II.exports),CI={exports:{}};!function(e,t){e.exports=function(e){return function(){var t=e,r=t.lib.WordArray;function n(e,t,n){for(var i=[],a=0,s=0;s<t;s++)if(s%4){var o=n[e.charCodeAt(s-1)]<<s%4*2|n[e.charCodeAt(s)]>>>6-s%4*2;i[a>>>2]|=o<<24-a%4*8,a++}return r.create(i,a)}t.enc.Base64={stringify:function(e){var t=e.words,r=e.sigBytes,n=this._map;e.clamp();for(var i=[],a=0;a<r;a+=3)for(var s=(t[a>>>2]>>>24-a%4*8&255)<<16|(t[a+1>>>2]>>>24-(a+1)%4*8&255)<<8|t[a+2>>>2]>>>24-(a+2)%4*8&255,o=0;o<4&&a+.75*o<r;o++)i.push(n.charAt(s>>>6*(3-o)&63));var c=n.charAt(64);if(c)for(;i.length%4;)i.push(c);return i.join("")},parse:function(e){var t=e.length,r=this._map,i=this._reverseMap;if(!i){i=this._reverseMap=[];for(var a=0;a<r.length;a++)i[r.charCodeAt(a)]=a}var s=r.charAt(64);if(s){var o=e.indexOf(s);-1!==o&&(t=o)}return n(e,t,i)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),e.enc.Base64}(RI)}(CI);var PI=n(CI.exports),NI={exports:{}};!function(e,t){e.exports=function(e){return e.enc.Utf8}(RI)}(NI);var BI=n(NI.exports);function UI(e){this.message=e}UI.prototype=new Error,UI.prototype.name="InvalidCharacterError";var LI="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(e){var t=String(e).replace(/=+$/,"");if(t.length%4==1)throw new UI("'atob' failed: The string to be decoded is not correctly encoded.");for(var r,n,i=0,a=0,s="";n=t.charAt(a++);~n&&(r=i%4?64*r+n:n,i++%4)?s+=String.fromCharCode(255&r>>(-2*i&6)):0)n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(n);return s};function jI(e){this.message=e}function DI(e,t){if("string"!=typeof e)throw new jI("Invalid token specified");var r=!0===(t=t||{}).header?0:1;try{return JSON.parse(function(e){var t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw"Illegal base64url string!"}try{return function(e){return decodeURIComponent(LI(e).replace(/(.)/g,(function(e,t){var r=t.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r})))}(t)}catch(e){return LI(t)}}(e.split(".")[r]))}catch(e){throw new jI("Invalid token specified: "+e.message)}}jI.prototype=new Error,jI.prototype.name="InvalidTokenError";var FI,qI,zI,KI={debug:()=>{},info:()=>{},warn:()=>{},error:()=>{}},HI=(e=>(e[e.NONE=0]="NONE",e[e.ERROR=1]="ERROR",e[e.WARN=2]="WARN",e[e.INFO=3]="INFO",e[e.DEBUG=4]="DEBUG",e))(HI||{});(zI=HI||(HI={})).reset=function(){FI=3,qI=KI},zI.setLevel=function(e){if(!(0<=e&&e<=4))throw new Error("Invalid log level");FI=e},zI.setLogger=function(e){qI=e};var GI=class{constructor(e){this._name=e}debug(...e){FI>=4&&qI.debug(GI._format(this._name,this._method),...e)}info(...e){FI>=3&&qI.info(GI._format(this._name,this._method),...e)}warn(...e){FI>=2&&qI.warn(GI._format(this._name,this._method),...e)}error(...e){FI>=1&&qI.error(GI._format(this._name,this._method),...e)}throw(e){throw this.error(e),e}create(e){const t=Object.create(this);return t._method=e,t.debug("begin"),t}static createStatic(e,t){const r=new GI(`${e}.${t}`);return r.debug("begin"),r}static _format(e,t){const r=`[${e}]`;return t?`${r} ${t}:`:r}static debug(e,...t){FI>=4&&qI.debug(GI._format(e),...t)}static info(e,...t){FI>=3&&qI.info(GI._format(e),...t)}static warn(e,...t){FI>=2&&qI.warn(GI._format(e),...t)}static error(e,...t){FI>=1&&qI.error(GI._format(e),...t)}};HI.reset();var VI=class{static _randomWord(){return OI.lib.WordArray.random(1).words[0]}static generateUUIDv4(){const e="10000000-1000-4000-8000-100000000000".replace(/[018]/g,(e=>(+e^VI._randomWord()&15>>+e/4).toString(16)));return e.replace(/-/g,"")}static generateCodeVerifier(){return VI.generateUUIDv4()+VI.generateUUIDv4()+VI.generateUUIDv4()}static generateCodeChallenge(e){try{const t=MI(e);return PI.stringify(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}catch(e){throw GI.error("CryptoUtils.generateCodeChallenge",e),e}}static generateBasicAuth(e,t){const r=BI.parse([e,t].join(":"));return PI.stringify(r)}},WI=class{constructor(e){this._name=e,this._logger=new GI(`Event('${this._name}')`),this._callbacks=[]}addHandler(e){return this._callbacks.push(e),()=>this.removeHandler(e)}removeHandler(e){const t=this._callbacks.lastIndexOf(e);t>=0&&this._callbacks.splice(t,1)}raise(...e){this._logger.debug("raise:",...e);for(const t of this._callbacks)t(...e)}},XI=class{static decode(e){try{return DI(e)}catch(e){throw GI.error("JwtUtils.decode",e),e}}},$I=class{static center({...e}){var t;return null==e.width&&(e.width=null!=(t=[800,720,600,480].find((e=>e<=window.outerWidth/1.618)))?t:360),null!=e.left||(e.left=Math.max(0,Math.round(window.screenX+(window.outerWidth-e.width)/2))),null!=e.height&&(null!=e.top||(e.top=Math.max(0,Math.round(window.screenY+(window.outerHeight-e.height)/2)))),e}static serialize(e){return Object.entries(e).filter((([,e])=>null!=e)).map((([e,t])=>`${e}=${"boolean"!=typeof t?t:t?"yes":"no"}`)).join(",")}},JI=class extends WI{constructor(){super(...arguments),this._logger=new GI(`Timer('${this._name}')`),this._timerHandle=null,this._expiration=0,this._callback=()=>{const e=this._expiration-JI.getEpochTime();this._logger.debug("timer completes in",e),this._expiration<=JI.getEpochTime()&&(this.cancel(),super.raise())}}static getEpochTime(){return Math.floor(Date.now()/1e3)}init(e){const t=this._logger.create("init");e=Math.max(Math.floor(e),1);const r=JI.getEpochTime()+e;if(this.expiration===r&&this._timerHandle)return void t.debug("skipping since already initialized for expiration at",this.expiration);this.cancel(),t.debug("using duration",e),this._expiration=r;const n=Math.min(e,5);this._timerHandle=setInterval(this._callback,1e3*n)}get expiration(){return this._expiration}cancel(){this._logger.create("cancel"),this._timerHandle&&(clearInterval(this._timerHandle),this._timerHandle=null)}},YI=class{static readParams(e,t="query"){if(!e)throw new TypeError("Invalid URL");const r=new URL(e,"http://127.0.0.1")["fragment"===t?"hash":"search"];return new URLSearchParams(r.slice(1))}},QI=class extends Error{constructor(e,t){var r,n,i;if(super(e.error_description||e.error||""),this.form=t,this.name="ErrorResponse",!e.error)throw GI.error("ErrorResponse","No error passed"),new Error("No error passed");this.error=e.error,this.error_description=null!=(r=e.error_description)?r:null,this.error_uri=null!=(n=e.error_uri)?n:null,this.state=e.userState,this.session_state=null!=(i=e.session_state)?i:null}},ZI=class extends Error{constructor(e){super(e),this.name="ErrorTimeout"}},eM=class{constructor(e){this._logger=new GI("AccessTokenEvents"),this._expiringTimer=new JI("Access token expiring"),this._expiredTimer=new JI("Access token expired"),this._expiringNotificationTimeInSeconds=e.expiringNotificationTimeInSeconds}load(e){const t=this._logger.create("load");if(e.access_token&&void 0!==e.expires_in){const r=e.expires_in;if(t.debug("access token present, remaining duration:",r),r>0){let e=r-this._expiringNotificationTimeInSeconds;e<=0&&(e=1),t.debug("registering expiring timer, raising in",e,"seconds"),this._expiringTimer.init(e)}else t.debug("canceling existing expiring timer because we're past expiration."),this._expiringTimer.cancel();const n=r+1;t.debug("registering expired timer, raising in",n,"seconds"),this._expiredTimer.init(n)}else this._expiringTimer.cancel(),this._expiredTimer.cancel()}unload(){this._logger.debug("unload: canceling existing access token timers"),this._expiringTimer.cancel(),this._expiredTimer.cancel()}addAccessTokenExpiring(e){return this._expiringTimer.addHandler(e)}removeAccessTokenExpiring(e){this._expiringTimer.removeHandler(e)}addAccessTokenExpired(e){return this._expiredTimer.addHandler(e)}removeAccessTokenExpired(e){this._expiredTimer.removeHandler(e)}},tM=class{constructor(){this._logger=new GI("InMemoryWebStorage"),this._data={}}clear(){this._logger.create("clear"),this._data={}}getItem(e){return this._logger.create(`getItem('${e}')`),this._data[e]}setItem(e,t){this._logger.create(`setItem('${e}')`),this._data[e]=t}removeItem(e){this._logger.create(`removeItem('${e}')`),delete this._data[e]}get length(){return Object.getOwnPropertyNames(this._data).length}key(e){return Object.getOwnPropertyNames(this._data)[e]}},rM=class{constructor(e=[],t=null,r={}){this._jwtHandler=t,this._extraHeaders=r,this._logger=new GI("JsonService"),this._contentTypes=[],this._contentTypes.push(...e,"application/json"),t&&this._contentTypes.push("application/jwt")}async fetchWithTimeout(e,t={}){const{timeoutInSeconds:r,...n}=t;if(!r)return await fetch(e,n);const i=new AbortController,a=setTimeout((()=>i.abort()),1e3*r);try{return await fetch(e,{...t,signal:i.signal})}catch(e){if(e instanceof DOMException&&"AbortError"===e.name)throw new ZI("Network timed out");throw e}finally{clearTimeout(a)}}async getJson(e,{token:t,credentials:r}={}){const n=this._logger.create("getJson"),i={Accept:this._contentTypes.join(", ")};let a;t&&(n.debug("token passed, setting Authorization header"),i.Authorization="Bearer "+t),this.appendExtraHeaders(i);try{n.debug("url:",e),a=await this.fetchWithTimeout(e,{method:"GET",headers:i,credentials:r})}catch(e){throw n.error("Network Error"),e}n.debug("HTTP response received, status",a.status);const s=a.headers.get("Content-Type");if(s&&!this._contentTypes.find((e=>s.startsWith(e)))&&n.throw(new Error(`Invalid response Content-Type: ${null!=s?s:"undefined"}, from URL: ${e}`)),a.ok&&this._jwtHandler&&(null==s?void 0:s.startsWith("application/jwt")))return await this._jwtHandler(await a.text());let o;try{o=await a.json()}catch(e){if(n.error("Error parsing JSON response",e),a.ok)throw e;throw new Error(`${a.statusText} (${a.status})`)}if(!a.ok){if(n.error("Error from server:",o),o.error)throw new QI(o);throw new Error(`${a.statusText} (${a.status}): ${JSON.stringify(o)}`)}return o}async postForm(e,{body:t,basicAuth:r,timeoutInSeconds:n,initCredentials:i}){const a=this._logger.create("postForm"),s={Accept:this._contentTypes.join(", "),"Content-Type":"application/x-www-form-urlencoded"};let o;void 0!==r&&(s.Authorization="Basic "+r),this.appendExtraHeaders(s);try{a.debug("url:",e),o=await this.fetchWithTimeout(e,{method:"POST",headers:s,body:t,timeoutInSeconds:n,credentials:i})}catch(e){throw a.error("Network error"),e}a.debug("HTTP response received, status",o.status);const c=o.headers.get("Content-Type");if(c&&!this._contentTypes.find((e=>c.startsWith(e))))throw new Error(`Invalid response Content-Type: ${null!=c?c:"undefined"}, from URL: ${e}`);const f=await o.text();let u={};if(f)try{u=JSON.parse(f)}catch(e){if(a.error("Error parsing JSON response",e),o.ok)throw e;throw new Error(`${o.statusText} (${o.status})`)}if(!o.ok){if(a.error("Error from server:",u),u.error)throw new QI(u,t);throw new Error(`${o.statusText} (${o.status}): ${JSON.stringify(u)}`)}return u}appendExtraHeaders(e){const t=this._logger.create("appendExtraHeaders"),r=Object.keys(this._extraHeaders),n=["authorization","accept","content-type"];0!==r.length&&r.forEach((r=>{if(n.includes(r.toLocaleLowerCase()))return void t.warn("Protected header could not be overridden",r,n);const i="function"==typeof this._extraHeaders[r]?this._extraHeaders[r]():this._extraHeaders[r];i&&""!==i&&(e[r]=i)}))}},nM=class{constructor({prefix:e="oidc.",store:t=localStorage}={}){this._logger=new GI("WebStorageStateStore"),this._store=t,this._prefix=e}async set(e,t){this._logger.create(`set('${e}')`),e=this._prefix+e,await this._store.setItem(e,t)}async get(e){this._logger.create(`get('${e}')`),e=this._prefix+e;return await this._store.getItem(e)}async remove(e){this._logger.create(`remove('${e}')`),e=this._prefix+e;const t=await this._store.getItem(e);return await this._store.removeItem(e),t}async getAllKeys(){this._logger.create("getAllKeys");const e=await this._store.length,t=[];for(let r=0;r<e;r++){const e=await this._store.key(r);e&&0===e.indexOf(this._prefix)&&t.push(e.substr(this._prefix.length))}return t}},iM=class{constructor({authority:e,metadataUrl:t,metadata:r,signingKeys:n,metadataSeed:i,client_id:a,client_secret:s,response_type:o="code",scope:c="openid",redirect_uri:f,post_logout_redirect_uri:u,client_authentication:d="client_secret_post",prompt:l,display:h,max_age:p,ui_locales:b,acr_values:g,resource:m,response_mode:y="query",filterProtocolClaims:v=!0,loadUserInfo:w=!1,staleStateAgeInSeconds:_=900,clockSkewInSeconds:E=300,userInfoJwtIssuer:A="OP",mergeClaims:S=!1,disablePKCE:k=!1,stateStore:x,refreshTokenCredentials:T,revokeTokenAdditionalContentTypes:R,fetchRequestCredentials:O,refreshTokenAllowedScope:I,extraQueryParams:M={},extraTokenParams:C={},extraHeaders:P={}}){if(this.authority=e,t?this.metadataUrl=t:(this.metadataUrl=e,e&&(this.metadataUrl.endsWith("/")||(this.metadataUrl+="/"),this.metadataUrl+=".well-known/openid-configuration")),this.metadata=r,this.metadataSeed=i,this.signingKeys=n,this.client_id=a,this.client_secret=s,this.response_type=o,this.scope=c,this.redirect_uri=f,this.post_logout_redirect_uri=u,this.client_authentication=d,this.prompt=l,this.display=h,this.max_age=p,this.ui_locales=b,this.acr_values=g,this.resource=m,this.response_mode=y,this.filterProtocolClaims=null==v||v,this.loadUserInfo=!!w,this.staleStateAgeInSeconds=_,this.clockSkewInSeconds=E,this.userInfoJwtIssuer=A,this.mergeClaims=!!S,this.disablePKCE=!!k,this.revokeTokenAdditionalContentTypes=R,O&&T&&console.warn("Both fetchRequestCredentials and refreshTokenCredentials is set. Only fetchRequestCredentials will be used."),this.fetchRequestCredentials=O||(T||"same-origin"),x)this.stateStore=x;else{const e="undefined"!=typeof window?window.localStorage:new tM;this.stateStore=new nM({store:e})}this.refreshTokenAllowedScope=I,this.extraQueryParams=M,this.extraTokenParams=C,this.extraHeaders=P}},aM=class{constructor(e,t){this._settings=e,this._metadataService=t,this._logger=new GI("TokenClient"),this._jsonService=new rM(this._settings.revokeTokenAdditionalContentTypes,null,this._settings.extraHeaders)}async exchangeCode({grant_type:e="authorization_code",redirect_uri:t=this._settings.redirect_uri,client_id:r=this._settings.client_id,client_secret:n=this._settings.client_secret,...i}){const a=this._logger.create("exchangeCode");r||a.throw(new Error("A client_id is required")),t||a.throw(new Error("A redirect_uri is required")),i.code||a.throw(new Error("A code is required"));const s=new URLSearchParams({grant_type:e,redirect_uri:t});for(const[e,t]of Object.entries(i))null!=t&&s.set(e,t);let o;switch(this._settings.client_authentication){case"client_secret_basic":if(!n)throw a.throw(new Error("A client_secret is required")),null;o=VI.generateBasicAuth(r,n);break;case"client_secret_post":s.append("client_id",r),n&&s.append("client_secret",n)}const c=await this._metadataService.getTokenEndpoint(!1);a.debug("got token endpoint");const f=await this._jsonService.postForm(c,{body:s,basicAuth:o,initCredentials:this._settings.fetchRequestCredentials});return a.debug("got response"),f}async exchangeCredentials({grant_type:e="password",client_id:t=this._settings.client_id,client_secret:r=this._settings.client_secret,scope:n=this._settings.scope,...i}){const a=this._logger.create("exchangeCredentials");t||a.throw(new Error("A client_id is required"));const s=new URLSearchParams({grant_type:e,scope:n});for(const[e,t]of Object.entries(i))null!=t&&s.set(e,t);let o;switch(this._settings.client_authentication){case"client_secret_basic":if(!r)throw a.throw(new Error("A client_secret is required")),null;o=VI.generateBasicAuth(t,r);break;case"client_secret_post":s.append("client_id",t),r&&s.append("client_secret",r)}const c=await this._metadataService.getTokenEndpoint(!1);a.debug("got token endpoint");const f=await this._jsonService.postForm(c,{body:s,basicAuth:o,initCredentials:this._settings.fetchRequestCredentials});return a.debug("got response"),f}async exchangeRefreshToken({grant_type:e="refresh_token",client_id:t=this._settings.client_id,client_secret:r=this._settings.client_secret,timeoutInSeconds:n,...i}){const a=this._logger.create("exchangeRefreshToken");t||a.throw(new Error("A client_id is required")),i.refresh_token||a.throw(new Error("A refresh_token is required"));const s=new URLSearchParams({grant_type:e});for(const[e,t]of Object.entries(i))null!=t&&s.set(e,t);let o;switch(this._settings.client_authentication){case"client_secret_basic":if(!r)throw a.throw(new Error("A client_secret is required")),null;o=VI.generateBasicAuth(t,r);break;case"client_secret_post":s.append("client_id",t),r&&s.append("client_secret",r)}const c=await this._metadataService.getTokenEndpoint(!1);a.debug("got token endpoint");const f=await this._jsonService.postForm(c,{body:s,basicAuth:o,timeoutInSeconds:n,initCredentials:this._settings.fetchRequestCredentials});return a.debug("got response"),f}async revoke(e){var t;const r=this._logger.create("revoke");e.token||r.throw(new Error("A token is required"));const n=await this._metadataService.getRevocationEndpoint(!1);r.debug(`got revocation endpoint, revoking ${null!=(t=e.token_type_hint)?t:"default token type"}`);const i=new URLSearchParams;for(const[t,r]of Object.entries(e))null!=r&&i.set(t,r);i.set("client_id",this._settings.client_id),this._settings.client_secret&&i.set("client_secret",this._settings.client_secret),await this._jsonService.postForm(n,{body:i}),r.debug("got response")}},sM=class{constructor(e){this.id=e.id||VI.generateUUIDv4(),this.data=e.data,e.created&&e.created>0?this.created=e.created:this.created=JI.getEpochTime(),this.request_type=e.request_type}toStorageString(){return new GI("State").create("toStorageString"),JSON.stringify({id:this.id,data:this.data,created:this.created,request_type:this.request_type})}static fromStorageString(e){return GI.createStatic("State","fromStorageString"),new sM(JSON.parse(e))}static async clearStaleState(e,t){const r=GI.createStatic("State","clearStaleState"),n=JI.getEpochTime()-t,i=await e.getAllKeys();r.debug("got keys",i);for(let t=0;t<i.length;t++){const a=i[t],s=await e.get(a);let o=!1;if(s)try{const e=sM.fromStorageString(s);r.debug("got item from key:",a,e.created),e.created<=n&&(o=!0)}catch(e){r.error("Error parsing state for key:",a,e),o=!0}else r.debug("no item in storage for key:",a),o=!0;o&&(r.debug("removed item for key:",a),e.remove(a))}}},oM=class extends sM{constructor(e){super(e),!0===e.code_verifier?this.code_verifier=VI.generateCodeVerifier():e.code_verifier&&(this.code_verifier=e.code_verifier),this.code_verifier&&(this.code_challenge=VI.generateCodeChallenge(this.code_verifier)),this.authority=e.authority,this.client_id=e.client_id,this.redirect_uri=e.redirect_uri,this.scope=e.scope,this.client_secret=e.client_secret,this.extraTokenParams=e.extraTokenParams,this.response_mode=e.response_mode,this.skipUserInfo=e.skipUserInfo}toStorageString(){return new GI("SigninState").create("toStorageString"),JSON.stringify({id:this.id,data:this.data,created:this.created,request_type:this.request_type,code_verifier:this.code_verifier,authority:this.authority,client_id:this.client_id,redirect_uri:this.redirect_uri,scope:this.scope,client_secret:this.client_secret,extraTokenParams:this.extraTokenParams,response_mode:this.response_mode,skipUserInfo:this.skipUserInfo})}static fromStorageString(e){GI.createStatic("SigninState","fromStorageString");const t=JSON.parse(e);return new oM(t)}},cM=class{constructor(e){this.access_token="",this.token_type="",this.profile={},this.state=e.get("state"),this.session_state=e.get("session_state"),this.error=e.get("error"),this.error_description=e.get("error_description"),this.error_uri=e.get("error_uri"),this.code=e.get("code")}get expires_in(){if(void 0!==this.expires_at)return this.expires_at-JI.getEpochTime()}set expires_in(e){"string"==typeof e&&(e=Number(e)),void 0!==e&&e>=0&&(this.expires_at=Math.floor(e)+JI.getEpochTime())}get isOpenId(){var e;return(null==(e=this.scope)?void 0:e.split(" ").includes("openid"))||!!this.id_token}},fM=["nbf","jti","auth_time","nonce","acr","amr","azp","at_hash"],uM=["sub","iss","aud","exp","iat"],dM=class{constructor(e){var t;this.id_token=e.id_token,this.session_state=null!=(t=e.session_state)?t:null,this.access_token=e.access_token,this.refresh_token=e.refresh_token,this.token_type=e.token_type,this.scope=e.scope,this.profile=e.profile,this.expires_at=e.expires_at,this.state=e.userState}get expires_in(){if(void 0!==this.expires_at)return this.expires_at-JI.getEpochTime()}set expires_in(e){void 0!==e&&(this.expires_at=Math.floor(e)+JI.getEpochTime())}get expired(){const e=this.expires_in;if(void 0!==e)return e<=0}get scopes(){var e,t;return null!=(t=null==(e=this.scope)?void 0:e.split(" "))?t:[]}toStorageString(){return new GI("User").create("toStorageString"),JSON.stringify({id_token:this.id_token,session_state:this.session_state,access_token:this.access_token,refresh_token:this.refresh_token,token_type:this.token_type,scope:this.scope,profile:this.profile,expires_at:this.expires_at})}static fromStorageString(e){return GI.createStatic("User","fromStorageString"),new dM(JSON.parse(e))}},lM="oidc-client",hM=class{constructor(){this._abort=new WI("Window navigation aborted"),this._disposeHandlers=new Set,this._window=null}async navigate(e){const t=this._logger.create("navigate");if(!this._window)throw new Error("Attempted to navigate on a disposed window");t.debug("setting URL in window"),this._window.location.replace(e.url);const{url:r,keepOpen:n}=await new Promise(((r,n)=>{const i=i=>{var a;const s=i.data,o=null!=(a=e.scriptOrigin)?a:window.location.origin;if(i.origin===o&&(null==s?void 0:s.source)===lM){try{const r=YI.readParams(s.url,e.response_mode).get("state");if(r||t.warn("no state found in response url"),i.source!==this._window&&r!==e.state)return}catch(e){this._dispose(),n(new Error("Invalid response from window"))}r(s)}};window.addEventListener("message",i,!1),this._disposeHandlers.add((()=>window.removeEventListener("message",i,!1))),this._disposeHandlers.add(this._abort.addHandler((e=>{this._dispose(),n(e)})))}));return t.debug("got response from window"),this._dispose(),n||this.close(),{url:r}}_dispose(){this._logger.create("_dispose");for(const e of this._disposeHandlers)e();this._disposeHandlers.clear()}static _notifyParent(e,t,r=!1,n=window.location.origin){e.postMessage({source:lM,url:t,keepOpen:r},n)}},pM={location:!1,toolbar:!1,height:640},bM="_blank",gM=60,mM=2,yM=10,vM=class extends iM{constructor(e){const{popup_redirect_uri:t=e.redirect_uri,popup_post_logout_redirect_uri:r=e.post_logout_redirect_uri,popupWindowFeatures:n=pM,popupWindowTarget:i=bM,redirectMethod:a="assign",redirectTarget:s="self",iframeNotifyParentOrigin:o=e.iframeNotifyParentOrigin,iframeScriptOrigin:c=e.iframeScriptOrigin,silent_redirect_uri:f=e.redirect_uri,silentRequestTimeoutInSeconds:u=yM,automaticSilentRenew:d=!0,validateSubOnSilentRenew:l=!0,includeIdTokenInSilentRenew:h=!1,monitorSession:p=!1,monitorAnonymousSession:b=!1,checkSessionIntervalInSeconds:g=mM,query_status_response_type:m="code",stopCheckSessionOnError:y=!0,revokeTokenTypes:v=["access_token","refresh_token"],revokeTokensOnSignout:w=!1,includeIdTokenInSilentSignout:_=!1,accessTokenExpiringNotificationTimeInSeconds:E=gM,userStore:A}=e;if(super(e),this.popup_redirect_uri=t,this.popup_post_logout_redirect_uri=r,this.popupWindowFeatures=n,this.popupWindowTarget=i,this.redirectMethod=a,this.redirectTarget=s,this.iframeNotifyParentOrigin=o,this.iframeScriptOrigin=c,this.silent_redirect_uri=f,this.silentRequestTimeoutInSeconds=u,this.automaticSilentRenew=d,this.validateSubOnSilentRenew=l,this.includeIdTokenInSilentRenew=h,this.monitorSession=p,this.monitorAnonymousSession=b,this.checkSessionIntervalInSeconds=g,this.stopCheckSessionOnError=y,this.query_status_response_type=m,this.revokeTokenTypes=v,this.revokeTokensOnSignout=w,this.includeIdTokenInSilentSignout=_,this.accessTokenExpiringNotificationTimeInSeconds=E,A)this.userStore=A;else{const e="undefined"!=typeof window?window.sessionStorage:new tM;this.userStore=new nM({store:e})}}},wM=class extends hM{constructor({silentRequestTimeoutInSeconds:e=yM}){super(),this._logger=new GI("IFrameWindow"),this._timeoutInSeconds=e,this._frame=wM.createHiddenIframe(),this._window=this._frame.contentWindow}static createHiddenIframe(){const e=window.document.createElement("iframe");return e.style.visibility="hidden",e.style.position="fixed",e.style.left="-1000px",e.style.top="0",e.width="0",e.height="0",e.setAttribute("sandbox","allow-scripts allow-same-origin allow-forms"),window.document.body.appendChild(e),e}async navigate(e){this._logger.debug("navigate: Using timeout of:",this._timeoutInSeconds);const t=setTimeout((()=>this._abort.raise(new ZI("IFrame timed out without a response"))),1e3*this._timeoutInSeconds);return this._disposeHandlers.add((()=>clearTimeout(t))),await super.navigate(e)}close(){var e;this._frame&&(this._frame.parentNode&&(this._frame.addEventListener("load",(e=>{var t;const r=e.target;null==(t=r.parentNode)||t.removeChild(r),this._abort.raise(new Error("IFrame removed from DOM"))}),!0),null==(e=this._frame.contentWindow)||e.location.replace("about:blank")),this._frame=null),this._window=null}static notifyParent(e,t){return super._notifyParent(window.parent,e,!1,t)}},_M=class extends hM{constructor({popupWindowTarget:e=bM,popupWindowFeatures:t={}}){super(),this._logger=new GI("PopupWindow");const r=$I.center({...pM,...t});this._window=window.open(void 0,e,$I.serialize(r))}async navigate(e){var t;null==(t=this._window)||t.focus();const r=setInterval((()=>{this._window&&!this._window.closed||this._abort.raise(new Error("Popup closed by user"))}),500);return this._disposeHandlers.add((()=>clearInterval(r))),await super.navigate(e)}close(){this._window&&(this._window.closed||(this._window.close(),this._abort.raise(new Error("Popup closed")))),this._window=null}static notifyOpener(e,t){if(!window.opener)throw new Error("No window.opener. Can't complete notification.");return super._notifyParent(window.opener,e,t)}},EM=class extends eM{constructor(e){super({expiringNotificationTimeInSeconds:e.accessTokenExpiringNotificationTimeInSeconds}),this._logger=new GI("UserManagerEvents"),this._userLoaded=new WI("User loaded"),this._userUnloaded=new WI("User unloaded"),this._silentRenewError=new WI("Silent renew error"),this._userSignedIn=new WI("User signed in"),this._userSignedOut=new WI("User signed out"),this._userSessionChanged=new WI("User session changed")}load(e,t=!0){super.load(e),t&&this._userLoaded.raise(e)}unload(){super.unload(),this._userUnloaded.raise()}addUserLoaded(e){return this._userLoaded.addHandler(e)}removeUserLoaded(e){return this._userLoaded.removeHandler(e)}addUserUnloaded(e){return this._userUnloaded.addHandler(e)}removeUserUnloaded(e){return this._userUnloaded.removeHandler(e)}addSilentRenewError(e){return this._silentRenewError.addHandler(e)}removeSilentRenewError(e){return this._silentRenewError.removeHandler(e)}_raiseSilentRenewError(e){this._silentRenewError.raise(e)}addUserSignedIn(e){return this._userSignedIn.addHandler(e)}removeUserSignedIn(e){this._userSignedIn.removeHandler(e)}_raiseUserSignedIn(){this._userSignedIn.raise()}addUserSignedOut(e){return this._userSignedOut.addHandler(e)}removeUserSignedOut(e){this._userSignedOut.removeHandler(e)}_raiseUserSignedOut(){this._userSignedOut.raise()}addUserSessionChanged(e){return this._userSessionChanged.addHandler(e)}removeUserSessionChanged(e){this._userSessionChanged.removeHandler(e)}_raiseUserSessionChanged(){this._userSessionChanged.raise()}},AM=(e=>(e.MissingApiKey="MISSING_API_KEY",e.ModalNotReady="MODAL_NOT_READY",e.MalformedResponse="MALFORMED_RESPONSE",e.InvalidArgument="INVALID_ARGUMENT",e.ExtensionNotInitialized="EXTENSION_NOT_INITIALIZED",e.IncompatibleExtensions="INCOMPATIBLE_EXTENSIONS",e))(AM||{}),SM=(e=>(e.SyncWeb3Method="SYNC_WEB3_METHOD",e.DuplicateIframe="DUPLICATE_IFRAME",e.ReactNativeEndpointConfiguration="REACT_NATIVE_ENDPOINT_CONFIGURATION",e.DeprecationNotice="DEPRECATION_NOTICE",e))(SM||{}),kM=(e=>(e[e.ParseError=-32700]="ParseError",e[e.InvalidRequest=-32600]="InvalidRequest",e[e.MethodNotFound=-32601]="MethodNotFound",e[e.InvalidParams=-32602]="InvalidParams",e[e.InternalError=-32603]="InternalError",e[e.MagicLinkFailedVerification=-1e4]="MagicLinkFailedVerification",e[e.MagicLinkExpired=-10001]="MagicLinkExpired",e[e.MagicLinkRateLimited=-10002]="MagicLinkRateLimited",e[e.MagicLinkInvalidRedirectURL=-10006]="MagicLinkInvalidRedirectURL",e[e.UserAlreadyLoggedIn=-10003]="UserAlreadyLoggedIn",e[e.UpdateEmailFailed=-10004]="UpdateEmailFailed",e[e.UserRequestEditEmail=-10005]="UserRequestEditEmail",e[e.InactiveRecipient=-10010]="InactiveRecipient",e[e.AccessDeniedToUser=-10011]="AccessDeniedToUser",e))(kM||{}),xM=(e=>(e.LoginWithSms="magic_auth_login_with_sms",e.LoginWithEmailOTP="magic_auth_login_with_email_otp",e.LoginWithMagicLink="magic_auth_login_with_magic_link",e.LoginWithCredential="magic_auth_login_with_credential",e.GetIdToken="magic_auth_get_id_token",e.GenerateIdToken="magic_auth_generate_id_token",e.GetMetadata="magic_auth_get_metadata",e.IsLoggedIn="magic_auth_is_logged_in",e.Logout="magic_auth_logout",e.UpdateEmail="magic_auth_update_email",e.UserSettings="magic_auth_settings",e.UserSettingsTestMode="magic_auth_settings_testing_mode",e.LoginWithSmsTestMode="magic_auth_login_with_sms_testing_mode",e.LoginWithEmailOTPTestMode="magic_auth_login_with_email_otp_testing_mode",e.LoginWithMagicLinkTestMode="magic_login_with_magic_link_testing_mode",e.LoginWithCredentialTestMode="magic_auth_login_with_credential_testing_mode",e.GetIdTokenTestMode="magic_auth_get_id_token_testing_mode",e.GenerateIdTokenTestMode="magic_auth_generate_id_token_testing_mode",e.GetMetadataTestMode="magic_auth_get_metadata_testing_mode",e.IsLoggedInTestMode="magic_auth_is_logged_in_testing_mode",e.LogoutTestMode="magic_auth_logout_testing_mode",e.UpdateEmailTestMode="magic_auth_update_email_testing_mode",e.IntermediaryEvent="magic_intermediary_event",e.RequestAccounts="eth_requestAccounts",e.GetInfo="mc_get_wallet_info",e.ShowUI="mc_wallet",e.NFTPurchase="magic_nft_purchase",e.RequestUserInfoWithUI="mc_request_user_info",e.Disconnect="mc_disconnect",e.UpdatePhoneNumber="magic_auth_update_phone_number",e.UpdatePhoneNumberTestMode="magic_auth_update_phone_number_testing_mode",e.RecoverAccount="magic_auth_recover_account",e.RecoverAccountTestMode="magic_auth_recover_account_testing_mode",e))(xM||{}),TM=(e=>(e.MAGIC_HANDLE_RESPONSE="MAGIC_HANDLE_RESPONSE",e.MAGIC_OVERLAY_READY="MAGIC_OVERLAY_READY",e.MAGIC_SHOW_OVERLAY="MAGIC_SHOW_OVERLAY",e.MAGIC_HIDE_OVERLAY="MAGIC_HIDE_OVERLAY",e.MAGIC_HANDLE_EVENT="MAGIC_HANDLE_EVENT",e))(TM||{}),RM=(e=>(e.MAGIC_HANDLE_REQUEST="MAGIC_HANDLE_REQUEST",e))(RM||{}),OM=(e=>(e.Harmony="HARMONY",e))(OM||{}),IM=Object.create,MM=Object.defineProperty,CM=Object.defineProperties,PM=Object.getOwnPropertyDescriptor,NM=Object.getOwnPropertyDescriptors,BM=Object.getOwnPropertyNames,UM=Object.getOwnPropertySymbols,LM=Object.getPrototypeOf,jM=Object.prototype.hasOwnProperty,DM=Object.prototype.propertyIsEnumerable,FM=(e,t,r)=>t in e?MM(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,qM=(e,t)=>{for(var r in t||(t={}))jM.call(t,r)&&FM(e,r,t[r]);if(UM)for(var r of UM(t))DM.call(t,r)&&FM(e,r,t[r]);return e},zM=(e,t,r)=>new Promise(((n,i)=>{var a=e=>{try{o(r.next(e))}catch(e){i(e)}},s=e=>{try{o(r.throw(e))}catch(e){i(e)}},o=e=>e.done?n(e.value):Promise.resolve(e.value).then(a,s);o((r=r.apply(e,t)).next())})),KM=((e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports))(((e,t)=>{var r=Object.prototype.hasOwnProperty,n="~";function i(){}function a(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function s(e,t,r,i,s){if("function"!=typeof r)throw new TypeError("The listener must be a function");var o=new a(r,i||e,s),c=n?n+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],o]:e._events[c].push(o):(e._events[c]=o,e._eventsCount++),e}function o(e,t){0==--e._eventsCount?e._events=new i:delete e._events[t]}function c(){this._events=new i,this._eventsCount=0}Object.create&&(i.prototype=Object.create(null),(new i).__proto__||(n=!1)),c.prototype.eventNames=function(){var e,t,i=[];if(0===this._eventsCount)return i;for(t in e=this._events)r.call(e,t)&&i.push(n?t.slice(1):t);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(e)):i},c.prototype.listeners=function(e){var t=n?n+e:e,r=this._events[t];if(!r)return[];if(r.fn)return[r.fn];for(var i=0,a=r.length,s=new Array(a);i<a;i++)s[i]=r[i].fn;return s},c.prototype.listenerCount=function(e){var t=n?n+e:e,r=this._events[t];return r?r.fn?1:r.length:0},c.prototype.emit=function(e,t,r,i,a,s){var o=n?n+e:e;if(!this._events[o])return!1;var c,f,u=this._events[o],d=arguments.length;if(u.fn){switch(u.once&&this.removeListener(e,u.fn,void 0,!0),d){case 1:return u.fn.call(u.context),!0;case 2:return u.fn.call(u.context,t),!0;case 3:return u.fn.call(u.context,t,r),!0;case 4:return u.fn.call(u.context,t,r,i),!0;case 5:return u.fn.call(u.context,t,r,i,a),!0;case 6:return u.fn.call(u.context,t,r,i,a,s),!0}for(f=1,c=new Array(d-1);f<d;f++)c[f-1]=arguments[f];u.fn.apply(u.context,c)}else{var l,h=u.length;for(f=0;f<h;f++)switch(u[f].once&&this.removeListener(e,u[f].fn,void 0,!0),d){case 1:u[f].fn.call(u[f].context);break;case 2:u[f].fn.call(u[f].context,t);break;case 3:u[f].fn.call(u[f].context,t,r);break;case 4:u[f].fn.call(u[f].context,t,r,i);break;default:if(!c)for(l=1,c=new Array(d-1);l<d;l++)c[l-1]=arguments[l];u[f].fn.apply(u[f].context,c)}}return!0},c.prototype.on=function(e,t,r){return s(this,e,t,r,!1)},c.prototype.once=function(e,t,r){return s(this,e,t,r,!0)},c.prototype.removeListener=function(e,t,r,i){var a=n?n+e:e;if(!this._events[a])return this;if(!t)return o(this,a),this;var s=this._events[a];if(s.fn)s.fn===t&&(!i||s.once)&&(!r||s.context===r)&&o(this,a);else{for(var c=0,f=[],u=s.length;c<u;c++)(s[c].fn!==t||i&&!s[c].once||r&&s[c].context!==r)&&f.push(s[c]);f.length?this._events[a]=1===f.length?f[0]:f:o(this,a)}return this},c.prototype.removeAllListeners=function(e){var t;return e?(t=n?n+e:e,this._events[t]&&o(this,t)):(this._events=new i,this._eventsCount=0),this},c.prototype.off=c.prototype.removeListener,c.prototype.addListener=c.prototype.on,c.prefixed=n,c.EventEmitter=c,typeof t<"u"&&(t.exports=c)}));var HM={SEMVER_SPEC_VERSION:"2.0.0",MAX_LENGTH:256,MAX_SAFE_INTEGER:Number.MAX_SAFE_INTEGER||9007199254740991,MAX_SAFE_COMPONENT_LENGTH:16},GM="object"==typeof process&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...e)=>console.error("SEMVER",...e):()=>{},VM=GM,WM=function(e){let t={exports:{}};return e(t,t.exports),t.exports}((function(e,t){let{MAX_SAFE_COMPONENT_LENGTH:r}=HM,n=(t=e.exports={}).re=[],i=t.src=[],a=t.t={},s=0,o=(e,t,r)=>{let o=s++;VM(o,t),a[e]=o,i[o]=t,n[o]=new RegExp(t,r?"g":void 0)};o("NUMERICIDENTIFIER","0|[1-9]\\d*"),o("NUMERICIDENTIFIERLOOSE","[0-9]+"),o("NONNUMERICIDENTIFIER","\\d*[a-zA-Z-][a-zA-Z0-9-]*"),o("MAINVERSION",`(${i[a.NUMERICIDENTIFIER]})\\.(${i[a.NUMERICIDENTIFIER]})\\.(${i[a.NUMERICIDENTIFIER]})`),o("MAINVERSIONLOOSE",`(${i[a.NUMERICIDENTIFIERLOOSE]})\\.(${i[a.NUMERICIDENTIFIERLOOSE]})\\.(${i[a.NUMERICIDENTIFIERLOOSE]})`),o("PRERELEASEIDENTIFIER",`(?:${i[a.NUMERICIDENTIFIER]}|${i[a.NONNUMERICIDENTIFIER]})`),o("PRERELEASEIDENTIFIERLOOSE",`(?:${i[a.NUMERICIDENTIFIERLOOSE]}|${i[a.NONNUMERICIDENTIFIER]})`),o("PRERELEASE",`(?:-(${i[a.PRERELEASEIDENTIFIER]}(?:\\.${i[a.PRERELEASEIDENTIFIER]})*))`),o("PRERELEASELOOSE",`(?:-?(${i[a.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${i[a.PRERELEASEIDENTIFIERLOOSE]})*))`),o("BUILDIDENTIFIER","[0-9A-Za-z-]+"),o("BUILD",`(?:\\+(${i[a.BUILDIDENTIFIER]}(?:\\.${i[a.BUILDIDENTIFIER]})*))`),o("FULLPLAIN",`v?${i[a.MAINVERSION]}${i[a.PRERELEASE]}?${i[a.BUILD]}?`),o("FULL",`^${i[a.FULLPLAIN]}$`),o("LOOSEPLAIN",`[v=\\s]*${i[a.MAINVERSIONLOOSE]}${i[a.PRERELEASELOOSE]}?${i[a.BUILD]}?`),o("LOOSE",`^${i[a.LOOSEPLAIN]}$`),o("GTLT","((?:<|>)?=?)"),o("XRANGEIDENTIFIERLOOSE",`${i[a.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),o("XRANGEIDENTIFIER",`${i[a.NUMERICIDENTIFIER]}|x|X|\\*`),o("XRANGEPLAIN",`[v=\\s]*(${i[a.XRANGEIDENTIFIER]})(?:\\.(${i[a.XRANGEIDENTIFIER]})(?:\\.(${i[a.XRANGEIDENTIFIER]})(?:${i[a.PRERELEASE]})?${i[a.BUILD]}?)?)?`),o("XRANGEPLAINLOOSE",`[v=\\s]*(${i[a.XRANGEIDENTIFIERLOOSE]})(?:\\.(${i[a.XRANGEIDENTIFIERLOOSE]})(?:\\.(${i[a.XRANGEIDENTIFIERLOOSE]})(?:${i[a.PRERELEASELOOSE]})?${i[a.BUILD]}?)?)?`),o("XRANGE",`^${i[a.GTLT]}\\s*${i[a.XRANGEPLAIN]}$`),o("XRANGELOOSE",`^${i[a.GTLT]}\\s*${i[a.XRANGEPLAINLOOSE]}$`),o("COERCE",`(^|[^\\d])(\\d{1,${r}})(?:\\.(\\d{1,${r}}))?(?:\\.(\\d{1,${r}}))?(?:$|[^\\d])`),o("COERCERTL",i[a.COERCE],!0),o("LONETILDE","(?:~>?)"),o("TILDETRIM",`(\\s*)${i[a.LONETILDE]}\\s+`,!0),t.tildeTrimReplace="$1~",o("TILDE",`^${i[a.LONETILDE]}${i[a.XRANGEPLAIN]}$`),o("TILDELOOSE",`^${i[a.LONETILDE]}${i[a.XRANGEPLAINLOOSE]}$`),o("LONECARET","(?:\\^)"),o("CARETTRIM",`(\\s*)${i[a.LONECARET]}\\s+`,!0),t.caretTrimReplace="$1^",o("CARET",`^${i[a.LONECARET]}${i[a.XRANGEPLAIN]}$`),o("CARETLOOSE",`^${i[a.LONECARET]}${i[a.XRANGEPLAINLOOSE]}$`),o("COMPARATORLOOSE",`^${i[a.GTLT]}\\s*(${i[a.LOOSEPLAIN]})$|^$`),o("COMPARATOR",`^${i[a.GTLT]}\\s*(${i[a.FULLPLAIN]})$|^$`),o("COMPARATORTRIM",`(\\s*)${i[a.GTLT]}\\s*(${i[a.LOOSEPLAIN]}|${i[a.XRANGEPLAIN]})`,!0),t.comparatorTrimReplace="$1$2$3",o("HYPHENRANGE",`^\\s*(${i[a.XRANGEPLAIN]})\\s+-\\s+(${i[a.XRANGEPLAIN]})\\s*$`),o("HYPHENRANGELOOSE",`^\\s*(${i[a.XRANGEPLAINLOOSE]})\\s+-\\s+(${i[a.XRANGEPLAINLOOSE]})\\s*$`),o("STAR","(<|>)?=?\\s*\\*"),o("GTE0","^\\s*>=\\s*0.0.0\\s*$"),o("GTE0PRE","^\\s*>=\\s*0.0.0-0\\s*$")})),XM=/^[0-9]+$/,$M=(e,t)=>{let r=XM.test(e),n=XM.test(t);return r&&n&&(e=+e,t=+t),e===t?0:r&&!n?-1:n&&!r?1:e<t?-1:1},JM={compareIdentifiers:$M,rcompareIdentifiers:(e,t)=>$M(t,e)},{MAX_LENGTH:YM,MAX_SAFE_INTEGER:QM}=HM,{re:ZM,t:eC}=WM,{compareIdentifiers:tC}=JM,rC=class{constructor(e,t){if(t&&"object"==typeof t||(t={loose:!!t,includePrerelease:!1}),e instanceof rC){if(e.loose===!!t.loose&&e.includePrerelease===!!t.includePrerelease)return e;e=e.version}else if("string"!=typeof e)throw new TypeError(`Invalid Version: ${e}`);if(e.length>YM)throw new TypeError(`version is longer than ${YM} characters`);VM("SemVer",e,t),this.options=t,this.loose=!!t.loose,this.includePrerelease=!!t.includePrerelease;let r=e.trim().match(t.loose?ZM[eC.LOOSE]:ZM[eC.FULL]);if(!r)throw new TypeError(`Invalid Version: ${e}`);if(this.raw=e,this.major=+r[1],this.minor=+r[2],this.patch=+r[3],this.major>QM||this.major<0)throw new TypeError("Invalid major version");if(this.minor>QM||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>QM||this.patch<0)throw new TypeError("Invalid patch version");r[4]?this.prerelease=r[4].split(".").map((e=>{if(/^[0-9]+$/.test(e)){let t=+e;if(t>=0&&t<QM)return t}return e})):this.prerelease=[],this.build=r[5]?r[5].split("."):[],this.format()}format(){return this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length&&(this.version+=`-${this.prerelease.join(".")}`),this.version}toString(){return this.version}compare(e){if(VM("SemVer.compare",this.version,this.options,e),!(e instanceof rC)){if("string"==typeof e&&e===this.version)return 0;e=new rC(e,this.options)}return e.version===this.version?0:this.compareMain(e)||this.comparePre(e)}compareMain(e){return e instanceof rC||(e=new rC(e,this.options)),tC(this.major,e.major)||tC(this.minor,e.minor)||tC(this.patch,e.patch)}comparePre(e){if(e instanceof rC||(e=new rC(e,this.options)),this.prerelease.length&&!e.prerelease.length)return-1;if(!this.prerelease.length&&e.prerelease.length)return 1;if(!this.prerelease.length&&!e.prerelease.length)return 0;let t=0;do{let r=this.prerelease[t],n=e.prerelease[t];if(VM("prerelease compare",t,r,n),void 0===r&&void 0===n)return 0;if(void 0===n)return 1;if(void 0===r)return-1;if(r!==n)return tC(r,n)}while(++t)}compareBuild(e){e instanceof rC||(e=new rC(e,this.options));let t=0;do{let r=this.build[t],n=e.build[t];if(VM("prerelease compare",t,r,n),void 0===r&&void 0===n)return 0;if(void 0===n)return 1;if(void 0===r)return-1;if(r!==n)return tC(r,n)}while(++t)}inc(e,t){switch(e){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",t);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",t);break;case"prepatch":this.prerelease.length=0,this.inc("patch",t),this.inc("pre",t);break;case"prerelease":0===this.prerelease.length&&this.inc("patch",t),this.inc("pre",t);break;case"major":0===this.minor&&0===this.patch&&0!==this.prerelease.length||this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case"minor":0===this.patch&&0!==this.prerelease.length||this.minor++,this.patch=0,this.prerelease=[];break;case"patch":0===this.prerelease.length&&this.patch++,this.prerelease=[];break;case"pre":if(0===this.prerelease.length)this.prerelease=[0];else{let e=this.prerelease.length;for(;--e>=0;)"number"==typeof this.prerelease[e]&&(this.prerelease[e]++,e=-2);-1===e&&this.prerelease.push(0)}t&&(this.prerelease[0]===t?isNaN(this.prerelease[1])&&(this.prerelease=[t,0]):this.prerelease=[t,0]);break;default:throw new Error(`invalid increment argument: ${e}`)}return this.format(),this.raw=this.version,this}},nC=(e,t,r)=>new rC(e,r).compare(new rC(t,r)),iC=(e,t,r)=>0===nC(e,t,r),aC=(e,t,r)=>0!==nC(e,t,r),sC=(e,t,r)=>nC(e,t,r)>0,oC=(e,t,r)=>nC(e,t,r)>=0,cC=(e,t,r)=>nC(e,t,r)<0,fC=(e,t,r)=>nC(e,t,r)<=0,uC=(e,t,r,n)=>{switch(t){case"===":return"object"==typeof e&&(e=e.version),"object"==typeof r&&(r=r.version),e===r;case"!==":return"object"==typeof e&&(e=e.version),"object"==typeof r&&(r=r.version),e!==r;case"":case"=":case"==":return iC(e,r,n);case"!=":return aC(e,r,n);case">":return sC(e,r,n);case">=":return oC(e,r,n);case"<":return cC(e,r,n);case"<=":return fC(e,r,n);default:throw new TypeError(`Invalid operator: ${t}`)}},dC=Symbol("SemVer ANY"),lC=class{static get ANY(){return dC}constructor(e,t){if(t&&"object"==typeof t||(t={loose:!!t,includePrerelease:!1}),e instanceof lC){if(e.loose===!!t.loose)return e;e=e.value}VM("comparator",e,t),this.options=t,this.loose=!!t.loose,this.parse(e),this.semver===dC?this.value="":this.value=this.operator+this.semver.version,VM("comp",this)}parse(e){let t=this.options.loose?hC[pC.COMPARATORLOOSE]:hC[pC.COMPARATOR],r=e.match(t);if(!r)throw new TypeError(`Invalid comparator: ${e}`);this.operator=void 0!==r[1]?r[1]:"","="===this.operator&&(this.operator=""),r[2]?this.semver=new rC(r[2],this.options.loose):this.semver=dC}toString(){return this.value}test(e){if(VM("Comparator.test",e,this.options.loose),this.semver===dC||e===dC)return!0;if("string"==typeof e)try{e=new rC(e,this.options)}catch(e){return!1}return uC(e,this.operator,this.semver,this.options)}intersects(e,t){if(!(e instanceof lC))throw new TypeError("a Comparator is required");if(t&&"object"==typeof t||(t={loose:!!t,includePrerelease:!1}),""===this.operator)return""===this.value||new bC(e.value,t).test(this.value);if(""===e.operator)return""===e.value||new bC(this.value,t).test(e.semver);let r=!(">="!==this.operator&&">"!==this.operator||">="!==e.operator&&">"!==e.operator),n=!("<="!==this.operator&&"<"!==this.operator||"<="!==e.operator&&"<"!==e.operator),i=this.semver.version===e.semver.version,a=!(">="!==this.operator&&"<="!==this.operator||">="!==e.operator&&"<="!==e.operator),s=uC(this.semver,"<",e.semver,t)&&(">="===this.operator||">"===this.operator)&&("<="===e.operator||"<"===e.operator),o=uC(this.semver,">",e.semver,t)&&("<="===this.operator||"<"===this.operator)&&(">="===e.operator||">"===e.operator);return r||n||i&&a||s||o}},{re:hC,t:pC}=WM,bC=class{constructor(e,t){if(t&&"object"==typeof t||(t={loose:!!t,includePrerelease:!1}),e instanceof bC)return e.loose===!!t.loose&&e.includePrerelease===!!t.includePrerelease?e:new bC(e.raw,t);if(e instanceof lC)return this.raw=e.value,this.set=[[e]],this.format(),this;if(this.options=t,this.loose=!!t.loose,this.includePrerelease=!!t.includePrerelease,this.raw=e,this.set=e.split(/\s*\|\|\s*/).map((e=>this.parseRange(e.trim()))).filter((e=>e.length)),!this.set.length)throw new TypeError(`Invalid SemVer Range: ${e}`);this.format()}format(){return this.range=this.set.map((e=>e.join(" ").trim())).join("||").trim(),this.range}toString(){return this.range}parseRange(e){let{loose:t}=this.options;e=e.trim();let r=t?gC[mC.HYPHENRANGELOOSE]:gC[mC.HYPHENRANGE];e=e.replace(r,CC(this.options.includePrerelease)),VM("hyphen replace",e),e=e.replace(gC[mC.COMPARATORTRIM],yC),VM("comparator trim",e,gC[mC.COMPARATORTRIM]),e=(e=(e=e.replace(gC[mC.TILDETRIM],vC)).replace(gC[mC.CARETTRIM],wC)).split(/\s+/).join(" ");let n=t?gC[mC.COMPARATORLOOSE]:gC[mC.COMPARATOR];return e.split(" ").map((e=>EC(e,this.options))).join(" ").split(/\s+/).map((e=>MC(e,this.options))).filter(this.options.loose?e=>!!e.match(n):()=>!0).map((e=>new lC(e,this.options)))}intersects(e,t){if(!(e instanceof bC))throw new TypeError("a Range is required");return this.set.some((r=>_C(r,t)&&e.set.some((e=>_C(e,t)&&r.every((r=>e.every((e=>r.intersects(e,t)))))))))}test(e){if(!e)return!1;if("string"==typeof e)try{e=new rC(e,this.options)}catch(e){return!1}for(let t=0;t<this.set.length;t++)if(PC(this.set[t],e,this.options))return!0;return!1}},{re:gC,t:mC,comparatorTrimReplace:yC,tildeTrimReplace:vC,caretTrimReplace:wC}=WM,_C=(e,t)=>{let r=!0,n=e.slice(),i=n.pop();for(;r&&n.length;)r=n.every((e=>i.intersects(e,t))),i=n.pop();return r},EC=(e,t)=>(VM("comp",e,t),e=xC(e,t),VM("caret",e),e=SC(e,t),VM("tildes",e),e=RC(e,t),VM("xrange",e),e=IC(e,t),VM("stars",e),e),AC=e=>!e||"x"===e.toLowerCase()||"*"===e,SC=(e,t)=>e.trim().split(/\s+/).map((e=>kC(e,t))).join(" "),kC=(e,t)=>{let r=t.loose?gC[mC.TILDELOOSE]:gC[mC.TILDE];return e.replace(r,((t,r,n,i,a)=>{let s;return VM("tilde",e,t,r,n,i,a),AC(r)?s="":AC(n)?s=`>=${r}.0.0 <${+r+1}.0.0-0`:AC(i)?s=`>=${r}.${n}.0 <${r}.${+n+1}.0-0`:a?(VM("replaceTilde pr",a),s=`>=${r}.${n}.${i}-${a} <${r}.${+n+1}.0-0`):s=`>=${r}.${n}.${i} <${r}.${+n+1}.0-0`,VM("tilde return",s),s}))},xC=(e,t)=>e.trim().split(/\s+/).map((e=>TC(e,t))).join(" "),TC=(e,t)=>{VM("caret",e,t);let r=t.loose?gC[mC.CARETLOOSE]:gC[mC.CARET],n=t.includePrerelease?"-0":"";return e.replace(r,((t,r,i,a,s)=>{let o;return VM("caret",e,t,r,i,a,s),AC(r)?o="":AC(i)?o=`>=${r}.0.0${n} <${+r+1}.0.0-0`:AC(a)?o="0"===r?`>=${r}.${i}.0${n} <${r}.${+i+1}.0-0`:`>=${r}.${i}.0${n} <${+r+1}.0.0-0`:s?(VM("replaceCaret pr",s),o="0"===r?"0"===i?`>=${r}.${i}.${a}-${s} <${r}.${i}.${+a+1}-0`:`>=${r}.${i}.${a}-${s} <${r}.${+i+1}.0-0`:`>=${r}.${i}.${a}-${s} <${+r+1}.0.0-0`):(VM("no pr"),o="0"===r?"0"===i?`>=${r}.${i}.${a}${n} <${r}.${i}.${+a+1}-0`:`>=${r}.${i}.${a}${n} <${r}.${+i+1}.0-0`:`>=${r}.${i}.${a} <${+r+1}.0.0-0`),VM("caret return",o),o}))},RC=(e,t)=>(VM("replaceXRanges",e,t),e.split(/\s+/).map((e=>OC(e,t))).join(" ")),OC=(e,t)=>{e=e.trim();let r=t.loose?gC[mC.XRANGELOOSE]:gC[mC.XRANGE];return e.replace(r,((r,n,i,a,s,o)=>{VM("xRange",e,r,n,i,a,s,o);let c=AC(i),f=c||AC(a),u=f||AC(s),d=u;return"="===n&&d&&(n=""),o=t.includePrerelease?"-0":"",c?r=">"===n||"<"===n?"<0.0.0-0":"*":n&&d?(f&&(a=0),s=0,">"===n?(n=">=",f?(i=+i+1,a=0,s=0):(a=+a+1,s=0)):"<="===n&&(n="<",f?i=+i+1:a=+a+1),"<"===n&&(o="-0"),r=`${n+i}.${a}.${s}${o}`):f?r=`>=${i}.0.0${o} <${+i+1}.0.0-0`:u&&(r=`>=${i}.${a}.0${o} <${i}.${+a+1}.0-0`),VM("xRange return",r),r}))},IC=(e,t)=>(VM("replaceStars",e,t),e.trim().replace(gC[mC.STAR],"")),MC=(e,t)=>(VM("replaceGTE0",e,t),e.trim().replace(gC[t.includePrerelease?mC.GTE0PRE:mC.GTE0],"")),CC=e=>(t,r,n,i,a,s,o,c,f,u,d,l,h)=>`${r=AC(n)?"":AC(i)?`>=${n}.0.0${e?"-0":""}`:AC(a)?`>=${n}.${i}.0${e?"-0":""}`:s?`>=${r}`:`>=${r}${e?"-0":""}`} ${c=AC(f)?"":AC(u)?`<${+f+1}.0.0-0`:AC(d)?`<${f}.${+u+1}.0-0`:l?`<=${f}.${u}.${d}-${l}`:e?`<${f}.${u}.${+d+1}-0`:`<=${c}`}`.trim(),PC=(e,t,r)=>{for(let r=0;r<e.length;r++)if(!e[r].test(t))return!1;if(t.prerelease.length&&!r.includePrerelease){for(let r=0;r<e.length;r++)if(VM(e[r].semver),e[r].semver!==lC.ANY&&e[r].semver.prerelease.length>0){let n=e[r].semver;if(n.major===t.major&&n.minor===t.minor&&n.patch===t.patch)return!0}return!1}return!0},NC=(e,t,r)=>{try{t=new bC(t,r)}catch(e){return!1}return t.test(e)},{MAX_LENGTH:BC}=HM,{re:UC,t:LC}=WM,jC=(e,t)=>{if(t&&"object"==typeof t||(t={loose:!!t,includePrerelease:!1}),e instanceof rC)return e;if("string"!=typeof e||e.length>BC||!(t.loose?UC[LC.LOOSE]:UC[LC.FULL]).test(e))return null;try{return new rC(e,t)}catch(e){return null}},{re:DC,t:FC}=WM,qC=(e,t)=>{if(e instanceof rC)return e;if("number"==typeof e&&(e=String(e)),"string"!=typeof e)return null;let r=null;if((t=t||{}).rtl){let t;for(;(t=DC[FC.COERCERTL].exec(e))&&(!r||r.index+r[0].length!==e.length);)r&&t.index+t[0].length===r.index+r[0].length||(r=t),DC[FC.COERCERTL].lastIndex=t.index+t[1].length+t[2].length;DC[FC.COERCERTL].lastIndex=-1}else r=e.match(DC[FC.COERCE]);return null===r?null:jC(`${r[2]}.${r[3]||"0"}.${r[4]||"0"}`,t)};function zC(e){return String.fromCharCode(parseInt(e.slice(1),16))}function KC(e){return`%${`00${e.charCodeAt(0).toString(16)}`.slice(-2)}`}function HC(e){return function(e){return btoa(encodeURIComponent(e).replace(/%[0-9A-F]{2}/g,zC))}(JSON.stringify(e))}function GC(e){return JSON.parse(function(e){return decodeURIComponent(Array.from(atob(e),KC).join(""))}(e))}function VC(e){return void 0===e}function WC(e){return function(e){return null===e}(e)||VC(e)}function XC(e){if(!e)return!0;for(let t in e)if(Object.hasOwnProperty.call(e,t))return!1;return!0}var $C={};var JC={"magic-sdk":"magic-sdk","@magic-sdk/react-native":"magic-sdk-rn","@magic-sdk/react-native-bare":"magic-sdk-rn-bare","@magic-sdk/react-native-expo":"magic-sdk-rn-expo"},YC=class extends Error{constructor(e,t){super(`Magic SDK Error: [${e}] ${t}`),this.code=e,this.rawMessage=t,this.__proto__=Error,Object.setPrototypeOf(this,YC.prototype)}},QC=class extends Error{constructor(e){super(),this.__proto__=Error;let t=Number(null==e?void 0:e.code);this.rawMessage=(null==e?void 0:e.message)||"Internal error",this.code=function(e){return!WC(e)&&"number"==typeof e&&Object.values(kM).includes(e)}(t)?t:kM.InternalError,this.message=`Magic RPC Error: [${this.code}] ${this.rawMessage}`,this.data=(null==e?void 0:e.data)||void 0,Object.setPrototypeOf(this,QC.prototype)}},ZC=class{constructor(e,t){this.code=e,this.rawMessage=t,this.message=`Magic SDK Warning: [${e}] ${t}`}log(){console.warn(this.message)}},eP=class extends Error{constructor(e,t,r,n){super(`Magic Extension Error (${e.name}): [${t}] ${r}`),this.code=t,this.rawMessage=r,this.data=n,this.__proto__=Error,Object.setPrototypeOf(this,eP.prototype)}},tP=class{constructor(e,t,r){this.code=t,this.rawMessage=r,this.message=`Magic Extension Warning (${e.name}): [${t}] ${r}`}log(){console.warn(this.message)}};function rP(){return new YC(AM.MissingApiKey,"Please provide an API key that you acquired from the Magic developer dashboard.")}function nP(){return new YC(AM.MalformedResponse,"Response from the Magic iframe is malformed.")}function iP(e){return new YC(AM.ExtensionNotInitialized,`Extensions must be initialized with a Magic SDK instance before \`Extension.${e}\` can be accessed. Do not invoke \`Extension.${e}\` inside an extension constructor.`)}function aP(e){let t=`Some extensions are incompatible with \`${$C.sdkName}@${$C.version}\`:`;return e.filter((e=>void 0!==e.compat&&null!==e.compat)).forEach((e=>{let r=e.compat[$C.sdkName];"string"==typeof r?t+=`\n - Extension \`${e.name}\` supports version(s) \`${r}\``:r||(t+=`\n - Extension \`${e.name}\` does not support ${$C.platform} environments.`)})),new YC(AM.IncompatibleExtensions,t)}function sP(e){return new YC(AM.InvalidArgument,`Invalid ${(e=>{let t=e+1,r=t%10,n=t%100;return 1===r&&11!==n?`${t}st`:2===r&&12!==n?`${t}nd`:3===r&&13!==n?`${t}rd`:`${t}th`})(e.argument)} argument given to \`${e.procedure}\`.\n Expected: \`${e.expected}\`\n Received: \`${e.received}\``)}function oP(){return new ZC(SM.ReactNativeEndpointConfiguration,`CUSTOM DOMAINS ARE NOT SUPPORTED WHEN USING MAGIC SDK WITH REACT NATIVE! The \`endpoint\` parameter SHOULD NOT be provided. The Magic \`<iframe>\` is automatically wrapped by a WebView pointed at \`${$C.defaultEndpoint}\`. Changing this default behavior will lead to unexpected results and potentially security-threatening bugs.`)}var cP=function*(){let e=0;for(;;)e<Number.MAX_SAFE_INTEGER?yield++e:e=0}();function fP(){return cP.next().value}var uP=Symbol("Payload pre-processed by Magic SDK");function dP(e){return Object.defineProperty(e,uP,{value:!0,enumerable:!1}),e}function lP(e){var t,r,n;return function(e){return!!e[uP]}(e)||(e.jsonrpc=null!=(t=e.jsonrpc)?t:"2.0",e.id=fP(),e.method=null!=(r=e.method)?r:"noop",e.params=null!=(n=e.params)?n:[],dP(e)),e}function hP(e,t=[]){return dP({params:t,method:e,jsonrpc:"2.0",id:fP()})}var pP=class{constructor(e){e instanceof pP?(this._jsonrpc=e.payload.jsonrpc,this._id=e.payload.id,this._result=e.payload.result,this._error=e.payload.error):function(e){return!WC(e)&&!(VC(e.jsonrpc)||VC(e.id)||VC(e.result)&&VC(e.error))}(e)?(this._jsonrpc=e.jsonrpc,this._id=e.id,this._result=e.result,this._error=e.error):(this._jsonrpc=e.jsonrpc,this._id=e.id,this._result=void 0,this._error=void 0)}applyError(e){return this._error=e,this}applyResult(e){return this._result=e,this}get hasError(){return void 0!==this._error&&null!==this._error}get hasResult(){return void 0!==this._result}get payload(){return{jsonrpc:this._jsonrpc,id:this._id,result:this._result,error:this._error}}},bP=((e,t,r)=>(r=null!=e?IM(LM(e)):{},((e,t,r,n)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let i of BM(t))!jM.call(e,i)&&i!==r&&MM(e,i,{get:()=>t[i],enumerable:!(n=PM(t,i))||n.enumerable});return e})(!t&&e&&e.__esModule?r:MM(r,"default",{value:e,enumerable:!0}),e)))(KM()),gP=class extends bP.default{};function mP(){let e=new gP;return{emitter:e,createChainingEmitterMethod:(t,r)=>(...n)=>(e[t].apply(e,n),r),createBoundEmitterMethod:t=>(...r)=>e[t].apply(e,r)}}var yP=Symbol("isPromiEvent");function vP(e){return!!e[yP]}function wP(e){let t=_P(e),{createBoundEmitterMethod:r,createChainingEmitterMethod:n}=mP(),i=Symbol("Promise.then"),a=Symbol("Promise.catch"),s=Symbol("Promise.finally"),o=(e,t)=>(...r)=>{let n=t[e].apply(t,r);return c(n)},c=e=>Object.assign(e,{[yP]:!0,[i]:e[i]||e.then,[a]:e[a]||e.catch,[s]:e[s]||e.finally,then:o(i,e),catch:o(a,e),finally:o(s,e),on:n("on",e),once:n("once",e),addListener:n("addListener",e),off:n("off",e),removeListener:n("removeListener",e),removeAllListeners:n("removeAllListeners",e),emit:r("emit"),eventNames:r("eventNames"),listeners:r("listeners"),listenerCount:r("listenerCount")}),f=c(t.then((e=>(f.emit("done",e),f.emit("settled"),e)),(e=>{throw f.emit("error",e),f.emit("settled"),e})));return f}function _P(e){return new Promise(((t,r)=>{let n=e(t,r);Promise.resolve(n).catch(r)}))}var EP,AP=class{constructor(e){this.sdk=e}get overlay(){return this.sdk.overlay}request(e){let t=this.overlay.post(RM.MAGIC_HANDLE_REQUEST,lP(e)),r=wP(((e,r)=>{t.then((t=>{if(n(),t.hasError)r(new QC(t.payload.error));else{if(!t.hasResult)throw nP();e(t.payload.result)}})).catch((e=>{n(),r(e)}))})),n=this.overlay.on(TM.MAGIC_HANDLE_EVENT,(t=>{var n;let{response:i}=t.data;if(i.id===e.id&&(null==(n=i.result)?void 0:n.event)){let{event:e,params:t=[]}=i.result;r.emit(e,...t)}}));return r}createIntermediaryEvent(e,t){return r=>{let n=hP(xM.IntermediaryEvent,[{payloadId:t,eventType:e,args:r}]);this.request(n)}}},SP=class extends AP{loginWithMagicLink(e){let{email:t,showUI:r=!0,redirectURI:n}=e,i=hP(this.sdk.testMode?xM.LoginWithMagicLinkTestMode:xM.LoginWithMagicLink,[{email:t,showUI:r,redirectURI:n}]);return this.request(i)}loginWithSMS(e){let{phoneNumber:t}=e,r=hP(this.sdk.testMode?xM.LoginWithSmsTestMode:xM.LoginWithSms,[{phoneNumber:t,showUI:!0}]);return this.request(r)}loginWithEmailOTP(e){let{email:t,showUI:r}=e,n=hP(this.sdk.testMode?xM.LoginWithEmailOTPTestMode:xM.LoginWithEmailOTP,[{email:t,showUI:r}]);if(!r){let e=this.request(n);return e&&e.on("otp-input-sent",(e=>{this.createIntermediaryEvent("verify-email-otp",n.id)(e)})),e}return this.request(n)}loginWithCredential(e){let t=null!=e?e:"";if(!e&&"web"===$C.platform){t=window.location.search;let e=window.location.origin+window.location.pathname;window.history.replaceState(null,"",e)}let r=hP(this.sdk.testMode?xM.LoginWithCredentialTestMode:xM.LoginWithCredential,[t]);return this.request(r)}},kP={};function xP(e){return(...t)=>zM(this,null,(function*(){return EP||(EP=yield $C.configureStorage()),yield EP.ready(),EP[e](...t)}))}((e,t)=>{for(var r in t)MM(e,r,{get:t[r],enumerable:!0})})(kP,{clear:()=>IP,getItem:()=>TP,iterate:()=>NP,key:()=>CP,keys:()=>PP,length:()=>MP,removeItem:()=>OP,setItem:()=>RP});var TP=xP("getItem"),RP=xP("setItem"),OP=xP("removeItem"),IP=xP("clear"),MP=xP("length"),CP=xP("key"),PP=xP("keys"),NP=xP("iterate");function BP(){let e=window.crypto.getRandomValues(new Uint8Array(16));e[6]=15&e[6]|64,e[8]=191&e[8]|128;let t="";return t+=e[0].toString(16),t+=e[1].toString(16),t+=e[2].toString(16),t+=e[3].toString(16),t+="-",t+=e[4].toString(16),t+=e[5].toString(16),t+="-",t+=e[6].toString(16),t+=e[7].toString(16),t+="-",t+=e[8].toString(16),t+=e[9].toString(16),t+="-",t+=e[10].toString(16),t+=e[11].toString(16),t+=e[12].toString(16),t+=e[13].toString(16),t+=e[14].toString(16),t+=e[15].toString(16),t}var UP="STORE_KEY_PRIVATE_KEY",LP="STORE_KEY_PUBLIC_JWK",jP="ECDSA",DP="P-256",FP={name:jP,namedCurve:DP},qP={name:jP,namedCurve:DP};function zP(){OP(LP),OP(UP)}function KP(){return zM(this,null,(function*(){let e=yield function(){return zM(this,null,(function*(){if(function(){let e="undefined"!=typeof window&&!!window.crypto,t=e&&!!window.crypto.subtle;return e&&t}())return(yield TP(LP))||(yield function(){return zM(this,null,(function*(){let e=null,{subtle:t}=window.crypto,r=yield t.generateKey(FP,!0,["sign"]),n=yield t.exportKey("jwk",r.privateKey);e=yield t.exportKey("jwk",r.publicKey);let i=yield t.importKey("jwk",n,qP,!1,["sign"]);yield RP(UP,i),yield RP(LP,e)}))}()),TP(LP);console.info("webcrypto is not supported")}))}();if(!e)return void console.info("unable to create public key or webcrypto is unsupported");let{subtle:t}=window.crypto,r=yield TP(UP);if(!r||!t)return void console.info("unable to find private key or webcrypto unsupported");let n={iat:Math.floor((new Date).getTime()/1e3),jti:BP()},i={typ:"dpop+jwt",alg:"ES256",jwk:e},a=HP(JSON.stringify(i)),s=HP(JSON.stringify(n)),o=function(e){return(new TextEncoder).encode(e)}(`${a}.${s}`),c={name:jP,hash:{name:"SHA-256"}},f=function(e){let t="";return e.forEach((e=>{t+=String.fromCharCode(e)})),GP(t)}(new Uint8Array(yield t.sign(c,r,o)));return`${a}.${s}.${f}`}))}function HP(e){return GP(function(e){return encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,((e,t)=>String.fromCharCode(parseInt(t,16))))}(e))}function GP(e){return btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+/g,"")}var VP=class extends AP{getIdToken(e){let t=hP(this.sdk.testMode?xM.GetIdTokenTestMode:xM.GetIdToken,[e]);return this.request(t)}generateIdToken(e){let t=hP(this.sdk.testMode?xM.GenerateIdTokenTestMode:xM.GenerateIdToken,[e]);return this.request(t)}getMetadata(){let e=hP(this.sdk.testMode?xM.GetMetadataTestMode:xM.GetMetadata);return this.request(e)}updateEmail(e){let{email:t,showUI:r=!0}=e,n=hP(this.sdk.testMode?xM.UpdateEmailTestMode:xM.UpdateEmail,[{email:t,showUI:r}]);return this.request(n)}isLoggedIn(){let e=hP(this.sdk.testMode?xM.IsLoggedInTestMode:xM.IsLoggedIn);return this.request(e)}logout(){zP();let e=hP(this.sdk.testMode?xM.LogoutTestMode:xM.Logout);return this.request(e)}showSettings(){let e=hP(this.sdk.testMode?xM.UserSettingsTestMode:xM.UserSettings);return this.request(e)}updatePhoneNumber(){let e=hP(this.sdk.testMode?xM.UpdatePhoneNumberTestMode:xM.UpdatePhoneNumber);return this.request(e)}recoverAccount(e){let t=hP(this.sdk.testMode?xM.RecoverAccountTestMode:xM.RecoverAccount,[e]);return this.request(t)}},WP=class extends AP{connectWithUI(){let e=hP(xM.RequestAccounts);return this.request(e)}showUI(){let e=hP(xM.ShowUI);return this.request(e)}getInfo(){let e=hP(xM.GetInfo);return this.request(e)}requestUserInfoWithUI(e){let t=hP(xM.RequestUserInfoWithUI,e?[e]:[]);return this.request(t)}disconnect(){zP();let e=hP(xM.Disconnect);return this.request(e)}},{createBoundEmitterMethod:XP,createChainingEmitterMethod:$P}=mP(),JP=class extends AP{constructor(){super(...arguments),this.isMagic=!0,this.on=$P("on",this),this.once=$P("once",this),this.addListener=$P("addListener",this),this.off=$P("off",this),this.removeListener=$P("removeListener",this),this.removeAllListeners=$P("removeAllListeners",this),this.emit=XP("emit"),this.eventNames=XP("eventNames"),this.listeners=XP("listeners"),this.listenerCount=XP("listenerCount")}sendAsync(e,t){if(!t)throw sP({procedure:"Magic.rpcProvider.sendAsync",argument:1,expected:"function",received:null===t?"null":typeof t});if(Array.isArray(e))this.overlay.post(RM.MAGIC_HANDLE_REQUEST,e.map((e=>{let t=lP(e);return this.prefixPayloadMethodForTestMode(t),t}))).then((e=>{t(null,e.map((e=>((e,t)=>CM(e,NM(t)))(qM({},e.payload),{error:e.hasError?new QC(e.payload.error):null}))))}));else{let r=lP(e);this.prefixPayloadMethodForTestMode(r),this.overlay.post(RM.MAGIC_HANDLE_REQUEST,r).then((e=>{t(e.hasError?new QC(e.payload.error):null,e.payload)}))}}send(e,t){if("string"==typeof e){let r=hP(e,Array.isArray(t)?t:[]);return this.request(r)}if(Array.isArray(e)||t)return void this.sendAsync(e,t);let r=new ZC(SM.SyncWeb3Method,"Non-async web3 methods are deprecated in web3 > 1.0 and are not supported by the Magic web3 provider. Please use an async method instead.");return r.log(),new pP(e).applyError({code:-32603,message:r.rawMessage}).payload}enable(){let e=hP("eth_accounts");return this.request(e)}request(e){return this.prefixPayloadMethodForTestMode(e),super.request(e)}prefixPayloadMethodForTestMode(e){this.sdk.testMode&&(e.method=`testMode/eth/${e.method}`)}};function YP(e,t){return t?new URL(e,t):new URL(e)}var QP=["request","overlay","sdk"];function ZP(e){let t=Object.getPrototypeOf(e),r=[t];for(;t!==AP.prototype;)t=Object.getPrototypeOf(t),r.push(t);return r}var eN=class extends AP{constructor(){super(void 0),this.__sdk_access_field_descriptors__=new Map,this.__is_initialized__=!1,this.utils={createPromiEvent:wP,isPromiEvent:vP,encodeJSON:HC,decodeJSON:GC,createJsonRpcRequestPayload:hP,standardizeJsonRpcRequestPayload:lP,storage:kP};let e=[this,...ZP(this)];QP.forEach((t=>{let r=e.map((e=>Object.getOwnPropertyDescriptor(e,t))),n=r.findIndex((e=>!!e)),i=n>0,a=r[n];a&&(this.__sdk_access_field_descriptors__.set(t,{descriptor:a,isPrototypeField:i}),Object.defineProperty(this,t,{configurable:!0,get:()=>{throw iP(t)}}))}))}init(e){this.__is_initialized__||(QP.forEach((e=>{if(this.__sdk_access_field_descriptors__.has(e)){let{descriptor:t,isPrototypeField:r}=this.__sdk_access_field_descriptors__.get(e);r?delete this[e]:Object.defineProperty(this,e,t)}})),this.sdk=e,this.__is_initialized__=!0)}createDeprecationWarning(e){let{method:t,removalVersion:r,useInstead:n}=e;return new tP(this,"DEPRECATION_NOTICE",`\`${t}\` will be removed from this Extension in version \`${r}\`.${n?` Use \`${n}\` instead.`:""}`)}createWarning(e,t){return new tP(this,e,t)}createError(e,t,r){return new eP(this,e,t,r)}},tN=class extends eN{};tN.Internal=class extends eN{},tN.Anonymous="anonymous extension";var rN=class extends AP{purchase(e){let t=hP(xM.NFTPurchase,[e]);return this.request(t)}};function nN(e){return!e.compat||null==e.compat[$C.sdkName]||("string"==typeof e.compat[$C.sdkName]?NC(qC($C.version),e.compat[$C.sdkName]):!!e.compat[$C.sdkName])}function iN(e){var t;let r=null!=(t=null==e?void 0:e.extensions)?t:[],n={},i=[];if(Array.isArray(r)?r.forEach((e=>{nN(e)?(e.init(this),(e.name||e.name!==tN.Anonymous)&&(this[e.name]=e),e instanceof tN.Internal&&(XC(e.config)||(n[e.name]=e.config))):i.push(e)})):Object.keys(r).forEach((e=>{if(nN(r[e])){r[e].init(this);let t=r[e];this[e]=t,t instanceof tN.Internal&&(XC(t.config)||(n[r[e].name]=t.config))}else i.push(r[e])})),i.length)throw aP(i);return n}var aN=class{constructor(e,t){var r;if(this.apiKey=e,!e)throw rP();"react-native"===$C.platform&&(null==t?void 0:t.endpoint)&&oP().log();let{defaultEndpoint:n,version:i}=$C;this.testMode=!(null==t||!t.testMode),this.endpoint=YP(null!=(r=null==t?void 0:t.endpoint)?r:n).origin,this.auth=new SP(this),this.user=new VP(this),this.wallet=new WP(this),this.nft=new rN(this),this.rpcProvider=new JP(this);let a=iN.call(this,t);this.parameters=HC(qM({API_KEY:this.apiKey,DOMAIN_ORIGIN:window.location?window.location.origin:"",ETH_NETWORK:null==t?void 0:t.network,host:YP(this.endpoint).host,sdk:JC[$C.sdkName],version:i,ext:XC(a)?void 0:a,locale:(null==t?void 0:t.locale)||"en_US"},$C.bundleId?{bundleId:$C.bundleId}:{}))}get overlay(){if(!aN.__overlays__.has(this.parameters)){let e=new $C.ViewController(this.endpoint,this.parameters);e.init(),aN.__overlays__.set(this.parameters,e)}return aN.__overlays__.get(this.parameters)}preload(){return zM(this,null,(function*(){yield this.overlay.ready}))}},sN=aN;function oN(e,t){var r;let n=null==(r=t.data.response)?void 0:r.id,i=function(e,t){return t&&Array.isArray(e)?e.find((e=>e.id===t)):e}(e,n);if(n&&i){return{id:n,response:new pP(i).applyResult(t.data.response.result).applyError(t.data.response.error)}}return{}}sN.__overlays__=new Map;var cN=class{constructor(e,t){this.endpoint=e,this.parameters=t,this.messageHandlers=new Set,this.ready=this.waitForReady(),this.listen()}post(e,t){return zM(this,null,(function*(){return _P((r=>zM(this,null,(function*(){yield this.ready;let n=[],i=Array.isArray(t)?t.map((e=>e.id)):[],a=yield function(e,t){return zM(this,null,(function*(){let r,n=yield TP("rt");if("web"===$C.platform)try{r=yield KP()}catch(e){console.error("webcrypto error",e)}return r?n?{msgType:e,payload:t,jwt:r,rt:n}:{msgType:e,payload:t,jwt:r}:{msgType:e,payload:t}}))}(`${e}-${this.parameters}`,t);yield this._post(a);let s=this.on(TM.MAGIC_HANDLE_RESPONSE,(e=>a=>{let{id:s,response:o}=oN(t,a);(function(e){zM(this,null,(function*(){!e.data.rt||(yield RP("rt",e.data.rt))}))})(a),s&&o&&Array.isArray(t)&&i.includes(s)?(n.push(o),n.length===t.length&&(e(),r(n))):s&&o&&!Array.isArray(t)&&s===t.id&&(e(),r(o))})((()=>s())))}))))}))}on(e,t){let r=t.bind(window),n=t=>{t.data.msgType===`${e}-${this.parameters}`&&r(t)};return this.messageHandlers.add(n),()=>this.messageHandlers.delete(n)}waitForReady(){return new Promise((e=>{this.on(TM.MAGIC_OVERLAY_READY,(()=>e()))}))}listen(){this.on(TM.MAGIC_HIDE_OVERLAY,(()=>{this.hideOverlay()})),this.on(TM.MAGIC_SHOW_OVERLAY,(()=>{this.showOverlay()}))}},fN=Object.create,uN=Object.defineProperty,dN=Object.getOwnPropertyDescriptor,lN=Object.getOwnPropertyNames,hN=Object.getPrototypeOf,pN=Object.prototype.hasOwnProperty,bN=(e=>"undefined"!=typeof require?require:"undefined"!=typeof Proxy?new Proxy(e,{get:(e,t)=>("undefined"!=typeof require?require:e)[t]}):e)((function(e){if("undefined"!=typeof require)return require.apply(this,arguments);throw new Error('Dynamic require of "'+e+'" is not supported')})),gN=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),mN=(e,t,r)=>(r=null!=e?fN(hN(e)):{},((e,t,r,n)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let i of lN(t))!pN.call(e,i)&&i!==r&&uN(e,i,{get:()=>t[i],enumerable:!(n=dN(t,i))||n.enumerable});return e})(!t&&e&&e.__esModule?r:uN(r,"default",{value:e,enumerable:!0}),e)),yN=(e,t,r)=>new Promise(((n,i)=>{var a=e=>{try{o(r.next(e))}catch(e){i(e)}},s=e=>{try{o(r.throw(e))}catch(e){i(e)}},o=e=>e.done?n(e.value):Promise.resolve(e.value).then(a,s);o((r=r.apply(e,t)).next())})),vN=gN(((e,t)=>{!function(r){if("object"==typeof e&&typeof t<"u")t.exports=r();else if("function"==typeof define&&define.amd)define([],r);else{(typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:this).localforage=r()}}((function(){return function e(t,r,n){function i(s,o){if(!r[s]){if(!t[s]){var c="function"==typeof bN&&bN;if(!o&&c)return c(s,!0);if(a)return a(s,!0);var f=new Error("Cannot find module '"+s+"'");throw f.code="MODULE_NOT_FOUND",f}var u=r[s]={exports:{}};t[s][0].call(u.exports,(function(e){return i(t[s][1][e]||e)}),u,u.exports,e,t,r,n)}return r[s].exports}for(var a="function"==typeof bN&&bN,s=0;s<n.length;s++)i(n[s]);return i}({1:[function(e,t,r){(function(e){var r,n=e.MutationObserver||e.WebKitMutationObserver;if(n){var i=0,a=new n(u),s=e.document.createTextNode("");a.observe(s,{characterData:!0}),r=function(){s.data=i=++i%2}}else if(!e.setImmediate&&typeof e.MessageChannel<"u"){var o=new e.MessageChannel;o.port1.onmessage=u,r=function(){o.port2.postMessage(0)}}else r="document"in e&&"onreadystatechange"in e.document.createElement("script")?function(){var t=e.document.createElement("script");t.onreadystatechange=function(){u(),t.onreadystatechange=null,t.parentNode.removeChild(t),t=null},e.document.documentElement.appendChild(t)}:function(){setTimeout(u,0)};var c,f=[];function u(){c=!0;for(var e,t,r=f.length;r;){for(t=f,f=[],e=-1;++e<r;)t[e]();r=f.length}c=!1}t.exports=function(e){1===f.push(e)&&!c&&r()}}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{}],2:[function(e,t,r){var n=e(1);function i(){}var a={},s=["REJECTED"],o=["FULFILLED"],c=["PENDING"];function f(e){if("function"!=typeof e)throw new TypeError("resolver must be a function");this.state=c,this.queue=[],this.outcome=void 0,e!==i&&h(this,e)}function u(e,t,r){this.promise=e,"function"==typeof t&&(this.onFulfilled=t,this.callFulfilled=this.otherCallFulfilled),"function"==typeof r&&(this.onRejected=r,this.callRejected=this.otherCallRejected)}function d(e,t,r){n((function(){var n;try{n=t(r)}catch(t){return a.reject(e,t)}n===e?a.reject(e,new TypeError("Cannot resolve promise with itself")):a.resolve(e,n)}))}function l(e){var t=e&&e.then;if(e&&("object"==typeof e||"function"==typeof e)&&"function"==typeof t)return function(){t.apply(e,arguments)}}function h(e,t){var r=!1;function n(t){r||(r=!0,a.reject(e,t))}function i(t){r||(r=!0,a.resolve(e,t))}var s=p((function(){t(i,n)}));"error"===s.status&&n(s.value)}function p(e,t){var r={};try{r.value=e(t),r.status="success"}catch(e){r.status="error",r.value=e}return r}t.exports=f,f.prototype.catch=function(e){return this.then(null,e)},f.prototype.then=function(e,t){if("function"!=typeof e&&this.state===o||"function"!=typeof t&&this.state===s)return this;var r=new this.constructor(i);this.state!==c?d(r,this.state===o?e:t,this.outcome):this.queue.push(new u(r,e,t));return r},u.prototype.callFulfilled=function(e){a.resolve(this.promise,e)},u.prototype.otherCallFulfilled=function(e){d(this.promise,this.onFulfilled,e)},u.prototype.callRejected=function(e){a.reject(this.promise,e)},u.prototype.otherCallRejected=function(e){d(this.promise,this.onRejected,e)},a.resolve=function(e,t){var r=p(l,t);if("error"===r.status)return a.reject(e,r.value);var n=r.value;if(n)h(e,n);else{e.state=o,e.outcome=t;for(var i=-1,s=e.queue.length;++i<s;)e.queue[i].callFulfilled(t)}return e},a.reject=function(e,t){e.state=s,e.outcome=t;for(var r=-1,n=e.queue.length;++r<n;)e.queue[r].callRejected(t);return e},f.resolve=function(e){return e instanceof this?e:a.resolve(new this(i),e)},f.reject=function(e){var t=new this(i);return a.reject(t,e)},f.all=function(e){var t=this;if("[object Array]"!==Object.prototype.toString.call(e))return this.reject(new TypeError("must be an array"));var r=e.length,n=!1;if(!r)return this.resolve([]);for(var s=new Array(r),o=0,c=-1,f=new this(i);++c<r;)u(e[c],c);return f;function u(e,i){t.resolve(e).then((function(e){s[i]=e,++o===r&&!n&&(n=!0,a.resolve(f,s))}),(function(e){n||(n=!0,a.reject(f,e))}))}},f.race=function(e){var t=this;if("[object Array]"!==Object.prototype.toString.call(e))return this.reject(new TypeError("must be an array"));var r=e.length,n=!1;if(!r)return this.resolve([]);for(var s=-1,o=new this(i);++s<r;)c(e[s]);return o;function c(e){t.resolve(e).then((function(e){n||(n=!0,a.resolve(o,e))}),(function(e){n||(n=!0,a.reject(o,e))}))}}},{1:1}],3:[function(e,t,r){(function(t){"function"!=typeof t.Promise&&(t.Promise=e(2))}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{2:2}],4:[function(e,t,r){var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};var i=function(){try{if(typeof indexedDB<"u")return indexedDB;if(typeof webkitIndexedDB<"u")return webkitIndexedDB;if(typeof mozIndexedDB<"u")return mozIndexedDB;if(typeof OIndexedDB<"u")return OIndexedDB;if(typeof msIndexedDB<"u")return msIndexedDB}catch{return}}();function a(e,t){e=e||[],t=t||{};try{return new Blob(e,t)}catch(i){if("TypeError"!==i.name)throw i;for(var r=new(typeof BlobBuilder<"u"?BlobBuilder:typeof MSBlobBuilder<"u"?MSBlobBuilder:typeof MozBlobBuilder<"u"?MozBlobBuilder:WebKitBlobBuilder),n=0;n<e.length;n+=1)r.append(e[n]);return r.getBlob(t.type)}}typeof Promise>"u"&&e(3);var s=Promise;function o(e,t){t&&e.then((function(e){t(null,e)}),(function(e){t(e)}))}function c(e,t,r){"function"==typeof t&&e.then(t),"function"==typeof r&&e.catch(r)}function f(e){return"string"!=typeof e&&(console.warn(e+" used as a key, but it is not a string."),e=String(e)),e}function u(){if(arguments.length&&"function"==typeof arguments[arguments.length-1])return arguments[arguments.length-1]}var d="local-forage-detect-blob-support",l=void 0,h={},p=Object.prototype.toString,b="readonly",g="readwrite";function m(e){return"boolean"==typeof l?s.resolve(l):function(e){return new s((function(t){var r=e.transaction(d,g),n=a([""]);r.objectStore(d).put(n,"key"),r.onabort=function(e){e.preventDefault(),e.stopPropagation(),t(!1)},r.oncomplete=function(){var e=navigator.userAgent.match(/Chrome\/(\d+)/),r=navigator.userAgent.match(/Edge\//);t(r||!e||parseInt(e[1],10)>=43)}})).catch((function(){return!1}))}(e).then((function(e){return l=e}))}function y(e){var t=h[e.name],r={};r.promise=new s((function(e,t){r.resolve=e,r.reject=t})),t.deferredOperations.push(r),t.dbReady?t.dbReady=t.dbReady.then((function(){return r.promise})):t.dbReady=r.promise}function v(e){var t=h[e.name].deferredOperations.pop();if(t)return t.resolve(),t.promise}function w(e,t){var r=h[e.name].deferredOperations.pop();if(r)return r.reject(t),r.promise}function _(e,t){return new s((function(r,n){if(h[e.name]=h[e.name]||{forages:[],db:null,dbReady:null,deferredOperations:[]},e.db){if(!t)return r(e.db);y(e),e.db.close()}var a=[e.name];t&&a.push(e.version);var s=i.open.apply(i,a);t&&(s.onupgradeneeded=function(t){var r=s.result;try{r.createObjectStore(e.storeName),t.oldVersion<=1&&r.createObjectStore(d)}catch(r){if("ConstraintError"!==r.name)throw r;console.warn('The database "'+e.name+'" has been upgraded from version '+t.oldVersion+" to version "+t.newVersion+', but the storage "'+e.storeName+'" already exists.')}}),s.onerror=function(e){e.preventDefault(),n(s.error)},s.onsuccess=function(){var t=s.result;t.onversionchange=function(e){e.target.close()},r(t),v(e)}}))}function E(e){return _(e,!1)}function A(e){return _(e,!0)}function S(e,t){if(!e.db)return!0;var r=!e.db.objectStoreNames.contains(e.storeName),n=e.version<e.db.version,i=e.version>e.db.version;if(n&&(e.version!==t&&console.warn('The database "'+e.name+"\" can't be downgraded from version "+e.db.version+" to version "+e.version+"."),e.version=e.db.version),i||r){if(r){var a=e.db.version+1;a>e.version&&(e.version=a)}return!0}return!1}function k(e){var t=function(e){for(var t=e.length,r=new ArrayBuffer(t),n=new Uint8Array(r),i=0;i<t;i++)n[i]=e.charCodeAt(i);return r}(atob(e.data));return a([t],{type:e.type})}function x(e){return e&&e.__local_forage_encoded_blob}function T(e){var t=this,r=t._initReady().then((function(){var e=h[t._dbInfo.name];if(e&&e.dbReady)return e.dbReady}));return c(r,e,e),r}function R(e,t,r,n){void 0===n&&(n=1);try{var i=e.db.transaction(e.storeName,t);r(null,i)}catch(i){if(n>0&&(!e.db||"InvalidStateError"===i.name||"NotFoundError"===i.name))return s.resolve().then((function(){if(!e.db||"NotFoundError"===i.name&&!e.db.objectStoreNames.contains(e.storeName)&&e.version<=e.db.version)return e.db&&(e.version=e.db.version+1),A(e)})).then((function(){return function(e){y(e);for(var t=h[e.name],r=t.forages,n=0;n<r.length;n++){var i=r[n];i._dbInfo.db&&(i._dbInfo.db.close(),i._dbInfo.db=null)}return e.db=null,E(e).then((function(t){return e.db=t,S(e)?A(e):t})).then((function(n){e.db=t.db=n;for(var i=0;i<r.length;i++)r[i]._dbInfo.db=n})).catch((function(t){throw w(e,t),t}))}(e).then((function(){R(e,t,r,n-1)}))})).catch(r);r(i)}}var O={_driver:"asyncStorage",_initStorage:function(e){var t=this,r={db:null};if(e)for(var n in e)r[n]=e[n];var i=h[r.name];i||(i={forages:[],db:null,dbReady:null,deferredOperations:[]},h[r.name]=i),i.forages.push(t),t._initReady||(t._initReady=t.ready,t.ready=T);var a=[];function o(){return s.resolve()}for(var c=0;c<i.forages.length;c++){var f=i.forages[c];f!==t&&a.push(f._initReady().catch(o))}var u=i.forages.slice(0);return s.all(a).then((function(){return r.db=i.db,E(r)})).then((function(e){return r.db=e,S(r,t._defaultConfig.version)?A(r):e})).then((function(e){r.db=i.db=e,t._dbInfo=r;for(var n=0;n<u.length;n++){var a=u[n];a!==t&&(a._dbInfo.db=r.db,a._dbInfo.version=r.version)}}))},_support:function(){try{if(!i||!i.open)return!1;var e=typeof openDatabase<"u"&&/(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)&&!/BlackBerry/.test(navigator.platform),t="function"==typeof fetch&&-1!==fetch.toString().indexOf("[native code");return(!e||t)&&typeof indexedDB<"u"&&typeof IDBKeyRange<"u"}catch{return!1}}(),iterate:function(e,t){var r=this,n=new s((function(t,n){r.ready().then((function(){R(r._dbInfo,b,(function(i,a){if(i)return n(i);try{var s=a.objectStore(r._dbInfo.storeName).openCursor(),o=1;s.onsuccess=function(){var r=s.result;if(r){var n=r.value;x(n)&&(n=k(n));var i=e(n,r.key,o++);void 0!==i?t(i):r.continue()}else t()},s.onerror=function(){n(s.error)}}catch(e){n(e)}}))})).catch(n)}));return o(n,t),n},getItem:function(e,t){var r=this;e=f(e);var n=new s((function(t,n){r.ready().then((function(){R(r._dbInfo,b,(function(i,a){if(i)return n(i);try{var s=a.objectStore(r._dbInfo.storeName).get(e);s.onsuccess=function(){var e=s.result;void 0===e&&(e=null),x(e)&&(e=k(e)),t(e)},s.onerror=function(){n(s.error)}}catch(e){n(e)}}))})).catch(n)}));return o(n,t),n},setItem:function(e,t,r){var n=this;e=f(e);var i=new s((function(r,i){var a;n.ready().then((function(){return a=n._dbInfo,"[object Blob]"===p.call(t)?m(a.db).then((function(e){return e?t:function(e){return new s((function(t,r){var n=new FileReader;n.onerror=r,n.onloadend=function(r){var n=btoa(r.target.result||"");t({__local_forage_encoded_blob:!0,data:n,type:e.type})},n.readAsBinaryString(e)}))}(t)})):t})).then((function(t){R(n._dbInfo,g,(function(a,s){if(a)return i(a);try{var o=s.objectStore(n._dbInfo.storeName);null===t&&(t=void 0);var c=o.put(t,e);s.oncomplete=function(){void 0===t&&(t=null),r(t)},s.onabort=s.onerror=function(){var e=c.error?c.error:c.transaction.error;i(e)}}catch(e){i(e)}}))})).catch(i)}));return o(i,r),i},removeItem:function(e,t){var r=this;e=f(e);var n=new s((function(t,n){r.ready().then((function(){R(r._dbInfo,g,(function(i,a){if(i)return n(i);try{var s=a.objectStore(r._dbInfo.storeName).delete(e);a.oncomplete=function(){t()},a.onerror=function(){n(s.error)},a.onabort=function(){var e=s.error?s.error:s.transaction.error;n(e)}}catch(e){n(e)}}))})).catch(n)}));return o(n,t),n},clear:function(e){var t=this,r=new s((function(e,r){t.ready().then((function(){R(t._dbInfo,g,(function(n,i){if(n)return r(n);try{var a=i.objectStore(t._dbInfo.storeName).clear();i.oncomplete=function(){e()},i.onabort=i.onerror=function(){var e=a.error?a.error:a.transaction.error;r(e)}}catch(e){r(e)}}))})).catch(r)}));return o(r,e),r},length:function(e){var t=this,r=new s((function(e,r){t.ready().then((function(){R(t._dbInfo,b,(function(n,i){if(n)return r(n);try{var a=i.objectStore(t._dbInfo.storeName).count();a.onsuccess=function(){e(a.result)},a.onerror=function(){r(a.error)}}catch(e){r(e)}}))})).catch(r)}));return o(r,e),r},key:function(e,t){var r=this,n=new s((function(t,n){e<0?t(null):r.ready().then((function(){R(r._dbInfo,b,(function(i,a){if(i)return n(i);try{var s=a.objectStore(r._dbInfo.storeName),o=!1,c=s.openKeyCursor();c.onsuccess=function(){var r=c.result;r?0===e||o?t(r.key):(o=!0,r.advance(e)):t(null)},c.onerror=function(){n(c.error)}}catch(e){n(e)}}))})).catch(n)}));return o(n,t),n},keys:function(e){var t=this,r=new s((function(e,r){t.ready().then((function(){R(t._dbInfo,b,(function(n,i){if(n)return r(n);try{var a=i.objectStore(t._dbInfo.storeName).openKeyCursor(),s=[];a.onsuccess=function(){var t=a.result;t?(s.push(t.key),t.continue()):e(s)},a.onerror=function(){r(a.error)}}catch(e){r(e)}}))})).catch(r)}));return o(r,e),r},dropInstance:function(e,t){t=u.apply(this,arguments);var r,n=this.config();if((e="function"!=typeof e&&e||{}).name||(e.name=e.name||n.name,e.storeName=e.storeName||n.storeName),e.name){var a=e.name===n.name&&this._dbInfo.db?s.resolve(this._dbInfo.db):E(e).then((function(t){var r=h[e.name],n=r.forages;r.db=t;for(var i=0;i<n.length;i++)n[i]._dbInfo.db=t;return t}));r=e.storeName?a.then((function(t){if(t.objectStoreNames.contains(e.storeName)){var r=t.version+1;y(e);var n=h[e.name],a=n.forages;t.close();for(var o=0;o<a.length;o++){var c=a[o];c._dbInfo.db=null,c._dbInfo.version=r}var f=new s((function(t,n){var a=i.open(e.name,r);a.onerror=function(e){a.result.close(),n(e)},a.onupgradeneeded=function(){a.result.deleteObjectStore(e.storeName)},a.onsuccess=function(){var e=a.result;e.close(),t(e)}}));return f.then((function(e){n.db=e;for(var t=0;t<a.length;t++){var r=a[t];r._dbInfo.db=e,v(r._dbInfo)}})).catch((function(t){throw(w(e,t)||s.resolve()).catch((function(){})),t}))}})):a.then((function(t){y(e);var r=h[e.name],n=r.forages;t.close();for(var a=0;a<n.length;a++){n[a]._dbInfo.db=null}var o=new s((function(t,r){var n=i.deleteDatabase(e.name);n.onerror=function(){var e=n.result;e&&e.close(),r(n.error)},n.onblocked=function(){console.warn('dropInstance blocked for database "'+e.name+'" until all open connections are closed')},n.onsuccess=function(){var e=n.result;e&&e.close(),t(e)}}));return o.then((function(e){r.db=e;for(var t=0;t<n.length;t++){v(n[t]._dbInfo)}})).catch((function(t){throw(w(e,t)||s.resolve()).catch((function(){})),t}))}))}else r=s.reject("Invalid arguments");return o(r,t),r}};var I="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",M=/^~~local_forage_type~([^~]+)~/,C="__lfsc__:",P="arbf",N="blob",B="si08",U="ui08",L="uic8",j="si16",D="si32",F="ur16",q="ui32",z="fl32",K="fl64",H=Object.prototype.toString;function G(e){var t,r,n,i,a,s=.75*e.length,o=e.length,c=0;"="===e[e.length-1]&&(s--,"="===e[e.length-2]&&s--);var f=new ArrayBuffer(s),u=new Uint8Array(f);for(t=0;t<o;t+=4)r=I.indexOf(e[t]),n=I.indexOf(e[t+1]),i=I.indexOf(e[t+2]),a=I.indexOf(e[t+3]),u[c++]=r<<2|n>>4,u[c++]=(15&n)<<4|i>>2,u[c++]=(3&i)<<6|63&a;return f}function V(e){var t,r=new Uint8Array(e),n="";for(t=0;t<r.length;t+=3)n+=I[r[t]>>2],n+=I[(3&r[t])<<4|r[t+1]>>4],n+=I[(15&r[t+1])<<2|r[t+2]>>6],n+=I[63&r[t+2]];return r.length%3==2?n=n.substring(0,n.length-1)+"=":r.length%3==1&&(n=n.substring(0,n.length-2)+"=="),n}var W={serialize:function(e,t){var r="";if(e&&(r=H.call(e)),e&&("[object ArrayBuffer]"===r||e.buffer&&"[object ArrayBuffer]"===H.call(e.buffer))){var n,i=C;e instanceof ArrayBuffer?(n=e,i+=P):(n=e.buffer,"[object Int8Array]"===r?i+=B:"[object Uint8Array]"===r?i+=U:"[object Uint8ClampedArray]"===r?i+=L:"[object Int16Array]"===r?i+=j:"[object Uint16Array]"===r?i+=F:"[object Int32Array]"===r?i+=D:"[object Uint32Array]"===r?i+=q:"[object Float32Array]"===r?i+=z:"[object Float64Array]"===r?i+=K:t(new Error("Failed to get type for BinaryArray"))),t(i+V(n))}else if("[object Blob]"===r){var a=new FileReader;a.onload=function(){var r="~~local_forage_type~"+e.type+"~"+V(this.result);t(C+N+r)},a.readAsArrayBuffer(e)}else try{t(JSON.stringify(e))}catch(r){console.error("Couldn't convert value into a JSON string: ",e),t(null,r)}},deserialize:function(e){if(e.substring(0,9)!==C)return JSON.parse(e);var t,r=e.substring(13),n=e.substring(9,13);if(n===N&&M.test(r)){var i=r.match(M);t=i[1],r=r.substring(i[0].length)}var s=G(r);switch(n){case P:return s;case N:return a([s],{type:t});case B:return new Int8Array(s);case U:return new Uint8Array(s);case L:return new Uint8ClampedArray(s);case j:return new Int16Array(s);case F:return new Uint16Array(s);case D:return new Int32Array(s);case q:return new Uint32Array(s);case z:return new Float32Array(s);case K:return new Float64Array(s);default:throw new Error("Unkown type: "+n)}},stringToBuffer:G,bufferToString:V};function X(e,t,r,n){e.executeSql("CREATE TABLE IF NOT EXISTS "+t.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],r,n)}function $(e,t,r,n,i,a){e.executeSql(r,n,i,(function(e,s){s.code===s.SYNTAX_ERR?e.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[t.storeName],(function(e,o){o.rows.length?a(e,s):X(e,t,(function(){e.executeSql(r,n,i,a)}),a)}),a):a(e,s)}),a)}function J(e,t,r,n){var i=this;e=f(e);var a=new s((function(a,s){i.ready().then((function(){void 0===t&&(t=null);var o=t,c=i._dbInfo;c.serializer.serialize(t,(function(t,f){f?s(f):c.db.transaction((function(r){$(r,c,"INSERT OR REPLACE INTO "+c.storeName+" (key, value) VALUES (?, ?)",[e,t],(function(){a(o)}),(function(e,t){s(t)}))}),(function(t){if(t.code===t.QUOTA_ERR){if(n>0)return void a(J.apply(i,[e,o,r,n-1]));s(t)}}))}))})).catch(s)}));return o(a,r),a}var Y={_driver:"webSQLStorage",_initStorage:function(e){var t=this,r={db:null};if(e)for(var n in e)r[n]="string"!=typeof e[n]?e[n].toString():e[n];var i=new s((function(e,n){try{r.db=openDatabase(r.name,String(r.version),r.description,r.size)}catch(e){return n(e)}r.db.transaction((function(i){X(i,r,(function(){t._dbInfo=r,e()}),(function(e,t){n(t)}))}),n)}));return r.serializer=W,i},_support:"function"==typeof openDatabase,iterate:function(e,t){var r=this,n=new s((function(t,n){r.ready().then((function(){var i=r._dbInfo;i.db.transaction((function(r){$(r,i,"SELECT * FROM "+i.storeName,[],(function(r,n){for(var a=n.rows,s=a.length,o=0;o<s;o++){var c=a.item(o),f=c.value;if(f&&(f=i.serializer.deserialize(f)),void 0!==(f=e(f,c.key,o+1)))return void t(f)}t()}),(function(e,t){n(t)}))}))})).catch(n)}));return o(n,t),n},getItem:function(e,t){var r=this;e=f(e);var n=new s((function(t,n){r.ready().then((function(){var i=r._dbInfo;i.db.transaction((function(r){$(r,i,"SELECT * FROM "+i.storeName+" WHERE key = ? LIMIT 1",[e],(function(e,r){var n=r.rows.length?r.rows.item(0).value:null;n&&(n=i.serializer.deserialize(n)),t(n)}),(function(e,t){n(t)}))}))})).catch(n)}));return o(n,t),n},setItem:function(e,t,r){return J.apply(this,[e,t,r,1])},removeItem:function(e,t){var r=this;e=f(e);var n=new s((function(t,n){r.ready().then((function(){var i=r._dbInfo;i.db.transaction((function(r){$(r,i,"DELETE FROM "+i.storeName+" WHERE key = ?",[e],(function(){t()}),(function(e,t){n(t)}))}))})).catch(n)}));return o(n,t),n},clear:function(e){var t=this,r=new s((function(e,r){t.ready().then((function(){var n=t._dbInfo;n.db.transaction((function(t){$(t,n,"DELETE FROM "+n.storeName,[],(function(){e()}),(function(e,t){r(t)}))}))})).catch(r)}));return o(r,e),r},length:function(e){var t=this,r=new s((function(e,r){t.ready().then((function(){var n=t._dbInfo;n.db.transaction((function(t){$(t,n,"SELECT COUNT(key) as c FROM "+n.storeName,[],(function(t,r){var n=r.rows.item(0).c;e(n)}),(function(e,t){r(t)}))}))})).catch(r)}));return o(r,e),r},key:function(e,t){var r=this,n=new s((function(t,n){r.ready().then((function(){var i=r._dbInfo;i.db.transaction((function(r){$(r,i,"SELECT key FROM "+i.storeName+" WHERE id = ? LIMIT 1",[e+1],(function(e,r){var n=r.rows.length?r.rows.item(0).key:null;t(n)}),(function(e,t){n(t)}))}))})).catch(n)}));return o(n,t),n},keys:function(e){var t=this,r=new s((function(e,r){t.ready().then((function(){var n=t._dbInfo;n.db.transaction((function(t){$(t,n,"SELECT key FROM "+n.storeName,[],(function(t,r){for(var n=[],i=0;i<r.rows.length;i++)n.push(r.rows.item(i).key);e(n)}),(function(e,t){r(t)}))}))})).catch(r)}));return o(r,e),r},dropInstance:function(e,t){t=u.apply(this,arguments);var r=this.config();(e="function"!=typeof e&&e||{}).name||(e.name=e.name||r.name,e.storeName=e.storeName||r.storeName);var n,i=this;return n=e.name?new s((function(t){var n;n=e.name===r.name?i._dbInfo.db:openDatabase(e.name,"","",0),e.storeName?t({db:n,storeNames:[e.storeName]}):t(function(e){return new s((function(t,r){e.transaction((function(n){n.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],(function(r,n){for(var i=[],a=0;a<n.rows.length;a++)i.push(n.rows.item(a).name);t({db:e,storeNames:i})}),(function(e,t){r(t)}))}),(function(e){r(e)}))}))}(n))})).then((function(e){return new s((function(t,r){e.db.transaction((function(n){function i(e){return new s((function(t,r){n.executeSql("DROP TABLE IF EXISTS "+e,[],(function(){t()}),(function(e,t){r(t)}))}))}for(var a=[],o=0,c=e.storeNames.length;o<c;o++)a.push(i(e.storeNames[o]));s.all(a).then((function(){t()})).catch((function(e){r(e)}))}),(function(e){r(e)}))}))})):s.reject("Invalid arguments"),o(n,t),n}};function Q(e,t){var r=e.name+"/";return e.storeName!==t.storeName&&(r+=e.storeName+"/"),r}function Z(){return!function(){var e="_localforage_support_test";try{return localStorage.setItem(e,!0),localStorage.removeItem(e),!1}catch{return!0}}()||localStorage.length>0}var ee={_driver:"localStorageWrapper",_initStorage:function(e){var t={};if(e)for(var r in e)t[r]=e[r];return t.keyPrefix=Q(e,this._defaultConfig),Z()?(this._dbInfo=t,t.serializer=W,s.resolve()):s.reject()},_support:function(){try{return typeof localStorage<"u"&&"setItem"in localStorage&&!!localStorage.setItem}catch{return!1}}(),iterate:function(e,t){var r=this,n=r.ready().then((function(){for(var t=r._dbInfo,n=t.keyPrefix,i=n.length,a=localStorage.length,s=1,o=0;o<a;o++){var c=localStorage.key(o);if(0===c.indexOf(n)){var f=localStorage.getItem(c);if(f&&(f=t.serializer.deserialize(f)),void 0!==(f=e(f,c.substring(i),s++)))return f}}}));return o(n,t),n},getItem:function(e,t){var r=this;e=f(e);var n=r.ready().then((function(){var t=r._dbInfo,n=localStorage.getItem(t.keyPrefix+e);return n&&(n=t.serializer.deserialize(n)),n}));return o(n,t),n},setItem:function(e,t,r){var n=this;e=f(e);var i=n.ready().then((function(){void 0===t&&(t=null);var r=t;return new s((function(i,a){var s=n._dbInfo;s.serializer.serialize(t,(function(t,n){if(n)a(n);else try{localStorage.setItem(s.keyPrefix+e,t),i(r)}catch(e){("QuotaExceededError"===e.name||"NS_ERROR_DOM_QUOTA_REACHED"===e.name)&&a(e),a(e)}}))}))}));return o(i,r),i},removeItem:function(e,t){var r=this;e=f(e);var n=r.ready().then((function(){var t=r._dbInfo;localStorage.removeItem(t.keyPrefix+e)}));return o(n,t),n},clear:function(e){var t=this,r=t.ready().then((function(){for(var e=t._dbInfo.keyPrefix,r=localStorage.length-1;r>=0;r--){var n=localStorage.key(r);0===n.indexOf(e)&&localStorage.removeItem(n)}}));return o(r,e),r},length:function(e){var t=this.keys().then((function(e){return e.length}));return o(t,e),t},key:function(e,t){var r=this,n=r.ready().then((function(){var t,n=r._dbInfo;try{t=localStorage.key(e)}catch{t=null}return t&&(t=t.substring(n.keyPrefix.length)),t}));return o(n,t),n},keys:function(e){var t=this,r=t.ready().then((function(){for(var e=t._dbInfo,r=localStorage.length,n=[],i=0;i<r;i++){var a=localStorage.key(i);0===a.indexOf(e.keyPrefix)&&n.push(a.substring(e.keyPrefix.length))}return n}));return o(r,e),r},dropInstance:function(e,t){if(t=u.apply(this,arguments),!(e="function"!=typeof e&&e||{}).name){var r=this.config();e.name=e.name||r.name,e.storeName=e.storeName||r.storeName}var n,i=this;return n=e.name?new s((function(t){e.storeName?t(Q(e,i._defaultConfig)):t(e.name+"/")})).then((function(e){for(var t=localStorage.length-1;t>=0;t--){var r=localStorage.key(t);0===r.indexOf(e)&&localStorage.removeItem(r)}})):s.reject("Invalid arguments"),o(n,t),n}},te=function(e,t){return e===t||"number"==typeof e&&"number"==typeof t&&isNaN(e)&&isNaN(t)},re=function(e,t){for(var r=e.length,n=0;n<r;){if(te(e[n],t))return!0;n++}return!1},ne=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)},ie={},ae={},se={INDEXEDDB:O,WEBSQL:Y,LOCALSTORAGE:ee},oe=[se.INDEXEDDB._driver,se.WEBSQL._driver,se.LOCALSTORAGE._driver],ce=["dropInstance"],fe=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(ce),ue={description:"",driver:oe.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1};function de(e,t){e[t]=function(){var r=arguments;return e.ready().then((function(){return e[t].apply(e,r)}))}}function le(){for(var e=1;e<arguments.length;e++){var t=arguments[e];if(t)for(var r in t)t.hasOwnProperty(r)&&(ne(t[r])?arguments[0][r]=t[r].slice():arguments[0][r]=t[r])}return arguments[0]}var he=function(){function e(t){for(var r in function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),se)if(se.hasOwnProperty(r)){var n=se[r],i=n._driver;this[r]=i,ie[i]||this.defineDriver(n)}this._defaultConfig=le({},ue),this._config=le({},this._defaultConfig,t),this._driverSet=null,this._initDriver=null,this._ready=!1,this._dbInfo=null,this._wrapLibraryMethodsWithReady(),this.setDriver(this._config.driver).catch((function(){}))}return e.prototype.config=function(e){if("object"===(typeof e>"u"?"undefined":n(e))){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(var t in e){if("storeName"===t&&(e[t]=e[t].replace(/\W/g,"_")),"version"===t&&"number"!=typeof e[t])return new Error("Database version must be a number.");this._config[t]=e[t]}return!("driver"in e)||!e.driver||this.setDriver(this._config.driver)}return"string"==typeof e?this._config[e]:this._config},e.prototype.defineDriver=function(e,t,r){var n=new s((function(t,r){try{var n=e._driver,i=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!e._driver)return void r(i);for(var a=fe.concat("_initStorage"),c=0,f=a.length;c<f;c++){var u=a[c];if((!re(ce,u)||e[u])&&"function"!=typeof e[u])return void r(i)}!function(){for(var t=function(e){return function(){var t=new Error("Method "+e+" is not implemented by the current driver"),r=s.reject(t);return o(r,arguments[arguments.length-1]),r}},r=0,n=ce.length;r<n;r++){var i=ce[r];e[i]||(e[i]=t(i))}}();var d=function(r){ie[n]&&console.info("Redefining LocalForage driver: "+n),ie[n]=e,ae[n]=r,t()};"_support"in e?e._support&&"function"==typeof e._support?e._support().then(d,r):d(!!e._support):d(!0)}catch(e){r(e)}}));return c(n,t,r),n},e.prototype.driver=function(){return this._driver||null},e.prototype.getDriver=function(e,t,r){var n=ie[e]?s.resolve(ie[e]):s.reject(new Error("Driver not found."));return c(n,t,r),n},e.prototype.getSerializer=function(e){var t=s.resolve(W);return c(t,e),t},e.prototype.ready=function(e){var t=this,r=t._driverSet.then((function(){return null===t._ready&&(t._ready=t._initDriver()),t._ready}));return c(r,e,e),r},e.prototype.setDriver=function(e,t,r){var n=this;ne(e)||(e=[e]);var i=this._getSupportedDrivers(e);function a(){n._config.driver=n.driver()}function o(e){return n._extend(e),a(),n._ready=n._initStorage(n._config),n._ready}var f=null!==this._driverSet?this._driverSet.catch((function(){return s.resolve()})):s.resolve();return this._driverSet=f.then((function(){var e=i[0];return n._dbInfo=null,n._ready=null,n.getDriver(e).then((function(e){n._driver=e._driver,a(),n._wrapLibraryMethodsWithReady(),n._initDriver=function(e){return function(){var t=0;return function r(){for(;t<e.length;){var i=e[t];return t++,n._dbInfo=null,n._ready=null,n.getDriver(i).then(o).catch(r)}a();var c=new Error("No available storage method found.");return n._driverSet=s.reject(c),n._driverSet}()}}(i)}))})).catch((function(){a();var e=new Error("No available storage method found.");return n._driverSet=s.reject(e),n._driverSet})),c(this._driverSet,t,r),this._driverSet},e.prototype.supports=function(e){return!!ae[e]},e.prototype._extend=function(e){le(this,e)},e.prototype._getSupportedDrivers=function(e){for(var t=[],r=0,n=e.length;r<n;r++){var i=e[r];this.supports(i)&&t.push(i)}return t},e.prototype._wrapLibraryMethodsWithReady=function(){for(var e=0,t=fe.length;e<t;e++)de(this,fe[e])},e.prototype.createInstance=function(t){return new e(t)},e}(),pe=new he;t.exports=pe},{3:3}]},{},[4])(4)}))})),wN=gN(((e,t)=>{!function(r,n){"object"==typeof e&&typeof t<"u"?n(e):"function"==typeof define&&define.amd?define("localforage-driver-memory",["exports"],n):n(r.LocalforageDriverMemory={})}(typeof self<"u"?self:e,(function(e){var t=/^~~local_forage_type~([^~]+)~/,r=Object.prototype.toString;function n(e){var t=.75*e.length,r=e.length;"="===e[e.length-1]&&(t--,"="===e[e.length-2]&&t--);for(var n=new ArrayBuffer(t),i=new Uint8Array(n),a=0,s=0;a<r;a+=4){var o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(e[a]),c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(e[a+1]),f="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(e[a+2]),u="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(e[a+3]);i[s++]=o<<2|c>>4,i[s++]=(15&c)<<4|f>>2,i[s++]=(3&f)<<6|63&u}return n}function i(e){for(var t=new Uint8Array(e),r="",n=0;n<t.length;n+=3)r+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[t[n]>>2],r+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(3&t[n])<<4|t[n+1]>>4],r+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(15&t[n+1])<<2|t[n+2]>>6],r+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[63&t[n+2]];return t.length%3==2?r=r.substring(0,r.length-1)+"=":t.length%3==1&&(r=r.substring(0,r.length-2)+"=="),r}function a(e){var t,r;if(null===e||"object"!=typeof e||"isActiveClone"in e)return e;var n=e instanceof Date?new Date(e):e.constructor();try{for(var i=function(e){var t="function"==typeof Symbol&&e[Symbol.iterator],r=0;return t?t.call(e):{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}}}(Object.keys(e)),s=i.next();!s.done;s=i.next()){var o=s.value;Object.prototype.hasOwnProperty.call(e,o)&&(e.isActiveClone=null,n[o]=a(e[o]),delete e.isActiveClone)}}catch(e){t={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(t)throw t.error}}return n}function s(e,t){return(e.name||t.name)+"/"+(e.storeName||t.storeName)+"/"}function o(e,t){t&&e.then((function(e){t(null,e)}),(function(e){t(e)}))}function c(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];if(arguments.length&&"function"==typeof arguments[arguments.length-1])return arguments[arguments.length-1]}function f(e,t){var r,n=this;if(t=c.apply(this,arguments),!(e="function"!=typeof e&&e||{}).name){var i=this.config();e.name=e.name||i.name,e.storeName=e.storeName||i.storeName}return r=e.name?new Promise((function(t){e.storeName?t(s(e,n._defaultConfig)):t(e.name+"/")})):Promise.reject("Invalid arguments"),{promise:r,callback:t}}function u(e){return"string"!=typeof e&&(console.warn(e+" used as a key, but it is not a string."),e=String(e)),e}var d={bufferToString:i,deserialize:function(e){if("__lfsc__:"!==e.substring(0,9))return JSON.parse(e);var r,i=e.substring(13),a=e.substring(9,13);if("blob"===a&&t.test(i)){var s=i.match(t);r=s[1],i=i.substring(s[0].length)}var o=n(i);switch(a){case"arbf":return o;case"blob":return function(e,t){e=e||[],t=t||{};try{return new Blob(e,t)}catch(i){if("TypeError"!==i.name)throw i;for(var r=new(typeof BlobBuilder<"u"?BlobBuilder:typeof MSBlobBuilder<"u"?MSBlobBuilder:typeof MozBlobBuilder<"u"?MozBlobBuilder:WebKitBlobBuilder),n=0;n<e.length;n+=1)r.append(e[n]);return r.getBlob(t.type)}}([o],{type:r});case"si08":return new Int8Array(o);case"ui08":return new Uint8Array(o);case"uic8":return new Uint8ClampedArray(o);case"si16":return new Int16Array(o);case"ur16":return new Uint16Array(o);case"si32":return new Int32Array(o);case"ui32":return new Uint32Array(o);case"fl32":return new Float32Array(o);case"fl64":return new Float64Array(o);default:throw new Error("Unkown type: "+a)}},serialize:function(e,t){var n="";if(e&&(n=r.call(e)),e&&("[object ArrayBuffer]"===n||e.buffer&&"[object ArrayBuffer]"===r.call(e.buffer))){var a=void 0,s="__lfsc__:";e instanceof ArrayBuffer?(a=e,s+="arbf"):(a=e.buffer,"[object Int8Array]"===n?s+="si08":"[object Uint8Array]"===n?s+="ui08":"[object Uint8ClampedArray]"===n?s+="uic8":"[object Int16Array]"===n?s+="si16":"[object Uint16Array]"===n?s+="ur16":"[object Int32Array]"===n?s+="si32":"[object Uint32Array]"===n?s+="ui32":"[object Float32Array]"===n?s+="fl32":"[object Float64Array]"===n?s+="fl64":t(new Error("Failed to get type for BinaryArray"))),t(s+i(a))}else if("[object Blob]"===n){var o=new FileReader;o.onload=function(){var r="~~local_forage_type~"+e.type+"~"+i(this.result);t("__lfsc__:blob"+r)},o.readAsArrayBuffer(e)}else try{t(JSON.stringify(e))}catch(r){console.error("Couldn't convert value into a JSON string: ",e),t(null,r)}},stringToBuffer:n},l={},h=function(){function e(e){this.kp=e,this.data={}}return e.resolve=function(t){return l[t]||(l[t]=new e(t)),l[t]},e.prototype.clear=function(){this.data={}},e.prototype.drop=function(){this.clear(),delete l[this.kp]},e.prototype.get=function(e){return this.data[e]},e.prototype.key=function(e){return this.keys()[e]},e.prototype.keys=function(){return Object.keys(this.data)},e.prototype.rm=function(e){delete this.data[e]},e.prototype.set=function(e,t){this.data[e]=t},e}();e._support=!0,e._driver="localforage-driver-memory",e._initStorage=function(e){var t=e?a(e):{},r=s(t,this._defaultConfig),n=h.resolve(r);return this._dbInfo=t,this._dbInfo.serializer=d,this._dbInfo.keyPrefix=r,this._dbInfo.mStore=n,Promise.resolve()},e.clear=function(e){var t=this,r=this.ready().then((function(){t._dbInfo.mStore.clear()}));return o(r,e),r},e.dropInstance=function(e,t){var r=f.apply(this,arguments),n=r.promise,i=r.callback,a=n.then((function(e){h.resolve(e).drop()}));return o(a,i),n},e.getItem=function(e,t){var r=this;e=u(e);var n=this.ready().then((function(){var t=r._dbInfo.mStore.get(e);return null==t?null:r._dbInfo.serializer.deserialize(t)}));return o(n,t),n},e.iterate=function(e,t){var r=this,n=this.ready().then((function(){for(var t=r._dbInfo.mStore,n=t.keys(),i=0;i<n.length;i++){var a=t.get(n[i]);if(a&&(a=r._dbInfo.serializer.deserialize(a)),void 0!==(a=e(a,n[i],i+1)))return a}}));return o(n,t),n},e.key=function(e,t){var r=this,n=this.ready().then((function(){var t;try{void 0===(t=r._dbInfo.mStore.key(e))&&(t=null)}catch{t=null}return t}));return o(n,t),n},e.keys=function(e){var t=this,r=this.ready().then((function(){return t._dbInfo.mStore.keys()}));return o(r,e),r},e.length=function(e){var t=this.keys().then((function(e){return e.length}));return o(t,e),t},e.removeItem=function(e,t){var r=this;e=u(e);var n=this.ready().then((function(){r._dbInfo.mStore.rm(e)}));return o(n,t),n},e.setItem=function(e,t,r){var n=this;e=u(e);var i=this.ready().then((function(){void 0===t&&(t=null);var r=t;return new Promise((function(i,a){n._dbInfo.serializer.serialize(t,(function(t,s){if(s)a(s);else try{n._dbInfo.mStore.set(e,t),i(r)}catch(e){a(e)}}))}))}));return o(i,r),i},Object.defineProperty(e,"__esModule",{value:!0})}))})),_N=mN(vN()),EN=mN(wN()),AN={display:"none",position:"fixed",top:"0",right:"0",width:"100%",height:"100%",borderRadius:"0",border:"none",zIndex:"2147483647"};var SN=function(e,t){return Object.assign($C,t),e}(sN,{platform:"web",sdkName:"magic-sdk",version:"13.6.2",defaultEndpoint:"https://auth.magic.link/",ViewController:class extends cN{constructor(){super(...arguments),this.activeElement=null}init(){this.test="hello",this.iframe=new Promise((e=>{let t=()=>{if(function(e){let t=[].slice.call(document.querySelectorAll(".magic-iframe"));return Boolean(t.find((t=>t.src.includes(e))))}(encodeURIComponent(this.parameters)))new ZC(SM.DuplicateIframe,"Duplicate iframes found.").log();else{let t=document.createElement("iframe");t.classList.add("magic-iframe"),t.dataset.magicIframeLabel=YP(this.endpoint).host,t.title="Secure Modal",t.src=YP(`/send?params=${encodeURIComponent(this.parameters)}`,this.endpoint).href,function(e){for(let[t,r]of Object.entries(AN))e.style[t]=r}(t),document.body.appendChild(t),e(t)}};["loaded","interactive","complete"].includes(document.readyState)?t():window.addEventListener("load",t,!1)})),window.addEventListener("message",(e=>{var t;if(e.origin===this.endpoint&&e.data&&e.data.msgType&&this.messageHandlers.size){e.data.response=null!=(t=e.data.response)?t:{};for(let t of this.messageHandlers.values())t(e)}}))}showOverlay(){return yN(this,null,(function*(){let e=yield this.iframe;e.style.display="block",this.activeElement=document.activeElement,e.focus()}))}hideOverlay(){return yN(this,null,(function*(){var e;(yield this.iframe).style.display="none",null!=(e=this.activeElement)&&e.focus&&this.activeElement.focus(),this.activeElement=null}))}_post(e){return yN(this,null,(function*(){let t=yield this.iframe;if(!t||!t.contentWindow)throw new YC(AM.ModalNotReady,"Modal is not ready.");t.contentWindow.postMessage(e,this.endpoint)}))}},configureStorage:()=>yN(void 0,null,(function*(){let e=_N.default.createInstance({name:"MagicAuthLocalStorageDB",storeName:"MagicAuthLocalStorage"});return yield e.defineDriver(EN),yield e.setDriver([_N.default.INDEXEDDB,_N.default.LOCALSTORAGE,EN._driver]),e}))}),kN=(e=>(e.LoginWithOIDC="magic_auth_login_with_oidc",e))(kN||{}),xN=class extends tN.Internal{constructor(){super(...arguments),this.name="openid",this.config={}}loginWithOIDC(e){let t=this.utils.createJsonRpcRequestPayload("magic_auth_login_with_oidc",[e]);return this.request(t)}};function TN(e,t){return function(){return e.apply(t,arguments)}}const{toString:RN}=Object.prototype,{getPrototypeOf:ON}=Object,IN=(e=>t=>{const r=RN.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),MN=e=>(e=e.toLowerCase(),t=>IN(t)===e),CN=e=>t=>typeof t===e,{isArray:PN}=Array,NN=CN("undefined");const BN=MN("ArrayBuffer");const UN=CN("string"),LN=CN("function"),jN=CN("number"),DN=e=>null!==e&&"object"==typeof e,FN=e=>{if("object"!==IN(e))return!1;const t=ON(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||Symbol.toStringTag in e||Symbol.iterator in e)},qN=MN("Date"),zN=MN("File"),KN=MN("Blob"),HN=MN("FileList"),GN=MN("URLSearchParams");function VN(e,t,{allOwnKeys:r=!1}={}){if(null==e)return;let n,i;if("object"!=typeof e&&(e=[e]),PN(e))for(n=0,i=e.length;n<i;n++)t.call(null,e[n],n,e);else{const i=r?Object.getOwnPropertyNames(e):Object.keys(e),a=i.length;let s;for(n=0;n<a;n++)s=i[n],t.call(null,e[s],s,e)}}function WN(e,t){t=t.toLowerCase();const r=Object.keys(e);let n,i=r.length;for(;i-- >0;)if(n=r[i],t===n.toLowerCase())return n;return null}const XN="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,$N=e=>!NN(e)&&e!==XN;const JN=(e=>t=>e&&t instanceof e)("undefined"!=typeof Uint8Array&&ON(Uint8Array)),YN=MN("HTMLFormElement"),QN=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),ZN=MN("RegExp"),eB=(e,t)=>{const r=Object.getOwnPropertyDescriptors(e),n={};VN(r,((r,i)=>{!1!==t(r,i,e)&&(n[i]=r)})),Object.defineProperties(e,n)},tB="abcdefghijklmnopqrstuvwxyz",rB="0123456789",nB={DIGIT:rB,ALPHA:tB,ALPHA_DIGIT:tB+tB.toUpperCase()+rB};const iB=MN("AsyncFunction");var aB={isArray:PN,isArrayBuffer:BN,isBuffer:function(e){return null!==e&&!NN(e)&&null!==e.constructor&&!NN(e.constructor)&&LN(e.constructor.isBuffer)&&e.constructor.isBuffer(e)},isFormData:e=>{let t;return e&&("function"==typeof FormData&&e instanceof FormData||LN(e.append)&&("formdata"===(t=IN(e))||"object"===t&&LN(e.toString)&&"[object FormData]"===e.toString()))},isArrayBufferView:function(e){let t;return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&BN(e.buffer),t},isString:UN,isNumber:jN,isBoolean:e=>!0===e||!1===e,isObject:DN,isPlainObject:FN,isUndefined:NN,isDate:qN,isFile:zN,isBlob:KN,isRegExp:ZN,isFunction:LN,isStream:e=>DN(e)&&LN(e.pipe),isURLSearchParams:GN,isTypedArray:JN,isFileList:HN,forEach:VN,merge:function e(){const{caseless:t}=$N(this)&&this||{},r={},n=(n,i)=>{const a=t&&WN(r,i)||i;FN(r[a])&&FN(n)?r[a]=e(r[a],n):FN(n)?r[a]=e({},n):PN(n)?r[a]=n.slice():r[a]=n};for(let e=0,t=arguments.length;e<t;e++)arguments[e]&&VN(arguments[e],n);return r},extend:(e,t,r,{allOwnKeys:n}={})=>(VN(t,((t,n)=>{r&&LN(t)?e[n]=TN(t,r):e[n]=t}),{allOwnKeys:n}),e),trim:e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),stripBOM:e=>(65279===e.charCodeAt(0)&&(e=e.slice(1)),e),inherits:(e,t,r,n)=>{e.prototype=Object.create(t.prototype,n),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},toFlatObject:(e,t,r,n)=>{let i,a,s;const o={};if(t=t||{},null==e)return t;do{for(i=Object.getOwnPropertyNames(e),a=i.length;a-- >0;)s=i[a],n&&!n(s,e,t)||o[s]||(t[s]=e[s],o[s]=!0);e=!1!==r&&ON(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},kindOf:IN,kindOfTest:MN,endsWith:(e,t,r)=>{e=String(e),(void 0===r||r>e.length)&&(r=e.length),r-=t.length;const n=e.indexOf(t,r);return-1!==n&&n===r},toArray:e=>{if(!e)return null;if(PN(e))return e;let t=e.length;if(!jN(t))return null;const r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},forEachEntry:(e,t)=>{const r=(e&&e[Symbol.iterator]).call(e);let n;for(;(n=r.next())&&!n.done;){const r=n.value;t.call(e,r[0],r[1])}},matchAll:(e,t)=>{let r;const n=[];for(;null!==(r=e.exec(t));)n.push(r);return n},isHTMLForm:YN,hasOwnProperty:QN,hasOwnProp:QN,reduceDescriptors:eB,freezeMethods:e=>{eB(e,((t,r)=>{if(LN(e)&&-1!==["arguments","caller","callee"].indexOf(r))return!1;const n=e[r];LN(n)&&(t.enumerable=!1,"writable"in t?t.writable=!1:t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")}))}))},toObjectSet:(e,t)=>{const r={},n=e=>{e.forEach((e=>{r[e]=!0}))};return PN(e)?n(e):n(String(e).split(t)),r},toCamelCase:e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,(function(e,t,r){return t.toUpperCase()+r})),noop:()=>{},toFiniteNumber:(e,t)=>(e=+e,Number.isFinite(e)?e:t),findKey:WN,global:XN,isContextDefined:$N,ALPHABET:nB,generateString:(e=16,t=nB.ALPHA_DIGIT)=>{let r="";const{length:n}=t;for(;e--;)r+=t[Math.random()*n|0];return r},isSpecCompliantForm:function(e){return!!(e&&LN(e.append)&&"FormData"===e[Symbol.toStringTag]&&e[Symbol.iterator])},toJSONObject:e=>{const t=new Array(10),r=(e,n)=>{if(DN(e)){if(t.indexOf(e)>=0)return;if(!("toJSON"in e)){t[n]=e;const i=PN(e)?[]:{};return VN(e,((e,t)=>{const a=r(e,n+1);!NN(a)&&(i[t]=a)})),t[n]=void 0,i}}return e};return r(e,0)},isAsyncFn:iB,isThenable:e=>e&&(DN(e)||LN(e))&&LN(e.then)&&LN(e.catch)};function sB(e,t,r,n,i){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack,this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),n&&(this.request=n),i&&(this.response=i)}aB.inherits(sB,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:aB.toJSONObject(this.config),code:this.code,status:this.response&&this.response.status?this.response.status:null}}});const oB=sB.prototype,cB={};["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((e=>{cB[e]={value:e}})),Object.defineProperties(sB,cB),Object.defineProperty(oB,"isAxiosError",{value:!0}),sB.from=(e,t,r,n,i,a)=>{const s=Object.create(oB);return aB.toFlatObject(e,s,(function(e){return e!==Error.prototype}),(e=>"isAxiosError"!==e)),sB.call(s,e.message,t,r,n,i),s.cause=e,s.name=e.name,a&&Object.assign(s,a),s};function fB(e){return aB.isPlainObject(e)||aB.isArray(e)}function uB(e){return aB.endsWith(e,"[]")?e.slice(0,-2):e}function dB(e,t,r){return e?e.concat(t).map((function(e,t){return e=uB(e),!r&&t?"["+e+"]":e})).join(r?".":""):t}const lB=aB.toFlatObject(aB,{},null,(function(e){return/^is[A-Z]/.test(e)}));function hB(e,t,r){if(!aB.isObject(e))throw new TypeError("target must be an object");t=t||new FormData;const n=(r=aB.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,(function(e,t){return!aB.isUndefined(t[e])}))).metaTokens,i=r.visitor||f,a=r.dots,s=r.indexes,o=(r.Blob||"undefined"!=typeof Blob&&Blob)&&aB.isSpecCompliantForm(t);if(!aB.isFunction(i))throw new TypeError("visitor must be a function");function c(e){if(null===e)return"";if(aB.isDate(e))return e.toISOString();if(!o&&aB.isBlob(e))throw new sB("Blob is not supported. Use a Buffer instead.");return aB.isArrayBuffer(e)||aB.isTypedArray(e)?o&&"function"==typeof Blob?new Blob([e]):Buffer.from(e):e}function f(e,r,i){let o=e;if(e&&!i&&"object"==typeof e)if(aB.endsWith(r,"{}"))r=n?r:r.slice(0,-2),e=JSON.stringify(e);else if(aB.isArray(e)&&function(e){return aB.isArray(e)&&!e.some(fB)}(e)||(aB.isFileList(e)||aB.endsWith(r,"[]"))&&(o=aB.toArray(e)))return r=uB(r),o.forEach((function(e,n){!aB.isUndefined(e)&&null!==e&&t.append(!0===s?dB([r],n,a):null===s?r:r+"[]",c(e))})),!1;return!!fB(e)||(t.append(dB(i,r,a),c(e)),!1)}const u=[],d=Object.assign(lB,{defaultVisitor:f,convertValue:c,isVisitable:fB});if(!aB.isObject(e))throw new TypeError("data must be an object");return function e(r,n){if(!aB.isUndefined(r)){if(-1!==u.indexOf(r))throw Error("Circular reference detected in "+n.join("."));u.push(r),aB.forEach(r,(function(r,a){!0===(!(aB.isUndefined(r)||null===r)&&i.call(t,r,aB.isString(a)?a.trim():a,n,d))&&e(r,n?n.concat(a):[a])})),u.pop()}}(e),t}function pB(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,(function(e){return t[e]}))}function bB(e,t){this._pairs=[],e&&hB(e,this,t)}const gB=bB.prototype;function mB(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function yB(e,t,r){if(!t)return e;const n=r&&r.encode||mB,i=r&&r.serialize;let a;if(a=i?i(t,r):aB.isURLSearchParams(t)?t.toString():new bB(t,r).toString(n),a){const t=e.indexOf("#");-1!==t&&(e=e.slice(0,t)),e+=(-1===e.indexOf("?")?"?":"&")+a}return e}gB.append=function(e,t){this._pairs.push([e,t])},gB.toString=function(e){const t=e?function(t){return e.call(this,t,pB)}:pB;return this._pairs.map((function(e){return t(e[0])+"="+t(e[1])}),"").join("&")};var vB=class{constructor(){this.handlers=[]}use(e,t,r){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!r&&r.synchronous,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){aB.forEach(this.handlers,(function(t){null!==t&&e(t)}))}},wB={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var _B={isBrowser:!0,classes:{URLSearchParams:"undefined"!=typeof URLSearchParams?URLSearchParams:bB,FormData:"undefined"!=typeof FormData?FormData:null,Blob:"undefined"!=typeof Blob?Blob:null},isStandardBrowserEnv:(()=>{let e;return("undefined"==typeof navigator||"ReactNative"!==(e=navigator.product)&&"NativeScript"!==e&&"NS"!==e)&&("undefined"!=typeof window&&"undefined"!=typeof document)})(),isStandardBrowserWebWorkerEnv:"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,protocols:["http","https","file","blob","url","data"]};function EB(e){function t(e,r,n,i){let a=e[i++];const s=Number.isFinite(+a),o=i>=e.length;if(a=!a&&aB.isArray(n)?n.length:a,o)return aB.hasOwnProp(n,a)?n[a]=[n[a],r]:n[a]=r,!s;n[a]&&aB.isObject(n[a])||(n[a]=[]);return t(e,r,n[a],i)&&aB.isArray(n[a])&&(n[a]=function(e){const t={},r=Object.keys(e);let n;const i=r.length;let a;for(n=0;n<i;n++)a=r[n],t[a]=e[a];return t}(n[a])),!s}if(aB.isFormData(e)&&aB.isFunction(e.entries)){const r={};return aB.forEachEntry(e,((e,n)=>{t(function(e){return aB.matchAll(/\w+|\[(\w*)]/g,e).map((e=>"[]"===e[0]?"":e[1]||e[0]))}(e),n,r,0)})),r}return null}const AB={"Content-Type":void 0};const SB={transitional:wB,adapter:["xhr","http"],transformRequest:[function(e,t){const r=t.getContentType()||"",n=r.indexOf("application/json")>-1,i=aB.isObject(e);i&&aB.isHTMLForm(e)&&(e=new FormData(e));if(aB.isFormData(e))return n&&n?JSON.stringify(EB(e)):e;if(aB.isArrayBuffer(e)||aB.isBuffer(e)||aB.isStream(e)||aB.isFile(e)||aB.isBlob(e))return e;if(aB.isArrayBufferView(e))return e.buffer;if(aB.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let a;if(i){if(r.indexOf("application/x-www-form-urlencoded")>-1)return function(e,t){return hB(e,new _B.classes.URLSearchParams,Object.assign({visitor:function(e,t,r,n){return _B.isNode&&aB.isBuffer(e)?(this.append(t,e.toString("base64")),!1):n.defaultVisitor.apply(this,arguments)}},t))}(e,this.formSerializer).toString();if((a=aB.isFileList(e))||r.indexOf("multipart/form-data")>-1){const t=this.env&&this.env.FormData;return hB(a?{"files[]":e}:e,t&&new t,this.formSerializer)}}return i||n?(t.setContentType("application/json",!1),function(e,t,r){if(aB.isString(e))try{return(t||JSON.parse)(e),aB.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(r||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){const t=this.transitional||SB.transitional,r=t&&t.forcedJSONParsing,n="json"===this.responseType;if(e&&aB.isString(e)&&(r&&!this.responseType||n)){const r=!(t&&t.silentJSONParsing)&&n;try{return JSON.parse(e)}catch(e){if(r){if("SyntaxError"===e.name)throw sB.from(e,sB.ERR_BAD_RESPONSE,this,null,this.response);throw e}}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:_B.classes.FormData,Blob:_B.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};aB.forEach(["delete","get","head"],(function(e){SB.headers[e]={}})),aB.forEach(["post","put","patch"],(function(e){SB.headers[e]=aB.merge(AB)}));var kB=SB;const xB=aB.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"]);const TB=Symbol("internals");function RB(e){return e&&String(e).trim().toLowerCase()}function OB(e){return!1===e||null==e?e:aB.isArray(e)?e.map(OB):String(e)}function IB(e,t,r,n,i){return aB.isFunction(n)?n.call(this,t,r):(i&&(t=r),aB.isString(t)?aB.isString(n)?-1!==t.indexOf(n):aB.isRegExp(n)?n.test(t):void 0:void 0)}class MB{constructor(e){e&&this.set(e)}set(e,t,r){const n=this;function i(e,t,r){const i=RB(t);if(!i)throw new Error("header name must be a non-empty string");const a=aB.findKey(n,i);(!a||void 0===n[a]||!0===r||void 0===r&&!1!==n[a])&&(n[a||t]=OB(e))}const a=(e,t)=>aB.forEach(e,((e,r)=>i(e,r,t)));return aB.isPlainObject(e)||e instanceof this.constructor?a(e,t):aB.isString(e)&&(e=e.trim())&&!/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim())?a((e=>{const t={};let r,n,i;return e&&e.split("\n").forEach((function(e){i=e.indexOf(":"),r=e.substring(0,i).trim().toLowerCase(),n=e.substring(i+1).trim(),!r||t[r]&&xB[r]||("set-cookie"===r?t[r]?t[r].push(n):t[r]=[n]:t[r]=t[r]?t[r]+", "+n:n)})),t})(e),t):null!=e&&i(t,e,r),this}get(e,t){if(e=RB(e)){const r=aB.findKey(this,e);if(r){const e=this[r];if(!t)return e;if(!0===t)return function(e){const t=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let n;for(;n=r.exec(e);)t[n[1]]=n[2];return t}(e);if(aB.isFunction(t))return t.call(this,e,r);if(aB.isRegExp(t))return t.exec(e);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=RB(e)){const r=aB.findKey(this,e);return!(!r||void 0===this[r]||t&&!IB(0,this[r],r,t))}return!1}delete(e,t){const r=this;let n=!1;function i(e){if(e=RB(e)){const i=aB.findKey(r,e);!i||t&&!IB(0,r[i],i,t)||(delete r[i],n=!0)}}return aB.isArray(e)?e.forEach(i):i(e),n}clear(e){const t=Object.keys(this);let r=t.length,n=!1;for(;r--;){const i=t[r];e&&!IB(0,this[i],i,e,!0)||(delete this[i],n=!0)}return n}normalize(e){const t=this,r={};return aB.forEach(this,((n,i)=>{const a=aB.findKey(r,i);if(a)return t[a]=OB(n),void delete t[i];const s=e?function(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,((e,t,r)=>t.toUpperCase()+r))}(i):String(i).trim();s!==i&&delete t[i],t[s]=OB(n),r[s]=!0})),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return aB.forEach(this,((r,n)=>{null!=r&&!1!==r&&(t[n]=e&&aB.isArray(r)?r.join(", "):r)})),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map((([e,t])=>e+": "+t)).join("\n")}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const r=new this(e);return t.forEach((e=>r.set(e))),r}static accessor(e){const t=(this[TB]=this[TB]={accessors:{}}).accessors,r=this.prototype;function n(e){const n=RB(e);t[n]||(!function(e,t){const r=aB.toCamelCase(" "+t);["get","set","has"].forEach((n=>{Object.defineProperty(e,n+r,{value:function(e,r,i){return this[n].call(this,t,e,r,i)},configurable:!0})}))}(r,e),t[n]=!0)}return aB.isArray(e)?e.forEach(n):n(e),this}}MB.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),aB.freezeMethods(MB.prototype),aB.freezeMethods(MB);var CB=MB;function PB(e,t){const r=this||kB,n=t||r,i=CB.from(n.headers);let a=n.data;return aB.forEach(e,(function(e){a=e.call(r,a,i.normalize(),t?t.status:void 0)})),i.normalize(),a}function NB(e){return!(!e||!e.__CANCEL__)}function BB(e,t,r){sB.call(this,null==e?"canceled":e,sB.ERR_CANCELED,t,r),this.name="CanceledError"}aB.inherits(BB,sB,{__CANCEL__:!0});var UB=_B.isStandardBrowserEnv?{write:function(e,t,r,n,i,a){const s=[];s.push(e+"="+encodeURIComponent(t)),aB.isNumber(r)&&s.push("expires="+new Date(r).toGMTString()),aB.isString(n)&&s.push("path="+n),aB.isString(i)&&s.push("domain="+i),!0===a&&s.push("secure"),document.cookie=s.join("; ")},read:function(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}};function LB(e,t){return e&&!/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)?function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}(e,t):t}var jB=_B.isStandardBrowserEnv?function(){const e=/(msie|trident)/i.test(navigator.userAgent),t=document.createElement("a");let r;function n(r){let n=r;return e&&(t.setAttribute("href",n),n=t.href),t.setAttribute("href",n),{href:t.href,protocol:t.protocol?t.protocol.replace(/:$/,""):"",host:t.host,search:t.search?t.search.replace(/^\?/,""):"",hash:t.hash?t.hash.replace(/^#/,""):"",hostname:t.hostname,port:t.port,pathname:"/"===t.pathname.charAt(0)?t.pathname:"/"+t.pathname}}return r=n(window.location.href),function(e){const t=aB.isString(e)?n(e):e;return t.protocol===r.protocol&&t.host===r.host}}():function(){return!0};function DB(e,t){let r=0;const n=function(e,t){e=e||10;const r=new Array(e),n=new Array(e);let i,a=0,s=0;return t=void 0!==t?t:1e3,function(o){const c=Date.now(),f=n[s];i||(i=c),r[a]=o,n[a]=c;let u=s,d=0;for(;u!==a;)d+=r[u++],u%=e;if(a=(a+1)%e,a===s&&(s=(s+1)%e),c-i<t)return;const l=f&&c-f;return l?Math.round(1e3*d/l):void 0}}(50,250);return i=>{const a=i.loaded,s=i.lengthComputable?i.total:void 0,o=a-r,c=n(o);r=a;const f={loaded:a,total:s,progress:s?a/s:void 0,bytes:o,rate:c||void 0,estimated:c&&s&&a<=s?(s-a)/c:void 0,event:i};f[t?"download":"upload"]=!0,e(f)}}var FB="undefined"!=typeof XMLHttpRequest&&function(e){return new Promise((function(t,r){let n=e.data;const i=CB.from(e.headers).normalize(),a=e.responseType;let s;function o(){e.cancelToken&&e.cancelToken.unsubscribe(s),e.signal&&e.signal.removeEventListener("abort",s)}aB.isFormData(n)&&(_B.isStandardBrowserEnv||_B.isStandardBrowserWebWorkerEnv?i.setContentType(!1):i.setContentType("multipart/form-data;",!1));let c=new XMLHttpRequest;if(e.auth){const t=e.auth.username||"",r=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";i.set("Authorization","Basic "+btoa(t+":"+r))}const f=LB(e.baseURL,e.url);function u(){if(!c)return;const n=CB.from("getAllResponseHeaders"in c&&c.getAllResponseHeaders());!function(e,t,r){const n=r.config.validateStatus;r.status&&n&&!n(r.status)?t(new sB("Request failed with status code "+r.status,[sB.ERR_BAD_REQUEST,sB.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r)):e(r)}((function(e){t(e),o()}),(function(e){r(e),o()}),{data:a&&"text"!==a&&"json"!==a?c.response:c.responseText,status:c.status,statusText:c.statusText,headers:n,config:e,request:c}),c=null}if(c.open(e.method.toUpperCase(),yB(f,e.params,e.paramsSerializer),!0),c.timeout=e.timeout,"onloadend"in c?c.onloadend=u:c.onreadystatechange=function(){c&&4===c.readyState&&(0!==c.status||c.responseURL&&0===c.responseURL.indexOf("file:"))&&setTimeout(u)},c.onabort=function(){c&&(r(new sB("Request aborted",sB.ECONNABORTED,e,c)),c=null)},c.onerror=function(){r(new sB("Network Error",sB.ERR_NETWORK,e,c)),c=null},c.ontimeout=function(){let t=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded";const n=e.transitional||wB;e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),r(new sB(t,n.clarifyTimeoutError?sB.ETIMEDOUT:sB.ECONNABORTED,e,c)),c=null},_B.isStandardBrowserEnv){const t=(e.withCredentials||jB(f))&&e.xsrfCookieName&&UB.read(e.xsrfCookieName);t&&i.set(e.xsrfHeaderName,t)}void 0===n&&i.setContentType(null),"setRequestHeader"in c&&aB.forEach(i.toJSON(),(function(e,t){c.setRequestHeader(t,e)})),aB.isUndefined(e.withCredentials)||(c.withCredentials=!!e.withCredentials),a&&"json"!==a&&(c.responseType=e.responseType),"function"==typeof e.onDownloadProgress&&c.addEventListener("progress",DB(e.onDownloadProgress,!0)),"function"==typeof e.onUploadProgress&&c.upload&&c.upload.addEventListener("progress",DB(e.onUploadProgress)),(e.cancelToken||e.signal)&&(s=t=>{c&&(r(!t||t.type?new BB(null,e,c):t),c.abort(),c=null)},e.cancelToken&&e.cancelToken.subscribe(s),e.signal&&(e.signal.aborted?s():e.signal.addEventListener("abort",s)));const d=function(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}(f);d&&-1===_B.protocols.indexOf(d)?r(new sB("Unsupported protocol "+d+":",sB.ERR_BAD_REQUEST,e)):c.send(n||null)}))};const qB={http:null,xhr:FB};aB.forEach(qB,((e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch(e){}Object.defineProperty(e,"adapterName",{value:t})}}));var zB=e=>{e=aB.isArray(e)?e:[e];const{length:t}=e;let r,n;for(let i=0;i<t&&(r=e[i],!(n=aB.isString(r)?qB[r.toLowerCase()]:r));i++);if(!n){if(!1===n)throw new sB(`Adapter ${r} is not supported by the environment`,"ERR_NOT_SUPPORT");throw new Error(aB.hasOwnProp(qB,r)?`Adapter '${r}' is not available in the build`:`Unknown adapter '${r}'`)}if(!aB.isFunction(n))throw new TypeError("adapter is not a function");return n};function KB(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new BB(null,e)}function HB(e){KB(e),e.headers=CB.from(e.headers),e.data=PB.call(e,e.transformRequest),-1!==["post","put","patch"].indexOf(e.method)&&e.headers.setContentType("application/x-www-form-urlencoded",!1);return zB(e.adapter||kB.adapter)(e).then((function(t){return KB(e),t.data=PB.call(e,e.transformResponse,t),t.headers=CB.from(t.headers),t}),(function(t){return NB(t)||(KB(e),t&&t.response&&(t.response.data=PB.call(e,e.transformResponse,t.response),t.response.headers=CB.from(t.response.headers))),Promise.reject(t)}))}const GB=e=>e instanceof CB?e.toJSON():e;function VB(e,t){t=t||{};const r={};function n(e,t,r){return aB.isPlainObject(e)&&aB.isPlainObject(t)?aB.merge.call({caseless:r},e,t):aB.isPlainObject(t)?aB.merge({},t):aB.isArray(t)?t.slice():t}function i(e,t,r){return aB.isUndefined(t)?aB.isUndefined(e)?void 0:n(void 0,e,r):n(e,t,r)}function a(e,t){if(!aB.isUndefined(t))return n(void 0,t)}function s(e,t){return aB.isUndefined(t)?aB.isUndefined(e)?void 0:n(void 0,e):n(void 0,t)}function o(r,i,a){return a in t?n(r,i):a in e?n(void 0,r):void 0}const c={url:a,method:a,data:a,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials: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:o,headers:(e,t)=>i(GB(e),GB(t),!0)};return aB.forEach(Object.keys(Object.assign({},e,t)),(function(n){const a=c[n]||i,s=a(e[n],t[n],n);aB.isUndefined(s)&&a!==o||(r[n]=s)})),r}const WB="1.4.0",XB={};["object","boolean","number","function","string","symbol"].forEach(((e,t)=>{XB[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}}));const $B={};XB.transitional=function(e,t,r){function n(e,t){return"[Axios v1.4.0] Transitional option '"+e+"'"+t+(r?". "+r:"")}return(r,i,a)=>{if(!1===e)throw new sB(n(i," has been removed"+(t?" in "+t:"")),sB.ERR_DEPRECATED);return t&&!$B[i]&&($B[i]=!0,console.warn(n(i," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(r,i,a)}};var JB={assertOptions:function(e,t,r){if("object"!=typeof e)throw new sB("options must be an object",sB.ERR_BAD_OPTION_VALUE);const n=Object.keys(e);let i=n.length;for(;i-- >0;){const a=n[i],s=t[a];if(s){const t=e[a],r=void 0===t||s(t,a,e);if(!0!==r)throw new sB("option "+a+" must be "+r,sB.ERR_BAD_OPTION_VALUE)}else if(!0!==r)throw new sB("Unknown option "+a,sB.ERR_BAD_OPTION)}},validators:XB};const YB=JB.validators;class QB{constructor(e){this.defaults=e,this.interceptors={request:new vB,response:new vB}}request(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{},t=VB(this.defaults,t);const{transitional:r,paramsSerializer:n,headers:i}=t;let a;void 0!==r&&JB.assertOptions(r,{silentJSONParsing:YB.transitional(YB.boolean),forcedJSONParsing:YB.transitional(YB.boolean),clarifyTimeoutError:YB.transitional(YB.boolean)},!1),null!=n&&(aB.isFunction(n)?t.paramsSerializer={serialize:n}:JB.assertOptions(n,{encode:YB.function,serialize:YB.function},!0)),t.method=(t.method||this.defaults.method||"get").toLowerCase(),a=i&&aB.merge(i.common,i[t.method]),a&&aB.forEach(["delete","get","head","post","put","patch","common"],(e=>{delete i[e]})),t.headers=CB.concat(a,i);const s=[];let o=!0;this.interceptors.request.forEach((function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(o=o&&e.synchronous,s.unshift(e.fulfilled,e.rejected))}));const c=[];let f;this.interceptors.response.forEach((function(e){c.push(e.fulfilled,e.rejected)}));let u,d=0;if(!o){const e=[HB.bind(this),void 0];for(e.unshift.apply(e,s),e.push.apply(e,c),u=e.length,f=Promise.resolve(t);d<u;)f=f.then(e[d++],e[d++]);return f}u=s.length;let l=t;for(d=0;d<u;){const e=s[d++],t=s[d++];try{l=e(l)}catch(e){t.call(this,e);break}}try{f=HB.call(this,l)}catch(e){return Promise.reject(e)}for(d=0,u=c.length;d<u;)f=f.then(c[d++],c[d++]);return f}getUri(e){return yB(LB((e=VB(this.defaults,e)).baseURL,e.url),e.params,e.paramsSerializer)}}aB.forEach(["delete","get","head","options"],(function(e){QB.prototype[e]=function(t,r){return this.request(VB(r||{},{method:e,url:t,data:(r||{}).data}))}})),aB.forEach(["post","put","patch"],(function(e){function t(t){return function(r,n,i){return this.request(VB(i||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:r,data:n}))}}QB.prototype[e]=t(),QB.prototype[e+"Form"]=t(!0)}));var ZB=QB;class eU{constructor(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");let t;this.promise=new Promise((function(e){t=e}));const r=this;this.promise.then((e=>{if(!r._listeners)return;let t=r._listeners.length;for(;t-- >0;)r._listeners[t](e);r._listeners=null})),this.promise.then=e=>{let t;const n=new Promise((e=>{r.subscribe(e),t=e})).then(e);return n.cancel=function(){r.unsubscribe(t)},n},e((function(e,n,i){r.reason||(r.reason=new BB(e,n,i),t(r.reason))}))}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}static source(){let e;const t=new eU((function(t){e=t}));return{token:t,cancel:e}}}var tU=eU;const rU={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(rU).forEach((([e,t])=>{rU[t]=e}));var nU=rU;const iU=function e(t){const r=new ZB(t),n=TN(ZB.prototype.request,r);return aB.extend(n,ZB.prototype,r,{allOwnKeys:!0}),aB.extend(n,r,null,{allOwnKeys:!0}),n.create=function(r){return e(VB(t,r))},n}(kB);iU.Axios=ZB,iU.CanceledError=BB,iU.CancelToken=tU,iU.isCancel=NB,iU.VERSION=WB,iU.toFormData=hB,iU.AxiosError=sB,iU.Cancel=iU.CanceledError,iU.all=function(e){return Promise.all(e)},iU.spread=function(e){return function(t){return e.apply(null,t)}},iU.isAxiosError=function(e){return aB.isObject(e)&&!0===e.isAxiosError},iU.mergeConfig=VB,iU.AxiosHeaders=CB,iU.formToJSON=e=>EB(aB.isHTMLForm(e)?new FormData(e):e),iU.HttpStatusCode=nU,iU.default=iU;var aU=iU;const sU="https://guardian.sandbox.imtbl.com".replace(/\/+$/,"");class oU{basePath;axios;configuration;constructor(e,t=sU,r=aU){this.basePath=t,this.axios=r,e&&(this.configuration=e,this.basePath=e.basePath||this.basePath)}}class cU extends Error{field;constructor(e,t){super(t),this.field=e,this.name="RequiredError"}}const fU="https://example.com",uU=function(e,t,r){if(null==r)throw new cU(t,`Required parameter ${t} was null or undefined when calling ${e}.`)},dU=async function(e,t){if(t&&t.accessToken){const r="function"==typeof t.accessToken?await t.accessToken():await t.accessToken;e.Authorization="Bearer "+r}};function lU(e,t,r=""){null!=t&&("object"==typeof t?Array.isArray(t)?t.forEach((t=>lU(e,t,r))):Object.keys(t).forEach((n=>lU(e,t[n],`${r}${""!==r?".":""}${n}`))):e.has(r)?e.append(r,t):e.set(r,t))}const hU=function(e,...t){const r=new URLSearchParams(e.search);lU(r,t),e.search=r.toString()},pU=function(e,t,r){const n="string"!=typeof e;return(n&&r&&r.isJsonMime?r.isJsonMime(t.headers["Content-Type"]):n)?JSON.stringify(void 0!==e?e:{}):e||""},bU=function(e){return e.pathname+e.search+e.hash},gU=function(e,t,r,n){return(i=t,a=r)=>{const s={...e.options,url:(n?.basePath||a)+e.url};return i.request(s)}},mU=function(e){const t=function(e){return{approvePendingTransaction:async(t,r,n={})=>{uU("approvePendingTransaction","payloadHash",t),uU("approvePendingTransaction","transactionApprovalRequest",r);const i="/guardian/v1/transactions/{payloadHash}/approve".replace("{payloadHash}",encodeURIComponent(String(t))),a=new URL(i,fU);let s;e&&(s=e.baseOptions);const o={method:"POST",...s,...n},c={};await dU(c,e),c["Content-Type"]="application/json",hU(a,{});let f=s&&s.headers?s.headers:{};return o.headers={...c,...f,...n.headers},o.data=pU(r,o,e),{url:bU(a),options:o}},evaluateTransaction:async(t,r,n={})=>{uU("evaluateTransaction","id",t),uU("evaluateTransaction","transactionEvaluationRequest",r);const i="/guardian/v1/transactions/{id}/evaluate".replace("{id}",encodeURIComponent(String(t))),a=new URL(i,fU);let s;e&&(s=e.baseOptions);const o={method:"POST",...s,...n},c={};await dU(c,e),c["Content-Type"]="application/json",hU(a,{});let f=s&&s.headers?s.headers:{};return o.headers={...c,...f,...n.headers},o.data=pU(r,o,e),{url:bU(a),options:o}},getTransactionByID:async(t,r,n,i={})=>{uU("getTransactionByID","transactionID",t),uU("getTransactionByID","chainType",r);const a="/guardian/v1/transactions/{transactionID}".replace("{transactionID}",encodeURIComponent(String(t))),s=new URL(a,fU);let o;e&&(o=e.baseOptions);const c={method:"GET",...o,...i},f={},u={};await dU(f,e),void 0!==r&&(u.chainType=r),void 0!==n&&(u.chainID=n),hU(s,u);let d=o&&o.headers?o.headers:{};return c.headers={...f,...d,...i.headers},{url:bU(s),options:c}}}}(e);return{async approvePendingTransaction(r,n,i){const a=await t.approvePendingTransaction(r,n,i);return gU(a,aU,sU,e)},async evaluateTransaction(r,n,i){const a=await t.evaluateTransaction(r,n,i);return gU(a,aU,sU,e)},async getTransactionByID(r,n,i,a){const s=await t.getTransactionByID(r,n,i,a);return gU(s,aU,sU,e)}}};class yU extends oU{approvePendingTransaction(e,t){return mU(this.configuration).approvePendingTransaction(e.payloadHash,e.transactionApprovalRequest,t).then((e=>e(this.axios,this.basePath)))}evaluateTransaction(e,t){return mU(this.configuration).evaluateTransaction(e.id,e.transactionEvaluationRequest,t).then((e=>e(this.axios,this.basePath)))}getTransactionByID(e,t){return mU(this.configuration).getTransactionByID(e.transactionID,e.chainType,e.chainID,t).then((e=>e(this.axios,this.basePath)))}}class vU{apiKey;username;password;accessToken;basePath;baseOptions;formDataCtor;constructor(e={}){this.apiKey=e.apiKey,this.username=e.username,this.password=e.password,this.accessToken=e.accessToken,this.basePath=e.basePath,this.baseOptions=e.baseOptions,this.formDataCtor=e.formDataCtor}isJsonMime(e){const t=new RegExp("^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$","i");return null!==e&&(t.test(e)||"application/json-patch+json"===e.toLowerCase())}}const wU="starkex",_U="evm";function EU(e){const t=-1!==new ce(e,16).cmp(new ce(27))?new ce(e,16).sub(new ce(27)).toNumber():new ce(e,16).toNumber();return e.trim()?t:void 0}async function AU(e,t){const r=function(e,t=64){const r=Gf(e);return{r:new ce(r.substring(0,t),"hex"),s:new ce(r.substring(t,2*t),"hex"),recoveryParam:EU(r.substring(2*t,2*t+2))}}(await t.signMessage(e));return Wf(Kf((n=r).r.toString(16),64)+Kf(n.s.toString(16),64)+Kf(n.recoveryParam?.toString(16)||"",2));var n}function SU(e){switch(e.type){case"ERC721":return{type:"ERC721",data:{token_id:e.tokenId,token_address:e.tokenAddress}};case"ERC20":return{type:"ERC20",data:{token_address:e.tokenAddress}};default:return{type:"ETH",data:{decimals:18}}}}const kU={erc1271:Object.freeze({__proto__:null,abi:[{type:"function",name:"isValidSignature",constant:!0,inputs:[{type:"bytes32"},{type:"bytes"}],outputs:[{type:"bytes4"}],payable:!1,stateMutability:"view"}],returns:{isValidSignatureBytes32:"0x1626ba7e"}}),factory:Object.freeze({__proto__:null,abi:[{type:"function",name:"deploy",constant:!1,inputs:[{type:"address"},{type:"bytes32"}],outputs:[],payable:!0,stateMutability:"payable"}]}),mainModule:Object.freeze({__proto__:null,abi:[{type:"function",name:"nonce",constant:!0,inputs:[],outputs:[{type:"uint256"}],payable:!1,stateMutability:"view"},{type:"function",name:"readNonce",constant:!0,inputs:[{type:"uint256"}],outputs:[{type:"uint256"}],payable:!1,stateMutability:"view"},{type:"function",name:"updateImplementation",constant:!1,inputs:[{type:"address"}],outputs:[],payable:!1,stateMutability:"nonpayable"},{type:"function",name:"selfExecute",constant:!1,inputs:[{components:[{type:"bool",name:"delegateCall"},{type:"bool",name:"revertOnError"},{type:"uint256",name:"gasLimit"},{type:"address",name:"target"},{type:"uint256",name:"value"},{type:"bytes",name:"data"}],type:"tuple[]"}],outputs:[],payable:!1,stateMutability:"nonpayable"},{type:"function",name:"execute",constant:!1,inputs:[{components:[{type:"bool",name:"delegateCall"},{type:"bool",name:"revertOnError"},{type:"uint256",name:"gasLimit"},{type:"address",name:"target"},{type:"uint256",name:"value"},{type:"bytes",name:"data"}],type:"tuple[]"},{type:"uint256"},{type:"bytes"}],outputs:[],payable:!1,stateMutability:"nonpayable"},{type:"function",name:"createContract",inputs:[{type:"bytes"}],payable:!0,stateMutability:"payable"}]}),mainModuleUpgradable:Object.freeze({__proto__:null,abi:[{type:"function",name:"updateImageHash",constant:!0,inputs:[{type:"bytes32"}],outputs:[],payable:!1,stateMutability:"view"},{type:"function",name:"imageHash",constant:!0,inputs:[],outputs:[{type:"bytes32"}],payable:!1,stateMutability:"view"}]}),sequenceUtils:Object.freeze({__proto__:null,abi:[{inputs:[{internalType:"address",name:"_factory",type:"address"},{internalType:"address",name:"_mainModule",type:"address"}],stateMutability:"nonpayable",type:"constructor"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"_wallet",type:"address"},{indexed:!0,internalType:"bytes32",name:"_imageHash",type:"bytes32"},{indexed:!1,internalType:"uint256",name:"_threshold",type:"uint256"},{indexed:!1,internalType:"bytes",name:"_signers",type:"bytes"}],name:"RequiredConfig",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"_wallet",type:"address"},{indexed:!0,internalType:"address",name:"_signer",type:"address"}],name:"RequiredSigner",type:"event"},{inputs:[{internalType:"address",name:"_addr",type:"address"}],name:"callBalanceOf",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"callBlockNumber",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"_i",type:"uint256"}],name:"callBlockhash",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"callChainId",outputs:[{internalType:"uint256",name:"id",type:"uint256"}],stateMutability:"pure",type:"function"},{inputs:[{internalType:"address",name:"_addr",type:"address"}],name:"callCode",outputs:[{internalType:"bytes",name:"code",type:"bytes"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"_addr",type:"address"}],name:"callCodeHash",outputs:[{internalType:"bytes32",name:"codeHash",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"_addr",type:"address"}],name:"callCodeSize",outputs:[{internalType:"uint256",name:"size",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"callCoinbase",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"callDifficulty",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"callGasLeft",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"callGasLimit",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"callGasPrice",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"callOrigin",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"callTimestamp",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"}],name:"knownImageHashes",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"",type:"bytes32"}],name:"lastImageHashUpdate",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"}],name:"lastSignerUpdate",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"}],name:"lastWalletUpdate",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{components:[{internalType:"bool",name:"delegateCall",type:"bool"},{internalType:"bool",name:"revertOnError",type:"bool"},{internalType:"uint256",name:"gasLimit",type:"uint256"},{internalType:"address",name:"target",type:"address"},{internalType:"uint256",name:"value",type:"uint256"},{internalType:"bytes",name:"data",type:"bytes"}],internalType:"struct IModuleCalls.Transaction[]",name:"_txs",type:"tuple[]"}],name:"multiCall",outputs:[{internalType:"bool[]",name:"_successes",type:"bool[]"},{internalType:"bytes[]",name:"_results",type:"bytes[]"}],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"_wallet",type:"address"},{internalType:"uint256",name:"_threshold",type:"uint256"},{components:[{internalType:"uint256",name:"weight",type:"uint256"},{internalType:"address",name:"signer",type:"address"}],internalType:"struct RequireUtils.Member[]",name:"_members",type:"tuple[]"},{internalType:"bool",name:"_index",type:"bool"}],name:"publishConfig",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"_wallet",type:"address"},{internalType:"bytes32",name:"_hash",type:"bytes32"},{internalType:"uint256",name:"_sizeMembers",type:"uint256"},{internalType:"bytes",name:"_signature",type:"bytes"},{internalType:"bool",name:"_index",type:"bool"}],name:"publishInitialSigners",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"_wallet",type:"address"},{internalType:"uint256",name:"_nonce",type:"uint256"}],name:"requireMinNonce",outputs:[],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"_expiration",type:"uint256"}],name:"requireNonExpired",outputs:[],stateMutability:"view",type:"function"}]}),requireFreshSigner:Object.freeze({__proto__:null,abi:[{inputs:[{internalType:"address",name:"",type:"address"}],name:"requireFreshSigner",outputs:[],stateMutability:"nonpayable",type:"function"}]})};function xU(){return xU=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},xU.apply(this,arguments)}var TU;!function(e){e[e.DEBUG=1]="DEBUG",e[e.INFO=2]="INFO",e[e.WARN=3]="WARN",e[e.ERROR=4]="ERROR",e[e.DISABLED=5]="DISABLED"}(TU||(TU={}));function RU(){return RU=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},RU.apply(this,arguments)}new class{constructor(e){this.config=e,this.logLevel=void 0,this.configure(e)}configure(e){switch(this.config=xU({},this.config,e),this.config.logLevel){case"DEBUG":this.logLevel=TU.DEBUG;break;case"INFO":default:this.logLevel=TU.INFO;break;case"WARN":this.logLevel=TU.WARN;break;case"ERROR":this.logLevel=TU.ERROR;break;case"DISABLED":this.logLevel=TU.DISABLED}void 0===this.config.silence&&(this.config.silence=!1)}debug(e,...t){!0!==this.config.silence&&this.logLevel===TU.DEBUG&&console.log(e,...t)}info(e,...t){!0!==this.config.silence&&this.logLevel<=TU.INFO&&console.log(e,...t)}warn(e,...t){!0!==this.config.silence&&this.logLevel<=TU.WARN&&(console.warn(e,...t),this.config.onwarn&&this.config.onwarn(e,t))}error(e,...t){!0!==this.config.silence&&this.logLevel<=TU.ERROR&&(console.error(e,...t),this.config.onerror&&this.config.onerror(e,t))}}({logLevel:"INFO",silence:!0});const OU=(e,t=!1)=>(((e,t=!1,r=!1)=>{if(!e)throw new Error("invalid network config: empty config");const n=[];if(Array.isArray(e)?n.push(...e):n.push(e),0===n.length){if(t)throw new Error("invalid network config: empty config");return!1}const i=n.map((e=>e.chainId)).sort(),a=i.filter(((e,t)=>i.indexOf(e)!==t));if(a.length>0){if(t)throw new Error(`invalid network config: duplicate chainIds ${a}`);return!1}n.forEach((e=>e.name=e.name.toLowerCase()));const s=n.map((e=>e.name)).sort(),o=s.filter(((e,t)=>s.indexOf(e)!==t));if(o.length>0){if(t)throw new Error(`invalid network config: duplicate network names ${o}`);return!1}let c=!1,f=!1;for(let e=0;e<n.length;e++){const i=n[e];if(!(i.rpcUrl&&""!==i.rpcUrl||i.provider)){if(t)throw new Error(`invalid network config for chainId ${i.chainId}: rpcUrl or provider must be provided`);return!1}if(!r&&!i.relayer){if(t)throw new Error(`invalid network config for chainId ${i.chainId}: relayer must be provided`);return!1}if(i.isDefaultChain){if(c){if(t)throw new Error(`invalid network config for chainId ${i.chainId}: DefaultChain is already set by another config`);return!1}c=!0}if(i.isAuthChain){if(f&&t)throw new Error(`invalid network config for chainId ${i.chainId}: AuthChain is already set by another config`);f=!0}}if(!c){if(t)throw new Error("invalid network config: DefaultChain must be set");return!1}if(!f){if(t)throw new Error("invalid network config: AuthChain must be set");return!1}})(e,!0,t),e),IU=e=>OU(MU(e)),MU=e=>{if(!e)return[];const t=e.sort(((e,t)=>e.chainId===t.chainId?0:e.chainId<t.chainId?-1:1)),r=t.findIndex((e=>e.isDefaultChain));r>0&&t.splice(0,0,t.splice(r,1)[0]);const n=t.findIndex((e=>e.isAuthChain&&!0!==e.isDefaultChain));return n>0&&t.splice(1,0,t.splice(n,1)[0]),t},CU=(e,t)=>"string"==typeof e?(t=t||{},e.replace(/\$\{\s*([$#@\-\d\w]+)\s*\}/gim,(function(e,r){let n=t[r];return n="function"==typeof n?n():null==n?"":"object"==typeof n||"symbol"==typeof n?n.toString():n.valueOf(),n}))):"";let PU;!function(e){e[e.MAINNET=1]="MAINNET",e[e.ROPSTEN=3]="ROPSTEN",e[e.RINKEBY=4]="RINKEBY",e[e.GOERLI=5]="GOERLI",e[e.KOVAN=42]="KOVAN",e[e.POLYGON=137]="POLYGON",e[e.POLYGON_MUMBAI=80001]="POLYGON_MUMBAI",e[e.POLYGON_ZKEVM=1101]="POLYGON_ZKEVM",e[e.BSC=56]="BSC",e[e.BSC_TESTNET=97]="BSC_TESTNET",e[e.OPTIMISM=10]="OPTIMISM",e[e.OPTIMISM_TESTNET=69]="OPTIMISM_TESTNET",e[e.ARBITRUM=42161]="ARBITRUM",e[e.ARBITRUM_GOERLI=421613]="ARBITRUM_GOERLI",e[e.ARBITRUM_NOVA=42170]="ARBITRUM_NOVA",e[e.AVALANCHE=43114]="AVALANCHE",e[e.AVALANCHE_TESTNET=43113]="AVALANCHE_TESTNET",e[e.FANTOM=250]="FANTOM",e[e.FANTOM_TESTNET=4002]="FANTOM_TESTNET",e[e.GNOSIS=100]="GNOSIS",e[e.AURORA=1313161554]="AURORA",e[e.AURORA_TESTNET=1313161556]="AURORA_TESTNET",e[e.BASE_GOERLI=84531]="BASE_GOERLI"}(PU||(PU={}));const NU=e=>CU("https://${network}-indexer.sequence.app",{network:e}),BU=e=>CU("https://${network}-relayer.sequence.app",{network:e}),UU=e=>CU("https://nodes.sequence.app/${network}",{network:e}),LU={[PU.MAINNET]:{chainId:PU.MAINNET,name:"mainnet",title:"Ethereum",blockExplorer:{name:"Etherscan",rootUrl:"https://etherscan.io/"},ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e"},[PU.ROPSTEN]:{chainId:PU.ROPSTEN,name:"ropsten",title:"Ropsten",testnet:!0,blockExplorer:{name:"Etherscan (Ropsten)",rootUrl:"https://ropsten.etherscan.io/"},ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e"},[PU.RINKEBY]:{chainId:PU.RINKEBY,name:"rinkeby",title:"Rinkeby",testnet:!0,blockExplorer:{name:"Etherscan (Rinkeby)",rootUrl:"https://rinkeby.etherscan.io/"},ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",disabled:!0},[PU.GOERLI]:{chainId:PU.GOERLI,name:"goerli",title:"Goerli",testnet:!0,blockExplorer:{name:"Etherscan (Goerli)",rootUrl:"https://goerli.etherscan.io/"},ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e"},[PU.KOVAN]:{chainId:PU.KOVAN,name:"kovan",title:"Kovan",testnet:!0,blockExplorer:{name:"Etherscan (Kovan)",rootUrl:"https://kovan.etherscan.io/"}},[PU.POLYGON]:{chainId:PU.POLYGON,name:"polygon",title:"Polygon",blockExplorer:{name:"Polygonscan",rootUrl:"https://polygonscan.com/"}},[PU.POLYGON_MUMBAI]:{chainId:PU.POLYGON_MUMBAI,name:"mumbai",title:"Polygon Mumbai",testnet:!0,blockExplorer:{name:"Polygonscan (Mumbai)",rootUrl:"https://mumbai.polygonscan.com/"}},[PU.POLYGON_ZKEVM]:{chainId:PU.POLYGON_ZKEVM,name:"polygon-zkevm",title:"Polygon zkEVM",blockExplorer:{name:"Polygonscan (zkEVM)",rootUrl:"https://zkevm.polygonscan.com/"}},[PU.BSC]:{chainId:PU.BSC,name:"bsc",title:"BNB Smart Chain",blockExplorer:{name:"BSCScan",rootUrl:"https://bscscan.com/"}},[PU.BSC_TESTNET]:{chainId:PU.BSC_TESTNET,name:"bsc-testnet",title:"BNB Smart Chain Testnet",testnet:!0,blockExplorer:{name:"BSCScan (Testnet)",rootUrl:"https://testnet.bscscan.com/"}},[PU.OPTIMISM]:{chainId:PU.OPTIMISM,name:"optimism",title:"Optimism",blockExplorer:{name:"Etherscan (Optimism)",rootUrl:"https://optimistic.etherscan.io/"}},[PU.OPTIMISM_TESTNET]:{chainId:PU.OPTIMISM_TESTNET,name:"optimism-testnet",title:"Optimistic Kovan",testnet:!0,blockExplorer:{name:"Etherscan (Optimism Testnet)",rootUrl:"https://kovan-optimistic.etherscan.io/"}},[PU.ARBITRUM]:{chainId:PU.ARBITRUM,name:"arbitrum",title:"Arbitrum One",blockExplorer:{name:"Arbiscan",rootUrl:"https://arbiscan.io/"}},[PU.ARBITRUM_GOERLI]:{chainId:PU.ARBITRUM_GOERLI,name:"arbitrum-goerli",title:"Arbitrum Goerli",testnet:!0,blockExplorer:{name:"Arbiscan (Testnet)",rootUrl:"https://testnet.arbiscan.io/"}},[PU.ARBITRUM_NOVA]:{chainId:PU.ARBITRUM_NOVA,name:"arbitrum-nova",title:"Arbitrum Nova",blockExplorer:{name:"Nova Explorer",rootUrl:"https://nova-explorer.arbitrum.io/"}},[PU.AVALANCHE]:{chainId:PU.AVALANCHE,name:"avalanche",title:"Avalanche",blockExplorer:{name:"Snowtrace",rootUrl:"https://snowtrace.io/"}},[PU.AVALANCHE_TESTNET]:{chainId:PU.AVALANCHE_TESTNET,name:"avalanche-testnet",title:"Avalanche Testnet",testnet:!0,blockExplorer:{name:"Snowtrace (Testnet)",rootUrl:"https://testnet.snowtrace.io/"}},[PU.FANTOM]:{chainId:PU.FANTOM,name:"fantom",title:"Fantom",blockExplorer:{name:"FTMScan",rootUrl:"https://ftmscan.com/"}},[PU.FANTOM_TESTNET]:{chainId:PU.FANTOM_TESTNET,name:"fantom-testnet",title:"Fantom Testnet",testnet:!0,blockExplorer:{name:"FTMScan (Testnet)",rootUrl:"https://testnet.ftmscan.com/"}},[PU.GNOSIS]:{chainId:PU.GNOSIS,name:"gnosis",title:"Gnosis Chain",blockExplorer:{name:"Gnosis Chain Explorer",rootUrl:"https://blockscout.com/xdai/mainnet/"}},[PU.AURORA]:{chainId:PU.AURORA,name:"aurora",title:"Aurora",blockExplorer:{name:"Aurora Explorer",rootUrl:"https://aurorascan.dev/"}},[PU.AURORA_TESTNET]:{chainId:PU.AURORA_TESTNET,name:"aurora-testnet",title:"Aurora Testnet",blockExplorer:{name:"Aurora Explorer (Testnet)",rootUrl:"https://testnet.aurorascan.dev/"}},[PU.BASE_GOERLI]:{chainId:PU.BASE_GOERLI,name:"base-goerli",title:"Base Goerli",blockExplorer:{name:"Base Goerli Explorer",rootUrl:"https://goerli.basescan.org/"}}};IU([RU({},LU[PU.MAINNET],{rpcUrl:UU("mainnet"),relayer:{url:BU("mainnet")},indexerUrl:NU("mainnet")}),RU({},LU[PU.POLYGON],{rpcUrl:UU("polygon"),relayer:{url:BU("polygon")},indexerUrl:NU("polygon"),isDefaultChain:!0,isAuthChain:!0}),RU({},LU[PU.BSC],{rpcUrl:UU("bsc"),indexerUrl:NU("bsc"),relayer:{url:BU("bsc")}}),RU({},LU[PU.AVALANCHE],{rpcUrl:UU("avalanche"),indexerUrl:NU("avalanche"),relayer:{url:BU("avalanche")}}),RU({},LU[PU.ARBITRUM],{rpcUrl:UU("arbitrum"),indexerUrl:NU("arbitrum"),relayer:{url:BU("arbitrum")}}),RU({},LU[PU.ARBITRUM_NOVA],{rpcUrl:UU("arbitrum-nova"),indexerUrl:NU("arbitrum-nova"),relayer:{url:BU("arbitrum-nova")}}),RU({},LU[PU.OPTIMISM],{rpcUrl:UU("optimism"),indexerUrl:NU("optimism"),relayer:{url:BU("optimism")}}),RU({},LU[PU.POLYGON_ZKEVM],{rpcUrl:UU("polygon-zkevm"),indexerUrl:NU("polygon-zkevm"),relayer:{url:BU("polygon-zkevm")}}),RU({},LU[PU.GNOSIS],{rpcUrl:UU("gnosis"),indexerUrl:NU("gnosis"),relayer:{url:BU("gnosis")}})]),IU([RU({},LU[PU.RINKEBY],{rpcUrl:UU("rinkeby"),relayer:{url:BU("rinkeby")},indexerUrl:NU("rinkeby")}),RU({},LU[PU.GOERLI],{rpcUrl:UU("goerli"),relayer:{url:BU("goerli")},indexerUrl:NU("goerli")}),RU({},LU[PU.POLYGON_MUMBAI],{rpcUrl:UU("mumbai"),relayer:{url:BU("mumbai")},indexerUrl:NU("mumbai"),isDefaultChain:!0,isAuthChain:!0}),RU({},LU[PU.BSC_TESTNET],{rpcUrl:UU("bsc-testnet"),relayer:{url:BU("bsc-testnet")},indexerUrl:NU("bsc-testnet")}),RU({},LU[PU.ARBITRUM_GOERLI],{rpcUrl:UU("arbitrum-goerli"),relayer:{url:BU("arbitrum-goerli")},indexerUrl:NU("arbitrum-goerli")}),RU({},LU[PU.BASE_GOERLI],{rpcUrl:UU("base-goerli"),relayer:{url:BU("base-goerli")},indexerUrl:NU("base-goerli")})]);function jU(){return jU=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},jU.apply(this,arguments)}let DU;!function(e){e.ethCall="eth_call",e.ethGetBalance="eth_getBalance",e.ethGetCode="eth_getCode"}(DU||(DU={}));let FU,qU;jU({},{batchSize:50,timeWindow:50,contract:"0xd130B43062D875a4B7aF3f8fc036Bc6e9D3E1B3E",verbose:!1});try{FU=localStorage}catch(e){const t=new Map;FU={getItem:e=>{var r;return null!=(r=t.get(e))?r:null},setItem:(e,r)=>t.set(e,r),removeItem:e=>t.delete(e)}}function zU(e){return void 0!==e.address&&!function(e){return KU(e)||HU(e)||GU(e)}(e)}function KU(e){const t=e;return void 0!==t.signature&&void 0===t.address}function HU(e){const t=e;return void 0!==t.r&&void 0!==t.s&&void 0!==t.v&&void 0!==t.t}function GU(e){const t=e;return void 0!==t.address&&void 0!==t.signature}!function(e){e[e.EOA=0]="EOA",e[e.Address=1]="Address",e[e.Full=2]="Full"}(qU||(qU={}));const VU=e=>{if("string"==typeof e)return VU((e=>{if("string"!=typeof e)return e;const t=e.replace("0x",""),r=He.from(`0x${t.slice(0,4)}`).toNumber(),n=[];for(let e=4;e<t.length;){const r=He.from(t.slice(e,e+2)).toNumber();e+=2;const i=He.from(`0x${t.slice(e,e+2)}`).toNumber();switch(e+=2,r){case qU.Address:const r=cr(t.slice(e,e+40));e+=40,n.push({weight:i,address:r});break;case qU.EOA:const a=ke(`0x${t.slice(e,e+132)}`);e+=132;const s=Le(a.slice(0,65)),o=s.r,c=s.s,f=s.v,u=He.from(a[a.length-1]).toNumber();n.push({weight:i,signature:a,r:o,s:c,v:f,t:u});break;case qU.Full:const d=cr(t.slice(e,e+40));e+=40;const l=He.from(`0x${t.slice(e,e+4)}`).mul(2).toNumber();e+=4;const h=ke(`0x${t.slice(e,e+l)}`);e+=l,n.push({weight:i,address:d,signature:h});break;default:throw Error("Signature type not supported")}}return{threshold:r,signers:n}})(e));const t=e.signers.map((e=>{if(zU(e))return Hc(["uint8","uint8","address"],[qU.Address,e.weight,e.address]);if(HU(e))return Hc(["uint8","uint8","bytes32","bytes32","uint8","uint8"],[qU.EOA,e.weight,e.r,e.s,e.v,e.t]);if(GU(e)){const t=ke(e.signature).length;return Hc(["uint8","uint8","address","uint16","bytes"],[qU.Full,e.weight,e.address,t,e.signature])}if(KU(e))return Hc(["uint8","uint8","bytes"],[qU.EOA,e.weight,e.signature]);throw Error("Unkwnown signature part type")}));return Hc(["uint16",...Array(t.length).fill("bytes")],[e.threshold,...t])};var WU;!function(e){e.AUTHENTICATION_ERROR="AUTHENTICATION_ERROR",e.INVALID_CONFIGURATION="INVALID_CONFIGURATION",e.WALLET_CONNECTION_ERROR="WALLET_CONNECTION_ERROR",e.NOT_LOGGED_IN_ERROR="NOT_LOGGED_IN_ERROR",e.SILENT_LOGIN_ERROR="SILENT_LOGIN_ERROR",e.REFRESH_TOKEN_ERROR="REFRESH_TOKEN_ERROR",e.USER_REGISTRATION_ERROR="USER_REGISTRATION_ERROR",e.LOGOUT_ERROR="LOGOUT_ERROR",e.TRANSFER_ERROR="TRANSFER_ERROR",e.CREATE_ORDER_ERROR="CREATE_ORDER_ERROR",e.CANCEL_ORDER_ERROR="CANCEL_ORDER_ERROR",e.EXCHANGE_TRANSFER_ERROR="EXCHANGE_TRANSFER_ERROR",e.CREATE_TRADE_ERROR="CREATE_TRADE_ERROR",e.OPERATION_NOT_SUPPORTED_ERROR="OPERATION_NOT_SUPPORTED_ERROR"}(WU||(WU={}));class XU extends Error{type;constructor(e,t){super(e),this.type=t}}const $U=async(e,t)=>{try{return await e()}catch(e){const r=`${t}: ${e.message}`||"UnknownError";throw new XU(r,t)}},JU="passport_credentials",YU="pkce_state",QU="pkce_verifier";class ZU{saveCredentials(e){if(!this.areValid(e))throw Error("Invalid credentials.");localStorage.setItem(JU,JSON.stringify(e))}getCredentials(){const e=localStorage.getItem(JU);return e?JSON.parse(e):null}areValid(e){if(e){const t=this.isTokenValid(e.access_token),r=this.isTokenValid(e.id_token);return t&&r}return!1}isTokenValid(e){try{const t=DI(e).exp??0;return t>Date.now()/1e3+3600}catch(e){return!1}}clearCredentials(){localStorage.removeItem(JU)}savePKCEData(e){localStorage.setItem(YU,e.state),localStorage.setItem(QU,e.verifier)}getPKCEData(){const e=localStorage.getItem(YU),t=localStorage.getItem(QU);return e&&t?{state:e,verifier:t}:null}}const eL={headers:{"Content-Type":"application/x-www-form-urlencoded"}};function tL(e){return new Promise((t=>{setTimeout(t,e)}))}class rL{userManager;config;deviceCredentialsManager;logoutMode;constructor(e){this.config=e,this.userManager=new class{constructor(e){this._logger=new GI("UserManager"),this.settings=new vM(e),this._client=new class{constructor(e){this._logger=new GI("OidcClient"),this.settings=new iM(e),this.metadataService=new class{constructor(e){this._settings=e,this._logger=new GI("MetadataService"),this._signingKeys=null,this._metadata=null,this._metadataUrl=this._settings.metadataUrl,this._jsonService=new rM(["application/jwk-set+json"],null,this._settings.extraHeaders),this._settings.signingKeys&&(this._logger.debug("using signingKeys from settings"),this._signingKeys=this._settings.signingKeys),this._settings.metadata&&(this._logger.debug("using metadata from settings"),this._metadata=this._settings.metadata),this._settings.fetchRequestCredentials&&(this._logger.debug("using fetchRequestCredentials from settings"),this._fetchRequestCredentials=this._settings.fetchRequestCredentials)}resetSigningKeys(){this._signingKeys=null}async getMetadata(){const e=this._logger.create("getMetadata");if(this._metadata)return e.debug("using cached values"),this._metadata;if(!this._metadataUrl)throw e.throw(new Error("No authority or metadataUrl configured on settings")),null;e.debug("getting metadata from",this._metadataUrl);const t=await this._jsonService.getJson(this._metadataUrl,{credentials:this._fetchRequestCredentials});return e.debug("merging remote JSON with seed metadata"),this._metadata=Object.assign({},this._settings.metadataSeed,t),this._metadata}getIssuer(){return this._getMetadataProperty("issuer")}getAuthorizationEndpoint(){return this._getMetadataProperty("authorization_endpoint")}getUserInfoEndpoint(){return this._getMetadataProperty("userinfo_endpoint")}getTokenEndpoint(e=!0){return this._getMetadataProperty("token_endpoint",e)}getCheckSessionIframe(){return this._getMetadataProperty("check_session_iframe",!0)}getEndSessionEndpoint(){return this._getMetadataProperty("end_session_endpoint",!0)}getRevocationEndpoint(e=!0){return this._getMetadataProperty("revocation_endpoint",e)}getKeysEndpoint(e=!0){return this._getMetadataProperty("jwks_uri",e)}async _getMetadataProperty(e,t=!1){const r=this._logger.create(`_getMetadataProperty('${e}')`),n=await this.getMetadata();if(r.debug("resolved"),void 0===n[e]){if(!0===t)return void r.warn("Metadata does not contain optional property");r.throw(new Error("Metadata does not contain property "+e))}return n[e]}async getSigningKeys(){const e=this._logger.create("getSigningKeys");if(this._signingKeys)return e.debug("returning signingKeys from cache"),this._signingKeys;const t=await this.getKeysEndpoint(!1);e.debug("got jwks_uri",t);const r=await this._jsonService.getJson(t);if(e.debug("got key set",r),!Array.isArray(r.keys))throw e.throw(new Error("Missing keys on keyset")),null;return this._signingKeys=r.keys,this._signingKeys}}(this.settings),this._claimsService=new class{constructor(e){this._settings=e,this._logger=new GI("ClaimsService")}filterProtocolClaims(e){const t={...e};if(this._settings.filterProtocolClaims){let e;e=Array.isArray(this._settings.filterProtocolClaims)?this._settings.filterProtocolClaims:fM;for(const r of e)uM.includes(r)||delete t[r]}return t}mergeClaims(e,t){const r={...e};for(const[e,n]of Object.entries(t))for(const t of Array.isArray(n)?n:[n]){const n=r[e];n?Array.isArray(n)?n.includes(t)||n.push(t):r[e]!==t&&("object"==typeof t&&this._settings.mergeClaims?r[e]=this.mergeClaims(n,t):r[e]=[n,t]):r[e]=t}return r}}(this.settings),this._validator=new class{constructor(e,t,r){this._settings=e,this._metadataService=t,this._claimsService=r,this._logger=new GI("ResponseValidator"),this._userInfoService=new class{constructor(e,t){this._settings=e,this._metadataService=t,this._logger=new GI("UserInfoService"),this._getClaimsFromJwt=async e=>{const t=this._logger.create("_getClaimsFromJwt");try{const r=XI.decode(e);return t.debug("JWT decoding successful"),r}catch(e){throw t.error("Error parsing JWT response"),e}},this._jsonService=new rM(void 0,this._getClaimsFromJwt,this._settings.extraHeaders)}async getClaims(e){const t=this._logger.create("getClaims");e||this._logger.throw(new Error("No token passed"));const r=await this._metadataService.getUserInfoEndpoint();t.debug("got userinfo url",r);const n=await this._jsonService.getJson(r,{token:e,credentials:this._settings.fetchRequestCredentials});return t.debug("got claims",n),n}}(this._settings,this._metadataService),this._tokenClient=new aM(this._settings,this._metadataService)}async validateSigninResponse(e,t){const r=this._logger.create("validateSigninResponse");this._processSigninState(e,t),r.debug("state processed"),await this._processCode(e,t),r.debug("code processed"),e.isOpenId&&this._validateIdTokenAttributes(e),r.debug("tokens validated"),await this._processClaims(e,null==t?void 0:t.skipUserInfo,e.isOpenId),r.debug("claims processed")}async validateCredentialsResponse(e,t){const r=this._logger.create("validateCredentialsResponse");e.isOpenId&&this._validateIdTokenAttributes(e),r.debug("tokens validated"),await this._processClaims(e,t,e.isOpenId),r.debug("claims processed")}async validateRefreshResponse(e,t){const r=this._logger.create("validateRefreshResponse");e.userState=t.data,null!=e.session_state||(e.session_state=t.session_state),null!=e.scope||(e.scope=t.scope),e.isOpenId&&e.id_token&&(this._validateIdTokenAttributes(e,t.id_token),r.debug("ID Token validated")),e.id_token||(e.id_token=t.id_token,e.profile=t.profile);const n=e.isOpenId&&!!e.id_token;await this._processClaims(e,!1,n),r.debug("claims processed")}validateSignoutResponse(e,t){const r=this._logger.create("validateSignoutResponse");if(t.id!==e.state&&r.throw(new Error("State does not match")),r.debug("state validated"),e.userState=t.data,e.error)throw r.warn("Response was error",e.error),new QI(e)}_processSigninState(e,t){const r=this._logger.create("_processSigninState");if(t.id!==e.state&&r.throw(new Error("State does not match")),t.client_id||r.throw(new Error("No client_id on state")),t.authority||r.throw(new Error("No authority on state")),this._settings.authority!==t.authority&&r.throw(new Error("authority mismatch on settings vs. signin state")),this._settings.client_id&&this._settings.client_id!==t.client_id&&r.throw(new Error("client_id mismatch on settings vs. signin state")),r.debug("state validated"),e.userState=t.data,null!=e.scope||(e.scope=t.scope),e.error)throw r.warn("Response was error",e.error),new QI(e);t.code_verifier&&!e.code&&r.throw(new Error("Expected code in response"))}async _processClaims(e,t=!1,r=!0){const n=this._logger.create("_processClaims");if(e.profile=this._claimsService.filterProtocolClaims(e.profile),t||!this._settings.loadUserInfo||!e.access_token)return void n.debug("not loading user info");n.debug("loading user info");const i=await this._userInfoService.getClaims(e.access_token);n.debug("user info claims received from user info endpoint"),r&&i.sub!==e.profile.sub&&n.throw(new Error("subject from UserInfo response does not match subject in ID Token")),e.profile=this._claimsService.mergeClaims(e.profile,this._claimsService.filterProtocolClaims(i)),n.debug("user info claims received, updated profile:",e.profile)}async _processCode(e,t){const r=this._logger.create("_processCode");if(e.code){r.debug("Validating code");const n=await this._tokenClient.exchangeCode({client_id:t.client_id,client_secret:t.client_secret,code:e.code,redirect_uri:t.redirect_uri,code_verifier:t.code_verifier,...t.extraTokenParams});Object.assign(e,n)}else r.debug("No code to process")}_validateIdTokenAttributes(e,t){var r;const n=this._logger.create("_validateIdTokenAttributes");n.debug("decoding ID Token JWT");const i=XI.decode(null!=(r=e.id_token)?r:"");if(i.sub||n.throw(new Error("ID Token is missing a subject claim")),t){const e=XI.decode(t);i.sub!==e.sub&&n.throw(new Error("sub in id_token does not match current sub")),i.auth_time&&i.auth_time!==e.auth_time&&n.throw(new Error("auth_time in id_token does not match original auth_time")),i.azp&&i.azp!==e.azp&&n.throw(new Error("azp in id_token does not match original azp")),!i.azp&&e.azp&&n.throw(new Error("azp not in id_token, but present in original id_token"))}e.profile=i}}(this.settings,this.metadataService,this._claimsService),this._tokenClient=new aM(this.settings,this.metadataService)}async createSigninRequest({state:e,request:t,request_uri:r,request_type:n,id_token_hint:i,login_hint:a,skipUserInfo:s,nonce:o,response_type:c=this.settings.response_type,scope:f=this.settings.scope,redirect_uri:u=this.settings.redirect_uri,prompt:d=this.settings.prompt,display:l=this.settings.display,max_age:h=this.settings.max_age,ui_locales:p=this.settings.ui_locales,acr_values:b=this.settings.acr_values,resource:g=this.settings.resource,response_mode:m=this.settings.response_mode,extraQueryParams:y=this.settings.extraQueryParams,extraTokenParams:v=this.settings.extraTokenParams}){const w=this._logger.create("createSigninRequest");if("code"!==c)throw new Error("Only the Authorization Code flow (with PKCE) is supported");const _=await this.metadataService.getAuthorizationEndpoint();w.debug("Received authorization endpoint",_);const E=new class{constructor({url:e,authority:t,client_id:r,redirect_uri:n,response_type:i,scope:a,state_data:s,response_mode:o,request_type:c,client_secret:f,nonce:u,resource:d,skipUserInfo:l,extraQueryParams:h,extraTokenParams:p,disablePKCE:b,...g}){if(this._logger=new GI("SigninRequest"),!e)throw this._logger.error("ctor: No url passed"),new Error("url");if(!r)throw this._logger.error("ctor: No client_id passed"),new Error("client_id");if(!n)throw this._logger.error("ctor: No redirect_uri passed"),new Error("redirect_uri");if(!i)throw this._logger.error("ctor: No response_type passed"),new Error("response_type");if(!a)throw this._logger.error("ctor: No scope passed"),new Error("scope");if(!t)throw this._logger.error("ctor: No authority passed"),new Error("authority");this.state=new oM({data:s,request_type:c,code_verifier:!b,client_id:r,authority:t,redirect_uri:n,response_mode:o,client_secret:f,scope:a,extraTokenParams:p,skipUserInfo:l});const m=new URL(e);m.searchParams.append("client_id",r),m.searchParams.append("redirect_uri",n),m.searchParams.append("response_type",i),m.searchParams.append("scope",a),u&&m.searchParams.append("nonce",u),m.searchParams.append("state",this.state.id),this.state.code_challenge&&(m.searchParams.append("code_challenge",this.state.code_challenge),m.searchParams.append("code_challenge_method","S256")),d&&(Array.isArray(d)?d:[d]).forEach((e=>m.searchParams.append("resource",e)));for(const[e,t]of Object.entries({response_mode:o,...g,...h}))null!=t&&m.searchParams.append(e,t.toString());this.url=m.href}}({url:_,authority:this.settings.authority,client_id:this.settings.client_id,redirect_uri:u,response_type:c,scope:f,state_data:e,prompt:d,display:l,max_age:h,ui_locales:p,id_token_hint:i,login_hint:a,acr_values:b,resource:g,request:t,request_uri:r,extraQueryParams:y,extraTokenParams:v,request_type:n,response_mode:m,client_secret:this.settings.client_secret,skipUserInfo:s,nonce:o,disablePKCE:this.settings.disablePKCE});await this.clearStaleState();const A=E.state;return await this.settings.stateStore.set(A.id,A.toStorageString()),E}async readSigninResponseState(e,t=!1){const r=this._logger.create("readSigninResponseState"),n=new cM(YI.readParams(e,this.settings.response_mode));if(!n.state)throw r.throw(new Error("No state in response")),null;const i=await this.settings.stateStore[t?"remove":"get"](n.state);if(!i)throw r.throw(new Error("No matching state found in storage")),null;return{state:oM.fromStorageString(i),response:n}}async processSigninResponse(e){const t=this._logger.create("processSigninResponse"),{state:r,response:n}=await this.readSigninResponseState(e,!0);return t.debug("received state from storage; validating response"),await this._validator.validateSigninResponse(n,r),n}async processResourceOwnerPasswordCredentials({username:e,password:t,skipUserInfo:r=!1,extraTokenParams:n={}}){const i=await this._tokenClient.exchangeCredentials({username:e,password:t,...n}),a=new cM(new URLSearchParams);return Object.assign(a,i),await this._validator.validateCredentialsResponse(a,r),a}async useRefreshToken({state:e,timeoutInSeconds:t}){var r;const n=this._logger.create("useRefreshToken");let i;if(void 0===this.settings.refreshTokenAllowedScope)i=e.scope;else{const t=this.settings.refreshTokenAllowedScope.split(" ");i=((null==(r=e.scope)?void 0:r.split(" "))||[]).filter((e=>t.includes(e))).join(" ")}const a=await this._tokenClient.exchangeRefreshToken({refresh_token:e.refresh_token,scope:i,timeoutInSeconds:t}),s=new cM(new URLSearchParams);return Object.assign(s,a),n.debug("validating response",s),await this._validator.validateRefreshResponse(s,{...e,scope:i}),s}async createSignoutRequest({state:e,id_token_hint:t,request_type:r,post_logout_redirect_uri:n=this.settings.post_logout_redirect_uri,extraQueryParams:i=this.settings.extraQueryParams}={}){const a=this._logger.create("createSignoutRequest"),s=await this.metadataService.getEndSessionEndpoint();if(!s)throw a.throw(new Error("No end session endpoint")),null;a.debug("Received end session endpoint",s);const o=new class{constructor({url:e,state_data:t,id_token_hint:r,post_logout_redirect_uri:n,extraQueryParams:i,request_type:a}){if(this._logger=new GI("SignoutRequest"),!e)throw this._logger.error("ctor: No url passed"),new Error("url");const s=new URL(e);r&&s.searchParams.append("id_token_hint",r),n&&(s.searchParams.append("post_logout_redirect_uri",n),t&&(this.state=new sM({data:t,request_type:a}),s.searchParams.append("state",this.state.id)));for(const[e,t]of Object.entries({...i}))null!=t&&s.searchParams.append(e,t.toString());this.url=s.href}}({url:s,id_token_hint:t,post_logout_redirect_uri:n,state_data:e,extraQueryParams:i,request_type:r});await this.clearStaleState();const c=o.state;return c&&(a.debug("Signout request has state to persist"),await this.settings.stateStore.set(c.id,c.toStorageString())),o}async readSignoutResponseState(e,t=!1){const r=this._logger.create("readSignoutResponseState"),n=new class{constructor(e){this.state=e.get("state"),this.error=e.get("error"),this.error_description=e.get("error_description"),this.error_uri=e.get("error_uri")}}(YI.readParams(e,this.settings.response_mode));if(!n.state){if(r.debug("No state in response"),n.error)throw r.warn("Response was error:",n.error),new QI(n);return{state:void 0,response:n}}const i=await this.settings.stateStore[t?"remove":"get"](n.state);if(!i)throw r.throw(new Error("No matching state found in storage")),null;return{state:sM.fromStorageString(i),response:n}}async processSignoutResponse(e){const t=this._logger.create("processSignoutResponse"),{state:r,response:n}=await this.readSignoutResponseState(e,!0);return r?(t.debug("Received state from storage; validating response"),this._validator.validateSignoutResponse(n,r)):t.debug("No state from storage; skipping response validation"),n}clearStaleState(){return this._logger.create("clearStaleState"),sM.clearStaleState(this.settings.stateStore,this.settings.staleStateAgeInSeconds)}async revokeToken(e,t){return this._logger.create("revokeToken"),await this._tokenClient.revoke({token:e,token_type_hint:t})}}(e),this._redirectNavigator=new class{constructor(e){this._settings=e,this._logger=new GI("RedirectNavigator")}async prepare({redirectMethod:e=this._settings.redirectMethod,redirectTarget:t=this._settings.redirectTarget}){var r;this._logger.create("prepare");let n=window.self;"top"===t&&(n=null!=(r=window.top)?r:window.self);const i=n.location[e].bind(n.location);let a;return{navigate:async e=>{this._logger.create("navigate");const t=new Promise(((e,t)=>{a=t}));return i(e.url),await t},close:()=>{this._logger.create("close"),null==a||a(new Error("Redirect aborted")),n.stop()}}}}(this.settings),this._popupNavigator=new class{constructor(e){this._settings=e,this._logger=new GI("PopupNavigator")}async prepare({popupWindowFeatures:e=this._settings.popupWindowFeatures,popupWindowTarget:t=this._settings.popupWindowTarget}){return new _M({popupWindowFeatures:e,popupWindowTarget:t})}async callback(e,t=!1){this._logger.create("callback"),_M.notifyOpener(e,t)}}(this.settings),this._iframeNavigator=new class{constructor(e){this._settings=e,this._logger=new GI("IFrameNavigator")}async prepare({silentRequestTimeoutInSeconds:e=this._settings.silentRequestTimeoutInSeconds}){return new wM({silentRequestTimeoutInSeconds:e})}async callback(e){this._logger.create("callback"),wM.notifyParent(e,this._settings.iframeNotifyParentOrigin)}}(this.settings),this._events=new EM(this.settings),this._silentRenewService=new class{constructor(e){this._userManager=e,this._logger=new GI("SilentRenewService"),this._isStarted=!1,this._retryTimer=new JI("Retry Silent Renew"),this._tokenExpiring=async()=>{const e=this._logger.create("_tokenExpiring");try{await this._userManager.signinSilent(),e.debug("silent token renewal successful")}catch(t){if(t instanceof ZI)return e.warn("ErrorTimeout from signinSilent:",t,"retry in 5s"),void this._retryTimer.init(5);e.error("Error from signinSilent:",t),this._userManager.events._raiseSilentRenewError(t)}}}async start(){const e=this._logger.create("start");if(!this._isStarted){this._isStarted=!0,this._userManager.events.addAccessTokenExpiring(this._tokenExpiring),this._retryTimer.addHandler(this._tokenExpiring);try{await this._userManager.getUser()}catch(t){e.error("getUser error",t)}}}stop(){this._isStarted&&(this._retryTimer.cancel(),this._retryTimer.removeHandler(this._tokenExpiring),this._userManager.events.removeAccessTokenExpiring(this._tokenExpiring),this._isStarted=!1)}}(this),this.settings.automaticSilentRenew&&this.startSilentRenew(),this._sessionMonitor=null,this.settings.monitorSession&&(this._sessionMonitor=new class{constructor(e){this._userManager=e,this._logger=new GI("SessionMonitor"),this._start=async e=>{const t=e.session_state;if(!t)return;const r=this._logger.create("_start");if(e.profile?(this._sub=e.profile.sub,this._sid=e.profile.sid,r.debug("session_state",t,", sub",this._sub)):(this._sub=void 0,this._sid=void 0,r.debug("session_state",t,", anonymous user")),this._checkSessionIFrame)this._checkSessionIFrame.start(t);else try{const e=await this._userManager.metadataService.getCheckSessionIframe();if(e){r.debug("initializing check session iframe");const n=this._userManager.settings.client_id,i=this._userManager.settings.checkSessionIntervalInSeconds,a=this._userManager.settings.stopCheckSessionOnError,s=new class{constructor(e,t,r,n,i){this._callback=e,this._client_id=t,this._intervalInSeconds=n,this._stopOnError=i,this._logger=new GI("CheckSessionIFrame"),this._timer=null,this._session_state=null,this._message=e=>{e.origin===this._frame_origin&&e.source===this._frame.contentWindow&&("error"===e.data?(this._logger.error("error message from check session op iframe"),this._stopOnError&&this.stop()):"changed"===e.data?(this._logger.debug("changed message from check session op iframe"),this.stop(),this._callback()):this._logger.debug(e.data+" message from check session op iframe"))};const a=new URL(r);this._frame_origin=a.origin,this._frame=window.document.createElement("iframe"),this._frame.style.visibility="hidden",this._frame.style.position="fixed",this._frame.style.left="-1000px",this._frame.style.top="0",this._frame.width="0",this._frame.height="0",this._frame.src=a.href}load(){return new Promise((e=>{this._frame.onload=()=>{e()},window.document.body.appendChild(this._frame),window.addEventListener("message",this._message,!1)}))}start(e){if(this._session_state===e)return;this._logger.create("start"),this.stop(),this._session_state=e;const t=()=>{this._frame.contentWindow&&this._session_state&&this._frame.contentWindow.postMessage(this._client_id+" "+this._session_state,this._frame_origin)};t(),this._timer=setInterval(t,1e3*this._intervalInSeconds)}stop(){this._logger.create("stop"),this._session_state=null,this._timer&&(clearInterval(this._timer),this._timer=null)}}(this._callback,n,e,i,a);await s.load(),this._checkSessionIFrame=s,s.start(t)}else r.warn("no check session iframe found in the metadata")}catch(e){r.error("Error from getCheckSessionIframe:",e instanceof Error?e.message:e)}},this._stop=()=>{const e=this._logger.create("_stop");if(this._sub=void 0,this._sid=void 0,this._checkSessionIFrame&&this._checkSessionIFrame.stop(),this._userManager.settings.monitorAnonymousSession){const t=setInterval((async()=>{clearInterval(t);try{const e=await this._userManager.querySessionStatus();if(e){const t={session_state:e.session_state,profile:e.sub&&e.sid?{sub:e.sub,sid:e.sid}:null};this._start(t)}}catch(t){e.error("error from querySessionStatus",t instanceof Error?t.message:t)}}),1e3)}},this._callback=async()=>{const e=this._logger.create("_callback");try{const t=await this._userManager.querySessionStatus();let r=!0;t&&this._checkSessionIFrame?t.sub===this._sub?(r=!1,this._checkSessionIFrame.start(t.session_state),t.sid===this._sid?e.debug("same sub still logged in at OP, restarting check session iframe; session_state",t.session_state):(e.debug("same sub still logged in at OP, session state has changed, restarting check session iframe; session_state",t.session_state),this._userManager.events._raiseUserSessionChanged())):e.debug("different subject signed into OP",t.sub):e.debug("subject no longer signed into OP"),r?this._sub?this._userManager.events._raiseUserSignedOut():this._userManager.events._raiseUserSignedIn():e.debug("no change in session detected, no event to raise")}catch(t){this._sub&&(e.debug("Error calling queryCurrentSigninSession; raising signed out event",t),this._userManager.events._raiseUserSignedOut())}},e||this._logger.throw(new Error("No user manager passed")),this._userManager.events.addUserLoaded(this._start),this._userManager.events.addUserUnloaded(this._stop),this._init().catch((e=>{this._logger.error(e)}))}async _init(){this._logger.create("_init");const e=await this._userManager.getUser();if(e)this._start(e);else if(this._userManager.settings.monitorAnonymousSession){const e=await this._userManager.querySessionStatus();if(e){const t={session_state:e.session_state,profile:e.sub&&e.sid?{sub:e.sub,sid:e.sid}:null};this._start(t)}}}}(this))}get events(){return this._events}get metadataService(){return this._client.metadataService}async getUser(){const e=this._logger.create("getUser"),t=await this._loadUser();return t?(e.info("user loaded"),this._events.load(t,!1),t):(e.info("user not found in storage"),null)}async removeUser(){const e=this._logger.create("removeUser");await this.storeUser(null),e.info("user removed from storage"),this._events.unload()}async signinRedirect(e={}){this._logger.create("signinRedirect");const{redirectMethod:t,...r}=e,n=await this._redirectNavigator.prepare({redirectMethod:t});await this._signinStart({request_type:"si:r",...r},n)}async signinRedirectCallback(e=window.location.href){const t=this._logger.create("signinRedirectCallback"),r=await this._signinEnd(e);return r.profile&&r.profile.sub?t.info("success, signed in subject",r.profile.sub):t.info("no subject"),r}async signinResourceOwnerCredentials({username:e,password:t,skipUserInfo:r=!1}){const n=this._logger.create("signinResourceOwnerCredential"),i=await this._client.processResourceOwnerPasswordCredentials({username:e,password:t,skipUserInfo:r,extraTokenParams:this.settings.extraTokenParams});n.debug("got signin response");const a=await this._buildUser(i);return a.profile&&a.profile.sub?n.info("success, signed in subject",a.profile.sub):n.info("no subject"),a}async signinPopup(e={}){const t=this._logger.create("signinPopup"),{popupWindowFeatures:r,popupWindowTarget:n,...i}=e,a=this.settings.popup_redirect_uri;a||t.throw(new Error("No popup_redirect_uri configured"));const s=await this._popupNavigator.prepare({popupWindowFeatures:r,popupWindowTarget:n}),o=await this._signin({request_type:"si:p",redirect_uri:a,display:"popup",...i},s);return o&&(o.profile&&o.profile.sub?t.info("success, signed in subject",o.profile.sub):t.info("no subject")),o}async signinPopupCallback(e=window.location.href,t=!1){const r=this._logger.create("signinPopupCallback");await this._popupNavigator.callback(e,t),r.info("success")}async signinSilent(e={}){var t;const r=this._logger.create("signinSilent"),{silentRequestTimeoutInSeconds:n,...i}=e;let a=await this._loadUser();if(null==a?void 0:a.refresh_token){r.debug("using refresh token");const e=new class{constructor(e){this.refresh_token=e.refresh_token,this.id_token=e.id_token,this.session_state=e.session_state,this.scope=e.scope,this.profile=e.profile,this.data=e.state}}(a);return await this._useRefreshToken(e)}const s=this.settings.silent_redirect_uri;let o;s||r.throw(new Error("No silent_redirect_uri configured")),a&&this.settings.validateSubOnSilentRenew&&(r.debug("subject prior to silent renew:",a.profile.sub),o=a.profile.sub);const c=await this._iframeNavigator.prepare({silentRequestTimeoutInSeconds:n});return a=await this._signin({request_type:"si:s",redirect_uri:s,prompt:"none",id_token_hint:this.settings.includeIdTokenInSilentRenew?null==a?void 0:a.id_token:void 0,...i},c,o),a&&((null==(t=a.profile)?void 0:t.sub)?r.info("success, signed in subject",a.profile.sub):r.info("no subject")),a}async _useRefreshToken(e){const t=await this._client.useRefreshToken({state:e,timeoutInSeconds:this.settings.silentRequestTimeoutInSeconds}),r=new dM({...e,...t});return await this.storeUser(r),this._events.load(r),r}async signinSilentCallback(e=window.location.href){const t=this._logger.create("signinSilentCallback");await this._iframeNavigator.callback(e),t.info("success")}async signinCallback(e=window.location.href){const{state:t}=await this._client.readSigninResponseState(e);switch(t.request_type){case"si:r":return await this.signinRedirectCallback(e);case"si:p":return await this.signinPopupCallback(e);case"si:s":return await this.signinSilentCallback(e);default:throw new Error("invalid response_type in state")}}async signoutCallback(e=window.location.href,t=!1){const{state:r}=await this._client.readSignoutResponseState(e);if(r)switch(r.request_type){case"so:r":await this.signoutRedirectCallback(e);break;case"so:p":await this.signoutPopupCallback(e,t);break;case"so:s":await this.signoutSilentCallback(e);break;default:throw new Error("invalid response_type in state")}}async querySessionStatus(e={}){const t=this._logger.create("querySessionStatus"),{silentRequestTimeoutInSeconds:r,...n}=e,i=this.settings.silent_redirect_uri;i||t.throw(new Error("No silent_redirect_uri configured"));const a=await this._loadUser(),s=await this._iframeNavigator.prepare({silentRequestTimeoutInSeconds:r}),o=await this._signinStart({request_type:"si:s",redirect_uri:i,prompt:"none",id_token_hint:this.settings.includeIdTokenInSilentRenew?null==a?void 0:a.id_token:void 0,response_type:this.settings.query_status_response_type,scope:"openid",skipUserInfo:!0,...n},s);try{const e=await this._client.processSigninResponse(o.url);return t.debug("got signin response"),e.session_state&&e.profile.sub?(t.info("success for subject",e.profile.sub),{session_state:e.session_state,sub:e.profile.sub,sid:e.profile.sid}):(t.info("success, user not authenticated"),null)}catch(e){if(this.settings.monitorAnonymousSession&&e instanceof QI)switch(e.error){case"login_required":case"consent_required":case"interaction_required":case"account_selection_required":return t.info("success for anonymous user"),{session_state:e.session_state}}throw e}}async _signin(e,t,r){const n=await this._signinStart(e,t);return await this._signinEnd(n.url,r)}async _signinStart(e,t){const r=this._logger.create("_signinStart");try{const n=await this._client.createSigninRequest(e);return r.debug("got signin request"),await t.navigate({url:n.url,state:n.state.id,response_mode:n.state.response_mode,scriptOrigin:this.settings.iframeScriptOrigin})}catch(e){throw r.debug("error after preparing navigator, closing navigator window"),t.close(),e}}async _signinEnd(e,t){const r=this._logger.create("_signinEnd"),n=await this._client.processSigninResponse(e);return r.debug("got signin response"),await this._buildUser(n,t)}async _buildUser(e,t){const r=this._logger.create("_buildUser"),n=new dM(e);if(t){if(t!==n.profile.sub)throw r.debug("current user does not match user returned from signin. sub from signin:",n.profile.sub),new QI({...e,error:"login_required"});r.debug("current user matches user returned from signin")}return await this.storeUser(n),r.debug("user stored"),this._events.load(n),n}async signoutRedirect(e={}){const t=this._logger.create("signoutRedirect"),{redirectMethod:r,...n}=e,i=await this._redirectNavigator.prepare({redirectMethod:r});await this._signoutStart({request_type:"so:r",post_logout_redirect_uri:this.settings.post_logout_redirect_uri,...n},i),t.info("success")}async signoutRedirectCallback(e=window.location.href){const t=this._logger.create("signoutRedirectCallback"),r=await this._signoutEnd(e);return t.info("success"),r}async signoutPopup(e={}){const t=this._logger.create("signoutPopup"),{popupWindowFeatures:r,popupWindowTarget:n,...i}=e,a=this.settings.popup_post_logout_redirect_uri,s=await this._popupNavigator.prepare({popupWindowFeatures:r,popupWindowTarget:n});await this._signout({request_type:"so:p",post_logout_redirect_uri:a,state:null==a?void 0:{},...i},s),t.info("success")}async signoutPopupCallback(e=window.location.href,t=!1){const r=this._logger.create("signoutPopupCallback");await this._popupNavigator.callback(e,t),r.info("success")}async _signout(e,t){const r=await this._signoutStart(e,t);return await this._signoutEnd(r.url)}async _signoutStart(e={},t){var r;const n=this._logger.create("_signoutStart");try{const i=await this._loadUser();n.debug("loaded current user from storage"),this.settings.revokeTokensOnSignout&&await this._revokeInternal(i);const a=e.id_token_hint||i&&i.id_token;a&&(n.debug("setting id_token_hint in signout request"),e.id_token_hint=a),await this.removeUser(),n.debug("user removed, creating signout request");const s=await this._client.createSignoutRequest(e);return n.debug("got signout request"),await t.navigate({url:s.url,state:null==(r=s.state)?void 0:r.id})}catch(e){throw n.debug("error after preparing navigator, closing navigator window"),t.close(),e}}async _signoutEnd(e){const t=this._logger.create("_signoutEnd"),r=await this._client.processSignoutResponse(e);return t.debug("got signout response"),r}async signoutSilent(e={}){var t;const r=this._logger.create("signoutSilent"),{silentRequestTimeoutInSeconds:n,...i}=e,a=this.settings.includeIdTokenInSilentSignout?null==(t=await this._loadUser())?void 0:t.id_token:void 0,s=this.settings.popup_post_logout_redirect_uri,o=await this._iframeNavigator.prepare({silentRequestTimeoutInSeconds:n});await this._signout({request_type:"so:s",post_logout_redirect_uri:s,id_token_hint:a,...i},o),r.info("success")}async signoutSilentCallback(e=window.location.href){const t=this._logger.create("signoutSilentCallback");await this._iframeNavigator.callback(e),t.info("success")}async revokeTokens(e){const t=await this._loadUser();await this._revokeInternal(t,e)}async _revokeInternal(e,t=this.settings.revokeTokenTypes){const r=this._logger.create("_revokeInternal");if(!e)return;const n=t.filter((t=>"string"==typeof e[t]));if(n.length){for(const t of n)await this._client.revokeToken(e[t],t),r.info(`${t} revoked successfully`),"access_token"!==t&&(e[t]=null);await this.storeUser(e),r.debug("user stored"),this._events.load(e)}else r.debug("no need to revoke due to no token(s)")}startSilentRenew(){this._logger.create("startSilentRenew"),this._silentRenewService.start()}stopSilentRenew(){this._silentRenewService.stop()}get _userStoreKey(){return`user:${this.settings.authority}:${this.settings.client_id}`}async _loadUser(){const e=this._logger.create("_loadUser"),t=await this.settings.userStore.get(this._userStoreKey);return t?(e.debug("user storageString loaded"),dM.fromStorageString(t)):(e.debug("no user storageString"),null)}async storeUser(e){const t=this._logger.create("storeUser");if(e){t.debug("storing user");const r=e.toStorageString();await this.settings.userStore.set(this._userStoreKey,r)}else this._logger.debug("removing user"),await this.settings.userStore.remove(this._userStoreKey)}async clearStaleState(){await this._client.clearStaleState()}}((({oidcConfiguration:e,authenticationDomain:t})=>{const r={authority:t,redirect_uri:e.redirectUri,popup_redirect_uri:e.redirectUri,client_id:e.clientId,metadata:{authorization_endpoint:`${t}/authorize`,token_endpoint:`${t}/oauth/token`,userinfo_endpoint:`${t}/userinfo`,end_session_endpoint:`${t}/v2/logout?returnTo=${encodeURIComponent(e.logoutRedirectUri)}&client_id=${e.clientId}`},mergeClaims:!0,loadUserInfo:!0,scope:e.scope};return e.audience&&(r.extraQueryParams={audience:e.audience}),r})(e)),this.deviceCredentialsManager=new ZU,this.logoutMode=e.oidcConfiguration.logoutMode||"redirect"}static mapOidcUserToDomainModel=e=>{const t=e.profile?.passport,r={expired:e.expired,idToken:e.id_token,accessToken:e.access_token,refreshToken:e.refresh_token,profile:{sub:e.profile.sub,email:e.profile.email,nickname:e.profile.nickname}};return t?.imx_eth_address&&(r.imx={ethAddress:t?.imx_eth_address,starkAddress:t?.imx_stark_address,userAdminAddress:t?.imx_user_admin_address}),t?.zkevm_eth_address&&(r.zkEvm={ethAddress:t?.zkevm_eth_address,userAdminAddress:t?.zkevm_user_admin_address}),r};static mapDeviceTokenResponseToDomainUserModel=e=>{const t=DI(e.id_token),r={idToken:e.id_token,accessToken:e.access_token,refreshToken:e.refresh_token,profile:{sub:t.sub,email:t.email,nickname:t.nickname}};return t?.passport?.imx_eth_address&&(r.imx={ethAddress:t?.passport?.imx_eth_address,starkAddress:t?.passport?.imx_stark_address,userAdminAddress:t?.passport?.imx_user_admin_address}),r};async login(){return $U((async()=>{const e=await this.userManager.signinPopup({popupWindowFeatures:{width:410,height:450}});return rL.mapOidcUserToDomainModel(e)}),WU.AUTHENTICATION_ERROR)}async loginCallback(){return $U((async()=>this.userManager.signinPopupCallback()),WU.AUTHENTICATION_ERROR)}async loginWithDeviceFlow(){return $U((async()=>{const e=await YO.post(`${this.config.authenticationDomain}/oauth/device/code`,{client_id:this.config.oidcConfiguration.clientId,scope:this.config.oidcConfiguration.scope,audience:this.config.oidcConfiguration.audience},eL);return{code:e.data.user_code,deviceCode:e.data.device_code,url:e.data.verification_uri_complete,interval:e.data.interval}}),WU.AUTHENTICATION_ERROR)}async connectImxDeviceFlow(e,t,r){return $U((async()=>{const n=Date.now();for(;;){if(null!=r&&Date.now()-n>r)throw new Error("Timed out");await tL(1e3*t);try{const t=await this.getDeviceFlowToken(e),r=rL.mapDeviceTokenResponseToDomainUserModel(t);return r.imx?.ethAddress&&r.imx?.starkAddress&&r.imx?.userAdminAddress&&this.deviceCredentialsManager.saveCredentials(t),r}catch(e){if(!YO.isAxiosError(e))throw e;{const t=e.response?.data;switch(t.error){case"authorization_pending":case"slow_down":break;case"expired_token":throw new Error("Token expired, please log in again");case"access_denied":throw new Error("User denied access");default:throw new Error("Error getting token")}}}}throw new Error("Failed to get credentials")}),WU.AUTHENTICATION_ERROR)}async getDeviceFlowToken(e){return(await YO.post(`${this.config.authenticationDomain}/oauth/token`,{client_id:this.config.oidcConfiguration.clientId,grant_type:"urn:ietf:params:oauth:grant-type:device_code",device_code:e},eL)).data}static base64URLEncode(e){return e.toString("base64").replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}static sha256(e){return(void 0)("sha256").update(e).digest()}getPKCEAuthorizationUrl(){const e=rL.base64URLEncode((void 0)(32)),t=rL.base64URLEncode(rL.sha256(e)),r=rL.base64URLEncode((void 0)(32));return this.deviceCredentialsManager.savePKCEData({state:r,verifier:e}),`${this.config.authenticationDomain}/authorize?response_type=code&code_challenge=${t}&code_challenge_method=S256&client_id=${this.config.oidcConfiguration.clientId}&redirect_uri=${this.config.oidcConfiguration.redirectUri}&scope=${this.config.oidcConfiguration.scope}&state=${r}&audience=${this.config.oidcConfiguration.audience}`}async connectImxPKCEFlow(e,t){return $U((async()=>{const r=this.deviceCredentialsManager.getPKCEData();if(!r)throw new Error("No code verifier or state for PKCE");if(t!==r.state)throw new Error("Provided state does not match stored state");const n=await this.getPKCEToken(e,r.verifier),i=rL.mapDeviceTokenResponseToDomainUserModel(n);return i.imx?.ethAddress&&i.imx?.starkAddress&&i.imx?.userAdminAddress&&this.deviceCredentialsManager.saveCredentials(n),i}),WU.AUTHENTICATION_ERROR)}async getPKCEToken(e,t){return(await YO.post(`${this.config.authenticationDomain}/oauth/token`,{client_id:this.config.oidcConfiguration.clientId,grant_type:"authorization_code",code_verifier:t,code:e,redirect_uri:this.config.oidcConfiguration.redirectUri},eL)).data}async connectImxWithCredentials(e){return $U((async()=>{if(this.deviceCredentialsManager.areValid(e))return rL.mapDeviceTokenResponseToDomainUserModel(e);const t=e?.refresh_token??null;if(t){const e=await this.refreshToken(t);return rL.mapDeviceTokenResponseToDomainUserModel(e)}return null}),WU.AUTHENTICATION_ERROR)}async refreshToken(e){return(await YO.post(`${this.config.authenticationDomain}/oauth/token`,{client_id:this.config.oidcConfiguration.clientId,grant_type:"refresh_token",refresh_token:e},eL)).data}async logout(){return $U((async()=>"silent"===this.logoutMode?this.userManager.signoutSilent():this.userManager.signoutRedirect()),WU.LOGOUT_ERROR)}async logoutSilentCallback(e){return this.userManager.signoutSilentCallback(e)}async logoutDeviceFlow(){return $U((async()=>{this.deviceCredentialsManager.clearCredentials()}),WU.LOGOUT_ERROR)}async loginSilent(){return $U((async()=>{if(!await this.getUser())return null;const e=await this.userManager.signinSilent();return e?rL.mapOidcUserToDomainModel(e):null}),WU.SILENT_LOGIN_ERROR)}async getUser(){return $U((async()=>{const e=await this.userManager.getUser();if(e)return rL.mapOidcUserToDomainModel(e);const t=this.deviceCredentialsManager.getCredentials();return t?rL.mapDeviceTokenResponseToDomainUserModel(t):null}),WU.NOT_LOGGED_IN_ERROR)}async getUserDeviceFlow(){return $U((async()=>{const e=this.deviceCredentialsManager.getCredentials();return e?rL.mapDeviceTokenResponseToDomainUserModel(e):null}),WU.NOT_LOGGED_IN_ERROR)}checkStoredDeviceFlowCredentials(){return this.deviceCredentialsManager.getCredentials()}}class nL{config;constructor(e){this.config=e}async login(e,t){return $U((async()=>{const r=new SN(this.config.magicPublishableApiKey,{extensions:[new xN],network:t});return await r.openid.loginWithOIDC({jwt:e,providerId:this.config.magicProviderId}),r.rpcProvider}),WU.WALLET_CONNECTION_ERROR)}}const iL=1e3,aL=3,sL=async(e,t)=>{const{retries:r=aL,interval:n=iL,finalErr:i=Error("Retry failed"),finallyFn:a=(()=>{})}=t||{};try{return await e()}catch(t){return r<=0?Promise.reject(i):(await(s=n,new Promise((e=>{setTimeout((()=>e()),s)}))),sL(e,{retries:r-1,finalErr:i,finallyFn:a}))}finally{r<=0&&a()}var s};var oL,cL;e.ProviderErrorCode=void 0,(oL=e.ProviderErrorCode||(e.ProviderErrorCode={}))[oL.USER_REJECTED_REQUEST=4001]="USER_REJECTED_REQUEST",oL[oL.UNAUTHORIZED=4100]="UNAUTHORIZED",oL[oL.UNSUPPORTED_METHOD=4200]="UNSUPPORTED_METHOD",oL[oL.DISCONNECTED=4900]="DISCONNECTED",e.RpcErrorCode=void 0,(cL=e.RpcErrorCode||(e.RpcErrorCode={}))[cL.RPC_SERVER_ERROR=-32e3]="RPC_SERVER_ERROR",cL[cL.INVALID_REQUEST=-32600]="INVALID_REQUEST",cL[cL.METHOD_NOT_FOUND=-32601]="METHOD_NOT_FOUND",cL[cL.INVALID_PARAMS=-32602]="INVALID_PARAMS",cL[cL.INTERNAL_ERROR=-32603]="INTERNAL_ERROR",cL[cL.PARSE_ERROR=-32700]="PARSE_ERROR",cL[cL.USER_REJECTED_REQUEST=-32003]="USER_REJECTED_REQUEST";class fL extends Error{message;code;constructor(e,t){super(t),this.message=t,this.code=e}}const uL=e=>He.from(e).toString();class dL{transactionAPI;confirmationScreen;imxEtherAddress;constructor({imxPublicApiDomain:e,accessToken:t,confirmationScreen:r,imxEtherAddress:n}){this.confirmationScreen=r,this.transactionAPI=new yU(new vU({accessToken:t,basePath:e})),this.imxEtherAddress=n}loading(e){this.confirmationScreen.loading(e)}async validate({payloadHash:e}){if(!(await sL((async()=>this.transactionAPI.getTransactionByID({transactionID:e,chainType:"starkex"})),{finallyFn:()=>{this.confirmationScreen.closeWindow()}})).data.id)throw new Error("Transaction doesn't exists");const t=await this.transactionAPI.evaluateTransaction({id:e,transactionEvaluationRequest:{chainType:"starkex"}}),{confirmationRequired:r}=t.data;if(r){if(!(await this.confirmationScreen.startGuardianTransaction(e,this.imxEtherAddress,wU)).confirmed)throw new Error("Transaction rejected by user")}else this.confirmationScreen.closeWindow()}async evaluateEVMTransaction({chainId:t,nonce:r,user:n,metaTransactions:i}){const a={Authorization:`Bearer ${n.accessToken}`},s=(t=>{try{return t.map((e=>({delegateCall:!0===e.delegateCall,revertOnError:!0===e.revertOnError,gasLimit:e.gasLimit?uL(e.gasLimit):"0",target:e.to??_r,value:e.value?uL(e.value):"0",data:e.data?e.data.toString():"0x"})))}catch(t){const r=t instanceof Error?t.message:String(t);throw new fL(e.RpcErrorCode.INVALID_PARAMS,`Transaction failed to parsing: ${r}`)}})(i);try{return(await this.transactionAPI.evaluateTransaction({id:"evm",transactionEvaluationRequest:{chainType:"evm",chainId:t,transactionData:{nonce:r,userAddress:n.zkEvm.ethAddress,metaTransactions:s}}},{headers:a})).data}catch(t){const r=t instanceof Error?t.message:String(t);throw new fL(e.RpcErrorCode.INTERNAL_ERROR,`Transaction failed to validate with error: ${r}`)}}async validateEVMTransaction({chainId:t,nonce:r,user:n,metaTransactions:i}){const a=await this.evaluateEVMTransaction({chainId:t,nonce:r,user:n,metaTransactions:i}),{confirmationRequired:s,transactionId:o}=a;if(s&&o){if(!(await this.confirmationScreen.startGuardianTransaction(o,this.imxEtherAddress,_U,t)).confirmed)throw new fL(e.RpcErrorCode.USER_REJECTED_REQUEST,"Transaction rejected by user ")}else this.confirmationScreen.closeWindow()}}const lL="ERC721";const hL="ERC721";class pL{user;starkSigner;immutableXClient;confirmationScreen;guardianClient;constructor({user:e,starkSigner:t,immutableXClient:r,imxPublicApiDomain:n,confirmationScreen:i}){this.user=e,this.starkSigner=t,this.immutableXClient=r,this.confirmationScreen=i,this.guardianClient=new dL({imxPublicApiDomain:n,accessToken:e.accessToken,confirmationScreen:i,imxEtherAddress:e.imx.ethAddress})}async transfer(e){return async function({request:e,transfersApi:t,starkSigner:r,user:n,guardianClient:i}){return $U((async()=>{i.loading();const a=e.type===hL?"1":e.amount,s={sender:n.imx.ethAddress,token:SU(e),amount:a,receiver:e.receiver},o={Authorization:`Bearer ${n.accessToken}`},c=await t.getSignableTransferV1({getSignableTransferRequest:s},{headers:o});await i.validate({payloadHash:c.data.payload_hash});const f=c.data,{payload_hash:u}=f,d=await r.signMessage(u),l=await r.getAddress(),h={createTransferRequest:{sender_stark_key:f.sender_stark_key||l,sender_vault_id:f.sender_vault_id,receiver_stark_key:f.receiver_stark_key,receiver_vault_id:f.receiver_vault_id,asset_id:f.asset_id,amount:f.amount,nonce:f.nonce,expiration_timestamp:f.expiration_timestamp,stark_signature:d}},{data:p}=await t.createTransferV1(h,{headers:o});return{sent_signature:p.sent_signature,status:p.status?.toString(),time:p.time,transfer_id:p.transfer_id}}),WU.TRANSFER_ERROR)}({request:e,user:this.user,starkSigner:this.starkSigner,transfersApi:this.immutableXClient.transfersApi,guardianClient:this.guardianClient})}registerOffchain(){throw new XU("Operation not supported",WU.OPERATION_NOT_SUPPORTED_ERROR)}isRegisteredOnchain(){throw new XU("Operation not supported",WU.OPERATION_NOT_SUPPORTED_ERROR)}createOrder(e){return async function({starkSigner:e,user:t,request:r,ordersApi:n,guardianClient:i}){return $U((async()=>{i.loading();const{ethAddress:a}=t.imx,s=r.sell.type===lL?"1":r.sell.amount,o=r.buy.type===lL?"1":r.buy.amount,c={Authorization:`Bearer ${t.accessToken}`},f={user:a,amount_buy:o,token_buy:SU(r.buy),amount_sell:s,token_sell:SU(r.sell),fees:r.fees,split_fees:!0,expiration_timestamp:r.expiration_timestamp},u=await n.getSignableOrder({getSignableOrderRequestV3:f},{headers:c});await i.validate({payloadHash:u.data.payload_hash});const{payload_hash:d}=u.data,l=await e.signMessage(d),h=u.data,p={createOrderRequest:{include_fees:!0,fees:r.fees,stark_signature:l,amount_buy:h.amount_buy,amount_sell:h.amount_sell,asset_id_buy:h.asset_id_buy,asset_id_sell:h.asset_id_sell,expiration_timestamp:h.expiration_timestamp,nonce:h.nonce,stark_key:h.stark_key,vault_id_buy:h.vault_id_buy,vault_id_sell:h.vault_id_sell}};return{...(await n.createOrderV3(p,{headers:c})).data}}),WU.CREATE_ORDER_ERROR)}({request:e,user:this.user,starkSigner:this.starkSigner,ordersApi:this.immutableXClient.ordersApi,guardianClient:this.guardianClient})}cancelOrder(e){return async function({user:e,starkSigner:t,request:r,ordersApi:n,guardianClient:i}){return $U((async()=>{i.loading();const a={order_id:r.order_id},s={Authorization:`Bearer ${e.accessToken}`},o=await n.getSignableCancelOrderV3({getSignableCancelOrderRequest:a},{headers:s});await i.validate({payloadHash:o.data.payload_hash});const{payload_hash:c}=o.data,f=await t.signMessage(c),u=await n.cancelOrderV3({id:r.order_id.toString(),cancelOrderRequest:{order_id:r.order_id,stark_signature:f}},{headers:s});return{order_id:u.data.order_id,status:u.data.status}}),WU.CANCEL_ORDER_ERROR)}({request:e,user:this.user,starkSigner:this.starkSigner,ordersApi:this.immutableXClient.ordersApi,guardianClient:this.guardianClient})}createTrade(e){return async function({request:e,tradesApi:t,user:r,starkSigner:n,guardianClient:i}){return $U((async()=>{i.loading();const{ethAddress:a}=r.imx,s={expiration_timestamp:e.expiration_timestamp,fees:e.fees,order_id:e.order_id,user:a},o={Authorization:`Bearer ${r.accessToken}`},c=await t.getSignableTrade({getSignableTradeRequest:s},{headers:o});await i.validate({payloadHash:c.data.payload_hash});const{payload_hash:f}=c.data,u=await n.signMessage(f),{data:d}=c,l={createTradeRequest:{include_fees:!0,fees:e?.fees,stark_signature:u,order_id:e?.order_id,fee_info:d.fee_info,amount_buy:d.amount_buy,amount_sell:d.amount_sell,asset_id_buy:d.asset_id_buy,asset_id_sell:d.asset_id_sell,expiration_timestamp:d.expiration_timestamp,nonce:d.nonce,stark_key:d.stark_key,vault_id_buy:d.vault_id_buy,vault_id_sell:d.vault_id_sell}},{data:h}=await t.createTradeV3(l,{headers:o});return h}),WU.CREATE_TRADE_ERROR)}({request:e,user:this.user,starkSigner:this.starkSigner,tradesApi:this.immutableXClient.tradesApi,guardianClient:this.guardianClient})}batchNftTransfer(e){return async function({user:e,starkSigner:t,request:r,transfersApi:n,guardianClient:i}){return $U((async()=>{i.loading({width:480,height:784});const{ethAddress:a}=e.imx,s={sender_ether_key:a,signable_requests:r.map((e=>({amount:"1",token:SU({type:hL,tokenId:e.tokenId,tokenAddress:e.tokenAddress}),receiver:e.receiver})))},o={Authorization:`Bearer ${e.accessToken}`},c=await n.getSignableTransfer({getSignableTransferRequestV2:s},{headers:o});await i.validate({payloadHash:c.data.signable_responses[0]?.payload_hash});const f=await Promise.all(c.data.signable_responses.map((async e=>{const r=await t.signMessage(e.payload_hash);return{sender_vault_id:e.sender_vault_id,receiver_stark_key:e.receiver_stark_key,receiver_vault_id:e.receiver_vault_id,asset_id:e.asset_id,amount:e.amount,nonce:e.nonce,expiration_timestamp:e.expiration_timestamp,stark_signature:r}}))),u={sender_stark_key:c.data.sender_stark_key,requests:f},d=await n.createTransfer({createTransferRequestV2:u},{headers:o});return{transfer_ids:d?.data.transfer_ids}}),WU.TRANSFER_ERROR)}({request:e,user:this.user,starkSigner:this.starkSigner,transfersApi:this.immutableXClient.transfersApi,guardianClient:this.guardianClient})}exchangeTransfer(e){return async function({user:e,starkSigner:t,request:r,exchangesApi:n}){return $U((async()=>{const{ethAddress:i}=e.imx,a=r.amount,s=await n.getExchangeSignableTransfer({id:r.transactionID,getSignableTransferRequest:{sender:i,token:SU(r),amount:a,receiver:r.receiver}}),o=await t.getAddress(),{payload_hash:c}=s.data,f=await t.signMessage(c),u={sender_stark_key:s.data.sender_stark_key||o,sender_vault_id:s.data.sender_vault_id,receiver_stark_key:s.data.receiver_stark_key,receiver_vault_id:s.data.receiver_vault_id,asset_id:s.data.asset_id,amount:s.data.amount,nonce:s.data.nonce,expiration_timestamp:s.data.expiration_timestamp,stark_signature:f},d={Authorization:`Bearer ${e.accessToken}`},l=await n.createExchangeTransfer({id:r.transactionID,createTransferRequest:u},{headers:d});return{sent_signature:l?.data.sent_signature,status:l?.data.status?.toString(),time:l?.data.time,transfer_id:l?.data.transfer_id}}),WU.EXCHANGE_TRANSFER_ERROR)}({request:e,user:this.user,starkSigner:this.starkSigner,exchangesApi:this.immutableXClient.exchangeApi})}deposit(e){throw new XU("Operation not supported",WU.OPERATION_NOT_SUPPORTED_ERROR)}prepareWithdrawal(e){throw new XU("Operation not supported",WU.OPERATION_NOT_SUPPORTED_ERROR)}completeWithdrawal(e,t){throw new XU("Operation not supported",WU.OPERATION_NOT_SUPPORTED_ERROR)}getAddress(){return Promise.resolve(this.user.imx.ethAddress)}}class bL{authManager;config;confirmationScreen;immutableXClient;magicAdapter;constructor({authManager:e,config:t,confirmationScreen:r,immutableXClient:n,magicAdapter:i}){this.authManager=e,this.config=t,this.confirmationScreen=r,this.immutableXClient=n,this.magicAdapter=i}async getProvider(){const e=await this.authManager.login();return this.createProviderInstance(e)}async getProviderSilent(){const e=await this.authManager.loginSilent();return e?this.createProviderInstance(e):null}async getProviderWithDeviceFlow(e,t,r){const n=await this.authManager.connectImxDeviceFlow(e,t,r);return this.createProviderInstance(n)}async getProviderWithPKCEFlow(e,t){const r=await this.authManager.connectImxPKCEFlow(e,t);return this.createProviderInstance(r)}async getProviderWithCredentials(e){const t=await this.authManager.connectImxWithCredentials(e);return t?this.createProviderInstance(t):null}async createProviderInstance(e){if(!e.idToken)throw new XU("Failed to initialise",WU.WALLET_CONNECTION_ERROR);const t=await this.magicAdapter.login(e.idToken,this.config.network),r=new Lc(t).getSigner(),n=await(async e=>$U((async()=>JA(await lR(e))),WU.WALLET_CONNECTION_ERROR))(r);if(!e.imx?.ethAddress){const t=await this.registerStarkEx(r,n,e.accessToken);return new pL({user:t,starkSigner:n,immutableXClient:this.immutableXClient,imxPublicApiDomain:this.config.imxPublicApiDomain,confirmationScreen:this.confirmationScreen})}return new pL({user:e,starkSigner:n,immutableXClient:this.immutableXClient,imxPublicApiDomain:this.config.imxPublicApiDomain,confirmationScreen:this.confirmationScreen})}async registerStarkEx(e,t,r){return $U((async()=>{await async function({ethSigner:e,starkSigner:t,usersApi:r},n){return $U((async()=>{const i=await e.getAddress(),a=await t.getAddress(),s=await r.getSignableRegistrationOffchain({getSignableRegistrationRequest:{ether_key:i,stark_key:a}}),{signable_message:o,payload_hash:c}=s.data,f=await AU(o,e),u=await t.signMessage(c);return(await r.registerPassportUser({authorization:`Bearer ${n}`,registerPassportUserRequest:{eth_signature:f,ether_key:i,stark_signature:u,stark_key:a}})).statusText}),WU.USER_REGISTRATION_ERROR)}({ethSigner:e,starkSigner:t,usersApi:this.immutableXClient.usersApi},r);return await sL((async()=>{const e=await this.authManager.loginSilent();return!!e?.imx?e:Promise.reject(new Error("user wallet addresses not exist"))}))}),WU.REFRESH_TOKEN_ERROR)}}var gL;e.Networks=void 0,(gL=e.Networks||(e.Networks={})).PRODUCTION="mainnet",gL.SANDBOX="goerli";const mL=(e,t,r)=>{const n=t.map((t=>!e[t]&&t)).filter((e=>e)).join(", ");if(""!==n){throw new XU(r?`${r} - ${n} cannot be null`:`${n} cannot be null`,WU.INVALID_CONFIGURATION)}};class yL{network;authenticationDomain;passportDomain;imxPublicApiDomain;magicPublishableApiKey;magicProviderId;oidcConfiguration;baseConfig;zkEvmChainId;zkEvmRpcUrl;relayerUrl;multiRollupConfig;constructor({baseConfig:t,overrides:r,...n}){if(mL(n,["clientId","logoutRedirectUri","redirectUri"]),this.oidcConfiguration=n,this.baseConfig=t,r)mL(r,["network","authenticationDomain","passportDomain","magicPublishableApiKey","magicProviderId","zkEvmRpcUrl","zkEvmChainId","relayerUrl","imxPublicApiDomain","indexerMrBasePath","orderBookMrBasePath","passportMrBasePath"],"overrides"),this.network=r.network,this.authenticationDomain=r.authenticationDomain,this.passportDomain=r.passportDomain,this.imxPublicApiDomain=r.imxPublicApiDomain,this.magicPublishableApiKey=r.magicPublishableApiKey,this.magicProviderId=r.magicProviderId,this.zkEvmRpcUrl=r.zkEvmRpcUrl,this.zkEvmChainId=r.zkEvmChainId,this.relayerUrl=r.relayerUrl,this.multiRollupConfig={indexer:SI({basePath:r.indexerMrBasePath}),orderBook:SI({basePath:r.orderBookMrBasePath}),passport:SI({basePath:r.passportMrBasePath})};else switch(t.environment){case e.Environment.PRODUCTION:this.network=e.Networks.PRODUCTION,this.authenticationDomain="https://auth.immutable.com",this.magicPublishableApiKey="pk_live_10F423798A540ED7",this.magicProviderId="fSMzaRQ4O7p4fttl7pCyGVtJS_G70P8SNsLXtPPGHo0=",this.passportDomain="https://passport.immutable.com",this.imxPublicApiDomain="https://api.immutable.com",this.zkEvmRpcUrl="",this.zkEvmChainId="",this.relayerUrl="https://api.immutable.com/relayer-mr",this.multiRollupConfig=kI();break;case e.Environment.SANDBOX:default:this.network=e.Networks.SANDBOX,this.authenticationDomain="https://auth.immutable.com",this.magicPublishableApiKey="pk_live_10F423798A540ED7",this.magicProviderId="fSMzaRQ4O7p4fttl7pCyGVtJS_G70P8SNsLXtPPGHo0=",this.passportDomain="https://passport.sandbox.immutable.com",this.imxPublicApiDomain="https://api.sandbox.immutable.com",this.zkEvmRpcUrl="https://rpc.testnet.immutable.com",this.zkEvmChainId="eip155:13372",this.relayerUrl="https://api.sandbox.immutable.com/relayer-mr",this.multiRollupConfig=xI()}}}var vL,wL,_L;!function(e){e.CONFIRMATION_WINDOW_READY="confirmation_window_ready",e.TRANSACTION_CONFIRMED="transaction_confirmed",e.TRANSACTION_ERROR="transaction_error"}(vL||(vL={})),function(e){e.TRANSACTION_START="transaction_start"}(wL||(wL={})),function(e){e.cancelOrder="delete:v1/orders",e.createOrder="post:v1/orders",e.createTrade="post:v1/trades",e.createTransfer="post:v1/transfers",e.createBatchTransfer="post:v2/transfers"}(_L||(_L={}));const EL="imx_passport_confirmation",AL=({url:e,title:t,width:r,height:n})=>{const i=Math.max(0,Math.round(window.screenX+(window.outerWidth-r)/2)),a=Math.max(0,Math.round(window.screenY+(window.outerHeight-n)/2)),s=window.open(e,t,`\n scrollbars=yes,\n width=${r}, \n height=${n}, \n top=${a}, \n left=${i}\n `);if(!s)throw new Error("Failed to open confirmation screen");return s.focus(),s},SL="Confirm this transaction";class kL{config;confirmationWindow;constructor(e){this.config=e}postMessage(e,t,r){e.postMessage({eventType:EL,accessToken:t,...r},this.config.passportDomain)}startTransaction(e,t,r){return new Promise(((n,i)=>{const a=({data:r,origin:a})=>{if(a===this.config.passportDomain&&r.eventType===EL)switch(r.messageType){case vL.CONFIRMATION_WINDOW_READY:this.postMessage(s,e,{messageType:wL.TRANSACTION_START,messageData:t});break;case vL.TRANSACTION_CONFIRMED:n({confirmed:!0});break;case vL.TRANSACTION_ERROR:i(new Error("Transaction error"));break;default:i(new Error("Unsupported message type"))}};window.addEventListener("message",a);const s=AL({url:`${this.config.passportDomain}/transaction-confirmation`,title:SL,width:r?.width||480,height:r?.height||380}),o=setInterval((()=>{s.closed&&(clearInterval(o),window.removeEventListener("message",a),n({confirmed:!1}))}),1e3)}))}startGuardianTransaction(e,t,r,n){return new Promise(((i,a)=>{const s=({data:e,origin:t})=>{if(t===this.config.passportDomain&&e.eventType===EL)switch(e.messageType){case vL.CONFIRMATION_WINDOW_READY:break;case vL.TRANSACTION_CONFIRMED:i({confirmed:!0});break;case vL.TRANSACTION_ERROR:a(new Error("Transaction error"));break;default:a(new Error("Unsupported message type"))}};if(window.addEventListener("message",s),!this.confirmationWindow)return void i({confirmed:!1});let o="";o=r===wU?`${this.config.passportDomain}/transaction-confirmation/transaction.html?transactionId=${e}&imxEtherAddress=${t}&chainType=starkex`:`${this.config.passportDomain}/transaction-confirmation/zkevm?transactionId=${e}&imxEtherAddress=${t}&chainType=evm&chainId=${n}`,this.confirmationWindow.location.href=o;const c=setInterval((()=>{this.confirmationWindow?.closed&&(clearInterval(c),window.removeEventListener("message",s),i({confirmed:!1}))}),1e3)}))}loading(e){this.confirmationWindow=AL({url:`${this.config.passportDomain}/transaction-confirmation/loading.html`,title:SL,width:e?.width||480,height:e?.height||380})}closeWindow(){this.confirmationWindow?.close()}}var xL;!function(e){e.PENDING="PENDING",e.SUBMITTED="SUBMITTED",e.SUCCESSFUL="SUCCESSFUL",e.REVERTED="REVERTED",e.FAILED="FAILED"}(xL||(xL={})),e.ProviderEvent=void 0,(e.ProviderEvent||(e.ProviderEvent={})).ACCOUNTS_CHANGED="accountsChanged";class TL{emitter=new qp;emit(e,...t){this.emitter.emit(e,...t)}on(e,t){this.emitter.on(e,t)}removeListener(e,t){this.emitter.removeListener(e,t)}}class RL{config;user;constructor({config:e,user:t}){this.config=e,this.user=t}async postToRelayer(e){const t={id:1,jsonrpc:"2.0",...e},r=await fetch(`${this.config.relayerUrl}/v1/transactions`,{method:"POST",headers:{Authorization:`Bearer ${this.user.accessToken}`,"Content-Type":"application/json"},body:JSON.stringify(t)}),n=await r.json();if(n.error)throw n.error;return n}async ethSendTransaction(e,t){const r={method:"eth_sendTransaction",params:[{to:e,data:t,chainId:this.config.zkEvmChainId.toString()}]},{result:n}=await this.postToRelayer(r);return n}async imGetTransactionByHash(e){const t={method:"im_getTransactionByHash",params:[e]},{result:r}=await this.postToRelayer(t);return r}async imGetFeeOptions(e,t){const r={method:"im_getFeeOptions",params:[{userAddress:e,data:t,chainId:this.config.zkEvmChainId.toString()}]},{result:n}=await this.postToRelayer(r);return n}}const OL=async({authManager:t,config:r,magicAdapter:n,multiRollupApiClients:i})=>{const a=await t.getUser()||await t.login();if(!a.idToken)throw new Error("User is missing idToken");const s=await n.login(a.idToken,r.network);if(!a.zkEvm){const r=await async function({authManager:t,magicProvider:r,multiRollupApiClients:n,accessToken:i}){const a=new Lc(r).getSigner(),s=await a.getAddress(),o=await AU("Only sign this message from Immutable Passport",a),c={Authorization:`Bearer ${i}`};try{await n.passportApi.createCounterfactualAddress({createCounterfactualAddressRequest:{ethereumAddress:s,ethereumSignature:o}},{headers:c})}catch(t){throw new fL(e.RpcErrorCode.INTERNAL_ERROR,`Failed to create counterfactual address: ${t}`)}const f=await t.loginSilent();if(!f?.zkEvm)throw new fL(e.RpcErrorCode.INTERNAL_ERROR,"Failed to refresh user details");return f}({authManager:t,magicProvider:s,multiRollupApiClients:i,accessToken:a.accessToken});return{user:r,magicProvider:s}}return{user:a,magicProvider:s}};const IL=async(e,t,r,n,i)=>{const a=e.map((e=>({delegateCall:!0===e.delegateCall,revertOnError:!0===e.revertOnError,gasLimit:e.gasLimit??Ar,target:e.to??_r,value:e.value??Ar,data:e.data??[]})));const s=function(e,t){return $t(Fr.encode(["uint256","tuple(\n bool delegateCall,\n bool revertOnError,\n uint256 gasLimit,\n address target,\n uint256 value,\n bytes data\n)[]"],[e,t]))}(t,a),o=ke($t(Hc(["string","uint256","address","bytes32"],["",r,n,s]))),c=await i.signMessage(o),f=VU({threshold:1,signers:[{weight:1,signature:`${c}02`}]}),u=new zn(kU.mainModule.abi);return u.encodeFunctionData(u.getFunction("execute"),[a,t,f])},ML=async({params:t,magicProvider:r,jsonRpcProvider:n,relayerClient:i,guardianClient:a,config:s,user:o})=>{a.loading({width:480,height:520});const c=t[0];if(!c.to)throw new fL(e.RpcErrorCode.INVALID_PARAMS,'eth_sendTransaction requires a "to" field');const f=(e=>{const t=e.split(":");if(2!==t.length)throw new Error("Invalid configuration, chain ID is not in CAIP-2 format");return He.from(t[1])})(s.zkEvmChainId),u=new Lc(r).getSigner(),d=await(async(e,t)=>{const r=await e.send("eth_getCode",[t,"latest"]);if(r&&"0x"!==r)return new mo(t,kU.mainModule.abi,e).nonce();return 0})(n,o.zkEvm.ethAddress),l={to:c.to,data:c.data,nonce:d,value:c.value,revertOnError:!0},h=await IL([l],d,f,o.zkEvm.ethAddress,u),p=(await i.imGetFeeOptions(o.zkEvm.ethAddress,h)).find((e=>"IMX"===e.tokenSymbol));if(!p)throw new Error("Failed to retrieve fees for IMX token");const b={nonce:d,to:p.recipientAddress,value:p.tokenPrice,revertOnError:!0};await a.validateEVMTransaction({chainId:s.zkEvmChainId,nonce:uL(d),user:o,metaTransactions:[l,b]});const g=await IL([l,b],d,f,o.zkEvm.ethAddress,u),m=await i.ethSendTransaction(o.zkEvm.ethAddress,g),y=await sL((async()=>{const e=await i.imGetTransactionByHash(m);if(e.status===xL.PENDING)throw new Error;return e}),{retries:30,interval:1e3,finalErr:new fL(e.RpcErrorCode.RPC_SERVER_ERROR,"transaction hash not generated in time")});if(![xL.SUBMITTED,xL.SUCCESSFUL].includes(y.status))throw new fL(e.RpcErrorCode.RPC_SERVER_ERROR,`Transaction failed to submit with status ${y.status}`);return y.hash};class CL{authManager;config;confirmationScreen;magicAdapter;transactionAPI;multiRollupApiClients;jsonRpcProvider;eventEmitter;guardianClient;relayerClient;magicProvider;user;constructor({authManager:e,magicAdapter:t,config:r,confirmationScreen:n,multiRollupApiClients:i}){this.authManager=e,this.magicAdapter=t,this.config=r,this.confirmationScreen=n,this.transactionAPI=new yU(new vU({basePath:this.config.imxPublicApiDomain})),this.jsonRpcProvider=new Pc(this.config.zkEvmRpcUrl),this.multiRollupApiClients=i,this.eventEmitter=new TL}isPassport=!0;isLoggedIn(){return void 0!==this.magicProvider&&void 0!==this.user&&void 0!==this.relayerClient&&void 0!==this.guardianClient}async performRequest(t){switch(t.method){case"eth_requestAccounts":{if(this.isLoggedIn())return[this.user.zkEvm.ethAddress];const{magicProvider:t,user:r}=await OL({authManager:this.authManager,config:this.config,magicAdapter:this.magicAdapter,multiRollupApiClients:this.multiRollupApiClients});return this.user=r,this.magicProvider=t,this.relayerClient=new RL({config:this.config,user:this.user}),this.guardianClient=new dL({imxPublicApiDomain:this.config.imxPublicApiDomain,accessToken:this.user.accessToken,confirmationScreen:this.confirmationScreen,imxEtherAddress:this.user.zkEvm.ethAddress}),this.eventEmitter.emit(e.ProviderEvent.ACCOUNTS_CHANGED,[this.user.zkEvm.ethAddress]),[this.user.zkEvm.ethAddress]}case"eth_sendTransaction":if(!this.isLoggedIn())throw new fL(e.ProviderErrorCode.UNAUTHORIZED,"Unauthorised - call eth_requestAccounts first");return ML({params:t.params||[],magicProvider:this.magicProvider,guardianClient:this.guardianClient,jsonRpcProvider:this.jsonRpcProvider,config:this.config,relayerClient:this.relayerClient,user:this.user});case"eth_accounts":return this.isLoggedIn()?[this.user.zkEvm.ethAddress]:[];case"eth_gasPrice":case"eth_getBalance":case"eth_getStorageAt":case"eth_estimateGas":case"eth_call":case"eth_blockNumber":case"eth_chainId":case"eth_getBlockByHash":case"eth_getBlockByNumber":case"eth_getTransactionByHash":case"eth_getTransactionReceipt":case"eth_getTransactionCount":return this.jsonRpcProvider.send(t.method,t.params||[]);default:throw new fL(e.ProviderErrorCode.UNSUPPORTED_METHOD,"Method not supported")}}async performJsonRpcRequest(t){const{id:r,jsonrpc:n}=t;try{return{id:r,jsonrpc:n,result:await this.performRequest(t)}}catch(t){let i;return i=t instanceof fL?t:t instanceof Error?new fL(e.RpcErrorCode.INTERNAL_ERROR,t.message):new fL(e.RpcErrorCode.INTERNAL_ERROR,"Internal error"),{id:r,jsonrpc:n,error:i}}}async request(t){try{return this.performRequest(t)}catch(t){if(t instanceof fL)throw t;if(t instanceof Error)throw new fL(e.RpcErrorCode.INTERNAL_ERROR,t.message);throw new fL(e.RpcErrorCode.INTERNAL_ERROR,"Internal error")}}sendAsync(e,t){if(!t)throw new Error("No callback provided");Array.isArray(e)?Promise.all(e.map(this.performJsonRpcRequest)).then((e=>{t(null,e)})).catch((e=>{t(e,[])})):this.performJsonRpcRequest(e).then((e=>{t(null,e)})).catch((e=>{t(e,null)}))}async send(t,r,n){if("string"==typeof t)return"function"==typeof r?this.sendAsync({method:t,params:[]},r):n?this.sendAsync({method:t,params:Array.isArray(r)?r:[]},n):this.request({method:t,params:Array.isArray(r)?r:[]});if("function"==typeof r)return this.sendAsync(t,r);if(!Array.isArray(t)&&"object"==typeof t)return this.performJsonRpcRequest(t);throw new fL(e.RpcErrorCode.INVALID_REQUEST,"Invalid request")}on(e,t){this.eventEmitter.on(e,t)}removeListener(e,t){this.eventEmitter.removeListener(e,t)}}var PL=n((function({mustBeMetaMask:e=!1,silent:t=!1,timeout:r=3e3}={}){!function(){if("boolean"!=typeof e)throw new Error("@metamask/detect-provider: Expected option 'mustBeMetaMask' to be a boolean.");if("boolean"!=typeof t)throw new Error("@metamask/detect-provider: Expected option 'silent' to be a boolean.");if("number"!=typeof r)throw new Error("@metamask/detect-provider: Expected option 'timeout' to be a number.")}();let n=!1;return new Promise((i=>{function a(){if(n)return;n=!0,window.removeEventListener("ethereum#initialized",a);const{ethereum:r}=window;if(!r||e&&!r.isMetaMask){const n=e&&r?"Non-MetaMask window.ethereum detected.":"Unable to detect window.ethereum.";!t&&console.error("@metamask/detect-provider:",n),i(null)}else i(r)}window.ethereum?a():(window.addEventListener("ethereum#initialized",a,{once:!0}),setTimeout((()=>{a()}),r))}))}));async function NL(e,t){if(!function(e,t){return e===t.ethConfiguration.chainID}(await e.getChainId(),t))throw new Error("The wallet used for this operation is not connected to the correct network.")}async function BL(e,t,r){await NL(t,r.immutableXConfig);const n=wA.Registration.connect(r.immutableXConfig.ethConfiguration.registrationContractAddress,t);try{return await n.isRegistered(e)}catch(e){if("USER_UNREGISTERED"===e.reason)return!1;throw e}}async function UL(e,t,r){const n=await r.getSignableRegistration({getSignableRegistrationRequest:{ether_key:e,stark_key:t}});return{operator_signature:n.data.operator_signature,payload_hash:n.data.payload_hash}}const LL=e=>{if(void 0!==e)return e;throw new Error("undefined field exception")};async function jL(e){const{signers:{ethSigner:t,starkSigner:r},type:n,config:i}=e;await NL(t,e.config);const a=new Sk(i.apiConfiguration),s="ERC721"===n?"1":e.amount,o=await a.getSignableWithdrawal({getSignableWithdrawalRequest:{user:await t.getAddress(),token:SU(e),amount:s}}),{signable_message:c,payload_hash:f}=o.data,u=await r.signMessage(f),{ethAddress:d,ethSignature:l}=await async function(e,t){return{message:e,ethAddress:await t.getAddress(),ethSignature:await AU(e,t)}}(c,t);return(await a.createWithdrawal({createWithdrawalRequest:{stark_key:LL(o.data.stark_key),amount:s,asset_id:LL(o.data.asset_id),vault_id:LL(o.data.vault_id),nonce:LL(o.data.nonce),stark_signature:u},xImxEthAddress:d,xImxEthSignature:l})).data}async function DL(e,t,r,n){const i=new IS(r.apiConfiguration);return(await i.encodeAsset({assetType:e,encodeAssetRequest:{token:{type:t,...n&&{data:n}}}})).data}async function FL({ethSigner:e,starkPublicKey:t,token:r,config:n}){await NL(e,n.immutableXConfig);const i=n.immutableXConfig,a=await DL("asset","ERC20",i,{token_address:r.tokenAddress});return await BL(t,e,n)?async function(e,t,r,n){const i=wA.Core.connect(n.ethConfiguration.coreContractAddress,e),a=await i.populateTransaction.withdraw(r,t);return e.sendTransaction(a)}(e,a.asset_type,t,i):async function({ethSigner:e,assetType:t,starkPublicKey:r,config:n}){const i=await e.getAddress(),a=n.immutableXConfig,s=new wk(a.apiConfiguration),o=await UL(i,r,s),c=wA.Registration.connect(n.immutableXConfig.ethConfiguration.registrationContractAddress,e),f=await c.populateTransaction.registerAndWithdraw(i,r,o.operator_signature,t);return e.sendTransaction(f)}({ethSigner:e,assetType:a.asset_type,starkPublicKey:t,config:n})}async function qL(e,t,r,n){const i=n.immutableXConfig,a=await DL("mintable-asset","ERC721",i,{id:r.data.id,token_address:r.data.tokenAddress,...r.data.blueprint&&{blueprint:r.data.blueprint}}),s=function(e){const{id:t}=e.data,r=e.data.blueprint||"";return Xf(kf(`{${t}}:{${r}}`))}(r);return await BL(t,e,n)?async function(e,t,r,n,i){const a=wA.Core.connect(i.ethConfiguration.coreContractAddress,e),s=await a.populateTransaction.withdrawAndMint(r,t,n);return e.sendTransaction(s)}(e,a.asset_type,t,s,i):async function(e,t,r,n,i){const a=await e.getAddress(),s=new wk(i.apiConfiguration),o=await UL(a,r,s),c=wA.Registration.connect(i.ethConfiguration.registrationContractAddress,e),f=await c.populateTransaction.regsiterAndWithdrawAndMint(a,r,o.operator_signature,t,n);return e.sendTransaction(f)}(e,a.asset_type,t,s,i)}async function zL(e,t,r,n){const i=n.immutableXConfig,a=await DL("asset","ERC721",i,{token_id:r.tokenId,token_address:r.tokenAddress});return await BL(t,e,n)?async function(e,t,r,n,i){const a=wA.Core.connect(i.ethConfiguration.coreContractAddress,e),s=await a.populateTransaction.withdrawNft(r,t,n);return e.sendTransaction(s)}(e,a.asset_type,t,r.tokenId,i):async function(e,t,r,n,i){const a=await e.getAddress(),s=new wk(i.apiConfiguration),o=await UL(a,r,s),c=wA.Registration.connect(i.ethConfiguration.registrationContractAddress,e),f=await c.populateTransaction.registerAndWithdrawNft(a,r,o.operator_signature,t,n);return e.sendTransaction(f)}(e,a.asset_type,t,r.tokenId,i)}async function KL({ethSigner:e,starkPublicKey:t,config:r}){await NL(e,r.immutableXConfig);const n=r.immutableXConfig,i=await DL("asset","ETH",n);return await BL(t,e,r)?async function(e,t,r,n){const i=wA.Core.connect(n.ethConfiguration.coreContractAddress,e),a=await i.populateTransaction.withdraw(r,t);return e.sendTransaction(a)}(e,i.asset_type,t,n):async function(e,t,r,n){const i=await e.getAddress(),a=new wk(n.apiConfiguration),s=await UL(i,r,a),o=wA.Registration.connect(n.ethConfiguration.registrationContractAddress,e),c=await o.populateTransaction.registerAndWithdraw(i,r,s.operator_signature,t);return e.sendTransaction(c)}(e,i.asset_type,t,n)}async function HL({signers:{ethSigner:e},starkPublicKey:t,token:r,config:n}){switch(r.type){case"ETH":return KL({ethSigner:e,starkPublicKey:t,config:n});case"ERC20":return FL({ethSigner:e,starkPublicKey:t,token:r,config:n});case"ERC721":return async function({ethSigner:e,starkPublicKey:t,token:r,config:n}){await NL(e,n.immutableXConfig);const{tokenAddress:i}=r,{tokenId:a}=r,s=n.immutableXConfig,o=new VS(s.apiConfiguration);return await o.getMintableTokenDetailsByClientTokenId({tokenAddress:i,tokenId:a}).then((r=>qL(e,t,{type:"ERC721",data:{id:a,tokenAddress:i,blueprint:r.data.blueprint}},n))).catch((i=>{if(404===i.response?.status)return zL(e,t,r,n);throw i}))}({ethSigner:e,starkPublicKey:t,token:r,config:n})}}async function GL({signers:{ethSigner:e},deposit:t,config:r}){await NL(e,r.immutableXConfig);const n=await e.getAddress(),i=Wc(t.amount,"wei"),a=r.immutableXConfig,s=new xS(a.apiConfiguration),o=new IS(a.apiConfiguration),c=new wk(a.apiConfiguration),f={user:n,token:{type:t.type,data:{decimals:18}},amount:i.toString()},u=await s.getSignableDeposit({getSignableDepositRequest:f}),d=(await o.encodeAsset({assetType:"asset",encodeAssetRequest:{token:{type:t.type}}})).data.asset_type,l=u.data.stark_key,h=u.data.vault_id;return await BL(l,e,r)?async function(e,t,r,n,i,a){const s=wA.Core.connect(a.ethConfiguration.coreContractAddress,e),o=await s.populateTransaction["deposit(uint256,uint256,uint256)"](n,r,i);return e.sendTransaction({...o,value:t})}(e,i,d,l,h,a):async function(e,t,r,n,i,a,s){const o=await e.getAddress(),c=wA.Core.connect(a.ethConfiguration.coreContractAddress,e),f=await UL(o,n,s),u=await c.populateTransaction.registerAndDepositEth(o,n,f.operator_signature,r,i);return e.sendTransaction({...u,value:t})}(e,i,d,l,h,a,c)}async function VL({signers:{ethSigner:e},deposit:t,config:r}){await NL(e,r.immutableXConfig);const{apiConfiguration:n,ethConfiguration:i}=r.immutableXConfig,a=await e.getAddress(),s=new ck(n),o=new xS(n),c=new IS(n),f=new wk(n),u=await s.getToken({address:t.tokenAddress}),d={decimals:parseInt(u.data.decimals),token_address:t.tokenAddress},l=Wc(t.amount,0),h=wA.IERC20.connect(t.tokenAddress,e),p=await h.populateTransaction.approve(i.coreContractAddress,l);await e.sendTransaction(p);const b={user:a,token:{type:t.type,data:d},amount:l.toString()},g=await o.getSignableDeposit({getSignableDepositRequest:b}),m=(await c.encodeAsset({assetType:"asset",encodeAssetRequest:{token:{type:t.type,data:{token_address:t.tokenAddress}}}})).data.asset_type,y=g.data.stark_key,v=g.data.vault_id,w=He.from(g.data.amount);return await BL(y,e,r)?async function(e,t,r,n,i,a){const s=wA.Core.connect(a.coreContractAddress,e),o=await s.populateTransaction.depositERC20(n,r,i,t);return e.sendTransaction(o)}(e,w,m,y,v,i):async function(e,t,r,n,i,a,s){const o=await e.getAddress(),c=wA.Core.connect(a.coreContractAddress,e),f=await UL(o,n,s),u=await c.populateTransaction.registerAndDepositERC20(o,n,f.operator_signature,r,i,t);return e.sendTransaction(u)}(e,w,m,y,v,i,f)}async function WL({signers:{ethSigner:e},deposit:t,config:r}){await NL(e,r.immutableXConfig);const n=await e.getAddress(),{immutableXConfig:i}=r,a=new xS(i.apiConfiguration),s=new IS(i.apiConfiguration),o=new wk(i.apiConfiguration),c={token_address:t.tokenAddress,token_id:t.tokenId},f={user:n,token:{type:t.type,data:c},amount:"1".toString()},u=await a.getSignableDeposit({getSignableDepositRequest:f}),d=(await s.encodeAsset({assetType:"asset",encodeAssetRequest:{token:{type:t.type,data:{token_address:t.tokenAddress,token_id:t.tokenId}}}})).data.asset_type,l=u.data.stark_key,h=u.data.vault_id,p=await BL(l,e,r),b=wA.IERC721.connect(t.tokenAddress,e),g=i.ethConfiguration.coreContractAddress;if(await b.isApprovedForAll(n,g)||await b.setApprovalForAll(g,!0),!p){const t=await UL(n,l,o),r=wA.Core.connect(i.ethConfiguration.coreContractAddress,e);await r.registerUser(n,l,t.operator_signature)}return async function(e,t,r,n,i,a){const s=wA.Core.connect(a.ethConfiguration.coreContractAddress,e),o=await s.populateTransaction.depositNft(n,r,i,t);return e.sendTransaction(o)}(e,t.tokenId,d,l,h,i)}class XL{config;signers;constructor(e,t,r){this.config=e,this.signers={ethSigner:t,starkSigner:r}}async getAddress(){return await this.signers.ethSigner.getAddress()}registerOffchain(){return async function(e,t){await NL(e.ethSigner,t.immutableXConfig);const r=new wk(t.immutableXConfig.apiConfiguration),n=await e.ethSigner.getAddress(),i=await e.starkSigner.getAddress(),a=await r.getSignableRegistrationOffchain({getSignableRegistrationRequest:{ether_key:n,stark_key:i}}),{signable_message:s,payload_hash:o}=a.data,c=await AU(s,e.ethSigner),f=await e.starkSigner.signMessage(o);return(await r.registerUser({registerUserRequest:{eth_signature:c,ether_key:n,stark_signature:f,stark_key:i}})).data}(this.signers,this.config)}batchNftTransfer(e){return async function({signers:{ethSigner:e,starkSigner:t},request:r,config:n}){await NL(e,n.immutableXConfig);const i=await e.getAddress(),a=new gk(n.immutableXConfig.apiConfiguration),s=r.map((e=>({amount:"1",token:SU({type:"ERC721",tokenId:e.tokenId,tokenAddress:e.tokenAddress}),receiver:e.receiver}))),o=await a.getSignableTransfer({getSignableTransferRequestV2:{sender_ether_key:i,signable_requests:s}}),c=o.data.signable_message;if(void 0===c)throw new Error("Invalid response from Signable registration offchain");const f=await AU(c,e),u=[];for(const e of o.data.signable_responses){const r=await t.signMessage(e.payload_hash),n={sender_vault_id:e.sender_vault_id,receiver_stark_key:e.receiver_stark_key,receiver_vault_id:e.receiver_vault_id,asset_id:e.asset_id,amount:e.amount,nonce:e.nonce,expiration_timestamp:e.expiration_timestamp,stark_signature:r};u.push(n)}const d={sender_stark_key:o.data.sender_stark_key,requests:u},l=await a.createTransfer({createTransferRequestV2:d,xImxEthAddress:i,xImxEthSignature:f});return{transfer_ids:l?.data.transfer_ids}}({signers:this.signers,request:e,config:this.config})}cancelOrder(e){return async function({signers:e,request:t,config:r}){const n=new ek(r.immutableXConfig.apiConfiguration),i=await n.getSignableCancelOrder({getSignableCancelOrderRequest:{order_id:t.order_id}}),{signable_message:a,payload_hash:s}=i.data,o=await AU(a,e.ethSigner),c=await e.starkSigner.signMessage(s),f=await e.ethSigner.getAddress(),u=await n.cancelOrder({id:t.order_id.toString(),cancelOrderRequest:{order_id:t.order_id,stark_signature:c},xImxEthAddress:f,xImxEthSignature:o});return{order_id:u.data.order_id,status:u.data.status}}({signers:this.signers,request:e,config:this.config})}completeWithdrawal(e,t){return HL({config:this.config,signers:this.signers,token:t,starkPublicKey:e})}createOrder(e){return async function({signers:e,request:t,config:r}){await NL(e.ethSigner,r.immutableXConfig);const n=await e.ethSigner.getAddress(),i=new ek(r.immutableXConfig.apiConfiguration),a="ERC721"===t.sell.type?"1":t.sell.amount,s={user:n,amount_buy:"ERC721"===t.buy.type?"1":t.buy.amount,token_buy:SU(t.buy),amount_sell:a,token_sell:SU(t.sell),fees:t.fees,expiration_timestamp:t.expiration_timestamp},o=await i.getSignableOrder({getSignableOrderRequestV3:s}),{signable_message:c,payload_hash:f}=o.data,u=await AU(c,e.ethSigner),d=await e.starkSigner.signMessage(f),l=o.data,h={createOrderRequest:{amount_buy:l.amount_buy,amount_sell:l.amount_sell,asset_id_buy:l.asset_id_buy,asset_id_sell:l.asset_id_sell,expiration_timestamp:l.expiration_timestamp,include_fees:!0,fees:t.fees,nonce:l.nonce,stark_key:l.stark_key,stark_signature:d,vault_id_buy:l.vault_id_buy,vault_id_sell:l.vault_id_sell},xImxEthAddress:n,xImxEthSignature:u};return{...(await i.createOrder(h)).data}}({signers:this.signers,request:e,config:this.config})}createTrade(e){return async function({signers:{ethSigner:e,starkSigner:t},request:r,config:n}){await NL(e,n.immutableXConfig);const i=await e.getAddress(),a=new lk(n.immutableXConfig.apiConfiguration),s=await a.getSignableTrade({getSignableTradeRequest:{user:i,order_id:r.order_id,fees:r.fees}}),{signable_message:o,payload_hash:c}=s.data,f=await AU(o,e),u=await t.signMessage(c);return(await a.createTrade({createTradeRequest:{amount_buy:s.data.amount_buy,amount_sell:s.data.amount_sell,asset_id_buy:s.data.asset_id_buy,asset_id_sell:s.data.asset_id_sell,expiration_timestamp:s.data.expiration_timestamp,fee_info:s.data.fee_info,fees:r.fees,include_fees:!0,nonce:s.data.nonce,order_id:r.order_id,stark_key:s.data.stark_key,vault_id_buy:s.data.vault_id_buy,vault_id_sell:s.data.vault_id_sell,stark_signature:u},xImxEthAddress:i,xImxEthSignature:f})).data}({signers:this.signers,request:e,config:this.config})}deposit(e){return async function({signers:e,deposit:t,config:r}){switch(t.type){case"ETH":return GL({signers:e,deposit:t,config:r});case"ERC20":return VL({signers:e,deposit:t,config:r});case"ERC721":return WL({signers:e,deposit:t,config:r})}}({signers:this.signers,deposit:e,config:this.config})}exchangeTransfer(e){return async function({signers:e,request:t,config:r}){await NL(e.ethSigner,r.immutableXConfig);const n=new NS(r.immutableXConfig.apiConfiguration),i=await e.ethSigner.getAddress(),a=t.amount,s=await n.getExchangeSignableTransfer({id:t.transactionID,getSignableTransferRequest:{sender:i,token:SU(t),amount:a,receiver:t.receiver}}),{signable_message:o,payload_hash:c}=s.data,f=await AU(o,e.ethSigner),u=await e.starkSigner.signMessage(c),d={sender_stark_key:s.data.sender_stark_key,sender_vault_id:s.data.sender_vault_id,receiver_stark_key:s.data.receiver_stark_key,receiver_vault_id:s.data.receiver_vault_id,asset_id:s.data.asset_id,amount:s.data.amount,nonce:s.data.nonce,expiration_timestamp:s.data.expiration_timestamp,stark_signature:u},l=await n.createExchangeTransfer({id:t.transactionID,createTransferRequest:d,xImxEthAddress:i,xImxEthSignature:f});return{sent_signature:l?.data.sent_signature,status:l?.data.status?.toString(),time:l?.data.time,transfer_id:l?.data.transfer_id}}({signers:this.signers,request:e,config:this.config})}async isRegisteredOnchain(){return BL(await this.signers.starkSigner.getAddress(),this.signers.ethSigner,this.config)}prepareWithdrawal(e){return async function({signers:e,withdrawal:t,config:r}){return jL({signers:e,config:r.immutableXConfig,...t})}({signers:this.signers,withdrawal:e,config:this.config})}transfer(e){return async function({signers:{ethSigner:e,starkSigner:t},request:r,config:n}){await NL(e,n.immutableXConfig);const i=await e.getAddress(),a=new gk(n.immutableXConfig.apiConfiguration),s="ERC721"===r.type?"1":r.amount,o=await a.getSignableTransferV1({getSignableTransferRequest:{sender:i,token:SU(r),amount:s,receiver:r.receiver}}),{signable_message:c,payload_hash:f}=o.data,u=await AU(c,e),d=await t.signMessage(f),l={sender_stark_key:o.data.sender_stark_key,sender_vault_id:o.data.sender_vault_id,receiver_stark_key:o.data.receiver_stark_key,receiver_vault_id:o.data.receiver_vault_id,asset_id:o.data.asset_id,amount:o.data.amount,nonce:o.data.nonce,expiration_timestamp:o.data.expiration_timestamp,stark_signature:d},h=await a.createTransferV1({createTransferRequest:l,xImxEthAddress:i,xImxEthSignature:u});return{sent_signature:h?.data.sent_signature,status:h?.data.status?.toString(),time:h?.data.time,transfer_id:h?.data.transfer_id}}({signers:this.signers,request:e,config:this.config})}}const $L={SWITCH_CHAIN:"wallet_switchEthereumChain",CONNECT:"eth_requestAccounts"};const JL="The Metamask provider was not found";async function YL({chainID:e}){const t=await PL();if(!function(e){return!!e?.request}(t))throw new Error(JL);return await async function(e,t){await e.request({method:$L.CONNECT}),t&&await e.request({method:$L.SWITCH_CHAIN,params:[{chainId:`0x${t.toString(16)}`}]})}(t,e),new Lc(t)}const QL="message";var ZL,ej;function tj(e,t){e&&e.contentWindow&&e.contentWindow.postMessage(t,new URL(e.src).origin)}function rj(e,t,r,n){if(e&&t.source!==e.contentWindow)return;const i=t.data;i.type===r&&n(i.details)}!function(e){e.GET_CONNECTION_REQUEST="GET_CONNECTION_REQUEST",e.CONNECT_WALLET_REQUEST="CONNECT_WALLET_REQUEST",e.SIGN_MESSAGE_REQUEST="SIGN_MESSAGE_REQUEST",e.DISCONNECT_WALLET_REQUEST="DISCONNECT_WALLET_REQUEST"}(ZL||(ZL={})),function(e){e.CONNECT_WALLET_RESPONSE="CONNECT_WALLET_RESPONSE",e.SIGN_MESSAGE_RESPONSE="SIGN_MESSAGE_RESPONSE",e.GET_CONNECTION_RESPONSE="GET_CONNECTION_RESPONSE",e.DISCONNECT_WALLET_RESPONSE="DISCONNECT_WALLET_RESPONSE"}(ej||(ej={}));class nj{publicAddress;iframe;constructor(e,t){this.publicAddress=e,this.iframe=t}getAddress(){return this.publicAddress}signMessage(e){return new Promise(((t,r)=>{const n=e=>{rj(this.iframe,e,ej.SIGN_MESSAGE_RESPONSE,(e=>{window.removeEventListener(QL,n),e.success||r(new Error(e.error?.message)),t(e.data.signedMessage)}))};window.addEventListener(QL,n),tj(this.iframe,{type:ZL.SIGN_MESSAGE_REQUEST,details:{starkPublicKey:this.publicAddress,message:e}})}))}getIFrame(){return this.iframe}}const ij="imx-wallet-app",aj={[e.Environment.SANDBOX]:"https://wallets.sandbox.immutable.com",[e.Environment.PRODUCTION]:"https://wallets.immutable.com"},sj="display: none;";async function oj(e){const t=document.querySelector(`iframe#${ij}`);return t||await async function(e){return new Promise((t=>{const r=document.createElement("iframe");r.setAttribute("id",ij),r.setAttribute("src",aj[e]),r.setAttribute("style",sj),document.body.appendChild(r),r.onload=()=>t(r)}))}(e)}var cj;!function(e){e.PROVIDER_CONNECTION_ERROR="PROVIDER_CONNECTION_ERROR",e.WALLET_CONNECTION_ERROR="WALLET_CONNECTION_ERROR"}(cj||(cj={}));class fj extends Error{type;constructor(e,t){super(e),this.type=t}}const uj=async(e,t)=>{try{return await e()}catch(e){const r=t.message||`${e.message}`||"UnknownError";throw new fj(r,t.type)}};class dj extends XL{static imxSigner;static async connect(e){return await uj((async()=>{const t=await YL({chainID:e.immutableXConfig.ethConfiguration.chainID});return this.imxSigner=await async function(e,t){const r=e.getSigner(),n=await r.getAddress(),i=await r.signMessage("Only sign this request if you’ve initiated an action with Immutable X."),a=await oj(t);return new Promise(((e,t)=>{const r=n=>{rj(a,n,ej.CONNECT_WALLET_RESPONSE,(n=>{window.removeEventListener(QL,r),n.success||t(new Error("The L2 IMX Wallet connection has failed")),e(new nj(n.data.starkPublicKey,a))}))};window.addEventListener(QL,r),tj(a,{type:ZL.CONNECT_WALLET_REQUEST,details:{ethAddress:n,signature:i}})}))}(t,e.baseConfig.environment),new dj(e,t.getSigner(),this.imxSigner)}),{type:cj.WALLET_CONNECTION_ERROR})}static async disconnect(){if(!this.imxSigner)throw new fj("Attempted to disconnect from the MetaMask IMX provider without an established connection",cj.PROVIDER_CONNECTION_ERROR);return uj((async()=>{await async function(e){const t=e.getIFrame();return new Promise(((r,n)=>{const i=e=>{rj(t,e,ej.DISCONNECT_WALLET_RESPONSE,(e=>{window.removeEventListener(QL,i),!e.success&&e.error&&n(e.error),t.remove(),r()}))};window.addEventListener(QL,i),tj(t,{type:ZL.DISCONNECT_WALLET_REQUEST,details:{starkPublicKey:e.getAddress()}})}))}(this.imxSigner)}),{type:cj.PROVIDER_CONNECTION_ERROR})}static async signMessage(e){if(!this.imxSigner)throw new fj("Attempted to sign a message with the MetaMask IMX provider without an established connection",cj.PROVIDER_CONNECTION_ERROR);return uj((async()=>await this.imxSigner.signMessage(e)),{type:cj.PROVIDER_CONNECTION_ERROR})}}e.GenericIMXProvider=XL,e.ImmutableConfiguration=class{environment;apiKey;constructor(e){this.environment=e.environment,this.apiKey=e.apiKey}},e.ImmutableXClient=mR,e.JsonRpcError=fL,e.MetaMaskIMXProvider=dj,e.Passport=class{authManager;config;confirmationScreen;immutableXClient;magicAdapter;passportImxProviderFactory;multiRollupApiClients;constructor(e){this.config=new yL(e),this.authManager=new rL(this.config),this.magicAdapter=new nL(this.config),this.confirmationScreen=new kL(this.config),this.immutableXClient=e.overrides?.immutableXClient||new mR({baseConfig:e.baseConfig}),this.multiRollupApiClients=new EI(this.config.multiRollupConfig),this.passportImxProviderFactory=new bL({authManager:this.authManager,config:this.config,confirmationScreen:this.confirmationScreen,immutableXClient:this.immutableXClient,magicAdapter:this.magicAdapter})}async connectImxSilent(){return this.passportImxProviderFactory.getProviderSilent()}async connectImx(){return this.passportImxProviderFactory.getProvider()}async loginWithDeviceFlow(){return this.authManager.loginWithDeviceFlow()}async connectImxDeviceFlow(e,t,r){return this.passportImxProviderFactory.getProviderWithDeviceFlow(e,t,r)}getPKCEAuthorizationUrl(){return this.authManager.getPKCEAuthorizationUrl()}async connectImxPKCEFlow(e,t){return this.passportImxProviderFactory.getProviderWithPKCEFlow(e,t)}checkStoredDeviceFlowCredentials(){return this.authManager.checkStoredDeviceFlowCredentials()}async connectImxWithCredentials(e){return this.passportImxProviderFactory.getProviderWithCredentials(e)}connectEvm(){if(this.config.network===e.Networks.PRODUCTION)throw new Error("EVM is not supported on production network");return new CL({authManager:this.authManager,magicAdapter:this.magicAdapter,config:this.config,confirmationScreen:this.confirmationScreen,multiRollupApiClients:this.multiRollupApiClients})}async loginCallback(){return this.authManager.loginCallback()}async logout(){return this.authManager.logout()}async logoutSilentCallback(e){return this.authManager.logoutSilentCallback(e)}async logoutDeviceFlow(){return this.authManager.logoutDeviceFlow()}async getUserInfo(){const e=await this.authManager.getUser();return e?.profile}async getUserInfoDeviceFlow(){const e=await this.authManager.getUserDeviceFlow();return e?.profile}async getIdToken(){const e=await this.authManager.getUser();return e?.idToken}async getAccessToken(){const e=await this.authManager.getUser();return e?.accessToken}},e.PassportError=XU,e.ProviderConfiguration=class{immutableXConfig;baseConfig;constructor({baseConfig:t,overrides:r}){if(this.baseConfig=t,r)this.immutableXConfig=r.immutableXConfig;else switch(t.environment){case e.Environment.SANDBOX:this.immutableXConfig=eR.SANDBOX;break;case e.Environment.PRODUCTION:this.immutableXConfig=eR.PRODUCTION}}},e.imxClientCreateStarkSigner=JA,e.imxClientGenerateLegacyStarkPrivateKey=lR}));
32
32
  //# sourceMappingURL=index.browser.js.map