-
Notifications
You must be signed in to change notification settings - Fork 2
/
bots.js.map
1 lines (1 loc) · 63.5 KB
/
bots.js.map
1
{"version":3,"file":"bots.e043900dc68bd3bf1dc9.js","sources":["webpack:///bots.e043900dc68bd3bf1dc9.js"],"sourcesContent":["(window.webpackJsonp=window.webpackJsonp||[]).push([[15],{1757:function(e,t,n){\"use strict\";var a=n(0),r=n.n(a),o=n(119),s=n(1),i=n.n(s),c=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},l=function(){function e(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,\"value\"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}return function(t,n,a){return n&&e(t.prototype,n),a&&e(t,a),t}}();function u(e,t){if(!(e instanceof t))throw new TypeError(\"Cannot call a class as a function\")}function m(e,t){if(!e)throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\");return!t||\"object\"!=typeof t&&\"function\"!=typeof t?e:t}function p(e,t){if(\"function\"!=typeof t&&null!==t)throw new TypeError(\"Super expression must either be null or a function, not \"+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var b=function(e){function t(e){u(this,t);var n=m(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n.state={imgError:!1},n}return p(t,r.a.Component),l(t,[{key:\"shouldComponentUpdate\",value:function(e,t){return this.props.asset!==e.asset||this.props.maxWidth!==e.maxWidth||this.props.whiteList!==e.whiteList||this.state.imgError!==t.imgError}},{key:\"_onError\",value:function(e){this.state.imgError||(this.props.replaceNoneToBts?this.refs[e.toLowerCase()].src=\"asset-symbols/bts.png\":this.refs[e.toLowerCase()].remove(),this.setState({imgError:!0}))}},{key:\"render\",value:function(){var e=function(e){return e.get(\"symbol\")}(this.props.asset);return r.a.createElement(\"img\",{ref:e.toLowerCase(),className:\"column-hide-small\",onError:this._onError.bind(this,e),style:{maxWidth:this.props.maxWidth,marginRight:5},src:\"asset-symbols/\"+e.toLowerCase()+\".png\"})}}]),t}();b.propTypes={replaceNoneToBts:i.a.bool,maxWidth:i.a.number},b.defaultProps={replaceNoneToBts:!0,maxWidth:20},b=Object(o.a)(b);var h=function(e){function t(){return u(this,t),m(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return p(t,r.a.Component),l(t,[{key:\"render\",value:function(){return r.a.createElement(b,c({},this.props,{asset:this.props.name}))}}]),t}();t.a=h},2067:function(e,t,n){\"use strict\";n.r(t);var a=n(0),r=n.n(a),o=n(305),s=n(13),i={db:new Proxy(s.Apis,{get:function(e,t){return function(){return e.instance().db_api().exec(t,[].concat(Array.prototype.slice.call(arguments)))}}}),history:new Proxy(s.Apis,{get:function(e,t){return function(){return e.instance().history_api().exec(t,[].concat(Array.prototype.slice.call(arguments)))}}}),network:new Proxy(s.Apis,{get:function(e,t){return function(){return e.instance().network_api().exec(t,[].concat(Array.prototype.slice.call(arguments)))}}}),crypto:new Proxy(s.Apis,{get:function(e,t){return function(){return e.instance().crypto_api().exec(t,[].concat(Array.prototype.slice.call(arguments)))}}}),orders:new Proxy(s.Apis,{get:function(e,t){return function(){return e.instance().orders_api().exec(t,[].concat(Array.prototype.slice.call(arguments)))}}})},c=(n(1748),function(){function e(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,\"value\"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}return function(t,n,a){return n&&e(t.prototype,n),a&&e(t,a),t}}());function l(e){return function(){var t=e.apply(this,arguments);return new Promise(function(e,n){return function a(r,o){try{var s=t[r](o),i=s.value}catch(e){return void n(e)}if(!s.done)return Promise.resolve(i).then(function(e){a(\"next\",e)},function(e){a(\"throw\",e)});e(i)}(\"next\")})}}var u=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError(\"Cannot call a class as a function\")}(this,e),Object.assign(this,t)}return c(e,null,[{key:\"get\",value:function(e,t){return this[t]?this[t]:this.getAsset(t)}},{key:\"getAsset\",value:function(){var e=l(regeneratorRuntime.mark(function e(t){var n,a;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.toUpperCase(),this.map=this.map||{},!this.map[n]){e.next=4;break}return e.abrupt(\"return\",this.map[n]);case 4:return e.next=6,i.db.list_assets(n,1);case 6:if((a=e.sent[0])&&a.symbol===n){e.next=9;break}throw new Error(\"Not found asset \"+n+\"! Blockchain return \"+(a?a.symbol:a));case 9:return this.map[n]=new this(a),e.abrupt(\"return\",this.map[n]);case 11:case\"end\":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:\"id\",value:function(){var e=l(regeneratorRuntime.mark(function e(t){var n,a=this;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.map=this.map||{},!(n=Object.keys(this.map).find(function(e){return a.map[e].id==t}))){e.next=4;break}return e.abrupt(\"return\",this.map[n]);case 4:return e.next=6,i.db.get_assets([t]);case 6:if(n=e.sent[0]){e.next=9;break}throw new Error(\"Not found asset by id \"+t+\"!\");case 9:return this.map[n.symbol]=new this(n),e.abrupt(\"return\",this.map[n.symbol]);case 11:case\"end\":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:\"fromParam\",value:function(){var e=l(regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.t0=t.amount,e.next=3,this.id(t.asset_id);case 3:return e.t1=e.sent,e.abrupt(\"return\",{amount:e.t0,asset:e.t1});case 5:case\"end\":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:\"update\",value:function(){var e=l(regeneratorRuntime.mark(function e(){var t=this;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return this.map=this.map||{},e.next=3,i.db.get_assets(Object.keys(this.map).map(function(e){return t.map[e].id}));case 3:e.sent.forEach(function(e){return Object.assign(t.map[e.symbol],e)});case 5:case\"end\":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()}]),c(e,[{key:\"toParam\",value:function(){return{amount:arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,asset_id:this.id}}},{key:\"fee\",value:function(){return this.options.market_fee_percent/100/100}},{key:\"update\",value:function(){var e=l(regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.t0=Object,e.t1=this,e.next=4,i.db.get_assets([this.id]);case 4:e.t2=e.sent[0],e.t0.assign.call(e.t0,e.t1,e.t2);case 6:case\"end\":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()}]),e}(),m=new Proxy({},u),p=n(1757),b=n(1938),h=n.n(b),d=n(37),f=n(14),v=n.n(f),g=function(){function e(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,\"value\"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}return function(t,n,a){return n&&e(t.prototype,n),a&&e(t,a),t}}();function y(e){return function(){var t=e.apply(this,arguments);return new Promise(function(e,n){return function a(r,o){try{var s=t[r](o),i=s.value}catch(e){return void n(e)}if(!s.done)return Promise.resolve(i).then(function(e){a(\"next\",e)},function(e){a(\"throw\",e)});e(i)}(\"next\")})}}function E(e,t){if(!(e instanceof t))throw new TypeError(\"Cannot call a class as a function\")}function k(e,t){if(!e)throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\");return!t||\"object\"!=typeof t&&\"function\"!=typeof t?e:t}function x(e,t){if(\"function\"!=typeof t&&null!==t)throw new TypeError(\"Super expression must either be null or a function, not \"+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var w=function(e){function t(){var e,n,a,r=this;E(this,t);for(var o=arguments.length,s=Array(o),i=0;i<o;i++)s[i]=arguments[i];return n=a=k(this,(e=t.__proto__||Object.getPrototypeOf(t)).call.apply(e,[this].concat(s))),a.state={name:null},a.hidePrefix=function(e){var t=e.split(\".\");return Object(d.c)().includes(t[0]+\".\")&&t.shift(),t.join(\".\")},a.setAssetName=function(){var e=y(regeneratorRuntime.mark(function e(t){var n;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,m[t];case 2:n=e.sent,a.setState({name:n.bitasset_data_id?\"bit\"+t:t});case 4:case\"end\":return e.stop()}},e,r)}));return function(t){return e.apply(this,arguments)}}(),k(a,n)}return x(t,r.a.Component),g(t,[{key:\"componentWillMount\",value:function(){this.setAssetName(this.props.name)}},{key:\"componentWillReceiveProps\",value:function(e){e.name!==this.props.name&&this.setAssetName(e.name)}},{key:\"render\",value:function(){return r.a.createElement(\"div\",null,r.a.createElement(p.a,{replaceNoneToBts:!1,maxWidth:30,name:this.props.name}),this.hidePrefix(this.state.name||this.props.name))}}]),t}(),_=Object(d.k)().map(function(e){return{value:e,label:r.a.createElement(w,{name:e})}}),A=function(e){function t(){var e,n,a,o=this;E(this,t);for(var s=arguments.length,c=Array(s),l=0;l<s;l++)c[l]=arguments[l];return n=a=k(this,(e=t.__proto__||Object.getPrototypeOf(t)).call.apply(e,[this].concat(c))),a.onChange=function(e){console.log(\"onChange\",e),a.props.onChange({target:{name:a.props.name,value:e?e.value:\"\"}})},a.promiseOptions=function(){var e=y(regeneratorRuntime.mark(function e(t){var n;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(t=t.toUpperCase(),0!==_.filter(function(e){return e.value==t}).length||!t){e.next=7;break}return e.next=5,i.db.list_assets(t,1);case 5:(n=e.sent[0])&&!_.find(function(e){return e.value==n.symbol})&&_.push({value:n.symbol,label:r.a.createElement(w,{name:n.symbol})});case 7:return e.abrupt(\"return\",{options:_});case 8:case\"end\":return e.stop()}},e,o)}));return function(t){return e.apply(this,arguments)}}(),k(a,n)}return x(t,r.a.Component),g(t,[{key:\"componentDidMount\",value:function(){this.promiseOptions=Object(o.a)(this.promiseOptions,200)}},{key:\"render\",value:function(){var e=this,t=_.find(function(t){return t.value===e.props.value});return r.a.createElement(\"div\",{style:{marginBottom:30}},r.a.createElement(h.a,{value:t,onChange:this.onChange,loadOptions:this.promiseOptions,searchPromptText:v.a.translate(\"bots.asset_selector.wait\"),placeholder:v.a.translate(\"bots.asset_selector.placeholder\")}))}}]),t}(),C=n(3),q=n.n(C),O=function(){function e(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,\"value\"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}return function(t,n,a){return n&&e(t.prototype,n),a&&e(t,a),t}}();function S(e,t){if(!e)throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\");return!t||\"object\"!=typeof t&&\"function\"!=typeof t?e:t}var N=function(e){function t(){var e,n,a,r=this;!function(e,t){if(!(e instanceof t))throw new TypeError(\"Cannot call a class as a function\")}(this,t);for(var o=arguments.length,s=Array(o),c=0;c<o;c++)s[c]=arguments[c];return n=a=S(this,(e=t.__proto__||Object.getPrototypeOf(t)).call.apply(e,[this].concat(s))),a.state={name:\"\",baseAsset:\"USD\",quoteAsset:\"BTC\",baseAmount:10,quoteAmount:.01,baseSpread:10,quoteSpread:10,baseBalance:100,quoteBalance:.1,percentBaseAmount:!1,percentQuoteAmount:!1,validate:[\"name\"]},a.assetValidate=function(){var e=function(e){return function(){var t=e.apply(this,arguments);return new Promise(function(e,n){return function a(r,o){try{var s=t[r](o),i=s.value}catch(e){return void n(e)}if(!s.done)return Promise.resolve(i).then(function(e){a(\"next\",e)},function(e){a(\"throw\",e)});e(i)}(\"next\")})}}(regeneratorRuntime.mark(function e(t){var n,o,s;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return n=a.state[t],e.next=3,i.db.list_assets(n,1);case 3:o=e.sent[0],s=a.state.validate,n!==o.symbol?s.push(t):s=s.filter(function(e){return e!==t}),a.setState({validate:s}),a.props.enableCreate(0==a.state.validate.length);case 8:case\"end\":return e.stop()}},e,r)}));return function(t){return e.apply(this,arguments)}}(),a.handleChange=function(e){var t=e.target.name,n=\"checkbox\"===e.target.type?e.target.checked:e.target.value;console.log(t,n),[\"baseAsset\",\"quoteAsset\"].includes(t)&&(n=n.toUpperCase()),a.setState(function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}({},t,n),function(){return a.validate(t,n)})},a.validate=function(e,t){var n=a.state.validate;switch(e){case\"name\":!/^\\w+$/.test(t)||pe.hasBot(a.props.account,a.props.name,t)?(n.push(e),a.setState({validate:n})):a.setState({validate:n.filter(function(t){return t!==e})});break;case\"baseAsset\":case\"quoteAsset\":0!==t.length?a.assetValidate(e):(n.push(e),a.setState({validate:n}));break;case\"baseBalance\":case\"quoteBalance\":\"-\"!==t&&isNaN(+t)?(n.push(e),a.setState({validate:n})):a.setState({validate:n.filter(function(t){return t!==e})});break;case\"baseAmount\":case\"quoteAmount\":case\"baseSpread\":case\"quoteSpread\":\"\"===t||isNaN(+t)?(n.push(e),a.setState({validate:n})):a.setState({validate:n.filter(function(t){return t!==e})});break;case\"defaultPrice\":isNaN(+t)?(n.push(e),a.setState({validate:n})):a.setState({validate:n.filter(function(t){return t!==e})})}console.log(a.state.validate),a.props.enableCreate(0==a.state.validate.length)},S(a,n)}return function(e,t){if(\"function\"!=typeof t&&null!==t)throw new TypeError(\"Super expression must either be null or a function, not \"+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,r.a.Component),O(t,[{key:\"componentDidMount\",value:function(){this.assetValidate=Object(o.a)(this.assetValidate,200)}},{key:\"render\",value:function(){return r.a.createElement(\"div\",null,r.a.createElement(\"div\",{className:\"content-block\"},r.a.createElement(\"label\",{className:\"left-label\"},r.a.createElement(q.a,{content:\"bots.common.name\"})),r.a.createElement(\"input\",{name:\"name\",id:\"name\",type:\"text\",ref:\"input\",value:this.state.name,onChange:this.handleChange,autoComplete:\"name\",style:{border:this.state.validate.includes(\"name\")?\"1px solid red\":\"none\"}})),r.a.createElement(\"div\",{className:\"grid-block horizontal\"},r.a.createElement(\"div\",{className:\"content-block\",style:{marginLeft:50}},r.a.createElement(\"label\",{style:{textAlign:\"center\"}},r.a.createElement(q.a,{content:\"bots.common.base\"})),r.a.createElement(\"label\",{className:\"left-label\"},r.a.createElement(q.a,{content:\"bots.common.asset\"})),r.a.createElement(A,{name:\"baseAsset\",value:this.state.baseAsset,onChange:this.handleChange}),r.a.createElement(\"label\",{className:\"left-label\"},r.a.createElement(q.a,{content:\"bots.common.balance\"})),r.a.createElement(\"input\",{name:\"baseBalance\",id:\"baseBalance\",type:\"text\",ref:\"input\",value:this.state.baseBalance,onChange:this.handleChange,autoComplete:\"baseBalance\",style:{marginBottom:30,border:this.state.validate.includes(\"baseBalance\")?\"1px solid red\":\"none\"}}),r.a.createElement(\"label\",{className:\"left-label\"},r.a.createElement(q.a,{content:\"bots.common.amount\"})),r.a.createElement(\"div\",{onChange:this.handleChange},r.a.createElement(\"input\",{type:\"radio\",value:!0,name:\"percentBaseAmount\"}),\" \",r.a.createElement(q.a,{content:\"bots.spread_trande.balance_percent\"}),r.a.createElement(\"br\",null),r.a.createElement(\"input\",{type:\"radio\",value:!1,name:\"percentBaseAmount\",defaultChecked:!0}),\" \",r.a.createElement(q.a,{content:\"bots.spread_trande.balance_value\"})),r.a.createElement(\"input\",{name:\"baseAmount\",id:\"baseAmount\",type:\"text\",ref:\"input\",value:this.state.baseAmount,onChange:this.handleChange,autoComplete:\"baseAmount\",style:{marginBottom:30,border:this.state.validate.includes(\"baseAmount\")?\"1px solid red\":\"none\"}}),r.a.createElement(\"label\",{className:\"left-label\"},r.a.createElement(q.a,{content:\"bots.spread_trande.spread\"})),r.a.createElement(\"input\",{name:\"baseSpread\",id:\"baseSpread\",type:\"text\",ref:\"input\",value:this.state.baseSpread,onChange:this.handleChange,autoComplete:\"baseSpread\",style:{marginBottom:30,border:this.state.validate.includes(\"baseSpread\")?\"1px solid red\":\"none\"}})),r.a.createElement(\"div\",{className:\"content-block\",style:{marginLeft:50}},r.a.createElement(\"label\",{style:{textAlign:\"center\"}},r.a.createElement(q.a,{content:\"bots.common.quote\"})),r.a.createElement(\"label\",{className:\"left-label\"},r.a.createElement(q.a,{content:\"bots.common.asset\"})),r.a.createElement(A,{name:\"quoteAsset\",value:this.state.quoteAsset,onChange:this.handleChange}),r.a.createElement(\"label\",{className:\"left-label\"},r.a.createElement(q.a,{content:\"bots.common.balance\"})),r.a.createElement(\"input\",{name:\"quoteBalance\",id:\"quoteBalance\",type:\"text\",ref:\"input\",value:this.state.quoteBalance,onChange:this.handleChange,autoComplete:\"quoteBalance\",style:{marginBottom:30,border:this.state.validate.includes(\"quoteBalance\")?\"1px solid red\":\"none\"}}),r.a.createElement(\"label\",{className:\"left-label\"},r.a.createElement(q.a,{content:\"bots.common.amount\"})),r.a.createElement(\"div\",{onChange:this.handleChange},r.a.createElement(\"input\",{type:\"radio\",value:!0,name:\"percentQuoteAmount\"}),\" \",r.a.createElement(q.a,{content:\"bots.spread_trande.balance_percent\"}),r.a.createElement(\"br\",null),r.a.createElement(\"input\",{type:\"radio\",value:!1,name:\"percentQuoteAmount\",defaultChecked:!0}),\" \",r.a.createElement(q.a,{content:\"bots.spread_trande.balance_value\"})),r.a.createElement(\"input\",{name:\"quoteAmount\",id:\"quoteAmount\",type:\"text\",ref:\"input\",value:this.state.quoteAmount,onChange:this.handleChange,autoComplete:\"quoteAmount\",style:{marginBottom:30,border:this.state.validate.includes(\"quoteAmount\")?\"1px solid red\":\"none\"}}),r.a.createElement(\"label\",{className:\"left-label\"},r.a.createElement(q.a,{content:\"bots.spread_trande.spread\"})),r.a.createElement(\"input\",{name:\"quoteSpread\",id:\"quoteSpread\",type:\"text\",ref:\"input\",value:this.state.quoteSpread,onChange:this.handleChange,autoComplete:\"quoteSpread\",style:{marginBottom:30,border:this.state.validate.includes(\"quoteSpread\")?\"1px solid red\":\"none\"}}))),r.a.createElement(\"div\",{className:\"content-block\"},r.a.createElement(\"label\",{className:\"left-label\"},r.a.createElement(q.a,{content:\"bots.spread_trande.default_price\"})),r.a.createElement(\"input\",{name:\"defaultPrice\",id:\"defaultPrice\",type:\"text\",ref:\"input\",value:this.state.defaultPrice,onChange:this.handleChange,autoComplete:\"defaultPrice\",style:{border:this.state.validate.includes(\"defaultPrice\")?\"1px solid red\":\"none\"}})),r.a.createElement(\"div\",{className:\"content-block\"},r.a.createElement(\"label\",null,r.a.createElement(\"input\",{type:\"checkbox\",name:\"fromMarket\",onChange:this.handleChange,checked:this.state.fromMarket}),r.a.createElement(q.a,{content:\"bots.spread_trande.get_price_from_market\"}))))}}]),t}(),j=n(1805),P=function(){function e(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,\"value\"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}return function(t,n,a){return n&&e(t.prototype,n),a&&e(t,a),t}}();function B(e,t){if(!e)throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\");return!t||\"object\"!=typeof t&&\"function\"!=typeof t?e:t}var R=function(e){function t(){var e,n,a;!function(e,t){if(!(e instanceof t))throw new TypeError(\"Cannot call a class as a function\")}(this,t);for(var r=arguments.length,o=Array(r),s=0;s<r;s++)o[s]=arguments[s];return n=a=B(this,(e=t.__proto__||Object.getPrototypeOf(t)).call.apply(e,[this].concat(o))),a.handleChange=function(e){var t=e.target.name,n=e.target.value,r=void 0,o=void 0;switch(t){case\"baseAmount\":(r=a.state.base).amount=n,a.setState({base:r});break;case\"percentBaseAmount\":(r=a.state.base).percent=\"true\"==n,a.setState({base:r});break;case\"baseBalance\":(r=a.state.base).balance=n,a.setState({base:r});break;case\"baseSpread\":(r=a.state.base).spread=n,a.setState({base:r});break;case\"quoteAmount\":(o=a.state.quote).amount=n,a.setState({quote:o});break;case\"percentQuoteAmount\":(o=a.state.quote).percent=\"true\"==n,a.setState({quote:o});break;case\"quoteBalance\":(o=a.state.quote).balance=n,a.setState({quote:o});break;case\"quoteSpread\":(o=a.state.quote).spread=n,a.setState({quote:o});break;case\"defaultPrice\":a.setState({defaultPrice:n});break;case\"fromMarket\":a.setState({fromMarket:e.target.checked})}},a.handleUpdateBot=function(){var e=a.props.bot.storage.read();a.state.base.order=e.base.order,a.state.quote.order=e.quote.order,a.props.bot.storage.write(a.state)},B(a,n)}return function(e,t){if(\"function\"!=typeof t&&null!==t)throw new TypeError(\"Super expression must either be null or a function, not \"+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,r.a.Component),P(t,[{key:\"componentWillMount\",value:function(){this.setState(Object.assign({validate:[]},this.props.bot.storage.read()))}},{key:\"render\",value:function(){return r.a.createElement(\"div\",null,r.a.createElement(\"div\",{className:\"grid-block horizontal\"},r.a.createElement(\"div\",{className:\"content-block\",style:{marginLeft:50,marginTop:30}},r.a.createElement(\"label\",{style:{textAlign:\"center\"}},r.a.createElement(q.a,{content:\"bots.common.base\"})),r.a.createElement(\"label\",{className:\"left-label\"},r.a.createElement(q.a,{content:\"bots.common.asset\"})),r.a.createElement(j.a,{style:{marginBottom:30},name:\"baseAsset\",value:{value:this.state.base.asset,label:r.a.createElement(w,{name:this.state.base.asset})},clearable:!1,searchable:!1,disabled:!0}),r.a.createElement(\"label\",{className:\"left-label\"},r.a.createElement(q.a,{content:\"bots.common.balance\"})),r.a.createElement(\"input\",{name:\"baseBalance\",type:\"text\",ref:\"input\",value:this.state.base.balance,onChange:this.handleChange,disabled:this.props.bot.run,style:{marginBottom:30,border:this.state.validate.includes(\"baseBalance\")?\"1px solid red\":\"none\"}}),r.a.createElement(\"label\",{className:\"left-label\"},r.a.createElement(q.a,{content:\"bots.common.amount\"})),r.a.createElement(\"div\",null,r.a.createElement(\"input\",{type:\"radio\",value:!0,name:\"percentBaseAmount\",checked:this.state.base.percent,onChange:this.handleChange}),\" \",r.a.createElement(q.a,{content:\"bots.spread_trande.balance_percent\"}),r.a.createElement(\"br\",null),r.a.createElement(\"input\",{type:\"radio\",value:!1,name:\"percentBaseAmount\",checked:!this.state.base.percent,onChange:this.handleChange}),\" \",r.a.createElement(q.a,{content:\"bots.spread_trande.balance_value\"})),r.a.createElement(\"input\",{name:\"baseAmount\",type:\"text\",ref:\"input\",value:this.state.base.amount,onChange:this.handleChange,disabled:this.props.bot.run,style:{marginBottom:30,border:this.state.validate.includes(\"baseAmount\")?\"1px solid red\":\"none\"}}),r.a.createElement(\"label\",{className:\"left-label\"},r.a.createElement(q.a,{content:\"bots.spread_trande.spread\"})),r.a.createElement(\"input\",{name:\"baseSpread\",type:\"text\",ref:\"input\",value:this.state.base.spread,onChange:this.handleChange,disabled:this.props.bot.run,style:{marginBottom:30,border:this.state.validate.includes(\"baseSpread\")?\"1px solid red\":\"none\"}})),r.a.createElement(\"div\",{className:\"content-block\",style:{marginLeft:50,marginTop:30}},r.a.createElement(\"label\",{style:{textAlign:\"center\"}},r.a.createElement(q.a,{content:\"bots.common.quote\"})),r.a.createElement(\"label\",{className:\"left-label\"},r.a.createElement(q.a,{content:\"bots.common.asset\"})),r.a.createElement(j.a,{style:{marginBottom:30},name:\"quoteAsset\",value:{value:this.state.quote.asset,label:r.a.createElement(w,{name:this.state.quote.asset})},clearable:!1,searchable:!1,disabled:!0}),r.a.createElement(\"label\",{className:\"left-label\"},r.a.createElement(q.a,{content:\"bots.common.balance\"})),r.a.createElement(\"input\",{name:\"quoteBalance\",type:\"text\",ref:\"input\",value:this.state.quote.balance,onChange:this.handleChange,disabled:this.props.bot.run,style:{marginBottom:30,border:this.state.validate.includes(\"quoteBalance\")?\"1px solid red\":\"none\"}}),r.a.createElement(\"label\",{className:\"left-label\"},r.a.createElement(q.a,{content:\"bots.common.amount\"})),r.a.createElement(\"div\",null,r.a.createElement(\"input\",{type:\"radio\",value:!0,name:\"percentQuoteAmount\",checked:this.state.quote.percent,onChange:this.handleChange}),\" \",r.a.createElement(q.a,{content:\"bots.spread_trande.balance_percent\"}),r.a.createElement(\"br\",null),r.a.createElement(\"input\",{type:\"radio\",value:!1,name:\"percentQuoteAmount\",checked:!this.state.quote.percent,onChange:this.handleChange}),\" \",r.a.createElement(q.a,{content:\"bots.spread_trande.balance_value\"})),r.a.createElement(\"input\",{name:\"quoteAmount\",type:\"text\",ref:\"input\",value:this.state.quote.amount,onChange:this.handleChange,disabled:this.props.bot.run,style:{marginBottom:30,border:this.state.validate.includes(\"quoteAmount\")?\"1px solid red\":\"none\"}}),r.a.createElement(\"label\",{className:\"left-label\"},r.a.createElement(q.a,{content:\"bots.spread_trande.spread\"})),r.a.createElement(\"input\",{name:\"quoteSpread\",type:\"text\",ref:\"input\",value:this.state.quote.spread,onChange:this.handleChange,disabled:this.props.bot.run,style:{marginBottom:30,border:this.state.validate.includes(\"quoteSpread\")?\"1px solid red\":\"none\"}}))),r.a.createElement(\"div\",{className:\"content-block\"},r.a.createElement(\"label\",{className:\"left-label\"},r.a.createElement(q.a,{content:\"bots.spread_trande.default_price\"})),r.a.createElement(\"input\",{name:\"defaultPrice\",type:\"text\",ref:\"input\",value:this.state.defaultPrice,onChange:this.handleChange,disabled:this.props.bot.run,style:{border:this.state.validate.includes(\"defaultPrice\")?\"1px solid red\":\"none\"}})),r.a.createElement(\"div\",{className:\"content-block\"},r.a.createElement(\"label\",null,r.a.createElement(\"input\",{type:\"checkbox\",name:\"fromMarket\",onChange:this.handleChange,checked:this.state.fromMarket,disabled:this.props.bot.run}),r.a.createElement(q.a,{content:\"bots.spread_trande.get_price_from_market\"}))),r.a.createElement(\"button\",{className:\"button\",onClick:this.handleUpdateBot,disabled:this.props.bot.run,style:{marginLeft:50,marginBottom:30}},r.a.createElement(q.a,{content:\"bots.common.update\"})))}}]),t}(),T=n(10),M=n(178),L=n(19),U=n(60),F=function(){return function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return function(e,t){var n=[],a=!0,r=!1,o=void 0;try{for(var s,i=e[Symbol.iterator]();!(a=(s=i.next()).done)&&(n.push(s.value),!t||n.length!==t);a=!0);}catch(e){r=!0,o=e}finally{try{!a&&i.return&&i.return()}finally{if(r)throw o}}return n}(e,t);throw new TypeError(\"Invalid attempt to destructure non-iterable instance\")}}(),D=function(){function e(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,\"value\"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}return function(t,n,a){return n&&e(t.prototype,n),a&&e(t,a),t}}();function W(e){return function(){var t=e.apply(this,arguments);return new Promise(function(e,n){return function a(r,o){try{var s=t[r](o),i=s.value}catch(e){return void n(e)}if(!s.done)return Promise.resolve(i).then(function(e){a(\"next\",e)},function(e){a(\"throw\",e)});e(i)}(\"next\")})}}var V=function(){function e(t){var n=this,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:\"BTS\";!function(e,t){if(!(e instanceof t))throw new TypeError(\"Cannot call a class as a function\")}(this,e),this.promise=Promise.all([i.db.get_account_by_name(t),m[a]]).then(function(e){var t=F(e,2),a=t[0],r=t[1];n.acc=a,n.feeAsset=r})}return D(e,[{key:\"cancelOrder\",value:function(){var e=W(regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.promise;case 2:return e.abrupt(\"return\",this.sendTransaction(\"limit_order_cancel\",{fee:this.feeAsset.toParam(),fee_paying_account:this.acc.id,order:t,extensions:[]}));case 3:case\"end\":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:\"buy\",value:function(){var e=W(regeneratorRuntime.mark(function e(t,n,a,r){var o,s,c,l,u,p=arguments.length>4&&void 0!==arguments[4]&&arguments[4],b=arguments.length>5&&void 0!==arguments[5]?arguments[5]:\"2020-02-02T02:02:02\";return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.promise;case 2:return e.next=4,m[t];case 4:return o=e.sent,e.next=7,m[n];case 7:if(s=e.sent,c=Math.floor(a*Math.pow(10,o.precision)),l=Math.floor(Object(M.a)(a).times(r*Math.pow(10,s.precision)).toString()),0!=c&&0!=l){e.next=12;break}throw new Error(\"Amount equal 0!\");case 12:return e.next=14,this.sendTransaction(\"limit_order_create\",{fee:this.feeAsset.toParam(),seller:this.acc.id,amount_to_sell:s.toParam(l),min_to_receive:o.toParam(c),expiration:b,fill_or_kill:p,extensions:[]});case 14:return u=e.sent,e.next=17,i.db.get_objects([u[0].trx.operation_results[0][1]]);case 17:return e.abrupt(\"return\",e.sent[0]);case 18:case\"end\":return e.stop()}},e,this)}));return function(t,n,a,r){return e.apply(this,arguments)}}()},{key:\"sell\",value:function(){var e=W(regeneratorRuntime.mark(function e(t,n,a,r){var o,s,c,l,u,p=arguments.length>4&&void 0!==arguments[4]&&arguments[4],b=arguments.length>5&&void 0!==arguments[5]?arguments[5]:\"2020-02-02T02:02:02\";return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.promise;case 2:return e.next=4,m[t];case 4:return o=e.sent,e.next=7,m[n];case 7:if(s=e.sent,c=Math.floor(a*Math.pow(10,o.precision)),0!=(l=Math.floor(Object(M.a)(a).times(r*Math.pow(10,s.precision)).toString()))&&0!=c){e.next=12;break}throw new Error(\"Amount equal 0!\");case 12:return e.next=14,this.sendTransaction(\"limit_order_create\",{fee:this.feeAsset.toParam(),seller:this.acc.id,amount_to_sell:o.toParam(c),min_to_receive:s.toParam(l),expiration:b,fill_or_kill:p,extensions:[]});case 14:return u=e.sent,e.next=17,i.db.get_objects([u[0].trx.operation_results[0][1]]);case 17:return e.abrupt(\"return\",e.sent[0]);case 18:case\"end\":return e.stop()}},e,this)}));return function(t,n,a,r){return e.apply(this,arguments)}}()},{key:\"balances\",value:function(){var e=W(regeneratorRuntime.mark(function e(){var t=arguments;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.promise;case 2:return e.abrupt(\"return\",i.db.get_account_balances(this.acc.id,[].concat(Array.prototype.slice.call(t))));case 3:case\"end\":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:\"sendTransaction\",value:function(){var e=W(regeneratorRuntime.mark(function e(t,n){var a,r;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return(a=new T.TransactionBuilder).add_type_operation(t,n),e.next=4,a.set_required_fees();case 4:return e.next=6,U.a.unlock();case 6:return r=L.a.getPrivateKey(this.acc.active.key_auths[0][0]),a.add_signer(r,r.toPublicKey().toPublicKeyString()),e.abrupt(\"return\",a.broadcast());case 9:case\"end\":return e.stop()}},e,this)}));return function(t,n){return e.apply(this,arguments)}}()}]),e}(),Q=n(23),I=function(){return function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return function(e,t){var n=[],a=!0,r=!1,o=void 0;try{for(var s,i=e[Symbol.iterator]();!(a=(s=i.next()).done)&&(n.push(s.value),!t||n.length!==t);a=!0);}catch(e){r=!0,o=e}finally{try{!a&&i.return&&i.return()}finally{if(r)throw o}}return n}(e,t);throw new TypeError(\"Invalid attempt to destructure non-iterable instance\")}}(),$=function(){function e(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,\"value\"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}return function(t,n,a){return n&&e(t.prototype,n),a&&e(t,a),t}}();function z(e){return function(){var t=e.apply(this,arguments);return new Promise(function(e,n){return function a(r,o){try{var s=t[r](o),i=s.value}catch(e){return void n(e)}if(!s.done)return Promise.resolve(i).then(function(e){a(\"next\",e)},function(e){a(\"throw\",e)});e(i)}(\"next\")})}}var K=function(){function e(t,n,a){var r=this;!function(e,t){if(!(e instanceof t))throw new TypeError(\"Cannot call a class as a function\")}(this,e),this.state=R,this.queue=function(){r.queueEvents=r.queueEvents.then(r.checkOrders).catch(r.logger.error.bind(r.logger))},this.checkOrders=z(regeneratorRuntime.mark(function e(){var t,n,a,o,s,c,l,u,m,p,b,h,d,f,v,g,y,E,k,x;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return t=r.storage.read(),e.next=3,i.db.get_ticker(r.base.symbol,r.quote.symbol);case 3:if(n=e.sent,r.defaultPrice=t.defaultPrice,!t.fromMarket){e.next=9;break}e.t0=Object(M.a)(n.latest),e.next=12;break;case 9:return e.next=11,r.getFeed();case 11:e.t0=e.sent;case 12:if(a=e.t0,o=a.times(1-t.base.spread/100).toNumber(),s=a.times(1+t.quote.spread/100).toNumber(),0!=(a=a.toNumber())){e.next=18;break}return e.abrupt(\"return\");case 18:if(!t.base.order.id){e.next=24;break}return e.next=21,i.db.get_objects([t.base.order.id]);case 21:e.t1=e.sent[0],e.next=25;break;case 24:e.t1=t.base.order.id;case 25:if(c=e.t1,!t.quote.order.id){e.next=32;break}return e.next=29,i.db.get_objects([t.quote.order.id]);case 29:e.t2=e.sent[0],e.next=33;break;case 32:e.t2=t.quote.order.id;case 33:return l=e.t2,e.next=36,r.account.balances(r.base.id,r.quote.id);case 36:if(e.t3=function(e,t){return r.base.id===t.asset_id?e.base=Object(M.a)(t.amount).div(Math.pow(10,r.base.precision)).toNumber():e.quote=Object(M.a)(t.amount).div(Math.pow(10,r.quote.precision)).toNumber(),e},e.t4={},u=e.sent.reduce(e.t3,e.t4),m=\"-\"===t.base.balance?0:\"\"===t.base.balance?u.base:Math.min(u.base,t.base.balance),p=\"-\"===t.quote.balance?0:\"\"===t.quote.balance?u.quote:Math.min(u.quote,t.quote.balance),b=t.base.percent?Object(M.a)(m).times(t.base.amount).div(100).toNumber():t.base.amount,h=t.quote.percent?Object(M.a)(p).times(t.quote.amount).div(100).toNumber():t.quote.amount,console.log(\"prices\",o,a,s),console.log(\"orders\",c,l),!c){e.next=69;break}if(console.log(\"check buyOrder: move=\"+(Math.abs(o-t.base.order.price)>Math.abs(a-o)/2)+\", fill=\"+(n.lowest_ask<=o)),!(Math.abs(o-t.base.order.price)>Math.abs(a-o)/2&&n.lowest_ask>o)){e.next=67;break}return r.logger.info(\"move buy order: \"+o+\" \"+r.quote.symbol+\"/\"+r.base.symbol),e.next=51,r.account.cancelOrder(t.base.order.id);case 51:return d=Object(M.a)(c.for_sale).div(Math.pow(10,r.base.precision)).toNumber(),![\"\",\"-\"].includes(t.base.balance)&&(t.base.balance=Number(t.base.balance)+d),t.base.order.amount>d&&![\"\",\"-\"].incudes(t.quote.balance)&&(t.quote.balance=Object(M.a)(t.base.order.amount-d).div(t.base.order.price).plus(t.quote.balance).toNumber()),f=Math.min(m,b),e.prev=55,e.next=58,r.account.sell(r.base.symbol,r.quote.symbol,f,Object(M.a)(1).div(o).toNumber());case 58:v=e.sent,t.base.order={id:v?v.id:\"1.7.0\",price:o,amount:f},![\"\",\"-\"].includes(t.base.balance)&&(t.base.balance-=f),e.next=67;break;case 63:e.prev=63,e.t5=e.catch(55),r.logger.error(e.t5),t.base.order.id=void 0;case 67:e.next=84;break;case 69:if(/^1.7.\\d*$/.test(t.base.order.id)&&(![\"\",\"-\"].includes(t.quote.balance)&&(t.quote.balance=Object(M.a)(t.base.order.amount).div(t.base.order.price).plus(t.quote.balance).toNumber()),t.base.order.id=void 0),console.log(\"create buyOrder: balance=\"+(m>=b)+\", fill=\"+(n.lowest_ask<=o)),!(m>=b&&n.lowest_ask>o)){e.next=84;break}return r.logger.info(\"buy: \"+o+\" \"+r.quote.symbol+\"/\"+r.base.symbol),e.prev=73,e.next=76,r.account.sell(r.base.symbol,r.quote.symbol,b,Object(M.a)(1).div(o).toNumber());case 76:g=e.sent,t.base.order={id:g?g.id:\"1.7.0\",price:o,amount:b},![\"\",\"-\"].includes(t.base.balance)&&(t.base.balance-=b),e.next=84;break;case 81:e.prev=81,e.t6=e.catch(73),r.logger.error(e.t6);case 84:if(!l){e.next=108;break}if(console.log(\"check sellOrder: move=\"+(Math.abs(s-t.quote.order.price)>Math.abs(a-s)/2)+\", fill=\"+(n.highest_bid>=s)),!(Math.abs(s-t.quote.order.price)>Math.abs(a-s)/2&&n.highest_bid<s)){e.next=106;break}return r.logger.info(\"move sell order: \"+s+\" \"+r.quote.symbol+\"/\"+r.base.symbol),e.next=90,r.account.cancelOrder(t.quote.order.id);case 90:return y=Object(M.a)(l.for_sale).div(Math.pow(10,r.quote.precision)).toNumber(),![\"\",\"-\"].includes(t.quote.balance)&&(t.quote.balance=Number(t.quote.balance)+y),t.quote.order.amount>y&&![\"\",\"-\"].includes(t.base.balance)&&(t.base.balance=Object(M.a)(t.quote.order.amount-y).times(t.quote.order.price).plus(t.base.balance).toNumber()),E=Math.min(p,h),e.prev=94,e.next=97,r.account.sell(r.quote.symbol,r.base.symbol,E,s);case 97:k=e.sent,t.quote.order={id:k?k.id:\"1.7.0\",price:s,amount:E},![\"\",\"-\"].includes(t.quote.balance)&&(t.quote.balance-=E),e.next=106;break;case 102:e.prev=102,e.t7=e.catch(94),r.logger.error(e.t7),t.quote.order.id=void 0;case 106:e.next=123;break;case 108:if(/^1.7.\\d*$/.test(t.quote.order.id)&&(![\"\",\"-\"].includes(t.base.balance)&&(t.base.balance=Object(M.a)(t.quote.order.amount).times(t.quote.order.price).plus(t.base.balance).toNumber()),t.quote.order.id=void 0),console.log(\"create sellOrder: balance=\"+(p>=h)+\", fill=\"+(n.highest_bid>=s)),!(p>=h&&n.highest_bid<s)){e.next=123;break}return r.logger.info(\"sell: \"+s+\" \"+r.quote.symbol+\"/\"+r.base.symbol),e.prev=112,e.next=115,r.account.sell(r.quote.symbol,r.base.symbol,h,s);case 115:x=e.sent,t.quote.order={id:x?x.id:\"1.7.0\",price:s,amount:h},![\"\",\"-\"].includes(t.quote.balance)&&(t.quote.balance-=h),e.next=123;break;case 120:e.prev=120,e.t8=e.catch(112),r.logger.error(e.t8);case 123:r.storage.write(t);case 124:case\"end\":return e.stop()}},e,r,[[55,63],[73,81],[94,102],[112,120]])})),this.account=new V(t),this.storage=n,a&&n.init({name:a.name,base:{asset:a.baseAsset,balance:a.baseBalance,spread:a.baseSpread,amount:a.baseAmount,percent:a.percentBaseAmount,order:{}},quote:{asset:a.quoteAsset,balance:a.quoteBalance,spread:a.quoteSpread,amount:a.quoteAmount,percent:a.percentQuoteAmount,order:{}},fromMarket:a.fromMarket,defaultPrice:a.defaultPrice}),this.name=n.read().name,this.logger=console,this.queueEvents=Promise.resolve(),this.run=!1}return $(e,[{key:\"start\",value:function(){var e=z(regeneratorRuntime.mark(function e(){var t;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.storage.read(),e.next=3,m[t.base.asset];case 3:return this.base=e.sent,e.next=6,m[t.quote.asset];case 6:return this.quote=e.sent,[this.base.issuer,this.quote.issuer].includes(\"1.2.0\")?[this.base.id,this.quote.id].includes(\"1.3.0\")?this.getFeed=this.getCoreFeed:this.base.issuer==this.quote.issuer?this.getFeed=this.getSmartFeed:this.getFeed=this.getUIAFeed:this.getFeed=this.getUIAFeed,e.next=10,U.a.unlock();case 10:Q.a.changeSetting({setting:\"walletLockTimeout\",value:0}),T.ChainStore.subscribe(this.queue),this.run=!0;case 13:case\"end\":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:\"stop\",value:function(){var e=z(regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return T.ChainStore.unsubscribe(this.queue),this.run=!1,e.next=4,this.queueEvents;case 4:case\"end\":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:\"delete\",value:function(){this.storage.delete()}},{key:\"getCoreFeed\",value:function(){var e=z(regeneratorRuntime.mark(function e(){var t,n,a,r,o;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(t=void 0,\"1.3.0\"!=this.base.id){e.next=7;break}return e.next=4,this.quote.update();case 4:t=this.quote.options.core_exchange_rate,e.next=10;break;case 7:return e.next=9,this.base.update();case 9:t=this.base.options.core_exchange_rate;case 10:return n=t.base.asset_id==this.base.id?[t.base,t.quote]:[t.quote,t.base],a=I(n,2),r=a[0],o=a[1],e.abrupt(\"return\",Object(M.a)(r.amount).div(Math.pow(10,this.base.precision)).div(Object(M.a)(o.amount).div(Math.pow(10,this.quote.precision))));case 12:case\"end\":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:\"getSmartFeed\",value:function(){var e=z(regeneratorRuntime.mark(function e(){var t,n,a,r,o,s,i,c;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,m.bts;case 2:return t=e.sent,e.next=5,this.base.update();case 5:return n=this.base.options.core_exchange_rate,a=\"1.3.0\"==n.base.asset_id?[n.base,n.quote]:[n.quote,n.base],r=I(a,2),o=r[0],s=r[1],i=Object(M.a)(o.amount).div(Math.pow(10,t.precision)).div(Object(M.a)(s.amount).div(Math.pow(10,this.base.precision))),e.next=10,this.quote.update();case 10:return\"1.3.0\"==(n=this.quote.options.core_exchange_rate).base.asset_id?(o=n.base,s=n.quote):(o=n.quote,s=n.base),c=Object(M.a)(o.amount).div(Math.pow(10,t.precision)).div(Object(M.a)(s.amount).div(Math.pow(10,this.quote.precision))),e.abrupt(\"return\",c.div(i));case 14:case\"end\":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:\"getUIAFeed\",value:function(){var e=z(regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.defaultPrice){e.next=4;break}e.t0=Object(M.a)(this.defaultPrice),e.next=7;break;case 4:return e.next=6,this.binancePrice(this.base.symbol,this.quote.symbol);case 6:e.t0=e.sent;case 7:return e.abrupt(\"return\",e.t0);case 8:case\"end\":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:\"binancePrice\",value:function(){var e=z(regeneratorRuntime.mark(function e(t,n){var a,r,o;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return a=(\"\"+n.split(\".\").slice(-1)[0]+t.split(\".\").slice(-1)[0]).toUpperCase().replace(\"USD\",\"USDT\"),console.log(\"get asset: \"+a),this.priceArray=this.priceArray||[],e.prev=3,e.next=6,fetch(\"https://api.binance.com/api/v1/trades?symbol=\"+a+\"&limit=1\");case 6:return r=e.sent,e.next=9,r.json();case 9:o=e.sent,this.priceArray.push(o[0].price),e.next=16;break;case 13:e.prev=13,e.t0=e.catch(3),this.logger.error(\"Error Binance request: \"+a+\", error: \"+e.t0);case 16:return this.priceArray.length>10&&this.priceArray.shift(),e.abrupt(\"return\",this.priceArray.length>0?this.priceArray.reduce(function(e,t){return e.plus(t)},Object(M.a)(0)).div(this.priceArray.length):Object(M.a)(0));case 18:case\"end\":return e.stop()}},e,this,[[3,13]])}));return function(t,n){return e.apply(this,arguments)}}()}]),e}();K.create=N;var J=K,G=function(){function e(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,\"value\"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}return function(t,n,a){return n&&e(t.prototype,n),a&&e(t,a),t}}();function H(e,t){if(!e)throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\");return!t||\"object\"!=typeof t&&\"function\"!=typeof t?e:t}var X=function(e){function t(){var e,n,a,r=this;!function(e,t){if(!(e instanceof t))throw new TypeError(\"Cannot call a class as a function\")}(this,t);for(var o=arguments.length,s=Array(o),c=0;c<o;c++)s[c]=arguments[c];return n=a=H(this,(e=t.__proto__||Object.getPrototypeOf(t)).call.apply(e,[this].concat(s))),a.state={name:\"\",sellAsset:\"BTC\",getAsset:\"USD\",amount:.01,minAmount:1,stoploss:100,percent:10,validate:[\"name\"]},a.handleChange=function(e){var t=e.target.name,n=e.target.value;[\"sellAsset\",\"getAsset\"].includes(t)&&(n=n.toUpperCase()),\"minAmount\"===t?a.setState({minAmount:n,stoploss:n/a.state.amount},function(){return a.validate(t,n)}):\"stoploss\"===t?a.setState({minAmount:a.state.amount*n,stoploss:n},function(){return a.validate(t,n)}):\"amount\"===t?a.setState({amount:n,minAmount:n*a.state.stoploss},function(){return a.validate(t,n)}):a.setState(function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}({},t,n),function(){return a.validate(t,n)})},a.assetValidate=function(){var e=function(e){return function(){var t=e.apply(this,arguments);return new Promise(function(e,n){return function a(r,o){try{var s=t[r](o),i=s.value}catch(e){return void n(e)}if(!s.done)return Promise.resolve(i).then(function(e){a(\"next\",e)},function(e){a(\"throw\",e)});e(i)}(\"next\")})}}(regeneratorRuntime.mark(function e(t){var n,o,s;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return n=a.state[t],e.next=3,i.db.list_assets(n,1);case 3:o=e.sent[0],s=a.state.validate,n!==o.symbol?s.push(t):s=s.filter(function(e){return e!==t}),a.setState({validate:s}),a.props.enableCreate(0==a.state.validate.length);case 8:case\"end\":return e.stop()}},e,r)}));return function(t){return e.apply(this,arguments)}}(),a.validate=function(e,t){var n=a.state.validate;switch(e){case\"name\":!/^\\w+$/.test(t)||pe.hasBot(a.props.account,a.props.name,t)?(n.push(e),a.setState({validate:n})):a.setState({validate:n.filter(function(t){return t!==e})});break;case\"sellAsset\":case\"getAsset\":0!==t.length?a.assetValidate(e):(n.push(e),a.setState({validate:n}));break;case\"amount\":case\"minAmount\":case\"pecent\":case\"stoploss\":\"\"===t||isNaN(+t)?(n.push(e),a.setState({validate:n})):a.setState({validate:n.filter(function(t){return t!==e})})}console.log(a.state.validate),a.props.enableCreate(0==a.state.validate.length)},H(a,n)}return function(e,t){if(\"function\"!=typeof t&&null!==t)throw new TypeError(\"Super expression must either be null or a function, not \"+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,r.a.Component),G(t,[{key:\"componentDidMount\",value:function(){this.assetValidate=Object(o.a)(this.assetValidate,200)}},{key:\"render\",value:function(){return r.a.createElement(\"div\",null,r.a.createElement(\"div\",{className:\"content-block\"},r.a.createElement(\"label\",{className:\"left-label\"},r.a.createElement(q.a,{content:\"bots.common.name\"})),r.a.createElement(\"input\",{name:\"name\",id:\"name\",type:\"text\",ref:\"input\",value:this.state.name,onChange:this.handleChange,style:{border:this.state.validate.includes(\"name\")?\"1px solid red\":\"none\"}})),r.a.createElement(\"div\",{className:\"grid-block horizontal\",style:{marginLeft:50}},r.a.createElement(\"div\",{className:\"content-block\"},r.a.createElement(\"label\",{className:\"left-label\"},r.a.createElement(q.a,{content:\"bots.trailing_stop.sell_asset\"})),r.a.createElement(A,{name:\"sellAsset\",value:this.state.sellAsset,onChange:this.handleChange}),r.a.createElement(\"label\",{className:\"left-label\"},r.a.createElement(q.a,{content:\"bots.trailing_stop.amount\"})),r.a.createElement(\"input\",{name:\"amount\",id:\"amount\",type:\"text\",ref:\"input\",value:this.state.amount,onChange:this.handleChange,style:{marginBottom:30,border:this.state.validate.includes(\"amount\")?\"1px solid red\":\"none\"}})),r.a.createElement(\"div\",{className:\"content-block\",style:{marginLeft:50}},r.a.createElement(\"label\",{className:\"left-label\"},r.a.createElement(q.a,{content:\"bots.trailing_stop.get_asset\"})),r.a.createElement(A,{name:\"getAsset\",value:this.state.getAsset,onChange:this.handleChange}),r.a.createElement(\"label\",{className:\"left-label\"},r.a.createElement(q.a,{content:\"bots.trailing_stop.min_amount\"})),r.a.createElement(\"input\",{name:\"minAmount\",id:\"minAmount\",type:\"text\",ref:\"input\",value:this.state.minAmount,onChange:this.handleChange,style:{marginBottom:30,border:this.state.validate.includes(\"minAmount\")?\"1px solid red\":\"none\"}}))),r.a.createElement(\"div\",{className:\"content-block\"},r.a.createElement(\"label\",{className:\"left-label\"},r.a.createElement(q.a,{content:\"bots.trailing_stop.stoploss\"})),r.a.createElement(\"input\",{name:\"stoploss\",id:\"stoploss\",type:\"text\",ref:\"input\",value:this.state.stoploss,onChange:this.handleChange,style:{marginBottom:30,border:this.state.validate.includes(\"stoploss\")?\"1px solid red\":\"none\"}}),r.a.createElement(\"label\",{className:\"left-label\"},r.a.createElement(q.a,{content:\"bots.trailing_stop.trailing_percent\"})),r.a.createElement(\"input\",{name:\"percent\",id:\"percent\",type:\"text\",ref:\"input\",value:this.state.percent,onChange:this.handleChange,style:{marginBottom:30,border:this.state.validate.includes(\"percent\")?\"1px solid red\":\"none\"}})))}}]),t}(),Y=function(){function e(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,\"value\"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}return function(t,n,a){return n&&e(t.prototype,n),a&&e(t,a),t}}();function Z(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ee(e,t){if(!e)throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\");return!t||\"object\"!=typeof t&&\"function\"!=typeof t?e:t}var te=function(e){function t(){var e,n,a;!function(e,t){if(!(e instanceof t))throw new TypeError(\"Cannot call a class as a function\")}(this,t);for(var r=arguments.length,o=Array(r),s=0;s<r;s++)o[s]=arguments[s];return n=a=ee(this,(e=t.__proto__||Object.getPrototypeOf(t)).call.apply(e,[this].concat(o))),a.state={validate:[]},a.handleChange=function(e){var t=e.target.name,n=e.target.value;[\"sellAsset\",\"getAsset\"].includes(t)&&(n=n.toUpperCase()),\"minAmount\"===t?a.setState({minAmount:n,stoploss:n/a.state.amount},function(){return a.validate(t,n)}):\"stoploss\"===t?a.setState({minAmount:a.state.amount*n,stoploss:n},function(){return a.validate(t,n)}):\"amount\"===t?a.setState({amount:n,minAmount:n*a.state.stoploss},function(){return a.validate(t,n)}):a.setState(Z({},t,n),function(){return a.validate(t,n)}),a.setState(Z({},t,n))},a.validate=function(e,t){},a.handleUpdateBot=function(){a.props.bot.storage.write(a.state)},ee(a,n)}return function(e,t){if(\"function\"!=typeof t&&null!==t)throw new TypeError(\"Super expression must either be null or a function, not \"+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,r.a.Component),Y(t,[{key:\"componentWillMount\",value:function(){var e=this.props.bot.storage.read();e.stoploss=e.minAmount/e.amount,this.setState(e)}},{key:\"render\",value:function(){return r.a.createElement(\"div\",null,r.a.createElement(\"div\",{className:\"grid-block horizontal\",style:{marginLeft:50,marginTop:50}},r.a.createElement(\"div\",{className:\"content-block\"},r.a.createElement(\"label\",{className:\"left-label\"},r.a.createElement(q.a,{content:\"bots.trailing_stop.sell_asset\"})),r.a.createElement(j.a,{style:{marginBottom:30},name:\"sellAsset\",value:{value:this.state.sellAsset,label:r.a.createElement(w,{name:this.state.sellAsset})},clearable:!1,searchable:!1,disabled:!0}),r.a.createElement(\"label\",{className:\"left-label\"},r.a.createElement(q.a,{content:\"bots.trailing_stop.amount\"})),r.a.createElement(\"input\",{name:\"amount\",id:\"amount\",type:\"text\",ref:\"input\",value:this.state.amount,onChange:this.handleChange,disabled:this.props.bot.run,style:{marginBottom:30,border:this.state.validate.includes(\"amount\")?\"1px solid red\":\"none\"}})),r.a.createElement(\"div\",{className:\"content-block\",style:{marginLeft:50}},r.a.createElement(\"label\",{className:\"left-label\"},r.a.createElement(q.a,{content:\"bots.trailing_stop.get_asset\"})),r.a.createElement(j.a,{style:{marginBottom:30},name:\"getAsset\",value:{value:this.state.getAsset,label:r.a.createElement(w,{name:this.state.getAsset})},clearable:!1,searchable:!1,disabled:!0}),r.a.createElement(\"label\",{className:\"left-label\"},r.a.createElement(q.a,{content:\"bots.trailing_stop.min_amount\"})),r.a.createElement(\"input\",{name:\"minAmount\",id:\"minAmount\",type:\"text\",ref:\"input\",value:this.state.minAmount,onChange:this.handleChange,disabled:this.props.bot.run,style:{marginBottom:30,border:this.state.validate.includes(\"minAmount\")?\"1px solid red\":\"none\"}}))),r.a.createElement(\"div\",{className:\"content-block\"},r.a.createElement(\"label\",{className:\"left-label\"},r.a.createElement(q.a,{content:\"bots.trailing_stop.stoploss\"})),r.a.createElement(\"input\",{name:\"stoploss\",id:\"stoploss\",type:\"text\",ref:\"input\",value:this.state.stoploss,onChange:this.handleChange,disabled:this.props.bot.run,style:{marginBottom:30,border:this.state.validate.includes(\"stoploss\")?\"1px solid red\":\"none\"}}),r.a.createElement(\"label\",{className:\"left-label\"},r.a.createElement(q.a,{content:\"bots.trailing_stop.trailing_percent\"})),r.a.createElement(\"input\",{name:\"percent\",id:\"percent\",type:\"text\",ref:\"input\",value:this.state.percent,onChange:this.handleChange,disabled:this.props.bot.run,style:{marginBottom:30,border:this.state.validate.includes(\"percent\")?\"1px solid red\":\"none\"}})),r.a.createElement(\"button\",{className:\"button\",onClick:this.handleUpdateBot,disabled:this.props.bot.run,style:{marginLeft:50,marginBottom:30}},r.a.createElement(q.a,{content:\"bots.common.update\"})))}}]),t}(),ne=function(){function e(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,\"value\"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}return function(t,n,a){return n&&e(t.prototype,n),a&&e(t,a),t}}();function ae(e){return function(){var t=e.apply(this,arguments);return new Promise(function(e,n){return function a(r,o){try{var s=t[r](o),i=s.value}catch(e){return void n(e)}if(!s.done)return Promise.resolve(i).then(function(e){a(\"next\",e)},function(e){a(\"throw\",e)});e(i)}(\"next\")})}}var re=function(){function e(t,n,a){var r=this;!function(e,t){if(!(e instanceof t))throw new TypeError(\"Cannot call a class as a function\")}(this,e),this.state=te,this.queue=function(){r.queueEvents=r.queueEvents.then(r.checkOrders).catch(r.logger.error.bind(r.logger))},this.checkOrders=ae(regeneratorRuntime.mark(function e(){var t,n,a,o,s,c;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return t=r.storage.read(),console.log(\"checkOrders\"),e.next=4,i.db.get_ticker(r.getAsset.symbol,r.sellAsset.symbol);case 4:if(n=e.sent,a=Object(M.a)(n.latest),o=a.times(1-t.percent/100),s=a.times(1-2*t.percent/3/100),c=Object(M.a)(t.minAmount).div(t.amount),console.log(a.toNumber(),o.toNumber(),s.toNumber(),c.toNumber()),!o.gt(c)){e.next=16;break}console.log(\"up minAmount\"),t.minAmount=o.times(t.amount).toNumber(),r.storage.write(t),e.next=21;break;case 16:if(!s.lt(c)){e.next=21;break}return console.log(\"create limit order\"),e.next=20,r.account.sell(r.sellAsset.symbol,r.getAsset.symbol,t.amount,c.toNumber());case 20:r.stop();case 21:case\"end\":return e.stop()}},e,r)})),this.account=new V(t),this.storage=n,a&&n.init({name:a.name,sellAsset:a.sellAsset,getAsset:a.getAsset,amount:a.amount,minAmount:a.minAmount,percent:a.percent}),this.name=n.read().name,this.logger=console,this.queueEvents=Promise.resolve(),this.run=!1}return ne(e,[{key:\"start\",value:function(){var e=ae(regeneratorRuntime.mark(function e(){var t;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.storage.read(),e.next=3,m[t.sellAsset];case 3:return this.sellAsset=e.sent,e.next=6,m[t.getAsset];case 6:return this.getAsset=e.sent,e.next=9,U.a.unlock();case 9:Q.a.changeSetting({setting:\"walletLockTimeout\",value:0}),T.ChainStore.subscribe(this.queue),this.run=!0;case 12:case\"end\":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:\"stop\",value:function(){var e=ae(regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return T.ChainStore.unsubscribe(this.queue),this.run=!1,e.next=4,this.queueEvents;case 4:case\"end\":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:\"delete\",value:function(){this.storage.delete()}}]),e}();re.create=X;var oe=re,se=n(98),ie=function(){function e(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,\"value\"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}return function(t,n,a){return n&&e(t.prototype,n),a&&e(t,a),t}}();var ce=Object(se.a)(\"__bots__\"),le=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError(\"Cannot call a class as a function\")}(this,e),this.name=t}return ie(e,null,[{key:\"getAccountBot\",value:function(e){var t=new RegExp(\"^__bots__\"+e+\"::\");return Object.keys(localStorage).filter(function(e){return t.test(e)})}},{key:\"has\",value:function(e){return ce.has(e)}}]),ie(e,[{key:\"init\",value:function(e){ce.has(name)||ce.set(this.name,e)}},{key:\"read\",value:function(){return ce.get(this.name)}},{key:\"write\",value:function(e){ce.set(this.name,e)}},{key:\"delete\",value:function(){ce.remove(this.name)}}]),e}(),ue=function(){return function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return function(e,t){var n=[],a=!0,r=!1,o=void 0;try{for(var s,i=e[Symbol.iterator]();!(a=(s=i.next()).done)&&(n.push(s.value),!t||n.length!==t);a=!0);}catch(e){r=!0,o=e}finally{try{!a&&i.return&&i.return()}finally{if(r)throw o}}return n}(e,t);throw new TypeError(\"Invalid attempt to destructure non-iterable instance\")}}(),me={},pe={strategies:{SpreadTrade:J,TrailingStop:oe},create:function(e,t,n){var a=new le(t+\"::\"+e+\"[\"+n.name+\"]\"),r=new this.strategies[e](t,a,n);return me[\"__bots__\"+a.name]=r,r},delete:function(e){var t=\"__bots__\"+e.storage.name;me[t].delete(),delete me[t]},getBots:function(e){var t=this;return le.getAccountBot(e).map(function(n){if(me[n])return me[n];var a=n.replace(/^__bots__(.+)::(\\w+)\\[(\\w+)\\]/,\"$2,$3\").split(\",\"),r=ue(a,2),o=r[0],s=r[1];if(!o||!s)return null;var i=new le(e+\"::\"+o+\"[\"+s+\"]\"),c=new t.strategies[o](e,i);return me[n]=c,c}).filter(function(e){return e})},hasBot:function(e,t,n){return console.log(\"check name stategy\",e,t,n),le.has(e+\"::\"+t+\"[\"+n+\"]\")}},be=n(26),he=n(35),de=n(2055),fe=function(){function e(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,\"value\"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}return function(t,n,a){return n&&e(t.prototype,n),a&&e(t,a),t}}();function ve(e){return function(){var t=e.apply(this,arguments);return new Promise(function(e,n){return function a(r,o){try{var s=t[r](o),i=s.value}catch(e){return void n(e)}if(!s.done)return Promise.resolve(i).then(function(e){a(\"next\",e)},function(e){a(\"throw\",e)});e(i)}(\"next\")})}}var ge=function(e){function t(e){var n=this;!function(e,t){if(!(e instanceof t))throw new TypeError(\"Cannot call a class as a function\")}(this,t);var a=function(e,t){if(!e)throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\");return!t||\"object\"!=typeof t&&\"function\"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return a.handleChangeStrategy=function(e){a.setState({selectStrategy:e.target.value})},a.handleChangeBot=function(e){var t=e.target.value;a.setState({selectBot:t,botRun:a.state.bots[t].run})},a.handleCreate=function(e){e.preventDefault();var t=a.state.bots;t.push(pe.create(a.state.selectStrategy,a.props.currentAccount,a.createForm.state)),a.setState({bots:t}),a.createForm.validate&&a.createForm.validate(\"name\",a.createForm.state.name)},a.handleEnableCreate=function(e){a.state.enableCreate!=e&&a.setState({enableCreate:e})},a.handleStartBot=ve(regeneratorRuntime.mark(function e(){var t;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return t=a.state.bots[a.state.selectBot],e.next=3,t.start();case 3:a.setState({botRun:t.run});case 4:case\"end\":return e.stop()}},e,n)})),a.handleStopBot=ve(regeneratorRuntime.mark(function e(){var t;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return t=a.state.bots[a.state.selectBot],e.next=3,t.stop();case 3:a.setState({botRun:t.run});case 4:case\"end\":return e.stop()}},e,n)})),a.handleDeleteBot=function(){pe.delete(a.state.bots[a.state.selectBot]),a.setState({bots:pe.getBots(a.props.currentAccount),selectBot:0})},a.strategies=pe.strategies,a.state={selectStrategy:Object.keys(a.strategies)[0],bots:[],selectBot:0,enableCreate:!1,botRun:!1},a}return function(e,t){if(\"function\"!=typeof t&&null!==t)throw new TypeError(\"Super expression must either be null or a function, not \"+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,r.a.Component),fe(t,[{key:\"componentDidMount\",value:function(){var e=pe.getBots(this.props.currentAccount);this.setState({bots:e,selectBot:0,botRun:!!e[0]&&e[0].run})}},{key:\"render\",value:function(){var e=this;if(null===this.props.currentAccount)return r.a.createElement(de.a,{to:\"/\"});var t=this.strategies[this.state.selectStrategy].create,n=this.state.bots[this.state.selectBot]||null;return r.a.createElement(\"div\",{className:\"grid-block vertical\"},r.a.createElement(\"div\",{className:\"grid-block shrink vertical medium-horizontal\"},r.a.createElement(\"form\",{style:{paddingBottom:20,overflow:\"visible\"},className:\"grid-content small-12 medium-6 large-5 large-offset-1 full-width-content\",onSubmit:this.handleCreate,noValidate:!0},r.a.createElement(\"div\",{className:\"left-label\",style:{marginTop:30}},r.a.createElement(q.a,{content:\"bots.common.select_strategy\"})),r.a.createElement(\"div\",{className:\"content-block\"},r.a.createElement(\"div\",{className:\"content-block\"},r.a.createElement(\"select\",{className:\"form-control bts-select \",value:this.state.selectStrategy,onChange:this.handleChangeStrategy},Object.keys(this.strategies).map(function(e){return r.a.createElement(\"option\",{key:e,value:e},e)})))),r.a.createElement(\"hr\",null),r.a.createElement(\"div\",{className:\"content-block\"},r.a.createElement(t,{ref:function(t){e.createForm=t},account:this.props.currentAccount,name:this.state.selectStrategy,enableCreate:this.handleEnableCreate}),r.a.createElement(\"button\",{className:\"button no-margin\",type:\"submit\",disabled:!this.state.enableCreate},r.a.createElement(q.a,{content:\"bots.common.create\"})))),r.a.createElement(\"div\",{className:\"content-block\"},r.a.createElement(\"div\",{className:\"left-label\",style:{marginTop:30}},r.a.createElement(q.a,{content:\"bots.common.bot_state\"})),r.a.createElement(\"select\",{className:\"form-control bts-select\",value:this.state.selectBot,onChange:this.handleChangeBot},this.state.bots.map(function(e,t){return r.a.createElement(\"option\",{key:e.name,value:t},e.name+\" (\"+e.constructor.name+\")\")})),r.a.createElement(\"div\",{className:\"content-block\"},n?r.a.createElement(\"div\",null,r.a.createElement(n.state,{key:n.name,bot:n}),r.a.createElement(\"button\",{className:\"button\",onClick:this.handleStartBot,disabled:this.state.botRun,style:{marginLeft:50}},r.a.createElement(q.a,{content:\"bots.common.start\"})),r.a.createElement(\"button\",{className:\"button\",onClick:this.handleStopBot,disabled:!this.state.botRun,style:{marginLeft:50}},r.a.createElement(q.a,{content:\"bots.common.stop\"})),r.a.createElement(\"button\",{className:\"button\",onClick:this.handleDeleteBot,disabled:this.state.botRun,style:{marginLeft:50}},r.a.createElement(q.a,{content:\"bots.common.delete\"}))):r.a.createElement(\"p\",null,r.a.createElement(q.a,{content:\"bots.common.select_bot\"}))))))}}]),t}();t.default=Object(he.a)(ge,{listenTo:function(){return[be.a]},getProps:function(){return{currentAccount:be.a.getState().currentAccount||be.a.getState().passwordAccount}}})}}]);"],"mappings":"AAAA","sourceRoot":""}