-
Notifications
You must be signed in to change notification settings - Fork 1
/
25.5dd7208063cc8aae4ad2.js
1 lines (1 loc) · 143 KB
/
25.5dd7208063cc8aae4ad2.js
1
(window.webpackJsonp=window.webpackJsonp||[]).push([[25],{"/yFf":function(t,e,r){"use strict";var n=r("oHnp");function s(t){if(t)return function(t){for(var e in s.prototype)t[e]=s.prototype[e];return t}(t)}t.exports=s,s.prototype.get=function(t){return this.header[t.toLowerCase()]},s.prototype._setHeaderProperties=function(t){var e=t["content-type"]||"";this.type=n.type(e);var r=n.params(e);for(var s in r)this[s]=r[s];this.links={};try{t.link&&(this.links=n.parseLinks(t.link))}catch(i){}},s.prototype._setStatusProperties=function(t){var e=t/100|0;this.status=this.statusCode=t,this.statusType=e,this.info=1==e,this.ok=2==e,this.redirect=3==e,this.clientError=4==e,this.serverError=5==e,this.error=(4==e||5==e)&&this.toError(),this.created=201==t,this.accepted=202==t,this.noContent=204==t,this.badRequest=400==t,this.unauthorized=401==t,this.notAcceptable=406==t,this.forbidden=403==t,this.notFound=404==t,this.unprocessableEntity=422==t}},"1B/i":function(t,e,r){"use strict";r.r(e),r.d(e,"TypedDataUtils",function(){return i}),r.d(e,"buildTypedData",function(){return a}),r.d(e,"domainType",function(){return u}),r.d(e,"encodeTypedDataDigest",function(){return o});var n=r("wDBh"),s=function(){return(s=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var s in e=arguments[r])Object.prototype.hasOwnProperty.call(e,s)&&(t[s]=e[s]);return t}).apply(this,arguments)},i={encodeDigest:function(t){var e=n.ethers.utils.arrayify("0x1901"),r=i.hashStruct(t,"EIP712Domain",t.domain),s=i.hashStruct(t,t.primaryType,t.message),o=n.ethers.utils.solidityPack(["bytes","bytes32","bytes32"],[e,h(r,32),h(s,32)]),a=n.ethers.utils.keccak256(o);return n.ethers.utils.arrayify(a)},encodeData:function(t,e,r){var s=t.types,o=s[e];if(!o||0===o.length)throw new Error("TypedDataUtils: "+t.primaryType+" type is not unknown");var a=new n.ethers.utils.AbiCoder,u=[],c=[],l=i.typeHash(t.types,e);u.push("bytes32"),c.push(h(l,32));for(var p=function(e,r,o){if(void 0!==s[r])return["bytes32",n.ethers.utils.arrayify(n.ethers.utils.keccak256(i.encodeData(t,r,o)))];if("bytes"===r||"string"===r){var u=void 0;return u="string"===r?n.ethers.utils.toUtf8Bytes(o):n.ethers.utils.arrayify(o),["bytes32",n.ethers.utils.arrayify(n.ethers.utils.hexZeroPad(n.ethers.utils.keccak256(u),32))]}if(r.lastIndexOf("[")>0){var h=r.slice(0,r.lastIndexOf("["));return u=o.map(function(t){return p(e,h,t)}),["bytes32",n.ethers.utils.arrayify(n.ethers.utils.keccak256(n.ethers.utils.arrayify(a.encode(u.map(function(t){return t[0]}),u.map(function(t){return t[1]})))))]}return[r,o]},f=0,d=o;f<d.length;f++){var g=d[f],y=p(g.name,g.type,r[g.name]),_=y[1];u.push(y[0]),c.push(_)}return n.ethers.utils.arrayify(a.encode(u,c))},hashStruct:function(t,e,r){return n.ethers.utils.arrayify(n.ethers.utils.keccak256(i.encodeData(t,e,r)))},typeHash:function(t,e){return n.ethers.utils.arrayify(n.ethers.utils.keccak256(n.ethers.utils.toUtf8Bytes(i.encodeType(t,e))))},encodeType:function(t,e){var r=t[e];if(!r||0===r.length)throw new Error("TypedDataUtils: "+e+" type is not defined");for(var n=[],s=e+"(",o=0;o<r.length;o++){var a=r[o],u=a.type.indexOf("["),h=u<0?a.type:a.type.slice(0,u);if(t[h]&&t[h].length>0){for(var c=!1,l=0;l<n.length;l++)n[l]===h&&(c=!0);c||n.push(h)}s+=a.type+" "+a.name,o<r.length-1&&(s+=",")}for(s+=")",n.sort(),o=0;o<n.length;o++)s+=i.encodeType(t,n[o]);return s},domainType:function(t){var e=[];return t.name&&e.push({name:"name",type:"string"}),t.version&&e.push({name:"version",type:"string"}),t.chainId&&e.push({name:"chainId",type:"uint256"}),t.verifyingContract&&e.push({name:"verifyingContract",type:"address"}),t.salt&&e.push({name:"salt",type:"bytes32"}),e},buildTypedData:function(t,e,r,n){var o=i.domainType(t);return{domain:t,types:s({EIP712Domain:o},e),primaryType:r,message:n}}},o=function(t){return i.encodeDigest(t)},a=function(t,e,r,n){return i.buildTypedData(t,e,r,n)},u=function(t){return i.domainType(t)},h=function(t,e){return n.ethers.utils.arrayify(n.ethers.utils.hexZeroPad(n.ethers.utils.hexlify(t),e))}},"24Ii":function(t,e,r){var n;"undefined"!=typeof window?n=window:"undefined"!=typeof self?n=self:(console.warn("Using browser-only version of superagent in non-browser environment"),n=this);var s=r("cpc2"),i=r("kMlx"),o=r("8zgK"),a=r("/yFf"),u=r("nZbv");function h(){}var c=e=t.exports=function(t,r){return"function"==typeof r?new e.Request("GET",t).end(r):1==arguments.length?new e.Request("GET",t):new e.Request(t,r)};e.Request=_,c.getXHR=function(){if(!(!n.XMLHttpRequest||n.location&&"file:"==n.location.protocol&&n.ActiveXObject))return new XMLHttpRequest;try{return new ActiveXObject("Microsoft.XMLHTTP")}catch(t){}try{return new ActiveXObject("Msxml2.XMLHTTP.6.0")}catch(t){}try{return new ActiveXObject("Msxml2.XMLHTTP.3.0")}catch(t){}try{return new ActiveXObject("Msxml2.XMLHTTP")}catch(t){}throw Error("Browser-only version of superagent could not find XHR")};var l="".trim?function(t){return t.trim()}:function(t){return t.replace(/(^\s*|\s*$)/g,"")};function p(t){if(!o(t))return t;var e=[];for(var r in t)f(e,r,t[r]);return e.join("&")}function f(t,e,r){if(null!=r)if(Array.isArray(r))r.forEach(function(r){f(t,e,r)});else if(o(r))for(var n in r)f(t,e+"["+n+"]",r[n]);else t.push(encodeURIComponent(e)+"="+encodeURIComponent(r));else null===r&&t.push(encodeURIComponent(e))}function d(t){for(var e,r,n={},s=t.split("&"),i=0,o=s.length;i<o;++i)-1==(r=(e=s[i]).indexOf("="))?n[decodeURIComponent(e)]="":n[decodeURIComponent(e.slice(0,r))]=decodeURIComponent(e.slice(r+1));return n}function g(t){return/[\/+]json($|[^-\w])/.test(t)}function y(t){this.req=t,this.xhr=this.req.xhr,this.text="HEAD"!=this.req.method&&(""===this.xhr.responseType||"text"===this.xhr.responseType)||void 0===this.xhr.responseType?this.xhr.responseText:null,this.statusText=this.req.xhr.statusText;var e=this.xhr.status;1223===e&&(e=204),this._setStatusProperties(e),this.header=this.headers=function(t){for(var e,r,n,s,i=t.split(/\r?\n/),o={},a=0,u=i.length;a<u;++a)-1!==(e=(r=i[a]).indexOf(":"))&&(n=r.slice(0,e).toLowerCase(),s=l(r.slice(e+1)),o[n]=s);return o}(this.xhr.getAllResponseHeaders()),this.header["content-type"]=this.xhr.getResponseHeader("content-type"),this._setHeaderProperties(this.header),this.body=null===this.text&&t._responseType?this.xhr.response:"HEAD"!=this.req.method?this._parseBody(this.text?this.text:this.xhr.response):null}function _(t,e){var r=this;this._query=this._query||[],this.method=t,this.url=e,this.header={},this._header={},this.on("end",function(){var t,e=null,n=null;try{n=new y(r)}catch(s){return(e=new Error("Parser is unable to parse the response")).parse=!0,e.original=s,r.xhr?(e.rawResponse=void 0===r.xhr.responseType?r.xhr.responseText:r.xhr.response,e.status=r.xhr.status?r.xhr.status:null,e.statusCode=e.status):(e.rawResponse=null,e.status=null),r.callback(e)}r.emit("response",n);try{r._isResponseOK(n)||(t=new Error(n.statusText||"Unsuccessful HTTP response"))}catch(i){t=i}t?(t.original=e,t.response=n,t.status=n.status,r.callback(t,n)):r.callback(null,n)})}function E(t,e,r){var n=c("DELETE",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n}c.serializeObject=p,c.parseString=d,c.types={html:"text/html",json:"application/json",xml:"text/xml",urlencoded:"application/x-www-form-urlencoded",form:"application/x-www-form-urlencoded","form-data":"application/x-www-form-urlencoded"},c.serialize={"application/x-www-form-urlencoded":p,"application/json":JSON.stringify},c.parse={"application/x-www-form-urlencoded":d,"application/json":JSON.parse},a(y.prototype),y.prototype._parseBody=function(t){var e=c.parse[this.type];return this.req._parser?this.req._parser(this,t):(!e&&g(this.type)&&(e=c.parse["application/json"]),e&&t&&(t.length||t instanceof Object)?e(t):null)},y.prototype.toError=function(){var t=this.req,e=t.method,r=t.url,n=new Error("cannot "+e+" "+r+" ("+this.status+")");return n.status=this.status,n.method=e,n.url=r,n},c.Response=y,s(_.prototype),i(_.prototype),_.prototype.type=function(t){return this.set("Content-Type",c.types[t]||t),this},_.prototype.accept=function(t){return this.set("Accept",c.types[t]||t),this},_.prototype.auth=function(t,e,r){1===arguments.length&&(e=""),"object"==typeof e&&null!==e&&(r=e,e=""),r||(r={type:"function"==typeof btoa?"basic":"auto"});var n=function(t){if("function"==typeof btoa)return btoa(t);throw new Error("Cannot use basic auth, btoa is not a function")};return this._auth(t,e,r,n)},_.prototype.query=function(t){return"string"!=typeof t&&(t=p(t)),t&&this._query.push(t),this},_.prototype.attach=function(t,e,r){if(e){if(this._data)throw Error("superagent can't mix .send() and .attach()");this._getFormData().append(t,e,r||e.name)}return this},_.prototype._getFormData=function(){return this._formData||(this._formData=new n.FormData),this._formData},_.prototype.callback=function(t,e){if(this._shouldRetry(t,e))return this._retry();var r=this._callback;this.clearTimeout(),t&&(this._maxRetries&&(t.retries=this._retries-1),this.emit("error",t)),r(t,e)},_.prototype.crossDomainError=function(){var t=new Error("Request has been terminated\nPossible causes: the network is offline, Origin is not allowed by Access-Control-Allow-Origin, the page is being unloaded, etc.");t.crossDomain=!0,t.status=this.status,t.method=this.method,t.url=this.url,this.callback(t)},_.prototype.buffer=_.prototype.ca=_.prototype.agent=function(){return console.warn("This is not supported in browser version of superagent"),this},_.prototype.pipe=_.prototype.write=function(){throw Error("Streaming is not supported in browser version of superagent")},_.prototype._isHost=function(t){return t&&"object"==typeof t&&!Array.isArray(t)&&"[object Object]"!==Object.prototype.toString.call(t)},_.prototype.end=function(t){return this._endCalled&&console.warn("Warning: .end() was called twice. This is not supported in superagent"),this._endCalled=!0,this._callback=t||h,this._finalizeQueryString(),this._end()},_.prototype._end=function(){var t=this,e=this.xhr=c.getXHR(),r=this._formData||this._data;this._setTimeouts(),e.onreadystatechange=function(){var r=e.readyState;if(r>=2&&t._responseTimeoutTimer&&clearTimeout(t._responseTimeoutTimer),4==r){var n;try{n=e.status}catch(s){n=0}if(!n){if(t.timedout||t._aborted)return;return t.crossDomainError()}t.emit("end")}};var n=function(e,r){r.total>0&&(r.percent=r.loaded/r.total*100),r.direction=e,t.emit("progress",r)};if(this.hasListeners("progress"))try{e.onprogress=n.bind(null,"download"),e.upload&&(e.upload.onprogress=n.bind(null,"upload"))}catch(a){}try{this.username&&this.password?e.open(this.method,this.url,!0,this.username,this.password):e.open(this.method,this.url,!0)}catch(u){return this.callback(u)}if(this._withCredentials&&(e.withCredentials=!0),!this._formData&&"GET"!=this.method&&"HEAD"!=this.method&&"string"!=typeof r&&!this._isHost(r)){var s=this._header["content-type"],i=this._serializer||c.serialize[s?s.split(";")[0]:""];!i&&g(s)&&(i=c.serialize["application/json"]),i&&(r=i(r))}for(var o in this.header)null!=this.header[o]&&this.header.hasOwnProperty(o)&&e.setRequestHeader(o,this.header[o]);return this._responseType&&(e.responseType=this._responseType),this.emit("request",this),e.send(void 0!==r?r:null),this},c.agent=function(){return new u},["GET","POST","OPTIONS","PATCH","PUT","DELETE"].forEach(function(t){u.prototype[t.toLowerCase()]=function(e,r){var n=new c.Request(t,e);return this._setDefaults(n),r&&n.end(r),n}}),u.prototype.del=u.prototype.delete,c.get=function(t,e,r){var n=c("GET",t);return"function"==typeof e&&(r=e,e=null),e&&n.query(e),r&&n.end(r),n},c.head=function(t,e,r){var n=c("HEAD",t);return"function"==typeof e&&(r=e,e=null),e&&n.query(e),r&&n.end(r),n},c.options=function(t,e,r){var n=c("OPTIONS",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n},c.del=E,c.delete=E,c.patch=function(t,e,r){var n=c("PATCH",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n},c.post=function(t,e,r){var n=c("POST",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n},c.put=function(t,e,r){var n=c("PUT",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n}},"2k3W":function(t,e,r){"use strict";r.r(e),r.d(e,"bits",function(){return s}),r.d(e,"buffer",function(){return E}),r.d(e,"byte",function(){return m}),r.d(e,"integer",function(){return w}),r.d(e,"nibble",function(){return S}),r.d(e,"string",function(){return v});for(var n=function(t){for(var e=[],r=0;r<t.length;r++)e[r]=1^t[r];return e},s={and:function(t,e){for(var r=[],n=0;n<t.length;n++)r[n]=t[n]&e[n];return r},circularShiftLeft:function(t,e){var r=[];if(e>t.length)throw new Error("shift amount can\u2019t be larger than bits array length");for(var n=0;n<t.length;n++)r[(t.length+n-e)%t.length]=t[n];return r},circularShiftRight:function(t,e){var r=[];if(e>t.length)throw new Error("shift amount can\u2019t be larger than bits array length");for(var n=0;n<t.length;n++)r[(n+e)%t.length]=t[n];return r},nand:function(t,e){for(var r=[],n=0;n<t.length;n++)r[n]=t[n]&e[n]^1;return r},nor:function(t,e){for(var r=[],n=0;n<t.length;n++)r[n]=1^(t[n]|e[n]);return r},not:n,or:function(t,e){for(var r=[],n=0;n<t.length;n++)r[n]=t[n]|e[n];return r},reduceAnd:function(t){if(t.length<2)throw new RangeError("Not enough bits.");for(var e=t[0],r=1;r<t.length;r++)e&=t[r];return e},reduceNand:function(t){if(t.length<2)throw new RangeError("Not enough bits.");for(var e=t[0],r=1;r<t.length;r++)e=e&t[r]^1;return e},reduceNor:function(t){if(t.length<2)throw new RangeError("Not enough bits.");for(var e=t[0],r=1;r<t.length;r++)e=1^(e|t[r]);return e},reduceOr:function(t){if(t.length<2)throw new RangeError("Not enough bits.");for(var e=t[0],r=1;r<t.length;r++)e|=t[r];return e},reduceXnor:function(t){if(t.length<2)throw new RangeError("Not enough bits.");for(var e=t[0],r=1;r<t.length;r++)e^=1^t[r];return e},reduceXor:function(t){if(t.length<2)throw new RangeError("Not enough bits.");for(var e=t[0],r=1;r<t.length;r++)e^=t[r];return e},toBoolean:function(t){for(var e=[],r=0;r<t.length;r++)e[r]=1===t[r];return e},toString:function(t,e,r){if(void 0===e&&(e=0),void 0===r&&(r=" "),!e)return t.join("");for(var n="",s=0;s<t.length;s++)n+=""+t[s],s%e==e-1&&s!==t.length-1&&(n+=r);return n},xnor:function(t,e){for(var r=[],n=0;n<t.length;n++)r[n]=t[n]^e[n]^1;return r},xor:function(t,e){for(var r=[],n=0;n<t.length;n++)r[n]=t[n]^e[n];return r}},i=r("XUzR"),o=r("GCxg"),a=r("G1u+"),u=function(t){if(t>255||t<0||~~t!==t)throw new RangeError("invalid byte");for(var e=[0,0,0,0,0,0,0,0],r=0;r<8;r++)e[7-r]=t>>r&1;return e},h=function(t,e,r){void 0===e&&(e=0),r||(r=8*t.length-e);var n=Math.floor(e/8),s=Math.floor(r/8)+2,i=[];i.length=8*s;for(var o=0;o<s;o++)if(void 0!==t[n+o]){var a=u(t[n+o]);i[8*o]=a[0],i[8*o+1]=a[1],i[8*o+2]=a[2],i[8*o+3]=a[3],i[8*o+4]=a[4],i[8*o+5]=a[5],i[8*o+6]=a[6],i[8*o+7]=a[7]}var h=e%8;return i.slice(h,h+r)},c=r("nMdu"),l=r("ILq/"),p=r("f7RY"),f=r("YnKP"),d=[],g=0;g<32;g++)d[g]=Math.pow(2,g);var y=r("vGFC"),_=r("5tNv"),E={and:i.a,create:o.a,modify:function(t,e,r){void 0===r&&(r=0);for(var n=Math.floor(r/8),s=Math.ceil((r+e.length)/8),i=t.slice(n,s),o=h(i),u=r%8,c=0;c<e.length;c++)o[u++]=e[c];for(var l=s-n,p=0;p<l;p++)i[p]=Object(a.a)(o.slice(8*p,8*(p+1)))},nand:c.a,nor:l.a,not:p.a,or:f.a,read:h,readInt:function(t,e,r){void 0===e&&(e=0),void 0===r&&(r=8);var s=h(t,e,r);if(0===s[0]){for(var i=0,o=0;o<r;o++)s[o]&&(i+=d[r-o-1]);return i}i=-1;var a=n(s);for(o=0;o<r;o++)a[o]&&(i-=d[r-o-1]);return i},readUInt:function(t,e,r){void 0===e&&(e=0),void 0===r&&(r=8);for(var n=h(t,e,r),s=0,i=0;i<r;i++)s+=n[i]*d[r-i-1];return s},xnor:y.a,xor:_.a},m={read:u,write:a.a},w={getBit:function(t,e){return t>>e&1},setBit:function(t,e,r){return 1===r?t|1<<e:t&~(1<<e)},toggleBit:function(t,e){return t^1<<e}},S={read:function(t){if(t<16&&t>=0&&Math.floor(t)===t){for(var e=[0,0,0,0],r=0;r<4;r++)e[3-r]=t>>r&1;return e}throw new RangeError("invalid array length")},write:function(t){if(!Array.isArray(t)||4!==t.length)throw new RangeError("invalid array length");for(var e=0,r=0;r<4;r++)t[3-r]&&(e|=1<<r);return e}},v={toBits:function(t){for(var e=[],r=0;r<t.length;r++)"1"===t[r]?e.push(1):"0"===t[r]&&e.push(0);return e}};e.default={bits:s,buffer:E,byte:m,integer:w,nibble:S,string:v}},"4Mn8":function(t,e,r){const n=r("pzNo");t.exports={Client:n}},"5tNv":function(t,e,r){"use strict";(function(t){e.a=function(e,r,n){void 0===n&&(n=!1);for(var s=n?r.length:e.length,i=t.alloc(s),o=0;o<s;o++)i[o]=e[n?o%e.length:o]^r[o];return i}}).call(this,r("tjlA").Buffer)},"6WMX":function(t,e,r){const n=r("hb/F").bech32,s=r("b3gk"),i=r("tjlA").Buffer,o=r("L21C"),a=i.from("01","hex"),{HARDENED_OFFSET:u}=r("L21C"),h=[44+u,u,u,1,0],c={LEGACY:0,SEGWIT:5,TESTNET:111,SEGWIT_TESTNET:196,SEGWIT_NATIVE_V0:208,SEGWIT_NATIVE_V0_TESTNET:240};e.addressVersion=c;const l={P2PKH:1,P2SH:2,P2SH_P2WPKH:3,P2WPKH_V0:4};function p(t,e){return i.concat([t,e])}function f(t){const e=i.alloc(4);return e.writeUInt32LE(t),e}function d(t){let e;return t<253?(e=i.alloc(1),e.writeUInt8(t)):t<=65535?(e=i.alloc(3),e.writeUInt8(253,0),e.writeUInt16LE(t,1)):t<4294967295?(e=i.alloc(5),e.writeUInt8(254,0),e.writeUInt32LE(t,1)):(e=i.alloc(9),e.writeUInt8(255,0),e.writeUInt32LE(t>>>0,1),e.writeUInt32LE(t/4294967296|0,5)),e}function g(t,e,r){"number"==typeof t&&(t=t.toString(16));const n=i.alloc(8),s=t.length%2==0?t.toString(16):`0${t.toString(16)}`;return i.from(s,"hex").reverse().copy(n,0),n.copy(e,r),n}function y(t){let e,r;try{e=s.decode(t)[0],r=s.decode(t).slice(1)}catch(o){try{const s=n.decode(t);if("bc"===s.prefix)e=208;else{if("tb"!==s.prefix)throw new Error("Unsupported prefix: must be bc or tb.");e=240}if(0!==s.words[0])throw new Error(`Unsupported segwit version: must be 0, got ${s.words[0]}`);r=i.from(n.fromWords(s.words.slice(1)))}catch(o){throw new Error(`Unable to decode address: ${t}: ${o.message}`)}}return{versionByte:e,pkh:r}}e.scriptTypes=l,e.buildBitcoinTxRequest=function(t){try{const{prevOuts:e,recipient:r,value:n,changePath:s=h,fee:a,isSegwit:u=null,changeVersion:p="SEGWIT",spenderScriptType:f=null}=t;if(5!==s.length)throw new Error("Please provide a full change path.");const d=i.alloc(59+69*e.length);let _=0;if(void 0===c[p])throw new Error("Invalid change version specified.");d.writeUInt8(c[p]),_++,d.writeUInt32LE(s.length,_),_+=4;for(let t=0;t<s.length;t++)d.writeUInt32LE(s[t],_),_+=4;d.writeUInt32LE(a,_),_+=4;const E=y(r);d.writeUInt8(E.versionByte,_),_++,E.pkh.copy(d,_),_+=E.pkh.length,g(n,d,_),_+=8,d.writeUInt8(e.length,_),_++;let m,w=0;if(null!==f&&l[f])m=l[f];else{if(null===u)throw new Error("Unsupported spender script type or none provided.");m=!0===u?l.P2SH_P2WPKH:l.P2PKH}return e.forEach(t=>{if(!t.signerPath||5!==t.signerPath.length)throw new Error("Full recipient path not specified ");d.writeUInt32LE(t.signerPath.length,_),_+=4;for(let e=0;e<t.signerPath.length;e++)d.writeUInt32LE(t.signerPath[e],_),_+=4;d.writeUInt32LE(t.index,_),_+=4,g(t.value,d,_),_+=8,w+=t.value,d.writeUInt8(m,_),_++,i.isBuffer(t.txHash)||(t.txHash=i.from(t.txHash,"hex")),t.txHash.copy(d,_),_+=t.txHash.length}),{payload:d,spenderScriptType:m,schema:o.signingSchema.BTC_TRANSFER,origData:t,changeData:{changeVersion:p,value:w-(n+a)}}}catch(e){return{err:e}}},e.serializeTx=function(t){const{inputs:e,outputs:r,spenderScriptType:n,lockTime:s=0,crypto:o}=t;let u=i.alloc(4),h=0;u.writeUInt32LE(2,h),h+=4,n===l.P2SH_P2WPKH&&(u=p(u,i.from("00","hex")),u=p(u,i.from("01","hex")));const _=d(e.length);u=p(u,_),h+=_.length,e.forEach(t=>{u=p(u,t.hash.reverse()),h+=t.hash.length;const e=f(t.index);if(u=p(u,e),h+=e.length,n===l.P2SH_P2WPKH){const e=function(t,e){const r=i.alloc(22),n=e.createHash("sha256").update(t).digest(),s=e.createHash("rmd160").update(n).digest();return r.writeUInt8(0),r.writeUInt8(s.length,1),s.copy(r,2),r}(t.pubkey,o),r=d(e.length),n=i.concat([r,e]),s=d(n.length);u=p(u,s),h+=s.length,u=p(u,n),h+=n.length}else{const e=function(t,e){const r=d((t=i.concat([t,a])).length),n=d(e.length),s=i.concat([r,t,n,e]),o=d(s.length);return i.concat([o,s])}(t.sig,t.pubkey);u=p(u,e),h+=e.length}const r=f(4294967295);u=p(u,r),h+=r.length});const E=d(r.length);if(u=p(u,E),h+=E.length,r.forEach(t=>{const e=function(t){const e=i.alloc(8);return g(t,e,0),e}(t.value);u=p(u,e),h+=e.length;const r=function(t){const e=y(t);switch(e.versionByte){case c.SEGWIT_NATIVE_V0:case c.SEGWIT_NATIVE_V0_TESTNET:return function(t){const e=i.alloc(2+t.length);return e.writeUInt8(0,0),e.writeUInt8(t.length,1),t.copy(e,2),e}(e.pkh);case c.SEGWIT:case c.SEGWIT_TESTNET:return function(t){const e=i.alloc(3+t.length);let r=0;return e.writeUInt8(169,r),r++,e.writeUInt8(t.length,r),r++,t.copy(e,r),r+=t.length,e.writeUInt8(135,r),r++,e}(e.pkh);case c.LEGACY:case c.TESTNET:return function(t){const e=i.alloc(5+t.length);let r=0;return e.writeUInt8(118,r),r++,e.writeUInt8(169,r),r++,e.writeUInt8(t.length,r),r++,t.copy(e,r),r+=t.length,e.writeUInt8(136,r),r++,e.writeUInt8(172,r),r++,e}(e.pkh);default:throw new Error(`Unknown version byte: ${e.versionByte}. Cannot build BTC transaction.`)}}(t.recipient),n=d(r.length);u=p(u,n),h+=n.length,u=p(u,r),h+=r.length}),n===l.P2SH_P2WPKH){const t=[],r=[];for(let s=0;s<e.length;s++)t.push(e[s].sig),r.push(e[s].pubkey);const n=function(t,e){let r=i.alloc(0);const n=i.alloc(1);n.writeUInt8(2);for(let s=0;s<t.length;s++){const o=i.concat([t[s],a]),u=d(o.length),h=e[s],c=d(h.length);r=i.concat([r,n,u,o,c,h])}return r}(t,r);u=p(u,n),h+=n.length}return i.concat([u,f(s)]).toString("hex")},e.getBitcoinAddress=function(t,e){return s.encode(i.concat([i.from([e]),t]))}},"8zgK":function(t,e,r){"use strict";t.exports=function(t){return null!==t&&"object"==typeof t}},AREZ:function(t,e,r){"use strict";e.Diagnose=r("jpl7"),e.Decoder=r("hDHj"),e.Encoder=r("LcfU"),e.Simple=r("UHYx"),e.Tagged=r("IrRL"),e.decodeAll=e.Decoder.decodeAll,e.decodeFirst=e.Decoder.decodeFirst,e.diagnose=e.Diagnose.diagnose,e.encode=e.Encoder.encode,e.decode=e.Decoder.decode,e.leveldb={decode:e.Decoder.decodeAll,encode:e.Encoder.encode,buffer:!0,name:"cbor"}},B3Rj:function(t,e,r){var n=r("QqcV");t.exports=n("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")},BumV:function(t,e,r){"use strict";var n=r("B3Rj"),s=r("hwdV").Buffer;t.exports=function(t){function e(e){var r=e.slice(0,-4),n=e.slice(-4),s=t(r);if(!(n[0]^s[0]|n[1]^s[1]|n[2]^s[2]|n[3]^s[3]))return r}return{encode:function(e){var r=t(e);return n.encode(s.concat([e,r],e.length+4))},decode:function(t){var r=e(n.decode(t));if(!r)throw new Error("Invalid checksum");return r},decodeUnsafe:function(t){var r=n.decodeUnsafe(t);if(r)return e(r)}}}},Fq86:function(t,e,r){"use strict";const{URLWithLegacySupport:n,format:s,URLSearchParams:i,defaultBase:o}=r("HwtC"),a=r("PV6L");t.exports={URL:n,URLSearchParams:i,format:s,relative:a,defaultBase:o}},"G1u+":function(t,e,r){"use strict";e.a=function(t){if(!Array.isArray(t)||8!==t.length)throw new RangeError("invalid array length");for(var e=0,r=0;r<8;r++)t[7-r]&&(e|=1<<r);return e}},GCxg:function(t,e,r){"use strict";(function(t){var n=r("G1u+");e.a=function(e){for(var r=[0,0,0,0,0,0,0,0],s=t.alloc(Math.ceil(e.length/8)),i=0;i<s.length;i++){for(var o=0;o<8;o++)r[o]=e[8*i+o]?e[8*i+o]:0;s[i]=Object(n.a)(r)}return s}}).call(this,r("tjlA").Buffer)},HwtC:function(t,e,r){"use strict";const n=self.location?self.location.protocol+"//"+self.location.host:"",s=self.URL;t.exports={URLWithLegacySupport:class{constructor(t="",e=n){this.super=new s(t,e),this.path=this.pathname+this.search,this.auth=this.username&&this.password?this.username+":"+this.password:null,this.query=this.search&&this.search.startsWith("?")?this.search.slice(1):null}get hash(){return this.super.hash}get host(){return this.super.host}get hostname(){return this.super.hostname}get href(){return this.super.href}get origin(){return this.super.origin}get password(){return this.super.password}get pathname(){return this.super.pathname}get port(){return this.super.port}get protocol(){return this.super.protocol}get search(){return this.super.search}get searchParams(){return this.super.searchParams}get username(){return this.super.username}set hash(t){this.super.hash=t}set host(t){this.super.host=t}set hostname(t){this.super.hostname=t}set href(t){this.super.href=t}set origin(t){this.super.origin=t}set password(t){this.super.password=t}set pathname(t){this.super.pathname=t}set port(t){this.super.port=t}set protocol(t){this.super.protocol=t}set search(t){this.super.search=t}set searchParams(t){this.super.searchParams=t}set username(t){this.super.username=t}createObjectURL(t){return this.super.createObjectURL(t)}revokeObjectURL(t){this.super.revokeObjectURL(t)}toJSON(){return this.super.toJSON()}toString(){return this.super.toString()}format(){return this.toString()}},URLSearchParams:self.URLSearchParams,defaultBase:n,format:function(t){if("string"==typeof t)return new s(t).toString();if(!(t instanceof s)){const e=t.auth?t.auth+"@":"",r=t.port?":"+t.port:"",n=t.hostname||"",s=t.search||(t.query?"?"+t.query:""),i=t.pathname||"";return`${t.protocol?t.protocol+"//":""}${(t.username&&t.password?`${t.username}:${t.password}@`:"")||e}${t.host||n+r}${t.path||i+s}${t.hash||""}`}}}},"ILq/":function(t,e,r){"use strict";(function(t){e.a=function(e,r,n){void 0===n&&(n=!1);for(var s=n?r.length:e.length,i=t.alloc(s),o=0;o<s;o++)i[o]=~(e[n?o%e.length:o]|r[o]);return i}}).call(this,r("tjlA").Buffer)},IrRL:function(t,e,r){"use strict";class n{constructor(t,e,r){if(this.tag=t,this.value=e,this.err=r,"number"!=typeof this.tag)throw new Error("Invalid tag type ("+typeof this.tag+")");if(this.tag<0||(0|this.tag)!==this.tag)throw new Error("Tag must be a positive integer: "+this.tag)}toString(){return`${this.tag}(${JSON.stringify(this.value)})`}encodeCBOR(t){return t._pushTag(this.tag),t.pushAny(this.value)}convert(t){var e;if("function"!=typeof(e=null!=t?t[this.tag]:void 0)&&"function"!=typeof(e=n["_tag"+this.tag]))return this;try{return e.call(n,this.value)}catch(r){return this.err=r,this}}}t.exports=n},L21C:function(t,e){const r={finalizePair:0,getAddresses:1290,sign:1090,getWallets:142,addAbiDefs:8,test:1646};let n=0;Object.keys(r).forEach(t=>{r[t]+82>n&&(n=r[t]+82)});const s={RESP_SUCCESS:0,RESP_ERR_INVALID_MSG:128,RESP_ERR_UNSUPPORTED_VER:129,RESP_ERR_DEV_BUSY:130,RESP_ERR_USER_TIMEOUT:131,RESP_ERR_USER_DECLINED:132,RESP_ERR_PAIR_FAIL:133,RESP_ERR_PAIR_DISABLED:134,RESP_ERR_PERMISSION_DISABLED:135,RESP_ERR_INTERNAL:136,RESP_ERR_GCE_TIMEOUT:137,RESP_ERR_WALLET_NOT_PRESENT:138,RESP_ERR_DEV_LOCKED:139,RESP_ERR_DISABLED:140,RESP_ERR_ALREADY:141},i={[s.RESP_SUCCESS]:0,[s.RESP_ERR_INVALID_MSG]:"Invalid Request",[s.RESP_ERR_UNSUPPORTED_VER]:"Unsupported Version",[s.RESP_ERR_DEV_BUSY]:"Device Busy",[s.RESP_ERR_USER_TIMEOUT]:"Timeout Waiting for User",[s.RESP_ERR_USER_DECLINED]:"Request Declined by User",[s.RESP_ERR_PAIR_FAIL]:"Pairing Failed",[s.RESP_ERR_PAIR_DISABLED]:"Pairing is Currently Disabled",[s.RESP_ERR_PERMISSION_DISABLED]:"Automated Signing is Currently Disabled",[s.RESP_ERR_INTERNAL]:"Device Error",[s.RESP_ERR_GCE_TIMEOUT]:"Timeout",[s.RESP_ERR_WALLET_NOT_PRESENT]:"Incorrect Wallet UID Provided",[s.RESP_ERR_DEV_LOCKED]:"Device Locked",[s.RESP_ERR_DISABLED]:"Disabled",[s.RESP_ERR_ALREADY]:"Record already exists. You must first remove it on your device."},o={address:1,bool:2,uint8:3,uint16:4,uint24:5,uint32:6,uint40:7,uint48:8,uint56:9,uint64:10,uint72:11,uint80:12,uint88:13,uint96:14,uint104:15,uint112:16,uint120:17,uint128:18,uint136:19,uint144:20,uint152:21,uint160:22,uint168:23,uint176:24,uint184:25,uint192:26,uint200:27,uint208:28,uint216:29,uint224:30,uint232:31,uint240:32,uint248:33,uint256:34,int8:35,int16:36,int24:37,int32:38,int40:39,int48:40,int56:41,int64:42,int72:43,int80:44,int88:45,int96:46,int104:47,int112:48,int120:49,int128:50,int136:51,int144:52,int152:53,int160:54,int168:55,int176:56,int184:57,int192:58,int200:59,int208:60,int216:61,int224:62,int232:63,int240:64,int248:65,int256:66,uint:67,bytes1:69,bytes2:70,bytes3:71,bytes4:72,bytes5:73,bytes6:74,bytes7:75,bytes8:76,bytes9:77,bytes10:78,bytes11:79,bytes12:80,bytes13:81,bytes14:82,bytes15:83,bytes16:84,bytes17:85,bytes18:86,bytes19:87,bytes20:88,bytes21:89,bytes22:90,bytes23:91,bytes24:92,bytes25:93,bytes26:94,bytes27:95,bytes28:96,bytes29:97,bytes30:98,bytes31:99,bytes32:100,bytes:101,string:102},a={...o,tuple1:103,tuple2:104,tuple3:105,tuple4:106,tuple5:107,tuple6:108,tuple7:109,tuple8:110,tuple9:111,tuple10:112,tuple11:113,tuple12:114,tuple13:115,tuple14:116,tuple15:117,tuple16:118,tuple17:119};t.exports={getFwVersionConst:function(t){const e={extraDataFrameSz:0,extraDataMaxFrames:0};function r(t,e){return t[2]>e[0]||t[2]===e[0]&&t[1]>e[1]||t[2]===e[0]&&t[1]===e[1]&&t[0]>e[2]||t[2]===e[0]&&t[1]===e[1]&&t[0]===e[2]}const n=0===t.length;return!n&&r(t,[0,10,10])&&(e.ethMsgPreHashAllowed=!0),!n&&r(t,[0,10,8])&&(e.prehashAllowed=!0),!n&&r(t,[0,10,5])&&(e.varAddrPathSzAllowed=!0,e.eip712Supported=!0),!n&&r(t,[0,10,4])&&(e.extraDataFrameSz=1500,e.extraDataMaxFrames=1),!n&&r(t,[0,10,4])||!n&&r(t,[0,10,0])?(e.reqMaxDataSz=1678,e.ethMaxDataSz=e.reqMaxDataSz-128,e.ethMaxMsgSz=e.ethMaxDataSz,e.ethMaxGasPrice=2e13,e.addrFlagsAllowed=!0):(e.reqMaxDataSz=1152,e.ethMaxDataSz=e.reqMaxDataSz-128,e.ethMaxMsgSz=e.ethMaxDataSz,e.ethMaxGasPrice=5e11,e.addrFlagsAllowed=!1),e},ADDR_STR_LEN:129,AES_IV:[109,121,115,101,99,114,101,116,112,97,115,115,119,111,114,100],BASE_URL:"https://signing.gridpl.us",ENC_MSG_LEN:n,addressSizes:{BTC:20,ETH:20},decResLengths:r,deviceCodes:{CONNECT:1,ENCRYPTED_REQUEST:2},encReqCodes:{FINALIZE_PAIRING:0,GET_ADDRESSES:1,ADD_PERMISSION:2,SIGN_TRANSACTION:3,GET_WALLETS:4,ADD_PERMISSION_V0:5,ADD_ABI_DEFS:6,TEST:7},ethMsgProtocol:{SIGN_PERSONAL:{str:"signPersonal",enumIdx:0},TYPED_DATA:{str:"typedData",enumIdx:1,rawDataMaxLen:1629,typeCodes:o}},messageConstants:{NOT_PAIRED:0,PAIRED:1},responseCodes:s,responseMsgs:i,signingSchema:{BTC_TRANSFER:0,ETH_TRANSFER:1,ERC20_TRANSFER:2,ETH_MSG:3,EXTRA_DATA:4},REQUEST_TYPE_BYTE:2,VERSION_BYTE:1,HARDENED_OFFSET:2147483648,HANDLE_LARGER_CHAIN_ID:255,MAX_CHAIN_ID_BYTES:8,ETH_ABI_LATTICE_FW_TYPE_MAP:a}},LcfU:function(t,e,r){"use strict";const{Buffer:n}=r("tjlA"),{URL:s}=r("Fq86"),i=r("kB5k").BigNumber,o=r("XuWj"),a=r("hb4V"),u=a.MT,h=a.NUMBYTES,c=a.SHIFT32,l=a.SYMS,p=a.TAG,f=a.MT.SIMPLE_FLOAT<<5|a.NUMBYTES.TWO,d=a.MT.SIMPLE_FLOAT<<5|a.NUMBYTES.FOUR,g=a.MT.SIMPLE_FLOAT<<5|a.NUMBYTES.EIGHT,y=a.MT.SIMPLE_FLOAT<<5|a.SIMPLE.TRUE,_=a.MT.SIMPLE_FLOAT<<5|a.SIMPLE.FALSE,E=a.MT.SIMPLE_FLOAT<<5|a.SIMPLE.UNDEFINED,m=a.MT.SIMPLE_FLOAT<<5|a.SIMPLE.NULL,w=new i("0x20000000000000"),S=n.from("f97e00","hex"),v=n.from("f9fc00","hex"),b=n.from("f97c00","hex");class I{constructor(t){this.streaming="function"==typeof(t=t||{}).stream,this.onData=t.stream,this.semanticTypes=[[s,this._pushUrl],[i,this._pushBigNumber]];const e=t.genTypes||[],r=e.length;for(let n=0;n<r;n++)this.addSemanticType(e[n][0],e[n][1]);this._reset()}addSemanticType(t,e){const r=this.semanticTypes.length;for(let n=0;n<r;n++)if(this.semanticTypes[n][0]===t){const t=this.semanticTypes[n][1];return this.semanticTypes[n][1]=e,t}return this.semanticTypes.push([t,e]),null}push(t){return!t||(this.result[this.offset]=t,this.resultMethod[this.offset]=0,this.resultLength[this.offset]=t.length,this.offset++,this.streaming&&this.onData(this.finalize()),!0)}pushWrite(t,e,r){return this.result[this.offset]=t,this.resultMethod[this.offset]=e,this.resultLength[this.offset]=r,this.offset++,this.streaming&&this.onData(this.finalize()),!0}_pushUInt8(t){return this.pushWrite(t,1,1)}_pushUInt16BE(t){return this.pushWrite(t,2,2)}_pushUInt32BE(t){return this.pushWrite(t,3,4)}_pushDoubleBE(t){return this.pushWrite(t,4,8)}_pushNaN(){return this.push(S)}_pushInfinity(t){return this.push(t<0?v:b)}_pushFloat(t){const e=n.allocUnsafe(2);if(o.writeHalf(e,t)&&o.parseHalf(e)===t)return this._pushUInt8(f)&&this.push(e);const r=n.allocUnsafe(4);return r.writeFloatBE(t,0),r.readFloatBE(0)===t?this._pushUInt8(d)&&this.push(r):this._pushUInt8(g)&&this._pushDoubleBE(t)}_pushInt(t,e,r){const n=e<<5;return t<24?this._pushUInt8(n|t):t<=255?this._pushUInt8(n|h.ONE)&&this._pushUInt8(t):t<=65535?this._pushUInt8(n|h.TWO)&&this._pushUInt16BE(t):t<=4294967295?this._pushUInt8(n|h.FOUR)&&this._pushUInt32BE(t):t<=Number.MAX_SAFE_INTEGER?this._pushUInt8(n|h.EIGHT)&&this._pushUInt32BE(Math.floor(t/c))&&this._pushUInt32BE(t%c):this._pushFloat(e===u.NEG_INT?r:t)}_pushIntNum(t){return t<0?this._pushInt(-t-1,u.NEG_INT,t):this._pushInt(t,u.POS_INT)}_pushNumber(t){switch(!1){case t==t:return this._pushNaN(t);case isFinite(t):return this._pushInfinity(t);case t%1!=0:return this._pushIntNum(t);default:return this._pushFloat(t)}}_pushString(t){const e=n.byteLength(t,"utf8");return this._pushInt(e,u.UTF8_STRING)&&this.pushWrite(t,5,e)}_pushBoolean(t){return this._pushUInt8(t?y:_)}_pushUndefined(t){return this._pushUInt8(E)}_pushArray(t,e){const r=e.length;if(!t._pushInt(r,u.ARRAY))return!1;for(let n=0;n<r;n++)if(!t.pushAny(e[n]))return!1;return!0}_pushTag(t){return this._pushInt(t,u.TAG)}_pushDate(t,e){return t._pushTag(p.DATE_EPOCH)&&t.pushAny(Math.round(e/1e3))}_pushBuffer(t,e){return t._pushInt(e.length,u.BYTE_STRING)&&t.push(e)}_pushNoFilter(t,e){return t._pushBuffer(t,e.slice())}_pushRegexp(t,e){return t._pushTag(p.REGEXP)&&t.pushAny(e.source)}_pushSet(t,e){if(!t._pushInt(e.size,u.ARRAY))return!1;for(const r of e)if(!t.pushAny(r))return!1;return!0}_pushUrl(t,e){return t._pushTag(p.URI)&&t.pushAny(e.format())}_pushBigint(t){let e=p.POS_BIGINT;t.isNegative()&&(t=t.negated().minus(1),e=p.NEG_BIGINT);let r=t.toString(16);r.length%2&&(r="0"+r);const s=n.from(r,"hex");return this._pushTag(e)&&this._pushBuffer(this,s)}_pushBigNumber(t,e){if(e.isNaN())return t._pushNaN();if(!e.isFinite())return t._pushInfinity(e.isNegative()?-1/0:1/0);if(e.isInteger())return t._pushBigint(e);if(!t._pushTag(p.DECIMAL_FRAC)||!t._pushInt(2,u.ARRAY))return!1;const r=e.decimalPlaces(),n=e.multipliedBy(new i(10).pow(r));return!!t._pushIntNum(-r)&&(n.abs().isLessThan(w)?t._pushIntNum(n.toNumber()):t._pushBigint(n))}_pushMap(t,e){return!!t._pushInt(e.size,u.MAP)&&this._pushRawMap(e.size,Array.from(e))}_pushObject(t){if(!t)return this._pushUInt8(m);for(var e=this.semanticTypes.length,r=0;r<e;r++)if(t instanceof this.semanticTypes[r][0])return this.semanticTypes[r][1].call(t,this,t);var n=t.encodeCBOR;if("function"==typeof n)return n.call(t,this);var s=Object.keys(t),i=s.length;return!!this._pushInt(i,u.MAP)&&this._pushRawMap(i,s.map(e=>[e,t[e]]))}_pushRawMap(t,e){e=e.map(function(t){return t[0]=I.encode(t[0]),t}).sort(o.keySorter);for(var r=0;r<t;r++){if(!this.push(e[r][0]))return!1;if(!this.pushAny(e[r][1]))return!1}return!0}write(t){return this.pushAny(t)}pushAny(t){switch(function(t){return{}.toString.call(t).slice(8,-1)}(t)){case"Number":return this._pushNumber(t);case"String":return this._pushString(t);case"Boolean":return this._pushBoolean(t);case"Object":return this._pushObject(t);case"Array":return this._pushArray(this,t);case"Uint8Array":return this._pushBuffer(this,n.isBuffer(t)?t:n.from(t));case"Null":return this._pushUInt8(m);case"Undefined":return this._pushUndefined(t);case"Map":return this._pushMap(this,t);case"Set":return this._pushSet(this,t);case"URL":return this._pushUrl(this,t);case"BigNumber":return this._pushBigNumber(this,t);case"Date":return this._pushDate(this,t);case"RegExp":return this._pushRegexp(this,t);case"Symbol":switch(t){case l.NULL:return this._pushObject(null);case l.UNDEFINED:return this._pushUndefined(void 0);default:throw new Error("Unknown symbol: "+t.toString())}default:throw new Error("Unknown type: "+typeof t+", "+(t?t.toString():""))}}finalize(){if(0===this.offset)return null;for(var t=this.result,e=this.resultLength,r=this.resultMethod,s=this.offset,i=0,o=0;o<s;o++)i+=e[o];var a=n.allocUnsafe(i),u=0,h=0;for(o=0;o<s;o++){switch(h=e[o],r[o]){case 0:t[o].copy(a,u);break;case 1:a.writeUInt8(t[o],u,!0);break;case 2:a.writeUInt16BE(t[o],u,!0);break;case 3:a.writeUInt32BE(t[o],u,!0);break;case 4:a.writeDoubleBE(t[o],u,!0);break;case 5:a.write(t[o],u,h,"utf8");break;default:throw new Error("unkown method")}u+=h}var c=a;return this._reset(),c}_reset(){this.result=[],this.resultMethod=[],this.resultLength=[],this.offset=0}static encode(t){const e=new I;if(!e.pushAny(t))throw new Error("Failed to encode input");return e.finalize()}}t.exports=I},MbHH:function(t,e,r){const n=r("9lTW"),s=r("tjlA").Buffer;function i(t,e){if("00"===t.slice(0,2))throw new Error("invalid RLP: extra zeros");return parseInt(t,e)}function o(t,e){if(t<56)return new s([t+e]);var r=h(t),n=h(e+55+r.length/2);return new s(n+r,"hex")}function a(t){var e,r,n,o,u,h=[],c=t[0];if(c<=127)return{data:t.slice(0,1),remainder:t.slice(1)};if(c<=183){if(e=c-127,n=128===c?new s([]):t.slice(1,e),2===e&&n[0]<128)throw new Error("invalid rlp encoding: byte must be less 0x80");return{data:n,remainder:t.slice(e)}}if(c<=191){if(e=i(t.slice(1,r=c-182).toString("hex"),16),(n=t.slice(r,e+r)).length<e)throw new Error("invalid RLP");return{data:n,remainder:t.slice(e+r)}}if(c<=247){for(o=t.slice(1,e=c-191);o.length;)u=a(o),h.push(u.data),o=u.remainder;return{data:h,remainder:t.slice(e)}}var l=(r=c-246)+(e=i(t.slice(1,r).toString("hex"),16));if(l>t.length)throw new Error("invalid rlp: total length is larger than the data");if(0===(o=t.slice(r,l)).length)throw new Error("invalid rlp, List has a invalid length");for(;o.length;)u=a(o),h.push(u.data),o=u.remainder;return{data:h,remainder:t.slice(l)}}function u(t){return"0x"===t.slice(0,2)}function h(t){var e=t.toString(16);return e.length%2&&(e="0"+e),e}function c(t){if(!s.isBuffer(t))if("string"==typeof t)t=u(t)?new s(((r="string"!=typeof(n=t)?n:u(n)?n.slice(2):n).length%2&&(r="0"+r),r),"hex"):new s(t);else if("number"==typeof t)t?(e=h(t),t=new s(e,"hex")):t=new s([]);else if(null==t)t=new s([]);else{if(!t.toArray)throw new Error("invalid type");t=new s(t.toArray())}var e,r,n;return t}e.encode=function(t){if(t instanceof Array){for(var r=[],n=0;n<t.length;n++)r.push(e.encode(t[n]));var i=s.concat(r);return s.concat([o(i.length,192),i])}return 1===(t=c(t)).length&&t[0]<128?t:s.concat([o(t.length,128),t])},e.decode=function(t,e){if(!t||0===t.length)return new s([]);var r=a(t=c(t));return e?r:(n.equal(r.remainder.length,0,"invalid remainder"),r.data)},e.getLength=function(t){if(!t||0===t.length)return new s([]);var e=(t=c(t))[0];if(e<=127)return t.length;if(e<=183)return e-127;if(e<=191)return e-182;if(e<=247)return e-191;var r=e-246;return r+i(t.slice(1,r).toString("hex"),16)}},PLHu:function(t,e,r){const{buildBitcoinTxRequest:n}=r("6WMX"),{buildEthereumTxRequest:s,buildEthereumMsgRequest:i,ensureHexBuffer:o}=r("xKF7"),a=r("tjlA").Buffer,u=r("lnXz"),h=r("cC09"),c=r("MzeL"),{AES_IV:l,responseCodes:p,responseMsgs:f,VERSION_BYTE:d}=r("L21C"),g=new(0,c.ec)("p256");function y(t){return h.buf(t)>>>0}t.exports={isValidAssetPath:function(t){const e=2147483648,r=[e,2147483649,2147483708],n=[e];return[2147483697,2147483692].indexOf(t[0])>=0&&r.indexOf(t[1])>=0&&n.indexOf(t[2])>=0&&[0,1].indexOf(t[3])>=0},isValidCoinType:function(t){return[2147483648,2147483649,2147483708].indexOf(t[1])>=0},ensureHexBuffer:o,signReqResolver:{BTC:n,ETH:s,ETH_MSG:i},aes256_decrypt:function(t,e){const r=a.from(l),n=new u.ModeOfOperation.cbc(e,r);return a.from(n.decrypt(t))},aes256_encrypt:function(t,e){const r=a.from(l),n=new u.ModeOfOperation.cbc(e,r),s=t.length%16==0?t:u.padding.pkcs7.pad(t);return a.from(n.encrypt(s))},parseDER:function(t){if(48!==t[0]||2!==t[2])return null;let e=3;const r={r:null,s:null},n=t[e];if(e++,r.r=t.slice(e,e+n),e+=n,2!==t[e])return null;e++;const s=t[e];return e++,r.s=t.slice(e,e+s),r},checksum:y,parseLattice1Response:function(t){const e={err:null,data:null},r=a.from(t,"hex");let n=0;const s=r.readUInt8(n);if(n++,s!==d)return e.err="Incorrect protocol version. Please update your SDK",e;const i=r.readUInt8(n);if(n++,0!==i)return e.err="Incorrect response from Lattice1",e;r.readUInt32BE(n),n+=4;const o=r.readUInt16BE(n);n+=2;const u=r.slice(n,n+o);n+=o;const h=u.readUInt8(0);return h!==p.RESP_SUCCESS?(e.err=`Error from device: ${f[h]?f[h]:"Unknown Error"}`,e.responseCode=h,e):(e.data=u.slice(1,u.length),r.readUInt32BE(n)!==y(r.slice(0,r.length-4))?(e.err="Invalid checksum from device response",e.data=null,e):e)},getP256KeyPair:function(t){return g.keyFromPrivate(t,"hex")},getP256KeyPairFromPub:function(t){return g.keyFromPublic(t,"hex")},toPaddedDER:function(t){const e=a.alloc(74);return a.from(t.toDER()).copy(e),e}}},PV6L:function(t,e,r){"use strict";const{URLWithLegacySupport:n,format:s}=r("HwtC");t.exports=(t,e={},r={},i)=>{let o,a=e.protocol?e.protocol.replace(":",""):"http";a=(r[a]||i||a)+":";try{o=new n(t)}catch(h){o={}}const u=Object.assign({},e,{protocol:a||o.protocol,host:e.host||o.host});return new n(t,s(u)).toString()}},UHYx:function(t,e,r){"use strict";const n=r("hb4V"),s=n.MT,i=n.SIMPLE,o=n.SYMS;class a{constructor(t){if("number"!=typeof t)throw new Error("Invalid Simple type: "+typeof t);if(t<0||t>255||(0|t)!==t)throw new Error("value must be a small positive integer: "+t);this.value=t}toString(){return"simple("+this.value+")"}inspect(){return"simple("+this.value+")"}encodeCBOR(t){return t._pushInt(this.value,s.SIMPLE_FLOAT)}static isSimple(t){return t instanceof a}static decode(t,e){switch(null==e&&(e=!0),t){case i.FALSE:return!1;case i.TRUE:return!0;case i.NULL:return e?null:o.NULL;case i.UNDEFINED:return e?void 0:o.UNDEFINED;case-1:if(!e)throw new Error("Invalid BREAK");return o.BREAK;default:return new a(t)}}}t.exports=a},XUzR:function(t,e,r){"use strict";(function(t){e.a=function(e,r,n){void 0===n&&(n=!1);for(var s=n?r.length:e.length,i=t.alloc(s),o=0;o<s;o++)i[o]=e[n?o%e.length:o]&r[o];return i}}).call(this,r("tjlA").Buffer)},XuWj:function(t,e,r){"use strict";const{Buffer:n}=r("tjlA"),s=r("kB5k").BigNumber,i=r("hb4V"),o=i.SHIFT32,a=i.SHIFT16;e.parseHalf=function(t){var e,r,n;return n=128&t[0]?-1:1,r=(3&t[0])<<8|t[1],(e=(124&t[0])>>2)?31===e?n*(r?NaN:Infinity):n*Math.pow(2,e-25)*(1024+r):5.960464477539063e-8*n*r},e.arrayBufferToBignumber=function(t){const e=t.byteLength;let r="";for(let s=0;s<e;s++)r+=(n=t[s])<16?"0"+n.toString(16):n.toString(16);var n;return new s(r,16)},e.buildMap=t=>{const e=new Map,r=Object.keys(t),n=r.length;for(let s=0;s<n;s++)e.set(r[s],t[r[s]]);return e},e.buildInt32=(t,e)=>t*a+e,e.buildInt64=(t,r,n,i)=>{const a=e.buildInt32(t,r),u=e.buildInt32(n,i);return a>2097151?new s(a).times(o).plus(u):a*o+u},e.writeHalf=function(t,e){const r=n.allocUnsafe(4);r.writeFloatBE(e,0);const s=r.readUInt32BE(0);if(0!=(8191&s))return!1;var i=s>>16&32768;const o=s>>23&255,a=8388607&s;if(o>=113&&o<=142)i+=(o-112<<10)+(a>>13);else{if(!(o>=103&&o<113))return!1;if(a&(1<<126-o)-1)return!1;i+=a+8388608>>126-o}return t.writeUInt16BE(i,0),!0},e.keySorter=function(t,e){var r=t[0].byteLength,n=e[0].byteLength;return r>n?1:n>r?-1:t[0].compare(e[0])},e.isNegativeZero=t=>0===t&&1/t<0,e.nextPowerOf2=t=>{let e=0;if(t&&!(t&t-1))return t;for(;0!==t;)t>>=1,e+=1;return 1<<e}},YnKP:function(t,e,r){"use strict";(function(t){e.a=function(e,r,n){void 0===n&&(n=!1);for(var s=n?r.length:e.length,i=t.alloc(s),o=0;o<s;o++)i[o]=e[n?o%e.length:o]|r[o];return i}}).call(this,r("tjlA").Buffer)},aFzb:function(t,e,r){(function(e){const n=r("HEbw"),s=r("+qE3").EventEmitter,i=r("4Mn8"),o="Lattice Hardware",a=2147483648;class u extends s{constructor(t={}){super(),this.type=o,this._resetDefaults(),this.deserialize(t)}deserialize(t={}){return t.creds&&(this.creds=t.creds),t.accounts&&(this.accounts=t.accounts),t.walletUID&&(this.walletUID=t.walletUID),t.name&&(this.name=t.name),t.network&&(this.network=t.network),Promise.resolve()}serialize(){return Promise.resolve({creds:this.creds,accounts:this.accounts,walletUID:this.walletUID,name:this.name,network:this.network})}isUnlocked(){return this._hasCreds()&&this._hasSession()}setHdPath(){console.warn("setHdPath not implemented.")}unlock(t=!0){return new Promise((e,r)=>{this._getCreds().then(t=>(t&&(this.creds.deviceID=t.deviceID,this.creds.password=t.password),this._initSession())).then(()=>this._connect(t)).then(()=>e("Unlocked")).catch(t=>r(new Error(t)))})}addAccounts(t=1){return new Promise((e,r)=>-1e3===t?(this.forgetDevice(),e([])):t<=0?r("Number of accounts to add must be a positive number."):void this.unlock().then(()=>this._fetchAddresses(t,this.unlockedAccount)).then(r=>(this.accounts.splice(this.unlockedAccount,t),this.accounts.splice(this.unlockedAccount,0,...r),e(this.accounts))).catch(t=>r(new Error(t))))}getAccounts(){return Promise.resolve(this.accounts?this.accounts.slice():[].slice())}signTransaction(t,r){return new Promise((n,s)=>{this._unlockAndFindAccount(t).then(t=>{const e={chainId:r.getChainId()||1,nonce:Number(`0x${r.nonce.toString("hex")}`)||0,gasPrice:Number(`0x${r.gasPrice.toString("hex")}`),gasLimit:Number(`0x${r.gasLimit.toString("hex")}`),to:`0x${r.to.toString("hex")}`,value:Number(`0x${r.value.toString("hex")}`),data:0===r.data.length?null:`0x${r.data.toString("hex")}`,signerPath:[2147483692,2147483708,a,0,t]};return this._signTxData(e)}).then(t=>t.sig&&t.sig.v&&t.sig.r&&t.sig.s?(r.v=t.sig.v,r.r=e.from(t.sig.r,"hex"),r.s=e.from(t.sig.s,"hex"),n(r)):s(Error("No signature returned"))).catch(t=>s(new Error(t)))})}signPersonalMessage(t,e){return this.signMessage(t,{payload:e,protocol:"signPersonal"})}signMessage(t,e){return new Promise((r,n)=>{this._unlockAndFindAccount(t).then(t=>{const{payload:s,protocol:i}=e;if(!s||!i)return n("`payload` and `protocol` fields must be included in the request");const o={currency:"ETH_MSG",data:{protocol:i,payload:s,signerPath:[2147483692,2147483708,a,0,t]}};if(!this._hasSession())return n("No SDK session started. Cannot sign transaction.");this.sdkSession.sign(o,(t,e)=>{if(t)return n(new Error(t));if(!e.sig)return n("No signature returned");let s=(e.sig.v-27).toString(16);return s.length<2&&(s=`0${s}`),r(`0x${e.sig.r}${e.sig.s}${s}`)})})})}exportAccount(t){return Promise.reject(Error("exportAccount not supported by this device"))}removeAccount(t){this.forgetDevice()}getFirstPage(){return this.page=0,this._getPage(1)}getNextPage(){return this.getFirstPage()}getPreviousPage(){return this.getFirstPage()}setAccountToUnlock(t){this.unlockedAccount=parseInt(t,10)}forgetDevice(){this._resetDefaults()}_unlockAndFindAccount(t){return new Promise((e,r)=>{this.unlock(!1).then(()=>this.getAccounts()).then(n=>{let s=null;return n.forEach((e,r)=>{t.toLowerCase()===e.toLowerCase()&&(s=r)}),null===s?r("Signer not present"):e(s)}).catch(t=>r(t))})}_resetDefaults(){this.accounts=[],this.isLocked=!0,this.creds={deviceID:null,password:null},this.walletUID=null,this.sdkSession=null,this.page=0,this.unlockedAccount=0,this.network=null}_getCreds(){return new Promise((t,e)=>{if(this._hasCreds())return t();const r=this.name?this.name:"Unknown";let n="https://wallet.gridplus.io";switch(this.network){case"rinkeby":n="https://gridplus-web-wallet-dev.herokuapp.com"}let s=`${n}?keyring=${r}`;this.network&&(s+=`&network=${this.network}`),window.open(s).postMessage("GET_LATTICE_CREDS",n),window.addEventListener("message",function(r){if(r.origin===n)try{const n=JSON.parse(r.data);return n.deviceID&&n.password?t(n):e(Error("Invalid credentials returned from Lattice."))}catch(s){return e(s)}},!1)})}_connect(t){return new Promise((e,r)=>{this.sdkSession.connect(this.creds.deviceID,n=>{if(n)return r(n);const s=this.sdkSession.getActiveWallet();if(!s||!s.uid)return r("No active wallet");const i=s.uid.toString("hex");if(i!=this.walletUID){if(!1===t)return r("Wallet has changed! Please reconnect.");this.accounts=[],this.walletUID=i}return e()})})}_initSession(){return new Promise((t,e)=>{if(this._hasSession())return t();try{let e="https://signing.gridpl.us";this.network&&"mainnet"!==this.network&&(e="https://signing.staging-gridpl.us");const r={name:this.name,baseUrl:e,crypto:n,timeout:12e4,privKey:this._genSessionKey(),network:this.network};return this.sdkSession=new i.Client(r),t()}catch(r){return e(r)}})}_fetchAddresses(t=1,e=0){return new Promise((r,n)=>this._hasSession()?e>this.accounts.length?n(`Requested address is out of bounds. You may only request index <${this.accounts.length}`):this.accounts.length>e?r(this.accounts.slice(e,t)):void this.sdkSession.getAddresses({currency:"ETH",startPath:[2147483692,2147483708,a,0,e],n:t},(t,e)=>t?n(Error(`Error getting addresses: ${t}`)):e.length<1?n("No addresses returned"):r(e)):n("No SDK session started. Cannot fetch addresses."))}_signTxData(t){return new Promise((e,r)=>{if(!this._hasSession())return r("No SDK session started. Cannot sign transaction.");this.sdkSession.sign({currency:"ETH",data:t},(t,n)=>t?r(t):n.tx?e(n):r("No transaction payload returned."))})}_getPage(t=1){return new Promise((e,r)=>{this.page+=t,this.page<=0&&(this.page=1);const n=5*(this.page-1);this.unlock().then(()=>this._fetchAddresses(1,0)).then(t=>{const r=[];return t.forEach((t,e)=>{r.push({address:t,balance:null,index:n+e})}),e(r)}).catch(t=>r(t))})}_hasCreds(){return null!==this.creds.deviceID&&null!==this.creds.password&&this.name}_hasSession(){return this.sdkSession&&this.walletUID}_genSessionKey(){if(!this._hasCreds())throw new Error("No credentials -- cannot create session key!");const t=e.concat([e.from(this.creds.password),e.from(this.creds.deviceID),e.from(this.name)]);return n.createHash("sha256").update(t).digest()}}u.type=o,t.exports=u}).call(this,r("tjlA").Buffer)},b3gk:function(t,e,r){"use strict";var n=r("mObS"),s=r("BumV");t.exports=s(function(t){var e=n("sha256").update(t).digest();return n("sha256").update(e).digest()})},cpc2:function(t,e,r){function n(t){if(t)return function(t){for(var e in n.prototype)t[e]=n.prototype[e];return t}(t)}t.exports=n,n.prototype.on=n.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+t]=this._callbacks["$"+t]||[]).push(e),this},n.prototype.once=function(t,e){function r(){this.off(t,r),e.apply(this,arguments)}return r.fn=e,this.on(t,r),this},n.prototype.off=n.prototype.removeListener=n.prototype.removeAllListeners=n.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var r,n=this._callbacks["$"+t];if(!n)return this;if(1==arguments.length)return delete this._callbacks["$"+t],this;for(var s=0;s<n.length;s++)if((r=n[s])===e||r.fn===e){n.splice(s,1);break}return 0===n.length&&delete this._callbacks["$"+t],this},n.prototype.emit=function(t){this._callbacks=this._callbacks||{};for(var e=new Array(arguments.length-1),r=this._callbacks["$"+t],n=1;n<arguments.length;n++)e[n-1]=arguments[n];if(r){n=0;for(var s=(r=r.slice(0)).length;n<s;++n)r[n].apply(this,e)}return this},n.prototype.listeners=function(t){return this._callbacks=this._callbacks||{},this._callbacks["$"+t]||[]},n.prototype.hasListeners=function(t){return!!this.listeners(t).length}},f7RY:function(t,e,r){"use strict";(function(t){e.a=function(e){for(var r=t.alloc(e.length),n=0;n<e.length;n++)r[n]=~e[n];return r}}).call(this,r("tjlA").Buffer)},gYz7:function(t,e){t.exports=function(t,e,r){"use asm";var n=new t.Uint8Array(r);var s=e.pushInt;var i=e.pushInt32;var o=e.pushInt32Neg;var a=e.pushInt64;var u=e.pushInt64Neg;var h=e.pushFloat;var c=e.pushFloatSingle;var l=e.pushFloatDouble;var p=e.pushTrue;var f=e.pushFalse;var d=e.pushUndefined;var g=e.pushNull;var y=e.pushInfinity;var _=e.pushInfinityNeg;var E=e.pushNaN;var m=e.pushNaNNeg;var w=e.pushArrayStart;var S=e.pushArrayStartFixed;var v=e.pushArrayStartFixed32;var b=e.pushArrayStartFixed64;var I=e.pushObjectStart;var T=e.pushObjectStartFixed;var A=e.pushObjectStartFixed32;var R=e.pushObjectStartFixed64;var x=e.pushByteString;var P=e.pushByteStringStart;var N=e.pushUtf8String;var U=e.pushUtf8StringStart;var D=e.pushSimpleUnassigned;var k=e.pushTagStart;var B=e.pushTagStart4;var L=e.pushTagStart8;var C=e.pushTagUnassigned;var F=e.pushBreak;var O=t.Math.pow;var M=0;var H=0;var z=0;function j(t){t=t|0;M=0;H=t;while((M|0)<(H|0)){z=Xt[n[M]&255](n[M]|0)|0;if((z|0)>0){break}}return z|0}function $(t){t=t|0;if(((M|0)+(t|0)|0)<(H|0)){return 0}return 1}function q(t){t=t|0;return n[t|0]<<8|n[t+1|0]|0}function G(t){t=t|0;return n[t|0]<<24|n[t+1|0]<<16|n[t+2|0]<<8|n[t+3|0]|0}function W(t){t=t|0;s(t|0);M=M+1|0;return 0}function K(t){t=t|0;if($(1)|0){return 1}s(n[M+1|0]|0);M=M+2|0;return 0}function Y(t){t=t|0;if($(2)|0){return 1}s(q(M+1|0)|0);M=M+3|0;return 0}function V(t){t=t|0;if($(4)|0){return 1}i(q(M+1|0)|0,q(M+3|0)|0);M=M+5|0;return 0}function X(t){t=t|0;if($(8)|0){return 1}a(q(M+1|0)|0,q(M+3|0)|0,q(M+5|0)|0,q(M+7|0)|0);M=M+9|0;return 0}function J(t){t=t|0;s(-1-(t-32|0)|0);M=M+1|0;return 0}function Q(t){t=t|0;if($(1)|0){return 1}s(-1-(n[M+1|0]|0)|0);M=M+2|0;return 0}function Z(t){t=t|0;var e=0;if($(2)|0){return 1}e=q(M+1|0)|0;s(-1-(e|0)|0);M=M+3|0;return 0}function tt(t){t=t|0;if($(4)|0){return 1}o(q(M+1|0)|0,q(M+3|0)|0);M=M+5|0;return 0}function et(t){t=t|0;if($(8)|0){return 1}u(q(M+1|0)|0,q(M+3|0)|0,q(M+5|0)|0,q(M+7|0)|0);M=M+9|0;return 0}function rt(t){t=t|0;var e=0;var r=0;var n=0;n=t-64|0;if($(n|0)|0){return 1}e=M+1|0;r=(M+1|0)+(n|0)|0;x(e|0,r|0);M=r|0;return 0}function nt(t){t=t|0;var e=0;var r=0;var s=0;if($(1)|0){return 1}s=n[M+1|0]|0;e=M+2|0;r=(M+2|0)+(s|0)|0;if($(s+1|0)|0){return 1}x(e|0,r|0);M=r|0;return 0}function st(t){t=t|0;var e=0;var r=0;var n=0;if($(2)|0){return 1}n=q(M+1|0)|0;e=M+3|0;r=(M+3|0)+(n|0)|0;if($(n+2|0)|0){return 1}x(e|0,r|0);M=r|0;return 0}function it(t){t=t|0;var e=0;var r=0;var n=0;if($(4)|0){return 1}n=G(M+1|0)|0;e=M+5|0;r=(M+5|0)+(n|0)|0;if($(n+4|0)|0){return 1}x(e|0,r|0);M=r|0;return 0}function ot(t){t=t|0;return 1}function at(t){t=t|0;P();M=M+1|0;return 0}function ut(t){t=t|0;var e=0;var r=0;var n=0;n=t-96|0;if($(n|0)|0){return 1}e=M+1|0;r=(M+1|0)+(n|0)|0;N(e|0,r|0);M=r|0;return 0}function ht(t){t=t|0;var e=0;var r=0;var s=0;if($(1)|0){return 1}s=n[M+1|0]|0;e=M+2|0;r=(M+2|0)+(s|0)|0;if($(s+1|0)|0){return 1}N(e|0,r|0);M=r|0;return 0}function ct(t){t=t|0;var e=0;var r=0;var n=0;if($(2)|0){return 1}n=q(M+1|0)|0;e=M+3|0;r=(M+3|0)+(n|0)|0;if($(n+2|0)|0){return 1}N(e|0,r|0);M=r|0;return 0}function lt(t){t=t|0;var e=0;var r=0;var n=0;if($(4)|0){return 1}n=G(M+1|0)|0;e=M+5|0;r=(M+5|0)+(n|0)|0;if($(n+4|0)|0){return 1}N(e|0,r|0);M=r|0;return 0}function pt(t){t=t|0;return 1}function ft(t){t=t|0;U();M=M+1|0;return 0}function dt(t){t=t|0;S(t-128|0);M=M+1|0;return 0}function gt(t){t=t|0;if($(1)|0){return 1}S(n[M+1|0]|0);M=M+2|0;return 0}function yt(t){t=t|0;if($(2)|0){return 1}S(q(M+1|0)|0);M=M+3|0;return 0}function _t(t){t=t|0;if($(4)|0){return 1}v(q(M+1|0)|0,q(M+3|0)|0);M=M+5|0;return 0}function Et(t){t=t|0;if($(8)|0){return 1}b(q(M+1|0)|0,q(M+3|0)|0,q(M+5|0)|0,q(M+7|0)|0);M=M+9|0;return 0}function mt(t){t=t|0;w();M=M+1|0;return 0}function wt(t){t=t|0;var e=0;e=t-160|0;if($(e|0)|0){return 1}T(e|0);M=M+1|0;return 0}function St(t){t=t|0;if($(1)|0){return 1}T(n[M+1|0]|0);M=M+2|0;return 0}function vt(t){t=t|0;if($(2)|0){return 1}T(q(M+1|0)|0);M=M+3|0;return 0}function bt(t){t=t|0;if($(4)|0){return 1}A(q(M+1|0)|0,q(M+3|0)|0);M=M+5|0;return 0}function It(t){t=t|0;if($(8)|0){return 1}R(q(M+1|0)|0,q(M+3|0)|0,q(M+5|0)|0,q(M+7|0)|0);M=M+9|0;return 0}function Tt(t){t=t|0;I();M=M+1|0;return 0}function At(t){t=t|0;k(t-192|0|0);M=M+1|0;return 0}function Rt(t){t|0;k(t|0);M=M+1|0;return 0}function xt(t){t|0;k(t|0);M=M+1|0;return 0}function Pt(t){t|0;k(t|0);M=M+1|0;return 0}function Nt(t){t|0;k(t|0);M=M+1|0;return 0}function Ut(t){t=t|0;k(t-192|0|0);M=M+1|0;return 0}function Dt(t){t|0;k(t|0);M=M+1|0;return 0}function kt(t){t|0;k(t|0);M=M+1|0;return 0}function Bt(t){t|0;k(t|0);M=M+1|0;return 0}function Lt(t){t=t|0;if($(1)|0){return 1}k(n[M+1|0]|0);M=M+2|0;return 0}function Ct(t){t=t|0;if($(2)|0){return 1}k(q(M+1|0)|0);M=M+3|0;return 0}function Ft(t){t=t|0;if($(4)|0){return 1}B(q(M+1|0)|0,q(M+3|0)|0);M=M+5|0;return 0}function Ot(t){t=t|0;if($(8)|0){return 1}L(q(M+1|0)|0,q(M+3|0)|0,q(M+5|0)|0,q(M+7|0)|0);M=M+9|0;return 0}function Mt(t){t=t|0;D((t|0)-224|0);M=M+1|0;return 0}function Ht(t){t=t|0;f();M=M+1|0;return 0}function zt(t){t=t|0;p();M=M+1|0;return 0}function jt(t){t=t|0;g();M=M+1|0;return 0}function $t(t){t=t|0;d();M=M+1|0;return 0}function qt(t){t=t|0;if($(1)|0){return 1}D(n[M+1|0]|0);M=M+2|0;return 0}function Gt(t){t=t|0;var e=0;var r=0;var s=1.0;var i=0.0;var o=0.0;var a=0.0;if($(2)|0){return 1}e=n[M+1|0]|0;r=n[M+2|0]|0;if((e|0)&0x80){s=-1.0}i=+(((e|0)&0x7C)>>2);o=+(((e|0)&0x03)<<8|r);if(+i==0.0){h(+(+s*+5.9604644775390625e-8*+o))}else if(+i==31.0){if(+s==1.0){if(+o>0.0){E()}else{y()}}else{if(+o>0.0){m()}else{_()}}}else{h(+(+s*O(+2,+(+i-25.0))*+(1024.0+o)))}M=M+3|0;return 0}function Wt(t){t=t|0;if($(4)|0){return 1}c(n[M+1|0]|0,n[M+2|0]|0,n[M+3|0]|0,n[M+4|0]|0);M=M+5|0;return 0}function Kt(t){t=t|0;if($(8)|0){return 1}l(n[M+1|0]|0,n[M+2|0]|0,n[M+3|0]|0,n[M+4|0]|0,n[M+5|0]|0,n[M+6|0]|0,n[M+7|0]|0,n[M+8|0]|0);M=M+9|0;return 0}function Yt(t){t=t|0;return 1}function Vt(t){t=t|0;F();M=M+1|0;return 0}var Xt=[W,W,W,W,W,W,W,W,W,W,W,W,W,W,W,W,W,W,W,W,W,W,W,W,K,Y,V,X,Yt,Yt,Yt,Yt,J,J,J,J,J,J,J,J,J,J,J,J,J,J,J,J,J,J,J,J,J,J,J,J,Q,Z,tt,et,Yt,Yt,Yt,Yt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,nt,st,it,ot,Yt,Yt,Yt,at,ut,ut,ut,ut,ut,ut,ut,ut,ut,ut,ut,ut,ut,ut,ut,ut,ut,ut,ut,ut,ut,ut,ut,ut,ht,ct,lt,pt,Yt,Yt,Yt,ft,dt,dt,dt,dt,dt,dt,dt,dt,dt,dt,dt,dt,dt,dt,dt,dt,dt,dt,dt,dt,dt,dt,dt,dt,gt,yt,_t,Et,Yt,Yt,Yt,mt,wt,wt,wt,wt,wt,wt,wt,wt,wt,wt,wt,wt,wt,wt,wt,wt,wt,wt,wt,wt,wt,wt,wt,wt,St,vt,bt,It,Yt,Yt,Yt,Tt,At,At,At,At,At,At,Ut,Ut,Ut,Ut,Ut,Ut,Ut,Ut,Ut,Ut,Ut,Ut,Ut,Ut,Ut,Ut,Ut,Ut,Lt,Ct,Ft,Ot,Yt,Yt,Yt,Yt,Mt,Mt,Mt,Mt,Mt,Mt,Mt,Mt,Mt,Mt,Mt,Mt,Mt,Mt,Mt,Mt,Mt,Mt,Mt,Mt,Ht,zt,jt,$t,qt,Gt,Wt,Kt,Yt,Yt,Yt,Vt];return{parse:j}}},hDHj:function(t,e,r){"use strict";(function(e){const{Buffer:n}=r("tjlA"),s=r("kVK+"),i=r("kB5k").BigNumber,o=r("gYz7"),a=r("XuWj"),u=r("hb4V"),h=r("UHYx"),c=r("IrRL"),{URL:l}=r("Fq86");class p{constructor(t){(t=t||{}).size=!t.size||t.size<65536?65536:a.nextPowerOf2(t.size),this._heap=new ArrayBuffer(t.size),this._heap8=new Uint8Array(this._heap),this._buffer=n.from(this._heap),this._reset(),this._knownTags=Object.assign({0:t=>new Date(t),1:t=>new Date(1e3*t),2:t=>a.arrayBufferToBignumber(t),3:t=>u.NEG_ONE.minus(a.arrayBufferToBignumber(t)),4:t=>u.TEN.pow(t[0]).times(t[1]),5:t=>u.TWO.pow(t[0]).times(t[1]),32:t=>new l(t),35:t=>new RegExp(t)},t.tags),this.parser=o(e,{log:console.log.bind(console),pushInt:this.pushInt.bind(this),pushInt32:this.pushInt32.bind(this),pushInt32Neg:this.pushInt32Neg.bind(this),pushInt64:this.pushInt64.bind(this),pushInt64Neg:this.pushInt64Neg.bind(this),pushFloat:this.pushFloat.bind(this),pushFloatSingle:this.pushFloatSingle.bind(this),pushFloatDouble:this.pushFloatDouble.bind(this),pushTrue:this.pushTrue.bind(this),pushFalse:this.pushFalse.bind(this),pushUndefined:this.pushUndefined.bind(this),pushNull:this.pushNull.bind(this),pushInfinity:this.pushInfinity.bind(this),pushInfinityNeg:this.pushInfinityNeg.bind(this),pushNaN:this.pushNaN.bind(this),pushNaNNeg:this.pushNaNNeg.bind(this),pushArrayStart:this.pushArrayStart.bind(this),pushArrayStartFixed:this.pushArrayStartFixed.bind(this),pushArrayStartFixed32:this.pushArrayStartFixed32.bind(this),pushArrayStartFixed64:this.pushArrayStartFixed64.bind(this),pushObjectStart:this.pushObjectStart.bind(this),pushObjectStartFixed:this.pushObjectStartFixed.bind(this),pushObjectStartFixed32:this.pushObjectStartFixed32.bind(this),pushObjectStartFixed64:this.pushObjectStartFixed64.bind(this),pushByteString:this.pushByteString.bind(this),pushByteStringStart:this.pushByteStringStart.bind(this),pushUtf8String:this.pushUtf8String.bind(this),pushUtf8StringStart:this.pushUtf8StringStart.bind(this),pushSimpleUnassigned:this.pushSimpleUnassigned.bind(this),pushTagUnassigned:this.pushTagUnassigned.bind(this),pushTagStart:this.pushTagStart.bind(this),pushTagStart4:this.pushTagStart4.bind(this),pushTagStart8:this.pushTagStart8.bind(this),pushBreak:this.pushBreak.bind(this)},this._heap)}get _depth(){return this._parents.length}get _currentParent(){return this._parents[this._depth-1]}get _ref(){return this._currentParent.ref}_closeParent(){var t=this._parents.pop();if(t.length>0)throw new Error(`Missing ${t.length} elements`);switch(t.type){case u.PARENT.TAG:this._push(this.createTag(t.ref[0],t.ref[1]));break;case u.PARENT.BYTE_STRING:this._push(this.createByteString(t.ref,t.length));break;case u.PARENT.UTF8_STRING:this._push(this.createUtf8String(t.ref,t.length));break;case u.PARENT.MAP:if(t.values%2>0)throw new Error("Odd number of elements in the map");this._push(this.createMap(t.ref,t.length));break;case u.PARENT.OBJECT:if(t.values%2>0)throw new Error("Odd number of elements in the map");this._push(this.createObject(t.ref,t.length));break;case u.PARENT.ARRAY:this._push(this.createArray(t.ref,t.length))}this._currentParent&&this._currentParent.type===u.PARENT.TAG&&this._dec()}_dec(){const t=this._currentParent;t.length<0||(t.length--,0===t.length&&this._closeParent())}_push(t,e){const r=this._currentParent;switch(r.values++,r.type){case u.PARENT.ARRAY:case u.PARENT.BYTE_STRING:case u.PARENT.UTF8_STRING:r.length>-1?this._ref[this._ref.length-r.length]=t:this._ref.push(t),this._dec();break;case u.PARENT.OBJECT:null!=r.tmpKey?(this._ref[r.tmpKey]=t,r.tmpKey=null,this._dec()):(r.tmpKey=t,"string"!=typeof r.tmpKey&&(r.type=u.PARENT.MAP,r.ref=a.buildMap(r.ref)));break;case u.PARENT.MAP:null!=r.tmpKey?(this._ref.set(r.tmpKey,t),r.tmpKey=null,this._dec()):r.tmpKey=t;break;case u.PARENT.TAG:this._ref.push(t),e||this._dec();break;default:throw new Error("Unknown parent type")}}_createParent(t,e,r){this._parents[this._depth]={type:e,length:r,ref:t,values:0,tmpKey:null}}_reset(){this._res=[],this._parents=[{type:u.PARENT.ARRAY,length:-1,ref:this._res,values:0,tmpKey:null}]}createTag(t,e){const r=this._knownTags[t];return r?r(e):new c(t,e)}createMap(t,e){return t}createObject(t,e){return t}createArray(t,e){return t}createByteString(t,e){return n.concat(t)}createByteStringFromHeap(t,e){return t===e?n.alloc(0):n.from(this._heap.slice(t,e))}createInt(t){return t}createInt32(t,e){return a.buildInt32(t,e)}createInt64(t,e,r,n){return a.buildInt64(t,e,r,n)}createFloat(t){return t}createFloatSingle(t,e,r,n){return s.read([t,e,r,n],0,!1,23,4)}createFloatDouble(t,e,r,n,i,o,a,u){return s.read([t,e,r,n,i,o,a,u],0,!1,52,8)}createInt32Neg(t,e){return-1-a.buildInt32(t,e)}createInt64Neg(t,e,r,n){const s=a.buildInt32(t,e),o=a.buildInt32(r,n);return s>u.MAX_SAFE_HIGH?u.NEG_ONE.minus(new i(s).times(u.SHIFT32).plus(o)):-1-(s*u.SHIFT32+o)}createTrue(){return!0}createFalse(){return!1}createNull(){return null}createUndefined(){}createInfinity(){return 1/0}createInfinityNeg(){return-1/0}createNaN(){return NaN}createNaNNeg(){return NaN}createUtf8String(t,e){return t.join("")}createUtf8StringFromHeap(t,e){return t===e?"":this._buffer.toString("utf8",t,e)}createSimpleUnassigned(t){return new h(t)}pushInt(t){this._push(this.createInt(t))}pushInt32(t,e){this._push(this.createInt32(t,e))}pushInt64(t,e,r,n){this._push(this.createInt64(t,e,r,n))}pushFloat(t){this._push(this.createFloat(t))}pushFloatSingle(t,e,r,n){this._push(this.createFloatSingle(t,e,r,n))}pushFloatDouble(t,e,r,n,s,i,o,a){this._push(this.createFloatDouble(t,e,r,n,s,i,o,a))}pushInt32Neg(t,e){this._push(this.createInt32Neg(t,e))}pushInt64Neg(t,e,r,n){this._push(this.createInt64Neg(t,e,r,n))}pushTrue(){this._push(this.createTrue())}pushFalse(){this._push(this.createFalse())}pushNull(){this._push(this.createNull())}pushUndefined(){this._push(this.createUndefined())}pushInfinity(){this._push(this.createInfinity())}pushInfinityNeg(){this._push(this.createInfinityNeg())}pushNaN(){this._push(this.createNaN())}pushNaNNeg(){this._push(this.createNaNNeg())}pushArrayStart(){this._createParent([],u.PARENT.ARRAY,-1)}pushArrayStartFixed(t){this._createArrayStartFixed(t)}pushArrayStartFixed32(t,e){const r=a.buildInt32(t,e);this._createArrayStartFixed(r)}pushArrayStartFixed64(t,e,r,n){const s=a.buildInt64(t,e,r,n);this._createArrayStartFixed(s)}pushObjectStart(){this._createObjectStartFixed(-1)}pushObjectStartFixed(t){this._createObjectStartFixed(t)}pushObjectStartFixed32(t,e){const r=a.buildInt32(t,e);this._createObjectStartFixed(r)}pushObjectStartFixed64(t,e,r,n){const s=a.buildInt64(t,e,r,n);this._createObjectStartFixed(s)}pushByteStringStart(){this._parents[this._depth]={type:u.PARENT.BYTE_STRING,length:-1,ref:[],values:0,tmpKey:null}}pushByteString(t,e){this._push(this.createByteStringFromHeap(t,e))}pushUtf8StringStart(){this._parents[this._depth]={type:u.PARENT.UTF8_STRING,length:-1,ref:[],values:0,tmpKey:null}}pushUtf8String(t,e){this._push(this.createUtf8StringFromHeap(t,e))}pushSimpleUnassigned(t){this._push(this.createSimpleUnassigned(t))}pushTagStart(t){this._parents[this._depth]={type:u.PARENT.TAG,length:1,ref:[t]}}pushTagStart4(t,e){this.pushTagStart(a.buildInt32(t,e))}pushTagStart8(t,e,r,n){this.pushTagStart(a.buildInt64(t,e,r,n))}pushTagUnassigned(t){this._push(this.createTag(t))}pushBreak(){if(this._currentParent.length>-1)throw new Error("Unexpected break");this._closeParent()}_createObjectStartFixed(t){0!==t?this._createParent({},u.PARENT.OBJECT,t):this._push(this.createObject({}))}_createArrayStartFixed(t){0!==t?this._createParent(new Array(t),u.PARENT.ARRAY,t):this._push(this.createArray([]))}_decode(t){if(0===t.byteLength)throw new Error("Input too short");this._reset(),this._heap8.set(t);const e=this.parser.parse(t.byteLength);if(this._depth>1){for(;0===this._currentParent.length;)this._closeParent();if(this._depth>1)throw new Error("Undeterminated nesting")}if(e>0)throw new Error("Failed to parse");if(0===this._res.length)throw new Error("No valid result")}decodeFirst(t){return this._decode(t),this._res[0]}decodeAll(t){return this._decode(t),this._res}static decode(t,e){return"string"==typeof t&&(t=n.from(t,e||"hex")),new p({size:t.length}).decodeFirst(t)}static decodeAll(t,e){return"string"==typeof t&&(t=n.from(t,e||"hex")),new p({size:t.length}).decodeAll(t)}}p.decodeFirst=p.decode,t.exports=p}).call(this,r("wg4m"))},"hb/F":function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.bech32m=e.bech32=void 0;const n="qpzry9x8gf2tvdw0s3jn54khce6mua7l",s={};for(let p=0;p<n.length;p++){const t=n.charAt(p);s[t]=p}function i(t){const e=t>>25;return(33554431&t)<<5^996825010&-(e>>0&1)^642813549&-(e>>1&1)^513874426&-(e>>2&1)^1027748829&-(e>>3&1)^705979059&-(e>>4&1)}function o(t){let e=1;for(let r=0;r<t.length;++r){const n=t.charCodeAt(r);if(n<33||n>126)return"Invalid prefix ("+t+")";e=i(e)^n>>5}e=i(e);for(let r=0;r<t.length;++r){const n=t.charCodeAt(r);e=i(e)^31&n}return e}function a(t,e,r,n){let s=0,i=0;const o=(1<<r)-1,a=[];for(let u=0;u<t.length;++u)for(s=s<<e|t[u],i+=e;i>=r;)i-=r,a.push(s>>i&o);if(n)i>0&&a.push(s<<r-i&o);else{if(i>=e)return"Excess padding";if(s<<r-i&o)return"Non-zero padding"}return a}function u(t){return a(t,8,5,!0)}function h(t){const e=a(t,5,8,!1);if(Array.isArray(e))return e}function c(t){const e=a(t,5,8,!1);if(Array.isArray(e))return e;throw new Error(e)}function l(t){let e;function r(t,r){if(t.length<8)return t+" too short";if(t.length>(r=r||90))return"Exceeds length limit";const n=t.toLowerCase(),a=t.toUpperCase();if(t!==n&&t!==a)return"Mixed-case string "+t;const u=(t=n).lastIndexOf("1");if(-1===u)return"No separator character for "+t;if(0===u)return"Missing prefix for "+t;const h=t.slice(0,u),c=t.slice(u+1);if(c.length<6)return"Data too short";let l=o(h);if("string"==typeof l)return l;const p=[];for(let e=0;e<c.length;++e){const t=c.charAt(e),r=s[t];if(void 0===r)return"Unknown character "+t;l=i(l)^r,e+6>=c.length||p.push(r)}return l!==e?"Invalid checksum for "+t:{prefix:h,words:p}}return e="bech32"===t?1:734539939,{decodeUnsafe:function(t,e){const n=r(t,e);if("object"==typeof n)return n},decode:function(t,e){const n=r(t,e);if("object"==typeof n)return n;throw new Error(n)},encode:function(t,r,s){if(t.length+7+r.length>(s=s||90))throw new TypeError("Exceeds length limit");let a=o(t=t.toLowerCase());if("string"==typeof a)throw new Error(a);let u=t+"1";for(let e=0;e<r.length;++e){const t=r[e];if(t>>5!=0)throw new Error("Non 5-bit word");a=i(a)^t,u+=n.charAt(t)}for(let e=0;e<6;++e)a=i(a);a^=e;for(let e=0;e<6;++e)u+=n.charAt(a>>5*(5-e)&31);return u},toWords:u,fromWordsUnsafe:h,fromWords:c}}e.bech32=l("bech32"),e.bech32m=l("bech32m")},hb4V:function(t,e,r){"use strict";const n=r("kB5k").BigNumber;e.MT={POS_INT:0,NEG_INT:1,BYTE_STRING:2,UTF8_STRING:3,ARRAY:4,MAP:5,TAG:6,SIMPLE_FLOAT:7},e.TAG={DATE_STRING:0,DATE_EPOCH:1,POS_BIGINT:2,NEG_BIGINT:3,DECIMAL_FRAC:4,BIGFLOAT:5,BASE64URL_EXPECTED:21,BASE64_EXPECTED:22,BASE16_EXPECTED:23,CBOR:24,URI:32,BASE64URL:33,BASE64:34,REGEXP:35,MIME:36},e.NUMBYTES={ZERO:0,ONE:24,TWO:25,FOUR:26,EIGHT:27,INDEFINITE:31},e.SIMPLE={FALSE:20,TRUE:21,NULL:22,UNDEFINED:23},e.SYMS={NULL:Symbol("null"),UNDEFINED:Symbol("undef"),PARENT:Symbol("parent"),BREAK:Symbol("break"),STREAM:Symbol("stream")},e.SHIFT32=Math.pow(2,32),e.SHIFT16=Math.pow(2,16),e.MAX_SAFE_HIGH=2097151,e.NEG_ONE=new n(-1),e.TEN=new n(10),e.TWO=new n(2),e.PARENT={ARRAY:0,OBJECT:1,MAP:2,TAG:3,BYTE_STRING:4,UTF8_STRING:5}},jpl7:function(t,e,r){"use strict";const{Buffer:n}=r("tjlA"),s=r("hDHj"),i=r("XuWj");class o extends s{createTag(t,e){return`${t}(${e})`}createInt(t){return super.createInt(t).toString()}createInt32(t,e){return super.createInt32(t,e).toString()}createInt64(t,e,r,n){return super.createInt64(t,e,r,n).toString()}createInt32Neg(t,e){return super.createInt32Neg(t,e).toString()}createInt64Neg(t,e,r,n){return super.createInt64Neg(t,e,r,n).toString()}createTrue(){return"true"}createFalse(){return"false"}createFloat(t){const e=super.createFloat(t);return i.isNegativeZero(t)?"-0_1":`${e}_1`}createFloatSingle(t,e,r,n){return`${super.createFloatSingle(t,e,r,n)}_2`}createFloatDouble(t,e,r,n,s,i,o,a){return`${super.createFloatDouble(t,e,r,n,s,i,o,a)}_3`}createByteString(t,e){const r=t.join(", ");return-1===e?`(_ ${r})`:`h'${r}`}createByteStringFromHeap(t,e){return`h'${n.from(super.createByteStringFromHeap(t,e)).toString("hex")}'`}createInfinity(){return"Infinity_1"}createInfinityNeg(){return"-Infinity_1"}createNaN(){return"NaN_1"}createNaNNeg(){return"-NaN_1"}createNull(){return"null"}createUndefined(){return"undefined"}createSimpleUnassigned(t){return`simple(${t})`}createArray(t,e){const r=super.createArray(t,e);return-1===e?`[_ ${r.join(", ")}]`:`[${r.join(", ")}]`}createMap(t,e){const r=super.createMap(t),n=Array.from(r.keys()).reduce(a(r),"");return-1===e?`{_ ${n}}`:`{${n}}`}createObject(t,e){const r=super.createObject(t),n=Object.keys(r).reduce(a(r),"");return-1===e?`{_ ${n}}`:`{${n}}`}createUtf8String(t,e){const r=t.join(", ");return-1===e?`(_ ${r})`:`"${r}"`}createUtf8StringFromHeap(t,e){return`"${n.from(super.createUtf8StringFromHeap(t,e)).toString("utf8")}"`}static diagnose(t,e){return"string"==typeof t&&(t=n.from(t,e||"hex")),(new o).decodeFirst(t)}}function a(t){return(e,r)=>e?`${e}, ${r}: ${t[r]}`:`${r}: ${t[r]}`}t.exports=o},kMlx:function(t,e,r){"use strict";var n=r("8zgK");function s(t){if(t)return function(t){for(var e in s.prototype)t[e]=s.prototype[e];return t}(t)}t.exports=s,s.prototype.clearTimeout=function(){return clearTimeout(this._timer),clearTimeout(this._responseTimeoutTimer),delete this._timer,delete this._responseTimeoutTimer,this},s.prototype.parse=function(t){return this._parser=t,this},s.prototype.responseType=function(t){return this._responseType=t,this},s.prototype.serialize=function(t){return this._serializer=t,this},s.prototype.timeout=function(t){if(!t||"object"!=typeof t)return this._timeout=t,this._responseTimeout=0,this;for(var e in t)switch(e){case"deadline":this._timeout=t.deadline;break;case"response":this._responseTimeout=t.response;break;default:console.warn("Unknown timeout option",e)}return this},s.prototype.retry=function(t,e){return 0!==arguments.length&&!0!==t||(t=1),t<=0&&(t=0),this._maxRetries=t,this._retries=0,this._retryCallback=e,this};var i=["ECONNRESET","ETIMEDOUT","EADDRINFO","ESOCKETTIMEDOUT"];s.prototype._shouldRetry=function(t,e){if(!this._maxRetries||this._retries++>=this._maxRetries)return!1;if(this._retryCallback)try{var r=this._retryCallback(t,e);if(!0===r)return!0;if(!1===r)return!1}catch(n){console.error(n)}if(e&&e.status&&e.status>=500&&501!=e.status)return!0;if(t){if(t.code&&~i.indexOf(t.code))return!0;if(t.timeout&&"ECONNABORTED"==t.code)return!0;if(t.crossDomain)return!0}return!1},s.prototype._retry=function(){return this.clearTimeout(),this.req&&(this.req=null,this.req=this.request()),this._aborted=!1,this.timedout=!1,this._end()},s.prototype.then=function(t,e){if(!this._fullfilledPromise){var r=this;this._endCalled&&console.warn("Warning: superagent request was sent twice, because both .end() and .then() were called. Never call .end() if you use promises"),this._fullfilledPromise=new Promise(function(t,e){r.end(function(r,n){r?e(r):t(n)})})}return this._fullfilledPromise.then(t,e)},s.prototype.catch=function(t){return this.then(void 0,t)},s.prototype.use=function(t){return t(this),this},s.prototype.ok=function(t){if("function"!=typeof t)throw Error("Callback required");return this._okCallback=t,this},s.prototype._isResponseOK=function(t){return!!t&&(this._okCallback?this._okCallback(t):t.status>=200&&t.status<300)},s.prototype.getHeader=s.prototype.get=function(t){return this._header[t.toLowerCase()]},s.prototype.set=function(t,e){if(n(t)){for(var r in t)this.set(r,t[r]);return this}return this._header[t.toLowerCase()]=e,this.header[t]=e,this},s.prototype.unset=function(t){return delete this._header[t.toLowerCase()],delete this.header[t],this},s.prototype.field=function(t,e){if(null==t)throw new Error(".field(name, val) name can not be empty");if(this._data&&console.error(".field() can't be used if .send() is used. Please use only .send() or only .field() & .attach()"),n(t)){for(var r in t)this.field(r,t[r]);return this}if(Array.isArray(e)){for(var s in e)this.field(t,e[s]);return this}if(null==e)throw new Error(".field(name, val) val can not be empty");return"boolean"==typeof e&&(e=""+e),this._getFormData().append(t,e),this},s.prototype.abort=function(){return this._aborted||(this._aborted=!0,this.xhr&&this.xhr.abort(),this.req&&this.req.abort(),this.clearTimeout(),this.emit("abort")),this},s.prototype._auth=function(t,e,r,n){switch(r.type){case"basic":this.set("Authorization","Basic "+n(t+":"+e));break;case"auto":this.username=t,this.password=e;break;case"bearer":this.set("Authorization","Bearer "+t)}return this},s.prototype.withCredentials=function(t){return null==t&&(t=!0),this._withCredentials=t,this},s.prototype.redirects=function(t){return this._maxRedirects=t,this},s.prototype.maxResponseSize=function(t){if("number"!=typeof t)throw TypeError("Invalid argument");return this._maxResponseSize=t,this},s.prototype.toJSON=function(){return{method:this.method,url:this.url,data:this._data,headers:this._header}},s.prototype.send=function(t){var e=n(t),r=this._header["content-type"];if(this._formData&&console.error(".send() can't be used if .attach() or .field() is used. Please use only .send() or only .field() & .attach()"),e&&!this._data)Array.isArray(t)?this._data=[]:this._isHost(t)||(this._data={});else if(t&&this._data&&this._isHost(this._data))throw Error("Can't merge these send calls");if(e&&n(this._data))for(var s in t)this._data[s]=t[s];else"string"==typeof t?(r||this.type("form"),this._data="application/x-www-form-urlencoded"==(r=this._header["content-type"])?this._data?this._data+"&"+t:t:(this._data||"")+t):this._data=t;return!e||this._isHost(t)||r||this.type("json"),this},s.prototype.sortQuery=function(t){return this._sort=void 0===t||t,this},s.prototype._finalizeQueryString=function(){var t=this._query.join("&");if(t&&(this.url+=(this.url.indexOf("?")>=0?"&":"?")+t),this._query.length=0,this._sort){var e=this.url.indexOf("?");if(e>=0){var r=this.url.substring(e+1).split("&");"function"==typeof this._sort?r.sort(this._sort):r.sort(),this.url=this.url.substring(0,e)+"?"+r.join("&")}}},s.prototype._appendQueryString=function(){console.trace("Unsupported")},s.prototype._timeoutError=function(t,e,r){if(!this._aborted){var n=new Error(t+e+"ms exceeded");n.timeout=e,n.code="ECONNABORTED",n.errno=r,this.timedout=!0,this.abort(),this.callback(n)}},s.prototype._setTimeouts=function(){var t=this;this._timeout&&!this._timer&&(this._timer=setTimeout(function(){t._timeoutError("Timeout of ",t._timeout,"ETIME")},this._timeout)),this._responseTimeout&&!this._responseTimeoutTimer&&(this._responseTimeoutTimer=setTimeout(function(){t._timeoutError("Response timeout of ",t._responseTimeout,"ETIMEDOUT")},this._responseTimeout))}},lnXz:function(t,e,r){!function(e){"use strict";function r(t){return parseInt(t)===t}function n(t){if(!r(t.length))return!1;for(var e=0;e<t.length;e++)if(!r(t[e])||t[e]<0||t[e]>255)return!1;return!0}function s(t,e){if(t.buffer&&"Uint8Array"===t.name)return e&&(t=t.slice?t.slice():Array.prototype.slice.call(t)),t;if(Array.isArray(t)){if(!n(t))throw new Error("Array contains invalid value: "+t);return new Uint8Array(t)}if(r(t.length)&&n(t))return new Uint8Array(t);throw new Error("unsupported array-like object")}function i(t){return new Uint8Array(t)}function o(t,e,r,n,s){null==n&&null==s||(t=t.slice?t.slice(n,s):Array.prototype.slice.call(t,n,s)),e.set(t,r)}var a,u={toBytes:function(t){var e=[],r=0;for(t=encodeURI(t);r<t.length;){var n=t.charCodeAt(r++);37===n?(e.push(parseInt(t.substr(r,2),16)),r+=2):e.push(n)}return s(e)},fromBytes:function(t){for(var e=[],r=0;r<t.length;){var n=t[r];n<128?(e.push(String.fromCharCode(n)),r++):n>191&&n<224?(e.push(String.fromCharCode((31&n)<<6|63&t[r+1])),r+=2):(e.push(String.fromCharCode((15&n)<<12|(63&t[r+1])<<6|63&t[r+2])),r+=3)}return e.join("")}},h=(a="0123456789abcdef",{toBytes:function(t){for(var e=[],r=0;r<t.length;r+=2)e.push(parseInt(t.substr(r,2),16));return e},fromBytes:function(t){for(var e=[],r=0;r<t.length;r++){var n=t[r];e.push(a[(240&n)>>4]+a[15&n])}return e.join("")}}),c={16:10,24:12,32:14},l=[1,2,4,8,16,32,64,128,27,54,108,216,171,77,154,47,94,188,99,198,151,53,106,212,179,125,250,239,197,145],p=[99,124,119,123,242,107,111,197,48,1,103,43,254,215,171,118,202,130,201,125,250,89,71,240,173,212,162,175,156,164,114,192,183,253,147,38,54,63,247,204,52,165,229,241,113,216,49,21,4,199,35,195,24,150,5,154,7,18,128,226,235,39,178,117,9,131,44,26,27,110,90,160,82,59,214,179,41,227,47,132,83,209,0,237,32,252,177,91,106,203,190,57,74,76,88,207,208,239,170,251,67,77,51,133,69,249,2,127,80,60,159,168,81,163,64,143,146,157,56,245,188,182,218,33,16,255,243,210,205,12,19,236,95,151,68,23,196,167,126,61,100,93,25,115,96,129,79,220,34,42,144,136,70,238,184,20,222,94,11,219,224,50,58,10,73,6,36,92,194,211,172,98,145,149,228,121,231,200,55,109,141,213,78,169,108,86,244,234,101,122,174,8,186,120,37,46,28,166,180,198,232,221,116,31,75,189,139,138,112,62,181,102,72,3,246,14,97,53,87,185,134,193,29,158,225,248,152,17,105,217,142,148,155,30,135,233,206,85,40,223,140,161,137,13,191,230,66,104,65,153,45,15,176,84,187,22],f=[82,9,106,213,48,54,165,56,191,64,163,158,129,243,215,251,124,227,57,130,155,47,255,135,52,142,67,68,196,222,233,203,84,123,148,50,166,194,35,61,238,76,149,11,66,250,195,78,8,46,161,102,40,217,36,178,118,91,162,73,109,139,209,37,114,248,246,100,134,104,152,22,212,164,92,204,93,101,182,146,108,112,72,80,253,237,185,218,94,21,70,87,167,141,157,132,144,216,171,0,140,188,211,10,247,228,88,5,184,179,69,6,208,44,30,143,202,63,15,2,193,175,189,3,1,19,138,107,58,145,17,65,79,103,220,234,151,242,207,206,240,180,230,115,150,172,116,34,231,173,53,133,226,249,55,232,28,117,223,110,71,241,26,113,29,41,197,137,111,183,98,14,170,24,190,27,252,86,62,75,198,210,121,32,154,219,192,254,120,205,90,244,31,221,168,51,136,7,199,49,177,18,16,89,39,128,236,95,96,81,127,169,25,181,74,13,45,229,122,159,147,201,156,239,160,224,59,77,174,42,245,176,200,235,187,60,131,83,153,97,23,43,4,126,186,119,214,38,225,105,20,99,85,33,12,125],d=[3328402341,4168907908,4000806809,4135287693,4294111757,3597364157,3731845041,2445657428,1613770832,33620227,3462883241,1445669757,3892248089,3050821474,1303096294,3967186586,2412431941,528646813,2311702848,4202528135,4026202645,2992200171,2387036105,4226871307,1101901292,3017069671,1604494077,1169141738,597466303,1403299063,3832705686,2613100635,1974974402,3791519004,1033081774,1277568618,1815492186,2118074177,4126668546,2211236943,1748251740,1369810420,3521504564,4193382664,3799085459,2883115123,1647391059,706024767,134480908,2512897874,1176707941,2646852446,806885416,932615841,168101135,798661301,235341577,605164086,461406363,3756188221,3454790438,1311188841,2142417613,3933566367,302582043,495158174,1479289972,874125870,907746093,3698224818,3025820398,1537253627,2756858614,1983593293,3084310113,2108928974,1378429307,3722699582,1580150641,327451799,2790478837,3117535592,0,3253595436,1075847264,3825007647,2041688520,3059440621,3563743934,2378943302,1740553945,1916352843,2487896798,2555137236,2958579944,2244988746,3151024235,3320835882,1336584933,3992714006,2252555205,2588757463,1714631509,293963156,2319795663,3925473552,67240454,4269768577,2689618160,2017213508,631218106,1269344483,2723238387,1571005438,2151694528,93294474,1066570413,563977660,1882732616,4059428100,1673313503,2008463041,2950355573,1109467491,537923632,3858759450,4260623118,3218264685,2177748300,403442708,638784309,3287084079,3193921505,899127202,2286175436,773265209,2479146071,1437050866,4236148354,2050833735,3362022572,3126681063,840505643,3866325909,3227541664,427917720,2655997905,2749160575,1143087718,1412049534,999329963,193497219,2353415882,3354324521,1807268051,672404540,2816401017,3160301282,369822493,2916866934,3688947771,1681011286,1949973070,336202270,2454276571,201721354,1210328172,3093060836,2680341085,3184776046,1135389935,3294782118,965841320,831886756,3554993207,4068047243,3588745010,2345191491,1849112409,3664604599,26054028,2983581028,2622377682,1235855840,3630984372,2891339514,4092916743,3488279077,3395642799,4101667470,1202630377,268961816,1874508501,4034427016,1243948399,1546530418,941366308,1470539505,1941222599,2546386513,3421038627,2715671932,3899946140,1042226977,2521517021,1639824860,227249030,260737669,3765465232,2084453954,1907733956,3429263018,2420656344,100860677,4160157185,470683154,3261161891,1781871967,2924959737,1773779408,394692241,2579611992,974986535,664706745,3655459128,3958962195,731420851,571543859,3530123707,2849626480,126783113,865375399,765172662,1008606754,361203602,3387549984,2278477385,2857719295,1344809080,2782912378,59542671,1503764984,160008576,437062935,1707065306,3622233649,2218934982,3496503480,2185314755,697932208,1512910199,504303377,2075177163,2824099068,1841019862,739644986],g=[2781242211,2230877308,2582542199,2381740923,234877682,3184946027,2984144751,1418839493,1348481072,50462977,2848876391,2102799147,434634494,1656084439,3863849899,2599188086,1167051466,2636087938,1082771913,2281340285,368048890,3954334041,3381544775,201060592,3963727277,1739838676,4250903202,3930435503,3206782108,4149453988,2531553906,1536934080,3262494647,484572669,2923271059,1783375398,1517041206,1098792767,49674231,1334037708,1550332980,4098991525,886171109,150598129,2481090929,1940642008,1398944049,1059722517,201851908,1385547719,1699095331,1587397571,674240536,2704774806,252314885,3039795866,151914247,908333586,2602270848,1038082786,651029483,1766729511,3447698098,2682942837,454166793,2652734339,1951935532,775166490,758520603,3000790638,4004797018,4217086112,4137964114,1299594043,1639438038,3464344499,2068982057,1054729187,1901997871,2534638724,4121318227,1757008337,0,750906861,1614815264,535035132,3363418545,3988151131,3201591914,1183697867,3647454910,1265776953,3734260298,3566750796,3903871064,1250283471,1807470800,717615087,3847203498,384695291,3313910595,3617213773,1432761139,2484176261,3481945413,283769337,100925954,2180939647,4037038160,1148730428,3123027871,3813386408,4087501137,4267549603,3229630528,2315620239,2906624658,3156319645,1215313976,82966005,3747855548,3245848246,1974459098,1665278241,807407632,451280895,251524083,1841287890,1283575245,337120268,891687699,801369324,3787349855,2721421207,3431482436,959321879,1469301956,4065699751,2197585534,1199193405,2898814052,3887750493,724703513,2514908019,2696962144,2551808385,3516813135,2141445340,1715741218,2119445034,2872807568,2198571144,3398190662,700968686,3547052216,1009259540,2041044702,3803995742,487983883,1991105499,1004265696,1449407026,1316239930,504629770,3683797321,168560134,1816667172,3837287516,1570751170,1857934291,4014189740,2797888098,2822345105,2754712981,936633572,2347923833,852879335,1133234376,1500395319,3084545389,2348912013,1689376213,3533459022,3762923945,3034082412,4205598294,133428468,634383082,2949277029,2398386810,3913789102,403703816,3580869306,2297460856,1867130149,1918643758,607656988,4049053350,3346248884,1368901318,600565992,2090982877,2632479860,557719327,3717614411,3697393085,2249034635,2232388234,2430627952,1115438654,3295786421,2865522278,3633334344,84280067,33027830,303828494,2747425121,1600795957,4188952407,3496589753,2434238086,1486471617,658119965,3106381470,953803233,334231800,3005978776,857870609,3151128937,1890179545,2298973838,2805175444,3056442267,574365214,2450884487,550103529,1233637070,4289353045,2018519080,2057691103,2399374476,4166623649,2148108681,387583245,3664101311,836232934,3330556482,3100665960,3280093505,2955516313,2002398509,287182607,3413881008,4238890068,3597515707,975967766],y=[1671808611,2089089148,2006576759,2072901243,4061003762,1807603307,1873927791,3310653893,810573872,16974337,1739181671,729634347,4263110654,3613570519,2883997099,1989864566,3393556426,2191335298,3376449993,2106063485,4195741690,1508618841,1204391495,4027317232,2917941677,3563566036,2734514082,2951366063,2629772188,2767672228,1922491506,3227229120,3082974647,4246528509,2477669779,644500518,911895606,1061256767,4144166391,3427763148,878471220,2784252325,3845444069,4043897329,1905517169,3631459288,827548209,356461077,67897348,3344078279,593839651,3277757891,405286936,2527147926,84871685,2595565466,118033927,305538066,2157648768,3795705826,3945188843,661212711,2999812018,1973414517,152769033,2208177539,745822252,439235610,455947803,1857215598,1525593178,2700827552,1391895634,994932283,3596728278,3016654259,695947817,3812548067,795958831,2224493444,1408607827,3513301457,0,3979133421,543178784,4229948412,2982705585,1542305371,1790891114,3410398667,3201918910,961245753,1256100938,1289001036,1491644504,3477767631,3496721360,4012557807,2867154858,4212583931,1137018435,1305975373,861234739,2241073541,1171229253,4178635257,33948674,2139225727,1357946960,1011120188,2679776671,2833468328,1374921297,2751356323,1086357568,2408187279,2460827538,2646352285,944271416,4110742005,3168756668,3066132406,3665145818,560153121,271589392,4279952895,4077846003,3530407890,3444343245,202643468,322250259,3962553324,1608629855,2543990167,1154254916,389623319,3294073796,2817676711,2122513534,1028094525,1689045092,1575467613,422261273,1939203699,1621147744,2174228865,1339137615,3699352540,577127458,712922154,2427141008,2290289544,1187679302,3995715566,3100863416,339486740,3732514782,1591917662,186455563,3681988059,3762019296,844522546,978220090,169743370,1239126601,101321734,611076132,1558493276,3260915650,3547250131,2901361580,1655096418,2443721105,2510565781,3828863972,2039214713,3878868455,3359869896,928607799,1840765549,2374762893,3580146133,1322425422,2850048425,1823791212,1459268694,4094161908,3928346602,1706019429,2056189050,2934523822,135794696,3134549946,2022240376,628050469,779246638,472135708,2800834470,3032970164,3327236038,3894660072,3715932637,1956440180,522272287,1272813131,3185336765,2340818315,2323976074,1888542832,1044544574,3049550261,1722469478,1222152264,50660867,4127324150,236067854,1638122081,895445557,1475980887,3117443513,2257655686,3243809217,489110045,2662934430,3778599393,4162055160,2561878936,288563729,1773916777,3648039385,2391345038,2493985684,2612407707,505560094,2274497927,3911240169,3460925390,1442818645,678973480,3749357023,2358182796,2717407649,2306869641,219617805,3218761151,3862026214,1120306242,1756942440,1103331905,2578459033,762796589,252780047,2966125488,1425844308,3151392187,372911126],_=[1667474886,2088535288,2004326894,2071694838,4075949567,1802223062,1869591006,3318043793,808472672,16843522,1734846926,724270422,4278065639,3621216949,2880169549,1987484396,3402253711,2189597983,3385409673,2105378810,4210693615,1499065266,1195886990,4042263547,2913856577,3570689971,2728590687,2947541573,2627518243,2762274643,1920112356,3233831835,3082273397,4261223649,2475929149,640051788,909531756,1061110142,4160160501,3435941763,875846760,2779116625,3857003729,4059105529,1903268834,3638064043,825316194,353713962,67374088,3351728789,589522246,3284360861,404236336,2526454071,84217610,2593830191,117901582,303183396,2155911963,3806477791,3958056653,656894286,2998062463,1970642922,151591698,2206440989,741110872,437923380,454765878,1852748508,1515908788,2694904667,1381168804,993742198,3604373943,3014905469,690584402,3823320797,791638366,2223281939,1398011302,3520161977,0,3991743681,538992704,4244381667,2981218425,1532751286,1785380564,3419096717,3200178535,960056178,1246420628,1280103576,1482221744,3486468741,3503319995,4025428677,2863326543,4227536621,1128514950,1296947098,859002214,2240123921,1162203018,4193849577,33687044,2139062782,1347481760,1010582648,2678045221,2829640523,1364325282,2745433693,1077985408,2408548869,2459086143,2644360225,943212656,4126475505,3166494563,3065430391,3671750063,555836226,269496352,4294908645,4092792573,3537006015,3452783745,202118168,320025894,3974901699,1600119230,2543297077,1145359496,387397934,3301201811,2812801621,2122220284,1027426170,1684319432,1566435258,421079858,1936954854,1616945344,2172753945,1330631070,3705438115,572679748,707427924,2425400123,2290647819,1179044492,4008585671,3099120491,336870440,3739122087,1583276732,185277718,3688593069,3772791771,842159716,976899700,168435220,1229577106,101059084,606366792,1549591736,3267517855,3553849021,2897014595,1650632388,2442242105,2509612081,3840161747,2038008818,3890688725,3368567691,926374254,1835907034,2374863873,3587531953,1313788572,2846482505,1819063512,1448540844,4109633523,3941213647,1701162954,2054852340,2930698567,134748176,3132806511,2021165296,623210314,774795868,471606328,2795958615,3031746419,3334885783,3907527627,3722280097,1953799400,522133822,1263263126,3183336545,2341176845,2324333839,1886425312,1044267644,3048588401,1718004428,1212733584,50529542,4143317495,235803164,1633788866,892690282,1465383342,3115962473,2256965911,3250673817,488449850,2661202215,3789633753,4177007595,2560144171,286339874,1768537042,3654906025,2391705863,2492770099,2610673197,505291324,2273808917,3924369609,3469625735,1431699370,673740880,3755965093,2358021891,2711746649,2307489801,218961690,3217021541,3873845719,1111672452,1751693520,1094828930,2576986153,757954394,252645662,2964376443,1414855848,3149649517,370555436],E=[1374988112,2118214995,437757123,975658646,1001089995,530400753,2902087851,1273168787,540080725,2910219766,2295101073,4110568485,1340463100,3307916247,641025152,3043140495,3736164937,632953703,1172967064,1576976609,3274667266,2169303058,2370213795,1809054150,59727847,361929877,3211623147,2505202138,3569255213,1484005843,1239443753,2395588676,1975683434,4102977912,2572697195,666464733,3202437046,4035489047,3374361702,2110667444,1675577880,3843699074,2538681184,1649639237,2976151520,3144396420,4269907996,4178062228,1883793496,2403728665,2497604743,1383856311,2876494627,1917518562,3810496343,1716890410,3001755655,800440835,2261089178,3543599269,807962610,599762354,33778362,3977675356,2328828971,2809771154,4077384432,1315562145,1708848333,101039829,3509871135,3299278474,875451293,2733856160,92987698,2767645557,193195065,1080094634,1584504582,3178106961,1042385657,2531067453,3711829422,1306967366,2438237621,1908694277,67556463,1615861247,429456164,3602770327,2302690252,1742315127,2968011453,126454664,3877198648,2043211483,2709260871,2084704233,4169408201,0,159417987,841739592,504459436,1817866830,4245618683,260388950,1034867998,908933415,168810852,1750902305,2606453969,607530554,202008497,2472011535,3035535058,463180190,2160117071,1641816226,1517767529,470948374,3801332234,3231722213,1008918595,303765277,235474187,4069246893,766945465,337553864,1475418501,2943682380,4003061179,2743034109,4144047775,1551037884,1147550661,1543208500,2336434550,3408119516,3069049960,3102011747,3610369226,1113818384,328671808,2227573024,2236228733,3535486456,2935566865,3341394285,496906059,3702665459,226906860,2009195472,733156972,2842737049,294930682,1206477858,2835123396,2700099354,1451044056,573804783,2269728455,3644379585,2362090238,2564033334,2801107407,2776292904,3669462566,1068351396,742039012,1350078989,1784663195,1417561698,4136440770,2430122216,775550814,2193862645,2673705150,1775276924,1876241833,3475313331,3366754619,270040487,3902563182,3678124923,3441850377,1851332852,3969562369,2203032232,3868552805,2868897406,566021896,4011190502,3135740889,1248802510,3936291284,699432150,832877231,708780849,3332740144,899835584,1951317047,4236429990,3767586992,866637845,4043610186,1106041591,2144161806,395441711,1984812685,1139781709,3433712980,3835036895,2664543715,1282050075,3240894392,1181045119,2640243204,25965917,4203181171,4211818798,3009879386,2463879762,3910161971,1842759443,2597806476,933301370,1509430414,3943906441,3467192302,3076639029,3776767469,2051518780,2631065433,1441952575,404016761,1942435775,1408749034,1610459739,3745345300,2017778566,3400528769,3110650942,941896748,3265478751,371049330,3168937228,675039627,4279080257,967311729,135050206,3635733660,1683407248,2076935265,3576870512,1215061108,3501741890],m=[1347548327,1400783205,3273267108,2520393566,3409685355,4045380933,2880240216,2471224067,1428173050,4138563181,2441661558,636813900,4233094615,3620022987,2149987652,2411029155,1239331162,1730525723,2554718734,3781033664,46346101,310463728,2743944855,3328955385,3875770207,2501218972,3955191162,3667219033,768917123,3545789473,692707433,1150208456,1786102409,2029293177,1805211710,3710368113,3065962831,401639597,1724457132,3028143674,409198410,2196052529,1620529459,1164071807,3769721975,2226875310,486441376,2499348523,1483753576,428819965,2274680428,3075636216,598438867,3799141122,1474502543,711349675,129166120,53458370,2592523643,2782082824,4063242375,2988687269,3120694122,1559041666,730517276,2460449204,4042459122,2706270690,3446004468,3573941694,533804130,2328143614,2637442643,2695033685,839224033,1973745387,957055980,2856345839,106852767,1371368976,4181598602,1033297158,2933734917,1179510461,3046200461,91341917,1862534868,4284502037,605657339,2547432937,3431546947,2003294622,3182487618,2282195339,954669403,3682191598,1201765386,3917234703,3388507166,0,2198438022,1211247597,2887651696,1315723890,4227665663,1443857720,507358933,657861945,1678381017,560487590,3516619604,975451694,2970356327,261314535,3535072918,2652609425,1333838021,2724322336,1767536459,370938394,182621114,3854606378,1128014560,487725847,185469197,2918353863,3106780840,3356761769,2237133081,1286567175,3152976349,4255350624,2683765030,3160175349,3309594171,878443390,1988838185,3704300486,1756818940,1673061617,3403100636,272786309,1075025698,545572369,2105887268,4174560061,296679730,1841768865,1260232239,4091327024,3960309330,3497509347,1814803222,2578018489,4195456072,575138148,3299409036,446754879,3629546796,4011996048,3347532110,3252238545,4270639778,915985419,3483825537,681933534,651868046,2755636671,3828103837,223377554,2607439820,1649704518,3270937875,3901806776,1580087799,4118987695,3198115200,2087309459,2842678573,3016697106,1003007129,2802849917,1860738147,2077965243,164439672,4100872472,32283319,2827177882,1709610350,2125135846,136428751,3874428392,3652904859,3460984630,3572145929,3593056380,2939266226,824852259,818324884,3224740454,930369212,2801566410,2967507152,355706840,1257309336,4148292826,243256656,790073846,2373340630,1296297904,1422699085,3756299780,3818836405,457992840,3099667487,2135319889,77422314,1560382517,1945798516,788204353,1521706781,1385356242,870912086,325965383,2358957921,2050466060,2388260884,2313884476,4006521127,901210569,3990953189,1014646705,1503449823,1062597235,2031621326,3212035895,3931371469,1533017514,350174575,2256028891,2177544179,1052338372,741876788,1606591296,1914052035,213705253,2334669897,1107234197,1899603969,3725069491,2631447780,2422494913,1635502980,1893020342,1950903388,1120974935],w=[2807058932,1699970625,2764249623,1586903591,1808481195,1173430173,1487645946,59984867,4199882800,1844882806,1989249228,1277555970,3623636965,3419915562,1149249077,2744104290,1514790577,459744698,244860394,3235995134,1963115311,4027744588,2544078150,4190530515,1608975247,2627016082,2062270317,1507497298,2200818878,567498868,1764313568,3359936201,2305455554,2037970062,1047239e3,1910319033,1337376481,2904027272,2892417312,984907214,1243112415,830661914,861968209,2135253587,2011214180,2927934315,2686254721,731183368,1750626376,4246310725,1820824798,4172763771,3542330227,48394827,2404901663,2871682645,671593195,3254988725,2073724613,145085239,2280796200,2779915199,1790575107,2187128086,472615631,3029510009,4075877127,3802222185,4107101658,3201631749,1646252340,4270507174,1402811438,1436590835,3778151818,3950355702,3963161475,4020912224,2667994737,273792366,2331590177,104699613,95345982,3175501286,2377486676,1560637892,3564045318,369057872,4213447064,3919042237,1137477952,2658625497,1119727848,2340947849,1530455833,4007360968,172466556,266959938,516552836,0,2256734592,3980931627,1890328081,1917742170,4294704398,945164165,3575528878,958871085,3647212047,2787207260,1423022939,775562294,1739656202,3876557655,2530391278,2443058075,3310321856,547512796,1265195639,437656594,3121275539,719700128,3762502690,387781147,218828297,3350065803,2830708150,2848461854,428169201,122466165,3720081049,1627235199,648017665,4122762354,1002783846,2117360635,695634755,3336358691,4234721005,4049844452,3704280881,2232435299,574624663,287343814,612205898,1039717051,840019705,2708326185,793451934,821288114,1391201670,3822090177,376187827,3113855344,1224348052,1679968233,2361698556,1058709744,752375421,2431590963,1321699145,3519142200,2734591178,188127444,2177869557,3727205754,2384911031,3215212461,2648976442,2450346104,3432737375,1180849278,331544205,3102249176,4150144569,2952102595,2159976285,2474404304,766078933,313773861,2570832044,2108100632,1668212892,3145456443,2013908262,418672217,3070356634,2594734927,1852171925,3867060991,3473416636,3907448597,2614737639,919489135,164948639,2094410160,2997825956,590424639,2486224549,1723872674,3157750862,3399941250,3501252752,3625268135,2555048196,3673637356,1343127501,4130281361,3599595085,2957853679,1297403050,81781910,3051593425,2283490410,532201772,1367295589,3926170974,895287692,1953757831,1093597963,492483431,3528626907,1446242576,1192455638,1636604631,209336225,344873464,1015671571,669961897,3375740769,3857572124,2973530695,3747192018,1933530610,3464042516,935293895,3454686199,2858115069,1863638845,3683022916,4085369519,3292445032,875313188,1080017571,3279033885,621591778,1233856572,2504130317,24197544,3017672716,3835484340,3247465558,2220981195,3060847922,1551124588,1463996600],S=[4104605777,1097159550,396673818,660510266,2875968315,2638606623,4200115116,3808662347,821712160,1986918061,3430322568,38544885,3856137295,718002117,893681702,1654886325,2975484382,3122358053,3926825029,4274053469,796197571,1290801793,1184342925,3556361835,2405426947,2459735317,1836772287,1381620373,3196267988,1948373848,3764988233,3385345166,3263785589,2390325492,1480485785,3111247143,3780097726,2293045232,548169417,3459953789,3746175075,439452389,1362321559,1400849762,1685577905,1806599355,2174754046,137073913,1214797936,1174215055,3731654548,2079897426,1943217067,1258480242,529487843,1437280870,3945269170,3049390895,3313212038,923313619,679998e3,3215307299,57326082,377642221,3474729866,2041877159,133361907,1776460110,3673476453,96392454,878845905,2801699524,777231668,4082475170,2330014213,4142626212,2213296395,1626319424,1906247262,1846563261,562755902,3708173718,1040559837,3871163981,1418573201,3294430577,114585348,1343618912,2566595609,3186202582,1078185097,3651041127,3896688048,2307622919,425408743,3371096953,2081048481,1108339068,2216610296,0,2156299017,736970802,292596766,1517440620,251657213,2235061775,2933202493,758720310,265905162,1554391400,1532285339,908999204,174567692,1474760595,4002861748,2610011675,3234156416,3693126241,2001430874,303699484,2478443234,2687165888,585122620,454499602,151849742,2345119218,3064510765,514443284,4044981591,1963412655,2581445614,2137062819,19308535,1928707164,1715193156,4219352155,1126790795,600235211,3992742070,3841024952,836553431,1669664834,2535604243,3323011204,1243905413,3141400786,4180808110,698445255,2653899549,2989552604,2253581325,3252932727,3004591147,1891211689,2487810577,3915653703,4237083816,4030667424,2100090966,865136418,1229899655,953270745,3399679628,3557504664,4118925222,2061379749,3079546586,2915017791,983426092,2022837584,1607244650,2118541908,2366882550,3635996816,972512814,3283088770,1568718495,3499326569,3576539503,621982671,2895723464,410887952,2623762152,1002142683,645401037,1494807662,2595684844,1335535747,2507040230,4293295786,3167684641,367585007,3885750714,1865862730,2668221674,2960971305,2763173681,1059270954,2777952454,2724642869,1320957812,2194319100,2429595872,2815956275,77089521,3973773121,3444575871,2448830231,1305906550,4021308739,2857194700,2516901860,3518358430,1787304780,740276417,1699839814,1592394909,2352307457,2272556026,188821243,1729977011,3687994002,274084841,3594982253,3613494426,2701949495,4162096729,322734571,2837966542,1640576439,484830689,1202797690,3537852828,4067639125,349075736,3342319475,4157467219,4255800159,1030690015,1155237496,2951971274,1757691577,607398968,2738905026,499347990,3794078908,1011452712,227885567,2818666809,213114376,3034881240,1455525988,3414450555,850817237,1817998408,3092726480],v=[0,235474187,470948374,303765277,941896748,908933415,607530554,708780849,1883793496,2118214995,1817866830,1649639237,1215061108,1181045119,1417561698,1517767529,3767586992,4003061179,4236429990,4069246893,3635733660,3602770327,3299278474,3400528769,2430122216,2664543715,2362090238,2193862645,2835123396,2801107407,3035535058,3135740889,3678124923,3576870512,3341394285,3374361702,3810496343,3977675356,4279080257,4043610186,2876494627,2776292904,3076639029,3110650942,2472011535,2640243204,2403728665,2169303058,1001089995,899835584,666464733,699432150,59727847,226906860,530400753,294930682,1273168787,1172967064,1475418501,1509430414,1942435775,2110667444,1876241833,1641816226,2910219766,2743034109,2976151520,3211623147,2505202138,2606453969,2302690252,2269728455,3711829422,3543599269,3240894392,3475313331,3843699074,3943906441,4178062228,4144047775,1306967366,1139781709,1374988112,1610459739,1975683434,2076935265,1775276924,1742315127,1034867998,866637845,566021896,800440835,92987698,193195065,429456164,395441711,1984812685,2017778566,1784663195,1683407248,1315562145,1080094634,1383856311,1551037884,101039829,135050206,437757123,337553864,1042385657,807962610,573804783,742039012,2531067453,2564033334,2328828971,2227573024,2935566865,2700099354,3001755655,3168937228,3868552805,3902563182,4203181171,4102977912,3736164937,3501741890,3265478751,3433712980,1106041591,1340463100,1576976609,1408749034,2043211483,2009195472,1708848333,1809054150,832877231,1068351396,766945465,599762354,159417987,126454664,361929877,463180190,2709260871,2943682380,3178106961,3009879386,2572697195,2538681184,2236228733,2336434550,3509871135,3745345300,3441850377,3274667266,3910161971,3877198648,4110568485,4211818798,2597806476,2497604743,2261089178,2295101073,2733856160,2902087851,3202437046,2968011453,3936291284,3835036895,4136440770,4169408201,3535486456,3702665459,3467192302,3231722213,2051518780,1951317047,1716890410,1750902305,1113818384,1282050075,1584504582,1350078989,168810852,67556463,371049330,404016761,841739592,1008918595,775550814,540080725,3969562369,3801332234,4035489047,4269907996,3569255213,3669462566,3366754619,3332740144,2631065433,2463879762,2160117071,2395588676,2767645557,2868897406,3102011747,3069049960,202008497,33778362,270040487,504459436,875451293,975658646,675039627,641025152,2084704233,1917518562,1615861247,1851332852,1147550661,1248802510,1484005843,1451044056,933301370,967311729,733156972,632953703,260388950,25965917,328671808,496906059,1206477858,1239443753,1543208500,1441952575,2144161806,1908694277,1675577880,1842759443,3610369226,3644379585,3408119516,3307916247,4011190502,3776767469,4077384432,4245618683,2809771154,2842737049,3144396420,3043140495,2673705150,2438237621,2203032232,2370213795],b=[0,185469197,370938394,487725847,741876788,657861945,975451694,824852259,1483753576,1400783205,1315723890,1164071807,1950903388,2135319889,1649704518,1767536459,2967507152,3152976349,2801566410,2918353863,2631447780,2547432937,2328143614,2177544179,3901806776,3818836405,4270639778,4118987695,3299409036,3483825537,3535072918,3652904859,2077965243,1893020342,1841768865,1724457132,1474502543,1559041666,1107234197,1257309336,598438867,681933534,901210569,1052338372,261314535,77422314,428819965,310463728,3409685355,3224740454,3710368113,3593056380,3875770207,3960309330,4045380933,4195456072,2471224067,2554718734,2237133081,2388260884,3212035895,3028143674,2842678573,2724322336,4138563181,4255350624,3769721975,3955191162,3667219033,3516619604,3431546947,3347532110,2933734917,2782082824,3099667487,3016697106,2196052529,2313884476,2499348523,2683765030,1179510461,1296297904,1347548327,1533017514,1786102409,1635502980,2087309459,2003294622,507358933,355706840,136428751,53458370,839224033,957055980,605657339,790073846,2373340630,2256028891,2607439820,2422494913,2706270690,2856345839,3075636216,3160175349,3573941694,3725069491,3273267108,3356761769,4181598602,4063242375,4011996048,3828103837,1033297158,915985419,730517276,545572369,296679730,446754879,129166120,213705253,1709610350,1860738147,1945798516,2029293177,1239331162,1120974935,1606591296,1422699085,4148292826,4233094615,3781033664,3931371469,3682191598,3497509347,3446004468,3328955385,2939266226,2755636671,3106780840,2988687269,2198438022,2282195339,2501218972,2652609425,1201765386,1286567175,1371368976,1521706781,1805211710,1620529459,2105887268,1988838185,533804130,350174575,164439672,46346101,870912086,954669403,636813900,788204353,2358957921,2274680428,2592523643,2441661558,2695033685,2880240216,3065962831,3182487618,3572145929,3756299780,3270937875,3388507166,4174560061,4091327024,4006521127,3854606378,1014646705,930369212,711349675,560487590,272786309,457992840,106852767,223377554,1678381017,1862534868,1914052035,2031621326,1211247597,1128014560,1580087799,1428173050,32283319,182621114,401639597,486441376,768917123,651868046,1003007129,818324884,1503449823,1385356242,1333838021,1150208456,1973745387,2125135846,1673061617,1756818940,2970356327,3120694122,2802849917,2887651696,2637442643,2520393566,2334669897,2149987652,3917234703,3799141122,4284502037,4100872472,3309594171,3460984630,3545789473,3629546796,2050466060,1899603969,1814803222,1730525723,1443857720,1560382517,1075025698,1260232239,575138148,692707433,878443390,1062597235,243256656,91341917,409198410,325965383,3403100636,3252238545,3704300486,3620022987,3874428392,3990953189,4042459122,4227665663,2460449204,2578018489,2226875310,2411029155,3198115200,3046200461,2827177882,2743944855],I=[0,218828297,437656594,387781147,875313188,958871085,775562294,590424639,1750626376,1699970625,1917742170,2135253587,1551124588,1367295589,1180849278,1265195639,3501252752,3720081049,3399941250,3350065803,3835484340,3919042237,4270507174,4085369519,3102249176,3051593425,2734591178,2952102595,2361698556,2177869557,2530391278,2614737639,3145456443,3060847922,2708326185,2892417312,2404901663,2187128086,2504130317,2555048196,3542330227,3727205754,3375740769,3292445032,3876557655,3926170974,4246310725,4027744588,1808481195,1723872674,1910319033,2094410160,1608975247,1391201670,1173430173,1224348052,59984867,244860394,428169201,344873464,935293895,984907214,766078933,547512796,1844882806,1627235199,2011214180,2062270317,1507497298,1423022939,1137477952,1321699145,95345982,145085239,532201772,313773861,830661914,1015671571,731183368,648017665,3175501286,2957853679,2807058932,2858115069,2305455554,2220981195,2474404304,2658625497,3575528878,3625268135,3473416636,3254988725,3778151818,3963161475,4213447064,4130281361,3599595085,3683022916,3432737375,3247465558,3802222185,4020912224,4172763771,4122762354,3201631749,3017672716,2764249623,2848461854,2331590177,2280796200,2431590963,2648976442,104699613,188127444,472615631,287343814,840019705,1058709744,671593195,621591778,1852171925,1668212892,1953757831,2037970062,1514790577,1463996600,1080017571,1297403050,3673637356,3623636965,3235995134,3454686199,4007360968,3822090177,4107101658,4190530515,2997825956,3215212461,2830708150,2779915199,2256734592,2340947849,2627016082,2443058075,172466556,122466165,273792366,492483431,1047239e3,861968209,612205898,695634755,1646252340,1863638845,2013908262,1963115311,1446242576,1530455833,1277555970,1093597963,1636604631,1820824798,2073724613,1989249228,1436590835,1487645946,1337376481,1119727848,164948639,81781910,331544205,516552836,1039717051,821288114,669961897,719700128,2973530695,3157750862,2871682645,2787207260,2232435299,2283490410,2667994737,2450346104,3647212047,3564045318,3279033885,3464042516,3980931627,3762502690,4150144569,4199882800,3070356634,3121275539,2904027272,2686254721,2200818878,2384911031,2570832044,2486224549,3747192018,3528626907,3310321856,3359936201,3950355702,3867060991,4049844452,4234721005,1739656202,1790575107,2108100632,1890328081,1402811438,1586903591,1233856572,1149249077,266959938,48394827,369057872,418672217,1002783846,919489135,567498868,752375421,209336225,24197544,376187827,459744698,945164165,895287692,574624663,793451934,1679968233,1764313568,2117360635,1933530610,1343127501,1560637892,1243112415,1192455638,3704280881,3519142200,3336358691,3419915562,3907448597,3857572124,4075877127,4294704398,3029510009,3113855344,2927934315,2744104290,2159976285,2377486676,2594734927,2544078150],T=[0,151849742,303699484,454499602,607398968,758720310,908999204,1059270954,1214797936,1097159550,1517440620,1400849762,1817998408,1699839814,2118541908,2001430874,2429595872,2581445614,2194319100,2345119218,3034881240,3186202582,2801699524,2951971274,3635996816,3518358430,3399679628,3283088770,4237083816,4118925222,4002861748,3885750714,1002142683,850817237,698445255,548169417,529487843,377642221,227885567,77089521,1943217067,2061379749,1640576439,1757691577,1474760595,1592394909,1174215055,1290801793,2875968315,2724642869,3111247143,2960971305,2405426947,2253581325,2638606623,2487810577,3808662347,3926825029,4044981591,4162096729,3342319475,3459953789,3576539503,3693126241,1986918061,2137062819,1685577905,1836772287,1381620373,1532285339,1078185097,1229899655,1040559837,923313619,740276417,621982671,439452389,322734571,137073913,19308535,3871163981,4021308739,4104605777,4255800159,3263785589,3414450555,3499326569,3651041127,2933202493,2815956275,3167684641,3049390895,2330014213,2213296395,2566595609,2448830231,1305906550,1155237496,1607244650,1455525988,1776460110,1626319424,2079897426,1928707164,96392454,213114376,396673818,514443284,562755902,679998e3,865136418,983426092,3708173718,3557504664,3474729866,3323011204,4180808110,4030667424,3945269170,3794078908,2507040230,2623762152,2272556026,2390325492,2975484382,3092726480,2738905026,2857194700,3973773121,3856137295,4274053469,4157467219,3371096953,3252932727,3673476453,3556361835,2763173681,2915017791,3064510765,3215307299,2156299017,2307622919,2459735317,2610011675,2081048481,1963412655,1846563261,1729977011,1480485785,1362321559,1243905413,1126790795,878845905,1030690015,645401037,796197571,274084841,425408743,38544885,188821243,3613494426,3731654548,3313212038,3430322568,4082475170,4200115116,3780097726,3896688048,2668221674,2516901860,2366882550,2216610296,3141400786,2989552604,2837966542,2687165888,1202797690,1320957812,1437280870,1554391400,1669664834,1787304780,1906247262,2022837584,265905162,114585348,499347990,349075736,736970802,585122620,972512814,821712160,2595684844,2478443234,2293045232,2174754046,3196267988,3079546586,2895723464,2777952454,3537852828,3687994002,3234156416,3385345166,4142626212,4293295786,3841024952,3992742070,174567692,57326082,410887952,292596766,777231668,660510266,1011452712,893681702,1108339068,1258480242,1343618912,1494807662,1715193156,1865862730,1948373848,2100090966,2701949495,2818666809,3004591147,3122358053,2235061775,2352307457,2535604243,2653899549,3915653703,3764988233,4219352155,4067639125,3444575871,3294430577,3746175075,3594982253,836553431,953270745,600235211,718002117,367585007,484830689,133361907,251657213,2041877159,1891211689,1806599355,1654886325,1568718495,1418573201,1335535747,1184342925];function A(t){for(var e=[],r=0;r<t.length;r+=4)e.push(t[r]<<24|t[r+1]<<16|t[r+2]<<8|t[r+3]);return e}var R=function(t){if(!(this instanceof R))throw Error("AES must be instanitated with `new`");Object.defineProperty(this,"key",{value:s(t,!0)}),this._prepare()};R.prototype._prepare=function(){var t=c[this.key.length];if(null==t)throw new Error("invalid key size (must be 16, 24 or 32 bytes)");this._Ke=[],this._Kd=[];for(var e=0;e<=t;e++)this._Ke.push([0,0,0,0]),this._Kd.push([0,0,0,0]);var r,n=4*(t+1),s=this.key.length/4,i=A(this.key);for(e=0;e<s;e++)this._Ke[r=e>>2][e%4]=i[e],this._Kd[t-r][e%4]=i[e];for(var o,a=0,u=s;u<n;){if(i[0]^=p[(o=i[s-1])>>16&255]<<24^p[o>>8&255]<<16^p[255&o]<<8^p[o>>24&255]^l[a]<<24,a+=1,8!=s)for(e=1;e<s;e++)i[e]^=i[e-1];else{for(e=1;e<s/2;e++)i[e]^=i[e-1];for(i[s/2]^=p[255&(o=i[s/2-1])]^p[o>>8&255]<<8^p[o>>16&255]<<16^p[o>>24&255]<<24,e=s/2+1;e<s;e++)i[e]^=i[e-1]}for(e=0;e<s&&u<n;)this._Ke[h=u>>2][f=u%4]=i[e],this._Kd[t-h][f]=i[e++],u++}for(var h=1;h<t;h++)for(var f=0;f<4;f++)this._Kd[h][f]=v[(o=this._Kd[h][f])>>24&255]^b[o>>16&255]^I[o>>8&255]^T[255&o]},R.prototype.encrypt=function(t){if(16!=t.length)throw new Error("invalid plaintext size (must be 16 bytes)");for(var e=this._Ke.length-1,r=[0,0,0,0],n=A(t),s=0;s<4;s++)n[s]^=this._Ke[0][s];for(var o=1;o<e;o++){for(s=0;s<4;s++)r[s]=d[n[s]>>24&255]^g[n[(s+1)%4]>>16&255]^y[n[(s+2)%4]>>8&255]^_[255&n[(s+3)%4]]^this._Ke[o][s];n=r.slice()}var a,u=i(16);for(s=0;s<4;s++)u[4*s]=255&(p[n[s]>>24&255]^(a=this._Ke[e][s])>>24),u[4*s+1]=255&(p[n[(s+1)%4]>>16&255]^a>>16),u[4*s+2]=255&(p[n[(s+2)%4]>>8&255]^a>>8),u[4*s+3]=255&(p[255&n[(s+3)%4]]^a);return u},R.prototype.decrypt=function(t){if(16!=t.length)throw new Error("invalid ciphertext size (must be 16 bytes)");for(var e=this._Kd.length-1,r=[0,0,0,0],n=A(t),s=0;s<4;s++)n[s]^=this._Kd[0][s];for(var o=1;o<e;o++){for(s=0;s<4;s++)r[s]=E[n[s]>>24&255]^m[n[(s+3)%4]>>16&255]^w[n[(s+2)%4]>>8&255]^S[255&n[(s+1)%4]]^this._Kd[o][s];n=r.slice()}var a,u=i(16);for(s=0;s<4;s++)u[4*s]=255&(f[n[s]>>24&255]^(a=this._Kd[e][s])>>24),u[4*s+1]=255&(f[n[(s+3)%4]>>16&255]^a>>16),u[4*s+2]=255&(f[n[(s+2)%4]>>8&255]^a>>8),u[4*s+3]=255&(f[255&n[(s+1)%4]]^a);return u};var x=function(t){if(!(this instanceof x))throw Error("AES must be instanitated with `new`");this.description="Electronic Code Block",this.name="ecb",this._aes=new R(t)};x.prototype.encrypt=function(t){if((t=s(t)).length%16!=0)throw new Error("invalid plaintext size (must be multiple of 16 bytes)");for(var e=i(t.length),r=i(16),n=0;n<t.length;n+=16)o(t,r,0,n,n+16),o(r=this._aes.encrypt(r),e,n);return e},x.prototype.decrypt=function(t){if((t=s(t)).length%16!=0)throw new Error("invalid ciphertext size (must be multiple of 16 bytes)");for(var e=i(t.length),r=i(16),n=0;n<t.length;n+=16)o(t,r,0,n,n+16),o(r=this._aes.decrypt(r),e,n);return e};var P=function(t,e){if(!(this instanceof P))throw Error("AES must be instanitated with `new`");if(this.description="Cipher Block Chaining",this.name="cbc",e){if(16!=e.length)throw new Error("invalid initialation vector size (must be 16 bytes)")}else e=i(16);this._lastCipherblock=s(e,!0),this._aes=new R(t)};P.prototype.encrypt=function(t){if((t=s(t)).length%16!=0)throw new Error("invalid plaintext size (must be multiple of 16 bytes)");for(var e=i(t.length),r=i(16),n=0;n<t.length;n+=16){o(t,r,0,n,n+16);for(var a=0;a<16;a++)r[a]^=this._lastCipherblock[a];this._lastCipherblock=this._aes.encrypt(r),o(this._lastCipherblock,e,n)}return e},P.prototype.decrypt=function(t){if((t=s(t)).length%16!=0)throw new Error("invalid ciphertext size (must be multiple of 16 bytes)");for(var e=i(t.length),r=i(16),n=0;n<t.length;n+=16){o(t,r,0,n,n+16),r=this._aes.decrypt(r);for(var a=0;a<16;a++)e[n+a]=r[a]^this._lastCipherblock[a];o(t,this._lastCipherblock,0,n,n+16)}return e};var N=function(t,e,r){if(!(this instanceof N))throw Error("AES must be instanitated with `new`");if(this.description="Cipher Feedback",this.name="cfb",e){if(16!=e.length)throw new Error("invalid initialation vector size (must be 16 size)")}else e=i(16);r||(r=1),this.segmentSize=r,this._shiftRegister=s(e,!0),this._aes=new R(t)};N.prototype.encrypt=function(t){if(t.length%this.segmentSize!=0)throw new Error("invalid plaintext size (must be segmentSize bytes)");for(var e,r=s(t,!0),n=0;n<r.length;n+=this.segmentSize){e=this._aes.encrypt(this._shiftRegister);for(var i=0;i<this.segmentSize;i++)r[n+i]^=e[i];o(this._shiftRegister,this._shiftRegister,0,this.segmentSize),o(r,this._shiftRegister,16-this.segmentSize,n,n+this.segmentSize)}return r},N.prototype.decrypt=function(t){if(t.length%this.segmentSize!=0)throw new Error("invalid ciphertext size (must be segmentSize bytes)");for(var e,r=s(t,!0),n=0;n<r.length;n+=this.segmentSize){e=this._aes.encrypt(this._shiftRegister);for(var i=0;i<this.segmentSize;i++)r[n+i]^=e[i];o(this._shiftRegister,this._shiftRegister,0,this.segmentSize),o(t,this._shiftRegister,16-this.segmentSize,n,n+this.segmentSize)}return r};var U=function(t,e){if(!(this instanceof U))throw Error("AES must be instanitated with `new`");if(this.description="Output Feedback",this.name="ofb",e){if(16!=e.length)throw new Error("invalid initialation vector size (must be 16 bytes)")}else e=i(16);this._lastPrecipher=s(e,!0),this._lastPrecipherIndex=16,this._aes=new R(t)};U.prototype.encrypt=function(t){for(var e=s(t,!0),r=0;r<e.length;r++)16===this._lastPrecipherIndex&&(this._lastPrecipher=this._aes.encrypt(this._lastPrecipher),this._lastPrecipherIndex=0),e[r]^=this._lastPrecipher[this._lastPrecipherIndex++];return e},U.prototype.decrypt=U.prototype.encrypt;var D=function(t){if(!(this instanceof D))throw Error("Counter must be instanitated with `new`");0===t||t||(t=1),"number"==typeof t?(this._counter=i(16),this.setValue(t)):this.setBytes(t)};D.prototype.setValue=function(t){if("number"!=typeof t||parseInt(t)!=t)throw new Error("invalid counter value (must be an integer)");if(t>Number.MAX_SAFE_INTEGER)throw new Error("integer value out of safe range");for(var e=15;e>=0;--e)this._counter[e]=t%256,t=parseInt(t/256)},D.prototype.setBytes=function(t){if(16!=(t=s(t,!0)).length)throw new Error("invalid counter bytes size (must be 16 bytes)");this._counter=t},D.prototype.increment=function(){for(var t=15;t>=0;t--){if(255!==this._counter[t]){this._counter[t]++;break}this._counter[t]=0}};var k=function(t,e){if(!(this instanceof k))throw Error("AES must be instanitated with `new`");this.description="Counter",this.name="ctr",e instanceof D||(e=new D(e)),this._counter=e,this._remainingCounter=null,this._remainingCounterIndex=16,this._aes=new R(t)};k.prototype.encrypt=function(t){for(var e=s(t,!0),r=0;r<e.length;r++)16===this._remainingCounterIndex&&(this._remainingCounter=this._aes.encrypt(this._counter._counter),this._remainingCounterIndex=0,this._counter.increment()),e[r]^=this._remainingCounter[this._remainingCounterIndex++];return e},k.prototype.decrypt=k.prototype.encrypt,t.exports={AES:R,Counter:D,ModeOfOperation:{ecb:x,cbc:P,cfb:N,ofb:U,ctr:k},utils:{hex:h,utf8:u},padding:{pkcs7:{pad:function(t){var e=16-(t=s(t,!0)).length%16,r=i(t.length+e);o(t,r);for(var n=t.length;n<r.length;n++)r[n]=e;return r},strip:function(t){if((t=s(t,!0)).length<16)throw new Error("PKCS#7 invalid length");var e=t[t.length-1];if(e>16)throw new Error("PKCS#7 padding byte out of range");for(var r=t.length-e,n=0;n<e;n++)if(t[r+n]!==e)throw new Error("PKCS#7 invalid padding byte");var a=i(r);return o(t,a,0,0,r),a}}},_arrayTest:{coerceArray:s,createArray:i,copyArray:o}}}()},nMdu:function(t,e,r){"use strict";(function(t){e.a=function(e,r,n){void 0===n&&(n=!1);for(var s=n?r.length:e.length,i=t.alloc(s),o=0;o<s;o++)i[o]=~(e[n?o%e.length:o]&r[o]);return i}}).call(this,r("tjlA").Buffer)},nZbv:function(t,e){function r(){this._defaults=[]}["use","on","once","set","query","type","accept","auth","withCredentials","sortQuery","retry","ok","redirects","timeout","buffer","serialize","parse","ca","key","pfx","cert"].forEach(function(t){r.prototype[t]=function(){return this._defaults.push({fn:t,arguments:arguments}),this}}),r.prototype._setDefaults=function(t){this._defaults.forEach(function(e){t[e.fn].apply(t,e.arguments)})},t.exports=r},oHnp:function(t,e,r){"use strict";e.type=function(t){return t.split(/ *; */).shift()},e.params=function(t){return t.split(/ *; */).reduce(function(t,e){var r=e.split(/ *= */),n=r.shift(),s=r.shift();return n&&s&&(t[n]=s),t},{})},e.parseLinks=function(t){return t.split(/ *, */).reduce(function(t,e){var r=e.split(/ *; */),n=r[0].slice(1,-1);return t[r[1].split(/ *= */)[1].slice(1,-1)]=n,t},{})},e.cleanHeader=function(t,e){return delete t["content-type"],delete t["content-length"],delete t["transfer-encoding"],delete t.host,e&&(delete t.authorization,delete t.cookie),t}},pzNo:function(t,e,r){const n=r("2k3W"),s=r("24Ii"),i=r("6WMX"),o=r("xKF7"),{buildAddAbiPayload:a,abiParsers:u,MAX_ABI_DEFS:h}=r("u0zn"),{isValidAssetPath:c,isValidCoinType:l,signReqResolver:p,aes256_decrypt:f,aes256_encrypt:d,parseDER:g,checksum:y,ensureHexBuffer:_,getP256KeyPair:E,getP256KeyPairFromPub:m,parseLattice1Response:w,toPaddedDER:S}=r("PLHu"),{getFwVersionConst:v,ADDR_STR_LEN:b,ENC_MSG_LEN:I,decResLengths:T,deviceCodes:A,encReqCodes:R,responseCodes:x,REQUEST_TYPE_BYTE:P,VERSION_BYTE:N,messageConstants:U,BASE_URL:D,signingSchema:k}=r("L21C"),B=r("tjlA").Buffer,L=B.alloc(32);t.exports=class{constructor({baseUrl:t,crypto:e,name:r,privKey:n,timeout:s,retryCount:i}={}){if(r&&r.length>24)throw new Error("name must be less than 24 characters");if(!e)throw new Error("crypto provider is required");this.baseUrl=t||D,this.crypto=e,this.name=r||"Unknown",this.privKey=n||this.crypto.randomBytes(32),this.key=E(this.privKey),this.ephemeralPub=null,this.sharedSecret=null,this.timeout=s||6e4,this.deviceId=null,this.isPaired=!1,this.retryCount=i||3,this.activeWallets={internal:{uid:L,name:null,capabilities:null,external:!1},external:{uid:L,name:null,capabilities:null,external:!0}}}connect(t,e){if("function"==typeof t){if(!this.deviceId)return e("No device ID has been stored. Please connect with your device ID first.");e=t}else this.deviceId=t;const r=this._buildRequest(A.CONNECT,this.pubKeyBytes());this._request(r,(t,r)=>t?e(t):(this.isPaired=this._handleConnect(r)||!1,this.isPaired?void this._getActiveWallet(t=>e(t,this.isPaired),!0):e(null)))}pair(t,e){const r=this.pubKeyBytes(),n=B.alloc(25);if(this.name.length>24)return e("Name is too many characters. Please change it to <25 characters.");n.write(this.name);const s=B.concat([r,n,B.from(t)]),i=this.crypto.createHash("sha256").update(s).digest(),o=this.key.sign(i),a=S(o),u=B.concat([n,a]),h=this._buildEncRequest(R.FINALIZE_PAIRING,u);this._request(h,(t,r)=>{if(t)return e(t);const n=this._handlePair(r);if(n)return e(n);this._getActiveWallet(t=>t?e(t):e(null,this.hasActiveWallet()),!0)})}test(t,e){if(!t.payload)return e("First argument must contain `testID` and `payload` fields.");const r=B.alloc(506);r.writeUInt32BE(t.testID,0),r.writeUInt16BE(t.payload.length,4),t.payload.copy(r,6);const n=this._buildEncRequest(R.TEST,r);this._request(n,(t,r)=>{if(t)return e(t);const n=this._handleEncResponse(r,T.test);return null!==n.err?e(n.err):e(null,n.data.slice(65))})}getAddresses(t,e){const{startPath:r,n:s,skipCache:i=!0}=t;if(void 0===r||void 0===s)return e("Please provide `startPath` and `n` options");if(r.length<2||r.length>5)return e("Path must include between 2 and 5 indices");if(s>10)return e("You may only request 10 addresses at once.");if(!1===i&&!1===c(r)||!0===i&&!1===l(r))return e("Parent path is not supported");const o=v(this.fwVersion);let a=53;if(o.varAddrPathSzAllowed)a+=1;else if(5!==r.length)return e("Your Lattice firmware only supports derivation paths with 5 indices. Please upgrade.");const u=B.alloc(a);let h=0;const p=this.getActiveWallet();if(null===p)return e("No active wallet.");p.uid.copy(u,h),h+=32,o.varAddrPathSzAllowed&&(u.writeUInt8(r.length,h),h+=1);for(let n=0;n<5;n++)n<=r.length&&u.writeUInt32BE(r[n],h),h+=4;let f;if(!0===o.addrFlagsAllowed){const t=n.nibble.read(!0===i?1:0),e=n.nibble.read(s);f=n.byte.write(t.concat(e))}else f=s;u.writeUInt8(f,h),h++;const d=this._buildEncRequest(R.GET_ADDRESSES,u);return this._request(d,(t,r)=>{if(t)return e(t);const n=this._handleGetAddresses(r);return n.err?e(n.err):e(null,n.data)})}sign(t,e,r=null,n=null){const{currency:s}=t;let{data:i}=t;if(void 0===s||void 0===i)return e("Please provide `currency` and `data` options");if(void 0===p[s])return e("Unsupported currency");const o=v(this.fwVersion);let a,u,h;if(i={fwConstants:o,...i},null!==r&&null!==n)a=r,u=B.concat([n,a.extraDataPayloads.shift()]),h=k.EXTRA_DATA;else{if(a=p[s](i),void 0!==a.err)return e(a.err);if(a.payload.length>o.reqMaxDataSz)return e("Transaction is too large");u=a.payload,h=a.schema}const c=B.alloc(2+o.reqMaxDataSz);let l=0;const f=a.extraDataPayloads&&Number(a.extraDataPayloads.length>0);c.writeUInt8(f,l),l+=1,c.writeUInt8(h,l),l+=1;const d=this.getActiveWallet();if(null===d)return e("No active wallet.");d.uid.copy(c,l),l+=d.uid.length,u.copy(c,l);const g=this._buildEncRequest(R.SIGN_TRANSACTION,c);return this._request(g,(i,o,u)=>{if(u===x.RESP_ERR_WALLET_NOT_PRESENT)this._getActiveWallet(s=>s?e(s):this.sign(t,e,r,n));else{if(!i){if(f){const s=this._handleEncResponse(o,T.sign);return n=s.data.slice(65,73),r||(r=a),this.sign(t,e,r,n)}{const t=this._handleSign(o,s,a);return e(t.err,t.data)}}if(i)return e(i)}})}addAbiDefs(t,e,r=null){const n=t.slice(0,h);let s;t=t.slice(h);try{s=a(n)}catch(u){return e(u)}const i=B.alloc(s.length+10);i.writeUInt16LE(t.length),null!==r&&r.copy(i,2),s.copy(i,10);const o=this._buildEncRequest(R.ADD_ABI_DEFS,i);return this._request(o,(n,s,i)=>{if(i&&i!==x.RESP_SUCCESS)return e("Error making request.");if(n)return e(n);const o=this._handleEncResponse(s,T.addAbiDefs);if(r=o.data.slice(65,73),0===t.length)return e(null);this.addAbiDefs(t,e,r,t)})}addPermissionV0(t,e){const{currency:r,timeWindow:n,limit:s,decimals:i,asset:o}=t;if(!r||void 0===n||void 0===s||void 0===i||null===n||null===s||null===i)return e("currency, timeWindow, decimals, and limit are all required options.");if(0===n||0===s)return e("Time window and spending limit must be positive.");let a=r;o&&(a+=`_${o}`);const u=B.alloc(293);if(B.from(a).length>255)return e("Asset name too long.");B.from(a).copy(u,0);const h=_(s);if(h.length>32)return e("Limit too large.");h.copy(u,32-h.length+256),u.writeUInt32BE(n,288),u.writeUInt8(i,292);const c=this._buildEncRequest(R.ADD_PERMISSION_V0,u);return this._request(c,(r,n,s)=>{if(s===x.RESP_ERR_WALLET_NOT_PRESENT)this._getActiveWallet(r=>r?e(r):this.addPermissionV0(t,e));else{if(!r){const t=this._handleEncResponse(n,T.finalizePair);return e(t.err?t.err:null)}if(r)return e(r)}})}_getActiveWallet(t,e=!1){if(!0===e||!0!==this.hasActiveWallet()&&!0===this.isPaired){const e=B.alloc(0),r=this._buildEncRequest(R.GET_WALLETS,e);return this._request(r,(e,r)=>e?(this._resetActiveWallets(),t(e)):t(this._handleGetWallets(r)))}return t(null)}_getSharedSecret(){return B.from(this.key.derive(this.ephemeralPub.getPublic()).toArray("be",32))}_getEphemId(){if(null===this.ephemeralPub)return null;const t=this._getSharedSecret();return this.crypto.createHash("sha256").update(t).digest().slice(0,4)}_buildEncRequest(t,e){const r=parseInt(this._getEphemId().toString("hex"),16),n=B.concat([B.from([t]),e]),s=y(n),i=B.alloc(n.length+4);n.copy(i,0),i.writeUInt32LE(s,n.length);const o=this._getSharedSecret(),a=d(i,o),u=B.alloc(I+4);return u.writeUInt32LE(r,0),a.copy(u,4),this._buildRequest(A.ENCRYPTED_REQUEST,u)}_buildRequest(t,e){let r=e&&B.isBuffer(e)?e.length+1:1;t===A.ENCRYPTED_REQUEST&&(r=1+e.length);let n=0;const s=B.alloc(r+8);n=s.writeUInt8(N,n),n=s.writeUInt8(P,n);const i=this.crypto.randomBytes(4);n=s.writeUInt32BE(parseInt(`0x${i.toString("hex")}`),n),n=s.writeUInt16BE(r,n),n=s.writeUInt8(t,n),r>1&&(n=e.copy(s,n));const o=y(s),a=B.alloc(s.length+4);return n=s.copy(a),a.writeUInt32BE(o,n),a}_request(t,e,r=this.retryCount){if(!this.deviceId)return e("Serial is not set. Please set it and try again.");s.post(`${this.baseUrl}/${this.deviceId}`).timeout(this.timeout).send({data:t}).then(n=>{if(!n||!n.body)return e(`Invalid response: ${n}`);if(200!==n.body.status)return e(`Error code ${n.body.status}: ${n.body.message}`);const s=w(n.body.message);return(s.responseCode===x.RESP_ERR_DEV_BUSY||s.responseCode===x.RESP_ERR_GCE_TIMEOUT)&&r>0?setTimeout(()=>{this._request(t,e,r-1)},3e3):(s.responseCode===x.RESP_ERR_WALLET_NOT_PRESENT&&this._resetActiveWallets(),s.err?e(s.err):e(null,s.data,s.responseCode))}).catch(t=>e("ECONNABORTED"===t.code&&"ETIME"===t.errno?"Timeout waiting for device. Please ensure it is connected to the internet and try again in a minute.":"Failed to make request to device."))}_handleConnect(t){let e=0;const r=t.readUInt8(e);e++;const n=t.slice(e,e+65).toString("hex");return e+=65,this.fwVersion=t.slice(e,e+4),this.ephemeralPub=m(n),r===U.PAIRED}_handleEncResponse(t,e){const r=this._getSharedSecret(),n=t.slice(0,I),s=f(n,r),i=s.slice(0,e+=65),o=parseInt(`0x${s.slice(e,e+4).toString("hex")}`),a=y(i);if(o!==a)return{err:`Checksum mismatch in response from Lattice (calculated ${a}, wanted ${o})`};const u=s.slice(0,65).toString("hex");try{return this.ephemeralPub=m(u),{err:null,data:s}}catch(h){return{err:`Error handling getAddresses response: ${h.toString()}`}}}_handlePair(t){const e=this._handleEncResponse(t,T.finalizePair);return e.err?e.err:(this.pairingSalt=null,this.isPaired=!0,null)}_handleGetAddresses(t){const e=this._handleEncResponse(t,T.getAddresses);if(null!==e.err)return e;const r=e.data;let n=65;const s=[];for(;n+4<T.getAddresses;){const t=r.slice(n,n+b);n+=b;const e=t.indexOf(0);e>0&&s.push(t.slice(0,e).toString())}return{data:s,err:null}}_handleGetWallets(t){const e=this._handleEncResponse(t,T.getWallets);if(null!==e.err)return e;const r=e.data;let n,s=65,i=!1;return n=r.slice(s,s+32),this.activeWallets.internal.uid=n,this.activeWallets.internal.capabilities=r.readUInt32BE(s+32),this.activeWallets.internal.name=r.slice(s+36,s+71),n.equals(L)||(i=!0),s+=71,n=r.slice(s,s+32),this.activeWallets.external.uid=n,this.activeWallets.external.capabilities=r.readUInt32BE(s+32),this.activeWallets.external.name=r.slice(s+36,s+71),n.equals(L)||(i=!0),!0===i?null:"No active wallet."}_handleSign(t,e,r=null){const n=this._handleEncResponse(t,T.sign);if(null!==n.err)return{err:n.err};let s=65;const a=n.data;let u;if("BTC"===e){const t=i.addressVersion[r.changeData.changeVersion],e=a.slice(s,s+20);s+=20,u=i.getBitcoinAddress(e,t)}const h={err:null,data:null};if("BTC"===e){const t=33,e=[],n=[];let o=0;for(;s<a.length&&48===a[s];)n.push(a.slice(s,s+2+a[s+1])),e.push(a.slice(o*t+825,(o+1)*t+825)),s+=74,o+=1;const c={inputs:[],outputs:[],spenderScriptType:r.spenderScriptType,network:r.origData.network,crypto:this.crypto};c.outputs.push({value:r.origData.value,recipient:r.origData.recipient}),r.changeData.value>0&&c.outputs.push({value:r.changeData.value,recipient:u});for(let s=0;s<n.length;s++)c.inputs.push({hash:r.origData.prevOuts[s].txHash,index:r.origData.prevOuts[s].index,sig:n[s],pubkey:e[s]});const l=i.serializeTx(c);let p=l;!0===c.isSegwitSpend&&(c.isSegwitSpend=!1,p=i.serializeTx(c));let f=this.crypto.createHash("sha256").update(B.from(p,"hex")).digest();f=this.crypto.createHash("sha256").update(f).digest().reverse().toString("hex"),h.data={tx:l,txHash:f,changeRecipient:u,sigs:n}}else if("ETH"===e){const t=g(a.slice(s,s+2+a[s+1]));s+=74;const e=a.slice(s,s+20),n=o.buildEthRawTx(r,t,e,r.useEIP155);h.data={tx:`0x${n}`,txHash:`0x${o.hashTransaction(n)}`,sig:{v:t.v,r:t.r.toString("hex"),s:t.s.toString("hex")},signer:e}}else if("ETH_MSG"===e){const t=g(a.slice(s,s+2+a[s+1]));s+=74;const e=a.slice(s,s+20),n=o.validateEthereumMsgResponse({signer:e,sig:t},r);h.data={sig:{v:n.v,r:n.r.toString("hex"),s:n.s.toString("hex")},signer:e}}return h}_resetActiveWallets(){this.activeWallets.internal.uid=L,this.activeWallets.internal.name=null,this.activeWallets.internal.capabilities=null,this.activeWallets.external.uid=L,this.activeWallets.external.name=null,this.activeWallets.external.capabilities=null}getActiveWallet(){return L.equals(this.activeWallets.external.uid)?L.equals(this.activeWallets.internal.uid)?null:this.activeWallets.internal:this.activeWallets.external}hasActiveWallet(){return null!==this.getActiveWallet()}pubKeyBytes(t=!1){const e=this.key.getPublic().encode("hex"),r=B.from(e,"hex");if(!0===t){const t=r.slice(1,33).reverse(),e=r.slice(33,65).reverse();return B.concat([r[0],t,e])}return r}parseAbi(t,e,r=!1){switch(t){case"etherscan":return u[t](e,r);default:return{err:`No ${t} parser available.`}}}}},u0zn:function(t,e,r){const n=r("tjlA").Buffer,s=r("zNmP").keccak256,{ETH_ABI_LATTICE_FW_TYPE_MAP:i}=r("L21C");function o(t,e=[],r=!1){let n=[];if(t.forEach(t=>{const s=t.type,a={isArray:!1,arraySz:0,name:t.name},u=s.indexOf("["),h=s.indexOf("]");if(s.split("[").length>2)throw new Error("Skipping function with unsupported multidimensional array type");{if(u>-1&&h>-1)if(u>=h);else if(u+1===h)a.isArray=!0;else{const t=parseInt(s.slice(u,h));if(isNaN(t))return a;a.isArray=!0,a.arraySz=t}let c=u>-1?s.slice(0,u):s;if("tuple"===c){if(!0===r)throw new Error("Nested tuples are not supported");c=`tuple${t.components.length}`,n=o(t.components,n,!0)}if(a.latticeTypeIdx=i[c],!a.latticeTypeIdx)throw new Error(`Unsupported type: ${s}`);e.push(a)}}),e.concat(n).length>18)throw new Error("Function has too many parameters for Lattice firmware (18 max)");return e.concat(n)}e.MAX_ABI_DEFS=2,e.buildAddAbiPayload=function(t){if(!t||!Array.isArray(t))throw new Error("Missing definitions.");if(t.length>e.MAX_ABI_DEFS)throw new Error("You may only add 2 ABI definitions per request.");const r=n.alloc(1211);let s=0;return r.writeUInt8(t.length,s),s++,t.forEach(t=>{if(!t.sig||!t.name||!t.params)throw new Error("name, sig, and params must be present for every ABI definition.");const e=n.from(t.sig,"hex");if(4!==e.length)throw new Error("Function signatures must always be four bytes.");if(e.copy(r,s),s+=e.length,n.from(t.name).length>99)throw new Error("Only function names shorter than 99 characters are supported.");n.from(t.name).slice(0,100).copy(r,s),s+=100;const i=Array.isArray(t.params)?t.params.length:0;if(r.writeUInt8(i,s),s++,t.category&&"string"==typeof t.category){const e=n.from(t.category);if(e.length>31)throw new Error(`Category name must be shorter than 31. Got ${e.length}`);e.copy(r,s)}if(s+=32,i>18)throw new Error("Currently only ABI defintions with <=10 parameters are supported.");i>0?(t.params.forEach(t=>{if(void 0===t.name||void 0===t.latticeTypeIdx||void 0===t.isArray||void 0===t.arraySz)throw new Error("name, latticeTypeIdx, isArray, and arraySz must be defined for all ABI params.");n.from(t.name).slice(0,20).copy(r,s),s+=20}),s+=20*(18-i),t.params.forEach(t=>{r.writeUInt8(t.latticeTypeIdx,s),s++,r.writeUInt8(!0===t.isArray,s),s++,r.writeUInt32LE(t.arraySz,s),s+=4}),s+=6*(18-i)):s+=468}),r},e.getFuncSig=function(t){let e=`${t.name}(`;return t.inputs.forEach(t=>{if(t.type.indexOf("tuple")>-1){const r=t.type.slice(t.type.indexOf("tuple")+5);e+="(",t.components.forEach((r,n)=>{e+=`${r.type}${n===t.components.length-1?"":","}`}),e+=`)${r},`}else e+=`${t.type},`}),t.inputs.length>0&&(e=e.slice(0,e.length-1)),e+=")",s(e).slice(0,8)},e.abiParsers={etherscan:function(t,r=!1){const n=[];return t.forEach(t=>{if(t.name&&t.inputs&&"function"===t.type&&"view"!==t.stateMutability&&!0!==t.constant)try{const r=e.getFuncSig(t),s=o(t.inputs);n.push({name:t.name,sig:r,params:s})}catch(s){if(!0!==r)throw new Error(s);console.error("Failed to load def:",t.name,s.toString())}}),n}}},vGFC:function(t,e,r){"use strict";(function(t){e.a=function(e,r,n){void 0===n&&(n=!1);for(var s=n?r.length:e.length,i=t.alloc(s),o=0;o<s;o++)i[o]=~(e[n?o%e.length:o]^r[o]);return i}}).call(this,r("tjlA").Buffer)},xKF7:function(t,e,r){const n=r("kB5k"),s=r("tjlA").Buffer,i=r("AREZ"),o=r("L21C"),a=r("wDBh"),u=r("1B/i"),h=r("zNmP").keccak256,c=r("MbHH"),l=r("IzB8");function p(t){let e=t[0];for(;t.length>0&&"0"===e.toString();)e=(t=t.slice(1))[0];return t}function f(t,e,r,n,i){try{const o=new Uint8Array(t);let a=0;const u=g(e.r,32);e.r=u;const h=g(e.s,32);e.s=h;const c=new Uint8Array(s.concat([u,h]));let p=l.ecdsaRecover(c,a,o,!1).slice(1);if(d(p)===r.toString("hex"))return e.v=y(a,i,n),e;if(a=1,p=l.ecdsaRecover(c,a,o,!1).slice(1),d(p)===r.toString("hex"))return e.v=y(a,i,n),e;throw new Error("Invalid Ethereum signature returned.")}catch(o){throw new Error(o)}}function d(t){return h(t).slice(-40)}function g(t,e){const r=s.alloc(e);return t.length<e?(t.copy(r,e-t.length),r):t.slice(-e)}function y(t,e,r=null){if(!1===e||null===r)return s.from(new n(t).plus(27).toString(16),"hex");const i=m(r);return S(`0x${new n(i.toString("hex"),16).times(2).plus(35).plus(t).toString(16)}`)}function _(t){return/^[\x00-\x7F]+$/.test(t)}e.buildEthereumMsgRequest=function(t){if(!t.payload||!t.protocol||!t.signerPath)throw new Error("You must provide `payload`, `signerPath`, and `protocol` arguments in the messsage request");if(t.signerPath.length>5||t.signerPath.length<2)throw new Error("Please provide a signer path with 2-5 indices");const e={schema:o.signingSchema.ETH_MSG,payload:null,input:t,msg:null};try{switch(t.protocol){case"signPersonal":return function(t,e){const r=e.fwConstants.ethMaxMsgSz,n=e.fwConstants.varAddrPathSzAllowed;let i=0;t.payload=s.alloc(24+r+4),t.payload.writeUInt8(o.ethMsgProtocol.SIGN_PERSONAL,0),i+=1;const a=v(e.signerPath,n);a.copy(t.payload,i),i+=a.length;let u=e.payload,c=!1;if("string"==typeof e.payload)if("0x"===e.payload.slice(0,2))u=S(e.payload),c=!1===_(s.from(e.payload.slice(2),"hex").toString());else{if(!1===function(t){for(let e=0;e<t.length;e++)if(t.charCodeAt(e)<32||t.charCodeAt(e)>127)return!1;return!0}(e.payload))throw new Error("Currently, the Lattice can only display ASCII strings.");u=s.from(e.payload)}else if("boolean"==typeof e.displayHex)c=e.displayHex;else{if(!e.payload.toString)throw new Error("Unsupported input data type");c=!1===_(e.payload.toString())}const l=e.fwConstants;if(l.ethMsgPreHashAllowed&&u.length>r+l.extraDataMaxFrames*l.extraDataFrameSz){t.payload.writeUInt8(c,i),i+=1,t.payload.writeUInt16LE(u.length,i),i+=2;const e=s.from(h(s.concat([A(u.length),u])),"hex");e.copy(t.payload,i),t.prehash=e}else{const r=b(u,e);t.extraDataPayloads=r,t.msg=u,t.payload.writeUInt8(c,i),i+=1,t.payload.writeUInt16LE(u.length,i),i+=2,u.copy(t.payload,i)}return t}(e,t);case"eip712":if(!t.fwConstants.eip712Supported)throw new Error("EIP712 is not supported by your Lattice firmware version. Please upgrade.");return function(t,e){try{const r=e.fwConstants.ethMaxMsgSz,n=e.fwConstants.varAddrPathSzAllowed,a=o.ethMsgProtocol.TYPED_DATA;let c=0;t.payload=s.alloc(24+r+4),t.payload.writeUInt8(a.enumIdx,0),c+=1;const l=v(e.signerPath,n);l.copy(t.payload,c),c+=l.length;const p=JSON.parse(JSON.stringify(e.payload));if(!p.primaryType||!p.types[p.primaryType])throw new Error("primaryType must be specified and the type must be included.");if(!p.message||!p.domain)throw new Error("message and domain must be specified.");if(0>Object.keys(p.types).indexOf("EIP712Domain"))throw new Error("EIP712Domain type must be defined.");e.payload.message=T(JSON.parse(JSON.stringify(p.message)),JSON.parse(JSON.stringify(p.primaryType)),JSON.parse(JSON.stringify(p.types)),!0),e.payload.domain=T(JSON.parse(JSON.stringify(p.domain)),"EIP712Domain",JSON.parse(JSON.stringify(p.types)),!0),p.domain=T(p.domain,"EIP712Domain",p.types,!1),p.message=T(p.message,p.primaryType,p.types,!1);const f=s.from(i.encode(p)),d=e.fwConstants,g=r+d.extraDataMaxFrames*d.extraDataFrameSz;if(d.ethMsgPreHashAllowed&&f.length>g){t.payload.writeUInt16LE(f.length,c),c+=2;const e=s.from(h(u.TypedDataUtils.encodeDigest(t.input.payload),"hex"),"hex");e.copy(t.payload,c),t.prehash=e}else{const r=b(f,e);t.extraDataPayloads=r,t.payload.writeUInt16LE(f.length,c),c+=2,f.copy(t.payload,c),c+=f.length,t.payload=t.payload.slice(0,c)}return t}catch(r){return{err:`Failed to build EIP712 request: ${r.message}`}}}(e,t);default:throw new Error("Unsupported protocol")}}catch(r){return{err:r.toString()}}},e.validateEthereumMsgResponse=function(t,e){const{signer:r,sig:n}=t,{input:i,msg:o,prehash:a=null}=e;if("signPersonal"===i.protocol)return f(a||s.from(h(s.concat([A(o.length),o])),"hex"),n,r,1,!1);if("eip712"===i.protocol)return f(a||u.TypedDataUtils.encodeDigest(e.input.payload),n,r);throw new Error("Unsupported protocol")},e.buildEthereumTxRequest=function(t){try{let{chainId:e=1}=t;const{signerPath:r,eip155:n=null,fwConstants:i}=t,{extraDataFrameSz:a,extraDataMaxFrames:u,prehashAllowed:l}=i,p=a>0&&u>0,f=i.ethMaxDataSz,d=i.varAddrPathSzAllowed;if("number"!=typeof e&&!1===w(e)&&(e=E[e]),!e)throw new Error("Unsupported chain ID or name");if(!r)throw new Error("`signerPath` not provided");let g=function(t){switch(t){case 3:case 4:return!1;case 1:case 42:case 5:default:return!0}}(e);null!==n&&"boolean"==typeof n&&(g=n),t.value||(t.value=0);const y=[],_=S(t.nonce),b=S(t.gasPrice),T=S(t.gasLimit),A=S(t.to),R=S(t.value),x=S(t.data);y.push(_),y.push(b),y.push(T),y.push(A),y.push(R),y.push(x),!0===g&&(y.push(S(e)),y.push(S(null)),y.push(S(null)));const P=s.alloc(f+122);let N,U=0;P.writeUInt8(Number(g),U),U++;let D=0;if(!0===function(t){const e=m(t);return 1!==e.length||255===e.readUInt8(0)}(e)){if(N=m(e),D=N.length,D>o.MAX_CHAIN_ID_BYTES)throw new Error("ChainID provided is too large.");P.writeUInt8(o.HANDLE_LARGER_CHAIN_ID,U),U++}else{if(N=S(e),1!==N.length)throw new Error("Error parsing chainID");N.copy(P,U),U+=N.length}const k=v(r,d);if(k.copy(P,U),U+=k.length,_.length>4)throw new Error("Nonce too large");if(_.copy(P,U+(4-_.length)),U+=4,b.length>8)throw new Error("Gas price too large");if(b.copy(P,U+(8-b.length)),U+=8,T.length>4)throw new Error("Gas limit too large");if(T.copy(P,U+(4-T.length)),U+=4,20!==A.length)throw new Error("Invalid `to` address");if(A.copy(P,U),U+=20,R.length>32)throw new Error("Value too large");R.copy(P,U+(32-R.length)),U+=32;const B=[];let L=null;if(x&&x.length>f){const t=D>0?D+1:0,e=x.length+t,r=f+u*a,n=s.alloc(x.length+t);if(t>0?(n.writeUInt8(D,0),N.copy(n,1),x.copy(n,t)):x.copy(n,0),l&&e>r)L=s.from(h(c.encode(y)),"hex");else{if(!p||p&&e>r)throw new Error(`Data field too large (got ${x.length}; must be <=${r-t} bytes)`);I(n.slice(f),a).forEach(t=>{const e=s.alloc(4);e.writeUInt32LE(t.length),B.push(s.concat([e,t]))})}}return P.writeUInt16BE(x.length,U),U+=2,D>0&&(P.writeUInt8(D,U),U++,N.copy(P,U),U+=D),L?(L.copy(P,U),U+=f):(x.slice(0,f).copy(P,U),U+=f),{rawTx:y,payload:P.slice(0,U),extraDataPayloads:B,schema:o.signingSchema.ETH_TRANSFER,chainId:e,useEIP155:g,signerPath:r}}catch(e){return{err:e.message}}},e.buildEthRawTx=function(t,e,r,n=!0){const i=c.encode(t.rawTx),o=f(s.from(h(i),"hex"),e,r,t.chainId,n),a=t.rawTx.slice(0,6);return a.push(o.v),a.push(p(o.r)),a.push(p(o.s)),c.encode(a).toString("hex")},e.hashTransaction=function(t){return h(s.from(t,"hex"))};const E={mainnet:1,roptsten:3,rinkeby:4,kovan:42,goerli:5};function m(t){let e,r;if(e=!0===w(t)?S(t):S(`0x${new n(t).toString(16)}`),e.length>8)throw new Error("ChainID provided is too large.");return e.length<=2||4===e.length||8===e.length?e:(3===e.length?(r=s.alloc(4),r.writeUInt32BE(t)):e.length<=8&&(r=s.alloc(8),e.copy(r,8-e.length)),r)}function w(t){if("string"!=typeof t)return!1;if("0x"!==t.slice(0,2))return!1;try{return!1===new n(t,16).isNaN()}catch(e){return!1}}function S(t,e=!0){try{if(null===t||0===t&&!0===e)return s.alloc(0);const r="number"==typeof t||function(t){const e=new n(t).toString().split(".").join(""),r=new String(t);return e.slice(0,8)===r.slice(0,8)}(t);return(t=r?`${new n(t).toString(16)}`:"string"==typeof t&&"0x"===t.slice(0,2)?t.slice(2):t.toString("hex")).length%2>0&&(t=`0${t}`),"00"!==t||r?s.from(t,"hex"):s.alloc(0)}catch(r){throw new Error(`Cannot convert ${t.toString()} to hex buffer (${r.toString()})`)}}function v(t,e){const r=s.alloc(24);let n=0;if(e&&t.length>5)throw new Error("Signer path must be <=5 indices.");if(!e&&5!==t.length)throw new Error("Your Lattice firmware only supports 5-index derivation paths. Please upgrade.");r.writeUInt32LE(t.length,n),n+=4;for(let s=0;s<5;s++)r.writeUInt32LE(s<t.length?t[s]:0,n),n+=4;return r}function b(t,e){const{ethMaxMsgSz:r,extraDataFrameSz:n,extraDataMaxFrames:i}=e.fwConstants,o=r,a=n>0&&i>0,u=[];if(t.length>o){const e=o+i*n;if(!a)throw new Error(`Your message is ${t.length} bytes, but can only be a maximum of ${o}`);if(a&&t.length>e)throw new Error(`Your message is ${t.length} bytes, but can only be a maximum of ${e}`);I(t.slice(o),n).forEach(t=>{const e=s.alloc(4);e.writeUInt32LE(t.length),u.push(s.concat([e,t]))})}return u}function I(t,e){const r=[],n=Math.ceil(t.length/e);let s=0;for(let i=0;i<n;i++)r.push(t.slice(s,s+e)),s+=e;return r}function T(t,e,r,n=!1){try{r[e].forEach(e=>{const u=Object.keys(r).indexOf(e.type)>-1;t[e.name]=!0===u?T(t[e.name],e.type,r,n):function(t,e,r=!1){if("bytes"===e)t=S(t);else if("bytes"===e.slice(0,5)){const r=parseInt(e.slice(5));if((t=S(t)).length!==r)throw new Error(`Expected ${e} type, but got ${t.length} bytes`)}else if("address"===e){if(0===(t=S(t)).length&&(t=s.alloc(20)),20!==t.length)throw new Error(`Address type must be 20 bytes, but got ${t.length} bytes`);!0===r&&(t=`0x${t.toString("hex")}`)}else if(o.ethMsgProtocol.TYPED_DATA.typeCodes[e]&&(e.indexOf("uint")>-1||e.indexOf("int")>-1)){let e=S(t);0===e.length&&(e=s.from("00","hex")),t=!0===r?a.BigNumber.from(`0x${e.toString("hex")}`):(new i.Encoder).semanticTypes[1][0](e.toString("hex"),16)}else"bool"===e&&(t=!0===t?1:0);return t}(t[e.name],e.type,n)})}catch(u){throw new Error(u.message)}return t}function A(t){return s.from(`\x19Ethereum Signed Message:\n${t.toString()}`,"utf-8")}e.chainIds=E,e.ensureHexBuffer=S}}]);