@imtbl/sdk 0.27.15-alpha.3 → 0.27.15-alpha.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/blockchain_data.js +1 -1
- package/dist/browser/checkout/sdk.js +1 -1
- package/dist/browser/checkout/widgets.js +1 -1
- package/dist/checkout_sdk.js +15 -6
- package/dist/immutablex_client.js +1 -1
- package/dist/index.browser.js +3 -3
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +17 -8
- package/dist/index.js +17 -8
- package/dist/passport.js +2 -2
- package/package.json +1 -1
|
@@ -32,7 +32,7 @@ n.mode.CTRGladman=function(){var e=n.lib.BlockCipherMode.extend();function t(e){
|
|
|
32
32
|
|
|
33
33
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
34
34
|
*/
|
|
35
|
-
function(e){var t=n,r=t.lib,i=r.WordArray,a=r.Hasher,o=t.algo,s=i.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),u=i.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),l=i.create([11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),c=i.create([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),d=i.create([0,1518500249,1859775393,2400959708,2840853838]),f=i.create([1352829926,1548603684,1836072691,2053994217,0]),p=o.RIPEMD160=a.extend({_doReset:function(){this._hash=i.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(e,t){for(var n=0;n<16;n++){var r=t+n,i=e[r];e[r]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8)}var a,o,p,w,E,T,A,_,x,C,k,S=this._hash.words,I=d.words,R=f.words,O=s.words,P=u.words,N=l.words,M=c.words;for(T=a=S[0],A=o=S[1],_=p=S[2],x=w=S[3],C=E=S[4],n=0;n<80;n+=1)k=a+e[t+O[n]]|0,k+=n<16?h(o,p,w)+I[0]:n<32?m(o,p,w)+I[1]:n<48?y(o,p,w)+I[2]:n<64?g(o,p,w)+I[3]:b(o,p,w)+I[4],k=(k=v(k|=0,N[n]))+E|0,a=E,E=w,w=v(p,10),p=o,o=k,k=T+e[t+P[n]]|0,k+=n<16?b(A,_,x)+R[0]:n<32?g(A,_,x)+R[1]:n<48?y(A,_,x)+R[2]:n<64?m(A,_,x)+R[3]:h(A,_,x)+R[4],k=(k=v(k|=0,M[n]))+C|0,T=C,C=x,x=v(_,10),_=A,A=k;k=S[1]+p+x|0,S[1]=S[2]+w+C|0,S[2]=S[3]+E+T|0,S[3]=S[4]+a+A|0,S[4]=S[0]+o+_|0,S[0]=k},_doFinalize:function(){var e=this._data,t=e.words,n=8*this._nDataBytes,r=8*e.sigBytes;t[r>>>5]|=128<<24-r%32,t[14+(r+64>>>9<<4)]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8),e.sigBytes=4*(t.length+1),this._process();for(var i=this._hash,a=i.words,o=0;o<5;o++){var s=a[o];a[o]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8)}return i},clone:function(){var e=a.clone.call(this);return e._hash=this._hash.clone(),e}});function h(e,t,n){return e^t^n}function m(e,t,n){return e&t|~e&n}function y(e,t,n){return(e|~t)^n}function g(e,t,n){return e&n|t&~n}function b(e,t,n){return e^(t|~n)}function v(e,t){return e<<t|e>>>32-t}t.RIPEMD160=a._createHelper(p),t.HmacRIPEMD160=a._createHmacHelper(p)}(),n.RIPEMD160)}(uC)),dC(),fC||(fC=1,function(e,t){var n;e.exports=(n=kx(),Zx(),dC(),function(){var e=n,t=e.lib,r=t.Base,i=t.WordArray,a=e.algo,o=a.SHA1,s=a.HMAC,u=a.PBKDF2=r.extend({cfg:r.extend({keySize:4,hasher:o,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var n=this.cfg,r=s.create(n.hasher,e),a=i.create(),o=i.create([1]),u=a.words,l=o.words,c=n.keySize,d=n.iterations;u.length<c;){var f=r.update(t).finalize(o);r.reset();for(var p=f.words,h=p.length,m=f,y=1;y<d;y++){m=r.finalize(m),r.reset();for(var g=m.words,b=0;b<h;b++)p[b]^=g[b]}a.concat(f),l[0]++}return a.sigBytes=4*c,a}});e.PBKDF2=function(e,t,n){return u.create(n).compute(e,t)}}(),n.PBKDF2)}(pC)),yC(),vC(),TC(),xC(),SC(),OC(),PC||(PC=1,function(e,t){var n,r;e.exports=(r=kx(),vC(),r.mode.ECB=((n=r.lib.BlockCipherMode.extend()).Encryptor=n.extend({processBlock:function(e,t){this._cipher.encryptBlock(e,t)}}),n.Decryptor=n.extend({processBlock:function(e,t){this._cipher.decryptBlock(e,t)}}),n),r.mode.ECB)}(NC)),MC||(MC=1,function(e,t){var n;e.exports=(n=kx(),vC(),n.pad.AnsiX923={pad:function(e,t){var n=e.sigBytes,r=4*t,i=r-n%r,a=n+i-1;e.clamp(),e.words[a>>>2]|=i<<24-a%4*8,e.sigBytes+=i},unpad:function(e){var t=255&e.words[e.sigBytes-1>>>2];e.sigBytes-=t}},n.pad.Ansix923)}(LC)),FC||(FC=1,function(e,t){var n;e.exports=(n=kx(),vC(),n.pad.Iso10126={pad:function(e,t){var r=4*t,i=r-e.sigBytes%r;e.concat(n.lib.WordArray.random(i-1)).concat(n.lib.WordArray.create([i<<24],1))},unpad:function(e){var t=255&e.words[e.sigBytes-1>>>2];e.sigBytes-=t}},n.pad.Iso10126)}(DC)),BC||(BC=1,function(e,t){var n;e.exports=(n=kx(),vC(),n.pad.Iso97971={pad:function(e,t){e.concat(n.lib.WordArray.create([2147483648],1)),n.pad.ZeroPadding.pad(e,t)},unpad:function(e){n.pad.ZeroPadding.unpad(e),e.sigBytes--}},n.pad.Iso97971)}(jC)),UC||(UC=1,function(e,t){var n;e.exports=(n=kx(),vC(),n.pad.ZeroPadding={pad:function(e,t){var n=4*t;e.clamp(),e.sigBytes+=n-(e.sigBytes%n||n)},unpad:function(e){for(var t=e.words,n=e.sigBytes-1;!(t[n>>>2]>>>24-n%4*8&255);)n--;e.sigBytes=n+1}},n.pad.ZeroPadding)}(zC)),VC||(VC=1,function(e,t){var n;e.exports=(n=kx(),vC(),n.pad.NoPadding={pad:function(){},unpad:function(){}},n.pad.NoPadding)}(HC)),qC||(qC=1,function(e,t){var n;e.exports=(n=kx(),vC(),function(e){var t=n,r=t.lib.CipherParams,i=t.enc.Hex;t.format.Hex={stringify:function(e){return e.ciphertext.toString(i)},parse:function(e){var t=i.parse(e);return r.create({ciphertext:t})}}}(),n.format.Hex)}(GC)),WC||(WC=1,function(e,t){var n;e.exports=(n=kx(),qx(),$x(),yC(),vC(),function(){var e=n,t=e.lib.BlockCipher,r=e.algo,i=[],a=[],o=[],s=[],u=[],l=[],c=[],d=[],f=[],p=[];!function(){for(var e=[],t=0;t<256;t++)e[t]=t<128?t<<1:t<<1^283;var n=0,r=0;for(t=0;t<256;t++){var h=r^r<<1^r<<2^r<<3^r<<4;h=h>>>8^255&h^99,i[n]=h,a[h]=n;var m=e[n],y=e[m],g=e[y],b=257*e[h]^16843008*h;o[n]=b<<24|b>>>8,s[n]=b<<16|b>>>16,u[n]=b<<8|b>>>24,l[n]=b,b=16843009*g^65537*y^257*m^16843008*n,c[h]=b<<24|b>>>8,d[h]=b<<16|b>>>16,f[h]=b<<8|b>>>24,p[h]=b,n?(n=m^e[e[e[g^m]]],r^=e[e[r]]):n=r=1}}();var h=[0,1,2,4,8,16,32,64,128,27,54],m=r.AES=t.extend({_doReset:function(){if(!this._nRounds||this._keyPriorReset!==this._key){for(var e=this._keyPriorReset=this._key,t=e.words,n=e.sigBytes/4,r=4*((this._nRounds=n+6)+1),a=this._keySchedule=[],o=0;o<r;o++)if(o<n)a[o]=t[o];else{var s=a[o-1];o%n?n>6&&o%n==4&&(s=i[s>>>24]<<24|i[s>>>16&255]<<16|i[s>>>8&255]<<8|i[255&s]):(s=i[(s=s<<8|s>>>24)>>>24]<<24|i[s>>>16&255]<<16|i[s>>>8&255]<<8|i[255&s],s^=h[o/n|0]<<24),a[o]=a[o-n]^s}for(var u=this._invKeySchedule=[],l=0;l<r;l++)o=r-l,s=l%4?a[o]:a[o-4],u[l]=l<4||o<=4?s:c[i[s>>>24]]^d[i[s>>>16&255]]^f[i[s>>>8&255]]^p[i[255&s]]}},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._keySchedule,o,s,u,l,i)},decryptBlock:function(e,t){var n=e[t+1];e[t+1]=e[t+3],e[t+3]=n,this._doCryptBlock(e,t,this._invKeySchedule,c,d,f,p,a),n=e[t+1],e[t+1]=e[t+3],e[t+3]=n},_doCryptBlock:function(e,t,n,r,i,a,o,s){for(var u=this._nRounds,l=e[t]^n[0],c=e[t+1]^n[1],d=e[t+2]^n[2],f=e[t+3]^n[3],p=4,h=1;h<u;h++){var m=r[l>>>24]^i[c>>>16&255]^a[d>>>8&255]^o[255&f]^n[p++],y=r[c>>>24]^i[d>>>16&255]^a[f>>>8&255]^o[255&l]^n[p++],g=r[d>>>24]^i[f>>>16&255]^a[l>>>8&255]^o[255&c]^n[p++],b=r[f>>>24]^i[l>>>16&255]^a[c>>>8&255]^o[255&d]^n[p++];l=m,c=y,d=g,f=b}m=(s[l>>>24]<<24|s[c>>>16&255]<<16|s[d>>>8&255]<<8|s[255&f])^n[p++],y=(s[c>>>24]<<24|s[d>>>16&255]<<16|s[f>>>8&255]<<8|s[255&l])^n[p++],g=(s[d>>>24]<<24|s[f>>>16&255]<<16|s[l>>>8&255]<<8|s[255&c])^n[p++],b=(s[f>>>24]<<24|s[l>>>16&255]<<16|s[c>>>8&255]<<8|s[255&d])^n[p++],e[t]=m,e[t+1]=y,e[t+2]=g,e[t+3]=b},keySize:8});e.AES=t._createHelper(m)}(),n.AES)}($C)),KC||(KC=1,function(e,t){var n;e.exports=(n=kx(),qx(),$x(),yC(),vC(),function(){var e=n,t=e.lib,r=t.WordArray,i=t.BlockCipher,a=e.algo,o=[57,49,41,33,25,17,9,1,58,50,42,34,26,18,10,2,59,51,43,35,27,19,11,3,60,52,44,36,63,55,47,39,31,23,15,7,62,54,46,38,30,22,14,6,61,53,45,37,29,21,13,5,28,20,12,4],s=[14,17,11,24,1,5,3,28,15,6,21,10,23,19,12,4,26,8,16,7,27,20,13,2,41,52,31,37,47,55,30,40,51,45,33,48,44,49,39,56,34,53,46,42,50,36,29,32],u=[1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28],l=[{0:8421888,268435456:32768,536870912:8421378,805306368:2,1073741824:512,1342177280:8421890,1610612736:8389122,1879048192:8388608,2147483648:514,2415919104:8389120,2684354560:33280,2952790016:8421376,3221225472:32770,3489660928:8388610,3758096384:0,4026531840:33282,134217728:0,402653184:8421890,671088640:33282,939524096:32768,1207959552:8421888,1476395008:512,1744830464:8421378,2013265920:2,2281701376:8389120,2550136832:33280,2818572288:8421376,3087007744:8389122,3355443200:8388610,3623878656:32770,3892314112:514,4160749568:8388608,1:32768,268435457:2,536870913:8421888,805306369:8388608,1073741825:8421378,1342177281:33280,1610612737:512,1879048193:8389122,2147483649:8421890,2415919105:8421376,2684354561:8388610,2952790017:33282,3221225473:514,3489660929:8389120,3758096385:32770,4026531841:0,134217729:8421890,402653185:8421376,671088641:8388608,939524097:512,1207959553:32768,1476395009:8388610,1744830465:2,2013265921:33282,2281701377:32770,2550136833:8389122,2818572289:514,3087007745:8421888,3355443201:8389120,3623878657:0,3892314113:33280,4160749569:8421378},{0:1074282512,16777216:16384,33554432:524288,50331648:1074266128,67108864:1073741840,83886080:1074282496,100663296:1073758208,117440512:16,134217728:540672,150994944:1073758224,167772160:1073741824,184549376:540688,201326592:524304,218103808:0,234881024:16400,251658240:1074266112,8388608:1073758208,25165824:540688,41943040:16,58720256:1073758224,75497472:1074282512,92274688:1073741824,109051904:524288,125829120:1074266128,142606336:524304,159383552:0,176160768:16384,192937984:1074266112,209715200:1073741840,226492416:540672,243269632:1074282496,260046848:16400,268435456:0,285212672:1074266128,301989888:1073758224,318767104:1074282496,335544320:1074266112,352321536:16,369098752:540688,385875968:16384,402653184:16400,419430400:524288,436207616:524304,452984832:1073741840,469762048:540672,486539264:1073758208,503316480:1073741824,520093696:1074282512,276824064:540688,293601280:524288,310378496:1074266112,327155712:16384,343932928:1073758208,360710144:1074282512,377487360:16,394264576:1073741824,411041792:1074282496,427819008:1073741840,444596224:1073758224,461373440:524304,478150656:0,494927872:16400,511705088:1074266128,528482304:540672},{0:260,1048576:0,2097152:67109120,3145728:65796,4194304:65540,5242880:67108868,6291456:67174660,7340032:67174400,8388608:67108864,9437184:67174656,10485760:65792,11534336:67174404,12582912:67109124,13631488:65536,14680064:4,15728640:256,524288:67174656,1572864:67174404,2621440:0,3670016:67109120,4718592:67108868,5767168:65536,6815744:65540,7864320:260,8912896:4,9961472:256,11010048:67174400,12058624:65796,13107200:65792,14155776:67109124,15204352:67174660,16252928:67108864,16777216:67174656,17825792:65540,18874368:65536,19922944:67109120,20971520:256,22020096:67174660,23068672:67108868,24117248:0,25165824:67109124,26214400:67108864,27262976:4,28311552:65792,29360128:67174400,30408704:260,31457280:65796,32505856:67174404,17301504:67108864,18350080:260,19398656:67174656,20447232:0,21495808:65540,22544384:67109120,23592960:256,24641536:67174404,25690112:65536,26738688:67174660,27787264:65796,28835840:67108868,29884416:67109124,30932992:67174400,31981568:4,33030144:65792},{0:2151682048,65536:2147487808,131072:4198464,196608:2151677952,262144:0,327680:4198400,393216:2147483712,458752:4194368,524288:2147483648,589824:4194304,655360:64,720896:2147487744,786432:2151678016,851968:4160,917504:4096,983040:2151682112,32768:2147487808,98304:64,163840:2151678016,229376:2147487744,294912:4198400,360448:2151682112,425984:0,491520:2151677952,557056:4096,622592:2151682048,688128:4194304,753664:4160,819200:2147483648,884736:4194368,950272:4198464,1015808:2147483712,1048576:4194368,1114112:4198400,1179648:2147483712,1245184:0,1310720:4160,1376256:2151678016,1441792:2151682048,1507328:2147487808,1572864:2151682112,1638400:2147483648,1703936:2151677952,1769472:4198464,1835008:2147487744,1900544:4194304,1966080:64,2031616:4096,1081344:2151677952,1146880:2151682112,1212416:0,1277952:4198400,1343488:4194368,1409024:2147483648,1474560:2147487808,1540096:64,1605632:2147483712,1671168:4096,1736704:2147487744,1802240:2151678016,1867776:4160,1933312:2151682048,1998848:4194304,2064384:4198464},{0:128,4096:17039360,8192:262144,12288:536870912,16384:537133184,20480:16777344,24576:553648256,28672:262272,32768:16777216,36864:537133056,40960:536871040,45056:553910400,49152:553910272,53248:0,57344:17039488,61440:553648128,2048:17039488,6144:553648256,10240:128,14336:17039360,18432:262144,22528:537133184,26624:553910272,30720:536870912,34816:537133056,38912:0,43008:553910400,47104:16777344,51200:536871040,55296:553648128,59392:16777216,63488:262272,65536:262144,69632:128,73728:536870912,77824:553648256,81920:16777344,86016:553910272,90112:537133184,94208:16777216,98304:553910400,102400:553648128,106496:17039360,110592:537133056,114688:262272,118784:536871040,122880:0,126976:17039488,67584:553648256,71680:16777216,75776:17039360,79872:537133184,83968:536870912,88064:17039488,92160:128,96256:553910272,100352:262272,104448:553910400,108544:0,112640:553648128,116736:16777344,120832:262144,124928:537133056,129024:536871040},{0:268435464,256:8192,512:270532608,768:270540808,1024:268443648,1280:2097152,1536:2097160,1792:268435456,2048:0,2304:268443656,2560:2105344,2816:8,3072:270532616,3328:2105352,3584:8200,3840:270540800,128:270532608,384:270540808,640:8,896:2097152,1152:2105352,1408:268435464,1664:268443648,1920:8200,2176:2097160,2432:8192,2688:268443656,2944:270532616,3200:0,3456:270540800,3712:2105344,3968:268435456,4096:268443648,4352:270532616,4608:270540808,4864:8200,5120:2097152,5376:268435456,5632:268435464,5888:2105344,6144:2105352,6400:0,6656:8,6912:270532608,7168:8192,7424:268443656,7680:270540800,7936:2097160,4224:8,4480:2105344,4736:2097152,4992:268435464,5248:268443648,5504:8200,5760:270540808,6016:270532608,6272:270540800,6528:270532616,6784:8192,7040:2105352,7296:2097160,7552:0,7808:268435456,8064:268443656},{0:1048576,16:33555457,32:1024,48:1049601,64:34604033,80:0,96:1,112:34603009,128:33555456,144:1048577,160:33554433,176:34604032,192:34603008,208:1025,224:1049600,240:33554432,8:34603009,24:0,40:33555457,56:34604032,72:1048576,88:33554433,104:33554432,120:1025,136:1049601,152:33555456,168:34603008,184:1048577,200:1024,216:34604033,232:1,248:1049600,256:33554432,272:1048576,288:33555457,304:34603009,320:1048577,336:33555456,352:34604032,368:1049601,384:1025,400:34604033,416:1049600,432:1,448:0,464:34603008,480:33554433,496:1024,264:1049600,280:33555457,296:34603009,312:1,328:33554432,344:1048576,360:1025,376:34604032,392:33554433,408:34603008,424:0,440:34604033,456:1049601,472:1024,488:33555456,504:1048577},{0:134219808,1:131072,2:134217728,3:32,4:131104,5:134350880,6:134350848,7:2048,8:134348800,9:134219776,10:133120,11:134348832,12:2080,13:0,14:134217760,15:133152,2147483648:2048,2147483649:134350880,2147483650:134219808,2147483651:134217728,2147483652:134348800,2147483653:133120,2147483654:133152,2147483655:32,2147483656:134217760,2147483657:2080,2147483658:131104,2147483659:134350848,2147483660:0,2147483661:134348832,2147483662:134219776,2147483663:131072,16:133152,17:134350848,18:32,19:2048,20:134219776,21:134217760,22:134348832,23:131072,24:0,25:131104,26:134348800,27:134219808,28:134350880,29:133120,30:2080,31:134217728,2147483664:131072,2147483665:2048,2147483666:134348832,2147483667:133152,2147483668:32,2147483669:134348800,2147483670:134217728,2147483671:134219808,2147483672:134350880,2147483673:134217760,2147483674:134219776,2147483675:0,2147483676:133120,2147483677:2080,2147483678:131104,2147483679:134350848}],c=[4160749569,528482304,33030144,2064384,129024,8064,504,2147483679],d=a.DES=i.extend({_doReset:function(){for(var e=this._key.words,t=[],n=0;n<56;n++){var r=o[n]-1;t[n]=e[r>>>5]>>>31-r%32&1}for(var i=this._subKeys=[],a=0;a<16;a++){var l=i[a]=[],c=u[a];for(n=0;n<24;n++)l[n/6|0]|=t[(s[n]-1+c)%28]<<31-n%6,l[4+(n/6|0)]|=t[28+(s[n+24]-1+c)%28]<<31-n%6;for(l[0]=l[0]<<1|l[0]>>>31,n=1;n<7;n++)l[n]=l[n]>>>4*(n-1)+3;l[7]=l[7]<<5|l[7]>>>27}var d=this._invSubKeys=[];for(n=0;n<16;n++)d[n]=i[15-n]},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._subKeys)},decryptBlock:function(e,t){this._doCryptBlock(e,t,this._invSubKeys)},_doCryptBlock:function(e,t,n){this._lBlock=e[t],this._rBlock=e[t+1],f.call(this,4,252645135),f.call(this,16,65535),p.call(this,2,858993459),p.call(this,8,16711935),f.call(this,1,1431655765);for(var r=0;r<16;r++){for(var i=n[r],a=this._lBlock,o=this._rBlock,s=0,u=0;u<8;u++)s|=l[u][((o^i[u])&c[u])>>>0];this._lBlock=o,this._rBlock=a^s}var d=this._lBlock;this._lBlock=this._rBlock,this._rBlock=d,f.call(this,1,1431655765),p.call(this,8,16711935),p.call(this,2,858993459),f.call(this,16,65535),f.call(this,4,252645135),e[t]=this._lBlock,e[t+1]=this._rBlock},keySize:2,ivSize:2,blockSize:2});function f(e,t){var n=(this._lBlock>>>e^this._rBlock)&t;this._rBlock^=n,this._lBlock^=n<<e}function p(e,t){var n=(this._rBlock>>>e^this._lBlock)&t;this._lBlock^=n,this._rBlock^=n<<e}e.DES=i._createHelper(d);var h=a.TripleDES=i.extend({_doReset:function(){var e=this._key.words;this._des1=d.createEncryptor(r.create(e.slice(0,2))),this._des2=d.createEncryptor(r.create(e.slice(2,4))),this._des3=d.createEncryptor(r.create(e.slice(4,6)))},encryptBlock:function(e,t){this._des1.encryptBlock(e,t),this._des2.decryptBlock(e,t),this._des3.encryptBlock(e,t)},decryptBlock:function(e,t){this._des3.decryptBlock(e,t),this._des2.encryptBlock(e,t),this._des1.decryptBlock(e,t)},keySize:6,ivSize:2,blockSize:2});e.TripleDES=i._createHelper(h)}(),n.TripleDES)}(XC)),ZC||(ZC=1,function(e,t){var n;e.exports=(n=kx(),qx(),$x(),yC(),vC(),function(){var e=n,t=e.lib.StreamCipher,r=e.algo,i=r.RC4=t.extend({_doReset:function(){for(var e=this._key,t=e.words,n=e.sigBytes,r=this._S=[],i=0;i<256;i++)r[i]=i;i=0;for(var a=0;i<256;i++){var o=i%n,s=t[o>>>2]>>>24-o%4*8&255;a=(a+r[i]+s)%256;var u=r[i];r[i]=r[a],r[a]=u}this._i=this._j=0},_doProcessBlock:function(e,t){e[t]^=a.call(this)},keySize:8,ivSize:0});function a(){for(var e=this._S,t=this._i,n=this._j,r=0,i=0;i<4;i++){n=(n+e[t=(t+1)%256])%256;var a=e[t];e[t]=e[n],e[n]=a,r|=e[(e[t]+e[n])%256]<<24-8*i}return this._i=t,this._j=n,r}e.RC4=t._createHelper(i);var o=r.RC4Drop=i.extend({cfg:i.cfg.extend({drop:192}),_doReset:function(){i._doReset.call(this);for(var e=this.cfg.drop;e>0;e--)a.call(this)}});e.RC4Drop=t._createHelper(o)}(),n.RC4)}(YC)),JC||(JC=1,function(e,t){var n;e.exports=(n=kx(),qx(),$x(),yC(),vC(),function(){var e=n,t=e.lib.StreamCipher,r=e.algo,i=[],a=[],o=[],s=r.Rabbit=t.extend({_doReset:function(){for(var e=this._key.words,t=this.cfg.iv,n=0;n<4;n++)e[n]=16711935&(e[n]<<8|e[n]>>>24)|4278255360&(e[n]<<24|e[n]>>>8);var r=this._X=[e[0],e[3]<<16|e[2]>>>16,e[1],e[0]<<16|e[3]>>>16,e[2],e[1]<<16|e[0]>>>16,e[3],e[2]<<16|e[1]>>>16],i=this._C=[e[2]<<16|e[2]>>>16,4294901760&e[0]|65535&e[1],e[3]<<16|e[3]>>>16,4294901760&e[1]|65535&e[2],e[0]<<16|e[0]>>>16,4294901760&e[2]|65535&e[3],e[1]<<16|e[1]>>>16,4294901760&e[3]|65535&e[0]];for(this._b=0,n=0;n<4;n++)u.call(this);for(n=0;n<8;n++)i[n]^=r[n+4&7];if(t){var a=t.words,o=a[0],s=a[1],l=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),c=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),d=l>>>16|4294901760&c,f=c<<16|65535&l;for(i[0]^=l,i[1]^=d,i[2]^=c,i[3]^=f,i[4]^=l,i[5]^=d,i[6]^=c,i[7]^=f,n=0;n<4;n++)u.call(this)}},_doProcessBlock:function(e,t){var n=this._X;u.call(this),i[0]=n[0]^n[5]>>>16^n[3]<<16,i[1]=n[2]^n[7]>>>16^n[5]<<16,i[2]=n[4]^n[1]>>>16^n[7]<<16,i[3]=n[6]^n[3]>>>16^n[1]<<16;for(var r=0;r<4;r++)i[r]=16711935&(i[r]<<8|i[r]>>>24)|4278255360&(i[r]<<24|i[r]>>>8),e[t+r]^=i[r]},blockSize:4,ivSize:2});function u(){for(var e=this._X,t=this._C,n=0;n<8;n++)a[n]=t[n];for(t[0]=t[0]+1295307597+this._b|0,t[1]=t[1]+3545052371+(t[0]>>>0<a[0]>>>0?1:0)|0,t[2]=t[2]+886263092+(t[1]>>>0<a[1]>>>0?1:0)|0,t[3]=t[3]+1295307597+(t[2]>>>0<a[2]>>>0?1:0)|0,t[4]=t[4]+3545052371+(t[3]>>>0<a[3]>>>0?1:0)|0,t[5]=t[5]+886263092+(t[4]>>>0<a[4]>>>0?1:0)|0,t[6]=t[6]+1295307597+(t[5]>>>0<a[5]>>>0?1:0)|0,t[7]=t[7]+3545052371+(t[6]>>>0<a[6]>>>0?1:0)|0,this._b=t[7]>>>0<a[7]>>>0?1:0,n=0;n<8;n++){var r=e[n]+t[n],i=65535&r,s=r>>>16,u=((i*i>>>17)+i*s>>>15)+s*s,l=((4294901760&r)*r|0)+((65535&r)*r|0);o[n]=u^l}e[0]=o[0]+(o[7]<<16|o[7]>>>16)+(o[6]<<16|o[6]>>>16)|0,e[1]=o[1]+(o[0]<<8|o[0]>>>24)+o[7]|0,e[2]=o[2]+(o[1]<<16|o[1]>>>16)+(o[0]<<16|o[0]>>>16)|0,e[3]=o[3]+(o[2]<<8|o[2]>>>24)+o[1]|0,e[4]=o[4]+(o[3]<<16|o[3]>>>16)+(o[2]<<16|o[2]>>>16)|0,e[5]=o[5]+(o[4]<<8|o[4]>>>24)+o[3]|0,e[6]=o[6]+(o[5]<<16|o[5]>>>16)+(o[4]<<16|o[4]>>>16)|0,e[7]=o[7]+(o[6]<<8|o[6]>>>24)+o[5]|0}e.Rabbit=t._createHelper(s)}(),n.Rabbit)}(QC)),ek||(ek=1,function(e,t){var n;e.exports=(n=kx(),qx(),$x(),yC(),vC(),function(){var e=n,t=e.lib.StreamCipher,r=e.algo,i=[],a=[],o=[],s=r.RabbitLegacy=t.extend({_doReset:function(){var e=this._key.words,t=this.cfg.iv,n=this._X=[e[0],e[3]<<16|e[2]>>>16,e[1],e[0]<<16|e[3]>>>16,e[2],e[1]<<16|e[0]>>>16,e[3],e[2]<<16|e[1]>>>16],r=this._C=[e[2]<<16|e[2]>>>16,4294901760&e[0]|65535&e[1],e[3]<<16|e[3]>>>16,4294901760&e[1]|65535&e[2],e[0]<<16|e[0]>>>16,4294901760&e[2]|65535&e[3],e[1]<<16|e[1]>>>16,4294901760&e[3]|65535&e[0]];this._b=0;for(var i=0;i<4;i++)u.call(this);for(i=0;i<8;i++)r[i]^=n[i+4&7];if(t){var a=t.words,o=a[0],s=a[1],l=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),c=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),d=l>>>16|4294901760&c,f=c<<16|65535&l;for(r[0]^=l,r[1]^=d,r[2]^=c,r[3]^=f,r[4]^=l,r[5]^=d,r[6]^=c,r[7]^=f,i=0;i<4;i++)u.call(this)}},_doProcessBlock:function(e,t){var n=this._X;u.call(this),i[0]=n[0]^n[5]>>>16^n[3]<<16,i[1]=n[2]^n[7]>>>16^n[5]<<16,i[2]=n[4]^n[1]>>>16^n[7]<<16,i[3]=n[6]^n[3]>>>16^n[1]<<16;for(var r=0;r<4;r++)i[r]=16711935&(i[r]<<8|i[r]>>>24)|4278255360&(i[r]<<24|i[r]>>>8),e[t+r]^=i[r]},blockSize:4,ivSize:2});function u(){for(var e=this._X,t=this._C,n=0;n<8;n++)a[n]=t[n];for(t[0]=t[0]+1295307597+this._b|0,t[1]=t[1]+3545052371+(t[0]>>>0<a[0]>>>0?1:0)|0,t[2]=t[2]+886263092+(t[1]>>>0<a[1]>>>0?1:0)|0,t[3]=t[3]+1295307597+(t[2]>>>0<a[2]>>>0?1:0)|0,t[4]=t[4]+3545052371+(t[3]>>>0<a[3]>>>0?1:0)|0,t[5]=t[5]+886263092+(t[4]>>>0<a[4]>>>0?1:0)|0,t[6]=t[6]+1295307597+(t[5]>>>0<a[5]>>>0?1:0)|0,t[7]=t[7]+3545052371+(t[6]>>>0<a[6]>>>0?1:0)|0,this._b=t[7]>>>0<a[7]>>>0?1:0,n=0;n<8;n++){var r=e[n]+t[n],i=65535&r,s=r>>>16,u=((i*i>>>17)+i*s>>>15)+s*s,l=((4294901760&r)*r|0)+((65535&r)*r|0);o[n]=u^l}e[0]=o[0]+(o[7]<<16|o[7]>>>16)+(o[6]<<16|o[6]>>>16)|0,e[1]=o[1]+(o[0]<<8|o[0]>>>24)+o[7]|0,e[2]=o[2]+(o[1]<<16|o[1]>>>16)+(o[0]<<16|o[0]>>>16)|0,e[3]=o[3]+(o[2]<<8|o[2]>>>24)+o[1]|0,e[4]=o[4]+(o[3]<<16|o[3]>>>16)+(o[2]<<16|o[2]>>>16)|0,e[5]=o[5]+(o[4]<<8|o[4]>>>24)+o[3]|0,e[6]=o[6]+(o[5]<<16|o[5]>>>16)+(o[4]<<16|o[4]>>>16)|0,e[7]=o[7]+(o[6]<<8|o[6]>>>24)+o[5]|0}e.RabbitLegacy=t._createHelper(s)}(),n.RabbitLegacy)}(tk)),n)}(Nx);var nk=Nx.exports,rk=o&&o.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Px,"__esModule",{value:!0}),Px.Base=void 0;const ik=n,ak=rk(nk);let ok=class e{print(){e.print(this)}bufferIndexOf(e,t,n=!1){if(n)return this.binarySearch(e,t,ik.Buffer.compare);return this.linearSearch(e,t,((e,t)=>e.equals(t)))}static binarySearch(e,t,n){let r=0,i=e.length-1;for(;r<=i;){const a=Math.floor((r+i)/2),o=n(e[a],t);if(0===o){for(let r=a-1;r>=0;r--)if(0!==n(e[r],t))return r+1;return 0}o<0?r=a+1:i=a-1}return-1}binarySearch(t,n,r){return e.binarySearch(t,n,r)}static linearSearch(e,t,n){for(let r=0;r<e.length;r++)if(n(e[r],t))return r;return-1}linearSearch(t,n,r){return e.linearSearch(t,n,r)}static bufferify(t){if(!ik.Buffer.isBuffer(t)){if("object"==typeof t&&t.words)return ik.Buffer.from(t.toString(ak.default.enc.Hex),"hex");if(e.isHexString(t))return ik.Buffer.from(t.replace(/^0x/,""),"hex");if("string"==typeof t)return ik.Buffer.from(t);if("bigint"==typeof t)return ik.Buffer.from(t.toString(16),"hex");if(t instanceof Uint8Array)return ik.Buffer.from(t.buffer);if("number"==typeof t){let e=t.toString();return e.length%2&&(e=`0${e}`),ik.Buffer.from(e,"hex")}if(ArrayBuffer.isView(t))return ik.Buffer.from(t.buffer,t.byteOffset,t.byteLength)}return t}bigNumberify(t){return e.bigNumberify(t)}static bigNumberify(t){if("bigint"==typeof t)return t;if("string"==typeof t)return t.startsWith("0x")&&e.isHexString(t)?BigInt("0x"+t.replace("0x","").toString()):BigInt(t);if(ik.Buffer.isBuffer(t))return BigInt("0x"+t.toString("hex"));if(t instanceof Uint8Array)return BigInt(t);if("number"==typeof t)return BigInt(t);throw new Error("cannot bigNumberify")}static isHexString(e){return"string"==typeof e&&/^(0x)?[0-9A-Fa-f]*$/.test(e)}static print(e){console.log(e.toString())}bufferToHex(t,n=!0){return e.bufferToHex(t,n)}static bufferToHex(e,t=!0){return`${t?"0x":""}${(e||ik.Buffer.alloc(0)).toString("hex")}`}bufferify(t){return e.bufferify(t)}bufferifyFn(e){return t=>{const n=e(t);return ik.Buffer.isBuffer(n)?n:this.isHexString(n)?ik.Buffer.from(n.replace("0x",""),"hex"):"string"==typeof n?ik.Buffer.from(n):"bigint"==typeof n?ik.Buffer.from(t.toString(16),"hex"):ArrayBuffer.isView(n)?ik.Buffer.from(n.buffer,n.byteOffset,n.byteLength):ik.Buffer.from(e(ak.default.enc.Hex.parse(t.toString("hex"))).toString(ak.default.enc.Hex),"hex")}}isHexString(t){return e.isHexString(t)}log2(e){return 1===e?0:1+this.log2(e/2|0)}zip(e,t){return e.map(((e,n)=>[e,t[n]]))}static hexZeroPad(e,t){return"0x"+e.replace("0x","").padStart(t,"0")}};Px.Base=ok,Px.default=ok;var sk=o&&o.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(_x,"__esModule",{value:!0}),_x.MerkleTree=void 0;const uk=n,lk=sk((function(e){for(var t=new Buffer(e.length),n=0,r=e.length-1;n<=r;++n,--r)t[n]=e[r],t[r]=e[n];return t})),ck=sk(Sx),dk=sk(Ox),fk=sk(Px);let pk=class e extends fk.default{constructor(e,t=ck.default,n={}){if(super(),this.duplicateOdd=!1,this.concatenator=uk.Buffer.concat,this.hashLeaves=!1,this.isBitcoinTree=!1,this.leaves=[],this.layers=[],this.sortLeaves=!1,this.sortPairs=!1,this.sort=!1,this.fillDefaultHash=null,this.complete=!1,n.complete){if(n.isBitcoinTree)throw new Error('option "complete" is incompatible with "isBitcoinTree"');if(n.duplicateOdd)throw new Error('option "complete" is incompatible with "duplicateOdd"')}if(this.isBitcoinTree=!!n.isBitcoinTree,this.hashLeaves=!!n.hashLeaves,this.sortLeaves=!!n.sortLeaves,this.sortPairs=!!n.sortPairs,this.complete=!!n.complete,n.fillDefaultHash)if("function"==typeof n.fillDefaultHash)this.fillDefaultHash=n.fillDefaultHash;else{if(!uk.Buffer.isBuffer(n.fillDefaultHash)&&"string"!=typeof n.fillDefaultHash)throw new Error('method "fillDefaultHash" must be a function, Buffer, or string');this.fillDefaultHash=(e,t)=>n.fillDefaultHash}this.sort=!!n.sort,this.sort&&(this.sortLeaves=!0,this.sortPairs=!0),this.duplicateOdd=!!n.duplicateOdd,n.concatenator&&(this.concatenator=n.concatenator),this.hashFn=this.bufferifyFn(t),this.processLeaves(e)}getOptions(){var e,t;return{complete:this.complete,isBitcoinTree:this.isBitcoinTree,hashLeaves:this.hashLeaves,sortLeaves:this.sortLeaves,sortPairs:this.sortPairs,sort:this.sort,fillDefaultHash:null!==(t=null===(e=this.fillDefaultHash)||void 0===e?void 0:e.toString())&&void 0!==t?t:null,duplicateOdd:this.duplicateOdd}}processLeaves(e){if(this.hashLeaves&&(e=e.map(this.hashFn)),this.leaves=e.map(this.bufferify),this.sortLeaves&&(this.leaves=this.leaves.sort(uk.Buffer.compare)),this.fillDefaultHash)for(let e=this.leaves.length;e<Math.pow(2,Math.ceil(Math.log2(this.leaves.length)));e++)this.leaves.push(this.bufferify(this.fillDefaultHash(e,this.hashFn)));this.createHashes(this.leaves)}createHashes(e){for(this.layers=[e];e.length>1;){const t=this.layers.length;this.layers.push([]);const n=this.complete&&1===t&&!Number.isInteger(Math.log2(e.length))?2*e.length-Math.pow(2,Math.ceil(Math.log2(e.length))):e.length;for(let r=0;r<e.length;r+=2){if(r>=n){this.layers[t].push(...e.slice(n));break}if(r+1===e.length&&e.length%2==1){const n=e[e.length-1];let i=n;if(this.isBitcoinTree){i=this.hashFn(this.concatenator([lk.default(n),lk.default(n)])),i=lk.default(this.hashFn(i)),this.layers[t].push(i);continue}if(!this.duplicateOdd){this.layers[t].push(e[r]);continue}}const i=e[r],a=r+1===e.length?i:e[r+1];let o=null;o=this.isBitcoinTree?[lk.default(i),lk.default(a)]:[i,a],this.sortPairs&&o.sort(uk.Buffer.compare);let s=this.hashFn(this.concatenator(o));this.isBitcoinTree&&(s=lk.default(this.hashFn(s))),this.layers[t].push(s)}e=this.layers[t]}}addLeaf(e,t=!1){t&&(e=this.hashFn(e)),this.processLeaves(this.leaves.concat(e))}addLeaves(e,t=!1){t&&(e=e.map(this.hashFn)),this.processLeaves(this.leaves.concat(e))}getLeaves(e){return Array.isArray(e)?(this.hashLeaves&&(e=e.map(this.hashFn),this.sortLeaves&&(e=e.sort(uk.Buffer.compare))),this.leaves.filter((t=>-1!==this.bufferIndexOf(e,t,this.sortLeaves)))):this.leaves}getLeaf(e){return e<0||e>this.leaves.length-1?uk.Buffer.from([]):this.leaves[e]}getLeafIndex(e){e=this.bufferify(e);const t=this.getLeaves();for(let n=0;n<t.length;n++){if(t[n].equals(e))return n}return-1}getLeafCount(){return this.leaves.length}getHexLeaves(){return this.leaves.map((e=>this.bufferToHex(e)))}static marshalLeaves(t){return JSON.stringify(t.map((t=>e.bufferToHex(t))),null,2)}static unmarshalLeaves(t){let n=null;if("string"==typeof t)n=JSON.parse(t);else{if(!(t instanceof Object))throw new Error("Expected type of string or object");n=t}if(!n)return[];if(!Array.isArray(n))throw new Error("Expected JSON string to be array");return n.map(e.bufferify)}getLayers(){return this.layers}getHexLayers(){return this.layers.reduce(((e,t)=>(Array.isArray(t)?e.push(t.map((e=>this.bufferToHex(e)))):e.push(t),e)),[])}getLayersFlat(){const e=this.layers.reduce(((e,t)=>(Array.isArray(t)?e.unshift(...t):e.unshift(t),e)),[]);return e.unshift(uk.Buffer.from([0])),e}getHexLayersFlat(){return this.getLayersFlat().map((e=>this.bufferToHex(e)))}getLayerCount(){return this.getLayers().length}getRoot(){return 0===this.layers.length?uk.Buffer.from([]):this.layers[this.layers.length-1][0]||uk.Buffer.from([])}getHexRoot(){return this.bufferToHex(this.getRoot())}getProof(e,t){if(void 0===e)throw new Error("leaf is required");e=this.bufferify(e);const n=[];if(!Number.isInteger(t)){t=-1;for(let n=0;n<this.leaves.length;n++)0===uk.Buffer.compare(e,this.leaves[n])&&(t=n)}if(t<=-1)return[];for(let e=0;e<this.layers.length;e++){const r=this.layers[e],i=t%2,a=i?t-1:this.isBitcoinTree&&t===r.length-1&&e<this.layers.length-1?t:t+1;a<r.length&&n.push({position:i?"left":"right",data:r[a]}),t=t/2|0}return n}getHexProof(e,t){return this.getProof(e,t).map((e=>this.bufferToHex(e.data)))}getProofs(){const e=[];return this.getProofsDFS(this.layers.length-1,0,[],e),e}getProofsDFS(e,t,n,r){const i=t%2;if(-1===e)return void(i||r.push([...n].reverse()));if(t>=this.layers[e].length)return;const a=this.layers[e],o=i?t-1:t+1;let s=!1;o<a.length&&(s=!0,n.push({position:i?"left":"right",data:a[o]}));const u=2*t,l=2*t+1;this.getProofsDFS(e-1,u,n,r),this.getProofsDFS(e-1,l,n,r),s&&n.splice(n.length-1,1)}getHexProofs(){return this.getProofs().map((e=>this.bufferToHex(e.data)))}getPositionalHexProof(e,t){return this.getProof(e,t).map((e=>["left"===e.position?0:1,this.bufferToHex(e.data)]))}static marshalProof(t){const n=t.map((t=>"string"==typeof t?t:uk.Buffer.isBuffer(t)?e.bufferToHex(t):{position:t.position,data:e.bufferToHex(t.data)}));return JSON.stringify(n,null,2)}static unmarshalProof(t){let n=null;if("string"==typeof t)n=JSON.parse(t);else{if(!(t instanceof Object))throw new Error("Expected type of string or object");n=t}if(!n)return[];if(!Array.isArray(n))throw new Error("Expected JSON string to be array");return n.map((t=>{if("string"==typeof t)return e.bufferify(t);if(t instanceof Object)return{position:t.position,data:e.bufferify(t.data)};throw new Error("Expected item to be of type string or object")}))}static marshalTree(t){const n=t.getHexRoot(),r=t.leaves.map((t=>e.bufferToHex(t))),i=t.getHexLayers(),a=t.getOptions();return JSON.stringify({options:a,root:n,layers:i,leaves:r},null,2)}static unmarshalTree(t,n=ck.default,r={}){let i=null;if("string"==typeof t)i=JSON.parse(t);else{if(!(t instanceof Object))throw new Error("Expected type of string or object");i=t}if(!i)throw new Error("could not parse json");return r=Object.assign({},i.options||{},r),new e(i.leaves,n,r)}getProofIndices(e,t){const n=Math.pow(2,t);let r=new Set;for(const t of e){let e=n+t;for(;e>1;)r.add(1^e),e=e/2|0}const i=e.map((e=>n+e)),a=Array.from(r).sort(((e,t)=>e-t)).reverse();r=i.concat(a);const o=new Set,s=[];for(let e of r)if(!o.has(e))for(s.push(e);e>1&&(o.add(e),o.has(1^e));)e=e/2|0;return s.filter((t=>!e.includes(t-n)))}getProofIndicesForUnevenTree(e,t){const n=Math.ceil(Math.log2(t)),r=[];for(let e=0;e<n;e++){t%2!=0&&r.push({index:e,leavesCount:t}),t=Math.ceil(t/2)}const i=[];let a=e;for(let e=0;e<n;e++){const t=a.map((e=>e%2==0?e+1:e-1));let n=t.filter((e=>!a.includes(e)));const o=r.find((({index:t})=>t===e));o&&a.includes(o.leavesCount-1)&&(n=n.slice(0,-1)),i.push(n),a=[...new Set(a.map((e=>e%2==0?e/2:e%2==0?(e+1)/2:(e-1)/2)))]}return i}getMultiProof(e,t){this.complete||console.warn("Warning: For correct multiProofs it's strongly recommended to set complete: true"),t||(t=e,e=this.getLayersFlat());if(this.isUnevenTree()&&t.every(Number.isInteger))return this.getMultiProofForUnevenTree(t);if(!t.every(Number.isInteger)){let e=t;this.sortPairs&&(e=e.sort(uk.Buffer.compare));let n=e.map((e=>this.bufferIndexOf(this.leaves,e,this.sortLeaves))).sort(((e,t)=>e===t?0:e>t?1:-1));if(!n.every((e=>-1!==e)))throw new Error("Element does not exist in Merkle tree");const r=[],i=[];let a=[];for(let e=0;e<this.layers.length;e++){const t=this.layers[e];for(let e=0;e<n.length;e++){const o=n[e],s=this.getPairNode(t,o);r.push(t[o]),s&&i.push(s),a.push(o/2|0)}n=a.filter(((e,t,n)=>n.indexOf(e)===t)),a=[]}return i.filter((e=>!r.includes(e)))}return this.getProofIndices(t,Math.log2(e.length/2|0)).map((t=>e[t]))}getMultiProofForUnevenTree(e,t){t||(t=e,e=this.getLayers());let n=[],r=t;for(const t of e){const e=[];for(const n of r){if(n%2==0){const i=n+1;if(!r.includes(i)&&t[i]){e.push(t[i]);continue}}const i=n-1;r.includes(i)||!t[i]||e.push(t[i])}n=n.concat(e);const i=new Set;for(const e of r)e%2!=0?e%2!=0?i.add((e-1)/2):i.add((e+1)/2):i.add(e/2);r=Array.from(i)}return n}getHexMultiProof(e,t){return this.getMultiProof(e,t).map((e=>this.bufferToHex(e)))}getProofFlags(e,t){if(!Array.isArray(e)||e.length<=0)throw new Error("Invalid Inputs!");let n;if(n=e.every(Number.isInteger)?[...e].sort(((e,t)=>e===t?0:e>t?1:-1)):e.map((e=>this.bufferIndexOf(this.leaves,e,this.sortLeaves))).sort(((e,t)=>e===t?0:e>t?1:-1)),!n.every((e=>-1!==e)))throw new Error("Element does not exist in Merkle tree");const r=t.map((e=>this.bufferify(e))),i=[],a=[];for(let e=0;e<this.layers.length;e++){const t=this.layers[e];n=n.reduce(((e,n)=>{if(!i.includes(t[n])){const e=this.getPairNode(t,n),o=r.includes(t[n])||r.includes(e);e&&a.push(!o),i.push(t[n]),i.push(e)}return e.push(n/2|0),e}),[])}return a}verify(e,t,n){let r=this.bufferify(t);if(n=this.bufferify(n),!Array.isArray(e)||!t||!n)return!1;for(let t=0;t<e.length;t++){const n=e[t];let i=null,a=null;if("string"==typeof n)i=this.bufferify(n),a=!0;else if(Array.isArray(n))a=0===n[0],i=this.bufferify(n[1]);else if(uk.Buffer.isBuffer(n))i=n,a=!0;else{if(!(n instanceof Object))throw new Error("Expected node to be of type string or object");i=this.bufferify(n.data),a="left"===n.position}const o=[];this.isBitcoinTree?(o.push(lk.default(r)),o[a?"unshift":"push"](lk.default(i)),r=this.hashFn(this.concatenator(o)),r=lk.default(this.hashFn(r))):this.sortPairs?-1===uk.Buffer.compare(r,i)?(o.push(r,i),r=this.hashFn(this.concatenator(o))):(o.push(i,r),r=this.hashFn(this.concatenator(o))):(o.push(r),o[a?"unshift":"push"](i),r=this.hashFn(this.concatenator(o)))}return 0===uk.Buffer.compare(r,n)}verifyMultiProof(e,t,n,r,i){if(this.isUnevenTree())return this.verifyMultiProofForUnevenTree(e,t,n,r,i);const a=Math.ceil(Math.log2(r));e=this.bufferify(e),n=n.map((e=>this.bufferify(e))),i=i.map((e=>this.bufferify(e)));const o={};for(const[e,r]of this.zip(t,n))o[Math.pow(2,a)+e]=r;for(const[e,n]of this.zip(this.getProofIndices(t,a),i))o[e]=n;let s=Object.keys(o).map((e=>+e)).sort(((e,t)=>e-t));s=s.slice(0,s.length-1);let u=0;for(;u<s.length;){const e=s[u];if(e>=2&&{}.hasOwnProperty.call(o,1^e)){let t=[o[e-e%2],o[e-e%2+1]];this.sortPairs&&(t=t.sort(uk.Buffer.compare));const n=t[1]?this.hashFn(this.concatenator(t)):t[0];o[e/2|0]=n,s.push(e/2|0)}u+=1}return!t.length||{}.hasOwnProperty.call(o,1)&&o[1].equals(e)}verifyMultiProofWithFlags(e,t,n,r){e=this.bufferify(e),t=t.map(this.bufferify),n=n.map(this.bufferify);const i=t.length,a=r.length,o=[];let s=0,u=0,l=0;for(let e=0;e<a;e++){const a=[r[e]?s<i?t[s++]:o[u++]:n[l++],s<i?t[s++]:o[u++]].sort(uk.Buffer.compare);o[e]=this.hashFn(this.concatenator(a))}return 0===uk.Buffer.compare(o[a-1],e)}verifyMultiProofForUnevenTree(e,t,n,r,i){e=this.bufferify(e),n=n.map((e=>this.bufferify(e))),i=i.map((e=>this.bufferify(e)));const a=this.calculateRootForUnevenTree(t,n,r,i);return e.equals(a)}getDepth(){return this.getLayers().length-1}getLayersAsObject(){const e=this.getLayers().map((e=>e.map((e=>this.bufferToHex(e,!1))))),t=[];for(let n=0;n<e.length;n++){const r=[];for(let i=0;i<e[n].length;i++){const a={[e[n][i]]:null};if(t.length){a[e[n][i]]={};const r=t.shift(),o=Object.keys(r)[0];if(a[e[n][i]][o]=r[o],t.length){const r=t.shift(),o=Object.keys(r)[0];a[e[n][i]][o]=r[o]}}r.push(a)}t.push(...r)}return t[0]}static verify(t,n,r,i=ck.default,a={}){return new e([],i,a).verify(t,n,r)}static getMultiProof(t,n){return new e([]).getMultiProof(t,n)}resetTree(){this.leaves=[],this.layers=[]}getPairNode(e,t){const n=t%2==0?t+1:t-1;return n<e.length?e[n]:null}toTreeString(){const e=this.getLayersAsObject();return dk.default.asTree(e,!0)}toString(){return this.toTreeString()}isUnevenTree(e){const t=(null==e?void 0:e.length)||this.getDepth();return!this.isPowOf2(t)}isPowOf2(e){return e&&!(e&e-1)}calculateRootForUnevenTree(e,t,n,r){const i=this.zip(e,t).sort((([e],[t])=>e-t)),a=i.map((([e])=>e)),o=this.getProofIndicesForUnevenTree(a,n);let s=0;const u=[];for(let e=0;e<o.length;e++){const t=o[e],n=s;s+=t.length,u[e]=this.zip(t,r.slice(n,s))}const l=[i];for(let e=0;e<u.length;e++){const t=u[e].concat(l[e]).sort((([e],[t])=>e-t)).map((([,e])=>e)),n=l[e].map((([e])=>e)),r=[...new Set(n.map((e=>e%2==0?e/2:e%2==0?(e+1)/2:(e-1)/2)))],i=[];for(let e=0;e<r.length;e++){const n=r[e],a=t[2*e],o=t[2*e+1],s=o?this.hashFn(this.concatenator([a,o])):a;i.push([n,s])}l.push(i)}return l[l.length-1][0][1]}};_x.MerkleTree=pk,"undefined"!=typeof window&&(window.MerkleTree=pk),_x.default=pk;var hk={},mk=o&&o.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(hk,"__esModule",{value:!0}),hk.MerkleMountainRange=void 0;const yk=n,gk=mk(Sx),bk=mk(Px);class vk extends bk.default{constructor(e=gk.default,t=[],n,r,i){super(),this.root=yk.Buffer.alloc(0),this.size=0,this.width=0,this.hashes={},this.data={},t=t.map(this.bufferify),this.hashFn=this.bufferifyFn(e),this.hashLeafFn=n,this.peakBaggingFn=r,this.hashBranchFn=i;for(const e of t)this.append(e)}append(e){e=this.bufferify(e);const t=this.hashFn(e),n=this.bufferToHex(t);this.data[n]&&this.bufferToHex(this.hashFn(this.data[n]))===n||(this.data[n]=e);const r=this.hashLeaf(this.size+1,t);this.hashes[this.size+1]=r,this.width+=1;const i=this.getPeakIndexes(this.width);this.size=this.getSize(this.width);const a=[];for(let e=0;e<i.length;e++)a[e]=this._getOrCreateNode(i[e]);this.root=this.peakBagging(this.width,a)}hashLeaf(e,t){return t=this.bufferify(t),this.hashLeafFn?this.bufferify(this.hashLeafFn(e,t)):this.hashFn(yk.Buffer.concat([this.bufferify(e),t]))}hashBranch(e,t,n){return this.hashBranchFn?this.bufferify(this.hashBranchFn(e,t,n)):this.hashFn(yk.Buffer.concat([this.bufferify(e),this.bufferify(t),this.bufferify(n)]))}getPeaks(){const e=this.getPeakIndexes(this.width),t=[];for(let n=0;n<e.length;n++)t[n]=this.hashes[e[n]];return t}getLeafIndex(e){return e%2==1?this.getSize(e):this.getSize(e-1)+1}getPeakIndexes(e){const t=this.numOfPeaks(e),n=[];let r=0,i=0;for(let a=255;a>0&&!(0!=(e&1<<a-1)&&(i=i+(1<<a)-1,n[r++]=i,n.length>=t));a--);if(r!==n.length)throw new Error("invalid bit calculation");return n}numOfPeaks(e){let t=e,n=0;for(;t>0;)t%2==1&&n++,t>>=1;return n}peakBagging(e,t){const n=this.getSize(e);if(this.numOfPeaks(e)!==t.length)throw new Error("received invalid number of peaks");return 0!==e||t.length?this.peakBaggingFn?this.bufferify(this.peakBaggingFn(n,t)):this.hashFn(yk.Buffer.concat([this.bufferify(n),...t.map(this.bufferify)])):yk.Buffer.alloc(0)}getSize(e){return(e<<1)-this.numOfPeaks(e)}getRoot(){return this.root}getHexRoot(){return this.bufferToHex(this.getRoot())}getNode(e){return this.hashes[e]}mountainHeight(e){let t=1;for(;1<<t<=e+t;)t++;return t-1}heightAt(e){let t=e,n=0,r=0;for(;t>n;)t-=(1<<r)-1,r=this.mountainHeight(t),n=(1<<r)-1;return r-(n-t)}isLeaf(e){return 1===this.heightAt(e)}getChildren(e){const t=e-(1<<this.heightAt(e)-1),n=e-1;if(t===n)throw new Error("not a parent");return[t,n]}getMerkleProof(e){if(e>this.size)throw new Error("out of range");if(!this.isLeaf(e))throw new Error("not a leaf");const t=this.root,n=this.width,r=this.getPeakIndexes(this.width),i=[];let a=0;for(let t=0;t<r.length;t++)i[t]=this.hashes[r[t]],r[t]>=e&&0===a&&(a=r[t]);let o=0,s=0,u=this.heightAt(a);const l=[];for(;a!==e;)u--,[o,s]=this.getChildren(a),a=e<=o?o:s,l[u-1]=this.hashes[e<=o?s:o];return{root:t,width:n,peakBagging:i,siblings:l}}verify(e,t,n,r,i,a){r=this.bufferify(r);if(this.getSize(t)<n)throw new Error("index is out of range");if(!e.equals(this.peakBagging(t,i)))throw new Error("invalid root hash from the peaks");let o,s=0;const u=this.getPeakIndexes(t);for(let e=0;e<u.length;e++)if(u[e]>=n){o=i[e],s=u[e];break}if(!o)throw new Error("target not found");let l=a.length+1;const c=new Array(l);let d,f=0,p=0;for(;l>0&&(c[--l]=s,s!==n);)[f,p]=this.getChildren(s),s=n>f?p:f;for(;l<c.length;)s=c[l],d=0===l?this.hashLeaf(s,this.hashFn(r)):s-1===c[l-1]?this.hashBranch(s,a[l-1],d):this.hashBranch(s,d,a[l-1]),l++;if(!d.equals(o))throw new Error("hashed peak is invalid");return!0}peaksToPeakMap(e,t){const n={};let r=0,i=0,a=t.length;for(let o=1;o<=32;o++)r=32-o,i=1<<o-1,n[r]=0!=(e&i)?t[--a]:0;if(0!==a)throw new Error("invalid number of peaks");return n}peakMapToPeaks(e,t){const n=this.numOfPeaks(e),r=new Array(n);let i=0;for(let e=0;e<32;e++)0!==t[e]&&(r[i++]=t[e]);if(i!==n)throw new Error("invalid number of peaks");return r}peakUpdate(e,t,n){const r={},i=e+1;let a=this.getLeafIndex(i),o=this.hashLeaf(a,n),s=0,u=0,l=!1,c=!1,d=!1;for(let n=1;n<=32;n++)s=32-n,d?r[s]=t[s]:(u=1<<n-1,l=0!=(e&u),c=0!=(i&u),a++,l&&(o=this.hashBranch(a,t[s],o)),c?(r[s]=l?t[s]:o,d=!0):r[s]=0);return r}rollUp(e,t,n,r){if(!e.equals(this.peakBagging(t,n)))throw new Error("invalid root hash from the peaks");let i=t,a=this.peaksToPeakMap(t,n);for(let e=0;e<r.length;e++)a=this.peakUpdate(i,a,r[e]),i++;return this.peakBagging(i,this.peakMapToPeaks(i,a))}_getOrCreateNode(e){if(e>this.size)throw new Error("out of range");if(!this.hashes[e]){const[t,n]=this.getChildren(e),r=this._getOrCreateNode(t),i=this._getOrCreateNode(n);this.hashes[e]=this.hashBranch(e,r,i)}return this.hashes[e]}}hk.MerkleMountainRange=vk,"undefined"!=typeof window&&(window.MerkleMountainRange=vk),hk.default=vk;var wk={},Ek=o&&o.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(wk,"__esModule",{value:!0}),wk.IncrementalMerkleTree=void 0;const Tk=Ek(Px),Ak=Ek(Ox);class _k extends Tk.default{constructor(e,t){if(super(),this.hashFn=e,t.depth&&(this.depth=t.depth),t.arity&&(this.arity=t.arity),this.depth<1)throw new Error("depth must be greater than 0");if(this.arity<1)throw new Error("arity must be greater than 0");const n=[];let r=t.zeroValue;if(this.zeroValue=r,this.zeroes=[],this.depth)for(let e=0;e<this.depth;e++)this.zeroes.push(r),n[e]=[],r=this.hashFn(Array(this.arity).fill(r));this.nodes=n,this.root=r}getRoot(){return this.root}getHexRoot(){return this.bufferToHex(this.bufferify(this.getRoot()))}insert(e){if(this.depth&&this.arity&&this.nodes[0].length>=this.getMaxLeaves())throw new Error("tree is full");let t=e,n=this.nodes[0].length;for(let e=0;e<this.depth;e+=1){const r=n-n%this.arity,i=r+this.arity,a=[];this.nodes[e][n]=t;for(let t=r;t<i;t+=1)t<this.nodes[e].length?a.push(this.nodes[e][t]):a.push(this.zeroes[e]);t=this.hashFn(a),n=Math.floor(n/this.arity)}this.root=t}delete(e){this.update(e,this.zeroValue)}update(e,t){if(e<0||e>=this.nodes[0].length)throw new Error("out of bounds");let n=t;for(let t=0;t<this.depth;t+=1){const r=e-e%this.arity,i=r+this.arity,a=[];this.nodes[t][e]=n;for(let e=r;e<i;e+=1)e<this.nodes[t].length?a.push(this.nodes[t][e]):a.push(this.zeroes[t]);n=this.hashFn(a),e=Math.floor(e/this.arity)}this.root=n}getDepth(){return this.depth}getArity(){return this.arity}getMaxLeaves(){return Math.pow(this.depth,this.arity)}indexOf(e){return this.nodes[0].indexOf(e)}getLeaves(){const e=this.copyList(this.nodes[0]);for(let t=this.nodes[0].length;t<this.getMaxLeaves();t++)e[t]=this.zeroValue;return e}copyList(e){return e.map((e=>BigInt(e)))}getLayers(){const e=[];for(const t of this.nodes)e.push(this.copyList(t));if(e[0].length<this.getMaxLeaves()){let t=e[0].length;for(let n=t;n<this.getMaxLeaves();n++)e[0][n]=this.zeroValue;for(let n=0;n<this.depth;n++){const r=t-t%this.arity,i=r+this.arity;for(let t=r;t<i;t++)t>=e[n].length&&(e[n][t]=this.zeroes[n]);t=Math.floor(t/this.arity)}}return e.push([this.root]),e}getHexLayers(){return this.getLayers().reduce(((e,t)=>(Array.isArray(t)?e.push(t.map((e=>this.bufferToHex(this.bufferify(e))))):e.push(t),e)),[])}getLayersAsObject(){const e=this.getLayers().map((e=>e.map((e=>this.bufferToHex(this.bufferify(e),!1))))),t=[];for(let n=0;n<e.length;n++){const r=[];for(let i=0;i<e[n].length;i++){const a={[e[n][i]]:null};if(t.length){a[e[n][i]]={};const r=t.shift(),o=Object.keys(r)[0];if(a[e[n][i]][o]=r[o],t.length){const r=t.shift(),o=Object.keys(r)[0];a[e[n][i]][o]=r[o]}}r.push(a)}t.push(...r)}return t[0]}computeRoot(){let e,t=this.nodes[0].length;for(let n=0;n<this.depth;n+=1){const r=t-t%this.arity,i=r+this.arity,a=[];for(let e=r;e<i;e+=1)e<this.nodes[n].length?a.push(this.nodes[n][e]):a.push(this.zeroes[n]);e=this.hashFn(a),t=Math.floor(t/this.arity)}return e}getProof(e){if(e<0||e>=this.nodes[0].length)throw new Error("The leaf does not exist in this tree");const t=[],n=[],r=e;for(let r=0;r<this.depth;r+=1){const i=e%this.arity,a=e-i,o=a+this.arity;n[r]=i,t[r]=[];for(let n=a;n<o;n+=1)n!==e&&(n<this.nodes[r].length?t[r].push(this.nodes[r][n]):t[r].push(this.zeroes[r]));e=Math.floor(e/this.arity)}return{root:this.root,leaf:this.nodes[0][r],pathIndices:n,siblings:t}}verify(e){let t=e.leaf;for(let n=0;n<e.siblings.length;n+=1){const r=e.siblings[n].slice();r.splice(e.pathIndices[n],0,t),t=this.hashFn(r)}return e.root===t}toString(){return this.toTreeString()}toTreeString(){const e=this.getLayersAsObject();return Ak.default.asTree(e,!0)}}wk.IncrementalMerkleTree=_k,"undefined"!=typeof window&&(window.IncrementalMerkleTree=_k),wk.default=_k;var xk={};Object.defineProperty(xk,"__esModule",{value:!0}),xk.MerkleSumTree=xk.ProofStep=xk.Leaf=xk.Bucket=void 0;const Ck=Px;class kk{constructor(e,t){this.size=BigInt(e),this.hashed=t,this.parent=null,this.left=null,this.right=null}}xk.Bucket=kk;xk.Leaf=class{constructor(e,t,n){this.hashFn=e,this.rng=t.map((e=>BigInt(e))),this.data=n}getBucket(){let e;return e=this.data?this.hashFn(this.data):Buffer.alloc(32),new kk(BigInt(this.rng[1])-BigInt(this.rng[0]),e)}};class Sk{constructor(e,t){this.bucket=e,this.right=t}}xk.ProofStep=Sk;class Ik extends Ck.Base{constructor(e,t){super(),this.leaves=e,this.hashFn=t,Ik.checkConsecutive(e),this.buckets=[];for(const t of e)this.buckets.push(t.getBucket());let n=[];for(const e of this.buckets)n.push(e);for(;1!==n.length;){const e=[];for(;n.length;)if(n.length>=2){const t=n.shift(),r=n.shift(),i=t.size+r.size,a=this.hashFn(Buffer.concat([this.sizeToBuffer(t.size),this.bufferify(t.hashed),this.sizeToBuffer(r.size),this.bufferify(r.hashed)])),o=new kk(i,a);r.parent=o,t.parent=r.parent,t.right=r,r.left=t,e.push(o)}else e.push(n.shift());n=e}this.root=n[0]}sizeToBuffer(e){const t=Buffer.alloc(8);return new DataView(t.buffer).setBigInt64(0,BigInt(e),!1),t}static checkConsecutive(e){let t=BigInt(0);for(const n of e){if(n.rng[0]!==t)throw new Error("leaf ranges are invalid");t=BigInt(n.rng[1])}}getProof(e){let t=this.buckets[Number(e)];const n=[];for(;t&&t.parent;){const e=!!t.right,r=t.right?t.right:t.left;t=t.parent,n.push(new Sk(r,e))}return n}sum(e){let t=BigInt(0);for(const n of e)t+=BigInt(n);return t}verifyProof(e,t,n){const r=[this.sum(n.filter((e=>!e.right)).map((e=>e.bucket.size))),BigInt(e.size)-this.sum(n.filter((e=>e.right)).map((e=>e.bucket.size)))];if(r[0]!==t.rng[0]||r[1]!==t.rng[1])return!1;let i,a=t.getBucket();for(const e of n)i=e.right?this.hashFn(Buffer.concat([this.sizeToBuffer(a.size),this.bufferify(a.hashed),this.sizeToBuffer(e.bucket.size),this.bufferify(e.bucket.hashed)])):this.hashFn(Buffer.concat([this.sizeToBuffer(e.bucket.size),this.bufferify(e.bucket.hashed),this.sizeToBuffer(a.size),this.bufferify(a.hashed)])),a=new kk(BigInt(a.size)+BigInt(e.bucket.size),i);return a.size===e.size&&a.hashed.toString("hex")===e.hashed.toString("hex")}}xk.MerkleSumTree=Ik,"undefined"!=typeof window&&(window.MerkleSumTree=Ik),xk.default=Ik,function(e){var t=o&&o.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.MerkleTree=void 0;const n=t(_x);e.MerkleTree=n.default;var r=hk;Object.defineProperty(e,"MerkleMountainRange",{enumerable:!0,get:function(){return r.MerkleMountainRange}});var i=wk;Object.defineProperty(e,"IncrementalMerkleTree",{enumerable:!0,get:function(){return i.IncrementalMerkleTree}});var a=xk;Object.defineProperty(e,"MerkleSumTree",{enumerable:!0,get:function(){return a.MerkleSumTree}}),e.default=n.default}(Ax);var Rk={};Object.defineProperty(Rk,"__esModule",{value:!0}),Rk.DefaultGetter=void 0;const Ok=A_,Pk=new P_.Logger("defaults"),Nk={integer:0,address:(0,Ok.hexZeroPad)("0x",20),bool:!1,bytes:"0x",string:""},Mk=e=>void 0!==e&&(null!=e&&(["string","number"].includes(typeof e)&&BigInt(e)===BigInt(0)||Array.isArray(e)&&e.every(Mk)||"object"==typeof e&&Object.values(e).every(Mk)||"boolean"==typeof e&&!1===e));class Lk{constructor(e){this.types=e,this.defaultValues={};for(const t in e){const e=this.getDefaultValue(t);this.defaultValues[t]=e,Mk(e)||Pk.throwError(`Got non-empty value for type ${t} in default generator: ${e}`)}}static from(e,t){const{defaultValues:n}=new Lk(e);return t?n[t]:n}getDefaultValue(e){if(this.defaultValues[e])return this.defaultValues[e];const t=function(e){var t;const[,n]=null!==(t=e.match(/^bytes(\d+)$/))&&void 0!==t?t:[];return n?(0,Ok.hexZeroPad)("0x",parseInt(n)):(e.match(/^(u?)int(\d*)$/)&&(e="integer"),Nk[e])}(e);if(void 0!==t)return t;const n=e.match(/^(.*)(\x5b(\d*)\x5d)$/);if(n){const e=n[1],t=parseInt(n[3]);if(t>0){const n=this.getDefaultValue(e);return Array(t).fill(n)}return[]}const r=this.types[e];return r?r.reduce(((e,{name:t,type:n})=>Object.assign(Object.assign({},e),{[t]:this.getDefaultValue(n)})),{}):Pk.throwArgumentError(`unknown type: ${e}`,"type",e)}}Rk.DefaultGetter=Lk;var Fk={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.getNextLayer=e.getRoot=e.fillArray=e.hashConcat=e.bufferKeccak=e.hexToBuffer=e.bufferToHex=e.chunk=e.makeArray=void 0;const t=A_;e.makeArray=(e,t)=>Array(e).fill(0).map(((e,n)=>t(n)));e.chunk=(t,n)=>(0,e.makeArray)(Math.ceil(t.length/n),(e=>t.slice(e*n,(e+1)*n)));e.bufferToHex=e=>(0,t.hexlify)(e);e.hexToBuffer=e=>Buffer.from(e.slice(2),"hex");e.bufferKeccak=n=>(0,e.hexToBuffer)((0,t.keccak256)(n));e.hashConcat=n=>(0,e.bufferKeccak)((0,t.hexConcat)(n));e.fillArray=(e,t,n)=>(t>e.length&&e.push(...Array(t-e.length).fill(n)),e);e.getRoot=(t,n=!0)=>{if(0===t.length)throw new Error("empty tree");const r=t.map((t=>{const r=Buffer.isBuffer(t)?t:(0,e.hexToBuffer)(t);return n?(0,e.bufferKeccak)(r):r})),i=[r];for(;i[i.length-1].length>1;)i.push((0,e.getNextLayer)(i[i.length-1]));return i[i.length-1][0]};e.getNextLayer=t=>(0,e.chunk)(t,2).map(e.hashConcat)}(Fk),Object.defineProperty(Tx,"__esModule",{value:!0}),Tx.Eip712MerkleTree=void 0;const Dk=S_,Bk=A_,jk=Ax,Uk=Rk,zk=Fk;Tx.Eip712MerkleTree=class{get completedSize(){return Math.pow(2,this.depth)}getCompleteElements(){const e=this.elements;return(0,zk.fillArray)([...e],this.completedSize,this.defaultNode)}getCompleteLeaves(){const e=this.elements.map(this.leafHasher);return(0,zk.fillArray)([...e],this.completedSize,this.defaultLeaf)}get root(){return this.tree.getHexRoot()}getProof(e){const t=this.getCompleteLeaves()[e];return{leaf:t,proof:this.tree.getHexProof(t,e),root:this.tree.getHexRoot()}}getEncodedProofAndSignature(e,t){const{proof:n}=this.getProof(e);return((e,t,n=`0x${"ff".repeat(64)}`)=>(0,Bk.hexConcat)([n,`0x${e.toString(16).padStart(6,"0")}`,Bk.defaultAbiCoder.encode([`uint256[${t.length}]`],[t])]))(e,n,t)}getDataToSign(){let e=this.getCompleteElements();for(;e.length>2;)e=(0,zk.chunk)(e,2);return e}add(e){this.elements.push(e)}getBulkOrderHash(){const e=this.encoder.hashStruct("BulkOrder",{tree:this.getDataToSign()}),t=this.getCompleteLeaves().map(zk.hexToBuffer),n=(0,zk.bufferToHex)((0,zk.getRoot)(t,!1)),r=(0,Bk.keccak256)((0,Bk.toUtf8Bytes)(this.encoder._types.BulkOrder));if((0,Bk.keccak256)((0,Bk.hexConcat)([r,n]))!==e)throw new Error("expected derived bulk order hash to match");return e}constructor(e,t,n,r,i){this.types=e,this.rootType=t,this.leafType=n,this.elements=r,this.depth=i;const a=Dk._TypedDataEncoder.from(e);var o,s;this.encoder=a,this.leafHasher=e=>a.hashStruct(n,e),this.defaultNode=Uk.DefaultGetter.from(e,n),this.defaultLeaf=this.leafHasher(this.defaultNode),this.tree=(o=this.getCompleteLeaves(),s=this.defaultLeaf,new jk.MerkleTree(o.map(zk.hexToBuffer),zk.bufferKeccak,{complete:!0,sort:!1,hashLeaves:!1,fillDefaultHash:(0,zk.hexToBuffer)(s)}))}},Object.defineProperty(Ex,"__esModule",{value:!0}),Ex.getBulkOrderTypeHashes=Ex.getBulkOrderTypeHash=Ex.getBulkOrderTree=Ex.getBulkOrderTreeHeight=void 0;const Vk=A_,Hk=Tx,qk=Rk,Gk=Fk,Wk=G_;function $k(e){const t=Object.assign({},Wk.EIP_712_BULK_ORDER_TYPE);return t.BulkOrder=[{name:"tree",type:`OrderComponents${"[2]".repeat(e)}`}],t}function Kk(e){return Math.max(Math.ceil(Math.log2(e)),1)}function Xk(e){const t=$k(e),n=Vk._TypedDataEncoder.from(t),r=(0,Vk.toUtf8Bytes)(n._types.BulkOrder);return(0,Vk.keccak256)(r)}Ex.getBulkOrderTreeHeight=Kk,Ex.getBulkOrderTree=function(e,t=0,n=Kk(e.length+t)){const r=$k(n),i=qk.DefaultGetter.from(r,"OrderComponents");let a=[...e];return t>0&&(a=[...(0,Gk.fillArray)([],t,i),...e]),new Hk.Eip712MerkleTree(r,"BulkOrder","OrderComponents",a,n)},Ex.getBulkOrderTypeHash=Xk,Ex.getBulkOrderTypeHashes=function(e){const t=[];for(let n=0;n<e;n++)t.push(Xk(n+1));return t};var Zk={},Yk={},Jk={};Object.defineProperty(Jk,"__esModule",{value:!0}),Jk.MerkleTree=void 0;const Qk=T_,eS=A_,tS=Ax,nS=e=>(0,eS.keccak256)(Buffer.from(Qk.BigNumber.from(e).toHexString().slice(2).padStart(64,"0"),"hex"));Jk.MerkleTree=class{constructor(e){this.tree=new tS.default(e.map(nS),eS.keccak256,{sort:!0})}getProof(e){return this.tree.getHexProof(nS(e))}getRoot(){return this.tree.getRoot().toString("hex")?this.tree.getHexRoot():"0"}},Object.defineProperty(Yk,"__esModule",{value:!0}),Yk.shouldUseMatchForFulfill=Yk.generateRandomSalt=Yk.mapOrderAmountsFromUnitsToFill=Yk.mapOrderAmountsFromFilledStatus=Yk.totalItemsAmount=Yk.areAllCurrenciesSame=Yk.mapInputItemToOfferItem=Yk.deductFees=Yk.feeToConsiderationItem=void 0;const rS=T_,iS=A_,aS=G_,oS=tx(),sS=Jk,uS=(e,t)=>rS.BigNumber.from(e).mul(rS.BigNumber.from(t)).div(aS.ONE_HUNDRED_PERCENT_BP);Yk.feeToConsiderationItem=({fee:e,token:t,baseAmount:n,baseEndAmount:r=n})=>({itemType:t===rS.ethers.constants.AddressZero?aS.ItemType.NATIVE:aS.ItemType.ERC20,token:t,identifierOrCriteria:"0",startAmount:uS(n,e.basisPoints).toString(),endAmount:uS(r,e.basisPoints).toString(),recipient:e.recipient});Yk.deductFees=(e,t)=>{if(!t)return e;const n=t.reduce(((e,t)=>e+t.basisPoints),0);return e.map((e=>Object.assign(Object.assign({},e),{startAmount:(0,oS.isCurrencyItem)(e)?rS.BigNumber.from(e.startAmount).sub(uS(e.startAmount,n)).toString():e.startAmount,endAmount:(0,oS.isCurrencyItem)(e)?rS.BigNumber.from(e.endAmount).sub(uS(e.endAmount,n)).toString():e.endAmount})))};Yk.mapInputItemToOfferItem=e=>{var t,n,r,i,a,o,s,u;if("itemType"in e){if("identifiers"in e||"criteria"in e){const i="criteria"in e?e.criteria:new sS.MerkleTree(e.identifiers).getRoot();return{itemType:e.itemType===aS.ItemType.ERC721?aS.ItemType.ERC721_WITH_CRITERIA:aS.ItemType.ERC1155_WITH_CRITERIA,token:e.token,identifierOrCriteria:i,startAmount:null!==(t=e.amount)&&void 0!==t?t:"1",endAmount:null!==(r=null!==(n=e.endAmount)&&void 0!==n?n:e.amount)&&void 0!==r?r:"1"}}return"amount"in e||"endAmount"in e?{itemType:e.itemType,token:e.token,identifierOrCriteria:null!==(i=e.identifier)&&void 0!==i?i:"0",startAmount:e.amount,endAmount:null!==(o=null!==(a=e.endAmount)&&void 0!==a?a:e.amount)&&void 0!==o?o:"1"}:{itemType:e.itemType,token:e.token,identifierOrCriteria:e.identifier,startAmount:"1",endAmount:"1"}}return{itemType:e.token&&e.token!==rS.ethers.constants.AddressZero?aS.ItemType.ERC20:aS.ItemType.NATIVE,token:null!==(s=e.token)&&void 0!==s?s:rS.ethers.constants.AddressZero,identifierOrCriteria:"0",startAmount:e.amount,endAmount:null!==(u=e.endAmount)&&void 0!==u?u:e.amount}};Yk.areAllCurrenciesSame=({offer:e,consideration:t})=>{const n=[...e,...t].filter(oS.isCurrencyItem);return n.every((({itemType:e,token:t})=>e===n[0].itemType&&t.toLowerCase()===n[0].token.toLowerCase()))};Yk.totalItemsAmount=e=>(rS.BigNumber.from(0),rS.BigNumber.from(0),e.map((({startAmount:e,endAmount:t})=>({startAmount:e,endAmount:t}))).reduce((({startAmount:e,endAmount:t},{startAmount:n,endAmount:r})=>({startAmount:e.add(n),endAmount:t.add(r)})),{startAmount:rS.BigNumber.from(0),endAmount:rS.BigNumber.from(0)}));Yk.mapOrderAmountsFromFilledStatus=(e,{totalFilled:t,totalSize:n})=>{if(t.eq(0)||n.eq(0))return e;const r=n.sub(t).mul(aS.ONE_HUNDRED_PERCENT_BP).div(n);return{parameters:Object.assign(Object.assign({},e.parameters),{offer:e.parameters.offer.map((e=>Object.assign(Object.assign({},e),{startAmount:uS(e.startAmount,r).toString(),endAmount:uS(e.endAmount,r).toString()}))),consideration:e.parameters.consideration.map((e=>Object.assign(Object.assign({},e),{startAmount:uS(e.startAmount,r).toString(),endAmount:uS(e.endAmount,r).toString()})))}),signature:e.signature}};const lS=(e,t,n)=>rS.BigNumber.from(e).mul(rS.BigNumber.from(t)).div(n);Yk.mapOrderAmountsFromUnitsToFill=(e,{unitsToFill:t,totalSize:n})=>{const r=rS.BigNumber.from(t);if(r.lte(0))throw new Error("Units to fill must be greater than 1");const i=(0,oS.getMaximumSizeForOrder)(e);return n.eq(0)&&(n=i),{parameters:Object.assign(Object.assign({},e.parameters),{offer:e.parameters.offer.map((e=>Object.assign(Object.assign({},e),{startAmount:lS(e.startAmount,r,n).toString(),endAmount:lS(e.endAmount,r,n).toString()}))),consideration:e.parameters.consideration.map((e=>Object.assign(Object.assign({},e),{startAmount:lS(e.startAmount,r,n).toString(),endAmount:lS(e.endAmount,r,n).toString()})))}),signature:e.signature}};Yk.generateRandomSalt=e=>e?`0x${Buffer.from((0,iS.concat)([(0,iS.keccak256)((0,iS.toUtf8Bytes)(e)).slice(0,10),Uint8Array.from(Array(20).fill(0)),(0,iS.randomBytes)(8)])).toString("hex")}`:`0x${Buffer.from((0,iS.randomBytes)(8)).toString("hex").padStart(64,"0")}`;Yk.shouldUseMatchForFulfill=()=>!0,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.getAdvancedOrderNumeratorDenominator=e.generateFulfillOrdersFulfillments=e.fulfillAvailableOrders=e.validateAndSanitizeFromOrderStatus=e.fulfillStandardOrder=e.fulfillBasicOrder=e.shouldUseBasicFulfill=void 0;const t=T_,n=G_,r=W_,i=cx,a=J_(),o=ex,s=tx(),u=Yk,l=nx;e.shouldUseBasicFulfill=({offer:e,consideration:r,offerer:i},a)=>{if(!a.eq(0))return!1;if(e.length>1||0===r.length)return!1;const o=[...e,...r],l=o.filter((({itemType:e})=>[n.ItemType.ERC721,n.ItemType.ERC1155].includes(e))),c=o.filter((({itemType:e})=>(0,s.isCriteriaItem)(e)));if((0,s.isNativeCurrencyItem)(e[0]))return!1;if(1!==l.length||0!==c.length)return!1;if(!(0,u.areAllCurrenciesSame)({offer:e,consideration:r}))return!1;if(o.some((({startAmount:e,endAmount:t})=>e!==t)))return!1;const[d,...f]=r;if(d.recipient.toLowerCase()!==i.toLowerCase())return!1;if(r.length>1&&f.every((t=>t.itemType===e[0].itemType))&&(0,u.totalItemsAmount)(f).endAmount.gt(e[0].endAmount))return!1;const p=o.filter(s.isCurrencyItem),h=p.filter((({itemType:e})=>e===n.ItemType.NATIVE)).every((({token:e})=>e===t.ethers.constants.AddressZero)),m=p.every((({identifierOrCriteria:e})=>t.BigNumber.from(e).eq(0))),y=l.filter((({itemType:e})=>e===n.ItemType.ERC721)).every((({endAmount:e})=>"1"===e));return h&&m&&y};const c={[n.ItemType.ERC20]:{[n.ItemType.ERC721]:n.BasicOrderRouteType.ERC721_TO_ERC20,[n.ItemType.ERC1155]:n.BasicOrderRouteType.ERC1155_TO_ERC20},[n.ItemType.ERC721]:{[n.ItemType.NATIVE]:n.BasicOrderRouteType.ETH_TO_ERC721,[n.ItemType.ERC20]:n.BasicOrderRouteType.ERC20_TO_ERC721},[n.ItemType.ERC1155]:{[n.ItemType.NATIVE]:n.BasicOrderRouteType.ETH_TO_ERC1155,[n.ItemType.ERC20]:n.BasicOrderRouteType.ERC20_TO_ERC1155}};function d(e,t){const{isValidated:n,isCancelled:r,totalFilled:i,totalSize:a}=t;if(a.gt(0)&&i.div(a).eq(1))throw new Error("The order you are trying to fulfill is already filled");if(r)throw new Error("The order you are trying to fulfill is cancelled");return n?{parameters:Object.assign({},e.parameters),signature:"0x"}:e}function f(e){const t=({sourceOrDestination:e,operator:t="",token:n,identifier:r})=>`${e}-${t}-${n}-${r}`,n={},r={};return e.forEach((({order:e,offererOperator:r,offerCriteria:i},o)=>{const u=(0,a.getItemToCriteriaMap)(e.parameters.offer,i);return e.parameters.offer.forEach(((i,a)=>{var l,c,d;const f=`${t({sourceOrDestination:e.parameters.offerer,operator:r,token:i.token,identifier:null!==(c=null===(l=u.get(i))||void 0===l?void 0:l.identifier)&&void 0!==c?c:i.identifierOrCriteria})}${(0,s.isErc721Item)(i.itemType)?a:""}`;n[f]=[...null!==(d=n[f])&&void 0!==d?d:[],{orderIndex:o,itemIndex:a}]}))})),e.forEach((({order:e,considerationCriteria:n,tips:i},o)=>{const u=(0,a.getItemToCriteriaMap)(e.parameters.consideration,n);return[...e.parameters.consideration,...i].forEach(((e,n)=>{var i,a,l;const c=`${t({sourceOrDestination:e.recipient,token:e.token,identifier:null!==(a=null===(i=u.get(e))||void 0===i?void 0:i.identifier)&&void 0!==a?a:e.identifierOrCriteria})}${(0,s.isErc721Item)(e.itemType)?n:""}`;r[c]=[...null!==(l=r[c])&&void 0!==l?l:[],{orderIndex:o,itemIndex:n}]}))})),{offerFulfillments:Object.values(n),considerationFulfillments:Object.values(r)}}e.fulfillBasicOrder=function({order:e,seaportContract:a,offererBalancesAndApprovals:o,fulfillerBalancesAndApprovals:u,timeBasedItemParams:d,offererOperator:f,fulfillerOperator:p,signer:h,tips:m=[],conduitKey:y=n.NO_CONDUIT,domain:g},b){var v,w;const{offer:E,consideration:T}=e.parameters,A=[...T,...m],_=E[0],[x,...C]=A,k=null===(v=c[_.itemType])||void 0===v?void 0:v[x.itemType];if(void 0===k)throw new Error("Order parameters did not result in a valid basic fulfillment");const S=C.map((({startAmount:e,recipient:t})=>({amount:e,recipient:t}))),I=A.filter((e=>e.itemType!==E[0].itemType)),R=null===(w=(0,s.getSummedTokenAndIdentifierAmounts)({items:I,criterias:[],timeBasedItemParams:Object.assign(Object.assign({},d),{isConsiderationItem:!0})})[t.ethers.constants.AddressZero])||void 0===w?void 0:w[0],O=(0,i.validateBasicFulfillBalancesAndApprovals)({offer:E,consideration:A,offererBalancesAndApprovals:o,fulfillerBalancesAndApprovals:u,timeBasedItemParams:d,offererOperator:f,fulfillerOperator:p}),P={offerer:e.parameters.offerer,offererConduitKey:e.parameters.conduitKey,zone:e.parameters.zone,basicOrderType:e.parameters.orderType+4*k,offerToken:_.token,offerIdentifier:_.identifierOrCriteria,offerAmount:_.endAmount,considerationToken:x.token,considerationIdentifier:x.identifierOrCriteria,considerationAmount:x.endAmount,startTime:e.parameters.startTime,endTime:e.parameters.endTime,salt:e.parameters.salt,totalOriginalAdditionalRecipients:e.parameters.consideration.length-1,signature:e.signature,fulfillerConduitKey:y,additionalRecipients:S,zoneHash:e.parameters.zoneHash},N={value:R},M=[...(0,r.getApprovalActions)(O,b,h),{type:"exchange",transactionMethods:(0,l.getTransactionMethods)(a.connect(h),"fulfillBasicOrder",[P,N],g)}];return{actions:M,executeAllActions:()=>(0,l.executeAllActions)(M)}},e.fulfillStandardOrder=function({order:n,unitsToFill:o=0,totalSize:c,totalFilled:d,offerCriteria:f,considerationCriteria:p,tips:h=[],extraData:m,seaportContract:y,offererBalancesAndApprovals:g,fulfillerBalancesAndApprovals:b,offererOperator:v,fulfillerOperator:w,timeBasedItemParams:E,conduitKey:T,recipientAddress:A,signer:_,domain:x},C){var k;const S=o?(0,u.mapOrderAmountsFromUnitsToFill)(n,{unitsToFill:o,totalSize:c}):(0,u.mapOrderAmountsFromFilledStatus)(n,{totalFilled:d,totalSize:c}),{parameters:{offer:I,consideration:R}}=S,O=[...R,...h],P=I.filter((({itemType:e})=>(0,s.isCriteriaItem)(e))),N=O.filter((({itemType:e})=>(0,s.isCriteriaItem)(e))),M=P.length>0||N.length>0;if(P.length!==f.length||N.length!==p.length)throw new Error("You must supply the appropriate criterias for criteria based items");const L=null===(k=(0,s.getSummedTokenAndIdentifierAmounts)({items:O,criterias:p,timeBasedItemParams:Object.assign(Object.assign({},E),{isConsiderationItem:!0})})[t.ethers.constants.AddressZero])||void 0===k?void 0:k[0],F=(0,i.validateStandardFulfillBalancesAndApprovals)({offer:I,consideration:O,offerCriteria:f,considerationCriteria:p,offererBalancesAndApprovals:g,fulfillerBalancesAndApprovals:b,timeBasedItemParams:E,offererOperator:v,fulfillerOperator:w}),D={value:L},B=(0,r.getApprovalActions)(F,C,_),j=A!==t.ethers.constants.AddressZero,U=Boolean(o)||M||j,z=Object.assign(Object.assign({},n),{parameters:Object.assign(Object.assign({},n.parameters),{consideration:[...n.parameters.consideration,...h],totalOriginalConsiderationItems:R.length})}),{numerator:V,denominator:H}=(0,e.getAdvancedOrderNumeratorDenominator)(n,o),q=[...B,{type:"exchange",transactionMethods:U?(0,l.getTransactionMethods)(y.connect(_),"fulfillAdvancedOrder",[Object.assign(Object.assign({},z),{numerator:V,denominator:H,extraData:null!=m?m:"0x"}),M?(0,a.generateCriteriaResolvers)({orders:[n],offerCriterias:[f],considerationCriterias:[p]}):[],T,A,D],x):(0,l.getTransactionMethods)(y.connect(_),"fulfillOrder",[z,T,D],x)}];return{actions:q,executeAllActions:()=>(0,l.executeAllActions)(q)}},e.validateAndSanitizeFromOrderStatus=d,e.fulfillAvailableOrders=function({ordersMetadata:n,seaportContract:o,fulfillerBalancesAndApprovals:c,fulfillerOperator:p,currentBlockTimestamp:h,ascendingAmountTimestampBuffer:m,conduitKey:y,signer:g,recipientAddress:b,exactApproval:v,domain:w}){const E=n.map((e=>Object.assign(Object.assign({},e),{order:d(e.order,e.orderStatus)}))),T=E.map((e=>Object.assign(Object.assign({},e),{order:e.unitsToFill?(0,u.mapOrderAmountsFromUnitsToFill)(e.order,{unitsToFill:e.unitsToFill,totalSize:e.orderStatus.totalSize}):(0,u.mapOrderAmountsFromFilledStatus)(e.order,{totalFilled:e.orderStatus.totalFilled,totalSize:e.orderStatus.totalSize})})));let A=t.BigNumber.from(0);const _=[],x=E.flatMap((e=>[e.order.parameters.offer,e.order.parameters.consideration])).flat().filter((({itemType:e})=>(0,s.isCriteriaItem)(e))).length>0;T.forEach((({order:e,tips:n,offerCriteria:r,considerationCriteria:a,offererBalancesAndApprovals:o,offererOperator:u})=>{var l,d;const f=[...e.parameters.consideration,...n],y={startTime:e.parameters.startTime,endTime:e.parameters.endTime,currentBlockTimestamp:h,ascendingAmountTimestampBuffer:m,isConsiderationItem:!0};A=A.add(null!==(d=null===(l=(0,s.getSummedTokenAndIdentifierAmounts)({items:f,criterias:a,timeBasedItemParams:y})[t.ethers.constants.AddressZero])||void 0===l?void 0:l[0])&&void 0!==d?d:t.BigNumber.from(0));const g=(0,i.validateStandardFulfillBalancesAndApprovals)({offer:e.parameters.offer,consideration:f,offerCriteria:r,considerationCriteria:a,offererBalancesAndApprovals:o,fulfillerBalancesAndApprovals:c,timeBasedItemParams:y,offererOperator:u,fulfillerOperator:p}),b=e.parameters.offer.filter((({itemType:e})=>(0,s.isCriteriaItem)(e))),v=f.filter((({itemType:e})=>(0,s.isCriteriaItem)(e)));if(b.length!==r.length||v.length!==a.length)throw new Error("You must supply the appropriate criterias for criteria based items");g.forEach((e=>{_.find((t=>t.token===e.token))||_.push(e)}))}));const C={value:A},k=(0,r.getApprovalActions)(_,v,g),S=E.map((({order:t,unitsToFill:n=0,tips:r,extraData:i})=>{const{numerator:a,denominator:o}=(0,e.getAdvancedOrderNumeratorDenominator)(t,n),s=[...t.parameters.consideration,...r];return Object.assign(Object.assign({},t),{parameters:Object.assign(Object.assign({},t.parameters),{consideration:s,totalOriginalConsiderationItems:t.parameters.consideration.length}),numerator:a,denominator:o,extraData:i})})),{offerFulfillments:I,considerationFulfillments:R}=f(n),O={type:"exchange",transactionMethods:(0,l.getTransactionMethods)(o.connect(g),"fulfillAvailableAdvancedOrders",[S,x?(0,a.generateCriteriaResolvers)({orders:n.map((({order:e})=>e)),offerCriterias:n.map((({offerCriteria:e})=>e)),considerationCriterias:n.map((({considerationCriteria:e})=>e))}):[],I,R,y,b,S.length,C],w)},P=[...k,O];return{actions:P,executeAllActions:()=>(0,l.executeAllActions)(P)}},e.generateFulfillOrdersFulfillments=f;e.getAdvancedOrderNumeratorDenominator=(e,n)=>{const r=(0,s.getMaximumSizeForOrder)(e),i=t.BigNumber.from(n),a=(0,o.gcd)(i,r);return{numerator:n?i.div(a):t.BigNumber.from(1),denominator:n?r.div(a):t.BigNumber.from(1)}}}(Zk);var cS=o&&o.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(i,a){function o(e){try{u(r.next(e))}catch(e){a(e)}}function s(e){try{u(r.throw(e))}catch(e){a(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}u((r=r.apply(e,t||[])).next())}))};Object.defineProperty(YA,"__esModule",{value:!0}),YA.Seaport=void 0;const dS=E_,fS=T_,pS=A_,hS=H_,mS=q_,yS=G_,gS=W_,bS=cx,vS=Ex,wS=Zk,ES=tx(),TS=Yk,AS=nx;YA.Seaport=class{constructor(e,{overrides:t,ascendingAmountFulfillmentBuffer:n=300,balanceAndApprovalChecksOnOrderCreation:r=!0,conduitKeyToConduit:i,seaportVersion:a="1.5"}={}){var o,s,u;this.OPENSEA_CONDUIT_KEY=yS.OPENSEA_CONDUIT_KEY,this.getOrderHash=e=>{const t="OfferItem(uint8 itemType,address token,uint256 identifierOrCriteria,uint256 startAmount,uint256 endAmount)",n="ConsiderationItem(uint8 itemType,address token,uint256 identifierOrCriteria,uint256 startAmount,uint256 endAmount,address recipient)",r=`OrderComponents(address offerer,address zone,OfferItem[] offer,ConsiderationItem[] consideration,uint8 orderType,uint256 startTime,uint256 endTime,bytes32 zoneHash,uint256 salt,bytes32 conduitKey,uint256 counter)${n}${t}`,i=fS.ethers.utils.keccak256(fS.ethers.utils.toUtf8Bytes(t)),a=fS.ethers.utils.keccak256(fS.ethers.utils.toUtf8Bytes(n)),o=fS.ethers.utils.keccak256(fS.ethers.utils.toUtf8Bytes(r)),s=fS.ethers.utils.keccak256("0x"+e.offer.map((e=>fS.ethers.utils.keccak256("0x"+[i.slice(2),e.itemType.toString().padStart(64,"0"),e.token.slice(2).padStart(64,"0"),fS.ethers.BigNumber.from(e.identifierOrCriteria).toHexString().slice(2).padStart(64,"0"),fS.ethers.BigNumber.from(e.startAmount).toHexString().slice(2).padStart(64,"0"),fS.ethers.BigNumber.from(e.endAmount).toHexString().slice(2).padStart(64,"0")].join("")).slice(2))).join("")),u=fS.ethers.utils.keccak256("0x"+e.consideration.map((e=>fS.ethers.utils.keccak256("0x"+[a.slice(2),e.itemType.toString().padStart(64,"0"),e.token.slice(2).padStart(64,"0"),fS.ethers.BigNumber.from(e.identifierOrCriteria).toHexString().slice(2).padStart(64,"0"),fS.ethers.BigNumber.from(e.startAmount).toHexString().slice(2).padStart(64,"0"),fS.ethers.BigNumber.from(e.endAmount).toHexString().slice(2).padStart(64,"0"),e.recipient.slice(2).padStart(64,"0")].join("")).slice(2))).join(""));return fS.ethers.utils.keccak256("0x"+[o.slice(2),e.offerer.slice(2).padStart(64,"0"),e.zone.slice(2).padStart(64,"0"),s.slice(2),u.slice(2),e.orderType.toString().padStart(64,"0"),fS.ethers.BigNumber.from(e.startTime).toHexString().slice(2).padStart(64,"0"),fS.ethers.BigNumber.from(e.endTime).toHexString().slice(2).padStart(64,"0"),e.zoneHash.slice(2),fS.BigNumber.from(e.salt).toHexString().slice(2).padStart(64,"0"),e.conduitKey.slice(2).padStart(64,"0"),fS.ethers.BigNumber.from(e.counter).toHexString().slice(2).padStart(64,"0")].join(""))};const l=e instanceof fS.providers.Provider?e:e.provider;if(this.signer=e._isSigner?e:void 0,!l)throw new Error("Either a provider or custom signer with provider must be provided");this.provider=l,this.multicallProvider=new dS.providers.MulticallProvider(this.provider),this.contract=new fS.Contract(null!==(o=null==t?void 0:t.contractAddress)&&void 0!==o?o:"1.5"===a?yS.CROSS_CHAIN_SEAPORT_V1_5_ADDRESS:yS.CROSS_CHAIN_SEAPORT_V1_4_ADDRESS,mS.SeaportABIv14,this.multicallProvider),this.domainRegistry=new fS.Contract(null!==(s=null==t?void 0:t.domainRegistryAddress)&&void 0!==s?s:yS.DOMAIN_REGISTRY_ADDRESS,hS.DomainRegistryABI,this.multicallProvider),this.config={ascendingAmountFulfillmentBuffer:n,balanceAndApprovalChecksOnOrderCreation:r,conduitKeyToConduit:Object.assign(Object.assign(Object.assign({},yS.KNOWN_CONDUIT_KEYS_TO_CONDUIT),{[yS.NO_CONDUIT]:this.contract.address}),i),seaportVersion:a},this.defaultConduitKey=null!==(u=null==t?void 0:t.defaultConduitKey)&&void 0!==u?u:yS.NO_CONDUIT}createOrder(e,t,n){return cS(this,void 0,void 0,(function*(){const r=this._getSigner(t),i=null!=t?t:yield r.getAddress(),{orderComponents:a,approvalActions:o}=yield this._formatOrder(r,i,Boolean(n),e),s={type:"create",getMessageToSign:()=>this._getMessageToSign(a),createOrder:()=>cS(this,void 0,void 0,(function*(){const e=yield this.signOrder(a,i);return{parameters:a,signature:e}}))},u=[...o,s];return{actions:u,executeAllActions:()=>(0,AS.executeAllActions)(u)}}))}createBulkOrders(e,t,n){var r;return cS(this,void 0,void 0,(function*(){const i=this._getSigner(t),a=yield i.getAddress(),o=yield this.getCounter(a),s=[],u=[];for(const t of e){null!==(r=t.counter)&&void 0!==r||(t.counter=o);const{orderComponents:e,approvalActions:l}=yield this._formatOrder(i,a,Boolean(n),t);u.push(e);for(const e of l)void 0===s.find((t=>t.token===e.token))&&s.push(e)}const l={type:"createBulk",getMessageToSign:()=>this._getBulkMessageToSign(u),createBulkOrders:()=>cS(this,void 0,void 0,(function*(){return yield this.signBulkOrder(u,a)}))},c=[...s,l];return{actions:c,executeAllActions:()=>(0,AS.executeAllActions)(c)}}))}_formatOrder(e,t,n,{conduitKey:r=this.defaultConduitKey,zone:i=fS.ethers.constants.AddressZero,zoneHash:a=fS.ethers.constants.HashZero,startTime:o=Math.floor(Date.now()/1e3).toString(),endTime:s=yS.MAX_INT.toString(),offer:u,consideration:l,counter:c,allowPartialFills:d,restrictedByZone:f,fees:p,domain:h,salt:m}){var y;return cS(this,void 0,void 0,(function*(){const g=u.map(TS.mapInputItemToOfferItem),b=[...l.map((e=>{var n;return Object.assign(Object.assign({},(0,TS.mapInputItemToOfferItem)(e)),{recipient:null!==(n=e.recipient)&&void 0!==n?n:t})}))];if((null==p?void 0:p.length)&&!(0,TS.areAllCurrenciesSame)({offer:g,consideration:b}))throw new Error("All currency tokens in the order must be the same token when applying fees");const v=[...g,...b].filter(ES.isCurrencyItem),w=(0,TS.totalItemsAmount)(v),E=this.config.conduitKeyToConduit[r],T=this._getOrderTypeFromOrderOptions({allowPartialFills:d,restrictedByZone:f}),A=[...(0,TS.deductFees)(b,p),...v.length&&null!==(y=null==p?void 0:p.map((e=>(0,TS.feeToConsiderationItem)({fee:e,token:v[0].token,baseAmount:w.startAmount,baseEndAmount:w.endAmount}))))&&void 0!==y?y:[]],_=void 0!==m?`0x${fS.BigNumber.from(m).toHexString().slice(2).padStart(64,"0")}`:(0,TS.generateRandomSalt)(h),x={offerer:t,zone:i,zoneHash:a,startTime:o,endTime:s,orderType:T,offer:g,consideration:A,totalOriginalConsiderationItems:A.length,salt:_,conduitKey:r,counter:(null!=c?c:yield this.getCounter(t)).toString()},C=[];if(this.config.balanceAndApprovalChecksOnOrderCreation){const r=yield(0,bS.getBalancesAndApprovals)({owner:t,items:g,criterias:[],multicallProvider:this.multicallProvider,operator:E}),i=(0,bS.validateOfferBalancesAndApprovals)({offer:g,criterias:[],balancesAndApprovals:r,throwOnInsufficientBalances:!0,operator:E}),a=(0,gS.getApprovalActions)(i,n,e);C.push(...a)}return{orderComponents:x,approvalActions:C}}))}_getSigner(e){if(this.signer)return this.signer;if(!(this.provider instanceof fS.providers.JsonRpcProvider))throw new Error("Either signer or a JsonRpcProvider must be provided");return this.provider.getSigner(e)}_getOrderTypeFromOrderOptions({allowPartialFills:e,restrictedByZone:t}){return e?t?yS.OrderType.PARTIAL_RESTRICTED:yS.OrderType.PARTIAL_OPEN:t?yS.OrderType.FULL_RESTRICTED:yS.OrderType.FULL_OPEN}_getDomainData(){return cS(this,void 0,void 0,(function*(){const{chainId:e}=yield this.provider.getNetwork();return{name:yS.SEAPORT_CONTRACT_NAME,version:"1.5"===this.config.seaportVersion?yS.SEAPORT_CONTRACT_VERSION_V1_5:yS.SEAPORT_CONTRACT_VERSION_V1_4,chainId:e,verifyingContract:this.contract.address}}))}_getMessageToSign(e){return cS(this,void 0,void 0,(function*(){const t=yield this._getDomainData();return JSON.stringify(pS._TypedDataEncoder.getPayload(t,yS.EIP_712_ORDER_TYPE,e))}))}_getBulkMessageToSign(e){return cS(this,void 0,void 0,(function*(){const t=yield this._getDomainData(),n=(0,vS.getBulkOrderTree)(e),r=n.types,i=n.getDataToSign();return JSON.stringify(pS._TypedDataEncoder.getPayload(t,r,{tree:i}))}))}signOrder(e,t){return cS(this,void 0,void 0,(function*(){const n=this._getSigner(t),r=yield this._getDomainData();let i=yield n._signTypedData(r,yS.EIP_712_ORDER_TYPE,e);return 132===i.length&&(i=fS.ethers.utils.splitSignature(i).compact),i}))}signBulkOrder(e,t){return cS(this,void 0,void 0,(function*(){const n=this._getSigner(t),r=yield this._getDomainData(),i=(0,vS.getBulkOrderTree)(e),a=i.types,o={tree:i.getDataToSign()};let s=yield n._signTypedData(r,a,o);132===s.length&&(s=fS.ethers.utils.splitSignature(s).compact);const u=e.map(((e,t)=>({parameters:e,signature:i.getEncodedProofAndSignature(t,s)})));return u}))}cancelOrders(e,t,n){const r=this._getSigner(t);return(0,AS.getTransactionMethods)(this.contract.connect(r),"cancel",[e],n)}bulkCancelOrders(e,t){const n=this._getSigner(e);return(0,AS.getTransactionMethods)(this.contract.connect(n),"incrementCounter",[],t)}validate(e,t,n){const r=this._getSigner(t);return(0,AS.getTransactionMethods)(this.contract.connect(r),"validate",[e],n)}getOrderStatus(e){return this.contract.getOrderStatus(e)}getCounter(e){return this.contract.getCounter(e)}fulfillOrder({order:e,unitsToFill:t,offerCriteria:n=[],considerationCriteria:r=[],tips:i=[],extraData:a="0x",accountAddress:o,conduitKey:s=this.defaultConduitKey,recipientAddress:u=fS.ethers.constants.AddressZero,domain:l,exactApproval:c=!1}){return cS(this,void 0,void 0,(function*(){if(!e.signature)throw new Error("Order is missing signature");const{parameters:d}=e,{offerer:f,offer:p,consideration:h}=d,m=this._getSigner(o),y=yield m.getAddress(),g=this.config.conduitKeyToConduit[d.conduitKey],b=this.config.conduitKeyToConduit[s],[v,w,E,T]=yield Promise.all([(0,bS.getBalancesAndApprovals)({owner:f,items:p,criterias:n,multicallProvider:this.multicallProvider,operator:g}),(0,bS.getBalancesAndApprovals)({owner:y,items:[...p,...h],criterias:[...n,...r],multicallProvider:this.multicallProvider,operator:b}),this.multicallProvider.getBlock("latest"),this.getOrderStatus(this.getOrderHash(d))]),A=E.timestamp,{totalFilled:_,totalSize:x}=T,C=(0,wS.validateAndSanitizeFromOrderStatus)(e,T),k={startTime:C.parameters.startTime,endTime:C.parameters.endTime,currentBlockTimestamp:A,ascendingAmountTimestampBuffer:this.config.ascendingAmountFulfillmentBuffer},S=i.map((e=>Object.assign(Object.assign({},(0,TS.mapInputItemToOfferItem)(e)),{recipient:e.recipient}))),I=u===fS.ethers.constants.AddressZero;return!t&&I&&(0,wS.shouldUseBasicFulfill)(C.parameters,_)?(0,wS.fulfillBasicOrder)({order:C,seaportContract:this.contract,offererBalancesAndApprovals:v,fulfillerBalancesAndApprovals:w,timeBasedItemParams:k,conduitKey:s,offererOperator:g,fulfillerOperator:b,signer:m,tips:S,domain:l},c):(0,wS.fulfillStandardOrder)({order:C,unitsToFill:t,totalFilled:_,totalSize:x.eq(0)?(0,ES.getMaximumSizeForOrder)(C):x,offerCriteria:n,considerationCriteria:r,tips:S,extraData:a,seaportContract:this.contract,offererBalancesAndApprovals:v,fulfillerBalancesAndApprovals:w,timeBasedItemParams:k,conduitKey:s,signer:m,offererOperator:g,fulfillerOperator:b,recipientAddress:u,domain:l},c)}))}fulfillOrders({fulfillOrderDetails:e,accountAddress:t,conduitKey:n=this.defaultConduitKey,recipientAddress:r=fS.ethers.constants.AddressZero,domain:i,exactApproval:a=!1}){return cS(this,void 0,void 0,(function*(){if(e.some((e=>!e.order.signature)))throw new Error("All orders must include signatures");const o=this._getSigner(t),s=yield o.getAddress(),u=e.map((({order:e})=>this.config.conduitKeyToConduit[e.parameters.conduitKey])),l=this.config.conduitKeyToConduit[n],c=e.flatMap((({order:e})=>e.parameters.offer)),d=e.flatMap((({order:e})=>e.parameters.consideration)),f=e.flatMap((({offerCriteria:e=[]})=>e)),p=e.flatMap((({considerationCriteria:e=[]})=>e)),[h,m,y,g]=yield Promise.all([Promise.all(e.map((({order:e,offerCriteria:t=[]},n)=>(0,bS.getBalancesAndApprovals)({owner:e.parameters.offerer,items:e.parameters.offer,criterias:t,operator:u[n],multicallProvider:this.multicallProvider})))),(0,bS.getBalancesAndApprovals)({owner:s,items:[...c,...d],criterias:[...f,...p],operator:l,multicallProvider:this.multicallProvider}),this.multicallProvider.getBlock("latest"),Promise.all(e.map((({order:e})=>this.getOrderStatus(this.getOrderHash(e.parameters)))))]),b=e.map(((e,t)=>{var n,r,i,a,o;return{order:e.order,unitsToFill:e.unitsToFill,orderStatus:g[t],offerCriteria:null!==(n=e.offerCriteria)&&void 0!==n?n:[],considerationCriteria:null!==(r=e.considerationCriteria)&&void 0!==r?r:[],tips:null!==(a=null===(i=e.tips)||void 0===i?void 0:i.map((e=>Object.assign(Object.assign({},(0,TS.mapInputItemToOfferItem)(e)),{recipient:e.recipient}))))&&void 0!==a?a:[],extraData:null!==(o=e.extraData)&&void 0!==o?o:"0x",offererBalancesAndApprovals:h[t],offererOperator:u[t]}}));return(0,wS.fulfillAvailableOrders)({ordersMetadata:b,seaportContract:this.contract,fulfillerBalancesAndApprovals:m,currentBlockTimestamp:y.timestamp,ascendingAmountTimestampBuffer:this.config.ascendingAmountFulfillmentBuffer,fulfillerOperator:l,signer:o,conduitKey:n,recipientAddress:r,domain:i,exactApproval:a})}))}matchOrders({orders:e,fulfillments:t,overrides:n,accountAddress:r,domain:i}){const a=this._getSigner(r);return(0,AS.getTransactionMethods)(this.contract.connect(a),"matchOrders",[e,t,n],i)}setDomain(e,t){const n=this._getSigner(t);return(0,AS.getTransactionMethods)(this.domainRegistry.connect(n),"setDomain",[e])}getNumberOfDomains(e){return cS(this,void 0,void 0,(function*(){return this.domainRegistry.getNumberOfDomains(e)}))}getDomain(e,t){return this.domainRegistry.getDomain(e,t)}getDomains(e,t){return cS(this,void 0,void 0,(function*(){try{if(t)throw Error;return this.domainRegistry.getDomains(e)}catch(t){const n=(yield this.domainRegistry.getNumberOfDomains(e)).toNumber(),r=Promise.all([...Array(n).keys()].map((t=>this.domainRegistry.getDomain(e,t))));return r}}))}},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.Seaport=void 0;const t=YA;Object.defineProperty(e,"Seaport",{enumerable:!0,get:function(){return t.Seaport}})}(ZA);class _S{config;constructor(e){this.config=e}}class xS extends Error{url;status;statusText;body;request;constructor(e,t,n){super(n),this.name="ApiError",this.url=t.url,this.status=t.status,this.statusText=t.statusText,this.body=t.body,this.request=e}}class CS extends Error{constructor(e){super(e),this.name="CancelError"}get isCancelled(){return!0}}class kS{[Symbol.toStringTag];_isResolved;_isRejected;_isCancelled;_cancelHandlers;_promise;_resolve;_reject;constructor(e){this._isResolved=!1,this._isRejected=!1,this._isCancelled=!1,this._cancelHandlers=[],this._promise=new Promise(((t,n)=>{this._resolve=t,this._reject=n;const r=e=>{this._isResolved||this._isRejected||this._isCancelled||this._cancelHandlers.push(e)};return Object.defineProperty(r,"isResolved",{get:()=>this._isResolved}),Object.defineProperty(r,"isRejected",{get:()=>this._isRejected}),Object.defineProperty(r,"isCancelled",{get:()=>this._isCancelled}),e((e=>{this._isResolved||this._isRejected||this._isCancelled||(this._isResolved=!0,this._resolve?.(e))}),(e=>{this._isResolved||this._isRejected||this._isCancelled||(this._isRejected=!0,this._reject?.(e))}),r)}))}then(e,t){return this._promise.then(e,t)}catch(e){return this._promise.catch(e)}finally(e){return this._promise.finally(e)}cancel(){if(!(this._isResolved||this._isRejected||this._isCancelled)){if(this._isCancelled=!0,this._cancelHandlers.length)try{for(const e of this._cancelHandlers)e()}catch(e){return void console.warn("Cancellation threw an error",e)}this._cancelHandlers.length=0,this._reject?.(new CS("Request aborted"))}}get isCancelled(){return this._isCancelled}}const SS=e=>null!=e,IS=e=>"string"==typeof e,RS=e=>IS(e)&&""!==e,OS=e=>"object"==typeof e&&"string"==typeof e.type&&"function"==typeof e.stream&&"function"==typeof e.arrayBuffer&&"function"==typeof e.constructor&&"string"==typeof e.constructor.name&&/^(Blob|File)$/.test(e.constructor.name)&&/^(Blob|File)$/.test(e[Symbol.toStringTag]),PS=e=>e>=200&&e<300,NS=e=>{const t=[],n=(e,r)=>{SS(r)&&(Array.isArray(r)?r.forEach((t=>{n(e,t)})):"object"==typeof r?Object.entries(r).forEach((([t,r])=>{n(`${e}[${t}]`,r)})):((e,n)=>{t.push(`${encodeURIComponent(e)}=${encodeURIComponent(String(n))}`)})(e,r))};return Object.entries(e).forEach((([e,t])=>{n(e,t)})),t.length>0?`?${t.join("&")}`:""},MS=async(e,t)=>"function"==typeof t?t(e):t,LS=async(e,t,n)=>{const r=await MS(t,e.TOKEN),i=await MS(t,e.USERNAME),a=await MS(t,e.PASSWORD),o=await MS(t,e.HEADERS),s="function"==typeof n?.getHeaders&&n?.getHeaders()||{},u=Object.entries({Accept:"application/json",...o,...t.headers,...s}).filter((([e,t])=>SS(t))).reduce(((e,[t,n])=>({...e,[t]:String(n)})),{});if(RS(r)&&(u.Authorization=`Bearer ${r}`),RS(i)&&RS(a)){const e=(e=>{try{return btoa(e)}catch(t){return Buffer.from(e).toString("base64")}})(`${i}:${a}`);u.Authorization=`Basic ${e}`}return t.body&&(t.mediaType?u["Content-Type"]=t.mediaType:OS(t.body)?u["Content-Type"]=t.body.type||"application/octet-stream":IS(t.body)?u["Content-Type"]="text/plain":t.body instanceof XA||(u["Content-Type"]="application/json")),u},FS=(e,t)=>new kS((async(n,r,i)=>{try{const r=((e,t)=>{const n=e.ENCODE_PATH||encodeURI,r=t.url.replace("{api-version}",e.VERSION).replace(/{(.*?)}/g,((e,r)=>t.path?.hasOwnProperty(r)?n(String(t.path[r])):e)),i=`${e.BASE}${r}`;return t.query?`${i}${NS(t.query)}`:i})(e,t),a=(e=>{if(e.formData){const t=new XA,n=(e,n)=>{IS(n)||OS(n)?t.append(e,n):t.append(e,JSON.stringify(n))};return Object.entries(e.formData).filter((([e,t])=>SS(t))).forEach((([e,t])=>{Array.isArray(t)?t.forEach((t=>n(e,t))):n(e,t)})),t}})(t),o=(e=>{if(e.body)return e.body})(t),s=await LS(e,t,a);if(!i.isCancelled){const u=await(async(e,t,n,r,i,a,o)=>{const s=hp.CancelToken.source(),u={url:n,headers:a,data:r??i,method:t.method,withCredentials:e.WITH_CREDENTIALS,cancelToken:s.token};o((()=>s.cancel("The user aborted a request.")));try{return await hp.request(u)}catch(e){const t=e;if(t.response)return t.response;throw e}})(e,t,r,o,a,s,i),l=(e=>{if(204!==e.status)return e.data})(u),c=((e,t)=>{if(t){const n=e.headers[t];if(IS(n))return n}})(u,t.responseHeader),d={url:r,ok:PS(u.status),status:u.status,statusText:u.statusText,body:c??l};((e,t)=>{const n={400:"Bad Request",401:"Unauthorized",403:"Forbidden",404:"Not Found",500:"Internal Server Error",502:"Bad Gateway",503:"Service Unavailable",...e.errors}[t.status];if(n)throw new xS(e,t,n);if(!t.ok)throw new xS(e,t,"Generic Error")})(t,d),n(d.body)}}catch(e){r(e)}}));class DS extends _S{constructor(e){super(e)}request(e){return FS(this.config,e)}}class BS{httpRequest;constructor(e){this.httpRequest=e}cancelOrders({chainName:e,requestBody:t}){return this.httpRequest.request({method:"POST",url:"/v1/chains/{chain_name}/orders/cancel",path:{chain_name:e},body:t,mediaType:"application/json",errors:{400:"Bad Request (400)",401:"Unauthorised Request (401)",404:"The specified resource was not found (404)",429:"Too Many Requests (429)",500:"Internal Server Error (500)",501:"Not Implemented Error (501)"}})}listListings({chainName:e,status:t,sellItemContractAddress:n,buyItemContractAddress:r,sellItemTokenId:i,fromUpdatedAt:a,pageSize:o,sortBy:s,sortDirection:u,pageCursor:l}){return this.httpRequest.request({method:"GET",url:"/v1/chains/{chain_name}/orders/listings",path:{chain_name:e},query:{status:t,sell_item_contract_address:n,buy_item_contract_address:r,sell_item_token_id:i,from_updated_at:a,page_size:o,sort_by:s,sort_direction:u,page_cursor:l},errors:{400:"Bad Request (400)",404:"The specified resource was not found (404)",500:"Internal Server Error (500)"}})}createListing({chainName:e,requestBody:t}){return this.httpRequest.request({method:"POST",url:"/v1/chains/{chain_name}/orders/listings",path:{chain_name:e},body:t,mediaType:"application/json",errors:{400:"Bad Request (400)",404:"The specified resource was not found (404)",500:"Internal Server Error (500)"}})}getListing({chainName:e,listingId:t}){return this.httpRequest.request({method:"GET",url:"/v1/chains/{chain_name}/orders/listings/{listing_id}",path:{chain_name:e,listing_id:t},errors:{400:"Bad Request (400)",404:"The specified resource was not found (404)",500:"Internal Server Error (500)"}})}fulfillmentData({chainName:e,requestBody:t}){return this.httpRequest.request({method:"POST",url:"/v1/chains/{chain_name}/orders/fulfillment-data",path:{chain_name:e},body:t,mediaType:"application/json",errors:{400:"Bad Request (400)",404:"The specified resource was not found (404)",500:"Internal Server Error (500)"}})}listTrades({chainName:e,accountAddress:t,fromIndexedAt:n,pageSize:r,sortBy:i,sortDirection:a,pageCursor:o}){return this.httpRequest.request({method:"GET",url:"/v1/chains/{chain_name}/trades",path:{chain_name:e},query:{account_address:t,from_indexed_at:n,page_size:r,sort_by:i,sort_direction:a,page_cursor:o},errors:{400:"Bad Request (400)",404:"The specified resource was not found (404)",500:"Internal Server Error (500)"}})}getTrade({chainName:e,tradeId:t}){return this.httpRequest.request({method:"GET",url:"/v1/chains/{chain_name}/trades/{trade_id}",path:{chain_name:e,trade_id:t},errors:{400:"Bad Request (400)",404:"The specified resource was not found (404)",500:"Internal Server Error (500)"}})}}class jS{orders;request;constructor(e,t=DS){this.request=new t({BASE:e?.BASE??"https://api.sandbox.immutable.com",VERSION:e?.VERSION??"1.0.0",WITH_CREDENTIALS:e?.WITH_CREDENTIALS??!1,CREDENTIALS:e?.CREDENTIALS??"include",TOKEN:e?.TOKEN,USERNAME:e?.USERNAME,PASSWORD:e?.PASSWORD,HEADERS:e?.HEADERS,ENCODE_PATH:e?.ENCODE_PATH}),this.orders=new BS(this.request)}}var US,zS,VS,HS,qS,GS,WS,$S,KS;function XS(e){const t=e.buy.map((e=>{if("ERC20"===e.item_type)return{type:"ERC20",contractAddress:e.contract_address,amount:e.start_amount};if("NATIVE"===e.item_type)return{type:"NATIVE",amount:e.start_amount};throw new Error("Buy items must be either ERC20 or NATIVE")})),n=e.sell.map((e=>{if("ERC721"===e.item_type)return{type:"ERC721",contractAddress:e.contract_address,tokenId:e.token_id};throw new Error("Sell items must ERC721")}));return{id:e.id,accountAddress:e.account_address,buy:t,sell:n,fees:e.fees.map((e=>({amount:e.amount,recipient:e.recipient,type:e.fee_type}))),chain:e.chain,createdAt:e.created_at,endAt:e.end_at,protocolData:{counter:e.protocol_data.counter,orderType:e.protocol_data.order_type,seaportAddress:e.protocol_data.seaport_address,seaportVersion:e.protocol_data.seaport_version,zoneAddress:e.protocol_data.zone_address},salt:e.salt,signature:e.signature,startAt:e.start_at,status:e.status,updatedAt:e.updated_at}}function ZS(e){const t=e.buy.map((e=>{if("ERC20"===e.item_type)return{type:"ERC20",contractAddress:e.contract_address,amount:e.start_amount};if("NATIVE"===e.item_type)return{type:"NATIVE",amount:e.start_amount};throw new Error("Buy items must be either ERC20 or NATIVE")})),n=e.sell.map((e=>{if("ERC721"===e.item_type)return{type:"ERC721",contractAddress:e.contract_address,tokenId:e.token_id};throw new Error("Sell items must ERC721")}));return{id:e.id,orderId:e.order_id,buy:t,sell:n,buyerFees:e.buyer_fees.map((e=>({amount:e.amount,recipient:e.recipient,type:e.fee_type}))),chain:e.chain,indexedAt:e.indexed_at,blockchainMetadata:{blockNumber:e.blockchain_metadata.block_number,logIndex:e.blockchain_metadata.log_index,transactionHash:e.blockchain_metadata.transaction_hash,transactionIndex:e.blockchain_metadata.transaction_index},buyerAddress:e.buyer_address,makerAddress:e.maker_address,sellerAddress:e.seller_address,takerAddress:e.taker_address}}function YS(e){return{nextCursor:e.next_cursor,previousCursor:e.previous_cursor}}!function(e){var t;(t=e.cancellation_type||(e.cancellation_type={})).ON_CHAIN="ON_CHAIN",t.OFF_CHAIN="OFF_CHAIN"}(US||(US={})),function(e){(e.reason_code||(e.reason_code={})).ALREADY_FILLED="ALREADY_FILLED"}(zS||(zS={})),function(e){var t;(t=e.fee_type||(e.fee_type={})).ROYALTY="ROYALTY",t.MAKER_ECOSYSTEM="MAKER_ECOSYSTEM",t.TAKER_ECOSYSTEM="TAKER_ECOSYSTEM",t.PROTOCOL="PROTOCOL"}(VS||(VS={})),function(e){e.PENDING="PENDING",e.ACTIVE="ACTIVE",e.INACTIVE="INACTIVE",e.FILLED="FILLED",e.EXPIRED="EXPIRED",e.CANCELLED="CANCELLED"}(HS||(HS={})),function(e){(e.order_type||(e.order_type={})).FULL_RESTRICTED="FULL_RESTRICTED"}(qS||(qS={})),function(e){e.MAKER_ECOSYSTEM="MAKER_ECOSYSTEM",e.TAKER_ECOSYSTEM="TAKER_ECOSYSTEM",e.PROTOCOL="PROTOCOL",e.ROYALTY="ROYALTY"}(GS||(GS={})),function(e){e.APPROVAL="APPROVAL",e.FULFILL_ORDER="FULFILL_ORDER"}(WS||(WS={})),function(e){e.CREATE_LISTING="CREATE_LISTING"}($S||($S={})),function(e){e.TRANSACTION="TRANSACTION",e.SIGNABLE="SIGNABLE"}(KS||(KS={}));const JS="1.5",QS={OrderComponents:[{name:"offerer",type:"address"},{name:"zone",type:"address"},{name:"offer",type:"OfferItem[]"},{name:"consideration",type:"ConsiderationItem[]"},{name:"orderType",type:"uint8"},{name:"startTime",type:"uint256"},{name:"endTime",type:"uint256"},{name:"zoneHash",type:"bytes32"},{name:"salt",type:"uint256"},{name:"conduitKey",type:"bytes32"},{name:"counter",type:"uint256"}],OfferItem:[{name:"itemType",type:"uint8"},{name:"token",type:"address"},{name:"identifierOrCriteria",type:"uint256"},{name:"startAmount",type:"uint256"},{name:"endAmount",type:"uint256"}],ConsiderationItem:[{name:"itemType",type:"uint8"},{name:"token",type:"address"},{name:"identifierOrCriteria",type:"uint256"},{name:"startAmount",type:"uint256"},{name:"endAmount",type:"uint256"},{name:"recipient",type:"address"}]};var eI,tI,nI,rI;function iI(e){return async()=>{const t=await e.buildTransaction();return t.gasLimit=await e.estimateGas(),t.gasLimit=t.gasLimit.add(t.gasLimit.div(5)),t}}!function(e){e[e.FULL_OPEN=0]="FULL_OPEN",e[e.PARTIAL_OPEN=1]="PARTIAL_OPEN",e[e.FULL_RESTRICTED=2]="FULL_RESTRICTED",e[e.PARTIAL_RESTRICTED=3]="PARTIAL_RESTRICTED"}(eI||(eI={})),function(e){e[e.NATIVE=0]="NATIVE",e[e.ERC20=1]="ERC20",e[e.ERC721=2]="ERC721",e[e.ERC1155=3]="ERC1155",e[e.ERC721_WITH_CRITERIA=4]="ERC721_WITH_CRITERIA",e[e.ERC1155_WITH_CRITERIA=5]="ERC1155_WITH_CRITERIA"}(tI||(tI={})),function(e){e[e.OFFER=0]="OFFER",e[e.CONSIDERATION=1]="CONSIDERATION"}(nI||(nI={})),function(e){e[e.ETH_TO_ERC721=0]="ETH_TO_ERC721",e[e.ETH_TO_ERC1155=1]="ETH_TO_ERC1155",e[e.ERC20_TO_ERC721=2]="ERC20_TO_ERC721",e[e.ERC20_TO_ERC1155=3]="ERC20_TO_ERC1155",e[e.ERC721_TO_ERC20=4]="ERC721_TO_ERC20",e[e.ERC1155_TO_ERC20=5]="ERC1155_TO_ERC20"}(rI||(rI={}));class aI{seaportLibFactory;provider;seaportContractAddress;zoneContractAddress;constructor(e,t,n,r){this.seaportLibFactory=e,this.provider=t,this.seaportContractAddress=n,this.zoneContractAddress=r}async prepareSeaportOrder(e,t,n,r,i){const{actions:a}=await this.createSeaportOrder(e,t,n,r,i),o=[],s=a.find((e=>"approval"===e.type));s&&o.push({type:KS.TRANSACTION,purpose:WS.APPROVAL,buildTransaction:iI(s.transactionMethods)});const u=a.find((e=>"create"===e.type));if(!u)throw new Error("No create order action found");const l=function(e){const t=JSON.parse(e).message;return t.salt=Y.from(t.salt).toHexString(),t}(await u.getMessageToSign());return o.push({type:KS.SIGNABLE,purpose:$S.CREATE_LISTING,message:await this.getTypedDataFromOrderComponents(l)}),{actions:o,orderComponents:l,orderHash:this.getSeaportLib().getOrderHash(l)}}async fulfillOrder(e,t,n){const{orderComponents:r,tips:i}=this.mapImmutableOrderToSeaportOrderComponents(e),a=this.getSeaportLib(e),{actions:o}=await a.fulfillOrders({accountAddress:t,fulfillOrderDetails:[{order:{parameters:r,signature:e.signature},extraData:n,tips:i}]}),s=[],u=o.find((e=>"approval"===e.type));u&&s.push({type:KS.TRANSACTION,buildTransaction:iI(u.transactionMethods),purpose:WS.APPROVAL});const l=o.find((e=>"exchange"===e.type));if(!l)throw new Error("No exchange action found");return s.push({type:KS.TRANSACTION,buildTransaction:iI(l.transactionMethods),purpose:WS.FULFILL_ORDER}),{actions:s,expiration:aI.getExpirationISOTimeFromExtraData(n),order:XS(e)}}async fulfillBulkOrders(e,t){const n=e.map((e=>{const{orderComponents:t,tips:n}=this.mapImmutableOrderToSeaportOrderComponents(e.order);return{order:{parameters:t,signature:e.order.signature},extraData:e.extra_data,tips:n}})),{actions:r}=await this.getSeaportLib().fulfillOrders({fulfillOrderDetails:n,accountAddress:t}),i=[],a=r.find((e=>"approval"===e.type));a&&i.push({type:KS.TRANSACTION,buildTransaction:iI(a.transactionMethods),purpose:WS.APPROVAL});const o=r.find((e=>"exchange"===e.type));if(!o)throw new Error("No exchange action found");return i.push({type:KS.TRANSACTION,buildTransaction:iI(o.transactionMethods),purpose:WS.FULFILL_ORDER}),{actions:i,expiration:n.map((e=>aI.getExpirationISOTimeFromExtraData(e.extraData))).reduce(((e,t)=>new Date(e)<new Date(t)?e:t))}}async cancelOrder(e,t){const{orderComponents:n}=this.mapImmutableOrderToSeaportOrderComponents(e),r=this.getSeaportLib(e);return iI(await r.cancelOrders([n],t))()}mapImmutableOrderToSeaportOrderComponents(e){return function(e,t,n){const r=e.buy.map((t=>{switch(t.item_type){case"NATIVE":return{startAmount:t.start_amount,endAmount:t.start_amount,itemType:tI.NATIVE,recipient:e.account_address,token:Dt,identifierOrCriteria:"0"};case"ERC20":return{startAmount:t.start_amount,endAmount:t.start_amount,itemType:tI.ERC20,recipient:e.account_address,token:t.contract_address||Dt,identifierOrCriteria:"0"};default:return{startAmount:"1",endAmount:"1",itemType:tI.ERC721,recipient:e.account_address,token:t.contract_address||Dt,identifierOrCriteria:"0"}}})),i=e.fees.map((t=>({amount:t.amount,itemType:"ERC20"===e.buy[0].item_type?tI.ERC20:tI.NATIVE,recipient:t.recipient,token:"ERC20"===e.buy[0].item_type?e.buy[0].contract_address:Dt,identifierOrCriteria:"0"})));return{orderComponents:{conduitKey:Wt,consideration:[...r],offer:e.sell.map((e=>{const t=e;return{startAmount:"1",endAmount:"1",itemType:tI.ERC721,token:t.contract_address,identifierOrCriteria:t.token_id}})),counter:t,endTime:Math.round(new Date(e.end_at).getTime()/1e3).toString(),startTime:Math.round(new Date(e.start_at).getTime()/1e3).toString(),salt:e.salt,offerer:e.account_address,zone:n,totalOriginalConsiderationItems:r.length,orderType:eI.FULL_RESTRICTED,zoneHash:Wt},tips:i}}(e,e.protocol_data.counter,this.zoneContractAddress)}createSeaportOrder(e,t,n,r,i){return this.getSeaportLib().createOrder({allowPartialFills:!1,offer:[{itemType:tI.ERC721,token:t.contractAddress,identifier:t.tokenId}],consideration:[{token:"ERC20"===n.type?n.contractAddress:void 0,amount:n.amount,recipient:e}],startTime:(r.getTime()/1e3).toFixed(0),endTime:(i.getTime()/1e3).toFixed(0),zone:this.zoneContractAddress,restrictedByZone:!0},e)}async getTypedDataFromOrderComponents(e){const{chainId:t}=await this.provider.getNetwork();return{domain:{name:"ImmutableSeaport",version:JS,chainId:t,verifyingContract:this.seaportContractAddress},types:QS,value:e}}getSeaportLib(e){const t=e?.protocol_data?.seaport_address??this.seaportContractAddress,n=JS;return this.seaportLibFactory.create(n,t)}static getExpirationISOTimeFromExtraData(e){const t=e.slice(44,60),n=parseInt(t,16);return new Date(1e3*n).toISOString()}}class oI{orderbookService;chainName;seaportAddress;constructor(e,t,n){this.orderbookService=e,this.chainName=t,this.seaportAddress=n}async fulfillmentData(e){return this.orderbookService.fulfillmentData({chainName:this.chainName,requestBody:e})}async getListing(e){return this.orderbookService.getListing({chainName:this.chainName,listingId:e})}async getTrade(e){return this.orderbookService.getTrade({chainName:this.chainName,tradeId:e})}async listListings(e){return this.orderbookService.listListings({chainName:this.chainName,...e})}async listTrades(e){return this.orderbookService.listTrades({chainName:this.chainName,...e})}async createListing({orderHash:e,orderComponents:t,orderSignature:n,makerFees:r}){if(1!==t.offer.length)throw new Error("Only one item can be listed at a time");if(Number(t.offer[0].itemType)!==tI.ERC721)throw new Error("Only ERC721 tokens can be listed");const i=[...t.consideration.map((e=>e.itemType))];if(!(1===new Set(i).size))throw new Error("All consideration items must be of the same type");return this.orderbookService.createListing({chainName:this.chainName,requestBody:{order_hash:e,account_address:t.offerer,buy:[{item_type:Number(t.consideration[0].itemType)===tI.NATIVE?"NATIVE":"ERC20",start_amount:t.consideration[0].startAmount,contract_address:t.consideration[0].token}],fees:r.map((e=>({amount:e.amount,fee_type:GS.MAKER_ECOSYSTEM,recipient:e.recipient}))),end_at:new Date(parseInt(`${t.endTime.toString()}000`,10)).toISOString(),protocol_data:{order_type:qS.order_type.FULL_RESTRICTED,zone_address:t.zone,seaport_address:this.seaportAddress,seaport_version:JS,counter:t.counter.toString()},salt:t.salt,sell:[{contract_address:t.offer[0].token,token_id:t.offer[0].identifierOrCriteria,item_type:"ERC721"}],signature:n,start_at:new Date(parseInt(`${t.startTime.toString()}000`,10)).toISOString()}})}}class sI{chainName;seaportAddress;orderbookClient;constructor(e,t,n){this.chainName=t,this.seaportAddress=n,this.orderbookClient=new jS({BASE:e})}create(){return new oI(this.orderbookClient.orders,this.chainName,this.seaportAddress)}}class uI{defaultSeaportContractAddress;provider;constructor(e,t){this.defaultSeaportContractAddress=e,this.provider=t}create(e,t){const n=e??JS,r=t??this.defaultSeaportContractAddress;return new ZA.Seaport(this.provider,{seaportVersion:n,balanceAndApprovalChecksOnOrderCreation:!0,overrides:{contractAddress:r}})}}class lI{apiClient;seaport;orderbookConfig;constructor(e){const t={...function(e){switch(e){case i.SANDBOX:return{seaportContractAddress:"0x7Fb7Da6De152597830eD16361633e362A2F59410",zoneContractAddress:"0x63441cBfBd15Dd8f5E92598E535661Ac5aCB808E",apiEndpoint:"https://api.sandbox.immutable.com",chainName:"imtbl-zkevm-testnet",provider:new ac("https://rpc.testnet.immutable.com")};case i.PRODUCTION:return{seaportContractAddress:"",zoneContractAddress:"",apiEndpoint:"https://api.immutable.com",chainName:"imtbl-zkevm-mainnet",provider:new ac("https://rpc.immutable.com")};default:return null}}(e.baseConfig.environment),...e.overrides};if(!t)throw new Error("Orderbook configuration not passed, please specify the environment under config.baseConfig.environment");this.orderbookConfig=t;const{apiEndpoint:n,chainName:r}=this.orderbookConfig;if(!n)throw new Error("API endpoint must be provided");this.apiClient=new sI(n,r,this.orderbookConfig.seaportContractAddress).create();const a=new uI(this.orderbookConfig.seaportContractAddress,this.orderbookConfig.provider);this.seaport=new aI(a,this.orderbookConfig.provider,this.orderbookConfig.seaportContractAddress,this.orderbookConfig.zoneContractAddress)}config(){return this.orderbookConfig}async getListing(e){return{result:XS((await this.apiClient.getListing(e)).result)}}async getTrade(e){return{result:ZS((await this.apiClient.getTrade(e)).result)}}async listListings(e){const t=await this.apiClient.listListings(e);return{page:YS(t.page),result:t.result.map(XS)}}async listTrades(e){const t=await this.apiClient.listTrades(e);return{page:YS(t.page),result:t.result.map(ZS)}}async prepareListing({makerAddress:e,sell:t,buy:n,orderExpiry:r}){return this.seaport.prepareSeaportOrder(e,t,n,new Date,r||new Date(Date.now()+63072e6))}async createListing(e){return{result:XS((await this.apiClient.createListing({...e})).result)}}async fulfillOrder(e,t,n){const r=await this.apiClient.fulfillmentData([{order_id:e,fees:n.map((e=>({amount:e.amount,fee_type:GS.TAKER_ECOSYSTEM,recipient:e.recipient})))}]);if(r.result.unfulfillable_orders?.length>0)throw new Error(`Unable to prepare fulfillment date: ${r.result.unfulfillable_orders[0].reason}`);if(1!==r.result.fulfillable_orders?.length)throw new Error("unexpected fulfillable order result length");const i=r.result.fulfillable_orders[0].extra_data,a=r.result.fulfillable_orders[0].order;if(a.status.name!==HS.ACTIVE)throw new Error(`Cannot fulfil order that is not active. Current status: ${a.status}`);return this.seaport.fulfillOrder(a,t,i)}async fulfillBulkOrders(e,t){const n=await this.apiClient.fulfillmentData(e.map((e=>({order_id:e.listingId,fees:e.takerFees.map((e=>({amount:e.amount,fee_type:GS.TAKER_ECOSYSTEM,recipient:e.recipient})))}))));try{return{...await this.seaport.fulfillBulkOrders(n.result.fulfillable_orders,t),fulfillableOrders:n.result.fulfillable_orders.map((e=>XS(e.order))),unfulfillableOrders:n.result.unfulfillable_orders.map((e=>({orderId:e.order_id,reason:e.reason}))),sufficientBalance:!0}}catch(e){if(String(e).includes("The fulfiller does not have the balances needed to fulfill."))return{fulfillableOrders:n.result.fulfillable_orders.map((e=>XS(e.order))),unfulfillableOrders:n.result.unfulfillable_orders.map((e=>({orderId:e.order_id,reason:e.reason}))),sufficientBalance:!1};throw e}}async cancelOrder(e,t){const n=await this.apiClient.getListing(e);if(n.result.status.name!==HS.ACTIVE&&n.result.status.name!==HS.INACTIVE&&n.result.status.name!==HS.PENDING)throw new Error(`Cannot cancel order with status ${n.result.status}`);if(n.result.account_address!==t.toLowerCase())throw new Error(`Only account ${n.result.account_address} can cancel order ${e}`);return{unsignedCancelOrderTransaction:await this.seaport.cancelOrder(n.result,t)}}}const cI=4e5,dI="https://api.sandbox.immutable.com".replace(/\/+$/,"");class fI{basePath;axios;configuration;constructor(e,t=dI,n=hp){this.basePath=t,this.axios=n,e&&(this.configuration=e,this.basePath=e.basePath||this.basePath)}}class pI extends Error{field;constructor(e,t){super(t),this.field=e,this.name="RequiredError"}}const hI="https://example.com",mI=function(e,t,n){if(null==n)throw new pI(t,`Required parameter ${t} was null or undefined when calling ${e}.`)},yI=async function(e,t,n){if(n&&n.apiKey){const r="function"==typeof n.apiKey?await n.apiKey(t):await n.apiKey;e[t]=r}},gI=async function(e,t){if(t&&t.accessToken){const n="function"==typeof t.accessToken?await t.accessToken():await t.accessToken;e.Authorization="Bearer "+n}};function bI(e,t,n=""){null!=t&&("object"==typeof t?Array.isArray(t)?t.forEach((t=>bI(e,t,n))):Object.keys(t).forEach((r=>bI(e,t[r],`${n}${""!==n?".":""}${r}`))):e.has(n)?e.append(n,t):e.set(n,t))}const vI=function(e,...t){const n=new URLSearchParams(e.search);bI(n,t),e.search=n.toString()},wI=function(e,t,n){const r="string"!=typeof e;return(r&&n&&n.isJsonMime?n.isJsonMime(t.headers["Content-Type"]):r)?JSON.stringify(void 0!==e?e:{}):e||""},EI=function(e){return e.pathname+e.search+e.hash},TI=function(e,t,n,r){return(i=t,a=n)=>{const o={...e.options,url:(r?.basePath||i.defaults.baseURL||a)+e.url};return i.request(o)}},AI=function(e){return{getActivity:async(t,n,r={})=>{mI("getActivity","chainName",t),mI("getActivity","activityId",n);const i="/v1/chains/{chain_name}/activities/{activity_id}".replace("{chain_name}",encodeURIComponent(String(t))).replace("{activity_id}",encodeURIComponent(String(n))),a=new URL(i,hI);let o;e&&(o=e.baseOptions);const s={method:"GET",...o,...r};vI(a,{});let u=o&&o.headers?o.headers:{};return s.headers={...u,...r.headers},{url:EI(a),options:s}},listActivities:async(t,n,r,i,a,o,s,u,l,c,d={})=>{mI("listActivities","chainName",t);const f="/v1/chains/{chain_name}/activities".replace("{chain_name}",encodeURIComponent(String(t))),p=new URL(f,hI);let h;e&&(h=e.baseOptions);const m={method:"GET",...h,...d},y={};void 0!==n&&(y.contract_address=n),void 0!==r&&(y.token_id=r),void 0!==i&&(y.account_address=i),void 0!==a&&(y.activity_type=a),void 0!==o&&(y.from_indexed_at=o instanceof Date?o.toISOString():o),void 0!==s&&(y.to_indexed_at=s instanceof Date?s.toISOString():s),void 0!==u&&(y.transaction_hash=u),void 0!==l&&(y.page_cursor=l),void 0!==c&&(y.page_size=c),vI(p,y);let g=h&&h.headers?h.headers:{};return m.headers={...g,...d.headers},{url:EI(p),options:m}}}},_I=function(e){const t=AI(e);return{async getActivity(n,r,i){const a=await t.getActivity(n,r,i);return TI(a,hp,dI,e)},async listActivities(n,r,i,a,o,s,u,l,c,d,f){const p=await t.listActivities(n,r,i,a,o,s,u,l,c,d,f);return TI(p,hp,dI,e)}}};const xI=function(e){return{listChains:async(t,n,r={})=>{const i=new URL("/v1/chains",hI);let a;e&&(a=e.baseOptions);const o={method:"GET",...a,...r},s={};void 0!==t&&(s.page_cursor=t),void 0!==n&&(s.page_size=n),vI(i,s);let u=a&&a.headers?a.headers:{};return o.headers={...u,...r.headers},{url:EI(i),options:o}}}},CI=function(e){const t=xI(e);return{async listChains(n,r,i){const a=await t.listChains(n,r,i);return TI(a,hp,dI,e)}}};const kI=function(e){return{getCollection:async(t,n,r={})=>{mI("getCollection","contractAddress",t),mI("getCollection","chainName",n);const i="/v1/chains/{chain_name}/collections/{contract_address}".replace("{contract_address}",encodeURIComponent(String(t))).replace("{chain_name}",encodeURIComponent(String(n))),a=new URL(i,hI);let o;e&&(o=e.baseOptions);const s={method:"GET",...o,...r};vI(a,{});let u=o&&o.headers?o.headers:{};return s.headers={...u,...r.headers},{url:EI(a),options:s}},listCollections:async(t,n,r,i,a,o={})=>{mI("listCollections","chainName",t);const s="/v1/chains/{chain_name}/collections".replace("{chain_name}",encodeURIComponent(String(t))),u=new URL(s,hI);let l;e&&(l=e.baseOptions);const c={method:"GET",...l,...o},d={};n&&(d.contract_address=n),void 0!==r&&(d.from_updated_at=r instanceof Date?r.toISOString():r),void 0!==i&&(d.page_cursor=i),void 0!==a&&(d.page_size=a),vI(u,d);let f=l&&l.headers?l.headers:{};return c.headers={...f,...o.headers},{url:EI(u),options:c}},listCollectionsByNFTOwner:async(t,n,r,i,a={})=>{mI("listCollectionsByNFTOwner","accountAddress",t),mI("listCollectionsByNFTOwner","chainName",n);const o="/v1/chains/{chain_name}/accounts/{account_address}/collections".replace("{account_address}",encodeURIComponent(String(t))).replace("{chain_name}",encodeURIComponent(String(n))),s=new URL(o,hI);let u;e&&(u=e.baseOptions);const l={method:"GET",...u,...a},c={};void 0!==r&&(c.page_cursor=r),void 0!==i&&(c.page_size=i),vI(s,c);let d=u&&u.headers?u.headers:{};return l.headers={...d,...a.headers},{url:EI(s),options:l}},refreshCollectionMetadata:async(t,n,r,i={})=>{mI("refreshCollectionMetadata","contractAddress",t),mI("refreshCollectionMetadata","chainName",n),mI("refreshCollectionMetadata","refreshCollectionMetadataRequest",r);const a="/v1/chains/{chain_name}/collections/{contract_address}/refresh-metadata".replace("{contract_address}",encodeURIComponent(String(t))).replace("{chain_name}",encodeURIComponent(String(n))),o=new URL(a,hI);let s;e&&(s=e.baseOptions);const u={method:"POST",...s,...i},l={};await yI(l,"x-immutable-api-Key",e),l["Content-Type"]="application/json",vI(o,{});let c=s&&s.headers?s.headers:{};return u.headers={...l,...c,...i.headers},u.data=wI(r,u,e),{url:EI(o),options:u}}}},SI=function(e){const t=kI(e);return{async getCollection(n,r,i){const a=await t.getCollection(n,r,i);return TI(a,hp,dI,e)},async listCollections(n,r,i,a,o,s){const u=await t.listCollections(n,r,i,a,o,s);return TI(u,hp,dI,e)},async listCollectionsByNFTOwner(n,r,i,a,o){const s=await t.listCollectionsByNFTOwner(n,r,i,a,o);return TI(s,hp,dI,e)},async refreshCollectionMetadata(n,r,i,a){const o=await t.refreshCollectionMetadata(n,r,i,a);return TI(o,hp,dI,e)}}};const II=function(e){return{getMetadata:async(t,n,r,i={})=>{mI("getMetadata","chainName",t),mI("getMetadata","contractAddress",n),mI("getMetadata","metadataId",r);const a="/v1/chains/{chain_name}/collections/{contract_address}/metadata/{metadata_id}".replace("{chain_name}",encodeURIComponent(String(t))).replace("{contract_address}",encodeURIComponent(String(n))).replace("{metadata_id}",encodeURIComponent(String(r))),o=new URL(a,hI);let s;e&&(s=e.baseOptions);const u={method:"GET",...s,...i};vI(o,{});let l=s&&s.headers?s.headers:{};return u.headers={...l,...i.headers},{url:EI(o),options:u}},listMetadata:async(t,n,r,i,a,o={})=>{mI("listMetadata","chainName",t),mI("listMetadata","contractAddress",n);const s="/v1/chains/{chain_name}/collections/{contract_address}/metadata".replace("{chain_name}",encodeURIComponent(String(t))).replace("{contract_address}",encodeURIComponent(String(n))),u=new URL(s,hI);let l;e&&(l=e.baseOptions);const c={method:"GET",...l,...o},d={};void 0!==r&&(d.from_updated_at=r instanceof Date?r.toISOString():r),void 0!==i&&(d.page_cursor=i),void 0!==a&&(d.page_size=a),vI(u,d);let f=l&&l.headers?l.headers:{};return c.headers={...f,...o.headers},{url:EI(u),options:c}},refreshMetadataByID:async(t,n,r,i={})=>{mI("refreshMetadataByID","chainName",t),mI("refreshMetadataByID","contractAddress",n),mI("refreshMetadataByID","refreshMetadataByIDRequest",r);const a="/v1/chains/{chain_name}/collections/{contract_address}/metadata/refresh-metadata".replace("{chain_name}",encodeURIComponent(String(t))).replace("{contract_address}",encodeURIComponent(String(n))),o=new URL(a,hI);let s;e&&(s=e.baseOptions);const u={method:"POST",...s,...i},l={};await yI(l,"x-immutable-api-Key",e),l["Content-Type"]="application/json",vI(o,{});let c=s&&s.headers?s.headers:{};return u.headers={...l,...c,...i.headers},u.data=wI(r,u,e),{url:EI(o),options:u}},refreshNFTMetadataByTokenID:async(t,n,r,i={})=>{mI("refreshNFTMetadataByTokenID","contractAddress",t),mI("refreshNFTMetadataByTokenID","chainName",n),mI("refreshNFTMetadataByTokenID","refreshNFTMetadataByTokenIDRequest",r);const a="/v1/chains/{chain_name}/collections/{contract_address}/nfts/refresh-metadata".replace("{contract_address}",encodeURIComponent(String(t))).replace("{chain_name}",encodeURIComponent(String(n))),o=new URL(a,hI);let s;e&&(s=e.baseOptions);const u={method:"POST",...s,...i},l={};await yI(l,"x-immutable-api-Key",e),l["Content-Type"]="application/json",vI(o,{});let c=s&&s.headers?s.headers:{};return u.headers={...l,...c,...i.headers},u.data=wI(r,u,e),{url:EI(o),options:u}}}},RI=function(e){const t=II(e);return{async getMetadata(n,r,i,a){const o=await t.getMetadata(n,r,i,a);return TI(o,hp,dI,e)},async listMetadata(n,r,i,a,o,s){const u=await t.listMetadata(n,r,i,a,o,s);return TI(u,hp,dI,e)},async refreshMetadataByID(n,r,i,a){const o=await t.refreshMetadataByID(n,r,i,a);return TI(o,hp,dI,e)},async refreshNFTMetadataByTokenID(n,r,i,a){const o=await t.refreshNFTMetadataByTokenID(n,r,i,a);return TI(o,hp,dI,e)}}};const OI=function(e){return{listNFTOwners:async(t,n,r,i,a,o={})=>{mI("listNFTOwners","contractAddress",t),mI("listNFTOwners","tokenId",n),mI("listNFTOwners","chainName",r);const s="/v1/chains/{chain_name}/collections/{contract_address}/nfts/{token_id}/owners".replace("{contract_address}",encodeURIComponent(String(t))).replace("{token_id}",encodeURIComponent(String(n))).replace("{chain_name}",encodeURIComponent(String(r))),u=new URL(s,hI);let l;e&&(l=e.baseOptions);const c={method:"GET",...l,...o},d={};void 0!==i&&(d.page_cursor=i),void 0!==a&&(d.page_size=a),vI(u,d);let f=l&&l.headers?l.headers:{};return c.headers={...f,...o.headers},{url:EI(u),options:c}},listOwnersByContractAddress:async(t,n,r,i,a,o={})=>{mI("listOwnersByContractAddress","contractAddress",t),mI("listOwnersByContractAddress","chainName",n);const s="/v1/chains/{chain_name}/collections/{contract_address}/owners".replace("{contract_address}",encodeURIComponent(String(t))).replace("{chain_name}",encodeURIComponent(String(n))),u=new URL(s,hI);let l;e&&(l=e.baseOptions);const c={method:"GET",...l,...o},d={};void 0!==r&&(d.from_updated_at=r instanceof Date?r.toISOString():r),void 0!==i&&(d.page_cursor=i),void 0!==a&&(d.page_size=a),vI(u,d);let f=l&&l.headers?l.headers:{};return c.headers={...f,...o.headers},{url:EI(u),options:c}}}},PI=function(e){const t=OI(e);return{async listNFTOwners(n,r,i,a,o,s){const u=await t.listNFTOwners(n,r,i,a,o,s);return TI(u,hp,dI,e)},async listOwnersByContractAddress(n,r,i,a,o,s){const u=await t.listOwnersByContractAddress(n,r,i,a,o,s);return TI(u,hp,dI,e)}}};const NI=function(e){return{getNFT:async(t,n,r,i={})=>{mI("getNFT","contractAddress",t),mI("getNFT","tokenId",n),mI("getNFT","chainName",r);const a="/v1/chains/{chain_name}/collections/{contract_address}/nfts/{token_id}".replace("{contract_address}",encodeURIComponent(String(t))).replace("{token_id}",encodeURIComponent(String(n))).replace("{chain_name}",encodeURIComponent(String(r))),o=new URL(a,hI);let s;e&&(s=e.baseOptions);const u={method:"GET",...s,...i};vI(o,{});let l=s&&s.headers?s.headers:{};return u.headers={...l,...i.headers},{url:EI(o),options:u}},listAllNFTOwners:async(t,n,r,i,a={})=>{mI("listAllNFTOwners","chainName",t),mI("listAllNFTOwners","fromUpdatedAt",n);const o="/v1/chains/{chain_name}/nft-owners".replace("{chain_name}",encodeURIComponent(String(t))),s=new URL(o,hI);let u;e&&(u=e.baseOptions);const l={method:"GET",...u,...a},c={};void 0!==n&&(c.from_updated_at=n instanceof Date?n.toISOString():n),void 0!==r&&(c.page_cursor=r),void 0!==i&&(c.page_size=i),vI(s,c);let d=u&&u.headers?u.headers:{};return l.headers={...d,...a.headers},{url:EI(s),options:l}},listAllNFTs:async(t,n,r,i,a={})=>{mI("listAllNFTs","chainName",t);const o="/v1/chains/{chain_name}/nfts".replace("{chain_name}",encodeURIComponent(String(t))),s=new URL(o,hI);let u;e&&(u=e.baseOptions);const l={method:"GET",...u,...a},c={};void 0!==n&&(c.from_updated_at=n instanceof Date?n.toISOString():n),void 0!==r&&(c.page_cursor=r),void 0!==i&&(c.page_size=i),vI(s,c);let d=u&&u.headers?u.headers:{};return l.headers={...d,...a.headers},{url:EI(s),options:l}},listNFTs:async(t,n,r,i,a,o={})=>{mI("listNFTs","contractAddress",t),mI("listNFTs","chainName",n);const s="/v1/chains/{chain_name}/collections/{contract_address}/nfts".replace("{contract_address}",encodeURIComponent(String(t))).replace("{chain_name}",encodeURIComponent(String(n))),u=new URL(s,hI);let l;e&&(l=e.baseOptions);const c={method:"GET",...l,...o},d={};void 0!==r&&(d.from_updated_at=r instanceof Date?r.toISOString():r),void 0!==i&&(d.page_cursor=i),void 0!==a&&(d.page_size=a),vI(u,d);let f=l&&l.headers?l.headers:{};return c.headers={...f,...o.headers},{url:EI(u),options:c}},listNFTsByAccountAddress:async(t,n,r,i,a,o={})=>{mI("listNFTsByAccountAddress","accountAddress",t),mI("listNFTsByAccountAddress","chainName",n);const s="/v1/chains/{chain_name}/accounts/{account_address}/nfts".replace("{account_address}",encodeURIComponent(String(t))).replace("{chain_name}",encodeURIComponent(String(n))),u=new URL(s,hI);let l;e&&(l=e.baseOptions);const c={method:"GET",...l,...o},d={};void 0!==r&&(d.contract_address=r),void 0!==i&&(d.page_cursor=i),void 0!==a&&(d.page_size=a),vI(u,d);let f=l&&l.headers?l.headers:{};return c.headers={...f,...o.headers},{url:EI(u),options:c}}}},MI=function(e){const t=NI(e);return{async getNFT(n,r,i,a){const o=await t.getNFT(n,r,i,a);return TI(o,hp,dI,e)},async listAllNFTOwners(n,r,i,a,o){const s=await t.listAllNFTOwners(n,r,i,a,o);return TI(s,hp,dI,e)},async listAllNFTs(n,r,i,a,o){const s=await t.listAllNFTs(n,r,i,a,o);return TI(s,hp,dI,e)},async listNFTs(n,r,i,a,o,s){const u=await t.listNFTs(n,r,i,a,o,s);return TI(u,hp,dI,e)},async listNFTsByAccountAddress(n,r,i,a,o,s){const u=await t.listNFTsByAccountAddress(n,r,i,a,o,s);return TI(u,hp,dI,e)}}};const LI=function(e){return{cancelOrders:async(t,n,r={})=>{mI("cancelOrders","chainName",t),mI("cancelOrders","cancelOrdersRequestBody",n);const i="/v1/chains/{chain_name}/orders/cancel".replace("{chain_name}",encodeURIComponent(String(t))),a=new URL(i,hI);let o;e&&(o=e.baseOptions);const s={method:"POST",...o,...r},u={};u["Content-Type"]="application/json",vI(a,{});let l=o&&o.headers?o.headers:{};return s.headers={...u,...l,...r.headers},s.data=wI(n,s,e),{url:EI(a),options:s}},createListing:async(t,n,r={})=>{mI("createListing","chainName",t),mI("createListing","createListingRequestBody",n);const i="/v1/chains/{chain_name}/orders/listings".replace("{chain_name}",encodeURIComponent(String(t))),a=new URL(i,hI);let o;e&&(o=e.baseOptions);const s={method:"POST",...o,...r},u={};u["Content-Type"]="application/json",vI(a,{});let l=o&&o.headers?o.headers:{};return s.headers={...u,...l,...r.headers},s.data=wI(n,s,e),{url:EI(a),options:s}},fulfillmentData:async(t,n,r={})=>{mI("fulfillmentData","chainName",t),mI("fulfillmentData","fulfillmentDataRequest",n);const i="/v1/chains/{chain_name}/orders/fulfillment-data".replace("{chain_name}",encodeURIComponent(String(t))),a=new URL(i,hI);let o;e&&(o=e.baseOptions);const s={method:"POST",...o,...r},u={};u["Content-Type"]="application/json",vI(a,{});let l=o&&o.headers?o.headers:{};return s.headers={...u,...l,...r.headers},s.data=wI(n,s,e),{url:EI(a),options:s}},getListing:async(t,n,r={})=>{mI("getListing","chainName",t),mI("getListing","listingId",n);const i="/v1/chains/{chain_name}/orders/listings/{listing_id}".replace("{chain_name}",encodeURIComponent(String(t))).replace("{listing_id}",encodeURIComponent(String(n))),a=new URL(i,hI);let o;e&&(o=e.baseOptions);const s={method:"GET",...o,...r};vI(a,{});let u=o&&o.headers?o.headers:{};return s.headers={...u,...r.headers},{url:EI(a),options:s}},getTrade:async(t,n,r={})=>{mI("getTrade","chainName",t),mI("getTrade","tradeId",n);const i="/v1/chains/{chain_name}/trades/{trade_id}".replace("{chain_name}",encodeURIComponent(String(t))).replace("{trade_id}",encodeURIComponent(String(n))),a=new URL(i,hI);let o;e&&(o=e.baseOptions);const s={method:"GET",...o,...r};vI(a,{});let u=o&&o.headers?o.headers:{};return s.headers={...u,...r.headers},{url:EI(a),options:s}},listListings:async(t,n,r,i,a,o,s,u,l,c={})=>{mI("listListings","chainName",t);const d="/v1/chains/{chain_name}/orders/listings".replace("{chain_name}",encodeURIComponent(String(t))),f=new URL(d,hI);let p;e&&(p=e.baseOptions);const h={method:"GET",...p,...c},m={};void 0!==n&&(m.status=n),void 0!==r&&(m.sell_item_contract_address=r),void 0!==i&&(m.buy_item_contract_address=i),void 0!==a&&(m.sell_item_token_id=a),void 0!==o&&(m.page_size=o),void 0!==s&&(m.sort_by=s),void 0!==u&&(m.sort_direction=u),void 0!==l&&(m.page_cursor=l),vI(f,m);let y=p&&p.headers?p.headers:{};return h.headers={...y,...c.headers},{url:EI(f),options:h}},listTrades:async(t,n,r,i,a,o,s={})=>{mI("listTrades","chainName",t);const u="/v1/chains/{chain_name}/trades".replace("{chain_name}",encodeURIComponent(String(t))),l=new URL(u,hI);let c;e&&(c=e.baseOptions);const d={method:"GET",...c,...s},f={};void 0!==n&&(f.account_address=n),void 0!==r&&(f.page_size=r),void 0!==i&&(f.sort_by=i),void 0!==a&&(f.sort_direction=a),void 0!==o&&(f.page_cursor=o),vI(l,f);let p=c&&c.headers?c.headers:{};return d.headers={...p,...s.headers},{url:EI(l),options:d}}}},FI=function(e){const t=LI(e);return{async cancelOrders(n,r,i){const a=await t.cancelOrders(n,r,i);return TI(a,hp,dI,e)},async createListing(n,r,i){const a=await t.createListing(n,r,i);return TI(a,hp,dI,e)},async fulfillmentData(n,r,i){const a=await t.fulfillmentData(n,r,i);return TI(a,hp,dI,e)},async getListing(n,r,i){const a=await t.getListing(n,r,i);return TI(a,hp,dI,e)},async getTrade(n,r,i){const a=await t.getTrade(n,r,i);return TI(a,hp,dI,e)},async listListings(n,r,i,a,o,s,u,l,c,d){const f=await t.listListings(n,r,i,a,o,s,u,l,c,d);return TI(f,hp,dI,e)},async listTrades(n,r,i,a,o,s,u){const l=await t.listTrades(n,r,i,a,o,s,u);return TI(l,hp,dI,e)}}};const DI=function(e){return{createCounterfactualAddress:async(t,n={})=>{mI("createCounterfactualAddress","createCounterfactualAddressRequest",t);const r=new URL("/passport-mr/v1/counterfactual-address",hI);let i;e&&(i=e.baseOptions);const a={method:"POST",...i,...n},o={};await gI(o,e),o["Content-Type"]="application/json",vI(r,{});let s=i&&i.headers?i.headers:{};return a.headers={...o,...s,...n.headers},a.data=wI(t,a,e),{url:EI(r),options:a}},getLinkedAddresses:async(t,n={})=>{mI("getLinkedAddresses","userId",t);const r="/passport-mr/v1/users/{userId}/linked-addresses".replace("{userId}",encodeURIComponent(String(t))),i=new URL(r,hI);let a;e&&(a=e.baseOptions);const o={method:"GET",...a,...n},s={};await gI(s,e),vI(i,{});let u=a&&a.headers?a.headers:{};return o.headers={...s,...u,...n.headers},{url:EI(i),options:o}}}},BI=function(e){const t=DI(e);return{async createCounterfactualAddress(n,r){const i=await t.createCounterfactualAddress(n,r);return TI(i,hp,dI,e)},async getLinkedAddresses(n,r){const i=await t.getLinkedAddresses(n,r);return TI(i,hp,dI,e)}}};const jI=function(e){return{getERC20Token:async(t,n,r={})=>{mI("getERC20Token","contractAddress",t),mI("getERC20Token","chainName",n);const i="/v1/chains/{chain_name}/tokens/{contract_address}".replace("{contract_address}",encodeURIComponent(String(t))).replace("{chain_name}",encodeURIComponent(String(n))),a=new URL(i,hI);let o;e&&(o=e.baseOptions);const s={method:"GET",...o,...r};vI(a,{});let u=o&&o.headers?o.headers:{};return s.headers={...u,...r.headers},{url:EI(a),options:s}},listERC20Tokens:async(t,n,r,i,a={})=>{mI("listERC20Tokens","chainName",t);const o="/v1/chains/{chain_name}/tokens".replace("{chain_name}",encodeURIComponent(String(t))),s=new URL(o,hI);let u;e&&(u=e.baseOptions);const l={method:"GET",...u,...a},c={};void 0!==n&&(c.from_updated_at=n instanceof Date?n.toISOString():n),void 0!==r&&(c.page_cursor=r),void 0!==i&&(c.page_size=i),vI(s,c);let d=u&&u.headers?u.headers:{};return l.headers={...d,...a.headers},{url:EI(s),options:l}}}},UI=function(e){const t=jI(e);return{async getERC20Token(n,r,i){const a=await t.getERC20Token(n,r,i);return TI(a,hp,dI,e)},async listERC20Tokens(n,r,i,a,o){const s=await t.listERC20Tokens(n,r,i,a,o);return TI(s,hp,dI,e)}}};var zI=Object.freeze({__proto__:null,ActiveOrderStatusNameEnum:{Active:"ACTIVE"},ActivitiesApi:class extends fI{getActivity(e,t){return _I(this.configuration).getActivity(e.chainName,e.activityId,t).then((e=>e(this.axios,this.basePath)))}listActivities(e,t){return _I(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)))}},ActivitiesApiAxiosParamCreator:AI,ActivitiesApiFactory:function(e,t,n){const r=_I(e);return{getActivity:(e,i)=>r.getActivity(e.chainName,e.activityId,i).then((e=>e(n,t))),listActivities:(e,i)=>r.listActivities(e.chainName,e.contractAddress,e.tokenId,e.accountAddress,e.activityType,e.fromIndexedAt,e.toIndexedAt,e.transactionHash,e.pageCursor,e.pageSize,i).then((e=>e(n,t)))}},ActivitiesApiFp:_I,ActivityType:{Mint:"mint",Burn:"burn",Transfer:"transfer",Sale:"sale",Deposit:"deposit",Withdrawal:"withdrawal"},CancelledOrderStatusCancellationTypeEnum:{OnChain:"ON_CHAIN",OffChain:"OFF_CHAIN"},CancelledOrderStatusNameEnum:{Cancelled:"CANCELLED"},ChainsApi:class extends fI{listChains(e={},t){return CI(this.configuration).listChains(e.pageCursor,e.pageSize,t).then((e=>e(this.axios,this.basePath)))}},ChainsApiAxiosParamCreator:xI,ChainsApiFactory:function(e,t,n){const r=CI(e);return{listChains:(e={},i)=>r.listChains(e.pageCursor,e.pageSize,i).then((e=>e(n,t)))}},ChainsApiFp:CI,CollectionContractType:{Erc721:"ERC721"},CollectionsApi:class extends fI{getCollection(e,t){return SI(this.configuration).getCollection(e.contractAddress,e.chainName,t).then((e=>e(this.axios,this.basePath)))}listCollections(e,t){return SI(this.configuration).listCollections(e.chainName,e.contractAddress,e.fromUpdatedAt,e.pageCursor,e.pageSize,t).then((e=>e(this.axios,this.basePath)))}listCollectionsByNFTOwner(e,t){return SI(this.configuration).listCollectionsByNFTOwner(e.accountAddress,e.chainName,e.pageCursor,e.pageSize,t).then((e=>e(this.axios,this.basePath)))}refreshCollectionMetadata(e,t){return SI(this.configuration).refreshCollectionMetadata(e.contractAddress,e.chainName,e.refreshCollectionMetadataRequest,t).then((e=>e(this.axios,this.basePath)))}},CollectionsApiAxiosParamCreator:kI,CollectionsApiFactory:function(e,t,n){const r=SI(e);return{getCollection:(e,i)=>r.getCollection(e.contractAddress,e.chainName,i).then((e=>e(n,t))),listCollections:(e,i)=>r.listCollections(e.chainName,e.contractAddress,e.fromUpdatedAt,e.pageCursor,e.pageSize,i).then((e=>e(n,t))),listCollectionsByNFTOwner:(e,i)=>r.listCollectionsByNFTOwner(e.accountAddress,e.chainName,e.pageCursor,e.pageSize,i).then((e=>e(n,t))),refreshCollectionMetadata:(e,i)=>r.refreshCollectionMetadata(e.contractAddress,e.chainName,e.refreshCollectionMetadataRequest,i).then((e=>e(n,t)))}},CollectionsApiFp:SI,Configuration: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())}},ERC20ItemItemTypeEnum:{Erc20:"ERC20"},ERC721ItemItemTypeEnum:{Erc721:"ERC721"},ExpiredOrderStatusNameEnum:{Expired:"EXPIRED"},FailedOrderCancellationReasonCodeEnum:{AlreadyFilled:"ALREADY_FILLED"},FeeFeeTypeEnum:{Royalty:"ROYALTY",MakerEcosystem:"MAKER_ECOSYSTEM",TakerEcosystem:"TAKER_ECOSYSTEM",Protocol:"PROTOCOL"},FilledOrderStatusNameEnum:{Filled:"FILLED"},InactiveOrderStatusNameEnum:{Inactive:"INACTIVE"},ListListingsSortByEnum:{CreatedAt:"created_at",UpdatedAt:"updated_at",BuyItemAmount:"buy_item_amount"},ListListingsSortDirectionEnum:{Asc:"asc",Desc:"desc"},ListTradesSortByEnum:{IndexedAt:"indexed_at"},ListTradesSortDirectionEnum:{Asc:"asc",Desc:"desc"},MetadataApi:class extends fI{getMetadata(e,t){return RI(this.configuration).getMetadata(e.chainName,e.contractAddress,e.metadataId,t).then((e=>e(this.axios,this.basePath)))}listMetadata(e,t){return RI(this.configuration).listMetadata(e.chainName,e.contractAddress,e.fromUpdatedAt,e.pageCursor,e.pageSize,t).then((e=>e(this.axios,this.basePath)))}refreshMetadataByID(e,t){return RI(this.configuration).refreshMetadataByID(e.chainName,e.contractAddress,e.refreshMetadataByIDRequest,t).then((e=>e(this.axios,this.basePath)))}refreshNFTMetadataByTokenID(e,t){return RI(this.configuration).refreshNFTMetadataByTokenID(e.contractAddress,e.chainName,e.refreshNFTMetadataByTokenIDRequest,t).then((e=>e(this.axios,this.basePath)))}},MetadataApiAxiosParamCreator:II,MetadataApiFactory:function(e,t,n){const r=RI(e);return{getMetadata:(e,i)=>r.getMetadata(e.chainName,e.contractAddress,e.metadataId,i).then((e=>e(n,t))),listMetadata:(e,i)=>r.listMetadata(e.chainName,e.contractAddress,e.fromUpdatedAt,e.pageCursor,e.pageSize,i).then((e=>e(n,t))),refreshMetadataByID:(e,i)=>r.refreshMetadataByID(e.chainName,e.contractAddress,e.refreshMetadataByIDRequest,i).then((e=>e(n,t))),refreshNFTMetadataByTokenID:(e,i)=>r.refreshNFTMetadataByTokenID(e.contractAddress,e.chainName,e.refreshNFTMetadataByTokenIDRequest,i).then((e=>e(n,t)))}},MetadataApiFp:RI,NFTContractType:{Erc721:"ERC721"},NativeItemItemTypeEnum:{Native:"NATIVE"},NftOwnersApi:class extends fI{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)))}listOwnersByContractAddress(e,t){return PI(this.configuration).listOwnersByContractAddress(e.contractAddress,e.chainName,e.fromUpdatedAt,e.pageCursor,e.pageSize,t).then((e=>e(this.axios,this.basePath)))}},NftOwnersApiAxiosParamCreator:OI,NftOwnersApiFactory:function(e,t,n){const r=PI(e);return{listNFTOwners:(e,i)=>r.listNFTOwners(e.contractAddress,e.tokenId,e.chainName,e.pageCursor,e.pageSize,i).then((e=>e(n,t))),listOwnersByContractAddress:(e,i)=>r.listOwnersByContractAddress(e.contractAddress,e.chainName,e.fromUpdatedAt,e.pageCursor,e.pageSize,i).then((e=>e(n,t)))}},NftOwnersApiFp:PI,NftsApi:class extends fI{getNFT(e,t){return MI(this.configuration).getNFT(e.contractAddress,e.tokenId,e.chainName,t).then((e=>e(this.axios,this.basePath)))}listAllNFTOwners(e,t){return MI(this.configuration).listAllNFTOwners(e.chainName,e.fromUpdatedAt,e.pageCursor,e.pageSize,t).then((e=>e(this.axios,this.basePath)))}listAllNFTs(e,t){return MI(this.configuration).listAllNFTs(e.chainName,e.fromUpdatedAt,e.pageCursor,e.pageSize,t).then((e=>e(this.axios,this.basePath)))}listNFTs(e,t){return MI(this.configuration).listNFTs(e.contractAddress,e.chainName,e.fromUpdatedAt,e.pageCursor,e.pageSize,t).then((e=>e(this.axios,this.basePath)))}listNFTsByAccountAddress(e,t){return MI(this.configuration).listNFTsByAccountAddress(e.accountAddress,e.chainName,e.contractAddress,e.pageCursor,e.pageSize,t).then((e=>e(this.axios,this.basePath)))}},NftsApiAxiosParamCreator:NI,NftsApiFactory:function(e,t,n){const r=MI(e);return{getNFT:(e,i)=>r.getNFT(e.contractAddress,e.tokenId,e.chainName,i).then((e=>e(n,t))),listAllNFTOwners:(e,i)=>r.listAllNFTOwners(e.chainName,e.fromUpdatedAt,e.pageCursor,e.pageSize,i).then((e=>e(n,t))),listAllNFTs:(e,i)=>r.listAllNFTs(e.chainName,e.fromUpdatedAt,e.pageCursor,e.pageSize,i).then((e=>e(n,t))),listNFTs:(e,i)=>r.listNFTs(e.contractAddress,e.chainName,e.fromUpdatedAt,e.pageCursor,e.pageSize,i).then((e=>e(n,t))),listNFTsByAccountAddress:(e,i)=>r.listNFTsByAccountAddress(e.accountAddress,e.chainName,e.contractAddress,e.pageCursor,e.pageSize,i).then((e=>e(n,t)))}},NftsApiFp:MI,OrderStatusName:{Pending:"PENDING",Active:"ACTIVE",Inactive:"INACTIVE",Filled:"FILLED",Expired:"EXPIRED",Cancelled:"CANCELLED"},OrdersApi:class extends fI{cancelOrders(e,t){return FI(this.configuration).cancelOrders(e.chainName,e.cancelOrdersRequestBody,t).then((e=>e(this.axios,this.basePath)))}createListing(e,t){return FI(this.configuration).createListing(e.chainName,e.createListingRequestBody,t).then((e=>e(this.axios,this.basePath)))}fulfillmentData(e,t){return FI(this.configuration).fulfillmentData(e.chainName,e.fulfillmentDataRequest,t).then((e=>e(this.axios,this.basePath)))}getListing(e,t){return FI(this.configuration).getListing(e.chainName,e.listingId,t).then((e=>e(this.axios,this.basePath)))}getTrade(e,t){return FI(this.configuration).getTrade(e.chainName,e.tradeId,t).then((e=>e(this.axios,this.basePath)))}listListings(e,t){return FI(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)))}listTrades(e,t){return FI(this.configuration).listTrades(e.chainName,e.accountAddress,e.pageSize,e.sortBy,e.sortDirection,e.pageCursor,t).then((e=>e(this.axios,this.basePath)))}},OrdersApiAxiosParamCreator:LI,OrdersApiFactory:function(e,t,n){const r=FI(e);return{cancelOrders:(e,i)=>r.cancelOrders(e.chainName,e.cancelOrdersRequestBody,i).then((e=>e(n,t))),createListing:(e,i)=>r.createListing(e.chainName,e.createListingRequestBody,i).then((e=>e(n,t))),fulfillmentData:(e,i)=>r.fulfillmentData(e.chainName,e.fulfillmentDataRequest,i).then((e=>e(n,t))),getListing:(e,i)=>r.getListing(e.chainName,e.listingId,i).then((e=>e(n,t))),getTrade:(e,i)=>r.getTrade(e.chainName,e.tradeId,i).then((e=>e(n,t))),listListings:(e,i)=>r.listListings(e.chainName,e.status,e.sellItemContractAddress,e.buyItemContractAddress,e.sellItemTokenId,e.pageSize,e.sortBy,e.sortDirection,e.pageCursor,i).then((e=>e(n,t))),listTrades:(e,i)=>r.listTrades(e.chainName,e.accountAddress,e.pageSize,e.sortBy,e.sortDirection,e.pageCursor,i).then((e=>e(n,t)))}},OrdersApiFp:FI,PassportApi:class extends fI{createCounterfactualAddress(e,t){return BI(this.configuration).createCounterfactualAddress(e.createCounterfactualAddressRequest,t).then((e=>e(this.axios,this.basePath)))}getLinkedAddresses(e,t){return BI(this.configuration).getLinkedAddresses(e.userId,t).then((e=>e(this.axios,this.basePath)))}},PassportApiAxiosParamCreator:DI,PassportApiFactory:function(e,t,n){const r=BI(e);return{createCounterfactualAddress:(e,i)=>r.createCounterfactualAddress(e.createCounterfactualAddressRequest,i).then((e=>e(n,t))),getLinkedAddresses:(e,i)=>r.getLinkedAddresses(e.userId,i).then((e=>e(n,t)))}},PassportApiFp:BI,PendingOrderStatusNameEnum:{Pending:"PENDING"},ProtocolDataOrderTypeEnum:{FullRestricted:"FULL_RESTRICTED"},SaleFeeTypeEnum:{Royalty:"ROYALTY"},TokenContractType:{Erc20:"ERC20"},TokensApi:class extends fI{getERC20Token(e,t){return UI(this.configuration).getERC20Token(e.contractAddress,e.chainName,t).then((e=>e(this.axios,this.basePath)))}listERC20Tokens(e,t){return UI(this.configuration).listERC20Tokens(e.chainName,e.fromUpdatedAt,e.pageCursor,e.pageSize,t).then((e=>e(this.axios,this.basePath)))}},TokensApiAxiosParamCreator:jI,TokensApiFactory:function(e,t,n){const r=UI(e);return{getERC20Token:(e,i)=>r.getERC20Token(e.contractAddress,e.chainName,i).then((e=>e(n,t))),listERC20Tokens:(e,i)=>r.listERC20Tokens(e.chainName,e.fromUpdatedAt,e.pageCursor,e.pageSize,i).then((e=>e(n,t)))}},TokensApiFp:UI});class VI extends Error{code;details;link;traceId;constructor({message:e,code:t,details:n,link:r,trace_id:i}){super(e),this.code=t,this.details=n,this.link=r,this.traceId=i}}const HI={sdkVersion:"ts-immutable-sdk-multi-rollup-api-client-__SDK_VERSION__"},qI=({baseConfig:e,basePath:t,headers:n})=>{if(!t.trim())throw Error("basePath can not be empty");const r={...e,basePath:t,baseOptions:{headers:{...n||{},...HI}}};return new zI.Configuration(r)};class GI{apiConfig;baseConfig;constructor({baseConfig:e,overrides:t}){if(this.baseConfig=e,t)this.apiConfig=qI(t);else switch(e.environment){case i.SANDBOX:this.apiConfig=qI({basePath:"https://api.sandbox.immutable.com",baseConfig:e});break;case i.PRODUCTION:this.apiConfig=qI({basePath:"https://indexer-mr.imtbl.com",baseConfig:e});break;default:this.apiConfig=qI({basePath:"https://api.sandbox.immutable.com",baseConfig:e})}}}function WI(e){if(hp.isAxiosError(e)&&e.response){const t=e.response.data;return t.code&&t.message?new VI({code:t.code,message:t.message,details:t.details||null,link:t.link||"",trace_id:t.trace_id||""}):new VI({code:e.code??e.response?.status.toString()??"unknown_error_code",message:String(e),details:null,link:"",trace_id:""})}return new VI({code:"unknown_error_code",message:String(e),details:null,link:"",trace_id:""})}class $I{config;activities;chains;collections;nfts;nftOwners;tokens;metadata;constructor(e){this.config=new GI(e),this.activities=new zI.ActivitiesApi(this.config.apiConfig),this.chains=new zI.ChainsApi(this.config.apiConfig),this.collections=new zI.CollectionsApi(this.config.apiConfig),this.nfts=new zI.NftsApi(this.config.apiConfig),this.nftOwners=new zI.NftOwnersApi(this.config.apiConfig),this.tokens=new zI.TokensApi(this.config.apiConfig),this.metadata=new zI.MetadataApi(this.config.apiConfig)}async listActivities(e){return await this.activities.listActivities(e).then((e=>e.data)).catch((e=>{throw WI(e)}))}async getActivity(e){return await this.activities.getActivity(e).then((e=>e.data)).catch((e=>{throw WI(e)}))}async listChains(e){return await this.chains.listChains(e).then((e=>e.data)).catch((e=>{throw WI(e)}))}async listCollections(e){return await this.collections.listCollections(e).then((e=>e.data)).catch((e=>{throw WI(e)}))}async listCollectionsByNFTOwner(e){return await this.collections.listCollectionsByNFTOwner(e).then((e=>e.data)).catch((e=>{throw WI(e)}))}async getCollection(e){return await this.collections.getCollection(e).then((e=>e.data)).catch((e=>{throw WI(e)}))}async getNFT(e){return await this.nfts.getNFT(e).then((e=>e.data)).catch((e=>{throw WI(e)}))}async listNFTs(e){return await this.nfts.listNFTs(e).then((e=>e.data)).catch((e=>{throw WI(e)}))}async listNFTsByAccountAddress(e){return await this.nfts.listNFTsByAccountAddress(e).then((e=>e.data)).catch((e=>{throw WI(e)}))}async listAllNFTs(e){return await this.nfts.listAllNFTs(e).then((e=>e.data)).catch((e=>{throw WI(e)}))}async listNFTOwners(e){return await this.nftOwners.listNFTOwners(e).then((e=>e.data)).catch((e=>{throw WI(e)}))}async listNFTOwnersByContractAddress(e){return await this.nftOwners.listOwnersByContractAddress(e).then((e=>e.data)).catch((e=>{throw WI(e)}))}async listAllNFTOwners(e){return await this.nfts.listAllNFTOwners(e).then((e=>e.data)).catch((e=>{throw WI(e)}))}async listTokens(e){return await this.tokens.listERC20Tokens(e).then((e=>e.data)).catch((e=>{throw WI(e)}))}async getToken(e){return await this.tokens.getERC20Token(e).then((e=>e.data)).catch((e=>{throw WI(e)}))}async getMetadata(e){return await this.metadata.getMetadata(e).then((e=>e.data)).catch((e=>{throw WI(e)}))}async listNFTMetadataByContractAddress(e){return await this.metadata.listMetadata(e).then((e=>e.data)).catch((e=>{throw WI(e)}))}async refreshCollectionMetadata(e){return await this.collections.refreshCollectionMetadata(e).then((e=>e.data)).catch((e=>{throw WI(e)}))}async refreshNFTMetadata(e){return await this.metadata.refreshNFTMetadataByTokenID(e).then((e=>e.data)).catch((e=>{throw WI(e)}))}async refreshStackedMetadata(e){return await this.metadata.refreshMetadataByID(e).then((e=>e.data)).catch((e=>{throw WI(e)}))}}var KI,XI,ZI,YI,JI,QI,eR,tR,nR,rR,iR,aR,oR,sR,uR,lR,cR,dR,fR,pR;!function(e){e.IMTBL_CONNECT_WIDGET_EVENT="imtbl-connect-widget",e.IMTBL_WALLET_WIDGET_EVENT="imtbl-wallet-widget",e.IMTBL_SWAP_WIDGET_EVENT="imtbl-swap-widget",e.IMTBL_BRIDGE_WIDGET_EVENT="imtbl-bridge-widget",e.IMTBL_ONRAMP_WIDGET_EVENT="imtbl-onramp-widget",e.IMTBL_SALE_WIDGET_EVENT="imtbl-sale-widget"}(KI||(KI={})),function(e){e.CLOSE_WIDGET="close-widget",e.SUCCESS="success",e.FAILURE="failure"}(XI||(XI={})),function(e){e.CLOSE_WIDGET="close-widget",e.NETWORK_SWITCH="network-switch",e.DISCONNECT_WALLET="disconnect-wallet"}(ZI||(ZI={})),function(e){e.CLOSE_WIDGET="close-widget",e.SUCCESS="success",e.FAILURE="failure",e.REJECTED="rejected"}(YI||(YI={})),function(e){e.CLOSE_WIDGET="close-widget",e.SUCCESS="success",e.FAILURE="failure",e.REJECTED="rejected"}(JI||(JI={})),function(e){e.CLOSE_WIDGET="close-widget",e.SUCCESS="success",e.FAILURE="failure"}(QI||(QI={})),function(e){e.REQUEST_CONNECT="request-connect",e.REQUEST_WALLET="request-wallet",e.REQUEST_SWAP="request-swap",e.REQUEST_BRIDGE="request-bridge",e.REQUEST_ONRAMP="request-onramp"}(eR||(eR={})),function(e){e.CLOSE_WIDGET="close-widget",e.SUCCESS="success",e.FAILURE="failure"}(tR||(tR={})),function(e){e.LIGHT="light",e.DARK="dark"}(nR||(nR={})),function(e){e.CONNECT="connect",e.WALLET="wallet",e.SWAP="swap",e.BRIDGE="bridge",e.ONRAMP="onramp"}(rR||(rR={})),function(e){e.LAYER1="LAYER1",e.LAYER2="LAYER2"}(iR||(iR={})),function(e){e[e.IMTBL_ZKEVM_MAINNET=13371]="IMTBL_ZKEVM_MAINNET",e[e.IMTBL_ZKEVM_TESTNET=13472]="IMTBL_ZKEVM_TESTNET",e[e.IMTBL_ZKEVM_DEVNET=13433]="IMTBL_ZKEVM_DEVNET",e[e.ETHEREUM=1]="ETHEREUM",e[e.SEPOLIA=11155111]="SEPOLIA"}(aR||(aR={})),function(e){e.ETHEREUM="Ethereum",e.SEPOLIA="Sepolia",e.IMTBL_ZKEVM_TESTNET="Immutable zkEVM Test",e.IMTBL_ZKEVM_DEVNET="Immutable zkEVM Dev",e.IMTBL_ZKEVM_MAINNET="Immutable zkEVM"}(oR||(oR={})),function(e){e.TRANSAK="201811419111"}(sR||(sR={})),function(e){e.BRIDGE_TO_L2="BRIDGE_TO_L2",e.SWAP="SWAP"}(uR||(uR={})),function(e){e.ALL="all"}(lR||(lR={})),function(e){e.ALL="all",e.SWAP="swap",e.BRIDGE="bridge",e.ONRAMP="onramp"}(cR||(cR={})),function(e){e.CHECK_CONNECTION="eth_accounts",e.CONNECT="eth_requestAccounts",e.ADD_NETWORK="wallet_addEthereumChain",e.SWITCH_NETWORK="wallet_switchEthereumChain",e.GET_CHAINID="eth_chainId"}(dR||(dR={})),function(e){e.ALL="all"}(fR||(fR={})),function(e){e.PASSPORT="passport",e.METAMASK="metamask"}(pR||(pR={}));const hR={allowMistmatchedChainId:!1,allowUnsupportedProvider:!1},mR="development",yR="0x0000000000000000000000000000000000001010",gR=18,bR={name:"IMX",symbol:"IMX",decimals:gR,address:yR},vR={[mR]:"https://api.dev.immutable.com",[i.SANDBOX]:"https://api.sandbox.immutable.com",[i.PRODUCTION]:"https://api.immutable.com"},wR={[mR]:"https://checkout-api.dev.immutable.com",[i.SANDBOX]:"https://checkout-api.sandbox.immutable.com",[i.PRODUCTION]:"https://checkout-api.immutable.com"},ER={[i.SANDBOX]:"https://global-stg.transak.com",[i.PRODUCTION]:"https://global.transak.com/"},TR=new Map([[aR.ETHEREUM,{chainIdHex:`0x${aR.ETHEREUM.toString(16)}`,chainName:oR.ETHEREUM,rpcUrls:["https://checkout-api.immutable.com/v1/rpc/eth-mainnet"],nativeCurrency:{name:oR.ETHEREUM,symbol:"ETH",decimals:18},blockExplorerUrls:["https://etherscan.io/"]}],[aR.IMTBL_ZKEVM_MAINNET,{chainIdHex:`0x${aR.IMTBL_ZKEVM_MAINNET.toString(16)}`,chainName:oR.IMTBL_ZKEVM_MAINNET,rpcUrls:["https://rpc.immutable.com"],nativeCurrency:bR}]]),AR=new Map([[aR.SEPOLIA,{chainIdHex:`0x${aR.SEPOLIA.toString(16)}`,chainName:oR.SEPOLIA,rpcUrls:["https://checkout-api.sandbox.immutable.com/v1/rpc/eth-sepolia"],nativeCurrency:{name:"Sep Eth",symbol:"ETH",decimals:18},blockExplorerUrls:["https://sepolia.etherscan.io/"]}],[aR.IMTBL_ZKEVM_TESTNET,{chainIdHex:`0x${aR.IMTBL_ZKEVM_TESTNET.toString(16)}`,chainName:oR.IMTBL_ZKEVM_TESTNET,rpcUrls:["https://rpc.testnet.immutable.com"],nativeCurrency:bR}]]),_R=new Map([[aR.SEPOLIA,{chainIdHex:`0x${aR.SEPOLIA.toString(16)}`,chainName:oR.SEPOLIA,rpcUrls:["https://checkout-api.dev.immutable.com/v1/rpc/eth-sepolia"],nativeCurrency:{name:"Sep Eth",symbol:"ETH",decimals:18},blockExplorerUrls:["https://sepolia.etherscan.io/"]}],[aR.IMTBL_ZKEVM_DEVNET,{chainIdHex:`0x${aR.IMTBL_ZKEVM_DEVNET.toString(16)}`,chainName:oR.IMTBL_ZKEVM_DEVNET,rpcUrls:["https://rpc.dev.immutable.com"],nativeCurrency:bR}]]),xR={[aR.IMTBL_ZKEVM_TESTNET]:{url:"https://explorer.testnet.immutable.com",nativeToken:AR.get(aR.IMTBL_ZKEVM_TESTNET).nativeCurrency},[aR.IMTBL_ZKEVM_MAINNET]:{url:"https://explorer.mainnet.immutable.com",nativeToken:TR.get(aR.IMTBL_ZKEVM_MAINNET).nativeCurrency},[aR.SEPOLIA]:{url:"https://eth-sepolia.blockscout.com",nativeToken:AR.get(aR.SEPOLIA).nativeCurrency},[aR.ETHEREUM]:{url:"https://eth.blockscout.com/",nativeToken:TR.get(aR.ETHEREUM).nativeCurrency}},CR=[{constant:!0,inputs:[],name:"name",outputs:[{name:"",type:"string"}],payable:!1,type:"function"},{constant:!0,inputs:[],name:"decimals",outputs:[{name:"",type:"uint8"}],payable:!1,type:"function"},{constant:!0,inputs:[{name:"_owner",type:"address"}],name:"balanceOf",outputs:[{name:"balance",type:"uint256"}],payable:!1,type:"function"},{constant:!0,inputs:[],name:"symbol",outputs:[{name:"",type:"string"}],payable:!1,type:"function"},{constant:!0,inputs:[{name:"_owner",type:"address"},{name:"_spender",type:"address"}],name:"allowance",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"_spender",type:"address"},{name:"_value",type:"uint256"}],name:"approve",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"}],kR=[{constant:!1,inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"approve",outputs:[],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[{internalType:"address",name:"owner",type:"address"},{internalType:"address",name:"operator",type:"address"}],name:"isApprovedForAll",outputs:[{internalType:"bool",name:"",type:"bool"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"getApproved",outputs:[{internalType:"address",name:"",type:"address"}],payable:!1,stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"ownerOf",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"}];var SR,IR,RR,OR,PR,NR,MR,LR,FR;!function(e){e.SUCCESS="SUCCESS",e.FAILED="FAILED",e.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS"}(SR||(SR={})),function(e){e.NATIVE="NATIVE",e.ERC20="ERC20",e.ERC721="ERC721"}(IR||(IR={})),function(e){e.TRANSACTION="TRANSACTION",e.GAS="GAS"}(RR||(RR={})),function(e){e.NATIVE="NATIVE",e.ERC20="ERC20"}(OR||(OR={})),function(e){e.ROUTES_FOUND="ROUTES_FOUND",e.NO_ROUTES_FOUND="NO_ROUTES_FOUND",e.NO_ROUTE_OPTIONS="NO_ROUTE_OPTIONS"}(PR||(PR={})),function(e){e.BRIDGE="BRIDGE",e.SWAP="SWAP",e.ONRAMP="ONRAMP"}(NR||(NR={})),function(e){e.ONRAMP="onramp"}(MR||(MR={})),function(e){e.WEB3_PROVIDER_ERROR="WEB3_PROVIDER_ERROR",e.PROVIDER_ERROR="PROVIDER_ERROR",e.DEFAULT_PROVIDER_ERROR="DEFAULT_PROVIDER_ERROR",e.CONNECT_PROVIDER_ERROR="CONNECT_PROVIDER_ERROR",e.GET_BALANCE_ERROR="GET_BALANCE_ERROR",e.GET_INDEXER_BALANCE_ERROR="GET_INDEXER_BALANCE_ERROR",e.GET_ERC20_BALANCE_ERROR="GET_ERC20_BALANCE_ERROR",e.GET_ERC721_BALANCE_ERROR="GET_ERC721_BALANCE_ERROR",e.GET_NETWORK_INFO_ERROR="GET_NETWORK_INFO_ERROR",e.METAMASK_PROVIDER_ERROR="METAMASK_PROVIDER_ERROR",e.CHAIN_NOT_SUPPORTED_ERROR="CHAIN_NOT_SUPPORTED_ERROR",e.PROVIDER_REQUEST_MISSING_ERROR="PROVIDER_REQUEST_MISSING_ERROR",e.PROVIDER_REQUEST_FAILED_ERROR="PROVIDER_REQUEST_FAILED_ERROR",e.USER_REJECTED_REQUEST_ERROR="USER_REJECTED_REQUEST_ERROR",e.TRANSACTION_FAILED="TRANSACTION_FAILED",e.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",e.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",e.INVALID_GAS_ESTIMATE_TYPE="INVALID_GAS_ESTIMATE_TYPE",e.UNSUPPORTED_TOKEN_TYPE_ERROR="UNSUPPORTED_TOKEN_TYPE_ERROR",e.UNSUPPORTED_BALANCE_REQUIREMENT_ERROR="UNSUPPORTED_BALANCE_REQUIREMENT_ERROR",e.GET_ORDER_LISTING_ERROR="GET_ORDER_LISTING_ERROR",e.CANCEL_ORDER_LISTING_ERROR="CANCEL_ORDER_LISTING_ERROR",e.PREPARE_ORDER_LISTING_ERROR="PREPARE_ORDER_LISTING_ERROR",e.CREATE_ORDER_LISTING_ERROR="CREATE_ORDER_LISTING_ERROR",e.FULFILL_ORDER_LISTING_ERROR="FULFILL_ORDER_LISTING_ERROR",e.SWITCH_NETWORK_UNSUPPORTED="SWITCH_NETWORK_UNSUPPORTED",e.GET_ERC20_ALLOWANCE_ERROR="GET_ERC20_ALLOWANCE_ERROR",e.GET_ERC721_ALLOWANCE_ERROR="GET_ERC721_ALLOWANCE_ERROR",e.EXECUTE_APPROVAL_TRANSACTION_ERROR="EXECUTE_APPROVAL_TRANSACTION_ERROR",e.EXECUTE_FULFILLMENT_TRANSACTION_ERROR="EXECUTE_FULFILLMENT_TRANSACTION_ERROR",e.SIGN_MESSAGE_ERROR="SIGN_MESSAGE_ERROR",e.BRIDGE_GAS_ESTIMATE_ERROR="BRIDGE_GAS_ESTIMATE_ERROR",e.ORDER_FEE_ERROR="ORDER_FEE_ERROR",e.ITEM_REQUIREMENTS_ERROR="ITEM_REQUIREMENTS_ERROR",e.API_ERROR="API_ERROR"}(LR||(LR={}));class DR extends Error{message;type;data;constructor(e,t,n){super(e),this.message=e,this.type=t,this.data=n}}!function(e){e.REJECTED_SWITCH_AFTER_ADDING_NETWORK="REJECTED_SWITCH_AFTER_ADDING_NETWORK"}(FR||(FR={}));const BR=async(e,t)=>{try{return await e()}catch(e){const n=`${e.message}`||"UnknownError",r=t.message?`[${t.type}]:${t.message}. Cause:${n}`:`[${t.type}] Cause:${n}`;if(e instanceof DR)throw new DR(r,t.type,{...t.data,innerErrorType:e.type,...e.data});throw new DR(r,t.type,{...t.data})}};async function jR(e){if(!e.provider?.request)throw new DR("Parsed provider is not a valid Web3Provider",LR.WEB3_PROVIDER_ERROR);const t=await e.provider.request({method:dR.GET_CHAINID,params:[]});return parseInt(t,16)}async function UR(e,{type:t=lR.ALL,exclude:n}){const{networkMap:r}=e,i=(await e.remote.getConfig("allowedNetworks")).filter((e=>{const r=t===lR.ALL,i=!(n||[]).map((e=>e.chainId)).includes(e.chainId);return r&&i})),a=[];return i.forEach((e=>{const t=r.get(e.chainId);t&&a.push({name:t.chainName,chainId:parseInt(t.chainIdHex,16),nativeCurrency:t.nativeCurrency,isSupported:!0})})),{networks:a}}async function zR(e,t){const{networkMap:n}=e;return BR((async()=>{try{const e=await t.getNetwork();if(Array.from(n.keys()).includes(e.chainId)){const t=n.get(e.chainId);return{name:t.chainName,chainId:parseInt(t.chainIdHex,16),nativeCurrency:t.nativeCurrency,isSupported:!0}}return{chainId:e.chainId,name:e.name,isSupported:!1}}catch(e){const r=await jR(t);return{chainId:r,isSupported:Array.from(n.keys()).includes(r)}}}),{type:LR.GET_NETWORK_INFO_ERROR})}async function VR(e,t,n){const{networkMap:r}=e;if(!(await UR(e,{type:lR.ALL})).networks.some((e=>e.chainId===n)))throw new DR(`Chain:${n} is not a supported chain`,LR.CHAIN_NOT_SUPPORTED_ERROR);if(t.provider?.isPassport)throw new DR("Switching networks with Passport provider is not supported",LR.SWITCH_NETWORK_UNSUPPORTED);try{await async function(e,t,n){if(t.provider?.request)return await t.provider.request({method:dR.SWITCH_NETWORK,params:[{chainId:e.get(n)?.chainIdHex}]})}(r,t,n)}catch(e){if(4902!==e.code)throw new DR("User cancelled switch network request",LR.USER_REJECTED_REQUEST_ERROR);try{await async function(e,t,n){if(t.provider?.request){const r=e.get(n),i={chainId:r?.chainIdHex,chainName:r?.chainName,rpcUrls:r?.rpcUrls,nativeCurrency:r?.nativeCurrency,blockExplorerUrls:r?.blockExplorerUrls};return await t.provider.request({method:dR.ADD_NETWORK,params:[i]})}}(r,t,n)}catch(e){throw new DR("User cancelled add network request",LR.USER_REJECTED_REQUEST_ERROR)}}const i=new sd(t.provider);if((await i.getNetwork()).chainId!==n)throw new DR("User cancelled switch network request",LR.USER_REJECTED_REQUEST_ERROR);return{network:await zR(e,i),provider:i}}class HR{isDevelopment;isProduction;configCache;tokensCache;constructor(e){this.isDevelopment=e.isDevelopment,this.isProduction=e.isProduction}static async makeHttpRequest(e){let t;try{t=await hp.get(e)}catch(e){throw new DR(`Error fetching from api: ${e.message}`,LR.API_ERROR)}if(200!==t.status)throw new DR(`Error fetching from api: ${t.status} ${t.statusText}`,LR.API_ERROR);return t}getEndpoint=()=>this.isDevelopment?wR[mR]:this.isProduction?wR[i.PRODUCTION]:wR[i.SANDBOX];async loadConfig(){if(this.configCache)return this.configCache;const e=await HR.makeHttpRequest(`${this.getEndpoint()}/v1/config`);return this.configCache=e.data,this.configCache}async loadConfigTokens(){if(this.tokensCache)return this.tokensCache;const e=await HR.makeHttpRequest(`${this.getEndpoint()}/v1/config/tokens`);return this.tokensCache=e.data,this.tokensCache}async getConfig(e){const t=await this.loadConfig();if(t)return e?t[e]:t}async getTokensConfig(e){const t=await this.loadConfigTokens();return t&&t[e]?t[e]??[]:{}}}class qR extends Error{message;constructor(e){super(e),this.message=e}}const GR=e=>e.isProduction?aR.ETHEREUM:aR.SEPOLIA,WR=e=>e.isDevelopment?aR.IMTBL_ZKEVM_DEVNET:e.isProduction?aR.IMTBL_ZKEVM_MAINNET:aR.IMTBL_ZKEVM_TESTNET;class $R{isDevelopment=!1;isProduction;isOnRampEnabled;isSwapEnabled;isBridgeEnabled;remote;environment;networkMap;constructor(e){if(!Object.values(i).includes(e.baseConfig.environment))throw new qR("Invalid checkout configuration of environment");var t;this.environment=e.baseConfig.environment,this.isProduction=!this.isDevelopment&&this.environment===i.PRODUCTION,this.isOnRampEnabled=e.isOnRampEnabled??true,this.isSwapEnabled=e.isSwapEnabled??true,this.isBridgeEnabled=e.isBridgeEnabled??true,this.networkMap=(t=this.isProduction,this.isDevelopment?_R:t?TR:AR),this.remote=new HR({isDevelopment:this.isDevelopment,isProduction:this.isProduction})}}const KR=async(e,{type:t=cR.ALL,chainId:n,exclude:r})=>{let i,a=[];switch(t){case cR.SWAP:a=(await e.remote.getConfig("dex")).tokens||[];break;case cR.ONRAMP:i=await e.remote.getConfig("onramp"),i||(a=[]),a=i[sR.TRANSAK]?.tokens||[];break;case cR.BRIDGE:case cR.ALL:default:a=(await e.remote.getTokensConfig(n||GR(e))).allowed}return r&&0!==r?.length?{tokens:a.filter((e=>!r.map((e=>e.address)).includes(e.address||"")))}:{tokens:a}};class XR{url;nativeToken;ttl;chainId;cacheMap;static async makeHttpRequest(e){return hp.get(e)}setCache(e,t){this.cacheMap[e]={data:t,ttl:(new Date).getTime()+1e3*this.ttl}}getCache(e){const t=this.cacheMap[e];return!t||t.ttl<=(new Date).getTime()?null:t.data}constructor(e){this.chainId=e.chainId,this.url=xR[this.chainId].url;const t=xR[this.chainId].nativeToken;this.nativeToken={address:t.address??"",decimals:t.decimals.toString(),name:t.name,symbol:t.symbol},this.cacheMap={},this.ttl=void 0!==e.ttl?e.ttl:60}static isChainSupported=e=>Boolean(xR[e]);static isBlockscoutError=e=>"code"in e;async getTokensByWalletAddress(e){try{let t=`${this.url}/api/v2/addresses/${e.walletAddress}/tokens?type=${e.tokenType}`;e.nextPage&&(t+=`&${new URLSearchParams(e.nextPage)}`);const n=this.getCache(t);if(n)return Promise.resolve(n);const r=await XR.makeHttpRequest(t);if(r.status>=400)return Promise.reject({code:r.status,message:r.statusText});const i={items:r.data?.items?.filter((e=>e.token.address&&e.token.address!==this.nativeToken.address)),next_page_params:r.data?.next_page_params};return this.setCache(t,i),Promise.resolve(i)}catch(e){let t=kp.InternalServerError,n="InternalServerError";return hp.isAxiosError(e)&&(t=e.response?.status||t,n=e.message),Promise.reject({code:t,message:n})}}async getNativeTokenByWalletAddress(e){try{const t=`${this.url}/api/v2/addresses/${e.walletAddress}`,n=this.getCache(t);if(n)return Promise.resolve(n);const r=await XR.makeHttpRequest(t);if(r.status>=400)return Promise.reject({code:r.status,message:r.statusText});const i={token:this.nativeToken,value:r.data.coin_balance};return this.setCache(t,i),Promise.resolve(i)}catch(e){let t=kp.InternalServerError,n="InternalServerError";return hp.isAxiosError(e)&&(t=e.response?.status||t,n=e.message),Promise.reject({code:t,message:n})}}}var ZR;!function(e){e.ERC20="ERC-20"}(ZR||(ZR={}));const YR=(e,t,n)=>{e.isProduction||console.debug(t,n)},JR=async(e,t,n)=>{const r=performance.now(),i=await n,a=performance.now();return YR(e,t,(a-r)/1e3),i},QR=async(e,t,n)=>await BR((async()=>{const r=await zR(e,t);if(!r.isSupported)throw new DR(`Chain:${r.chainId} is not a supported chain`,LR.CHAIN_NOT_SUPPORTED_ERROR,{chainName:r.name});const i=await t.getBalance(n);return{balance:i,formattedBalance:_d(i,r.nativeCurrency.decimals),token:r.nativeCurrency}}),{type:LR.GET_BALANCE_ERROR});async function eO(e,t,n){return await BR((async()=>{const r=new gs(n,JSON.stringify(CR),e);return Promise.all([r.name(),r.symbol(),r.balanceOf(t),r.decimals()]).then((([e,t,r,i])=>({balance:r,formattedBalance:_d(r,i),token:{name:e,symbol:t,decimals:i,address:n}})))}),{type:LR.GET_ERC20_BALANCE_ERROR})}const tO=new Map,nO=async(e,t,n,r)=>{const i=[];r.forEach((r=>{r.address&&r.address!==yR?i.push(eO(t,n,r.address)):i.push(QR(e,t,n))}));return{balances:(await Promise.allSettled(i)).filter((e=>"fulfilled"===e.status)).map((e=>e.value))}},rO=async(e,t,n,r)=>{const{tokens:i}=await KR(e,{type:cR.ALL,chainId:r});let a=!1;try{a=(await e.remote.getTokensConfig(r)).blockscout||a}catch(e){console.error(e)}if(a&&XR.isChainSupported(r)){const t=GR(e)===r;return JR(e,`Time to fetch balances using blockscout for ${r}`,(async(e,t,n)=>{const r=n.length>0,i=Object.assign({},...n.map((e=>({[e.address||""]:e}))));let a=tO.get(t);a||(a=new XR({chainId:t}),tO.set(t,a));const o=[],s=ZR.ERC20;let u;try{do{u=await a.getTokensByWalletAddress({walletAddress:e,tokenType:s,nextPage:u?.next_page_params}),o.push(...u.items)}while(u.next_page_params)}catch(e){if(e?.code!==kp.NotFound)throw new DR(e.message||"InternalServerError | getTokensByWalletAddress",LR.GET_INDEXER_BALANCE_ERROR,e)}try{const t=await a.getNativeTokenByWalletAddress({walletAddress:e});o.push(t)}catch(e){if(e?.code!==kp.NotFound)throw new DR(e.message||"InternalServerError | getNativeTokenByWalletAddress",LR.GET_INDEXER_BALANCE_ERROR,e)}const l=[];return o.forEach((e=>{if(r&&!i[e.token.address])return;const t=e.token||{},n=Y.from(e.value);let a=parseInt(t.decimals,10);Number.isNaN(a)&&(a=gR);const o={...t,decimals:a},s=_d(e.value,o.decimals);l.push({balance:n,formattedBalance:s,token:o})})),{balances:l}})(n,r,t?i:[]))}return await JR(e,`Time to fetch balances using RPC for ${r}`,nO(e,t,n,i))};async function iO(e,t){let n=null;switch(e){case pR.PASSPORT:if(!t)throw new DR("Passport not provided",LR.DEFAULT_PROVIDER_ERROR);n=new sd(t.connectEvm());break;case pR.METAMASK:n=await async function(){const e=await BR((async()=>await Op()),{type:LR.METAMASK_PROVIDER_ERROR});if(!e||!e.request)throw new DR("No MetaMask provider installed.",LR.METAMASK_PROVIDER_ERROR);return new sd(e)}();break;default:throw new DR("Provider not supported",LR.DEFAULT_PROVIDER_ERROR)}return{provider:n,walletProviderName:e}}function aO(e){return!(!e||!e.provider?.request||"function"!=typeof e.provider.request)}async function oO(e,t,n){return BR((async()=>{if(t.provider?.isPassport)return t;if(!aO(t))throw new DR("Parsed provider is not a valid Web3Provider",LR.WEB3_PROVIDER_ERROR);const r={...hR,...n},i=await jR(t);let a=t.network?.chainId;try{a=t.network?.chainId,a||(a=(await t.getNetwork()).chainId)}catch(e){throw new DR("Unable to detect the web3Provider network",LR.WEB3_PROVIDER_ERROR)}if(a!==i&&!r.allowMistmatchedChainId)throw new DR("Your wallet has changed network, please switch to a supported network",LR.WEB3_PROVIDER_ERROR);if(!(await UR(e,{type:lR.ALL})).networks.some((e=>e.chainId===i))&&!r.allowUnsupportedProvider)throw new DR("Your wallet is connected to an unsupported network, please switch to a supported network",LR.WEB3_PROVIDER_ERROR);return t}),{type:LR.WEB3_PROVIDER_ERROR})}const sO=e=>(e=>!!e.maxFeePerGas&&!!e.maxPriorityFeePerGas)(e)?Y.from(e.maxFeePerGas).add(Y.from(e.maxPriorityFeePerGas)):e.gasPrice?Y.from(e.gasPrice):null,uO=async e=>{const t=await e.getFeeData(),n=sO(t);if(n)return n.mul(14e4)};async function lO(e,t,n,r){const i=n.get(e),o=n.get(t);if(!i)throw new DR(`Chain:${e} is not a supported chain`,LR.CHAIN_NOT_SUPPORTED_ERROR);if(!o)throw new DR(`Chain:${t} is not a supported chain`,LR.CHAIN_NOT_SUPPORTED_ERROR);let s=Fp;r.isDevelopment&&(s=Lp),r.isProduction&&(s=Dp);const u=new Yy({baseConfig:new a({environment:r.environment}),bridgeInstance:s,rootProvider:i,childProvider:o});return new Wy(u)}async function cO(e,t){const n=await t.remote.getConfig("dex");return new KA({chainId:e,baseConfig:new a({environment:t.environment}),overrides:n?.overrides})}function dO(e){return new lI({baseConfig:{environment:e.environment}})}function fO(e,t,n){return new gs(e,t,n)}const pO="0x0000000000000000000000000000000000000001",hO=18;async function mO(e,t,n,r){const i=GR(t),a=WR(t),o=await t.remote.getConfig("gasEstimateTokens"),{gasTokenAddress:s,fromAddress:u}=o[i].bridgeToL2Addresses,l=e.get(i);if(!l)throw new Error(`Missing JsonRpcProvider for chain id: ${i}`);try{const o=await async function(e,t){const n=await uO(e);return n&&t?{estimatedAmount:n.add(n)}:{estimatedAmount:n}}(l,n);o.token=await async function(e,t,n,r){if("NATIVE"===t)return e.networkMap.get(n)?.nativeCurrency;const i=new gs(t,JSON.stringify(CR),r);return{name:await i.name(),symbol:await i.symbol(),decimals:await i.decimals(),address:t}}(t,r??(s||"NATIVE"),i,l);const c=await lO(i,a,e,t),{bridgeFee:d,bridgeable:f}=await async function(e,t){const n=await e.getFee({token:t});return{bridgeFee:{estimatedAmount:n.feeAmount},bridgeable:n.bridgeable}}(c,u);return{gasEstimateType:uR.BRIDGE_TO_L2,gasFee:o,bridgeFee:{estimatedAmount:d?.estimatedAmount,token:d?.token},bridgeable:f}}catch{return{gasEstimateType:uR.BRIDGE_TO_L2,gasFee:{},bridgeFee:{},bridgeable:!1}}}async function yO(e,t,n){switch(e.gasEstimateType){case uR.BRIDGE_TO_L2:return await mO(t,n,e.isSpendingCapApprovalRequired,e.tokenAddress);case uR.SWAP:return await async function(e){const t=WR(e),n=await e.remote.getConfig("gasEstimateTokens"),{inAddress:r,outAddress:i}=n[t].swapAddresses;try{const n=await cO(t,e),{swap:a}=await n.getUnsignedSwapTxFromAmountIn(pO,r,i,Y.from(xd("1",hO)));if(null===a.gasFeeEstimate)return{gasEstimateType:uR.SWAP,gasFee:{}};let o;return a.gasFeeEstimate.value&&(o=Y.from(a.gasFeeEstimate.value)),{gasEstimateType:uR.SWAP,gasFee:{estimatedAmount:o,token:{address:a.gasFeeEstimate?.token.address,symbol:a.gasFeeEstimate?.token.symbol??"",name:a.gasFeeEstimate?.token.name??"",decimals:a.gasFeeEstimate?.token.decimals??hO}}}}catch{return{gasEstimateType:uR.SWAP,gasFee:{}}}}(n);default:throw new DR("Invalid type provided for gasEstimateType",LR.INVALID_GAS_ESTIMATE_TYPE)}}const gO=e=>(e=>{const t=new Map,n=[];return e.forEach((e=>{const{type:r}=e;if(r!==IR.ERC721)return void n.push(e);const{contractAddress:i,spenderAddress:a,id:o}=e,s=`${i}${a}${o}`;t.get(s)||t.set(s,{...e})})),n.concat(Array.from(t.values()))})((e=>{const t=new Map,n=[];return e.forEach((e=>{const{type:r}=e;if(r!==IR.ERC20)return void n.push(e);const{contractAddress:i,spenderAddress:a,amount:o}=e,s=`${i}${a}`,u=t.get(s);u&&u.type===IR.ERC20?u.amount=Y.from(u.amount).add(o):t.set(s,{...e})})),n.concat(Array.from(t.values()))})((e=>{const t=new Map,n=[];return e.forEach((e=>{const{type:r}=e;if(r!==IR.NATIVE)return void n.push(e);const{amount:i}=e,a=t.get(r);a&&a.type===IR.NATIVE?a.amount=Y.from(a.amount).add(i):t.set(r,{...e})})),n.concat(Array.from(t.values()))})(e))),bO=async(e,t,n,r)=>{try{const i=new gs(n,JSON.stringify(CR),e);return await i.allowance(t,r)}catch(e){throw new DR("Failed to get the allowance for ERC20",LR.GET_ERC20_ALLOWANCE_ERROR,{contractAddress:n})}},vO=async(e,t,n,r,i)=>{try{const a=new gs(n,JSON.stringify(CR),e),o=await a.populateTransaction.approve(r,i);return o&&(o.from=t),o}catch{throw new DR("Failed to get the approval transaction for ERC20",LR.GET_ERC20_ALLOWANCE_ERROR,{contractAddress:n})}},wO=async(e,t,n,r)=>{try{const i=new gs(n,JSON.stringify(kR),e);return await i.isApprovedForAll(t,r)}catch(e){throw new DR("Failed to check approval for all ERC721s of collection",LR.GET_ERC721_ALLOWANCE_ERROR,{ownerAddress:t,contractAddress:n,spenderAddress:r})}},EO=async(e,t,n,r,i)=>{try{const a=new gs(n,JSON.stringify(kR),e),o=await a.populateTransaction.approve(r,i);return o&&(o.from=t),o}catch(e){throw new DR("Failed to get the approval transaction for ERC721",LR.GET_ERC721_ALLOWANCE_ERROR,{id:i.toString(),contractAddress:n,spenderAddress:r,ownerAddress:t})}},TO=async(e,t,n)=>{try{const r=new gs(t,JSON.stringify(kR),e);return await r.getApproved(n)}catch(e){throw new DR("Failed to get approved address for ERC721",LR.GET_ERC721_ALLOWANCE_ERROR,{id:n.toString(),contractAddress:t})}},AO=(e,t)=>{const n=parseInt(e,10);if(Number.isNaN(n))throw new DR("Invalid ERC721 ID",LR.GET_ERC721_ALLOWANCE_ERROR,{id:e,contractAddress:t});return n},_O=async(e,t,n)=>{let r=!0;const i=[],a=new Map,o=new Map,s=new Map,u=new Map,l=await(async(e,t,n)=>{const r=new Map,i=new Map;for(const a of t){if(a.type!==IR.ERC721)continue;const{contractAddress:t,spenderAddress:o}=a,s=`${t}-${o}`;r.set(s,!1),i.has(s)||i.set(s,wO(e,n,t,o))}const a=await Promise.all(i.values()),o=Array.from(i.keys());return a.forEach(((e,t)=>{r.set(o[t],e)})),r})(e,n,t);for(const t of n){if(t.type!==IR.ERC721)continue;const{contractAddress:n,id:r,spenderAddress:s}=t,u=`${n}-${s}`;if(l.get(u)){i.push({sufficient:!0,itemRequirement:t});continue}const c=`${n}-${r}`,d=AO(r,n);a.set(c,t),o.set(c,TO(e,n,d))}const c=await Promise.all(o.values()),d=Array.from(o.keys());for(let n=0;n<c.length;n++){const o=a.get(d[n]);if(!o||o.type!==IR.ERC721)continue;if(c[n]===o.spenderAddress){i.push({sufficient:!0,itemRequirement:o});continue}r=!1;const{contractAddress:l,id:f,spenderAddress:p}=o,h=`${l}-${f}`,m=AO(f,l);s.set(h,{type:IR.ERC721,sufficient:!1,itemRequirement:o,approvalTransaction:void 0}),u.set(h,EO(e,t,l,p,m))}const f=await Promise.all(u.values()),p=Array.from(u.keys());return f.forEach(((e,t)=>{const n=s.get(p[t]);n&&(n.sufficient||(n.approvalTransaction=e))})),{sufficient:r,allowances:i.concat(Array.from(s.values()))}},xO=e=>(e=>{const t=new Map,n=[];return e.forEach((e=>{const{type:r}=e;if(r!==IR.ERC721)return void n.push(e);const{contractAddress:i,id:a}=e,o=`${i}${a}`;t.get(o)||t.set(o,{...e})})),n.concat(Array.from(t.values()))})((e=>{const t=new Map,n=[];return e.forEach((e=>{const{type:r}=e;if(r!==IR.ERC20)return void n.push(e);const{contractAddress:i,amount:a}=e,o=`${i}`,s=t.get(o);s&&s.type===IR.ERC20?s.amount=Y.from(s.amount).add(a):t.set(o,{...e})})),n.concat(Array.from(t.values()))})((e=>{const t=new Map,n=[];return e.forEach((e=>{const{type:r}=e;if(r!==IR.NATIVE)return void n.push(e);const{amount:i}=e,a=t.get(r);a&&a.type===IR.NATIVE?a.amount=Y.from(a.amount).add(i):t.set(r,{...e})})),n.concat(Array.from(t.values()))})(e))),CO=(e,t)=>{const n=Y.from(1),r=t.find((t=>{const n=t;return n.contractAddress===e.contractAddress&&n.id===e.id})),i=n.isNegative()||n.isZero()||(r?.balance.gte(n)??!1),a=n.sub(r?.balance??Y.from(0));let o=r;return o||(o={type:IR.ERC721,balance:Y.from(0),formattedBalance:"0",contractAddress:e.contractAddress,id:e.id}),{sufficient:i,type:IR.ERC721,delta:{balance:a,formattedBalance:a.toString()},current:o,required:{...o,balance:Y.from(1),formattedBalance:"1"}}},kO=async(e,t,n,r)=>{let i=[];try{const a=(e=>e.map((e=>e.type===IR.NATIVE?{address:yR}:{address:e.contractAddress})))(r),{balances:o}=await nO(e,t,n,a);i=[...o.map((e=>e))]}catch(e){throw new DR("Failed to get balances",LR.GET_BALANCE_ERROR)}return i},SO=async(e,t,n,r)=>{const i=xO(r);if(i.filter((e=>e.type!==IR.ERC721&&e.type!==IR.ERC20&&e.type!==IR.NATIVE)).length>0)throw new DR("Unsupported item requirement balance check",LR.UNSUPPORTED_BALANCE_REQUIREMENT_ERROR);const a=[],o=i.filter((e=>e.type===IR.ERC20||e.type===IR.NATIVE));o.length>0&&a.push(kO(e,t,n,i));const s=i.filter((e=>e.type===IR.ERC721));s.length>0&&a.push((async(e,t,n)=>{const r=[],i=new Map,a=new Map;n.forEach((t=>{if(t.type!==IR.ERC721)return;const n=new gs(t.contractAddress,JSON.stringify(kR),e);i.set(t.contractAddress,t),a.set(t.contractAddress,n.ownerOf(t.id))}));try{const e=await Promise.all(a.values()),n=Array.from(a.keys());e.forEach(((e,a)=>{const o=i.get(n[a]);let s=0;o&&t===e&&(s=1),r.push({type:IR.ERC721,balance:Y.from(s),formattedBalance:s.toString(),contractAddress:o.contractAddress,id:o.id})}))}catch(e){throw new DR("Failed to get ERC721 balances",LR.GET_ERC721_BALANCE_ERROR)}return r})(t,n,i));const u=await Promise.all(a).then((e=>{const t=[];if(e.length>1||o.length>0){const n=e[0];if(o.forEach((e=>{t.push(((e,t)=>{let n;e.type===IR.ERC20?n=t.find((t=>t.token?.address===e.contractAddress)):e.type===IR.NATIVE&&(n=t.find((e=>""===e.token?.address||e.token?.address===yR)));const r=e.amount,i=r.isNegative()||r.isZero()||(n?.balance.gte(r)??!1),a=r.sub(n?.balance??Y.from(0));let o="",s="",u=gR;n&&(u=n.token?.decimals??gR,o=n.token.name,s=n.token.symbol);let l=n;return e.type===IR.NATIVE?(l||(l={type:IR.NATIVE,balance:Y.from(0),formattedBalance:"0",token:{name:o,symbol:s,decimals:gR,address:yR}}),{sufficient:i,type:IR.NATIVE,delta:{balance:a,formattedBalance:_d(a,u)},current:{...l,type:IR.NATIVE},required:{...l,type:IR.NATIVE,balance:Y.from(e.amount),formattedBalance:_d(e.amount,u)}}):(l||(l={type:e.type,balance:Y.from(0),formattedBalance:"0",token:{name:o,symbol:s,address:e.contractAddress,decimals:u}}),{sufficient:i,type:IR.ERC20,delta:{balance:a,formattedBalance:_d(a,u)},current:l,required:{...l,balance:Y.from(e.amount),formattedBalance:_d(e.amount,u)}})})(e,n))})),s.length>0){const n=e[1];s.forEach((e=>{t.push(CO(e,n))}))}}else if(s.length>0){const n=e[0];s.forEach((e=>{t.push(CO(e,n))}))}return t}));return{sufficient:u.reduce(((e,t)=>e&&t.sufficient),!0),balanceRequirements:u}},IO=async(e,t)=>{try{return await e.estimateGas(t)}catch(e){throw new DR("Failed to estimate gas for transaction",LR.UNPREDICTABLE_GAS_LIMIT)}},RO=async(e,t,n)=>{const r=[];let i=Y.from(0);for(const n of t)void 0!==n.approvalTransaction&&r.push(IO(e,n.approvalTransaction));if(n.type===RR.TRANSACTION)r.push(IO(e,n.transaction));else{const t=await e.getFeeData(),r=sO(t);if(null!==r){const e=r?.mul(n.gasToken.limit);e&&(i=i.add(e))}}return(await Promise.all(r)).forEach((e=>{i=i.add(e)})),i.eq(0)?null:((e,t)=>t.type===RR.TRANSACTION||t.gasToken.type===OR.NATIVE?{type:IR.NATIVE,amount:e}:{type:IR.ERC20,amount:e,contractAddress:t.gasToken.contractAddress,spenderAddress:""})(i,n)},OO=(e,t)=>({checkDexAvailability:async()=>{let n;try{n=await hp.post(`${e?vR[mR]:t?vR[i.PRODUCTION]:vR[i.SANDBOX]}/v1/availability/checkout/swap`)}catch(e){n=e.response}if(403===n.status)return!1;if(204===n.status)return!0;throw new DR(`Error fetching from api: ${n.status} ${n.statusText}`,LR.API_ERROR)}}),PO=async()=>!0,NO=async e=>{const t=OO(e.isDevelopment,e.isProduction);try{return await t.checkDexAvailability()}catch{return!1}};async function MO(e,t){if(e.isProduction&&t?.has(aR.ETHEREUM))return t;if(t?.has(aR.SEPOLIA))return t;const n=new Map;return(await UR(e,{type:lR.ALL})).networks.forEach((t=>{const r=e.networkMap.get(t.chainId)?.rpcUrls[0],i=new ac(r);n.set(t.chainId,i)})),n}const LO=async(e,t,n,r,i)=>{const a=new Map;try{const o=await cO(t,e),s=[],u=[];for(const e of i)e!==r.address&&(s.push(o.getUnsignedSwapTxFromAmountOut(n,e,r.address,r.amount,1)),u.push(e));return(await JR(e,"Time to resolve swap quotes from the dex",Promise.allSettled(s))).forEach(((e,t)=>{if("rejected"===e.status)return;const n=u[t];a.set(n,{quote:e.value.quote,approval:e.value.approval?.gasFeeEstimate??null,swap:e.value.swap.gasFeeEstimate})})),a}catch{return a}},FO=(e,t,n)=>{let r,i=Y.from(0),a="0";e&&(i=e.value,a=_d(e.value,e.token.decimals),r={name:e.token.name??"",symbol:e.token.symbol??"",address:e.token.address,decimals:e.token.decimals});let o,s=Y.from(0),u="0";t&&(s=t.value,u=_d(t.value,t.token.decimals),o={name:t.token.name??"",symbol:t.token.symbol??"",address:t.token.address,decimals:t.token.decimals});const l=[];for(const e of n)l.push({amount:e.amount.value,formattedAmount:_d(e.amount.value,e.amount.token.decimals),token:{name:e.amount.token.name??"",symbol:e.amount.token.symbol??"",address:e.amount.token.address,decimals:e.amount.token.decimals}});return{approvalGasFees:{amount:i,formattedAmount:a,token:r},swapGasFees:{amount:s,formattedAmount:u,token:o},swapFees:l}},DO=(e,t,n,r)=>{const i=n.token.address;let a=IR.ERC20;return i===yR&&(a=IR.NATIVE),{type:NR.SWAP,chainId:e,fundingItem:{type:a,fundsRequired:{amount:t,formattedAmount:_d(t,n.token.decimals)},userBalance:{balance:n.balance,formattedBalance:n.formattedBalance},token:n.token},fees:r}},BO=(e,t)=>{if(!t)return{sufficient:!0,approvalGasFee:Y.from(0),approvalGasTokenAddress:""};const n=t.value,r=t.token.address;if(0===e.length)return{sufficient:!1,approvalGasFee:n,approvalGasTokenAddress:r};const i=e.find((e=>e.token.address===r));return i?i.balance.lt(n)?{sufficient:!1,approvalGasFee:n,approvalGasTokenAddress:r}:{sufficient:!0,approvalGasFee:n,approvalGasTokenAddress:r}:{sufficient:!1,approvalGasFee:n,approvalGasTokenAddress:r}},jO=(e,t,n,r,i)=>{const a=new Map;if(""!==t.approvalGasTokenAddress&&a.set(t.approvalGasTokenAddress,t.approvalGasFee),n){const e=a.get(n.token.address);e?a.set(n.token.address,e.add(n.value)):a.set(n.token.address,n.value)}if(i){const e=a.get(i.address);e?a.set(i.address,e.add(i.amount)):a.set(i.address,i.amount)}for(const e of r){const t=a.get(e.amount.token.address);t?a.set(e.amount.token.address,t.add(e.amount.value)):a.set(e.amount.token.address,e.amount.value)}for(const[t,n]of a.entries()){if(n===Y.from(0))continue;const r=e.find((e=>e.token.address===t));if(!r)return!1;if(r.balance.lt(n))return!1}return!0},UO=(e,t,n,r,i,a)=>{let o=Y.from(0),s="",u=!1;if(t.balanceRequirements.forEach((t=>{t.type!==IR.NATIVE&&t.type!==IR.ERC20||t.required.token.address===n&&(s=t.required.token.address,u=!0,o=e.sub(t.required.balance))})),!u)return!0;i.approvalGasTokenAddress===s&&(o=o.sub(i.approvalGasFee));for(const e of a)e.amount.token.address===s&&(o=o.sub(e.amount.value));return o.gte(r)},zO=async(e,t,n,r,i,a,o)=>{const s=[];if(!t.swap)return s;if(0===a.length)return s;const u=(e=>{let t="",n=Y.from(0);switch(e.type){case IR.ERC20:t=e.required.token.address??"",n=e.delta.balance;break;case IR.NATIVE:t=yR,n=e.delta.balance}return{address:t,amount:n}})(r);if(""===u.address)return s;const l=WR(e),c=i.get(l);if(!c)return s;const d=c.balances;if(0===d.length)return s;const f=await LO(e,WR(e),n,u,a),p=Array.from(f.keys());for(const e of p){const t=f.get(e);if(!t)continue;const n=d.find((t=>t.token.address===e));if(!n)continue;const r=t.quote.amount;if(n.balance.lt(r.value))continue;const i=BO(d,t.approval);if(!i.sufficient)continue;if(!jO(d,i,t.swap,t.quote.fees,{amount:r.value,address:e}))continue;if(!UO(n.balance,o,e,r.value,i,t.quote.fees))continue;const a=FO(t.approval,t.swap,t.quote.fees);s.push(DO(l,r.value,n,a))}return s},VO=(e,t)=>t&&t.success?e.filter((e=>"address"in e?t.balances.find((t=>t.token.address===e.address&&t.balance.gt(0))):t.balances.find((e=>!("address"in e.token)&&e.balance.gt(0))))):[],HO=async(e,t)=>{if(t.onRamp){const t=await e.remote.getConfig("onramp"),n={};return Object.entries(t).forEach((([e,t])=>{n[e]=t.tokens??[]})),n}return{}},qO=async(e,t,n)=>{if(n.bridge){const n=(await e.remote.getConfig("bridge"))?.tokens??[],r=t.get(GR(e));return VO(n,r)}return[]},GO=async(e,t,n)=>{const r={};return r.swap=await(async(e,t,n)=>{if(n.swap){const n=(await e.remote.getConfig("dex"))?.tokens??[],r=t.get(WR(e));return VO(n,r)}return[]})(e,t,n),r.bridge=await qO(e,t,n),r.onRamp=await HO(e,n),r},WO="0x0000000000000000000000000000000000000001",$O=async(e,t)=>(await t.remote.getConfig("imxAddressMapping"))[e]??"",KO=async(e,t)=>{if(""===t)return{l1address:"",l2address:t};if(t===yR)return{l1address:await $O(GR(e),e),l2address:yR};const n=WR(e)===aR.IMTBL_ZKEVM_TESTNET?"imtbl-zkevm-testnet":"";if(""===n)return{l1address:"",l2address:t};const r=function(e){return new $I({baseConfig:{environment:e.environment}})}(e),i=(await r.getToken({chainName:n,contractAddress:t})).result.root_contract_address;return null===i?{l1address:"",l2address:t}:{l1address:i,l2address:t}},XO=async(e,t,n,r,i,a)=>{if(i===WO)return Y.from(0);const o=GR(e),s=WR(e);return await(async(e,t,n,r,i,a,o,s)=>{try{const u=await lO(i,a,t,e),{unsignedTx:l}=await u.getUnsignedApproveDepositBridgeTx({depositorAddress:r,token:o,depositAmount:s});return null===l?Y.from(0):await n.estimateGas(l)}catch(e){throw new DR("Error occurred while attempting ot estimate gas for approval transaction",LR.BRIDGE_GAS_ESTIMATE_ERROR,{message:e.message})}})(e,t,n,r,o,s,i,a)},ZO=(e,t)=>(e=>{for(const t of e.balances)if(!t.token.address||""===t.token.address)return t.balance;return Y.from(0)})(e).gte(t),YO=async(e,t,n)=>{let r=n.get(NR.BRIDGE);return r||(r=await(async(e,t)=>{try{const n=await yO({gasEstimateType:uR.BRIDGE_TO_L2,isSpendingCapApprovalRequired:!1},t,e),r=n.gasFee.estimatedAmount,i=n.bridgeFee.estimatedAmount;let a=Y.from(0);return r&&(a=a.add(r)),i&&(a=a.add(i)),{type:NR.BRIDGE,gasFee:{estimatedAmount:r??Y.from(0),token:n.gasFee.token},bridgeFee:{estimatedAmount:i??Y.from(0),token:n.bridgeFee.token},totalFees:a}}catch(e){throw new DR("Error estimating gas for bridge",LR.BRIDGE_GAS_ESTIMATE_ERROR,{message:e.message})}})(e,t),n.set(NR.BRIDGE,r),r)},JO=(e,t,n)=>{const r=n.token?.decimals??gR;return{approvalGasFees:{amount:e,formattedAmount:_d(e,gR),token:t.token},bridgeGasFees:{amount:t.estimatedAmount,formattedAmount:_d(t.estimatedAmount,gR),token:t.token},bridgeFees:[{amount:n.estimatedAmount,formattedAmount:_d(n.estimatedAmount,r),token:n.token}]}},QO=(e,t,n,r,i)=>({type:NR.BRIDGE,chainId:e,fundingItem:{type:r,fundsRequired:{amount:n.amount,formattedAmount:n.formattedAmount},userBalance:{balance:t.balance,formattedBalance:t.formattedBalance},token:{name:t.token.name,symbol:t.token.symbol,address:t.token.address,decimals:t.token.decimals}},fees:i}),eP=async(e,t,n,r,i,a,o)=>{if(!r.bridge)return;if(void 0===i.l2address||""===i.l2address)return;const s=GR(e),u=a.get(s),l=t.get(s);if(!l)throw new DR("No L1 provider available",LR.PROVIDER_ERROR,{chainId:s.toString()});if(void 0===u||!1===u.success)return;const c=await qO(e,a,r);if(0===c.length)return;const d=await YO(e,t,o);if(!ZO(u,d.totalFees))return;const f=await KO(e,i.l2address),{l1address:p}=f;if(""===p)return;if(p===WO){if(!c.find((e=>!("address"in e))))return}else if(!c.find((e=>e.address===p)))return;const h=await XO(e,t,l,n,p,i.amount);let m=d.bridgeFee.estimatedAmount;if(p===WO){const e=u.balances.find((e=>(e=>!e||""===e)(e.token.address)));if(d.gasFee.estimatedAmount&&(m=m.add(d.gasFee.estimatedAmount)),!ZO(u,m))return;if(e&&e.balance.gte(i.amount.add(m))){const t=JO(h,d.gasFee,d.bridgeFee);return QO(s,e,i,IR.NATIVE,t)}return}if(m.add(h).add(d.gasFee.estimatedAmount),!ZO(u,m))return;const y=u.balances.find((e=>e.token.address===p));if(y&&y.balance.gte(i.amount)){const e=JO(h,d.gasFee,d.bridgeFee);return QO(s,y,i,IR.ERC20,e)}},tP=(e,t)=>{let n=Y.from(0);return e.quote.fees.forEach((e=>{e.amount.token.address===t&&(n=n.add(e.amount.value))})),e.approval&&e.approval.token.address===t&&(n=n.add(e.approval.value)),n},nP=(e,t)=>{for(const n of e.balanceRequirements)if((n.type===IR.NATIVE||n.type===IR.ERC20)&&n.required.token.address===t)return n.required.balance;return Y.from(0)},rP=(e,t,n)=>{const r=n?.balance??Y.from(0);if(r.gte(e.add(t)))return Y.from(0);if(r.lte(0))return e.add(t);const i=r.sub(t);return i.gte(0)?e.sub(i):e.add(t).sub(r)},iP=async(e,t,n,r,i,a,o,s,u,l)=>{const{l1balances:c,l2balances:d}=((e,t)=>{const n={l1balances:[],l2balances:[]},r=t.get(GR(e)),i=t.get(WR(e));return r?void 0!==r.error?n:r.success&&i?void 0!==i.error?n:i.success?{l1balances:r.balances,l2balances:i.balances}:n:n:n})(e,o),f=r.required.token.address;if(((e,t,n,r,i,a)=>0===e.length||0===t.length||0===n.length||0===r.length||!i.bridge||!i.swap||void 0===a||""===a)(s,u,c,d,n,f))return[];const p=await(async(e,t)=>{const n=t.map((t=>KO(e,t.address??"")));return await Promise.all(n)})(e,u),h=((e,t,n,r)=>{const i=[];for(const a of r){if(""===a.l1address)continue;if(""===a.l2address)continue;if(!t.includes(a.l1address))continue;if(a.l2address===e)continue;const r=n.find((e=>e.address===a.l2address));r&&i.push(r)}return i})(f,s,u,p);if(0===h.length)return[];const m=await(async(e,t,n,r,i)=>{const a=[];for(const e of i)e.address&&a.push(e.address);return await LO(e,WR(e),t,{address:n,amount:r.delta.balance},a)})(e,i,f,r,h),y=((e,t,n,r,i)=>{const a=[];for(const[o,s]of e){const e=n.find((e=>e.token.address===o)),u=r.find((e=>e.l2address===o));if(!u)continue;const{l1address:l,l2address:c}=u;if(!l)continue;const d=t.find((e=>void 0===e.token.address&&l===WO||e.token.address===l));if(!d)continue;const f=s.quote.amountWithMaxSlippage.value,p=tP(s,o),h=f.add(p),m=nP(i,o),y=rP(h,m,e);y.lte(0)||y.gte(d.balance)||a.push({amount:y,formattedAmount:_d(y,d.token.decimals),l2address:c})}return a})(m,c,d,p,l);if(0===y.length)return[];const g=new Map,b=new Map,v=[];for(const r of y)r.l2address&&(g.set(r.l2address,eP(e,t,i,n,r,o,a)),b.set(r.l2address,{amount:r.amount,formattedAmount:r.formattedAmount,l2address:r.l2address}));const w=await Promise.all(g.values()),E=Array.from(g.keys()),T=[];if(w.forEach(((e,t)=>{const n=E[t];if(void 0===e)return;T.push(n);const r=b.get(n);r&&v.push({amount:r.amount,formattedAmount:r.formattedAmount,l2address:r.l2address})})),0===T.length)return[];if(0===v.length)return[];const A=((e,t,n,r,i)=>{const a=new Map;for(const[e,n]of t)a.set(e,{success:n.success,balances:n.balances});const o=new Map;for(const e of n)e.token.address&&o.set(e.token.address,e);for(const e of r){const{amount:t,l2address:n}=e;if(""===n)continue;let r=Y.from(0);const a=o.get(n);a&&(r=a.balance);const s=r.add(t),u=i.find((e=>e.address===n));o.set(n,{balance:s,formattedBalance:_d(s,u.decimals),token:u})}const s=Array.from(o.values());return a.set(WR(e),{success:!0,balances:s}),a})(e,o,d,v,u),_=await zO(e,n,i,r,A,T,l);if(!_)return[];const x=((e,t)=>{const n=[];for(const r of t){const{chainId:t,fundingItem:i}=r,{userBalance:a}=r.fundingItem,o=e.get(t);if(!o)continue;let s=Y.from(0),u="0";const l=o.balances.find((e=>e.token.address===i.token.address));l&&(s=l.balance,u=l.formattedBalance),a.balance=s,a.formattedBalance=u,n.push(r)}return n})(o,_);return((e,t,n)=>{const r=[];for(const i of e){if(!i)continue;const e=n.find((e=>void 0===i.fundingItem.token.address?e.l1address===WO&&e.l2address:e.l1address===i.fundingItem.token.address&&e.l2address));if(!e)continue;const a=t.find((t=>t.fundingItem.token.address===e.l2address));a&&r.push({bridgeFundingStep:i,swapFundingStep:a})}return r})(w,x,p)},aP=async(e,t,n)=>{if(!t.onRamp)return;if(void 0===n)return;const r=await(async(e,t,n)=>{if(n.type!==IR.ERC20&&n.type!==IR.NATIVE)return;const{required:r,current:i,delta:a}=n;let o=!1;const s=await HO(e,t);return Object.values(s).forEach((e=>{e.length>0&&!o&&(o=!!e.find((e=>e.address===r.token?.address)))})),o?{type:NR.ONRAMP,chainId:WR(e),fundingItem:{type:r.token.address===yR?IR.NATIVE:IR.ERC20,fundsRequired:{amount:a.balance,formattedAmount:a.formattedBalance},userBalance:{balance:i.balance,formattedBalance:i.formattedBalance},token:r.token}}:void 0})(e,t,n);return r},oP=async(e,t,n,r)=>{if(!(e=>e.bridge||e.swap||e.onRamp)(r))return{type:PR.NO_ROUTE_OPTIONS,message:"No routing options are available"};let i;try{i=await MO(e)}catch(e){throw new DR("Error occurred while creating read only providers",LR.PROVIDER_ERROR,{message:e.message})}const a=await JR(e,"Time to get token balances inside router",(async(e,t,n,r)=>{const i=new Map,a=new Map;if(0===t.size){const t={success:!1,error:new DR("No L1 or L2 provider available",LR.PROVIDER_ERROR),balances:[]};return i.set(GR(e),t),i.set(WR(e),t),i}if(r.bridge){const r=GR(e);t.has(r)?a.set(r,rO(e,t.get(r),n,r)):i.set(GR(e),{success:!1,error:new DR(`No L1 provider available for ${r}`,LR.PROVIDER_ERROR),balances:[]})}const o=WR(e);if(t.has(o)?a.set(o,rO(e,t.get(o),n,o)):i.set(WR(e),{success:!1,error:new DR(`No L2 provider available for ${o}`,LR.PROVIDER_ERROR),balances:[]}),a.size>0){const e=Array.from(a.keys());(await Promise.allSettled(a.values())).forEach(((t,n)=>{const r=e[n];"fulfilled"===t.status?i.set(r,{success:!0,balances:t.value.balances}):i.set(r,{success:!1,error:new DR(`Error getting ${o} balances`,LR.GET_BALANCE_ERROR),balances:[]})}))}return i})(e,i,t,r)),o=await JR(e,"Time to get routing allowlist",GO(e,a,r)),s=new Map,u=(e=>{let t,n=0;for(const r of e.balanceRequirements)r.sufficient||(n++,t=r);if(1===n)return t})(n),l=[];l.push((async(e,t,n,r,i,a,o)=>{let s;if(void 0===r)return;if(r.type!==IR.NATIVE&&r.type!==IR.ERC20)return;const u={amount:r.delta.balance,formattedAmount:r.delta.formattedBalance,l2address:r.required.token.address??""};return n.bridge&&r&&(s=await eP(e,t,i,n,u,a,o)),s})(e,i,r,u,t,a,s)),l.push((async(e,t,n,r,i,a,o)=>{const s=[];if(!t.swap)return s;if(void 0===n)return s;if(void 0===a)return s;const u=i.get(WR(e));if(!u)return s;if(void 0!==u.error||!u.success)return s;if(0===a.length)return s;const l=a.filter((e=>e.address)).map((e=>e.address));return 0===l.length?s:await zO(e,t,r,n,i,l,o)})(e,r,u,t,a,o.swap,n)),l.push(aP(e,r,u)),l.push((async(e,t,n,r,i,a,o,s,u)=>{if(!r)return[];const l=a.get(GR(e)),c=a.get(WR(e));if(!l)return[];if(void 0!==l.error||!l.success)return[];if(!c)return[];if(void 0!==c.error||!c.success)return[];const d=(o?.bridge??[]).map((e=>void 0===e.address?WO:e.address)),f=o?.swap??[];return r.type!==IR.NATIVE&&r.type!==IR.ERC20?[]:await iP(e,t,n,r,i,s,a,d,f,u)})(e,i,r,u,t,a,o,s,n));const c=await JR(e,"Time to resolve all routes",Promise.all(l));let d,f,p=[],h=[];if(c.forEach(((e,t)=>{0===t&&(d=e),1===t&&(p=e),2===t&&(f=e),3===t&&(h=e)})),!d&&0===p.length&&!f&&0===h.length)return{type:PR.NO_ROUTES_FOUND,message:"Smart Checkout did not find any funding routes to fulfill the transaction"};const m={type:PR.ROUTES_FOUND,fundingRoutes:[]};let y=0;return p.length>0&&(y++,p.forEach((e=>{m.fundingRoutes.push({priority:y,steps:[e]})}))),d&&(y++,m.fundingRoutes.push({priority:y,steps:[d]})),f&&(y++,m.fundingRoutes.push({priority:y,steps:[f]})),h&&(y++,h.forEach((e=>{const t=e.bridgeFundingStep,n=e.swapFundingStep;m.fundingRoutes.push({priority:y,steps:[t,n]})}))),m},sP=async(e,t,n,r)=>{const i=await t.getSigner().getAddress();let a=gO(n);const o=(async(e,t,n)=>{let r=!0;const i=[],a=new Map,o=new Map,s=new Map,u=new Map;for(const r of n){if(r.type!==IR.ERC20)continue;const{contractAddress:n,spenderAddress:i}=r,s=`${n}${i}`;a.set(s,r),o.set(s,bO(e,t,n,i))}const l=await Promise.all(o.values()),c=Array.from(o.keys());for(let n=0;n<l.length;n++){const o=a.get(c[n]);if(!o||o.type!==IR.ERC20)continue;if(l[n].gte(o.amount)){i.push({sufficient:!0,itemRequirement:o});continue}r=!1;const{contractAddress:d,spenderAddress:f}=o,p=`${d}${f}`,h=o.amount.sub(l[n]);s.set(p,{type:IR.ERC20,sufficient:!1,delta:h,itemRequirement:o,approvalTransaction:void 0}),u.set(p,vO(e,t,d,f,h))}const d=await Promise.all(u.values()),f=Array.from(u.keys());return d.forEach(((e,t)=>{const n=s.get(f[t]);n&&(n.sufficient||(n.approvalTransaction=e))})),{sufficient:r,allowances:i.concat(Array.from(s.values()))}})(t,i,a),s=_O(t,i,a),u=await JR(e,"Time to calculate token allowances",Promise.all([o,s])),l=((e,t)=>{const n=[];if(!e.sufficient)for(const t of e.allowances)t.sufficient||n.push(t);if(!t.sufficient)for(const e of t.allowances)e.sufficient||n.push(e);return n})(u[0],u[1]),c=await JR(e,"Time to run gas calculator",RO(t,l,r));null!==c&&(a.push(c),a=gO(a));const d=await JR(e,"Time to run balance checks",SO(e,t,i,a)),{sufficient:f}=d,p=d.balanceRequirements;if(f)return{sufficient:f,transactionRequirements:p};const h=await JR(e,"Time to fetch available routing options",(async(e,t)=>{const n={onRamp:e.isOnRampEnabled,swap:e.isSwapEnabled,bridge:e.isBridgeEnabled},r=[];if(n.onRamp&&r.push({id:"onRamp",promise:PO()}),n.swap&&r.push({id:"swap",promise:NO(e)}),r.length>0){const e=r.map((e=>e.promise));(await Promise.allSettled(e)).forEach(((e,t)=>{const i=r[t].id;n[i]=n[i]&&"fulfilled"===e.status&&e.value}))}return n.bridge=n.bridge&&!(e=>!0===e.provider?.isPassport??!1)(t),n})(e,t));return{sufficient:f,transactionRequirements:p,router:{availableRoutingOptions:h,routingOutcome:await JR(e,"Total time to run the routing calculator",oP(e,i,d,h))}}};var uP;!function(e){e.SUCCESS="SUCCESS",e.FAILED="FAILED"}(uP||(uP={}));const lP=async(e,t)=>{let n=[];try{const r=await Promise.all(t.map((t=>e.getSigner().sendTransaction(t))));n=await Promise.all(r.map((e=>e.wait())))}catch(e){throw new DR("An error occurred while executing the approval transaction",LR.EXECUTE_APPROVAL_TRANSACTION_ERROR,{message:e.message})}for(const e of n)if(0===e.status)return{type:uP.FAILED,transactionHash:e.transactionHash,reason:"Approval transaction failed and was reverted"};return{type:uP.SUCCESS}},cP=async(e,t)=>{let n=[];try{const r=await Promise.all(t.map((t=>e.getSigner().sendTransaction(t))));n=await Promise.all(r.map((e=>e.wait())))}catch(e){throw new DR("An error occurred while executing the fulfillment transaction",LR.EXECUTE_FULFILLMENT_TRANSACTION_ERROR,{message:e.message})}for(const e of n)if(0===e.status)return{type:uP.FAILED,transactionHash:e.transactionHash,reason:"Fulfillment transaction failed and was reverted"};return{type:uP.SUCCESS}},dP=async e=>{let t=[];const n=[];for(const t of e)t.type===KS.TRANSACTION&&t.purpose===WS.FULFILL_ORDER&&n.push(t.buildTransaction());return t=await Promise.all(n),t},fP=(e,t)=>{const n=e.amount,r=Math.round(n.percentageDecimal*10**6);return t.mul(Y.from(r)).div(10**6)},pP=(e,t)=>xd(e.amount.token,t),hP=(e,t,n=18)=>{let r=Y.from(0);const i=Y.from(t),a=i.mul(1e6).div(10**6),o=[];for(const t of e){let e=Y.from(0);if(Object.hasOwn(t.amount,"percentageDecimal"))e=fP(t,i),r=r.add(e);else{if(!Object.hasOwn(t.amount,"token"))throw new DR("Unknown fee type parsed, must be percentageDecimal or token",LR.ORDER_FEE_ERROR);e=pP(t,n),r=r.add(e)}if(r.gt(a))throw new DR("The combined fees are above the allowed maximum of 100%",LR.ORDER_FEE_ERROR);e.gt(0)&&o.push({amount:e.toString(),recipient:t.recipient})}return o},mP=(e,t,n,r)=>{switch(e){case IR.ERC20:return{type:e,amount:n,contractAddress:t,spenderAddress:r};case IR.NATIVE:default:return{type:IR.NATIVE,amount:n}}},yP=async(e,t,n)=>{let r,i,a="";const o=cI;if(0===n.length)throw new DR("No orders were provided to the orders array. Please provide at least one order.",LR.FULFILL_ORDER_LISTING_ERROR);const{id:s,takerFees:u}=n[0];try{r=dO(e),i=await JR(e,"Time to fetch the listing from the orderbook",r.getListing(s));const{seaportContractAddress:t}=r.config();a=t}catch(e){throw new DR("An error occurred while getting the order listing",LR.GET_ORDER_LISTING_ERROR,{orderId:s,message:e.message})}if(0===i.result.buy.length)throw new DR("An error occurred with the get order listing",LR.GET_ORDER_LISTING_ERROR,{orderId:s,message:"No buy side tokens found on order"});const l=i.result.buy[0];let c=18;if("ERC20"===i.result.buy[0].type){const n=fO(i.result.buy[0].contractAddress,CR,t);c=await JR(e,"Time to get decimals of token contract for the buy token",n.decimals())}let d=[];u&&u.length>0&&(d=hP(u,l.amount,c));let f=[],p=[],h=[];const m=(new Date).getTime();try{const n=await JR(e,"Time to get the address from the provider",t.getSigner().getAddress()),{actions:i}=await JR(e,"Time to call fulfillOrder from the orderbook",r.fulfillOrder(s,n,d));h=i,f=await JR(e,"Time to construct the unsigned approval transactions",(async e=>{let t=[];const n=[];for(const t of e)t.type===KS.TRANSACTION&&t.purpose===WS.APPROVAL&&n.push(t.buildTransaction());return t=await Promise.all(n),t})(i))}catch(t){const n=((new Date).getTime()-m)/1e3;YR(e,"Time to call fulfillOrder from the orderbook",n)}try{p=await JR(e,"Time to construct the unsigned fulfillment transactions",dP(h))}catch{}let y=Y.from("0"),g=IR.NATIVE,b="";const v=i.result.buy;if(v.length>0)switch(v[0].type){case"NATIVE":g=IR.NATIVE;break;case"ERC20":g=IR.ERC20,b=v[0].contractAddress;break;default:throw new DR("Purchasing token type is unsupported",LR.UNSUPPORTED_TOKEN_TYPE_ERROR,{orderId:s})}v.forEach((e=>{e.type!==IR.ERC721&&(y=y.add(Y.from(e.amount)))}));i.result.fees.forEach((e=>{y=y.add(Y.from(e.amount))}));const w=[mP(g,b,y,a)],E=await JR(e,"Total time running smart checkout",sP(e,t,w,((e,t)=>t.length>0?{type:RR.TRANSACTION,transaction:t[0]}:{type:RR.GAS,gasToken:{type:OR.NATIVE,limit:Y.from(e)}})(o,p)));if(E.sufficient){const e=await lP(t,f);if(e.type===uP.FAILED)return{status:SR.FAILED,transactionHash:e.transactionHash,reason:e.reason,smartCheckoutResult:E};try{0===p.length&&(p=await dP(h))}catch(e){throw new DR("Error fetching fulfillment transaction",LR.FULFILL_ORDER_LISTING_ERROR,{message:e.message})}const n=await cP(t,p);return n.type===uP.FAILED?{status:SR.FAILED,transactionHash:n.transactionHash,reason:n.reason,smartCheckoutResult:E}:{status:SR.SUCCESS,smartCheckoutResult:E}}return{status:SR.INSUFFICIENT_FUNDS,smartCheckoutResult:E}},gP=(e,t,n)=>({type:IR.ERC721,id:e,contractAddress:t,spenderAddress:n}),bP=async(e,t,n)=>{let r,i,a="";if(0===n.length)throw new DR("No orders were provided to the orders array. Please provide at least one order.",LR.PREPARE_ORDER_LISTING_ERROR);const{buyToken:o,sellToken:s,makerFees:u}=n[0];let l=18;if(o.type===IR.ERC20){const n=new gs(o.contractAddress,JSON.stringify(CR),t);l=await JR(e,"Time to get decimals of token contract for the buy token",n.decimals())}const c=((e,t=18)=>{const n=xd(e.amount,t);return e.type===IR.NATIVE?{type:IR.NATIVE,amount:n.toString()}:{type:IR.ERC20,amount:n.toString(),contractAddress:e.contractAddress}})(o,l);try{const n=await JR(e,"Time to get the address from the provider",t.getSigner().getAddress());r=dO(e);const{seaportContractAddress:o}=r.config();a=o,i=await JR(e,"Time to prepare the listing from the orderbook",r.prepareListing({makerAddress:n,buy:c,sell:{type:IR.ERC721,contractAddress:s.collectionAddress,tokenId:s.id}}))}catch(e){throw new DR("An error occurred while preparing the listing",LR.PREPARE_ORDER_LISTING_ERROR,{message:e.message,id:s.id,collectionAddress:s.collectionAddress})}const d=[gP(s.id,s.collectionAddress,a)],f=await JR(e,"Total time running smart checkout",sP(e,t,d,{type:RR.GAS,gasToken:{type:OR.NATIVE,limit:Y.from(cI)}}));if(f.sufficient){const e=await(async e=>{let t=[],n=[];const r=[],i=[];for(const t of e)t.type===KS.TRANSACTION&&(t.purpose===WS.APPROVAL&&r.push(t.buildTransaction()),t.purpose===WS.FULFILL_ORDER&&i.push(t.buildTransaction()));return t=await Promise.all(r),n=await Promise.all(i),{approvalTransactions:t,fulfillmentTransactions:n}})(i.actions),n=await lP(t,e.approvalTransactions);if(n.type===uP.FAILED)return{status:SR.FAILED,transactionHash:n.transactionHash,reason:n.reason,smartCheckoutResult:f};const a=((e,t,n)=>{let r;for(const e of n)e.type===KS.SIGNABLE&&e.purpose===$S.CREATE_LISTING&&(r={domain:e.message.domain,types:e.message.types,value:e.message.value});if(r)return{orderHash:e,orderComponents:t,unsignedMessage:r}})(i.orderHash,i.orderComponents,i.actions);if(!a)throw new DR("The unsigned message is missing after preparing the listing",LR.SIGN_MESSAGE_ERROR,{id:s.id,collectionAddress:s.collectionAddress});const o=await(async(e,t)=>{try{const n=await e.getSigner()._signTypedData(t.unsignedMessage.domain,t.unsignedMessage.types,t.unsignedMessage.value);return{orderComponents:t.orderComponents,orderHash:t.orderHash,signedMessage:n}}catch(e){throw new DR("An error occurred while signing the message",LR.SIGN_MESSAGE_ERROR,{message:e.message})}})(t,a);let d="";const p={orderComponents:o.orderComponents,orderHash:o.orderHash,orderSignature:o.signedMessage,makerFees:[]};if(void 0!==u){const e=hP(u,c.amount,l);if(e.length!==u.length)throw new DR("One of the fees is too small, must be greater than 0.000001",LR.CREATE_ORDER_LISTING_ERROR);p.makerFees=e}try{d=(await r.createListing(p)).result.id}catch(e){throw new DR("An error occurred while creating the listing",LR.CREATE_ORDER_LISTING_ERROR,{message:e.message,collectionId:s.id,collectionAddress:s.collectionAddress})}return{status:SR.SUCCESS,orderIds:[d],smartCheckoutResult:f}}return{status:SR.INSUFFICIENT_FUNDS,smartCheckoutResult:f}};class vP{config;constructor(e){this.config=e}async feeEstimate(){const e=await this.config.remote.getConfig("onramp");return e[sR.TRANSAK]?.fees}async createWidgetUrl(e){return await this.getTransakWidgetUrl(e)}async getTransakWidgetUrl(e){let t=`${ER[this.config.environment]}?`;if(t+=`${`apiKey=${(await this.config.remote.getConfig("onramp"))[sR.TRANSAK].publishableApiKey}`}&network=immutablezkevm&defaultPaymentMethod=credit_debit_card&disablePaymentMethods=sepa_bank_transfer,gbp_bank_transfer,pm_cash_app,pm_jwire,pm_paymaya,pm_bpi,pm_ubp,pm_grabpay,pm_shopeepay,pm_gcash,pm_pix,pm_astropay,pm_pse,inr_bank_transfer&productsAvailed=buy&exchangeScreenTitle=Buy&themeColor=0D0D0D`,e.isPassport&&e.email){t+=`&email=${encodeURIComponent(e.email)}&isAutoFillUserData=true&disableWalletAddressForm=true`}return e.tokenAmount&&e.tokenSymbol?t+=`&defaultCryptoAmount=${e.tokenAmount}&cryptoCurrencyCode=${e.tokenSymbol}`:t+="&defaultCryptoCurrency=IMX",e.walletAddress&&(t+=`&walletAddress=${e.walletAddress}`),t}}const wP=()=>"__SDK_VERSION__";function EP(e){if(void 0===window)throw new Error("missing window object: please run Checkout client side");if(void 0===document)throw new Error("missing document object: please run Checkout client side");const t=function(e){const t=wP();if(void 0===e||void 0===e.major)return t;if(!Number.isInteger(e.major)||e.major<0)return t;if(void 0!==e.minor&&e.minor<0)return t;if(void 0!==e.patch&&e.patch<0)return t;if(0===e.major&&void 0===e.minor)return t;if(0===e.major&&0===e.minor&&void 0===e.patch)return t;if(0===e.major&&void 0===e.minor&&void 0===e.patch)return t;if(0===e.major&&0===e.minor&&0===e.patch)return t;let n=e.major.toString();return void 0===e.minor||(Number.isInteger(e.minor)&&(n+=`.${e.minor.toString()}`),void 0===e.patch||(Number.isInteger(e.patch)&&(n+=`.${e.patch.toString()}`),void 0===e.prerelease||"alpha"!==e.prerelease||("alpha"===e.prerelease&&(n+=`-${e.prerelease}`),void 0===e.build||Number.isInteger(e.build)&&e.build>=0&&(n+=`.${e.build.toString()}`)))),n}(e),n=document.querySelector('[data-product="checkout"]');if(n)return{loaded:!0,element:n};const r=document.createElement("script");let i=`https://cdn.jsdelivr.net/npm/@imtbl/sdk@${t}/dist/browser/checkout/widgets.js`;return r.setAttribute("data-product","checkout"),r.setAttribute("data-version",t),r.setAttribute("src",i),document.head.appendChild(r),{loaded:!1,element:r}}const TP={baseConfig:{environment:i.SANDBOX}};class AP{readOnlyProviders;config;fiatRampService;availability;constructor(e=TP){this.config=new $R(e),this.fiatRampService=new vP(this.config),this.readOnlyProviders=new Map,this.availability=OO(this.config.isDevelopment,this.config.isProduction)}async widgets(e){const t=this,n=new Promise(((n,r)=>{try{const r=EP(e.version);r.loaded?n(new ImmutableCheckoutWidgets.WidgetsFactory(t,e.config)):r.element.onload=()=>n(new ImmutableCheckoutWidgets.WidgetsFactory(t,e.config))}catch(e){r(e)}}));return console.log("factory",n),n}async createProvider(e){return await iO(e.walletProvider,e.passport)}async checkIsWalletConnected(e){return async function(e){if(!e?.provider?.request)throw new DR("Check wallet connection request failed",LR.PROVIDER_REQUEST_FAILED_ERROR,{rpcMethod:dR.CHECK_CONNECTION});let t=[];try{t=await e.provider.request({method:dR.CHECK_CONNECTION,params:[]})}catch(e){throw new DR("Check wallet connection request failed",LR.PROVIDER_REQUEST_FAILED_ERROR,{rpcMethod:dR.CHECK_CONNECTION})}return{isConnected:t&&t.length>0,walletAddress:t[0]??""}}(await oO(this.config,e.provider,{allowUnsupportedProvider:!0}))}async connect(e){const t=await oO(this.config,e.provider,{allowUnsupportedProvider:!0});await async function(e){if(!e||!e.provider?.request)throw new DR("Incompatible provider",LR.PROVIDER_REQUEST_MISSING_ERROR,{details:"Attempting to connect with an incompatible provider"});return await BR((async()=>{e.provider.request&&await e.provider.request({method:dR.CONNECT,params:[]})}),{type:LR.USER_REJECTED_REQUEST_ERROR}),e}(t);return{provider:t,network:await zR(this.config,t)}}async switchNetwork(e){const t=await oO(this.config,e.provider,{allowUnsupportedProvider:!0,allowMistmatchedChainId:!0});return await VR(this.config,t,e.chainId)}async getBalance(e){const t=await oO(this.config,e.provider);return e.contractAddress&&""!==e.contractAddress?await eO(t,e.walletAddress,e.contractAddress):await QR(this.config,t,e.walletAddress)}async getAllBalances(e){const t=await oO(this.config,e.provider);return rO(this.config,t,e.walletAddress,e.chainId)}async getNetworkAllowList(e){return await UR(this.config,e)}async getTokenAllowList(e){return await KR(this.config,e)}async getWalletAllowList(e){return await async function(e){const t=[],n=e.exclude?.map((e=>e.walletProvider))??[];let r=Object.values(pR);0!==n.length&&(r=r.filter((e=>!n.includes(e))));for(const e of r)t.push({walletProvider:e,name:e});return{wallets:t}}(e)}async sendTransaction(e){const t=await oO(this.config,e.provider);return await(async(e,t)=>{try{return{transactionResponse:await e.getSigner().sendTransaction(t)}}catch(e){if(e.code===v.INSUFFICIENT_FUNDS)throw new DR(e.message,LR.INSUFFICIENT_FUNDS);if(e.code===v.ACTION_REJECTED)throw new DR(e.message,LR.USER_REJECTED_REQUEST_ERROR);if(e.code===v.UNPREDICTABLE_GAS_LIMIT)throw new DR(e.message,LR.UNPREDICTABLE_GAS_LIMIT);throw new DR(e.message,LR.TRANSACTION_FAILED)}})(t,e.transaction)}async getNetworkInfo(e){const t=await oO(this.config,e.provider,{allowUnsupportedProvider:!0,allowMistmatchedChainId:!0});return await zR(this.config,t)}async buy(e){e.orders.length>1&&console.warn("This endpoint currently only processes the first order in the array.");const t=await oO(this.config,e.provider);return await yP(this.config,t,e.orders)}async sell(e){e.orders.length>1&&console.warn("This endpoint currently only processes the first order in the array.");const t=await oO(this.config,e.provider);return await bP(this.config,t,e.orders)}async cancel(e){console.warn("This endpoint currently only processes the first order in the array.");const t=await oO(this.config,e.provider);return await(async(e,t,n)=>{let r;if(0===n.length)throw new DR("No orderIds were provided to the orderIds array. Please provide at least one orderId.",LR.CANCEL_ORDER_LISTING_ERROR);const i=n[0];try{const n=await JR(e,"Time to get the address from the provider",t.getSigner().getAddress()),a=dO(e);r=(await JR(e,"Time to get the cancel order from the orderbook",a.cancelOrder(i,n))).unsignedCancelOrderTransaction}catch(e){throw new DR("An error occurred while cancelling the order listing",LR.CANCEL_ORDER_LISTING_ERROR,{orderId:i,message:e.message})}const a=await cP(t,[r]);return a.type===uP.FAILED?{status:SR.FAILED,transactionHash:a.transactionHash,reason:a.reason}:{status:SR.SUCCESS}})(this.config,t,e.orderIds)}async smartCheckout(e){const t=await oO(this.config,e.provider);let n=[];try{n=await async function(e,t){const n=[];t.forEach((t=>{if(t.type===IR.ERC20){const{contractAddress:r}=t;n.push(fO(r,CR,e).decimals())}}));const r=await Promise.all(n),i=t.map(((e,t)=>e.type===IR.NATIVE?{...e,amount:xd(e.amount,18)}:e.type===IR.ERC20?{...e,amount:xd(e.amount,r[t])}:e));return i}(t,e.itemRequirements)}catch{throw new DR("Failed to map item requirements",LR.ITEM_REQUIREMENTS_ERROR)}return await sP(this.config,t,n,e.transactionOrGasAmount)}static isWeb3Provider(e){return aO(e)}async gasEstimate(e){return this.readOnlyProviders=await MO(this.config,this.readOnlyProviders),await yO(e,this.readOnlyProviders,this.config)}async createFiatRampUrl(e){let t,n,r="IMX";const i=await e.web3Provider.getSigner().getAddress(),a=e.web3Provider.provider?.isPassport||!1;if(a&&e.passport){const t=await e.passport.getUserInfo();n=t?.email}const o=await KR(this.config,{type:cR.ONRAMP}),s=o.tokens?.find((t=>t.address?.toLowerCase()===e.tokenAddress?.toLowerCase()));return s&&(t=e.tokenAmount,r=s.symbol),await this.fiatRampService.createWidgetUrl({exchangeType:e.exchangeType,isPassport:a,walletAddress:i,tokenAmount:t,tokenSymbol:r,email:n})}async getExchangeFeeEstimate(){return await this.fiatRampService.feeEstimate()}async isSwapAvailable(){return this.availability.checkDexAvailability()}}var _P,xP={exports:{}},CP={},kP={exports:{}},SP={};kP.exports=function(){if(_P)return SP;_P=1;var e=Symbol.for("react.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),a=Symbol.for("react.provider"),o=Symbol.for("react.context"),s=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),l=Symbol.for("react.memo"),c=Symbol.for("react.lazy"),d=Symbol.iterator,f={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},p=Object.assign,h={};function m(e,t,n){this.props=e,this.context=t,this.refs=h,this.updater=n||f}function y(){}function g(e,t,n){this.props=e,this.context=t,this.refs=h,this.updater=n||f}m.prototype.isReactComponent={},m.prototype.setState=function(e,t){if("object"!=typeof e&&"function"!=typeof e&&null!=e)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")},m.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")},y.prototype=m.prototype;var b=g.prototype=new y;b.constructor=g,p(b,m.prototype),b.isPureReactComponent=!0;var v=Array.isArray,w=Object.prototype.hasOwnProperty,E={current:null},T={key:!0,ref:!0,__self:!0,__source:!0};function A(t,n,r){var i,a={},o=null,s=null;if(null!=n)for(i in void 0!==n.ref&&(s=n.ref),void 0!==n.key&&(o=""+n.key),n)w.call(n,i)&&!T.hasOwnProperty(i)&&(a[i]=n[i]);var u=arguments.length-2;if(1===u)a.children=r;else if(1<u){for(var l=Array(u),c=0;c<u;c++)l[c]=arguments[c+2];a.children=l}if(t&&t.defaultProps)for(i in u=t.defaultProps)void 0===a[i]&&(a[i]=u[i]);return{$$typeof:e,type:t,key:o,ref:s,props:a,_owner:E.current}}function _(t){return"object"==typeof t&&null!==t&&t.$$typeof===e}var x=/\/+/g;function C(e,t){return"object"==typeof e&&null!==e&&null!=e.key?function(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,(function(e){return t[e]}))}(""+e.key):t.toString(36)}function k(n,r,i,a,o){var s=typeof n;"undefined"!==s&&"boolean"!==s||(n=null);var u=!1;if(null===n)u=!0;else switch(s){case"string":case"number":u=!0;break;case"object":switch(n.$$typeof){case e:case t:u=!0}}if(u)return o=o(u=n),n=""===a?"."+C(u,0):a,v(o)?(i="",null!=n&&(i=n.replace(x,"$&/")+"/"),k(o,r,i,"",(function(e){return e}))):null!=o&&(_(o)&&(o=function(t,n){return{$$typeof:e,type:t.type,key:n,ref:t.ref,props:t.props,_owner:t._owner}}(o,i+(!o.key||u&&u.key===o.key?"":(""+o.key).replace(x,"$&/")+"/")+n)),r.push(o)),1;if(u=0,a=""===a?".":a+":",v(n))for(var l=0;l<n.length;l++){var c=a+C(s=n[l],l);u+=k(s,r,i,c,o)}else if(c=function(e){return null===e||"object"!=typeof e?null:"function"==typeof(e=d&&e[d]||e["@@iterator"])?e:null}(n),"function"==typeof c)for(n=c.call(n),l=0;!(s=n.next()).done;)u+=k(s=s.value,r,i,c=a+C(s,l++),o);else if("object"===s)throw r=String(n),Error("Objects are not valid as a React child (found: "+("[object Object]"===r?"object with keys {"+Object.keys(n).join(", ")+"}":r)+"). If you meant to render a collection of children, use an array instead.");return u}function S(e,t,n){if(null==e)return e;var r=[],i=0;return k(e,r,"","",(function(e){return t.call(n,e,i++)})),r}function I(e){if(-1===e._status){var t=e._result;(t=t()).then((function(t){0!==e._status&&-1!==e._status||(e._status=1,e._result=t)}),(function(t){0!==e._status&&-1!==e._status||(e._status=2,e._result=t)})),-1===e._status&&(e._status=0,e._result=t)}if(1===e._status)return e._result.default;throw e._result}var R={current:null},O={transition:null},P={ReactCurrentDispatcher:R,ReactCurrentBatchConfig:O,ReactCurrentOwner:E};return SP.Children={map:S,forEach:function(e,t,n){S(e,(function(){t.apply(this,arguments)}),n)},count:function(e){var t=0;return S(e,(function(){t++})),t},toArray:function(e){return S(e,(function(e){return e}))||[]},only:function(e){if(!_(e))throw Error("React.Children.only expected to receive a single React element child.");return e}},SP.Component=m,SP.Fragment=n,SP.Profiler=i,SP.PureComponent=g,SP.StrictMode=r,SP.Suspense=u,SP.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=P,SP.cloneElement=function(t,n,r){if(null==t)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+t+".");var i=p({},t.props),a=t.key,o=t.ref,s=t._owner;if(null!=n){if(void 0!==n.ref&&(o=n.ref,s=E.current),void 0!==n.key&&(a=""+n.key),t.type&&t.type.defaultProps)var u=t.type.defaultProps;for(l in n)w.call(n,l)&&!T.hasOwnProperty(l)&&(i[l]=void 0===n[l]&&void 0!==u?u[l]:n[l])}var l=arguments.length-2;if(1===l)i.children=r;else if(1<l){u=Array(l);for(var c=0;c<l;c++)u[c]=arguments[c+2];i.children=u}return{$$typeof:e,type:t.type,key:a,ref:o,props:i,_owner:s}},SP.createContext=function(e){return(e={$$typeof:o,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null}).Provider={$$typeof:a,_context:e},e.Consumer=e},SP.createElement=A,SP.createFactory=function(e){var t=A.bind(null,e);return t.type=e,t},SP.createRef=function(){return{current:null}},SP.forwardRef=function(e){return{$$typeof:s,render:e}},SP.isValidElement=_,SP.lazy=function(e){return{$$typeof:c,_payload:{_status:-1,_result:e},_init:I}},SP.memo=function(e,t){return{$$typeof:l,type:e,compare:void 0===t?null:t}},SP.startTransition=function(e){var t=O.transition;O.transition={};try{e()}finally{O.transition=t}},SP.unstable_act=function(){throw Error("act(...) is not supported in production builds of React.")},SP.useCallback=function(e,t){return R.current.useCallback(e,t)},SP.useContext=function(e){return R.current.useContext(e)},SP.useDebugValue=function(){},SP.useDeferredValue=function(e){return R.current.useDeferredValue(e)},SP.useEffect=function(e,t){return R.current.useEffect(e,t)},SP.useId=function(){return R.current.useId()},SP.useImperativeHandle=function(e,t,n){return R.current.useImperativeHandle(e,t,n)},SP.useInsertionEffect=function(e,t){return R.current.useInsertionEffect(e,t)},SP.useLayoutEffect=function(e,t){return R.current.useLayoutEffect(e,t)},SP.useMemo=function(e,t){return R.current.useMemo(e,t)},SP.useReducer=function(e,t,n){return R.current.useReducer(e,t,n)},SP.useRef=function(e){return R.current.useRef(e)},SP.useState=function(e){return R.current.useState(e)},SP.useSyncExternalStore=function(e,t,n){return R.current.useSyncExternalStore(e,t,n)},SP.useTransition=function(){return R.current.useTransition()},SP.version="18.2.0",SP}();var IP,RP=kP.exports,OP=s(RP),PP=r({__proto__:null,default:OP},[RP]);xP.exports=function(){if(IP)return CP;IP=1;var e=RP,t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,i=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,a={key:!0,ref:!0,__self:!0,__source:!0};function o(e,n,o){var s,u={},l=null,c=null;for(s in void 0!==o&&(l=""+o),void 0!==n.key&&(l=""+n.key),void 0!==n.ref&&(c=n.ref),n)r.call(n,s)&&!a.hasOwnProperty(s)&&(u[s]=n[s]);if(e&&e.defaultProps)for(s in n=e.defaultProps)void 0===u[s]&&(u[s]=n[s]);return{$$typeof:t,type:e,key:l,ref:c,props:u,_owner:i.current}}return CP.Fragment=n,CP.jsx=o,CP.jsxs=o,CP}();var NP,MP,LP,FP=xP.exports,DP={exports:{}},BP={},jP={exports:{}},UP={};function zP(){return MP||(MP=1,jP.exports=(NP||(NP=1,function(e){function t(e,t){var n=e.length;e.push(t);e:for(;0<n;){var r=n-1>>>1,a=e[r];if(!(0<i(a,t)))break e;e[r]=t,e[n]=a,n=r}}function n(e){return 0===e.length?null:e[0]}function r(e){if(0===e.length)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;e:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,u=e[s],l=s+1,c=e[l];if(0>i(u,n))l<a&&0>i(c,u)?(e[r]=c,e[l]=n,r=l):(e[r]=u,e[s]=n,r=s);else{if(!(l<a&&0>i(c,n)))break e;e[r]=c,e[l]=n,r=l}}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return 0!==n?n:e.id-t.id}if("object"==typeof performance&&"function"==typeof performance.now){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var u=[],l=[],c=1,d=null,f=3,p=!1,h=!1,m=!1,y="function"==typeof setTimeout?setTimeout:null,g="function"==typeof clearTimeout?clearTimeout:null,b="undefined"!=typeof setImmediate?setImmediate:null;function v(e){for(var i=n(l);null!==i;){if(null===i.callback)r(l);else{if(!(i.startTime<=e))break;r(l),i.sortIndex=i.expirationTime,t(u,i)}i=n(l)}}function w(e){if(m=!1,v(e),!h)if(null!==n(u))h=!0,P(E);else{var t=n(l);null!==t&&N(w,t.startTime-e)}}function E(t,i){h=!1,m&&(m=!1,g(x),x=-1),p=!0;var a=f;try{for(v(i),d=n(u);null!==d&&(!(d.expirationTime>i)||t&&!S());){var o=d.callback;if("function"==typeof o){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=i);i=e.unstable_now(),"function"==typeof s?d.callback=s:d===n(u)&&r(u),v(i)}else r(u);d=n(u)}if(null!==d)var c=!0;else{var y=n(l);null!==y&&N(w,y.startTime-i),c=!1}return c}finally{d=null,f=a,p=!1}}"undefined"!=typeof navigator&&void 0!==navigator.scheduling&&void 0!==navigator.scheduling.isInputPending&&navigator.scheduling.isInputPending.bind(navigator.scheduling);var T,A=!1,_=null,x=-1,C=5,k=-1;function S(){return!(e.unstable_now()-k<C)}function I(){if(null!==_){var t=e.unstable_now();k=t;var n=!0;try{n=_(!0,t)}finally{n?T():(A=!1,_=null)}}else A=!1}if("function"==typeof b)T=function(){b(I)};else if("undefined"!=typeof MessageChannel){var R=new MessageChannel,O=R.port2;R.port1.onmessage=I,T=function(){O.postMessage(null)}}else T=function(){y(I,0)};function P(e){_=e,A||(A=!0,T())}function N(t,n){x=y((function(){t(e.unstable_now())}),n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_continueExecution=function(){h||p||(h=!0,P(E))},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):C=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_getFirstCallbackNode=function(){return n(u)},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(a="object"==typeof a&&null!==a&&"number"==typeof(a=a.delay)&&0<a?o+a:o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return r={id:c++,callback:i,priorityLevel:r,startTime:a,expirationTime:s=a+s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),null===n(u)&&r===n(l)&&(m?(g(x),x=-1):m=!0,N(w,a-o))):(r.sortIndex=s,t(u,r),h||p||(h=!0,P(E))),r},e.unstable_shouldYield=S,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}}(UP)),UP)),jP.exports}
|
|
35
|
+
function(e){var t=n,r=t.lib,i=r.WordArray,a=r.Hasher,o=t.algo,s=i.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),u=i.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),l=i.create([11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),c=i.create([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),d=i.create([0,1518500249,1859775393,2400959708,2840853838]),f=i.create([1352829926,1548603684,1836072691,2053994217,0]),p=o.RIPEMD160=a.extend({_doReset:function(){this._hash=i.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(e,t){for(var n=0;n<16;n++){var r=t+n,i=e[r];e[r]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8)}var a,o,p,w,E,T,A,_,x,C,k,S=this._hash.words,I=d.words,R=f.words,O=s.words,P=u.words,N=l.words,M=c.words;for(T=a=S[0],A=o=S[1],_=p=S[2],x=w=S[3],C=E=S[4],n=0;n<80;n+=1)k=a+e[t+O[n]]|0,k+=n<16?h(o,p,w)+I[0]:n<32?m(o,p,w)+I[1]:n<48?y(o,p,w)+I[2]:n<64?g(o,p,w)+I[3]:b(o,p,w)+I[4],k=(k=v(k|=0,N[n]))+E|0,a=E,E=w,w=v(p,10),p=o,o=k,k=T+e[t+P[n]]|0,k+=n<16?b(A,_,x)+R[0]:n<32?g(A,_,x)+R[1]:n<48?y(A,_,x)+R[2]:n<64?m(A,_,x)+R[3]:h(A,_,x)+R[4],k=(k=v(k|=0,M[n]))+C|0,T=C,C=x,x=v(_,10),_=A,A=k;k=S[1]+p+x|0,S[1]=S[2]+w+C|0,S[2]=S[3]+E+T|0,S[3]=S[4]+a+A|0,S[4]=S[0]+o+_|0,S[0]=k},_doFinalize:function(){var e=this._data,t=e.words,n=8*this._nDataBytes,r=8*e.sigBytes;t[r>>>5]|=128<<24-r%32,t[14+(r+64>>>9<<4)]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8),e.sigBytes=4*(t.length+1),this._process();for(var i=this._hash,a=i.words,o=0;o<5;o++){var s=a[o];a[o]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8)}return i},clone:function(){var e=a.clone.call(this);return e._hash=this._hash.clone(),e}});function h(e,t,n){return e^t^n}function m(e,t,n){return e&t|~e&n}function y(e,t,n){return(e|~t)^n}function g(e,t,n){return e&n|t&~n}function b(e,t,n){return e^(t|~n)}function v(e,t){return e<<t|e>>>32-t}t.RIPEMD160=a._createHelper(p),t.HmacRIPEMD160=a._createHmacHelper(p)}(),n.RIPEMD160)}(uC)),dC(),fC||(fC=1,function(e,t){var n;e.exports=(n=kx(),Zx(),dC(),function(){var e=n,t=e.lib,r=t.Base,i=t.WordArray,a=e.algo,o=a.SHA1,s=a.HMAC,u=a.PBKDF2=r.extend({cfg:r.extend({keySize:4,hasher:o,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var n=this.cfg,r=s.create(n.hasher,e),a=i.create(),o=i.create([1]),u=a.words,l=o.words,c=n.keySize,d=n.iterations;u.length<c;){var f=r.update(t).finalize(o);r.reset();for(var p=f.words,h=p.length,m=f,y=1;y<d;y++){m=r.finalize(m),r.reset();for(var g=m.words,b=0;b<h;b++)p[b]^=g[b]}a.concat(f),l[0]++}return a.sigBytes=4*c,a}});e.PBKDF2=function(e,t,n){return u.create(n).compute(e,t)}}(),n.PBKDF2)}(pC)),yC(),vC(),TC(),xC(),SC(),OC(),PC||(PC=1,function(e,t){var n,r;e.exports=(r=kx(),vC(),r.mode.ECB=((n=r.lib.BlockCipherMode.extend()).Encryptor=n.extend({processBlock:function(e,t){this._cipher.encryptBlock(e,t)}}),n.Decryptor=n.extend({processBlock:function(e,t){this._cipher.decryptBlock(e,t)}}),n),r.mode.ECB)}(NC)),MC||(MC=1,function(e,t){var n;e.exports=(n=kx(),vC(),n.pad.AnsiX923={pad:function(e,t){var n=e.sigBytes,r=4*t,i=r-n%r,a=n+i-1;e.clamp(),e.words[a>>>2]|=i<<24-a%4*8,e.sigBytes+=i},unpad:function(e){var t=255&e.words[e.sigBytes-1>>>2];e.sigBytes-=t}},n.pad.Ansix923)}(LC)),FC||(FC=1,function(e,t){var n;e.exports=(n=kx(),vC(),n.pad.Iso10126={pad:function(e,t){var r=4*t,i=r-e.sigBytes%r;e.concat(n.lib.WordArray.random(i-1)).concat(n.lib.WordArray.create([i<<24],1))},unpad:function(e){var t=255&e.words[e.sigBytes-1>>>2];e.sigBytes-=t}},n.pad.Iso10126)}(DC)),BC||(BC=1,function(e,t){var n;e.exports=(n=kx(),vC(),n.pad.Iso97971={pad:function(e,t){e.concat(n.lib.WordArray.create([2147483648],1)),n.pad.ZeroPadding.pad(e,t)},unpad:function(e){n.pad.ZeroPadding.unpad(e),e.sigBytes--}},n.pad.Iso97971)}(jC)),UC||(UC=1,function(e,t){var n;e.exports=(n=kx(),vC(),n.pad.ZeroPadding={pad:function(e,t){var n=4*t;e.clamp(),e.sigBytes+=n-(e.sigBytes%n||n)},unpad:function(e){for(var t=e.words,n=e.sigBytes-1;!(t[n>>>2]>>>24-n%4*8&255);)n--;e.sigBytes=n+1}},n.pad.ZeroPadding)}(zC)),VC||(VC=1,function(e,t){var n;e.exports=(n=kx(),vC(),n.pad.NoPadding={pad:function(){},unpad:function(){}},n.pad.NoPadding)}(HC)),qC||(qC=1,function(e,t){var n;e.exports=(n=kx(),vC(),function(e){var t=n,r=t.lib.CipherParams,i=t.enc.Hex;t.format.Hex={stringify:function(e){return e.ciphertext.toString(i)},parse:function(e){var t=i.parse(e);return r.create({ciphertext:t})}}}(),n.format.Hex)}(GC)),WC||(WC=1,function(e,t){var n;e.exports=(n=kx(),qx(),$x(),yC(),vC(),function(){var e=n,t=e.lib.BlockCipher,r=e.algo,i=[],a=[],o=[],s=[],u=[],l=[],c=[],d=[],f=[],p=[];!function(){for(var e=[],t=0;t<256;t++)e[t]=t<128?t<<1:t<<1^283;var n=0,r=0;for(t=0;t<256;t++){var h=r^r<<1^r<<2^r<<3^r<<4;h=h>>>8^255&h^99,i[n]=h,a[h]=n;var m=e[n],y=e[m],g=e[y],b=257*e[h]^16843008*h;o[n]=b<<24|b>>>8,s[n]=b<<16|b>>>16,u[n]=b<<8|b>>>24,l[n]=b,b=16843009*g^65537*y^257*m^16843008*n,c[h]=b<<24|b>>>8,d[h]=b<<16|b>>>16,f[h]=b<<8|b>>>24,p[h]=b,n?(n=m^e[e[e[g^m]]],r^=e[e[r]]):n=r=1}}();var h=[0,1,2,4,8,16,32,64,128,27,54],m=r.AES=t.extend({_doReset:function(){if(!this._nRounds||this._keyPriorReset!==this._key){for(var e=this._keyPriorReset=this._key,t=e.words,n=e.sigBytes/4,r=4*((this._nRounds=n+6)+1),a=this._keySchedule=[],o=0;o<r;o++)if(o<n)a[o]=t[o];else{var s=a[o-1];o%n?n>6&&o%n==4&&(s=i[s>>>24]<<24|i[s>>>16&255]<<16|i[s>>>8&255]<<8|i[255&s]):(s=i[(s=s<<8|s>>>24)>>>24]<<24|i[s>>>16&255]<<16|i[s>>>8&255]<<8|i[255&s],s^=h[o/n|0]<<24),a[o]=a[o-n]^s}for(var u=this._invKeySchedule=[],l=0;l<r;l++)o=r-l,s=l%4?a[o]:a[o-4],u[l]=l<4||o<=4?s:c[i[s>>>24]]^d[i[s>>>16&255]]^f[i[s>>>8&255]]^p[i[255&s]]}},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._keySchedule,o,s,u,l,i)},decryptBlock:function(e,t){var n=e[t+1];e[t+1]=e[t+3],e[t+3]=n,this._doCryptBlock(e,t,this._invKeySchedule,c,d,f,p,a),n=e[t+1],e[t+1]=e[t+3],e[t+3]=n},_doCryptBlock:function(e,t,n,r,i,a,o,s){for(var u=this._nRounds,l=e[t]^n[0],c=e[t+1]^n[1],d=e[t+2]^n[2],f=e[t+3]^n[3],p=4,h=1;h<u;h++){var m=r[l>>>24]^i[c>>>16&255]^a[d>>>8&255]^o[255&f]^n[p++],y=r[c>>>24]^i[d>>>16&255]^a[f>>>8&255]^o[255&l]^n[p++],g=r[d>>>24]^i[f>>>16&255]^a[l>>>8&255]^o[255&c]^n[p++],b=r[f>>>24]^i[l>>>16&255]^a[c>>>8&255]^o[255&d]^n[p++];l=m,c=y,d=g,f=b}m=(s[l>>>24]<<24|s[c>>>16&255]<<16|s[d>>>8&255]<<8|s[255&f])^n[p++],y=(s[c>>>24]<<24|s[d>>>16&255]<<16|s[f>>>8&255]<<8|s[255&l])^n[p++],g=(s[d>>>24]<<24|s[f>>>16&255]<<16|s[l>>>8&255]<<8|s[255&c])^n[p++],b=(s[f>>>24]<<24|s[l>>>16&255]<<16|s[c>>>8&255]<<8|s[255&d])^n[p++],e[t]=m,e[t+1]=y,e[t+2]=g,e[t+3]=b},keySize:8});e.AES=t._createHelper(m)}(),n.AES)}($C)),KC||(KC=1,function(e,t){var n;e.exports=(n=kx(),qx(),$x(),yC(),vC(),function(){var e=n,t=e.lib,r=t.WordArray,i=t.BlockCipher,a=e.algo,o=[57,49,41,33,25,17,9,1,58,50,42,34,26,18,10,2,59,51,43,35,27,19,11,3,60,52,44,36,63,55,47,39,31,23,15,7,62,54,46,38,30,22,14,6,61,53,45,37,29,21,13,5,28,20,12,4],s=[14,17,11,24,1,5,3,28,15,6,21,10,23,19,12,4,26,8,16,7,27,20,13,2,41,52,31,37,47,55,30,40,51,45,33,48,44,49,39,56,34,53,46,42,50,36,29,32],u=[1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28],l=[{0:8421888,268435456:32768,536870912:8421378,805306368:2,1073741824:512,1342177280:8421890,1610612736:8389122,1879048192:8388608,2147483648:514,2415919104:8389120,2684354560:33280,2952790016:8421376,3221225472:32770,3489660928:8388610,3758096384:0,4026531840:33282,134217728:0,402653184:8421890,671088640:33282,939524096:32768,1207959552:8421888,1476395008:512,1744830464:8421378,2013265920:2,2281701376:8389120,2550136832:33280,2818572288:8421376,3087007744:8389122,3355443200:8388610,3623878656:32770,3892314112:514,4160749568:8388608,1:32768,268435457:2,536870913:8421888,805306369:8388608,1073741825:8421378,1342177281:33280,1610612737:512,1879048193:8389122,2147483649:8421890,2415919105:8421376,2684354561:8388610,2952790017:33282,3221225473:514,3489660929:8389120,3758096385:32770,4026531841:0,134217729:8421890,402653185:8421376,671088641:8388608,939524097:512,1207959553:32768,1476395009:8388610,1744830465:2,2013265921:33282,2281701377:32770,2550136833:8389122,2818572289:514,3087007745:8421888,3355443201:8389120,3623878657:0,3892314113:33280,4160749569:8421378},{0:1074282512,16777216:16384,33554432:524288,50331648:1074266128,67108864:1073741840,83886080:1074282496,100663296:1073758208,117440512:16,134217728:540672,150994944:1073758224,167772160:1073741824,184549376:540688,201326592:524304,218103808:0,234881024:16400,251658240:1074266112,8388608:1073758208,25165824:540688,41943040:16,58720256:1073758224,75497472:1074282512,92274688:1073741824,109051904:524288,125829120:1074266128,142606336:524304,159383552:0,176160768:16384,192937984:1074266112,209715200:1073741840,226492416:540672,243269632:1074282496,260046848:16400,268435456:0,285212672:1074266128,301989888:1073758224,318767104:1074282496,335544320:1074266112,352321536:16,369098752:540688,385875968:16384,402653184:16400,419430400:524288,436207616:524304,452984832:1073741840,469762048:540672,486539264:1073758208,503316480:1073741824,520093696:1074282512,276824064:540688,293601280:524288,310378496:1074266112,327155712:16384,343932928:1073758208,360710144:1074282512,377487360:16,394264576:1073741824,411041792:1074282496,427819008:1073741840,444596224:1073758224,461373440:524304,478150656:0,494927872:16400,511705088:1074266128,528482304:540672},{0:260,1048576:0,2097152:67109120,3145728:65796,4194304:65540,5242880:67108868,6291456:67174660,7340032:67174400,8388608:67108864,9437184:67174656,10485760:65792,11534336:67174404,12582912:67109124,13631488:65536,14680064:4,15728640:256,524288:67174656,1572864:67174404,2621440:0,3670016:67109120,4718592:67108868,5767168:65536,6815744:65540,7864320:260,8912896:4,9961472:256,11010048:67174400,12058624:65796,13107200:65792,14155776:67109124,15204352:67174660,16252928:67108864,16777216:67174656,17825792:65540,18874368:65536,19922944:67109120,20971520:256,22020096:67174660,23068672:67108868,24117248:0,25165824:67109124,26214400:67108864,27262976:4,28311552:65792,29360128:67174400,30408704:260,31457280:65796,32505856:67174404,17301504:67108864,18350080:260,19398656:67174656,20447232:0,21495808:65540,22544384:67109120,23592960:256,24641536:67174404,25690112:65536,26738688:67174660,27787264:65796,28835840:67108868,29884416:67109124,30932992:67174400,31981568:4,33030144:65792},{0:2151682048,65536:2147487808,131072:4198464,196608:2151677952,262144:0,327680:4198400,393216:2147483712,458752:4194368,524288:2147483648,589824:4194304,655360:64,720896:2147487744,786432:2151678016,851968:4160,917504:4096,983040:2151682112,32768:2147487808,98304:64,163840:2151678016,229376:2147487744,294912:4198400,360448:2151682112,425984:0,491520:2151677952,557056:4096,622592:2151682048,688128:4194304,753664:4160,819200:2147483648,884736:4194368,950272:4198464,1015808:2147483712,1048576:4194368,1114112:4198400,1179648:2147483712,1245184:0,1310720:4160,1376256:2151678016,1441792:2151682048,1507328:2147487808,1572864:2151682112,1638400:2147483648,1703936:2151677952,1769472:4198464,1835008:2147487744,1900544:4194304,1966080:64,2031616:4096,1081344:2151677952,1146880:2151682112,1212416:0,1277952:4198400,1343488:4194368,1409024:2147483648,1474560:2147487808,1540096:64,1605632:2147483712,1671168:4096,1736704:2147487744,1802240:2151678016,1867776:4160,1933312:2151682048,1998848:4194304,2064384:4198464},{0:128,4096:17039360,8192:262144,12288:536870912,16384:537133184,20480:16777344,24576:553648256,28672:262272,32768:16777216,36864:537133056,40960:536871040,45056:553910400,49152:553910272,53248:0,57344:17039488,61440:553648128,2048:17039488,6144:553648256,10240:128,14336:17039360,18432:262144,22528:537133184,26624:553910272,30720:536870912,34816:537133056,38912:0,43008:553910400,47104:16777344,51200:536871040,55296:553648128,59392:16777216,63488:262272,65536:262144,69632:128,73728:536870912,77824:553648256,81920:16777344,86016:553910272,90112:537133184,94208:16777216,98304:553910400,102400:553648128,106496:17039360,110592:537133056,114688:262272,118784:536871040,122880:0,126976:17039488,67584:553648256,71680:16777216,75776:17039360,79872:537133184,83968:536870912,88064:17039488,92160:128,96256:553910272,100352:262272,104448:553910400,108544:0,112640:553648128,116736:16777344,120832:262144,124928:537133056,129024:536871040},{0:268435464,256:8192,512:270532608,768:270540808,1024:268443648,1280:2097152,1536:2097160,1792:268435456,2048:0,2304:268443656,2560:2105344,2816:8,3072:270532616,3328:2105352,3584:8200,3840:270540800,128:270532608,384:270540808,640:8,896:2097152,1152:2105352,1408:268435464,1664:268443648,1920:8200,2176:2097160,2432:8192,2688:268443656,2944:270532616,3200:0,3456:270540800,3712:2105344,3968:268435456,4096:268443648,4352:270532616,4608:270540808,4864:8200,5120:2097152,5376:268435456,5632:268435464,5888:2105344,6144:2105352,6400:0,6656:8,6912:270532608,7168:8192,7424:268443656,7680:270540800,7936:2097160,4224:8,4480:2105344,4736:2097152,4992:268435464,5248:268443648,5504:8200,5760:270540808,6016:270532608,6272:270540800,6528:270532616,6784:8192,7040:2105352,7296:2097160,7552:0,7808:268435456,8064:268443656},{0:1048576,16:33555457,32:1024,48:1049601,64:34604033,80:0,96:1,112:34603009,128:33555456,144:1048577,160:33554433,176:34604032,192:34603008,208:1025,224:1049600,240:33554432,8:34603009,24:0,40:33555457,56:34604032,72:1048576,88:33554433,104:33554432,120:1025,136:1049601,152:33555456,168:34603008,184:1048577,200:1024,216:34604033,232:1,248:1049600,256:33554432,272:1048576,288:33555457,304:34603009,320:1048577,336:33555456,352:34604032,368:1049601,384:1025,400:34604033,416:1049600,432:1,448:0,464:34603008,480:33554433,496:1024,264:1049600,280:33555457,296:34603009,312:1,328:33554432,344:1048576,360:1025,376:34604032,392:33554433,408:34603008,424:0,440:34604033,456:1049601,472:1024,488:33555456,504:1048577},{0:134219808,1:131072,2:134217728,3:32,4:131104,5:134350880,6:134350848,7:2048,8:134348800,9:134219776,10:133120,11:134348832,12:2080,13:0,14:134217760,15:133152,2147483648:2048,2147483649:134350880,2147483650:134219808,2147483651:134217728,2147483652:134348800,2147483653:133120,2147483654:133152,2147483655:32,2147483656:134217760,2147483657:2080,2147483658:131104,2147483659:134350848,2147483660:0,2147483661:134348832,2147483662:134219776,2147483663:131072,16:133152,17:134350848,18:32,19:2048,20:134219776,21:134217760,22:134348832,23:131072,24:0,25:131104,26:134348800,27:134219808,28:134350880,29:133120,30:2080,31:134217728,2147483664:131072,2147483665:2048,2147483666:134348832,2147483667:133152,2147483668:32,2147483669:134348800,2147483670:134217728,2147483671:134219808,2147483672:134350880,2147483673:134217760,2147483674:134219776,2147483675:0,2147483676:133120,2147483677:2080,2147483678:131104,2147483679:134350848}],c=[4160749569,528482304,33030144,2064384,129024,8064,504,2147483679],d=a.DES=i.extend({_doReset:function(){for(var e=this._key.words,t=[],n=0;n<56;n++){var r=o[n]-1;t[n]=e[r>>>5]>>>31-r%32&1}for(var i=this._subKeys=[],a=0;a<16;a++){var l=i[a]=[],c=u[a];for(n=0;n<24;n++)l[n/6|0]|=t[(s[n]-1+c)%28]<<31-n%6,l[4+(n/6|0)]|=t[28+(s[n+24]-1+c)%28]<<31-n%6;for(l[0]=l[0]<<1|l[0]>>>31,n=1;n<7;n++)l[n]=l[n]>>>4*(n-1)+3;l[7]=l[7]<<5|l[7]>>>27}var d=this._invSubKeys=[];for(n=0;n<16;n++)d[n]=i[15-n]},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._subKeys)},decryptBlock:function(e,t){this._doCryptBlock(e,t,this._invSubKeys)},_doCryptBlock:function(e,t,n){this._lBlock=e[t],this._rBlock=e[t+1],f.call(this,4,252645135),f.call(this,16,65535),p.call(this,2,858993459),p.call(this,8,16711935),f.call(this,1,1431655765);for(var r=0;r<16;r++){for(var i=n[r],a=this._lBlock,o=this._rBlock,s=0,u=0;u<8;u++)s|=l[u][((o^i[u])&c[u])>>>0];this._lBlock=o,this._rBlock=a^s}var d=this._lBlock;this._lBlock=this._rBlock,this._rBlock=d,f.call(this,1,1431655765),p.call(this,8,16711935),p.call(this,2,858993459),f.call(this,16,65535),f.call(this,4,252645135),e[t]=this._lBlock,e[t+1]=this._rBlock},keySize:2,ivSize:2,blockSize:2});function f(e,t){var n=(this._lBlock>>>e^this._rBlock)&t;this._rBlock^=n,this._lBlock^=n<<e}function p(e,t){var n=(this._rBlock>>>e^this._lBlock)&t;this._lBlock^=n,this._rBlock^=n<<e}e.DES=i._createHelper(d);var h=a.TripleDES=i.extend({_doReset:function(){var e=this._key.words;this._des1=d.createEncryptor(r.create(e.slice(0,2))),this._des2=d.createEncryptor(r.create(e.slice(2,4))),this._des3=d.createEncryptor(r.create(e.slice(4,6)))},encryptBlock:function(e,t){this._des1.encryptBlock(e,t),this._des2.decryptBlock(e,t),this._des3.encryptBlock(e,t)},decryptBlock:function(e,t){this._des3.decryptBlock(e,t),this._des2.encryptBlock(e,t),this._des1.decryptBlock(e,t)},keySize:6,ivSize:2,blockSize:2});e.TripleDES=i._createHelper(h)}(),n.TripleDES)}(XC)),ZC||(ZC=1,function(e,t){var n;e.exports=(n=kx(),qx(),$x(),yC(),vC(),function(){var e=n,t=e.lib.StreamCipher,r=e.algo,i=r.RC4=t.extend({_doReset:function(){for(var e=this._key,t=e.words,n=e.sigBytes,r=this._S=[],i=0;i<256;i++)r[i]=i;i=0;for(var a=0;i<256;i++){var o=i%n,s=t[o>>>2]>>>24-o%4*8&255;a=(a+r[i]+s)%256;var u=r[i];r[i]=r[a],r[a]=u}this._i=this._j=0},_doProcessBlock:function(e,t){e[t]^=a.call(this)},keySize:8,ivSize:0});function a(){for(var e=this._S,t=this._i,n=this._j,r=0,i=0;i<4;i++){n=(n+e[t=(t+1)%256])%256;var a=e[t];e[t]=e[n],e[n]=a,r|=e[(e[t]+e[n])%256]<<24-8*i}return this._i=t,this._j=n,r}e.RC4=t._createHelper(i);var o=r.RC4Drop=i.extend({cfg:i.cfg.extend({drop:192}),_doReset:function(){i._doReset.call(this);for(var e=this.cfg.drop;e>0;e--)a.call(this)}});e.RC4Drop=t._createHelper(o)}(),n.RC4)}(YC)),JC||(JC=1,function(e,t){var n;e.exports=(n=kx(),qx(),$x(),yC(),vC(),function(){var e=n,t=e.lib.StreamCipher,r=e.algo,i=[],a=[],o=[],s=r.Rabbit=t.extend({_doReset:function(){for(var e=this._key.words,t=this.cfg.iv,n=0;n<4;n++)e[n]=16711935&(e[n]<<8|e[n]>>>24)|4278255360&(e[n]<<24|e[n]>>>8);var r=this._X=[e[0],e[3]<<16|e[2]>>>16,e[1],e[0]<<16|e[3]>>>16,e[2],e[1]<<16|e[0]>>>16,e[3],e[2]<<16|e[1]>>>16],i=this._C=[e[2]<<16|e[2]>>>16,4294901760&e[0]|65535&e[1],e[3]<<16|e[3]>>>16,4294901760&e[1]|65535&e[2],e[0]<<16|e[0]>>>16,4294901760&e[2]|65535&e[3],e[1]<<16|e[1]>>>16,4294901760&e[3]|65535&e[0]];for(this._b=0,n=0;n<4;n++)u.call(this);for(n=0;n<8;n++)i[n]^=r[n+4&7];if(t){var a=t.words,o=a[0],s=a[1],l=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),c=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),d=l>>>16|4294901760&c,f=c<<16|65535&l;for(i[0]^=l,i[1]^=d,i[2]^=c,i[3]^=f,i[4]^=l,i[5]^=d,i[6]^=c,i[7]^=f,n=0;n<4;n++)u.call(this)}},_doProcessBlock:function(e,t){var n=this._X;u.call(this),i[0]=n[0]^n[5]>>>16^n[3]<<16,i[1]=n[2]^n[7]>>>16^n[5]<<16,i[2]=n[4]^n[1]>>>16^n[7]<<16,i[3]=n[6]^n[3]>>>16^n[1]<<16;for(var r=0;r<4;r++)i[r]=16711935&(i[r]<<8|i[r]>>>24)|4278255360&(i[r]<<24|i[r]>>>8),e[t+r]^=i[r]},blockSize:4,ivSize:2});function u(){for(var e=this._X,t=this._C,n=0;n<8;n++)a[n]=t[n];for(t[0]=t[0]+1295307597+this._b|0,t[1]=t[1]+3545052371+(t[0]>>>0<a[0]>>>0?1:0)|0,t[2]=t[2]+886263092+(t[1]>>>0<a[1]>>>0?1:0)|0,t[3]=t[3]+1295307597+(t[2]>>>0<a[2]>>>0?1:0)|0,t[4]=t[4]+3545052371+(t[3]>>>0<a[3]>>>0?1:0)|0,t[5]=t[5]+886263092+(t[4]>>>0<a[4]>>>0?1:0)|0,t[6]=t[6]+1295307597+(t[5]>>>0<a[5]>>>0?1:0)|0,t[7]=t[7]+3545052371+(t[6]>>>0<a[6]>>>0?1:0)|0,this._b=t[7]>>>0<a[7]>>>0?1:0,n=0;n<8;n++){var r=e[n]+t[n],i=65535&r,s=r>>>16,u=((i*i>>>17)+i*s>>>15)+s*s,l=((4294901760&r)*r|0)+((65535&r)*r|0);o[n]=u^l}e[0]=o[0]+(o[7]<<16|o[7]>>>16)+(o[6]<<16|o[6]>>>16)|0,e[1]=o[1]+(o[0]<<8|o[0]>>>24)+o[7]|0,e[2]=o[2]+(o[1]<<16|o[1]>>>16)+(o[0]<<16|o[0]>>>16)|0,e[3]=o[3]+(o[2]<<8|o[2]>>>24)+o[1]|0,e[4]=o[4]+(o[3]<<16|o[3]>>>16)+(o[2]<<16|o[2]>>>16)|0,e[5]=o[5]+(o[4]<<8|o[4]>>>24)+o[3]|0,e[6]=o[6]+(o[5]<<16|o[5]>>>16)+(o[4]<<16|o[4]>>>16)|0,e[7]=o[7]+(o[6]<<8|o[6]>>>24)+o[5]|0}e.Rabbit=t._createHelper(s)}(),n.Rabbit)}(QC)),ek||(ek=1,function(e,t){var n;e.exports=(n=kx(),qx(),$x(),yC(),vC(),function(){var e=n,t=e.lib.StreamCipher,r=e.algo,i=[],a=[],o=[],s=r.RabbitLegacy=t.extend({_doReset:function(){var e=this._key.words,t=this.cfg.iv,n=this._X=[e[0],e[3]<<16|e[2]>>>16,e[1],e[0]<<16|e[3]>>>16,e[2],e[1]<<16|e[0]>>>16,e[3],e[2]<<16|e[1]>>>16],r=this._C=[e[2]<<16|e[2]>>>16,4294901760&e[0]|65535&e[1],e[3]<<16|e[3]>>>16,4294901760&e[1]|65535&e[2],e[0]<<16|e[0]>>>16,4294901760&e[2]|65535&e[3],e[1]<<16|e[1]>>>16,4294901760&e[3]|65535&e[0]];this._b=0;for(var i=0;i<4;i++)u.call(this);for(i=0;i<8;i++)r[i]^=n[i+4&7];if(t){var a=t.words,o=a[0],s=a[1],l=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),c=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),d=l>>>16|4294901760&c,f=c<<16|65535&l;for(r[0]^=l,r[1]^=d,r[2]^=c,r[3]^=f,r[4]^=l,r[5]^=d,r[6]^=c,r[7]^=f,i=0;i<4;i++)u.call(this)}},_doProcessBlock:function(e,t){var n=this._X;u.call(this),i[0]=n[0]^n[5]>>>16^n[3]<<16,i[1]=n[2]^n[7]>>>16^n[5]<<16,i[2]=n[4]^n[1]>>>16^n[7]<<16,i[3]=n[6]^n[3]>>>16^n[1]<<16;for(var r=0;r<4;r++)i[r]=16711935&(i[r]<<8|i[r]>>>24)|4278255360&(i[r]<<24|i[r]>>>8),e[t+r]^=i[r]},blockSize:4,ivSize:2});function u(){for(var e=this._X,t=this._C,n=0;n<8;n++)a[n]=t[n];for(t[0]=t[0]+1295307597+this._b|0,t[1]=t[1]+3545052371+(t[0]>>>0<a[0]>>>0?1:0)|0,t[2]=t[2]+886263092+(t[1]>>>0<a[1]>>>0?1:0)|0,t[3]=t[3]+1295307597+(t[2]>>>0<a[2]>>>0?1:0)|0,t[4]=t[4]+3545052371+(t[3]>>>0<a[3]>>>0?1:0)|0,t[5]=t[5]+886263092+(t[4]>>>0<a[4]>>>0?1:0)|0,t[6]=t[6]+1295307597+(t[5]>>>0<a[5]>>>0?1:0)|0,t[7]=t[7]+3545052371+(t[6]>>>0<a[6]>>>0?1:0)|0,this._b=t[7]>>>0<a[7]>>>0?1:0,n=0;n<8;n++){var r=e[n]+t[n],i=65535&r,s=r>>>16,u=((i*i>>>17)+i*s>>>15)+s*s,l=((4294901760&r)*r|0)+((65535&r)*r|0);o[n]=u^l}e[0]=o[0]+(o[7]<<16|o[7]>>>16)+(o[6]<<16|o[6]>>>16)|0,e[1]=o[1]+(o[0]<<8|o[0]>>>24)+o[7]|0,e[2]=o[2]+(o[1]<<16|o[1]>>>16)+(o[0]<<16|o[0]>>>16)|0,e[3]=o[3]+(o[2]<<8|o[2]>>>24)+o[1]|0,e[4]=o[4]+(o[3]<<16|o[3]>>>16)+(o[2]<<16|o[2]>>>16)|0,e[5]=o[5]+(o[4]<<8|o[4]>>>24)+o[3]|0,e[6]=o[6]+(o[5]<<16|o[5]>>>16)+(o[4]<<16|o[4]>>>16)|0,e[7]=o[7]+(o[6]<<8|o[6]>>>24)+o[5]|0}e.RabbitLegacy=t._createHelper(s)}(),n.RabbitLegacy)}(tk)),n)}(Nx);var nk=Nx.exports,rk=o&&o.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Px,"__esModule",{value:!0}),Px.Base=void 0;const ik=n,ak=rk(nk);let ok=class e{print(){e.print(this)}bufferIndexOf(e,t,n=!1){if(n)return this.binarySearch(e,t,ik.Buffer.compare);return this.linearSearch(e,t,((e,t)=>e.equals(t)))}static binarySearch(e,t,n){let r=0,i=e.length-1;for(;r<=i;){const a=Math.floor((r+i)/2),o=n(e[a],t);if(0===o){for(let r=a-1;r>=0;r--)if(0!==n(e[r],t))return r+1;return 0}o<0?r=a+1:i=a-1}return-1}binarySearch(t,n,r){return e.binarySearch(t,n,r)}static linearSearch(e,t,n){for(let r=0;r<e.length;r++)if(n(e[r],t))return r;return-1}linearSearch(t,n,r){return e.linearSearch(t,n,r)}static bufferify(t){if(!ik.Buffer.isBuffer(t)){if("object"==typeof t&&t.words)return ik.Buffer.from(t.toString(ak.default.enc.Hex),"hex");if(e.isHexString(t))return ik.Buffer.from(t.replace(/^0x/,""),"hex");if("string"==typeof t)return ik.Buffer.from(t);if("bigint"==typeof t)return ik.Buffer.from(t.toString(16),"hex");if(t instanceof Uint8Array)return ik.Buffer.from(t.buffer);if("number"==typeof t){let e=t.toString();return e.length%2&&(e=`0${e}`),ik.Buffer.from(e,"hex")}if(ArrayBuffer.isView(t))return ik.Buffer.from(t.buffer,t.byteOffset,t.byteLength)}return t}bigNumberify(t){return e.bigNumberify(t)}static bigNumberify(t){if("bigint"==typeof t)return t;if("string"==typeof t)return t.startsWith("0x")&&e.isHexString(t)?BigInt("0x"+t.replace("0x","").toString()):BigInt(t);if(ik.Buffer.isBuffer(t))return BigInt("0x"+t.toString("hex"));if(t instanceof Uint8Array)return BigInt(t);if("number"==typeof t)return BigInt(t);throw new Error("cannot bigNumberify")}static isHexString(e){return"string"==typeof e&&/^(0x)?[0-9A-Fa-f]*$/.test(e)}static print(e){console.log(e.toString())}bufferToHex(t,n=!0){return e.bufferToHex(t,n)}static bufferToHex(e,t=!0){return`${t?"0x":""}${(e||ik.Buffer.alloc(0)).toString("hex")}`}bufferify(t){return e.bufferify(t)}bufferifyFn(e){return t=>{const n=e(t);return ik.Buffer.isBuffer(n)?n:this.isHexString(n)?ik.Buffer.from(n.replace("0x",""),"hex"):"string"==typeof n?ik.Buffer.from(n):"bigint"==typeof n?ik.Buffer.from(t.toString(16),"hex"):ArrayBuffer.isView(n)?ik.Buffer.from(n.buffer,n.byteOffset,n.byteLength):ik.Buffer.from(e(ak.default.enc.Hex.parse(t.toString("hex"))).toString(ak.default.enc.Hex),"hex")}}isHexString(t){return e.isHexString(t)}log2(e){return 1===e?0:1+this.log2(e/2|0)}zip(e,t){return e.map(((e,n)=>[e,t[n]]))}static hexZeroPad(e,t){return"0x"+e.replace("0x","").padStart(t,"0")}};Px.Base=ok,Px.default=ok;var sk=o&&o.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(_x,"__esModule",{value:!0}),_x.MerkleTree=void 0;const uk=n,lk=sk((function(e){for(var t=new Buffer(e.length),n=0,r=e.length-1;n<=r;++n,--r)t[n]=e[r],t[r]=e[n];return t})),ck=sk(Sx),dk=sk(Ox),fk=sk(Px);let pk=class e extends fk.default{constructor(e,t=ck.default,n={}){if(super(),this.duplicateOdd=!1,this.concatenator=uk.Buffer.concat,this.hashLeaves=!1,this.isBitcoinTree=!1,this.leaves=[],this.layers=[],this.sortLeaves=!1,this.sortPairs=!1,this.sort=!1,this.fillDefaultHash=null,this.complete=!1,n.complete){if(n.isBitcoinTree)throw new Error('option "complete" is incompatible with "isBitcoinTree"');if(n.duplicateOdd)throw new Error('option "complete" is incompatible with "duplicateOdd"')}if(this.isBitcoinTree=!!n.isBitcoinTree,this.hashLeaves=!!n.hashLeaves,this.sortLeaves=!!n.sortLeaves,this.sortPairs=!!n.sortPairs,this.complete=!!n.complete,n.fillDefaultHash)if("function"==typeof n.fillDefaultHash)this.fillDefaultHash=n.fillDefaultHash;else{if(!uk.Buffer.isBuffer(n.fillDefaultHash)&&"string"!=typeof n.fillDefaultHash)throw new Error('method "fillDefaultHash" must be a function, Buffer, or string');this.fillDefaultHash=(e,t)=>n.fillDefaultHash}this.sort=!!n.sort,this.sort&&(this.sortLeaves=!0,this.sortPairs=!0),this.duplicateOdd=!!n.duplicateOdd,n.concatenator&&(this.concatenator=n.concatenator),this.hashFn=this.bufferifyFn(t),this.processLeaves(e)}getOptions(){var e,t;return{complete:this.complete,isBitcoinTree:this.isBitcoinTree,hashLeaves:this.hashLeaves,sortLeaves:this.sortLeaves,sortPairs:this.sortPairs,sort:this.sort,fillDefaultHash:null!==(t=null===(e=this.fillDefaultHash)||void 0===e?void 0:e.toString())&&void 0!==t?t:null,duplicateOdd:this.duplicateOdd}}processLeaves(e){if(this.hashLeaves&&(e=e.map(this.hashFn)),this.leaves=e.map(this.bufferify),this.sortLeaves&&(this.leaves=this.leaves.sort(uk.Buffer.compare)),this.fillDefaultHash)for(let e=this.leaves.length;e<Math.pow(2,Math.ceil(Math.log2(this.leaves.length)));e++)this.leaves.push(this.bufferify(this.fillDefaultHash(e,this.hashFn)));this.createHashes(this.leaves)}createHashes(e){for(this.layers=[e];e.length>1;){const t=this.layers.length;this.layers.push([]);const n=this.complete&&1===t&&!Number.isInteger(Math.log2(e.length))?2*e.length-Math.pow(2,Math.ceil(Math.log2(e.length))):e.length;for(let r=0;r<e.length;r+=2){if(r>=n){this.layers[t].push(...e.slice(n));break}if(r+1===e.length&&e.length%2==1){const n=e[e.length-1];let i=n;if(this.isBitcoinTree){i=this.hashFn(this.concatenator([lk.default(n),lk.default(n)])),i=lk.default(this.hashFn(i)),this.layers[t].push(i);continue}if(!this.duplicateOdd){this.layers[t].push(e[r]);continue}}const i=e[r],a=r+1===e.length?i:e[r+1];let o=null;o=this.isBitcoinTree?[lk.default(i),lk.default(a)]:[i,a],this.sortPairs&&o.sort(uk.Buffer.compare);let s=this.hashFn(this.concatenator(o));this.isBitcoinTree&&(s=lk.default(this.hashFn(s))),this.layers[t].push(s)}e=this.layers[t]}}addLeaf(e,t=!1){t&&(e=this.hashFn(e)),this.processLeaves(this.leaves.concat(e))}addLeaves(e,t=!1){t&&(e=e.map(this.hashFn)),this.processLeaves(this.leaves.concat(e))}getLeaves(e){return Array.isArray(e)?(this.hashLeaves&&(e=e.map(this.hashFn),this.sortLeaves&&(e=e.sort(uk.Buffer.compare))),this.leaves.filter((t=>-1!==this.bufferIndexOf(e,t,this.sortLeaves)))):this.leaves}getLeaf(e){return e<0||e>this.leaves.length-1?uk.Buffer.from([]):this.leaves[e]}getLeafIndex(e){e=this.bufferify(e);const t=this.getLeaves();for(let n=0;n<t.length;n++){if(t[n].equals(e))return n}return-1}getLeafCount(){return this.leaves.length}getHexLeaves(){return this.leaves.map((e=>this.bufferToHex(e)))}static marshalLeaves(t){return JSON.stringify(t.map((t=>e.bufferToHex(t))),null,2)}static unmarshalLeaves(t){let n=null;if("string"==typeof t)n=JSON.parse(t);else{if(!(t instanceof Object))throw new Error("Expected type of string or object");n=t}if(!n)return[];if(!Array.isArray(n))throw new Error("Expected JSON string to be array");return n.map(e.bufferify)}getLayers(){return this.layers}getHexLayers(){return this.layers.reduce(((e,t)=>(Array.isArray(t)?e.push(t.map((e=>this.bufferToHex(e)))):e.push(t),e)),[])}getLayersFlat(){const e=this.layers.reduce(((e,t)=>(Array.isArray(t)?e.unshift(...t):e.unshift(t),e)),[]);return e.unshift(uk.Buffer.from([0])),e}getHexLayersFlat(){return this.getLayersFlat().map((e=>this.bufferToHex(e)))}getLayerCount(){return this.getLayers().length}getRoot(){return 0===this.layers.length?uk.Buffer.from([]):this.layers[this.layers.length-1][0]||uk.Buffer.from([])}getHexRoot(){return this.bufferToHex(this.getRoot())}getProof(e,t){if(void 0===e)throw new Error("leaf is required");e=this.bufferify(e);const n=[];if(!Number.isInteger(t)){t=-1;for(let n=0;n<this.leaves.length;n++)0===uk.Buffer.compare(e,this.leaves[n])&&(t=n)}if(t<=-1)return[];for(let e=0;e<this.layers.length;e++){const r=this.layers[e],i=t%2,a=i?t-1:this.isBitcoinTree&&t===r.length-1&&e<this.layers.length-1?t:t+1;a<r.length&&n.push({position:i?"left":"right",data:r[a]}),t=t/2|0}return n}getHexProof(e,t){return this.getProof(e,t).map((e=>this.bufferToHex(e.data)))}getProofs(){const e=[];return this.getProofsDFS(this.layers.length-1,0,[],e),e}getProofsDFS(e,t,n,r){const i=t%2;if(-1===e)return void(i||r.push([...n].reverse()));if(t>=this.layers[e].length)return;const a=this.layers[e],o=i?t-1:t+1;let s=!1;o<a.length&&(s=!0,n.push({position:i?"left":"right",data:a[o]}));const u=2*t,l=2*t+1;this.getProofsDFS(e-1,u,n,r),this.getProofsDFS(e-1,l,n,r),s&&n.splice(n.length-1,1)}getHexProofs(){return this.getProofs().map((e=>this.bufferToHex(e.data)))}getPositionalHexProof(e,t){return this.getProof(e,t).map((e=>["left"===e.position?0:1,this.bufferToHex(e.data)]))}static marshalProof(t){const n=t.map((t=>"string"==typeof t?t:uk.Buffer.isBuffer(t)?e.bufferToHex(t):{position:t.position,data:e.bufferToHex(t.data)}));return JSON.stringify(n,null,2)}static unmarshalProof(t){let n=null;if("string"==typeof t)n=JSON.parse(t);else{if(!(t instanceof Object))throw new Error("Expected type of string or object");n=t}if(!n)return[];if(!Array.isArray(n))throw new Error("Expected JSON string to be array");return n.map((t=>{if("string"==typeof t)return e.bufferify(t);if(t instanceof Object)return{position:t.position,data:e.bufferify(t.data)};throw new Error("Expected item to be of type string or object")}))}static marshalTree(t){const n=t.getHexRoot(),r=t.leaves.map((t=>e.bufferToHex(t))),i=t.getHexLayers(),a=t.getOptions();return JSON.stringify({options:a,root:n,layers:i,leaves:r},null,2)}static unmarshalTree(t,n=ck.default,r={}){let i=null;if("string"==typeof t)i=JSON.parse(t);else{if(!(t instanceof Object))throw new Error("Expected type of string or object");i=t}if(!i)throw new Error("could not parse json");return r=Object.assign({},i.options||{},r),new e(i.leaves,n,r)}getProofIndices(e,t){const n=Math.pow(2,t);let r=new Set;for(const t of e){let e=n+t;for(;e>1;)r.add(1^e),e=e/2|0}const i=e.map((e=>n+e)),a=Array.from(r).sort(((e,t)=>e-t)).reverse();r=i.concat(a);const o=new Set,s=[];for(let e of r)if(!o.has(e))for(s.push(e);e>1&&(o.add(e),o.has(1^e));)e=e/2|0;return s.filter((t=>!e.includes(t-n)))}getProofIndicesForUnevenTree(e,t){const n=Math.ceil(Math.log2(t)),r=[];for(let e=0;e<n;e++){t%2!=0&&r.push({index:e,leavesCount:t}),t=Math.ceil(t/2)}const i=[];let a=e;for(let e=0;e<n;e++){const t=a.map((e=>e%2==0?e+1:e-1));let n=t.filter((e=>!a.includes(e)));const o=r.find((({index:t})=>t===e));o&&a.includes(o.leavesCount-1)&&(n=n.slice(0,-1)),i.push(n),a=[...new Set(a.map((e=>e%2==0?e/2:e%2==0?(e+1)/2:(e-1)/2)))]}return i}getMultiProof(e,t){this.complete||console.warn("Warning: For correct multiProofs it's strongly recommended to set complete: true"),t||(t=e,e=this.getLayersFlat());if(this.isUnevenTree()&&t.every(Number.isInteger))return this.getMultiProofForUnevenTree(t);if(!t.every(Number.isInteger)){let e=t;this.sortPairs&&(e=e.sort(uk.Buffer.compare));let n=e.map((e=>this.bufferIndexOf(this.leaves,e,this.sortLeaves))).sort(((e,t)=>e===t?0:e>t?1:-1));if(!n.every((e=>-1!==e)))throw new Error("Element does not exist in Merkle tree");const r=[],i=[];let a=[];for(let e=0;e<this.layers.length;e++){const t=this.layers[e];for(let e=0;e<n.length;e++){const o=n[e],s=this.getPairNode(t,o);r.push(t[o]),s&&i.push(s),a.push(o/2|0)}n=a.filter(((e,t,n)=>n.indexOf(e)===t)),a=[]}return i.filter((e=>!r.includes(e)))}return this.getProofIndices(t,Math.log2(e.length/2|0)).map((t=>e[t]))}getMultiProofForUnevenTree(e,t){t||(t=e,e=this.getLayers());let n=[],r=t;for(const t of e){const e=[];for(const n of r){if(n%2==0){const i=n+1;if(!r.includes(i)&&t[i]){e.push(t[i]);continue}}const i=n-1;r.includes(i)||!t[i]||e.push(t[i])}n=n.concat(e);const i=new Set;for(const e of r)e%2!=0?e%2!=0?i.add((e-1)/2):i.add((e+1)/2):i.add(e/2);r=Array.from(i)}return n}getHexMultiProof(e,t){return this.getMultiProof(e,t).map((e=>this.bufferToHex(e)))}getProofFlags(e,t){if(!Array.isArray(e)||e.length<=0)throw new Error("Invalid Inputs!");let n;if(n=e.every(Number.isInteger)?[...e].sort(((e,t)=>e===t?0:e>t?1:-1)):e.map((e=>this.bufferIndexOf(this.leaves,e,this.sortLeaves))).sort(((e,t)=>e===t?0:e>t?1:-1)),!n.every((e=>-1!==e)))throw new Error("Element does not exist in Merkle tree");const r=t.map((e=>this.bufferify(e))),i=[],a=[];for(let e=0;e<this.layers.length;e++){const t=this.layers[e];n=n.reduce(((e,n)=>{if(!i.includes(t[n])){const e=this.getPairNode(t,n),o=r.includes(t[n])||r.includes(e);e&&a.push(!o),i.push(t[n]),i.push(e)}return e.push(n/2|0),e}),[])}return a}verify(e,t,n){let r=this.bufferify(t);if(n=this.bufferify(n),!Array.isArray(e)||!t||!n)return!1;for(let t=0;t<e.length;t++){const n=e[t];let i=null,a=null;if("string"==typeof n)i=this.bufferify(n),a=!0;else if(Array.isArray(n))a=0===n[0],i=this.bufferify(n[1]);else if(uk.Buffer.isBuffer(n))i=n,a=!0;else{if(!(n instanceof Object))throw new Error("Expected node to be of type string or object");i=this.bufferify(n.data),a="left"===n.position}const o=[];this.isBitcoinTree?(o.push(lk.default(r)),o[a?"unshift":"push"](lk.default(i)),r=this.hashFn(this.concatenator(o)),r=lk.default(this.hashFn(r))):this.sortPairs?-1===uk.Buffer.compare(r,i)?(o.push(r,i),r=this.hashFn(this.concatenator(o))):(o.push(i,r),r=this.hashFn(this.concatenator(o))):(o.push(r),o[a?"unshift":"push"](i),r=this.hashFn(this.concatenator(o)))}return 0===uk.Buffer.compare(r,n)}verifyMultiProof(e,t,n,r,i){if(this.isUnevenTree())return this.verifyMultiProofForUnevenTree(e,t,n,r,i);const a=Math.ceil(Math.log2(r));e=this.bufferify(e),n=n.map((e=>this.bufferify(e))),i=i.map((e=>this.bufferify(e)));const o={};for(const[e,r]of this.zip(t,n))o[Math.pow(2,a)+e]=r;for(const[e,n]of this.zip(this.getProofIndices(t,a),i))o[e]=n;let s=Object.keys(o).map((e=>+e)).sort(((e,t)=>e-t));s=s.slice(0,s.length-1);let u=0;for(;u<s.length;){const e=s[u];if(e>=2&&{}.hasOwnProperty.call(o,1^e)){let t=[o[e-e%2],o[e-e%2+1]];this.sortPairs&&(t=t.sort(uk.Buffer.compare));const n=t[1]?this.hashFn(this.concatenator(t)):t[0];o[e/2|0]=n,s.push(e/2|0)}u+=1}return!t.length||{}.hasOwnProperty.call(o,1)&&o[1].equals(e)}verifyMultiProofWithFlags(e,t,n,r){e=this.bufferify(e),t=t.map(this.bufferify),n=n.map(this.bufferify);const i=t.length,a=r.length,o=[];let s=0,u=0,l=0;for(let e=0;e<a;e++){const a=[r[e]?s<i?t[s++]:o[u++]:n[l++],s<i?t[s++]:o[u++]].sort(uk.Buffer.compare);o[e]=this.hashFn(this.concatenator(a))}return 0===uk.Buffer.compare(o[a-1],e)}verifyMultiProofForUnevenTree(e,t,n,r,i){e=this.bufferify(e),n=n.map((e=>this.bufferify(e))),i=i.map((e=>this.bufferify(e)));const a=this.calculateRootForUnevenTree(t,n,r,i);return e.equals(a)}getDepth(){return this.getLayers().length-1}getLayersAsObject(){const e=this.getLayers().map((e=>e.map((e=>this.bufferToHex(e,!1))))),t=[];for(let n=0;n<e.length;n++){const r=[];for(let i=0;i<e[n].length;i++){const a={[e[n][i]]:null};if(t.length){a[e[n][i]]={};const r=t.shift(),o=Object.keys(r)[0];if(a[e[n][i]][o]=r[o],t.length){const r=t.shift(),o=Object.keys(r)[0];a[e[n][i]][o]=r[o]}}r.push(a)}t.push(...r)}return t[0]}static verify(t,n,r,i=ck.default,a={}){return new e([],i,a).verify(t,n,r)}static getMultiProof(t,n){return new e([]).getMultiProof(t,n)}resetTree(){this.leaves=[],this.layers=[]}getPairNode(e,t){const n=t%2==0?t+1:t-1;return n<e.length?e[n]:null}toTreeString(){const e=this.getLayersAsObject();return dk.default.asTree(e,!0)}toString(){return this.toTreeString()}isUnevenTree(e){const t=(null==e?void 0:e.length)||this.getDepth();return!this.isPowOf2(t)}isPowOf2(e){return e&&!(e&e-1)}calculateRootForUnevenTree(e,t,n,r){const i=this.zip(e,t).sort((([e],[t])=>e-t)),a=i.map((([e])=>e)),o=this.getProofIndicesForUnevenTree(a,n);let s=0;const u=[];for(let e=0;e<o.length;e++){const t=o[e],n=s;s+=t.length,u[e]=this.zip(t,r.slice(n,s))}const l=[i];for(let e=0;e<u.length;e++){const t=u[e].concat(l[e]).sort((([e],[t])=>e-t)).map((([,e])=>e)),n=l[e].map((([e])=>e)),r=[...new Set(n.map((e=>e%2==0?e/2:e%2==0?(e+1)/2:(e-1)/2)))],i=[];for(let e=0;e<r.length;e++){const n=r[e],a=t[2*e],o=t[2*e+1],s=o?this.hashFn(this.concatenator([a,o])):a;i.push([n,s])}l.push(i)}return l[l.length-1][0][1]}};_x.MerkleTree=pk,"undefined"!=typeof window&&(window.MerkleTree=pk),_x.default=pk;var hk={},mk=o&&o.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(hk,"__esModule",{value:!0}),hk.MerkleMountainRange=void 0;const yk=n,gk=mk(Sx),bk=mk(Px);class vk extends bk.default{constructor(e=gk.default,t=[],n,r,i){super(),this.root=yk.Buffer.alloc(0),this.size=0,this.width=0,this.hashes={},this.data={},t=t.map(this.bufferify),this.hashFn=this.bufferifyFn(e),this.hashLeafFn=n,this.peakBaggingFn=r,this.hashBranchFn=i;for(const e of t)this.append(e)}append(e){e=this.bufferify(e);const t=this.hashFn(e),n=this.bufferToHex(t);this.data[n]&&this.bufferToHex(this.hashFn(this.data[n]))===n||(this.data[n]=e);const r=this.hashLeaf(this.size+1,t);this.hashes[this.size+1]=r,this.width+=1;const i=this.getPeakIndexes(this.width);this.size=this.getSize(this.width);const a=[];for(let e=0;e<i.length;e++)a[e]=this._getOrCreateNode(i[e]);this.root=this.peakBagging(this.width,a)}hashLeaf(e,t){return t=this.bufferify(t),this.hashLeafFn?this.bufferify(this.hashLeafFn(e,t)):this.hashFn(yk.Buffer.concat([this.bufferify(e),t]))}hashBranch(e,t,n){return this.hashBranchFn?this.bufferify(this.hashBranchFn(e,t,n)):this.hashFn(yk.Buffer.concat([this.bufferify(e),this.bufferify(t),this.bufferify(n)]))}getPeaks(){const e=this.getPeakIndexes(this.width),t=[];for(let n=0;n<e.length;n++)t[n]=this.hashes[e[n]];return t}getLeafIndex(e){return e%2==1?this.getSize(e):this.getSize(e-1)+1}getPeakIndexes(e){const t=this.numOfPeaks(e),n=[];let r=0,i=0;for(let a=255;a>0&&!(0!=(e&1<<a-1)&&(i=i+(1<<a)-1,n[r++]=i,n.length>=t));a--);if(r!==n.length)throw new Error("invalid bit calculation");return n}numOfPeaks(e){let t=e,n=0;for(;t>0;)t%2==1&&n++,t>>=1;return n}peakBagging(e,t){const n=this.getSize(e);if(this.numOfPeaks(e)!==t.length)throw new Error("received invalid number of peaks");return 0!==e||t.length?this.peakBaggingFn?this.bufferify(this.peakBaggingFn(n,t)):this.hashFn(yk.Buffer.concat([this.bufferify(n),...t.map(this.bufferify)])):yk.Buffer.alloc(0)}getSize(e){return(e<<1)-this.numOfPeaks(e)}getRoot(){return this.root}getHexRoot(){return this.bufferToHex(this.getRoot())}getNode(e){return this.hashes[e]}mountainHeight(e){let t=1;for(;1<<t<=e+t;)t++;return t-1}heightAt(e){let t=e,n=0,r=0;for(;t>n;)t-=(1<<r)-1,r=this.mountainHeight(t),n=(1<<r)-1;return r-(n-t)}isLeaf(e){return 1===this.heightAt(e)}getChildren(e){const t=e-(1<<this.heightAt(e)-1),n=e-1;if(t===n)throw new Error("not a parent");return[t,n]}getMerkleProof(e){if(e>this.size)throw new Error("out of range");if(!this.isLeaf(e))throw new Error("not a leaf");const t=this.root,n=this.width,r=this.getPeakIndexes(this.width),i=[];let a=0;for(let t=0;t<r.length;t++)i[t]=this.hashes[r[t]],r[t]>=e&&0===a&&(a=r[t]);let o=0,s=0,u=this.heightAt(a);const l=[];for(;a!==e;)u--,[o,s]=this.getChildren(a),a=e<=o?o:s,l[u-1]=this.hashes[e<=o?s:o];return{root:t,width:n,peakBagging:i,siblings:l}}verify(e,t,n,r,i,a){r=this.bufferify(r);if(this.getSize(t)<n)throw new Error("index is out of range");if(!e.equals(this.peakBagging(t,i)))throw new Error("invalid root hash from the peaks");let o,s=0;const u=this.getPeakIndexes(t);for(let e=0;e<u.length;e++)if(u[e]>=n){o=i[e],s=u[e];break}if(!o)throw new Error("target not found");let l=a.length+1;const c=new Array(l);let d,f=0,p=0;for(;l>0&&(c[--l]=s,s!==n);)[f,p]=this.getChildren(s),s=n>f?p:f;for(;l<c.length;)s=c[l],d=0===l?this.hashLeaf(s,this.hashFn(r)):s-1===c[l-1]?this.hashBranch(s,a[l-1],d):this.hashBranch(s,d,a[l-1]),l++;if(!d.equals(o))throw new Error("hashed peak is invalid");return!0}peaksToPeakMap(e,t){const n={};let r=0,i=0,a=t.length;for(let o=1;o<=32;o++)r=32-o,i=1<<o-1,n[r]=0!=(e&i)?t[--a]:0;if(0!==a)throw new Error("invalid number of peaks");return n}peakMapToPeaks(e,t){const n=this.numOfPeaks(e),r=new Array(n);let i=0;for(let e=0;e<32;e++)0!==t[e]&&(r[i++]=t[e]);if(i!==n)throw new Error("invalid number of peaks");return r}peakUpdate(e,t,n){const r={},i=e+1;let a=this.getLeafIndex(i),o=this.hashLeaf(a,n),s=0,u=0,l=!1,c=!1,d=!1;for(let n=1;n<=32;n++)s=32-n,d?r[s]=t[s]:(u=1<<n-1,l=0!=(e&u),c=0!=(i&u),a++,l&&(o=this.hashBranch(a,t[s],o)),c?(r[s]=l?t[s]:o,d=!0):r[s]=0);return r}rollUp(e,t,n,r){if(!e.equals(this.peakBagging(t,n)))throw new Error("invalid root hash from the peaks");let i=t,a=this.peaksToPeakMap(t,n);for(let e=0;e<r.length;e++)a=this.peakUpdate(i,a,r[e]),i++;return this.peakBagging(i,this.peakMapToPeaks(i,a))}_getOrCreateNode(e){if(e>this.size)throw new Error("out of range");if(!this.hashes[e]){const[t,n]=this.getChildren(e),r=this._getOrCreateNode(t),i=this._getOrCreateNode(n);this.hashes[e]=this.hashBranch(e,r,i)}return this.hashes[e]}}hk.MerkleMountainRange=vk,"undefined"!=typeof window&&(window.MerkleMountainRange=vk),hk.default=vk;var wk={},Ek=o&&o.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(wk,"__esModule",{value:!0}),wk.IncrementalMerkleTree=void 0;const Tk=Ek(Px),Ak=Ek(Ox);class _k extends Tk.default{constructor(e,t){if(super(),this.hashFn=e,t.depth&&(this.depth=t.depth),t.arity&&(this.arity=t.arity),this.depth<1)throw new Error("depth must be greater than 0");if(this.arity<1)throw new Error("arity must be greater than 0");const n=[];let r=t.zeroValue;if(this.zeroValue=r,this.zeroes=[],this.depth)for(let e=0;e<this.depth;e++)this.zeroes.push(r),n[e]=[],r=this.hashFn(Array(this.arity).fill(r));this.nodes=n,this.root=r}getRoot(){return this.root}getHexRoot(){return this.bufferToHex(this.bufferify(this.getRoot()))}insert(e){if(this.depth&&this.arity&&this.nodes[0].length>=this.getMaxLeaves())throw new Error("tree is full");let t=e,n=this.nodes[0].length;for(let e=0;e<this.depth;e+=1){const r=n-n%this.arity,i=r+this.arity,a=[];this.nodes[e][n]=t;for(let t=r;t<i;t+=1)t<this.nodes[e].length?a.push(this.nodes[e][t]):a.push(this.zeroes[e]);t=this.hashFn(a),n=Math.floor(n/this.arity)}this.root=t}delete(e){this.update(e,this.zeroValue)}update(e,t){if(e<0||e>=this.nodes[0].length)throw new Error("out of bounds");let n=t;for(let t=0;t<this.depth;t+=1){const r=e-e%this.arity,i=r+this.arity,a=[];this.nodes[t][e]=n;for(let e=r;e<i;e+=1)e<this.nodes[t].length?a.push(this.nodes[t][e]):a.push(this.zeroes[t]);n=this.hashFn(a),e=Math.floor(e/this.arity)}this.root=n}getDepth(){return this.depth}getArity(){return this.arity}getMaxLeaves(){return Math.pow(this.depth,this.arity)}indexOf(e){return this.nodes[0].indexOf(e)}getLeaves(){const e=this.copyList(this.nodes[0]);for(let t=this.nodes[0].length;t<this.getMaxLeaves();t++)e[t]=this.zeroValue;return e}copyList(e){return e.map((e=>BigInt(e)))}getLayers(){const e=[];for(const t of this.nodes)e.push(this.copyList(t));if(e[0].length<this.getMaxLeaves()){let t=e[0].length;for(let n=t;n<this.getMaxLeaves();n++)e[0][n]=this.zeroValue;for(let n=0;n<this.depth;n++){const r=t-t%this.arity,i=r+this.arity;for(let t=r;t<i;t++)t>=e[n].length&&(e[n][t]=this.zeroes[n]);t=Math.floor(t/this.arity)}}return e.push([this.root]),e}getHexLayers(){return this.getLayers().reduce(((e,t)=>(Array.isArray(t)?e.push(t.map((e=>this.bufferToHex(this.bufferify(e))))):e.push(t),e)),[])}getLayersAsObject(){const e=this.getLayers().map((e=>e.map((e=>this.bufferToHex(this.bufferify(e),!1))))),t=[];for(let n=0;n<e.length;n++){const r=[];for(let i=0;i<e[n].length;i++){const a={[e[n][i]]:null};if(t.length){a[e[n][i]]={};const r=t.shift(),o=Object.keys(r)[0];if(a[e[n][i]][o]=r[o],t.length){const r=t.shift(),o=Object.keys(r)[0];a[e[n][i]][o]=r[o]}}r.push(a)}t.push(...r)}return t[0]}computeRoot(){let e,t=this.nodes[0].length;for(let n=0;n<this.depth;n+=1){const r=t-t%this.arity,i=r+this.arity,a=[];for(let e=r;e<i;e+=1)e<this.nodes[n].length?a.push(this.nodes[n][e]):a.push(this.zeroes[n]);e=this.hashFn(a),t=Math.floor(t/this.arity)}return e}getProof(e){if(e<0||e>=this.nodes[0].length)throw new Error("The leaf does not exist in this tree");const t=[],n=[],r=e;for(let r=0;r<this.depth;r+=1){const i=e%this.arity,a=e-i,o=a+this.arity;n[r]=i,t[r]=[];for(let n=a;n<o;n+=1)n!==e&&(n<this.nodes[r].length?t[r].push(this.nodes[r][n]):t[r].push(this.zeroes[r]));e=Math.floor(e/this.arity)}return{root:this.root,leaf:this.nodes[0][r],pathIndices:n,siblings:t}}verify(e){let t=e.leaf;for(let n=0;n<e.siblings.length;n+=1){const r=e.siblings[n].slice();r.splice(e.pathIndices[n],0,t),t=this.hashFn(r)}return e.root===t}toString(){return this.toTreeString()}toTreeString(){const e=this.getLayersAsObject();return Ak.default.asTree(e,!0)}}wk.IncrementalMerkleTree=_k,"undefined"!=typeof window&&(window.IncrementalMerkleTree=_k),wk.default=_k;var xk={};Object.defineProperty(xk,"__esModule",{value:!0}),xk.MerkleSumTree=xk.ProofStep=xk.Leaf=xk.Bucket=void 0;const Ck=Px;class kk{constructor(e,t){this.size=BigInt(e),this.hashed=t,this.parent=null,this.left=null,this.right=null}}xk.Bucket=kk;xk.Leaf=class{constructor(e,t,n){this.hashFn=e,this.rng=t.map((e=>BigInt(e))),this.data=n}getBucket(){let e;return e=this.data?this.hashFn(this.data):Buffer.alloc(32),new kk(BigInt(this.rng[1])-BigInt(this.rng[0]),e)}};class Sk{constructor(e,t){this.bucket=e,this.right=t}}xk.ProofStep=Sk;class Ik extends Ck.Base{constructor(e,t){super(),this.leaves=e,this.hashFn=t,Ik.checkConsecutive(e),this.buckets=[];for(const t of e)this.buckets.push(t.getBucket());let n=[];for(const e of this.buckets)n.push(e);for(;1!==n.length;){const e=[];for(;n.length;)if(n.length>=2){const t=n.shift(),r=n.shift(),i=t.size+r.size,a=this.hashFn(Buffer.concat([this.sizeToBuffer(t.size),this.bufferify(t.hashed),this.sizeToBuffer(r.size),this.bufferify(r.hashed)])),o=new kk(i,a);r.parent=o,t.parent=r.parent,t.right=r,r.left=t,e.push(o)}else e.push(n.shift());n=e}this.root=n[0]}sizeToBuffer(e){const t=Buffer.alloc(8);return new DataView(t.buffer).setBigInt64(0,BigInt(e),!1),t}static checkConsecutive(e){let t=BigInt(0);for(const n of e){if(n.rng[0]!==t)throw new Error("leaf ranges are invalid");t=BigInt(n.rng[1])}}getProof(e){let t=this.buckets[Number(e)];const n=[];for(;t&&t.parent;){const e=!!t.right,r=t.right?t.right:t.left;t=t.parent,n.push(new Sk(r,e))}return n}sum(e){let t=BigInt(0);for(const n of e)t+=BigInt(n);return t}verifyProof(e,t,n){const r=[this.sum(n.filter((e=>!e.right)).map((e=>e.bucket.size))),BigInt(e.size)-this.sum(n.filter((e=>e.right)).map((e=>e.bucket.size)))];if(r[0]!==t.rng[0]||r[1]!==t.rng[1])return!1;let i,a=t.getBucket();for(const e of n)i=e.right?this.hashFn(Buffer.concat([this.sizeToBuffer(a.size),this.bufferify(a.hashed),this.sizeToBuffer(e.bucket.size),this.bufferify(e.bucket.hashed)])):this.hashFn(Buffer.concat([this.sizeToBuffer(e.bucket.size),this.bufferify(e.bucket.hashed),this.sizeToBuffer(a.size),this.bufferify(a.hashed)])),a=new kk(BigInt(a.size)+BigInt(e.bucket.size),i);return a.size===e.size&&a.hashed.toString("hex")===e.hashed.toString("hex")}}xk.MerkleSumTree=Ik,"undefined"!=typeof window&&(window.MerkleSumTree=Ik),xk.default=Ik,function(e){var t=o&&o.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.MerkleTree=void 0;const n=t(_x);e.MerkleTree=n.default;var r=hk;Object.defineProperty(e,"MerkleMountainRange",{enumerable:!0,get:function(){return r.MerkleMountainRange}});var i=wk;Object.defineProperty(e,"IncrementalMerkleTree",{enumerable:!0,get:function(){return i.IncrementalMerkleTree}});var a=xk;Object.defineProperty(e,"MerkleSumTree",{enumerable:!0,get:function(){return a.MerkleSumTree}}),e.default=n.default}(Ax);var Rk={};Object.defineProperty(Rk,"__esModule",{value:!0}),Rk.DefaultGetter=void 0;const Ok=A_,Pk=new P_.Logger("defaults"),Nk={integer:0,address:(0,Ok.hexZeroPad)("0x",20),bool:!1,bytes:"0x",string:""},Mk=e=>void 0!==e&&(null!=e&&(["string","number"].includes(typeof e)&&BigInt(e)===BigInt(0)||Array.isArray(e)&&e.every(Mk)||"object"==typeof e&&Object.values(e).every(Mk)||"boolean"==typeof e&&!1===e));class Lk{constructor(e){this.types=e,this.defaultValues={};for(const t in e){const e=this.getDefaultValue(t);this.defaultValues[t]=e,Mk(e)||Pk.throwError(`Got non-empty value for type ${t} in default generator: ${e}`)}}static from(e,t){const{defaultValues:n}=new Lk(e);return t?n[t]:n}getDefaultValue(e){if(this.defaultValues[e])return this.defaultValues[e];const t=function(e){var t;const[,n]=null!==(t=e.match(/^bytes(\d+)$/))&&void 0!==t?t:[];return n?(0,Ok.hexZeroPad)("0x",parseInt(n)):(e.match(/^(u?)int(\d*)$/)&&(e="integer"),Nk[e])}(e);if(void 0!==t)return t;const n=e.match(/^(.*)(\x5b(\d*)\x5d)$/);if(n){const e=n[1],t=parseInt(n[3]);if(t>0){const n=this.getDefaultValue(e);return Array(t).fill(n)}return[]}const r=this.types[e];return r?r.reduce(((e,{name:t,type:n})=>Object.assign(Object.assign({},e),{[t]:this.getDefaultValue(n)})),{}):Pk.throwArgumentError(`unknown type: ${e}`,"type",e)}}Rk.DefaultGetter=Lk;var Fk={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.getNextLayer=e.getRoot=e.fillArray=e.hashConcat=e.bufferKeccak=e.hexToBuffer=e.bufferToHex=e.chunk=e.makeArray=void 0;const t=A_;e.makeArray=(e,t)=>Array(e).fill(0).map(((e,n)=>t(n)));e.chunk=(t,n)=>(0,e.makeArray)(Math.ceil(t.length/n),(e=>t.slice(e*n,(e+1)*n)));e.bufferToHex=e=>(0,t.hexlify)(e);e.hexToBuffer=e=>Buffer.from(e.slice(2),"hex");e.bufferKeccak=n=>(0,e.hexToBuffer)((0,t.keccak256)(n));e.hashConcat=n=>(0,e.bufferKeccak)((0,t.hexConcat)(n));e.fillArray=(e,t,n)=>(t>e.length&&e.push(...Array(t-e.length).fill(n)),e);e.getRoot=(t,n=!0)=>{if(0===t.length)throw new Error("empty tree");const r=t.map((t=>{const r=Buffer.isBuffer(t)?t:(0,e.hexToBuffer)(t);return n?(0,e.bufferKeccak)(r):r})),i=[r];for(;i[i.length-1].length>1;)i.push((0,e.getNextLayer)(i[i.length-1]));return i[i.length-1][0]};e.getNextLayer=t=>(0,e.chunk)(t,2).map(e.hashConcat)}(Fk),Object.defineProperty(Tx,"__esModule",{value:!0}),Tx.Eip712MerkleTree=void 0;const Dk=S_,Bk=A_,jk=Ax,Uk=Rk,zk=Fk;Tx.Eip712MerkleTree=class{get completedSize(){return Math.pow(2,this.depth)}getCompleteElements(){const e=this.elements;return(0,zk.fillArray)([...e],this.completedSize,this.defaultNode)}getCompleteLeaves(){const e=this.elements.map(this.leafHasher);return(0,zk.fillArray)([...e],this.completedSize,this.defaultLeaf)}get root(){return this.tree.getHexRoot()}getProof(e){const t=this.getCompleteLeaves()[e];return{leaf:t,proof:this.tree.getHexProof(t,e),root:this.tree.getHexRoot()}}getEncodedProofAndSignature(e,t){const{proof:n}=this.getProof(e);return((e,t,n=`0x${"ff".repeat(64)}`)=>(0,Bk.hexConcat)([n,`0x${e.toString(16).padStart(6,"0")}`,Bk.defaultAbiCoder.encode([`uint256[${t.length}]`],[t])]))(e,n,t)}getDataToSign(){let e=this.getCompleteElements();for(;e.length>2;)e=(0,zk.chunk)(e,2);return e}add(e){this.elements.push(e)}getBulkOrderHash(){const e=this.encoder.hashStruct("BulkOrder",{tree:this.getDataToSign()}),t=this.getCompleteLeaves().map(zk.hexToBuffer),n=(0,zk.bufferToHex)((0,zk.getRoot)(t,!1)),r=(0,Bk.keccak256)((0,Bk.toUtf8Bytes)(this.encoder._types.BulkOrder));if((0,Bk.keccak256)((0,Bk.hexConcat)([r,n]))!==e)throw new Error("expected derived bulk order hash to match");return e}constructor(e,t,n,r,i){this.types=e,this.rootType=t,this.leafType=n,this.elements=r,this.depth=i;const a=Dk._TypedDataEncoder.from(e);var o,s;this.encoder=a,this.leafHasher=e=>a.hashStruct(n,e),this.defaultNode=Uk.DefaultGetter.from(e,n),this.defaultLeaf=this.leafHasher(this.defaultNode),this.tree=(o=this.getCompleteLeaves(),s=this.defaultLeaf,new jk.MerkleTree(o.map(zk.hexToBuffer),zk.bufferKeccak,{complete:!0,sort:!1,hashLeaves:!1,fillDefaultHash:(0,zk.hexToBuffer)(s)}))}},Object.defineProperty(Ex,"__esModule",{value:!0}),Ex.getBulkOrderTypeHashes=Ex.getBulkOrderTypeHash=Ex.getBulkOrderTree=Ex.getBulkOrderTreeHeight=void 0;const Vk=A_,Hk=Tx,qk=Rk,Gk=Fk,Wk=G_;function $k(e){const t=Object.assign({},Wk.EIP_712_BULK_ORDER_TYPE);return t.BulkOrder=[{name:"tree",type:`OrderComponents${"[2]".repeat(e)}`}],t}function Kk(e){return Math.max(Math.ceil(Math.log2(e)),1)}function Xk(e){const t=$k(e),n=Vk._TypedDataEncoder.from(t),r=(0,Vk.toUtf8Bytes)(n._types.BulkOrder);return(0,Vk.keccak256)(r)}Ex.getBulkOrderTreeHeight=Kk,Ex.getBulkOrderTree=function(e,t=0,n=Kk(e.length+t)){const r=$k(n),i=qk.DefaultGetter.from(r,"OrderComponents");let a=[...e];return t>0&&(a=[...(0,Gk.fillArray)([],t,i),...e]),new Hk.Eip712MerkleTree(r,"BulkOrder","OrderComponents",a,n)},Ex.getBulkOrderTypeHash=Xk,Ex.getBulkOrderTypeHashes=function(e){const t=[];for(let n=0;n<e;n++)t.push(Xk(n+1));return t};var Zk={},Yk={},Jk={};Object.defineProperty(Jk,"__esModule",{value:!0}),Jk.MerkleTree=void 0;const Qk=T_,eS=A_,tS=Ax,nS=e=>(0,eS.keccak256)(Buffer.from(Qk.BigNumber.from(e).toHexString().slice(2).padStart(64,"0"),"hex"));Jk.MerkleTree=class{constructor(e){this.tree=new tS.default(e.map(nS),eS.keccak256,{sort:!0})}getProof(e){return this.tree.getHexProof(nS(e))}getRoot(){return this.tree.getRoot().toString("hex")?this.tree.getHexRoot():"0"}},Object.defineProperty(Yk,"__esModule",{value:!0}),Yk.shouldUseMatchForFulfill=Yk.generateRandomSalt=Yk.mapOrderAmountsFromUnitsToFill=Yk.mapOrderAmountsFromFilledStatus=Yk.totalItemsAmount=Yk.areAllCurrenciesSame=Yk.mapInputItemToOfferItem=Yk.deductFees=Yk.feeToConsiderationItem=void 0;const rS=T_,iS=A_,aS=G_,oS=tx(),sS=Jk,uS=(e,t)=>rS.BigNumber.from(e).mul(rS.BigNumber.from(t)).div(aS.ONE_HUNDRED_PERCENT_BP);Yk.feeToConsiderationItem=({fee:e,token:t,baseAmount:n,baseEndAmount:r=n})=>({itemType:t===rS.ethers.constants.AddressZero?aS.ItemType.NATIVE:aS.ItemType.ERC20,token:t,identifierOrCriteria:"0",startAmount:uS(n,e.basisPoints).toString(),endAmount:uS(r,e.basisPoints).toString(),recipient:e.recipient});Yk.deductFees=(e,t)=>{if(!t)return e;const n=t.reduce(((e,t)=>e+t.basisPoints),0);return e.map((e=>Object.assign(Object.assign({},e),{startAmount:(0,oS.isCurrencyItem)(e)?rS.BigNumber.from(e.startAmount).sub(uS(e.startAmount,n)).toString():e.startAmount,endAmount:(0,oS.isCurrencyItem)(e)?rS.BigNumber.from(e.endAmount).sub(uS(e.endAmount,n)).toString():e.endAmount})))};Yk.mapInputItemToOfferItem=e=>{var t,n,r,i,a,o,s,u;if("itemType"in e){if("identifiers"in e||"criteria"in e){const i="criteria"in e?e.criteria:new sS.MerkleTree(e.identifiers).getRoot();return{itemType:e.itemType===aS.ItemType.ERC721?aS.ItemType.ERC721_WITH_CRITERIA:aS.ItemType.ERC1155_WITH_CRITERIA,token:e.token,identifierOrCriteria:i,startAmount:null!==(t=e.amount)&&void 0!==t?t:"1",endAmount:null!==(r=null!==(n=e.endAmount)&&void 0!==n?n:e.amount)&&void 0!==r?r:"1"}}return"amount"in e||"endAmount"in e?{itemType:e.itemType,token:e.token,identifierOrCriteria:null!==(i=e.identifier)&&void 0!==i?i:"0",startAmount:e.amount,endAmount:null!==(o=null!==(a=e.endAmount)&&void 0!==a?a:e.amount)&&void 0!==o?o:"1"}:{itemType:e.itemType,token:e.token,identifierOrCriteria:e.identifier,startAmount:"1",endAmount:"1"}}return{itemType:e.token&&e.token!==rS.ethers.constants.AddressZero?aS.ItemType.ERC20:aS.ItemType.NATIVE,token:null!==(s=e.token)&&void 0!==s?s:rS.ethers.constants.AddressZero,identifierOrCriteria:"0",startAmount:e.amount,endAmount:null!==(u=e.endAmount)&&void 0!==u?u:e.amount}};Yk.areAllCurrenciesSame=({offer:e,consideration:t})=>{const n=[...e,...t].filter(oS.isCurrencyItem);return n.every((({itemType:e,token:t})=>e===n[0].itemType&&t.toLowerCase()===n[0].token.toLowerCase()))};Yk.totalItemsAmount=e=>(rS.BigNumber.from(0),rS.BigNumber.from(0),e.map((({startAmount:e,endAmount:t})=>({startAmount:e,endAmount:t}))).reduce((({startAmount:e,endAmount:t},{startAmount:n,endAmount:r})=>({startAmount:e.add(n),endAmount:t.add(r)})),{startAmount:rS.BigNumber.from(0),endAmount:rS.BigNumber.from(0)}));Yk.mapOrderAmountsFromFilledStatus=(e,{totalFilled:t,totalSize:n})=>{if(t.eq(0)||n.eq(0))return e;const r=n.sub(t).mul(aS.ONE_HUNDRED_PERCENT_BP).div(n);return{parameters:Object.assign(Object.assign({},e.parameters),{offer:e.parameters.offer.map((e=>Object.assign(Object.assign({},e),{startAmount:uS(e.startAmount,r).toString(),endAmount:uS(e.endAmount,r).toString()}))),consideration:e.parameters.consideration.map((e=>Object.assign(Object.assign({},e),{startAmount:uS(e.startAmount,r).toString(),endAmount:uS(e.endAmount,r).toString()})))}),signature:e.signature}};const lS=(e,t,n)=>rS.BigNumber.from(e).mul(rS.BigNumber.from(t)).div(n);Yk.mapOrderAmountsFromUnitsToFill=(e,{unitsToFill:t,totalSize:n})=>{const r=rS.BigNumber.from(t);if(r.lte(0))throw new Error("Units to fill must be greater than 1");const i=(0,oS.getMaximumSizeForOrder)(e);return n.eq(0)&&(n=i),{parameters:Object.assign(Object.assign({},e.parameters),{offer:e.parameters.offer.map((e=>Object.assign(Object.assign({},e),{startAmount:lS(e.startAmount,r,n).toString(),endAmount:lS(e.endAmount,r,n).toString()}))),consideration:e.parameters.consideration.map((e=>Object.assign(Object.assign({},e),{startAmount:lS(e.startAmount,r,n).toString(),endAmount:lS(e.endAmount,r,n).toString()})))}),signature:e.signature}};Yk.generateRandomSalt=e=>e?`0x${Buffer.from((0,iS.concat)([(0,iS.keccak256)((0,iS.toUtf8Bytes)(e)).slice(0,10),Uint8Array.from(Array(20).fill(0)),(0,iS.randomBytes)(8)])).toString("hex")}`:`0x${Buffer.from((0,iS.randomBytes)(8)).toString("hex").padStart(64,"0")}`;Yk.shouldUseMatchForFulfill=()=>!0,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.getAdvancedOrderNumeratorDenominator=e.generateFulfillOrdersFulfillments=e.fulfillAvailableOrders=e.validateAndSanitizeFromOrderStatus=e.fulfillStandardOrder=e.fulfillBasicOrder=e.shouldUseBasicFulfill=void 0;const t=T_,n=G_,r=W_,i=cx,a=J_(),o=ex,s=tx(),u=Yk,l=nx;e.shouldUseBasicFulfill=({offer:e,consideration:r,offerer:i},a)=>{if(!a.eq(0))return!1;if(e.length>1||0===r.length)return!1;const o=[...e,...r],l=o.filter((({itemType:e})=>[n.ItemType.ERC721,n.ItemType.ERC1155].includes(e))),c=o.filter((({itemType:e})=>(0,s.isCriteriaItem)(e)));if((0,s.isNativeCurrencyItem)(e[0]))return!1;if(1!==l.length||0!==c.length)return!1;if(!(0,u.areAllCurrenciesSame)({offer:e,consideration:r}))return!1;if(o.some((({startAmount:e,endAmount:t})=>e!==t)))return!1;const[d,...f]=r;if(d.recipient.toLowerCase()!==i.toLowerCase())return!1;if(r.length>1&&f.every((t=>t.itemType===e[0].itemType))&&(0,u.totalItemsAmount)(f).endAmount.gt(e[0].endAmount))return!1;const p=o.filter(s.isCurrencyItem),h=p.filter((({itemType:e})=>e===n.ItemType.NATIVE)).every((({token:e})=>e===t.ethers.constants.AddressZero)),m=p.every((({identifierOrCriteria:e})=>t.BigNumber.from(e).eq(0))),y=l.filter((({itemType:e})=>e===n.ItemType.ERC721)).every((({endAmount:e})=>"1"===e));return h&&m&&y};const c={[n.ItemType.ERC20]:{[n.ItemType.ERC721]:n.BasicOrderRouteType.ERC721_TO_ERC20,[n.ItemType.ERC1155]:n.BasicOrderRouteType.ERC1155_TO_ERC20},[n.ItemType.ERC721]:{[n.ItemType.NATIVE]:n.BasicOrderRouteType.ETH_TO_ERC721,[n.ItemType.ERC20]:n.BasicOrderRouteType.ERC20_TO_ERC721},[n.ItemType.ERC1155]:{[n.ItemType.NATIVE]:n.BasicOrderRouteType.ETH_TO_ERC1155,[n.ItemType.ERC20]:n.BasicOrderRouteType.ERC20_TO_ERC1155}};function d(e,t){const{isValidated:n,isCancelled:r,totalFilled:i,totalSize:a}=t;if(a.gt(0)&&i.div(a).eq(1))throw new Error("The order you are trying to fulfill is already filled");if(r)throw new Error("The order you are trying to fulfill is cancelled");return n?{parameters:Object.assign({},e.parameters),signature:"0x"}:e}function f(e){const t=({sourceOrDestination:e,operator:t="",token:n,identifier:r})=>`${e}-${t}-${n}-${r}`,n={},r={};return e.forEach((({order:e,offererOperator:r,offerCriteria:i},o)=>{const u=(0,a.getItemToCriteriaMap)(e.parameters.offer,i);return e.parameters.offer.forEach(((i,a)=>{var l,c,d;const f=`${t({sourceOrDestination:e.parameters.offerer,operator:r,token:i.token,identifier:null!==(c=null===(l=u.get(i))||void 0===l?void 0:l.identifier)&&void 0!==c?c:i.identifierOrCriteria})}${(0,s.isErc721Item)(i.itemType)?a:""}`;n[f]=[...null!==(d=n[f])&&void 0!==d?d:[],{orderIndex:o,itemIndex:a}]}))})),e.forEach((({order:e,considerationCriteria:n,tips:i},o)=>{const u=(0,a.getItemToCriteriaMap)(e.parameters.consideration,n);return[...e.parameters.consideration,...i].forEach(((e,n)=>{var i,a,l;const c=`${t({sourceOrDestination:e.recipient,token:e.token,identifier:null!==(a=null===(i=u.get(e))||void 0===i?void 0:i.identifier)&&void 0!==a?a:e.identifierOrCriteria})}${(0,s.isErc721Item)(e.itemType)?n:""}`;r[c]=[...null!==(l=r[c])&&void 0!==l?l:[],{orderIndex:o,itemIndex:n}]}))})),{offerFulfillments:Object.values(n),considerationFulfillments:Object.values(r)}}e.fulfillBasicOrder=function({order:e,seaportContract:a,offererBalancesAndApprovals:o,fulfillerBalancesAndApprovals:u,timeBasedItemParams:d,offererOperator:f,fulfillerOperator:p,signer:h,tips:m=[],conduitKey:y=n.NO_CONDUIT,domain:g},b){var v,w;const{offer:E,consideration:T}=e.parameters,A=[...T,...m],_=E[0],[x,...C]=A,k=null===(v=c[_.itemType])||void 0===v?void 0:v[x.itemType];if(void 0===k)throw new Error("Order parameters did not result in a valid basic fulfillment");const S=C.map((({startAmount:e,recipient:t})=>({amount:e,recipient:t}))),I=A.filter((e=>e.itemType!==E[0].itemType)),R=null===(w=(0,s.getSummedTokenAndIdentifierAmounts)({items:I,criterias:[],timeBasedItemParams:Object.assign(Object.assign({},d),{isConsiderationItem:!0})})[t.ethers.constants.AddressZero])||void 0===w?void 0:w[0],O=(0,i.validateBasicFulfillBalancesAndApprovals)({offer:E,consideration:A,offererBalancesAndApprovals:o,fulfillerBalancesAndApprovals:u,timeBasedItemParams:d,offererOperator:f,fulfillerOperator:p}),P={offerer:e.parameters.offerer,offererConduitKey:e.parameters.conduitKey,zone:e.parameters.zone,basicOrderType:e.parameters.orderType+4*k,offerToken:_.token,offerIdentifier:_.identifierOrCriteria,offerAmount:_.endAmount,considerationToken:x.token,considerationIdentifier:x.identifierOrCriteria,considerationAmount:x.endAmount,startTime:e.parameters.startTime,endTime:e.parameters.endTime,salt:e.parameters.salt,totalOriginalAdditionalRecipients:e.parameters.consideration.length-1,signature:e.signature,fulfillerConduitKey:y,additionalRecipients:S,zoneHash:e.parameters.zoneHash},N={value:R},M=[...(0,r.getApprovalActions)(O,b,h),{type:"exchange",transactionMethods:(0,l.getTransactionMethods)(a.connect(h),"fulfillBasicOrder",[P,N],g)}];return{actions:M,executeAllActions:()=>(0,l.executeAllActions)(M)}},e.fulfillStandardOrder=function({order:n,unitsToFill:o=0,totalSize:c,totalFilled:d,offerCriteria:f,considerationCriteria:p,tips:h=[],extraData:m,seaportContract:y,offererBalancesAndApprovals:g,fulfillerBalancesAndApprovals:b,offererOperator:v,fulfillerOperator:w,timeBasedItemParams:E,conduitKey:T,recipientAddress:A,signer:_,domain:x},C){var k;const S=o?(0,u.mapOrderAmountsFromUnitsToFill)(n,{unitsToFill:o,totalSize:c}):(0,u.mapOrderAmountsFromFilledStatus)(n,{totalFilled:d,totalSize:c}),{parameters:{offer:I,consideration:R}}=S,O=[...R,...h],P=I.filter((({itemType:e})=>(0,s.isCriteriaItem)(e))),N=O.filter((({itemType:e})=>(0,s.isCriteriaItem)(e))),M=P.length>0||N.length>0;if(P.length!==f.length||N.length!==p.length)throw new Error("You must supply the appropriate criterias for criteria based items");const L=null===(k=(0,s.getSummedTokenAndIdentifierAmounts)({items:O,criterias:p,timeBasedItemParams:Object.assign(Object.assign({},E),{isConsiderationItem:!0})})[t.ethers.constants.AddressZero])||void 0===k?void 0:k[0],F=(0,i.validateStandardFulfillBalancesAndApprovals)({offer:I,consideration:O,offerCriteria:f,considerationCriteria:p,offererBalancesAndApprovals:g,fulfillerBalancesAndApprovals:b,timeBasedItemParams:E,offererOperator:v,fulfillerOperator:w}),D={value:L},B=(0,r.getApprovalActions)(F,C,_),j=A!==t.ethers.constants.AddressZero,U=Boolean(o)||M||j,z=Object.assign(Object.assign({},n),{parameters:Object.assign(Object.assign({},n.parameters),{consideration:[...n.parameters.consideration,...h],totalOriginalConsiderationItems:R.length})}),{numerator:V,denominator:H}=(0,e.getAdvancedOrderNumeratorDenominator)(n,o),q=[...B,{type:"exchange",transactionMethods:U?(0,l.getTransactionMethods)(y.connect(_),"fulfillAdvancedOrder",[Object.assign(Object.assign({},z),{numerator:V,denominator:H,extraData:null!=m?m:"0x"}),M?(0,a.generateCriteriaResolvers)({orders:[n],offerCriterias:[f],considerationCriterias:[p]}):[],T,A,D],x):(0,l.getTransactionMethods)(y.connect(_),"fulfillOrder",[z,T,D],x)}];return{actions:q,executeAllActions:()=>(0,l.executeAllActions)(q)}},e.validateAndSanitizeFromOrderStatus=d,e.fulfillAvailableOrders=function({ordersMetadata:n,seaportContract:o,fulfillerBalancesAndApprovals:c,fulfillerOperator:p,currentBlockTimestamp:h,ascendingAmountTimestampBuffer:m,conduitKey:y,signer:g,recipientAddress:b,exactApproval:v,domain:w}){const E=n.map((e=>Object.assign(Object.assign({},e),{order:d(e.order,e.orderStatus)}))),T=E.map((e=>Object.assign(Object.assign({},e),{order:e.unitsToFill?(0,u.mapOrderAmountsFromUnitsToFill)(e.order,{unitsToFill:e.unitsToFill,totalSize:e.orderStatus.totalSize}):(0,u.mapOrderAmountsFromFilledStatus)(e.order,{totalFilled:e.orderStatus.totalFilled,totalSize:e.orderStatus.totalSize})})));let A=t.BigNumber.from(0);const _=[],x=E.flatMap((e=>[e.order.parameters.offer,e.order.parameters.consideration])).flat().filter((({itemType:e})=>(0,s.isCriteriaItem)(e))).length>0;T.forEach((({order:e,tips:n,offerCriteria:r,considerationCriteria:a,offererBalancesAndApprovals:o,offererOperator:u})=>{var l,d;const f=[...e.parameters.consideration,...n],y={startTime:e.parameters.startTime,endTime:e.parameters.endTime,currentBlockTimestamp:h,ascendingAmountTimestampBuffer:m,isConsiderationItem:!0};A=A.add(null!==(d=null===(l=(0,s.getSummedTokenAndIdentifierAmounts)({items:f,criterias:a,timeBasedItemParams:y})[t.ethers.constants.AddressZero])||void 0===l?void 0:l[0])&&void 0!==d?d:t.BigNumber.from(0));const g=(0,i.validateStandardFulfillBalancesAndApprovals)({offer:e.parameters.offer,consideration:f,offerCriteria:r,considerationCriteria:a,offererBalancesAndApprovals:o,fulfillerBalancesAndApprovals:c,timeBasedItemParams:y,offererOperator:u,fulfillerOperator:p}),b=e.parameters.offer.filter((({itemType:e})=>(0,s.isCriteriaItem)(e))),v=f.filter((({itemType:e})=>(0,s.isCriteriaItem)(e)));if(b.length!==r.length||v.length!==a.length)throw new Error("You must supply the appropriate criterias for criteria based items");g.forEach((e=>{_.find((t=>t.token===e.token))||_.push(e)}))}));const C={value:A},k=(0,r.getApprovalActions)(_,v,g),S=E.map((({order:t,unitsToFill:n=0,tips:r,extraData:i})=>{const{numerator:a,denominator:o}=(0,e.getAdvancedOrderNumeratorDenominator)(t,n),s=[...t.parameters.consideration,...r];return Object.assign(Object.assign({},t),{parameters:Object.assign(Object.assign({},t.parameters),{consideration:s,totalOriginalConsiderationItems:t.parameters.consideration.length}),numerator:a,denominator:o,extraData:i})})),{offerFulfillments:I,considerationFulfillments:R}=f(n),O={type:"exchange",transactionMethods:(0,l.getTransactionMethods)(o.connect(g),"fulfillAvailableAdvancedOrders",[S,x?(0,a.generateCriteriaResolvers)({orders:n.map((({order:e})=>e)),offerCriterias:n.map((({offerCriteria:e})=>e)),considerationCriterias:n.map((({considerationCriteria:e})=>e))}):[],I,R,y,b,S.length,C],w)},P=[...k,O];return{actions:P,executeAllActions:()=>(0,l.executeAllActions)(P)}},e.generateFulfillOrdersFulfillments=f;e.getAdvancedOrderNumeratorDenominator=(e,n)=>{const r=(0,s.getMaximumSizeForOrder)(e),i=t.BigNumber.from(n),a=(0,o.gcd)(i,r);return{numerator:n?i.div(a):t.BigNumber.from(1),denominator:n?r.div(a):t.BigNumber.from(1)}}}(Zk);var cS=o&&o.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(i,a){function o(e){try{u(r.next(e))}catch(e){a(e)}}function s(e){try{u(r.throw(e))}catch(e){a(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}u((r=r.apply(e,t||[])).next())}))};Object.defineProperty(YA,"__esModule",{value:!0}),YA.Seaport=void 0;const dS=E_,fS=T_,pS=A_,hS=H_,mS=q_,yS=G_,gS=W_,bS=cx,vS=Ex,wS=Zk,ES=tx(),TS=Yk,AS=nx;YA.Seaport=class{constructor(e,{overrides:t,ascendingAmountFulfillmentBuffer:n=300,balanceAndApprovalChecksOnOrderCreation:r=!0,conduitKeyToConduit:i,seaportVersion:a="1.5"}={}){var o,s,u;this.OPENSEA_CONDUIT_KEY=yS.OPENSEA_CONDUIT_KEY,this.getOrderHash=e=>{const t="OfferItem(uint8 itemType,address token,uint256 identifierOrCriteria,uint256 startAmount,uint256 endAmount)",n="ConsiderationItem(uint8 itemType,address token,uint256 identifierOrCriteria,uint256 startAmount,uint256 endAmount,address recipient)",r=`OrderComponents(address offerer,address zone,OfferItem[] offer,ConsiderationItem[] consideration,uint8 orderType,uint256 startTime,uint256 endTime,bytes32 zoneHash,uint256 salt,bytes32 conduitKey,uint256 counter)${n}${t}`,i=fS.ethers.utils.keccak256(fS.ethers.utils.toUtf8Bytes(t)),a=fS.ethers.utils.keccak256(fS.ethers.utils.toUtf8Bytes(n)),o=fS.ethers.utils.keccak256(fS.ethers.utils.toUtf8Bytes(r)),s=fS.ethers.utils.keccak256("0x"+e.offer.map((e=>fS.ethers.utils.keccak256("0x"+[i.slice(2),e.itemType.toString().padStart(64,"0"),e.token.slice(2).padStart(64,"0"),fS.ethers.BigNumber.from(e.identifierOrCriteria).toHexString().slice(2).padStart(64,"0"),fS.ethers.BigNumber.from(e.startAmount).toHexString().slice(2).padStart(64,"0"),fS.ethers.BigNumber.from(e.endAmount).toHexString().slice(2).padStart(64,"0")].join("")).slice(2))).join("")),u=fS.ethers.utils.keccak256("0x"+e.consideration.map((e=>fS.ethers.utils.keccak256("0x"+[a.slice(2),e.itemType.toString().padStart(64,"0"),e.token.slice(2).padStart(64,"0"),fS.ethers.BigNumber.from(e.identifierOrCriteria).toHexString().slice(2).padStart(64,"0"),fS.ethers.BigNumber.from(e.startAmount).toHexString().slice(2).padStart(64,"0"),fS.ethers.BigNumber.from(e.endAmount).toHexString().slice(2).padStart(64,"0"),e.recipient.slice(2).padStart(64,"0")].join("")).slice(2))).join(""));return fS.ethers.utils.keccak256("0x"+[o.slice(2),e.offerer.slice(2).padStart(64,"0"),e.zone.slice(2).padStart(64,"0"),s.slice(2),u.slice(2),e.orderType.toString().padStart(64,"0"),fS.ethers.BigNumber.from(e.startTime).toHexString().slice(2).padStart(64,"0"),fS.ethers.BigNumber.from(e.endTime).toHexString().slice(2).padStart(64,"0"),e.zoneHash.slice(2),fS.BigNumber.from(e.salt).toHexString().slice(2).padStart(64,"0"),e.conduitKey.slice(2).padStart(64,"0"),fS.ethers.BigNumber.from(e.counter).toHexString().slice(2).padStart(64,"0")].join(""))};const l=e instanceof fS.providers.Provider?e:e.provider;if(this.signer=e._isSigner?e:void 0,!l)throw new Error("Either a provider or custom signer with provider must be provided");this.provider=l,this.multicallProvider=new dS.providers.MulticallProvider(this.provider),this.contract=new fS.Contract(null!==(o=null==t?void 0:t.contractAddress)&&void 0!==o?o:"1.5"===a?yS.CROSS_CHAIN_SEAPORT_V1_5_ADDRESS:yS.CROSS_CHAIN_SEAPORT_V1_4_ADDRESS,mS.SeaportABIv14,this.multicallProvider),this.domainRegistry=new fS.Contract(null!==(s=null==t?void 0:t.domainRegistryAddress)&&void 0!==s?s:yS.DOMAIN_REGISTRY_ADDRESS,hS.DomainRegistryABI,this.multicallProvider),this.config={ascendingAmountFulfillmentBuffer:n,balanceAndApprovalChecksOnOrderCreation:r,conduitKeyToConduit:Object.assign(Object.assign(Object.assign({},yS.KNOWN_CONDUIT_KEYS_TO_CONDUIT),{[yS.NO_CONDUIT]:this.contract.address}),i),seaportVersion:a},this.defaultConduitKey=null!==(u=null==t?void 0:t.defaultConduitKey)&&void 0!==u?u:yS.NO_CONDUIT}createOrder(e,t,n){return cS(this,void 0,void 0,(function*(){const r=this._getSigner(t),i=null!=t?t:yield r.getAddress(),{orderComponents:a,approvalActions:o}=yield this._formatOrder(r,i,Boolean(n),e),s={type:"create",getMessageToSign:()=>this._getMessageToSign(a),createOrder:()=>cS(this,void 0,void 0,(function*(){const e=yield this.signOrder(a,i);return{parameters:a,signature:e}}))},u=[...o,s];return{actions:u,executeAllActions:()=>(0,AS.executeAllActions)(u)}}))}createBulkOrders(e,t,n){var r;return cS(this,void 0,void 0,(function*(){const i=this._getSigner(t),a=yield i.getAddress(),o=yield this.getCounter(a),s=[],u=[];for(const t of e){null!==(r=t.counter)&&void 0!==r||(t.counter=o);const{orderComponents:e,approvalActions:l}=yield this._formatOrder(i,a,Boolean(n),t);u.push(e);for(const e of l)void 0===s.find((t=>t.token===e.token))&&s.push(e)}const l={type:"createBulk",getMessageToSign:()=>this._getBulkMessageToSign(u),createBulkOrders:()=>cS(this,void 0,void 0,(function*(){return yield this.signBulkOrder(u,a)}))},c=[...s,l];return{actions:c,executeAllActions:()=>(0,AS.executeAllActions)(c)}}))}_formatOrder(e,t,n,{conduitKey:r=this.defaultConduitKey,zone:i=fS.ethers.constants.AddressZero,zoneHash:a=fS.ethers.constants.HashZero,startTime:o=Math.floor(Date.now()/1e3).toString(),endTime:s=yS.MAX_INT.toString(),offer:u,consideration:l,counter:c,allowPartialFills:d,restrictedByZone:f,fees:p,domain:h,salt:m}){var y;return cS(this,void 0,void 0,(function*(){const g=u.map(TS.mapInputItemToOfferItem),b=[...l.map((e=>{var n;return Object.assign(Object.assign({},(0,TS.mapInputItemToOfferItem)(e)),{recipient:null!==(n=e.recipient)&&void 0!==n?n:t})}))];if((null==p?void 0:p.length)&&!(0,TS.areAllCurrenciesSame)({offer:g,consideration:b}))throw new Error("All currency tokens in the order must be the same token when applying fees");const v=[...g,...b].filter(ES.isCurrencyItem),w=(0,TS.totalItemsAmount)(v),E=this.config.conduitKeyToConduit[r],T=this._getOrderTypeFromOrderOptions({allowPartialFills:d,restrictedByZone:f}),A=[...(0,TS.deductFees)(b,p),...v.length&&null!==(y=null==p?void 0:p.map((e=>(0,TS.feeToConsiderationItem)({fee:e,token:v[0].token,baseAmount:w.startAmount,baseEndAmount:w.endAmount}))))&&void 0!==y?y:[]],_=void 0!==m?`0x${fS.BigNumber.from(m).toHexString().slice(2).padStart(64,"0")}`:(0,TS.generateRandomSalt)(h),x={offerer:t,zone:i,zoneHash:a,startTime:o,endTime:s,orderType:T,offer:g,consideration:A,totalOriginalConsiderationItems:A.length,salt:_,conduitKey:r,counter:(null!=c?c:yield this.getCounter(t)).toString()},C=[];if(this.config.balanceAndApprovalChecksOnOrderCreation){const r=yield(0,bS.getBalancesAndApprovals)({owner:t,items:g,criterias:[],multicallProvider:this.multicallProvider,operator:E}),i=(0,bS.validateOfferBalancesAndApprovals)({offer:g,criterias:[],balancesAndApprovals:r,throwOnInsufficientBalances:!0,operator:E}),a=(0,gS.getApprovalActions)(i,n,e);C.push(...a)}return{orderComponents:x,approvalActions:C}}))}_getSigner(e){if(this.signer)return this.signer;if(!(this.provider instanceof fS.providers.JsonRpcProvider))throw new Error("Either signer or a JsonRpcProvider must be provided");return this.provider.getSigner(e)}_getOrderTypeFromOrderOptions({allowPartialFills:e,restrictedByZone:t}){return e?t?yS.OrderType.PARTIAL_RESTRICTED:yS.OrderType.PARTIAL_OPEN:t?yS.OrderType.FULL_RESTRICTED:yS.OrderType.FULL_OPEN}_getDomainData(){return cS(this,void 0,void 0,(function*(){const{chainId:e}=yield this.provider.getNetwork();return{name:yS.SEAPORT_CONTRACT_NAME,version:"1.5"===this.config.seaportVersion?yS.SEAPORT_CONTRACT_VERSION_V1_5:yS.SEAPORT_CONTRACT_VERSION_V1_4,chainId:e,verifyingContract:this.contract.address}}))}_getMessageToSign(e){return cS(this,void 0,void 0,(function*(){const t=yield this._getDomainData();return JSON.stringify(pS._TypedDataEncoder.getPayload(t,yS.EIP_712_ORDER_TYPE,e))}))}_getBulkMessageToSign(e){return cS(this,void 0,void 0,(function*(){const t=yield this._getDomainData(),n=(0,vS.getBulkOrderTree)(e),r=n.types,i=n.getDataToSign();return JSON.stringify(pS._TypedDataEncoder.getPayload(t,r,{tree:i}))}))}signOrder(e,t){return cS(this,void 0,void 0,(function*(){const n=this._getSigner(t),r=yield this._getDomainData();let i=yield n._signTypedData(r,yS.EIP_712_ORDER_TYPE,e);return 132===i.length&&(i=fS.ethers.utils.splitSignature(i).compact),i}))}signBulkOrder(e,t){return cS(this,void 0,void 0,(function*(){const n=this._getSigner(t),r=yield this._getDomainData(),i=(0,vS.getBulkOrderTree)(e),a=i.types,o={tree:i.getDataToSign()};let s=yield n._signTypedData(r,a,o);132===s.length&&(s=fS.ethers.utils.splitSignature(s).compact);const u=e.map(((e,t)=>({parameters:e,signature:i.getEncodedProofAndSignature(t,s)})));return u}))}cancelOrders(e,t,n){const r=this._getSigner(t);return(0,AS.getTransactionMethods)(this.contract.connect(r),"cancel",[e],n)}bulkCancelOrders(e,t){const n=this._getSigner(e);return(0,AS.getTransactionMethods)(this.contract.connect(n),"incrementCounter",[],t)}validate(e,t,n){const r=this._getSigner(t);return(0,AS.getTransactionMethods)(this.contract.connect(r),"validate",[e],n)}getOrderStatus(e){return this.contract.getOrderStatus(e)}getCounter(e){return this.contract.getCounter(e)}fulfillOrder({order:e,unitsToFill:t,offerCriteria:n=[],considerationCriteria:r=[],tips:i=[],extraData:a="0x",accountAddress:o,conduitKey:s=this.defaultConduitKey,recipientAddress:u=fS.ethers.constants.AddressZero,domain:l,exactApproval:c=!1}){return cS(this,void 0,void 0,(function*(){if(!e.signature)throw new Error("Order is missing signature");const{parameters:d}=e,{offerer:f,offer:p,consideration:h}=d,m=this._getSigner(o),y=yield m.getAddress(),g=this.config.conduitKeyToConduit[d.conduitKey],b=this.config.conduitKeyToConduit[s],[v,w,E,T]=yield Promise.all([(0,bS.getBalancesAndApprovals)({owner:f,items:p,criterias:n,multicallProvider:this.multicallProvider,operator:g}),(0,bS.getBalancesAndApprovals)({owner:y,items:[...p,...h],criterias:[...n,...r],multicallProvider:this.multicallProvider,operator:b}),this.multicallProvider.getBlock("latest"),this.getOrderStatus(this.getOrderHash(d))]),A=E.timestamp,{totalFilled:_,totalSize:x}=T,C=(0,wS.validateAndSanitizeFromOrderStatus)(e,T),k={startTime:C.parameters.startTime,endTime:C.parameters.endTime,currentBlockTimestamp:A,ascendingAmountTimestampBuffer:this.config.ascendingAmountFulfillmentBuffer},S=i.map((e=>Object.assign(Object.assign({},(0,TS.mapInputItemToOfferItem)(e)),{recipient:e.recipient}))),I=u===fS.ethers.constants.AddressZero;return!t&&I&&(0,wS.shouldUseBasicFulfill)(C.parameters,_)?(0,wS.fulfillBasicOrder)({order:C,seaportContract:this.contract,offererBalancesAndApprovals:v,fulfillerBalancesAndApprovals:w,timeBasedItemParams:k,conduitKey:s,offererOperator:g,fulfillerOperator:b,signer:m,tips:S,domain:l},c):(0,wS.fulfillStandardOrder)({order:C,unitsToFill:t,totalFilled:_,totalSize:x.eq(0)?(0,ES.getMaximumSizeForOrder)(C):x,offerCriteria:n,considerationCriteria:r,tips:S,extraData:a,seaportContract:this.contract,offererBalancesAndApprovals:v,fulfillerBalancesAndApprovals:w,timeBasedItemParams:k,conduitKey:s,signer:m,offererOperator:g,fulfillerOperator:b,recipientAddress:u,domain:l},c)}))}fulfillOrders({fulfillOrderDetails:e,accountAddress:t,conduitKey:n=this.defaultConduitKey,recipientAddress:r=fS.ethers.constants.AddressZero,domain:i,exactApproval:a=!1}){return cS(this,void 0,void 0,(function*(){if(e.some((e=>!e.order.signature)))throw new Error("All orders must include signatures");const o=this._getSigner(t),s=yield o.getAddress(),u=e.map((({order:e})=>this.config.conduitKeyToConduit[e.parameters.conduitKey])),l=this.config.conduitKeyToConduit[n],c=e.flatMap((({order:e})=>e.parameters.offer)),d=e.flatMap((({order:e})=>e.parameters.consideration)),f=e.flatMap((({offerCriteria:e=[]})=>e)),p=e.flatMap((({considerationCriteria:e=[]})=>e)),[h,m,y,g]=yield Promise.all([Promise.all(e.map((({order:e,offerCriteria:t=[]},n)=>(0,bS.getBalancesAndApprovals)({owner:e.parameters.offerer,items:e.parameters.offer,criterias:t,operator:u[n],multicallProvider:this.multicallProvider})))),(0,bS.getBalancesAndApprovals)({owner:s,items:[...c,...d],criterias:[...f,...p],operator:l,multicallProvider:this.multicallProvider}),this.multicallProvider.getBlock("latest"),Promise.all(e.map((({order:e})=>this.getOrderStatus(this.getOrderHash(e.parameters)))))]),b=e.map(((e,t)=>{var n,r,i,a,o;return{order:e.order,unitsToFill:e.unitsToFill,orderStatus:g[t],offerCriteria:null!==(n=e.offerCriteria)&&void 0!==n?n:[],considerationCriteria:null!==(r=e.considerationCriteria)&&void 0!==r?r:[],tips:null!==(a=null===(i=e.tips)||void 0===i?void 0:i.map((e=>Object.assign(Object.assign({},(0,TS.mapInputItemToOfferItem)(e)),{recipient:e.recipient}))))&&void 0!==a?a:[],extraData:null!==(o=e.extraData)&&void 0!==o?o:"0x",offererBalancesAndApprovals:h[t],offererOperator:u[t]}}));return(0,wS.fulfillAvailableOrders)({ordersMetadata:b,seaportContract:this.contract,fulfillerBalancesAndApprovals:m,currentBlockTimestamp:y.timestamp,ascendingAmountTimestampBuffer:this.config.ascendingAmountFulfillmentBuffer,fulfillerOperator:l,signer:o,conduitKey:n,recipientAddress:r,domain:i,exactApproval:a})}))}matchOrders({orders:e,fulfillments:t,overrides:n,accountAddress:r,domain:i}){const a=this._getSigner(r);return(0,AS.getTransactionMethods)(this.contract.connect(a),"matchOrders",[e,t,n],i)}setDomain(e,t){const n=this._getSigner(t);return(0,AS.getTransactionMethods)(this.domainRegistry.connect(n),"setDomain",[e])}getNumberOfDomains(e){return cS(this,void 0,void 0,(function*(){return this.domainRegistry.getNumberOfDomains(e)}))}getDomain(e,t){return this.domainRegistry.getDomain(e,t)}getDomains(e,t){return cS(this,void 0,void 0,(function*(){try{if(t)throw Error;return this.domainRegistry.getDomains(e)}catch(t){const n=(yield this.domainRegistry.getNumberOfDomains(e)).toNumber(),r=Promise.all([...Array(n).keys()].map((t=>this.domainRegistry.getDomain(e,t))));return r}}))}},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.Seaport=void 0;const t=YA;Object.defineProperty(e,"Seaport",{enumerable:!0,get:function(){return t.Seaport}})}(ZA);class _S{config;constructor(e){this.config=e}}class xS extends Error{url;status;statusText;body;request;constructor(e,t,n){super(n),this.name="ApiError",this.url=t.url,this.status=t.status,this.statusText=t.statusText,this.body=t.body,this.request=e}}class CS extends Error{constructor(e){super(e),this.name="CancelError"}get isCancelled(){return!0}}class kS{[Symbol.toStringTag];_isResolved;_isRejected;_isCancelled;_cancelHandlers;_promise;_resolve;_reject;constructor(e){this._isResolved=!1,this._isRejected=!1,this._isCancelled=!1,this._cancelHandlers=[],this._promise=new Promise(((t,n)=>{this._resolve=t,this._reject=n;const r=e=>{this._isResolved||this._isRejected||this._isCancelled||this._cancelHandlers.push(e)};return Object.defineProperty(r,"isResolved",{get:()=>this._isResolved}),Object.defineProperty(r,"isRejected",{get:()=>this._isRejected}),Object.defineProperty(r,"isCancelled",{get:()=>this._isCancelled}),e((e=>{this._isResolved||this._isRejected||this._isCancelled||(this._isResolved=!0,this._resolve?.(e))}),(e=>{this._isResolved||this._isRejected||this._isCancelled||(this._isRejected=!0,this._reject?.(e))}),r)}))}then(e,t){return this._promise.then(e,t)}catch(e){return this._promise.catch(e)}finally(e){return this._promise.finally(e)}cancel(){if(!(this._isResolved||this._isRejected||this._isCancelled)){if(this._isCancelled=!0,this._cancelHandlers.length)try{for(const e of this._cancelHandlers)e()}catch(e){return void console.warn("Cancellation threw an error",e)}this._cancelHandlers.length=0,this._reject?.(new CS("Request aborted"))}}get isCancelled(){return this._isCancelled}}const SS=e=>null!=e,IS=e=>"string"==typeof e,RS=e=>IS(e)&&""!==e,OS=e=>"object"==typeof e&&"string"==typeof e.type&&"function"==typeof e.stream&&"function"==typeof e.arrayBuffer&&"function"==typeof e.constructor&&"string"==typeof e.constructor.name&&/^(Blob|File)$/.test(e.constructor.name)&&/^(Blob|File)$/.test(e[Symbol.toStringTag]),PS=e=>e>=200&&e<300,NS=e=>{const t=[],n=(e,r)=>{SS(r)&&(Array.isArray(r)?r.forEach((t=>{n(e,t)})):"object"==typeof r?Object.entries(r).forEach((([t,r])=>{n(`${e}[${t}]`,r)})):((e,n)=>{t.push(`${encodeURIComponent(e)}=${encodeURIComponent(String(n))}`)})(e,r))};return Object.entries(e).forEach((([e,t])=>{n(e,t)})),t.length>0?`?${t.join("&")}`:""},MS=async(e,t)=>"function"==typeof t?t(e):t,LS=async(e,t,n)=>{const r=await MS(t,e.TOKEN),i=await MS(t,e.USERNAME),a=await MS(t,e.PASSWORD),o=await MS(t,e.HEADERS),s="function"==typeof n?.getHeaders&&n?.getHeaders()||{},u=Object.entries({Accept:"application/json",...o,...t.headers,...s}).filter((([e,t])=>SS(t))).reduce(((e,[t,n])=>({...e,[t]:String(n)})),{});if(RS(r)&&(u.Authorization=`Bearer ${r}`),RS(i)&&RS(a)){const e=(e=>{try{return btoa(e)}catch(t){return Buffer.from(e).toString("base64")}})(`${i}:${a}`);u.Authorization=`Basic ${e}`}return t.body&&(t.mediaType?u["Content-Type"]=t.mediaType:OS(t.body)?u["Content-Type"]=t.body.type||"application/octet-stream":IS(t.body)?u["Content-Type"]="text/plain":t.body instanceof XA||(u["Content-Type"]="application/json")),u},FS=(e,t)=>new kS((async(n,r,i)=>{try{const r=((e,t)=>{const n=e.ENCODE_PATH||encodeURI,r=t.url.replace("{api-version}",e.VERSION).replace(/{(.*?)}/g,((e,r)=>t.path?.hasOwnProperty(r)?n(String(t.path[r])):e)),i=`${e.BASE}${r}`;return t.query?`${i}${NS(t.query)}`:i})(e,t),a=(e=>{if(e.formData){const t=new XA,n=(e,n)=>{IS(n)||OS(n)?t.append(e,n):t.append(e,JSON.stringify(n))};return Object.entries(e.formData).filter((([e,t])=>SS(t))).forEach((([e,t])=>{Array.isArray(t)?t.forEach((t=>n(e,t))):n(e,t)})),t}})(t),o=(e=>{if(e.body)return e.body})(t),s=await LS(e,t,a);if(!i.isCancelled){const u=await(async(e,t,n,r,i,a,o)=>{const s=hp.CancelToken.source(),u={url:n,headers:a,data:r??i,method:t.method,withCredentials:e.WITH_CREDENTIALS,cancelToken:s.token};o((()=>s.cancel("The user aborted a request.")));try{return await hp.request(u)}catch(e){const t=e;if(t.response)return t.response;throw e}})(e,t,r,o,a,s,i),l=(e=>{if(204!==e.status)return e.data})(u),c=((e,t)=>{if(t){const n=e.headers[t];if(IS(n))return n}})(u,t.responseHeader),d={url:r,ok:PS(u.status),status:u.status,statusText:u.statusText,body:c??l};((e,t)=>{const n={400:"Bad Request",401:"Unauthorized",403:"Forbidden",404:"Not Found",500:"Internal Server Error",502:"Bad Gateway",503:"Service Unavailable",...e.errors}[t.status];if(n)throw new xS(e,t,n);if(!t.ok)throw new xS(e,t,"Generic Error")})(t,d),n(d.body)}}catch(e){r(e)}}));class DS extends _S{constructor(e){super(e)}request(e){return FS(this.config,e)}}class BS{httpRequest;constructor(e){this.httpRequest=e}cancelOrders({chainName:e,requestBody:t}){return this.httpRequest.request({method:"POST",url:"/v1/chains/{chain_name}/orders/cancel",path:{chain_name:e},body:t,mediaType:"application/json",errors:{400:"Bad Request (400)",401:"Unauthorised Request (401)",404:"The specified resource was not found (404)",429:"Too Many Requests (429)",500:"Internal Server Error (500)",501:"Not Implemented Error (501)"}})}listListings({chainName:e,status:t,sellItemContractAddress:n,buyItemContractAddress:r,sellItemTokenId:i,fromUpdatedAt:a,pageSize:o,sortBy:s,sortDirection:u,pageCursor:l}){return this.httpRequest.request({method:"GET",url:"/v1/chains/{chain_name}/orders/listings",path:{chain_name:e},query:{status:t,sell_item_contract_address:n,buy_item_contract_address:r,sell_item_token_id:i,from_updated_at:a,page_size:o,sort_by:s,sort_direction:u,page_cursor:l},errors:{400:"Bad Request (400)",404:"The specified resource was not found (404)",500:"Internal Server Error (500)"}})}createListing({chainName:e,requestBody:t}){return this.httpRequest.request({method:"POST",url:"/v1/chains/{chain_name}/orders/listings",path:{chain_name:e},body:t,mediaType:"application/json",errors:{400:"Bad Request (400)",404:"The specified resource was not found (404)",500:"Internal Server Error (500)"}})}getListing({chainName:e,listingId:t}){return this.httpRequest.request({method:"GET",url:"/v1/chains/{chain_name}/orders/listings/{listing_id}",path:{chain_name:e,listing_id:t},errors:{400:"Bad Request (400)",404:"The specified resource was not found (404)",500:"Internal Server Error (500)"}})}fulfillmentData({chainName:e,requestBody:t}){return this.httpRequest.request({method:"POST",url:"/v1/chains/{chain_name}/orders/fulfillment-data",path:{chain_name:e},body:t,mediaType:"application/json",errors:{400:"Bad Request (400)",404:"The specified resource was not found (404)",500:"Internal Server Error (500)"}})}listTrades({chainName:e,accountAddress:t,fromIndexedAt:n,pageSize:r,sortBy:i,sortDirection:a,pageCursor:o}){return this.httpRequest.request({method:"GET",url:"/v1/chains/{chain_name}/trades",path:{chain_name:e},query:{account_address:t,from_indexed_at:n,page_size:r,sort_by:i,sort_direction:a,page_cursor:o},errors:{400:"Bad Request (400)",404:"The specified resource was not found (404)",500:"Internal Server Error (500)"}})}getTrade({chainName:e,tradeId:t}){return this.httpRequest.request({method:"GET",url:"/v1/chains/{chain_name}/trades/{trade_id}",path:{chain_name:e,trade_id:t},errors:{400:"Bad Request (400)",404:"The specified resource was not found (404)",500:"Internal Server Error (500)"}})}}class jS{orders;request;constructor(e,t=DS){this.request=new t({BASE:e?.BASE??"https://api.sandbox.immutable.com",VERSION:e?.VERSION??"1.0.0",WITH_CREDENTIALS:e?.WITH_CREDENTIALS??!1,CREDENTIALS:e?.CREDENTIALS??"include",TOKEN:e?.TOKEN,USERNAME:e?.USERNAME,PASSWORD:e?.PASSWORD,HEADERS:e?.HEADERS,ENCODE_PATH:e?.ENCODE_PATH}),this.orders=new BS(this.request)}}var US,zS,VS,HS,qS,GS,WS,$S,KS;function XS(e){const t=e.buy.map((e=>{if("ERC20"===e.item_type)return{type:"ERC20",contractAddress:e.contract_address,amount:e.start_amount};if("NATIVE"===e.item_type)return{type:"NATIVE",amount:e.start_amount};throw new Error("Buy items must be either ERC20 or NATIVE")})),n=e.sell.map((e=>{if("ERC721"===e.item_type)return{type:"ERC721",contractAddress:e.contract_address,tokenId:e.token_id};throw new Error("Sell items must ERC721")}));return{id:e.id,accountAddress:e.account_address,buy:t,sell:n,fees:e.fees.map((e=>({amount:e.amount,recipient:e.recipient,type:e.fee_type}))),chain:e.chain,createdAt:e.created_at,endAt:e.end_at,protocolData:{counter:e.protocol_data.counter,orderType:e.protocol_data.order_type,seaportAddress:e.protocol_data.seaport_address,seaportVersion:e.protocol_data.seaport_version,zoneAddress:e.protocol_data.zone_address},salt:e.salt,signature:e.signature,startAt:e.start_at,status:e.status,updatedAt:e.updated_at}}function ZS(e){const t=e.buy.map((e=>{if("ERC20"===e.item_type)return{type:"ERC20",contractAddress:e.contract_address,amount:e.start_amount};if("NATIVE"===e.item_type)return{type:"NATIVE",amount:e.start_amount};throw new Error("Buy items must be either ERC20 or NATIVE")})),n=e.sell.map((e=>{if("ERC721"===e.item_type)return{type:"ERC721",contractAddress:e.contract_address,tokenId:e.token_id};throw new Error("Sell items must ERC721")}));return{id:e.id,orderId:e.order_id,buy:t,sell:n,buyerFees:e.buyer_fees.map((e=>({amount:e.amount,recipient:e.recipient,type:e.fee_type}))),chain:e.chain,indexedAt:e.indexed_at,blockchainMetadata:{blockNumber:e.blockchain_metadata.block_number,logIndex:e.blockchain_metadata.log_index,transactionHash:e.blockchain_metadata.transaction_hash,transactionIndex:e.blockchain_metadata.transaction_index},buyerAddress:e.buyer_address,makerAddress:e.maker_address,sellerAddress:e.seller_address,takerAddress:e.taker_address}}function YS(e){return{nextCursor:e.next_cursor,previousCursor:e.previous_cursor}}!function(e){var t;(t=e.cancellation_type||(e.cancellation_type={})).ON_CHAIN="ON_CHAIN",t.OFF_CHAIN="OFF_CHAIN"}(US||(US={})),function(e){(e.reason_code||(e.reason_code={})).ALREADY_FILLED="ALREADY_FILLED"}(zS||(zS={})),function(e){var t;(t=e.fee_type||(e.fee_type={})).ROYALTY="ROYALTY",t.MAKER_ECOSYSTEM="MAKER_ECOSYSTEM",t.TAKER_ECOSYSTEM="TAKER_ECOSYSTEM",t.PROTOCOL="PROTOCOL"}(VS||(VS={})),function(e){e.PENDING="PENDING",e.ACTIVE="ACTIVE",e.INACTIVE="INACTIVE",e.FILLED="FILLED",e.EXPIRED="EXPIRED",e.CANCELLED="CANCELLED"}(HS||(HS={})),function(e){(e.order_type||(e.order_type={})).FULL_RESTRICTED="FULL_RESTRICTED"}(qS||(qS={})),function(e){e.MAKER_ECOSYSTEM="MAKER_ECOSYSTEM",e.TAKER_ECOSYSTEM="TAKER_ECOSYSTEM",e.PROTOCOL="PROTOCOL",e.ROYALTY="ROYALTY"}(GS||(GS={})),function(e){e.APPROVAL="APPROVAL",e.FULFILL_ORDER="FULFILL_ORDER"}(WS||(WS={})),function(e){e.CREATE_LISTING="CREATE_LISTING"}($S||($S={})),function(e){e.TRANSACTION="TRANSACTION",e.SIGNABLE="SIGNABLE"}(KS||(KS={}));const JS="1.5",QS={OrderComponents:[{name:"offerer",type:"address"},{name:"zone",type:"address"},{name:"offer",type:"OfferItem[]"},{name:"consideration",type:"ConsiderationItem[]"},{name:"orderType",type:"uint8"},{name:"startTime",type:"uint256"},{name:"endTime",type:"uint256"},{name:"zoneHash",type:"bytes32"},{name:"salt",type:"uint256"},{name:"conduitKey",type:"bytes32"},{name:"counter",type:"uint256"}],OfferItem:[{name:"itemType",type:"uint8"},{name:"token",type:"address"},{name:"identifierOrCriteria",type:"uint256"},{name:"startAmount",type:"uint256"},{name:"endAmount",type:"uint256"}],ConsiderationItem:[{name:"itemType",type:"uint8"},{name:"token",type:"address"},{name:"identifierOrCriteria",type:"uint256"},{name:"startAmount",type:"uint256"},{name:"endAmount",type:"uint256"},{name:"recipient",type:"address"}]};var eI,tI,nI,rI;function iI(e){return async()=>{const t=await e.buildTransaction();return t.gasLimit=await e.estimateGas(),t.gasLimit=t.gasLimit.add(t.gasLimit.div(5)),t}}!function(e){e[e.FULL_OPEN=0]="FULL_OPEN",e[e.PARTIAL_OPEN=1]="PARTIAL_OPEN",e[e.FULL_RESTRICTED=2]="FULL_RESTRICTED",e[e.PARTIAL_RESTRICTED=3]="PARTIAL_RESTRICTED"}(eI||(eI={})),function(e){e[e.NATIVE=0]="NATIVE",e[e.ERC20=1]="ERC20",e[e.ERC721=2]="ERC721",e[e.ERC1155=3]="ERC1155",e[e.ERC721_WITH_CRITERIA=4]="ERC721_WITH_CRITERIA",e[e.ERC1155_WITH_CRITERIA=5]="ERC1155_WITH_CRITERIA"}(tI||(tI={})),function(e){e[e.OFFER=0]="OFFER",e[e.CONSIDERATION=1]="CONSIDERATION"}(nI||(nI={})),function(e){e[e.ETH_TO_ERC721=0]="ETH_TO_ERC721",e[e.ETH_TO_ERC1155=1]="ETH_TO_ERC1155",e[e.ERC20_TO_ERC721=2]="ERC20_TO_ERC721",e[e.ERC20_TO_ERC1155=3]="ERC20_TO_ERC1155",e[e.ERC721_TO_ERC20=4]="ERC721_TO_ERC20",e[e.ERC1155_TO_ERC20=5]="ERC1155_TO_ERC20"}(rI||(rI={}));class aI{seaportLibFactory;provider;seaportContractAddress;zoneContractAddress;constructor(e,t,n,r){this.seaportLibFactory=e,this.provider=t,this.seaportContractAddress=n,this.zoneContractAddress=r}async prepareSeaportOrder(e,t,n,r,i){const{actions:a}=await this.createSeaportOrder(e,t,n,r,i),o=[],s=a.find((e=>"approval"===e.type));s&&o.push({type:KS.TRANSACTION,purpose:WS.APPROVAL,buildTransaction:iI(s.transactionMethods)});const u=a.find((e=>"create"===e.type));if(!u)throw new Error("No create order action found");const l=function(e){const t=JSON.parse(e).message;return t.salt=Y.from(t.salt).toHexString(),t}(await u.getMessageToSign());return o.push({type:KS.SIGNABLE,purpose:$S.CREATE_LISTING,message:await this.getTypedDataFromOrderComponents(l)}),{actions:o,orderComponents:l,orderHash:this.getSeaportLib().getOrderHash(l)}}async fulfillOrder(e,t,n){const{orderComponents:r,tips:i}=this.mapImmutableOrderToSeaportOrderComponents(e),a=this.getSeaportLib(e),{actions:o}=await a.fulfillOrders({accountAddress:t,fulfillOrderDetails:[{order:{parameters:r,signature:e.signature},extraData:n,tips:i}]}),s=[],u=o.find((e=>"approval"===e.type));u&&s.push({type:KS.TRANSACTION,buildTransaction:iI(u.transactionMethods),purpose:WS.APPROVAL});const l=o.find((e=>"exchange"===e.type));if(!l)throw new Error("No exchange action found");return s.push({type:KS.TRANSACTION,buildTransaction:iI(l.transactionMethods),purpose:WS.FULFILL_ORDER}),{actions:s,expiration:aI.getExpirationISOTimeFromExtraData(n),order:XS(e)}}async fulfillBulkOrders(e,t){const n=e.map((e=>{const{orderComponents:t,tips:n}=this.mapImmutableOrderToSeaportOrderComponents(e.order);return{order:{parameters:t,signature:e.order.signature},extraData:e.extra_data,tips:n}})),{actions:r}=await this.getSeaportLib().fulfillOrders({fulfillOrderDetails:n,accountAddress:t}),i=[],a=r.find((e=>"approval"===e.type));a&&i.push({type:KS.TRANSACTION,buildTransaction:iI(a.transactionMethods),purpose:WS.APPROVAL});const o=r.find((e=>"exchange"===e.type));if(!o)throw new Error("No exchange action found");return i.push({type:KS.TRANSACTION,buildTransaction:iI(o.transactionMethods),purpose:WS.FULFILL_ORDER}),{actions:i,expiration:n.map((e=>aI.getExpirationISOTimeFromExtraData(e.extraData))).reduce(((e,t)=>new Date(e)<new Date(t)?e:t))}}async cancelOrder(e,t){const{orderComponents:n}=this.mapImmutableOrderToSeaportOrderComponents(e),r=this.getSeaportLib(e);return iI(await r.cancelOrders([n],t))()}mapImmutableOrderToSeaportOrderComponents(e){return function(e,t,n){const r=e.buy.map((t=>{switch(t.item_type){case"NATIVE":return{startAmount:t.start_amount,endAmount:t.start_amount,itemType:tI.NATIVE,recipient:e.account_address,token:Dt,identifierOrCriteria:"0"};case"ERC20":return{startAmount:t.start_amount,endAmount:t.start_amount,itemType:tI.ERC20,recipient:e.account_address,token:t.contract_address||Dt,identifierOrCriteria:"0"};default:return{startAmount:"1",endAmount:"1",itemType:tI.ERC721,recipient:e.account_address,token:t.contract_address||Dt,identifierOrCriteria:"0"}}})),i=e.fees.map((t=>({amount:t.amount,itemType:"ERC20"===e.buy[0].item_type?tI.ERC20:tI.NATIVE,recipient:t.recipient,token:"ERC20"===e.buy[0].item_type?e.buy[0].contract_address:Dt,identifierOrCriteria:"0"})));return{orderComponents:{conduitKey:Wt,consideration:[...r],offer:e.sell.map((e=>{const t=e;return{startAmount:"1",endAmount:"1",itemType:tI.ERC721,token:t.contract_address,identifierOrCriteria:t.token_id}})),counter:t,endTime:Math.round(new Date(e.end_at).getTime()/1e3).toString(),startTime:Math.round(new Date(e.start_at).getTime()/1e3).toString(),salt:e.salt,offerer:e.account_address,zone:n,totalOriginalConsiderationItems:r.length,orderType:eI.FULL_RESTRICTED,zoneHash:Wt},tips:i}}(e,e.protocol_data.counter,this.zoneContractAddress)}createSeaportOrder(e,t,n,r,i){return this.getSeaportLib().createOrder({allowPartialFills:!1,offer:[{itemType:tI.ERC721,token:t.contractAddress,identifier:t.tokenId}],consideration:[{token:"ERC20"===n.type?n.contractAddress:void 0,amount:n.amount,recipient:e}],startTime:(r.getTime()/1e3).toFixed(0),endTime:(i.getTime()/1e3).toFixed(0),zone:this.zoneContractAddress,restrictedByZone:!0},e)}async getTypedDataFromOrderComponents(e){const{chainId:t}=await this.provider.getNetwork();return{domain:{name:"ImmutableSeaport",version:JS,chainId:t,verifyingContract:this.seaportContractAddress},types:QS,value:e}}getSeaportLib(e){const t=e?.protocol_data?.seaport_address??this.seaportContractAddress,n=JS;return this.seaportLibFactory.create(n,t)}static getExpirationISOTimeFromExtraData(e){const t=e.slice(44,60),n=parseInt(t,16);return new Date(1e3*n).toISOString()}}class oI{orderbookService;chainName;seaportAddress;constructor(e,t,n){this.orderbookService=e,this.chainName=t,this.seaportAddress=n}async fulfillmentData(e){return this.orderbookService.fulfillmentData({chainName:this.chainName,requestBody:e})}async getListing(e){return this.orderbookService.getListing({chainName:this.chainName,listingId:e})}async getTrade(e){return this.orderbookService.getTrade({chainName:this.chainName,tradeId:e})}async listListings(e){return this.orderbookService.listListings({chainName:this.chainName,...e})}async listTrades(e){return this.orderbookService.listTrades({chainName:this.chainName,...e})}async createListing({orderHash:e,orderComponents:t,orderSignature:n,makerFees:r}){if(1!==t.offer.length)throw new Error("Only one item can be listed at a time");if(Number(t.offer[0].itemType)!==tI.ERC721)throw new Error("Only ERC721 tokens can be listed");const i=[...t.consideration.map((e=>e.itemType))];if(!(1===new Set(i).size))throw new Error("All consideration items must be of the same type");return this.orderbookService.createListing({chainName:this.chainName,requestBody:{order_hash:e,account_address:t.offerer,buy:[{item_type:Number(t.consideration[0].itemType)===tI.NATIVE?"NATIVE":"ERC20",start_amount:t.consideration[0].startAmount,contract_address:t.consideration[0].token}],fees:r.map((e=>({amount:e.amount,fee_type:GS.MAKER_ECOSYSTEM,recipient:e.recipient}))),end_at:new Date(parseInt(`${t.endTime.toString()}000`,10)).toISOString(),protocol_data:{order_type:qS.order_type.FULL_RESTRICTED,zone_address:t.zone,seaport_address:this.seaportAddress,seaport_version:JS,counter:t.counter.toString()},salt:t.salt,sell:[{contract_address:t.offer[0].token,token_id:t.offer[0].identifierOrCriteria,item_type:"ERC721"}],signature:n,start_at:new Date(parseInt(`${t.startTime.toString()}000`,10)).toISOString()}})}}class sI{chainName;seaportAddress;orderbookClient;constructor(e,t,n){this.chainName=t,this.seaportAddress=n,this.orderbookClient=new jS({BASE:e})}create(){return new oI(this.orderbookClient.orders,this.chainName,this.seaportAddress)}}class uI{defaultSeaportContractAddress;provider;constructor(e,t){this.defaultSeaportContractAddress=e,this.provider=t}create(e,t){const n=e??JS,r=t??this.defaultSeaportContractAddress;return new ZA.Seaport(this.provider,{seaportVersion:n,balanceAndApprovalChecksOnOrderCreation:!0,overrides:{contractAddress:r}})}}class lI{apiClient;seaport;orderbookConfig;constructor(e){const t={...function(e){switch(e){case i.SANDBOX:return{seaportContractAddress:"0x7Fb7Da6De152597830eD16361633e362A2F59410",zoneContractAddress:"0x63441cBfBd15Dd8f5E92598E535661Ac5aCB808E",apiEndpoint:"https://api.sandbox.immutable.com",chainName:"imtbl-zkevm-testnet",provider:new ac("https://rpc.testnet.immutable.com")};case i.PRODUCTION:return{seaportContractAddress:"",zoneContractAddress:"",apiEndpoint:"https://api.immutable.com",chainName:"imtbl-zkevm-mainnet",provider:new ac("https://rpc.immutable.com")};default:return null}}(e.baseConfig.environment),...e.overrides};if(!t)throw new Error("Orderbook configuration not passed, please specify the environment under config.baseConfig.environment");this.orderbookConfig=t;const{apiEndpoint:n,chainName:r}=this.orderbookConfig;if(!n)throw new Error("API endpoint must be provided");this.apiClient=new sI(n,r,this.orderbookConfig.seaportContractAddress).create();const a=new uI(this.orderbookConfig.seaportContractAddress,this.orderbookConfig.provider);this.seaport=new aI(a,this.orderbookConfig.provider,this.orderbookConfig.seaportContractAddress,this.orderbookConfig.zoneContractAddress)}config(){return this.orderbookConfig}async getListing(e){return{result:XS((await this.apiClient.getListing(e)).result)}}async getTrade(e){return{result:ZS((await this.apiClient.getTrade(e)).result)}}async listListings(e){const t=await this.apiClient.listListings(e);return{page:YS(t.page),result:t.result.map(XS)}}async listTrades(e){const t=await this.apiClient.listTrades(e);return{page:YS(t.page),result:t.result.map(ZS)}}async prepareListing({makerAddress:e,sell:t,buy:n,orderExpiry:r}){return this.seaport.prepareSeaportOrder(e,t,n,new Date,r||new Date(Date.now()+63072e6))}async createListing(e){return{result:XS((await this.apiClient.createListing({...e})).result)}}async fulfillOrder(e,t,n){const r=await this.apiClient.fulfillmentData([{order_id:e,fees:n.map((e=>({amount:e.amount,fee_type:GS.TAKER_ECOSYSTEM,recipient:e.recipient})))}]);if(r.result.unfulfillable_orders?.length>0)throw new Error(`Unable to prepare fulfillment date: ${r.result.unfulfillable_orders[0].reason}`);if(1!==r.result.fulfillable_orders?.length)throw new Error("unexpected fulfillable order result length");const i=r.result.fulfillable_orders[0].extra_data,a=r.result.fulfillable_orders[0].order;if(a.status.name!==HS.ACTIVE)throw new Error(`Cannot fulfil order that is not active. Current status: ${a.status}`);return this.seaport.fulfillOrder(a,t,i)}async fulfillBulkOrders(e,t){const n=await this.apiClient.fulfillmentData(e.map((e=>({order_id:e.listingId,fees:e.takerFees.map((e=>({amount:e.amount,fee_type:GS.TAKER_ECOSYSTEM,recipient:e.recipient})))}))));try{return{...await this.seaport.fulfillBulkOrders(n.result.fulfillable_orders,t),fulfillableOrders:n.result.fulfillable_orders.map((e=>XS(e.order))),unfulfillableOrders:n.result.unfulfillable_orders.map((e=>({orderId:e.order_id,reason:e.reason}))),sufficientBalance:!0}}catch(e){if(String(e).includes("The fulfiller does not have the balances needed to fulfill."))return{fulfillableOrders:n.result.fulfillable_orders.map((e=>XS(e.order))),unfulfillableOrders:n.result.unfulfillable_orders.map((e=>({orderId:e.order_id,reason:e.reason}))),sufficientBalance:!1};throw e}}async cancelOrder(e,t){const n=await this.apiClient.getListing(e);if(n.result.status.name!==HS.ACTIVE&&n.result.status.name!==HS.INACTIVE&&n.result.status.name!==HS.PENDING)throw new Error(`Cannot cancel order with status ${n.result.status}`);if(n.result.account_address!==t.toLowerCase())throw new Error(`Only account ${n.result.account_address} can cancel order ${e}`);return{unsignedCancelOrderTransaction:await this.seaport.cancelOrder(n.result,t)}}}const cI=4e5,dI="https://api.sandbox.immutable.com".replace(/\/+$/,"");class fI{basePath;axios;configuration;constructor(e,t=dI,n=hp){this.basePath=t,this.axios=n,e&&(this.configuration=e,this.basePath=e.basePath||this.basePath)}}class pI extends Error{field;constructor(e,t){super(t),this.field=e,this.name="RequiredError"}}const hI="https://example.com",mI=function(e,t,n){if(null==n)throw new pI(t,`Required parameter ${t} was null or undefined when calling ${e}.`)},yI=async function(e,t,n){if(n&&n.apiKey){const r="function"==typeof n.apiKey?await n.apiKey(t):await n.apiKey;e[t]=r}},gI=async function(e,t){if(t&&t.accessToken){const n="function"==typeof t.accessToken?await t.accessToken():await t.accessToken;e.Authorization="Bearer "+n}};function bI(e,t,n=""){null!=t&&("object"==typeof t?Array.isArray(t)?t.forEach((t=>bI(e,t,n))):Object.keys(t).forEach((r=>bI(e,t[r],`${n}${""!==n?".":""}${r}`))):e.has(n)?e.append(n,t):e.set(n,t))}const vI=function(e,...t){const n=new URLSearchParams(e.search);bI(n,t),e.search=n.toString()},wI=function(e,t,n){const r="string"!=typeof e;return(r&&n&&n.isJsonMime?n.isJsonMime(t.headers["Content-Type"]):r)?JSON.stringify(void 0!==e?e:{}):e||""},EI=function(e){return e.pathname+e.search+e.hash},TI=function(e,t,n,r){return(i=t,a=n)=>{const o={...e.options,url:(r?.basePath||i.defaults.baseURL||a)+e.url};return i.request(o)}},AI=function(e){return{getActivity:async(t,n,r={})=>{mI("getActivity","chainName",t),mI("getActivity","activityId",n);const i="/v1/chains/{chain_name}/activities/{activity_id}".replace("{chain_name}",encodeURIComponent(String(t))).replace("{activity_id}",encodeURIComponent(String(n))),a=new URL(i,hI);let o;e&&(o=e.baseOptions);const s={method:"GET",...o,...r};vI(a,{});let u=o&&o.headers?o.headers:{};return s.headers={...u,...r.headers},{url:EI(a),options:s}},listActivities:async(t,n,r,i,a,o,s,u,l,c,d={})=>{mI("listActivities","chainName",t);const f="/v1/chains/{chain_name}/activities".replace("{chain_name}",encodeURIComponent(String(t))),p=new URL(f,hI);let h;e&&(h=e.baseOptions);const m={method:"GET",...h,...d},y={};void 0!==n&&(y.contract_address=n),void 0!==r&&(y.token_id=r),void 0!==i&&(y.account_address=i),void 0!==a&&(y.activity_type=a),void 0!==o&&(y.from_indexed_at=o instanceof Date?o.toISOString():o),void 0!==s&&(y.to_indexed_at=s instanceof Date?s.toISOString():s),void 0!==u&&(y.transaction_hash=u),void 0!==l&&(y.page_cursor=l),void 0!==c&&(y.page_size=c),vI(p,y);let g=h&&h.headers?h.headers:{};return m.headers={...g,...d.headers},{url:EI(p),options:m}}}},_I=function(e){const t=AI(e);return{async getActivity(n,r,i){const a=await t.getActivity(n,r,i);return TI(a,hp,dI,e)},async listActivities(n,r,i,a,o,s,u,l,c,d,f){const p=await t.listActivities(n,r,i,a,o,s,u,l,c,d,f);return TI(p,hp,dI,e)}}};const xI=function(e){return{listChains:async(t,n,r={})=>{const i=new URL("/v1/chains",hI);let a;e&&(a=e.baseOptions);const o={method:"GET",...a,...r},s={};void 0!==t&&(s.page_cursor=t),void 0!==n&&(s.page_size=n),vI(i,s);let u=a&&a.headers?a.headers:{};return o.headers={...u,...r.headers},{url:EI(i),options:o}}}},CI=function(e){const t=xI(e);return{async listChains(n,r,i){const a=await t.listChains(n,r,i);return TI(a,hp,dI,e)}}};const kI=function(e){return{getCollection:async(t,n,r={})=>{mI("getCollection","contractAddress",t),mI("getCollection","chainName",n);const i="/v1/chains/{chain_name}/collections/{contract_address}".replace("{contract_address}",encodeURIComponent(String(t))).replace("{chain_name}",encodeURIComponent(String(n))),a=new URL(i,hI);let o;e&&(o=e.baseOptions);const s={method:"GET",...o,...r};vI(a,{});let u=o&&o.headers?o.headers:{};return s.headers={...u,...r.headers},{url:EI(a),options:s}},listCollections:async(t,n,r,i,a,o={})=>{mI("listCollections","chainName",t);const s="/v1/chains/{chain_name}/collections".replace("{chain_name}",encodeURIComponent(String(t))),u=new URL(s,hI);let l;e&&(l=e.baseOptions);const c={method:"GET",...l,...o},d={};n&&(d.contract_address=n),void 0!==r&&(d.from_updated_at=r instanceof Date?r.toISOString():r),void 0!==i&&(d.page_cursor=i),void 0!==a&&(d.page_size=a),vI(u,d);let f=l&&l.headers?l.headers:{};return c.headers={...f,...o.headers},{url:EI(u),options:c}},listCollectionsByNFTOwner:async(t,n,r,i,a={})=>{mI("listCollectionsByNFTOwner","accountAddress",t),mI("listCollectionsByNFTOwner","chainName",n);const o="/v1/chains/{chain_name}/accounts/{account_address}/collections".replace("{account_address}",encodeURIComponent(String(t))).replace("{chain_name}",encodeURIComponent(String(n))),s=new URL(o,hI);let u;e&&(u=e.baseOptions);const l={method:"GET",...u,...a},c={};void 0!==r&&(c.page_cursor=r),void 0!==i&&(c.page_size=i),vI(s,c);let d=u&&u.headers?u.headers:{};return l.headers={...d,...a.headers},{url:EI(s),options:l}},refreshCollectionMetadata:async(t,n,r,i={})=>{mI("refreshCollectionMetadata","contractAddress",t),mI("refreshCollectionMetadata","chainName",n),mI("refreshCollectionMetadata","refreshCollectionMetadataRequest",r);const a="/v1/chains/{chain_name}/collections/{contract_address}/refresh-metadata".replace("{contract_address}",encodeURIComponent(String(t))).replace("{chain_name}",encodeURIComponent(String(n))),o=new URL(a,hI);let s;e&&(s=e.baseOptions);const u={method:"POST",...s,...i},l={};await yI(l,"x-immutable-api-Key",e),l["Content-Type"]="application/json",vI(o,{});let c=s&&s.headers?s.headers:{};return u.headers={...l,...c,...i.headers},u.data=wI(r,u,e),{url:EI(o),options:u}}}},SI=function(e){const t=kI(e);return{async getCollection(n,r,i){const a=await t.getCollection(n,r,i);return TI(a,hp,dI,e)},async listCollections(n,r,i,a,o,s){const u=await t.listCollections(n,r,i,a,o,s);return TI(u,hp,dI,e)},async listCollectionsByNFTOwner(n,r,i,a,o){const s=await t.listCollectionsByNFTOwner(n,r,i,a,o);return TI(s,hp,dI,e)},async refreshCollectionMetadata(n,r,i,a){const o=await t.refreshCollectionMetadata(n,r,i,a);return TI(o,hp,dI,e)}}};const II=function(e){return{getMetadata:async(t,n,r,i={})=>{mI("getMetadata","chainName",t),mI("getMetadata","contractAddress",n),mI("getMetadata","metadataId",r);const a="/v1/chains/{chain_name}/collections/{contract_address}/metadata/{metadata_id}".replace("{chain_name}",encodeURIComponent(String(t))).replace("{contract_address}",encodeURIComponent(String(n))).replace("{metadata_id}",encodeURIComponent(String(r))),o=new URL(a,hI);let s;e&&(s=e.baseOptions);const u={method:"GET",...s,...i};vI(o,{});let l=s&&s.headers?s.headers:{};return u.headers={...l,...i.headers},{url:EI(o),options:u}},listMetadata:async(t,n,r,i,a,o={})=>{mI("listMetadata","chainName",t),mI("listMetadata","contractAddress",n);const s="/v1/chains/{chain_name}/collections/{contract_address}/metadata".replace("{chain_name}",encodeURIComponent(String(t))).replace("{contract_address}",encodeURIComponent(String(n))),u=new URL(s,hI);let l;e&&(l=e.baseOptions);const c={method:"GET",...l,...o},d={};void 0!==r&&(d.from_updated_at=r instanceof Date?r.toISOString():r),void 0!==i&&(d.page_cursor=i),void 0!==a&&(d.page_size=a),vI(u,d);let f=l&&l.headers?l.headers:{};return c.headers={...f,...o.headers},{url:EI(u),options:c}},refreshMetadataByID:async(t,n,r,i={})=>{mI("refreshMetadataByID","chainName",t),mI("refreshMetadataByID","contractAddress",n),mI("refreshMetadataByID","refreshMetadataByIDRequest",r);const a="/v1/chains/{chain_name}/collections/{contract_address}/metadata/refresh-metadata".replace("{chain_name}",encodeURIComponent(String(t))).replace("{contract_address}",encodeURIComponent(String(n))),o=new URL(a,hI);let s;e&&(s=e.baseOptions);const u={method:"POST",...s,...i},l={};await yI(l,"x-immutable-api-Key",e),l["Content-Type"]="application/json",vI(o,{});let c=s&&s.headers?s.headers:{};return u.headers={...l,...c,...i.headers},u.data=wI(r,u,e),{url:EI(o),options:u}},refreshNFTMetadataByTokenID:async(t,n,r,i={})=>{mI("refreshNFTMetadataByTokenID","contractAddress",t),mI("refreshNFTMetadataByTokenID","chainName",n),mI("refreshNFTMetadataByTokenID","refreshNFTMetadataByTokenIDRequest",r);const a="/v1/chains/{chain_name}/collections/{contract_address}/nfts/refresh-metadata".replace("{contract_address}",encodeURIComponent(String(t))).replace("{chain_name}",encodeURIComponent(String(n))),o=new URL(a,hI);let s;e&&(s=e.baseOptions);const u={method:"POST",...s,...i},l={};await yI(l,"x-immutable-api-Key",e),l["Content-Type"]="application/json",vI(o,{});let c=s&&s.headers?s.headers:{};return u.headers={...l,...c,...i.headers},u.data=wI(r,u,e),{url:EI(o),options:u}}}},RI=function(e){const t=II(e);return{async getMetadata(n,r,i,a){const o=await t.getMetadata(n,r,i,a);return TI(o,hp,dI,e)},async listMetadata(n,r,i,a,o,s){const u=await t.listMetadata(n,r,i,a,o,s);return TI(u,hp,dI,e)},async refreshMetadataByID(n,r,i,a){const o=await t.refreshMetadataByID(n,r,i,a);return TI(o,hp,dI,e)},async refreshNFTMetadataByTokenID(n,r,i,a){const o=await t.refreshNFTMetadataByTokenID(n,r,i,a);return TI(o,hp,dI,e)}}};const OI=function(e){return{listNFTOwners:async(t,n,r,i,a,o={})=>{mI("listNFTOwners","contractAddress",t),mI("listNFTOwners","tokenId",n),mI("listNFTOwners","chainName",r);const s="/v1/chains/{chain_name}/collections/{contract_address}/nfts/{token_id}/owners".replace("{contract_address}",encodeURIComponent(String(t))).replace("{token_id}",encodeURIComponent(String(n))).replace("{chain_name}",encodeURIComponent(String(r))),u=new URL(s,hI);let l;e&&(l=e.baseOptions);const c={method:"GET",...l,...o},d={};void 0!==i&&(d.page_cursor=i),void 0!==a&&(d.page_size=a),vI(u,d);let f=l&&l.headers?l.headers:{};return c.headers={...f,...o.headers},{url:EI(u),options:c}},listOwnersByContractAddress:async(t,n,r,i,a,o={})=>{mI("listOwnersByContractAddress","contractAddress",t),mI("listOwnersByContractAddress","chainName",n);const s="/v1/chains/{chain_name}/collections/{contract_address}/owners".replace("{contract_address}",encodeURIComponent(String(t))).replace("{chain_name}",encodeURIComponent(String(n))),u=new URL(s,hI);let l;e&&(l=e.baseOptions);const c={method:"GET",...l,...o},d={};void 0!==r&&(d.from_updated_at=r instanceof Date?r.toISOString():r),void 0!==i&&(d.page_cursor=i),void 0!==a&&(d.page_size=a),vI(u,d);let f=l&&l.headers?l.headers:{};return c.headers={...f,...o.headers},{url:EI(u),options:c}}}},PI=function(e){const t=OI(e);return{async listNFTOwners(n,r,i,a,o,s){const u=await t.listNFTOwners(n,r,i,a,o,s);return TI(u,hp,dI,e)},async listOwnersByContractAddress(n,r,i,a,o,s){const u=await t.listOwnersByContractAddress(n,r,i,a,o,s);return TI(u,hp,dI,e)}}};const NI=function(e){return{getNFT:async(t,n,r,i={})=>{mI("getNFT","contractAddress",t),mI("getNFT","tokenId",n),mI("getNFT","chainName",r);const a="/v1/chains/{chain_name}/collections/{contract_address}/nfts/{token_id}".replace("{contract_address}",encodeURIComponent(String(t))).replace("{token_id}",encodeURIComponent(String(n))).replace("{chain_name}",encodeURIComponent(String(r))),o=new URL(a,hI);let s;e&&(s=e.baseOptions);const u={method:"GET",...s,...i};vI(o,{});let l=s&&s.headers?s.headers:{};return u.headers={...l,...i.headers},{url:EI(o),options:u}},listAllNFTOwners:async(t,n,r,i,a={})=>{mI("listAllNFTOwners","chainName",t),mI("listAllNFTOwners","fromUpdatedAt",n);const o="/v1/chains/{chain_name}/nft-owners".replace("{chain_name}",encodeURIComponent(String(t))),s=new URL(o,hI);let u;e&&(u=e.baseOptions);const l={method:"GET",...u,...a},c={};void 0!==n&&(c.from_updated_at=n instanceof Date?n.toISOString():n),void 0!==r&&(c.page_cursor=r),void 0!==i&&(c.page_size=i),vI(s,c);let d=u&&u.headers?u.headers:{};return l.headers={...d,...a.headers},{url:EI(s),options:l}},listAllNFTs:async(t,n,r,i,a={})=>{mI("listAllNFTs","chainName",t);const o="/v1/chains/{chain_name}/nfts".replace("{chain_name}",encodeURIComponent(String(t))),s=new URL(o,hI);let u;e&&(u=e.baseOptions);const l={method:"GET",...u,...a},c={};void 0!==n&&(c.from_updated_at=n instanceof Date?n.toISOString():n),void 0!==r&&(c.page_cursor=r),void 0!==i&&(c.page_size=i),vI(s,c);let d=u&&u.headers?u.headers:{};return l.headers={...d,...a.headers},{url:EI(s),options:l}},listNFTs:async(t,n,r,i,a,o={})=>{mI("listNFTs","contractAddress",t),mI("listNFTs","chainName",n);const s="/v1/chains/{chain_name}/collections/{contract_address}/nfts".replace("{contract_address}",encodeURIComponent(String(t))).replace("{chain_name}",encodeURIComponent(String(n))),u=new URL(s,hI);let l;e&&(l=e.baseOptions);const c={method:"GET",...l,...o},d={};void 0!==r&&(d.from_updated_at=r instanceof Date?r.toISOString():r),void 0!==i&&(d.page_cursor=i),void 0!==a&&(d.page_size=a),vI(u,d);let f=l&&l.headers?l.headers:{};return c.headers={...f,...o.headers},{url:EI(u),options:c}},listNFTsByAccountAddress:async(t,n,r,i,a,o={})=>{mI("listNFTsByAccountAddress","accountAddress",t),mI("listNFTsByAccountAddress","chainName",n);const s="/v1/chains/{chain_name}/accounts/{account_address}/nfts".replace("{account_address}",encodeURIComponent(String(t))).replace("{chain_name}",encodeURIComponent(String(n))),u=new URL(s,hI);let l;e&&(l=e.baseOptions);const c={method:"GET",...l,...o},d={};void 0!==r&&(d.contract_address=r),void 0!==i&&(d.page_cursor=i),void 0!==a&&(d.page_size=a),vI(u,d);let f=l&&l.headers?l.headers:{};return c.headers={...f,...o.headers},{url:EI(u),options:c}}}},MI=function(e){const t=NI(e);return{async getNFT(n,r,i,a){const o=await t.getNFT(n,r,i,a);return TI(o,hp,dI,e)},async listAllNFTOwners(n,r,i,a,o){const s=await t.listAllNFTOwners(n,r,i,a,o);return TI(s,hp,dI,e)},async listAllNFTs(n,r,i,a,o){const s=await t.listAllNFTs(n,r,i,a,o);return TI(s,hp,dI,e)},async listNFTs(n,r,i,a,o,s){const u=await t.listNFTs(n,r,i,a,o,s);return TI(u,hp,dI,e)},async listNFTsByAccountAddress(n,r,i,a,o,s){const u=await t.listNFTsByAccountAddress(n,r,i,a,o,s);return TI(u,hp,dI,e)}}};const LI=function(e){return{cancelOrders:async(t,n,r={})=>{mI("cancelOrders","chainName",t),mI("cancelOrders","cancelOrdersRequestBody",n);const i="/v1/chains/{chain_name}/orders/cancel".replace("{chain_name}",encodeURIComponent(String(t))),a=new URL(i,hI);let o;e&&(o=e.baseOptions);const s={method:"POST",...o,...r},u={};u["Content-Type"]="application/json",vI(a,{});let l=o&&o.headers?o.headers:{};return s.headers={...u,...l,...r.headers},s.data=wI(n,s,e),{url:EI(a),options:s}},createListing:async(t,n,r={})=>{mI("createListing","chainName",t),mI("createListing","createListingRequestBody",n);const i="/v1/chains/{chain_name}/orders/listings".replace("{chain_name}",encodeURIComponent(String(t))),a=new URL(i,hI);let o;e&&(o=e.baseOptions);const s={method:"POST",...o,...r},u={};u["Content-Type"]="application/json",vI(a,{});let l=o&&o.headers?o.headers:{};return s.headers={...u,...l,...r.headers},s.data=wI(n,s,e),{url:EI(a),options:s}},fulfillmentData:async(t,n,r={})=>{mI("fulfillmentData","chainName",t),mI("fulfillmentData","fulfillmentDataRequest",n);const i="/v1/chains/{chain_name}/orders/fulfillment-data".replace("{chain_name}",encodeURIComponent(String(t))),a=new URL(i,hI);let o;e&&(o=e.baseOptions);const s={method:"POST",...o,...r},u={};u["Content-Type"]="application/json",vI(a,{});let l=o&&o.headers?o.headers:{};return s.headers={...u,...l,...r.headers},s.data=wI(n,s,e),{url:EI(a),options:s}},getListing:async(t,n,r={})=>{mI("getListing","chainName",t),mI("getListing","listingId",n);const i="/v1/chains/{chain_name}/orders/listings/{listing_id}".replace("{chain_name}",encodeURIComponent(String(t))).replace("{listing_id}",encodeURIComponent(String(n))),a=new URL(i,hI);let o;e&&(o=e.baseOptions);const s={method:"GET",...o,...r};vI(a,{});let u=o&&o.headers?o.headers:{};return s.headers={...u,...r.headers},{url:EI(a),options:s}},getTrade:async(t,n,r={})=>{mI("getTrade","chainName",t),mI("getTrade","tradeId",n);const i="/v1/chains/{chain_name}/trades/{trade_id}".replace("{chain_name}",encodeURIComponent(String(t))).replace("{trade_id}",encodeURIComponent(String(n))),a=new URL(i,hI);let o;e&&(o=e.baseOptions);const s={method:"GET",...o,...r};vI(a,{});let u=o&&o.headers?o.headers:{};return s.headers={...u,...r.headers},{url:EI(a),options:s}},listListings:async(t,n,r,i,a,o,s,u,l,c={})=>{mI("listListings","chainName",t);const d="/v1/chains/{chain_name}/orders/listings".replace("{chain_name}",encodeURIComponent(String(t))),f=new URL(d,hI);let p;e&&(p=e.baseOptions);const h={method:"GET",...p,...c},m={};void 0!==n&&(m.status=n),void 0!==r&&(m.sell_item_contract_address=r),void 0!==i&&(m.buy_item_contract_address=i),void 0!==a&&(m.sell_item_token_id=a),void 0!==o&&(m.page_size=o),void 0!==s&&(m.sort_by=s),void 0!==u&&(m.sort_direction=u),void 0!==l&&(m.page_cursor=l),vI(f,m);let y=p&&p.headers?p.headers:{};return h.headers={...y,...c.headers},{url:EI(f),options:h}},listTrades:async(t,n,r,i,a,o,s={})=>{mI("listTrades","chainName",t);const u="/v1/chains/{chain_name}/trades".replace("{chain_name}",encodeURIComponent(String(t))),l=new URL(u,hI);let c;e&&(c=e.baseOptions);const d={method:"GET",...c,...s},f={};void 0!==n&&(f.account_address=n),void 0!==r&&(f.page_size=r),void 0!==i&&(f.sort_by=i),void 0!==a&&(f.sort_direction=a),void 0!==o&&(f.page_cursor=o),vI(l,f);let p=c&&c.headers?c.headers:{};return d.headers={...p,...s.headers},{url:EI(l),options:d}}}},FI=function(e){const t=LI(e);return{async cancelOrders(n,r,i){const a=await t.cancelOrders(n,r,i);return TI(a,hp,dI,e)},async createListing(n,r,i){const a=await t.createListing(n,r,i);return TI(a,hp,dI,e)},async fulfillmentData(n,r,i){const a=await t.fulfillmentData(n,r,i);return TI(a,hp,dI,e)},async getListing(n,r,i){const a=await t.getListing(n,r,i);return TI(a,hp,dI,e)},async getTrade(n,r,i){const a=await t.getTrade(n,r,i);return TI(a,hp,dI,e)},async listListings(n,r,i,a,o,s,u,l,c,d){const f=await t.listListings(n,r,i,a,o,s,u,l,c,d);return TI(f,hp,dI,e)},async listTrades(n,r,i,a,o,s,u){const l=await t.listTrades(n,r,i,a,o,s,u);return TI(l,hp,dI,e)}}};const DI=function(e){return{createCounterfactualAddress:async(t,n={})=>{mI("createCounterfactualAddress","createCounterfactualAddressRequest",t);const r=new URL("/passport-mr/v1/counterfactual-address",hI);let i;e&&(i=e.baseOptions);const a={method:"POST",...i,...n},o={};await gI(o,e),o["Content-Type"]="application/json",vI(r,{});let s=i&&i.headers?i.headers:{};return a.headers={...o,...s,...n.headers},a.data=wI(t,a,e),{url:EI(r),options:a}},getLinkedAddresses:async(t,n={})=>{mI("getLinkedAddresses","userId",t);const r="/passport-mr/v1/users/{userId}/linked-addresses".replace("{userId}",encodeURIComponent(String(t))),i=new URL(r,hI);let a;e&&(a=e.baseOptions);const o={method:"GET",...a,...n},s={};await gI(s,e),vI(i,{});let u=a&&a.headers?a.headers:{};return o.headers={...s,...u,...n.headers},{url:EI(i),options:o}}}},BI=function(e){const t=DI(e);return{async createCounterfactualAddress(n,r){const i=await t.createCounterfactualAddress(n,r);return TI(i,hp,dI,e)},async getLinkedAddresses(n,r){const i=await t.getLinkedAddresses(n,r);return TI(i,hp,dI,e)}}};const jI=function(e){return{getERC20Token:async(t,n,r={})=>{mI("getERC20Token","contractAddress",t),mI("getERC20Token","chainName",n);const i="/v1/chains/{chain_name}/tokens/{contract_address}".replace("{contract_address}",encodeURIComponent(String(t))).replace("{chain_name}",encodeURIComponent(String(n))),a=new URL(i,hI);let o;e&&(o=e.baseOptions);const s={method:"GET",...o,...r};vI(a,{});let u=o&&o.headers?o.headers:{};return s.headers={...u,...r.headers},{url:EI(a),options:s}},listERC20Tokens:async(t,n,r,i,a={})=>{mI("listERC20Tokens","chainName",t);const o="/v1/chains/{chain_name}/tokens".replace("{chain_name}",encodeURIComponent(String(t))),s=new URL(o,hI);let u;e&&(u=e.baseOptions);const l={method:"GET",...u,...a},c={};void 0!==n&&(c.from_updated_at=n instanceof Date?n.toISOString():n),void 0!==r&&(c.page_cursor=r),void 0!==i&&(c.page_size=i),vI(s,c);let d=u&&u.headers?u.headers:{};return l.headers={...d,...a.headers},{url:EI(s),options:l}}}},UI=function(e){const t=jI(e);return{async getERC20Token(n,r,i){const a=await t.getERC20Token(n,r,i);return TI(a,hp,dI,e)},async listERC20Tokens(n,r,i,a,o){const s=await t.listERC20Tokens(n,r,i,a,o);return TI(s,hp,dI,e)}}};var zI=Object.freeze({__proto__:null,ActiveOrderStatusNameEnum:{Active:"ACTIVE"},ActivitiesApi:class extends fI{getActivity(e,t){return _I(this.configuration).getActivity(e.chainName,e.activityId,t).then((e=>e(this.axios,this.basePath)))}listActivities(e,t){return _I(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)))}},ActivitiesApiAxiosParamCreator:AI,ActivitiesApiFactory:function(e,t,n){const r=_I(e);return{getActivity:(e,i)=>r.getActivity(e.chainName,e.activityId,i).then((e=>e(n,t))),listActivities:(e,i)=>r.listActivities(e.chainName,e.contractAddress,e.tokenId,e.accountAddress,e.activityType,e.fromIndexedAt,e.toIndexedAt,e.transactionHash,e.pageCursor,e.pageSize,i).then((e=>e(n,t)))}},ActivitiesApiFp:_I,ActivityType:{Mint:"mint",Burn:"burn",Transfer:"transfer",Sale:"sale",Deposit:"deposit",Withdrawal:"withdrawal"},CancelledOrderStatusCancellationTypeEnum:{OnChain:"ON_CHAIN",OffChain:"OFF_CHAIN"},CancelledOrderStatusNameEnum:{Cancelled:"CANCELLED"},ChainsApi:class extends fI{listChains(e={},t){return CI(this.configuration).listChains(e.pageCursor,e.pageSize,t).then((e=>e(this.axios,this.basePath)))}},ChainsApiAxiosParamCreator:xI,ChainsApiFactory:function(e,t,n){const r=CI(e);return{listChains:(e={},i)=>r.listChains(e.pageCursor,e.pageSize,i).then((e=>e(n,t)))}},ChainsApiFp:CI,CollectionContractType:{Erc721:"ERC721"},CollectionsApi:class extends fI{getCollection(e,t){return SI(this.configuration).getCollection(e.contractAddress,e.chainName,t).then((e=>e(this.axios,this.basePath)))}listCollections(e,t){return SI(this.configuration).listCollections(e.chainName,e.contractAddress,e.fromUpdatedAt,e.pageCursor,e.pageSize,t).then((e=>e(this.axios,this.basePath)))}listCollectionsByNFTOwner(e,t){return SI(this.configuration).listCollectionsByNFTOwner(e.accountAddress,e.chainName,e.pageCursor,e.pageSize,t).then((e=>e(this.axios,this.basePath)))}refreshCollectionMetadata(e,t){return SI(this.configuration).refreshCollectionMetadata(e.contractAddress,e.chainName,e.refreshCollectionMetadataRequest,t).then((e=>e(this.axios,this.basePath)))}},CollectionsApiAxiosParamCreator:kI,CollectionsApiFactory:function(e,t,n){const r=SI(e);return{getCollection:(e,i)=>r.getCollection(e.contractAddress,e.chainName,i).then((e=>e(n,t))),listCollections:(e,i)=>r.listCollections(e.chainName,e.contractAddress,e.fromUpdatedAt,e.pageCursor,e.pageSize,i).then((e=>e(n,t))),listCollectionsByNFTOwner:(e,i)=>r.listCollectionsByNFTOwner(e.accountAddress,e.chainName,e.pageCursor,e.pageSize,i).then((e=>e(n,t))),refreshCollectionMetadata:(e,i)=>r.refreshCollectionMetadata(e.contractAddress,e.chainName,e.refreshCollectionMetadataRequest,i).then((e=>e(n,t)))}},CollectionsApiFp:SI,Configuration: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())}},ERC20ItemItemTypeEnum:{Erc20:"ERC20"},ERC721ItemItemTypeEnum:{Erc721:"ERC721"},ExpiredOrderStatusNameEnum:{Expired:"EXPIRED"},FailedOrderCancellationReasonCodeEnum:{AlreadyFilled:"ALREADY_FILLED"},FeeFeeTypeEnum:{Royalty:"ROYALTY",MakerEcosystem:"MAKER_ECOSYSTEM",TakerEcosystem:"TAKER_ECOSYSTEM",Protocol:"PROTOCOL"},FilledOrderStatusNameEnum:{Filled:"FILLED"},InactiveOrderStatusNameEnum:{Inactive:"INACTIVE"},ListListingsSortByEnum:{CreatedAt:"created_at",UpdatedAt:"updated_at",BuyItemAmount:"buy_item_amount"},ListListingsSortDirectionEnum:{Asc:"asc",Desc:"desc"},ListTradesSortByEnum:{IndexedAt:"indexed_at"},ListTradesSortDirectionEnum:{Asc:"asc",Desc:"desc"},MetadataApi:class extends fI{getMetadata(e,t){return RI(this.configuration).getMetadata(e.chainName,e.contractAddress,e.metadataId,t).then((e=>e(this.axios,this.basePath)))}listMetadata(e,t){return RI(this.configuration).listMetadata(e.chainName,e.contractAddress,e.fromUpdatedAt,e.pageCursor,e.pageSize,t).then((e=>e(this.axios,this.basePath)))}refreshMetadataByID(e,t){return RI(this.configuration).refreshMetadataByID(e.chainName,e.contractAddress,e.refreshMetadataByIDRequest,t).then((e=>e(this.axios,this.basePath)))}refreshNFTMetadataByTokenID(e,t){return RI(this.configuration).refreshNFTMetadataByTokenID(e.contractAddress,e.chainName,e.refreshNFTMetadataByTokenIDRequest,t).then((e=>e(this.axios,this.basePath)))}},MetadataApiAxiosParamCreator:II,MetadataApiFactory:function(e,t,n){const r=RI(e);return{getMetadata:(e,i)=>r.getMetadata(e.chainName,e.contractAddress,e.metadataId,i).then((e=>e(n,t))),listMetadata:(e,i)=>r.listMetadata(e.chainName,e.contractAddress,e.fromUpdatedAt,e.pageCursor,e.pageSize,i).then((e=>e(n,t))),refreshMetadataByID:(e,i)=>r.refreshMetadataByID(e.chainName,e.contractAddress,e.refreshMetadataByIDRequest,i).then((e=>e(n,t))),refreshNFTMetadataByTokenID:(e,i)=>r.refreshNFTMetadataByTokenID(e.contractAddress,e.chainName,e.refreshNFTMetadataByTokenIDRequest,i).then((e=>e(n,t)))}},MetadataApiFp:RI,NFTContractType:{Erc721:"ERC721"},NativeItemItemTypeEnum:{Native:"NATIVE"},NftOwnersApi:class extends fI{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)))}listOwnersByContractAddress(e,t){return PI(this.configuration).listOwnersByContractAddress(e.contractAddress,e.chainName,e.fromUpdatedAt,e.pageCursor,e.pageSize,t).then((e=>e(this.axios,this.basePath)))}},NftOwnersApiAxiosParamCreator:OI,NftOwnersApiFactory:function(e,t,n){const r=PI(e);return{listNFTOwners:(e,i)=>r.listNFTOwners(e.contractAddress,e.tokenId,e.chainName,e.pageCursor,e.pageSize,i).then((e=>e(n,t))),listOwnersByContractAddress:(e,i)=>r.listOwnersByContractAddress(e.contractAddress,e.chainName,e.fromUpdatedAt,e.pageCursor,e.pageSize,i).then((e=>e(n,t)))}},NftOwnersApiFp:PI,NftsApi:class extends fI{getNFT(e,t){return MI(this.configuration).getNFT(e.contractAddress,e.tokenId,e.chainName,t).then((e=>e(this.axios,this.basePath)))}listAllNFTOwners(e,t){return MI(this.configuration).listAllNFTOwners(e.chainName,e.fromUpdatedAt,e.pageCursor,e.pageSize,t).then((e=>e(this.axios,this.basePath)))}listAllNFTs(e,t){return MI(this.configuration).listAllNFTs(e.chainName,e.fromUpdatedAt,e.pageCursor,e.pageSize,t).then((e=>e(this.axios,this.basePath)))}listNFTs(e,t){return MI(this.configuration).listNFTs(e.contractAddress,e.chainName,e.fromUpdatedAt,e.pageCursor,e.pageSize,t).then((e=>e(this.axios,this.basePath)))}listNFTsByAccountAddress(e,t){return MI(this.configuration).listNFTsByAccountAddress(e.accountAddress,e.chainName,e.contractAddress,e.pageCursor,e.pageSize,t).then((e=>e(this.axios,this.basePath)))}},NftsApiAxiosParamCreator:NI,NftsApiFactory:function(e,t,n){const r=MI(e);return{getNFT:(e,i)=>r.getNFT(e.contractAddress,e.tokenId,e.chainName,i).then((e=>e(n,t))),listAllNFTOwners:(e,i)=>r.listAllNFTOwners(e.chainName,e.fromUpdatedAt,e.pageCursor,e.pageSize,i).then((e=>e(n,t))),listAllNFTs:(e,i)=>r.listAllNFTs(e.chainName,e.fromUpdatedAt,e.pageCursor,e.pageSize,i).then((e=>e(n,t))),listNFTs:(e,i)=>r.listNFTs(e.contractAddress,e.chainName,e.fromUpdatedAt,e.pageCursor,e.pageSize,i).then((e=>e(n,t))),listNFTsByAccountAddress:(e,i)=>r.listNFTsByAccountAddress(e.accountAddress,e.chainName,e.contractAddress,e.pageCursor,e.pageSize,i).then((e=>e(n,t)))}},NftsApiFp:MI,OrderStatusName:{Pending:"PENDING",Active:"ACTIVE",Inactive:"INACTIVE",Filled:"FILLED",Expired:"EXPIRED",Cancelled:"CANCELLED"},OrdersApi:class extends fI{cancelOrders(e,t){return FI(this.configuration).cancelOrders(e.chainName,e.cancelOrdersRequestBody,t).then((e=>e(this.axios,this.basePath)))}createListing(e,t){return FI(this.configuration).createListing(e.chainName,e.createListingRequestBody,t).then((e=>e(this.axios,this.basePath)))}fulfillmentData(e,t){return FI(this.configuration).fulfillmentData(e.chainName,e.fulfillmentDataRequest,t).then((e=>e(this.axios,this.basePath)))}getListing(e,t){return FI(this.configuration).getListing(e.chainName,e.listingId,t).then((e=>e(this.axios,this.basePath)))}getTrade(e,t){return FI(this.configuration).getTrade(e.chainName,e.tradeId,t).then((e=>e(this.axios,this.basePath)))}listListings(e,t){return FI(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)))}listTrades(e,t){return FI(this.configuration).listTrades(e.chainName,e.accountAddress,e.pageSize,e.sortBy,e.sortDirection,e.pageCursor,t).then((e=>e(this.axios,this.basePath)))}},OrdersApiAxiosParamCreator:LI,OrdersApiFactory:function(e,t,n){const r=FI(e);return{cancelOrders:(e,i)=>r.cancelOrders(e.chainName,e.cancelOrdersRequestBody,i).then((e=>e(n,t))),createListing:(e,i)=>r.createListing(e.chainName,e.createListingRequestBody,i).then((e=>e(n,t))),fulfillmentData:(e,i)=>r.fulfillmentData(e.chainName,e.fulfillmentDataRequest,i).then((e=>e(n,t))),getListing:(e,i)=>r.getListing(e.chainName,e.listingId,i).then((e=>e(n,t))),getTrade:(e,i)=>r.getTrade(e.chainName,e.tradeId,i).then((e=>e(n,t))),listListings:(e,i)=>r.listListings(e.chainName,e.status,e.sellItemContractAddress,e.buyItemContractAddress,e.sellItemTokenId,e.pageSize,e.sortBy,e.sortDirection,e.pageCursor,i).then((e=>e(n,t))),listTrades:(e,i)=>r.listTrades(e.chainName,e.accountAddress,e.pageSize,e.sortBy,e.sortDirection,e.pageCursor,i).then((e=>e(n,t)))}},OrdersApiFp:FI,PassportApi:class extends fI{createCounterfactualAddress(e,t){return BI(this.configuration).createCounterfactualAddress(e.createCounterfactualAddressRequest,t).then((e=>e(this.axios,this.basePath)))}getLinkedAddresses(e,t){return BI(this.configuration).getLinkedAddresses(e.userId,t).then((e=>e(this.axios,this.basePath)))}},PassportApiAxiosParamCreator:DI,PassportApiFactory:function(e,t,n){const r=BI(e);return{createCounterfactualAddress:(e,i)=>r.createCounterfactualAddress(e.createCounterfactualAddressRequest,i).then((e=>e(n,t))),getLinkedAddresses:(e,i)=>r.getLinkedAddresses(e.userId,i).then((e=>e(n,t)))}},PassportApiFp:BI,PendingOrderStatusNameEnum:{Pending:"PENDING"},ProtocolDataOrderTypeEnum:{FullRestricted:"FULL_RESTRICTED"},SaleFeeTypeEnum:{Royalty:"ROYALTY"},TokenContractType:{Erc20:"ERC20"},TokensApi:class extends fI{getERC20Token(e,t){return UI(this.configuration).getERC20Token(e.contractAddress,e.chainName,t).then((e=>e(this.axios,this.basePath)))}listERC20Tokens(e,t){return UI(this.configuration).listERC20Tokens(e.chainName,e.fromUpdatedAt,e.pageCursor,e.pageSize,t).then((e=>e(this.axios,this.basePath)))}},TokensApiAxiosParamCreator:jI,TokensApiFactory:function(e,t,n){const r=UI(e);return{getERC20Token:(e,i)=>r.getERC20Token(e.contractAddress,e.chainName,i).then((e=>e(n,t))),listERC20Tokens:(e,i)=>r.listERC20Tokens(e.chainName,e.fromUpdatedAt,e.pageCursor,e.pageSize,i).then((e=>e(n,t)))}},TokensApiFp:UI});class VI extends Error{code;details;link;traceId;constructor({message:e,code:t,details:n,link:r,trace_id:i}){super(e),this.code=t,this.details=n,this.link=r,this.traceId=i}}const HI={sdkVersion:"ts-immutable-sdk-multi-rollup-api-client-__SDK_VERSION__"},qI=({baseConfig:e,basePath:t,headers:n})=>{if(!t.trim())throw Error("basePath can not be empty");const r={...e,basePath:t,baseOptions:{headers:{...n||{},...HI}}};return new zI.Configuration(r)};class GI{apiConfig;baseConfig;constructor({baseConfig:e,overrides:t}){if(this.baseConfig=e,t)this.apiConfig=qI(t);else switch(e.environment){case i.SANDBOX:this.apiConfig=qI({basePath:"https://api.sandbox.immutable.com",baseConfig:e});break;case i.PRODUCTION:this.apiConfig=qI({basePath:"https://indexer-mr.imtbl.com",baseConfig:e});break;default:this.apiConfig=qI({basePath:"https://api.sandbox.immutable.com",baseConfig:e})}}}function WI(e){if(hp.isAxiosError(e)&&e.response){const t=e.response.data;return t.code&&t.message?new VI({code:t.code,message:t.message,details:t.details||null,link:t.link||"",trace_id:t.trace_id||""}):new VI({code:e.code??e.response?.status.toString()??"unknown_error_code",message:String(e),details:null,link:"",trace_id:""})}return new VI({code:"unknown_error_code",message:String(e),details:null,link:"",trace_id:""})}class $I{config;activities;chains;collections;nfts;nftOwners;tokens;metadata;constructor(e){this.config=new GI(e),this.activities=new zI.ActivitiesApi(this.config.apiConfig),this.chains=new zI.ChainsApi(this.config.apiConfig),this.collections=new zI.CollectionsApi(this.config.apiConfig),this.nfts=new zI.NftsApi(this.config.apiConfig),this.nftOwners=new zI.NftOwnersApi(this.config.apiConfig),this.tokens=new zI.TokensApi(this.config.apiConfig),this.metadata=new zI.MetadataApi(this.config.apiConfig)}async listActivities(e){return await this.activities.listActivities(e).then((e=>e.data)).catch((e=>{throw WI(e)}))}async getActivity(e){return await this.activities.getActivity(e).then((e=>e.data)).catch((e=>{throw WI(e)}))}async listChains(e){return await this.chains.listChains(e).then((e=>e.data)).catch((e=>{throw WI(e)}))}async listCollections(e){return await this.collections.listCollections(e).then((e=>e.data)).catch((e=>{throw WI(e)}))}async listCollectionsByNFTOwner(e){return await this.collections.listCollectionsByNFTOwner(e).then((e=>e.data)).catch((e=>{throw WI(e)}))}async getCollection(e){return await this.collections.getCollection(e).then((e=>e.data)).catch((e=>{throw WI(e)}))}async getNFT(e){return await this.nfts.getNFT(e).then((e=>e.data)).catch((e=>{throw WI(e)}))}async listNFTs(e){return await this.nfts.listNFTs(e).then((e=>e.data)).catch((e=>{throw WI(e)}))}async listNFTsByAccountAddress(e){return await this.nfts.listNFTsByAccountAddress(e).then((e=>e.data)).catch((e=>{throw WI(e)}))}async listAllNFTs(e){return await this.nfts.listAllNFTs(e).then((e=>e.data)).catch((e=>{throw WI(e)}))}async listNFTOwners(e){return await this.nftOwners.listNFTOwners(e).then((e=>e.data)).catch((e=>{throw WI(e)}))}async listNFTOwnersByContractAddress(e){return await this.nftOwners.listOwnersByContractAddress(e).then((e=>e.data)).catch((e=>{throw WI(e)}))}async listAllNFTOwners(e){return await this.nfts.listAllNFTOwners(e).then((e=>e.data)).catch((e=>{throw WI(e)}))}async listTokens(e){return await this.tokens.listERC20Tokens(e).then((e=>e.data)).catch((e=>{throw WI(e)}))}async getToken(e){return await this.tokens.getERC20Token(e).then((e=>e.data)).catch((e=>{throw WI(e)}))}async getMetadata(e){return await this.metadata.getMetadata(e).then((e=>e.data)).catch((e=>{throw WI(e)}))}async listNFTMetadataByContractAddress(e){return await this.metadata.listMetadata(e).then((e=>e.data)).catch((e=>{throw WI(e)}))}async refreshCollectionMetadata(e){return await this.collections.refreshCollectionMetadata(e).then((e=>e.data)).catch((e=>{throw WI(e)}))}async refreshNFTMetadata(e){return await this.metadata.refreshNFTMetadataByTokenID(e).then((e=>e.data)).catch((e=>{throw WI(e)}))}async refreshStackedMetadata(e){return await this.metadata.refreshMetadataByID(e).then((e=>e.data)).catch((e=>{throw WI(e)}))}}var KI,XI,ZI,YI,JI,QI,eR,tR,nR,rR,iR,aR,oR,sR,uR,lR,cR,dR,fR,pR;!function(e){e.IMTBL_CONNECT_WIDGET_EVENT="imtbl-connect-widget",e.IMTBL_WALLET_WIDGET_EVENT="imtbl-wallet-widget",e.IMTBL_SWAP_WIDGET_EVENT="imtbl-swap-widget",e.IMTBL_BRIDGE_WIDGET_EVENT="imtbl-bridge-widget",e.IMTBL_ONRAMP_WIDGET_EVENT="imtbl-onramp-widget",e.IMTBL_SALE_WIDGET_EVENT="imtbl-sale-widget"}(KI||(KI={})),function(e){e.CLOSE_WIDGET="close-widget",e.SUCCESS="success",e.FAILURE="failure"}(XI||(XI={})),function(e){e.CLOSE_WIDGET="close-widget",e.NETWORK_SWITCH="network-switch",e.DISCONNECT_WALLET="disconnect-wallet"}(ZI||(ZI={})),function(e){e.CLOSE_WIDGET="close-widget",e.SUCCESS="success",e.FAILURE="failure",e.REJECTED="rejected"}(YI||(YI={})),function(e){e.CLOSE_WIDGET="close-widget",e.SUCCESS="success",e.FAILURE="failure",e.REJECTED="rejected"}(JI||(JI={})),function(e){e.CLOSE_WIDGET="close-widget",e.SUCCESS="success",e.FAILURE="failure"}(QI||(QI={})),function(e){e.REQUEST_CONNECT="request-connect",e.REQUEST_WALLET="request-wallet",e.REQUEST_SWAP="request-swap",e.REQUEST_BRIDGE="request-bridge",e.REQUEST_ONRAMP="request-onramp"}(eR||(eR={})),function(e){e.CLOSE_WIDGET="close-widget",e.SUCCESS="success",e.FAILURE="failure"}(tR||(tR={})),function(e){e.LIGHT="light",e.DARK="dark"}(nR||(nR={})),function(e){e.CONNECT="connect",e.WALLET="wallet",e.SWAP="swap",e.BRIDGE="bridge",e.ONRAMP="onramp"}(rR||(rR={})),function(e){e.LAYER1="LAYER1",e.LAYER2="LAYER2"}(iR||(iR={})),function(e){e[e.IMTBL_ZKEVM_MAINNET=13371]="IMTBL_ZKEVM_MAINNET",e[e.IMTBL_ZKEVM_TESTNET=13472]="IMTBL_ZKEVM_TESTNET",e[e.IMTBL_ZKEVM_DEVNET=13433]="IMTBL_ZKEVM_DEVNET",e[e.ETHEREUM=1]="ETHEREUM",e[e.SEPOLIA=11155111]="SEPOLIA"}(aR||(aR={})),function(e){e.ETHEREUM="Ethereum",e.SEPOLIA="Sepolia",e.IMTBL_ZKEVM_TESTNET="Immutable zkEVM Test",e.IMTBL_ZKEVM_DEVNET="Immutable zkEVM Dev",e.IMTBL_ZKEVM_MAINNET="Immutable zkEVM"}(oR||(oR={})),function(e){e.TRANSAK="201811419111"}(sR||(sR={})),function(e){e.BRIDGE_TO_L2="BRIDGE_TO_L2",e.SWAP="SWAP"}(uR||(uR={})),function(e){e.ALL="all"}(lR||(lR={})),function(e){e.ALL="all",e.SWAP="swap",e.BRIDGE="bridge",e.ONRAMP="onramp"}(cR||(cR={})),function(e){e.CHECK_CONNECTION="eth_accounts",e.CONNECT="eth_requestAccounts",e.ADD_NETWORK="wallet_addEthereumChain",e.SWITCH_NETWORK="wallet_switchEthereumChain",e.GET_CHAINID="eth_chainId"}(dR||(dR={})),function(e){e.ALL="all"}(fR||(fR={})),function(e){e.PASSPORT="passport",e.METAMASK="metamask"}(pR||(pR={}));const hR={allowMistmatchedChainId:!1,allowUnsupportedProvider:!1},mR="development",yR="0x0000000000000000000000000000000000001010",gR=18,bR={name:"IMX",symbol:"IMX",decimals:gR,address:yR},vR={[mR]:"https://api.dev.immutable.com",[i.SANDBOX]:"https://api.sandbox.immutable.com",[i.PRODUCTION]:"https://api.immutable.com"},wR={[mR]:"https://checkout-api.dev.immutable.com",[i.SANDBOX]:"https://checkout-api.sandbox.immutable.com",[i.PRODUCTION]:"https://checkout-api.immutable.com"},ER={[i.SANDBOX]:"https://global-stg.transak.com",[i.PRODUCTION]:"https://global.transak.com/"},TR=new Map([[aR.ETHEREUM,{chainIdHex:`0x${aR.ETHEREUM.toString(16)}`,chainName:oR.ETHEREUM,rpcUrls:["https://checkout-api.immutable.com/v1/rpc/eth-mainnet"],nativeCurrency:{name:oR.ETHEREUM,symbol:"ETH",decimals:18},blockExplorerUrls:["https://etherscan.io/"]}],[aR.IMTBL_ZKEVM_MAINNET,{chainIdHex:`0x${aR.IMTBL_ZKEVM_MAINNET.toString(16)}`,chainName:oR.IMTBL_ZKEVM_MAINNET,rpcUrls:["https://rpc.immutable.com"],nativeCurrency:bR}]]),AR=new Map([[aR.SEPOLIA,{chainIdHex:`0x${aR.SEPOLIA.toString(16)}`,chainName:oR.SEPOLIA,rpcUrls:["https://checkout-api.sandbox.immutable.com/v1/rpc/eth-sepolia"],nativeCurrency:{name:"Sep Eth",symbol:"ETH",decimals:18},blockExplorerUrls:["https://sepolia.etherscan.io/"]}],[aR.IMTBL_ZKEVM_TESTNET,{chainIdHex:`0x${aR.IMTBL_ZKEVM_TESTNET.toString(16)}`,chainName:oR.IMTBL_ZKEVM_TESTNET,rpcUrls:["https://rpc.testnet.immutable.com"],nativeCurrency:bR}]]),_R=new Map([[aR.SEPOLIA,{chainIdHex:`0x${aR.SEPOLIA.toString(16)}`,chainName:oR.SEPOLIA,rpcUrls:["https://checkout-api.dev.immutable.com/v1/rpc/eth-sepolia"],nativeCurrency:{name:"Sep Eth",symbol:"ETH",decimals:18},blockExplorerUrls:["https://sepolia.etherscan.io/"]}],[aR.IMTBL_ZKEVM_DEVNET,{chainIdHex:`0x${aR.IMTBL_ZKEVM_DEVNET.toString(16)}`,chainName:oR.IMTBL_ZKEVM_DEVNET,rpcUrls:["https://rpc.dev.immutable.com"],nativeCurrency:bR}]]),xR={[aR.IMTBL_ZKEVM_TESTNET]:{url:"https://explorer.testnet.immutable.com",nativeToken:AR.get(aR.IMTBL_ZKEVM_TESTNET).nativeCurrency},[aR.IMTBL_ZKEVM_MAINNET]:{url:"https://explorer.mainnet.immutable.com",nativeToken:TR.get(aR.IMTBL_ZKEVM_MAINNET).nativeCurrency},[aR.SEPOLIA]:{url:"https://eth-sepolia.blockscout.com",nativeToken:AR.get(aR.SEPOLIA).nativeCurrency},[aR.ETHEREUM]:{url:"https://eth.blockscout.com/",nativeToken:TR.get(aR.ETHEREUM).nativeCurrency}},CR=[{constant:!0,inputs:[],name:"name",outputs:[{name:"",type:"string"}],payable:!1,type:"function"},{constant:!0,inputs:[],name:"decimals",outputs:[{name:"",type:"uint8"}],payable:!1,type:"function"},{constant:!0,inputs:[{name:"_owner",type:"address"}],name:"balanceOf",outputs:[{name:"balance",type:"uint256"}],payable:!1,type:"function"},{constant:!0,inputs:[],name:"symbol",outputs:[{name:"",type:"string"}],payable:!1,type:"function"},{constant:!0,inputs:[{name:"_owner",type:"address"},{name:"_spender",type:"address"}],name:"allowance",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"_spender",type:"address"},{name:"_value",type:"uint256"}],name:"approve",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"}],kR=[{constant:!1,inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"approve",outputs:[],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[{internalType:"address",name:"owner",type:"address"},{internalType:"address",name:"operator",type:"address"}],name:"isApprovedForAll",outputs:[{internalType:"bool",name:"",type:"bool"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"getApproved",outputs:[{internalType:"address",name:"",type:"address"}],payable:!1,stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"ownerOf",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"}];var SR,IR,RR,OR,PR,NR,MR,LR,FR;!function(e){e.SUCCESS="SUCCESS",e.FAILED="FAILED",e.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS"}(SR||(SR={})),function(e){e.NATIVE="NATIVE",e.ERC20="ERC20",e.ERC721="ERC721"}(IR||(IR={})),function(e){e.TRANSACTION="TRANSACTION",e.GAS="GAS"}(RR||(RR={})),function(e){e.NATIVE="NATIVE",e.ERC20="ERC20"}(OR||(OR={})),function(e){e.ROUTES_FOUND="ROUTES_FOUND",e.NO_ROUTES_FOUND="NO_ROUTES_FOUND",e.NO_ROUTE_OPTIONS="NO_ROUTE_OPTIONS"}(PR||(PR={})),function(e){e.BRIDGE="BRIDGE",e.SWAP="SWAP",e.ONRAMP="ONRAMP"}(NR||(NR={})),function(e){e.ONRAMP="onramp"}(MR||(MR={})),function(e){e.WEB3_PROVIDER_ERROR="WEB3_PROVIDER_ERROR",e.PROVIDER_ERROR="PROVIDER_ERROR",e.DEFAULT_PROVIDER_ERROR="DEFAULT_PROVIDER_ERROR",e.CONNECT_PROVIDER_ERROR="CONNECT_PROVIDER_ERROR",e.GET_BALANCE_ERROR="GET_BALANCE_ERROR",e.GET_INDEXER_BALANCE_ERROR="GET_INDEXER_BALANCE_ERROR",e.GET_ERC20_BALANCE_ERROR="GET_ERC20_BALANCE_ERROR",e.GET_ERC721_BALANCE_ERROR="GET_ERC721_BALANCE_ERROR",e.GET_NETWORK_INFO_ERROR="GET_NETWORK_INFO_ERROR",e.METAMASK_PROVIDER_ERROR="METAMASK_PROVIDER_ERROR",e.CHAIN_NOT_SUPPORTED_ERROR="CHAIN_NOT_SUPPORTED_ERROR",e.PROVIDER_REQUEST_MISSING_ERROR="PROVIDER_REQUEST_MISSING_ERROR",e.PROVIDER_REQUEST_FAILED_ERROR="PROVIDER_REQUEST_FAILED_ERROR",e.USER_REJECTED_REQUEST_ERROR="USER_REJECTED_REQUEST_ERROR",e.TRANSACTION_FAILED="TRANSACTION_FAILED",e.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",e.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",e.INVALID_GAS_ESTIMATE_TYPE="INVALID_GAS_ESTIMATE_TYPE",e.UNSUPPORTED_TOKEN_TYPE_ERROR="UNSUPPORTED_TOKEN_TYPE_ERROR",e.UNSUPPORTED_BALANCE_REQUIREMENT_ERROR="UNSUPPORTED_BALANCE_REQUIREMENT_ERROR",e.GET_ORDER_LISTING_ERROR="GET_ORDER_LISTING_ERROR",e.CANCEL_ORDER_LISTING_ERROR="CANCEL_ORDER_LISTING_ERROR",e.PREPARE_ORDER_LISTING_ERROR="PREPARE_ORDER_LISTING_ERROR",e.CREATE_ORDER_LISTING_ERROR="CREATE_ORDER_LISTING_ERROR",e.FULFILL_ORDER_LISTING_ERROR="FULFILL_ORDER_LISTING_ERROR",e.SWITCH_NETWORK_UNSUPPORTED="SWITCH_NETWORK_UNSUPPORTED",e.GET_ERC20_ALLOWANCE_ERROR="GET_ERC20_ALLOWANCE_ERROR",e.GET_ERC721_ALLOWANCE_ERROR="GET_ERC721_ALLOWANCE_ERROR",e.EXECUTE_APPROVAL_TRANSACTION_ERROR="EXECUTE_APPROVAL_TRANSACTION_ERROR",e.EXECUTE_FULFILLMENT_TRANSACTION_ERROR="EXECUTE_FULFILLMENT_TRANSACTION_ERROR",e.SIGN_MESSAGE_ERROR="SIGN_MESSAGE_ERROR",e.BRIDGE_GAS_ESTIMATE_ERROR="BRIDGE_GAS_ESTIMATE_ERROR",e.ORDER_FEE_ERROR="ORDER_FEE_ERROR",e.ITEM_REQUIREMENTS_ERROR="ITEM_REQUIREMENTS_ERROR",e.API_ERROR="API_ERROR"}(LR||(LR={}));class DR extends Error{message;type;data;constructor(e,t,n){super(e),this.message=e,this.type=t,this.data=n}}!function(e){e.REJECTED_SWITCH_AFTER_ADDING_NETWORK="REJECTED_SWITCH_AFTER_ADDING_NETWORK"}(FR||(FR={}));const BR=async(e,t)=>{try{return await e()}catch(e){const n=`${e.message}`||"UnknownError",r=t.message?`[${t.type}]:${t.message}. Cause:${n}`:`[${t.type}] Cause:${n}`;if(e instanceof DR)throw new DR(r,t.type,{...t.data,innerErrorType:e.type,...e.data});throw new DR(r,t.type,{...t.data})}};async function jR(e){if(!e.provider?.request)throw new DR("Parsed provider is not a valid Web3Provider",LR.WEB3_PROVIDER_ERROR);const t=await e.provider.request({method:dR.GET_CHAINID,params:[]});return parseInt(t,16)}async function UR(e,{type:t=lR.ALL,exclude:n}){const{networkMap:r}=e,i=(await e.remote.getConfig("allowedNetworks")).filter((e=>{const r=t===lR.ALL,i=!(n||[]).map((e=>e.chainId)).includes(e.chainId);return r&&i})),a=[];return i.forEach((e=>{const t=r.get(e.chainId);t&&a.push({name:t.chainName,chainId:parseInt(t.chainIdHex,16),nativeCurrency:t.nativeCurrency,isSupported:!0})})),{networks:a}}async function zR(e,t){const{networkMap:n}=e;return BR((async()=>{try{const e=await t.getNetwork();if(Array.from(n.keys()).includes(e.chainId)){const t=n.get(e.chainId);return{name:t.chainName,chainId:parseInt(t.chainIdHex,16),nativeCurrency:t.nativeCurrency,isSupported:!0}}return{chainId:e.chainId,name:e.name,isSupported:!1}}catch(e){const r=await jR(t);return{chainId:r,isSupported:Array.from(n.keys()).includes(r)}}}),{type:LR.GET_NETWORK_INFO_ERROR})}async function VR(e,t,n){const{networkMap:r}=e;if(!(await UR(e,{type:lR.ALL})).networks.some((e=>e.chainId===n)))throw new DR(`Chain:${n} is not a supported chain`,LR.CHAIN_NOT_SUPPORTED_ERROR);if(t.provider?.isPassport)throw new DR("Switching networks with Passport provider is not supported",LR.SWITCH_NETWORK_UNSUPPORTED);try{await async function(e,t,n){if(t.provider?.request)return await t.provider.request({method:dR.SWITCH_NETWORK,params:[{chainId:e.get(n)?.chainIdHex}]})}(r,t,n)}catch(e){if(4902!==e.code)throw new DR("User cancelled switch network request",LR.USER_REJECTED_REQUEST_ERROR);try{await async function(e,t,n){if(t.provider?.request){const r=e.get(n),i={chainId:r?.chainIdHex,chainName:r?.chainName,rpcUrls:r?.rpcUrls,nativeCurrency:r?.nativeCurrency,blockExplorerUrls:r?.blockExplorerUrls};return await t.provider.request({method:dR.ADD_NETWORK,params:[i]})}}(r,t,n)}catch(e){throw new DR("User cancelled add network request",LR.USER_REJECTED_REQUEST_ERROR)}}const i=new sd(t.provider);if((await i.getNetwork()).chainId!==n)throw new DR("User cancelled switch network request",LR.USER_REJECTED_REQUEST_ERROR);return{network:await zR(e,i),provider:i}}class HR{isDevelopment;isProduction;configCache;tokensCache;constructor(e){this.isDevelopment=e.isDevelopment,this.isProduction=e.isProduction}static async makeHttpRequest(e){let t;try{t=await hp.get(e)}catch(e){throw new DR(`Error fetching from api: ${e.message}`,LR.API_ERROR)}if(200!==t.status)throw new DR(`Error fetching from api: ${t.status} ${t.statusText}`,LR.API_ERROR);return t}getEndpoint=()=>this.isDevelopment?wR[mR]:this.isProduction?wR[i.PRODUCTION]:wR[i.SANDBOX];async loadConfig(){if(this.configCache)return this.configCache;const e=await HR.makeHttpRequest(`${this.getEndpoint()}/v1/config`);return this.configCache=e.data,this.configCache}async loadConfigTokens(){if(this.tokensCache)return this.tokensCache;const e=await HR.makeHttpRequest(`${this.getEndpoint()}/v1/config/tokens`);return this.tokensCache=e.data,this.tokensCache}async getConfig(e){const t=await this.loadConfig();if(t)return e?t[e]:t}async getTokensConfig(e){const t=await this.loadConfigTokens();return t&&t[e]?t[e]??[]:{}}}class qR extends Error{message;constructor(e){super(e),this.message=e}}const GR=e=>e.isProduction?aR.ETHEREUM:aR.SEPOLIA,WR=e=>e.isDevelopment?aR.IMTBL_ZKEVM_DEVNET:e.isProduction?aR.IMTBL_ZKEVM_MAINNET:aR.IMTBL_ZKEVM_TESTNET;class $R{isDevelopment=!1;isProduction;isOnRampEnabled;isSwapEnabled;isBridgeEnabled;remote;environment;networkMap;constructor(e){if(!Object.values(i).includes(e.baseConfig.environment))throw new qR("Invalid checkout configuration of environment");var t;this.environment=e.baseConfig.environment,this.isProduction=!this.isDevelopment&&this.environment===i.PRODUCTION,this.isOnRampEnabled=e.isOnRampEnabled??true,this.isSwapEnabled=e.isSwapEnabled??true,this.isBridgeEnabled=e.isBridgeEnabled??true,this.networkMap=(t=this.isProduction,this.isDevelopment?_R:t?TR:AR),this.remote=new HR({isDevelopment:this.isDevelopment,isProduction:this.isProduction})}}const KR=async(e,{type:t=cR.ALL,chainId:n,exclude:r})=>{let i,a=[];switch(t){case cR.SWAP:a=(await e.remote.getConfig("dex")).tokens||[];break;case cR.ONRAMP:i=await e.remote.getConfig("onramp"),i||(a=[]),a=i[sR.TRANSAK]?.tokens||[];break;case cR.BRIDGE:case cR.ALL:default:a=(await e.remote.getTokensConfig(n||GR(e))).allowed}return r&&0!==r?.length?{tokens:a.filter((e=>!r.map((e=>e.address)).includes(e.address||"")))}:{tokens:a}};class XR{url;nativeToken;ttl;chainId;cacheMap;static async makeHttpRequest(e){return hp.get(e)}setCache(e,t){this.cacheMap[e]={data:t,ttl:(new Date).getTime()+1e3*this.ttl}}getCache(e){const t=this.cacheMap[e];return!t||t.ttl<=(new Date).getTime()?null:t.data}constructor(e){this.chainId=e.chainId,this.url=xR[this.chainId].url;const t=xR[this.chainId].nativeToken;this.nativeToken={address:t.address??"",decimals:t.decimals.toString(),name:t.name,symbol:t.symbol},this.cacheMap={},this.ttl=void 0!==e.ttl?e.ttl:60}static isChainSupported=e=>Boolean(xR[e]);static isBlockscoutError=e=>"code"in e;async getTokensByWalletAddress(e){try{let t=`${this.url}/api/v2/addresses/${e.walletAddress}/tokens?type=${e.tokenType}`;e.nextPage&&(t+=`&${new URLSearchParams(e.nextPage)}`);const n=this.getCache(t);if(n)return Promise.resolve(n);const r=await XR.makeHttpRequest(t);if(r.status>=400)return Promise.reject({code:r.status,message:r.statusText});const i={items:r.data?.items?.filter((e=>e.token.address&&e.token.address!==this.nativeToken.address)),next_page_params:r.data?.next_page_params};return this.setCache(t,i),Promise.resolve(i)}catch(e){let t=kp.InternalServerError,n="InternalServerError";return hp.isAxiosError(e)&&(t=e.response?.status||t,n=e.message),Promise.reject({code:t,message:n})}}async getNativeTokenByWalletAddress(e){try{const t=`${this.url}/api/v2/addresses/${e.walletAddress}`,n=this.getCache(t);if(n)return Promise.resolve(n);const r=await XR.makeHttpRequest(t);if(r.status>=400)return Promise.reject({code:r.status,message:r.statusText});const i={token:this.nativeToken,value:r.data.coin_balance};return this.setCache(t,i),Promise.resolve(i)}catch(e){let t=kp.InternalServerError,n="InternalServerError";return hp.isAxiosError(e)&&(t=e.response?.status||t,n=e.message),Promise.reject({code:t,message:n})}}}var ZR;!function(e){e.ERC20="ERC-20"}(ZR||(ZR={}));const YR=(e,t,n)=>{e.isProduction||console.debug(t,n)},JR=async(e,t,n)=>{const r=performance.now(),i=await n,a=performance.now();return YR(e,t,(a-r)/1e3),i},QR=async(e,t,n)=>await BR((async()=>{const r=await zR(e,t);if(!r.isSupported)throw new DR(`Chain:${r.chainId} is not a supported chain`,LR.CHAIN_NOT_SUPPORTED_ERROR,{chainName:r.name});const i=await t.getBalance(n);return{balance:i,formattedBalance:_d(i,r.nativeCurrency.decimals),token:r.nativeCurrency}}),{type:LR.GET_BALANCE_ERROR});async function eO(e,t,n){return await BR((async()=>{const r=new gs(n,JSON.stringify(CR),e);return Promise.all([r.name(),r.symbol(),r.balanceOf(t),r.decimals()]).then((([e,t,r,i])=>({balance:r,formattedBalance:_d(r,i),token:{name:e,symbol:t,decimals:i,address:n}})))}),{type:LR.GET_ERC20_BALANCE_ERROR})}const tO=new Map,nO=async(e,t,n,r)=>{const i=[];r.forEach((r=>{r.address&&r.address!==yR?i.push(eO(t,n,r.address)):i.push(QR(e,t,n))}));return{balances:(await Promise.allSettled(i)).filter((e=>"fulfilled"===e.status)).map((e=>e.value))}},rO=async(e,t,n,r)=>{const{tokens:i}=await KR(e,{type:cR.ALL,chainId:r});let a=!1;try{a=(await e.remote.getTokensConfig(r)).blockscout||a}catch(e){console.error(e)}if(a&&XR.isChainSupported(r)){const t=GR(e)===r;return JR(e,`Time to fetch balances using blockscout for ${r}`,(async(e,t,n)=>{const r=n.length>0,i=Object.assign({},...n.map((e=>({[e.address||""]:e}))));let a=tO.get(t);a||(a=new XR({chainId:t}),tO.set(t,a));const o=[],s=ZR.ERC20;let u;try{do{u=await a.getTokensByWalletAddress({walletAddress:e,tokenType:s,nextPage:u?.next_page_params}),o.push(...u.items)}while(u.next_page_params)}catch(e){if(e?.code!==kp.NotFound)throw new DR(e.message||"InternalServerError | getTokensByWalletAddress",LR.GET_INDEXER_BALANCE_ERROR,e)}try{const t=await a.getNativeTokenByWalletAddress({walletAddress:e});o.push(t)}catch(e){if(e?.code!==kp.NotFound)throw new DR(e.message||"InternalServerError | getNativeTokenByWalletAddress",LR.GET_INDEXER_BALANCE_ERROR,e)}const l=[];return o.forEach((e=>{if(r&&!i[e.token.address])return;const t=e.token||{},n=Y.from(e.value);let a=parseInt(t.decimals,10);Number.isNaN(a)&&(a=gR);const o={...t,decimals:a},s=_d(e.value,o.decimals);l.push({balance:n,formattedBalance:s,token:o})})),{balances:l}})(n,r,t?i:[]))}return await JR(e,`Time to fetch balances using RPC for ${r}`,nO(e,t,n,i))};async function iO(e,t){let n=null;switch(e){case pR.PASSPORT:if(!t)throw new DR("Passport not provided",LR.DEFAULT_PROVIDER_ERROR);n=new sd(t.connectEvm());break;case pR.METAMASK:n=await async function(){const e=await BR((async()=>await Op()),{type:LR.METAMASK_PROVIDER_ERROR});if(!e||!e.request)throw new DR("No MetaMask provider installed.",LR.METAMASK_PROVIDER_ERROR);return new sd(e)}();break;default:throw new DR("Provider not supported",LR.DEFAULT_PROVIDER_ERROR)}return{provider:n,walletProviderName:e}}function aO(e){return!(!e||!e.provider?.request||"function"!=typeof e.provider.request)}async function oO(e,t,n){return BR((async()=>{if(t.provider?.isPassport)return t;if(!aO(t))throw new DR("Parsed provider is not a valid Web3Provider",LR.WEB3_PROVIDER_ERROR);const r={...hR,...n},i=await jR(t);let a=t.network?.chainId;try{a=t.network?.chainId,a||(a=(await t.getNetwork()).chainId)}catch(e){throw new DR("Unable to detect the web3Provider network",LR.WEB3_PROVIDER_ERROR)}if(a!==i&&!r.allowMistmatchedChainId)throw new DR("Your wallet has changed network, please switch to a supported network",LR.WEB3_PROVIDER_ERROR);if(!(await UR(e,{type:lR.ALL})).networks.some((e=>e.chainId===i))&&!r.allowUnsupportedProvider)throw new DR("Your wallet is connected to an unsupported network, please switch to a supported network",LR.WEB3_PROVIDER_ERROR);return t}),{type:LR.WEB3_PROVIDER_ERROR})}const sO=e=>(e=>!!e.maxFeePerGas&&!!e.maxPriorityFeePerGas)(e)?Y.from(e.maxFeePerGas).add(Y.from(e.maxPriorityFeePerGas)):e.gasPrice?Y.from(e.gasPrice):null,uO=async e=>{const t=await e.getFeeData(),n=sO(t);if(n)return n.mul(14e4)};async function lO(e,t,n,r){const i=n.get(e),o=n.get(t);if(!i)throw new DR(`Chain:${e} is not a supported chain`,LR.CHAIN_NOT_SUPPORTED_ERROR);if(!o)throw new DR(`Chain:${t} is not a supported chain`,LR.CHAIN_NOT_SUPPORTED_ERROR);let s=Fp;r.isDevelopment&&(s=Lp),r.isProduction&&(s=Dp);const u=new Yy({baseConfig:new a({environment:r.environment}),bridgeInstance:s,rootProvider:i,childProvider:o});return new Wy(u)}async function cO(e,t){const n=await t.remote.getConfig("dex");return new KA({chainId:e,baseConfig:new a({environment:t.environment}),overrides:n?.overrides})}function dO(e){return new lI({baseConfig:{environment:e.environment}})}function fO(e,t,n){return new gs(e,t,n)}const pO="0x0000000000000000000000000000000000000001",hO=18;async function mO(e,t,n,r){const i=GR(t),a=WR(t),o=await t.remote.getConfig("gasEstimateTokens"),{gasTokenAddress:s,fromAddress:u}=o[i].bridgeToL2Addresses,l=e.get(i);if(!l)throw new Error(`Missing JsonRpcProvider for chain id: ${i}`);try{const o=await async function(e,t){const n=await uO(e);return n&&t?{estimatedAmount:n.add(n)}:{estimatedAmount:n}}(l,n);o.token=await async function(e,t,n,r){if("NATIVE"===t)return e.networkMap.get(n)?.nativeCurrency;const i=new gs(t,JSON.stringify(CR),r);return{name:await i.name(),symbol:await i.symbol(),decimals:await i.decimals(),address:t}}(t,r??(s||"NATIVE"),i,l);const c=await lO(i,a,e,t),{bridgeFee:d,bridgeable:f}=await async function(e,t){const n=await e.getFee({token:t});return{bridgeFee:{estimatedAmount:n.feeAmount},bridgeable:n.bridgeable}}(c,u);return{gasEstimateType:uR.BRIDGE_TO_L2,gasFee:o,bridgeFee:{estimatedAmount:d?.estimatedAmount,token:d?.token},bridgeable:f}}catch{return{gasEstimateType:uR.BRIDGE_TO_L2,gasFee:{},bridgeFee:{},bridgeable:!1}}}async function yO(e,t,n){switch(e.gasEstimateType){case uR.BRIDGE_TO_L2:return await mO(t,n,e.isSpendingCapApprovalRequired,e.tokenAddress);case uR.SWAP:return await async function(e){const t=WR(e),n=await e.remote.getConfig("gasEstimateTokens"),{inAddress:r,outAddress:i}=n[t].swapAddresses;try{const n=await cO(t,e),{swap:a}=await n.getUnsignedSwapTxFromAmountIn(pO,r,i,Y.from(xd("1",hO)));if(null===a.gasFeeEstimate)return{gasEstimateType:uR.SWAP,gasFee:{}};let o;return a.gasFeeEstimate.value&&(o=Y.from(a.gasFeeEstimate.value)),{gasEstimateType:uR.SWAP,gasFee:{estimatedAmount:o,token:{address:a.gasFeeEstimate?.token.address,symbol:a.gasFeeEstimate?.token.symbol??"",name:a.gasFeeEstimate?.token.name??"",decimals:a.gasFeeEstimate?.token.decimals??hO}}}}catch{return{gasEstimateType:uR.SWAP,gasFee:{}}}}(n);default:throw new DR("Invalid type provided for gasEstimateType",LR.INVALID_GAS_ESTIMATE_TYPE)}}const gO=e=>(e=>{const t=new Map,n=[];return e.forEach((e=>{const{type:r}=e;if(r!==IR.ERC721)return void n.push(e);const{contractAddress:i,spenderAddress:a,id:o}=e,s=`${i}${a}${o}`;t.get(s)||t.set(s,{...e})})),n.concat(Array.from(t.values()))})((e=>{const t=new Map,n=[];return e.forEach((e=>{const{type:r}=e;if(r!==IR.ERC20)return void n.push(e);const{contractAddress:i,spenderAddress:a,amount:o}=e,s=`${i}${a}`,u=t.get(s);u&&u.type===IR.ERC20?u.amount=Y.from(u.amount).add(o):t.set(s,{...e})})),n.concat(Array.from(t.values()))})((e=>{const t=new Map,n=[];return e.forEach((e=>{const{type:r}=e;if(r!==IR.NATIVE)return void n.push(e);const{amount:i}=e,a=t.get(r);a&&a.type===IR.NATIVE?a.amount=Y.from(a.amount).add(i):t.set(r,{...e})})),n.concat(Array.from(t.values()))})(e))),bO=async(e,t,n,r)=>{try{const i=new gs(n,JSON.stringify(CR),e);return await i.allowance(t,r)}catch(e){throw new DR("Failed to get the allowance for ERC20",LR.GET_ERC20_ALLOWANCE_ERROR,{contractAddress:n})}},vO=async(e,t,n,r,i)=>{try{const a=new gs(n,JSON.stringify(CR),e),o=await a.populateTransaction.approve(r,i);return o&&(o.from=t),o}catch{throw new DR("Failed to get the approval transaction for ERC20",LR.GET_ERC20_ALLOWANCE_ERROR,{contractAddress:n})}},wO=async(e,t,n,r)=>{try{const i=new gs(n,JSON.stringify(kR),e);return await i.isApprovedForAll(t,r)}catch(e){throw new DR("Failed to check approval for all ERC721s of collection",LR.GET_ERC721_ALLOWANCE_ERROR,{ownerAddress:t,contractAddress:n,spenderAddress:r})}},EO=async(e,t,n,r,i)=>{try{const a=new gs(n,JSON.stringify(kR),e),o=await a.populateTransaction.approve(r,i);return o&&(o.from=t),o}catch(e){throw new DR("Failed to get the approval transaction for ERC721",LR.GET_ERC721_ALLOWANCE_ERROR,{id:i.toString(),contractAddress:n,spenderAddress:r,ownerAddress:t})}},TO=async(e,t,n)=>{try{const r=new gs(t,JSON.stringify(kR),e);return await r.getApproved(n)}catch(e){throw new DR("Failed to get approved address for ERC721",LR.GET_ERC721_ALLOWANCE_ERROR,{id:n.toString(),contractAddress:t})}},AO=(e,t)=>{const n=parseInt(e,10);if(Number.isNaN(n))throw new DR("Invalid ERC721 ID",LR.GET_ERC721_ALLOWANCE_ERROR,{id:e,contractAddress:t});return n},_O=async(e,t,n)=>{let r=!0;const i=[],a=new Map,o=new Map,s=new Map,u=new Map,l=await(async(e,t,n)=>{const r=new Map,i=new Map;for(const a of t){if(a.type!==IR.ERC721)continue;const{contractAddress:t,spenderAddress:o}=a,s=`${t}-${o}`;r.set(s,!1),i.has(s)||i.set(s,wO(e,n,t,o))}const a=await Promise.all(i.values()),o=Array.from(i.keys());return a.forEach(((e,t)=>{r.set(o[t],e)})),r})(e,n,t);for(const t of n){if(t.type!==IR.ERC721)continue;const{contractAddress:n,id:r,spenderAddress:s}=t,u=`${n}-${s}`;if(l.get(u)){i.push({sufficient:!0,itemRequirement:t});continue}const c=`${n}-${r}`,d=AO(r,n);a.set(c,t),o.set(c,TO(e,n,d))}const c=await Promise.all(o.values()),d=Array.from(o.keys());for(let n=0;n<c.length;n++){const o=a.get(d[n]);if(!o||o.type!==IR.ERC721)continue;if(c[n]===o.spenderAddress){i.push({sufficient:!0,itemRequirement:o});continue}r=!1;const{contractAddress:l,id:f,spenderAddress:p}=o,h=`${l}-${f}`,m=AO(f,l);s.set(h,{type:IR.ERC721,sufficient:!1,itemRequirement:o,approvalTransaction:void 0}),u.set(h,EO(e,t,l,p,m))}const f=await Promise.all(u.values()),p=Array.from(u.keys());return f.forEach(((e,t)=>{const n=s.get(p[t]);n&&(n.sufficient||(n.approvalTransaction=e))})),{sufficient:r,allowances:i.concat(Array.from(s.values()))}},xO=e=>(e=>{const t=new Map,n=[];return e.forEach((e=>{const{type:r}=e;if(r!==IR.ERC721)return void n.push(e);const{contractAddress:i,id:a}=e,o=`${i}${a}`;t.get(o)||t.set(o,{...e})})),n.concat(Array.from(t.values()))})((e=>{const t=new Map,n=[];return e.forEach((e=>{const{type:r}=e;if(r!==IR.ERC20)return void n.push(e);const{contractAddress:i,amount:a}=e,o=`${i}`,s=t.get(o);s&&s.type===IR.ERC20?s.amount=Y.from(s.amount).add(a):t.set(o,{...e})})),n.concat(Array.from(t.values()))})((e=>{const t=new Map,n=[];return e.forEach((e=>{const{type:r}=e;if(r!==IR.NATIVE)return void n.push(e);const{amount:i}=e,a=t.get(r);a&&a.type===IR.NATIVE?a.amount=Y.from(a.amount).add(i):t.set(r,{...e})})),n.concat(Array.from(t.values()))})(e))),CO=(e,t)=>{const n=Y.from(1),r=t.find((t=>{const n=t;return n.contractAddress===e.contractAddress&&n.id===e.id})),i=n.isNegative()||n.isZero()||(r?.balance.gte(n)??!1),a=n.sub(r?.balance??Y.from(0));let o=r;return o||(o={type:IR.ERC721,balance:Y.from(0),formattedBalance:"0",contractAddress:e.contractAddress,id:e.id}),{sufficient:i,type:IR.ERC721,delta:{balance:a,formattedBalance:a.toString()},current:o,required:{...o,balance:Y.from(1),formattedBalance:"1"}}},kO=async(e,t,n,r)=>{let i=[];try{const a=(e=>e.map((e=>e.type===IR.NATIVE?{address:yR}:{address:e.contractAddress})))(r),{balances:o}=await nO(e,t,n,a);i=[...o.map((e=>e))]}catch(e){throw new DR("Failed to get balances",LR.GET_BALANCE_ERROR)}return i},SO=async(e,t,n,r)=>{const i=xO(r);if(i.filter((e=>e.type!==IR.ERC721&&e.type!==IR.ERC20&&e.type!==IR.NATIVE)).length>0)throw new DR("Unsupported item requirement balance check",LR.UNSUPPORTED_BALANCE_REQUIREMENT_ERROR);const a=[],o=i.filter((e=>e.type===IR.ERC20||e.type===IR.NATIVE));o.length>0&&a.push(kO(e,t,n,i));const s=i.filter((e=>e.type===IR.ERC721));s.length>0&&a.push((async(e,t,n)=>{const r=[],i=new Map,a=new Map;n.forEach((t=>{if(t.type!==IR.ERC721)return;const n=new gs(t.contractAddress,JSON.stringify(kR),e);i.set(t.contractAddress,t),a.set(t.contractAddress,n.ownerOf(t.id))}));try{const e=await Promise.all(a.values()),n=Array.from(a.keys());e.forEach(((e,a)=>{const o=i.get(n[a]);let s=0;o&&t===e&&(s=1),r.push({type:IR.ERC721,balance:Y.from(s),formattedBalance:s.toString(),contractAddress:o.contractAddress,id:o.id})}))}catch(e){throw new DR("Failed to get ERC721 balances",LR.GET_ERC721_BALANCE_ERROR)}return r})(t,n,i));const u=await Promise.all(a).then((e=>{const t=[];if(e.length>1||o.length>0){const n=e[0];if(o.forEach((e=>{t.push(((e,t)=>{let n;e.type===IR.ERC20?n=t.find((t=>t.token?.address===e.contractAddress)):e.type===IR.NATIVE&&(n=t.find((e=>""===e.token?.address||e.token?.address===yR)));const r=e.amount,i=r.isNegative()||r.isZero()||(n?.balance.gte(r)??!1),a=r.sub(n?.balance??Y.from(0));let o="",s="",u=gR;n&&(u=n.token?.decimals??gR,o=n.token.name,s=n.token.symbol);let l=n;return e.type===IR.NATIVE?(l||(l={type:IR.NATIVE,balance:Y.from(0),formattedBalance:"0",token:{name:o,symbol:s,decimals:gR,address:yR}}),{sufficient:i,type:IR.NATIVE,delta:{balance:a,formattedBalance:_d(a,u)},current:{...l,type:IR.NATIVE},required:{...l,type:IR.NATIVE,balance:Y.from(e.amount),formattedBalance:_d(e.amount,u)}}):(l||(l={type:e.type,balance:Y.from(0),formattedBalance:"0",token:{name:o,symbol:s,address:e.contractAddress,decimals:u}}),{sufficient:i,type:IR.ERC20,delta:{balance:a,formattedBalance:_d(a,u)},current:l,required:{...l,balance:Y.from(e.amount),formattedBalance:_d(e.amount,u)}})})(e,n))})),s.length>0){const n=e[1];s.forEach((e=>{t.push(CO(e,n))}))}}else if(s.length>0){const n=e[0];s.forEach((e=>{t.push(CO(e,n))}))}return t}));return{sufficient:u.reduce(((e,t)=>e&&t.sufficient),!0),balanceRequirements:u}},IO=async(e,t)=>{try{return await e.estimateGas(t)}catch(e){throw new DR("Failed to estimate gas for transaction",LR.UNPREDICTABLE_GAS_LIMIT)}},RO=async(e,t,n)=>{const r=[];let i=Y.from(0);for(const n of t)void 0!==n.approvalTransaction&&r.push(IO(e,n.approvalTransaction));if(n.type===RR.TRANSACTION)r.push(IO(e,n.transaction));else{const t=await e.getFeeData(),r=sO(t);if(null!==r){const e=r?.mul(n.gasToken.limit);e&&(i=i.add(e))}}return(await Promise.all(r)).forEach((e=>{i=i.add(e)})),i.eq(0)?null:((e,t)=>t.type===RR.TRANSACTION||t.gasToken.type===OR.NATIVE?{type:IR.NATIVE,amount:e}:{type:IR.ERC20,amount:e,contractAddress:t.gasToken.contractAddress,spenderAddress:""})(i,n)},OO=(e,t)=>({checkDexAvailability:async()=>{let n;try{n=await hp.post(`${e?vR[mR]:t?vR[i.PRODUCTION]:vR[i.SANDBOX]}/v1/availability/checkout/swap`)}catch(e){n=e.response}if(403===n.status)return!1;if(204===n.status)return!0;throw new DR(`Error fetching from api: ${n.status} ${n.statusText}`,LR.API_ERROR)}}),PO=async()=>!0,NO=async e=>{const t=OO(e.isDevelopment,e.isProduction);try{return await t.checkDexAvailability()}catch{return!1}};async function MO(e,t){if(e.isProduction&&t?.has(aR.ETHEREUM))return t;if(t?.has(aR.SEPOLIA))return t;const n=new Map;return(await UR(e,{type:lR.ALL})).networks.forEach((t=>{const r=e.networkMap.get(t.chainId)?.rpcUrls[0],i=new ac(r);n.set(t.chainId,i)})),n}const LO=async(e,t,n,r,i)=>{const a=new Map;try{const o=await cO(t,e),s=[],u=[];for(const e of i)e!==r.address&&(s.push(o.getUnsignedSwapTxFromAmountOut(n,e,r.address,r.amount,1)),u.push(e));return(await JR(e,"Time to resolve swap quotes from the dex",Promise.allSettled(s))).forEach(((e,t)=>{if("rejected"===e.status)return;const n=u[t];a.set(n,{quote:e.value.quote,approval:e.value.approval?.gasFeeEstimate??null,swap:e.value.swap.gasFeeEstimate})})),a}catch{return a}},FO=(e,t,n)=>{let r,i=Y.from(0),a="0";e&&(i=e.value,a=_d(e.value,e.token.decimals),r={name:e.token.name??"",symbol:e.token.symbol??"",address:e.token.address,decimals:e.token.decimals});let o,s=Y.from(0),u="0";t&&(s=t.value,u=_d(t.value,t.token.decimals),o={name:t.token.name??"",symbol:t.token.symbol??"",address:t.token.address,decimals:t.token.decimals});const l=[];for(const e of n)l.push({amount:e.amount.value,formattedAmount:_d(e.amount.value,e.amount.token.decimals),token:{name:e.amount.token.name??"",symbol:e.amount.token.symbol??"",address:e.amount.token.address,decimals:e.amount.token.decimals}});return{approvalGasFees:{amount:i,formattedAmount:a,token:r},swapGasFees:{amount:s,formattedAmount:u,token:o},swapFees:l}},DO=(e,t,n,r)=>{const i=n.token.address;let a=IR.ERC20;return i===yR&&(a=IR.NATIVE),{type:NR.SWAP,chainId:e,fundingItem:{type:a,fundsRequired:{amount:t,formattedAmount:_d(t,n.token.decimals)},userBalance:{balance:n.balance,formattedBalance:n.formattedBalance},token:n.token},fees:r}},BO=(e,t)=>{if(!t)return{sufficient:!0,approvalGasFee:Y.from(0),approvalGasTokenAddress:""};const n=t.value,r=t.token.address;if(0===e.length)return{sufficient:!1,approvalGasFee:n,approvalGasTokenAddress:r};const i=e.find((e=>e.token.address===r));return i?i.balance.lt(n)?{sufficient:!1,approvalGasFee:n,approvalGasTokenAddress:r}:{sufficient:!0,approvalGasFee:n,approvalGasTokenAddress:r}:{sufficient:!1,approvalGasFee:n,approvalGasTokenAddress:r}},jO=(e,t,n,r,i)=>{const a=new Map;if(""!==t.approvalGasTokenAddress&&a.set(t.approvalGasTokenAddress,t.approvalGasFee),n){const e=a.get(n.token.address);e?a.set(n.token.address,e.add(n.value)):a.set(n.token.address,n.value)}if(i){const e=a.get(i.address);e?a.set(i.address,e.add(i.amount)):a.set(i.address,i.amount)}for(const e of r){const t=a.get(e.amount.token.address);t?a.set(e.amount.token.address,t.add(e.amount.value)):a.set(e.amount.token.address,e.amount.value)}for(const[t,n]of a.entries()){if(n===Y.from(0))continue;const r=e.find((e=>e.token.address===t));if(!r)return!1;if(r.balance.lt(n))return!1}return!0},UO=(e,t,n,r,i,a)=>{let o=Y.from(0),s="",u=!1;if(t.balanceRequirements.forEach((t=>{t.type!==IR.NATIVE&&t.type!==IR.ERC20||t.required.token.address===n&&(s=t.required.token.address,u=!0,o=e.sub(t.required.balance))})),!u)return!0;i.approvalGasTokenAddress===s&&(o=o.sub(i.approvalGasFee));for(const e of a)e.amount.token.address===s&&(o=o.sub(e.amount.value));return o.gte(r)},zO=async(e,t,n,r,i,a,o)=>{const s=[];if(!t.swap)return s;if(0===a.length)return s;const u=(e=>{let t="",n=Y.from(0);switch(e.type){case IR.ERC20:t=e.required.token.address??"",n=e.delta.balance;break;case IR.NATIVE:t=yR,n=e.delta.balance}return{address:t,amount:n}})(r);if(""===u.address)return s;const l=WR(e),c=i.get(l);if(!c)return s;const d=c.balances;if(0===d.length)return s;const f=await LO(e,WR(e),n,u,a),p=Array.from(f.keys());for(const e of p){const t=f.get(e);if(!t)continue;const n=d.find((t=>t.token.address===e));if(!n)continue;const r=t.quote.amount;if(n.balance.lt(r.value))continue;const i=BO(d,t.approval);if(!i.sufficient)continue;if(!jO(d,i,t.swap,t.quote.fees,{amount:r.value,address:e}))continue;if(!UO(n.balance,o,e,r.value,i,t.quote.fees))continue;const a=FO(t.approval,t.swap,t.quote.fees);s.push(DO(l,r.value,n,a))}return s},VO=(e,t)=>t&&t.success?e.filter((e=>"address"in e?t.balances.find((t=>t.token.address===e.address&&t.balance.gt(0))):t.balances.find((e=>!("address"in e.token)&&e.balance.gt(0))))):[],HO=async(e,t)=>{if(t.onRamp){const t=await e.remote.getConfig("onramp"),n={};return Object.entries(t).forEach((([e,t])=>{n[e]=t.tokens??[]})),n}return{}},qO=async(e,t,n)=>{if(n.bridge){const n=(await e.remote.getConfig("bridge"))?.tokens??[],r=t.get(GR(e));return VO(n,r)}return[]},GO=async(e,t,n)=>{const r={};return r.swap=await(async(e,t,n)=>{if(n.swap){const n=(await e.remote.getConfig("dex"))?.tokens??[],r=t.get(WR(e));return VO(n,r)}return[]})(e,t,n),r.bridge=await qO(e,t,n),r.onRamp=await HO(e,n),r},WO="0x0000000000000000000000000000000000000001",$O=async(e,t)=>(await t.remote.getConfig("imxAddressMapping"))[e]??"",KO=async(e,t)=>{if(""===t)return{l1address:"",l2address:t};if(t===yR)return{l1address:await $O(GR(e),e),l2address:yR};const n=WR(e)===aR.IMTBL_ZKEVM_TESTNET?"imtbl-zkevm-testnet":"";if(""===n)return{l1address:"",l2address:t};const r=function(e){return new $I({baseConfig:{environment:e.environment}})}(e),i=(await r.getToken({chainName:n,contractAddress:t})).result.root_contract_address;return null===i?{l1address:"",l2address:t}:{l1address:i,l2address:t}},XO=async(e,t,n,r,i,a)=>{if(i===WO)return Y.from(0);const o=GR(e),s=WR(e);return await(async(e,t,n,r,i,a,o,s)=>{try{const u=await lO(i,a,t,e),{unsignedTx:l}=await u.getUnsignedApproveDepositBridgeTx({depositorAddress:r,token:o,depositAmount:s});return null===l?Y.from(0):await n.estimateGas(l)}catch(e){throw new DR("Error occurred while attempting ot estimate gas for approval transaction",LR.BRIDGE_GAS_ESTIMATE_ERROR,{message:e.message})}})(e,t,n,r,o,s,i,a)},ZO=(e,t)=>(e=>{for(const t of e.balances)if(!t.token.address||""===t.token.address)return t.balance;return Y.from(0)})(e).gte(t),YO=async(e,t,n)=>{let r=n.get(NR.BRIDGE);return r||(r=await(async(e,t)=>{try{const n=await yO({gasEstimateType:uR.BRIDGE_TO_L2,isSpendingCapApprovalRequired:!1},t,e),r=n.gasFee.estimatedAmount,i=n.bridgeFee.estimatedAmount;let a=Y.from(0);return r&&(a=a.add(r)),i&&(a=a.add(i)),{type:NR.BRIDGE,gasFee:{estimatedAmount:r??Y.from(0),token:n.gasFee.token},bridgeFee:{estimatedAmount:i??Y.from(0),token:n.bridgeFee.token},totalFees:a}}catch(e){throw new DR("Error estimating gas for bridge",LR.BRIDGE_GAS_ESTIMATE_ERROR,{message:e.message})}})(e,t),n.set(NR.BRIDGE,r),r)},JO=(e,t,n)=>{const r=n.token?.decimals??gR;return{approvalGasFees:{amount:e,formattedAmount:_d(e,gR),token:t.token},bridgeGasFees:{amount:t.estimatedAmount,formattedAmount:_d(t.estimatedAmount,gR),token:t.token},bridgeFees:[{amount:n.estimatedAmount,formattedAmount:_d(n.estimatedAmount,r),token:n.token}]}},QO=(e,t,n,r,i)=>({type:NR.BRIDGE,chainId:e,fundingItem:{type:r,fundsRequired:{amount:n.amount,formattedAmount:n.formattedAmount},userBalance:{balance:t.balance,formattedBalance:t.formattedBalance},token:{name:t.token.name,symbol:t.token.symbol,address:t.token.address,decimals:t.token.decimals}},fees:i}),eP=async(e,t,n,r,i,a,o)=>{if(!r.bridge)return;if(void 0===i.l2address||""===i.l2address)return;const s=GR(e),u=a.get(s),l=t.get(s);if(!l)throw new DR("No L1 provider available",LR.PROVIDER_ERROR,{chainId:s.toString()});if(void 0===u||!1===u.success)return;const c=await qO(e,a,r);if(0===c.length)return;const d=await YO(e,t,o);if(!ZO(u,d.totalFees))return;const f=await KO(e,i.l2address),{l1address:p}=f;if(""===p)return;if(p===WO){if(!c.find((e=>!("address"in e))))return}else if(!c.find((e=>e.address===p)))return;const h=await XO(e,t,l,n,p,i.amount);let m=d.bridgeFee.estimatedAmount;if(p===WO){const e=u.balances.find((e=>(e=>!e||""===e)(e.token.address)));if(d.gasFee.estimatedAmount&&(m=m.add(d.gasFee.estimatedAmount)),!ZO(u,m))return;if(e&&e.balance.gte(i.amount.add(m))){const t=JO(h,d.gasFee,d.bridgeFee);return QO(s,e,i,IR.NATIVE,t)}return}if(m.add(h).add(d.gasFee.estimatedAmount),!ZO(u,m))return;const y=u.balances.find((e=>e.token.address===p));if(y&&y.balance.gte(i.amount)){const e=JO(h,d.gasFee,d.bridgeFee);return QO(s,y,i,IR.ERC20,e)}},tP=(e,t)=>{let n=Y.from(0);return e.quote.fees.forEach((e=>{e.amount.token.address===t&&(n=n.add(e.amount.value))})),e.approval&&e.approval.token.address===t&&(n=n.add(e.approval.value)),n},nP=(e,t)=>{for(const n of e.balanceRequirements)if((n.type===IR.NATIVE||n.type===IR.ERC20)&&n.required.token.address===t)return n.required.balance;return Y.from(0)},rP=(e,t,n)=>{const r=n?.balance??Y.from(0);if(r.gte(e.add(t)))return Y.from(0);if(r.lte(0))return e.add(t);const i=r.sub(t);return i.gte(0)?e.sub(i):e.add(t).sub(r)},iP=async(e,t,n,r,i,a,o,s,u,l)=>{const{l1balances:c,l2balances:d}=((e,t)=>{const n={l1balances:[],l2balances:[]},r=t.get(GR(e)),i=t.get(WR(e));return r?void 0!==r.error?n:r.success&&i?void 0!==i.error?n:i.success?{l1balances:r.balances,l2balances:i.balances}:n:n:n})(e,o),f=r.required.token.address;if(((e,t,n,r,i,a)=>0===e.length||0===t.length||0===n.length||0===r.length||!i.bridge||!i.swap||void 0===a||""===a)(s,u,c,d,n,f))return[];const p=await(async(e,t)=>{const n=t.map((t=>KO(e,t.address??"")));return await Promise.all(n)})(e,u),h=((e,t,n,r)=>{const i=[];for(const a of r){if(""===a.l1address)continue;if(""===a.l2address)continue;if(!t.includes(a.l1address))continue;if(a.l2address===e)continue;const r=n.find((e=>e.address===a.l2address));r&&i.push(r)}return i})(f,s,u,p);if(0===h.length)return[];const m=await(async(e,t,n,r,i)=>{const a=[];for(const e of i)e.address&&a.push(e.address);return await LO(e,WR(e),t,{address:n,amount:r.delta.balance},a)})(e,i,f,r,h),y=((e,t,n,r,i)=>{const a=[];for(const[o,s]of e){const e=n.find((e=>e.token.address===o)),u=r.find((e=>e.l2address===o));if(!u)continue;const{l1address:l,l2address:c}=u;if(!l)continue;const d=t.find((e=>void 0===e.token.address&&l===WO||e.token.address===l));if(!d)continue;const f=s.quote.amountWithMaxSlippage.value,p=tP(s,o),h=f.add(p),m=nP(i,o),y=rP(h,m,e);y.lte(0)||y.gte(d.balance)||a.push({amount:y,formattedAmount:_d(y,d.token.decimals),l2address:c})}return a})(m,c,d,p,l);if(0===y.length)return[];const g=new Map,b=new Map,v=[];for(const r of y)r.l2address&&(g.set(r.l2address,eP(e,t,i,n,r,o,a)),b.set(r.l2address,{amount:r.amount,formattedAmount:r.formattedAmount,l2address:r.l2address}));const w=await Promise.all(g.values()),E=Array.from(g.keys()),T=[];if(w.forEach(((e,t)=>{const n=E[t];if(void 0===e)return;T.push(n);const r=b.get(n);r&&v.push({amount:r.amount,formattedAmount:r.formattedAmount,l2address:r.l2address})})),0===T.length)return[];if(0===v.length)return[];const A=((e,t,n,r,i)=>{const a=new Map;for(const[e,n]of t)a.set(e,{success:n.success,balances:n.balances});const o=new Map;for(const e of n)e.token.address&&o.set(e.token.address,e);for(const e of r){const{amount:t,l2address:n}=e;if(""===n)continue;let r=Y.from(0);const a=o.get(n);a&&(r=a.balance);const s=r.add(t),u=i.find((e=>e.address===n));o.set(n,{balance:s,formattedBalance:_d(s,u.decimals),token:u})}const s=Array.from(o.values());return a.set(WR(e),{success:!0,balances:s}),a})(e,o,d,v,u),_=await zO(e,n,i,r,A,T,l);if(!_)return[];const x=((e,t)=>{const n=[];for(const r of t){const{chainId:t,fundingItem:i}=r,{userBalance:a}=r.fundingItem,o=e.get(t);if(!o)continue;let s=Y.from(0),u="0";const l=o.balances.find((e=>e.token.address===i.token.address));l&&(s=l.balance,u=l.formattedBalance),a.balance=s,a.formattedBalance=u,n.push(r)}return n})(o,_);return((e,t,n)=>{const r=[];for(const i of e){if(!i)continue;const e=n.find((e=>void 0===i.fundingItem.token.address?e.l1address===WO&&e.l2address:e.l1address===i.fundingItem.token.address&&e.l2address));if(!e)continue;const a=t.find((t=>t.fundingItem.token.address===e.l2address));a&&r.push({bridgeFundingStep:i,swapFundingStep:a})}return r})(w,x,p)},aP=async(e,t,n)=>{if(!t.onRamp)return;if(void 0===n)return;const r=await(async(e,t,n)=>{if(n.type!==IR.ERC20&&n.type!==IR.NATIVE)return;const{required:r,current:i,delta:a}=n;let o=!1;const s=await HO(e,t);return Object.values(s).forEach((e=>{e.length>0&&!o&&(o=!!e.find((e=>e.address===r.token?.address)))})),o?{type:NR.ONRAMP,chainId:WR(e),fundingItem:{type:r.token.address===yR?IR.NATIVE:IR.ERC20,fundsRequired:{amount:a.balance,formattedAmount:a.formattedBalance},userBalance:{balance:i.balance,formattedBalance:i.formattedBalance},token:r.token}}:void 0})(e,t,n);return r},oP=async(e,t,n,r)=>{if(!(e=>e.bridge||e.swap||e.onRamp)(r))return{type:PR.NO_ROUTE_OPTIONS,message:"No routing options are available"};let i;try{i=await MO(e)}catch(e){throw new DR("Error occurred while creating read only providers",LR.PROVIDER_ERROR,{message:e.message})}const a=await JR(e,"Time to get token balances inside router",(async(e,t,n,r)=>{const i=new Map,a=new Map;if(0===t.size){const t={success:!1,error:new DR("No L1 or L2 provider available",LR.PROVIDER_ERROR),balances:[]};return i.set(GR(e),t),i.set(WR(e),t),i}if(r.bridge){const r=GR(e);t.has(r)?a.set(r,rO(e,t.get(r),n,r)):i.set(GR(e),{success:!1,error:new DR(`No L1 provider available for ${r}`,LR.PROVIDER_ERROR),balances:[]})}const o=WR(e);if(t.has(o)?a.set(o,rO(e,t.get(o),n,o)):i.set(WR(e),{success:!1,error:new DR(`No L2 provider available for ${o}`,LR.PROVIDER_ERROR),balances:[]}),a.size>0){const e=Array.from(a.keys());(await Promise.allSettled(a.values())).forEach(((t,n)=>{const r=e[n];"fulfilled"===t.status?i.set(r,{success:!0,balances:t.value.balances}):i.set(r,{success:!1,error:new DR(`Error getting ${o} balances`,LR.GET_BALANCE_ERROR),balances:[]})}))}return i})(e,i,t,r)),o=await JR(e,"Time to get routing allowlist",GO(e,a,r)),s=new Map,u=(e=>{let t,n=0;for(const r of e.balanceRequirements)r.sufficient||(n++,t=r);if(1===n)return t})(n),l=[];l.push((async(e,t,n,r,i,a,o)=>{let s;if(void 0===r)return;if(r.type!==IR.NATIVE&&r.type!==IR.ERC20)return;const u={amount:r.delta.balance,formattedAmount:r.delta.formattedBalance,l2address:r.required.token.address??""};return n.bridge&&r&&(s=await eP(e,t,i,n,u,a,o)),s})(e,i,r,u,t,a,s)),l.push((async(e,t,n,r,i,a,o)=>{const s=[];if(!t.swap)return s;if(void 0===n)return s;if(void 0===a)return s;const u=i.get(WR(e));if(!u)return s;if(void 0!==u.error||!u.success)return s;if(0===a.length)return s;const l=a.filter((e=>e.address)).map((e=>e.address));return 0===l.length?s:await zO(e,t,r,n,i,l,o)})(e,r,u,t,a,o.swap,n)),l.push(aP(e,r,u)),l.push((async(e,t,n,r,i,a,o,s,u)=>{if(!r)return[];const l=a.get(GR(e)),c=a.get(WR(e));if(!l)return[];if(void 0!==l.error||!l.success)return[];if(!c)return[];if(void 0!==c.error||!c.success)return[];const d=(o?.bridge??[]).map((e=>void 0===e.address?WO:e.address)),f=o?.swap??[];return r.type!==IR.NATIVE&&r.type!==IR.ERC20?[]:await iP(e,t,n,r,i,s,a,d,f,u)})(e,i,r,u,t,a,o,s,n));const c=await JR(e,"Time to resolve all routes",Promise.all(l));let d,f,p=[],h=[];if(c.forEach(((e,t)=>{0===t&&(d=e),1===t&&(p=e),2===t&&(f=e),3===t&&(h=e)})),!d&&0===p.length&&!f&&0===h.length)return{type:PR.NO_ROUTES_FOUND,message:"Smart Checkout did not find any funding routes to fulfill the transaction"};const m={type:PR.ROUTES_FOUND,fundingRoutes:[]};let y=0;return p.length>0&&(y++,p.forEach((e=>{m.fundingRoutes.push({priority:y,steps:[e]})}))),d&&(y++,m.fundingRoutes.push({priority:y,steps:[d]})),f&&(y++,m.fundingRoutes.push({priority:y,steps:[f]})),h&&(y++,h.forEach((e=>{const t=e.bridgeFundingStep,n=e.swapFundingStep;m.fundingRoutes.push({priority:y,steps:[t,n]})}))),m},sP=async(e,t,n,r)=>{const i=await t.getSigner().getAddress();let a=gO(n);const o=(async(e,t,n)=>{let r=!0;const i=[],a=new Map,o=new Map,s=new Map,u=new Map;for(const r of n){if(r.type!==IR.ERC20)continue;const{contractAddress:n,spenderAddress:i}=r,s=`${n}${i}`;a.set(s,r),o.set(s,bO(e,t,n,i))}const l=await Promise.all(o.values()),c=Array.from(o.keys());for(let n=0;n<l.length;n++){const o=a.get(c[n]);if(!o||o.type!==IR.ERC20)continue;if(l[n].gte(o.amount)){i.push({sufficient:!0,itemRequirement:o});continue}r=!1;const{contractAddress:d,spenderAddress:f}=o,p=`${d}${f}`,h=o.amount.sub(l[n]);s.set(p,{type:IR.ERC20,sufficient:!1,delta:h,itemRequirement:o,approvalTransaction:void 0}),u.set(p,vO(e,t,d,f,h))}const d=await Promise.all(u.values()),f=Array.from(u.keys());return d.forEach(((e,t)=>{const n=s.get(f[t]);n&&(n.sufficient||(n.approvalTransaction=e))})),{sufficient:r,allowances:i.concat(Array.from(s.values()))}})(t,i,a),s=_O(t,i,a),u=await JR(e,"Time to calculate token allowances",Promise.all([o,s])),l=((e,t)=>{const n=[];if(!e.sufficient)for(const t of e.allowances)t.sufficient||n.push(t);if(!t.sufficient)for(const e of t.allowances)e.sufficient||n.push(e);return n})(u[0],u[1]),c=await JR(e,"Time to run gas calculator",RO(t,l,r));null!==c&&(a.push(c),a=gO(a));const d=await JR(e,"Time to run balance checks",SO(e,t,i,a)),{sufficient:f}=d,p=d.balanceRequirements;if(f)return{sufficient:f,transactionRequirements:p};const h=await JR(e,"Time to fetch available routing options",(async(e,t)=>{const n={onRamp:e.isOnRampEnabled,swap:e.isSwapEnabled,bridge:e.isBridgeEnabled},r=[];if(n.onRamp&&r.push({id:"onRamp",promise:PO()}),n.swap&&r.push({id:"swap",promise:NO(e)}),r.length>0){const e=r.map((e=>e.promise));(await Promise.allSettled(e)).forEach(((e,t)=>{const i=r[t].id;n[i]=n[i]&&"fulfilled"===e.status&&e.value}))}return n.bridge=n.bridge&&!(e=>!0===e.provider?.isPassport??!1)(t),n})(e,t));return{sufficient:f,transactionRequirements:p,router:{availableRoutingOptions:h,routingOutcome:await JR(e,"Total time to run the routing calculator",oP(e,i,d,h))}}};var uP;!function(e){e.SUCCESS="SUCCESS",e.FAILED="FAILED"}(uP||(uP={}));const lP=async(e,t)=>{let n=[];try{const r=await Promise.all(t.map((t=>e.getSigner().sendTransaction(t))));n=await Promise.all(r.map((e=>e.wait())))}catch(e){throw new DR("An error occurred while executing the approval transaction",LR.EXECUTE_APPROVAL_TRANSACTION_ERROR,{message:e.message})}for(const e of n)if(0===e.status)return{type:uP.FAILED,transactionHash:e.transactionHash,reason:"Approval transaction failed and was reverted"};return{type:uP.SUCCESS}},cP=async(e,t)=>{let n=[];try{const r=await Promise.all(t.map((t=>e.getSigner().sendTransaction(t))));n=await Promise.all(r.map((e=>e.wait())))}catch(e){throw new DR("An error occurred while executing the fulfillment transaction",LR.EXECUTE_FULFILLMENT_TRANSACTION_ERROR,{message:e.message})}for(const e of n)if(0===e.status)return{type:uP.FAILED,transactionHash:e.transactionHash,reason:"Fulfillment transaction failed and was reverted"};return{type:uP.SUCCESS}},dP=async e=>{let t=[];const n=[];for(const t of e)t.type===KS.TRANSACTION&&t.purpose===WS.FULFILL_ORDER&&n.push(t.buildTransaction());return t=await Promise.all(n),t},fP=(e,t)=>{const n=e.amount,r=Math.round(n.percentageDecimal*10**6);return t.mul(Y.from(r)).div(10**6)},pP=(e,t)=>xd(e.amount.token,t),hP=(e,t,n=18)=>{let r=Y.from(0);const i=Y.from(t),a=i.mul(1e6).div(10**6),o=[];for(const t of e){let e=Y.from(0);if(Object.hasOwn(t.amount,"percentageDecimal"))e=fP(t,i),r=r.add(e);else{if(!Object.hasOwn(t.amount,"token"))throw new DR("Unknown fee type parsed, must be percentageDecimal or token",LR.ORDER_FEE_ERROR);e=pP(t,n),r=r.add(e)}if(r.gt(a))throw new DR("The combined fees are above the allowed maximum of 100%",LR.ORDER_FEE_ERROR);e.gt(0)&&o.push({amount:e.toString(),recipient:t.recipient})}return o},mP=(e,t,n,r)=>{switch(e){case IR.ERC20:return{type:e,amount:n,contractAddress:t,spenderAddress:r};case IR.NATIVE:default:return{type:IR.NATIVE,amount:n}}},yP=async(e,t,n)=>{let r,i,a="";const o=cI;if(0===n.length)throw new DR("No orders were provided to the orders array. Please provide at least one order.",LR.FULFILL_ORDER_LISTING_ERROR);const{id:s,takerFees:u}=n[0];try{r=dO(e),i=await JR(e,"Time to fetch the listing from the orderbook",r.getListing(s));const{seaportContractAddress:t}=r.config();a=t}catch(e){throw new DR("An error occurred while getting the order listing",LR.GET_ORDER_LISTING_ERROR,{orderId:s,message:e.message})}if(0===i.result.buy.length)throw new DR("An error occurred with the get order listing",LR.GET_ORDER_LISTING_ERROR,{orderId:s,message:"No buy side tokens found on order"});const l=i.result.buy[0];let c=18;if("ERC20"===i.result.buy[0].type){const n=fO(i.result.buy[0].contractAddress,CR,t);c=await JR(e,"Time to get decimals of token contract for the buy token",n.decimals())}let d=[];u&&u.length>0&&(d=hP(u,l.amount,c));let f=[],p=[],h=[];const m=(new Date).getTime();try{const n=await JR(e,"Time to get the address from the provider",t.getSigner().getAddress()),{actions:i}=await JR(e,"Time to call fulfillOrder from the orderbook",r.fulfillOrder(s,n,d));h=i,f=await JR(e,"Time to construct the unsigned approval transactions",(async e=>{let t=[];const n=[];for(const t of e)t.type===KS.TRANSACTION&&t.purpose===WS.APPROVAL&&n.push(t.buildTransaction());return t=await Promise.all(n),t})(i))}catch(t){const n=((new Date).getTime()-m)/1e3;YR(e,"Time to call fulfillOrder from the orderbook",n)}try{p=await JR(e,"Time to construct the unsigned fulfillment transactions",dP(h))}catch{}let y=Y.from("0"),g=IR.NATIVE,b="";const v=i.result.buy;if(v.length>0)switch(v[0].type){case"NATIVE":g=IR.NATIVE;break;case"ERC20":g=IR.ERC20,b=v[0].contractAddress;break;default:throw new DR("Purchasing token type is unsupported",LR.UNSUPPORTED_TOKEN_TYPE_ERROR,{orderId:s})}v.forEach((e=>{e.type!==IR.ERC721&&(y=y.add(Y.from(e.amount)))}));i.result.fees.forEach((e=>{y=y.add(Y.from(e.amount))}));const w=[mP(g,b,y,a)],E=await JR(e,"Total time running smart checkout",sP(e,t,w,((e,t)=>t.length>0?{type:RR.TRANSACTION,transaction:t[0]}:{type:RR.GAS,gasToken:{type:OR.NATIVE,limit:Y.from(e)}})(o,p)));if(E.sufficient){const e=await lP(t,f);if(e.type===uP.FAILED)return{status:SR.FAILED,transactionHash:e.transactionHash,reason:e.reason,smartCheckoutResult:E};try{0===p.length&&(p=await dP(h))}catch(e){throw new DR("Error fetching fulfillment transaction",LR.FULFILL_ORDER_LISTING_ERROR,{message:e.message})}const n=await cP(t,p);return n.type===uP.FAILED?{status:SR.FAILED,transactionHash:n.transactionHash,reason:n.reason,smartCheckoutResult:E}:{status:SR.SUCCESS,smartCheckoutResult:E}}return{status:SR.INSUFFICIENT_FUNDS,smartCheckoutResult:E}},gP=(e,t,n)=>({type:IR.ERC721,id:e,contractAddress:t,spenderAddress:n}),bP=async(e,t,n)=>{let r,i,a="";if(0===n.length)throw new DR("No orders were provided to the orders array. Please provide at least one order.",LR.PREPARE_ORDER_LISTING_ERROR);const{buyToken:o,sellToken:s,makerFees:u}=n[0];let l=18;if(o.type===IR.ERC20){const n=new gs(o.contractAddress,JSON.stringify(CR),t);l=await JR(e,"Time to get decimals of token contract for the buy token",n.decimals())}const c=((e,t=18)=>{const n=xd(e.amount,t);return e.type===IR.NATIVE?{type:IR.NATIVE,amount:n.toString()}:{type:IR.ERC20,amount:n.toString(),contractAddress:e.contractAddress}})(o,l);try{const n=await JR(e,"Time to get the address from the provider",t.getSigner().getAddress());r=dO(e);const{seaportContractAddress:o}=r.config();a=o,i=await JR(e,"Time to prepare the listing from the orderbook",r.prepareListing({makerAddress:n,buy:c,sell:{type:IR.ERC721,contractAddress:s.collectionAddress,tokenId:s.id}}))}catch(e){throw new DR("An error occurred while preparing the listing",LR.PREPARE_ORDER_LISTING_ERROR,{message:e.message,id:s.id,collectionAddress:s.collectionAddress})}const d=[gP(s.id,s.collectionAddress,a)],f=await JR(e,"Total time running smart checkout",sP(e,t,d,{type:RR.GAS,gasToken:{type:OR.NATIVE,limit:Y.from(cI)}}));if(f.sufficient){const e=await(async e=>{let t=[],n=[];const r=[],i=[];for(const t of e)t.type===KS.TRANSACTION&&(t.purpose===WS.APPROVAL&&r.push(t.buildTransaction()),t.purpose===WS.FULFILL_ORDER&&i.push(t.buildTransaction()));return t=await Promise.all(r),n=await Promise.all(i),{approvalTransactions:t,fulfillmentTransactions:n}})(i.actions),n=await lP(t,e.approvalTransactions);if(n.type===uP.FAILED)return{status:SR.FAILED,transactionHash:n.transactionHash,reason:n.reason,smartCheckoutResult:f};const a=((e,t,n)=>{let r;for(const e of n)e.type===KS.SIGNABLE&&e.purpose===$S.CREATE_LISTING&&(r={domain:e.message.domain,types:e.message.types,value:e.message.value});if(r)return{orderHash:e,orderComponents:t,unsignedMessage:r}})(i.orderHash,i.orderComponents,i.actions);if(!a)throw new DR("The unsigned message is missing after preparing the listing",LR.SIGN_MESSAGE_ERROR,{id:s.id,collectionAddress:s.collectionAddress});const o=await(async(e,t)=>{try{const n=await e.getSigner()._signTypedData(t.unsignedMessage.domain,t.unsignedMessage.types,t.unsignedMessage.value);return{orderComponents:t.orderComponents,orderHash:t.orderHash,signedMessage:n}}catch(e){throw new DR("An error occurred while signing the message",LR.SIGN_MESSAGE_ERROR,{message:e.message})}})(t,a);let d="";const p={orderComponents:o.orderComponents,orderHash:o.orderHash,orderSignature:o.signedMessage,makerFees:[]};if(void 0!==u){const e=hP(u,c.amount,l);if(e.length!==u.length)throw new DR("One of the fees is too small, must be greater than 0.000001",LR.CREATE_ORDER_LISTING_ERROR);p.makerFees=e}try{d=(await r.createListing(p)).result.id}catch(e){throw new DR("An error occurred while creating the listing",LR.CREATE_ORDER_LISTING_ERROR,{message:e.message,collectionId:s.id,collectionAddress:s.collectionAddress})}return{status:SR.SUCCESS,orderIds:[d],smartCheckoutResult:f}}return{status:SR.INSUFFICIENT_FUNDS,smartCheckoutResult:f}};class vP{config;constructor(e){this.config=e}async feeEstimate(){const e=await this.config.remote.getConfig("onramp");return e[sR.TRANSAK]?.fees}async createWidgetUrl(e){return await this.getTransakWidgetUrl(e)}async getTransakWidgetUrl(e){let t=`${ER[this.config.environment]}?`;if(t+=`${`apiKey=${(await this.config.remote.getConfig("onramp"))[sR.TRANSAK].publishableApiKey}`}&network=immutablezkevm&defaultPaymentMethod=credit_debit_card&disablePaymentMethods=sepa_bank_transfer,gbp_bank_transfer,pm_cash_app,pm_jwire,pm_paymaya,pm_bpi,pm_ubp,pm_grabpay,pm_shopeepay,pm_gcash,pm_pix,pm_astropay,pm_pse,inr_bank_transfer&productsAvailed=buy&exchangeScreenTitle=Buy&themeColor=0D0D0D`,e.isPassport&&e.email){t+=`&email=${encodeURIComponent(e.email)}&isAutoFillUserData=true&disableWalletAddressForm=true`}return e.tokenAmount&&e.tokenSymbol?t+=`&defaultCryptoAmount=${e.tokenAmount}&cryptoCurrencyCode=${e.tokenSymbol}`:t+="&defaultCryptoCurrency=IMX",e.walletAddress&&(t+=`&walletAddress=${e.walletAddress}`),t}}const wP=()=>"__SDK_VERSION__";function EP(e){if(void 0===window)throw new Error("missing window object: please run Checkout client side");if(void 0===document)throw new Error("missing document object: please run Checkout client side");const t=function(e){const t=wP();if(void 0===e||void 0===e.major)return t;if(!Number.isInteger(e.major)||e.major<0)return t;if(void 0!==e.minor&&e.minor<0)return t;if(void 0!==e.patch&&e.patch<0)return t;if(0===e.major&&void 0===e.minor)return t;if(0===e.major&&0===e.minor&&void 0===e.patch)return t;if(0===e.major&&void 0===e.minor&&void 0===e.patch)return t;if(0===e.major&&0===e.minor&&0===e.patch)return t;let n=e.major.toString();return void 0===e.minor||(Number.isInteger(e.minor)&&(n+=`.${e.minor.toString()}`),void 0===e.patch||(Number.isInteger(e.patch)&&(n+=`.${e.patch.toString()}`),void 0===e.prerelease||"alpha"!==e.prerelease||("alpha"===e.prerelease&&(n+=`-${e.prerelease}`),void 0===e.build||Number.isInteger(e.build)&&e.build>=0&&(n+=`.${e.build.toString()}`)))),n}(e),n=document.querySelector('[data-product="checkout"]');if(n)return{loaded:!0,element:n};const r=document.createElement("script");let i=`https://cdn.jsdelivr.net/npm/@imtbl/sdk@${t}/dist/browser/checkout/widgets.js`;return r.setAttribute("data-product","checkout"),r.setAttribute("data-version",t),r.setAttribute("src",i),document.head.appendChild(r),{loaded:!1,element:r}}const TP={baseConfig:{environment:i.SANDBOX}};class AP{readOnlyProviders;config;fiatRampService;availability;constructor(e=TP){this.config=new $R(e),this.fiatRampService=new vP(this.config),this.readOnlyProviders=new Map,this.availability=OO(this.config.isDevelopment,this.config.isProduction)}async widgets(e){const t=this,n=new Promise(((n,r)=>{function i(){"undefined"!=typeof ImmutableCheckoutWidgets&&n(new ImmutableCheckoutWidgets.WidgetsFactory(t,e.config))}try{if(EP(e.version).loaded)console.warn("Checkout widgets script is already loaded"),i();else{new MutationObserver(((e,t)=>{i(),t.disconnect()})).observe(document.head,{childList:!0,subtree:!0})}}catch(e){r(e)}}));return n}async createProvider(e){return await iO(e.walletProvider,e.passport)}async checkIsWalletConnected(e){return async function(e){if(!e?.provider?.request)throw new DR("Check wallet connection request failed",LR.PROVIDER_REQUEST_FAILED_ERROR,{rpcMethod:dR.CHECK_CONNECTION});let t=[];try{t=await e.provider.request({method:dR.CHECK_CONNECTION,params:[]})}catch(e){throw new DR("Check wallet connection request failed",LR.PROVIDER_REQUEST_FAILED_ERROR,{rpcMethod:dR.CHECK_CONNECTION})}return{isConnected:t&&t.length>0,walletAddress:t[0]??""}}(await oO(this.config,e.provider,{allowUnsupportedProvider:!0}))}async connect(e){const t=await oO(this.config,e.provider,{allowUnsupportedProvider:!0});await async function(e){if(!e||!e.provider?.request)throw new DR("Incompatible provider",LR.PROVIDER_REQUEST_MISSING_ERROR,{details:"Attempting to connect with an incompatible provider"});return await BR((async()=>{e.provider.request&&await e.provider.request({method:dR.CONNECT,params:[]})}),{type:LR.USER_REJECTED_REQUEST_ERROR}),e}(t);return{provider:t,network:await zR(this.config,t)}}async switchNetwork(e){const t=await oO(this.config,e.provider,{allowUnsupportedProvider:!0,allowMistmatchedChainId:!0});return await VR(this.config,t,e.chainId)}async getBalance(e){const t=await oO(this.config,e.provider);return e.contractAddress&&""!==e.contractAddress?await eO(t,e.walletAddress,e.contractAddress):await QR(this.config,t,e.walletAddress)}async getAllBalances(e){const t=await oO(this.config,e.provider);return rO(this.config,t,e.walletAddress,e.chainId)}async getNetworkAllowList(e){return await UR(this.config,e)}async getTokenAllowList(e){return await KR(this.config,e)}async getWalletAllowList(e){return await async function(e){const t=[],n=e.exclude?.map((e=>e.walletProvider))??[];let r=Object.values(pR);0!==n.length&&(r=r.filter((e=>!n.includes(e))));for(const e of r)t.push({walletProvider:e,name:e});return{wallets:t}}(e)}async sendTransaction(e){const t=await oO(this.config,e.provider);return await(async(e,t)=>{try{return{transactionResponse:await e.getSigner().sendTransaction(t)}}catch(e){if(e.code===v.INSUFFICIENT_FUNDS)throw new DR(e.message,LR.INSUFFICIENT_FUNDS);if(e.code===v.ACTION_REJECTED)throw new DR(e.message,LR.USER_REJECTED_REQUEST_ERROR);if(e.code===v.UNPREDICTABLE_GAS_LIMIT)throw new DR(e.message,LR.UNPREDICTABLE_GAS_LIMIT);throw new DR(e.message,LR.TRANSACTION_FAILED)}})(t,e.transaction)}async getNetworkInfo(e){const t=await oO(this.config,e.provider,{allowUnsupportedProvider:!0,allowMistmatchedChainId:!0});return await zR(this.config,t)}async buy(e){e.orders.length>1&&console.warn("This endpoint currently only processes the first order in the array.");const t=await oO(this.config,e.provider);return await yP(this.config,t,e.orders)}async sell(e){e.orders.length>1&&console.warn("This endpoint currently only processes the first order in the array.");const t=await oO(this.config,e.provider);return await bP(this.config,t,e.orders)}async cancel(e){console.warn("This endpoint currently only processes the first order in the array.");const t=await oO(this.config,e.provider);return await(async(e,t,n)=>{let r;if(0===n.length)throw new DR("No orderIds were provided to the orderIds array. Please provide at least one orderId.",LR.CANCEL_ORDER_LISTING_ERROR);const i=n[0];try{const n=await JR(e,"Time to get the address from the provider",t.getSigner().getAddress()),a=dO(e);r=(await JR(e,"Time to get the cancel order from the orderbook",a.cancelOrder(i,n))).unsignedCancelOrderTransaction}catch(e){throw new DR("An error occurred while cancelling the order listing",LR.CANCEL_ORDER_LISTING_ERROR,{orderId:i,message:e.message})}const a=await cP(t,[r]);return a.type===uP.FAILED?{status:SR.FAILED,transactionHash:a.transactionHash,reason:a.reason}:{status:SR.SUCCESS}})(this.config,t,e.orderIds)}async smartCheckout(e){const t=await oO(this.config,e.provider);let n=[];try{n=await async function(e,t){const n=[];t.forEach((t=>{if(t.type===IR.ERC20){const{contractAddress:r}=t;n.push(fO(r,CR,e).decimals())}}));const r=await Promise.all(n),i=t.map(((e,t)=>e.type===IR.NATIVE?{...e,amount:xd(e.amount,18)}:e.type===IR.ERC20?{...e,amount:xd(e.amount,r[t])}:e));return i}(t,e.itemRequirements)}catch{throw new DR("Failed to map item requirements",LR.ITEM_REQUIREMENTS_ERROR)}return await sP(this.config,t,n,e.transactionOrGasAmount)}static isWeb3Provider(e){return aO(e)}async gasEstimate(e){return this.readOnlyProviders=await MO(this.config,this.readOnlyProviders),await yO(e,this.readOnlyProviders,this.config)}async createFiatRampUrl(e){let t,n,r="IMX";const i=await e.web3Provider.getSigner().getAddress(),a=e.web3Provider.provider?.isPassport||!1;if(a&&e.passport){const t=await e.passport.getUserInfo();n=t?.email}const o=await KR(this.config,{type:cR.ONRAMP}),s=o.tokens?.find((t=>t.address?.toLowerCase()===e.tokenAddress?.toLowerCase()));return s&&(t=e.tokenAmount,r=s.symbol),await this.fiatRampService.createWidgetUrl({exchangeType:e.exchangeType,isPassport:a,walletAddress:i,tokenAmount:t,tokenSymbol:r,email:n})}async getExchangeFeeEstimate(){return await this.fiatRampService.feeEstimate()}async isSwapAvailable(){return this.availability.checkDexAvailability()}}var _P,xP={exports:{}},CP={},kP={exports:{}},SP={};kP.exports=function(){if(_P)return SP;_P=1;var e=Symbol.for("react.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),a=Symbol.for("react.provider"),o=Symbol.for("react.context"),s=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),l=Symbol.for("react.memo"),c=Symbol.for("react.lazy"),d=Symbol.iterator,f={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},p=Object.assign,h={};function m(e,t,n){this.props=e,this.context=t,this.refs=h,this.updater=n||f}function y(){}function g(e,t,n){this.props=e,this.context=t,this.refs=h,this.updater=n||f}m.prototype.isReactComponent={},m.prototype.setState=function(e,t){if("object"!=typeof e&&"function"!=typeof e&&null!=e)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")},m.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")},y.prototype=m.prototype;var b=g.prototype=new y;b.constructor=g,p(b,m.prototype),b.isPureReactComponent=!0;var v=Array.isArray,w=Object.prototype.hasOwnProperty,E={current:null},T={key:!0,ref:!0,__self:!0,__source:!0};function A(t,n,r){var i,a={},o=null,s=null;if(null!=n)for(i in void 0!==n.ref&&(s=n.ref),void 0!==n.key&&(o=""+n.key),n)w.call(n,i)&&!T.hasOwnProperty(i)&&(a[i]=n[i]);var u=arguments.length-2;if(1===u)a.children=r;else if(1<u){for(var l=Array(u),c=0;c<u;c++)l[c]=arguments[c+2];a.children=l}if(t&&t.defaultProps)for(i in u=t.defaultProps)void 0===a[i]&&(a[i]=u[i]);return{$$typeof:e,type:t,key:o,ref:s,props:a,_owner:E.current}}function _(t){return"object"==typeof t&&null!==t&&t.$$typeof===e}var x=/\/+/g;function C(e,t){return"object"==typeof e&&null!==e&&null!=e.key?function(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,(function(e){return t[e]}))}(""+e.key):t.toString(36)}function k(n,r,i,a,o){var s=typeof n;"undefined"!==s&&"boolean"!==s||(n=null);var u=!1;if(null===n)u=!0;else switch(s){case"string":case"number":u=!0;break;case"object":switch(n.$$typeof){case e:case t:u=!0}}if(u)return o=o(u=n),n=""===a?"."+C(u,0):a,v(o)?(i="",null!=n&&(i=n.replace(x,"$&/")+"/"),k(o,r,i,"",(function(e){return e}))):null!=o&&(_(o)&&(o=function(t,n){return{$$typeof:e,type:t.type,key:n,ref:t.ref,props:t.props,_owner:t._owner}}(o,i+(!o.key||u&&u.key===o.key?"":(""+o.key).replace(x,"$&/")+"/")+n)),r.push(o)),1;if(u=0,a=""===a?".":a+":",v(n))for(var l=0;l<n.length;l++){var c=a+C(s=n[l],l);u+=k(s,r,i,c,o)}else if(c=function(e){return null===e||"object"!=typeof e?null:"function"==typeof(e=d&&e[d]||e["@@iterator"])?e:null}(n),"function"==typeof c)for(n=c.call(n),l=0;!(s=n.next()).done;)u+=k(s=s.value,r,i,c=a+C(s,l++),o);else if("object"===s)throw r=String(n),Error("Objects are not valid as a React child (found: "+("[object Object]"===r?"object with keys {"+Object.keys(n).join(", ")+"}":r)+"). If you meant to render a collection of children, use an array instead.");return u}function S(e,t,n){if(null==e)return e;var r=[],i=0;return k(e,r,"","",(function(e){return t.call(n,e,i++)})),r}function I(e){if(-1===e._status){var t=e._result;(t=t()).then((function(t){0!==e._status&&-1!==e._status||(e._status=1,e._result=t)}),(function(t){0!==e._status&&-1!==e._status||(e._status=2,e._result=t)})),-1===e._status&&(e._status=0,e._result=t)}if(1===e._status)return e._result.default;throw e._result}var R={current:null},O={transition:null},P={ReactCurrentDispatcher:R,ReactCurrentBatchConfig:O,ReactCurrentOwner:E};return SP.Children={map:S,forEach:function(e,t,n){S(e,(function(){t.apply(this,arguments)}),n)},count:function(e){var t=0;return S(e,(function(){t++})),t},toArray:function(e){return S(e,(function(e){return e}))||[]},only:function(e){if(!_(e))throw Error("React.Children.only expected to receive a single React element child.");return e}},SP.Component=m,SP.Fragment=n,SP.Profiler=i,SP.PureComponent=g,SP.StrictMode=r,SP.Suspense=u,SP.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=P,SP.cloneElement=function(t,n,r){if(null==t)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+t+".");var i=p({},t.props),a=t.key,o=t.ref,s=t._owner;if(null!=n){if(void 0!==n.ref&&(o=n.ref,s=E.current),void 0!==n.key&&(a=""+n.key),t.type&&t.type.defaultProps)var u=t.type.defaultProps;for(l in n)w.call(n,l)&&!T.hasOwnProperty(l)&&(i[l]=void 0===n[l]&&void 0!==u?u[l]:n[l])}var l=arguments.length-2;if(1===l)i.children=r;else if(1<l){u=Array(l);for(var c=0;c<l;c++)u[c]=arguments[c+2];i.children=u}return{$$typeof:e,type:t.type,key:a,ref:o,props:i,_owner:s}},SP.createContext=function(e){return(e={$$typeof:o,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null}).Provider={$$typeof:a,_context:e},e.Consumer=e},SP.createElement=A,SP.createFactory=function(e){var t=A.bind(null,e);return t.type=e,t},SP.createRef=function(){return{current:null}},SP.forwardRef=function(e){return{$$typeof:s,render:e}},SP.isValidElement=_,SP.lazy=function(e){return{$$typeof:c,_payload:{_status:-1,_result:e},_init:I}},SP.memo=function(e,t){return{$$typeof:l,type:e,compare:void 0===t?null:t}},SP.startTransition=function(e){var t=O.transition;O.transition={};try{e()}finally{O.transition=t}},SP.unstable_act=function(){throw Error("act(...) is not supported in production builds of React.")},SP.useCallback=function(e,t){return R.current.useCallback(e,t)},SP.useContext=function(e){return R.current.useContext(e)},SP.useDebugValue=function(){},SP.useDeferredValue=function(e){return R.current.useDeferredValue(e)},SP.useEffect=function(e,t){return R.current.useEffect(e,t)},SP.useId=function(){return R.current.useId()},SP.useImperativeHandle=function(e,t,n){return R.current.useImperativeHandle(e,t,n)},SP.useInsertionEffect=function(e,t){return R.current.useInsertionEffect(e,t)},SP.useLayoutEffect=function(e,t){return R.current.useLayoutEffect(e,t)},SP.useMemo=function(e,t){return R.current.useMemo(e,t)},SP.useReducer=function(e,t,n){return R.current.useReducer(e,t,n)},SP.useRef=function(e){return R.current.useRef(e)},SP.useState=function(e){return R.current.useState(e)},SP.useSyncExternalStore=function(e,t,n){return R.current.useSyncExternalStore(e,t,n)},SP.useTransition=function(){return R.current.useTransition()},SP.version="18.2.0",SP}();var IP,RP=kP.exports,OP=s(RP),PP=r({__proto__:null,default:OP},[RP]);xP.exports=function(){if(IP)return CP;IP=1;var e=RP,t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,i=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,a={key:!0,ref:!0,__self:!0,__source:!0};function o(e,n,o){var s,u={},l=null,c=null;for(s in void 0!==o&&(l=""+o),void 0!==n.key&&(l=""+n.key),void 0!==n.ref&&(c=n.ref),n)r.call(n,s)&&!a.hasOwnProperty(s)&&(u[s]=n[s]);if(e&&e.defaultProps)for(s in n=e.defaultProps)void 0===u[s]&&(u[s]=n[s]);return{$$typeof:t,type:e,key:l,ref:c,props:u,_owner:i.current}}return CP.Fragment=n,CP.jsx=o,CP.jsxs=o,CP}();var NP,MP,LP,FP=xP.exports,DP={exports:{}},BP={},jP={exports:{}},UP={};function zP(){return MP||(MP=1,jP.exports=(NP||(NP=1,function(e){function t(e,t){var n=e.length;e.push(t);e:for(;0<n;){var r=n-1>>>1,a=e[r];if(!(0<i(a,t)))break e;e[r]=t,e[n]=a,n=r}}function n(e){return 0===e.length?null:e[0]}function r(e){if(0===e.length)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;e:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,u=e[s],l=s+1,c=e[l];if(0>i(u,n))l<a&&0>i(c,u)?(e[r]=c,e[l]=n,r=l):(e[r]=u,e[s]=n,r=s);else{if(!(l<a&&0>i(c,n)))break e;e[r]=c,e[l]=n,r=l}}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return 0!==n?n:e.id-t.id}if("object"==typeof performance&&"function"==typeof performance.now){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var u=[],l=[],c=1,d=null,f=3,p=!1,h=!1,m=!1,y="function"==typeof setTimeout?setTimeout:null,g="function"==typeof clearTimeout?clearTimeout:null,b="undefined"!=typeof setImmediate?setImmediate:null;function v(e){for(var i=n(l);null!==i;){if(null===i.callback)r(l);else{if(!(i.startTime<=e))break;r(l),i.sortIndex=i.expirationTime,t(u,i)}i=n(l)}}function w(e){if(m=!1,v(e),!h)if(null!==n(u))h=!0,P(E);else{var t=n(l);null!==t&&N(w,t.startTime-e)}}function E(t,i){h=!1,m&&(m=!1,g(x),x=-1),p=!0;var a=f;try{for(v(i),d=n(u);null!==d&&(!(d.expirationTime>i)||t&&!S());){var o=d.callback;if("function"==typeof o){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=i);i=e.unstable_now(),"function"==typeof s?d.callback=s:d===n(u)&&r(u),v(i)}else r(u);d=n(u)}if(null!==d)var c=!0;else{var y=n(l);null!==y&&N(w,y.startTime-i),c=!1}return c}finally{d=null,f=a,p=!1}}"undefined"!=typeof navigator&&void 0!==navigator.scheduling&&void 0!==navigator.scheduling.isInputPending&&navigator.scheduling.isInputPending.bind(navigator.scheduling);var T,A=!1,_=null,x=-1,C=5,k=-1;function S(){return!(e.unstable_now()-k<C)}function I(){if(null!==_){var t=e.unstable_now();k=t;var n=!0;try{n=_(!0,t)}finally{n?T():(A=!1,_=null)}}else A=!1}if("function"==typeof b)T=function(){b(I)};else if("undefined"!=typeof MessageChannel){var R=new MessageChannel,O=R.port2;R.port1.onmessage=I,T=function(){O.postMessage(null)}}else T=function(){y(I,0)};function P(e){_=e,A||(A=!0,T())}function N(t,n){x=y((function(){t(e.unstable_now())}),n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_continueExecution=function(){h||p||(h=!0,P(E))},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):C=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_getFirstCallbackNode=function(){return n(u)},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(a="object"==typeof a&&null!==a&&"number"==typeof(a=a.delay)&&0<a?o+a:o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return r={id:c++,callback:i,priorityLevel:r,startTime:a,expirationTime:s=a+s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),null===n(u)&&r===n(l)&&(m?(g(x),x=-1):m=!0,N(w,a-o))):(r.sortIndex=s,t(u,r),h||p||(h=!0,P(E))),r},e.unstable_shouldYield=S,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}}(UP)),UP)),jP.exports}
|
|
36
36
|
/**
|
|
37
37
|
* @license React
|
|
38
38
|
* react-dom.production.min.js
|