diff --git a/charting_library/charting_library.min.js b/charting_library/charting_library.min.js index 31c6bc43..a2a391a3 100644 --- a/charting_library/charting_library.min.js +++ b/charting_library/charting_library.min.js @@ -3,7 +3,7 @@ e.ontimeout=function(){d(500,"timeout")};e.onload=function(){var a="Content-Leng !1;try{k.loadXML(e.responseText)}catch(n){k=void 0}if(!k||!k.documentElement||k.getElementsByTagName("parsererror").length)throw b=500,c="parseerror","Invalid XML: "+e.responseText;g.xml=k}}catch(m){throw m;}finally{d(b,c,g,a)}};e.onprogress=function(){};e.onerror=function(){d(500,"error",{text:e.responseText})};c.data&&(g="string"===f.type(c.data)?c.data:f.param(c.data));e.open(b.type,b.url);e.send(g)},abort:function(){e&&e.abort()}}}})}});"use strict"; function inherit(f,h){var d=function(){};d.prototype=h.prototype;f.prototype=new d;f.prototype.constructor=f;f.prototype.superclass=h} (function(){function f(a){"hideSymbolSearch enabledStudies enabledDrawings disabledDrawings disabledStudies disableLogo hideSideToolbar".split(" ").map(function(b){a[b]&&console.warn("Feature `"+b+"` is obsolete. Please see the doc for details.")})}if(!window.TradingView){var h={mobile:{disabledFeatures:"left_toolbar header_widget timeframes_toolbar edit_buttons_in_legend context_menus control_bar border_around_the_chart".split(" "),enabledFeatures:["narrow_chart_enabled"]}},d={BARS:0,CANDLES:1,LINE:2, -AREA:3,HEIKEN_ASHI:8,HOLLOW_CANDLES:9,version:function(){return"1.5 (internal id a10abf5b @ 2016-04-13 09:03:05.703233)"},gEl:function(a){return document.getElementById(a)},gId:function(){return"tradingview_"+(1048576*(1+Math.random())|0).toString(16).substring(1)},onready:function(a){window.addEventListener?window.addEventListener("DOMContentLoaded",a,!1):window.attachEvent("onload",a)},css:function(a){var b=document.getElementsByTagName("head")[0],c=document.createElement("style");c.type="text/css"; +AREA:3,HEIKEN_ASHI:8,HOLLOW_CANDLES:9,version:function(){return"1.5 (internal id a74e7e7d @ 2016-04-18 01:10:39.256426)"},gEl:function(a){return document.getElementById(a)},gId:function(){return"tradingview_"+(1048576*(1+Math.random())|0).toString(16).substring(1)},onready:function(a){window.addEventListener?window.addEventListener("DOMContentLoaded",a,!1):window.attachEvent("onload",a)},css:function(a){var b=document.getElementsByTagName("head")[0],c=document.createElement("style");c.type="text/css"; c.styleSheet?c.styleSheet.cssText=a:(a=document.createTextNode(a),c.appendChild(a));b.appendChild(c)},bindEvent:function(a,b,c){a.addEventListener?a.addEventListener(b,c,!1):a.attachEvent&&a.attachEvent("on"+b,c)},unbindEvent:function(a,b,c){a.removeEventListener?a.removeEventListener(b,c,!1):a.detachEvent&&a.detachEvent("on"+b,c)},widget:function(a){this.id=d.gId();if(!a.datafeed)throw"Datafeed is not defined";var b={width:800,height:500,symbol:"AA",interval:"D",timezone:"",container:"",path:"", locale:"en",toolbar_bg:void 0,hideSymbolSearch:!1,hideSideToolbar:!1,enabledStudies:[],enabledDrawings:[],disabledDrawings:[],disabledStudies:[],drawingsAccess:void 0,studiesAccess:void 0,widgetbar:{datawindow:!1,details:!1,watchlist:!1,watchlist_settings:{default_symbols:[]}},overrides:{"mainSeriesProperties.showCountdown":!1},studiesOverrides:{},fullscreen:!1,autosize:!1,disabledFeatures:[],enabledFeatures:[],indicators_file_name:null,custom_css_url:null,auto_save_delay:null,debug:!1,time_frames:[{text:"5y", resolution:"W"},{text:"1y",resolution:"W"},{text:"6m",resolution:"120"},{text:"3m",resolution:"60"},{text:"1m",resolution:"30"},{text:"5d",resolution:"5"},{text:"1d",resolution:"1"}],client_id:"0",user_id:"0",charts_storage_url:void 0,charts_storage_api_version:"1.0",logo:{},favorites:{intervals:[],chartTypes:[]},rss_news_feed:null},c={width:a.width,height:a.height,symbol:a.symbol,interval:a.interval,timezone:a.timezone,container:a.container_id,path:a.library_path,locale:a.locale,toolbar_bg:a.toolbar_bg, diff --git a/charting_library/static/bundles/1.14b33d8252a7275a6935.js b/charting_library/static/bundles/1.14b33d8252a7275a6935.js index 2d4ab51c..c3e929b7 100644 --- a/charting_library/static/bundles/1.14b33d8252a7275a6935.js +++ b/charting_library/static/bundles/1.14b33d8252a7275a6935.js @@ -1,8 +1,8 @@ -webpackJsonp([1,4],{322:function(e,t,i){"use strict";var r=i(323),n=i(324),o=i(325),s=i(328),a=i(339),l=i(340),u=i(341),d=i(342),c=i(343),p=i(338),f=function(e){this.activeAccount=new WatchedValue,this._trading=e,this._chartWidgetControllers=[],this._resolver=new n(this)};f.prototype.id=function(){return"CQG"},f.prototype.trading=function(){return this._trading},f.prototype.createAccountManager=function(e){return new o(e,this)},f.prototype.connect=function(){var e=this;this._connection=new s(this),this._connection.onMustChangePassword.subscribe(null,function(){d.get(e).open({title:$.t("Your Password Has Expired"),allowCancel:!1,message:$.t("Your password has expired, please enter new password")})})},f.prototype.disconnect=function(){this._connection.disconnect(),this._chartWidgetControllers.forEach(function(e){e.controller&&e.controller.reset()}),this._chartWidgetControllers=[]},f.prototype.connection=function(){return this._connection||this.connect(),this._connection},f.prototype.buttonDropdownOptions=function(e){var t=this.connection().connectStatus()==r.CONNECTED,i=this;if(t){var n=[{title:$.t("Show Buy/Sell Panel"),icon:{image:"url('"+TradingView.wrapUrl("images/dialogs/checkbox.png")+"')",offset:i.trading().hideFloatingPanel.value()?"":"0 -16px"},action:function(){i.trading().hideFloatingPanel.setValue(!i.trading().hideFloatingPanel.value())}},{title:$.t("Show Active Orders Only"),icon:{image:"url('"+TradingView.wrapUrl("images/dialogs/checkbox.png")+"')",offset:i.trading().hideCompletedOrders.value()?"0 -16px":""},action:function(){i.trading().hideCompletedOrders.setValue(!i.trading().hideCompletedOrders.value())}},{separator:!0},{title:$.t("Trading Properties"),action:function(){i.trading().showTradingProperties()}},{separator:!0},{title:$.t("Disconnect"),action:function(){i.disconnect()}},{title:$.t("Change Password"),disabled:!t,action:function(){d.get(i).open({title:$.t("Change Password"),allowCancel:!0})}}];return W75.enabled("charting_library_base")||(n.push({separator:!0}),n.push({title:$.t("Select Broker"),action:function(){i.trading().selectBroker()}})),n}return[{title:$.t("Select Broker"),action:function(){i.trading().selectBroker()}}]},f.prototype.formatter=function(e){return new p(e)},f.prototype.createProfitLossEmitter=function(e){return{}},f.prototype.registerChartWidget=function(e){var t={widget:e};this._chartWidgetControllers.push(t);var i=this;e.model().model().mainSeries().onSymbolResolved().subscribe(null,function(){r()}),i.activeAccount.subscribe(function(){r()});var r=function(){var r=e.model().model().mainSeries().symbolInfo();if(r){var n=r.pro_name;i._resolver.tv2cqg(n).done(function(r){i.activeAccount.when(function(){if(i.trading().getActiveBroker()==i){var n=i.activeAccount.value().id;t.controller?t.controller.setCQGSymbol(r,n):t.controller=new a(e,r,n,i)}})}).fail(function(){t.controller&&i.activeAccount.when(function(){t.controller.setCQGSymbol("",i.activeAccount.value().id)})})}};t.controllerCreator=r,r()},f.prototype.unregisterChartWidget=function(e){for(var t=this._chartWidgetControllers.length-1;t>=0;--t){var i=this._chartWidgetControllers[t];if(i.widget==e){i.controller&&i.controller.reset(),this._chartWidgetControllers.splice(t,1),e.model().model().mainSeries().onSymbolResolved().unsubscribe(null,i.controllerCreator),e.model().model().mainSeries().onCompleted().unsubscribe(null,i.controllerCreator);break}}},f.prototype.supportFloatingPanel=function(){return!0},f.prototype.closePosition=function(e){var t=this,i={account_id:e.account_id,qty:e.qty,side:"Buy"==e.side?"Sell":"Buy",symbol:e.symbol,type:"Market",duration:{type:"DAY"},executionOptions:{}};this.trading().noConfirmEnabled.value()?this.connection().resolveSymbol(i.symbol).done(function(e){i.contract_id=e.contract_metadata.contract_id,t.connection().placeOrder(i)}):l.get(t).open(i)},f.prototype.cancelOrder=function(e){var t=this;this.trading().noConfirmEnabled.value()?t.connection().cancelOrder(e):c.get().open(e).done(function(){t.connection().cancelOrder(e)})},f.prototype.getOrderDialog=function(){var e=this;return{open:function(t,i){if(e.connection().connectStatus()!=r.CONNECTED)return e.trading().onOpenBottomWidgetBar.fire(),e.trading().onNeedAttention.fire(),$.Deferred().reject().promise();var n=$.Deferred();if(i){var o=t&&t.symbol;e._connection.isTradable(o).done(function(i){i?(t.account_id=t.account_id?t.account_id:e.activeAccount.value().id,l.get(e).open(t).done(function(){n.resolve()}).fail(function(){n.reject()})):(e.getUntradableDialog().open(s),n.reject())})}else{var s=t&&t.symbol;e._resolver.tv2cqg(s).done(function(i){e._connection.isTradable(i).done(function(r){if(r){var o=TradingView.clone(t);o.symbol=i,o.tvSymbol=s,o.account_id=o.account_id?o.account_id:e.activeAccount.value().id,l.get(e).open(o).done(function(){n.resolve()}).fail(function(){n.reject()})}else e.getUntradableDialog().open(s),n.reject()})}).fail(function(){e.getUntradableDialog().open(s),n.reject()})}return n.promise()}}},f.prototype.getUntradableDialog=function(){return u.get()},f.prototype.resolver=function(){return this._resolver},f.prototype.chartContextMenuActions=function(e,t){var i=NaN,r=this,n=NaN,o=1,s="",a="",l="";if(e){a=e.proSymbol(),l=(e.symbolInfo()||{}).name||a;var u=e.priceScale();if(t){if(i=u.coordinateToPrice(t.localY),u.isPercentage()){var d=e.firstValue();i=void 0!==d?u.priceRange().convertFromPercent(i,d):null}s=e.formatter().format(i)}var c=e.bars().last();c&&(n=c.value[TradingView.CLOSE_PLOT]);var p=this.connection();p&&(o=+p.suggestedQty().value(a),(0>o||!isFinite(o))&&(o=1))}var f=[],h=r.activeAccount.value()&&r.activeAccount.value().id;if(n>i){var m=new TradingView.Action({text:"Buy "+l+" Limit "+TradingView.abbreviatedNumber(o)+" @ "+s});m.callbacks().subscribe(null,function(){r.getOrderDialog().open({account_id:h,symbol:a,formatted_limit_price:s,side:"Buy",type:"Limit",qty:o,noConfirm:!0})}),f.push(m);var m=new TradingView.Action({text:"Sell "+l+" Stop "+TradingView.abbreviatedNumber(o)+" @ "+s});m.callbacks().subscribe(null,function(){r.getOrderDialog().open({account_id:h,symbol:a,formatted_stop_price:s,side:"Sell",type:"Stop",qty:o,noConfirm:!0})}),f.push(m)}else if(i>n){var m=new TradingView.Action({text:"Sell "+l+" Limit "+TradingView.abbreviatedNumber(o)+" @ "+s});m.callbacks().subscribe(null,function(){r.getOrderDialog().open({account_id:h,symbol:a,formatted_limit_price:s,side:"Sell",type:"Limit",qty:o,noConfirm:!0})}),f.push(m);var m=new TradingView.Action({text:"Buy "+l+" Stop "+TradingView.abbreviatedNumber(o)+" @ "+s});m.callbacks().subscribe(null,function(){r.getOrderDialog().open({account_id:h,symbol:a,formatted_stop_price:s,side:"Buy",type:"Stop",qty:o,noConfirm:!0})}),f.push(m)}var m=new TradingView.Action({text:"Create New Order..."});return m.callbacks().subscribe(null,function(){r.getOrderDialog().open({account_id:h,qty:o,symbol:a})}),f.push(m),f},f.prototype.getSymbolInfo=function(e){var t=this,i=$.Deferred();return t._resolver.tv2cqg(e).done(function(e){t.connection().resolveSymbol(e).done(function(e){i.resolve({realtimeContractId:e.contract_metadata.contract_id,formatter:t.formatter(e.contract_metadata)})}).fail(function(e){i.reject(e)})}).fail(function(e){i.reject(e)}),i},e.exports=f},324:function(e,t){"use strict";var i=function(e){this._cache2tv={},this._cache2cqg={},this._broker=e};i.prototype.tv2cqg=function(e){var t=this,i=$.Deferred();if(this._cache2cqg[e]){var r=this._cache2cqg[e];setTimeout(function(){"SYMBOL_NOT_FOUND"==r?i.reject():i.resolve(r)},0)}else $.get("/cqg_mapping/2cqg/"+e+"/").done(function(r){var n=r.symbol;r.error?(t._cache2cqg[e]="SYMBOL_NOT_FOUND",i.reject()):(t._cache2cqg[e]=n,i.resolve(n))});return i.promise()},i.prototype.cqg2tv=function(e){var t=$.Deferred(),i=this._cache2tv[e];if(i)setTimeout(function(){"SYMBOL_NOT_FOUND"==i?t.reject():t.resolve(i)},0);else{var r=this;$.get("/cqg_mapping/2tv/"+e+"/").done(function(i){var n=i.symbol;i.error?(r._cache2tv[e]="SYMBOL_NOT_FOUND",t.reject()):(r._cache2tv[e]=n,t.resolve(n))})}return t.promise()},e.exports=i},325:function(e,t,i){(function(t){"use strict";var r=i(323),n=i(326),o=i(327),s=function(e,t){this._broker=t,this._connection=t.connection(),this._resolver=t.resolver(),this.$container=$(document.createElement("div")),this.$container.appendTo(e.$body).addClass("cqg-trading"),this.height=e.height,this.minimized=e.minimized,this.properties=e.properties,this.body=e.$body,this._connection.onStatusChanged.subscribe(this,s.prototype._updateContentPanel),this._contextMenuHandler=this._onContextMenu.bind(this),this._changeacc=s.prototype._changeAccount.bind(this),this._changesymbol=s.prototype._updateSymbol.bind(this),this._updateContentPanel({status:this._connection.connectStatus()}),this._broker.trading().onNeedAttention.subscribe(this,this.drawAttention)};s.prototype.selectActiveSymbol=function(e){this._tables.orders.getRows().forEach(function(t){t.row.toggleClass("tv-data-table__stroke--active",t.symbol==e)}),this._tables.positions.getRows().forEach(function(t){t.row.toggleClass("tv-data-table__stroke--active",t.symbol==e)})},s.prototype.connect=function(){this._connection.onBalance.subscribe(this,s.prototype._updateBalance),this._connection.onCollateral.subscribe(this,s.prototype._updateCollaterals),this._connection.onOrderUpdate.subscribe(this,s.prototype._updateOrder),this._connection.onPositionUpdate.subscribe(this,s.prototype._updatePosition)},s.prototype.disconnect=function(){this._broker.activeAccount.unsubscribe(this._changeacc),this._ordersHandler&&this._broker.trading().hideCompletedOrders.unsubscribe(this._ordersHandler),this.body.off("contextmenu",this._contextMenuHandler),$44.proSymbol.unsubscribe(this._changesymbol),this._connection.onBalance.unsubscribe(this,s.prototype._updateBalance),this._connection.onCollateral.unsubscribe(this,s.prototype._updateCollaterals),this._connection.onOrderUpdate.unsubscribe(this,s.prototype._updateOrder),this._connection.onPositionUpdate.unsubscribe(this,s.prototype._updatePosition)},s.prototype.remove=function(){this._tables&&this._tables.positions.getRows().forEach(function(e){e.plCalculator&&e.plCalculator.stop()}),delete this._tables,this.$container.remove(),this.disconnect(),this._connection.onStatusChanged.unsubscribe(this,s.prototype._updateContentPanel)},s.prototype._updateContentPanel=function(e){if(this._tables&&this._tables.positions.getRows().forEach(function(e){e.plCalculator&&(e.plCalculator.stop(),delete e.plCalculator)}),this._flatAccounts=[],this.$container.empty(),this._spinner&&(this._spinner.stop(),delete this._spinner),this._spinnerContainer&&(this._spinnerContainer.remove(),delete this._spinnerContainer),e.status==r.ERROR||e.status==r.DISCONNECT){this.disconnect(),e.message&&$("
").addClass("trading-connection-error-message").text(e.message).appendTo(this.$container);var t=new o(this._connection,this._broker.trading());this.$container.append(t.content()),t.focus(),this._loginForm=t}else this._loginForm=null;e.status==r.CONNECTING&&(this._spinnerContainer=$(document.createElement("div")).addClass("spinner-container").appendTo(this.$container),this._spinner=TradingView.unifiedSpinner().spin(this._spinnerContainer.get(0))),e.status==r.CONNECTED&&(this.connect(),this._updateAccount(this._connection.flatAccounts()),this._changeAccount(this._broker.activeAccount.value()))};var a=[{label:$.t("Symbol"),className:"tv-data-table__cell--symbol-cell",property:"symbol",formatter:"symbol"},{label:$.t("Side"),className:"",property:"side",formatter:"side"},{label:$.t("Type"),className:"",property:"type"},{label:$.t("Limit Price"),className:"tv-data-table__cell--right-align",property:"limit_price",sortProp:"real_limit_price",formatter:"formatPrice"},{label:$.t("Stop Price"),className:"tv-data-table__cell--right-align",property:"stop_price",sortProp:"real_stop_price",formatter:"formatPrice"},{label:$.t("Qty"),className:"tv-data-table__cell--right-align",property:"qty",help:$.t("Size in lots")},{label:$.t("Status"),className:"",property:"status"},{label:$.t("Active At"),className:"",property:"activate_at",formatter:"date"},{label:$.t("Avg Fill Price"),className:"tv-data-table__cell--right-align",property:"avg_fill_price",sortProp:"real_avg_fill_price",formatter:"formatPrice"},{label:$.t("Fill Qty"),className:"tv-data-table__cell--right-align",property:"fill_qty"},{label:$.t("Placing Time"),className:"",property:"placing_time",formatter:"date"},{label:$.t("Order id"),className:"",property:"order_id"},{label:"",className:"tv-data-table__cell--buttons-cell",formatter:"orderSettings",notSortable:!0}],l=[{label:$.t("Currency"),property:"currency"},{label:$.t("Account Balance"),className:"tv-data-table__cell--right-align",property:"account_balance",formatter:"fixed",help:$.t("Total account balance")},{label:$.t("OTE/MVO"),className:"tv-data-table__cell--right-align",property:"ote_mvo",formatter:"fixed",help:$.t("Open trade equity (market value of options)")},{label:$.t("P/L"),className:"tv-data-table__cell--right-align",property:"pl",formatter:"fixed",help:$.t("Current day profit/loss")},{label:$.t("OTE/MVO+P/L"),className:"tv-data-table__cell--right-align",property:"ote_mvo_pl",formatter:"fixed",help:$.t("Open trade equity (market value of options) and current day profit/loss")},{label:$.t("Prev Day Balance"),className:"tv-data-table__cell--right-align",property:"balance",formatter:"fixed",help:$.t("Previous day account balance")},{label:$.t("Collateral"),className:"tv-data-table__cell--right-align",property:"collateral",formatter:"fixed",help:$.t("Collateral on deposit")},{label:$.t("NLV"),className:"tv-data-table__cell--right-align",property:"nlv",formatter:"fixed",help:$.t("Net liquidity value of account")},{label:$.t("UPL"),className:"tv-data-table__cell--right-align",property:"upl",formatter:"fixed",help:$.t("Unrealized profit/loss for options")},{label:$.t("MVO"),className:"tv-data-table__cell--right-align",property:"mvo",formatter:"fixed",help:$.t("Market value of options")},{label:$.t("Cash Excess"),className:"tv-data-table__cell--right-align",property:"cash_excess",formatter:"fixed"},{label:$.t("Currency Rate"),className:"tv-data-table__cell--right-align",property:"rate",formatter:"rate"}],u=[{label:$.t("Currency"),className:"",property:"currency"},{label:$.t("Total Margin"),className:"tv-data-table__cell--right-align",property:"total_margin",formatter:"fixed"},{label:$.t("OTE"),className:"tv-data-table__cell--right-align",property:"ote",formatter:"fixed",help:$.t("Open trade equity")},{label:$.t("MVO"),className:"tv-data-table__cell--right-align",property:"mvo",formatter:"fixed",help:$.t("Market value of options")},{label:$.t("Purchasing Power"),className:"tv-data-table__cell--right-align",property:"purchasing_power",formatter:"fixed"}],d=[{label:$.t("Symbol"),className:"tv-data-table__cell--symbol-cell",property:"symbol",formatter:"symbol"},{label:$.t("Side"),className:"",property:"side",formatter:"side"},{label:$.t("Qty"),className:"tv-data-table__cell--right-align",property:"qty",help:$.t("Size in lots")},{label:$.t("Avg Price"),className:"tv-data-table__cell--right-align",property:"avg_price",formatter:"formatAvgPrice"},{label:$.t("OTE/MVO"),className:"tv-data-table__cell--right-align",property:"open_pl",formatter:"fixed",help:$.t("Current open trade equity / market value of options")},{label:$.t("UPL"),className:"tv-data-table__cell--right-align",property:"upl",formatter:"fixed",help:$.t("Unrealized profit/loss for options")},{label:$.t("MVO"),className:"tv-data-table__cell--right-align",property:"mvo",formatter:"fixed",help:$.t("Market value of options")},{label:$.t("Currency"),className:"",property:"currency"},{label:"",className:"tv-data-table__cell--buttons-cell",formatter:"posSettings",notSortable:!0}];s.prototype._positionProfitHandler=function(e){this._tables.positions.addRow(e)},s.prototype._changeAccount=function(e){var t=this._connection.getAccountData(e.id);t.positions.forEach(function(e){this._connection.subscribePositionProfit(e,this._positionProfitHandler,this)},this),t.positions=t.positions.filter(function(e){return 0!==e.qty}),this._tables.positions.getRows().forEach(function(e){this._connection.unsubscribePositionProfit(e,this._positionProfitHandler,this)},this);for(var i in t)this._tables[i].deleteRows(),this._tables[i].addRows(t[i]);this._tables.orders.getRows().forEach(function(e){var t=this._broker.trading().hideCompletedOrders.value()&&!this._isOrderStatusActive(e.status);e.row.toggleClass("tv-data-table__stroke--hide",t),e.row.toggleClass("tv-data-table__stroke--grayed",!this._isOrderStatusActive(e.status))},this),this._resolver.tv2cqg($44.proSymbol.value()||$44.symbol.value()).done(function(e){this.selectActiveSymbol(e)}.bind(this)),this.ordCount.text(this._tables.orders.getRows().length),this.posCount.text(this._tables.positions.getRows().length)},s.prototype._isOrderStatusActive=function(e){return"In transit"===e||"Active At"===e||"Working"===e||"In modify"===e},s.prototype._splitThousands=function(e){var t=(e+"").split(".");return t[0].replace(/\B(?=(\d{3})+(?!\d))/g," ")+(t[1]?"."+t[1]:"")},s.prototype._updateAccount=function(e){var i=this;this.$container.empty(),this._flatAccounts=e;var r=$("
").addClass("head-wrapper").appendTo(this.$container),o=$("
").addClass("group").appendTo(r);$("
").addClass("title").text("CQG "+this._connection.server()+":").appendTo(o);var s=this._broker.activeAccount.value().name,o=$("
").addClass("group").appendTo(r),c=$("
").addClass("acc-wrapper").append($("
").addClass("caption").text(s)).appendTo(o);if(this._flatAccounts.length>1){this._broker.activeAccount.subscribe(this._changeacc);var p=function(){return i._flatAccounts.map(function(e){return{title:e.name,action:function(){$(".acc-wrapper.dropdown .caption").text(e.name),i._broker.activeAccount.setValue(e)},active:e==i._broker.activeAccount.value()}})};c.addClass("dropdown"),TradingView.bindPopupMenu(c,p,{direction:"down",notCloseOnButtons:!0,addClass:"account-selector"})}var f=$("
").addClass("select-wrapper").appendTo(r);this.posCount=$("").addClass("count-label").text("0"),this.ordCount=$("").addClass("count-label").text("0");var h=$("
    ").addClass("tabs").appendTo(f);$("
  • ").addClass("tabs-label").text($.t("Orders")).append(this.ordCount).appendTo(h),$("
  • ").addClass("tabs-label").text($.t("Positions")).append(this.posCount).appendTo(h),$("
  • ").addClass("tabs-label").text($.t("Account Summary")).appendTo(h);var m=$("
    ").addClass("content-wrapper").appendTo(this.$container),_=$("
    ").addClass("page orders-page").appendTo(m),g=$("
    ").addClass("page positions-page").appendTo(m),y=$("
    ").addClass("page account-summary-page").appendTo(m);i.tabs=new $70(h,m);var v=this._resolver,b=function(e){var r=[{name:"symbol",cb:function(e){var i=$(t.render(TradingView.templates.tvDataTableCell,{contain:e}));return i.on("click",function(){v.cqg2tv(e).done(function(e){$44.symbol.setValue(e)})}),i}},{name:"side",cb:function(e){var i=$(t.render(TradingView.templates.tvDataTableCell,{contain:e}));return"buy"==e.toLowerCase()?i.addClass("tv-data-table__blue-text"):i.addClass("tv-data-table__light-red-text"),i}},{name:"formatPrice",cb:function(e,r){var n=$(t.render(TradingView.templates.tvDataTableCell,{contain:e?i._splitThousands(r.format(e)):""}));return n}},{name:"formatAvgPrice",cb:function(e,r){var n=$(t.render(TradingView.templates.tvDataTableCell,{contain:i._splitThousands(r.formatAvgPrice(e))}));return n}},{name:"date",cb:function(e){var i=$(t.render(TradingView.templates.tvDataTableCell,{contain:e?moment(e).format("D MMM YYYY, H:mm:ss"):""}));return i}},{name:"fixed",cb:function(e,r){var n=$(t.render(TradingView.templates.tvDataTableCell,{contain:i._splitThousands((e||0).toFixed(2))}));return n}},{name:"rate",cb:function(e,i){var r=$(t.render(TradingView.templates.tvDataTableCell,{contain:void 0!==e?e.toFixed(4):""}));return r}},{name:"orderSettings",cb:function(e){var r=$(t.render(TradingView.templates.tvDataTableCell,{}));if(i._isOrderStatusActive(e.status)){$("").addClass("tv-data-table__button").attr("title",$.t("Edit Order")).append(svgAsset("properties","12x12")).appendTo(r).on("click",function(t){t.preventDefault(),i._broker.getOrderDialog().open(e,!0)}),$("").addClass("tv-data-table__button").attr("title",$.t("Cancel Order")).append(svgAsset("close-cross","12x12")).appendTo(r).on("click",function(t){t.preventDefault(),i._broker.cancelOrder(e)})}return r}},{name:"posSettings",cb:function(e){var r=$(t.render(TradingView.templates.tvDataTableCell,{}));$("").addClass("tv-data-table__button").attr("title",$.t("Close Position")).append(svgAsset("close-cross","12x12")).appendTo(r).on("click",function(t){t.preventDefault(),i._broker.closePosition(e)});return r}}];r=r.sort(function(e,t){var i=e.name,r=t.name;return r>i?-1:i>r?1:0});var n=[];e.map(function(e){return e.formatter}).sort().forEach(function(e){!e||n.length&&n[n.length-1]==e||n.push(e)});for(var o=[],s=0,a=0;s").text(r.title).appendTo(e);var o=t.render(TradingView.templates.tvDataTable,{columns:i,className:"tv-data-table--trading-cqg "+r.className,bodys:[{className:""}]});$(o).appendTo(e),this.head=r.className?$(e).find("."+r.className+" thead"):$(e).find("thead"),this.body=r.className?$(e).find("."+r.className+" tbody"):$(e).find("tbody"),i.forEach(function(e,t){var i=n.head.find("tr").children()[t];$(i).find(".tv-data-table__sortable").on("click",function(e){e.preventDefault(),n.head.find(".tv-data-table__sortable--asc, .tv-data-table__sortable--desc").removeClass("tv-data-table__sortable--asc tv-data-table__sortable--desc"),n.idx==t?n.asc=!n.asc:(n.idx=t,n.asc=!1),$(this).addClass(n.asc?"tv-data-table__sortable--desc":"tv-data-table__sortable--asc"),n._sortView()})},this),this.head.find("th:eq("+this.idx+") .tv-data-table__sortable").addClass("tv-data-table__sortable--asc")};i.prototype.defFormatter=function(e){var i=t.render(TradingView.templates.tvDataTableCell,{contain:e});return $(i)},i.prototype.addRow=function(e,i){var r=this.data.filter(function(t){return t[this.idProperty]==e[this.idProperty]},this)[0];if(r)return this.updateRow(r,e,i);e=this._copy({},e);for(var n,o,s=this.data.length;s--;)-1==this._compare(e,this.data[s])&&(n=this.data[s],o=s);var a=t.render(TradingView.templates.tvDataTableRow,{});n?(this.data.splice(o,0,e),e.row=$(a).insertBefore(n.row)):(this.data.push(e),e.row=$(a).appendTo(this.body));var l=e.priceFormatter;this.columns.forEach(function(t){var i=this.formatters[t.formatter]?this.formatters[t.formatter]:this.defFormatter,r=t.property?e[t.property]:e;i(r,l).addClass(t.className).appendTo(e.row)},this),"function"==typeof i&&i(e)},i.prototype.addRows=function(e){e.forEach(function(e){this.addRow(e)},this)},i.prototype.deleteRow=function(e){var t=this.data.filter(function(t){return t[this.idProperty]==e[this.idProperty]},this)[0];t&&(t.row.remove(),this.data.splice(this.data.indexOf(t),1))},i.prototype.deleteRows=function(){this.data.forEach(function(e){e.row.remove()}),this.data=[]},i.prototype.updateRow=function(e,t,i){if(!e)throw Error("row not exist");var r=!1,n=e.priceFormatter;this.columns.forEach(function(i,o){if(!i.property||e[i.property]!=t[i.property]){o==this.idx&&(r=!0),e[i.property]=t[i.property];var s=e.row.find("td:eq("+o+")"),a=this.formatters[i.formatter]?this.formatters[i.formatter]:this.defFormatter,l=i.property?e[i.property]:e;a(l,n).addClass(i.className).insertBefore(s),s.remove()}},this),r&&this._sortView(),e=this._copy(e,t),"function"==typeof i&&i(e)},i.prototype.getRows=function(){return this.data},i.prototype.addFormatter=function(e,t){this.formatters[e]=t},i.prototype.addFormatters=function(e){e.forEach(function(e){this.addFormatter(e.name,e.cb)},this)},i.prototype._copy=function(e,t){for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i]);return e},i.prototype._compare=function(e,t){var i=this.columns[this.idx].sortProp||this.columns[this.idx].property,r=e[i]||"",n=t[i]||"",o=0;if(this._group&&"function"==typeof this._group){var s=this._group(e),a=this._group(t);o=a>s?1:s>a?-1:0}if(o||(o=n>r?1:r>n?-1:0,this.asc&&(o=-o)),!o){var i=this.columns[0].sortProp||this.columns[0].property;r=e[i]||"",n=t[i]||"",o=n>r?1:r>n?-1:0}return o},i.prototype._sortView=function(){this.data.sort(this._compare.bind(this));for(var e=null,t=this.data.length;t--;){var i=this.data[t].row[0];e&&e.parentNode.insertBefore(i,e),e=i}},e.exports=i}).call(t,i(29))},327:function(e,t,i){(function(t){"use strict";var i=function(e,i){var r=this,n='
    {{#options}}
    {{{toptions}}}
    {{/options}}
    {{#brokers}}{{/brokers}}{{#tdemolink}}{{/tdemolink}}
    ',o={cqglogosource:TradingView.wrapUrl("images/svg/cqg.svg"),cqglogowidth:150,cqglogoheight:35,username:TVSettings.getValue("trading.cqg.username",""),brokers:i.availableBrokers().length>1,tusername:$.t("Username"),tpassword:$.t("Password"),treal:$.t("Live"),tdemo:$.t("Demo"),tconnect:$.t("Connect"),tbrokers:$.t("or choose another broker"),timagehelp:$.t("Connect to CQG"),options:W75.enabled("cqg_trading_confirm_risks"),toptions:$.t('By clicking "Connect" I confirm I\'ve read the warning and terms of use and accept all risks.')};this._content=$(t.render(n,o)),this._content.find(".select-broker a").on("click",function(e){e.preventDefault(),i.selectBroker(void 0)});var s=TVSettings.getInt("trading.cqg.server",0),a=this._content.find(".type-selector");["real","demo"].forEach(function(e,t){a.find("a."+e).toggleClass("active",t==s).on("click",function(e){e.preventDefault(),s=t,a.find("a").removeClass("active"),$(this).addClass("active")})}),this._submitHandler=function(t){t.preventDefault();var i=r._content.find('[name="cqg_username"]').val().trim(),n=r._content.find('[name="cqg_password"]').val().trim();return i&&n?(TVSettings.setValue("trading.cqg.username",i), +webpackJsonp([1,4],{322:function(e,t,i){"use strict";var r=i(323),n=i(324),o=i(325),s=i(328),a=i(339),l=i(340),u=i(341),d=i(342),c=i(343),p=i(338),f=function(e){this.activeAccount=new WatchedValue,this._trading=e,this._chartWidgetControllers=[],this._resolver=new n(this)};f.prototype.id=function(){return"CQG"},f.prototype.trading=function(){return this._trading},f.prototype.createAccountManager=function(e){return new o(e,this)},f.prototype.connect=function(){var e=this;this._connection=new s(this),this._connection.onMustChangePassword.subscribe(null,function(){d.get(e).open({title:$.t("Your Password Has Expired"),allowCancel:!1,message:$.t("Your password has expired, please enter new password")})})},f.prototype.disconnect=function(){this._connection.disconnect(),this._chartWidgetControllers.forEach(function(e){e.controller&&e.controller.reset()}),this._chartWidgetControllers=[]},f.prototype.connection=function(){return this._connection||this.connect(),this._connection},f.prototype.buttonDropdownOptions=function(e){var t=this.connection().connectStatus()==r.CONNECTED,i=this;if(t){var n=[{title:$.t("Show Buy/Sell Panel"),icon:{image:"url('"+TradingView.wrapUrl("images/dialogs/checkbox.png")+"')",offset:i.trading().hideFloatingPanel.value()?"":"0 -16px"},action:function(){i.trading().hideFloatingPanel.setValue(!i.trading().hideFloatingPanel.value())}},{title:$.t("Show Active Orders Only"),icon:{image:"url('"+TradingView.wrapUrl("images/dialogs/checkbox.png")+"')",offset:i.trading().hideCompletedOrders.value()?"0 -16px":""},action:function(){i.trading().hideCompletedOrders.setValue(!i.trading().hideCompletedOrders.value())}},{separator:!0},{title:$.t("Trading Properties"),action:function(){i.trading().showTradingProperties()}},{separator:!0},{title:$.t("Disconnect"),action:function(){i.disconnect()}},{title:$.t("Change Password"),disabled:!t,action:function(){d.get(i).open({title:$.t("Change Password"),allowCancel:!0})}}];return D75.enabled("charting_library_base")||(n.push({separator:!0}),n.push({title:$.t("Select Broker"),action:function(){i.trading().selectBroker()}})),n}return[{title:$.t("Select Broker"),action:function(){i.trading().selectBroker()}}]},f.prototype.formatter=function(e){return new p(e)},f.prototype.createProfitLossEmitter=function(e){return{}},f.prototype.registerChartWidget=function(e){var t={widget:e};this._chartWidgetControllers.push(t);var i=this;e.model().model().mainSeries().onSymbolResolved().subscribe(null,function(){r()}),i.activeAccount.subscribe(function(){r()});var r=function(){var r=e.model().model().mainSeries().symbolInfo();if(r){var n=r.pro_name;i._resolver.tv2cqg(n).done(function(r){i.activeAccount.when(function(){if(i.trading().getActiveBroker()==i){var n=i.activeAccount.value().id;t.controller?t.controller.setCQGSymbol(r,n):t.controller=new a(e,r,n,i)}})}).fail(function(){t.controller&&i.activeAccount.when(function(){t.controller.setCQGSymbol("",i.activeAccount.value().id)})})}};t.controllerCreator=r,r()},f.prototype.unregisterChartWidget=function(e){for(var t=this._chartWidgetControllers.length-1;t>=0;--t){var i=this._chartWidgetControllers[t];if(i.widget==e){i.controller&&i.controller.reset(),this._chartWidgetControllers.splice(t,1),e.model().model().mainSeries().onSymbolResolved().unsubscribe(null,i.controllerCreator),e.model().model().mainSeries().onCompleted().unsubscribe(null,i.controllerCreator);break}}},f.prototype.supportFloatingPanel=function(){return!0},f.prototype.closePosition=function(e){var t=this,i={account_id:e.account_id,qty:e.qty,side:"Buy"==e.side?"Sell":"Buy",symbol:e.symbol,type:"Market",duration:{type:"DAY"},executionOptions:{}};this.trading().noConfirmEnabled.value()?this.connection().resolveSymbol(i.symbol).done(function(e){i.contract_id=e.contract_metadata.contract_id,t.connection().placeOrder(i)}):l.get(t).open(i)},f.prototype.cancelOrder=function(e){var t=this;this.trading().noConfirmEnabled.value()?t.connection().cancelOrder(e):c.get().open(e).done(function(){t.connection().cancelOrder(e)})},f.prototype.getOrderDialog=function(){var e=this;return{open:function(t,i){if(e.connection().connectStatus()!=r.CONNECTED)return e.trading().onOpenBottomWidgetBar.fire(),e.trading().onNeedAttention.fire(),$.Deferred().reject().promise();var n=$.Deferred();if(i){var o=t&&t.symbol;e._connection.isTradable(o).done(function(i){i?(t.account_id=t.account_id?t.account_id:e.activeAccount.value().id,l.get(e).open(t).done(function(){n.resolve()}).fail(function(){n.reject()})):(e.getUntradableDialog().open(s),n.reject())})}else{var s=t&&t.symbol;e._resolver.tv2cqg(s).done(function(i){e._connection.isTradable(i).done(function(r){if(r){var o=TradingView.clone(t);o.symbol=i,o.tvSymbol=s,o.account_id=o.account_id?o.account_id:e.activeAccount.value().id,l.get(e).open(o).done(function(){n.resolve()}).fail(function(){n.reject()})}else e.getUntradableDialog().open(s),n.reject()})}).fail(function(){e.getUntradableDialog().open(s),n.reject()})}return n.promise()}}},f.prototype.getUntradableDialog=function(){return u.get()},f.prototype.resolver=function(){return this._resolver},f.prototype.chartContextMenuActions=function(e,t){var i=NaN,r=this,n=NaN,o=1,s="",a="",l="";if(e){a=e.proSymbol(),l=(e.symbolInfo()||{}).name||a;var u=e.priceScale();if(t){if(i=u.coordinateToPrice(t.localY),u.isPercentage()){var d=e.firstValue();i=void 0!==d?u.priceRange().convertFromPercent(i,d):null}s=e.formatter().format(i)}var c=e.bars().last();c&&(n=c.value[TradingView.CLOSE_PLOT]);var p=this.connection();p&&(o=+p.suggestedQty().value(a),(0>o||!isFinite(o))&&(o=1))}var f=[],h=r.activeAccount.value()&&r.activeAccount.value().id;if(n>i){var m=new TradingView.Action({text:"Buy "+l+" Limit "+TradingView.abbreviatedNumber(o)+" @ "+s});m.callbacks().subscribe(null,function(){r.getOrderDialog().open({account_id:h,symbol:a,formatted_limit_price:s,side:"Buy",type:"Limit",qty:o,noConfirm:!0})}),f.push(m);var m=new TradingView.Action({text:"Sell "+l+" Stop "+TradingView.abbreviatedNumber(o)+" @ "+s});m.callbacks().subscribe(null,function(){r.getOrderDialog().open({account_id:h,symbol:a,formatted_stop_price:s,side:"Sell",type:"Stop",qty:o,noConfirm:!0})}),f.push(m)}else if(i>n){var m=new TradingView.Action({text:"Sell "+l+" Limit "+TradingView.abbreviatedNumber(o)+" @ "+s});m.callbacks().subscribe(null,function(){r.getOrderDialog().open({account_id:h,symbol:a,formatted_limit_price:s,side:"Sell",type:"Limit",qty:o,noConfirm:!0})}),f.push(m);var m=new TradingView.Action({text:"Buy "+l+" Stop "+TradingView.abbreviatedNumber(o)+" @ "+s});m.callbacks().subscribe(null,function(){r.getOrderDialog().open({account_id:h,symbol:a,formatted_stop_price:s,side:"Buy",type:"Stop",qty:o,noConfirm:!0})}),f.push(m)}var m=new TradingView.Action({text:"Create New Order..."});return m.callbacks().subscribe(null,function(){r.getOrderDialog().open({account_id:h,qty:o,symbol:a})}),f.push(m),f},f.prototype.getSymbolInfo=function(e){var t=this,i=$.Deferred();return t._resolver.tv2cqg(e).done(function(e){t.connection().resolveSymbol(e).done(function(e){i.resolve({realtimeContractId:e.contract_metadata.contract_id,formatter:t.formatter(e.contract_metadata)})}).fail(function(e){i.reject(e)})}).fail(function(e){i.reject(e)}),i},e.exports=f},324:function(e,t){"use strict";var i=function(e){this._cache2tv={},this._cache2cqg={},this._broker=e};i.prototype.tv2cqg=function(e){var t=this,i=$.Deferred();if(this._cache2cqg[e]){var r=this._cache2cqg[e];setTimeout(function(){"SYMBOL_NOT_FOUND"==r?i.reject():i.resolve(r)},0)}else $.get("/cqg_mapping/2cqg/"+e+"/").done(function(r){var n=r.symbol;r.error?(t._cache2cqg[e]="SYMBOL_NOT_FOUND",i.reject()):(t._cache2cqg[e]=n,i.resolve(n))});return i.promise()},i.prototype.cqg2tv=function(e){var t=$.Deferred(),i=this._cache2tv[e];if(i)setTimeout(function(){"SYMBOL_NOT_FOUND"==i?t.reject():t.resolve(i)},0);else{var r=this;$.get("/cqg_mapping/2tv/"+e+"/").done(function(i){var n=i.symbol;i.error?(r._cache2tv[e]="SYMBOL_NOT_FOUND",t.reject()):(r._cache2tv[e]=n,t.resolve(n))})}return t.promise()},e.exports=i},325:function(e,t,i){(function(t){"use strict";var r=i(323),n=i(326),o=i(327),s=function(e,t){this._broker=t,this._connection=t.connection(),this._resolver=t.resolver(),this.$container=$(document.createElement("div")),this.$container.appendTo(e.$body).addClass("cqg-trading"),this.height=e.height,this.minimized=e.minimized,this.properties=e.properties,this.body=e.$body,this._connection.onStatusChanged.subscribe(this,s.prototype._updateContentPanel),this._contextMenuHandler=this._onContextMenu.bind(this),this._changeacc=s.prototype._changeAccount.bind(this),this._changesymbol=s.prototype._updateSymbol.bind(this),this._updateContentPanel({status:this._connection.connectStatus()}),this._broker.trading().onNeedAttention.subscribe(this,this.drawAttention)};s.prototype.selectActiveSymbol=function(e){this._tables.orders.getRows().forEach(function(t){t.row.toggleClass("tv-data-table__stroke--active",t.symbol==e)}),this._tables.positions.getRows().forEach(function(t){t.row.toggleClass("tv-data-table__stroke--active",t.symbol==e)})},s.prototype.connect=function(){this._connection.onBalance.subscribe(this,s.prototype._updateBalance),this._connection.onCollateral.subscribe(this,s.prototype._updateCollaterals),this._connection.onOrderUpdate.subscribe(this,s.prototype._updateOrder),this._connection.onPositionUpdate.subscribe(this,s.prototype._updatePosition)},s.prototype.disconnect=function(){this._broker.activeAccount.unsubscribe(this._changeacc),this._ordersHandler&&this._broker.trading().hideCompletedOrders.unsubscribe(this._ordersHandler),this.body.off("contextmenu",this._contextMenuHandler),$44.proSymbol.unsubscribe(this._changesymbol),this._connection.onBalance.unsubscribe(this,s.prototype._updateBalance),this._connection.onCollateral.unsubscribe(this,s.prototype._updateCollaterals),this._connection.onOrderUpdate.unsubscribe(this,s.prototype._updateOrder),this._connection.onPositionUpdate.unsubscribe(this,s.prototype._updatePosition)},s.prototype.remove=function(){this._tables&&this._tables.positions.getRows().forEach(function(e){e.plCalculator&&e.plCalculator.stop()}),delete this._tables,this.$container.remove(),this.disconnect(),this._connection.onStatusChanged.unsubscribe(this,s.prototype._updateContentPanel)},s.prototype._updateContentPanel=function(e){if(this._tables&&this._tables.positions.getRows().forEach(function(e){e.plCalculator&&(e.plCalculator.stop(),delete e.plCalculator)}),this._flatAccounts=[],this.$container.empty(),this._spinner&&(this._spinner.stop(),delete this._spinner),this._spinnerContainer&&(this._spinnerContainer.remove(),delete this._spinnerContainer),e.status==r.ERROR||e.status==r.DISCONNECT){this.disconnect(),e.message&&$("
    ").addClass("trading-connection-error-message").text(e.message).appendTo(this.$container);var t=new o(this._connection,this._broker.trading());this.$container.append(t.content()),t.focus(),this._loginForm=t}else this._loginForm=null;e.status==r.CONNECTING&&(this._spinnerContainer=$(document.createElement("div")).addClass("spinner-container").appendTo(this.$container),this._spinner=TradingView.unifiedSpinner().spin(this._spinnerContainer.get(0))),e.status==r.CONNECTED&&(this.connect(),this._updateAccount(this._connection.flatAccounts()),this._changeAccount(this._broker.activeAccount.value()))};var a=[{label:$.t("Symbol"),className:"tv-data-table__cell--symbol-cell",property:"symbol",formatter:"symbol"},{label:$.t("Side"),className:"",property:"side",formatter:"side"},{label:$.t("Type"),className:"",property:"type"},{label:$.t("Limit Price"),className:"tv-data-table__cell--right-align",property:"limit_price",sortProp:"real_limit_price",formatter:"formatPrice"},{label:$.t("Stop Price"),className:"tv-data-table__cell--right-align",property:"stop_price",sortProp:"real_stop_price",formatter:"formatPrice"},{label:$.t("Qty"),className:"tv-data-table__cell--right-align",property:"qty",help:$.t("Size in lots")},{label:$.t("Status"),className:"",property:"status"},{label:$.t("Active At"),className:"",property:"activate_at",formatter:"date"},{label:$.t("Avg Fill Price"),className:"tv-data-table__cell--right-align",property:"avg_fill_price",sortProp:"real_avg_fill_price",formatter:"formatPrice"},{label:$.t("Fill Qty"),className:"tv-data-table__cell--right-align",property:"fill_qty"},{label:$.t("Placing Time"),className:"",property:"placing_time",formatter:"date"},{label:$.t("Order id"),className:"",property:"order_id"},{label:"",className:"tv-data-table__cell--buttons-cell",formatter:"orderSettings",notSortable:!0}],l=[{label:$.t("Currency"),property:"currency"},{label:$.t("Account Balance"),className:"tv-data-table__cell--right-align",property:"account_balance",formatter:"fixed",help:$.t("Total account balance")},{label:$.t("OTE/MVO"),className:"tv-data-table__cell--right-align",property:"ote_mvo",formatter:"fixed",help:$.t("Open trade equity (market value of options)")},{label:$.t("P/L"),className:"tv-data-table__cell--right-align",property:"pl",formatter:"fixed",help:$.t("Current day profit/loss")},{label:$.t("OTE/MVO+P/L"),className:"tv-data-table__cell--right-align",property:"ote_mvo_pl",formatter:"fixed",help:$.t("Open trade equity (market value of options) and current day profit/loss")},{label:$.t("Prev Day Balance"),className:"tv-data-table__cell--right-align",property:"balance",formatter:"fixed",help:$.t("Previous day account balance")},{label:$.t("Collateral"),className:"tv-data-table__cell--right-align",property:"collateral",formatter:"fixed",help:$.t("Collateral on deposit")},{label:$.t("NLV"),className:"tv-data-table__cell--right-align",property:"nlv",formatter:"fixed",help:$.t("Net liquidity value of account")},{label:$.t("UPL"),className:"tv-data-table__cell--right-align",property:"upl",formatter:"fixed",help:$.t("Unrealized profit/loss for options")},{label:$.t("MVO"),className:"tv-data-table__cell--right-align",property:"mvo",formatter:"fixed",help:$.t("Market value of options")},{label:$.t("Cash Excess"),className:"tv-data-table__cell--right-align",property:"cash_excess",formatter:"fixed"},{label:$.t("Currency Rate"),className:"tv-data-table__cell--right-align",property:"rate",formatter:"rate"}],u=[{label:$.t("Currency"),className:"",property:"currency"},{label:$.t("Total Margin"),className:"tv-data-table__cell--right-align",property:"total_margin",formatter:"fixed"},{label:$.t("OTE"),className:"tv-data-table__cell--right-align",property:"ote",formatter:"fixed",help:$.t("Open trade equity")},{label:$.t("MVO"),className:"tv-data-table__cell--right-align",property:"mvo",formatter:"fixed",help:$.t("Market value of options")},{label:$.t("Purchasing Power"),className:"tv-data-table__cell--right-align",property:"purchasing_power",formatter:"fixed"}],d=[{label:$.t("Symbol"),className:"tv-data-table__cell--symbol-cell",property:"symbol",formatter:"symbol"},{label:$.t("Side"),className:"",property:"side",formatter:"side"},{label:$.t("Qty"),className:"tv-data-table__cell--right-align",property:"qty",help:$.t("Size in lots")},{label:$.t("Avg Price"),className:"tv-data-table__cell--right-align",property:"avg_price",formatter:"formatAvgPrice"},{label:$.t("OTE/MVO"),className:"tv-data-table__cell--right-align",property:"open_pl",formatter:"fixed",help:$.t("Current open trade equity / market value of options")},{label:$.t("UPL"),className:"tv-data-table__cell--right-align",property:"upl",formatter:"fixed",help:$.t("Unrealized profit/loss for options")},{label:$.t("MVO"),className:"tv-data-table__cell--right-align",property:"mvo",formatter:"fixed",help:$.t("Market value of options")},{label:$.t("Currency"),className:"",property:"currency"},{label:"",className:"tv-data-table__cell--buttons-cell",formatter:"posSettings",notSortable:!0}];s.prototype._positionProfitHandler=function(e){this._tables.positions.addRow(e)},s.prototype._changeAccount=function(e){var t=this._connection.getAccountData(e.id);t.positions.forEach(function(e){this._connection.subscribePositionProfit(e,this._positionProfitHandler,this)},this),t.positions=t.positions.filter(function(e){return 0!==e.qty}),this._tables.positions.getRows().forEach(function(e){this._connection.unsubscribePositionProfit(e,this._positionProfitHandler,this)},this);for(var i in t)this._tables[i].deleteRows(),this._tables[i].addRows(t[i]);this._tables.orders.getRows().forEach(function(e){var t=this._broker.trading().hideCompletedOrders.value()&&!this._isOrderStatusActive(e.status);e.row.toggleClass("tv-data-table__stroke--hide",t),e.row.toggleClass("tv-data-table__stroke--grayed",!this._isOrderStatusActive(e.status))},this),this._resolver.tv2cqg($44.proSymbol.value()||$44.symbol.value()).done(function(e){this.selectActiveSymbol(e)}.bind(this)),this.ordCount.text(this._tables.orders.getRows().length),this.posCount.text(this._tables.positions.getRows().length)},s.prototype._isOrderStatusActive=function(e){return"In transit"===e||"Active At"===e||"Working"===e||"In modify"===e},s.prototype._splitThousands=function(e){var t=(e+"").split(".");return t[0].replace(/\B(?=(\d{3})+(?!\d))/g," ")+(t[1]?"."+t[1]:"")},s.prototype._updateAccount=function(e){var i=this;this.$container.empty(),this._flatAccounts=e;var r=$("
    ").addClass("head-wrapper").appendTo(this.$container),o=$("
    ").addClass("group").appendTo(r);$("
    ").addClass("title").text("CQG "+this._connection.server()+":").appendTo(o);var s=this._broker.activeAccount.value().name,o=$("
    ").addClass("group").appendTo(r),c=$("
    ").addClass("acc-wrapper").append($("
    ").addClass("caption").text(s)).appendTo(o);if(this._flatAccounts.length>1){this._broker.activeAccount.subscribe(this._changeacc);var p=function(){return i._flatAccounts.map(function(e){return{title:e.name,action:function(){$(".acc-wrapper.dropdown .caption").text(e.name),i._broker.activeAccount.setValue(e)},active:e==i._broker.activeAccount.value()}})};c.addClass("dropdown"),TradingView.bindPopupMenu(c,p,{direction:"down",notCloseOnButtons:!0,addClass:"account-selector"})}var f=$("
    ").addClass("select-wrapper").appendTo(r);this.posCount=$("").addClass("count-label").text("0"),this.ordCount=$("").addClass("count-label").text("0");var h=$("
      ").addClass("tabs").appendTo(f);$("
    • ").addClass("tabs-label").text($.t("Orders")).append(this.ordCount).appendTo(h),$("
    • ").addClass("tabs-label").text($.t("Positions")).append(this.posCount).appendTo(h),$("
    • ").addClass("tabs-label").text($.t("Account Summary")).appendTo(h);var m=$("
      ").addClass("content-wrapper").appendTo(this.$container),_=$("
      ").addClass("page orders-page").appendTo(m),g=$("
      ").addClass("page positions-page").appendTo(m),y=$("
      ").addClass("page account-summary-page").appendTo(m);i.tabs=new $70(h,m);var v=this._resolver,b=function(e){var r=[{name:"symbol",cb:function(e){var i=$(t.render(TradingView.templates.tvDataTableCell,{contain:e}));return i.on("click",function(){v.cqg2tv(e).done(function(e){$44.symbol.setValue(e)})}),i}},{name:"side",cb:function(e){var i=$(t.render(TradingView.templates.tvDataTableCell,{contain:e}));return"buy"==e.toLowerCase()?i.addClass("tv-data-table__blue-text"):i.addClass("tv-data-table__light-red-text"),i}},{name:"formatPrice",cb:function(e,r){var n=$(t.render(TradingView.templates.tvDataTableCell,{contain:e?i._splitThousands(r.format(e)):""}));return n}},{name:"formatAvgPrice",cb:function(e,r){var n=$(t.render(TradingView.templates.tvDataTableCell,{contain:i._splitThousands(r.formatAvgPrice(e))}));return n}},{name:"date",cb:function(e){var i=$(t.render(TradingView.templates.tvDataTableCell,{contain:e?moment(e).format("D MMM YYYY, H:mm:ss"):""}));return i}},{name:"fixed",cb:function(e,r){var n=$(t.render(TradingView.templates.tvDataTableCell,{contain:i._splitThousands((e||0).toFixed(2))}));return n}},{name:"rate",cb:function(e,i){var r=$(t.render(TradingView.templates.tvDataTableCell,{contain:void 0!==e?e.toFixed(4):""}));return r}},{name:"orderSettings",cb:function(e){var r=$(t.render(TradingView.templates.tvDataTableCell,{}));if(i._isOrderStatusActive(e.status)){$("").addClass("tv-data-table__button").attr("title",$.t("Edit Order")).append(svgAsset("properties","12x12")).appendTo(r).on("click",function(t){t.preventDefault(),i._broker.getOrderDialog().open(e,!0)}),$("").addClass("tv-data-table__button").attr("title",$.t("Cancel Order")).append(svgAsset("close-cross","12x12")).appendTo(r).on("click",function(t){t.preventDefault(),i._broker.cancelOrder(e)})}return r}},{name:"posSettings",cb:function(e){var r=$(t.render(TradingView.templates.tvDataTableCell,{}));$("").addClass("tv-data-table__button").attr("title",$.t("Close Position")).append(svgAsset("close-cross","12x12")).appendTo(r).on("click",function(t){t.preventDefault(),i._broker.closePosition(e)});return r}}];r=r.sort(function(e,t){var i=e.name,r=t.name;return r>i?-1:i>r?1:0});var n=[];e.map(function(e){return e.formatter}).sort().forEach(function(e){!e||n.length&&n[n.length-1]==e||n.push(e)});for(var o=[],s=0,a=0;s").text(r.title).appendTo(e);var o=t.render(TradingView.templates.tvDataTable,{columns:i,className:"tv-data-table--trading-cqg "+r.className,bodys:[{className:""}]});$(o).appendTo(e),this.head=r.className?$(e).find("."+r.className+" thead"):$(e).find("thead"),this.body=r.className?$(e).find("."+r.className+" tbody"):$(e).find("tbody"),i.forEach(function(e,t){var i=n.head.find("tr").children()[t];$(i).find(".tv-data-table__sortable").on("click",function(e){e.preventDefault(),n.head.find(".tv-data-table__sortable--asc, .tv-data-table__sortable--desc").removeClass("tv-data-table__sortable--asc tv-data-table__sortable--desc"),n.idx==t?n.asc=!n.asc:(n.idx=t,n.asc=!1),$(this).addClass(n.asc?"tv-data-table__sortable--desc":"tv-data-table__sortable--asc"),n._sortView()})},this),this.head.find("th:eq("+this.idx+") .tv-data-table__sortable").addClass("tv-data-table__sortable--asc")};i.prototype.defFormatter=function(e){var i=t.render(TradingView.templates.tvDataTableCell,{contain:e});return $(i)},i.prototype.addRow=function(e,i){var r=this.data.filter(function(t){return t[this.idProperty]==e[this.idProperty]},this)[0];if(r)return this.updateRow(r,e,i);e=this._copy({},e);for(var n,o,s=this.data.length;s--;)-1==this._compare(e,this.data[s])&&(n=this.data[s],o=s);var a=t.render(TradingView.templates.tvDataTableRow,{});n?(this.data.splice(o,0,e),e.row=$(a).insertBefore(n.row)):(this.data.push(e),e.row=$(a).appendTo(this.body));var l=e.priceFormatter;this.columns.forEach(function(t){var i=this.formatters[t.formatter]?this.formatters[t.formatter]:this.defFormatter,r=t.property?e[t.property]:e;i(r,l).addClass(t.className).appendTo(e.row)},this),"function"==typeof i&&i(e)},i.prototype.addRows=function(e){e.forEach(function(e){this.addRow(e)},this)},i.prototype.deleteRow=function(e){var t=this.data.filter(function(t){return t[this.idProperty]==e[this.idProperty]},this)[0];t&&(t.row.remove(),this.data.splice(this.data.indexOf(t),1))},i.prototype.deleteRows=function(){this.data.forEach(function(e){e.row.remove()}),this.data=[]},i.prototype.updateRow=function(e,t,i){if(!e)throw Error("row not exist");var r=!1,n=e.priceFormatter;this.columns.forEach(function(i,o){if(!i.property||e[i.property]!=t[i.property]){o==this.idx&&(r=!0),e[i.property]=t[i.property];var s=e.row.find("td:eq("+o+")"),a=this.formatters[i.formatter]?this.formatters[i.formatter]:this.defFormatter,l=i.property?e[i.property]:e;a(l,n).addClass(i.className).insertBefore(s),s.remove()}},this),r&&this._sortView(),e=this._copy(e,t),"function"==typeof i&&i(e)},i.prototype.getRows=function(){return this.data},i.prototype.addFormatter=function(e,t){this.formatters[e]=t},i.prototype.addFormatters=function(e){e.forEach(function(e){this.addFormatter(e.name,e.cb)},this)},i.prototype._copy=function(e,t){for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i]);return e},i.prototype._compare=function(e,t){var i=this.columns[this.idx].sortProp||this.columns[this.idx].property,r=e[i]||"",n=t[i]||"",o=0;if(this._group&&"function"==typeof this._group){var s=this._group(e),a=this._group(t);o=a>s?1:s>a?-1:0}if(o||(o=n>r?1:r>n?-1:0,this.asc&&(o=-o)),!o){var i=this.columns[0].sortProp||this.columns[0].property;r=e[i]||"",n=t[i]||"",o=n>r?1:r>n?-1:0}return o},i.prototype._sortView=function(){this.data.sort(this._compare.bind(this));for(var e=null,t=this.data.length;t--;){var i=this.data[t].row[0];e&&e.parentNode.insertBefore(i,e),e=i}},e.exports=i}).call(t,i(29))},327:function(e,t,i){(function(t){"use strict";var i=function(e,i){var r=this,n='
      {{#options}}
      {{{toptions}}}
      {{/options}}
      {{#brokers}}{{/brokers}}{{#tdemolink}}{{/tdemolink}}
      ',o={cqglogosource:TradingView.wrapUrl("images/svg/cqg.svg"),cqglogowidth:150,cqglogoheight:35,username:TVSettings.getValue("trading.cqg.username",""),brokers:i.availableBrokers().length>1,tusername:$.t("Username"),tpassword:$.t("Password"),treal:$.t("Live"),tdemo:$.t("Demo"),tconnect:$.t("Connect"),tbrokers:$.t("or choose another broker"),timagehelp:$.t("Connect to CQG"),options:D75.enabled("cqg_trading_confirm_risks"),toptions:$.t('By clicking "Connect" I confirm I\'ve read the warning and terms of use and accept all risks.')};this._content=$(t.render(n,o)),this._content.find(".select-broker a").on("click",function(e){e.preventDefault(),i.selectBroker(void 0)});var s=TVSettings.getInt("trading.cqg.server",0),a=this._content.find(".type-selector");["real","demo"].forEach(function(e,t){a.find("a."+e).toggleClass("active",t==s).on("click",function(e){e.preventDefault(),s=t,a.find("a").removeClass("active"),$(this).addClass("active")})}),this._submitHandler=function(t){t.preventDefault();var i=r._content.find('[name="cqg_username"]').val().trim(),n=r._content.find('[name="cqg_password"]').val().trim();return i&&n?(TVSettings.setValue("trading.cqg.username",i), TVSettings.setValue("trading.cqg.server",s),void e.connect(i,n,s)):r.drawAttention()},this._content.on("submit",this._submitHandler)};i.prototype.content=function(){return this._content},i.prototype.focus=function(){var e=this._content.find('[name="cqg_username"]');e.val()?this._content.find('[name="cqg_password"]').focus():e.focus()},i.prototype.drawAttention=function(){this.focus(),this._content.find('[name="cqg_password"], [name="cqg_username"]').filter(function(){return""===$(this).attr("value")}).highlight(4)},e.exports=i}).call(t,i(29))},328:function(e,t,i){"use strict";var r=i(329),n=i(323),o=i(336),s=i(337),a=i(337),l=i(338),u=!1,d="TradingView",c="TradingView",p="TradingView",f="TradingView",h=function(e){this.onStatusChanged=new Delegate,this.onMustChangePassword=new Delegate,this.onLoggedOff=new Delegate,this.onBalance=new Delegate,this.onCollateral=new Delegate,this.onOrderReject=new Delegate,this.onOrderUpdate=new Delegate,this.onPositionUpdate=new Delegate,this.onExecutionUpdate=new Delegate,this._broker=e,this._status=n.DISCONNECT,this._infoReqCounter=1,this._orderCounter=1,this._workingInformationRequests={},this._orderRequestsDeferreds={},this._orderRequests={},this._orders={},this._tradeSubscriptionDeffereds={},this._tradeScopeCompletion=[],this._positions=[],this._clientOrders=[],this._balances=[],this._collaterals=[],this._executions=[],this._contractInfo={},this._contractIdBySymbol={},this._contractResolvingBySymbol={},this._currency_rates={},this._subscribedContracts={},this._profitCallbacks={},this._profitHandlers={},this._historyRequests={},this._historyReports={},this._resolvedSessions={}};h.prototype._order2ClientOrder=function(e){function t(e){return e==o._api.Order.Side.BUY?"Buy":e==o._api.Order.Side.SELL?"Sell":void 0}function i(e){return e==o._api.Order.OrderType.MKT?"Market":e==o._api.Order.OrderType.LMT?"Limit":e==o._api.Order.OrderType.STP?"Stop":e==o._api.Order.OrderType.STL?"StopLimit":void 0}function r(e){return e==o._api.OrderStatus.Status.IN_TRANSIT?"In transit":e==o._api.OrderStatus.Status.REJECTED?"Rejected":e==o._api.OrderStatus.Status.WORKING?"Working":e==o._api.OrderStatus.Status.EXPIRED?"Expired":e==o._api.OrderStatus.Status.IN_CANCEL?"In cancel":e==o._api.OrderStatus.Status.IN_MODIFY?"In modify":e==o._api.OrderStatus.Status.CANCELLED?"Cancelled":e==o._api.OrderStatus.Status.FILLED?"Filled":e==o._api.OrderStatus.Status.SUSPENDED?"Suspended":e==o._api.OrderStatus.Status.DISCONNECTED?"Disconnected":e==o._api.OrderStatus.Status.ACTIVEAT?"Active At":void 0}function n(e){return e==o._api.Order.Duration.DAY?"DAY":e==o._api.Order.Duration.GTC?"GTC":e==o._api.Order.Duration.GTD?"GTD":e==o._api.Order.Duration.GTT?"GTT":e==o._api.Order.Duration.FAK?"FAK":e==o._api.Order.Duration.FAK?"FOK":e==o._api.Order.Duration.ATO?"ATO":e==o._api.Order.Duration.ATC?"ATC":void 0}var o=this,s=o._contractInfo[e.contract_id].formatter,a={account_id:e.account_id,order_id:e.chain_order_id,server_order_id:e.order_id,client_order_id:e.cl_order_id,symbol:e.contract_metadata.contract_symbol,side:t(e.side),qty:e.qty,type:i(e.order_type),limit_price:e.limit_price||0,stop_price:e.stop_price||0,status:r(e.status),priceFormatter:s,avg_fill_price:e.avg_fill_price||0,fill_qty:e.fill_qty,executionOptions:{},real_limit_price:s.realPrice(e.limit_price),real_stop_price:s.realPrice(e.stop_price),real_avg_fill_price:s.realPrice(e.avg_fill_price)};try{var l=e.when_utc_time.toNumber()+o._baseTime.valueOf();a.placing_time=new Date(l)}catch(u){}return e.active_at_utc_time&&(a.activate_at=new Date(e.active_at_utc_time.toNumber()+this._baseTime.valueOf())),(e.exec_instruction||[]).forEach(function(t){t==o._api.Order.ExecInstruction.AON&&(a.executionOptions.AON=!0),t==o._api.Order.ExecInstruction.ICEBERG&&(a.executionOptions.ICEBERG={visible_qty:e.visible_qty}),t==o._api.Order.ExecInstruction.QT&&(a.executionOptions.QTY_TRIGGER={quantity:e.trigger_qty}),t==o._api.Order.ExecInstruction.TRAIL&&(a.executionOptions.TRAILING={peg:e.trailing_peg,offset:e.trail_offset}),t==o._api.Order.ExecInstruction.FUNARI&&(a.executionOptions.FUNARI=!0),t==o._api.Order.ExecInstruction.MIT&&(a.executionOptions.MIT=!0),t==o._api.Order.ExecInstruction.MLM&&(a.executionOptions.MLM=!0)}),a.duration={type:n(e.duration)},e.good_thru_date&&(a.duration.gtd=e.good_thru_date.toNumber()+o._baseTime.valueOf()),e.good_thru_utc_time&&(a.duration.gtt=e.good_thru_utc_time.toNumber()+o._baseTime.valueOf()),a.aggressivity=e.is_aggressive,a.open_close=e.is_close?"leave":"enter",a},h.prototype._compare=function(e,t){return void 0===e||void 0===t?!0:e==t},h.prototype._getterFactory=function(e){return function(t){return e.filter(function(e){return this._compare(e.symbol,t)&&this._compare(e.account_id,this._broker.activeAccount.value().id)},this)}.bind(this)},h.prototype.getOrders=function(){return this._getterFactory(this._clientOrders).apply(this,arguments)},h.prototype.getPositions=function(){return this._getterFactory(this._positions).apply(this,arguments)},h.prototype.getExecutions=function(){return this._getterFactory(this._executions).apply(this,arguments)},h.prototype.getCollaterals=function(){return this._collaterals.filter(function(e){return e.account_id==this._broker.activeAccount.value().id},this)},h.prototype.getBalances=function(){return this._balances.filter(function(e){return e.account_id==this._broker.activeAccount.value().id},this)},h.prototype.getBalance=function(e){return this._balances.filter(function(t){return t.account_id==this._broker.activeAccount.value().id&&t.currency==e},this)[0]},h.prototype.getAccountData=function(){return{orders:this.getOrders(),positions:this.getPositions(),collaterals:this.getCollaterals(),balances:this.getBalances()}},h.prototype._addAccountData=function(e){return e=e||{},e.accounts=this.flatAccounts(),e.server=this._server,e},h.prototype._timeToDateObject=function(e){return new Date(1e3*e.low)},h.prototype.connectStatus=function(){return this._status},h.prototype._initTransport=function(e){var t=r.loadJson(e);this._api={Logon:t.build("WebAPI_1.Logon"),LogonResult:t.build("WebAPI_1.LogonResult"),Logoff:t.build("WebAPI_1.Logoff"),LoggedOff:t.build("WebAPI_1.Logoff"),PasswordChange:t.build("WebAPI_1.PasswordChange"),ClientMsg:t.build("WebAPI_1.ClientMsg"),ServerMessage:t.build("WebAPI_1.ServerMsg"),InformationRequest:t.build("WebAPI_1.InformationRequest"),InformationReport:t.build("WebAPI_1.InformationReport"),SymbolResolutionRequest:t.build("WebAPI_1.SymbolResolutionRequest"),AccountsRequest:t.build("WebAPI_1.AccountsRequest"),TradeSubscription:t.build("WebAPI_1.TradeSubscription"),LastStatementBalancesRequest:t.build("WebAPI_1.LastStatementBalancesRequest"),Order:t.build("WebAPI_1.Order"),OrderStatus:t.build("WebAPI_1.OrderStatus"),OrderRequest:t.build("WebAPI_1.OrderRequest"),NewOrder:t.build("WebAPI_1.NewOrder"),MarketDataSubscription:t.build("WebAPI_1.MarketDataSubscription"),Quote:t.build("WebAPI_1.Quote"),CancelOrder:t.build("WebAPI_1.CancelOrder"),ModifyOrder:t.build("WebAPI_1.ModifyOrder"),CurrencyRatesRequest:t.build("WebAPI_1.CurrencyRatesRequest"),RealTimeCollapsing:t.build("WebAPI_1.RealTimeCollapsing"),ProtocolVersionMinor:t.build("WebAPI_1.ProtocolVersionMinor"),ProtocolVersionMajor:t.build("WebAPI_1.ProtocolVersionMajor"),PasswordChangeResult:t.build("WebAPI_1.PasswordChangeResult"),HistoricalOrdersRequest:t.build("WebAPI_1.HistoricalOrdersRequest"),TimeBarRequest:t.build("WebAPI_1.TimeBarRequest"),TimeBarParameters:t.build("WebAPI_1.TimeBarParameters"),SessionInformationRequest:t.build("WebAPI_1.SessionInformationRequest"),SessionInformationReport:t.build("WebAPI_1.SessionInformationReport"),SessionInfo:t.build("WebAPI_1.SessionInfo")},this._api.RestoreSession=t.build("WebAPI_1.RestoreOrJoinSession"),this._api.RestoreSessionResult=t.build("WebAPI_1.RestoreOrJoinSessionResult")},h.prototype.setServerDemo=function(){this._server={type:"Demo",address:"wss://demoapi.cqg.com:443",client_id:c,private_label:f},this._initTransport(a)},h.prototype.setServerReal=function(){this._server={type:"Real",address:"wss://api.cqg.com:443",client_id:d,private_label:p},this._initTransport(s)},h.prototype.createSocket=function(e){this._status=n.CONNECTING,this.onStatusChanged.fire({status:n.CONNECTING}),this._socket&&(this._socket.onclose=function(){},this._socket.close()),this._socket=new WebSocket(this._server.address),this._socket.binaryType="arraybuffer";var t=this;this._socket.onopen=e,this._socket.onmessage=function(e){t._onMessage(e)},this._socket.onclose=function(){t._socket=null,t._status!==n.DISCONNECT&&(t._status=n.DISCONNECT,t.onStatusChanged.fire({status:n.DISCONNECT}))}},h.prototype.selectServerByIndex=function(e){switch(e){case 0:this.setServerReal();break;case 1:this.setServerDemo();break;default:this.setServerDemo()}},h.prototype.connect=function(e,t,i){var r=this;this._username=e,this.selectServerByIndex(i),this.createSocket(function(){r._onConnected({username:e,password:t}),t=void 0})},h.prototype.userName=function(){return this._username},h.prototype.restoreSession=function(e,t,i){var r=this;this.selectServerByIndex(t),this.createSocket(function(){r._restoreSession({token:e})}),this._username=i},h.prototype._clearCache=function(){this._workingInformationRequests={},this._orderRequestsDeferreds={},this._orderRequests={},this._orders={},this._positions=[],this._clientOrders=[],this._balances=[],this._collaterals=[],this._executions=[],this._contractInfo={},this._contractIdBySymbol={},this._contractResolvingBySymbol={},this._subscribedContracts={},this._profitCallbacks={},this._profitHandlers={}},h.prototype.disconnect=function(){var e=this;delete e._server,e._clearCache(),e._socket&&e.logoff().done(function(){e._socket.onclose=function(){},e._socket.onmessage=function(){},e._socket.close(),delete e._socket,e._status=n.DISCONNECT,e.onStatusChanged.fire({status:n.DISCONNECT}),e._historyRequests={},e._historyReports={}})},h.prototype._send=function(e){TradingView.logNormal("CQG.Send.:"+JSON.stringify(e),"CQG"),this._socket.send(e.toArrayBuffer())},h.prototype.flatAccounts=function(){return this._flatAccounts},h.prototype.server=function(){return this._server.type},h.prototype.logoff=function(){if(this._logoffDeferred)throw"cannot logoff until previous try completed";this._logoffDeferred=$.Deferred();var e=new this._api.Logoff,t=new this._api.ClientMsg({logoff:e});return this._send(t),this._logoffDeferred.promise()},h.prototype.changePassword=function(e,t){if(this._passwordChangeDeferred)throw"Cannot change password until previous try completed";this._passwordChangeDeferred=$.Deferred();var i=new this._api.PasswordChange(e,t),r=new this._api.ClientMsg({password_change:i});return this._send(r),this._passwordChangeDeferred.promise()},h.prototype._nextRequestId=function(){return this._infoReqCounter++},h.prototype.nextOrderId=function(){return"order_"+(new Date).valueOf()},h.prototype.requestAccount=function(){var e=new this._api.AccountsRequest,t=new this._api.InformationRequest({accounts_request:e,id:this._nextRequestId()});return this._sendInformationRequest(t)},h.prototype.requestHistoricalData=function(){var e=new this._api.HistoricalOrdersRequest({from_date:-6912e5}),t=new this._api.InformationRequest({historical_orders_request:e,id:this._nextRequestId()});return this._sendInformationRequest(t)},h.prototype.requestCurrencyRates=function(){var e=new this._api.CurrencyRatesRequest,t=new this._api.InformationRequest({currency_rates_request:e,id:this._nextRequestId()});return this._sendInformationRequest(t)},h.prototype.requestBalance=function(){var e=new this._api.InformationRequest({last_statement_balances_request:new this._api.LastStatementBalancesRequest,id:this._nextRequestId(),subscribe:!0});return this._sendInformationRequest(e)},h.prototype.subscribeTradeInfo=function(){var e=new this._api.TradeSubscription({publication_type:this._api.TradeSubscription.PublicationType.ALL_AUTHORIZED,subscription_scope:[this._api.TradeSubscription.SubscriptionScope.ORDERS,this._api.TradeSubscription.SubscriptionScope.POSITIONS,this._api.TradeSubscription.SubscriptionScope.COLLATERAL],subscribe:!0,id:this._nextRequestId()}),t=$.Deferred();this._tradeSubscriptionDeffereds[e.id]=t;var i=new this._api.ClientMsg({trade_subscription:[e]});return this._send(i),t.promise()},h.prototype.requestSessionInfo=function(e){var t=$.Deferred(),i=this;if(void 0!==this._resolvedSessions[e]){if(void 0!==this._resolvedSessions[e].done)return this._resolvedSessions[e];setTimeout(function(){t.resolve(i._resolvedSessions[e])},0)}else{var r=new this._api.SessionInformationRequest(e),n=new this._api.InformationRequest({session_information_request:r,id:this._nextRequestId()});this._resolvedSessions[e]=t,this._sendInformationRequest(n).done(function(r){t.resolve(r.session_information_report),i._resolvedSessions[e]=r.session_information_report}).fail(function(e){$71.sendReport("cqg_trading",this._addAccountData()),t.reject({code:e.status_code,message:e.text_message})})}return t.promise()},h.prototype.resolveSymbol=function(e){if(this._contractResolvingBySymbol[e])return this._contractResolvingBySymbol[e];var t=$.Deferred(),i=this;if(void 0!==this._contractIdBySymbol[e]&&void 0!==this._contractInfo[this._contractIdBySymbol[e]])return setTimeout(function(){t.resolve({contract_metadata:i._contractInfo[i._contractIdBySymbol[e]]})},0),t.promise();var r=new this._api.SymbolResolutionRequest(e),n=new this._api.InformationRequest({symbol_resolution_request:r,id:this._nextRequestId()});return this._sendInformationRequest(n).done(function(r){var n=r.symbol_resolution_report.contract_metadata;i._storeContractInfo(n),i._contractIdBySymbol[e]=n.contract_id,delete i._contractResolvingBySymbol[e],t.resolve(r.symbol_resolution_report)}).fail(function(r){delete i._contractResolvingBySymbol[e],$71.sendReport("cqg_trading",i._addAccountData()),t.reject({code:r.status_code,message:r.text_message})}),this._contractResolvingBySymbol[e]=t.promise(),this._contractResolvingBySymbol[e]},h.prototype.subscribeRealtime=function(e,t){if(this._subscribedContracts[e])this._subscribedContracts[e].listeners.push(t),Object.keys(this._contractInfo[e].snapshot).length&&setTimeout(function(){t(this._contractInfo[e].snapshot)}.bind(this),0);else{this._subscribedContracts[e]={listeners:[t]};var i=new this._api.MarketDataSubscription({contract_id:e,level:this._api.MarketDataSubscription.Level.TRADES_BBA}),r=new this._api.ClientMsg({market_data_subscription:[i]});this._send(r)}},h.prototype.unsubscribeRealtime=function(e,t){if(this._subscribedContracts[e]){var i=this._subscribedContracts[e];if(i.listeners=i.listeners.filter(function(e){return e!=t}),!i.listeners.length&&(delete this._subscribedContracts[e],this._socket)){var r=new this._api.MarketDataSubscription({contract_id:e,level:this._api.MarketDataSubscription.Level.NONE}),n=new this._api.ClientMsg({market_data_subscription:[r]});this._send(n)}}},h.prototype._isOption=function(e){return/^C\..+$/.test(e)},h.prototype._profitHandler=function(e,t){var i=e.priceFormatter,r=e.open_pl,n=e.upl,o=e.mvo,s="Sell"==e.side?-1:1,a=i.realPrice(t.trade||t.settlement||t.yesterday_settlement),l=a-e.avg_price;if(e.open_pl=s*e.qty*i.priceInCurr(l),this._isOption(e.symbol)?(e.upl=e.open_pl,e.open_pl=e.mvo=s*e.qty*i.priceInCurr(a)):(e.mvo=0,e.upl=0),e.open_pl!=r||e.mvo!=o||e.upl!=n){var u=this._profitCallbacks[e.symbol+e.account_id];u.forEach(function(t){t.cb.call(t.ctx,e)}),this._updateBalance(e)}},h.prototype.subscribePositionProfit=function(e,t,i){var r=e.contract_id,n=e.symbol+e.account_id;e.qty&&(this._profitCallbacks[n]?this._profitCallbacks[n].push({cb:t,ctx:i}):this._profitCallbacks[n]=[{cb:t,ctx:i}],this._profitHandlers[n]||(this._profitHandlers[n]=this._profitHandler.bind(this,e),this.subscribeRealtime(r,this._profitHandlers[n])))},h.prototype.unsubscribePositionProfit=function(e,t,i){var r=e.contract_id,n=e.symbol+e.account_id,o=this._profitCallbacks[n]||[];o=o.filter(function(e){return e.cb!=t&&e.ctx!=i}),0===o.length?(delete this._profitCallbacks[n],this.unsubscribeRealtime(r,this._profitHandlers[n]),delete this._profitHandlers[n]):this._profitCallbacks[n]=o},h.prototype.requestHistory=function(e,t,i,r,n){var o=$.Deferred(),s=new this._api.TimeBarParameters({contract_id:e,bar_unit:t,from_utc_time:r-this._baseTime.valueOf(),to_utc_time:n-this._baseTime.valueOf()});i&&(s.units_number=i);var a=new this._api.TimeBarRequest({request_id:this._nextRequestId(),time_bar_parameters:s,request_type:1});this._historyRequests[a.request_id]=o;var l=new this._api.ClientMsg({time_bar_request:[a]});return this._send(l),o.promise()},h.prototype._parseDuration=function(e){return{DAY:this._api.Order.Duration.DAY,GTC:this._api.Order.Duration.GTC,GTD:this._api.Order.Duration.GTD,GTT:this._api.Order.Duration.GTT,FAK:this._api.Order.Duration.FAK,FOK:this._api.Order.Duration.FOK,ATO:this._api.Order.Duration.ATO,ATC:this._api.Order.Duration.ATC}[e]},h.prototype.modifyOrder=function(e){TradingView.trackEvent("CQG "+this.server(),"modify order");var t={order_id:e.server_order_id,account_id:e.account_id,orig_cl_order_id:e.client_order_id,cl_order_id:this.nextOrderId(),when_utc_time:(new Date).valueOf()},i=this._orders[e.order_id];i.qty!=e.qty&&(t.qty=e.qty),e.executionOptions&&e.executionOptions.ICEBERG&&i.visible_qty!=e.executionOptions.ICEBERG.visible_qty&&(t.visible_qty=e.visible_qty),i.limit_price!=e.limit_price&&(t.limit_price=e.limit_price),i.stop_price!=e.stop_price&&(t.stop_price=e.stop_price);var r=this._parseDuration(e.duration.type);i.duration!=r&&(t.duration=r),i.good_thru_date!=e.duration.gtd&&(t.good_thru_date=e.duration.gtd-this._baseTime.valueOf()),i.good_thru_date!=e.duration.gtt&&(t.good_thru_utc_time=e.duration.gtt-this._baseTime.valueOf());var n=new this._api.ModifyOrder(t),o=new this._api.OrderRequest({request_id:this._nextRequestId(),modify_order:n}),s=new this._api.ClientMsg({order_request:[o]});this._orderRequests[o.request_id]=o,this._send(s);var a=$.Deferred();return this._orderRequestsDeferreds[t.cl_order_id]=a,a.promise()},h.prototype.placeOrder=function(e){function t(e){return{Market:o._api.Order.OrderType.MKT,Limit:o._api.Order.OrderType.LMT,Stop:o._api.Order.OrderType.STP,StopLimit:o._api.Order.OrderType.STL}[e]}function i(e){var t={AON:o._api.Order.ExecInstruction.AON,ICEBERG:o._api.Order.ExecInstruction.ICEBERG,QTY_TRIGGER:o._api.Order.ExecInstruction.QT,TRAILING:o._api.Order.ExecInstruction.TRAIL,FUNARI:o._api.Order.ExecInstruction.FUNARI,MIT:o._api.Order.ExecInstruction.MIT,MLM:o._api.Order.ExecInstruction.MLM},i=[];for(var r in e)i.push(t[r]);return i}function r(e){return{Sell:o._api.Order.Side.SELL,Buy:o._api.Order.Side.BUY}[e]}function n(e){return{bestbid:o._api.Order.TrailingPeg.BESTBID,bestask:o._api.Order.TrailingPeg.BESTASK,lasttrade:o._api.Order.TrailingPeg.LASTTRADE}[e]}var o=this;TradingView.trackEvent("CQG "+this.server(),"open order");var s={account_id:e.account_id,when_utc_time:(new Date).valueOf()-this._baseTime.valueOf(),contract_id:e.contract_id,cl_order_id:this.nextOrderId(),order_type:t(e.type),exec_instruction:i(e.executionOptions),duration:this._parseDuration(e.duration.type),side:r(e.side),qty:e.qty,is_manual:!0};"GTD"==e.duration.type&&(s.good_thru_date=e.duration.gtd-this._baseTime.valueOf()),"GTT"==e.duration.type&&(s.good_thru_utc_time=e.duration.gtt-this._baseTime.valueOf()),"Limit"!=e.type&&"StopLimit"!=e.type||(s.limit_price=e.limit_price),"Stop"!=e.type&&"StopLimit"!=e.type||(s.stop_price=e.stop_price),e.executionOptions.ICEBERG&&(s.visible_qty=e.executionOptions.ICEBERG.visible_qty),e.executionOptions.TRAILING&&(s.trail_offset=e.executionOptions.TRAILING.offset,s.trailing_peg=n(e.executionOptions.TRAILING.peg)),e.executionOptions.QTY_TRIGGER&&(s.trigger_qty=e.executionOptions.QTY_TRIGGER.quantity),"yes"==e.aggressivity&&(s.is_aggressive=!0),"no"==e.aggressivity&&(s.is_aggressive=!1),"enter"==e.open_close&&(s.is_close=!1),"leave"==e.open_close&&(s.is_close=!0);var a=new this._api.Order(s),l=new this._api.NewOrder({order:a}),u=new this._api.OrderRequest({request_id:this._nextRequestId(),new_order:l}),d=new this._api.ClientMsg({order_request:[u]});this._orderRequests[u.request_id]=u,this._send(d);var c=$.Deferred();return this._orderRequestsDeferreds[s.cl_order_id]=c,c.promise()},h.prototype.cancelOrder=function(e){TradingView.trackEvent("CQG "+this.server(),"cancel order");var t=new this._api.CancelOrder({order_id:e.server_order_id,account_id:e.account_id,orig_cl_order_id:e.client_order_id,cl_order_id:this.nextOrderId(),when_utc_time:(new Date).valueOf()}),i=new this._api.OrderRequest({request_id:this._nextRequestId(),cancel_order:t}),r=new this._api.ClientMsg({order_request:[i]});this._send(r)},h.prototype._storeContractInfo=function(e){this._contractInfo[e.contract_id]?$.extend(this._contractInfo[e.contract_id],e):(this._contractInfo[e.contract_id]=e,this._contractInfo[e.contract_id].snapshot={},this._contractInfo[e.contract_id].formatter=new l(e)),this._contractIdBySymbol[e.contract_symbol]=e.contract_id},h.prototype._onHistoryOrder=function(e){function t(e){return e==i._api.Order.Side.BUY?"buy":e==i._api.Order.Side.SELL?"sell":void 0}var i=this;if((e.contract_metadata||[]).forEach(function(e){i._storeContractInfo(e)}),e.status==this._api.OrderStatus.Status.FILLED){var r={id:e.order_id,qty:e.fill_qty,symbol:i._contractInfo[e.order.contract_id].contract_symbol,account_id:e.account_id,time:new Date(e.status_utc_time.toNumber()+i._baseTime.valueOf()),price:i._contractInfo[e.order.contract_id].formatter.format(e.avg_fill_price),side:t(e.order.side)};this._executions.push(r),this.onExecutionUpdate.fire(r)}},h.prototype._newBalance=function(e,t){return{account_id:e,account_balance:0,balance:0,cash_excess:0,collateral:0,currency:t,initial_margin:0,mvo:0,ote:0,nlv:0,ote_mvo:0,ote_mvo_pl:0,pl:0,total_value:0,rate:this._currency_rates[t],upl:0}},h.prototype._getTotalName=function(){return"TOTAL ("+this._master_currency+")"},h.prototype._addCurrencyToBalance=function(){this._balances.forEach(function(e){e.currency!=this._getTotalName()&&(e.rate=this._currency_rates[e.currency])},this)},h.prototype._onInformationReport=function(e){if(e.symbol_resolution_report){var t=e.symbol_resolution_report.contract_metadata;this._storeContractInfo(t)}if(this._workingInformationRequests[e.id]&&(e.status_code==this._api.InformationReport.StatusCode.SUCCESS||e.status_code==this._api.InformationReport.StatusCode.SUBSCRIBED?this._workingInformationRequests[e.id].resolve(e):this._workingInformationRequests[e.id].reject(e),delete this._workingInformationRequests[e.id]),e.accounts_report){this._flatAccounts=[],e.accounts_report.brokerage.forEach(function(e){e.sales_series.forEach(function(t){t.account.forEach(function(i){this._flatAccounts.push({brokerage_name:e.name,series_name:t.name,name:i.name,id:i.account_id})},this)},this)},this),this._flatAccounts.sort(function(e,t){return e.namer||s>n;)o>r&&s>n&&e[r].id==t[n].id?(i.push(t[n++]),r++):r>=o&&s>n||o>r&&s>n&&e[r].id>t[n].id?i.push(t[n++]):i.push(e[r++]);return i}var i=this,r=e.contract_metadata;r?i._storeContractInfo(r):r=this._contractInfo[e.contract_id];var n=this._positions.filter(function(t){return t.symbol==r.contract_symbol&&t.account_id==e.account_id})[0],o={};o.purchase_and_sales_group=n?n.purchase_and_sales_group:[],o.open_positions=n?n.open_positions:[];n?n.open_positions:[];e.open_position.forEach(function(e){if(0===e.qty)o.open_positions=o.open_positions.filter(function(t){return t.id!=e.id});else{var t=o.open_positions.filter(function(t){return t.id==e.id})[0];t?t.qty=e.qty:o.open_positions.push(e)}});var s=0,a=0;o.open_positions.forEach(function(e){0===e.qty&&(a=0);var t;t="sell"==o.side?-e.qty:e.qty,a+=t,s+=t*e.price}),o.purchase_and_sales_group=t(o.purchase_and_sales_group,e.purchase_and_sales_group),o.account_id=e.account_id,o.side=e.is_short_open_position?"Sell":"Buy",o.qty=a,o.avg_price=a?s/a:0,o.symbol=r.contract_symbol,o.contract_id=r.contract_id,o.currency=r.currency,o.priceFormatter=i._contractInfo[o.contract_id].formatter,n?(o=$.extend(n,o),0===o.qty?(TradingView.trackEvent("CQG "+this.server(),"close position"),this._updateBalance(o)):TradingView.trackEvent("CQG "+this.server(),"open position")):(TradingView.trackEvent("CQG "+this.server(),"open position"),this._positions.push(o)),this.onPositionUpdate.fire(o);var l=this._balances.filter(function(e){return e.account_id==o.account_id&&e.currency==o.currency});0===l.length?(l=this._newBalance(o.account_id,o.currency),this._balances.push(l)):l=l[0];var u=o.profit||0;o.profit=o.purchase_and_sales_group.map(function(e){return e.realized_profit_loss}).reduce(function(e,t){return e+t},0),l.pl=l.pl+o.profit-u,l.ote_mvo_pl=l.pl+l.ote_mvo,l.nlv=l.balance+l.ote_mvo_pl,l.account_balance=l.pl+l.balance,setTimeout(function(){this.onBalance.fire(l),this._updateTotal(o.account_id)}.bind(this),0)},h.prototype._updateTotal=function(e){var t=this._balances.filter(function(t){return t.currency==this._getTotalName()&&t.account_id==e},this)[0];if(t){var i=this._balances.filter(function(t){return t.currency!=this._getTotalName()&&t.account_id==e},this),r=["balance","upl","mvo","cash_excess","collateral","account_balance","nlv","pl","ote_mvo","ote_mvo_pl"];r.forEach(function(e){t[e]=i.reduce(function(t,i){return t+i[e]*i.rate},0)}),this.onBalance.fire(t)}},h.prototype._updateBalance=function(e){var t=this.getBalance(e.currency),i=this._positions.filter(function(t){return e.account_id==t.account_id&&e.currency==t.currency&&t.qty},this);t.ote_mvo=i.reduce(function(e,t){ return e+t.open_pl||0},0),t.upl=i.reduce(function(e,t){return e+t.upl||0},0),t.mvo=i.reduce(function(e,t){return e+t.mvo||0},0),t.ote_mvo_pl=t.ote_mvo+t.pl,t.nlv=t.balance+t.ote_mvo_pl,setTimeout(function(){this.onBalance.fire(t),this._updateTotal(e.account_id)}.bind(this),0)},h.prototype._calcChange=function(e,t,i){if(t){var r=i-t;0!==r&&(e.change=r,e.changePercent=e.change/t)}},h.prototype._convertDate=function(e){return new Date(e.toNumber()+this._baseTime.valueOf())},h.prototype._isTradable=function(e){if(this._contractInfo[e].last_trading_date){var t=60*Math.floor((new Date).valueOf()/864e5)*60*1e3*24;return this._convertDate(this._contractInfo[e].last_trading_date).valueOf()>=t}return!0},h.prototype.isTradable=function(e){var t=$.Deferred(),i=this;return this.resolveSymbol(e).done(function(e){t.resolve(i._isTradable(e.contract_metadata.contract_id))}),t.promise()},h.prototype._onRealtime=function(e){function t(e){return null!==e?e:void 0}function i(e,i){return{open:t(e.open_price),high:t(e.high_price),low:t(e.low_price),close:t(e.close_proce),yesterday_settlement:t(e.yesterday_settlement),volume:t(e.total_volume),prev_close:t(e.yesterday_close),is_tradable:i}}var r=this;if(this._subscribedContracts[e.contract_id]){var n=this._contractInfo[e.contract_id].snapshot;if(null!==e.is_snapshot){var o=n.close;n=$.extend(n,i(e.market_values,this._isTradable(e.contract_id))),this._calcChange(n,o,n.close)}e.quote.forEach(function(e){e.type==r._api.Quote.Type.TRADE?(n.trade=e.price,n.size=e.volume,n.trade_date=e.quote_utc_time):e.type==r._api.Quote.Type.BESTBID?(n.bid=e.price,n.bid_size=e.volume,n.bid_date=e.quote_utc_time):e.type==r._api.Quote.Type.BESTASK?(n.ask=e.price,n.ask_size=e.volume,n.ask_date=e.quote_utc_time):e.type==r._api.Quote.Type.SETTLEMENT&&(n.settlement=e.price,n.settlement_size=e.volume,n.settlement_date=e.quote_utc_time),e.session_ohlc_indicator.forEach(function(t){switch(t){case r._api.Quote.SessionOhlcIndicator.OPEN:n.open=e.price;break;case r._api.Quote.SessionOhlcIndicator.HIGH:n.high=e.price;break;case r._api.Quote.SessionOhlcIndicator.LOW:n.low=e.price;break;case r._api.Quote.SessionOhlcIndicator.CLOSE:n.close!==e.price&&(r._calcChange(n,n.close,e.price),n.close=e.price)}})}),this._subscribedContracts[e.contract_id].listeners.forEach(function(e){e(n)})}},h.prototype._preprocessBars=function(e){for(var t=0;t0?(void 0===this._historyReports[e.request_id]&&(this._historyReports[e.request_id]=[]),this._historyReports[e.request_id]=this._historyReports[e.request_id].concat(this._preprocessBars(e.time_bar)),e.is_report_complete&&(this._historyRequests[e.request_id].resolve(this._historyReports[e.request_id]),delete this._historyReports[e.request_id])):(this._historyRequests[e.request_id].reject({code:e.status_code,message:e.text_message}),void 0!==this._historyReports[e.request_id]&&delete this._historyReports[e.request_id]))},h.prototype._onMessage=function(e){function t(e){return function(t){return TradingView.logNormal("CQG.Receive.:"+JSON.stringify(t),"CQG"),e.call(i,t)}}var i=this,r=this._api.ServerMessage.decode(e.data);r.logon_result&&t(this._onLogonResult)(r.logon_result),r.restore_or_join_session_result&&t(this._onLogonResult)(r.restore_or_join_session_result),r.password_change_result&&t(this._onPasswordChangeResult)(r.password_change_result),r.logged_off&&t(this._onLoggedOff)(r.logged_off);var i=this;(r.time_bar_report||[]).forEach(function(e){t(i._onHistoryReport)(e)}),(r.information_report||[]).forEach(function(e){t(i._onInformationReport)(e)}),(r.order_request_reject||[]).forEach(function(e){t(i._onOrderReject)(e)}),(r.trade_subscription_status||[]).forEach(function(e){t(i._onTradeSubscriptionStatus)(r.rep)}),(r.trade_snapshot_completion||[]).forEach(function(e){t(i._onTradeSnapshotCompletion)(e)}),(r.order_status||[]).forEach(function(e){t(i._onOrderStatus)(e)}),(r.position_status||[]).forEach(function(e){t(i._onPositionStatus)(e)}),(r.collateral_status||[]).forEach(function(e){i._onCollateralStatus(e)}),(r.real_time_market_data||[]).forEach(function(e){i._onRealtime(e)})},h.prototype.suggestedQty=function(){if(!this._suggestedQty){var e=new Delegate;this._suggestedQty={changed:e,value:function t(e,i){var r=1,t=TVSettings.getValue(o.QTY+e);return(null==t||0>=t||!isFinite(t))&&(t=r),+t},setValue:function(t,i){TVSettings.setValue(o.QTY+t,i),e.fire(t)}}}return this._suggestedQty},e.exports=h},329:function(e,t,i){var r,n,o;(function(e,s){!function(e,a){i(331).amd?(n=[i(332)],r=a,o="function"==typeof r?r.apply(t,n):r,!(void 0!==o&&(s.exports=o))):"object"==typeof s&&s&&s.exports?s.exports=a(i(332),!0):(e.dcodeIO=e.dcodeIO||{}).ProtoBuf=a(e.dcodeIO.ByteBuffer)}(this,function(t,r){"use strict";var n={};return n.ByteBuffer=t,n.Long=t.Long||null,n.VERSION="5.0.1",n.WIRE_TYPES={},n.WIRE_TYPES.VARINT=0,n.WIRE_TYPES.BITS64=1,n.WIRE_TYPES.LDELIM=2,n.WIRE_TYPES.STARTGROUP=3,n.WIRE_TYPES.ENDGROUP=4,n.WIRE_TYPES.BITS32=5,n.PACKABLE_WIRE_TYPES=[n.WIRE_TYPES.VARINT,n.WIRE_TYPES.BITS64,n.WIRE_TYPES.BITS32],n.TYPES={int32:{name:"int32",wireType:n.WIRE_TYPES.VARINT,defaultValue:0},uint32:{name:"uint32",wireType:n.WIRE_TYPES.VARINT,defaultValue:0},sint32:{name:"sint32",wireType:n.WIRE_TYPES.VARINT,defaultValue:0},int64:{name:"int64",wireType:n.WIRE_TYPES.VARINT,defaultValue:n.Long?n.Long.ZERO:void 0},uint64:{name:"uint64",wireType:n.WIRE_TYPES.VARINT,defaultValue:n.Long?n.Long.UZERO:void 0},sint64:{name:"sint64",wireType:n.WIRE_TYPES.VARINT,defaultValue:n.Long?n.Long.ZERO:void 0},bool:{name:"bool",wireType:n.WIRE_TYPES.VARINT,defaultValue:!1},"double":{name:"double",wireType:n.WIRE_TYPES.BITS64,defaultValue:0},string:{name:"string",wireType:n.WIRE_TYPES.LDELIM,defaultValue:""},bytes:{name:"bytes",wireType:n.WIRE_TYPES.LDELIM,defaultValue:null},fixed32:{name:"fixed32",wireType:n.WIRE_TYPES.BITS32,defaultValue:0},sfixed32:{name:"sfixed32",wireType:n.WIRE_TYPES.BITS32,defaultValue:0},fixed64:{name:"fixed64",wireType:n.WIRE_TYPES.BITS64,defaultValue:n.Long?n.Long.UZERO:void 0},sfixed64:{name:"sfixed64",wireType:n.WIRE_TYPES.BITS64,defaultValue:n.Long?n.Long.ZERO:void 0},"float":{name:"float",wireType:n.WIRE_TYPES.BITS32,defaultValue:0},"enum":{name:"enum",wireType:n.WIRE_TYPES.VARINT,defaultValue:0},message:{name:"message",wireType:n.WIRE_TYPES.LDELIM,defaultValue:null},group:{name:"group",wireType:n.WIRE_TYPES.STARTGROUP,defaultValue:null}},n.MAP_KEY_TYPES=[n.TYPES.int32,n.TYPES.sint32,n.TYPES.sfixed32,n.TYPES.uint32,n.TYPES.fixed32,n.TYPES.int64,n.TYPES.sint64,n.TYPES.sfixed64,n.TYPES.uint64,n.TYPES.fixed64,n.TYPES.bool,n.TYPES.string,n.TYPES.bytes],n.ID_MIN=1,n.ID_MAX=536870911,n.convertFieldsToCamelCase=!1,n.populateAccessors=!0,n.populateDefaults=!0,n.Util=function(){var t={};return t.IS_NODE=!("object"!=typeof e||e+""!="[object process]"||e.browser),t.XHR=function(){for(var e=[function(){return new XMLHttpRequest},function(){return new ActiveXObject("Msxml2.XMLHTTP")},function(){return new ActiveXObject("Msxml3.XMLHTTP")},function(){return new ActiveXObject("Microsoft.XMLHTTP")}],t=null,i=0;i]/g,RULE:/^(?:required|optional|repeated|map)$/,TYPE:/^(?:double|float|int32|uint32|sint32|int64|uint64|sint64|fixed32|sfixed32|fixed64|sfixed64|bool|string|bytes)$/,NAME:/^[a-zA-Z_][a-zA-Z_0-9]*$/,TYPEDEF:/^[a-zA-Z][a-zA-Z_0-9]*$/,TYPEREF:/^(?:\.?[a-zA-Z_][a-zA-Z_0-9]*)+$/,FQTYPEREF:/^(?:\.[a-zA-Z][a-zA-Z_0-9]*)+$/,NUMBER:/^-?(?:[1-9][0-9]*|0|0[xX][0-9a-fA-F]+|0[0-7]+|([0-9]*(\.[0-9]*)?([Ee][+-]?[0-9]+)?)|inf|nan)$/,NUMBER_DEC:/^(?:[1-9][0-9]*|0)$/,NUMBER_HEX:/^0[xX][0-9a-fA-F]+$/,NUMBER_OCT:/^0[0-7]+$/,NUMBER_FLT:/^([0-9]*(\.[0-9]*)?([Ee][+-]?[0-9]+)?|inf|nan)$/,BOOL:/^(?:true|false)$/i,ID:/^(?:[1-9][0-9]*|0|0[xX][0-9a-fA-F]+|0[0-7]+)$/,NEGID:/^\-?(?:[1-9][0-9]*|0|0[xX][0-9a-fA-F]+|0[0-7]+)$/,WHITESPACE:/\s/,STRING:/(?:"([^"\\]*(?:\\.[^"\\]*)*)")|(?:'([^'\\]*(?:\\.[^'\\]*)*)')/g,STRING_DQ:/(?:"([^"\\]*(?:\\.[^"\\]*)*)")/g,STRING_SQ:/(?:'([^'\\]*(?:\\.[^'\\]*)*)')/g},n.DotProto=function(e,t){function i(e,i){var r=-1,n=1;if("-"==e.charAt(0)&&(n=-1,e=e.substring(1)),t.NUMBER_DEC.test(e))r=parseInt(e);else if(t.NUMBER_HEX.test(e))r=parseInt(e.substring(2),16);else{if(!t.NUMBER_OCT.test(e))throw Error("illegal id value: "+(0>n?"-":"")+e);r=parseInt(e.substring(1),8)}if(r=n*r|0,!i&&0>r)throw Error("illegal id value: "+(0>n?"-":"")+e);return r}function r(e){var i=1;if("-"==e.charAt(0)&&(i=-1,e=e.substring(1)),t.NUMBER_DEC.test(e))return i*parseInt(e,10);if(t.NUMBER_HEX.test(e))return i*parseInt(e.substring(2),16);if(t.NUMBER_OCT.test(e))return i*parseInt(e.substring(1),8);if("inf"===e)return i*(1/0);if("nan"===e)return NaN;if(t.NUMBER_FLT.test(e))return i*parseFloat(e);throw Error("illegal number value: "+(0>i?"-":"")+e)}function n(e,t,i){void 0===e[t]?e[t]=i:(Array.isArray(e[t])||(e[t]=[e[t]]),e[t].push(i))}var o={},s=function(e){this.source=e+"",this.index=0,this.line=1,this.stack=[],this._stringOpen=null},a=s.prototype;a._readString=function(){var e='"'===this._stringOpen?t.STRING_DQ:t.STRING_SQ;e.lastIndex=this.index-1;var i=e.exec(this.source);if(!i)throw Error("unterminated string");return this.index=e.lastIndex,this.stack.push(this._stringOpen),this._stringOpen=null,i[1]},a.next=function(){if(this.stack.length>0)return this.stack.shift();if(this.index>=this.source.length)return null;if(null!==this._stringOpen)return this._readString();var e,i,r;do{for(e=!1;t.WHITESPACE.test(r=this.source.charAt(this.index));)if("\n"===r&&++this.line,++this.index===this.source.length)return null;if("/"===this.source.charAt(this.index))if(++this.index,"/"===this.source.charAt(this.index)){for(;"\n"!==this.source.charAt(++this.index);)if(this.index==this.source.length)return null;++this.index,++this.line,e=!0}else{if("*"!==(r=this.source.charAt(this.index)))return"/";do{if("\n"===r&&++this.line,++this.index===this.source.length)return null;i=r,r=this.source.charAt(this.index)}while("*"!==i||"/"!==r);++this.index,e=!0}}while(e);if(this.index===this.source.length)return null;var n=this.index;t.DELIM.lastIndex=0;var o=t.DELIM.test(this.source.charAt(n++));if(!o)for(;n"),o=this.tn.next(),!t.NAME.test(o))throw Error("illegal message field name: "+o);s.name=o,this.tn.skip("="),s.id=i(this.tn.next()),o=this.tn.peek(),"["===o&&this._parseFieldOptions(s),this.tn.skip(";")}else if(n=void 0!==n?n:this.tn.next(),"group"===n){var a=this._parseMessage(e,s);if(!/^[A-Z]/.test(a.name))throw Error("illegal group name: "+a.name);s.type=a.name,s.name=a.name.toLowerCase(),this.tn.omit(";")}else{if(!t.TYPE.test(n)&&!t.TYPEREF.test(n))throw Error("illegal message field type: "+n);if(s.type=n,o=this.tn.next(),!t.NAME.test(o))throw Error("illegal message field name: "+o);s.name=o,this.tn.skip("="),s.id=i(this.tn.next()),o=this.tn.peek(),"["===o&&this._parseFieldOptions(s),this.tn.skip(";")}return e.fields.push(s),s},u._parseMessageOneOf=function(e){var i=this.tn.next();if(!t.NAME.test(i))throw Error("illegal oneof name: "+i);var r,n=i,o=[];for(this.tn.skip("{");"}"!==(i=this.tn.next());)r=this._parseMessageField(e,"optional",i),r.oneof=n,o.push(r.id);this.tn.omit(";"),e.oneofs[n]=o},u._parseFieldOptions=function(e){this.tn.skip("[");for(var t,i=!0;"]"!==(t=this.tn.peek());)i||this.tn.skip(","),this._parseOption(e,!0),i=!1;this.tn.next()},u._parseEnum=function(e){var r={name:"",values:[],options:{}},n=this.tn.next();if(!t.NAME.test(n))throw Error("illegal name: "+n);for(r.name=n,this.tn.skip("{");"}"!==(n=this.tn.next());)if("option"===n)this._parseOption(r);else{if(!t.NAME.test(n))throw Error("illegal name: "+n);this.tn.skip("=");var o={name:n,id:i(this.tn.next(),!0)};n=this.tn.peek(),"["===n&&this._parseFieldOptions({options:{}}),this.tn.skip(";"),r.values.push(o)}this.tn.omit(";"),e.enums.push(r)},u._parseExtensionRanges=function(){var t,i,n,o=[];do{for(i=[];;){switch(t=this.tn.next()){case"min":n=e.ID_MIN;break;case"max":n=e.ID_MAX;break;default:n=r(t)}if(i.push(n),2===i.length)break;if("to"!==this.tn.peek()){i.push(n);break}this.tn.next()}o.push(i)}while(this.tn.omit(","));return this.tn.skip(";"),o},u._parseExtend=function(e){var i=this.tn.next();if(!t.TYPEREF.test(i))throw Error("illegal extend reference: "+i);var r={ref:i,fields:[]};for(this.tn.skip("{");"}"!==(i=this.tn.next());)if(t.RULE.test(i))this._parseMessageField(r,i);else{if(!t.TYPEREF.test(i))throw Error("illegal extend token: "+i);if(!this.proto3)throw Error("illegal field rule: "+i);this._parseMessageField(r,"optional",i)}return this.tn.omit(";"),e.messages.push(r),r},u.toString=function(){return"Parser at line "+this.tn.line},o.Parser=l,o}(n,n.Lang),n.Reflect=function(e){function i(i){if("string"==typeof i&&(i=e.TYPES[i]),void 0===i.defaultValue)throw Error("default value for type "+i.name+" is not supported");return i==e.TYPES.bytes?new t(0):i.defaultValue}function r(t,i){if(t&&"number"==typeof t.low&&"number"==typeof t.high&&"boolean"==typeof t.unsigned&&t.low===t.low&&t.high===t.high)return new e.Long(t.low,t.high,void 0===i?t.unsigned:i);if("string"==typeof t)return e.Long.fromString(t,i||!1,10);if("number"==typeof t)return e.Long.fromNumber(t,i||!1);throw Error("not convertible to Long")}function n(t,i){var r=i.readVarint32(),o=7&r,s=r>>>3;switch(o){case e.WIRE_TYPES.VARINT:do r=i.readUint8();while(128===(128&r));break;case e.WIRE_TYPES.BITS64:i.offset+=8;break;case e.WIRE_TYPES.LDELIM:r=i.readVarint32(),i.offset+=r;break;case e.WIRE_TYPES.STARTGROUP:n(s,i);break;case e.WIRE_TYPES.ENDGROUP:if(s===t)return!1;throw Error("Illegal GROUPEND after unknown group: "+s+" ("+t+" expected)");case e.WIRE_TYPES.BITS32:i.offset+=4;break;default:throw Error("Illegal wire type in unknown group "+t+": "+o)}return!0}var o={},s=function(e,t,i){this.builder=e,this.parent=t,this.name=i,this.className},a=s.prototype;a.fqn=function(){for(var e=this.name,t=this;;){if(t=t.parent,null==t)break;e=t.name+"."+e}return e},a.toString=function(e){return(e?this.className+" ":"")+this.fqn()},a.build=function(){throw Error(this.toString(!0)+" cannot be built directly")},o.T=s;var l=function(e,t,i,r,n){s.call(this,e,t,i),this.className="Namespace",this.children=[],this.options=r||{},this.syntax=n||"proto2"},u=l.prototype=Object.create(s.prototype);u.getChildren=function(e){if(e=e||null,null==e)return this.children.slice();for(var t=[],i=0,r=this.children.length;r>i;++i)this.children[i]instanceof e&&t.push(this.children[i]);return t},u.addChild=function(e){var t;if(t=this.getChild(e.name))if(t instanceof p.Field&&t.name!==t.originalName&&null===this.getChild(t.originalName))t.name=t.originalName;else{if(!(e instanceof p.Field&&e.name!==e.originalName&&null===this.getChild(e.originalName)))throw Error("Duplicate name in namespace "+this.toString(!0)+": "+e.name);e.name=e.originalName}this.children.push(e)},u.getChild=function(e){for(var t="number"==typeof e?"id":"name",i=0,r=this.children.length;r>i;++i)if(this.children[i][t]===e)return this.children[i];return null},u.resolve=function(e,t){var i="string"==typeof e?e.split("."):e,r=this,n=0;if(""===i[n]){for(;null!==r.parent;)r=r.parent;n++}var s;do{do{if(!(r instanceof o.Namespace)){r=null;break}if(s=r.getChild(i[n]),!s||!(s instanceof o.T)||t&&!(s instanceof o.Namespace)){r=null;break}r=s,n++}while(nr;++r)e=i[r],e instanceof l&&(t[e.name]=e.build());return Object.defineProperty&&Object.defineProperty(t,"$options",{value:this.buildOpt()}),t},u.buildOpt=function(){for(var e={},t=Object.keys(this.options),i=0,r=t.length;r>i;++i){var n=t[i],o=this.options[t[i]];e[n]=o}return e},u.getOption=function(e){return void 0===e?this.options:void 0!==this.options[e]?this.options[e]:null},o.Namespace=l;var d=function(t,i,r,n){if(this.type=t,this.resolvedType=i,this.isMapKey=r,this.syntax=n,r&&e.MAP_KEY_TYPES.indexOf(t)<0)throw Error("Invalid map key type: "+t.name)},c=d.prototype;d.defaultFieldValue=i,c.verifyValue=function(i){function n(e,t){throw Error("Illegal value for "+o.toString(!0)+" of type "+o.type.name+": "+e+" ("+t+")")}var o=this;switch(this.type){case e.TYPES.int32:case e.TYPES.sint32:case e.TYPES.sfixed32:return("number"!=typeof i||i===i&&i%1!==0)&&n(typeof i,"not an integer"),i>4294967295?0|i:i;case e.TYPES.uint32:case e.TYPES.fixed32:return("number"!=typeof i||i===i&&i%1!==0)&&n(typeof i,"not an integer"),0>i?i>>>0:i;case e.TYPES.int64:case e.TYPES.sint64:case e.TYPES.sfixed64:if(e.Long)try{return r(i,!1)}catch(s){n(typeof i,s.message)}else n(typeof i,"requires Long.js");case e.TYPES.uint64:case e.TYPES.fixed64:if(e.Long)try{return r(i,!0)}catch(s){n(typeof i,s.message)}else n(typeof i,"requires Long.js");case e.TYPES.bool:return"boolean"!=typeof i&&n(typeof i,"not a boolean"),i;case e.TYPES["float"]:case e.TYPES["double"]:return"number"!=typeof i&&n(typeof i,"not a number"),i;case e.TYPES.string:return"string"==typeof i||i&&i instanceof String||n(typeof i,"not a string"),""+i;case e.TYPES.bytes:return t.isByteBuffer(i)?i:t.wrap(i,"base64");case e.TYPES["enum"]:var a=this.resolvedType.getChildren(e.Reflect.Enum.Value);for(u=0;u4294967295||0>i)&&n(typeof i,"not in range for uint32"),i;n(i,"not a valid enum value");case e.TYPES.group:case e.TYPES.message:if(i&&"object"==typeof i||n(typeof i,"object expected"),i instanceof this.resolvedType.clazz)return i;if(i instanceof e.Builder.Message){var l={};for(var u in i)i.hasOwnProperty(u)&&(l[u]=i[u]);i=l}return new this.resolvedType.clazz(i)}throw Error("[INTERNAL] Illegal value for "+this.toString(!0)+": "+i+" (undefined type "+this.type+")")},c.calculateLength=function(i,r){if(null===r)return 0;var n;switch(this.type){case e.TYPES.int32:return 0>r?t.calculateVarint64(r):t.calculateVarint32(r);case e.TYPES.uint32:return t.calculateVarint32(r);case e.TYPES.sint32:return t.calculateVarint32(t.zigZagEncode32(r));case e.TYPES.fixed32:case e.TYPES.sfixed32:case e.TYPES["float"]:return 4;case e.TYPES.int64:case e.TYPES.uint64:return t.calculateVarint64(r);case e.TYPES.sint64:return t.calculateVarint64(t.zigZagEncode64(r));case e.TYPES.fixed64:case e.TYPES.sfixed64:return 8;case e.TYPES.bool:return 1;case e.TYPES["enum"]:return t.calculateVarint32(r);case e.TYPES["double"]:return 8;case e.TYPES.string:return n=t.calculateUTF8Bytes(r),t.calculateVarint32(n)+n;case e.TYPES.bytes:if(r.remaining()<0)throw Error("Illegal value for "+this.toString(!0)+": "+r.remaining()+" bytes remaining");return t.calculateVarint32(r.remaining())+r.remaining();case e.TYPES.message:return n=this.resolvedType.calculate(r),t.calculateVarint32(n)+n;case e.TYPES.group:return n=this.resolvedType.calculate(r),n+t.calculateVarint32(i<<3|e.WIRE_TYPES.ENDGROUP)}throw Error("[INTERNAL] Illegal value to encode in "+this.toString(!0)+": "+r+" (unknown type)")},c.encodeValue=function(i,r,n){if(null===r)return n;switch(this.type){case e.TYPES.int32:0>r?n.writeVarint64(r):n.writeVarint32(r);break;case e.TYPES.uint32:n.writeVarint32(r);break;case e.TYPES.sint32:n.writeVarint32ZigZag(r);break;case e.TYPES.fixed32:n.writeUint32(r);break;case e.TYPES.sfixed32:n.writeInt32(r);break;case e.TYPES.int64:case e.TYPES.uint64:n.writeVarint64(r);break;case e.TYPES.sint64:n.writeVarint64ZigZag(r);break;case e.TYPES.fixed64:n.writeUint64(r);break;case e.TYPES.sfixed64:n.writeInt64(r);break;case e.TYPES.bool:"string"==typeof r?n.writeVarint32("false"===r.toLowerCase()?0:!!r):n.writeVarint32(r?1:0);break;case e.TYPES["enum"]:n.writeVarint32(r);break;case e.TYPES["float"]:n.writeFloat32(r);break;case e.TYPES["double"]:n.writeFloat64(r);break;case e.TYPES.string:n.writeVString(r);break;case e.TYPES.bytes:if(r.remaining()<0)throw Error("Illegal value for "+this.toString(!0)+": "+r.remaining()+" bytes remaining");var o=r.offset;n.writeVarint32(r.remaining()),n.append(r),r.offset=o;break;case e.TYPES.message:var s=(new t).LE();this.resolvedType.encode(r,s),n.writeVarint32(s.offset),n.append(s.flip());break;case e.TYPES.group:this.resolvedType.encode(r,n),n.writeVarint32(i<<3|e.WIRE_TYPES.ENDGROUP);break;default:throw Error("[INTERNAL] Illegal value to encode in "+this.toString(!0)+": "+r+" (unknown type)")}return n},c.decode=function(t,i,r){if(i!=this.type.wireType)throw Error("Unexpected wire type for element");var n,o;switch(this.type){case e.TYPES.int32:return 0|t.readVarint32();case e.TYPES.uint32:return t.readVarint32()>>>0;case e.TYPES.sint32:return 0|t.readVarint32ZigZag();case e.TYPES.fixed32:return t.readUint32()>>>0;case e.TYPES.sfixed32:return 0|t.readInt32();case e.TYPES.int64:return t.readVarint64();case e.TYPES.uint64:return t.readVarint64().toUnsigned();case e.TYPES.sint64:return t.readVarint64ZigZag();case e.TYPES.fixed64:return t.readUint64();case e.TYPES.sfixed64:return t.readInt64();case e.TYPES.bool:return!!t.readVarint32();case e.TYPES["enum"]:return t.readVarint32();case e.TYPES["float"]:return t.readFloat();case e.TYPES["double"]:return t.readDouble();case e.TYPES.string:return t.readVString();case e.TYPES.bytes:if(o=t.readVarint32(),t.remaining()l;++l)this[o[l].name]=null;for(l=0,u=n.length;u>l;++l){var d=n[l];this[d.name]=d.repeated?[]:d.map?new e.Map(d):null,!d.required&&"proto3"!==i.syntax||null===d.defaultValue||(this[d.name]=d.defaultValue)}if(arguments.length>0){var c;if(1!==arguments.length||null===r||"object"!=typeof r||!("function"!=typeof r.encode||r instanceof s)||Array.isArray(r)||r instanceof e.Map||t.isByteBuffer(r)||r instanceof ArrayBuffer||e.Long&&r instanceof e.Long)for(l=0,u=arguments.length;u>l;++l)void 0!==(c=arguments[l])&&this.$set(n[l].name,c);else this.$set(r)}},a=s.prototype=Object.create(e.Builder.Message.prototype);a.add=function(t,r,n){var o=i._fieldsByName[t];if(!n){if(!o)throw Error(this+"#"+t+" is undefined");if(!(o instanceof e.Reflect.Message.Field))throw Error(this+"#"+t+" is not a field: "+o.toString(!0));if(!o.repeated)throw Error(this+"#"+t+" is not a repeated field");r=o.verifyValue(r,!0)}return null===this[t]&&(this[t]=[]),this[t].push(r),this},a.$add=a.add,a.set=function(t,r,n){if(t&&"object"==typeof t){n=r;for(var o in t)t.hasOwnProperty(o)&&void 0!==(r=t[o])&&this.$set(o,r,n);return this}var s=i._fieldsByName[t];if(n)this[t]=r;else{if(!s)throw Error(this+"#"+t+" is not a field: undefined");if(!(s instanceof e.Reflect.Message.Field))throw Error(this+"#"+t+" is not a field: "+s.toString(!0));this[s.name]=r=s.verifyValue(r)}if(s&&s.oneof){var a=this[s.oneof.name];null!==r?(null!==a&&a!==s.name&&(this[a]=null),this[s.oneof.name]=s.name):a===t&&(this[s.oneof.name]=null)}return this},a.$set=a.set,a.get=function(t,r){if(r)return this[t];var n=i._fieldsByName[t];if(!(n&&n instanceof e.Reflect.Message.Field))throw Error(this+"#"+t+" is not a field: undefined");if(!(n instanceof e.Reflect.Message.Field))throw Error(this+"#"+t+" is not a field: "+n.toString(!0)); return this[n.name]},a.$get=a.get;for(var l=0;lo;o++)if(n=this.children[o],n instanceof y||n instanceof p||n instanceof w){if(r.hasOwnProperty(n.name))throw Error("Illegal reflect child of "+this.toString(!0)+": "+n.toString(!0)+" cannot override static property '"+n.name+"'");r[n.name]=n.build()}else if(n instanceof p.Field)n.build(),this._fields.push(n),this._fieldsById[n.id]=n,this._fieldsByName[n.name]=n;else if(!(n instanceof p.OneOf||n instanceof T))throw Error("Illegal reflect child of "+this.toString(!0)+": "+this.children[o].toString(!0));return this.clazz=r},f.encode=function(e,t,i){for(var r,n,o=null,s=0,a=this._fields.length;a>s;++s)r=this._fields[s],n=e[r.name],r.required&&null===n?null===o&&(o=r):r.encode(i?n:r.verifyValue(n),t,e);if(null!==o){var l=Error("Missing at least one required field for "+this.toString(!0)+": "+o);throw l.encoded=t,l}return t},f.calculate=function(e){for(var t,i,r=0,n=0,o=this._fields.length;o>n;++n){if(t=this._fields[n],i=e[t.name],t.required&&null===i)throw Error("Missing at least one required field for "+this.toString(!0)+": "+t);r+=t.calculate(i,e)}return r},f.decode=function(t,i,r){i="number"==typeof i?i:-1;for(var o,s,a,l,u=t.offset,d=new this.clazz;t.offset0;){if(o=t.readVarint32(),s=7&o,a=o>>>3,s===e.WIRE_TYPES.ENDGROUP){if(a!==r)throw Error("Illegal group end indicator for "+this.toString(!0)+": "+a+" ("+(r?r+" expected":"not a group")+")");break}if(l=this._fieldsById[a]){if(l.repeated&&!l.options.packed)d[l.name].push(l.decode(s,t));else if(l.map){var c=l.decode(s,t);d[l.name].set(c[0],c[1])}else if(d[l.name]=l.decode(s,t),l.oneof){var p=d[l.oneof.name];null!==p&&p!==l.name&&(d[p]=null),d[l.oneof.name]=l.name}}else switch(s){case e.WIRE_TYPES.VARINT:t.readVarint32();break;case e.WIRE_TYPES.BITS32:t.offset+=4;break;case e.WIRE_TYPES.BITS64:t.offset+=8;break;case e.WIRE_TYPES.LDELIM:var f=t.readVarint32();t.offset+=f;break;case e.WIRE_TYPES.STARTGROUP:for(;n(a,t););break;default:throw Error("Illegal wire type for unknown field "+a+" in "+this.toString(!0)+"#decode: "+s)}}for(var h=0,m=this._fields.length;m>h;++h)if(l=this._fields[h],null===d[l.name])if("proto3"===this.syntax)d[l.name]=l.defaultValue;else{if(l.required){var _=Error("Missing at least one required field for "+this.toString(!0)+": "+l.name);throw _.decoded=d,_}e.populateDefaults&&null!==l.defaultValue&&(d[l.name]=l.defaultValue)}return d},o.Message=p;var h=function(t,i,r,n,o,a,l,u,d,c){s.call(this,t,i,a),this.className="Message.Field",this.required="required"===r,this.repeated="repeated"===r,this.map="map"===r,this.keyType=n||null,this.type=o,this.resolvedType=null,this.id=l,this.options=u||{},this.defaultValue=null,this.oneof=d||null,this.syntax=c||"proto2",this.originalName=this.name,this.element=null,this.keyElement=null,!this.builder.options.convertFieldsToCamelCase||this instanceof p.ExtensionField||(this.name=e.Util.toCamelCase(this.name))},m=h.prototype=Object.create(s.prototype);m.build=function(){this.element=new d(this.type,this.resolvedType,!1,this.syntax),this.map&&(this.keyElement=new d(this.keyType,void 0,!0,this.syntax)),"proto3"!==this.syntax||this.repeated||this.map?void 0!==this.options["default"]&&(this.defaultValue=this.verifyValue(this.options["default"])):this.defaultValue=d.defaultFieldValue(this.type)},m.verifyValue=function(t,i){function r(e,t){throw Error("Illegal value for "+n.toString(!0)+" of type "+n.type.name+": "+e+" ("+t+")")}i=i||!1;var n=this;if(null===t)return this.required&&r(typeof t,"required"),"proto3"===this.syntax&&this.type!==e.TYPES.message&&r(typeof t,"proto3 field without field presence cannot be null"),null;var o;if(this.repeated&&!i){Array.isArray(t)||(t=[t]);var s=[];for(o=0;o0;case e.TYPES.bytes:return t.remaining()>0;case e.TYPES["enum"]:return 0!==t;case e.TYPES.message:return null!==t;default:return!0}},m.encode=function(i,r,n){if(null===this.type||"object"!=typeof this.type)throw Error("[INTERNAL] Unresolved type in "+this.toString(!0)+": "+this.type);if(null===i||this.repeated&&0==i.length)return r;try{if(this.repeated){var o;if(this.options.packed&&e.PACKABLE_WIRE_TYPES.indexOf(this.type.wireType)>=0){r.writeVarint32(this.id<<3|e.WIRE_TYPES.LDELIM),r.ensureCapacity(r.offset+=1);var s=r.offset;for(o=0;o1){var u=r.slice(s,r.offset);s+=l-1,r.offset=s,r.append(u)}r.writeVarint32(a,s-l)}else for(o=0;o=0){for(n+=t.calculateVarint32(this.id<<3|e.WIRE_TYPES.LDELIM),s=0,o=0;o=0&&!r){o=i.readVarint32(),o=i.offset+o;for(var a=[];i.offset0;){var c=u.readVarint32();t=7&c;var p=c>>>3;if(1===p)l=this.keyElement.decode(u,t,p);else{if(2!==p)throw Error("Unexpected tag in map field key/value submessage");n=this.element.decode(u,t,p)}}return[l,n]}return this.element.decode(i,t,this.id)},o.Message.Field=h;var _=function(e,t,i,r,n,o,s){h.call(this,e,t,i,null,r,n,o,s),this.extension};_.prototype=Object.create(h.prototype),o.Message.ExtensionField=_;var g=function(e,t,i){s.call(this,e,t,i),this.fields=[]};o.Message.OneOf=g;var y=function(e,t,i,r,n){l.call(this,e,t,i,r,n),this.className="Enum",this.object=null};y.getName=function(e,t){for(var i,r=Object.keys(e),n=0;nn;++n)i[r[n].name]=r[n].id;return Object.defineProperty&&Object.defineProperty(i,"$options",{value:this.buildOpt(),enumerable:!1}),this.object=i},o.Enum=y;var b=function(e,t,i,r){s.call(this,e,t,i),this.className="Enum.Value",this.id=r};b.prototype=Object.create(s.prototype),o.Enum.Value=b;var T=function(e,t,i,r){s.call(this,e,t,i),this.field=r};T.prototype=Object.create(s.prototype),o.Extension=T;var w=function(e,t,i,r){l.call(this,e,t,i,r),this.className="Service",this.clazz=null},E=w.prototype=Object.create(l.prototype);E.build=function(i){return this.clazz&&!i?this.clazz:this.clazz=function(e,i){for(var r=function(t){e.Builder.Service.call(this),this.rpcImpl=t||function(e,t,i){setTimeout(i.bind(this,Error("Not implemented, see: https://github.com/dcodeIO/ProtoBuf.js/wiki/Services")),0)}},n=r.prototype=Object.create(e.Builder.Service.prototype),o=i.getChildren(e.Reflect.Service.RPCMethod),s=0;s0;){if(t=i.pop(),!Array.isArray(t))throw Error("not a valid namespace: "+JSON.stringify(t));for(;t.length>0;){var n=t.shift();if(o.isMessage(n)){var s=new r.Message(this,this.ptr,n.name,n.options,n.isGroup,n.syntax),a={};n.oneofs&&Object.keys(n.oneofs).forEach(function(e){s.addChild(a[e]=new r.Message.OneOf(this,s,e))},this),n.fields&&n.fields.forEach(function(e){if(null!==s.getChild(0|e.id))throw Error("duplicate or invalid field id in "+s.name+": "+e.id);if(e.options&&"object"!=typeof e.options)throw Error("illegal field options in "+s.name+"#"+e.name);var t=null;if("string"==typeof e.oneof&&!(t=a[e.oneof]))throw Error("illegal oneof in "+s.name+"#"+e.name+": "+e.oneof);e=new r.Message.Field(this,s,e.rule,e.keytype,e.type,e.name,e.id,e.options,t,n.syntax),t&&t.fields.push(e),s.addChild(e)},this);var l=[];if(n.enums&&n.enums.forEach(function(e){l.push(e)}),n.messages&&n.messages.forEach(function(e){l.push(e)}),n.services&&n.services.forEach(function(e){l.push(e)}),n.extensions&&("number"==typeof n.extensions[0]?s.extensions=[n.extensions]:s.extensions=n.extensions),this.ptr.addChild(s),l.length>0){i.push(t),t=l,l=null,this.ptr=s,s=null;continue}l=null}else if(o.isEnum(n))s=new r.Enum(this,this.ptr,n.name,n.options,n.syntax),n.values.forEach(function(e){s.addChild(new r.Enum.Value(this,s,e.name,e.id))},this),this.ptr.addChild(s);else if(o.isService(n))s=new r.Service(this,this.ptr,n.name,n.options),Object.keys(n.rpc).forEach(function(e){var t=n.rpc[e];s.addChild(new r.Service.RPCMethod(this,s,e,t.request,t.response,!!t.request_stream,!!t.response_stream,t.options))},this),this.ptr.addChild(s);else{if(!o.isExtend(n))throw Error("not a valid definition: "+JSON.stringify(n));if(s=this.ptr.resolve(n.ref,!0))n.fields.forEach(function(t){if(null!==s.getChild(0|t.id))throw Error("duplicate extended field id in "+s.name+": "+t.id);if(s.extensions){var i=!1;if(s.extensions.forEach(function(e){t.id>=e[0]&&t.id<=e[1]&&(i=!0)}),!i)throw Error("illegal extended field id in "+s.name+": "+t.id+" (not within valid ranges)")}var n=t.name;this.options.convertFieldsToCamelCase&&(n=e.Util.toCamelCase(n));var o=new r.Message.ExtensionField(this,s,t.rule,t.type,this.ptr.fqn()+"."+n,t.id,t.options),a=new r.Extension(this,this.ptr,t.name,o);o.extension=a,this.ptr.addChild(a),s.addChild(o)},this);else if(!/\.?google\.protobuf\./.test(n.ref))throw Error("extended message "+n.ref+" is not defined")}n=null,s=null}t=null,this.ptr=this.ptr.parent}return this.resolved=!1,this.result=null,this},s["import"]=function(t,r){var o="/";if("string"==typeof r){if(e.Util.IS_NODE&&(r=i(335).resolve(r)),this.files[r]===!0)return this.reset();this.files[r]=!0}else if("object"==typeof r){var s=r.root;e.Util.IS_NODE&&(s=i(335).resolve(s)),(s.indexOf("\\")>=0||r.file.indexOf("\\")>=0)&&(o="\\");var a=s+o+r.file;if(this.files[a]===!0)return this.reset();this.files[a]=!0}if(t.imports&&t.imports.length>0){var l,u=!1;"object"==typeof r?(this.importRoot=r.root,u=!0,l=this.importRoot,r=r.file,(l.indexOf("\\")>=0||r.indexOf("\\")>=0)&&(o="\\")):"string"==typeof r?this.importRoot?l=this.importRoot:r.indexOf("/")>=0?(l=r.replace(/\/[^\/]*$/,""),""===l&&(l="/")):r.indexOf("\\")>=0?(l=r.replace(/\\[^\\]*$/,""),o="\\"):l=".":l=null;for(var d=0;d1)for(var i=1;i1024&&(t.push(l.apply(String,e)),e.length=0),void Array.prototype.push.apply(e,arguments))}}function r(e,t,i,r,n){var o,s,a=8*n-r-1,l=(1<>1,d=-7,c=i?n-1:0,p=i?-1:1,f=e[t+c];for(c+=p,o=f&(1<<-d)-1,f>>=-d,d+=a;d>0;o=256*o+e[t+c],c+=p,d-=8);for(s=o&(1<<-d)-1,o>>=-d,d+=r;d>0;s=256*s+e[t+c],c+=p,d-=8);if(0===o)o=1-u;else{if(o===l)return s?NaN:(f?-1:1)*(1/0);s+=Math.pow(2,r),o-=u}return(f?-1:1)*s*Math.pow(2,o-r)}function n(e,t,i,r,n,o){var s,a,l,u=8*o-n-1,d=(1<>1,p=23===n?Math.pow(2,-24)-Math.pow(2,-77):0,f=r?0:o-1,h=r?1:-1,m=0>t||0===t&&0>1/t?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=d):(s=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-s))<1&&(s--,l*=2),t+=s+c>=1?p/l:p*Math.pow(2,1-c),t*l>=2&&(s++,l/=2),s+c>=d?(a=0,s=d):s+c>=1?(a=(t*l-1)*Math.pow(2,n),s+=c):(a=t*Math.pow(2,c-1)*Math.pow(2,n),s=0));n>=8;e[i+f]=255&a,f+=h,a/=256,n-=8);for(s=s<0;e[i+f]=255&s,f+=h,s/=256,u-=8);e[i+f-h]|=128*m}var o=function(e,t,i){if(void 0===e&&(e=o.DEFAULT_CAPACITY),void 0===t&&(t=o.DEFAULT_ENDIAN),void 0===i&&(i=o.DEFAULT_NOASSERT),!i){if(e=0|e,0>e)throw RangeError("Illegal capacity");t=!!t,i=!!i}this.buffer=0===e?a:new ArrayBuffer(e),this.view=0===e?null:new Uint8Array(this.buffer),this.offset=0,this.markedOffset=-1,this.limit=e,this.littleEndian=t,this.noAssert=i};o.VERSION="5.0.1",o.LITTLE_ENDIAN=!0,o.BIG_ENDIAN=!1,o.DEFAULT_CAPACITY=16,o.DEFAULT_ENDIAN=o.BIG_ENDIAN,o.DEFAULT_NOASSERT=!1,o.Long=e||null;var s=o.prototype;s.__isByteBuffer__,Object.defineProperty(s,"__isByteBuffer__",{value:!0,enumerable:!1,configurable:!1});var a=new ArrayBuffer(0),l=String.fromCharCode;o.accessor=function(){return Uint8Array},o.allocate=function(e,t,i){return new o(e,t,i)},o.concat=function(e,t,i,r){"boolean"!=typeof t&&"string"==typeof t||(r=i,i=t,t=void 0);for(var n,s=0,a=0,l=e.length;l>a;++a)o.isByteBuffer(e[a])||(e[a]=o.wrap(e[a],t)),n=e[a].limit-e[a].offset,n>0&&(s+=n);if(0===s)return new o(0,i,r);var u,d=new o(s,i,r);for(a=0;l>a;)u=e[a++],n=u.limit-u.offset,0>=n||(d.view.set(u.view.subarray(u.offset,u.limit),d.offset),d.offset+=n);return d.limit=d.offset,d.offset=0,d},o.isByteBuffer=function(e){return(e&&e.__isByteBuffer__)===!0},o.type=function(){return ArrayBuffer},o.wrap=function(e,t,i,r){if("string"!=typeof t&&(r=i,i=t,t=void 0),"string"==typeof e)switch(void 0===t&&(t="utf8"),t){case"base64":return o.fromBase64(e,i);case"hex":return o.fromHex(e,i);case"binary":return o.fromBinary(e,i);case"utf8":return o.fromUTF8(e,i);case"debug":return o.fromDebug(e,i);default:throw Error("Unsupported encoding: "+t)}if(null===e||"object"!=typeof e)throw TypeError("Illegal buffer");var n;if(o.isByteBuffer(e))return n=s.clone.call(e),n.markedOffset=-1,n;if(e instanceof Uint8Array)n=new o(0,i,r),e.length>0&&(n.buffer=e.buffer,n.offset=e.byteOffset,n.limit=e.byteOffset+e.byteLength,n.view=new Uint8Array(e.buffer));else if(e instanceof ArrayBuffer)n=new o(0,i,r),e.byteLength>0&&(n.buffer=e,n.offset=0,n.limit=e.byteLength,n.view=e.byteLength>0?new Uint8Array(e):null);else{if("[object Array]"!==Object.prototype.toString.call(e))throw TypeError("Illegal buffer");n=new o(e.length,i,r),n.limit=e.length;for(var a=0;a>>=0,0>t||t+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+0) <= "+this.buffer.byteLength)}var r,n=t,o=e.length,s=o>>3,a=0;for(t+=this.writeVarint32(o,t);s--;)r=1&!!e[a++]|(1&!!e[a++])<<1|(1&!!e[a++])<<2|(1&!!e[a++])<<3|(1&!!e[a++])<<4|(1&!!e[a++])<<5|(1&!!e[a++])<<6|(1&!!e[a++])<<7,this.writeByte(r,t++);if(o>a){var l=0;for(r=0;o>a;)r|=(1&!!e[a++])<>3,s=0,a=[];for(e+=r.length;o--;)i=this.readByte(e++),a[s++]=!!(1&i),a[s++]=!!(2&i),a[s++]=!!(4&i),a[s++]=!!(8&i),a[s++]=!!(16&i),a[s++]=!!(32&i),a[s++]=!!(64&i),a[s++]=!!(128&i);if(n>s){var l=0;for(i=this.readByte(e++);n>s;)a[s++]=!!(i>>l++&1)}return t&&(this.offset=e),a},s.readBytes=function(e,t){var i=void 0===t;if(i&&(t=this.offset),!this.noAssert){if("number"!=typeof t||t%1!==0)throw TypeError("Illegal offset: "+t+" (not an integer)");if(t>>>=0,0>t||t+e>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+"+e+") <= "+this.buffer.byteLength)}var r=this.slice(t,t+e);return i&&(this.offset+=e),r},s.writeBytes=s.append,s.writeInt8=function(e,t){var i=void 0===t;if(i&&(t=this.offset),!this.noAssert){if("number"!=typeof e||e%1!==0)throw TypeError("Illegal value: "+e+" (not an integer)");if(e|=0,"number"!=typeof t||t%1!==0)throw TypeError("Illegal offset: "+t+" (not an integer)");if(t>>>=0,0>t||t+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+0) <= "+this.buffer.byteLength); }t+=1;var r=this.buffer.byteLength;return t>r&&this.resize((r*=2)>t?r:t),t-=1,this.view[t]=e,i&&(this.offset+=1),this},s.writeByte=s.writeInt8,s.readInt8=function(e){var t=void 0===e;if(t&&(e=this.offset),!this.noAssert){if("number"!=typeof e||e%1!==0)throw TypeError("Illegal offset: "+e+" (not an integer)");if(e>>>=0,0>e||e+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+e+" (+1) <= "+this.buffer.byteLength)}var i=this.view[e];return 128===(128&i)&&(i=-(255-i+1)),t&&(this.offset+=1),i},s.readByte=s.readInt8,s.writeUint8=function(e,t){var i=void 0===t;if(i&&(t=this.offset),!this.noAssert){if("number"!=typeof e||e%1!==0)throw TypeError("Illegal value: "+e+" (not an integer)");if(e>>>=0,"number"!=typeof t||t%1!==0)throw TypeError("Illegal offset: "+t+" (not an integer)");if(t>>>=0,0>t||t+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+0) <= "+this.buffer.byteLength)}t+=1;var r=this.buffer.byteLength;return t>r&&this.resize((r*=2)>t?r:t),t-=1,this.view[t]=e,i&&(this.offset+=1),this},s.writeUInt8=s.writeUint8,s.readUint8=function(e){var t=void 0===e;if(t&&(e=this.offset),!this.noAssert){if("number"!=typeof e||e%1!==0)throw TypeError("Illegal offset: "+e+" (not an integer)");if(e>>>=0,0>e||e+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+e+" (+1) <= "+this.buffer.byteLength)}var i=this.view[e];return t&&(this.offset+=1),i},s.readUInt8=s.readUint8,s.writeInt16=function(e,t){var i=void 0===t;if(i&&(t=this.offset),!this.noAssert){if("number"!=typeof e||e%1!==0)throw TypeError("Illegal value: "+e+" (not an integer)");if(e|=0,"number"!=typeof t||t%1!==0)throw TypeError("Illegal offset: "+t+" (not an integer)");if(t>>>=0,0>t||t+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+0) <= "+this.buffer.byteLength)}t+=2;var r=this.buffer.byteLength;return t>r&&this.resize((r*=2)>t?r:t),t-=2,this.littleEndian?(this.view[t+1]=(65280&e)>>>8,this.view[t]=255&e):(this.view[t]=(65280&e)>>>8,this.view[t+1]=255&e),i&&(this.offset+=2),this},s.writeShort=s.writeInt16,s.readInt16=function(e){var t=void 0===e;if(t&&(e=this.offset),!this.noAssert){if("number"!=typeof e||e%1!==0)throw TypeError("Illegal offset: "+e+" (not an integer)");if(e>>>=0,0>e||e+2>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+e+" (+2) <= "+this.buffer.byteLength)}var i=0;return this.littleEndian?(i=this.view[e],i|=this.view[e+1]<<8):(i=this.view[e]<<8,i|=this.view[e+1]),32768===(32768&i)&&(i=-(65535-i+1)),t&&(this.offset+=2),i},s.readShort=s.readInt16,s.writeUint16=function(e,t){var i=void 0===t;if(i&&(t=this.offset),!this.noAssert){if("number"!=typeof e||e%1!==0)throw TypeError("Illegal value: "+e+" (not an integer)");if(e>>>=0,"number"!=typeof t||t%1!==0)throw TypeError("Illegal offset: "+t+" (not an integer)");if(t>>>=0,0>t||t+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+0) <= "+this.buffer.byteLength)}t+=2;var r=this.buffer.byteLength;return t>r&&this.resize((r*=2)>t?r:t),t-=2,this.littleEndian?(this.view[t+1]=(65280&e)>>>8,this.view[t]=255&e):(this.view[t]=(65280&e)>>>8,this.view[t+1]=255&e),i&&(this.offset+=2),this},s.writeUInt16=s.writeUint16,s.readUint16=function(e){var t=void 0===e;if(t&&(e=this.offset),!this.noAssert){if("number"!=typeof e||e%1!==0)throw TypeError("Illegal offset: "+e+" (not an integer)");if(e>>>=0,0>e||e+2>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+e+" (+2) <= "+this.buffer.byteLength)}var i=0;return this.littleEndian?(i=this.view[e],i|=this.view[e+1]<<8):(i=this.view[e]<<8,i|=this.view[e+1]),t&&(this.offset+=2),i},s.readUInt16=s.readUint16,s.writeInt32=function(e,t){var i=void 0===t;if(i&&(t=this.offset),!this.noAssert){if("number"!=typeof e||e%1!==0)throw TypeError("Illegal value: "+e+" (not an integer)");if(e|=0,"number"!=typeof t||t%1!==0)throw TypeError("Illegal offset: "+t+" (not an integer)");if(t>>>=0,0>t||t+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+0) <= "+this.buffer.byteLength)}t+=4;var r=this.buffer.byteLength;return t>r&&this.resize((r*=2)>t?r:t),t-=4,this.littleEndian?(this.view[t+3]=e>>>24&255,this.view[t+2]=e>>>16&255,this.view[t+1]=e>>>8&255,this.view[t]=255&e):(this.view[t]=e>>>24&255,this.view[t+1]=e>>>16&255,this.view[t+2]=e>>>8&255,this.view[t+3]=255&e),i&&(this.offset+=4),this},s.writeInt=s.writeInt32,s.readInt32=function(e){var t=void 0===e;if(t&&(e=this.offset),!this.noAssert){if("number"!=typeof e||e%1!==0)throw TypeError("Illegal offset: "+e+" (not an integer)");if(e>>>=0,0>e||e+4>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+e+" (+4) <= "+this.buffer.byteLength)}var i=0;return this.littleEndian?(i=this.view[e+2]<<16,i|=this.view[e+1]<<8,i|=this.view[e],i+=this.view[e+3]<<24>>>0):(i=this.view[e+1]<<16,i|=this.view[e+2]<<8,i|=this.view[e+3],i+=this.view[e]<<24>>>0),i|=0,t&&(this.offset+=4),i},s.readInt=s.readInt32,s.writeUint32=function(e,t){var i=void 0===t;if(i&&(t=this.offset),!this.noAssert){if("number"!=typeof e||e%1!==0)throw TypeError("Illegal value: "+e+" (not an integer)");if(e>>>=0,"number"!=typeof t||t%1!==0)throw TypeError("Illegal offset: "+t+" (not an integer)");if(t>>>=0,0>t||t+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+0) <= "+this.buffer.byteLength)}t+=4;var r=this.buffer.byteLength;return t>r&&this.resize((r*=2)>t?r:t),t-=4,this.littleEndian?(this.view[t+3]=e>>>24&255,this.view[t+2]=e>>>16&255,this.view[t+1]=e>>>8&255,this.view[t]=255&e):(this.view[t]=e>>>24&255,this.view[t+1]=e>>>16&255,this.view[t+2]=e>>>8&255,this.view[t+3]=255&e),i&&(this.offset+=4),this},s.writeUInt32=s.writeUint32,s.readUint32=function(e){var t=void 0===e;if(t&&(e=this.offset),!this.noAssert){if("number"!=typeof e||e%1!==0)throw TypeError("Illegal offset: "+e+" (not an integer)");if(e>>>=0,0>e||e+4>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+e+" (+4) <= "+this.buffer.byteLength)}var i=0;return this.littleEndian?(i=this.view[e+2]<<16,i|=this.view[e+1]<<8,i|=this.view[e],i+=this.view[e+3]<<24>>>0):(i=this.view[e+1]<<16,i|=this.view[e+2]<<8,i|=this.view[e+3],i+=this.view[e]<<24>>>0),t&&(this.offset+=4),i},s.readUInt32=s.readUint32,e&&(s.writeInt64=function(t,i){var r=void 0===i;if(r&&(i=this.offset),!this.noAssert){if("number"==typeof t)t=e.fromNumber(t);else if("string"==typeof t)t=e.fromString(t);else if(!(t&&t instanceof e))throw TypeError("Illegal value: "+t+" (not an integer or Long)");if("number"!=typeof i||i%1!==0)throw TypeError("Illegal offset: "+i+" (not an integer)");if(i>>>=0,0>i||i+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+i+" (+0) <= "+this.buffer.byteLength)}"number"==typeof t?t=e.fromNumber(t):"string"==typeof t&&(t=e.fromString(t)),i+=8;var n=this.buffer.byteLength;i>n&&this.resize((n*=2)>i?n:i),i-=8;var o=t.low,s=t.high;return this.littleEndian?(this.view[i+3]=o>>>24&255,this.view[i+2]=o>>>16&255,this.view[i+1]=o>>>8&255,this.view[i]=255&o,i+=4,this.view[i+3]=s>>>24&255,this.view[i+2]=s>>>16&255,this.view[i+1]=s>>>8&255,this.view[i]=255&s):(this.view[i]=s>>>24&255,this.view[i+1]=s>>>16&255,this.view[i+2]=s>>>8&255,this.view[i+3]=255&s,i+=4,this.view[i]=o>>>24&255,this.view[i+1]=o>>>16&255,this.view[i+2]=o>>>8&255,this.view[i+3]=255&o),r&&(this.offset+=8),this},s.writeLong=s.writeInt64,s.readInt64=function(t){var i=void 0===t;if(i&&(t=this.offset),!this.noAssert){if("number"!=typeof t||t%1!==0)throw TypeError("Illegal offset: "+t+" (not an integer)");if(t>>>=0,0>t||t+8>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+8) <= "+this.buffer.byteLength)}var r=0,n=0;this.littleEndian?(r=this.view[t+2]<<16,r|=this.view[t+1]<<8,r|=this.view[t],r+=this.view[t+3]<<24>>>0,t+=4,n=this.view[t+2]<<16,n|=this.view[t+1]<<8,n|=this.view[t],n+=this.view[t+3]<<24>>>0):(n=this.view[t+1]<<16,n|=this.view[t+2]<<8,n|=this.view[t+3],n+=this.view[t]<<24>>>0,t+=4,r=this.view[t+1]<<16,r|=this.view[t+2]<<8,r|=this.view[t+3],r+=this.view[t]<<24>>>0);var o=new e(r,n,!1);return i&&(this.offset+=8),o},s.readLong=s.readInt64,s.writeUint64=function(t,i){var r=void 0===i;if(r&&(i=this.offset),!this.noAssert){if("number"==typeof t)t=e.fromNumber(t);else if("string"==typeof t)t=e.fromString(t);else if(!(t&&t instanceof e))throw TypeError("Illegal value: "+t+" (not an integer or Long)");if("number"!=typeof i||i%1!==0)throw TypeError("Illegal offset: "+i+" (not an integer)");if(i>>>=0,0>i||i+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+i+" (+0) <= "+this.buffer.byteLength)}"number"==typeof t?t=e.fromNumber(t):"string"==typeof t&&(t=e.fromString(t)),i+=8;var n=this.buffer.byteLength;i>n&&this.resize((n*=2)>i?n:i),i-=8;var o=t.low,s=t.high;return this.littleEndian?(this.view[i+3]=o>>>24&255,this.view[i+2]=o>>>16&255,this.view[i+1]=o>>>8&255,this.view[i]=255&o,i+=4,this.view[i+3]=s>>>24&255,this.view[i+2]=s>>>16&255,this.view[i+1]=s>>>8&255,this.view[i]=255&s):(this.view[i]=s>>>24&255,this.view[i+1]=s>>>16&255,this.view[i+2]=s>>>8&255,this.view[i+3]=255&s,i+=4,this.view[i]=o>>>24&255,this.view[i+1]=o>>>16&255,this.view[i+2]=o>>>8&255,this.view[i+3]=255&o),r&&(this.offset+=8),this},s.writeUInt64=s.writeUint64,s.readUint64=function(t){var i=void 0===t;if(i&&(t=this.offset),!this.noAssert){if("number"!=typeof t||t%1!==0)throw TypeError("Illegal offset: "+t+" (not an integer)");if(t>>>=0,0>t||t+8>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+8) <= "+this.buffer.byteLength)}var r=0,n=0;this.littleEndian?(r=this.view[t+2]<<16,r|=this.view[t+1]<<8,r|=this.view[t],r+=this.view[t+3]<<24>>>0,t+=4,n=this.view[t+2]<<16,n|=this.view[t+1]<<8,n|=this.view[t],n+=this.view[t+3]<<24>>>0):(n=this.view[t+1]<<16,n|=this.view[t+2]<<8,n|=this.view[t+3],n+=this.view[t]<<24>>>0,t+=4,r=this.view[t+1]<<16,r|=this.view[t+2]<<8,r|=this.view[t+3],r+=this.view[t]<<24>>>0);var o=new e(r,n,!0);return i&&(this.offset+=8),o},s.readUInt64=s.readUint64),s.writeFloat32=function(e,t){var i=void 0===t;if(i&&(t=this.offset),!this.noAssert){if("number"!=typeof e)throw TypeError("Illegal value: "+e+" (not a number)");if("number"!=typeof t||t%1!==0)throw TypeError("Illegal offset: "+t+" (not an integer)");if(t>>>=0,0>t||t+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+0) <= "+this.buffer.byteLength)}t+=4;var r=this.buffer.byteLength;return t>r&&this.resize((r*=2)>t?r:t),t-=4,n(this.view,e,t,this.littleEndian,23,4),i&&(this.offset+=4),this},s.writeFloat=s.writeFloat32,s.readFloat32=function(e){var t=void 0===e;if(t&&(e=this.offset),!this.noAssert){if("number"!=typeof e||e%1!==0)throw TypeError("Illegal offset: "+e+" (not an integer)");if(e>>>=0,0>e||e+4>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+e+" (+4) <= "+this.buffer.byteLength)}var i=r(this.view,e,this.littleEndian,23,4);return t&&(this.offset+=4),i},s.readFloat=s.readFloat32,s.writeFloat64=function(e,t){var i=void 0===t;if(i&&(t=this.offset),!this.noAssert){if("number"!=typeof e)throw TypeError("Illegal value: "+e+" (not a number)");if("number"!=typeof t||t%1!==0)throw TypeError("Illegal offset: "+t+" (not an integer)");if(t>>>=0,0>t||t+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+0) <= "+this.buffer.byteLength)}t+=8;var r=this.buffer.byteLength;return t>r&&this.resize((r*=2)>t?r:t),t-=8,n(this.view,e,t,this.littleEndian,52,8),i&&(this.offset+=8),this},s.writeDouble=s.writeFloat64,s.readFloat64=function(e){var t=void 0===e;if(t&&(e=this.offset),!this.noAssert){if("number"!=typeof e||e%1!==0)throw TypeError("Illegal offset: "+e+" (not an integer)");if(e>>>=0,0>e||e+8>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+e+" (+8) <= "+this.buffer.byteLength)}var i=r(this.view,e,this.littleEndian,52,8);return t&&(this.offset+=8),i},s.readDouble=s.readFloat64,o.MAX_VARINT32_BYTES=5,o.calculateVarint32=function(e){return e>>>=0,128>e?1:16384>e?2:1<<21>e?3:1<<28>e?4:5},o.zigZagEncode32=function(e){return((e|=0)<<1^e>>31)>>>0},o.zigZagDecode32=function(e){return e>>>1^-(1&e)|0},s.writeVarint32=function(e,t){var i=void 0===t;if(i&&(t=this.offset),!this.noAssert){if("number"!=typeof e||e%1!==0)throw TypeError("Illegal value: "+e+" (not an integer)");if(e|=0,"number"!=typeof t||t%1!==0)throw TypeError("Illegal offset: "+t+" (not an integer)");if(t>>>=0,0>t||t+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+0) <= "+this.buffer.byteLength)}var r,n=o.calculateVarint32(e);t+=n;var s=this.buffer.byteLength;for(t>s&&this.resize((s*=2)>t?s:t),t-=n,e>>>=0;e>=128;)r=127&e|128,this.view[t++]=r,e>>>=7;return this.view[t++]=e,i?(this.offset=t,this):n},s.writeVarint32ZigZag=function(e,t){return this.writeVarint32(o.zigZagEncode32(e),t)},s.readVarint32=function(e){var t=void 0===e;if(t&&(e=this.offset),!this.noAssert){if("number"!=typeof e||e%1!==0)throw TypeError("Illegal offset: "+e+" (not an integer)");if(e>>>=0,0>e||e+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+e+" (+1) <= "+this.buffer.byteLength)}var i,r=0,n=0;do{if(!this.noAssert&&e>this.limit){var o=Error("Truncated");throw o.truncated=!0,o}i=this.view[e++],5>r&&(n|=(127&i)<<7*r),++r}while(0!==(128&i));return n|=0,t?(this.offset=e,n):{value:n,length:r}},s.readVarint32ZigZag=function(e){var t=this.readVarint32(e);return"object"==typeof t?t.value=o.zigZagDecode32(t.value):t=o.zigZagDecode32(t),t},e&&(o.MAX_VARINT64_BYTES=10,o.calculateVarint64=function(t){"number"==typeof t?t=e.fromNumber(t):"string"==typeof t&&(t=e.fromString(t));var i=t.toInt()>>>0,r=t.shiftRightUnsigned(28).toInt()>>>0,n=t.shiftRightUnsigned(56).toInt()>>>0;return 0==n?0==r?16384>i?128>i?1:2:1<<21>i?3:4:16384>r?128>r?5:6:1<<21>r?7:8:128>n?9:10},o.zigZagEncode64=function(t){return"number"==typeof t?t=e.fromNumber(t,!1):"string"==typeof t?t=e.fromString(t,!1):t.unsigned!==!1&&(t=t.toSigned()),t.shiftLeft(1).xor(t.shiftRight(63)).toUnsigned()},o.zigZagDecode64=function(t){return"number"==typeof t?t=e.fromNumber(t,!1):"string"==typeof t?t=e.fromString(t,!1):t.unsigned!==!1&&(t=t.toSigned()),t.shiftRightUnsigned(1).xor(t.and(e.ONE).toSigned().negate()).toSigned()},s.writeVarint64=function(t,i){var r=void 0===i;if(r&&(i=this.offset),!this.noAssert){if("number"==typeof t)t=e.fromNumber(t);else if("string"==typeof t)t=e.fromString(t);else if(!(t&&t instanceof e))throw TypeError("Illegal value: "+t+" (not an integer or Long)");if("number"!=typeof i||i%1!==0)throw TypeError("Illegal offset: "+i+" (not an integer)");if(i>>>=0,0>i||i+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+i+" (+0) <= "+this.buffer.byteLength)}"number"==typeof t?t=e.fromNumber(t,!1):"string"==typeof t?t=e.fromString(t,!1):t.unsigned!==!1&&(t=t.toSigned());var n=o.calculateVarint64(t),s=t.toInt()>>>0,a=t.shiftRightUnsigned(28).toInt()>>>0,l=t.shiftRightUnsigned(56).toInt()>>>0;i+=n;var u=this.buffer.byteLength;switch(i>u&&this.resize((u*=2)>i?u:i),i-=n,n){case 10:this.view[i+9]=l>>>7&1;case 9:this.view[i+8]=9!==n?128|l:127&l;case 8:this.view[i+7]=8!==n?a>>>21|128:a>>>21&127;case 7:this.view[i+6]=7!==n?a>>>14|128:a>>>14&127;case 6:this.view[i+5]=6!==n?a>>>7|128:a>>>7&127;case 5:this.view[i+4]=5!==n?128|a:127&a;case 4:this.view[i+3]=4!==n?s>>>21|128:s>>>21&127;case 3:this.view[i+2]=3!==n?s>>>14|128:s>>>14&127;case 2:this.view[i+1]=2!==n?s>>>7|128:s>>>7&127;case 1:this.view[i]=1!==n?128|s:127&s}return r?(this.offset+=n,this):n},s.writeVarint64ZigZag=function(e,t){return this.writeVarint64(o.zigZagEncode64(e),t)},s.readVarint64=function(t){var i=void 0===t;if(i&&(t=this.offset),!this.noAssert){if("number"!=typeof t||t%1!==0)throw TypeError("Illegal offset: "+t+" (not an integer)");if(t>>>=0,0>t||t+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+1) <= "+this.buffer.byteLength)}var r=t,n=0,o=0,s=0,a=0;if(a=this.view[t++],n=127&a,128&a&&(a=this.view[t++],n|=(127&a)<<7,(128&a||this.noAssert&&void 0===a)&&(a=this.view[t++],n|=(127&a)<<14,(128&a||this.noAssert&&void 0===a)&&(a=this.view[t++],n|=(127&a)<<21,(128&a||this.noAssert&&void 0===a)&&(a=this.view[t++],o=127&a,(128&a||this.noAssert&&void 0===a)&&(a=this.view[t++],o|=(127&a)<<7,(128&a||this.noAssert&&void 0===a)&&(a=this.view[t++],o|=(127&a)<<14,(128&a||this.noAssert&&void 0===a)&&(a=this.view[t++],o|=(127&a)<<21,(128&a||this.noAssert&&void 0===a)&&(a=this.view[t++],s=127&a,(128&a||this.noAssert&&void 0===a)&&(a=this.view[t++],s|=(127&a)<<7,128&a||this.noAssert&&void 0===a))))))))))throw Error("Buffer overrun");var l=e.fromBits(n|o<<28,o>>>4|s<<24,!1);return i?(this.offset=t,l):{value:l,length:t-r}},s.readVarint64ZigZag=function(t){var i=this.readVarint64(t);return i&&i.value instanceof e?i.value=o.zigZagDecode64(i.value):i=o.zigZagDecode64(i),i}),s.writeCString=function(e,i){var r=void 0===i;r&&(i=this.offset);var n,o=e.length;if(!this.noAssert){if("string"!=typeof e)throw TypeError("Illegal str: Not a string");for(n=0;o>n;++n)if(0===e.charCodeAt(n))throw RangeError("Illegal str: Contains NULL-characters");if("number"!=typeof i||i%1!==0)throw TypeError("Illegal offset: "+i+" (not an integer)");if(i>>>=0,0>i||i+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+i+" (+0) <= "+this.buffer.byteLength)}o=d.calculateUTF16asUTF8(t(e))[1],i+=o+1;var s=this.buffer.byteLength;return i>s&&this.resize((s*=2)>i?s:i),i-=o+1,d.encodeUTF16toUTF8(t(e),function(e){this.view[i++]=e}.bind(this)),this.view[i++]=0,r?(this.offset=i,this):o},s.readCString=function(e){var t=void 0===e;if(t&&(e=this.offset),!this.noAssert){if("number"!=typeof e||e%1!==0)throw TypeError("Illegal offset: "+e+" (not an integer)");if(e>>>=0,0>e||e+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+e+" (+1) <= "+this.buffer.byteLength)}var r,n=e,o=-1;return d.decodeUTF8toUTF16(function(){if(0===o)return null;if(e>=this.limit)throw RangeError("Illegal range: Truncated data, "+e+" < "+this.limit);return o=this.view[e++],0===o?null:o}.bind(this),r=i(),!0),t?(this.offset=e,r()):{string:r(),length:e-n}},s.writeIString=function(e,i){var r=void 0===i;if(r&&(i=this.offset),!this.noAssert){if("string"!=typeof e)throw TypeError("Illegal str: Not a string");if("number"!=typeof i||i%1!==0)throw TypeError("Illegal offset: "+i+" (not an integer)");if(i>>>=0,0>i||i+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+i+" (+0) <= "+this.buffer.byteLength)}var n,o=i;n=d.calculateUTF16asUTF8(t(e),this.noAssert)[1],i+=4+n;var s=this.buffer.byteLength;if(i>s&&this.resize((s*=2)>i?s:i),i-=4+n,this.littleEndian?(this.view[i+3]=n>>>24&255,this.view[i+2]=n>>>16&255,this.view[i+1]=n>>>8&255,this.view[i]=255&n):(this.view[i]=n>>>24&255,this.view[i+1]=n>>>16&255,this.view[i+2]=n>>>8&255,this.view[i+3]=255&n),i+=4,d.encodeUTF16toUTF8(t(e),function(e){this.view[i++]=e}.bind(this)),i!==o+4+n)throw RangeError("Illegal range: Truncated data, "+i+" == "+(i+4+n));return r?(this.offset=i,this):i-o},s.readIString=function(e){var t=void 0===e;if(t&&(e=this.offset),!this.noAssert){if("number"!=typeof e||e%1!==0)throw TypeError("Illegal offset: "+e+" (not an integer)");if(e>>>=0,0>e||e+4>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+e+" (+4) <= "+this.buffer.byteLength)}var i=e,r=this.readUint32(e),n=this.readUTF8String(r,o.METRICS_BYTES,e+=4);return e+=n.length,t?(this.offset=e,n.string):{string:n.string,length:e-i}},o.METRICS_CHARS="c",o.METRICS_BYTES="b",s.writeUTF8String=function(e,i){var r=void 0===i;if(r&&(i=this.offset),!this.noAssert){if("number"!=typeof i||i%1!==0)throw TypeError("Illegal offset: "+i+" (not an integer)");if(i>>>=0,0>i||i+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+i+" (+0) <= "+this.buffer.byteLength)}var n,o=i;n=d.calculateUTF16asUTF8(t(e))[1],i+=n;var s=this.buffer.byteLength;return i>s&&this.resize((s*=2)>i?s:i),i-=n,d.encodeUTF16toUTF8(t(e),function(e){this.view[i++]=e}.bind(this)),r?(this.offset=i,this):i-o},s.writeString=s.writeUTF8String,o.calculateUTF8Chars=function(e){return d.calculateUTF16asUTF8(t(e))[0]},o.calculateUTF8Bytes=function(e){return d.calculateUTF16asUTF8(t(e))[1]},o.calculateString=o.calculateUTF8Bytes,s.readUTF8String=function(e,t,r){"number"==typeof t&&(r=t,t=void 0);var n=void 0===r;if(n&&(r=this.offset),void 0===t&&(t=o.METRICS_CHARS),!this.noAssert){if("number"!=typeof e||e%1!==0)throw TypeError("Illegal length: "+e+" (not an integer)");if(e|=0,"number"!=typeof r||r%1!==0)throw TypeError("Illegal offset: "+r+" (not an integer)");if(r>>>=0,0>r||r+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+r+" (+0) <= "+this.buffer.byteLength)}var s,a=0,l=r;if(t===o.METRICS_CHARS){if(s=i(),d.decodeUTF8(function(){return e>a&&r>>=0,0>r||r+e>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+r+" (+"+e+") <= "+this.buffer.byteLength)}var u=r+e;if(d.decodeUTF8toUTF16(function(){return u>r?this.view[r++]:null}.bind(this),s=i(),this.noAssert),r!==u)throw RangeError("Illegal range: Truncated data, "+r+" == "+u);return n?(this.offset=r,s()):{string:s(),length:r-l}}throw TypeError("Unsupported metrics: "+t)},s.readString=s.readUTF8String,s.writeVString=function(e,i){var r=void 0===i;if(r&&(i=this.offset),!this.noAssert){if("string"!=typeof e)throw TypeError("Illegal str: Not a string");if("number"!=typeof i||i%1!==0)throw TypeError("Illegal offset: "+i+" (not an integer)");if(i>>>=0,0>i||i+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+i+" (+0) <= "+this.buffer.byteLength)}var n,s,a=i;n=d.calculateUTF16asUTF8(t(e),this.noAssert)[1],s=o.calculateVarint32(n),i+=s+n;var l=this.buffer.byteLength;if(i>l&&this.resize((l*=2)>i?l:i),i-=s+n,i+=this.writeVarint32(n,i),d.encodeUTF16toUTF8(t(e),function(e){this.view[i++]=e}.bind(this)),i!==a+n+s)throw RangeError("Illegal range: Truncated data, "+i+" == "+(i+n+s));return r?(this.offset=i,this):i-a},s.readVString=function(e){var t=void 0===e;if(t&&(e=this.offset),!this.noAssert){if("number"!=typeof e||e%1!==0)throw TypeError("Illegal offset: "+e+" (not an integer)");if(e>>>=0,0>e||e+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+e+" (+1) <= "+this.buffer.byteLength)}var i=e,r=this.readVarint32(e),n=this.readUTF8String(r.value,o.METRICS_BYTES,e+=r.length);return e+=n.length,t?(this.offset=e,n.string):{string:n.string,length:e-i}},s.append=function(e,t,i){"number"!=typeof t&&"string"==typeof t||(i=t,t=void 0);var r=void 0===i;if(r&&(i=this.offset),!this.noAssert){if("number"!=typeof i||i%1!==0)throw TypeError("Illegal offset: "+i+" (not an integer)");if(i>>>=0,0>i||i+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+i+" (+0) <= "+this.buffer.byteLength)}e instanceof o||(e=o.wrap(e,t));var n=e.limit-e.offset;if(0>=n)return this;i+=n;var s=this.buffer.byteLength;return i>s&&this.resize((s*=2)>i?s:i),i-=n,this.view.set(e.view.subarray(e.offset,e.limit),i),e.offset+=n,r&&(this.offset+=n),this},s.appendTo=function(e,t){return e.append(this,t),this},s.assert=function(e){return this.noAssert=!e,this},s.capacity=function(){return this.buffer.byteLength},s.clear=function(){return this.offset=0,this.limit=this.buffer.byteLength,this.markedOffset=-1,this},s.clone=function(e){var t=new o(0,this.littleEndian,this.noAssert);return e?(t.buffer=new ArrayBuffer(this.buffer.byteLength),t.view=new Uint8Array(t.buffer)):(t.buffer=this.buffer,t.view=this.view),t.offset=this.offset,t.markedOffset=this.markedOffset,t.limit=this.limit,t},s.compact=function(e,t){if(void 0===e&&(e=this.offset),void 0===t&&(t=this.limit),!this.noAssert){if("number"!=typeof e||e%1!==0)throw TypeError("Illegal begin: Not an integer");if(e>>>=0,"number"!=typeof t||t%1!==0)throw TypeError("Illegal end: Not an integer");if(t>>>=0,0>e||e>t||t>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+e+" <= "+t+" <= "+this.buffer.byteLength)}if(0===e&&t===this.buffer.byteLength)return this;var i=t-e;if(0===i)return this.buffer=a,this.view=null,this.markedOffset>=0&&(this.markedOffset-=e),this.offset=0,this.limit=0,this;var r=new ArrayBuffer(i),n=new Uint8Array(r);return n.set(this.view.subarray(e,t)),this.buffer=r,this.view=n,this.markedOffset>=0&&(this.markedOffset-=e),this.offset=0,this.limit=i,this},s.copy=function(e,t){if(void 0===e&&(e=this.offset),void 0===t&&(t=this.limit),!this.noAssert){if("number"!=typeof e||e%1!==0)throw TypeError("Illegal begin: Not an integer");if(e>>>=0,"number"!=typeof t||t%1!==0)throw TypeError("Illegal end: Not an integer");if(t>>>=0,0>e||e>t||t>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+e+" <= "+t+" <= "+this.buffer.byteLength)}if(e===t)return new o(0,this.littleEndian,this.noAssert);var i=t-e,r=new o(i,this.littleEndian,this.noAssert);return r.offset=0,r.limit=i,r.markedOffset>=0&&(r.markedOffset-=e),this.copyTo(r,0,e,t),r},s.copyTo=function(e,t,i,r){var n,s;if(!this.noAssert&&!o.isByteBuffer(e))throw TypeError("Illegal target: Not a ByteBuffer");if(t=(s=void 0===t)?e.offset:0|t,i=(n=void 0===i)?this.offset:0|i,r=void 0===r?this.limit:0|r,0>t||t>e.buffer.byteLength)throw RangeError("Illegal target range: 0 <= "+t+" <= "+e.buffer.byteLength);if(0>i||r>this.buffer.byteLength)throw RangeError("Illegal source range: 0 <= "+i+" <= "+this.buffer.byteLength);var a=r-i;return 0===a?e:(e.ensureCapacity(t+a),e.view.set(this.view.subarray(i,r),t),n&&(this.offset+=a),s&&(e.offset+=a),this)},s.ensureCapacity=function(e){var t=this.buffer.byteLength;return e>t?this.resize((t*=2)>e?t:e):this},s.fill=function(e,t,i){var r=void 0===t;if(r&&(t=this.offset),"string"==typeof e&&e.length>0&&(e=e.charCodeAt(0)),void 0===t&&(t=this.offset),void 0===i&&(i=this.limit),!this.noAssert){if("number"!=typeof e||e%1!==0)throw TypeError("Illegal value: "+e+" (not an integer)");if(e|=0,"number"!=typeof t||t%1!==0)throw TypeError("Illegal begin: Not an integer");if(t>>>=0,"number"!=typeof i||i%1!==0)throw TypeError("Illegal end: Not an integer");if(i>>>=0,0>t||t>i||i>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+t+" <= "+i+" <= "+this.buffer.byteLength)}if(t>=i)return this;for(;i>t;)this.view[t++]=e;return r&&(this.offset=t),this},s.flip=function(){return this.limit=this.offset,this.offset=0,this},s.mark=function(e){if(e=void 0===e?this.offset:e,!this.noAssert){if("number"!=typeof e||e%1!==0)throw TypeError("Illegal offset: "+e+" (not an integer)");if(e>>>=0,0>e||e+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+e+" (+0) <= "+this.buffer.byteLength)}return this.markedOffset=e,this},s.order=function(e){if(!this.noAssert&&"boolean"!=typeof e)throw TypeError("Illegal littleEndian: Not a boolean");return this.littleEndian=!!e,this},s.LE=function(e){return this.littleEndian=void 0!==e?!!e:!0,this},s.BE=function(e){return this.littleEndian=void 0!==e?!e:!1,this},s.prepend=function(e,t,i){"number"!=typeof t&&"string"==typeof t||(i=t,t=void 0);var r=void 0===i;if(r&&(i=this.offset),!this.noAssert){if("number"!=typeof i||i%1!==0)throw TypeError("Illegal offset: "+i+" (not an integer)");if(i>>>=0,0>i||i+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+i+" (+0) <= "+this.buffer.byteLength)}e instanceof o||(e=o.wrap(e,t));var n=e.limit-e.offset;if(0>=n)return this;var s=n-i;if(s>0){var a=new ArrayBuffer(this.buffer.byteLength+s),l=new Uint8Array(a);l.set(this.view.subarray(i,this.buffer.byteLength),n),this.buffer=a,this.view=l,this.offset+=s,this.markedOffset>=0&&(this.markedOffset+=s),this.limit+=s,i+=s}else{new Uint8Array(this.buffer)}return this.view.set(e.view.subarray(e.offset,e.limit),i-n),e.offset=e.limit,r&&(this.offset-=n),this},s.prependTo=function(e,t){return e.prepend(this,t),this},s.printDebug=function(e){"function"!=typeof e&&(e=console.log.bind(console)),e(""+this+"\n-------------------------------------------------------------------\n"+this.toDebug(!0))},s.remaining=function(){return this.limit-this.offset},s.reset=function(){return this.markedOffset>=0?(this.offset=this.markedOffset,this.markedOffset=-1):this.offset=0,this},s.resize=function(e){if(!this.noAssert){if("number"!=typeof e||e%1!==0)throw TypeError("Illegal capacity: "+e+" (not an integer)");if(e|=0,0>e)throw RangeError("Illegal capacity: 0 <= "+e)}if(this.buffer.byteLength>>=0,"number"!=typeof t||t%1!==0)throw TypeError("Illegal end: Not an integer");if(t>>>=0,0>e||e>t||t>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+e+" <= "+t+" <= "+this.buffer.byteLength)}return e===t?this:(Array.prototype.reverse.call(this.view.subarray(e,t)),this)},s.skip=function(e){if(!this.noAssert){if("number"!=typeof e||e%1!==0)throw TypeError("Illegal length: "+e+" (not an integer)");e|=0}var t=this.offset+e;if(!this.noAssert&&(0>t||t>this.buffer.byteLength))throw RangeError("Illegal length: 0 <= "+this.offset+" + "+e+" <= "+this.buffer.byteLength);return this.offset=t,this},s.slice=function(e,t){if(void 0===e&&(e=this.offset),void 0===t&&(t=this.limit),!this.noAssert){if("number"!=typeof e||e%1!==0)throw TypeError("Illegal begin: Not an integer");if(e>>>=0,"number"!=typeof t||t%1!==0)throw TypeError("Illegal end: Not an integer");if(t>>>=0,0>e||e>t||t>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+e+" <= "+t+" <= "+this.buffer.byteLength)}var i=this.clone();return i.offset=e,i.limit=t,i},s.toBuffer=function(e){var t=this.offset,i=this.limit;if(!this.noAssert){if("number"!=typeof t||t%1!==0)throw TypeError("Illegal offset: Not an integer");if(t>>>=0,"number"!=typeof i||i%1!==0)throw TypeError("Illegal limit: Not an integer");if(i>>>=0,0>t||t>i||i>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+t+" <= "+i+" <= "+this.buffer.byteLength)}if(!e&&0===t&&i===this.buffer.byteLength)return this.buffer;if(t===i)return a;var r=new ArrayBuffer(i-t);return new Uint8Array(r).set(new Uint8Array(this.buffer).subarray(t,i),0),r},s.toArrayBuffer=s.toBuffer,s.toString=function(e,t,i){if(void 0===e)return"ByteBufferAB(offset="+this.offset+",markedOffset="+this.markedOffset+",limit="+this.limit+",capacity="+this.capacity()+")";switch("number"==typeof e&&(e="utf8",t=e,i=t),e){case"utf8":return this.toUTF8(t,i);case"base64":return this.toBase64(t,i);case"hex":return this.toHex(t,i);case"binary":return this.toBinary(t,i);case"debug":return this.toDebug();case"columns":return this.toColumns();default:throw Error("Unsupported encoding: "+e)}};var u=function(){for(var e={},t=[65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,48,49,50,51,52,53,54,55,56,57,43,47],i=[],r=0,n=t.length;n>r;++r)i[t[r]]=r;return e.encode=function(e,i){for(var r,n;null!==(r=e());)i(t[r>>2&63]),n=(3&r)<<4,null!==(r=e())?(n|=r>>4&15,i(t[63&(n|r>>4&15)]),n=(15&r)<<2,null!==(r=e())?(i(t[63&(n|r>>6&3)]),i(t[63&r])):(i(t[63&n]),i(61))):(i(t[63&n]),i(61),i(61))},e.decode=function(e,t){function r(e){throw Error("Illegal character code: "+e)}for(var n,o,s;null!==(n=e());)if(o=i[n],void 0===o&&r(n),null!==(n=e())&&(s=i[n],void 0===s&&r(n),t(o<<2>>>0|(48&s)>>4),null!==(n=e()))){if(o=i[n],void 0===o){if(61===n)break;r(n)}if(t((15&s)<<4>>>0|(60&o)>>2),null!==(n=e())){if(s=i[n],void 0===s){if(61===n)break;r(n)}t((3&o)<<6>>>0|s)}}},e.test=function(e){return/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/.test(e)},e}();s.toBase64=function(e,t){if(void 0===e&&(e=this.offset),void 0===t&&(t=this.limit),e=0|e,t=0|t,0>e||t>this.capacity||e>t)throw RangeError("begin, end");var r;return u.encode(function(){return t>e?this.view[e++]:null}.bind(this),r=i()), r()},o.fromBase64=function(e,i){if("string"!=typeof e)throw TypeError("str");var r=new o(e.length/4*3,i),n=0;return u.decode(t(e),function(e){r.view[n++]=e}),r.limit=n,r},o.btoa=function(e){return o.fromBinary(e).toBase64()},o.atob=function(e){return o.fromBase64(e).toBinary()},s.toBinary=function(e,t){if(void 0===e&&(e=this.offset),void 0===t&&(t=this.limit),e|=0,t|=0,0>e||t>this.capacity()||e>t)throw RangeError("begin, end");if(e===t)return"";for(var i=[],r=[];t>e;)i.push(this.view[e++]),i.length>=1024&&(r.push(String.fromCharCode.apply(String,i)),i=[]);return r.join("")+String.fromCharCode.apply(String,i)},o.fromBinary=function(e,t){if("string"!=typeof e)throw TypeError("str");for(var i,r=0,n=e.length,s=new o(n,t);n>r;){if(i=e.charCodeAt(r),i>255)throw RangeError("illegal char code: "+i);s.view[r++]=i}return s.limit=n,s},s.toDebug=function(e){for(var t,i=-1,r=this.buffer.byteLength,n="",o="",s="";r>i;){if(-1!==i&&(t=this.view[i],n+=16>t?"0"+t.toString(16).toUpperCase():t.toString(16).toUpperCase(),e&&(o+=t>32&&127>t?String.fromCharCode(t):".")),++i,e&&i>0&&i%16===0&&i!==r){for(;n.length<51;)n+=" ";s+=n+o+"\n",n=o=""}n+=i===this.offset&&i===this.limit?i===this.markedOffset?"!":"|":i===this.offset?i===this.markedOffset?"[":"<":i===this.limit?i===this.markedOffset?"]":">":i===this.markedOffset?"'":e||0!==i&&i!==r?" ":""}if(e&&" "!==n){for(;n.length<51;)n+=" ";s+=n+o+"\n"}return e?s:n},o.fromDebug=function(e,t,i){for(var r,n,s=e.length,a=new o((s+1)/3|0,t,i),l=0,u=0,d=!1,c=!1,p=!1,f=!1,h=!1;s>l;){switch(r=e.charAt(l++)){case"!":if(!i){if(c||p||f){h=!0;break}c=p=f=!0}a.offset=a.markedOffset=a.limit=u,d=!1;break;case"|":if(!i){if(c||f){h=!0;break}c=f=!0}a.offset=a.limit=u,d=!1;break;case"[":if(!i){if(c||p){h=!0;break}c=p=!0}a.offset=a.markedOffset=u,d=!1;break;case"<":if(!i){if(c){h=!0;break}c=!0}a.offset=u,d=!1;break;case"]":if(!i){if(f||p){h=!0;break}f=p=!0}a.limit=a.markedOffset=u,d=!1;break;case">":if(!i){if(f){h=!0;break}f=!0}a.limit=u,d=!1;break;case"'":if(!i){if(p){h=!0;break}p=!0}a.markedOffset=u,d=!1;break;case" ":d=!1;break;default:if(!i&&d){h=!0;break}if(n=parseInt(r+e.charAt(l++),16),!i&&(isNaN(n)||0>n||n>255))throw TypeError("Illegal str: Not a debug encoded string");a.view[u++]=n,d=!0}if(h)throw TypeError("Illegal str: Invalid symbol at "+l)}if(!i){if(!c||!f)throw TypeError("Illegal str: Missing offset or limit");if(u>>=0,"number"!=typeof t||t%1!==0)throw TypeError("Illegal end: Not an integer");if(t>>>=0,0>e||e>t||t>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+e+" <= "+t+" <= "+this.buffer.byteLength)}for(var i,r=Array(t-e);t>e;)i=this.view[e++],16>i?r.push("0",i.toString(16)):r.push(i.toString(16));return r.join("")},o.fromHex=function(e,t,i){if(!i){if("string"!=typeof e)throw TypeError("Illegal str: Not a string");if(e.length%2!==0)throw TypeError("Illegal str: Length not a multiple of 2")}for(var r,n=e.length,s=new o(n/2|0,t),a=0,l=0;n>a;a+=2){if(r=parseInt(e.substring(a,a+2),16),!i&&(!isFinite(r)||0>r||r>255))throw TypeError("Illegal str: Contains non-hex characters");s.view[l++]=r}return s.limit=l,s};var d=function(){var e={};return e.MAX_CODEPOINT=1114111,e.encodeUTF8=function(e,t){var i=null;for("number"==typeof e&&(i=e,e=function(){return null});null!==i||null!==(i=e());)128>i?t(127&i):2048>i?(t(i>>6&31|192),t(63&i|128)):65536>i?(t(i>>12&15|224),t(i>>6&63|128),t(63&i|128)):(t(i>>18&7|240),t(i>>12&63|128),t(i>>6&63|128),t(63&i|128)),i=null},e.decodeUTF8=function(e,t){for(var i,r,n,o,s=function(e){e=e.slice(0,e.indexOf(null));var t=Error(""+e);throw t.name="TruncatedError",t.bytes=e,t};null!==(i=e());)if(0===(128&i))t(i);else if(192===(224&i))null===(r=e())&&s([i,r]),t((31&i)<<6|63&r);else if(224===(240&i))(null===(r=e())||null===(n=e()))&&s([i,r,n]),t((15&i)<<12|(63&r)<<6|63&n);else{if(240!==(248&i))throw RangeError("Illegal starting byte: "+i);(null===(r=e())||null===(n=e())||null===(o=e()))&&s([i,r,n,o]),t((7&i)<<18|(63&r)<<12|(63&n)<<6|63&o)}},e.UTF16toUTF8=function(e,t){for(var i,r=null;;){if(null===(i=null!==r?r:e()))break;i>=55296&&57343>=i&&null!==(r=e())&&r>=56320&&57343>=r?(t(1024*(i-55296)+r-56320+65536),r=null):t(i)}null!==r&&t(r)},e.UTF8toUTF16=function(e,t){var i=null;for("number"==typeof e&&(i=e,e=function(){return null});null!==i||null!==(i=e());)65535>=i?t(i):(i-=65536,t((i>>10)+55296),t(i%1024+56320)),i=null},e.encodeUTF16toUTF8=function(t,i){e.UTF16toUTF8(t,function(t){e.encodeUTF8(t,i)})},e.decodeUTF8toUTF16=function(t,i){e.decodeUTF8(t,function(t){e.UTF8toUTF16(t,i)})},e.calculateCodePoint=function(e){return 128>e?1:2048>e?2:65536>e?3:4},e.calculateUTF8=function(e){for(var t,i=0;null!==(t=e());)i+=128>t?1:2048>t?2:65536>t?3:4;return i},e.calculateUTF16asUTF8=function(t){var i=0,r=0;return e.UTF16toUTF8(t,function(e){++i,r+=128>e?1:2048>e?2:65536>e?3:4}),[i,r]},e}();return s.toUTF8=function(e,t){if(void 0===e&&(e=this.offset),void 0===t&&(t=this.limit),!this.noAssert){if("number"!=typeof e||e%1!==0)throw TypeError("Illegal begin: Not an integer");if(e>>>=0,"number"!=typeof t||t%1!==0)throw TypeError("Illegal end: Not an integer");if(t>>>=0,0>e||e>t||t>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+e+" <= "+t+" <= "+this.buffer.byteLength)}var r;try{d.decodeUTF8toUTF16(function(){return t>e?this.view[e++]:null}.bind(this),r=i())}catch(n){if(e!==t)throw RangeError("Illegal range: Truncated data, "+e+" != "+t)}return r()},o.fromUTF8=function(e,i,r){if(!r&&"string"!=typeof e)throw TypeError("Illegal str: Not a string");var n=new o(d.calculateUTF16asUTF8(t(e),!0)[1],i,r),s=0;return d.encodeUTF16toUTF8(t(e),function(e){n.view[s++]=e}),n.limit=s,n},o})}).call(t,i(11)(e))},333:function(e,t,i){var r,n,o;(function(e){!function(s,a){i(331).amd?(n=[],r=a,o="function"==typeof r?r.apply(t,n):r,!(void 0!==o&&(e.exports=o))):"object"==typeof e&&e&&e.exports?e.exports=a():(s.dcodeIO=s.dcodeIO||{}).Long=a()}(this,function(){"use strict";function e(e,t,i){this.low=0|e,this.high=0|t,this.unsigned=!!i}function t(e){return(e&&e.__isLong__)===!0}function i(e,t){var i,r,o;return t?(e>>>=0,(o=e>=0&&256>e)&&(r=l[e])?r:(i=n(e,0>(0|e)?-1:0,!0),o&&(l[e]=i),i)):(e|=0,(o=e>=-128&&128>e)&&(r=a[e])?r:(i=n(e,0>e?-1:0,!1),o&&(a[e]=i),i))}function r(e,t){if(isNaN(e)||!isFinite(e))return t?_:m;if(t){if(0>e)return _;if(e>=p)return T}else{if(-f>=e)return w;if(e+1>=f)return b}return 0>e?r(-e,t).neg():n(e%c|0,e/c|0,t)}function n(t,i,r){return new e(t,i,r)}function o(e,t,i){if(0===e.length)throw Error("empty string");if("NaN"===e||"Infinity"===e||"+Infinity"===e||"-Infinity"===e)return m;if("number"==typeof t?(i=t,t=!1):t=!!t,i=i||10,2>i||i>36)throw RangeError("radix");var n;if((n=e.indexOf("-"))>0)throw Error("interior hyphen");if(0===n)return o(e.substring(1),t,i).neg();for(var s=r(u(i,8)),a=m,l=0;ld){var p=r(u(i,d));a=a.mul(p).add(r(c))}else a=a.mul(s),a=a.add(r(c))}return a.unsigned=t,a}function s(t){return t instanceof e?t:"number"==typeof t?r(t):"string"==typeof t?o(t):n(t.low,t.high,t.unsigned)}e.__isLong__,Object.defineProperty(e.prototype,"__isLong__",{value:!0,enumerable:!1,configurable:!1}),e.isLong=t;var a={},l={};e.fromInt=i,e.fromNumber=r,e.fromBits=n;var u=Math.pow;e.fromString=o,e.fromValue=s;var d=1<<24,c=4294967296,p=0x10000000000000000,f=p/2,h=i(d),m=i(0);e.ZERO=m;var _=i(0,!0);e.UZERO=_;var g=i(1);e.ONE=g;var y=i(1,!0);e.UONE=y;var v=i(-1);e.NEG_ONE=v;var b=n(-1,2147483647,!1);e.MAX_VALUE=b;var T=n(-1,-1,!0);e.MAX_UNSIGNED_VALUE=T;var w=n(0,-2147483648,!1);e.MIN_VALUE=w;var E=e.prototype;return E.toInt=function(){return this.unsigned?this.low>>>0:this.low},E.toNumber=function(){return this.unsigned?(this.high>>>0)*c+(this.low>>>0):this.high*c+(this.low>>>0)},E.toString=function(e){if(e=e||10,2>e||e>36)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative()){if(this.eq(w)){var t=r(e),i=this.div(t),n=i.mul(t).sub(this);return i.toString(e)+n.toInt().toString(e)}return"-"+this.neg().toString(e)}for(var o=r(u(e,6),this.unsigned),s=this,a="";;){var l=s.div(o),d=s.sub(l.mul(o)).toInt()>>>0,c=d.toString(e);if(s=l,s.isZero())return c+a;for(;c.length<6;)c="0"+c;a=""+c+a}},E.getHighBits=function(){return this.high},E.getHighBitsUnsigned=function(){return this.high>>>0},E.getLowBits=function(){return this.low},E.getLowBitsUnsigned=function(){return this.low>>>0},E.getNumBitsAbs=function(){if(this.isNegative())return this.eq(w)?64:this.neg().getNumBitsAbs();for(var e=0!=this.high?this.high:this.low,t=31;t>0&&0==(e&1<=0},E.isOdd=function(){return 1===(1&this.low)},E.isEven=function(){return 0===(1&this.low)},E.equals=function(e){return t(e)||(e=s(e)),this.unsigned!==e.unsigned&&this.high>>>31===1&&e.high>>>31===1?!1:this.high===e.high&&this.low===e.low},E.eq=E.equals,E.notEquals=function(e){return!this.eq(e)},E.neq=E.notEquals,E.lessThan=function(e){return this.comp(e)<0},E.lt=E.lessThan,E.lessThanOrEqual=function(e){return this.comp(e)<=0},E.lte=E.lessThanOrEqual,E.greaterThan=function(e){return this.comp(e)>0},E.gt=E.greaterThan,E.greaterThanOrEqual=function(e){return this.comp(e)>=0},E.gte=E.greaterThanOrEqual,E.compare=function(e){if(t(e)||(e=s(e)),this.eq(e))return 0;var i=this.isNegative(),r=e.isNegative();return i&&!r?-1:!i&&r?1:this.unsigned?e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1:this.sub(e).isNegative()?-1:1},E.comp=E.compare,E.negate=function(){return!this.unsigned&&this.eq(w)?w:this.not().add(g)},E.neg=E.negate,E.add=function(e){t(e)||(e=s(e));var i=this.high>>>16,r=65535&this.high,o=this.low>>>16,a=65535&this.low,l=e.high>>>16,u=65535&e.high,d=e.low>>>16,c=65535&e.low,p=0,f=0,h=0,m=0;return m+=a+c,h+=m>>>16,m&=65535,h+=o+d,f+=h>>>16,h&=65535,f+=r+u,p+=f>>>16,f&=65535,p+=i+l,p&=65535,n(h<<16|m,p<<16|f,this.unsigned)},E.subtract=function(e){return t(e)||(e=s(e)),this.add(e.neg())},E.sub=E.subtract,E.multiply=function(e){if(this.isZero())return m;if(t(e)||(e=s(e)),e.isZero())return m;if(this.eq(w))return e.isOdd()?w:m;if(e.eq(w))return this.isOdd()?w:m;if(this.isNegative())return e.isNegative()?this.neg().mul(e.neg()):this.neg().mul(e).neg();if(e.isNegative())return this.mul(e.neg()).neg();if(this.lt(h)&&e.lt(h))return r(this.toNumber()*e.toNumber(),this.unsigned);var i=this.high>>>16,o=65535&this.high,a=this.low>>>16,l=65535&this.low,u=e.high>>>16,d=65535&e.high,c=e.low>>>16,p=65535&e.low,f=0,_=0,g=0,y=0;return y+=l*p,g+=y>>>16,y&=65535,g+=a*p,_+=g>>>16,g&=65535,g+=l*c,_+=g>>>16,g&=65535,_+=o*p,f+=_>>>16,_&=65535,_+=a*c,f+=_>>>16,_&=65535,_+=l*d,f+=_>>>16,_&=65535,f+=i*p+o*c+a*d+l*u,f&=65535,n(g<<16|y,f<<16|_,this.unsigned)},E.mul=E.multiply,E.divide=function(e){if(t(e)||(e=s(e)),e.isZero())throw Error("division by zero");if(this.isZero())return this.unsigned?_:m;var i,n,o;if(this.unsigned)e.unsigned||(e=e.toUnsigned());else{if(this.eq(w)){if(e.eq(g)||e.eq(v))return w;if(e.eq(w))return g;var a=this.shr(1);return i=a.div(e).shl(1),i.eq(m)?e.isNegative()?g:v:(n=this.sub(e.mul(i)),o=i.add(n.div(e)))}if(e.eq(w))return this.unsigned?_:m;if(this.isNegative())return e.isNegative()?this.neg().div(e.neg()):this.neg().div(e).neg();if(e.isNegative())return this.div(e.neg()).neg()}if(this.unsigned){if(e.gt(this))return _;if(e.gt(this.shru(1)))return y;o=_}else o=m;for(n=this;n.gte(e);){i=Math.max(1,Math.floor(n.toNumber()/e.toNumber()));for(var l=Math.ceil(Math.log(i)/Math.LN2),d=48>=l?1:u(2,l-48),c=r(i),p=c.mul(e);p.isNegative()||p.gt(n);)i-=d,c=r(i,this.unsigned),p=c.mul(e);c.isZero()&&(c=g),o=o.add(c),n=n.sub(p)}return o},E.div=E.divide,E.modulo=function(e){return t(e)||(e=s(e)),this.sub(this.div(e).mul(e))},E.mod=E.modulo,E.not=function(){return n(~this.low,~this.high,this.unsigned)},E.and=function(e){return t(e)||(e=s(e)),n(this.low&e.low,this.high&e.high,this.unsigned)},E.or=function(e){return t(e)||(e=s(e)),n(this.low|e.low,this.high|e.high,this.unsigned)},E.xor=function(e){return t(e)||(e=s(e)),n(this.low^e.low,this.high^e.high,this.unsigned)},E.shiftLeft=function(e){return t(e)&&(e=e.toInt()),0===(e&=63)?this:32>e?n(this.low<>>32-e,this.unsigned):n(0,this.low<e?n(this.low>>>e|this.high<<32-e,this.high>>e,this.unsigned):n(this.high>>e-32,this.high>=0?0:-1,this.unsigned)},E.shr=E.shiftRight,E.shiftRightUnsigned=function(e){if(t(e)&&(e=e.toInt()),e&=63,0===e)return this;var i=this.high;if(32>e){var r=this.low;return n(r>>>e|i<<32-e,i>>>e,this.unsigned)}return 32===e?n(i,0,this.unsigned):n(i>>>e-32,0,this.unsigned)},E.shru=E.shiftRightUnsigned,E.toSigned=function(){return this.unsigned?n(this.low,this.high,!1):this},E.toUnsigned=function(){return this.unsigned?this:n(this.low,this.high,!0)},e})}).call(t,i(11)(e))},334:function(e,t){},335:334,337:function(e,t){e.exports={"package":"WebAPI_1",messages:[{name:"ClientMsg",fields:[{rule:"optional",type:"Logon",name:"logon",id:100},{rule:"optional",type:"RestoreOrJoinSession",name:"restore_or_join_session",id:101},{rule:"optional",type:"Logoff",name:"logoff",id:102},{rule:"optional",type:"PasswordChange",name:"password_change",id:103},{rule:"optional",type:"ObtainDemoCredentials",name:"obtain_demo_credentials",id:104},{rule:"optional",type:"UserSessionStateRequest",name:"user_session_state_request",id:105},{rule:"optional",type:"Ping",name:"ping",id:107},{rule:"optional",type:"Pong",name:"pong",id:108},{rule:"optional",type:"LogonRoutineClient",name:"logon_routine_client",id:109},{rule:"optional",type:"PasswordChangeRoutineClient",name:"password_change_routine_client",id:110},{rule:"repeated",type:"InformationRequest",name:"information_request",id:1},{rule:"repeated",type:"TradeSubscription",name:"trade_subscription",id:2},{rule:"repeated",type:"OrderRequest",name:"order_request",id:3},{rule:"repeated",type:"MarketDataSubscription",name:"market_data_subscription",id:4},{rule:"repeated",type:"ReadUserAttributeRequest",name:"read_user_attribute_request",id:5},{rule:"repeated",type:"ModifyUserAttributeRequest",name:"modify_user_attribute_request",id:6},{rule:"repeated",type:"TimeAndSalesRequest",name:"time_and_sales_request",id:7},{rule:"repeated",type:"TimeBarRequest",name:"time_bar_request",id:8}]},{name:"ServerMsg",fields:[{rule:"optional",type:"LogonResult",name:"logon_result",id:100},{rule:"optional",type:"RestoreOrJoinSessionResult",name:"restore_or_join_session_result",id:101},{rule:"repeated",type:"ConcurrentConnectionJoin",name:"concurrent_connection_join",id:111},{rule:"optional",type:"LoggedOff",name:"logged_off",id:102},{rule:"optional",type:"PasswordChangeResult",name:"password_change_result",id:103},{rule:"repeated",type:"UserMessage",name:"user_message",id:104},{rule:"optional",type:"ObtainDemoCredentialsResult",name:"obtain_demo_credentials_result",id:105},{rule:"optional",type:"UserSessionStateResult",name:"user_session_state_result",id:106},{rule:"optional",type:"Ping",name:"ping",id:107},{rule:"optional",type:"Pong",name:"pong",id:108},{rule:"optional",type:"LogonRoutineServer",name:"logon_routine_server",id:109},{rule:"optional",type:"PasswordChangeRoutineServer",name:"password_change_routine_server",id:110},{rule:"repeated",type:"InformationReport",name:"information_report",id:1},{rule:"repeated",type:"OrderRequestReject",name:"order_request_reject",id:2},{rule:"repeated",type:"TradeSubscriptionStatus",name:"trade_subscription_status",id:3},{rule:"repeated",type:"TradeSnapshotCompletion",name:"trade_snapshot_completion",id:4},{rule:"repeated",type:"OrderStatus",name:"order_status",id:5},{rule:"repeated",type:"PositionStatus",name:"position_status",id:6},{rule:"repeated",type:"CollateralStatus",name:"collateral_status",id:7},{rule:"repeated",type:"MarketDataSubscriptionStatus",name:"market_data_subscription_status",id:8},{rule:"repeated",type:"RealTimeMarketData",name:"real_time_market_data",id:9},{rule:"repeated",type:"ReadUserAttributeResult",name:"read_user_attribute_result",id:10},{rule:"repeated",type:"ModifyUserAttributeResult",name:"modify_user_attribute_result",id:11},{rule:"repeated",type:"TimeAndSalesReport",name:"time_and_sales_report",id:12},{rule:"repeated",type:"TimeBarReport",name:"time_bar_report",id:13}]},{name:"RealTimeCollapsing",fields:[],enums:[{name:"Level",values:[{name:"NONE",id:0},{name:"DOM",id:1},{name:"DOM_BBA",id:2},{name:"DOM_BBA_TRADES",id:3}]}]},{name:"Logon",fields:[{rule:"required",type:"string",name:"user_name",id:1},{rule:"required",type:"string",name:"password",id:2},{rule:"optional",type:"string",name:"one_time_password",id:3},{rule:"optional",type:"string",name:"private_label",id:4},{rule:"required",type:"string",name:"client_app_id",id:5},{rule:"required",type:"string",name:"client_version",id:6},{rule:"optional",type:"bool",name:"drop_concurrent_session",id:7},{rule:"optional",type:"uint32",name:"collapsing_level",id:8},{rule:"optional",type:"uint32",name:"protocol_version_minor",id:9},{rule:"optional",type:"uint32",name:"protocol_version_major",id:10},{rule:"repeated",type:"uint32",name:"session_settings",id:11}],enums:[{name:"SessionSetting",values:[{name:"ALLOW_SESSION_RESTORE",id:1},{name:"ALLOW_SESSION_JOIN",id:2}]}]},{name:"LogonResult",fields:[{rule:"required",type:"uint32",name:"result_code",id:1},{rule:"required",type:"string",name:"base_time",id:2},{rule:"optional",type:"string",name:"session_token",id:3},{rule:"optional",type:"string",name:"text_message",id:4},{rule:"optional",type:"string",name:"redirect_url",id:5},{rule:"required",type:"uint32",name:"protocol_version_minor",id:6},{rule:"required",type:"uint32",name:"protocol_version_major",id:7},{rule:"optional",type:"sint32",name:"user_id",id:8}],enums:[{name:"ResultCode",values:[{name:"SUCCESS",id:0},{name:"FAILURE",id:101},{name:"NO_ONETIME_PASSWORD",id:103},{name:"PASSWORD_EXPIRED",id:104},{name:"CONCURRENT_SESSION",id:105},{name:"REDIRECTED",id:106},{name:"ROUTINE_ERROR",id:107}]}]},{name:"LogonRoutineClient",fields:[{rule:"optional",type:"LogonInit",name:"logon_init",id:1},{rule:"repeated",type:"PasswordResponse",name:"password_response",id:2},{rule:"optional",type:"bool",name:"trader_agreement_accepted",id:3},{rule:"optional",type:"AbortRoutine",name:"abort_logon",id:4}]},{name:"LogonRoutineServer",fields:[{rule:"optional",type:"LogonResult",name:"logon_result",id:1},{rule:"repeated",type:"PasswordRequest",name:"password_request",id:2},{rule:"optional",type:"string",name:"trader_agreement_url",id:3}]},{name:"PasswordChangeRoutineClient",fields:[{rule:"optional",type:"bool",name:"init_password_change",id:1},{rule:"repeated",type:"PasswordResponse",name:"password_response",id:2},{rule:"optional",type:"AbortRoutine",name:"abort_password_change",id:3}]},{name:"PasswordChangeRoutineServer",fields:[{rule:"repeated",type:"PasswordRequest",name:"password_request",id:1},{rule:"optional",type:"PasswordChangeResult",name:"password_change_result",id:2}]},{name:"AbortRoutine",fields:[{rule:"optional",type:"string",name:"comment",id:1}]},{name:"LogonInit",fields:[{rule:"required",type:"string",name:"user_name",id:1},{rule:"optional",type:"string",name:"private_label",id:2},{rule:"required",type:"string",name:"client_app_id",id:3},{rule:"required",type:"string",name:"client_version",id:4},{rule:"optional",type:"bool",name:"drop_concurrent_session",id:5},{rule:"optional",type:"uint32",name:"collapsing_level",id:6},{rule:"optional",type:"uint32",name:"protocol_version_minor",id:7},{rule:"optional",type:"uint32",name:"protocol_version_major",id:8},{rule:"repeated",type:"uint32",name:"session_settings",id:9}]},{name:"PasswordRequest",fields:[{rule:"required",type:"uint32",name:"request_id",id:1},{rule:"required",type:"uint32",name:"password_type",id:2},{rule:"optional",type:"string",name:"user_prompt_type",id:3},{rule:"optional",type:"string",name:"user_prompt_type_alt",id:4},{rule:"optional",type:"string",name:"user_prompt",id:5},{rule:"repeated",type:"Encoding",name:"encoding",id:6}],enums:[{name:"PasswordType",values:[{name:"STATIC",id:1},{name:"ONE_TIME",id:2},{name:"NEW_STATIC",id:3},{name:"CUR_AND_NEW_STATIC",id:4},{name:"TEXT",id:5}]}]},{name:"PasswordResponse",fields:[{rule:"required",type:"uint32",name:"request_id",id:1},{rule:"required",type:"string",name:"encoding_type",id:2},{rule:"required",type:"string",name:"password",id:3}]},{name:"Encoding",fields:[{rule:"required",type:"string",name:"encoding_type",id:1},{rule:"required",type:"uint32",name:"priority_rank",id:2},{rule:"repeated",type:"EncodingParameter",name:"encoding_parameter",id:3}]},{name:"EncodingParameter",fields:[{rule:"required",type:"string",name:"name",id:1},{rule:"required",type:"string",name:"value",id:2}]},{name:"RestoreOrJoinSession",fields:[{rule:"required",type:"string",name:"session_token",id:1},{rule:"optional",type:"string",name:"private_label",id:2},{rule:"optional",type:"string",name:"client_app_id",id:3},{rule:"optional",type:"uint32",name:"collapsing_level",id:4},{rule:"optional",type:"uint32",name:"protocol_version_minor",id:5},{rule:"optional",type:"uint32",name:"protocol_version_major",id:6}]},{name:"RestoreOrJoinSessionResult",fields:[{rule:"required",type:"uint32",name:"result_code",id:1},{rule:"required",type:"string",name:"base_time",id:2},{rule:"optional",type:"string",name:"text_message",id:3}],enums:[{name:"ResultCode",values:[{name:"SUCCESS",id:0},{name:"FAILURE",id:104},{name:"UNKNOWN_SESSION",id:101},{name:"ACCESS_DENIED",id:102},{name:"INVALID_PARAMS",id:103}]}]},{name:"ConcurrentConnectionJoin",fields:[{rule:"required",type:"bool",name:"is_same_app_type",id:1}]},{name:"Logoff",fields:[{rule:"optional",type:"string",name:"text_message",id:1}]},{name:"LoggedOff",fields:[{rule:"required",type:"uint32",name:"logoff_reason",id:1},{rule:"optional",type:"string",name:"text_message",id:2},{rule:"optional",type:"string",name:"redirect_url",id:3}],enums:[{name:"LogoffReason",values:[{name:"BY_REQUEST",id:1},{name:"REDIRECTED",id:2},{name:"FORCED",id:3},{name:"REASSIGNED",id:4}]}]},{name:"PasswordChange",fields:[{rule:"required",type:"string",name:"old_password",id:1},{rule:"required",type:"string",name:"new_password",id:2}]},{name:"PasswordChangeResult",fields:[{rule:"required",type:"uint32",name:"result_code",id:1},{rule:"optional",type:"string",name:"text_message",id:2}],enums:[{name:"ResultCode",values:[{name:"SUCCESS",id:0},{name:"FAILURE",id:101},{name:"ROUTINE_ERROR",id:102}]}]},{name:"ObtainDemoCredentials",fields:[{rule:"required",type:"string",name:"client_app_id",id:1},{rule:"required",type:"string",name:"first_name",id:2},{rule:"required",type:"string",name:"second_name",id:3},{rule:"required",type:"string",name:"e_mail",id:4},{rule:"optional",type:"string",name:"private_label",id:5}]},{name:"ObtainDemoCredentialsResult",fields:[{rule:"required",type:"uint32",name:"result_code",id:1},{rule:"optional",type:"string",name:"user_name",id:2},{rule:"optional",type:"string",name:"password",id:3},{rule:"optional",type:"string",name:"text_message",id:4}],enums:[{name:"ResultCode",values:[{name:"SUCCESS",id:0},{name:"FAILURE",id:101}]}]},{name:"UserMessage",fields:[{rule:"required",type:"uint32",name:"message_type",id:1},{rule:"required",type:"string",name:"source",id:2},{rule:"optional",type:"string",name:"subject",id:3},{rule:"required",type:"string",name:"text",id:4},{rule:"optional",type:"sint64",name:"expiration_utc_time",id:5}],enums:[{name:"MessageType",values:[{name:"CRITICAL_ERROR",id:1},{name:"WARNING",id:2},{name:"INFO",id:3},{name:"LOG",id:4}]}]},{name:"UserSessionStateRequest",fields:[{rule:"required",type:"string",name:"session_token",id:1}]},{name:"UserSessionStateResult",fields:[{rule:"required",type:"string",name:"session_token",id:1},{rule:"required",type:"uint32",name:"result_code",id:2},{rule:"optional",type:"sint32",name:"user_id",id:3},{rule:"optional",type:"string",name:"username",id:4}],enums:[{name:"ResultCode",values:[{name:"SUCCESS",id:0},{name:"FAILURE",id:101},{name:"UNKNOWN_SESSION",id:102},{name:"ACCESS_DENIED",id:103}]}]},{name:"Ping",fields:[{rule:"optional",type:"string",name:"token",id:1},{rule:"required",type:"sint64",name:"ping_utc_time",id:2}]},{name:"Pong",fields:[{rule:"optional",type:"string",name:"token",id:1},{rule:"required",type:"sint64",name:"ping_utc_time",id:2},{rule:"required",type:"sint64",name:"pong_utc_time",id:3}]},{name:"TickSizeByPrice",fields:[{rule:"required",type:"double",name:"tick_size",id:1},{rule:"required",type:"double",name:"tick_value",id:2},{rule:"required",type:"double",name:"minimum_price",id:3}]},{name:"TickSizeByDateTillExpiration",fields:[{rule:"required",type:"uint32",name:"id",id:1},{rule:"required",type:"double",name:"tick_size",id:2},{rule:"required",type:"double",name:"tick_value",id:3}]},{name:"ContractMetadata",fields:[{rule:"required",type:"uint32",name:"contract_id",id:1},{rule:"required",type:"string",name:"contract_symbol",id:2},{rule:"required",type:"double",name:"correct_price_scale",id:3},{rule:"required",type:"uint32",name:"display_price_scale",id:4},{rule:"required",type:"string",name:"description",id:5},{rule:"required",type:"string",name:"title",id:6},{rule:"required",type:"double",name:"tick_size",id:7},{rule:"required",type:"string",name:"currency",id:8},{rule:"required",type:"double",name:"tick_value",id:9},{rule:"required",type:"string",name:"cfi_code",id:10},{rule:"optional",type:"bool",name:"is_most_active",id:11},{rule:"optional",type:"sint64",name:"last_trading_date",id:12},{rule:"optional",type:"sint64",name:"first_notice_date",id:13},{rule:"optional",type:"string",name:"underlying_contract_symbol",id:14},{rule:"optional",type:"uint32",name:"margin_style",id:15},{rule:"required",type:"string",name:"instrument_group_name",id:16},{rule:"required",type:"sint32",name:"session_info_id",id:17},{rule:"optional",type:"string",name:"mic",id:18},{rule:"optional",type:"sint64",name:"delay",id:20},{rule:"required",type:"string",name:"short_instrument_group_name",id:21},{rule:"required",type:"string",name:"instrument_group_description",id:22},{rule:"repeated",type:"TickSizeByPrice",name:"tick_sizes_by_price",id:23},{rule:"repeated",type:"TickSizeByDateTillExpiration",name:"tick_sizes_by_dte",id:24},{rule:"optional",type:"uint32",name:"tick_sizes_by_dte_id",id:25},{rule:"optional",type:"sint32",name:"strike",id:26},{rule:"optional",type:"double",name:"strike_price",id:27}],enums:[{name:"MarginStyle",values:[{name:"FUTURE",id:1},{name:"PREMIUM",id:2}]}]},{name:"InformationRequest",fields:[{rule:"required",type:"uint32",name:"id",id:1},{rule:"optional",type:"bool",name:"subscribe",id:2},{rule:"optional",type:"AccountsRequest",name:"accounts_request",id:3},{rule:"optional",type:"SymbolResolutionRequest",name:"symbol_resolution_request",id:4},{rule:"optional",type:"LastStatementBalancesRequest",name:"last_statement_balances_request",id:5},{rule:"optional",type:"CurrencyRatesRequest",name:"currency_rates_request",id:6},{rule:"optional",type:"SessionInformationRequest",name:"session_information_request",id:7},{rule:"optional",type:"HistoricalOrdersRequest",name:"historical_orders_request",id:13},{rule:"optional",type:"SymbolsByUnderlyingRequest",name:"symbols_by_underlying_request",id:14},{rule:"optional",type:"ChildSymbolsRequest",name:"child_symbols_request",id:15},{rule:"optional",type:"AtTheMoneyStrikeRequest",name:"at_the_money_strike_request",id:16}]},{name:"InformationReport",fields:[{rule:"required",type:"uint32",name:"id",id:1},{rule:"optional",type:"bool",name:"is_report_complete",id:2,options:{"default":!0}},{rule:"required",type:"uint32",name:"status_code",id:3},{rule:"optional",type:"string",name:"text_message",id:4},{rule:"optional",type:"AccountsReport",name:"accounts_report",id:5},{rule:"optional",type:"SymbolResolutionReport",name:"symbol_resolution_report",id:6},{rule:"optional",type:"LastStatementBalancesReport",name:"last_statement_balances_report",id:7},{rule:"optional",type:"CurrencyRatesReport",name:"currency_rates_report",id:8},{rule:"optional",type:"SessionInformationReport",name:"session_information_report",id:9},{rule:"optional",type:"HistoricalOrdersReport",name:"historical_orders_report",id:15},{rule:"optional",type:"SymbolsByUnderlyingReport",name:"symbols_by_underlying_report",id:16},{rule:"optional",type:"ChildSymbolsReport",name:"child_symbols_report",id:17},{rule:"optional",type:"AtTheMoneyStrikeReport",name:"at_the_money_strike_report",id:18}],enums:[{name:"StatusCode",values:[{name:"SUCCESS",id:0},{name:"SUBSCRIBED",id:1},{name:"DROPPED",id:2},{name:"UPDATE",id:3},{name:"DISCONNECTED",id:4},{name:"FAILURE",id:101},{name:"NOT_FOUND",id:104},{name:"REQUEST_LIMIT_VIOLATION",id:105}]}]},{name:"AccountsRequest",fields:[]},{name:"AccountsReport",fields:[{rule:"repeated",type:"Brokerage",name:"brokerage",id:1}]},{name:"Brokerage",fields:[{rule:"required",type:"uint32",name:"id",id:1},{rule:"required",type:"string",name:"name",id:2},{rule:"repeated",type:"SalesSeries",name:"sales_series",id:3}]},{name:"SalesSeries",fields:[{rule:"required",type:"string",name:"number",id:1},{rule:"required",type:"string",name:"name",id:2},{rule:"repeated",type:"Account",name:"account",id:3}]},{name:"Account",fields:[{rule:"required",type:"sint32",name:"account_id",id:1},{rule:"required",type:"string",name:"brokerage_account_id",id:2},{rule:"required",type:"string",name:"name",id:3},{rule:"required",type:"sint64",name:"last_statement_date",id:4},{rule:"optional",type:"bool",name:"is_view_only",id:5},{rule:"optional",type:"bool",name:"is_unauthorized",id:6}]},{name:"SymbolResolutionRequest",fields:[{rule:"required",type:"string",name:"symbol",id:1}]},{name:"SymbolResolutionReport",fields:[{rule:"required",type:"ContractMetadata",name:"contract_metadata",id:1},{rule:"optional",type:"bool",name:"deleted",id:2}]},{name:"LastStatementBalancesRequest",fields:[]},{name:"LastStatementBalancesReport",fields:[{rule:"repeated",type:"Balance",name:"balance",id:1}]},{name:"Balance",fields:[{rule:"required",type:"sint32",name:"id",id:1},{rule:"required",type:"sint32",name:"account_id",id:2},{rule:"required",type:"sint64",name:"statement_date",id:3},{rule:"required",type:"string",name:"currency",id:4},{rule:"required",type:"double",name:"balance",id:5},{rule:"required",type:"double",name:"total_value",id:6},{rule:"required",type:"double",name:"ote",id:7},{rule:"required",type:"double",name:"upl",id:8},{rule:"required",type:"double",name:"mvo",id:9},{rule:"required",type:"double",name:"cash_excess",id:10},{rule:"required",type:"double",name:"collateral",id:11},{rule:"required",type:"double",name:"initial_margin",id:12}]},{name:"CurrencyRatesRequest",fields:[]},{name:"CurrencyRatesReport",fields:[{rule:"repeated",type:"BrokerageCurrencyRates",name:"brokerage_currency_rates",id:1}]},{name:"BrokerageCurrencyRates",fields:[{rule:"required",type:"uint32",name:"brokerage_id",id:1},{rule:"required",type:"string",name:"master_currency",id:2},{rule:"required",type:"sint64",name:"statement_date",id:3},{rule:"repeated",type:"CurrencyRate",name:"currency_rate",id:4}]},{name:"CurrencyRate",fields:[{rule:"required",type:"string",name:"currency",id:2},{rule:"required",type:"double",name:"rate",id:3}]},{name:"SessionInformationRequest",fields:[{rule:"required",type:"sint32",name:"session_info_id",id:1},{rule:"optional",type:"sint64",name:"from_utc_time",id:2},{rule:"optional",type:"sint64",name:"to_utc_time",id:3}]},{name:"SessionInformationReport",fields:[{rule:"required",type:"sint32",name:"session_info_id",id:1},{rule:"repeated",type:"SessionSegment",name:"session_segment",id:2 }]},{name:"SessionSegment",fields:[{rule:"required",type:"sint32",name:"session_segment_id",id:1},{rule:"optional",type:"bool",name:"deleted",id:2},{rule:"optional",type:"sint64",name:"from_utc_time",id:3},{rule:"optional",type:"sint64",name:"to_utc_time",id:4},{rule:"repeated",type:"SessionSchedule",name:"session_schedule",id:5},{rule:"repeated",type:"TradingDay",name:"trading_day",id:6},{rule:"repeated",type:"SessionHoliday",name:"daily_holiday",id:7}]},{name:"SessionSchedule",fields:[{rule:"required",type:"string",name:"name",id:1},{rule:"repeated",type:"SessionDay",name:"session_day",id:2},{rule:"repeated",type:"SessionHoliday",name:"session_holiday",id:3},{rule:"optional",type:"bool",name:"is_primary",id:4}]},{name:"TradingDay",fields:[{rule:"repeated",type:"DayOfWeek",name:"day_of_week",id:1},{rule:"optional",type:"sint64",name:"start_offset",id:2}]},{name:"SessionDay",fields:[{rule:"repeated",type:"DayOfWeek",name:"day_of_week",id:1},{rule:"optional",type:"sint64",name:"pre_open_offset",id:2},{rule:"optional",type:"sint64",name:"open_offset",id:3},{rule:"optional",type:"sint64",name:"close_offset",id:4},{rule:"optional",type:"sint64",name:"post_close_offset",id:5}]},{name:"SessionHoliday",fields:[{rule:"required",type:"sint64",name:"holiday_date",id:1},{rule:"required",type:"string",name:"holiday_name",id:2}]},{name:"SymbolsByUnderlyingRequest",fields:[{rule:"required",type:"uint32",name:"underlying_contract_id",id:1}]},{name:"SymbolsByUnderlyingReport",fields:[{rule:"repeated",type:"Symbol",name:"symbol",id:1}]},{name:"ChildSymbolsRequest",fields:[{rule:"required",type:"string",name:"parent_symbol_id",id:1}]},{name:"ChildSymbolsReport",fields:[{rule:"repeated",type:"Symbol",name:"symbol",id:1}]},{name:"AtTheMoneyStrikeRequest",fields:[{rule:"required",type:"string",name:"option_maturity_symbol_id",id:1}]},{name:"AtTheMoneyStrikeReport",fields:[{rule:"optional",type:"sint32",name:"strike",id:1}]},{name:"Symbol",fields:[{rule:"required",type:"string",name:"id",id:1},{rule:"required",type:"string",name:"name",id:2},{rule:"required",type:"string",name:"description",id:3},{rule:"optional",type:"string",name:"cfi_code",id:4},{rule:"optional",type:"bool",name:"has_child_symbols",id:5},{rule:"optional",type:"ContractMetadata",name:"contract_metadata",id:6},{rule:"optional",type:"bool",name:"deleted",id:7},{rule:"optional",type:"sint64",name:"last_trading_date",id:8},{rule:"optional",type:"string",name:"maturity_month_year",id:9},{rule:"required",type:"string",name:"instrument_group_name",id:10}]},{name:"TradeSubscription",fields:[{rule:"required",type:"uint32",name:"id",id:1},{rule:"repeated",type:"uint32",name:"subscription_scope",id:2},{rule:"optional",type:"uint32",name:"publication_type",id:3},{rule:"optional",type:"uint32",name:"account_id",id:4},{rule:"optional",type:"string",name:"sales_series_number",id:5},{rule:"optional",type:"uint32",name:"brokerage_id",id:6},{rule:"required",type:"bool",name:"subscribe",id:7},{rule:"optional",type:"sint64",name:"last_order_update_utc_time",id:8},{rule:"optional",type:"bool",name:"skip_orders_snapshot",id:9},{rule:"optional",type:"bool",name:"confirmed_positions_only",id:10},{rule:"optional",type:"uint32",name:"matching_algorithm",id:11},{rule:"optional",type:"bool",name:"match_intraday_first",id:12},{rule:"optional",type:"uint32",name:"historical_matching_algorithm",id:13}],enums:[{name:"SubscriptionScope",values:[{name:"ORDERS",id:1},{name:"POSITIONS",id:2},{name:"COLLATERAL",id:3}]},{name:"PublicationType",values:[{name:"ACCOUNT",id:1},{name:"SALES_SERIES",id:2},{name:"BROKERAGE",id:3},{name:"ALL_AUTHORIZED",id:4}]},{name:"MatchingAlgorithm",values:[{name:"FIFO",id:1},{name:"HBHS",id:2},{name:"LIFO",id:3}]}]},{name:"TradeSubscriptionStatus",fields:[{rule:"required",type:"uint32",name:"id",id:1},{rule:"required",type:"uint32",name:"status_code",id:2},{rule:"optional",type:"string",name:"text_message",id:3}],enums:[{name:"StatusCode",values:[{name:"SUCCESS",id:0},{name:"DISCONNECTED",id:1},{name:"FAILURE",id:101},{name:"REQUEST_LIMIT_VIOLATION",id:102}]}]},{name:"TradeSnapshotCompletion",fields:[{rule:"required",type:"uint32",name:"subscription_id",id:1},{rule:"repeated",type:"uint32",name:"subscription_scope",id:2}]},{name:"OrderRequest",fields:[{rule:"required",type:"uint32",name:"request_id",id:1},{rule:"optional",type:"NewOrder",name:"new_order",id:2},{rule:"optional",type:"ModifyOrder",name:"modify_order",id:3},{rule:"optional",type:"CancelOrder",name:"cancel_order",id:4},{rule:"optional",type:"ActivateOrder",name:"activate_order",id:5},{rule:"optional",type:"ModifyUserAttributes",name:"modify_user_attributes",id:6},{rule:"optional",type:"string",name:"on_behalf_of_user",id:7},{rule:"optional",type:"NewCompoundOrder",name:"new_compound_order",id:8},{rule:"optional",type:"uint32",name:"client_regulatory_algorithm_id",id:9}]},{name:"OrderRequestReject",fields:[{rule:"required",type:"uint32",name:"request_id",id:1},{rule:"required",type:"uint32",name:"reject_code",id:2},{rule:"optional",type:"string",name:"text_message",id:3}]},{name:"NewOrder",fields:[{rule:"required",type:"Order",name:"order",id:1},{rule:"optional",type:"bool",name:"suspend",id:2}]},{name:"Order",fields:[{rule:"required",type:"sint32",name:"account_id",id:1},{rule:"required",type:"sint64",name:"when_utc_time",id:2},{rule:"required",type:"uint32",name:"contract_id",id:3},{rule:"required",type:"string",name:"cl_order_id",id:4},{rule:"required",type:"uint32",name:"order_type",id:5},{rule:"repeated",type:"uint32",name:"exec_instruction",id:6},{rule:"required",type:"uint32",name:"duration",id:7},{rule:"optional",type:"sint64",name:"good_thru_date",id:8},{rule:"required",type:"uint32",name:"side",id:9},{rule:"optional",type:"sint32",name:"limit_price",id:10},{rule:"optional",type:"sint32",name:"stop_price",id:11},{rule:"required",type:"uint32",name:"qty",id:12},{rule:"optional",type:"uint32",name:"visible_qty",id:13},{rule:"optional",type:"uint32",name:"min_visible_qty",id:14},{rule:"required",type:"bool",name:"is_manual",id:15},{rule:"optional",type:"bool",name:"is_close",id:16},{rule:"optional",type:"bool",name:"is_aggressive",id:17},{rule:"optional",type:"sint32",name:"trail_offset",id:18},{rule:"optional",type:"uint32",name:"trailing_peg",id:19},{rule:"optional",type:"uint32",name:"trigger_qty",id:20},{rule:"optional",type:"sint64",name:"activation_utc_time",id:21},{rule:"optional",type:"sint64",name:"suspension_utc_time",id:22},{rule:"repeated",type:"UserAttribute",name:"user_attribute",id:23},{rule:"optional",type:"sint64",name:"good_thru_utc_time",id:24}],enums:[{name:"Side",values:[{name:"BUY",id:1},{name:"SELL",id:2}]},{name:"OrderType",values:[{name:"MKT",id:1},{name:"LMT",id:2},{name:"STP",id:3},{name:"STL",id:4}]},{name:"ExecInstruction",values:[{name:"AON",id:1},{name:"ICEBERG",id:2},{name:"QT",id:3},{name:"TRAIL",id:4},{name:"FUNARI",id:5},{name:"MIT",id:6},{name:"MLM",id:7}]},{name:"Duration",values:[{name:"DAY",id:1},{name:"GTC",id:2},{name:"GTD",id:3},{name:"GTT",id:4},{name:"FAK",id:5},{name:"FOK",id:6},{name:"ATO",id:7},{name:"ATC",id:8}]},{name:"TrailingPeg",values:[{name:"BESTBID",id:1},{name:"BESTASK",id:2},{name:"LASTTRADE",id:3}]}]},{name:"UserAttribute",fields:[{rule:"required",type:"string",name:"name",id:1},{rule:"optional",type:"string",name:"value",id:2},{rule:"optional",type:"bool",name:"delete",id:3}]},{name:"ModifyOrder",fields:[{rule:"required",type:"string",name:"order_id",id:1},{rule:"required",type:"sint32",name:"account_id",id:2},{rule:"required",type:"string",name:"orig_cl_order_id",id:3},{rule:"required",type:"string",name:"cl_order_id",id:4},{rule:"required",type:"sint64",name:"when_utc_time",id:5},{rule:"optional",type:"uint32",name:"qty",id:6},{rule:"optional",type:"uint32",name:"visible_qty",id:7},{rule:"optional",type:"uint32",name:"min_visible_qty",id:8},{rule:"optional",type:"sint32",name:"limit_price",id:9},{rule:"optional",type:"sint32",name:"stop_price",id:10},{rule:"optional",type:"sint64",name:"activation_utc_time",id:11},{rule:"optional",type:"bool",name:"remove_activation_time",id:12},{rule:"optional",type:"sint64",name:"suspension_utc_time",id:13},{rule:"optional",type:"bool",name:"remove_suspension_utc_time",id:14},{rule:"optional",type:"uint32",name:"duration",id:15},{rule:"optional",type:"sint64",name:"good_thru_date",id:16},{rule:"optional",type:"sint64",name:"good_thru_utc_time",id:17}]},{name:"CancelOrder",fields:[{rule:"required",type:"string",name:"order_id",id:1},{rule:"required",type:"sint32",name:"account_id",id:2},{rule:"required",type:"string",name:"orig_cl_order_id",id:3},{rule:"required",type:"string",name:"cl_order_id",id:4},{rule:"required",type:"sint64",name:"when_utc_time",id:5}]},{name:"ActivateOrder",fields:[{rule:"required",type:"string",name:"order_id",id:1},{rule:"required",type:"sint32",name:"account_id",id:2},{rule:"required",type:"string",name:"orig_cl_order_id",id:3},{rule:"required",type:"string",name:"cl_order_id",id:4},{rule:"required",type:"sint64",name:"when_utc_time",id:5}]},{name:"ModifyUserAttributes",fields:[{rule:"required",type:"string",name:"chain_order_id",id:1},{rule:"required",type:"sint32",name:"account_id",id:2},{rule:"repeated",type:"UserAttribute",name:"user_attribute",id:3}]},{name:"NewCompoundOrder",fields:[{rule:"required",type:"CompoundOrder",name:"compound_order",id:1},{rule:"optional",type:"bool",name:"partial_fills_handling",id:2,options:{"default":!0}}]},{name:"CompoundOrder",fields:[{rule:"required",type:"uint32",name:"type",id:1},{rule:"required",type:"string",name:"cl_compound_id",id:2},{rule:"repeated",type:"CompoundOrderEntry",name:"compound_order_entry",id:3}],enums:[{name:"Type",values:[{name:"OPO",id:1},{name:"OCO",id:2}]}]},{name:"CompoundOrderEntry",fields:[{rule:"optional",type:"Order",name:"order",id:1},{rule:"optional",type:"CompoundOrder",name:"compound_order",id:2}]},{name:"OrderStatus",fields:[{rule:"repeated",type:"uint32",name:"subscription_id",id:1},{rule:"optional",type:"bool",name:"is_snapshot",id:2},{rule:"required",type:"uint32",name:"status",id:3},{rule:"required",type:"string",name:"order_id",id:4},{rule:"required",type:"string",name:"chain_order_id",id:5},{rule:"optional",type:"string",name:"exec_order_id",id:6},{rule:"required",type:"sint64",name:"status_utc_time",id:7},{rule:"required",type:"sint64",name:"submission_utc_time",id:8},{rule:"required",type:"uint32",name:"fill_qty",id:9},{rule:"required",type:"uint32",name:"fill_cnt",id:10},{rule:"required",type:"sint32",name:"avg_fill_price",id:11},{rule:"optional",type:"sint64",name:"active_at_utc_time",id:12},{rule:"required",type:"uint32",name:"remaining_qty",id:13},{rule:"optional",type:"Order",name:"order",id:14},{rule:"repeated",type:"TransactionStatus",name:"transaction_status",id:15},{rule:"required",type:"string",name:"entered_by_user",id:16},{rule:"required",type:"sint64",name:"first_statement_date",id:17},{rule:"optional",type:"sint64",name:"last_statement_date",id:18},{rule:"repeated",type:"ContractMetadata",name:"contract_metadata",id:19},{rule:"required",type:"sint32",name:"account_id",id:20},{rule:"optional",type:"CompoundOrderStructure",name:"compound_order_structure",id:21}],enums:[{name:"Status",values:[{name:"IN_TRANSIT",id:1},{name:"REJECTED",id:2},{name:"WORKING",id:3},{name:"EXPIRED",id:4},{name:"IN_CANCEL",id:5},{name:"IN_MODIFY",id:6},{name:"CANCELLED",id:7},{name:"FILLED",id:8},{name:"SUSPENDED",id:9},{name:"DISCONNECTED",id:10},{name:"ACTIVEAT",id:11}]}]},{name:"TransactionStatus",fields:[{rule:"required",type:"uint32",name:"status",id:1},{rule:"required",type:"uint64",name:"trans_id",id:2},{rule:"required",type:"sint64",name:"trans_utc_time",id:3},{rule:"optional",type:"uint64",name:"ref_trans_id",id:4},{rule:"optional",type:"string",name:"orig_cl_order_id",id:5},{rule:"required",type:"string",name:"cl_order_id",id:6},{rule:"optional",type:"uint32",name:"fill_qty",id:7},{rule:"optional",type:"sint32",name:"fill_price",id:8},{rule:"repeated",type:"Trade",name:"trade",id:9},{rule:"optional",type:"uint32",name:"prev_order_qty",id:10},{rule:"optional",type:"uint32",name:"order_qty",id:11},{rule:"optional",type:"sint32",name:"prev_limit_price",id:12},{rule:"optional",type:"sint32",name:"limit_price",id:13},{rule:"optional",type:"sint32",name:"prev_stop_price",id:14},{rule:"optional",type:"sint32",name:"stop_price",id:15},{rule:"optional",type:"uint32",name:"prev_visible_qty",id:16},{rule:"optional",type:"uint32",name:"visible_qty",id:17},{rule:"optional",type:"uint32",name:"prev_min_visible_qty",id:18},{rule:"optional",type:"uint32",name:"min_visible_qty",id:19},{rule:"optional",type:"uint32",name:"prev_fill_qty",id:20},{rule:"optional",type:"sint32",name:"prev_fill_price",id:21},{rule:"optional",type:"uint32",name:"prev_order_type",id:22},{rule:"optional",type:"uint32",name:"order_type",id:23},{rule:"repeated",type:"uint32",name:"prev_exec_instruction",id:24},{rule:"repeated",type:"uint32",name:"exec_instruction",id:25},{rule:"optional",type:"uint32",name:"prev_duration",id:26},{rule:"optional",type:"uint32",name:"duration",id:27},{rule:"optional",type:"sint64",name:"prev_good_thru_date",id:28},{rule:"optional",type:"sint64",name:"good_thru_date",id:29},{rule:"optional",type:"uint32",name:"reject_code",id:30},{rule:"optional",type:"string",name:"fill_counterparty",id:31},{rule:"optional",type:"string",name:"route_cl_order_id",id:32},{rule:"optional",type:"string",name:"text_message",id:33},{rule:"optional",type:"sint64",name:"prev_good_thru_utc_time",id:34},{rule:"optional",type:"sint64",name:"good_thru_utc_time",id:35},{rule:"optional",type:"uint32",name:"client_regulatory_algorithm_id",id:36},{rule:"optional",type:"uint32",name:"effective_regulatory_algorithm_id",id:37}],enums:[{name:"Status",values:[{name:"IN_TRANSIT",id:1},{name:"REJECTED",id:2},{name:"ACK_PLACE",id:3},{name:"EXPIRED",id:4},{name:"IN_CANCEL",id:5},{name:"ACK_CANCEL",id:6},{name:"REJECT_CANCEL",id:7},{name:"IN_MODIFY",id:8},{name:"ACK_MODIFY",id:9},{name:"REJECT_MODIFY",id:10},{name:"FILL",id:11},{name:"SUSPEND",id:12},{name:"FILL_CORRECT",id:13},{name:"FILL_CANCEL",id:14},{name:"FILL_BUST",id:15},{name:"ACTIVEAT",id:16},{name:"DISCONNECT",id:17},{name:"SYNTHETIC_ACTIVATED",id:18},{name:"UPDATE",id:19}]}]},{name:"Trade",fields:[{rule:"required",type:"string",name:"trade_id",id:1},{rule:"required",type:"uint32",name:"contract_id",id:2},{rule:"required",type:"sint64",name:"statement_date",id:3},{rule:"required",type:"sint64",name:"trade_utc_time",id:4},{rule:"required",type:"sint64",name:"trade_date",id:5},{rule:"required",type:"sint32",name:"price",id:6},{rule:"required",type:"uint32",name:"side",id:7},{rule:"required",type:"uint32",name:"qty",id:8},{rule:"optional",type:"string",name:"trade_counterparty",id:9},{rule:"optional",type:"bool",name:"is_aggressive",id:10}]},{name:"CompoundOrderStructure",fields:[{rule:"required",type:"uint32",name:"type",id:1},{rule:"required",type:"string",name:"cl_compound_id",id:2},{rule:"repeated",type:"CompoundOrderStructureEntry",name:"compound_order_entry",id:3}]},{name:"CompoundOrderStructureEntry",fields:[{rule:"optional",type:"string",name:"chain_order_id",id:1},{rule:"optional",type:"CompoundOrderStructure",name:"compound_order_structure",id:2}]},{name:"PositionStatus",fields:[{rule:"repeated",type:"uint32",name:"subscription_id",id:1},{rule:"optional",type:"bool",name:"is_snapshot",id:2},{rule:"required",type:"sint32",name:"account_id",id:3},{rule:"required",type:"uint32",name:"contract_id",id:4},{rule:"required",type:"bool",name:"is_short_open_position",id:5},{rule:"repeated",type:"OpenPosition",name:"open_position",id:6},{rule:"repeated",type:"PurchaseAndSalesGroup",name:"purchase_and_sales_group",id:7},{rule:"optional",type:"ContractMetadata",name:"contract_metadata",id:8}]},{name:"OpenPosition",fields:[{rule:"required",type:"sint32",name:"id",id:1},{rule:"required",type:"uint32",name:"qty",id:2},{rule:"required",type:"double",name:"price",id:3},{rule:"required",type:"sint64",name:"trade_date",id:4},{rule:"required",type:"sint64",name:"statement_date",id:5},{rule:"optional",type:"sint64",name:"trade_utc_time",id:6}]},{name:"PurchaseAndSalesGroup",fields:[{rule:"required",type:"sint32",name:"id",id:1},{rule:"required",type:"double",name:"realized_profit_loss",id:2},{rule:"repeated",type:"MatchedTrade",name:"matched_trade",id:3}]},{name:"MatchedTrade",fields:[{rule:"required",type:"uint32",name:"qty",id:1},{rule:"optional",type:"bool",name:"is_short",id:2},{rule:"required",type:"double",name:"price",id:3},{rule:"required",type:"sint64",name:"trade_date",id:4},{rule:"required",type:"sint64",name:"statement_date",id:5},{rule:"optional",type:"sint64",name:"trade_utc_time",id:6}]},{name:"CollateralStatus",fields:[{rule:"repeated",type:"uint32",name:"subscription_id",id:1},{rule:"optional",type:"bool",name:"is_snapshot",id:2},{rule:"required",type:"sint32",name:"account_id",id:3},{rule:"required",type:"string",name:"currency",id:4},{rule:"required",type:"double",name:"total_margin",id:5},{rule:"required",type:"double",name:"purchasing_power",id:6},{rule:"optional",type:"double",name:"ote",id:7},{rule:"optional",type:"double",name:"mvo",id:8}]},{name:"MarketDataSubscription",fields:[{rule:"required",type:"uint32",name:"contract_id",id:1},{rule:"required",type:"uint32",name:"level",id:2}],enums:[{name:"Level",values:[{name:"NONE",id:0},{name:"TRADES",id:1},{name:"TRADES_BBA",id:2},{name:"TRADES_BBA_VOLUMES",id:3},{name:"TRADES_BBA_DOM",id:4}]}]},{name:"MarketDataSubscriptionStatus",fields:[{rule:"required",type:"uint32",name:"contract_id",id:1},{rule:"required",type:"uint32",name:"status_code",id:2},{rule:"required",type:"uint32",name:"level",id:3},{rule:"optional",type:"string",name:"text_message",id:4}],enums:[{name:"StatusCode",values:[{name:"SUCCESS",id:0},{name:"DISCONNECTED",id:1},{name:"FAILURE",id:101},{name:"INVALID_PARAMS",id:102},{name:"ACCESS_DENIED",id:103},{name:"DELETED",id:104},{name:"REQUEST_LIMIT_VIOLATION",id:105}]}]},{name:"RealTimeMarketData",fields:[{rule:"required",type:"uint32",name:"contract_id",id:1},{rule:"repeated",type:"Quote",name:"quote",id:2},{rule:"optional",type:"bool",name:"is_snapshot",id:3},{rule:"optional",type:"uint32",name:"collapsing_level",id:4},{rule:"optional",type:"MarketValues",name:"market_values",id:5}]},{name:"Quote",fields:[{rule:"required",type:"uint32",name:"type",id:1},{rule:"optional",type:"sint64",name:"quote_utc_time",id:2},{rule:"required",type:"sint32",name:"price",id:3},{rule:"optional",type:"uint64",name:"volume",id:4},{rule:"repeated",type:"uint32",name:"session_ohlc_indicator",id:5}],enums:[{name:"Type",values:[{name:"TRADE",id:0},{name:"BESTBID",id:1},{name:"BESTASK",id:2},{name:"BID",id:3},{name:"ASK",id:4},{name:"SETTLEMENT",id:5}]},{name:"SessionOhlcIndicator",values:[{name:"OPEN",id:1},{name:"HIGH",id:2},{name:"LOW",id:3},{name:"CLOSE",id:4}]}]},{name:"MarketValues",fields:[{rule:"optional",type:"sint32",name:"open_price",id:1},{rule:"optional",type:"sint32",name:"high_price",id:2},{rule:"optional",type:"sint32",name:"low_price",id:3},{rule:"optional",type:"sint32",name:"close_price",id:4},{rule:"optional",type:"sint32",name:"yesterday_settlement",id:5},{rule:"optional",type:"uint32",name:"total_volume",id:6},{rule:"optional",type:"sint32",name:"yesterday_close",id:7},{rule:"optional",type:"sint32",name:"indicative_open",id:8}]},{name:"ReadUserAttributeRequest",fields:[{rule:"required",type:"uint32",name:"request_id",id:1},{rule:"repeated",type:"string",name:"attribute_name",id:2}]},{name:"ReadUserAttributeResult",fields:[{rule:"required",type:"uint32",name:"request_id",id:1},{rule:"required",type:"uint32",name:"result_code",id:2},{rule:"repeated",type:"UserAttribute",name:"user_attribute",id:3},{rule:"optional",type:"string",name:"text_message",id:4}],enums:[{name:"ResultCode",values:[{name:"SUCCESS",id:0},{name:"FAILURE",id:101},{name:"REQUEST_LIMIT_VIOLATION",id:102}]}]},{name:"ModifyUserAttributeRequest",fields:[{rule:"required",type:"uint32",name:"request_id",id:1},{rule:"repeated",type:"UserAttribute",name:"user_attribute",id:2}]},{name:"ModifyUserAttributeResult",fields:[{rule:"required",type:"uint32",name:"request_id",id:1},{rule:"required",type:"uint32",name:"result_code",id:2},{rule:"optional",type:"string",name:"text_message",id:3}],enums:[{name:"ResultCode",values:[{name:"SUCCESS",id:0},{name:"FAILURE",id:101},{name:"REQUEST_LIMIT_VIOLATION",id:102}]}]},{name:"TimeAndSalesParameters",fields:[{rule:"required",type:"uint32",name:"contract_id",id:1},{rule:"required",type:"uint32",name:"level",id:2},{rule:"required",type:"sint64",name:"from_utc_time",id:3},{rule:"optional",type:"sint64",name:"to_utc_time",id:4}],enums:[{name:"Level",values:[{name:"TRADES",id:1},{name:"TRADES_BBA_VOLUMES",id:3}]}]},{name:"TimeAndSalesRequest",fields:[{rule:"required",type:"uint32",name:"request_id",id:1},{rule:"optional",type:"TimeAndSalesParameters",name:"time_and_sales_parameters",id:2},{rule:"optional",type:"uint32",name:"request_type",id:3}],enums:[{name:"RequestType",values:[{name:"GET",id:1},{name:"DROP",id:3}]}]},{name:"TimeAndSalesReport",fields:[{rule:"required",type:"uint32",name:"request_id",id:1},{rule:"required",type:"uint32",name:"result_code",id:2},{rule:"repeated",type:"Quote",name:"quote",id:3},{rule:"optional",type:"int64",name:"up_to_utc_time",id:4},{rule:"optional",type:"bool",name:"is_report_complete",id:5,options:{"default":!0}},{rule:"optional",type:"string",name:"text_message",id:6},{rule:"optional",type:"bool",name:"truncated",id:7}],enums:[{name:"ResultCode",values:[{name:"SUCCESS",id:0},{name:"DROPPED",id:2},{name:"DISCONNECTED",id:4},{name:"FAILURE",id:101},{name:"ACCESS_DENIED",id:103},{name:"NOT_FOUND",id:104},{name:"OUTSIDE_ALLOWED_RANGE",id:105},{name:"REQUEST_LIMIT_VIOLATION",id:106}]}]},{name:"TimeBarParameters",fields:[{rule:"required",type:"uint32",name:"contract_id",id:1},{rule:"required",type:"uint32",name:"bar_unit",id:2},{rule:"optional",type:"uint32",name:"units_number",id:3},{rule:"required",type:"sint64",name:"from_utc_time",id:4},{rule:"optional",type:"sint64",name:"to_utc_time",id:5},{rule:"optional",type:"bool",name:"use_settlements",id:6}],enums:[{name:"BarUnit",values:[{name:"YEAR",id:1},{name:"SEMI_ANNUAL",id:2},{name:"QUARTER",id:3},{name:"MONTH",id:4},{name:"WEEK",id:5},{name:"DAY",id:6},{name:"HOUR",id:7},{name:"MIN",id:8}]}]},{name:"TimeBarRequest",fields:[{rule:"required",type:"uint32",name:"request_id",id:1},{rule:"optional",type:"TimeBarParameters",name:"time_bar_parameters",id:2},{rule:"optional",type:"uint32",name:"request_type",id:3}],enums:[{name:"RequestType",values:[{name:"GET",id:1},{name:"SUBSCRIBE",id:2},{name:"DROP",id:3}]}]},{name:"TimeBar",fields:[{rule:"required",type:"sint64",name:"bar_utc_time",id:1},{rule:"optional",type:"sint32",name:"open_price",id:2},{rule:"optional",type:"sint32",name:"high_price",id:3},{rule:"optional",type:"sint32",name:"low_price",id:4},{rule:"optional",type:"sint32",name:"close_price",id:5},{rule:"optional",type:"uint64",name:"volume",id:6},{rule:"optional",type:"sint64",name:"trade_date",id:7},{rule:"optional",type:"uint64",name:"commodity_volume",id:8},{rule:"optional",type:"uint32",name:"open_interest",id:9},{rule:"optional",type:"uint32",name:"commodity_open_interest",id:10},{rule:"optional",type:"sint32",name:"settlement_price",id:11}]},{name:"TimeBarReport",fields:[{rule:"required",type:"uint32",name:"request_id",id:1},{rule:"required",type:"uint32",name:"status_code",id:2},{rule:"repeated",type:"TimeBar",name:"time_bar",id:3},{rule:"optional",type:"int64",name:"up_to_utc_time",id:4},{rule:"optional",type:"bool",name:"is_report_complete",id:5,options:{"default":!0}},{rule:"optional",type:"string",name:"text_message",id:6},{rule:"optional",type:"bool",name:"truncated",id:7}],enums:[{name:"StatusCode",values:[{name:"SUCCESS",id:0},{name:"SUBSCRIBED",id:1},{name:"DROPPED",id:2},{name:"UPDATE",id:3},{name:"DISCONNECTED",id:4},{name:"FAILURE",id:101},{name:"ACCESS_DENIED",id:103},{name:"NOT_FOUND",id:104},{name:"OUTSIDE_ALLOWED_RANGE",id:105},{name:"INVALID_PARAMS",id:106},{name:"REQUEST_LIMIT_VIOLATION",id:107}]}]},{name:"HistoricalOrdersRequest",fields:[{rule:"required",type:"sint64",name:"from_date",id:1},{rule:"optional",type:"sint64",name:"to_date",id:2},{rule:"repeated",type:"sint32",name:"account_id",id:3}]},{name:"HistoricalOrdersReport",fields:[{rule:"repeated",type:"OrderStatus",name:"order_status",id:1}]}],enums:[{name:"ProtocolVersionMajor",values:[{name:"PROTOCOL_VERSION_MAJOR",id:1}]},{name:"ProtocolVersionMinor",values:[{name:"PROTOCOL_VERSION_MINOR",id:32}]},{name:"DayOfWeek",values:[{name:"Sunday",id:0},{name:"Monday",id:1},{name:"Tuesday",id:2},{name:"Wednesday",id:3},{name:"Thursday",id:4},{name:"Friday",id:5},{name:"Saturday",id:6}]}]}},338:function(e,t){"use strict";var i=function(e){this._dp=".",this._fract="'",this._correct_price_scale=e.correct_price_scale,this._tick_size=e.tick_size,this._tick_value=e.tick_value,this._tick_size_by_price=e.tick_sizes_by_price,this._fo=this._formatOptions(e.display_price_scale,e.tick_size),this._formatter=new TradingView.PriceFormatter(this._fo.priceScale,this._fo.minMove,this._fo.fractional,this._fo.minmove2)};i.prototype.options=function(){return this._fo},i.prototype._formatOptions=function(e,t){switch(e){case 0:return{priceScale:1,minMove:t,fractional:!1,regexp:"([0-9]+)"};case 1:return{priceScale:10,minMove:10*t,fractional:!1,regexp:"([0-9]+)(\\"+this._dp+"[0-9])|()"};case 2:return{priceScale:100,minMove:100*t,fractional:!1,regexp:"([0-9]+)(\\"+this._dp+"[0-9]{1,2})|()"};case 3:return{priceScale:1e3,minMove:1e3*t,fractional:!1,regexp:"([0-9]+)(\\"+this._dp+"[0-9]{1,3})|()"};case 4:return{priceScale:1e4,minMove:1e4*t,fractional:!1,regexp:"([0-9]+)(\\"+this._dp+"[0-9]{1,4})|()"};case 5:return{priceScale:1e5,minMove:1e5*t,fractional:!1,regexp:"([0-9]+)(\\"+this._dp+"[0-9]{1,5})|()"};case 6:return{priceScale:1e6,minMove:1e6*t,fractional:!1,regexp:"([0-9]+)(\\"+this._dp+"[0-9]{1,6})|()"};case 7:return{priceScale:1e7,minMove:1e7*t,fractional:!1,regexp:"([0-9]+)(\\"+this._dp+"[0-9]{1,7})|()"};case 8:return{priceScale:1e8,minMove:1e8*t,fractional:!1,regexp:"([0-9]+)(\\"+this._dp+"[0-9]{1,8})|()"};case 9:return{priceScale:1e9,minMove:1e9*t,fractional:!1,regexp:"([0-9]+)(\\"+this._dp+"[0-9]{1,9})|()"};case 10:return{priceScale:1e10,minMove:1e10*t,fractional:!1,regexp:"([0-9]+)(\\"+this._dp+"[0-9]{1,10})|()"};case 11:return{priceScale:1e11,minMove:1e11*t,fractional:!1,regexp:"([0-9]+)(\\"+this._dp+"[0-9]{1,11})|()"};case 12:return{priceScale:1e12,minMove:1e12*t,fractional:!1,regexp:"([0-9]+)(\\"+this._dp+"[0-9]{1,12})|()"};case 13:return{priceScale:1e13,minMove:1e13*t,fractional:!1,regexp:"([0-9]+)(\\"+this._dp+"[0-9]{1,13})|()"};case 14:return{priceScale:1e14,minMove:1e14*t,fractional:!1,regexp:"([0-9]+)(\\"+this._dp+"[0-9]{1,14})|()"};case 15:return{priceScale:1e15,minMove:1e15*t,fractional:!1,regexp:"([0-9]+)(\\"+this._dp+"[0-9]{1,15})|()"};case 101:return{priceScale:2,minMove:1,fractional:!0,regexp:"([0-9]+)'[0,5]"};case 102:return{priceScale:4,minMove:1,fractional:!0,regexp:"([0-9]+)'[0,3,5,7]"};case 103:return{priceScale:8,minMove:1,fractional:!0,regexp:"([0-9]+)'[0-7]"};case 104:return{priceScale:16,minMove:1,fractional:!0,regexp:"([0-9]+)'0[0-9]|11|12|13|14|15"};case 105:return{priceScale:32,minMove:1,fractional:!0,regexp:"([0-9]+)'[0-2][0-9]|30|31"};case 106:return{priceScale:64,minMove:1,fractional:!0,regexp:"([0-9]+)'[0-5][0-9]|60|61|62|63|64"};case 107:return{priceScale:128,minMove:1,fractional:!0,regexp:"([0-9]+)'[0-5][0-9]|60|61|62|63|64"};case 108:return{priceScale:256,minMove:1,fractional:!0};case 109:return{priceScale:512,minMove:1,fractional:!0};case 110:return{priceScale:1024,minMove:1,fractional:!0};case 201:return{priceScale:64,minMove:1,minmove2:2,fractional:!0};case 202:return{priceScale:128,minMove:1,minmove2:4,fractional:!0};case 203:return{priceScale:256,minMove:1,minmove2:8,fractional:!0};case 204:return{priceScale:128,minMove:1,minmove2:2,fractional:!0};case 205:return{priceScale:256,minMove:1,minmove2:2,fractional:!0}}return{priceScale:100,minMove:1}},i.prototype.format=function(e){return this._formatter.format(e*this._correct_price_scale)},i.prototype.realPrice=function(e){return+(e*this._correct_price_scale).toFixed(8)},i.prototype.intPrice=function(e){return Math.round(e/this._correct_price_scale)},i.prototype.formatAvgPrice=function(e){var e=this.intPrice(e);return this.format(e)},i.prototype._getTickSize=function(e,t){t=Math.abs(t);for(var i=0,r=e.length;r>i;++i)if(e[i].minimum_price<=t&&(i+1>=r||e[i+1].minimum_price>t))return{size:e[i].tick_size,value:e[i].tick_value};return{}},i.prototype.priceInCurr=function(e){var t=this._getTickSize(this._tick_size_by_price,this.intPrice(e));return e/(t.size||this._tick_size)*(t.value||this._tick_value)},i.prototype.parseAsIntPrice=function(e){var t=this._formatter.parse(e);if(!t.res)return t;var i=Math.trunc(t.price/this._correct_price_scale),r=i-t.price/this._correct_price_scale;return r>this._correct_price_scale-r&&(i+=1),t.intPrice=Math.round(i),t},e.exports=i},339:function(e,t,i){"use strict";var r=i(323),n=function(e,t,i,r){this.Q2=e,this._broker=r,this._connection=r.connection(),this._connection.onStatusChanged.subscribe(this,n.prototype.onStatusChanged),this.onStatusChanged({status:r.connection().connectStatus()}),this._id=++o,this.setCQGSymbol(t,i)},o=1;n.prototype.removeObjects=function(){for(var e in this._executions)this._executions[e]._adapter.remove();for(var t in this._orders)this._orders[t].mainTool._adapter.remove(),this._orders[t].addTool&&this._orders[t].addTool._adapter.remove();this._position&&(this._position._adapter.remove(),this._connection.unsubscribePositionProfit(this._position.position,this._positionProfitHandler,this)),this._executions={},this._orders={},this._position=null},n.prototype.updateAll=function(){var e=this;this.removeObjects();var t=this._connection.getPositions(this._cqgSymbol);t.forEach(function(t){e.onPositionUpdate(t)});var i=this._connection.getOrders(this._cqgSymbol);i.forEach(function(t){e.onOrderUpdate(t)});var r=this._connection.getExecutions(this._cqgSymbol);r.forEach(function(t){e.onExecutionUpdate(t)})},n.prototype.setCQGSymbol=function(e,t){this._cqgSymbol=e,this._account=t,this.Q2.model().mainSeries().data().isEmpty()?this.Q2.model().mainSeries().onCompleted().subscribe(this,this.updateAll,!0):this.updateAll()},n.prototype.onStatusChanged=function(e){e.status!=r.CONNECTED?this.reset():(this._connection.onPositionUpdate.subscribe(this,n.prototype.onPositionUpdate),this._connection.onOrderUpdate.subscribe(this,n.prototype.onOrderUpdate),this._connection.onExecutionUpdate.subscribe(this,n.prototype.onExecutionUpdate))},n.prototype.reset=function(){this.removeObjects(),this._connection.onPositionUpdate.unsubscribe(this,n.prototype.onPositionUpdate),this._connection.onOrderUpdate.unsubscribe(this,n.prototype.onOrderUpdate);var e=this.Q2.model().model(),t=e.Q17(),i=t.filter(function(e){return e instanceof TradingView.LineToolPosition});if(i.length>0){var r=i[0];TradingView.logError("Chart has position after reset"),TradingView.logError("position symbol:"+r.symbol()),TradingView.logError("position quantity:"+r._adapter.getQuantity()),TradingView.logError("old controllerId:"+r.controllerId)}},n.prototype.redraw=function(){var e=this.Q2.model().model(),t=e.paneForSource(e.mainSeries());e.updatePane(t)},n.prototype.positionSideColor=function(e){return"Buy"==e.side?"rgb(64,148,232)":"rgb(231,86,86)"},n.prototype.profitColor=function(e){return e>0?"rgb(38,140,2)":0>e?"rgb(231,86,86)":"rgb(100,100,100)"},n.prototype._positionProfitHandler=function(e){this._position._adapter.setText(e.open_pl.toFixed(2)).setBodyTextColor(this.profitColor(e.open_pl))},n.prototype.onPositionUpdate=function(e){if(e.symbol==this._cqgSymbol&&this._account==e.account_id&&(this._position&&(e.qty||(this._position._adapter.remove(), -this._connection.unsubscribePositionProfit(e,this._positionProfitHandler,this),this._position=null)),TradingView.logDebug("CQG_CHART. Update position. Symbol:"+e.symbol+" , qty:"+e.qty),e.qty)){var t=this,i=this.Q2;if(!this._position){var r=i.model().model(),n=r.paneForSource(i.model().model().mainSeries()),o=r.Q17(),s=o.filter(function(e){return e instanceof TradingView.LineToolPosition});if(s.length>0){var a=s[0];TradingView.logError("Chart already had a position"),TradingView.logError("position symbol:"+a.symbol()),TradingView.logError("position quantity:"+a._adapter.getQuantity()),TradingView.logError("old controllerId:"+a.controllerId)}var l=r.createLineTool(n,{price:Math.abs(e.avg_price),index:0},"LineToolPosition");l.position=e,l.controllerId=this._id;this._position=l,e.open_pl&&l._adapter.setText(e.open_pl.toFixed(2)).setBodyTextColor(t.profitColor(e.open_pl)),this._connection.subscribePositionProfit(e,this._positionProfitHandler,this)}var u=this.positionSideColor(e);Math.abs(e.qty)||TradingView.logError("set position qty to 0!"),this._position._adapter.setPrice(Math.abs(e.avg_price)).setQuantity(Math.abs(e.qty)).setQuantityBackgroundColor(u).setBodyBorderColor(u).setCloseButtonIconColor(u).setCloseButtonBorderColor(u).setQuantityBorderColor(u).setLineColor(u).onClose(function(){t._broker.closePosition(e)}).onContextMenu(function(){var i=new TradingView.Action({text:$.t("Close Position")});return i.callbacks().subscribe(null,function(){t._broker.closePosition(e)}),[i]}),this._position.updateAllViews(),this.redraw()}},n.prototype.orderSideColor=function(e,t){return"Buy"==e.side?t?"rgba(64,148,232,.5)":"rgb(64,148,232)":t?"rgba(231,86,86,.5)":"rgb(231,86,86)"},n.prototype.orderText=function(e){return(e.side+" "+e.type).toUpperCase()},n.prototype.onOrderUpdate=function(e){if(e.symbol==this._cqgSymbol&&this._account==e.account_id){var t=this,i=e.order_id,r=e.priceFormatter,n=this.Q2;if("Working"!==e.status&&"In transit"!==e.status&&"Active At"!==e.status&&"In modify"!==e.status)this._orders[i]&&(this._orders[i].mainTool._adapter.remove(),this._orders[i].addTool&&this._orders[i].addTool._adapter.remove(),delete this._orders[i]);else{if(!this._orders[i]){var o=n.model().model(),s=o.paneForSource(n.model().model().mainSeries()),a=r.realPrice(e.stop_price||e.limit_price),l=o.createLineTool(s,{price:a,index:0},"LineToolOrder");if(this._orders[i]={mainTool:l},"StopLimit"==e.type){var u=r.realPrice(e.limit_price),d=o.createLineTool(s,{price:u,index:0},"LineToolOrder");this._orders[i].addTool=d}}if(this._orders[i].addTool&&"StopLimit"!=e.type&&(this._orders[i].mainTool._adapter.remove(),this._orders[i].mainTool=this._orders[i].addTool,delete this._orders[i].addTool),this._orders[i]){var c=this._orders[i].mainTool._adapter,p="Working"!==e.status,f=this.orderSideColor(e,p),h=r.realPrice(e.stop_price||e.limit_price);if(c.setPrice(h).setQuantity(e.qty).setText(this.orderText(e)).setQuantityBackgroundColor(f).setBodyTextColor(f).setBodyBorderColor(f).setQuantityBorderColor(f).setCancelButtonBorderColor(f).setCancelButtonIconColor(f).setLineColor(f).setQuantity(e.qty).onMove(function(i){var n=TradingView.clone(e),o=r.intPrice(c.getPrice());n.stop_price?n.stop_price=o:n.limit_price&&(n.limit_price=o),n.noConfirm=!0,t._broker.getOrderDialog().open(n,!0).done(function(){}).fail(function(){c.setPrice(h)})}).onContextMenu(function(){var i=new TradingView.Action({text:$.t("Edit Order…")});i.callbacks().subscribe(null,function(){t._broker.getOrderDialog().open(e,!0)});var r=new TradingView.Action({text:$.t("Cancel Order")});return r.callbacks().subscribe(null,function(){t._broker.cancelOrder(e)}),[i,r]}).onModify(function(){t._broker.getOrderDialog().open(e,!0)}).onCancel(function(){t._broker.cancelOrder(e)}),this._orders[i].addTool){var u=r.realPrice(e.limit_price),m=this._orders[i].addTool._adapter,f=this.orderSideColor(e,!0);m.setPrice(u).setQuantity(e.qty).setText(this.orderText(e)).setQuantityBackgroundColor(f).setBodyTextColor(f).setBodyBorderColor(f).setQuantityBorderColor(f).setCancelButtonBorderColor(f).setCancelButtonIconColor(f).setLineColor(f).setQuantity(e.qty).onModify(function(){t._broker.getOrderDialog().open(e)}).onMove(function(i){var n=TradingView.clone(e);n.limit_price=r.intPrice(m.getPrice()),n.noConfirm=!0,t._broker.getOrderDialog().open(n).done(function(){}).fail(function(){m.setPrice(u)})})}}}}},n.prototype.executionColor=function(e){return"buy"==e.side?"#4094e8":"#e75656"},n.prototype.executionText=function(e){var t=e.side+" "+e.qty+" @ "+e.price;return t.substr(0,1).toUpperCase()+t.substr(1).toLowerCase()},n.prototype.onExecutionUpdate=function(e){if(e.symbol===this._cqgSymbol&&e.account_id===this._account){var t=this.Q2,i=e.id,r=Math.round(e.time.valueOf()/1e3);if(this._executions[i])this._executions[i]._adapter.setPrice(e.price);else{var n=t.model().model(),o=n.paneForSource(n.mainSeries()),s=n.createLineTool(o,{price:e.price,index:void 0},"LineToolExecution");this._executions[i]=s}var a=this.executionText(e);this._executions[i]._adapter.setTime(r),this._executions[i]._adapter.setPrice(e.price),this._executions[i]._adapter.setDirection(e.side),this._executions[i]._adapter.setTooltip(a),this._executions[i]._adapter.setArrowColor(this.executionColor(e)),this._executions[i].updateAllViews(),this.redraw()}},e.exports=n},340:function(e,t,i){"use strict";function r(e){this._broker=e,this._connection=e.connection()}var n=i(323),o=null;r.get=function(e){return o||(o=new r(e)),o.setBroker(e)},r.prototype.setBroker=function(e){return this._broker=e,this._connection=e.connection(),this},r.prototype.close=function(){this.title&&($82.destroy(this.title),this._connection.unsubscribeRealtime(this.metainfo.contract_id,this.realtimeListener))},r.prototype.open=function(e){function t(){r.metainfo&&r._connection.unsubscribeRealtime(r.metainfo.contract_id,h),X.empty(),J.empty()}if(this._connection.connectStatus()!==n.CONNECTED)return $.Deferred().reject().promise();var i,r=this,o=!1,s=$.Deferred();if(this._broker.trading().noConfirmEnabled.value()&&e&&e.noConfirm){var a={account_id:e.account_id,executionOptions:{},duration:{type:"DAY"},qty:e.qty};switch(e.order_id&&(a.order_id=e.order_id,a.client_order_id=e.client_order_id,a.server_order_id=e.server_order_id),e.type.toLowerCase()){case"limit":a.type="Limit";break;case"stop":a.type="Stop";break;case"market":a.type="Market";break;case"stoplimit":a.type="StopLimit"}switch(e.side.toLowerCase()){case"buy":a.side="Buy";break;case"sell":a.side="Sell"}return this._connection.resolveSymbol(e.symbol).done(function(t){a.contract_id=t.contract_metadata.contract_id;var i=r._broker.formatter(t.contract_metadata);if("Limit"===a.type||"StopLimit"===a.type){var n=i.parseAsIntPrice(e.formatted_limit_price||"0");a.limit_price=e.limit_price||n.intPrice}if("Stop"===a.type||"StopLimit"===a.type){var l=i.parseAsIntPrice(e.formatted_stop_price||"0");a.stop_price=e.stop_price||l.intPrice}a.aggressivity="none",a.open_close="none",r._connection[e.order_id?"modifyOrder":"placeOrder"](a).done(function(){o=!0,s.resolve()}).fail(function(e){s.reject(e)})}),s.promise()}var l=function(){$82.destroy(u)},u=e&&e.order_id?"CQG: Modify order "+e.order_id:"CQG: Place Order",d=$82.createDialog(u,{width:"508px"});this.title=u,d.addClass("trading-dialog cqg-trading-dialog");var c=$("").appendTo(d.find("._tv-dialog-title")),p=$("
      ").attr("action","javascript://").appendTo(d.find("._tv-dialog-content")),f=p;$(d).on("destroy",t),$(d).on("destroy",function(){delete r.title,o?s.resolve():s.reject()}),this.$dialog=d;var h=function(e){i=r.formatter.format(e.trade||(e.ask+e.bid)/2);var t;t=isFinite(e.ask)?r.formatter.format(e.ask):"n/a";var n;if(n=isFinite(e.bid)?r.formatter.format(e.bid):"n/a",isFinite(e.trade)&&"n/a"==t&&"n/a"==n){var o=r.formatter.format(e.trade);t=n=o}X.text(t),J.text(n)};this.realtimeListener=h;var m={},_=null,g="",y=function(){var n=T.val();if(g!==n){if(g=n,_)return void _.always(y);t(),c.empty(),K.empty().append($('').text("Resolving "+n+"...")),X.text("..."),J.text("..."),_=r._connection.resolveSymbol(n).done(function(t){r.metainfo=t.contract_metadata,r.formatter=r._broker.formatter(t.contract_metadata),m[n]=t.contract_metadata.contract_id,g=t.contract_metadata.contract_symbol,T.val(t.contract_metadata.contract_symbol),c.text(", "+t.contract_metadata.contract_symbol),K.empty().text(t.contract_metadata.description),i=void 0,r._connection.subscribeRealtime(r.metainfo.contract_id,h);var o=function(e){var t=r.formatter.intPrice(e),i=r.formatter.format(t);return i},s=function(e){var t=r.formatter.parseAsIntPrice(e);if(t.res){var i=r.formatter.realPrice(t.intPrice);return i}};if(e.formatted_limit_price){var a=r.formatter.parseAsIntPrice(e.formatted_limit_price);I.val(r.formatter.realPrice(a.intPrice))}if(I.TVTicker({step:t.contract_metadata.tick_size||1,formatter:o,parser:s}).on("tvticker-beforechange",function(){var e=$(this);0===+e.val()&&i&&e.val(i)}),e.formatted_stop_price){var a=r.formatter.parseAsIntPrice(e.formatted_stop_price);R.val(r.formatter.realPrice(a.intPrice))}R.TVTicker({step:t.contract_metadata.tick_size||1,formatter:o,parser:s}).on("tvticker-beforechange",function(){var e=$(this);0===+e.val()&&i&&e.val(i)}),e&&e.limit_price>0&&I.val(r.formatter.format(e.limit_price));var s=function(e){var t=r.formatter.parseAsIntPrice(e);if(t.res){var i=r.formatter.realPrice(t.intPrice);return i}};I.TVTicker({step:t.contract_metadata.tick_size||1,formatter:o,parser:s}).on("tvticker-beforechange",function(){var e=$(this);0===+e.val()&&i&&e.val(i)}),R.TVTicker({step:t.contract_metadata.tick_size||1,formatter:o,parser:s}).on("tvticker-beforechange",function(){var e=$(this);0===+e.val()&&i&&e.val(i)}),e&&e.limit_price>0&&I.val(r.formatter.format(e.limit_price)),e&&e.stop_price>0&&R.val(r.formatter.format(e.stop_price)),pe()}).fail(function(e){r.metainfo=null,K.empty().append($('').text("Failed to resolve symbol")),c.empty(),X.empty(),J.empty()}).always(function(){_=null})}},v=$("").attr("spellcheck","false");T.on("keypress keydown",function(e){13===e.keyCode&&(e.preventDefault(),y())}),T.on("change",y);var w=$("").val(1),S=$(""),R=$(""),O=$("
      '),q=C.find('[name="expired-date"]');TradingView.makeInputDateOnly(q),q.datepicker({dateFormat:"yy-mm-dd",minDate:new Date,showOtherMonths:!0});var A=$('
      '),x=A.find('[name="expired-date"]');TradingView.makeInputDateOnly(x),x.datepicker({dateFormat:"yy-mm-dd",minDate:new Date,showOtherMonths:!0});var k=A.find('[name="expired-time"]');TradingView.makeInputTimeOnly(k),k.clockpicker({autoclose:!0,donetext:"OK"});var P=$(""),L=$(""),N=$(""),D=$("").attr("placeholder","Visible Qty"),M=$(""),B=$(""),V=$("").val(1),U=$(""),F=$(""),Y=$(""),W=$("");if($("