(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([`