UNPKG

uniswap-blocklet

Version:

A blocklet for uniswap blocklet

2 lines 613 kB
/*! For license information please see 5.1a0ba608.chunk.js.LICENSE.txt */ (this["webpackJsonp@uniswap/interface"]=this["webpackJsonp@uniswap/interface"]||[]).push([[5],{1004:function(e,t,r){"use strict";var n=r(174),i=r(354),o=r(355);Object.defineProperty(t,"__esModule",{value:!0});var a=r(73),s=a.__importDefault(r(1005)),u=a.__importStar(r(1021)),c=function(e){i(r,e);var t=o(r);function r(e,i){return n(this,r),t.call(this,{cryptoLib:u,connectorOpts:e,pushServerOpts:i})}return r}(s.default);t.default=c},1005:function(e,t,r){"use strict";var n=r(5),i=r(174),o=r(175);Object.defineProperty(t,"__esModule",{value:!0});var a=r(73),s=r(800),u=a.__importDefault(r(1015)),c=r(1018),f=a.__importDefault(r(1019)),l=a.__importDefault(r(1020)),h=function(){function e(t){if(i(this,e),this.protocol="wc",this.version=1,this._bridge="",this._key=null,this._clientId="",this._clientMeta=null,this._peerId="",this._peerMeta=null,this._handshakeId=0,this._handshakeTopic="",this._connected=!1,this._accounts=[],this._chainId=0,this._networkId=0,this._rpcUrl="",this._eventManager=new f.default,this._clientMeta=s.getMeta()||t.connectorOpts.clientMeta||null,this._cryptoLib=t.cryptoLib,this._sessionStorage=t.sessionStorage||new l.default,this._qrcodeModal=t.connectorOpts.qrcodeModal,this._qrcodeModalOptions=t.connectorOpts.qrcodeModalOptions,!t.connectorOpts.bridge&&!t.connectorOpts.uri&&!t.connectorOpts.session)throw new Error(c.ERROR_MISSING_REQUIRED);t.connectorOpts.bridge&&(this.bridge=t.connectorOpts.bridge),t.connectorOpts.uri&&(this.uri=t.connectorOpts.uri);var r=t.connectorOpts.session||this._getStorageSession();r&&(this.session=r),this.handshakeId&&this._subscribeToSessionResponse(this.handshakeId,"Session request rejected"),this._transport=t.transport||new u.default({url:this.bridge,subscriptions:[this.clientId]}),this._subscribeToInternalEvents(),this._initTransport(),t.connectorOpts.uri&&this._subscribeToSessionRequest(),t.pushServerOpts&&this._registerPushServer(t.pushServerOpts)}return o(e,[{key:"on",value:function(e,t){var r={event:e,callback:t};this._eventManager.subscribe(r)}},{key:"createInstantRequest",value:function(e){return a.__awaiter(this,void 0,void 0,n.mark((function t(){var r,i,o,a=this;return n.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._generateKey();case 2:return this._key=t.sent,r=this._formatRequest({method:"wc_instantRequest",params:[{peerId:this.clientId,peerMeta:this.clientMeta,request:this._formatRequest(e)}]}),this.handshakeId=r.id,this.handshakeTopic=s.uuid(),this._eventManager.trigger({event:"display_uri",params:[this.uri]}),this.on("modal_closed",(function(){throw new Error(c.ERROR_QRCODE_MODAL_USER_CLOSED)})),i=function(){a.killSession()},t.prev=9,t.next=12,this._sendCallRequest(r);case 12:return(o=t.sent)&&i(),t.abrupt("return",o);case 17:throw t.prev=17,t.t0=t.catch(9),i(),t.t0;case 21:case"end":return t.stop()}}),t,this,[[9,17]])})))}},{key:"connect",value:function(e){var t=this;if(!this._qrcodeModal)throw new Error(c.ERROR_QRCODE_MODAL_NOT_PROVIDED);return new Promise((function(r,i){return a.__awaiter(t,void 0,void 0,n.mark((function t(){return n.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.connected&&r({chainId:this.chainId,accounts:this.accounts}),this.connected){t.next=10;break}return t.prev=2,t.next=5,this.createSession(e);case 5:t.next=10;break;case 7:t.prev=7,t.t0=t.catch(2),i(t.t0);case 10:this.on("modal_closed",(function(){return i(new Error(c.ERROR_QRCODE_MODAL_USER_CLOSED))})),this.on("connect",(function(e,t){if(e)return i(e);r(t.params[0])}));case 12:case"end":return t.stop()}}),t,this,[[2,7]])})))}))}},{key:"createSession",value:function(e){return a.__awaiter(this,void 0,void 0,n.mark((function t(){var r;return n.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this._connected){t.next=2;break}throw new Error(c.ERROR_SESSION_CONNECTED);case 2:if(!this.pending){t.next=4;break}return t.abrupt("return");case 4:return t.next=6,this._generateKey();case 6:this._key=t.sent,r=this._formatRequest({method:"wc_sessionRequest",params:[{peerId:this.clientId,peerMeta:this.clientMeta,chainId:e&&e.chainId?e.chainId:null}]}),this.handshakeId=r.id,this.handshakeTopic=s.uuid(),this._sendSessionRequest(r,"Session update rejected",{topic:this.handshakeTopic}),this._eventManager.trigger({event:"display_uri",params:[this.uri]});case 12:case"end":return t.stop()}}),t,this)})))}},{key:"approveSession",value:function(e){if(this._connected)throw new Error(c.ERROR_SESSION_CONNECTED);this.chainId=e.chainId,this.accounts=e.accounts,this.networkId=e.networkId||0,this.rpcUrl=e.rpcUrl||"";var t={approved:!0,chainId:this.chainId,networkId:this.networkId,accounts:this.accounts,rpcUrl:this.rpcUrl,peerId:this.clientId,peerMeta:this.clientMeta},r={id:this.handshakeId,jsonrpc:"2.0",result:t};this._sendResponse(r),this._connected=!0,this._setStorageSession(),this._eventManager.trigger({event:"connect",params:[{peerId:this.peerId,peerMeta:this.peerMeta,chainId:this.chainId,accounts:this.accounts}]})}},{key:"rejectSession",value:function(e){if(this._connected)throw new Error(c.ERROR_SESSION_CONNECTED);var t=e&&e.message?e.message:c.ERROR_SESSION_REJECTED,r=this._formatResponse({id:this.handshakeId,error:{message:t}});this._sendResponse(r),this._connected=!1,this._eventManager.trigger({event:"disconnect",params:[{message:t}]}),this._removeStorageSession()}},{key:"updateSession",value:function(e){if(!this._connected)throw new Error(c.ERROR_SESSION_DISCONNECTED);this.chainId=e.chainId,this.accounts=e.accounts,this.networkId=e.networkId||0,this.rpcUrl=e.rpcUrl||"";var t={approved:!0,chainId:this.chainId,networkId:this.networkId,accounts:this.accounts,rpcUrl:this.rpcUrl},r=this._formatRequest({method:"wc_sessionUpdate",params:[t]});this._sendSessionRequest(r,"Session update rejected"),this._eventManager.trigger({event:"session_update",params:[{chainId:this.chainId,accounts:this.accounts}]}),this._manageStorageSession()}},{key:"killSession",value:function(e){return a.__awaiter(this,void 0,void 0,n.mark((function t(){var r,i,o;return n.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e?e.message:"Session Disconnected",i={approved:!1,chainId:null,networkId:null,accounts:null},o=this._formatRequest({method:"wc_sessionUpdate",params:[i]}),t.next=5,this._sendRequest(o);case 5:this._handleSessionDisconnect(r);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"sendTransaction",value:function(e){return a.__awaiter(this,void 0,void 0,n.mark((function t(){var r,i,o;return n.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._connected){t.next=2;break}throw new Error(c.ERROR_SESSION_DISCONNECTED);case 2:return r=s.parseTransactionData(e),i=this._formatRequest({method:"eth_sendTransaction",params:[r]}),t.next=6,this._sendCallRequest(i);case 6:return o=t.sent,t.abrupt("return",o);case 8:case"end":return t.stop()}}),t,this)})))}},{key:"signTransaction",value:function(e){return a.__awaiter(this,void 0,void 0,n.mark((function t(){var r,i,o;return n.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._connected){t.next=2;break}throw new Error(c.ERROR_SESSION_DISCONNECTED);case 2:return r=s.parseTransactionData(e),i=this._formatRequest({method:"eth_signTransaction",params:[r]}),t.next=6,this._sendCallRequest(i);case 6:return o=t.sent,t.abrupt("return",o);case 8:case"end":return t.stop()}}),t,this)})))}},{key:"signMessage",value:function(e){return a.__awaiter(this,void 0,void 0,n.mark((function t(){var r,i;return n.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._connected){t.next=2;break}throw new Error(c.ERROR_SESSION_DISCONNECTED);case 2:return r=this._formatRequest({method:"eth_sign",params:e}),t.next=5,this._sendCallRequest(r);case 5:return i=t.sent,t.abrupt("return",i);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"signPersonalMessage",value:function(e){return a.__awaiter(this,void 0,void 0,n.mark((function t(){var r,i;return n.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._connected){t.next=2;break}throw new Error(c.ERROR_SESSION_DISCONNECTED);case 2:return e=s.parsePersonalSign(e),r=this._formatRequest({method:"personal_sign",params:e}),t.next=6,this._sendCallRequest(r);case 6:return i=t.sent,t.abrupt("return",i);case 8:case"end":return t.stop()}}),t,this)})))}},{key:"signTypedData",value:function(e){return a.__awaiter(this,void 0,void 0,n.mark((function t(){var r,i;return n.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._connected){t.next=2;break}throw new Error(c.ERROR_SESSION_DISCONNECTED);case 2:return r=this._formatRequest({method:"eth_signTypedData",params:e}),t.next=5,this._sendCallRequest(r);case 5:return i=t.sent,t.abrupt("return",i);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"updateChain",value:function(e){return a.__awaiter(this,void 0,void 0,n.mark((function t(){var r,i;return n.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._connected){t.next=2;break}throw new Error("Session currently disconnected");case 2:return r=this._formatRequest({method:"wallet_updateChain",params:[e]}),t.next=5,this._sendCallRequest(r);case 5:return i=t.sent,t.abrupt("return",i);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"unsafeSend",value:function(e,t){var r=this;return this._sendRequest(e,t),new Promise((function(t,n){r._subscribeToResponse(e.id,(function(e,r){if(e)n(e);else{if(!r)throw new Error(c.ERROR_MISSING_JSON_RPC);t(r)}}))}))}},{key:"sendCustomRequest",value:function(e,t){return a.__awaiter(this,void 0,void 0,n.mark((function r(){var i,o;return n.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(this._connected){r.next=2;break}throw new Error(c.ERROR_SESSION_DISCONNECTED);case 2:r.t0=e.method,r.next="eth_accounts"===r.t0?5:"eth_chainId"===r.t0?6:"eth_sendTransaction"===r.t0||"eth_signTransaction"===r.t0?7:"personal_sign"===r.t0?9:11;break;case 5:return r.abrupt("return",this.accounts);case 6:return r.abrupt("return",s.convertNumberToHex(this.chainId));case 7:return e.params&&(e.params[0]=s.parseTransactionData(e.params[0])),r.abrupt("break",12);case 9:return e.params&&(e.params=s.parsePersonalSign(e.params)),r.abrupt("break",12);case 11:return r.abrupt("break",12);case 12:return i=this._formatRequest(e),r.next=15,this._sendCallRequest(i,t);case 15:return o=r.sent,r.abrupt("return",o);case 17:case"end":return r.stop()}}),r,this)})))}},{key:"approveRequest",value:function(e){if(!s.isJsonRpcResponseSuccess(e))throw new Error(c.ERROR_MISSING_RESULT);var t=this._formatResponse(e);this._sendResponse(t)}},{key:"rejectRequest",value:function(e){if(!s.isJsonRpcResponseError(e))throw new Error(c.ERROR_MISSING_ERROR);var t=this._formatResponse(e);this._sendResponse(t)}},{key:"_sendRequest",value:function(e,t){var r,i;return a.__awaiter(this,void 0,void 0,n.mark((function o(){var a,u,c,f,l;return n.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return a=this._formatRequest(e),n.next=3,this._encrypt(a);case 3:u=n.sent,c="undefined"!==typeof(null===(r=t)||void 0===r?void 0:r.topic)?t.topic:this.peerId,f=JSON.stringify(u),l="undefined"!==typeof(null===(i=t)||void 0===i?void 0:i.forcePushNotification)?!t.forcePushNotification:s.isSilentPayload(a),this._transport.send(f,c,l);case 8:case"end":return n.stop()}}),o,this)})))}},{key:"_sendResponse",value:function(e){return a.__awaiter(this,void 0,void 0,n.mark((function t(){var r,i,o;return n.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._encrypt(e);case 2:r=t.sent,i=this.peerId,o=JSON.stringify(r),!0,this._transport.send(o,i,!0);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"_sendSessionRequest",value:function(e,t,r){return a.__awaiter(this,void 0,void 0,n.mark((function i(){return n.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:this._sendRequest(e,r),this._subscribeToSessionResponse(e.id,t);case 2:case"end":return n.stop()}}),i,this)})))}},{key:"_sendCallRequest",value:function(e,t){if(this._sendRequest(e,t),s.isMobile()&&s.signingMethods.includes(e.method)){var r=s.getLocal(s.mobileLinkChoiceKey);r&&(window.location.href=r.href)}return this._subscribeToCallResponse(e.id)}},{key:"_formatRequest",value:function(e){if("undefined"===typeof e.method)throw new Error(c.ERROR_MISSING_METHOD);return{id:"undefined"===typeof e.id?s.payloadId():e.id,jsonrpc:"2.0",method:e.method,params:"undefined"===typeof e.params?[]:e.params}}},{key:"_formatResponse",value:function(e){if("undefined"===typeof e.id)throw new Error(c.ERROR_MISSING_ID);var t={id:e.id,jsonrpc:"2.0"};if(s.isJsonRpcResponseError(e)){var r=s.formatRpcError(e.error);return Object.assign(Object.assign(Object.assign({},t),e),{error:r})}if(s.isJsonRpcResponseSuccess(e))return Object.assign(Object.assign({},t),e);throw new Error(c.ERROR_INVALID_RESPONSE)}},{key:"_handleSessionDisconnect",value:function(e){var t=e||"Session Disconnected";this._connected||(this._qrcodeModal&&this._qrcodeModal.close(),s.removeLocal(s.mobileLinkChoiceKey)),this._connected&&(this._connected=!1),this._eventManager.trigger({event:"disconnect",params:[{message:t}]}),this._removeStorageSession(),this._transport.close()}},{key:"_handleSessionResponse",value:function(e,t){t&&t.approved?(this._connected?(t.chainId&&(this.chainId=t.chainId),t.accounts&&(this.accounts=t.accounts),this._eventManager.trigger({event:"session_update",params:[{chainId:this.chainId,accounts:this.accounts}]})):(this._connected=!0,t.chainId&&(this.chainId=t.chainId),t.accounts&&(this.accounts=t.accounts),t.peerId&&!this.peerId&&(this.peerId=t.peerId),t.peerMeta&&!this.peerMeta&&(this.peerMeta=t.peerMeta),this._eventManager.trigger({event:"connect",params:[{peerId:this.peerId,peerMeta:this.peerMeta,chainId:this.chainId,accounts:this.accounts}]})),this._manageStorageSession()):this._handleSessionDisconnect(e)}},{key:"_handleIncomingMessages",value:function(e){return a.__awaiter(this,void 0,void 0,n.mark((function t(){var r,i;return n.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if([this.clientId,this.handshakeTopic].includes(e.topic)){t.next=3;break}return t.abrupt("return");case 3:t.prev=3,r=JSON.parse(e.payload),t.next=10;break;case 7:return t.prev=7,t.t0=t.catch(3),t.abrupt("return");case 10:return t.next=12,this._decrypt(r);case 12:(i=t.sent)&&this._eventManager.trigger(i);case 14:case"end":return t.stop()}}),t,this,[[3,7]])})))}},{key:"_subscribeToSessionRequest",value:function(){this._transport.subscribe(this.handshakeTopic)}},{key:"_subscribeToResponse",value:function(e,t){this.on("response:".concat(e),t)}},{key:"_subscribeToSessionResponse",value:function(e,t){var r=this;this._subscribeToResponse(e,(function(e,n){e?r._handleSessionResponse(e.message):n.result?r._handleSessionResponse(t,n.result):n.error&&n.error.message?r._handleSessionResponse(n.error.message):r._handleSessionResponse(t)}))}},{key:"_subscribeToCallResponse",value:function(e){var t=this;return new Promise((function(r,n){t._subscribeToResponse(e,(function(e,t){e?n(e):t.result?r(t.result):t.error&&t.error.message?n(new Error(t.error.message)):n(new Error(c.ERROR_INVALID_RESPONSE))}))}))}},{key:"_subscribeToInternalEvents",value:function(){var e=this;this.on("display_uri",(function(){e._qrcodeModal&&e._qrcodeModal.open(e.uri,(function(){e._eventManager.trigger({event:"modal_closed",params:[]})}),e._qrcodeModalOptions)})),this.on("connect",(function(){e._qrcodeModal&&e._qrcodeModal.close()})),this.on("wc_sessionRequest",(function(t,r){t&&e._eventManager.trigger({event:"error",params:[{code:"SESSION_REQUEST_ERROR",message:t.toString()}]}),e.handshakeId=r.id,e.peerId=r.params[0].peerId,e.peerMeta=r.params[0].peerMeta;var n=Object.assign(Object.assign({},r),{method:"session_request"});e._eventManager.trigger(n)})),this.on("wc_sessionUpdate",(function(t,r){t&&e._handleSessionResponse(t.message),e._handleSessionResponse("Session disconnected",r.params[0])}))}},{key:"_initTransport",value:function(){var e=this;this._transport.on("message",(function(t){return e._handleIncomingMessages(t)})),this._transport.on("open",(function(){return e._eventManager.trigger({event:"transport_open",params:[]})})),this._transport.on("close",(function(){return e._eventManager.trigger({event:"transport_close",params:[]})})),this._transport.open()}},{key:"_formatUri",value:function(){var e=this.protocol,t=this.handshakeTopic,r=this.version,n=encodeURIComponent(this.bridge),i=this.key;return"".concat(e,":").concat(t,"@").concat(r,"?bridge=").concat(n,"&key=").concat(i)}},{key:"_parseUri",value:function(e){var t=s.parseWalletConnectUri(e);if(t.protocol===this.protocol){if(!t.handshakeTopic)throw Error("Invalid or missing handshakeTopic parameter value");var r=t.handshakeTopic;if(!t.bridge)throw Error("Invalid or missing bridge url parameter value");var n=decodeURIComponent(t.bridge);if(!t.key)throw Error("Invalid or missing kkey parameter value");return{handshakeTopic:r,bridge:n,key:t.key}}throw new Error(c.ERROR_INVALID_URI)}},{key:"_generateKey",value:function(){return a.__awaiter(this,void 0,void 0,n.mark((function e(){var t;return n.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._cryptoLib){e.next=5;break}return e.next=3,this._cryptoLib.generateKey();case 3:return t=e.sent,e.abrupt("return",t);case 5:return e.abrupt("return",null);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"_encrypt",value:function(e){return a.__awaiter(this,void 0,void 0,n.mark((function t(){var r,i;return n.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=this._key,!this._cryptoLib||!r){t.next=6;break}return t.next=4,this._cryptoLib.encrypt(e,r);case 4:return i=t.sent,t.abrupt("return",i);case 6:return t.abrupt("return",null);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"_decrypt",value:function(e){return a.__awaiter(this,void 0,void 0,n.mark((function t(){var r,i;return n.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=this._key,!this._cryptoLib||!r){t.next=6;break}return t.next=4,this._cryptoLib.decrypt(e,r);case 4:return i=t.sent,t.abrupt("return",i);case 6:return t.abrupt("return",null);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"_getStorageSession",value:function(){var e=null;return this._sessionStorage&&(e=this._sessionStorage.getSession()),e}},{key:"_setStorageSession",value:function(){this._sessionStorage&&this._sessionStorage.setSession(this.session)}},{key:"_removeStorageSession",value:function(){this._sessionStorage&&this._sessionStorage.removeSession()}},{key:"_manageStorageSession",value:function(){this._connected?this._setStorageSession():this._removeStorageSession()}},{key:"_registerPushServer",value:function(e){var t=this;if(!e.url||"string"!==typeof e.url)throw Error("Invalid or missing pushServerOpts.url parameter value");if(!e.type||"string"!==typeof e.type)throw Error("Invalid or missing pushServerOpts.type parameter value");if(!e.token||"string"!==typeof e.token)throw Error("Invalid or missing pushServerOpts.token parameter value");var r={bridge:this.bridge,topic:this.clientId,type:e.type,token:e.token,peerName:"",language:e.language||""};this.on("connect",(function(i,o){return a.__awaiter(t,void 0,void 0,n.mark((function t(){var a,s;return n.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!i){t.next=2;break}throw i;case 2:return e.peerMeta&&(a=o.params[0].peerMeta.name,r.peerName=a),t.prev=3,t.next=6,fetch("".concat(e.url,"/new"),{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(r)});case 6:return s=t.sent,t.next=9,s.json();case 9:if(t.sent.success){t.next=12;break}throw Error("Failed to register in Push Server");case 12:t.next=17;break;case 14:throw t.prev=14,t.t0=t.catch(3),Error("Failed to register in Push Server");case 17:case"end":return t.stop()}}),t,null,[[3,14]])})))}))}},{key:"bridge",set:function(e){e&&(this._bridge=e)},get:function(){return this._bridge}},{key:"key",set:function(e){if(e){var t=s.convertHexToArrayBuffer(e);this._key=t}},get:function(){return this._key?s.convertArrayBufferToHex(this._key,!0):""}},{key:"clientId",set:function(e){e&&(this._clientId=e)},get:function(){var e=this._clientId;return e||(e=this._clientId=s.uuid()),this._clientId}},{key:"peerId",set:function(e){e&&(this._peerId=e)},get:function(){return this._peerId}},{key:"clientMeta",set:function(e){},get:function(){var e=this._clientMeta;return e||(e=this._clientMeta=s.getMeta()),e}},{key:"peerMeta",set:function(e){this._peerMeta=e},get:function(){return this._peerMeta}},{key:"handshakeTopic",set:function(e){e&&(this._handshakeTopic=e)},get:function(){return this._handshakeTopic}},{key:"handshakeId",set:function(e){e&&(this._handshakeId=e)},get:function(){return this._handshakeId}},{key:"uri",get:function(){return this._formatUri()},set:function(e){if(e){var t=this._parseUri(e),r=t.handshakeTopic,n=t.bridge,i=t.key;this.handshakeTopic=r,this.bridge=n,this.key=i}}},{key:"chainId",set:function(e){this._chainId=e},get:function(){return this._chainId}},{key:"networkId",set:function(e){this._networkId=e},get:function(){return this._networkId}},{key:"accounts",set:function(e){this._accounts=e},get:function(){return this._accounts}},{key:"rpcUrl",set:function(e){this._rpcUrl=e},get:function(){return this._rpcUrl}},{key:"connected",set:function(e){},get:function(){return this._connected}},{key:"pending",set:function(e){},get:function(){return!!this._handshakeTopic}},{key:"session",get:function(){return{connected:this.connected,accounts:this.accounts,chainId:this.chainId,bridge:this.bridge,key:this.key,clientId:this.clientId,clientMeta:this.clientMeta,peerId:this.peerId,peerMeta:this.peerMeta,handshakeId:this.handshakeId,handshakeTopic:this.handshakeTopic}},set:function(e){e&&(this._connected=e.connected,this.accounts=e.accounts,this.chainId=e.chainId,this.bridge=e.bridge,this.key=e.key,this.clientId=e.clientId,this.clientMeta=e.clientMeta,this.peerId=e.peerId,this.peerMeta=e.peerMeta,this.handshakeId=e.handshakeId,this.handshakeTopic=e.handshakeTopic)}}]),e}();t.default=h},1006:function(e,t,r){"use strict";(function(e){var r=this&&this.__spreadArrays||function(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;var n=Array(e),i=0;for(t=0;t<r;t++)for(var o=arguments[t],a=0,s=o.length;a<s;a++,i++)n[i]=o[a];return n};Object.defineProperty(t,"__esModule",{value:!0});var n=function(e,t,r){this.name=e,this.version=t,this.os=r,this.type="browser"};t.BrowserInfo=n;var i=function(t){this.version=t,this.type="node",this.name="node",this.os=e.platform};t.NodeInfo=i;var o=function(e,t,r,n){this.name=e,this.version=t,this.os=r,this.bot=n,this.type="bot-device"};t.SearchBotDeviceInfo=o;var a=function(){this.type="bot",this.bot=!0,this.name="bot",this.version=null,this.os=null};t.BotInfo=a;var s=function(){this.type="react-native",this.name="react-native",this.version=null,this.os=null};t.ReactNativeInfo=s;var u=/(nuhk|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/,c=[["aol",/AOLShield\/([0-9\._]+)/],["edge",/Edge\/([0-9\._]+)/],["edge-ios",/EdgiOS\/([0-9\._]+)/],["yandexbrowser",/YaBrowser\/([0-9\._]+)/],["kakaotalk",/KAKAOTALK\s([0-9\.]+)/],["samsung",/SamsungBrowser\/([0-9\.]+)/],["silk",/\bSilk\/([0-9._-]+)\b/],["miui",/MiuiBrowser\/([0-9\.]+)$/],["beaker",/BeakerBrowser\/([0-9\.]+)/],["edge-chromium",/Edg\/([0-9\.]+)/],["chromium-webview",/(?!Chrom.*OPR)wv\).*Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["chrome",/(?!Chrom.*OPR)Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["phantomjs",/PhantomJS\/([0-9\.]+)(:?\s|$)/],["crios",/CriOS\/([0-9\.]+)(:?\s|$)/],["firefox",/Firefox\/([0-9\.]+)(?:\s|$)/],["fxios",/FxiOS\/([0-9\.]+)/],["opera-mini",/Opera Mini.*Version\/([0-9\.]+)/],["opera",/Opera\/([0-9\.]+)(?:\s|$)/],["opera",/OPR\/([0-9\.]+)(:?\s|$)/],["ie",/Trident\/7\.0.*rv\:([0-9\.]+).*\).*Gecko$/],["ie",/MSIE\s([0-9\.]+);.*Trident\/[4-7].0/],["ie",/MSIE\s(7\.0)/],["bb10",/BB10;\sTouch.*Version\/([0-9\.]+)/],["android",/Android\s([0-9\.]+)/],["ios",/Version\/([0-9\._]+).*Mobile.*Safari.*/],["safari",/Version\/([0-9\._]+).*Safari/],["facebook",/FBAV\/([0-9\.]+)/],["instagram",/Instagram\s([0-9\.]+)/],["ios-webview",/AppleWebKit\/([0-9\.]+).*Mobile/],["ios-webview",/AppleWebKit\/([0-9\.]+).*Gecko\)$/],["searchbot",/alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/]],f=[["iOS",/iP(hone|od|ad)/],["Android OS",/Android/],["BlackBerry OS",/BlackBerry|BB10/],["Windows Mobile",/IEMobile/],["Amazon OS",/Kindle/],["Windows 3.11",/Win16/],["Windows 95",/(Windows 95)|(Win95)|(Windows_95)/],["Windows 98",/(Windows 98)|(Win98)/],["Windows 2000",/(Windows NT 5.0)|(Windows 2000)/],["Windows XP",/(Windows NT 5.1)|(Windows XP)/],["Windows Server 2003",/(Windows NT 5.2)/],["Windows Vista",/(Windows NT 6.0)/],["Windows 7",/(Windows NT 6.1)/],["Windows 8",/(Windows NT 6.2)/],["Windows 8.1",/(Windows NT 6.3)/],["Windows 10",/(Windows NT 10.0)/],["Windows ME",/Windows ME/],["Open BSD",/OpenBSD/],["Sun OS",/SunOS/],["Chrome OS",/CrOS/],["Linux",/(Linux)|(X11)/],["Mac OS",/(Mac_PowerPC)|(Macintosh)/],["QNX",/QNX/],["BeOS",/BeOS/],["OS/2",/OS\/2/]];function l(e){return""!==e&&c.reduce((function(t,r){var n=r[0],i=r[1];if(t)return t;var o=i.exec(e);return!!o&&[n,o]}),!1)}function h(e){var t=l(e);if(!t)return null;var i=t[0],s=t[1];if("searchbot"===i)return new a;var c=s[1]&&s[1].split(/[._]/).slice(0,3);c?c.length<3&&(c=r(c,function(e){for(var t=[],r=0;r<e;r++)t.push("0");return t}(3-c.length))):c=[];var f=c.join("."),h=d(e),p=u.exec(e);return p&&p[1]?new o(i,f,h,p[1]):new n(i,c.join("."),h)}function d(e){for(var t=0,r=f.length;t<r;t++){var n=f[t],i=n[0];if(n[1].exec(e))return i}return null}function p(){return"undefined"!==typeof e&&e.version?new i(e.version.slice(1)):null}t.detect=function(e){return e?h(e):"undefined"===typeof document&&"undefined"!==typeof navigator&&"ReactNative"===navigator.product?new s:"undefined"!==typeof navigator?h(navigator.userAgent):p()},t.browserName=function(e){var t=l(e);return t?t[0]:null},t.parseUserAgent=h,t.detectOS=d,t.getNodeVersion=p}).call(this,r(74))},1007:function(e,t,r){(function(e){!function(e,t){"use strict";function n(e,t){if(!e)throw new Error(t||"Assertion failed")}function i(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}function o(e,t,r){if(o.isBN(e))return e;this.negative=0,this.words=null,this.length=0,this.red=null,null!==e&&("le"!==t&&"be"!==t||(r=t,t=10),this._init(e||0,t||10,r||"be"))}var a;"object"===typeof e?e.exports=o:t.BN=o,o.BN=o,o.wordSize=26;try{a=r(1008).Buffer}catch(k){}function s(e,t,r){for(var n=0,i=Math.min(e.length,r),o=t;o<i;o++){var a=e.charCodeAt(o)-48;n<<=4,n|=a>=49&&a<=54?a-49+10:a>=17&&a<=22?a-17+10:15&a}return n}function u(e,t,r,n){for(var i=0,o=Math.min(e.length,r),a=t;a<o;a++){var s=e.charCodeAt(a)-48;i*=n,i+=s>=49?s-49+10:s>=17?s-17+10:s}return i}o.isBN=function(e){return e instanceof o||null!==e&&"object"===typeof e&&e.constructor.wordSize===o.wordSize&&Array.isArray(e.words)},o.max=function(e,t){return e.cmp(t)>0?e:t},o.min=function(e,t){return e.cmp(t)<0?e:t},o.prototype._init=function(e,t,r){if("number"===typeof e)return this._initNumber(e,t,r);if("object"===typeof e)return this._initArray(e,t,r);"hex"===t&&(t=16),n(t===(0|t)&&t>=2&&t<=36);var i=0;"-"===(e=e.toString().replace(/\s+/g,""))[0]&&i++,16===t?this._parseHex(e,i):this._parseBase(e,t,i),"-"===e[0]&&(this.negative=1),this.strip(),"le"===r&&this._initArray(this.toArray(),t,r)},o.prototype._initNumber=function(e,t,r){e<0&&(this.negative=1,e=-e),e<67108864?(this.words=[67108863&e],this.length=1):e<4503599627370496?(this.words=[67108863&e,e/67108864&67108863],this.length=2):(n(e<9007199254740992),this.words=[67108863&e,e/67108864&67108863,1],this.length=3),"le"===r&&this._initArray(this.toArray(),t,r)},o.prototype._initArray=function(e,t,r){if(n("number"===typeof e.length),e.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(e.length/3),this.words=new Array(this.length);for(var i=0;i<this.length;i++)this.words[i]=0;var o,a,s=0;if("be"===r)for(i=e.length-1,o=0;i>=0;i-=3)a=e[i]|e[i-1]<<8|e[i-2]<<16,this.words[o]|=a<<s&67108863,this.words[o+1]=a>>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);else if("le"===r)for(i=0,o=0;i<e.length;i+=3)a=e[i]|e[i+1]<<8|e[i+2]<<16,this.words[o]|=a<<s&67108863,this.words[o+1]=a>>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);return this.strip()},o.prototype._parseHex=function(e,t){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var r=0;r<this.length;r++)this.words[r]=0;var n,i,o=0;for(r=e.length-6,n=0;r>=t;r-=6)i=s(e,r,r+6),this.words[n]|=i<<o&67108863,this.words[n+1]|=i>>>26-o&4194303,(o+=24)>=26&&(o-=26,n++);r+6!==t&&(i=s(e,t,r+6),this.words[n]|=i<<o&67108863,this.words[n+1]|=i>>>26-o&4194303),this.strip()},o.prototype._parseBase=function(e,t,r){this.words=[0],this.length=1;for(var n=0,i=1;i<=67108863;i*=t)n++;n--,i=i/t|0;for(var o=e.length-r,a=o%n,s=Math.min(o,o-a)+r,c=0,f=r;f<s;f+=n)c=u(e,f,f+n,t),this.imuln(i),this.words[0]+c<67108864?this.words[0]+=c:this._iaddn(c);if(0!==a){var l=1;for(c=u(e,f,e.length,t),f=0;f<a;f++)l*=t;this.imuln(l),this.words[0]+c<67108864?this.words[0]+=c:this._iaddn(c)}},o.prototype.copy=function(e){e.words=new Array(this.length);for(var t=0;t<this.length;t++)e.words[t]=this.words[t];e.length=this.length,e.negative=this.negative,e.red=this.red},o.prototype.clone=function(){var e=new o(null);return this.copy(e),e},o.prototype._expand=function(e){for(;this.length<e;)this.words[this.length++]=0;return this},o.prototype.strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},o.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},o.prototype.inspect=function(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"};var c=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],f=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],l=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function h(e,t,r){r.negative=t.negative^e.negative;var n=e.length+t.length|0;r.length=n,n=n-1|0;var i=0|e.words[0],o=0|t.words[0],a=i*o,s=67108863&a,u=a/67108864|0;r.words[0]=s;for(var c=1;c<n;c++){for(var f=u>>>26,l=67108863&u,h=Math.min(c,t.length-1),d=Math.max(0,c-e.length+1);d<=h;d++){var p=c-d|0;f+=(a=(i=0|e.words[p])*(o=0|t.words[d])+l)/67108864|0,l=67108863&a}r.words[c]=0|l,u=0|f}return 0!==u?r.words[c]=0|u:r.length--,r.strip()}o.prototype.toString=function(e,t){var r;if(t=0|t||1,16===(e=e||10)||"hex"===e){r="";for(var i=0,o=0,a=0;a<this.length;a++){var s=this.words[a],u=(16777215&(s<<i|o)).toString(16);r=0!==(o=s>>>24-i&16777215)||a!==this.length-1?c[6-u.length]+u+r:u+r,(i+=2)>=26&&(i-=26,a--)}for(0!==o&&(r=o.toString(16)+r);r.length%t!==0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}if(e===(0|e)&&e>=2&&e<=36){var h=f[e],d=l[e];r="";var p=this.clone();for(p.negative=0;!p.isZero();){var v=p.modn(d).toString(e);r=(p=p.idivn(d)).isZero()?v+r:c[h-v.length]+v+r}for(this.isZero()&&(r="0"+r);r.length%t!==0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}n(!1,"Base should be between 2 and 36")},o.prototype.toNumber=function(){var e=this.words[0];return 2===this.length?e+=67108864*this.words[1]:3===this.length&&1===this.words[2]?e+=4503599627370496+67108864*this.words[1]:this.length>2&&n(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-e:e},o.prototype.toJSON=function(){return this.toString(16)},o.prototype.toBuffer=function(e,t){return n("undefined"!==typeof a),this.toArrayLike(a,e,t)},o.prototype.toArray=function(e,t){return this.toArrayLike(Array,e,t)},o.prototype.toArrayLike=function(e,t,r){var i=this.byteLength(),o=r||Math.max(1,i);n(i<=o,"byte array longer than desired length"),n(o>0,"Requested array length <= 0"),this.strip();var a,s,u="le"===t,c=new e(o),f=this.clone();if(u){for(s=0;!f.isZero();s++)a=f.andln(255),f.iushrn(8),c[s]=a;for(;s<o;s++)c[s]=0}else{for(s=0;s<o-i;s++)c[s]=0;for(s=0;!f.isZero();s++)a=f.andln(255),f.iushrn(8),c[o-s-1]=a}return c},Math.clz32?o.prototype._countBits=function(e){return 32-Math.clz32(e)}:o.prototype._countBits=function(e){var t=e,r=0;return t>=4096&&(r+=13,t>>>=13),t>=64&&(r+=7,t>>>=7),t>=8&&(r+=4,t>>>=4),t>=2&&(r+=2,t>>>=2),r+t},o.prototype._zeroBits=function(e){if(0===e)return 26;var t=e,r=0;return 0===(8191&t)&&(r+=13,t>>>=13),0===(127&t)&&(r+=7,t>>>=7),0===(15&t)&&(r+=4,t>>>=4),0===(3&t)&&(r+=2,t>>>=2),0===(1&t)&&r++,r},o.prototype.bitLength=function(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},o.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,t=0;t<this.length;t++){var r=this._zeroBits(this.words[t]);if(e+=r,26!==r)break}return e},o.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},o.prototype.toTwos=function(e){return 0!==this.negative?this.abs().inotn(e).iaddn(1):this.clone()},o.prototype.fromTwos=function(e){return this.testn(e-1)?this.notn(e).iaddn(1).ineg():this.clone()},o.prototype.isNeg=function(){return 0!==this.negative},o.prototype.neg=function(){return this.clone().ineg()},o.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},o.prototype.iuor=function(e){for(;this.length<e.length;)this.words[this.length++]=0;for(var t=0;t<e.length;t++)this.words[t]=this.words[t]|e.words[t];return this.strip()},o.prototype.ior=function(e){return n(0===(this.negative|e.negative)),this.iuor(e)},o.prototype.or=function(e){return this.length>e.length?this.clone().ior(e):e.clone().ior(this)},o.prototype.uor=function(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},o.prototype.iuand=function(e){var t;t=this.length>e.length?e:this;for(var r=0;r<t.length;r++)this.words[r]=this.words[r]&e.words[r];return this.length=t.length,this.strip()},o.prototype.iand=function(e){return n(0===(this.negative|e.negative)),this.iuand(e)},o.prototype.and=function(e){return this.length>e.length?this.clone().iand(e):e.clone().iand(this)},o.prototype.uand=function(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},o.prototype.iuxor=function(e){var t,r;this.length>e.length?(t=this,r=e):(t=e,r=this);for(var n=0;n<r.length;n++)this.words[n]=t.words[n]^r.words[n];if(this!==t)for(;n<t.length;n++)this.words[n]=t.words[n];return this.length=t.length,this.strip()},o.prototype.ixor=function(e){return n(0===(this.negative|e.negative)),this.iuxor(e)},o.prototype.xor=function(e){return this.length>e.length?this.clone().ixor(e):e.clone().ixor(this)},o.prototype.uxor=function(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},o.prototype.inotn=function(e){n("number"===typeof e&&e>=0);var t=0|Math.ceil(e/26),r=e%26;this._expand(t),r>0&&t--;for(var i=0;i<t;i++)this.words[i]=67108863&~this.words[i];return r>0&&(this.words[i]=~this.words[i]&67108863>>26-r),this.strip()},o.prototype.notn=function(e){return this.clone().inotn(e)},o.prototype.setn=function(e,t){n("number"===typeof e&&e>=0);var r=e/26|0,i=e%26;return this._expand(r+1),this.words[r]=t?this.words[r]|1<<i:this.words[r]&~(1<<i),this.strip()},o.prototype.iadd=function(e){var t,r,n;if(0!==this.negative&&0===e.negative)return this.negative=0,t=this.isub(e),this.negative^=1,this._normSign();if(0===this.negative&&0!==e.negative)return e.negative=0,t=this.isub(e),e.negative=1,t._normSign();this.length>e.length?(r=this,n=e):(r=e,n=this);for(var i=0,o=0;o<n.length;o++)t=(0|r.words[o])+(0|n.words[o])+i,this.words[o]=67108863&t,i=t>>>26;for(;0!==i&&o<r.length;o++)t=(0|r.words[o])+i,this.words[o]=67108863&t,i=t>>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;o<r.length;o++)this.words[o]=r.words[o];return this},o.prototype.add=function(e){var t;return 0!==e.negative&&0===this.negative?(e.negative=0,t=this.sub(e),e.negative^=1,t):0===e.negative&&0!==this.negative?(this.negative=0,t=e.sub(this),this.negative=1,t):this.length>e.length?this.clone().iadd(e):e.clone().iadd(this)},o.prototype.isub=function(e){if(0!==e.negative){e.negative=0;var t=this.iadd(e);return e.negative=1,t._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var r,n,i=this.cmp(e);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(r=this,n=e):(r=e,n=this);for(var o=0,a=0;a<n.length;a++)o=(t=(0|r.words[a])-(0|n.words[a])+o)>>26,this.words[a]=67108863&t;for(;0!==o&&a<r.length;a++)o=(t=(0|r.words[a])+o)>>26,this.words[a]=67108863&t;if(0===o&&a<r.length&&r!==this)for(;a<r.length;a++)this.words[a]=r.words[a];return this.length=Math.max(this.length,a),r!==this&&(this.negative=1),this.strip()},o.prototype.sub=function(e){return this.clone().isub(e)};var d=function(e,t,r){var n,i,o,a=e.words,s=t.words,u=r.words,c=0,f=0|a[0],l=8191&f,h=f>>>13,d=0|a[1],p=8191&d,v=d>>>13,g=0|a[2],m=8191&g,y=g>>>13,w=0|a[3],A=8191&w,b=w>>>13,E=0|a[4],x=8191&E,k=E>>>13,C=0|a[5],S=8191&C,R=C>>>13,_=0|a[6],I=8191&_,M=_>>>13,L=0|a[7],T=8191&L,P=L>>>13,B=0|a[8],O=8191&B,N=B>>>13,H=0|a[9],D=8191&H,j=H>>>13,z=0|s[0],G=8191&z,U=z>>>13,F=0|s[1],K=8191&F,V=F>>>13,Y=0|s[2],W=8191&Y,X=Y>>>13,q=0|s[3],Z=8191&q,J=q>>>13,Q=0|s[4],$=8191&Q,ee=Q>>>13,te=0|s[5],re=8191&te,ne=te>>>13,ie=0|s[6],oe=8191&ie,ae=ie>>>13,se=0|s[7],ue=8191&se,ce=se>>>13,fe=0|s[8],le=8191&fe,he=fe>>>13,de=0|s[9],pe=8191&de,ve=de>>>13;r.negative=e.negative^t.negative,r.length=19;var ge=(c+(n=Math.imul(l,G))|0)+((8191&(i=(i=Math.imul(l,U))+Math.imul(h,G)|0))<<13)|0;c=((o=Math.imul(h,U))+(i>>>13)|0)+(ge>>>26)|0,ge&=67108863,n=Math.imul(p,G),i=(i=Math.imul(p,U))+Math.imul(v,G)|0,o=Math.imul(v,U);var me=(c+(n=n+Math.imul(l,K)|0)|0)+((8191&(i=(i=i+Math.imul(l,V)|0)+Math.imul(h,K)|0))<<13)|0;c=((o=o+Math.imul(h,V)|0)+(i>>>13)|0)+(me>>>26)|0,me&=67108863,n=Math.imul(m,G),i=(i=Math.imul(m,U))+Math.imul(y,G)|0,o=Math.imul(y,U),n=n+Math.imul(p,K)|0,i=(i=i+Math.imul(p,V)|0)+Math.imul(v,K)|0,o=o+Math.imul(v,V)|0;var ye=(c+(n=n+Math.imul(l,W)|0)|0)+((8191&(i=(i=i+Math.imul(l,X)|0)+Math.imul(h,W)|0))<<13)|0;c=((o=o+Math.imul(h,X)|0)+(i>>>13)|0)+(ye>>>26)|0,ye&=67108863,n=Math.imul(A,G),i=(i=Math.imul(A,U))+Math.imul(b,G)|0,o=Math.imul(b,U),n=n+Math.imul(m,K)|0,i=(i=i+Math.imul(m,V)|0)+Math.imul(y,K)|0,o=o+Math.imul(y,V)|0,n=n+Math.imul(p,W)|0,i=(i=i+Math.imul(p,X)|0)+Math.imul(v,W)|0,o=o+Math.imul(v,X)|0;var we=(c+(n=n+Math.imul(l,Z)|0)|0)+((8191&(i=(i=i+Math.imul(l,J)|0)+Math.imul(h,Z)|0))<<13)|0;c=((o=o+Math.imul(h,J)|0)+(i>>>13)|0)+(we>>>26)|0,we&=67108863,n=Math.imul(x,G),i=(i=Math.imul(x,U))+Math.imul(k,G)|0,o=Math.imul(k,U),n=n+Math.imul(A,K)|0,i=(i=i+Math.imul(A,V)|0)+Math.imul(b,K)|0,o=o+Math.imul(b,V)|0,n=n+Math.imul(m,W)|0,i=(i=i+Math.imul(m,X)|0)+Math.imul(y,W)|0,o=o+Math.imul(y,X)|0,n=n+Math.imul(p,Z)|0,i=(i=i+Math.imul(p,J)|0)+Math.imul(v,Z)|0,o=o+Math.imul(v,J)|0;var Ae=(c+(n=n+Math.imul(l,$)|0)|0)+((8191&(i=(i=i+Math.imul(l,ee)|0)+Math.imul(h,$)|0))<<13)|0;c=((o=o+Math.imul(h,ee)|0)+(i>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,n=Math.imul(S,G),i=(i=Math.imul(S,U))+Math.imul(R,G)|0,o=Math.imul(R,U),n=n+Math.imul(x,K)|0,i=(i=i+Math.imul(x,V)|0)+Math.imul(k,K)|0,o=o+Math.imul(k,V)|0,n=n+Math.imul(A,W)|0,i=(i=i+Math.imul(A,X)|0)+Math.imul(b,W)|0,o=o+Math.imul(b,X)|0,n=n+Math.imul(m,Z)|0,i=(i=i+Math.imul(m,J)|0)+Math.imul(y,Z)|0,o=o+Math.imul(y,J)|0,n=n+Math.imul(p,$)|0,i=(i=i+Math.imul(p,ee)|0)+Math.imul(v,$)|0,o=o+Math.imul(v,ee)|0;var be=(c+(n=n+Math.imul(l,re)|0)|0)+((8191&(i=(i=i+Math.imul(l,ne)|0)+Math.imul(h,re)|0))<<13)|0;c=((o=o+Math.imul(h,ne)|0)+(i>>>13)|0)+(be>>>26)|0,be&=67108863,n=Math.imul(I,G),i=(i=Math.imul(I,U))+Math.imul(M,G)|0,o=Math.imul(M,U),n=n+Math.imul(S,K)|0,i=(i=i+Math.imul(S,V)|0)+Math.imul(R,K)|0,o=o+Math.imul(R,V)|0,n=n+Math.imul(x,W)|0,i=(i=i+Math.imul(x,X)|0)+Math.imul(k,W)|0,o=o+Math.imul(k,X)|0,n=n+Math.imul(A,Z)|0,i=(i=i+Math.imul(A,J)|0)+Math.imul(b,Z)|0,o=o+Math.imul(b,J)|0,n=n+Math.imul(m,$)|0,i=(i=i+Math.imul(m,ee)|0)+Math.imul(y,$)|0,o=o+Math.imul(y,ee)|0,n=n+Math.imul(p,re)|0,i=(i=i+Math.imul(p,ne)|0)+Math.imul(v,re)|0,o=o+Math.imul(v,ne)|0;var Ee=(c+(n=n+Math.imul(l,oe)|0)|0)+((8191&(i=(i=i+Math.imul(l,ae)|0)+Math.imul(h,oe)|0))<<13)|0;c=((o=o+Math.imul(h,ae)|0)+(i>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,n=Math.imul(T,G),i=(i=Math.imul(T,U))+Math.imul(P,G)|0,o=Math.imul(P,U),n=n+Math.imul(I,K)|0,i=(i=i+Math.imul(I,V)|0)+Math.imul(M,K)|0,o=o+Math.imul(M,V)|0,n=n+Math.imul(S,W)|0,i=(i=i+Math.imul(S,X)|0)+Math.imul(R,W)|0,o=o+Math.imul(R,X)|0,n=n+Math.imul(x,Z)|0,i=(i=i+Math.imul(x,J)|0)+Math.imul(k,Z)|0,o=o+Math.imul(k,J)|0,n=n+Math.imul(A,$)|0,i=(i=i+Math.imul(A,ee)|0)+Math.imul(b,$)|0,o=o+Math.imul(b,ee)|0,n=n+Math.imul(m,re)|0,i=(i=i+Math.imul(m,ne)|0)+Math.imul(y,re)|0,o=o+Math.imul(y,ne)|0,n=n+Math.imul(p,oe)|0,i=(i=i+Math.imul(p,ae)|0)+Math.imul(v,oe)|0,o=o+Math.imul(v,ae)|0;var xe=(c+(n=n+Math.imul(l,ue)|0)|0)+((8191&(i=(i=i+Math.imul(l,ce)|0)+Math.imul(h,ue)|0))<<13)|0;c=((o=o+Math.imul(h,ce)|0)+(i>>>13)|0)+(xe>>>26)|0,xe&=67108863,n=Math.imul(O,G),i=(i=Math.imul(O,U))+Math.imul(N,G)|0,o=Math.imul(N,U),n=n+Math.imul(T,K)|0,i=(i=i+Math.imul(T,V)|0)+Math.imul(P,K)|0,o=o+Math.imul(P,V)|0,n=n+Math.imul(I,W)|0,i=(i=i+Math.imul(I,X)|0)+Math.imul(M,W)|0,o=o+Math.imul(M,X)|0,n=n+Math.imul(S,Z)|0,i=(i=i+Math.imul(S,J)|0)+Math.imul(R,Z)|0,o=o+Math.imul(R,J)|0,n=n+Math.imul(x,$)|0,i=(i=i+Math.imul(x,ee)|0)+Math.imul(k,$)|0,o=o+Math.imul(k,ee)|0,n=n+Math.imul(A,re)|0,i=(i=i+Math.imul(A,ne)|0)+Math.imul(b,re)|0,o=o+Math.imul(b,ne)|0,n=n+Math.imul(m,oe)|0,i=(i=i+Math.imul(m,ae)|0)+Math.imul(y,oe)|0,o=o+Math.imul(y,ae)|0,n=n+Math.imul(p,ue)|0,i=(i=i+Math.imul(p,ce)|0)+Math.imul(v,ue)|0,o=o+Math.imul(v,ce)|0;var ke=(c+(n=n+Math.imul(l,le)|0)|0)+((8191&(i=(i=i+Math.imul(l,he)|0)+Math.imul(h,le)|0))<<13)|0;c=((o=o+Math.imul(h,he)|0)+(i>>>13)|0)+(ke>>>26)|0,ke&=67108863,n=Math.imul(D,G),i=(i=Math.imul(D,U))+Math.imul(j,G)|0,o=Math.imul(j,U),n=n+Math.imul(O,K)|0,i=(i=i+Math.imul(O,V)|0)+Math.imul(N,K)|0,o=o+Math.imul(N,V)|0,n=n+Math.imul(T,W)|0,i=(i=i+Math.imul(T,X)|0)+Math.imul(P,W)|0,o=o+Math.imul(P,X)|0,n=n+Math.imul(I,Z)|0,i=(i=i+Math.imul(I,J)|0)+Math.imul(M,Z)|0,o=o+Math.imul(M,J)|0,n=n+Math.imul(S,$)|0,i=(i=i+Math.imul(S,ee)|0)+Math.imul(R,$)|0,o=o+Math.imul(R,ee)|0,n=n+Math.imul(x,re)|0,i=(i=i+Math.imul(x,ne)|0)+Math.imul(k,re)|0,o=o+Math.imul(k,ne)|0,n=n+Math.imul(A,oe)|0,i=(i=i+Math.imul(A,ae)|0)+Math.imul(b,oe)|0,o=o+Math.imul(b,ae)|0,n=n+Math.imul(m,ue)|0,i=(i=i+Math.imul(m,ce)|0)+Math.imul(y,ue)|0,o=o+Math.imul(y,ce)|0,n=n+Math.imul(p,le)|0,i=(i=i+Math.imul(p,he)|0)+Math.imul(v,le)|0,o=o+Math.imul(v,he)|0;var Ce=(c+(n=n+Math.imul(l,pe)|0)|0)+((8191&(i=(i=i+Math.imul(l,ve)|0)+Math.imul(h,pe)|0))<<13)|0;c=((o=o+Math.imul(h,ve)|0)+(i>>>13)|0)+(Ce>>>26)|0,Ce&=67108863,n=Math.imul(D,K),i=(i=Math.imul(D,V))+Math.imul(j,K)|0,o=Math.imul(j,V),n=n+Math.imul(O,W)|0,i=(i=i+Math.imul(O,X)|0)+Math.imul(N,W)|0,o=o+Math.imul(N,X)|0,n=n+Math.imul(T,Z)|0,i=(i=i+Math.imul(T,J)|0)+Math.imul(P,Z)|0,o=o+Math.imul(P,J)|0,n=n+Math.imul(I,$)|0,i=(i=i+Math.imul(I,ee)|0)+Math.imul(M,$)|0,o=o+Math.imul(M,ee)|0,n=n+Math.imul(S,re)|0,i=(i=i+Math.imul(S,ne)|0)+Math.imul(R,re)|0,o=o+Math.imul(R,ne)|0,n=n+Math.imul(x,oe)|0,i=(i=i+Math.imul(x,ae)|0)+Math.imul(k,oe)|0,o=o+Math.imul(k,ae)|0,n=n+Math.imul(A,ue)|0,i=(i=i+Math.imul(A,ce)|0)+Math.imul(b,ue)|0,o=o+Math.imul(b,ce)|0,n=n+Math.imul(m,le)|0,i=(i=i+Math.imul(m,he)|0)+Math.imul(y,le)|0,o=o+Math.imul(y,he)|0;var Se=(c+(n=n+Math.imul(p,pe)|0)|0)+((8191&(i=(i=i+Math.imul(p,ve)|0)+Math.imul(v,pe)|0))<<13)|0;c=((o=o+Math.imul(v,ve)|0)+(i>>>13)|0)+(Se>>>26)|0,Se&=67108863,n=Math.imul(D,W),i=(i=Math.imul(D,X))+Math.imul(j,W)|0,o=Math.imul(j,X),n=n+Math.imul(O,Z)|0,i=(i=i+Math.imul(O,J)|0)+Math.imul(N,Z)|0,o=o+Math.imul(N,J)|0,n=n+Math.imul(T,$)|0,i=(i=i+Math.imul(T,ee)|0)+Math.imul(P,$)|0,o=o+Math.imul(P,ee)|0,n=n+Math.imul(I,re)|0,i=(i=i+Math.imul(I,ne)|0)+Math.imul(M,re)|0,o=o+Math.imul(M,ne)|0,n=n+Math.imul(S,oe)|0,i=(i=i+Math.imul(S,ae)|0)+Math.imul(R,oe)|0,o=o+Math.imul(R,ae)|0,n=n+Math.imul(x,ue)|0,i=(i=i+Math.imul(x,ce)|0)+Math.imul(k,ue)|0,o=o+Math.imul(k,ce)|0,n=n+Math.imul(A,le)|0,i=(i=i+Math.imul(A,he)|0)+Math.imul(b,le)|0,o=o+Math.imul(b,he)|0;var Re=(c+(n=n+Math.imul(m,pe)|0)|0)+((8191&(i=(i=i+Math.imul(m,ve)|0)+Math.imul(y,pe)|0))<<13)|0;c=((o=o+Math.imul(y,ve)|0)+(i>>>13)|0)+(Re>>>26)|0,Re&=67108863,n=Math.imul(D,Z),i=(i=Math.imul(D,J))+Math.imul(j,Z)|0,o=Math.imul(j,J),n=n+Math.imul(O,$)|0,i=(i=i+Math.imul(O,ee)|0)+Math.imul(N,$)|0,o=o+Math.imul(N,ee)|0,n=n+Math.imul(T,re)|0,i=(i=i+Math.imul(T,ne)|0)+Math.imul(P,re)|0,o=o+Math.imul(P,ne)|0,n=n+Math.imul(I,oe)|0,i=(i=i+Math.imul(I,ae)|0)+Math.imul(M,oe)|0,o=o+Math.imul(M,ae)|0,n=n+Math.imul(S,ue)|0,i=(i=i+Math.imul(S,ce)|0)+Math.imul(R,ue)|0,o=o+Math.imul(R,ce)|0,n=n+Math.imul(x,le)|0,i=(i=i+Math.imul(x,he)|0)+Math.imul(k,le)|0,o=o+Math.imul(k,he)|0;var _e=(c+(n=n+Math.imul(A,pe)|0)|0)+((8191&(i=(i=i+Math.imul(A,ve)|0)+Math.imul(b,pe)|0))<<13)|0;c=((o=o+Math.imul(b,ve)|0)+(i>>>13)|0)+(_e>>>26)|0,_e&=67108863,n=Math.imul(D,$),i=(i=Math.imul(D,ee))+Math.imul(j,$)|0,o=Math.imul(j,ee),n=n+Math.imul(O,re)|0,i=(i=i+Math.imul(O,ne)|0)+Math.imul(N,re)|0,o=o+Math.imul(N,ne)|0,n=n+Math.imul(T,oe)|0,i=(i=i+Math.imul(T,ae)|0)+Math.imul(P,oe)|0,o=o+Math.imul(P,ae)|0,n=n+Math.imul(I,ue)|0,i=(i=i+Math.imul(I,ce)|0)+Math.imul(M,ue)|0,o=o+Math.imul(M,ce)|0,n=n+Math.imul(S,le)|0,i=(i=i+Math.imul(S,he)|0)+Math.imul(R,le)|0,o=o+Math.imul(R,he)|0;var Ie=(c+(n=n+Math.imul(x,pe)|0)|0)+((8191&(i=(i=i+Math.imul(x,ve)|0)+Math.imul(k,pe)|0))<<13)|0;c=((o=o+Math.imul(k,ve)|0)+(i>>>13)|0)+(Ie>>>26)|0,Ie&=67108863,n=Math.imul(D,re),i=(i=Math.imul(D,ne))+Math.imul(j,re)|0,o=Math.imul(j,ne),n=n+Math.imul(O,oe)|0,i=(i=i+Math.imul(O,ae)|0)+Math.imul(N,oe)|0,o=o+Math.imul(N,ae)|0,n=n+Math.imul(T,ue)|0,i=(i=i+Math.imul(T,ce)|0)+Math.imul(P,ue)|0,o=o+Math.imul(P,ce)|0,n=n+Math.imul(I,le)|0,i=(i=i+Math.imul(I,he)|0)+Math.imul(M,le)|0,o=o+Math.imul(M,he)|0;var Me=(c+(n=n+Math.imul(S,pe)|0)|0)+((8191&(i=(i=i+Math.imul(S,ve)|0)+Math.imul(R,pe)|0))<<13)|0;c=((o=o+Math.imul(R,ve)|0)+(i>>>13)|0)+(Me>>>26)|0,Me&=67108863,n=Math.imul(D,oe),i=(i=Math.imul(D,ae))+Math.imul(j,oe)|0,o=Math.imul(j,ae),n=n+Math.imul(O,ue)|0,i=(i=i+Math.imul(O,ce)|0)+Math.imul(N,ue)|0,o=o+Math.imul(N,ce)|0,n=n+Math.imul(T,le)|0,i=(i=i+Math.imul(T,he)|0)+Math.imul(P,le)|0,o=o+Math.imul(P,he)|0;var Le=(c+(n=n+Math.imul(I,pe)|0)|0)+((8191&(i=(i=i+Math.imul(I,ve)|0)+Math.imul(M,pe)|0))<<13)|0;c=((o=o+Math.imul(M,ve)|0)+(i>>>13)|0)+(Le>>>26)|0,Le&=67108863,n=Math.imul(D,ue),i=(i=Math.imul(D,ce))+Math.imul(j,ue)|0,o=Math.imul(j,ce),n=n+Math.imul(O,le)|0,i=(i=i+Math.imul(O,he)|0)+Math.imul(N,le)|0,o=o+Math.imul(N,he)|0;var Te=(c+(n=n+Math.imul(T,pe)|0)|0)+((8191&(i=(i=i+Math.imul(T,ve)|0)+Math.imul(P,pe)|0))<<13)|0;c=((o=o+Math.imul(P,ve)|0)+(i>>>13)|0)+(Te>>>26)|0,Te&=67108863,n=Math.imul(D,le),i=(i=Math.imul(D,he))+Math.imul(j,le)|0,o=Math.imul(j,he);var Pe=(c+(n=n+Math.imul(O,pe)|0)|0)+((8191&(i=(i=i+Math.imul(O,ve)|0)+Math.imul(N,pe)|0))<<13)|0;c=((o=o+Math.imul(N,ve)|0)+(i>>>13)|0)+(Pe>>>26)|0,Pe&=67108863;var Be=(c+(n=Math.imul(D,pe))|0)+((8191&(i=(i=Math.imul(D,ve))+Math.imul(j,pe)|0))<<13)|0;return c=((o=Math.imul(j,ve))+(i>>>13)|0)+(Be>>>26)|0,Be&=67108863,u[0]=ge,u[1]=me,u[2]=ye,u[3]=we,u[4]=Ae,u[5]=be,u[6]=Ee,u[7]=xe,u[8]=ke,u[9]=Ce,u[10]=Se,u[11]=Re,u[12]=_e,u[13]=Ie,u[14]=Me,u[15]=Le,u[16]=Te,u[17]=Pe,u[18]=Be,0!==c&&(u[19]=c,r.length++),r};function p(e,t,r){return(new v).mulp(e,t,r)}function v(e,t){this.x=e,this.y=t}Math.imul||(d=h),o.prototype.mulTo=function(e,t){var r=this.length+e.length;return 10===this.length&&10===e.length?d(this,e,t):r<63?h(this,e,t):r<1024?function(e,t,r){r.negative=t.negative^e.negative,r.length=e.length+t.length;for(var n=0,i=0,o=0;o<r.length-1;o++){var a=i;i=0;for(var s=67108863&n,u=Math.min(o,t.length-1),c=Math.max(0,o-e.length+1);c<=u;c++){var f=o-c,l=(0|e.words[f])*(0|t.words[c]),h=67108863&l;s=67108863&(h=h+s|0),i+=(a=(a=a+(l/67108864|0)|0)+(h>>>26)|0)>>>26,a&=67108863}r.words[o]=s,n=a,a=i}return 0!==n?r.words[o]=n:r.length--,r.strip()}(this,e,t):p(this,e,t)},v.prototype.makeRBT=function(e){for(var t=new Array(e),r=o.prototype._countBits(e)-1,n=0;n<e;n++)t[n]=this.revBin(n,r,e);return t},v.prototype.revBin=function(e,t,r){if(0===e||e===r-1)return e;for(var n=0,i=0;i<t;i++)n|=(1&e)<<t-i-1,e>>=1;return n},v.prototype.permute=function(e,t,r,n,i,o){for(var a=0;a<o;a++)n[a]=t[e[a]],i[a]=r[e[a]]},v.prototype.transform=function(e,t,r,n,i,o){this.permute(o,e,t,r,n,i);for(var a=1;a<i;a<<=1)for(var s=a<<1,u=Math.cos(2*Math.PI/s),c=Math.sin(2*Math.PI/s),f=0;f<i;f+=s)for(var l=u,h=c,d=0;d<a;d++){var p=r[f+d],v=n[f+d],g=r[f+d+a],m=n[f+d+a],y=l*g-h*m;m=l*m+h*g,g=y,r[f+d]=p+g,n[f+d]=v+m,r[f+d+a]=p-g,n[f+d+a]=v-m,d!==s&&(y=u*l-c*h,h=u*h+c*l,l=y)}},v.prototype.guessLen13b=function(e,t){var r=1|Math.max(t,e),n=1&r,i=0;for(r=r/2|0;r;r>>>=1)i++;return 1<<i+1+n},v.prototype.conjugate=function(e,t,r){if(!(r<=1))for(var n=0;n<r/2;n++){var i=e[n];e[n]=e[r-n-1],e[r-n-1]=i,i=t[n],t[n]=-t[r-n-1],t[r-n-1]=-i}},v.prototype.normalize13b=function(e,t){for(var r=0,n=0;n<t/2;n++){var i=8192*Math.round(e[2*n+1]/t)+Math.round(e[2*n]/t)+r;e[n]=67108863&i,r=i<67108864?0:i/67108864|0}return e},v.prototype.convert13b=function(e,t,r,i){for(var o=0,a=0;a<t;a++)o+=0|e[a],r[2*a]=8191&o,o>>>=13,r[2*a+1]=8191&o,o>>>=13;for(a=2*t;a<i;++a)r[a]=0;n(0===o),n(0===(-8192&o))},v.prototype.stub=function(e){for(var t=new Array(e),r=0;r<e;r++)t[r]=0;r