diff --git a/css/codemirror.css b/css/codemirror.css new file mode 100644 index 0000000000..23eaf74d44 --- /dev/null +++ b/css/codemirror.css @@ -0,0 +1,263 @@ +/* BASICS */ + +.CodeMirror { + /* Set height, width, borders, and global font properties here */ + font-family: monospace; + height: 300px; +} +.CodeMirror-scroll { + /* Set scrolling behaviour here */ + overflow: auto; +} + +/* PADDING */ + +.CodeMirror-lines { + padding: 4px 0; /* Vertical padding around content */ +} +.CodeMirror pre { + padding: 0 4px; /* Horizontal padding of content */ +} + +.CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler { + background-color: white; /* The little square between H and V scrollbars */ +} + +/* GUTTER */ + +.CodeMirror-gutters { + border-right: 1px solid #ddd; + background-color: #f7f7f7; + white-space: nowrap; +} +.CodeMirror-linenumbers {} +.CodeMirror-linenumber { + padding: 0 3px 0 5px; + min-width: 20px; + text-align: right; + color: #999; +} + +/* CURSOR */ + +.CodeMirror div.CodeMirror-cursor { + border-left: 1px solid black; + z-index: 3; +} +/* Shown when moving in bi-directional text */ +.CodeMirror div.CodeMirror-secondarycursor { + border-left: 1px solid silver; +} +.CodeMirror.cm-keymap-fat-cursor div.CodeMirror-cursor { + width: auto; + border: 0; + background: #7e7; + z-index: 1; +} +/* Can style cursor different in overwrite (non-insert) mode */ +.CodeMirror div.CodeMirror-cursor.CodeMirror-overwrite {} + +.cm-tab { display: inline-block; } + +/* DEFAULT THEME */ + +.cm-s-default .cm-keyword {color: #708;} +.cm-s-default .cm-atom {color: #219;} +.cm-s-default .cm-number {color: #164;} +.cm-s-default .cm-def {color: #00f;} +.cm-s-default .cm-variable {color: black;} +.cm-s-default .cm-variable-2 {color: #05a;} +.cm-s-default .cm-variable-3 {color: #085;} +.cm-s-default .cm-property {color: black;} +.cm-s-default .cm-operator {color: black;} +.cm-s-default .cm-comment {color: #a50;} +.cm-s-default .cm-string {color: #a11;} +.cm-s-default .cm-string-2 {color: #f50;} +.cm-s-default .cm-meta {color: #555;} +.cm-s-default .cm-qualifier {color: #555;} +.cm-s-default .cm-builtin {color: #30a;} +.cm-s-default .cm-bracket {color: #997;} +.cm-s-default .cm-tag {color: #170;} +.cm-s-default .cm-attribute {color: #00c;} +.cm-s-default .cm-header {color: blue;} +.cm-s-default .cm-quote {color: #090;} +.cm-s-default .cm-hr {color: #999;} +.cm-s-default .cm-link {color: #00c;} + +.cm-negative {color: #d44;} +.cm-positive {color: #292;} +.cm-header, .cm-strong {font-weight: bold;} +.cm-em {font-style: italic;} +.cm-link {text-decoration: underline;} + +.cm-s-default .cm-error {color: #f00;} +.cm-invalidchar {color: #f00;} + +div.CodeMirror span.CodeMirror-matchingbracket {color: #0f0;} +div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;} +.CodeMirror-activeline-background {background: #e8f2ff;} + +/* STOP */ + +/* The rest of this file contains styles related to the mechanics of + the editor. You probably shouldn't touch them. */ + +.CodeMirror { + line-height: 1; + position: relative; + overflow: hidden; + background: white; + color: black; +} + +.CodeMirror-scroll { + /* 30px is the magic margin used to hide the element's real scrollbars */ + /* See overflow: hidden in .CodeMirror */ + margin-bottom: -30px; margin-right: -30px; + padding-bottom: 30px; padding-right: 30px; + height: 100%; + outline: none; /* Prevent dragging from highlighting the element */ + position: relative; + -moz-box-sizing: content-box; + box-sizing: content-box; +} +.CodeMirror-sizer { + position: relative; +} + +/* The fake, visible scrollbars. Used to force redraw during scrolling + before actuall scrolling happens, thus preventing shaking and + flickering artifacts. */ +.CodeMirror-vscrollbar, .CodeMirror-hscrollbar, .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler { + position: absolute; + z-index: 6; + display: none; +} +.CodeMirror-vscrollbar { + right: 0; top: 0; + overflow-x: hidden; + overflow-y: scroll; +} +.CodeMirror-hscrollbar { + bottom: 0; left: 0; + overflow-y: hidden; + overflow-x: scroll; +} +.CodeMirror-scrollbar-filler { + right: 0; bottom: 0; +} +.CodeMirror-gutter-filler { + left: 0; bottom: 0; +} + +.CodeMirror-gutters { + position: absolute; left: 0; top: 0; + padding-bottom: 30px; + z-index: 3; +} +.CodeMirror-gutter { + white-space: normal; + height: 100%; + -moz-box-sizing: content-box; + box-sizing: content-box; + padding-bottom: 30px; + margin-bottom: -32px; + display: inline-block; + /* Hack to make IE7 behave */ + *zoom:1; + *display:inline; +} +.CodeMirror-gutter-elt { + position: absolute; + cursor: default; + z-index: 4; +} + +.CodeMirror-lines { + cursor: text; +} +.CodeMirror pre { + /* Reset some styles that the rest of the page might have set */ + -moz-border-radius: 0; -webkit-border-radius: 0; border-radius: 0; + border-width: 0; + background: transparent; + font-family: inherit; + font-size: inherit; + margin: 0; + white-space: pre; + word-wrap: normal; + line-height: inherit; + color: inherit; + z-index: 2; + position: relative; + overflow: visible; +} +.CodeMirror-wrap pre { + word-wrap: break-word; + white-space: pre-wrap; + word-break: normal; +} +.CodeMirror-code pre { + border-right: 30px solid transparent; + width: -webkit-fit-content; + width: -moz-fit-content; + width: fit-content; +} +.CodeMirror-wrap .CodeMirror-code pre { + border-right: none; + width: auto; +} +.CodeMirror-linebackground { + position: absolute; + left: 0; right: 0; top: 0; bottom: 0; + z-index: 0; +} + +.CodeMirror-linewidget { + position: relative; + z-index: 2; + overflow: auto; +} + +.CodeMirror-widget {} + +.CodeMirror-wrap .CodeMirror-scroll { + overflow-x: hidden; +} + +.CodeMirror-measure { + position: absolute; + width: 100%; + height: 0; + overflow: hidden; + visibility: hidden; +} +.CodeMirror-measure pre { position: static; } + +.CodeMirror div.CodeMirror-cursor { + position: absolute; + visibility: hidden; + border-right: none; + width: 0; +} +.CodeMirror-focused div.CodeMirror-cursor { + visibility: visible; +} + +.CodeMirror-selected { background: #d9d9d9; } +.CodeMirror-focused .CodeMirror-selected { background: #d7d4f0; } + +.cm-searching { + background: #ffa; + background: rgba(255, 255, 0, .4); +} + +/* IE7 hack to prevent it from returning funny offsetTops on the spans */ +.CodeMirror span { *vertical-align: text-bottom; } + +@media print { + /* Hide the cursor when printing */ + .CodeMirror div.CodeMirror-cursor { + visibility: hidden; + } +} diff --git a/js/api-main.min.js b/js/api-main.min.js new file mode 100644 index 0000000000..3cd1e92daf --- /dev/null +++ b/js/api-main.min.js @@ -0,0 +1 @@ +(function(){function v(e){var e=e.toLowerCase();$(t).removeClass(),$(t).addClass(e),$(t).text(e)}function m(){return m._c}function b(e,t){var n={id:void 0,name:e,message:{command:e}};return Object.keys(t||{}).forEach(function(e){e[0]==="_"?n[e]=t[e]:n.message[e]=t[e]}),y[e]=n,n}function S(e){if(typeof e=="string")var e=JSON.parse(e);var t={};return e.id&&(t.id=e.id),e.command&&(t.command=e.command),e.status&&(t.status=e.status),e.type&&(t.type=e.type),Object.keys(e).forEach(function(n){t.hasOwnProperty(n)||(t[n]=e[n])}),t}function N(e){var t=e.message;e._description?$(u).text(e._description).show():$(u).hide(),$("#selected_command").html($("").attr("href",e._link).text(e.name)),x.setValue(JSON.stringify(t,null,2))}function O(t){var n=S(t),r=n.type==="response";if(r&&n.id===m._c){if(!L)return;L=!1;var i=''+g.name;0/0;var s=''+(Date.now()-g.t)+"ms"+"";$(e).removeClass("depressed"),$(p).html(i+s),$(l).removeClass(),$(l).addClass(n.error?"error":"success"),T.setValue(JSON.stringify(n,null,2)),++m._c}else if(!r&&!C){var o=$('
').get(0);$(h).prepend(o),CodeMirror(o,{value:JSON.stringify(n,null,2),mode:"javascript",json:!0,smartIndent:!1,readOnly:!0}),A.unshift(n)}}function M(e){g=y[e],g.message.id=m(),g.message=S(g.message),N(g);if(g.name!=="submit"){$("#sign_button").hide();return}if(!d._connected){d.once("connected",function(){M(e)});return}$("#sign_button").show();var t=g.message.tx_json;ripple.UInt160.is_valid(t.Account)&&(g.message.id=m._c,d.request_account_info(t.Account,function(e,n){m.reset(),t.Sequence=n.account_data.Sequence,N(g)}))}function D(e){var t=Array.isArray(e),n=t?[]:{};Object.keys(e).forEach(function(t){var r=e[t];switch(typeof r){case"undefined":break;case"object":n[t]=D(r);break;default:n[t]=r}}),t&&(n=n.filter(function(e){return e!==null&&typeof e!="undefined"}));var r=t&&n.length===0;return r?void 0:n}function B(){var e=d.request_server_info(),t=x.getValue();try{var n=JSON.parse(t)}catch(r){alert("Invalid request JSON");return}$(this).addClass("depressed"),$(l).addClass("obscured"),L=!0,g.message=n,g.t=Date.now(),e.message=D(n),e.request()}function j(){m._c=d._get_server()._id,d._get_server().on("message",O),$(e).click(B)}var e=$("#request_button"),t=$("#online_state"),n=$("#command_wrapper"),r=$(n).find("#command_list"),i=$(r).find("li"),s=$(n).find("#command_table"),o=$(n).find("#input"),u=$(o).find("#description"),a=$(o).find("#options"),f=$(n).find("#output"),l=$(n).find("#response"),c=$(n).find("#request"),h=$(n).find("#status"),p=$(n).find("#info"),d=new ripple.Remote({trusted:!0,local_signing:!0,local_fee:!1,servers:[{host:"s1.ripple.com",port:443,secure:!0}]});d.on("disconnect",function(){v("disconnected")}),d.on("connect",function(){v("connected")}),m._c=2,m.reset=function(){m._c=d._get_server()._id};var g={},y={};$(i).each(function(e,t){y[$(t).text()]=0});var w="r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",E="E08D6E9754025BA2534A78707605E0601F03ACE063687A0CA1BDDACFCD1698C7";b("server_info",{_description:"Returns information about the state of the server for human consumption. Results are subject to change without notice.",_link:"https://ripple.com/wiki/JSON_Messages#server_info"}),b("server_state",{_description:"Returns information about the state of the server for machine consumption.",_link:"https://ripple.com/wiki/JSON_Messages#server_state"}),b("ping",{_description:"This command is used to check connectivity for clients. Websocket clients can use this to determine turn around time and actively discover loss of connectivity to a server.",_link:"https://ripple.com/wiki/JSON_Messages#ping"}),b("subscribe",{accounts:[],streams:["server","ledger"],_description:"Start receiving selected streams from the server.",_link:"https://ripple.com/wiki/JSON_Messages#subscribe"}),b("unsubscribe",{accounts:[],streams:["server","ledger"],_description:"Stop receiving selected streams from the server.",_link:"https://ripple.com/wiki/JSON_Messages#unsubscribe"}),b("ledger",{ledger_index:void 0,ledger_hash:void 0,full:!1,expand:!1,transactions:!0,accounts:!0,_description:"Returns ledger information.",_link:"https://ripple.com/wiki/JSON_Messages#ledger"}),b("ledger_entry",{type:"account_root",account_root:w,ledger_hash:"validated",ledger_index:void 0,_description:"Returns a ledger entry. For untrusted servers, the index option provides raw access to ledger entries and proof.",_link:"https://ripple.com/wiki/JSON_Messages#ledger_entry"}),b("ledger_closed",{_description:"Returns the most recent closed ledger index. If a validation list has been provided, then validations should be available.",_link:"https://ripple.com/wiki/JSON_Messages#ledger_closed"}),b("ledger_current",{_description:"Returns the current proposed ledger index. Proof is not possible for the current ledger. This command is primarily useful for testing.",_link:"https://ripple.com/wiki/JSON_Messages#ledger_current"}),b("account_info",{account:w,_description:"Returns information about the specified account.",_link:"https://ripple.com/wiki/JSON_Messages#account_info"}),b("account_lines",{account:w,account_index:void 0,ledger:"current",_description:"Returns information about the ripple credit lines for the specified account.",_link:"https://ripple.com/wiki/JSON_Messages#account_lines"}),b("account_offers",{account:w,account_index:void 0,ledger:"current",_description:"Returns the outstanding offers for a specified account.",_link:"https://ripple.com/wiki/JSON_Messages#account_offers"}),b("account_tx",{account:w,ledger_index_min:-1,ledger_index_max:-1,binary:!1,count:!1,descending:!1,offset:0,limit:10,forward:!1,marker:void 0,_description:"Returns a list of transactions that applied to a specified account.",_link:"https://ripple.com/wiki/JSON_Messages#account_tx"}),b("transaction_entry",{tx_hash:E,ledger_index:348734,ledger_hash:void 0,_description:"Returns information about a specified transaction.",_link:"https://ripple.com/wiki/JSON_Messages#transaction_entry"}),b("tx",{transaction:E,_description:"Returns information about a specified transaction.",_link:"https://ripple.com/wiki/JSON_Messages#tx"}),b("tx_history",{start:10,_description:"Returns the last N transactions starting from start index, in descending order, by ledger sequence number. Server sets N.",_link:"https://ripple.com/wiki/JSON_Messages#tx_history"}),b("book_offers",{ledger_hash:void 0,ledger_index:void 0,taker:w,taker_gets:ripple.Amount.from_json("1/EUR/rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B").to_json(),taker_pays:ripple.Amount.from_json("1/USD/rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B").to_json(),_description:"Returns the offers for an order book as one or more pages.",_link:"https://ripple.com/wiki/JSON_Messages#book_offers"}),b("path_find",{subcommand:"create",source_account:w,destination_account:"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",destination_amount:ripple.Amount.from_json("0.001/USD/rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B").to_json(),_description:"Find or modify a payment pathway between specified accounts.",_link:"https://ripple.com/wiki/JSON_Messages#path_find"}),b("ripple_path_find",{ledger_hash:void 0,ledger_index:void 0,source_account:w,source_currencies:[{currency:"USD"}],destination_account:"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",destination_amount:ripple.Amount.from_json("0.001/USD/rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B").to_json(),_description:"Find a path and estimated costs.For non-interactive use, such as automated payment sending from business integrations, ripple_path_find gives you single response that you can use immediately. However, for uses that need updated paths as new ledgers close, repeated calls becomes expensive. In those cases, when possible, use the RPC path_find in place of this API.",_link:"https://ripple.com/wiki/JSON_Messages#ripple_path_find"}),b("submit",{secret:"",tx_json:{Flags:0,TransactionType:"AccountSet",Account:"",Sequence:void 0,Fee:"15",Flags:0},_description:"Submits a transaction to the network.",_link:"https://ripple.com/wiki/JSON_Messages#submit"});var x=CodeMirror(c.get(0),{mode:"javascript",json:!0,smartIndent:!1}),T=CodeMirror(l.get(0),{mode:"javascript",json:!0,smartIndent:!1,readOnly:!0}),C=!1,k=!1,L=!1,A=[];$(i).click(function(){var e=$(this).text().trim();if(!y[e])return;M(e,!0),window.location.hash=e,$(this).siblings().removeClass("selected"),$(this).addClass("selected")});var _=void 0;$(window).keydown(function(t){t.which===13&&_===17&&(t.preventDefault(),t.stopPropagation(),$(e).click()),_=t.which}),$("#stream_show").click(function(){$(h).is(":visible")?($(h).hide(),$(h).empty(),$(this).text("show"),k=!1):($(this).text("hide"),$(h).show(),k=!0,A.forEach(function(e){var t=$('
')[0];$(h).append(t),CodeMirror(t,{value:JSON.stringify(e,null,2),mode:"javascript",json:!0})}))}),$("#stream_pause").click(function(){$(this).hasClass("paused")?($(this).removeClass("paused"),$(this).text("pause"),$(h).removeClass("obscured"),C=!1):($(this).addClass("paused"),$(this).text("unpause"),$(h).addClass("obscured"),C=!0)}),$(document.body).delegate("a","click",function(e){e.preventDefault(),e.stopPropagation(),window.open($(this).attr("href"))});var P=$("#tooltip"),H=!1;$(window).mousedown(function(){H=!0}),$(window).mouseup(function(){H=!1}),$("#sign_button").click(function(){if(g._signed)return;var e=this,t=x.getValue();try{t=JSON.parse(t)}catch(n){alert("Invalid JSON");return}var r=t.tx_json;if(!ripple.UInt160.is_valid(r.Account)){alert("Account is invalid");return}if(!t.secret){alert("Transacting account must have specified secret");return}$(this).addClass("depressed"),d.account(r.Account).get_next_sequence(function(n,i){m.reset(),r.Sequence=i;try{var s=d.transaction();s.tx_json=r,s._secret=t.secret,s.complete(),s.sign()}catch(n){alert("Unable to sign transaction "+n.message),$(e).removeClass("depressed");return}t.tx_blob=s.serialize().to_hex(),delete t.secret,delete t.tx_json,g.message=t,g._signed=!0,N(g),$(e).removeClass("depressed")})}),$(function(){v("connecting"),d.connect(j);if(window.location.hash){var e=window.location.hash.slice(1).toLowerCase(),t=Object.keys(y),n=t.indexOf(e);if(n===-1)return;var r=$(i).eq(n);M(e),window.cmd=e,$(r).siblings().removeClass("selected"),$(r).addClass("selected")}else M("server_info")})})(); \ No newline at end of file diff --git a/js/api-ripple.min.js b/js/api-ripple.min.js new file mode 100644 index 0000000000..2a9d3bc6b5 --- /dev/null +++ b/js/api-ripple.min.js @@ -0,0 +1,6 @@ +var ripple=function(t){function e(i){if(r[i])return r[i].exports;var n=r[i]={exports:{},id:i,loaded:!1};return t[i].call(null,n,n.exports,e),n.loaded=!0,n.exports}var r={};return e.e=function(t,e){e.call(null,this)},e.modules=t,e.cache=r,e(0)}({c:"",0:function(t,e,r){e.Remote=r(1).Remote,e.Amount=r(2).Amount,e.Currency=r(3).Currency,e.Base=r(4).Base,e.UInt160=r(2).UInt160,e.Seed=r(2).Seed,e.Transaction=r(5).Transaction,e.Meta=r(6).Meta,e.SerializedObject=r(7).SerializedObject,e.binformat=r(8),e.utils=r(9),e.Server=r(10).Server,e.sjcl=r(9).sjcl,e.config=r(11)},1:function(t,e,r){function i(t){function e(t){"transaction_all"===t&&(!i._transaction_subs&&i._connected&&i.request_subscribe("transactions").request(),i._transaction_subs+=1)}function r(t){"transaction_all"===t&&(i._transaction_subs-=1,!i._transaction_subs&&i._connected&&i.request_unsubscribe("transactions").request())}n.call(this);var i=this;this.trusted=Boolean(t.trusted),this.local_sequence=Boolean(t.local_sequence),this.local_fee="undefined"==typeof t.local_fee?!0:Boolean(t.local_fee),this.local_signing="undefined"==typeof t.local_signing?!0:Boolean(t.local_signing),this.fee_cushion="undefined"==typeof t.fee_cushion?1.5:Number(t.fee_cushion),this.max_fee="undefined"==typeof t.max_fee?1/0:Number(t.max_fee),this.id=0,this.trace=Boolean(t.trace),this._server_fatal=!1,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._transaction_subs=0,this.online_target=!1,this._online_state="closed",this.state="offline",this.retry_timer=void 0,this.retry=void 0,this._load_base=256,this._load_factor=256,this._fee_ref=10,this._fee_base=10,this._reserve_base=void 0,this._reserve_inc=void 0,this._connection_count=0,this._connected=!1,this._connection_offset=1e3*(Number(t.connection_offset)||5),this._submission_timeout=1e3*(Number(t.submission_timeout)||10),this._received_tx={},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:{}}},t.hasOwnProperty("servers")||(t.servers=[{host:t.websocket_ip,port:t.websocket_port,secure:t.websocket_ssl,trusted:t.trusted}]),t.servers.forEach(function(t){for(var e=Number(t.pool)||1;e--;)i.add_server(t)});var s=t.maxListeners||t.max_listeners||0;this._servers.concat(this).forEach(function(t){t.setMaxListeners(s)}),this.on("newListener",e),this.on("removeListener",r)}var n=r(24).EventEmitter,s=r(25),o=r(13).Request,a=r(10).Server,c=r(2).Amount,u=r(3).Currency,h=r(14).UInt160,f=r(5).Transaction,l=r(15).Account,_=r(6).Meta,p=r(16).OrderBook,d=r(17).PathFind,y=r(18).RippleError,v=r(9),m=r(11),g=r(9).sjcl;s.inherits(i,n),i.flags={account_root:{PasswordSpent:65536,RequireDestTag:131072,RequireAuth:262144,DisallowXRP:524288}},i.from_config=function(t,e){function r(t){var e=m.accounts[t];"object"==typeof e&&e.secret&&(s.set_secret(t,e.secret),s.set_secret(e.account,e.secret))}var n="string"==typeof t?m.servers[t]:t,s=new i(n,e);if("object"==typeof m.accounts)for(var o in m.accounts)r(o);return s},i.create_remote=function(t,e){var r=i.from_config(t);return r.connect(e),r},i.prototype.add_server=function(t){function e(t){n._handle_message(t,s)}function r(){n._connection_count++,n._set_state("online"),(t.primary||!n._primary_server)&&n._set_primary_server(s),n._connection_count===n._servers.length&&n.emit("ready")}function i(){n._connection_count--,n._connection_count||n._set_state("offline")}var n=this,s=new a(this,{host:t.host||t.websocket_ip,port:t.port||t.websocket_port,secure:t.secure||t.websocket_ssl});return s.on("message",e),s.on("connect",r),s.on("disconnect",i),this._servers.push(s),this},i.prototype.server_fatal=function(){this._server_fatal=!0},i.prototype._set_state=function(t){if(this._trace("remote: set_state: %s",t),this.state!==t)switch(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")}},i.prototype.set_trace=function(t){return this.trace=void 0===t||t,this},i.prototype._trace=function(){this.trace&&v.logObject.apply(v,arguments)},i.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()}var e=this;return function r(t){var i=e._servers[t];i.connect(),i._sid=++t,t=3&&(n=n.payment(t,e,r),"function"==typeof i&&n.submit(i)),n},i.prototype.fee_tx=function(t){var e=this.fee_tx_unit();return c.from_json(String(Math.ceil(t*e)))},i.prototype.fee_tx_unit=function(){var t=this._fee_base/this._fee_ref;return t*=this._load_factor/this._load_base,t*=this.fee_cushion},i.prototype.reserve=function(t){var e=c.from_json(String(this._reserve_base)),r=c.from_json(String(this._reserve_inc)),t=t||0;if(0>t)throw new Error("Owner count must not be negative.");return e.add(r.product_human(t))},i.prototype.ping=function(t,e){var r=new o(this,"ping");switch(typeof t){case"function":e=t;break;case"string":r.set_server(t)}var i=Date.now();return r.once("success",function(){r.emit("pong",Date.now()-i)}),r.callback(e,"pong"),r},e.Remote=i},2:function(t,e,r){function i(){this._value=new o,this._offset=0,this._is_native=!0,this._is_negative=!1,this._currency=new u,this._issuer=new a}var n=r(9),s=n.sjcl;s.bn;var o=n.jsbn.BigInteger,a=r(14).UInt160,c=r(19).Seed,u=r(3).Currency,h=e.consts={currency_xns:0,currency_one:1,xns_precision:6,bi_5:new o("5"),bi_7:new o("7"),bi_10:new o("10"),bi_1e14:new o(String(1e14)),bi_1e16:new o(String(1e16)),bi_1e17:new o(String(1e17)),bi_1e32:new o("100000000000000000000000000000000"),bi_man_max_value:new o("9999999999999999"),bi_man_min_value:new o("1000000000000000"),bi_xns_max:new o("9000000000000000000"),bi_xns_min:new o("-9000000000000000000"),bi_xns_unit:new o("1000000"),cMinOffset:-96,cMaxOffset:80};i.text_full_rewrite=function(t){return i.from_json(t).to_text_full()},i.json_rewrite=function(t){return i.from_json(t).to_json()},i.from_number=function(t){return(new i).parse_number(t)},i.from_json=function(t){return(new i).parse_json(t)},i.from_quality=function(t,e,r){return(new i).parse_quality(t,e,r)},i.from_human=function(t){return(new i).parse_human(t)},i.is_valid=function(t){return i.from_json(t).is_valid()},i.is_valid_full=function(t){return i.from_json(t).is_valid_full()},i.NaN=function(){var t=new i;return t._value=0/0,t},i.prototype.abs=function(){return this.clone(this.is_negative())},i.prototype.add=function(t){var e;if(t=i.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 i;var r=this._is_negative?this._value.negate():this._value,n=t._is_negative?t._value.negate():t._value,s=r.add(n);e._is_negative=s.compareTo(o.ZERO)<0,e._value=e._is_negative?s.negate():s,e._currency=this._currency,e._issuer=this._issuer}else{for(var r=this._is_negative?this._value.negate():this._value,a=this._offset,n=t._is_negative?t._value.negate():t._value,c=t._offset;c>a;)r=r.divide(h.bi_10),a+=1;for(;a>c;)n=n.divide(h.bi_10),c+=1;e=new i,e._is_native=!1,e._offset=a,e._value=r.add(n),e._is_negative=e._value.compareTo(o.ZERO)<0,e._is_negative&&(e._value=e._value.negate()),e._currency=this._currency,e._issuer=this._issuer,e.canonicalize()}else e=i.NaN();return e},i.prototype.canonicalize=function(){if(this._value instanceof o)if(this._is_native)if(this._value.equals(o.ZERO))this._offset=0,this._is_negative=!1;else{for(;this._offset<0;)this._value=this._value.divide(h.bi_10),this._offset+=1;for(;this._offset>0;)this._value=this._value.multiply(h.bi_10),this._offset-=1}else if(this.is_zero())this._offset=-100,this._is_negative=!1;else{for(;this._value.compareTo(h.bi_man_min_value)<0;)this._value=this._value.multiply(h.bi_10),this._offset-=1;for(;this._value.compareTo(h.bi_man_max_value)>0;)this._value=this._value.divide(h.bi_10),this._offset+=1}else;return this},i.prototype.clone=function(t){return this.copyTo(new i,t)},i.prototype.compareTo=function(t){var e;return this.is_comparable(t)?this._is_negative!==t._is_negative?e=this._is_negative?-1:1:this._value.equals(o.ZERO)?e=t._value.equals(o.ZERO)?0:-1:t._value.equals(o.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=i.NaN(),e},i.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},i.prototype.currency=function(){return this._currency},i.prototype.equals=function(t,e){if("string"==typeof t)return this.equals(i.from_json(t));var r=!0;return 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))))},i.prototype.divide=function(t){var e;if(t.is_zero())throw"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(h.bi_man_min_value)<0;)r._value=r._value.multiply(h.bi_10),r._offset-=1;var n=t;if(n.is_native())for(n=n.clone();n._value.compareTo(h.bi_man_min_value)<0;)n._value=n._value.multiply(h.bi_10),n._offset-=1;e=new i,e._offset=r._offset-n._offset-17,e._value=r._value.multiply(h.bi_1e17).divide(n._value).add(h.bi_5),e._is_native=r._is_native,e._is_negative=r._is_negative!==n._is_negative,e._currency=r._currency,e._issuer=r._issuer,e.canonicalize()}return e},i.prototype.ratio_human=function(t){t="number"==typeof t&&parseInt(t,10)===t?i.from_json(""+t+".0"):i.from_json(t);var e=this;return t=i.from_json(t),e.is_valid()&&t.is_valid()?(t._is_native&&(e=e.clone(),e._value=e._value.multiply(h.bi_xns_unit),e.canonicalize()),e.divide(t)):i.NaN()},i.prototype.product_human=function(t){if(t="number"==typeof t&&parseInt(t,10)===t?i.from_json(String(t)+".0"):i.from_json(t),!this.is_valid()||!t.is_valid())return i.NaN();var e=this.multiply(t);return t._is_native&&(e._value=e._value.divide(h.bi_xns_unit),e.canonicalize()),e},i.prototype.is_comparable=function(t){return this._value instanceof o&&t._value instanceof o&&this._is_native===t._is_native},i.prototype.is_native=function(){return this._is_native},i.prototype.is_negative=function(){return this._value instanceof o?this._is_negative:!1},i.prototype.is_positive=function(){return!this.is_zero()&&!this.is_negative()},i.prototype.is_valid=function(){return this._value instanceof o},i.prototype.is_valid_full=function(){return this.is_valid()&&this._currency.is_valid()&&this._issuer.is_valid()},i.prototype.is_zero=function(){return this._value instanceof o?this._value.equals(o.ZERO):!1},i.prototype.issuer=function(){return this._issuer},i.prototype.multiply=function(t){var e;if(this.is_zero())e=this;else if(t.is_zero())e=this.clone(),e._value=o.ZERO;else{var r=this._value,n=this._offset,s=t._value,a=t._offset;if(this.is_native())for(;r.compareTo(h.bi_man_min_value)<0;)r=r.multiply(h.bi_10),n-=1;if(t.is_native())for(;s.compareTo(h.bi_man_min_value)<0;)s=s.multiply(h.bi_10),a-=1;e=new i,e._offset=n+a+14,e._value=r.multiply(s).divide(h.bi_1e14).add(h.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},i.prototype.negate=function(){return this.clone("NEGATE")},i.prototype.invert=function(){var t=this.clone();return t._value=o.ONE,t._offset=0,t._is_negative=!1,t.canonicalize(),t.ratio_human(this)},i.human_RE=/^\s*([a-z]{3})?\s*(-)?(\d+)(?:\.(\d*))?\s*([a-z]{3})?\s*$/i,i.prototype.parse_human=function(t){var e=String(t).match(i.human_RE);if(e){var r=e[1]||e[5]||"XRP",n=e[3]||"0",s=e[4]||"",a=null;if(r=r.toUpperCase(),this._value=new o(n),this.set_currency(r),"XRP"===r){for(s=s.slice(0,6);s.length<6;)s+="0";this._is_native=!0,this._value=this._value.multiply(h.bi_xns_unit).add(new o(s))}else{s=s.replace(/0+$/,""),a=s.length,this._is_native=!1;var c=h.bi_10.clone().pow(a);this._value=this._value.multiply(c).add(new o(s)),this._offset=-a,this.canonicalize()}this._is_negative=!!e[2]}else this._value=0/0;return this},i.prototype.parse_issuer=function(t){return this._issuer=a.from_json(t),this},i.prototype.parse_quality=function(t,e,r){return this._is_negative=!1,this._value=new o(t.substring(t.length-14),16),this._offset=parseInt(t.substring(t.length-16,t.length-14),16)-100,this._currency=u.from_json(e),this._issuer=a.from_json(r),this._is_native=this._currency.is_native(),this.canonicalize(),this},i.prototype.parse_number=function(t){return this._is_native=!1,this._currency=u.from_json(1),this._issuer=a.from_json(1),this._is_negative=0>t?1:0,this._value=new o(String(this._is_negative?-t:t)),this._offset=0,this.canonicalize(),this},i.prototype.parse_json=function(t){switch(typeof t){case"string":var e=t.match(/^([^/]+)\/(...)(?:\/(.+))?$/);e?(this._currency=u.from_json(e[2]),this._issuer=e[3]?a.from_json(e[3]):a.from_json("1"),this.parse_value(e[1])):(this.parse_native(t),this._currency=u.from_json("0"),this._issuer=a.from_json("0"));break;case"number":this.parse_json(String(t));break;case"object":if(null===t)break;t instanceof i?t.copyTo(this):t.hasOwnProperty("value")&&(this._currency.parse_json(t.currency),"string"==typeof t.issuer&&this._issuer.parse_json(t.issuer),this.parse_value(t.value));break;default:this._value=0/0}return this},i.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 o(e[2]);else{var r=new o(e[2]).multiply(h.bi_xns_unit),i=new o(e[3]).multiply(new o(String(Math.pow(10,1+h.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(o.ZERO),this._value.compareTo(h.bi_xns_max)>0&&(this._value=0/0)}else this._value=0/0;return this},i.prototype.parse_value=function(t){switch(this._is_native=!1,typeof t){case"number":this._is_negative=0>t,this._value=new o(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 o(i[2]),this._offset=parseInt(i[3]),this._is_negative=!!i[1],this.canonicalize();else if(r){var n=new o(r[2]),s=new o(r[3]),a=r[3].length;this._value=n.multiply(h.bi_10.clone().pow(a)).add(s),this._offset=-a,this._is_negative=!!r[1],this.canonicalize()}else e?(this._value=new o(e[2]),this._offset=0,this._is_negative=!!e[1],this.canonicalize()):this._value=0/0;break;default:this._value=t instanceof o?t:0/0}return this},i.prototype.set_currency=function(t){return this._currency=u.from_json(t),this._is_native=this._currency.is_native(),this},i.prototype.set_issuer=function(t){return this._issuer=t instanceof a?t:a.from_json(t),this},i.prototype.subtract=function(t){return this.add(i.from_json(t).negate())},i.prototype.to_number=function(t){var e=this.to_text(t);return"string"==typeof e?Number(e):e},i.prototype.to_text=function(t){var e=0/0;if(this._is_native)this.is_valid()&&this._value.compareTo(h.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),n=r.substring(this._offset+43),s=i.match(/[1-9].*$/),o=n.match(/[1-9]0*$/);e=""+(s?s[0]:"0")+(o?"."+n.substring(0,1+n.length-o[0].length):"")}return!t&&"number"==typeof e&&isNaN(e)?e="0":this._is_negative&&(e="-"+e),e},i.prototype.to_human=function(t){var t=t||{};if(!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;for(var e=this._is_native?h.xns_precision:-this._offset,r=h.bi_10.clone().pow(e),i=this._value.divide(r).toString(10),s=this._value.mod(r).toString(10);s.length0&&(s=s.slice(0,-u))}if("number"==typeof t.min_precision)for(;s.lengthr;r++)e=e&&(12===r||13===r||14===r||0===t[0]);if(e){var i=String.fromCharCode(t[12])+String.fromCharCode(t[13])+String.fromCharCode(t[14]);this._value=/^[A-Z0-9]{3}$/.test(i)&&"XRP"!==i?i:"\0\0\0"===i?0:0/0}else this._value=0/0}else this._value=0/0;return this},r.prototype.is_native=function(){return!isNaN(this._value)&&!this._value},r.prototype.is_valid=function(){return"string"==typeof this._value||!isNaN(this._value)},r.prototype.to_json=function(){return this._value?this._value:"XRP"},r.prototype.to_human=function(){return this._value?this._value:"XRP"},e.Currency=r},4:function(t,e,r){function i(t){return s.codec.bytes.fromBits(s.hash.sha256.hash(s.codec.bytes.toBits(t)))}function n(t){return i(i(t))}var s=r(9).sjcl,o=r(9),a=r(29),c=o.jsbn.BigInteger,u={},h=u.alphabets={ripple:"rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz",tipple:"RPShNAF39wBUDnEGHJKLM4pQrsT7VWXYZ2bcdeCg65jkm8ofqi1tuvaxyz",bitcoin:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"};a(u,{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}),u.encode=function(t,e){for(var r=h[e||"ripple"],i=new c(String(r.length)),n=new c,s=new c,o=new c(t),a=[];o.compareTo(c.ZERO)>0;)o.divRemTo(i,n,s),n.copyTo(o),a.push(r[s.intValue()]);for(var u=0;u!==t.length&&!t[u];u+=1)a.push(r[0]);return a.reverse().join("")},u.decode=function(t,e){if("string"!=typeof t)return void 0;var r,i=h[e||"ripple"],n=new c(String(i.length)),s=new c;for(r=0;r!=t.length&&t[r]===i[0];r+=1);for(;r!==t.length;r+=1){var a=i.indexOf(t[r]);if(0>a)return void 0;var u=new c;u.fromInt(a),s=s.multiply(n).add(u)}for(var f=s.toByteArray().map(function(t){return t?0>t?256+t:t:0}),l=0;l!=f.length&&!f[l];)l+=1;l&&(f=f.slice(l));for(var _=0;_!==t.length&&t[_]===i[0];)_+=1;return[].concat(o.arraySet(_,0),f)},u.verify_checksum=function(t){for(var e=n(t.slice(0,-4)).slice(0,4),r=t.slice(-4),i=!0,s=0;4>s;s++)if(e[s]!==r[s]){i=!1;break}return i},u.encode_check=function(t,e,r){var n=[].concat(t,e),s=i(i(n)).slice(0,4);return u.encode([].concat(n,s),r)},u.decode_check=function(t,e,r){var i=u.decode(e,r);if(!i||i.length<5)return 0/0;if("number"==typeof t&&i[0]!==t)return 0/0;if(Array.isArray(t)){for(var n=!1,s=0,o=t.length;o>s;s++)n|=t[s]===i[0];if(!n)return 0/0}return u.verify_checksum(i)?(i[0]=0,new c(i.slice(0,-4),256)):0/0},e.Base=u},5:function(t,e,r){function i(t){n.call(this),this.remote=t,this._secret=void 0,this._build_path=!1,this.tx_json={Flags:0},this.hash=void 0,this.submit_index=void 0,this.state=void 0,this.finalized=!1,this._previous_signing_hash=void 0}var n=r(24).EventEmitter,s=r(25),o=r(9).sjcl,a=r(2).Amount,c=r(2).Currency,u=r(2).UInt160,h=r(19).Seed,f=r(7).SerializedObject,l=r(18).RippleError,_=r(11);s.inherits(i,n),i.fee_units={"default":10},i.flags={AccountSet:{RequireDestTag:65536,OptionalDestTag:131072,RequireAuth:262144,OptionalAuth:524288,DisallowXRP:1048576,AllowXRP:2097152},OfferCreate:{Passive:65536,ImmediateOrCancel:131072,FillOrKill:262144,Sell:524288},Payment:{NoRippleDirect:65536,PartialPayment:131072,LimitQuality:262144}},i.formats=r(8).tx,i.HASH_SIGN=1398036480,i.HASH_SIGN_TESTNET=1937012736,i.prototype.consts={telLOCAL_ERROR:-399,temMALFORMED:-299,tefFAILURE:-199,terRETRY:-99,tesSUCCESS:0,tecCLAIMED:100},i.prototype.isTelLocal=function(t){return t>=this.consts.telLOCAL_ERROR&&t=this.consts.temMALFORMED&&t=this.consts.tefFAILURE&&t=this.consts.terRETRY&&t=this.consts.tesSUCCESS},i.prototype.isTecClaimed=function(t){return t>=this.consts.tecCLAIMED},i.prototype.isRejected=function(t){return this.isTelLocal(t)||this.isTemMalformed(t)||this.isTefFailure(t)},i.prototype.set_state=function(t){this.state!==t&&(this.state=t,this.emit("state",t))},i.prototype.get_fee=function(){return i.fees["default"].to_json()},i.prototype.complete=function(){if(this.remote&&"undefined"==typeof this.tx_json.Fee&&(this.remote.local_fee||!this.remote.trusted)&&(this.tx_json.Fee=this.remote.fee_tx(this.fee_units()).to_json()),"undefined"==typeof this.tx_json.SigningPubKey&&(!this.remote||this.remote.local_signing)){var t=h.from_json(this._secret),e=t.get_key(this.tx_json.Account);this.tx_json.SigningPubKey=e.to_hex_pub()}return this.tx_json},i.prototype.serialize=function(){return f.from_json(this.tx_json)},i.prototype.signing_hash=function(){var t=i[_.testnet?"HASH_SIGN_TESTNET":"HASH_SIGN"];return f.from_json(this.tx_json).signing_hash(t)},i.prototype.sign=function(){var t=h.from_json(this._secret);delete this.tx_json.TxnSignature;var e=this.signing_hash(),r=this.tx_json.TxnSignature&&e===this._previous_signing_hash;if(!r){var i=t.get_key(this.tx_json.Account),n=i.sign(e,0),s=o.codec.hex.fromBits(n).toUpperCase();this.tx_json.TxnSignature=s}},i.prototype.build_path=function(t){return this._build_path=t,this},i.prototype.destination_tag=function(t){return void 0!==t&&(this.tx_json.DestinationTag=t),this},i._path_rewrite=function(t){var e=t.map(function(t){var e={};return t.hasOwnProperty("account")&&(e.account=u.json_rewrite(t.account)),t.hasOwnProperty("issuer")&&(e.issuer=u.json_rewrite(t.issuer)),t.hasOwnProperty("currency")&&(e.currency=c.json_rewrite(t.currency)),e});return e},i.prototype.path_add=function(t){return this.tx_json.Paths=this.tx_json.Paths||[],this.tx_json.Paths.push(i._path_rewrite(t)),this},i.prototype.paths=function(t){for(var e=0,r=t.length;r>e;e++)this.path_add(t[e]);return this},i.prototype.secret=function(t){this._secret=t},i.prototype.send_max=function(t){return t&&(this.tx_json.SendMax=a.json_rewrite(t)),this},i.prototype.source_tag=function(t){return t&&(this.tx_json.SourceTag=t),this},i.prototype.transfer_rate=function(t){if(this.tx_json.TransferRate=Number(t),this.tx_json.TransferRate<1e9)throw new Error("invalidTransferRate");return this},i.prototype.set_flags=function(t){if(t){var e=i.flags[this.tx_json.TransactionType];void 0===this.tx_json.Flags&&(this.tx_json.Flags=0);for(var r=Array.isArray(t)?t:[t],n=0,s=r.length;s>n;n++){var o=r[n];e.hasOwnProperty(o)&&(this.tx_json.Flags+=e[o])}}return this},i.prototype._account_secret=function(t){return this.remote.secrets[t]},i.prototype.account_set=function(t){if("object"==typeof t){var e=t;t=e.source||e.from}if(!u.is_valid(t))throw new Error("Source address invalid");return this._secret=this._account_secret(t),this.tx_json.TransactionType="AccountSet",this.tx_json.Account=u.json_rewrite(t),this},i.prototype.claim=function(t,e,r,i){if("object"==typeof t){var n=t;i=n.signature,r=n.public_key,e=n.generator,t=n.source||n.from}return this._secret=this._account_secret(t),this.tx_json.TransactionType="Claim",this.tx_json.Generator=e,this.tx_json.PublicKey=r,this.tx_json.Signature=i,this},i.prototype.offer_cancel=function(t,e){if("object"==typeof t){var r=t;e=r.sequence,t=r.source||r.from}if(!u.is_valid(t))throw new Error("Source address invalid");return this._secret=this._account_secret(t),this.tx_json.TransactionType="OfferCancel",this.tx_json.Account=u.json_rewrite(t),this.tx_json.OfferSequence=Number(e),this},i.prototype.offer_create=function(t,e,r,i,n){if("object"==typeof t){var s=t;n=s.cancel_sequence,i=s.expiration,r=s.taker_gets||s.sell,e=s.taker_pays||s.buy,t=s.source||s.from}if(!u.is_valid(t))throw new Error("Source address invalid");return this._secret=this._account_secret(t),this.tx_json.TransactionType="OfferCreate",this.tx_json.Account=u.json_rewrite(t),this.tx_json.TakerPays=a.json_rewrite(e),this.tx_json.TakerGets=a.json_rewrite(r),this.remote.local_fee,i&&(this.tx_json.Expiration=i instanceof Date?i.getTime():Number(i)),n&&(this.tx_json.OfferSequence=Number(n)),this},i.prototype.password_fund=function(t,e){if("object"==typeof t){var r=t;e=r.destination||r.to,t=r.source||r.from}if(!u.is_valid(e))throw new Error("Destination address invalid");return this._secret=this._account_secret(t),this.tx_json.TransactionType="PasswordFund",this.tx_json.Destination=u.json_rewrite(e),this},i.prototype.password_set=function(t,e,r,i,n){if("object"==typeof t){var s=t;n=s.signature,i=s.public_key,r=s.generator,e=s.authorized_key,t=s.source||s.from}if(!u.is_valid(t))throw new Error("Source address invalid");return this._secret=this._account_secret(t),this.tx_json.TransactionType="PasswordSet",this.tx_json.RegularKey=e,this.tx_json.Generator=r,this.tx_json.PublicKey=i,this.tx_json.Signature=n,this},i.prototype.payment=function(t,e,r){if("object"==typeof t){var i=t;r=i.amount,e=i.destination||i.to,t=i.source||i.from}if(!u.is_valid(t))throw new Error("Payment source address invalid");if(!u.is_valid(e))throw new Error("Payment destination address invalid");return/^[\d]+[A-Z]{3}$/.test(r)&&(r=a.from_human(r)),this._secret=this._account_secret(t),this.tx_json.TransactionType="Payment",this.tx_json.Account=u.json_rewrite(t),this.tx_json.Amount=a.json_rewrite(r),this.tx_json.Destination=u.json_rewrite(e),this},i.prototype.ripple_line_set=function(t,e,r,i){if("object"==typeof t){var n=t;i=n.quality_out,r=n.quality_in,e=n.limit,t=n.source||n.from}if(!u.is_valid(t))throw new Error("Source address invalid");return this._secret=this._account_secret(t),this.tx_json.TransactionType="TrustSet",this.tx_json.Account=u.json_rewrite(t),void 0!==e&&(this.tx_json.LimitAmount=a.json_rewrite(e)),r&&(this.tx_json.QualityIn=r),i&&(this.tx_json.QualityOut=i),this},i.prototype.wallet_add=function(t,e,r,i,n){if("object"==typeof t){var s=t;n=s.signature,i=s.public_key,r=s.authorized_key,e=s.amount,t=s.source||s.from}if(!u.is_valid(t))throw new Error("Source address invalid");return this._secret=this._account_secret(t),this.tx_json.TransactionType="WalletAdd",this.tx_json.Amount=a.json_rewrite(e),this.tx_json.RegularKey=r,this.tx_json.PublicKey=i,this.tx_json.Signature=n,this},i.prototype.fee_units=function(){return i.fee_units["default"]},i.prototype.submit=function(t){function e(t,e){t instanceof l||(t=new l(t,e)),i.callback(t)}function r(t){i.callback(null,t)}var i=this;this.callback="function"==typeof t?t:function(){},this.on("error",function(){}),this.once("error",e),this.once("success",r);var n=this.tx_json.Account;return"string"!=typeof n?this.emit("error",new l("tejInvalidAccount","Account is unspecified")):this.remote.account(n).submit(this),this},i.prototype.abort=function(t){if(!this.finalized){var t="function"==typeof t?t:function(){};this.once("final",t),this.emit("abort")}},e.Transaction=i},6:function(t,e,r){function i(t){var e=this;this.nodes=[],this.node_types=["CreatedNode","ModifiedNode","DeletedNode"];for(var r=0,i=t.AffectedNodes.length;i>r;r++){var s=t.AffectedNodes[r],o={};if(e.node_types.forEach(function(t){s.hasOwnProperty(t)&&(o.diffType=t)}),!o.diffType)return null;s=s[o.diffType],o.entryType=s.LedgerEntryType,o.ledgerIndex=s.LedgerIndex,o.fields=n({},s.PreviousFields,s.NewFields,s.FinalFields),o.fieldsPrev=s.PreviousFields||{},o.fieldsNew=s.NewFields||{},o.fieldsFinal=s.FinalFields||{},this.nodes.push(o)}}var n=r(29),s=r(9),o=r(14).UInt160,a=r(2).Amount;i.prototype.each=function(t){for(var e=0,r=this.nodes.length;r>e;e++)t(this.nodes[e],e)},["forEach","map","filter","every","reduce"].forEach(function(t){i.prototype[t]=function(){return Array.prototype[t].apply(this.nodes,arguments)}});var c=["LowLimit","HighLimit","TakerPays","TakerGets"];i.prototype.getAffectedAccounts=function(){var t=[];return this.nodes.forEach(function(e){var r="CreatedNode"===e.diffType?e.fieldsNew:e.fieldsFinal;for(var i in r){var n=r[i];if("string"==typeof n&&o.is_valid(n))t.push(n);else if(-1!==c.indexOf(i)){var s=a.from_json(n),u=s.issuer();u.is_valid()&&!u.is_zero()&&t.push(u.to_json())}}}),s.arrayUnique(t)},i.prototype.getAffectedBooks=function(){var t=[];return this.nodes.forEach(function(e){if("Offer"===e.entryType){var r=a.from_json(e.fields.TakerGets),i=a.from_json(e.fields.TakerPays),n=r.currency().to_json();"XRP"!==n&&(n+="/"+r.issuer().to_json());var s=i.currency().to_json();"XRP"!==s&&(s+="/"+i.issuer().to_json());var o=n+":"+s;t.push(o)}}),s.arrayUnique(t)},e.Meta=i},7:function(t,e,r){!function(t,r){function i(t){if(Array.isArray(t)||r&&r.isBuffer(t))this.buffer=t;else if("string"==typeof t)this.buffer=o.codec.bytes.fromBits(o.codec.hex.toBits(t));else{if(t)throw new Error("Invalid buffer passed.");this.buffer=[]}this.pointer=0}function n(t){return function(e){var r=this.pointer,i=r+e;if(i>this.buffer.length)throw new Error("Buffer length exceeded");var n=this.buffer.slice(r,i);return t&&(this.pointer=i),n}}var s=t(8),o=t(9).sjcl,a=t(29),c=t(20),u=t(21).UInt256,h=t(26),f={0:"Payment",3:"AccountSet",5:"SetRegularKey",7:"OfferCreate",8:"OfferCancel",9:"Contract",10:"RemoveContract",20:"TrustSet",100:"EnableFeature",101:"SetFee"},l={97:"AccountRoot",99:"Contract",100:"DirectoryNode",102:"Features",103:"GeneratorMap",104:"LedgerHashes",110:"Nickname",111:"Offer",114:"RippleState",115:"FeeSettings"},_={0:"tesSUCCESS",100:"tecCLAIM",101:"tecPATH_PARTIAL",102:"tecUNFUNDED_ADD",103:"tecUNFUNDED_OFFER",104:"tecUNFUNDED_PAYMENT",105:"tecFAILED_PROCESSING",121:"tecDIR_FULL",122:"tecINSUF_RESERVE_LINE",123:"tecINSUF_RESERVE_OFFER",124:"tecNO_DST",125:"tecNO_DST_INSUF_XRP",126:"tecNO_LINE_INSUF_RESERVE",127:"tecNO_LINE_REDUNDANT",128:"tecPATH_DRY",129:"tecUNFUNDED",130:"tecMASTER_DISABLED",131:"tecNO_REGULAR_KEY",132:"tecOWNERS"},p={};Object.keys(s.tx).forEach(function(t){p[t[0]]=t}),i.from_json=function(t){var e,t=a({},t),r=new i;switch(typeof t.TransactionType){case"number":if(t.TransactionType=i.lookup_type_tx(t.TransactionType),!t.TransactionType)throw new Error("Transaction type ID is invalid.");break;case"string":if(e=s.tx[t.TransactionType],!Array.isArray(e))throw new Error("Transaction type is invalid");e=e.slice(),t.TransactionType=e.shift();break;default:throw"undefined"!=typeof t.LedgerEntryType?new Error("Ledger entry binary format not yet implemented."):new Error("Object to be serialized must contain either TransactionType or LedgerEntryType.")}return r.serialize(e,t),r},i.prototype.append=function(t){this.buffer=this.buffer.concat(t),this.pointer+=t.length},i.prototype.resetPointer=function(){this.pointer=0},i.prototype.read=n(!0),i.prototype.peek=n(!1),i.prototype.to_bits=function(){return o.codec.bytes.toBits(this.buffer)},i.prototype.to_hex=function(){return o.codec.hex.fromBits(this.to_bits()).toUpperCase()},i.prototype.to_json=function(){var t=this.pointer;this.resetPointer();for(var e={};this.pointers;s++){var a=n[s];r[a]=i.jsonify_structure(t[a],a)}}break;default:r=t}return r},i.prototype.serialize=function(t,e){for(var t=i.sort_typedef(t),r=0,n=t.length;n>r;r++)this.serialize_field(t[r],e)},i.prototype.signing_hash=function(t){var e=new i;return c.Int32.serialize(e,t),e.append(this.buffer),e.hash_sha512_half()},i.prototype.hash_sha512_half=function(){var t=o.codec.bytes.toBits(this.buffer),e=o.bitArray.bitSlice(o.hash.sha512.hash(t),0,256);return u.from_hex(o.codec.hex.fromBits(e))},i.prototype.serialize_field=function(t,e){var r=t[0],n=t[1],o=t[2],a=t[3];if("undefined"!=typeof e[r]){this.append(i.get_field_header(a.id,o));try{a.serialize(this,e[r])}catch(c){throw c.message='Error serializing "'+r+'": '+c.message,c}}else if(n===s.REQUIRED)throw new Error("Missing required field "+r)},i.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},i.sort_typedef=function(t){function e(t,e){return t[3].id!==e[3].id?t[3].id-e[3].id:t[2]-e[2]}return h(Array.isArray(t)),t.sort(e)},i.lookup_type_tx=function(t){return h("string"==typeof t),p[t]},e.SerializedObject=i}(r,r(22).Buffer)},8:function(t,e,r){var i=r(20),n=e.REQUIRED=0,s=e.OPTIONAL=1,o=e.DEFAULT=2;i.Int16.id=1,i.Int32.id=2,i.Int64.id=3,i.Hash128.id=4,i.Hash256.id=5,i.Amount.id=6,i.VariableLength.id=7,i.Account.id=8,i.Object.id=14,i.Array.id=15,i.Int8.id=16,i.Hash160.id=17,i.PathSet.id=18,i.Vector256.id=19;var a=[["TransactionType",n,2,i.Int16],["Flags",s,2,i.Int32],["SourceTag",s,3,i.Int32],["Account",n,1,i.Account],["Sequence",n,4,i.Int32],["Fee",n,8,i.Amount],["OperationLimit",s,29,i.Int32],["SigningPubKey",n,3,i.VariableLength],["TxnSignature",s,4,i.VariableLength]];e.tx={AccountSet:[3].concat(a,[["EmailHash",s,1,i.Hash128],["WalletLocator",s,7,i.Hash256],["WalletSize",s,12,i.Int32],["MessageKey",s,2,i.VariableLength],["Domain",s,7,i.VariableLength],["TransferRate",s,11,i.Int32]]),TrustSet:[20].concat(a,[["LimitAmount",s,3,i.Amount],["QualityIn",s,20,i.Int32],["QualityOut",s,21,i.Int32]]),OfferCreate:[7].concat(a,[["TakerPays",n,4,i.Amount],["TakerGets",n,5,i.Amount],["Expiration",s,10,i.Int32]]),OfferCancel:[8].concat(a,[["OfferSequence",n,25,i.Int32]]),SetRegularKey:[5].concat(a,[["RegularKey",n,8,i.Account]]),Payment:[0].concat(a,[["Destination",n,3,i.Account],["Amount",n,1,i.Amount],["SendMax",s,9,i.Amount],["Paths",o,1,i.PathSet],["InvoiceID",s,17,i.Hash256],["DestinationTag",s,14,i.Int32]]),Contract:[9].concat(a,[["Expiration",n,10,i.Int32],["BondAmount",n,23,i.Int32],["StampEscrow",n,22,i.Int32],["RippleEscrow",n,17,i.Amount],["CreateCode",s,11,i.VariableLength],["FundCode",s,8,i.VariableLength],["RemoveCode",s,9,i.VariableLength],["ExpireCode",s,10,i.VariableLength]]),RemoveContract:[10].concat(a,[["Target",n,7,i.Account]]),EnableFeature:[100].concat(a,[["Feature",n,19,i.Hash256]]),SetFee:[101].concat(a,[["Features",n,9,i.Array],["BaseFee",n,5,i.Int64],["ReferenceFeeUnits",n,30,i.Int32],["ReserveBase",n,31,i.Int32],["ReserveIncrement",n,32,i.Int32]])}},9:function(t,e,r){var e=t.exports=r(12);e.logObject=function(t,e){/MSIE/.test(navigator.userAgent)?console.log(t,JSON.stringify(e)):console.log(t,"",e)}},10:function(t,e,r){function i(t,e){if(n.call(this),"object"!=typeof e)throw new Error("Invalid server configuration.");var r=this;this._remote=t,this._opts=e,this._host=e.host,this._port=e.port,this._secure="boolean"==typeof e.secure?e.secure:!0,this._ws=void 0,this._connected=!1,this._should_connect=!1,this._state=void 0,this._id=0,this._retry=0,this._requests={},this._opts.url=(e.secure?"wss://":"ws://")+e.host+":"+e.port,this.on("message",function(t){r._handle_message(t)}),this.on("response_subscribe",function(t){r._handle_response_subscribe(t)})}var n=r(24).EventEmitter,s=r(25),o=r(9);s.inherits(i,n),i.online_states=["syncing","tracking","proposing","validating","full"],i.prototype._is_online=function(t){return-1!==i.online_states.indexOf(t)},i.prototype._set_state=function(t){if(t!==this._state)switch(this._state=t,this.emit("state",t),t){case"online":this._connected=!0,this.emit("connect");break;case"offline":this._connected=!1,this.emit("disconnect")}},i.prototype._trace=function(){this._remote.trace&&o.logObject.apply(o,arguments)},i.prototype._remote_address=function(){try{var t=this._ws._socket.remoteAddress}catch(e){}return t},i.prototype.websocket_constructor=function(){return r(23)},i.prototype.connect=function(){function t(){e.emit("socket_close"),e._set_state("offline"),i.onopen=i.onerror=i.onclose=i.onmessage=function(){},e._should_connect&&(e._retry+=1,e._retry_timer=setTimeout(function(){e._trace("server: retry"),e._should_connect&&e.connect()},e._retry<40?50:e._retry<100?1e3:e._retry<160?1e4:3e4))}var e=this;if(!this._connected){this._trace("server: connect: %s",this._opts.url),this._ws&&this._ws.close();var r=this.websocket_constructor(),i=this._ws=new r(this._opts.url);this._should_connect=!0,e.emit("connecting"),i.onopen=function(){if(i===e._ws){e.emit("socket_open");var t=e._remote._server_prepare_subscribe();e.request(t)}},i.onerror=function(r){i===e._ws&&(e._trace("server: onerror: %s",r.data||r),t())},i.onclose=function(){i===e._ws&&(e._trace("server: onclose: %s",i.readyState),t())},i.onmessage=function(t){e.emit("message",t.data)}}},i.prototype.disconnect=function(){this._should_connect=!1,this._set_state("offline"),this._ws&&this._ws.close()},i.prototype.send_message=function(t){this._ws&&this._ws.send(JSON.stringify(t))},i.prototype.request=function(t){function e(){r._trace("server: request: %s",t.message),r.send_message(t.message)}var r=this;if(this._ws){t.server=this,t.message.id=this._id,this._requests[t.message.id]=t,this._id++;var i=this._connected||"subscribe"===t.message.command&&1===this._ws.readyState;i?(this._trace("server: request: %s",t.message),this.send_message(t.message)):this.once("connect",e)}else this._trace("server: request: DROPPING: %s",t.message)},i.prototype._handle_message=function(t){var e=this;try{t=JSON.parse(t)}catch(r){}var i="object"!=typeof t||"string"!=typeof t.type;if(!i)switch(t.type){case"response":var n=e._requests[t.id];delete e._requests[t.id],n?"success"===t.status?(this._trace("server: response: %s",t),n.emit("success",t.result),[e,e._remote].forEach(function(e){e.emit("response_"+n.message.command,t.result,n,t)})):t.error&&(this._trace("server: error: %s",t),n.emit("error",{error:"remoteError",error_message:"Remote reported an error.",remote:t})):this._trace("server: UNEXPECTED: %s",t);break;case"path_find":e._remote.trace&&o.logObject("server: path_find: %s",t);break;case"serverStatus":this._set_state(this._is_online(t.server_status)?"online":"offline")}},i.prototype._handle_response_subscribe=function(t){this._server_status=t.server_status,this._is_online(t.server_status)&&this._set_state("online")},e.Server=i},11:function(t,e,r){var i=r(29),n=t.exports={load:function(t){return i(n,t),n}}},12:function(t,e,r){function i(t,e){return function(){console.log("%s: %s",i,arguments.toString),e(arguments)}}function n(t,e){for(var r=new Array(t),i=0;t>i;i++)r[i]=e;return r}function s(t){var e=[],r=0;for(t.length%2&&(e.push(String.fromCharCode(parseInt(t.substring(0,1),16))),r=1);ri?"0"+i.toString(16):i.toString(16)}return e}function a(t){for(var e=new Array(t.length),r=0;rn;n+=e)i.push(t.slice(n,e+n));return i}function h(t,e){console.log(t,JSON.stringify(e,null,2))}function f(t,e){if(!t)throw new Error("Assertion failed"+(e?": "+e:"."))}function l(t){for(var e={},r=[],i=0,n=t.length;n>i;i++){var s=t[i];e[s]||(r.push(s),e[s]=!0)}return r}function _(t){return 1e3*(t+946684800)}Function.prototype.method=function(t,e){return this.prototype[t]=e,this},e.trace=i,e.arraySet=n,e.hexToString=s,e.hexToArray=c,e.stringToArray=a,e.stringToHex=o,e.chunkString=u,e.logObject=h,e.assert=f,e.arrayUnique=l,e.toTimestamp=_,e.sjcl=r(27),e.jsbn=r(28)},13:function(t,e,r){function i(t,e){n.call(this),this.remote=t,this.requested=!1,this.message={command:e,id:void 0}}var n=r(24).EventEmitter,s=r(25),o=r(14).UInt160,a=r(3).Currency;r(5).Transaction,r(15).Account,r(6).Meta,r(16).OrderBook;var c=r(18).RippleError;s.inherits(i,n),i.prototype.request=function(t){this.requested||(this.requested=!0,this.on("error",new Function),this.remote.request(this),this.emit("request",t))},i.prototype.callback=function(t,e,r){function i(e){t.call(s,null,e)}function n(e){e instanceof c||(e=new c(e)),t.call(s,e)}if(t&&"function"==typeof t){var s=this;this.once(e||"success",i),this.once(r||"error",n),this.request()}return this},i.prototype.timeout=function(t,e){function r(){i.timeout(t,e)}var i=this;if(!this.requested)return this.once("request",r),void 0;var n=this.emit,s=!1,o=setTimeout(function(){s=!0,"function"==typeof e&&e(),n.call(i,"timeout")},t);return this.emit=function(){s||(clearTimeout(o),n.apply(i,arguments))},this},i.prototype.set_server=function(t){var e=null;switch(typeof t){case"object":e=t;break;case"string":for(var r,i=0;r=this.remote._servers[i];i++)if(r._host===t){e=r;break}}this.server=e},i.prototype.build_path=function(t){return t&&(this.message.build_path=!0),this},i.prototype.ledger_choose=function(t){return t?this.message.ledger_index=this.remote._ledger_current_index:this.message.ledger_hash=this.remote._ledger_hash,this},i.prototype.ledger_hash=function(t){return this.message.ledger_hash=t,this},i.prototype.ledger_index=function(t){return this.message.ledger_index=t,this},i.prototype.ledger_select=function(t){switch(t){case"current":case"closed":case"verified":this.message.ledger_index=t;break;default:Number(t)?this.message.ledger_index=t:this.message.ledger_hash=t}return this},i.prototype.account_root=function(t){return this.message.account_root=o.json_rewrite(t),this},i.prototype.index=function(t){return this.message.index=t,this},i.prototype.offer_id=function(t,e){return this.message.offer={account:o.json_rewrite(t),seq:e},this},i.prototype.offer_index=function(t){return this.message.offer=t,this},i.prototype.secret=function(t){return t&&(this.message.secret=t),this},i.prototype.tx_hash=function(t){return this.message.tx_hash=t,this},i.prototype.tx_json=function(t){return this.message.tx_json=t,this},i.prototype.tx_blob=function(t){return this.message.tx_blob=t,this},i.prototype.ripple_state=function(t,e,r){return this.message.ripple_state={currency:r,accounts:[o.json_rewrite(t),o.json_rewrite(e)]},this},i.prototype.accounts=function(t,e){Array.isArray(t)||(t=[t]);var r=t.map(function(t){return o.json_rewrite(t)});return e?this.message.rt_accounts=r:this.message.accounts=r,this},i.prototype.rt_accounts=function(t){return this.accounts(t,!0)},i.prototype.books=function(t,e){function r(t){if(!c[t])throw new Error("Missing "+t);var e=u[t]={currency:a.json_rewrite(c[t].currency)};"XRP"!==e.currency&&(e.issuer=o.json_rewrite(c[t].issuer))}for(var i=[],n=0,s=t.length;s>n;n++){var c=t[n],u={};r("taker_gets"),r("taker_pays"),e&&(u.snapshot=!0),c.both&&(u.both=!0),i.push(u)}return this.message.books=i,this},e.Request=i},14:function(t,e,r){r(9).sjcl;var i=r(9),n=r(11),s=r(29),o=i.jsbn.BigInteger,a=r(31).UInt,c=r(4).Base,u=s(function(){this._value=0/0},a);u.width=20,u.prototype=s({},a.prototype),u.prototype.constructor=u,u.ACCOUNT_ZERO="rrrrrrrrrrrrrrrrrrrrrhoLvTp",u.ACCOUNT_ONE="rrrrrrrrrrrrrrrrrrrrBZbvji";var h=u.HEX_ZERO="0000000000000000000000000000000000000000",f=u.HEX_ONE="0000000000000000000000000000000000000001";u.STR_ZERO=i.hexToString(h),u.STR_ONE=i.hexToString(f),u.prototype.parse_json=function(t){return n.accounts&&t in n.accounts&&(t=n.accounts[t].account),this._value="number"!=typeof t||isNaN(t)?"string"!=typeof t?0/0:"r"===t[0]?c.decode_check(c.VER_ACCOUNT_ID,t):0/0:new o(String(t)),this},u.prototype.to_json=function(t){var t=t||{},e=0/0;return this._value instanceof o&&(e=c.encode_check(c.VER_ACCOUNT_ID,this.to_bytes()),t.gateways&&e in t.gateways&&(e=t.gateways[e])),e},e.UInt160=u},15:function(t,e,r){function i(t,e){function r(t){~i.subscribe_events.indexOf(t)&&(!h._subs&&h._remote._connected&&h._remote.request_subscribe().accounts(h._account_id).request(),h._subs+=1)}function s(t){~i.subscribe_events.indexOf(t)&&(h._subs-=1,!h._subs&&h._remote._connected&&h._remote.request_unsubscribe().accounts(h._account_id).request())}function c(t){h._account.is_valid()&&h._subs&&t.accounts(h._account_id)}function u(t){var e=!1;t.mmeta.each(function(t){var r="AccountRoot"===t.entryType&&t.fields.Account===h._account_id;r&&(o(h._entry,t.fieldsNew,t.fieldsFinal),e=!0)}),e&&h.emit("entry",h._entry)}n.call(this);var h=this;return this._remote=t,this._account=a.from_json(e),this._account_id=this._account.to_json(),this._subs=0,this._entry={},this.on("newListener",r),this.on("removeListener",s),this._remote.on("prepare_subscribe",c),this.on("transaction",u),this}var n=r(24).EventEmitter,s=r(25),o=r(29);r(2).Amount;var a=r(14).UInt160,c=r(30).TransactionManager;s.inherits(i,n),i.subscribe_events=["transaction","entry"],i.prototype.to_json=function(){return this._account.to_json()},i.prototype.is_valid=function(){return this._account.is_valid()},i.prototype.get_info=function(t){var t="function"==typeof t?t:function(){},e=this._remote.request_account_info(this._account_id,t);return e},i.prototype.entry=function(t){var e=this,t="function"==typeof t?t:function(){};return this.get_info(function(r,i){r?t(r):(o(e._entry,i.account_data),e.emit("entry",e._entry),t(null,i))}),this},i.prototype.get_next_sequence=function(t){var t="function"==typeof t?t:function(){};return this.get_info(function(e,r){e?t(e):t(null,r.account_data.Sequence)}),this},i.prototype.lines=function(t){function e(e,i){e?t(e):(r._lines=i.lines,r.emit("lines",r._lines),t(null,i))}var r=this,t="function"==typeof t?t:function(){};return this._remote.request_account_lines(this._account_id,e),this},i.prototype.notify=i.prototype.notifyTx=function(t){if(this._subs){this.emit("transaction",t);var e=t.transaction.Account;if(!e)return;e===this._account_id?this.emit("transaction-outbound",t):this.emit("transaction-inbound",t)}},i.prototype.submit=function(t){this._tx_manager||(this._tx_manager=new c(this)),this._tx_manager.submit(t)},e.Account=i},16:function(t,e,r){function i(t,e,r,s,o){n.call(this);var a=this;return this._remote=t,this._currency_gets=e,this._issuer_gets=r,this._currency_pays=s,this._issuer_pays=o,this._subs=0,this._sync=!1,this._offers=[],this.on("newListener",function(t){-1!==i.subscribe_events.indexOf(t)&&(!a._subs&&a._remote._connected&&a._subscribe(),a._subs+=1)}),this.on("removeListener",function(t){~i.subscribe_events.indexOf(t)&&(a._subs-=1,!a._subs&&a._remote._connected&&(a._sync=!1,a._remote.request_unsubscribe().books([a.to_json()]).request()))}),this._remote.on("connect",function(){a._subs&&a._subscribe()}),this._remote.on("disconnect",function(){a._sync=!1}),this}var n=r(24).EventEmitter,s=r(25),o=r(2).Amount,a=r(14).UInt160,c=r(3).Currency,u=r(29);s.inherits(i,n),i.subscribe_events=["transaction","model","trade"],i.prototype._subscribe=function(){var t=this,e=t._remote.request_subscribe();e.books([t.to_json()],!0),e.callback(function(e,r){e||(t._sync=!0,t._offers=r.offers,t.emit("model",t._offers))})},i.prototype.to_json=function(){var t={taker_gets:{currency:this._currency_gets},taker_pays:{currency:this._currency_pays}};return"XRP"!==this._currency_gets&&(t.taker_gets.issuer=this._issuer_gets),"XRP"!==this._currency_pays&&(t.taker_pays.issuer=this._issuer_pays),t},i.prototype.is_valid=function(){return c.is_valid(this._currency_pays)&&("XRP"===this._currency_pays||a.is_valid(this._issuer_pays))&&c.is_valid(this._currency_gets)&&("XRP"===this._currency_gets||a.is_valid(this._issuer_gets))&&!("XRP"===this._currency_pays&&"XRP"===this._currency_gets)},i.prototype.trade=function(t){var e="";return o.from_json(e)},i.prototype.notify=i.prototype.notifyTx=function(t){var e=this,r=!1,i=this.trade("gets"),n=this.trade("pays"); +t.mmeta.each(function(s){if("Offer"===s.entryType){var a,c,h;switch(s.diffType){case"DeletedNode":case"ModifiedNode":var f="DeletedNode"===s.diffType;for(a=0,c=e._offers.length;c>a;a++)if(h=e._offers[a],h.index===s.ledgerIndex){f?e._offers.splice(a,1):u(h,s.fieldsFinal),r=!0;break}if("OfferCancel"===t.transaction.TransactionType)return;i=i.add(s.fieldsPrev.TakerGets),n=n.add(s.fieldsPrev.TakerPays),f||(i=i.subtract(s.fieldsFinal.TakerGets),n=n.subtract(s.fieldsFinal.TakerPays));break;case"CreatedNode":var l=o.from_json(s.fields.TakerPays).ratio_human(s.fields.TakerGets);for(a=0,c=e._offers.length;c>a;a++){h=e._offers[a];var _=o.from_json(h.TakerPays).ratio_human(h.TakerGets);if(l.compareTo(_)<=0){var p=s.fields;p.index=s.ledgerIndex,e._offers.splice(a,0,s.fields),r=!0;break}}}}}),this._subs&&(this.emit("transaction",t),r&&this.emit("model",this._offers),i.is_zero()||this.emit("trade",n,i))},i.prototype.offers=function(t){return"function"==typeof t&&(this._sync?t(this._offers):this.once("model",t)),this},i.prototype.offersSync=function(){return this._offers},e.OrderBook=i},17:function(t,e,r){function i(t,e,r,i,s){n.call(this),this.remote=t,this.src_account=e,this.dst_account=r,this.dst_amount=i,this.src_currencies=s}var n=r(24).EventEmitter,s=r(25),o=r(2).Amount;r(29),s.inherits(i,n),i.prototype.create=function(){function t(t,r){t?e.emit("error",t):e.notify_update(r)}var e=this,r=this.remote.request_path_find_create(this.src_account,this.dst_account,this.dst_amount,this.src_currencies,t);r.request()},i.prototype.close=function(){this.remote.request_path_find_close().request(),this.emit("end"),this.emit("close")},i.prototype.notify_update=function(t){var e=t.source_account,r=t.destination_account,i=o.from_json(t.destination_amount);this.src_account===e&&this.dst_account===r&&this.dst_amount.equals(i)&&this.emit("update",t)},i.prototype.notify_superceded=function(){this.emit("end"),this.emit("superceded")},e.PathFind=i},18:function(t,e,r){function i(t,e){switch(typeof t){case"object":s(this,t);break;case"string":this.result=t,this.result_message=e}this.result=this.result||this.error||"Error",this.result_message=this.result_message||this.error_message||"Error",this.message=this.result_message;var r;Error.captureStackTrace?Error.captureStackTrace(this,t||this):(r=(new Error).stack)&&(this.stack=r)}var n=r(25),s=r(29);n.inherits(i,Error),i.prototype.name="RippleError",e.RippleError=i},19:function(t,e,r){function i(t,e){return[].concat(t,e>>24,255&e>>16,255&e>>8,255&e)}function n(t){return o.bitArray.bitSlice(o.hash.sha512.hash(o.codec.bytes.toBits(t)),0,256)}var s=r(9),o=s.sjcl,a=r(29),c=s.jsbn.BigInteger,u=r(4).Base,h=r(31).UInt;r(21).UInt256;var f=r(32).KeyPair,l=a(function(){this._curve=o.ecc.curves.c256,this._value=0/0},h);l.width=16,l.prototype=a({},h.prototype),l.prototype.constructor=l,l.prototype.parse_json=function(t){return"string"==typeof t?t.length?"s"===t[0]?this._value=u.decode_check(u.VER_FAMILY_SEED,t):32===t.length?this._value=this.parse_hex(t):this.parse_passphrase(t):this._value=0/0:this._value=0/0,this},l.prototype.parse_passphrase=function(t){if("string"!=typeof t)throw new Error("Passphrase must be a string");var e=o.hash.sha512.hash(o.codec.utf8String.toBits(t)),r=o.bitArray.bitSlice(e,0,128);return this.parse_bits(r),this},l.prototype.to_json=function(){if(!(this._value instanceof c))return 0/0;var t=u.encode_check(u.VER_FAMILY_SEED,this.to_bytes());return t},l.prototype.get_key=function(){if(!this.is_valid())throw new Error("Cannot generate keys from invalid seed!");var t,e,r=this._curve,s=0,a=0;do t=o.bn.fromBits(n(i(this.to_bytes(),a))),a++;while(!r.r.greaterEquals(t));e=r.G.mult(t);var c;a=0;do c=o.bn.fromBits(n(i(i(e.toBytesCompressed(),s),a))),a++;while(!r.r.greaterEquals(c));return c=c.add(t).mod(r.r),f.from_bn_secret(c)},e.Seed=l},20:function(t,e,r){function i(t){return"number"==typeof t&&isFinite(t)}function n(t){return"string"==typeof t}function s(t){return n(t)&&/^[0-9A-F]{0,16}$/i.test(t)}function o(t){return n(t)&&/^[A-Z]{3}$/.test(t)}function a(t){return t instanceof S}function c(t,e,r){var i=T.fromBits(k.toBits(e));r||A.serialize_varint(t,i.length),t.append(i)}function u(t){return v.codec.hex.fromBits(v.codec.bytes.toBits(t)).toUpperCase()}function h(t,e,r){if(!i(e))throw new Error("Value is not a number");if(0>e||e>=Math.pow(256,r))throw new Error("Value out of bounds");for(var n=[],s=0;r>s;s++)n.unshift(255&e>>>8*s);t.append(n)}function f(t,e){for(var r=0,i=0;e>i;i++)r+=t.read(1)[0]<<8*(e-i-1);return r}function l(t,e,r){var i=G[e],n=i[0],s=i[1],o=(16>n?n<<4:0)|(16>s?s:0);j.serialize(t,o),n>=16&&j.serialize(t,n),s>=16&&j.serialize(t,s);var a=V[n];a.serialize(t,r)}function _(t){var e=t.read(1)[0],r=e>>4;0===r&&(r=t.read(1)[0]);var i=V[r];p(i,"Unknown type: "+r);var n=15&e,s=s=0===n?H[r][t.read(1)[0]]:H[r][n];return p(s,"Unknown field: "+e),[s,i.parse(t)]}var p=r(26),d=r(29),y=r(9),v=y.sjcl,m=r(33).UInt128,g=r(14).UInt160,b=r(21).UInt256,w=r(2),E=w.Amount,x=w.Currency,k=v.codec.hex,T=v.codec.bytes,S=y.jsbn.BigInteger,A=function(t){d(this,t)};A.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),255&e>>>8,255&e])}},A.prototype.parse_varint=function(t){var e,r,i,n=t.read(1)[0];if(n>254)throw new Error("Invalid varint length indicator");return 192>=n?i=n:240>=n?(e=t.read(1)[0],i=193+256*(n-193)+e):254>=n&&(e=t.read(1)[0],r=t.read(1)[0],i=12481+65536*(n-241)+256*e+r),i};var j=e.Int8=new A({serialize:function(t,e){h(t,e,1)},parse:function(t){return f(t,1)}}),B=e.Int16=new A({serialize:function(t,e){h(t,e,2)},parse:function(t){return f(t,2)}}),q=e.Int32=new A({serialize:function(t,e){h(t,e,4)},parse:function(t){return f(t,4)}}),I=e.Int64=new A({serialize:function(t,e){var r;if(i(e)){if(e=Math.floor(e),0>e)throw new Error("Negative value for unsigned Int64 is invalid.");r=new S(String(e),10)}else if(n(e)){if(!s(e))throw new Error("Not a valid hex Int64.");r=new S(e,16)}else{if(!a(e))throw new Error("Invalid type for Int64");if(e.compareTo(S.ZERO)<0)throw new Error("Negative value for unsigned Int64 is invalid.");r=e}var o=r.toString(16);if(o.length>16)throw new Error("Int64 is too large");for(;o.length<16;)o="0"+o;return c(t,o,!0)},parse:function(t){var e=f(t,4),r=f(t,4),i=new S(String(e));return i.shiftLeft(32),i.add(r),i}}),R=e.Hash128=new A({serialize:function(t,e){var r=m.from_json(e);if(!r.is_valid())throw new Error("Invalid Hash128");c(t,r.to_hex(),!0)},parse:function(t){return m.from_bytes(t.read(16))}}),D=e.Hash256=new A({serialize:function(t,e){var r=b.from_json(e);if(!r.is_valid())throw new Error("Invalid Hash256");c(t,r.to_hex(),!0)},parse:function(t){return b.from_bytes(t.read(32))}}),O=e.Hash160=new A({serialize:function(t,e){var r=g.from_json(e);if(!r.is_valid())throw new Error("Invalid Hash160");c(t,r.to_hex(),!0)},parse:function(t){return g.from_bytes(t.read(20))}}),M=new A({serialize:function(t,e){var r=e.to_json().toUpperCase();if(!o(r))throw new Error("Tried to serialize invalid/unimplemented currency type.");if("XRP"===r)c(t,g.HEX_ZERO,!0);else{var i=r.toUpperCase(),n=y.arraySet(20,0);n[12]=255&i.charCodeAt(0),n[13]=255&i.charCodeAt(1),n[14]=255&i.charCodeAt(2),t.append(n)}},parse:function(t){var e=t.read(20),r=x.from_bytes(e);return r}}),L=e.Amount=new A({serialize:function(t,e){var r=E.from_json(e);if(!r.is_valid())throw new Error("Not a valid Amount object.");var i=y.arraySet(8,0);if(r.is_native()){var n=r._value.toString(16);if(n.length>16)throw new Error("Value out of bounds");for(;n.length<16;)n="0"+n;i=T.fromBits(k.toBits(n)),i[0]&=63,r.is_negative()||(i[0]|=64)}else{var s=0,o=0;s|=1<<31,r.is_zero()||(r.is_negative()||(s|=1<<30),s|=(255&97+r._offset)<<22,s|=4194303&r._value.shiftRight(32).intValue(),o=4294967295&r._value.intValue()),i=v.codec.bytes.fromBits([s,o])}if(t.append(i),!r.is_native()){var a=r.currency();M.serialize(t,a),t.append(r.issuer().to_bytes())}},parse:function(t){for(var e=new E,r=t.read(8),i=!(127&r[0]),n=1;8>n;n++)i=i&&!r[n];if(128&r[0]){var s=M.parse(t),o=t.read(20),a=g.from_bytes(o),c=((63&r[0])<<2)+(r[1]>>>6)-97,u=r.slice(1);u[0]&=63;var h=new S(u,256);if(h.equals(S.ZERO)&&!i)throw new Error("Invalid zero representation");e._value=h,e._offset=c,e._currency=s,e._issuer=a,e._is_native=!1}else{var f=r.slice();f[0]&=63,e._value=new S(f,256),e._is_native=!0}return e._is_negative=!(i||64&r[0]),e}}),C=e.VariableLength=new A({serialize:function(t,e){if("string"!=typeof e)throw new Error("Unknown datatype.");c(t,e)},parse:function(t){var e=this.parse_varint(t);return u(t.read(e))}}),N=e.Account=new A({serialize:function(t,e){var r=g.from_json(e);if(!r.is_valid())throw new Error("Invalid account!");c(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=g.from_bytes(t.read(e));return r}}),F=e.PathSet=new A({typeBoundary:255,typeEnd:0,typeAccount:1,typeCurrency:16,typeIssuer:32,serialize:function(t,e){for(var r=0,i=e.length;i>r;r++){r&&j.serialize(t,this.typeBoundary);for(var n=0,s=e[r].length;s>n;n++){var o=e[r][n],a=0;if(o.account&&(a|=this.typeAccount),o.currency&&(a|=this.typeCurrency),o.issuer&&(a|=this.typeIssuer),j.serialize(t,a),o.account&&t.append(g.from_json(o.account).to_bytes()),o.currency){var c=x.from_json(o.currency);M.serialize(t,c)}o.issuer&&t.append(g.from_json(o.issuer).to_bytes())}}j.serialize(t,this.typeEnd)},parse:function(t){for(var e,r=[],i=[];(e=t.read(1)[0])!==this.typeEnd;)if(e===this.typeBoundary)i&&r.push(i),i=[];else{var n={};if(e&this.typeAccount&&(n.account=O.parse(t)),e&this.typeCurrency&&(n.currency=M.parse(t)),e&this.typeIssuer&&(n.issuer=O.parse(t)),!(n.account||n.currency||n.issuer))throw new Error("Invalid path entry");i.push(n)}return i&&r.push(i),r}}),P=e.Vector256=new A({serialize:function(t,e){A.serialize_varint(t,e.length);for(var r=0,i=e.length;i>r;r++)D.serialize(t,e[r])},parse:function(t){for(var e=this.parse_varint(t),r=[],i=0;e>i;i++)r.push(D.parse(t));return r}});e.serialize=e.serialize_whatever=l,e.parse=e.parse_whatever=_;var z=e.Object=new A({serialize:function(t,e){for(var r=Object.keys(e),i=0;ir;r++){var n=Object.keys(e[r]);if(1!==n.length)throw Error("Cannot serialize an array containing non-single-key objects");var s=n[0],o=e[r][s];l(t,s,o)}j.serialize(t,241)},parse:function(t){for(var e=[];241!==t.peek(1)[0];){var r=_(t),i={};i[r[0]]=r[1],e.push(i)}return t.read(1),e}}),V=[void 0,B,q,I,R,D,L,C,N,void 0,void 0,void 0,void 0,void 0,z,U,j,O,F,P],H={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",16:"BookDirectory",17:"InvoiceID",18:"Nickname",19:"Feature"},6:{1:"Amount",2:"Balance",3:"LimitAmount",4:"TakerPays",5:"TakerGets",6:"LowLimit",7:"HighLimit",8:"Fee",9:"SendMax",16:"MinimumOffer",17:"RippleEscrow"},7:{1:"PublicKey",2:"MessageKey",3:"SigningPubKey",4:"TxnSignature",5:"Generator",6:"Signature",7:"Domain",8:"FundCode",9:"RemoveCode",10:"ExpireCode",11:"CreateCode"},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"},15:{1:void 0,2:"SigningAccounts",3:"TxnSignatures",4:"Signatures",5:"Template",6:"Necessary",7:"Sufficient",8:"AffectedNodes"},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:"Features"}},G={};Object.keys(H).forEach(function(t){Object.keys(H[t]).forEach(function(e){G[H[t][e]]=[Number(t),Number(e)]})})},21:function(t,e,r){r(9).sjcl;var i=r(9);r(11);var n=r(29);i.jsbn.BigInteger;var s=r(31).UInt;r(4).Base;var o=n(function(){this._value=0/0},s);o.width=32,o.prototype=n({},s.prototype),o.prototype.constructor=o;var a=o.HEX_ZERO="0000000000000000000000000000000000000000000000000000000000000000",c=o.HEX_ONE="0000000000000000000000000000000000000000000000000000000000000001";o.STR_ZERO=i.hexToString(a),o.STR_ONE=i.hexToString(c),e.UInt256=o},22:function(t,e,r){!function(t,r){function i(t){this.length=t}function n(t){return 16>t?"0"+t.toString(16):t.toString(16)}function s(t){for(var e=[],r=0;rn&&!(n+r>=e.length||n>=t.length);)e[n+r]=t[n],n++;return n}function u(t){try{return decodeURIComponent(t)}catch(e){return String.fromCharCode(65533)}}function h(t){return t=~~Math.ceil(+t),0>t?0:t}function r(t,e,n){if(!(this instanceof r))return new r(t,e,n);var s;if("number"==typeof n)this.length=h(e),this.parent=t,this.offset=n;else{switch(s=typeof t){case"number":this.length=h(t);break;case"string":this.length=r.byteLength(t,e);break;case"object":this.length=h(t.length);break;default:throw new Error("First argument needs to be a number, array or string.")}if(this.length>r.poolSize?(this.parent=new i(this.length),this.offset=0):((!B||B.length-B.used>>0):(n=t.parent[t.offset+e+2]<<16,n|=t.parent[t.offset+e+1]<<8,n|=t.parent[t.offset+e],n+=t.parent[t.offset+e+3]<<24>>>0),n}function d(t,e,r,i){var n,s;return i||(j.ok("boolean"==typeof r,"missing or invalid endian"),j.ok(void 0!==e&&null!==e,"missing offset"),j.ok(e+1=0,"specified a negative value for writing an unsigned value"),j.ok(e>=t,"value is larger than maximum value for type"),j.ok(Math.floor(t)===t,"value has a fractional component")}function b(t,e,r,i,n){n||(j.ok(void 0!==e&&null!==e,"missing value"),j.ok("boolean"==typeof i,"missing or invalid endian"),j.ok(void 0!==r&&null!==r,"missing offset"),j.ok(r+1>>8,t.parent[t.offset+r+1]=255&e):(t.parent[t.offset+r+1]=(65280&e)>>>8,t.parent[t.offset+r]=255&e)}function w(t,e,r,i,n){n||(j.ok(void 0!==e&&null!==e,"missing value"),j.ok("boolean"==typeof i,"missing or invalid endian"),j.ok(void 0!==r&&null!==r,"missing offset"),j.ok(r+3>>24,t.parent[t.offset+r+1]=255&e>>>16,t.parent[t.offset+r+2]=255&e>>>8,t.parent[t.offset+r+3]=255&e):(t.parent[t.offset+r+3]=255&e>>>24,t.parent[t.offset+r+2]=255&e>>>16,t.parent[t.offset+r+1]=255&e>>>8,t.parent[t.offset+r]=255&e)}function E(t,e,r){j.ok("number"==typeof t,"cannot write a non-number as a number"),j.ok(e>=t,"value larger than maximum allowed value"),j.ok(t>=r,"value smaller than minimum allowed value"),j.ok(Math.floor(t)===t,"value has a fractional component")}function x(t,e,r){j.ok("number"==typeof t,"cannot write a non-number as a number"),j.ok(e>=t,"value larger than maximum allowed value"),j.ok(t>=r,"value smaller than minimum allowed value")}function k(t,e,r,i,n){n||(j.ok(void 0!==e&&null!==e,"missing value"),j.ok("boolean"==typeof i,"missing or invalid endian"),j.ok(void 0!==r&&null!==r,"missing offset"),j.ok(r+1=0?b(t,e,r,i,n):b(t,65535+e+1,r,i,n)}function T(t,e,r,i,n){n||(j.ok(void 0!==e&&null!==e,"missing value"),j.ok("boolean"==typeof i,"missing or invalid endian"),j.ok(void 0!==r&&null!==r,"missing offset"),j.ok(r+3=0?w(t,e,r,i,n):w(t,4294967295+e+1,r,i,n)}function S(e,r,i,n,s){s||(j.ok(void 0!==r&&null!==r,"missing value"),j.ok("boolean"==typeof n,"missing or invalid endian"),j.ok(void 0!==i&&null!==i,"missing offset"),j.ok(i+3i;i++)if(t[i]=n(this[i]),i==e.INSPECT_MAX_BYTES){t[i+1]="...";break}return""},i.prototype.hexSlice=function(t,e){var r=this.length;(!t||0>t)&&(t=0),(!e||0>e||e>r)&&(e=r);for(var i="",s=t;e>s;s++)i+=n(this[s]);return i},i.prototype.toString=function(t,e,r){if(t=String(t||"utf8").toLowerCase(),e=+e||0,"undefined"==typeof r&&(r=this.length),+r==e)return"";switch(t){case"hex":return this.hexSlice(e,r);case"utf8":case"utf-8":return this.utf8Slice(e,r);case"ascii":return this.asciiSlice(e,r);case"binary":return this.binarySlice(e,r);case"base64":return this.base64Slice(e,r);case"ucs2":case"ucs-2":return this.ucs2Slice(e,r);default:throw new Error("Unknown encoding")}},i.prototype.hexWrite=function(t,e,r){e=+e||0;var n=this.length-e;r?(r=+r,r>n&&(r=n)):r=n;var s=t.length;if(s%2)throw new Error("Invalid hex string");r>s/2&&(r=s/2);for(var o=0;r>o;o++){var a=parseInt(t.substr(2*o,2),16);if(isNaN(a))throw new Error("Invalid hex string");this[e+o]=a}return i._charsWritten=2*o,o},i.prototype.write=function(t,e,r,i){if(isFinite(e))isFinite(r)||(i=r,r=void 0);else{var n=i;i=e,e=r,r=n}e=+e||0;var s=this.length-e;switch(r?(r=+r,r>s&&(r=s)):r=s,i=String(i||"utf8").toLowerCase()){case"hex":return this.hexWrite(t,e,r);case"utf8":case"utf-8":return this.utf8Write(t,e,r);case"ascii":return this.asciiWrite(t,e,r);case"binary":return this.binaryWrite(t,e,r);case"base64":return this.base64Write(t,e,r);case"ucs2":case"ucs-2":return this.ucs2Write(t,e,r);default:throw new Error("Unknown encoding")}},i.prototype.slice=function(t,e){if(void 0===e&&(e=this.length),e>this.length)throw new Error("oob");if(t>e)throw new Error("oob");return new r(this,e-t,+t)},i.prototype.copy=function(t,e,r,i){for(var n=[],s=r;i>s;s++)j.ok("undefined"!=typeof this[s],"copying undefined buffer bytes!"),n.push(this[s]);for(var s=e;si;i++)if(t[i]=n(this.parent[i+this.offset]),i==e.INSPECT_MAX_BYTES){t[i+1]="...";break}return""},r.prototype.get=function(t){if(0>t||t>=this.length)throw new Error("oob");return this.parent[this.offset+t]},r.prototype.set=function(t,e){if(0>t||t>=this.length)throw new Error("oob");return this.parent[this.offset+t]=e},r.prototype.write=function(t,e,n,s){if(isFinite(e))isFinite(n)||(s=n,n=void 0);else{var o=s;s=e,e=n,n=o}e=+e||0;var a=this.length-e;n?(n=+n,n>a&&(n=a)):n=a,s=String(s||"utf8").toLowerCase();var c;switch(s){case"hex":c=this.parent.hexWrite(t,this.offset+e,n);break;case"utf8":case"utf-8":c=this.parent.utf8Write(t,this.offset+e,n);break;case"ascii":c=this.parent.asciiWrite(t,this.offset+e,n);break;case"binary":c=this.parent.binaryWrite(t,this.offset+e,n);break;case"base64":c=this.parent.base64Write(t,this.offset+e,n);break;case"ucs2":case"ucs-2":c=this.parent.ucs2Write(t,this.offset+e,n);break;default:throw new Error("Unknown encoding")}return r._charsWritten=i._charsWritten,c},r.prototype.toString=function(t,e,r){switch(t=String(t||"utf8").toLowerCase(),"undefined"==typeof e||0>e?e=0:e>this.length&&(e=this.length),"undefined"==typeof r||r>this.length?r=this.length:0>r&&(r=0),e+=this.offset,r+=this.offset,t){case"hex":return this.parent.hexSlice(e,r);case"utf8":case"utf-8":return this.parent.utf8Slice(e,r);case"ascii":return this.parent.asciiSlice(e,r);case"binary":return this.parent.binarySlice(e,r);case"base64":return this.parent.base64Slice(e,r);case"ucs2":case"ucs-2":return this.parent.ucs2Slice(e,r);default:throw new Error("Unknown encoding")}},r.byteLength=i.byteLength,r.prototype.fill=function(t,e,r){if(t||(t=0),e||(e=0),r||(r=this.length),"string"==typeof t&&(t=t.charCodeAt(0)),"number"!=typeof t||isNaN(t))throw new Error("value is not a number");if(e>r)throw new Error("end < start");if(r===e)return 0;if(0==this.length)return 0;if(0>e||e>=this.length)throw new Error("start out of bounds");if(0>r||r>this.length)throw new Error("end out of bounds");return this.parent.fill(t,e+this.offset,r+this.offset)},r.prototype.copy=function(t,e,r,i){var n=this;if(r||(r=0),i||(i=this.length),e||(e=0),r>i)throw new Error("sourceEnd < sourceStart");if(i===r)return 0;if(0==t.length||0==n.length)return 0;if(0>e||e>=t.length)throw new Error("targetStart out of bounds");if(0>r||r>=n.length)throw new Error("sourceStart out of bounds");if(0>i||i>n.length)throw new Error("sourceEnd out of bounds");return i>this.length&&(i=this.length),t.length-ethis.length)throw new Error("oob");if(t>e)throw new Error("oob");return new r(this.parent,e-t,+t+this.offset)},r.prototype.utf8Slice=function(t,e){return this.toString("utf8",t,e)},r.prototype.binarySlice=function(t,e){return this.toString("binary",t,e)},r.prototype.asciiSlice=function(t,e){return this.toString("ascii",t,e)},r.prototype.utf8Write=function(t,e){return this.write(t,e,"utf8")},r.prototype.binaryWrite=function(t,e){return this.write(t,e,"binary")},r.prototype.asciiWrite=function(t,e){return this.write(t,e,"ascii")},r.prototype.readUInt8=function(t,e){var r=this;return e||(j.ok(void 0!==t&&null!==t,"missing offset"),j.ok(t=0?i.writeUInt8(t,e,r):i.writeUInt8(255+t+1,e,r)},r.prototype.writeInt16LE=function(t,e,r){k(this,t,e,!1,r)},r.prototype.writeInt16BE=function(t,e,r){k(this,t,e,!0,r)},r.prototype.writeInt32LE=function(t,e,r){T(this,t,e,!1,r)},r.prototype.writeInt32BE=function(t,e,r){T(this,t,e,!0,r)},r.prototype.writeFloatLE=function(t,e,r){S(this,t,e,!1,r)},r.prototype.writeFloatBE=function(t,e,r){S(this,t,e,!0,r)},r.prototype.writeDoubleLE=function(t,e,r){A(this,t,e,!1,r)},r.prototype.writeDoubleBE=function(t,e,r){A(this,t,e,!0,r)},i.prototype.readUInt8=r.prototype.readUInt8,i.prototype.readUInt16LE=r.prototype.readUInt16LE,i.prototype.readUInt16BE=r.prototype.readUInt16BE,i.prototype.readUInt32LE=r.prototype.readUInt32LE,i.prototype.readUInt32BE=r.prototype.readUInt32BE,i.prototype.readInt8=r.prototype.readInt8,i.prototype.readInt16LE=r.prototype.readInt16LE,i.prototype.readInt16BE=r.prototype.readInt16BE,i.prototype.readInt32LE=r.prototype.readInt32LE,i.prototype.readInt32BE=r.prototype.readInt32BE,i.prototype.readFloatLE=r.prototype.readFloatLE,i.prototype.readFloatBE=r.prototype.readFloatBE,i.prototype.readDoubleLE=r.prototype.readDoubleLE,i.prototype.readDoubleBE=r.prototype.readDoubleBE,i.prototype.writeUInt8=r.prototype.writeUInt8,i.prototype.writeUInt16LE=r.prototype.writeUInt16LE,i.prototype.writeUInt16BE=r.prototype.writeUInt16BE,i.prototype.writeUInt32LE=r.prototype.writeUInt32LE,i.prototype.writeUInt32BE=r.prototype.writeUInt32BE,i.prototype.writeInt8=r.prototype.writeInt8,i.prototype.writeInt16LE=r.prototype.writeInt16LE,i.prototype.writeInt16BE=r.prototype.writeInt16BE,i.prototype.writeInt32LE=r.prototype.writeInt32LE,i.prototype.writeInt32BE=r.prototype.writeInt32BE,i.prototype.writeFloatLE=r.prototype.writeFloatLE,i.prototype.writeFloatBE=r.prototype.writeFloatBE,i.prototype.writeDoubleLE=r.prototype.writeDoubleLE,i.prototype.writeDoubleBE=r.prototype.writeDoubleBE}(r,r(22).Buffer)},23:function(t){try{t.exports=WebSocket}catch(e){t.exports=MozWebSocket}},24:function(t,e,r){var i=e.EventEmitter=function(){},n=r(35);r(36);var s=10;i.prototype.setMaxListeners=function(t){this._events||(this._events={}),this._maxListeners=t},i.prototype.emit=function(t){if("error"===t&&(!this._events||!this._events.error||n(this._events.error)&&!this._events.error.length))throw arguments[1]instanceof Error?arguments[1]:new Error("Uncaught, unspecified 'error' event.");if(!this._events)return!1;var e=this._events[t];if(!e)return!1;if("function"==typeof e){switch(arguments.length){case 1:e.call(this);break;case 2:e.call(this,arguments[1]);break;case 3:e.call(this,arguments[1],arguments[2]);break;default:var r=Array.prototype.slice.call(arguments,1);e.apply(this,r)}return!0}if(n(e)){for(var r=Array.prototype.slice.call(arguments,1),i=e.slice(),s=0,o=i.length;o>s;s++)i[s].apply(this,r);return!0}return!1},i.prototype.addListener=function(t,e){if("function"!=typeof e)throw new Error("addListener only takes instances of Function");if(this._events||(this._events={}),this.emit("newListener",t,e),this._events[t]?n(this._events[t])?this._events[t].push(e):this._events[t]=[this._events[t],e]:this._events[t]=e,n(this._events[t])&&!this._events[t].warned){var r;r=void 0!==this._maxListeners?this._maxListeners:s,r&&r>0&&this._events[t].length>r&&(this._events[t].warned=!0,console.error("(events) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),console.trace())}return this},i.prototype.on=i.prototype.addListener,i.prototype.once=function(t,e){function r(){i.removeListener(t,r),e.apply(this,arguments)}if("function"!=typeof e)throw new Error(".once only takes instances of Function");var i=this;return r.listener=e,i.on(t,r),this},i.prototype.removeListener=function(t,e){if("function"!=typeof e)throw new Error("removeListener only takes instances of Function");if(!this._events||!this._events[t])return this;var r=this._events[t];if(n(r)){for(var i=-1,s=0,o=r.length;o>s;s++)if(r[s]===e||r[s].listener&&r[s].listener===e){i=s;break}if(0>i)return this;r.splice(i,1),0==r.length&&delete this._events[t]}else(r===e||r.listener&&r.listener===e)&&delete this._events[t];return this},i.prototype.removeAllListeners=function(t){return 0===arguments.length?(this._events={},this):(t&&this._events&&this._events[t]&&(this._events[t]=null),this)},i.prototype.listeners=function(t){return this._events||(this._events={}),this._events[t]||(this._events[t]=[]),n(this._events[t])||(this._events[t]=[this._events[t]]),this._events[t] +}},25:function(t,e,r){function i(t){if(t instanceof Date)return!0;if("object"!=typeof t)return!1;var e=Date.prototype&&o(Date.prototype),r=t.__proto__&&o(t.__proto__);return JSON.stringify(r)===JSON.stringify(e)}r(24);var n=r(35),s=r(37),o=r(38),a=r(39),c=r(40);e.isArray=n,e.isDate=i,e.isRegExp=c,e.print=function(){},e.puts=function(){},e.debug=function(){},e.inspect=function(t,r,a,u){function h(t,a){if(t&&"function"==typeof t.inspect&&t!==e&&(!t.constructor||t.constructor.prototype!==t))return t.inspect(a);switch(typeof t){case"undefined":return l("undefined","undefined");case"string":var u="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return l(u,"string");case"number":return l(""+t,"number");case"boolean":return l(""+t,"boolean")}if(null===t)return l("null","null");var _=s(t),p=r?o(t):_;if("function"==typeof t&&0===p.length){if(c(t))return l(""+t,"regexp");var d=t.name?": "+t.name:"";return l("[Function"+d+"]","special")}if(i(t)&&0===p.length)return l(t.toUTCString(),"date");var y,v,m;if(n(t)?(v="Array",m=["[","]"]):(v="Object",m=["{","}"]),"function"==typeof t){var g=t.name?": "+t.name:"";y=c(t)?" "+t:" [Function"+g+"]"}else y="";if(i(t)&&(y=" "+t.toUTCString()),0===p.length)return m[0]+y+m[1];if(0>a)return c(t)?l(""+t,"regexp"):l("[Object]","special");f.push(t);var b=p.map(function(e){var r,i;if(t.__lookupGetter__&&(t.__lookupGetter__(e)?i=t.__lookupSetter__(e)?l("[Getter/Setter]","special"):l("[Getter]","special"):t.__lookupSetter__(e)&&(i=l("[Setter]","special"))),_.indexOf(e)<0&&(r="["+e+"]"),i||(f.indexOf(t[e])<0?(i=null===a?h(t[e]):h(t[e],a-1),i.indexOf("\n")>-1&&(i=n(t)?i.split("\n").map(function(t){return" "+t}).join("\n").substr(2):"\n"+i.split("\n").map(function(t){return" "+t}).join("\n"))):i=l("[Circular]","special")),"undefined"==typeof r){if("Array"===v&&e.match(/^\d+$/))return i;r=JSON.stringify(""+e),r.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(r=r.substr(1,r.length-2),r=l(r,"name")):(r=r.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),r=l(r,"string"))}return r+": "+i});f.pop();var w=0,E=b.reduce(function(t,e){return w++,e.indexOf("\n")>=0&&w++,t+e.length+1},0);return b=E>50?m[0]+(""===y?"":y+"\n ")+" "+b.join(",\n ")+" "+m[1]:m[0]+y+" "+b.join(", ")+" "+m[1]}var f=[],l=function(t,e){var r={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={special:"cyan",number:"blue","boolean":"yellow",undefined:"grey","null":"bold",string:"green",date:"magenta",regexp:"red"}[e];return i?"["+r[i][0]+"m"+t+"["+r[i][1]+"m":t};return u||(l=function(t){return t}),h(t,"undefined"==typeof a?2:a)},e.log=function(){},e.pump=null,e.inherits=function(t,e){t.super_=e,t.prototype=a(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})};var u=/%[sdj%]/g;e.format=function(t){if("string"!=typeof t){for(var r=[],i=0;i=s)return t;switch(t){case"%s":return String(n[i++]);case"%d":return Number(n[i++]);case"%j":return JSON.stringify(n[i++]);default:return t}}),a=n[i];s>i;a=n[++i])o+=null===a||"object"!=typeof a?" "+a:" "+e.inspect(a);return o}},26:function(t,e,r){function i(t,e){return void 0===e?""+e:"number"!=typeof e||!isNaN(e)&&isFinite(e)?"function"==typeof e||e instanceof RegExp?e.toString():e:e.toString()}function n(t,e){return"string"==typeof t?t.length=0;i--)if(n[i]!=s[i])return!1;for(i=n.length-1;i>=0;i--)if(r=n[i],!a(t[r],e[r]))return!1;return!0}function f(t,e){return t&&e?y(e)?e.test(t):t instanceof e?!0:e.call({},t)===!0?!0:!1:!1}function l(t,e,r,i){var n;"string"==typeof r&&(i=r,r=null);try{e()}catch(o){n=o}if(i=(r&&r.name?" ("+r.name+").":".")+(i?" "+i:"."),t&&!n&&s(n,r,"Missing expected exception"+i),!t&&f(n,r)&&s(n,r,"Got unwanted exception"+i),t&&n&&r&&!f(n,r)||!t&&n)throw n}var _=r(25),p=Array.prototype.slice,d=r(37),y=r(40),v=t.exports=o;v.AssertionError=function(t){this.name="AssertionError",this.message=t.message,this.actual=t.actual,this.expected=t.expected,this.operator=t.operator;var e=t.stackStartFunction||s;Error.captureStackTrace&&Error.captureStackTrace(this,e)},_.inherits(v.AssertionError,Error),v.AssertionError.prototype.toString=function(){return this.message?[this.name+":",this.message].join(" "):[this.name+":",n(JSON.stringify(this.actual,i),128),this.operator,n(JSON.stringify(this.expected,i),128)].join(" ")},v.AssertionError.__proto__=Error.prototype,v.fail=s,v.ok=o,v.equal=function(t,e,r){t!=e&&s(t,e,r,"==",v.equal)},v.notEqual=function(t,e,r){t==e&&s(t,e,r,"!=",v.notEqual)},v.deepEqual=function(t,e,r){a(t,e)||s(t,e,r,"deepEqual",v.deepEqual)},v.notDeepEqual=function(t,e,r){a(t,e)&&s(t,e,r,"notDeepEqual",v.notDeepEqual)},v.strictEqual=function(t,e,r){t!==e&&s(t,e,r,"===",v.strictEqual)},v.notStrictEqual=function(t,e,r){t===e&&s(t,e,r,"!==",v.notStrictEqual)},v.throws=function(){l.apply(this,[!0].concat(p.call(arguments)))},v.doesNotThrow=function(){l.apply(this,[!1].concat(p.call(arguments)))},v.ifError=function(t){if(t)throw t}},27:function(t,e,r){!function(t,e){"use strict";function r(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}var i={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 e&&e.exports&&(e.exports=i),i.cipher.aes=function(t){this._tables[0][0][0]||this._precompute();var e,r,n,s,o,a=this._tables[0][4],c=this._tables[1],u=t.length,h=1;if(4!==u&&6!==u&&8!==u)throw new i.exception.invalid("invalid aes key size");for(this._key=[s=t.slice(0),o=[]],e=u;4*u+28>e;e++)n=s[e-1],(0===e%u||8===u&&4===e%u)&&(n=a[n>>>24]<<24^a[255&n>>16]<<16^a[255&n>>8]<<8^a[255&n],0===e%u&&(n=n<<8^n>>>24^h<<24,h=h<<1^283*(h>>7))),s[e]=s[e-u]^n;for(r=0;e;r++,e--)n=s[3&r?e:e-4],o[r]=4>=e||4>r?n:c[0][a[n>>>24]]^c[1][a[255&n>>16]]^c[2][a[255&n>>8]]^c[3][a[255&n]]},i.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,i,n,s,o,a,c,u=this._tables[0],h=this._tables[1],f=u[4],l=h[4],_=[],p=[];for(t=0;256>t;t++)p[(_[t]=t<<1^283*(t>>7))^t]=t;for(e=r=0;!f[e];e^=i||1,r=p[r]||1)for(o=r^r<<1^r<<2^r<<3^r<<4,o=99^(o>>8^255&o),f[e]=o,l[o]=e,s=_[n=_[i=_[e]]],c=16843009*s^65537*n^257*i^16843008*e,a=257*_[o]^16843008*o,t=0;4>t;t++)u[t][e]=a=a<<24^a>>>8,h[t][o]=c=c<<24^c>>>8;for(t=0;5>t;t++)u[t]=u[t].slice(0),h[t]=h[t].slice(0)},_crypt:function(t,e){if(4!==t.length)throw new i.exception.invalid("invalid aes block size");var r,n,s,o,a=this._key[e],c=t[0]^a[0],u=t[e?3:1]^a[1],h=t[2]^a[2],f=t[e?1:3]^a[3],l=a.length/4-2,_=4,p=[0,0,0,0],d=this._tables[e],y=d[0],v=d[1],m=d[2],g=d[3],b=d[4];for(o=0;l>o;o++)r=y[c>>>24]^v[255&u>>16]^m[255&h>>8]^g[255&f]^a[_],n=y[u>>>24]^v[255&h>>16]^m[255&f>>8]^g[255&c]^a[_+1],s=y[h>>>24]^v[255&f>>16]^m[255&c>>8]^g[255&u]^a[_+2],f=y[f>>>24]^v[255&c>>16]^m[255&u>>8]^g[255&h]^a[_+3],_+=4,c=r,u=n,h=s;for(o=0;4>o;o++)p[e?3&-o:o]=b[c>>>24]<<24^b[255&u>>16]<<16^b[255&h>>8]<<8^b[255&f]^a[_++],r=c,c=u,u=h,h=f,f=r;return p}},i.bitArray={bitSlice:function(t,e,r){return t=i.bitArray._shiftRight(t.slice(e/32),32-(31&e)).slice(1),void 0===r?t:i.bitArray.clamp(t,r-e)},extract:function(t,e,r){var i,n=Math.floor(31&-e-r);return i=-32&(e+r-1^e)?t[0|e/32]<<32-n^t[0|e/32+1]>>>n:t[0|e/32]>>>n,i&(1<0&&e&&(t[r-1]=i.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(i.bitArray.bitLength(t)!==i.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(s=0;s>>e),r=t[s]<<32-e;return a=t.length?t[t.length-1]:0,o=i.bitArray.getPartial(a),n.push(i.bitArray.partial(31&e+o,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]]}},i.codec.utf8String={fromBits:function(t){var e,r,n="",s=i.bitArray.bitLength(t);for(e=0;s/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?(c=t[n]<<6-o,o+=26,n++):(c<<=6,o-=6);for(;3&s.length&&!e;)s+="=";return s},toBits:function(t,e){t=t.replace(/\s|=/g,"");var r,n,s=[],o=0,a=i.codec.base64._chars,c=0;for(e&&(a=a.substr(0,62)+"-_"),r=0;rn)throw new i.exception.invalid("this isn't base64!");o>26?(o-=26,s.push(c^n>>>o),c=n<<32-o):(o+=6,c^=n<<32-o)}return 56&o&&s.push(i.bitArray.partial(56&o,c,1)),s}},i.codec.base64url={fromBits:function(t){return i.codec.base64.fromBits(t,1,1)},toBits:function(t){return i.codec.base64.toBits(t,1)}},i.codec.bytes={fromBits:function(t){var e,r,n=[],s=i.bitArray.bitLength(t);for(e=0;s/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=i.bitArray.concat(e,[i.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 0|4294967296*(t-Math.floor(t))}var e,r=0,i=2;t:for(;64>r;i++){for(e=2;i>=e*e;e++)if(0===i%e)continue t;8>r&&(this._init[r]=t(Math.pow(i,.5))),this._key[r]=t(Math.pow(i,1/3)),r++}},_block:function(t){var e,r,i,n,s=t.slice(0),o=this._h,a=this._key,c=o[0],u=o[1],h=o[2],f=o[3],l=o[4],_=o[5],p=o[6],d=o[7];for(e=0;64>e;e++)16>e?r=s[e]:(i=s[15&e+1],n=s[15&e+14],r=s[15&e]=0|(i>>>7^i>>>18^i>>>3^i<<25^i<<14)+(n>>>17^n>>>19^n>>>10^n<<15^n<<13)+s[15&e]+s[15&e+9]),r=r+d+(l>>>6^l>>>11^l>>>25^l<<26^l<<21^l<<7)+(p^l&(_^p))+a[e],d=p,p=_,_=l,l=0|f+r,f=h,h=u,u=c,c=0|r+(u&h^f&(u^h))+(u>>>2^u>>>13^u>>>22^u<<30^u<<19^u<<10);o[0]=0|o[0]+c,o[1]=0|o[1]+u,o[2]=0|o[2]+h,o[3]=0|o[3]+f,o[4]=0|o[4]+l,o[5]=0|o[5]+_,o[6]=0|o[6]+p,o[7]=0|o[7]+d}},i.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()},i.hash.sha512.hash=function(t){return(new i.hash.sha512).update(t).finalize()},i.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=i.codec.utf8String.toBits(t));var e,r=this._buffer=i.bitArray.concat(this._buffer,t),n=this._length,s=this._length=n+i.bitArray.bitLength(t);for(e=-1024&1024+n;s>=e;e+=1024)this._block(r.splice(0,32));return this},finalize:function(){var t,e=this._buffer,r=this._h;for(e=i.bitArray.concat(e,[i.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 0|4294967296*(t-Math.floor(t))}function e(t){return 255&1099511627776*(t-Math.floor(t))}var r,i=0,n=2;t:for(;80>i;n++){for(r=2;n>=r*r;r++)if(0===n%r)continue t;8>i&&(this._init[2*i]=t(Math.pow(n,.5)),this._init[2*i+1]=e(Math.pow(n,.5))<<24|this._initr[i]),this._key[2*i]=t(Math.pow(n,1/3)),this._key[2*i+1]=e(Math.pow(n,1/3))<<24|this._keyr[i],i++}},_block:function(t){var e,r,i,n=t.slice(0),s=this._h,o=this._key,a=s[0],c=s[1],u=s[2],h=s[3],f=s[4],l=s[5],_=s[6],p=s[7],d=s[8],y=s[9],v=s[10],m=s[11],g=s[12],b=s[13],w=s[14],E=s[15],x=a,k=c,T=u,S=h,A=f,j=l,B=_,q=p,I=d,R=y,D=v,O=m,M=g,L=b,C=w,N=E;for(e=0;80>e;e++){if(16>e)r=n[2*e],i=n[2*e+1];else{var F=n[2*(e-15)],P=n[2*(e-15)+1],z=(P<<31|F>>>1)^(P<<24|F>>>8)^F>>>7,U=(F<<31|P>>>1)^(F<<24|P>>>8)^(F<<25|P>>>7),V=n[2*(e-2)],H=n[2*(e-2)+1],G=(H<<13|V>>>19)^(V<<3|H>>>29)^V>>>6,X=(V<<13|H>>>19)^(H<<3|V>>>29)^(V<<26|H>>>6),Z=n[2*(e-7)],W=n[2*(e-7)+1],K=n[2*(e-16)],J=n[2*(e-16)+1];i=U+W,r=z+Z+(U>>>0>i>>>0?1:0),i+=X,r+=G+(X>>>0>i>>>0?1:0),i+=J,r+=K+(J>>>0>i>>>0?1:0)}n[2*e]=r|=0,n[2*e+1]=i|=0;var Q=I&D^~I&M,Y=R&O^~R&L,$=x&T^x&A^T&A,te=k&S^k&j^S&j,ee=(k<<4|x>>>28)^(x<<30|k>>>2)^(x<<25|k>>>7),re=(x<<4|k>>>28)^(k<<30|x>>>2)^(k<<25|x>>>7),ie=(R<<18|I>>>14)^(R<<14|I>>>18)^(I<<23|R>>>9),ne=(I<<18|R>>>14)^(I<<14|R>>>18)^(R<<23|I>>>9),se=o[2*e],oe=o[2*e+1],ae=N+ne,ce=C+ie+(N>>>0>ae>>>0?1:0);ae+=Y,ce+=Q+(Y>>>0>ae>>>0?1:0),ae+=oe,ce+=se+(oe>>>0>ae>>>0?1:0),ae+=i,ce+=r+(i>>>0>ae>>>0?1:0);var ue=re+te,he=ee+$+(re>>>0>ue>>>0?1:0);C=M,N=L,M=D,L=O,D=I,O=R,R=0|q+ae,I=0|B+ce+(q>>>0>R>>>0?1:0),B=A,q=j,A=T,j=S,T=x,S=k,k=0|ae+ue,x=0|ce+he+(ae>>>0>k>>>0?1:0)}c=s[1]=0|c+k,s[0]=0|a+x+(k>>>0>c>>>0?1:0),h=s[3]=0|h+S,s[2]=0|u+T+(S>>>0>h>>>0?1:0),l=s[5]=0|l+j,s[4]=0|f+A+(j>>>0>l>>>0?1:0),p=s[7]=0|p+q,s[6]=0|_+B+(q>>>0>p>>>0?1:0),y=s[9]=0|y+R,s[8]=0|d+I+(R>>>0>y>>>0?1:0),m=s[11]=0|m+O,s[10]=0|v+D+(O>>>0>m>>>0?1:0),b=s[13]=0|b+L,s[12]=0|g+M+(L>>>0>b>>>0?1:0),E=s[15]=0|E+N,s[14]=0|w+C+(N>>>0>E>>>0?1:0)}},i.hash.sha1=function(t){t?(this._h=t._h.slice(0),this._buffer=t._buffer.slice(0),this._length=t._length):this.reset()},i.hash.sha1.hash=function(t){return(new i.hash.sha1).update(t).finalize()},i.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=i.codec.utf8String.toBits(t));var e,r=this._buffer=i.bitArray.concat(this._buffer,t),n=this._length,s=this._length=n+i.bitArray.bitLength(t);for(e=this.blockSize+n&-this.blockSize;s>=e;e+=this.blockSize)this._block(r.splice(0,16));return this},finalize:function(){var t,e=this._buffer,r=this._h;for(e=i.bitArray.concat(e,[i.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,i){return 19>=t?e&r|~e&i:39>=t?e^r^i:59>=t?e&r|e&i|r&i:79>=t?e^r^i:void 0},_S:function(t,e){return e<>>32-t},_block:function(t){var e,r,i,n,s,o,a,c=t.slice(0),u=this._h;for(this._key,i=u[0],n=u[1],s=u[2],o=u[3],a=u[4],e=0;79>=e;e++)e>=16&&(c[e]=this._S(1,c[e-3]^c[e-8]^c[e-14]^c[e-16])),r=0|this._S(5,i)+this._f(e,n,s,o)+a+c[e]+this._key[Math.floor(e/20)],a=o,o=s,s=this._S(30,n),n=i,i=r;u[0]=0|u[0]+i,u[1]=0|u[1]+n,u[2]=0|u[2]+s,u[3]=0|u[3]+o,u[4]=0|u[4]+a}},i.mode.ccm={name:"ccm",encrypt:function(t,e,r,n,s){var o,a,c=e.slice(0),u=i.bitArray,h=u.bitLength(r)/8,f=u.bitLength(c)/8;if(s=s||64,n=n||[],7>h)throw new i.exception.invalid("ccm: iv must be at least 7 bytes");for(o=2;4>o&&f>>>8*o;o++);return 15-h>o&&(o=15-h),r=u.clamp(r,8*(15-o)),a=i.mode.ccm._computeTag(t,e,r,n,s,o),c=i.mode.ccm._ctrMode(t,c,r,a,s,o),u.concat(c.data,c.tag)},decrypt:function(t,e,r,n,s){s=s||64,n=n||[];var o,a,c=i.bitArray,u=c.bitLength(r)/8,h=c.bitLength(e),f=c.clamp(e,h-s),l=c.bitSlice(e,h-s);if(h=(h-s)/8,7>u)throw new i.exception.invalid("ccm: iv must be at least 7 bytes");for(o=2;4>o&&h>>>8*o;o++);if(15-u>o&&(o=15-u),r=c.clamp(r,8*(15-o)),f=i.mode.ccm._ctrMode(t,f,r,l,s,o),a=i.mode.ccm._computeTag(t,f.data,r,n,s,o),!c.equal(f.tag,a))throw new i.exception.corrupt("ccm: tag doesn't match");return f.data},_computeTag:function(t,e,r,n,s,o){var a,c,u,h=[],f=i.bitArray,l=f._xor4;if(s/=8,s%2||4>s||s>16)throw new i.exception.invalid("ccm: invalid tag length");if(n.length>4294967295||e.length>4294967295)throw new i.exception.bug("ccm: can't deal with 4GiB or more data");if(a=[f.partial(8,(n.length?64:0)|s-2<<2|o-1)],a=f.concat(a,r),a[3]|=f.bitLength(e)/8,a=t.encrypt(a),n.length)for(c=f.bitLength(n)/8,65279>=c?h=[f.partial(16,c)]:4294967295>=c&&(h=f.concat([f.partial(16,65534)],[c])),h=f.concat(h,n),u=0;uc;c+=4)u[3]++,a=t.encrypt(u),e[c]^=a[0],e[c+1]^=a[1],e[c+2]^=a[2],e[c+3]^=a[3];return{tag:n,data:h.clamp(e,_)}}},i.misc.hmac=function(t,e){this._hash=e=e||i.hash.sha256;var r,n=[[],[]],s=e.prototype.blockSize/32;for(this._baseHash=[new e,new e],t.length>s&&(t=e.hash(t)),r=0;s>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])},i.misc.hmac.prototype.encrypt=i.misc.hmac.prototype.mac=function(t){var e=new this._hash(this._baseHash[0]).update(t).finalize();return new this._hash(this._baseHash[1]).update(e).finalize()},i.misc.pbkdf2=function(t,e,r,n,s){if(r=r||1e3,0>n||0>r)throw i.exception.invalid("invalid params to pbkdf2");"string"==typeof t&&(t=i.codec.utf8String.toBits(t)),s=s||i.misc.hmac;var o,a,c,u,h,f=new s(t),l=[],_=i.bitArray;for(h=1;32*l.length<(n||1);h++){for(o=a=f.encrypt(_.concat(e,[h])),c=1;r>c;c++)for(a=f.encrypt(a),u=0;ur;r+=4)0===(r+1)%this._MAX_WORDS_PER_BURST&&this._gate(),n=this._gen4words(),s.push(n[0],n[1],n[2],n[3]);return this._gate(),s.slice(0,t)},setDefaultParanoia:function(t){this._defaultParanoia=t},addEntropy:function(t,e,r){r=r||"user";var n,s,o,a=(new Date).valueOf(),c=this._robins[r],u=this.isReady(),h=0;switch(n=this._collectorIds[r],void 0===n&&(n=this._collectorIds[r]=this._collectorIdNext++),void 0===c&&(c=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[c].update([n,this._eventId++,1,e,a,1,0|t]);break;case"object":var f=Object.prototype.toString.call(t);if("[object Uint32Array]"===f){for(o=[],s=0;s0;)e++,o>>>=1;this._pools[c].update([n,this._eventId++,2,e,a,t.length].concat(t))}break;case"string":void 0===e&&(e=t.length),this._pools[c].update([n,this._eventId++,3,e,a,t.length]),this._pools[c].update(t);break;default:h=1}if(h)throw new i.exception.bug("random: addEntropy only supports number, array of numbers or string");this._poolEntropy[c]+=e,this._poolStrength+=e,u===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(window.addEventListener)window.addEventListener("load",this._loadTimeCollector,!1),window.addEventListener("mousemove",this._mouseCollector,!1);else{if(!document.attachEvent)throw new i.exception.bug("can't attach event");document.attachEvent("onload",this._loadTimeCollector),document.attachEvent("onmousemove",this._mouseCollector)}this._collectorsStarted=!0}},stopCollectors:function(){this._collectorsStarted&&(window.removeEventListener?(window.removeEventListener("load",this._loadTimeCollector,!1),window.removeEventListener("mousemove",this._mouseCollector,!1)):window.detachEvent&&(window.detachEvent("onload",this._loadTimeCollector),window.detachEvent("onmousemove",this._mouseCollector)),this._collectorsStarted=!1)},addEventListener:function(t,e){this._callbacks[t][this._callbackI++]=e},removeEventListener:function(t,e){var r,i,n=this._callbacks[t],s=[];for(i in n)n.hasOwnProperty(i)&&n[i]===e&&s.push(i);for(r=0;rt&&(this._counter[t]=0|this._counter[t]+1,!this._counter[t]);t++);return this._cipher.encrypt(this._counter)},_gate:function(){this._key=this._gen4words().concat(this._gen4words()),this._cipher=new i.cipher.aes(this._key)},_reseed:function(t){this._key=i.hash.sha256.hash(this._key.concat(t)),this._cipher=new i.cipher.aes(this._key);for(var e=0;4>e&&(this._counter[e]=0|this._counter[e]+1,!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(0|4294967296*Math.random());for(e=0;e=1<this._strength&&(this._strength=n),this._reseedCount++,this._reseed(r)},_mouseCollector:function(t){var e=t.x||t.clientX||t.offsetX||0,r=t.y||t.clientY||t.offsetY||0;i.random.addEntropy([e,r],2,"mouse")},_loadTimeCollector:function(){i.random.addEntropy((new Date).valueOf(),2,"loadtime")},_fireEvent:function(t,e){var r,n=i.random._callbacks[t],s=[];for(r in n)n.hasOwnProperty(r)&&s.push(n[r]);for(r=0;r4)throw new i.exception.invalid("json encrypt: invalid parameters");return"string"==typeof t?(s=i.misc.cachedPbkdf2(t,u),t=s.key.slice(0,u.ks/32),u.salt=s.salt):i.ecc&&t instanceof i.ecc.elGamal.publicKey&&(s=t.kem(),u.kemtag=s.tag,t=s.key.slice(0,u.ks/32)),"string"==typeof e&&(e=i.codec.utf8String.toBits(e)),"string"==typeof a&&(a=i.codec.utf8String.toBits(a)),o=new i.cipher[u.cipher](t),c._add(n,u),n.key=t,u.ct=i.mode[u.mode].encrypt(o,e,u.iv,a,u.ts),c.encode(u)},decrypt:function(t,e,r,n){r=r||{},n=n||{};var s,o,a,c=i.json,u=c._add(c._add(c._add({},c.defaults),c.decode(e)),r,!0),h=u.adata;if("string"==typeof u.salt&&(u.salt=i.codec.base64.toBits(u.salt)),"string"==typeof u.iv&&(u.iv=i.codec.base64.toBits(u.iv)),!i.mode[u.mode]||!i.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 i.exception.invalid("json decrypt: invalid parameters");return"string"==typeof t?(o=i.misc.cachedPbkdf2(t,u),t=o.key.slice(0,u.ks/32),u.salt=o.salt):i.ecc&&t instanceof i.ecc.elGamal.secretKey&&(t=t.unkem(i.codec.base64.toBits(u.kemtag)).slice(0,u.ks/32)),"string"==typeof h&&(h=i.codec.utf8String.toBits(h)),a=new i.cipher[u.cipher](t),s=i.mode[u.mode].decrypt(a,u.ct,u.iv,h,u.ts),c._add(n,u),n.key=t,i.codec.utf8String.fromBits(s)},encode:function(t){var e,r="{",n="";for(e in t)if(t.hasOwnProperty(e)){if(!e.match(/^[a-z0-9]+$/i))throw new i.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+='"'+i.codec.base64.fromBits(t[e],0)+'"';break;default:throw new i.exception.bug("json encode: unsupported type")}}return r+"}"},decode:function(t){if(t=t.replace(/\s/g,""),!t.match(/^\{.*\}$/))throw new i.exception.invalid("json decode: this isn't json!");var e,r,n=t.replace(/^\{|\}$/g,"").split(/,/),s={};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,i,n=0,s=0;for(e=Math.max(this.limbs.length,t.limbs.length)-1;e>=0;e--)r=this.getLimb(e),i=t.getLimb(e),s|=i-r&~n,n|=r-i&~s;return(s|~n)>>>31},toString:function(){this.fullReduce();var t,e,r="",i=this.limbs;for(t=0;t>i;return r&&s.push(r),this},halveM:function(){var t,e,r=0,i=this.radix,n=this.limbs;for(t=n.length-1;t>=0;t--)e=n[t],n[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 i.bn(1),s=new i.bn(0),o=new i.bn(this),a=new i.bn(t),c=1;if(!(1&t.limbs[0]))throw new i.exception.invalid("inverseMod: p must be odd");do for(1&o.limbs[0]&&(o.greaterEquals(a)||(e=o,o=a,a=e,e=n,n=s,s=e),o.subM(a),o.normalize(),n.greaterEquals(s)||n.addM(t),n.subM(s)),o.halveM(),1&n.limbs[0]&&n.addM(t),n.normalize(),n.halveM(),r=c=0;re;e++){for(i=n[e],r=0;a>r;r++)u[e+r]+=i*s[r];--h||(h=this.maxMul,c.cnormalize())}return c.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,i=new this._class(1),n=this;for(e=0;et||0!==i&&-1!==i;t++)e=(s[t]||0)+i,r=s[t]=e&a,i=(e-r)*n;return-1===i&&(s[t-1]-=this.placeVal),this},cnormalize:function(){var t,e,r,i=0,n=this.ipv,s=this.limbs,o=s.length,a=this.radixMask;for(t=0;o-1>t;t++)e=s[t]+i,r=s[t]=e&a,i=(e-r)*n;return s[t]+=i,this},toBits:function(t){this.fullReduce(),t=t||this.exponent||this.bitLength();var e=Math.floor((t-1)/24),r=i.bitArray,n=(-8&t+7)%this.radix||this.radix,s=[r.partial(n,this.getLimb(e))];for(e--;e>=0;e--)s=r.concat(s,[r.partial(Math.min(this.radix,t),this.getLimb(e))]),t-=this.radix;return s},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-8&t+7}},i.bn.fromBits=function(t){var e=this,r=new e,n=[],s=i.bitArray,o=this.prototype,a=Math.min(this.bitLength||4294967296,s.bitLength(t)),c=a%o.radix||o.radix;for(n[0]=s.extract(t,0,c);a>c;c+=o.radix)n.unshift(s.extract(t,c,o.radix));return r.limbs=n,r},i.bn.prototype.ipv=1/(i.bn.prototype.placeVal=Math.pow(2,i.bn.prototype.radix)),i.bn.prototype.radixMask=(1<n;){for(r=s.pop(),i=s.length,e=0;a>e;e++)s[i+o[e]]-=c[e]*r;t--,t||(s.push(0),this.cnormalize(),t=this.minOffset)}return this.cnormalize(),this},a._strongReduce=-1===a.fullMask?a.reduce:function(){var t,e,r=this.limbs,i=r.length-1;if(this.reduce(),i===this.modOffset-1){for(e=r[i]&this.fullMask,r[i]-=e,t=0;tn;n++)r[n]&=t.radixMask;if(a.limbs=r,!a.greaterEquals(t))return a}},i.ecc={},i.ecc.point=function(t,e,r){void 0===e?this.isIdentity=!0:(this.x=e,this.y=r,this.isIdentity=!1),this.curve=t},i.ecc.point.prototype={toJac:function(){return new i.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 i.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 i.bitArray.concat(this.x.toBits(),this.y.toBits())}},i.ecc.pointJac=function(t,e,r,i){void 0===e?this.isIdentity=!0:(this.x=e,this.y=r,this.z=i,this.isIdentity=!1),this.curve=t},i.ecc.pointJac.prototype={add:function(t){var e,r,n,s,o,a,c,u,h,f,l,_=this;if(_.curve!==t.curve)throw"sjcl.ecc.add(): Points must be on the same curve to add them!";return _.isIdentity?t.toJac():t.isIdentity?_:(e=_.z.square(),r=t.x.mul(e).subM(_.x),r.equals(0)?_.y.equals(t.y.mul(e.mul(_.z)))?_.doubl():new i.ecc.pointJac(_.curve):(n=t.y.mul(e.mul(_.z)).subM(_.y),s=r.square(),o=n.square(),a=r.square().mul(r).addM(_.x.add(_.x).mul(s)),c=o.subM(a),u=_.x.mul(s).subM(c).mul(n),h=_.y.mul(r.square().mul(r)),f=u.subM(h),l=_.z.mul(r),new i.ecc.pointJac(this.curve,c,f,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(),s=this.x.sub(n).mul(3).mul(this.x.add(n)),o=s.square().subM(e).subM(e),a=e.sub(o).mul(s).subM(r),c=this.y.add(this.y).mul(this.z);return new i.ecc.pointJac(this.curve,o,a,c)},toAffine:function(){if(this.isIdentity||this.z.equals(0))return new i.ecc.point(this.curve);var t=this.z.inverse(),e=t.square();return new i.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,s=new i.ecc.point(this.curve).toJac(),o=e.multiples();for(r=t.length-1;r>=0;r--)for(n=i.bn.prototype.radix-4;n>=0;n-=4)s=s.doubl().doubl().doubl().doubl().add(o[15&t[r]>>n]);return s},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 s,o,a,c,u=new i.ecc.point(this.curve).toJac(),h=e.multiples(),f=n.multiples();for(s=Math.max(t.length,r.length)-1;s>=0;s--)for(a=0|t[s],c=0|r[s],o=i.bn.prototype.radix-4;o>=0;o-=4)u=u.doubl().doubl().doubl().doubl().add(h[15&a>>o]).add(f[15&c>>o]);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()))))}},i.ecc.curve=function(t,e,r,n,s,o){this.field=t,this.r=t.prototype.modulus.sub(e),this.a=new t(r),this.b=new t(n),this.G=new i.ecc.point(this,new t(s),new t(o))},i.ecc.curve.prototype.fromBits=function(t){var e=i.bitArray,r=-8&this.field.prototype.exponent+7,n=new i.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 i.exception.corrupt("not on the curve!");return n},i.ecc.curves={c192:new i.ecc.curve(i.bn.prime.p192,"0x662107c8eb94364e4b2dd7ce",-3,"0x64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1","0x188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012","0x07192b95ffc8da78631011ed6b24cdd573f977a11e794811"),c224:new i.ecc.curve(i.bn.prime.p224,"0xe95c1f470fc1ec22d6baa3a3d5c4",-3,"0xb4050a850c04b3abf54132565044b0b7d7bfd8ba270b39432355ffb4","0xb70e0cbd6bb4bf7f321390b94a03c1d356c21122343280d6115c1d21","0xbd376388b5f723fb4c22dfe6cd4375a05a07476444d5819985007e34"),c256:new i.ecc.curve(i.bn.prime.p256,"0x4319055358e8617b0c46353d039cdaae",-3,"0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b","0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296","0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5"),c384:new i.ecc.curve(i.bn.prime.p384,"0x389cb27e0bc8d21fa7e5f24cb74f58851313e696333ad68c",-3,"0xb3312fa7e23ee7e4988e056be3f82d19181d9c6efe8141120314088f5013875ac656398d8a2ed19d2a85c8edd3ec2aef","0xaa87ca22be8b05378eb1c71ef320ad746e1d3b628ba79b9859f741e082542a385502f25dbf55296c3a545e3872760ab7","0x3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f")},i.ecc._dh=function(t){i.ecc[t]={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=i.bitArray.bitLength(t),r=i.bitArray.bitSlice(t,0,e/2),n=i.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()}},generateKeys:function(e,r,n){if(void 0===e&&(e=256),"number"==typeof e&&(e=i.ecc.curves["c"+e],void 0===e))throw new i.exception.invalid("no such curve");if(void 0===n)var n=i.bn.random(e.r,r);var s=e.G.mult(n);return{pub:new i.ecc[t].publicKey(e,s),sec:new i.ecc[t].secretKey(e,n)}}}},i.ecc._dh("elGamal"),i.ecc.elGamal.publicKey.prototype={kem:function(t){var e=i.bn.random(this._curve.r,t),r=this._curve.G.mult(e).toBits(),n=i.hash.sha256.hash(this._point.mult(e).toBits());return{key:n,tag:r}}},i.ecc.elGamal.secretKey.prototype={unkem:function(t){return i.hash.sha256.hash(this._curve.fromBits(t).mult(this._exponent).toBits())},dh:function(t){return i.hash.sha256.hash(t._point.mult(this._exponent).toBits())}},i.ecc._dh("ecdsa"),i.ecc.ecdsa.secretKey.prototype={sign:function(t,e,r,n){i.bitArray.bitLength(t)>this._curveBitLength&&(t=i.bitArray.clamp(t,this._curveBitLength));var s=this._curve.r,o=s.bitLength(),a=n||i.bn.random(s.sub(1),e).add(1),c=this._curve.G.mult(a).x.mod(s),u=i.bn.fromBits(t).add(c.mul(this._exponent)),h=r?u.inverseMod(s).mul(a).mod(s):u.mul(a.inverseMod(s)).mod(s);return i.bitArray.concat(c.toBits(o),h.toBits(o))}},i.ecc.ecdsa.publicKey.prototype={verify:function(t,e,r){i.bitArray.bitLength(t)>this._curveBitLength&&(t=i.bitArray.clamp(t,this._curveBitLength));var n=i.bitArray,s=this._curve.r,o=this._curveBitLength,a=i.bn.fromBits(n.bitSlice(e,0,o)),c=i.bn.fromBits(n.bitSlice(e,o,2*o)),u=r?c:c.inverseMod(s),h=i.bn.fromBits(t).mul(u).mod(s),f=a.mul(u).mod(s),l=this._curve.G.mult2(h,f,this._point).x;if(a.equals(0)||c.equals(0)||a.greaterEquals(s)||c.greaterEquals(s)||!l.equals(a)){if(void 0===r)return this.verify(t,e,!0);throw new i.exception.corrupt("signature didn't check out")}return!0}},i.keyexchange.srp={makeVerifier:function(t,e,r,n){var s;return s=i.keyexchange.srp.makeX(t,e,r),s=i.bn.fromBits(s),n.g.powermod(s,n.N)},makeX:function(t,e,r){var n=i.hash.sha1.hash(t+":"+e);return i.hash.sha1.hash(i.bitArray.concat(r,n))},knownGroup:function(t){return"string"!=typeof t&&(t=t.toString()),i.keyexchange.srp._didInitKnownGroups||i.keyexchange.srp._initKnownGroups(),i.keyexchange.srp._knownGroups[t]},_didInitKnownGroups:!1,_initKnownGroups:function(){var t,e,r;for(t=0;t>>32-e}function a(t){return(255&t)<<24|(65280&t)<<8|(t&255<<16)>>>8|(t&255<<24)>>>24}function c(i){for(var a,c=this._h[0],u=this._h[1],l=this._h[2],_=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],k=0;16>k;++k)a=o(c+t(u,l,_)+i[p[k]]+h[k],y[k])+m,c=m,m=_,_=o(l,10),l=u,u=a,a=o(g+s(b,w,E)+i[d[k]]+f[k],v[k])+x,g=x,x=E,E=o(w,10),w=b,b=a;for(;32>k;++k)a=o(c+e(u,l,_)+i[p[k]]+h[k],y[k])+m,c=m,m=_,_=o(l,10),l=u,u=a,a=o(g+n(b,w,E)+i[d[k]]+f[k],v[k])+x,g=x,x=E,E=o(w,10),w=b,b=a;for(;48>k;++k)a=o(c+r(u,l,_)+i[p[k]]+h[k],y[k])+m,c=m,m=_,_=o(l,10),l=u,u=a,a=o(g+r(b,w,E)+i[d[k]]+f[k],v[k])+x,g=x,x=E,E=o(w,10),w=b,b=a;for(;64>k;++k)a=o(c+n(u,l,_)+i[p[k]]+h[k],y[k])+m,c=m,m=_,_=o(l,10),l=u,u=a,a=o(g+e(b,w,E)+i[d[k]]+f[k],v[k])+x,g=x,x=E,E=o(w,10),w=b,b=a;for(;80>k;++k)a=o(c+s(u,l,_)+i[p[k]]+h[k],y[k])+m,c=m,m=_,_=o(l,10),l=u,u=a,a=o(g+t(b,w,E)+i[d[k]]+f[k],v[k])+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]+_+x,this._h[2]=this._h[3]+m+g,this._h[3]=this._h[4]+c+b,this._h[4]=this._h[0]+u+w,this._h[0]=a}i.hash.ripemd160=function(t){t?(this._h=t._h.slice(0),this._buffer=t._buffer.slice(0),this._length=t._length):this.reset()},i.hash.ripemd160.hash=function(t){return(new i.hash.ripemd160).update(t).finalize()},i.hash.ripemd160.prototype={reset:function(){return this._h=u.slice(0),this._buffer=[],this._length=0,this},update:function(t){"string"==typeof t&&(t=i.codec.utf8String.toBits(t));var e,r=this._buffer=i.bitArray.concat(this._buffer,t),n=this._length,s=this._length=n+i.bitArray.bitLength(t);for(e=-512&512+n;s>=e;e+=512){for(var o=r.splice(0,16),u=0;16>u;++u)o[u]=a(o[u]);c.call(this,o)}return this},finalize:function(){var t=i.bitArray.concat(this._buffer,[i.bitArray.partial(1,1)]),e=(this._length+1)%512,r=(e>448?512:448)-e%448,n=r%32;for(n>0&&(t=i.bitArray.concat(t,[i.bitArray.partial(n,0)]));r>=32;r-=32)t.push(0);for(t.push(a(0|this._length)),t.push(a(Math.floor(this._length/4294967296)));t.length;){for(var s=t.splice(0,16),o=0;16>o;++o)s[o]=a(s[o]);c.call(this,s)}var u=this._h;this.reset();for(var o=0;5>o;++o)u[o]=a(u[o]);return u}};for(var u=[1732584193,4023233417,2562383102,271733878,3285377520],h=[0,1518500249,1859775393,2400959708,2840853838],f=[1352829926,1548603684,1836072691,2053994217,0],l=4;l>=0;--l)for(var _=1;16>_;++_)h.splice(l,0,h[l]),f.splice(l,0,f[l]);var p=[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],d=[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]}(),i.bn.ZERO=new i.bn(0),i.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),s=0;if(!e.greaterEquals(r))return[new i.bn(0),this.copy()];if(e.equals(r))return[new i.bn(1),new i.bn(0)];for(;e.greaterEquals(r);s++)r.doubleM();for(;s>0;s--)n.doubleM(),r.halveM(),e.greaterEquals(r)&&(n.addM(1),e.subM(t).normalize());return[n,e]},i.bn.prototype.divRound=function(t){var e=this.divRem(t),r=e[0],i=e[1];return i.doubleM().greaterEquals(t)&&r.addM(1),r},i.bn.prototype.div=function(t){var e=this.divRem(t);return e[0]},i.bn.prototype.sign=function(){return this.greaterEquals(i.bn.ZERO)?1:-1},i.bn.prototype.neg=function(){return i.bn.ZERO.sub(this)},i.bn.prototype.abs=function(){return-1===this.sign()?this.neg():this},i.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 i.bn(this);t>=this.radix;)e.limbs.shift(),t-=this.radix;for(;t--;)e.halveM();return e},i.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 i.bn(this);t>=this.radix;)e.limbs.unshift(0),t-=this.radix;for(;t--;)e.doubleM();return e},i.bn.prototype.toNumber=function(){return 0|this.limbs[0]},i.bn.prototype.testBit=function(t){var e=Math.floor(t/this.radix),r=t%this.radix;return e>=this.limbs.length?0:1&this.limbs[e]>>>r},i.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},i.bn.prototype.am=function(t,e,r,i,n,s){for(var o=4095&e,a=e>>12;--s>=0;){var c=4095&this.limbs[t],u=this.limbs[t++]>>12,h=a*c+u*o;c=o*c+((4095&h)<<12)+r.limbs[i]+n,n=(c>>24)+(h>>12)+a*u,r.limbs[i++]=16777215&c}return n};var n=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(i=r+this.mt,t.limbs[i]+=this.m.am(0,n,t,r,0,this.mt);t.limbs[i]>=e;)t.limbs[i]-=e,t.limbs[++i]++}return t.trim(),t=t.shiftRight(this.mt*this.m.radix),t.greaterEquals(this.m)&&(t=t.sub(this.m)),t.trim().normalize().reduce()},n.prototype.square=function(t){return this.reduce(t.square())},n.prototype.multiply=function(t,e){return this.reduce(t.mul(e))},n.prototype.convert=function(t){return t.abs().shiftLeft(this.mt*this.m.radix).mod(this.m)},n.prototype.revert=function(t){return this.reduce(t.copy())},i.bn.prototype.powermodMontgomery=function(t,e){var i,s=t.bitLength(),o=new this._class(1);if(0>=s)return o;if(i=18>s?1:48>s?3:144>s?4:768>s?5:6,8>s||!e.testBit(0))return this.powermod(t,e);var a=new n(e);t.trim().normalize();var c=new Array,u=3,h=i-1,f=(1<1)for(var l=a.square(c[1]);f>=u;)c[u]=a.multiply(l,c[u-2]),u+=2;var _,p,d=t.limbs.length-1,y=!0,v=new this._class;for(s=r(t.limbs[d])-1;d>=0;){for(s>=h?_=t.limbs[d]>>s-h&f:(_=(t.limbs[d]&(1<0&&(_|=t.limbs[d-1]>>this.radix+s-h)),u=i;0==(1&_);)_>>=1,--u;if((s-=u)<0&&(s+=this.radix,--d),y)o=c[_].copy(),y=!1;else{for(;u>1;)v=a.square(o),o=a.square(v),u-=2;u>0?v=a.square(o):(p=o,o=v,v=p),o=a.multiply(v,c[_])}for(;d>=0&&0==(t.limbs[d]&1<=0;){var o=e*this[t++]+r[i]+n;n=Math.floor(o/67108864),r[i++]=67108863&o}return n}function s(t,e,r,i,n,s){for(var o=32767&e,a=e>>15;--s>=0;){var c=32767&this[t],u=this[t++]>>15,h=a*c+u*o;c=o*c+((32767&h)<<15)+r[i]+(1073741823&n),n=(c>>>30)+(h>>>15)+a*u+(n>>>30),r[i++]=1073741823&c}return n}function o(t,e,r,i,n,s){for(var o=16383&e,a=e>>14;--s>=0;){var c=16383&this[t],u=this[t++]>>14,h=a*c+u*o;c=o*c+((16383&h)<<14)+r[i]+n,n=(c>>28)+(h>>14)+a*u,r[i++]=268435455&c}return n}function a(t){return or.charAt(t)}function c(t,e){var r=ar[t.charCodeAt(e)];return null==r?-1:r}function u(t){for(var e=this.t-1;e>=0;--e)t[e]=this[e];t.t=this.t,t.s=this.s}function h(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 f(t){var e=i();return e.fromInt(t),e}function l(t,e){var i;if(16==e)i=4;else if(8==e)i=3;else if(256==e)i=8;else if(2==e)i=1;else if(32==e)i=5;else{if(4!=e)return this.fromRadix(t,e),void 0;i=2}this.t=0,this.s=0;for(var n=t.length,s=!1,o=0;--n>=0;){var a=8==i?255&t[n]:c(t,n);0>a?"-"==t.charAt(n)&&(s=!0):(s=!1,0==o?this[this.t++]=a:o+i>this.DB?(this[this.t-1]|=(a&(1<>this.DB-o):this[this.t-1]|=a<=this.DB&&(o-=this.DB))}8==i&&0!=(128&t[0])&&(this.s=-1,o>0&&(this[this.t-1]|=(1<0&&this[this.t-1]==t;)--this.t}function p(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,i=(1<0)for(c>c)>0&&(n=!0,s=a(r));o>=0;)e>c?(r=(this[o]&(1<>(c+=this.DB-e)):(r=this[o]>>(c-=e)&i,0>=c&&(c+=this.DB,--o)),r>0&&(n=!0),n&&(s+=a(r));return n?s:"0"}function d(){var t=i();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+o+1]=this[r]>>n|a,a=(this[r]&s)<=0;--r)e[r]=0;e[o]=a,e.t=this.t+o+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 i=t%this.DB,n=this.DB-i,s=(1<>i;for(var o=r+1;o>i;i>0&&(e[this.t-r-1]|=(this.s&s)<r;)i+=this[r]-t[r],e[r++]=i&this.DM,i>>=this.DB;if(t.t>=this.DB;i+=this.s}else{for(i+=this.s;r>=this.DB;i-=t.s}e.s=0>i?-1:0,-1>i?e[r++]=this.DV+i:i>0&&(e[r++]=i),e.t=r,e.clamp()}function T(t,e){var i=this.abs(),n=t.abs(),s=i.t;for(e.t=s+n.t;--s>=0;)e[s]=0;for(s=0;s=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 A(t,e,n){var s=t.abs();if(!(s.t<=0)){var o=this.abs();if(o.t0?(s.lShiftTo(h,a),o.lShiftTo(h,n)):(s.copyTo(a),o.copyTo(n));var f=a.t,l=a[f-1];if(0!=l){var _=l*(1<1?a[f-2]>>this.F2:0),p=this.FV/_,d=(1<=0&&(n[n.t++]=1,n.subTo(b,n)),r.ONE.dlShiftTo(f,b),b.subTo(a,a);a.t=0;){var w=n[--v]==l?this.DM:Math.floor(n[v]*p+(n[v-1]+y)*d);if((n[v]+=a.am(0,w,n,g,0,f))0&&n.rShiftTo(h,n),0>c&&r.ZERO.subTo(n,n)}}}function j(t){var e=i();return this.abs().divRemTo(t,null,e),this.s<0&&e.compareTo(r.ZERO)>0&&t.subTo(e,e),e}function B(t){this.m=t}function q(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t}function I(t){return t}function R(t){t.divRemTo(this.m,null,t)}function D(t,e,r){t.multiplyTo(e,r),this.reduce(r)}function O(t,e){t.squareTo(e),this.reduce(e)}function M(){if(this.t<1)return 0;var t=this[0];if(0==(1&t))return 0;var e=3&t;return e=15&e*(2-(15&t)*e),e=255&e*(2-(255&t)*e),e=65535&e*(2-(65535&(65535&t)*e)),e=e*(2-t*e%this.DV)%this.DV,e>0?this.DV-e:-e}function L(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 N(t){var e=i();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,i,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 z(t,e,r){t.multiplyTo(e,r),this.reduce(r)}function U(){return 0==(this.t>0?1&this[0]:this.s)}function V(t,e){if(t>4294967295||1>t)return r.ONE;var n=i(),s=i(),o=e.convert(this),a=m(t)-1;for(o.copyTo(n);--a>=0;)if(e.sqrTo(n,s),(t&1<0)e.mulTo(s,o,n);else{var c=n;n=s,s=c}return e.revert(n)}function H(t,e){var r;return r=256>t||e.isEven()?new B(e):new L(e),this.exp(t,r)}function G(){var t=i();return this.copyTo(t),t}function X(){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 W(){return 0==this.t?this.s:this[0]<<16>>16}function K(t){return Math.floor(Math.LN2*this.DB/Math.log(t))}function J(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1}function Q(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),n=f(r),s=i(),o=i(),a="";for(this.divRemTo(n,s,o);s.signum()>0;)a=(r+o.intValue()).toString(t).substr(1)+a,s.divRemTo(n,s,o);return o.intValue().toString(t)+a}function Y(t,e){this.fromInt(0),null==e&&(e=10);for(var i=this.chunkSize(e),n=Math.pow(e,i),s=!1,o=0,a=0,u=0;uh?"-"==t.charAt(u)&&0==this.signum()&&(s=!0):(a=e*a+h,++o>=i&&(this.dMultiply(n),this.dAddOffset(a,0),o=0,a=0))}o>0&&(this.dMultiply(Math.pow(e,o)),this.dAddOffset(a,0)),s&&r.ZERO.subTo(this,this)}function $(t,e,i){if("number"==typeof e)if(2>t)this.fromInt(1); +else for(this.fromNumber(t,i),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 n=new Array,s=7&t;n.length=(t>>3)+1,e.nextBytes(n),s>0?n[0]&=(1<0)for(i>i)!=(this.s&this.DM)>>i&&(e[n++]=r|this.s<=0;)8>i?(r=(this[t]&(1<>(i+=this.DB-8)):(r=255&this[t]>>(i-=8),0>=i&&(i+=this.DB,--t)),0!=(128&r)&&(r|=-256),0==n&&(128&this.s)!=(128&r)&&++n,(n>0||r!=this.s)&&(e[n++]=r);return e}function ee(t){return 0==this.compareTo(t)}function re(t){return this.compareTo(t)<0?this:t}function ie(t){return this.compareTo(t)>0?this:t}function ne(t,e,r){var i,n,s=Math.min(t.t,this.t);for(i=0;s>i;++i)r[i]=e(this[i],t[i]);if(t.tt?this.rShiftTo(-t,e):this.lShiftTo(t,e),e}function de(t){var e=i();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;)i+=this[r]+t[r],e[r++]=i&this.DM,i>>=this.DB;if(t.t>=this.DB;i+=this.s}else{for(i+=this.s;r>=this.DB;i+=t.s}e.s=0>i?-1:0,i>0?e[r++]=i:-1>i&&(e[r++]=this.DV+i),e.t=r,e.clamp()}function Se(t){var e=i();return this.addTo(t,e),e}function Ae(t){var e=i();return this.subTo(t,e),e}function je(t){var e=i();return this.multiplyTo(t,e),e}function Be(){var t=i();return this.squareTo(t),t}function qe(t){var e=i();return this.divRemTo(t,e,null),e}function Ie(t){var e=i();return this.divRemTo(t,null,e),e}function Re(t){var e=i(),r=i();return this.divRemTo(t,e,r),new Array(e,r)}function De(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 Me(){}function Le(t){return t}function Ce(t,e,r){t.multiplyTo(e,r)}function Ne(t,e){t.squareTo(e)}function Fe(t){return this.exp(t,new Me)}function Pe(t,e,r){var i=Math.min(this.t+t.t,e);for(r.s=0,r.t=i;i>0;)r[--i]=0;var n;for(n=r.t-this.t;n>i;++i)r[i+this.t]=this.am(0,t[i],r,i,0,this.t);for(n=Math.min(t.t,e);n>i;++i)this.am(0,t[i],r,i,0,e-i);r.clamp()}function ze(t,e,r){--e;var i=r.t=this.t+t.t-e;for(r.s=0;--i>=0;)r[i]=0;for(i=Math.max(e-this.t,0);i2*this.m.t)return t.mod(this.m);if(t.compareTo(this.m)<0)return t;var e=i();return t.copyTo(e),this.reduce(e),e}function He(t){return t}function Ge(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 Xe(t,e){t.squareTo(e),this.reduce(e)}function Ze(t,e,r){t.multiplyTo(e,r),this.reduce(r)}function We(t,e){var r,n,s=t.bitLength(),o=f(1);if(0>=s)return o;r=18>s?1:48>s?3:144>s?4:768>s?5:6,n=8>s?new B(e):e.isEven()?new Ue(e):new L(e);var a=new Array,c=3,u=r-1,h=(1<1){var l=i();for(n.sqrTo(a[1],l);h>=c;)a[c]=i(),n.mulTo(l,a[c-2],a[c]),c+=2}var _,p,d=t.t-1,y=!0,v=i();for(s=m(t[d])-1;d>=0;){for(s>=u?_=t[d]>>s-u&h:(_=(t[d]&(1<0&&(_|=t[d-1]>>this.DB+s-u)),c=r;0==(1&_);)_>>=1,--c;if((s-=c)<0&&(s+=this.DB,--d),y)a[_].copyTo(o),y=!1;else{for(;c>1;)n.sqrTo(o,v),n.sqrTo(v,o),c-=2;c>0?n.sqrTo(o,v):(p=o,o=v,v=p),n.mulTo(v,a[_],o)}for(;d>=0&&0==(t[d]&1<s)return e;for(s>n&&(s=n),s>0&&(e.rShiftTo(s,e),r.rShiftTo(s,r));e.signum()>0;)(n=e.getLowestSetBit())>0&&e.rShiftTo(n,e),(n=r.getLowestSetBit())>0&&r.rShiftTo(n,r),e.compareTo(r)>=0?(e.subTo(r,e),e.rShiftTo(1,e)):(r.subTo(e,r),r.rShiftTo(1,r));return s>0&&r.lShiftTo(s,r),r}function Je(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 i=this.t-1;i>=0;--i)r=(e*r+this[i])%t;return r}function Qe(t){var e=t.isEven();if(this.isEven()&&e||0==t.signum())return r.ZERO;for(var i=t.clone(),n=this.clone(),s=f(1),o=f(0),a=f(0),c=f(1);0!=i.signum();){for(;i.isEven();)i.rShiftTo(1,i),e?(s.isEven()&&o.isEven()||(s.addTo(this,s),o.subTo(t,o)),s.rShiftTo(1,s)):o.isEven()||o.subTo(t,o),o.rShiftTo(1,o);for(;n.isEven();)n.rShiftTo(1,n),e?(a.isEven()&&c.isEven()||(a.addTo(this,a),c.subTo(t,c)),a.rShiftTo(1,a)):c.isEven()||c.subTo(t,c),c.rShiftTo(1,c);i.compareTo(n)>=0?(i.subTo(n,i),e&&s.subTo(a,s),o.subTo(c,o)):(n.subTo(i,n),e&&a.subTo(s,a),c.subTo(o,c))}return 0!=n.compareTo(r.ONE)?r.ZERO:c.compareTo(t)>=0?c.subtract(t):c.signum()<0?(c.addTo(t,c),c.signum()<0?c.add(t):c):c}function Ye(t){var e,r=this.abs();if(1==r.t&&r[0]<=cr[cr.length-1]){for(e=0;ei;)i*=cr[n++];for(i=r.modInt(i);n>e;)if(0==i%cr[e++])return!1}return r.millerRabin(t)}function $e(t){var e=this.subtract(r.ONE),n=e.getLowestSetBit();if(0>=n)return!1;var s=e.shiftRight(n);t=t+1>>1,t>cr.length&&(t=cr.length);for(var o=i(),a=0;t>a;++a){o.fromInt(cr[Math.floor(Math.random()*cr.length)]);var c=o.modPow(s,this);if(0!=c.compareTo(r.ONE)&&0!=c.compareTo(e)){for(var u=1;u++=sr;++sr)ar[nr++]=sr;for(nr="a".charCodeAt(0),sr=10;36>sr;++sr)ar[nr++]=sr;for(nr="A".charCodeAt(0),sr=10;36>sr;++sr)ar[nr++]=sr;B.prototype.convert=q,B.prototype.revert=I,B.prototype.reduce=R,B.prototype.mulTo=D,B.prototype.sqrTo=O,L.prototype.convert=C,L.prototype.revert=N,L.prototype.reduce=F,L.prototype.mulTo=z,L.prototype.sqrTo=P,Me.prototype.convert=Le,Me.prototype.revert=Le,Me.prototype.mulTo=Ce,Me.prototype.sqrTo=Ne,Ue.prototype.convert=Ve,Ue.prototype.revert=He,Ue.prototype.reduce=Ge,Ue.prototype.mulTo=Ze,Ue.prototype.sqrTo=Xe;var cr=[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],ur=(1<<26)/cr[cr.length-1];r.prototype.chunkSize=K,r.prototype.toRadix=Q,r.prototype.fromRadix=Y,r.prototype.fromNumber=$,r.prototype.bitwiseTo=ne,r.prototype.changeBit=we,r.prototype.addTo=Te,r.prototype.dMultiply=De,r.prototype.dAddOffset=Oe,r.prototype.multiplyLowerTo=Pe,r.prototype.multiplyUpperTo=ze,r.prototype.modInt=Je,r.prototype.millerRabin=$e,r.prototype.copyTo=u,r.prototype.fromInt=h,r.prototype.fromString=l,r.prototype.clamp=_,r.prototype.dlShiftTo=b,r.prototype.drShiftTo=w,r.prototype.lShiftTo=E,r.prototype.rShiftTo=x,r.prototype.subTo=k,r.prototype.multiplyTo=T,r.prototype.squareTo=S,r.prototype.divRemTo=A,r.prototype.invDigit=M,r.prototype.isEven=U,r.prototype.exp=V,r.prototype.toString=p,r.prototype.negate=d,r.prototype.abs=y,r.prototype.compareTo=v,r.prototype.bitLength=g,r.prototype.mod=j,r.prototype.modPowInt=H,r.prototype.clone=G,r.prototype.intValue=X,r.prototype.byteValue=Z,r.prototype.shortValue=W,r.prototype.signum=J,r.prototype.toByteArray=te,r.prototype.equals=ee,r.prototype.min=re,r.prototype.max=ie,r.prototype.and=oe,r.prototype.or=ce,r.prototype.xor=he,r.prototype.andNot=le,r.prototype.not=_e,r.prototype.shiftLeft=pe,r.prototype.shiftRight=de,r.prototype.getLowestSetBit=ve,r.prototype.bitCount=ge,r.prototype.testBit=be,r.prototype.setBit=Ee,r.prototype.clearBit=xe,r.prototype.flipBit=ke,r.prototype.add=Se,r.prototype.subtract=Ae,r.prototype.multiply=je,r.prototype.divide=qe,r.prototype.remainder=Ie,r.prototype.divideAndRemainder=Re,r.prototype.modPow=We,r.prototype.modInverse=Qe,r.prototype.pow=Fe,r.prototype.gcd=Ke,r.prototype.isProbablePrime=Ye,r.prototype.square=Be,r.ZERO=f(0),r.ONE=f(1),r.valueOf=i,e.BigInteger=r},29:function(t){function e(t){if(!t||"[object Object]"!==i.call(t)||t.nodeType||t.setInterval)return!1;var e=r.call(t,"constructor"),n=r.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!e&&!n)return!1;var s;for(s in t);return void 0===s||r.call(t,s)}var r=Object.prototype.hasOwnProperty,i=Object.prototype.toString;t.exports=function n(){var t,r,i,s,o,a,c=arguments[0]||{},u=1,h=arguments.length,f=!1;for("boolean"==typeof c&&(f=c,c=arguments[1]||{},u=2),"object"!=typeof c&&"function"!=typeof c&&(c={});h>u;u++)if(null!=(t=arguments[u]))for(r in t)i=c[r],s=t[r],c!==s&&(f&&s&&(e(s)||(o=Array.isArray(s)))?(o?(o=!1,a=i&&Array.isArray(i)?i:[]):a=i&&e(i)?i:{},c[r]=n(f,a,s)):void 0!==s&&(c[r]=s));return c}},30:function(t,e,r){function i(t){function e(t,e){f._next_sequence=e,f.emit("sequence_loaded",e)}function r(t){var t=i.normalize_transaction(t),e=t.tx_json.Sequence,r=t.hash;f._sequence_cache[e]=t;var n=f._pending.get("hash",r);n?n.emit("success",t):f._cache[r]=t}function n(){var t={account:f.account._account_id,ledger_index_min:-1,ledger_index_max:-1,limit:5};f.remote.request_account_tx(t,function(t,e){!t&&e.transactions&&e.transactions.forEach(r)}),f.account.get_next_sequence(function(t,r){e(t,r),f._resubmit(3)})}function c(){f.remote.once("connect",n)}function u(){f._pending.forEach(function(t){if(f.remote.local_fee&&t.tx_json.Fee){var e=t.tx_json.Fee,r=f.remote.fee_tx(t.fee_units()).to_json();t.tx_json.Fee=r,t.emit("fee_adjusted",e,r)}})}function h(t){f._pending.forEach(function(e){switch(e.last_ledger=t,t.ledger_index-e.submit_index){case 8:e.emit("lost",t),e.emit("error",new o("tejLost","Transaction lost"));break;case 4:e.set_state("client_missing"),e.emit("missing",t)}})}s.call(this);var f=this;this.account=t,this.remote=t._remote,this._timeout=void 0,this._pending=new a,this._next_sequence=void 0,this._cache={},this._sequence_cache={},this._max_fee=this.remote.max_fee,this._submission_timeout=this.remote._submission_timeout,this.account.get_next_sequence(e),this.account.on("transaction-outbound",r),this.remote.on("disconnect",c),this.remote.on("load_changed",u),this.remote.on("ledger_closed",h)}var n=r(25),s=r(24).EventEmitter,o=r(18).RippleError,a=r(42).TransactionQueue;r(2),n.inherits(i,s),i.normalize_transaction=function(t){t.tx&&(t.transaction=t.tx);var e=t.transaction.hash;t.transaction.Sequence;var r={ledger_hash:t.ledger_hash||t.transaction.ledger_hash,ledger_index:t.ledger_index||t.transaction.ledger_index,metadata:t.meta,tx_json:t.transaction};return r.hash=e,r.tx_json.ledger_index=r.ledger_index,r.tx_json.inLedger=r.ledger_index,r},i.prototype._fill=function(t){var e=this.account._account_id,r=this.remote.transaction().account_set(e);r.tx_json.Sequence=t.tx_json.Sequence-1,r.submit()},i.prototype._resubmit=function(t){function e(t){if(t&&!t.finalized){var e=r._cache[t.hash],i=r._sequence_cache[t.tx_json.Sequence];e?t.emit("success",e):i?(t.tx_json.Sequence++,r._request(t)):r._request(t)}}var r=this;if(t){var i=Number(t)||3;this._wait_ledgers(i,function(){r._pending.forEach(e)})}else r._pending.forEach(e)},i.prototype._wait_ledgers=function(t,e){function r(){++n===t&&(e(),i.remote.removeListener("ledger_closed",r))}var i=this,n=0;this.remote.on("ledger_closed",r)},i.prototype._request=function(t){function e(e){t.hash=e.tx_json.hash,t.set_state("client_proposed"),t.emit("proposed",{tx_json:e.tx_json,engine_result:e.engine_result,engine_result_code:e.engine_result_code,engine_result_message:e.engine_result_message,rejected:t.isRejected(e.engine_result_code)})}function r(t){switch(t.engine_result){case"tefPAST_SEQ":a.account.get_next_sequence(function(t,e){"number"==typeof e&&(a._next_sequence=e,a._resubmit(2))});break;default:n(t)}}function i(e){switch(e.engine_result){case"terPRE_SEQ":a._fill(t),a._resubmit(3);break;default:n(e)}}function n(e){a._is_too_busy(e)?a._resubmit(1):(a._next_sequence--,t.set_state("remoteError"),t.emit("submitted",e),t.emit("error",new o(e)))}function s(s){switch(t.hash||(t.hash=s.tx_json.hash),s.result=s.engine_result||"",t.emit("submitted",s),s.result.slice(0,3)){case"tec":t.emit("error",s);break;case"tes":e(s);break;case"tef":r(s);break;case"ter":i(s);break;default:n(s)}}var a=this,c=this.remote;if(t.attempts>10)return t.emit("error",new o("tejAttemptsExceeded")),void 0;var u=c.request_submit();return c.local_signing?(t.sign(),u.tx_blob(t.serialize().to_hex())):(u.secret(t._secret),u.build_path(t._build_path),u.tx_json(t.tx_json)),u.once("success",s),u.once("error",n),u.request(),u.timeout(this._submission_timeout,function(){t.emit("timeout"),a.remote._connected&&a._resubmit(1)}),t.set_state("client_submitted"),t.attempts++,u},i.prototype._is_remote_error=function(t){return t&&"object"==typeof t&&"remoteError"===t.error&&"object"==typeof t.remote},i.prototype._is_not_found=function(t){return this._is_remote_error(t)&&/^(txnNotFound|transactionNotFound)$/.test(t.remote.error)},i.prototype._is_too_busy=function(t){return this._is_remote_error(t)&&"tooBusy"===t.remote.error},i.prototype.submit=function(t){function e(e){t.finalized||(r._pending.removeHash(t.hash),t.finalized=!0,t.emit("final",e))}var r=this;if("undefined"==typeof this._next_sequence)return this.once("sequence_loaded",function(){r.submit(t)}),void 0;"number"!=typeof t.tx_json.Sequence&&(t.tx_json.Sequence=this._next_sequence++),t.submit_index=this.remote._ledger_current_index,t.last_ledger=void 0,t.attempts=0,t.complete(),t.on("error",e),t.once("success",e),t.once("abort",function(){t.emit("error",new o("tejAbort","Transaction aborted"))});var i=Number(t.tx_json.Fee),n=this.remote;t._secret||t.tx_json.TxnSignature?n.trusted||n.local_signing?i&&i>this._max_fee?t.emit("error",new o("tejMaxFeeExceeded","Max fee exceeded")):(this._pending.push(t),this._request(t)):t.emit("error",new o("tejServerUntrusted","Attempt to give secret to untrusted server")):t.emit("error",new o("tejSecretUnknown","Missing secret"))},e.TransactionManager=i},31:function(t,e,r){var i=r(9),n=i.sjcl,s=r(11),o=i.jsbn.BigInteger,a=r(4).Base,c=function(){this._value=0/0};c.json_rewrite=function(t,e){return this.from_json(t).to_json(e)},c.from_generic=function(t){return t instanceof this?t.clone():(new this).parse_generic(t)},c.from_hex=function(t){return t instanceof this?t.clone():(new this).parse_hex(t)},c.from_json=function(t){return t instanceof this?t.clone():(new this).parse_json(t)},c.from_bits=function(t){return t instanceof this?t.clone():(new this).parse_bits(t)},c.from_bytes=function(t){return t instanceof this?t.clone():(new this).parse_bytes(t)},c.from_bn=function(t){return t instanceof this?t.clone():(new this).parse_bn(t)},c.is_valid=function(t){return this.from_json(t).is_valid()},c.prototype.clone=function(){return this.copyTo(new this.constructor)},c.prototype.copyTo=function(t){return t._value=this._value,t},c.prototype.equals=function(t){return this._value instanceof o&&t._value instanceof o&&this._value.equals(t._value)},c.prototype.is_valid=function(){return this._value instanceof o},c.prototype.is_zero=function(){return this._value.equals(o.ZERO)},c.prototype.parse_generic=function(t){switch(s.accounts&&t in s.accounts&&(t=s.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=o.valueOf();break;case"1":case this.constructor.STR_ONE:case this.constructor.ACCOUNT_ONE:case this.constructor.HEX_ONE:this._value=new o([1]);break;default:this._value="string"!=typeof t?0/0:"r"===t[0]?a.decode_check(a.VER_ACCOUNT_ID,t):this.constructor.width===t.length?new o(i.stringToArray(t),256):2*this.constructor.width===t.length?new o(t,16):0/0}return this},c.prototype.parse_hex=function(t){return this._value="string"==typeof t&&t.length===2*this.constructor.width?new o(t,16):0/0,this},c.prototype.parse_bits=function(t){if(n.bitArray.bitLength(t)!==8*this.constructor.width)this._value=0/0;else{var e=n.codec.bytes.fromBits(t);this.parse_bytes(e)}return this},c.prototype.parse_bytes=function(t){return this._value=Array.isArray(t)&&t.length===this.constructor.width?new o(t,256):0/0,this},c.prototype.parse_json=c.prototype.parse_hex,c.prototype.parse_bn=function(t){if(t instanceof n.bn&&t.bitLength()<=8*this.constructor.width){var e=n.codec.bytes.fromBits(t.toBits());this._value=new o(e,256)}else this._value=0/0;return this},c.prototype.to_bytes=function(){if(!(this._value instanceof o))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.length>1,h=-7,f=r?0:n-1,l=r?1:-1,_=t[e+f];for(f+=l,s=_&(1<<-h)-1,_>>=-h,h+=a;h>0;s=256*s+t[e+f],f+=l,h-=8);for(o=s&(1<<-h)-1,s>>=-h,h+=i;h>0;o=256*o+t[e+f],f+=l,h-=8);if(0===s)s=1-u;else{if(s===c)return o?0/0:1/0*(_?-1:1);o+=Math.pow(2,i),s-=u}return(_?-1:1)*o*Math.pow(2,s-i)},e.writeIEEE754=function(t,e,r,i,n,s){var o,a,c,u=8*s-n-1,h=(1<>1,l=23===n?Math.pow(2,-24)-Math.pow(2,-77):0,_=i?s-1:0,p=i?-1:1,d=0>e||0===e&&0>1/e?1:0;for(e=Math.abs(e),isNaN(e)||1/0===e?(a=isNaN(e)?1:0,o=h):(o=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-o))<1&&(o--,c*=2),e+=o+f>=1?l/c:l*Math.pow(2,1-f),e*c>=2&&(o++,c/=2),o+f>=h?(a=0,o=h):o+f>=1?(a=(e*c-1)*Math.pow(2,n),o+=f):(a=e*Math.pow(2,f-1)*Math.pow(2,n),o=0));n>=8;t[r+_]=255&a,_+=p,a/=256,n-=8);for(o=o<0;t[r+_]=255&o,_+=p,o/=256,u-=8);t[r+_-p]|=128*d}},35:function(t){t.exports="function"==typeof Array.isArray?Array.isArray:function(t){return"[object Array]"===Object.prototype.toString.call(t)}},36:function(t){t.exports=function(t,e){if(t.indexOf)return t.indexOf(e);for(var r=0;r-1?this._queue[r]:!1},r.prototype.removeSequence=function(t){for(var e,r=[],i=0;e=this._queue[i];i++)e.tx_json&&e.tx_json.Sequence!==t&&r.push(e);this._queue=r},r.prototype.removeHash=function(t){for(var e,r=[],i=0;e=this._queue[i];i++)e.tx_json&&e.hash!==t&&r.push(e);this._queue=r},r.prototype.forEach=function(){Array.prototype.forEach.apply(this._queue,arguments)},r.prototype.push=function(){Array.prototype.push.apply(this._queue,arguments)},e.TransactionQueue=r},43:function(t){!function(){"use strict";function e(t){var e,r,n,s,o,a;if(t.length%4>0)throw"Invalid string. Length must be a multiple of 4";for(o=t.indexOf("="),o=o>0?t.length-o:0,a=[],n=o>0?t.length-4:t.length,e=0,r=0;n>e;e+=4,r+=3)s=i.indexOf(t[e])<<18|i.indexOf(t[e+1])<<12|i.indexOf(t[e+2])<<6|i.indexOf(t[e+3]),a.push((16711680&s)>>16),a.push((65280&s)>>8),a.push(255&s);return 2===o?(s=i.indexOf(t[e])<<2|i.indexOf(t[e+1])>>4,a.push(255&s)):1===o&&(s=i.indexOf(t[e])<<10|i.indexOf(t[e+1])<<4|i.indexOf(t[e+2])>>2,a.push(255&s>>8),a.push(255&s)),a}function r(t){function e(t){return i[63&t>>18]+i[63&t>>12]+i[63&t>>6]+i[63&t]}var r,n,s,o=t.length%3,a="";for(r=0,s=t.length-o;s>r;r+=3)n=(t[r]<<16)+(t[r+1]<<8)+t[r+2],a+=e(n);switch(o){case 1:n=t[t.length-1],a+=i[n>>2],a+=i[63&n<<4],a+="==";break;case 2:n=(t[t.length-2]<<8)+t[t.length-1],a+=i[n>>10],a+=i[63&n>>4],a+=i[63&n<<2],a+="="}return a}var i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";t.exports.toByteArray=e,t.exports.fromByteArray=r}()}}); \ No newline at end of file diff --git a/js/cm-javascript.min.js b/js/cm-javascript.min.js new file mode 100644 index 0000000000..0be93bda5a --- /dev/null +++ b/js/cm-javascript.min.js @@ -0,0 +1,2 @@ +// TODO actually recognize syntax of TypeScript constructs +CodeMirror.defineMode("javascript",function(e,t){function a(e,t,n){return t.tokenize=n,n(e,t)}function f(e,t){var n=!1,r;while((r=e.next())!=null){if(r==t&&!n)return!1;n=!n&&r=="\\"}return n}function h(e,t,n){return l=e,c=n,t}function p(e,t){var n=e.next();if(n=='"'||n=="'")return a(e,t,d(n));if(n=="."&&e.match(/^\d+(?:[eE][+\-]?\d+)?/))return h("number","number");if(/[\[\]{}\(\),;\:\.]/.test(n))return h(n);if(n=="0"&&e.eat(/x/i))return e.eatWhile(/[\da-f]/i),h("number","number");if(/\d/.test(n))return e.match(/^\d*(?:\.\d*)?(?:[eE][+\-]?\d+)?/),h("number","number");if(n=="/")return e.eat("*")?a(e,t,v):e.eat("/")?(e.skipToEnd(),h("comment","comment")):t.lastType=="operator"||t.lastType=="keyword c"||/^[\[{}\(,;:]$/.test(t.lastType)?(f(e,"/"),e.eatWhile(/[gimy]/),h("regexp","string-2")):(e.eatWhile(u),h("operator",null,e.current()));if(n=="#")return e.skipToEnd(),h("error","error");if(u.test(n))return e.eatWhile(u),h("operator",null,e.current());e.eatWhile(/[\w\$_]/);var r=e.current(),i=o.propertyIsEnumerable(r)&&o[r];return i&&t.lastType!="."?h(i.type,i.style,r):h("variable","variable",r)}function d(e){return function(t,n){return f(t,e)||(n.tokenize=p),h("string","string")}}function v(e,t){var n=!1,r;while(r=e.next()){if(r=="/"&&n){t.tokenize=p;break}n=r=="*"}return h("comment","comment")}function g(e,t,n,r,i,s){this.indented=e,this.column=t,this.type=n,this.prev=i,this.info=s,r!=null&&(this.align=r)}function y(e,t){for(var n=e.localVars;n;n=n.next)if(n.name==t)return!0}function b(e,t,n,r,s){var o=e.cc;w.state=e,w.stream=s,w.marked=null,w.cc=o,e.lexical.hasOwnProperty("align")||(e.lexical.align=!0);for(;;){var u=o.length?o.pop():i?M:O;if(u(n,r)){while(o.length&&o[o.length-1].lex)o.pop()();return w.marked?w.marked:n=="variable"&&y(e,r)?"variable-2":t}}}function E(){for(var e=arguments.length-1;e>=0;e--)w.cc.push(arguments[e])}function S(){return E.apply(null,arguments),!0}function x(e){function t(t){for(var n=t;n;n=n.next)if(n.name==e)return!0;return!1}var n=w.state;if(n.context){w.marked="def";if(t(n.localVars))return;n.localVars={name:e,next:n.localVars}}else{if(t(n.globalVars))return;n.globalVars={name:e,next:n.globalVars}}}function N(){w.state.context={prev:w.state.context,vars:w.state.localVars},w.state.localVars=T}function C(){w.state.localVars=w.state.context.vars,w.state.context=w.state.context.prev}function k(e,t){var n=function(){var n=w.state,r=n.indented;n.lexical.type=="stat"&&(r=n.lexical.indented),n.lexical=new g(r,w.stream.column(),e,null,n.lexical,t)};return n.lex=!0,n}function L(){var e=w.state;e.lexical.prev&&(e.lexical.type==")"&&(e.indented=e.lexical.indented),e.lexical=e.lexical.prev)}function A(e){return function(t){return t==e?S():e==";"?E():S(arguments.callee)}}function O(e){return e=="var"?S(k("vardef"),V,A(";"),L):e=="keyword a"?S(k("form"),M,O,L):e=="keyword b"?S(k("form"),O,L):e=="{"?S(k("}"),z,L):e==";"?S():e=="if"?S(k("form"),M,O,L,J):e=="function"?S(Z):e=="for"?S(k("form"),A("("),k(")"),K,A(")"),L,O,L):e=="variable"?S(k("stat"),F):e=="switch"?S(k("form"),M,k("}","switch"),A("{"),z,L,L):e=="case"?S(M,A(":")):e=="default"?S(A(":")):e=="catch"?S(k("form"),N,A("("),et,A(")"),O,L,C):E(k("stat"),M,A(";"),L)}function M(e){return D(e,!1)}function _(e){return D(e,!0)}function D(e,t){var n=t?j:B;return m.hasOwnProperty(e)?S(n):e=="function"?S(Z):e=="keyword c"?S(t?H:P):e=="("?S(k(")"),P,A(")"),L,n):e=="operator"?S(t?_:M):e=="["?S(k("]"),U(_,"]"),L,n):e=="{"?S(k("}"),U(q,"}"),L,n):S()}function P(e){return e.match(/[;\}\)\],]/)?E():E(M)}function H(e){return e.match(/[;\}\)\],]/)?E():E(_)}function B(e,t){return e==","?S(M):j(e,t,!1)}function j(e,t,n){var r=n==0?B:j,i=n==0?M:_;if(e=="operator")return/\+\+|--/.test(t)?S(r):t=="?"?S(M,A(":"),i):S(i);if(e==";")return;if(e=="(")return S(k(")","call"),U(_,")"),L,r);if(e==".")return S(I,r);if(e=="[")return S(k("]"),P,A("]"),L,r)}function F(e){return e==":"?S(L,O):E(B,A(";"),L)}function I(e){if(e=="variable")return w.marked="property",S()}function q(e,t){if(e=="variable"){w.marked="property";if(t=="get"||t=="set")return S(R)}else if(e=="number"||e=="string")w.marked=e+" property";if(m.hasOwnProperty(e))return S(A(":"),_)}function R(e){return e==":"?S(M):e!="variable"?S(A(":"),M):(w.marked="property",S(Z))}function U(e,t){function n(r){if(r==","){var i=w.state.lexical;return i.info=="call"&&(i.pos=(i.pos||0)+1),S(e,n)}return r==t?S():S(A(t))}return function(r){return r==t?S():E(e,n)}}function z(e){return e=="}"?S():E(O,z)}function W(e){return e==":"?S(X):E()}function X(e){return e=="variable"?(w.marked="variable-3",S()):E()}function V(e,t){return e=="variable"?(x(t),s?S(W,$):S($)):E()}function $(e,t){if(t=="=")return S(_,$);if(e==",")return S(V)}function J(e,t){if(e=="keyword b"&&t=="else")return S(k("form"),O,L)}function K(e){return e=="var"?S(V,A(";"),G):e==";"?S(G):e=="variable"?S(Q):E(M,A(";"),G)}function Q(e,t){return t=="in"?S(M):S(B,G)}function G(e,t){return e==";"?S(Y):t=="in"?S(M):E(M,A(";"),Y)}function Y(e){e!=")"&&S(M)}function Z(e,t){if(e=="variable")return x(t),S(Z);if(e=="(")return S(k(")"),N,U(et,")"),L,O,C)}function et(e,t){if(e=="variable")return x(t),s?S(W):S()}var n=e.indentUnit,r=t.statementIndent,i=t.json,s=t.typescript,o=function(){function e(e){return{type:e,style:"keyword"}}var t=e("keyword a"),n=e("keyword b"),r=e("keyword c"),i=e("operator"),o={type:"atom",style:"atom"},u={"if":e("if"),"while":t,"with":t,"else":n,"do":n,"try":n,"finally":n,"return":r,"break":r,"continue":r,"new":r,"delete":r,"throw":r,"var":e("var"),"const":e("var"),let:e("var"),"function":e("function"),"catch":e("catch"),"for":e("for"),"switch":e("switch"),"case":e("case"),"default":e("default"),"in":i,"typeof":i,"instanceof":i,"true":o,"false":o,"null":o,"undefined":o,NaN:o,Infinity:o,"this":e("this")};if(s){var a={type:"variable",style:"variable-3"},f={"interface":e("interface"),"class":e("class"),"extends":e("extends"),constructor:e("constructor"),"public":e("public"),"private":e("private"),"protected":e("protected"),"static":e("static"),"super":e("super"),string:a,number:a,bool:a,any:a};for(var l in f)u[l]=f[l]}return u}(),u=/[+\-*&%=<>!?|~^]/,l,c,m={atom:!0,number:!0,variable:!0,string:!0,regexp:!0,"this":!0},w={state:null,column:null,marked:null,cc:null},T={name:"this",next:{name:"arguments"}};return L.lex=!0,{startState:function(e){return{tokenize:p,lastType:null,cc:[],lexical:new g((e||0)-n,0,"block",!1),localVars:t.localVars,globalVars:t.globalVars,context:t.localVars&&{vars:t.localVars},indented:0}},token:function(e,t){e.sol()&&(t.lexical.hasOwnProperty("align")||(t.lexical.align=!1),t.indented=e.indentation());if(t.tokenize!=v&&e.eatSpace())return null;var n=t.tokenize(e,t);return l=="comment"?n:(t.lastType=l!="operator"||c!="++"&&c!="--"?l:"incdec",b(t,n,l,c,e))},indent:function(e,i){if(e.tokenize==v)return CodeMirror.Pass;if(e.tokenize!=p)return 0;var s=i&&i.charAt(0),o=e.lexical;for(var u=e.cc.length-1;u>=0;--u){var a=e.cc[u];if(a==L)o=o.prev;else if(a!=J||/^else\b/.test(i))break}o.type=="stat"&&s=="}"&&(o=o.prev),r&&o.type==")"&&o.prev.type=="stat"&&(o=o.prev);var f=o.type,l=s==f;return f=="vardef"?o.indented+(e.lastType=="operator"||e.lastType==","?4:0):f=="form"&&s=="{"?o.indented:f=="form"?o.indented+n:f=="stat"?o.indented+(e.lastType=="operator"||e.lastType==","?r||n:0):o.info=="switch"&&!l&&t.doubleIndentSwitch!=0?o.indented+(/^(?:case|default)\b/.test(i)?n:2*n):o.align?o.column+(l?0:1):o.indented+(l?0:n)},electricChars:":{}",blockCommentStart:i?null:"/*",blockCommentEnd:i?null:"*/",lineComment:i?null:"//",fold:"brace",helperType:i?"json":"javascript",jsonMode:i}}),CodeMirror.defineMIME("text/javascript","javascript"),CodeMirror.defineMIME("text/ecmascript","javascript"),CodeMirror.defineMIME("application/javascript","javascript"),CodeMirror.defineMIME("application/ecmascript","javascript"),CodeMirror.defineMIME("application/json",{name:"javascript",json:!0}),CodeMirror.defineMIME("application/x-json",{name:"javascript",json:!0}),CodeMirror.defineMIME("text/typescript",{name:"javascript",typescript:!0}),CodeMirror.defineMIME("application/typescript",{name:"javascript",typescript:!0}); \ No newline at end of file diff --git a/ripple-api-tool.html b/ripple-api-tool.html new file mode 100644 index 0000000000..7e5ef42ec3 --- /dev/null +++ b/ripple-api-tool.html @@ -0,0 +1,256 @@ + + + + + + + + Ripple Developer Portal: Ripple API Tool + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+

Ripple WebSocket API tool

+
Offline
+
+
+
    +
  • server_info
  • +
  • server_state
  • +
  • ping
  • +
    +
  • subscribe
  • +
  • unsubscribe
  • +
    +
  • ledger
  • +
  • ledger_closed
  • +
  • ledger_current
  • +
  • ledger_entry
  • +
    +
  • account_info
  • +
  • account_lines
  • +
  • account_offers
  • +
  • account_tx
  • +
    +
  • transaction_entry
  • +
  • tx
  • +
  • tx_history
  • +
    +
  • submit
  • +
    +
  • ripple_path_find
  • +
  • path_find
  • +
  • book_offers
  • +
+
+
+
+

Request

+
+
Send request
+
Sign transaction
+
+
+

server_info

+

+
Invalid JSON
+

JSON

+
+
+
+

Response

+

Stream output

+
    +
  • show
  • +
  • pause
  • +
+
+

+
+
+
+
+
+
+
+
+ + +