(self.webpackChunktradingview=self.webpackChunktradingview||[]).push([[5516,9685],{26574:e=>{e.exports={switcher:"switcher-fwE97QDf","thumb-wrapper":"thumb-wrapper-fwE97QDf","size-small":"size-small-fwE97QDf","size-medium":"size-medium-fwE97QDf","size-large":"size-large-fwE97QDf",input:"input-fwE97QDf","intent-default":"intent-default-fwE97QDf","disable-active-state-styles":"disable-active-state-styles-fwE97QDf","intent-select":"intent-select-fwE97QDf",track:"track-fwE97QDf",thumb:"thumb-fwE97QDf"}},88803:e=>{e.exports={"tablet-normal-breakpoint":"screen and (max-width: 768px)","small-height-breakpoint":"screen and (max-height: 360px)","tablet-small-breakpoint":"screen and (max-width: 430px)"}},17723:e=>{e.exports={footer:"footer-dwINHZFL"}},14877:e=>{e.exports={favorite:"favorite-_FRQhM5Y",hovered:"hovered-_FRQhM5Y",disabled:"disabled-_FRQhM5Y",active:"active-_FRQhM5Y",checked:"checked-_FRQhM5Y"}},33963:e=>{e.exports={item:"item-zwyEh4hn",label:"label-zwyEh4hn",labelRow:"labelRow-zwyEh4hn",toolbox:"toolbox-zwyEh4hn"}},27306:e=>{e.exports={button:"button-iLKiGOdQ",hovered:"hovered-iLKiGOdQ",disabled:"disabled-iLKiGOdQ",active:"active-iLKiGOdQ",hidden:"hidden-iLKiGOdQ"}},17946:(e,t,a)=>{"use strict";a.d(t,{CustomBehaviourContext:()=>n});const n=(0,a(50959).createContext)({enableActiveStateStyles:!0});n.displayName="CustomBehaviourContext"},76974:(e,t,a)=>{"use strict";a.d(t,{useIsMounted:()=>i});var n=a(50959);const i=()=>{const e=(0,n.useRef)(!1);return(0,n.useEffect)((()=>(e.current=!0,()=>{e.current=!1})),[]),e}},24437:(e,t,a)=>{"use strict";a.d(t,{DialogBreakpoints:()=>i});var n=a(88803);const i={SmallHeight:n["small-height-breakpoint"],TabletSmall:n["tablet-small-breakpoint"],TabletNormal:n["tablet-normal-breakpoint"]}},39362:(e,t,a)=>{"use strict";a.d(t,{SymbolSearchDialogFooter:()=>l});var n=a(50959),i=a(97754),o=a.n(i),s=a(17723);function l(e){const{className:t,children:a}=e;return n.createElement("div",{className:o()(s.footer,t)},a)}},36189:(e,t,a)=>{"use strict";a.d(t,{FavoriteButton:()=>d});var n=a(44352),i=a(50959),o=a(97754),s=a(9745),l=a(39146),r=a(48010),h=a(14877);const c={add:n.t(null,void 0,a(44629)),remove:n.t(null,void 0,a(72482))};function d(e){const{className:t,isFilled:a,isActive:n,onClick:d,...u}=e;return i.createElement(s.Icon,{...u,className:o(h.favorite,"apply-common-tooltip",a&&h.checked,n&&h.active,t),icon:a?l:r,onClick:d,title:a?c.remove:c.add})}},37968:(e,t,a)=>{"use strict";a.d(t,{useForceUpdate:()=>i});var n=a(50959);const i=()=>{const[,e]=(0,n.useReducer)((e=>e+1),0);return e}},70412:(e,t,a)=>{"use strict";a.d(t,{hoverMouseEventFilter:()=>o,useAccurateHover:()=>s,useHover:()=>i});var n=a(50959);function i(){const[e,t]=(0,n.useState)(!1);return[e,{onMouseOver:function(e){o(e)&&t(!0)},onMouseOut:function(e){o(e)&&t(!1)}}]}function o(e){return!e.currentTarget.contains(e.relatedTarget)}function s(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:()=>s});var n=a(40173),i=a(71986),o=a(33963);const s=(0,n.mergeThemes)(i,o)},96040:(e,t,a)=>{"use strict";a.d(t,{RemoveButton:()=>h});var n=a(44352),i=a(50959),o=a(97754),s=a(9745),l=a(33765),r=a(27306);function h(e){const{className:t,isActive:h,onClick:c,onMouseDown:d,title:u,hidden:v,"data-name":m="remove-button",...p}=e;return i.createElement(s.Icon,{...p,"data-name":m,className:o(r.button,"apply-common-tooltip",h&&r.active,v&&r.hidden,t),icon:l,onClick:c,onMouseDown:d,title:u||n.t(null,void 0,a(34596))})}},47102:e=>{e.exports={accessible:"accessible-NQERJsv9",active:"active-NQERJsv9"}},12989:e=>{e.exports={summary:"summary-ynHBVe1n",hovered:"hovered-ynHBVe1n",caret:"caret-ynHBVe1n"}},90785:e=>{e.exports={accessible:"accessible-raQdxQp0"}},89089:e=>{e.exports={button:"button-LkmyTVRc",active:"active-LkmyTVRc"}},20461:e=>{e.exports={wrapper:"wrapper-psOC5oyI",labelRow:"labelRow-psOC5oyI",label:"label-psOC5oyI",labelHint:"labelHint-psOC5oyI",labelOn:"labelOn-psOC5oyI"}},40670:e=>{e.exports={wrapper:"wrapper-bl9AR3Gv",hovered:"hovered-bl9AR3Gv",withIcon:"withIcon-bl9AR3Gv",labelRow:"labelRow-bl9AR3Gv",label:"label-bl9AR3Gv",switchWrap:"switchWrap-bl9AR3Gv",icon:"icon-bl9AR3Gv",labelHint:"labelHint-bl9AR3Gv",labelOn:"labelOn-bl9AR3Gv"}},90826:e=>{e.exports={button:"button-Y1TCZogJ",active:"active-Y1TCZogJ"}},38456:e=>{e.exports={button:"button-ptpAHg8E",withText:"withText-ptpAHg8E",withoutText:"withoutText-ptpAHg8E"}},67972:e=>{e.exports={form:"form-MgR0zejo",input:"input-MgR0zejo",menu:"menu-MgR0zejo",add:"add-MgR0zejo",hovered:"hovered-MgR0zejo",wrap:"wrap-MgR0zejo",accessible:"accessible-MgR0zejo",menuLabel:"menuLabel-MgR0zejo",hover:"hover-MgR0zejo"}},39357:e=>{e.exports={spinnerWrap:"spinnerWrap-cZT0OZe0"}},52045:e=>{e.exports={button:"button-neROVfUe",first:"first-neROVfUe",last:"last-neROVfUe"}},97041:e=>{e.exports={wrap:"wrap-n5bmFxyX"}},64618:e=>{e.exports={hidden:"hidden-5MVS18J8"}},18369:e=>{e.exports={"tablet-small-breakpoint":"screen and (max-width: 430px)",item:"item-o5a0MQMm",withIcon:"withIcon-o5a0MQMm",shortcut:"shortcut-o5a0MQMm",loading:"loading-o5a0MQMm",icon:"icon-o5a0MQMm"}},4549:e=>{e.exports={button:"button-b3Cgff6l",group:"group-b3Cgff6l",menu:"menu-b3Cgff6l"}},27363:e=>{e.exports={customTradingViewStyleButton:"customTradingViewStyleButton-zigjK1n2",withoutIcon:"withoutIcon-zigjK1n2"}},75352:e=>{e.exports={dropdown:"dropdown-l0nf43ai",label:"label-l0nf43ai",smallWidthTitle:"smallWidthTitle-l0nf43ai",smallWidthMenuItem:"smallWidthMenuItem-l0nf43ai",smallWidthWrapper:"smallWidthWrapper-l0nf43ai"}},20371:e=>{e.exports={value:"value-gwXludjS",selected:"selected-gwXludjS"}},867:e=>{e.exports={smallWidthMenuItem:"smallWidthMenuItem-RmqZNwwp",menuItem:"menuItem-RmqZNwwp",remove:"remove-RmqZNwwp"}},80022:e=>{e.exports={button:"button-S_1OCXUK",first:"first-S_1OCXUK",last:"last-S_1OCXUK",menu:"menu-S_1OCXUK",dropdown:"dropdown-S_1OCXUK",menuContent:"menuContent-S_1OCXUK", section:"section-S_1OCXUK",smallTabletSectionTitle:"smallTabletSectionTitle-S_1OCXUK",addCustomInterval:"addCustomInterval-S_1OCXUK",hovered:"hovered-S_1OCXUK",group:"group-S_1OCXUK"}},23902:e=>{e.exports={button:"button-gn9HMufu"}},92998:e=>{e.exports={button:"button-ZuDkGGhF",isDisabled:"isDisabled-ZuDkGGhF"}},70152:e=>{e.exports={saveString:"saveString-XVd1Kfjg",hidden:"hidden-XVd1Kfjg",loader:"loader-XVd1Kfjg"}},63672:e=>{e.exports={opened:"opened-yyMUOAN9",hover:"hover-yyMUOAN9",autoSaveWrapper:"autoSaveWrapper-yyMUOAN9",sharingWrapper:"sharingWrapper-yyMUOAN9",button:"button-yyMUOAN9",buttonSmallPadding:"buttonSmallPadding-yyMUOAN9",hintPlaceHolder:"hintPlaceHolder-yyMUOAN9",smallHintPlaceHolder:"smallHintPlaceHolder-yyMUOAN9",popupItemRowTabletSmall:"popupItemRowTabletSmall-yyMUOAN9",shortcut:"shortcut-yyMUOAN9",toolTitle:"toolTitle-yyMUOAN9",toolTitleMobile:"toolTitleMobile-yyMUOAN9",layoutItem:"layoutItem-yyMUOAN9",layoutMeta:"layoutMeta-yyMUOAN9",labelRow:"labelRow-yyMUOAN9",layoutTitle:"layoutTitle-yyMUOAN9",layoutItemWrap:"layoutItemWrap-yyMUOAN9",layoutTitleMobile:"layoutTitleMobile-yyMUOAN9",active:"active-yyMUOAN9",textWrap:"textWrap-yyMUOAN9",text:"text-yyMUOAN9",withIcon:"withIcon-yyMUOAN9",sharingLabelWrap:"sharingLabelWrap-yyMUOAN9",infoIcon:"infoIcon-yyMUOAN9",copyLink:"copyLink-yyMUOAN9",copyLinkMobile:"copyLinkMobile-yyMUOAN9"}},25882:e=>{e.exports={button:"button-cq__ntSC",largeLeftPadding:"largeLeftPadding-cq__ntSC",text:"text-cq__ntSC",uppercase:"uppercase-cq__ntSC"}},26431:e=>{e.exports={button:"button-HwLRKjG6",text:"text-HwLRKjG6",logo:"logo-HwLRKjG6"}},92710:e=>{e.exports={description:"description-jgoQcEnP"}},5145:e=>{e.exports={item:"item-j7oVl2yI",accessible:"accessible-j7oVl2yI",round:"round-j7oVl2yI"}},85013:e=>{e.exports={wrap:"wrap-HXSqojvq",titleWrap:"titleWrap-HXSqojvq",indicators:"indicators-HXSqojvq",title:"title-HXSqojvq",icon:"icon-HXSqojvq",text:"text-HXSqojvq",titleTabletSmall:"titleTabletSmall-HXSqojvq",labelRow:"labelRow-HXSqojvq",label:"label-HXSqojvq"}},48261:e=>{e.exports={labelRow:"labelRow-JeQoCpvi",toolbox:"toolbox-JeQoCpvi",description:"description-JeQoCpvi",descriptionTabletSmall:"descriptionTabletSmall-JeQoCpvi",item:"item-JeQoCpvi",titleItem:"titleItem-JeQoCpvi",titleItemTabletSmall:"titleItemTabletSmall-JeQoCpvi",itemTabletSmall:"itemTabletSmall-JeQoCpvi",itemLabelTabletSmall:"itemLabelTabletSmall-JeQoCpvi",wrap:"wrap-JeQoCpvi",hovered:"hovered-JeQoCpvi"}},36001:e=>{e.exports={menu:"menu-hcofKPms",menuSmallTablet:"menuSmallTablet-hcofKPms",menuItemHeaderTabletSmall:"menuItemHeaderTabletSmall-hcofKPms",menuItemHeader:"menuItemHeader-hcofKPms"}},70760:e=>{e.exports={wrap:"wrap-jiC5bgmi",full:"full-jiC5bgmi",first:"first-jiC5bgmi",last:"last-jiC5bgmi",medium:"medium-jiC5bgmi",buttonWithFavorites:"buttonWithFavorites-jiC5bgmi"}},57778:e=>{e.exports={icon:"icon-uMfL97K2"}},76197:(e,t,a)=>{"use strict";a.d(t,{CollapsibleSection:()=>r});var n=a(50959),i=a(97754),o=a.n(i),s=a(10381),l=a(12989);const r=(0,n.forwardRef)((function(e,t){ const{open:a,summary:i,children:r,onStateChange:h,tabIndex:c,className:d,...u}=e;return n.createElement(n.Fragment,null,n.createElement("div",{...u,className:o()(d,l.summary),onClick:function(){h&&h(!a)},"data-open":a,ref:t,tabIndex:c},i,n.createElement(s.ToolWidgetCaret,{className:l.caret,dropped:Boolean(a)})),a&&r)}))},69297:(e,t,a)=>{"use strict";a.d(t,{DEFAULT_MENU_ITEM_SWITCHER_THEME:()=>m,MenuItemSwitcher:()=>p});var n=a(50959),i=a(97754),o=a.n(i),s=a(17946),l=a(26574),r=a.n(l);function h(e){const t=(0,n.useContext)(s.CustomBehaviourContext),{className:a,intent:o="default",size:l="small",enableActiveStateStyles:h=t.enableActiveStateStyles}=e;return i(a,r().switcher,r()[`size-${l}`],r()[`intent-${o}`],!h&&r()["disable-active-state-styles"])}function c(e){var t;const{reference:a,size:i,intent:o,role:s,"aria-checked":l,checked:c,defaultChecked:d,onKeyDown:u,...v}=e,m=(0,n.useCallback)((e=>{13===e.keyCode&&e.target.click(),u&&u(e)}),[u]);return n.createElement("span",{className:h(e)},n.createElement("input",{...v,type:"checkbox",className:r().input,ref:a,role:null!=s?s:"switch","aria-checked":null!==(t=null!=l?l:c)&&void 0!==t?t:d,checked:c,defaultChecked:d,onKeyDown:m}),n.createElement("span",{className:r()["thumb-wrapper"]},n.createElement("span",{className:r().track}),n.createElement("span",{className:r().thumb})))}var d=a(9745),u=a(90186),v=a(40670);const m=v;function p(e){const{className:t,checked:a,id:i,label:s,labelDescription:l,value:r,preventLabelHighlight:h,reference:m,switchReference:p,theme:g=v,disabled:b,icon:C}=e,S=o()(g.label,a&&!h&&g.labelOn),_=o()(t,g.wrapper,a&&g.wrapperWithOnLabel,l&&g.wrapperWithDescription);return n.createElement("label",{className:o()(_,C&&g.withIcon),htmlFor:i,ref:m},void 0!==C&&n.createElement(d.Icon,{className:g.icon,icon:C}),n.createElement("div",{className:g.labelRow},n.createElement("div",{className:S},s),l&&n.createElement("div",{className:g.labelHint},l)),n.createElement("div",{className:v.switchWrap},n.createElement(c,{disabled:b,className:g.switch,reference:p,checked:a,onChange:function(t){const a=t.target.checked;void 0!==e.onChange&&e.onChange(a)},value:r,tabIndex:-1,id:i,role:e.switchRole,...(0,u.filterDataProps)(e)})))}},65817:(e,t,a)=>{"use strict";a.d(t,{INTERVALS:()=>i});var n=a(44352);const i=[{name:"",label:n.t(null,{context:"interval"},a(37830))},{name:"H",label:n.t(null,{context:"interval"},a(5285))},{name:"D",label:n.t(null,{context:"interval"},a(6174))},{name:"W",label:n.t(null,{context:"interval"},a(25042))},{name:"M",label:n.t(null,{context:"interval"},a(79410))}]},6652:(e,t,a)=>{"use strict";a.r(t),a.d(t,{getRestrictedToolSet:()=>tn});var n=a(14483),i=a(50959),o=a(19036),s=a(44352),l=a(82992),r=a(88732),h=a(45876),c=a(36189),d=a(9745),u=a(16396),v=a(50298),m=a(97754),p=a.n(m),g=a(97041);const b=i.forwardRef(((e,t)=>{const{children:a,className:n,...o}=e;return i.createElement("div",{className:m(n,g.wrap),ref:t,...o},a)}));var C=a(88066),S=a(52045);class _ extends i.PureComponent{constructor(){super(...arguments),this._handleClick=()=>{ const{onClick:e,onClickArg:t}=this.props;e&&e(t)}}render(){const{className:e,icon:t,hint:a,text:n,isDisabled:o,isActive:s,isFirst:l,isLast:r,onClick:h,onClickArg:c,...d}=this.props;return i.createElement(C.ToolbarButton,{...d,icon:t,text:n,tooltip:a,isDisabled:o,isActive:s,isGrouped:!0,onClick:this._handleClick,className:m(e,S.button,{[S.first]:l,[S.last]:r})})}}var y=a(51613),f=a(90692),w=a(24437),E=a(81332),M=a(5962),k=a(16410),T=a(42960),x=a(47201),I=a(3343),A=a(16838);function R(e){const{orientation:t,onKeyDown:a,...n}=e,o=A.PLATFORM_ACCESSIBILITY_ENABLED?{role:"radiogroup","aria-orientation":t}:{};return i.createElement("div",{...n,...o,onKeyDown:(0,x.createSafeMulticastEventHandler)((function(e){if(!A.PLATFORM_ACCESSIBILITY_ENABLED)return;if(e.defaultPrevented)return;if(!(document.activeElement instanceof HTMLElement))return;const a=(0,I.hashFromEvent)(e);if("vertical"!==t&&38!==a&&40!==a)return;if("vertical"===t&&37!==a&&39!==a)return;const n=(i=e.currentTarget,Array.from(i.querySelectorAll('[role="radio"]:not([disabled], [aria-disabled])')).filter((0,A.createScopedVisibleElementFilter)(i))).sort(A.navigationOrderComparator);var i;if(0===n.length)return;const o=n.indexOf(document.activeElement);if(-1===o)return;e.preventDefault();const s=()=>{const e=(o+n.length-1)%n.length;n[o].dispatchEvent(new CustomEvent("roving-tabindex:secondary-element")),n[e].dispatchEvent(new CustomEvent("roving-tabindex:main-element")),n[e].focus()},l=()=>{const e=(o+n.length+1)%n.length;n[o].dispatchEvent(new CustomEvent("roving-tabindex:secondary-element")),n[e].dispatchEvent(new CustomEvent("roving-tabindex:main-element")),n[e].focus()};switch(a){case 38:"vertical"!==t&&s();break;case 40:"vertical"!==t&&l();break;case 37:"vertical"===t&&s();break;case 39:"vertical"===t&&l()}}),a)})}var N=a(4549);const F={barsStyle:s.t(null,void 0,a(84232))},H=(0,M.registryContextType)();function L(e){var t;return!(null===(t=l.linking.supportedChartStyles.value())||void 0===t?void 0:t.includes(e))}class O 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,M.validateRegistry)(t,{chartWidgetCollection:o.any.isRequired,favoriteChartStylesService:o.any.isRequired});const{chartWidgetCollection:a,favoriteChartStylesService:n}=t,i=a.activeChartStyle.value(),s=n.get(),l=(0,k.japaneseChartStyles)();this.state={activeStyle:i,favorites:s,styles:(0,k.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:o,styles:s,japaneseStyles:l,lastSelectedNotFavorite:c}=this.state,u="small"!==t&&e&&0!==o.length,m=[...o];m.includes(n)?void 0!==c&&m.push(c):m.push(n);const p=u&&m.length>1;return i.createElement(f.MatchMedia,{rule:w.DialogBreakpoints.TabletSmall},(e=>{const t=s.map((t=>this._renderPopupMenuItem(t,t===n,e))),o=l.map((t=>this._renderPopupMenuItem(t,t===n,e)));return i.createElement(b,{id:a},p&&i.createElement(R,{orientation:"horizontal",className:N.group},m.map(((e,t)=>i.createElement(_,{role:"radio",className:N.button,icon:h.SERIES_ICONS[e],"aria-checked":u&&n===e,isActive:u&&n===e,isDisabled:L(e),key:t,hint:(0,T.getTranslatedChartStyleName)(e),isFirst:0===t,isLast:t===m.length-1,onClick:u?this._handleQuickClick:void 0,onClickArg:e,"data-value":r.STYLE_SHORT_NAMES[e]})))),i.createElement(v.ToolbarMenuButton,{arrow:Boolean(p),content:p?void 0:i.createElement(b,null,i.createElement(d.Icon,{icon:h.SERIES_ICONS[n]})),tooltip:p?F.barsStyle:(0,T.getTranslatedChartStyleName)(n),className:N.menu,isDrawer:e,onClick:this._trackClick},t,!!o.length&&i.createElement(y.PopupMenuSeparator,null),o))}))}_renderPopupMenuItem(e,t,a){const{isFavoritingAllowed:n}=this.props,o=this._isStyleFavorited(e);return i.createElement(u.PopupMenuItem,{key:e,theme:a?E.multilineLabelWithIconAndToolboxTheme:void 0,icon:h.SERIES_ICONS[e],isActive:t,isDisabled:L(e),label:(0,T.getTranslatedChartStyleName)(e)||"",onClick:this._handleSelectStyle,onClickArg:e,showToolboxOnHover:!o,toolbox:n&&i.createElement(c.FavoriteButton,{isActive:t,isFilled:o,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}}O.contextType=H;var D=a(50238),P=a(31409),U=a(38456);const B=["medium","small"],W=(0,i.forwardRef)((function(e,t){const{text:a,className:n,displayMode:o,collapseWhen:s=B,...l}=e,r=!s.includes(o);return i.createElement(P.ToolWidgetButton,{...l,ref:t,text:r?a:void 0,className:m(n,U.button,r?U.withText:U.withoutText)})}));function z(e){const{tooltip:t,...a}=e,[n,o]=(0,D.useRovingTabindexElement)(null);return i.createElement(W,{"aria-label":A.PLATFORM_ACCESSIBILITY_ENABLED?t:void 0,...a, tag:A.PLATFORM_ACCESSIBILITY_ENABLED?"button":"div",tabIndex:o,ref:n,"data-tooltip":t})}var V=a(51768),Z=a(76460),K=a(1393);const Q=(0,M.registryContextType)();class q extends i.PureComponent{constructor(e,t){super(e,t),this._updateState=e=>{this.setState({isActive:e})},this._handleClick=e=>{var t;(0,V.trackEvent)("GUI","Chart Header Toolbar","compare"),null===(t=this._compareDialogRenderer)||void 0===t||t.show({shouldReturnFocus:(0,Z.isKeyboardClick)(e)})},(0,M.validateRegistry)(t,{chartWidgetCollection:o.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(z,{...this.props,icon:K,isOpened:e,onClick:this._handleClick,collapseWhen:["full","medium","small"],tooltip:s.t(null,void 0,a(20229))})}}q.contextType=Q;var j=a(48889),G=a(61814),Y=a(68335),X=a(97268);const J=(0,G.hotKeySerialize)({keys:[(0,Y.humanReadableModifiers)(Y.Modifiers.Shift,!1),"F"],text:"{0} + {1}"}),$=(0,M.registryContextType)();class ee extends i.PureComponent{constructor(e,t){super(e,t),this._handleClick=()=>{const{chartWidgetCollection:e}=this.context;e.startFullscreen()},(0,M.validateRegistry)(t,{chartWidgetCollection:o.any.isRequired})}render(){const{className:e,id:t}=this.props;return i.createElement(j.ToolbarIconButton,{id:t,icon:X,onClick:this._handleClick,className:m(e),tooltip:s.t(null,void 0,a(11682)),"data-tooltip-hotkey":J})}}ee.contextType=$;var te=a(50151);const ae=(0,a(59224).getLogger)("FavoritesInfo");function ne(e,t){if(0===e.length)return Promise.resolve([]);ae.logNormal("Requesting favorites info");const a=[],n=new Map,i=new Map,o=new Map;return e.forEach((e=>{switch(e.type){case"java":o.set(e.studyId,e);break;case"pine":isPublishedPineId(e.pineId)?n.set(e.pineId,e):i.set(e.pineId,e);break;default:(0,te.assert)(!1,`unknown favorite type ${JSON.stringify(e)}`)}})),0!==o.size&&a.push(t.findAllJavaStudies().then((e=>{const t=new Map;for(const a of e)!a.is_hidden_study&&o.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}(o,e);if(0!==t.notFoundItems.length){const e=t.notFoundItems.map((e=>e.studyId));ae.logWarn(`Cannot find java scripts: ${JSON.stringify(e)}`)}return t.items}))),Promise.all(a).then((e=>(ae.logNormal("Requesting favorites info finished"),e.reduce(((e,t)=>e.concat(t)),[]))))}var ie=a(29673),oe=a(88348),se=a(26996),le=a(39357);function re(e){const{className:t}=e;return i.createElement("div",{className:p()(le.spinnerWrap,t)},i.createElement(se.Loader,null))} var he=a(82962),ce=a(76422),de=a(39681),ue=a(75352);const ve=(0,G.hotKeySerialize)({keys:["/"],text:"{0}"}),me=(0,M.registryContextType)();class pe 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=e=>{const{studyMarket:t}=this.props;this.setState({isActive:!0},(()=>{t.visible().value()?t.hide():t.show({shouldReturnFocus:(0,Z.isKeyboardClick)(e)})})),this._trackClick()},this._handleSelectIndicator=e=>{e=(0,te.ensureDefined)(e),this._trackFavoriteAction("Favorite indicator from toolbar");"java"===e.type?e.studyId:e.pineId;(()=>{e=(0,te.ensureDefined)(e);const{chartWidgetCollection:t}=this.context;if("java"===e.type){const t=(0,ie.tryFindStudyLineToolNameByStudyId)(e.studyId);if(null!==t)return void oe.tool.setValue(t)}t.activeChartWidget.value().insertStudy(e,[])})()},this._handleFavoriteIndicatorsChange=()=>{const{favoriteScriptsModel:e}=this.context,t=[...(0,te.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,M.validateRegistry)(t,{favoriteScriptsModel:o.any,chartWidgetCollection:o.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)),ce.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)),ce.unsubscribe("TVScriptRenamed",this._handleScriptRenamed,null),this._promise=null}render(){const{isActive:e,favorites:t,favoriteFundamentals:n,isLoading:o}=this.state,{className:l,displayMode:r,id:h}=this.props,{chartWidgetCollection:c}=this.context;return i.createElement(i.Fragment,null,i.createElement(b,{id:h, onMouseEnter:this._handleMouseEnter,onClick:this._handleWrapClick},i.createElement(z,{displayMode:r,className:l,icon:de,isOpened:e,onClick:this._handleClick,text:s.t(null,void 0,a(61142)),"data-role":"button","data-name":"open-indicators-dialog",tooltip:s.t(null,void 0,a(74527)),"data-tooltip-hotkey":ve}),Boolean(t.length>0||(null==n?void 0:n.size))&&i.createElement(f.MatchMedia,{rule:"screen and (max-width: 430px)"},(e=>i.createElement(v.ToolbarMenuButton,{key:c.activeChartWidget.value().id(),arrow:!0,closeOnClickOutside:!0,isDrawer:e,drawerPosition:"Bottom",ref:this._menu,onClick:this._handleFavoriteMenuClick,"data-name":"show-favorite-indicators",tooltip:s.t(null,void 0,a(33959))},i.createElement("div",{className:p()(ue.dropdown,e&&ue.smallWidthWrapper)},i.createElement(he.ToolWidgetMenuSummary,{className:e&&ue.smallWidthTitle},s.t(null,void 0,a(83127))),o&&i.createElement(re,null),!o&&i.createElement(i.Fragment,null,this.state.infos.length>0?this.state.infos.map((t=>i.createElement(u.PopupMenuItem,{className:p()(e&&ue.smallWidthMenuItem),theme:e?E.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&&ue.label,e&&ue.smallWidthLabel,"apply-overflow-tooltip")},ge(t))}))):null!==this._promise&&i.createElement(u.PopupMenuItem,{isDisabled:!0,label:s.t(null,void 0,a(23687))}))))))))}_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([ne(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)=>ge(e).localeCompare(ge(t)))),this.setState({infos:i,isLoading:!1},(()=>{this._menu.current&&this._menu.current.update()}))}))}_trackClick(){0}_trackFavoriteAction(e){(0,V.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 ge(e){return e.info.localizedName||s.t(e.info.name,{context:"study"},a(68716))}pe.contextType=me;var be=a(94025),Ce=a(20371);function Se(e){return i.createElement("div",{className:m(Ce.value,{[Ce.selected]:e.isSelected})},e.value,e.metric)}var _e=a(65817),ye=a(67972);function fe(e){const{className:t,...a}=e,[n,o]=(0,D.useRovingTabindexElement)(null),s=A.PLATFORM_ACCESSIBILITY_ENABLED?"button":"div";return i.createElement(s,{...a,ref:n,tabIndex:o,"data-role":A.PLATFORM_ACCESSIBILITY_ENABLED?"menuitem":void 0,className:p()(A.PLATFORM_ACCESSIBILITY_ENABLED&&ye.accessible,t)})}function we(e){ const{className:t,...a}=e,[n,o]=(0,D.useRovingTabindexElement)(null);return i.createElement("input",{...a,ref:n,tabIndex:o,"data-role":A.PLATFORM_ACCESSIBILITY_ENABLED?"menuitem":void 0,className:p()(A.PLATFORM_ACCESSIBILITY_ENABLED&&ye.accessible,t)})}var Ee=a(47102);function Me(e){const{className:t,...a}=e,[n,o]=(0,D.useRovingTabindexElement)(null);return i.createElement(u.PopupMenuItem,{...a,className:p()(A.PLATFORM_ACCESSIBILITY_ENABLED&&Ee.accessible,e.isActive&&Ee.active,t),reference:n,tabIndex:o,onKeyDown:function(e){if(!A.PLATFORM_ACCESSIBILITY_ENABLED||e.target!==e.currentTarget)return;const t=(0,I.hashFromEvent)(e);13!==t&&32!==t||(e.preventDefault(),n.current instanceof HTMLElement&&n.current.click())},"data-role":A.PLATFORM_ACCESSIBILITY_ENABLED?"menuitem":void 0,"aria-disabled":A.PLATFORM_ACCESSIBILITY_ENABLED&&e.isDisabled||void 0})}class ke extends i.PureComponent{constructor(e){super(e),this._menu=i.createRef(),this._handleChangeInput=e=>{const{value:t}=e.currentTarget;/^[0-9]*$/.test(t)&&this.setState({inputValue:t})},this._handleSelectTime=e=>{var t,a,n,i;this.setState({selectedIntervalSuffix:e}),null===(a=(t=this.props).onSelect)||void 0===a||a.call(t),null===(n=this._menu.current)||void 0===n||n.close(),null===(i=this._menu.current)||void 0===i||i.focus()},this._handleClickAdd=()=>{const{inputValue:e,selectedIntervalSuffix:t}=this.state;this.props.onAdd(e,t)},this.state={inputValue:"1",selectedIntervalSuffix:_e.INTERVALS[0].name}}render(){const{inputValue:e,menuWidth:t,selectedIntervalSuffix:n}=this.state;return i.createElement("div",{className:ye.form},i.createElement(we,{className:ye.input,maxLength:7,onChange:this._handleChangeInput,value:e}),i.createElement(v.ToolbarMenuButton,{orientation:"none",minWidth:t,"data-role":"menuitem",onClose:this.props.onCloseMenu,onOpen:this.props.onOpenMenu,className:ye.menu,ref:this._menu,content:i.createElement("div",{className:ye.menuLabel},_e.INTERVALS.find((e=>e.name===n)).label)},_e.INTERVALS.map((e=>i.createElement(Me,{dontClosePopup:!0,key:e.name,label:e.label,onClick:this._handleSelectTime,onClickArg:e.name})))),i.createElement(fe,{className:ye.add,onClick:this._handleClickAdd},s.t(null,void 0,a(54777))))}}var Te=a(90186),xe=a(70412),Ie=a(32563),Ae=a(96040),Re=a(90826);function Ne(e){const{tooltip:t,onClick:a,...n}=e,[o,s]=(0,D.useRovingTabindexElement)(null);return A.PLATFORM_ACCESSIBILITY_ENABLED?i.createElement("button",{ref:o,tabIndex:s,onClick:a,className:p()(Re.button,n.isActive&&Re.active),type:"button"},i.createElement(Ae.RemoveButton,{"aria-label":t,...n,"data-tooltip":t})):i.createElement(Ae.RemoveButton,{...e,"data-tooltip":t})}var Fe=a(89089);function He(e){const{tooltip:t,onClick:a,...n}=e,[o,s]=(0,D.useRovingTabindexElement)(null);return A.PLATFORM_ACCESSIBILITY_ENABLED?i.createElement("button",{ref:o,tabIndex:s,onClick:a,className:p()(Fe.button,n.isActive&&Fe.active),type:"button"},i.createElement(c.FavoriteButton,{"aria-label":t,...n,"data-tooltip":t})):i.createElement(c.FavoriteButton,{...e,"data-tooltip":t})}var Le=a(867) ;function Oe(e){const{interval:t,hint:a,isActive:n,isDisabled:o,isFavorite:s,isSignaling:l,onClick:r,onClickRemove:h,onClickFavorite:c,isSmallTablet:d}=e,u=(0,Te.filterDataProps)(e),[v,m]=(0,xe.useHover)(),g=i.useCallback((e=>h(t,e)),[h,t]),b=i.useCallback((()=>c(t)),[c,t]),C=(0,i.useRef)(null);return(0,i.useEffect)((()=>{var e;l&&d&&(null===(e=C.current)||void 0===e||e.scrollIntoView())}),[l,d]),i.createElement("div",{...m,ref:C},i.createElement(Me,{...u,className:p()(Le.menuItem,d&&Le.smallWidthMenuItem),theme:d?E.multilineLabelWithIconAndToolboxTheme:void 0,isActive:n,isDisabled:o,isHovered:l,onClick:r,onClickArg:t,toolbox:function(){const{isRemovable:t,isFavoritingAllowed:a}=e,l=i.createElement(Ne,{key:"remove",isActive:n,hidden:!Ie.touch&&!v,onClick:g,className:Le.remove}),r=i.createElement(He,{key:"favorite",isActive:n,isFilled:s,onClick:b});return[t&&l,!o&&a&&r]}(),showToolboxOnHover:!s,showToolboxOnFocus:A.PLATFORM_ACCESSIBILITY_ENABLED,label:a}))}var De=a(36274);const Pe={[De.ResolutionKind.Ticks]:s.t(null,{context:"interval_group_name"},a(30426)),[De.ResolutionKind.Seconds]:s.t(null,{context:"interval_group_name"},a(74973)),[De.ResolutionKind.Minutes]:s.t(null,{context:"interval_group_name"},a(57470)),[De.SpecialResolutionKind.Hours]:s.t(null,{context:"interval_group_name"},a(62346)),[De.ResolutionKind.Days]:s.t(null,{context:"interval_group_name"},a(74787)),[De.ResolutionKind.Weeks]:s.t(null,{context:"interval_group_name"},a(86614)),[De.ResolutionKind.Months]:s.t(null,{context:"interval_group_name"},a(94328)),[De.ResolutionKind.Range]:s.t(null,{context:"interval_group_name"},a(48801)),[De.ResolutionKind.Invalid]:""};function Ue(e,t=!1){return{id:e,name:Pe[e],items:[],mayOmitSeparator:t}}var Be=a(57898),We=a.n(Be),ze=a(29197),Ve=a(59064),Ze=a(76197),Ke=a(90785);function Qe(e){const{className:t,...a}=e,[n,o]=(0,D.useRovingTabindexElement)(null);return i.createElement(Ze.CollapsibleSection,{...a,ref:n,tabIndex:o,"data-role":A.PLATFORM_ACCESSIBILITY_ENABLED?"menuitem":void 0,className:p()(A.PLATFORM_ACCESSIBILITY_ENABLED&&Ke.accessible,t),onKeyDown:function(e){const t=(0,I.hashFromEvent)(e);13!==t&&32!==t||(e.preventDefault(),n.current instanceof HTMLElement&&n.current.click())}})}var qe=a(80022);const je={openDialog:s.t(null,void 0,a(79353)),timeInterval:s.t(null,void 0,a(32916))},Ge=(0,G.hotKeySerialize)({keys:[","],text:s.t(null,void 0,a(14605))}),Ye=(0,M.registryContextType)(),Xe=new(We()),Je=i.lazy((async()=>({default:(await Promise.all([a.e(1013),a.e(5145),a.e(855),a.e(2191),a.e(6221),a.e(4215),a.e(7194),a.e(2676),a.e(3016),a.e(4403),a.e(4013)]).then(a.bind(a,44762))).ToolWidgetIntervalsAddDialog})));class $e extends i.PureComponent{constructor(e,t){super(e,t),this._menu=i.createRef(),this._menuItemsContainerRef=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,be.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,V.trackEvent)("GUI","Time Interval",e)},this._handleClickFavorite=e=>{e=(0,te.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,t)=>{var a,n;const{intervalService:i}=this.context;if(e){if(A.PLATFORM_ACCESSIBILITY_ENABLED&&t&&(0,Z.isKeyboardClick)(t)&&this._menuItemsContainerRef.current){const t=(0,v.queryMenuElements)(this._menuItemsContainerRef.current),i=t.findIndex((t=>t.matches(`[data-value="${e}"]`)));if(-1!==i){const e=null!==(a=t[i+1])&&void 0!==a?a:t[i-1];e?e.focus():null===(n=this._menu.current)||void 0===n||n.focusMenu()}}i.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||Xe.fire()},this._handeQuickClick=e=>{this._handleSelectInterval(e),this._trackClick()},this._updateMenuPosition=()=>{var e;null===(e=this._menu.current)||void 0===e||e.update()},(0,M.validateRegistry)(t,{chartApiInstance:o.any.isRequired,favoriteIntervalsService:o.any.isRequired,intervalService:o.any.isRequired,intervalsMenuViewStateService:o.any.isRequired});const{chartApiInstance:a,favoriteIntervalsService:s,intervalService:r,intervalsMenuViewStateService:h}=t;this._customIntervals=n.enabled("custom_resolutions");const c=l.linking.interval.value(),d=c&&(0,be.normalizeIntervalString)(c),u=s.get(),m=r.getCustomIntervals(),p=h.get();this._defaultIntervals=a.defaultResolutions().filter(be.isIntervalEnabled).map(be.normalizeIntervalString),this.state={isOpenedFormMenu:!1,activeInterval:d,favorites:u,customs:m,menuViewState:p,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),l.linking.dataFrequencyResolution.subscribe(this._bindedForceUpdate),Ve.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),l.linking.dataFrequencyResolution.unsubscribe(this._bindedForceUpdate),Ve.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:o,isAddIntervalDialogOpened:s}=this.state,l=this._getQuicks(),r=(0,be.sortResolutions)([...l]);void 0!==a&&r.includes(a)?void 0!==o&&r.push(o):void 0!==a&&r.push(a);const h=(!(!e||0===l.length)||void 0)&&r.length>1,c={},d=(0,be.mergeResolutions)(this._defaultIntervals,n);(void 0!==a?d.concat(a):d).filter(be.isAvailable).forEach((e=>c[e]=!0));const u=void 0!==a?(0,be.getTranslatedResolutionModel)(a):null;return i.createElement(b,{id:t},h&&i.createElement(R,{className:qe.group,orientation:"horizontal"},r.map(((e,t)=>{const n=(0,be.getTranslatedResolutionModel)(e);return i.createElement(_,{key:t,role:"radio",className:m(qe.button,{[qe.first]:0===t,[qe.last]:t===r.length-1}),text:i.createElement(Se,{value:n.mayOmitMultiplier?void 0:n.multiplier,metric:n.shortKind}),hint:n.hint,"aria-checked":a===e,isActive:a===e,isDisabled:!c[e]&&e!==o,onClick:this._handeQuickClick,onClickArg:e,"data-value":e})}))),i.createElement(f.MatchMedia,{rule:w.DialogBreakpoints.TabletSmall},(e=>i.createElement(i.Fragment,null,i.createElement(ze.CloseDelegateContext.Provider,{value:Xe},i.createElement(v.ToolbarMenuButton,{arrow:Boolean(h),closeOnClickOutside:!0,content:h||null===u?void 0:i.createElement(b,{className:qe.menuContent},i.createElement(Se,{value:u.mayOmitMultiplier?void 0:u.multiplier,metric:u.shortKind})),hotKey:h?Ge:void 0,className:qe.menu,ref:this._menu,isDrawer:e,onClick:this._trackClick,tooltip:h||null===u?je.timeInterval:u.hint,menuReference:this._menuItemsContainerRef},i.createElement("div",{className:qe.dropdown},this._renderChildren(d,e)))),e&&s&&i.createElement(i.Suspense,{fallback:null},i.createElement(Je,{onAdd:this._handleAddInterval, onClose:this._handleCloseAddIntervalDialog,onUnmount:this._handleCloseAddIntervalDialog}))))))}_createMenuItems(e,t){const a=function(e){const t=Ue(De.ResolutionKind.Ticks),a=Ue(De.ResolutionKind.Seconds),n=Ue(De.ResolutionKind.Minutes),i=Ue(De.SpecialResolutionKind.Hours),o=Ue(De.ResolutionKind.Days),s=Ue(De.ResolutionKind.Range);return e.forEach((e=>{const l=De.Interval.parse(e);l.isMinuteHours()?i.items.push(e):l.isMinutes()?(0,De.isHour)(Number(l.multiplier()))?i.items.push(e):n.items.push(e):l.isSeconds()?a.items.push(e):l.isDWM()?o.items.push(e):l.isRange()?s.items.push(e):l.isTicks()&&t.items.push(e)})),[t,a,n,i,o,s].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===y.PopupMenuSeparator&&(0!==a&&a!==n.length-1||(i=!1),t&&(i=!1)),t=e.type===y.PopupMenuSeparator,i}))}([].concat(...a))}_createIntervalForm(e){if(this._customIntervals){const t=e?i.createElement(et,{key:"add-dialog",onClick:this._handleOpenAddIntervalDialog}):i.createElement(ke,{key:"add-form",onAdd:this._handleAddInterval,onCloseMenu:this._handleCloseMenu,onOpenMenu:this._handleOpenMenu,onSelect:this._updateMenuPosition});return[i.createElement(y.PopupMenuSeparator,{key:"custom-interval-separator"}),t]}return[]}_renderResolutionsGroup(e,t=!1,a){const n=[],o=e.items.map((e=>this._renderPopupMenuItem(e,a)));if(t)n.push(...o);else if(a){const t=i.createElement(tt,{key:e.id,title:e.name},o);n.push(t)}else{const{intervalsMenuViewStateService:t}=this.context,{menuViewState:a}=this.state;if(!t.isAllowed(e.id))return[];const s=i.createElement(Qe,{key:e.id,className:qe.section,summary:e.name,open:!a[e.id],onStateChange:this._getHandleSectionStateChange(e.id)},o);n.push(s)}return(!e.mayOmitSeparator||e.items.length>1)&&(n.unshift(i.createElement(y.PopupMenuSeparator,{key:`begin-${e.name}`})),n.push(i.createElement(y.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:o}=this.state,s=e===n,l=(0,be.isAvailable)(e),r=this._isIntervalFavorite(e),h=this._isIntervalDefault(e),c=(0,be.getTranslatedResolutionModel)(e);return i.createElement(Oe,{key:e,isSmallTablet:t,interval:e,hint:c.hint,isSignaling:o===e,isFavoritingAllowed:a,isDisabled:!l,isFavorite:r,isRemovable:!h,isActive:s,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}}function et(e){ const{onClick:t,className:n}=e;return i.createElement("div",{key:"add-dialog",className:m(qe.addCustomInterval,n),onClick:t},s.t(null,void 0,a(95798))+"…")}function tt(e){const{children:t,title:a,className:n}=e;return i.createElement("div",{className:n},i.createElement("div",{className:qe.smallTabletSectionTitle},a),t)}$e.contextType=Ye;var at=a(23902),nt=a(82436);const it=(0,M.registryContextType)();class ot 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,M.validateRegistry)(t,{isFundamental:o.any,chartWidgetCollection:o.any.isRequired,windowMessageService:o.any.isRequired})}render(){const{className:e}=this.props;return i.createElement(j.ToolbarIconButton,{className:m(e,at.button),icon:nt,onClick:this._handleClick,tooltip:s.t(null,void 0,a(55520))})}}ot.contextType=it;var st=a(48449);const lt=(0,M.registryContextType)();class rt extends i.PureComponent{constructor(e,t){super(e,t),this._handleClick=e=>{const{chartWidgetCollection:t}=this.context,a=t.activeChartWidget.value();(0,V.trackEvent)("GUI","Chart Header Toolbar","chart properties"),a.showGeneralChartProperties(void 0,{shouldReturnFocus:(0,Z.isKeyboardClick)(e)})},(0,M.validateRegistry)(t,{chartWidgetCollection:o.any.isRequired})}render(){return i.createElement(j.ToolbarIconButton,{...this.props,icon:st,onClick:this._handleClick,tooltip:s.t(null,void 0,a(74207))})}}rt.contextType=lt;var ht=a(4741),ct=a(93352),dt=a(40173),ut=a(69297),vt=a(20461);(0,dt.mergeThemes)(ut.DEFAULT_MENU_ITEM_SWITCHER_THEME,vt);var mt=a(53180),pt=a(70152);function gt(e){const{wasChanges:t,isSaving:n,className:o}=e;return i.createElement("span",{className:m(pt.saveString,!t&&!n&&pt.hidden,o)},n?i.createElement(se.Loader,{className:pt.loader,size:"small",staticPosition:!0}):s.t(null,void 0,a(85520)))}var bt=a(36296),Ct=a(63672),St=a(92998);a(40670);const _t=n.enabled("widget"),yt=s.t(null,void 0,a(75789)),ft=(0,dt.mergeThemes)(P.DEFAULT_TOOL_WIDGET_BUTTON_THEME,St),wt=(0,dt.mergeThemes)(u.DEFAULT_POPUP_MENU_ITEM_THEME,{shortcut:Ct.shortcut,withIcon:Ct.withIcon}),Et=s.t(null,void 0,a(80959)),Mt=s.t(null,void 0,a(11680)),kt=[],Tt=(0,G.hotKeySerialize)({keys:[(0,Y.humanReadableModifiers)(Y.Modifiers.Mod,!1),"S"],text:"{0} + {1}"});class xt extends i.PureComponent{constructor(e){super(e),this._copyElRef=i.createRef(),this._handleCopyLinkClick=()=>Promise.resolve(),this._handleCloneClick=()=>{var e,t;null===(t=(e=this.props).onCloneChart)||void 0===t||t.call(e)},this._handleSaveClick=()=>{var e,t;null===(t=(e=this.props).onSaveChart)||void 0===t||t.call(e),this._trackClick()},this._handleSaveAsClick=()=>{var e,t;null===(t=(e=this.props).onSaveAsChart)||void 0===t||t.call(e)},this.state={isSaving:!1}}componentDidUpdate(e,t){ e.isProcessing&&!this.props.isProcessing&&(clearTimeout(this._timeout),this._timeout=void 0,this.setState({isSaving:!1})),!e.isProcessing&&this.props.isProcessing&&(this._timeout=setTimeout((()=>{this.setState({isSaving:!0})}),1e3))}componentWillUnmount(){this._timeout&&clearTimeout(this._timeout)}render(){const{id:e,isReadOnly:t,displayMode:n,isProcessing:o,title:l,wasChanges:r,hideMenu:h,isTabletSmall:c,onOpenMenu:u,dataNameSaveMenu:p}=this.props,g=!t&&!h,C=!(r||!l||this.state.isSaving),S=i.createElement("div",{className:Ct.textWrap},i.createElement("span",{className:Ct.text},l||s.t(null,void 0,a(85520))),i.createElement(gt,{isSaving:this.state.isSaving,wasChanges:r}));return i.createElement(b,null,t?i.createElement(b,null,i.createElement(z,{id:e,displayMode:n,icon:i.createElement(d.Icon,{icon:bt}),isDisabled:o,onClick:this._handleCloneClick,text:s.t(null,void 0,a(35216)),collapseWhen:kt,tooltip:Et})):i.createElement(b,null,i.createElement(z,{id:e,className:m(Ct.button,g&&Ct.buttonSmallPadding),displayMode:n,"aria-disabled":!!C||void 0,isDisabled:o,onClick:C?void 0:this._handleSaveClick,text:S,theme:ft,collapseWhen:kt,tooltip:C?s.t(null,void 0,a(88368)):s.t(null,void 0,a(87409)),"data-tooltip-hotkey":_t||C?"":Tt}),g&&i.createElement(v.ToolbarMenuButton,{"data-name":p,arrow:!0,isDrawer:c,drawerPosition:"Bottom",onClick:this._trackClick,onOpen:u,tooltip:s.t(null,void 0,a(58219))},this._renderMenuItems(Boolean(c)))))}_renderMenuItems(e){const{wasChanges:t,isProcessing:n,chartId:o,onSaveChartFromMenu:l,onRenameChart:r,onLoadChart:h,onNewChart:c,isAutoSaveEnabled:d,autoSaveId:v,sharingId:p,onAutoSaveChanged:g,isSharingEnabled:b,onSharingChanged:C,layoutItems:S,onExportData:_,isAuthenticated:f}=this.props,w=e?E.multilineLabelWithIconAndToolboxTheme:wt,M=e?void 0:(0,Y.humanReadableHash)(Y.Modifiers.Mod+83),k=e?void 0:s.t(null,{context:"hotkey"},a(14229)),T=[];return T.push(i.createElement(u.PopupMenuItem,{key:"save",isDisabled:Boolean(n||!t&&o),label:Mt,onClick:l,shortcut:M,labelRowClassName:m(e&&Ct.popupItemRowTabletSmall),theme:w,"data-name":"save-load-menu-item-save"})),void 0!==o&&T.push(i.createElement(u.PopupMenuItem,{key:"rename",icon:void 0,label:(0,mt.appendEllipsis)(s.t(null,void 0,a(35038))),onClick:r,labelRowClassName:m(e&&Ct.popupItemRowTabletSmall),theme:w,"data-name":"save-load-menu-item-rename"}),i.createElement(u.PopupMenuItem,{key:"save-as",icon:void 0,label:(0,mt.appendEllipsis)(Et),onClick:this._handleSaveAsClick,labelRowClassName:m(e&&Ct.popupItemRowTabletSmall),theme:w,"data-name":"save-load-menu-item-clone"})),T.push(i.createElement(y.PopupMenuSeparator,{key:"all-layouts-separator"}),i.createElement(u.PopupMenuItem,{key:"all-layouts",className:"js-save-load-menu-item-load-chart",label:(0,mt.appendEllipsis)(yt),onClick:h,labelRowClassName:m(e&&Ct.popupItemRowTabletSmall),theme:w,shortcut:k,"data-name":"save-load-menu-item-load"})),T}_trackClick(){0}}const It=(0,M.registryContextType)();class At extends i.PureComponent{constructor(e,t){super(e,t),this._exportDialogPromise=null, this._layoutsAbortController=null,this._requestRecentLayouts=()=>{},this._handleExportData=()=>{0},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._handleOpenMenu=()=>{this._requestRecentLayouts()},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,M.validateRegistry)(t,{chartWidgetCollection:o.any.isRequired,chartChangesWatcher:o.any.isRequired,saveChartService:o.any.isRequired,sharingChartService:o.any,loadChartService:o.any.isRequired});const{chartWidgetCollection:a,chartChangesWatcher:n,saveChartService:i,sharingChartService:s}=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:n}=this.props,{chartWidgetCollection:i,chartChangesWatcher:o,saveChartService:l,sharingChartService:r}=this.context;t?n.on("change",this._syncState):(o.getOnChange().subscribe(this,this._onChangeHasChanges),i.metaInfo.name.subscribe(this._onChangeTitle),i.metaInfo.id.subscribe(this._onChangeId),this._hotkeys=(0,ht.createGroup)({desc:"Save/Load"}),this._hotkeys.add({desc:s.t(null,void 0,a(75687)),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(){var e;const{chartSaver:t,isFake:a,stateSyncEmitter:n}=this.props,{chartWidgetCollection:i,chartChangesWatcher:o,saveChartService:s,sharingChartService:l}=this.context;a?n.off("change",this._syncState):(o.getOnChange().unsubscribe(this,this._onChangeHasChanges),i.metaInfo.name.unsubscribe(this._onChangeTitle), i.metaInfo.id.unsubscribe(this._onChangeId),(0,te.ensureDefined)(this._hotkeys).destroy(),t.chartSaved().unsubscribe(this,this._onChartSaved),t.chartAboutToBeSaved().unsubscribe(this,this._onChartAboutToBeSaved),window.loginStateChange.unsubscribe(this,this._onLoginStateChange),null===(e=this._layoutsAbortController)||void 0===e||e.abort())}render(){const{isReadOnly:e,displayMode:t,id:a,isFake:n}=this.props,{isProcessing:o,isAuthenticated:s,title:l,id:r,wasChanges:h,isAutoSaveEnabled:c,isSharingEnabled:d,recentLayouts:u}=this.state,v={displayMode:t,isReadOnly:e,isAuthenticated:s,isProcessing:o,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:w.DialogBreakpoints.TabletSmall},(e=>i.createElement(xt,{...v,isTabletSmall:e})))}_onLoginStateChange(){this.setState({isAuthenticated:window.is_authenticated})}_trackEvent(e){0}}At.contextType=It;var Rt=a(53166),Nt=a(34928),Ft=a(79982);const Ht=new Nt.DateTimeFormatter({dateTimeSeparator:"_",timeFormat:"%h-%m-%s"}),Lt={takeSnapshot:s.t(null,void 0,a(88513))},Ot=(0,M.registryContextType)();const Dt=s.t(null,void 0,a(90879));function Pt(e,t,a){return async function(e,t,a){const n=URL.createObjectURL(new Blob([`