(self.webpackChunktradingview=self.webpackChunktradingview||[]).push([[5516,3718],{62092:e=>{e.exports={loader:"loader-MuZZSHRY",static:"static-MuZZSHRY",item:"item-MuZZSHRY","tv-button-loader":"tv-button-loader-MuZZSHRY",medium:"medium-MuZZSHRY",small:"small-MuZZSHRY",black:"black-MuZZSHRY",white:"white-MuZZSHRY",gray:"gray-MuZZSHRY",primary:"primary-MuZZSHRY","loader-initial":"loader-initial-MuZZSHRY","loader-appear":"loader-appear-MuZZSHRY"}},26390:e=>{e.exports={switcher:"switcher-GT7Z98Io","disable-cursor-pointer":"disable-cursor-pointer-GT7Z98Io",input:"input-GT7Z98Io","thumb-wrapper":"thumb-wrapper-GT7Z98Io","size-small":"size-small-GT7Z98Io","size-large":"size-large-GT7Z98Io","intent-default":"intent-default-GT7Z98Io","disable-active-state-styles":"disable-active-state-styles-GT7Z98Io","intent-select":"intent-select-GT7Z98Io",track:"track-GT7Z98Io",thumb:"thumb-GT7Z98Io"}},50789:e=>{e.exports={summary:"summary-hk3Mmxts",hovered:"hovered-hk3Mmxts",caret:"caret-hk3Mmxts"}},28857:e=>{e.exports={wrapper:"wrapper-OGmb0GMo",labelRow:"labelRow-OGmb0GMo",label:"label-OGmb0GMo",labelHint:"labelHint-OGmb0GMo",labelOn:"labelOn-OGmb0GMo"}},31405:e=>{e.exports={wrapper:"wrapper-IbP2mmCe",hovered:"hovered-IbP2mmCe",labelRow:"labelRow-IbP2mmCe",label:"label-IbP2mmCe",labelHint:"labelHint-IbP2mmCe",labelOn:"labelOn-IbP2mmCe"}},39592:e=>{e.exports={button:"button-Rsu8YfBx",withText:"withText-Rsu8YfBx",withoutText:"withoutText-Rsu8YfBx"}},69698:e=>{e.exports={form:"form-obOlo718",interacting:"interacting-obOlo718",input:"input-obOlo718",menu:"menu-obOlo718",add:"add-obOlo718",hovered:"hovered-obOlo718",hover:"hover-obOlo718",wrap:"wrap-obOlo718"}},59174:e=>{e.exports={spinnerWrap:"spinnerWrap-OjdCXkZp"}},78966:e=>{e.exports={title:"title-mAu74Mtg"}},936:e=>{e.exports={button:"button-2Vex9IkU",first:"first-2Vex9IkU",last:"last-2Vex9IkU"}},82832:e=>{e.exports={wrap:"wrap-H6XRnLaC"}},91887:e=>{e.exports={hidden:"hidden-vHZuIWsw"}},75492:e=>{e.exports={"tablet-small-breakpoint":"screen and (max-width: 428px)",item:"item-AFYo6gMo",withIcon:"withIcon-AFYo6gMo",shortcut:"shortcut-AFYo6gMo",loading:"loading-AFYo6gMo",icon:"icon-AFYo6gMo"}},19450:e=>{e.exports={button:"button-OSzyNVEZ",menu:"menu-OSzyNVEZ"}},33191:e=>{e.exports={customTradingViewStyleButton:"customTradingViewStyleButton-fjLcMxZj",withoutIcon:"withoutIcon-fjLcMxZj"}},64142:e=>{e.exports={dropdown:"dropdown-E3UQYoRD",label:"label-E3UQYoRD",smallWidthTitle:"smallWidthTitle-E3UQYoRD",smallWidthMenuItem:"smallWidthMenuItem-E3UQYoRD",smallWidthWrapper:"smallWidthWrapper-E3UQYoRD"}},87906:e=>{e.exports={value:"value-e0RYyFXU",selected:"selected-e0RYyFXU"}},32062:e=>{e.exports={smallWidthMenuItem:"smallWidthMenuItem-xvK6HzAF"}},6500:e=>{e.exports={button:"button-cXbh8Gcw",first:"first-cXbh8Gcw",last:"last-cXbh8Gcw",newStyles:"newStyles-cXbh8Gcw",menu:"menu-cXbh8Gcw",dropdown:"dropdown-cXbh8Gcw",menuContent:"menuContent-cXbh8Gcw",section:"section-cXbh8Gcw",smallTabletSectionTitle:"smallTabletSectionTitle-cXbh8Gcw",addCustomInterval:"addCustomInterval-cXbh8Gcw", hovered:"hovered-cXbh8Gcw"}},76521:e=>{e.exports={button:"button-CiwmljCL"}},4050:e=>{e.exports={button:"button-mEQw2hrh",isDisabled:"isDisabled-mEQw2hrh",text:"text-mEQw2hrh"}},96141:e=>{e.exports={opened:"opened-SUlSleuH",hover:"hover-SUlSleuH",autoSaveWrapper:"autoSaveWrapper-SUlSleuH",sharingWrapper:"sharingWrapper-SUlSleuH",button:"button-SUlSleuH",buttonSmallPadding:"buttonSmallPadding-SUlSleuH",hintPlaceHolder:"hintPlaceHolder-SUlSleuH",smallHintPlaceHolder:"smallHintPlaceHolder-SUlSleuH",popupItemRowTabletSmall:"popupItemRowTabletSmall-SUlSleuH",shortcut:"shortcut-SUlSleuH"}},72597:e=>{e.exports={button:"button-TTaQ4aBF",text:"text-TTaQ4aBF",logo:"logo-TTaQ4aBF"}},67397:e=>{e.exports={button:"button-IQnsk0hp",largeLeftPadding:"largeLeftPadding-IQnsk0hp",text:"text-IQnsk0hp",uppercase:"uppercase-IQnsk0hp"}},75668:e=>{e.exports={description:"description-Q7biiIOG"}},52157:e=>{e.exports={item:"item-UfrwNtjY",round:"round-UfrwNtjY"}},41939:e=>{e.exports={wrap:"wrap-hoa11YwL",titleWrap:"titleWrap-hoa11YwL",indicators:"indicators-hoa11YwL",title:"title-hoa11YwL",icon:"icon-hoa11YwL",text:"text-hoa11YwL",titleTabletSmall:"titleTabletSmall-hoa11YwL",labelRow:"labelRow-hoa11YwL",label:"label-hoa11YwL"}},14621:e=>{e.exports={labelRow:"labelRow-qyt9pxdb",toolbox:"toolbox-qyt9pxdb",description:"description-qyt9pxdb",descriptionTabletSmall:"descriptionTabletSmall-qyt9pxdb",item:"item-qyt9pxdb",titleItem:"titleItem-qyt9pxdb",titleItemTabletSmall:"titleItemTabletSmall-qyt9pxdb",itemTabletSmall:"itemTabletSmall-qyt9pxdb",itemLabelTabletSmall:"itemLabelTabletSmall-qyt9pxdb",wrap:"wrap-qyt9pxdb",hovered:"hovered-qyt9pxdb"}},89227:e=>{e.exports={menu:"menu-Pi7orIC5",menuSmallTablet:"menuSmallTablet-Pi7orIC5",menuItemHeaderTabletSmall:"menuItemHeaderTabletSmall-Pi7orIC5",menuItemHeader:"menuItemHeader-Pi7orIC5"}},73887:e=>{e.exports={wrap:"wrap-mbKoosX4",full:"full-mbKoosX4",first:"first-mbKoosX4",last:"last-mbKoosX4",medium:"medium-mbKoosX4",buttonWithFavorites:"buttonWithFavorites-mbKoosX4"}},82559:e=>{e.exports={icon:"icon-0KfEd2LW"}},4039:e=>{e.exports={buttonUndo:"buttonUndo-6VeYguKu",buttonRedo:"buttonRedo-6VeYguKu"}},72142:e=>{e.exports={footer:"footer-C0oTZgbU"}},49473:e=>{e.exports={dottedCloud:"dottedCloud-NezC5dyJ",check:"check-NezC5dyJ",spinningCloud:"spinningCloud-NezC5dyJ",arrow:"arrow-NezC5dyJ",arrowGap:"arrowGap-NezC5dyJ",container:"container-NezC5dyJ",unsaved:"unsaved-NezC5dyJ",hovered:"hovered-NezC5dyJ",saving:"saving-NezC5dyJ",saved:"saved-NezC5dyJ"}},63095:e=>{e.exports={item:"item-UZNJ2Dq5",label:"label-UZNJ2Dq5",labelRow:"labelRow-UZNJ2Dq5",toolbox:"toolbox-UZNJ2Dq5"}},524:e=>{e.exports={separator:"separator-GzmeVcFo",small:"small-GzmeVcFo",normal:"normal-GzmeVcFo",large:"large-GzmeVcFo"}},17946:(e,t,a)=>{"use strict";a.d(t,{CustomBehaviourContext:()=>n,presetDefault:()=>i,presetPlatform:()=>s});const n=(0,a(59496).createContext)({enablePointerOnHover:!0,enableActiveStateStyles:!0}),i={enableActiveStateStyles:!0,enablePointerOnHover:!0},s={enableActiveStateStyles:!1,enablePointerOnHover:!1}},76974:(e,t,a)=>{ "use strict";a.d(t,{useIsMounted:()=>i});var n=a(59496);const i=()=>{const e=(0,n.useRef)(!1);return(0,n.useEffect)(()=>(e.current=!0,()=>{e.current=!1}),[]),e}},26996:(e,t,a)=>{"use strict";a.d(t,{Loader:()=>h});var n,i=a(59496),s=a(97754),o=a(74991),l=a(62092),r=a.n(l);!function(e){e[e.Initial=0]="Initial",e[e.Appear=1]="Appear",e[e.Active=2]="Active"}(n||(n={}));class h extends i.PureComponent{constructor(e){super(e),this._stateChangeTimeout=null,this.state={state:n.Initial}}render(){const{className:e,color:t="black",size:a="medium",staticPosition:n}=this.props,o=s(r().item,r()[t],r()[a]);return i.createElement("span",{className:s(r().loader,n&&r().static,this._getStateClass(),e)},i.createElement("span",{className:o}),i.createElement("span",{className:o}),i.createElement("span",{className:o}))}componentDidMount(){this.setState({state:n.Appear}),this._stateChangeTimeout=setTimeout(()=>{this.setState({state:n.Active})},2*o.dur)}componentWillUnmount(){this._stateChangeTimeout&&(clearTimeout(this._stateChangeTimeout),this._stateChangeTimeout=null)}_getStateClass(){switch(this.state.state){case n.Initial:return r()["loader-initial"];case n.Appear:return r()["loader-appear"];default:return""}}}},17290:(e,t,a)=>{"use strict";a.d(t,{Switch:()=>h});var n=a(59496),i=a(97754),s=a(17946),o=a(26390),l=a.n(o);function r(e){const t=(0,n.useContext)(s.CustomBehaviourContext),{className:a,intent:o="default",size:r="small",enablePointerOnHover:h=t.enablePointerOnHover,enableActiveStateStyles:c=t.enableActiveStateStyles}=e;return i(a,l().switcher,l()["size-"+r],l()["intent-"+o],!h&&l()["disable-cursor-pointer"],!c&&l()["disable-active-state-styles"])}function h(e){const{reference:t,size:a,intent:i,...s}=e;return n.createElement("div",{className:r(e)},n.createElement("input",{...s,type:"checkbox",className:l().input,ref:t}),n.createElement("div",{className:l()["thumb-wrapper"]},n.createElement("div",{className:l().track}),n.createElement("div",{className:l().thumb})))}},26005:(e,t,a)=>{"use strict";a.d(t,{CollapsibleSection:()=>r});var n=a(59496),i=a(97754),s=a.n(i),o=a(10381),l=a(50789);function r(e){return n.createElement(n.Fragment,null,n.createElement("div",{className:s()(e.className,l.summary),onClick:function(){e.onStateChange&&e.onStateChange(!e.open)},"data-open":e.open},e.summary,n.createElement(o.ToolWidgetCaret,{className:l.caret,dropped:Boolean(e.open)})),e.open&&e.children)}},59918:(e,t,a)=>{"use strict";a.d(t,{DEFAULT_MENU_ITEM_SWITCHER_THEME:()=>h,MenuItemSwitcher:()=>c});var n=a(59496),i=a(97754),s=a.n(i),o=a(17290),l=a(90186),r=a(31405);const h=r;function c(e){const{className:t,checked:a,id:i,label:h,labelDescription:c,value:d,preventLabelHighlight:u,reference:m,switchReference:v,theme:p=r,disabled:g}=e,b=s()(p.label,a&&!u&&p.labelOn),S=s()(t,p.wrapper,a&&p.wrapperWithOnLabel);return n.createElement("label",{className:S,htmlFor:i,ref:m},n.createElement("div",{className:p.labelRow},n.createElement("div",{className:b},h),c&&n.createElement("div",{className:p.labelHint},c)),n.createElement(o.Switch,{disabled:g, className:p.switch,reference:v,checked:a,onChange:function(t){const a=t.target.checked;void 0!==e.onChange&&e.onChange(a)},value:d,tabIndex:-1,id:i,...(0,l.filterDataProps)(e)}))}},53374:(e,t,a)=>{"use strict";a.d(t,{INTERVALS:()=>i});var n=a(28353);const i=[{name:"",label:(0,n.t)("minutes",{context:"interval"})},{name:"H",label:(0,n.t)("hours",{context:"interval"})},{name:"D",label:(0,n.t)("days",{context:"interval"})},{name:"W",label:(0,n.t)("weeks",{context:"interval"})},{name:"M",label:(0,n.t)("months",{context:"interval"})}]},49466:(e,t,a)=>{"use strict";a.d(t,{ToolWidgetMenuSummary:()=>o});var n=a(59496),i=a(97754),s=a(78966);function o(e){return n.createElement("div",{className:i(e.className,s.title)},e.children)}},79389:(e,t,a)=>{"use strict";a.r(t),a.d(t,{getRestrictedToolSet:()=>sn});var n=a(67337),i=a(59496),s=a(19036),o=a(28353),l=a(82992),r=a(16654),h=a(37466),c=a(36189),d=a(9745),u=a(16396),m=a(35390),v=a(97754),p=a.n(v),g=a(82832);class b extends i.PureComponent{render(){const{children:e,className:t,...a}=this.props;return i.createElement("div",{className:v(t,g.wrap),...a},e)}}var S=a(4825),C=a(90186),_=a(936);class y extends i.PureComponent{constructor(){super(...arguments),this._handleClick=()=>{const{onClick:e,onClickArg:t}=this.props;e&&e(t)}}render(){const{isFirst:e,isLast:t,hint:a,text:n,icon:s,isActive:o,isDisabled:l,className:r}=this.props,h=(0,C.filterDataProps)(this.props);return i.createElement(S.ToolWidgetButton,{...h,icon:s,text:n,title:a,isDisabled:l,isActive:o,isGrouped:!0,onClick:this._handleClick,className:v(r,_.button,{[_.first]:e,[_.last]:t})})}}var w=a(51613),f=a(90692),k=a(24437),M=a(81332),T=a(55402),E=a(15943),x=a(19450);const I={0:(0,o.t)("Bars"),1:(0,o.t)("Candles"),9:(0,o.t)("Hollow candles"),13:(0,o.t)("Columns"),8:(0,o.t)("Heikin Ashi"),2:(0,o.t)("Line"),3:(0,o.t)("Area"),10:(0,o.t)("Baseline"),12:(0,o.t)("High-low")};const A={barsStyle:(0,o.t)("Bar's style"),labels:I},R=(0,T.registryContextType)();function F(e){var t;return!(null===(t=l.linking.supportedChartStyles.value())||void 0===t?void 0:t.includes(e))}class N extends i.PureComponent{constructor(e,t){super(e,t),this._handleChangeStyle=e=>{const{favorites:t,lastSelectedNotFavorite:a,activeStyle:n}=this.state;this.setState({activeStyle:e,lastSelectedNotFavorite:t.includes(n)?a:n})},this._handleSelectStyle=e=>{const{chartWidgetCollection:t}=this.context;e!==t.activeChartStyle.value()&&t.setChartStyleToWidget(e)},this._handleClickFavorite=e=>{this._isStyleFavorited(e)?this._handleRemoveFavorite(e):this._handleAddFavorite(e)},this._boundForceUpdate=()=>{this.forceUpdate()},this._handleQuickClick=e=>{this._handleSelectStyle(e),this._trackClick()},(0,T.validateRegistry)(t,{chartWidgetCollection:s.any.isRequired,favoriteChartStylesService:s.any.isRequired});const{chartWidgetCollection:a,favoriteChartStylesService:n}=t,i=a.activeChartStyle.value(),o=n.get(),l=(0,E.japaneseChartStyles)();this.state={activeStyle:i,favorites:o,styles:(0,E.commonChartStyles)(),japaneseStyles:l}}componentDidMount(){ const{chartWidgetCollection:e,favoriteChartStylesService:t}=this.context;e.activeChartStyle.subscribe(this._handleChangeStyle),t.getOnChange().subscribe(this,this._handleChangeSettings),l.linking.supportedChartStyles.subscribe(this._boundForceUpdate)}componentWillUnmount(){const{chartWidgetCollection:e,favoriteChartStylesService:t}=this.context;e.activeChartStyle.unsubscribe(this._handleChangeStyle),t.getOnChange().unsubscribe(this,this._handleChangeSettings),l.linking.supportedChartStyles.unsubscribe(this._boundForceUpdate)}render(){const{isShownQuicks:e,displayMode:t="full",id:a}=this.props,{activeStyle:n,favorites:s,styles:o,japaneseStyles:l,lastSelectedNotFavorite:c}=this.state,u="small"!==t&&e&&0!==s.length,v=[...s];v.includes(n)?void 0!==c&&v.push(c):v.push(n);const p=u&&v.length>1;return i.createElement(f.MatchMedia,{rule:k.DialogBreakpoints.TabletSmall},e=>{const t=o.map(t=>this._renderPopupMenuItem(t,t===n,e)),s=l.map(t=>this._renderPopupMenuItem(t,t===n,e));return i.createElement(b,{id:a},p&&v.map((e,t)=>i.createElement(y,{className:x.button,icon:h.SERIES_ICONS[e],isActive:u&&n===e,isDisabled:F(e),key:t,hint:A.labels[e],isFirst:0===t,isLast:t===v.length-1,onClick:u?this._handleQuickClick:void 0,onClickArg:e,"data-value":r.STYLE_SHORT_NAMES[e]})),i.createElement(m.ToolWidgetMenu,{arrow:Boolean(p),content:p?void 0:i.createElement(b,null,i.createElement(d.Icon,{icon:h.SERIES_ICONS[n]})),title:p?A.barsStyle:A.labels[n],className:x.menu,isDrawer:e,onClick:this._trackClick},t,!!s.length&&i.createElement(w.PopupMenuSeparator,null),s))})}_renderPopupMenuItem(e,t,a){const{isFavoritingAllowed:n}=this.props,s=this._isStyleFavorited(e);return i.createElement(u.PopupMenuItem,{key:e,theme:a?M.multilineLabelWithIconAndToolboxTheme:void 0,icon:h.SERIES_ICONS[e],isActive:t,isDisabled:F(e),label:A.labels[e]||"",onClick:this._handleSelectStyle,onClickArg:e,showToolboxOnHover:!s,toolbox:n&&i.createElement(c.FavoriteButton,{isActive:t,isFilled:s,onClick:()=>this._handleClickFavorite(e)}),"data-value":r.STYLE_SHORT_NAMES[e]})}_handleChangeSettings(e){this.setState({lastSelectedNotFavorite:void 0,favorites:e})}_isStyleFavorited(e){return-1!==this.state.favorites.indexOf(e)}_handleAddFavorite(e){const{favorites:t}=this.state,{favoriteChartStylesService:a}=this.context;a.set([...t,e])}_handleRemoveFavorite(e){const{favorites:t}=this.state,{favoriteChartStylesService:a}=this.context;a.set(t.filter(t=>t!==e))}_trackClick(){0}}N.contextType=R;var H=a(39592);const z=["medium","small"];function P(e){const{text:t,className:a,displayMode:n,collapseWhen:s=z,...o}=e,l=!s.includes(n);return i.createElement(S.ToolWidgetButton,{...o,text:l?t:void 0,className:v(a,H.button,l?H.withText:H.withoutText)})}var W=a(51768),D=a(37669),L=a(2323);const O={compare:(0,o.t)("Compare"),compareOrAddSymbol:(0,o.t)("Compare or Add Symbol")},U=(0,T.registryContextType)();class B extends i.PureComponent{constructor(e,t){super(e,t),this._updateState=e=>{this.setState({isActive:e})},this._handleClick=()=>{var e;(0, W.trackEvent)("GUI","Chart Header Toolbar","compare"),null===(e=this._compareDialogRenderer)||void 0===e||e.show()},(0,T.validateRegistry)(t,{chartWidgetCollection:s.any.isRequired}),this.state={isActive:!1},this._compareDialogRenderer=this.context.chartWidgetCollection.getCompareDialogRenderer()}componentDidMount(){var e;null===(e=this._compareDialogRenderer)||void 0===e||e.visible().subscribe(this._updateState)}componentWillUnmount(){var e;null===(e=this._compareDialogRenderer)||void 0===e||e.visible().unsubscribe(this._updateState)}render(){const{isActive:e}=this.state;return i.createElement(P,{...this.props,icon:L,isOpened:e,onClick:this._handleClick,text:D.hasNewHeaderToolbarStyles?void 0:O.compare,title:O.compareOrAddSymbol,collapseWhen:D.hasNewHeaderToolbarStyles?["full","medium","small"]:void 0})}}B.contextType=U;var V=a(14593),G=a(61814),Z=a(68335),Y=a(90711),q=a(15392);const K={hint:(0,o.t)("Fullscreen mode")},Q=(0,G.hotKeySerialize)({keys:[(0,Z.humanReadableModifiers)(Z.Modifiers.Shift,!1),"F"],text:"{0} + {1}"}),j=(0,T.registryContextType)();class X extends i.PureComponent{constructor(e,t){super(e,t),this._handleClick=()=>{const{chartWidgetCollection:e}=this.context;e.startFullscreen()},(0,T.validateRegistry)(t,{chartWidgetCollection:s.any.isRequired})}render(){const{className:e,id:t}=this.props;return i.createElement(V.ToolWidgetIconButton,{id:t,icon:D.hasNewHeaderToolbarStyles?q:Y,onClick:this._handleClick,title:K.hint,className:v(e),"data-tooltip-hotkey":Q})}}X.contextType=j;var J=a(88537);const $=(0,a(98125).getLogger)("FavoritesInfo");function ee(e,t){if(0===e.length)return Promise.resolve([]);$.logNormal("Requesting favorites info");const a=[],n=new Map,i=new Map,s=new Map;return e.forEach(e=>{switch(e.type){case"java":s.set(e.studyId,e);break;case"pine":isPublishedPineId(e.pineId)?n.set(e.pineId,e):i.set(e.pineId,e);break;default:(0,J.assert)(!1,"unknown favorite type "+JSON.stringify(e))}}),0!==s.size&&a.push(t.findAllJavaStudies().then(e=>{const t=new Map;for(const a of e)!a.is_hidden_study&&s.has(a.id)&&t.set(a.id,{name:a.description,localizedName:a.description_localized,studyMarketShittyObject:a});return t}).then(e=>{const t=function(e,t){const a={items:[],notFoundItems:[]};return e.forEach((e,n)=>{const i=t.get(n);void 0!==i?a.items.push({item:e,info:i}):a.notFoundItems.push(e)}),a}(s,e);if(0!==t.notFoundItems.length){const e=t.notFoundItems.map(e=>e.studyId);$.logWarn("Cannot find java scripts: "+JSON.stringify(e))}return t.items})),Promise.all(a).then(e=>($.logNormal("Requesting favorites info finished"),e.reduce((e,t)=>e.concat(t),[])))}var te=a(14291),ae=a(85733),ne=a(26996),ie=a(59174);function se(e){const{className:t}=e;return i.createElement("div",{className:p()(ie.spinnerWrap,t)},i.createElement(ne.Loader,null))}var oe=a(49466),le=a(76422),re=a(60373),he=a(64142);const ce={text:(0,o.t)("Indicators"),hint:(0,o.t)("Indicators & Strategies"),favorites:(0,o.t)("Favorites")},de=(0,G.hotKeySerialize)({keys:["/"],text:"{0}"}),ue=(0,T.registryContextType)();class me extends i.PureComponent{ constructor(e,t){super(e,t),this._promise=null,this._menu=i.createRef(),this._favoriteFundamentalsModel=null,this._setActiveState=e=>{this.setState({isActive:e})},this._handleClick=()=>{const{studyMarket:e}=this.props;this.setState({isActive:!0},()=>{e.visible().value()?e.hide():e.show()}),this._trackClick()},this._handleSelectIndicator=e=>{e=(0,J.ensureDefined)(e),this._trackFavoriteAction("Favorite indicator from toolbar");const{chartWidgetCollection:t}=this.context;if("java"===e.type){const t=(0,te.tryFindStudyLineToolNameByStudyId)(e.studyId);if(null!==t)return void ae.tool.setValue(t)}t.activeChartWidget.value().insertStudy(e)},this._handleFavoriteIndicatorsChange=()=>{const{favoriteScriptsModel:e}=this.context,t=[...(0,J.ensureDefined)(e).favorites()];this.setState({favorites:t}),this._clearCache()},this._handleFavoriteFundamentalsChange=()=>{var e;const t=new Set((null===(e=this._favoriteFundamentalsModel)||void 0===e?void 0:e.favorites())||[]);this.setState({favoriteFundamentals:t}),this._clearCache()},this._handleMouseEnter=()=>{this._prefetchFavorites()},this._handleWrapClick=()=>{this._prefetchFavorites()},this._handleChangeActiveWidget=()=>{this._clearCache()},this._clearCache=()=>{this._promise=null,this.setState({infos:[]})},this._handleScriptRenamed=e=>{const{favoriteScriptsModel:t}=this.context;void 0!==t&&t.isFav(e.scriptIdPart)&&this._clearCache()},this._handleFavoriteMenuClick=()=>{this._trackClick(),this._trackFavoriteAction("Select favorite indicators dropdown")},(0,T.validateRegistry)(t,{favoriteScriptsModel:s.any,chartWidgetCollection:s.any.isRequired});const{favoriteScriptsModel:a}=t,n=void 0!==a?a.favorites():[];this.state={isActive:!1,isLoading:!1,favorites:n,favoriteFundamentals:void 0,infos:[]}}componentDidMount(){const{studyMarket:e}=this.props,{favoriteScriptsModel:t,chartWidgetCollection:a}=this.context;e.visible().subscribe(this._setActiveState),void 0!==t&&(t.favoritesChanged().subscribe(this,this._handleFavoriteIndicatorsChange),a.activeChartWidget.subscribe(this._handleChangeActiveWidget)),le.on("TVScriptRenamed",this._handleScriptRenamed,null)}componentWillUnmount(){const{studyMarket:e}=this.props,{favoriteScriptsModel:t,chartWidgetCollection:a}=this.context;e.visible().unsubscribe(this._setActiveState),void 0!==t&&(t.favoritesChanged().unsubscribe(this,this._handleFavoriteIndicatorsChange),a.activeChartWidget.unsubscribe(this._handleChangeActiveWidget)),le.unsubscribe("TVScriptRenamed",this._handleScriptRenamed,null),this._promise=null}render(){const{isActive:e,favorites:t,favoriteFundamentals:a,isLoading:n}=this.state,{className:s,displayMode:l,id:r}=this.props,{chartWidgetCollection:h}=this.context;return i.createElement(i.Fragment,null,i.createElement(b,{id:r,onMouseEnter:this._handleMouseEnter,onClick:this._handleWrapClick},i.createElement(P,{displayMode:l,className:s,icon:re,isOpened:e,onClick:this._handleClick,text:ce.text,title:ce.hint,"data-role":"button","data-name":"open-indicators-dialog","data-tooltip-hotkey":de }),Boolean(t.length>0||(null==a?void 0:a.size))&&i.createElement(f.MatchMedia,{rule:"screen and (max-width: 428px)"},e=>i.createElement(m.ToolWidgetMenu,{key:h.activeChartWidget.value().id(),arrow:!0,closeOnClickOutside:!0,isDrawer:e,drawerPosition:"Bottom",title:ce.favorites,ref:this._menu,onClick:this._handleFavoriteMenuClick,"data-name":"show-favorite-indicators"},i.createElement("div",{className:p()(he.dropdown,e&&he.smallWidthWrapper)},i.createElement(oe.ToolWidgetMenuSummary,{className:e&&he.smallWidthTitle},(0,o.t)("Favorite Indicators")),n&&i.createElement(se,null),!n&&i.createElement(i.Fragment,null,this.state.infos.length>0?this.state.infos.map(t=>i.createElement(u.PopupMenuItem,{className:p()(e&&he.smallWidthMenuItem),theme:e?M.multilineLabelWithIconAndToolboxTheme:void 0,key:"java"===t.item.type?t.item.studyId:t.item.pineId,onClick:this._handleSelectIndicator,onClickArg:t.item,label:i.createElement("span",{className:p()(!e&&he.label,e&&he.smallWidthLabel,"apply-overflow-tooltip")},ve(t))})):null!==this._promise&&i.createElement(u.PopupMenuItem,{isDisabled:!0,label:(0,o.t)("You have no Favorites Indicators yet")})))))))}_prefetchFavorites(){const{chartWidgetCollection:e}=this.context;if(null!==this._promise||!window.is_authenticated)return;const t=e.activeChartWidget.value();if(!t.hasModel())return;const a=t.model().model().studyMetaInfoRepository();this.setState({isLoading:!0});const n=this._promise=Promise.all([ee(this.state.favorites,a),void 0]).then(e=>{if(n!==this._promise)return;const[t,a]=e;let i=[...t];if(a){const e=a.filter(e=>{var t;return null===(t=this.state.favoriteFundamentals)||void 0===t?void 0:t.has(e.scriptIdPart)}).map(this._mapFundamentalToFavoriteItemInfo);i.push(...e)}i=[...i].sort((e,t)=>ve(e).localeCompare(ve(t))),this.setState({infos:i,isLoading:!1},()=>{this._menu.current&&this._menu.current.update()})})}_trackClick(){0}_trackFavoriteAction(e){(0,W.trackEvent)("GUI","Chart Header Toolbar",e)}_mapFundamentalToFavoriteItemInfo(e){return{item:{type:"pine",pineId:e.scriptIdPart},info:{name:e.scriptName,localizedName:getLocalizedFundamentalsName(e),studyMarketShittyObject:void 0}}}}function ve(e){return e.info.localizedName||(0,o.t)(e.info.name,{context:"study"})}me.contextType=ue;var pe=a(9315),ge=a(29823),be=a(87906);function Se(e){return i.createElement("div",{className:v(be.value,{[be.selected]:e.isSelected})},e.value,e.metric)}var Ce=a(50628),_e=a(10381),ye=a(53374),we=a(69698);class fe extends i.PureComponent{constructor(e){super(e),this._timeMenu=null,this._setMenuRef=e=>{this._timeMenu=e},this._handleChangeInput=e=>{const{value:t}=e.currentTarget;/^[0-9]*$/.test(t)&&this.setState({inputValue:t})},this._handleSelectTime=e=>{this.setState({selectedIntervalSuffix:e}),this._closeMenu()},this._handleClickAdd=()=>{const{inputValue:e,selectedIntervalSuffix:t}=this.state;this.props.onAdd(e,t)},this._toggleMenu=()=>{this.state.isOpenedMenu?this._closeMenu():this._openMenu()},this._closeMenu=()=>{this.props.onCloseMenu(),this.setState({isOpenedMenu:!1})},this._openMenu=()=>{ this.props.onOpenMenu(),this.setState({isOpenedMenu:!0})},this._getMenuPosition=()=>{const e=(0,J.ensureNotNull)(this._timeMenu).getBoundingClientRect();return{overrideWidth:e.width,x:e.left,y:e.bottom+1}},this.state={inputValue:"1",isOpenedMenu:!1,selectedIntervalSuffix:ye.INTERVALS[0].name}}render(){const{inputValue:e,isOpenedMenu:t,menuWidth:a,selectedIntervalSuffix:n}=this.state;return i.createElement("div",{className:v(we.form,{[we.interacting]:t})},i.createElement("input",{className:we.input,maxLength:7,onChange:this._handleChangeInput,value:e}),i.createElement("div",{className:we.menu,onClick:this._toggleMenu,ref:this._setMenuRef},ye.INTERVALS.find(e=>e.name===n).label,i.createElement(_e.ToolWidgetCaret,{dropped:t})),i.createElement("div",{className:we.add,onClick:this._handleClickAdd},(0,o.t)("Add")),i.createElement(Ce.PopupMenu,{doNotCloseOn:this,isOpened:t,minWidth:a,onClose:this._closeMenu,position:this._getMenuPosition},ye.INTERVALS.map(e=>i.createElement(u.PopupMenuItem,{dontClosePopup:!0,key:e.name,label:e.label,onClick:this._handleSelectTime,onClickArg:e.name}))))}}var ke=a(96040),Me=a(70412),Te=a(32563),Ee=a(32062);function xe(e){const{interval:t,hint:a,isActive:n,isDisabled:s,isFavorite:o,isSignaling:l,onClick:r,onClickRemove:h,onClickFavorite:d,isSmallTablet:m}=e,v=(0,C.filterDataProps)(e),[g,b]=(0,Me.useHover)(),S=i.useCallback(()=>h(t),[h,t]),_=i.useCallback(()=>d(t),[d,t]),y=(0,i.useRef)(null);return(0,i.useEffect)(()=>{var e;l&&m&&(null===(e=y.current)||void 0===e||e.scrollIntoView())},[l,m]),i.createElement("div",{...b,ref:y},i.createElement(u.PopupMenuItem,{...v,className:p()(m&&Ee.smallWidthMenuItem),theme:m?M.multilineLabelWithIconAndToolboxTheme:void 0,isActive:n,isDisabled:s,isHovered:l,onClick:r,onClickArg:t,toolbox:function(){const{isRemovable:t,isFavoritingAllowed:a}=e,l=i.createElement(ke.RemoveButton,{key:"remove",isActive:n,hidden:!Te.touch&&!g,onClick:S}),r=i.createElement(c.FavoriteButton,{key:"favorite",isActive:n,isFilled:o,onClick:_});return[t&&l,!s&&a&&r]}(),showToolboxOnHover:!o,label:a}))}const Ie={[ge.ResolutionKind.Ticks]:(0,o.t)("Ticks",{context:"interval_group_name"}),[ge.ResolutionKind.Seconds]:(0,o.t)("Seconds",{context:"interval_group_name"}),[ge.ResolutionKind.Minutes]:(0,o.t)("Minutes",{context:"interval_group_name"}),[ge.SpecialResolutionKind.Hours]:(0,o.t)("Hours",{context:"interval_group_name"}),[ge.ResolutionKind.Days]:(0,o.t)("Days",{context:"interval_group_name"}),[ge.ResolutionKind.Weeks]:(0,o.t)("Weeks",{context:"interval_group_name"}),[ge.ResolutionKind.Months]:(0,o.t)("Months",{context:"interval_group_name"}),[ge.ResolutionKind.Range]:(0,o.t)("Ranges",{context:"interval_group_name"}),[ge.ResolutionKind.Invalid]:""};function Ae(e,t=!1){return{id:e,name:Ie[e],items:[],mayOmitSeparator:t}}var Re=a(26005),Fe=a(2872),Ne=a.n(Fe),He=a(29197),ze=a(59064),Pe=a(6500);const We={openDialog:(0,o.t)("Open Interval Dialog"),timeInterval:(0,o.t)("Time Interval")},De=(0,G.hotKeySerialize)({keys:[","],text:(0,o.t)("Number or {hotKey_0}")}),Le=(0, T.registryContextType)(),Oe=new(Ne()),Ue=i.lazy(async()=>({default:(await Promise.all([a.e(2888),a.e(4956),a.e(8463),a.e(9289),a.e(7962),a.e(8986),a.e(3848),a.e(1692),a.e(7345),a.e(5643),a.e(1e3),a.e(2947),a.e(2502),a.e(4013)]).then(a.bind(a,21317))).ToolWidgetIntervalsAddDialog}));function Be(e){{const t=ge.Interval.parse(e);if(!(0,pe.isSecondsEnabled)()&&t.isSeconds())return!1;if(!(0,pe.isTicksEnabled)()&&t.isTicks())return!1}return!0}class Ve extends i.PureComponent{constructor(e,t){super(e,t),this._menu=i.createRef(),this._renderChildren=(e,t)=>[...this._createMenuItems(e,t),...this._createIntervalForm(t)],this._handleChangeInterval=e=>{const{activeInterval:t,lastNotQuicked:a}=this.state,n=this._getQuicks();this.setState({activeInterval:(0,pe.normalizeIntervalString)(e),lastNotQuicked:void 0===t||n.includes(t)?a:t})},this._bindedForceUpdate=()=>{this.forceUpdate()},this._handleCloseMenu=()=>{this.setState({isOpenedFormMenu:!1})},this._handleOpenMenu=()=>{this.setState({isOpenedFormMenu:!0})},this._handleSelectInterval=e=>{void 0!==e&&e!==l.linking.interval.value()&&this.context.chartWidgetCollection.setResolution(e),e&&(0,W.trackEvent)("GUI","Time Interval",e)},this._handleClickFavorite=e=>{e=(0,J.ensureDefined)(e),this._isIntervalFavorite(e)?this._handleRemoveFavorite(e):this._handleAddFavorite(e)},this._handleAddFavorite=e=>{const{favorites:t}=this.state;this.context.favoriteIntervalsService.set([...t,e])},this._handleRemoveFavorite=e=>{const{favorites:t}=this.state;this.context.favoriteIntervalsService.set(t.filter(t=>t!==e))},this._handleAddInterval=(e,t)=>{const{intervalService:a}=this.context,n=a.add(e,t);n&&this.setState({lastAddedInterval:n})},this._handleRemoveInterval=e=>{const{intervalService:t}=this.context;e&&(t.remove(e),this._handleRemoveFavorite(e))},this._getHandleSectionStateChange=e=>t=>{const{menuViewState:a}=this.state,{intervalsMenuViewStateService:n}=this.context;n.set({...a,[e]:!t})},this._handleOpenAddIntervalDialog=()=>{this.setState({isAddIntervalDialogOpened:!0})},this._handleCloseAddIntervalDialog=()=>{this.setState({isAddIntervalDialogOpened:!1})},this._handleGlobalClose=()=>{const{isFake:e}=this.props,{isAddIntervalDialogOpened:t}=this.state;e||t||Oe.fire()},this._handeQuickClick=e=>{this._handleSelectInterval(e),this._trackClick()},(0,T.validateRegistry)(t,{chartApiInstance:s.any.isRequired,favoriteIntervalsService:s.any.isRequired,intervalService:s.any.isRequired,intervalsMenuViewStateService:s.any.isRequired});const{chartApiInstance:a,favoriteIntervalsService:o,intervalService:r,intervalsMenuViewStateService:h}=t;this._customIntervals=n.enabled("custom_resolutions");const c=l.linking.interval.value(),d=c&&(0,pe.normalizeIntervalString)(c),u=o.get(),m=r.getCustomIntervals(),v=h.get();this._defaultIntervals=a.defaultResolutions().filter(Be).map(pe.normalizeIntervalString),this.state={isOpenedFormMenu:!1,activeInterval:d,favorites:u,customs:m,menuViewState:v,isAddIntervalDialogOpened:!1}}componentDidMount(){ const{favoriteIntervalsService:e,intervalService:t,intervalsMenuViewStateService:a}=this.context;e.getOnChange().subscribe(this,this._handleChangeFavorites),a.getOnChange().subscribe(this,this._handleChangeMenuViewState),t.getOnChange().subscribe(this,this._handleChangeCustoms),l.linking.interval.subscribe(this._handleChangeInterval),l.linking.intraday.subscribe(this._bindedForceUpdate),l.linking.seconds.subscribe(this._bindedForceUpdate),l.linking.ticks.subscribe(this._bindedForceUpdate),l.linking.range.subscribe(this._bindedForceUpdate),l.linking.supportedResolutions.subscribe(this._bindedForceUpdate),ze.globalCloseDelegate.subscribe(this,this._handleGlobalClose)}componentWillUnmount(){const{favoriteIntervalsService:e,intervalService:t,intervalsMenuViewStateService:a}=this.context;e.getOnChange().unsubscribe(this,this._handleChangeFavorites),a.getOnChange().unsubscribe(this,this._handleChangeMenuViewState),t.getOnChange().unsubscribe(this,this._handleChangeCustoms),l.linking.interval.unsubscribe(this._handleChangeInterval),l.linking.intraday.unsubscribe(this._bindedForceUpdate),l.linking.seconds.unsubscribe(this._bindedForceUpdate),l.linking.ticks.unsubscribe(this._bindedForceUpdate),l.linking.range.unsubscribe(this._bindedForceUpdate),l.linking.supportedResolutions.unsubscribe(this._bindedForceUpdate),ze.globalCloseDelegate.unsubscribe(this,this._handleGlobalClose)}componentDidUpdate(e,t){this.state.lastAddedInterval&&setTimeout(()=>this.setState({lastAddedInterval:void 0}),400)}render(){const{isShownQuicks:e,id:t}=this.props,{activeInterval:a,customs:n,lastNotQuicked:s,isAddIntervalDialogOpened:o}=this.state,l=this._getQuicks(),r=(0,pe.sortResolutions)([...l]);void 0!==a&&r.includes(a)?void 0!==s&&r.push(s):void 0!==a&&r.push(a);const h=(!(!e||0===l.length)||void 0)&&r.length>1,c={},d=(0,pe.mergeResolutions)(this._defaultIntervals,n);(void 0!==a?d.concat(a):d).filter(pe.isAvailable).forEach(e=>c[e]=!0);const u=void 0!==a?(0,pe.getTranslatedResolutionModel)(a):null;return i.createElement(b,{id:t},h&&r.map((e,t)=>{const n=(0,pe.getTranslatedResolutionModel)(e);return i.createElement(y,{key:t,className:v(Pe.button,{[Pe.first]:0===t,[Pe.last]:t===r.length-1,[Pe.newStyles]:D.hasNewHeaderToolbarStyles}),text:i.createElement(Se,{value:n.mayOmitMultiplier?void 0:n.multiplier,metric:n.shortKind}),hint:n.hint,isActive:a===e,isDisabled:!c[e]&&e!==s,onClick:this._handeQuickClick,onClickArg:e,"data-value":e})}),i.createElement(f.MatchMedia,{rule:k.DialogBreakpoints.TabletSmall},e=>i.createElement(i.Fragment,null,i.createElement(He.CloseDelegateContext.Provider,{value:Oe},i.createElement(m.ToolWidgetMenu,{arrow:Boolean(h),closeOnClickOutside:!0,content:h||null===u?void 0:i.createElement(b,{className:Pe.menuContent},i.createElement(Se,{value:u.mayOmitMultiplier?void 0:u.multiplier,metric:u.shortKind})),title:h||null===u?We.timeInterval:u.hint,hotKey:h?De:void 0,className:Pe.menu,ref:this._menu,isDrawer:e,onClick:this._trackClick},i.createElement("div",{className:Pe.dropdown },this._renderChildren(d,e)))),e&&o&&i.createElement(i.Suspense,{fallback:null},i.createElement(Ue,{onAdd:this._handleAddInterval,onClose:this._handleCloseAddIntervalDialog,onUnmount:this._handleCloseAddIntervalDialog})))))}_createMenuItems(e,t){const a=function(e){const t=Ae(ge.ResolutionKind.Ticks),a=Ae(ge.ResolutionKind.Seconds),n=Ae(ge.ResolutionKind.Minutes),i=Ae(ge.SpecialResolutionKind.Hours),s=Ae(ge.ResolutionKind.Days),o=Ae(ge.ResolutionKind.Range);return e.forEach(e=>{const l=ge.Interval.parse(e);l.isMinuteHours()?i.items.push(e):l.isMinutes()?(0,ge.isHour)(Number(l.multiplier()))?i.items.push(e):n.items.push(e):l.isSeconds()?a.items.push(e):l.isDWM()?s.items.push(e):l.isRange()?o.items.push(e):l.isTicks()&&t.items.push(e)}),[t,a,n,i,s,o].filter(e=>0!==e.items.length)}(e).map((e,a,n)=>this._renderResolutionsGroup(e,1===n.length,t));return function(e){let t=!1;return e.filter((e,a,n)=>{let i=!0;return e.type===w.PopupMenuSeparator&&(0!==a&&a!==n.length-1||(i=!1),t&&(i=!1)),t=e.type===w.PopupMenuSeparator,i})}([].concat(...a))}_createIntervalForm(e){if(this._customIntervals){const t=e?i.createElement("div",{key:"add-dialog",className:Pe.addCustomInterval,onClick:this._handleOpenAddIntervalDialog},(0,o.t)("Add custom interval")+"…"):i.createElement(fe,{key:"add-form",onAdd:this._handleAddInterval,onCloseMenu:this._handleCloseMenu,onOpenMenu:this._handleOpenMenu});return[i.createElement(w.PopupMenuSeparator,{key:"custom-interval-separator"}),t]}return[]}_renderResolutionsGroup(e,t=!1,a){const n=[],s=e.items.map(e=>this._renderPopupMenuItem(e,a));if(t)n.push(...s);else if(a){const t=i.createElement("div",{key:e.id},i.createElement("div",{className:Pe.smallTabletSectionTitle},e.name),s);n.push(t)}else{const{intervalsMenuViewStateService:t}=this.context,{menuViewState:a}=this.state;if(!t.isAllowed(e.id))return[];const o=i.createElement(Re.CollapsibleSection,{key:e.id,className:Pe.section,summary:e.name,open:!a[e.id],onStateChange:this._getHandleSectionStateChange(e.id)},s);n.push(o)}return(!e.mayOmitSeparator||e.items.length>1)&&(n.unshift(i.createElement(w.PopupMenuSeparator,{key:"begin-"+e.name})),n.push(i.createElement(w.PopupMenuSeparator,{key:"end-"+e.name}))),n}_handleChangeFavorites(e){this.setState({lastNotQuicked:void 0,favorites:e})}_handleChangeCustoms(e){this.setState({customs:e})}_handleChangeMenuViewState(e){this.setState({menuViewState:e},()=>{this._menu.current&&this._menu.current.update()})}_renderPopupMenuItem(e,t){const{isFavoritingAllowed:a}=this.props,{activeInterval:n,lastAddedInterval:s}=this.state,o=e===n,l=(0,pe.isAvailable)(e),r=this._isIntervalFavorite(e),h=this._isIntervalDefault(e),c=(0,pe.getTranslatedResolutionModel)(e);return i.createElement(xe,{key:e,isSmallTablet:t,interval:e,hint:c.hint,isSignaling:s===e,isFavoritingAllowed:a,isDisabled:!l,isFavorite:r,isRemovable:!h,isActive:o,onClick:this._handleSelectInterval,onClickRemove:this._handleRemoveInterval,onClickFavorite:this._handleClickFavorite,"data-value":e})}_isIntervalDefault(e){return this._defaultIntervals.includes(e)} _isIntervalFavorite(e){return this.state.favorites.includes(e)}_getQuicks(e){return this.props.isShownQuicks&&"small"!==this.props.displayMode?void 0===e?this.state.favorites:e:[]}_trackClick(){0}}Ve.contextType=Le;var Ge=a(76521),Ze=a(74034);const Ye={hint:(0,o.t)("Open chart in popup")},qe=(0,T.registryContextType)();class Ke extends i.PureComponent{constructor(e,t){super(e,t),this._handleClick=()=>{const{chartWidgetCollection:e,windowMessageService:t,isFundamental:a}=this.context,n=e.activeChartWidget.value();n.withModel(null,()=>{t.post(parent,"openChartInPopup",{symbol:n.model().mainSeries().actualSymbol(),interval:n.model().mainSeries().interval(),fundamental:a})})},(0,T.validateRegistry)(t,{isFundamental:s.any,chartWidgetCollection:s.any.isRequired,windowMessageService:s.any.isRequired})}render(){const{className:e}=this.props;return i.createElement(V.ToolWidgetIconButton,{className:v(e,Ge.button),icon:Ze,onClick:this._handleClick,title:Ye.hint})}}Ke.contextType=qe;var Qe=a(28289);const je={hint:(0,o.t)("Chart settings")},Xe=(0,T.registryContextType)();class Je extends i.PureComponent{constructor(e,t){super(e,t),this._handleClick=()=>{const{chartWidgetCollection:e}=this.context,t=e.activeChartWidget.value();(0,W.trackEvent)("GUI","Chart Header Toolbar","chart properties"),t.showGeneralChartProperties()},(0,T.validateRegistry)(t,{chartWidgetCollection:s.any.isRequired})}render(){return i.createElement(V.ToolWidgetIconButton,{...this.props,icon:Qe,title:je.hint,onClick:this._handleClick})}}Je.contextType=Xe;var $e=a(25760),et=a(59199),tt=a(68587),at=a(49473);const nt="M21.5 21.5h-14a5 5 0 1 1 .42-9.983 7.5 7.5 0 0 1 14.57 2.106 4.002 4.002 0 0 1-.99 7.877z",it=13.08991081237793,st={strokeDashOffset:49.242997817993164,strokeDash:49.866326904296876,strokeGap:it,strokeDashCheck:0},ot={strokeDashOffset:62.956237716674806,strokeGap:0,strokeDash:62.956237716674806,strokeDashCheck:200};class lt extends i.PureComponent{constructor(e){super(e),this.state=st}componentDidMount(){"saved"===this.props.state?this.setState(ot):this._goToNextState(this.props.state)}componentWillUnmount(){this._currentAnimation=void 0}UNSAFE_componentWillReceiveProps(e){this.props.state!==e.state&&this._goToNextState(e.state)}render(){const{strokeDashOffset:e,strokeDash:t,strokeGap:a,strokeDashCheck:n}=this.state,{className:s,size:o,onClick:l,state:r,isHovered:h=!1}=this.props,c=v(at.container,s,h&&at.hovered,{[at.unsaved]:"unsaved"===r,[at.saving]:"saving"===r,[at.saved]:"saved"===r});return i.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:c,version:"1.1",width:o,height:o,viewBox:"0 0 28 28",onClick:l},i.createElement("g",{fill:"none"},i.createElement("path",{className:at.dottedCloud,stroke:"currentColor",strokeDasharray:"3.5,2.5",d:nt}),i.createElement("path",{className:at.spinningCloud,stroke:"currentColor",strokeDasharray:`${t} ${a}`,strokeDashoffset:e,d:nt}),i.createElement("path",{className:at.arrowGap,d:"M11 20h6v5h-6z"}),i.createElement("g",{className:at.arrow,stroke:"currentColor"},i.createElement("path",{ strokeLinecap:"square",d:"M14.5 14.5v10"}),i.createElement("path",{d:"M11 17l3.5-3.5L18 17"})),i.createElement("g",{className:at.check,stroke:"currentColor"},i.createElement("path",{strokeDasharray:`${n}% ${200-n}%`,d:"M10 15l2.5 2.5L18 12"}))))}_goToNextState(e){switch(e){case"unsaved":this.setState(st);break;case"saving":"unsaved"!==this.props.state&&this.setState(st),this._currentAnimation=Promise.resolve(this._currentAnimation).then(()=>this._createSpinAnimationWhile(()=>"saving"===this.props.state));break;case"saved":this._currentAnimation=Promise.resolve(this._currentAnimation).then(this._createFillGapAnimation.bind(this)).then(this._createCheckAnimation.bind(this))}}_createSpinAnimationWhile(e){return this._createSpinAnimation().then(()=>e()?this._createSpinAnimationWhile(e):Promise.resolve())}_createSpinAnimation(){return new Promise(e=>{(0,et.doAnimate)({onStep:(e,t)=>{void 0!==this._currentAnimation&&this.setState({strokeDashOffset:t})},onComplete:()=>e(),from:49.242997817993164,to:111.57590644836426,easing:tt.easingFunc.linear,duration:1e3})})}_createCheckAnimation(){return new Promise(e=>{(0,et.doAnimate)({onStep:(e,t)=>{void 0!==this._currentAnimation&&this.setState({strokeDashCheck:Math.round(t)})},onComplete:()=>e(),from:0,to:200,easing:tt.easingFunc.linear,duration:1e3})})}_createFillGapAnimation(){return new Promise(e=>{(0,et.doAnimate)({onStep:(e,t)=>{void 0!==this._currentAnimation&&this.setState({strokeDashOffset:62.956237716674806-t,strokeGap:t,strokeDash:62.956237716674806-t})},onComplete:()=>e(),from:it,to:0,easing:tt.easingFunc.linear,duration:200})})}}var rt=a(40173),ht=a(59918),ct=a(28857);(0,rt.mergeThemes)(ht.DEFAULT_MENU_ITEM_SWITCHER_THEME,ct);var dt=a(82724),ut=a(16788),mt=a(96141),vt=a(4050);a(31405);const pt=n.enabled("widget"),gt=(0,rt.mergeThemes)(S.DEFAULT_TOOL_WIDGET_BUTTON_THEME,vt),bt=(0,rt.mergeThemes)(u.DEFAULT_POPUP_MENU_ITEM_THEME,{shortcut:mt.shortcut}),St={copy:(0,o.t)("Copy"),makeCopy:(0,o.t)("Make a Copy"),newChartLayout:(0,o.t)("New Chart Layout"),loadChartLayout:(0,dt.appendEllipsis)((0,o.t)("Load Chart Layout")),rename:(0,dt.appendEllipsis)((0,o.t)("Rename")),renameChartLayout:(0,o.t)("Rename Chart Layout"),saveAs:(0,dt.appendEllipsis)((0,o.t)("Make a Copy")),saveChartLayout:(0,o.t)("Save"),saveChartLayoutLong:(0,o.t)("Save all charts for all symbols and intervals on your layout"),manageChartLayouts:(0,o.t)("Manage Chart Layouts")},Ct=[],_t=(0,G.hotKeySerialize)({keys:[(0,Z.humanReadableModifiers)(Z.Modifiers.Mod,!1),"S"],text:"{0} + {1}"});class yt extends i.PureComponent{constructor(e){super(e),this._handleSaveHoverBegin=()=>{this.setState({iconHovered:!0})},this._handleSaveHoverEnd=()=>{this.setState({iconHovered:!1})},this._handleCloneClick=()=>{var e,t;null===(t=(e=this.props).onCloneChart)||void 0===t||t.call(e),this._trackClick()},this._handleSaveClick=()=>{var e,t;null===(t=(e=this.props).onSaveChart)||void 0===t||t.call(e),this._trackClick()},this.state={iconHovered:!1}}render(){ const{id:e,isReadOnly:t,displayMode:a,isProcessing:n,title:s,chartId:o,wasChanges:l,hideMenu:r,isTabletSmall:h,dataNameSaveMenu:c}=this.props,{iconHovered:u}=this.state,p=!t&&!r;let g="saved";return!l&&s||(g="unsaved"),n&&(g="saving"),i.createElement(b,null,t?i.createElement(b,null,i.createElement(P,{id:e,displayMode:a,icon:i.createElement(d.Icon,{icon:ut}),isDisabled:n,onClick:this._handleCloneClick,text:St.copy,title:St.makeCopy,onMouseEnter:this._handleSaveHoverBegin,onMouseLeave:this._handleSaveHoverEnd,collapseWhen:Ct})):i.createElement(b,null,i.createElement(P,{id:e,className:v(mt.button,p&&mt.buttonSmallPadding),displayMode:a,icon:i.createElement(lt,{size:28,state:g,isHovered:u}),isDisabled:o&&!l||n,onClick:this._handleSaveClick,text:s||St.saveChartLayout,title:St.saveChartLayoutLong,onMouseEnter:this._handleSaveHoverBegin,onMouseLeave:this._handleSaveHoverEnd,theme:gt,collapseWhen:Ct,"data-tooltip-hotkey":pt?"":_t}),p&&i.createElement(m.ToolWidgetMenu,{"data-name":c,className:"js-save-load-menu-open-button",arrow:!0,isDrawer:h,drawerPosition:"Bottom",title:St.manageChartLayouts,onClick:this._trackClick},this._renderMenuItems(Boolean(h)))))}_renderMenuItems(e){const{wasChanges:t,isProcessing:a,chartId:n,onSaveChartFromMenu:s,onRenameChart:l,onSaveAsChart:r,onLoadChart:h,onNewChart:c,isAutoSaveEnabled:d,autoSaveId:m,sharingId:p,onAutoSaveChanged:g,isSharingEnabled:b,onSharingChanged:S}=this.props,C=e?M.multilineLabelWithIconAndToolboxTheme:bt,_=e?void 0:(0,Z.humanReadableHash)(Z.Modifiers.Mod+83),y=e?void 0:(0,o.t)("Dot",{context:"hotkey"}),f=[];return f.push(i.createElement(u.PopupMenuItem,{key:"save",isDisabled:Boolean(a||!t&&n),label:St.saveChartLayout,onClick:s,shortcut:_,labelRowClassName:v(e&&mt.popupItemRowTabletSmall),theme:C,"data-name":"save-load-menu-item-save"})),void 0!==n&&(e||f.push(i.createElement(w.PopupMenuSeparator,{key:"existing-chart-section-begin"})),f.push(i.createElement(u.PopupMenuItem,{key:"rename",label:St.rename,onClick:l,labelRowClassName:v(e&&mt.popupItemRowTabletSmall),theme:C,"data-name":"save-load-menu-item-rename"}),i.createElement(u.PopupMenuItem,{key:"save-as",label:St.saveAs,onClick:r,labelRowClassName:v(e&&mt.popupItemRowTabletSmall),theme:C,"data-name":"save-load-menu-item-clone"}))),f.push(i.createElement(w.PopupMenuSeparator,{key:"platform-section-begin"})),f.push(i.createElement(u.PopupMenuItem,{key:"load-chart",className:"js-save-load-menu-item-load-chart",label:St.loadChartLayout,onClick:h,labelRowClassName:v(e&&mt.popupItemRowTabletSmall),theme:C,shortcut:y,"data-name":"save-load-menu-item-load"})),f}_trackClick(){0}}const wt=(0,T.registryContextType)();class ft extends i.PureComponent{constructor(e,t){super(e,t),this._syncState=e=>{this.setState(e)},this._onChangeHasChanges=e=>{this.state.wasChanges!==e&&this.setState({wasChanges:e})},this._onChangeAutoSaveEnabled=e=>{0},this._onChangeSharingEnabled=e=>{this.setState({isSharingEnabled:e})},this._onChangeTitle=e=>{this.setState({title:e})},this._onChangeId=e=>{this.setState({id:e})},this._onChartAboutToBeSaved=()=>{ this.setState({isProcessing:!0})},this._onChartSaved=()=>{this.setState({isProcessing:!1})},this._handleAutoSaveEnabled=e=>{0},this._handleSharingEnabled=e=>{0},this._handleClickSave=()=>{this.context.saveChartService.saveChartOrShowTitleDialog(),this._trackEvent("Save click")},this._handleClickSaveFromMenu=()=>{this.context.saveChartService.saveChartOrShowTitleDialog(),this._trackEvent("Save From Menu")},this._handleClickClone=()=>{this.context.saveChartService.cloneChart()},this._handleClickSaveAs=()=>{this.context.saveChartService.saveChartAs(),this._trackEvent("Make a copy")},this._handleClickNew=()=>{this._trackEvent("New chart layout")},this._handleClickLoad=()=>{this.context.loadChartService.showLoadDialog(),this._trackEvent("Load chart layout")},this._handleHotkey=()=>{this.context.loadChartService.showLoadDialog()},this._handleClickRename=()=>{this.context.saveChartService.renameChart(),this._trackEvent("Rename")},(0,T.validateRegistry)(t,{chartWidgetCollection:s.any.isRequired,chartChangesWatcher:s.any.isRequired,saveChartService:s.any.isRequired,sharingChartService:s.any,loadChartService:s.any.isRequired});const{chartWidgetCollection:a,chartChangesWatcher:n,saveChartService:i,sharingChartService:o}=t;this.state={isAuthenticated:window.is_authenticated,isProcessing:!1,id:a.metaInfo.id.value(),title:a.metaInfo.name.value(),wasChanges:n.hasChanges(),iconHovered:!1}}componentDidMount(){const{chartSaver:e,isFake:t,stateSyncEmitter:a}=this.props,{chartWidgetCollection:n,chartChangesWatcher:i,saveChartService:s,sharingChartService:l}=this.context;t?a.on("change",this._syncState):(i.getOnChange().subscribe(this,this._onChangeHasChanges),n.metaInfo.name.subscribe(this._onChangeTitle),n.metaInfo.id.subscribe(this._onChangeId),this._hotkeys=(0,$e.createGroup)({desc:"Save/Load"}),this._hotkeys.add({desc:(0,o.t)("Load Chart Layout"),handler:this._handleHotkey,hotkey:190}),e.chartSaved().subscribe(this,this._onChartSaved),e.chartAboutToBeSaved().subscribe(this,this._onChartAboutToBeSaved),window.loginStateChange.subscribe(this,this._onLoginStateChange))}componentDidUpdate(e,t){this.props.isFake||t!==this.state&&this.props.stateSyncEmitter.emit("change",this.state)}componentWillUnmount(){const{chartSaver:e,isFake:t,stateSyncEmitter:a}=this.props,{chartWidgetCollection:n,chartChangesWatcher:i,saveChartService:s,sharingChartService:o}=this.context;t?a.off("change",this._syncState):(i.getOnChange().unsubscribe(this,this._onChangeHasChanges),n.metaInfo.name.unsubscribe(this._onChangeTitle),n.metaInfo.id.unsubscribe(this._onChangeId),(0,J.ensureDefined)(this._hotkeys).destroy(),e.chartSaved().unsubscribe(this,this._onChartSaved),e.chartAboutToBeSaved().unsubscribe(this,this._onChartAboutToBeSaved),window.loginStateChange.unsubscribe(this,this._onLoginStateChange))}render(){const{isReadOnly:e,displayMode:t,id:a,isFake:n}=this.props,{isProcessing:s,isAuthenticated:o,title:l,id:r,wasChanges:h,isAutoSaveEnabled:c,isSharingEnabled:d}=this.state,u={displayMode:t,isReadOnly:e,isAuthenticated:o,isProcessing:s,wasChanges:h,title:l, id:a,chartId:null!==r?r:void 0,dataNameSaveMenu:n?void 0:"save-load-menu",onCloneChart:this._handleClickClone,onSaveChart:this._handleClickSave,onSaveChartFromMenu:this._handleClickSaveFromMenu,onRenameChart:this._handleClickRename,onSaveAsChart:this._handleClickSaveAs,onLoadChart:this._handleClickLoad};return i.createElement(f.MatchMedia,{rule:k.DialogBreakpoints.TabletSmall},e=>i.createElement(yt,{...u,isTabletSmall:e}))}_onLoginStateChange(){this.setState({isAuthenticated:window.is_authenticated})}_trackEvent(e){0}}ft.contextType=wt;var kt=a(20301),Mt=a(95792),Tt=a(82029);const Et=new Mt.DateTimeFormatter({dateTimeSeparator:"_",timeFormat:"%h-%m-%s"}),xt={takeSnapshot:(0,o.t)("Take a snapshot")},It=(0,T.registryContextType)();const At=o.t("Loading...");function Rt(e,t,a){return async function(e,t,a){const n=URL.createObjectURL(new Blob([`${At}`],{type:"text/html"}));try{const i=open(n,t,a);if(!i)throw new Error("cound not open a new tab");const s=await e.catch(()=>{});void 0!==s?i.location.replace(s):i.close()}finally{URL.revokeObjectURL(n)}}(e,t,a)}var Ft=a(65446),Nt=a(58455),Ht=a(91887);function zt(e){const t=v(e.isLoading&&Ht.hidden),a=v(!e.isLoading&&Ht.hidden);return i.createElement("div",null,i.createElement("span",{className:t},e.children),i.createElement("span",{className:a},i.createElement(ne.Loader,null)))}var Pt=a(76974),Wt=a(60498),Dt=a(17191),Lt=a(37402),Ot=a(50377),Ut=a(86149),Bt=a(75492);const Vt=(0,rt.mergeThemes)(u.DEFAULT_POPUP_MENU_ITEM_THEME,Bt);function Gt(e){const{serverSnapshot:t,clientSnapshot:n}=e,[s,l]=(0,i.useState)(!1),[r,h]=(0,i.useState)(!1),[c,d]=(0,i.useState)(!1),m=(0,Pt.useIsMounted)(),p=(0,i.useCallback)(async()=>{var e;const t=n(),a=t.then(e=>new Promise(t=>e.canvas.toBlob(e=>{null!==e&&t(e)})));try{await(0,Ft.writePromiseUsingApi)(a,"image/png"),le.emit("onClientScreenshotCopiedToClipboard")}catch(a){const{canvas:n}=await t;null===(e=window.open())||void 0===e||e.document.write(``)}},[n]),g=(0,i.useCallback)(async()=>{const e=await n(),t=await function(e){return new Promise(t=>{try{e.canvas.toBlob(e=>{if(null===e)throw new Error("Unable to generate blob");t(URL.createObjectURL(e))})}catch(a){t(e.canvas.toDataURL())}})}(e);t&&(0,Nt.downloadFile)(e.name+".png",t)},[n]),b=e=>Rt(e.then(e=>e.imageUrl)),S=(0,i.useCallback)(async(e=!1)=>{const a=t();try{if(e)await b(a);else{const e=a.then(e=>new Blob([e.imageUrl],{type:"text/plain"}));await(0,Ft.writePromiseUsingApi)(e,"text/plain"),le.emit("onServerScreenshotCopiedToClipboard")}return!0}catch(e){return b(a),!0}finally{m.current&&(h(!1),l(!1),(0,ze.globalCloseMenu)())}},[t]),C=(0,i.useCallback)(async()=>{d(!0);const[e,n]=await Promise.all([a.e(4665).then(a.bind(a,2679)),t()]);e.Twitter.shareSnapshotInstantly(n.symbol,n.imageUrl), m.current&&(d(!1),(0,ze.globalCloseMenu)())},[t]);return i.createElement(i.Fragment,null,i.createElement(u.PopupMenuItem,{"data-name":"save-chart-image",label:(0,o.t)("Save chart image"),icon:Lt,onClick:g,shortcut:(0,Z.humanReadableHash)(Z.Modifiers.Mod+Z.Modifiers.Alt+83),theme:Vt}),i.createElement(u.PopupMenuItem,{"data-name":"copy-chart-image",label:(0,o.t)("Copy chart image"),icon:Dt,onClick:p,shortcut:(0,Z.humanReadableHash)(Z.Modifiers.Mod+Z.Modifiers.Shift+83),theme:Vt}),i.createElement(u.PopupMenuItem,{"data-name":"copy-link-to-the-chart-image",label:i.createElement(zt,{isLoading:s},(0,o.t)("Copy link to the chart image")),icon:Ot,onClick:()=>{l(!0),S(!1)},dontClosePopup:!0,isDisabled:s,shortcut:(0,Z.humanReadableHash)(Z.Modifiers.Alt+83),className:v(s&&Bt.loading),theme:Vt}),i.createElement(u.PopupMenuItem,{"data-name":"open-image-in-new-tab",label:i.createElement(zt,{isLoading:r},(0,o.t)("Open image in new tab")),icon:Ut,onClick:()=>{h(!0),S(!0)},dontClosePopup:!0,isDisabled:r,className:v(r&&Bt.loading),theme:Vt}),i.createElement(u.PopupMenuItem,{"data-name":"tweet-chart-image",label:i.createElement(zt,{isLoading:c},(0,o.t)("Tweet chart image")),icon:Wt,onClick:C,dontClosePopup:!0,isDisabled:c,className:v(c&&Bt.loading),theme:Vt}))}var Zt=a(84015);function Yt(e){const[t,a]=(0,i.useState)(!1),n=(0,Pt.useIsMounted)(),s=(0,i.useCallback)(async()=>{a(!0),await e.serverSnapshot(),n.current&&a(!1)},[e.serverSnapshot]);return i.createElement(S.ToolWidgetButton,{id:e.id,className:e.className,isDisabled:t,onClick:s,title:e.tooltip,icon:e.icon})}var qt=a(62346);const Kt=(Qt=function(e){return(0,Zt.isOnMobileAppPage)("any")?i.createElement(Yt,{...e,icon:qt}):i.createElement(m.ToolWidgetMenu,{content:i.createElement(S.ToolWidgetButton,{id:e.id,className:e.className,title:e.tooltip,icon:qt}),drawerPosition:"Bottom",drawerBreakpoint:k.DialogBreakpoints.TabletSmall,arrow:!1,onClick:function(){}},i.createElement(Gt,{...e}))},(jt=class extends i.PureComponent{constructor(e,t){super(e,t),this._clientSnapshot=async()=>{const e=this.context.chartWidgetCollection.activeChartWidget.value().model().mainSeries().actualSymbol();return{canvas:await this.context.chartWidgetCollection.clientSnapshot(),name:`${(0,Tt.shortName)(e)}_${Et.formatLocal(new Date)}`}},this._serverSnapshot=async()=>{const e=this.context.chartWidgetCollection.activeChartWidget.value().model().mainSeries().actualSymbol(),t=await this.context.chartWidgetCollection.takeScreenshot(),a=n.enabled("charting_library_base")&&void 0!==this.context.snapshotUrl?t:(0,kt.convertImageNameToUrl)(t);return{symbol:(0,Tt.shortName)(e),imageUrl:a}},(0,T.validateRegistry)(t,{chartWidgetCollection:s.any.isRequired})}render(){const{className:e,id:t}=this.props;return i.createElement(Qt,{id:t,className:e,tooltip:xt.takeSnapshot,serverSnapshot:this._serverSnapshot,clientSnapshot:this._clientSnapshot})}}).contextType=It,jt);var Qt,jt,Xt=a(38318),Jt=a(39362),$t=a(11181);class ea{async show(e){if(null!==ea._provider){const e=await ea._provider.getSymbol() ;return l.linking.symbol.setValue(e.symbol),e}if(ea._currentShowingInstance)throw new DOMException("SymbolSearchUI is already shown","InvalidStateError");try{ea._currentShowingInstance=this,ea.preload();const t=await ea._implementation;return(0,J.assert)(null!==t),new Promise(a=>{t.showDefaultSearchDialog({...e,onSearchComplete:e=>{a({symbol:e})}})})}finally{ea._currentShowingInstance=null}}static setProvider(e){this._provider=e}static preload(){null===this._provider&&null===this._implementation&&(this._implementation=(0,$t.loadNewSymbolSearch)())}}ea._currentShowingInstance=null,ea._provider=null,ea._implementation=null;var ta=a(67397),aa=a(72597);const na=(0,rt.mergeThemes)(S.DEFAULT_TOOL_WIDGET_BUTTON_THEME,ta);(0,rt.mergeThemes)(na,aa);class ia extends i.PureComponent{constructor(e){super(e),this._openSymbolSearchDialog=async e=>{if((0,Z.modifiersFromEvent)(e)!==Z.Modifiers.Alt)try{(0,W.trackEvent)("GUI","SS","main search"),await(new ea).show({defaultValue:this._isSpread(this.state.symbol)?this.state.symbol:this.state.shortName,showSpreadActions:(0,Xt.canShowSpreadActions)()&&this.props.isActionsVisible,source:"searchBar",footer:Te.mobiletouch?void 0:i.createElement(Jt.SymbolSearchDialogFooter,null,(0,o.t)("Simply start typing while on the chart to pull up this search box"))})}catch(e){}else navigator.clipboard.writeText(this.state.symbol)},this._isSpread=e=>!1,this._onSymbolChanged=()=>{const e=l.linking.symbol.value();this.setState({symbol:e,shortName:sa()})},this.state={symbol:l.linking.symbol.value(),shortName:sa()}}componentDidMount(){l.linking.symbol.subscribe(this._onSymbolChanged),l.linking.seriesShortSymbol.subscribe(this._onSymbolChanged),ea.preload()}componentWillUnmount(){l.linking.symbol.unsubscribe(this._onSymbolChanged),l.linking.seriesShortSymbol.unsubscribe(this._onSymbolChanged)}render(){const{id:e,className:t}=this.props;return i.createElement(S.ToolWidgetButton,{id:e,className:p()(t,n.enabled("uppercase_instrument_names")&&ta.uppercase,ta.largeLeftPadding),theme:na,icon:void 0,text:this.state.shortName,title:(0,o.t)("Symbol Search"),onClick:this._openSymbolSearchDialog})}async _updateQuotes(e){}}function sa(){return l.linking.seriesShortSymbol.value()||l.linking.symbol.value()||""}var oa=a(52157);class la extends i.PureComponent{constructor(){super(...arguments),this._handleClick=e=>{e.stopPropagation();const{onApply:t,item:a}=this.props;t(a)}}render(){const{className:e,item:t}=this.props;return i.createElement("div",{className:v(e,oa.item,"apply-common-tooltip"),onClick:this._handleClick,title:t.name},i.createElement("div",{className:oa.round},t.name.length>0?t.name[0].toUpperCase():" "))}}var ra=a(23177),ha=a(75668);function ca(e){return i.createElement("div",{className:v(ha.description,e.className)},e.children)}var da=a(14621);const ua=(0,rt.mergeThemes)(u.DEFAULT_POPUP_MENU_ITEM_THEME,{labelRow:da.labelRow,toolbox:da.toolbox,item:da.titleItem}),ma=(0,rt.mergeThemes)(u.DEFAULT_POPUP_MENU_ITEM_THEME,{labelRow:da.labelRow,toolbox:da.toolbox,item:da.titleItemTabletSmall}),va=(0, rt.mergeThemes)(u.DEFAULT_POPUP_MENU_ITEM_THEME,{item:da.item}),pa=(0,rt.mergeThemes)(u.DEFAULT_POPUP_MENU_ITEM_THEME,{item:da.itemTabletSmall});function ga(e){const{item:t,onApply:a,onRemove:n,onFavor:s,favorite:o,isFavoritingAllowed:l,isTabletSmall:r}=e,[h,d]=(0,Me.useHover)(),m=t.meta_info,v=m?(0,ra.descriptionString)(m.indicators):void 0,g=r?ma:ua,b=r?pa:va,S=(0,i.useCallback)(()=>a(t),[a,t]),C=(0,i.useCallback)(()=>n(t),[n,t]),_=(0,i.useCallback)(()=>{s&&s(t)},[s,t]);return i.createElement("div",{...d,className:da.wrap,"data-name":t.name,"data-id":t.id,"data-is-default":Boolean(t.is_default)},i.createElement(u.PopupMenuItem,{theme:g,label:t.name,labelRowClassName:p()(r&&da.itemLabelTabletSmall),isHovered:h,showToolboxOnHover:!o&&!h,onClick:S,toolbox:i.createElement(i.Fragment,null,!t.is_default&&i.createElement(ke.RemoveButton,{key:"remove",hidden:!Te.touch&&!h,onClick:C}),Boolean(s)&&l&&i.createElement(c.FavoriteButton,{key:"favorite",isFilled:Boolean(o),onClick:_}))}),v&&i.createElement(u.PopupMenuItem,{theme:b,label:i.createElement(ca,{className:p()(da.description,r&&da.descriptionTabletSmall)},v),onClick:S,isHovered:h}))}var ba=a(25382),Sa=a(41939);const Ca=(0,rt.mergeThemes)(u.DEFAULT_POPUP_MENU_ITEM_THEME,Sa),_a={text:(0,dt.appendEllipsis)((0,o.t)("Save Indicator template"))};function ya(e){const{onClick:t,isTabletSmall:a}=e;return i.createElement(u.PopupMenuItem,{theme:Ca,className:Sa.wrap,label:i.createElement("div",{className:Sa.titleWrap},i.createElement("div",{className:p()(Sa.title,a&&Sa.titleTabletSmall)},i.createElement(d.Icon,{className:Sa.icon,icon:ba}),i.createElement("div",{className:Sa.text},_a.text))),onClick:t})}var wa=a(36947),fa=a(64706);const ka=i.createContext(null);var Ma=a(89227);function Ta(e){const{templates:t,favorites:a,onTemplateSave:n,onTemplateRemove:s,onTemplateSelect:o,onTemplateFavorite:l,isTabletSmall:r,isLoading:h}=e,c=(0,i.useMemo)(()=>t.filter(e=>e.is_default),[t]),d=(0,i.useMemo)(()=>t.filter(e=>!e.is_default),[t]),u=(0,i.useMemo)(()=>new Set(a.map(e=>e.name)),[a]),m=(0,i.useContext)(ka),v=(0,i.useContext)(fa.MenuContext),g=(0,wa.useForceUpdate)();(0,i.useEffect)(()=>{if(null!==m){const e={};return m.getOnChange().subscribe(e,()=>{g(),v&&v.update()}),()=>m.getOnChange().unsubscribeAll(e)}return()=>{}},[]);const b=e=>i.createElement(ga,{key:e.name,item:e,isFavoritingAllowed:Boolean(l),favorite:u.has(e.name),onApply:o,onFavor:l,onRemove:s,isTabletSmall:r});return i.createElement("div",{className:p()(Ma.menu,r&&Ma.menuSmallTablet)},i.createElement(ya,{onClick:n,isTabletSmall:r}),h&&i.createElement(i.Fragment,null,i.createElement(w.PopupMenuSeparator,null),i.createElement(se,null)),!h&&(r?i.createElement(Ea,{defaults:c,customs:d,render:b}):i.createElement(xa,{defaults:c,customs:d,render:b,state:m})))}function Ea(e){const{defaults:t,customs:a,render:n}=e;return i.createElement(i.Fragment,null,a.length>0&&i.createElement(i.Fragment,null,i.createElement(w.PopupMenuSeparator,null),i.createElement(oe.ToolWidgetMenuSummary,{className:Ma.menuItemHeaderTabletSmall},(0, o.t)("My templates")),a.map(n)),t.length>0&&i.createElement(i.Fragment,null,i.createElement(w.PopupMenuSeparator,null),i.createElement(oe.ToolWidgetMenuSummary,{className:Ma.menuItemHeaderTabletSmall},(0,o.t)("Default templates")),t.map(n)))}function xa(e){const{defaults:t,customs:a,render:n,state:s}=e;return i.createElement(i.Fragment,null,a.length>0&&i.createElement(i.Fragment,null,i.createElement(w.PopupMenuSeparator,null),i.createElement(oe.ToolWidgetMenuSummary,{className:Ma.menuItemHeader},(0,o.t)("My templates")),a.map(n)),a.length>0&&t.length>0&&s&&i.createElement(i.Fragment,null,i.createElement(w.PopupMenuSeparator,null),i.createElement(Re.CollapsibleSection,{summary:(0,o.t)("Default templates"),open:!s.get().defaultsCollapsed,onStateChange:e=>s.set({defaultsCollapsed:!e})},t.map(n))),0===a.length&&t.length>0&&i.createElement(i.Fragment,null,i.createElement(w.PopupMenuSeparator,null),i.createElement(oe.ToolWidgetMenuSummary,{className:Ma.menuItemHeader},(0,o.t)("Default templates")),t.map(n)))}var Ia=a(52714),Aa=a.n(Ia);class Ra{constructor(e,t){var a,i;this._isFavoriteEnabled=n.enabled("items_favoriting"),this.handleFavorTemplate=e=>{if(!this._isFavoriteEnabled)return;const{name:t}=e;this._isTemplateFavorite(t)?this._removeFavoriteTemplate(t):this._addFavoriteTemplate(t)},this.handleDropdownOpen=()=>{this._setState({isLoading:!0}),this._studyTemplates.invalidate(),this._studyTemplates.refreshStudyTemplateList(()=>this._setState({isLoading:!1}))},this.handleApplyTemplate=e=>{this._studyTemplates.applyTemplate(e.name)},this.handleRemoveTemplate=e=>{this._studyTemplates.deleteStudyTemplate(e.name)},this.handleSaveTemplate=()=>{this._studyTemplates.showSaveAsDialog()},this._studyTemplates=e,this._favoriteStudyTemplatesService=t;const s=(null===(a=this._favoriteStudyTemplatesService)||void 0===a?void 0:a.get())||[],o=this._studyTemplates.list();this._state=new(Aa())({isLoading:!1,studyTemplatesList:o,favorites:s}),this._studyTemplates.getOnChange().subscribe(this,this._handleTemplatesChange),this._studyTemplates.refreshStudyTemplateList(),this._isFavoriteEnabled&&(null===(i=this._favoriteStudyTemplatesService)||void 0===i||i.getOnChange().subscribe(this,this._handleFavoritesChange))}destroy(){var e;this._studyTemplates.getOnChange().unsubscribe(this,this._handleTemplatesChange),this._isFavoriteEnabled&&(null===(e=this._favoriteStudyTemplatesService)||void 0===e||e.getOnChange().unsubscribe(this,this._handleFavoritesChange))}state(){return this._state.readonly()}_setState(e){this._state.setValue({...this._state.value(),...e})}_handleTemplatesChange(){this._setState({studyTemplatesList:this._studyTemplates.list()})}_handleFavoritesChange(e){this._isFavoriteEnabled&&this._setState({favorites:e})}_removeFavoriteTemplate(e){var t;const{favorites:a}=this._state.value();null===(t=this._favoriteStudyTemplatesService)||void 0===t||t.set(a.filter(t=>t!==e))}_addFavoriteTemplate(e){var t;const{favorites:a}=this._state.value();null===(t=this._favoriteStudyTemplatesService)||void 0===t||t.set([...a,e])} _isTemplateFavorite(e){const{favorites:t}=this._state.value();return t.includes(e)}}var Fa=a(36257),Na=a(73887);const Ha={title:(0,o.t)("Templates"),tooltip:(0,o.t)("Indicator Templates")},za=(0,T.registryContextType)();class Pa extends i.PureComponent{constructor(e,t){super(e,t),this._updateState=e=>{this.setState({...e,isActive:this.state.isActive})},this._handleApplyTemplate=e=>{this._handleClose(),this._model.handleApplyTemplate(e)},this._handleRemoveTemplate=e=>{this._handleClose(),this._model.handleRemoveTemplate(e)},this._handleClose=()=>{this._handleToggleDropdown(!1)},this._handleToggleDropdown=e=>{const{isActive:t}=this.state,a="boolean"==typeof e?e:!t;this.setState({isActive:a})},(0,T.validateRegistry)(t,{favoriteStudyTemplatesService:s.any,studyTemplates:s.any.isRequired,templatesMenuViewStateService:s.any});const{favoriteStudyTemplatesService:a,studyTemplates:n}=t;this._model=new Ra(n,a),this.state={...this._model.state().value(),isActive:!1}}componentDidMount(){this._model.state().subscribe(this._updateState)}componentWillUnmount(){this._model.state().unsubscribe(this._updateState),this._model.destroy()}render(){const{studyTemplatesList:e,favorites:t}=this.state,{isShownQuicks:a,className:n,displayMode:s,id:o}=this.props;return i.createElement(ka.Provider,{value:this.context.templatesMenuViewStateService||null},i.createElement(Wa,{id:o,className:n,mode:s,templates:e,favorites:t,onMenuOpen:this._model.handleDropdownOpen,onTemplateFavorite:a?this._model.handleFavorTemplate:void 0,onTemplateSelect:this._handleApplyTemplate,onTemplateRemove:this._handleRemoveTemplate,onTemplateSave:this._model.handleSaveTemplate}))}}function Wa(e){const{id:t,className:a,mode:n,favorites:s,templates:o,isMenuOpen:l,onTemplateSelect:r,onTemplateSave:h,onTemplateFavorite:c,onTemplateRemove:d}=e,u=p()(a,Na.wrap,{[Na.full]:"full"===n,[Na.medium]:"medium"===n}),v=o.filter(e=>s.includes(e.name)),g="small"!==n&&c&&v.length>0;return i.createElement(b,{id:t,className:u},i.createElement(f.MatchMedia,{rule:k.DialogBreakpoints.TabletSmall},t=>i.createElement(m.ToolWidgetMenu,{onOpen:e.onMenuOpen,isDrawer:t,drawerPosition:"Bottom",arrow:!1,content:i.createElement(P,{className:p()(g&&Na.buttonWithFavorites),displayMode:n,isOpened:l,icon:Fa,text:D.hasNewHeaderToolbarStyles?void 0:Ha.title,title:Ha.tooltip,forceInteractive:!0,collapseWhen:D.hasNewHeaderToolbarStyles?["full","medium","small"]:void 0}),onClick:S},i.createElement(Ta,{onTemplateSave:h,onTemplateSelect:r,onTemplateRemove:d,onTemplateFavorite:c,templates:o,favorites:v,isTabletSmall:t}))),g&&i.createElement(Da,{favorites:v,onTemplateSelect:function(e){r(e),S()}}));function S(){0}}function Da(e){return i.createElement(i.Fragment,null,e.favorites.map((t,a,n)=>i.createElement(la,{key:t.name,item:t,onApply:e.onTemplateSelect,className:p()({[Na.first]:0===a,[Na.last]:a===n.length-1})})))}Pa.contextType=za;a(94419);var La=a(4039),Oa=a(82559),Ua=a(55576),Ba=a(17717),Va=a(76294);const Ga={undoHint:(0,o.t)("Undo {hint}"),redoHint:(0,o.t)("Redo {hint}")},Za={undoHotKey:(0, G.hotKeySerialize)({keys:[(0,Z.humanReadableModifiers)(Z.Modifiers.Mod,!1),"Z"],text:"{0} + {1}"}),redoHotKey:(0,G.hotKeySerialize)({keys:[(0,Z.humanReadableModifiers)(Z.Modifiers.Mod,!1),"Y"],text:"{0} + {1}"})},Ya=(0,rt.weakComposeClasses)(Ua,La,{buttonUndo:"button",buttonRedo:"button"}),qa=(0,rt.mergeThemes)(Ua,Oa),Ka={...Ua,button:Ya.buttonUndo},Qa={...Ua,button:Ya.buttonRedo},ja=(0,T.registryContextType)();class Xa extends i.PureComponent{constructor(e,t){super(e,t),this._batched=null,this._handleClickUndo=()=>{(0,W.trackEvent)("GUI","Undo");const{chartWidgetCollection:e}=this.context;e.undoHistory.undo()},this._handleClickRedo=()=>{(0,W.trackEvent)("GUI","Redo");const{chartWidgetCollection:e}=this.context;e.undoHistory.redo()},(0,T.validateRegistry)(t,{chartWidgetCollection:s.any.isRequired}),this.state=this._getStateFromUndoHistory()}componentDidMount(){const{chartWidgetCollection:e}=this.context;e.undoHistory.redoStack().onChange().subscribe(this,this._onChangeStack),e.undoHistory.undoStack().onChange().subscribe(this,this._onChangeStack)}componentWillUnmount(){const{chartWidgetCollection:e}=this.context;e.undoHistory.redoStack().onChange().unsubscribe(this,this._onChangeStack),e.undoHistory.undoStack().onChange().unsubscribe(this,this._onChangeStack),this._batched=null}render(){const{id:e}=this.props,{isEnabledRedo:t,isEnabledUndo:a,redoStack:n,undoStack:s}=this.state;return i.createElement(b,{id:e},i.createElement(S.ToolWidgetButton,{icon:Ba,isDisabled:!a,onClick:this._handleClickUndo,title:a?Ga.undoHint.format({hint:s}):void 0,"data-tooltip-hotkey":a?Za.undoHotKey:void 0,theme:D.hasNewHeaderToolbarStyles?qa:Ka}),i.createElement(S.ToolWidgetButton,{icon:Va,isDisabled:!t,onClick:this._handleClickRedo,title:t?Ga.redoHint.format({hint:n}):void 0,"data-tooltip-hotkey":t?Za.redoHotKey:void 0,theme:D.hasNewHeaderToolbarStyles?qa:Qa}))}_onChangeStack(){null===this._batched&&(this._batched=Promise.resolve().then(()=>{if(null===this._batched)return;this._batched=null;const e=this._getStateFromUndoHistory();this.setState(e)}))}_getStateFromUndoHistory(){const{chartWidgetCollection:e}=this.context,t=e.undoHistory.undoStack(),a=e.undoHistory.redoStack(),n=a.head(),i=t.head();return{isEnabledRedo:!a.isEmpty(),isEnabledUndo:!t.isEmpty(),redoStack:n?n.text().translatedText():"",undoStack:i?i.text().translatedText():""}}}Xa.contextType=ja;var Ja=a(87995),$a=a(9837);class en extends i.PureComponent{constructor(){super(...arguments),this._ref=null,this._update=()=>{this.forceUpdate()},this._setRef=e=>{this._ref=e},this._handleMeasure=({width:e})=>{this.props.width.setValue(e)}}componentDidMount(){const{element:e,isFake:t,width:a}=this.props;if(t)a.subscribe(this._update);else{const t=(0,J.ensureNotNull)(this._ref);Ja.findDOMNode(t).appendChild(e)}}componentWillUnmount(){const{width:e,isFake:t}=this.props;t&&e.unsubscribe(this._update)}render(){const{isFake:e=!1,width:t}=this.props;return i.createElement($a,{shouldMeasure:!e,whitelist:["width"],onMeasure:this._handleMeasure},i.createElement(b,{ref:this._setRef,style:e?{ width:t.value()}:void 0,"data-is-custom-header-element":!0}))}}function tn(e){const{displayMode:t,params:a}=e;return i.createElement(m.ToolWidgetMenu,{content:i.createElement(P,{collapseWhen:void 0!==a.icon?void 0:[],displayMode:t,icon:a.icon,text:a.title,title:a.tooltip,"data-name":"dropdown","data-is-custom-header-element":!0}),drawerPosition:"Bottom",drawerBreakpoint:k.DialogBreakpoints.TabletSmall,arrow:!1},a.items.map((e,t)=>i.createElement(u.PopupMenuItem,{key:t,label:e.title,onClick:()=>e.onSelect(),"data-name":"dropdown-item"})))}var an=a(33191);function nn(e){const{className:t,...a}=e;return i.createElement(P,{...a,className:v(t,an.customTradingViewStyleButton,an.withoutIcon),collapseWhen:[],"data-name":"custom-tradingview-styled-button"})}function sn(){return{Bars:n.enabled("header_chart_type")?N:void 0,Compare:n.enabled("header_compare")?B:void 0,Custom:en,CustomTradingViewStyledButton:nn,Fullscreen:n.enabled("header_fullscreen_button")?X:void 0,Indicators:n.enabled("header_indicators")?me:void 0,Intervals:n.enabled("header_resolutions")?Ve:void 0,OpenPopup:Ke,Properties:n.enabled("header_settings")&&n.enabled("show_chart_property_page")?Je:void 0,SaveLoad:n.enabled("header_saveload")?ft:void 0,Screenshot:n.enabled("header_screenshot")?Kt:void 0,SymbolSearch:n.enabled("header_symbol_search")?ia:void 0,Templates:n.enabled("study_templates")?Pa:void 0,Dropdown:tn,UndoRedo:n.enabled("header_undo_redo")?Xa:void 0,Layout:void 0}}},23177:(e,t,a)=>{"use strict";a.d(t,{createStudyTemplateMetaInfo:()=>i,descriptionString:()=>s});var n=a(81851);function i(e,t){return{indicators:e.orderedDataSources(!0).filter(e=>(0,n.isStudy)(e)&&!0).map(e=>({id:e.metaInfo().id,description:e.title(!0,void 0,!0)})),interval:t}}function s(e){const t=new Map;return e.forEach(e=>{const[a,n]=t.get(e.id)||[e.description,0];t.set(e.id,[a,n+1])}),Array.from(t.values()).map(([e,t])=>`${e}${t>1?" x "+t:""}`).join(", ")}},55402:(e,t,a)=>{"use strict";a.d(t,{validateRegistry:()=>l,RegistryProvider:()=>r,registryContextType:()=>h});var n=a(59496),i=a(19036),s=a.n(i);const o=n.createContext({});function l(e,t){s().checkPropTypes(t,e,"context","RegistryContext")}function r(e){const{validation:t,value:a}=e;return l(a,t),n.createElement(o.Provider,{value:a},e.children)}function h(){return o}},37466:(e,t,a)=>{"use strict";a.r(t),a.d(t,{SERIES_ICONS:()=>u});var n=a(8774),i=a(9322),s=a(14409),o=a(97567),l=a(84051),r=a(21610),h=a(65316),c=a(35361),d=a(92628);const u={3:n,0:i,1:s,8:o,9:l,2:r,10:h,12:c,13:d}},20301:(e,t,a)=>{"use strict";a.d(t,{convertImageNameToUrl:()=>s});var n=a(67337),i=a(76861);function s(e){return n.enabled("charting_library_base")||(0,i.isProd)()?"https://www.tradingview.com/x/"+e+"/":window.location.protocol+"//"+window.location.host+"/x/"+e+"/"}},58455:(e,t,a)=>{"use strict";function n(e,t){const a=document.createElement("a");a.style.display="none",a.href=t,a.download=e,a.click()}a.d(t,{downloadFile:()=>n})},39362:(e,t,a)=>{"use strict";a.d(t,{SymbolSearchDialogFooter:()=>l});var n=a(59496),i=a(97754),s=a.n(i),o=a(72142) ;function l(e){const{className:t,children:a}=e;return n.createElement("div",{className:s()(o.footer,t)},a)}},36947:(e,t,a)=>{"use strict";a.d(t,{useForceUpdate:()=>i});var n=a(59496);const i=()=>{const[,e]=(0,n.useReducer)((e,t)=>e+1,0);return e}},70412:(e,t,a)=>{"use strict";a.d(t,{hoverMouseEventFilter:()=>s,useAccurateHover:()=>o,useHover:()=>i});var n=a(59496);function i(){const[e,t]=(0,n.useState)(!1);return[e,{onMouseOver:function(e){s(e)&&t(!0)},onMouseOut:function(e){s(e)&&t(!1)}}]}function s(e){return!e.currentTarget.contains(e.relatedTarget)}function o(e){const[t,a]=(0,n.useState)(!1);return(0,n.useEffect)(()=>{const t=t=>{if(null===e.current)return;const n=e.current.contains(t.target);a(n)};return document.addEventListener("mouseover",t),()=>document.removeEventListener("mouseover",t)},[]),t}},81332:(e,t,a)=>{"use strict";a.d(t,{multilineLabelWithIconAndToolboxTheme:()=>o});var n=a(40173),i=a(23576),s=a(63095);const o=(0,n.mergeThemes)(i,s)},51613:(e,t,a)=>{"use strict";a.d(t,{PopupMenuSeparator:()=>l});var n=a(59496),i=a(97754),s=a.n(i),o=a(524);function l(e){const{size:t="normal",className:a}=e;return n.createElement("div",{className:s()(o.separator,"small"===t&&o.small,"normal"===t&&o.normal,"large"===t&&o.large,a)})}},15392:e=>{e.exports=''},86149:e=>{e.exports=''},8774:e=>{e.exports=''},9322:e=>{ e.exports=''},65316:e=>{e.exports=''},14409:e=>{e.exports=''},25382:e=>{e.exports=''},92628:e=>{e.exports=''},2323:e=>{e.exports=''},90711:e=>{e.exports=''},97567:e=>{e.exports=''},35361:e=>{ e.exports=''},84051:e=>{e.exports=''},60373:e=>{e.exports=''},21610:e=>{e.exports=''},74034:e=>{e.exports=''},28289:e=>{ e.exports=''},76294:e=>{e.exports=''},62346:e=>{e.exports=''},36257:e=>{ e.exports=''},17717:e=>{e.exports=''},37402:e=>{e.exports=''},50377:e=>{e.exports=''},60498:e=>{e.exports=''}}]);