@ultrade/shared 1.0.8 → 1.0.10

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.
Files changed (124) hide show
  1. package/dist/browser/common/auth.helper.js +17 -0
  2. package/dist/browser/common/big-number.helper.js +11 -0
  3. package/dist/browser/common/index.js +17 -0
  4. package/dist/browser/common/mappers/codexAsset.mapper.js +11 -0
  5. package/dist/browser/common/mappers/codexBalance.mapper.js +11 -0
  6. package/dist/browser/common/mappers/index.js +11 -0
  7. package/dist/browser/common/mappers/trade.mapper.js +11 -0
  8. package/dist/browser/common/utils/assert.js +11 -0
  9. package/dist/browser/common/utils/decode.js +11 -0
  10. package/dist/browser/common/utils/index.js +11 -0
  11. package/dist/browser/common/utils/social.js +11 -0
  12. package/dist/browser/common/utils/stat.js +11 -0
  13. package/dist/browser/constants/index.js +11 -0
  14. package/dist/browser/enums/index.js +11 -0
  15. package/dist/browser/helpers/Encoding.js +17 -0
  16. package/dist/browser/helpers/algo.helper.js +17 -0
  17. package/dist/browser/helpers/assert.helper.js +11 -0
  18. package/dist/browser/helpers/atomic.helper.js +11 -0
  19. package/dist/browser/helpers/balance.helper.js +17 -0
  20. package/dist/browser/helpers/codex/common.helper.js +18 -0
  21. package/dist/browser/helpers/codex/index.js +18 -0
  22. package/dist/browser/helpers/codex/mbr.helper.js +17 -0
  23. package/dist/browser/helpers/codex/mna.helper.js +17 -0
  24. package/dist/browser/helpers/codex/order.helper.js +17 -0
  25. package/dist/browser/helpers/codex/setGlobal.helper.js +17 -0
  26. package/dist/browser/helpers/codex/transfer.helper.js +18 -0
  27. package/dist/browser/helpers/codex/txn.helper.js +17 -0
  28. package/dist/browser/helpers/codex.helper.js +24 -0
  29. package/dist/browser/helpers/eth.helper.js +18 -0
  30. package/dist/browser/helpers/index.js +11 -0
  31. package/dist/browser/helpers/interval.helpers.js +11 -0
  32. package/dist/browser/helpers/liquidity.helper.js +11 -0
  33. package/dist/browser/helpers/order.helper.js +11 -0
  34. package/dist/browser/helpers/pair.helper.js +11 -0
  35. package/dist/browser/helpers/pointSystem.helper.js +11 -0
  36. package/dist/browser/helpers/ticker.helpers.js +11 -0
  37. package/dist/browser/helpers/vaa.helper.js +11 -0
  38. package/dist/browser/helpers/withdraw.helper.js +18 -0
  39. package/dist/browser/interfaces/index.js +11 -0
  40. package/dist/browser/types/index.js +11 -0
  41. package/dist/node/common/auth.helper.js +1 -0
  42. package/dist/node/common/big-number.helper.js +1 -0
  43. package/dist/node/common/index.js +1 -0
  44. package/dist/node/common/mappers/codexAsset.mapper.js +1 -0
  45. package/dist/node/common/mappers/codexBalance.mapper.js +1 -0
  46. package/dist/node/common/mappers/index.js +1 -0
  47. package/dist/node/common/mappers/trade.mapper.js +1 -0
  48. package/dist/node/common/utils/assert.js +1 -0
  49. package/dist/node/common/utils/decode.js +1 -0
  50. package/dist/node/common/utils/index.js +1 -0
  51. package/dist/node/common/utils/social.js +1 -0
  52. package/dist/node/common/utils/stat.js +1 -0
  53. package/dist/node/constants/index.js +1 -0
  54. package/dist/node/enums/index.js +1 -0
  55. package/dist/node/helpers/Encoding.js +1 -0
  56. package/dist/node/helpers/algo.helper.js +1 -0
  57. package/dist/node/helpers/assert.helper.js +1 -0
  58. package/dist/node/helpers/atomic.helper.js +1 -0
  59. package/dist/node/helpers/balance.helper.js +1 -0
  60. package/dist/node/helpers/codex/common.helper.js +2 -0
  61. package/dist/node/helpers/codex/index.js +2 -0
  62. package/dist/node/helpers/codex/mbr.helper.js +1 -0
  63. package/dist/node/helpers/codex/mna.helper.js +1 -0
  64. package/dist/node/helpers/codex/order.helper.js +1 -0
  65. package/dist/node/helpers/codex/setGlobal.helper.js +1 -0
  66. package/dist/node/helpers/codex/transfer.helper.js +2 -0
  67. package/dist/node/helpers/codex/txn.helper.js +1 -0
  68. package/dist/node/helpers/codex.helper.js +8 -0
  69. package/dist/node/helpers/eth.helper.js +2 -0
  70. package/dist/node/helpers/index.js +1 -0
  71. package/dist/node/helpers/interval.helpers.js +1 -0
  72. package/dist/node/helpers/liquidity.helper.js +1 -0
  73. package/dist/node/helpers/order.helper.js +1 -0
  74. package/dist/node/helpers/pair.helper.js +1 -0
  75. package/dist/node/helpers/pointSystem.helper.js +1 -0
  76. package/dist/node/helpers/ticker.helpers.js +1 -0
  77. package/dist/node/helpers/vaa.helper.js +0 -0
  78. package/dist/node/helpers/withdraw.helper.js +2 -0
  79. package/dist/node/interfaces/index.js +1 -0
  80. package/dist/node/types/index.js +1 -0
  81. package/dist/src/helpers/vaa.helper.d.ts +0 -2
  82. package/dist/src/interfaces/index.d.ts +1 -0
  83. package/dist/src/interfaces/pagination.interface.d.ts +57 -0
  84. package/package.json +25 -47
  85. package/dist/common/auth.helper.js +0 -1
  86. package/dist/common/big-number.helper.js +0 -1
  87. package/dist/common/index.js +0 -1
  88. package/dist/common/mappers/codexAsset.mapper.js +0 -1
  89. package/dist/common/mappers/codexBalance.mapper.js +0 -1
  90. package/dist/common/mappers/index.js +0 -1
  91. package/dist/common/mappers/trade.mapper.js +0 -1
  92. package/dist/common/utils/assert.js +0 -1
  93. package/dist/common/utils/decode.js +0 -1
  94. package/dist/common/utils/index.js +0 -1
  95. package/dist/common/utils/social.js +0 -1
  96. package/dist/common/utils/stat.js +0 -1
  97. package/dist/constants/index.js +0 -1
  98. package/dist/enums/index.js +0 -1
  99. package/dist/helpers/Encoding.js +0 -1
  100. package/dist/helpers/algo.helper.js +0 -1
  101. package/dist/helpers/assert.helper.js +0 -1
  102. package/dist/helpers/atomic.helper.js +0 -1
  103. package/dist/helpers/balance.helper.js +0 -1
  104. package/dist/helpers/codex/common.helper.js +0 -2
  105. package/dist/helpers/codex/index.js +0 -2
  106. package/dist/helpers/codex/mbr.helper.js +0 -1
  107. package/dist/helpers/codex/mna.helper.js +0 -1
  108. package/dist/helpers/codex/order.helper.js +0 -1
  109. package/dist/helpers/codex/setGlobal.helper.js +0 -1
  110. package/dist/helpers/codex/transfer.helper.js +0 -2
  111. package/dist/helpers/codex/txn.helper.js +0 -1
  112. package/dist/helpers/codex.helper.js +0 -8
  113. package/dist/helpers/eth.helper.js +0 -2
  114. package/dist/helpers/index.js +0 -1
  115. package/dist/helpers/interval.helpers.js +0 -1
  116. package/dist/helpers/liquidity.helper.js +0 -1
  117. package/dist/helpers/order.helper.js +0 -1
  118. package/dist/helpers/pair.helper.js +0 -1
  119. package/dist/helpers/pointSystem.helper.js +0 -1
  120. package/dist/helpers/ticker.helpers.js +0 -1
  121. package/dist/helpers/vaa.helper.js +0 -1
  122. package/dist/helpers/withdraw.helper.js +0 -2
  123. package/dist/interfaces/index.js +0 -1
  124. package/dist/types/index.js +0 -1
@@ -0,0 +1,24 @@
1
+ function Re(){throw new Error("setTimeout has not been defined")}function Se(){throw new Error("clearTimeout has not been defined")}var j=Re,Q=Se;typeof globalThis.setTimeout=="function"&&(j=setTimeout);typeof globalThis.clearTimeout=="function"&&(Q=clearTimeout);function Be(t){if(j===setTimeout)return setTimeout(t,0);if((j===Re||!j)&&setTimeout)return j=setTimeout,setTimeout(t,0);try{return j(t,0)}catch{try{return j.call(null,t,0)}catch{return j.call(this,t,0)}}}function tn(t){if(Q===clearTimeout)return clearTimeout(t);if((Q===Se||!Q)&&clearTimeout)return Q=clearTimeout,clearTimeout(t);try{return Q(t)}catch{try{return Q.call(null,t)}catch{return Q.call(this,t)}}}var X=[],dr=!1,or,wr=-1;function nn(){!dr||!or||(dr=!1,or.length?X=or.concat(X):wr=-1,X.length&&De())}function De(){if(!dr){var t=Be(nn);dr=!0;for(var r=X.length;r;){for(or=X,X=[];++wr<r;)or&&or[wr].run();wr=-1,r=X.length}or=null,dr=!1,tn(t)}}function on(t){var r=new Array(arguments.length-1);if(arguments.length>1)for(var e=1;e<arguments.length;e++)r[e-1]=arguments[e];X.push(new Ce(t,r)),X.length===1&&!dr&&Be(De)}function Ce(t,r){this.fun=t,this.array=r}Ce.prototype.run=function(){this.fun.apply(null,this.array)};var an="browser",sn="browser",cn=!0,un={},pn=[],ln="",mn={},dn={},fn={};function ir(){}var gn=ir,hn=ir,xn=ir,bn=ir,En=ir,An=ir,Tn=ir;function yn(t){throw new Error("process.binding is not supported")}function _n(){return"/"}function In(t){throw new Error("process.chdir is not supported")}function wn(){return 0}var mr=globalThis.performance||{},Nn=mr.now||mr.mozNow||mr.msNow||mr.oNow||mr.webkitNow||function(){return new Date().getTime()};function Rn(t){var r=Nn.call(mr)*.001,e=Math.floor(r),n=Math.floor(r%1*1e9);return t&&(e=e-t[0],n=n-t[1],n<0&&(e--,n+=1e9)),[e,n]}var Sn=new Date;function Bn(){var t=new Date,r=t-Sn;return r/1e3}var f={nextTick:on,title:an,browser:cn,env:un,argv:pn,version:ln,versions:mn,on:gn,addListener:hn,once:xn,off:bn,removeListener:En,removeAllListeners:An,emit:Tn,binding:yn,cwd:_n,chdir:In,umask:wn,hrtime:Rn,platform:sn,release:dn,config:fn,uptime:Bn},Ne={};Object.keys(Ne).forEach(t=>{let r=t.split("."),e=f;for(let n=0;n<r.length;n++){let o=r[n];n===r.length-1?e[o]=Ne[t]:e=e[o]||(e[o]={})}});var Y=[],k=[],Dn=typeof Uint8Array<"u"?Uint8Array:Array,qr=!1;function Pe(){qr=!0;for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r=0,e=t.length;r<e;++r)Y[r]=t[r],k[t.charCodeAt(r)]=r;k[45]=62,k[95]=63}function Cn(t){qr||Pe();var r,e,n,o,i,a,c=t.length;if(c%4>0)throw new Error("Invalid string. Length must be a multiple of 4");i=t[c-2]==="="?2:t[c-1]==="="?1:0,a=new Dn(c*3/4-i),n=i>0?c-4:c;var u=0;for(r=0,e=0;r<n;r+=4,e+=3)o=k[t.charCodeAt(r)]<<18|k[t.charCodeAt(r+1)]<<12|k[t.charCodeAt(r+2)]<<6|k[t.charCodeAt(r+3)],a[u++]=o>>16&255,a[u++]=o>>8&255,a[u++]=o&255;return i===2?(o=k[t.charCodeAt(r)]<<2|k[t.charCodeAt(r+1)]>>4,a[u++]=o&255):i===1&&(o=k[t.charCodeAt(r)]<<10|k[t.charCodeAt(r+1)]<<4|k[t.charCodeAt(r+2)]>>2,a[u++]=o>>8&255,a[u++]=o&255),a}function On(t){return Y[t>>18&63]+Y[t>>12&63]+Y[t>>6&63]+Y[t&63]}function kn(t,r,e){for(var n,o=[],i=r;i<e;i+=3)n=(t[i]<<16)+(t[i+1]<<8)+t[i+2],o.push(On(n));return o.join("")}function Oe(t){qr||Pe();for(var r,e=t.length,n=e%3,o="",i=[],a=16383,c=0,u=e-n;c<u;c+=a)i.push(kn(t,c,c+a>u?u:c+a));return n===1?(r=t[e-1],o+=Y[r>>2],o+=Y[r<<4&63],o+="=="):n===2&&(r=(t[e-2]<<8)+t[e-1],o+=Y[r>>10],o+=Y[r>>4&63],o+=Y[r<<2&63],o+="="),i.push(o),i.join("")}s.TYPED_ARRAY_SUPPORT=globalThis.TYPED_ARRAY_SUPPORT!==void 0?globalThis.TYPED_ARRAY_SUPPORT:!0;function Nr(){return s.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function q(t,r){if(Nr()<r)throw new RangeError("Invalid typed array length");return s.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(r),t.__proto__=s.prototype):(t===null&&(t=new s(r)),t.length=r),t}function s(t,r,e){if(!s.TYPED_ARRAY_SUPPORT&&!(this instanceof s))return new s(t,r,e);if(typeof t=="number"){if(typeof r=="string")throw new Error("If encoding is specified then the first argument must be a string");return Jr(this,t)}return Le(this,t,r,e)}s.poolSize=8192;s._augment=function(t){return t.__proto__=s.prototype,t};function Le(t,r,e,n){if(typeof r=="number")throw new TypeError('"value" argument must not be a number');return typeof ArrayBuffer<"u"&&r instanceof ArrayBuffer?Ln(t,r,e,n):typeof r=="string"?Pn(t,r,e):Mn(t,r)}s.from=function(t,r,e){return Le(null,t,r,e)};s.kMaxLength=Nr();s.TYPED_ARRAY_SUPPORT&&(s.prototype.__proto__=Uint8Array.prototype,s.__proto__=Uint8Array,typeof Symbol<"u"&&Symbol.species&&s[Symbol.species]);function Me(t){if(typeof t!="number")throw new TypeError('"size" argument must be a number');if(t<0)throw new RangeError('"size" argument must not be negative')}function Un(t,r,e,n){return Me(r),r<=0?q(t,r):e!==void 0?typeof n=="string"?q(t,r).fill(e,n):q(t,r).fill(e):q(t,r)}s.alloc=function(t,r,e){return Un(null,t,r,e)};function Jr(t,r){if(Me(r),t=q(t,r<0?0:jr(r)|0),!s.TYPED_ARRAY_SUPPORT)for(var e=0;e<r;++e)t[e]=0;return t}s.allocUnsafe=function(t){return Jr(null,t)};s.allocUnsafeSlow=function(t){return Jr(null,t)};function Pn(t,r,e){if((typeof e!="string"||e==="")&&(e="utf8"),!s.isEncoding(e))throw new TypeError('"encoding" must be a valid string encoding');var n=ve(r,e)|0;t=q(t,n);var o=t.write(r,e);return o!==n&&(t=t.slice(0,o)),t}function Xr(t,r){var e=r.length<0?0:jr(r.length)|0;t=q(t,e);for(var n=0;n<e;n+=1)t[n]=r[n]&255;return t}function Ln(t,r,e,n){if(r.byteLength,e<0||r.byteLength<e)throw new RangeError("'offset' is out of bounds");if(r.byteLength<e+(n||0))throw new RangeError("'length' is out of bounds");return e===void 0&&n===void 0?r=new Uint8Array(r):n===void 0?r=new Uint8Array(r,e):r=new Uint8Array(r,e,n),s.TYPED_ARRAY_SUPPORT?(t=r,t.__proto__=s.prototype):t=Xr(t,r),t}function Mn(t,r){if(G(r)){var e=jr(r.length)|0;return t=q(t,e),t.length===0||r.copy(t,0,0,e),t}if(r){if(typeof ArrayBuffer<"u"&&r.buffer instanceof ArrayBuffer||"length"in r)return typeof r.length!="number"||to(r.length)?q(t,0):Xr(t,r);if(r.type==="Buffer"&&Array.isArray(r.data))return Xr(t,r.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}function jr(t){if(t>=Nr())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Nr().toString(16)+" bytes");return t|0}s.isBuffer=no;function G(t){return!!(t!=null&&t._isBuffer)}s.compare=function(r,e){if(!G(r)||!G(e))throw new TypeError("Arguments must be Buffers");if(r===e)return 0;for(var n=r.length,o=e.length,i=0,a=Math.min(n,o);i<a;++i)if(r[i]!==e[i]){n=r[i],o=e[i];break}return n<o?-1:o<n?1:0};s.isEncoding=function(r){switch(String(r).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};s.concat=function(r,e){if(!Array.isArray(r))throw new TypeError('"list" argument must be an Array of Buffers');if(r.length===0)return s.alloc(0);var n;if(e===void 0)for(e=0,n=0;n<r.length;++n)e+=r[n].length;var o=s.allocUnsafe(e),i=0;for(n=0;n<r.length;++n){var a=r[n];if(!G(a))throw new TypeError('"list" argument must be an Array of Buffers');a.copy(o,i),i+=a.length}return o};function ve(t,r){if(G(t))return t.length;if(typeof ArrayBuffer<"u"&&typeof ArrayBuffer.isView=="function"&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;typeof t!="string"&&(t=""+t);var e=t.length;if(e===0)return 0;for(var n=!1;;)switch(r){case"ascii":case"latin1":case"binary":return e;case"utf8":case"utf-8":case void 0:return Rr(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return e*2;case"hex":return e>>>1;case"base64":return Ve(t).length;default:if(n)return Rr(t).length;r=(""+r).toLowerCase(),n=!0}}s.byteLength=ve;function vn(t,r,e){var n=!1;if((r===void 0||r<0)&&(r=0),r>this.length||((e===void 0||e>this.length)&&(e=this.length),e<=0)||(e>>>=0,r>>>=0,e<=r))return"";for(t||(t="utf8");;)switch(t){case"hex":return Xn(this,r,e);case"utf8":case"utf-8":return Ge(this,r,e);case"ascii":return $n(this,r,e);case"latin1":case"binary":return zn(this,r,e);case"base64":return Hn(this,r,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return qn(this,r,e);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}s.prototype._isBuffer=!0;function ar(t,r,e){var n=t[r];t[r]=t[e],t[e]=n}s.prototype.swap16=function(){var r=this.length;if(r%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<r;e+=2)ar(this,e,e+1);return this};s.prototype.swap32=function(){var r=this.length;if(r%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<r;e+=4)ar(this,e,e+3),ar(this,e+1,e+2);return this};s.prototype.swap64=function(){var r=this.length;if(r%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<r;e+=8)ar(this,e,e+7),ar(this,e+1,e+6),ar(this,e+2,e+5),ar(this,e+3,e+4);return this};s.prototype.toString=function(){var r=this.length|0;return r===0?"":arguments.length===0?Ge(this,0,r):vn.apply(this,arguments)};s.prototype.equals=function(r){if(!G(r))throw new TypeError("Argument must be a Buffer");return this===r?!0:s.compare(this,r)===0};s.prototype.compare=function(r,e,n,o,i){if(!G(r))throw new TypeError("Argument must be a Buffer");if(e===void 0&&(e=0),n===void 0&&(n=r?r.length:0),o===void 0&&(o=0),i===void 0&&(i=this.length),e<0||n>r.length||o<0||i>this.length)throw new RangeError("out of range index");if(o>=i&&e>=n)return 0;if(o>=i)return-1;if(e>=n)return 1;if(e>>>=0,n>>>=0,o>>>=0,i>>>=0,this===r)return 0;for(var a=i-o,c=n-e,u=Math.min(a,c),p=this.slice(o,i),d=r.slice(e,n),m=0;m<u;++m)if(p[m]!==d[m]){a=p[m],c=d[m];break}return a<c?-1:c<a?1:0};function Fe(t,r,e,n,o){if(t.length===0)return-1;if(typeof e=="string"?(n=e,e=0):e>2147483647?e=2147483647:e<-2147483648&&(e=-2147483648),e=+e,isNaN(e)&&(e=o?0:t.length-1),e<0&&(e=t.length+e),e>=t.length){if(o)return-1;e=t.length-1}else if(e<0)if(o)e=0;else return-1;if(typeof r=="string"&&(r=s.from(r,n)),G(r))return r.length===0?-1:ke(t,r,e,n,o);if(typeof r=="number")return r=r&255,s.TYPED_ARRAY_SUPPORT&&typeof Uint8Array.prototype.indexOf=="function"?o?Uint8Array.prototype.indexOf.call(t,r,e):Uint8Array.prototype.lastIndexOf.call(t,r,e):ke(t,[r],e,n,o);throw new TypeError("val must be string, number or Buffer")}function ke(t,r,e,n,o){var i=1,a=t.length,c=r.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(t.length<2||r.length<2)return-1;i=2,a/=2,c/=2,e/=2}function u(x,E){return i===1?x[E]:x.readUInt16BE(E*i)}var p;if(o){var d=-1;for(p=e;p<a;p++)if(u(t,p)===u(r,d===-1?0:p-d)){if(d===-1&&(d=p),p-d+1===c)return d*i}else d!==-1&&(p-=p-d),d=-1}else for(e+c>a&&(e=a-c),p=e;p>=0;p--){for(var m=!0,h=0;h<c;h++)if(u(t,p+h)!==u(r,h)){m=!1;break}if(m)return p}return-1}s.prototype.includes=function(r,e,n){return this.indexOf(r,e,n)!==-1};s.prototype.indexOf=function(r,e,n){return Fe(this,r,e,n,!0)};s.prototype.lastIndexOf=function(r,e,n){return Fe(this,r,e,n,!1)};function Fn(t,r,e,n){e=Number(e)||0;var o=t.length-e;n?(n=Number(n),n>o&&(n=o)):n=o;var i=r.length;if(i%2!==0)throw new TypeError("Invalid hex string");n>i/2&&(n=i/2);for(var a=0;a<n;++a){var c=parseInt(r.substr(a*2,2),16);if(isNaN(c))return a;t[e+a]=c}return a}function Yn(t,r,e,n){return Dr(Rr(r,t.length-e),t,e,n)}function Ye(t,r,e,n){return Dr(ro(r),t,e,n)}function Gn(t,r,e,n){return Ye(t,r,e,n)}function Wn(t,r,e,n){return Dr(Ve(r),t,e,n)}function Kn(t,r,e,n){return Dr(eo(r,t.length-e),t,e,n)}s.prototype.write=function(r,e,n,o){if(e===void 0)o="utf8",n=this.length,e=0;else if(n===void 0&&typeof e=="string")o=e,n=this.length,e=0;else if(isFinite(e))e=e|0,isFinite(n)?(n=n|0,o===void 0&&(o="utf8")):(o=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var i=this.length-e;if((n===void 0||n>i)&&(n=i),r.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");o||(o="utf8");for(var a=!1;;)switch(o){case"hex":return Fn(this,r,e,n);case"utf8":case"utf-8":return Yn(this,r,e,n);case"ascii":return Ye(this,r,e,n);case"latin1":case"binary":return Gn(this,r,e,n);case"base64":return Wn(this,r,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Kn(this,r,e,n);default:if(a)throw new TypeError("Unknown encoding: "+o);o=(""+o).toLowerCase(),a=!0}};s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Hn(t,r,e){return r===0&&e===t.length?Oe(t):Oe(t.slice(r,e))}function Ge(t,r,e){e=Math.min(t.length,e);for(var n=[],o=r;o<e;){var i=t[o],a=null,c=i>239?4:i>223?3:i>191?2:1;if(o+c<=e){var u,p,d,m;switch(c){case 1:i<128&&(a=i);break;case 2:u=t[o+1],(u&192)===128&&(m=(i&31)<<6|u&63,m>127&&(a=m));break;case 3:u=t[o+1],p=t[o+2],(u&192)===128&&(p&192)===128&&(m=(i&15)<<12|(u&63)<<6|p&63,m>2047&&(m<55296||m>57343)&&(a=m));break;case 4:u=t[o+1],p=t[o+2],d=t[o+3],(u&192)===128&&(p&192)===128&&(d&192)===128&&(m=(i&15)<<18|(u&63)<<12|(p&63)<<6|d&63,m>65535&&m<1114112&&(a=m))}}a===null?(a=65533,c=1):a>65535&&(a-=65536,n.push(a>>>10&1023|55296),a=56320|a&1023),n.push(a),o+=c}return Vn(n)}var Ue=4096;function Vn(t){var r=t.length;if(r<=Ue)return String.fromCharCode.apply(String,t);for(var e="",n=0;n<r;)e+=String.fromCharCode.apply(String,t.slice(n,n+=Ue));return e}function $n(t,r,e){var n="";e=Math.min(t.length,e);for(var o=r;o<e;++o)n+=String.fromCharCode(t[o]&127);return n}function zn(t,r,e){var n="";e=Math.min(t.length,e);for(var o=r;o<e;++o)n+=String.fromCharCode(t[o]);return n}function Xn(t,r,e){var n=t.length;(!r||r<0)&&(r=0),(!e||e<0||e>n)&&(e=n);for(var o="",i=r;i<e;++i)o+=Zn(t[i]);return o}function qn(t,r,e){for(var n=t.slice(r,e),o="",i=0;i<n.length;i+=2)o+=String.fromCharCode(n[i]+n[i+1]*256);return o}s.prototype.slice=function(r,e){var n=this.length;r=~~r,e=e===void 0?n:~~e,r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),e<r&&(e=r);var o;if(s.TYPED_ARRAY_SUPPORT)o=this.subarray(r,e),o.__proto__=s.prototype;else{var i=e-r;o=new s(i,void 0);for(var a=0;a<i;++a)o[a]=this[a+r]}return o};function _(t,r,e){if(t%1!==0||t<0)throw new RangeError("offset is not uint");if(t+r>e)throw new RangeError("Trying to access beyond buffer length")}s.prototype.readUIntLE=function(r,e,n){r=r|0,e=e|0,n||_(r,e,this.length);for(var o=this[r],i=1,a=0;++a<e&&(i*=256);)o+=this[r+a]*i;return o};s.prototype.readUIntBE=function(r,e,n){r=r|0,e=e|0,n||_(r,e,this.length);for(var o=this[r+--e],i=1;e>0&&(i*=256);)o+=this[r+--e]*i;return o};s.prototype.readUInt8=function(r,e){return e||_(r,1,this.length),this[r]};s.prototype.readUInt16LE=function(r,e){return e||_(r,2,this.length),this[r]|this[r+1]<<8};s.prototype.readUInt16BE=function(r,e){return e||_(r,2,this.length),this[r]<<8|this[r+1]};s.prototype.readUInt32LE=function(r,e){return e||_(r,4,this.length),(this[r]|this[r+1]<<8|this[r+2]<<16)+this[r+3]*16777216};s.prototype.readUInt32BE=function(r,e){return e||_(r,4,this.length),this[r]*16777216+(this[r+1]<<16|this[r+2]<<8|this[r+3])};s.prototype.readIntLE=function(r,e,n){r=r|0,e=e|0,n||_(r,e,this.length);for(var o=this[r],i=1,a=0;++a<e&&(i*=256);)o+=this[r+a]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*e)),o};s.prototype.readIntBE=function(r,e,n){r=r|0,e=e|0,n||_(r,e,this.length);for(var o=e,i=1,a=this[r+--o];o>0&&(i*=256);)a+=this[r+--o]*i;return i*=128,a>=i&&(a-=Math.pow(2,8*e)),a};s.prototype.readInt8=function(r,e){return e||_(r,1,this.length),this[r]&128?(255-this[r]+1)*-1:this[r]};s.prototype.readInt16LE=function(r,e){e||_(r,2,this.length);var n=this[r]|this[r+1]<<8;return n&32768?n|4294901760:n};s.prototype.readInt16BE=function(r,e){e||_(r,2,this.length);var n=this[r+1]|this[r]<<8;return n&32768?n|4294901760:n};s.prototype.readInt32LE=function(r,e){return e||_(r,4,this.length),this[r]|this[r+1]<<8|this[r+2]<<16|this[r+3]<<24};s.prototype.readInt32BE=function(r,e){return e||_(r,4,this.length),this[r]<<24|this[r+1]<<16|this[r+2]<<8|this[r+3]};s.prototype.readFloatLE=function(r,e){return e||_(r,4,this.length),Cr(this,r,!0,23,4)};s.prototype.readFloatBE=function(r,e){return e||_(r,4,this.length),Cr(this,r,!1,23,4)};s.prototype.readDoubleLE=function(r,e){return e||_(r,8,this.length),Cr(this,r,!0,52,8)};s.prototype.readDoubleBE=function(r,e){return e||_(r,8,this.length),Cr(this,r,!1,52,8)};function B(t,r,e,n,o,i){if(!G(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(r>o||r<i)throw new RangeError('"value" argument is out of bounds');if(e+n>t.length)throw new RangeError("Index out of range")}s.prototype.writeUIntLE=function(r,e,n,o){if(r=+r,e=e|0,n=n|0,!o){var i=Math.pow(2,8*n)-1;B(this,r,e,n,i,0)}var a=1,c=0;for(this[e]=r&255;++c<n&&(a*=256);)this[e+c]=r/a&255;return e+n};s.prototype.writeUIntBE=function(r,e,n,o){if(r=+r,e=e|0,n=n|0,!o){var i=Math.pow(2,8*n)-1;B(this,r,e,n,i,0)}var a=n-1,c=1;for(this[e+a]=r&255;--a>=0&&(c*=256);)this[e+a]=r/c&255;return e+n};s.prototype.writeUInt8=function(r,e,n){return r=+r,e=e|0,n||B(this,r,e,1,255,0),s.TYPED_ARRAY_SUPPORT||(r=Math.floor(r)),this[e]=r&255,e+1};function Sr(t,r,e,n){r<0&&(r=65535+r+1);for(var o=0,i=Math.min(t.length-e,2);o<i;++o)t[e+o]=(r&255<<8*(n?o:1-o))>>>(n?o:1-o)*8}s.prototype.writeUInt16LE=function(r,e,n){return r=+r,e=e|0,n||B(this,r,e,2,65535,0),s.TYPED_ARRAY_SUPPORT?(this[e]=r&255,this[e+1]=r>>>8):Sr(this,r,e,!0),e+2};s.prototype.writeUInt16BE=function(r,e,n){return r=+r,e=e|0,n||B(this,r,e,2,65535,0),s.TYPED_ARRAY_SUPPORT?(this[e]=r>>>8,this[e+1]=r&255):Sr(this,r,e,!1),e+2};function Br(t,r,e,n){r<0&&(r=4294967295+r+1);for(var o=0,i=Math.min(t.length-e,4);o<i;++o)t[e+o]=r>>>(n?o:3-o)*8&255}s.prototype.writeUInt32LE=function(r,e,n){return r=+r,e=e|0,n||B(this,r,e,4,4294967295,0),s.TYPED_ARRAY_SUPPORT?(this[e+3]=r>>>24,this[e+2]=r>>>16,this[e+1]=r>>>8,this[e]=r&255):Br(this,r,e,!0),e+4};s.prototype.writeUInt32BE=function(r,e,n){return r=+r,e=e|0,n||B(this,r,e,4,4294967295,0),s.TYPED_ARRAY_SUPPORT?(this[e]=r>>>24,this[e+1]=r>>>16,this[e+2]=r>>>8,this[e+3]=r&255):Br(this,r,e,!1),e+4};s.prototype.writeIntLE=function(r,e,n,o){if(r=+r,e=e|0,!o){var i=Math.pow(2,8*n-1);B(this,r,e,n,i-1,-i)}var a=0,c=1,u=0;for(this[e]=r&255;++a<n&&(c*=256);)r<0&&u===0&&this[e+a-1]!==0&&(u=1),this[e+a]=(r/c>>0)-u&255;return e+n};s.prototype.writeIntBE=function(r,e,n,o){if(r=+r,e=e|0,!o){var i=Math.pow(2,8*n-1);B(this,r,e,n,i-1,-i)}var a=n-1,c=1,u=0;for(this[e+a]=r&255;--a>=0&&(c*=256);)r<0&&u===0&&this[e+a+1]!==0&&(u=1),this[e+a]=(r/c>>0)-u&255;return e+n};s.prototype.writeInt8=function(r,e,n){return r=+r,e=e|0,n||B(this,r,e,1,127,-128),s.TYPED_ARRAY_SUPPORT||(r=Math.floor(r)),r<0&&(r=255+r+1),this[e]=r&255,e+1};s.prototype.writeInt16LE=function(r,e,n){return r=+r,e=e|0,n||B(this,r,e,2,32767,-32768),s.TYPED_ARRAY_SUPPORT?(this[e]=r&255,this[e+1]=r>>>8):Sr(this,r,e,!0),e+2};s.prototype.writeInt16BE=function(r,e,n){return r=+r,e=e|0,n||B(this,r,e,2,32767,-32768),s.TYPED_ARRAY_SUPPORT?(this[e]=r>>>8,this[e+1]=r&255):Sr(this,r,e,!1),e+2};s.prototype.writeInt32LE=function(r,e,n){return r=+r,e=e|0,n||B(this,r,e,4,2147483647,-2147483648),s.TYPED_ARRAY_SUPPORT?(this[e]=r&255,this[e+1]=r>>>8,this[e+2]=r>>>16,this[e+3]=r>>>24):Br(this,r,e,!0),e+4};s.prototype.writeInt32BE=function(r,e,n){return r=+r,e=e|0,n||B(this,r,e,4,2147483647,-2147483648),r<0&&(r=4294967295+r+1),s.TYPED_ARRAY_SUPPORT?(this[e]=r>>>24,this[e+1]=r>>>16,this[e+2]=r>>>8,this[e+3]=r&255):Br(this,r,e,!1),e+4};function We(t,r,e,n,o,i){if(e+n>t.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function Ke(t,r,e,n,o){return o||We(t,r,e,4,34028234663852886e22,-34028234663852886e22),ze(t,r,e,n,23,4),e+4}s.prototype.writeFloatLE=function(r,e,n){return Ke(this,r,e,!0,n)};s.prototype.writeFloatBE=function(r,e,n){return Ke(this,r,e,!1,n)};function He(t,r,e,n,o){return o||We(t,r,e,8,17976931348623157e292,-17976931348623157e292),ze(t,r,e,n,52,8),e+8}s.prototype.writeDoubleLE=function(r,e,n){return He(this,r,e,!0,n)};s.prototype.writeDoubleBE=function(r,e,n){return He(this,r,e,!1,n)};s.prototype.copy=function(r,e,n,o){if(n||(n=0),!o&&o!==0&&(o=this.length),e>=r.length&&(e=r.length),e||(e=0),o>0&&o<n&&(o=n),o===n||r.length===0||this.length===0)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("sourceStart out of bounds");if(o<0)throw new RangeError("sourceEnd out of bounds");o>this.length&&(o=this.length),r.length-e<o-n&&(o=r.length-e+n);var i=o-n,a;if(this===r&&n<e&&e<o)for(a=i-1;a>=0;--a)r[a+e]=this[a+n];else if(i<1e3||!s.TYPED_ARRAY_SUPPORT)for(a=0;a<i;++a)r[a+e]=this[a+n];else Uint8Array.prototype.set.call(r,this.subarray(n,n+i),e);return i};s.prototype.fill=function(r,e,n,o){if(typeof r=="string"){if(typeof e=="string"?(o=e,e=0,n=this.length):typeof n=="string"&&(o=n,n=this.length),r.length===1){var i=r.charCodeAt(0);i<256&&(r=i)}if(o!==void 0&&typeof o!="string")throw new TypeError("encoding must be a string");if(typeof o=="string"&&!s.isEncoding(o))throw new TypeError("Unknown encoding: "+o)}else typeof r=="number"&&(r=r&255);if(e<0||this.length<e||this.length<n)throw new RangeError("Out of range index");if(n<=e)return this;e=e>>>0,n=n===void 0?this.length:n>>>0,r||(r=0);var a;if(typeof r=="number")for(a=e;a<n;++a)this[a]=r;else{var c=G(r)?r:Rr(new s(r,o).toString()),u=c.length;for(a=0;a<n-e;++a)this[a+e]=c[a%u]}return this};var Jn=/[^+\/0-9A-Za-z-_]/g;function jn(t){if(t=Qn(t).replace(Jn,""),t.length<2)return"";for(;t.length%4!==0;)t=t+"=";return t}function Qn(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function Zn(t){return t<16?"0"+t.toString(16):t.toString(16)}function Rr(t,r){r=r||1/0;for(var e,n=t.length,o=null,i=[],a=0;a<n;++a){if(e=t.charCodeAt(a),e>55295&&e<57344){if(!o){if(e>56319){(r-=3)>-1&&i.push(239,191,189);continue}else if(a+1===n){(r-=3)>-1&&i.push(239,191,189);continue}o=e;continue}if(e<56320){(r-=3)>-1&&i.push(239,191,189),o=e;continue}e=(o-55296<<10|e-56320)+65536}else o&&(r-=3)>-1&&i.push(239,191,189);if(o=null,e<128){if((r-=1)<0)break;i.push(e)}else if(e<2048){if((r-=2)<0)break;i.push(e>>6|192,e&63|128)}else if(e<65536){if((r-=3)<0)break;i.push(e>>12|224,e>>6&63|128,e&63|128)}else if(e<1114112){if((r-=4)<0)break;i.push(e>>18|240,e>>12&63|128,e>>6&63|128,e&63|128)}else throw new Error("Invalid code point")}return i}function ro(t){for(var r=[],e=0;e<t.length;++e)r.push(t.charCodeAt(e)&255);return r}function eo(t,r){for(var e,n,o,i=[],a=0;a<t.length&&!((r-=2)<0);++a)e=t.charCodeAt(a),n=e>>8,o=e%256,i.push(o),i.push(n);return i}function Ve(t){return Cn(jn(t))}function Dr(t,r,e,n){for(var o=0;o<n&&!(o+e>=r.length||o>=t.length);++o)r[o+e]=t[o];return o}function to(t){return t!==t}function no(t){return t!=null&&(!!t._isBuffer||$e(t)||oo(t))}function $e(t){return!!t.constructor&&typeof t.constructor.isBuffer=="function"&&t.constructor.isBuffer(t)}function oo(t){return typeof t.readFloatLE=="function"&&typeof t.slice=="function"&&$e(t.slice(0,0))}function Cr(t,r,e,n,o){var i,a,c=o*8-n-1,u=(1<<c)-1,p=u>>1,d=-7,m=e?o-1:0,h=e?-1:1,x=t[r+m];for(m+=h,i=x&(1<<-d)-1,x>>=-d,d+=c;d>0;i=i*256+t[r+m],m+=h,d-=8);for(a=i&(1<<-d)-1,i>>=-d,d+=n;d>0;a=a*256+t[r+m],m+=h,d-=8);if(i===0)i=1-p;else{if(i===u)return a?NaN:(x?-1:1)*(1/0);a=a+Math.pow(2,n),i=i-p}return(x?-1:1)*a*Math.pow(2,i-n)}function ze(t,r,e,n,o,i){var a,c,u,p=i*8-o-1,d=(1<<p)-1,m=d>>1,h=o===23?Math.pow(2,-24)-Math.pow(2,-77):0,x=n?0:i-1,E=n?1:-1,y=r<0||r===0&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(c=isNaN(r)?1:0,a=d):(a=Math.floor(Math.log(r)/Math.LN2),r*(u=Math.pow(2,-a))<1&&(a--,u*=2),a+m>=1?r+=h/u:r+=h*Math.pow(2,1-m),r*u>=2&&(a++,u/=2),a+m>=d?(c=0,a=d):a+m>=1?(c=(r*u-1)*Math.pow(2,o),a=a+m):(c=r*Math.pow(2,m-1)*Math.pow(2,o),a=0));o>=8;t[e+x]=c&255,x+=E,c/=256,o-=8);for(a=a<<o|c,p+=o;p>0;t[e+x]=a&255,x+=E,a/=256,p-=8);t[e+x-E]|=y*128}import b from"algosdk";import*as Kr from"bs58";import Qr from"bignumber.js";Qr.config({DECIMAL_PLACES:40,EXPONENTIAL_AT:45});function sr(t,r){return io(t,r,"/")}function io(t,r,e){switch(t=new Qr(String(t)),r=new Qr(String(r)),e.toLowerCase()){case"-":return t.minus(r).toString();case"+":return t.plus(r).toString();case"*":case"x":return t.multipliedBy(r).toString();case"\xF7":case"/":return t.dividedBy(r).toString();case">=":return t.isGreaterThanOrEqualTo(r);case">":return t.isGreaterThan(r);case"<=":return t.isLessThanOrEqualTo(r);case"<":return t.isLessThan(r);case"==":return t.isEqualTo(r);case"mod":return t.modulo(r);default:break}}var Xe=t=>{let r=new Date(t),e=r.toLocaleDateString("default",{year:"numeric",month:"numeric",day:"numeric"}),n=r.toLocaleTimeString("en-US",{hour12:!0,hour:"2-digit",minute:"2-digit"});return e+" "+n};import $o from"algosdk";import*as ae from"bs58";import xt from"algosdk";import Ri,{decodeAddress as Si,encodeAddress as Bi}from"algosdk";var W=[],U=[],ao=typeof Uint8Array<"u"?Uint8Array:Array,re=!1;function Qe(){re=!0;for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r=0,e=t.length;r<e;++r)W[r]=t[r],U[t.charCodeAt(r)]=r;U[45]=62,U[95]=63}function so(t){re||Qe();var r,e,n,o,i,a,c=t.length;if(c%4>0)throw new Error("Invalid string. Length must be a multiple of 4");i=t[c-2]==="="?2:t[c-1]==="="?1:0,a=new ao(c*3/4-i),n=i>0?c-4:c;var u=0;for(r=0,e=0;r<n;r+=4,e+=3)o=U[t.charCodeAt(r)]<<18|U[t.charCodeAt(r+1)]<<12|U[t.charCodeAt(r+2)]<<6|U[t.charCodeAt(r+3)],a[u++]=o>>16&255,a[u++]=o>>8&255,a[u++]=o&255;return i===2?(o=U[t.charCodeAt(r)]<<2|U[t.charCodeAt(r+1)]>>4,a[u++]=o&255):i===1&&(o=U[t.charCodeAt(r)]<<10|U[t.charCodeAt(r+1)]<<4|U[t.charCodeAt(r+2)]>>2,a[u++]=o>>8&255,a[u++]=o&255),a}function co(t){return W[t>>18&63]+W[t>>12&63]+W[t>>6&63]+W[t&63]}function uo(t,r,e){for(var n,o=[],i=r;i<e;i+=3)n=(t[i]<<16)+(t[i+1]<<8)+t[i+2],o.push(co(n));return o.join("")}function qe(t){re||Qe();for(var r,e=t.length,n=e%3,o="",i=[],a=16383,c=0,u=e-n;c<u;c+=a)i.push(uo(t,c,c+a>u?u:c+a));return n===1?(r=t[e-1],o+=W[r>>2],o+=W[r<<4&63],o+="=="):n===2&&(r=(t[e-2]<<8)+t[e-1],o+=W[r>>10],o+=W[r>>4&63],o+=W[r<<2&63],o+="="),i.push(o),i.join("")}function Ur(t,r,e,n,o){var i,a,c=o*8-n-1,u=(1<<c)-1,p=u>>1,d=-7,m=e?o-1:0,h=e?-1:1,x=t[r+m];for(m+=h,i=x&(1<<-d)-1,x>>=-d,d+=c;d>0;i=i*256+t[r+m],m+=h,d-=8);for(a=i&(1<<-d)-1,i>>=-d,d+=n;d>0;a=a*256+t[r+m],m+=h,d-=8);if(i===0)i=1-p;else{if(i===u)return a?NaN:(x?-1:1)*(1/0);a=a+Math.pow(2,n),i=i-p}return(x?-1:1)*a*Math.pow(2,i-n)}function Ze(t,r,e,n,o,i){var a,c,u,p=i*8-o-1,d=(1<<p)-1,m=d>>1,h=o===23?Math.pow(2,-24)-Math.pow(2,-77):0,x=n?0:i-1,E=n?1:-1,y=r<0||r===0&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(c=isNaN(r)?1:0,a=d):(a=Math.floor(Math.log(r)/Math.LN2),r*(u=Math.pow(2,-a))<1&&(a--,u*=2),a+m>=1?r+=h/u:r+=h*Math.pow(2,1-m),r*u>=2&&(a++,u/=2),a+m>=d?(c=0,a=d):a+m>=1?(c=(r*u-1)*Math.pow(2,o),a=a+m):(c=r*Math.pow(2,m-1)*Math.pow(2,o),a=0));o>=8;t[e+x]=c&255,x+=E,c/=256,o-=8);for(a=a<<o|c,p+=o;p>0;t[e+x]=a&255,x+=E,a/=256,p-=8);t[e+x-E]|=y*128}var po={}.toString,rt=Array.isArray||function(t){return po.call(t)=="[object Array]"};var lo=50;l.TYPED_ARRAY_SUPPORT=globalThis.TYPED_ARRAY_SUPPORT!==void 0?globalThis.TYPED_ARRAY_SUPPORT:!0;var yi=Or();function Or(){return l.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function J(t,r){if(Or()<r)throw new RangeError("Invalid typed array length");return l.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(r),t.__proto__=l.prototype):(t===null&&(t=new l(r)),t.length=r),t}function l(t,r,e){if(!l.TYPED_ARRAY_SUPPORT&&!(this instanceof l))return new l(t,r,e);if(typeof t=="number"){if(typeof r=="string")throw new Error("If encoding is specified then the first argument must be a string");return ee(this,t)}return et(this,t,r,e)}l.poolSize=8192;l._augment=function(t){return t.__proto__=l.prototype,t};function et(t,r,e,n){if(typeof r=="number")throw new TypeError('"value" argument must not be a number');return typeof ArrayBuffer<"u"&&r instanceof ArrayBuffer?go(t,r,e,n):typeof r=="string"?fo(t,r,e):ho(t,r)}l.from=function(t,r,e){return et(null,t,r,e)};l.TYPED_ARRAY_SUPPORT&&(l.prototype.__proto__=Uint8Array.prototype,l.__proto__=Uint8Array);function tt(t){if(typeof t!="number")throw new TypeError('"size" argument must be a number');if(t<0)throw new RangeError('"size" argument must not be negative')}function mo(t,r,e,n){return tt(r),r<=0?J(t,r):e!==void 0?typeof n=="string"?J(t,r).fill(e,n):J(t,r).fill(e):J(t,r)}l.alloc=function(t,r,e){return mo(null,t,r,e)};function ee(t,r){if(tt(r),t=J(t,r<0?0:te(r)|0),!l.TYPED_ARRAY_SUPPORT)for(var e=0;e<r;++e)t[e]=0;return t}l.allocUnsafe=function(t){return ee(null,t)};l.allocUnsafeSlow=function(t){return ee(null,t)};function fo(t,r,e){if((typeof e!="string"||e==="")&&(e="utf8"),!l.isEncoding(e))throw new TypeError('"encoding" must be a valid string encoding');var n=nt(r,e)|0;t=J(t,n);var o=t.write(r,e);return o!==n&&(t=t.slice(0,o)),t}function Zr(t,r){var e=r.length<0?0:te(r.length)|0;t=J(t,e);for(var n=0;n<e;n+=1)t[n]=r[n]&255;return t}function go(t,r,e,n){if(r.byteLength,e<0||r.byteLength<e)throw new RangeError("'offset' is out of bounds");if(r.byteLength<e+(n||0))throw new RangeError("'length' is out of bounds");return e===void 0&&n===void 0?r=new Uint8Array(r):n===void 0?r=new Uint8Array(r,e):r=new Uint8Array(r,e,n),l.TYPED_ARRAY_SUPPORT?(t=r,t.__proto__=l.prototype):t=Zr(t,r),t}function ho(t,r){if(K(r)){var e=te(r.length)|0;return t=J(t,e),t.length===0||r.copy(t,0,0,e),t}if(r){if(typeof ArrayBuffer<"u"&&r.buffer instanceof ArrayBuffer||"length"in r)return typeof r.length!="number"||Po(r.length)?J(t,0):Zr(t,r);if(r.type==="Buffer"&&rt(r.data))return Zr(t,r.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}function te(t){if(t>=Or())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Or().toString(16)+" bytes");return t|0}l.isBuffer=Lo;function K(t){return!!(t!=null&&t._isBuffer)}l.compare=function(r,e){if(!K(r)||!K(e))throw new TypeError("Arguments must be Buffers");if(r===e)return 0;for(var n=r.length,o=e.length,i=0,a=Math.min(n,o);i<a;++i)if(r[i]!==e[i]){n=r[i],o=e[i];break}return n<o?-1:o<n?1:0};l.isEncoding=function(r){switch(String(r).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};l.concat=function(r,e){if(!rt(r))throw new TypeError('"list" argument must be an Array of Buffers');if(r.length===0)return l.alloc(0);var n;if(e===void 0)for(e=0,n=0;n<r.length;++n)e+=r[n].length;var o=l.allocUnsafe(e),i=0;for(n=0;n<r.length;++n){var a=r[n];if(!K(a))throw new TypeError('"list" argument must be an Array of Buffers');a.copy(o,i),i+=a.length}return o};function nt(t,r){if(K(t))return t.length;if(typeof ArrayBuffer<"u"&&typeof ArrayBuffer.isView=="function"&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;typeof t!="string"&&(t=""+t);var e=t.length;if(e===0)return 0;for(var n=!1;;)switch(r){case"ascii":case"latin1":case"binary":return e;case"utf8":case"utf-8":case void 0:return kr(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return e*2;case"hex":return e>>>1;case"base64":return pt(t).length;default:if(n)return kr(t).length;r=(""+r).toLowerCase(),n=!0}}l.byteLength=nt;function xo(t,r,e){var n=!1;if((r===void 0||r<0)&&(r=0),r>this.length||((e===void 0||e>this.length)&&(e=this.length),e<=0)||(e>>>=0,r>>>=0,e<=r))return"";for(t||(t="utf8");;)switch(t){case"hex":return Ro(this,r,e);case"utf8":case"utf-8":return at(this,r,e);case"ascii":return wo(this,r,e);case"latin1":case"binary":return No(this,r,e);case"base64":return _o(this,r,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return So(this,r,e);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}l.prototype._isBuffer=!0;function cr(t,r,e){var n=t[r];t[r]=t[e],t[e]=n}l.prototype.swap16=function(){var r=this.length;if(r%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<r;e+=2)cr(this,e,e+1);return this};l.prototype.swap32=function(){var r=this.length;if(r%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<r;e+=4)cr(this,e,e+3),cr(this,e+1,e+2);return this};l.prototype.swap64=function(){var r=this.length;if(r%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<r;e+=8)cr(this,e,e+7),cr(this,e+1,e+6),cr(this,e+2,e+5),cr(this,e+3,e+4);return this};l.prototype.toString=function(){var r=this.length|0;return r===0?"":arguments.length===0?at(this,0,r):xo.apply(this,arguments)};l.prototype.equals=function(r){if(!K(r))throw new TypeError("Argument must be a Buffer");return this===r?!0:l.compare(this,r)===0};l.prototype.inspect=function(){var r="",e=lo;return this.length>0&&(r=this.toString("hex",0,e).match(/.{2}/g).join(" "),this.length>e&&(r+=" ... ")),"<Buffer "+r+">"};l.prototype.compare=function(r,e,n,o,i){if(!K(r))throw new TypeError("Argument must be a Buffer");if(e===void 0&&(e=0),n===void 0&&(n=r?r.length:0),o===void 0&&(o=0),i===void 0&&(i=this.length),e<0||n>r.length||o<0||i>this.length)throw new RangeError("out of range index");if(o>=i&&e>=n)return 0;if(o>=i)return-1;if(e>=n)return 1;if(e>>>=0,n>>>=0,o>>>=0,i>>>=0,this===r)return 0;for(var a=i-o,c=n-e,u=Math.min(a,c),p=this.slice(o,i),d=r.slice(e,n),m=0;m<u;++m)if(p[m]!==d[m]){a=p[m],c=d[m];break}return a<c?-1:c<a?1:0};function ot(t,r,e,n,o){if(t.length===0)return-1;if(typeof e=="string"?(n=e,e=0):e>2147483647?e=2147483647:e<-2147483648&&(e=-2147483648),e=+e,isNaN(e)&&(e=o?0:t.length-1),e<0&&(e=t.length+e),e>=t.length){if(o)return-1;e=t.length-1}else if(e<0)if(o)e=0;else return-1;if(typeof r=="string"&&(r=l.from(r,n)),K(r))return r.length===0?-1:Je(t,r,e,n,o);if(typeof r=="number")return r=r&255,l.TYPED_ARRAY_SUPPORT&&typeof Uint8Array.prototype.indexOf=="function"?o?Uint8Array.prototype.indexOf.call(t,r,e):Uint8Array.prototype.lastIndexOf.call(t,r,e):Je(t,[r],e,n,o);throw new TypeError("val must be string, number or Buffer")}function Je(t,r,e,n,o){var i=1,a=t.length,c=r.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(t.length<2||r.length<2)return-1;i=2,a/=2,c/=2,e/=2}function u(x,E){return i===1?x[E]:x.readUInt16BE(E*i)}var p;if(o){var d=-1;for(p=e;p<a;p++)if(u(t,p)===u(r,d===-1?0:p-d)){if(d===-1&&(d=p),p-d+1===c)return d*i}else d!==-1&&(p-=p-d),d=-1}else for(e+c>a&&(e=a-c),p=e;p>=0;p--){for(var m=!0,h=0;h<c;h++)if(u(t,p+h)!==u(r,h)){m=!1;break}if(m)return p}return-1}l.prototype.includes=function(r,e,n){return this.indexOf(r,e,n)!==-1};l.prototype.indexOf=function(r,e,n){return ot(this,r,e,n,!0)};l.prototype.lastIndexOf=function(r,e,n){return ot(this,r,e,n,!1)};function bo(t,r,e,n){e=Number(e)||0;var o=t.length-e;n?(n=Number(n),n>o&&(n=o)):n=o;var i=r.length;if(i%2!==0)throw new TypeError("Invalid hex string");n>i/2&&(n=i/2);for(var a=0;a<n;++a){var c=parseInt(r.substr(a*2,2),16);if(isNaN(c))return a;t[e+a]=c}return a}function Eo(t,r,e,n){return Mr(kr(r,t.length-e),t,e,n)}function it(t,r,e,n){return Mr(ko(r),t,e,n)}function Ao(t,r,e,n){return it(t,r,e,n)}function To(t,r,e,n){return Mr(pt(r),t,e,n)}function yo(t,r,e,n){return Mr(Uo(r,t.length-e),t,e,n)}l.prototype.write=function(r,e,n,o){if(e===void 0)o="utf8",n=this.length,e=0;else if(n===void 0&&typeof e=="string")o=e,n=this.length,e=0;else if(isFinite(e))e=e|0,isFinite(n)?(n=n|0,o===void 0&&(o="utf8")):(o=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var i=this.length-e;if((n===void 0||n>i)&&(n=i),r.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");o||(o="utf8");for(var a=!1;;)switch(o){case"hex":return bo(this,r,e,n);case"utf8":case"utf-8":return Eo(this,r,e,n);case"ascii":return it(this,r,e,n);case"latin1":case"binary":return Ao(this,r,e,n);case"base64":return To(this,r,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return yo(this,r,e,n);default:if(a)throw new TypeError("Unknown encoding: "+o);o=(""+o).toLowerCase(),a=!0}};l.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function _o(t,r,e){return r===0&&e===t.length?qe(t):qe(t.slice(r,e))}function at(t,r,e){e=Math.min(t.length,e);for(var n=[],o=r;o<e;){var i=t[o],a=null,c=i>239?4:i>223?3:i>191?2:1;if(o+c<=e){var u,p,d,m;switch(c){case 1:i<128&&(a=i);break;case 2:u=t[o+1],(u&192)===128&&(m=(i&31)<<6|u&63,m>127&&(a=m));break;case 3:u=t[o+1],p=t[o+2],(u&192)===128&&(p&192)===128&&(m=(i&15)<<12|(u&63)<<6|p&63,m>2047&&(m<55296||m>57343)&&(a=m));break;case 4:u=t[o+1],p=t[o+2],d=t[o+3],(u&192)===128&&(p&192)===128&&(d&192)===128&&(m=(i&15)<<18|(u&63)<<12|(p&63)<<6|d&63,m>65535&&m<1114112&&(a=m))}}a===null?(a=65533,c=1):a>65535&&(a-=65536,n.push(a>>>10&1023|55296),a=56320|a&1023),n.push(a),o+=c}return Io(n)}var je=4096;function Io(t){var r=t.length;if(r<=je)return String.fromCharCode.apply(String,t);for(var e="",n=0;n<r;)e+=String.fromCharCode.apply(String,t.slice(n,n+=je));return e}function wo(t,r,e){var n="";e=Math.min(t.length,e);for(var o=r;o<e;++o)n+=String.fromCharCode(t[o]&127);return n}function No(t,r,e){var n="";e=Math.min(t.length,e);for(var o=r;o<e;++o)n+=String.fromCharCode(t[o]);return n}function Ro(t,r,e){var n=t.length;(!r||r<0)&&(r=0),(!e||e<0||e>n)&&(e=n);for(var o="",i=r;i<e;++i)o+=Oo(t[i]);return o}function So(t,r,e){for(var n=t.slice(r,e),o="",i=0;i<n.length;i+=2)o+=String.fromCharCode(n[i]+n[i+1]*256);return o}l.prototype.slice=function(r,e){var n=this.length;r=~~r,e=e===void 0?n:~~e,r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),e<r&&(e=r);var o;if(l.TYPED_ARRAY_SUPPORT)o=this.subarray(r,e),o.__proto__=l.prototype;else{var i=e-r;o=new l(i,void 0);for(var a=0;a<i;++a)o[a]=this[a+r]}return o};function I(t,r,e){if(t%1!==0||t<0)throw new RangeError("offset is not uint");if(t+r>e)throw new RangeError("Trying to access beyond buffer length")}l.prototype.readUIntLE=function(r,e,n){r=r|0,e=e|0,n||I(r,e,this.length);for(var o=this[r],i=1,a=0;++a<e&&(i*=256);)o+=this[r+a]*i;return o};l.prototype.readUIntBE=function(r,e,n){r=r|0,e=e|0,n||I(r,e,this.length);for(var o=this[r+--e],i=1;e>0&&(i*=256);)o+=this[r+--e]*i;return o};l.prototype.readUInt8=function(r,e){return e||I(r,1,this.length),this[r]};l.prototype.readUInt16LE=function(r,e){return e||I(r,2,this.length),this[r]|this[r+1]<<8};l.prototype.readUInt16BE=function(r,e){return e||I(r,2,this.length),this[r]<<8|this[r+1]};l.prototype.readUInt32LE=function(r,e){return e||I(r,4,this.length),(this[r]|this[r+1]<<8|this[r+2]<<16)+this[r+3]*16777216};l.prototype.readUInt32BE=function(r,e){return e||I(r,4,this.length),this[r]*16777216+(this[r+1]<<16|this[r+2]<<8|this[r+3])};l.prototype.readIntLE=function(r,e,n){r=r|0,e=e|0,n||I(r,e,this.length);for(var o=this[r],i=1,a=0;++a<e&&(i*=256);)o+=this[r+a]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*e)),o};l.prototype.readIntBE=function(r,e,n){r=r|0,e=e|0,n||I(r,e,this.length);for(var o=e,i=1,a=this[r+--o];o>0&&(i*=256);)a+=this[r+--o]*i;return i*=128,a>=i&&(a-=Math.pow(2,8*e)),a};l.prototype.readInt8=function(r,e){return e||I(r,1,this.length),this[r]&128?(255-this[r]+1)*-1:this[r]};l.prototype.readInt16LE=function(r,e){e||I(r,2,this.length);var n=this[r]|this[r+1]<<8;return n&32768?n|4294901760:n};l.prototype.readInt16BE=function(r,e){e||I(r,2,this.length);var n=this[r+1]|this[r]<<8;return n&32768?n|4294901760:n};l.prototype.readInt32LE=function(r,e){return e||I(r,4,this.length),this[r]|this[r+1]<<8|this[r+2]<<16|this[r+3]<<24};l.prototype.readInt32BE=function(r,e){return e||I(r,4,this.length),this[r]<<24|this[r+1]<<16|this[r+2]<<8|this[r+3]};l.prototype.readFloatLE=function(r,e){return e||I(r,4,this.length),Ur(this,r,!0,23,4)};l.prototype.readFloatBE=function(r,e){return e||I(r,4,this.length),Ur(this,r,!1,23,4)};l.prototype.readDoubleLE=function(r,e){return e||I(r,8,this.length),Ur(this,r,!0,52,8)};l.prototype.readDoubleBE=function(r,e){return e||I(r,8,this.length),Ur(this,r,!1,52,8)};function D(t,r,e,n,o,i){if(!K(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(r>o||r<i)throw new RangeError('"value" argument is out of bounds');if(e+n>t.length)throw new RangeError("Index out of range")}l.prototype.writeUIntLE=function(r,e,n,o){if(r=+r,e=e|0,n=n|0,!o){var i=Math.pow(2,8*n)-1;D(this,r,e,n,i,0)}var a=1,c=0;for(this[e]=r&255;++c<n&&(a*=256);)this[e+c]=r/a&255;return e+n};l.prototype.writeUIntBE=function(r,e,n,o){if(r=+r,e=e|0,n=n|0,!o){var i=Math.pow(2,8*n)-1;D(this,r,e,n,i,0)}var a=n-1,c=1;for(this[e+a]=r&255;--a>=0&&(c*=256);)this[e+a]=r/c&255;return e+n};l.prototype.writeUInt8=function(r,e,n){return r=+r,e=e|0,n||D(this,r,e,1,255,0),l.TYPED_ARRAY_SUPPORT||(r=Math.floor(r)),this[e]=r&255,e+1};function Pr(t,r,e,n){r<0&&(r=65535+r+1);for(var o=0,i=Math.min(t.length-e,2);o<i;++o)t[e+o]=(r&255<<8*(n?o:1-o))>>>(n?o:1-o)*8}l.prototype.writeUInt16LE=function(r,e,n){return r=+r,e=e|0,n||D(this,r,e,2,65535,0),l.TYPED_ARRAY_SUPPORT?(this[e]=r&255,this[e+1]=r>>>8):Pr(this,r,e,!0),e+2};l.prototype.writeUInt16BE=function(r,e,n){return r=+r,e=e|0,n||D(this,r,e,2,65535,0),l.TYPED_ARRAY_SUPPORT?(this[e]=r>>>8,this[e+1]=r&255):Pr(this,r,e,!1),e+2};function Lr(t,r,e,n){r<0&&(r=4294967295+r+1);for(var o=0,i=Math.min(t.length-e,4);o<i;++o)t[e+o]=r>>>(n?o:3-o)*8&255}l.prototype.writeUInt32LE=function(r,e,n){return r=+r,e=e|0,n||D(this,r,e,4,4294967295,0),l.TYPED_ARRAY_SUPPORT?(this[e+3]=r>>>24,this[e+2]=r>>>16,this[e+1]=r>>>8,this[e]=r&255):Lr(this,r,e,!0),e+4};l.prototype.writeUInt32BE=function(r,e,n){return r=+r,e=e|0,n||D(this,r,e,4,4294967295,0),l.TYPED_ARRAY_SUPPORT?(this[e]=r>>>24,this[e+1]=r>>>16,this[e+2]=r>>>8,this[e+3]=r&255):Lr(this,r,e,!1),e+4};l.prototype.writeIntLE=function(r,e,n,o){if(r=+r,e=e|0,!o){var i=Math.pow(2,8*n-1);D(this,r,e,n,i-1,-i)}var a=0,c=1,u=0;for(this[e]=r&255;++a<n&&(c*=256);)r<0&&u===0&&this[e+a-1]!==0&&(u=1),this[e+a]=(r/c>>0)-u&255;return e+n};l.prototype.writeIntBE=function(r,e,n,o){if(r=+r,e=e|0,!o){var i=Math.pow(2,8*n-1);D(this,r,e,n,i-1,-i)}var a=n-1,c=1,u=0;for(this[e+a]=r&255;--a>=0&&(c*=256);)r<0&&u===0&&this[e+a+1]!==0&&(u=1),this[e+a]=(r/c>>0)-u&255;return e+n};l.prototype.writeInt8=function(r,e,n){return r=+r,e=e|0,n||D(this,r,e,1,127,-128),l.TYPED_ARRAY_SUPPORT||(r=Math.floor(r)),r<0&&(r=255+r+1),this[e]=r&255,e+1};l.prototype.writeInt16LE=function(r,e,n){return r=+r,e=e|0,n||D(this,r,e,2,32767,-32768),l.TYPED_ARRAY_SUPPORT?(this[e]=r&255,this[e+1]=r>>>8):Pr(this,r,e,!0),e+2};l.prototype.writeInt16BE=function(r,e,n){return r=+r,e=e|0,n||D(this,r,e,2,32767,-32768),l.TYPED_ARRAY_SUPPORT?(this[e]=r>>>8,this[e+1]=r&255):Pr(this,r,e,!1),e+2};l.prototype.writeInt32LE=function(r,e,n){return r=+r,e=e|0,n||D(this,r,e,4,2147483647,-2147483648),l.TYPED_ARRAY_SUPPORT?(this[e]=r&255,this[e+1]=r>>>8,this[e+2]=r>>>16,this[e+3]=r>>>24):Lr(this,r,e,!0),e+4};l.prototype.writeInt32BE=function(r,e,n){return r=+r,e=e|0,n||D(this,r,e,4,2147483647,-2147483648),r<0&&(r=4294967295+r+1),l.TYPED_ARRAY_SUPPORT?(this[e]=r>>>24,this[e+1]=r>>>16,this[e+2]=r>>>8,this[e+3]=r&255):Lr(this,r,e,!1),e+4};function st(t,r,e,n,o,i){if(e+n>t.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function ct(t,r,e,n,o){return o||st(t,r,e,4),Ze(t,r,e,n,23,4),e+4}l.prototype.writeFloatLE=function(r,e,n){return ct(this,r,e,!0,n)};l.prototype.writeFloatBE=function(r,e,n){return ct(this,r,e,!1,n)};function ut(t,r,e,n,o){return o||st(t,r,e,8),Ze(t,r,e,n,52,8),e+8}l.prototype.writeDoubleLE=function(r,e,n){return ut(this,r,e,!0,n)};l.prototype.writeDoubleBE=function(r,e,n){return ut(this,r,e,!1,n)};l.prototype.copy=function(r,e,n,o){if(n||(n=0),!o&&o!==0&&(o=this.length),e>=r.length&&(e=r.length),e||(e=0),o>0&&o<n&&(o=n),o===n||r.length===0||this.length===0)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("sourceStart out of bounds");if(o<0)throw new RangeError("sourceEnd out of bounds");o>this.length&&(o=this.length),r.length-e<o-n&&(o=r.length-e+n);var i=o-n,a;if(this===r&&n<e&&e<o)for(a=i-1;a>=0;--a)r[a+e]=this[a+n];else if(i<1e3||!l.TYPED_ARRAY_SUPPORT)for(a=0;a<i;++a)r[a+e]=this[a+n];else Uint8Array.prototype.set.call(r,this.subarray(n,n+i),e);return i};l.prototype.fill=function(r,e,n,o){if(typeof r=="string"){if(typeof e=="string"?(o=e,e=0,n=this.length):typeof n=="string"&&(o=n,n=this.length),r.length===1){var i=r.charCodeAt(0);i<256&&(r=i)}if(o!==void 0&&typeof o!="string")throw new TypeError("encoding must be a string");if(typeof o=="string"&&!l.isEncoding(o))throw new TypeError("Unknown encoding: "+o)}else typeof r=="number"&&(r=r&255);if(e<0||this.length<e||this.length<n)throw new RangeError("Out of range index");if(n<=e)return this;e=e>>>0,n=n===void 0?this.length:n>>>0,r||(r=0);var a;if(typeof r=="number")for(a=e;a<n;++a)this[a]=r;else{var c=K(r)?r:kr(new l(r,o).toString()),u=c.length;for(a=0;a<n-e;++a)this[a+e]=c[a%u]}return this};var Bo=/[^+\/0-9A-Za-z-_]/g;function Do(t){if(t=Co(t).replace(Bo,""),t.length<2)return"";for(;t.length%4!==0;)t=t+"=";return t}function Co(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function Oo(t){return t<16?"0"+t.toString(16):t.toString(16)}function kr(t,r){r=r||1/0;for(var e,n=t.length,o=null,i=[],a=0;a<n;++a){if(e=t.charCodeAt(a),e>55295&&e<57344){if(!o){if(e>56319){(r-=3)>-1&&i.push(239,191,189);continue}else if(a+1===n){(r-=3)>-1&&i.push(239,191,189);continue}o=e;continue}if(e<56320){(r-=3)>-1&&i.push(239,191,189),o=e;continue}e=(o-55296<<10|e-56320)+65536}else o&&(r-=3)>-1&&i.push(239,191,189);if(o=null,e<128){if((r-=1)<0)break;i.push(e)}else if(e<2048){if((r-=2)<0)break;i.push(e>>6|192,e&63|128)}else if(e<65536){if((r-=3)<0)break;i.push(e>>12|224,e>>6&63|128,e&63|128)}else if(e<1114112){if((r-=4)<0)break;i.push(e>>18|240,e>>12&63|128,e>>6&63|128,e&63|128)}else throw new Error("Invalid code point")}return i}function ko(t){for(var r=[],e=0;e<t.length;++e)r.push(t.charCodeAt(e)&255);return r}function Uo(t,r){for(var e,n,o,i=[],a=0;a<t.length&&!((r-=2)<0);++a)e=t.charCodeAt(a),n=e>>8,o=e%256,i.push(o),i.push(n);return i}function pt(t){return so(Do(t))}function Mr(t,r,e,n){for(var o=0;o<n&&!(o+e>=r.length||o>=t.length);++o)r[o+e]=t[o];return o}function Po(t){return t!==t}function Lo(t){return t!=null&&(!!t._isBuffer||lt(t)||Mo(t))}function lt(t){return!!t.constructor&&typeof t.constructor.isBuffer=="function"&&t.constructor.isBuffer(t)}function Mo(t){return typeof t.readFloatLE=="function"&&typeof t.slice=="function"&&lt(t.slice(0,0))}import{encodeAddress as ft,decodeAddress as Pi}from"algosdk";function A(t){return t.reduce((r,e)=>Uint8Array.from([...r,...e]))}function Z(t){return new Uint8Array(l.from(t))}function mt(t){return l.from(t).toString("utf-8")}function dt(t){let r=l.alloc(8);for(let e=0;e<8;e++)r[7-e]=Number(BigInt(t)>>BigInt(e*8)&BigInt(255));return new Uint8Array(r)}function vr(t){return l.from(t).toString("base64")}function fr(t){return l.from(t,"base64")}var Ji=`{"theme1":{"value":"${f.env.FRONTEND_URL}/Theme%3DDark.svg","active":true},"theme2":{"value":"${f.env.FRONTEND_URL}/Theme%3DLight.svg","active":true},"theme3":{"value":"${f.env.FRONTEND_URL}/Theme%3DLight.svg","active":true}}`;var gt={V1_1:"v1_1",V2:"v2"},ra={[gt.V1_1]:{testnet:62368684,mainnet:552635992},[gt.V2]:{testnet:148607e3,mainnet:1002541853}};function ht(t){return Object.keys(t).sort().reduce((r,e)=>({...r,[e]:t[e]}),{})}function Fo(t){let r={};return t.forEach(e=>{let n=fr(e.key).toString(),o=e.value,i=o.type;i==2&&(o=o.uint),i==1&&(o=fr(o.bytes)),n=="gov"?r.gov=ft(o):r[n]=o}),ht(r)}var bt=t=>{let r={0:t.amount},e=t.assets;for(let n=0;n<e.length;n++){let o=e[n]["asset-id"],i=e[n].amount;r[o]=i}return console.log(`Account ${t.address} balances`,JSON.stringify(r)),r},Et=async(t,r)=>{let e=await t.getApplicationByID(r).do();return Fo(e.params["global-state"])};var H=async(t,r,e)=>{try{let{value:n}=await t.getApplicationBoxByName(r,e).do();return n}catch(n){if(n.message.includes("box not found"))return console.log(`Box not found '${s.from(e).toString("hex")}'`),null;throw n}},V=async(t,r=1)=>{let e=await t.getTransactionParams().do();return r>1&&(e.fee=xt.ALGORAND_MIN_TX_FEE*r,e.flatFee=!0),{...e}},At=(t,r)=>Object.keys(t).includes(r.toString()),Tt=t=>xt.decodeAddress(t.toUpperCase()).publicKey;import*as T from"ethereumjs-util";function P(t){let r=T.fromSigned(s.from(t));return BigInt(r.toString())}function Go(t){return T.toUnsigned(new T.BN(String(t)))}function ne(t){let r=Go(t);if(r.length>32)throw new Error("Invalid value. The buffer length of the value is more than 32");return new Uint8Array(T.setLengthLeft(r,32))}var oe=t=>{if(t.length!==32)throw new Error("Invalid address bytes. The address buffer length is not equel 32");let r=s.from(t).toString("hex");if(r.slice(0,24)!=="000000000000000000000000")throw console.log("normalizedAddress",r),new Error("Invalid normalized address");let e="0x"+r.slice(-40);if(!Ko(e))throw new Error("Invalid hex address");return e},yt=t=>new Uint8Array(T.setLengthLeft(br(t),32)),br=t=>s.from(Wo(t),"hex"),Wo=t=>t.startsWith("0x")?t.slice(2):t,Ko=t=>T.isValidAddress(t),_t=(t,r)=>{let e=T.keccak256(t),{r:n,s:o,v:i}=T.fromRpcSig(r);return T.ecrecover(e,i,n,o)};var C=t=>new Uint8Array(T.keccak256(s.from(t)));var wt=(o=>(o.GLOBAL_PAIR_DELISTING="GLOBAL_PAIR_DELISTING",o.GLOBAL_NEW_PAIR_LISTING="GLOBAL_NEW_PAIR_LISTING",o.GLOBAL_SYSTEM_MAINTENANCE="GLOBAL_SYSTEM_MAINTENANCE",o.GLOBAL_SMART_CONTRACT_UPDATE="GLOBAL_SMART_CONTRACT_UPDATE",o))(wt||{}),Nt=(n=>(n.ACCOUNT_POINTS_UNLOCK_ACHIEVEMENT="ACCOUNT_POINTS_UNLOCK_ACHIEVEMENT",n.ACCOUNT_KYC_STATUS_CHANGED="ACCOUNT_KYC_STATUS_CHANGED",n.ACCOUNT_AFFILIATE_DASHBOARD_UNLOCKED="ACCOUNT_AFFILIATE_DASHBOARD_UNLOCKED",n))(Nt||{}),Xs={...wt,...Nt};var se=(t,r)=>A([g(r,"str"),C(t)]),ce=(t,r)=>A([g(r,"str"),s.from(t,"hex")]),R=(t,r)=>{let e=$o.ABIMethod.fromSignature(t),n=e.getSelector(),o={},i=r.map((a,c)=>{let u=e.args[c].type.encode(a);return o[`txnArgs${c}`]=Array.apply([],Array.from(u)).join(", "),u});return[n,...i]},Er=(t,r,e)=>{let n=s.from(t,r),o=n.subarray(n.length-e),i=s.from(o).toString();return fr(i)},ur=(t,r,e,n,o="hex")=>[ie(t,o,n),zo(r,n),Xo(e,n,t,r,o)],zo=(t,r)=>r===8?fr(t):r===1?ae.decode(t):br(t),Xo=(t,r,e,n,o)=>r===8||r===1?$(t,r):_t(ie(e,o,r),n),qo=(t,r)=>r===8?"MX":r===1?"":`Ethereum Signed Message:
2
+ ${t.length}`,ie=(t,r,e)=>{let n=s.from(t,r);return s.concat([Z(qo(n,e)),n])};var $=(t,r)=>r===8?Tt(t):r===1?ae.decode(t):yt(t);import ou from"algosdk";import du from"algosdk";import Qu from"algosdk";var Ar={"0x4343545055534443000000000000000000000000000000000000000000000000":65537};var Bu={SMALLESTUNIT:f.env.SMALLEST_UNIT},Du={SMALLEST_UNITS:f.env.SMALLEST_UNIT};var Pu=["point-system.discordEnabled","point-system.telegramBotName","point-system.telegramBotId","point-system.telegramEnabled","point-system.telegramGroupId","point-system.telegramGroupName","point-system.twitterAccountId","point-system.twitterAccountName","point-system.twitterEnabled","point-system.twitterJobEnabled","point-system.guideLink"];var pe=(t,r="hex")=>Er(t,r,328),Fr=(t,r)=>se(pe(t,r),"O_"),St=t=>ce(t,"O_");import cp from"algosdk";import me from"algosdk";var Yr=(t,r,e,n,o,i)=>{let a=R("dummy(uint64)void",[1]);return me.makeApplicationNoOpTxnFromObject({from:r,suggestedParams:{...e,fee:me.ALGORAND_MIN_TX_FEE,flatFee:!0},appArgs:a,appIndex:t,boxes:n,foreignApps:i,note:new Uint8Array(s.from(o))})},Bt=(t,r)=>{let{accounts:n,foreignAssets:o,foreignApps:i,boxes:a,appIndex:c,from:u,suggestedParams:p}=r;console.log("Total resources",[n,i,o,a]);let d=[n,i,o,a].reduce((w,M)=>w+(M?.length||0),0),m=a?.slice(0,8-d)||[],h=a?.slice(8-d)||[],x=8-(i?.length||0),E=me.makeApplicationNoOpTxnFromObject({...r,boxes:m}),y=1,S=[],N=[];for(let w=0;w<h.length;w++){let M=h[w];S.push(M),(S.length===x||w===h.length-1)&&(N.push(Yr(c,u,p,S,`${t}_${y}`,i)),S=[],y++)}return N.push(Yr(c,u,p,[],`${t}_${++y}`,i)),console.log("dummy count",N.length),[E,...N]};function de(t){switch(t){case"B":return"BUY";case"S":return"SELL";default:throw new Error("Unknown order side short type: "+t)}}function fe(t){switch(t){case"I":return"IOC";case"P":return"POST";case"M":return"Market";case"L":default:return"Limit"}}var qp=(t,r,e="address")=>({address:(e==="token"?Zo:Ut)(t,Number(r)),chainId:Number(r)}),Ut=(t,r)=>{let e=s.from(t.startsWith("0x")?t.substring(2):t,"hex");return r===8?b.encodeAddress(e):r===1?Kr.encode(e):oe(e)};function Zo(t,r){return Number(r)===8?String(Number(t)):Ar["0x"+t]?"0x"+t:Ut(t,Number(r))}var g=(t,r,e)=>{switch(r){case"8B":return b.encodeUint64(Number(t));case"32B":return ne(t);case"str":return Z(String(t));case"address":return $(String(t),e);case"token":return Ae(String(t),e);case"float":{var n=s.alloc(8);return n.writeDoubleBE(Number(t),0),new Uint8Array(n)}case"bool":return new Uint8Array(s.from(b.encodeUint64(Number(t))).subarray(-1));case"2B":return new Uint8Array(s.from(b.encodeUint64(Number(t))).subarray(-2));case"4B":return new Uint8Array(s.from(b.encodeUint64(Number(t))).subarray(-4));default:return s.from(t.toString())}},O=(t,r,e)=>{switch(r){case"8B":return b.decodeUint64(t,"safe");case"32B":return P(t);case"str":return mt(t);case"address":return lr(t,e);case"token":return Pt(t,e);case"float":return s.from(t).readDoubleBE(0);case"bool":case"2B":return O(t,"8B");default:return s.from(t).toString()}},xe=(t,r,e)=>lr(t.subarray(r,r+32),e),Dt=(t,r,e)=>Pt(t.subarray(r,r+32),e),ri=(t,r=0)=>Number(O(t.subarray(r,r+8),"float")),Ct=(t,r,e)=>String(O(t.subarray(r,r+e),"str")),ge=(t,r=0)=>Number(O(t.subarray(r,r+2),"8B")),he=(t,r=0)=>Number(O(t.subarray(r,r+4),"8B")),be=(t,r=0)=>Number(O(t.subarray(r,r+8),"8B")),Ot=(t,r=0)=>String(O(t.subarray(r,r+32),"32B")),lr=(t,r)=>r===8?b.encodeAddress(t):r===1?Kr.encode(t):oe(t),Pt=(t,r)=>{let e=s.from(t).toString("hex");return e.startsWith("0x")||(e="0x"+e),Ar[e]?e:r===8?String(P(t)):r===1?Kr.encode(t):lr(t,r)},Jp=(t,r,e=!1)=>{let n=s.from($(t,r)).toString("hex");return e&&!n.startsWith("0x")?`0x${n}`:n},jp=t=>t.startsWith("0x")?s.from(t.substring(2),"hex").length===32:s.from(t,"hex").length===32,Ae=(t,r)=>r===8?ne(+t):Ar[t]?new Uint8Array(br(String(t))):$(String(t),r),Qp=async(t,r)=>{let e=await Et(t,r),n=e.MSG_PROCESSOR,o=e.UL_SUPERADMIN_APP,i=e.UL_SUPERADMIN_WALLET;i=i?.length?i:void 0;let a=i&&Number(O(i.subarray(32,40),"8B")),c={collectionWallet:i&&lr(i.subarray(0,32),a),collectionWalletChainId:a,msgProcId:n,superAppId:o};return console.log("CodexState parsed",c),c},Zp=async(t,r)=>{let e=b.getApplicationAddress(r);console.log("appAddress",e);let n=await t.accountInformation(e).do();console.log("CODEX AccountInfo",n)},rl=(t,r)=>{let e=L(t.address,t.chainId,r.address,r.chainId);return s.from(C(e)).toString("hex")},L=(t,r,e,n)=>{let o=$(t,r),i=b.encodeUint64(r),a=b.encodeUint64(n),c=Ae(e,n);return A([o,i,c,a])},Te=(t,r)=>{let e=A([Ae(t,r),b.encodeUint64(r)]);return C(e)},el=async(t,r,e,n)=>{let o=Te(e,n),i=await ye(t,r,o);return console.log("Box CCTP balance",e.substring(0,18),n,i),i},tl=async(t,r,e,n=[1,6,10002,10003,10004,10005])=>{let o=await Promise.all(n.map(c=>ye(t,r,Te(e,c)))),i=(c,u=6)=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:u}).format(+sr(c,10**u)),a={};for(let c=0;c<n.length;c++){let u=n[c];a[u]=i(o[c])}return console.log("Box CCTP balance",a),a},nl=t=>A([g("Rebalance_","str"),b.encodeUint64(t)]),Ee=t=>{let r=A([g("TokenManager","str"),b.encodeUint64(t)]);return C(r)},ol=async(t,r,e)=>{let n=Ee(e),o=await H(t,r,n);if(!o)return;let i=lr(o,e);return console.log("Box TokenManager of chain",e,i),i},gr=(t,r)=>{let e=$(t,r),n=Z("TK_");return A([n,e])},il=async(t,r,e,n)=>{let o=C(gr(e,n)),i=await H(t,r,o);if(!i)return;let a=[];for(let c=0;c+32<=i.length;c+=32){let u=lr(i.subarray(c,c+32),8);a.push(u)}return console.log("Box account trading keys",e.substring(0,8),a,s.from(o).toString("hex")),a},al=async(t,r)=>{let e=b.getApplicationAddress(r);return await ei(t,e)},ei=async(t,r)=>{let e=await t.accountInformation(r).do();return bt(e)},sl=async(t,r)=>{let{boxes:e}=await t.getApplicationBoxes(r).do();console.log(`boxes of ${r}`,e.map(n=>n.name))},cl=async(t,r,e,n)=>ti(t,r,e.address,e.chainId,n.address,n.chainId),ti=async(t,r,e,n,o,i)=>{let a=C(L(e,n,o,i)),c=await ye(t,r,a);return console.log("Box account value",e.substring(0,8),o,c,s.from(a).toString("hex")),String(c)},ul=async(t,r,e)=>{let n=s.from(e,"hex"),o=await H(t,r,n),i=0n;return o&&(i=P(o)),console.log("Box account value",JSON.stringify({hash:e.substring(0,8),boxValue:String(i),box:`[${o?.toString()}]`})),i},ye=async(t,r,e)=>{let n=await H(t,r,e),o=0n;return n&&(o=P(n)),o},Tr=t=>g(t,"8B"),pl=async(t,r,e)=>{let n=Tr(e),o=await H(t,r,n);if(!o)return;let i=Number(O(o.subarray(32,40),"8B")),a={collectionWallet:lr(o.subarray(0,32),i),collectionWalletChainId:i,takerFee:Number(O(o.subarray(40,48),"8B")),makerFee:o.length>48?Number(O(o.subarray(48,56),"8B")):0};return console.log(`Box company #${e} value`,a),a},ll=async(t,r,e,n)=>{let o=C(_e(e,n)),i=await H(t,r,o);if(!i)return;let a={minSize:P(i.subarray(0,32)),minPriceIncrement:P(i.subarray(32,64)),minSizeIncrement:P(i.subarray(64,96))};return console.log("Box pair value",i,a),a},ml=async(t,r,e,n=!0)=>{let o=e.boxName||e.hash&&St(e.hash)||Fr(e.message,"hex"),i=await H(t,r,o);if(!i)return;let a={hash:s.from(o).toString("hex"),amount:P(i.subarray(0,32)),price:P(i.subarray(32,64)),expiredTime:P(i.subarray(64,72)),expiredDate:new Date(Number(P(i.subarray(64,72)))*1e3)};return n&&console.log("Box order value",JSON.stringify({expiredDate:a.expiredDate,expiredTime:String(a.expiredTime),hash:a.hash,price:String(a.price),amount:String(a.amount)})),a},dl=async(t,r,e)=>{let n=C(er(e)),o=await H(t,r,n);if(!o)return;let i={decimal:Number(O(o.subarray(2,10),"8B")),name:String(O(o.subarray(12,o.length),"str"))};return console.log("Box token value",o,i),i},ni=(t,r,e,n,o,i)=>{if(i.chainId!==8)return;let a=Number(i.address);if(a===0||At(o,a))return;console.log("Make optin to codex for",a);let u=b.ABIMethod.fromSignature("asset_opt_in(asset)void").getSelector(),p={...n,fee:b.ALGORAND_MIN_TX_FEE*2,flatFee:!0};return b.makeApplicationNoOpTxnFromObject({appIndex:t,from:e,suggestedParams:p,appArgs:[u,dt(a)],foreignApps:[r],foreignAssets:[a]})},fl=async(t,r,e,n,o,i,a,c)=>{console.log("makeDeposit args",{sender:e,loginAddress:n,loginChainId:o,tokenAmount:i,tokenIndex:a,appId:t});let u=[],p=await V(r,1),d=b.getApplicationAddress(t),m={suggestedParams:p,from:e,to:d,amount:i};u.push(a===0?b.makePaymentTxnWithSuggestedParamsFromObject(m):b.makeAssetTransferTxnWithSuggestedParamsFromObject({...m,assetIndex:a}));let h=b.ABIMethod.fromSignature("depositToCodex(byte[])uint64"),x=h.getSelector(),E=oi({loginAddress:n,loginChainId:o}),y=h.args[0].type.encode(E),S=C(L(n,o,a,c));return u.push(b.makeApplicationNoOpTxnFromObject({appIndex:t,from:e,suggestedParams:p,appArgs:[x,y],boxes:[{appIndex:t,name:S}]})),u},Lt=(t,r)=>{let e=$(t,r),n=b.encodeUint64(r),o=A([e,n]);return console.log("messageBytes",o,JSON.stringify(o),vr(o)),o},oi=({loginAddress:t,loginChainId:r})=>Lt(t,r),ii=({loginAddress:t,loginChainId:r})=>Lt(t,r),gl=t=>{let r=s.concat([g(t.version,"2B"),g(t.expiredTime,"4B"),g(t.orderSide,"str"),g(t.price,"32B"),g(t.amount,"32B"),g(t.orderType,"str"),g(t.address,"address",t.chainId),g(t.chainId,"2B"),g(t.baseTokenAddress,"token",t.baseTokenChainId),g(t.baseTokenChainId,"4B"),g(t.priceTokenAddress,"token",t.priceTokenChainId),g(t.priceTokenChainId,"4B"),g(t.companyId,"2B"),g(t.random,"8B"),g(t.decimalPrice,"float"),s.alloc(50)]),e=new Uint8Array(s.from(vr(r))),n=new Uint8Array([...ai(t),...e]);return console.log(`Order data should be ${328} bytes`,e.length,e),n},ai=t=>{let{amount:r,price:e,baseTokenAddress:n,baseChain:o,baseCurrency:i,baseDecimal:a,priceTokenAddress:c,priceChain:u,priceCurrency:p,priceDecimal:d}=t,m=i?.toUpperCase(),h=p?.toUpperCase(),x=sr(r,10**a),E=sr(e,10**d),y=de(t.orderSide),S=fe(t.orderType),N=(nr,v)=>`${nr}`+(v&&` (${v})`),w=t.orderType==="M"?`ESTIMATED TOTAL ${E} ${h}`:`LIMIT PRICE ${E} ${h} per ${m}`,tr=[`NEW ${S.toUpperCase()} ORDER ${N(m,o)} / ${N(h,u)}:`,`${y} ${x} ${m}, ${w}`,`${m} ID: ${n}`,`${h} ID: ${c}`,`Exp: ${30} Days`].join(`
3
+ `)+`
4
+ `;return new Uint8Array(s.from(tr,"utf-8"))},hl=t=>{let{orderId:r,amount:e,price:n,baseTokenAddress:o,baseChain:i,baseCurrency:a,baseDecimal:c,priceTokenAddress:u,priceChain:p,priceCurrency:d,priceDecimal:m}=t,h=a?.toUpperCase(),x=d?.toUpperCase(),E=(v,F)=>`${v}`+(F&&` (${F})`),y=sr(e,10**c),S=sr(n,10**m),N=de(t.orderSide),w=fe(t.orderType),M=t.orderType==="M"?`ESTIMATED TOTAL ${S} ${x}`:`LIMIT PRICE ${S} ${x} per ${h}`,nr=[`CANCEL ${w.toUpperCase()} ORDER ${E(h,i)} / ${E(x,p)}:`,`${N} ${y} ${h}, ${M}`,`Order ID: ${r}`,`${h} ID: ${o}`,`${x} ID: ${u}`].join(`
5
+ `)+`
6
+ `;return new Uint8Array(s.from(nr,"utf-8"))},xl=(t,r="hex")=>{let e=pe(t,r),n=ge(e,104),o=he(e,138),i=he(e,174),a={version:ge(e),expiredTime:he(e,2),orderSide:Ct(e,6,1),price:Ot(e,7),amount:Ot(e,39),orderType:Ct(e,71,1),address:xe(e,72,n),chainId:n,baseTokenAddress:Dt(e,106,o),baseTokenChainId:o,priceTokenAddress:Dt(e,142,i),priceTokenChainId:i,companyId:ge(e,178),random:be(e,180),decimalPrice:ri(e,188)};return{...a,expiredDate:String(a.expiredTime).length>10?new Date(a.expiredTime):new Date(a.expiredTime*1e3)}},kt=t=>{let{id:r,address:e,chain:n,message:o,encoding:i,signature:a,tradingKey:c}=t,u=c||e,p=c?8:n;return[...ur(o,a,u,p,i),r]},_e=(t,r)=>A([er(t),er(r)]),er=({address:t,chainId:r})=>A([g(t,"token",r),g(r,"8B")]),pr=(t,r,e=C)=>r.map(o=>({appIndex:t,name:e(o)})),Gr=t=>t?A([g(t.address,"address",t.chainId),g(t.chainId,"2B"),g(t.feeShare,"2B")]):s.alloc(36),rr=(t,r)=>{let e;return t?.address&&t?.chainId&&(e=L(t.address,t.chainId,r.address,r.chainId)),e},Wr=(t,r)=>{let e;return t.collectionWallet&&t.collectionWalletChainId&&(e=L(t.collectionWallet,t.collectionWalletChainId,r.address,r.chainId)),e},bl=(t,r,e,n,o="hex")=>{let{id:i,amount:a,buy:c,sell:u,baseAsset:p,priceAsset:d,superCompany:m,superAppId:h,fee:x}=r,{b_share:E,s_share:y,tfee_tier:S,mfee_tier:N,mmfee_tier:w,mm_tfee:M,p_mfee:tr,p_tfee:nr,bdMaker:v,bdTaker:F,afMaker:hr,afTaker:xr}=x;if(!m)throw new Error("Collection wallet for super user was not provided");let Hr=A([g(E,"2B"),g(y,"2B"),g(N,"str"),g(S,"str"),g(w,"str"),g(M,"2B"),g(nr,"2B"),g(tr,"2B")]),yr=A([Gr(v),Gr(hr),Gr(F),Gr(xr)]),_r=[...kt({...c,encoding:o}),...kt({...u,encoding:o}),g(a,"32B"),Hr,g(i,"8B"),yr],Ir=R("match(byte[],byte[],byte[],uint64,byte[],byte[],byte[],uint64,byte[],byte[],byte[],byte[])uint64",_r),Ft=_e(p,d),Yt=Fr(c.message,o),Gt=Fr(u.message,o),Wt=er(p),Kt=er(d),Ht=L(c.address,c.chain,p.address,p.chainId),Vt=L(c.address,c.chain,d.address,d.chainId),$t=L(u.address,u.chain,p.address,p.chainId),zt=L(u.address,u.chain,d.address,d.chainId),Xt=Tr(c.companyId),qt=Tr(u.companyId),Jt=[...new Set([Ft,Wt,Kt,Ht,Vt,gr(c.address,c.chain),gr(u.address,u.chain),$t,zt,Wr(m,p),Wr(m,d),Wr(c,p),Wr(u,d),rr(v,p),rr(v,d),rr(F,p),rr(F,d),rr(hr,p),rr(hr,d),rr(xr,p),rr(xr,d)].filter(Boolean).map(z=>s.from(z).toString("hex")))].map(z=>s.from(z,"hex")),Vr=[...pr(t,Jt),...pr(t,[Yt,Gt,Xt,qt],z=>z)],jt=[...new Set(Vr.map(z=>s.from(z.name).toString("hex")))];console.log(`[TradeID: ${i}] All boxes`,JSON.stringify(jt));let $r=[h],zr=8,Qt=Vr.slice(0,zr-$r.length),Ie=Vr.slice(zr-$r.length),Zt=b.makeApplicationNoOpTxnFromObject({from:n,suggestedParams:e,appIndex:t,appArgs:Ir,boxes:Qt,foreignApps:$r,note:b.encodeUint64(i)}),rn={...e,fee:0,flatFee:!0},we=[Zt],en=1;for(;Ie.length>0;){let z=Ie.splice(0,zr);we.push(Yr(t,n,rn,z,`${i}_${en++}`))}return we},El=(t,r)=>{let{address:e,technology:n}=t;return Mt(r||JSON.stringify({address:e,technology:n}))},Al=({tkAddress:t,loginAddress:r,loginChainId:e,expiredDate:n,type:o},i=!0)=>{let a=`${i?"Add":"Revoke"} ${o} key: ${t}`,c=n?`Expires On: ${Xe(n)}`:"No Expiration",u=a+(i?`
7
+ `+c:""),p=A([g(t,"address",8),g(r,"address",e),g(e,"8B"),g(n||0,"8B")]);return ci(u,p)},si=108,Tl=(t,r="hex")=>{let e=Er(t,r,si),n=be(e,64),o={tkAddress:xe(e,0,8),address:xe(e,32,n),chainId:n,expiredTime:be(e,72)};return{...o,expiredDate:new Date(o.expiredTime)}},yl=async(t,r,e,n,{loginAddress:o,loginChainId:i},a,c)=>{let u=ur(a,c,o,i),p=R("manageTradingKey(byte[],byte[],byte[],byte[])uint64",[g("add","str"),...u]),d=gr(o,i),m=await V(t,5);return b.makeApplicationNoOpTxnFromObject({from:n,suggestedParams:m,appIndex:r,appArgs:p,boxes:pr(r,[d]),foreignApps:[e]})},_l=async(t,r,e,n,{loginAddress:o,loginChainId:i},a,c)=>{let u=ur(a,c,o,i),p=R("manageTradingKey(byte[],byte[],byte[],byte[])uint64",[g("delete","str"),...u]),d=gr(o,i);return b.makeApplicationNoOpTxnFromObject({from:n,suggestedParams:await V(t,5),appIndex:r,appArgs:p,boxes:pr(r,[d]),foreignApps:[e]})},Il=t=>{let{loginAddress:r,loginChainId:e,companyId:n}=t,o=b.encodeUint64(n),i=$(r,e),a=b.encodeUint64(e),c=A([i,a,o]),u=new Uint8Array([...le(c)]);return console.log("MESSAGE LENGTH: ",u),u},ci=(t,r)=>A([Mt(t),le(r)]),Mt=t=>new Uint8Array(s.from(t+`
8
+ `,"utf-8")),le=t=>new Uint8Array(s.from(vr(t))),wl=async(t,{loginAddress:r,loginChainId:e,tokenIndex:n,recipient:o,recipientChainId:i},a,c,u,p)=>{let d=ur(a,c,r,e),m=R("withdraw(byte[],byte[],byte[])uint64",d),h=i===8,x=await V(t,h?6:2);x.fee=x.fee+b.ALGORAND_MIN_TX_FEE*5;let{appId:E,coreId:y,lsaAddress:S,msgProcessorId:N,unifiedChainId:w,cctpSupportedChains:M,superWallet:tr}=p,nr=C(L(r,e,n,w||i)),v=C(L(tr.address,tr.chainId,n,w||i)),F=[{appIndex:E,name:nr},{appIndex:E,name:v}];!h&&!w&&F.push({appIndex:N,name:Ee(i)}),w&&F.push(...M.map(Ir=>[{appIndex:N,name:Te(String(n),Ir)},{appIndex:N,name:Ee(Ir)}]).flat());let hr=h&&n!=0?[+n]:void 0,xr=h?[y]:[y,N],Hr=b.getApplicationAddress(y),yr=[S,Hr];h&&yr.push(o);let _r=Bt("withdraw",{appIndex:E,from:u,suggestedParams:x,appArgs:m,accounts:yr,foreignAssets:hr,foreignApps:xr,boxes:F,note:b.encodeUint64(Date.now())});return console.log("withdraw txns",_r),_r},Nl=async(t,r,{message:e,signature:n,signerAddress:o,signerChainId:i},a,c,u)=>{let p=ur(e,n,o,i),d=R("setCollectionWallet(byte[],byte[],byte[])void",p),m=await V(t,4),h=Tr(u),x=[c],E=b.makeApplicationNoOpTxnFromObject({appIndex:a,from:r,suggestedParams:m,appArgs:d,foreignApps:x,boxes:[{appIndex:a,name:h}]});return console.log("setCollectionWallet txn",E),E},Rl=async(t,r,e,n,o,i)=>{let a=ii({loginAddress:o,loginChainId:i});return vt(t,r,e,n,{key:"UL_SUPERADMIN_WALLET",type:"S",value:a})},Sl=async(t,r,e,n,o)=>{let i=g(o,"8B");return vt(t,r,e,n,{key:"UL_SUPERADMIN_APP",type:"N",value:i})},vt=async(t,r,e,n,o)=>{let{key:i,type:a,value:c}=o,u=R("setGlobal(byte[],byte[],byte[])void",[Z(i),c,Z(a)]),p=await V(t,6),d=[e];return b.makeApplicationNoOpTxnFromObject({appIndex:r,from:n,suggestedParams:p,appArgs:u,foreignApps:d})},Bl=async(t,{fee:r,feeType:e,companyId:n},o,i,a)=>{let c=R("setCompanyFee(uint64,uint64,byte[])void",[r,n,Z(e)]),u=await V(t,1),p=Tr(n),d=[a],m=b.makeApplicationNoOpTxnFromObject({appIndex:i,from:o,suggestedParams:u,appArgs:c,boxes:[{appIndex:i,name:p}],foreignApps:d});return console.log("setCompanyFee txn",m),m},Dl=(t,r,e,n,o,i)=>{let a=er(i),c=[g(i.address,"token",i.chainId),i.chainId,g(i.name,"str"),i.decimal],u=R("updateTokenInfo(byte[],uint64,byte[],uint64)uint64",c),d=[b.makeApplicationNoOpTxnFromObject({from:e,suggestedParams:n,appIndex:t,appArgs:u,boxes:pr(t,[a]),foreignApps:[r]})],m=ni(t,r,e,n,o,i);return m&&d.unshift(m),d},Cl=(t,r,e,n,o,i,a,c,u)=>{let p=er(o),d=er(i),m=_e(o,i),h=R("updatePairInfo(byte[],uint64,byte[],uint64,byte[],byte[],byte[])uint64",[g(o.address,"token",o.chainId),o.chainId,g(i.address,"token",i.chainId),i.chainId,g(a,"32B"),g(c,"32B"),g(u,"32B")]);return b.makeApplicationNoOpTxnFromObject({from:e,suggestedParams:n,appIndex:t,appArgs:h,boxes:pr(t,[m,p,d]),foreignApps:[r]})},Ol=(t,r)=>A([g("upgradee","str"),g(t,"8B"),$(r,t),g(0,"8B")]);export{jp as checkIfAddressIsNormalized,pr as createBoxes,O as decode,lr as decodeAddress,xl as decodeCreateOrderMsg,Pt as decodeToken,Tl as decodeTradingKeyMsg,g as encode,$ as encodeAddress,Ae as encodeToken,xe as extractAddress,ri as extractDouble,Ct as extractStr,Dt as extractToken,ge as extractUint16,Ot as extractUint256,he as extractUint32,be as extractUint64,L as getAccountBalanceBoxName,rl as getAccountBalanceBoxNameHash,cl as getAccountBalanceBoxValue,ul as getAccountBoxByHash,ti as getAccountBoxValue,qp as getAddressChainFromNormalized,Ut as getAddressFromNormalized,ei as getAssetBalancesByAppAddress,al as getAssetBalancesByAppIndex,le as getBase64EncodedData,sl as getBoxes,Te as getCCTPBalanceBoxName,el as getCCTPBalanceBoxValue,tl as getCCTPBalancesBoxValue,hl as getCancelOrderDataJsonBytes,Zp as getCodexAccountInfo,Qp as getCodexStateValue,Tr as getCompanyBoxName,pl as getCompanyBoxValue,ml as getOrderBoxValue,_e as getPairBoxKey,ll as getPairBoxValue,nl as getRebalanceBoxName,Ee as getTmcBoxName,ol as getTmcBoxValue,er as getTokenBoxKey,dl as getTokenBoxValue,Zo as getTokenFromNormalized,gr as getTradingKeyBoxName,il as getTradingKeyBoxValue,Ol as getUpgradeImpMsg,Mt as getUtf8EncodedData,yl as makeAddTradingKeyTxn,ni as makeAssetOptInTxn,gl as makeCreateOrderMsg,oi as makeDepositMsg,fl as makeDepositTxns,El as makeLoginMsg,bl as makeMatchTxns,_l as makeRevokeTradingKeyTxn,Il as makeSetCollectionWalletMsg,Nl as makeSetCollectionWalletTxn,Bl as makeSetCompanyFeeTxn,Sl as makeSetSuperAppTxns,Rl as makeSetSuperCollectionWalletTxns,ci as makeSigningMessage,Al as makeTradingKeyMsg,Cl as makeUpdatePairInfoTxn,Dl as makeUpdateTokenInfoTxns,wl as makeWithdrawTxns,Jp as normalizeAddress};
9
+ /*!
10
+ * The buffer module from node.js, for the browser.
11
+ *
12
+ * @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
13
+ * @license MIT
14
+ */
15
+ /*! Bundled license information:
16
+
17
+ @esbuild-plugins/node-globals-polyfill/Buffer.js:
18
+ (*!
19
+ * The buffer module from node.js, for the browser.
20
+ *
21
+ * @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
22
+ * @license MIT
23
+ *)
24
+ */
@@ -0,0 +1,18 @@
1
+ function fr(){throw new Error("setTimeout has not been defined")}function gr(){throw new Error("clearTimeout has not been defined")}var O=fr,k=gr;typeof globalThis.setTimeout=="function"&&(O=setTimeout);typeof globalThis.clearTimeout=="function"&&(k=clearTimeout);function hr(t){if(O===setTimeout)return setTimeout(t,0);if((O===fr||!O)&&setTimeout)return O=setTimeout,setTimeout(t,0);try{return O(t,0)}catch{try{return O.call(null,t,0)}catch{return O.call(this,t,0)}}}function ue(t){if(k===clearTimeout)return clearTimeout(t);if((k===gr||!k)&&clearTimeout)return k=clearTimeout,clearTimeout(t);try{return k(t)}catch{try{return k.call(null,t)}catch{return k.call(this,t)}}}var B=[],F=!1,U,G=-1;function pe(){!F||!U||(F=!1,U.length?B=U.concat(B):G=-1,B.length&&xr())}function xr(){if(!F){var t=hr(pe);F=!0;for(var r=B.length;r;){for(U=B,B=[];++G<r;)U&&U[G].run();G=-1,r=B.length}U=null,F=!1,ue(t)}}function le(t){var r=new Array(arguments.length-1);if(arguments.length>1)for(var e=1;e<arguments.length;e++)r[e-1]=arguments[e];B.push(new br(t,r)),B.length===1&&!F&&hr(xr)}function br(t,r){this.fun=t,this.array=r}br.prototype.run=function(){this.fun.apply(null,this.array)};var me="browser",de="browser",fe=!0,ge={},he=[],xe="",be={},Ee={},Ae={};function P(){}var Te=P,ye=P,_e=P,Ie=P,we=P,Ne=P,Re=P;function Se(t){throw new Error("process.binding is not supported")}function Be(){return"/"}function De(t){throw new Error("process.chdir is not supported")}function Ce(){return 0}var v=globalThis.performance||{},Oe=v.now||v.mozNow||v.msNow||v.oNow||v.webkitNow||function(){return new Date().getTime()};function ke(t){var r=Oe.call(v)*.001,e=Math.floor(r),n=Math.floor(r%1*1e9);return t&&(e=e-t[0],n=n-t[1],n<0&&(e--,n+=1e9)),[e,n]}var Ue=new Date;function Pe(){var t=new Date,r=t-Ue;return r/1e3}var m={nextTick:le,title:me,browser:fe,env:ge,argv:he,version:xe,versions:be,on:Te,addListener:ye,once:_e,off:Ie,removeListener:we,removeAllListeners:Ne,emit:Re,binding:Se,cwd:Be,chdir:De,umask:Ce,hrtime:ke,platform:de,release:Ee,config:Ae,uptime:Pe},dr={};Object.keys(dr).forEach(t=>{let r=t.split("."),e=m;for(let n=0;n<r.length;n++){let o=r[n];n===r.length-1?e[o]=dr[t]:e=e[o]||(e[o]={})}});var w=[],_=[],Le=typeof Uint8Array<"u"?Uint8Array:Array,or=!1;function yr(){or=!0;for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r=0,e=t.length;r<e;++r)w[r]=t[r],_[t.charCodeAt(r)]=r;_[45]=62,_[95]=63}function Me(t){or||yr();var r,e,n,o,i,a,c=t.length;if(c%4>0)throw new Error("Invalid string. Length must be a multiple of 4");i=t[c-2]==="="?2:t[c-1]==="="?1:0,a=new Le(c*3/4-i),n=i>0?c-4:c;var p=0;for(r=0,e=0;r<n;r+=4,e+=3)o=_[t.charCodeAt(r)]<<18|_[t.charCodeAt(r+1)]<<12|_[t.charCodeAt(r+2)]<<6|_[t.charCodeAt(r+3)],a[p++]=o>>16&255,a[p++]=o>>8&255,a[p++]=o&255;return i===2?(o=_[t.charCodeAt(r)]<<2|_[t.charCodeAt(r+1)]>>4,a[p++]=o&255):i===1&&(o=_[t.charCodeAt(r)]<<10|_[t.charCodeAt(r+1)]<<4|_[t.charCodeAt(r+2)]>>2,a[p++]=o>>8&255,a[p++]=o&255),a}function ve(t){return w[t>>18&63]+w[t>>12&63]+w[t>>6&63]+w[t&63]}function Fe(t,r,e){for(var n,o=[],i=r;i<e;i+=3)n=(t[i]<<16)+(t[i+1]<<8)+t[i+2],o.push(ve(n));return o.join("")}function Er(t){or||yr();for(var r,e=t.length,n=e%3,o="",i=[],a=16383,c=0,p=e-n;c<p;c+=a)i.push(Fe(t,c,c+a>p?p:c+a));return n===1?(r=t[e-1],o+=w[r>>2],o+=w[r<<4&63],o+="=="):n===2&&(r=(t[e-2]<<8)+t[e-1],o+=w[r>>10],o+=w[r>>4&63],o+=w[r<<2&63],o+="="),i.push(o),i.join("")}s.TYPED_ARRAY_SUPPORT=globalThis.TYPED_ARRAY_SUPPORT!==void 0?globalThis.TYPED_ARRAY_SUPPORT:!0;function W(){return s.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function D(t,r){if(W()<r)throw new RangeError("Invalid typed array length");return s.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(r),t.__proto__=s.prototype):(t===null&&(t=new s(r)),t.length=r),t}function s(t,r,e){if(!s.TYPED_ARRAY_SUPPORT&&!(this instanceof s))return new s(t,r,e);if(typeof t=="number"){if(typeof r=="string")throw new Error("If encoding is specified then the first argument must be a string");return ir(this,t)}return _r(this,t,r,e)}s.poolSize=8192;s._augment=function(t){return t.__proto__=s.prototype,t};function _r(t,r,e,n){if(typeof r=="number")throw new TypeError('"value" argument must not be a number');return typeof ArrayBuffer<"u"&&r instanceof ArrayBuffer?We(t,r,e,n):typeof r=="string"?Ge(t,r,e):Ke(t,r)}s.from=function(t,r,e){return _r(null,t,r,e)};s.kMaxLength=W();s.TYPED_ARRAY_SUPPORT&&(s.prototype.__proto__=Uint8Array.prototype,s.__proto__=Uint8Array,typeof Symbol<"u"&&Symbol.species&&s[Symbol.species]);function Ir(t){if(typeof t!="number")throw new TypeError('"size" argument must be a number');if(t<0)throw new RangeError('"size" argument must not be negative')}function Ye(t,r,e,n){return Ir(r),r<=0?D(t,r):e!==void 0?typeof n=="string"?D(t,r).fill(e,n):D(t,r).fill(e):D(t,r)}s.alloc=function(t,r,e){return Ye(null,t,r,e)};function ir(t,r){if(Ir(r),t=D(t,r<0?0:ar(r)|0),!s.TYPED_ARRAY_SUPPORT)for(var e=0;e<r;++e)t[e]=0;return t}s.allocUnsafe=function(t){return ir(null,t)};s.allocUnsafeSlow=function(t){return ir(null,t)};function Ge(t,r,e){if((typeof e!="string"||e==="")&&(e="utf8"),!s.isEncoding(e))throw new TypeError('"encoding" must be a valid string encoding');var n=wr(r,e)|0;t=D(t,n);var o=t.write(r,e);return o!==n&&(t=t.slice(0,o)),t}function nr(t,r){var e=r.length<0?0:ar(r.length)|0;t=D(t,e);for(var n=0;n<e;n+=1)t[n]=r[n]&255;return t}function We(t,r,e,n){if(r.byteLength,e<0||r.byteLength<e)throw new RangeError("'offset' is out of bounds");if(r.byteLength<e+(n||0))throw new RangeError("'length' is out of bounds");return e===void 0&&n===void 0?r=new Uint8Array(r):n===void 0?r=new Uint8Array(r,e):r=new Uint8Array(r,e,n),s.TYPED_ARRAY_SUPPORT?(t=r,t.__proto__=s.prototype):t=nr(t,r),t}function Ke(t,r){if(N(r)){var e=ar(r.length)|0;return t=D(t,e),t.length===0||r.copy(t,0,0,e),t}if(r){if(typeof ArrayBuffer<"u"&&r.buffer instanceof ArrayBuffer||"length"in r)return typeof r.length!="number"||ct(r.length)?D(t,0):nr(t,r);if(r.type==="Buffer"&&Array.isArray(r.data))return nr(t,r.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}function ar(t){if(t>=W())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+W().toString(16)+" bytes");return t|0}s.isBuffer=ut;function N(t){return!!(t!=null&&t._isBuffer)}s.compare=function(r,e){if(!N(r)||!N(e))throw new TypeError("Arguments must be Buffers");if(r===e)return 0;for(var n=r.length,o=e.length,i=0,a=Math.min(n,o);i<a;++i)if(r[i]!==e[i]){n=r[i],o=e[i];break}return n<o?-1:o<n?1:0};s.isEncoding=function(r){switch(String(r).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};s.concat=function(r,e){if(!Array.isArray(r))throw new TypeError('"list" argument must be an Array of Buffers');if(r.length===0)return s.alloc(0);var n;if(e===void 0)for(e=0,n=0;n<r.length;++n)e+=r[n].length;var o=s.allocUnsafe(e),i=0;for(n=0;n<r.length;++n){var a=r[n];if(!N(a))throw new TypeError('"list" argument must be an Array of Buffers');a.copy(o,i),i+=a.length}return o};function wr(t,r){if(N(t))return t.length;if(typeof ArrayBuffer<"u"&&typeof ArrayBuffer.isView=="function"&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;typeof t!="string"&&(t=""+t);var e=t.length;if(e===0)return 0;for(var n=!1;;)switch(r){case"ascii":case"latin1":case"binary":return e;case"utf8":case"utf-8":case void 0:return K(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return e*2;case"hex":return e>>>1;case"base64":return Or(t).length;default:if(n)return K(t).length;r=(""+r).toLowerCase(),n=!0}}s.byteLength=wr;function He(t,r,e){var n=!1;if((r===void 0||r<0)&&(r=0),r>this.length||((e===void 0||e>this.length)&&(e=this.length),e<=0)||(e>>>=0,r>>>=0,e<=r))return"";for(t||(t="utf8");;)switch(t){case"hex":return rt(this,r,e);case"utf8":case"utf-8":return Sr(this,r,e);case"ascii":return Qe(this,r,e);case"latin1":case"binary":return Ze(this,r,e);case"base64":return Je(this,r,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return et(this,r,e);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}s.prototype._isBuffer=!0;function L(t,r,e){var n=t[r];t[r]=t[e],t[e]=n}s.prototype.swap16=function(){var r=this.length;if(r%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<r;e+=2)L(this,e,e+1);return this};s.prototype.swap32=function(){var r=this.length;if(r%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<r;e+=4)L(this,e,e+3),L(this,e+1,e+2);return this};s.prototype.swap64=function(){var r=this.length;if(r%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<r;e+=8)L(this,e,e+7),L(this,e+1,e+6),L(this,e+2,e+5),L(this,e+3,e+4);return this};s.prototype.toString=function(){var r=this.length|0;return r===0?"":arguments.length===0?Sr(this,0,r):He.apply(this,arguments)};s.prototype.equals=function(r){if(!N(r))throw new TypeError("Argument must be a Buffer");return this===r?!0:s.compare(this,r)===0};s.prototype.compare=function(r,e,n,o,i){if(!N(r))throw new TypeError("Argument must be a Buffer");if(e===void 0&&(e=0),n===void 0&&(n=r?r.length:0),o===void 0&&(o=0),i===void 0&&(i=this.length),e<0||n>r.length||o<0||i>this.length)throw new RangeError("out of range index");if(o>=i&&e>=n)return 0;if(o>=i)return-1;if(e>=n)return 1;if(e>>>=0,n>>>=0,o>>>=0,i>>>=0,this===r)return 0;for(var a=i-o,c=n-e,p=Math.min(a,c),d=this.slice(o,i),f=r.slice(e,n),l=0;l<p;++l)if(d[l]!==f[l]){a=d[l],c=f[l];break}return a<c?-1:c<a?1:0};function Nr(t,r,e,n,o){if(t.length===0)return-1;if(typeof e=="string"?(n=e,e=0):e>2147483647?e=2147483647:e<-2147483648&&(e=-2147483648),e=+e,isNaN(e)&&(e=o?0:t.length-1),e<0&&(e=t.length+e),e>=t.length){if(o)return-1;e=t.length-1}else if(e<0)if(o)e=0;else return-1;if(typeof r=="string"&&(r=s.from(r,n)),N(r))return r.length===0?-1:Ar(t,r,e,n,o);if(typeof r=="number")return r=r&255,s.TYPED_ARRAY_SUPPORT&&typeof Uint8Array.prototype.indexOf=="function"?o?Uint8Array.prototype.indexOf.call(t,r,e):Uint8Array.prototype.lastIndexOf.call(t,r,e):Ar(t,[r],e,n,o);throw new TypeError("val must be string, number or Buffer")}function Ar(t,r,e,n,o){var i=1,a=t.length,c=r.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(t.length<2||r.length<2)return-1;i=2,a/=2,c/=2,e/=2}function p(g,y){return i===1?g[y]:g.readUInt16BE(y*i)}var d;if(o){var f=-1;for(d=e;d<a;d++)if(p(t,d)===p(r,f===-1?0:d-f)){if(f===-1&&(f=d),d-f+1===c)return f*i}else f!==-1&&(d-=d-f),f=-1}else for(e+c>a&&(e=a-c),d=e;d>=0;d--){for(var l=!0,h=0;h<c;h++)if(p(t,d+h)!==p(r,h)){l=!1;break}if(l)return d}return-1}s.prototype.includes=function(r,e,n){return this.indexOf(r,e,n)!==-1};s.prototype.indexOf=function(r,e,n){return Nr(this,r,e,n,!0)};s.prototype.lastIndexOf=function(r,e,n){return Nr(this,r,e,n,!1)};function Ve(t,r,e,n){e=Number(e)||0;var o=t.length-e;n?(n=Number(n),n>o&&(n=o)):n=o;var i=r.length;if(i%2!==0)throw new TypeError("Invalid hex string");n>i/2&&(n=i/2);for(var a=0;a<n;++a){var c=parseInt(r.substr(a*2,2),16);if(isNaN(c))return a;t[e+a]=c}return a}function $e(t,r,e,n){return $(K(r,t.length-e),t,e,n)}function Rr(t,r,e,n){return $(at(r),t,e,n)}function ze(t,r,e,n){return Rr(t,r,e,n)}function Xe(t,r,e,n){return $(Or(r),t,e,n)}function qe(t,r,e,n){return $(st(r,t.length-e),t,e,n)}s.prototype.write=function(r,e,n,o){if(e===void 0)o="utf8",n=this.length,e=0;else if(n===void 0&&typeof e=="string")o=e,n=this.length,e=0;else if(isFinite(e))e=e|0,isFinite(n)?(n=n|0,o===void 0&&(o="utf8")):(o=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var i=this.length-e;if((n===void 0||n>i)&&(n=i),r.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");o||(o="utf8");for(var a=!1;;)switch(o){case"hex":return Ve(this,r,e,n);case"utf8":case"utf-8":return $e(this,r,e,n);case"ascii":return Rr(this,r,e,n);case"latin1":case"binary":return ze(this,r,e,n);case"base64":return Xe(this,r,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return qe(this,r,e,n);default:if(a)throw new TypeError("Unknown encoding: "+o);o=(""+o).toLowerCase(),a=!0}};s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Je(t,r,e){return r===0&&e===t.length?Er(t):Er(t.slice(r,e))}function Sr(t,r,e){e=Math.min(t.length,e);for(var n=[],o=r;o<e;){var i=t[o],a=null,c=i>239?4:i>223?3:i>191?2:1;if(o+c<=e){var p,d,f,l;switch(c){case 1:i<128&&(a=i);break;case 2:p=t[o+1],(p&192)===128&&(l=(i&31)<<6|p&63,l>127&&(a=l));break;case 3:p=t[o+1],d=t[o+2],(p&192)===128&&(d&192)===128&&(l=(i&15)<<12|(p&63)<<6|d&63,l>2047&&(l<55296||l>57343)&&(a=l));break;case 4:p=t[o+1],d=t[o+2],f=t[o+3],(p&192)===128&&(d&192)===128&&(f&192)===128&&(l=(i&15)<<18|(p&63)<<12|(d&63)<<6|f&63,l>65535&&l<1114112&&(a=l))}}a===null?(a=65533,c=1):a>65535&&(a-=65536,n.push(a>>>10&1023|55296),a=56320|a&1023),n.push(a),o+=c}return je(n)}var Tr=4096;function je(t){var r=t.length;if(r<=Tr)return String.fromCharCode.apply(String,t);for(var e="",n=0;n<r;)e+=String.fromCharCode.apply(String,t.slice(n,n+=Tr));return e}function Qe(t,r,e){var n="";e=Math.min(t.length,e);for(var o=r;o<e;++o)n+=String.fromCharCode(t[o]&127);return n}function Ze(t,r,e){var n="";e=Math.min(t.length,e);for(var o=r;o<e;++o)n+=String.fromCharCode(t[o]);return n}function rt(t,r,e){var n=t.length;(!r||r<0)&&(r=0),(!e||e<0||e>n)&&(e=n);for(var o="",i=r;i<e;++i)o+=it(t[i]);return o}function et(t,r,e){for(var n=t.slice(r,e),o="",i=0;i<n.length;i+=2)o+=String.fromCharCode(n[i]+n[i+1]*256);return o}s.prototype.slice=function(r,e){var n=this.length;r=~~r,e=e===void 0?n:~~e,r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),e<r&&(e=r);var o;if(s.TYPED_ARRAY_SUPPORT)o=this.subarray(r,e),o.__proto__=s.prototype;else{var i=e-r;o=new s(i,void 0);for(var a=0;a<i;++a)o[a]=this[a+r]}return o};function b(t,r,e){if(t%1!==0||t<0)throw new RangeError("offset is not uint");if(t+r>e)throw new RangeError("Trying to access beyond buffer length")}s.prototype.readUIntLE=function(r,e,n){r=r|0,e=e|0,n||b(r,e,this.length);for(var o=this[r],i=1,a=0;++a<e&&(i*=256);)o+=this[r+a]*i;return o};s.prototype.readUIntBE=function(r,e,n){r=r|0,e=e|0,n||b(r,e,this.length);for(var o=this[r+--e],i=1;e>0&&(i*=256);)o+=this[r+--e]*i;return o};s.prototype.readUInt8=function(r,e){return e||b(r,1,this.length),this[r]};s.prototype.readUInt16LE=function(r,e){return e||b(r,2,this.length),this[r]|this[r+1]<<8};s.prototype.readUInt16BE=function(r,e){return e||b(r,2,this.length),this[r]<<8|this[r+1]};s.prototype.readUInt32LE=function(r,e){return e||b(r,4,this.length),(this[r]|this[r+1]<<8|this[r+2]<<16)+this[r+3]*16777216};s.prototype.readUInt32BE=function(r,e){return e||b(r,4,this.length),this[r]*16777216+(this[r+1]<<16|this[r+2]<<8|this[r+3])};s.prototype.readIntLE=function(r,e,n){r=r|0,e=e|0,n||b(r,e,this.length);for(var o=this[r],i=1,a=0;++a<e&&(i*=256);)o+=this[r+a]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*e)),o};s.prototype.readIntBE=function(r,e,n){r=r|0,e=e|0,n||b(r,e,this.length);for(var o=e,i=1,a=this[r+--o];o>0&&(i*=256);)a+=this[r+--o]*i;return i*=128,a>=i&&(a-=Math.pow(2,8*e)),a};s.prototype.readInt8=function(r,e){return e||b(r,1,this.length),this[r]&128?(255-this[r]+1)*-1:this[r]};s.prototype.readInt16LE=function(r,e){e||b(r,2,this.length);var n=this[r]|this[r+1]<<8;return n&32768?n|4294901760:n};s.prototype.readInt16BE=function(r,e){e||b(r,2,this.length);var n=this[r+1]|this[r]<<8;return n&32768?n|4294901760:n};s.prototype.readInt32LE=function(r,e){return e||b(r,4,this.length),this[r]|this[r+1]<<8|this[r+2]<<16|this[r+3]<<24};s.prototype.readInt32BE=function(r,e){return e||b(r,4,this.length),this[r]<<24|this[r+1]<<16|this[r+2]<<8|this[r+3]};s.prototype.readFloatLE=function(r,e){return e||b(r,4,this.length),z(this,r,!0,23,4)};s.prototype.readFloatBE=function(r,e){return e||b(r,4,this.length),z(this,r,!1,23,4)};s.prototype.readDoubleLE=function(r,e){return e||b(r,8,this.length),z(this,r,!0,52,8)};s.prototype.readDoubleBE=function(r,e){return e||b(r,8,this.length),z(this,r,!1,52,8)};function A(t,r,e,n,o,i){if(!N(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(r>o||r<i)throw new RangeError('"value" argument is out of bounds');if(e+n>t.length)throw new RangeError("Index out of range")}s.prototype.writeUIntLE=function(r,e,n,o){if(r=+r,e=e|0,n=n|0,!o){var i=Math.pow(2,8*n)-1;A(this,r,e,n,i,0)}var a=1,c=0;for(this[e]=r&255;++c<n&&(a*=256);)this[e+c]=r/a&255;return e+n};s.prototype.writeUIntBE=function(r,e,n,o){if(r=+r,e=e|0,n=n|0,!o){var i=Math.pow(2,8*n)-1;A(this,r,e,n,i,0)}var a=n-1,c=1;for(this[e+a]=r&255;--a>=0&&(c*=256);)this[e+a]=r/c&255;return e+n};s.prototype.writeUInt8=function(r,e,n){return r=+r,e=e|0,n||A(this,r,e,1,255,0),s.TYPED_ARRAY_SUPPORT||(r=Math.floor(r)),this[e]=r&255,e+1};function H(t,r,e,n){r<0&&(r=65535+r+1);for(var o=0,i=Math.min(t.length-e,2);o<i;++o)t[e+o]=(r&255<<8*(n?o:1-o))>>>(n?o:1-o)*8}s.prototype.writeUInt16LE=function(r,e,n){return r=+r,e=e|0,n||A(this,r,e,2,65535,0),s.TYPED_ARRAY_SUPPORT?(this[e]=r&255,this[e+1]=r>>>8):H(this,r,e,!0),e+2};s.prototype.writeUInt16BE=function(r,e,n){return r=+r,e=e|0,n||A(this,r,e,2,65535,0),s.TYPED_ARRAY_SUPPORT?(this[e]=r>>>8,this[e+1]=r&255):H(this,r,e,!1),e+2};function V(t,r,e,n){r<0&&(r=4294967295+r+1);for(var o=0,i=Math.min(t.length-e,4);o<i;++o)t[e+o]=r>>>(n?o:3-o)*8&255}s.prototype.writeUInt32LE=function(r,e,n){return r=+r,e=e|0,n||A(this,r,e,4,4294967295,0),s.TYPED_ARRAY_SUPPORT?(this[e+3]=r>>>24,this[e+2]=r>>>16,this[e+1]=r>>>8,this[e]=r&255):V(this,r,e,!0),e+4};s.prototype.writeUInt32BE=function(r,e,n){return r=+r,e=e|0,n||A(this,r,e,4,4294967295,0),s.TYPED_ARRAY_SUPPORT?(this[e]=r>>>24,this[e+1]=r>>>16,this[e+2]=r>>>8,this[e+3]=r&255):V(this,r,e,!1),e+4};s.prototype.writeIntLE=function(r,e,n,o){if(r=+r,e=e|0,!o){var i=Math.pow(2,8*n-1);A(this,r,e,n,i-1,-i)}var a=0,c=1,p=0;for(this[e]=r&255;++a<n&&(c*=256);)r<0&&p===0&&this[e+a-1]!==0&&(p=1),this[e+a]=(r/c>>0)-p&255;return e+n};s.prototype.writeIntBE=function(r,e,n,o){if(r=+r,e=e|0,!o){var i=Math.pow(2,8*n-1);A(this,r,e,n,i-1,-i)}var a=n-1,c=1,p=0;for(this[e+a]=r&255;--a>=0&&(c*=256);)r<0&&p===0&&this[e+a+1]!==0&&(p=1),this[e+a]=(r/c>>0)-p&255;return e+n};s.prototype.writeInt8=function(r,e,n){return r=+r,e=e|0,n||A(this,r,e,1,127,-128),s.TYPED_ARRAY_SUPPORT||(r=Math.floor(r)),r<0&&(r=255+r+1),this[e]=r&255,e+1};s.prototype.writeInt16LE=function(r,e,n){return r=+r,e=e|0,n||A(this,r,e,2,32767,-32768),s.TYPED_ARRAY_SUPPORT?(this[e]=r&255,this[e+1]=r>>>8):H(this,r,e,!0),e+2};s.prototype.writeInt16BE=function(r,e,n){return r=+r,e=e|0,n||A(this,r,e,2,32767,-32768),s.TYPED_ARRAY_SUPPORT?(this[e]=r>>>8,this[e+1]=r&255):H(this,r,e,!1),e+2};s.prototype.writeInt32LE=function(r,e,n){return r=+r,e=e|0,n||A(this,r,e,4,2147483647,-2147483648),s.TYPED_ARRAY_SUPPORT?(this[e]=r&255,this[e+1]=r>>>8,this[e+2]=r>>>16,this[e+3]=r>>>24):V(this,r,e,!0),e+4};s.prototype.writeInt32BE=function(r,e,n){return r=+r,e=e|0,n||A(this,r,e,4,2147483647,-2147483648),r<0&&(r=4294967295+r+1),s.TYPED_ARRAY_SUPPORT?(this[e]=r>>>24,this[e+1]=r>>>16,this[e+2]=r>>>8,this[e+3]=r&255):V(this,r,e,!1),e+4};function Br(t,r,e,n,o,i){if(e+n>t.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function Dr(t,r,e,n,o){return o||Br(t,r,e,4,34028234663852886e22,-34028234663852886e22),Ur(t,r,e,n,23,4),e+4}s.prototype.writeFloatLE=function(r,e,n){return Dr(this,r,e,!0,n)};s.prototype.writeFloatBE=function(r,e,n){return Dr(this,r,e,!1,n)};function Cr(t,r,e,n,o){return o||Br(t,r,e,8,17976931348623157e292,-17976931348623157e292),Ur(t,r,e,n,52,8),e+8}s.prototype.writeDoubleLE=function(r,e,n){return Cr(this,r,e,!0,n)};s.prototype.writeDoubleBE=function(r,e,n){return Cr(this,r,e,!1,n)};s.prototype.copy=function(r,e,n,o){if(n||(n=0),!o&&o!==0&&(o=this.length),e>=r.length&&(e=r.length),e||(e=0),o>0&&o<n&&(o=n),o===n||r.length===0||this.length===0)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("sourceStart out of bounds");if(o<0)throw new RangeError("sourceEnd out of bounds");o>this.length&&(o=this.length),r.length-e<o-n&&(o=r.length-e+n);var i=o-n,a;if(this===r&&n<e&&e<o)for(a=i-1;a>=0;--a)r[a+e]=this[a+n];else if(i<1e3||!s.TYPED_ARRAY_SUPPORT)for(a=0;a<i;++a)r[a+e]=this[a+n];else Uint8Array.prototype.set.call(r,this.subarray(n,n+i),e);return i};s.prototype.fill=function(r,e,n,o){if(typeof r=="string"){if(typeof e=="string"?(o=e,e=0,n=this.length):typeof n=="string"&&(o=n,n=this.length),r.length===1){var i=r.charCodeAt(0);i<256&&(r=i)}if(o!==void 0&&typeof o!="string")throw new TypeError("encoding must be a string");if(typeof o=="string"&&!s.isEncoding(o))throw new TypeError("Unknown encoding: "+o)}else typeof r=="number"&&(r=r&255);if(e<0||this.length<e||this.length<n)throw new RangeError("Out of range index");if(n<=e)return this;e=e>>>0,n=n===void 0?this.length:n>>>0,r||(r=0);var a;if(typeof r=="number")for(a=e;a<n;++a)this[a]=r;else{var c=N(r)?r:K(new s(r,o).toString()),p=c.length;for(a=0;a<n-e;++a)this[a+e]=c[a%p]}return this};var tt=/[^+\/0-9A-Za-z-_]/g;function nt(t){if(t=ot(t).replace(tt,""),t.length<2)return"";for(;t.length%4!==0;)t=t+"=";return t}function ot(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function it(t){return t<16?"0"+t.toString(16):t.toString(16)}function K(t,r){r=r||1/0;for(var e,n=t.length,o=null,i=[],a=0;a<n;++a){if(e=t.charCodeAt(a),e>55295&&e<57344){if(!o){if(e>56319){(r-=3)>-1&&i.push(239,191,189);continue}else if(a+1===n){(r-=3)>-1&&i.push(239,191,189);continue}o=e;continue}if(e<56320){(r-=3)>-1&&i.push(239,191,189),o=e;continue}e=(o-55296<<10|e-56320)+65536}else o&&(r-=3)>-1&&i.push(239,191,189);if(o=null,e<128){if((r-=1)<0)break;i.push(e)}else if(e<2048){if((r-=2)<0)break;i.push(e>>6|192,e&63|128)}else if(e<65536){if((r-=3)<0)break;i.push(e>>12|224,e>>6&63|128,e&63|128)}else if(e<1114112){if((r-=4)<0)break;i.push(e>>18|240,e>>12&63|128,e>>6&63|128,e&63|128)}else throw new Error("Invalid code point")}return i}function at(t){for(var r=[],e=0;e<t.length;++e)r.push(t.charCodeAt(e)&255);return r}function st(t,r){for(var e,n,o,i=[],a=0;a<t.length&&!((r-=2)<0);++a)e=t.charCodeAt(a),n=e>>8,o=e%256,i.push(o),i.push(n);return i}function Or(t){return Me(nt(t))}function $(t,r,e,n){for(var o=0;o<n&&!(o+e>=r.length||o>=t.length);++o)r[o+e]=t[o];return o}function ct(t){return t!==t}function ut(t){return t!=null&&(!!t._isBuffer||kr(t)||pt(t))}function kr(t){return!!t.constructor&&typeof t.constructor.isBuffer=="function"&&t.constructor.isBuffer(t)}function pt(t){return typeof t.readFloatLE=="function"&&typeof t.slice=="function"&&kr(t.slice(0,0))}function z(t,r,e,n,o){var i,a,c=o*8-n-1,p=(1<<c)-1,d=p>>1,f=-7,l=e?o-1:0,h=e?-1:1,g=t[r+l];for(l+=h,i=g&(1<<-f)-1,g>>=-f,f+=c;f>0;i=i*256+t[r+l],l+=h,f-=8);for(a=i&(1<<-f)-1,i>>=-f,f+=n;f>0;a=a*256+t[r+l],l+=h,f-=8);if(i===0)i=1-d;else{if(i===p)return a?NaN:(g?-1:1)*(1/0);a=a+Math.pow(2,n),i=i-d}return(g?-1:1)*a*Math.pow(2,i-n)}function Ur(t,r,e,n,o,i){var a,c,p,d=i*8-o-1,f=(1<<d)-1,l=f>>1,h=o===23?Math.pow(2,-24)-Math.pow(2,-77):0,g=n?0:i-1,y=n?1:-1,tr=r<0||r===0&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(c=isNaN(r)?1:0,a=f):(a=Math.floor(Math.log(r)/Math.LN2),r*(p=Math.pow(2,-a))<1&&(a--,p*=2),a+l>=1?r+=h/p:r+=h*Math.pow(2,1-l),r*p>=2&&(a++,p/=2),a+l>=f?(c=0,a=f):a+l>=1?(c=(r*p-1)*Math.pow(2,o),a=a+l):(c=r*Math.pow(2,l-1)*Math.pow(2,o),a=0));o>=8;t[e+g]=c&255,g+=y,c/=256,o-=8);for(a=a<<o|c,d+=o;d>0;t[e+g]=a&255,g+=y,a/=256,d-=8);t[e+g-y]|=tr*128}import*as x from"ethereumjs-util";import Tu from"algosdk";import*as cn from"bs58";import Wo from"algosdk";import Nn,{decodeAddress as Rn,encodeAddress as Sn}from"algosdk";var R=[],I=[],lt=typeof Uint8Array<"u"?Uint8Array:Array,cr=!1;function vr(){cr=!0;for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r=0,e=t.length;r<e;++r)R[r]=t[r],I[t.charCodeAt(r)]=r;I[45]=62,I[95]=63}function mt(t){cr||vr();var r,e,n,o,i,a,c=t.length;if(c%4>0)throw new Error("Invalid string. Length must be a multiple of 4");i=t[c-2]==="="?2:t[c-1]==="="?1:0,a=new lt(c*3/4-i),n=i>0?c-4:c;var p=0;for(r=0,e=0;r<n;r+=4,e+=3)o=I[t.charCodeAt(r)]<<18|I[t.charCodeAt(r+1)]<<12|I[t.charCodeAt(r+2)]<<6|I[t.charCodeAt(r+3)],a[p++]=o>>16&255,a[p++]=o>>8&255,a[p++]=o&255;return i===2?(o=I[t.charCodeAt(r)]<<2|I[t.charCodeAt(r+1)]>>4,a[p++]=o&255):i===1&&(o=I[t.charCodeAt(r)]<<10|I[t.charCodeAt(r+1)]<<4|I[t.charCodeAt(r+2)]>>2,a[p++]=o>>8&255,a[p++]=o&255),a}function dt(t){return R[t>>18&63]+R[t>>12&63]+R[t>>6&63]+R[t&63]}function ft(t,r,e){for(var n,o=[],i=r;i<e;i+=3)n=(t[i]<<16)+(t[i+1]<<8)+t[i+2],o.push(dt(n));return o.join("")}function Pr(t){cr||vr();for(var r,e=t.length,n=e%3,o="",i=[],a=16383,c=0,p=e-n;c<p;c+=a)i.push(ft(t,c,c+a>p?p:c+a));return n===1?(r=t[e-1],o+=R[r>>2],o+=R[r<<4&63],o+="=="):n===2&&(r=(t[e-2]<<8)+t[e-1],o+=R[r>>10],o+=R[r>>4&63],o+=R[r<<2&63],o+="="),i.push(o),i.join("")}function J(t,r,e,n,o){var i,a,c=o*8-n-1,p=(1<<c)-1,d=p>>1,f=-7,l=e?o-1:0,h=e?-1:1,g=t[r+l];for(l+=h,i=g&(1<<-f)-1,g>>=-f,f+=c;f>0;i=i*256+t[r+l],l+=h,f-=8);for(a=i&(1<<-f)-1,i>>=-f,f+=n;f>0;a=a*256+t[r+l],l+=h,f-=8);if(i===0)i=1-d;else{if(i===p)return a?NaN:(g?-1:1)*(1/0);a=a+Math.pow(2,n),i=i-d}return(g?-1:1)*a*Math.pow(2,i-n)}function Fr(t,r,e,n,o,i){var a,c,p,d=i*8-o-1,f=(1<<d)-1,l=f>>1,h=o===23?Math.pow(2,-24)-Math.pow(2,-77):0,g=n?0:i-1,y=n?1:-1,tr=r<0||r===0&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(c=isNaN(r)?1:0,a=f):(a=Math.floor(Math.log(r)/Math.LN2),r*(p=Math.pow(2,-a))<1&&(a--,p*=2),a+l>=1?r+=h/p:r+=h*Math.pow(2,1-l),r*p>=2&&(a++,p/=2),a+l>=f?(c=0,a=f):a+l>=1?(c=(r*p-1)*Math.pow(2,o),a=a+l):(c=r*Math.pow(2,l-1)*Math.pow(2,o),a=0));o>=8;t[e+g]=c&255,g+=y,c/=256,o-=8);for(a=a<<o|c,d+=o;d>0;t[e+g]=a&255,g+=y,a/=256,d-=8);t[e+g-y]|=tr*128}var gt={}.toString,Yr=Array.isArray||function(t){return gt.call(t)=="[object Array]"};var ht=50;u.TYPED_ARRAY_SUPPORT=globalThis.TYPED_ARRAY_SUPPORT!==void 0?globalThis.TYPED_ARRAY_SUPPORT:!0;var Tn=X();function X(){return u.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function C(t,r){if(X()<r)throw new RangeError("Invalid typed array length");return u.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(r),t.__proto__=u.prototype):(t===null&&(t=new u(r)),t.length=r),t}function u(t,r,e){if(!u.TYPED_ARRAY_SUPPORT&&!(this instanceof u))return new u(t,r,e);if(typeof t=="number"){if(typeof r=="string")throw new Error("If encoding is specified then the first argument must be a string");return ur(this,t)}return Gr(this,t,r,e)}u.poolSize=8192;u._augment=function(t){return t.__proto__=u.prototype,t};function Gr(t,r,e,n){if(typeof r=="number")throw new TypeError('"value" argument must not be a number');return typeof ArrayBuffer<"u"&&r instanceof ArrayBuffer?Et(t,r,e,n):typeof r=="string"?bt(t,r,e):At(t,r)}u.from=function(t,r,e){return Gr(null,t,r,e)};u.TYPED_ARRAY_SUPPORT&&(u.prototype.__proto__=Uint8Array.prototype,u.__proto__=Uint8Array);function Wr(t){if(typeof t!="number")throw new TypeError('"size" argument must be a number');if(t<0)throw new RangeError('"size" argument must not be negative')}function xt(t,r,e,n){return Wr(r),r<=0?C(t,r):e!==void 0?typeof n=="string"?C(t,r).fill(e,n):C(t,r).fill(e):C(t,r)}u.alloc=function(t,r,e){return xt(null,t,r,e)};function ur(t,r){if(Wr(r),t=C(t,r<0?0:pr(r)|0),!u.TYPED_ARRAY_SUPPORT)for(var e=0;e<r;++e)t[e]=0;return t}u.allocUnsafe=function(t){return ur(null,t)};u.allocUnsafeSlow=function(t){return ur(null,t)};function bt(t,r,e){if((typeof e!="string"||e==="")&&(e="utf8"),!u.isEncoding(e))throw new TypeError('"encoding" must be a valid string encoding');var n=Kr(r,e)|0;t=C(t,n);var o=t.write(r,e);return o!==n&&(t=t.slice(0,o)),t}function sr(t,r){var e=r.length<0?0:pr(r.length)|0;t=C(t,e);for(var n=0;n<e;n+=1)t[n]=r[n]&255;return t}function Et(t,r,e,n){if(r.byteLength,e<0||r.byteLength<e)throw new RangeError("'offset' is out of bounds");if(r.byteLength<e+(n||0))throw new RangeError("'length' is out of bounds");return e===void 0&&n===void 0?r=new Uint8Array(r):n===void 0?r=new Uint8Array(r,e):r=new Uint8Array(r,e,n),u.TYPED_ARRAY_SUPPORT?(t=r,t.__proto__=u.prototype):t=sr(t,r),t}function At(t,r){if(S(r)){var e=pr(r.length)|0;return t=C(t,e),t.length===0||r.copy(t,0,0,e),t}if(r){if(typeof ArrayBuffer<"u"&&r.buffer instanceof ArrayBuffer||"length"in r)return typeof r.length!="number"||Ft(r.length)?C(t,0):sr(t,r);if(r.type==="Buffer"&&Yr(r.data))return sr(t,r.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}function pr(t){if(t>=X())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+X().toString(16)+" bytes");return t|0}u.isBuffer=Yt;function S(t){return!!(t!=null&&t._isBuffer)}u.compare=function(r,e){if(!S(r)||!S(e))throw new TypeError("Arguments must be Buffers");if(r===e)return 0;for(var n=r.length,o=e.length,i=0,a=Math.min(n,o);i<a;++i)if(r[i]!==e[i]){n=r[i],o=e[i];break}return n<o?-1:o<n?1:0};u.isEncoding=function(r){switch(String(r).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};u.concat=function(r,e){if(!Yr(r))throw new TypeError('"list" argument must be an Array of Buffers');if(r.length===0)return u.alloc(0);var n;if(e===void 0)for(e=0,n=0;n<r.length;++n)e+=r[n].length;var o=u.allocUnsafe(e),i=0;for(n=0;n<r.length;++n){var a=r[n];if(!S(a))throw new TypeError('"list" argument must be an Array of Buffers');a.copy(o,i),i+=a.length}return o};function Kr(t,r){if(S(t))return t.length;if(typeof ArrayBuffer<"u"&&typeof ArrayBuffer.isView=="function"&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;typeof t!="string"&&(t=""+t);var e=t.length;if(e===0)return 0;for(var n=!1;;)switch(r){case"ascii":case"latin1":case"binary":return e;case"utf8":case"utf-8":case void 0:return q(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return e*2;case"hex":return e>>>1;case"base64":return Jr(t).length;default:if(n)return q(t).length;r=(""+r).toLowerCase(),n=!0}}u.byteLength=Kr;function Tt(t,r,e){var n=!1;if((r===void 0||r<0)&&(r=0),r>this.length||((e===void 0||e>this.length)&&(e=this.length),e<=0)||(e>>>=0,r>>>=0,e<=r))return"";for(t||(t="utf8");;)switch(t){case"hex":return Ct(this,r,e);case"utf8":case"utf-8":return $r(this,r,e);case"ascii":return Bt(this,r,e);case"latin1":case"binary":return Dt(this,r,e);case"base64":return Rt(this,r,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ot(this,r,e);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}u.prototype._isBuffer=!0;function M(t,r,e){var n=t[r];t[r]=t[e],t[e]=n}u.prototype.swap16=function(){var r=this.length;if(r%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<r;e+=2)M(this,e,e+1);return this};u.prototype.swap32=function(){var r=this.length;if(r%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<r;e+=4)M(this,e,e+3),M(this,e+1,e+2);return this};u.prototype.swap64=function(){var r=this.length;if(r%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<r;e+=8)M(this,e,e+7),M(this,e+1,e+6),M(this,e+2,e+5),M(this,e+3,e+4);return this};u.prototype.toString=function(){var r=this.length|0;return r===0?"":arguments.length===0?$r(this,0,r):Tt.apply(this,arguments)};u.prototype.equals=function(r){if(!S(r))throw new TypeError("Argument must be a Buffer");return this===r?!0:u.compare(this,r)===0};u.prototype.inspect=function(){var r="",e=ht;return this.length>0&&(r=this.toString("hex",0,e).match(/.{2}/g).join(" "),this.length>e&&(r+=" ... ")),"<Buffer "+r+">"};u.prototype.compare=function(r,e,n,o,i){if(!S(r))throw new TypeError("Argument must be a Buffer");if(e===void 0&&(e=0),n===void 0&&(n=r?r.length:0),o===void 0&&(o=0),i===void 0&&(i=this.length),e<0||n>r.length||o<0||i>this.length)throw new RangeError("out of range index");if(o>=i&&e>=n)return 0;if(o>=i)return-1;if(e>=n)return 1;if(e>>>=0,n>>>=0,o>>>=0,i>>>=0,this===r)return 0;for(var a=i-o,c=n-e,p=Math.min(a,c),d=this.slice(o,i),f=r.slice(e,n),l=0;l<p;++l)if(d[l]!==f[l]){a=d[l],c=f[l];break}return a<c?-1:c<a?1:0};function Hr(t,r,e,n,o){if(t.length===0)return-1;if(typeof e=="string"?(n=e,e=0):e>2147483647?e=2147483647:e<-2147483648&&(e=-2147483648),e=+e,isNaN(e)&&(e=o?0:t.length-1),e<0&&(e=t.length+e),e>=t.length){if(o)return-1;e=t.length-1}else if(e<0)if(o)e=0;else return-1;if(typeof r=="string"&&(r=u.from(r,n)),S(r))return r.length===0?-1:Lr(t,r,e,n,o);if(typeof r=="number")return r=r&255,u.TYPED_ARRAY_SUPPORT&&typeof Uint8Array.prototype.indexOf=="function"?o?Uint8Array.prototype.indexOf.call(t,r,e):Uint8Array.prototype.lastIndexOf.call(t,r,e):Lr(t,[r],e,n,o);throw new TypeError("val must be string, number or Buffer")}function Lr(t,r,e,n,o){var i=1,a=t.length,c=r.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(t.length<2||r.length<2)return-1;i=2,a/=2,c/=2,e/=2}function p(g,y){return i===1?g[y]:g.readUInt16BE(y*i)}var d;if(o){var f=-1;for(d=e;d<a;d++)if(p(t,d)===p(r,f===-1?0:d-f)){if(f===-1&&(f=d),d-f+1===c)return f*i}else f!==-1&&(d-=d-f),f=-1}else for(e+c>a&&(e=a-c),d=e;d>=0;d--){for(var l=!0,h=0;h<c;h++)if(p(t,d+h)!==p(r,h)){l=!1;break}if(l)return d}return-1}u.prototype.includes=function(r,e,n){return this.indexOf(r,e,n)!==-1};u.prototype.indexOf=function(r,e,n){return Hr(this,r,e,n,!0)};u.prototype.lastIndexOf=function(r,e,n){return Hr(this,r,e,n,!1)};function yt(t,r,e,n){e=Number(e)||0;var o=t.length-e;n?(n=Number(n),n>o&&(n=o)):n=o;var i=r.length;if(i%2!==0)throw new TypeError("Invalid hex string");n>i/2&&(n=i/2);for(var a=0;a<n;++a){var c=parseInt(r.substr(a*2,2),16);if(isNaN(c))return a;t[e+a]=c}return a}function _t(t,r,e,n){return Z(q(r,t.length-e),t,e,n)}function Vr(t,r,e,n){return Z(Mt(r),t,e,n)}function It(t,r,e,n){return Vr(t,r,e,n)}function wt(t,r,e,n){return Z(Jr(r),t,e,n)}function Nt(t,r,e,n){return Z(vt(r,t.length-e),t,e,n)}u.prototype.write=function(r,e,n,o){if(e===void 0)o="utf8",n=this.length,e=0;else if(n===void 0&&typeof e=="string")o=e,n=this.length,e=0;else if(isFinite(e))e=e|0,isFinite(n)?(n=n|0,o===void 0&&(o="utf8")):(o=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var i=this.length-e;if((n===void 0||n>i)&&(n=i),r.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");o||(o="utf8");for(var a=!1;;)switch(o){case"hex":return yt(this,r,e,n);case"utf8":case"utf-8":return _t(this,r,e,n);case"ascii":return Vr(this,r,e,n);case"latin1":case"binary":return It(this,r,e,n);case"base64":return wt(this,r,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Nt(this,r,e,n);default:if(a)throw new TypeError("Unknown encoding: "+o);o=(""+o).toLowerCase(),a=!0}};u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Rt(t,r,e){return r===0&&e===t.length?Pr(t):Pr(t.slice(r,e))}function $r(t,r,e){e=Math.min(t.length,e);for(var n=[],o=r;o<e;){var i=t[o],a=null,c=i>239?4:i>223?3:i>191?2:1;if(o+c<=e){var p,d,f,l;switch(c){case 1:i<128&&(a=i);break;case 2:p=t[o+1],(p&192)===128&&(l=(i&31)<<6|p&63,l>127&&(a=l));break;case 3:p=t[o+1],d=t[o+2],(p&192)===128&&(d&192)===128&&(l=(i&15)<<12|(p&63)<<6|d&63,l>2047&&(l<55296||l>57343)&&(a=l));break;case 4:p=t[o+1],d=t[o+2],f=t[o+3],(p&192)===128&&(d&192)===128&&(f&192)===128&&(l=(i&15)<<18|(p&63)<<12|(d&63)<<6|f&63,l>65535&&l<1114112&&(a=l))}}a===null?(a=65533,c=1):a>65535&&(a-=65536,n.push(a>>>10&1023|55296),a=56320|a&1023),n.push(a),o+=c}return St(n)}var Mr=4096;function St(t){var r=t.length;if(r<=Mr)return String.fromCharCode.apply(String,t);for(var e="",n=0;n<r;)e+=String.fromCharCode.apply(String,t.slice(n,n+=Mr));return e}function Bt(t,r,e){var n="";e=Math.min(t.length,e);for(var o=r;o<e;++o)n+=String.fromCharCode(t[o]&127);return n}function Dt(t,r,e){var n="";e=Math.min(t.length,e);for(var o=r;o<e;++o)n+=String.fromCharCode(t[o]);return n}function Ct(t,r,e){var n=t.length;(!r||r<0)&&(r=0),(!e||e<0||e>n)&&(e=n);for(var o="",i=r;i<e;++i)o+=Lt(t[i]);return o}function Ot(t,r,e){for(var n=t.slice(r,e),o="",i=0;i<n.length;i+=2)o+=String.fromCharCode(n[i]+n[i+1]*256);return o}u.prototype.slice=function(r,e){var n=this.length;r=~~r,e=e===void 0?n:~~e,r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),e<r&&(e=r);var o;if(u.TYPED_ARRAY_SUPPORT)o=this.subarray(r,e),o.__proto__=u.prototype;else{var i=e-r;o=new u(i,void 0);for(var a=0;a<i;++a)o[a]=this[a+r]}return o};function E(t,r,e){if(t%1!==0||t<0)throw new RangeError("offset is not uint");if(t+r>e)throw new RangeError("Trying to access beyond buffer length")}u.prototype.readUIntLE=function(r,e,n){r=r|0,e=e|0,n||E(r,e,this.length);for(var o=this[r],i=1,a=0;++a<e&&(i*=256);)o+=this[r+a]*i;return o};u.prototype.readUIntBE=function(r,e,n){r=r|0,e=e|0,n||E(r,e,this.length);for(var o=this[r+--e],i=1;e>0&&(i*=256);)o+=this[r+--e]*i;return o};u.prototype.readUInt8=function(r,e){return e||E(r,1,this.length),this[r]};u.prototype.readUInt16LE=function(r,e){return e||E(r,2,this.length),this[r]|this[r+1]<<8};u.prototype.readUInt16BE=function(r,e){return e||E(r,2,this.length),this[r]<<8|this[r+1]};u.prototype.readUInt32LE=function(r,e){return e||E(r,4,this.length),(this[r]|this[r+1]<<8|this[r+2]<<16)+this[r+3]*16777216};u.prototype.readUInt32BE=function(r,e){return e||E(r,4,this.length),this[r]*16777216+(this[r+1]<<16|this[r+2]<<8|this[r+3])};u.prototype.readIntLE=function(r,e,n){r=r|0,e=e|0,n||E(r,e,this.length);for(var o=this[r],i=1,a=0;++a<e&&(i*=256);)o+=this[r+a]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*e)),o};u.prototype.readIntBE=function(r,e,n){r=r|0,e=e|0,n||E(r,e,this.length);for(var o=e,i=1,a=this[r+--o];o>0&&(i*=256);)a+=this[r+--o]*i;return i*=128,a>=i&&(a-=Math.pow(2,8*e)),a};u.prototype.readInt8=function(r,e){return e||E(r,1,this.length),this[r]&128?(255-this[r]+1)*-1:this[r]};u.prototype.readInt16LE=function(r,e){e||E(r,2,this.length);var n=this[r]|this[r+1]<<8;return n&32768?n|4294901760:n};u.prototype.readInt16BE=function(r,e){e||E(r,2,this.length);var n=this[r+1]|this[r]<<8;return n&32768?n|4294901760:n};u.prototype.readInt32LE=function(r,e){return e||E(r,4,this.length),this[r]|this[r+1]<<8|this[r+2]<<16|this[r+3]<<24};u.prototype.readInt32BE=function(r,e){return e||E(r,4,this.length),this[r]<<24|this[r+1]<<16|this[r+2]<<8|this[r+3]};u.prototype.readFloatLE=function(r,e){return e||E(r,4,this.length),J(this,r,!0,23,4)};u.prototype.readFloatBE=function(r,e){return e||E(r,4,this.length),J(this,r,!1,23,4)};u.prototype.readDoubleLE=function(r,e){return e||E(r,8,this.length),J(this,r,!0,52,8)};u.prototype.readDoubleBE=function(r,e){return e||E(r,8,this.length),J(this,r,!1,52,8)};function T(t,r,e,n,o,i){if(!S(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(r>o||r<i)throw new RangeError('"value" argument is out of bounds');if(e+n>t.length)throw new RangeError("Index out of range")}u.prototype.writeUIntLE=function(r,e,n,o){if(r=+r,e=e|0,n=n|0,!o){var i=Math.pow(2,8*n)-1;T(this,r,e,n,i,0)}var a=1,c=0;for(this[e]=r&255;++c<n&&(a*=256);)this[e+c]=r/a&255;return e+n};u.prototype.writeUIntBE=function(r,e,n,o){if(r=+r,e=e|0,n=n|0,!o){var i=Math.pow(2,8*n)-1;T(this,r,e,n,i,0)}var a=n-1,c=1;for(this[e+a]=r&255;--a>=0&&(c*=256);)this[e+a]=r/c&255;return e+n};u.prototype.writeUInt8=function(r,e,n){return r=+r,e=e|0,n||T(this,r,e,1,255,0),u.TYPED_ARRAY_SUPPORT||(r=Math.floor(r)),this[e]=r&255,e+1};function j(t,r,e,n){r<0&&(r=65535+r+1);for(var o=0,i=Math.min(t.length-e,2);o<i;++o)t[e+o]=(r&255<<8*(n?o:1-o))>>>(n?o:1-o)*8}u.prototype.writeUInt16LE=function(r,e,n){return r=+r,e=e|0,n||T(this,r,e,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[e]=r&255,this[e+1]=r>>>8):j(this,r,e,!0),e+2};u.prototype.writeUInt16BE=function(r,e,n){return r=+r,e=e|0,n||T(this,r,e,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[e]=r>>>8,this[e+1]=r&255):j(this,r,e,!1),e+2};function Q(t,r,e,n){r<0&&(r=4294967295+r+1);for(var o=0,i=Math.min(t.length-e,4);o<i;++o)t[e+o]=r>>>(n?o:3-o)*8&255}u.prototype.writeUInt32LE=function(r,e,n){return r=+r,e=e|0,n||T(this,r,e,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[e+3]=r>>>24,this[e+2]=r>>>16,this[e+1]=r>>>8,this[e]=r&255):Q(this,r,e,!0),e+4};u.prototype.writeUInt32BE=function(r,e,n){return r=+r,e=e|0,n||T(this,r,e,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[e]=r>>>24,this[e+1]=r>>>16,this[e+2]=r>>>8,this[e+3]=r&255):Q(this,r,e,!1),e+4};u.prototype.writeIntLE=function(r,e,n,o){if(r=+r,e=e|0,!o){var i=Math.pow(2,8*n-1);T(this,r,e,n,i-1,-i)}var a=0,c=1,p=0;for(this[e]=r&255;++a<n&&(c*=256);)r<0&&p===0&&this[e+a-1]!==0&&(p=1),this[e+a]=(r/c>>0)-p&255;return e+n};u.prototype.writeIntBE=function(r,e,n,o){if(r=+r,e=e|0,!o){var i=Math.pow(2,8*n-1);T(this,r,e,n,i-1,-i)}var a=n-1,c=1,p=0;for(this[e+a]=r&255;--a>=0&&(c*=256);)r<0&&p===0&&this[e+a+1]!==0&&(p=1),this[e+a]=(r/c>>0)-p&255;return e+n};u.prototype.writeInt8=function(r,e,n){return r=+r,e=e|0,n||T(this,r,e,1,127,-128),u.TYPED_ARRAY_SUPPORT||(r=Math.floor(r)),r<0&&(r=255+r+1),this[e]=r&255,e+1};u.prototype.writeInt16LE=function(r,e,n){return r=+r,e=e|0,n||T(this,r,e,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[e]=r&255,this[e+1]=r>>>8):j(this,r,e,!0),e+2};u.prototype.writeInt16BE=function(r,e,n){return r=+r,e=e|0,n||T(this,r,e,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[e]=r>>>8,this[e+1]=r&255):j(this,r,e,!1),e+2};u.prototype.writeInt32LE=function(r,e,n){return r=+r,e=e|0,n||T(this,r,e,4,2147483647,-2147483648),u.TYPED_ARRAY_SUPPORT?(this[e]=r&255,this[e+1]=r>>>8,this[e+2]=r>>>16,this[e+3]=r>>>24):Q(this,r,e,!0),e+4};u.prototype.writeInt32BE=function(r,e,n){return r=+r,e=e|0,n||T(this,r,e,4,2147483647,-2147483648),r<0&&(r=4294967295+r+1),u.TYPED_ARRAY_SUPPORT?(this[e]=r>>>24,this[e+1]=r>>>16,this[e+2]=r>>>8,this[e+3]=r&255):Q(this,r,e,!1),e+4};function zr(t,r,e,n,o,i){if(e+n>t.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function Xr(t,r,e,n,o){return o||zr(t,r,e,4),Fr(t,r,e,n,23,4),e+4}u.prototype.writeFloatLE=function(r,e,n){return Xr(this,r,e,!0,n)};u.prototype.writeFloatBE=function(r,e,n){return Xr(this,r,e,!1,n)};function qr(t,r,e,n,o){return o||zr(t,r,e,8),Fr(t,r,e,n,52,8),e+8}u.prototype.writeDoubleLE=function(r,e,n){return qr(this,r,e,!0,n)};u.prototype.writeDoubleBE=function(r,e,n){return qr(this,r,e,!1,n)};u.prototype.copy=function(r,e,n,o){if(n||(n=0),!o&&o!==0&&(o=this.length),e>=r.length&&(e=r.length),e||(e=0),o>0&&o<n&&(o=n),o===n||r.length===0||this.length===0)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("sourceStart out of bounds");if(o<0)throw new RangeError("sourceEnd out of bounds");o>this.length&&(o=this.length),r.length-e<o-n&&(o=r.length-e+n);var i=o-n,a;if(this===r&&n<e&&e<o)for(a=i-1;a>=0;--a)r[a+e]=this[a+n];else if(i<1e3||!u.TYPED_ARRAY_SUPPORT)for(a=0;a<i;++a)r[a+e]=this[a+n];else Uint8Array.prototype.set.call(r,this.subarray(n,n+i),e);return i};u.prototype.fill=function(r,e,n,o){if(typeof r=="string"){if(typeof e=="string"?(o=e,e=0,n=this.length):typeof n=="string"&&(o=n,n=this.length),r.length===1){var i=r.charCodeAt(0);i<256&&(r=i)}if(o!==void 0&&typeof o!="string")throw new TypeError("encoding must be a string");if(typeof o=="string"&&!u.isEncoding(o))throw new TypeError("Unknown encoding: "+o)}else typeof r=="number"&&(r=r&255);if(e<0||this.length<e||this.length<n)throw new RangeError("Out of range index");if(n<=e)return this;e=e>>>0,n=n===void 0?this.length:n>>>0,r||(r=0);var a;if(typeof r=="number")for(a=e;a<n;++a)this[a]=r;else{var c=S(r)?r:q(new u(r,o).toString()),p=c.length;for(a=0;a<n-e;++a)this[a+e]=c[a%p]}return this};var kt=/[^+\/0-9A-Za-z-_]/g;function Ut(t){if(t=Pt(t).replace(kt,""),t.length<2)return"";for(;t.length%4!==0;)t=t+"=";return t}function Pt(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function Lt(t){return t<16?"0"+t.toString(16):t.toString(16)}function q(t,r){r=r||1/0;for(var e,n=t.length,o=null,i=[],a=0;a<n;++a){if(e=t.charCodeAt(a),e>55295&&e<57344){if(!o){if(e>56319){(r-=3)>-1&&i.push(239,191,189);continue}else if(a+1===n){(r-=3)>-1&&i.push(239,191,189);continue}o=e;continue}if(e<56320){(r-=3)>-1&&i.push(239,191,189),o=e;continue}e=(o-55296<<10|e-56320)+65536}else o&&(r-=3)>-1&&i.push(239,191,189);if(o=null,e<128){if((r-=1)<0)break;i.push(e)}else if(e<2048){if((r-=2)<0)break;i.push(e>>6|192,e&63|128)}else if(e<65536){if((r-=3)<0)break;i.push(e>>12|224,e>>6&63|128,e&63|128)}else if(e<1114112){if((r-=4)<0)break;i.push(e>>18|240,e>>12&63|128,e>>6&63|128,e&63|128)}else throw new Error("Invalid code point")}return i}function Mt(t){for(var r=[],e=0;e<t.length;++e)r.push(t.charCodeAt(e)&255);return r}function vt(t,r){for(var e,n,o,i=[],a=0;a<t.length&&!((r-=2)<0);++a)e=t.charCodeAt(a),n=e>>8,o=e%256,i.push(o),i.push(n);return i}function Jr(t){return mt(Ut(t))}function Z(t,r,e,n){for(var o=0;o<n&&!(o+e>=r.length||o>=t.length);++o)r[o+e]=t[o];return o}function Ft(t){return t!==t}function Yt(t){return t!=null&&(!!t._isBuffer||jr(t)||Gt(t))}function jr(t){return!!t.constructor&&typeof t.constructor.isBuffer=="function"&&t.constructor.isBuffer(t)}function Gt(t){return typeof t.readFloatLE=="function"&&typeof t.slice=="function"&&jr(t.slice(0,0))}import{encodeAddress as Wt,decodeAddress as Un}from"algosdk";function lr(t){return new Uint8Array(u.from(t))}import Kt from"bignumber.js";Kt.config({DECIMAL_PLACES:40,EXPONENTIAL_AT:45});var Zn=`{"theme1":{"value":"${m.env.FRONTEND_URL}/Theme%3DDark.svg","active":true},"theme2":{"value":"${m.env.FRONTEND_URL}/Theme%3DLight.svg","active":true},"theme3":{"value":"${m.env.FRONTEND_URL}/Theme%3DLight.svg","active":true}}`;var Qr={V1_1:"v1_1",V2:"v2"},no={[Qr.V1_1]:{testnet:62368684,mainnet:552635992},[Qr.V2]:{testnet:148607e3,mainnet:1002541853}};import nu from"algosdk";import*as nn from"bs58";import Qo from"algosdk";import si from"algosdk";import $i from"algosdk";var _i={SMALLESTUNIT:m.env.SMALLEST_UNIT},Ii={SMALLEST_UNITS:m.env.SMALLEST_UNIT};var Bi=["point-system.discordEnabled","point-system.telegramBotName","point-system.telegramBotId","point-system.telegramEnabled","point-system.telegramGroupId","point-system.telegramGroupName","point-system.twitterAccountId","point-system.twitterAccountName","point-system.twitterEnabled","point-system.twitterJobEnabled","point-system.guideLink"];import ic from"algosdk";var ee=(o=>(o.GLOBAL_PAIR_DELISTING="GLOBAL_PAIR_DELISTING",o.GLOBAL_NEW_PAIR_LISTING="GLOBAL_NEW_PAIR_LISTING",o.GLOBAL_SYSTEM_MAINTENANCE="GLOBAL_SYSTEM_MAINTENANCE",o.GLOBAL_SMART_CONTRACT_UPDATE="GLOBAL_SMART_CONTRACT_UPDATE",o))(ee||{}),te=(n=>(n.ACCOUNT_POINTS_UNLOCK_ACHIEVEMENT="ACCOUNT_POINTS_UNLOCK_ACHIEVEMENT",n.ACCOUNT_KYC_STATUS_CHANGED="ACCOUNT_KYC_STATUS_CHANGED",n.ACCOUNT_AFFILIATE_DASHBOARD_UNLOCKED="ACCOUNT_AFFILIATE_DASHBOARD_UNLOCKED",n))(te||{}),ns={...ee,...te};import yc from"algosdk";var un=(t,r)=>r===8?"MX":r===1?"":`Ethereum Signed Message:
2
+ ${t.length}`,ae=(t,r,e)=>{let n=s.from(t,r);return s.concat([lr(un(n,e)),n])},se=t=>{switch(t){case"ALGORAND":return 8;case"SOLANA":return 1;case"EVM":return 5;default:return 5}};function on(t){let r=x.fromSigned(s.from(t));return BigInt(r.toString())}function ln(t){return x.toUnsigned(new x.BN(String(t)))}function an(t){let r=ln(t);if(r.length>32)throw new Error("Invalid value. The buffer length of the value is more than 32");return new Uint8Array(x.setLengthLeft(r,32))}var sn=t=>{if(t.length!==32)throw new Error("Invalid address bytes. The address buffer length is not equel 32");let r=s.from(t).toString("hex");if(r.slice(0,24)!=="000000000000000000000000")throw console.log("normalizedAddress",r),new Error("Invalid normalized address");let e="0x"+r.slice(-40);if(!dn(e))throw new Error("Invalid hex address");return e},pn=t=>new Uint8Array(x.setLengthLeft(mr(t),32)),mr=t=>s.from(mn(t),"hex"),mn=t=>t.startsWith("0x")?t.slice(2):t,dn=t=>x.isValidAddress(t),ce=(t,r)=>{let e=x.keccak256(t),{r:n,s:o,v:i}=x.fromRpcSig(r);return x.ecrecover(e,i,n,o)},Du=(t,r,e,n)=>fn(ae(e,n,se("EVM")),t,r),fn=(t,r,e)=>{let n=ce(t,r);return x.bufferToHex(x.publicToAddress(n)).toLowerCase()===e.toLowerCase()},oe=t=>new Uint8Array(x.keccak256(s.from(t)));export{on as decode32Bytes,pn as decodeAndNormalizeAddress,mr as decodeHexString,an as encode32Bytes,sn as encodeAddress,ln as encodeBigNumber,dn as isAddress,oe as keccak256,ce as recoverPublicKey,mn as unpadHexPrefix,fn as verifyMessage,Du as verifySignature};
3
+ /*!
4
+ * The buffer module from node.js, for the browser.
5
+ *
6
+ * @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
7
+ * @license MIT
8
+ */
9
+ /*! Bundled license information:
10
+
11
+ @esbuild-plugins/node-globals-polyfill/Buffer.js:
12
+ (*!
13
+ * The buffer module from node.js, for the browser.
14
+ *
15
+ * @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
16
+ * @license MIT
17
+ *)
18
+ */
@@ -0,0 +1,11 @@
1
+ function z(){throw new Error("setTimeout has not been defined")}function $(){throw new Error("clearTimeout has not been defined")}var A=z,I=$;typeof globalThis.setTimeout=="function"&&(A=setTimeout);typeof globalThis.clearTimeout=="function"&&(I=clearTimeout);function J(t){if(A===setTimeout)return setTimeout(t,0);if((A===z||!A)&&setTimeout)return A=setTimeout,setTimeout(t,0);try{return A(t,0)}catch{try{return A.call(null,t,0)}catch{return A.call(this,t,0)}}}function xr(t){if(I===clearTimeout)return clearTimeout(t);if((I===$||!I)&&clearTimeout)return I=clearTimeout,clearTimeout(t);try{return I(t)}catch{try{return I.call(null,t)}catch{return I.call(this,t)}}}var _=[],v=!1,R,O=-1;function _r(){!v||!R||(v=!1,R.length?_=R.concat(_):O=-1,_.length&&X())}function X(){if(!v){var t=J(_r);v=!0;for(var r=_.length;r;){for(R=_,_=[];++O<r;)R&&R[O].run();O=-1,r=_.length}R=null,v=!1,xr(t)}}function yr(t){var r=new Array(arguments.length-1);if(arguments.length>1)for(var e=1;e<arguments.length;e++)r[e-1]=arguments[e];_.push(new Q(t,r)),_.length===1&&!v&&J(X)}function Q(t,r){this.fun=t,this.array=r}Q.prototype.run=function(){this.fun.apply(null,this.array)};var wr="browser",Ar="browser",Ir=!0,Rr={},Sr=[],Nr="",Pr={},kr={},vr={};function S(){}var Dr=S,Or=S,Cr=S,Mr=S,Br=S,Lr=S,Ur=S;function Yr(t){throw new Error("process.binding is not supported")}function Fr(){return"/"}function Wr(t){throw new Error("process.chdir is not supported")}function Gr(){return 0}var k=globalThis.performance||{},Hr=k.now||k.mozNow||k.msNow||k.oNow||k.webkitNow||function(){return new Date().getTime()};function Vr(t){var r=Hr.call(k)*.001,e=Math.floor(r),n=Math.floor(r%1*1e9);return t&&(e=e-t[0],n=n-t[1],n<0&&(e--,n+=1e9)),[e,n]}var Kr=new Date;function qr(){var t=new Date,r=t-Kr;return r/1e3}var m={nextTick:yr,title:wr,browser:Ir,env:Rr,argv:Sr,version:Nr,versions:Pr,on:Dr,addListener:Or,once:Cr,off:Mr,removeListener:Br,removeAllListeners:Lr,emit:Ur,binding:Yr,cwd:Fr,chdir:Wr,umask:Gr,hrtime:Vr,platform:Ar,release:kr,config:vr,uptime:qr},q={};Object.keys(q).forEach(t=>{let r=t.split("."),e=m;for(let n=0;n<r.length;n++){let i=r[n];n===r.length-1?e[i]=q[t]:e=e[i]||(e[i]={})}});var E=[],d=[],zr=typeof Uint8Array<"u"?Uint8Array:Array,G=!1;function er(){G=!0;for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r=0,e=t.length;r<e;++r)E[r]=t[r],d[t.charCodeAt(r)]=r;d[45]=62,d[95]=63}function $r(t){G||er();var r,e,n,i,o,a,s=t.length;if(s%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o=t[s-2]==="="?2:t[s-1]==="="?1:0,a=new zr(s*3/4-o),n=o>0?s-4:s;var c=0;for(r=0,e=0;r<n;r+=4,e+=3)i=d[t.charCodeAt(r)]<<18|d[t.charCodeAt(r+1)]<<12|d[t.charCodeAt(r+2)]<<6|d[t.charCodeAt(r+3)],a[c++]=i>>16&255,a[c++]=i>>8&255,a[c++]=i&255;return o===2?(i=d[t.charCodeAt(r)]<<2|d[t.charCodeAt(r+1)]>>4,a[c++]=i&255):o===1&&(i=d[t.charCodeAt(r)]<<10|d[t.charCodeAt(r+1)]<<4|d[t.charCodeAt(r+2)]>>2,a[c++]=i>>8&255,a[c++]=i&255),a}function Jr(t){return E[t>>18&63]+E[t>>12&63]+E[t>>6&63]+E[t&63]}function Xr(t,r,e){for(var n,i=[],o=r;o<e;o+=3)n=(t[o]<<16)+(t[o+1]<<8)+t[o+2],i.push(Jr(n));return i.join("")}function Z(t){G||er();for(var r,e=t.length,n=e%3,i="",o=[],a=16383,s=0,c=e-n;s<c;s+=a)o.push(Xr(t,s,s+a>c?c:s+a));return n===1?(r=t[e-1],i+=E[r>>2],i+=E[r<<4&63],i+="=="):n===2&&(r=(t[e-2]<<8)+t[e-1],i+=E[r>>10],i+=E[r>>4&63],i+=E[r<<2&63],i+="="),o.push(i),o.join("")}u.TYPED_ARRAY_SUPPORT=globalThis.TYPED_ARRAY_SUPPORT!==void 0?globalThis.TYPED_ARRAY_SUPPORT:!0;function C(){return u.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function y(t,r){if(C()<r)throw new RangeError("Invalid typed array length");return u.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(r),t.__proto__=u.prototype):(t===null&&(t=new u(r)),t.length=r),t}function u(t,r,e){if(!u.TYPED_ARRAY_SUPPORT&&!(this instanceof u))return new u(t,r,e);if(typeof t=="number"){if(typeof r=="string")throw new Error("If encoding is specified then the first argument must be a string");return H(this,t)}return tr(this,t,r,e)}u.poolSize=8192;u._augment=function(t){return t.__proto__=u.prototype,t};function tr(t,r,e,n){if(typeof r=="number")throw new TypeError('"value" argument must not be a number');return typeof ArrayBuffer<"u"&&r instanceof ArrayBuffer?jr(t,r,e,n):typeof r=="string"?Zr(t,r,e):re(t,r)}u.from=function(t,r,e){return tr(null,t,r,e)};u.kMaxLength=C();u.TYPED_ARRAY_SUPPORT&&(u.prototype.__proto__=Uint8Array.prototype,u.__proto__=Uint8Array,typeof Symbol<"u"&&Symbol.species&&u[Symbol.species]);function nr(t){if(typeof t!="number")throw new TypeError('"size" argument must be a number');if(t<0)throw new RangeError('"size" argument must not be negative')}function Qr(t,r,e,n){return nr(r),r<=0?y(t,r):e!==void 0?typeof n=="string"?y(t,r).fill(e,n):y(t,r).fill(e):y(t,r)}u.alloc=function(t,r,e){return Qr(null,t,r,e)};function H(t,r){if(nr(r),t=y(t,r<0?0:V(r)|0),!u.TYPED_ARRAY_SUPPORT)for(var e=0;e<r;++e)t[e]=0;return t}u.allocUnsafe=function(t){return H(null,t)};u.allocUnsafeSlow=function(t){return H(null,t)};function Zr(t,r,e){if((typeof e!="string"||e==="")&&(e="utf8"),!u.isEncoding(e))throw new TypeError('"encoding" must be a valid string encoding');var n=ir(r,e)|0;t=y(t,n);var i=t.write(r,e);return i!==n&&(t=t.slice(0,i)),t}function W(t,r){var e=r.length<0?0:V(r.length)|0;t=y(t,e);for(var n=0;n<e;n+=1)t[n]=r[n]&255;return t}function jr(t,r,e,n){if(r.byteLength,e<0||r.byteLength<e)throw new RangeError("'offset' is out of bounds");if(r.byteLength<e+(n||0))throw new RangeError("'length' is out of bounds");return e===void 0&&n===void 0?r=new Uint8Array(r):n===void 0?r=new Uint8Array(r,e):r=new Uint8Array(r,e,n),u.TYPED_ARRAY_SUPPORT?(t=r,t.__proto__=u.prototype):t=W(t,r),t}function re(t,r){if(x(r)){var e=V(r.length)|0;return t=y(t,e),t.length===0||r.copy(t,0,0,e),t}if(r){if(typeof ArrayBuffer<"u"&&r.buffer instanceof ArrayBuffer||"length"in r)return typeof r.length!="number"||Ee(r.length)?y(t,0):W(t,r);if(r.type==="Buffer"&&Array.isArray(r.data))return W(t,r.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}function V(t){if(t>=C())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+C().toString(16)+" bytes");return t|0}u.isBuffer=xe;function x(t){return!!(t!=null&&t._isBuffer)}u.compare=function(r,e){if(!x(r)||!x(e))throw new TypeError("Arguments must be Buffers");if(r===e)return 0;for(var n=r.length,i=e.length,o=0,a=Math.min(n,i);o<a;++o)if(r[o]!==e[o]){n=r[o],i=e[o];break}return n<i?-1:i<n?1:0};u.isEncoding=function(r){switch(String(r).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};u.concat=function(r,e){if(!Array.isArray(r))throw new TypeError('"list" argument must be an Array of Buffers');if(r.length===0)return u.alloc(0);var n;if(e===void 0)for(e=0,n=0;n<r.length;++n)e+=r[n].length;var i=u.allocUnsafe(e),o=0;for(n=0;n<r.length;++n){var a=r[n];if(!x(a))throw new TypeError('"list" argument must be an Array of Buffers');a.copy(i,o),o+=a.length}return i};function ir(t,r){if(x(t))return t.length;if(typeof ArrayBuffer<"u"&&typeof ArrayBuffer.isView=="function"&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;typeof t!="string"&&(t=""+t);var e=t.length;if(e===0)return 0;for(var n=!1;;)switch(r){case"ascii":case"latin1":case"binary":return e;case"utf8":case"utf-8":case void 0:return M(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return e*2;case"hex":return e>>>1;case"base64":return pr(t).length;default:if(n)return M(t).length;r=(""+r).toLowerCase(),n=!0}}u.byteLength=ir;function ee(t,r,e){var n=!1;if((r===void 0||r<0)&&(r=0),r>this.length||((e===void 0||e>this.length)&&(e=this.length),e<=0)||(e>>>=0,r>>>=0,e<=r))return"";for(t||(t="utf8");;)switch(t){case"hex":return pe(this,r,e);case"utf8":case"utf-8":return ur(this,r,e);case"ascii":return ce(this,r,e);case"latin1":case"binary":return le(this,r,e);case"base64":return ue(this,r,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return fe(this,r,e);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}u.prototype._isBuffer=!0;function N(t,r,e){var n=t[r];t[r]=t[e],t[e]=n}u.prototype.swap16=function(){var r=this.length;if(r%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<r;e+=2)N(this,e,e+1);return this};u.prototype.swap32=function(){var r=this.length;if(r%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<r;e+=4)N(this,e,e+3),N(this,e+1,e+2);return this};u.prototype.swap64=function(){var r=this.length;if(r%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<r;e+=8)N(this,e,e+7),N(this,e+1,e+6),N(this,e+2,e+5),N(this,e+3,e+4);return this};u.prototype.toString=function(){var r=this.length|0;return r===0?"":arguments.length===0?ur(this,0,r):ee.apply(this,arguments)};u.prototype.equals=function(r){if(!x(r))throw new TypeError("Argument must be a Buffer");return this===r?!0:u.compare(this,r)===0};u.prototype.compare=function(r,e,n,i,o){if(!x(r))throw new TypeError("Argument must be a Buffer");if(e===void 0&&(e=0),n===void 0&&(n=r?r.length:0),i===void 0&&(i=0),o===void 0&&(o=this.length),e<0||n>r.length||i<0||o>this.length)throw new RangeError("out of range index");if(i>=o&&e>=n)return 0;if(i>=o)return-1;if(e>=n)return 1;if(e>>>=0,n>>>=0,i>>>=0,o>>>=0,this===r)return 0;for(var a=o-i,s=n-e,c=Math.min(a,s),f=this.slice(i,o),l=r.slice(e,n),p=0;p<c;++p)if(f[p]!==l[p]){a=f[p],s=l[p];break}return a<s?-1:s<a?1:0};function or(t,r,e,n,i){if(t.length===0)return-1;if(typeof e=="string"?(n=e,e=0):e>2147483647?e=2147483647:e<-2147483648&&(e=-2147483648),e=+e,isNaN(e)&&(e=i?0:t.length-1),e<0&&(e=t.length+e),e>=t.length){if(i)return-1;e=t.length-1}else if(e<0)if(i)e=0;else return-1;if(typeof r=="string"&&(r=u.from(r,n)),x(r))return r.length===0?-1:j(t,r,e,n,i);if(typeof r=="number")return r=r&255,u.TYPED_ARRAY_SUPPORT&&typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(t,r,e):Uint8Array.prototype.lastIndexOf.call(t,r,e):j(t,[r],e,n,i);throw new TypeError("val must be string, number or Buffer")}function j(t,r,e,n,i){var o=1,a=t.length,s=r.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(t.length<2||r.length<2)return-1;o=2,a/=2,s/=2,e/=2}function c(h,P){return o===1?h[P]:h.readUInt16BE(P*o)}var f;if(i){var l=-1;for(f=e;f<a;f++)if(c(t,f)===c(r,l===-1?0:f-l)){if(l===-1&&(l=f),f-l+1===s)return l*o}else l!==-1&&(f-=f-l),l=-1}else for(e+s>a&&(e=a-s),f=e;f>=0;f--){for(var p=!0,T=0;T<s;T++)if(c(t,f+T)!==c(r,T)){p=!1;break}if(p)return f}return-1}u.prototype.includes=function(r,e,n){return this.indexOf(r,e,n)!==-1};u.prototype.indexOf=function(r,e,n){return or(this,r,e,n,!0)};u.prototype.lastIndexOf=function(r,e,n){return or(this,r,e,n,!1)};function te(t,r,e,n){e=Number(e)||0;var i=t.length-e;n?(n=Number(n),n>i&&(n=i)):n=i;var o=r.length;if(o%2!==0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var a=0;a<n;++a){var s=parseInt(r.substr(a*2,2),16);if(isNaN(s))return a;t[e+a]=s}return a}function ne(t,r,e,n){return U(M(r,t.length-e),t,e,n)}function ar(t,r,e,n){return U(de(r),t,e,n)}function ie(t,r,e,n){return ar(t,r,e,n)}function oe(t,r,e,n){return U(pr(r),t,e,n)}function ae(t,r,e,n){return U(Te(r,t.length-e),t,e,n)}u.prototype.write=function(r,e,n,i){if(e===void 0)i="utf8",n=this.length,e=0;else if(n===void 0&&typeof e=="string")i=e,n=this.length,e=0;else if(isFinite(e))e=e|0,isFinite(n)?(n=n|0,i===void 0&&(i="utf8")):(i=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var o=this.length-e;if((n===void 0||n>o)&&(n=o),r.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");for(var a=!1;;)switch(i){case"hex":return te(this,r,e,n);case"utf8":case"utf-8":return ne(this,r,e,n);case"ascii":return ar(this,r,e,n);case"latin1":case"binary":return ie(this,r,e,n);case"base64":return oe(this,r,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ae(this,r,e,n);default:if(a)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),a=!0}};u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function ue(t,r,e){return r===0&&e===t.length?Z(t):Z(t.slice(r,e))}function ur(t,r,e){e=Math.min(t.length,e);for(var n=[],i=r;i<e;){var o=t[i],a=null,s=o>239?4:o>223?3:o>191?2:1;if(i+s<=e){var c,f,l,p;switch(s){case 1:o<128&&(a=o);break;case 2:c=t[i+1],(c&192)===128&&(p=(o&31)<<6|c&63,p>127&&(a=p));break;case 3:c=t[i+1],f=t[i+2],(c&192)===128&&(f&192)===128&&(p=(o&15)<<12|(c&63)<<6|f&63,p>2047&&(p<55296||p>57343)&&(a=p));break;case 4:c=t[i+1],f=t[i+2],l=t[i+3],(c&192)===128&&(f&192)===128&&(l&192)===128&&(p=(o&15)<<18|(c&63)<<12|(f&63)<<6|l&63,p>65535&&p<1114112&&(a=p))}}a===null?(a=65533,s=1):a>65535&&(a-=65536,n.push(a>>>10&1023|55296),a=56320|a&1023),n.push(a),i+=s}return se(n)}var rr=4096;function se(t){var r=t.length;if(r<=rr)return String.fromCharCode.apply(String,t);for(var e="",n=0;n<r;)e+=String.fromCharCode.apply(String,t.slice(n,n+=rr));return e}function ce(t,r,e){var n="";e=Math.min(t.length,e);for(var i=r;i<e;++i)n+=String.fromCharCode(t[i]&127);return n}function le(t,r,e){var n="";e=Math.min(t.length,e);for(var i=r;i<e;++i)n+=String.fromCharCode(t[i]);return n}function pe(t,r,e){var n=t.length;(!r||r<0)&&(r=0),(!e||e<0||e>n)&&(e=n);for(var i="",o=r;o<e;++o)i+=he(t[o]);return i}function fe(t,r,e){for(var n=t.slice(r,e),i="",o=0;o<n.length;o+=2)i+=String.fromCharCode(n[o]+n[o+1]*256);return i}u.prototype.slice=function(r,e){var n=this.length;r=~~r,e=e===void 0?n:~~e,r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),e<r&&(e=r);var i;if(u.TYPED_ARRAY_SUPPORT)i=this.subarray(r,e),i.__proto__=u.prototype;else{var o=e-r;i=new u(o,void 0);for(var a=0;a<o;++a)i[a]=this[a+r]}return i};function b(t,r,e){if(t%1!==0||t<0)throw new RangeError("offset is not uint");if(t+r>e)throw new RangeError("Trying to access beyond buffer length")}u.prototype.readUIntLE=function(r,e,n){r=r|0,e=e|0,n||b(r,e,this.length);for(var i=this[r],o=1,a=0;++a<e&&(o*=256);)i+=this[r+a]*o;return i};u.prototype.readUIntBE=function(r,e,n){r=r|0,e=e|0,n||b(r,e,this.length);for(var i=this[r+--e],o=1;e>0&&(o*=256);)i+=this[r+--e]*o;return i};u.prototype.readUInt8=function(r,e){return e||b(r,1,this.length),this[r]};u.prototype.readUInt16LE=function(r,e){return e||b(r,2,this.length),this[r]|this[r+1]<<8};u.prototype.readUInt16BE=function(r,e){return e||b(r,2,this.length),this[r]<<8|this[r+1]};u.prototype.readUInt32LE=function(r,e){return e||b(r,4,this.length),(this[r]|this[r+1]<<8|this[r+2]<<16)+this[r+3]*16777216};u.prototype.readUInt32BE=function(r,e){return e||b(r,4,this.length),this[r]*16777216+(this[r+1]<<16|this[r+2]<<8|this[r+3])};u.prototype.readIntLE=function(r,e,n){r=r|0,e=e|0,n||b(r,e,this.length);for(var i=this[r],o=1,a=0;++a<e&&(o*=256);)i+=this[r+a]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*e)),i};u.prototype.readIntBE=function(r,e,n){r=r|0,e=e|0,n||b(r,e,this.length);for(var i=e,o=1,a=this[r+--i];i>0&&(o*=256);)a+=this[r+--i]*o;return o*=128,a>=o&&(a-=Math.pow(2,8*e)),a};u.prototype.readInt8=function(r,e){return e||b(r,1,this.length),this[r]&128?(255-this[r]+1)*-1:this[r]};u.prototype.readInt16LE=function(r,e){e||b(r,2,this.length);var n=this[r]|this[r+1]<<8;return n&32768?n|4294901760:n};u.prototype.readInt16BE=function(r,e){e||b(r,2,this.length);var n=this[r+1]|this[r]<<8;return n&32768?n|4294901760:n};u.prototype.readInt32LE=function(r,e){return e||b(r,4,this.length),this[r]|this[r+1]<<8|this[r+2]<<16|this[r+3]<<24};u.prototype.readInt32BE=function(r,e){return e||b(r,4,this.length),this[r]<<24|this[r+1]<<16|this[r+2]<<8|this[r+3]};u.prototype.readFloatLE=function(r,e){return e||b(r,4,this.length),Y(this,r,!0,23,4)};u.prototype.readFloatBE=function(r,e){return e||b(r,4,this.length),Y(this,r,!1,23,4)};u.prototype.readDoubleLE=function(r,e){return e||b(r,8,this.length),Y(this,r,!0,52,8)};u.prototype.readDoubleBE=function(r,e){return e||b(r,8,this.length),Y(this,r,!1,52,8)};function g(t,r,e,n,i,o){if(!x(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(r>i||r<o)throw new RangeError('"value" argument is out of bounds');if(e+n>t.length)throw new RangeError("Index out of range")}u.prototype.writeUIntLE=function(r,e,n,i){if(r=+r,e=e|0,n=n|0,!i){var o=Math.pow(2,8*n)-1;g(this,r,e,n,o,0)}var a=1,s=0;for(this[e]=r&255;++s<n&&(a*=256);)this[e+s]=r/a&255;return e+n};u.prototype.writeUIntBE=function(r,e,n,i){if(r=+r,e=e|0,n=n|0,!i){var o=Math.pow(2,8*n)-1;g(this,r,e,n,o,0)}var a=n-1,s=1;for(this[e+a]=r&255;--a>=0&&(s*=256);)this[e+a]=r/s&255;return e+n};u.prototype.writeUInt8=function(r,e,n){return r=+r,e=e|0,n||g(this,r,e,1,255,0),u.TYPED_ARRAY_SUPPORT||(r=Math.floor(r)),this[e]=r&255,e+1};function B(t,r,e,n){r<0&&(r=65535+r+1);for(var i=0,o=Math.min(t.length-e,2);i<o;++i)t[e+i]=(r&255<<8*(n?i:1-i))>>>(n?i:1-i)*8}u.prototype.writeUInt16LE=function(r,e,n){return r=+r,e=e|0,n||g(this,r,e,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[e]=r&255,this[e+1]=r>>>8):B(this,r,e,!0),e+2};u.prototype.writeUInt16BE=function(r,e,n){return r=+r,e=e|0,n||g(this,r,e,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[e]=r>>>8,this[e+1]=r&255):B(this,r,e,!1),e+2};function L(t,r,e,n){r<0&&(r=4294967295+r+1);for(var i=0,o=Math.min(t.length-e,4);i<o;++i)t[e+i]=r>>>(n?i:3-i)*8&255}u.prototype.writeUInt32LE=function(r,e,n){return r=+r,e=e|0,n||g(this,r,e,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[e+3]=r>>>24,this[e+2]=r>>>16,this[e+1]=r>>>8,this[e]=r&255):L(this,r,e,!0),e+4};u.prototype.writeUInt32BE=function(r,e,n){return r=+r,e=e|0,n||g(this,r,e,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[e]=r>>>24,this[e+1]=r>>>16,this[e+2]=r>>>8,this[e+3]=r&255):L(this,r,e,!1),e+4};u.prototype.writeIntLE=function(r,e,n,i){if(r=+r,e=e|0,!i){var o=Math.pow(2,8*n-1);g(this,r,e,n,o-1,-o)}var a=0,s=1,c=0;for(this[e]=r&255;++a<n&&(s*=256);)r<0&&c===0&&this[e+a-1]!==0&&(c=1),this[e+a]=(r/s>>0)-c&255;return e+n};u.prototype.writeIntBE=function(r,e,n,i){if(r=+r,e=e|0,!i){var o=Math.pow(2,8*n-1);g(this,r,e,n,o-1,-o)}var a=n-1,s=1,c=0;for(this[e+a]=r&255;--a>=0&&(s*=256);)r<0&&c===0&&this[e+a+1]!==0&&(c=1),this[e+a]=(r/s>>0)-c&255;return e+n};u.prototype.writeInt8=function(r,e,n){return r=+r,e=e|0,n||g(this,r,e,1,127,-128),u.TYPED_ARRAY_SUPPORT||(r=Math.floor(r)),r<0&&(r=255+r+1),this[e]=r&255,e+1};u.prototype.writeInt16LE=function(r,e,n){return r=+r,e=e|0,n||g(this,r,e,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[e]=r&255,this[e+1]=r>>>8):B(this,r,e,!0),e+2};u.prototype.writeInt16BE=function(r,e,n){return r=+r,e=e|0,n||g(this,r,e,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[e]=r>>>8,this[e+1]=r&255):B(this,r,e,!1),e+2};u.prototype.writeInt32LE=function(r,e,n){return r=+r,e=e|0,n||g(this,r,e,4,2147483647,-2147483648),u.TYPED_ARRAY_SUPPORT?(this[e]=r&255,this[e+1]=r>>>8,this[e+2]=r>>>16,this[e+3]=r>>>24):L(this,r,e,!0),e+4};u.prototype.writeInt32BE=function(r,e,n){return r=+r,e=e|0,n||g(this,r,e,4,2147483647,-2147483648),r<0&&(r=4294967295+r+1),u.TYPED_ARRAY_SUPPORT?(this[e]=r>>>24,this[e+1]=r>>>16,this[e+2]=r>>>8,this[e+3]=r&255):L(this,r,e,!1),e+4};function sr(t,r,e,n,i,o){if(e+n>t.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function cr(t,r,e,n,i){return i||sr(t,r,e,4,34028234663852886e22,-34028234663852886e22),mr(t,r,e,n,23,4),e+4}u.prototype.writeFloatLE=function(r,e,n){return cr(this,r,e,!0,n)};u.prototype.writeFloatBE=function(r,e,n){return cr(this,r,e,!1,n)};function lr(t,r,e,n,i){return i||sr(t,r,e,8,17976931348623157e292,-17976931348623157e292),mr(t,r,e,n,52,8),e+8}u.prototype.writeDoubleLE=function(r,e,n){return lr(this,r,e,!0,n)};u.prototype.writeDoubleBE=function(r,e,n){return lr(this,r,e,!1,n)};u.prototype.copy=function(r,e,n,i){if(n||(n=0),!i&&i!==0&&(i=this.length),e>=r.length&&(e=r.length),e||(e=0),i>0&&i<n&&(i=n),i===n||r.length===0||this.length===0)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("sourceStart out of bounds");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),r.length-e<i-n&&(i=r.length-e+n);var o=i-n,a;if(this===r&&n<e&&e<i)for(a=o-1;a>=0;--a)r[a+e]=this[a+n];else if(o<1e3||!u.TYPED_ARRAY_SUPPORT)for(a=0;a<o;++a)r[a+e]=this[a+n];else Uint8Array.prototype.set.call(r,this.subarray(n,n+o),e);return o};u.prototype.fill=function(r,e,n,i){if(typeof r=="string"){if(typeof e=="string"?(i=e,e=0,n=this.length):typeof n=="string"&&(i=n,n=this.length),r.length===1){var o=r.charCodeAt(0);o<256&&(r=o)}if(i!==void 0&&typeof i!="string")throw new TypeError("encoding must be a string");if(typeof i=="string"&&!u.isEncoding(i))throw new TypeError("Unknown encoding: "+i)}else typeof r=="number"&&(r=r&255);if(e<0||this.length<e||this.length<n)throw new RangeError("Out of range index");if(n<=e)return this;e=e>>>0,n=n===void 0?this.length:n>>>0,r||(r=0);var a;if(typeof r=="number")for(a=e;a<n;++a)this[a]=r;else{var s=x(r)?r:M(new u(r,i).toString()),c=s.length;for(a=0;a<n-e;++a)this[a+e]=s[a%c]}return this};var me=/[^+\/0-9A-Za-z-_]/g;function be(t){if(t=ge(t).replace(me,""),t.length<2)return"";for(;t.length%4!==0;)t=t+"=";return t}function ge(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function he(t){return t<16?"0"+t.toString(16):t.toString(16)}function M(t,r){r=r||1/0;for(var e,n=t.length,i=null,o=[],a=0;a<n;++a){if(e=t.charCodeAt(a),e>55295&&e<57344){if(!i){if(e>56319){(r-=3)>-1&&o.push(239,191,189);continue}else if(a+1===n){(r-=3)>-1&&o.push(239,191,189);continue}i=e;continue}if(e<56320){(r-=3)>-1&&o.push(239,191,189),i=e;continue}e=(i-55296<<10|e-56320)+65536}else i&&(r-=3)>-1&&o.push(239,191,189);if(i=null,e<128){if((r-=1)<0)break;o.push(e)}else if(e<2048){if((r-=2)<0)break;o.push(e>>6|192,e&63|128)}else if(e<65536){if((r-=3)<0)break;o.push(e>>12|224,e>>6&63|128,e&63|128)}else if(e<1114112){if((r-=4)<0)break;o.push(e>>18|240,e>>12&63|128,e>>6&63|128,e&63|128)}else throw new Error("Invalid code point")}return o}function de(t){for(var r=[],e=0;e<t.length;++e)r.push(t.charCodeAt(e)&255);return r}function Te(t,r){for(var e,n,i,o=[],a=0;a<t.length&&!((r-=2)<0);++a)e=t.charCodeAt(a),n=e>>8,i=e%256,o.push(i),o.push(n);return o}function pr(t){return $r(be(t))}function U(t,r,e,n){for(var i=0;i<n&&!(i+e>=r.length||i>=t.length);++i)r[i+e]=t[i];return i}function Ee(t){return t!==t}function xe(t){return t!=null&&(!!t._isBuffer||fr(t)||_e(t))}function fr(t){return!!t.constructor&&typeof t.constructor.isBuffer=="function"&&t.constructor.isBuffer(t)}function _e(t){return typeof t.readFloatLE=="function"&&typeof t.slice=="function"&&fr(t.slice(0,0))}function Y(t,r,e,n,i){var o,a,s=i*8-n-1,c=(1<<s)-1,f=c>>1,l=-7,p=e?i-1:0,T=e?-1:1,h=t[r+p];for(p+=T,o=h&(1<<-l)-1,h>>=-l,l+=s;l>0;o=o*256+t[r+p],p+=T,l-=8);for(a=o&(1<<-l)-1,o>>=-l,l+=n;l>0;a=a*256+t[r+p],p+=T,l-=8);if(o===0)o=1-f;else{if(o===c)return a?NaN:(h?-1:1)*(1/0);a=a+Math.pow(2,n),o=o-f}return(h?-1:1)*a*Math.pow(2,o-n)}function mr(t,r,e,n,i,o){var a,s,c,f=o*8-i-1,l=(1<<f)-1,p=l>>1,T=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,h=n?0:o-1,P=n?1:-1,Er=r<0||r===0&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(s=isNaN(r)?1:0,a=l):(a=Math.floor(Math.log(r)/Math.LN2),r*(c=Math.pow(2,-a))<1&&(a--,c*=2),a+p>=1?r+=T/c:r+=T*Math.pow(2,1-p),r*c>=2&&(a++,c/=2),a+p>=l?(s=0,a=l):a+p>=1?(s=(r*c-1)*Math.pow(2,i),a=a+p):(s=r*Math.pow(2,p-1)*Math.pow(2,i),a=0));i>=8;t[e+h]=s&255,h+=P,s/=256,i-=8);for(a=a<<i|s,f+=i;f>0;t[e+h]=a&255,h+=P,a/=256,f-=8);t[e+h-P]|=Er*128}var D={hour:/(\d+)[H]/i,day:/(\d+)[D]/i,week:/(\d+)[W]/i,month:/(\d+)[M]/i,year:/(\d+)[Y]/i};function De(t){let r=ye(t);if(r===null)throw new Error(`Cannot fetch datepart from interval: ${t}`);let e=Number(r==="minute"?t:t.slice(0,-1));return e?r==="minute"&&e%10080===0?w("week",e/10080):r==="minute"&&e%1440===0?w("day",e/1440):r==="minute"&&e%60===0?w("hour",e/60):r==="hour"&&e%168===0?w("week",e/168):r==="hour"&&e%24===0?w(e===24?"hour":"day",e===24?24:e/24):r==="day"&&e%7===0?w("week",e/7):r==="month"&&e%12===0?w("year",e/12):w(r,e):w(r,1)}function ye(t){if(!isNaN(Number(t)))return"minute";let e=`1${t.slice(-1)}`;switch(!0){case D.hour.test(e):return"hour";case D.day.test(e):return"day";case D.week.test(e):return"week";case D.month.test(e):return"month";case D.year.test(e):return"year";default:return null}}function w(t,r){return{datepart:t,value:r,timeframe:Ie(t,r)}}function we(t){return[1,3,5,15,30].includes(t)}function Ae(t){return[1,2,3,4,12].includes(t)}function Ie(t,r){switch(t){case"minute":return we(r)?`${r}m`:"1m";case"hour":return Ae(r)?`${r}h`:"1h";case"day":return"1d";case"week":return"1w";case"month":return"1M";case"year":return"1Y";default:throw new Error(`Unsupported datepart: ${t}`)}}import K from"bignumber.js";K.config({DECIMAL_PLACES:40,EXPONENTIAL_AT:45});function br(t,r){return F(t,r,"+")}function gr(t,r){return F(t,r,"/")}function hr(t,r){return!!F(t,r,">")}function dr(t,r){return!!F(t,r,"<")}function F(t,r,e){switch(t=new K(String(t)),r=new K(String(r)),e.toLowerCase()){case"-":return t.minus(r).toString();case"+":return t.plus(r).toString();case"*":case"x":return t.multipliedBy(r).toString();case"\xF7":case"/":return t.dividedBy(r).toString();case">=":return t.isGreaterThanOrEqualTo(r);case">":return t.isGreaterThan(r);case"<=":return t.isLessThanOrEqualTo(r);case"<":return t.isLessThan(r);case"==":return t.isEqualTo(r);case"mod":return t.modulo(r);default:break}}function We(t,r,e){let n=[],i=e-r,o=null,a=t.sort((s,c)=>c.t-s.t);for(let s=0;s<a.length;s++){let c=a[s];c.t<i&&(o&&(n.push({...o}),o=null),i=i-r*Math.ceil((i-c.t)/r)),o?(dr(o.h,c.h)&&(o.h=c.h),hr(o.l,c.l)&&(o.l=c.l),o.o=c.o,o.v=Number(br(o.v,c.v))):o={...c,t:i},s+1===a.length&&n.push({...o})}return n}function Ge(t,r,e){let n=t.sort((a,s)=>s.t-a.t),i=[],o=new Map;for(let a of n){let c=new Date(a.t*1e3).getFullYear();o.has(c)||o.set(c,[]),o.get(c).push(a)}for(let[a,s]of o){if(s.length===0)continue;let c=s.sort((l,p)=>l.t-p.t),f={t:new Date(a,0,1).getTime()/1e3,o:c[0].o,h:Math.max(...c.map(l=>l.h)),l:Math.min(...c.map(l=>l.l)),c:c[c.length-1].c,v:c.reduce((l,p)=>l+p.v,0),q:c.reduce((l,p)=>l+p.q,0)};i.push(f)}return i.sort((a,s)=>s.t-a.t)}function He(t,r,e){throw new Error("groupTickersByYearInterval has not implemented yet")}function Ve(t){return{t:+gr(t.timestamp,1e3),o:t.open,h:t.high,l:t.low,c:t.close,v:t.volume,q:t.quote}}function Ke(t){return new Date(t*1e3).setSeconds(60,0)/1e3}function qe(t){return new Date(t*1e3).setMinutes(60,0,0)/1e3}function ze(t){return new Date(t*1e3).setHours(24,0,0,0)/1e3}var et=`{"theme1":{"value":"${m.env.FRONTEND_URL}/Theme%3DDark.svg","active":true},"theme2":{"value":"${m.env.FRONTEND_URL}/Theme%3DLight.svg","active":true},"theme3":{"value":"${m.env.FRONTEND_URL}/Theme%3DLight.svg","active":true}}`;var Tr={V1_1:"v1_1",V2:"v2"},ot={[Tr.V1_1]:{testnet:62368684,mainnet:552635992},[Tr.V2]:{testnet:148607e3,mainnet:1002541853}};var Dt=t=>{let r={};return t.forEach(({settingId:e,value:n,setting:i})=>{i.type==="boolean"?r[e]=n==="true":r[e]=n}),{discordEnabled:r["point-system.discordEnabled"],telegramBotName:r["point-system.telegramBotName"],telegramBotId:r["point-system.telegramBotId"],telegramEnabled:r["point-system.telegramEnabled"],telegramGroupId:r["point-system.telegramGroupId"],telegramGroupName:r["point-system.telegramGroupName"],twitterAccountId:r["point-system.twitterAccountId"],twitterAccountName:r["point-system.twitterAccountName"],twitterEnabled:r["point-system.twitterEnabled"],twitterJobEnabled:r["point-system.twitterJobEnabled"],guideLink:r["point-system.guideLink"]}};function Bt(t){return Object.keys(t).sort().reduce((r,e)=>({...r,[e]:t[e]}),{})}function Lt(t){return Math.round(t*100)/100}export{De as getDatepartValue,We as groupTickersByInterval,Ge as groupTickersByMonthInterval,He as groupTickersByYearInterval,ye as identityDatepart,Ae as inHourCandles,we as inMinCandles,Ve as mapCandleToTicker,Lt as round2,ze as roundUpHoursInTimestamp,qe as roundUpMinutesInTimestamp,Ke as roundUpSecondsInTimestamp,Bt as sortKeysInObject,Dt as transformPointSystemSettings};
2
+ /*! Bundled license information:
3
+
4
+ @esbuild-plugins/node-globals-polyfill/Buffer.js:
5
+ (*!
6
+ * The buffer module from node.js, for the browser.
7
+ *
8
+ * @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
9
+ * @license MIT
10
+ *)
11
+ */
@@ -0,0 +1,11 @@
1
+ function G(){throw new Error("setTimeout has not been defined")}function J(){throw new Error("clearTimeout has not been defined")}var d=G,_=J;typeof globalThis.setTimeout=="function"&&(d=setTimeout);typeof globalThis.clearTimeout=="function"&&(_=clearTimeout);function O(e){if(d===setTimeout)return setTimeout(e,0);if((d===G||!d)&&setTimeout)return d=setTimeout,setTimeout(e,0);try{return d(e,0)}catch{try{return d.call(null,e,0)}catch{return d.call(this,e,0)}}}function lr(e){if(_===clearTimeout)return clearTimeout(e);if((_===J||!_)&&clearTimeout)return _=clearTimeout,clearTimeout(e);try{return _(e)}catch{try{return _.call(null,e)}catch{return _.call(this,e)}}}var g=[],D=!1,I,P=-1;function wr(){!D||!I||(D=!1,I.length?g=I.concat(g):P=-1,g.length&&Q())}function Q(){if(!D){var e=O(wr);D=!0;for(var r=g.length;r;){for(I=g,g=[];++P<r;)I&&I[P].run();P=-1,r=g.length}I=null,D=!1,lr(e)}}function xr(e){var r=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)r[n-1]=arguments[n];g.push(new X(e,r)),g.length===1&&!D&&O(Q)}function X(e,r){this.fun=e,this.array=r}X.prototype.run=function(){this.fun.apply(null,this.array)};var mr="browser",Er="browser",yr=!0,Ar={},gr=[],Tr="",Rr={},dr={},_r={};function U(){}var Ir=U,Ur=U,vr=U,Br=U,Yr=U,Dr=U,Sr=U;function Pr(e){throw new Error("process.binding is not supported")}function Mr(){return"/"}function kr(e){throw new Error("process.chdir is not supported")}function Cr(){return 0}var Y=globalThis.performance||{},Nr=Y.now||Y.mozNow||Y.msNow||Y.oNow||Y.webkitNow||function(){return new Date().getTime()};function Lr(e){var r=Nr.call(Y)*.001,n=Math.floor(r),i=Math.floor(r%1*1e9);return e&&(n=n-e[0],i=i-e[1],i<0&&(n--,i+=1e9)),[n,i]}var Fr=new Date;function Wr(){var e=new Date,r=e-Fr;return r/1e3}var W={nextTick:xr,title:mr,browser:yr,env:Ar,argv:gr,version:Tr,versions:Rr,on:Ir,addListener:Ur,once:vr,off:Br,removeListener:Yr,removeAllListeners:Dr,emit:Sr,binding:Pr,cwd:Mr,chdir:kr,umask:Cr,hrtime:Lr,platform:Er,release:dr,config:_r,uptime:Wr},z={};Object.keys(z).forEach(e=>{let r=e.split("."),n=W;for(let i=0;i<r.length;i++){let t=r[i];i===r.length-1?n[t]=z[e]:n=n[t]||(n[t]={})}});var y=[],m=[],Hr=typeof Uint8Array<"u"?Uint8Array:Array,$=!1;function j(){$=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r=0,n=e.length;r<n;++r)y[r]=e[r],m[e.charCodeAt(r)]=r;m[45]=62,m[95]=63}function $r(e){$||j();var r,n,i,t,u,f,a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");u=e[a-2]==="="?2:e[a-1]==="="?1:0,f=new Hr(a*3/4-u),i=u>0?a-4:a;var h=0;for(r=0,n=0;r<i;r+=4,n+=3)t=m[e.charCodeAt(r)]<<18|m[e.charCodeAt(r+1)]<<12|m[e.charCodeAt(r+2)]<<6|m[e.charCodeAt(r+3)],f[h++]=t>>16&255,f[h++]=t>>8&255,f[h++]=t&255;return u===2?(t=m[e.charCodeAt(r)]<<2|m[e.charCodeAt(r+1)]>>4,f[h++]=t&255):u===1&&(t=m[e.charCodeAt(r)]<<10|m[e.charCodeAt(r+1)]<<4|m[e.charCodeAt(r+2)]>>2,f[h++]=t>>8&255,f[h++]=t&255),f}function Vr(e){return y[e>>18&63]+y[e>>12&63]+y[e>>6&63]+y[e&63]}function br(e,r,n){for(var i,t=[],u=r;u<n;u+=3)i=(e[u]<<16)+(e[u+1]<<8)+e[u+2],t.push(Vr(i));return t.join("")}function q(e){$||j();for(var r,n=e.length,i=n%3,t="",u=[],f=16383,a=0,h=n-i;a<h;a+=f)u.push(br(e,a,a+f>h?h:a+f));return i===1?(r=e[n-1],t+=y[r>>2],t+=y[r<<4&63],t+="=="):i===2&&(r=(e[n-2]<<8)+e[n-1],t+=y[r>>10],t+=y[r>>4&63],t+=y[r<<2&63],t+="="),u.push(t),u.join("")}o.TYPED_ARRAY_SUPPORT=globalThis.TYPED_ARRAY_SUPPORT!==void 0?globalThis.TYPED_ARRAY_SUPPORT:!0;function M(){return o.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function T(e,r){if(M()<r)throw new RangeError("Invalid typed array length");return o.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(r),e.__proto__=o.prototype):(e===null&&(e=new o(r)),e.length=r),e}function o(e,r,n){if(!o.TYPED_ARRAY_SUPPORT&&!(this instanceof o))return new o(e,r,n);if(typeof e=="number"){if(typeof r=="string")throw new Error("If encoding is specified then the first argument must be a string");return V(this,e)}return rr(this,e,r,n)}o.poolSize=8192;o._augment=function(e){return e.__proto__=o.prototype,e};function rr(e,r,n,i){if(typeof r=="number")throw new TypeError('"value" argument must not be a number');return typeof ArrayBuffer<"u"&&r instanceof ArrayBuffer?Jr(e,r,n,i):typeof r=="string"?Gr(e,r,n):Or(e,r)}o.from=function(e,r,n){return rr(null,e,r,n)};o.kMaxLength=M();o.TYPED_ARRAY_SUPPORT&&(o.prototype.__proto__=Uint8Array.prototype,o.__proto__=Uint8Array,typeof Symbol<"u"&&Symbol.species&&o[Symbol.species]);function nr(e){if(typeof e!="number")throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function zr(e,r,n,i){return nr(r),r<=0?T(e,r):n!==void 0?typeof i=="string"?T(e,r).fill(n,i):T(e,r).fill(n):T(e,r)}o.alloc=function(e,r,n){return zr(null,e,r,n)};function V(e,r){if(nr(r),e=T(e,r<0?0:b(r)|0),!o.TYPED_ARRAY_SUPPORT)for(var n=0;n<r;++n)e[n]=0;return e}o.allocUnsafe=function(e){return V(null,e)};o.allocUnsafeSlow=function(e){return V(null,e)};function Gr(e,r,n){if((typeof n!="string"||n==="")&&(n="utf8"),!o.isEncoding(n))throw new TypeError('"encoding" must be a valid string encoding');var i=er(r,n)|0;e=T(e,i);var t=e.write(r,n);return t!==i&&(e=e.slice(0,t)),e}function H(e,r){var n=r.length<0?0:b(r.length)|0;e=T(e,n);for(var i=0;i<n;i+=1)e[i]=r[i]&255;return e}function Jr(e,r,n,i){if(r.byteLength,n<0||r.byteLength<n)throw new RangeError("'offset' is out of bounds");if(r.byteLength<n+(i||0))throw new RangeError("'length' is out of bounds");return n===void 0&&i===void 0?r=new Uint8Array(r):i===void 0?r=new Uint8Array(r,n):r=new Uint8Array(r,n,i),o.TYPED_ARRAY_SUPPORT?(e=r,e.__proto__=o.prototype):e=H(e,r),e}function Or(e,r){if(A(r)){var n=b(r.length)|0;return e=T(e,n),e.length===0||r.copy(e,0,0,n),e}if(r){if(typeof ArrayBuffer<"u"&&r.buffer instanceof ArrayBuffer||"length"in r)return typeof r.length!="number"||ln(r.length)?T(e,0):H(e,r);if(r.type==="Buffer"&&Array.isArray(r.data))return H(e,r.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}function b(e){if(e>=M())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+M().toString(16)+" bytes");return e|0}o.isBuffer=wn;function A(e){return!!(e!=null&&e._isBuffer)}o.compare=function(r,n){if(!A(r)||!A(n))throw new TypeError("Arguments must be Buffers");if(r===n)return 0;for(var i=r.length,t=n.length,u=0,f=Math.min(i,t);u<f;++u)if(r[u]!==n[u]){i=r[u],t=n[u];break}return i<t?-1:t<i?1:0};o.isEncoding=function(r){switch(String(r).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};o.concat=function(r,n){if(!Array.isArray(r))throw new TypeError('"list" argument must be an Array of Buffers');if(r.length===0)return o.alloc(0);var i;if(n===void 0)for(n=0,i=0;i<r.length;++i)n+=r[i].length;var t=o.allocUnsafe(n),u=0;for(i=0;i<r.length;++i){var f=r[i];if(!A(f))throw new TypeError('"list" argument must be an Array of Buffers');f.copy(t,u),u+=f.length}return t};function er(e,r){if(A(e))return e.length;if(typeof ArrayBuffer<"u"&&typeof ArrayBuffer.isView=="function"&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;typeof e!="string"&&(e=""+e);var n=e.length;if(n===0)return 0;for(var i=!1;;)switch(r){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return k(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return n*2;case"hex":return n>>>1;case"base64":return hr(e).length;default:if(i)return k(e).length;r=(""+r).toLowerCase(),i=!0}}o.byteLength=er;function Qr(e,r,n){var i=!1;if((r===void 0||r<0)&&(r=0),r>this.length||((n===void 0||n>this.length)&&(n=this.length),n<=0)||(n>>>=0,r>>>=0,n<=r))return"";for(e||(e="utf8");;)switch(e){case"hex":return un(this,r,n);case"utf8":case"utf-8":return ur(this,r,n);case"ascii":return en(this,r,n);case"latin1":case"binary":return tn(this,r,n);case"base64":return rn(this,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return fn(this,r,n);default:if(i)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),i=!0}}o.prototype._isBuffer=!0;function v(e,r,n){var i=e[r];e[r]=e[n],e[n]=i}o.prototype.swap16=function(){var r=this.length;if(r%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var n=0;n<r;n+=2)v(this,n,n+1);return this};o.prototype.swap32=function(){var r=this.length;if(r%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var n=0;n<r;n+=4)v(this,n,n+3),v(this,n+1,n+2);return this};o.prototype.swap64=function(){var r=this.length;if(r%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var n=0;n<r;n+=8)v(this,n,n+7),v(this,n+1,n+6),v(this,n+2,n+5),v(this,n+3,n+4);return this};o.prototype.toString=function(){var r=this.length|0;return r===0?"":arguments.length===0?ur(this,0,r):Qr.apply(this,arguments)};o.prototype.equals=function(r){if(!A(r))throw new TypeError("Argument must be a Buffer");return this===r?!0:o.compare(this,r)===0};o.prototype.compare=function(r,n,i,t,u){if(!A(r))throw new TypeError("Argument must be a Buffer");if(n===void 0&&(n=0),i===void 0&&(i=r?r.length:0),t===void 0&&(t=0),u===void 0&&(u=this.length),n<0||i>r.length||t<0||u>this.length)throw new RangeError("out of range index");if(t>=u&&n>=i)return 0;if(t>=u)return-1;if(n>=i)return 1;if(n>>>=0,i>>>=0,t>>>=0,u>>>=0,this===r)return 0;for(var f=u-t,a=i-n,h=Math.min(f,a),s=this.slice(t,u),p=r.slice(n,i),c=0;c<h;++c)if(s[c]!==p[c]){f=s[c],a=p[c];break}return f<a?-1:a<f?1:0};function ir(e,r,n,i,t){if(e.length===0)return-1;if(typeof n=="string"?(i=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=t?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(t)return-1;n=e.length-1}else if(n<0)if(t)n=0;else return-1;if(typeof r=="string"&&(r=o.from(r,i)),A(r))return r.length===0?-1:Z(e,r,n,i,t);if(typeof r=="number")return r=r&255,o.TYPED_ARRAY_SUPPORT&&typeof Uint8Array.prototype.indexOf=="function"?t?Uint8Array.prototype.indexOf.call(e,r,n):Uint8Array.prototype.lastIndexOf.call(e,r,n):Z(e,[r],n,i,t);throw new TypeError("val must be string, number or Buffer")}function Z(e,r,n,i,t){var u=1,f=e.length,a=r.length;if(i!==void 0&&(i=String(i).toLowerCase(),i==="ucs2"||i==="ucs-2"||i==="utf16le"||i==="utf-16le")){if(e.length<2||r.length<2)return-1;u=2,f/=2,a/=2,n/=2}function h(x,B){return u===1?x[B]:x.readUInt16BE(B*u)}var s;if(t){var p=-1;for(s=n;s<f;s++)if(h(e,s)===h(r,p===-1?0:s-p)){if(p===-1&&(p=s),s-p+1===a)return p*u}else p!==-1&&(s-=s-p),p=-1}else for(n+a>f&&(n=f-a),s=n;s>=0;s--){for(var c=!0,E=0;E<a;E++)if(h(e,s+E)!==h(r,E)){c=!1;break}if(c)return s}return-1}o.prototype.includes=function(r,n,i){return this.indexOf(r,n,i)!==-1};o.prototype.indexOf=function(r,n,i){return ir(this,r,n,i,!0)};o.prototype.lastIndexOf=function(r,n,i){return ir(this,r,n,i,!1)};function Xr(e,r,n,i){n=Number(n)||0;var t=e.length-n;i?(i=Number(i),i>t&&(i=t)):i=t;var u=r.length;if(u%2!==0)throw new TypeError("Invalid hex string");i>u/2&&(i=u/2);for(var f=0;f<i;++f){var a=parseInt(r.substr(f*2,2),16);if(isNaN(a))return f;e[n+f]=a}return f}function qr(e,r,n,i){return L(k(r,e.length-n),e,n,i)}function tr(e,r,n,i){return L(sn(r),e,n,i)}function Zr(e,r,n,i){return tr(e,r,n,i)}function Kr(e,r,n,i){return L(hr(r),e,n,i)}function jr(e,r,n,i){return L(pn(r,e.length-n),e,n,i)}o.prototype.write=function(r,n,i,t){if(n===void 0)t="utf8",i=this.length,n=0;else if(i===void 0&&typeof n=="string")t=n,i=this.length,n=0;else if(isFinite(n))n=n|0,isFinite(i)?(i=i|0,t===void 0&&(t="utf8")):(t=i,i=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var u=this.length-n;if((i===void 0||i>u)&&(i=u),r.length>0&&(i<0||n<0)||n>this.length)throw new RangeError("Attempt to write outside buffer bounds");t||(t="utf8");for(var f=!1;;)switch(t){case"hex":return Xr(this,r,n,i);case"utf8":case"utf-8":return qr(this,r,n,i);case"ascii":return tr(this,r,n,i);case"latin1":case"binary":return Zr(this,r,n,i);case"base64":return Kr(this,r,n,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return jr(this,r,n,i);default:if(f)throw new TypeError("Unknown encoding: "+t);t=(""+t).toLowerCase(),f=!0}};o.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function rn(e,r,n){return r===0&&n===e.length?q(e):q(e.slice(r,n))}function ur(e,r,n){n=Math.min(e.length,n);for(var i=[],t=r;t<n;){var u=e[t],f=null,a=u>239?4:u>223?3:u>191?2:1;if(t+a<=n){var h,s,p,c;switch(a){case 1:u<128&&(f=u);break;case 2:h=e[t+1],(h&192)===128&&(c=(u&31)<<6|h&63,c>127&&(f=c));break;case 3:h=e[t+1],s=e[t+2],(h&192)===128&&(s&192)===128&&(c=(u&15)<<12|(h&63)<<6|s&63,c>2047&&(c<55296||c>57343)&&(f=c));break;case 4:h=e[t+1],s=e[t+2],p=e[t+3],(h&192)===128&&(s&192)===128&&(p&192)===128&&(c=(u&15)<<18|(h&63)<<12|(s&63)<<6|p&63,c>65535&&c<1114112&&(f=c))}}f===null?(f=65533,a=1):f>65535&&(f-=65536,i.push(f>>>10&1023|55296),f=56320|f&1023),i.push(f),t+=a}return nn(i)}var K=4096;function nn(e){var r=e.length;if(r<=K)return String.fromCharCode.apply(String,e);for(var n="",i=0;i<r;)n+=String.fromCharCode.apply(String,e.slice(i,i+=K));return n}function en(e,r,n){var i="";n=Math.min(e.length,n);for(var t=r;t<n;++t)i+=String.fromCharCode(e[t]&127);return i}function tn(e,r,n){var i="";n=Math.min(e.length,n);for(var t=r;t<n;++t)i+=String.fromCharCode(e[t]);return i}function un(e,r,n){var i=e.length;(!r||r<0)&&(r=0),(!n||n<0||n>i)&&(n=i);for(var t="",u=r;u<n;++u)t+=cn(e[u]);return t}function fn(e,r,n){for(var i=e.slice(r,n),t="",u=0;u<i.length;u+=2)t+=String.fromCharCode(i[u]+i[u+1]*256);return t}o.prototype.slice=function(r,n){var i=this.length;r=~~r,n=n===void 0?i:~~n,r<0?(r+=i,r<0&&(r=0)):r>i&&(r=i),n<0?(n+=i,n<0&&(n=0)):n>i&&(n=i),n<r&&(n=r);var t;if(o.TYPED_ARRAY_SUPPORT)t=this.subarray(r,n),t.__proto__=o.prototype;else{var u=n-r;t=new o(u,void 0);for(var f=0;f<u;++f)t[f]=this[f+r]}return t};function l(e,r,n){if(e%1!==0||e<0)throw new RangeError("offset is not uint");if(e+r>n)throw new RangeError("Trying to access beyond buffer length")}o.prototype.readUIntLE=function(r,n,i){r=r|0,n=n|0,i||l(r,n,this.length);for(var t=this[r],u=1,f=0;++f<n&&(u*=256);)t+=this[r+f]*u;return t};o.prototype.readUIntBE=function(r,n,i){r=r|0,n=n|0,i||l(r,n,this.length);for(var t=this[r+--n],u=1;n>0&&(u*=256);)t+=this[r+--n]*u;return t};o.prototype.readUInt8=function(r,n){return n||l(r,1,this.length),this[r]};o.prototype.readUInt16LE=function(r,n){return n||l(r,2,this.length),this[r]|this[r+1]<<8};o.prototype.readUInt16BE=function(r,n){return n||l(r,2,this.length),this[r]<<8|this[r+1]};o.prototype.readUInt32LE=function(r,n){return n||l(r,4,this.length),(this[r]|this[r+1]<<8|this[r+2]<<16)+this[r+3]*16777216};o.prototype.readUInt32BE=function(r,n){return n||l(r,4,this.length),this[r]*16777216+(this[r+1]<<16|this[r+2]<<8|this[r+3])};o.prototype.readIntLE=function(r,n,i){r=r|0,n=n|0,i||l(r,n,this.length);for(var t=this[r],u=1,f=0;++f<n&&(u*=256);)t+=this[r+f]*u;return u*=128,t>=u&&(t-=Math.pow(2,8*n)),t};o.prototype.readIntBE=function(r,n,i){r=r|0,n=n|0,i||l(r,n,this.length);for(var t=n,u=1,f=this[r+--t];t>0&&(u*=256);)f+=this[r+--t]*u;return u*=128,f>=u&&(f-=Math.pow(2,8*n)),f};o.prototype.readInt8=function(r,n){return n||l(r,1,this.length),this[r]&128?(255-this[r]+1)*-1:this[r]};o.prototype.readInt16LE=function(r,n){n||l(r,2,this.length);var i=this[r]|this[r+1]<<8;return i&32768?i|4294901760:i};o.prototype.readInt16BE=function(r,n){n||l(r,2,this.length);var i=this[r+1]|this[r]<<8;return i&32768?i|4294901760:i};o.prototype.readInt32LE=function(r,n){return n||l(r,4,this.length),this[r]|this[r+1]<<8|this[r+2]<<16|this[r+3]<<24};o.prototype.readInt32BE=function(r,n){return n||l(r,4,this.length),this[r]<<24|this[r+1]<<16|this[r+2]<<8|this[r+3]};o.prototype.readFloatLE=function(r,n){return n||l(r,4,this.length),F(this,r,!0,23,4)};o.prototype.readFloatBE=function(r,n){return n||l(r,4,this.length),F(this,r,!1,23,4)};o.prototype.readDoubleLE=function(r,n){return n||l(r,8,this.length),F(this,r,!0,52,8)};o.prototype.readDoubleBE=function(r,n){return n||l(r,8,this.length),F(this,r,!1,52,8)};function w(e,r,n,i,t,u){if(!A(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(r>t||r<u)throw new RangeError('"value" argument is out of bounds');if(n+i>e.length)throw new RangeError("Index out of range")}o.prototype.writeUIntLE=function(r,n,i,t){if(r=+r,n=n|0,i=i|0,!t){var u=Math.pow(2,8*i)-1;w(this,r,n,i,u,0)}var f=1,a=0;for(this[n]=r&255;++a<i&&(f*=256);)this[n+a]=r/f&255;return n+i};o.prototype.writeUIntBE=function(r,n,i,t){if(r=+r,n=n|0,i=i|0,!t){var u=Math.pow(2,8*i)-1;w(this,r,n,i,u,0)}var f=i-1,a=1;for(this[n+f]=r&255;--f>=0&&(a*=256);)this[n+f]=r/a&255;return n+i};o.prototype.writeUInt8=function(r,n,i){return r=+r,n=n|0,i||w(this,r,n,1,255,0),o.TYPED_ARRAY_SUPPORT||(r=Math.floor(r)),this[n]=r&255,n+1};function C(e,r,n,i){r<0&&(r=65535+r+1);for(var t=0,u=Math.min(e.length-n,2);t<u;++t)e[n+t]=(r&255<<8*(i?t:1-t))>>>(i?t:1-t)*8}o.prototype.writeUInt16LE=function(r,n,i){return r=+r,n=n|0,i||w(this,r,n,2,65535,0),o.TYPED_ARRAY_SUPPORT?(this[n]=r&255,this[n+1]=r>>>8):C(this,r,n,!0),n+2};o.prototype.writeUInt16BE=function(r,n,i){return r=+r,n=n|0,i||w(this,r,n,2,65535,0),o.TYPED_ARRAY_SUPPORT?(this[n]=r>>>8,this[n+1]=r&255):C(this,r,n,!1),n+2};function N(e,r,n,i){r<0&&(r=4294967295+r+1);for(var t=0,u=Math.min(e.length-n,4);t<u;++t)e[n+t]=r>>>(i?t:3-t)*8&255}o.prototype.writeUInt32LE=function(r,n,i){return r=+r,n=n|0,i||w(this,r,n,4,4294967295,0),o.TYPED_ARRAY_SUPPORT?(this[n+3]=r>>>24,this[n+2]=r>>>16,this[n+1]=r>>>8,this[n]=r&255):N(this,r,n,!0),n+4};o.prototype.writeUInt32BE=function(r,n,i){return r=+r,n=n|0,i||w(this,r,n,4,4294967295,0),o.TYPED_ARRAY_SUPPORT?(this[n]=r>>>24,this[n+1]=r>>>16,this[n+2]=r>>>8,this[n+3]=r&255):N(this,r,n,!1),n+4};o.prototype.writeIntLE=function(r,n,i,t){if(r=+r,n=n|0,!t){var u=Math.pow(2,8*i-1);w(this,r,n,i,u-1,-u)}var f=0,a=1,h=0;for(this[n]=r&255;++f<i&&(a*=256);)r<0&&h===0&&this[n+f-1]!==0&&(h=1),this[n+f]=(r/a>>0)-h&255;return n+i};o.prototype.writeIntBE=function(r,n,i,t){if(r=+r,n=n|0,!t){var u=Math.pow(2,8*i-1);w(this,r,n,i,u-1,-u)}var f=i-1,a=1,h=0;for(this[n+f]=r&255;--f>=0&&(a*=256);)r<0&&h===0&&this[n+f+1]!==0&&(h=1),this[n+f]=(r/a>>0)-h&255;return n+i};o.prototype.writeInt8=function(r,n,i){return r=+r,n=n|0,i||w(this,r,n,1,127,-128),o.TYPED_ARRAY_SUPPORT||(r=Math.floor(r)),r<0&&(r=255+r+1),this[n]=r&255,n+1};o.prototype.writeInt16LE=function(r,n,i){return r=+r,n=n|0,i||w(this,r,n,2,32767,-32768),o.TYPED_ARRAY_SUPPORT?(this[n]=r&255,this[n+1]=r>>>8):C(this,r,n,!0),n+2};o.prototype.writeInt16BE=function(r,n,i){return r=+r,n=n|0,i||w(this,r,n,2,32767,-32768),o.TYPED_ARRAY_SUPPORT?(this[n]=r>>>8,this[n+1]=r&255):C(this,r,n,!1),n+2};o.prototype.writeInt32LE=function(r,n,i){return r=+r,n=n|0,i||w(this,r,n,4,2147483647,-2147483648),o.TYPED_ARRAY_SUPPORT?(this[n]=r&255,this[n+1]=r>>>8,this[n+2]=r>>>16,this[n+3]=r>>>24):N(this,r,n,!0),n+4};o.prototype.writeInt32BE=function(r,n,i){return r=+r,n=n|0,i||w(this,r,n,4,2147483647,-2147483648),r<0&&(r=4294967295+r+1),o.TYPED_ARRAY_SUPPORT?(this[n]=r>>>24,this[n+1]=r>>>16,this[n+2]=r>>>8,this[n+3]=r&255):N(this,r,n,!1),n+4};function fr(e,r,n,i,t,u){if(n+i>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function or(e,r,n,i,t){return t||fr(e,r,n,4,34028234663852886e22,-34028234663852886e22),sr(e,r,n,i,23,4),n+4}o.prototype.writeFloatLE=function(r,n,i){return or(this,r,n,!0,i)};o.prototype.writeFloatBE=function(r,n,i){return or(this,r,n,!1,i)};function ar(e,r,n,i,t){return t||fr(e,r,n,8,17976931348623157e292,-17976931348623157e292),sr(e,r,n,i,52,8),n+8}o.prototype.writeDoubleLE=function(r,n,i){return ar(this,r,n,!0,i)};o.prototype.writeDoubleBE=function(r,n,i){return ar(this,r,n,!1,i)};o.prototype.copy=function(r,n,i,t){if(i||(i=0),!t&&t!==0&&(t=this.length),n>=r.length&&(n=r.length),n||(n=0),t>0&&t<i&&(t=i),t===i||r.length===0||this.length===0)return 0;if(n<0)throw new RangeError("targetStart out of bounds");if(i<0||i>=this.length)throw new RangeError("sourceStart out of bounds");if(t<0)throw new RangeError("sourceEnd out of bounds");t>this.length&&(t=this.length),r.length-n<t-i&&(t=r.length-n+i);var u=t-i,f;if(this===r&&i<n&&n<t)for(f=u-1;f>=0;--f)r[f+n]=this[f+i];else if(u<1e3||!o.TYPED_ARRAY_SUPPORT)for(f=0;f<u;++f)r[f+n]=this[f+i];else Uint8Array.prototype.set.call(r,this.subarray(i,i+u),n);return u};o.prototype.fill=function(r,n,i,t){if(typeof r=="string"){if(typeof n=="string"?(t=n,n=0,i=this.length):typeof i=="string"&&(t=i,i=this.length),r.length===1){var u=r.charCodeAt(0);u<256&&(r=u)}if(t!==void 0&&typeof t!="string")throw new TypeError("encoding must be a string");if(typeof t=="string"&&!o.isEncoding(t))throw new TypeError("Unknown encoding: "+t)}else typeof r=="number"&&(r=r&255);if(n<0||this.length<n||this.length<i)throw new RangeError("Out of range index");if(i<=n)return this;n=n>>>0,i=i===void 0?this.length:i>>>0,r||(r=0);var f;if(typeof r=="number")for(f=n;f<i;++f)this[f]=r;else{var a=A(r)?r:k(new o(r,t).toString()),h=a.length;for(f=0;f<i-n;++f)this[f+n]=a[f%h]}return this};var on=/[^+\/0-9A-Za-z-_]/g;function an(e){if(e=hn(e).replace(on,""),e.length<2)return"";for(;e.length%4!==0;)e=e+"=";return e}function hn(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}function cn(e){return e<16?"0"+e.toString(16):e.toString(16)}function k(e,r){r=r||1/0;for(var n,i=e.length,t=null,u=[],f=0;f<i;++f){if(n=e.charCodeAt(f),n>55295&&n<57344){if(!t){if(n>56319){(r-=3)>-1&&u.push(239,191,189);continue}else if(f+1===i){(r-=3)>-1&&u.push(239,191,189);continue}t=n;continue}if(n<56320){(r-=3)>-1&&u.push(239,191,189),t=n;continue}n=(t-55296<<10|n-56320)+65536}else t&&(r-=3)>-1&&u.push(239,191,189);if(t=null,n<128){if((r-=1)<0)break;u.push(n)}else if(n<2048){if((r-=2)<0)break;u.push(n>>6|192,n&63|128)}else if(n<65536){if((r-=3)<0)break;u.push(n>>12|224,n>>6&63|128,n&63|128)}else if(n<1114112){if((r-=4)<0)break;u.push(n>>18|240,n>>12&63|128,n>>6&63|128,n&63|128)}else throw new Error("Invalid code point")}return u}function sn(e){for(var r=[],n=0;n<e.length;++n)r.push(e.charCodeAt(n)&255);return r}function pn(e,r){for(var n,i,t,u=[],f=0;f<e.length&&!((r-=2)<0);++f)n=e.charCodeAt(f),i=n>>8,t=n%256,u.push(t),u.push(i);return u}function hr(e){return $r(an(e))}function L(e,r,n,i){for(var t=0;t<i&&!(t+n>=r.length||t>=e.length);++t)r[t+n]=e[t];return t}function ln(e){return e!==e}function wn(e){return e!=null&&(!!e._isBuffer||cr(e)||xn(e))}function cr(e){return!!e.constructor&&typeof e.constructor.isBuffer=="function"&&e.constructor.isBuffer(e)}function xn(e){return typeof e.readFloatLE=="function"&&typeof e.slice=="function"&&cr(e.slice(0,0))}function F(e,r,n,i,t){var u,f,a=t*8-i-1,h=(1<<a)-1,s=h>>1,p=-7,c=n?t-1:0,E=n?-1:1,x=e[r+c];for(c+=E,u=x&(1<<-p)-1,x>>=-p,p+=a;p>0;u=u*256+e[r+c],c+=E,p-=8);for(f=u&(1<<-p)-1,u>>=-p,p+=i;p>0;f=f*256+e[r+c],c+=E,p-=8);if(u===0)u=1-s;else{if(u===h)return f?NaN:(x?-1:1)*(1/0);f=f+Math.pow(2,i),u=u-s}return(x?-1:1)*f*Math.pow(2,u-i)}function sr(e,r,n,i,t,u){var f,a,h,s=u*8-t-1,p=(1<<s)-1,c=p>>1,E=t===23?Math.pow(2,-24)-Math.pow(2,-77):0,x=i?0:u-1,B=i?1:-1,pr=r<0||r===0&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(a=isNaN(r)?1:0,f=p):(f=Math.floor(Math.log(r)/Math.LN2),r*(h=Math.pow(2,-f))<1&&(f--,h*=2),f+c>=1?r+=E/h:r+=E*Math.pow(2,1-c),r*h>=2&&(f++,h/=2),f+c>=p?(a=0,f=p):f+c>=1?(a=(r*h-1)*Math.pow(2,t),f=f+c):(a=r*Math.pow(2,c-1)*Math.pow(2,t),f=0));t>=8;e[n+x]=a&255,x+=B,a/=256,t-=8);for(f=f<<t|a,s+=t;s>0;e[n+x]=f&255,x+=B,f/=256,s-=8);e[n+x-B]|=pr*128}var S={hour:/(\d+)[H]/i,day:/(\d+)[D]/i,week:/(\d+)[W]/i,month:/(\d+)[M]/i,year:/(\d+)[Y]/i};function Un(e){let r=mn(e);if(r===null)throw new Error(`Cannot fetch datepart from interval: ${e}`);let n=Number(r==="minute"?e:e.slice(0,-1));return n?r==="minute"&&n%10080===0?R("week",n/10080):r==="minute"&&n%1440===0?R("day",n/1440):r==="minute"&&n%60===0?R("hour",n/60):r==="hour"&&n%168===0?R("week",n/168):r==="hour"&&n%24===0?R(n===24?"hour":"day",n===24?24:n/24):r==="day"&&n%7===0?R("week",n/7):r==="month"&&n%12===0?R("year",n/12):R(r,n):R(r,1)}function mn(e){if(!isNaN(Number(e)))return"minute";let n=`1${e.slice(-1)}`;switch(!0){case S.hour.test(n):return"hour";case S.day.test(n):return"day";case S.week.test(n):return"week";case S.month.test(n):return"month";case S.year.test(n):return"year";default:return null}}function R(e,r){return{datepart:e,value:r,timeframe:An(e,r)}}function En(e){return[1,3,5,15,30].includes(e)}function yn(e){return[1,2,3,4,12].includes(e)}function An(e,r){switch(e){case"minute":return En(r)?`${r}m`:"1m";case"hour":return yn(r)?`${r}h`:"1h";case"day":return"1d";case"week":return"1w";case"month":return"1M";case"year":return"1Y";default:throw new Error(`Unsupported datepart: ${e}`)}}export{Un as getDatepartValue,mn as identityDatepart,yn as inHourCandles,En as inMinCandles};
2
+ /*! Bundled license information:
3
+
4
+ @esbuild-plugins/node-globals-polyfill/Buffer.js:
5
+ (*!
6
+ * The buffer module from node.js, for the browser.
7
+ *
8
+ * @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
9
+ * @license MIT
10
+ *)
11
+ */