(self.webpackChunktradingview=self.webpackChunktradingview||[]).push([[5516,9685],{49107:e=>{e.exports={loader:"loader-UL6iwcBa",static:"static-UL6iwcBa",item:"item-UL6iwcBa","tv-button-loader":"tv-button-loader-UL6iwcBa",medium:"medium-UL6iwcBa",small:"small-UL6iwcBa",black:"black-UL6iwcBa",white:"white-UL6iwcBa",gray:"gray-UL6iwcBa",primary:"primary-UL6iwcBa"}},47282:e=>{e.exports={small:"small-CtnpmPzP",medium:"medium-CtnpmPzP",large:"large-CtnpmPzP",switchView:"switchView-CtnpmPzP",checked:"checked-CtnpmPzP",disabled:"disabled-CtnpmPzP",track:"track-CtnpmPzP",thumb:"thumb-CtnpmPzP"}},70330:e=>{e.exports={switcher:"switcher-fwE97QDf",input:"input-fwE97QDf",thumbWrapper:"thumbWrapper-fwE97QDf",disabled:"disabled-fwE97QDf",checked:"checked-fwE97QDf"}},77579:e=>{e.exports={labelRow:"labelRow-_uXjSSQ5",toolbox:"toolbox-_uXjSSQ5",description:"description-_uXjSSQ5",descriptionTabletSmall:"descriptionTabletSmall-_uXjSSQ5",item:"item-_uXjSSQ5",titleItem:"titleItem-_uXjSSQ5",remove:"remove-_uXjSSQ5",active:"active-_uXjSSQ5",titleItemTabletSmall:"titleItemTabletSmall-_uXjSSQ5",itemTabletSmall:"itemTabletSmall-_uXjSSQ5",itemLabelTabletSmall:"itemLabelTabletSmall-_uXjSSQ5",wrap:"wrap-_uXjSSQ5",hovered:"hovered-_uXjSSQ5"}},1560:e=>{e.exports={footer:"footer-dwINHZFL"}},9959:e=>{e.exports={item:"item-zwyEh4hn",label:"label-zwyEh4hn",labelRow:"labelRow-zwyEh4hn",toolbox:"toolbox-zwyEh4hn"}},40359:e=>{e.exports={separator:"separator-QjUlCDId",small:"small-QjUlCDId",normal:"normal-QjUlCDId",large:"large-QjUlCDId"}},17946:(e,t,a)=>{"use strict";a.d(t,{CustomBehaviourContext:()=>n});const n=(0,a(50959).createContext)({enableActiveStateStyles:!0});n.displayName="CustomBehaviourContext"},125:(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}},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}},26996:(e,t,a)=>{"use strict";a.d(t,{Loader:()=>c});var n,i=a(50959),o=a(97754),s=a.n(o),l=a(49107),r=a.n(l);function c(e){const{className:t,size:a="medium",staticPosition:n,color:o="black"}=e,l=s()(r().item,r()[o],r()[a]);return i.createElement("span",{className:s()(r().loader,n&&r().static,t)},i.createElement("span",{className:l}),i.createElement("span",{className:l}),i.createElement("span",{className:l}))}!function(e){e.Medium="medium",e.Small="small"}(n||(n={}))},39362:(e,t,a)=>{"use strict";a.d(t,{SymbolSearchDialogFooter:()=>l});var n=a(50959),i=a(97754),o=a.n(i),s=a(1560);function l(e){const{className:t,children:a}=e;return n.createElement("div",{className:o()(s.footer,t)},a)}},46043:(e,t,a)=>{"use strict";a.d(t,{useForceUpdate:()=>n.useForceUpdate});var n=a(125)},81332:(e,t,a)=>{"use strict";a.d(t,{multilineLabelWithIconAndToolboxTheme:()=>s});var n=a(40173),i=a(17888),o=a(9959);const s=(0,n.mergeThemes)(i,o)},51613:(e,t,a)=>{"use strict";a.d(t,{PopupMenuSeparator:()=>r});var n,i=a(50959),o=a(97754),s=a.n(o),l=a(40359);function r(e){ const{size:t="normal",className:a,ariaHidden:n=!1}=e;return i.createElement("div",{className:s()(l.separator,"small"===t&&l.small,"normal"===t&&l.normal,"large"===t&&l.large,a),role:"separator","aria-hidden":n})}!function(e){e.Small="small",e.Large="large",e.Normal="normal"}(n||(n={}))},40173:(e,t,a)=>{"use strict";function n(e,t,a={}){return Object.assign({},e,function(e,t,a={}){const n=Object.assign({},t);for(const i of Object.keys(t)){const o=a[i]||i;o in e&&(n[i]=[e[o],t[i]].join(" "))}return n}(e,t,a))}a.d(t,{mergeThemes:()=>n})},70596:e=>{e.exports={summary:"summary-ynHBVe1n",hovered:"hovered-ynHBVe1n",caret:"caret-ynHBVe1n"}},26978:e=>{e.exports={item:"item-KMkDzD5K",accessible:"accessible-KMkDzD5K",round:"round-KMkDzD5K",active:"active-KMkDzD5K"}},41110:e=>{e.exports={accessible:"accessible-raQdxQp0"}},59703:e=>{e.exports={button:"button-LkmyTVRc",active:"active-LkmyTVRc"}},16284:e=>{e.exports={wrapper:"wrapper-psOC5oyI",labelRow:"labelRow-psOC5oyI",label:"label-psOC5oyI",labelHint:"labelHint-psOC5oyI",labelOn:"labelOn-psOC5oyI"}},57213:e=>{e.exports={wrapper:"wrapper-bl9AR3Gv",hovered:"hovered-bl9AR3Gv",switchWrap:"switchWrap-bl9AR3Gv",withIcon:"withIcon-bl9AR3Gv",labelRow:"labelRow-bl9AR3Gv",label:"label-bl9AR3Gv",icon:"icon-bl9AR3Gv",label_disabled:"label_disabled-bl9AR3Gv",labelHint:"labelHint-bl9AR3Gv",labelOn:"labelOn-bl9AR3Gv",accessible:"accessible-bl9AR3Gv"}},11064:e=>{e.exports={button:"button-Y1TCZogJ",active:"active-Y1TCZogJ"}},83157:e=>{e.exports={button:"button-ptpAHg8E",withText:"withText-ptpAHg8E",withoutText:"withoutText-ptpAHg8E"}},8645:e=>{e.exports={spinnerWrap:"spinnerWrap-cZT0OZe0"}},79619:e=>{e.exports={title:"title-u3QJgF_p"}},35765:e=>{e.exports={wrap:"wrap-n5bmFxyX"}},11306:e=>{e.exports={hidden:"hidden-5MVS18J8"}},51097:e=>{e.exports={"tablet-small-breakpoint":"(max-width: 440px)",item:"item-o5a0MQMm",withIcon:"withIcon-o5a0MQMm",shortcut:"shortcut-o5a0MQMm",loading:"loading-o5a0MQMm",icon:"icon-o5a0MQMm"}},42020:e=>{e.exports={button:"button-b3Cgff6l",group:"group-b3Cgff6l",menu:"menu-b3Cgff6l",betaBadge:"betaBadge-b3Cgff6l",newBadge:"newBadge-b3Cgff6l",label:"label-b3Cgff6l"}},32597:e=>{e.exports={customTradingViewStyleButton:"customTradingViewStyleButton-zigjK1n2",withoutIcon:"withoutIcon-zigjK1n2"}},44404:e=>{e.exports={dropdown:"dropdown-l0nf43ai",label:"label-l0nf43ai",smallWidthTitle:"smallWidthTitle-l0nf43ai",smallWidthMenuItem:"smallWidthMenuItem-l0nf43ai",smallWidthWrapper:"smallWidthWrapper-l0nf43ai"}},33759:e=>{e.exports={value:"value-gwXludjS",selected:"selected-gwXludjS"}},58839:e=>{e.exports={smallWidthMenuItem:"smallWidthMenuItem-RmqZNwwp",menuItem:"menuItem-RmqZNwwp",remove:"remove-RmqZNwwp",signal:"signal-RmqZNwwp","highlight-animation":"highlight-animation-RmqZNwwp"}},9899:e=>{e.exports={button:"button-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",desktop:"desktop-S_1OCXUK", group:"group-S_1OCXUK"}},41111:e=>{e.exports={button:"button-gn9HMufu"}},32707:e=>{e.exports={button:"button-ZuDkGGhF",isDisabled:"isDisabled-ZuDkGGhF"}},23568:e=>{e.exports={saveString:"saveString-XVd1Kfjg",hidden:"hidden-XVd1Kfjg",loader:"loader-XVd1Kfjg"}},71837:e=>{e.exports={menuBtnWrap:"menuBtnWrap-yyMUOAN9",menu:"menu-yyMUOAN9",hintPlaceholder:"hintPlaceholder-yyMUOAN9",hintWrapper:"hintWrapper-yyMUOAN9",hintText:"hintText-yyMUOAN9",hintButton:"hintButton-yyMUOAN9",hintButtons:"hintButtons-yyMUOAN9",hintAdditionalButton:"hintAdditionalButton-yyMUOAN9",opened:"opened-yyMUOAN9",hover:"hover-yyMUOAN9",clicked:"clicked-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",toolbox:"toolbox-yyMUOAN9",toolboxSmall:"toolboxSmall-yyMUOAN9",layoutTitle:"layoutTitle-yyMUOAN9",layoutItemWrap:"layoutItemWrap-yyMUOAN9",layoutItemWrapSmall:"layoutItemWrapSmall-yyMUOAN9",layoutTitleSmall:"layoutTitleSmall-yyMUOAN9",textWrap:"textWrap-yyMUOAN9",text:"text-yyMUOAN9",withIcon:"withIcon-yyMUOAN9",sharingLabelWrap:"sharingLabelWrap-yyMUOAN9",titleSharingLabel:"titleSharingLabel-yyMUOAN9",switcherLabel:"switcherLabel-yyMUOAN9",iconWrap:"iconWrap-yyMUOAN9",infoIcon:"infoIcon-yyMUOAN9",accessibleLabel:"accessibleLabel-yyMUOAN9"}},81890:e=>{e.exports={button:"button-cq__ntSC",smallLeftPadding:"smallLeftPadding-cq__ntSC",text:"text-cq__ntSC",uppercase:"uppercase-cq__ntSC"}},54914:e=>{e.exports={description:"description-jgoQcEnP"}},90470: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"}},63591:e=>{e.exports={menu:"menu-hcofKPms",menuSmallTablet:"menuSmallTablet-hcofKPms",menuItemHeaderTabletSmall:"menuItemHeaderTabletSmall-hcofKPms",menuItemHeader:"menuItemHeader-hcofKPms"}},9952:e=>{e.exports={wrap:"wrap-jiC5bgmi",full:"full-jiC5bgmi",first:"first-jiC5bgmi",last:"last-jiC5bgmi",medium:"medium-jiC5bgmi",buttonWithFavorites:"buttonWithFavorites-jiC5bgmi"}},97045:e=>{e.exports={icon:"icon-uMfL97K2"}},13067:(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(70596);const r=(0,n.forwardRef)((function(e,t){const{open:a,summary:i,children:r,onStateChange:c,tabIndex:h,className:d,...u}=e;return n.createElement(n.Fragment,null,n.createElement("div",{...u,className:o()(d,l.summary),onClick:function(){c&&c(!a)},"data-open":a,"aria-expanded":a,ref:t,tabIndex:h},i,n.createElement(s.ToolWidgetCaret,{className:l.caret,dropped:Boolean(a)})),a&&r)}))}, 23484:(e,t,a)=>{"use strict";a.d(t,{MenuFavoriteButton:()=>h});var n=a(50959),i=a(97754),o=a.n(i),s=a(50238),l=a(36189),r=a(71402),c=a(59703);function h(e){const{onClick:t,isFilled:a,isActive:i,...h}=e,[d,u]=(0,s.useRovingTabindexElement)(null),m=a?r.removeTitlesMap[r.RemoveTitleType.Remove]:r.removeTitlesMap[r.RemoveTitleType.Add];return(0,n.useLayoutEffect)((()=>{const e=d.current;e instanceof HTMLElement&&e.dispatchEvent(new CustomEvent("common-tooltip-update"))}),[m,d]),n.createElement("button",{ref:d,tabIndex:u,onClick:t,className:o()(c.button,i&&c.active,"apply-common-tooltip"),type:"button","aria-label":m,"data-tooltip":m},n.createElement(l.FavoriteButton,{...h,isFilled:a,isActive:i,title:""}))}},74302:(e,t,a)=>{"use strict";a.d(t,{DEFAULT_MENU_ITEM_SWITCHER_THEME:()=>_,MenuItemSwitcher:()=>y});var n,i=a(50959),o=a(97754),s=a.n(o),l=a(17946),r=a(47282),c=a.n(r);function h(e){const{size:t="small",checked:a,disabled:n}=e;return i.createElement("span",{className:s()(c().switchView,c()[t],n&&c().disabled,a&&c().checked)},i.createElement("span",{className:c().track}),i.createElement("span",{className:c().thumb}))}!function(e){e.Small="small",e.Medium="medium",e.Large="large"}(n||(n={}));var d,u=a(3343),m=a(70330),v=a.n(m);function p(e){const t=(0,i.useContext)(l.CustomBehaviourContext),{size:a,intent:n="default",checked:o,className:r,enableActiveStateStyles:c=t.enableActiveStateStyles,disabled:d,onChange:m,title:p,id:g,name:b,value:S,tabIndex:C,role:_="switch",ariaDisabled:y,reference:w,ariaLabelledBy:f,ariaLabel:T,...E}=e;return i.createElement("span",{className:s()(r,v().switcher)},i.createElement("input",{...E,type:"checkbox",className:s()(v().input,c&&v().activeStylesEnabled,o&&v().checked,d&&v().disabled),role:_,"aria-checked":o,checked:o,onKeyDown:e=>{13===(0,u.hashFromEvent)(e)&&e.currentTarget?.click()},onChange:m,disabled:d,"aria-disabled":y,tabIndex:C,title:p,id:g,name:b,value:S,ref:w,"aria-label":T,"aria-labelledby":f}),i.createElement("span",{className:s()(v().thumbWrapper,v()[n])},i.createElement(h,{checked:o,size:a,disabled:d})))}!function(e){e.Default="default",e.Select="select"}(d||(d={}));var g=a(9745),b=a(50238),S=a(90186),C=a(57213);const _=C;function y(e){const{role:t,checked:a,onChange:n,className:o,id:l,label:r,labelDescription:c,preventLabelHighlight:h,value:d,reference:m,switchReference:v,theme:_=C,disabled:y,switchRole:w,icon:f}=e,[T,E]=(0,b.useRovingTabindexElement)(null),k=s()(_.label,a&&!h&&_.labelOn,y&&C.label_disabled),M=s()(o,_.wrapper,a&&_.wrapperWithOnLabel,c&&_.wrapperWithDescription);return i.createElement("label",{role:t,className:s()(M,f&&_.withIcon,C.accessible),htmlFor:l,ref:m,onKeyDown:function(e){if(e.target!==e.currentTarget)return;const t=(0,u.hashFromEvent)(e);13!==t&&32!==t||(e.preventDefault(),T.current instanceof HTMLElement&&T.current.click())},tabIndex:E,"data-role":"menuitem","aria-disabled":y||void 0,"aria-selected":a},void 0!==f&&i.createElement(g.Icon,{className:_.icon,icon:f}),i.createElement("div",{className:_.labelRow},i.createElement("div",{className:k },r),c&&i.createElement("div",{className:_.labelHint},c)),i.createElement("div",{className:C.switchWrap},i.createElement(p,{disabled:y,className:_.switch,reference:function(e){T(e),v?.(e)},checked:a,onChange:function(e){const t=e.target.checked;void 0!==n&&n(t)},value:d,tabIndex:-1,id:l,role:w,ariaDisabled:!0,...(0,S.filterDataProps)(e)})))}},31398:(e,t,a)=>{"use strict";a.d(t,{menuItemSwitcherMobileTheme:()=>s});var n=a(40173),i=a(74302),o=a(16284);const s=(0,n.mergeThemes)(i.DEFAULT_MENU_ITEM_SWITCHER_THEME,o)},62576:(e,t,a)=>{"use strict";a.d(t,{MenuRemoveButton:()=>d});var n=a(50959),i=a(97754),o=a.n(i),s=a(11542),l=a(50238),r=a(96040),c=a(60925),h=a(11064);function d(e){const{onClick:t,isActive:i,onKeyDown:d,...u}=e,[m,v]=(0,l.useRovingTabindexElement)(null);return n.createElement("button",{ref:m,tabIndex:v,onClick:t,onKeyDown:d,className:o()(h.button,i&&h.active,"apply-common-tooltip"),"aria-label":s.t(null,void 0,a(67410)),"data-tooltip":s.t(null,void 0,a(67410)),type:"button"},n.createElement(r.RemoveButton,{...u,isActive:i,title:"",icon:c}))}},43845:(e,t,a)=>{"use strict";a.d(t,{ToolWidgetMenuSummary:()=>s});var n=a(50959),i=a(97754),o=a(79619);function s(e){return n.createElement("div",{className:i(e.className,o.title)},e.children)}},40610:(e,t,a)=>{"use strict";a.d(t,{DEFAULT_TOOLBAR_BUTTON_THEME:()=>s,ToolbarButton:()=>l});var n=a(50959),i=a(46003),o=a(50238);const s=i.DEFAULT_TOOL_WIDGET_BUTTON_THEME,l=(0,n.forwardRef)((function(e,t){const{tooltip:a,...s}=e,[l,r]=(0,o.useRovingTabindexElement)(t);return n.createElement(i.ToolWidgetButton,{"aria-label":a,...s,tag:"button",ref:l,tabIndex:r,"data-tooltip":a})}))},58169:(e,t,a)=>{"use strict";a.d(t,{ToolbarIconButton:()=>l});var n=a(50959),i=a(50238),o=a(21618);const s=(0,n.forwardRef)((function(e,t){const{tooltip:a,...i}=e;return n.createElement(o.ToolWidgetIconButton,{"aria-label":a,...i,tag:"button",ref:t,"data-tooltip":a,"data-tooltip-show-on-focus":"true"})})),l=(0,n.forwardRef)((function(e,t){const[a,o]=(0,i.useRovingTabindexElement)(t);return n.createElement(s,{...e,ref:a,tabIndex:o})}))},34788:(e,t,a)=>{"use strict";a.d(t,{ToolbarMenuButton:()=>h});var n=a(50959),i=a(39416),o=a(50238),s=a(99247),l=a(54374),r=a(73607);const c=(0,n.forwardRef)((function(e,t){const{tooltip:a,tag:o,buttonRef:s,reference:c,...h}=e,d=(0,i.useFunctionalRefObject)(c??null);return n.createElement(l.ToolWidgetMenu,{"aria-label":a,...h,ref:t,tag:o??"button",reference:s??d,"data-tooltip":a,onMenuKeyDown:r.handleAccessibleMenuKeyDown,onMenuFocus:e=>(0,r.handleAccessibleMenuFocus)(e,s??d)})})),h=(0,n.forwardRef)((function(e,t){const{tooltip:a,menuReference:l=null,...r}=e,[h,d]=(0,o.useRovingTabindexElement)(null),u=(0,i.useFunctionalRefObject)(l);return n.createElement(c,{"aria-label":a,"aria-haspopup":"menu",...s.MouseClickAutoBlurHandler.attributes(),...r,ref:t,tag:"button",buttonRef:h,tabIndex:d,menuReference:u,tooltip:a})}))},92024:(e,t,a)=>{"use strict";a.r(t),a.d(t,{getRestrictedToolSet:()=>rn}) ;var n=a(37103),i=a(50959),o=a(19036),s=a(9745),l=a(11542),r=a(29803),c=a(82095),h=a(99678),d=a(34788),u=a(97754),m=a.n(u),v=a(35765);const p=i.forwardRef(((e,t)=>{const{children:a,className:n,...o}=e;return i.createElement("div",{className:u(n,v.wrap),ref:t,...o},a)}));var g=a(40610);class b 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,onClick:l,onClickArg:r,...c}=this.props;return i.createElement(g.ToolbarButton,{...c,icon:t,text:n,tooltip:a,isDisabled:o,isActive:s,isGrouped:!0,onClick:this._handleClick,className:e})}}var S=a(51613),C=a(90692),_=a(73986),y=a(81332),w=a(68976),f=a(54370),T=a(95059),E=a(47201),k=a(3343),M=a(22692),x=a(15754);function I(e){const{orientation:t,onKeyDown:a,...n}=e;return i.createElement("div",{...n,role:"radiogroup","aria-orientation":t,onKeyDown:(0,E.createSafeMulticastEventHandler)((function(e){if(e.defaultPrevented)return;if(!(document.activeElement instanceof HTMLElement))return;const a=(0,k.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]):not([aria-disabled])')).filter((0,x.createScopedVisibleElementFilter)(i))).sort(M.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 R=a(90397),A=a(23484),N=a(42020);const F=(0,w.registryContextType)();function O(e){return!r.linking.supportedChartStyles.value()?.includes(e)}const H="ITEMS_DIVIDER",U=[[0,1,9,19,21],[2,14,15],[3,16,10],[13,12],[17,18,20],[8,4,7,5,6,11]];new Set([]),new Set([]);class D 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,w.validateRegistry)(t,{chartWidgetCollection:o.any.isRequired,favoriteChartStylesService:o.any.isRequired}) ;const{chartWidgetCollection:a,favoriteChartStylesService:n}=t,i=a.activeChartStyle.value(),s=n.get(),l=new Set((0,f.allChartStyles)());this.state={activeStyle:i,favorites:s,styles:U.reduce(((e,t)=>{const a=t.filter((e=>l.has(e)));return a.length&&(e.length&&a.unshift(H),e.push(...a)),e}),[])}}componentDidMount(){const{chartWidgetCollection:e,favoriteChartStylesService:t}=this.context;e.activeChartStyle.subscribe(this._handleChangeStyle),t.getOnChange().subscribe(this,this._handleChangeSettings),r.linking.supportedChartStyles.subscribe(this._boundForceUpdate)}componentWillUnmount(){const{chartWidgetCollection:e,favoriteChartStylesService:t}=this.context;e.activeChartStyle.unsubscribe(this._handleChangeStyle),t.getOnChange().unsubscribe(this,this._handleChangeSettings),r.linking.supportedChartStyles.unsubscribe(this._boundForceUpdate)}render(){const{isShownQuicks:e,displayMode:t="full",id:n}=this.props,{activeStyle:o,favorites:r,styles:u,lastSelectedNotFavorite:m}=this.state,v="small"!==t&&e&&0!==r.length,g=[...r];g.includes(o)?void 0!==m&&g.push(m):g.push(o);const y=v&&g.length>1;return i.createElement(C.MatchMedia,{rule:_.DialogBreakpoints.TabletSmall},(e=>{const t=u.map(((t,a)=>t===H?i.createElement(S.PopupMenuSeparator,{key:`separator-${a}`}):this._renderPopupMenuItem(t,t===o,e)));return i.createElement(p,{id:n},y&&i.createElement(I,{orientation:"horizontal",className:N.group},g.map(((e,t)=>i.createElement(b,{role:"radio",className:N.button,icon:h.SERIES_ICONS[e],"aria-checked":v&&o===e,isActive:v&&o===e,isDisabled:O(e),key:t,hint:(0,T.getTranslatedChartStyleName)(e),onClick:v?this._handleQuickClick:void 0,onClickArg:e,"data-value":c.STYLE_SHORT_NAMES[e]})))),i.createElement(d.ToolbarMenuButton,{arrow:Boolean(y),content:y?void 0:i.createElement(p,null,i.createElement(s.Icon,{icon:h.SERIES_ICONS[o]})),tooltip:y?l.t(null,void 0,a(27246)):(0,T.getTranslatedChartStyleName)(o),className:N.menu,isDrawer:e,onClick:this._trackClick,menuRole:"treegrid"},t))}))}_renderPopupMenuItem(e,t,a){const{isFavoritingAllowed:n}=this.props,o=this._isStyleFavorited(e);return i.createElement(R.AccessibleMenuItem,{key:`chart-type-${e}`,role:"row",theme:a?y.multilineLabelWithIconAndToolboxTheme:void 0,icon:h.SERIES_ICONS[e],isActive:t,"aria-selected":t,isDisabled:O(e),label:i.createElement("div",{className:N.label},(0,T.getTranslatedChartStyleName)(e)||"",!1,!1),onClick:this._handleSelectStyle,onClickArg:e,showToolboxOnHover:!o,showToolboxOnFocus:!0,toolbox:n&&i.createElement(A.MenuFavoriteButton,{isActive:t,isFilled:o,onClick:()=>this._handleClickFavorite(e)}),"data-value":c.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}}D.contextType=F ;var L=a(50238),W=a(46003),z=a(83157);const P=["medium","small"],B=(0,i.forwardRef)((function(e,t){const{text:a,className:n,displayMode:o,collapseWhen:s=P,...l}=e,r=!s.includes(o);return i.createElement(W.ToolWidgetButton,{...l,ref:t,text:r?a:void 0,className:u(n,z.button,r?z.withText:z.withoutText)})}));function V(e){const{tooltip:t,...a}=e,[n,o]=(0,L.useRovingTabindexElement)(null);return i.createElement(B,{"aria-label":t,...a,tag:"button",tabIndex:o,ref:n,"data-tooltip":t})}var K=a(51768),Z=a(76460),j=a(1393);const q=(0,w.registryContextType)();class Q extends i.PureComponent{constructor(e,t){super(e,t),this._updateState=e=>{this.setState({isActive:e})},this._handleClick=e=>{(0,K.trackEvent)("GUI","Chart Header Toolbar","compare"),this._compareDialogRenderer?.show({shouldReturnFocus:(0,Z.isKeyboardClick)(e)})},(0,w.validateRegistry)(t,{chartWidgetCollection:o.any.isRequired}),this.state={isActive:!1},this._compareDialogRenderer=this.context.chartWidgetCollection.getCompareDialogRenderer()}componentDidMount(){this._compareDialogRenderer?.visible().subscribe(this._updateState)}componentWillUnmount(){this._compareDialogRenderer?.visible().unsubscribe(this._updateState)}render(){const{isActive:e}=this.state;return i.createElement(V,{...this.props,icon:j,isOpened:e,onClick:this._handleClick,collapseWhen:["full","medium","small"],tooltip:l.t(null,void 0,a(53942)),"aria-haspopup":"dialog"})}}Q.contextType=q;var X=a(69830),G=a(50151),$=a(16396),J=a(73607),Y=a(61814),ee=a(72972);const te=(0,a(9343).getLogger)("FavoritesInfo");function ae(e){if(0===e.length)return Promise.resolve([]);te.logNormal("Requesting favorites info");const t=[],a=new Map,n=new Map,i=new Map;return e.forEach((e=>{switch(e.type){case"java":i.set(e.studyId,e);break;case"pine":isPublishedPineId(e.pineId)?a.set(e.pineId,e):n.set(e.pineId,e);break;default:(0,G.assert)(!1,`unknown favorite type ${JSON.stringify(e)}`)}})),0!==i.size&&t.push((0,ee.studyMetaInfoRepository)().findAllJavaStudies().then((e=>{const t=new Map;for(const a of e)!a.is_hidden_study&&i.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}(i,e);if(0!==t.notFoundItems.length){const e=t.notFoundItems.map((e=>e.studyId));te.logWarn(`Cannot find java scripts: ${JSON.stringify(e)}`)}return t.items}))),Promise.all(t).then((e=>(te.logNormal("Requesting favorites info finished"),e.reduce(((e,t)=>e.concat(t)),[]))))}var ne=a(26610),ie=a(78861),oe=a(26996),se=a(8645);function le(e){const{className:t}=e;return i.createElement("div",{className:m()(se.spinnerWrap,t)},i.createElement(oe.Loader,null))}var re=a(43845),ce=a(76422),he=a(39681),de=a(44404);const ue=(0,Y.hotKeySerialize)({keys:["/"],text:"{0}"}),me=(0,w.registryContextType)();class ve extends i.PureComponent{constructor(e,t){super(e,t),this._promise=null,this._menu=i.createRef(), this._menuItemsContainer=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,G.ensureDefined)(e),this._trackFavoriteAction("Favorite indicator from toolbar");"java"===e.type?e.studyId:e.pineId;(async()=>{e=(0,G.ensureDefined)(e);const{chartWidgetCollection:t}=this.context;if("java"===e.type){const t=(0,ne.tryFindStudyLineToolNameByStudyId)(e.studyId);if(null!==t)return await(0,ne.initLineTool)(t),void ie.tool.setValue(t)}t.activeChartWidget.value().insertStudy(e,[])})()},this._handleFavoriteIndicatorsChange=()=>{const{favoriteScriptsModel:e}=this.context,t=[...(0,G.ensureDefined)(e).favorites()];this.setState({favorites:t}),this._clearCache()},this._handleFavoriteFundamentalsChange=()=>{const e=new Set(this._favoriteFundamentalsModel?.favorites()||[]);this.setState({favoriteFundamentals:e}),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,w.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:s,displayMode:r,id:c}=this.props,{chartWidgetCollection:h}=this.context;return i.createElement(i.Fragment,null,i.createElement(p,{id:c,onMouseEnter:this._handleMouseEnter,onClick:this._handleWrapClick},i.createElement(V,{displayMode:r,className:s,icon:he,isOpened:e,onClick:this._handleClick,text:l.t(null,void 0,a(84549)),"data-role":"button", "data-name":"open-indicators-dialog",tooltip:l.t(null,void 0,a(62005)),"data-tooltip-hotkey":ue,collapseWhen:void 0}),Boolean(t.length>0||n?.size)&&i.createElement(C.MatchMedia,{rule:"(max-width: 440px)"},(e=>i.createElement(d.ToolbarMenuButton,{key:h.activeChartWidget.value().id(),arrow:!0,closeOnClickOutside:!0,isDrawer:e,drawerPosition:"Bottom",ref:this._menu,menuReference:this._menuItemsContainer,onClick:this._handleFavoriteMenuClick,"data-name":"show-favorite-indicators",tooltip:l.t(null,void 0,a(70234)),menuRole:"menu"},i.createElement("div",{className:m()(de.dropdown,e&&de.smallWidthWrapper)},i.createElement(re.ToolWidgetMenuSummary,{className:e&&de.smallWidthTitle},l.t(null,void 0,a(52530))),o&&i.createElement(le,null),!o&&i.createElement(i.Fragment,null,this.state.infos.length>0?this.state.infos.map((t=>i.createElement(R.AccessibleMenuItem,{role:"menuitem",className:m()(e&&de.smallWidthMenuItem),theme:e?y.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:m()(!e&&de.label,e&&de.smallWidthLabel,"apply-overflow-tooltip")},pe(t))}))):null!==this._promise&&i.createElement($.PopupMenuItem,{isDisabled:!0,label:l.t(null,void 0,a(18448))}))))))))}_prefetchFavorites(){const{chartWidgetCollection:e}=this.context;if(null!==this._promise||!window.is_authenticated)return;if(!e.activeChartWidget.value().hasModel())return;this.setState({isLoading:!0});const t=this._promise=Promise.all([ae(this.state.favorites),void 0]).then((e=>{if(t!==this._promise)return;const[a,n]=e;let i=[...a];if(n){const e=n.filter((e=>this.state.favoriteFundamentals?.has(e.scriptIdPart))).map(this._mapFundamentalToFavoriteItemInfo);i.push(...e)}i=[...i].sort(((e,t)=>pe(e).localeCompare(pe(t)))),this.setState({infos:i,isLoading:!1},(()=>{this._menu.current?.update(),this._menuItemsContainer.current&&document.activeElement===this._menuItemsContainer.current&&(0,J.focusFirstMenuItem)(this._menuItemsContainer.current)}))}))}_trackClick(){0}_trackFavoriteAction(e){(0,K.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 pe(e){return e.info.localizedName||l.t(e.info.name,{context:"study"},a(83477))}ve.contextType=me;var ge=a(87296),be=a(46082),Se=a(33759);function Ce(e){return i.createElement("div",{className:u(Se.value,{[Se.selected]:e.isSelected})},e.value,e.metric)}var _e=a(70412),ye=a(32563),we=a(62576),fe=a(58839);function Te(e){const{role:t,interval:a,hint:n,isActive:o,isDisabled:s,isFavorite:l,isRemovable:r,isFavoritingAllowed:c,isSignaling:h,onClick:d,onClickRemove:u,onClickFavorite:v,isSmallTablet:p,scrollContainerRef:g,...b}=e,[S,C]=(0,_e.useHoverDeprecated)(),_=i.useCallback((e=>u(a,e)),[u,a]),w=i.useCallback((()=>v(a)),[v,a]),f=(0,i.useRef)(null);return(0,i.useEffect)((()=>{if(h){const e=f.current;if(e&&g.current){ const t=e.getBoundingClientRect(),a=g.current.getBoundingClientRect();(a.top>t.top||a.bottom({default:(await Promise.all([a.e(7037),a.e(5371),a.e(2202),a.e(5563),a.e(2647),a.e(2537),a.e(8894),a.e(5743),a.e(9487),a.e(3329),a.e(9970),a.e(9965),a.e(3460),a.e(9418),a.e(9928),a.e(4013)]).then(a.bind(a,45618))).ToolWidgetIntervalsAddDialog})));class Pe extends i.PureComponent{constructor(e,t){super(e,t),this._menu=i.createRef(),this._menuItemsContainerRef=i.createRef(),this._drawerContainerRef=i.createRef(),this._renderChildren=(e,t)=>{const a=this._customIntervals?1:0,n=function(e){const t=ke(be.ResolutionKind.Ticks),a=ke(be.ResolutionKind.Seconds),n=ke(be.ResolutionKind.Minutes),i=ke(be.SpecialResolutionKind.Hours),o=ke(be.ResolutionKind.Days),s=ke(be.ResolutionKind.Range);return e.forEach((e=>{const l=be.Interval.parse(e);l.isMinuteHours()?i.items.push(e):l.isMinutes()?(0,be.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),i=n.length+a;return[...this._createIntervalItem(t,i),...this._createMenuItems(n,t,a,i)]},this._handleChangeInterval=()=>{const e=r.linking.interval.value(),{activeInterval:t,lastNotQuicked:a}=this.state,n=this._getQuicks();this.setState({activeInterval:(0,ge.normalizeIntervalString)(e),lastNotQuicked:void 0===t||n.includes(t)?a:t})},this._bindedForceUpdate=()=>{this.forceUpdate()},this._handleSelectInterval=(e,t,a)=>{const n=r.linking.interval.value();void 0===e||be.Interval.isEqual(e,n)||r.linking.setIntervalAndLogInitiator(e,a??"Header toolbar"),e&&(0,K.trackEvent)("GUI","Time Interval",e)},this._handleClickFavorite=e=>{e=(0,G.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,intervalsMenuViewStateService:n}=this.context,{menuViewState:i}=this.state,o=a.add(e,t);if(o){this.setState({lastAddedInterval:o});const e=be.Interval.parseExt(o);if(e.interval.isMinuteHours())return void n.set({...i,[be.SpecialResolutionKind.Hours]:!1});const t=e.guiResolutionKind;if(t===be.ResolutionKind.Days||t===be.ResolutionKind.Weeks||t===be.ResolutionKind.Months)return void n.set({...i,[be.ResolutionKind.Days]:!1});n.set({...i,[t]:!1})}},this._handleRemoveInterval=(e,t)=>{const{intervalService:a}=this.context;if(e){if(t&&(0,Z.isKeyboardClick)(t)&&this._menuItemsContainerRef.current){const t=(0,J.queryMenuElements)(this._menuItemsContainerRef.current),a=t.findIndex((t=>t.matches(`[data-value="${e}"]`)));if(-1!==a){const e=t[a+1]??t[a-1];e?e.focus():(0,J.focusFirstMenuItem)(this._menuItemsContainerRef.current)}}a.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||We.fire()},this._handeQuickClick=e=>{this._handleSelectInterval(e,void 0,"Favorites"),this._trackClick()},(0,w.validateRegistry)(t,{chartApiInstance:o.any.isRequired,favoriteIntervalsService:o.any.isRequired,intervalService:o.any.isRequired,intervalsMenuViewStateService:o.any.isRequired});const{chartApiInstance:a,favoriteIntervalsService:s,intervalService:l,intervalsMenuViewStateService:c}=t;this._customIntervals=n.enabled("custom_resolutions");const h=r.linking.interval.value(),d=h&&(0,ge.normalizeIntervalString)(h),u=s.get(),m=l.getCustomIntervals(),v=c.get();this._defaultIntervals=a.defaultResolutions().filter(ge.isIntervalEnabled).map(ge.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),r.linking.interval.subscribe(this._handleChangeInterval),r.linking.intraday.subscribe(this._bindedForceUpdate),r.linking.seconds.subscribe(this._bindedForceUpdate),r.linking.ticks.subscribe(this._bindedForceUpdate),r.linking.range.subscribe(this._bindedForceUpdate),r.linking.supportedResolutions.subscribe(this._bindedForceUpdate),r.linking.dataFrequencyResolution.subscribe(this._bindedForceUpdate),Ie.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),r.linking.interval.unsubscribe(this._handleChangeInterval),r.linking.intraday.unsubscribe(this._bindedForceUpdate),r.linking.seconds.unsubscribe(this._bindedForceUpdate),r.linking.ticks.unsubscribe(this._bindedForceUpdate),r.linking.range.unsubscribe(this._bindedForceUpdate),r.linking.supportedResolutions.unsubscribe(this._bindedForceUpdate),r.linking.dataFrequencyResolution.unsubscribe(this._bindedForceUpdate),Ie.globalCloseDelegate.unsubscribe(this,this._handleGlobalClose)}componentDidUpdate(e,t){this.state.lastAddedInterval&&setTimeout((()=>this.setState({lastAddedInterval:void 0})),1600)}render(){const{isShownQuicks:e,id:t}=this.props,{activeInterval:a,customs:n,lastNotQuicked:o,isAddIntervalDialogOpened:s}=this.state,l=this._getQuicks(),r=(0,ge.sortResolutions)([...l]);void 0!==a&&r.includes(a)?void 0!==o&&r.push(o):void 0!==a&&r.push(a);const c=(!(!e||0===l.length)||void 0)&&r.length>1,h={},u=(0,ge.mergeResolutions)(this._defaultIntervals,n);(void 0!==a?u.concat(a):u).filter(ge.isAvailable).forEach((e=>h[e]=!0));const m=void 0!==a?(0,ge.getTranslatedResolutionModel)(a):null;return i.createElement(p,{id:t},c&&i.createElement(I,{className:Oe.group,orientation:"horizontal"},r.map(((e,t)=>{const n=(0,ge.getTranslatedResolutionModel)(e);return i.createElement(b,{key:t,role:"radio",className:Oe.button,text:i.createElement(Ce,{value:n.mayOmitMultiplier?void 0:n.multiplier,metric:n.shortKind}),hint:n.hint,"aria-checked":a===e,isActive:a===e,isDisabled:!h[e],onClick:this._handeQuickClick,onClickArg:e,"data-value":e})}))),i.createElement(C.MatchMedia,{rule:_.DialogBreakpoints.TabletSmall},(e=>i.createElement(i.Fragment,null,i.createElement(xe.CloseDelegateContext.Provider,{value:We},i.createElement(d.ToolbarMenuButton,{arrow:Boolean(c),closeOnClickOutside:!s,content:c||null===m?void 0:i.createElement(p,{className:Oe.menuContent},i.createElement(Ce,{ value:m.mayOmitMultiplier?void 0:m.multiplier,metric:m.shortKind})),hotKey:c?De:void 0,className:Oe.menu,ref:this._menu,isDrawer:e,onClick:this._trackClick,tooltip:c||null===m?Ue.timeInterval:m.hint,menuReference:this._menuItemsContainerRef,menuRole:"treegrid",drawerReference:this._drawerContainerRef},i.createElement("div",{className:Oe.dropdown},this._renderChildren(u,e)))),s&&i.createElement(i.Suspense,{fallback:null},i.createElement(ze,{onAdd:this._handleAddInterval,onClose:this._handleCloseAddIntervalDialog,onUnmount:this._handleCloseAddIntervalDialog,intervalService:this.context.intervalService,isSmallTablet:e}))))))}_createMenuItems(e,t,a,n){const i=e.map(((e,i,o)=>this._renderResolutionsGroup(e,1===o.length,t,i+1+a,n)));return function(e){let t=!1;return e.filter(((e,a,n)=>{let i=!0;return e.type===S.PopupMenuSeparator&&(0!==a&&a!==n.length-1||(i=!1),t&&(i=!1)),t=e.type===S.PopupMenuSeparator,i}))}([].concat(...i))}_createIntervalItem(e,t){return this._customIntervals?[i.createElement(Be,{key:"add-dialog","aria-level":1,"aria-posinset":1,"aria-setsize":t,isSmallTablet:e,onClick:this._handleOpenAddIntervalDialog}),i.createElement(S.PopupMenuSeparator,{key:"custom-interval-separator"})]:[]}_renderResolutionsGroup(e,t=!1,a,n,o){const s=[],l=t?1:2,r=e.items.map(((t,n)=>this._renderPopupMenuItem(t,a,n+1,e.items.length,l)));if(t)s.push(...r);else if(a){const t=i.createElement(Ve,{key:e.id,title:e.name},r);s.push(t)}else{const{intervalsMenuViewStateService:t}=this.context,{menuViewState:a}=this.state;if(!t.isAllowed(e.id))return[];const l=i.createElement(Ne,{key:e.id,role:"row","aria-posinset":n,"aria-setsize":o,"aria-level":1,className:Oe.section,summary:e.name,open:!a[e.id],onStateChange:this._getHandleSectionStateChange(e.id)},r);s.push(l)}return(!e.mayOmitSeparator||e.items.length>1)&&(s.unshift(i.createElement(S.PopupMenuSeparator,{key:`begin-${e.name}`})),s.push(i.createElement(S.PopupMenuSeparator,{key:`end-${e.name}`}))),s}_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,a,n,o){const{isFavoritingAllowed:s}=this.props,{activeInterval:l,lastAddedInterval:r}=this.state,c=e===l,h=(0,ge.isAvailable)(e),d=this._isIntervalFavorite(e),u=this._isIntervalDefault(e),m=(0,ge.getTranslatedResolutionModel)(e);return i.createElement(Te,{key:e,role:"row","aria-level":o,"aria-posinset":a,"aria-setsize":n,"aria-selected":c,isSmallTablet:t,interval:e,hint:m.hint,isSignaling:r===e,isFavoritingAllowed:s,isDisabled:!h,isFavorite:d,isRemovable:!u,isActive:c,onClick:this._handleSelectInterval,onClickRemove:this._handleRemoveInterval,onClickFavorite:this._handleClickFavorite,scrollContainerRef:t?this._drawerContainerRef:this._menuItemsContainerRef,"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 Be(e){const{onClick:t,className:n,isSmallTablet:o,...s}=e;return i.createElement(R.AccessibleMenuItem,{...s,key:"add-dialog",role:"row","aria-haspopup":"dialog",className:u(Oe.addCustomInterval,!o&&Oe.desktop,n),onClick:t,label:(0,Fe.appendEllipsis)(l.t(null,void 0,a(80335))),icon:He,dontClosePopup:!0})}function Ve(e){const{children:t,title:a,className:n}=e;return i.createElement("div",{className:n},i.createElement("div",{className:Oe.smallTabletSectionTitle},a),t)}Pe.contextType=Le;var Ke=a(58169),Ze=a(41111),je=a(82436);const qe=(0,w.registryContextType)();class Qe extends i.PureComponent{constructor(e,t){super(e,t),this._handleClick=()=>{const{chartWidgetCollection:e,windowMessageService:t,isFundamental:a}=this.context,n=e.activeChartWidget.value();const i=function(){const e=new URL(window.location.href),t=JSON.parse(decodeURIComponent(e.hash.slice(1)));return delete t.show_popup_button,e.hash=`#${encodeURIComponent(JSON.stringify(t))}`,e.toString()}();n.withModel(null,(()=>{t.post(parent,"openChartInPopup",{symbol:n.model().mainSeries().actualSymbol(),interval:n.model().mainSeries().interval(),fundamental:a,url:i})}))},(0,w.validateRegistry)(t,{isFundamental:o.any,chartWidgetCollection:o.any.isRequired,windowMessageService:o.any.isRequired})}render(){const{className:e}=this.props;return i.createElement(Ke.ToolbarIconButton,{className:u(e,Ze.button),icon:je,onClick:this._handleClick,tooltip:l.t(null,void 0,a(34770))})}}Qe.contextType=qe;var Xe=a(34369);const Ge=(0,w.registryContextType)();class $e extends i.PureComponent{constructor(e,t){super(e,t),this._updateState=e=>{this.setState({isOpened:e})},this._handleClick=e=>{const{chartWidgetCollection:t}=this.context,a=t.activeChartWidget.value();(0,K.trackEvent)("GUI","Chart Header Toolbar","chart properties"),a.showGeneralChartProperties(void 0,{shouldReturnFocus:(0,Z.isKeyboardClick)(e)})},(0,w.validateRegistry)(t,{chartWidgetCollection:o.any.isRequired}),this.state={isOpened:!1},this._propertiesDialogRenderer=this.context.chartWidgetCollection.getChartPropertiesDialogRenderer()}componentDidMount(){this._propertiesDialogRenderer?.visible().subscribe(this._updateState)}componentWillUnmount(){this._propertiesDialogRenderer?.visible().unsubscribe(this._updateState)}render(){const{isOpened:e}=this.state;return i.createElement(Ke.ToolbarIconButton,{...this.props,icon:Xe,isOpened:e,onClick:this._handleClick,tooltip:l.t(null,void 0,a(32514))})}}$e.contextType=Ge;var Je=a(26709),Ye=a(68335),et=a(56616),tt=a(49483),at=a(40173),nt=a(56127),it=a(31398),ot=a(23568);function st(e){const{wasChanges:t,isSaving:n,className:o}=e;return i.createElement("span",{className:u(ot.saveString,!t&&!n&&ot.hidden,o)},n?i.createElement(oe.Loader,{className:ot.loader,size:"small",staticPosition:!0}):l.t(null,void 0,a(64e3)))}var lt=a(36235),rt=a(36296),ct=a(13090),ht=a(71837),dt=a(32707);a(57213);const ut=n.enabled("widget"),mt=n.enabled("save_shortcut"),vt=(0, at.mergeThemes)(W.DEFAULT_TOOL_WIDGET_BUTTON_THEME,dt),pt=(0,at.mergeThemes)($.DEFAULT_POPUP_MENU_ITEM_THEME,{shortcut:ht.shortcut,withIcon:ht.withIcon}),gt=((0,at.mergeThemes)($.DEFAULT_POPUP_MENU_ITEM_THEME,{toolbox:ht.toolbox}),(0,at.mergeThemes)($.DEFAULT_POPUP_MENU_ITEM_THEME,{toolbox:ht.toolboxSmall}),l.t(null,void 0,a(40115))),bt=l.t(null,void 0,a(26276)),St=[],Ct=(0,Y.hotKeySerialize)({keys:[(0,Ye.humanReadableModifiers)(Ye.Modifiers.Mod,!1),"S"],text:"{0} + {1}"}),_t=()=>null;class yt extends i.PureComponent{constructor(e){super(e),this._copyElRef=i.createRef(),this._menuRef=i.createRef(),this._handleCopyLinkClick=()=>Promise.resolve(),this._handleCloneClick=()=>{this.props.onCloneChart?.()},this._handleSaveClick=()=>{this.props.onSaveChart?.(),this._trackClick()},this._handleSaveAsClick=()=>{this.props.onSaveAsChart?.()},this.state={isSaving:!1}}componentDidUpdate(e,t){e.isProcessing&&!this.props.isProcessing&&(clearTimeout(this._timeout),this._timeout=void 0,this.setState({isSaving:!1})),!e.recentItems?.length&&this.props.recentItems?.length&&this._menuRef.current?.update(),!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:r,wasChanges:c,hideMenu:h,isTabletSmall:m,onOpenMenu:v,dataNameSaveMenu:g,isSaveDialogOpened:b,chartList:S,favorites:C,showRemoveFavoriteHint:_,onButtonClick:y,onAdditionalButtonClick:w}=this.props,f=!t&&!h;let T=[];lt.showFavoriteLayouts&&S&&C&&(T=S.filter((e=>C[e.id])).sort(((e,t)=>e.name.localeCompare(t.name))));const E=!(c||!r||this.state.isSaving),k=i.createElement("div",{className:ht.textWrap},i.createElement("span",{className:ht.text},i.createElement(nt.LeadingEmojiText,{text:r||l.t(null,void 0,a(64e3))})),i.createElement(st,{isSaving:this.state.isSaving,wasChanges:c}));return i.createElement(p,null,t?i.createElement(p,null,i.createElement(V,{id:e,displayMode:n,icon:i.createElement(s.Icon,{icon:rt}),isDisabled:o,onClick:this._handleCloneClick,text:l.t(null,void 0,a(49680)),collapseWhen:St,tooltip:gt})):i.createElement(p,null,i.createElement(V,{id:e,className:u(ht.button,f&&ht.buttonSmallPadding),displayMode:n,"aria-disabled":!!E||void 0,isDisabled:o,onClick:E?void 0:this._handleSaveClick,text:k,theme:vt,collapseWhen:St,isOpened:b,tooltip:E?l.t(null,void 0,a(89771)):l.t(null,void 0,a(15356)),"data-tooltip-hotkey":ut||E?"":mt?Ct:""}),f&&i.createElement("div",{className:ht.menuBtnWrap},i.createElement(d.ToolbarMenuButton,{"data-name":g,arrow:!0,ref:this._menuRef,isDrawer:m,drawerPosition:"Bottom",onClick:this._trackClick,onOpen:v,tooltip:l.t(null,void 0,a(38973)),menuClassName:u(!m&&ht.menu),menuRole:"grid"},this._renderMenuItems(Boolean(m))),lt.showFavoriteLayouts&&_&&T.length>FAVORITE_LAYOUTS_LIMIT&&i.createElement(i.Suspense,{fallback:null},i.createElement(_t,{onClick:y,onAdditionalClick:w,placement:"auto",theme:undefined,buttonSize:"small",saveHintStateByClick:!1,text:l.t(null,{ count:T.length,plural:"Your favorite layouts have moved to the top toolbar. You currently have {count} favorites. You can reduce the number to find them easier — unfavorite all in just one click or set up your choice manually.",replace:{count:T.length.toString()}},a(6094)),buttonText:l.t(null,void 0,a(66418)),additionalButtonText:l.t(null,void 0,a(36291)),settingsHintKey:"hint.favoriteLayouts",placeHolderClassName:ht.hintPlaceholder,hideWithReference:!0,hintStateHandler:favoriteLayoutsHintStateHandler}))),!1))}_renderMenuItems(e){const{wasChanges:t,isProcessing:n,chartId:o,onSaveChartFromMenu:s,onRenameChart:r,onLoadChart:c,onNewChart:h,isAutoSaveEnabled:d,autoSaveId:m,sharingId:v,onAutoSaveChanged:p,isSharingEnabled:g,onSharingChanged:b,recentItems:C,onExportData:_,isAuthenticated:w,favorites:f}=this.props,T=e?y.multilineLabelWithIconAndToolboxTheme:pt,E=(e&&it.menuItemSwitcherMobileTheme,e?void 0:(0,Ye.humanReadableHash)(Ye.Modifiers.Mod+83)),k=e?void 0:l.t(null,{context:"hotkey"},a(23821)),M=[];return M.push(i.createElement(R.AccessibleMenuItem,{key:"save",role:"row",isDisabled:Boolean(n||!t&&o),label:bt,onClick:s,shortcut:E,labelRowClassName:u(e&&ht.popupItemRowTabletSmall),theme:T,"data-name":"save-load-menu-item-save"})),void 0!==o&&M.push(i.createElement(R.AccessibleMenuItem,{key:"save-as",role:"row",icon:void 0,label:(0,Fe.appendEllipsis)(gt),onClick:this._handleSaveAsClick,labelRowClassName:u(e&&ht.popupItemRowTabletSmall),theme:T,"data-name":"save-load-menu-item-clone","aria-haspopup":"dialog"}),i.createElement(R.AccessibleMenuItem,{key:"rename",role:"row",icon:void 0,label:(0,Fe.appendEllipsis)(l.t(null,void 0,a(6321))),onClick:r,labelRowClassName:u(e&&ht.popupItemRowTabletSmall),theme:T,"data-name":"save-load-menu-item-rename","aria-haspopup":"dialog"})),M.push(i.createElement(S.PopupMenuSeparator,{key:"all-layouts-separator"}),i.createElement(R.AccessibleMenuItem,{key:"all-layouts",role:"row",className:"js-save-load-menu-item-load-chart",label:(0,Fe.appendEllipsis)(l.t(null,void 0,a(65433))),onClick:c,icon:ct,labelRowClassName:u(e&&ht.popupItemRowTabletSmall),theme:T,shortcut:k,"data-name":"save-load-menu-item-load","aria-haspopup":"dialog"})),M}_trackClick(){0}}const wt=(0,w.registryContextType)();class ft extends i.PureComponent{constructor(e,t){super(e,t),this._exportDialogPromise=null,this._recentLayoutsAbortController=null,this._requestRecentLayouts=()=>{this._recentLayoutsAbortController?.abort()},this._updateState=e=>{this.setState((t=>({...t,...e})))},this._handleExportData=()=>{0},this._onSaveDialogVisibleChange=e=>{this.setState({isSaveDialogOpened:e})},this._syncState=e=>{this.setState(e)},this._handleAdditionalButton=()=>{const{loadChartService:e}=this.context;e.deleteAllFavorites()},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._handleHotkey=()=>{this.context.loadChartService.showLoadDialog()},this._handleClickRename=()=>{this.context.saveChartService.renameChart(),this._trackEvent("Rename")},(0,w.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,loadChartService:l}=t;this._loadChartServiceState=l.state(),this.state={isAuthenticated:window.is_authenticated,isProcessing:!1,id:a.metaInfo.id.value(),title:a.metaInfo.name.value(),wasChanges:n.hasChanges(),iconHovered:!1,isSaveDialogOpened:!1,...this._loadChartServiceState.value()}}componentDidMount(){const{chartSaver:e,isFake:t,stateSyncEmitter:n}=this.props,{chartWidgetCollection:i,chartChangesWatcher:o,saveChartService:s,sharingChartService:r,loadChartService:c}=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,Je.createGroup)({desc:"Save/Load"}),this._hotkeys.add({desc:l.t(null,void 0,a(29517)),handler:this._handleHotkey,hotkey:190}),e.chartSaved().subscribe(this,this._onChartSaved),e.chartAboutToBeSaved().subscribe(this,this._onChartAboutToBeSaved),window.loginStateChange.subscribe(this,this._onLoginStateChange),this.context.saveChartService.getCreateController().visible().subscribe(this._onSaveDialogVisibleChange),this._loadChartServiceState.subscribe(this._updateState),lt.showFavoriteLayouts&&c.refreshChartList())}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:o,sharingChartService:s}=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,G.ensureDefined)(this._hotkeys).destroy(),e.chartSaved().unsubscribe(this,this._onChartSaved), e.chartAboutToBeSaved().unsubscribe(this,this._onChartAboutToBeSaved),window.loginStateChange.unsubscribe(this,this._onLoginStateChange),this._recentLayoutsAbortController?.abort(),this.context.saveChartService.getCreateController().visible().unsubscribe(this._onSaveDialogVisibleChange),this._loadChartServiceState.unsubscribe(this._updateState))}render(){const{isReadOnly:e,displayMode:t,id:a,isFake:n}=this.props,{isProcessing:o,isAuthenticated:s,title:l,id:r,wasChanges:c,isAutoSaveEnabled:h,isSharingEnabled:d,isSaveDialogOpened:u,favorites:m,chartList:v,recents:p}=this.state,g={displayMode:t,isReadOnly:e,isAuthenticated:s,isProcessing:o,wasChanges:c,title:l,id:a,isSaveDialogOpened:u,favorites:m,chartList:v,chartId:null!==r?r:void 0,dataNameSaveMenu:n?void 0:"save-load-menu",showRemoveFavoriteHint:!n,onCloneChart:this._handleClickClone,onSaveChart:this._handleClickSave,onSaveChartFromMenu:this._handleClickSaveFromMenu,onRenameChart:this._handleClickRename,onSaveAsChart:this._handleClickSaveAs,onLoadChart:this._handleClickLoad,onButtonClick:this._handleClickLoad,onAdditionalButtonClick:this._handleAdditionalButton};return i.createElement(C.MatchMedia,{rule:_.DialogBreakpoints.TabletSmall},(e=>i.createElement(yt,{...g,isTabletSmall:e})))}_onLoginStateChange(){const e=window.is_authenticated;this.setState({isAuthenticated:e}),lt.showFavoriteLayouts&&this.context.loadChartService.refreshChartList()}_trackEvent(e){0}}ft.contextType=wt;var Tt=a(12850),Et=a(86957),kt=a(59149);const Mt=new Et.DateTimeFormatter({dateTimeSeparator:"_",timeFormat:"%h-%m-%s"}),xt={takeSnapshot:l.t(null,void 0,a(87972))},It=(0,w.registryContextType)();var Rt=a(53977);function At(e){const[t,a]=(0,i.useState)(!1);return{copySnapshotToClipboard:(0,i.useCallback)((async()=>{const t=e(),a=t.then((e=>new Promise((t=>e.canvas.toBlob((e=>{null!==e&&t(e)}))))));try{await(0,et.writePromiseUsingApi)(a,"image/png"),ce.emit("onClientScreenshotCopiedToClipboard")}catch(e){const{canvas:a}=await t;window.open()?.document.write(``)}}),[e]),downloadSnapshot:(0,i.useCallback)((async()=>{const t=await e(),a=await function(e){return new Promise((t=>{try{e.canvas.toBlob((e=>{if(null===e)throw new Error("Unable to generate blob");t(URL.createObjectURL(e))}))}catch{t(e.canvas.toDataURL())}}))}(t);a&&(0,Rt.downloadFile)(`${t.name}.png`,a)}),[e]),shareSymphony:null,symphonyLoading:t}}var Nt,Ft=a(76974);!function(e){function t(e,t){return"cme"===TradingView.widgetCustomer?t+" from cmegroup.com via @tradingview $"+e:`Check out my #${e} analysis on @TradingView: ${t}`}function a(e="about:blank",t="snapshot_tweet"){const a=Math.round(screen.width/2-275),n=Math.round(screen.height/2-210);return window.open(e,t,`scrollbars=yes,resizable=yes,toolbar=no,location=yes,\n\t\t\t\twidth=550,height=420,\n\t\t\t\tleft=${a},top=${n}`)}function n(e,a){return"https://twitter.com/intent/tweet?&text="+encodeURIComponent(t(e,a))}e.getStatus=t,e.shareSnapshotInstantly=function(e,t){a(n(e,t))},e.createWindow=a, e.createTwitterHrefWithCustomText=function(e,t){const a=e.replace("{url}",t);return`https://twitter.com/intent/tweet?text=${encodeURIComponent(a)}`},e.createTwitterHrefBySymbol=n}(Nt||(Nt={}));var Ot=a(75774);function Ht(e,t,n){return async function(e,t,n){const i=URL.createObjectURL(new Blob([`${l.t(null,void 0,a(93292))}`],{type:"text/html"}));try{Ot.isIOS&&await new Promise((e=>setTimeout(e)));const a=open(i,t,n);if(!a)throw new Error("cound not open a new tab");const o=await e.catch((()=>{}));void 0!==o?a.location.replace(o):a.close()}finally{URL.revokeObjectURL(i)}}(e,t,n)}async function Ut(e){return Ht(e.then((e=>e.imageUrl)))}var Dt=a(11306);function Lt(e){const t=u(e.isLoading&&Dt.hidden),a=u(!e.isLoading&&Dt.hidden);return i.createElement("div",null,i.createElement("span",{className:t},e.children),i.createElement("span",{className:a},i.createElement(oe.Loader,null)))}var Wt=a(67487),zt=a(1457),Pt=a(23595),Bt=a(29414),Vt=a(99280),Kt=a(51097);const Zt=(0,at.mergeThemes)($.DEFAULT_POPUP_MENU_ITEM_THEME,Kt);function jt(e){const{serverSnapshot:t,clientSnapshot:n,hideShortcuts:o,sendEvent:s}=e,{downloadSnapshot:r,copySnapshotToClipboard:c,shareSymphony:h,symphonyLoading:d}=At(n),{takeSnapshot:u,takeSnapshotEmbedCode:v,shareSnapshot:p,newTabLoading:g,copyLinkLoading:b,embedCodeLoading:S,tweetLoading:C}=function(e){const[t,a]=(0,i.useState)(!1),[n,o]=(0,i.useState)(!1),[s,l]=(0,i.useState)(!1),[r,c]=(0,i.useState)(!1),h=(0,Ft.useIsMounted)();return{takeSnapshot:(0,i.useCallback)((async(t=!1)=>{const n=e();try{if(t)o(!0),await Ut(n);else{a(!0);const e=n.then((e=>new Blob([e.imageUrl],{type:"text/plain"})));await(0,et.writePromiseUsingApi)(e,"text/plain"),ce.emit("onServerScreenshotCopiedToClipboard")}}catch(e){await Ut(n)}finally{h.current&&(o(!1),a(!1),(0,Ie.globalCloseMenu)())}}),[e]),takeSnapshotEmbedCode:(0,i.useCallback)((async()=>{l(!0);const t=e();try{const e=720,a=t.then((async t=>{if(!t.symbol)throw new Error("Symbol not found in ServerSnapshotResult");const a=await snapshoter().getSnapshot(t.symbol,new Set(["description"])),n="error"!==a.status?a.values.description:t.symbol,i=t.imageUrl.match(/\/x\/([0-9a-zA-Z]{8})/)?.[1]??"",o=createSnapshotImageUrls(i)?.url;return new Blob([`

${n} chart by TradingView

`],{type:"text/plain"})}));await(0,et.writePromiseUsingApi)(a,"text/plain"),ce.emit("onServerScreenshotEmbedCodeCopiedToClipboard")}catch(e){await Ut(t)}finally{h.current&&(l(!1),(0,Ie.globalCloseMenu)())}}),[e]),shareSnapshot:(0,i.useCallback)((async t=>{c(!0);const a=Nt.createWindow(),n=await e();if(t)a.location.href=Nt.createTwitterHrefWithCustomText(t,n.imageUrl);else{if(!n.symbol)return void c(!1) ;a.location.href=Nt.createTwitterHrefBySymbol(n.symbol,n.imageUrl)}h.current&&(c(!1),(0,Ie.globalCloseMenu)())}),[e]),copyLinkLoading:t,newTabLoading:n,embedCodeLoading:s,tweetLoading:r}}(t),_=(e.snapshotUrl&&e.snapshotUrl.length>0)??!1;return i.createElement(i.Fragment,null,i.createElement(re.ToolWidgetMenuSummary,null,l.t(null,void 0,a(58425))),i.createElement(R.AccessibleMenuItem,{role:"row","data-name":"save-chart-image",label:l.t(null,void 0,a(26200)),icon:Pt,onClick:function(){r(),s?.("download")},shortcut:o?void 0:(0,Ye.humanReadableHash)(Ye.Modifiers.Mod+Ye.Modifiers.Alt+83),theme:Zt}),i.createElement(R.AccessibleMenuItem,{role:"row","data-name":"copy-chart-image",label:l.t(null,void 0,a(96554)),icon:zt,onClick:function(){c(),s?.("copyImg")},shortcut:o?void 0:(0,Ye.humanReadableHash)(Ye.Modifiers.Mod+Ye.Modifiers.Shift+83),theme:Zt}),_&&!(0,tt.onWidget)()&&i.createElement(R.AccessibleMenuItem,{role:"row","data-name":"copy-link-to-the-chart-image",label:i.createElement(Lt,{isLoading:b},l.t(null,void 0,a(81939))),icon:Bt,onClick:()=>window.runOrSignIn((()=>{u(!1),s?.("copyLink")}),{source:"Copy link to the chart image"}),dontClosePopup:!0,isDisabled:b,shortcut:o?void 0:(0,Ye.humanReadableHash)(Ye.Modifiers.Alt+83),className:m()(b&&Kt.loading),theme:Zt}),!1,_&&!(0,tt.onWidget)()&&!(0,tt.isSymphonyEmbed)()&&i.createElement(R.AccessibleMenuItem,{role:"row","data-name":"open-image-in-new-tab",label:i.createElement(Lt,{isLoading:g},l.t(null,void 0,a(19159))),icon:Vt,onClick:()=>window.runOrSignIn((()=>{u(!0),s?.("openNewTab")}),{source:"Open image in new tab"}),dontClosePopup:!0,isDisabled:g,className:m()(g&&Kt.loading),theme:Zt}),_&&!(0,tt.onWidget)()&&!(0,tt.isSymphonyEmbed)()&&i.createElement(R.AccessibleMenuItem,{role:"row","data-name":"tweet-chart-image",label:i.createElement(Lt,{isLoading:C},l.t(null,void 0,a(28239))),icon:Wt,onClick:()=>window.runOrSignIn((()=>{p(),s?.("tweetImg")}),{source:"Tweet chart image"}),dontClosePopup:!0,isDisabled:C,className:m()(C&&Kt.loading),theme:Zt}),!1)}var qt=a(84015);function Qt(e){const[t,a]=(0,i.useState)(!1),n=(0,Ft.useIsMounted)(),o=(0,i.useCallback)((async()=>{a(!0),await e.serverSnapshot(),n.current&&a(!1)}),[e.serverSnapshot]);return i.createElement(W.ToolWidgetButton,{id:e.id,className:e.className,isDisabled:t,onClick:o,title:e.tooltip,icon:e.icon})}var Xt=a(72644);const Gt=($t=function(e){return(0,qt.isOnMobileAppPage)("any")?i.createElement(Qt,{...e,icon:Xt}):i.createElement(d.ToolbarMenuButton,{content:i.createElement(W.ToolWidgetButton,{tag:"div",id:e.id,className:e.className,icon:Xt}),drawerPosition:"Bottom",drawerBreakpoint:_.DialogBreakpoints.TabletSmall,arrow:!1,onClick:function(){},tooltip:e.tooltip,menuRole:"grid"},i.createElement(jt,{...e}))},(Jt=class extends i.PureComponent{constructor(e,t){super(e,t),this._clientSnapshot=async()=>{const e=this.context.chartWidgetCollection.activeChartWidget.value().model().mainSeries().actualSymbol();return{canvas:await this.context.chartWidgetCollection.clientSnapshot(),name:`${(0, kt.shortName)(e)}_${Mt.formatLocal(new Date)}`}},this._serverSnapshot=async()=>{const e=this.context.chartWidgetCollection.activeChartWidget.value().model().mainSeries().actualSymbol(),t=await this.context.chartWidgetCollection.takeScreenshot(),a=void 0!==this.context.snapshotUrl?t:(0,Tt.convertImageNameToUrl)(t);return{symbol:(0,kt.shortName)(e),imageUrl:a}},(0,w.validateRegistry)(t,{chartWidgetCollection:o.any.isRequired})}render(){const{className:e,id:t}=this.props;return i.createElement($t,{id:t,className:e,tooltip:xt.takeSnapshot,serverSnapshot:this._serverSnapshot,clientSnapshot:this._clientSnapshot,snapshotUrl:this.context.snapshotUrl})}}).contextType=It,Jt);var $t,Jt;var Yt=a(4745),ea=a(39362),ta=a(8686);class aa{async show(e){if(null!==aa._provider){const e=await aa._provider.getSymbol();return r.linking.setSymbolAndLogInitiator(e.symbol,"symbol search UI"),e}if(aa._currentShowingInstance)throw new DOMException("SymbolSearchUI is already shown","InvalidStateError");try{aa._currentShowingInstance=this,aa.preload();const t=await aa._implementation;return(0,G.assert)(null!==t),new Promise((a=>{t.showDefaultSearchDialog({...e,onSearchComplete:e=>{a({symbol:e})}})}))}finally{aa._currentShowingInstance=null}}static setProvider(e){this._provider=e}static preload(){null===this._provider&&null===this._implementation&&(this._implementation=(0,ta.loadNewSymbolSearch)())}}aa._currentShowingInstance=null,aa._provider=null,aa._implementation=null;var na=a(29142),ia=a(81890);const oa=(0,at.mergeThemes)(g.DEFAULT_TOOLBAR_BUTTON_THEME,ia),sa=(0,w.registryContextType)();class la extends i.PureComponent{constructor(e,t){super(e,t),this._openSymbolSearchDialog=async e=>{if((0,Ye.modifiersFromEvent)(e)===Ye.Modifiers.Alt)return void(0,et.getClipboard)().writeText(this.state.symbol);if(this.state.isOpened)return;const{chartWidgetCollection:t}=this.context,o=t?.activeChartWidget.value().model().model(),s=o?.mainSeries().symbolInfo(),r="option"===s?.type;try{(0,K.trackEvent)("GUI","SS","main search");let t=this._isSpread(this.state.symbol)?this.state.symbol:this.state.shortName;if(n.enabled("symbol_search_option_chain_selector")&&r){const e=await resolveUnderlyingSymbol(this.state.symbol);e&&(t={type:"option",value:this.state.symbol,underlying:e})}await(new aa).show({trackResultsOptions:{trackResults:!1,emptySearchType:"empty_result__supercharts"},onClose:()=>{this.setState({isOpened:!1})},onOpen:()=>{this.setState({isOpened:!0})},shouldReturnFocus:(0,Z.isKeyboardClick)(e),defaultValue:t,showSpreadActions:(0,Yt.canShowSpreadActions)()&&this.props.isActionsVisible,source:"searchBar",enableOptionsChain:n.enabled("symbol_search_option_chain_selector"),footer:ye.mobiletouch?void 0:i.createElement(ea.SymbolSearchDialogFooter,null,l.t(null,void 0,a(50021)))})}catch(e){}},this._isSpread=e=>!1,this._onSymbolInfoResolved=()=>{const e=r.linking.proSymbol.value();this.setState({symbol:e,shortName:ra()})},this._onSymbolChanged=()=>{const e=r.linking.proSymbol.value();this.setState({symbol:e,shortName:ra()})},(0,w.validateRegistry)(t,{ chartWidgetCollection:o.any.isRequired}),this.state={symbol:r.linking.proSymbol.value(),shortName:ra(),isOpened:!1}}componentDidMount(){r.linking.proSymbol.subscribe(this._onSymbolChanged),n.enabled("use_symbol_name_for_header_toolbar")&&r.linking.getChartWidget()?.model().mainSeries().symbolResolved().subscribe(null,this._onSymbolInfoResolved,!1),aa.preload()}componentWillUnmount(){r.linking.proSymbol.unsubscribe(this._onSymbolChanged),n.enabled("use_symbol_name_for_header_toolbar")&&r.linking.getChartWidget()?.model().mainSeries().symbolResolved().unsubscribe(null,this._onSymbolInfoResolved)}render(){const{id:e,className:t}=this.props;return i.createElement(g.ToolbarButton,{id:e,className:m()(t,n.enabled("uppercase_instrument_names")&&ia.uppercase,ia.smallLeftPadding),theme:oa,icon:na,isOpened:this.state.isOpened,text:this.state.shortName,onClick:this._openSymbolSearchDialog,tooltip:l.t(null,void 0,a(51165))})}async _updateQuotes(e){}}function ra(){const e=r.linking.proSymbol.value();if(n.enabled("use_symbol_name_for_header_toolbar")){const e=r.linking.seriesShortSymbol.value();if(e)return e}return function(e){return e.includes(":")?e.split(":"):["",e]}(e)[1]}la.contextType=sa;var ca=a(54914);function ha(e){return i.createElement("div",{className:u(ca.description,e.className)},e.children)}var da=a(77579);const ua=(0,at.mergeThemes)($.DEFAULT_POPUP_MENU_ITEM_THEME,{labelRow:da.labelRow,toolbox:da.toolbox,item:da.titleItem}),ma=(0,at.mergeThemes)($.DEFAULT_POPUP_MENU_ITEM_THEME,{labelRow:da.labelRow,toolbox:da.toolbox,item:da.titleItemTabletSmall}),va=(0,at.mergeThemes)($.DEFAULT_POPUP_MENU_ITEM_THEME,{item:da.item}),pa=(0,at.mergeThemes)($.DEFAULT_POPUP_MENU_ITEM_THEME,{item:da.itemTabletSmall});function ga(e){const{role:t,className:a,item:n,description:o,favorite:s,isFavoritingAllowed:l,isTabletSmall:r,onApply:c,onRemove:h,onFavor:d,isActive:u,descriptionDataName:v,...p}=e,g=p,[b,S]=(0,_e.useHoverDeprecated)(),C=r?ma:ua,_=r?pa:va,y=(0,i.useCallback)((()=>c(n)),[c,n]),w=(0,i.useCallback)((e=>h(n,e)),[h,n]),f=(0,i.useCallback)((()=>{d&&d(n)}),[d,n]);return i.createElement("div",{...S,...g,className:m()(a,da.wrap)},i.createElement(R.AccessibleMenuItem,{role:t,theme:C,label:i.createElement(nt.LeadingEmojiText,{text:n.name}),labelRowClassName:m()(r&&da.itemLabelTabletSmall),isHovered:b,showToolboxOnHover:!s&&!b,showToolboxOnFocus:!0,onClick:y,isActive:u,toolbox:i.createElement(i.Fragment,null,!n.isDefault&&i.createElement(we.MenuRemoveButton,{key:"remove",hidden:!ye.touch&&!b,onClick:w,className:m()(da.remove,u&&da.active)}),Boolean(d)&&l&&i.createElement(A.MenuFavoriteButton,{key:"favorite",isFilled:Boolean(s),onClick:f}))}),o&&i.createElement($.PopupMenuItem,{theme:_,label:i.createElement(ha,{className:m()(da.description,r&&da.descriptionTabletSmall)},o),onClick:y,isHovered:b,isActive:u,"data-name":v}))}var ba=a(18041);function Sa(e){const{item:t}=e,a={...t,isDefault:t.is_default},n={"data-name":t.name,"data-id":t.id,"data-is-default":Boolean(t.is_default)},o=t.meta_info,s=o?(0, ba.getStudyTemplateDescString)(o.indicators):void 0;return i.createElement(ga,{...e,...n,description:s,item:a})}var Ca=a(90470);const _a=(0,at.mergeThemes)($.DEFAULT_POPUP_MENU_ITEM_THEME,Ca);function ya(e){const{onClick:t,isTabletSmall:a,className:n,icon:o,title:l,...r}=e;return i.createElement(R.AccessibleMenuItem,{...r,theme:_a,className:m()(n,Ca.wrap),label:i.createElement("div",{className:Ca.titleWrap},i.createElement("div",{className:m()(Ca.title,a&&Ca.titleTabletSmall)},i.createElement(s.Icon,{className:Ca.icon,icon:o}),i.createElement("div",{className:Ca.text},l))),onClick:t})}var wa=a(46043),fa=a(64706);const Ta=i.createContext(null),Ea=!1;var ka=a(53707),Ma=a(63591);function xa(e){const{templates:t,recents:n,onTemplateSave:o,onTemplateRemove:s,onTemplateSelect:r,onTemplateFavorite:c,isTabletSmall:h,isLoading:d,onOpenTemplatesDialog:u}=e,v=(0,i.useMemo)((()=>t.filter((e=>e.is_default))),[t]),p=(0,i.useMemo)((()=>t.filter((e=>!e.is_default))),[t]),g=(0,i.useContext)(Ta),b=(0,i.useContext)(fa.MenuContext),C=(0,wa.useForceUpdate)();(0,i.useEffect)((()=>{if(null!==g){const e={};return g.getOnChange().subscribe(e,(()=>{C(),b&&b.update()})),()=>g.getOnChange().unsubscribeAll(e)}return()=>{}}),[]);const _=(e,t)=>i.createElement(Sa,{key:e.name,role:"row",item:e,isFavoritingAllowed:Boolean(c),favorite:null!==e.favorite_date,onApply:r,onFavor:c,onRemove:s,isTabletSmall:h,"data-group-name":t});return i.createElement("div",{role:"treegrid",className:m()(Ma.menu,h&&Ma.menuSmallTablet)},i.createElement(ya,{role:"row",onClick:o,isTabletSmall:h,icon:ka,title:(0,Fe.appendEllipsis)(l.t(null,void 0,a(26869))),"aria-haspopup":"dialog"}),d&&i.createElement(i.Fragment,null,i.createElement(S.PopupMenuSeparator,null),i.createElement(le,null)),!d&&(h?i.createElement(Ia,{defaults:v,customs:p,recents:n,render:_}):i.createElement(Ra,{defaults:v,customs:p,recents:n,render:_,state:g})),Ea)}function Ia(e){const{defaults:t,customs:n,recents:o,render:s}=e;return i.createElement(i.Fragment,null,n.length>0&&i.createElement(i.Fragment,null,i.createElement(S.PopupMenuSeparator,null),i.createElement(re.ToolWidgetMenuSummary,{className:Ma.menuItemHeaderTabletSmall},l.t(null,void 0,a(83300))),n.map((e=>s(e)))),t.length>0&&i.createElement(i.Fragment,null,i.createElement(S.PopupMenuSeparator,null),i.createElement(re.ToolWidgetMenuSummary,{className:Ma.menuItemHeaderTabletSmall},l.t(null,void 0,a(46838))),t.map((e=>s(e)))))}function Ra(e){const{defaults:t,customs:n,recents:o,render:s,state:r}=e;return i.createElement(i.Fragment,null,n.length>0&&i.createElement(i.Fragment,null,i.createElement(S.PopupMenuSeparator,null),i.createElement(re.ToolWidgetMenuSummary,{className:Ma.menuItemHeader},l.t(null,void 0,a(83300))),n.map((e=>s(e)))),n.length>0&&t.length>0&&r&&i.createElement(i.Fragment,null,i.createElement(S.PopupMenuSeparator,null),i.createElement(Ne,{role:"row",summary:l.t(null,void 0,a(46838)),open:!r.get().defaultsCollapsed,onStateChange:e=>r.set({defaultsCollapsed:!e}) },t.map((e=>s(e))))),0===n.length&&t.length>0&&i.createElement(i.Fragment,null,i.createElement(S.PopupMenuSeparator,null),i.createElement(re.ToolWidgetMenuSummary,{className:Ma.menuItemHeader},l.t(null,void 0,a(46838))),t.map((e=>s(e)))))}var Aa=a(22613),Na=a(81593);class Fa{constructor(e,t){this._isFavoriteEnabled=n.enabled("items_favoriting"),this.handleFavorTemplate=e=>{if(!this._isFavoriteEnabled)return;const{id:t,is_default:a,favorite_date:n}=e;null!==n?this._removeFavoriteTemplate(t,a):this._addFavoriteTemplate(t,a)},this.handleDropdownOpen=()=>{this._setState({isLoading:!0}),this._studyTemplates.invalidate(),this._studyTemplates.refreshStudyTemplateList((()=>this._setState({isLoading:!1})))},this.handleApplyTemplate=e=>{this._studyTemplates.applyTemplate(e.name),this._recentStudyTemplatesService&&this._recentStudyTemplatesService.add(e.id)},this.handleRemoveTemplate=(e,t,a)=>{this._studyTemplates.deleteStudyTemplate(e.name,t,a)},this.handleSaveTemplate=e=>{this._studyTemplates.showSaveAsDialog(e)},this._studyTemplates=e,this._recentStudyTemplatesService=t;const a=this._recentStudyTemplatesService?.get()||[],i=this._studyTemplates.list();this._state=new Aa.WatchedValue({isLoading:!1,studyTemplatesList:i,recents:a}),this._studyTemplates.getOnChange().subscribe(this,this._handleTemplatesChange),this._recentStudyTemplatesService?.getOnChange().subscribe(this,this._handleRecentsChange),this._studyTemplates.refreshStudyTemplateList()}destroy(){this._studyTemplates.getOnChange().unsubscribe(this,this._handleTemplatesChange),this._recentStudyTemplatesService?.getOnChange().unsubscribe(this,this._handleRecentsChange)}state(){return this._state.readonly()}getSortedFavoritesStudyTemplates(e){return e.filter((e=>null!==e.favorite_date)).sort(((e,t)=>null!==e.favorite_date&&null!==t.favorite_date&&e.favorite_date>t.favorite_date?1:-1))}getValidRecents(e){const t=e.reduce(((e,t)=>(e[t.id]=t,e)),{});return this._state.value().recents.map((e=>t[e])).filter((e=>void 0!==e))}_setState(e){this._state.setValue({...this._state.value(),...e})}_handleTemplatesChange(){this._setState({studyTemplatesList:this._studyTemplates.list()})}_handleRecentsChange(){this._setState({recents:this._recentStudyTemplatesService?.get()||[]})}_removeFavoriteTemplate(e,t){const a=t?Na.backend.favorStandardStudyTemplate:Na.backend.favorStudyTemplate;this._replaceOldFavoriteStudyTemplate(e,null,t),a(e,!1)}_addFavoriteTemplate(e,t){const a=this.getSortedFavoritesStudyTemplates(this._state.value().studyTemplatesList),n=a.length?a[a.length-1].favorite_date:0,i=window.is_authenticated?Date.now():n+1,o=t?Na.backend.favorStandardStudyTemplate:Na.backend.favorStudyTemplate;this._replaceOldFavoriteStudyTemplate(e,i,t),o(e,!0)}_replaceOldFavoriteStudyTemplate(e,t,a){const n=this._state.value().studyTemplatesList.map((n=>n.id===e&&n.is_default===a?{...n,favorite_date:t}:n));this._setState({studyTemplatesList:n})}}var Oa=a(63472),Ha=a(26978);function Ua(e){const{className:t,children:a,item:n,onApply:o,isActive:s,href:l,target:r}=e,c=n.name?.trim()??" ",[h,d]=(0, L.useRovingTabindexElement)(null),m=l?"a":o?"button":"div",v=n.tooltip??c,p=(0,Oa.getLeadingEmojiHtml)(v);return i.createElement(m,{ref:h,type:o&&!l?"button":void 0,className:u(t,Ha.item,Ha.accessible,"apply-common-tooltip","common-tooltip-html"),onClick:function(e){if(e.stopPropagation(),o&&l){if((0,k.modifiersFromEvent)(e)!==k.Modifiers.None||1===e.button)return;e.preventDefault()}o?.(n)},onKeyDown:"a"===m?function(e){32===(0,k.hashFromEvent)(e)&&(e.preventDefault(),h.current?.click())}:void 0,"data-tooltip":p,"aria-label":v,tabIndex:d,href:"a"===m?l:void 0,target:"a"===m?r:void 0},i.createElement("div",{className:u(Ha.round,s&&Ha.active)},a||i.createElement(nt.LeadingEmojiText,{text:c,firstSegmentOnly:!0})))}var Da=a(21233),La=a(9952);const Wa=(0,w.registryContextType)();class za extends i.PureComponent{constructor(e,t){super(e,t),this._updateState=e=>{this.setState({...e,isActive:this.state.isActive})},this._handleApplyTemplate=e=>{this._handleClose(),this._model.handleApplyTemplate(e)},this._handleRemoveTemplate=(e,t,a)=>{this._handleClose(),this._model.handleRemoveTemplate(e,t,a)},this._handleClose=()=>{this._handleToggleDropdown(!1)},this._handleToggleDropdown=e=>{const{isActive:t}=this.state,a="boolean"==typeof e?e:!t;this.setState({isActive:a})},this._handleOpenTemplatesDialog=()=>{isNewTemplatesViewEnabled&&showIndicatorTemplatesDialog(this._model)},(0,w.validateRegistry)(t,{studyTemplates:o.any.isRequired,templatesMenuViewStateService:o.any,recentStudyTemplatesService:o.any});const{recentStudyTemplatesService:a,studyTemplates:n}=t;this._model=new Fa(n,a),this.state={...this._model.state().value(),isActive:!1}}componentDidMount(){this._model.state().subscribe(this._updateState)}componentWillUnmount(){this._model.state().unsubscribe(this._updateState),this._model.destroy()}render(){const{studyTemplatesList:e}=this.state,{isShownQuicks:t,className:a,displayMode:n,id:o}=this.props,s=this._model.getSortedFavoritesStudyTemplates(e),l=this._model.getValidRecents(e);return i.createElement(Ta.Provider,{value:this.context.templatesMenuViewStateService||null},i.createElement(Pa,{id:o,className:a,mode:n,templates:e,favorites:s,recents:l,onMenuOpen:this._model.handleDropdownOpen,onTemplateFavorite:t?this._model.handleFavorTemplate:void 0,onTemplateSelect:this._handleApplyTemplate,onTemplateRemove:this._handleRemoveTemplate,onTemplateSave:this._model.handleSaveTemplate,onOpenTemplatesDialog:this._handleOpenTemplatesDialog}))}}function Pa(e){const{id:t,className:n,mode:o,templates:s,favorites:r,recents:c,isMenuOpen:h,onTemplateSelect:u,onTemplateSave:v,onTemplateFavorite:g,onTemplateRemove:b,onOpenTemplatesDialog:S}=e,y=(0,i.useRef)(null),w=(0,i.useRef)(null),f=m()(n,La.wrap,{[La.full]:"full"===o,[La.medium]:"medium"===o}),T="small"!==o&&g&&r.length>0;return i.createElement(p,{id:t,className:f},i.createElement(C.MatchMedia,{rule:_.DialogBreakpoints.TabletSmall},(t=>i.createElement(d.ToolbarMenuButton,{ref:y,menuReference:w,onOpen:e.onMenuOpen,isDrawer:t,drawerPosition:"Bottom",arrow:!1,content:i.createElement(B,{ tag:"div",className:m()(T&&La.buttonWithFavorites),displayMode:o,isOpened:h,icon:Da,forceInteractive:!0,collapseWhen:["full","medium","small"]}),onClick:k,tooltip:l.t(null,void 0,a(76443)),menuDataName:"indicator-templates-menu"},i.createElement(xa,{onTemplateSave:v,onTemplateSelect:u,onTemplateRemove:E,onTemplateFavorite:g,templates:s,recents:c,isTabletSmall:t,onOpenTemplatesDialog:S})))),T&&i.createElement(Ba,{favorites:r,onTemplateSelect:function(e){u(e),k()}}));function E(e,t){if(t&&(0,Z.isKeyboardClick)(t)&&w.current){const t=(0,J.queryMenuElements)(w.current),a=t.findIndex((t=>null!==t.closest(`[data-id="${e.id}"]`)));b(e,null,(()=>{if(-1!==a&&w.current){const e=t[a+1]??t[a-1];e?e.focus():(0,J.focusFirstMenuItem)(w.current),y.current?.update()}}))}else b(e)}function k(){0}}function Ba(e){return i.createElement(i.Fragment,null,e.favorites.map(((t,a,n)=>i.createElement(Ua,{key:t.name,item:t,onApply:e.onTemplateSelect,className:m()({[La.first]:0===a,[La.last]:a===n.length-1})}))))}za.contextType=Wa;a(40167);var Va=a(77665),Ka=a(96052),Za=a(97045);const ja={undoHotKey:(0,Y.hotKeySerialize)({keys:[(0,Ye.humanReadableModifiers)(Ye.Modifiers.Mod,!1),"Z"],text:"{0} + {1}"}),redoHotKey:(0,Y.hotKeySerialize)({keys:[(0,Ye.humanReadableModifiers)(Ye.Modifiers.Mod,!1),"Y"],text:"{0} + {1}"})},qa=(0,at.mergeThemes)(g.DEFAULT_TOOLBAR_BUTTON_THEME,Za),Qa=(0,w.registryContextType)();class Xa extends i.PureComponent{constructor(e,t){super(e,t),this._batched=null,this._handleClickUndo=()=>{(0,K.trackEvent)("GUI","Undo");const{chartWidgetCollection:e}=this.context;e.undoHistory.undo()},this._handleClickRedo=()=>{(0,K.trackEvent)("GUI","Redo");const{chartWidgetCollection:e}=this.context;e.undoHistory.redo()},(0,w.validateRegistry)(t,{chartWidgetCollection:o.any.isRequired}),this.state=this._getStateFromUndoHistory()}componentDidMount(){const{chartWidgetCollection:e}=this.context;e.undoHistory.redoStack().onChange().subscribe(this,this._onChangeStack),e.undoHistory.undoStack().onChange().subscribe(this,this._onChangeStack)}componentWillUnmount(){const{chartWidgetCollection:e}=this.context;e.undoHistory.redoStack().onChange().unsubscribe(this,this._onChangeStack),e.undoHistory.undoStack().onChange().unsubscribe(this,this._onChangeStack),this._batched=null}render(){const{id:e}=this.props,{isEnabledRedo:t,isEnabledUndo:n,redoStack:o,undoStack:s}=this.state;return i.createElement(p,{id:e},i.createElement(g.ToolbarButton,{icon:Va,isDisabled:!n,onClick:this._handleClickUndo,theme:qa,tooltip:n?l.t(null,{replace:{hint:s}},a(66020)):void 0,"data-tooltip-hotkey":n?ja.undoHotKey:void 0}),i.createElement(g.ToolbarButton,{icon:Ka,isDisabled:!t,onClick:this._handleClickRedo,theme:qa,tooltip:t?l.t(null,{replace:{hint:o}},a(11304)):void 0,"data-tooltip-hotkey":t?ja.redoHotKey:void 0}))}_onChangeStack(){null===this._batched&&(this._batched=Promise.resolve().then((()=>{if(null===this._batched)return;this._batched=null;const e=this._getStateFromUndoHistory();this.setState(e)})))}_getStateFromUndoHistory(){ const{chartWidgetCollection:e}=this.context,t=e.undoHistory.undoStack(),a=e.undoHistory.redoStack(),n=a.head(),i=t.head();return{isEnabledRedo:!a.isEmpty(),isEnabledUndo:!t.isEmpty(),redoStack:n?n.text().translatedText():"",undoStack:i?i.text().translatedText():""}}}Xa.contextType=Qa;const Ga=e=>{if((e=>"http://www.w3.org/1999/xhtml"===e?.namespaceURI)(e)&&"true"!==e.dataset.internalAllowKeyboardNavigation){e.tabIndex=-1,e.ariaDisabled="true";for(let t=0;t{this.forceUpdate()},this._setRef=e=>{this._wrapperElement=e},this._handleMeasure=([e])=>{this.props.width.setValue(e.contentRect.width)},this._handleMutation=([e])=>{"childList"===e.type&&Ga(this.props.element)}}componentDidMount(){const{element:e,isFake:t,width:a}=this.props;!t&&this._wrapperElement?(this._resizeObserver=new ResizeObserver(this._handleMeasure),this._mutationObserver=new MutationObserver(this._handleMutation),this._wrapperElement.appendChild(e),this._resizeObserver.observe(this._wrapperElement),this._mutationObserver.observe(e,{subtree:!0,childList:!0})):a.subscribe(this._update)}componentWillUnmount(){const{width:e,isFake:t}=this.props;t&&e.unsubscribe(this._update),this._resizeObserver&&this._wrapperElement&&this._resizeObserver.unobserve(this._wrapperElement),this._mutationObserver&&(this._mutationObserver.disconnect(),this._mutationObserver=null)}render(){const{isFake:e=!1,width:t}=this.props;return i.createElement(p,{ref:this._setRef,style:e?{width:t.value()}:void 0,"data-is-custom-header-element":!0})}}function Ja(e){const{displayMode:t,params:a}=e;return i.createElement(d.ToolbarMenuButton,{content:i.createElement(B,{collapseWhen:void 0!==a.icon?void 0:[],displayMode:t,icon:a.icon,text:a.title,"data-name":"dropdown","data-is-custom-header-element":!0}),drawerPosition:"Bottom",drawerBreakpoint:_.DialogBreakpoints.TabletSmall,arrow:!1,tooltip:a.tooltip},a.items.map(((e,t)=>i.createElement($.PopupMenuItem,{key:t,label:e.title,icon:e.icon,onClick:()=>e.onSelect(),"data-name":"dropdown-item"}))))}var Ya=a(32597);function en(e){const{className:t,title:a,...n}=e;return i.createElement(V,{...n,className:u(t,Ya.customTradingViewStyleButton,Ya.withoutIcon),collapseWhen:[],"data-name":"custom-tradingview-styled-button",tooltip:a})}var tn=a(60448);const an=(0,Y.hotKeySerialize)({keys:[(0,Ye.humanReadableModifiers)(Ye.Modifiers.Mod,!1),"K"],text:"{0} + {1}"}),nn=(0,w.registryContextType)();class on extends i.PureComponent{constructor(e,t){super(e),this._dialog=null,this._updateState=e=>{this.setState({isOpened:e})},this._handleClick=e=>{const{openGlobalSearch:t}=this.context;t({shouldReturnFocus:(0,Z.isKeyboardClick)(e)}).then((e=>{this._dialog?.visible().unsubscribe(this._updateState),this._dialog=e,e.visible().subscribe(this._updateState)}))},(0,w.validateRegistry)(t,{openGlobalSearch:o.any.isRequired}),this.state={isOpened:!1}} componentWillUnmount(){this._dialog?.visible().unsubscribe(this._updateState)}render(){return i.createElement(Ke.ToolbarIconButton,{...this.props,icon:tn,isOpened:this.state.isOpened,onClick:this._handleClick,"data-tooltip-hotkey":an,tooltip:l.t(null,void 0,a(18243))})}}on.contextType=nn;var sn=a(23745),ln=a(91572);function rn(){return{Bars:n.enabled("header_chart_type")?D:void 0,Compare:n.enabled("header_compare")?Q:void 0,Custom:$a,CustomTradingViewStyledButton:en,Fullscreen:(0,ln.shouldShowFullscreen)()?X.ToolWidgetFullscreen:void 0,Indicators:n.enabled("header_indicators")?ve:void 0,Intervals:n.enabled("header_resolutions")?Pe:void 0,OpenPopup:Qe,Properties:n.enabled("header_settings")&&n.enabled("show_chart_property_page")?$e:void 0,SaveLoad:n.enabled("header_saveload")?ft:void 0,Screenshot:n.enabled("header_screenshot")?Gt:void 0,SymbolSearch:n.enabled("header_symbol_search")?la:void 0,Templates:n.enabled("study_templates")?za:void 0,Dropdown:Ja,UndoRedo:n.enabled("header_undo_redo")?Xa:void 0,Layout:undefined,QuickSearch:(0,sn.shouldShowQuickSearchOnLib)()?on:void 0}}},91572:(e,t,a)=>{"use strict";a.d(t,{shouldShowFullscreen:()=>i});var n=a(37103);function i(){return n.enabled("header_fullscreen_button")}},69830:(e,t,a)=>{"use strict";a.d(t,{ToolWidgetFullscreen:()=>p});var n=a(50959),i=a(19036),o=a(97754),s=a(11542),l=a(58169),r=a(68976),c=a(61814),h=a(68335),d=a(97268),u=a(36992);const m=(0,c.hotKeySerialize)({keys:[(0,h.humanReadableModifiers)(h.Modifiers.Shift,!1),"F"],text:"{0} + {1}"}),v=(0,r.registryContextType)();class p extends n.PureComponent{constructor(e,t){super(e,t),this._updateState=()=>{this.setState({isFullscreen:this.context.chartWidgetCollection.fullscreen().value()})},this._handleClick=()=>{const{chartWidgetCollection:e}=this.context,{clickArea:t}=this.props;e.fullscreen().value()?e.exitFullscreen():e.startFullscreen()},(0,r.validateRegistry)(t,{chartWidgetCollection:i.any.isRequired}),this.state={isFullscreen:this.context.chartWidgetCollection.fullscreen().value()},this._subscribe()}render(){const{className:e,id:t,isActive:i}=this.props,{isFullscreen:r}=this.state;return n.createElement(l.ToolbarIconButton,{id:t,icon:r?u:d,onClick:this._handleClick,className:o(e),tooltip:s.t(null,void 0,a(67092)),"data-tooltip-hotkey":m,isActive:i})}componentWillUnmount(){this._unsubscribe()}_subscribe(){this.context.chartWidgetCollection.fullscreen().subscribe(this._updateState)}_unsubscribe(){this.context.chartWidgetCollection.fullscreen().unsubscribe(this._updateState)}}p.contextType=v},68976:(e,t,a)=>{"use strict";a.d(t,{RegistryProvider:()=>r,registryContextType:()=>c,validateRegistry:()=>l});var n=a(50959),i=a(19036),o=a.n(i);const s=n.createContext({});function l(e,t){o().checkPropTypes(t,e,"context","RegistryContext")}function r(e){const{validation:t,value:a}=e;return l(a,t),n.createElement(s.Provider,{value:a},e.children)}function c(){return s}},99678:(e,t,a)=>{"use strict";a.r(t),a.d(t,{SERIES_ICONS:()=>g}) ;var n=a(4475),i=a(94670),o=a(87778),s=a(39956),l=a(14083),r=a(45504),c=a(52867),h=a(41473),d=a(31246),u=a(15726),m=a(24464),v=a(71705),p=a(9450);const g={3:i,16:o,0:s,1:l,8:r,9:c,2:h,14:d,15:u,10:m,12:v,13:p};g[21]=n},12850:(e,t,a)=>{"use strict";function n(e){return"https://www.tradingview.com/x/"+e+"/"}a.d(t,{convertImageNameToUrl:()=>n})},53977:(e,t,a)=>{"use strict";function n(e,t){const a=document.createElement("a");a.style.display="none",a.href=t,a.download=e,a.click()}a.d(t,{downloadFile:()=>n})},29142:e=>{e.exports=''},97268:e=>{e.exports=''},36992:e=>{e.exports=''},87778:e=>{e.exports=''},13090:e=>{e.exports=''},6198:e=>{e.exports=''},99280:e=>{ e.exports=''},60448:e=>{e.exports=''},21233:e=>{e.exports=''},94670:e=>{e.exports=''},39956:e=>{e.exports=''},24464:e=>{ e.exports=''},14083:e=>{e.exports=''},53707:e=>{e.exports=''},9450:e=>{e.exports=''},1393:e=>{e.exports=''},45504:e=>{e.exports=''},71705:e=>{e.exports=''},4475:e=>{e.exports=''},52867:e=>{ e.exports=''},39681:e=>{e.exports=''},31246:e=>{e.exports=''},41473:e=>{e.exports=''},82436:e=>{e.exports=''},96052:e=>{e.exports=''},72644:e=>{e.exports=''},15726:e=>{e.exports=''},77665:e=>{ e.exports=''},36296:e=>{e.exports=''},23595:e=>{e.exports=''},29414:e=>{e.exports=''},67487:e=>{e.exports=''}}]);