var ripple=function(t){function e(n){if(r[n])return r[n].exports;var i=r[n]={exports:{},id:n,loaded:!1};return t[n].call(i.exports,i,i.exports,e),i.loaded=!0,i.exports}var r={};return e.m=t,e.c=r,e.p="",e(0)}([function(t,e,r){function n(t){var r=e[t];Object.keys(r.prototype).forEach(function(t){var e=/([A-Z]{1})[a-z]+/g;if(e.test(t)){var n=t.replace(e,function(t){return"_"+t.toLowerCase()});r.prototype[n]=r.prototype[t]}})}e.Remote=r(1).Remote,e.Request=r(2).Request,e.Amount=r(3).Amount,e.Account=r(4).Account,e.Transaction=r(5).Transaction,e.Currency=r(6).Currency,e.Base=r(7).Base,e.UInt128=r(8).UInt128,e.UInt160=r(9).UInt160,e.UInt256=r(10).UInt256,e.Seed=r(11).Seed,e.Meta=r(12).Meta,e.SerializedObject=r(13).SerializedObject,e.RippleError=r(14).RippleError,e.Message=r(15).Message,e.binformat=r(16),e.utils=r(17),e.Server=r(18).Server,e.Wallet=r(19),e.Ledger=r(20).Ledger,e.TransactionQueue=r(21).TransactionQueue,e.RangeSet=r(22).RangeSet,e.sjcl=r(17).sjcl,e.jsbn=r(17).jsbn,e.types=r(23),e.config=r(24),["Remote","Request","Transaction","Account","Server"].forEach(n)},function(t,e,r){function n(t){function e(t){"transaction_all"===t&&(!s._transaction_subs&&s.isConnected()&&s.request_subscribe("transactions").request(),s._transaction_subs+=1)}function r(t){"transaction_all"===t&&(s._transaction_subs-=1,!s._transaction_subs&&s.isConnected()&&s.request_unsubscribe("transactions").request())}function n(){s._pingInterval=setInterval(function(){var t=s.requestPing();t.on("error",function(){}),t.broadcast()},1e3*t.ping)}function o(){s.reconnect()}i.call(this);var s=this,t=t||{};if(this.trusted=Boolean(t.trusted),this.state="offline",this._server_fatal=!1,this._allow_partial_history="boolean"==typeof t.allow_partial_history?t.allow_partial_history:!0,this.local_sequence=Boolean(t.local_sequence),this.local_fee="boolean"==typeof t.local_fee?t.local_fee:!0,this.local_signing="boolean"==typeof t.local_signing?t.local_signing:!0,this.canonical_signing="boolean"==typeof t.canonical_signing?t.canonical_signing:!0,this.fee_cushion="number"==typeof t.fee_cushion?t.fee_cushion:1.2,this.max_fee="number"==typeof t.max_fee?t.max_fee:1e6,this.max_attempts="number"==typeof t.max_attempts?t.max_attempts:10,this._ledger_current_index=void 0,this._ledger_hash=void 0,this._ledger_time=void 0,this._stand_alone=void 0,this._testnet=void 0,this.trace=Boolean(t.trace),this._transaction_subs=0,this._connection_count=0,this._connected=!1,this._should_connect=!0,this._submission_timeout=1e3*("number"==typeof t.submission_timeout?t.submission_timeout:20),this._last_ledger_offset="number"==typeof t.last_ledger_offset?t.last_ledger_offset:3,this._received_tx=a({max:100}),this._cur_path_find=null,this.local_signing&&(this.local_sequence=!0,this.local_fee=!0),this._servers=[],this._primary_server=void 0,this.accounts={},this._accounts={},this._books={},this.secrets={},this.ledgers={current:{account_root:{}}},"number"!=typeof this._submission_timeout)throw new TypeError('Remote "submission_timeout" configuration is not a Number');if("number"!=typeof this.max_fee)throw new TypeError('Remote "max_fee" configuration is not a Number');if("number"!=typeof this.fee_cushion)throw new TypeError('Remote "fee_cushion" configuration is not a Number');if(!/^(undefined|boolean)$/.test(typeof t.trace))throw new TypeError('Remote "trace" configuration is not a Boolean');if("boolean"!=typeof this.local_signing)throw new TypeError('Remote "local_signing" configuration is not a Boolean');if("boolean"!=typeof this.local_fee)throw new TypeError('Remote "local_fee" configuration is not a Boolean');if("boolean"!=typeof this.local_sequence)throw new TypeError('Remote "local_sequence" configuration is not a Boolean');if(!/^(undefined|number)$/.test(typeof t.ping))throw new TypeError('Remote "ping" configuration is not a Number');if(!/^(undefined|object)$/.test(typeof t.storage))throw new TypeError('Remote "storage" configuration is not an Object');!t.hasOwnProperty("servers")&&t.hasOwnProperty("websocket_ip")&&(t.servers=[{host:t.websocket_ip,port:t.websocket_port,secure:t.websocket_ssl,trusted:t.trusted}]),(t.servers||[]).forEach(function(t){s.addServer(t)});var u=t.maxListeners||t.max_listeners||0;this._servers.concat(this).forEach(function(t){t instanceof i&&t.setMaxListeners(u)}),this.on("newListener",e),this.on("removeListener",r),t.storage&&(this.storage=t.storage,this.once("connect",this.getPendingTransactions.bind(this))),t.ping&&this.on("connect",n),"undefined"!=typeof window&&(window.addEventListener?window.addEventListener("online",o):window.attachEvent&&window.attachEvent("ononline",o))}var i=r(39).EventEmitter,o=r(40),s=r(41),a=r(48),u=r(47),c=r(18).Server,f=r(2).Request,c=r(18).Server,h=r(3).Amount,l=r(6).Currency,p=r(9).UInt160,d=r(10).UInt256,_=r(5).Transaction,y=r(4).Account,v=r(12).Meta,m=r(25).OrderBook,g=r(26).PathFind,b=r(13).SerializedObject,w=r(14).RippleError,E=r(17),x=r(17).sjcl,A=r(27),S=r(24),T=r(28).internal.sub("remote");o.inherits(n,i),n.flags={account_root:{PasswordSpent:65536,RequireDestTag:131072,RequireAuth:262144,DisallowXRP:524288,DisableMaster:1048576},offer:{Passive:65536,Sell:131072},state:{LowReserve:65536,HighReserve:131072,LowAuth:262144,HighAuth:524288,LowNoRipple:1048576,HighNoRipple:2097152}},n.from_config=function(t,e){function r(t){var e=S.accounts[t];"object"==typeof e&&e.secret&&(o.setSecret(t,e.secret),o.setSecret(e.account,e.secret))}var i="string"==typeof t?S.servers[t]:t,o=new n(i,e);return S.accounts&&Object.keys(S.accounts).forEach(r),o},n.isValidMessage=function(t){return"object"==typeof t&&"string"==typeof t.type},n.isValidLedgerData=function(t){return"object"==typeof t&&"number"==typeof t.fee_base&&"number"==typeof t.fee_ref&&"string"==typeof t.ledger_hash&&"number"==typeof t.ledger_index&&"number"==typeof t.ledger_time&&"number"==typeof t.reserve_base&&"number"==typeof t.reserve_inc},n.isValidLoadStatus=function(t){return"number"==typeof t.load_base&&"number"==typeof t.load_factor},n.isValidated=function(t){return t&&"object"==typeof t&&t.validated===!0},n.prototype._setState=function(t){if(this.state!==t)switch(this.trace&&T.info("set_state:",t),this.state=t,this.emit("state",t),t){case"online":this._online_state="open",this._connected=!0,this.emit("connect"),this.emit("connected");break;case"offline":this._online_state="closed",this._connected=!1,this.emit("disconnect"),this.emit("disconnected")}},n.prototype.setServerFatal=function(){this._server_fatal=!0},n.prototype.setTrace=function(t){return this.trace=void 0===t||t,this},n.prototype._trace=function(){this.trace&&T.info.apply(T,arguments)},n.prototype.setSecret=function(t,e){this.secrets[t]=e},n.prototype.getPendingTransactions=function(){function t(t){if("object"==typeof t){var r=e.transaction();r.parseJson(t.tx_json),r.clientID(t.clientID),Object.keys(t).forEach(function(e){switch(e){case"secret":case"submittedIDs":case"submitIndex":r[e]=t[e]}}),r.submit()}}var e=this;this.storage.getPendingTransactions(function(e,r){!e&&Array.isArray(r)&&r.forEach(t)})},n.prototype.addServer=function(t){function e(t){i._handleMessage(t,o)}function r(){i._connection_count+=1,t.primary&&i._setPrimaryServer(o),1===i._connection_count&&i._setState("online"),i._connection_count===i._servers.length&&i.emit("ready")}function n(){i._connection_count--,0===i._connection_count&&i._setState("offline")}var i=this,o=new c(this,t);return o.on("message",e),o.on("connect",r),o.on("disconnect",n),this._servers.push(o),this},n.prototype.reconnect=function(){if(this._should_connect)return T.info("reconnecting"),this._servers.forEach(function(t){t.reconnect()}),this},n.prototype.connect=function(t){if(!this._servers.length)throw new Error("No servers available.");switch(typeof t){case"undefined":break;case"function":this.once("connect",t);break;default:if(!Boolean(t))return this.disconnect()}return this._should_connect=!0,this._servers.forEach(function(t){t.connect()}),this},n.prototype.disconnect=function(t){if(!this._servers.length)throw new Error("No servers available, not disconnecting");var t="function"==typeof t?t:function(){};return this.isConnected()?(this._should_connect=!1,this.once("disconnect",t),this._servers.forEach(function(t){t.disconnect()}),this._set_state("offline"),this):(t(),this)},n.prototype._handleMessage=function(t,e){try{t=JSON.parse(t)}catch(r){}if(!n.isValidMessage(t))return this.emit("error",new w("remoteUnexpected","Unexpected response from remote")),void 0;switch(t.type){case"ledgerClosed":this._handleLedgerClosed(t,e);break;case"serverStatus":this._handleServerStatus(t,e);break;case"transaction":this._handleTransaction(t,e);break;case"path_find":this._handlePathFind(t,e);break;default:this.trace&&T.info(t.type+": ",t)}},n.prototype._handleLedgerClosed=function(t,e){var r=this;if(n.isValidLedgerData(t)){var i=t.ledger_index>=this._ledger_current_index;(isNaN(this._ledger_current_index)||i)&&(this._ledger_time=t.ledger_time,this._ledger_hash=t.ledger_hash,this._ledger_current_index=t.ledger_index+1,this.isConnected()?this.emit("ledger_closed",t,e):this.once("connect",function(){r.emit("ledger_closed",t,e)}))}},n.prototype._handleServerStatus=function(t,e){this.emit("server_status",t,e)},n.prototype._handleTransaction=function(t,e){function r(e){var r=this[e];r&&"function"==typeof r.notify&&r.notify(t)}var n=this,i=t.transaction.hash;if(!this._received_tx.get(i)){t.validated&&this._received_tx.set(i,!0),this.trace&&T.info("tx:",t);var o=t.meta||t.metadata;if(o){t.mmeta=new v(o);var s=t.mmeta.getAffectedAccounts();s.forEach(r.bind(this._accounts));var a=t.mmeta.getAffectedBooks();a.forEach(r.bind(this._books))}else["Account","Destination"].forEach(function(e){r.call(n._accounts,t.transaction[e])});this.emit("transaction",t,e),this.emit("transaction_all",t,e)}},n.prototype._handlePathFind=function(t,e){this._cur_path_find&&this._cur_path_find.notify_update(t),this.emit("path_find_all",t,e)},n.prototype.getLedgerHash=function(){return this._ledger_hash},n.prototype._setPrimaryServer=n.prototype.setPrimaryServer=function(t){this._primary_server&&(this._primary_server._primary=!1),this._primary_server=t,this._primary_server._primary=!0},n.prototype.isConnected=function(){return this._connected},n.prototype.getConnectedServers=function(){for(var t=[],e=0;eo&&(e=i,r=o)}return e},n.prototype.request=function(t){if("string"==typeof t){if(/^request_/.test(t)||(t="request_"+t),"function"==typeof this[t]){var e=Array.prototype.slice.call(arguments,1);return this[t].apply(this,e)}throw new Error("Command does not exist: "+t)}if(!(t instanceof f))throw new Error("Argument is not a Request");if(this._servers.length)if(this.isConnected())if(null===t.server)t.emit("error",new Error("Server does not exist"));else{var r=t.server||this.getServer();r?r._request(t):t.emit("error",new Error("No servers available"))}else this.once("connect",this.request.bind(this,t));else t.emit("error",new Error("No servers available"))},n.prototype.ping=n.prototype.requestPing=function(t,e){var r=new f(this,"ping");switch(typeof t){case"function":e=t;break;case"string":r.setServer(t)}var n=Date.now();return r.once("success",function(){r.emit("pong",Date.now()-n)}),r.callback(e,"pong"),r},n.prototype.requestServerInfo=function(t){return new f(this,"server_info").callback(t)},n.prototype.requestLedger=function(t,e){var r=new f(this,"ledger");switch(typeof t){case"undefined":break;case"function":e=t;break;case"object":if(!t)break;Object.keys(t).forEach(function(e){switch(e){case"full":case"expand":case"transactions":case"accounts":r.message[e]=!0;break;case"ledger_index":case"ledger_hash":r.message[e]=t[e];break;case"closed":case"current":case"validated":r.message.ledger_index=e}},t);break;default:r.ledgerSelect(t)}return r.callback(e),r},n.prototype.requestLedgerClosed=n.prototype.requestLedgerHash=function(t){return new f(this,"ledger_closed").callback(t)},n.prototype.requestLedgerHeader=function(t){return new f(this,"ledger_header").callback(t)},n.prototype.requestLedgerCurrent=function(t){return new f(this,"ledger_current").callback(t)},n.prototype.requestLedgerData=function(t,e){var r=new f(this,"ledger_data");return r.message.binary=t.binary!==!1,r.selectLedger(t.ledger),r.message.limit=t.limit,r.once("success",function(e){return t.binary===!1?(r.emit("state",e),void 0):(u.mapSeries(e.state,function(t,e){u.setImmediate(function(){e(null,n.parseBinaryLedgerData(t))})},function(t,n){e.state=n,r.emit("state",e)}),void 0)}),r.callback(e,"state"),r},n.prototype.requestLedgerEntry=function(t,e){var r=this,n=new f(this,"ledger_entry");return"function"==typeof t&&(e=t),"account_root"===t&&(n.request_default=n.request,n.request=function(){var e=!0;if(!r._ledger_hash&&"account_root"===t){var i=r.ledgers.current.account_root;i||(i=r.ledgers.current.account_root={});var o=r.ledgers.current.account_root[n.message.account_root];if(o)n.emit("success",{node:o}),e=!1;else switch(t){case"account_root":n.once("success",function(t){r.ledgers.current.account_root[t.node.Account]=t.node})}}e&&n.request_default()}),n.callback(e),n},n.prototype.requestSubscribe=function(t,e){var r=new f(this,"subscribe");return t&&(r.message.streams=Array.isArray(t)?t:[t]),r.callback(e),r},n.prototype.requestUnsubscribe=function(t,e){var r=new f(this,"unsubscribe");return t&&(r.message.streams=Array.isArray(t)?t:[t]),r.callback(e),r},n.prototype.requestTransactionEntry=function(t,e,r){var n=new f(this,"transaction_entry");switch(n.txHash(t),typeof e){case"string":case"number":n.ledgerSelect(e);break;case"undefined":case"function":n.ledgerIndex("validated"),r=e;break;default:throw new Error("Invalid ledger_hash type")}return n.callback(r),n},n.prototype.requestTransaction=n.prototype.requestTx=function(t,e){var r;r="string"==typeof t?{hash:t}:t;var i=new f(this,"tx");return i.message.binary=r.binary!==!1,i.message.transaction=r.hash,i.once("success",function(t){return r.binary===!1?(i.emit("transaction",t),void 0):(i.emit("transaction",n.parseBinaryTransaction(t)),void 0)}),i.callback(e,"transaction"),i},n.accountRequest=function(t,e,r){var n,i,o,s,a;if("object"==typeof e&&(n=e.account,i=e.ledger,o=e.peer,s=e.limit,a=e.marker),a&&!(Number(i)>0||d.is_valid(i)))throw new Error("A ledger_index or ledger_hash must be provided when using a marker");var u=arguments[arguments.length-1];"function"==typeof u&&(r=u);var c=new f(this,t);return n&&(n=p.json_rewrite(n),c.message.account=n),c.ledgerSelect(i),p.is_valid(o)&&(c.message.peer=p.json_rewrite(o)),isNaN(s)||(s=Number(s),s>1e9&&(s=1e9),0>s&&(s=0),c.message.limit=s),a&&(c.message.marker=a),c.callback(r),c},n.prototype.requestAccountInfo=function(){var t=Array.prototype.concat.apply(["account_info"],arguments);return n.accountRequest.apply(this,t)},n.prototype.requestAccountCurrencies=function(){var t=Array.prototype.concat.apply(["account_currencies"],arguments);return n.accountRequest.apply(this,t)},n.prototype.requestAccountLines=function(){var t=Array.prototype.concat.apply(["account_lines"],arguments);return n.accountRequest.apply(this,t)},n.prototype.requestAccountOffers=function(){var t=Array.prototype.concat.apply(["account_offers"],arguments);return n.accountRequest.apply(this,t)},n.prototype.requestAccountTransactions=n.prototype.requestAccountTx=function(t,e){var r=new f(this,"account_tx");return t.binary=t.binary!==!1,void 0!==t.min_ledger&&(t.ledger_index_min=t.min_ledger),void 0!==t.max_ledger&&(t.ledger_index_max=t.max_ledger),t.binary&&void 0===t.parseBinary&&(t.parseBinary=!0),Object.keys(t).forEach(function(t){switch(t){case"account":case"ledger_index_min":case"ledger_index_max":case"binary":case"count":case"descending":case"offset":case"limit":case"forward":case"marker":r.message[t]=this[t]}},t),r.once("success",function(e){return t.parseBinary?(u.mapSeries(e.transactions,function(t,e){u.setImmediate(function(){e(null,n.parseBinaryAccountTransaction(t))})},function(t,n){e.transactions=n,r.emit("transactions",e)}),void 0):(r.emit("transactions",e),void 0)}),r.callback(e,"transactions"),r},n.parseBinaryAccountTransaction=function(t){var e=new b(t.tx_blob),r=e.to_json(),n=new b(t.meta).to_json(),i={validated:t.validated};return i.meta=n,i.tx=r,i.tx.hash=e.hash(A.HASH_TX_ID).to_hex(),i.tx.ledger_index=t.ledger_index,i.tx.inLedger=t.ledger_index,"object"==typeof n.DeliveredAmount?i.meta.delivered_amount=n.DeliveredAmount:("string"==typeof r.Amount||"object"==typeof r.Amount)&&(i.meta.delivered_amount=r.Amount),i},n.parseBinaryTransaction=function(t){var e=new b(t.tx).to_json(),r=new b(t.meta).to_json(),n=e;return n.date=t.date,n.hash=t.hash,n.inLedger=t.inLedger,n.ledger_index=t.ledger_index,n.meta=r,n.validated=t.validated,"string"==typeof r.DeliveredAmount||"object"==typeof r.DeliveredAmount?n.meta.delivered_amount=r.DeliveredAmount:("string"==typeof e.Amount||"object"==typeof e.Amount)&&(n.meta.delivered_amount=e.Amount),n},n.parseBinaryLedgerData=function(t){var e=new b(t.data),r=e.to_json();return r.index=t.index,r},n.prototype.requestTransactionHistory=n.prototype.requestTxHistory=function(t,e){var r=new f(this,"tx_history");return r.message.start=t,r.callback(e),r},n.prototype.requestBookOffers=function(t,e,r,n){var i,o,s=arguments[arguments.length-1];if(t.hasOwnProperty("gets")||t.hasOwnProperty("taker_gets")){var a=t;n=e,r=a.taker,e=a.pays||a.taker_pays,t=a.gets||a.taker_gets,i=a.ledger,o=a.limit}"function"==typeof s&&(n=s);var u=new f(this,"book_offers");return u.message.taker_gets={currency:l.json_rewrite(t.currency,{force_hex:!0})},l.from_json(u.message.taker_gets.currency).is_native()||(u.message.taker_gets.issuer=p.json_rewrite(t.issuer)),u.message.taker_pays={currency:l.json_rewrite(e.currency,{force_hex:!0})},l.from_json(u.message.taker_pays.currency).is_native()||(u.message.taker_pays.issuer=p.json_rewrite(e.issuer)),u.message.taker=r?r:p.ACCOUNT_ONE,u.ledgerSelect(i),isNaN(o)||(o=Number(o),o>1e9&&(o=1e9),0>o&&(o=0),u.message.limit=o),u.callback(n),u},n.prototype.requestWalletAccounts=function(t,e){E.assert(this.trusted);var r=new f(this,"wallet_accounts");return r.message.seed=t,r.callback(e),r},n.prototype.requestSign=function(t,e,r){E.assert(this.trusted);var n=new f(this,"sign");return n.message.secret=t,n.message.tx_json=e,n.callback(r),n},n.prototype.requestSubmit=function(t){return new f(this,"submit").callback(t)},n.prototype._serverPrepareSubscribe=function(t,e){function r(e){if(n._stand_alone=!!e.stand_alone,n._testnet=!!e.testnet,"string"==typeof e.random){for(var r=e.random.match(/[0-9A-F]{8}/gi);r&&r.length;)x.random.addEntropy(parseInt(r.pop(),16));n.emit("random",E.hexToArray(e.random))}n._handleLedgerClosed(e,t),n.emit("subscribed")}var n=this,i=["ledger","server"];"function"==typeof t&&(e=t),this._transaction_subs&&i.push("transactions");var o=this.requestSubscribe(i);return o.on("error",function(t){n.trace&&T.info("Initial server subscribe failed",t)}),o.once("success",r),n.emit("prepare_subscribe",o),o.callback(e,"subscribed"),o},n.prototype.ledgerAccept=n.prototype.requestLedgerAccept=function(t){if(!this._stand_alone)return this.emit("error",new w("notStandAlone")),void 0;var e=new f(this,"ledger_accept");return this.once("ledger_closed",function(t){e.emit("ledger_closed",t)}),e.callback(t,"ledger_closed"),e.request(),e},n.accountRootRequest=function(t,e,r,n,i){"object"==typeof r&&(i=n,n=r.ledger,r=r.account);var o=arguments[arguments.length-1];"function"==typeof o&&(i=o);var s=this.requestLedgerEntry("account_root");return s.accountRoot(r),s.ledgerSelect(n),s.once("success",function(r){s.emit(t,e(r))}),s.callback(i,t),s},n.prototype.requestAccountBalance=function(){function t(t){return h.from_json(t.node.Balance)}var e=Array.prototype.concat.apply(["account_balance",t],arguments),r=n.accountRootRequest.apply(this,e);return r},n.prototype.requestAccountFlags=function(){function t(t){return t.node.Flags}var e=Array.prototype.concat.apply(["account_flags",t],arguments),r=n.accountRootRequest.apply(this,e);return r},n.prototype.requestOwnerCount=function(){function t(t){return t.node.OwnerCount}var e=Array.prototype.concat.apply(["owner_count",t],arguments),r=n.accountRootRequest.apply(this,e);return r},n.prototype.getAccount=function(t){return this._accounts[p.json_rewrite(t)]},n.prototype.addAccount=function(t){var e=new y(this,t);return e.isValid()&&(this._accounts[t]=e),e},n.prototype.account=n.prototype.findAccount=function(t){var e=this.getAccount(t);return e?e:this.addAccount(t)},n.prototype.pathFind=n.prototype.createPathFind=function(t,e,r,n){if("object"==typeof t){var i=t;n=i.src_currencies,r=i.dst_amount,e=i.dst_account,t=i.src_account}var o=new g(this,t,e,r,n);return this._cur_path_find&&this._cur_path_find.notify_superceded(),o.create(),this._cur_path_find=o,o},n.prepareTrade=function(t,e){return t+(l.from_json(t).is_native()?"":"/"+e)},n.prototype.book=n.prototype.createOrderBook=function(t,e,r,i){if("object"==typeof t){var o=t;i=o.issuer_pays,r=o.currency_pays,e=o.issuer_gets,t=o.currency_gets}var s=n.prepareTrade(t,e),a=n.prepareTrade(r,i),u=s+":"+a;if(this._books.hasOwnProperty(u))return this._books[u];var c=new m(this,t,e,r,i,u);return c.is_valid()&&(this._books[u]=c),c},n.prototype.accountSeq=n.prototype.getAccountSequence=function(t,e){var t=p.json_rewrite(t),r=this.accounts[t];if(r){var n=r.seq,i={ADVANCE:1,REWIND:-1}[e.toUpperCase()]||0;return r.seq+=i,n}},n.prototype.setAccountSequence=n.prototype.setAccountSeq=function(t,e){var t=p.json_rewrite(t);this.accounts.hasOwnProperty(t)||(this.accounts[t]={}),this.accounts[t].seq=e},n.prototype.accountSeqCache=function(t,e,r){function n(t){delete s.caching_seq_request;var e=t.node.Sequence;s.seq=e,a.emit("success_account_seq_cache",t)}function i(t){delete s.caching_seq_request,a.emit("error_account_seq_cache",t)}if("object"==typeof t){var o=t;r=e,e=o.ledger,t=o.account}this.accounts.hasOwnProperty(t)||(this.accounts[t]={});var s=this.accounts[t],a=s.caching_seq_request;return a||(a=this.requestLedgerEntry("account_root"),a.accountRoot(t),a.ledgerChoose(e),a.once("success",n),a.once("error",i),s.caching_seq_request=a),a.callback(r,"success_account_seq_cache","error_account_seq_cache"),a},n.prototype.dirtyAccountRoot=function(t){var t=p.json_rewrite(t);delete this.ledgers.current.account_root[t]},n.prototype.requestOffer=function(t,e){var r=this.requestLedgerEntry("offer");return t.account&&t.sequence?r.offerId(t.account,t.sequence):t.index&&r.offerIndex(t.index),r.ledgerSelect(t.ledger),r.once("success",function(t){r.emit("offer",t)}),r.callback(e,"offer"),r},n.prototype.requestRippleBalance=function(t,e,r,n,i){function o(r){var n=r.node,i=h.from_json(n.LowLimit),o=h.from_json(n.HighLimit),s=h.from_json(n.Balance),u=p.from_json(t).equals(o.issuer());a.emit("ripple_state",{account_balance:(u?s.negate():s.clone()).parse_issuer(t),peer_balance:(u?s.clone():s.negate()).parse_issuer(e),account_limit:(u?o:i).clone().parse_issuer(e),peer_limit:(u?i:o).clone().parse_issuer(t),account_quality_in:u?n.HighQualityIn:n.LowQualityIn,peer_quality_in:u?n.LowQualityIn:n.HighQualityIn,account_quality_out:u?n.HighQualityOut:n.LowQualityOut,peer_quality_out:u?n.LowQualityOut:n.HighQualityOut})}if("object"==typeof t){var s=t;i=e,n=s.ledger,r=s.currency,e=s.issuer,t=s.account}var a=this.requestLedgerEntry("ripple_state");return a.rippleState(t,e,r),a.ledgerChoose(n),a.once("success",o),a.callback(i,"ripple_state"),a},n.prepareCurrencies=function(t){var e={};return t.hasOwnProperty("issuer")&&(e.issuer=p.json_rewrite(t.issuer)),t.hasOwnProperty("currency")&&(e.currency=l.json_rewrite(t.currency,{force_hex:!0})),e},n.prototype.requestRipplePathFind=function(t,e,r,i,o){if("object"==typeof t){var s=t;o=e,i=s.src_currencies,r=s.dst_amount,e=s.dst_account,t=s.src_account}var a=new f(this,"ripple_path_find");return a.message.source_account=p.json_rewrite(t),a.message.destination_account=p.json_rewrite(e),a.message.destination_amount=h.json_rewrite(r),i&&(a.message.source_currencies=i.map(n.prepareCurrencies)),a.callback(o),a},n.prototype.requestPathFindCreate=function(t,e,r,i,o){if("object"==typeof t){var s=t;o=e,i=s.src_currencies,r=s.dst_amount,e=s.dst_account,t=s.src_account}var a=new f(this,"path_find");return a.message.subcommand="create",a.message.source_account=p.json_rewrite(t),a.message.destination_account=p.json_rewrite(e),a.message.destination_amount=h.json_rewrite(r),i&&(a.message.source_currencies=i.map(n.prepareCurrencies)),a.callback(o),a},n.prototype.requestPathFindClose=function(t){var e=new f(this,"path_find");return e.message.subcommand="close",e.callback(t),e},n.prototype.requestUnlList=function(t){return new f(this,"unl_list").callback(t)},n.prototype.requestUnlAdd=function(t,e,r){var n=new f(this,"unl_add");return n.message.node=t,e&&(n.message.comment=void 0),n.callback(r),n},n.prototype.requestUnlDelete=function(t,e){var r=new f(this,"unl_delete");return r.message.node=t,r.callback(e),r},n.prototype.requestPeers=function(t){return new f(this,"peers").callback(t)},n.prototype.requestConnect=function(t,e,r){var n=new f(this,"connect");return n.message.ip=t,e&&(n.message.port=e),n.callback(r),n},n.prototype.transaction=n.prototype.createTransaction=function(t,e){if(0===arguments.length)return new _(this);s.strictEqual(typeof t,"string","TransactionType must be a string"),s.strictEqual(typeof e,"object","Transaction options must be an object");var r=new _(this),n={payment:"payment",accountset:"accountSet",trustset:"trustSet",offercreate:"offerCreate",offercancel:"offerCancel",setregularkey:"setRegularKey",sign:"sign"},i=n[t.toLowerCase()];if(!i)throw new Error("Invalid transaction type: "+t);return r[i](e)},n.prototype.feeTx=function(t){var e=this.getServer();if(!e)throw new Error("No connected servers");return e._feeTx(t)},n.prototype.feeTxUnit=function(){var t=this.getServer();if(!t)throw new Error("No connected servers");return t._feeTxUnit()},n.prototype.reserve=function(t){var e=this.getServer();if(!e)throw new Error("No connected servers");return e._reserve(t)},e.Remote=n},function(t,e,r){function n(t,e){i.call(this),this.remote=t,this.requested=!1,this.reconnectTimeout=3e3,this.successEvent="success",this.errorEvent="error",this.message={command:e,id:void 0}}var i=r(39).EventEmitter,o=r(40),s=r(47),a=r(9).UInt160,u=r(6).Currency,c=r(14).RippleError,f=r(18).Server;o.inherits(n,i),n.prototype.request=function(t,e){return this.emit("before"),"function"==typeof t&&(e=t),this.callback(e),this.requested?this:(this.requested=!0,this.on("error",function(){}),this.emit("request",this.remote),Array.isArray(t)?t.forEach(function(t){this.setServer(t),this.remote.request(this)},this):this.remote.request(this),this)},n.prototype.filter=n.prototype.addFilter=n.prototype.broadcast=function(t){function e(r,s){function a(){clearTimeout(o[u]),o[u]=null,e(r,s)}if(r.isConnected())return n.once("proposed",function(e){i=e,s(t(e))}),r._request(n);var u=r.getServerID();o[u]=setTimeout(function(){r.removeListener("connect",a),s(!1)},n.reconnectTimeout),r.once("connect",a)}function r(t){a.call(n,t?"success":"error",i)}var n=this;if(!this.requested)return this.once("before",function(){n.requested=!0,n.broadcast(t)}),this;var t="function"==typeof t?t:Boolean,i=new Error("No servers available"),o={},a=this.emit;this.emit=function(t,e,r){switch(t){case"success":case"error":a.call(n,"proposed",e,r);break;default:a.apply(n,arguments)}};var u=this.remote._servers.filter(function(t){return!(!t.isConnected()&&!t._shouldConnect||n.message.hasOwnProperty("ledger_index")&&!t.hasLedger(n.message.ledger_index)||n.message.hasOwnProperty("ledger_index_min")&&-1!==n.message.ledger_index_min&&!t.hasLedger(n.message.ledger_index_min)||n.message.hasOwnProperty("ledger_index_max")&&-1!==n.message.ledger_index_max&&!t.hasLedger(n.message.ledger_index_max))});return s.some(u,e,r),this},n.prototype.cancel=function(){return this.removeAllListeners(),this.on("error",function(){}),this},n.prototype.setCallback=function(t){return"function"==typeof t&&this.callback(t),this},n.prototype.setReconnectTimeout=function(t){return"number"!=typeof t||isNaN(t)||(this.reconnectTimeout=t),this},n.prototype.callback=function(t,e,r){function n(e){s||(s=!0,t.call(o,null,e))}function i(e){s||(s=!0,e instanceof c||(e=new c(e)),t.call(o,e))}var o=this;if("function"!=typeof t)return this;"string"==typeof e&&(this.successEvent=e),"string"==typeof r&&(this.errorEvent=r);var s=!1;return this.once(this.successEvent,n),this.once(this.errorEvent,i),this.request(),this},n.prototype.timeout=function(t,e){function r(){n.timeout(t,e)}var n=this;if(!this.requested)return this.once("request",r);var i=this.emit,o=!1,s=setTimeout(function(){o=!0,"function"==typeof e&&e(),i.call(n,"timeout"),n.cancel()},t);return this.emit=function(){o||(clearTimeout(s),i.apply(n,arguments))},this},n.prototype.setServer=function(t){var e=null;switch(typeof t){case"object":e=t;break;case"string":for(var r,n=this.remote._servers,i=0;r=n[i];i++)if(r._url===t){e=r;break}}return e instanceof f&&(this.server=e),this},n.prototype.buildPath=function(t){if(this.remote.local_signing)throw new Error("`build_path` is completely ignored when doing local signing as `Paths` is a component of the signed blob. The `tx_blob` is signed,sealed and delivered, and the txn unmodified after");return t?this.message.build_path=!0:delete this.message.build_path,this},n.prototype.ledgerChoose=function(t){return t?this.message.ledger_index=this.remote._ledger_current_index:this.message.ledger_hash=this.remote._ledger_hash,this},n.prototype.ledgerHash=function(t){return this.message.ledger_hash=t,this},n.prototype.ledgerIndex=function(t){return this.message.ledger_index=t,this},n.prototype.selectLedger=n.prototype.ledgerSelect=function(t){switch(t){case"current":case"closed":case"validated":this.message.ledger_index=t;break;default:Number(t)&&isFinite(Number(t))?this.message.ledger_index=Number(t):/^[A-F0-9]{64}$/.test(t)&&(this.message.ledger_hash=t)}return this},n.prototype.accountRoot=function(t){return this.message.account_root=a.json_rewrite(t),this},n.prototype.index=function(t){return this.message.index=t,this},n.prototype.offerId=function(t,e){return this.message.offer={account:a.json_rewrite(t),seq:e},this},n.prototype.offerIndex=function(t){return this.message.offer=t,this},n.prototype.secret=function(t){return t&&(this.message.secret=t),this},n.prototype.txHash=function(t){return this.message.tx_hash=t,this},n.prototype.txJson=function(t){return this.message.tx_json=t,this},n.prototype.txBlob=function(t){return this.message.tx_blob=t,this},n.prototype.rippleState=function(t,e,r){return this.message.ripple_state={currency:r,accounts:[a.json_rewrite(t),a.json_rewrite(e)]},this},n.prototype.setAccounts=n.prototype.accounts=function(t,e){Array.isArray(t)||(t=[t]);var r=t.map(function(t){return a.json_rewrite(t)});return e?this.message.accounts_proposed=r:this.message.accounts=r,this},n.prototype.addAccount=function(t,e){if(Array.isArray(t))return t.forEach(this.addAccount,this),this;var r=a.json_rewrite(t),n=e===!0?"accounts_proposed":"accounts";return this.message[n]=(this.message[n]||[]).concat(r),this},n.prototype.setAccountsProposed=n.prototype.rtAccounts=n.prototype.accountsProposed=function(t){return this.accounts(t,!0)},n.prototype.addAccountProposed=function(t){return Array.isArray(t)?(t.forEach(this.addAccountProposed,this),this):this.addAccount(t,!0)},n.prototype.setBooks=n.prototype.books=function(t,e){this.message.books=[];for(var r=0,n=t.length;n>r;r++){var i=t[r];this.addBook(i,e)}return this},n.prototype.addBook=function(t,e){function r(e){if(!t[e])throw new Error("Missing "+e); var r=n[e]={currency:u.json_rewrite(t[e].currency,{force_hex:!0})};u.from_json(r.currency).is_native()||(r.issuer=a.json_rewrite(t[e].issuer))}if(Array.isArray(t))return t.forEach(this.addBook,this),this;var n={};return["taker_gets","taker_pays"].forEach(r),"boolean"!=typeof e?n.snapshot=!0:e?n.snapshot=!0:delete n.snapshot,t.both&&(n.both=!0),this.message.books=(this.message.books||[]).concat(n),this},n.prototype.addStream=function(t,e){if(Array.isArray(e))switch(t){case"accounts":this.addAccount(e);break;case"accounts_proposed":this.addAccountProposed(e);break;case"books":this.addBook(e)}else if(arguments.length>1){for(arg in arguments)this.addStream(arguments[arg]);return}return Array.isArray(this.message.streams)||(this.message.streams=[]),-1===this.message.streams.indexOf(t)&&this.message.streams.push(t),this},e.Request=n},function(t,e,r){function n(){this._value=new a,this._offset=0,this._is_native=!0,this._is_negative=!1,this._currency=new f,this._issuer=new u}var i=r(46),o=r(17),s=o.sjcl,a=(s.bn,o.jsbn.BigInteger),u=r(9).UInt160,c=r(11).Seed,f=r(6).Currency,h={currency_xns:0,currency_one:1,xns_precision:6,bi_5:new a("5"),bi_7:new a("7"),bi_10:new a("10"),bi_1e14:new a(String(1e14)),bi_1e16:new a(String(1e16)),bi_1e17:new a(String(1e17)),bi_1e32:new a("100000000000000000000000000000000"),bi_man_max_value:new a("9999999999999999"),bi_man_min_value:new a("1000000000000000"),bi_xns_max:new a("9000000000000000000"),bi_xns_min:new a("-9000000000000000000"),bi_xns_unit:new a("1000000"),cMinOffset:-96,cMaxOffset:80,max_value:"9999999999999999e80",min_value:"-1000000000000000e-96"};i(n,h),e.consts=h,n.text_full_rewrite=function(t){return n.from_json(t).to_text_full()},n.json_rewrite=function(t){return n.from_json(t).to_json()},n.from_number=function(t){return(new n).parse_number(t)},n.from_json=function(t){return(new n).parse_json(t)},n.from_quality=function(t,e,r,i){return(new n).parse_quality(t,e,r,i)},n.from_human=function(t,e){return(new n).parse_human(t,e)},n.is_valid=function(t){return n.from_json(t).is_valid()},n.is_valid_full=function(t){return n.from_json(t).is_valid_full()},n.NaN=function(){var t=new n;return t._value=0/0,t},n.prototype.abs=function(){return this.clone(this.is_negative())},n.prototype.add=function(t){var e;if(t=n.from_json(t),this.is_comparable(t))if(t.is_zero())e=this;else if(this.is_zero())e=t.clone(),e._is_native=this._is_native,e._currency=this._currency,e._issuer=this._issuer;else if(this._is_native){e=new n;var r=this._is_negative?this._value.negate():this._value,i=t._is_negative?t._value.negate():t._value,o=r.add(i);e._is_negative=o.compareTo(a.ZERO)<0,e._value=e._is_negative?o.negate():o,e._currency=this._currency,e._issuer=this._issuer}else{for(var r=this._is_negative?this._value.negate():this._value,s=this._offset,i=t._is_negative?t._value.negate():t._value,u=t._offset;u>s;)r=r.divide(n.bi_10),s+=1;for(;s>u;)i=i.divide(n.bi_10),u+=1;e=new n,e._is_native=!1,e._offset=s,e._value=r.add(i),e._is_negative=e._value.compareTo(a.ZERO)<0,e._is_negative&&(e._value=e._value.negate()),e._currency=this._currency,e._issuer=this._issuer,e.canonicalize()}else e=n.NaN();return e},n.prototype.subtract=function(t){return this.add(n.from_json(t).negate())},n.prototype.multiply=function(t){var e;if(t=n.from_json(t),this.is_zero())e=this;else if(t.is_zero())e=this.clone(),e._value=a.ZERO;else{var r=this._value,i=this._offset,o=t._value,s=t._offset;if(this.is_native())for(;r.compareTo(n.bi_man_min_value)<0;)r=r.multiply(n.bi_10),i-=1;if(t.is_native())for(;o.compareTo(n.bi_man_min_value)<0;)o=o.multiply(n.bi_10),s-=1;e=new n,e._offset=i+s+14,e._value=r.multiply(o).divide(n.bi_1e14).add(n.bi_7),e._is_native=this._is_native,e._is_negative=this._is_negative!==t._is_negative,e._currency=this._currency,e._issuer=this._issuer,e.canonicalize()}return e},n.prototype.divide=function(t){var e;if(t=n.from_json(t),t.is_zero())throw new Error("divide by zero");if(this.is_zero())e=this;else{if(!this.is_valid())throw new Error("Invalid dividend");if(!t.is_valid())throw new Error("Invalid divisor");var r=this;if(r.is_native())for(r=r.clone();r._value.compareTo(n.bi_man_min_value)<0;)r._value=r._value.multiply(n.bi_10),r._offset-=1;var i=t;if(i.is_native())for(i=i.clone();i._value.compareTo(n.bi_man_min_value)<0;)i._value=i._value.multiply(n.bi_10),i._offset-=1;e=new n,e._offset=r._offset-i._offset-17,e._value=r._value.multiply(n.bi_1e17).divide(i._value).add(n.bi_5),e._is_native=r._is_native,e._is_negative=r._is_negative!==i._is_negative,e._currency=r._currency,e._issuer=r._issuer,e.canonicalize()}return e},n.prototype.ratio_human=function(t,e){e=i({},e);var r=this;return t="number"==typeof t&&parseInt(t,10)===t?n.from_json(String(t)+".0"):n.from_json(t),t=n.from_json(t),r.is_valid()&&t.is_valid()?t.is_zero()?n.NaN():(e.reference_date&&(t=t.applyInterest(e.reference_date)),t._is_native&&(r=r.clone(),r._value=r._value.multiply(n.bi_xns_unit),r.canonicalize()),r.divide(t)):n.NaN()},n.prototype.product_human=function(t,e){if(e=e||{},t="number"==typeof t&&parseInt(t,10)===t?n.from_json(String(t)+".0"):n.from_json(t),!this.is_valid()||!t.is_valid())return n.NaN();e.reference_date&&(t=t.applyInterest(e.reference_date));var r=this.multiply(t);return t._is_native&&(r._value=r._value.divide(n.bi_xns_unit),r.canonicalize()),r},n.prototype._invert=function(){return this._value=n.bi_1e32.divide(this._value),this._offset=-32-this._offset,this.canonicalize(),this},n.prototype.invert=function(){return this.copy()._invert()},n.prototype.canonicalize=function(){if(this._value instanceof a)if(this._is_native)if(this._value.equals(a.ZERO))this._offset=0,this._is_negative=!1;else{for(;this._offset<0;)this._value=this._value.divide(n.bi_10),this._offset+=1;for(;this._offset>0;)this._value=this._value.multiply(n.bi_10),this._offset-=1}else if(this.is_zero())this._offset=n.cMinOffset,this._is_negative=!1;else{for(;this._value.compareTo(n.bi_man_min_value)<0;)this._value=this._value.multiply(n.bi_10),this._offset-=1;for(;this._value.compareTo(n.bi_man_max_value)>0;)this._value=this._value.divide(n.bi_10),this._offset+=1}else;if(this.is_negative()&&this._offsetn.cMaxOffset)throw new Error("Exceeding max value of "+n.max_value);return this},n.prototype.clone=function(t){return this.copyTo(new n,t)},n.prototype.compareTo=function(t){var e;return t=n.from_json(t),this.is_comparable(t)?this._is_negative!==t._is_negative?e=this._is_negative?-1:1:this._value.equals(a.ZERO)?e=t._value.equals(a.ZERO)?0:-1:t._value.equals(a.ZERO)?e=1:!this._is_native&&this._offset>t._offset?e=this._is_negative?-1:1:!this._is_native&&this._offset0?e=this._is_negative?-1:1:0>e&&(e=this._is_negative?1:-1)):e=n.NaN(),e},n.prototype.copyTo=function(t,e){return"object"==typeof this._value?this._value.copyTo(t._value):t._value=this._value,t._offset=this._offset,t._is_native=this._is_native,t._is_negative=e?!this._is_negative:this._is_negative,t._currency=this._currency,t._issuer=this._issuer,t.is_zero()&&(t._is_negative=!1),t},n.prototype.currency=function(){return this._currency},n.prototype.equals=function(t,e){if("string"==typeof t)return this.equals(n.from_json(t));var r=!!(this.is_valid()&&t.is_valid()&&this._is_native===t._is_native&&this._value.equals(t._value)&&this._offset===t._offset&&this._is_negative===t._is_negative&&(this._is_native||this._currency.equals(t._currency)&&(e||this._issuer.equals(t._issuer))));return r},n.prototype.is_comparable=function(t){return this._value instanceof a&&t._value instanceof a&&this._is_native===t._is_native},n.prototype.is_native=function(){return this._is_native},n.prototype.is_negative=function(){return this._value instanceof a?this._is_negative:!1},n.prototype.is_positive=function(){return!this.is_zero()&&!this.is_negative()},n.prototype.is_valid=function(){return this._value instanceof a},n.prototype.is_valid_full=function(){return this.is_valid()&&this._currency.is_valid()&&this._issuer.is_valid()},n.prototype.is_zero=function(){return this._value instanceof a?this._value.equals(a.ZERO):!1},n.prototype.issuer=function(){return this._issuer},n.prototype.negate=function(){return this.clone("NEGATE")},n.prototype.invert=function(){var t=this.clone();return t._value=a.ONE,t._offset=0,t._is_negative=!1,t.canonicalize(),t.ratio_human(this)},n.human_RE_hex=/^\s*(-)?(\d+)(?:\.(\d*))?\s*([a-fA-F0-9]{40})\s*$/,n.human_RE=/^\s*([A-z]{3}|[0-9]{3})?\s*(-)?(\d+)(?:\.(\d*))?\s*([A-z]{3}|[0-9]{3})?\s*$/,n.prototype.parse_human=function(t,e){e=e||{};var r,i,o,s=null,u=String(t).match(n.human_RE_hex);if(u&&5===u.length&&u[4]&&(r=u[2],i=u[3]||"",o=u[4],this._is_negative=Boolean(u[1])),void 0===r&&void 0===o){var c=String(t).match(n.human_RE);c&&(o=c[5]||c[1]||"XRP",r=c[5]&&c[1]?c[1]+""+c[3]:c[3]||"0",i=c[4]||"",this._is_negative=Boolean(c[2]))}if(r){if(o=o.toUpperCase(),this._value=new a(r),this.set_currency(o),"XRP"===o){for(i=i.slice(0,6);i.length<6;)i+="0";this._is_native=!0,this._value=this._value.multiply(n.bi_xns_unit).add(new a(i))}else{i=i.replace(/0+$/,""),s=i.length,this._is_native=!1;var f=n.bi_10.clone().pow(s);this._value=this._value.multiply(f).add(new a(i)),this._offset=-s,this.canonicalize()}if(e.reference_date&&this._currency.has_interest()){var h=this._currency.get_interest_at(e.reference_date),l=n.from_json(""+h+"/1/1");if(l.is_valid()){var p=this.divide(l);this._value=p._value,this._offset=p._offset}}}else this._value=0/0;return this},n.prototype.parse_issuer=function(t){return this._issuer=u.from_json(t),this},n.prototype.parse_quality=function(t,e,r,i){i=i||{};var o=f.from_json(i.base_currency);if(this._is_negative=!1,this._value=new a(t.substring(t.length-14),16),this._offset=parseInt(t.substring(t.length-16,t.length-14),16)-100,this._currency=f.from_json(e),this._issuer=u.from_json(r),this._is_native=this._currency.is_native(),!i.xrp_as_drops&&o.is_valid()&&o.is_native()&&(i.inverse?this._offset-=6:this._offset+=6),i.inverse&&this._invert(),this.canonicalize(),i.reference_date&&o.is_valid()&&o.has_interest()){var s=o.get_interest_at(i.reference_date),c=n.from_json(""+s+"/1/1");if(c.is_valid()){var h=this.divide(c);this._value=h._value,this._offset=h._offset}}return this},n.prototype.parse_number=function(t){return this._is_native=!1,this._currency=f.from_json(1),this._issuer=u.from_json(1),this._is_negative=0>t?!0:!1,this._value=new a(String(this._is_negative?-t:t)),this._offset=0,this.canonicalize(),this},n.prototype.parse_json=function(t){switch(typeof t){case"string":var e=t.match(/^([^/]+)\/([^/]+)(?:\/(.+))?$/);e?(this._currency=f.from_json(e[2]),this._issuer=e[3]?u.from_json(e[3]):u.from_json("1"),this.parse_value(e[1])):(this.parse_native(t),this._currency=f.from_json("0"),this._issuer=u.from_json("0"));break;case"number":this.parse_json(String(t));break;case"object":if(null===t)break;t instanceof n?t.copyTo(this):t.hasOwnProperty("value")&&(this._currency.parse_json(t.currency,!0),"string"==typeof t.issuer&&this._issuer.parse_json(t.issuer),this.parse_value(t.value));break;default:this._value=0/0}return this},n.prototype.parse_native=function(t){var e;if("string"==typeof t&&(e=t.match(/^(-?)(\d*)(\.\d{0,6})?$/)),e){if(void 0===e[3])this._value=new a(e[2]);else{var r=new a(e[2]).multiply(n.bi_xns_unit),i=new a(e[3]).multiply(new a(String(Math.pow(10,1+n.xns_precision-e[3].length))));this._value=r.add(i)}this._is_native=!0,this._offset=0,this._is_negative=!!e[1]&&0!==this._value.compareTo(a.ZERO),this._value.compareTo(n.bi_xns_max)>0&&(this._value=0/0)}else this._value=0/0;return this},n.prototype.parse_value=function(t){switch(this._is_native=!1,typeof t){case"number":this._is_negative=0>t,this._value=new a(Math.abs(t)),this._offset=0,this.canonicalize();break;case"string":var e=t.match(/^(-?)(\d+)$/),r=!e&&t.match(/^(-?)(\d*)\.(\d*)$/),i=!i&&t.match(/^(-?)(\d*)e(-?\d+)$/);if(i)this._value=new a(i[2]),this._offset=parseInt(i[3]),this._is_negative=!!i[1],this.canonicalize();else if(r){var o=new a(r[2]),s=new a(r[3]),u=r[3].length;this._value=o.multiply(n.bi_10.clone().pow(u)).add(s),this._offset=-u,this._is_negative=!!r[1],this.canonicalize()}else e?(this._value=new a(e[2]),this._offset=0,this._is_negative=!!e[1],this.canonicalize()):this._value=0/0;break;default:this._value=t instanceof a?t:0/0}return this},n.prototype.set_currency=function(t){return this._currency=f.from_json(t),this._is_native=this._currency.is_native(),this},n.prototype.set_issuer=function(t){return this._issuer=t instanceof u?t:u.from_json(t),this},n.prototype.to_number=function(t){var e=this.to_text(t);return"string"==typeof e?Number(e):e},n.prototype.to_text=function(t){var e=0/0;if(this._is_native)this.is_valid()&&this._value.compareTo(n.bi_xns_max)<=0&&(e=this._value.toString());else if(this.is_zero())e="0";else if(this._offset&&(this._offset<-25||this._offset>-4))e=this._value.toString()+"e"+this._offset;else{var r="000000000000000000000000000"+this._value.toString()+"00000000000000000000000",i=r.substring(0,this._offset+43),o=r.substring(this._offset+43),s=i.match(/[1-9].*$/),a=o.match(/[1-9]0*$/);e=""+(s?s[0]:"0")+(a?"."+o.substring(0,1+o.length-a[0].length):"")}return!t&&"number"==typeof e&&isNaN(e)?e="0":this._is_negative&&(e="-"+e),e},n.prototype.applyInterest=function(t){if(!this._currency.has_interest())return this;var e=this._currency.get_interest_at(t),r=n.from_json(String(e)+"/1/1");return r.is_valid()?this.multiply(r):void 0},n.prototype.to_human=function(t){if(t=t||{},!this.is_valid())return"";"undefined"==typeof t.signed&&(t.signed=!0),"undefined"==typeof t.group_sep&&(t.group_sep=!0),t.group_width=t.group_width||3;var e=this;t.reference_date&&(e=this.applyInterest(t.reference_date));for(var r=e._is_native?n.xns_precision:-e._offset,i=n.bi_10.clone().pow(r),s=e._value.divide(i).toString(),a=e._value.mod(i).toString();a.lengthc?a=c.substring(2):(s=(Number(s)+1).toString(),a="");a.length0&&(a=a.slice(0,-p))}if("number"==typeof t.min_precision)for(t.min_precision=Math.max(0,t.min_precision);a.length=this.consts.telLOCAL_ERROR&&t=this.consts.temMALFORMED&&t=this.consts.tefFAILURE&&t=this.consts.terRETRY&&t=this.consts.tesSUCCESS},n.prototype.isTecClaimed=function(t){return t>=this.consts.tecCLAIMED},n.prototype.isRejected=function(t){return this.isTelLocal(t)||this.isTemMalformed(t)||this.isTefFailure(t)},n.from_json=function(t){return(new n).parseJson(t)},n.prototype.parseJson=function(t){return this.tx_json=t,this},n.prototype.setState=function(t){this.state!==t&&(this.state=t,this.emit("state",t))},n.prototype.finalize=function(t){return this.finalized=!0,this.result?(this.result.ledger_index=t.ledger_index,this.result.ledger_hash=t.ledger_hash):(this.result=t,this.result.tx_json=this.tx_json),this.emit("cleanup"),this.emit("final",t),this.remote&&this.remote.trace&&y.info("transaction finalized:",this.tx_json,this.getManager()._pending.getLength()),this},n.prototype.getAccount=function(){return this.tx_json.Account},n.prototype.getTransactionType=function(){return this.tx_json.TransactionType},n.prototype.getManager=function(t){return this.remote?(t||(t=this.tx_json.Account),this.remote.account(t)._transactionManager):void 0},n.prototype.getSecret=n.prototype._accountSecret=function(t){return this.remote?(t||(t=this.tx_json.Account),this.remote.secrets[t]):void 0},n.prototype._getFeeUnits=n.prototype.feeUnits=function(){return n.fee_units["default"]},n.prototype._computeFee=function(){if(!this.remote)return void 0;for(var t=this.remote._servers,e=[],r=0;re?1:e>t?-1:0});var i=Math.floor(e.length/2),o=e.length%2===0?Math.floor(.5+(e[i]+e[i-1])/2):e[i];return String(o)},n.prototype.complete=function(){if(this.remote&&!this.remote.trusted&&!this.remote.local_signing)return this.emit("error",new p("tejServerUntrusted","Attempt to give secret to untrusted server")),!1;if(!this._secret&&!(this._secret=this.getSecret()))return this.emit("error",new p("tejSecretUnknown","Missing secret")),!1;if("undefined"==typeof this.tx_json.SigningPubKey)try{var t=h.from_json(this._secret),e=t.get_key(this.tx_json.Account);this.tx_json.SigningPubKey=e.to_hex_pub()}catch(r){return this.emit("error",new p("tejSecretInvalid","Invalid secret")),!1}return!this.remote||"undefined"!=typeof this.tx_json.Fee||!this.remote.local_fee&&this.remote.trusted||(this.tx_json.Fee=this._computeFee())?Number(this.tx_json.Fee)>this._maxFee?(this.emit("error",new p("tejMaxFeeExceeded","Max fee exceeded")),!1):(this.remote&&this.remote.local_signing&&this.canonical&&(this.tx_json.Flags|=n.flags.Universal.FullyCanonicalSig,this.tx_json.Flags=this.tx_json.Flags>>>0),this.tx_json):(this.emit("error",new p("tejUnconnected")),!1)},n.prototype.serialize=function(){return l.from_json(this.tx_json)},n.prototype.signingHash=function(){return this.hash(_.testnet?"HASH_TX_SIGN_TESTNET":"HASH_TX_SIGN")},n.prototype.hash=function(t,e,r){if("string"==typeof t){if("undefined"==typeof d[t])throw new Error("Unknown hashing prefix requested.");t=d[t]}else t||(t=d.HASH_TX_ID);var n=(r||this.serialize()).hash(t);return e?n:n.to_hex()},n.prototype.sign=function(){var t=h.from_json(this._secret),e=this.tx_json.TxnSignature;delete this.tx_json.TxnSignature;var r=this.signingHash();if(e&&r===this.previousSigningHash)return this.tx_json.TxnSignature=e,this;var n=t.get_key(this.tx_json.Account),i=n.sign(r,0),o=a.codec.hex.fromBits(i).toUpperCase();return this.tx_json.TxnSignature=o,this.previousSigningHash=r,this},n.prototype.addId=function(t){-1===this.submittedIDs.indexOf(t)&&this.submittedIDs.unshift(t)},n.prototype.findId=function(t){for(var e,r=0;r=0&&(this._setMaxFee=!0,this._maxFee=t),this},n.prototype.setFixedFee=function(t){return"number"==typeof t&&t>=0&&(this._setFixedFee=!0,this.tx_json.Fee=String(t)),this},n._rewritePath=function(t){if(!Array.isArray(t))throw new Error("Path must be an array");var e=t.map(function(t){var e={};return t.hasOwnProperty("account")&&(e.account=f.json_rewrite(t.account)),t.hasOwnProperty("issuer")&&(e.issuer=f.json_rewrite(t.issuer)),t.hasOwnProperty("currency")&&(e.currency=c.json_rewrite(t.currency)),t.hasOwnProperty("type_hex")&&(e.type_hex=t.type_hex),e});return e},n.prototype.addPath=n.prototype.pathAdd=function(t){return Array.isArray(t)&&(this.tx_json.Paths=this.tx_json.Paths||[],this.tx_json.Paths.push(n._rewritePath(t))),this},n.prototype.setPaths=n.prototype.paths=function(t){if(Array.isArray(t))for(var e=0,r=t.length;r>e;e++)this.addPath(t[e]);return this},n.prototype.setSecret=n.prototype.secret=function(t){return"string"==typeof t&&(this._secret=t),this},n.prototype.setSendMax=n.prototype.sendMax=function(t){return t&&(this.tx_json.SendMax=u.json_rewrite(t)),this},n.prototype.transferRate=function(t){return"number"==typeof t&&t>=1e9&&(this.tx_json.TransferRate=t),this},n.prototype.setFlags=function(t){if(void 0===t)return this;if("number"==typeof t)return this.tx_json.Flags=t,this;for(var e=n.flags[this.getTransactionType()]||{},r=Array.isArray(t)?t:[].slice.call(arguments),i=0,o=r.length;o>i;i++){var s=r[i];if(!e.hasOwnProperty(s))return this.emit("error",new p("tejInvalidFlag"));this.tx_json.Flags+=e[s]}return this},n.prototype.addMemo=function(t,e,r){if("object"==typeof t){var i=t;t=i.memoType,e=i.memoFormat,r=i.memoData}if(!/(undefined|string)/.test(typeof t))throw new Error("MemoType must be a string");if(!n.ASCII_REGEX.test(t))throw new Error("MemoType must be valid ASCII");if(!/(undefined|string)/.test(typeof e))throw new Error("MemoFormat must be a string");if(!n.ASCII_REGEX.test(e))throw new Error("MemoFormat must be valid ASCII");var o={};return t&&(o.MemoType=n.MEMO_TYPES[t]?n.MEMO_TYPES[t]:t),e&&(o.MemoFormat=e),r&&(o.MemoData=r),this.tx_json.Memos=(this.tx_json.Memos||[]).concat({Memo:o}),this},n.prototype.setAccountTxnID=n.prototype.accountTxnID=function(t){return"string"==typeof t&&(this.tx_json.AccountTxnID=t),this},n.prototype.accountSet=function(t,e,r){function i(t){return"number"==typeof t?t:s[t]||s["asf"+t]}if("object"==typeof t){var o=t;t=o.source||o.from||o.account,e=o.set_flag||o.set,r=o.clear_flag||o.clear}if(!f.is_valid(t))throw new Error("Source address invalid");this.tx_json.TransactionType="AccountSet",this.tx_json.Account=f.json_rewrite(t);var s=n.set_clear_flags.AccountSet;return e&&(e=i(e))&&(this.tx_json.SetFlag=e),r&&(r=i(r))&&(this.tx_json.ClearFlag=r),this},n.prototype.claim=function(t,e,r,n){if("object"==typeof t){var i=t;n=i.signature,r=i.public_key,e=i.generator,t=i.source||i.from||i.account}return this.tx_json.TransactionType="Claim",this.tx_json.Generator=e,this.tx_json.PublicKey=r,this.tx_json.Signature=n,this},n.prototype.offerCancel=function(t,e){if("object"==typeof t){var r=t;e=r.sequence,t=r.source||r.from||r.account}if(!f.is_valid(t))throw new Error("Source address invalid");return this.tx_json.TransactionType="OfferCancel",this.tx_json.Account=f.json_rewrite(t),this.tx_json.OfferSequence=Number(e),this},n.prototype.offerCreate=function(t,e,r,n,i){if("object"==typeof t){var o=t;i=o.cancel_sequence||o.sequence,n=o.expiration,r=o.taker_gets||o.sell,e=o.taker_pays||o.buy,t=o.source||o.from||o.account}if(!f.is_valid(t))throw new Error("Source address invalid");return this.tx_json.TransactionType="OfferCreate",this.tx_json.Account=f.json_rewrite(t),this.tx_json.TakerPays=u.json_rewrite(e),this.tx_json.TakerGets=u.json_rewrite(r),n&&(this.tx_json.Expiration=s.time.toRipple(n)),i&&(this.tx_json.OfferSequence=Number(i)),this},n.prototype.setRegularKey=function(t,e){if("object"==typeof t){var r=t;t=r.address||r.account||r.from,e=r.regular_key}if(!f.is_valid(t))throw new Error("Source address invalid");if(!f.is_valid(e))throw new Error("RegularKey must be a valid Ripple Address");return this.tx_json.TransactionType="SetRegularKey",this.tx_json.Account=f.json_rewrite(t),this.tx_json.RegularKey=f.json_rewrite(e),this},n.prototype.payment=function(t,e,r){if("object"==typeof t){var n=t;r=n.amount,e=n.destination||n.to,t=n.source||n.from||n.account}if(!f.is_valid(t))throw new Error("Payment source address invalid");if(!f.is_valid(e))throw new Error("Payment destination address invalid");return this.tx_json.TransactionType="Payment",this.tx_json.Account=f.json_rewrite(t),this.tx_json.Amount=u.json_rewrite(r),this.tx_json.Destination=f.json_rewrite(e),this},n.prototype.trustSet=n.prototype.rippleLineSet=function(t,e,r,n){if("object"==typeof t){var i=t;n=i.quality_out,r=i.quality_in,e=i.limit,t=i.source||i.from||i.account}if(!f.is_valid(t))throw new Error("Source address invalid");return this.tx_json.TransactionType="TrustSet",this.tx_json.Account=f.json_rewrite(t),void 0!==e&&(this.tx_json.LimitAmount=u.json_rewrite(e)),r&&(this.tx_json.QualityIn=r),n&&(this.tx_json.QualityOut=n),this},n.prototype.submit=function(t){var e=this;return this.callback="function"==typeof t?t:function(){},this._errorHandler=function(t,r){t instanceof p||(t=new p(t,r)),e.callback(t)},this._successHandler=function(t){e.callback(null,t)},this.remote?(this.getManager().submit(this),this):(this.emit("error",new Error("No remote found")),void 0)},n.prototype.abort=function(){this.finalized||this.emit("error",new p("tejAbort","Transaction aborted"))},n.prototype.summary=function(){var t={tx_json:this.tx_json,clientID:this._clientID,submittedIDs:this.submittedIDs,submissionAttempts:this.attempts,submitIndex:this.submitIndex,initialSubmitIndex:this.initialSubmitIndex,lastLedgerSequence:this.lastLedgerSequence,state:this.state,server:this._server?this._server._opts.url:void 0,finalized:this.finalized}; return this.result&&(t.result={engine_result:this.result.engine_result,engine_result_message:this.result.engine_result_message,ledger_hash:this.result.ledger_hash,ledger_index:this.result.ledger_index,transaction_hash:this.result.tx_json.hash}),t},e.Transaction=n},function(t,e,r){var n=r(46),i=r(9).UInt160,o=r(17),s=r(30).Float,a=n(function(){this._value=0/0,this._update()},i);a.prototype=n({},i.prototype),a.prototype.constructor=a,a.HEX_CURRENCY_BAD="0000000000000000000000005852500000000000",a.prototype.human_RE=/^\s*([a-zA-Z0-9]{3})(\s*-\s*[- \w]+)?(\s*\(-?\d+\.?\d*%pa\))?\s*$/,a.from_json=function(t,e){return(new a).parse_json(t,e)},a.from_human=function(t,e){return(new a).parse_human(t,e)},a.prototype.parse_json=function(t,e){switch(this._value=0/0,typeof t){case"string":if(!t||"0"===t){this.parse_hex(e?a.HEX_CURRENCY_BAD:a.HEX_ZERO);break}var r=String(t).match(this.human_RE);if(r){var n=r[1];if(!n||/^(0|XRP)$/.test(n)){this.parse_hex(e?a.HEX_CURRENCY_BAD:a.HEX_ZERO);break}var i=r[3]||"",u=i.match(/(-?\d+\.?\d+)/);n=n.toUpperCase();var c=o.arraySet(20,0);if(u){c[0]=1,c[1]=255&n.charCodeAt(0),c[2]=255&n.charCodeAt(1),c[3]=255&n.charCodeAt(2),u=parseFloat(u[0]);for(var f=31536e3,h=f/Math.log(1+u/100),l=s.toIEEE754Double(h),p=0;p<=l.length;p++)c[8+p]=255&l[p]}else c[12]=255&n.charCodeAt(0),c[13]=255&n.charCodeAt(1),c[14]=255&n.charCodeAt(2);this.parse_bytes(c)}else this.parse_hex(t);break;case"number":isNaN(t)||this.parse_number(t);break;case"object":t instanceof a&&(this._value=t.copyTo({})._value,this._update())}return this},a.prototype.parse_human=function(t){return this.parse_json(t)},a.prototype._update=function(){var t=this.to_bytes(),e=!0;if(!t)return"XRP";this._native=!1,this._type=-1,this._interest_start=0/0,this._interest_period=0/0,this._iso_code="";for(var r=0;20>r;r++)e=e&&(12===r||13===r||14===r||0===t[r]);e?(this._iso_code=String.fromCharCode(t[12])+String.fromCharCode(t[13])+String.fromCharCode(t[14]),"\x00\x00\x00"===this._iso_code&&(this._native=!0,this._iso_code="XRP"),this._type=0):1===t[0]&&(this._iso_code=String.fromCharCode(t[1])+String.fromCharCode(t[2])+String.fromCharCode(t[3]),this._type=1,this._interest_start=(t[4]<<24)+(t[5]<<16)+(t[6]<<8)+t[7],this._interest_period=s.fromIEEE754Double(t.slice(8,16)))},a.prototype.is_native=function(){return this._native},a.prototype.has_interest=function(){return 1===this._type&&!isNaN(this._interest_start)&&!isNaN(this._interest_period)},a.prototype.get_interest_at=function(t){return this.has_interest()?(t||(t=this._interest_start+31536e3),t instanceof Date&&(t=o.fromTimestamp(t.getTime())),Math.exp((t-this._interest_start)/this._interest_period)):0},a.prototype.get_interest_percentage_at=function(t,e){var r=this.get_interest_at(t,e),r=100*r-100,n=e?Math.pow(10,e):100;return Math.round(r*n)/n},a.prototype.to_json=function(t){if(!this.is_valid())return"XRP";var e,t=t||{},r=t&&t.full_name?" - "+t.full_name:"";if(t.show_interest=void 0!==t.show_interest?t.show_interest:this.has_interest(),!t.force_hex&&/^[A-Z0-9]{3}$/.test(this._iso_code)){if(e=this._iso_code+r,t.show_interest){var n=isNaN(t.decimals)?void 0:t.decimals,i=this.has_interest()?this.get_interest_percentage_at(this._interest_start+31536e3,n):0;e+=" ("+i+"%pa)"}}else e=this.to_hex(),e===a.HEX_ONE&&(e=1);return e},a.prototype.to_human=function(t){return this.to_json(t)},a.prototype.get_iso=function(){return this._iso_code},e.Currency=a},function(t,e,r){function n(t){return o.codec.bytes.fromBits(o.hash.sha256.hash(o.codec.bytes.toBits(t)))}function i(t){return n(n(t))}var o=r(17).sjcl,s=r(17),a=r(46),u=s.jsbn.BigInteger,c={},f=c.alphabets={ripple:"rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz",tipple:"RPShNAF39wBUDnEGHJKLM4pQrsT7VWXYZ2bcdeCg65jkm8ofqi1tuvaxyz",bitcoin:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"};a(c,{VER_NONE:1,VER_NODE_PUBLIC:28,VER_NODE_PRIVATE:32,VER_ACCOUNT_ID:0,VER_ACCOUNT_PUBLIC:35,VER_ACCOUNT_PRIVATE:34,VER_FAMILY_GENERATOR:41,VER_FAMILY_SEED:33}),c.encode=function(t,e){for(var r=f[e||"ripple"],n=new u(String(r.length)),i=new u,o=new u,s=new u(t),a=[];s.compareTo(u.ZERO)>0;)s.divRemTo(n,i,o),i.copyTo(s),a.push(r[o.intValue()]);for(var c=0;c!==t.length&&!t[c];c+=1)a.push(r[0]);return a.reverse().join("")},c.decode=function(t,e){if("string"!=typeof t)return void 0;var r,n=f[e||"ripple"],i=new u(String(n.length)),o=new u;for(r=0;r!==t.length&&t[r]===n[0];r+=1);for(;r!==t.length;r+=1){var a=n.indexOf(t[r]);if(0>a)return void 0;var c=new u;c.fromInt(a),o=o.multiply(i).add(c)}for(var h=o.toByteArray().map(function(t){return t?0>t?256+t:t:0}),l=0;l!==h.length&&!h[l];)l+=1;l&&(h=h.slice(l));for(var p=0;p!==t.length&&t[p]===n[0];)p+=1;return[].concat(s.arraySet(p,0),h)},c.verify_checksum=function(t){for(var e=i(t.slice(0,-4)).slice(0,4),r=t.slice(-4),n=!0,o=0;4>o;o++)if(e[o]!==r[o]){n=!1;break}return n},c.encode_check=function(t,e,r){var i=[].concat(t,e),o=n(n(i)).slice(0,4);return c.encode([].concat(i,o),r)},c.decode_check=function(t,e,r){var n=c.decode(e,r);if(!n||n.length<5)return 0/0;if("number"==typeof t&&n[0]!==t)return 0/0;if(Array.isArray(t)){for(var i=!1,o=0,s=t.length;s>o;o++)i|=t[o]===n[0];if(!i)return 0/0}return c.verify_checksum(n)?(n[0]=0,new u(n.slice(0,-4),256)):0/0},e.Base=c},function(t,e,r){var n=r(17),i=r(46),o=r(31).UInt,s=i(function(){this._value=0/0},o);s.width=16,s.prototype=i({},o.prototype),s.prototype.constructor=s;{var a=s.HEX_ZERO="00000000000000000000000000000000",u=s.HEX_ONE="00000000000000000000000000000000";s.STR_ZERO=n.hexToString(a),s.STR_ONE=n.hexToString(u)}e.UInt128=s},function(t,e,r){var n=r(17),i=r(24),o=r(46),s=n.jsbn.BigInteger,a=r(31).UInt,u=r(7).Base,c=o(function(){this._value=0/0,this._version_byte=void 0,this._update()},a);c.width=20,c.prototype=o({},a.prototype),c.prototype.constructor=c;{var f=(c.ACCOUNT_ZERO="rrrrrrrrrrrrrrrrrrrrrhoLvTp",c.ACCOUNT_ONE="rrrrrrrrrrrrrrrrrrrrBZbvji",c.HEX_ZERO="0000000000000000000000000000000000000000"),h=c.HEX_ONE="0000000000000000000000000000000000000001";c.STR_ZERO=n.hexToString(f),c.STR_ONE=n.hexToString(h)}c.prototype.set_version=function(t){return this._version_byte=t,this},c.prototype.get_version=function(){return this._version_byte},c.prototype.parse_json=function(t){return i.accounts&&t in i.accounts&&(t=i.accounts[t].account),"number"!=typeof t||isNaN(t)?"string"!=typeof t?this._value=0/0:"r"===t[0]?(this._value=u.decode_check(u.VER_ACCOUNT_ID,t),this._version_byte=u.VER_ACCOUNT_ID):this.parse_hex(t):(this._value=new s(String(t)),this._version_byte=u.VER_ACCOUNT_ID),this._update(),this},c.prototype.parse_generic=function(t){return a.prototype.parse_generic.call(this,t),isNaN(this._value)&&"string"==typeof t&&"r"===t[0]&&(this._value=u.decode_check(u.VER_ACCOUNT_ID,t)),this._update(),this},c.prototype.to_json=function(t){if(t=t||{},this._value instanceof s){if("number"==typeof this._version_byte){var e=u.encode_check(this._version_byte,this.to_bytes());return t.gateways&&e in t.gateways&&(e=t.gateways[e]),e}return this.to_hex()}return 0/0},e.UInt160=c},function(t,e,r){var n=r(17),i=r(46),o=r(31).UInt,s=i(function(){this._value=0/0},o);s.width=32,s.prototype=i({},o.prototype),s.prototype.constructor=s;{var a=s.HEX_ZERO="0000000000000000000000000000000000000000000000000000000000000000",u=s.HEX_ONE="0000000000000000000000000000000000000000000000000000000000000001";s.STR_ZERO=n.hexToString(a),s.STR_ONE=n.hexToString(u)}e.UInt256=s},function(t,e,r){function n(t,e){return[].concat(t,e>>24,e>>16&255,e>>8&255,255&e)}function i(t){return a.bitArray.bitSlice(a.hash.sha512.hash(a.codec.bytes.toBits(t)),0,256)}var o=r(46),s=r(17),a=s.sjcl,u=s.jsbn.BigInteger,c=r(7).Base,f=r(31).UInt,h=(r(10).UInt256,r(9).UInt160),l=r(32).KeyPair,p=o(function(){this._curve=a.ecc.curves.k256,this._value=0/0},f);p.width=16,p.prototype=o({},f.prototype),p.prototype.constructor=p,p.prototype.parse_json=function(t){return"string"==typeof t?t.length?"s"===t[0]?this._value=c.decode_check(c.VER_FAMILY_SEED,t):/^[0-9a-fA-f]{32}$/.test(t)?this.parse_hex(t):this.parse_passphrase(t):this._value=0/0:this._value=0/0,this},p.prototype.parse_passphrase=function(t){if("string"!=typeof t)throw new Error("Passphrase must be a string");var e=a.hash.sha512.hash(a.codec.utf8String.toBits(t)),r=a.bitArray.bitSlice(e,0,128);return this.parse_bits(r),this},p.prototype.to_json=function(){if(!(this._value instanceof u))return 0/0;var t=c.encode_check(c.VER_FAMILY_SEED,this.to_bytes());return t},p.prototype.get_key=function(t,e){var r,o=0,s=e||1;if(!this.is_valid())throw new Error("Cannot generate keys from invalid seed!");t&&("number"==typeof t?(o=t,s=o+1):r=h.from_json(t));var u,c,f=this._curve,p=0;do u=a.bn.fromBits(i(n(this.to_bytes(),p))),p++;while(!f.r.greaterEquals(u));c=f.G.mult(u);var d,_;do{p=0;do d=a.bn.fromBits(i(n(n(c.toBytesCompressed(),o),p))),p++;while(!f.r.greaterEquals(d));if(o++,d=d.add(u).mod(f.r),_=l.from_bn_secret(d),s--<=0)throw new Error("Too many loops looking for KeyPair yielding "+r.to_json()+" from "+this.to_json())}while(r&&!_.get_address().equals(r));return _},e.Seed=p},function(t,e,r){function n(t){if(this.nodes=[],"object"!=typeof t)throw new TypeError("Missing metadata");if(!Array.isArray(t.AffectedNodes))throw new TypeError("Metadata missing AffectedNodes");t.AffectedNodes.forEach(this.addNode,this)}var i=r(46),o=r(17),s=r(9).UInt160,a=r(3).Amount;n.NODE_TYPES=["CreatedNode","ModifiedNode","DeletedNode"],n.AMOUNT_FIELDS_AFFECTING_ISSUER=["LowLimit","HighLimit","TakerPays","TakerGets"],n.ACCOUNT_FIELDS=["Account","Owner","Destination","Issuer","Target"],n.prototype.getNodeType=function(t){for(var e=null,r=0;rthis.buffer.length)throw new Error("Buffer length exceeded");var i=this.buffer.slice(r,n);return t&&(this.pointer=n),i}}var o=r(41),s=r(46),a=r(16),u=r(23),c=(r(10).UInt256,r(33).Crypt),f=r(17),h=f.sjcl,l=f.jsbn.BigInteger,p={};Object.keys(a.tx).forEach(function(t){p[a.tx[t][0]]=t});var d={};Object.keys(a.ledger).forEach(function(t){d[a.ledger[t][0]]=t});var _={};Object.keys(a.ter).forEach(function(t){_[a.ter[t]]=t}),n.from_json=function(t){var e,t=s(!0,{},t),r=new n;if("number"==typeof t.TransactionType&&(t.TransactionType=n.lookup_type_tx(t.TransactionType),!t.TransactionType))throw new Error("Transaction type ID is invalid.");if("number"==typeof t.LedgerEntryType&&(t.LedgerEntryType=n.lookup_type_le(t.LedgerEntryType),!t.LedgerEntryType))throw new Error("LedgerEntryType ID is invalid.");if("string"==typeof t.TransactionType){if(e=a.tx[t.TransactionType],!Array.isArray(e))throw new Error("Transaction type is invalid");e=e.slice(),t.TransactionType=e.shift()}else if("string"==typeof t.LedgerEntryType){if(e=a.ledger[t.LedgerEntryType],!Array.isArray(e))throw new Error("LedgerEntryType is invalid");e=e.slice(),t.LedgerEntryType=e.shift()}else{if("object"!=typeof t.AffectedNodes)throw new Error("Object to be serialized must contain either TransactionType, LedgerEntryType or AffectedNodes.");e=a.metadata}return n.check_no_missing_fields(e,t),r.serialize(e,t),r},n.check_no_missing_fields=function(t,e){for(var r=[],i=t.length-1;i>=0;i--){var o=t[i],s=o[0],u=o[1];a.REQUIRED===u&&void 0===e[s]&&r.push(s)}if(r.length>0){var c;throw c=void 0!==e.TransactionType?n.lookup_type_tx(e.TransactionType):null!=e.LedgerEntryType?n.lookup_type_le(e.LedgerEntryType):"TransactionMetaData",new Error(c+" is missing fields: "+JSON.stringify(r))}},n.prototype.append=function(t){t instanceof n&&(t=t.buffer),this.buffer=this.buffer.concat(t),this.pointer+=t.length},n.prototype.resetPointer=function(){this.pointer=0},n.prototype.read=i(!0),n.prototype.peek=i(!1),n.prototype.to_bits=function(){return h.codec.bytes.toBits(this.buffer)},n.prototype.to_hex=function(){return h.codec.hex.fromBits(this.to_bits()).toUpperCase()},n.prototype.to_json=function(){var t=this.pointer;this.resetPointer();for(var e={};this.pointero;o++){var a=i[o];r[a]=n.jsonify_structure(t[a],a)}}break;default:r=t}return r},n.prototype.serialize=function(t,e){u.Object.serialize(this,e,!0)},n.prototype.hash=function(t){var e=new n;"undefined"!=typeof t&&u.Int32.serialize(e,t),e.append(this.buffer);var r=h.codec.bytes.toBits(e.buffer);return c.hashSha512Half(r)},n.prototype.signing_hash=n.prototype.hash,n.prototype.serialize_field=function(t,e){{var r=t[0],n=t[1];t[2],u[t[3]]}if("undefined"!=typeof e[r])try{u.serialize(this,r,e[r])}catch(i){throw i.message='Error serializing "'+r+'": '+i.message,i}else if(n===a.REQUIRED)throw new Error("Missing required field "+r)},n.get_field_header=function(t,e){var r=[0];return t>15?r.push(255&t):r[0]+=(15&t)<<4,e>15?r.push(255&e):r[0]+=15&e,r},n.sort_typedef=function(t){function e(t,e){return t[3]!==e[3]?u[t[3]].id-u[e[3]].id:t[2]-e[2]}return o(Array.isArray(t)),t.sort(e)},n.lookup_type_tx=function(t){return o.strictEqual(typeof t,"number"),p[t]},n.lookup_type_le=function(t){return o("number"==typeof t),d[t]},e.SerializedObject=n}).call(e,r(43).Buffer)},function(t,e,r){function n(t,e){switch(typeof t){case"object":o(this,t);break;case"string":this.result=t,this.result_message=e}this.engine_result=this.result=this.result||this.engine_result||this.error||"Error",this.engine_result_message=this.result_message=this.result_message||this.engine_result_message||this.error_message||"Error",this.result_message=this.message=this.result_message;var r;Error.captureStackTrace?Error.captureStackTrace(this,t||this):(r=(new Error).stack)&&(this.stack=r)}var i=r(40),o=r(46);i.inherits(n,Error),n.prototype.name="RippleError",e.RippleError=n},function(t,e,r){var n=r(47),i=(r(44),r(17).sjcl),o=r(1).Remote,s=r(11).Seed,a=r(32).KeyPair,u=r(4).Account,c=r(9).UInt160,f={};f.HASH_FUNCTION=i.hash.sha512.hash,f.MAGIC_BYTES="Ripple Signed Message:\n";var h=/^[0-9a-fA-F]+$/,l=/^([A-Za-z0-9\+]{4})*([A-Za-z0-9\+]{2}==)|([A-Za-z0-9\+]{3}=)?$/;f.signMessage=function(t,e,r){return f.signHash(f.HASH_FUNCTION(f.MAGIC_BYTES+t),e,r)},f.signHash=function(t,e,r){if("string"==typeof t&&/^[0-9a-fA-F]+$/.test(t)&&(t=i.codec.hex.toBits(t)),"object"!=typeof t||t.length<=0||"number"!=typeof t[0])throw new Error("Hash must be a bitArray or hex-encoded string");e instanceof i.ecc.ecdsa.secretKey||(e=s.from_json(e).get_key(r)._secret);var n=e.signWithRecoverablePublicKey(t),o=i.codec.base64.fromBits(n);return o},f.verifyMessageSignature=function(t,e,r){return"string"!=typeof t.message?r(new Error("Data object must contain message field to verify signature")):(t.hash=f.HASH_FUNCTION(f.MAGIC_BYTES+t.message),f.verifyHashSignature(t,e,r))},f.verifyHashSignature=function(t,e,r){function s(t){var e;try{e=i.ecc.ecdsa.publicKey.recoverFromSignature(p,_)}catch(r){return t(r)}e?t(null,e):t(new Error("Could not recover public key from signature"))}function f(t,r){var n=new a;n._pubkey=t;var i=n.to_hex_pub(),o=new u(e,d);o.publicKeyIsActive(i,r)}var p,d,_;if("function"!=typeof r)throw new Error("Must supply callback function");if(p=t.hash,p&&"string"==typeof p&&h.test(p)&&(p=i.codec.hex.toBits(p)),"object"!=typeof p||p.length<=0||"number"!=typeof p[0])return r(new Error("Hash must be a bitArray or hex-encoded string"));if(d=t.account||t.address,!d||!c.from_json(d).is_valid())return r(new Error("Account must be a valid ripple address"));if(_=t.signature,"string"!=typeof _||!l.test(_))return r(new Error("Signature must be a Base64-encoded string"));if(_=i.codec.base64.toBits(_),!(e instanceof o)||"online"!==e.state)return r(new Error("Must supply connected Remote to verify signature"));var y=[s,f];n.waterfall(y,r)},e.Message=f},function(t,e){var r=(e.types=[void 0,"Int16","Int32","Int64","Hash128","Hash256","Amount","VL","Account",void 0,void 0,void 0,void 0,void 0,"Object","Array","Int8","Hash160","PathSet","Vector256"],e.fields={1:{1:"LedgerEntryType",2:"TransactionType"},2:{2:"Flags",3:"SourceTag",4:"Sequence",5:"PreviousTxnLgrSeq",6:"LedgerSequence",7:"CloseTime",8:"ParentCloseTime",9:"SigningTime",10:"Expiration",11:"TransferRate",12:"WalletSize",13:"OwnerCount",14:"DestinationTag",16:"HighQualityIn",17:"HighQualityOut",18:"LowQualityIn",19:"LowQualityOut",20:"QualityIn",21:"QualityOut",22:"StampEscrow",23:"BondAmount",24:"LoadFee",25:"OfferSequence",26:"FirstLedgerSequence",27:"LastLedgerSequence",28:"TransactionIndex",29:"OperationLimit",30:"ReferenceFeeUnits",31:"ReserveBase",32:"ReserveIncrement",33:"SetFlag",34:"ClearFlag"},3:{1:"IndexNext",2:"IndexPrevious",3:"BookNode",4:"OwnerNode",5:"BaseFee",6:"ExchangeRate",7:"LowNode",8:"HighNode"},4:{1:"EmailHash"},5:{1:"LedgerHash",2:"ParentHash",3:"TransactionHash",4:"AccountHash",5:"PreviousTxnID",6:"LedgerIndex",7:"WalletLocator",8:"RootIndex",9:"AccountTxnID",16:"BookDirectory",17:"InvoiceID",18:"Nickname",19:"Amendment",20:"TicketID"},6:{1:"Amount",2:"Balance",3:"LimitAmount",4:"TakerPays",5:"TakerGets",6:"LowLimit",7:"HighLimit",8:"Fee",9:"SendMax",16:"MinimumOffer",17:"RippleEscrow",18:"DeliveredAmount"},7:{1:"PublicKey",2:"MessageKey",3:"SigningPubKey",4:"TxnSignature",5:"Generator",6:"Signature",7:"Domain",8:"FundCode",9:"RemoveCode",10:"ExpireCode",11:"CreateCode",12:"MemoType",13:"MemoData",14:"MemoFormat"},8:{1:"Account",2:"Owner",3:"Destination",4:"Issuer",7:"Target",8:"RegularKey"},14:{1:void 0,2:"TransactionMetaData",3:"CreatedNode",4:"DeletedNode",5:"ModifiedNode",6:"PreviousFields",7:"FinalFields",8:"NewFields",9:"TemplateEntry",10:"Memo"},15:{1:void 0,2:"SigningAccounts",3:"TxnSignatures",4:"Signatures",5:"Template",6:"Necessary",7:"Sufficient",8:"AffectedNodes",9:"Memos"},16:{1:"CloseResolution",2:"TemplateEntryType",3:"TransactionResult"},17:{1:"TakerPaysCurrency",2:"TakerPaysIssuer",3:"TakerGetsCurrency",4:"TakerGetsIssuer"},18:{1:"Paths"},19:{1:"Indexes",2:"Hashes",3:"Amendments"}}),n=e.fieldsInverseMap={};Object.keys(r).forEach(function(t){Object.keys(r[t]).forEach(function(e){n[r[t][e]]=[Number(t),Number(e)]})});var i=e.REQUIRED=0,o=e.OPTIONAL=1,s=e.DEFAULT=2,a=[["TransactionType",i],["Flags",o],["SourceTag",o],["LastLedgerSequence",o],["Account",i],["Sequence",i],["Fee",i],["OperationLimit",o],["SigningPubKey",i],["TxnSignature",o]];e.tx={AccountSet:[3].concat(a,[["EmailHash",o],["WalletLocator",o],["WalletSize",o],["MessageKey",o],["Domain",o],["TransferRate",o]]),TrustSet:[20].concat(a,[["LimitAmount",o],["QualityIn",o],["QualityOut",o]]),OfferCreate:[7].concat(a,[["TakerPays",i],["TakerGets",i],["Expiration",o]]),OfferCancel:[8].concat(a,[["OfferSequence",i]]),SetRegularKey:[5].concat(a,[["RegularKey",i]]),Payment:[0].concat(a,[["Destination",i],["Amount",i],["SendMax",o],["Paths",s],["InvoiceID",o],["DestinationTag",o]]),Contract:[9].concat(a,[["Expiration",i],["BondAmount",i],["StampEscrow",i],["RippleEscrow",i],["CreateCode",o],["FundCode",o],["RemoveCode",o],["ExpireCode",o]]),RemoveContract:[10].concat(a,[["Target",i]]),EnableFeature:[100].concat(a,[["Feature",i]]),SetFee:[101].concat(a,[["Features",i],["BaseFee",i],["ReferenceFeeUnits",i],["ReserveBase",i],["ReserveIncrement",i]])};var u=[["LedgerIndex",o],["LedgerEntryType",i],["Flags",i]];e.ledger={AccountRoot:[97].concat(u,[["Sequence",i],["PreviousTxnLgrSeq",i],["TransferRate",o],["WalletSize",o],["OwnerCount",i],["EmailHash",o],["PreviousTxnID",i],["AccountTxnID",o],["WalletLocator",o],["Balance",i],["MessageKey",o],["Domain",o],["Account",i],["RegularKey",o]]),Contract:[99].concat(u,[["PreviousTxnLgrSeq",i],["Expiration",i],["BondAmount",i],["PreviousTxnID",i],["Balance",i],["FundCode",o],["RemoveCode",o],["ExpireCode",o],["CreateCode",o],["Account",i],["Owner",i],["Issuer",i]]),DirectoryNode:[100].concat(u,[["IndexNext",o],["IndexPrevious",o],["ExchangeRate",o],["RootIndex",i],["Owner",o],["TakerPaysCurrency",o],["TakerPaysIssuer",o],["TakerGetsCurrency",o],["TakerGetsIssuer",o],["Indexes",i]]),EnabledFeatures:[102].concat(u,[["Features",i]]),FeeSettings:[115].concat(u,[["ReferenceFeeUnits",i],["ReserveBase",i],["ReserveIncrement",i],["BaseFee",i],["LedgerIndex",o]]),GeneratorMap:[103].concat(u,[["Generator",i]]),LedgerHashes:[104].concat(u,[["LedgerEntryType",i],["Flags",i],["FirstLedgerSequence",o],["LastLedgerSequence",o],["LedgerIndex",o],["Hashes",i]]),Nickname:[110].concat(u,[["LedgerEntryType",i],["Flags",i],["LedgerIndex",o],["MinimumOffer",o],["Account",i]]),Offer:[111].concat(u,[["LedgerEntryType",i],["Flags",i],["Sequence",i],["PreviousTxnLgrSeq",i],["Expiration",o],["BookNode",i],["OwnerNode",i],["PreviousTxnID",i],["LedgerIndex",o],["BookDirectory",i],["TakerPays",i],["TakerGets",i],["Account",i]]),RippleState:[114].concat(u,[["LedgerEntryType",i],["Flags",i],["PreviousTxnLgrSeq",i],["HighQualityIn",o],["HighQualityOut",o],["LowQualityIn",o],["LowQualityOut",o],["LowNode",o],["HighNode",o],["PreviousTxnID",i],["LedgerIndex",o],["Balance",i],["LowLimit",i],["HighLimit",i]])},e.metadata=[["TransactionIndex",i],["TransactionResult",i],["AffectedNodes",i]],e.ter={tesSUCCESS:0,tecCLAIM:100,tecPATH_PARTIAL:101,tecUNFUNDED_ADD:102,tecUNFUNDED_OFFER:103,tecUNFUNDED_PAYMENT:104,tecFAILED_PROCESSING:105,tecDIR_FULL:121,tecINSUF_RESERVE_LINE:122,tecINSUF_RESERVE_OFFER:123,tecNO_DST:124,tecNO_DST_INSUF_XRP:125,tecNO_LINE_INSUF_RESERVE:126,tecNO_LINE_REDUNDANT:127,tecPATH_DRY:128,tecUNFUNDED:129,tecMASTER_DISABLED:130,tecNO_REGULAR_KEY:131,tecOWNERS:132,tecNO_ISSUER:133,tecNO_AUTH:134,tecNO_LINE:135,tecINSUFF_FEE:136,tecFROZEN:137,tecNO_TARGET:138,tecNO_PERMISSION:139,tecNO_ENTRY:140,tecINSUFFICIENT_RESERVE:141}},function(t,e,r){function n(t,e){return function(){console.log("%s: %s",n,arguments.toString),e(arguments)}}function i(t,e){for(var r=new Array(t),n=0;t>n;n++)r[n]=e;return r}function o(t){var e=[],r=0;for(t.length%2&&(e.push(String.fromCharCode(parseInt(t.substring(0,1),16))),r=1);rn?"0"+n.toString(16):n.toString(16)}return e}function a(t){for(var e=new Array(t.length),r=0;ri;i+=e)n.push(t.slice(i,e+i));return n}function f(t,e){if(!t)throw new Error("Assertion failed"+(e?": "+e:"."))}function h(t){for(var e={},r=[],n=0,i=t.length;i>n;n++){var o=t[n];e[o]||(r.push(o),e[o]=!0)}return r}function l(t){return 1e3*(t+946684800)}function p(t){return t instanceof Date&&(t=t.getTime()),Math.round(t/1e3)-946684800}e.time={fromRipple:l,toRipple:p},e.trace=n,e.arraySet=i,e.hexToString=o,e.hexToArray=u,e.stringToArray=a,e.stringToHex=s,e.chunkString=c,e.assert=f,e.arrayUnique=h,e.toTimestamp=l,e.fromTimestamp=p,e.sjcl=r(36),e.jsbn=r(37)},function(t,e,r){function n(t,e){function r(){var t=i._checkActivity.bind(i);i._activityInterval=setInterval(t,1e3)}a.call(this);var i=this;if("string"==typeof e){var u=o.parse(e);e={host:u.hostname,port:u.port,secure:"ws:"===u.protocol?!1:!0}}if("object"!=typeof e)throw new TypeError("Server configuration is not an Object");if(!n.DOMAIN_RE.test(e.host))throw new Error('Server host is malformed, use "host" and "port" server configuration');if(!(e.port=Number(e.port)))throw new TypeError("Server port must be a number");if(e.port<1||e.port>65535)throw new TypeError('Server "port" must be an integer in range 1-65535');"boolean"!=typeof e.secure&&(e.secure=!0),this._remote=t,this._opts=e,this._ws=void 0,this._connected=!1,this._shouldConnect=!1,this._state="offline",this._ledgerRanges=new c,this._ledgerMap=s({max:200}),this._id=0,this._retry=0,this._requests={},this._load_base=256,this._load_factor=256,this._fee=10,this._fee_ref=10,this._fee_base=10,this._reserve_base=void 0,this._reserve_inc=void 0,this._fee_cushion=this._remote.fee_cushion,this._lastLedgerIndex=0/0,this._lastLedgerClose=0/0,this._score=0,this._scoreWeights={ledgerclose:5,response:1},this._pubkey_node="",this._url=this._opts.url=(this._opts.secure?"wss://":"ws://")+this._opts.host+":"+this._opts.port,this.on("message",function(t){i._handleMessage(t)}),this.on("response_subscribe",function(t){i._handleResponseSubscribe(t)}),this.on("disconnect",function(){clearInterval(i._activityInterval),i.once("ledger_closed",r)}),this.once("ledger_closed",r),this._remote.on("ledger_closed",function(t){i._updateScore("ledgerclose",t)}),this.on("response_ping",function(t,e){i._updateScore("response",e)}),this.on("load_changed",function(t){i._updateScore("loadchange",t)}),this.on("connect",function(){i.requestServerID()})}var i=r(40),o=r(45),s=r(48),a=r(39).EventEmitter,u=r(3).Amount,c=r(22).RangeSet,f=r(28).internal.sub("server");i.inherits(n,a),n.DOMAIN_RE=/^(?=.{1,255}$)[0-9A-Za-z](?:(?:[0-9A-Za-z]|[-_]){0,61}[0-9A-Za-z])?(?:\.[0-9A-Za-z](?:(?:[0-9A-Za-z]|[-_]){0,61}[0-9A-Za-z])?)*\.?$/,n.TLS_ERRORS=["UNABLE_TO_GET_ISSUER_CERT","UNABLE_TO_GET_CRL","UNABLE_TO_DECRYPT_CERT_SIGNATURE","UNABLE_TO_DECRYPT_CRL_SIGNATURE","UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY","CERT_SIGNATURE_FAILURE","CRL_SIGNATURE_FAILURE","CERT_NOT_YET_VALID","CERT_HAS_EXPIRED","CRL_NOT_YET_VALID","CRL_HAS_EXPIRED","ERROR_IN_CERT_NOT_BEFORE_FIELD","ERROR_IN_CERT_NOT_AFTER_FIELD","ERROR_IN_CRL_LAST_UPDATE_FIELD","ERROR_IN_CRL_NEXT_UPDATE_FIELD","OUT_OF_MEM","DEPTH_ZERO_SELF_SIGNED_CERT","SELF_SIGNED_CERT_IN_CHAIN","UNABLE_TO_GET_ISSUER_CERT_LOCALLY","UNABLE_TO_VERIFY_LEAF_SIGNATURE","CERT_CHAIN_TOO_LONG","CERT_REVOKED","INVALID_CA","PATH_LENGTH_EXCEEDED","INVALID_PURPOSE","CERT_UNTRUSTED","CERT_REJECTED"],n.onlineStates=["syncing","tracking","proposing","validating","full"],n.websocketConstructor=function(){return r(38)},n.prototype._setState=function(t){if(t!==this._state)switch(this._remote.trace&&f.info(this.getServerID(),"set_state:",t),this._state=t,this.emit("state",t),t){case"online":this._connected=!0,this._retry=0,this.emit("connect");break;case"offline":this._connected=!1,this.emit("disconnect")}},n.prototype._checkActivity=function(){if(this.isConnected()&&!isNaN(this._lastLedgerClose)){var t=Date.now()-this._lastLedgerClose;t>25e3&&(this._remote.trace&&f.info(this.getServerID(),"reconnect: activity delta:",t),this.reconnect())}},n.prototype.requestServerID=function(){var t=this;if(!this._pubkey_node){this.on("response_server_info",function(e){try{t._pubkey_node=e.info.pubkey_node}catch(r){}});var e=this._remote.requestServerInfo();e.on("error",function(){}),this._request(e)}},n.prototype._updateScore=function(t,e){if(this.isConnected()){var r=this._scoreWeights[t]||1;switch(t){case"ledgerclose":var n=e.ledger_index-this._lastLedgerIndex;n>0&&(this._score+=r*n);break;case"response":var n=Math.floor((Date.now()-e.time)/200);this._score+=r*n;break;case"loadchange":this._fee=Number(this._computeFee(10))}this._score>1e3&&(this._remote.trace&&f.info(this.getServerID(),"reconnect: score:",this._score),this.reconnect())}},n.prototype.getRemoteAddress=n.prototype._remoteAddress=function(){var t;try{t=this._ws._socket.remoteAddress}catch(e){}return t},n.prototype.getHostID=n.prototype.getServerID=function(){return this._url+" ("+(this._pubkey_node?this._pubkey_node:"")+")"},n.prototype.disconnect=function(){var t=this;return this.isConnected()?(this._lastLedgerIndex=0/0,this._lastLedgerClose=0/0,this._score=0,this._shouldConnect=!1,this._ledgerRanges.reset(),this._ledgerMap.reset(),this._setState("offline"),this._ws&&this._ws.close(),void 0):(this.once("socket_open",function(){t.disconnect()}),void 0)},n.prototype.reconnect=function(){function t(){e._shouldConnect=!0,e._retry=0,e.connect()}var e=this;this._ws&&this._shouldConnect&&(this.isConnected()?(this.once("disconnect",t),this.disconnect()):t())},n.prototype.connect=function(){var t=this,e=n.websocketConstructor();if(!e)throw new Error("No websocket support detected!");if(!this.isConnected()){this._ws&&this._ws.close(),this._remote.trace&&f.info(this.getServerID(),"connect");var r=this._ws=new e(this._opts.url);this._shouldConnect=!0,t.emit("connecting"),r.onmessage=function(e){t.emit("message",e.data)},r.onopen=function(){r===t._ws&&(t.emit("socket_open"),t._request(t._remote._serverPrepareSubscribe(t)))},r.onerror=function(e){if(r===t._ws){if(t.emit("socket_error"),t._remote.trace&&f.info(t.getServerID(),"onerror:",e.data||e),-1!==n.TLS_ERRORS.indexOf(e.message))throw e;t._handleClose()}},r.onclose=function(){r===t._ws&&(t._remote.trace&&f.info(t.getServerID(),"onclose:",r.readyState),t._handleClose())}}},n.prototype._retryConnect=function(){function t(){e._shouldConnect&&(e._remote.trace&&f.info(e.getServerID(),"retry",e._retry),e.connect())}var e=this;this._retry+=1;var r=this._retry<40?50:this._retry<100?1e3:this._retry<160?1e4:3e4;this._retryTimer=setTimeout(t,r)},n.prototype._handleClose=function(){function t(){}var e=this._ws;e.onopen=e.onerror=e.onclose=e.onmessage=t,this.emit("socket_close"),this._setState("offline"),this._shouldConnect&&this._retryConnect()},n.prototype._handleMessage=function(t){try{t=JSON.parse(t)}catch(e){}if(!n.isValidMessage(t))return this.emit("unexpected",t),void 0;switch(t.type){case"ledgerClosed":this._handleLedgerClosed(t);break;case"serverStatus":this._handleServerStatus(t);break;case"response":this._handleResponse(t);break;case"path_find":this._handlePathFind(t)}},n.prototype._handleLedgerClosed=function(t){this._lastLedgerIndex=t.ledger_index,this._lastLedgerClose=Date.now(),this._ledgerRanges.add(t.ledger_index),this._ledgerMap.set(t.ledger_hash,t.ledger_index),this.emit("ledger_closed",t) },n.prototype._handleServerStatus=function(t){var e=~n.onlineStates.indexOf(t.server_status);if(this._setState(e?"online":"offline"),n.isLoadStatus(t)){this.emit("load",t,this),this._remote.emit("load",t,this);var r=t.load_base!==this._load_base||t.load_factor!==this._load_factor;r&&(this._load_base=t.load_base,this._load_factor=t.load_factor,this.emit("load_changed",t,this),this._remote.emit("load_changed",t,this))}},n.prototype._handleResponse=function(t){var e=this._requests[t.id];if(delete this._requests[t.id],!e)return this._remote.trace&&f.info(this.getServerID(),"UNEXPECTED:",t),void 0;if("success"===t.status){this._remote.trace&&f.info(this.getServerID(),"response:",t);var r=e.message.command,n=t.result,i="response_"+r;e.emit("success",n),[this,this._remote].forEach(function(r){r.emit(i,n,e,t)})}else t.error&&(this._remote.trace&&f.info(this.getServerID(),"error:",t),e.emit("error",{error:"remoteError",error_message:"Remote reported an error.",remote:t}))},n.prototype._handlePathFind=function(t){this._remote.trace&&f.info(this.getServerID(),"path_find:",t)},n.prototype._handleResponseSubscribe=function(t){if(!this.isConnected()){if(!this._remote._allow_partial_history&&!n.hasFullLedgerHistory(t))return this.reconnect();t.pubkey_node&&(this._pubkey_node=t.pubkey_node),n.isLoadStatus(t)&&(this._load_base=t.load_base||256,this._load_factor=t.load_factor||256,this._fee_ref=t.fee_ref||10,this._fee_base=t.fee_base||10,this._reserve_base=t.reserve_base,this._reserve_inc=t.reserve_inc),t.validated_ledgers&&this._ledgerRanges.add(t.validated_ledgers),~n.onlineStates.indexOf(t.server_status)&&this._setState("online")}},n.hasFullLedgerHistory=function(t){return"object"==typeof t&&"full"===t.server_status&&"string"==typeof t.validated_ledgers&&2===t.validated_ledgers.split("-").length},n.isValidMessage=function(t){return"object"==typeof t&&"string"==typeof t.type},n.isLoadStatus=function(t){return"object"==typeof t&&"number"==typeof t.load_base&&"number"==typeof t.load_factor},n.prototype._sendMessage=function(t){this._ws&&(this._remote.trace&&f.info(this.getServerID(),"request:",t),this._ws.send(JSON.stringify(t)))},n.prototype._request=function(t){function e(){r._sendMessage(t.message)}var r=this;if(!this._ws)return this._remote.trace&&f.info(this.getServerID(),"request: DROPPING:",t.message),void 0;t.server=this,t.message.id=this._id,t.time=Date.now(),this._requests[t.message.id]=t,this._id++;var n=1===this._ws.readyState,i=t&&"subscribe"===t.message.command;this.isConnected()||n&&i?e():this.once("connect",e)},n.prototype.isConnected=n.prototype._isConnected=function(){return this._connected},n.prototype._computeFee=function(t){if(isNaN(t))throw new Error("Invalid argument");return this._feeTx(Number(t)).to_json()},n.prototype._feeTx=function(t){var e=this._feeTxUnit();return u.from_json(String(Math.ceil(t*e)))},n.prototype._feeTxUnit=function(){var t=this._fee_base/this._fee_ref;return t*=this._load_factor/this._load_base,t*=this._fee_cushion},n.prototype._reserve=function(t){var e=u.from_json(String(this._reserve_base)),r=u.from_json(String(this._reserve_inc)),n=t||0;if(0>n)throw new Error("Owner count must not be negative.");return e.add(r.product_human(n))},n.prototype.hasLedger=function(t){var e=!1;return"string"==typeof t&&/^[A-F0-9]{64}$/.test(t)?e=this._ledgerMap.has(t):null==t||isNaN(t)||(e=this._ledgerRanges.has(t)),e},n.prototype.getLastLedger=n.prototype.getLastLedgerIndex=function(){return this._lastLedgerIndex},e.Server=n},function(t,e,r){var n=r(17).sjcl,i=r(49)({sjcl:n});t.exports=i},function(t,e,r){function n(){this.ledger_json={}}{var i=r(5).Transaction,o=r(34).SHAMap,s=r(34).SHAMapTreeNode,a=r(13).SerializedObject,u=r(23),c=r(9).UInt160,f=r(6).Currency,u=r(23);r(17).sjcl,r(33).Crypt}n.from_json=function(t){var e=new n;return e.parse_json(t),e},n.space=r(35),n.calcAccountRootEntryHash=n.prototype.calcAccountRootEntryHash=function(t){t=c.from_json(t);var e=new a;return e.append([0,n.space.account.charCodeAt(0)]),e.append(t.to_bytes()),e.hash()},n.calcOfferEntryHash=n.prototype.calcOfferEntryHash=function(t,e){t=c.from_json(t),e=parseInt(e);var r=new a;return r.append([0,n.space.offer.charCodeAt(0)]),r.append(t.to_bytes()),u.Int32.serialize(r,e),r.hash()},n.calcRippleStateEntryHash=n.prototype.calcRippleStateEntryHash=function(t,e,r){if(r=f.from_json(r),t=c.from_json(t),e=c.from_json(e),!t.is_valid())throw new Error("Invalid first account");if(!e.is_valid())throw new Error("Invalid second account");if(!r.is_valid())throw new Error("Invalid currency");if(t.to_bn().greaterEquals(e.to_bn())){var i=e;e=t,t=i}var o=new a;return o.append([0,n.space.rippleState.charCodeAt(0)]),o.append(t.to_bytes()),o.append(e.to_bytes()),o.append(r.to_bytes()),o.hash()},n.prototype.parse_json=function(t){this.ledger_json=t},n.prototype.calc_tx_hash=function(){var t=new o;return this.ledger_json.transactions.forEach(function(e){var r=i.from_json(e),n=a.from_json(e.metaData),o=new a;u.VariableLength.serialize(o,r.serialize().to_hex()),u.VariableLength.serialize(o,n.to_hex()),t.add_item(r.hash(),o,s.TYPE_TRANSACTION_MD)}),t.hash()},n.prototype.calc_account_hash=function(t){var e,r=new o;if(this.ledger_json.accountState.forEach(function(n){var i=a.from_json(n);if(null!=t&&t.sanity_test)try{var o=i.to_json();i=a.from_json(o)}catch(u){console.log("account state item: ",n),console.log("to_json() ",o),console.log("exception: ",u),e=!0}r.add_item(n.index,i,s.TYPE_ACCOUNT_STATE)}),e)throw new Error("There were errors with sanity_test");return r.hash()},e.Ledger=n},function(t,e,r){function n(){this._queue=[],this._idCache=i({max:200}),this._sequenceCache=i({max:200})}var i=r(48),o=r(5).Transaction;n.prototype.addReceivedSequence=function(t){this._sequenceCache.set(String(t),!0)},n.prototype.hasSequence=function(t){return this._sequenceCache.has(String(t))},n.prototype.addReceivedId=function(t,e){this._idCache.set(t,e)},n.prototype.getReceived=function(t){return this._idCache.get(t)},n.prototype.getSubmission=function(t){for(var e,r=void 0,n=0;e=this._queue[n];n++)if(~e.submittedIDs.indexOf(t)){r=e;break}return r},n.prototype.getMinLedger=function(){for(var t,e=1/0,r=0;t=this._queue[r];r++)t.initialSubmitIndex1)return t.forEach(this.add,this);t=t[0].split("-").map(Number);var e={start:t[0],end:t[1===t.length?0:1]};i(e.start<=e.end,"Ledger range malformed");var r=o.sortedIndex(this._ranges,e,function(t){return t.start});this._ranges.splice(r,0,e)},n.prototype.has=n.prototype.contains=function(t){return i(null!=t&&!isNaN(t),"Ledger must be a number"),t=Number(t),this._ranges.some(function(e){return t>=e.start&&t<=e.end})},n.prototype.reset=function(){this._ranges=[]},e.RangeSet=n},function(t,e,r){function n(t){return"number"==typeof t&&isFinite(t)}function i(t){return"string"==typeof t}function o(t){return i(t)&&/^[0-9A-F]{0,16}$/i.test(t)}function s(t){return t instanceof B}function a(t,e,r){var n=j.fromBits(I.toBits(e));r||L.serialize_varint(t,n.length),t.append(n)}function u(t){return b.codec.hex.fromBits(b.codec.bytes.toBits(t)).toUpperCase()}function c(t){return I.fromBits(C.toBits(t)).toUpperCase()}function f(t){return C.fromBits(I.toBits(t))}function h(t,e){if(!n(t))throw new Error("Value is not a number",e);if(0>t||t>=Math.pow(256,e))throw new Error("Value out of bounds");for(var r=[],i=0;e>i;i++)r.unshift(t>>>8*i&255);return r}function l(t,e){var r=0;if(e>4)throw new Error("This function only supports up to four bytes.");for(var n=0;e>n;n++){var i=t.read(1)[0];r+=i<<8*(e-n-1)}return r>>>0}function p(t,r,n){var i=m.fieldsInverseMap[r],o=i[0],s=i[1],a=(16>o?o<<4:0)|(16>s?s:0);"LedgerEntryType"===r&&"string"==typeof n&&(n=m.ledger[n][0]),"TransactionResult"===r&&"string"==typeof n&&(n=m.ter[n]),R.serialize(t,a),o>=16&&R.serialize(t,o),s>=16&&R.serialize(t,s);var u;u="Memo"===r&&"object"==typeof n?e.STMemo:e[m.types[o]];try{u.serialize(t,n)}catch(c){throw c.message+=" ("+r+")",c}}function d(t){var r=t.read(1)[0],n=r>>4;0===n&&(n=t.read(1)[0]);var i=15&r,o=o=0===i?m.fields[n][t.read(1)[0]]:m.fields[n][i];y(o,"Unknown field - header byte is 0x"+r.toString(16));var s="Memo"===o?e.STMemo:e[m.types[n]];return y(s,"Unknown type - header byte is 0x"+r.toString(16)),[o,s.parse(t)]}function _(t){function e(t,e){var r=m.fieldsInverseMap[t],n=r[0],i=r[1],o=m.fieldsInverseMap[e],s=o[0],a=o[1];return n!==s?n-s:i-a}return t.sort(e)}var y=r(41),v=r(46),m=r(16),g=r(17),b=g.sjcl,w=r(8).UInt128,E=r(9).UInt160,x=r(10).UInt256,A=r(7).Base,S=r(3),T=S.Amount,k=S.Currency,I=b.codec.hex,j=b.codec.bytes,C=b.codec.utf8String,B=g.jsbn.BigInteger,L=function(t){v(this,t)};L.serialize_varint=function(t,e){if(0>e)throw new Error("Variable integers are unsigned.");if(192>=e)t.append([e]);else if(12480>=e)e-=193,t.append([193+(e>>>8),255&e]);else{if(!(918744>=e))throw new Error("Variable integer overflow.");e-=12481,t.append([241+(e>>>16),e>>>8&255,255&e])}},L.prototype.parse_varint=function(t){var e,r,n,i=t.read(1)[0];if(i>254)throw new Error("Invalid varint length indicator");return 192>=i?n=i:240>=i?(e=t.read(1)[0],n=193+256*(i-193)+e):254>=i&&(e=t.read(1)[0],r=t.read(1)[0],n=12481+65536*(i-241)+256*e+r),n};var R=e.Int8=new L({serialize:function(t,e){t.append(h(e,1))},parse:function(t){return l(t,1)}});R.id=16;var O=e.Int16=new L({serialize:function(t,e){t.append(h(e,2))},parse:function(t){return l(t,2)}});O.id=1;var D=e.Int32=new L({serialize:function(t,e){t.append(h(e,4))},parse:function(t){return l(t,4)}});D.id=2;var N=e.Int64=new L({serialize:function(t,e){var r;if(n(e)){if(e=Math.floor(e),0>e)throw new Error("Negative value for unsigned Int64 is invalid.");r=new B(String(e),10)}else if(i(e)){if(!o(e))throw new Error("Not a valid hex Int64.");r=new B(e,16)}else{if(!s(e))throw new Error("Invalid type for Int64");if(e.compareTo(B.ZERO)<0)throw new Error("Negative value for unsigned Int64 is invalid.");r=e}var u=r.toString(16);if(u.length>16)throw new Error("Int64 is too large");for(;u.length<16;)u="0"+u;a(t,u,!0)},parse:function(t){var e=t.read(8),r=new B([0].concat(e),256);return y(r instanceof B),r}});N.id=3;var q=e.Hash128=new L({serialize:function(t,e){var r=w.from_json(e);if(!r.is_valid())throw new Error("Invalid Hash128");a(t,r.to_hex(),!0)},parse:function(t){return w.from_bytes(t.read(16))}});q.id=4;var M=e.Hash256=new L({serialize:function(t,e){var r=x.from_json(e);if(!r.is_valid())throw new Error("Invalid Hash256");a(t,r.to_hex(),!0)},parse:function(t){return x.from_bytes(t.read(32))}});M.id=5;var F=e.Hash160=new L({serialize:function(t,e){var r=E.from_json(e);if(!r.is_valid())throw new Error("Invalid Hash160");a(t,r.to_hex(),!0)},parse:function(t){return E.from_bytes(t.read(20))}});F.id=17;var P=new L({serialize:function(t,e){var r=e.to_bytes();if(!r)throw new Error("Tried to serialize invalid/unimplemented currency type.");t.append(r)},parse:function(t){var e=t.read(20),r=k.from_bytes(e);return r}}),U=e.Amount=new L({serialize:function(t,e){var r=T.from_json(e);if(!r.is_valid())throw new Error("Not a valid Amount object.");var n=g.arraySet(8,0);if(r.is_native()){var i=r._value.toString(16);if(i.length>16)throw new Error("Value out of bounds");for(;i.length<16;)i="0"+i;n=j.fromBits(I.toBits(i)),n[0]&=63,r.is_negative()||(n[0]|=64)}else{var o=0,s=0;o|=1<<31,r.is_zero()||(r.is_negative()||(o|=1<<30),o|=(97+r._offset&255)<<22,o|=4194303&r._value.shiftRight(32).intValue(),s=4294967295&r._value.intValue()),n=b.codec.bytes.fromBits([o,s])}if(t.append(n),!r.is_native()){var a=r.currency();P.serialize(t,a,!0),t.append(r.issuer().to_bytes())}},parse:function(t){for(var e=new T,r=t.read(8),n=!(127&r[0]),i=1;8>i;i++)n=n&&!r[i];if(128&r[0]){var o=P.parse(t),s=t.read(20),a=E.from_bytes(s);a.set_version(A.VER_ACCOUNT_ID);var u=((63&r[0])<<2)+(r[1]>>>6)-97,c=r.slice(1);c[0]&=63;var f=new B(c,256);if(f.equals(B.ZERO)&&!n)throw new Error("Invalid zero representation");e._value=f,e._offset=u,e._currency=o,e._issuer=a,e._is_native=!1}else{var h=r.slice();h[0]&=63,e._value=new B(h,256),e._is_native=!0}return e._is_negative=!(n||64&r[0]),e}});U.id=6;var z=e.VariableLength=e.VL=new L({serialize:function(t,e){if("string"!=typeof e)throw new Error("Unknown datatype.");a(t,e)},parse:function(t){var e=this.parse_varint(t);return u(t.read(e))}});z.id=7;var H=e.Account=new L({serialize:function(t,e){var r=E.from_json(e);if(!r.is_valid())throw new Error("Invalid account!");a(t,r.to_hex())},parse:function(t){var e=this.parse_varint(t);if(20!==e)throw new Error("Non-standard-length account ID");var r=E.from_bytes(t.read(e));return r.set_version(A.VER_ACCOUNT_ID),r}});H.id=8;var G=e.PathSet=new L({typeBoundary:255,typeEnd:0,typeAccount:1,typeCurrency:16,typeIssuer:32,serialize:function(t,e){for(var r=0,n=e.length;n>r;r++){r&&R.serialize(t,this.typeBoundary);for(var i=0,o=e[r].length;o>i;i++){var s=e[r][i],a=0;if(s.account&&(a|=this.typeAccount),s.currency&&(a|=this.typeCurrency),s.issuer&&(a|=this.typeIssuer),R.serialize(t,a),s.account&&t.append(E.from_json(s.account).to_bytes()),s.currency){var u=k.from_json(s.currency,s.non_native);P.serialize(t,u)}s.issuer&&t.append(E.from_json(s.issuer).to_bytes())}}R.serialize(t,this.typeEnd)},parse:function(t){for(var e,r=[],n=[];(e=t.read(1)[0])!==this.typeEnd;)if(e!==this.typeBoundary){var i={},o=0;if(e&this.typeAccount&&(i.account=F.parse(t),i.account.set_version(A.VER_ACCOUNT_ID),o|=this.typeAccount),e&this.typeCurrency&&(i.currency=P.parse(t),"XRP"!==i.currency.to_json()||i.currency.is_native()||(i.non_native=!0),o|=this.typeCurrency),e&this.typeIssuer&&(i.issuer=F.parse(t),i.issuer.set_version(A.VER_ACCOUNT_ID),o|=this.typeIssuer),!(i.account||i.currency||i.issuer))throw new Error("Invalid path entry");i.type=o,i.type_hex=("000000000000000"+o.toString(16)).slice(-16),n.push(i)}else n&&r.push(n),n=[];return n&&r.push(n),r}});G.id=18;var V=e.Vector256=new L({serialize:function(t,e){for(var r=(L.serialize_varint(t,32*e.length),0),n=e.length;n>r;r++)M.serialize(t,e[r])},parse:function(t){for(var e=this.parse_varint(t),r=[],n=0;e/32>n;n++)r.push(M.parse(t));return r}});V.id=19;e.STMemo=new L({serialize:function(t,e,r){var n=[];Object.keys(e).forEach(function(t){if(t[0]!==t[0].toLowerCase()){if("undefined"==typeof m.fieldsInverseMap[t])throw new Error('JSON contains unknown field: "'+t+'"');n.push(t)}}),n=_(n);for(var o="json"===e.MemoFormat,s=0;sr;r++){var i=Object.keys(e[r]);if(1!==i.length)throw Error("Cannot serialize an array containing non-single-key objects");var o=i[0],s=e[r][o];p(t,o,s)}R.serialize(t,241)},parse:function(t){for(var e=[];241!==t.peek(1)[0];){var r=d(t),n={};n[r[0]]=r[1],e.push(n)}return t.read(1),e}});X.id=15},function(t,e,r){var n=r(46),i=t.exports={load:function(t){return n(i,t),i}}},function(t,e,r){function n(t,e,r,i,o,s){function a(t,e){if(~n.EVENTS.indexOf(e))switch(t){case"add":1===++f._listeners&&f.subscribe();break;case"remove":0===--f._listeners&&f.unsubscribe()}}function c(t){f.updateFundedAmounts(t)}u.call(this);var f=this;return this._remote=t,this._currencyGets=h.from_json(e),this._issuerGets=r,this._currencyPays=h.from_json(i),this._issuerPays=o,this._key=s,this._subscribed=!1,this._shouldSubscribe=!0,this._listeners=0,this._offers=[],this._offerCounts={},this._ownerFunds={},this._ownerOffers={},this._synchronized=!1,this.on("newListener",function(t){a("add",t)}),this.on("removeListener",function(t){a("remove",t)}),this._remote.on("transaction",c),this.on("unsubscribe",function(){f.resetCache(),f._remote.removeListener("transaction",c)}),this._remote.once("prepare_subscribe",function(){f.subscribe()}),this._remote.on("disconnect",function(){f.resetCache(),f._remote.once("prepare_subscribe",function(){f.subscribe()})}),this}var i=r(40),o=r(46),s=r(41),a=r(47),u=r(39).EventEmitter,c=r(3).Amount,f=r(9).UInt160,h=r(6).Currency,l=r(28).internal.sub("orderbook");i.inherits(n,u),n.EVENTS=["transaction","model","trade","offer_added","offer_removed","offer_changed","offer_funds_changed"],n.DEFAULT_TRANSFER_RATE=1e9,n.IOU_SUFFIX="/000/rrrrrrrrrrrrrrrrrrrrrhoLvTp",n.prototype.subscribe=function(){var t=this;if(this._shouldSubscribe){this._remote.trace&&l.info("subscribing",this._key);var e=[function(e){t.requestTransferRate(e)},function(e){t.requestOffers(e)},function(e){t.subscribeTransactions(e)}];a.series(e,function(){})}},n.prototype.unsubscribe=function(){var t=this;this._remote.trace&&l.info("unsubscribing",this._key),this._subscribed=!1,this._shouldSubscribe=!1,n.EVENTS.forEach(function(e){t.listeners(e).length>0&&t.removeAllListeners(e)}),this.emit("unsubscribe")},n.prototype.resetCache=function(){this._ownerFunds={},this._ownerOffers={},this._offerCounts={},this._synchronized=!1},n.prototype.hasCachedFunds=function(t){return s(f.is_valid(t),"Account is invalid"),void 0!==this._ownerFunds[t]},n.prototype.addCachedFunds=function(t,e){s(f.is_valid(t),"Account is invalid"),s(!isNaN(e),"Funded amount is invalid"),this._ownerFunds[t]=e},n.prototype.getCachedFunds=function(t){return s(f.is_valid(t),"Account is invalid"),this._ownerFunds[t]},n.prototype.removeCachedFunds=function(t){s(f.is_valid(t),"Account is invalid"),this._ownerFunds[t]=void 0},n.prototype.getOfferCount=function(t){return s(f.is_valid(t),"Account is invalid"),this._offerCounts[t]||0},n.prototype.incrementOfferCount=function(t){s(f.is_valid(t),"Account is invalid");var e=(this._offerCounts[t]||0)+1;return this._offerCounts[t]=e,e},n.prototype.decrementOfferCount=function(t){s(f.is_valid(t),"Account is invalid");var e=(this._offerCounts[t]||1)-1;return this._offerCounts[t]=e,e},n.prototype.addOwnerOffer=function(t,e){s(f.is_valid(t),"Account is invalid");var r=this.getOwnerOfferSum(t),n=r.add(c.from_json(e));return this._ownerOffers[t]=n,n},n.prototype.subtractOwnerOffer=function(t,e){s(f.is_valid(t),"Account is invalid");var r=this.getOwnerOfferSum(t),n=r.subtract(c.from_json(e));return this._ownerOffers[t]=n,n},n.prototype.getOwnerOfferSum=function(t){s(f.is_valid(t),"Account is invalid");var e=this._ownerOffers[t];return e||(e=this._currencyGets.is_native()?c.from_json("0"):c.from_json("0"+n.IOU_SUFFIX)),e},n.prototype.applyTransferRate=function(t,e){if(s(!isNaN(t),"Balance is invalid"),this._currencyGets.is_native())return t;if(void 0===e&&(e=this._issuerTransferRate),s(!isNaN(e),"Transfer rate is invalid"),e===n.DEFAULT_TRANSFER_RATE)return t;var r=c.from_json(t+n.IOU_SUFFIX).divide(e).multiply(c.from_json(n.DEFAULT_TRANSFER_RATE)).to_json().value;return r},n.prototype.requestTransferRate=function(t){s.strictEqual(typeof t,"function");var e=this,r=this._issuerGets;return this._currencyGets.is_native()?(t(null,n.DEFAULT_TRANSFER_RATE),void 0):this._issuerTransferRate?(t(null,this._issuerTransferRate),void 0):(this._remote.requestAccountInfo({account:r},function(r,i){if(r)return t(r);var o=i.account_data.TransferRate;o||(o=n.DEFAULT_TRANSFER_RATE),e._issuerTransferRate=o,t(null,o)}),void 0)},n.prototype.setFundedAmount=function(t,e){if(s.strictEqual(typeof t,"object","Offer is invalid"),s(!isNaN(e),"Funds is invalid"),"0"===e)return t.taker_gets_funded="0",t.taker_pays_funded="0",t.is_fully_funded=!1,t;var r=this.getOwnerOfferSum(t.Account);if(r.is_zero()&&(r=c.from_json(t.TakerGets)),t.is_fully_funded=c.from_json(this._currencyGets.is_native()?e:e+n.IOU_SUFFIX).compareTo(r)>=0,t.is_fully_funded)return t.taker_gets_funded=c.from_json(t.TakerGets).to_text(),t.taker_pays_funded=c.from_json(t.TakerPays).to_text(),t;t.taker_gets_funded=e;var i="object"==typeof t.TakerPays?t.TakerPays.value:t.TakerPays,o=c.from_json(i+n.IOU_SUFFIX),a=c.from_json(r),u=c.from_json(e+n.IOU_SUFFIX),f=o.divide(a);return u=u.multiply(f),u=u.compareTo(o)<0?this._currencyPays.is_native()?String(parseInt(u.to_json().value,10)):u.to_json().value:o.to_json().value,t.taker_pays_funded=u,t},n.prototype.requestFundedAmount=function(t,e){function r(e){o._remote.requestAccountInfo({account:t},function(t,r){t?e(t):e(null,String(r.account_data.Balance))})}function n(e){var r=o._remote.requestAccountLines({account:t,ledger:"validated",peer:o._issuerGets});r.request(function(t,r){if(t)return e(t);for(var n,i=o._currencyGets.to_json(),s="0",a=0;n=r.lines[a];a++)if(n.currency===i){s=n.balance;break}e(null,s)})}function i(r,n){if(r)return o._remote.trace&&l.info("failed to request funds",r),e(r);o._remote.trace&&l.info("requested funds",t,n);var i,s;o._currencyGets.is_native()?(i=n[0],s=i):(i=n[1],s=o.applyTransferRate(i,n[0])),e(null,s)}s(f.is_valid(t),"Account is invalid"),s.strictEqual(typeof e,"function","Callback is invalid");var o=this;o._remote.trace&&l.info("requesting funds",t);var u=[];this._currencyGets.is_native()?u.push(r):(u.push(this.requestTransferRate.bind(this)),u.push(n)),a.parallel(u,i)},n.prototype.getBalanceChange=function(t){var e={account:void 0,balance:void 0};switch(t.entryType){case"AccountRoot":e.account=t.fields.Account,e.balance=t.fieldsFinal.Balance;break;case"RippleState":t.fields.HighLimit.issuer===this._issuerGets?(e.account=t.fields.LowLimit.issuer,e.balance=t.fieldsFinal.Balance.value):t.fields.LowLimit.issuer===this._issuerGets&&(e.account=t.fields.HighLimit.issuer,e.balance=c.from_json(t.fieldsFinal.Balance).negate().to_json().value)}return e.isValid=!isNaN(e.balance)&&f.is_valid(e.account),e},n.prototype.isBalanceChange=function(t){return t.fields&&t.fields.Balance&&t.fieldsPrev&&t.fieldsFinal&&t.fieldsPrev.Balance&&t.fieldsFinal.Balance?this._currencyGets.is_native()?!isNaN(t.fields.Balance):t.fields.Balance.currency!==this._currencyGets.to_json()?!1:t.fields.HighLimit.issuer!==this._issuerGets&&t.fields.LowLimit.issuer!==this._issuerGets?!1:!0:!1},n.prototype.updateFundedAmounts=function(t){var e=this,r=t.mmeta.getAffectedAccounts(),n=r.some(function(t){return e.hasCachedFunds(t)});if(n){if(!this._currencyGets.is_native()&&!this._issuerTransferRate)return this._remote.trace&&l.info("waiting for transfer rate"),this.requestTransferRate(function(){e.updateFundedAmounts(t)}),void 0;for(var i=t.mmeta.getNodes({nodeType:"ModifiedNode",entryType:this._currencyGets.is_native()?"AccountRoot":"RippleState"}),o=0,s=i.length;s>o;o++){var a=i[o];if(this.isBalanceChange(a)){var u=this.getBalanceChange(a);u.isValid&&this.hasCachedFunds(u.account)&&this.updateAccountFunds(u.account,u.balance)}}}},n.offerRewrite=function(t){for(var e={},r=Object.keys(t),n=0,i=r.length;i>n;n++){var o=r[n];switch(o){case"PreviousTxnID":case"PreviousTxnLgrSeq":case"quality":break;default:e[o]=t[o]}}return e.Flags=e.Flags||0,e.OwnerNode=e.OwnerNode||new Array(17).join("0"),e.BookNode=e.BookNode||new Array(17).join("0"),e},n.prototype.setOffers=function(t){s(Array.isArray(t));for(var e=t.length,r=[],i=0;e>i;i++){var o=t[i];this.addOwnerOffer(o.Account,o.TakerGets)}for(var i=0;e>i;i++){var a,o=n.offerRewrite(t[i]);this.hasCachedFunds(o.Account)?a=this.getCachedFunds(o.Account):o.hasOwnProperty("owner_funds")&&(a=this.applyTransferRate(o.owner_funds),this.addCachedFunds(o.Account,a)),this.incrementOfferCount(o.Account),this.setFundedAmount(o,a),r.push(o)}this._offers=r},n.prototype.requestOffers=function(t){function e(e){return Array.isArray(e.offers)?(n._remote.trace&&l.info("requested offers",n._key,"offers: "+e.offers.length),n.setOffers(e.offers),n._synchronized=!0,n.emit("model",n._offers),t(null,n._offers),void 0):t(new Error("Invalid response"))}function r(e){n._remote.trace&&l.info("failed to request offers",n._key,e),t(e)}var n=this;if("function"!=typeof t&&(t=function(){}),!this._shouldSubscribe)return t(new Error("Should not request offers"));this._remote.trace&&l.info("requesting offers",this._key);var i=this._remote.requestBookOffers(this.toJSON());return i.once("success",e),i.once("error",r),i.request(),i},n.prototype.subscribeTransactions=function(t){function e(e){n._remote.trace&&l.info("subscribed to transactions"),n._subscribed=!0,t(null,e)}function r(e){n._remote.trace&&l.info("failed to subscribe to transactions",n._key,e),t(e)}var n=this;if("function"!=typeof t&&(t=function(){}),!this._shouldSubscribe)return t("Should not subscribe");this._remote.trace&&l.info("subscribing to transactions");var i=this._remote.requestSubscribe();return i.addStream("transactions"),i.once("success",e),i.once("error",r),i.request(),i},n.prototype.offers=n.prototype.getOffers=function(t){s.strictEqual(typeof t,"function","Callback missing");return this._synchronized?t(null,this._offers):this.once("model",function(e){t(null,e)}),this},n.prototype.offersSync=n.prototype.getOffersSync=function(){return this._offers},n.prototype.updateAccountFunds=function(t,e){s(f.is_valid(t),"Account is invalid"),s(!isNaN(e),"Funded amount is invalid"),this._remote.trace&&l.info("updating offer funds",this._key,t,r);var r=this.applyTransferRate(e);this.addCachedFunds(t,r);for(var i=0,a=this._offers.length;a>i;i++){var u=this._offers[i];if(u.Account===t){var h=o({},u),p=c.from_json(u.taker_gets_funded+n.IOU_SUFFIX);u.owner_funds=e,this.setFundedAmount(u,r);var d=!p.equals(c.from_json(u.taker_gets_funded+n.IOU_SUFFIX));d&&(this.emit("offer_changed",h,u),this.emit("offer_funds_changed",u,h.taker_gets_funded,u.taker_gets_funded))}}},n.prototype.insertOffer=function(t,e){this._remote.trace&&l.info("inserting offer",this._key,t.fields),this.addOwnerOffer(t.fields.Account,t.fields.TakerGets);var r=n.offerRewrite(t.fields);r.LedgerEntryType=t.entryType,r.index=t.ledgerIndex,isNaN(e)||(this.setFundedAmount(r,e),this.addCachedFunds(r.Account,e));for(var i={reference_date:new Date},o=c.from_json(r.TakerPays).ratio_human(r.TakerGets,i),s=0,a=this._offers.length;a>s;s++){var u=this._offers[s],f=c.from_json(u.TakerPays).ratio_human(u.TakerGets,i);if(o.compareTo(f)<=0){this._offers.splice(s,0,r);break}s===a-1&&this._offers.push(r)}this.emit("offer_added",r)},n.prototype.modifyOffer=function(t,e){this._remote.trace&&(e?l.info("deleting offer",this._key,t.fields):l.info("modifying offer",this._key,t.fields));for(var r=0,n=this._offers.length;n>r;r++){var i=this._offers[r];if(i.index===t.ledgerIndex){if(e)this.subtractOwnerOffer(i.Account,i.TakerGets),this._offers.splice(r,1),this.emit("offer_removed",i);else{var s=o({},i);o(i,t.fieldsFinal),this.subtractOwnerOffer(i.Account,s.TakerGets),this.addOwnerOffer(i.Account,i.TakerGets),this.emit("offer_changed",s,i)}break}}},n.prototype.notify=function(t){function e(e,n){var s="DeletedNode"===e.nodeType,a="OfferCancel"===t.transaction.TransactionType;switch(e.nodeType){case"DeletedNode":case"ModifiedNode":r.modifyOffer(e,s),a||(i=i.add(e.fieldsPrev.TakerGets),o=o.add(e.fieldsPrev.TakerPays),s?r.decrementOfferCount(e.fields.Account)<1&&r.removeCachedFunds(e.fields.Account):(i=i.subtract(e.fieldsFinal.TakerGets),o=o.subtract(e.fieldsFinal.TakerPays))),n();break;case"CreatedNode":r.incrementOfferCount(e.fields.Account);var u=t.transaction.owner_funds;if(!isNaN(u))return r.insertOffer(e,u),n();r.requestFundedAmount(e.fields.Account,function(t,i){t||r.insertOffer(e,i),n()})}}var r=this;if(this._subscribed){var n=t.mmeta.getNodes({entryType:"Offer",bookKey:this._key});if(!(n.length<1)){this._remote.trace&&l.info("notifying",this._key,t.transaction.hash);var i=c.from_json("0"+(h.from_json(this._currencyGets).is_native()?"":"/"+this._currencyGets+"/"+this._issuerGets)),o=c.from_json("0"+(h.from_json(this._currencyPays).is_native()?"":"/"+this._currencyPays+"/"+this._issuerPays));a.eachSeries(n,e,function(){r.emit("transaction",t),r.emit("model",r._offers),i.is_zero()||r.emit("trade",o,i)})}}},n.prototype.toJSON=n.prototype.to_json=function(){var t={taker_gets:{currency:this._currencyGets.to_hex()},taker_pays:{currency:this._currencyPays.to_hex()}};return this._currencyGets.is_native()||(t.taker_gets.issuer=this._issuerGets),this._currencyPays.is_native()||(t.taker_pays.issuer=this._issuerPays),t},n.prototype.isValid=n.prototype.is_valid=function(){return this._currencyPays&&this._currencyPays.is_valid()&&(this._currencyPays.is_native()||f.is_valid(this._issuerPays))&&this._currencyGets&&this._currencyGets.is_valid()&&(this._currencyGets.is_native()||f.is_valid(this._issuerGets))&&!(this._currencyPays.is_native()&&this._currencyGets.is_native())},e.OrderBook=n},function(t,e,r){function n(t,e,r,n,o){i.call(this),this.remote=t,this.src_account=e,this.dst_account=r,this.dst_amount=n,this.src_currencies=o}{var i=r(39).EventEmitter,o=r(40),s=r(3).Amount;r(46)}o.inherits(n,i),n.prototype.create=function(){var t=this,e=this.remote.request_path_find_create(this.src_account,this.dst_account,this.dst_amount,this.src_currencies);e.once("error",function(e){t.emit("error",e)}),e.once("success",function(e){t.notify_update(e)}),e.broadcast().request()},n.prototype.close=function(){this.remote.request_path_find_close().broadcast().request(),this.emit("end"),this.emit("close")},n.prototype.notify_update=function(t){var e=t.source_account,r=t.destination_account,n=s.from_json(t.destination_amount);this.src_account===e&&this.dst_account===r&&this.dst_amount.equals(n)&&this.emit("update",t)},n.prototype.notify_superceded=function(){this.emit("end"),this.emit("superceded")},e.PathFind=n},function(t,e){e.HASH_TX_ID=1415073280,e.HASH_TX_NODE=1397638144,e.HASH_INNER_NODE=1296649728,e.HASH_LEAF_NODE=1296846336,e.HASH_TX_SIGN=1398036480,e.HASH_TX_SIGN_TESTNET=1937012736},function(t,e,r){var e=t.exports=r(42),n={logObject:function(t){var e=Array.prototype.slice.call(arguments,1);e=e.map(function(t){return/MSIE/.test(navigator.userAgent)?JSON.stringify(t,null,2):t}),e.unshift(t),e.unshift("["+(new Date).toISOString()+"]"),console.log.apply(console,e)}};window.console&&window.console.log&&(e.Log.engine=n)},function(t,e,r){function n(t){function e(t){n._updatePendingStatus(t)}function r(){n._handleReconnect(function(){n._remote.on("ledger_closed",e)})}a.call(this);var n=this;this._account=t,this._accountID=t._account_id,this._remote=t._remote,this._nextSequence=void 0,this._maxFee=this._remote.max_fee,this._maxAttempts=this._remote.max_attempts,this._submissionTimeout=this._remote._submission_timeout,this._lastLedgerOffset=this._remote._last_ledger_offset,this._pending=new f,this._account.on("transaction-outbound",function(t){n._transactionReceived(t) }),this._remote.on("load_changed",function(t){n._adjustFees(t)}),this._remote.on("ledger_closed",e),this._remote.on("disconnect",function(){n._remote.removeListener("ledger_closed",e),n._remote.once("connect",r)}),this._loadSequence()}var i=r(40),o=r(41),s=r(47),a=r(39).EventEmitter,u=r(5).Transaction,c=r(14).RippleError,f=r(21).TransactionQueue,h=r(28).internal.sub("transactionmanager");i.inherits(n,a),n._isNoOp=function(t){return"object"==typeof t&&"object"==typeof t.tx_json&&"AccountSet"===t.tx_json.TransactionType&&0===t.tx_json.Flags},n._isRemoteError=function(t){return"object"==typeof t&&"remoteError"===t.error&&"object"==typeof t.remote},n._isNotFound=function(t){return n._isRemoteError(t)&&/^(txnNotFound|transactionNotFound)$/.test(t.remote.error)},n._isTooBusy=function(t){return n._isRemoteError(t)&&"tooBusy"===t.remote.error},n.normalizeTransaction=function(t){for(var e={},r=Object.keys(t),n=0;ne._maxFee)return t(r);r.tx_json.Fee=i,r.emit("fee_adjusted",n,i),e._remote.trace&&h.info("fee adjusted:",r.tx_json,n,i)}})},n.prototype.getPending=function(){return this._pending},n.prototype._updatePendingStatus=function(t){o.strictEqual(typeof t,"object"),o.strictEqual(typeof t.ledger_index,"number"),this._pending.forEach(function(e){switch(t.ledger_index-e.submitIndex){case 4:e.emit("missing",t);break;case 8:e.emit("lost",t)}e.finalized||t.ledger_index>e.tx_json.LastLedgerSequence&&e.emit("error",new c("tejMaxLedger","Transaction LastLedgerSequence exceeded"))})},n.prototype._fillSequence=function(t,e){function r(e,r){var n=i._remote.transaction();n.account_set(i._accountID),n.tx_json.Sequence=e,n.once("submitted",r),t._secret&&n.secret(t._secret),n.submit()}function n(n,i){if("number"!=typeof i)return e(new Error("Failed to fetch account transaction sequence"));var o=t.tx_json.Sequence-i,s=0;!function a(n){n>=t.tx_json.Sequence||r(n,function(){++s===o?e():a(n+1)})}(i)}var i=this;this._loadSequence(n)},n.prototype._loadSequence=function(t){function e(e,n){return(e||"number"!=typeof n)&&r._remote.trace?(h.info("error requesting account transaction sequence",e),void 0):(r._nextSequence=n,r.emit("sequence_loaded",n),t(e,n),void 0)}var r=this,t="function"==typeof t?t:function(){};this._account.getNextSequence(e)},n.prototype._handleReconnect=function(t){function e(e,n){return e||"object"!=typeof n?(r._remote.trace&&h.info("error requesting account_tx",e),t(),void 0):(Array.isArray(n.transactions)&&n.transactions.forEach(r._transactionReceived,r),t(),r._loadSequence(function(){r._resubmit()}),void 0)}var r=this,t="function"==typeof t?t:function(){};if(!this._pending.length())return t();var n={account:this._accountID,ledger_index_min:this._pending.getMinLedger(),ledger_index_max:-1,binary:!0,parseBinary:!0,limit:20};this._remote.requestAccountTx(n,e)},n.prototype._waitLedgers=function(t,e){function r(){++i===t&&(n._remote.removeListener("ledger_closed",r),e())}if(o.strictEqual(typeof t,"number"),o.strictEqual(typeof e,"function"),1>t)return e();var n=this,i=0;this._remote.on("ledger_closed",r)},n.prototype._resubmit=function(t,e){function r(t,e){if(t&&!t.finalized){var r=t.findId(n._pending._idCache);if(r)switch(r.engine_result){case"tesSUCCESS":t.emit("success",r);break;default:t.emit("error",r)}for(;n._pending.hasSequence(t.tx_json.Sequence);)t.tx_json.Sequence+=1,n._remote.trace&&h.info("incrementing sequence:",t.tx_json);n._remote.trace&&h.info("resubmit:",t.tx_json),t.once("submitted",function(r){t.emit("resubmitted",r),e()}),n._request(t)}}var n=this,t=t||0,e=e?[e]:this._pending;this._waitLedgers(t,function(){s.eachSeries(e,r)})},n.prototype._prepareRequest=function(t){var e=this._remote.requestSubmit();if(this._remote.local_signing){t.sign();var r=t.serialize();e.tx_blob(r.to_hex());var n=t.hash(null,null,r);t.addId(n)}else e.build_path(t._build_path),e.secret(t._secret),e.tx_json(t.tx_json);return e},n.prototype._request=function(t){function e(e){"tefPAST_SEQ"===e.engine_result&&u._resubmit(1,t)}function r(){u._fillSequence(t,function(){u._resubmit(1,t)})}function i(e){"telINSUF_FEE_P"===e.engine_result&&u._resubmit(1,t)}function o(e){n._isTooBusy(e)?u._resubmit(1,t):(u._nextSequence--,t.emit("error",e))}function s(n){if(!t.finalized)switch(n.tx_json&&n.tx_json.hash&&t.addId(n.tx_json.hash),n.result=n.engine_result||"",t.result=n,t.responses+=1,f.trace&&h.info("submit response:",n),t.emit("submitted",n),n.result.slice(0,3)){case"tes":t.emit("proposed",n);break;case"tec":break;case"ter":r(n);break;case"tef":e(n);break;case"tel":i(n);break;default:o(n)}}function a(){t.finalized||(t.emit("timeout"),f.isConnected()&&(f.trace&&h.info("timeout:",t.tx_json),u._resubmit(1,t)))}var u=this,f=this._remote;if(!t.finalized){if(t.attempts>this._maxAttempts)return t.emit("error",new c("tejAttemptsExceeded")),void 0;if(t.attempts>0&&!f.local_signing){var l="Automatic resubmission requires local signing";return t.emit("error",new c("tejLocalSigningRequired",l)),void 0}f.trace&&h.info("submit transaction:",t.tx_json),t.submitIndex=this._remote._ledger_current_index,0===t.attempts&&(t.initialSubmitIndex=t.submitIndex),t._setLastLedger||(t.tx_json.LastLedgerSequence=t.initialSubmitIndex+this._lastLedgerOffset),t.lastLedgerSequence=t.tx_json.LastLedgerSequence,f.local_signing&&t.sign();var p=this._prepareRequest(t);return p.once("error",s),p.once("success",s),t.emit("presubmit"),p.broadcast().request(),t.attempts++,t.emit("postsubmit"),p.timeout(u._submissionTimeout,a),p}},n.prototype.submit=function(t){{var e=this;this._remote}if("number"!=typeof this._nextSequence)return this.once("sequence_loaded",function(){e.submit(t)}),void 0;if(!t.finalized){if("number"!=typeof t.tx_json.Sequence&&(t.tx_json.Sequence=this._nextSequence++),t.once("cleanup",function(){e.getPending().remove(t)}),!t.complete())return this._nextSequence--,void 0;this._pending.push(t),this._request(t)}},e.TransactionManager=n},function(t,e){var r=e.Float={};r.toIEEE754=function(t,e,r){var n,i,o,s=(1<t?1:0;else if(0===t)i=0,o=0,n=1/t===-1/0?1:0;else if(n=0>t,t=Math.abs(t),t>=Math.pow(2,1-s)){var a=Math.min(Math.floor(Math.log(t)/Math.LN2),s);i=a+s,o=t*Math.pow(2,r-a)-Math.pow(2,r)}else i=0,o=t/Math.pow(2,1-s-r);var u,c=[];for(u=r;u;u-=1)c.push(o%2?1:0),o=Math.floor(o/2);for(u=e;u;u-=1)c.push(i%2?1:0),i=Math.floor(i/2);c.push(n?1:0),c.reverse();for(var f=c.join(""),h=[];f.length;)h.push(parseInt(f.substring(0,8),2)),f=f.substring(8);return h},r.fromIEEE754=function(t,e,r){for(var n=[],i=t.length;i;i-=1)for(var o=t[i-1],s=8;s;s-=1)n.push(o%2?1:0),o>>=1;n.reverse();var a=n.join(""),u=(1<0?c*Math.pow(2,f-u)*(1+h/Math.pow(2,r)):0!==h?c*Math.pow(2,-(u-1))*(h/Math.pow(2,r)):0*c},r.fromIEEE754Double=function(t){return r.fromIEEE754(t,11,52)},r.toIEEE754Double=function(t){return r.toIEEE754(t,11,52)},r.fromIEEE754Single=function(t){return r.fromIEEE754(t,8,23)},r.toIEEE754Single=function(t){return r.toIEEE754(t,8,23)},r.toIEEE754DoubleString=function(t){return e.toIEEE754Double(t).map(function(t){for(t=t.toString(2);t.length<8;t="0"+t);return t}).join("").replace(/(.)(.{11})(.{52})/,"$1 $2 $3")}},function(t,e,r){var n=r(17),i=n.sjcl,o=r(24),s=n.jsbn.BigInteger,a=function(){this._value=0/0,this._update()};a.json_rewrite=function(t,e){return this.from_json(t).to_json(e)},a.from_generic=function(t){return t instanceof this?t.clone():(new this).parse_generic(t)},a.from_hex=function(t){return t instanceof this?t.clone():(new this).parse_hex(t)},a.from_json=function(t){return t instanceof this?t.clone():(new this).parse_json(t)},a.from_bits=function(t){return t instanceof this?t.clone():(new this).parse_bits(t)},a.from_bytes=function(t){return t instanceof this?t.clone():(new this).parse_bytes(t)},a.from_bn=function(t){return t instanceof this?t.clone():(new this).parse_bn(t)},a.from_number=function(t){return t instanceof this?t.clone():(new this).parse_number(t)},a.is_valid=function(t){return this.from_json(t).is_valid()},a.prototype.clone=function(){return this.copyTo(new this.constructor)},a.prototype.copyTo=function(t){return t._value=this._value,void 0!==this._version_byte&&(t._version_byte=this._version_byte),"function"==typeof t._update&&t._update(),t},a.prototype.equals=function(t){return this._value instanceof s&&t._value instanceof s&&this._value.equals(t._value)},a.prototype.is_valid=function(){return this._value instanceof s},a.prototype.is_zero=function(){return this._value.equals(s.ZERO)},a.prototype._update=function(){},a.prototype.parse_generic=function(t){switch(o.accounts&&t in o.accounts&&(t=o.accounts[t].account),t){case void 0:case"0":case this.constructor.STR_ZERO:case this.constructor.ACCOUNT_ZERO:case this.constructor.HEX_ZERO:this._value=s.valueOf();break;case"1":case this.constructor.STR_ONE:case this.constructor.ACCOUNT_ONE:case this.constructor.HEX_ONE:this._value=new s([1]);break;default:this._value="string"!=typeof t?0/0:this.constructor.width===t.length?new s(n.stringToArray(t),256):2*this.constructor.width===t.length?new s(t,16):0/0}return this._update(),this},a.prototype.parse_hex=function(t){return this._value="string"==typeof t&&t.length===2*this.constructor.width?new s(t,16):0/0,this._update(),this},a.prototype.parse_bits=function(t){if(i.bitArray.bitLength(t)!==8*this.constructor.width)this._value=0/0;else{var e=i.codec.bytes.fromBits(t);this.parse_bytes(e)}return this._update(),this},a.prototype.parse_bytes=function(t){return this._value=Array.isArray(t)&&t.length===this.constructor.width?new s([0].concat(t),256):0/0,this._update(),this},a.prototype.parse_json=a.prototype.parse_hex,a.prototype.parse_bn=function(t){if(t instanceof i.bn&&t.bitLength()<=8*this.constructor.width){var e=i.codec.bytes.fromBits(t.toBits());this._value=new s(e,256)}else this._value=0/0;return this._update(),this},a.prototype.parse_number=function(t){return this._value=0/0,"number"==typeof t&&isFinite(t)&&t>=0&&(this._value=new s(String(t))),this._update(),this},a.prototype.to_bytes=function(){if(!(this._value instanceof s))return null;var t=this._value.toByteArray();t=t.map(function(t){return(t+256)%256});var e=this.constructor.width;for(t=t.slice(-e);t.lengthe;e++)s.random.addEntropy(Math.random(),32,"Math.random()");return s.random.randomWords(t)}var s=r(17).sjcl,a=r(7).Base,u=r(11).Seed,c=r(9).UInt160,f=r(10).UInt256,h=r(62),l=(r(51),r(46)),p=(r(45),{}),d={cipher:"aes",mode:"ccm",ts:64,ks:256,iter:1e3};p.derive=function(t,e,r,o,a){var u;u="login"===e?["id","crypt"]:["unlock"];var c=new s.bn(String(t.exponent)),f=new s.bn(String(t.modulus)),l=new s.bn(String(t.alpha)),p=["PAKDF_1_0_0",t.host.length,t.host,r.length,r,e.length,e].join(":")+":",d=Math.ceil(Math.min(7+f.bitLength()>>>3,256)/8),_=n(p,d),y=s.codec.hex.fromBits(_),v=new s.bn(String(y)).setBitM(0),m=[p,o.length,o].join(":")+":",g=7+f.bitLength()>>>3,b=n(m,g),w=s.codec.hex.fromBits(b),E=new s.bn(String(w)).mod(f);1!==E.jacobi(f)&&(E=E.mul(l).mod(f));for(var x;x=s.bn.random(f,0),1!==x.jacobi(f););var A=x.powermodMontgomery(v.mul(c),f),S=E.mulmod(A,f),T=s.codec.hex.fromBits(S.toBits());h.post(t.url).send({info:p,signreq:T}).end(function(e,r){if(e||!r)return a(new Error("Could not query PAKDF server "+t.host));var n=r.body||r.text?JSON.parse(r.text):{};if("success"!==n.result)return a(new Error("Could not query PAKDF server "+t.host));var o=new s.bn(String(n.signres)),c=x.inverseMod(f),h=o.mulmod(c,f),l=h.toBits(),p={};u.forEach(function(t){p[t]=i(l,t)}),a(null,p)})},p.encrypt=function(t,e){t=s.codec.hex.toBits(t);var r=l(!0,{},d),n=JSON.parse(s.encrypt(t,e,r)),i=[s.bitArray.partial(8,0)],o=s.codec.base64.toBits(n.iv),a=s.codec.base64.toBits(n.ct),u=s.bitArray.concat(i,o);return u=s.bitArray.concat(u,a),s.codec.base64.fromBits(u)},p.decrypt=function(t,e){t=s.codec.hex.toBits(t);var r=s.codec.base64.toBits(e),n=s.bitArray.extract(r,0,8);if(0!==n)throw new Error("Unsupported encryption version: "+n);var i=l(!0,{},d,{iv:s.codec.base64.fromBits(s.bitArray.bitSlice(r,8,136)),ct:s.codec.base64.fromBits(s.bitArray.bitSlice(r,136))});return s.decrypt(t,JSON.stringify(i))},p.isValidAddress=function(t){return c.is_valid(t)},p.createSecret=function(t){return s.codec.hex.fromBits(o(t))},p.createMaster=function(){return a.encode_check(33,s.codec.bytes.fromBits(o(4)))},p.getAddress=function(t){return u.from_json(t).get_key().get_address().to_json()},p.hashSha512=function(t){return s.codec.hex.fromBits(s.hash.sha512.hash(t))},p.hashSha512Half=function(t){return f.from_hex(p.hashSha512(t).substr(0,64))},p.signString=function(t,e){var r=new s.misc.hmac(s.codec.hex.toBits(t),s.hash.sha512);return s.codec.hex.fromBits(r.mac(e))},p.deriveRecoveryEncryptionKeyFromSecret=function(t){var e=u.from_json(t).to_bits(),r=new s.misc.hmac(e,s.hash.sha512),n=r.mac("ripple/hmac/recovery_encryption_key/v1");return n=s.bitArray.bitSlice(n,0,256),s.codec.hex.fromBits(n)},p.base64ToBase64Url=function(t){return t.replace(/\+/g,"-").replace(/\//g,"_").replace(/[=]+$/,"")},p.base64UrlToBase64=function(t){for(t=t.replace(/-/g,"+").replace(/_/g,"/");t.length%4;)t+="=";return t},p.decodeBase64=function(t){return s.codec.utf8String.fromBits(s.codec.base64.toBits(t))},e.Crypt=p},function(t,e,r){function n(){this.root=new o(0)}function i(){}function o(t){i.call(this),this.leaves={},this.type=i.INNER,this.depth=null==t?0:t,this.empty=!0}function s(t,e,r){if(i.call(this),"string"!=typeof t)throw new Error("Tag is unexpected type.");this.tag=t,this.tag_bytes=c.from_hex(this.tag).to_bytes(),this.type=r,this.node=e}var a=r(40),u=(r(17).sjcl,r(23),r(27)),c=r(10).UInt256,f=r(13).SerializedObject;n.prototype.add_item=function(t,e,r){var e=new s(t,e,r);this.root.add_item(t,e)},n.prototype.hash=function(){return this.root.hash()},i.TYPE_INNER=1,i.TYPE_TRANSACTION_NM=2,i.TYPE_TRANSACTION_MD=3,i.TYPE_ACCOUNT_STATE=4,i.prototype.add_item=function(){throw new Error("Called unimplemented virtual method SHAMapTreeNode#add_item.")},i.prototype.hash=function(){throw new Error("Called unimplemented virtual method SHAMapTreeNode#hash.")},a.inherits(o,i),o.prototype.add_item=function(t,e){var r=this.depth,n=this.get_node(t[r]);if(n)if(n instanceof o)n.add_item(t,e);else{if(n.tag===t)throw new Error("Tried to add a node to a SHAMap that was already in there.");var i=new o(r+1);i.add_item(n.tag,n),i.add_item(t,e),this.set_node(t[r],i)}else this.set_node(t[r],e)},o.prototype.set_node=function(t,e){this.leaves[t]=e,this.empty=!1},o.prototype.get_node=function(t){return this.leaves[t]},o.prototype.hash=function(){if(this.empty)return c.from_hex(c.HEX_ZERO);for(var t=new f,e=0;16>e;e++){var r=c.from_hex(c.HEX_ZERO),n=e.toString(16).toUpperCase();"object"==typeof this.leaves[n]&&(r=this.leaves[n].hash()),t.append(r.to_bytes())}var i=t.hash(u.HASH_INNER_NODE);return c.from_bits(i)},a.inherits(s,i),s.prototype.hash=function(){var t=new f;switch(this.type){case i.TYPE_ACCOUNT_STATE:return t.append(this.node),t.append(this.tag_bytes),t.hash(u.HASH_LEAF_NODE);case i.TYPE_TRANSACTION_NM:return this.tag_bytes;case i.TYPE_TRANSACTION_MD:return t.append(this.node),t.append(this.tag_bytes),t.hash(u.HASH_TX_NODE);default:throw new Error("Tried to hash a SHAMap node of unknown type.")}},e.SHAMap=n,e.SHAMapTreeNode=i,e.SHAMapTreeNodeInner=o,e.SHAMapTreeNodeLeaf=s},function(t){t.exports={account:"a",dirNode:"d",generatorMap:"g",nickname:"n",rippleState:"r",offer:"o",ownerDir:"O",bookDir:"B",contract:"c",skipList:"s",amendment:"f",feeSettings:"e"}},function(t,e,r){function n(t){var e,r=1;return 0!=(e=t>>>16)&&(t=e,r+=16),0!=(e=t>>8)&&(t=e,r+=8),0!=(e=t>>4)&&(t=e,r+=4),0!=(e=t>>2)&&(t=e,r+=2),0!=(e=t>>1)&&(t=e,r+=1),r}function i(t,e){var r=t.r.bitLength();return{r:f.bn.fromBits(f.bitArray.bitSlice(e,0,r)),s:f.bn.fromBits(f.bitArray.bitSlice(e,r,f.bitArray.bitLength(e)))}}function o(t,e,r,n,i){for(var o=i.toBits(),a=0;4>a;a++){var u;try{u=s(t,e,r,n,a)}catch(c){continue}if(f.bitArray.equal(u.toBits(),o))return a}throw new f.exception.bug("unable to calculate recovery factor from signature")}function s(t,e,r,n,i){var o=t.r,s=t.field.modulus;i=3&i;var u=1&i,c=i>>1;p||(p=s.add(1).div(4));var h;h=c?e.add(o):e;var l,d=h.mul(h).mul(h).add(t.a.mul(h)).add(t.b).mod(s),_=d.powermodMontgomery(p,s),y=_.mod(2).equals(0);l=y&&!u||!y&&u?_:s.sub(_);var v=new f.ecc.point(t,h,l);if(!v.isValidPoint())throw new f.exception.corrupt("point R. Not a valid point on the curve. Cannot recover public key");var m=f.bn.fromBits(n),g=new f.bn(0).sub(m).mod(o),b=e.inverseMod(o),w=v.mult2(r,g,t.G).mult(b);if(!w.isValidPoint())throw new f.exception.corrupt("public_key_point. Not a valid point on the curve. Cannot recover public key");if(!a(t,m,e,r,w))throw new f.exception.corrupt("cannot recover public key");return w}function a(t,e,r,n,i){var o=t.r;if(new f.bn(1).greaterEquals(r)||r.greaterEquals(new f.bn(o)))return!1;if(new f.bn(1).greaterEquals(n)||n.greaterEquals(new f.bn(o)))return!1;var s=n.inverseMod(o),a=e.mul(s).mod(o),u=r.mul(s).mod(o),c=t.G.mult2(a,u,i);return r.equals(c.x.mod(o))}var u,c,f={cipher:{},hash:{},keyexchange:{},mode:{},misc:{},codec:{},exception:{corrupt:function(t){this.toString=function(){return"CORRUPT: "+this.message},this.message=t},invalid:function(t){this.toString=function(){return"INVALID: "+this.message},this.message=t},bug:function(t){this.toString=function(){return"BUG: "+this.message},this.message=t},notReady:function(t){this.toString=function(){return"NOT READY: "+this.message},this.message=t}}};"undefined"!=typeof t&&t.exports&&(t.exports=f),u=[],c=function(){return f}.apply(null,u),!(void 0!==c&&(t.exports=c)),f.cipher.aes=function(t){this._tables[0][0][0]||this._precompute();var e,r,n,i,o,s=this._tables[0][4],a=this._tables[1],u=t.length,c=1;if(4!==u&&6!==u&&8!==u)throw new f.exception.invalid("invalid aes key size");for(this._key=[i=t.slice(0),o=[]],e=u;4*u+28>e;e++)n=i[e-1],(e%u===0||8===u&&e%u===4)&&(n=s[n>>>24]<<24^s[n>>16&255]<<16^s[n>>8&255]<<8^s[255&n],e%u===0&&(n=n<<8^n>>>24^c<<24,c=c<<1^283*(c>>7))),i[e]=i[e-u]^n;for(r=0;e;r++,e--)n=i[3&r?e:e-4],o[r]=4>=e||4>r?n:a[0][s[n>>>24]]^a[1][s[n>>16&255]]^a[2][s[n>>8&255]]^a[3][s[255&n]]},f.cipher.aes.prototype={encrypt:function(t){return this._crypt(t,0)},decrypt:function(t){return this._crypt(t,1)},_tables:[[[],[],[],[],[]],[[],[],[],[],[]]],_precompute:function(){var t,e,r,n,i,o,s,a,u,c=this._tables[0],f=this._tables[1],h=c[4],l=f[4],p=[],d=[];for(t=0;256>t;t++)d[(p[t]=t<<1^283*(t>>7))^t]=t;for(e=r=0;!h[e];e^=n||1,r=d[r]||1)for(s=r^r<<1^r<<2^r<<3^r<<4,s=s>>8^255&s^99,h[e]=s,l[s]=e,o=p[i=p[n=p[e]]],u=16843009*o^65537*i^257*n^16843008*e,a=257*p[s]^16843008*s,t=0;4>t;t++)c[t][e]=a=a<<24^a>>>8,f[t][s]=u=u<<24^u>>>8;for(t=0;5>t;t++)c[t]=c[t].slice(0),f[t]=f[t].slice(0)},_crypt:function(t,e){if(4!==t.length)throw new f.exception.invalid("invalid aes block size");var r,n,i,o,s=this._key[e],a=t[0]^s[0],u=t[e?3:1]^s[1],c=t[2]^s[2],h=t[e?1:3]^s[3],l=s.length/4-2,p=4,d=[0,0,0,0],_=this._tables[e],y=_[0],v=_[1],m=_[2],g=_[3],b=_[4];for(o=0;l>o;o++)r=y[a>>>24]^v[u>>16&255]^m[c>>8&255]^g[255&h]^s[p],n=y[u>>>24]^v[c>>16&255]^m[h>>8&255]^g[255&a]^s[p+1],i=y[c>>>24]^v[h>>16&255]^m[a>>8&255]^g[255&u]^s[p+2],h=y[h>>>24]^v[a>>16&255]^m[u>>8&255]^g[255&c]^s[p+3],p+=4,a=r,u=n,c=i;for(o=0;4>o;o++)d[e?3&-o:o]=b[a>>>24]<<24^b[u>>16&255]<<16^b[c>>8&255]<<8^b[255&h]^s[p++],r=a,a=u,u=c,c=h,h=r;return d}},f.bitArray={bitSlice:function(t,e,r){return t=f.bitArray._shiftRight(t.slice(e/32),32-(31&e)).slice(1),void 0===r?t:f.bitArray.clamp(t,r-e)},extract:function(t,e,r){var n,i=Math.floor(-e-r&31);return n=-32&(e+r-1^e)?t[e/32|0]<<32-i^t[e/32+1|0]>>>i:t[e/32|0]>>>i,n&(1<0&&e&&(t[r-1]=f.bitArray.partial(e,t[r-1]&2147483648>>e-1,1)),t},partial:function(t,e,r){return 32===t?e:(r?0|e:e<<32-t)+1099511627776*t},getPartial:function(t){return Math.round(t/1099511627776)||32},equal:function(t,e){if(f.bitArray.bitLength(t)!==f.bitArray.bitLength(e))return!1;var r,n=0;for(r=0;r=32;e-=32)n.push(r),r=0;if(0===e)return n.concat(t);for(i=0;i>>e),r=t[i]<<32-e;return s=t.length?t[t.length-1]:0,o=f.bitArray.getPartial(s),n.push(f.bitArray.partial(e+o&31,e+o>32?r:n.pop(),1)),n},_xor4:function(t,e){return[t[0]^e[0],t[1]^e[1],t[2]^e[2],t[3]^e[3]]},byteswapM:function(t){var e,r,n=65280;for(e=0;e>>24|r>>>8&n|(r&n)<<8|r<<24;return t}},f.codec.utf8String={fromBits:function(t){var e,r,n="",i=f.bitArray.bitLength(t);for(e=0;i/8>e;e++)0===(3&e)&&(r=t[e/4]),n+=String.fromCharCode(r>>>24),r<<=8;return decodeURIComponent(escape(n))},toBits:function(t){t=unescape(encodeURIComponent(t));var e,r=[],n=0;for(e=0;e>>o)>>>26),6>o?(a=t[n]<<6-o,o+=26,n++):(a<<=6,o-=6);for(;3&i.length&&!e;)i+="=";return i},toBits:function(t,e){t=t.replace(/\s|=/g,"");var r,n,i=[],o=0,s=f.codec.base64._chars,a=0;for(e&&(s=s.substr(0,62)+"-_"),r=0;rn)throw new f.exception.invalid("this isn't base64!");o>26?(o-=26,i.push(a^n>>>o),a=n<<32-o):(o+=6,a^=n<<32-o)}return 56&o&&i.push(f.bitArray.partial(56&o,a,1)),i}},f.codec.base64url={fromBits:function(t){return f.codec.base64.fromBits(t,1,1)},toBits:function(t){return f.codec.base64.toBits(t,1)}},f.codec.bytes={fromBits:function(t){var e,r,n=[],i=f.bitArray.bitLength(t);for(e=0;i/8>e;e++)0===(3&e)&&(r=t[e/4]),n.push(r>>>24),r<<=8;return n},toBits:function(t){var e,r=[],n=0;for(e=0;e=e;e+=512)this._block(r.splice(0,16));return this},finalize:function(){var t,e=this._buffer,r=this._h;for(e=f.bitArray.concat(e,[f.bitArray.partial(1,1)]),t=e.length+2;15&t;t++)e.push(0);for(e.push(Math.floor(this._length/4294967296)),e.push(0|this._length);e.length;)this._block(e.splice(0,16));return this.reset(),r},_init:[],_key:[],_precompute:function(){function t(t){return 4294967296*(t-Math.floor(t))|0}var e,r=0,n=2;t:for(;64>r;n++){for(e=2;n>=e*e;e++)if(n%e===0)continue t;8>r&&(this._init[r]=t(Math.pow(n,.5))),this._key[r]=t(Math.pow(n,1/3)),r++}},_block:function(t){var e,r,n,i,o=t.slice(0),s=this._h,a=this._key,u=s[0],c=s[1],f=s[2],h=s[3],l=s[4],p=s[5],d=s[6],_=s[7];for(e=0;64>e;e++)16>e?r=o[e]:(n=o[e+1&15],i=o[e+14&15],r=o[15&e]=(n>>>7^n>>>18^n>>>3^n<<25^n<<14)+(i>>>17^i>>>19^i>>>10^i<<15^i<<13)+o[15&e]+o[e+9&15]|0),r=r+_+(l>>>6^l>>>11^l>>>25^l<<26^l<<21^l<<7)+(d^l&(p^d))+a[e],_=d,d=p,p=l,l=h+r|0,h=f,f=c,c=u,u=r+(c&f^h&(c^f))+(c>>>2^c>>>13^c>>>22^c<<30^c<<19^c<<10)|0;s[0]=s[0]+u|0,s[1]=s[1]+c|0,s[2]=s[2]+f|0,s[3]=s[3]+h|0,s[4]=s[4]+l|0,s[5]=s[5]+p|0,s[6]=s[6]+d|0,s[7]=s[7]+_|0}},f.hash.sha512=function(t){this._key[0]||this._precompute(),t?(this._h=t._h.slice(0),this._buffer=t._buffer.slice(0),this._length=t._length):this.reset()},f.hash.sha512.hash=function(t){return(new f.hash.sha512).update(t).finalize()},f.hash.sha512.prototype={blockSize:1024,reset:function(){return this._h=this._init.slice(0),this._buffer=[],this._length=0,this},update:function(t){"string"==typeof t&&(t=f.codec.utf8String.toBits(t));var e,r=this._buffer=f.bitArray.concat(this._buffer,t),n=this._length,i=this._length=n+f.bitArray.bitLength(t);for(e=1024+n&-1024;i>=e;e+=1024)this._block(r.splice(0,32));return this},finalize:function(){var t,e=this._buffer,r=this._h;for(e=f.bitArray.concat(e,[f.bitArray.partial(1,1)]),t=e.length+4;31&t;t++)e.push(0);for(e.push(0),e.push(0),e.push(Math.floor(this._length/4294967296)),e.push(0|this._length);e.length;)this._block(e.splice(0,32));return this.reset(),r},_init:[],_initr:[12372232,13281083,9762859,1914609,15106769,4090911,4308331,8266105],_key:[],_keyr:[2666018,15689165,5061423,9034684,4764984,380953,1658779,7176472,197186,7368638,14987916,16757986,8096111,1480369,13046325,6891156,15813330,5187043,9229749,11312229,2818677,10937475,4324308,1135541,6741931,11809296,16458047,15666916,11046850,698149,229999,945776,13774844,2541862,12856045,9810911,11494366,7844520,15576806,8533307,15795044,4337665,16291729,5553712,15684120,6662416,7413802,12308920,13816008,4303699,9366425,10176680,13195875,4295371,6546291,11712675,15708924,1519456,15772530,6568428,6495784,8568297,13007125,7492395,2515356,12632583,14740254,7262584,1535930,13146278,16321966,1853211,294276,13051027,13221564,1051980,4080310,6651434,14088940,4675607],_precompute:function(){function t(t){return 4294967296*(t-Math.floor(t))|0}function e(t){return 1099511627776*(t-Math.floor(t))&255}var r,n=0,i=2;t:for(;80>n;i++){for(r=2;i>=r*r;r++)if(i%r===0)continue t;8>n&&(this._init[2*n]=t(Math.pow(i,.5)),this._init[2*n+1]=e(Math.pow(i,.5))<<24|this._initr[n]),this._key[2*n]=t(Math.pow(i,1/3)),this._key[2*n+1]=e(Math.pow(i,1/3))<<24|this._keyr[n],n++}},_block:function(t){var e,r,n,i=t.slice(0),o=this._h,s=this._key,a=o[0],u=o[1],c=o[2],f=o[3],h=o[4],l=o[5],p=o[6],d=o[7],_=o[8],y=o[9],v=o[10],m=o[11],g=o[12],b=o[13],w=o[14],E=o[15],x=a,A=u,S=c,T=f,k=h,I=l,j=p,C=d,B=_,L=y,R=v,O=m,D=g,N=b,q=w,M=E;for(e=0;80>e;e++){if(16>e)r=i[2*e],n=i[2*e+1];else{var F=i[2*(e-15)],P=i[2*(e-15)+1],U=(P<<31|F>>>1)^(P<<24|F>>>8)^F>>>7,z=(F<<31|P>>>1)^(F<<24|P>>>8)^(F<<25|P>>>7),H=i[2*(e-2)],G=i[2*(e-2)+1],V=(G<<13|H>>>19)^(H<<3|G>>>29)^H>>>6,K=(H<<13|G>>>19)^(G<<3|H>>>29)^(H<<26|G>>>6),X=i[2*(e-7)],Z=i[2*(e-7)+1],J=i[2*(e-16)],Y=i[2*(e-16)+1];n=z+Z,r=U+X+(z>>>0>n>>>0?1:0),n+=K,r+=V+(K>>>0>n>>>0?1:0),n+=Y,r+=J+(Y>>>0>n>>>0?1:0)}i[2*e]=r|=0,i[2*e+1]=n|=0;var $=B&R^~B&D,W=L&O^~L&N,Q=x&S^x&k^S&k,te=A&T^A&I^T&I,ee=(A<<4|x>>>28)^(x<<30|A>>>2)^(x<<25|A>>>7),re=(x<<4|A>>>28)^(A<<30|x>>>2)^(A<<25|x>>>7),ne=(L<<18|B>>>14)^(L<<14|B>>>18)^(B<<23|L>>>9),ie=(B<<18|L>>>14)^(B<<14|L>>>18)^(L<<23|B>>>9),oe=s[2*e],se=s[2*e+1],ae=M+ie,ue=q+ne+(M>>>0>ae>>>0?1:0);ae+=W,ue+=$+(W>>>0>ae>>>0?1:0),ae+=se,ue+=oe+(se>>>0>ae>>>0?1:0),ae=ae+n|0,ue+=r+(n>>>0>ae>>>0?1:0);var ce=re+te,fe=ee+Q+(re>>>0>ce>>>0?1:0);q=D,M=N,D=R,N=O,R=B,O=L,L=C+ae|0,B=j+ue+(C>>>0>L>>>0?1:0)|0,j=k,C=I,k=S,I=T,S=x,T=A,A=ae+ce|0,x=ue+fe+(ae>>>0>A>>>0?1:0)|0}u=o[1]=u+A|0,o[0]=a+x+(A>>>0>u>>>0?1:0)|0,f=o[3]=f+T|0,o[2]=c+S+(T>>>0>f>>>0?1:0)|0,l=o[5]=l+I|0,o[4]=h+k+(I>>>0>l>>>0?1:0)|0,d=o[7]=d+C|0,o[6]=p+j+(C>>>0>d>>>0?1:0)|0,y=o[9]=y+L|0,o[8]=_+B+(L>>>0>y>>>0?1:0)|0,m=o[11]=m+O|0,o[10]=v+R+(O>>>0>m>>>0?1:0)|0,b=o[13]=b+N|0,o[12]=g+D+(N>>>0>b>>>0?1:0)|0,E=o[15]=E+M|0,o[14]=w+q+(M>>>0>E>>>0?1:0)|0}},f.hash.sha1=function(t){t?(this._h=t._h.slice(0),this._buffer=t._buffer.slice(0),this._length=t._length):this.reset()},f.hash.sha1.hash=function(t){return(new f.hash.sha1).update(t).finalize()},f.hash.sha1.prototype={blockSize:512,reset:function(){return this._h=this._init.slice(0),this._buffer=[],this._length=0,this},update:function(t){"string"==typeof t&&(t=f.codec.utf8String.toBits(t));var e,r=this._buffer=f.bitArray.concat(this._buffer,t),n=this._length,i=this._length=n+f.bitArray.bitLength(t);for(e=this.blockSize+n&-this.blockSize;i>=e;e+=this.blockSize)this._block(r.splice(0,16));return this},finalize:function(){var t,e=this._buffer,r=this._h;for(e=f.bitArray.concat(e,[f.bitArray.partial(1,1)]),t=e.length+2;15&t;t++)e.push(0); for(e.push(Math.floor(this._length/4294967296)),e.push(0|this._length);e.length;)this._block(e.splice(0,16));return this.reset(),r},_init:[1732584193,4023233417,2562383102,271733878,3285377520],_key:[1518500249,1859775393,2400959708,3395469782],_f:function(t,e,r,n){return 19>=t?e&r|~e&n:39>=t?e^r^n:59>=t?e&r|e&n|r&n:79>=t?e^r^n:void 0},_S:function(t,e){return e<>>32-t},_block:function(t){var e,r,n,i,o,s,a,u=t.slice(0),c=this._h;for(n=c[0],i=c[1],o=c[2],s=c[3],a=c[4],e=0;79>=e;e++)e>=16&&(u[e]=this._S(1,u[e-3]^u[e-8]^u[e-14]^u[e-16])),r=this._S(5,n)+this._f(e,i,o,s)+a+u[e]+this._key[Math.floor(e/20)]|0,a=s,s=o,o=this._S(30,i),i=n,n=r;c[0]=c[0]+n|0,c[1]=c[1]+i|0,c[2]=c[2]+o|0,c[3]=c[3]+s|0,c[4]=c[4]+a|0}},f.mode.ccm={name:"ccm",encrypt:function(t,e,r,n,i){var o,s,a=e.slice(0),u=f.bitArray,c=u.bitLength(r)/8,h=u.bitLength(a)/8;if(i=i||64,n=n||[],7>c)throw new f.exception.invalid("ccm: iv must be at least 7 bytes");for(o=2;4>o&&h>>>8*o;o++);return 15-c>o&&(o=15-c),r=u.clamp(r,8*(15-o)),s=f.mode.ccm._computeTag(t,e,r,n,i,o),a=f.mode.ccm._ctrMode(t,a,r,s,i,o),u.concat(a.data,a.tag)},decrypt:function(t,e,r,n,i){i=i||64,n=n||[];var o,s,a=f.bitArray,u=a.bitLength(r)/8,c=a.bitLength(e),h=a.clamp(e,c-i),l=a.bitSlice(e,c-i);if(c=(c-i)/8,7>u)throw new f.exception.invalid("ccm: iv must be at least 7 bytes");for(o=2;4>o&&c>>>8*o;o++);if(15-u>o&&(o=15-u),r=a.clamp(r,8*(15-o)),h=f.mode.ccm._ctrMode(t,h,r,l,i,o),s=f.mode.ccm._computeTag(t,h.data,r,n,i,o),!a.equal(h.tag,s))throw new f.exception.corrupt("ccm: tag doesn't match");return h.data},_computeTag:function(t,e,r,n,i,o){var s,a,u,c=[],h=f.bitArray,l=h._xor4;if(i/=8,i%2||4>i||i>16)throw new f.exception.invalid("ccm: invalid tag length");if(n.length>4294967295||e.length>4294967295)throw new f.exception.bug("ccm: can't deal with 4GiB or more data");if(s=[h.partial(8,(n.length?64:0)|i-2<<2|o-1)],s=h.concat(s,r),s[3]|=h.bitLength(e)/8,s=t.encrypt(s),n.length)for(a=h.bitLength(n)/8,65279>=a?c=[h.partial(16,a)]:4294967295>=a&&(c=h.concat([h.partial(16,65534)],[a])),c=h.concat(c,n),u=0;ua;a+=4)u[3]++,s=t.encrypt(u),e[a]^=s[0],e[a+1]^=s[1],e[a+2]^=s[2],e[a+3]^=s[3];return{tag:n,data:c.clamp(e,p)}}},f.misc.hmac=function(t,e){this._hash=e=e||f.hash.sha256;var r,n=[[],[]],i=e.prototype.blockSize/32;for(this._baseHash=[new e,new e],t.length>i&&(t=e.hash(t)),r=0;i>r;r++)n[0][r]=909522486^t[r],n[1][r]=1549556828^t[r];this._baseHash[0].update(n[0]),this._baseHash[1].update(n[1]),this._resultHash=new e(this._baseHash[0])},f.misc.hmac.prototype.encrypt=f.misc.hmac.prototype.mac=function(t){if(this._updated)throw new f.exception.invalid("encrypt on already updated hmac called!");return this.update(t),this.digest(t)},f.misc.hmac.prototype.reset=function(){this._resultHash=new this._hash(this._baseHash[0]),this._updated=!1},f.misc.hmac.prototype.update=function(t){this._updated=!0,this._resultHash.update(t)},f.misc.hmac.prototype.digest=function(){var t=this._resultHash.finalize(),e=new this._hash(this._baseHash[1]).update(t).finalize();return this.reset(),e},f.misc.pbkdf2=function(t,e,r,n,i){if(r=r||1e3,0>n||0>r)throw f.exception.invalid("invalid params to pbkdf2");"string"==typeof t&&(t=f.codec.utf8String.toBits(t)),"string"==typeof e&&(e=f.codec.utf8String.toBits(e)),i=i||f.misc.hmac;var o,s,a,u,c,h=new i(t),l=[],p=f.bitArray;for(c=1;32*l.length<(n||1);c++){for(o=s=h.encrypt(p.concat(e,[c])),a=1;r>a;a++)for(s=h.encrypt(s),u=0;ur;r+=4)(r+1)%this._MAX_WORDS_PER_BURST===0&&this._gate(),n=this._gen4words(),i.push(n[0],n[1],n[2],n[3]);return this._gate(),i.slice(0,t)},setDefaultParanoia:function(t,e){if(0===t&&"Setting paranoia=0 will ruin your security; use it only for testing"!==e)throw"Setting paranoia=0 will ruin your security; use it only for testing";this._defaultParanoia=t},addEntropy:function(t,e,r){r=r||"user";var n,i,o,s,a=(new Date).valueOf(),u=this._robins[r],c=this.isReady(),h=0;switch(n=this._collectorIds[r],void 0===n&&(n=this._collectorIds[r]=this._collectorIdNext++),void 0===u&&(u=this._robins[r]=0),this._robins[r]=(this._robins[r]+1)%this._pools.length,typeof t){case"number":void 0===e&&(e=1),this._pools[u].update([n,this._eventId++,1,e,a,1,0|t]);break;case"object":if(s=Object.prototype.toString.call(t),"[object Uint32Array]"===s){for(o=[],i=0;i0;)e++,o>>>=1;this._pools[u].update([n,this._eventId++,2,e,a,t.length].concat(t))}break;case"string":void 0===e&&(e=t.length),this._pools[u].update([n,this._eventId++,3,e,a,t.length]),this._pools[u].update(t);break;default:h=1}if(h)throw new f.exception.bug("random: addEntropy only supports number, array of numbers or string");this._poolEntropy[u]+=e,this._poolStrength+=e,c===this._NOT_READY&&(this.isReady()!==this._NOT_READY&&this._fireEvent("seeded",Math.max(this._strength,this._poolStrength)),this._fireEvent("progress",this.getProgress()))},isReady:function(t){var e=this._PARANOIA_LEVELS[void 0!==t?t:this._defaultParanoia];return this._strength&&this._strength>=e?this._poolEntropy[0]>this._BITS_PER_RESEED&&(new Date).valueOf()>this._nextReseed?this._REQUIRES_RESEED|this._READY:this._READY:this._poolStrength>=e?this._REQUIRES_RESEED|this._NOT_READY:this._NOT_READY},getProgress:function(t){var e=this._PARANOIA_LEVELS[t?t:this._defaultParanoia];return this._strength>=e?1:this._poolStrength>e?1:this._poolStrength/e},startCollectors:function(){if(!this._collectorsStarted){if(this._eventListener={loadTimeCollector:this._bind(this._loadTimeCollector),mouseCollector:this._bind(this._mouseCollector),keyboardCollector:this._bind(this._keyboardCollector),accelerometerCollector:this._bind(this._accelerometerCollector),touchCollector:this._bind(this._touchCollector)},window.addEventListener)window.addEventListener("load",this._eventListener.loadTimeCollector,!1),window.addEventListener("mousemove",this._eventListener.mouseCollector,!1),window.addEventListener("keypress",this._eventListener.keyboardCollector,!1),window.addEventListener("devicemotion",this._eventListener.accelerometerCollector,!1),window.addEventListener("touchmove",this._eventListener.touchCollector,!1);else{if(!document.attachEvent)throw new f.exception.bug("can't attach event");document.attachEvent("onload",this._eventListener.loadTimeCollector),document.attachEvent("onmousemove",this._eventListener.mouseCollector),document.attachEvent("keypress",this._eventListener.keyboardCollector)}this._collectorsStarted=!0}},stopCollectors:function(){this._collectorsStarted&&(window.removeEventListener?(window.removeEventListener("load",this._eventListener.loadTimeCollector,!1),window.removeEventListener("mousemove",this._eventListener.mouseCollector,!1),window.removeEventListener("keypress",this._eventListener.keyboardCollector,!1),window.removeEventListener("devicemotion",this._eventListener.accelerometerCollector,!1),window.removeEventListener("touchmove",this._eventListener.touchCollector,!1)):document.detachEvent&&(document.detachEvent("onload",this._eventListener.loadTimeCollector),document.detachEvent("onmousemove",this._eventListener.mouseCollector),document.detachEvent("keypress",this._eventListener.keyboardCollector)),this._collectorsStarted=!1)},addEventListener:function(t,e){this._callbacks[t][this._callbackI++]=e},removeEventListener:function(t,e){var r,n,i=this._callbacks[t],o=[];for(n in i)i.hasOwnProperty(n)&&i[n]===e&&o.push(n);for(r=0;rt&&(this._counter[t]=this._counter[t]+1|0,!this._counter[t]);t++);return this._cipher.encrypt(this._counter)},_gate:function(){this._key=this._gen4words().concat(this._gen4words()),this._cipher=new f.cipher.aes(this._key)},_reseed:function(t){this._key=f.hash.sha256.hash(this._key.concat(t)),this._cipher=new f.cipher.aes(this._key);for(var e=0;4>e&&(this._counter[e]=this._counter[e]+1|0,!this._counter[e]);e++);},_reseedFromPools:function(t){var e,r=[],n=0;for(this._nextReseed=r[0]=(new Date).valueOf()+this._MILLISECONDS_PER_RESEED,e=0;16>e;e++)r.push(4294967296*Math.random()|0);for(e=0;e=1<this._strength&&(this._strength=n),this._reseedCount++,this._reseed(r)},_keyboardCollector:function(){this._addCurrentTimeToEntropy(1)},_mouseCollector:function(t){var e,r;try{e=t.x||t.clientX||t.offsetX||0,r=t.y||t.clientY||t.offsetY||0}catch(n){e=0,r=0}0!=e&&0!=r&&f.random.addEntropy([e,r],2,"mouse"),this._addCurrentTimeToEntropy(0)},_touchCollector:function(t){var e=t.touches[0]||t.changedTouches[0],r=e.pageX||e.clientX,n=e.pageY||e.clientY;f.random.addEntropy([r,n],1,"touch"),this._addCurrentTimeToEntropy(0)},_loadTimeCollector:function(){this._addCurrentTimeToEntropy(2)},_addCurrentTimeToEntropy:function(t){"undefined"!=typeof window&&window.performance&&"function"==typeof window.performance.now?f.random.addEntropy(window.performance.now(),t,"loadtime"):f.random.addEntropy((new Date).valueOf(),t,"loadtime")},_accelerometerCollector:function(t){var e=t.accelerationIncludingGravity.x||t.accelerationIncludingGravity.y||t.accelerationIncludingGravity.z;if(window.orientation){var r=window.orientation;"number"==typeof r&&f.random.addEntropy(r,1,"accelerometer")}e&&f.random.addEntropy(e,2,"accelerometer"),this._addCurrentTimeToEntropy(0)},_fireEvent:function(t,e){var r,n=f.random._callbacks[t],i=[];for(r in n)n.hasOwnProperty(r)&&i.push(n[r]);for(r=0;r4)throw new f.exception.invalid("json encrypt: invalid parameters");return"string"==typeof t?(i=f.misc.cachedPbkdf2(t,u),t=i.key.slice(0,u.ks/32),u.salt=i.salt):f.ecc&&t instanceof f.ecc.elGamal.publicKey&&(i=t.kem(),u.kemtag=i.tag,t=i.key.slice(0,u.ks/32)),"string"==typeof e&&(e=f.codec.utf8String.toBits(e)),"string"==typeof s&&(s=f.codec.utf8String.toBits(s)),o=new f.cipher[u.cipher](t),a._add(n,u),n.key=t,u.ct=f.mode[u.mode].encrypt(o,e,u.iv,s,u.ts),u},encrypt:function(){var t=f.json,e=t._encrypt.apply(t,arguments);return t.encode(e)},_decrypt:function(t,e,r,n){r=r||{},n=n||{};var i,o,s,a=f.json,u=a._add(a._add(a._add({},a.defaults),e),r,!0),c=u.adata;if("string"==typeof u.salt&&(u.salt=f.codec.base64.toBits(u.salt)),"string"==typeof u.iv&&(u.iv=f.codec.base64.toBits(u.iv)),!f.mode[u.mode]||!f.cipher[u.cipher]||"string"==typeof t&&u.iter<=100||64!==u.ts&&96!==u.ts&&128!==u.ts||128!==u.ks&&192!==u.ks&&256!==u.ks||!u.iv||u.iv.length<2||u.iv.length>4)throw new f.exception.invalid("json decrypt: invalid parameters");return"string"==typeof t?(o=f.misc.cachedPbkdf2(t,u),t=o.key.slice(0,u.ks/32),u.salt=o.salt):f.ecc&&t instanceof f.ecc.elGamal.secretKey&&(t=t.unkem(f.codec.base64.toBits(u.kemtag)).slice(0,u.ks/32)),"string"==typeof c&&(c=f.codec.utf8String.toBits(c)),s=new f.cipher[u.cipher](t),i=f.mode[u.mode].decrypt(s,u.ct,u.iv,c,u.ts),a._add(n,u),n.key=t,1===r.raw?i:f.codec.utf8String.fromBits(i)},decrypt:function(t,e,r,n){var i=f.json;return i._decrypt(t,i.decode(e),r,n)},encode:function(t){var e,r="{",n="";for(e in t)if(t.hasOwnProperty(e)){if(!e.match(/^[a-z0-9]+$/i))throw new f.exception.invalid("json encode: invalid property name");switch(r+=n+'"'+e+'":',n=",",typeof t[e]){case"number":case"boolean":r+=t[e];break;case"string":r+='"'+escape(t[e])+'"';break;case"object":r+='"'+f.codec.base64.fromBits(t[e],0)+'"';break;default:throw new f.exception.bug("json encode: unsupported type")}}return r+"}"},decode:function(t){if(t=t.replace(/\s/g,""),!t.match(/^\{.*\}$/))throw new f.exception.invalid("json decode: this isn't json!");var e,r,n=t.replace(/^\{|\}$/g,"").split(/,/),i={};for(e=0;e=this.limbs.length?0:this.limbs[t]},greaterEquals:function(t){"number"==typeof t&&(t=new this._class(t));var e,r,n,i=0,o=0;for(e=Math.max(this.limbs.length,t.limbs.length)-1;e>=0;e--)r=this.getLimb(e),n=t.getLimb(e),o|=n-r&~i,i|=r-n&~o;return(o|~i)>>>31},toString:function(){this.fullReduce();var t,e,r="",n=this.limbs;for(t=0;t>n;return r&&o.push(r),this},halveM:function(){var t,e,r=0,n=this.radix,i=this.limbs;for(t=i.length-1;t>=0;t--)e=i[t],i[t]=e+r>>1,r=(1&e)<0;n--)t.halveM(),r.greaterEquals(t)&&r.subM(t).normalize();return r.trim()},inverseMod:function(t){var e,r,n=new f.bn(1),i=new f.bn(0),o=new f.bn(this),s=new f.bn(t),a=1;if(!(1&t.limbs[0]))throw new f.exception.invalid("inverseMod: p must be odd");do for(1&o.limbs[0]&&(o.greaterEquals(s)||(e=o,o=s,s=e,e=n,n=i,i=e),o.subM(s),o.normalize(),n.greaterEquals(i)||n.addM(t),n.subM(i)),o.halveM(),1&n.limbs[0]&&n.addM(t),n.normalize(),n.halveM(),r=a=0;re;e++){for(n=i[e],r=0;a>r;r++)c[e+r]+=n*o[r];--f||(f=this.maxMul,u.cnormalize())}return u.cnormalize().reduce()},square:function(){return this.mul(this)},power:function(t){"number"==typeof t?t=[t]:void 0!==t.limbs&&(t=t.normalize().limbs);var e,r,n=new this._class(1),i=this;for(e=0;et||0!==n&&-1!==n;t++)e=(s[t]||0)+n,r=s[t]=e&u,n=(e-r)*o;return-1===n&&(s[t-1]-=i),this},cnormalize:function(){var t,e,r,n=0,i=this.ipv,o=this.limbs,s=o.length,a=this.radixMask;for(t=0;s-1>t;t++)e=o[t]+n,r=o[t]=e&a,n=(e-r)*i;return o[t]+=n,this},toBits:function(t){this.fullReduce(),t=t||this.exponent||this.bitLength();var e=Math.floor((t-1)/24),r=f.bitArray,n=(t+7&-8)%this.radix||this.radix,i=[r.partial(n,this.getLimb(e))];for(e--;e>=0;e--)i=r.concat(i,[r.partial(Math.min(this.radix,t),this.getLimb(e))]),t-=this.radix;return i},bitLength:function(){this.fullReduce();for(var t=this.radix*(this.limbs.length-1),e=this.limbs[this.limbs.length-1];e;e>>>=1)t++;return t+7&-8}},f.bn.fromBits=function(t){var e=this,r=new e,n=[],i=f.bitArray,o=this.prototype,s=Math.min(this.bitLength||4294967296,i.bitLength(t)),a=s%o.radix||o.radix;for(n[0]=i.extract(t,0,a);s>a;a+=o.radix)n.unshift(i.extract(t,a,o.radix));return r.limbs=n,r},f.bn.prototype.ipv=1/(f.bn.prototype.placeVal=Math.pow(2,f.bn.prototype.radix)),f.bn.prototype.radixMask=(1<i;){for(r=o.pop(),n=o.length,e=0;a>e;e++)o[n+s[e]]-=u[e]*r;t--,t||(o.push(0),this.cnormalize(),t=this.minOffset)}return this.cnormalize(),this},s._strongReduce=-1===s.fullMask?s.reduce:function(){var t,e,r=this.limbs,n=r.length-1;if(this.reduce(),n===this.modOffset-1){for(e=r[n]&this.fullMask,r[n]-=e,t=0;tn;n++)r[n]&=t.radixMask;if(s.limbs=r,!s.greaterEquals(t))return s}},f.ecc={},f.ecc.point=function(t,e,r){void 0===e?this.isIdentity=!0:(e instanceof f.bn&&(e=new t.field(e)),r instanceof f.bn&&(r=new t.field(r)),this.x=e,this.y=r,this.isIdentity=!1),this.curve=t},f.ecc.point.prototype={toJac:function(){return new f.ecc.pointJac(this.curve,this.x,this.y,new this.curve.field(1))},mult:function(t){return this.toJac().mult(t,this).toAffine()},mult2:function(t,e,r){return this.toJac().mult2(t,this,e,r).toAffine()},multiples:function(){var t,e,r;if(void 0===this._multiples)for(r=this.toJac().doubl(),t=this._multiples=[new f.ecc.point(this.curve),this,r.toAffine()],e=3;16>e;e++)r=r.add(this),t.push(r.toAffine());return this._multiples},isValid:function(){return this.y.square().equals(this.curve.b.add(this.x.mul(this.curve.a.add(this.x.square()))))},toBits:function(){return f.bitArray.concat(this.x.toBits(),this.y.toBits())}},f.ecc.pointJac=function(t,e,r,n){void 0===e?this.isIdentity=!0:(this.x=e,this.y=r,this.z=n,this.isIdentity=!1),this.curve=t},f.ecc.pointJac.prototype={add:function(t){var e,r,n,i,o,s,a,u,c,h,l,p=this;if(p.curve!==t.curve)throw"sjcl.ecc.add(): Points must be on the same curve to add them!";return p.isIdentity?t.toJac():t.isIdentity?p:(e=p.z.square(),r=t.x.mul(e).subM(p.x),r.equals(0)?p.y.equals(t.y.mul(e.mul(p.z)))?p.doubl():new f.ecc.pointJac(p.curve):(n=t.y.mul(e.mul(p.z)).subM(p.y),i=r.square(),o=n.square(),s=r.square().mul(r).addM(p.x.add(p.x).mul(i)),a=o.subM(s),u=p.x.mul(i).subM(a).mul(n),c=p.y.mul(r.square().mul(r)),h=u.subM(c),l=p.z.mul(r),new f.ecc.pointJac(this.curve,a,h,l)))},doubl:function(){if(this.isIdentity)return this;var t=this.y.square(),e=t.mul(this.x.mul(4)),r=t.square().mul(8),n=this.z.square(),i=this.curve.a.toString()==new f.bn(-3).toString()?this.x.sub(n).mul(3).mul(this.x.add(n)):this.x.square().mul(3).add(n.square().mul(this.curve.a)),o=i.square().subM(e).subM(e),s=e.sub(o).mul(i).subM(r),a=this.y.add(this.y).mul(this.z);return new f.ecc.pointJac(this.curve,o,s,a)},toAffine:function(){if(this.isIdentity||this.z.equals(0))return new f.ecc.point(this.curve);var t=this.z.inverse(),e=t.square();return new f.ecc.point(this.curve,this.x.mul(e).fullReduce(),this.y.mul(e.mul(t)).fullReduce())},mult:function(t,e){"number"==typeof t?t=[t]:void 0!==t.limbs&&(t=t.normalize().limbs);var r,n,i=new f.ecc.point(this.curve).toJac(),o=e.multiples();for(r=t.length-1;r>=0;r--)for(n=f.bn.prototype.radix-4;n>=0;n-=4)i=i.doubl().doubl().doubl().doubl().add(o[t[r]>>n&15]);return i},mult2:function(t,e,r,n){"number"==typeof t?t=[t]:void 0!==t.limbs&&(t=t.normalize().limbs),"number"==typeof r?r=[r]:void 0!==r.limbs&&(r=r.normalize().limbs);var i,o,s,a,u=new f.ecc.point(this.curve).toJac(),c=e.multiples(),h=n.multiples();for(i=Math.max(t.length,r.length)-1;i>=0;i--)for(s=0|t[i],a=0|r[i],o=f.bn.prototype.radix-4;o>=0;o-=4)u=u.doubl().doubl().doubl().doubl().add(c[s>>o&15]).add(h[a>>o&15]);return u},isValid:function(){var t=this.z.square(),e=t.square(),r=e.mul(t);return this.y.square().equals(this.curve.b.mul(r).add(this.x.mul(this.curve.a.mul(e).add(this.x.square()))))}},f.ecc.curve=function(t,e,r,n,i,o){this.field=t,this.r=new f.bn(e),this.a=new t(r),this.b=new t(n),this.G=new f.ecc.point(this,new t(i),new t(o))},f.ecc.curve.prototype.fromBits=function(t){var e=f.bitArray,r=this.field.prototype.exponent+7&-8,n=new f.ecc.point(this,this.field.fromBits(e.bitSlice(t,0,r)),this.field.fromBits(e.bitSlice(t,r,2*r)));if(!n.isValid())throw new f.exception.corrupt("not on the curve!");return n},f.ecc.curves={c192:new f.ecc.curve(f.bn.prime.p192,"0xffffffffffffffffffffffff99def836146bc9b1b4d22831",-3,"0x64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1","0x188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012","0x07192b95ffc8da78631011ed6b24cdd573f977a11e794811"),c224:new f.ecc.curve(f.bn.prime.p224,"0xffffffffffffffffffffffffffff16a2e0b8f03e13dd29455c5c2a3d",-3,"0xb4050a850c04b3abf54132565044b0b7d7bfd8ba270b39432355ffb4","0xb70e0cbd6bb4bf7f321390b94a03c1d356c21122343280d6115c1d21","0xbd376388b5f723fb4c22dfe6cd4375a05a07476444d5819985007e34"),c256:new f.ecc.curve(f.bn.prime.p256,"0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551",-3,"0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b","0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296","0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5"),c384:new f.ecc.curve(f.bn.prime.p384,"0xffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52973",-3,"0xb3312fa7e23ee7e4988e056be3f82d19181d9c6efe8141120314088f5013875ac656398d8a2ed19d2a85c8edd3ec2aef","0xaa87ca22be8b05378eb1c71ef320ad746e1d3b628ba79b9859f741e082542a385502f25dbf55296c3a545e3872760ab7","0x3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f"),k192:new f.ecc.curve(f.bn.prime.p192k,"0xfffffffffffffffffffffffe26f2fc170f69466a74defd8d",0,3,"0xdb4ff10ec057e9ae26b07d0280b7f4341da5d1b1eae06c7d","0x9b2f2f6d9c5628a7844163d015be86344082aa88d95e2f9d"),k224:new f.ecc.curve(f.bn.prime.p224k,"0x010000000000000000000000000001dce8d2ec6184caf0a971769fb1f7",0,5,"0xa1455b334df099df30fc28a169a467e9e47075a90f7e650eb6b7a45c","0x7e089fed7fba344282cafbd6f7e319f7c0b0bd59e2ca4bdb556d61a5"),k256:new f.ecc.curve(f.bn.prime.p256k,"0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141",0,7,"0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},f.ecc.basicKey={publicKey:function(t,e){this._curve=t,this._curveBitLength=t.r.bitLength(),this._point=e instanceof Array?t.fromBits(e):e,this.get=function(){var t=this._point.toBits(),e=f.bitArray.bitLength(t),r=f.bitArray.bitSlice(t,0,e/2),n=f.bitArray.bitSlice(t,e/2);return{x:r,y:n}}},secretKey:function(t,e){this._curve=t,this._curveBitLength=t.r.bitLength(),this._exponent=e,this.get=function(){return this._exponent.toBits()}}},f.ecc.basicKey.generateKeys=function(t){return function(e,r,n){if(e=e||256,"number"==typeof e&&(e=f.ecc.curves["c"+e],void 0===e))throw new f.exception.invalid("no such curve");n=n||f.bn.random(e.r,r);var i=e.G.mult(n);return{pub:new f.ecc[t].publicKey(e,i),sec:new f.ecc[t].secretKey(e,n)}}},f.ecc.elGamal={generateKeys:f.ecc.basicKey.generateKeys("elGamal"),publicKey:function(){f.ecc.basicKey.publicKey.apply(this,arguments)},secretKey:function(){f.ecc.basicKey.secretKey.apply(this,arguments)}},f.ecc.elGamal.publicKey.prototype={kem:function(t){var e=f.bn.random(this._curve.r,t),r=this._curve.G.mult(e).toBits(),n=f.hash.sha256.hash(this._point.mult(e).toBits());return{key:n,tag:r}}},f.ecc.elGamal.secretKey.prototype={unkem:function(t){return f.hash.sha256.hash(this._curve.fromBits(t).mult(this._exponent).toBits())},dh:function(t){return f.hash.sha256.hash(t._point.mult(this._exponent).toBits())},dhJavaEc:function(t){return t._point.mult(this._exponent).x.toBits()}},f.ecc.ecdsa={generateKeys:f.ecc.basicKey.generateKeys("ecdsa")},f.ecc.ecdsa.publicKey=function(){f.ecc.basicKey.publicKey.apply(this,arguments)},f.ecc.ecdsa.publicKey.prototype={verify:function(t,e,r){f.bitArray.bitLength(t)>this._curveBitLength&&(t=f.bitArray.clamp(t,this._curveBitLength));var n=f.bitArray,i=this._curve.r,o=this._curveBitLength,s=f.bn.fromBits(n.bitSlice(e,0,o)),a=f.bn.fromBits(n.bitSlice(e,o,2*o)),u=r?a:a.inverseMod(i),c=f.bn.fromBits(t).mul(u).mod(i),h=s.mul(u).mod(i),l=this._curve.G.mult2(c,h,this._point).x;if(s.equals(0)||a.equals(0)||s.greaterEquals(i)||a.greaterEquals(i)||!l.equals(s)){if(void 0===r)return this.verify(t,e,!0);throw new f.exception.corrupt("signature didn't check out")}return!0}},f.ecc.ecdsa.secretKey=function(){f.ecc.basicKey.secretKey.apply(this,arguments)},f.ecc.ecdsa.secretKey.prototype={sign:function(t,e,r,n){f.bitArray.bitLength(t)>this._curveBitLength&&(t=f.bitArray.clamp(t,this._curveBitLength));var i=this._curve.r,o=i.bitLength(),s=n||f.bn.random(i.sub(1),e).add(1),a=this._curve.G.mult(s).x.mod(i),u=f.bn.fromBits(t).add(a.mul(this._exponent)),c=r?u.inverseMod(i).mul(s).mod(i):u.mul(s.inverseMod(i)).mod(i);return f.bitArray.concat(a.toBits(o),c.toBits(o))}},f.keyexchange.srp={makeVerifier:function(t,e,r,n){var i;return i=f.keyexchange.srp.makeX(t,e,r),i=f.bn.fromBits(i),n.g.powermod(i,n.N)},makeX:function(t,e,r){var n=f.hash.sha1.hash(t+":"+e);return f.hash.sha1.hash(f.bitArray.concat(r,n))},knownGroup:function(t){return"string"!=typeof t&&(t=t.toString()),f.keyexchange.srp._didInitKnownGroups||f.keyexchange.srp._initKnownGroups(),f.keyexchange.srp._knownGroups[t]},_didInitKnownGroups:!1,_initKnownGroups:function(){var t,e,r;for(t=0;t>>32-e}function s(t){return(255&t)<<24|(65280&t)<<8|(t&255<<16)>>>8|(t&255<<24)>>>24}function a(s){for(var a,u=this._h[0],f=this._h[1],l=this._h[2],p=this._h[3],m=this._h[4],g=this._h[0],b=this._h[1],w=this._h[2],E=this._h[3],x=this._h[4],A=0;16>A;++A)a=o(u+t(f,l,p)+s[d[A]]+c[A],y[A])+m,u=m,m=p,p=o(l,10),l=f,f=a,a=o(g+i(b,w,E)+s[_[A]]+h[A],v[A])+x,g=x,x=E,E=o(w,10),w=b,b=a;for(;32>A;++A)a=o(u+e(f,l,p)+s[d[A]]+c[A],y[A])+m,u=m,m=p,p=o(l,10),l=f,f=a,a=o(g+n(b,w,E)+s[_[A]]+h[A],v[A])+x,g=x,x=E,E=o(w,10),w=b,b=a;for(;48>A;++A)a=o(u+r(f,l,p)+s[d[A]]+c[A],y[A])+m,u=m,m=p,p=o(l,10),l=f,f=a,a=o(g+r(b,w,E)+s[_[A]]+h[A],v[A])+x,g=x,x=E,E=o(w,10),w=b,b=a;for(;64>A;++A)a=o(u+n(f,l,p)+s[d[A]]+c[A],y[A])+m,u=m,m=p,p=o(l,10),l=f,f=a,a=o(g+e(b,w,E)+s[_[A]]+h[A],v[A])+x,g=x,x=E,E=o(w,10),w=b,b=a;for(;80>A;++A)a=o(u+i(f,l,p)+s[d[A]]+c[A],y[A])+m,u=m,m=p,p=o(l,10),l=f,f=a,a=o(g+t(b,w,E)+s[_[A]]+h[A],v[A])+x,g=x,x=E,E=o(w,10),w=b,b=a;a=this._h[1]+l+E,this._h[1]=this._h[2]+p+x,this._h[2]=this._h[3]+m+g,this._h[3]=this._h[4]+u+b,this._h[4]=this._h[0]+f+w,this._h[0]=a}f.hash.ripemd160=function(t){t?(this._h=t._h.slice(0),this._buffer=t._buffer.slice(0),this._length=t._length):this.reset()},f.hash.ripemd160.hash=function(t){return(new f.hash.ripemd160).update(t).finalize()},f.hash.ripemd160.prototype={reset:function(){return this._h=u.slice(0),this._buffer=[],this._length=0,this},update:function(t){"string"==typeof t&&(t=f.codec.utf8String.toBits(t));var e,r=this._buffer=f.bitArray.concat(this._buffer,t),n=this._length,i=this._length=n+f.bitArray.bitLength(t);for(e=512+n&-512;i>=e;e+=512){for(var o=r.splice(0,16),u=0;16>u;++u)o[u]=s(o[u]);a.call(this,o)}return this},finalize:function(){var t=f.bitArray.concat(this._buffer,[f.bitArray.partial(1,1)]),e=(this._length+1)%512,r=(e>448?512:448)-e%448,n=r%32;for(n>0&&(t=f.bitArray.concat(t,[f.bitArray.partial(n,0)]));r>=32;r-=32)t.push(0);for(t.push(s(0|this._length)),t.push(s(Math.floor(this._length/4294967296)));t.length;){for(var i=t.splice(0,16),o=0;16>o;++o)i[o]=s(i[o]);a.call(this,i)}var u=this._h;this.reset();for(var o=0;5>o;++o)u[o]=s(u[o]);return u}};for(var u=[1732584193,4023233417,2562383102,271733878,3285377520],c=[0,1518500249,1859775393,2400959708,2840853838],h=[1352829926,1548603684,1836072691,2053994217,0],l=4;l>=0;--l)for(var p=1;16>p;++p)c.splice(l,0,c[l]),h.splice(l,0,h[l]);var d=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],_=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],y=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],v=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]}(),f.bn.ZERO=new f.bn(0),f.bn.prototype.divRem=function(t){"object"!=typeof t&&(t=new this._class(t));var e=this.abs(),r=t.abs(),n=new this._class(0),i=0;if(!e.greaterEquals(r))return[new f.bn(0),this.copy()];if(e.equals(r))return[new f.bn(1),new f.bn(0)];for(;e.greaterEquals(r);i++)r.doubleM();for(;i>0;i--)n.doubleM(),r.halveM(),e.greaterEquals(r)&&(n.addM(1),e.subM(t).normalize());return[n,e]},f.bn.prototype.divRound=function(t){var e=this.divRem(t),r=e[0],n=e[1];return n.doubleM().greaterEquals(t)&&r.addM(1),r},f.bn.prototype.div=function(t){var e=this.divRem(t);return e[0]},f.bn.prototype.sign=function(){return this.greaterEquals(f.bn.ZERO)?1:-1},f.bn.prototype.neg=function(){return f.bn.ZERO.sub(this)},f.bn.prototype.abs=function(){return-1===this.sign()?this.neg():this},f.bn.prototype.shiftRight=function(t){if("number"!=typeof t)throw new Error("shiftRight expects a number");if(t=+t,0>t)return this.shiftLeft(t);for(var e=new f.bn(this);t>=this.radix;)e.limbs.shift(),t-=this.radix;for(;t--;)e.halveM();return e},f.bn.prototype.shiftLeft=function(t){if("number"!=typeof t)throw new Error("shiftLeft expects a number");if(t=+t,0>t)return this.shiftRight(t);for(var e=new f.bn(this);t>=this.radix;)e.limbs.unshift(0),t-=this.radix;for(;t--;)e.doubleM();return e},f.bn.prototype.toNumber=function(){return 0|this.limbs[0]},f.bn.prototype.testBit=function(t){var e=Math.floor(t/this.radix),r=t%this.radix;return e>=this.limbs.length?0:this.limbs[e]>>>r&1},f.bn.prototype.setBitM=function(t){for(var e=Math.floor(t/this.radix),r=t%this.radix;e>=this.limbs.length;)this.limbs.push(0);return this.limbs[e]|=1<0?t-r:-r},f.bn.prototype.am=function(t,e,r,n,i,o){for(var s=4095&e,a=e>>12;--o>=0;){var u=4095&this.limbs[t],c=this.limbs[t++]>>12,f=a*u+c*s;u=s*u+((4095&f)<<12)+r.limbs[n]+i,i=(u>>24)+(f>>12)+a*c,r.limbs[n++]=16777215&u}return i};var l=function(t){this.m=t,this.mt=t.limbs.length,this.mt2=2*this.mt,this.mp=t.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<>15)*this.mpl&this.um)<<15)&t.radixMask;for(n=r+this.mt,t.limbs[n]+=this.m.am(0,i,t,r,0,this.mt);t.limbs[n]>=e;)t.limbs[n]-=e,t.limbs[++n]++}return t.trim(),t=t.shiftRight(this.mt*this.m.radix),t.greaterEquals(this.m)&&(t=t.sub(this.m)),t.trim().normalize().reduce()},l.prototype.square=function(t){return this.reduce(t.square())},l.prototype.multiply=function(t,e){return this.reduce(t.mul(e))},l.prototype.convert=function(t){return t.abs().shiftLeft(this.mt*this.m.radix).mod(this.m)},l.prototype.revert=function(t){return this.reduce(t.copy())},f.bn.prototype.powermodMontgomery=function(t,e){var r,i=t.bitLength(),o=new this._class(1);if(0>=i)return o;if(r=18>i?1:48>i?3:144>i?4:768>i?5:6,8>i||!e.testBit(0))return this.powermod(t,e);var s=new l(e);t.trim().normalize();var a=new Array,u=3,c=r-1,f=(1<1)for(var h=s.square(a[1]);f>=u;)a[u]=s.multiply(h,a[u-2]),u+=2;var p,d,_=t.limbs.length-1,y=!0,v=new this._class;for(i=n(t.limbs[_])-1;_>=0;){for(i>=c?p=t.limbs[_]>>i-c&f:(p=(t.limbs[_]&(1<0&&(p|=t.limbs[_-1]>>this.radix+i-c)),u=r;0==(1&p);)p>>=1,--u;if((i-=u)<0&&(i+=this.radix,--_),y)o=a[p].copy(),y=!1;else{for(;u>1;)v=s.square(o),o=s.square(v),u-=2;u>0?v=s.square(o):(d=o,o=v,v=d),o=s.multiply(v,a[p])}for(;_>=0&&0==(t.limbs[_]&1<0&&"number"==typeof r[0]?r:"string"==typeof r&&/^[0-9a-fA-F]+$/.test(r)?f.bn.fromBits(f.codec.hex.toBits(r)):f.bn.random(i.sub(1),e).add(1);var s=this._curve.G.mult(n).x.mod(i),a=f.bn.fromBits(t).add(s.mul(this._exponent)).mul(n.inverseMod(i)).mod(i);return f.bitArray.concat(s.toBits(o),a.toBits(o))},f.ecc.ecdsa.publicKey.prototype.verify=function(t,e){var r=f.bitArray,n=this._curve.r,i=n.bitLength(),o=f.bn.fromBits(r.bitSlice(e,0,i)),s=f.bn.fromBits(r.bitSlice(e,i,2*i)),a=s.inverseMod(n),u=f.bn.fromBits(t).mul(a).mod(n),c=o.mul(a).mod(n),h=this._curve.G.mult2(u,c,this._point).x;if(o.equals(0)||s.equals(0)||o.greaterEquals(n)||s.greaterEquals(n)||!h.equals(o))throw new f.exception.corrupt("signature didn't check out");return!0},f.ecc.ecdsa.secretKey.prototype.canonicalizeSignature=function(t){var e=f.bitArray,r=this._curve.r,n=r.bitLength(),i=f.bn.fromBits(e.bitSlice(t,0,n)),o=f.bn.fromBits(e.bitSlice(t,n,2*n));return r.copy().halveM().greaterEquals(o)||(o=r.sub(o)),e.concat(i.toBits(n),o.toBits(n))},f.ecc.ecdsa.secretKey.prototype.signDER=function(t,e){return this.encodeDER(this.sign(t,e))},f.ecc.ecdsa.secretKey.prototype.encodeDER=function(t){for(var e=f.bitArray,r=this._curve.r,n=r.bitLength(),i=f.codec.bytes.fromBits(e.bitSlice(t,0,n)),o=f.codec.bytes.fromBits(e.bitSlice(t,n,2*n));!i[0]&&i.length;)i.shift();for(;!o[0]&&o.length;)o.shift();128&i[0]&&i.unshift(0),128&o[0]&&o.unshift(0);var s=[].concat(48,4+i.length+o.length,2,i.length,i,2,o.length,o);return f.codec.bytes.toBits(s)};var p;f.ecc.ecdsa.secretKey.prototype.signWithRecoverablePublicKey=function(t,e,r){var n,s=this;if(!("object"==typeof t&&t.length>0&&"number"==typeof t[0]))throw new f.exception.invalid("hash. Must be a bitArray");n=t;var a=s.sign(n,e,r),u=s.canonicalizeSignature(a),c=i(s._curve,u),h=s._curve.G.mult(f.bn.fromBits(s.get())),l=o(s._curve,c.r,c.s,n,h),p=l+27,d=f.bitArray.concat([p],u);return d},f.ecc.ecdsa.publicKey.recoverFromSignature=function(t,e,r){if(!e||e instanceof f.ecc.curve)throw new f.exception.invalid("must supply hash and signature to recover public key");r||(r=f.ecc.curves.k256);var n;if(!("object"==typeof t&&t.length>0&&"number"==typeof t[0]))throw new f.exception.invalid("hash. Must be a bitArray");n=t;var o;if(!("object"==typeof e&&e.length>0&&"number"==typeof e[0]))throw new f.exception.invalid("signature. Must be a bitArray");o=e;var a=o[0]-27;if(0>a||a>3)throw new f.exception.invalid("signature. Signature must be generated with algorithm that prepends the recovery factor in order to recover the public key");var u=i(r,o.slice(1)),c=u.r,h=u.s,l=s(r,c,h,n,a),p=new f.ecc.ecdsa.publicKey(r,l);return p},f.bn.prototype.jacobi=function(t){var e=this;if(t=new f.bn(t),-1!==t.sign()){if(e.equals(0))return 0;if(e.equals(1))return 1;for(var r=0,n=0;!e.testBit(n);)n++;var i=e.shiftRight(n);if(0===(1&n))r=1;else{var o=t.modInt(8);1===o||7===o?r=1:(3===o||5===o)&&(r=-1)}return 3===t.modInt(4)&&3===i.modInt(4)&&(r=-r),i.equals(1)?r:r*t.mod(i).jacobi(i)}}},function(t,e){function r(t,e,r){null!=t&&("number"==typeof t?this.fromNumber(t,e,r):null==e&&"string"!=typeof t?this.fromString(t,256):this.fromString(t,e))}function n(){return new r(null)}function i(t,e,r,n,i,o){for(;--o>=0;){var s=e*this[t++]+r[n]+i;i=Math.floor(s/67108864),r[n++]=67108863&s}return i}function o(t,e,r,n,i,o){for(var s=32767&e,a=e>>15;--o>=0;){var u=32767&this[t],c=this[t++]>>15,f=a*u+c*s;u=s*u+((32767&f)<<15)+r[n]+(1073741823&i),i=(u>>>30)+(f>>>15)+a*c+(i>>>30),r[n++]=1073741823&u}return i}function s(t,e,r,n,i,o){for(var s=16383&e,a=e>>14;--o>=0;){var u=16383&this[t],c=this[t++]>>14,f=a*u+c*s;u=s*u+((16383&f)<<14)+r[n]+i,i=(u>>28)+(f>>14)+a*c,r[n++]=268435455&u}return i}function a(t){return sr.charAt(t)}function u(t,e){var r=ar[t.charCodeAt(e)];return null==r?-1:r}function c(t){for(var e=this.t-1;e>=0;--e)t[e]=this[e];t.t=this.t,t.s=this.s}function f(t){this.t=1,this.s=0>t?-1:0,t>0?this[0]=t:-1>t?this[0]=t+this.DV:this.t=0}function h(t){var e=n();return e.fromInt(t),e}function l(t,e){var n;if(16==e)n=4;else if(8==e)n=3;else if(256==e)n=8;else if(2==e)n=1;else if(32==e)n=5;else{if(4!=e)return this.fromRadix(t,e),void 0;n=2}this.t=0,this.s=0;for(var i=t.length,o=!1,s=0;--i>=0;){var a=8==n?255&t[i]:u(t,i);0>a?"-"==t.charAt(i)&&(o=!0):(o=!1,0==s?this[this.t++]=a:s+n>this.DB?(this[this.t-1]|=(a&(1<>this.DB-s):this[this.t-1]|=a<=this.DB&&(s-=this.DB))}8==n&&0!=(128&t[0])&&(this.s=-1,s>0&&(this[this.t-1]|=(1<0&&this[this.t-1]==t;)--this.t}function d(t){if(this.s<0)return"-"+this.negate().toString(t);var e;if(16==t)e=4;else if(8==t)e=3;else if(2==t)e=1;else if(32==t)e=5;else{if(4!=t)return this.toRadix(t);e=2}var r,n=(1<0)for(u>u)>0&&(i=!0,o=a(r));s>=0;)e>u?(r=(this[s]&(1<>(u+=this.DB-e)):(r=this[s]>>(u-=e)&n,0>=u&&(u+=this.DB,--s)),r>0&&(i=!0),i&&(o+=a(r));return i?o:"0"}function _(){var t=n();return r.ZERO.subTo(this,t),t}function y(){return this.s<0?this.negate():this}function v(t){var e=this.s-t.s;if(0!=e)return e;var r=this.t;if(e=r-t.t,0!=e)return this.s<0?-e:e;for(;--r>=0;)if(0!=(e=this[r]-t[r]))return e;return 0}function m(t){var e,r=1;return 0!=(e=t>>>16)&&(t=e,r+=16),0!=(e=t>>8)&&(t=e,r+=8),0!=(e=t>>4)&&(t=e,r+=4),0!=(e=t>>2)&&(t=e,r+=2),0!=(e=t>>1)&&(t=e,r+=1),r}function g(){return this.t<=0?0:this.DB*(this.t-1)+m(this[this.t-1]^this.s&this.DM)}function b(t,e){var r;for(r=this.t-1;r>=0;--r)e[r+t]=this[r];for(r=t-1;r>=0;--r)e[r]=0;e.t=this.t+t,e.s=this.s}function w(t,e){for(var r=t;r=0;--r)e[r+s+1]=this[r]>>i|a,a=(this[r]&o)<=0;--r)e[r]=0;e[s]=a,e.t=this.t+s+1,e.s=this.s,e.clamp()}function x(t,e){e.s=this.s;var r=Math.floor(t/this.DB);if(r>=this.t)return e.t=0,void 0;var n=t%this.DB,i=this.DB-n,o=(1<>n;for(var s=r+1;s>n;n>0&&(e[this.t-r-1]|=(this.s&o)<r;)n+=this[r]-t[r],e[r++]=n&this.DM,n>>=this.DB;if(t.t>=this.DB;n+=this.s}else{for(n+=this.s;r>=this.DB;n-=t.s}e.s=0>n?-1:0,-1>n?e[r++]=this.DV+n:n>0&&(e[r++]=n),e.t=r,e.clamp()}function S(t,e){var n=this.abs(),i=t.abs(),o=n.t;for(e.t=o+i.t;--o>=0;)e[o]=0;for(o=0;o=0;)t[r]=0;for(r=0;r=e.DV&&(t[r+e.t]-=e.DV,t[r+e.t+1]=1)}t.t>0&&(t[t.t-1]+=e.am(r,e[r],t,2*r,0,1)),t.s=0,t.clamp()}function k(t,e,i){var o=t.abs();if(!(o.t<=0)){var s=this.abs();if(s.t0?(o.lShiftTo(f,a),s.lShiftTo(f,i)):(o.copyTo(a),s.copyTo(i));var h=a.t,l=a[h-1];if(0!=l){var p=l*(1<1?a[h-2]>>this.F2:0),d=this.FV/p,_=(1<=0&&(i[i.t++]=1,i.subTo(b,i)),r.ONE.dlShiftTo(h,b),b.subTo(a,a);a.t=0;){var w=i[--v]==l?this.DM:Math.floor(i[v]*d+(i[v-1]+y)*_);if((i[v]+=a.am(0,w,i,g,0,h))0&&i.rShiftTo(f,i),0>u&&r.ZERO.subTo(i,i)}}}function I(t){var e=n();return this.abs().divRemTo(t,null,e),this.s<0&&e.compareTo(r.ZERO)>0&&t.subTo(e,e),e}function j(t){this.m=t}function C(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t}function B(t){return t}function L(t){t.divRemTo(this.m,null,t)}function R(t,e,r){t.multiplyTo(e,r),this.reduce(r)}function O(t,e){t.squareTo(e),this.reduce(e)}function D(){if(this.t<1)return 0;var t=this[0];if(0==(1&t))return 0;var e=3&t;return e=e*(2-(15&t)*e)&15,e=e*(2-(255&t)*e)&255,e=e*(2-((65535&t)*e&65535))&65535,e=e*(2-t*e%this.DV)%this.DV,e>0?this.DV-e:-e}function N(t){this.m=t,this.mp=t.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<0&&this.m.subTo(e,e),e}function M(t){var e=n();return t.copyTo(e),this.reduce(e),e}function F(t){for(;t.t<=this.mt2;)t[t.t++]=0;for(var e=0;e>15)*this.mpl&this.um)<<15)&t.DM;for(r=e+this.m.t,t[r]+=this.m.am(0,n,t,e,0,this.m.t);t[r]>=t.DV;)t[r]-=t.DV,t[++r]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)}function P(t,e){t.squareTo(e),this.reduce(e)}function U(t,e,r){t.multiplyTo(e,r),this.reduce(r)}function z(){return 0==(this.t>0?1&this[0]:this.s)}function H(t,e){if(t>4294967295||1>t)return r.ONE;var i=n(),o=n(),s=e.convert(this),a=m(t)-1;for(s.copyTo(i);--a>=0;)if(e.sqrTo(i,o),(t&1<0)e.mulTo(o,s,i);else{var u=i;i=o,o=u}return e.revert(i)}function G(t,e){var r;return r=256>t||e.isEven()?new j(e):new N(e),this.exp(t,r)}function V(){var t=n();return this.copyTo(t),t}function K(){if(this.s<0){if(1==this.t)return this[0]-this.DV;if(0==this.t)return-1}else{if(1==this.t)return this[0];if(0==this.t)return 0}return(this[1]&(1<<32-this.DB)-1)<>24}function Z(){return 0==this.t?this.s:this[0]<<16>>16}function J(t){return Math.floor(Math.LN2*this.DB/Math.log(t))}function Y(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1}function $(t){if(null==t&&(t=10),0==this.signum()||2>t||t>36)return"0";var e=this.chunkSize(t),r=Math.pow(t,e),i=h(r),o=n(),s=n(),a="";for(this.divRemTo(i,o,s);o.signum()>0;)a=(r+s.intValue()).toString(t).substr(1)+a,o.divRemTo(i,o,s);return s.intValue().toString(t)+a}function W(t,e){this.fromInt(0),null==e&&(e=10);for(var n=this.chunkSize(e),i=Math.pow(e,n),o=!1,s=0,a=0,c=0;cf?"-"==t.charAt(c)&&0==this.signum()&&(o=!0):(a=e*a+f,++s>=n&&(this.dMultiply(i),this.dAddOffset(a,0),s=0,a=0))}s>0&&(this.dMultiply(Math.pow(e,s)),this.dAddOffset(a,0)),o&&r.ZERO.subTo(this,this)}function Q(t,e,n){if("number"==typeof e)if(2>t)this.fromInt(1);else for(this.fromNumber(t,n),this.testBit(t-1)||this.bitwiseTo(r.ONE.shiftLeft(t-1),ae,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(e);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo(r.ONE.shiftLeft(t-1),this);else{var i=new Array,o=7&t;i.length=(t>>3)+1,e.nextBytes(i),o>0?i[0]&=(1<0)for(n>n)!=(this.s&this.DM)>>n&&(e[i++]=r|this.s<=0;)8>n?(r=(this[t]&(1<>(n+=this.DB-8)):(r=this[t]>>(n-=8)&255,0>=n&&(n+=this.DB,--t)),0!=(128&r)&&(r|=-256),0==i&&(128&this.s)!=(128&r)&&++i,(i>0||r!=this.s)&&(e[i++]=r);return e}function ee(t){return 0==this.compareTo(t)}function re(t){return this.compareTo(t)<0?this:t}function ne(t){return this.compareTo(t)>0?this:t}function ie(t,e,r){var n,i,o=Math.min(t.t,this.t);for(n=0;o>n;++n)r[n]=e(this[n],t[n]);if(t.tt?this.rShiftTo(-t,e):this.lShiftTo(t,e),e}function _e(t){var e=n();return 0>t?this.lShiftTo(-t,e):this.rShiftTo(t,e),e}function ye(t){if(0==t)return-1;var e=0;return 0==(65535&t)&&(t>>=16,e+=16),0==(255&t)&&(t>>=8,e+=8),0==(15&t)&&(t>>=4,e+=4),0==(3&t)&&(t>>=2,e+=2),0==(1&t)&&++e,e}function ve(){for(var t=0;t=this.t?0!=this.s:0!=(this[e]&1<r;)n+=this[r]+t[r],e[r++]=n&this.DM,n>>=this.DB;if(t.t>=this.DB;n+=this.s}else{for(n+=this.s;r>=this.DB;n+=t.s}e.s=0>n?-1:0,n>0?e[r++]=n:-1>n&&(e[r++]=this.DV+n),e.t=r,e.clamp()}function Te(t){var e=n();return this.addTo(t,e),e}function ke(t){var e=n();return this.subTo(t,e),e}function Ie(t){var e=n();return this.multiplyTo(t,e),e}function je(){var t=n();return this.squareTo(t),t}function Ce(t){var e=n();return this.divRemTo(t,e,null),e}function Be(t){var e=n();return this.divRemTo(t,null,e),e}function Le(t){var e=n(),r=n();return this.divRemTo(t,e,r),new Array(e,r)}function Re(t){this[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()}function Oe(t,e){if(0!=t){for(;this.t<=e;)this[this.t++]=0;for(this[e]+=t;this[e]>=this.DV;)this[e]-=this.DV,++e>=this.t&&(this[this.t++]=0),++this[e]}}function De(){}function Ne(t){return t}function qe(t,e,r){t.multiplyTo(e,r)}function Me(t,e){t.squareTo(e)}function Fe(t){return this.exp(t,new De)}function Pe(t,e,r){var n=Math.min(this.t+t.t,e);for(r.s=0,r.t=n;n>0;)r[--n]=0;var i;for(i=r.t-this.t;i>n;++n)r[n+this.t]=this.am(0,t[n],r,n,0,this.t);for(i=Math.min(t.t,e);i>n;++n)this.am(0,t[n],r,n,0,e-n);r.clamp()}function Ue(t,e,r){--e;var n=r.t=this.t+t.t-e;for(r.s=0;--n>=0;)r[n]=0;for(n=Math.max(e-this.t,0);n2*this.m.t)return t.mod(this.m);if(t.compareTo(this.m)<0)return t;var e=n();return t.copyTo(e),this.reduce(e),e}function Ge(t){return t}function Ve(t){for(t.drShiftTo(this.m.t-1,this.r2),t.t>this.m.t+1&&(t.t=this.m.t+1,t.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);t.compareTo(this.r2)<0;)t.dAddOffset(1,this.m.t+1);for(t.subTo(this.r2,t);t.compareTo(this.m)>=0;)t.subTo(this.m,t)}function Ke(t,e){t.squareTo(e),this.reduce(e)}function Xe(t,e,r){t.multiplyTo(e,r),this.reduce(r)}function Ze(t,e){var r,i,o=t.bitLength(),s=h(1);if(0>=o)return s;r=18>o?1:48>o?3:144>o?4:768>o?5:6,i=8>o?new j(e):e.isEven()?new ze(e):new N(e);var a=new Array,u=3,c=r-1,f=(1<1){var l=n();for(i.sqrTo(a[1],l);f>=u;)a[u]=n(),i.mulTo(l,a[u-2],a[u]),u+=2}var p,d,_=t.t-1,y=!0,v=n();for(o=m(t[_])-1;_>=0;){for(o>=c?p=t[_]>>o-c&f:(p=(t[_]&(1<0&&(p|=t[_-1]>>this.DB+o-c)),u=r;0==(1&p);)p>>=1,--u;if((o-=u)<0&&(o+=this.DB,--_),y)a[p].copyTo(s),y=!1;else{for(;u>1;)i.sqrTo(s,v),i.sqrTo(v,s),u-=2;u>0?i.sqrTo(s,v):(d=s,s=v,v=d),i.mulTo(v,a[p],s)}for(;_>=0&&0==(t[_]&1<o)return e;for(o>i&&(o=i),o>0&&(e.rShiftTo(o,e),r.rShiftTo(o,r));e.signum()>0;)(i=e.getLowestSetBit())>0&&e.rShiftTo(i,e),(i=r.getLowestSetBit())>0&&r.rShiftTo(i,r),e.compareTo(r)>=0?(e.subTo(r,e),e.rShiftTo(1,e)):(r.subTo(e,r),r.rShiftTo(1,r));return o>0&&r.lShiftTo(o,r),r}function Ye(t){if(0>=t)return 0;var e=this.DV%t,r=this.s<0?t-1:0;if(this.t>0)if(0==e)r=this[0]%t;else for(var n=this.t-1;n>=0;--n)r=(e*r+this[n])%t;return r}function $e(t){var e=t.isEven();if(this.isEven()&&e||0==t.signum())return r.ZERO;for(var n=t.clone(),i=this.clone(),o=h(1),s=h(0),a=h(0),u=h(1);0!=n.signum();){for(;n.isEven();)n.rShiftTo(1,n),e?(o.isEven()&&s.isEven()||(o.addTo(this,o),s.subTo(t,s)),o.rShiftTo(1,o)):s.isEven()||s.subTo(t,s),s.rShiftTo(1,s);for(;i.isEven();)i.rShiftTo(1,i),e?(a.isEven()&&u.isEven()||(a.addTo(this,a),u.subTo(t,u)),a.rShiftTo(1,a)):u.isEven()||u.subTo(t,u),u.rShiftTo(1,u);n.compareTo(i)>=0?(n.subTo(i,n),e&&o.subTo(a,o),s.subTo(u,s)):(i.subTo(n,i),e&&a.subTo(o,a),u.subTo(s,u))}return 0!=i.compareTo(r.ONE)?r.ZERO:u.compareTo(t)>=0?u.subtract(t):u.signum()<0?(u.addTo(t,u),u.signum()<0?u.add(t):u):u}function We(t){var e,r=this.abs();if(1==r.t&&r[0]<=ur[ur.length-1]){for(e=0;en;)n*=ur[i++];for(n=r.modInt(n);i>e;)if(n%ur[e++]==0)return!1}return r.millerRabin(t)}function Qe(t){var e=this.subtract(r.ONE),i=e.getLowestSetBit();if(0>=i)return!1;var o=e.shiftRight(i);t=t+1>>1,t>ur.length&&(t=ur.length);for(var s=n(),a=0;t>a;++a){s.fromInt(ur[Math.floor(Math.random()*ur.length)]);var u=s.modPow(o,this);if(0!=u.compareTo(r.ONE)&&0!=u.compareTo(e)){for(var c=1;c++=or;++or)ar[ir++]=or;for(ir="a".charCodeAt(0),or=10;36>or;++or)ar[ir++]=or;for(ir="A".charCodeAt(0),or=10;36>or;++or)ar[ir++]=or;j.prototype.convert=C,j.prototype.revert=B,j.prototype.reduce=L,j.prototype.mulTo=R,j.prototype.sqrTo=O,N.prototype.convert=q,N.prototype.revert=M,N.prototype.reduce=F,N.prototype.mulTo=U,N.prototype.sqrTo=P,De.prototype.convert=Ne,De.prototype.revert=Ne,De.prototype.mulTo=qe,De.prototype.sqrTo=Me,ze.prototype.convert=He,ze.prototype.revert=Ge,ze.prototype.reduce=Ve,ze.prototype.mulTo=Xe,ze.prototype.sqrTo=Ke;var ur=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],cr=(1<<26)/ur[ur.length-1];r.prototype.chunkSize=J,r.prototype.toRadix=$,r.prototype.fromRadix=W,r.prototype.fromNumber=Q,r.prototype.bitwiseTo=ie,r.prototype.changeBit=we,r.prototype.addTo=Se,r.prototype.dMultiply=Re,r.prototype.dAddOffset=Oe,r.prototype.multiplyLowerTo=Pe,r.prototype.multiplyUpperTo=Ue,r.prototype.modInt=Ye,r.prototype.millerRabin=Qe,r.prototype.copyTo=c,r.prototype.fromInt=f,r.prototype.fromString=l,r.prototype.clamp=p,r.prototype.dlShiftTo=b,r.prototype.drShiftTo=w,r.prototype.lShiftTo=E,r.prototype.rShiftTo=x,r.prototype.subTo=A,r.prototype.multiplyTo=S,r.prototype.squareTo=T,r.prototype.divRemTo=k,r.prototype.invDigit=D,r.prototype.isEven=z,r.prototype.exp=H,r.prototype.toString=d,r.prototype.negate=_,r.prototype.abs=y,r.prototype.compareTo=v,r.prototype.bitLength=g,r.prototype.mod=I,r.prototype.modPowInt=G,r.prototype.clone=V,r.prototype.intValue=K,r.prototype.byteValue=X,r.prototype.shortValue=Z,r.prototype.signum=Y,r.prototype.toByteArray=te,r.prototype.equals=ee,r.prototype.min=re,r.prototype.max=ne,r.prototype.and=se,r.prototype.or=ue,r.prototype.xor=fe,r.prototype.andNot=le,r.prototype.not=pe,r.prototype.shiftLeft=de,r.prototype.shiftRight=_e,r.prototype.getLowestSetBit=ve,r.prototype.bitCount=ge,r.prototype.testBit=be,r.prototype.setBit=Ee,r.prototype.clearBit=xe,r.prototype.flipBit=Ae,r.prototype.add=Te,r.prototype.subtract=ke,r.prototype.multiply=Ie,r.prototype.divide=Ce,r.prototype.remainder=Be,r.prototype.divideAndRemainder=Le,r.prototype.modPow=Ze,r.prototype.modInverse=$e,r.prototype.pow=Fe,r.prototype.gcd=Je,r.prototype.isProbablePrime=We,r.prototype.square=je,r.ZERO=h(0),r.ONE=h(1),r.valueOf=n,e.BigInteger=r},function(t){try{t.exports=WebSocket}catch(e){t.exports=MozWebSocket}var r,n=/Version\/(\d+)\.(\d+)(?:\.(\d+))?.*Safari\//;"object"==typeof navigator&&"string"==typeof navigator.userAgent&&(r=n.exec(navigator.userAgent))&&2===window.WebSocket.CLOSED&&(/iP(hone|od|ad)/.test(navigator.platform)?+r[1]<5&&(t.exports=void 0):-1!==navigator.appVersion.indexOf("Mac")&&+r[1]<6&&(t.exports=void 0))},function(t){function e(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function r(t){return"function"==typeof t}function n(t){return"number"==typeof t}function i(t){return"object"==typeof t&&null!==t}function o(t){return void 0===t}t.exports=e,e.EventEmitter=e,e.prototype._events=void 0,e.prototype._maxListeners=void 0,e.defaultMaxListeners=10,e.prototype.setMaxListeners=function(t){if(!n(t)||0>t||isNaN(t))throw TypeError("n must be a positive number");return this._maxListeners=t,this},e.prototype.emit=function(t){var e,n,s,a,u,c;if(this._events||(this._events={}),"error"===t&&(!this._events.error||i(this._events.error)&&!this._events.error.length)){if(e=arguments[1],e instanceof Error)throw e;throw TypeError('Uncaught, unspecified "error" event.')}if(n=this._events[t],o(n))return!1;if(r(n))switch(arguments.length){case 1:n.call(this);break;case 2:n.call(this,arguments[1]);break;case 3:n.call(this,arguments[1],arguments[2]);break;default:for(s=arguments.length,a=new Array(s-1),u=1;s>u;u++)a[u-1]=arguments[u];n.apply(this,a)}else if(i(n)){for(s=arguments.length,a=new Array(s-1),u=1;s>u;u++)a[u-1]=arguments[u]; for(c=n.slice(),s=c.length,u=0;s>u;u++)c[u].apply(this,a)}return!0},e.prototype.addListener=function(t,n){var s;if(!r(n))throw TypeError("listener must be a function");if(this._events||(this._events={}),this._events.newListener&&this.emit("newListener",t,r(n.listener)?n.listener:n),this._events[t]?i(this._events[t])?this._events[t].push(n):this._events[t]=[this._events[t],n]:this._events[t]=n,i(this._events[t])&&!this._events[t].warned){var s;s=o(this._maxListeners)?e.defaultMaxListeners:this._maxListeners,s&&s>0&&this._events[t].length>s&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),"function"==typeof console.trace&&console.trace())}return this},e.prototype.on=e.prototype.addListener,e.prototype.once=function(t,e){function n(){this.removeListener(t,n),i||(i=!0,e.apply(this,arguments))}if(!r(e))throw TypeError("listener must be a function");var i=!1;return n.listener=e,this.on(t,n),this},e.prototype.removeListener=function(t,e){var n,o,s,a;if(!r(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(n=this._events[t],s=n.length,o=-1,n===e||r(n.listener)&&n.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(i(n)){for(a=s;a-->0;)if(n[a]===e||n[a].listener&&n[a].listener===e){o=a;break}if(0>o)return this;1===n.length?(n.length=0,delete this._events[t]):n.splice(o,1),this._events.removeListener&&this.emit("removeListener",t,e)}return this},e.prototype.removeAllListeners=function(t){var e,n;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[t]&&delete this._events[t],this;if(0===arguments.length){for(e in this._events)"removeListener"!==e&&this.removeAllListeners(e);return this.removeAllListeners("removeListener"),this._events={},this}if(n=this._events[t],r(n))this.removeListener(t,n);else for(;n.length;)this.removeListener(t,n[n.length-1]);return delete this._events[t],this},e.prototype.listeners=function(t){var e;return e=this._events&&this._events[t]?r(this._events[t])?[this._events[t]]:this._events[t].slice():[]},e.listenerCount=function(t,e){var n;return n=t._events&&t._events[e]?r(t._events[e])?1:t._events[e].length:0}},function(t,e,r){(function(t,n){function i(t,r){var n={seen:[],stylize:s};return arguments.length>=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),_(r)?n.showHidden=r:r&&e._extend(n,r),w(n.showHidden)&&(n.showHidden=!1),w(n.depth)&&(n.depth=2),w(n.colors)&&(n.colors=!1),w(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=o),u(n,t,n.depth)}function o(t,e){var r=i.styles[e];return r?"["+i.colors[r][0]+"m"+t+"["+i.colors[r][1]+"m":t}function s(t){return t}function a(t){var e={};return t.forEach(function(t){e[t]=!0}),e}function u(t,r,n){if(t.customInspect&&r&&T(r.inspect)&&r.inspect!==e.inspect&&(!r.constructor||r.constructor.prototype!==r)){var i=r.inspect(n,t);return g(i)||(i=u(t,i,n)),i}var o=c(t,r);if(o)return o;var s=Object.keys(r),_=a(s);if(t.showHidden&&(s=Object.getOwnPropertyNames(r)),S(r)&&(s.indexOf("message")>=0||s.indexOf("description")>=0))return f(r);if(0===s.length){if(T(r)){var y=r.name?": "+r.name:"";return t.stylize("[Function"+y+"]","special")}if(E(r))return t.stylize(RegExp.prototype.toString.call(r),"regexp");if(A(r))return t.stylize(Date.prototype.toString.call(r),"date");if(S(r))return f(r)}var v="",m=!1,b=["{","}"];if(d(r)&&(m=!0,b=["[","]"]),T(r)){var w=r.name?": "+r.name:"";v=" [Function"+w+"]"}if(E(r)&&(v=" "+RegExp.prototype.toString.call(r)),A(r)&&(v=" "+Date.prototype.toUTCString.call(r)),S(r)&&(v=" "+f(r)),0===s.length&&(!m||0==r.length))return b[0]+v+b[1];if(0>n)return E(r)?t.stylize(RegExp.prototype.toString.call(r),"regexp"):t.stylize("[Object]","special");t.seen.push(r);var x;return x=m?h(t,r,n,_,s):s.map(function(e){return l(t,r,n,_,e,m)}),t.seen.pop(),p(x,v,b)}function c(t,e){if(w(e))return t.stylize("undefined","undefined");if(g(e)){var r="'"+JSON.stringify(e).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return t.stylize(r,"string")}return m(e)?t.stylize(""+e,"number"):_(e)?t.stylize(""+e,"boolean"):y(e)?t.stylize("null","null"):void 0}function f(t){return"["+Error.prototype.toString.call(t)+"]"}function h(t,e,r,n,i){for(var o=[],s=0,a=e.length;a>s;++s)B(e,String(s))?o.push(l(t,e,r,n,String(s),!0)):o.push("");return i.forEach(function(i){i.match(/^\d+$/)||o.push(l(t,e,r,n,i,!0))}),o}function l(t,e,r,n,i,o){var s,a,c;if(c=Object.getOwnPropertyDescriptor(e,i)||{value:e[i]},c.get?a=c.set?t.stylize("[Getter/Setter]","special"):t.stylize("[Getter]","special"):c.set&&(a=t.stylize("[Setter]","special")),B(n,i)||(s="["+i+"]"),a||(t.seen.indexOf(c.value)<0?(a=y(r)?u(t,c.value,null):u(t,c.value,r-1),a.indexOf("\n")>-1&&(a=o?a.split("\n").map(function(t){return" "+t}).join("\n").substr(2):"\n"+a.split("\n").map(function(t){return" "+t}).join("\n"))):a=t.stylize("[Circular]","special")),w(s)){if(o&&i.match(/^\d+$/))return a;s=JSON.stringify(""+i),s.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=t.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=t.stylize(s,"string"))}return s+": "+a}function p(t,e,r){var n=0,i=t.reduce(function(t,e){return n++,e.indexOf("\n")>=0&&n++,t+e.replace(/\u001b\[\d\d?m/g,"").length+1},0);return i>60?r[0]+(""===e?"":e+"\n ")+" "+t.join(",\n ")+" "+r[1]:r[0]+e+" "+t.join(", ")+" "+r[1]}function d(t){return Array.isArray(t)}function _(t){return"boolean"==typeof t}function y(t){return null===t}function v(t){return null==t}function m(t){return"number"==typeof t}function g(t){return"string"==typeof t}function b(t){return"symbol"==typeof t}function w(t){return void 0===t}function E(t){return x(t)&&"[object RegExp]"===I(t)}function x(t){return"object"==typeof t&&null!==t}function A(t){return x(t)&&"[object Date]"===I(t)}function S(t){return x(t)&&("[object Error]"===I(t)||t instanceof Error)}function T(t){return"function"==typeof t}function k(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||"undefined"==typeof t}function I(t){return Object.prototype.toString.call(t)}function j(t){return 10>t?"0"+t.toString(10):t.toString(10)}function C(){var t=new Date,e=[j(t.getHours()),j(t.getMinutes()),j(t.getSeconds())].join(":");return[t.getDate(),D[t.getMonth()],e].join(" ")}function B(t,e){return Object.prototype.hasOwnProperty.call(t,e)}var L=/%[sdj%]/g;e.format=function(t){if(!g(t)){for(var e=[],r=0;r=o)return t;switch(t){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return t}}),a=n[r];o>r;a=n[++r])s+=y(a)||!x(a)?" "+a:" "+i(a);return s},e.deprecate=function(r,i){function o(){if(!s){if(n.throwDeprecation)throw new Error(i);n.traceDeprecation?console.trace(i):console.error(i),s=!0}return r.apply(this,arguments)}if(w(t.process))return function(){return e.deprecate(r,i).apply(this,arguments)};if(n.noDeprecation===!0)return r;var s=!1;return o};var R,O={};e.debuglog=function(t){if(w(R)&&(R=n.env.NODE_DEBUG||""),t=t.toUpperCase(),!O[t])if(new RegExp("\\b"+t+"\\b","i").test(R)){var r=n.pid;O[t]=function(){var n=e.format.apply(e,arguments);console.error("%s %d: %s",t,r,n)}}else O[t]=function(){};return O[t]},e.inspect=i,i.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},i.styles={special:"cyan",number:"yellow","boolean":"yellow",undefined:"grey","null":"bold",string:"green",date:"magenta",regexp:"red"},e.isArray=d,e.isBoolean=_,e.isNull=y,e.isNullOrUndefined=v,e.isNumber=m,e.isString=g,e.isSymbol=b,e.isUndefined=w,e.isRegExp=E,e.isObject=x,e.isDate=A,e.isError=S,e.isFunction=T,e.isPrimitive=k,e.isBuffer=r(56);var D=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];e.log=function(){console.log("%s - %s",C(),e.format.apply(e,arguments))},e.inherits=r(67),e._extend=function(t,e){if(!e||!x(e))return t;for(var r=Object.keys(e),n=r.length;n--;)t[r[n]]=e[r[n]];return t}}).call(e,function(){return this}(),r(61))},function(t,e,r){function n(t,e){return p.isUndefined(e)?""+e:!p.isNumber(e)||!isNaN(e)&&isFinite(e)?p.isFunction(e)||p.isRegExp(e)?e.toString():e:e.toString()}function i(t,e){return p.isString(t)?t.length=0;n--)if(i[n]!=o[n])return!1;for(n=i.length-1;n>=0;n--)if(r=i[n],!u(t[r],e[r]))return!1;return!0}function h(t,e){return t&&e?"[object RegExp]"==Object.prototype.toString.call(e)?e.test(t):t instanceof e?!0:e.call({},t)===!0?!0:!1:!1}function l(t,e,r,n){var i;p.isString(r)&&(n=r,r=null);try{e()}catch(o){i=o}if(n=(r&&r.name?" ("+r.name+").":".")+(n?" "+n:"."),t&&!i&&s(i,r,"Missing expected exception"+n),!t&&h(i,r)&&s(i,r,"Got unwanted exception"+n),t&&i&&r&&!h(i,r)||!t&&i)throw i}var p=r(40),d=Array.prototype.slice,_=Object.prototype.hasOwnProperty,y=t.exports=a;y.AssertionError=function(t){this.name="AssertionError",this.actual=t.actual,this.expected=t.expected,this.operator=t.operator,t.message?(this.message=t.message,this.generatedMessage=!1):(this.message=o(this),this.generatedMessage=!0);var e=t.stackStartFunction||s;if(Error.captureStackTrace)Error.captureStackTrace(this,e);else{var r=new Error;if(r.stack){var n=r.stack,i=e.name,a=n.indexOf("\n"+i);if(a>=0){var u=n.indexOf("\n",a+1);n=n.substring(u+1)}this.stack=n}}},p.inherits(y.AssertionError,Error),y.fail=s,y.ok=a,y.equal=function(t,e,r){t!=e&&s(t,e,r,"==",y.equal)},y.notEqual=function(t,e,r){t==e&&s(t,e,r,"!=",y.notEqual)},y.deepEqual=function(t,e,r){u(t,e)||s(t,e,r,"deepEqual",y.deepEqual)},y.notDeepEqual=function(t,e,r){u(t,e)&&s(t,e,r,"notDeepEqual",y.notDeepEqual)},y.strictEqual=function(t,e,r){t!==e&&s(t,e,r,"===",y.strictEqual)},y.notStrictEqual=function(t,e,r){t===e&&s(t,e,r,"!==",y.notStrictEqual)},y.throws=function(){l.apply(this,[!0].concat(d.call(arguments)))},y.doesNotThrow=function(){l.apply(this,[!1].concat(d.call(arguments)))},y.ifError=function(t){if(t)throw t};var v=Object.keys||function(t){var e=[];for(var r in t)_.call(t,r)&&e.push(r);return e}},function(t){function e(t){this._namespace=t?Array.isArray(t)?t:[""+t]:[],this._prefix=this._namespace.concat([""]).join(": ")}e.prototype.sub=function(t){var r=this._namespace.slice();t&&"string"==typeof t&&r.push(t);var n=new e(r);return n._setParent(this),n},e.prototype._setParent=function(t){this._parent=t},e.makeLevel=function(){return function(){var t=Array.prototype.slice.call(arguments);t[0]=this._prefix+t[0],e.engine.logObject.apply(e,t)}},e.prototype.debug=e.makeLevel(1),e.prototype.info=e.makeLevel(2),e.prototype.warn=e.makeLevel(3),e.prototype.error=e.makeLevel(4);var r={logObject:function(t){var e=Array.prototype.slice.call(arguments,1);e=e.map(function(t){return JSON.stringify(t,null,2)}),e.unshift(t),e.unshift("["+(new Date).toISOString()+"]"),console.log.apply(console,e)}},n={logObject:function(){}};e.engine=n,console&&console.log&&(e.engine=r),t.exports=new e,t.exports.internal=t.exports.sub(),t.exports.Log=e},function(t,e,r){(function(t){function t(e,r,n){if(!(this instanceof t))return new t(e,r,n);var i=typeof e;if("base64"===r&&"string"===i)for(e=k(e);e.length%4!==0;)e+="=";var o;if("number"===i)o=j(e);else if("string"===i)o=t.byteLength(e,r);else{if("object"!==i)throw new Error("First argument needs to be a number, array or string.");o=j(e.length)}var s;t._useTypedArrays?s=t._augment(new Uint8Array(o)):(s=this,s.length=o,s._isBuffer=!0);var a;if(t._useTypedArrays&&"number"==typeof e.byteLength)s._set(e);else if(B(e))for(a=0;o>a;a++)s[a]=t.isBuffer(e)?e.readUInt8(a):e[a];else if("string"===i)s.write(e,0,r);else if("number"===i&&!t._useTypedArrays&&!n)for(a=0;o>a;a++)s[a]=0;return s}function n(e,r,n,i){n=Number(n)||0;var o=e.length-n;i?(i=Number(i),i>o&&(i=o)):i=o;var s=r.length;z(s%2===0,"Invalid hex string"),i>s/2&&(i=s/2);for(var a=0;i>a;a++){var u=parseInt(r.substr(2*a,2),16);z(!isNaN(u),"Invalid hex string"),e[n+a]=u}return t._charsWritten=2*a,a}function i(e,r,n,i){var o=t._charsWritten=q(R(r),e,n,i);return o}function o(e,r,n,i){var o=t._charsWritten=q(O(r),e,n,i);return o}function s(t,e,r,n){return o(t,e,r,n)}function a(e,r,n,i){var o=t._charsWritten=q(N(r),e,n,i);return o}function u(e,r,n,i){var o=t._charsWritten=q(D(r),e,n,i);return o}function c(t,e,r){return 0===e&&r===t.length?H.fromByteArray(t):H.fromByteArray(t.slice(e,r))}function f(t,e,r){var n="",i="";r=Math.min(t.length,r);for(var o=e;r>o;o++)t[o]<=127?(n+=M(i)+String.fromCharCode(t[o]),i=""):i+="%"+t[o].toString(16);return n+M(i)}function h(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;r>i;i++)n+=String.fromCharCode(t[i]);return n}function l(t,e,r){return h(t,e,r)}function p(t,e,r){var n=t.length;(!e||0>e)&&(e=0),(!r||0>r||r>n)&&(r=n);for(var i="",o=e;r>o;o++)i+=L(t[o]);return i}function d(t,e,r){for(var n=t.slice(e,r),i="",o=0;o=i)){var o;return r?(o=t[e],i>e+1&&(o|=t[e+1]<<8)):(o=t[e]<<8,i>e+1&&(o|=t[e+1])),o}}function y(t,e,r,n){n||(z("boolean"==typeof r,"missing or invalid endian"),z(void 0!==e&&null!==e,"missing offset"),z(e+3=i)){var o;return r?(i>e+2&&(o=t[e+2]<<16),i>e+1&&(o|=t[e+1]<<8),o|=t[e],i>e+3&&(o+=t[e+3]<<24>>>0)):(i>e+1&&(o=t[e+1]<<16),i>e+2&&(o|=t[e+2]<<8),i>e+3&&(o|=t[e+3]),o+=t[e]<<24>>>0),o}}function v(t,e,r,n){n||(z("boolean"==typeof r,"missing or invalid endian"),z(void 0!==e&&null!==e,"missing offset"),z(e+1=i)){var o=_(t,e,r,!0),s=32768&o;return s?-1*(65535-o+1):o}}function m(t,e,r,n){n||(z("boolean"==typeof r,"missing or invalid endian"),z(void 0!==e&&null!==e,"missing offset"),z(e+3=i)){var o=y(t,e,r,!0),s=2147483648&o;return s?-1*(4294967295-o+1):o}}function g(t,e,r,n){return n||(z("boolean"==typeof r,"missing or invalid endian"),z(e+3=o))for(var s=0,a=Math.min(o-r,2);a>s;s++)t[r+s]=(e&255<<8*(n?s:1-s))>>>8*(n?s:1-s)}function E(t,e,r,n,i){i||(z(void 0!==e&&null!==e,"missing value"),z("boolean"==typeof n,"missing or invalid endian"),z(void 0!==r&&null!==r,"missing offset"),z(r+3=o))for(var s=0,a=Math.min(o-r,4);a>s;s++)t[r+s]=e>>>8*(n?s:3-s)&255}function x(t,e,r,n,i){i||(z(void 0!==e&&null!==e,"missing value"),z("boolean"==typeof n,"missing or invalid endian"),z(void 0!==r&&null!==r,"missing offset"),z(r+1=o||(e>=0?w(t,e,r,n,i):w(t,65535+e+1,r,n,i))}function A(t,e,r,n,i){i||(z(void 0!==e&&null!==e,"missing value"),z("boolean"==typeof n,"missing or invalid endian"),z(void 0!==r&&null!==r,"missing offset"),z(r+3=o||(e>=0?E(t,e,r,n,i):E(t,4294967295+e+1,r,n,i))}function S(t,e,r,n,i){i||(z(void 0!==e&&null!==e,"missing value"),z("boolean"==typeof n,"missing or invalid endian"),z(void 0!==r&&null!==r,"missing offset"),z(r+3=o||G.write(t,e,r,n,23,4)}function T(t,e,r,n,i){i||(z(void 0!==e&&null!==e,"missing value"),z("boolean"==typeof n,"missing or invalid endian"),z(void 0!==r&&null!==r,"missing offset"),z(r+7=o||G.write(t,e,r,n,52,8)}function k(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function I(t,e,r){return"number"!=typeof t?r:(t=~~t,t>=e?e:t>=0?t:(t+=e,t>=0?t:0))}function j(t){return t=~~Math.ceil(+t),0>t?0:t}function C(t){return(Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)})(t)}function B(e){return C(e)||t.isBuffer(e)||e&&"object"==typeof e&&"number"==typeof e.length}function L(t){return 16>t?"0"+t.toString(16):t.toString(16)}function R(t){for(var e=[],r=0;r=n)e.push(t.charCodeAt(r));else{var i=r;n>=55296&&57343>=n&&r++;for(var o=encodeURIComponent(t.slice(i,r+1)).substr(1).split("%"),s=0;s>8,n=e%256,i.push(n),i.push(r);return i}function N(t){return H.toByteArray(t)}function q(t,e,r,n){for(var i=0;n>i&&!(i+r>=e.length||i>=t.length);i++)e[i+r]=t[i];return i}function M(t){try{return decodeURIComponent(t)}catch(e){return String.fromCharCode(65533)}}function F(t,e){z("number"==typeof t,"cannot write a non-number as a number"),z(t>=0,"specified a negative value for writing an unsigned value"),z(e>=t,"value is larger than maximum value for type"),z(Math.floor(t)===t,"value has a fractional component")}function P(t,e,r){z("number"==typeof t,"cannot write a non-number as a number"),z(e>=t,"value larger than maximum allowed value"),z(t>=r,"value smaller than minimum allowed value"),z(Math.floor(t)===t,"value has a fractional component")}function U(t,e,r){z("number"==typeof t,"cannot write a non-number as a number"),z(e>=t,"value larger than maximum allowed value"),z(t>=r,"value smaller than minimum allowed value")}function z(t,e){if(!t)throw new Error(e||"Failed assertion")}var H=r(70),G=r(65);e.Buffer=t,e.SlowBuffer=t,e.INSPECT_MAX_BYTES=50,t.poolSize=8192,t._useTypedArrays=function(){try{var t=new ArrayBuffer(0),e=new Uint8Array(t);return e.foo=function(){return 42},42===e.foo()&&"function"==typeof e.subarray}catch(r){return!1}}(),t.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},t.isBuffer=function(t){return!(null===t||void 0===t||!t._isBuffer)},t.byteLength=function(t,e){var r;switch(t+="",e||"utf8"){case"hex":r=t.length/2;break;case"utf8":case"utf-8":r=R(t).length;break;case"ascii":case"binary":case"raw":r=t.length;break;case"base64":r=N(t).length;break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":r=2*t.length;break;default:throw new Error("Unknown encoding")}return r},t.concat=function(e,r){if(z(C(e),"Usage: Buffer.concat(list, [totalLength])\nlist should be an Array."),0===e.length)return new t(0);if(1===e.length)return e[0];var n;if("number"!=typeof r)for(r=0,n=0;nh&&(r=h)):r=h,c=String(c||"utf8").toLowerCase();var l;switch(c){case"hex":l=n(this,t,e,r);break;case"utf8":case"utf-8":l=i(this,t,e,r);break;case"ascii":l=o(this,t,e,r);break;case"binary":l=s(this,t,e,r);break;case"base64":l=a(this,t,e,r);break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":l=u(this,t,e,r);break;default:throw new Error("Unknown encoding")}return l},t.prototype.toString=function(t,e,r){var n=this;if(t=String(t||"utf8").toLowerCase(),e=Number(e)||0,r=void 0!==r?Number(r):r=n.length,r===e)return"";var i;switch(t){case"hex":i=p(n,e,r);break;case"utf8":case"utf-8":i=f(n,e,r);break;case"ascii":i=h(n,e,r);break;case"binary":i=l(n,e,r);break;case"base64":i=c(n,e,r);break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":i=d(n,e,r);break;default:throw new Error("Unknown encoding")}return i},t.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},t.prototype.copy=function(e,r,n,i){var o=this;if(n||(n=0),i||0===i||(i=this.length),r||(r=0),i!==n&&0!==e.length&&0!==o.length){z(i>=n,"sourceEnd < sourceStart"),z(r>=0&&r=0&&n=0&&i<=o.length,"sourceEnd out of bounds"),i>this.length&&(i=this.length),e.length-rs||!t._useTypedArrays)for(var a=0;s>a;a++)e[a+r]=this[a+n];else e._set(this.subarray(n,n+s),r)}},t.prototype.slice=function(e,r){var n=this.length;if(e=I(e,n,0),r=I(r,n,n),t._useTypedArrays)return t._augment(this.subarray(e,r));for(var i=r-e,o=new t(i,void 0,!0),s=0;i>s;s++)o[s]=this[s+e];return o},t.prototype.get=function(t){return console.log(".get() is deprecated. Access using array indexes instead."),this.readUInt8(t)},t.prototype.set=function(t,e){return console.log(".set() is deprecated. Access using array indexes instead."),this.writeUInt8(t,e)},t.prototype.readUInt8=function(t,e){return e||(z(void 0!==t&&null!==t,"missing offset"),z(t=this.length?void 0:this[t]},t.prototype.readUInt16LE=function(t,e){return _(this,t,!0,e)},t.prototype.readUInt16BE=function(t,e){return _(this,t,!1,e)},t.prototype.readUInt32LE=function(t,e){return y(this,t,!0,e)},t.prototype.readUInt32BE=function(t,e){return y(this,t,!1,e)},t.prototype.readInt8=function(t,e){if(e||(z(void 0!==t&&null!==t,"missing offset"),z(t=this.length)){var r=128&this[t];return r?-1*(255-this[t]+1):this[t]}},t.prototype.readInt16LE=function(t,e){return v(this,t,!0,e)},t.prototype.readInt16BE=function(t,e){return v(this,t,!1,e)},t.prototype.readInt32LE=function(t,e){return m(this,t,!0,e)},t.prototype.readInt32BE=function(t,e){return m(this,t,!1,e)},t.prototype.readFloatLE=function(t,e){return g(this,t,!0,e)},t.prototype.readFloatBE=function(t,e){return g(this,t,!1,e)},t.prototype.readDoubleLE=function(t,e){return b(this,t,!0,e)},t.prototype.readDoubleBE=function(t,e){return b(this,t,!1,e)},t.prototype.writeUInt8=function(t,e,r){r||(z(void 0!==t&&null!==t,"missing value"),z(void 0!==e&&null!==e,"missing offset"),z(e=this.length||(this[e]=t)},t.prototype.writeUInt16LE=function(t,e,r){w(this,t,e,!0,r)},t.prototype.writeUInt16BE=function(t,e,r){w(this,t,e,!1,r)},t.prototype.writeUInt32LE=function(t,e,r){E(this,t,e,!0,r)},t.prototype.writeUInt32BE=function(t,e,r){E(this,t,e,!1,r)},t.prototype.writeInt8=function(t,e,r){r||(z(void 0!==t&&null!==t,"missing value"),z(void 0!==e&&null!==e,"missing offset"),z(e=this.length||(t>=0?this.writeUInt8(t,e,r):this.writeUInt8(255+t+1,e,r))},t.prototype.writeInt16LE=function(t,e,r){x(this,t,e,!0,r)},t.prototype.writeInt16BE=function(t,e,r){x(this,t,e,!1,r)},t.prototype.writeInt32LE=function(t,e,r){A(this,t,e,!0,r)},t.prototype.writeInt32BE=function(t,e,r){A(this,t,e,!1,r)},t.prototype.writeFloatLE=function(t,e,r){S(this,t,e,!0,r)},t.prototype.writeFloatBE=function(t,e,r){S(this,t,e,!1,r)},t.prototype.writeDoubleLE=function(t,e,r){T(this,t,e,!0,r)},t.prototype.writeDoubleBE=function(t,e,r){T(this,t,e,!1,r)},t.prototype.fill=function(t,e,r){if(t||(t=0),e||(e=0),r||(r=this.length),"string"==typeof t&&(t=t.charCodeAt(0)),z("number"==typeof t&&!isNaN(t),"value is not a number"),z(r>=e,"end < start"),r!==e&&0!==this.length){z(e>=0&&e=0&&r<=this.length,"end out of bounds");for(var n=e;r>n;n++)this[n]=t}},t.prototype.inspect=function(){for(var t=[],r=this.length,n=0;r>n;n++)if(t[n]=L(this[n]),n===e.INSPECT_MAX_BYTES){t[n+1]="...";break}return""},t.prototype.toArrayBuffer=function(){if("undefined"!=typeof Uint8Array){if(t._useTypedArrays)return new t(this).buffer;for(var e=new Uint8Array(this.length),r=0,n=e.length;n>r;r+=1)e[r]=this[r];return e.buffer}throw new Error("Buffer.toArrayBuffer not supported in this browser")};var V=t.prototype;t._augment=function(t){return t._isBuffer=!0,t._get=t.get,t._set=t.set,t.get=V.get,t.set=V.set,t.write=V.write,t.toString=V.toString,t.toLocaleString=V.toString,t.toJSON=V.toJSON,t.copy=V.copy,t.slice=V.slice,t.readUInt8=V.readUInt8,t.readUInt16LE=V.readUInt16LE,t.readUInt16BE=V.readUInt16BE,t.readUInt32LE=V.readUInt32LE,t.readUInt32BE=V.readUInt32BE,t.readInt8=V.readInt8,t.readInt16LE=V.readInt16LE,t.readInt16BE=V.readInt16BE,t.readInt32LE=V.readInt32LE,t.readInt32BE=V.readInt32BE,t.readFloatLE=V.readFloatLE,t.readFloatBE=V.readFloatBE,t.readDoubleLE=V.readDoubleLE,t.readDoubleBE=V.readDoubleBE,t.writeUInt8=V.writeUInt8,t.writeUInt16LE=V.writeUInt16LE,t.writeUInt16BE=V.writeUInt16BE,t.writeUInt32LE=V.writeUInt32LE,t.writeUInt32BE=V.writeUInt32BE,t.writeInt8=V.writeInt8,t.writeInt16LE=V.writeInt16LE,t.writeInt16BE=V.writeInt16BE,t.writeInt32LE=V.writeInt32LE,t.writeInt32BE=V.writeInt32BE,t.writeFloatLE=V.writeFloatLE,t.writeFloatBE=V.writeFloatBE,t.writeDoubleLE=V.writeDoubleLE,t.writeDoubleBE=V.writeDoubleBE,t.fill=V.fill,t.inspect=V.inspect,t.toArrayBuffer=V.toArrayBuffer,t}}).call(e,r(43).Buffer)},function(t,e,r){(function(t){function n(){var t=[].slice.call(arguments).join(" ");throw new Error([t,"we accept pull requests","http://github.com/dominictarr/crypto-browserify"].join("\n"))}function i(t,e){for(var r in t)e(t[r],r)}var o=r(52);e.createHash=r(53),e.createHmac=r(54),e.randomBytes=function(e,r){if(!r||!r.call)return new t(o(e));try{r.call(this,void 0,new t(o(e)))}catch(n){r(n)}},e.getHashes=function(){return["sha1","sha256","md5","rmd160"]};var s=r(55)(e.createHmac);e.pbkdf2=s.pbkdf2,e.pbkdf2Sync=s.pbkdf2Sync,i(["createCredentials","createCipher","createCipheriv","createDecipher","createDecipheriv","createSign","createVerify","createDiffieHellman"],function(t){e[t]=function(){n("sorry,",t,"is not implemented yet")}})}).call(e,r(43).Buffer)},function(t,e,r){!function(){"use strict";function t(t,e,r){if(t&&"object"==typeof t&&t.href)return t;if("string"!=typeof t)throw new TypeError("Parameter 'url' must be a string, not "+typeof t);var i={},o=t;o=o.trim();var c=u.exec(o);if(c){c=c[0];var f=c.toLowerCase();i.protocol=f,o=o.substr(c.length)}if(r||c||o.match(/^\/\/[^@\/]+@[^@\/]+/)){var h="//"===o.substr(0,2);!h||c&&g[c]||(o=o.substr(2),i.slashes=!0)}if(!g[c]&&(h||c&&!b[c])){var E=o.indexOf("@");if(-1!==E){for(var x=o.slice(0,E),A=!0,S=0,T=d.length;T>S;S++)if(-1!==x.indexOf(d[S])){A=!1;break}A&&(i.auth=decodeURIComponent(x),o=o.substr(E+1))}for(var k=-1,S=0,T=p.length;T>S;S++){var I=o.indexOf(p[S]);-1!==I&&(0>k||k>I)&&(k=I)}-1!==k?(i.host=o.substr(0,k),o=o.substr(k)):(i.host=o,o="");for(var j=s(i.host),C=Object.keys(j),S=0,T=C.length;T>S;S++){var B=C[S];i[B]=j[B]}i.hostname=i.hostname||"";var L="["===i.hostname[0]&&"]"===i.hostname[i.hostname.length-1];if(i.hostname.length>_)i.hostname="";else if(!L)for(var R=i.hostname.split(/\./),S=0,T=R.length;T>S;S++){var O=R[S];if(O&&!O.match(y)){for(var D="",N=0,q=O.length;q>N;N++)D+=O.charCodeAt(N)>127?"x":O[N];if(!D.match(y)){var M=R.slice(0,S),F=R.slice(S+1),P=O.match(v);P&&(M.push(P[1]),F.unshift(P[2])),F.length&&(o="/"+F.join(".")+o),i.hostname=M.join(".");break}}}if(i.hostname=i.hostname.toLowerCase(),!L){for(var U=i.hostname.split("."),z=[],S=0;SS;S++){var G=l[S],V=encodeURIComponent(G);V===G&&(V=escape(G)),o=o.split(G).join(V)}var K=o.indexOf("#");-1!==K&&(i.hash=o.substr(K),o=o.slice(0,K));var X=o.indexOf("?");return-1!==X?(i.search=o.substr(X),i.query=o.substr(X+1),e&&(i.query=w.parse(i.query)),o=o.slice(0,X)):e&&(i.search="",i.query={}),o&&(i.pathname=o),b[c]&&i.hostname&&!i.pathname&&(i.pathname="/"),(i.pathname||i.search)&&(i.path=(i.pathname?i.pathname:"")+(i.search?i.search:"")),i.href=n(i),i}function n(e){"string"==typeof e&&(e=t(e));var r=e.auth||"";r&&(r=encodeURIComponent(r),r=r.replace(/%3A/i,":"),r+="@");var n=e.protocol||"",i=e.pathname||"",o=e.hash||"",s=!1,a="";void 0!==e.host?s=r+e.host:void 0!==e.hostname&&(s=r+(-1===e.hostname.indexOf(":")?e.hostname:"["+e.hostname+"]"),e.port&&(s+=":"+e.port)),e.query&&"object"==typeof e.query&&Object.keys(e.query).length&&(a=w.stringify(e.query));var u=e.search||a&&"?"+a||"";return n&&":"!==n.substr(-1)&&(n+=":"),e.slashes||(!n||b[n])&&s!==!1?(s="//"+(s||""),i&&"/"!==i.charAt(0)&&(i="/"+i)):s||(s=""),o&&"#"!==o.charAt(0)&&(o="#"+o),u&&"?"!==u.charAt(0)&&(u="?"+u),n+s+i+u+o}function i(t,e){return n(o(t,e))}function o(e,r){if(!e)return r;if(e=t(n(e),!1,!0),r=t(n(r),!1,!0),e.hash=r.hash,""===r.href)return e.href=n(e),e;if(r.slashes&&!r.protocol)return r.protocol=e.protocol,b[r.protocol]&&r.hostname&&!r.pathname&&(r.path=r.pathname="/"),r.href=n(r),r;if(r.protocol&&r.protocol!==e.protocol){if(!b[r.protocol])return r.href=n(r),r;if(e.protocol=r.protocol,!r.host&&!g[r.protocol]){for(var i=(r.pathname||"").split("/");i.length&&!(r.host=i.shift()););r.host||(r.host=""),r.hostname||(r.hostname=""),""!==i[0]&&i.unshift(""),i.length<2&&i.unshift(""),r.pathname=i.join("/")}return e.pathname=r.pathname,e.search=r.search,e.query=r.query,e.host=r.host||"",e.auth=r.auth,e.hostname=r.hostname||r.host,e.port=r.port,(void 0!==e.pathname||void 0!==e.search)&&(e.path=(e.pathname?e.pathname:"")+(e.search?e.search:"")),e.slashes=e.slashes||r.slashes,e.href=n(e),e}var o=e.pathname&&"/"===e.pathname.charAt(0),s=void 0!==r.host||r.pathname&&"/"===r.pathname.charAt(0),a=s||o||e.host&&r.pathname,u=a,c=e.pathname&&e.pathname.split("/")||[],i=r.pathname&&r.pathname.split("/")||[],f=e.protocol&&!b[e.protocol];if(f&&(delete e.hostname,delete e.port,e.host&&(""===c[0]?c[0]=e.host:c.unshift(e.host)),delete e.host,r.protocol&&(delete r.hostname,delete r.port,r.host&&(""===i[0]?i[0]=r.host:i.unshift(r.host)),delete r.host),a=a&&(""===i[0]||""===c[0])),s)e.host=r.host||""===r.host?r.host:e.host,e.hostname=r.hostname||""===r.hostname?r.hostname:e.hostname,e.search=r.search,e.query=r.query,c=i; else if(i.length)c||(c=[]),c.pop(),c=c.concat(i),e.search=r.search,e.query=r.query;else if("search"in r){if(f){e.hostname=e.host=c.shift();var h=e.host&&e.host.indexOf("@")>0?e.host.split("@"):!1;h&&(e.auth=h.shift(),e.host=e.hostname=h.shift())}return e.search=r.search,e.query=r.query,(void 0!==e.pathname||void 0!==e.search)&&(e.path=(e.pathname?e.pathname:"")+(e.search?e.search:"")),e.href=n(e),e}if(!c.length)return delete e.pathname,e.search?delete e.path:e.path="/"+e.search,e.href=n(e),e;for(var l=c.slice(-1)[0],p=(e.host||r.host)&&("."===l||".."===l)||""===l,d=0,_=c.length;_>=0;_--)l=c[_],"."==l?c.splice(_,1):".."===l?(c.splice(_,1),d++):d&&(c.splice(_,1),d--);if(!a&&!u)for(;d--;d)c.unshift("..");!a||""===c[0]||c[0]&&"/"===c[0].charAt(0)||c.unshift(""),p&&"/"!==c.join("/").substr(-1)&&c.push("");var y=""===c[0]||c[0]&&"/"===c[0].charAt(0);if(f){e.hostname=e.host=y?"":c.length?c.shift():"";var h=e.host&&e.host.indexOf("@")>0?e.host.split("@"):!1;h&&(e.auth=h.shift(),e.host=e.hostname=h.shift())}return a=a||e.host&&c.length,a&&!y&&c.unshift(""),e.pathname=c.join("/"),(void 0!==e.pathname||void 0!==e.search)&&(e.path=(e.pathname?e.pathname:"")+(e.search?e.search:"")),e.auth=r.auth||e.auth,e.slashes=e.slashes||r.slashes,e.href=n(e),e}function s(t){var e={},r=c.exec(t);return r&&(r=r[0],":"!==r&&(e.port=r.substr(1)),t=t.substr(0,t.length-r.length)),t&&(e.hostname=t),e}var a=r(68);e.parse=t,e.resolve=i,e.resolveObject=o,e.format=n;var u=/^([a-z0-9.+-]+:)/i,c=/:[0-9]*$/,f=["<",">",'"',"`"," ","\r","\n"," "],h=["{","}","|","\\","^","~","`"].concat(f),l=["'"].concat(f),p=["%","/","?",";","#"].concat(h).concat(l),d=["/","@","?","#"].concat(f),_=255,y=/^[a-zA-Z0-9][a-z0-9A-Z_-]{0,62}$/,v=/^([a-zA-Z0-9][a-z0-9A-Z_-]{0,62})(.*)$/,m={javascript:!0,"javascript:":!0},g={javascript:!0,"javascript:":!0},b={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},w=r(69)}()},function(t){function e(t){if(!t||"[object Object]"!==n.call(t)||t.nodeType||t.setInterval)return!1;var e=r.call(t,"constructor"),i=r.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!e&&!i)return!1;var o;for(o in t);return void 0===o||r.call(t,o)}var r=Object.prototype.hasOwnProperty,n=Object.prototype.toString;t.exports=function i(){var t,r,n,o,s,a,u=arguments[0]||{},c=1,f=arguments.length,h=!1;for("boolean"==typeof u&&(h=u,u=arguments[1]||{},c=2),"object"!=typeof u&&"function"!=typeof u&&(u={});f>c;c++)if(null!=(t=arguments[c]))for(r in t)n=u[r],o=t[r],u!==o&&(h&&o&&(e(o)||(s=Array.isArray(o)))?(s?(s=!1,a=n&&Array.isArray(n)?n:[]):a=n&&e(n)?n:{},u[r]=i(h,a,o)):void 0!==o&&(u[r]=o));return u}},function(t,e,r){var n,i;(function(e){!function(){function r(t){var e=!1;return function(){if(e)throw new Error("Callback was already called.");e=!0,t.apply(o,arguments)}}var o,s,a={};o=this,null!=o&&(s=o.async),a.noConflict=function(){return o.async=s,a};var u=Object.prototype.toString,c=Array.isArray||function(t){return"[object Array]"===u.call(t)},f=function(t,e){if(t.forEach)return t.forEach(e);for(var r=0;r=t.length&&n())}if(n=n||function(){},!t.length)return n();var o=0;f(t,function(t){e(t,r(i))})},a.forEach=a.each,a.eachSeries=function(t,e,r){if(r=r||function(){},!t.length)return r();var n=0,i=function(){e(t[n],function(e){e?(r(e),r=function(){}):(n+=1,n>=t.length?r():i())})};i()},a.forEachSeries=a.eachSeries,a.eachLimit=function(t,e,r,n){var i=d(e);i.apply(null,[t,r,n])},a.forEachLimit=a.eachLimit;var d=function(t){return function(e,r,n){if(n=n||function(){},!e.length||0>=t)return n();var i=0,o=0,s=0;!function a(){if(i>=e.length)return n();for(;t>s&&o=e.length?n():a())})}()}},_=function(t){return function(){var e=Array.prototype.slice.call(arguments);return t.apply(null,[a.each].concat(e))}},y=function(t,e){return function(){var r=Array.prototype.slice.call(arguments);return e.apply(null,[d(t)].concat(r))}},v=function(t){return function(){var e=Array.prototype.slice.call(arguments);return t.apply(null,[a.eachSeries].concat(e))}},m=function(t,e,r,n){if(e=h(e,function(t,e){return{index:e,value:t}}),n){var i=[];t(e,function(t,e){r(t.value,function(r,n){i[t.index]=n,e(r)})},function(t){n(t,i)})}else t(e,function(t,e){r(t.value,function(t){e(t)})})};a.map=_(m),a.mapSeries=v(m),a.mapLimit=function(t,e,r,n){return g(e)(t,r,n)};var g=function(t){return y(t,m)};a.reduce=function(t,e,r,n){a.eachSeries(t,function(t,n){r(e,t,function(t,r){e=r,n(t)})},function(t){n(t,e)})},a.inject=a.reduce,a.foldl=a.reduce,a.reduceRight=function(t,e,r,n){var i=h(t,function(t){return t}).reverse();a.reduce(i,e,r,n)},a.foldr=a.reduceRight;var b=function(t,e,r,n){var i=[];e=h(e,function(t,e){return{index:e,value:t}}),t(e,function(t,e){r(t.value,function(r){r&&i.push(t),e()})},function(){n(h(i.sort(function(t,e){return t.index-e.index}),function(t){return t.value}))})};a.filter=_(b),a.filterSeries=v(b),a.select=a.filter,a.selectSeries=a.filterSeries;var w=function(t,e,r,n){var i=[];e=h(e,function(t,e){return{index:e,value:t}}),t(e,function(t,e){r(t.value,function(r){r||i.push(t),e()})},function(){n(h(i.sort(function(t,e){return t.index-e.index}),function(t){return t.value}))})};a.reject=_(w),a.rejectSeries=v(w);var E=function(t,e,r,n){t(e,function(t,e){r(t,function(r){r?(n(t),n=function(){}):e()})},function(){n()})};a.detect=_(E),a.detectSeries=v(E),a.some=function(t,e,r){a.each(t,function(t,n){e(t,function(t){t&&(r(!0),r=function(){}),n()})},function(){r(!1)})},a.any=a.some,a.every=function(t,e,r){a.each(t,function(t,n){e(t,function(t){t||(r(!1),r=function(){}),n()})},function(){r(!0)})},a.all=a.every,a.sortBy=function(t,e,r){a.map(t,function(t,r){e(t,function(e,n){e?r(e):r(null,{value:t,criteria:n})})},function(t,e){if(t)return r(t);var n=function(t,e){var r=t.criteria,n=e.criteria;return n>r?-1:r>n?1:0};r(null,h(e.sort(n),function(t){return t.value}))})},a.auto=function(t,e){e=e||function(){};var r=p(t),n=r.length;if(!n)return e();var i={},o=[],s=function(t){o.unshift(t)},u=function(t){for(var e=0;ee;e++)t[e].apply(null,arguments)}])))};return i.memo=r,i.unmemoized=t,i},a.unmemoize=function(t){return function(){return(t.unmemoized||t).apply(null,arguments)}},a.times=function(t,e,r){for(var n=[],i=0;t>i;i++)n.push(i);return a.map(n,e,r)},a.timesSeries=function(t,e,r){for(var n=[],i=0;t>i;i++)n.push(i);return a.mapSeries(n,e,r)},a.seq=function(){var t=arguments;return function(){var e=this,r=Array.prototype.slice.call(arguments),n=r.pop();a.reduce(t,r,function(t,r,n){r.apply(e,t.concat([function(){var t=arguments[0],e=Array.prototype.slice.call(arguments,1);n(t,e)}]))},function(t,r){n.apply(e,[t].concat(r))})}},a.compose=function(){return a.seq.apply(null,Array.prototype.reverse.call(arguments))};var T=function(t,e){var r=function(){var r=this,n=Array.prototype.slice.call(arguments),i=n.pop();return t(e,function(t,e){t.apply(r,n.concat([e]))},i)};if(arguments.length>2){var n=Array.prototype.slice.call(arguments,2);return r.apply(this,n)}return r};a.applyEach=_(T),a.applyEachSeries=v(T),a.forever=function(t,e){function r(n){if(n){if(e)return e(n);throw n}t(r)}r()},"undefined"!=typeof t&&t.exports?t.exports=a:(n=[],i=function(){return a}.apply(null,n),!(void 0!==i&&(t.exports=i)))}()}).call(e,r(61))},function(t){!function(){function e(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function r(){return 1}function n(t){return this instanceof n?("number"==typeof t&&(t={max:t}),t||(t={}),this._max=t.max,(!this._max||"number"!=typeof this._max||this._max<=0)&&(this._max=1/0),this._lengthCalculator=t.length||r,"function"!=typeof this._lengthCalculator&&(this._lengthCalculator=r),this._allowStale=t.stale||!1,this._maxAge=t.maxAge||null,this._dispose=t.dispose,this.reset(),void 0):new n(t)}function i(t,e,r){var n=t._cache[e];return n&&(t._maxAge&&Date.now()-n.now>t._maxAge?(u(t,n),t._allowStale||(n=void 0)):r&&o(t,n),n&&(n=n.value)),n}function o(t,e){a(t,e),e.lu=t._mru++,t._lruList[e.lu]=e}function s(t){for(;t._lrut._max;)u(t,t._lruList[t._lru])}function a(t,e){for(delete t._lruList[e.lu];t._lru=t)&&(t=1/0),this._max=t,this._length>this._max&&s(this)},get:function(){return this._max},enumerable:!0}),Object.defineProperty(n.prototype,"lengthCalculator",{set:function(t){if("function"!=typeof t){this._lengthCalculator=r,this._length=this._itemCount;for(var e in this._cache)this._cache[e].length=1}else{this._lengthCalculator=t,this._length=0;for(var e in this._cache)this._cache[e].length=this._lengthCalculator(this._cache[e].value),this._length+=this._cache[e].length}this._length>this._max&&s(this)},get:function(){return this._lengthCalculator},enumerable:!0}),Object.defineProperty(n.prototype,"length",{get:function(){return this._length},enumerable:!0}),Object.defineProperty(n.prototype,"itemCount",{get:function(){return this._itemCount},enumerable:!0}),n.prototype.forEach=function(t,e){e=e||this;for(var r=0,n=this._mru-1;n>=0&&rthis._maxAge&&(u(this,i),this._allowStale||(i=void 0)),i&&t.call(e,i.value,i.key,this)}},n.prototype.keys=function(){for(var t=new Array(this._itemCount),e=0,r=this._mru-1;r>=0&&e=0&&ethis._max?(this._dispose&&this._dispose(t,r),!1):(this._length+=o.length,this._lruList[o.lu]=this._cache[t]=o,this._itemCount++,this._length>this._max&&s(this),!0)},n.prototype.has=function(t){if(!e(this._cache,t))return!1;var r=this._cache[t];return this._maxAge&&Date.now()-r.now>this._maxAge?!1:!0},n.prototype.get=function(t){return i(this,t,!0)},n.prototype.peek=function(t){return i(this,t,!1)},n.prototype.pop=function(){var t=this._lruList[this._lru];return u(this,t),t||null},n.prototype.del=function(t){u(this,this._cache[t])}}()},function(t,e,r){t.exports=function(t){function e(t){return o.bitArray.bitSlice(o.hash.sha512.hash(o.codec.bytes.toBits(t)),0,256)}function n(t,e){return[].concat(t,e>>24,e>>16&255,e>>8&255,255&e)}function i(t){if(this.secret=t,!this.secret)throw"Invalid secret."}var o=t.sjcl,s=r(57)({sjcl:t.sjcl}),a=r(58)({sjcl:t.sjcl}),u=r(59)({sjcl:t.sjcl}),c=r(60)({sjcl:t.sjcl});return i.prototype={getPrivateKey:function(){var t=this;return s.decode_base_check(33,t.secret)},getPrivateGenerator:function(t){var r=0;do privateGenerator=o.bn.fromBits(e(n(t,r))),r++;while(!o.ecc.curves.c256.r.greaterEquals(privateGenerator));return privateGenerator},getPublicGenerator:function(){var t=this.getPrivateKey(this.secret),e=this.getPrivateGenerator(t);return c.fromPrivateGenerator(e)},getPublicKey:function(t){var r,i=0;do r=o.bn.fromBits(e(n(n(t.toBytesCompressed(),0),i))),i++;while(!o.ecc.curves.c256.r.greaterEquals(r));return o.ecc.curves.c256.G.mult(r).toJac().add(t).toAffine()},getAddress:function(){var t=this.getPrivateKey(this.secret),e=this.getPrivateGenerator(t),r=c.fromPrivateGenerator(e).value,n=this.getPublicKey(r);return u.fromPublicKey(n)}},i.getRandom=function(){var t=a.getRandom().value;return new i(t)},i.generate=function(){var t=a.getRandom().value,e=new i(t);return{address:e.getAddress().value,secret:t}},i}},function(t,e,r){var n;(function(t,i){(function(){function o(t,e,r){for(var n=(r||0)-1,i=t?t.length:0;++n-1?0:-1:t?0:-1}function a(t){var e=this.cache,r=typeof t;if("boolean"==r||null==t)e[t]=!0;else{"number"!=r&&"string"!=r&&(r="object");var n="number"==r?t:A+t,i=e[r]||(e[r]={});"object"==r?(i[n]||(i[n]=[])).push(t):i[n]=!0}}function u(t){return t.charCodeAt(0)}function c(t,e){for(var r=t.criteria,n=e.criteria,i=-1,o=r.length;++ia||"undefined"==typeof s)return 1;if(a>s||"undefined"==typeof a)return-1}}return t.index-e.index}function f(t){var e=-1,r=t.length,n=t[0],i=t[r/2|0],o=t[r-1];if(n&&"object"==typeof n&&i&&"object"==typeof i&&o&&"object"==typeof o)return!1;var s=p();s["false"]=s["null"]=s["true"]=s.undefined=!1;var u=p();for(u.array=t,u.cache=s,u.push=a;++ei?0:i);++n=S&&n===o,u=[];if(a){var c=f(e);c?(n=s,e=c):a=!1}for(;++r-1:void 0});return i.pop(),o.pop(),g&&(_(i),_(o)),s}function ae(t,e,r,n,i){(hi(e)?nr:Si)(e,function(e,o){var s,a,u=e,c=t[o];if(e&&((a=hi(e))||Ti(e))){for(var f=n.length;f--;)if(s=n[f]==e){c=i[f];break}if(!s){var h;r&&(u=r(c,e),(h="undefined"!=typeof u)&&(c=u)),h||(c=a?hi(c)?c:[]:Ti(c)?c:{}),n.push(e),i.push(c),h||ae(c,e,r,n,i)}}else r&&(u=r(c,e),"undefined"==typeof u&&(u=e)),"undefined"!=typeof u&&(c=u);t[o]=c})}function ue(t,e){return t+Un(oi()*(e-t+1))}function fe(t,e,r){var n=-1,i=_e(),a=t?t.length:0,u=[],c=!e&&a>=S&&i===o,h=r||c?l():u;if(c){var p=f(h);i=s,h=p}for(;++n3&&"function"==typeof e[r-2])var n=b(e[--r-1],e[r--],2);else r>2&&"function"==typeof e[r-1]&&(n=e[--r]);for(var i=v(arguments,1,r),o=-1,s=l(),a=l();++or?ri(0,o+r):r)||0,hi(t)?s=i(t,e,r)>-1:"number"==typeof o?s=(ze(t)?t.indexOf(e,r):i(t,e,r))>-1:wi(t,function(t){return++n>=r?!(s=t===e):void 0}),s}function Qe(t,r,n){var i=!0;if(r=e.createCallback(r,n,3),hi(t))for(var o=-1,s=t.length;++oo&&(o=c)}else r=null==r&&ze(t)?u:e.createCallback(r,n,3),wi(t,function(t,e,n){var s=r(t,e,n);s>i&&(i=s,o=t)});return o}function ur(t,r,n){var i=1/0,o=i;if("function"!=typeof r&&n&&n[r]===t&&(r=null),null==r&&hi(t))for(var s=-1,a=t.length;++sc&&(o=c)}else r=null==r&&ze(t)?u:e.createCallback(r,n,3),wi(t,function(t,e,n){var s=r(t,e,n);i>s&&(i=s,o=t)});return o}function cr(t,r,n,i){var o=arguments.length<3;if(r=e.createCallback(r,i,4),hi(t)){var s=-1,a=t.length;for(o&&(n=t[++s]);++sr?ri(0,n+r):r||0}else if(r){var i=Rr(t,e);return t[i]===e?i:-1}return o(t,e,r)}function Sr(t,r,n){var i=0,o=t?t.length:0;if("number"!=typeof r&&null!=r){var s=o;for(r=e.createCallback(r,n,3);s--&&r(t[s],s,t);)i++}else i=null==r||n?1:r||i;return v(t,0,ni(ri(0,o-i),o))}function Tr(){for(var t=[],e=-1,r=arguments.length,n=l(),i=_e(),a=i===o,u=l();++e=S&&f(e?t[e]:u)))}var h=t[0],p=-1,d=h?h.length:0,v=[];t:for(;++pr?ri(0,n+r):ni(r,n-1))+1);n--;)if(t[n]===e)return n;return-1}function jr(t){for(var e=arguments,r=0,n=e.length,i=t?t.length:0;++ro;){var a=o+s>>>1;n(t[a])1?arguments:arguments[0],e=-1,r=t?ar(Ci(t,"length")):0,n=wn(0>r?0:r);++e2?le(t,17,v(arguments,2),null,e):le(t,1,null,null,e)}function zr(t){for(var e=arguments.length>1?ie(arguments,!0,!1,1):ke(t),r=-1,n=e.length;++r2?le(e,19,v(arguments,2),null,t):le(e,3,null,null,t)}function Gr(){for(var t=arguments,e=t.length;e--;)if(!Ne(t[e]))throw new Bn;return function(){for(var e=arguments,r=t.length;r--;)e=[t[r].apply(this,e)];return e[0]}}function Vr(t,e){return e="number"==typeof e?e:+e||t.length,le(t,4,null,null,null,e)}function Kr(t,e,r){var n,i,o,s,a,u,c,f=0,h=!1,l=!0;if(!Ne(t))throw new Bn;if(e=ri(0,e)||0,r===!0){var p=!0;l=!1}else qe(r)&&(p=r.leading,h="maxWait"in r&&(ri(e,r.maxWait)||0),l="trailing"in r?r.trailing:l);var d=function(){var r=e-(Li()-s);if(0>=r){i&&Pn(i);var h=c;i=u=c=g,h&&(f=Li(),o=t.apply(a,n),u||i||(n=a=null))}else u=Xn(d,r)},_=function(){u&&Pn(u),i=u=c=g,(l||h!==e)&&(f=Li(),o=t.apply(a,n),u||i||(n=a=null))};return function(){if(n=arguments,s=Li(),a=this,c=l&&(u||!p),h===!1)var r=p&&!u;else{i||p||(f=s);var y=h-(s-f),v=0>=y;v?(i&&(i=Pn(i)),f=s,o=t.apply(a,n)):i||(i=Xn(_,y))}return v&&u?u=Pn(u):u||e===h||(u=Xn(d,e)),r&&(v=!0,o=t.apply(a,n)),!v||u||i||(n=a=null),o}}function Xr(t){if(!Ne(t))throw new Bn;var e=v(arguments,1);return Xn(function(){t.apply(g,e)},1)}function Zr(t,e){if(!Ne(t))throw new Bn;var r=v(arguments,2);return Xn(function(){t.apply(g,r)},e)}function Jr(t,e){if(!Ne(t))throw new Bn;var r=function(){var n=r.cache,i=e?e.apply(this,arguments):A+arguments[0];return Gn.call(n,i)?n[i]:n[i]=t.apply(this,arguments)};return r.cache={},r}function Yr(t){var e,r;if(!Ne(t))throw new Bn;return function(){return e?r:(e=!0,r=t.apply(this,arguments),t=null,r)}}function $r(t){return le(t,16,v(arguments,1))}function Wr(t){return le(t,32,null,v(arguments,1))}function Qr(t,e,r){var n=!0,i=!0;if(!Ne(t))throw new Bn;return r===!1?n=!1:qe(r)&&(n="leading"in r?r.leading:n,i="trailing"in r?r.trailing:i),te.leading=n,te.maxWait=e,te.trailing=i,Kr(t,e,te)}function tn(t,e){return le(e,16,[t])}function en(t){return function(){return t}}function rn(t,e,r){var n=typeof t;if(null==t||"function"==n)return b(t,e,r);if("object"!=n)return cn(t);var i=pi(t),o=i[0],s=t[o];return 1!=i.length||s!==s||qe(s)?function(e){for(var r=i.length,n=!1;r--&&(n=se(e[i[r]],t[i[r]],null,!0)););return n}:function(t){var e=t[o];return s===e&&(0!==s||1/s==1/e)}}function nn(t){return null==t?"":Cn(t).replace(bi,de)}function on(t){return t}function sn(t,n,i){var o=!0,s=n&&ke(n);n&&(i||s.length)||(null==i&&(i=n),a=r,n=t,t=e,s=ke(n)),i===!1?o=!1:qe(i)&&"chain"in i&&(o=i.chain);var a=t,u=Ne(a);nr(s,function(e){var r=t[e]=n[e];u&&(a.prototype[e]=function(){var e=this.__chain__,n=this.__wrapped__,i=[n];Vn.apply(i,arguments);var s=r.apply(t,i);if(o||e){if(n===s&&qe(s))return this;s=new a(s),s.__chain__=e}return s})})}function an(){return t._=Nn,this}function un(){}function cn(t){return function(e){return e[t]}}function fn(t,e,r){var n=null==t,i=null==e;if(null==r&&("boolean"==typeof t&&i?(r=t,t=1):i||"boolean"!=typeof e||(r=e,i=!0)),n&&i&&(e=1),t=+t||0,i?(e=t,t=0):e=+e||0,r||t%1||e%1){var o=oi();return ni(t+o*(e-t+parseFloat("1e-"+((o+"").length-1))),e)}return ue(t,e)}function hn(t,e){if(t){var r=t[e];return Ne(r)?t[e]():r}}function ln(t,r,n){var i=e.templateSettings;t=Cn(t||""),n=xi({},n,i);var o,s=xi({},n.imports,i.imports),a=pi(s),u=Ye(s),c=0,f=n.interpolate||q,l="__p += '",p=jn((n.escape||q).source+"|"+f.source+"|"+(f===D?L:q).source+"|"+(n.evaluate||q).source+"|$","g");t.replace(p,function(e,r,n,i,s,a){return n||(n=i),l+=t.slice(c,a).replace(F,h),r&&(l+="' +\n__e("+r+") +\n'"),s&&(o=!0,l+="';\n"+s+";\n__p += '"),n&&(l+="' +\n((__t = ("+n+")) == null ? '' : __t) +\n'"),c=a+e.length,e}),l+="';\n";var d=n.variable,_=d;_||(d="obj",l="with ("+d+") {\n"+l+"\n}\n"),l=(o?l.replace(j,""):l).replace(C,"$1").replace(B,"$1;"),l="function("+d+") {\n"+(_?"":d+" || ("+d+" = {});\n")+"var __t, __p = '', __e = _.escape"+(o?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+l+"return __p\n}";var y="\n/*\n//# sourceURL="+(n.sourceURL||"/lodash/template/source["+z++ +"]")+"\n*/";try{var v=Sn(a,"return "+l+y).apply(g,u)}catch(m){throw m.source=l,m}return r?v(r):(v.source=l,v)}function pn(t,e,r){t=(t=+t)>-1?t:0;var n=-1,i=wn(t);for(e=b(e,r,1);++n/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:D,variable:"",imports:{_:e}};var ci=function(t){var e="var index, iterable = "+t.firstArg+", result = "+t.init+";\nif (!iterable) return result;\n"+t.top+";";t.array?(e+="\nvar length = iterable.length; index = -1;\nif ("+t.array+") { ",ui.unindexedChars&&(e+="\n if (isString(iterable)) {\n iterable = iterable.split('')\n } "),e+="\n while (++index < length) {\n "+t.loop+";\n }\n}\nelse { "):ui.nonEnumArgs&&(e+="\n var length = iterable.length; index = -1;\n if (length && isArguments(iterable)) {\n while (++index < length) {\n index += '';\n "+t.loop+";\n }\n } else { "),ui.enumPrototypes&&(e+="\n var skipProto = typeof iterable == 'function';\n "),ui.enumErrorProps&&(e+="\n var skipErrorProps = iterable === errorProto || iterable instanceof Error;\n ");var r=[];if(ui.enumPrototypes&&r.push('!(skipProto && index == "prototype")'),ui.enumErrorProps&&r.push('!(skipErrorProps && (index == "message" || index == "name"))'),t.useHas&&t.keys)e+="\n var ownIndex = -1,\n ownProps = objectTypes[typeof iterable] && keys(iterable),\n length = ownProps ? ownProps.length : 0;\n\n while (++ownIndex < length) {\n index = ownProps[ownIndex];\n",r.length&&(e+=" if ("+r.join(" && ")+") {\n "),e+=t.loop+"; ",r.length&&(e+="\n }"),e+="\n } ";else if(e+="\n for (index in iterable) {\n",t.useHas&&r.push("hasOwnProperty.call(iterable, index)"),r.length&&(e+=" if ("+r.join(" && ")+") {\n "),e+=t.loop+"; ",r.length&&(e+="\n }"),e+="\n } ",ui.nonEnumShadows){for(e+="\n\n if (iterable !== objectProto) {\n var ctor = iterable.constructor,\n isProto = iterable === (ctor && ctor.prototype),\n className = iterable === stringProto ? stringClass : iterable === errorProto ? errorClass : toString.call(iterable),\n nonEnum = nonEnumProps[className];\n ",k=0;7>k;k++)e+="\n index = '"+t.shadowedProps[k]+"';\n if ((!(isProto && nonEnum[index]) && hasOwnProperty.call(iterable, index))",t.useHas||(e+=" || (!nonEnum[index] && iterable[index] !== objectProto[index])"),e+=") {\n "+t.loop+";\n } ";e+="\n } "}return(t.array||ui.nonEnumArgs)&&(e+="\n}"),e+=t.bottom+";\nreturn result"};$n||(a=function(){function e(){}return function(r){if(qe(r)){e.prototype=r;var n=new e;e.prototype=null}return n||t.Object()}}());var fi=Yn?function(t,e){ee.value=e,Yn(t,"__bindData__",ee)}:un;ui.argsClass||(ge=function(t){return t&&"object"==typeof t&&"number"==typeof t.length&&Gn.call(t,"callee")&&!Kn.call(t,"callee")||!1});var hi=Wn||function(t){return t&&"object"==typeof t&&"number"==typeof t.length&&qn.call(t)==G||!1},li=pe({args:"object",init:"[]",top:"if (!(objectTypes[typeof object])) return result",loop:"result.push(index)"}),pi=ei?function(t){return qe(t)?ui.enumPrototypes&&"function"==typeof t||ui.nonEnumArgs&&t.length&&ge(t)?li(t):ei(t):[]}:li,di={args:"collection, callback, thisArg",top:"callback = callback && typeof thisArg == 'undefined' ? callback : baseCreateCallback(callback, thisArg, 3)",array:"typeof length == 'number'",keys:pi,loop:"if (callback(iterable[index], index, collection) === false) return result"},_i={args:"object, source, guard",top:"var args = arguments,\n argsIndex = 0,\n argsLength = typeof guard == 'number' ? 2 : args.length;\nwhile (++argsIndex < argsLength) {\n iterable = args[argsIndex];\n if (iterable && objectTypes[typeof iterable]) {",keys:pi,loop:"if (typeof result[index] == 'undefined') result[index] = iterable[index]",bottom:" }\n}"},yi={top:"if (!objectTypes[typeof iterable]) return result;\n"+di.top,array:!1},vi={"&":"&","<":"<",">":">",'"':""","'":"'"},mi=je(vi),gi=jn("("+pi(mi).join("|")+")","g"),bi=jn("["+pi(vi).join("")+"]","g"),wi=pe(di),Ei=pe(_i,{top:_i.top.replace(";",";\nif (argsLength > 3 && typeof args[argsLength - 2] == 'function') {\n var callback = baseCreateCallback(args[--argsLength - 1], args[argsLength--], 2);\n} else if (argsLength > 2 && typeof args[argsLength - 1] == 'function') {\n callback = args[--argsLength];\n}"),loop:"result[index] = callback ? callback(result[index], iterable[index]) : iterable[index]"}),xi=pe(_i),Ai=pe(di,yi,{useHas:!1}),Si=pe(di,yi);Ne(/x/)&&(Ne=function(t){return"function"==typeof t&&qn.call(t)==Z});var Ti=Hn?function(t){if(!t||qn.call(t)!=Y||!ui.argsClass&&ge(t))return!1;var e=t.valueOf,r=ye(e)&&(r=Hn(e))&&Hn(r);return r?t==r||Hn(t)==r:ve(t)}:ve,ki=he(function(t,e,r){Gn.call(t,r)?t[r]++:t[r]=1}),Ii=he(function(t,e,r){(Gn.call(t,r)?t[r]:t[r]=[]).push(e)}),ji=he(function(t,e,r){t[r]=e}),Ci=sr,Bi=tr,Li=ye(Li=xn.now)&&Li||function(){return(new xn).getTime()},Ri=8==ii(I+"08")?ii:function(t,e){return ii(ze(t)?t.replace(N,""):t,e||0)};return e.after=Pr,e.assign=Ei,e.at=$e,e.bind=Ur,e.bindAll=zr,e.bindKey=Hr,e.chain=yn,e.compact=mr,e.compose=Gr,e.constant=en,e.countBy=ki,e.create=Ee,e.createCallback=rn,e.curry=Vr,e.debounce=Kr,e.defaults=xi,e.defer=Xr,e.delay=Zr,e.difference=gr,e.filter=tr,e.flatten=xr,e.forEach=nr,e.forEachRight=ir,e.forIn=Ai,e.forInRight=Se,e.forOwn=Si,e.forOwnRight=Te,e.functions=ke,e.groupBy=Ii,e.indexBy=ji,e.initial=Sr,e.intersection=Tr,e.invert=je,e.invoke=or,e.keys=pi,e.map=sr,e.mapValues=Ge,e.max=ar,e.memoize=Jr,e.merge=Ve,e.min=ur,e.omit=Ke,e.once=Yr,e.pairs=Xe,e.partial=$r,e.partialRight=Wr,e.pick=Ze,e.pluck=Ci,e.property=cn,e.pull=jr,e.range=Cr,e.reject=hr,e.remove=Br,e.rest=Lr,e.shuffle=pr,e.sortBy=yr,e.tap=vn,e.throttle=Qr,e.times=pn,e.toArray=vr,e.transform=Je,e.union=Or,e.uniq=Dr,e.values=Ye,e.where=Bi,e.without=Nr,e.wrap=tn,e.xor=qr,e.zip=Mr,e.zipObject=Fr,e.collect=sr,e.drop=Lr,e.each=nr,e.eachRight=ir,e.extend=Ei,e.methods=ke,e.object=Fr,e.select=tr,e.tail=Lr,e.unique=Dr,e.unzip=Mr,sn(e),e.clone=be,e.cloneDeep=we,e.contains=We,e.escape=nn,e.every=Qe,e.find=er,e.findIndex=br,e.findKey=xe,e.findLast=rr,e.findLastIndex=wr,e.findLastKey=Ae,e.has=Ie,e.identity=on,e.indexOf=Ar,e.isArguments=ge,e.isArray=hi,e.isBoolean=Ce,e.isDate=Be,e.isElement=Le,e.isEmpty=Re,e.isEqual=Oe,e.isFinite=De,e.isFunction=Ne,e.isNaN=Me,e.isNull=Fe,e.isNumber=Pe,e.isObject=qe,e.isPlainObject=Ti,e.isRegExp=Ue,e.isString=ze,e.isUndefined=He,e.lastIndexOf=Ir,e.mixin=sn,e.noConflict=an,e.noop=un,e.now=Li,e.parseInt=Ri,e.random=fn,e.reduce=cr,e.reduceRight=fr,e.result=hn,e.runInContext=m,e.size=dr,e.some=_r,e.sortedIndex=Rr,e.template=ln,e.unescape=dn,e.uniqueId=_n,e.all=Qe,e.any=_r,e.detect=er,e.findWhere=er,e.foldl=cr,e.foldr=fr,e.include=We,e.inject=cr,sn(function(){var t={};return Si(e,function(r,n){e.prototype[n]||(t[n]=r)}),t}(),!1),e.first=Er,e.last=kr,e.sample=lr,e.take=Er,e.head=Er,Si(e,function(t,n){var i="sample"!==n;e.prototype[n]||(e.prototype[n]=function(e,n){var o=this.__chain__,s=t(this.__wrapped__,e,n);return o||null!=e&&(!n||i&&"function"==typeof e)?new r(s,o):s})}),e.VERSION="2.4.1",e.prototype.chain=mn,e.prototype.toString=gn,e.prototype.value=bn,e.prototype.valueOf=bn,wi(["join","pop","shift"],function(t){var n=Ln[t];e.prototype[t]=function(){var t=this.__chain__,e=n.apply(this.__wrapped__,arguments);return t?new r(e,t):e}}),wi(["push","reverse","sort","unshift"],function(t){var r=Ln[t];e.prototype[t]=function(){return r.apply(this.__wrapped__,arguments),this}}),wi(["concat","slice","splice"],function(t){var n=Ln[t];e.prototype[t]=function(){return new r(n.apply(this.__wrapped__,arguments),this.__chain__)}}),ui.spliceObjects||wi(["pop","shift","splice"],function(t){var n=Ln[t],i="splice"==t;e.prototype[t]=function(){var t=this.__chain__,e=this.__wrapped__,o=n.apply(e,arguments);return 0===e.length&&delete e[0],t||i?new r(o,t):o}}),e}var g,b=[],w=[],E=0,x={},A=+new Date+"",S=75,T=40,I=" \f \n\r\u2028\u2029 ᠎              ",j=/\b__p \+= '';/g,C=/\b(__p \+=) '' \+/g,B=/(__e\(.*?\)|\b__t\)) \+\n'';/g,L=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,R=/\w*$/,O=/^\s*function[ \n\r\t]+\w/,D=/<%=([\s\S]+?)%>/g,N=RegExp("^["+I+"]*0+(?=.$)"),q=/($^)/,M=/\bthis\b/,F=/['\n\r\t\u2028\u2029\\]/g,P=["Array","Boolean","Date","Error","Function","Math","Number","Object","RegExp","String","_","attachEvent","clearTimeout","isFinite","isNaN","parseInt","setTimeout"],U=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],z=0,H="[object Arguments]",G="[object Array]",V="[object Boolean]",K="[object Date]",X="[object Error]",Z="[object Function]",J="[object Number]",Y="[object Object]",$="[object RegExp]",W="[object String]",Q={};Q[Z]=!1,Q[H]=Q[G]=Q[V]=Q[K]=Q[J]=Q[Y]=Q[$]=Q[W]=!0;var te={leading:!1,maxWait:0,trailing:!1},ee={configurable:!1,enumerable:!1,value:null,writable:!1},re={args:"",array:null,bottom:"",firstArg:"",init:"",keys:null,loop:"",shadowedProps:null,support:null,top:"",useHas:!1},ne={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},ie={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"},oe=ne[typeof window]&&window||this,se=ne[typeof e]&&e&&!e.nodeType&&e,ae=ne[typeof t]&&t&&!t.nodeType&&t,ue=(ae&&ae.exports===se&&se,ne[typeof i]&&i);!ue||ue.global!==ue&&ue.window!==ue||(oe=ue);var ce=m();oe._=ce,n=function(){return ce}.call(e,r,e,t),!(n!==g&&(t.exports=n))}).call(this)}).call(e,r(71)(t),function(){return this}())},function(t,e,r){"use strict";e.decode=e.parse=r(63),e.encode=e.stringify=r(64)},function(t,e,r){(function(e){!function(){var r,n,i=this;r=function(t){for(var r,r,n=new e(t),i=0;t>i;i++)0==(3&i)&&(r=4294967296*Math.random()),n[i]=r>>>((3&i)<<3)&255;return n},i.crypto&&crypto.getRandomValues&&(n=function(t){var r=new e(t);return crypto.getRandomValues(r),r}),t.exports=n||r}()}).call(e,r(43).Buffer)},function(t,e,r){(function(e){function n(t){return function(){var r=[],n={update:function(t,n){return e.isBuffer(t)||(t=new e(t,n)),r.push(t),this},digest:function(n){var i=e.concat(r),o=t(i);return r=null,n?o.toString(n):o}};return n}}var i=r(72),o=n(r(66)),s=n(r(75));t.exports=function(t){return"md5"===t?new o:"rmd160"===t?new s:i(t)}}).call(e,r(43).Buffer)},function(t,e,r){(function(e){function n(t,r){if(!(this instanceof n))return new n(t,r);this._opad=u,this._alg=t,r=this._key=e.isBuffer(r)?r:new e(r),r.length>o?r=i(t).update(r).digest():r.lengthc;c++)a[c]=54^r[c],u[c]=92^r[c];this._hash=i(t).update(a)}var i=r(53),o=64,s=new e(o);s.fill(0),t.exports=n,n.prototype.update=function(t,e){return this._hash.update(t,e),this},n.prototype.digest=function(t){var e=this._hash.digest();return i(this._alg).update(this._opad).update(e).digest(t)}}).call(e,r(43).Buffer)},function(t,e,r){(function(e){var r=64,n=new e(r);n.fill(0),t.exports=function(t,i){return i=i||{},i.pbkdf2=function(t,e,r,n,o){if("function"!=typeof o)throw new Error("No callback provided to pbkdf2");setTimeout(function(){o(null,i.pbkdf2Sync(t,e,r,n))})},i.pbkdf2Sync=function(i,o,s,a){if("number"!=typeof s)throw new TypeError("Iterations not a number");if(0>s)throw new TypeError("Bad iterations");if("number"!=typeof a)throw new TypeError("Key length not a number");if(0>a)throw new TypeError("Bad key length");var i=e.isBuffer(i)?i:new e(i);i.length>r?i=createHash(alg).update(i).digest():i.length20?20:a,p[0]=l>>24&255,p[1]=l>>16&255,p[2]=l>>8&255,p[3]=255&l,u=t("sha1",i),u.update(o),u.update(p),f=u.digest(),f.copy(d,h,0,c);for(var _=1;s>_;_++){u=t("sha1",i),u.update(f),f=u.digest();for(var y=0;c>y;y++)d[y]^=f[y]}a-=c,l++,h+=c}return d},i}}).call(e,r(43).Buffer)},function(t){t.exports=function(t){return t&&"object"==typeof t&&"function"==typeof t.copy&&"function"==typeof t.fill&&"function"==typeof t.readUInt8}},function(t){t.exports=function(t){var e=t.sjcl,r=function(){var t={ripple:"rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz",bitcoin:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"},n=function(t){return e.codec.bytes.fromBits(e.hash.sha256.hash(e.codec.bytes.toBits(t)))};return{encode_base:function(r,n){for(var i=t[n||"ripple"],o=new e.bn(i.length),s=e.bn.fromBits(e.codec.bytes.toBits(r)),a=[];s.greaterEquals(o);){var u=s.mod(o);a.push(i[u.limbs[0]]),s=s.div(o)}a.push(i[s.limbs[0]]);for(var c=0;c!=r.length&&!r[c];c+=1)a.push(i[0]);return a.reverse().join("")},decode_base:function(r,n){for(var i,o=t[n||"ripple"],s=new e.bn(o.length),a=new e.bn(0);i!=r.length&&r[i]===o[0];)i+=1;for(i=0;i!=r.length;i+=1){var u=o.indexOf(r[i]);if(0>u)return null;a=a.mul(s).addM(u)}for(var c=e.codec.bytes.fromBits(a.toBits()).reverse();0===c[c.length-1];)c.pop();for(i=0;r[i]===o[0];i++)c.push(0);return c.reverse(),c},encode_base_check:function(t,e,i){var o=[].concat(t,e),s=n(n(o)).slice(0,4);return r.encode_base([].concat(o,s),i)},decode_base_check:function(t,e,i){var o=r.decode_base(e,i);if(!o||o[0]!==t||o.length<5)return 0/0;var s,a=n(n(o.slice(0,-4))).slice(0,4),u=o.slice(-4);for(s=0;4!=s;s+=1)if(a[s]!==u[s])return 0/0;return o.slice(1,-4)}}}();return r}},function(t,e,r){t.exports=function(t){function e(t){this.value=t}var n=t.sjcl,i=r(57)({sjcl:n});return e.fromBytes=function(t){return new e(i.encode_base_check(33,t))},e.getRandom=function(){for(var t=0;8>t;t++)n.random.addEntropy(Math.random(),32,"Math.random()");var r=n.codec.bytes.fromBits(n.random.randomWords(4));return e.fromBytes(r)},e}},function(t,e,r){t.exports=function(t){function e(t){return i.hash.ripemd160.hash(i.hash.sha256.hash(t))}function n(t){this.value=t}var i=t.sjcl,o=r(57)({sjcl:i});return n.fromPublicKey=function(t){var r=i.codec.bytes.fromBits(e(i.codec.bytes.toBits(t.toBytesCompressed())));return new this(o.encode_base_check(0,r))},n}},function(t){t.exports=function(t){function e(t){if(!(t instanceof r.ecc.point))throw new Error("eccPoint must be a sjcl.ecc.point");this.value=t}var r=t.sjcl;return e.fromPrivateGenerator=function(t){return new this(r.ecc.curves.c256.G.mult(t))},e.prototype={toString:function(){return this.value.toString()}},e}},function(t){function e(){}var r=t.exports={};r.nextTick=function(){var t="undefined"!=typeof window&&window.setImmediate,e="undefined"!=typeof window&&window.postMessage&&window.addEventListener;if(t)return function(t){return window.setImmediate(t)};if(e){var r=[];return window.addEventListener("message",function(t){var e=t.source;if((e===window||null===e)&&"process-tick"===t.data&&(t.stopPropagation(),r.length>0)){var n=r.shift();n()}},!0),function(t){r.push(t),window.postMessage("process-tick","*")}}return function(t){setTimeout(t,0)}}(),r.title="browser",r.browser=!0,r.env={},r.argv=[],r.on=e,r.once=e,r.off=e,r.emit=e,r.binding=function(){throw new Error("process.binding is not supported")},r.cwd=function(){return"/"},r.chdir=function(){throw new Error("process.chdir is not supported")}},function(t,e,r){function n(){}function i(t){var e={}.toString.call(t);switch(e){case"[object File]":case"[object Blob]":case"[object FormData]":return!0;default:return!1}}function o(){if(v.XMLHttpRequest&&("file:"!=v.location.protocol||!v.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){}return!1}function s(t){return t===Object(t)}function a(t){if(!s(t))return t;var e=[];for(var r in t)null!=t[r]&&e.push(encodeURIComponent(r)+"="+encodeURIComponent(t[r]));return e.join("&")}function u(t){for(var e,r,n={},i=t.split("&"),o=0,s=i.length;s>o;++o)r=i[o],e=r.split("="),n[decodeURIComponent(e[0])]=decodeURIComponent(e[1]);return n}function c(t){var e,r,n,i,o=t.split(/\r?\n/),s={};o.pop();for(var a=0,u=o.length;u>a;++a)r=o[a],e=r.indexOf(":"),n=r.slice(0,e).toLowerCase(),i=m(r.slice(e+1)),s[n]=i;return s}function f(t){return t.split(/ *; */).shift()}function h(t){return y(t.split(/ *; */),function(t,e){var r=e.split(/ *= */),n=r.shift(),i=r.shift();return n&&i&&(t[n]=i),t},{})}function l(t,e){e=e||{},this.req=t,this.xhr=this.req.xhr,this.text=this.xhr.responseText,this.setStatusProperties(this.xhr.status),this.header=this.headers=c(this.xhr.getAllResponseHeaders()),this.header["content-type"]=this.xhr.getResponseHeader("content-type"),this.setHeaderProperties(this.header),this.body="HEAD"!=this.req.method?this.parseBody(this.text):null}function p(t,e){var r=this;_.call(this),this._query=this._query||[],this.method=t,this.url=e,this.header={},this._header={},this.on("end",function(){var e=new l(r);"HEAD"==t&&(e.text=null),r.callback(null,e)})}function d(t,e){return"function"==typeof e?new p("GET",t).end(e):1==arguments.length?new p("GET",t):new p(t,e)}var _=r(76),y=r(77),v="undefined"==typeof window?this:window,m="".trim?function(t){return t.trim()}:function(t){return t.replace(/(^\s*|\s*$)/g,"")};d.serializeObject=a,d.parseString=u,d.types={html:"text/html",json:"application/json",xml:"application/xml",urlencoded:"application/x-www-form-urlencoded",form:"application/x-www-form-urlencoded","form-data":"application/x-www-form-urlencoded"},d.serialize={"application/x-www-form-urlencoded":a,"application/json":JSON.stringify},d.parse={"application/x-www-form-urlencoded":u,"application/json":JSON.parse},l.prototype.get=function(t){return this.header[t.toLowerCase()]},l.prototype.setHeaderProperties=function(){var t=this.header["content-type"]||"";this.type=f(t);var e=h(t);for(var r in e)this[r]=e[r]},l.prototype.parseBody=function(t){var e=d.parse[this.type];return e?e(t):null},l.prototype.setStatusProperties=function(t){var e=t/100|0;this.status=t,this.statusType=e,this.info=1==e,this.ok=2==e,this.clientError=4==e,this.serverError=5==e,this.error=4==e||5==e?this.toError():!1,this.accepted=202==t,this.noContent=204==t||1223==t,this.badRequest=400==t,this.unauthorized=401==t,this.notAcceptable=406==t,this.notFound=404==t,this.forbidden=403==t},l.prototype.toError=function(){var t=this.req,e=t.method,r=t.url,n="cannot "+e+" "+r+" ("+this.status+")",i=new Error(n);return i.status=this.status,i.method=e,i.url=r,i},d.Response=l,_(p.prototype),p.prototype.use=function(t){return t(this),this},p.prototype.timeout=function(t){return this._timeout=t,this},p.prototype.clearTimeout=function(){return this._timeout=0,clearTimeout(this._timer),this},p.prototype.abort=function(){return this.aborted?void 0:(this.aborted=!0,this.xhr.abort(),this.clearTimeout(),this.emit("abort"),this)},p.prototype.set=function(t,e){if(s(t)){for(var r in t)this.set(r,t[r]);return this}return this._header[t.toLowerCase()]=e,this.header[t]=e,this},p.prototype.getHeader=function(t){return this._header[t.toLowerCase()]},p.prototype.type=function(t){return this.set("Content-Type",d.types[t]||t),this},p.prototype.accept=function(t){return this.set("Accept",d.types[t]||t),this},p.prototype.auth=function(t,e){var r=btoa(t+":"+e);return this.set("Authorization","Basic "+r),this},p.prototype.query=function(t){return"string"!=typeof t&&(t=a(t)),t&&this._query.push(t),this},p.prototype.field=function(t,e){return this._formData||(this._formData=new FormData),this._formData.append(t,e),this},p.prototype.attach=function(t,e,r){return this._formData||(this._formData=new FormData),this._formData.append(t,e,r),this},p.prototype.send=function(t){var e=s(t),r=this.getHeader("Content-Type");if(e&&s(this._data))for(var n in t)this._data[n]=t[n];else"string"==typeof t?(r||this.type("form"),r=this.getHeader("Content-Type"),this._data="application/x-www-form-urlencoded"==r?this._data?this._data+"&"+t:t:(this._data||"")+t):this._data=t;return e?(r||this.type("json"),this):this},p.prototype.callback=function(t,e){var r=this._callback;return 2==r.length?r(t,e):t?this.emit("error",t):(r(e),void 0)},p.prototype.crossDomainError=function(){var t=new Error("Origin is not allowed by Access-Control-Allow-Origin");t.crossDomain=!0,this.callback(t)},p.prototype.timeoutError=function(){var t=this._timeout,e=new Error("timeout of "+t+"ms exceeded");e.timeout=t,this.callback(e)},p.prototype.withCredentials=function(){return this._withCredentials=!0,this},p.prototype.end=function(t){var e=this,r=this.xhr=o(),s=this._query.join("&"),a=this._timeout,u=this._formData||this._data;if(this._callback=t||n,r.onreadystatechange=function(){return 4==r.readyState?0==r.status?e.aborted?e.timeoutError():e.crossDomainError():(e.emit("end"),void 0):void 0},r.upload&&(r.upload.onprogress=function(t){t.percent=t.loaded/t.total*100,e.emit("progress",t)}),a&&!this._timer&&(this._timer=setTimeout(function(){e.abort()},a)),s&&(s=d.serializeObject(s),this.url+=~this.url.indexOf("?")?"&"+s:"?"+s),r.open(this.method,this.url,!0),this._withCredentials&&(r.withCredentials=!0),"GET"!=this.method&&"HEAD"!=this.method&&"string"!=typeof u&&!i(u)){var c=d.serialize[this.getHeader("Content-Type")];c&&(u=c(u))}for(var f in this.header)null!=this.header[f]&&r.setRequestHeader(f,this.header[f]);return this.emit("request",this),r.send(u),this},d.Request=p,d.get=function(t,e,r){var n=d("GET",t);return"function"==typeof e&&(r=e,e=null),e&&n.query(e),r&&n.end(r),n},d.head=function(t,e,r){var n=d("HEAD",t); return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n},d.del=function(t,e){var r=d("DELETE",t);return e&&r.end(e),r},d.patch=function(t,e,r){var n=d("PATCH",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n},d.post=function(t,e,r){var n=d("POST",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n},d.put=function(t,e,r){var n=d("PUT",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n},t.exports=d},function(t){"use strict";function e(t,e){return Object.prototype.hasOwnProperty.call(t,e)}t.exports=function(t,n,i,o){n=n||"&",i=i||"=";var s={};if("string"!=typeof t||0===t.length)return s;var a=/\+/g;t=t.split(n);var u=1e3;o&&"number"==typeof o.maxKeys&&(u=o.maxKeys);var c=t.length;u>0&&c>u&&(c=u);for(var f=0;c>f;++f){var h,l,p,d,_=t[f].replace(a,"%20"),y=_.indexOf(i);y>=0?(h=_.substr(0,y),l=_.substr(y+1)):(h=_,l=""),p=decodeURIComponent(h),d=decodeURIComponent(l),e(s,p)?r(s[p])?s[p].push(d):s[p]=[s[p],d]:s[p]=d}return s};var r=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)}},function(t){"use strict";function e(t,e){if(t.map)return t.map(e);for(var r=[],n=0;n>1,f=-7,h=r?i-1:0,l=r?-1:1,p=t[e+h];for(h+=l,o=p&(1<<-f)-1,p>>=-f,f+=a;f>0;o=256*o+t[e+h],h+=l,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+t[e+h],h+=l,f-=8);if(0===o)o=1-c;else{if(o===u)return s?0/0:1/0*(p?-1:1);s+=Math.pow(2,n),o-=c}return(p?-1:1)*s*Math.pow(2,o-n)},e.write=function(t,e,r,n,i,o){var s,a,u,c=8*o-i-1,f=(1<>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,d=n?1:-1,_=0>e||0===e&&0>1/e?1:0;for(e=Math.abs(e),isNaN(e)||1/0===e?(a=isNaN(e)?1:0,s=f):(s=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-s))<1&&(s--,u*=2),e+=s+h>=1?l/u:l*Math.pow(2,1-h),e*u>=2&&(s++,u/=2),s+h>=f?(a=0,s=f):s+h>=1?(a=(e*u-1)*Math.pow(2,i),s+=h):(a=e*Math.pow(2,h-1)*Math.pow(2,i),s=0));i>=8;t[r+p]=255&a,p+=d,a/=256,i-=8);for(s=s<0;t[r+p]=255&s,p+=d,s/=256,c-=8);t[r+p-d]|=128*_}},function(t,e,r){function n(t,e){t[e>>5]|=128<>>9<<4)+14]=e;for(var r=1732584193,n=-271733879,i=-1732584194,f=271733878,h=0;h>16)+(e>>16)+(r>>16);return n<<16|65535&r}function f(t,e){return t<>>32-e}var h=r(73);t.exports=function(t){return h.hash(t,n,16)}},function(t){t.exports="function"==typeof Object.create?function(t,e){t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}:function(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}},function(t,e,r){var n,i;(function(t){!function(o){function s(t){throw RangeError(R[t])}function a(t,e){for(var r=t.length;r--;)t[r]=e(t[r]);return t}function u(t,e){var r=".";return a(t.split(r),e).join(r)}function c(t){for(var e,r,n=[],i=0,o=t.length;o>i;)e=t.charCodeAt(i++),55296==(63488&e)&&(r=t.charCodeAt(i++),(55296!=(64512&e)||56320!=(64512&r))&&s("ucs2decode"),e=((1023&e)<<10)+(1023&r)+65536),n.push(e);return n}function f(t){return a(t,function(t){var e="";return 55296==(63488&t)&&s("ucs2encode"),t>65535&&(t-=65536,e+=N(t>>>10&1023|55296),t=56320|1023&t),e+=N(t)}).join("")}function h(t){return 10>t-48?t-22:26>t-65?t-65:26>t-97?t-97:x}function l(t,e){return t+22+75*(26>t)-((0!=e)<<5)}function p(t,e,r){var n=0;for(t=r?D(t/k):t>>1,t+=D(t/e);t>O*S>>1;n+=x)t=D(t/O);return D(n+(O+1)*t/(t+T))}function d(t){var e,r,n,i,o,a,u,c,l,d,_=[],y=t.length,v=0,m=j,g=I;for(r=t.lastIndexOf(C),0>r&&(r=0),n=0;r>n;++n)t.charCodeAt(n)>=128&&s("not-basic"),_.push(t.charCodeAt(n));for(i=r>0?r+1:0;y>i;){for(o=v,a=1,u=x;i>=y&&s("invalid-input"),c=h(t.charCodeAt(i++)),(c>=x||c>D((E-v)/a))&&s("overflow"),v+=c*a,l=g>=u?A:u>=g+S?S:u-g,!(l>c);u+=x)d=x-l,a>D(E/d)&&s("overflow"),a*=d;e=_.length+1,g=p(v-o,e,0==o),D(v/e)>E-m&&s("overflow"),m+=D(v/e),v%=e,_.splice(v++,0,m)}return f(_)}function _(t){var e,r,n,i,o,a,u,f,h,d,_,y,v,m,g,b=[];for(t=c(t),y=t.length,e=j,r=0,o=I,a=0;y>a;++a)_=t[a],128>_&&b.push(N(_));for(n=i=b.length,i&&b.push(C);y>n;){for(u=E,a=0;y>a;++a)_=t[a],_>=e&&u>_&&(u=_);for(v=n+1,u-e>D((E-r)/v)&&s("overflow"),r+=(u-e)*v,e=u,a=0;y>a;++a)if(_=t[a],e>_&&++r>E&&s("overflow"),_==e){for(f=r,h=x;d=o>=h?A:h>=o+S?S:h-o,!(d>f);h+=x)g=f-d,m=x-d,b.push(N(l(d+g%m,0))),f=D(g/m);b.push(N(l(f,0))),o=p(r,v,n==i),r=0,++n}++r,++e}return b.join("")}function y(t){return u(t,function(t){return L.test(t)?d(t.slice(4).toLowerCase()):t})}function v(t){return u(t,function(t){return B.test(t)?"xn--"+_(t):t})}var m,g,b=(r(74),"object"==typeof e&&e),w="object"==typeof t&&t,E=2147483647,x=36,A=1,S=26,T=38,k=700,I=72,j=128,C="-",B=/[^ -~]/,L=/^xn--/,R={overflow:"Overflow: input needs wider integers to process.",ucs2decode:"UCS-2(decode): illegal sequence",ucs2encode:"UCS-2(encode): illegal value","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},O=x-A,D=Math.floor,N=String.fromCharCode;if(m={version:"1.0.0",ucs2:{decode:c,encode:f},decode:d,encode:_,toASCII:v,toUnicode:y},b)if(w&&w.exports==b)w.exports=m;else for(g in m)m.hasOwnProperty(g)&&(b[g]=m[g]);else r(74)?(n=m,!("function"==typeof n?(i=n.call(e,r,e,t),void 0!==i&&(t.exports=i)):t.exports=n)):o.punycode=m}(this)}).call(e,r(71)(t))},function(t,e,r){var n;n=function(t,e,r,n){"use strict";var i=e;i.unescape=decodeURIComponent,i.escape=encodeURIComponent;var o=function(t){switch(typeof t){case"string":return t;case"boolean":return t?"true":"false";case"number":return isFinite(t)?t:"";default:return""}};i.stringify=i.encode=function(t,e,r,s){switch(e=e||"&",r=r||"=",t=null===t?n:t,typeof t){case"object":return Object.keys(t).map(function(n){return Array.isArray(t[n])?t[n].map(function(t){return i.escape(o(n))+r+i.escape(o(t))}).join(e):i.escape(o(n))+r+i.escape(o(t[n]))}).join(e);default:return s?i.escape(o(s))+r+i.escape(o(t)):""}},i.parse=i.decode=function(t,e,r){e=e||"&",r=r||"=";var n={};return"string"!=typeof t||0===t.length?n:(t.split(e).forEach(function(t){var e=t.split(r),o=i.unescape(e[0],!0),s=i.unescape(e.slice(1).join(r),!0);o in n?Array.isArray(n[o])?n[o].push(s):n[o]=[n[o],s]:n[o]=s}),n)}}.call(e,r,e,t),!(void 0!==n&&(t.exports=n))},function(t,e){var r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";!function(t){"use strict";function e(t){var e=t.charCodeAt(0);return e===s||e===h?62:e===a||e===l?63:u>e?-1:u+10>e?e-u+26+26:f+26>e?e-f:c+26>e?e-c+26:void 0}function n(t){function r(t){c[h++]=t}var n,i,s,a,u,c;if(t.length%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var f=t.length;u="="===t.charAt(f-2)?2:"="===t.charAt(f-1)?1:0,c=new o(3*t.length/4-u),s=u>0?t.length-4:t.length;var h=0;for(n=0,i=0;s>n;n+=4,i+=3)a=e(t.charAt(n))<<18|e(t.charAt(n+1))<<12|e(t.charAt(n+2))<<6|e(t.charAt(n+3)),r((16711680&a)>>16),r((65280&a)>>8),r(255&a);return 2===u?(a=e(t.charAt(n))<<2|e(t.charAt(n+1))>>4,r(255&a)):1===u&&(a=e(t.charAt(n))<<10|e(t.charAt(n+1))<<4|e(t.charAt(n+2))>>2,r(a>>8&255),r(255&a)),c}function i(t){function e(t){return r.charAt(t)}function n(t){return e(t>>18&63)+e(t>>12&63)+e(t>>6&63)+e(63&t)}var i,o,s,a=t.length%3,u="";for(i=0,s=t.length-a;s>i;i+=3)o=(t[i]<<16)+(t[i+1]<<8)+t[i+2],u+=n(o);switch(a){case 1:o=t[t.length-1],u+=e(o>>2),u+=e(o<<4&63),u+="==";break;case 2:o=(t[t.length-2]<<8)+t[t.length-1],u+=e(o>>10),u+=e(o>>4&63),u+=e(o<<2&63),u+="="}return u}var o="undefined"!=typeof Uint8Array?Uint8Array:Array,s="+".charCodeAt(0),a="/".charCodeAt(0),u="0".charCodeAt(0),c="a".charCodeAt(0),f="A".charCodeAt(0),h="-".charCodeAt(0),l="_".charCodeAt(0);t.toByteArray=n,t.fromByteArray=i}("undefined"==typeof e?this.base64js={}:e)},function(t){t.exports=function(t){return t.webpackPolyfill||(t.deprecate=function(){},t.paths=[],t.children=[],t.webpackPolyfill=1),t}},function(t,e,r){var e=t.exports=function(t){var r=e[t];if(!r)throw new Error(t+" is not supported (we accept pull requests)");return new r},n=r(81).Buffer,i=r(78)(n);e.sha=e.sha1=r(79)(n,i),e.sha256=r(80)(n,i)},function(t,e,r){(function(e){function r(t,r){if(t.length%o!==0){var n=t.length+(o-t.length%o);t=e.concat([t,s],n)}for(var i=[],a=r?t.readInt32BE:t.readInt32LE,u=0;u>>32-e}function u(t){var r=[1732584193,4023233417,2562383102,271733878,3285377520];"string"==typeof t&&(t=new e(t,"utf8"));var n=_(t),i=8*t.length,o=8*t.length;n[i>>>5]|=128<<24-i%32,n[(i+64>>>9<<4)+14]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8);for(var s=0;ss;s++){var a=r[s];r[s]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8)}var u=y(r);return new e(u)}t.exports=u;var c=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],f=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],h=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],l=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11],p=[0,1518500249,1859775393,2400959708,2840853838],d=[1352829926,1548603684,1836072691,2053994217,0],_=function(t){for(var e=[],r=0,n=0;r>>5]|=t[r]<<24-n%32;return e},y=function(t){for(var e=[],r=0;r<32*t.length;r+=8)e.push(t[r>>>5]>>>24-r%32&255);return e},v=function(t,e,u){for(var _=0;16>_;_++){var y=u+_,v=e[y];e[y]=16711935&(v<<8|v>>>24)|4278255360&(v<<24|v>>>8)}var m,g,b,w,E,x,A,S,T,k;x=m=t[0],A=g=t[1],S=b=t[2],T=w=t[3],k=E=t[4];for(var I,_=0;80>_;_+=1)I=m+e[u+c[_]]|0,I+=16>_?r(g,b,w)+p[0]:32>_?n(g,b,w)+p[1]:48>_?i(g,b,w)+p[2]:64>_?o(g,b,w)+p[3]:s(g,b,w)+p[4],I=0|I,I=a(I,h[_]),I=I+E|0,m=E,E=w,w=a(b,10),b=g,g=I,I=x+e[u+f[_]]|0,I+=16>_?s(A,S,T)+d[0]:32>_?o(A,S,T)+d[1]:48>_?i(A,S,T)+d[2]:64>_?n(A,S,T)+d[3]:r(A,S,T)+d[4],I=0|I,I=a(I,l[_]),I=I+k|0,x=k,k=T,T=a(S,10),S=A,A=I;I=t[1]+b+T|0,t[1]=t[2]+w+k|0,t[2]=t[3]+E+x|0,t[3]=t[4]+m+A|0,t[4]=t[0]+g+S|0,t[0]=I}}).call(e,r(43).Buffer)},function(t){function e(t){return t?r(t):void 0}function r(t){for(var r in e.prototype)t[r]=e.prototype[r];return t}t.exports=e,e.prototype.on=e.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks[t]=this._callbacks[t]||[]).push(e),this},e.prototype.once=function(t,e){function r(){n.off(t,r),e.apply(this,arguments)}var n=this;return this._callbacks=this._callbacks||{},r.fn=e,this.on(t,r),this},e.prototype.off=e.prototype.removeListener=e.prototype.removeAllListeners=e.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var r=this._callbacks[t];if(!r)return this;if(1==arguments.length)return delete this._callbacks[t],this;for(var n,i=0;in;++n)r[n].apply(this,e)}return this},e.prototype.listeners=function(t){return this._callbacks=this._callbacks||{},this._callbacks[t]||[]},e.prototype.hasListeners=function(t){return!!this.listeners(t).length}},function(t){t.exports=function(t,e,r){for(var n=0,i=t.length,o=3==arguments.length?r:t[n++];i>n;)o=e.call(null,o,t[n],++n,t);return o}},function(t,e,r){var n=r(82),i=n.write,o=n.zeroFill;t.exports=function(t){function e(e,r){this._block=new t(e),this._finalSize=r,this._blockSize=e,this._len=0,this._s=0}function r(t,e){return null==e?t.byteLength||t.length:"ascii"==e||"binary"==e?t.length:"hex"==e?t.length/2:"base64"==e?t.length/3:void 0}return e.prototype.init=function(){this._s=0,this._len=0},e.prototype.update=function(e,n){var o,s=this._blockSize;n||"string"!=typeof e||(n="utf8"),n?("utf-8"===n&&(n="utf8"),("base64"===n||"utf8"===n)&&(e=new t(e,n),n=null),o=r(e,n)):o=e.byteLength||e.length;for(var a=this._len+=o,u=this._s=this._s||0,c=0,f=this._block;a>u;){var h=Math.min(o,c+s);i(f,e,n,u%s,c,h);var l=h-c;u+=l,c+=l,u%s||this._update(f)}return this._s=u,this},e.prototype.digest=function(t){var e=this._blockSize,r=this._finalSize,i=8*this._len,s=this._block,a=i%(8*e);s[this._len%e]=128,o(this._block,this._len%e+1),a>=8*r&&(this._update(this._block),n.zeroFill(this._block,0)),s.writeInt32BE(i,r+4);var u=this._update(this._block)||this._hash();return null==t?u:u.toString(t)},e.prototype._update=function(){throw new Error("_update must be implemented by subclass")},e}},function(t,e,r){t.exports=function(t,e){function n(){return _.length?_.pop().init():this instanceof n?(this._w=d,e.call(this,64,56),this._h=null,this.init(),void 0):new n}function i(t,e,r,n){return 20>t?e&r|~e&n:40>t?e^r^n:60>t?e&r|e&n|r&n:e^r^n}function o(t){return 20>t?1518500249:40>t?1859775393:60>t?-1894007588:-899497514}function s(t,e){return t+e|0}function a(t,e){return t<>>32-e}var u=r(40).inherits;u(n,e);var c=0,f=4,h=8,l=12,p=16,d=new Int32Array(80),_=[];n.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,e.prototype.init.call(this),this},n.prototype._POOL=_;new t(1)instanceof DataView;return n.prototype._update=function(){{var t,e,r,n,u,c,f,h,l,p,d=this._block;this._h}t=c=this._a,e=f=this._b,r=h=this._c,n=l=this._d,u=p=this._e;for(var _=this._w,y=0;80>y;y++){var v=_[y]=16>y?d.readInt32BE(4*y):a(_[y-3]^_[y-8]^_[y-14]^_[y-16],1),m=s(s(a(t,5),i(y,e,r,n)),s(s(u,v),o(y)));u=n,n=r,r=a(e,30),e=t,t=m}this._a=s(t,c),this._b=s(e,f),this._c=s(r,h),this._d=s(n,l),this._e=s(u,p)},n.prototype._hash=function(){_.length<100&&_.push(this);var e=new t(20);return e.writeInt32BE(0|this._a,c),e.writeInt32BE(0|this._b,f),e.writeInt32BE(0|this._c,h),e.writeInt32BE(0|this._d,l),e.writeInt32BE(0|this._e,p),e},n}},function(t,e,r){{var n=r(40).inherits;r(82)}t.exports=function(t,e){function r(){d.length,this.init(),this._w=p,e.call(this,64,56)}function i(t,e){return t>>>e|t<<32-e}function o(t,e){return t>>>e}function s(t,e,r){return t&e^~t&r}function a(t,e,r){return t&e^t&r^e&r}function u(t){return i(t,2)^i(t,13)^i(t,22)}function c(t){return i(t,6)^i(t,11)^i(t,25)}function f(t){return i(t,7)^i(t,18)^o(t,3)}function h(t){return i(t,17)^i(t,19)^o(t,10)}var l=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];n(r,e);var p=new Array(64),d=[];r.prototype.init=function(){return this._a=1779033703,this._b=-1150833019,this._c=1013904242,this._d=-1521486534,this._e=1359893119,this._f=-1694144372,this._g=528734635,this._h=1541459225,this._len=this._s=0,this};return r.prototype._update=function(){var t,e,r,n,i,o,p,d,_,y,v=this._block,m=this._w;t=0|this._a,e=0|this._b,r=0|this._c,n=0|this._d,i=0|this._e,o=0|this._f,p=0|this._g,d=0|this._h;for(var g=0;64>g;g++){var b=m[g]=16>g?v.readInt32BE(4*g):h(m[g-2])+m[g-7]+f(m[g-15])+m[g-16];_=d+c(i)+s(i,o,p)+l[g]+b,y=u(t)+a(t,e,r),d=p,p=o,o=i,i=n+_,n=r,r=e,e=t,t=_+y}this._a=t+this._a|0,this._b=e+this._b|0,this._c=r+this._c|0,this._d=n+this._d|0,this._e=i+this._e|0,this._f=o+this._f|0,this._g=p+this._g|0,this._h=d+this._h|0},r.prototype._hash=function(){d.length<10&&d.push(this);var e=new t(32);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e.writeInt32BE(this._h,28),e},r}},function(t,e,r){(function(t){function t(e,r,n){if(!(this instanceof t))return new t(e,r,n);var i=typeof e;"base64"===r&&"string"===i&&(e=k(e));var o;if("number"===i)o=C(e);else if("string"===i)o=t.byteLength(e,r);else{if("object"!==i)throw new Error("First argument needs to be a number, array or string.");o=C(e.length)}var s;t._useTypedArrays?s=t._augment(new Uint8Array(o)):(s=this,s.length=o,s._isBuffer=!0);var a;if(t._useTypedArrays&&"number"==typeof e.byteLength)s._set(e);else if(L(e))if(t.isBuffer(e))for(a=0;o>a;a++)s[a]=e.readUInt8(a);else for(a=0;o>a;a++)s[a]=(e[a]%256+256)%256;else if("string"===i)s.write(e,0,r);else if("number"===i&&!t._useTypedArrays&&!n)for(a=0;o>a;a++)s[a]=0;return s}function n(t,e,r,n){r=Number(r)||0;var i=t.length-r;n?(n=Number(n),n>i&&(n=i)):n=i;var o=e.length;H(o%2===0,"Invalid hex string"),n>o/2&&(n=o/2);for(var s=0;n>s;s++){var a=parseInt(e.substr(2*s,2),16);H(!isNaN(a),"Invalid hex string"),t[r+s]=a}return s}function i(t,e,r,n){var i=M(O(e),t,r,n);return i}function o(t,e,r,n){var i=M(D(e),t,r,n);return i}function s(t,e,r,n){return o(t,e,r,n)}function a(t,e,r,n){var i=M(q(e),t,r,n);return i}function u(t,e,r,n){var i=M(N(e),t,r,n);return i}function c(t,e,r){return 0===e&&r===t.length?G.fromByteArray(t):G.fromByteArray(t.slice(e,r))}function f(t,e,r){var n="",i="";r=Math.min(t.length,r);for(var o=e;r>o;o++)t[o]<=127?(n+=F(i)+String.fromCharCode(t[o]),i=""):i+="%"+t[o].toString(16);return n+F(i)}function h(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;r>i;i++)n+=String.fromCharCode(t[i]);return n}function l(t,e,r){return h(t,e,r)}function p(t,e,r){var n=t.length;(!e||0>e)&&(e=0),(!r||0>r||r>n)&&(r=n);for(var i="",o=e;r>o;o++)i+=R(t[o]);return i}function d(t,e,r){for(var n=t.slice(e,r),i="",o=0;o=i)){var o;return r?(o=t[e],i>e+1&&(o|=t[e+1]<<8)):(o=t[e]<<8,i>e+1&&(o|=t[e+1])),o}}function y(t,e,r,n){n||(H("boolean"==typeof r,"missing or invalid endian"),H(void 0!==e&&null!==e,"missing offset"),H(e+3=i)){var o;return r?(i>e+2&&(o=t[e+2]<<16),i>e+1&&(o|=t[e+1]<<8),o|=t[e],i>e+3&&(o+=t[e+3]<<24>>>0)):(i>e+1&&(o=t[e+1]<<16),i>e+2&&(o|=t[e+2]<<8),i>e+3&&(o|=t[e+3]),o+=t[e]<<24>>>0),o}}function v(t,e,r,n){n||(H("boolean"==typeof r,"missing or invalid endian"),H(void 0!==e&&null!==e,"missing offset"),H(e+1=i)){var o=_(t,e,r,!0),s=32768&o;return s?-1*(65535-o+1):o}}function m(t,e,r,n){n||(H("boolean"==typeof r,"missing or invalid endian"),H(void 0!==e&&null!==e,"missing offset"),H(e+3=i)){var o=y(t,e,r,!0),s=2147483648&o;return s?-1*(4294967295-o+1):o}}function g(t,e,r,n){return n||(H("boolean"==typeof r,"missing or invalid endian"),H(e+3=o)){for(var s=0,a=Math.min(o-r,2);a>s;s++)t[r+s]=(e&255<<8*(n?s:1-s))>>>8*(n?s:1-s);return r+2}}function E(t,e,r,n,i){i||(H(void 0!==e&&null!==e,"missing value"),H("boolean"==typeof n,"missing or invalid endian"),H(void 0!==r&&null!==r,"missing offset"),H(r+3=o)){for(var s=0,a=Math.min(o-r,4);a>s;s++)t[r+s]=e>>>8*(n?s:3-s)&255;return r+4}}function x(t,e,r,n,i){i||(H(void 0!==e&&null!==e,"missing value"),H("boolean"==typeof n,"missing or invalid endian"),H(void 0!==r&&null!==r,"missing offset"),H(r+1=o))return e>=0?w(t,e,r,n,i):w(t,65535+e+1,r,n,i),r+2}function A(t,e,r,n,i){i||(H(void 0!==e&&null!==e,"missing value"),H("boolean"==typeof n,"missing or invalid endian"),H(void 0!==r&&null!==r,"missing offset"),H(r+3=o))return e>=0?E(t,e,r,n,i):E(t,4294967295+e+1,r,n,i),r+4}function S(t,e,r,n,i){i||(H(void 0!==e&&null!==e,"missing value"),H("boolean"==typeof n,"missing or invalid endian"),H(void 0!==r&&null!==r,"missing offset"),H(r+3=o))return V.write(t,e,r,n,23,4),r+4}function T(t,e,r,n,i){i||(H(void 0!==e&&null!==e,"missing value"),H("boolean"==typeof n,"missing or invalid endian"),H(void 0!==r&&null!==r,"missing offset"),H(r+7=o))return V.write(t,e,r,n,52,8),r+8}function k(t){for(t=I(t).replace(X,"");t.length%4!==0;)t+="=";return t}function I(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function j(t,e,r){return"number"!=typeof t?r:(t=~~t,t>=e?e:t>=0?t:(t+=e,t>=0?t:0))}function C(t){return t=~~Math.ceil(+t),0>t?0:t}function B(t){return(Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)})(t)}function L(e){return B(e)||t.isBuffer(e)||e&&"object"==typeof e&&"number"==typeof e.length}function R(t){return 16>t?"0"+t.toString(16):t.toString(16)}function O(t){for(var e=[],r=0;r=n)e.push(n);else{var i=r;n>=55296&&57343>=n&&r++;for(var o=encodeURIComponent(t.slice(i,r+1)).substr(1).split("%"),s=0;s>8,n=e%256,i.push(n),i.push(r);return i}function q(t){return G.toByteArray(t)}function M(t,e,r,n){for(var i=0;n>i&&!(i+r>=e.length||i>=t.length);i++)e[i+r]=t[i];return i}function F(t){try{return decodeURIComponent(t)}catch(e){return String.fromCharCode(65533)}}function P(t,e){H("number"==typeof t,"cannot write a non-number as a number"),H(t>=0,"specified a negative value for writing an unsigned value"),H(e>=t,"value is larger than maximum value for type"),H(Math.floor(t)===t,"value has a fractional component")}function U(t,e,r){H("number"==typeof t,"cannot write a non-number as a number"),H(e>=t,"value larger than maximum allowed value"),H(t>=r,"value smaller than minimum allowed value"),H(Math.floor(t)===t,"value has a fractional component")}function z(t,e,r){H("number"==typeof t,"cannot write a non-number as a number"),H(e>=t,"value larger than maximum allowed value"),H(t>=r,"value smaller than minimum allowed value")}function H(t,e){if(!t)throw new Error(e||"Failed assertion")}var G=r(84),V=r(83);e.Buffer=t,e.SlowBuffer=t,e.INSPECT_MAX_BYTES=50,t.poolSize=8192,t._useTypedArrays=function(){try{var t=new ArrayBuffer(0),e=new Uint8Array(t);return e.foo=function(){return 42},42===e.foo()&&"function"==typeof e.subarray}catch(r){return!1}}(),t.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},t.isBuffer=function(t){return!(null==t||!t._isBuffer)},t.byteLength=function(t,e){var r;switch(t=t.toString(),e||"utf8"){case"hex":r=t.length/2;break;case"utf8":case"utf-8":r=O(t).length;break;case"ascii":case"binary":case"raw":r=t.length;break;case"base64":r=q(t).length;break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":r=2*t.length;break;default:throw new Error("Unknown encoding")}return r},t.concat=function(e,r){if(H(B(e),"Usage: Buffer.concat(list[, length])"),0===e.length)return new t(0);if(1===e.length)return e[0];var n;if(void 0===r)for(r=0,n=0;no&&e[o]===r[o];o++);return o!==s&&(n=e[o],i=r[o]),i>n?-1:n>i?1:0},t.prototype.write=function(t,e,r,c){if(isFinite(e))isFinite(r)||(c=r,r=void 0);else{var f=c;c=e,e=r,r=f}e=Number(e)||0;var h=this.length-e;r?(r=Number(r),r>h&&(r=h)):r=h,c=String(c||"utf8").toLowerCase();var l;switch(c){case"hex":l=n(this,t,e,r);break;case"utf8":case"utf-8":l=i(this,t,e,r);break;case"ascii":l=o(this,t,e,r);break;case"binary":l=s(this,t,e,r);break;case"base64":l=a(this,t,e,r);break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":l=u(this,t,e,r);break;default:throw new Error("Unknown encoding")}return l},t.prototype.toString=function(t,e,r){var n=this;if(t=String(t||"utf8").toLowerCase(),e=Number(e)||0,r=void 0===r?n.length:Number(r),r===e)return"";var i;switch(t){case"hex":i=p(n,e,r);break;case"utf8":case"utf-8":i=f(n,e,r);break;case"ascii":i=h(n,e,r);break;case"binary":i=l(n,e,r);break;case"base64":i=c(n,e,r);break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":i=d(n,e,r);break;default:throw new Error("Unknown encoding")}return i},t.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},t.prototype.equals=function(e){return H(t.isBuffer(e),"Argument must be a Buffer"),0===t.compare(this,e)},t.prototype.compare=function(e){return H(t.isBuffer(e),"Argument must be a Buffer"),t.compare(this,e)},t.prototype.copy=function(e,r,n,i){var o=this;if(n||(n=0),i||0===i||(i=this.length),r||(r=0),i!==n&&0!==e.length&&0!==o.length){H(i>=n,"sourceEnd < sourceStart"),H(r>=0&&r=0&&n=0&&i<=o.length,"sourceEnd out of bounds"),i>this.length&&(i=this.length),e.length-rs||!t._useTypedArrays)for(var a=0;s>a;a++)e[a+r]=this[a+n];else e._set(this.subarray(n,n+s),r)}},t.prototype.slice=function(e,r){var n=this.length;if(e=j(e,n,0),r=j(r,n,n),t._useTypedArrays)return t._augment(this.subarray(e,r));for(var i=r-e,o=new t(i,void 0,!0),s=0;i>s;s++)o[s]=this[s+e];return o},t.prototype.get=function(t){return console.log(".get() is deprecated. Access using array indexes instead."),this.readUInt8(t)},t.prototype.set=function(t,e){return console.log(".set() is deprecated. Access using array indexes instead."),this.writeUInt8(t,e)},t.prototype.readUInt8=function(t,e){return e||(H(void 0!==t&&null!==t,"missing offset"),H(t=this.length?void 0:this[t]},t.prototype.readUInt16LE=function(t,e){return _(this,t,!0,e)},t.prototype.readUInt16BE=function(t,e){return _(this,t,!1,e)},t.prototype.readUInt32LE=function(t,e){return y(this,t,!0,e)},t.prototype.readUInt32BE=function(t,e){return y(this,t,!1,e)},t.prototype.readInt8=function(t,e){if(e||(H(void 0!==t&&null!==t,"missing offset"),H(t=this.length)){var r=128&this[t];return r?-1*(255-this[t]+1):this[t]}},t.prototype.readInt16LE=function(t,e){return v(this,t,!0,e)},t.prototype.readInt16BE=function(t,e){return v(this,t,!1,e)},t.prototype.readInt32LE=function(t,e){return m(this,t,!0,e)},t.prototype.readInt32BE=function(t,e){return m(this,t,!1,e)},t.prototype.readFloatLE=function(t,e){return g(this,t,!0,e)},t.prototype.readFloatBE=function(t,e){return g(this,t,!1,e) },t.prototype.readDoubleLE=function(t,e){return b(this,t,!0,e)},t.prototype.readDoubleBE=function(t,e){return b(this,t,!1,e)},t.prototype.writeUInt8=function(t,e,r){return r||(H(void 0!==t&&null!==t,"missing value"),H(void 0!==e&&null!==e,"missing offset"),H(e=this.length?void 0:(this[e]=t,e+1)},t.prototype.writeUInt16LE=function(t,e,r){return w(this,t,e,!0,r)},t.prototype.writeUInt16BE=function(t,e,r){return w(this,t,e,!1,r)},t.prototype.writeUInt32LE=function(t,e,r){return E(this,t,e,!0,r)},t.prototype.writeUInt32BE=function(t,e,r){return E(this,t,e,!1,r)},t.prototype.writeInt8=function(t,e,r){return r||(H(void 0!==t&&null!==t,"missing value"),H(void 0!==e&&null!==e,"missing offset"),H(e=this.length?void 0:(t>=0?this.writeUInt8(t,e,r):this.writeUInt8(255+t+1,e,r),e+1)},t.prototype.writeInt16LE=function(t,e,r){return x(this,t,e,!0,r)},t.prototype.writeInt16BE=function(t,e,r){return x(this,t,e,!1,r)},t.prototype.writeInt32LE=function(t,e,r){return A(this,t,e,!0,r)},t.prototype.writeInt32BE=function(t,e,r){return A(this,t,e,!1,r)},t.prototype.writeFloatLE=function(t,e,r){return S(this,t,e,!0,r)},t.prototype.writeFloatBE=function(t,e,r){return S(this,t,e,!1,r)},t.prototype.writeDoubleLE=function(t,e,r){return T(this,t,e,!0,r)},t.prototype.writeDoubleBE=function(t,e,r){return T(this,t,e,!1,r)},t.prototype.fill=function(t,e,r){if(t||(t=0),e||(e=0),r||(r=this.length),H(r>=e,"end < start"),r!==e&&0!==this.length){H(e>=0&&e=0&&r<=this.length,"end out of bounds");var n;if("number"==typeof t)for(n=e;r>n;n++)this[n]=t;else{var i=O(t.toString()),o=i.length;for(n=e;r>n;n++)this[n]=i[n%o]}return this}},t.prototype.inspect=function(){for(var t=[],r=this.length,n=0;r>n;n++)if(t[n]=R(this[n]),n===e.INSPECT_MAX_BYTES){t[n+1]="...";break}return""},t.prototype.toArrayBuffer=function(){if("undefined"!=typeof Uint8Array){if(t._useTypedArrays)return new t(this).buffer;for(var e=new Uint8Array(this.length),r=0,n=e.length;n>r;r+=1)e[r]=this[r];return e.buffer}throw new Error("Buffer.toArrayBuffer not supported in this browser")};var K=t.prototype;t._augment=function(t){return t._isBuffer=!0,t._get=t.get,t._set=t.set,t.get=K.get,t.set=K.set,t.write=K.write,t.toString=K.toString,t.toLocaleString=K.toString,t.toJSON=K.toJSON,t.equals=K.equals,t.compare=K.compare,t.copy=K.copy,t.slice=K.slice,t.readUInt8=K.readUInt8,t.readUInt16LE=K.readUInt16LE,t.readUInt16BE=K.readUInt16BE,t.readUInt32LE=K.readUInt32LE,t.readUInt32BE=K.readUInt32BE,t.readInt8=K.readInt8,t.readInt16LE=K.readInt16LE,t.readInt16BE=K.readInt16BE,t.readInt32LE=K.readInt32LE,t.readInt32BE=K.readInt32BE,t.readFloatLE=K.readFloatLE,t.readFloatBE=K.readFloatBE,t.readDoubleLE=K.readDoubleLE,t.readDoubleBE=K.readDoubleBE,t.writeUInt8=K.writeUInt8,t.writeUInt16LE=K.writeUInt16LE,t.writeUInt16BE=K.writeUInt16BE,t.writeUInt32LE=K.writeUInt32LE,t.writeUInt32BE=K.writeUInt32BE,t.writeInt8=K.writeInt8,t.writeInt16LE=K.writeInt16LE,t.writeInt16BE=K.writeInt16BE,t.writeInt32LE=K.writeInt32LE,t.writeInt32BE=K.writeInt32BE,t.writeFloatLE=K.writeFloatLE,t.writeFloatBE=K.writeFloatBE,t.writeDoubleLE=K.writeDoubleLE,t.writeDoubleBE=K.writeDoubleBE,t.fill=K.fill,t.inspect=K.inspect,t.toArrayBuffer=K.toArrayBuffer,t};var X=/[^+\/0-9A-z]/g}).call(e,r(43).Buffer)},function(t,e){function r(t,e,r,n,i,o){var s=o-i;if("ascii"===r||"binary"===r)for(var a=0;s>a;a++)t[n+a]=e.charCodeAt(a+i);else if(null==r)for(var a=0;s>a;a++)t[n+a]=e[a+i];else{if("hex"!==r)throw"base64"===r?new Error("base64 encoding not yet supported"):new Error(r+" encoding not yet supported");for(var a=0;s>a;a++){var u=i+a;t[n+a]=parseInt(e[2*u]+e[2*u+1],16)}}}function n(t,e){for(var r=e;r>1,f=-7,h=r?i-1:0,l=r?-1:1,p=t[e+h];for(h+=l,o=p&(1<<-f)-1,p>>=-f,f+=a;f>0;o=256*o+t[e+h],h+=l,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+t[e+h],h+=l,f-=8);if(0===o)o=1-c;else{if(o===u)return s?0/0:1/0*(p?-1:1);s+=Math.pow(2,n),o-=c}return(p?-1:1)*s*Math.pow(2,o-n)},e.write=function(t,e,r,n,i,o){var s,a,u,c=8*o-i-1,f=(1<>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,d=n?1:-1,_=0>e||0===e&&0>1/e?1:0;for(e=Math.abs(e),isNaN(e)||1/0===e?(a=isNaN(e)?1:0,s=f):(s=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-s))<1&&(s--,u*=2),e+=s+h>=1?l/u:l*Math.pow(2,1-h),e*u>=2&&(s++,u/=2),s+h>=f?(a=0,s=f):s+h>=1?(a=(e*u-1)*Math.pow(2,i),s+=h):(a=e*Math.pow(2,h-1)*Math.pow(2,i),s=0));i>=8;t[r+p]=255&a,p+=d,a/=256,i-=8);for(s=s<0;t[r+p]=255&s,p+=d,s/=256,c-=8);t[r+p-d]|=128*_}},function(t,e){var r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";!function(t){"use strict";function e(t){var e=t.charCodeAt(0);return e===s||e===h?62:e===a||e===l?63:u>e?-1:u+10>e?e-u+26+26:f+26>e?e-f:c+26>e?e-c+26:void 0}function n(t){function r(t){c[h++]=t}var n,i,s,a,u,c;if(t.length%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var f=t.length;u="="===t.charAt(f-2)?2:"="===t.charAt(f-1)?1:0,c=new o(3*t.length/4-u),s=u>0?t.length-4:t.length;var h=0;for(n=0,i=0;s>n;n+=4,i+=3)a=e(t.charAt(n))<<18|e(t.charAt(n+1))<<12|e(t.charAt(n+2))<<6|e(t.charAt(n+3)),r((16711680&a)>>16),r((65280&a)>>8),r(255&a);return 2===u?(a=e(t.charAt(n))<<2|e(t.charAt(n+1))>>4,r(255&a)):1===u&&(a=e(t.charAt(n))<<10|e(t.charAt(n+1))<<4|e(t.charAt(n+2))>>2,r(a>>8&255),r(255&a)),c}function i(t){function e(t){return r.charAt(t)}function n(t){return e(t>>18&63)+e(t>>12&63)+e(t>>6&63)+e(63&t)}var i,o,s,a=t.length%3,u="";for(i=0,s=t.length-a;s>i;i+=3)o=(t[i]<<16)+(t[i+1]<<8)+t[i+2],u+=n(o);switch(a){case 1:o=t[t.length-1],u+=e(o>>2),u+=e(o<<4&63),u+="==";break;case 2:o=(t[t.length-2]<<8)+t[t.length-1],u+=e(o>>10),u+=e(o>>4&63),u+=e(o<<2&63),u+="="}return u}var o="undefined"!=typeof Uint8Array?Uint8Array:Array,s="+".charCodeAt(0),a="/".charCodeAt(0),u="0".charCodeAt(0),c="a".charCodeAt(0),f="A".charCodeAt(0),h="-".charCodeAt(0),l="_".charCodeAt(0);t.toByteArray=n,t.fromByteArray=i}("undefined"==typeof e?this.base64js={}:e)}]);