(self.webpackChunktradingview=self.webpackChunktradingview||[]).push([[30128],{128563:(e,t,s)=>{e.exports=[{name:s.tf(null,void 0,s(695271)),value:"",search_type:"undefined"},{name:s.tf(null,void 0,s(426294)),value:"stocks",search_type:"stocks"},{name:s.tf(null,void 0,s(301992)),value:"funds",search_type:"funds"},{name:s.tf(null,void 0,s(468631)),value:"futures",search_type:"futures"},{name:s.tf(null,void 0,s(324241)),value:"forex",search_type:"forex"},{name:s.tf(null,void 0,s(494695)),value:"cfd",search_type:"cfd"},{name:s.tf(null,void 0,s(612760)),value:"bitcoin,crypto",search_type:"crypto"},{name:s.tf(null,void 0,s(433468)),value:"index",search_type:"index"},{name:s.tf(null,void 0,s(290368)),value:"bond",search_type:"bond"},{name:s.tf(null,void 0,s(337556)),value:"economic",search_type:"economic"}]},799402:(e,t,s)=>{"use strict";s.d(t,{AuthToken:()=>a});var n=s(707957),o=s(201089),i=s(120780);const r=(0,o.getLogger)("ChartApi.AuthToken",{color:"#173"});class a{constructor(){this.invalidated=new n.Delegate,this._tid=0,window.loginStateChange||(window.loginStateChange=new n.Delegate),window.loginStateChange.subscribe(this,(e=>{e||(this._set(window.user.auth_token),this.invalidated.fire())})),this._set(window.user.auth_token)}get(e){return window.is_authenticated?!e&&performance.now(){if(!window.is_authenticated)throw new Error("User logged out while the request was in flight");return this._set(e),e})).catch((e=>(r.logError(`Error fetching new token: ${e&&e.message}`),""))):Promise.resolve("")}reset(){this._set(void 0),this.invalidated.fire()}_set(e){if(window.is_authenticated&&void 0!==e){const t=function(e){if(""===e)return 144e5;try{const t=JSON.parse(atob(e.split(".")[1].replace(/-/g,"+").replace(/_/g,"/"))),s=1e3*(t.exp-t.iat);if(!isFinite(s))throw new Error("invalid expiration");return Math.max(s-3e5,3e5)}catch(t){return r.logError(`${e} is invalid: ${t.message}`),144e5}}(e);this._cache={token:e,monoValidThru:performance.now()+t,wallValidThru:Date.now()+t},clearTimeout(this._tid),this._tid=setTimeout((()=>this.reset()),t),r.logInfo(`Cached for ${t} ms: ${e}`)}else this._cache={token:"",monoValidThru:-1/0,wallValidThru:-1/0},clearTimeout(this._tid),r.logInfo("Cache dropped")}_fetch(e,t){return r.logNormal(`Fetching a new token, grabSession=${e}`),(0,i.fetch)("/quote_token/",{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:e?"grabSession=true":""}).then((e=>{if(!e.ok)throw new Error(`Response status is not ok: ${e.status}`);return e.json().then(String)}),(s=>{if(t>=3)throw s;return r.logWarn("Request failed, will retry"),function(e){return new Promise((t=>setTimeout(t,1e3*e)))}(t).then((()=>this._fetch(e,t+1)))}))}}},448203:(e,t,s)=>{"use strict";s.r(t),s.d(t,{TVChartApiBase:()=>x}) ;var n=s(12481),o=s(203308),i=s(822914),r=s(650151),a=s(389743),d=s(778016),c=s(125226),u=s(314802),h=s(799402),l=s(244842),_=s(268222),m=s(928691),p=s(401580);class f{constructor(e){this._cache=e}async getValue(e){const t=await this._cache.match(e);if(!t)return null;return"application/json"===(0,r.ensureNotNull)(t.headers.get("Content-Type"))?t.json():t.text()}async setValue(e,t){return"string"==typeof t?this._cache.put(e,new Response(t,{headers:{"content-type":"text/plain"}})):this._cache.put(e,new Response(JSON.stringify(t),{headers:{"content-type":"application/json"}}))}}class g{constructor(){this._data=new Map}async getValue(e){var t;return null!==(t=this._data.get(e))&&void 0!==t?t:null}async setValue(e,t){this._data.set(e,t)}}var y=s(678515),v=s(201089),w=s(175203),b=s(833813);function C(e){return e.index=e.i,e.value=e.v,delete e.i,delete e.v,e}function S(e){for(const t of Object.keys(e))e[t].t&&(e[t].turnaround=e[t].t),e[t].s&&!e[t].series&&(e[t].series=e[t].s.map(C)),e[t].st&&!e[t].series&&(e[t].series=e[t].st.map(C))}class k{set_broker(e){return[e]}set_data_quality(){return["low"]}quote_create_session(e){return[e]}quote_delete_session(e){return[e]}quote_set_fields(e,t){return[e].concat(t)}quote_add_symbols(e,t){return[e].concat(t)}quote_remove_symbols(e,t){return[e].concat(t)}quote_fast_symbols(e,t){return[e].concat(t)}quote_hibernate_all(e){return[e]}depth_create_session(e,t,s){return[e,t,s]}depth_delete_session(e){return[e]}depth_set_symbol(e,t){return[e,t]}depth_clear_symbol(e){return[e]}depth_set_scale(e,t){return[e,t]}chart_create_session(e,t){return[e,t?"disable_statistics":""]}chart_delete_session(e){return[e]}set_auth_token(e){return[e]}set_locale(e,t){return[e,t]}switch_timezone(e,t){return[e,t]}resolve_symbol(e,t,s){return[e,t,s]}create_series(e,t,s,n,o,i,r){return[e,t,s=s||"",n,o,i,r]}remove_series(e,t){return[e,t]}modify_series(e,t,s,n,o,i){return[e,t,s=s||"",n,o,i]}request_more_data(e,t,s){return[e,t,s]}request_studies_metadata(e){return[e]}create_study(e,t,s,n,o,i){return[e,t,s=s||"",n,o].concat(i)}create_child_study(e,t,s,n,o,i){return this.create_study(e,t,s,n,o,i)}remove_study(e,t){return[e,t]}modify_study(e,t,s,n){return[e,t,s=s||""].concat(n)}create_pointset(e,t,s,n,o,i){return[e,t,s=s||"",n,o].concat(i)}modify_pointset(e,t,s,n){return[e,t,s=s||""].concat(n)}remove_pointset(e,t){return[e,t]}request_more_tickmarks(e,t,s){return[e,t,s]}get_first_bar_time(e,t,s){return[e,t,s]}replay_create_session(e){return[e]}replay_delete_session(e){return[e]}replay_reset(e,t,s){return[e,t,s]}replay_start(e,t,s){return[e,t,s]}replay_stop(e,t){return[e,t]}replay_step(e,t,s){return[e,t,s]}replay_add_series(e,t,s,n){return[e,t,s,n]}replay_remove_series(e,t,s,n){return[e,t,s,n]}replay_set_resolution(e,t,s){return[e,t,s]}replay_get_depth(e,t,s,n){return[e,t,s,n]}convertTimescaleResponse(e){const t=e.marks.map((e=>({span:e[0],time:e[1],index:e[2]}))),s=void 0===e.index_diff?[]:e.index_diff.map((e=>({old:e[0],new:e[1]})));return{...e,marks:t,index_diff:s}}getDataUpdateObjects(e){return this.getTimescaleObjects(e) }getTimescaleObjects(e){return e.params[0]}getTimescaleChangeset(e){return e.params[1]}prepareDataUpdateObjects(e,t,s){for(const n of Object.keys(t)){const o=t[n],i={customId:n,turnaround:o.turnaround,plots:o.series?o.series:o.plots};o.ns&&(i.nonseries=o.ns),o.lbs&&(i.lastBar={closeTime:o.lbs.bar_close_time});for(const e of i.plots)for(let t=0;t=1e100&&(e.value[t]=void 0)}s(e,n,{method:"data_update",params:i})}}unpack(e){const t=JSON.parse(e);t.m&&t.p&&(t.method=t.m,t.params=t.p,t.time=t.t);const s=t.params[1];switch(t.method){case"qsd":t.method="quote_symbol_data",s.symbolname=s.n,s.status=s.s,s.values=s.v,s.values.change=s.v.ch,s.values.last_price=s.v.lp,s.values.change_percent=s.v.chp,delete s.n,delete s.s,delete s.v,delete s.values.ch,delete s.values.lp,delete s.values.chp;break;case"du":t.method="data_update",S(s);break;case"clear_data":for(const e of Object.keys(s))s[e].turnaround=s[e].t;break;case"timescale_update":S(s)}return t}prepareEncodeMessage(e,t){return JSON.stringify({m:e,p:t})}request_data_problems(){return[]}}var q=s(397150),T=s(61378);const R=(0,v.getLogger)("Chart.Studies.StudyMetaInfoRepository",{color:"#606"}),M=(0,v.getLogger)("ChartApi.TrafficMeter",{maxCount:20,color:"#268"}),N=!(0,u.isOnMobileAppPage)("any"),D=(0,c.isFeatureEnabled)("broker_id_session");let A=!1;const P=["","KB","MB","GB","TB"];function L(e){if(0===e)return"0";const t=(0,y.toInt)(Math.floor(Math.log(e)/Math.log(1024)));return(e/Math.pow(1024,t)).toFixed(2)+P[t]}function I(e,t){return`${e}__${t}`}function E(e,t,s){var n;const o=null!==(n=t[s])&&void 0!==n?n:0;t[s]=o+e}const H=E.bind(null,1),O=E.bind(null,-1);class x{constructor(e,t,s,n){this.sessionid=null,this._banInfo=new p.WatchedValue(null),this._isAuthTokenLoaded=!1,this._authTokenDfd=null,this._serverTimeBasePoint=Date.now()-performance.now(),this._initCachePromise=async function(e){try{const t=await caches.open(e);return new f(t)}catch(e){return new g}}("TVChartApi"),this._trafficStats={total:0,sinceConnect:0,lastChunk:0},this._lowQualityEnabled=!1,this._brokerId="",this._sendingQueuedRequestsCount=0,this._modifyStudyMap=new Map,this._disconnectCount=0,this._isConnected=!1,this._metadataDeferredPromise=null,this._dataHandleModule=new k,this._notificationHandlers={},this._pendingMessagesQueue=[],this._loadNewBars=!1,this._metadataRequestNextNumber=1,this._fundamentalCounter={},this._studyCounter={},this._childStudyCounter={},this._studySpecs=new Map,this._connectionsLimitReached=new p.WatchedValue(!1),this._wsBackendConnection=e,this._chartSessionLog=t,this._chartApiLog=s,this._quoteSessionLog=n,this._wsBackendConnection.onReconnect(this._bindSocketEvents.bind(this)),this._wsBackendConnection.setLogger(s,v.getLogHistory),this._wsBackendConnection.setTelemetry(w.telemetry),this._bindSocketEvents(),this._isNonCountedStudy=()=>!0,setInterval((()=>{M.logNormal("Last 30 seconds:"+L(this._trafficStats.lastChunk)+" Since last connect:"+L(this._trafficStats.sinceConnect)+" Total traffic:"+L(this._trafficStats.total)), this._trafficStats.lastChunk=0}),3e4),this._connectionsLimitReached.subscribe((e=>{e&&this.disconnect()}))}connect(e){this._connectOnlyOptions=e,this._wsBackendConnection.isConnected()||this._wsBackendConnection.isConnecting()||this._wsBackendConnection.connect()}disconnect(){this._wsBackendConnection.disconnect()}availablePriceSources(){return Promise.resolve([])}connectionBanInfo(){return this._banInfo.readonly()}connectionsLimitReached(){return this._connectionsLimitReached.readonly()}serverTime(){return Math.round(this._serverTimeBasePoint+performance.now())}compensateConnectionLag(e){const t=this.serverTime(),s=Math.floor(e-t);s>0&&(this._serverTimeBasePoint+=s)}setBroker(e){return e===this._brokerId||(this._brokerId=e,this._sendBrokerIdToSession(this._brokerId))}getStudyCounter(e){var t;return null!==(t=this._studyCounter[e])&&void 0!==t?t:0}getFundamentalCounter(e){var t;return null!==(t=this._fundamentalCounter[e])&&void 0!==t?t:0}async requestMetadata(){return null===this._metadataDeferredPromise&&(this._metadataDeferredPromise=(0,_.createDeferredPromise)(),this._metadataDeferredPromise.promise.finally((()=>{this._metadataDeferredPromise=null})),this._requestMetadata()),this._metadataDeferredPromise.promise}setLoadNew(e){this._loadNewBars=!!e}setIsNonCountedStudyFn(e){this._isNonCountedStudy=e}canCreateStudy(e,t,s){var n;const{id:o,child:i,fundamental:a}=t,c=(0,r.ensureNotNull)((0,d.getConfig)(b.ProductFeatures.STUDY_ON_STUDY)).child_limit;if(i&&(!(0,d.enabled)(b.ProductFeatures.STUDY_ON_STUDY)||(null!==(n=this._childStudyCounter[e])&&void 0!==n?n:0)>=c))return{success:!1,reason:"child",limitValue:c};if(s)return{success:!0};const u=(0,r.ensureNotNull)((0,d.getConfig)(b.ProductFeatures.FUNDAMENTALS_ON_CHART)).limit;if(a&&(!(0,d.enabled)(b.ProductFeatures.FUNDAMENTALS_ON_CHART)||this.getFundamentalCounter(e)>=u))return{success:!1,reason:"fundamental",limitValue:u};const h=(0,r.ensureNotNull)((0,d.getConfig)(b.ProductFeatures.INDICATORS_ON_CHART)).limit;return a||this._isNonCountedStudy(o)||(0,d.enabled)(b.ProductFeatures.INDICATORS_ON_CHART)&&!(this.getStudyCounter(e)>=h)?{success:!0}:{success:!1,reason:"general",limitValue:h}}createStudy(e,t,s,n,o,i,r,a){const d=this.canCreateStudy(e,a);return d.success||"child"!==d.reason?(this._notificationHandlers[e][t]=new T.HandlerInfo(r,t),this._sendRequest("create_study",[e,t,s,n,o,i]),a.fundamental?H(this._fundamentalCounter,e):this._isNonCountedStudy(a.id)||H(this._studyCounter,e),a.child&&H(this._childStudyCounter,e),this._studySpecs.set(I(e,t),a),!0):((0,q.showTooManyStudiesNotice)(d.limitValue),!1)}modifyStudy(e,t,s,o,i,a){var d,c;E(a=null!=a?a:0,this._childStudyCounter,e),0!==a&&((0,r.ensureDefined)(this._studySpecs.get(I(e,t))).child=a>0),this._notificationHandlers[e][t]=new T.HandlerInfo(i,t);const u=e+t;if(this._modifyStudyMap.has(u)){return null===(d=(0,r.ensureDefined)(this._modifyStudyMap.get(u))(e,t,s,o))||void 0===d||d}{const i=(0,n.default)(((e,t,s,n)=>this._sendRequest("modify_study",[e,t,s,n])),500,{maxWait:550});return this._modifyStudyMap.set(u,i), null===(c=i(e,t,s,o))||void 0===c||c}}removeStudy(e,t){var s;const n=e+t;delete this._notificationHandlers[e][t],null===(s=this._modifyStudyMap.get(n))||void 0===s||s.flush();const o=this._sendRequest("remove_study",[e,t]);if(!1===o)return!1;this._modifyStudyMap.delete(n);const i=I(e,t),a=(0,r.ensureDefined)(this._studySpecs.get(i));return this._studySpecs.delete(i),a.fundamental?O(this._fundamentalCounter,e):this._isNonCountedStudy(a.id)||O(this._studyCounter,e),a.child&&O(this._childStudyCounter,e),o}unpack(e){return this._dataHandleModule.unpack(e)}sendRequest(e,t){return this._sendRequest(e,t)}enableLowQualityMode(){this._lowQualityEnabled=!0,this._sendLowQualityModeIfEnabled()}_init(){this._notificationHandlers={},this._studyCounter={},this._childStudyCounter={},this._fundamentalCounter={},this._modifyStudyMap=new Map}_sendRequest(e,t){if(0!==this._sendingQueuedRequestsCount)return this._pendingMessagesQueue.push({method:e,args:t}),!0;const s=this._dataHandleModule[e].apply(this._dataHandleModule,t),n={m:e,p:s},o=JSON.stringify(n);if(s.length>0){const e=s[0];e.startsWith("qs_")?this._quoteSessionLog.logNormal("send: "+o):e.startsWith("cs_")&&this._chartSessionLog.logNormal("send: "+o)}else this._chartApiLog.logNormal("send: "+o);const i=this._dataHandleModule.prepareEncodeMessage(e,s);return this._wsBackendConnection.send(i)}_onConnect(){if(this.connected())return;if(this._trafficStats.sinceConnect=0,this._isAuthTokenLoaded=!1,this._connectOnlyOptions=this._connectOnlyOptions||{},this._authTokenDfd=this._getAuthTokenDfd(this._connectOnlyOptions.tokenGrabSession),this._connectOnlyOptions={},this.sessionid=this._wsBackendConnection.getSessionId(),!this.sessionid||this._isConnected)return;this._pendingMessagesQueue=[],this._sendingQueuedRequestsCount=0,this._studyCounter={},this._childStudyCounter={},this._fundamentalCounter={},this._studySpecs.clear(),this._isConnected=!0,this._banInfo.setValue(null),this._connectionsLimitReached.setValue(!1);const e=JSON.parse(this.sessionid);this._sendLowQualityModeIfEnabled(),this._metadataServerHash=e.studies_metadata_hash||null;const t=this._wsBackendConnection.getConnectionEstablished();try{this._serverTimeBasePoint=Math.round(e.timestampMs-t)}catch(e){this._serverTimeBasePoint=Date.now()-performance.now()}if(this._chartApiLog.logInfo("Time shift with server: "+this._formatTime(this.serverTime()-Date.now())),this._authTokenDfd){this._sendingQueuedRequestsCount+=1,this._chartApiLog.logInfo("Wait for auth token before send messages");const e=this._authTokenDfd;e.then((t=>{if(null!==this._authTokenDfd&&this._authTokenDfd===e){if(this._chartApiLog.logNormal("Auth token request is finished, token: "+Boolean(t)),this._authTokenDfd=null,t){const e=[{method:"set_auth_token",args:[t]}];if(N){const t=window.initData&&window.initData.currentLocaleInfo;t&&e.push({method:"set_locale",args:[t.iso,t.flag.toUpperCase()]})}this._pendingMessagesQueue.unshift(...e)}this._onSendingQueueRequestFinished(),this._isAuthTokenLoaded=!0,this._notifySessions({method:"connected",params:[]}) }else this._chartApiLog.logNormal("Comes auth token after requesting new token or after socket disconnected")})).catch((e=>{this._chartApiLog.logNormal((0,m.errorToString)(e))}))}else this._chartApiLog.logWarn("Deferred auth token object is not valid"),this._isAuthTokenLoaded=!0;""!==this._brokerId&&this._sendBrokerIdToSession(this._brokerId);const s=this._wsBackendConnection.getConnectionStart();window.TradingView.WEB_SOCKET_WAS_CONNECTED=!0,w.telemetry.setSessionInfo(this.sessionid),w.telemetry.sendChartReport("websocket_connected"),w.telemetry.sendChartReport("websocket_connection_time_frame",{value:t-s}),w.telemetry.sendChartReport("reconnect_count_frame",{value:this._wsBackendConnection.getReconnectCount()}),w.telemetry.sendChartReport("redirect_count_frame",{value:this._wsBackendConnection.getRedirectCount()}),A||(A=!0,w.telemetry.sendChartReport("before_websocket_connection_time_frame",{value:s})),this._wsBackendConnection.resetCounters(),clearTimeout(this._telemetryDisconnectTimeout)}_formatTime(e){return`${(e/1e3).toFixed(2)} seconds.`}_onMessage(e){this._calcTrafficStats(e);const t=this.unpack(e);"t_ms"in t&&(0,o.default)(t.t_ms)&&window.ChartApiInstance.compensateConnectionLag(t.t_ms),"protocol_switched"!==t.method?"protocol_error"!==t.method?this._dispatchNotification(t,e):this._processProtocolError(t):this._chartApiLog.logError("Unexpected protocol changing request, try skipping. Requested protocol:"+t.params[0])}async _processedMetadata(e){const t=(0,r.ensureNotNull)(this._metadataDeferredPromise),s=await this._initCachePromise,n=window.pro.hash(),o=l.enabled("widget"),a=o?"studies_metadata_widget":"studies_metadata";try{if(await s.setValue(a,(0,i.default)(e)),this._chartApiLog.logNormal("Updated studies_metadata cache"),!o)try{await s.setValue("pro_hash",(0,i.default)(n)),this._chartApiLog.logNormal("Updated pro_hash cache")}catch(e){t.reject(),this._chartApiLog.logError("Cannot update pro_hash cache, reason: "+e)}}catch(e){t.reject(),this._chartApiLog.logError("Cannot update studies_metadata cache, reason: "+e)}t.resolve((0,i.default)(e))}async _requestMetadata(){const e=this._makeNextRequestId();R.logNormal(`Requesting metainfo #${e}`);const t=(0,r.ensureNotNull)(this._metadataDeferredPromise),s=window.pro,n=s.hash(),o=l.enabled("widget"),a=o?"studies_metadata_widget":"studies_metadata";this._chartApiLog.logNormal("Requesting pro hash");let d=!1;try{const r=await this._initCachePromise,c=await r.getValue("pro_hash");if(null!==c&&c===n||o){this._chartApiLog.logNormal("Pro hash has not changed, requesting from local");const o=await r.getValue(a),c=null!==o&&o.params[1].hash||null;if(null===c||null===this._metadataServerHash||this._metadataServerHash!==c)this._chartApiLog.logNormal("Metadata hash has changed (cached:'"+c+"', server:'"+this._metadataServerHash+"'')"),d=this._requestMetadataFromServer(e);else{if(!s.hasPackage("tv-volumebyprice")||void 0!==o.params[1].metainfo.find((e=>e.id.includes("@tv-volumebyprice"))))return this._chartApiLog.logNormal("Using studies_metadata from browser cache"), void t.resolve((0,i.default)(o));this._chartApiLog.logNormal("De-sync detected! pro.hash contains VbPR studies, but data from cache doesn't and pro.hash isn't changed, pro.hash="+n),d=this._requestMetadataFromServer(e)}}else this._chartApiLog.logNormal("Pro hash has changed (cached: '"+c+"', current:'"+n+"')"),d=this._requestMetadataFromServer(e)}catch(t){this._chartApiLog.logError("Cannot get studies_metadata, reason: "+t),d=this._requestMetadataFromServer(e)}finally{d||t.reject(),R.logNormal(`Requesting studies metadata #${e} finished`)}}_makeNextRequestId(){return"metadata_"+this._metadataRequestNextNumber++}_processProtocolError(e){const t=e.params[0];this._chartApiLog.logError(`Protocol error. Reason=${t}.`),"banned"!==t&&"banned by user_id"!==t&&"banned by ip"!==t||(this._banInfo.setValue({reason:t}),this.disconnect()),this._connectionsLimitReached.setValue("user connections limit reached"===t)}_requestMetadataFromServer(e){return this._chartApiLog.logNormal("Request studies_metadata from server"),this._sendRequest("request_studies_metadata",[e])}_bindSocketEvents(){this.connectDfd=new Promise(((e,t)=>{this._wsBackendConnection.on("connect",(()=>{this._onConnect(),e()})),this._wsBackendConnection.on("message",this._onMessage.bind(this)),this._wsBackendConnection.on("disconnect",(()=>{this._authTokenDfd&&(this._authTokenDfd=null),this._onDataProblemsPromiseErrback&&this._onDataProblemsPromiseErrback(),this._isConnected=!1,this._notifySessions({method:"disconnected",params:[]}),this._banInfo.value()||(this._metadataDeferredPromise=null),this._disconnectCount=(this._disconnectCount||0)+1,this._wsBackendConnection.isConnected()&&(this._telemetryDisconnectTimeout=setTimeout((()=>{w.telemetry.sendChartReport("disconnect")}),5e3),this._wsBackendConnection.isMaxReconnects()&&(this._notifySessions({method:"reconnect_bailout",params:[]}),t(),w.telemetry.sendChartReport("reconnect_bailout")))}))}))}_calcTrafficStats(e){const t=e.length;this._trafficStats.total+=t,this._trafficStats.sinceConnect+=t,this._trafficStats.lastChunk+=t}_sendBrokerIdToSession(e){return!D||this._sendRequest("set_broker",[e])}_sendLowQualityModeIfEnabled(){this._lowQualityEnabled&&this.connected()&&this._sendRequest("set_data_quality",[])}_getAuthTokenDfd(e){if(this._loadNewBars)return Promise.resolve("load_new_token");if(l.enabled("widget")||-1!==window.location.search.indexOf("widget_token")||-1!==window.location.hash.indexOf("widget_token")){const e=window.TradingView&&window.TradingView.widgetCustomer||"";return Promise.resolve(a[e]||"widget_user_token")}return window.is_authenticated?(this._authTokenManager||(this._authTokenManager=new h.AuthToken,this._authTokenManager.invalidated.subscribe(null,(()=>{var e;null===(e=this._authTokenManager)||void 0===e||e.get().then((e=>{e&&this.connected()&&this._sendRequest("set_auth_token",[e])}))}))),this._authTokenManager.get(e)):Promise.resolve("unauthorized_user_token")}_onSendingQueueRequestFinished(){this._sendingQueuedRequestsCount-=1, this._chartApiLog.logInfo(`Sending queue request finished. Remaining pending requests=${this._sendingQueuedRequestsCount}`),this._sendingQueuedRequestsCount<0&&this._chartApiLog.logError(`Invalid queue state=${this._sendingQueuedRequestsCount}`),0===this._sendingQueuedRequestsCount&&this._flushPendingMessages()}_flushPendingMessages(){this._chartApiLog.logInfo(`Flush pending messages. Count=${this._pendingMessagesQueue.length}`),this._pendingMessagesQueue.forEach((e=>this._sendRequest(e.method,e.args))),this._pendingMessagesQueue=[]}}},84461:(e,t,s)=>{"use strict";var n=s(389137).declareClassAsPureInterface;function o(){}TradingView.WEB_SOCKET_WAS_CONNECTED=!1,o.prototype.defaultResolutions=function(){},o.prototype.availableCurrencies=function(){},o.prototype.availableUnits=function(){},o.prototype.supportedSymbolsTypes=function(){},o.prototype.symbolsGrouping=function(){},o.prototype.quoteCreateSession=function(e){},o.prototype.quoteDeleteSession=function(e){},o.prototype.quoteSetFields=function(e,t){},o.prototype.quoteAddSymbols=function(e,t){},o.prototype.quoteRemoveSymbols=function(e,t){},o.prototype.quoteFastSymbols=function(e,t){},o.prototype.depthCreateSession=function(e,t,s){},o.prototype.depthDeleteSession=function(e){},o.prototype.depthSetSymbol=function(e,t){},o.prototype.depthClearSymbol=function(e){},o.prototype.depthSetScale=function(e,t){},o.prototype.chartCreateSession=function(e,t){},o.prototype.chartDeleteSession=function(e){},o.prototype.createSession=function(e,t){},o.prototype.removeSession=function(e){},o.prototype.connected=function(){},o.prototype.connect=function(){},o.prototype.disconnect=function(){},o.prototype.switchTimezone=function(e,t){},o.prototype.resolveSymbol=function(e,t,s,n){},o.prototype.createSeries=function(e,t,s,n,o,i,r,a){},o.prototype.removeSeries=function(e,t,s){},o.prototype.modifySeries=function(e,t,s,n,o,i,r){},o.prototype.requestMoreData=function(e,t,s,n){},o.prototype.requestMetadata=function(e){},o.prototype.canCreateStudy=function(e,t,s){},o.prototype.createStudy=function(e,t,s,n,o,i,r,a){},o.prototype.getStudyCounter=function(e){},o.prototype.getFundamentalCounter=function(e){},o.prototype.removeStudy=function(e,t){},o.prototype.modifyStudy=function(e,t,s,n,o){},o.prototype.createPointset=function(e,t,s,n,o,i,r){},o.prototype.modifyPointset=function(e,t,s,n,o){},o.prototype.removePointset=function(e,t,s){},o.prototype.requestMoreTickmarks=function(e,t,s,n){},o.prototype.requestFirstBarTime=function(e,t,s,n){},o.prototype._invokeHandler=function(e,t){},o.prototype._sendRequest=function(e,t){},o.prototype._onMessage=function(e){},o.prototype._dispatchNotification=function(e){},o.prototype._invokeNotificationHandler=function(e,t,s){},o.prototype._notifySessions=function(e){},o.prototype.unpack=function(e){},o.prototype.searchSymbols=function(e,t,s,n,o,i,r,a,d,c){},o.prototype.getMarks=function(e,t,s,n,o){},o.prototype.getTimescaleMarks=function(e,t,s,n,o){},n(o,"ChartApiInterface"),e.exports.ChartApiInterface=o},730128:(e,t,s)=>{"use strict";e=s.nmd(e) ;var n=!1,o=!1,i=s(84461).ChartApiInterface;const{HandlerInfo:r}=s(61378);var a=s(66974),d=s(175203).telemetry,c=s(244842),u=s(846540),h=s(389137).requireFullInterfaceImplementation,l=s(125226).isFeatureEnabled,_=s(230648).ResponseMethods,m=s(201089),p=s(638456).onWidget,f=m.getLogger("ChartApi.Core",{color:"#706"}),g=m.getLogger("ChartApi.ChartSession",{color:"#706"}),y=m.getLogger("ChartApi.ChartSession",{highRate:!0,maxCount:100,color:"#706"}),v=m.getLogger("ChartApi.ChartSession",{maxCount:0,color:"#706"}),w=m.getLogger("ChartApi.ChartSession",{maxCount:50,color:"#706"}),b=m.getLogger("ChartApi.QuoteSession",{maxCount:50,color:"#660"}),C=m.getLogger("ChartApi.QuoteSession",{highRate:!0,maxCount:10,color:"#660"}),S=s(128563),k=s(120780).fetch,q=s(315347).TIMEFRAMETYPE,{getLogoUrlResolver:T,LogoSize:R}=s(849204);const{TVChartApiBase:M}=s(448203);var N=l("tick_intervals")&&!p(),D=null;function A(){if(null===D){const e=document.querySelector('link[rel~="conversions-config"]'),t=new URL(e.href);D=k(t.toString(),{method:"GET"}).then((function(e){if(!e.ok)throw new Error("Response status is not success");return e.json()})).then((e=>{const t=T();return e.currencies.forEach((e=>{void 0!==e.logoid&&(e.logoUrl=t.getSymbolLogoUrl(e.logoid,R.Medium))})),e}))}return D}function P(e){if(null===e)return"";if(e.type===q.PeriodBack){var t=e.value;return"YTD"!==t&&"D"===t.slice(-1)&&(t=t.slice(0,-1)),t}return"r,"+e.from+":"+e.to}class L extends M{constructor(e){super(e,g,f,b),this._notificationHandlers={},this._sessions={}}defaultResolutions(){var e=["1","3","5","15","30","45","60","120","180","240","1D","1W","1M","3M","6M","12M","1R","10R","100R","1000R"];if(!c.enabled("widget")){var t=["1S","5S","10S","15S","30S"];return N&&(t=["1T","10T","100T","1000T"].concat(t)),t.concat(e)}return e}availableCurrencies(){return A().then((e=>e.currencies))}availableUnits(){return A().then((e=>{const t={};for(const s of e.units)t[s.type]||(t[s.type]=[]),t[s.type].push(s);return t}))}supportedSymbolsTypes(){return"bovespa"===TradingView.widgetCustomer?S.filter((function(e){return-1!==["","stock","futures","index"].indexOf(e.value)})):"cme"===TradingView.widgetCustomer?S.filter((function(e){return e.value!==u.types.QUANDL})):S}symbolsGrouping(){return{futures:/^(.+?)([12]!|\w\d{4})?$/}}quoteCreateSession(e){return this._sendRequest("quote_create_session",[e])}quoteDeleteSession(e){return this._sendRequest("quote_delete_session",[e])}quoteSetFields(e,t){return this._sendRequest("quote_set_fields",[e,t])}quoteAddSymbols(e,t){return this._sendRequest("quote_add_symbols",[e,t])}quoteRemoveSymbols(e,t){return this._sendRequest("quote_remove_symbols",[e,t])}quoteFastSymbols(e,t){return this._sendRequest("quote_fast_symbols",[e,t])}quoteHibernateAll(e){return this._sendRequest("quote_hibernate_all",[e])}depthCreateSession(e,t,s){return this._sendRequest("depth_create_session",[e,t,s])}depthDeleteSession(e){return this._sendRequest("depth_delete_session",[e])}depthSetSymbol(e,t){return this._sendRequest("depth_set_symbol",[e,t])}depthClearSymbol(e){ return this._sendRequest("depth_clear_symbol",[e])}depthSetScale(e,t){return this._sendRequest("depth_set_scale",[e,t])}chartCreateSession(e,t){return this._sendRequest("chart_create_session",[e,t])}chartDeleteSession(e){return this._sendRequest("chart_delete_session",[e])}createSession(e,t){this._sessions[e]=t,this._notificationHandlers[e]={},this.connected()&&this._isAuthTokenLoaded&&t.onMessage({method:"connected",params:[]})}removeSession(e){delete this._sessions[e],delete this._notificationHandlers[e]}connected(){return!!this._isConnected}disconnectReason(e){return 1e3===e?"Normal closure, meaning that the purpose for which the connection was established has been fulfilled.":1001===e?'An endpoint is "going away", such as a server going down or a browser having navigated away from a page.':1002===e?"An endpoint is terminating the connection due to a protocol error":1003===e?"An endpoint is terminating the connection because it has received a type of data it cannot accept (e.g., an endpoint that understands only text data MAY send this if it receives a binary message).":1004===e?"Reserved. The specific meaning might be defined in the future.":1005===e?"No status code was actually present.":1006===e?"The connection was closed abnormally, e.g., without sending or receiving a Close control frame":1007===e?"An endpoint is terminating the connection because it has received data within a message that was not consistent with the type of the message (e.g., non-UTF-8 [http://tools.ietf.org/html/rfc3629] data within a text message).":1008===e?'An endpoint is terminating the connection because it has received a message that "violates its policy". This reason is given either if there is no other sutible reason, or if there is a need to hide specific details about the policy.':1009===e?"An endpoint is terminating the connection because it has received a message that is too big for it to process.":1010===e?"An endpoint (client) is terminating the connection because it has expected the server to negotiate one or more extension, but the server didn't return them in the response message of the WebSocket handshake.
Specifically, the extensions that are needed are: "+event.reason:1011===e?"A server is terminating the connection because it encountered an unexpected condition that prevented it from fulfilling the request.":1015===e?"The connection was closed due to a failure to perform a TLS handshake (e.g., the server certificate can't be verified).":"Unknown reason"}switchTimezone(e,t){return this._sendRequest("switch_timezone",[e,t])}resolveSymbol(e,t,s,n){return d.timeCounters.series["resolve_symbol_"+e]=window.performance.now(),this._notificationHandlers[e][t]=new r(n,t),this._sendRequest("resolve_symbol",[e,t,s])}createSeries(e,t,s,n,o,i,a,c){this._notificationHandlers[e][t]=new r(c,t),d.timeCounters.series.marks.push("create_series_"+e);const u=P(a);return this._sendRequest("create_series",[e,t,s,n,o,i,u])}removeSeries(e,t){return delete this._notificationHandlers[e][t],this._sendRequest("remove_series",[e,t])} modifySeries(e,t,s,n,o,i,a,d){this._notificationHandlers[e][t]=new r(d,t);const c=P(a);return this._sendRequest("modify_series",[e,t,s,n,o,c])}requestMoreData(e,t,s,n){if("number"!=typeof s)throw new Error("unsupported request to load more data, bars="+s);return this._notificationHandlers[e][t]=new r(n,t),this._sendRequest("request_more_data",[e,t,s])}authTokenManager(){return this._authTokenManager}createPointset(e,t,s,n,o,i,a){return this._notificationHandlers[e][t]=new r(a,t),this._sendRequest("create_pointset",[e,t,s,n,o,i])}modifyPointset(e,t,s,n,o){return this._notificationHandlers[e][t]=new r(o,t),this._sendRequest("modify_pointset",[e,t,s,n])}removePointset(e,t,s){return this._notificationHandlers[e][t]=new r(s,t),this._sendRequest("remove_pointset",[e,t])}requestMoreTickmarks(e,t,s,n){return this._notificationHandlers[e][t]=new r(n,t),this._sendRequest("request_more_tickmarks",[e,t,s])}requestFirstBarTime(e,t,s,n){return this._notificationHandlers[e][t]=new r(n,t),this._sendRequest("get_first_bar_time",[e,t,s])}redirectCount(){return this._wsBackendConnection.getRedirectCount()}disconnectCount(){return this._disconnectCount||0}_invokeHandler(e,t){e&&e(t)}_convertTimescaleResponse(e){return this._dataHandleModule.convertTimescaleResponse(e)}_appendDuration(e,t){return e?t+", duration: "+this._formatTime(this.serverTime()-1e3*e):t}_dispatchNotification(e,t){if("request_data_problems"===e.method&&this._onDataProblemsPromiseCb)this._onDataProblemsPromiseCb(e.params);else if("studies_metadata"!==e.method||null===this._metadataDeferredPromise){var s=e.params.shift();if(this._notificationHandlers[s]){var i=e.params[0];if("symbol_resolved"===e.method){var r=e.params[1].full_name;d.sendChartReport("symbol_resolved",{count:1,additional:{symbol:r}});var a=d.timeCounters.series["resolve_symbol_"+s];"number"==typeof a&&d.sendChartReport("symbol_resolve_time_frame",{value:window.performance.now()-a,additional:{symbol:r}})}if(["series_error","series_completed"].includes(e.method)&&d.timeCounters.series.marks.length>0){var c="create_series_"+s,u=d.timeCounters.series.marks.indexOf(c);u>=0&&d.timeCounters.series.marks.splice(u,1)}o||"series_error"!==e.method||(o=!0);var h=this._wsBackendConnection.getConnectionEstablished();if(null!==h&&"series_completed"===e.method&&(o||(o=!0,d.sendChartReport("first_series_full_time_frame",{value:window.performance.now()-h}),d.timeCounters.series.marks=[]),n||(n=!0,d.sendChartReport("page_full_load_time_frame",{value:window.performance.now()}))),s.startsWith("cs_")){var l="recv: "+t;"data_update"===e.method?(l=m.isHighRateEnabled()?l:l.slice(0,500),y.logNormal(this._appendDuration(e.time,l))):"study_loading"===e.method?v.logNormal(this._appendDuration(e.time,l)):"tickmark_update"===e.method?w.logNormal(this._appendDuration(e.time,l)):g.logNormal(this._appendDuration(e.time,l))}if(s.startsWith("qs_"))("quote_symbol_data"===e.method?C.logNormal:b.logNormal)("recv: "+t);switch(e.method){case"timescale_update": var p=this._dataHandleModule.getTimescaleObjects(e),S=this._dataHandleModule.getTimescaleChangeset(e);(k=this._convertTimescaleResponse(S)).clear=0===k.changes.length&&0===k.index_diff.length&&0===k.marks.length,this._sessions[s].onMessage({method:"timescale_update",params:k}),this._dataHandleModule.prepareDataUpdateObjects(s,p,function(e,t,s){this._invokeNotificationHandler(e,t,s)}.bind(this));break;case"tickmark_update":var k;(k=this._convertTimescaleResponse(e.params[0])).changes=[],this._sessions[s].onMessage({method:"timescale_update",params:k});break;case"data_update":p=this._dataHandleModule.getDataUpdateObjects(e);this._dataHandleModule.prepareDataUpdateObjects(s,p,function(e,t,s){this._invokeNotificationHandler(e,t,s)}.bind(this));break;case"index_update":for(var T in e.params[0]){var R={method:"index_update",params:e.params[0][T]};this._invokeNotificationHandler(s,T,R)}break;case"critical_error":f.logInfo(new Date+" critical_error session:"+this.sessionid+" reason:"+e.params[0]),d.sendChartReport("critical_error"),this._sessions[s].onMessage({method:"critical_error",params:e.params});break;case"timescale_completed":case"quote_symbol_data":case"quote_list_fields":case"quote_completed":case"depth_symbol_error":case"depth_symbol_success":case"dd":case"dpu":case"depth_bar_last_value":this._sessions[s].onMessage({method:e.method,params:e.params});break;case"clear_data":for(var M in e.params[0])this._invokeNotificationHandler(s,M,{method:"clear_data",params:e.params[0][M]});break;case _.point:case _.resolutions:case _.endOfData:case _.instanceId:case _.replayDepth:case _.error:case _.ok:this._sessions[s].onMessage(e);break;case"series_timeframe":e.params[4]=function(e){if(null==e)return null;var t=/r,(\d+):(\d+)/.exec(e);return null!==t?{from:Number(t[1]),to:Number(t[2]),type:q.TimeRange}:{value:e,type:q.PeriodBack}}(e.params[4]),this._invokeNotificationHandler(s,i,e);break;case"symbol_resolved":!function(e){if(void 0===e.corrections){var t=e.subsessions.find((function(t){return t.id===e.subsession_id}));void 0!==t&&(e.corrections=t["session-correction"])}}(e.params[1]),this._invokeNotificationHandler(s,i,e);break;default:this._invokeNotificationHandler(s,i,e)}}}else this._processedMetadata(e)}_isStrategy(e,t){var s=this._notificationHandlers[e][t];return s&&s.handler&&s.handler.isTVScriptStrategy}_invokeNotificationHandler(e,t,s){if(void 0!==t){var n=this._notificationHandlers[e][t];void 0!==n&&this._invokeHandler(n.handler,s)}}_notifySessions(e){for(var t in this._sessions){if(!this._sessions.hasOwnProperty(t))return;var s=this._sessions[t];"function"==typeof s.onMessage&&s.onMessage(e)}}searchSymbols(e,t,s,n,o,i,r,c,h,l){var _=this;this._symbolSearchRequest&&this._symbolSearchRequest.abort();var m=location.protocol+"//"+window.SS_HOST;a.isProd()?m+="/symbol_search/":m+="/local_search/",window.SS_URL&&(m=window.SS_URL);var p={text:e,exchange:t,type:s,hl:o,lang:n};window.SS_DOMAIN_PARAMETER&&(p.domain=window.SS_DOMAIN_PARAMETER),i&&(p.strict=1), s===u.types.QUANDL&&(m="https://quandlapi.tradingview.com/api/v3/datasets.json",p={query:e,database_code:t}),r&&(p.broker=r,c&&(p.tradable=!0),h&&(p.unhide=h));var f=Object.keys(p).map((function(e){return encodeURIComponent(e)+"="+encodeURIComponent(p[e])})).join("&"),g=new XMLHttpRequest;g.open("GET",m+"?"+f);var y=window.performance.now();function v(){d.sendChartReport("symbol_search_time_frame",{value:window.performance.now()-y})}function w(){v(),d.sendChartReport("symbol_search_http_error"),_._symbolSearchRequest=null}g.addEventListener("load",(function(){var e=JSON.parse(g.responseText);l&&l(e),v(),d.sendChartReport("symbol_search_http_status",{value:g.status}),_._symbolSearchRequest=null})),g.addEventListener("error",w),g.addEventListener("timeout",w),this._symbolSearchRequest=g,g.send()}getMarks(e,t,s,n,o){throw Error("This method is not implemented")}getTimescaleMarks(e,t,s,n,o){throw Error("This method is not implemented")}getPingInfo(){return this._wsBackendConnection.getPingInfo()}requestDataProblems(){return this._requestDataProblemsPromise||(this._requestDataProblemsPromise=this.connectDfd.then((()=>new Promise(((e,t)=>{this._onDataProblemsPromiseErrback=t,this._sendRequest("request_data_problems",[])?this._onDataProblemsPromiseCb=e:t()})))).finally((()=>{this._requestDataProblemsPromise=null}))),this._requestDataProblemsPromise}}h(L,"TVChartApi",i,"ChartApiInterface"),window.ChartApiInstance=new L(window.WSBackendConnection),e&&e.exports&&(e.exports=L)},61378:(e,t,s)=>{"use strict";s.r(t),s.d(t,{HandlerInfo:()=>n});class n{constructor(e,t){this.handler=e,this.customId=t}}},230648:(e,t,s)=>{"use strict";var n,o;s.d(t,{ResponseMethods:()=>n}),function(e){e.error="replay_error",e.point="replay_point",e.ok="replay_ok",e.resolutions="replay_resolutions",e.endOfData="replay_data_end",e.instanceId="replay_instance_id",e.replayDepth="replay_depth"}(n||(n={})),function(e){e.tooSmallDelay="too_small_delay",e.alreadyInAutoplay="already_in_autoplay",e.nothingToStop="nothing_to_stop",e.pointTooDeep="point_too_deep",e.alreadyInSession="already_in_session",e.thereIsNoSuchSeries="no_series",e.notAllowedInAutoplay="not_allow_in_autoplay",e.invalidResolution="invalid_resolution"}(o||(o={}))},268222:(e,t,s)=>{"use strict";function n(){let e,t;return{promise:new Promise(((s,n)=>{e=s,t=n})),reject:t,resolve:e}}s.d(t,{createDeferredPromise:()=>n})},928691:(e,t,s)=>{"use strict";function n(e){if(void 0===e)return"";if(e instanceof Error){let t=e.message;return e.stack&&(t+=" "+e.stack),t}return"string"==typeof e?e.toString():JSON.stringify(e)}s.d(t,{errorToString:()=>n})}}]);