(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")})})();