Release v19.037 (from ca0cc69b)

Fixes tradingview/charting_library#5867
This commit is contained in:
jenkins@nwork.local
2021-07-09 16:57:57 +00:00
parent 24720e28be
commit 2f85a8b661
36 changed files with 36 additions and 36 deletions

View File

@@ -221,7 +221,7 @@ d._pointsetsManagers[i].getUpdatesForSymbol(e.full_name,t,s).forEach((function(t
this._pointsetsManagers[e].removePointset(t)},P.prototype.createPointset=function(e,t,i,n,r){var o=this._getTimeScaleBuilder(e,i,n);if(this._pointsetsManagers[e].createPointset(t,i.full_name,n,r,o),null===this._refreshPointsetsTimerId){var s=this;this._refreshPointsetsTimerId=setTimeout((function(){s._refreshPointsetsTimerId=null,s._refreshPointsets(s._invalidatedPointsetSessions),s._invalidatedPointsetSessions.clear()}),0)}this._invalidatedPointsetSessions.add(e)},P.prototype._refreshPointsets=function(e){var t=this;e.forEach((function(e){var i=t._studiesCache[e];if(null!=i){var n=null;for(var r in i){var o=i[r];if("series"===o.type){n=o;break}}if(null!==n&&null!=n.symbolInfo){var s=t._getTimeScaleBuilder(e,n.symbolInfo,n.resolution);t._pointsetsManagers[e].getUpdatesForSymbol(n.symbolInfo.full_name,n.resolution,s).forEach((function(t,i){TradingView.ChartapiMessagerInstances[e].onPointsetDataUpdate(i,null,t,n.symbolInfo)}))}}}))},P.prototype.studiesMetadata=function(){return 0===this._metainfoCache.length&&(this._metainfoCache=JSServer.studyLibrary.map((function(e){return e.metainfo})),this._metainfoCache.push({palettes:{},inputs:[],plots:[{id:"open",type:"line"},{id:"high",type:"line"},{id:"low",type:"line"},{id:"close",type:"line"},{id:"volume",type:"line"}],graphics:{},_metainfoVersion:48,description:"Unnamed Study",format:{type:"inherit"},is_hidden_study:!0,is_price_study:!1,shortDescription:"Unnamed Study",description_localized:"Unnamed Study",id:"BarSetHeikenAshi@tv-prostudies",shortId:"BarSetHeikenAshi",packageId:"tv-basicstudies",version:"13",fullId:"BarSetHeikenAshi@tv-basicstudies-13",productId:"tv-basicstudies",name:"BarSetHeikenAshi@tv-basicstudies"})),this._metainfoCache},P.prototype.searchSymbols=function(e,t,i,n){this._logMessage("Symbol search requested: search string `{0}`, exchange: `{1}`, type `{2}`".format(e,t,i));var r=this;this._externalDatafeed.searchSymbols(e,t,i,(function(e){r._logMessage("Symbol search response: {0}".format(JSON.stringify(e))),n(e)}))},P.prototype.resolveSymbol=function(e,t,i){y(e)||console.error("Expect to get symbol encoded string, but got the following instead: "+e);var n=g(e),r="string"==typeof n.symbol?n:n.symbol,o=r.symbol,s=r["currency-id"];this._resolveSymbolByName(o,{currency:s},t,i)},P.prototype._resolveSymbolByName=function(e,t,i,n){var r,o=t&&t.currency,s=e+(o?"_#_"+o:"");this._resolveRequests[s]?r=this._resolveRequests[s]:(r=this._resolveSymbolInternal(e,o||void 0),this._resolveRequests[s]=r),r.then(i).catch(n)},P.prototype._resolveSymbolInternal=function(e,t){var i=this;return new Promise(function(n,r){this._logMessage("Symbol resolve requested: `{0}` ".format(e));var o=!0;this._externalDatafeed.resolveSymbol(e,(function(t){o&&console.warn("`resolveSymbol` should return result asynchronously. Use `setTimeout` with 0 interval to execute the callback function."),i._logMessage("Symbol resolved: `{0}`, SymbolInfo in server response {1}".format(e,JSON.stringify(t))),function(e){if(e.base_name||(e.base_name=[e.name]),e.legs||(e.legs=[e.name]),
e.exchange||(e.exchange=e["exchange-listed"]),e.full_name||(e.full_name=e.symbol||(e.exchange?e.exchange+":"+e.name:e.name)),e.pro_name||(e.pro_name=e.full_name),e.data_status||(e.data_status="streaming"),e.ticker||(e.ticker=e.symbol||e.name),!e.session&&e["session-regular"]&&(e.session=e["session-regular"]),!e.minmov&&e.minmovement&&(e.minmov=e.minmovement),e.currency_code&&(e.currency_id=e.currency_code),e.original_currency_code&&(e.original_currency_id=e.original_currency_code),e.supported_resolutions)for(var t=0;t<e.supported_resolutions.length;t++){var i=u.parse(e.supported_resolutions[t]);i.isValid()&&(e.supported_resolutions[t]=i.value())}}(t),function(e){function t(e){console.warn("SymbolInfo validation: "+e)}if(e.has_empty_bars&&!m()&&t('both has_empty_bars field and featureset "disable_resolution_rebuild" are enabled and may cause data issues (see #3329)'),(void 0===e.minmov||e.minmov<=0)&&t("minmov must be positive"),(void 0===e.pricescale||e.pricescale<=0)&&t("pricescale must be positive"),void 0!==e.name&&0!==e.name.length||t("name must be non-empty string"),void 0!==e.session&&0!==e.session.length||t("session must be non-empty string"),void 0===e.timezone||0===e.timezone.length?t("timezone must be non-empty string"):"exchange"!==e.timezone&&_(e.timezone)||"UTC"!==e.timezone&&t('unsupported timezone "{0}"'.format(e.timezone)),void 0!==e.intraday_multipliers){var i=e.intraday_multipliers;if(Array.isArray(i))for(var n=0;n<i.length;++n)"string"!=typeof i[n]&&t('intraday_multipliers[{0}] = "{1}" must be string (now: {2})'.format(n+1,i[n],typeof i[n]));else t("intraday_multipliers must be array")}(e.supported_resolutions||[]).filter((function(e){return!u.isValid(e)})).forEach((function(e){t("supported_resolutions field contains invalid value: "+e)}))}(t),i._logMessage("Symbol info after post-processing: `{0}`, SymbolInfo {1}".format(e,JSON.stringify(t))),n(t)}),(function(t){i._logMessage("Symbol resolve failed: `{0}`, reason: `{1}`".format(e,t)),r(t)}),{currencyCode:t}),o=!1}.bind(this))},P.prototype._createMarketStatusWatchers=function(e,t){void 0===this._marketStatusWatchers[e]&&(this._marketStatusWatchers[e]={});var i=this;t.forEach((function(t){void 0===i._marketStatusWatchers[e][t]&&(i._marketStatusWatchers[e][t]=new n(i._resolveSymbolByName.bind(i),e,t))}))},P.prototype._removeMarketStatusWatchers=function(e){var t=this;Object.keys(this._marketStatusWatchers[e]||{}).forEach((function(i){t._marketStatusWatchers[e][i].stop()})),this._marketStatusWatchers[e]={}},P.prototype._stopQuotesSubscription=function(e){this._quotesInfo[e].listenerGUID&&(this._externalDatafeed.unsubscribeQuotes(this._quotesInfo[e].listenerGUID),this._quotesInfo[e].listenerGUID=void 0),this._removeMarketStatusWatchers(e)},P.prototype._startQuotesSubscription=function(e){var t={},i=this;function n(t,n){var r=i._marketStatusWatchers[e][t.n];t.symbolname=t.n,t.status=t.s,t.values=t.v,t.values.change=t.v.ch,t.values.last_price=t.v.lp,t.values.change_percent=t.v.chp,t.values.current_session=t.v.cs||r&&r.marketStatus(),
t.values.pricescale=n.pricescale,t.values.minmov=n.minmov,t.values.minmove2=n.minmove2||0,t.values.fractional=n.fractional||!1,r&&t.v.cs&&r.stop(),TradingView.ChartapiMessagerInstances[e].onQuotesData([e].concat([t]))}function r(e){e.forEach((function(e){void 0!==t[e.n]?null!==t[e.n]&&n(e,t[e.n]):i._resolveSymbolByName(e.n,null,(function(i){t[e.n]=i,n(e,i)}),(function(){t[e.n]=null}))}))}var o=this._quotesInfo[e].symbols;0!==o.length&&(this._externalDatafeed.getQuotes&&!S.enabled("charting_library")?this._externalDatafeed.getQuotes(o,(function(t){i._quotesInfo[e]&&(r(t),i._quotesInfo[e].listenerGUID=e,i._externalDatafeed.subscribeQuotes(o,i._quotesInfo[e].fastSymbols,r,i._quotesInfo[e].listenerGUID))}),(function(e){})):!this._externalDatafeed.getQuotes&&S.enabled("trading_terminal")&&setTimeout((function(){r(o.map((function(e){return{n:e,s:"ok",v:{}}})))})),this._createMarketStatusWatchers(e,o))},P.prototype._restartQuotesSubscription=function(e){this._stopQuotesSubscription(e),this._startQuotesSubscription(e)},P.prototype.quoteCreateSession=function(e){this._quotesInfo[e]={symbols:[],fastSymbols:[],listenerGUID:void 0}},P.prototype.quoteDeleteSession=function(e){this._stopQuotesSubscription(e),this._quotesInfo[e]=null},P.prototype.quoteSetFields=function(e,t){},P.prototype.quoteAddSymbols=function(e,t){this._quotesInfo[e].symbols=this._filteredSymbols(this._quotesInfo[e].symbols.concat(t)),this._restartQuotesSubscription(e)},P.prototype.quoteRemoveSymbols=function(e,t){this._quotesInfo[e].symbols=this._quotesInfo[e].symbols.filter((function(e){return t.indexOf(e)<0})),this._restartQuotesSubscription(e)},P.prototype.quoteFastSymbols=function(e,t){this._quotesInfo[e].fastSymbols=this._filteredSymbols(t),this._restartQuotesSubscription(e)},P.prototype.quoteHibernateAll=function(e){},P.prototype._stopDepthSubscription=function(e){this._depthInfo[e].listenerGUID&&(this._externalDatafeed.unsubscribeDepth(this._depthInfo[e].listenerGUID),this._depthInfo[e].listenerGUID=void 0)},P.prototype._startDepthSubscription=function(e){var t=this,i=this._depthInfo[e].symbol;function n(e){return e.map((function(e){return{p:e.price,v:e.volume}}))}function r(e){var t={};return t.s=i,t.bids=n(e.bids),t.asks=n(e.asks),t}i&&this._externalDatafeed.subscribeDepth&&(t._depthInfo[e].listenerGUID=this._externalDatafeed.subscribeDepth(i,(function(i){var n;t._depthInfo[e]&&((n=i).snapshot?TradingView.ChartapiMessagerInstances[e].onDepthData([e].concat([r(n)])):TradingView.ChartapiMessagerInstances[e].onDepthUpdate([e].concat([r(n)])))})))},P.prototype._restartDepthSubscription=function(e){this._stopDepthSubscription(e),this._startDepthSubscription(e)},P.prototype.depthCreateSession=function(e){this._depthInfo[e]={symbol:null,listenerGUID:void 0}},P.prototype.depthDeleteSession=function(e){this._depthInfo[e].symbol=null,this._stopDepthSubscription(e),delete this._depthInfo[e]},P.prototype.depthSetSymbol=function(e,t){this._depthInfo[e].symbol=t,this._restartDepthSubscription(e)},P.prototype._filteredSymbols=function(e){var t=[]
;return e.forEach((function(e){e instanceof Object||t.indexOf(e)<0&&t.push(e)})),t},P.prototype._isEndOfData=function(e,t,i){var n=e+"!"+t+"@"+i;return!!this._endOfData[n]},P.prototype._setEndOfData=function(e,t,i,n){var r=e+"!"+t+"@"+i;this._endOfData[r]=n},P.prototype.serverTimeOffset=function(){return this._serverTimeOffset},P.prototype.getCurrentUTCTime=function(){return(new Date).valueOf()/1e3+this._serverTimeOffset},P.prototype.regenerateTickmarks=function(e){var t=this._sessionsLastDataCache[e];if(null!==t){var i=null;for(var n in this._studiesCache[e]){var r=this._studiesCache[e][n];if("series"===r.type){i=r;break}}if(null!==i&&null!=i.symbolInfo){var o=this._getTimeScaleBuilder(e,i.symbolInfo,i.resolution),s=t.map((function(e){return e.value[0]/1e3})).concat(o.futureBars());0!==s.length&&TradingView.ChartapiMessagerInstances[e].onTickmarksUpdated(0,s,i.symbolInfo,i.resolution)}}},e.exports=P},EX27:function(e,t,i){"use strict";var n=i("XPit").TimePointIndexSearchMode,r=i("IiTo"),o=i("LxhU").Interval,s=i("EJcV"),a=i("MrEN"),l=i("XzZr"),c=l.ChartApiInterface,u=l.HandlerInfo,h=i("ogJP").requireFullInterfaceImplementation,d=i("txPx").getLogger("Chart.ChartApiLocal"),p=i("uDHo").TIMEFRAMETYPE,f=i("uDHo").areEqualTimeFrames,_=i("OLhd").createDwmAligner;function m(e,t,i){if(e[t])if(void 0!==i)e[t][i]&&(clearTimeout(e[t][i]),delete e[t][i]);else{for(var n in e[t])e[t].hasOwnProperty(n)&&m(e,t,n);delete e[t]}}function v(e,t,i,n){m(e,t,i),e[t]||(e[t]={}),e[t][i]=n}TradingView.STUDY_COUNT_LIMIT=210,JSServer.ChartApi=function(e){this._notificationHandlers={},this._sessions={},this.studyCounter=0,this._seriesTimers={},this._studyTimers={},this._connected=!1,this._enabled=!1,this._studyEngine=new s(e),this._callbacks={},this._symbolIdCache={},this._seriesIdCache={},this._recentSeriesId={},this._enableLogging=!1,this._enabledMoreBarsRequest=!0,this._serverTimeOffset=0;var t=this;this._studyEngine.on("configuration_received",(function(){t._fireEvent("configuration_received")})),this._studyEngine.on("realtime_tick",(function(e){var i={time:e.value[0]/1e3,open:e.value[1],high:e.value[2],low:e.value[3],close:e.value[4],volume:e.value[5]};t._fireEvent("realtime_tick",i,!0)})),this._setVisibleRangeTimeout={}},JSServer.ChartApi.prototype._makeSymbolKey=function(e,t){if(!e||!t)throw Error("incorrect identifiers");return e+"_"+t},JSServer.ChartApi.prototype._makeSeriesKey=function(e,t){if(!e||!t)throw Error("incorrect identifiers");return e+"_"+t},JSServer.ChartApi.prototype.destroy=function(){this._studyEngine.destroy(),this._studyEngine=null},JSServer.ChartApi.prototype.purgeCache=function(e){this._studyEngine.purgeCache(),this._studyEngine.purgeDataCache(),this._symbolIdCache={},this._seriesIdCache={},this._recentSeriesId={}},JSServer.ChartApi.prototype.setAdditionalBarsRequestEnabled=function(e){this._enabledMoreBarsRequest=e},JSServer.ChartApi.prototype.defaultWatchlistSymbols=function(){return this._watchlistSettings.default_symbols},JSServer.ChartApi.prototype.defaultResolutions=function(){
;return e.forEach((function(e){e instanceof Object||t.indexOf(e)<0&&t.push(e)})),t},P.prototype._isEndOfData=function(e,t,i){var n=e+"!"+t+"@"+i;return!!this._endOfData[n]},P.prototype._setEndOfData=function(e,t,i,n){var r=e+"!"+t+"@"+i;this._endOfData[r]=n},P.prototype.serverTimeOffset=function(){return this._serverTimeOffset},P.prototype.getCurrentUTCTime=function(){return(new Date).valueOf()/1e3+this._serverTimeOffset},P.prototype.regenerateTickmarks=function(e){var t=this._sessionsLastDataCache[e];if(null!==t){var i=null;for(var n in this._studiesCache[e]){var r=this._studiesCache[e][n];if("series"===r.type){i=r;break}}if(null!==i&&null!=i.symbolInfo){var o=this._getTimeScaleBuilder(e,i.symbolInfo,i.resolution),s=t.map((function(e){return e.value[0]})).concat(o.futureBars());0!==s.length&&TradingView.ChartapiMessagerInstances[e].onTickmarksUpdated(0,s,i.symbolInfo,i.resolution)}}},e.exports=P},EX27:function(e,t,i){"use strict";var n=i("XPit").TimePointIndexSearchMode,r=i("IiTo"),o=i("LxhU").Interval,s=i("EJcV"),a=i("MrEN"),l=i("XzZr"),c=l.ChartApiInterface,u=l.HandlerInfo,h=i("ogJP").requireFullInterfaceImplementation,d=i("txPx").getLogger("Chart.ChartApiLocal"),p=i("uDHo").TIMEFRAMETYPE,f=i("uDHo").areEqualTimeFrames,_=i("OLhd").createDwmAligner;function m(e,t,i){if(e[t])if(void 0!==i)e[t][i]&&(clearTimeout(e[t][i]),delete e[t][i]);else{for(var n in e[t])e[t].hasOwnProperty(n)&&m(e,t,n);delete e[t]}}function v(e,t,i,n){m(e,t,i),e[t]||(e[t]={}),e[t][i]=n}TradingView.STUDY_COUNT_LIMIT=210,JSServer.ChartApi=function(e){this._notificationHandlers={},this._sessions={},this.studyCounter=0,this._seriesTimers={},this._studyTimers={},this._connected=!1,this._enabled=!1,this._studyEngine=new s(e),this._callbacks={},this._symbolIdCache={},this._seriesIdCache={},this._recentSeriesId={},this._enableLogging=!1,this._enabledMoreBarsRequest=!0,this._serverTimeOffset=0;var t=this;this._studyEngine.on("configuration_received",(function(){t._fireEvent("configuration_received")})),this._studyEngine.on("realtime_tick",(function(e){var i={time:e.value[0]/1e3,open:e.value[1],high:e.value[2],low:e.value[3],close:e.value[4],volume:e.value[5]};t._fireEvent("realtime_tick",i,!0)})),this._setVisibleRangeTimeout={}},JSServer.ChartApi.prototype._makeSymbolKey=function(e,t){if(!e||!t)throw Error("incorrect identifiers");return e+"_"+t},JSServer.ChartApi.prototype._makeSeriesKey=function(e,t){if(!e||!t)throw Error("incorrect identifiers");return e+"_"+t},JSServer.ChartApi.prototype.destroy=function(){this._studyEngine.destroy(),this._studyEngine=null},JSServer.ChartApi.prototype.purgeCache=function(e){this._studyEngine.purgeCache(),this._studyEngine.purgeDataCache(),this._symbolIdCache={},this._seriesIdCache={},this._recentSeriesId={}},JSServer.ChartApi.prototype.setAdditionalBarsRequestEnabled=function(e){this._enabledMoreBarsRequest=e},JSServer.ChartApi.prototype.defaultWatchlistSymbols=function(){return this._watchlistSettings.default_symbols},JSServer.ChartApi.prototype.defaultResolutions=function(){
return this._studyEngine.supportedResolutions()||["1","3","5","15","30","45","60","120","180","240","1D","1W","1M"]},JSServer.ChartApi.prototype.availableCurrencies=function(){var e=this._studyEngine.supportedCurrencies().map((function(e){return{id:e,code:e,convertible:!0}}));return Promise.resolve(e)},JSServer.ChartApi.prototype.supportedSymbolsTypes=function(){return this._studyEngine.supportedSymbolsTypes()},JSServer.ChartApi.prototype.supportedExchangesList=function(){return this._studyEngine.supportedExchangesList()},JSServer.ChartApi.prototype.symbolsGrouping=function(){return this._studyEngine.symbolsGrouping()},JSServer.ChartApi.prototype.start=function(){this._enabled=!0,this._fireEvent("start_enabled")},JSServer.ChartApi.prototype._logMessage=function(e){this._enableLogging&&console.log(e)},JSServer.ChartApi.prototype.unsubscribe=function(e,t){var i=this._callbacks[e];i&&i.splice(i.indexOf(t),1)},JSServer.ChartApi.prototype.on=function(e,t){return this._callbacks.hasOwnProperty(e)||(this._callbacks[e]=[]),this._callbacks[e].push(t),this},JSServer.ChartApi.prototype._fireEvent=function(e,t,i){if(this._callbacks.hasOwnProperty(e)){var n=this._callbacks[e].slice(0);i||(this._callbacks[e]=[]);for(var r=0;r<n.length;++r)n[r](t)}},JSServer.ChartApi.prototype.chartCreateSession=function(e,t){this._studyEngine.chartCreateSession(e)},JSServer.ChartApi.prototype.chartDeleteSession=function(e){this._studyEngine.chartDeleteSession(e)},JSServer.ChartApi.prototype.createSession=function(e,t){TradingView.ChartapiMessagerInstances[e]=new a(this,e),this._sessions[e]=t,this._notificationHandlers[e]={},this.connected()&&t.onMessage({method:"connected",params:[]})},JSServer.ChartApi.prototype.removeSession=function(e){delete this._sessions[e],delete this._notificationHandlers[e],this._studyEngine.stopSources(e),m(this._seriesTimers,e),m(this._studyTimers,e)},JSServer.ChartApi.prototype.connected=function(){return this._connected},JSServer.ChartApi.prototype.connect=function(){if(this._enabled)this.connected()||(this._connected=!0,this.sessionid="dummy session id",this._notifySessions({method:"connected",params:[]}));else{var e=this;this.on("start_enabled",(function(){e.connect()}))}},JSServer.ChartApi.prototype.disconnect=function(){this._connected=!1,this._notifySessions({method:"disconnected",params:[]}),this.purgeCache(),this.studyCounter=0},JSServer.ChartApi.prototype.switchTimezone=function(e,t){TradingView.ChartapiMessagerInstances[e].timezone()!==t&&(TradingView.ChartapiMessagerInstances[e].setTimezone(t),this._studyEngine.regenerateTickmarks(e))},JSServer.ChartApi.prototype.receiveLocalResponse=function(e){this._logMessage("< "+e.method),this._dispathNotification(e),this._fireEvent("message_"+e.method,void 0,!0)},JSServer.ChartApi.prototype.getMarks=function(e,t,i,n,r){this._studyEngine.getMarks(e,t,i,n,r)},JSServer.ChartApi.prototype.getTimescaleMarks=function(e,t,i,n,r){this._studyEngine.getTimescaleMarks(e,t,i,n,r)},JSServer.ChartApi.prototype.resolveSymbol=function(e,t,i,n,r){
this._notificationHandlers[e][t]=new u(n,t),this._symbolIdCache[this._makeSymbolKey(e,t)]=null;var o=this;function s(t,n){Object.keys(o._seriesIdCache).some((function(e){return o._seriesIdCache[e].symbolId===t}))&&TradingView.ChartapiMessagerInstances[e].onSeriesClearData(0,""),TradingView.ChartapiMessagerInstances[e].onSymbolError(t,n),o._symbolIdCache[o._makeSymbolKey(e,t)]={requestedSymbol:i,status:"invalid_symbol"},o._fireEvent("resolve_fail",{session:e,symbolId:t},!0),o._fireEvent(o._makeSymbolKey(e,t)+"_resolve_fail")}this._studyEngine.resolveSymbol(i,(function(n){n.errmsg?s(t,n.errmsg):(o._symbolIdCache[o._makeSymbolKey(e,t)]={requestedSymbol:i,symbolInfo:n,status:"ok"},o._fireEvent("symbol_resolved",{symbolInfo:n,symbolId:t,session:e},!0),o._fireEvent(o._makeSymbolKey(e,t)+"_resolved",n),TradingView.ChartapiMessagerInstances[e].onSymbolResolved(t,n))}),(function(e){s(t,e)}))},JSServer.ChartApi.prototype._doWhenSymbolIdIsReady=function(e,t,i){var n=this,r=!0;function o(){r&&(i({requestedSymbol:n._symbolIdCache[n._makeSymbolKey(e,t)].requestedSymbol,symbolInfo:n._symbolIdCache[n._makeSymbolKey(e,t)].symbolInfo}),r=!1,n.unsubscribe(n._makeSymbolKey(e,t)+"_resolved",o),n.unsubscribe(n._makeSymbolKey(e,t)+"_resolve_fail",o))}this._symbolIdCache[this._makeSymbolKey(e,t)]?o():(this.on(this._makeSymbolKey(e,t)+"_resolved",o),this.on(this._makeSymbolKey(e,t)+"_resolve_fail",o))},JSServer.ChartApi.prototype._doWhenSeriesDataReceived=function(e,t){TradingView.ChartapiMessagerInstances[e].seriesCompleted.subscribe(null,t,!0)},JSServer.ChartApi.prototype._doWhenSeriesSymbolIdIsReady=function(e,t,i,n){var r=this,o=this._seriesIdCache[e+"_"+t].symbolId;function s(){var t;i({requestedSymbol:(t=r._symbolIdCache[r._makeSymbolKey(e,o)]).requestedSymbol,symbolInfo:t.symbolInfo})}function a(){r.unsubscribe("symbol_resolved",c),r.unsubscribe("resolve_fail",l)}function l(t){t.symbolId===o&&t.session===e&&(a(),n&&n())}function c(t){t.symbolId===o&&t.session===e&&(a(),s())}this._symbolIdCache[this._makeSymbolKey(e,o)]?s():(this.on("symbol_resolved",c),this.on("resolve_fail",l))},JSServer.ChartApi.prototype.createSeries=function(e,t,i,n,r,s,a,l){i=i||"";var c=this;this._notificationHandlers[e][t]=new u((function(r){"series_completed"===r.method&&null!==a&&c._applyTimeFrame(e,n,t,i,a),l(r)}),t),this._recentSeriesId[e]=t,TradingView.ChartapiMessagerInstances[e].setResolution(o.normalize(r)),this._seriesIdCache[e+"_"+t]={symbolId:n,resolution:r,timeframe:a,turnaround:i},this._studyEngine.updateSeriesTurnaround(e,t,i),this._doWhenSeriesSymbolIdIsReady(e,t,(function(n){c._studyEngine.seriesTurnaround(e,t)===i&&c._studyEngine.createSeries(n.requestedSymbol,r,e,t,i,{countBack:s||300})}))},JSServer.ChartApi.prototype.removeSeries=function(e,t,i){this._notificationHandlers[e][t]=new u(i,t),this._studyEngine.removeSeries(e,t),m(this._seriesTimers,e,t)},JSServer.ChartApi.prototype.setVisibleTimeRange=function(e,t,i,r,o,s){var a=e.data().bars().first(),l=i,c=r,u=_(e.interval(),e.symbolInfo());null!==u&&(l=u.timeToSessionStart(1e3*i)/1e3,
c=u.timeToSessionStart(1e3*r)/1e3);var h=null!==a&&a.value[0]<=l,d=this._recentSeriesId[t],p=this._seriesIdCache[t+"_"+d].turnaround;function f(){var i=e.data(),r=i.plotValueToTimePointIndex(l,TradingView.TIME_PLOT,n.FromLeft),a=i.plotValueToTimePointIndex(c,TradingView.TIME_PLOT,n.FromRight);if(!(r>a)){var u=0,h=i.valueAt(a)[TradingView.TIME_PLOT];if(h<c&&e.syncModel()){var f=e.syncModel().distance(h,c);f.success&&(a+=u=f.result)}var _=i.last().value[TradingView.TIME_PLOT];!o||h===_&&0===u||(o.applyDefaultRightMargin=!1,o.percentRightMargin=0),TradingView.ChartapiMessagerInstances[t].onSeriesTimeframeUpdate(d,p,r,a,o),e.requestMoreData(),s&&s()}}if(h||this._studyEngine.isExtendedTo(d,t,i))f();else{var m=TradingView.ChartapiMessagerInstances[t].seriesCompleted,v=TradingView.ChartapiMessagerInstances[t].seriesError;void 0!==this._setVisibleRangeTimeout[t]&&clearTimeout(this._setVisibleRangeTimeout[t]),this._setVisibleRangeTimeout[t]=setTimeout(function(){delete this._setVisibleRangeTimeout[t],m.subscribe(null,y,!0),v.subscribe(null,g,!0),this._studyEngine.ensureExtendedTo(d,t,i)}.bind(this),0)}function y(e,t){e===d&&t===p&&(m.unsubscribe(null,y),v.unsubscribe(null,g),f())}function g(e,t){e===d&&t===p&&m.unsubscribe(null,y)}},JSServer.ChartApi.prototype._applyTimeFrame=function(e,t,i,n,s){var a,l;if(s.type===p.PeriodBack){if(!(l=TradingView.ChartapiMessagerInstances[e].lastBarTime(i)))return;var c=o.parse(s.value),u=this._symbolIdCache[this._makeSymbolKey(e,t)].symbolInfo;a=r.alignPeriodsBack(u.session,u.holidays,u.corrections,c.letter(),c.multiplier(),1,1e3*l)/1e3}else a=s.from,l=s.to;var h=chartWidget.model().mainSeries();this.setVisibleTimeRange(h,e,a,l,{applyDefaultRightMargin:!0})},JSServer.ChartApi.prototype.modifySeries=function(e,t,i,n,r,s,a,l){i=i||"";var c=this._seriesIdCache[e+"_"+t]?this._seriesIdCache[e+"_"+t].timeframe:void 0;TradingView.ChartapiMessagerInstances[e].setResolution(o.normalize(r));var h=this;this._notificationHandlers[e][t]=new u((function(r){"series_completed"===r.method&&null!==s&&(null!=c&&f(c,s)||h._applyTimeFrame(e,n,t,i,s)),a(r)}),t),this._recentSeriesId[e]=t,this._studyEngine.updateSeriesTurnaround(e,t,i),l&&(this._seriesIdCache[this._makeSeriesKey(e,l)]=null),this._seriesIdCache[this._makeSymbolKey(e,t)]={symbolId:n,resolution:r,timeframe:s,turnaround:i},this._doWhenSeriesSymbolIdIsReady(e,t,(function(t){h._studyEngine.recreateSources(t.requestedSymbol,r,e,{countBack:0},!0)}))},JSServer.ChartApi.prototype.requestMoreData=function(e,t,i,n){if(this._enabledMoreBarsRequest){var r=this,o=setTimeout((function(){r._notificationHandlers[e][t]=new u(n,t),r._studyEngine.extendSeriesRange(t,e,i)}),0);v(this._seriesTimers,e,t,o)}},JSServer.ChartApi.prototype.setStudiesAccessController=function(e){this.studiesAccessController=e},JSServer.ChartApi.prototype.setWatchlistSettings=function(e){this._watchlistSettings=e},JSServer.ChartApi.prototype.allStudiesMetadata=function(){return this._studyEngine.studiesMetadata()},JSServer.ChartApi.prototype.requestMetadata=function(e,t,i){