@dodoex/wallet-web3 0.0.41 → 0.0.43-0

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 (86) hide show
  1. package/dist/{DefaultJsonRpcProvider-81dbd3f9.js → DefaultJsonRpcProvider-d03291cf.js} +1 -1
  2. package/dist/__node-resolve_empty-7cc52421.js +1 -0
  3. package/dist/__tslib-c18c68ca.js +1 -0
  4. package/dist/{blocto-a553b391.js → blocto-4f268393.js} +1 -1
  5. package/dist/{bn-8f7cc9b5.js → bn-cd5d9c7e.js} +1 -1
  6. package/dist/{browser-ponyfill-4134b2b7.js → browser-ponyfill-0d656c3b.js} +1 -1
  7. package/dist/cjs/{DefaultJsonRpcProvider-851de86a.cjs → DefaultJsonRpcProvider-fe0308e2.cjs} +1 -1
  8. package/dist/cjs/{__node-resolve_empty-04cc3662.cjs → __node-resolve_empty-8a1ddcdf.cjs} +1 -1
  9. package/dist/cjs/__tslib-eb9eb2b7.cjs +1 -0
  10. package/dist/cjs/{blocto-1d2d3abc.cjs → blocto-d45a7d82.cjs} +1 -1
  11. package/dist/cjs/{bn-8a65a921.cjs → bn-94c30d2e.cjs} +1 -1
  12. package/dist/cjs/{browser-ponyfill-96a14706.cjs → browser-ponyfill-b3718e5b.cjs} +1 -1
  13. package/dist/cjs/{draggabilly-326f0353.cjs → draggabilly-2a4e5cff.cjs} +1 -1
  14. package/dist/cjs/{ethers-c6e7830c.cjs → ethers-f94c032f.cjs} +1 -1
  15. package/dist/cjs/{id-ac2184da.cjs → id-52024487.cjs} +1 -1
  16. package/dist/cjs/index-0740e7fe.cjs +1 -0
  17. package/dist/cjs/{index-8d32723e.cjs → index-2eb62a28.cjs} +1 -1
  18. package/dist/cjs/{index-6130f88a.cjs → index-38a6dc28.cjs} +2 -2
  19. package/dist/cjs/{index-38a82c12.cjs → index-8a11ae09.cjs} +1 -1
  20. package/dist/cjs/{index-c6a78b5c.cjs → index-8cd59ca8.cjs} +1 -1
  21. package/dist/cjs/{index-4f46ab04.cjs → index-9dc5efa7.cjs} +1 -1
  22. package/dist/cjs/{index-b3a93c7d.cjs → index-afa45043.cjs} +1 -1
  23. package/dist/cjs/index-d886349d.cjs +9 -0
  24. package/dist/cjs/{index-97c32dcf.cjs → index-dd475117.cjs} +1 -1
  25. package/dist/cjs/index-e0461bd6.cjs +6 -0
  26. package/dist/cjs/{index-d89005f4.cjs → index-f6a4cadd.cjs} +1 -1
  27. package/dist/cjs/{index-01b3872e.cjs → index-f78f51c3.cjs} +1 -1
  28. package/dist/cjs/index.cjs +1 -1
  29. package/dist/cjs/{index.es-168fe2b1.cjs → index.es-e2c97fd8.cjs} +1 -1
  30. package/dist/cjs/{interface-f6b53727.cjs → interface-a109a0d8.cjs} +1 -1
  31. package/dist/cjs/{lib-typedarrays-05755aa6.cjs → lib-typedarrays-06843b62.cjs} +1 -1
  32. package/dist/cjs/{portis-7873ce6a.cjs → portis-92310876.cjs} +1 -1
  33. package/dist/cjs/{provider-d7c647ea.cjs → provider-a2e5d503.cjs} +1 -1
  34. package/dist/cjs/providers/connector/injected.d.ts +1 -1
  35. package/dist/cjs/providers/connector/types.d.ts +1 -0
  36. package/dist/cjs/{rainbow-43c8e5f6.cjs → rainbow-8c27c228.cjs} +1 -1
  37. package/dist/cjs/sha224-a9b32339.cjs +1 -0
  38. package/dist/cjs/{sha256-7cc68713.cjs → sha256-2e691c21.cjs} +1 -1
  39. package/dist/cjs/{uAuth-6aa71b34.cjs → uAuth-323e7587.cjs} +1 -1
  40. package/dist/cjs/walletConnect-39af2510.cjs +1 -0
  41. package/dist/cjs/walletLink-cb148ef1.cjs +3 -0
  42. package/dist/{draggabilly-291f869b.js → draggabilly-12ef51c6.js} +1 -1
  43. package/dist/{ethers-f8f094be.js → ethers-20b88c06.js} +1 -1
  44. package/dist/{id-dcb529f4.js → id-5fb9d202.js} +1 -1
  45. package/dist/{index-a1df7720.js → index-198785fa.js} +1 -1
  46. package/dist/index-2e23cc8c.js +6 -0
  47. package/dist/{index-89a7e976.js → index-53bc60c6.js} +1 -1
  48. package/dist/index-6e0697ab.js +9 -0
  49. package/dist/{index-7a7a090a.js → index-8d5315df.js} +1 -1
  50. package/dist/{index-cebac794.js → index-9b0e9b64.js} +2 -2
  51. package/dist/{index-914dc773.js → index-a35d2562.js} +1 -1
  52. package/dist/{index-20ce8a4c.js → index-c8e896d5.js} +1 -1
  53. package/dist/index-d00482ad.js +1 -0
  54. package/dist/{index-4e6b81d8.js → index-d1fdba35.js} +1 -1
  55. package/dist/{index-e3070128.js → index-d605fbc1.js} +1 -1
  56. package/dist/index-ec6e039e.js +1 -0
  57. package/dist/{index.es-b6986074.js → index.es-9e9bc056.js} +1 -1
  58. package/dist/index.js +1 -1
  59. package/dist/{interface-6c3ec32a.js → interface-a6f33bb4.js} +1 -1
  60. package/dist/{lib-typedarrays-f1051e37.js → lib-typedarrays-60e6aa6b.js} +1 -1
  61. package/dist/{portis-6c321b6b.js → portis-19afe2ea.js} +1 -1
  62. package/dist/{provider-0a241f15.js → provider-6f989b4e.js} +1 -1
  63. package/dist/providers/connector/injected.d.ts +1 -1
  64. package/dist/providers/connector/types.d.ts +1 -0
  65. package/dist/rainbow-463c6dc0.js +1 -0
  66. package/dist/sha224-fc7a621b.js +1 -0
  67. package/dist/{sha256-79cd8cb2.js → sha256-3d0dbba6.js} +1 -1
  68. package/dist/{uAuth-57530103.js → uAuth-d42a0af6.js} +1 -1
  69. package/dist/walletConnect-380a5d1c.js +1 -0
  70. package/dist/walletLink-b1651399.js +3 -0
  71. package/package.json +2 -2
  72. package/dist/__node-resolve_empty-314df16e.js +0 -1
  73. package/dist/__tslib-895a7349.js +0 -1
  74. package/dist/cjs/__tslib-07f80053.cjs +0 -1
  75. package/dist/cjs/index-4685dfbc.cjs +0 -9
  76. package/dist/cjs/index-823d3a25.cjs +0 -6
  77. package/dist/cjs/sha224-86e8cc7f.cjs +0 -1
  78. package/dist/cjs/walletConnect-b0df4f12.cjs +0 -1
  79. package/dist/cjs/walletLink-eb56d177.cjs +0 -3
  80. package/dist/index-bc061f7b.js +0 -9
  81. package/dist/index-cbfb042c.js +0 -1
  82. package/dist/index-cec5c507.js +0 -6
  83. package/dist/rainbow-43a583fd.js +0 -1
  84. package/dist/sha224-1e5a1736.js +0 -1
  85. package/dist/walletConnect-dc900305.js +0 -1
  86. package/dist/walletLink-7f641f02.js +0 -3
@@ -1 +1 @@
1
- import{c as t,k as i}from"./index-bc061f7b.js";import{r}from"./__node-resolve_empty-314df16e.js";import{isBytes as e,hexlify as n,isHexString as h,arrayify as o}from"@ethersproject/bytes";let s=!1,u=!1;const a={debug:1,default:2,info:2,warning:3,error:4,off:5};let l=a.default,m=null;const f=function(){try{const t=[];if(["NFD","NFC","NFKD","NFKC"].forEach((i=>{try{if("test"!=="test".normalize(i))throw new Error("bad normalize")}catch(r){t.push(i)}})),t.length)throw new Error("missing "+t.join(", "));if(String.fromCharCode(233).normalize("NFD")!==String.fromCharCode(101,769))throw new Error("broken implementation")}catch(t){return t.message}return null}();var d,p;!function(t){t.DEBUG="DEBUG",t.INFO="INFO",t.WARNING="WARNING",t.ERROR="ERROR",t.OFF="OFF"}(d||(d={})),function(t){t.UNKNOWN_ERROR="UNKNOWN_ERROR",t.NOT_IMPLEMENTED="NOT_IMPLEMENTED",t.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",t.NETWORK_ERROR="NETWORK_ERROR",t.SERVER_ERROR="SERVER_ERROR",t.TIMEOUT="TIMEOUT",t.BUFFER_OVERRUN="BUFFER_OVERRUN",t.NUMERIC_FAULT="NUMERIC_FAULT",t.MISSING_NEW="MISSING_NEW",t.INVALID_ARGUMENT="INVALID_ARGUMENT",t.MISSING_ARGUMENT="MISSING_ARGUMENT",t.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",t.CALL_EXCEPTION="CALL_EXCEPTION",t.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",t.NONCE_EXPIRED="NONCE_EXPIRED",t.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",t.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",t.TRANSACTION_REPLACED="TRANSACTION_REPLACED",t.ACTION_REJECTED="ACTION_REJECTED"}(p||(p={}));const g="0123456789abcdef";class c{constructor(t){Object.defineProperty(this,"version",{enumerable:!0,value:t,writable:!1})}_log(t,i){const r=t.toLowerCase();null==a[r]&&this.throwArgumentError("invalid log level name","logLevel",t),l>a[r]||console.log.apply(console,i)}debug(...t){this._log(c.levels.DEBUG,t)}info(...t){this._log(c.levels.INFO,t)}warn(...t){this._log(c.levels.WARNING,t)}makeError(t,i,r){if(u)return this.makeError("censored error",i,{});i||(i=c.errors.UNKNOWN_ERROR),r||(r={});const e=[];Object.keys(r).forEach((t=>{const i=r[t];try{if(i instanceof Uint8Array){let r="";for(let t=0;t<i.length;t++)r+=g[i[t]>>4],r+=g[15&i[t]];e.push(t+"=Uint8Array(0x"+r+")")}else e.push(t+"="+JSON.stringify(i))}catch(i){e.push(t+"="+JSON.stringify(r[t].toString()))}})),e.push(`code=${i}`),e.push(`version=${this.version}`);const n=t;let h="";switch(i){case p.NUMERIC_FAULT:{h="NUMERIC_FAULT";const i=t;switch(i){case"overflow":case"underflow":case"division-by-zero":h+="-"+i;break;case"negative-power":case"negative-width":h+="-unsupported";break;case"unbound-bitwise-result":h+="-unbound-result"}break}case p.CALL_EXCEPTION:case p.INSUFFICIENT_FUNDS:case p.MISSING_NEW:case p.NONCE_EXPIRED:case p.REPLACEMENT_UNDERPRICED:case p.TRANSACTION_REPLACED:case p.UNPREDICTABLE_GAS_LIMIT:h=i}h&&(t+=" [ See: https://links.ethers.org/v5-errors-"+h+" ]"),e.length&&(t+=" ("+e.join(", ")+")");const o=new Error(t);return o.reason=n,o.code=i,Object.keys(r).forEach((function(t){o[t]=r[t]})),o}throwError(t,i,r){throw this.makeError(t,i,r)}throwArgumentError(t,i,r){return this.throwError(t,c.errors.INVALID_ARGUMENT,{argument:i,value:r})}assert(t,i,r,e){t||this.throwError(i,r,e)}assertArgument(t,i,r,e){t||this.throwArgumentError(i,r,e)}checkNormalize(t){f&&this.throwError("platform missing String.prototype.normalize",c.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:f})}checkSafeUint53(t,i){"number"==typeof t&&(null==i&&(i="value not safe"),(t<0||t>=9007199254740991)&&this.throwError(i,c.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:t}),t%1&&this.throwError(i,c.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:t}))}checkArgumentCount(t,i,r){r=r?": "+r:"",t<i&&this.throwError("missing argument"+r,c.errors.MISSING_ARGUMENT,{count:t,expectedCount:i}),t>i&&this.throwError("too many arguments"+r,c.errors.UNEXPECTED_ARGUMENT,{count:t,expectedCount:i})}checkNew(t,i){t!==Object&&null!=t||this.throwError("missing new",c.errors.MISSING_NEW,{name:i.name})}checkAbstract(t,i){t===i?this.throwError("cannot instantiate abstract class "+JSON.stringify(i.name)+" directly; use a sub-class",c.errors.UNSUPPORTED_OPERATION,{name:t.name,operation:"new"}):t!==Object&&null!=t||this.throwError("missing new",c.errors.MISSING_NEW,{name:i.name})}static globalLogger(){return m||(m=new c("logger/5.7.0")),m}static setCensorship(t,i){if(!t&&i&&this.globalLogger().throwError("cannot permanently disable censorship",c.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),s){if(!t)return;this.globalLogger().throwError("error censorship permanent",c.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}u=!!t,s=!!i}static setLogLevel(t){const i=a[t.toLowerCase()];null!=i?l=i:c.globalLogger().warn("invalid log level - "+t)}static from(t){return new c(t)}}c.errors=p,c.levels=d;var M=Object.freeze({__proto__:null,get LogLevel(){return d},get ErrorCode(){return p},Logger:c}),v={exports:{}};!function(t,i){function e(t,i){if(!t)throw new Error(i||"Assertion failed")}function n(t,i){t.super_=i;var r=function(){};r.prototype=i.prototype,t.prototype=new r,t.prototype.constructor=t}function h(t,i,r){if(h.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==i&&"be"!==i||(r=i,i=10),this._init(t||0,i||10,r||"be"))}var o;"object"==typeof t?t.exports=h:i.BN=h,h.BN=h,h.wordSize=26;try{o="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:r.Buffer}catch(t){}function s(t,i){var r=t.charCodeAt(i);return r>=48&&r<=57?r-48:r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:void e(!1,"Invalid character in "+t)}function u(t,i,r){var e=s(t,r);return r-1>=i&&(e|=s(t,r-1)<<4),e}function a(t,i,r,n){for(var h=0,o=0,s=Math.min(t.length,r),u=i;u<s;u++){var a=t.charCodeAt(u)-48;h*=n,o=a>=49?a-49+10:a>=17?a-17+10:a,e(a>=0&&o<n,"Invalid character"),h+=o}return h}function l(t,i){t.words=i.words,t.length=i.length,t.negative=i.negative,t.red=i.red}if(h.isBN=function(t){return t instanceof h||null!==t&&"object"==typeof t&&t.constructor.wordSize===h.wordSize&&Array.isArray(t.words)},h.max=function(t,i){return t.cmp(i)>0?t:i},h.min=function(t,i){return t.cmp(i)<0?t:i},h.prototype._init=function(t,i,r){if("number"==typeof t)return this._initNumber(t,i,r);if("object"==typeof t)return this._initArray(t,i,r);"hex"===i&&(i=16),e(i===(0|i)&&i>=2&&i<=36);var n=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&(n++,this.negative=1),n<t.length&&(16===i?this._parseHex(t,n,r):(this._parseBase(t,i,n),"le"===r&&this._initArray(this.toArray(),i,r)))},h.prototype._initNumber=function(t,i,r){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(e(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===r&&this._initArray(this.toArray(),i,r)},h.prototype._initArray=function(t,i,r){if(e("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var n=0;n<this.length;n++)this.words[n]=0;var h,o,s=0;if("be"===r)for(n=t.length-1,h=0;n>=0;n-=3)o=t[n]|t[n-1]<<8|t[n-2]<<16,this.words[h]|=o<<s&67108863,this.words[h+1]=o>>>26-s&67108863,(s+=24)>=26&&(s-=26,h++);else if("le"===r)for(n=0,h=0;n<t.length;n+=3)o=t[n]|t[n+1]<<8|t[n+2]<<16,this.words[h]|=o<<s&67108863,this.words[h+1]=o>>>26-s&67108863,(s+=24)>=26&&(s-=26,h++);return this._strip()},h.prototype._parseHex=function(t,i,r){this.length=Math.ceil((t.length-i)/6),this.words=new Array(this.length);for(var e=0;e<this.length;e++)this.words[e]=0;var n,h=0,o=0;if("be"===r)for(e=t.length-1;e>=i;e-=2)n=u(t,i,e)<<h,this.words[o]|=67108863&n,h>=18?(h-=18,o+=1,this.words[o]|=n>>>26):h+=8;else for(e=(t.length-i)%2==0?i+1:i;e<t.length;e+=2)n=u(t,i,e)<<h,this.words[o]|=67108863&n,h>=18?(h-=18,o+=1,this.words[o]|=n>>>26):h+=8;this._strip()},h.prototype._parseBase=function(t,i,r){this.words=[0],this.length=1;for(var e=0,n=1;n<=67108863;n*=i)e++;e--,n=n/i|0;for(var h=t.length-r,o=h%e,s=Math.min(h,h-o)+r,u=0,l=r;l<s;l+=e)u=a(t,l,l+e,i),this.imuln(n),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u);if(0!==o){var m=1;for(u=a(t,l,t.length,i),l=0;l<o;l++)m*=i;this.imuln(m),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u)}this._strip()},h.prototype.copy=function(t){t.words=new Array(this.length);for(var i=0;i<this.length;i++)t.words[i]=this.words[i];t.length=this.length,t.negative=this.negative,t.red=this.red},h.prototype._move=function(t){l(t,this)},h.prototype.clone=function(){var t=new h(null);return this.copy(t),t},h.prototype._expand=function(t){for(;this.length<t;)this.words[this.length++]=0;return this},h.prototype._strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},h.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},"undefined"!=typeof Symbol&&"function"==typeof Symbol.for)try{h.prototype[Symbol.for("nodejs.util.inspect.custom")]=m}catch(t){h.prototype.inspect=m}else h.prototype.inspect=m;function m(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var f=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],d=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],p=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function g(t,i,r){r.negative=i.negative^t.negative;var e=t.length+i.length|0;r.length=e,e=e-1|0;var n=0|t.words[0],h=0|i.words[0],o=n*h,s=67108863&o,u=o/67108864|0;r.words[0]=s;for(var a=1;a<e;a++){for(var l=u>>>26,m=67108863&u,f=Math.min(a,i.length-1),d=Math.max(0,a-t.length+1);d<=f;d++){var p=a-d|0;l+=(o=(n=0|t.words[p])*(h=0|i.words[d])+m)/67108864|0,m=67108863&o}r.words[a]=0|m,u=0|l}return 0!==u?r.words[a]=0|u:r.length--,r._strip()}h.prototype.toString=function(t,i){var r;if(i=0|i||1,16===(t=t||10)||"hex"===t){r="";for(var n=0,h=0,o=0;o<this.length;o++){var s=this.words[o],u=(16777215&(s<<n|h)).toString(16);h=s>>>24-n&16777215,(n+=2)>=26&&(n-=26,o--),r=0!==h||o!==this.length-1?f[6-u.length]+u+r:u+r}for(0!==h&&(r=h.toString(16)+r);r.length%i!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}if(t===(0|t)&&t>=2&&t<=36){var a=d[t],l=p[t];r="";var m=this.clone();for(m.negative=0;!m.isZero();){var g=m.modrn(l).toString(t);r=(m=m.idivn(l)).isZero()?g+r:f[a-g.length]+g+r}for(this.isZero()&&(r="0"+r);r.length%i!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}e(!1,"Base should be between 2 and 36")},h.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&e(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},h.prototype.toJSON=function(){return this.toString(16,2)},o&&(h.prototype.toBuffer=function(t,i){return this.toArrayLike(o,t,i)}),h.prototype.toArray=function(t,i){return this.toArrayLike(Array,t,i)},h.prototype.toArrayLike=function(t,i,r){this._strip();var n=this.byteLength(),h=r||Math.max(1,n);e(n<=h,"byte array longer than desired length"),e(h>0,"Requested array length <= 0");var o=function(t,i){return t.allocUnsafe?t.allocUnsafe(i):new t(i)}(t,h);return this["_toArrayLike"+("le"===i?"LE":"BE")](o,n),o},h.prototype._toArrayLikeLE=function(t,i){for(var r=0,e=0,n=0,h=0;n<this.length;n++){var o=this.words[n]<<h|e;t[r++]=255&o,r<t.length&&(t[r++]=o>>8&255),r<t.length&&(t[r++]=o>>16&255),6===h?(r<t.length&&(t[r++]=o>>24&255),e=0,h=0):(e=o>>>24,h+=2)}if(r<t.length)for(t[r++]=e;r<t.length;)t[r++]=0},h.prototype._toArrayLikeBE=function(t,i){for(var r=t.length-1,e=0,n=0,h=0;n<this.length;n++){var o=this.words[n]<<h|e;t[r--]=255&o,r>=0&&(t[r--]=o>>8&255),r>=0&&(t[r--]=o>>16&255),6===h?(r>=0&&(t[r--]=o>>24&255),e=0,h=0):(e=o>>>24,h+=2)}if(r>=0)for(t[r--]=e;r>=0;)t[r--]=0},Math.clz32?h.prototype._countBits=function(t){return 32-Math.clz32(t)}:h.prototype._countBits=function(t){var i=t,r=0;return i>=4096&&(r+=13,i>>>=13),i>=64&&(r+=7,i>>>=7),i>=8&&(r+=4,i>>>=4),i>=2&&(r+=2,i>>>=2),r+i},h.prototype._zeroBits=function(t){if(0===t)return 26;var i=t,r=0;return 0==(8191&i)&&(r+=13,i>>>=13),0==(127&i)&&(r+=7,i>>>=7),0==(15&i)&&(r+=4,i>>>=4),0==(3&i)&&(r+=2,i>>>=2),0==(1&i)&&r++,r},h.prototype.bitLength=function(){var t=this.words[this.length-1],i=this._countBits(t);return 26*(this.length-1)+i},h.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,i=0;i<this.length;i++){var r=this._zeroBits(this.words[i]);if(t+=r,26!==r)break}return t},h.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},h.prototype.toTwos=function(t){return 0!==this.negative?this.abs().inotn(t).iaddn(1):this.clone()},h.prototype.fromTwos=function(t){return this.testn(t-1)?this.notn(t).iaddn(1).ineg():this.clone()},h.prototype.isNeg=function(){return 0!==this.negative},h.prototype.neg=function(){return this.clone().ineg()},h.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},h.prototype.iuor=function(t){for(;this.length<t.length;)this.words[this.length++]=0;for(var i=0;i<t.length;i++)this.words[i]=this.words[i]|t.words[i];return this._strip()},h.prototype.ior=function(t){return e(0==(this.negative|t.negative)),this.iuor(t)},h.prototype.or=function(t){return this.length>t.length?this.clone().ior(t):t.clone().ior(this)},h.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},h.prototype.iuand=function(t){var i;i=this.length>t.length?t:this;for(var r=0;r<i.length;r++)this.words[r]=this.words[r]&t.words[r];return this.length=i.length,this._strip()},h.prototype.iand=function(t){return e(0==(this.negative|t.negative)),this.iuand(t)},h.prototype.and=function(t){return this.length>t.length?this.clone().iand(t):t.clone().iand(this)},h.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},h.prototype.iuxor=function(t){var i,r;this.length>t.length?(i=this,r=t):(i=t,r=this);for(var e=0;e<r.length;e++)this.words[e]=i.words[e]^r.words[e];if(this!==i)for(;e<i.length;e++)this.words[e]=i.words[e];return this.length=i.length,this._strip()},h.prototype.ixor=function(t){return e(0==(this.negative|t.negative)),this.iuxor(t)},h.prototype.xor=function(t){return this.length>t.length?this.clone().ixor(t):t.clone().ixor(this)},h.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},h.prototype.inotn=function(t){e("number"==typeof t&&t>=0);var i=0|Math.ceil(t/26),r=t%26;this._expand(i),r>0&&i--;for(var n=0;n<i;n++)this.words[n]=67108863&~this.words[n];return r>0&&(this.words[n]=~this.words[n]&67108863>>26-r),this._strip()},h.prototype.notn=function(t){return this.clone().inotn(t)},h.prototype.setn=function(t,i){e("number"==typeof t&&t>=0);var r=t/26|0,n=t%26;return this._expand(r+1),this.words[r]=i?this.words[r]|1<<n:this.words[r]&~(1<<n),this._strip()},h.prototype.iadd=function(t){var i,r,e;if(0!==this.negative&&0===t.negative)return this.negative=0,i=this.isub(t),this.negative^=1,this._normSign();if(0===this.negative&&0!==t.negative)return t.negative=0,i=this.isub(t),t.negative=1,i._normSign();this.length>t.length?(r=this,e=t):(r=t,e=this);for(var n=0,h=0;h<e.length;h++)i=(0|r.words[h])+(0|e.words[h])+n,this.words[h]=67108863&i,n=i>>>26;for(;0!==n&&h<r.length;h++)i=(0|r.words[h])+n,this.words[h]=67108863&i,n=i>>>26;if(this.length=r.length,0!==n)this.words[this.length]=n,this.length++;else if(r!==this)for(;h<r.length;h++)this.words[h]=r.words[h];return this},h.prototype.add=function(t){var i;return 0!==t.negative&&0===this.negative?(t.negative=0,i=this.sub(t),t.negative^=1,i):0===t.negative&&0!==this.negative?(this.negative=0,i=t.sub(this),this.negative=1,i):this.length>t.length?this.clone().iadd(t):t.clone().iadd(this)},h.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var i=this.iadd(t);return t.negative=1,i._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,e,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(r=this,e=t):(r=t,e=this);for(var h=0,o=0;o<e.length;o++)h=(i=(0|r.words[o])-(0|e.words[o])+h)>>26,this.words[o]=67108863&i;for(;0!==h&&o<r.length;o++)h=(i=(0|r.words[o])+h)>>26,this.words[o]=67108863&i;if(0===h&&o<r.length&&r!==this)for(;o<r.length;o++)this.words[o]=r.words[o];return this.length=Math.max(this.length,o),r!==this&&(this.negative=1),this._strip()},h.prototype.sub=function(t){return this.clone().isub(t)};var c=function(t,i,r){var e,n,h,o=t.words,s=i.words,u=r.words,a=0,l=0|o[0],m=8191&l,f=l>>>13,d=0|o[1],p=8191&d,g=d>>>13,c=0|o[2],M=8191&c,v=c>>>13,w=0|o[3],y=8191&w,b=w>>>13,E=0|o[4],N=8191&E,_=E>>>13,R=0|o[5],S=8191&R,A=R>>>13,I=0|o[6],T=8191&I,O=I>>>13,U=0|o[7],C=8191&U,k=U>>>13,x=0|o[8],L=8191&x,P=x>>>13,D=0|o[9],B=8191&D,F=D>>>13,G=0|s[0],Z=8191&G,q=G>>>13,z=0|s[1],j=8191&z,X=z>>>13,K=0|s[2],V=8191&K,W=K>>>13,H=0|s[3],J=8191&H,$=H>>>13,Q=0|s[4],Y=8191&Q,tt=Q>>>13,it=0|s[5],rt=8191&it,et=it>>>13,nt=0|s[6],ht=8191&nt,ot=nt>>>13,st=0|s[7],ut=8191&st,at=st>>>13,lt=0|s[8],mt=8191&lt,ft=lt>>>13,dt=0|s[9],pt=8191&dt,gt=dt>>>13;r.negative=t.negative^i.negative,r.length=19;var ct=(a+(e=Math.imul(m,Z))|0)+((8191&(n=(n=Math.imul(m,q))+Math.imul(f,Z)|0))<<13)|0;a=((h=Math.imul(f,q))+(n>>>13)|0)+(ct>>>26)|0,ct&=67108863,e=Math.imul(p,Z),n=(n=Math.imul(p,q))+Math.imul(g,Z)|0,h=Math.imul(g,q);var Mt=(a+(e=e+Math.imul(m,j)|0)|0)+((8191&(n=(n=n+Math.imul(m,X)|0)+Math.imul(f,j)|0))<<13)|0;a=((h=h+Math.imul(f,X)|0)+(n>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,e=Math.imul(M,Z),n=(n=Math.imul(M,q))+Math.imul(v,Z)|0,h=Math.imul(v,q),e=e+Math.imul(p,j)|0,n=(n=n+Math.imul(p,X)|0)+Math.imul(g,j)|0,h=h+Math.imul(g,X)|0;var vt=(a+(e=e+Math.imul(m,V)|0)|0)+((8191&(n=(n=n+Math.imul(m,W)|0)+Math.imul(f,V)|0))<<13)|0;a=((h=h+Math.imul(f,W)|0)+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,e=Math.imul(y,Z),n=(n=Math.imul(y,q))+Math.imul(b,Z)|0,h=Math.imul(b,q),e=e+Math.imul(M,j)|0,n=(n=n+Math.imul(M,X)|0)+Math.imul(v,j)|0,h=h+Math.imul(v,X)|0,e=e+Math.imul(p,V)|0,n=(n=n+Math.imul(p,W)|0)+Math.imul(g,V)|0,h=h+Math.imul(g,W)|0;var wt=(a+(e=e+Math.imul(m,J)|0)|0)+((8191&(n=(n=n+Math.imul(m,$)|0)+Math.imul(f,J)|0))<<13)|0;a=((h=h+Math.imul(f,$)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,e=Math.imul(N,Z),n=(n=Math.imul(N,q))+Math.imul(_,Z)|0,h=Math.imul(_,q),e=e+Math.imul(y,j)|0,n=(n=n+Math.imul(y,X)|0)+Math.imul(b,j)|0,h=h+Math.imul(b,X)|0,e=e+Math.imul(M,V)|0,n=(n=n+Math.imul(M,W)|0)+Math.imul(v,V)|0,h=h+Math.imul(v,W)|0,e=e+Math.imul(p,J)|0,n=(n=n+Math.imul(p,$)|0)+Math.imul(g,J)|0,h=h+Math.imul(g,$)|0;var yt=(a+(e=e+Math.imul(m,Y)|0)|0)+((8191&(n=(n=n+Math.imul(m,tt)|0)+Math.imul(f,Y)|0))<<13)|0;a=((h=h+Math.imul(f,tt)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,e=Math.imul(S,Z),n=(n=Math.imul(S,q))+Math.imul(A,Z)|0,h=Math.imul(A,q),e=e+Math.imul(N,j)|0,n=(n=n+Math.imul(N,X)|0)+Math.imul(_,j)|0,h=h+Math.imul(_,X)|0,e=e+Math.imul(y,V)|0,n=(n=n+Math.imul(y,W)|0)+Math.imul(b,V)|0,h=h+Math.imul(b,W)|0,e=e+Math.imul(M,J)|0,n=(n=n+Math.imul(M,$)|0)+Math.imul(v,J)|0,h=h+Math.imul(v,$)|0,e=e+Math.imul(p,Y)|0,n=(n=n+Math.imul(p,tt)|0)+Math.imul(g,Y)|0,h=h+Math.imul(g,tt)|0;var bt=(a+(e=e+Math.imul(m,rt)|0)|0)+((8191&(n=(n=n+Math.imul(m,et)|0)+Math.imul(f,rt)|0))<<13)|0;a=((h=h+Math.imul(f,et)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,e=Math.imul(T,Z),n=(n=Math.imul(T,q))+Math.imul(O,Z)|0,h=Math.imul(O,q),e=e+Math.imul(S,j)|0,n=(n=n+Math.imul(S,X)|0)+Math.imul(A,j)|0,h=h+Math.imul(A,X)|0,e=e+Math.imul(N,V)|0,n=(n=n+Math.imul(N,W)|0)+Math.imul(_,V)|0,h=h+Math.imul(_,W)|0,e=e+Math.imul(y,J)|0,n=(n=n+Math.imul(y,$)|0)+Math.imul(b,J)|0,h=h+Math.imul(b,$)|0,e=e+Math.imul(M,Y)|0,n=(n=n+Math.imul(M,tt)|0)+Math.imul(v,Y)|0,h=h+Math.imul(v,tt)|0,e=e+Math.imul(p,rt)|0,n=(n=n+Math.imul(p,et)|0)+Math.imul(g,rt)|0,h=h+Math.imul(g,et)|0;var Et=(a+(e=e+Math.imul(m,ht)|0)|0)+((8191&(n=(n=n+Math.imul(m,ot)|0)+Math.imul(f,ht)|0))<<13)|0;a=((h=h+Math.imul(f,ot)|0)+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863,e=Math.imul(C,Z),n=(n=Math.imul(C,q))+Math.imul(k,Z)|0,h=Math.imul(k,q),e=e+Math.imul(T,j)|0,n=(n=n+Math.imul(T,X)|0)+Math.imul(O,j)|0,h=h+Math.imul(O,X)|0,e=e+Math.imul(S,V)|0,n=(n=n+Math.imul(S,W)|0)+Math.imul(A,V)|0,h=h+Math.imul(A,W)|0,e=e+Math.imul(N,J)|0,n=(n=n+Math.imul(N,$)|0)+Math.imul(_,J)|0,h=h+Math.imul(_,$)|0,e=e+Math.imul(y,Y)|0,n=(n=n+Math.imul(y,tt)|0)+Math.imul(b,Y)|0,h=h+Math.imul(b,tt)|0,e=e+Math.imul(M,rt)|0,n=(n=n+Math.imul(M,et)|0)+Math.imul(v,rt)|0,h=h+Math.imul(v,et)|0,e=e+Math.imul(p,ht)|0,n=(n=n+Math.imul(p,ot)|0)+Math.imul(g,ht)|0,h=h+Math.imul(g,ot)|0;var Nt=(a+(e=e+Math.imul(m,ut)|0)|0)+((8191&(n=(n=n+Math.imul(m,at)|0)+Math.imul(f,ut)|0))<<13)|0;a=((h=h+Math.imul(f,at)|0)+(n>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,e=Math.imul(L,Z),n=(n=Math.imul(L,q))+Math.imul(P,Z)|0,h=Math.imul(P,q),e=e+Math.imul(C,j)|0,n=(n=n+Math.imul(C,X)|0)+Math.imul(k,j)|0,h=h+Math.imul(k,X)|0,e=e+Math.imul(T,V)|0,n=(n=n+Math.imul(T,W)|0)+Math.imul(O,V)|0,h=h+Math.imul(O,W)|0,e=e+Math.imul(S,J)|0,n=(n=n+Math.imul(S,$)|0)+Math.imul(A,J)|0,h=h+Math.imul(A,$)|0,e=e+Math.imul(N,Y)|0,n=(n=n+Math.imul(N,tt)|0)+Math.imul(_,Y)|0,h=h+Math.imul(_,tt)|0,e=e+Math.imul(y,rt)|0,n=(n=n+Math.imul(y,et)|0)+Math.imul(b,rt)|0,h=h+Math.imul(b,et)|0,e=e+Math.imul(M,ht)|0,n=(n=n+Math.imul(M,ot)|0)+Math.imul(v,ht)|0,h=h+Math.imul(v,ot)|0,e=e+Math.imul(p,ut)|0,n=(n=n+Math.imul(p,at)|0)+Math.imul(g,ut)|0,h=h+Math.imul(g,at)|0;var _t=(a+(e=e+Math.imul(m,mt)|0)|0)+((8191&(n=(n=n+Math.imul(m,ft)|0)+Math.imul(f,mt)|0))<<13)|0;a=((h=h+Math.imul(f,ft)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,e=Math.imul(B,Z),n=(n=Math.imul(B,q))+Math.imul(F,Z)|0,h=Math.imul(F,q),e=e+Math.imul(L,j)|0,n=(n=n+Math.imul(L,X)|0)+Math.imul(P,j)|0,h=h+Math.imul(P,X)|0,e=e+Math.imul(C,V)|0,n=(n=n+Math.imul(C,W)|0)+Math.imul(k,V)|0,h=h+Math.imul(k,W)|0,e=e+Math.imul(T,J)|0,n=(n=n+Math.imul(T,$)|0)+Math.imul(O,J)|0,h=h+Math.imul(O,$)|0,e=e+Math.imul(S,Y)|0,n=(n=n+Math.imul(S,tt)|0)+Math.imul(A,Y)|0,h=h+Math.imul(A,tt)|0,e=e+Math.imul(N,rt)|0,n=(n=n+Math.imul(N,et)|0)+Math.imul(_,rt)|0,h=h+Math.imul(_,et)|0,e=e+Math.imul(y,ht)|0,n=(n=n+Math.imul(y,ot)|0)+Math.imul(b,ht)|0,h=h+Math.imul(b,ot)|0,e=e+Math.imul(M,ut)|0,n=(n=n+Math.imul(M,at)|0)+Math.imul(v,ut)|0,h=h+Math.imul(v,at)|0,e=e+Math.imul(p,mt)|0,n=(n=n+Math.imul(p,ft)|0)+Math.imul(g,mt)|0,h=h+Math.imul(g,ft)|0;var Rt=(a+(e=e+Math.imul(m,pt)|0)|0)+((8191&(n=(n=n+Math.imul(m,gt)|0)+Math.imul(f,pt)|0))<<13)|0;a=((h=h+Math.imul(f,gt)|0)+(n>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,e=Math.imul(B,j),n=(n=Math.imul(B,X))+Math.imul(F,j)|0,h=Math.imul(F,X),e=e+Math.imul(L,V)|0,n=(n=n+Math.imul(L,W)|0)+Math.imul(P,V)|0,h=h+Math.imul(P,W)|0,e=e+Math.imul(C,J)|0,n=(n=n+Math.imul(C,$)|0)+Math.imul(k,J)|0,h=h+Math.imul(k,$)|0,e=e+Math.imul(T,Y)|0,n=(n=n+Math.imul(T,tt)|0)+Math.imul(O,Y)|0,h=h+Math.imul(O,tt)|0,e=e+Math.imul(S,rt)|0,n=(n=n+Math.imul(S,et)|0)+Math.imul(A,rt)|0,h=h+Math.imul(A,et)|0,e=e+Math.imul(N,ht)|0,n=(n=n+Math.imul(N,ot)|0)+Math.imul(_,ht)|0,h=h+Math.imul(_,ot)|0,e=e+Math.imul(y,ut)|0,n=(n=n+Math.imul(y,at)|0)+Math.imul(b,ut)|0,h=h+Math.imul(b,at)|0,e=e+Math.imul(M,mt)|0,n=(n=n+Math.imul(M,ft)|0)+Math.imul(v,mt)|0,h=h+Math.imul(v,ft)|0;var St=(a+(e=e+Math.imul(p,pt)|0)|0)+((8191&(n=(n=n+Math.imul(p,gt)|0)+Math.imul(g,pt)|0))<<13)|0;a=((h=h+Math.imul(g,gt)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,e=Math.imul(B,V),n=(n=Math.imul(B,W))+Math.imul(F,V)|0,h=Math.imul(F,W),e=e+Math.imul(L,J)|0,n=(n=n+Math.imul(L,$)|0)+Math.imul(P,J)|0,h=h+Math.imul(P,$)|0,e=e+Math.imul(C,Y)|0,n=(n=n+Math.imul(C,tt)|0)+Math.imul(k,Y)|0,h=h+Math.imul(k,tt)|0,e=e+Math.imul(T,rt)|0,n=(n=n+Math.imul(T,et)|0)+Math.imul(O,rt)|0,h=h+Math.imul(O,et)|0,e=e+Math.imul(S,ht)|0,n=(n=n+Math.imul(S,ot)|0)+Math.imul(A,ht)|0,h=h+Math.imul(A,ot)|0,e=e+Math.imul(N,ut)|0,n=(n=n+Math.imul(N,at)|0)+Math.imul(_,ut)|0,h=h+Math.imul(_,at)|0,e=e+Math.imul(y,mt)|0,n=(n=n+Math.imul(y,ft)|0)+Math.imul(b,mt)|0,h=h+Math.imul(b,ft)|0;var At=(a+(e=e+Math.imul(M,pt)|0)|0)+((8191&(n=(n=n+Math.imul(M,gt)|0)+Math.imul(v,pt)|0))<<13)|0;a=((h=h+Math.imul(v,gt)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,e=Math.imul(B,J),n=(n=Math.imul(B,$))+Math.imul(F,J)|0,h=Math.imul(F,$),e=e+Math.imul(L,Y)|0,n=(n=n+Math.imul(L,tt)|0)+Math.imul(P,Y)|0,h=h+Math.imul(P,tt)|0,e=e+Math.imul(C,rt)|0,n=(n=n+Math.imul(C,et)|0)+Math.imul(k,rt)|0,h=h+Math.imul(k,et)|0,e=e+Math.imul(T,ht)|0,n=(n=n+Math.imul(T,ot)|0)+Math.imul(O,ht)|0,h=h+Math.imul(O,ot)|0,e=e+Math.imul(S,ut)|0,n=(n=n+Math.imul(S,at)|0)+Math.imul(A,ut)|0,h=h+Math.imul(A,at)|0,e=e+Math.imul(N,mt)|0,n=(n=n+Math.imul(N,ft)|0)+Math.imul(_,mt)|0,h=h+Math.imul(_,ft)|0;var It=(a+(e=e+Math.imul(y,pt)|0)|0)+((8191&(n=(n=n+Math.imul(y,gt)|0)+Math.imul(b,pt)|0))<<13)|0;a=((h=h+Math.imul(b,gt)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863,e=Math.imul(B,Y),n=(n=Math.imul(B,tt))+Math.imul(F,Y)|0,h=Math.imul(F,tt),e=e+Math.imul(L,rt)|0,n=(n=n+Math.imul(L,et)|0)+Math.imul(P,rt)|0,h=h+Math.imul(P,et)|0,e=e+Math.imul(C,ht)|0,n=(n=n+Math.imul(C,ot)|0)+Math.imul(k,ht)|0,h=h+Math.imul(k,ot)|0,e=e+Math.imul(T,ut)|0,n=(n=n+Math.imul(T,at)|0)+Math.imul(O,ut)|0,h=h+Math.imul(O,at)|0,e=e+Math.imul(S,mt)|0,n=(n=n+Math.imul(S,ft)|0)+Math.imul(A,mt)|0,h=h+Math.imul(A,ft)|0;var Tt=(a+(e=e+Math.imul(N,pt)|0)|0)+((8191&(n=(n=n+Math.imul(N,gt)|0)+Math.imul(_,pt)|0))<<13)|0;a=((h=h+Math.imul(_,gt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,e=Math.imul(B,rt),n=(n=Math.imul(B,et))+Math.imul(F,rt)|0,h=Math.imul(F,et),e=e+Math.imul(L,ht)|0,n=(n=n+Math.imul(L,ot)|0)+Math.imul(P,ht)|0,h=h+Math.imul(P,ot)|0,e=e+Math.imul(C,ut)|0,n=(n=n+Math.imul(C,at)|0)+Math.imul(k,ut)|0,h=h+Math.imul(k,at)|0,e=e+Math.imul(T,mt)|0,n=(n=n+Math.imul(T,ft)|0)+Math.imul(O,mt)|0,h=h+Math.imul(O,ft)|0;var Ot=(a+(e=e+Math.imul(S,pt)|0)|0)+((8191&(n=(n=n+Math.imul(S,gt)|0)+Math.imul(A,pt)|0))<<13)|0;a=((h=h+Math.imul(A,gt)|0)+(n>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,e=Math.imul(B,ht),n=(n=Math.imul(B,ot))+Math.imul(F,ht)|0,h=Math.imul(F,ot),e=e+Math.imul(L,ut)|0,n=(n=n+Math.imul(L,at)|0)+Math.imul(P,ut)|0,h=h+Math.imul(P,at)|0,e=e+Math.imul(C,mt)|0,n=(n=n+Math.imul(C,ft)|0)+Math.imul(k,mt)|0,h=h+Math.imul(k,ft)|0;var Ut=(a+(e=e+Math.imul(T,pt)|0)|0)+((8191&(n=(n=n+Math.imul(T,gt)|0)+Math.imul(O,pt)|0))<<13)|0;a=((h=h+Math.imul(O,gt)|0)+(n>>>13)|0)+(Ut>>>26)|0,Ut&=67108863,e=Math.imul(B,ut),n=(n=Math.imul(B,at))+Math.imul(F,ut)|0,h=Math.imul(F,at),e=e+Math.imul(L,mt)|0,n=(n=n+Math.imul(L,ft)|0)+Math.imul(P,mt)|0,h=h+Math.imul(P,ft)|0;var Ct=(a+(e=e+Math.imul(C,pt)|0)|0)+((8191&(n=(n=n+Math.imul(C,gt)|0)+Math.imul(k,pt)|0))<<13)|0;a=((h=h+Math.imul(k,gt)|0)+(n>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,e=Math.imul(B,mt),n=(n=Math.imul(B,ft))+Math.imul(F,mt)|0,h=Math.imul(F,ft);var kt=(a+(e=e+Math.imul(L,pt)|0)|0)+((8191&(n=(n=n+Math.imul(L,gt)|0)+Math.imul(P,pt)|0))<<13)|0;a=((h=h+Math.imul(P,gt)|0)+(n>>>13)|0)+(kt>>>26)|0,kt&=67108863;var xt=(a+(e=Math.imul(B,pt))|0)+((8191&(n=(n=Math.imul(B,gt))+Math.imul(F,pt)|0))<<13)|0;return a=((h=Math.imul(F,gt))+(n>>>13)|0)+(xt>>>26)|0,xt&=67108863,u[0]=ct,u[1]=Mt,u[2]=vt,u[3]=wt,u[4]=yt,u[5]=bt,u[6]=Et,u[7]=Nt,u[8]=_t,u[9]=Rt,u[10]=St,u[11]=At,u[12]=It,u[13]=Tt,u[14]=Ot,u[15]=Ut,u[16]=Ct,u[17]=kt,u[18]=xt,0!==a&&(u[19]=a,r.length++),r};function M(t,i,r){r.negative=i.negative^t.negative,r.length=t.length+i.length;for(var e=0,n=0,h=0;h<r.length-1;h++){var o=n;n=0;for(var s=67108863&e,u=Math.min(h,i.length-1),a=Math.max(0,h-t.length+1);a<=u;a++){var l=h-a,m=(0|t.words[l])*(0|i.words[a]),f=67108863&m;s=67108863&(f=f+s|0),n+=(o=(o=o+(m/67108864|0)|0)+(f>>>26)|0)>>>26,o&=67108863}r.words[h]=s,e=o,o=n}return 0!==e?r.words[h]=e:r.length--,r._strip()}function v(t,i,r){return M(t,i,r)}Math.imul||(c=g),h.prototype.mulTo=function(t,i){var r=this.length+t.length;return 10===this.length&&10===t.length?c(this,t,i):r<63?g(this,t,i):r<1024?M(this,t,i):v(this,t,i)},h.prototype.mul=function(t){var i=new h(null);return i.words=new Array(this.length+t.length),this.mulTo(t,i)},h.prototype.mulf=function(t){var i=new h(null);return i.words=new Array(this.length+t.length),v(this,t,i)},h.prototype.imul=function(t){return this.clone().mulTo(t,this)},h.prototype.imuln=function(t){var i=t<0;i&&(t=-t),e("number"==typeof t),e(t<67108864);for(var r=0,n=0;n<this.length;n++){var h=(0|this.words[n])*t,o=(67108863&h)+(67108863&r);r>>=26,r+=h/67108864|0,r+=o>>>26,this.words[n]=67108863&o}return 0!==r&&(this.words[n]=r,this.length++),i?this.ineg():this},h.prototype.muln=function(t){return this.clone().imuln(t)},h.prototype.sqr=function(){return this.mul(this)},h.prototype.isqr=function(){return this.imul(this.clone())},h.prototype.pow=function(t){var i=function(t){for(var i=new Array(t.bitLength()),r=0;r<i.length;r++){var e=r/26|0,n=r%26;i[r]=t.words[e]>>>n&1}return i}(t);if(0===i.length)return new h(1);for(var r=this,e=0;e<i.length&&0===i[e];e++,r=r.sqr());if(++e<i.length)for(var n=r.sqr();e<i.length;e++,n=n.sqr())0!==i[e]&&(r=r.mul(n));return r},h.prototype.iushln=function(t){e("number"==typeof t&&t>=0);var i,r=t%26,n=(t-r)/26,h=67108863>>>26-r<<26-r;if(0!==r){var o=0;for(i=0;i<this.length;i++){var s=this.words[i]&h,u=(0|this.words[i])-s<<r;this.words[i]=u|o,o=s>>>26-r}o&&(this.words[i]=o,this.length++)}if(0!==n){for(i=this.length-1;i>=0;i--)this.words[i+n]=this.words[i];for(i=0;i<n;i++)this.words[i]=0;this.length+=n}return this._strip()},h.prototype.ishln=function(t){return e(0===this.negative),this.iushln(t)},h.prototype.iushrn=function(t,i,r){var n;e("number"==typeof t&&t>=0),n=i?(i-i%26)/26:0;var h=t%26,o=Math.min((t-h)/26,this.length),s=67108863^67108863>>>h<<h,u=r;if(n-=o,n=Math.max(0,n),u){for(var a=0;a<o;a++)u.words[a]=this.words[a];u.length=o}if(0===o);else if(this.length>o)for(this.length-=o,a=0;a<this.length;a++)this.words[a]=this.words[a+o];else this.words[0]=0,this.length=1;var l=0;for(a=this.length-1;a>=0&&(0!==l||a>=n);a--){var m=0|this.words[a];this.words[a]=l<<26-h|m>>>h,l=m&s}return u&&0!==l&&(u.words[u.length++]=l),0===this.length&&(this.words[0]=0,this.length=1),this._strip()},h.prototype.ishrn=function(t,i,r){return e(0===this.negative),this.iushrn(t,i,r)},h.prototype.shln=function(t){return this.clone().ishln(t)},h.prototype.ushln=function(t){return this.clone().iushln(t)},h.prototype.shrn=function(t){return this.clone().ishrn(t)},h.prototype.ushrn=function(t){return this.clone().iushrn(t)},h.prototype.testn=function(t){e("number"==typeof t&&t>=0);var i=t%26,r=(t-i)/26,n=1<<i;return!(this.length<=r||!(this.words[r]&n))},h.prototype.imaskn=function(t){e("number"==typeof t&&t>=0);var i=t%26,r=(t-i)/26;if(e(0===this.negative,"imaskn works only with positive numbers"),this.length<=r)return this;if(0!==i&&r++,this.length=Math.min(r,this.length),0!==i){var n=67108863^67108863>>>i<<i;this.words[this.length-1]&=n}return this._strip()},h.prototype.maskn=function(t){return this.clone().imaskn(t)},h.prototype.iaddn=function(t){return e("number"==typeof t),e(t<67108864),t<0?this.isubn(-t):0!==this.negative?1===this.length&&(0|this.words[0])<=t?(this.words[0]=t-(0|this.words[0]),this.negative=0,this):(this.negative=0,this.isubn(t),this.negative=1,this):this._iaddn(t)},h.prototype._iaddn=function(t){this.words[0]+=t;for(var i=0;i<this.length&&this.words[i]>=67108864;i++)this.words[i]-=67108864,i===this.length-1?this.words[i+1]=1:this.words[i+1]++;return this.length=Math.max(this.length,i+1),this},h.prototype.isubn=function(t){if(e("number"==typeof t),e(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var i=0;i<this.length&&this.words[i]<0;i++)this.words[i]+=67108864,this.words[i+1]-=1;return this._strip()},h.prototype.addn=function(t){return this.clone().iaddn(t)},h.prototype.subn=function(t){return this.clone().isubn(t)},h.prototype.iabs=function(){return this.negative=0,this},h.prototype.abs=function(){return this.clone().iabs()},h.prototype._ishlnsubmul=function(t,i,r){var n,h,o=t.length+r;this._expand(o);var s=0;for(n=0;n<t.length;n++){h=(0|this.words[n+r])+s;var u=(0|t.words[n])*i;s=((h-=67108863&u)>>26)-(u/67108864|0),this.words[n+r]=67108863&h}for(;n<this.length-r;n++)s=(h=(0|this.words[n+r])+s)>>26,this.words[n+r]=67108863&h;if(0===s)return this._strip();for(e(-1===s),s=0,n=0;n<this.length;n++)s=(h=-(0|this.words[n])+s)>>26,this.words[n]=67108863&h;return this.negative=1,this._strip()},h.prototype._wordDiv=function(t,i){var r=(this.length,t.length),e=this.clone(),n=t,o=0|n.words[n.length-1];0!=(r=26-this._countBits(o))&&(n=n.ushln(r),e.iushln(r),o=0|n.words[n.length-1]);var s,u=e.length-n.length;if("mod"!==i){(s=new h(null)).length=u+1,s.words=new Array(s.length);for(var a=0;a<s.length;a++)s.words[a]=0}var l=e.clone()._ishlnsubmul(n,1,u);0===l.negative&&(e=l,s&&(s.words[u]=1));for(var m=u-1;m>=0;m--){var f=67108864*(0|e.words[n.length+m])+(0|e.words[n.length+m-1]);for(f=Math.min(f/o|0,67108863),e._ishlnsubmul(n,f,m);0!==e.negative;)f--,e.negative=0,e._ishlnsubmul(n,1,m),e.isZero()||(e.negative^=1);s&&(s.words[m]=f)}return s&&s._strip(),e._strip(),"div"!==i&&0!==r&&e.iushrn(r),{div:s||null,mod:e}},h.prototype.divmod=function(t,i,r){return e(!t.isZero()),this.isZero()?{div:new h(0),mod:new h(0)}:0!==this.negative&&0===t.negative?(s=this.neg().divmod(t,i),"mod"!==i&&(n=s.div.neg()),"div"!==i&&(o=s.mod.neg(),r&&0!==o.negative&&o.iadd(t)),{div:n,mod:o}):0===this.negative&&0!==t.negative?(s=this.divmod(t.neg(),i),"mod"!==i&&(n=s.div.neg()),{div:n,mod:s.mod}):0!=(this.negative&t.negative)?(s=this.neg().divmod(t.neg(),i),"div"!==i&&(o=s.mod.neg(),r&&0!==o.negative&&o.isub(t)),{div:s.div,mod:o}):t.length>this.length||this.cmp(t)<0?{div:new h(0),mod:this}:1===t.length?"div"===i?{div:this.divn(t.words[0]),mod:null}:"mod"===i?{div:null,mod:new h(this.modrn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new h(this.modrn(t.words[0]))}:this._wordDiv(t,i);var n,o,s},h.prototype.div=function(t){return this.divmod(t,"div",!1).div},h.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},h.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},h.prototype.divRound=function(t){var i=this.divmod(t);if(i.mod.isZero())return i.div;var r=0!==i.div.negative?i.mod.isub(t):i.mod,e=t.ushrn(1),n=t.andln(1),h=r.cmp(e);return h<0||1===n&&0===h?i.div:0!==i.div.negative?i.div.isubn(1):i.div.iaddn(1)},h.prototype.modrn=function(t){var i=t<0;i&&(t=-t),e(t<=67108863);for(var r=(1<<26)%t,n=0,h=this.length-1;h>=0;h--)n=(r*n+(0|this.words[h]))%t;return i?-n:n},h.prototype.modn=function(t){return this.modrn(t)},h.prototype.idivn=function(t){var i=t<0;i&&(t=-t),e(t<=67108863);for(var r=0,n=this.length-1;n>=0;n--){var h=(0|this.words[n])+67108864*r;this.words[n]=h/t|0,r=h%t}return this._strip(),i?this.ineg():this},h.prototype.divn=function(t){return this.clone().idivn(t)},h.prototype.egcd=function(t){e(0===t.negative),e(!t.isZero());var i=this,r=t.clone();i=0!==i.negative?i.umod(t):i.clone();for(var n=new h(1),o=new h(0),s=new h(0),u=new h(1),a=0;i.isEven()&&r.isEven();)i.iushrn(1),r.iushrn(1),++a;for(var l=r.clone(),m=i.clone();!i.isZero();){for(var f=0,d=1;0==(i.words[0]&d)&&f<26;++f,d<<=1);if(f>0)for(i.iushrn(f);f-- >0;)(n.isOdd()||o.isOdd())&&(n.iadd(l),o.isub(m)),n.iushrn(1),o.iushrn(1);for(var p=0,g=1;0==(r.words[0]&g)&&p<26;++p,g<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(s.isOdd()||u.isOdd())&&(s.iadd(l),u.isub(m)),s.iushrn(1),u.iushrn(1);i.cmp(r)>=0?(i.isub(r),n.isub(s),o.isub(u)):(r.isub(i),s.isub(n),u.isub(o))}return{a:s,b:u,gcd:r.iushln(a)}},h.prototype._invmp=function(t){e(0===t.negative),e(!t.isZero());var i=this,r=t.clone();i=0!==i.negative?i.umod(t):i.clone();for(var n,o=new h(1),s=new h(0),u=r.clone();i.cmpn(1)>0&&r.cmpn(1)>0;){for(var a=0,l=1;0==(i.words[0]&l)&&a<26;++a,l<<=1);if(a>0)for(i.iushrn(a);a-- >0;)o.isOdd()&&o.iadd(u),o.iushrn(1);for(var m=0,f=1;0==(r.words[0]&f)&&m<26;++m,f<<=1);if(m>0)for(r.iushrn(m);m-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);i.cmp(r)>=0?(i.isub(r),o.isub(s)):(r.isub(i),s.isub(o))}return(n=0===i.cmpn(1)?o:s).cmpn(0)<0&&n.iadd(t),n},h.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var i=this.clone(),r=t.clone();i.negative=0,r.negative=0;for(var e=0;i.isEven()&&r.isEven();e++)i.iushrn(1),r.iushrn(1);for(;;){for(;i.isEven();)i.iushrn(1);for(;r.isEven();)r.iushrn(1);var n=i.cmp(r);if(n<0){var h=i;i=r,r=h}else if(0===n||0===r.cmpn(1))break;i.isub(r)}return r.iushln(e)},h.prototype.invm=function(t){return this.egcd(t).a.umod(t)},h.prototype.isEven=function(){return 0==(1&this.words[0])},h.prototype.isOdd=function(){return 1==(1&this.words[0])},h.prototype.andln=function(t){return this.words[0]&t},h.prototype.bincn=function(t){e("number"==typeof t);var i=t%26,r=(t-i)/26,n=1<<i;if(this.length<=r)return this._expand(r+1),this.words[r]|=n,this;for(var h=n,o=r;0!==h&&o<this.length;o++){var s=0|this.words[o];h=(s+=h)>>>26,s&=67108863,this.words[o]=s}return 0!==h&&(this.words[o]=h,this.length++),this},h.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},h.prototype.cmpn=function(t){var i,r=t<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this._strip(),this.length>1)i=1;else{r&&(t=-t),e(t<=67108863,"Number is too big");var n=0|this.words[0];i=n===t?0:n<t?-1:1}return 0!==this.negative?0|-i:i},h.prototype.cmp=function(t){if(0!==this.negative&&0===t.negative)return-1;if(0===this.negative&&0!==t.negative)return 1;var i=this.ucmp(t);return 0!==this.negative?0|-i:i},h.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length<t.length)return-1;for(var i=0,r=this.length-1;r>=0;r--){var e=0|this.words[r],n=0|t.words[r];if(e!==n){e<n?i=-1:e>n&&(i=1);break}}return i},h.prototype.gtn=function(t){return 1===this.cmpn(t)},h.prototype.gt=function(t){return 1===this.cmp(t)},h.prototype.gten=function(t){return this.cmpn(t)>=0},h.prototype.gte=function(t){return this.cmp(t)>=0},h.prototype.ltn=function(t){return-1===this.cmpn(t)},h.prototype.lt=function(t){return-1===this.cmp(t)},h.prototype.lten=function(t){return this.cmpn(t)<=0},h.prototype.lte=function(t){return this.cmp(t)<=0},h.prototype.eqn=function(t){return 0===this.cmpn(t)},h.prototype.eq=function(t){return 0===this.cmp(t)},h.red=function(t){return new R(t)},h.prototype.toRed=function(t){return e(!this.red,"Already a number in reduction context"),e(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},h.prototype.fromRed=function(){return e(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},h.prototype._forceRed=function(t){return this.red=t,this},h.prototype.forceRed=function(t){return e(!this.red,"Already a number in reduction context"),this._forceRed(t)},h.prototype.redAdd=function(t){return e(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},h.prototype.redIAdd=function(t){return e(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},h.prototype.redSub=function(t){return e(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},h.prototype.redISub=function(t){return e(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},h.prototype.redShl=function(t){return e(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},h.prototype.redMul=function(t){return e(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},h.prototype.redIMul=function(t){return e(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},h.prototype.redSqr=function(){return e(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},h.prototype.redISqr=function(){return e(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},h.prototype.redSqrt=function(){return e(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},h.prototype.redInvm=function(){return e(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},h.prototype.redNeg=function(){return e(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},h.prototype.redPow=function(t){return e(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var w={k256:null,p224:null,p192:null,p25519:null};function y(t,i){this.name=t,this.p=new h(i,16),this.n=this.p.bitLength(),this.k=new h(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function b(){y.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function E(){y.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function N(){y.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function _(){y.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function R(t){if("string"==typeof t){var i=h._prime(t);this.m=i.p,this.prime=i}else e(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function S(t){R.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new h(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}y.prototype._tmp=function(){var t=new h(null);return t.words=new Array(Math.ceil(this.n/13)),t},y.prototype.ireduce=function(t){var i,r=t;do{this.split(r,this.tmp),i=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(i>this.n);var e=i<this.n?-1:r.ucmp(this.p);return 0===e?(r.words[0]=0,r.length=1):e>0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},y.prototype.split=function(t,i){t.iushrn(this.n,0,i)},y.prototype.imulK=function(t){return t.imul(this.k)},n(b,y),b.prototype.split=function(t,i){for(var r=4194303,e=Math.min(t.length,9),n=0;n<e;n++)i.words[n]=t.words[n];if(i.length=e,t.length<=9)return t.words[0]=0,void(t.length=1);var h=t.words[9];for(i.words[i.length++]=h&r,n=10;n<t.length;n++){var o=0|t.words[n];t.words[n-10]=(o&r)<<4|h>>>22,h=o}h>>>=22,t.words[n-10]=h,0===h&&t.length>10?t.length-=10:t.length-=9},b.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var i=0,r=0;r<t.length;r++){var e=0|t.words[r];i+=977*e,t.words[r]=67108863&i,i=64*e+(i/67108864|0)}return 0===t.words[t.length-1]&&(t.length--,0===t.words[t.length-1]&&t.length--),t},n(E,y),n(N,y),n(_,y),_.prototype.imulK=function(t){for(var i=0,r=0;r<t.length;r++){var e=19*(0|t.words[r])+i,n=67108863&e;e>>>=26,t.words[r]=n,i=e}return 0!==i&&(t.words[t.length++]=i),t},h._prime=function(t){if(w[t])return w[t];var i;if("k256"===t)i=new b;else if("p224"===t)i=new E;else if("p192"===t)i=new N;else{if("p25519"!==t)throw new Error("Unknown prime "+t);i=new _}return w[t]=i,i},R.prototype._verify1=function(t){e(0===t.negative,"red works only with positives"),e(t.red,"red works only with red numbers")},R.prototype._verify2=function(t,i){e(0==(t.negative|i.negative),"red works only with positives"),e(t.red&&t.red===i.red,"red works only with red numbers")},R.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):(l(t,t.umod(this.m)._forceRed(this)),t)},R.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},R.prototype.add=function(t,i){this._verify2(t,i);var r=t.add(i);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},R.prototype.iadd=function(t,i){this._verify2(t,i);var r=t.iadd(i);return r.cmp(this.m)>=0&&r.isub(this.m),r},R.prototype.sub=function(t,i){this._verify2(t,i);var r=t.sub(i);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},R.prototype.isub=function(t,i){this._verify2(t,i);var r=t.isub(i);return r.cmpn(0)<0&&r.iadd(this.m),r},R.prototype.shl=function(t,i){return this._verify1(t),this.imod(t.ushln(i))},R.prototype.imul=function(t,i){return this._verify2(t,i),this.imod(t.imul(i))},R.prototype.mul=function(t,i){return this._verify2(t,i),this.imod(t.mul(i))},R.prototype.isqr=function(t){return this.imul(t,t.clone())},R.prototype.sqr=function(t){return this.mul(t,t)},R.prototype.sqrt=function(t){if(t.isZero())return t.clone();var i=this.m.andln(3);if(e(i%2==1),3===i){var r=this.m.add(new h(1)).iushrn(2);return this.pow(t,r)}for(var n=this.m.subn(1),o=0;!n.isZero()&&0===n.andln(1);)o++,n.iushrn(1);e(!n.isZero());var s=new h(1).toRed(this),u=s.redNeg(),a=this.m.subn(1).iushrn(1),l=this.m.bitLength();for(l=new h(2*l*l).toRed(this);0!==this.pow(l,a).cmp(u);)l.redIAdd(u);for(var m=this.pow(l,n),f=this.pow(t,n.addn(1).iushrn(1)),d=this.pow(t,n),p=o;0!==d.cmp(s);){for(var g=d,c=0;0!==g.cmp(s);c++)g=g.redSqr();e(c<p);var M=this.pow(m,new h(1).iushln(p-c-1));f=f.redMul(M),m=M.redSqr(),d=d.redMul(m),p=c}return f},R.prototype.invm=function(t){var i=t._invmp(this.m);return 0!==i.negative?(i.negative=0,this.imod(i).redNeg()):this.imod(i)},R.prototype.pow=function(t,i){if(i.isZero())return new h(1).toRed(this);if(0===i.cmpn(1))return t.clone();var r=new Array(16);r[0]=new h(1).toRed(this),r[1]=t;for(var e=2;e<r.length;e++)r[e]=this.mul(r[e-1],t);var n=r[0],o=0,s=0,u=i.bitLength()%26;for(0===u&&(u=26),e=i.length-1;e>=0;e--){for(var a=i.words[e],l=u-1;l>=0;l--){var m=a>>l&1;n!==r[0]&&(n=this.sqr(n)),0!==m||0!==o?(o<<=1,o|=m,(4==++s||0===e&&0===l)&&(n=this.mul(n,r[o]),s=0,o=0)):s=0}u=26}return n},R.prototype.convertTo=function(t){var i=t.umod(this.m);return i===t?i.clone():i},R.prototype.convertFrom=function(t){var i=t.clone();return i.red=null,i},h.mont=function(t){return new S(t)},n(S,R),S.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},S.prototype.convertFrom=function(t){var i=this.imod(t.mul(this.rinv));return i.red=null,i},S.prototype.imul=function(t,i){if(t.isZero()||i.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(i),e=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(e).iushrn(this.shift),h=n;return n.cmp(this.m)>=0?h=n.isub(this.m):n.cmpn(0)<0&&(h=n.iadd(this.m)),h._forceRed(this)},S.prototype.mul=function(t,i){if(t.isZero()||i.isZero())return new h(0)._forceRed(this);var r=t.mul(i),e=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(e).iushrn(this.shift),o=n;return n.cmp(this.m)>=0?o=n.isub(this.m):n.cmpn(0)<0&&(o=n.iadd(this.m)),o._forceRed(this)},S.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(v,t);const w="bignumber/5.7.0";var y=v.exports.BN;const b=new c(w),E={},N=9007199254740991;function _(t){return null!=t&&(S.isBigNumber(t)||"number"==typeof t&&t%1==0||"string"==typeof t&&!!t.match(/^-?[0-9]+$/)||h(t)||"bigint"==typeof t||e(t))}let R=!1;class S{constructor(t,i){t!==E&&b.throwError("cannot call constructor directly; use BigNumber.from",c.errors.UNSUPPORTED_OPERATION,{operation:"new (BigNumber)"}),this._hex=i,this._isBigNumber=!0,Object.freeze(this)}fromTwos(t){return I(T(this).fromTwos(t))}toTwos(t){return I(T(this).toTwos(t))}abs(){return"-"===this._hex[0]?S.from(this._hex.substring(1)):this}add(t){return I(T(this).add(T(t)))}sub(t){return I(T(this).sub(T(t)))}div(t){return S.from(t).isZero()&&O("division-by-zero","div"),I(T(this).div(T(t)))}mul(t){return I(T(this).mul(T(t)))}mod(t){const i=T(t);return i.isNeg()&&O("division-by-zero","mod"),I(T(this).umod(i))}pow(t){const i=T(t);return i.isNeg()&&O("negative-power","pow"),I(T(this).pow(i))}and(t){const i=T(t);return(this.isNegative()||i.isNeg())&&O("unbound-bitwise-result","and"),I(T(this).and(i))}or(t){const i=T(t);return(this.isNegative()||i.isNeg())&&O("unbound-bitwise-result","or"),I(T(this).or(i))}xor(t){const i=T(t);return(this.isNegative()||i.isNeg())&&O("unbound-bitwise-result","xor"),I(T(this).xor(i))}mask(t){return(this.isNegative()||t<0)&&O("negative-width","mask"),I(T(this).maskn(t))}shl(t){return(this.isNegative()||t<0)&&O("negative-width","shl"),I(T(this).shln(t))}shr(t){return(this.isNegative()||t<0)&&O("negative-width","shr"),I(T(this).shrn(t))}eq(t){return T(this).eq(T(t))}lt(t){return T(this).lt(T(t))}lte(t){return T(this).lte(T(t))}gt(t){return T(this).gt(T(t))}gte(t){return T(this).gte(T(t))}isNegative(){return"-"===this._hex[0]}isZero(){return T(this).isZero()}toNumber(){try{return T(this).toNumber()}catch(t){O("overflow","toNumber",this.toString())}return null}toBigInt(){try{return BigInt(this.toString())}catch(t){}return b.throwError("this platform does not support BigInt",c.errors.UNSUPPORTED_OPERATION,{value:this.toString()})}toString(){return arguments.length>0&&(10===arguments[0]?R||(R=!0,b.warn("BigNumber.toString does not accept any parameters; base-10 is assumed")):16===arguments[0]?b.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()",c.errors.UNEXPECTED_ARGUMENT,{}):b.throwError("BigNumber.toString does not accept parameters",c.errors.UNEXPECTED_ARGUMENT,{})),T(this).toString(10)}toHexString(){return this._hex}toJSON(t){return{type:"BigNumber",hex:this.toHexString()}}static from(t){if(t instanceof S)return t;if("string"==typeof t)return t.match(/^-?0x[0-9a-f]+$/i)?new S(E,A(t)):t.match(/^-?[0-9]+$/)?new S(E,A(new y(t))):b.throwArgumentError("invalid BigNumber string","value",t);if("number"==typeof t)return t%1&&O("underflow","BigNumber.from",t),(t>=N||t<=-N)&&O("overflow","BigNumber.from",t),S.from(String(t));const i=t;if("bigint"==typeof i)return S.from(i.toString());if(e(i))return S.from(n(i));if(i)if(i.toHexString){const t=i.toHexString();if("string"==typeof t)return S.from(t)}else{let t=i._hex;if(null==t&&"BigNumber"===i.type&&(t=i.hex),"string"==typeof t&&(h(t)||"-"===t[0]&&h(t.substring(1))))return S.from(t)}return b.throwArgumentError("invalid BigNumber value","value",t)}static isBigNumber(t){return!(!t||!t._isBigNumber)}}function A(t){if("string"!=typeof t)return A(t.toString(16));if("-"===t[0])return"-"===(t=t.substring(1))[0]&&b.throwArgumentError("invalid hex","value",t),"0x00"===(t=A(t))?t:"-"+t;if("0x"!==t.substring(0,2)&&(t="0x"+t),"0x"===t)return"0x00";for(t.length%2&&(t="0x0"+t.substring(2));t.length>4&&"0x00"===t.substring(0,4);)t="0x"+t.substring(4);return t}function I(t){return S.from(A(t))}function T(t){const i=S.from(t).toHexString();return"-"===i[0]?new y("-"+i.substring(3),16):new y(i.substring(2),16)}function O(t,i,r){const e={fault:t,operation:i};return null!=r&&(e.value=r),b.throwError(t,c.errors.NUMERIC_FAULT,e)}const U=new c("strings/5.7.0");var C,k;function x(t,i,r,e,n){if(t===k.BAD_PREFIX||t===k.UNEXPECTED_CONTINUE){let t=0;for(let e=i+1;e<r.length&&r[e]>>6==2;e++)t++;return t}return t===k.OVERRUN?r.length-i-1:0}!function(t){t.current="",t.NFC="NFC",t.NFD="NFD",t.NFKC="NFKC",t.NFKD="NFKD"}(C||(C={})),function(t){t.UNEXPECTED_CONTINUE="unexpected continuation byte",t.BAD_PREFIX="bad codepoint prefix",t.OVERRUN="string overrun",t.MISSING_CONTINUE="missing continuation byte",t.OUT_OF_RANGE="out of UTF-8 range",t.UTF16_SURROGATE="UTF-16 surrogate",t.OVERLONG="overlong representation"}(k||(k={}));const L=Object.freeze({error:function(t,i,r,e,n){return U.throwArgumentError(`invalid codepoint at offset ${i}; ${t}`,"bytes",r)},ignore:x,replace:function(t,i,r,e,n){return t===k.OVERLONG?(e.push(n),0):(e.push(65533),x(t,i,r))}});function P(t,i){null==i&&(i=L.error),t=o(t);const r=[];let e=0;for(;e<t.length;){const n=t[e++];if(n>>7==0){r.push(n);continue}let h=null,o=null;if(192==(224&n))h=1,o=127;else if(224==(240&n))h=2,o=2047;else{if(240!=(248&n)){e+=i(128==(192&n)?k.UNEXPECTED_CONTINUE:k.BAD_PREFIX,e-1,t,r);continue}h=3,o=65535}if(e-1+h>=t.length){e+=i(k.OVERRUN,e-1,t,r);continue}let s=n&(1<<8-h-1)-1;for(let n=0;n<h;n++){let n=t[e];if(128!=(192&n)){e+=i(k.MISSING_CONTINUE,e,t,r),s=null;break}s=s<<6|63&n,e++}null!==s&&(s>1114111?e+=i(k.OUT_OF_RANGE,e-1-h,t,r,s):s>=55296&&s<=57343?e+=i(k.UTF16_SURROGATE,e-1-h,t,r,s):s<=o?e+=i(k.OVERLONG,e-1-h,t,r,s):r.push(s))}return r}function D(t,i=C.current){i!=C.current&&(U.checkNormalize(),t=t.normalize(i));let r=[];for(let i=0;i<t.length;i++){const e=t.charCodeAt(i);if(e<128)r.push(e);else if(e<2048)r.push(e>>6|192),r.push(63&e|128);else if(55296==(64512&e)){i++;const n=t.charCodeAt(i);if(i>=t.length||56320!=(64512&n))throw new Error("invalid utf-8 string");const h=65536+((1023&e)<<10)+(1023&n);r.push(h>>18|240),r.push(h>>12&63|128),r.push(h>>6&63|128),r.push(63&h|128)}else r.push(e>>12|224),r.push(e>>6&63|128),r.push(63&e|128)}return o(r)}function B(t){const i="0000"+t.toString(16);return"\\u"+i.substring(i.length-4)}function F(t,i){return'"'+P(t,i).map((t=>{if(t<256){switch(t){case 8:return"\\b";case 9:return"\\t";case 10:return"\\n";case 13:return"\\r";case 34:return'\\"';case 92:return"\\\\"}if(t>=32&&t<127)return String.fromCharCode(t)}return t<=65535?B(t):B(55296+((t-=65536)>>10&1023))+B(56320+(1023&t))})).join("")+'"'}function G(t){return t.map((t=>t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode(55296+(t>>10&1023),56320+(1023&t))))).join("")}function Z(t,i){return G(P(t,i))}function q(t,i=C.current){return P(D(t,i))}function z(t){return i(D(t))}export{S as B,p as E,c as L,C as U,G as _,Z as a,_ as b,q as c,F as d,L as e,k as f,z as i,M as l,D as t,w as v};
1
+ import{c as t,k as i}from"./index-6e0697ab.js";import{r}from"./__node-resolve_empty-7cc52421.js";import{isBytes as e,hexlify as n,isHexString as h,arrayify as o}from"@ethersproject/bytes";let s=!1,u=!1;const a={debug:1,default:2,info:2,warning:3,error:4,off:5};let l=a.default,m=null;const f=function(){try{const t=[];if(["NFD","NFC","NFKD","NFKC"].forEach((i=>{try{if("test"!=="test".normalize(i))throw new Error("bad normalize")}catch(r){t.push(i)}})),t.length)throw new Error("missing "+t.join(", "));if(String.fromCharCode(233).normalize("NFD")!==String.fromCharCode(101,769))throw new Error("broken implementation")}catch(t){return t.message}return null}();var d,p;!function(t){t.DEBUG="DEBUG",t.INFO="INFO",t.WARNING="WARNING",t.ERROR="ERROR",t.OFF="OFF"}(d||(d={})),function(t){t.UNKNOWN_ERROR="UNKNOWN_ERROR",t.NOT_IMPLEMENTED="NOT_IMPLEMENTED",t.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",t.NETWORK_ERROR="NETWORK_ERROR",t.SERVER_ERROR="SERVER_ERROR",t.TIMEOUT="TIMEOUT",t.BUFFER_OVERRUN="BUFFER_OVERRUN",t.NUMERIC_FAULT="NUMERIC_FAULT",t.MISSING_NEW="MISSING_NEW",t.INVALID_ARGUMENT="INVALID_ARGUMENT",t.MISSING_ARGUMENT="MISSING_ARGUMENT",t.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",t.CALL_EXCEPTION="CALL_EXCEPTION",t.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",t.NONCE_EXPIRED="NONCE_EXPIRED",t.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",t.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",t.TRANSACTION_REPLACED="TRANSACTION_REPLACED",t.ACTION_REJECTED="ACTION_REJECTED"}(p||(p={}));const g="0123456789abcdef";class c{constructor(t){Object.defineProperty(this,"version",{enumerable:!0,value:t,writable:!1})}_log(t,i){const r=t.toLowerCase();null==a[r]&&this.throwArgumentError("invalid log level name","logLevel",t),l>a[r]||console.log.apply(console,i)}debug(...t){this._log(c.levels.DEBUG,t)}info(...t){this._log(c.levels.INFO,t)}warn(...t){this._log(c.levels.WARNING,t)}makeError(t,i,r){if(u)return this.makeError("censored error",i,{});i||(i=c.errors.UNKNOWN_ERROR),r||(r={});const e=[];Object.keys(r).forEach((t=>{const i=r[t];try{if(i instanceof Uint8Array){let r="";for(let t=0;t<i.length;t++)r+=g[i[t]>>4],r+=g[15&i[t]];e.push(t+"=Uint8Array(0x"+r+")")}else e.push(t+"="+JSON.stringify(i))}catch(i){e.push(t+"="+JSON.stringify(r[t].toString()))}})),e.push(`code=${i}`),e.push(`version=${this.version}`);const n=t;let h="";switch(i){case p.NUMERIC_FAULT:{h="NUMERIC_FAULT";const i=t;switch(i){case"overflow":case"underflow":case"division-by-zero":h+="-"+i;break;case"negative-power":case"negative-width":h+="-unsupported";break;case"unbound-bitwise-result":h+="-unbound-result"}break}case p.CALL_EXCEPTION:case p.INSUFFICIENT_FUNDS:case p.MISSING_NEW:case p.NONCE_EXPIRED:case p.REPLACEMENT_UNDERPRICED:case p.TRANSACTION_REPLACED:case p.UNPREDICTABLE_GAS_LIMIT:h=i}h&&(t+=" [ See: https://links.ethers.org/v5-errors-"+h+" ]"),e.length&&(t+=" ("+e.join(", ")+")");const o=new Error(t);return o.reason=n,o.code=i,Object.keys(r).forEach((function(t){o[t]=r[t]})),o}throwError(t,i,r){throw this.makeError(t,i,r)}throwArgumentError(t,i,r){return this.throwError(t,c.errors.INVALID_ARGUMENT,{argument:i,value:r})}assert(t,i,r,e){t||this.throwError(i,r,e)}assertArgument(t,i,r,e){t||this.throwArgumentError(i,r,e)}checkNormalize(t){f&&this.throwError("platform missing String.prototype.normalize",c.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:f})}checkSafeUint53(t,i){"number"==typeof t&&(null==i&&(i="value not safe"),(t<0||t>=9007199254740991)&&this.throwError(i,c.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:t}),t%1&&this.throwError(i,c.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:t}))}checkArgumentCount(t,i,r){r=r?": "+r:"",t<i&&this.throwError("missing argument"+r,c.errors.MISSING_ARGUMENT,{count:t,expectedCount:i}),t>i&&this.throwError("too many arguments"+r,c.errors.UNEXPECTED_ARGUMENT,{count:t,expectedCount:i})}checkNew(t,i){t!==Object&&null!=t||this.throwError("missing new",c.errors.MISSING_NEW,{name:i.name})}checkAbstract(t,i){t===i?this.throwError("cannot instantiate abstract class "+JSON.stringify(i.name)+" directly; use a sub-class",c.errors.UNSUPPORTED_OPERATION,{name:t.name,operation:"new"}):t!==Object&&null!=t||this.throwError("missing new",c.errors.MISSING_NEW,{name:i.name})}static globalLogger(){return m||(m=new c("logger/5.7.0")),m}static setCensorship(t,i){if(!t&&i&&this.globalLogger().throwError("cannot permanently disable censorship",c.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),s){if(!t)return;this.globalLogger().throwError("error censorship permanent",c.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}u=!!t,s=!!i}static setLogLevel(t){const i=a[t.toLowerCase()];null!=i?l=i:c.globalLogger().warn("invalid log level - "+t)}static from(t){return new c(t)}}c.errors=p,c.levels=d;var M=Object.freeze({__proto__:null,get LogLevel(){return d},get ErrorCode(){return p},Logger:c}),v={exports:{}};!function(t,i){function e(t,i){if(!t)throw new Error(i||"Assertion failed")}function n(t,i){t.super_=i;var r=function(){};r.prototype=i.prototype,t.prototype=new r,t.prototype.constructor=t}function h(t,i,r){if(h.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==i&&"be"!==i||(r=i,i=10),this._init(t||0,i||10,r||"be"))}var o;"object"==typeof t?t.exports=h:i.BN=h,h.BN=h,h.wordSize=26;try{o="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:r.Buffer}catch(t){}function s(t,i){var r=t.charCodeAt(i);return r>=48&&r<=57?r-48:r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:void e(!1,"Invalid character in "+t)}function u(t,i,r){var e=s(t,r);return r-1>=i&&(e|=s(t,r-1)<<4),e}function a(t,i,r,n){for(var h=0,o=0,s=Math.min(t.length,r),u=i;u<s;u++){var a=t.charCodeAt(u)-48;h*=n,o=a>=49?a-49+10:a>=17?a-17+10:a,e(a>=0&&o<n,"Invalid character"),h+=o}return h}function l(t,i){t.words=i.words,t.length=i.length,t.negative=i.negative,t.red=i.red}if(h.isBN=function(t){return t instanceof h||null!==t&&"object"==typeof t&&t.constructor.wordSize===h.wordSize&&Array.isArray(t.words)},h.max=function(t,i){return t.cmp(i)>0?t:i},h.min=function(t,i){return t.cmp(i)<0?t:i},h.prototype._init=function(t,i,r){if("number"==typeof t)return this._initNumber(t,i,r);if("object"==typeof t)return this._initArray(t,i,r);"hex"===i&&(i=16),e(i===(0|i)&&i>=2&&i<=36);var n=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&(n++,this.negative=1),n<t.length&&(16===i?this._parseHex(t,n,r):(this._parseBase(t,i,n),"le"===r&&this._initArray(this.toArray(),i,r)))},h.prototype._initNumber=function(t,i,r){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(e(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===r&&this._initArray(this.toArray(),i,r)},h.prototype._initArray=function(t,i,r){if(e("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var n=0;n<this.length;n++)this.words[n]=0;var h,o,s=0;if("be"===r)for(n=t.length-1,h=0;n>=0;n-=3)o=t[n]|t[n-1]<<8|t[n-2]<<16,this.words[h]|=o<<s&67108863,this.words[h+1]=o>>>26-s&67108863,(s+=24)>=26&&(s-=26,h++);else if("le"===r)for(n=0,h=0;n<t.length;n+=3)o=t[n]|t[n+1]<<8|t[n+2]<<16,this.words[h]|=o<<s&67108863,this.words[h+1]=o>>>26-s&67108863,(s+=24)>=26&&(s-=26,h++);return this._strip()},h.prototype._parseHex=function(t,i,r){this.length=Math.ceil((t.length-i)/6),this.words=new Array(this.length);for(var e=0;e<this.length;e++)this.words[e]=0;var n,h=0,o=0;if("be"===r)for(e=t.length-1;e>=i;e-=2)n=u(t,i,e)<<h,this.words[o]|=67108863&n,h>=18?(h-=18,o+=1,this.words[o]|=n>>>26):h+=8;else for(e=(t.length-i)%2==0?i+1:i;e<t.length;e+=2)n=u(t,i,e)<<h,this.words[o]|=67108863&n,h>=18?(h-=18,o+=1,this.words[o]|=n>>>26):h+=8;this._strip()},h.prototype._parseBase=function(t,i,r){this.words=[0],this.length=1;for(var e=0,n=1;n<=67108863;n*=i)e++;e--,n=n/i|0;for(var h=t.length-r,o=h%e,s=Math.min(h,h-o)+r,u=0,l=r;l<s;l+=e)u=a(t,l,l+e,i),this.imuln(n),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u);if(0!==o){var m=1;for(u=a(t,l,t.length,i),l=0;l<o;l++)m*=i;this.imuln(m),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u)}this._strip()},h.prototype.copy=function(t){t.words=new Array(this.length);for(var i=0;i<this.length;i++)t.words[i]=this.words[i];t.length=this.length,t.negative=this.negative,t.red=this.red},h.prototype._move=function(t){l(t,this)},h.prototype.clone=function(){var t=new h(null);return this.copy(t),t},h.prototype._expand=function(t){for(;this.length<t;)this.words[this.length++]=0;return this},h.prototype._strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},h.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},"undefined"!=typeof Symbol&&"function"==typeof Symbol.for)try{h.prototype[Symbol.for("nodejs.util.inspect.custom")]=m}catch(t){h.prototype.inspect=m}else h.prototype.inspect=m;function m(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var f=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],d=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],p=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function g(t,i,r){r.negative=i.negative^t.negative;var e=t.length+i.length|0;r.length=e,e=e-1|0;var n=0|t.words[0],h=0|i.words[0],o=n*h,s=67108863&o,u=o/67108864|0;r.words[0]=s;for(var a=1;a<e;a++){for(var l=u>>>26,m=67108863&u,f=Math.min(a,i.length-1),d=Math.max(0,a-t.length+1);d<=f;d++){var p=a-d|0;l+=(o=(n=0|t.words[p])*(h=0|i.words[d])+m)/67108864|0,m=67108863&o}r.words[a]=0|m,u=0|l}return 0!==u?r.words[a]=0|u:r.length--,r._strip()}h.prototype.toString=function(t,i){var r;if(i=0|i||1,16===(t=t||10)||"hex"===t){r="";for(var n=0,h=0,o=0;o<this.length;o++){var s=this.words[o],u=(16777215&(s<<n|h)).toString(16);h=s>>>24-n&16777215,(n+=2)>=26&&(n-=26,o--),r=0!==h||o!==this.length-1?f[6-u.length]+u+r:u+r}for(0!==h&&(r=h.toString(16)+r);r.length%i!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}if(t===(0|t)&&t>=2&&t<=36){var a=d[t],l=p[t];r="";var m=this.clone();for(m.negative=0;!m.isZero();){var g=m.modrn(l).toString(t);r=(m=m.idivn(l)).isZero()?g+r:f[a-g.length]+g+r}for(this.isZero()&&(r="0"+r);r.length%i!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}e(!1,"Base should be between 2 and 36")},h.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&e(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},h.prototype.toJSON=function(){return this.toString(16,2)},o&&(h.prototype.toBuffer=function(t,i){return this.toArrayLike(o,t,i)}),h.prototype.toArray=function(t,i){return this.toArrayLike(Array,t,i)},h.prototype.toArrayLike=function(t,i,r){this._strip();var n=this.byteLength(),h=r||Math.max(1,n);e(n<=h,"byte array longer than desired length"),e(h>0,"Requested array length <= 0");var o=function(t,i){return t.allocUnsafe?t.allocUnsafe(i):new t(i)}(t,h);return this["_toArrayLike"+("le"===i?"LE":"BE")](o,n),o},h.prototype._toArrayLikeLE=function(t,i){for(var r=0,e=0,n=0,h=0;n<this.length;n++){var o=this.words[n]<<h|e;t[r++]=255&o,r<t.length&&(t[r++]=o>>8&255),r<t.length&&(t[r++]=o>>16&255),6===h?(r<t.length&&(t[r++]=o>>24&255),e=0,h=0):(e=o>>>24,h+=2)}if(r<t.length)for(t[r++]=e;r<t.length;)t[r++]=0},h.prototype._toArrayLikeBE=function(t,i){for(var r=t.length-1,e=0,n=0,h=0;n<this.length;n++){var o=this.words[n]<<h|e;t[r--]=255&o,r>=0&&(t[r--]=o>>8&255),r>=0&&(t[r--]=o>>16&255),6===h?(r>=0&&(t[r--]=o>>24&255),e=0,h=0):(e=o>>>24,h+=2)}if(r>=0)for(t[r--]=e;r>=0;)t[r--]=0},Math.clz32?h.prototype._countBits=function(t){return 32-Math.clz32(t)}:h.prototype._countBits=function(t){var i=t,r=0;return i>=4096&&(r+=13,i>>>=13),i>=64&&(r+=7,i>>>=7),i>=8&&(r+=4,i>>>=4),i>=2&&(r+=2,i>>>=2),r+i},h.prototype._zeroBits=function(t){if(0===t)return 26;var i=t,r=0;return 0==(8191&i)&&(r+=13,i>>>=13),0==(127&i)&&(r+=7,i>>>=7),0==(15&i)&&(r+=4,i>>>=4),0==(3&i)&&(r+=2,i>>>=2),0==(1&i)&&r++,r},h.prototype.bitLength=function(){var t=this.words[this.length-1],i=this._countBits(t);return 26*(this.length-1)+i},h.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,i=0;i<this.length;i++){var r=this._zeroBits(this.words[i]);if(t+=r,26!==r)break}return t},h.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},h.prototype.toTwos=function(t){return 0!==this.negative?this.abs().inotn(t).iaddn(1):this.clone()},h.prototype.fromTwos=function(t){return this.testn(t-1)?this.notn(t).iaddn(1).ineg():this.clone()},h.prototype.isNeg=function(){return 0!==this.negative},h.prototype.neg=function(){return this.clone().ineg()},h.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},h.prototype.iuor=function(t){for(;this.length<t.length;)this.words[this.length++]=0;for(var i=0;i<t.length;i++)this.words[i]=this.words[i]|t.words[i];return this._strip()},h.prototype.ior=function(t){return e(0==(this.negative|t.negative)),this.iuor(t)},h.prototype.or=function(t){return this.length>t.length?this.clone().ior(t):t.clone().ior(this)},h.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},h.prototype.iuand=function(t){var i;i=this.length>t.length?t:this;for(var r=0;r<i.length;r++)this.words[r]=this.words[r]&t.words[r];return this.length=i.length,this._strip()},h.prototype.iand=function(t){return e(0==(this.negative|t.negative)),this.iuand(t)},h.prototype.and=function(t){return this.length>t.length?this.clone().iand(t):t.clone().iand(this)},h.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},h.prototype.iuxor=function(t){var i,r;this.length>t.length?(i=this,r=t):(i=t,r=this);for(var e=0;e<r.length;e++)this.words[e]=i.words[e]^r.words[e];if(this!==i)for(;e<i.length;e++)this.words[e]=i.words[e];return this.length=i.length,this._strip()},h.prototype.ixor=function(t){return e(0==(this.negative|t.negative)),this.iuxor(t)},h.prototype.xor=function(t){return this.length>t.length?this.clone().ixor(t):t.clone().ixor(this)},h.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},h.prototype.inotn=function(t){e("number"==typeof t&&t>=0);var i=0|Math.ceil(t/26),r=t%26;this._expand(i),r>0&&i--;for(var n=0;n<i;n++)this.words[n]=67108863&~this.words[n];return r>0&&(this.words[n]=~this.words[n]&67108863>>26-r),this._strip()},h.prototype.notn=function(t){return this.clone().inotn(t)},h.prototype.setn=function(t,i){e("number"==typeof t&&t>=0);var r=t/26|0,n=t%26;return this._expand(r+1),this.words[r]=i?this.words[r]|1<<n:this.words[r]&~(1<<n),this._strip()},h.prototype.iadd=function(t){var i,r,e;if(0!==this.negative&&0===t.negative)return this.negative=0,i=this.isub(t),this.negative^=1,this._normSign();if(0===this.negative&&0!==t.negative)return t.negative=0,i=this.isub(t),t.negative=1,i._normSign();this.length>t.length?(r=this,e=t):(r=t,e=this);for(var n=0,h=0;h<e.length;h++)i=(0|r.words[h])+(0|e.words[h])+n,this.words[h]=67108863&i,n=i>>>26;for(;0!==n&&h<r.length;h++)i=(0|r.words[h])+n,this.words[h]=67108863&i,n=i>>>26;if(this.length=r.length,0!==n)this.words[this.length]=n,this.length++;else if(r!==this)for(;h<r.length;h++)this.words[h]=r.words[h];return this},h.prototype.add=function(t){var i;return 0!==t.negative&&0===this.negative?(t.negative=0,i=this.sub(t),t.negative^=1,i):0===t.negative&&0!==this.negative?(this.negative=0,i=t.sub(this),this.negative=1,i):this.length>t.length?this.clone().iadd(t):t.clone().iadd(this)},h.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var i=this.iadd(t);return t.negative=1,i._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,e,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(r=this,e=t):(r=t,e=this);for(var h=0,o=0;o<e.length;o++)h=(i=(0|r.words[o])-(0|e.words[o])+h)>>26,this.words[o]=67108863&i;for(;0!==h&&o<r.length;o++)h=(i=(0|r.words[o])+h)>>26,this.words[o]=67108863&i;if(0===h&&o<r.length&&r!==this)for(;o<r.length;o++)this.words[o]=r.words[o];return this.length=Math.max(this.length,o),r!==this&&(this.negative=1),this._strip()},h.prototype.sub=function(t){return this.clone().isub(t)};var c=function(t,i,r){var e,n,h,o=t.words,s=i.words,u=r.words,a=0,l=0|o[0],m=8191&l,f=l>>>13,d=0|o[1],p=8191&d,g=d>>>13,c=0|o[2],M=8191&c,v=c>>>13,w=0|o[3],y=8191&w,b=w>>>13,E=0|o[4],N=8191&E,_=E>>>13,R=0|o[5],S=8191&R,A=R>>>13,I=0|o[6],T=8191&I,O=I>>>13,U=0|o[7],C=8191&U,k=U>>>13,x=0|o[8],L=8191&x,P=x>>>13,D=0|o[9],B=8191&D,F=D>>>13,G=0|s[0],Z=8191&G,q=G>>>13,z=0|s[1],j=8191&z,X=z>>>13,K=0|s[2],V=8191&K,W=K>>>13,H=0|s[3],J=8191&H,$=H>>>13,Q=0|s[4],Y=8191&Q,tt=Q>>>13,it=0|s[5],rt=8191&it,et=it>>>13,nt=0|s[6],ht=8191&nt,ot=nt>>>13,st=0|s[7],ut=8191&st,at=st>>>13,lt=0|s[8],mt=8191&lt,ft=lt>>>13,dt=0|s[9],pt=8191&dt,gt=dt>>>13;r.negative=t.negative^i.negative,r.length=19;var ct=(a+(e=Math.imul(m,Z))|0)+((8191&(n=(n=Math.imul(m,q))+Math.imul(f,Z)|0))<<13)|0;a=((h=Math.imul(f,q))+(n>>>13)|0)+(ct>>>26)|0,ct&=67108863,e=Math.imul(p,Z),n=(n=Math.imul(p,q))+Math.imul(g,Z)|0,h=Math.imul(g,q);var Mt=(a+(e=e+Math.imul(m,j)|0)|0)+((8191&(n=(n=n+Math.imul(m,X)|0)+Math.imul(f,j)|0))<<13)|0;a=((h=h+Math.imul(f,X)|0)+(n>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,e=Math.imul(M,Z),n=(n=Math.imul(M,q))+Math.imul(v,Z)|0,h=Math.imul(v,q),e=e+Math.imul(p,j)|0,n=(n=n+Math.imul(p,X)|0)+Math.imul(g,j)|0,h=h+Math.imul(g,X)|0;var vt=(a+(e=e+Math.imul(m,V)|0)|0)+((8191&(n=(n=n+Math.imul(m,W)|0)+Math.imul(f,V)|0))<<13)|0;a=((h=h+Math.imul(f,W)|0)+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,e=Math.imul(y,Z),n=(n=Math.imul(y,q))+Math.imul(b,Z)|0,h=Math.imul(b,q),e=e+Math.imul(M,j)|0,n=(n=n+Math.imul(M,X)|0)+Math.imul(v,j)|0,h=h+Math.imul(v,X)|0,e=e+Math.imul(p,V)|0,n=(n=n+Math.imul(p,W)|0)+Math.imul(g,V)|0,h=h+Math.imul(g,W)|0;var wt=(a+(e=e+Math.imul(m,J)|0)|0)+((8191&(n=(n=n+Math.imul(m,$)|0)+Math.imul(f,J)|0))<<13)|0;a=((h=h+Math.imul(f,$)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,e=Math.imul(N,Z),n=(n=Math.imul(N,q))+Math.imul(_,Z)|0,h=Math.imul(_,q),e=e+Math.imul(y,j)|0,n=(n=n+Math.imul(y,X)|0)+Math.imul(b,j)|0,h=h+Math.imul(b,X)|0,e=e+Math.imul(M,V)|0,n=(n=n+Math.imul(M,W)|0)+Math.imul(v,V)|0,h=h+Math.imul(v,W)|0,e=e+Math.imul(p,J)|0,n=(n=n+Math.imul(p,$)|0)+Math.imul(g,J)|0,h=h+Math.imul(g,$)|0;var yt=(a+(e=e+Math.imul(m,Y)|0)|0)+((8191&(n=(n=n+Math.imul(m,tt)|0)+Math.imul(f,Y)|0))<<13)|0;a=((h=h+Math.imul(f,tt)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,e=Math.imul(S,Z),n=(n=Math.imul(S,q))+Math.imul(A,Z)|0,h=Math.imul(A,q),e=e+Math.imul(N,j)|0,n=(n=n+Math.imul(N,X)|0)+Math.imul(_,j)|0,h=h+Math.imul(_,X)|0,e=e+Math.imul(y,V)|0,n=(n=n+Math.imul(y,W)|0)+Math.imul(b,V)|0,h=h+Math.imul(b,W)|0,e=e+Math.imul(M,J)|0,n=(n=n+Math.imul(M,$)|0)+Math.imul(v,J)|0,h=h+Math.imul(v,$)|0,e=e+Math.imul(p,Y)|0,n=(n=n+Math.imul(p,tt)|0)+Math.imul(g,Y)|0,h=h+Math.imul(g,tt)|0;var bt=(a+(e=e+Math.imul(m,rt)|0)|0)+((8191&(n=(n=n+Math.imul(m,et)|0)+Math.imul(f,rt)|0))<<13)|0;a=((h=h+Math.imul(f,et)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,e=Math.imul(T,Z),n=(n=Math.imul(T,q))+Math.imul(O,Z)|0,h=Math.imul(O,q),e=e+Math.imul(S,j)|0,n=(n=n+Math.imul(S,X)|0)+Math.imul(A,j)|0,h=h+Math.imul(A,X)|0,e=e+Math.imul(N,V)|0,n=(n=n+Math.imul(N,W)|0)+Math.imul(_,V)|0,h=h+Math.imul(_,W)|0,e=e+Math.imul(y,J)|0,n=(n=n+Math.imul(y,$)|0)+Math.imul(b,J)|0,h=h+Math.imul(b,$)|0,e=e+Math.imul(M,Y)|0,n=(n=n+Math.imul(M,tt)|0)+Math.imul(v,Y)|0,h=h+Math.imul(v,tt)|0,e=e+Math.imul(p,rt)|0,n=(n=n+Math.imul(p,et)|0)+Math.imul(g,rt)|0,h=h+Math.imul(g,et)|0;var Et=(a+(e=e+Math.imul(m,ht)|0)|0)+((8191&(n=(n=n+Math.imul(m,ot)|0)+Math.imul(f,ht)|0))<<13)|0;a=((h=h+Math.imul(f,ot)|0)+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863,e=Math.imul(C,Z),n=(n=Math.imul(C,q))+Math.imul(k,Z)|0,h=Math.imul(k,q),e=e+Math.imul(T,j)|0,n=(n=n+Math.imul(T,X)|0)+Math.imul(O,j)|0,h=h+Math.imul(O,X)|0,e=e+Math.imul(S,V)|0,n=(n=n+Math.imul(S,W)|0)+Math.imul(A,V)|0,h=h+Math.imul(A,W)|0,e=e+Math.imul(N,J)|0,n=(n=n+Math.imul(N,$)|0)+Math.imul(_,J)|0,h=h+Math.imul(_,$)|0,e=e+Math.imul(y,Y)|0,n=(n=n+Math.imul(y,tt)|0)+Math.imul(b,Y)|0,h=h+Math.imul(b,tt)|0,e=e+Math.imul(M,rt)|0,n=(n=n+Math.imul(M,et)|0)+Math.imul(v,rt)|0,h=h+Math.imul(v,et)|0,e=e+Math.imul(p,ht)|0,n=(n=n+Math.imul(p,ot)|0)+Math.imul(g,ht)|0,h=h+Math.imul(g,ot)|0;var Nt=(a+(e=e+Math.imul(m,ut)|0)|0)+((8191&(n=(n=n+Math.imul(m,at)|0)+Math.imul(f,ut)|0))<<13)|0;a=((h=h+Math.imul(f,at)|0)+(n>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,e=Math.imul(L,Z),n=(n=Math.imul(L,q))+Math.imul(P,Z)|0,h=Math.imul(P,q),e=e+Math.imul(C,j)|0,n=(n=n+Math.imul(C,X)|0)+Math.imul(k,j)|0,h=h+Math.imul(k,X)|0,e=e+Math.imul(T,V)|0,n=(n=n+Math.imul(T,W)|0)+Math.imul(O,V)|0,h=h+Math.imul(O,W)|0,e=e+Math.imul(S,J)|0,n=(n=n+Math.imul(S,$)|0)+Math.imul(A,J)|0,h=h+Math.imul(A,$)|0,e=e+Math.imul(N,Y)|0,n=(n=n+Math.imul(N,tt)|0)+Math.imul(_,Y)|0,h=h+Math.imul(_,tt)|0,e=e+Math.imul(y,rt)|0,n=(n=n+Math.imul(y,et)|0)+Math.imul(b,rt)|0,h=h+Math.imul(b,et)|0,e=e+Math.imul(M,ht)|0,n=(n=n+Math.imul(M,ot)|0)+Math.imul(v,ht)|0,h=h+Math.imul(v,ot)|0,e=e+Math.imul(p,ut)|0,n=(n=n+Math.imul(p,at)|0)+Math.imul(g,ut)|0,h=h+Math.imul(g,at)|0;var _t=(a+(e=e+Math.imul(m,mt)|0)|0)+((8191&(n=(n=n+Math.imul(m,ft)|0)+Math.imul(f,mt)|0))<<13)|0;a=((h=h+Math.imul(f,ft)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,e=Math.imul(B,Z),n=(n=Math.imul(B,q))+Math.imul(F,Z)|0,h=Math.imul(F,q),e=e+Math.imul(L,j)|0,n=(n=n+Math.imul(L,X)|0)+Math.imul(P,j)|0,h=h+Math.imul(P,X)|0,e=e+Math.imul(C,V)|0,n=(n=n+Math.imul(C,W)|0)+Math.imul(k,V)|0,h=h+Math.imul(k,W)|0,e=e+Math.imul(T,J)|0,n=(n=n+Math.imul(T,$)|0)+Math.imul(O,J)|0,h=h+Math.imul(O,$)|0,e=e+Math.imul(S,Y)|0,n=(n=n+Math.imul(S,tt)|0)+Math.imul(A,Y)|0,h=h+Math.imul(A,tt)|0,e=e+Math.imul(N,rt)|0,n=(n=n+Math.imul(N,et)|0)+Math.imul(_,rt)|0,h=h+Math.imul(_,et)|0,e=e+Math.imul(y,ht)|0,n=(n=n+Math.imul(y,ot)|0)+Math.imul(b,ht)|0,h=h+Math.imul(b,ot)|0,e=e+Math.imul(M,ut)|0,n=(n=n+Math.imul(M,at)|0)+Math.imul(v,ut)|0,h=h+Math.imul(v,at)|0,e=e+Math.imul(p,mt)|0,n=(n=n+Math.imul(p,ft)|0)+Math.imul(g,mt)|0,h=h+Math.imul(g,ft)|0;var Rt=(a+(e=e+Math.imul(m,pt)|0)|0)+((8191&(n=(n=n+Math.imul(m,gt)|0)+Math.imul(f,pt)|0))<<13)|0;a=((h=h+Math.imul(f,gt)|0)+(n>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,e=Math.imul(B,j),n=(n=Math.imul(B,X))+Math.imul(F,j)|0,h=Math.imul(F,X),e=e+Math.imul(L,V)|0,n=(n=n+Math.imul(L,W)|0)+Math.imul(P,V)|0,h=h+Math.imul(P,W)|0,e=e+Math.imul(C,J)|0,n=(n=n+Math.imul(C,$)|0)+Math.imul(k,J)|0,h=h+Math.imul(k,$)|0,e=e+Math.imul(T,Y)|0,n=(n=n+Math.imul(T,tt)|0)+Math.imul(O,Y)|0,h=h+Math.imul(O,tt)|0,e=e+Math.imul(S,rt)|0,n=(n=n+Math.imul(S,et)|0)+Math.imul(A,rt)|0,h=h+Math.imul(A,et)|0,e=e+Math.imul(N,ht)|0,n=(n=n+Math.imul(N,ot)|0)+Math.imul(_,ht)|0,h=h+Math.imul(_,ot)|0,e=e+Math.imul(y,ut)|0,n=(n=n+Math.imul(y,at)|0)+Math.imul(b,ut)|0,h=h+Math.imul(b,at)|0,e=e+Math.imul(M,mt)|0,n=(n=n+Math.imul(M,ft)|0)+Math.imul(v,mt)|0,h=h+Math.imul(v,ft)|0;var St=(a+(e=e+Math.imul(p,pt)|0)|0)+((8191&(n=(n=n+Math.imul(p,gt)|0)+Math.imul(g,pt)|0))<<13)|0;a=((h=h+Math.imul(g,gt)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,e=Math.imul(B,V),n=(n=Math.imul(B,W))+Math.imul(F,V)|0,h=Math.imul(F,W),e=e+Math.imul(L,J)|0,n=(n=n+Math.imul(L,$)|0)+Math.imul(P,J)|0,h=h+Math.imul(P,$)|0,e=e+Math.imul(C,Y)|0,n=(n=n+Math.imul(C,tt)|0)+Math.imul(k,Y)|0,h=h+Math.imul(k,tt)|0,e=e+Math.imul(T,rt)|0,n=(n=n+Math.imul(T,et)|0)+Math.imul(O,rt)|0,h=h+Math.imul(O,et)|0,e=e+Math.imul(S,ht)|0,n=(n=n+Math.imul(S,ot)|0)+Math.imul(A,ht)|0,h=h+Math.imul(A,ot)|0,e=e+Math.imul(N,ut)|0,n=(n=n+Math.imul(N,at)|0)+Math.imul(_,ut)|0,h=h+Math.imul(_,at)|0,e=e+Math.imul(y,mt)|0,n=(n=n+Math.imul(y,ft)|0)+Math.imul(b,mt)|0,h=h+Math.imul(b,ft)|0;var At=(a+(e=e+Math.imul(M,pt)|0)|0)+((8191&(n=(n=n+Math.imul(M,gt)|0)+Math.imul(v,pt)|0))<<13)|0;a=((h=h+Math.imul(v,gt)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,e=Math.imul(B,J),n=(n=Math.imul(B,$))+Math.imul(F,J)|0,h=Math.imul(F,$),e=e+Math.imul(L,Y)|0,n=(n=n+Math.imul(L,tt)|0)+Math.imul(P,Y)|0,h=h+Math.imul(P,tt)|0,e=e+Math.imul(C,rt)|0,n=(n=n+Math.imul(C,et)|0)+Math.imul(k,rt)|0,h=h+Math.imul(k,et)|0,e=e+Math.imul(T,ht)|0,n=(n=n+Math.imul(T,ot)|0)+Math.imul(O,ht)|0,h=h+Math.imul(O,ot)|0,e=e+Math.imul(S,ut)|0,n=(n=n+Math.imul(S,at)|0)+Math.imul(A,ut)|0,h=h+Math.imul(A,at)|0,e=e+Math.imul(N,mt)|0,n=(n=n+Math.imul(N,ft)|0)+Math.imul(_,mt)|0,h=h+Math.imul(_,ft)|0;var It=(a+(e=e+Math.imul(y,pt)|0)|0)+((8191&(n=(n=n+Math.imul(y,gt)|0)+Math.imul(b,pt)|0))<<13)|0;a=((h=h+Math.imul(b,gt)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863,e=Math.imul(B,Y),n=(n=Math.imul(B,tt))+Math.imul(F,Y)|0,h=Math.imul(F,tt),e=e+Math.imul(L,rt)|0,n=(n=n+Math.imul(L,et)|0)+Math.imul(P,rt)|0,h=h+Math.imul(P,et)|0,e=e+Math.imul(C,ht)|0,n=(n=n+Math.imul(C,ot)|0)+Math.imul(k,ht)|0,h=h+Math.imul(k,ot)|0,e=e+Math.imul(T,ut)|0,n=(n=n+Math.imul(T,at)|0)+Math.imul(O,ut)|0,h=h+Math.imul(O,at)|0,e=e+Math.imul(S,mt)|0,n=(n=n+Math.imul(S,ft)|0)+Math.imul(A,mt)|0,h=h+Math.imul(A,ft)|0;var Tt=(a+(e=e+Math.imul(N,pt)|0)|0)+((8191&(n=(n=n+Math.imul(N,gt)|0)+Math.imul(_,pt)|0))<<13)|0;a=((h=h+Math.imul(_,gt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,e=Math.imul(B,rt),n=(n=Math.imul(B,et))+Math.imul(F,rt)|0,h=Math.imul(F,et),e=e+Math.imul(L,ht)|0,n=(n=n+Math.imul(L,ot)|0)+Math.imul(P,ht)|0,h=h+Math.imul(P,ot)|0,e=e+Math.imul(C,ut)|0,n=(n=n+Math.imul(C,at)|0)+Math.imul(k,ut)|0,h=h+Math.imul(k,at)|0,e=e+Math.imul(T,mt)|0,n=(n=n+Math.imul(T,ft)|0)+Math.imul(O,mt)|0,h=h+Math.imul(O,ft)|0;var Ot=(a+(e=e+Math.imul(S,pt)|0)|0)+((8191&(n=(n=n+Math.imul(S,gt)|0)+Math.imul(A,pt)|0))<<13)|0;a=((h=h+Math.imul(A,gt)|0)+(n>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,e=Math.imul(B,ht),n=(n=Math.imul(B,ot))+Math.imul(F,ht)|0,h=Math.imul(F,ot),e=e+Math.imul(L,ut)|0,n=(n=n+Math.imul(L,at)|0)+Math.imul(P,ut)|0,h=h+Math.imul(P,at)|0,e=e+Math.imul(C,mt)|0,n=(n=n+Math.imul(C,ft)|0)+Math.imul(k,mt)|0,h=h+Math.imul(k,ft)|0;var Ut=(a+(e=e+Math.imul(T,pt)|0)|0)+((8191&(n=(n=n+Math.imul(T,gt)|0)+Math.imul(O,pt)|0))<<13)|0;a=((h=h+Math.imul(O,gt)|0)+(n>>>13)|0)+(Ut>>>26)|0,Ut&=67108863,e=Math.imul(B,ut),n=(n=Math.imul(B,at))+Math.imul(F,ut)|0,h=Math.imul(F,at),e=e+Math.imul(L,mt)|0,n=(n=n+Math.imul(L,ft)|0)+Math.imul(P,mt)|0,h=h+Math.imul(P,ft)|0;var Ct=(a+(e=e+Math.imul(C,pt)|0)|0)+((8191&(n=(n=n+Math.imul(C,gt)|0)+Math.imul(k,pt)|0))<<13)|0;a=((h=h+Math.imul(k,gt)|0)+(n>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,e=Math.imul(B,mt),n=(n=Math.imul(B,ft))+Math.imul(F,mt)|0,h=Math.imul(F,ft);var kt=(a+(e=e+Math.imul(L,pt)|0)|0)+((8191&(n=(n=n+Math.imul(L,gt)|0)+Math.imul(P,pt)|0))<<13)|0;a=((h=h+Math.imul(P,gt)|0)+(n>>>13)|0)+(kt>>>26)|0,kt&=67108863;var xt=(a+(e=Math.imul(B,pt))|0)+((8191&(n=(n=Math.imul(B,gt))+Math.imul(F,pt)|0))<<13)|0;return a=((h=Math.imul(F,gt))+(n>>>13)|0)+(xt>>>26)|0,xt&=67108863,u[0]=ct,u[1]=Mt,u[2]=vt,u[3]=wt,u[4]=yt,u[5]=bt,u[6]=Et,u[7]=Nt,u[8]=_t,u[9]=Rt,u[10]=St,u[11]=At,u[12]=It,u[13]=Tt,u[14]=Ot,u[15]=Ut,u[16]=Ct,u[17]=kt,u[18]=xt,0!==a&&(u[19]=a,r.length++),r};function M(t,i,r){r.negative=i.negative^t.negative,r.length=t.length+i.length;for(var e=0,n=0,h=0;h<r.length-1;h++){var o=n;n=0;for(var s=67108863&e,u=Math.min(h,i.length-1),a=Math.max(0,h-t.length+1);a<=u;a++){var l=h-a,m=(0|t.words[l])*(0|i.words[a]),f=67108863&m;s=67108863&(f=f+s|0),n+=(o=(o=o+(m/67108864|0)|0)+(f>>>26)|0)>>>26,o&=67108863}r.words[h]=s,e=o,o=n}return 0!==e?r.words[h]=e:r.length--,r._strip()}function v(t,i,r){return M(t,i,r)}Math.imul||(c=g),h.prototype.mulTo=function(t,i){var r=this.length+t.length;return 10===this.length&&10===t.length?c(this,t,i):r<63?g(this,t,i):r<1024?M(this,t,i):v(this,t,i)},h.prototype.mul=function(t){var i=new h(null);return i.words=new Array(this.length+t.length),this.mulTo(t,i)},h.prototype.mulf=function(t){var i=new h(null);return i.words=new Array(this.length+t.length),v(this,t,i)},h.prototype.imul=function(t){return this.clone().mulTo(t,this)},h.prototype.imuln=function(t){var i=t<0;i&&(t=-t),e("number"==typeof t),e(t<67108864);for(var r=0,n=0;n<this.length;n++){var h=(0|this.words[n])*t,o=(67108863&h)+(67108863&r);r>>=26,r+=h/67108864|0,r+=o>>>26,this.words[n]=67108863&o}return 0!==r&&(this.words[n]=r,this.length++),i?this.ineg():this},h.prototype.muln=function(t){return this.clone().imuln(t)},h.prototype.sqr=function(){return this.mul(this)},h.prototype.isqr=function(){return this.imul(this.clone())},h.prototype.pow=function(t){var i=function(t){for(var i=new Array(t.bitLength()),r=0;r<i.length;r++){var e=r/26|0,n=r%26;i[r]=t.words[e]>>>n&1}return i}(t);if(0===i.length)return new h(1);for(var r=this,e=0;e<i.length&&0===i[e];e++,r=r.sqr());if(++e<i.length)for(var n=r.sqr();e<i.length;e++,n=n.sqr())0!==i[e]&&(r=r.mul(n));return r},h.prototype.iushln=function(t){e("number"==typeof t&&t>=0);var i,r=t%26,n=(t-r)/26,h=67108863>>>26-r<<26-r;if(0!==r){var o=0;for(i=0;i<this.length;i++){var s=this.words[i]&h,u=(0|this.words[i])-s<<r;this.words[i]=u|o,o=s>>>26-r}o&&(this.words[i]=o,this.length++)}if(0!==n){for(i=this.length-1;i>=0;i--)this.words[i+n]=this.words[i];for(i=0;i<n;i++)this.words[i]=0;this.length+=n}return this._strip()},h.prototype.ishln=function(t){return e(0===this.negative),this.iushln(t)},h.prototype.iushrn=function(t,i,r){var n;e("number"==typeof t&&t>=0),n=i?(i-i%26)/26:0;var h=t%26,o=Math.min((t-h)/26,this.length),s=67108863^67108863>>>h<<h,u=r;if(n-=o,n=Math.max(0,n),u){for(var a=0;a<o;a++)u.words[a]=this.words[a];u.length=o}if(0===o);else if(this.length>o)for(this.length-=o,a=0;a<this.length;a++)this.words[a]=this.words[a+o];else this.words[0]=0,this.length=1;var l=0;for(a=this.length-1;a>=0&&(0!==l||a>=n);a--){var m=0|this.words[a];this.words[a]=l<<26-h|m>>>h,l=m&s}return u&&0!==l&&(u.words[u.length++]=l),0===this.length&&(this.words[0]=0,this.length=1),this._strip()},h.prototype.ishrn=function(t,i,r){return e(0===this.negative),this.iushrn(t,i,r)},h.prototype.shln=function(t){return this.clone().ishln(t)},h.prototype.ushln=function(t){return this.clone().iushln(t)},h.prototype.shrn=function(t){return this.clone().ishrn(t)},h.prototype.ushrn=function(t){return this.clone().iushrn(t)},h.prototype.testn=function(t){e("number"==typeof t&&t>=0);var i=t%26,r=(t-i)/26,n=1<<i;return!(this.length<=r||!(this.words[r]&n))},h.prototype.imaskn=function(t){e("number"==typeof t&&t>=0);var i=t%26,r=(t-i)/26;if(e(0===this.negative,"imaskn works only with positive numbers"),this.length<=r)return this;if(0!==i&&r++,this.length=Math.min(r,this.length),0!==i){var n=67108863^67108863>>>i<<i;this.words[this.length-1]&=n}return this._strip()},h.prototype.maskn=function(t){return this.clone().imaskn(t)},h.prototype.iaddn=function(t){return e("number"==typeof t),e(t<67108864),t<0?this.isubn(-t):0!==this.negative?1===this.length&&(0|this.words[0])<=t?(this.words[0]=t-(0|this.words[0]),this.negative=0,this):(this.negative=0,this.isubn(t),this.negative=1,this):this._iaddn(t)},h.prototype._iaddn=function(t){this.words[0]+=t;for(var i=0;i<this.length&&this.words[i]>=67108864;i++)this.words[i]-=67108864,i===this.length-1?this.words[i+1]=1:this.words[i+1]++;return this.length=Math.max(this.length,i+1),this},h.prototype.isubn=function(t){if(e("number"==typeof t),e(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var i=0;i<this.length&&this.words[i]<0;i++)this.words[i]+=67108864,this.words[i+1]-=1;return this._strip()},h.prototype.addn=function(t){return this.clone().iaddn(t)},h.prototype.subn=function(t){return this.clone().isubn(t)},h.prototype.iabs=function(){return this.negative=0,this},h.prototype.abs=function(){return this.clone().iabs()},h.prototype._ishlnsubmul=function(t,i,r){var n,h,o=t.length+r;this._expand(o);var s=0;for(n=0;n<t.length;n++){h=(0|this.words[n+r])+s;var u=(0|t.words[n])*i;s=((h-=67108863&u)>>26)-(u/67108864|0),this.words[n+r]=67108863&h}for(;n<this.length-r;n++)s=(h=(0|this.words[n+r])+s)>>26,this.words[n+r]=67108863&h;if(0===s)return this._strip();for(e(-1===s),s=0,n=0;n<this.length;n++)s=(h=-(0|this.words[n])+s)>>26,this.words[n]=67108863&h;return this.negative=1,this._strip()},h.prototype._wordDiv=function(t,i){var r=(this.length,t.length),e=this.clone(),n=t,o=0|n.words[n.length-1];0!=(r=26-this._countBits(o))&&(n=n.ushln(r),e.iushln(r),o=0|n.words[n.length-1]);var s,u=e.length-n.length;if("mod"!==i){(s=new h(null)).length=u+1,s.words=new Array(s.length);for(var a=0;a<s.length;a++)s.words[a]=0}var l=e.clone()._ishlnsubmul(n,1,u);0===l.negative&&(e=l,s&&(s.words[u]=1));for(var m=u-1;m>=0;m--){var f=67108864*(0|e.words[n.length+m])+(0|e.words[n.length+m-1]);for(f=Math.min(f/o|0,67108863),e._ishlnsubmul(n,f,m);0!==e.negative;)f--,e.negative=0,e._ishlnsubmul(n,1,m),e.isZero()||(e.negative^=1);s&&(s.words[m]=f)}return s&&s._strip(),e._strip(),"div"!==i&&0!==r&&e.iushrn(r),{div:s||null,mod:e}},h.prototype.divmod=function(t,i,r){return e(!t.isZero()),this.isZero()?{div:new h(0),mod:new h(0)}:0!==this.negative&&0===t.negative?(s=this.neg().divmod(t,i),"mod"!==i&&(n=s.div.neg()),"div"!==i&&(o=s.mod.neg(),r&&0!==o.negative&&o.iadd(t)),{div:n,mod:o}):0===this.negative&&0!==t.negative?(s=this.divmod(t.neg(),i),"mod"!==i&&(n=s.div.neg()),{div:n,mod:s.mod}):0!=(this.negative&t.negative)?(s=this.neg().divmod(t.neg(),i),"div"!==i&&(o=s.mod.neg(),r&&0!==o.negative&&o.isub(t)),{div:s.div,mod:o}):t.length>this.length||this.cmp(t)<0?{div:new h(0),mod:this}:1===t.length?"div"===i?{div:this.divn(t.words[0]),mod:null}:"mod"===i?{div:null,mod:new h(this.modrn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new h(this.modrn(t.words[0]))}:this._wordDiv(t,i);var n,o,s},h.prototype.div=function(t){return this.divmod(t,"div",!1).div},h.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},h.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},h.prototype.divRound=function(t){var i=this.divmod(t);if(i.mod.isZero())return i.div;var r=0!==i.div.negative?i.mod.isub(t):i.mod,e=t.ushrn(1),n=t.andln(1),h=r.cmp(e);return h<0||1===n&&0===h?i.div:0!==i.div.negative?i.div.isubn(1):i.div.iaddn(1)},h.prototype.modrn=function(t){var i=t<0;i&&(t=-t),e(t<=67108863);for(var r=(1<<26)%t,n=0,h=this.length-1;h>=0;h--)n=(r*n+(0|this.words[h]))%t;return i?-n:n},h.prototype.modn=function(t){return this.modrn(t)},h.prototype.idivn=function(t){var i=t<0;i&&(t=-t),e(t<=67108863);for(var r=0,n=this.length-1;n>=0;n--){var h=(0|this.words[n])+67108864*r;this.words[n]=h/t|0,r=h%t}return this._strip(),i?this.ineg():this},h.prototype.divn=function(t){return this.clone().idivn(t)},h.prototype.egcd=function(t){e(0===t.negative),e(!t.isZero());var i=this,r=t.clone();i=0!==i.negative?i.umod(t):i.clone();for(var n=new h(1),o=new h(0),s=new h(0),u=new h(1),a=0;i.isEven()&&r.isEven();)i.iushrn(1),r.iushrn(1),++a;for(var l=r.clone(),m=i.clone();!i.isZero();){for(var f=0,d=1;0==(i.words[0]&d)&&f<26;++f,d<<=1);if(f>0)for(i.iushrn(f);f-- >0;)(n.isOdd()||o.isOdd())&&(n.iadd(l),o.isub(m)),n.iushrn(1),o.iushrn(1);for(var p=0,g=1;0==(r.words[0]&g)&&p<26;++p,g<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(s.isOdd()||u.isOdd())&&(s.iadd(l),u.isub(m)),s.iushrn(1),u.iushrn(1);i.cmp(r)>=0?(i.isub(r),n.isub(s),o.isub(u)):(r.isub(i),s.isub(n),u.isub(o))}return{a:s,b:u,gcd:r.iushln(a)}},h.prototype._invmp=function(t){e(0===t.negative),e(!t.isZero());var i=this,r=t.clone();i=0!==i.negative?i.umod(t):i.clone();for(var n,o=new h(1),s=new h(0),u=r.clone();i.cmpn(1)>0&&r.cmpn(1)>0;){for(var a=0,l=1;0==(i.words[0]&l)&&a<26;++a,l<<=1);if(a>0)for(i.iushrn(a);a-- >0;)o.isOdd()&&o.iadd(u),o.iushrn(1);for(var m=0,f=1;0==(r.words[0]&f)&&m<26;++m,f<<=1);if(m>0)for(r.iushrn(m);m-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);i.cmp(r)>=0?(i.isub(r),o.isub(s)):(r.isub(i),s.isub(o))}return(n=0===i.cmpn(1)?o:s).cmpn(0)<0&&n.iadd(t),n},h.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var i=this.clone(),r=t.clone();i.negative=0,r.negative=0;for(var e=0;i.isEven()&&r.isEven();e++)i.iushrn(1),r.iushrn(1);for(;;){for(;i.isEven();)i.iushrn(1);for(;r.isEven();)r.iushrn(1);var n=i.cmp(r);if(n<0){var h=i;i=r,r=h}else if(0===n||0===r.cmpn(1))break;i.isub(r)}return r.iushln(e)},h.prototype.invm=function(t){return this.egcd(t).a.umod(t)},h.prototype.isEven=function(){return 0==(1&this.words[0])},h.prototype.isOdd=function(){return 1==(1&this.words[0])},h.prototype.andln=function(t){return this.words[0]&t},h.prototype.bincn=function(t){e("number"==typeof t);var i=t%26,r=(t-i)/26,n=1<<i;if(this.length<=r)return this._expand(r+1),this.words[r]|=n,this;for(var h=n,o=r;0!==h&&o<this.length;o++){var s=0|this.words[o];h=(s+=h)>>>26,s&=67108863,this.words[o]=s}return 0!==h&&(this.words[o]=h,this.length++),this},h.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},h.prototype.cmpn=function(t){var i,r=t<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this._strip(),this.length>1)i=1;else{r&&(t=-t),e(t<=67108863,"Number is too big");var n=0|this.words[0];i=n===t?0:n<t?-1:1}return 0!==this.negative?0|-i:i},h.prototype.cmp=function(t){if(0!==this.negative&&0===t.negative)return-1;if(0===this.negative&&0!==t.negative)return 1;var i=this.ucmp(t);return 0!==this.negative?0|-i:i},h.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length<t.length)return-1;for(var i=0,r=this.length-1;r>=0;r--){var e=0|this.words[r],n=0|t.words[r];if(e!==n){e<n?i=-1:e>n&&(i=1);break}}return i},h.prototype.gtn=function(t){return 1===this.cmpn(t)},h.prototype.gt=function(t){return 1===this.cmp(t)},h.prototype.gten=function(t){return this.cmpn(t)>=0},h.prototype.gte=function(t){return this.cmp(t)>=0},h.prototype.ltn=function(t){return-1===this.cmpn(t)},h.prototype.lt=function(t){return-1===this.cmp(t)},h.prototype.lten=function(t){return this.cmpn(t)<=0},h.prototype.lte=function(t){return this.cmp(t)<=0},h.prototype.eqn=function(t){return 0===this.cmpn(t)},h.prototype.eq=function(t){return 0===this.cmp(t)},h.red=function(t){return new R(t)},h.prototype.toRed=function(t){return e(!this.red,"Already a number in reduction context"),e(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},h.prototype.fromRed=function(){return e(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},h.prototype._forceRed=function(t){return this.red=t,this},h.prototype.forceRed=function(t){return e(!this.red,"Already a number in reduction context"),this._forceRed(t)},h.prototype.redAdd=function(t){return e(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},h.prototype.redIAdd=function(t){return e(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},h.prototype.redSub=function(t){return e(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},h.prototype.redISub=function(t){return e(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},h.prototype.redShl=function(t){return e(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},h.prototype.redMul=function(t){return e(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},h.prototype.redIMul=function(t){return e(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},h.prototype.redSqr=function(){return e(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},h.prototype.redISqr=function(){return e(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},h.prototype.redSqrt=function(){return e(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},h.prototype.redInvm=function(){return e(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},h.prototype.redNeg=function(){return e(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},h.prototype.redPow=function(t){return e(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var w={k256:null,p224:null,p192:null,p25519:null};function y(t,i){this.name=t,this.p=new h(i,16),this.n=this.p.bitLength(),this.k=new h(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function b(){y.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function E(){y.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function N(){y.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function _(){y.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function R(t){if("string"==typeof t){var i=h._prime(t);this.m=i.p,this.prime=i}else e(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function S(t){R.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new h(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}y.prototype._tmp=function(){var t=new h(null);return t.words=new Array(Math.ceil(this.n/13)),t},y.prototype.ireduce=function(t){var i,r=t;do{this.split(r,this.tmp),i=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(i>this.n);var e=i<this.n?-1:r.ucmp(this.p);return 0===e?(r.words[0]=0,r.length=1):e>0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},y.prototype.split=function(t,i){t.iushrn(this.n,0,i)},y.prototype.imulK=function(t){return t.imul(this.k)},n(b,y),b.prototype.split=function(t,i){for(var r=4194303,e=Math.min(t.length,9),n=0;n<e;n++)i.words[n]=t.words[n];if(i.length=e,t.length<=9)return t.words[0]=0,void(t.length=1);var h=t.words[9];for(i.words[i.length++]=h&r,n=10;n<t.length;n++){var o=0|t.words[n];t.words[n-10]=(o&r)<<4|h>>>22,h=o}h>>>=22,t.words[n-10]=h,0===h&&t.length>10?t.length-=10:t.length-=9},b.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var i=0,r=0;r<t.length;r++){var e=0|t.words[r];i+=977*e,t.words[r]=67108863&i,i=64*e+(i/67108864|0)}return 0===t.words[t.length-1]&&(t.length--,0===t.words[t.length-1]&&t.length--),t},n(E,y),n(N,y),n(_,y),_.prototype.imulK=function(t){for(var i=0,r=0;r<t.length;r++){var e=19*(0|t.words[r])+i,n=67108863&e;e>>>=26,t.words[r]=n,i=e}return 0!==i&&(t.words[t.length++]=i),t},h._prime=function(t){if(w[t])return w[t];var i;if("k256"===t)i=new b;else if("p224"===t)i=new E;else if("p192"===t)i=new N;else{if("p25519"!==t)throw new Error("Unknown prime "+t);i=new _}return w[t]=i,i},R.prototype._verify1=function(t){e(0===t.negative,"red works only with positives"),e(t.red,"red works only with red numbers")},R.prototype._verify2=function(t,i){e(0==(t.negative|i.negative),"red works only with positives"),e(t.red&&t.red===i.red,"red works only with red numbers")},R.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):(l(t,t.umod(this.m)._forceRed(this)),t)},R.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},R.prototype.add=function(t,i){this._verify2(t,i);var r=t.add(i);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},R.prototype.iadd=function(t,i){this._verify2(t,i);var r=t.iadd(i);return r.cmp(this.m)>=0&&r.isub(this.m),r},R.prototype.sub=function(t,i){this._verify2(t,i);var r=t.sub(i);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},R.prototype.isub=function(t,i){this._verify2(t,i);var r=t.isub(i);return r.cmpn(0)<0&&r.iadd(this.m),r},R.prototype.shl=function(t,i){return this._verify1(t),this.imod(t.ushln(i))},R.prototype.imul=function(t,i){return this._verify2(t,i),this.imod(t.imul(i))},R.prototype.mul=function(t,i){return this._verify2(t,i),this.imod(t.mul(i))},R.prototype.isqr=function(t){return this.imul(t,t.clone())},R.prototype.sqr=function(t){return this.mul(t,t)},R.prototype.sqrt=function(t){if(t.isZero())return t.clone();var i=this.m.andln(3);if(e(i%2==1),3===i){var r=this.m.add(new h(1)).iushrn(2);return this.pow(t,r)}for(var n=this.m.subn(1),o=0;!n.isZero()&&0===n.andln(1);)o++,n.iushrn(1);e(!n.isZero());var s=new h(1).toRed(this),u=s.redNeg(),a=this.m.subn(1).iushrn(1),l=this.m.bitLength();for(l=new h(2*l*l).toRed(this);0!==this.pow(l,a).cmp(u);)l.redIAdd(u);for(var m=this.pow(l,n),f=this.pow(t,n.addn(1).iushrn(1)),d=this.pow(t,n),p=o;0!==d.cmp(s);){for(var g=d,c=0;0!==g.cmp(s);c++)g=g.redSqr();e(c<p);var M=this.pow(m,new h(1).iushln(p-c-1));f=f.redMul(M),m=M.redSqr(),d=d.redMul(m),p=c}return f},R.prototype.invm=function(t){var i=t._invmp(this.m);return 0!==i.negative?(i.negative=0,this.imod(i).redNeg()):this.imod(i)},R.prototype.pow=function(t,i){if(i.isZero())return new h(1).toRed(this);if(0===i.cmpn(1))return t.clone();var r=new Array(16);r[0]=new h(1).toRed(this),r[1]=t;for(var e=2;e<r.length;e++)r[e]=this.mul(r[e-1],t);var n=r[0],o=0,s=0,u=i.bitLength()%26;for(0===u&&(u=26),e=i.length-1;e>=0;e--){for(var a=i.words[e],l=u-1;l>=0;l--){var m=a>>l&1;n!==r[0]&&(n=this.sqr(n)),0!==m||0!==o?(o<<=1,o|=m,(4==++s||0===e&&0===l)&&(n=this.mul(n,r[o]),s=0,o=0)):s=0}u=26}return n},R.prototype.convertTo=function(t){var i=t.umod(this.m);return i===t?i.clone():i},R.prototype.convertFrom=function(t){var i=t.clone();return i.red=null,i},h.mont=function(t){return new S(t)},n(S,R),S.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},S.prototype.convertFrom=function(t){var i=this.imod(t.mul(this.rinv));return i.red=null,i},S.prototype.imul=function(t,i){if(t.isZero()||i.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(i),e=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(e).iushrn(this.shift),h=n;return n.cmp(this.m)>=0?h=n.isub(this.m):n.cmpn(0)<0&&(h=n.iadd(this.m)),h._forceRed(this)},S.prototype.mul=function(t,i){if(t.isZero()||i.isZero())return new h(0)._forceRed(this);var r=t.mul(i),e=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(e).iushrn(this.shift),o=n;return n.cmp(this.m)>=0?o=n.isub(this.m):n.cmpn(0)<0&&(o=n.iadd(this.m)),o._forceRed(this)},S.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(v,t);const w="bignumber/5.7.0";var y=v.exports.BN;const b=new c(w),E={},N=9007199254740991;function _(t){return null!=t&&(S.isBigNumber(t)||"number"==typeof t&&t%1==0||"string"==typeof t&&!!t.match(/^-?[0-9]+$/)||h(t)||"bigint"==typeof t||e(t))}let R=!1;class S{constructor(t,i){t!==E&&b.throwError("cannot call constructor directly; use BigNumber.from",c.errors.UNSUPPORTED_OPERATION,{operation:"new (BigNumber)"}),this._hex=i,this._isBigNumber=!0,Object.freeze(this)}fromTwos(t){return I(T(this).fromTwos(t))}toTwos(t){return I(T(this).toTwos(t))}abs(){return"-"===this._hex[0]?S.from(this._hex.substring(1)):this}add(t){return I(T(this).add(T(t)))}sub(t){return I(T(this).sub(T(t)))}div(t){return S.from(t).isZero()&&O("division-by-zero","div"),I(T(this).div(T(t)))}mul(t){return I(T(this).mul(T(t)))}mod(t){const i=T(t);return i.isNeg()&&O("division-by-zero","mod"),I(T(this).umod(i))}pow(t){const i=T(t);return i.isNeg()&&O("negative-power","pow"),I(T(this).pow(i))}and(t){const i=T(t);return(this.isNegative()||i.isNeg())&&O("unbound-bitwise-result","and"),I(T(this).and(i))}or(t){const i=T(t);return(this.isNegative()||i.isNeg())&&O("unbound-bitwise-result","or"),I(T(this).or(i))}xor(t){const i=T(t);return(this.isNegative()||i.isNeg())&&O("unbound-bitwise-result","xor"),I(T(this).xor(i))}mask(t){return(this.isNegative()||t<0)&&O("negative-width","mask"),I(T(this).maskn(t))}shl(t){return(this.isNegative()||t<0)&&O("negative-width","shl"),I(T(this).shln(t))}shr(t){return(this.isNegative()||t<0)&&O("negative-width","shr"),I(T(this).shrn(t))}eq(t){return T(this).eq(T(t))}lt(t){return T(this).lt(T(t))}lte(t){return T(this).lte(T(t))}gt(t){return T(this).gt(T(t))}gte(t){return T(this).gte(T(t))}isNegative(){return"-"===this._hex[0]}isZero(){return T(this).isZero()}toNumber(){try{return T(this).toNumber()}catch(t){O("overflow","toNumber",this.toString())}return null}toBigInt(){try{return BigInt(this.toString())}catch(t){}return b.throwError("this platform does not support BigInt",c.errors.UNSUPPORTED_OPERATION,{value:this.toString()})}toString(){return arguments.length>0&&(10===arguments[0]?R||(R=!0,b.warn("BigNumber.toString does not accept any parameters; base-10 is assumed")):16===arguments[0]?b.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()",c.errors.UNEXPECTED_ARGUMENT,{}):b.throwError("BigNumber.toString does not accept parameters",c.errors.UNEXPECTED_ARGUMENT,{})),T(this).toString(10)}toHexString(){return this._hex}toJSON(t){return{type:"BigNumber",hex:this.toHexString()}}static from(t){if(t instanceof S)return t;if("string"==typeof t)return t.match(/^-?0x[0-9a-f]+$/i)?new S(E,A(t)):t.match(/^-?[0-9]+$/)?new S(E,A(new y(t))):b.throwArgumentError("invalid BigNumber string","value",t);if("number"==typeof t)return t%1&&O("underflow","BigNumber.from",t),(t>=N||t<=-N)&&O("overflow","BigNumber.from",t),S.from(String(t));const i=t;if("bigint"==typeof i)return S.from(i.toString());if(e(i))return S.from(n(i));if(i)if(i.toHexString){const t=i.toHexString();if("string"==typeof t)return S.from(t)}else{let t=i._hex;if(null==t&&"BigNumber"===i.type&&(t=i.hex),"string"==typeof t&&(h(t)||"-"===t[0]&&h(t.substring(1))))return S.from(t)}return b.throwArgumentError("invalid BigNumber value","value",t)}static isBigNumber(t){return!(!t||!t._isBigNumber)}}function A(t){if("string"!=typeof t)return A(t.toString(16));if("-"===t[0])return"-"===(t=t.substring(1))[0]&&b.throwArgumentError("invalid hex","value",t),"0x00"===(t=A(t))?t:"-"+t;if("0x"!==t.substring(0,2)&&(t="0x"+t),"0x"===t)return"0x00";for(t.length%2&&(t="0x0"+t.substring(2));t.length>4&&"0x00"===t.substring(0,4);)t="0x"+t.substring(4);return t}function I(t){return S.from(A(t))}function T(t){const i=S.from(t).toHexString();return"-"===i[0]?new y("-"+i.substring(3),16):new y(i.substring(2),16)}function O(t,i,r){const e={fault:t,operation:i};return null!=r&&(e.value=r),b.throwError(t,c.errors.NUMERIC_FAULT,e)}const U=new c("strings/5.7.0");var C,k;function x(t,i,r,e,n){if(t===k.BAD_PREFIX||t===k.UNEXPECTED_CONTINUE){let t=0;for(let e=i+1;e<r.length&&r[e]>>6==2;e++)t++;return t}return t===k.OVERRUN?r.length-i-1:0}!function(t){t.current="",t.NFC="NFC",t.NFD="NFD",t.NFKC="NFKC",t.NFKD="NFKD"}(C||(C={})),function(t){t.UNEXPECTED_CONTINUE="unexpected continuation byte",t.BAD_PREFIX="bad codepoint prefix",t.OVERRUN="string overrun",t.MISSING_CONTINUE="missing continuation byte",t.OUT_OF_RANGE="out of UTF-8 range",t.UTF16_SURROGATE="UTF-16 surrogate",t.OVERLONG="overlong representation"}(k||(k={}));const L=Object.freeze({error:function(t,i,r,e,n){return U.throwArgumentError(`invalid codepoint at offset ${i}; ${t}`,"bytes",r)},ignore:x,replace:function(t,i,r,e,n){return t===k.OVERLONG?(e.push(n),0):(e.push(65533),x(t,i,r))}});function P(t,i){null==i&&(i=L.error),t=o(t);const r=[];let e=0;for(;e<t.length;){const n=t[e++];if(n>>7==0){r.push(n);continue}let h=null,o=null;if(192==(224&n))h=1,o=127;else if(224==(240&n))h=2,o=2047;else{if(240!=(248&n)){e+=i(128==(192&n)?k.UNEXPECTED_CONTINUE:k.BAD_PREFIX,e-1,t,r);continue}h=3,o=65535}if(e-1+h>=t.length){e+=i(k.OVERRUN,e-1,t,r);continue}let s=n&(1<<8-h-1)-1;for(let n=0;n<h;n++){let n=t[e];if(128!=(192&n)){e+=i(k.MISSING_CONTINUE,e,t,r),s=null;break}s=s<<6|63&n,e++}null!==s&&(s>1114111?e+=i(k.OUT_OF_RANGE,e-1-h,t,r,s):s>=55296&&s<=57343?e+=i(k.UTF16_SURROGATE,e-1-h,t,r,s):s<=o?e+=i(k.OVERLONG,e-1-h,t,r,s):r.push(s))}return r}function D(t,i=C.current){i!=C.current&&(U.checkNormalize(),t=t.normalize(i));let r=[];for(let i=0;i<t.length;i++){const e=t.charCodeAt(i);if(e<128)r.push(e);else if(e<2048)r.push(e>>6|192),r.push(63&e|128);else if(55296==(64512&e)){i++;const n=t.charCodeAt(i);if(i>=t.length||56320!=(64512&n))throw new Error("invalid utf-8 string");const h=65536+((1023&e)<<10)+(1023&n);r.push(h>>18|240),r.push(h>>12&63|128),r.push(h>>6&63|128),r.push(63&h|128)}else r.push(e>>12|224),r.push(e>>6&63|128),r.push(63&e|128)}return o(r)}function B(t){const i="0000"+t.toString(16);return"\\u"+i.substring(i.length-4)}function F(t,i){return'"'+P(t,i).map((t=>{if(t<256){switch(t){case 8:return"\\b";case 9:return"\\t";case 10:return"\\n";case 13:return"\\r";case 34:return'\\"';case 92:return"\\\\"}if(t>=32&&t<127)return String.fromCharCode(t)}return t<=65535?B(t):B(55296+((t-=65536)>>10&1023))+B(56320+(1023&t))})).join("")+'"'}function G(t){return t.map((t=>t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode(55296+(t>>10&1023),56320+(1023&t))))).join("")}function Z(t,i){return G(P(t,i))}function q(t,i=C.current){return P(D(t,i))}function z(t){return i(D(t))}export{S as B,p as E,c as L,C as U,G as _,Z as a,_ as b,q as c,F as d,L as e,k as f,z as i,M as l,D as t,w as v};
@@ -1 +1 @@
1
- import{c as e,g as t,b as s,_ as a,d as r,u as n}from"./index-bc061f7b.js";import{b as i}from"./browser-ponyfill-4134b2b7.js";import{e as o,W as d,F as c,l as u,u as l,w as f,v as h,a as g}from"./ethers-f8f094be.js";import{Signer as p,VoidSigner as _}from"@ethersproject/abstract-signer";import*as E from"@ethersproject/providers";import{getDefaultProvider as m}from"@ethersproject/providers";import{BaseContract as v,Contract as T,ContractFactory as y}from"@ethersproject/contracts";import{B as w,E as S}from"./id-dcb529f4.js";import*as I from"@ethersproject/constants";import b from"events";import"zustand";import"@ethersproject/address";import"@ethersproject/properties";import"@ethersproject/transactions";import"@ethersproject/bytes";import"@ethersproject/abstract-provider";import"./index-4e6b81d8.js";import"./__node-resolve_empty-314df16e.js";import"./hash-b468659c.js";import"./inherits_browser-51bb8c3c.js";import"@ethersproject/json-wallets";import"./interface-6c3ec32a.js";import"./index-89a7e976.js";var A={},P={},M={},O={},C={},R={name:"@safe-global/safe-apps-sdk",version:"7.10.1",description:"SDK developed to integrate third-party apps with Safe app.",main:"dist/src/index.js",typings:"dist/src/index.d.ts",_files:["dist/**/*","src/**/*","CHANGELOG.md","README.md"],keywords:["Safe","sdk","apps"],scripts:{test:"jest","format-dist":"sed -i '' 's/\"files\":/\"_files\":/' dist/package.json",build:"yarn rimraf dist && tsc && yarn format-dist"},author:"Safe (https://safe.global)",license:"MIT",dependencies:{"@safe-global/safe-gateway-typescript-sdk":"^3.5.3",ethers:"^5.7.2"},devDependencies:{rimraf:"^3.0.2"},repository:{type:"git",url:"git+https://github.com/safe-global/safe-apps-sdk.git"},bugs:{url:"https://github.com/safe-global/safe-apps-sdk/issues"},homepage:"https://github.com/safe-global/safe-apps-sdk#readme",publishConfig:{access:"public"}},N=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(C,"__esModule",{value:!0}),C.getSDKVersion=void 0;const L=N(R);C.getSDKVersion=()=>L.default.version.split("-")[0];var D={};Object.defineProperty(D,"__esModule",{value:!0}),D.generateRequestId=void 0;const j=e=>e.toString(16).padStart(2,"0");D.generateRequestId=()=>"undefined"!=typeof window?(e=>{const t=new Uint8Array((e||40)/2);return window.crypto.getRandomValues(t),Array.from(t,j).join("")})(10):(new Date).getTime().toString(36),Object.defineProperty(O,"__esModule",{value:!0}),O.MessageFormatter=void 0;const x=C,H=D;class B{}O.MessageFormatter=B,B.makeRequest=(e,t)=>({id:(0,H.generateRequestId)(),method:e,params:t,env:{sdkVersion:(0,x.getSDKVersion)()}}),B.makeResponse=(e,t,s)=>({id:e,success:!0,version:s,data:t}),B.makeErrorResponse=(e,t,s)=>({id:e,success:!1,error:t,version:s});var k,q,U={};k=U,Object.defineProperty(k,"__esModule",{value:!0}),k.RestrictedMethods=k.Methods=void 0,(q=k.Methods||(k.Methods={})).sendTransactions="sendTransactions",q.rpcCall="rpcCall",q.getChainInfo="getChainInfo",q.getSafeInfo="getSafeInfo",q.getTxBySafeTxHash="getTxBySafeTxHash",q.getSafeBalances="getSafeBalances",q.signMessage="signMessage",q.signTypedMessage="signTypedMessage",q.getEnvironmentInfo="getEnvironmentInfo",q.getOffChainSignature="getOffChainSignature",q.requestAddressBook="requestAddressBook",q.wallet_getPermissions="wallet_getPermissions",q.wallet_requestPermissions="wallet_requestPermissions",(k.RestrictedMethods||(k.RestrictedMethods={})).requestAddressBook="requestAddressBook",function(t){var s=e&&e.__createBinding||(Object.create?function(e,t,s,a){void 0===a&&(a=s);var r=Object.getOwnPropertyDescriptor(t,s);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[s]}}),Object.defineProperty(e,a,r)}:function(e,t,s,a){void 0===a&&(a=s),e[a]=t[s]}),a=e&&e.__exportStar||function(e,t){for(var a in e)"default"===a||Object.prototype.hasOwnProperty.call(t,a)||s(t,e,a)};Object.defineProperty(t,"__esModule",{value:!0});const r=O;t.default=class{constructor(e=null,t=!1){this.allowedOrigins=null,this.callbacks=new Map,this.debugMode=!1,this.isServer="undefined"==typeof window,this.isValidMessage=({origin:e,data:t,source:s})=>{const a=!t,r=!this.isServer&&s===window.parent,n=(void 0!==t.version&&parseInt(t.version.split(".")[0]))>=1;let i=!0;return Array.isArray(this.allowedOrigins)&&(i=void 0!==this.allowedOrigins.find((t=>t.test(e)))),!a&&r&&n&&i},this.logIncomingMessage=e=>{console.info(`Safe Apps SDK v1: A message was received from origin ${e.origin}. `,e.data)},this.onParentMessage=e=>{this.isValidMessage(e)&&(this.debugMode&&this.logIncomingMessage(e),this.handleIncomingMessage(e.data))},this.handleIncomingMessage=e=>{const{id:t}=e,s=this.callbacks.get(t);s&&(s(e),this.callbacks.delete(t))},this.send=(e,t)=>{const s=r.MessageFormatter.makeRequest(e,t);if(this.isServer)throw new Error("Window doesn't exist");return window.parent.postMessage(s,"*"),new Promise(((e,t)=>{this.callbacks.set(s.id,(s=>{s.success?e(s):t(new Error(s.error))}))}))},this.allowedOrigins=e,this.debugMode=t,this.isServer||window.addEventListener("message",this.onParentMessage)}},a(U,t)}(M);var G={},$={},F={};Object.defineProperty(F,"__esModule",{value:!0}),F.isObjectEIP712TypedData=void 0;F.isObjectEIP712TypedData=e=>"object"==typeof e&&null!=e&&"domain"in e&&"types"in e&&"message"in e;var V={};Object.defineProperty(V,"__esModule",{value:!0});var W={},K={},Q={},X={},Y=e&&e.__awaiter||function(e,t,s,a){return new(s||(s=Promise))((function(r,n){function i(e){try{d(a.next(e))}catch(e){n(e)}}function o(e){try{d(a.throw(e))}catch(e){n(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof s?t:new s((function(e){e(t)}))).then(i,o)}d((a=a.apply(e,t||[])).next())}))},J=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(X,"__esModule",{value:!0}),X.fetchData=X.stringifyQuery=X.insertParams=void 0;const z=J(i.exports);X.insertParams=function(e,t){return t?Object.keys(t).reduce(((e,s)=>function(e,t,s){return e.replace(new RegExp(`\\{${t}\\}`,"g"),s)}(e,s,String(t[s]))),e):e},X.stringifyQuery=function(e){if(!e)return"";const t=new URLSearchParams;Object.keys(e).forEach((s=>{null!=e[s]&&t.append(s,String(e[s]))}));const s=t.toString();return s?`?${s}`:""},X.fetchData=function(e,t){return Y(this,void 0,void 0,(function*(){let s;null!=t&&(s={method:"POST",body:"string"==typeof t?t:JSON.stringify(t),headers:{"Content-Type":"application/json"}});const a=yield(0,z.default)(e,s);let r;try{r=yield a.json()}catch(e){if(a.headers&&"0"!==a.headers.get("content-length"))throw new Error(`Invalid response content: ${a.statusText}`)}if(!a.ok){const e="object"==typeof(n=r)&&null!==n&&"code"in n&&"message"in n?`${r.code}: ${r.message}`:a.statusText;throw new Error(e)}var n;return r}))},Object.defineProperty(Q,"__esModule",{value:!0}),Q.getEndpoint=Q.postEndpoint=void 0;const Z=X;function ee(e,t,s,a){return`${e}${(0,Z.insertParams)(t,s)}${(0,Z.stringifyQuery)(a)}`}Q.postEndpoint=function(e,t,s){const a=ee(e,t,null==s?void 0:s.path,null==s?void 0:s.query);return(0,Z.fetchData)(a,null==s?void 0:s.body)},Q.getEndpoint=function(e,t,s,a){if(a)return(0,Z.fetchData)(a);const r=ee(e,t,null==s?void 0:s.path,null==s?void 0:s.query);return(0,Z.fetchData)(r)};var te={};Object.defineProperty(te,"__esModule",{value:!0}),te.DEFAULT_BASE_URL=void 0,te.DEFAULT_BASE_URL="https://safe-client.safe.global";var se={};!function(e){var t;Object.defineProperty(e,"__esModule",{value:!0}),e.ImplementationVersionState=void 0,(t=e.ImplementationVersionState||(e.ImplementationVersionState={})).UP_TO_DATE="UP_TO_DATE",t.OUTDATED="OUTDATED",t.UNKNOWN="UNKNOWN"}(se);var ae={};!function(e){var t,s;Object.defineProperty(e,"__esModule",{value:!0}),e.SafeAppSocialPlatforms=e.SafeAppFeatures=e.SafeAppAccessPolicyTypes=void 0,(t=e.SafeAppAccessPolicyTypes||(e.SafeAppAccessPolicyTypes={})).NoRestrictions="NO_RESTRICTIONS",t.DomainAllowlist="DOMAIN_ALLOWLIST",(e.SafeAppFeatures||(e.SafeAppFeatures={})).BATCHED_TRANSACTIONS="BATCHED_TRANSACTIONS",(s=e.SafeAppSocialPlatforms||(e.SafeAppSocialPlatforms={})).TWITTER="TWITTER",s.GITHUB="GITHUB",s.DISCORD="DISCORD"}(ae);var re={};!function(e){var t,s,a,r,n,i,o,d,c,u;Object.defineProperty(e,"__esModule",{value:!0}),e.LabelValue=e.DetailedExecutionInfoType=e.TransactionListItemType=e.ConflictType=e.TransactionInfoType=e.SettingsInfoType=e.TransactionTokenType=e.TransferDirection=e.TransactionStatus=e.Operation=void 0,(t=e.Operation||(e.Operation={}))[t.CALL=0]="CALL",t[t.DELEGATE=1]="DELEGATE",(s=e.TransactionStatus||(e.TransactionStatus={})).AWAITING_CONFIRMATIONS="AWAITING_CONFIRMATIONS",s.AWAITING_EXECUTION="AWAITING_EXECUTION",s.CANCELLED="CANCELLED",s.FAILED="FAILED",s.SUCCESS="SUCCESS",(a=e.TransferDirection||(e.TransferDirection={})).INCOMING="INCOMING",a.OUTGOING="OUTGOING",a.UNKNOWN="UNKNOWN",(r=e.TransactionTokenType||(e.TransactionTokenType={})).ERC20="ERC20",r.ERC721="ERC721",r.NATIVE_COIN="NATIVE_COIN",(n=e.SettingsInfoType||(e.SettingsInfoType={})).SET_FALLBACK_HANDLER="SET_FALLBACK_HANDLER",n.ADD_OWNER="ADD_OWNER",n.REMOVE_OWNER="REMOVE_OWNER",n.SWAP_OWNER="SWAP_OWNER",n.CHANGE_THRESHOLD="CHANGE_THRESHOLD",n.CHANGE_IMPLEMENTATION="CHANGE_IMPLEMENTATION",n.ENABLE_MODULE="ENABLE_MODULE",n.DISABLE_MODULE="DISABLE_MODULE",n.SET_GUARD="SET_GUARD",n.DELETE_GUARD="DELETE_GUARD",(i=e.TransactionInfoType||(e.TransactionInfoType={})).TRANSFER="Transfer",i.SETTINGS_CHANGE="SettingsChange",i.CUSTOM="Custom",i.CREATION="Creation",(o=e.ConflictType||(e.ConflictType={})).NONE="None",o.HAS_NEXT="HasNext",o.END="End",(d=e.TransactionListItemType||(e.TransactionListItemType={})).TRANSACTION="TRANSACTION",d.LABEL="LABEL",d.CONFLICT_HEADER="CONFLICT_HEADER",d.DATE_LABEL="DATE_LABEL",(c=e.DetailedExecutionInfoType||(e.DetailedExecutionInfoType={})).MULTISIG="MULTISIG",c.MODULE="MODULE",(u=e.LabelValue||(e.LabelValue={})).Queued="Queued",u.Next="Next"}(re);var ne={};!function(e){var t,s,a;Object.defineProperty(e,"__esModule",{value:!0}),e.FEATURES=e.GAS_PRICE_TYPE=e.RPC_AUTHENTICATION=void 0,(t=e.RPC_AUTHENTICATION||(e.RPC_AUTHENTICATION={})).API_KEY_PATH="API_KEY_PATH",t.NO_AUTHENTICATION="NO_AUTHENTICATION",t.UNKNOWN="UNKNOWN",(s=e.GAS_PRICE_TYPE||(e.GAS_PRICE_TYPE={})).ORACLE="ORACLE",s.FIXED="FIXED",s.UNKNOWN="UNKNOWN",(a=e.FEATURES||(e.FEATURES={})).ERC721="ERC721",a.SAFE_APPS="SAFE_APPS",a.CONTRACT_INTERACTION="CONTRACT_INTERACTION",a.DOMAIN_LOOKUP="DOMAIN_LOOKUP",a.SPENDING_LIMIT="SPENDING_LIMIT",a.EIP1559="EIP1559",a.SAFE_TX_GAS_OPTIONAL="SAFE_TX_GAS_OPTIONAL",a.TX_SIMULATION="TX_SIMULATION",a.EIP1271="EIP1271"}(ne);var ie={};!function(e){var t;Object.defineProperty(e,"__esModule",{value:!0}),e.TokenType=void 0,(t=e.TokenType||(e.TokenType={})).ERC20="ERC20",t.ERC721="ERC721",t.NATIVE_TOKEN="NATIVE_TOKEN"}(ie);var oe={};Object.defineProperty(oe,"__esModule",{value:!0});var de={};Object.defineProperty(de,"__esModule",{value:!0});var ce={};!function(e){var t,s;Object.defineProperty(e,"__esModule",{value:!0}),e.SafeMessageStatus=e.SafeMessageListItemType=void 0,(t=e.SafeMessageListItemType||(e.SafeMessageListItemType={})).DATE_LABEL="DATE_LABEL",t.MESSAGE="MESSAGE",(s=e.SafeMessageStatus||(e.SafeMessageStatus={})).NEEDS_CONFIRMATION="NEEDS_CONFIRMATION",s.CONFIRMED="CONFIRMED"}(ce),function(t){var s=e&&e.__createBinding||(Object.create?function(e,t,s,a){void 0===a&&(a=s);var r=Object.getOwnPropertyDescriptor(t,s);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[s]}}),Object.defineProperty(e,a,r)}:function(e,t,s,a){void 0===a&&(a=s),e[a]=t[s]}),a=e&&e.__exportStar||function(e,t){for(var a in e)"default"===a||Object.prototype.hasOwnProperty.call(t,a)||s(t,e,a)};Object.defineProperty(t,"__esModule",{value:!0}),t.confirmSafeMessage=t.proposeSafeMessage=t.getSafeMessage=t.getSafeMessages=t.getDecodedData=t.getMasterCopies=t.getSafeApps=t.getChainConfig=t.getChainsConfig=t.proposeTransaction=t.postSafeGasEstimation=t.getTransactionDetails=t.getTransactionQueue=t.getTransactionHistory=t.getCollectiblesPage=t.getCollectibles=t.getOwnedSafes=t.getFiatCurrencies=t.getBalances=t.getMultisigTransactions=t.getModuleTransactions=t.getIncomingTransfers=t.getSafeInfo=t.setBaseUrl=void 0;const r=Q,n=te;a(se,t),a(ae,t),a(re,t),a(ne,t),a(ie,t),a(oe,t),a(de,t),a(ce,t);let i=n.DEFAULT_BASE_URL;t.setBaseUrl=e=>{i=e},t.getSafeInfo=function(e,t){return(0,r.getEndpoint)(i,"/v1/chains/{chainId}/safes/{address}",{path:{chainId:e,address:t}})},t.getIncomingTransfers=function(e,t,s,a){return(0,r.getEndpoint)(i,"/v1/chains/{chainId}/safes/{address}/incoming-transfers/",{path:{chainId:e,address:t},query:s},a)},t.getModuleTransactions=function(e,t,s,a){return(0,r.getEndpoint)(i,"/v1/chains/{chainId}/safes/{address}/module-transactions/",{path:{chainId:e,address:t},query:s},a)},t.getMultisigTransactions=function(e,t,s,a){return(0,r.getEndpoint)(i,"/v1/chains/{chainId}/safes/{address}/multisig-transactions/",{path:{chainId:e,address:t},query:s},a)},t.getBalances=function(e,t,s="usd",a={}){return(0,r.getEndpoint)(i,"/v1/chains/{chainId}/safes/{address}/balances/{currency}",{path:{chainId:e,address:t,currency:s},query:a})},t.getFiatCurrencies=function(){return(0,r.getEndpoint)(i,"/v1/balances/supported-fiat-codes")},t.getOwnedSafes=function(e,t){return(0,r.getEndpoint)(i,"/v1/chains/{chainId}/owners/{address}/safes",{path:{chainId:e,address:t}})},t.getCollectibles=function(e,t,s={}){return(0,r.getEndpoint)(i,"/v1/chains/{chainId}/safes/{address}/collectibles",{path:{chainId:e,address:t},query:s})},t.getCollectiblesPage=function(e,t,s={},a){return(0,r.getEndpoint)(i,"/v2/chains/{chainId}/safes/{address}/collectibles",{path:{chainId:e,address:t},query:s},a)},t.getTransactionHistory=function(e,t,s){return(0,r.getEndpoint)(i,"/v1/chains/{chainId}/safes/{safe_address}/transactions/history",{path:{chainId:e,safe_address:t},query:{}},s)},t.getTransactionQueue=function(e,t,s,a){return(0,r.getEndpoint)(i,"/v1/chains/{chainId}/safes/{safe_address}/transactions/queued",{path:{chainId:e,safe_address:t},query:{trusted:a}},s)},t.getTransactionDetails=function(e,t){return(0,r.getEndpoint)(i,"/v1/chains/{chainId}/transactions/{transactionId}",{path:{chainId:e,transactionId:t}})},t.postSafeGasEstimation=function(e,t,s){return(0,r.postEndpoint)(i,"/v2/chains/{chainId}/safes/{safe_address}/multisig-transactions/estimations",{path:{chainId:e,safe_address:t},body:s})},t.proposeTransaction=function(e,t,s){return(0,r.postEndpoint)(i,"/v1/chains/{chainId}/transactions/{safe_address}/propose",{path:{chainId:e,safe_address:t},body:s})},t.getChainsConfig=function(e){return(0,r.getEndpoint)(i,"/v1/chains",{query:e})},t.getChainConfig=function(e){return(0,r.getEndpoint)(i,"/v1/chains/{chainId}",{path:{chainId:e}})},t.getSafeApps=function(e,t={}){return(0,r.getEndpoint)(i,"/v1/chains/{chainId}/safe-apps",{path:{chainId:e},query:t})},t.getMasterCopies=function(e){return(0,r.getEndpoint)(i,"/v1/chains/{chainId}/about/master-copies",{path:{chainId:e}})},t.getDecodedData=function(e,t){return(0,r.postEndpoint)(i,"/v1/chains/{chainId}/data-decoder",{path:{chainId:e},body:{data:t}})},t.getSafeMessages=function(e,t,s){return(0,r.getEndpoint)(i,"/v1/chains/{chainId}/safes/{safe_address}/messages",{path:{chainId:e,safe_address:t},query:{}},s)},t.getSafeMessage=function(e,t){return(0,r.getEndpoint)(i,"/v1/chains/{chainId}/messages/{message_hash}",{path:{chainId:e,message_hash:t}})},t.proposeSafeMessage=function(e,t,s){return(0,r.postEndpoint)(i,"/v1/chains/{chainId}/safes/{safe_address}/messages",{path:{chainId:e,safe_address:t},body:s})},t.confirmSafeMessage=function(e,t,s){return(0,r.postEndpoint)(i,"/v1/chains/{chainId}/messages/{message_hash}/signatures",{path:{chainId:e,message_hash:t},body:s})}}(K),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.TransferDirection=e.TransactionStatus=e.TokenType=e.Operation=void 0;var t=K;Object.defineProperty(e,"Operation",{enumerable:!0,get:function(){return t.Operation}}),Object.defineProperty(e,"TokenType",{enumerable:!0,get:function(){return t.TokenType}}),Object.defineProperty(e,"TransactionStatus",{enumerable:!0,get:function(){return t.TransactionStatus}}),Object.defineProperty(e,"TransferDirection",{enumerable:!0,get:function(){return t.TransferDirection}})}(W);var ue={};Object.defineProperty(ue,"__esModule",{value:!0}),function(t){var s=e&&e.__createBinding||(Object.create?function(e,t,s,a){void 0===a&&(a=s);var r=Object.getOwnPropertyDescriptor(t,s);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[s]}}),Object.defineProperty(e,a,r)}:function(e,t,s,a){void 0===a&&(a=s),e[a]=t[s]}),a=e&&e.__exportStar||function(e,t){for(var a in e)"default"===a||Object.prototype.hasOwnProperty.call(t,a)||s(t,e,a)};Object.defineProperty(t,"__esModule",{value:!0}),a(F,t),a(V,t),a(W,t),a(ue,t)}($),Object.defineProperty(G,"__esModule",{value:!0}),G.TXs=void 0;const le=U,fe=$;G.TXs=class{constructor(e){this.communicator=e}async getBySafeTxHash(e){if(!e)throw new Error("Invalid safeTxHash");return(await this.communicator.send(le.Methods.getTxBySafeTxHash,{safeTxHash:e})).data}async signMessage(e){const t={message:e};return(await this.communicator.send(le.Methods.signMessage,t)).data}async signTypedMessage(e){if(!(0,fe.isObjectEIP712TypedData)(e))throw new Error("Invalid typed data");return(await this.communicator.send(le.Methods.signTypedMessage,{typedData:e})).data}async send({txs:e,params:t}){if(!e||!e.length)throw new Error("No transactions were passed");const s={txs:e,params:t};return(await this.communicator.send(le.Methods.sendTransactions,s)).data}};var he={},ge={};Object.defineProperty(ge,"__esModule",{value:!0}),ge.RPC_CALLS=void 0,ge.RPC_CALLS={eth_call:"eth_call",eth_gasPrice:"eth_gasPrice",eth_getLogs:"eth_getLogs",eth_getBalance:"eth_getBalance",eth_getCode:"eth_getCode",eth_getBlockByHash:"eth_getBlockByHash",eth_getBlockByNumber:"eth_getBlockByNumber",eth_getStorageAt:"eth_getStorageAt",eth_getTransactionByHash:"eth_getTransactionByHash",eth_getTransactionReceipt:"eth_getTransactionReceipt",eth_getTransactionCount:"eth_getTransactionCount",eth_estimateGas:"eth_estimateGas",safe_setSettings:"safe_setSettings"},Object.defineProperty(he,"__esModule",{value:!0}),he.Eth=void 0;const pe=ge,_e=U,Ee={defaultBlockParam:(e="latest")=>e,returnFullTxObjectParam:(e=!1)=>e,blockNumberToHex:e=>Number.isInteger(e)?`0x${e.toString(16)}`:e};he.Eth=class{constructor(e){this.communicator=e,this.call=this.buildRequest({call:pe.RPC_CALLS.eth_call,formatters:[null,Ee.defaultBlockParam]}),this.getBalance=this.buildRequest({call:pe.RPC_CALLS.eth_getBalance,formatters:[null,Ee.defaultBlockParam]}),this.getCode=this.buildRequest({call:pe.RPC_CALLS.eth_getCode,formatters:[null,Ee.defaultBlockParam]}),this.getStorageAt=this.buildRequest({call:pe.RPC_CALLS.eth_getStorageAt,formatters:[null,Ee.blockNumberToHex,Ee.defaultBlockParam]}),this.getPastLogs=this.buildRequest({call:pe.RPC_CALLS.eth_getLogs}),this.getBlockByHash=this.buildRequest({call:pe.RPC_CALLS.eth_getBlockByHash,formatters:[null,Ee.returnFullTxObjectParam]}),this.getBlockByNumber=this.buildRequest({call:pe.RPC_CALLS.eth_getBlockByNumber,formatters:[Ee.blockNumberToHex,Ee.returnFullTxObjectParam]}),this.getTransactionByHash=this.buildRequest({call:pe.RPC_CALLS.eth_getTransactionByHash}),this.getTransactionReceipt=this.buildRequest({call:pe.RPC_CALLS.eth_getTransactionReceipt}),this.getTransactionCount=this.buildRequest({call:pe.RPC_CALLS.eth_getTransactionCount,formatters:[null,Ee.defaultBlockParam]}),this.getGasPrice=this.buildRequest({call:pe.RPC_CALLS.eth_gasPrice}),this.getEstimateGas=e=>this.buildRequest({call:pe.RPC_CALLS.eth_estimateGas})([e]),this.setSafeSettings=this.buildRequest({call:pe.RPC_CALLS.safe_setSettings})}buildRequest(e){const{call:t,formatters:s}=e;return async e=>{s&&Array.isArray(e)&&s.forEach(((t,s)=>{t&&(e[s]=t(e[s]))}));const a={call:t,params:e||[]};return(await this.communicator.send(_e.Methods.rpcCall,a)).data}}};var me={};try{const e=window;null==e._ethers&&(e._ethers=o)}catch(e){}var ve=t(Object.freeze({__proto__:null,ethers:o,Signer:p,Wallet:d,VoidSigner:_,getDefaultProvider:m,providers:E,BaseContract:v,Contract:T,ContractFactory:y,BigNumber:w,FixedNumber:c,constants:I,get errors(){return S},logger:u,utils:l,wordlists:f,version:h,Wordlist:g})),Te={};Object.defineProperty(Te,"__esModule",{value:!0}),Te.MAGIC_VALUE_BYTES=Te.MAGIC_VALUE=Te.EIP_1271_BYTES_INTERFACE=Te.EIP_1271_INTERFACE=void 0;const ye=ve;Te.MAGIC_VALUE="0x1626ba7e";Te.MAGIC_VALUE_BYTES="0x20c13b0b";const we=new ye.ethers.utils.Interface(["function isValidSignature(bytes32 _dataHash, bytes calldata _signature) external view"]);Te.EIP_1271_INTERFACE=we;const Se=new ye.ethers.utils.Interface(["function isValidSignature(bytes calldata _data, bytes calldata _signature) public view"]);Te.EIP_1271_BYTES_INTERFACE=Se;var Ie={},be={},Ae={};Object.defineProperty(Ae,"__esModule",{value:!0}),Ae.PermissionsError=Ae.PERMISSIONS_REQUEST_REJECTED=void 0,Ae.PERMISSIONS_REQUEST_REJECTED=4001;class Pe extends Error{constructor(e,t,s){super(e),this.code=t,this.data=s,Object.setPrototypeOf(this,Pe.prototype)}}Ae.PermissionsError=Pe,Object.defineProperty(be,"__esModule",{value:!0}),be.Wallet=void 0;const Me=U,Oe=Ae;be.Wallet=class{constructor(e){this.communicator=e}async getPermissions(){return(await this.communicator.send(Me.Methods.wallet_getPermissions,void 0)).data}async requestPermissions(e){if(!this.isPermissionRequestValid(e))throw new Oe.PermissionsError("Permissions request is invalid",Oe.PERMISSIONS_REQUEST_REJECTED);try{return(await this.communicator.send(Me.Methods.wallet_requestPermissions,e)).data}catch(e){throw new Oe.PermissionsError("Permissions rejected",Oe.PERMISSIONS_REQUEST_REJECTED)}}isPermissionRequestValid(e){return e.every((e=>"object"==typeof e&&Object.keys(e).every((e=>!!Object.values(Me.RestrictedMethods).includes(e)))))}},Object.defineProperty(Ie,"__esModule",{value:!0});const Ce=be,Re=Ae,Ne=(e,t)=>t.some((t=>t.parentCapability===e));Ie.default=()=>(e,t,s)=>{const a=s.value;return s.value=async function(){const e=new Ce.Wallet(this.communicator);let s=await e.getPermissions();if(Ne(t,s)||(s=await e.requestPermissions([{[t]:{}}])),!Ne(t,s))throw new Re.PermissionsError("Permissions rejected",Re.PERMISSIONS_REQUEST_REJECTED);return a.apply(this)},s};var Le=e&&e.__decorate||function(e,t,s,a){var r,n=arguments.length,i=n<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,s):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,s,a);else for(var o=e.length-1;o>=0;o--)(r=e[o])&&(i=(n<3?r(i):n>3?r(t,s,i):r(t,s))||i);return n>3&&i&&Object.defineProperty(t,s,i),i},De=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(me,"__esModule",{value:!0}),me.Safe=void 0;const je=ve,xe=Te,He=U,Be=ge,ke=$,qe=De(Ie);class Ue{constructor(e){this.communicator=e}async getChainInfo(){return(await this.communicator.send(He.Methods.getChainInfo,void 0)).data}async getInfo(){return(await this.communicator.send(He.Methods.getSafeInfo,void 0)).data}async experimental_getBalances({currency:e="usd"}={}){return(await this.communicator.send(He.Methods.getSafeBalances,{currency:e})).data}async check1271Signature(e,t="0x"){const s=await this.getInfo(),a=xe.EIP_1271_INTERFACE.encodeFunctionData("isValidSignature",[e,t]),r={call:Be.RPC_CALLS.eth_call,params:[{to:s.safeAddress,data:a},"latest"]};try{return(await this.communicator.send(He.Methods.rpcCall,r)).data.slice(0,10).toLowerCase()===xe.MAGIC_VALUE}catch(e){return!1}}async check1271SignatureBytes(e,t="0x"){const s=await this.getInfo(),a=je.ethers.utils.arrayify(e),r=xe.EIP_1271_BYTES_INTERFACE.encodeFunctionData("isValidSignature",[a,t]),n={call:Be.RPC_CALLS.eth_call,params:[{to:s.safeAddress,data:r},"latest"]};try{return(await this.communicator.send(He.Methods.rpcCall,n)).data.slice(0,10).toLowerCase()===xe.MAGIC_VALUE_BYTES}catch(e){return!1}}calculateMessageHash(e){return je.ethers.utils.hashMessage(e)}calculateTypedMessageHash(e){return je.ethers.utils._TypedDataEncoder.hash(e.domain,e.types,e.message)}async getOffChainSignature(e){return(await this.communicator.send(He.Methods.getOffChainSignature,e)).data}async isMessageSigned(e,t="0x"){let s;if("string"==typeof e&&(s=async()=>{const s=this.calculateMessageHash(e);return await this.isMessageHashSigned(s,t)}),(0,ke.isObjectEIP712TypedData)(e)&&(s=async()=>{const s=this.calculateTypedMessageHash(e);return await this.isMessageHashSigned(s,t)}),s){return await s()}throw new Error("Invalid message type")}async isMessageHashSigned(e,t="0x"){const s=[this.check1271Signature.bind(this),this.check1271SignatureBytes.bind(this)];for(const a of s){if(await a(e,t))return!0}return!1}async getEnvironmentInfo(){return(await this.communicator.send(He.Methods.getEnvironmentInfo,void 0)).data}async requestAddressBook(){return(await this.communicator.send(He.Methods.requestAddressBook,void 0)).data}}Le([(0,qe.default)()],Ue.prototype,"requestAddressBook",null),me.Safe=Ue;var Ge=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(P,"__esModule",{value:!0});const $e=Ge(M),Fe=G,Ve=he,We=me,Ke=be;P.default=class{constructor(e={}){const{allowedDomains:t=null,debug:s=!1}=e;this.communicator=new $e.default(t,s),this.eth=new Ve.Eth(this.communicator),this.txs=new Fe.TXs(this.communicator),this.safe=new We.Safe(this.communicator),this.wallet=new Ke.Wallet(this.communicator)}},function(t){var s=e&&e.__createBinding||(Object.create?function(e,t,s,a){void 0===a&&(a=s);var r=Object.getOwnPropertyDescriptor(t,s);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[s]}}),Object.defineProperty(e,a,r)}:function(e,t,s,a){void 0===a&&(a=s),e[a]=t[s]}),a=e&&e.__exportStar||function(e,t){for(var a in e)"default"===a||Object.prototype.hasOwnProperty.call(t,a)||s(t,e,a)},r=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.getSDKVersion=void 0;const n=r(P);t.default=n.default,a(P,t),a($,t),a(U,t),a(O,t);var i=C;Object.defineProperty(t,"getSDKVersion",{enumerable:!0,get:function(){return i.getSDKVersion}})}(A);var Qe=s(A),Xe={},Ye={},Je={};Object.defineProperty(Je,"__esModule",{value:!0}),Je.getLowerCase=void 0,Je.getLowerCase=function(e){return e?e.toLowerCase():e},Object.defineProperty(Ye,"__esModule",{value:!0}),Ye.SafeAppProvider=void 0;const ze=b,Ze=Je;class et extends ze.EventEmitter{constructor(e,t){super(),this.submittedTxs=new Map,this.safe=e,this.sdk=t}async connect(){this.emit("connect",{chainId:this.chainId})}async disconnect(){}get chainId(){return this.safe.chainId}async request(e){const{method:t,params:s=[]}=e;switch(t){case"eth_accounts":return[this.safe.safeAddress];case"net_version":case"eth_chainId":return`0x${this.chainId.toString(16)}`;case"personal_sign":{const[e,t]=s;if(this.safe.safeAddress.toLowerCase()!==t.toLowerCase())throw new Error("The address or message hash is invalid");return await this.sdk.txs.signMessage(e),"0x"}case"eth_sign":{const[e,t]=s;if(this.safe.safeAddress.toLowerCase()!==e.toLowerCase()||!t.startsWith("0x"))throw new Error("The address or message hash is invalid");return await this.sdk.txs.signMessage(t),"0x"}case"eth_signTypedData":case"eth_signTypedData_v4":{const[e,t]=s,a="string"==typeof t?JSON.parse(t):t;if(this.safe.safeAddress.toLowerCase()!==e.toLowerCase())throw new Error("The address is invalid");return await this.sdk.txs.signTypedMessage(a),"0x"}case"eth_sendTransaction":const t=Object.assign({value:"0",data:"0x"},s[0]);"string"==typeof t.gas&&t.gas.startsWith("0x")&&(t.gas=parseInt(t.gas,16));const a=await this.sdk.txs.send({txs:[t],params:{safeTxGas:t.gas}});return this.submittedTxs.set(a.safeTxHash,{from:this.safe.safeAddress,hash:a.safeTxHash,gas:0,gasPrice:"0x00",nonce:0,input:t.data,value:t.value,to:t.to,blockHash:null,blockNumber:null,transactionIndex:null}),a.safeTxHash;case"eth_blockNumber":return(await this.sdk.eth.getBlockByNumber(["latest"])).number;case"eth_getBalance":return this.sdk.eth.getBalance([(0,Ze.getLowerCase)(s[0]),s[1]]);case"eth_getCode":return this.sdk.eth.getCode([(0,Ze.getLowerCase)(s[0]),s[1]]);case"eth_getTransactionCount":return this.sdk.eth.getTransactionCount([(0,Ze.getLowerCase)(s[0]),s[1]]);case"eth_getStorageAt":return this.sdk.eth.getStorageAt([(0,Ze.getLowerCase)(s[0]),s[1],s[2]]);case"eth_getBlockByNumber":return this.sdk.eth.getBlockByNumber([s[0],s[1]]);case"eth_getBlockByHash":return this.sdk.eth.getBlockByHash([s[0],s[1]]);case"eth_getTransactionByHash":let r=s[0];try{r=(await this.sdk.txs.getBySafeTxHash(r)).txHash||r}catch(e){}return this.submittedTxs.has(r)?this.submittedTxs.get(r):this.sdk.eth.getTransactionByHash([r]).then((e=>(e&&(e.hash=s[0]),e)));case"eth_getTransactionReceipt":{let e=s[0];try{e=(await this.sdk.txs.getBySafeTxHash(e)).txHash||e}catch(e){}return this.sdk.eth.getTransactionReceipt([e]).then((e=>(e&&(e.transactionHash=s[0]),e)))}case"eth_estimateGas":return this.sdk.eth.getEstimateGas(s[0]);case"eth_call":return this.sdk.eth.call([s[0],s[1]]);case"eth_getLogs":return this.sdk.eth.getPastLogs([s[0]]);case"eth_gasPrice":return this.sdk.eth.getGasPrice();case"wallet_getPermissions":return this.sdk.wallet.getPermissions();case"wallet_requestPermissions":return this.sdk.wallet.requestPermissions(s[0]);case"safe_setSettings":return this.sdk.eth.setSafeSettings([s[0]]);default:throw Error(`"${e.method}" not implemented`)}}send(e,t){e||t("Undefined request"),this.request(e).then((s=>t(null,{jsonrpc:"2.0",id:e.id,result:s}))).catch((e=>t(e,null)))}}let tt,st;function at(){return a(this,void 0,void 0,(function*(){return st||(st=new Qe),void 0===tt&&(tt=yield Promise.race([st.safe.getInfo(),new Promise((e=>setTimeout(e,200)))])),tt}))}function rt(){return a(this,void 0,void 0,(function*(){return!!(yield at())}))}function nt(e){return a(this,void 0,void 0,(function*(){const t=yield at();if(!t)throw Error("Could not load Safe information");const s=new Xe.SafeAppProvider(t,st);return s.on("connect",e.connect),s.on("disconnect",e.disconnect),s.on("accountsChanged",e.accountsChanged),s.on("chainChanged",e.chainChanged),s.on("message",e.message),r(s)}))}Ye.SafeAppProvider=et,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.SafeAppProvider=void 0;var t=Ye;Object.defineProperty(e,"SafeAppProvider",{enumerable:!0,get:function(){return t.SafeAppProvider}})}(Xe);var it={},ot={},dt={};Object.defineProperty(dt,"__esModule",{value:!0}),dt.getTxServiceBaseUrl=void 0,dt.getTxServiceBaseUrl=function(e){return`${e}/api`};var ct={},ut={exports:{}};!function(t,s){var a=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==e)return e;throw new Error("unable to locate global object")}();t.exports=s=a.fetch,a.fetch&&(s.default=a.fetch.bind(a)),s.Headers=a.Headers,s.Request=a.Request,s.Response=a.Response}(ut,ut.exports),function(t){var s=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.sendRequest=t.HttpMethod=void 0;const a=s(ut.exports);var r;(r=t.HttpMethod||(t.HttpMethod={})).Get="get",r.Post="post",r.Delete="delete",t.sendRequest=async function({url:e,method:t,body:s}){const r=await(0,a.default)(e,{method:t,headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(s)});let n;try{n=await r.json()}catch(e){if(!r.ok)throw new Error(r.statusText)}if(r.ok)return n;if(n.data)throw new Error(n.data);if(n.detail)throw new Error(n.detail);if(n.message)throw new Error(n.message);if(n.nonFieldErrors)throw new Error(n.nonFieldErrors);if(n.delegate)throw new Error(n.delegate);if(n.safe)throw new Error(n.safe);if(n.delegator)throw new Error(n.delegator);throw new Error(r.statusText)}}(ct);var lt,ft,ht=e&&e.__classPrivateFieldSet||function(e,t,s,a,r){if("m"===a)throw new TypeError("Private method is not writable");if("a"===a&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===a?r.call(e,s):r?r.value=s:t.set(e,s),s},gt=e&&e.__classPrivateFieldGet||function(e,t,s,a){if("a"===s&&!a)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!a:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===s?a:"a"===s?a.call(e):a?a.value:t.get(e)};Object.defineProperty(ot,"__esModule",{value:!0});const pt=dt,_t=ct;lt=new WeakMap,ft=new WeakMap,ot.default=class{constructor({txServiceUrl:e,ethAdapter:t}){lt.set(this,void 0),ft.set(this,void 0),ht(this,lt,(0,pt.getTxServiceBaseUrl)(e),"f"),ht(this,ft,t,"f")}async getServiceInfo(){return(0,_t.sendRequest)({url:`${gt(this,lt,"f")}/v1/about`,method:_t.HttpMethod.Get})}async getServiceMasterCopiesInfo(){return(0,_t.sendRequest)({url:`${gt(this,lt,"f")}/v1/about/master-copies`,method:_t.HttpMethod.Get})}async decodeData(e){if(""===e)throw new Error("Invalid data");return(0,_t.sendRequest)({url:`${gt(this,lt,"f")}/v1/data-decoder/`,method:_t.HttpMethod.Post,body:{data:e}})}async getSafesByOwner(e){if(""===e)throw new Error("Invalid owner address");const{address:t}=await gt(this,ft,"f").getEip3770Address(e);return(0,_t.sendRequest)({url:`${gt(this,lt,"f")}/v1/owners/${t}/safes/`,method:_t.HttpMethod.Get})}async getSafesByModule(e){if(""===e)throw new Error("Invalid module address");const{address:t}=await gt(this,ft,"f").getEip3770Address(e);return(0,_t.sendRequest)({url:`${gt(this,lt,"f")}/v1/modules/${t}/safes/`,method:_t.HttpMethod.Get})}async getTransaction(e){if(""===e)throw new Error("Invalid safeTxHash");return(0,_t.sendRequest)({url:`${gt(this,lt,"f")}/v1/multisig-transactions/${e}/`,method:_t.HttpMethod.Get})}async getTransactionConfirmations(e){if(""===e)throw new Error("Invalid safeTxHash");return(0,_t.sendRequest)({url:`${gt(this,lt,"f")}/v1/multisig-transactions/${e}/confirmations/`,method:_t.HttpMethod.Get})}async confirmTransaction(e,t){if(""===e)throw new Error("Invalid safeTxHash");if(""===t)throw new Error("Invalid signature");return(0,_t.sendRequest)({url:`${gt(this,lt,"f")}/v1/multisig-transactions/${e}/confirmations/`,method:_t.HttpMethod.Post,body:{signature:t}})}async getSafeInfo(e){if(""===e)throw new Error("Invalid Safe address");const{address:t}=await gt(this,ft,"f").getEip3770Address(e);return(0,_t.sendRequest)({url:`${gt(this,lt,"f")}/v1/safes/${t}/`,method:_t.HttpMethod.Get})}async getSafeDelegates({safeAddress:e,delegateAddress:t,delegatorAddress:s,label:a,limit:r,offset:n}){const i=new URL(`${gt(this,lt,"f")}/v1/delegates`);if(e){const{address:t}=await gt(this,ft,"f").getEip3770Address(e);i.searchParams.set("safe",t)}if(t){const{address:e}=await gt(this,ft,"f").getEip3770Address(t);i.searchParams.set("delegate",e)}if(s){const{address:e}=await gt(this,ft,"f").getEip3770Address(s);i.searchParams.set("delegator",e)}return a&&i.searchParams.set("label",a),r&&i.searchParams.set("limit",r),n&&i.searchParams.set("offset",n),(0,_t.sendRequest)({url:i.toString(),method:_t.HttpMethod.Get})}async addSafeDelegate({safeAddress:e,delegateAddress:t,delegatorAddress:s,label:a,signer:r}){if(""===t)throw new Error("Invalid Safe delegate address");if(""===s)throw new Error("Invalid Safe delegator address");if(""===a)throw new Error("Invalid label");const{address:n}=await gt(this,ft,"f").getEip3770Address(t),{address:i}=await gt(this,ft,"f").getEip3770Address(s),o=n+Math.floor(Date.now()/1e3/3600),d=await r.signMessage(o),c={safe:e?(await gt(this,ft,"f").getEip3770Address(e)).address:null,delegate:n,delegator:i,label:a,signature:d};return(0,_t.sendRequest)({url:`${gt(this,lt,"f")}/v1/delegates/`,method:_t.HttpMethod.Post,body:c})}async removeSafeDelegate({delegateAddress:e,delegatorAddress:t,signer:s}){if(""===e)throw new Error("Invalid Safe delegate address");if(""===t)throw new Error("Invalid Safe delegator address");const{address:a}=await gt(this,ft,"f").getEip3770Address(e),{address:r}=await gt(this,ft,"f").getEip3770Address(t),n=a+Math.floor(Date.now()/1e3/3600),i=await s.signMessage(n);return(0,_t.sendRequest)({url:`${gt(this,lt,"f")}/v1/delegates/${a}`,method:_t.HttpMethod.Delete,body:{delegate:a,delegator:r,signature:i}})}async getSafeCreationInfo(e){if(""===e)throw new Error("Invalid Safe address");const{address:t}=await gt(this,ft,"f").getEip3770Address(e);return(0,_t.sendRequest)({url:`${gt(this,lt,"f")}/v1/safes/${t}/creation/`,method:_t.HttpMethod.Get})}async estimateSafeTransaction(e,t){if(""===e)throw new Error("Invalid Safe address");const{address:s}=await gt(this,ft,"f").getEip3770Address(e);return(0,_t.sendRequest)({url:`${gt(this,lt,"f")}/v1/safes/${s}/multisig-transactions/estimations/`,method:_t.HttpMethod.Post,body:t})}async proposeTransaction({safeAddress:e,safeTransactionData:t,safeTxHash:s,senderAddress:a,senderSignature:r,origin:n}){if(""===e)throw new Error("Invalid Safe address");const{address:i}=await gt(this,ft,"f").getEip3770Address(e),{address:o}=await gt(this,ft,"f").getEip3770Address(a);if(""===s)throw new Error("Invalid safeTxHash");return(0,_t.sendRequest)({url:`${gt(this,lt,"f")}/v1/safes/${i}/multisig-transactions/`,method:_t.HttpMethod.Post,body:{...t,contractTransactionHash:s,sender:o,signature:r,origin:n}})}async getIncomingTransactions(e){if(""===e)throw new Error("Invalid Safe address");const{address:t}=await gt(this,ft,"f").getEip3770Address(e);return(0,_t.sendRequest)({url:`${gt(this,lt,"f")}/v1/safes/${t}/incoming-transfers?executed=true`,method:_t.HttpMethod.Get})}async getModuleTransactions(e){if(""===e)throw new Error("Invalid Safe address");const{address:t}=await gt(this,ft,"f").getEip3770Address(e);return(0,_t.sendRequest)({url:`${gt(this,lt,"f")}/v1/safes/${t}/module-transactions/`,method:_t.HttpMethod.Get})}async getMultisigTransactions(e){if(""===e)throw new Error("Invalid Safe address");const{address:t}=await gt(this,ft,"f").getEip3770Address(e);return(0,_t.sendRequest)({url:`${gt(this,lt,"f")}/v1/safes/${t}/multisig-transactions/`,method:_t.HttpMethod.Get})}async getPendingTransactions(e,t){if(""===e)throw new Error("Invalid Safe address");const{address:s}=await gt(this,ft,"f").getEip3770Address(e),a=t||(await this.getSafeInfo(s)).nonce;return(0,_t.sendRequest)({url:`${gt(this,lt,"f")}/v1/safes/${s}/multisig-transactions/?executed=false&nonce__gte=${a}`,method:_t.HttpMethod.Get})}async getAllTransactions(e,t){var s,a,r;if(""===e)throw new Error("Invalid Safe address");const{address:n}=await gt(this,ft,"f").getEip3770Address(e),i=new URL(`${gt(this,lt,"f")}/v1/safes/${n}/all-transactions/`),o=(null===(s=null==t?void 0:t.trusted)||void 0===s?void 0:s.toString())||"true";i.searchParams.set("trusted",o);const d=(null===(a=null==t?void 0:t.queued)||void 0===a?void 0:a.toString())||"true";i.searchParams.set("queued",d);const c=(null===(r=null==t?void 0:t.executed)||void 0===r?void 0:r.toString())||"false";return i.searchParams.set("executed",c),(0,_t.sendRequest)({url:i.toString(),method:_t.HttpMethod.Get})}async getNextNonce(e){if(""===e)throw new Error("Invalid Safe address");const{address:t}=await gt(this,ft,"f").getEip3770Address(e),s=await this.getPendingTransactions(t);if(s.results.length>0){const e=s.results.map((e=>e.nonce));return Math.max(...e)+1}return(await this.getSafeInfo(t)).nonce}async getTokenList(){return(0,_t.sendRequest)({url:`${gt(this,lt,"f")}/v1/tokens/`,method:_t.HttpMethod.Get})}async getToken(e){if(""===e)throw new Error("Invalid token address");const{address:t}=await gt(this,ft,"f").getEip3770Address(e);return(0,_t.sendRequest)({url:`${gt(this,lt,"f")}/v1/tokens/${t}/`,method:_t.HttpMethod.Get})}};var Et={};Object.defineProperty(Et,"__esModule",{value:!0}),function(t){var s=e&&e.__createBinding||(Object.create?function(e,t,s,a){void 0===a&&(a=s);var r=Object.getOwnPropertyDescriptor(t,s);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[s]}}),Object.defineProperty(e,a,r)}:function(e,t,s,a){void 0===a&&(a=s),e[a]=t[s]}),a=e&&e.__exportStar||function(e,t){for(var a in e)"default"===a||Object.prototype.hasOwnProperty.call(t,a)||s(t,e,a)},r=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const n=r(ot);a(Et,t),t.default=n.default}(it);var mt=s(it);const vt={1:"https://safe-transaction-mainnet.safe.global/",5:"https://safe-transaction-goerli.safe.global/",42161:"https://safe-transaction-arbitrum.safe.global/",43114:"https://safe-transaction-avalanche.safe.global/",1313161554:"https://safe-transaction-aurora.safe.global/",56:"https://safe-transaction-bsc.safe.global/",10:"https://safe-transaction-optimism.safe.global/",137:"https://safe-transaction-polygon.safe.global/"};let Tt;function yt(e){return a(this,void 0,void 0,(function*(){if((null==Tt?void 0:Tt.chainId)===e)return Tt.safeService;if(!n.getState().provider)throw new Error("provider is undefined");const t=function(){return{getEip3770Address:e=>a(this,void 0,void 0,(function*(){const{address:t,prefix:s}=function(e){const t=e.split(":"),s=t.length>1?t[1]:t[0];return{prefix:t.length>1?t[0]:"",address:s}}(e);return{address:t,prefix:s}}))}}(),s=vt[e];if(!s)return;const r=new mt({txServiceUrl:s,ethAdapter:t});return Tt={safeService:r,chainId:e},Tt.safeService}))}function wt(e,t){return a(this,void 0,void 0,(function*(){if(!t)return!1;const s=yield yt(e);if(!s)return!1;try{return!!(yield s.getSafeInfo(t))}catch(e){return console.error(e),!1}}))}function St(e,t,s){return a(this,void 0,void 0,(function*(){const a=yield yt(e);if(!a)return console.error(`chainId: ${e} is not supported safe`),s;if(s!==t)return s;const r=yield a.getMultisigTransactions(s),[n]=r.results;return n.safeTxHash}))}function It(e,t,s){return a(this,void 0,void 0,(function*(){const a=yield yt(e);if(!a)throw new Error(`chainId: ${e} is not supported safe`);try{const{results:e}=yield a.getMultisigTransactions(s),r=e.find((e=>e.safeTxHash.toLocaleLowerCase()===t.toLocaleLowerCase()));if(!r)return null;if(e.some((e=>!(e.nonce!==r.nonce||e.safeTxHash.toLocaleLowerCase()===t.toLocaleLowerCase()||!e.isExecuted||!e.isSuccessful))))return"rejected";if(null===r.isExecuted||null===r.isSuccessful)return null;return{status:r.isExecuted&&r.isSuccessful||!1,transactionHash:r.transactionHash,blockNumber:r.blockNumber||null}}catch(e){throw console.error(e),new Error(`safeTxHash: ${t} is not valid.`)}}))}function bt(e,t,s){const a={1:"eth",5:"gor",137:"matic",56:"bnb",42161:"arb1",10:"oeth",43114:"avax",1313161554:"aurora"}[t];if(!a)throw new Error(`Not Supported network: ${t}`);return`https://app.safe.global/transactions/tx?id=multisig_${s}_${e}&safe=${a}%3A${s}`}export{nt as default,wt as getAccountIsSafe,at as getConnectedSafe,rt as getIsSafe,bt as getSafeHashDetailUrl,St as getSafeTxHash,It as getSafeTxStatus};
1
+ import{c as e,g as t,b as s,_ as a,d as r,u as n}from"./index-6e0697ab.js";import{b as i}from"./browser-ponyfill-0d656c3b.js";import{e as o,W as d,F as c,l as u,u as l,w as f,v as h,a as g}from"./ethers-20b88c06.js";import{Signer as p,VoidSigner as _}from"@ethersproject/abstract-signer";import*as E from"@ethersproject/providers";import{getDefaultProvider as m}from"@ethersproject/providers";import{BaseContract as v,Contract as T,ContractFactory as y}from"@ethersproject/contracts";import{B as w,E as S}from"./id-5fb9d202.js";import*as I from"@ethersproject/constants";import b from"events";import"zustand";import"@ethersproject/address";import"@ethersproject/properties";import"@ethersproject/transactions";import"@ethersproject/bytes";import"@ethersproject/abstract-provider";import"./index-d1fdba35.js";import"./__node-resolve_empty-7cc52421.js";import"./hash-b468659c.js";import"./inherits_browser-51bb8c3c.js";import"@ethersproject/json-wallets";import"./interface-a6f33bb4.js";import"./index-53bc60c6.js";var A={},P={},M={},O={},C={},R={name:"@safe-global/safe-apps-sdk",version:"7.10.1",description:"SDK developed to integrate third-party apps with Safe app.",main:"dist/src/index.js",typings:"dist/src/index.d.ts",_files:["dist/**/*","src/**/*","CHANGELOG.md","README.md"],keywords:["Safe","sdk","apps"],scripts:{test:"jest","format-dist":"sed -i '' 's/\"files\":/\"_files\":/' dist/package.json",build:"yarn rimraf dist && tsc && yarn format-dist"},author:"Safe (https://safe.global)",license:"MIT",dependencies:{"@safe-global/safe-gateway-typescript-sdk":"^3.5.3",ethers:"^5.7.2"},devDependencies:{rimraf:"^3.0.2"},repository:{type:"git",url:"git+https://github.com/safe-global/safe-apps-sdk.git"},bugs:{url:"https://github.com/safe-global/safe-apps-sdk/issues"},homepage:"https://github.com/safe-global/safe-apps-sdk#readme",publishConfig:{access:"public"}},N=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(C,"__esModule",{value:!0}),C.getSDKVersion=void 0;const L=N(R);C.getSDKVersion=()=>L.default.version.split("-")[0];var D={};Object.defineProperty(D,"__esModule",{value:!0}),D.generateRequestId=void 0;const j=e=>e.toString(16).padStart(2,"0");D.generateRequestId=()=>"undefined"!=typeof window?(e=>{const t=new Uint8Array((e||40)/2);return window.crypto.getRandomValues(t),Array.from(t,j).join("")})(10):(new Date).getTime().toString(36),Object.defineProperty(O,"__esModule",{value:!0}),O.MessageFormatter=void 0;const x=C,H=D;class B{}O.MessageFormatter=B,B.makeRequest=(e,t)=>({id:(0,H.generateRequestId)(),method:e,params:t,env:{sdkVersion:(0,x.getSDKVersion)()}}),B.makeResponse=(e,t,s)=>({id:e,success:!0,version:s,data:t}),B.makeErrorResponse=(e,t,s)=>({id:e,success:!1,error:t,version:s});var k,q,U={};k=U,Object.defineProperty(k,"__esModule",{value:!0}),k.RestrictedMethods=k.Methods=void 0,(q=k.Methods||(k.Methods={})).sendTransactions="sendTransactions",q.rpcCall="rpcCall",q.getChainInfo="getChainInfo",q.getSafeInfo="getSafeInfo",q.getTxBySafeTxHash="getTxBySafeTxHash",q.getSafeBalances="getSafeBalances",q.signMessage="signMessage",q.signTypedMessage="signTypedMessage",q.getEnvironmentInfo="getEnvironmentInfo",q.getOffChainSignature="getOffChainSignature",q.requestAddressBook="requestAddressBook",q.wallet_getPermissions="wallet_getPermissions",q.wallet_requestPermissions="wallet_requestPermissions",(k.RestrictedMethods||(k.RestrictedMethods={})).requestAddressBook="requestAddressBook",function(t){var s=e&&e.__createBinding||(Object.create?function(e,t,s,a){void 0===a&&(a=s);var r=Object.getOwnPropertyDescriptor(t,s);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[s]}}),Object.defineProperty(e,a,r)}:function(e,t,s,a){void 0===a&&(a=s),e[a]=t[s]}),a=e&&e.__exportStar||function(e,t){for(var a in e)"default"===a||Object.prototype.hasOwnProperty.call(t,a)||s(t,e,a)};Object.defineProperty(t,"__esModule",{value:!0});const r=O;t.default=class{constructor(e=null,t=!1){this.allowedOrigins=null,this.callbacks=new Map,this.debugMode=!1,this.isServer="undefined"==typeof window,this.isValidMessage=({origin:e,data:t,source:s})=>{const a=!t,r=!this.isServer&&s===window.parent,n=(void 0!==t.version&&parseInt(t.version.split(".")[0]))>=1;let i=!0;return Array.isArray(this.allowedOrigins)&&(i=void 0!==this.allowedOrigins.find((t=>t.test(e)))),!a&&r&&n&&i},this.logIncomingMessage=e=>{console.info(`Safe Apps SDK v1: A message was received from origin ${e.origin}. `,e.data)},this.onParentMessage=e=>{this.isValidMessage(e)&&(this.debugMode&&this.logIncomingMessage(e),this.handleIncomingMessage(e.data))},this.handleIncomingMessage=e=>{const{id:t}=e,s=this.callbacks.get(t);s&&(s(e),this.callbacks.delete(t))},this.send=(e,t)=>{const s=r.MessageFormatter.makeRequest(e,t);if(this.isServer)throw new Error("Window doesn't exist");return window.parent.postMessage(s,"*"),new Promise(((e,t)=>{this.callbacks.set(s.id,(s=>{s.success?e(s):t(new Error(s.error))}))}))},this.allowedOrigins=e,this.debugMode=t,this.isServer||window.addEventListener("message",this.onParentMessage)}},a(U,t)}(M);var G={},$={},F={};Object.defineProperty(F,"__esModule",{value:!0}),F.isObjectEIP712TypedData=void 0;F.isObjectEIP712TypedData=e=>"object"==typeof e&&null!=e&&"domain"in e&&"types"in e&&"message"in e;var V={};Object.defineProperty(V,"__esModule",{value:!0});var W={},K={},Q={},X={},Y=e&&e.__awaiter||function(e,t,s,a){return new(s||(s=Promise))((function(r,n){function i(e){try{d(a.next(e))}catch(e){n(e)}}function o(e){try{d(a.throw(e))}catch(e){n(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof s?t:new s((function(e){e(t)}))).then(i,o)}d((a=a.apply(e,t||[])).next())}))},J=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(X,"__esModule",{value:!0}),X.fetchData=X.stringifyQuery=X.insertParams=void 0;const z=J(i.exports);X.insertParams=function(e,t){return t?Object.keys(t).reduce(((e,s)=>function(e,t,s){return e.replace(new RegExp(`\\{${t}\\}`,"g"),s)}(e,s,String(t[s]))),e):e},X.stringifyQuery=function(e){if(!e)return"";const t=new URLSearchParams;Object.keys(e).forEach((s=>{null!=e[s]&&t.append(s,String(e[s]))}));const s=t.toString();return s?`?${s}`:""},X.fetchData=function(e,t){return Y(this,void 0,void 0,(function*(){let s;null!=t&&(s={method:"POST",body:"string"==typeof t?t:JSON.stringify(t),headers:{"Content-Type":"application/json"}});const a=yield(0,z.default)(e,s);let r;try{r=yield a.json()}catch(e){if(a.headers&&"0"!==a.headers.get("content-length"))throw new Error(`Invalid response content: ${a.statusText}`)}if(!a.ok){const e="object"==typeof(n=r)&&null!==n&&"code"in n&&"message"in n?`${r.code}: ${r.message}`:a.statusText;throw new Error(e)}var n;return r}))},Object.defineProperty(Q,"__esModule",{value:!0}),Q.getEndpoint=Q.postEndpoint=void 0;const Z=X;function ee(e,t,s,a){return`${e}${(0,Z.insertParams)(t,s)}${(0,Z.stringifyQuery)(a)}`}Q.postEndpoint=function(e,t,s){const a=ee(e,t,null==s?void 0:s.path,null==s?void 0:s.query);return(0,Z.fetchData)(a,null==s?void 0:s.body)},Q.getEndpoint=function(e,t,s,a){if(a)return(0,Z.fetchData)(a);const r=ee(e,t,null==s?void 0:s.path,null==s?void 0:s.query);return(0,Z.fetchData)(r)};var te={};Object.defineProperty(te,"__esModule",{value:!0}),te.DEFAULT_BASE_URL=void 0,te.DEFAULT_BASE_URL="https://safe-client.safe.global";var se={};!function(e){var t;Object.defineProperty(e,"__esModule",{value:!0}),e.ImplementationVersionState=void 0,(t=e.ImplementationVersionState||(e.ImplementationVersionState={})).UP_TO_DATE="UP_TO_DATE",t.OUTDATED="OUTDATED",t.UNKNOWN="UNKNOWN"}(se);var ae={};!function(e){var t,s;Object.defineProperty(e,"__esModule",{value:!0}),e.SafeAppSocialPlatforms=e.SafeAppFeatures=e.SafeAppAccessPolicyTypes=void 0,(t=e.SafeAppAccessPolicyTypes||(e.SafeAppAccessPolicyTypes={})).NoRestrictions="NO_RESTRICTIONS",t.DomainAllowlist="DOMAIN_ALLOWLIST",(e.SafeAppFeatures||(e.SafeAppFeatures={})).BATCHED_TRANSACTIONS="BATCHED_TRANSACTIONS",(s=e.SafeAppSocialPlatforms||(e.SafeAppSocialPlatforms={})).TWITTER="TWITTER",s.GITHUB="GITHUB",s.DISCORD="DISCORD"}(ae);var re={};!function(e){var t,s,a,r,n,i,o,d,c,u;Object.defineProperty(e,"__esModule",{value:!0}),e.LabelValue=e.DetailedExecutionInfoType=e.TransactionListItemType=e.ConflictType=e.TransactionInfoType=e.SettingsInfoType=e.TransactionTokenType=e.TransferDirection=e.TransactionStatus=e.Operation=void 0,(t=e.Operation||(e.Operation={}))[t.CALL=0]="CALL",t[t.DELEGATE=1]="DELEGATE",(s=e.TransactionStatus||(e.TransactionStatus={})).AWAITING_CONFIRMATIONS="AWAITING_CONFIRMATIONS",s.AWAITING_EXECUTION="AWAITING_EXECUTION",s.CANCELLED="CANCELLED",s.FAILED="FAILED",s.SUCCESS="SUCCESS",(a=e.TransferDirection||(e.TransferDirection={})).INCOMING="INCOMING",a.OUTGOING="OUTGOING",a.UNKNOWN="UNKNOWN",(r=e.TransactionTokenType||(e.TransactionTokenType={})).ERC20="ERC20",r.ERC721="ERC721",r.NATIVE_COIN="NATIVE_COIN",(n=e.SettingsInfoType||(e.SettingsInfoType={})).SET_FALLBACK_HANDLER="SET_FALLBACK_HANDLER",n.ADD_OWNER="ADD_OWNER",n.REMOVE_OWNER="REMOVE_OWNER",n.SWAP_OWNER="SWAP_OWNER",n.CHANGE_THRESHOLD="CHANGE_THRESHOLD",n.CHANGE_IMPLEMENTATION="CHANGE_IMPLEMENTATION",n.ENABLE_MODULE="ENABLE_MODULE",n.DISABLE_MODULE="DISABLE_MODULE",n.SET_GUARD="SET_GUARD",n.DELETE_GUARD="DELETE_GUARD",(i=e.TransactionInfoType||(e.TransactionInfoType={})).TRANSFER="Transfer",i.SETTINGS_CHANGE="SettingsChange",i.CUSTOM="Custom",i.CREATION="Creation",(o=e.ConflictType||(e.ConflictType={})).NONE="None",o.HAS_NEXT="HasNext",o.END="End",(d=e.TransactionListItemType||(e.TransactionListItemType={})).TRANSACTION="TRANSACTION",d.LABEL="LABEL",d.CONFLICT_HEADER="CONFLICT_HEADER",d.DATE_LABEL="DATE_LABEL",(c=e.DetailedExecutionInfoType||(e.DetailedExecutionInfoType={})).MULTISIG="MULTISIG",c.MODULE="MODULE",(u=e.LabelValue||(e.LabelValue={})).Queued="Queued",u.Next="Next"}(re);var ne={};!function(e){var t,s,a;Object.defineProperty(e,"__esModule",{value:!0}),e.FEATURES=e.GAS_PRICE_TYPE=e.RPC_AUTHENTICATION=void 0,(t=e.RPC_AUTHENTICATION||(e.RPC_AUTHENTICATION={})).API_KEY_PATH="API_KEY_PATH",t.NO_AUTHENTICATION="NO_AUTHENTICATION",t.UNKNOWN="UNKNOWN",(s=e.GAS_PRICE_TYPE||(e.GAS_PRICE_TYPE={})).ORACLE="ORACLE",s.FIXED="FIXED",s.UNKNOWN="UNKNOWN",(a=e.FEATURES||(e.FEATURES={})).ERC721="ERC721",a.SAFE_APPS="SAFE_APPS",a.CONTRACT_INTERACTION="CONTRACT_INTERACTION",a.DOMAIN_LOOKUP="DOMAIN_LOOKUP",a.SPENDING_LIMIT="SPENDING_LIMIT",a.EIP1559="EIP1559",a.SAFE_TX_GAS_OPTIONAL="SAFE_TX_GAS_OPTIONAL",a.TX_SIMULATION="TX_SIMULATION",a.EIP1271="EIP1271"}(ne);var ie={};!function(e){var t;Object.defineProperty(e,"__esModule",{value:!0}),e.TokenType=void 0,(t=e.TokenType||(e.TokenType={})).ERC20="ERC20",t.ERC721="ERC721",t.NATIVE_TOKEN="NATIVE_TOKEN"}(ie);var oe={};Object.defineProperty(oe,"__esModule",{value:!0});var de={};Object.defineProperty(de,"__esModule",{value:!0});var ce={};!function(e){var t,s;Object.defineProperty(e,"__esModule",{value:!0}),e.SafeMessageStatus=e.SafeMessageListItemType=void 0,(t=e.SafeMessageListItemType||(e.SafeMessageListItemType={})).DATE_LABEL="DATE_LABEL",t.MESSAGE="MESSAGE",(s=e.SafeMessageStatus||(e.SafeMessageStatus={})).NEEDS_CONFIRMATION="NEEDS_CONFIRMATION",s.CONFIRMED="CONFIRMED"}(ce),function(t){var s=e&&e.__createBinding||(Object.create?function(e,t,s,a){void 0===a&&(a=s);var r=Object.getOwnPropertyDescriptor(t,s);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[s]}}),Object.defineProperty(e,a,r)}:function(e,t,s,a){void 0===a&&(a=s),e[a]=t[s]}),a=e&&e.__exportStar||function(e,t){for(var a in e)"default"===a||Object.prototype.hasOwnProperty.call(t,a)||s(t,e,a)};Object.defineProperty(t,"__esModule",{value:!0}),t.confirmSafeMessage=t.proposeSafeMessage=t.getSafeMessage=t.getSafeMessages=t.getDecodedData=t.getMasterCopies=t.getSafeApps=t.getChainConfig=t.getChainsConfig=t.proposeTransaction=t.postSafeGasEstimation=t.getTransactionDetails=t.getTransactionQueue=t.getTransactionHistory=t.getCollectiblesPage=t.getCollectibles=t.getOwnedSafes=t.getFiatCurrencies=t.getBalances=t.getMultisigTransactions=t.getModuleTransactions=t.getIncomingTransfers=t.getSafeInfo=t.setBaseUrl=void 0;const r=Q,n=te;a(se,t),a(ae,t),a(re,t),a(ne,t),a(ie,t),a(oe,t),a(de,t),a(ce,t);let i=n.DEFAULT_BASE_URL;t.setBaseUrl=e=>{i=e},t.getSafeInfo=function(e,t){return(0,r.getEndpoint)(i,"/v1/chains/{chainId}/safes/{address}",{path:{chainId:e,address:t}})},t.getIncomingTransfers=function(e,t,s,a){return(0,r.getEndpoint)(i,"/v1/chains/{chainId}/safes/{address}/incoming-transfers/",{path:{chainId:e,address:t},query:s},a)},t.getModuleTransactions=function(e,t,s,a){return(0,r.getEndpoint)(i,"/v1/chains/{chainId}/safes/{address}/module-transactions/",{path:{chainId:e,address:t},query:s},a)},t.getMultisigTransactions=function(e,t,s,a){return(0,r.getEndpoint)(i,"/v1/chains/{chainId}/safes/{address}/multisig-transactions/",{path:{chainId:e,address:t},query:s},a)},t.getBalances=function(e,t,s="usd",a={}){return(0,r.getEndpoint)(i,"/v1/chains/{chainId}/safes/{address}/balances/{currency}",{path:{chainId:e,address:t,currency:s},query:a})},t.getFiatCurrencies=function(){return(0,r.getEndpoint)(i,"/v1/balances/supported-fiat-codes")},t.getOwnedSafes=function(e,t){return(0,r.getEndpoint)(i,"/v1/chains/{chainId}/owners/{address}/safes",{path:{chainId:e,address:t}})},t.getCollectibles=function(e,t,s={}){return(0,r.getEndpoint)(i,"/v1/chains/{chainId}/safes/{address}/collectibles",{path:{chainId:e,address:t},query:s})},t.getCollectiblesPage=function(e,t,s={},a){return(0,r.getEndpoint)(i,"/v2/chains/{chainId}/safes/{address}/collectibles",{path:{chainId:e,address:t},query:s},a)},t.getTransactionHistory=function(e,t,s){return(0,r.getEndpoint)(i,"/v1/chains/{chainId}/safes/{safe_address}/transactions/history",{path:{chainId:e,safe_address:t},query:{}},s)},t.getTransactionQueue=function(e,t,s,a){return(0,r.getEndpoint)(i,"/v1/chains/{chainId}/safes/{safe_address}/transactions/queued",{path:{chainId:e,safe_address:t},query:{trusted:a}},s)},t.getTransactionDetails=function(e,t){return(0,r.getEndpoint)(i,"/v1/chains/{chainId}/transactions/{transactionId}",{path:{chainId:e,transactionId:t}})},t.postSafeGasEstimation=function(e,t,s){return(0,r.postEndpoint)(i,"/v2/chains/{chainId}/safes/{safe_address}/multisig-transactions/estimations",{path:{chainId:e,safe_address:t},body:s})},t.proposeTransaction=function(e,t,s){return(0,r.postEndpoint)(i,"/v1/chains/{chainId}/transactions/{safe_address}/propose",{path:{chainId:e,safe_address:t},body:s})},t.getChainsConfig=function(e){return(0,r.getEndpoint)(i,"/v1/chains",{query:e})},t.getChainConfig=function(e){return(0,r.getEndpoint)(i,"/v1/chains/{chainId}",{path:{chainId:e}})},t.getSafeApps=function(e,t={}){return(0,r.getEndpoint)(i,"/v1/chains/{chainId}/safe-apps",{path:{chainId:e},query:t})},t.getMasterCopies=function(e){return(0,r.getEndpoint)(i,"/v1/chains/{chainId}/about/master-copies",{path:{chainId:e}})},t.getDecodedData=function(e,t){return(0,r.postEndpoint)(i,"/v1/chains/{chainId}/data-decoder",{path:{chainId:e},body:{data:t}})},t.getSafeMessages=function(e,t,s){return(0,r.getEndpoint)(i,"/v1/chains/{chainId}/safes/{safe_address}/messages",{path:{chainId:e,safe_address:t},query:{}},s)},t.getSafeMessage=function(e,t){return(0,r.getEndpoint)(i,"/v1/chains/{chainId}/messages/{message_hash}",{path:{chainId:e,message_hash:t}})},t.proposeSafeMessage=function(e,t,s){return(0,r.postEndpoint)(i,"/v1/chains/{chainId}/safes/{safe_address}/messages",{path:{chainId:e,safe_address:t},body:s})},t.confirmSafeMessage=function(e,t,s){return(0,r.postEndpoint)(i,"/v1/chains/{chainId}/messages/{message_hash}/signatures",{path:{chainId:e,message_hash:t},body:s})}}(K),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.TransferDirection=e.TransactionStatus=e.TokenType=e.Operation=void 0;var t=K;Object.defineProperty(e,"Operation",{enumerable:!0,get:function(){return t.Operation}}),Object.defineProperty(e,"TokenType",{enumerable:!0,get:function(){return t.TokenType}}),Object.defineProperty(e,"TransactionStatus",{enumerable:!0,get:function(){return t.TransactionStatus}}),Object.defineProperty(e,"TransferDirection",{enumerable:!0,get:function(){return t.TransferDirection}})}(W);var ue={};Object.defineProperty(ue,"__esModule",{value:!0}),function(t){var s=e&&e.__createBinding||(Object.create?function(e,t,s,a){void 0===a&&(a=s);var r=Object.getOwnPropertyDescriptor(t,s);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[s]}}),Object.defineProperty(e,a,r)}:function(e,t,s,a){void 0===a&&(a=s),e[a]=t[s]}),a=e&&e.__exportStar||function(e,t){for(var a in e)"default"===a||Object.prototype.hasOwnProperty.call(t,a)||s(t,e,a)};Object.defineProperty(t,"__esModule",{value:!0}),a(F,t),a(V,t),a(W,t),a(ue,t)}($),Object.defineProperty(G,"__esModule",{value:!0}),G.TXs=void 0;const le=U,fe=$;G.TXs=class{constructor(e){this.communicator=e}async getBySafeTxHash(e){if(!e)throw new Error("Invalid safeTxHash");return(await this.communicator.send(le.Methods.getTxBySafeTxHash,{safeTxHash:e})).data}async signMessage(e){const t={message:e};return(await this.communicator.send(le.Methods.signMessage,t)).data}async signTypedMessage(e){if(!(0,fe.isObjectEIP712TypedData)(e))throw new Error("Invalid typed data");return(await this.communicator.send(le.Methods.signTypedMessage,{typedData:e})).data}async send({txs:e,params:t}){if(!e||!e.length)throw new Error("No transactions were passed");const s={txs:e,params:t};return(await this.communicator.send(le.Methods.sendTransactions,s)).data}};var he={},ge={};Object.defineProperty(ge,"__esModule",{value:!0}),ge.RPC_CALLS=void 0,ge.RPC_CALLS={eth_call:"eth_call",eth_gasPrice:"eth_gasPrice",eth_getLogs:"eth_getLogs",eth_getBalance:"eth_getBalance",eth_getCode:"eth_getCode",eth_getBlockByHash:"eth_getBlockByHash",eth_getBlockByNumber:"eth_getBlockByNumber",eth_getStorageAt:"eth_getStorageAt",eth_getTransactionByHash:"eth_getTransactionByHash",eth_getTransactionReceipt:"eth_getTransactionReceipt",eth_getTransactionCount:"eth_getTransactionCount",eth_estimateGas:"eth_estimateGas",safe_setSettings:"safe_setSettings"},Object.defineProperty(he,"__esModule",{value:!0}),he.Eth=void 0;const pe=ge,_e=U,Ee={defaultBlockParam:(e="latest")=>e,returnFullTxObjectParam:(e=!1)=>e,blockNumberToHex:e=>Number.isInteger(e)?`0x${e.toString(16)}`:e};he.Eth=class{constructor(e){this.communicator=e,this.call=this.buildRequest({call:pe.RPC_CALLS.eth_call,formatters:[null,Ee.defaultBlockParam]}),this.getBalance=this.buildRequest({call:pe.RPC_CALLS.eth_getBalance,formatters:[null,Ee.defaultBlockParam]}),this.getCode=this.buildRequest({call:pe.RPC_CALLS.eth_getCode,formatters:[null,Ee.defaultBlockParam]}),this.getStorageAt=this.buildRequest({call:pe.RPC_CALLS.eth_getStorageAt,formatters:[null,Ee.blockNumberToHex,Ee.defaultBlockParam]}),this.getPastLogs=this.buildRequest({call:pe.RPC_CALLS.eth_getLogs}),this.getBlockByHash=this.buildRequest({call:pe.RPC_CALLS.eth_getBlockByHash,formatters:[null,Ee.returnFullTxObjectParam]}),this.getBlockByNumber=this.buildRequest({call:pe.RPC_CALLS.eth_getBlockByNumber,formatters:[Ee.blockNumberToHex,Ee.returnFullTxObjectParam]}),this.getTransactionByHash=this.buildRequest({call:pe.RPC_CALLS.eth_getTransactionByHash}),this.getTransactionReceipt=this.buildRequest({call:pe.RPC_CALLS.eth_getTransactionReceipt}),this.getTransactionCount=this.buildRequest({call:pe.RPC_CALLS.eth_getTransactionCount,formatters:[null,Ee.defaultBlockParam]}),this.getGasPrice=this.buildRequest({call:pe.RPC_CALLS.eth_gasPrice}),this.getEstimateGas=e=>this.buildRequest({call:pe.RPC_CALLS.eth_estimateGas})([e]),this.setSafeSettings=this.buildRequest({call:pe.RPC_CALLS.safe_setSettings})}buildRequest(e){const{call:t,formatters:s}=e;return async e=>{s&&Array.isArray(e)&&s.forEach(((t,s)=>{t&&(e[s]=t(e[s]))}));const a={call:t,params:e||[]};return(await this.communicator.send(_e.Methods.rpcCall,a)).data}}};var me={};try{const e=window;null==e._ethers&&(e._ethers=o)}catch(e){}var ve=t(Object.freeze({__proto__:null,ethers:o,Signer:p,Wallet:d,VoidSigner:_,getDefaultProvider:m,providers:E,BaseContract:v,Contract:T,ContractFactory:y,BigNumber:w,FixedNumber:c,constants:I,get errors(){return S},logger:u,utils:l,wordlists:f,version:h,Wordlist:g})),Te={};Object.defineProperty(Te,"__esModule",{value:!0}),Te.MAGIC_VALUE_BYTES=Te.MAGIC_VALUE=Te.EIP_1271_BYTES_INTERFACE=Te.EIP_1271_INTERFACE=void 0;const ye=ve;Te.MAGIC_VALUE="0x1626ba7e";Te.MAGIC_VALUE_BYTES="0x20c13b0b";const we=new ye.ethers.utils.Interface(["function isValidSignature(bytes32 _dataHash, bytes calldata _signature) external view"]);Te.EIP_1271_INTERFACE=we;const Se=new ye.ethers.utils.Interface(["function isValidSignature(bytes calldata _data, bytes calldata _signature) public view"]);Te.EIP_1271_BYTES_INTERFACE=Se;var Ie={},be={},Ae={};Object.defineProperty(Ae,"__esModule",{value:!0}),Ae.PermissionsError=Ae.PERMISSIONS_REQUEST_REJECTED=void 0,Ae.PERMISSIONS_REQUEST_REJECTED=4001;class Pe extends Error{constructor(e,t,s){super(e),this.code=t,this.data=s,Object.setPrototypeOf(this,Pe.prototype)}}Ae.PermissionsError=Pe,Object.defineProperty(be,"__esModule",{value:!0}),be.Wallet=void 0;const Me=U,Oe=Ae;be.Wallet=class{constructor(e){this.communicator=e}async getPermissions(){return(await this.communicator.send(Me.Methods.wallet_getPermissions,void 0)).data}async requestPermissions(e){if(!this.isPermissionRequestValid(e))throw new Oe.PermissionsError("Permissions request is invalid",Oe.PERMISSIONS_REQUEST_REJECTED);try{return(await this.communicator.send(Me.Methods.wallet_requestPermissions,e)).data}catch(e){throw new Oe.PermissionsError("Permissions rejected",Oe.PERMISSIONS_REQUEST_REJECTED)}}isPermissionRequestValid(e){return e.every((e=>"object"==typeof e&&Object.keys(e).every((e=>!!Object.values(Me.RestrictedMethods).includes(e)))))}},Object.defineProperty(Ie,"__esModule",{value:!0});const Ce=be,Re=Ae,Ne=(e,t)=>t.some((t=>t.parentCapability===e));Ie.default=()=>(e,t,s)=>{const a=s.value;return s.value=async function(){const e=new Ce.Wallet(this.communicator);let s=await e.getPermissions();if(Ne(t,s)||(s=await e.requestPermissions([{[t]:{}}])),!Ne(t,s))throw new Re.PermissionsError("Permissions rejected",Re.PERMISSIONS_REQUEST_REJECTED);return a.apply(this)},s};var Le=e&&e.__decorate||function(e,t,s,a){var r,n=arguments.length,i=n<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,s):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,s,a);else for(var o=e.length-1;o>=0;o--)(r=e[o])&&(i=(n<3?r(i):n>3?r(t,s,i):r(t,s))||i);return n>3&&i&&Object.defineProperty(t,s,i),i},De=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(me,"__esModule",{value:!0}),me.Safe=void 0;const je=ve,xe=Te,He=U,Be=ge,ke=$,qe=De(Ie);class Ue{constructor(e){this.communicator=e}async getChainInfo(){return(await this.communicator.send(He.Methods.getChainInfo,void 0)).data}async getInfo(){return(await this.communicator.send(He.Methods.getSafeInfo,void 0)).data}async experimental_getBalances({currency:e="usd"}={}){return(await this.communicator.send(He.Methods.getSafeBalances,{currency:e})).data}async check1271Signature(e,t="0x"){const s=await this.getInfo(),a=xe.EIP_1271_INTERFACE.encodeFunctionData("isValidSignature",[e,t]),r={call:Be.RPC_CALLS.eth_call,params:[{to:s.safeAddress,data:a},"latest"]};try{return(await this.communicator.send(He.Methods.rpcCall,r)).data.slice(0,10).toLowerCase()===xe.MAGIC_VALUE}catch(e){return!1}}async check1271SignatureBytes(e,t="0x"){const s=await this.getInfo(),a=je.ethers.utils.arrayify(e),r=xe.EIP_1271_BYTES_INTERFACE.encodeFunctionData("isValidSignature",[a,t]),n={call:Be.RPC_CALLS.eth_call,params:[{to:s.safeAddress,data:r},"latest"]};try{return(await this.communicator.send(He.Methods.rpcCall,n)).data.slice(0,10).toLowerCase()===xe.MAGIC_VALUE_BYTES}catch(e){return!1}}calculateMessageHash(e){return je.ethers.utils.hashMessage(e)}calculateTypedMessageHash(e){return je.ethers.utils._TypedDataEncoder.hash(e.domain,e.types,e.message)}async getOffChainSignature(e){return(await this.communicator.send(He.Methods.getOffChainSignature,e)).data}async isMessageSigned(e,t="0x"){let s;if("string"==typeof e&&(s=async()=>{const s=this.calculateMessageHash(e);return await this.isMessageHashSigned(s,t)}),(0,ke.isObjectEIP712TypedData)(e)&&(s=async()=>{const s=this.calculateTypedMessageHash(e);return await this.isMessageHashSigned(s,t)}),s){return await s()}throw new Error("Invalid message type")}async isMessageHashSigned(e,t="0x"){const s=[this.check1271Signature.bind(this),this.check1271SignatureBytes.bind(this)];for(const a of s){if(await a(e,t))return!0}return!1}async getEnvironmentInfo(){return(await this.communicator.send(He.Methods.getEnvironmentInfo,void 0)).data}async requestAddressBook(){return(await this.communicator.send(He.Methods.requestAddressBook,void 0)).data}}Le([(0,qe.default)()],Ue.prototype,"requestAddressBook",null),me.Safe=Ue;var Ge=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(P,"__esModule",{value:!0});const $e=Ge(M),Fe=G,Ve=he,We=me,Ke=be;P.default=class{constructor(e={}){const{allowedDomains:t=null,debug:s=!1}=e;this.communicator=new $e.default(t,s),this.eth=new Ve.Eth(this.communicator),this.txs=new Fe.TXs(this.communicator),this.safe=new We.Safe(this.communicator),this.wallet=new Ke.Wallet(this.communicator)}},function(t){var s=e&&e.__createBinding||(Object.create?function(e,t,s,a){void 0===a&&(a=s);var r=Object.getOwnPropertyDescriptor(t,s);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[s]}}),Object.defineProperty(e,a,r)}:function(e,t,s,a){void 0===a&&(a=s),e[a]=t[s]}),a=e&&e.__exportStar||function(e,t){for(var a in e)"default"===a||Object.prototype.hasOwnProperty.call(t,a)||s(t,e,a)},r=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.getSDKVersion=void 0;const n=r(P);t.default=n.default,a(P,t),a($,t),a(U,t),a(O,t);var i=C;Object.defineProperty(t,"getSDKVersion",{enumerable:!0,get:function(){return i.getSDKVersion}})}(A);var Qe=s(A),Xe={},Ye={},Je={};Object.defineProperty(Je,"__esModule",{value:!0}),Je.getLowerCase=void 0,Je.getLowerCase=function(e){return e?e.toLowerCase():e},Object.defineProperty(Ye,"__esModule",{value:!0}),Ye.SafeAppProvider=void 0;const ze=b,Ze=Je;class et extends ze.EventEmitter{constructor(e,t){super(),this.submittedTxs=new Map,this.safe=e,this.sdk=t}async connect(){this.emit("connect",{chainId:this.chainId})}async disconnect(){}get chainId(){return this.safe.chainId}async request(e){const{method:t,params:s=[]}=e;switch(t){case"eth_accounts":return[this.safe.safeAddress];case"net_version":case"eth_chainId":return`0x${this.chainId.toString(16)}`;case"personal_sign":{const[e,t]=s;if(this.safe.safeAddress.toLowerCase()!==t.toLowerCase())throw new Error("The address or message hash is invalid");return await this.sdk.txs.signMessage(e),"0x"}case"eth_sign":{const[e,t]=s;if(this.safe.safeAddress.toLowerCase()!==e.toLowerCase()||!t.startsWith("0x"))throw new Error("The address or message hash is invalid");return await this.sdk.txs.signMessage(t),"0x"}case"eth_signTypedData":case"eth_signTypedData_v4":{const[e,t]=s,a="string"==typeof t?JSON.parse(t):t;if(this.safe.safeAddress.toLowerCase()!==e.toLowerCase())throw new Error("The address is invalid");return await this.sdk.txs.signTypedMessage(a),"0x"}case"eth_sendTransaction":const t=Object.assign({value:"0",data:"0x"},s[0]);"string"==typeof t.gas&&t.gas.startsWith("0x")&&(t.gas=parseInt(t.gas,16));const a=await this.sdk.txs.send({txs:[t],params:{safeTxGas:t.gas}});return this.submittedTxs.set(a.safeTxHash,{from:this.safe.safeAddress,hash:a.safeTxHash,gas:0,gasPrice:"0x00",nonce:0,input:t.data,value:t.value,to:t.to,blockHash:null,blockNumber:null,transactionIndex:null}),a.safeTxHash;case"eth_blockNumber":return(await this.sdk.eth.getBlockByNumber(["latest"])).number;case"eth_getBalance":return this.sdk.eth.getBalance([(0,Ze.getLowerCase)(s[0]),s[1]]);case"eth_getCode":return this.sdk.eth.getCode([(0,Ze.getLowerCase)(s[0]),s[1]]);case"eth_getTransactionCount":return this.sdk.eth.getTransactionCount([(0,Ze.getLowerCase)(s[0]),s[1]]);case"eth_getStorageAt":return this.sdk.eth.getStorageAt([(0,Ze.getLowerCase)(s[0]),s[1],s[2]]);case"eth_getBlockByNumber":return this.sdk.eth.getBlockByNumber([s[0],s[1]]);case"eth_getBlockByHash":return this.sdk.eth.getBlockByHash([s[0],s[1]]);case"eth_getTransactionByHash":let r=s[0];try{r=(await this.sdk.txs.getBySafeTxHash(r)).txHash||r}catch(e){}return this.submittedTxs.has(r)?this.submittedTxs.get(r):this.sdk.eth.getTransactionByHash([r]).then((e=>(e&&(e.hash=s[0]),e)));case"eth_getTransactionReceipt":{let e=s[0];try{e=(await this.sdk.txs.getBySafeTxHash(e)).txHash||e}catch(e){}return this.sdk.eth.getTransactionReceipt([e]).then((e=>(e&&(e.transactionHash=s[0]),e)))}case"eth_estimateGas":return this.sdk.eth.getEstimateGas(s[0]);case"eth_call":return this.sdk.eth.call([s[0],s[1]]);case"eth_getLogs":return this.sdk.eth.getPastLogs([s[0]]);case"eth_gasPrice":return this.sdk.eth.getGasPrice();case"wallet_getPermissions":return this.sdk.wallet.getPermissions();case"wallet_requestPermissions":return this.sdk.wallet.requestPermissions(s[0]);case"safe_setSettings":return this.sdk.eth.setSafeSettings([s[0]]);default:throw Error(`"${e.method}" not implemented`)}}send(e,t){e||t("Undefined request"),this.request(e).then((s=>t(null,{jsonrpc:"2.0",id:e.id,result:s}))).catch((e=>t(e,null)))}}let tt,st;function at(){return a(this,void 0,void 0,(function*(){return st||(st=new Qe),void 0===tt&&(tt=yield Promise.race([st.safe.getInfo(),new Promise((e=>setTimeout(e,200)))])),tt}))}function rt(){return a(this,void 0,void 0,(function*(){return!!(yield at())}))}function nt(e){return a(this,void 0,void 0,(function*(){const t=yield at();if(!t)throw Error("Could not load Safe information");const s=new Xe.SafeAppProvider(t,st);return s.on("connect",e.connect),s.on("disconnect",e.disconnect),s.on("accountsChanged",e.accountsChanged),s.on("chainChanged",e.chainChanged),s.on("message",e.message),r(s)}))}Ye.SafeAppProvider=et,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.SafeAppProvider=void 0;var t=Ye;Object.defineProperty(e,"SafeAppProvider",{enumerable:!0,get:function(){return t.SafeAppProvider}})}(Xe);var it={},ot={},dt={};Object.defineProperty(dt,"__esModule",{value:!0}),dt.getTxServiceBaseUrl=void 0,dt.getTxServiceBaseUrl=function(e){return`${e}/api`};var ct={},ut={exports:{}};!function(t,s){var a=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==e)return e;throw new Error("unable to locate global object")}();t.exports=s=a.fetch,a.fetch&&(s.default=a.fetch.bind(a)),s.Headers=a.Headers,s.Request=a.Request,s.Response=a.Response}(ut,ut.exports),function(t){var s=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.sendRequest=t.HttpMethod=void 0;const a=s(ut.exports);var r;(r=t.HttpMethod||(t.HttpMethod={})).Get="get",r.Post="post",r.Delete="delete",t.sendRequest=async function({url:e,method:t,body:s}){const r=await(0,a.default)(e,{method:t,headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(s)});let n;try{n=await r.json()}catch(e){if(!r.ok)throw new Error(r.statusText)}if(r.ok)return n;if(n.data)throw new Error(n.data);if(n.detail)throw new Error(n.detail);if(n.message)throw new Error(n.message);if(n.nonFieldErrors)throw new Error(n.nonFieldErrors);if(n.delegate)throw new Error(n.delegate);if(n.safe)throw new Error(n.safe);if(n.delegator)throw new Error(n.delegator);throw new Error(r.statusText)}}(ct);var lt,ft,ht=e&&e.__classPrivateFieldSet||function(e,t,s,a,r){if("m"===a)throw new TypeError("Private method is not writable");if("a"===a&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===a?r.call(e,s):r?r.value=s:t.set(e,s),s},gt=e&&e.__classPrivateFieldGet||function(e,t,s,a){if("a"===s&&!a)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!a:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===s?a:"a"===s?a.call(e):a?a.value:t.get(e)};Object.defineProperty(ot,"__esModule",{value:!0});const pt=dt,_t=ct;lt=new WeakMap,ft=new WeakMap,ot.default=class{constructor({txServiceUrl:e,ethAdapter:t}){lt.set(this,void 0),ft.set(this,void 0),ht(this,lt,(0,pt.getTxServiceBaseUrl)(e),"f"),ht(this,ft,t,"f")}async getServiceInfo(){return(0,_t.sendRequest)({url:`${gt(this,lt,"f")}/v1/about`,method:_t.HttpMethod.Get})}async getServiceMasterCopiesInfo(){return(0,_t.sendRequest)({url:`${gt(this,lt,"f")}/v1/about/master-copies`,method:_t.HttpMethod.Get})}async decodeData(e){if(""===e)throw new Error("Invalid data");return(0,_t.sendRequest)({url:`${gt(this,lt,"f")}/v1/data-decoder/`,method:_t.HttpMethod.Post,body:{data:e}})}async getSafesByOwner(e){if(""===e)throw new Error("Invalid owner address");const{address:t}=await gt(this,ft,"f").getEip3770Address(e);return(0,_t.sendRequest)({url:`${gt(this,lt,"f")}/v1/owners/${t}/safes/`,method:_t.HttpMethod.Get})}async getSafesByModule(e){if(""===e)throw new Error("Invalid module address");const{address:t}=await gt(this,ft,"f").getEip3770Address(e);return(0,_t.sendRequest)({url:`${gt(this,lt,"f")}/v1/modules/${t}/safes/`,method:_t.HttpMethod.Get})}async getTransaction(e){if(""===e)throw new Error("Invalid safeTxHash");return(0,_t.sendRequest)({url:`${gt(this,lt,"f")}/v1/multisig-transactions/${e}/`,method:_t.HttpMethod.Get})}async getTransactionConfirmations(e){if(""===e)throw new Error("Invalid safeTxHash");return(0,_t.sendRequest)({url:`${gt(this,lt,"f")}/v1/multisig-transactions/${e}/confirmations/`,method:_t.HttpMethod.Get})}async confirmTransaction(e,t){if(""===e)throw new Error("Invalid safeTxHash");if(""===t)throw new Error("Invalid signature");return(0,_t.sendRequest)({url:`${gt(this,lt,"f")}/v1/multisig-transactions/${e}/confirmations/`,method:_t.HttpMethod.Post,body:{signature:t}})}async getSafeInfo(e){if(""===e)throw new Error("Invalid Safe address");const{address:t}=await gt(this,ft,"f").getEip3770Address(e);return(0,_t.sendRequest)({url:`${gt(this,lt,"f")}/v1/safes/${t}/`,method:_t.HttpMethod.Get})}async getSafeDelegates({safeAddress:e,delegateAddress:t,delegatorAddress:s,label:a,limit:r,offset:n}){const i=new URL(`${gt(this,lt,"f")}/v1/delegates`);if(e){const{address:t}=await gt(this,ft,"f").getEip3770Address(e);i.searchParams.set("safe",t)}if(t){const{address:e}=await gt(this,ft,"f").getEip3770Address(t);i.searchParams.set("delegate",e)}if(s){const{address:e}=await gt(this,ft,"f").getEip3770Address(s);i.searchParams.set("delegator",e)}return a&&i.searchParams.set("label",a),r&&i.searchParams.set("limit",r),n&&i.searchParams.set("offset",n),(0,_t.sendRequest)({url:i.toString(),method:_t.HttpMethod.Get})}async addSafeDelegate({safeAddress:e,delegateAddress:t,delegatorAddress:s,label:a,signer:r}){if(""===t)throw new Error("Invalid Safe delegate address");if(""===s)throw new Error("Invalid Safe delegator address");if(""===a)throw new Error("Invalid label");const{address:n}=await gt(this,ft,"f").getEip3770Address(t),{address:i}=await gt(this,ft,"f").getEip3770Address(s),o=n+Math.floor(Date.now()/1e3/3600),d=await r.signMessage(o),c={safe:e?(await gt(this,ft,"f").getEip3770Address(e)).address:null,delegate:n,delegator:i,label:a,signature:d};return(0,_t.sendRequest)({url:`${gt(this,lt,"f")}/v1/delegates/`,method:_t.HttpMethod.Post,body:c})}async removeSafeDelegate({delegateAddress:e,delegatorAddress:t,signer:s}){if(""===e)throw new Error("Invalid Safe delegate address");if(""===t)throw new Error("Invalid Safe delegator address");const{address:a}=await gt(this,ft,"f").getEip3770Address(e),{address:r}=await gt(this,ft,"f").getEip3770Address(t),n=a+Math.floor(Date.now()/1e3/3600),i=await s.signMessage(n);return(0,_t.sendRequest)({url:`${gt(this,lt,"f")}/v1/delegates/${a}`,method:_t.HttpMethod.Delete,body:{delegate:a,delegator:r,signature:i}})}async getSafeCreationInfo(e){if(""===e)throw new Error("Invalid Safe address");const{address:t}=await gt(this,ft,"f").getEip3770Address(e);return(0,_t.sendRequest)({url:`${gt(this,lt,"f")}/v1/safes/${t}/creation/`,method:_t.HttpMethod.Get})}async estimateSafeTransaction(e,t){if(""===e)throw new Error("Invalid Safe address");const{address:s}=await gt(this,ft,"f").getEip3770Address(e);return(0,_t.sendRequest)({url:`${gt(this,lt,"f")}/v1/safes/${s}/multisig-transactions/estimations/`,method:_t.HttpMethod.Post,body:t})}async proposeTransaction({safeAddress:e,safeTransactionData:t,safeTxHash:s,senderAddress:a,senderSignature:r,origin:n}){if(""===e)throw new Error("Invalid Safe address");const{address:i}=await gt(this,ft,"f").getEip3770Address(e),{address:o}=await gt(this,ft,"f").getEip3770Address(a);if(""===s)throw new Error("Invalid safeTxHash");return(0,_t.sendRequest)({url:`${gt(this,lt,"f")}/v1/safes/${i}/multisig-transactions/`,method:_t.HttpMethod.Post,body:{...t,contractTransactionHash:s,sender:o,signature:r,origin:n}})}async getIncomingTransactions(e){if(""===e)throw new Error("Invalid Safe address");const{address:t}=await gt(this,ft,"f").getEip3770Address(e);return(0,_t.sendRequest)({url:`${gt(this,lt,"f")}/v1/safes/${t}/incoming-transfers?executed=true`,method:_t.HttpMethod.Get})}async getModuleTransactions(e){if(""===e)throw new Error("Invalid Safe address");const{address:t}=await gt(this,ft,"f").getEip3770Address(e);return(0,_t.sendRequest)({url:`${gt(this,lt,"f")}/v1/safes/${t}/module-transactions/`,method:_t.HttpMethod.Get})}async getMultisigTransactions(e){if(""===e)throw new Error("Invalid Safe address");const{address:t}=await gt(this,ft,"f").getEip3770Address(e);return(0,_t.sendRequest)({url:`${gt(this,lt,"f")}/v1/safes/${t}/multisig-transactions/`,method:_t.HttpMethod.Get})}async getPendingTransactions(e,t){if(""===e)throw new Error("Invalid Safe address");const{address:s}=await gt(this,ft,"f").getEip3770Address(e),a=t||(await this.getSafeInfo(s)).nonce;return(0,_t.sendRequest)({url:`${gt(this,lt,"f")}/v1/safes/${s}/multisig-transactions/?executed=false&nonce__gte=${a}`,method:_t.HttpMethod.Get})}async getAllTransactions(e,t){var s,a,r;if(""===e)throw new Error("Invalid Safe address");const{address:n}=await gt(this,ft,"f").getEip3770Address(e),i=new URL(`${gt(this,lt,"f")}/v1/safes/${n}/all-transactions/`),o=(null===(s=null==t?void 0:t.trusted)||void 0===s?void 0:s.toString())||"true";i.searchParams.set("trusted",o);const d=(null===(a=null==t?void 0:t.queued)||void 0===a?void 0:a.toString())||"true";i.searchParams.set("queued",d);const c=(null===(r=null==t?void 0:t.executed)||void 0===r?void 0:r.toString())||"false";return i.searchParams.set("executed",c),(0,_t.sendRequest)({url:i.toString(),method:_t.HttpMethod.Get})}async getNextNonce(e){if(""===e)throw new Error("Invalid Safe address");const{address:t}=await gt(this,ft,"f").getEip3770Address(e),s=await this.getPendingTransactions(t);if(s.results.length>0){const e=s.results.map((e=>e.nonce));return Math.max(...e)+1}return(await this.getSafeInfo(t)).nonce}async getTokenList(){return(0,_t.sendRequest)({url:`${gt(this,lt,"f")}/v1/tokens/`,method:_t.HttpMethod.Get})}async getToken(e){if(""===e)throw new Error("Invalid token address");const{address:t}=await gt(this,ft,"f").getEip3770Address(e);return(0,_t.sendRequest)({url:`${gt(this,lt,"f")}/v1/tokens/${t}/`,method:_t.HttpMethod.Get})}};var Et={};Object.defineProperty(Et,"__esModule",{value:!0}),function(t){var s=e&&e.__createBinding||(Object.create?function(e,t,s,a){void 0===a&&(a=s);var r=Object.getOwnPropertyDescriptor(t,s);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[s]}}),Object.defineProperty(e,a,r)}:function(e,t,s,a){void 0===a&&(a=s),e[a]=t[s]}),a=e&&e.__exportStar||function(e,t){for(var a in e)"default"===a||Object.prototype.hasOwnProperty.call(t,a)||s(t,e,a)},r=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const n=r(ot);a(Et,t),t.default=n.default}(it);var mt=s(it);const vt={1:"https://safe-transaction-mainnet.safe.global/",5:"https://safe-transaction-goerli.safe.global/",42161:"https://safe-transaction-arbitrum.safe.global/",43114:"https://safe-transaction-avalanche.safe.global/",1313161554:"https://safe-transaction-aurora.safe.global/",56:"https://safe-transaction-bsc.safe.global/",10:"https://safe-transaction-optimism.safe.global/",137:"https://safe-transaction-polygon.safe.global/"};let Tt;function yt(e){return a(this,void 0,void 0,(function*(){if((null==Tt?void 0:Tt.chainId)===e)return Tt.safeService;if(!n.getState().provider)throw new Error("provider is undefined");const t=function(){return{getEip3770Address:e=>a(this,void 0,void 0,(function*(){const{address:t,prefix:s}=function(e){const t=e.split(":"),s=t.length>1?t[1]:t[0];return{prefix:t.length>1?t[0]:"",address:s}}(e);return{address:t,prefix:s}}))}}(),s=vt[e];if(!s)return;const r=new mt({txServiceUrl:s,ethAdapter:t});return Tt={safeService:r,chainId:e},Tt.safeService}))}function wt(e,t){return a(this,void 0,void 0,(function*(){if(!t)return!1;const s=yield yt(e);if(!s)return!1;try{return!!(yield s.getSafeInfo(t))}catch(e){return console.error(e),!1}}))}function St(e,t,s){return a(this,void 0,void 0,(function*(){const a=yield yt(e);if(!a)return console.error(`chainId: ${e} is not supported safe`),s;if(s!==t)return s;const r=yield a.getMultisigTransactions(s),[n]=r.results;return n.safeTxHash}))}function It(e,t,s){return a(this,void 0,void 0,(function*(){const a=yield yt(e);if(!a)throw new Error(`chainId: ${e} is not supported safe`);try{const{results:e}=yield a.getMultisigTransactions(s),r=e.find((e=>e.safeTxHash.toLocaleLowerCase()===t.toLocaleLowerCase()));if(!r)return null;if(e.some((e=>!(e.nonce!==r.nonce||e.safeTxHash.toLocaleLowerCase()===t.toLocaleLowerCase()||!e.isExecuted||!e.isSuccessful))))return"rejected";if(null===r.isExecuted||null===r.isSuccessful)return null;return{status:r.isExecuted&&r.isSuccessful||!1,transactionHash:r.transactionHash,blockNumber:r.blockNumber||null}}catch(e){throw console.error(e),new Error(`safeTxHash: ${t} is not valid.`)}}))}function bt(e,t,s){const a={1:"eth",5:"gor",137:"matic",56:"bnb",42161:"arb1",10:"oeth",43114:"avax",1313161554:"aurora"}[t];if(!a)throw new Error(`Not Supported network: ${t}`);return`https://app.safe.global/transactions/tx?id=multisig_${s}_${e}&safe=${a}%3A${s}`}export{nt as default,wt as getAccountIsSafe,at as getConnectedSafe,rt as getIsSafe,bt as getSafeHashDetailUrl,St as getSafeTxHash,It as getSafeTxStatus};