@liberfi.io/ui-tradingview 0.1.234 → 0.1.236
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +39 -12
- package/dist/index.d.ts +39 -12
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -81,7 +81,7 @@ type SeriesType = number;
|
|
|
81
81
|
interface SeriesFormatterFactory {
|
|
82
82
|
(symbolInfo: LibrarySymbolInfo | null, minTick: string): {
|
|
83
83
|
format: (price: number) => string;
|
|
84
|
-
};
|
|
84
|
+
} | null;
|
|
85
85
|
}
|
|
86
86
|
interface ChartingLibraryWidgetOptions {
|
|
87
87
|
container: string | HTMLElement;
|
|
@@ -388,6 +388,7 @@ declare class ChartAreaManager {
|
|
|
388
388
|
get symbolInfo(): LibrarySymbolInfo | null;
|
|
389
389
|
destroy(): void;
|
|
390
390
|
private handleChartReady;
|
|
391
|
+
private applyChartStyle;
|
|
391
392
|
}
|
|
392
393
|
|
|
393
394
|
/**
|
|
@@ -457,6 +458,8 @@ declare class ChartManager {
|
|
|
457
458
|
setReverseColor(reverseColor: boolean): void;
|
|
458
459
|
setLayout(layout: TvChartLayout): void;
|
|
459
460
|
reloadChart(): void;
|
|
461
|
+
setResolution(resolution: TvChartResolution): Promise<void>;
|
|
462
|
+
setChartStyle(chartStyle: SeriesType): void;
|
|
460
463
|
updateChartContents(): void;
|
|
461
464
|
get settingsData(): {
|
|
462
465
|
layout: TvChartLayout;
|
|
@@ -509,6 +512,7 @@ declare enum TvChartTheme {
|
|
|
509
512
|
Dark = "dark"
|
|
510
513
|
}
|
|
511
514
|
declare enum TvChartFeature {
|
|
515
|
+
IframeLoadingCompatibilityMode = "iframe_loading_compatibility_mode",
|
|
512
516
|
HeaderWidget = "header_widget",
|
|
513
517
|
HeaderCandleStyleMenu = "header_candle_style_menu",
|
|
514
518
|
HeaderFullscreenButton = "header_fullscreen_button",
|
|
@@ -678,6 +682,7 @@ declare const TradingViewProvider: react.ForwardRefExoticComponent<TradingViewCo
|
|
|
678
682
|
children?: react.ReactNode | undefined;
|
|
679
683
|
} & react.RefAttributes<TvChartHandle>>;
|
|
680
684
|
|
|
685
|
+
type TradingViewMultiChartSymbolSelector = (activeTickerSymbol: string) => Promise<string | null | undefined>;
|
|
681
686
|
interface TradingViewToolbarProps {
|
|
682
687
|
/** Extra elements to render before the default toolbar items */
|
|
683
688
|
prefix?: ReactNode;
|
|
@@ -697,8 +702,18 @@ interface TradingViewToolbarProps {
|
|
|
697
702
|
showFullscreen?: boolean;
|
|
698
703
|
/** Show/hide snapshot button (default: true) */
|
|
699
704
|
showSnapshot?: boolean;
|
|
705
|
+
/** Show/hide multi-chart layout selector (default: false) */
|
|
706
|
+
showMultiChartSelect?: boolean;
|
|
707
|
+
/** Show/hide price/market-cap switch (default: false) */
|
|
708
|
+
showPriceTypeSwitch?: boolean;
|
|
709
|
+
/** Show/hide USD/native quote switch (default: false) */
|
|
710
|
+
showQuoteTypeSwitch?: boolean;
|
|
711
|
+
/** Native quote displayed by the quote switch */
|
|
712
|
+
nativeQuote?: TvChartQuoteType;
|
|
713
|
+
/** Opens the consumer token picker and returns the selected chart symbol */
|
|
714
|
+
onSelectMultiChartSymbol?: TradingViewMultiChartSymbolSelector;
|
|
700
715
|
}
|
|
701
|
-
declare const TradingViewToolbar: react.MemoExoticComponent<({ children, prefix: prefixSlot, suffix, showResolutions, showKlineStyleSelect, showOpenIndicator, showOpenSettings, showFullscreen, showSnapshot, }: TradingViewToolbarProps) => react_jsx_runtime.JSX.Element>;
|
|
716
|
+
declare const TradingViewToolbar: react.MemoExoticComponent<({ children, prefix: prefixSlot, suffix, showResolutions, showKlineStyleSelect, showOpenIndicator, showOpenSettings, showFullscreen, showSnapshot, showMultiChartSelect, showPriceTypeSwitch, showQuoteTypeSwitch, nativeQuote, onSelectMultiChartSymbol, }: TradingViewToolbarProps) => react_jsx_runtime.JSX.Element>;
|
|
702
717
|
|
|
703
718
|
interface TradingViewInstance {
|
|
704
719
|
handle: TvChartHandle;
|
|
@@ -742,6 +757,7 @@ declare const TradingViewWidgetContainer: react.ForwardRefExoticComponent<Tradin
|
|
|
742
757
|
|
|
743
758
|
interface TvChartToolbarContextValue {
|
|
744
759
|
activeAreaManager: ChartAreaManager | null;
|
|
760
|
+
activeTickerSymbol: string;
|
|
745
761
|
symbolInfo: LibrarySymbolInfo | null;
|
|
746
762
|
}
|
|
747
763
|
declare function useTvChartToolbarContext(): TvChartToolbarContextValue;
|
|
@@ -751,6 +767,24 @@ declare const TradingViewResolutions: react.MemoExoticComponent<() => react_jsx_
|
|
|
751
767
|
|
|
752
768
|
declare const TradingViewKlineStyleSelect: react.MemoExoticComponent<() => react_jsx_runtime.JSX.Element>;
|
|
753
769
|
|
|
770
|
+
interface TradingViewMultiChartSelectProps {
|
|
771
|
+
/** Opens the consumer token picker and returns its chart symbol. */
|
|
772
|
+
onSelectSymbol?: (activeTickerSymbol: string) => Promise<string | null | undefined>;
|
|
773
|
+
}
|
|
774
|
+
/** Adds a selected token as a chart and chooses its layout automatically. */
|
|
775
|
+
declare const TradingViewMultiChartSelect: react.MemoExoticComponent<({ onSelectSymbol }: TradingViewMultiChartSelectProps) => react_jsx_runtime.JSX.Element>;
|
|
776
|
+
|
|
777
|
+
interface TradingViewPriceTypeSwitchProps {
|
|
778
|
+
className?: string;
|
|
779
|
+
}
|
|
780
|
+
declare const TradingViewPriceTypeSwitch: react.MemoExoticComponent<({ className }: TradingViewPriceTypeSwitchProps) => react_jsx_runtime.JSX.Element | null>;
|
|
781
|
+
|
|
782
|
+
interface TradingViewQuoteTypeSwitchProps {
|
|
783
|
+
nativeQuote: TvChartQuoteType;
|
|
784
|
+
className?: string;
|
|
785
|
+
}
|
|
786
|
+
declare const TradingViewQuoteTypeSwitch: react.MemoExoticComponent<({ nativeQuote, className }: TradingViewQuoteTypeSwitchProps) => react_jsx_runtime.JSX.Element | null>;
|
|
787
|
+
|
|
754
788
|
declare const TradingViewOpenIndicator: react.MemoExoticComponent<() => react_jsx_runtime.JSX.Element>;
|
|
755
789
|
|
|
756
790
|
declare const TradingViewOpenSettings: react.MemoExoticComponent<() => react_jsx_runtime.JSX.Element>;
|
|
@@ -759,15 +793,8 @@ declare const TradingViewFullscreen: react.MemoExoticComponent<() => react_jsx_r
|
|
|
759
793
|
|
|
760
794
|
declare const TradingViewSnapshot: react.MemoExoticComponent<() => react_jsx_runtime.JSX.Element>;
|
|
761
795
|
|
|
762
|
-
/**
|
|
763
|
-
|
|
764
|
-
* The TradingView charting library renders charts into its own iframes,
|
|
765
|
-
* so layout-level customization is done via the bridge's installEventHooks.
|
|
766
|
-
*
|
|
767
|
-
* This component can be extended to inject custom UI above or around
|
|
768
|
-
* individual chart panes when multi-chart layouts are active.
|
|
769
|
-
*/
|
|
770
|
-
declare const TradingViewLayout: react.MemoExoticComponent<() => null>;
|
|
796
|
+
/** Injects the original per-area title and close interaction into multi-chart panes. */
|
|
797
|
+
declare function TradingViewLayout(): null;
|
|
771
798
|
|
|
772
799
|
interface TradingViewAreaTitleProps {
|
|
773
800
|
index?: number;
|
|
@@ -1065,4 +1092,4 @@ declare const settingsDataFamily: jotai_vanilla_utils_atomFamily.AtomFamily<stri
|
|
|
1065
1092
|
areaContents: ChartAreaState[];
|
|
1066
1093
|
}>>;
|
|
1067
1094
|
|
|
1068
|
-
export { ALL_TV_CHART_RESOLUTIONS, type Bar, type CandleSource, ChartAreaManager, type ChartAreaState, ChartDataFeed, ChartLibraryWidget, ChartManager, ChartSaveLoadAdapter, ChartSettings, ChartSettingsAdapter, ChartSettingsStore, ChartSymbolResolver, ChartWidget, ChartWidgetBridge, type ChartingLibraryWidgetOptions, DEFAULT_TV_CHART_MOBILE_BREAKPOINT_PX, DEFAULT_TV_CHART_RESOLUTIONS, ENABLED_TV_CHART_FEATURES, EventEmitter, type HistoryMetaInfo, type IChartWidgetApi, type IChartingLibraryWidget, type ITvChartDataFeedModule, type ITvChartSymbolResolver, type LanguageCode, type LibrarySymbolInfo, type Mark, type PeriodParams, type ResolutionString, SUPPORTED_TV_CHART_LAYOUTS, type SeriesFormatterFactory, type SubscribeBarsCallback, type SymbolResolveExtension, TV_CHART_THEME_COLORS, type ThemeName, type Timezone, TradingView, TradingViewAreaTitle, type TradingViewCandle, TradingViewConfig, type TradingViewConfigProps, TradingViewDatafeedAdapter, type TradingViewDatafeedAdapterOptions, TradingViewFullscreen, type TradingViewHistoryRequest, type TradingViewInstance, TradingViewKlineStyleSelect, TradingViewLayout, type TradingViewLiveSubscribeRequest, TradingViewOpenIndicator, TradingViewOpenSettings, type TradingViewProps, TradingViewProvider, type TradingViewProviderProps, TradingViewResolutions, TradingViewSnapshot, TradingViewToolbar, type TradingViewToolbarProps, TradingViewToolbarProvider, TradingViewWidgetContainer, TradingViewWidgetProvider, type TvChartConfig, type TvChartContextValue, TvChartErrorResetType, TvChartFeature, TvChartHandle, TvChartKlineStyle, TvChartLayout, TvChartPriceType, TvChartQuoteType, type TvChartResolution, type TvChartSymbol, type TvChartSymbolChange, type TvChartSymbolInfo, TvChartTheme, TvChartType, type WidgetConstructor, chartAreasFamily, chartFullscreenFamily, chartLoadingFamily, chartPinnedResolutionsFamily, chartSelectedIndexFamily, chartShowDrawingToolbarFamily, getTvChartLayoutReverse, getTvChartLibraryLayout, getTvChartLibraryLocale, getTvChartLibraryResolution, getTvChartLibraryTheme, getTvChartResolutionFrame, getTvChartResolutionReverse, getTvChartTickTimestamp, isTvChartMobileViewport, parseSymbol, settingsBackgroundColorFamily, settingsChartTypeFamily, settingsDataFamily, settingsDisabledFeaturesFamily, settingsEnabledFeaturesFamily, settingsLayoutFamily, settingsLocaleFamily, settingsReverseColorFamily, settingsStorageIdFamily, settingsThemeFamily, settingsTickerSymbolFamily, settingsTimezoneFamily, stringifySymbol, stringifySymbolShort, useActiveAreaManager, useChartManager, useSymbolInfo, useTvChartContext, useTvChartManager, useTvChartPrefix, useTvChartToolbarContext, widgetReadyFamily };
|
|
1095
|
+
export { ALL_TV_CHART_RESOLUTIONS, type Bar, type CandleSource, ChartAreaManager, type ChartAreaState, ChartDataFeed, ChartLibraryWidget, ChartManager, ChartSaveLoadAdapter, ChartSettings, ChartSettingsAdapter, ChartSettingsStore, ChartSymbolResolver, ChartWidget, ChartWidgetBridge, type ChartingLibraryWidgetOptions, DEFAULT_TV_CHART_MOBILE_BREAKPOINT_PX, DEFAULT_TV_CHART_RESOLUTIONS, ENABLED_TV_CHART_FEATURES, EventEmitter, type HistoryMetaInfo, type IChartWidgetApi, type IChartingLibraryWidget, type ITvChartDataFeedModule, type ITvChartSymbolResolver, type LanguageCode, type LibrarySymbolInfo, type Mark, type PeriodParams, type ResolutionString, SUPPORTED_TV_CHART_LAYOUTS, type SeriesFormatterFactory, type SubscribeBarsCallback, type SymbolResolveExtension, TV_CHART_THEME_COLORS, type ThemeName, type Timezone, TradingView, TradingViewAreaTitle, type TradingViewCandle, TradingViewConfig, type TradingViewConfigProps, TradingViewDatafeedAdapter, type TradingViewDatafeedAdapterOptions, TradingViewFullscreen, type TradingViewHistoryRequest, type TradingViewInstance, TradingViewKlineStyleSelect, TradingViewLayout, type TradingViewLiveSubscribeRequest, TradingViewMultiChartSelect, type TradingViewMultiChartSelectProps, type TradingViewMultiChartSymbolSelector, TradingViewOpenIndicator, TradingViewOpenSettings, TradingViewPriceTypeSwitch, type TradingViewPriceTypeSwitchProps, type TradingViewProps, TradingViewProvider, type TradingViewProviderProps, TradingViewQuoteTypeSwitch, type TradingViewQuoteTypeSwitchProps, TradingViewResolutions, TradingViewSnapshot, TradingViewToolbar, type TradingViewToolbarProps, TradingViewToolbarProvider, TradingViewWidgetContainer, TradingViewWidgetProvider, type TvChartConfig, type TvChartContextValue, TvChartErrorResetType, TvChartFeature, TvChartHandle, TvChartKlineStyle, TvChartLayout, TvChartPriceType, TvChartQuoteType, type TvChartResolution, type TvChartSymbol, type TvChartSymbolChange, type TvChartSymbolInfo, TvChartTheme, TvChartType, type WidgetConstructor, chartAreasFamily, chartFullscreenFamily, chartLoadingFamily, chartPinnedResolutionsFamily, chartSelectedIndexFamily, chartShowDrawingToolbarFamily, getTvChartLayoutReverse, getTvChartLibraryLayout, getTvChartLibraryLocale, getTvChartLibraryResolution, getTvChartLibraryTheme, getTvChartResolutionFrame, getTvChartResolutionReverse, getTvChartTickTimestamp, isTvChartMobileViewport, parseSymbol, settingsBackgroundColorFamily, settingsChartTypeFamily, settingsDataFamily, settingsDisabledFeaturesFamily, settingsEnabledFeaturesFamily, settingsLayoutFamily, settingsLocaleFamily, settingsReverseColorFamily, settingsStorageIdFamily, settingsThemeFamily, settingsTickerSymbolFamily, settingsTimezoneFamily, stringifySymbol, stringifySymbolShort, useActiveAreaManager, useChartManager, useSymbolInfo, useTvChartContext, useTvChartManager, useTvChartPrefix, useTvChartToolbarContext, widgetReadyFamily };
|
package/dist/index.d.ts
CHANGED
|
@@ -81,7 +81,7 @@ type SeriesType = number;
|
|
|
81
81
|
interface SeriesFormatterFactory {
|
|
82
82
|
(symbolInfo: LibrarySymbolInfo | null, minTick: string): {
|
|
83
83
|
format: (price: number) => string;
|
|
84
|
-
};
|
|
84
|
+
} | null;
|
|
85
85
|
}
|
|
86
86
|
interface ChartingLibraryWidgetOptions {
|
|
87
87
|
container: string | HTMLElement;
|
|
@@ -388,6 +388,7 @@ declare class ChartAreaManager {
|
|
|
388
388
|
get symbolInfo(): LibrarySymbolInfo | null;
|
|
389
389
|
destroy(): void;
|
|
390
390
|
private handleChartReady;
|
|
391
|
+
private applyChartStyle;
|
|
391
392
|
}
|
|
392
393
|
|
|
393
394
|
/**
|
|
@@ -457,6 +458,8 @@ declare class ChartManager {
|
|
|
457
458
|
setReverseColor(reverseColor: boolean): void;
|
|
458
459
|
setLayout(layout: TvChartLayout): void;
|
|
459
460
|
reloadChart(): void;
|
|
461
|
+
setResolution(resolution: TvChartResolution): Promise<void>;
|
|
462
|
+
setChartStyle(chartStyle: SeriesType): void;
|
|
460
463
|
updateChartContents(): void;
|
|
461
464
|
get settingsData(): {
|
|
462
465
|
layout: TvChartLayout;
|
|
@@ -509,6 +512,7 @@ declare enum TvChartTheme {
|
|
|
509
512
|
Dark = "dark"
|
|
510
513
|
}
|
|
511
514
|
declare enum TvChartFeature {
|
|
515
|
+
IframeLoadingCompatibilityMode = "iframe_loading_compatibility_mode",
|
|
512
516
|
HeaderWidget = "header_widget",
|
|
513
517
|
HeaderCandleStyleMenu = "header_candle_style_menu",
|
|
514
518
|
HeaderFullscreenButton = "header_fullscreen_button",
|
|
@@ -678,6 +682,7 @@ declare const TradingViewProvider: react.ForwardRefExoticComponent<TradingViewCo
|
|
|
678
682
|
children?: react.ReactNode | undefined;
|
|
679
683
|
} & react.RefAttributes<TvChartHandle>>;
|
|
680
684
|
|
|
685
|
+
type TradingViewMultiChartSymbolSelector = (activeTickerSymbol: string) => Promise<string | null | undefined>;
|
|
681
686
|
interface TradingViewToolbarProps {
|
|
682
687
|
/** Extra elements to render before the default toolbar items */
|
|
683
688
|
prefix?: ReactNode;
|
|
@@ -697,8 +702,18 @@ interface TradingViewToolbarProps {
|
|
|
697
702
|
showFullscreen?: boolean;
|
|
698
703
|
/** Show/hide snapshot button (default: true) */
|
|
699
704
|
showSnapshot?: boolean;
|
|
705
|
+
/** Show/hide multi-chart layout selector (default: false) */
|
|
706
|
+
showMultiChartSelect?: boolean;
|
|
707
|
+
/** Show/hide price/market-cap switch (default: false) */
|
|
708
|
+
showPriceTypeSwitch?: boolean;
|
|
709
|
+
/** Show/hide USD/native quote switch (default: false) */
|
|
710
|
+
showQuoteTypeSwitch?: boolean;
|
|
711
|
+
/** Native quote displayed by the quote switch */
|
|
712
|
+
nativeQuote?: TvChartQuoteType;
|
|
713
|
+
/** Opens the consumer token picker and returns the selected chart symbol */
|
|
714
|
+
onSelectMultiChartSymbol?: TradingViewMultiChartSymbolSelector;
|
|
700
715
|
}
|
|
701
|
-
declare const TradingViewToolbar: react.MemoExoticComponent<({ children, prefix: prefixSlot, suffix, showResolutions, showKlineStyleSelect, showOpenIndicator, showOpenSettings, showFullscreen, showSnapshot, }: TradingViewToolbarProps) => react_jsx_runtime.JSX.Element>;
|
|
716
|
+
declare const TradingViewToolbar: react.MemoExoticComponent<({ children, prefix: prefixSlot, suffix, showResolutions, showKlineStyleSelect, showOpenIndicator, showOpenSettings, showFullscreen, showSnapshot, showMultiChartSelect, showPriceTypeSwitch, showQuoteTypeSwitch, nativeQuote, onSelectMultiChartSymbol, }: TradingViewToolbarProps) => react_jsx_runtime.JSX.Element>;
|
|
702
717
|
|
|
703
718
|
interface TradingViewInstance {
|
|
704
719
|
handle: TvChartHandle;
|
|
@@ -742,6 +757,7 @@ declare const TradingViewWidgetContainer: react.ForwardRefExoticComponent<Tradin
|
|
|
742
757
|
|
|
743
758
|
interface TvChartToolbarContextValue {
|
|
744
759
|
activeAreaManager: ChartAreaManager | null;
|
|
760
|
+
activeTickerSymbol: string;
|
|
745
761
|
symbolInfo: LibrarySymbolInfo | null;
|
|
746
762
|
}
|
|
747
763
|
declare function useTvChartToolbarContext(): TvChartToolbarContextValue;
|
|
@@ -751,6 +767,24 @@ declare const TradingViewResolutions: react.MemoExoticComponent<() => react_jsx_
|
|
|
751
767
|
|
|
752
768
|
declare const TradingViewKlineStyleSelect: react.MemoExoticComponent<() => react_jsx_runtime.JSX.Element>;
|
|
753
769
|
|
|
770
|
+
interface TradingViewMultiChartSelectProps {
|
|
771
|
+
/** Opens the consumer token picker and returns its chart symbol. */
|
|
772
|
+
onSelectSymbol?: (activeTickerSymbol: string) => Promise<string | null | undefined>;
|
|
773
|
+
}
|
|
774
|
+
/** Adds a selected token as a chart and chooses its layout automatically. */
|
|
775
|
+
declare const TradingViewMultiChartSelect: react.MemoExoticComponent<({ onSelectSymbol }: TradingViewMultiChartSelectProps) => react_jsx_runtime.JSX.Element>;
|
|
776
|
+
|
|
777
|
+
interface TradingViewPriceTypeSwitchProps {
|
|
778
|
+
className?: string;
|
|
779
|
+
}
|
|
780
|
+
declare const TradingViewPriceTypeSwitch: react.MemoExoticComponent<({ className }: TradingViewPriceTypeSwitchProps) => react_jsx_runtime.JSX.Element | null>;
|
|
781
|
+
|
|
782
|
+
interface TradingViewQuoteTypeSwitchProps {
|
|
783
|
+
nativeQuote: TvChartQuoteType;
|
|
784
|
+
className?: string;
|
|
785
|
+
}
|
|
786
|
+
declare const TradingViewQuoteTypeSwitch: react.MemoExoticComponent<({ nativeQuote, className }: TradingViewQuoteTypeSwitchProps) => react_jsx_runtime.JSX.Element | null>;
|
|
787
|
+
|
|
754
788
|
declare const TradingViewOpenIndicator: react.MemoExoticComponent<() => react_jsx_runtime.JSX.Element>;
|
|
755
789
|
|
|
756
790
|
declare const TradingViewOpenSettings: react.MemoExoticComponent<() => react_jsx_runtime.JSX.Element>;
|
|
@@ -759,15 +793,8 @@ declare const TradingViewFullscreen: react.MemoExoticComponent<() => react_jsx_r
|
|
|
759
793
|
|
|
760
794
|
declare const TradingViewSnapshot: react.MemoExoticComponent<() => react_jsx_runtime.JSX.Element>;
|
|
761
795
|
|
|
762
|
-
/**
|
|
763
|
-
|
|
764
|
-
* The TradingView charting library renders charts into its own iframes,
|
|
765
|
-
* so layout-level customization is done via the bridge's installEventHooks.
|
|
766
|
-
*
|
|
767
|
-
* This component can be extended to inject custom UI above or around
|
|
768
|
-
* individual chart panes when multi-chart layouts are active.
|
|
769
|
-
*/
|
|
770
|
-
declare const TradingViewLayout: react.MemoExoticComponent<() => null>;
|
|
796
|
+
/** Injects the original per-area title and close interaction into multi-chart panes. */
|
|
797
|
+
declare function TradingViewLayout(): null;
|
|
771
798
|
|
|
772
799
|
interface TradingViewAreaTitleProps {
|
|
773
800
|
index?: number;
|
|
@@ -1065,4 +1092,4 @@ declare const settingsDataFamily: jotai_vanilla_utils_atomFamily.AtomFamily<stri
|
|
|
1065
1092
|
areaContents: ChartAreaState[];
|
|
1066
1093
|
}>>;
|
|
1067
1094
|
|
|
1068
|
-
export { ALL_TV_CHART_RESOLUTIONS, type Bar, type CandleSource, ChartAreaManager, type ChartAreaState, ChartDataFeed, ChartLibraryWidget, ChartManager, ChartSaveLoadAdapter, ChartSettings, ChartSettingsAdapter, ChartSettingsStore, ChartSymbolResolver, ChartWidget, ChartWidgetBridge, type ChartingLibraryWidgetOptions, DEFAULT_TV_CHART_MOBILE_BREAKPOINT_PX, DEFAULT_TV_CHART_RESOLUTIONS, ENABLED_TV_CHART_FEATURES, EventEmitter, type HistoryMetaInfo, type IChartWidgetApi, type IChartingLibraryWidget, type ITvChartDataFeedModule, type ITvChartSymbolResolver, type LanguageCode, type LibrarySymbolInfo, type Mark, type PeriodParams, type ResolutionString, SUPPORTED_TV_CHART_LAYOUTS, type SeriesFormatterFactory, type SubscribeBarsCallback, type SymbolResolveExtension, TV_CHART_THEME_COLORS, type ThemeName, type Timezone, TradingView, TradingViewAreaTitle, type TradingViewCandle, TradingViewConfig, type TradingViewConfigProps, TradingViewDatafeedAdapter, type TradingViewDatafeedAdapterOptions, TradingViewFullscreen, type TradingViewHistoryRequest, type TradingViewInstance, TradingViewKlineStyleSelect, TradingViewLayout, type TradingViewLiveSubscribeRequest, TradingViewOpenIndicator, TradingViewOpenSettings, type TradingViewProps, TradingViewProvider, type TradingViewProviderProps, TradingViewResolutions, TradingViewSnapshot, TradingViewToolbar, type TradingViewToolbarProps, TradingViewToolbarProvider, TradingViewWidgetContainer, TradingViewWidgetProvider, type TvChartConfig, type TvChartContextValue, TvChartErrorResetType, TvChartFeature, TvChartHandle, TvChartKlineStyle, TvChartLayout, TvChartPriceType, TvChartQuoteType, type TvChartResolution, type TvChartSymbol, type TvChartSymbolChange, type TvChartSymbolInfo, TvChartTheme, TvChartType, type WidgetConstructor, chartAreasFamily, chartFullscreenFamily, chartLoadingFamily, chartPinnedResolutionsFamily, chartSelectedIndexFamily, chartShowDrawingToolbarFamily, getTvChartLayoutReverse, getTvChartLibraryLayout, getTvChartLibraryLocale, getTvChartLibraryResolution, getTvChartLibraryTheme, getTvChartResolutionFrame, getTvChartResolutionReverse, getTvChartTickTimestamp, isTvChartMobileViewport, parseSymbol, settingsBackgroundColorFamily, settingsChartTypeFamily, settingsDataFamily, settingsDisabledFeaturesFamily, settingsEnabledFeaturesFamily, settingsLayoutFamily, settingsLocaleFamily, settingsReverseColorFamily, settingsStorageIdFamily, settingsThemeFamily, settingsTickerSymbolFamily, settingsTimezoneFamily, stringifySymbol, stringifySymbolShort, useActiveAreaManager, useChartManager, useSymbolInfo, useTvChartContext, useTvChartManager, useTvChartPrefix, useTvChartToolbarContext, widgetReadyFamily };
|
|
1095
|
+
export { ALL_TV_CHART_RESOLUTIONS, type Bar, type CandleSource, ChartAreaManager, type ChartAreaState, ChartDataFeed, ChartLibraryWidget, ChartManager, ChartSaveLoadAdapter, ChartSettings, ChartSettingsAdapter, ChartSettingsStore, ChartSymbolResolver, ChartWidget, ChartWidgetBridge, type ChartingLibraryWidgetOptions, DEFAULT_TV_CHART_MOBILE_BREAKPOINT_PX, DEFAULT_TV_CHART_RESOLUTIONS, ENABLED_TV_CHART_FEATURES, EventEmitter, type HistoryMetaInfo, type IChartWidgetApi, type IChartingLibraryWidget, type ITvChartDataFeedModule, type ITvChartSymbolResolver, type LanguageCode, type LibrarySymbolInfo, type Mark, type PeriodParams, type ResolutionString, SUPPORTED_TV_CHART_LAYOUTS, type SeriesFormatterFactory, type SubscribeBarsCallback, type SymbolResolveExtension, TV_CHART_THEME_COLORS, type ThemeName, type Timezone, TradingView, TradingViewAreaTitle, type TradingViewCandle, TradingViewConfig, type TradingViewConfigProps, TradingViewDatafeedAdapter, type TradingViewDatafeedAdapterOptions, TradingViewFullscreen, type TradingViewHistoryRequest, type TradingViewInstance, TradingViewKlineStyleSelect, TradingViewLayout, type TradingViewLiveSubscribeRequest, TradingViewMultiChartSelect, type TradingViewMultiChartSelectProps, type TradingViewMultiChartSymbolSelector, TradingViewOpenIndicator, TradingViewOpenSettings, TradingViewPriceTypeSwitch, type TradingViewPriceTypeSwitchProps, type TradingViewProps, TradingViewProvider, type TradingViewProviderProps, TradingViewQuoteTypeSwitch, type TradingViewQuoteTypeSwitchProps, TradingViewResolutions, TradingViewSnapshot, TradingViewToolbar, type TradingViewToolbarProps, TradingViewToolbarProvider, TradingViewWidgetContainer, TradingViewWidgetProvider, type TvChartConfig, type TvChartContextValue, TvChartErrorResetType, TvChartFeature, TvChartHandle, TvChartKlineStyle, TvChartLayout, TvChartPriceType, TvChartQuoteType, type TvChartResolution, type TvChartSymbol, type TvChartSymbolChange, type TvChartSymbolInfo, TvChartTheme, TvChartType, type WidgetConstructor, chartAreasFamily, chartFullscreenFamily, chartLoadingFamily, chartPinnedResolutionsFamily, chartSelectedIndexFamily, chartShowDrawingToolbarFamily, getTvChartLayoutReverse, getTvChartLibraryLayout, getTvChartLibraryLocale, getTvChartLibraryResolution, getTvChartLibraryTheme, getTvChartResolutionFrame, getTvChartResolutionReverse, getTvChartTickTimestamp, isTvChartMobileViewport, parseSymbol, settingsBackgroundColorFamily, settingsChartTypeFamily, settingsDataFamily, settingsDisabledFeaturesFamily, settingsEnabledFeaturesFamily, settingsLayoutFamily, settingsLocaleFamily, settingsReverseColorFamily, settingsStorageIdFamily, settingsThemeFamily, settingsTickerSymbolFamily, settingsTimezoneFamily, stringifySymbol, stringifySymbolShort, useActiveAreaManager, useChartManager, useSymbolInfo, useTvChartContext, useTvChartManager, useTvChartPrefix, useTvChartToolbarContext, widgetReadyFamily };
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
'use strict';var react=require('react'),jotai=require('jotai'),utils=require('jotai/utils'),lodashEs=require('lodash-es'),jsxRuntime=require('react/jsx-runtime'),i18n=require('@liberfi.io/i18n');var te=(t=>(t.TradingView="TradingView",t.Original="Original",t))(te||{}),Ue=(t=>(t.Price="price",t.MarketCap="market_cap",t))(Ue||{}),ze=(o=>(o.USD="USD",o.SOL="SOL",o.ETH="ETH",o.TRX="TRX",o.BNB="BNB",o))(ze||{}),re=(d=>(d[d.Bars=0]="Bars",d[d.Candles=1]="Candles",d[d.Line=2]="Line",d[d.Area=3]="Area",d[d.HeikenAshi=8]="HeikenAshi",d[d.HollowCandles=9]="HollowCandles",d[d.Baseline=10]="Baseline",d[d.HiLo=12]="HiLo",d[d.Column=13]="Column",d[d.LineWithMarkers=14]="LineWithMarkers",d[d.Stepline=15]="Stepline",d[d.HLCArea=16]="HLCArea",d[d.VolCandle=19]="VolCandle",d[d.Renko=4]="Renko",d[d.Kagi=5]="Kagi",d[d.PointAndFigure=6]="PointAndFigure",d[d.LineBreak=7]="LineBreak",d))(re||{}),$e=(t=>(t.Light="light",t.Dark="dark",t))($e||{}),ae=(C=>(C.HeaderWidget="header_widget",C.HeaderCandleStyleMenu="header_candle_style_menu",C.HeaderFullscreenButton="header_fullscreen_button",C.TradingAccountManager="trading_account_manager",C.MultiCharts="multi_charts",C.CreateVolumeIndicatorByDefault="create_volume_indicator_by_default",C.VolumeForceOverlay="volume_force_overlay",C.HideDrawingToolsByDefault="hide_drawing_tools_by_default",C.LegendSeriesTitle="legend_series_title",C.LegendVolume="legend_volume",C.TimeframesToolbar="timeframes_toolbar",C.SaveDrawingToServer="save_drawing_to_server",C))(ae||{}),I=(g=>(g.Layout1A="1A",g.Layout2A="2A",g.Layout2B="2B",g.Layout3A="3A",g.Layout3B="3B",g.Layout3C="3C",g.Layout3D="3D",g.Layout3E="3E",g.Layout3F="3F",g.Layout4A="4A",g.Layout4B="4B",g.Layout4C="4C",g.Layout4D="4D",g.Layout4E="4E",g.Layout4F="4F",g.Layout5A="5A",g.Layout5B="5B",g.Layout5C="5C",g.Layout5D="5D",g.Layout6A="6A",g.Layout6B="6B",g.Layout6C="6C",g.Layout7A="7A",g.Layout8A="8A",g.Layout8B="8B",g.Layout8C="8C",g))(I||{}),qe=(r=>(r[r.None=0]="None",r[r.ResetData=1]="ResetData",r[r.ResetChart=2]="ResetChart",r))(qe||{});var pe=["header_widget","header_candle_style_menu","header_fullscreen_button","multi_charts","volume_force_overlay","legend_series_title","timeframes_toolbar","save_drawing_to_server"],T=["1s","30s","1m","1h","4h","1d"],w=["1s","15s","30s","1m","5m","15m","1h","4h","12h","1d"],ye=["1A","2A","2B","3A","3B","3C","3D","3E","3F","4A","4B","4C","4D","4E","4F","5A","5B","5C","5D","6A","6B","6C","7A","8A","8B","8C"],Je=["click","keydown","mousedown","mouseup","contextmenu"],S={decrease:"#f76816",increase:"#c7ff2e",chartBg:"#050807",card:"#0e1211"},Ge={card:"#242424"};var M=utils.atomFamily(a=>jotai.atom(true)),_=utils.atomFamily(a=>jotai.atom(false)),b=utils.atomFamily(a=>jotai.atom(0)),x=utils.atomFamily(a=>jotai.atom([...T])),y=utils.atomFamily(a=>jotai.atom([])),L=utils.atomFamily(a=>jotai.atom(false)),P=utils.atomFamily(a=>jotai.atom("1A")),A=utils.atomFamily(a=>jotai.atom("TradingView")),D=utils.atomFamily(a=>jotai.atom("dark")),ie=utils.atomFamily(a=>jotai.atom("en")),oe=utils.atomFamily(a=>jotai.atom("Etc/UTC")),se=utils.atomFamily(a=>jotai.atom("")),O=utils.atomFamily(a=>jotai.atom("kline")),ne=utils.atomFamily(a=>jotai.atom(false)),le=utils.atomFamily(a=>jotai.atom(null)),Ce=utils.atomFamily(a=>jotai.atom(null)),be=utils.atomFamily(a=>jotai.atom(null)),F=utils.atomFamily(a=>jotai.atom([])),V=utils.atomFamily(a=>jotai.atom([])),W=utils.atomFamily(a=>jotai.atom(false)),N=utils.atomFamily(a=>jotai.atom(e=>{let t=e(P(a)),r=e(A(a)),i=e(b(a)),o=e(x(a)),s=e(L(a)),n=e(y(a));return {layout:t,chartType:r,selectedIndex:i,pinnedResolutions:o,showDrawingToolbar:s,areaContents:n}}),lodashEs.isEqual);var k=class{settings;chartManager;chartIndex;store;prefix;pendingTickerSymbol=null;pendingResolution=null;constructor(e,t,r,i,o,s){this.settings=e,this.chartManager=t,this.chartIndex=r,this.store=i,this.prefix=o;let l={...{resolution:"1m",chartStyle:1,symbol:"",tickerSymbol:"",rightOffset:10,barSpacing:6,dataReady:false},...s};this.patchArea(l);}get state(){return this.store.get(y(this.prefix))[this.chartIndex]??{resolution:"1m",chartStyle:1,symbol:"",tickerSymbol:"",rightOffset:10,barSpacing:6,dataReady:false}}patchArea(e){let t=[...this.store.get(y(this.prefix))],r=t[this.chartIndex]??{resolution:"1m",chartStyle:1,symbol:"",tickerSymbol:"",rightOffset:10,barSpacing:6,dataReady:false};t[this.chartIndex]={...r,...e},this.store.set(y(this.prefix),t);}setState(e,t){t!=null&&this.patchArea({[e]:t});}get tickerSymbol(){return this.state.tickerSymbol}get symbol(){return this.state.symbol}get resolution(){return this.state.resolution}get chartStyle(){return this.state.chartStyle}get rightOffset(){return this.state.rightOffset}get barSpacing(){return this.state.barSpacing}get dataReady(){return this.state.dataReady}get internalChartWidget(){return this.chartManager.internalWidget?.chartByIndex(this.chartIndex)}setChartStyle(e){this.setState("chartStyle",e),this.internalChartWidget?.setChartStyle(e);}async setSymbol(e){if(this.state.tickerSymbol!==e){this.setState("tickerSymbol",e),this.setState("dataReady",false),this.pendingTickerSymbol=e;try{let t=[this.internalChartWidget?.handleSymbolChange(e,this.tickerSymbol),this.chartManager.symbolResolver?.resolveSymbolInfo(e).then(r=>{r&&this.setState("symbol",r.name);})];for(let r of await Promise.allSettled(t))if(r.status==="rejected")throw r.reason}catch(t){console.error(t);}finally{this.pendingTickerSymbol===e&&(this.pendingTickerSymbol=null);}this.tickerSymbol===e&&this.setState("dataReady",true);}}async setResolution(e){if(this.resolution!==e){this.setState("resolution",e),this.setState("dataReady",false),this.pendingResolution=e;try{await this.internalChartWidget?.handleResolutionChange(e,this.resolution);}finally{this.pendingResolution===e&&(this.pendingResolution=null);}}}toJSON(){return {...this.state}}widgetReady(){this.internalChartWidget?.dataReady()?.then(()=>this.handleChartReady())?.catch(()=>{});}get active(){return this.chartIndex<this.chartManager.chartCount}get selected(){return this.chartManager.selectedIndex===this.chartIndex}get symbolInfo(){return this.chartManager.symbolResolver?.getSymbolInfo(this.tickerSymbol)??null}destroy(){}async handleChartReady(){this.internalChartWidget&&(this.setState("dataReady",true),this.selected&&this.internalChartWidget.setBarSpacing(this.barSpacing));}};var H=class{prefix;settings;store;initialized=false;focused=false;reloadId=0;internalWidget=null;datafeed=null;symbolResolver=null;unsubAutoSave=null;constructor(e,t,r){this.prefix=e,this.store=t,this.settings=r;}get loading(){return this.store.get(M(this.prefix))}get fullscreen(){return this.store.get(_(this.prefix))}set fullscreen(e){this.store.set(_(this.prefix),e),e?document.body.classList.add("fullScreen"):document.body.classList.remove("fullScreen");}get selectedIndex(){return this.store.get(b(this.prefix))}set selectedIndex(e){this.store.set(b(this.prefix),e);}get pinnedResolutions(){return this.store.get(x(this.prefix))}set pinnedResolutions(e){this.store.set(x(this.prefix),e);}get showDrawingToolbar(){return this.store.get(L(this.prefix))}get chartCount(){return parseInt(this.settings.layout,10)||1}get areas(){let e=this.store.get(y(this.prefix));return this._areaManagers.slice(0,e.length)}_areaManagers=[];areaByIndex(e){return this.initialized&&this.updateChartContents(),this._areaManagers[e]??null}get activeArea(){return this.areaByIndex(this.selectedIndex)}async init(){if(this.initialized)return;let e=this.settings.saveLoadAdapter.getSettings();if(e?.selectedIndex!=null&&(this.selectedIndex=e.selectedIndex),e?.pinnedResolutions){let r=e.pinnedResolutions;r.length===T.length&&r.every(i=>T.includes(i))?this.pinnedResolutions=[...T]:this.pinnedResolutions=r;}if(e?.areaContents&&e.areaContents.forEach((r,i)=>{let o=new k(this.settings,this,i,this.store,this.prefix,r);this._areaManagers[i]=o;}),e?.showDrawingToolbar!=null&&this.store.set(L(this.prefix),e.showDrawingToolbar),this.settings.updateValue("layout",e?.layout),this.settings.updateValue("chartType",e?.chartType),this.settings.enableMultiCharts||this.settings.updateValue("layout","1A"),this.settings.enableHideDrawingToolsByDefault&&this.store.set(L(this.prefix),false),this.updateChartContents(),this.settings.tickerSymbol&&this.activeArea)try{await this.activeArea.setSymbol(this.settings.tickerSymbol);}catch(r){console.warn("ChartManager init failed to set symbol",r);}this.initialized=true;let t=lodashEs.debounce(()=>{let r=this.store.get(N(this.prefix));this.settings.saveLoadAdapter.saveSettings(r).catch(console.error);},1e3);this.unsubAutoSave=this.store.sub(N(this.prefix),t);}destroy(){this.unsubAutoSave?.(),this._areaManagers.forEach(e=>e.destroy()),this._areaManagers=[];}setLoading(e){this.store.set(M(this.prefix),e);}setLocale(e){this.settings.updateValue("locale",e);}setTimezone(e){this.settings.updateValue("timezone",e);}setFocused(e){this.focused=e;}setShowDrawingToolbar(e){this.store.set(L(this.prefix),e);}setInternalWidget(e){this.internalWidget=e,this.store.set(W(this.prefix),false);}onInternalWidgetReady(){this.store.set(W(this.prefix),true),this.areas.forEach((e,t)=>{t<this.chartCount&&e.widgetReady();});}setChartType(e){this.settings.updateValue("chartType",e);}setTheme(e){this.settings.theme!==e&&(this.settings.updateValue("theme",e),this.internalWidget?.onThemeChange?.(e,this.settings.reverseColor));}setColorPalette(e){this.settings.updateValue("backgroundColor",e.backgroundColor),this.settings.updateValue("increaseColor",e.increaseColor),this.settings.updateValue("decreaseColor",e.decreaseColor),this.internalWidget?.bridge.applyColorPaletteOverrides();}setReverseColor(e){this.settings.reverseColor!==e&&(this.settings.updateValue("reverseColor",e),this.internalWidget?.onThemeChange?.(this.settings.theme,e));}setLayout(e){let t=this.settings.enableMultiCharts?e:"1A";if(this.settings.layout!==t){this.settings.updateValue("layout",t),this.updateChartContents(),this.internalWidget?.onLayoutChange?.(t);let r=this.chartCount;setTimeout(()=>{if(this.store.get(W(this.prefix)))for(let i=r;i<this.chartCount;i++)this.areaByIndex(i)?.widgetReady();});}}reloadChart(){this.reloadId+=1;}updateChartContents(){if(this.chartCount>this._areaManagers.length)for(let e=this._areaManagers.length;e<this.chartCount;e++){let t=this._areaManagers[this.selectedIndex],r=t?.toJSON(),i=new k(this.settings,this,e,this.store,this.prefix,r);this._areaManagers[e]=i,this.selectedIndex!==e&&!t&&i.setSymbol(this.settings.tickerSymbol).catch(()=>{});}this.selectedIndex>=this.chartCount&&(this.selectedIndex=this.chartCount-1);}get settingsData(){return this.store.get(N(this.prefix))}getAllCharts(){return this.updateChartContents(),this._areaManagers.slice(0,this.chartCount)}};var U=class{storageId;constructor(e){this.storageId=e;}get settingsKey(){return `${this.storageId}.TvChart.Settings`}get shapesKey(){return `${this.storageId}.TvChart.Shapes`}getSettings(){let e=this.getLocalSettingsData(),t=this.getChartStoreData();return {layout:t?.layout,selectedIndex:t?.currentAreaIndex,chartType:t?.chartType,pinnedResolutions:t?.pinnedResolutions,areaContents:t?.areas?.map(i=>({resolution:i.resolution||i.period||"1m",chartStyle:i.chartStyle,symbol:i.symbol,tickerSymbol:i.tickerSymbol,rightOffset:i.rightOffset,barSpacing:i.barSpacing})),showDrawingToolbar:t?.drawing?.toolbarSwitch,drawing:e?.drawing?{...e.drawing,defaultStates:lodashEs.omit(e,["drawing","DrawingToolGroupLastUsedTool","riskRewardAvailableChanged","riskRewardRiskSizeChanged","drawingShapeTemplate"]),lastUsedTools:e.DrawingToolGroupLastUsedTool,riskRewardAvailableChanged:e.riskRewardAvailableChanged,riskRewardRiskSizeChanged:e.riskRewardRiskSizeChanged,drawingShapeTemplate:e.drawingShapeTemplate}:void 0}}getChartStoreData(){return this.getLocalData(this.storageId)}setChartStoreData(e){this.setLocalData(this.storageId,e);}async saveSettings(e){let t=this.getChartStoreData(),r={...t,layout:e.layout,currentAreaIndex:e.selectedIndex,chartType:e.chartType,pinnedResolutions:e.pinnedResolutions,areas:e.areaContents?.map((i,o)=>({...t?.areas?.[o],...i})),drawing:{...t?.drawing,toolbarSwitch:e.showDrawingToolbar}};this.setChartStoreData(r);}async getShapes(e){let t=this.getLocalShapesData();return !t||!t[e]?[]:Object.values(t[e])}async saveShapes(e,t){let r=this.getLocalShapesData()||{};r[e]={...r[e],...t},Object.keys(r[e]).forEach(i=>{r[e][i]||delete r[e][i];}),this.setLocalShapesData(r);}getLocalData(e){try{let t=localStorage.getItem(e);return t?JSON.parse(t):null}catch{return null}}setLocalData(e,t){localStorage.setItem(e,JSON.stringify(t));}getLocalSettingsData(){return this.getLocalData(this.settingsKey)}getLocalShapesData(){return this.getLocalData(this.shapesKey)}setLocalShapesData(e){this.setLocalData(this.shapesKey,e);}};function de(a){let[e,t,r,i]=a.split("/");return {address:t,chain:e,quote:r,priceType:i}}function wt(a){return !a.quote||!a.priceType?`${a.chain}/${a.address}`:`${a.chain}/${a.address}/${a.quote}/${a.priceType}`}function he(a){return `${a.chain}/${a.address}`}var xt={dark:"Dark",light:"Light"};function B(a){return xt[a.toLowerCase()]??"Dark"}var Ke={"1s":"1S","5s":"5S","15s":"15S","30s":"30S","1m":"1","5m":"5","15m":"15","30m":"30","1h":"60","4h":"240","12h":"720","1d":"1D"};function f(a="1m"){return Ke[a]??Ke["1m"]}var Lt={"1S":"1s","5S":"5s","15S":"15s","30S":"30s",1:"1m",5:"5m",15:"15m",30:"30m",60:"1h",240:"4h",720:"12h","1D":"1d"};function z(a){return Lt[a]??"1s"}var Rt={en:"en","zh-CN":"zh","zh-TW":"zh"};function It(a){return Rt[a]??a}var Ye={"1A":"s","2A":"2h","2B":"2v","3A":"3s","3B":"3h","3C":"3v","3D":"2-1","3E":"1-2","3F":"3r","4A":"4","4B":"4h","4C":"4v","4D":"4s","4E":"1-3","4F":"2-2","5A":"1-4","5B":"5s","5C":"2-3","5D":"5h","6A":"6","6B":"6c","6C":"6h","7A":"7h","8A":"8","8B":"8c","8C":"8h"};function $(a){return Ye[a]??"s"}var Mt=Object.fromEntries(Object.entries(Ye).map(([a,e])=>[e,a]));function fe(a){return Mt[a]??"1A"}var _t={"1s":1e3,"5s":5e3,"15s":15e3,"30s":3e4,"1m":6e4,"5m":3e5,"15m":9e5,"30m":18e5,"1h":36e5,"4h":144e5,"12h":432e5,"1d":864e5};function ge(a){let e=_t[a];if(!e)throw new Error(`Invalid interval: ${a}`);return e}function ve(a,e){let t=a.toString().length>10?a:1e3*a;return Math.floor(t/e)*e}var q=class{prefix;store;supportedResolutions=w.map(f);supportedLayouts=ye;supportedChartTypes=["TradingView"];chartNames={};priceFormatterFactory=null;saveLoadAdapter;constructor(e,t){this.prefix=e,this.store=t,this.saveLoadAdapter=new U(e),this.store.set(O(e),e);}get layout(){return this.store.get(P(this.prefix))}get chartType(){return this.store.get(A(this.prefix))}get theme(){return this.store.get(D(this.prefix))}get reverseColor(){return this.store.get(ne(this.prefix))}get locale(){return this.store.get(ie(this.prefix))}get timezone(){return this.store.get(oe(this.prefix))}get tickerSymbol(){return this.store.get(se(this.prefix))}get storageId(){return this.store.get(O(this.prefix))}get backgroundColor(){return this.store.get(le(this.prefix))}get increaseColor(){return this.store.get(Ce(this.prefix))}get decreaseColor(){return this.store.get(be(this.prefix))}get enabledFeatures(){return this.store.get(F(this.prefix))}get disabledFeatures(){return this.store.get(V(this.prefix))}updateValue(e,t){if(t==null)return;let i={layout:()=>this.store.set(P(this.prefix),t),chartType:()=>this.store.set(A(this.prefix),t),theme:()=>this.store.set(D(this.prefix),t),reverseColor:()=>this.store.set(ne(this.prefix),t),locale:()=>this.store.set(ie(this.prefix),t),timezone:()=>this.store.set(oe(this.prefix),t),tickerSymbol:()=>this.store.set(se(this.prefix),t),storageId:()=>this.store.set(O(this.prefix),t),backgroundColor:()=>this.store.set(le(this.prefix),t),increaseColor:()=>this.store.set(Ce(this.prefix),t),decreaseColor:()=>this.store.set(be(this.prefix),t),enabledFeatures:()=>this.store.set(F(this.prefix),t),disabledFeatures:()=>this.store.set(V(this.prefix),t)}[e];i&&i();}isFeatureEnabled(e){return !this.disabledFeatures.includes(e)&&this.enabledFeatures.includes(e)||pe.includes(e)}setFeature(e,t){this.resetFeature(e),t?this.store.set(F(this.prefix),[...this.enabledFeatures,e]):this.store.set(V(this.prefix),[...this.disabledFeatures,e]);}resetFeature(e){this.store.set(F(this.prefix),this.enabledFeatures.filter(t=>t!==e)),this.store.set(V(this.prefix),this.disabledFeatures.filter(t=>t!==e));}get enableMultiCharts(){return this.isFeatureEnabled("multi_charts")}get enableCreateVolumeIndicatorByDefault(){return this.isFeatureEnabled("create_volume_indicator_by_default")}get enableHideDrawingToolsByDefault(){return this.isFeatureEnabled("hide_drawing_tools_by_default")}get enableLegendSeriesTitle(){return this.isFeatureEnabled("legend_series_title")}get enableLegendVolume(){return this.isFeatureEnabled("legend_volume")}get enableTimeframesToolbar(){return this.isFeatureEnabled("timeframes_toolbar")}get enableVolumeForceOverlay(){return this.isFeatureEnabled("volume_force_overlay")}sub(e,t){let i={layout:P(this.prefix),chartType:A(this.prefix),theme:D(this.prefix)}[e];return i?this.store.sub(i,t):()=>{}}};var J=class{datafeed;cache=new Map;pendingRequests=new Map;constructor(e){this.datafeed=e;}async resolveSymbolInfo(e){return this.datafeed.resolveSymbol(e)}async resolveSymbolInfos(e){return e.filter(r=>!this.cache.has(r)&&!this.pendingRequests.has(r)).forEach(r=>{let i=this.resolveSymbolInfo(r);i.then(o=>{o&&this.cache.set(r,o);}).catch(()=>{}).finally(()=>this.pendingRequests.delete(r)),this.pendingRequests.set(r,i);}),await Promise.all(e.filter(r=>this.pendingRequests.has(r)).map(r=>this.pendingRequests.get(r))),e.map(r=>this.cache.get(r)??null).filter(r=>r!==null)}getSymbolInfo(e){return this.resolveSymbolInfo(e).catch(t=>{console.error("ChartSymbolResolver.getSymbolInfo",t);}),this.cache.get(e)??null}};var Te=({initConfig:a,children:e})=>{let{chartManager:t,chartSettings:r}=h(),[i,o]=react.useState(false);return react.useEffect(()=>{t.initialized||(r.updateValue("tickerSymbol",a.tickerSymbol),r.updateValue("theme",a.theme),r.updateValue("reverseColor",a.reverseColor),r.updateValue("layout",a.layout),r.updateValue("chartType",a.chartType),r.updateValue("timezone",a.timezone),r.updateValue("locale",a.locale),r.updateValue("backgroundColor",a.backgroundColor),r.updateValue("increaseColor",a.increaseColor),r.updateValue("decreaseColor",a.decreaseColor),r.updateValue("storageId",a.storageId),r.updateValue("enabledFeatures",a.enabledFeatures),r.updateValue("disabledFeatures",a.disabledFeatures),a.chartNames&&(r.chartNames=a.chartNames),a.priceFormatterFactory&&(r.priceFormatterFactory=a.priceFormatterFactory),a.supportedResolutions&&(r.supportedResolutions=a.supportedResolutions),a.supportedLayouts&&(r.supportedLayouts=a.supportedLayouts),a.supportedChartTypes&&(r.supportedChartTypes=a.supportedChartTypes),t.datafeed=a.datafeed,t.symbolResolver=new J(a.datafeed));},[t,r,a]),react.useEffect(()=>{i&&(t.setTheme(a.theme),t.setColorPalette({backgroundColor:a.backgroundColor,increaseColor:a.increaseColor,decreaseColor:a.decreaseColor}));},[t,i,a.backgroundColor,a.decreaseColor,a.increaseColor,a.theme]),react.useEffect(()=>(t.init().then(()=>o(true)).catch(s=>{console.error("TradingViewConfig chartManager init error",s);}),()=>{t.destroy();}),[t]),i&&t.initialized?jsxRuntime.jsx(jsxRuntime.Fragment,{children:e}):null};var Qe=react.createContext(null);function h(){let a=react.useContext(Qe);if(!a)throw new Error("useTvChartContext must be used within TradingViewProvider");return a}function Ot(){return h().chartManager}function Wt(){return h().prefix}var ce=class{setting;chartManager;constructor(e,t){this.setting=e,this.chartManager=t;}get internalWidget(){return this.chartManager.internalWidget}chartCount(){return this.chartManager.chartCount}setActiveChart(e){e<this.chartCount()&&(this.chartManager.selectedIndex=e);}layout(){return this.setting.layout}setLayout(e){this.chartManager.setLayout(e);}theme(){return this.setting.theme}setTheme(e){this.chartManager.setTheme(e);}setChartType(e){this.chartManager.setChartType(e);}getSetting(){return this.setting}getChartManager(){return this.chartManager}},we=react.forwardRef(({children:a,initConfig:e,widgetConstructor:t,libraryPath:r,customCssUrl:i},o)=>{let s=jotai.useStore(),n=e.storageId,l=react.useMemo(()=>new q(n,s),[n,s]),u=react.useMemo(()=>new H(n,s,l),[n,s,l]),c=react.useMemo(()=>new ce(l,u),[l,u]);react.useImperativeHandle(o,()=>c,[c]);let v=react.useMemo(()=>({prefix:n,chartSettings:l,chartManager:u,widgetConstructor:t,libraryPath:r,customCssUrl:i}),[n,l,u,t,r,i]);return jsxRuntime.jsx(Qe.Provider,{value:v,children:jsxRuntime.jsx(Te,{initConfig:e,children:a})})});var xe=react.memo(()=>{let{t:a}=i18n.useTranslation(),{prefix:e,chartManager:t}=h(),r=jotai.useAtomValue(_(e)),i=react.useCallback(()=>{t.fullscreen=!t.fullscreen;},[t]);return jsxRuntime.jsx("button",{type:"button",onClick:i,className:"text-xs text-muted-foreground hover:text-foreground px-1.5 py-0.5 rounded hover:bg-muted cursor-pointer transition-colors",title:a(r?"tradingView.exitFullscreen":"tradingView.fullscreen"),children:a(r?"tradingView.exit":"tradingView.fullscreen")})});var je=react.createContext(null);function G(){let a=react.useContext(je);if(!a)throw new Error("useTvChartToolbarContext must be used within TradingViewToolbarProvider");return a}var Re=({children:a})=>{let{prefix:e,chartManager:t}=h(),r=jotai.useAtomValue(b(e)),i=jotai.useAtomValue(y(e)),o=react.useMemo(()=>i.length?t.areaByIndex(r):null,[t,r,i]),s=react.useMemo(()=>o?.symbolInfo??null,[o]),n=react.useMemo(()=>({activeAreaManager:o,symbolInfo:s}),[o,s]);return jsxRuntime.jsx(je.Provider,{value:n,children:a})};var tt={0:"tradingView.style.bars",1:"tradingView.style.candles",2:"tradingView.style.line",3:"tradingView.style.area",8:"tradingView.style.heikenAshi",9:"tradingView.style.hollowCandles",10:"tradingView.style.baseline"},Qt=[1,0,2,3,9,8,10],Ie=react.memo(()=>{let{t:a}=i18n.useTranslation(),{prefix:e}=h(),{activeAreaManager:t}=G(),r=jotai.useAtomValue(y(e)),i=jotai.useAtomValue(b(e)),o=r[i]?.chartStyle??1,s=react.useCallback(n=>{let l=parseInt(n.target.value,10);t?.setChartStyle(l);},[t]);return jsxRuntime.jsx("select",{value:o,onChange:s,className:"text-xs bg-transparent text-muted-foreground hover:text-foreground cursor-pointer border-none outline-none px-1 py-0.5",title:a("tradingView.klineStyle"),children:Qt.map(n=>jsxRuntime.jsx("option",{value:n,children:tt[n]?a(tt[n]):n},n))})});var Me=react.memo(()=>{let{t:a}=i18n.useTranslation(),{chartManager:e}=h(),t=react.useCallback(()=>{e.internalWidget?.openIndicatorSettingsDialog();},[e]);return jsxRuntime.jsx("button",{type:"button",onClick:t,className:"text-xs text-muted-foreground hover:text-foreground px-1.5 py-0.5 rounded hover:bg-muted cursor-pointer transition-colors",title:a("tradingView.indicators"),children:a("tradingView.indicators")})});var _e=react.memo(()=>{let{t:a}=i18n.useTranslation(),{chartManager:e}=h(),t=react.useCallback(()=>{e.internalWidget?.openSettingsDialog();},[e]);return jsxRuntime.jsx("button",{type:"button",onClick:t,className:"text-xs text-muted-foreground hover:text-foreground px-1.5 py-0.5 rounded hover:bg-muted cursor-pointer transition-colors",title:a("tradingView.chartSettings"),children:a("tradingView.settings")})});var Ae=react.memo(()=>{let{t:a}=i18n.useTranslation(),{prefix:e}=h(),{activeAreaManager:t}=G(),r=jotai.useAtomValue(x(e)),i=jotai.useAtomValue(y(e)),o=jotai.useAtomValue(b(e)),s=i[o]?.resolution,n=react.useCallback(l=>{t?.setResolution(l);},[t]);return jsxRuntime.jsx("div",{className:"flex items-center gap-0.5",children:r.map(l=>jsxRuntime.jsx("button",{type:"button",onClick:()=>n(l),className:`px-2 py-0.5 text-xs rounded cursor-pointer transition-colors ${s===l?"bg-primary text-primary-foreground":"text-muted-foreground hover:text-foreground hover:bg-muted"}`,children:a(`common.resolution.${l}`)},l))})});var Fe=react.memo(()=>{let{t:a}=i18n.useTranslation(),{chartManager:e}=h(),t=react.useCallback(async()=>{try{let r=await e.internalWidget?.takeClientScreenshot();if(!r)return;let i=document.createElement("a");i.download=`chart-${Date.now()}.png`,i.href=r.toDataURL("image/png"),i.click();}catch(r){console.error("TradingViewSnapshot",r);}},[e]);return jsxRuntime.jsx("button",{type:"button",onClick:t,className:"text-xs text-muted-foreground hover:text-foreground px-1.5 py-0.5 rounded hover:bg-muted cursor-pointer transition-colors",title:a("tradingView.takeSnapshot"),children:a("tradingView.snapshot")})});var ke=react.memo(({children:a,prefix:e,suffix:t,showResolutions:r=true,showKlineStyleSelect:i=true,showOpenIndicator:o=true,showOpenSettings:s=true,showFullscreen:n=true,showSnapshot:l=true})=>jsxRuntime.jsx(Re,{children:jsxRuntime.jsxs("div",{className:"flex items-center gap-1 px-2 py-1 border-b border-border min-h-[36px] flex-shrink-0",children:[e,a??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[r&&jsxRuntime.jsx(Ae,{}),jsxRuntime.jsxs("div",{className:"flex items-center gap-0.5 ml-auto",children:[i&&jsxRuntime.jsx(Ie,{}),o&&jsxRuntime.jsx(Me,{}),s&&jsxRuntime.jsx(_e,{}),l&&jsxRuntime.jsx(Fe,{}),n&&jsxRuntime.jsx(xe,{})]})]}),t]})}));var K=class{settings;chartManager;bridge;chartIndex;constructor(e,t,r,i){this.settings=e,this.chartManager=t,this.bridge=r,this.chartIndex=i;}get chartAreaManager(){return this.chartManager.areaByIndex(this.chartIndex)}get widget(){return this.bridge.getWidget()}get chartWidget(){return this.widget?.chart(this.chartIndex)??null}setChartStyle(e){this.chartWidget?.setChartType(e);}getChartStyle(){return this.chartWidget?.chartType()??1}handleSymbolChange(e,t){return this.bridge.asyncWidgetMethodContext((r,i)=>{r.chart(this.chartIndex).setSymbol(e,{dataReady:()=>i(),doNotActivateChart:false});})}handleResolutionChange(e,t){return this.bridge.asyncWidgetMethodContext((r,i)=>{let o=r.chart(this.chartIndex);o.dataReady(()=>{o.setResolution(f(e),{dataReady:i,doNotActivateChart:true}).catch(()=>{});});})}setPrecision(e){this.widget?.applyOverrides({"mainSeriesProperties.minTick":e===null?"default":`${Math.pow(10,e)},1,false`});}async dataReady(){if(await this.bridge.onReady(),!this.chartWidget)throw Error("ChartWidget: chartWidget is null");return new Promise(e=>{this.chartWidget?.dataReady(()=>setTimeout(e));})}timeScaleWidth(){return this.chartWidget?.getTimeScale()?.width()??NaN}rightOffset(){return this.chartWidget?.getTimeScale()?.rightOffset()??NaN}setRightOffset(e){this.chartWidget?.getTimeScale()?.setRightOffset(e);}barSpacing(){return this.chartWidget?.getTimeScale()?.barSpacing()??NaN}setBarSpacing(e){this.chartWidget?.getTimeScale()?.setBarSpacing(e);}};var Y=class{settings;chartManager;bridge;constructor(e,t,r){this.settings=e,this.chartManager=t,this.bridge=r;}get widget(){return this.bridge.getWidget()}chartByIndex(e){return new K(this.settings,this.chartManager,this.bridge,e)}activeChart(){let e=this.widget?.activeChartIndex();return e===void 0?void 0:this.chartByIndex(e)}openIndicatorSettingsDialog(){this.widget?.activeChart().executeActionById("insertIndicator");}openSettingsDialog(){this.widget?.activeChart().executeActionById("chartProperties");}takeClientScreenshot(){return this.widget?.takeClientScreenshot()}onLayoutChange(e){this.widget?.setLayout($(e));}async onThemeChange(e,t){let r=B(e);await this.widget?.changeTheme(r,{disableUndo:true}),this.bridge.applyColorPaletteOverrides();}};var X=class{listeners=new Map;on(e,t){return this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(t),()=>{this.listeners.get(e)?.delete(t);}}emit(e,t){this.listeners.get(e)?.forEach(r=>r(t));}off(e,t){this.listeners.get(e)?.delete(t);}clear(){this.listeners.clear();}};var Q=class{settings;chartManager;bridge;abortController=new AbortController;constructor(e,t,r){this.settings=e,this.chartManager=t,this.bridge=r;}toJSON(){return null}async onReady(e){setTimeout(()=>{e({supported_resolutions:w.map(f),supports_marks:true,exchanges:[]});}),await this.chartManager.datafeed?.onReady({setting:this.settings,chartManager:this.chartManager,instance:this.bridge});}destroy(){this.abortController.abort();}async resolveSymbol(e,t,r,i){try{let o=await this.chartManager.datafeed?.resolveSymbol(e,i);o&&t(o);}catch(o){console.error("ChartDataFeed.resolveSymbol",o),r(o);}}async getBars(e,t,r,i,o){try{let s=await this.chartManager.datafeed?.getBars(e,t,r);s&&i(s,{noData:s.length===0});}catch(s){console.error("ChartDataFeed.getBars",s),o(s);}}subscribeBars(e,t,r,i,o){this.chartManager.datafeed?.subscribeBars(e,t,r,i,o);}unsubscribeBars(e){this.chartManager.datafeed?.unsubscribeBars(e);}async getMarks(e,t,r,i,o){this.chartManager.datafeed?.getMarks?.(e,t,r,i,o);}getQuotes(e,t,r){t(e.map(i=>({s:"ok",n:i,v:{}})));}subscribeQuotes(e,t,r,i){}unsubscribeQuotes(e){}};var Z=class{settings;chartManager;bridge;data;drawings;constructor(e,t,r){this.settings=e,this.chartManager=t,this.bridge=r,this.data=null,this.drawings=null,this.loadDataFromLocalStorage();}get layoutId(){return this.settings.storageId}get shouldResetColorPalette(){let e=this.data?.theme,t=this.data?.reverseColor;return e!==this.settings.theme||t!==this.settings.reverseColor}toJSON(){return null}getAllCharts(){return new Promise(e=>{let t=[];this.data&&t.push({id:this.data.id,name:this.data.name,symbol:this.data.symbol,resolution:this.data.resolution,timestamp:this.data.timestamp}),e(t);})}removeChart(e){throw Error("Method not implemented.")}async saveChart(e){return this.data={...e,theme:this.settings.theme,reverseColor:this.settings.reverseColor,id:this.layoutId,timestamp:0},this.saveDataToLocalStorage(),this.data.id}getChartContent(e){return new Promise(t=>{let r=JSON.parse(this.data.content),i=JSON.parse(r.charts_symbols),o=JSON.parse(r.content);t(JSON.stringify({...r,chart_symbols:JSON.stringify(i),content:JSON.stringify(o)}));})}async saveLineToolsAndGroups(e,t,r){this.drawings=this.drawings||{data:{},timestamp:0},this.drawings.data=this.drawings.data||{},this.drawings.data[t]=this.drawings.data[t]||{};try{if(!r.sources)return;for(let[i,o]of r.sources)if(!o||!o.symbol||!o.state||Object.keys(o.state).length===0||i.includes("/"))o===null&&delete this.drawings.data[t][i];else {let{address:s,chain:n}=de(o.symbol),l=he({address:s,chain:n}),u={...o,symbol:l,id:o.id.indexOf("/")>0?o.id.split("/")[0]:o.id};this.drawings.data[t][i]=u;}this.saveDataToLocalStorage();}catch(i){console.error("saveLineToolsAndGroups",i);}}async loadLineToolsAndGroups(e,t,r,i){if(!i?.symbol||!this.drawings?.data?.[t])return null;let o=i.symbol,{address:s,chain:n}=de(o),l=he({address:s,chain:n}),u=lodashEs.uniqBy(Object.values(lodashEs.cloneDeep(this.drawings.data[t])).filter(c=>c.symbol===l),"id");try{return {sources:new Map(u.map(c=>{let v=lodashEs.cloneDeep({...c,symbol:o});return [v.id,v]}))}}catch(c){return console.error("ChartSaveLoadAdapter.loadLineToolsAndGroups",c),null}}getLayoutKey(e){return `charts.tradingview.data.${e}`}getDrawingKey(e){return `charts.tradingview.drawing.${e}`}loadDataFromLocalStorage(){let e=this.getLayoutKey(this.layoutId),t=this.getDrawingKey(this.layoutId),r=localStorage.getItem(e),i=localStorage.getItem(t);if(r)try{let o=JSON.parse(r),s=JSON.parse(o.content);o.content=JSON.stringify(s),this.data=o;}catch(o){console.error("ChartSaveLoadAdapter loadDataFromLocalStorage parse layout error",o);}if(i)try{this.drawings=JSON.parse(i);}catch(o){console.error("ChartSaveLoadAdapter loadDataFromLocalStorage parse drawing error",o);}}saveDataToLocalStorage(){let e=this.getLayoutKey(this.layoutId),t=this.getDrawingKey(this.layoutId),r=Math.round(Date.now()/1e3);this.data&&(this.data.timestamp=r,localStorage.setItem(e,JSON.stringify(this.data))),this.drawings&&(this.drawings.timestamp=r,localStorage.setItem(t,JSON.stringify(this.drawings)));}};var Be="trading.chart.proterty",j=class{storagePrefix;initialSettings;constructor(e,t,r){this.storagePrefix=`tradingview.${e.storageId}.`,this.initialSettings={};for(let o=0;o<localStorage.length;o++){let s=localStorage.key(o);if(s&&s.startsWith(this.storagePrefix)){let n=s.slice(this.storagePrefix.length);this.initialSettings[n]=localStorage.getItem(s);}}let i={noConfirmEnabled:1};if(this.initialSettings[Be])try{let o=JSON.parse(this.initialSettings[Be]);Object.assign(i,o),Object.assign(i,{noConfirmEnabled:!0});}catch(o){console.error("ChartSettingsAdapter: failed to parse chart settings",o);}this.initialSettings[Be]=JSON.stringify(i);}toJSON(){return null}removeValue(e){delete this.initialSettings[e],localStorage.removeItem(`${this.storagePrefix}${e}`);}setValue(e,t){this.initialSettings[e]=t,localStorage.setItem(`${this.storagePrefix}${e}`,t);}};var ee=class{settings;chartManager;WidgetCtor;moduleInstances=new Map;symbolIntervalSubs=new Map;abortController=new AbortController;widgetReadyPromise=null;readyPromise=null;widget=null;container=null;ready=false;layoutReady=true;events=new X;libraryPath;customCssUrl;constructor(e,t,r,i){this.settings=e,this.chartManager=t,this.WidgetCtor=r,this.libraryPath=i?.libraryPath??"/static/charting_library/",this.customCssUrl=i?.customCssUrl??"custom-styles.css",this.initModules();}getWidget(){return this.widget}async init(e){if(this.widgetReadyPromise)throw new Error("ChartWidgetBridge already initialized.");let t=this.getWidgetOptions();this.container=e,this.widget=new this.WidgetCtor({...t,container:e});let r=new Promise(i=>{this.widget?.onChartReady(()=>i());});this.widgetReadyPromise=r,this.readyPromise=r.then(()=>(this.ready=true,this.handleChartReady())).catch(i=>{console.warn("ChartWidgetBridge widget ready failed",i);}),this.moduleInstances.forEach((i,o)=>{try{i.init?.call(i);}catch(s){console.warn(`ChartWidgetBridge init module ${o}`,s);}}),await Promise.race([this.readyPromise,new Promise((i,o)=>setTimeout(o,6e4,new Error("ChartWidgetBridge init timeout")))]);}async destroy(){this.moduleInstances.forEach(e=>e.destroy?.call(e)),this.symbolIntervalSubs.forEach(e=>e()),this.symbolIntervalSubs.clear(),this.events.clear(),this.abortController.abort(),this.ready=false,this.widgetReadyPromise=null,this.readyPromise=null,this.widget?.remove(),this.widget=null;}async onReady(){return new Promise((e,t)=>{this.widget?this.widget.onChartReady(()=>this.readyPromise?.then(e).catch(t)):t(Error("cannot call `onReady` before `init`"));})}async asyncWidgetMethodContext(e){return new Promise((t,r)=>{if(!this.widgetReadyPromise){r(new Error("ChartWidgetBridge: widget not ready"));return}let i=this.widgetReadyPromise.then(()=>this.waitForLayout()),o=this.abortController.signal,s=()=>r(o.reason);o.addEventListener("abort",s),i.then(()=>e(this.widget,t)).catch(r).finally(()=>o.removeEventListener("abort",s));})}getModule(e){return this.moduleInstances.get(e)}applyColorPaletteOverrides(){this.widget?.applyOverrides(this.getColorPaletteOverrides()),this.widget?.applyStudiesOverrides(this.getColorPaletteStudiesOverrides());}getWidgetOptions(){let e=["header_widget","legend_inplace_edit","display_market_status","save_shortcut","show_interval_dialog_on_key_press","symbol_info","symbol_search_hot_key","uppercase_instrument_names","show_symbol_logo_in_legend","show_symbol_logo_for_compare_studies","drawing_templates",...this.settings.disabledFeatures],t=["determine_first_data_request_size_using_visible_range","request_only_visible_range_on_reset","show_exchange_logos","show_symbol_logos","dont_show_boolean_study_arguments","hide_last_na_study_output","hide_right_toolbar","seconds_resolution","saveload_separate_drawings_storage","volume_force_overlay","create_volume_indicator_by_default","two_character_bar_marks_labels",...this.settings.enabledFeatures];return this.settings.enableHideDrawingToolsByDefault&&t.push("hide_left_toolbar_by_default"),this.settings.enableTimeframesToolbar||e.push("timeframes_toolbar"),this.settings.enableCreateVolumeIndicatorByDefault||e.push("create_volume_indicator_by_default"),this.settings.enableVolumeForceOverlay||e.push("volume_force_overlay"),{container:"",autosize:true,debug:false,load_last_chart:true,auto_save_delay:1,timezone:this.localTimezone,library_path:this.libraryPath,custom_css_url:this.customCssUrl,theme:B(this.settings.theme),custom_font_family:window.getComputedStyle(document.body).fontFamily,symbol:this.chartManager.activeArea?.tickerSymbol,interval:f(this.chartManager.activeArea?.resolution),locale:this.settings.locale,datafeed:this.getModule("datafeed"),save_load_adapter:this.getModule("saveLoadAdapter"),settings_adapter:this.getModule("settingsAdapter"),custom_formatters:{priceFormatterFactory:this.settings.priceFormatterFactory?(r,i)=>this.settings.priceFormatterFactory(r,i):()=>null},overrides:{...this.getSettingsOverrides(),...this.getColorPaletteOverrides()},studies_overrides:this.getColorPaletteStudiesOverrides(),disabled_features:[...new Set(e)],enabled_features:[...new Set(t)].filter(r=>!e.includes(r)),supported_resolutions:w.map(f)}}async handleChartReady(){let e=$(this.settings.layout);e!==this.widget?.layout()&&await this.waitForLayout(e),this.widget?.setActiveChart(this.chartManager.selectedIndex),this.getModule("saveLoadAdapter")?.shouldResetColorPalette&&await this.widget?.changeTheme(B(this.settings.theme),{disableUndo:true}),this.applyColorPaletteOverrides(),this.widget?.subscribe("onAutoSaveNeeded",this.onAutoSaveNeeded.bind(this)),this.widget?.subscribe("activeChartChanged",this.activeChartChanged.bind(this)),this.widget?.subscribe("layout_about_to_be_changed",this.layoutWillChange.bind(this)),this.widget?.subscribe("layout_changed",this.layoutChanged.bind(this)),this.syncChartsChanges(),this.subscribeChartsChanges(),this.installEventHooks(),this.resetTimezone();}onAutoSaveNeeded(){try{this.widget?.saveChartToServer(void 0,void 0,{defaultChartName:"DEFAULT"});}catch(e){console.warn("ChartWidgetBridge.onAutoSaveNeeded",e);}}activeChartChanged(e){this.chartManager.selectedIndex=e,this.chartManager.settings.saveLoadAdapter.saveSettings(this.chartManager.settingsData).catch(console.error);}layoutWillChange(e){this.layoutReady=false,this.chartManager.setLayout(fe(e));}layoutChanged(){this.layoutReady=true,this.syncChartsChanges(),this.subscribeChartsChanges(),this.widget?.unloadUnusedCharts(),this.widget?.saveChartToServer();}syncChartsChanges(){this.widget?.symbolSync()?.setValue(false),this.widget?.intervalSync()?.setValue(false);let e=this.widget?.chartsCount()??0;for(let t=0;t<e;t++){let r=this.chartManager.areaByIndex(t),i=this.widget.chart(t);i.setSymbol(r?.tickerSymbol??"",{doNotActivateChart:true}),i.setResolution(f(r?.resolution),{doNotActivateChart:true});}}subscribeChartsChanges(){let e=this.widget?.chartsCount()??0;this.symbolIntervalSubs.forEach((t,r)=>{parseInt(r)>=e&&(t(),this.symbolIntervalSubs.delete(r));});for(let t=0;t<e;t++){if(this.symbolIntervalSubs.has(`${t}`))continue;let r=this.chartManager.areaByIndex(t),i=this.widget.chart(t);i.getPanes().forEach(u=>u.getMainSourcePriceScale()?.setAutoScale(true));let o=i.onSymbolChanged(),s=i.onIntervalChanged(),n=()=>{this.events.emit("symbolChanged",[t,i.symbol()]),r?.setSymbol(i.symbol()).catch(()=>{}),this.onAutoSaveNeeded();},l=u=>{let c=z(u);this.events.emit("resolutionChanged",[t,c]),r?.setResolution(c).catch(()=>{});};o.subscribe(r,n),s.subscribe(r,l),this.symbolIntervalSubs.set(`${t}`,()=>{o.unsubscribe(r,n),s.unsubscribe(r,l);});}}installEventHooks(){let e=this.container?.lastElementChild,t=e?.contentWindow?.document;if(t&&(t.addEventListener("click",()=>e?.click()),t.defaultView?.MutationObserver)){let r=new WeakSet,i=t.querySelector(".layout__area--center");if(i){let o=()=>{i.querySelectorAll(".chart-container").forEach((s,n)=>{r.has(s)||(r.add(s),Je.forEach(l=>{s.addEventListener(l,u=>this.events.emit("domEvent",[n,l,u]),{passive:true});}));});};new t.defaultView.MutationObserver(o).observe(i,{childList:true}),o();}}}resetTimezone(){try{let e=this.widget?.chartsCount()??0;for(let t=0;t<e;t++)this.widget?.chart(t)?.getTimezoneApi()?.setTimezone(this.localTimezone);}catch(e){console.error("ChartWidgetBridge: Reset timezone",e);}}get localTimezone(){return Intl.DateTimeFormat().resolvedOptions().timeZone}async waitForLayout(e){if(!this.widget||this.layoutReady&&!e)return;let t;return new Promise(i=>{t=i,this.widget.subscribe("layout_changed",i),e&&this.widget.setLayout(e);}).finally(()=>{this.widget.unsubscribe("layout_changed",t);})}getSettingsOverrides(){return {"mainSeriesProperties.minTick":"default","paneProperties.legendProperties.showSeriesTitle":this.settings.enableLegendSeriesTitle}}getColorPaletteOverrides(){let e=this.resolveThemeColor(this.settings.backgroundColor,S.chartBg),t=this.resolveThemeColor(this.settings.increaseColor,S.increase),r=this.resolveThemeColor(this.settings.decreaseColor,S.decrease),i=this.settings.theme==="dark"?S.card:Ge.card;return {"paneProperties.background":e,"paneProperties.backgroundType":"solid",volumePaneSize:"medium","mainSeriesProperties.candleStyle.upColor":t,"mainSeriesProperties.barStyle.upColor":t,"mainSeriesProperties.columnStyle.upColor":t,"mainSeriesProperties.candleStyle.downColor":r,"mainSeriesProperties.barStyle.downColor":r,"mainSeriesProperties.columnStyle.downColor":r,"mainSeriesProperties.candleStyle.borderUpColor":t,"mainSeriesProperties.candleStyle.borderDownColor":r,"mainSeriesProperties.candleStyle.wickUpColor":t,"mainSeriesProperties.candleStyle.wickDownColor":r,"mainSeriesProperties.hollowCandleStyle.upColor":t,"mainSeriesProperties.hollowCandleStyle.downColor":r,"mainSeriesProperties.hollowCandleStyle.borderUpColor":t,"mainSeriesProperties.hollowCandleStyle.borderDownColor":r,"mainSeriesProperties.hollowCandleStyle.wickUpColor":t,"mainSeriesProperties.hollowCandleStyle.wickDownColor":r,"mainSeriesProperties.haStyle.upColor":t,"mainSeriesProperties.haStyle.downColor":r,"mainSeriesProperties.haStyle.borderUpColor":t,"mainSeriesProperties.haStyle.borderDownColor":r,"mainSeriesProperties.haStyle.wickUpColor":t,"mainSeriesProperties.haStyle.wickDownColor":r,"mainSeriesProperties.lineStyle.color":t,"mainSeriesProperties.areaStyle.color1":t,"mainSeriesProperties.areaStyle.color2":e,"mainSeriesProperties.areaStyle.linecolor":t,"mainSeriesProperties.areaStyle.transparency":65,"mainSeriesProperties.baselineStyle.topFillColor1":t,"mainSeriesProperties.baselineStyle.topFillColor2":e,"mainSeriesProperties.baselineStyle.bottomFillColor1":r,"mainSeriesProperties.baselineStyle.bottomFillColor2":e,"mainSeriesProperties.baselineStyle.topLineColor":t,"mainSeriesProperties.baselineStyle.bottomLineColor":r,"mainSeriesProperties.baselineStyle.transparency":65,"linetoolorder.bodyBackgroundColor":i,"linetoolorder.bodyBackgroundTransparency":0}}getColorPaletteStudiesOverrides(){let e=this.resolveThemeColor(this.settings.increaseColor,S.increase);return {"volume.volume.color.0":this.resolveThemeColor(this.settings.decreaseColor,S.decrease),"volume.volume.color.1":e,"volume.volume.transparency":80}}resolveThemeColor(e,t){if(!e||!e.includes("var("))return e??t;if(typeof document>"u"||!document.body)return t;let r=document.createElement("span");r.style.color=e,r.style.display="none",document.body.appendChild(r);let i=window.getComputedStyle(r).color;return r.remove(),i||t}initModules(){Object.entries({datafeed:Q,saveLoadAdapter:Z,settingsAdapter:j}).forEach(([t,r])=>{this.moduleInstances.set(t,new r(this.settings,this.chartManager,this));});}};var Ee=react.memo(()=>null);var Oe=react.forwardRef(({onReady:a},e)=>{let{chartManager:t,chartSettings:r,widgetConstructor:i,libraryPath:o,customCssUrl:s}=h(),n=react.useRef(a),[l,u]=react.useState(),[c,v]=react.useState(null),[C,He]=react.useState(false);return react.useEffect(()=>{C&&n.current&&setTimeout(n.current);},[C]),react.useImperativeHandle(e,()=>l,[l]),react.useEffect(()=>{if(!c)return;let me=new ee(r,t,i,{libraryPath:o,customCssUrl:s}),bt=new Y(r,t,me);return u(bt),me.init(c).then(()=>He(true)).catch(ft=>{console.error("TradingViewWidgetContainer: failed to init bridge",ft);}),()=>{me.destroy().then(()=>{u(void 0),He(false);}).catch(()=>{console.error("TradingViewWidgetContainer: failed to destroy bridge");});}},[c,r,t,i,o,s]),jsxRuntime.jsxs("div",{className:"w-full h-full",children:[jsxRuntime.jsx(Ee,{}),jsxRuntime.jsx("div",{id:"tv_chart_container",className:"w-full h-full",ref:v})]})});var We=react.memo(({onReady:a})=>{let{chartManager:e,chartSettings:t}=h(),r=react.useMemo(()=>`${t.timezone}_${e.reloadId}`,[t.timezone,e.reloadId]);react.useLayoutEffect(()=>{e.setLoading(true);},[e,t.chartType,r]);let i=react.useCallback(()=>{a?.(),e.onInternalWidgetReady(),e.setLoading(false);},[e,a]);return jsxRuntime.jsx("div",{className:"h-full min-h-0 w-full overflow-hidden",children:jsxRuntime.jsx(Oe,{onReady:i,ref:o=>e.setInternalWidget(o??null)})})});var Mr=react.memo(({toolbar:a,loadingOverlay:e,onReady:t,children:r})=>{let{prefix:i}=h(),o=jotai.useAtomValue(M(i));return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[a!==false&&jsxRuntime.jsx(ke,{...a||{}}),jsxRuntime.jsxs("div",{className:"relative flex-1 w-full overflow-hidden",children:[o&&e&&jsxRuntime.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center bg-background/80",children:e}),jsxRuntime.jsx(We,{onReady:t})]}),r]})}),_r=react.forwardRef(({initConfig:a,widgetConstructor:e,libraryPath:t,customCssUrl:r,toolbar:i,loadingOverlay:o,onReady:s,children:n,className:l},u)=>jsxRuntime.jsx("div",{className:`flex flex-col w-full h-full ${l??""}`,children:jsxRuntime.jsx(we,{ref:u,initConfig:a,widgetConstructor:e,libraryPath:t,customCssUrl:r,children:jsxRuntime.jsx(Mr,{toolbar:i,loadingOverlay:o,onReady:s,children:n})})}));var Fr=react.memo(({index:a})=>{let{prefix:e}=h(),t=jotai.useAtomValue(y(e)),r=jotai.useAtomValue(b(e)),o=t[a??r];return o?jsxRuntime.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[jsxRuntime.jsx("span",{className:"font-medium text-foreground",children:o.tickerSymbol||o.symbol}),jsxRuntime.jsx("span",{children:o.resolution})]}):null});function kr(){return h().chartManager}function Er(){let{prefix:a,chartManager:e}=h(),t=jotai.useAtomValue(b(a)),r=jotai.useAtomValue(y(a));return react.useMemo(()=>r.length?e.areaByIndex(t):null,[e,t,r])}function Or(){let{prefix:a,chartManager:e}=h(),t=jotai.useAtomValue(b(a)),i=jotai.useAtomValue(y(a))[t];return react.useMemo(()=>i?.tickerSymbol?e.symbolResolver?.getSymbolInfo(i.tickerSymbol)??null:null,[e,i?.tickerSymbol])}var yt=768;function Ct(a,e=yt){return a>0&&a<e}function ct(a){try{return ge(a)}catch{return ge(z(a))}}function Wr(a){return a instanceof Date?a.getTime():a}function mt(a,e){let t={time:ve(Wr(a.time),e),open:a.open,high:a.high,low:a.low,close:a.close};return a.volume!==void 0&&(t.volume=a.volume),t}function pt(a,e){return `${a.ticker??a.name}:${e}`}var Ne=class{source;options;liveListeners=new Map;lastHistoryBarTime=new Map;liveGeneration=0;constructor(e,t={}){this.source=e,this.options=t;}isMobileViewport(e){return Ct(e,this.options.mobileBreakpointPx)}async onReady(e){await this.options.onReady?.(e);}onDestroy(){for(let e of [...this.liveListeners.keys()])this.unsubscribeLiveBars(e);this.lastHistoryBarTime.clear(),this.options.onDestroy?.();}async resolveSymbol(e,t){return await this.options.resolveSymbol?.(e,t)??null}async getBars(e,t,r){return this.getHistoryBars(e,t,r)}subscribeBars(e,t,r,i,o){this.subscribeLiveBars(e,t,r,i,o);}unsubscribeBars(e){this.unsubscribeLiveBars(e);}getMarks(e,t,r,i,o){this.options.getMarks?.(e,t,r,i,o);}getFirstBarTime(e,t,r){return this.options.getFirstBarTime?.(e,t,r)??Promise.resolve()}async getHistoryBars(e,t,r){let i=await this.source.getHistory({symbolInfo:e,resolution:t,periodParams:r}),o=ct(t),s=(i??[]).map(n=>mt(n,o));if(s.length>0){let n=pt(e,t),l=Math.max(...s.map(c=>c.time)),u=this.lastHistoryBarTime.get(n)??0;l>u&&this.lastHistoryBarTime.set(n,l);}return s}subscribeLiveBars(e,t,r,i,o){this.unsubscribeLiveBars(i);let s=pt(e,t),n=ct(t),l=++this.liveGeneration;this.liveListeners.set(i,{symbolKey:s,lastBarTime:this.lastHistoryBarTime.get(s)??0,generation:l}),this.source.subscribe({symbolInfo:e,resolution:t,listenerGuid:i,onResetCacheNeededCallback:o},u=>{let c=this.liveListeners.get(i);if(!c||c.generation!==l)return;let v=mt(u,n),C=Math.max(c.lastBarTime,this.lastHistoryBarTime.get(c.symbolKey)??0);v.time<C||(c.lastBarTime=v.time,r(v));});}unsubscribeLiveBars(e){this.liveListeners.has(e)&&(this.liveListeners.delete(e),this.source.unsubscribe(e));}};exports.ALL_TV_CHART_RESOLUTIONS=w;exports.ChartAreaManager=k;exports.ChartDataFeed=Q;exports.ChartLibraryWidget=Y;exports.ChartManager=H;exports.ChartSaveLoadAdapter=Z;exports.ChartSettings=q;exports.ChartSettingsAdapter=j;exports.ChartSettingsStore=U;exports.ChartSymbolResolver=J;exports.ChartWidget=K;exports.ChartWidgetBridge=ee;exports.DEFAULT_TV_CHART_MOBILE_BREAKPOINT_PX=yt;exports.DEFAULT_TV_CHART_RESOLUTIONS=T;exports.ENABLED_TV_CHART_FEATURES=pe;exports.EventEmitter=X;exports.SUPPORTED_TV_CHART_LAYOUTS=ye;exports.TV_CHART_THEME_COLORS=S;exports.TradingView=_r;exports.TradingViewAreaTitle=Fr;exports.TradingViewConfig=Te;exports.TradingViewDatafeedAdapter=Ne;exports.TradingViewFullscreen=xe;exports.TradingViewKlineStyleSelect=Ie;exports.TradingViewLayout=Ee;exports.TradingViewOpenIndicator=Me;exports.TradingViewOpenSettings=_e;exports.TradingViewProvider=we;exports.TradingViewResolutions=Ae;exports.TradingViewSnapshot=Fe;exports.TradingViewToolbar=ke;exports.TradingViewToolbarProvider=Re;exports.TradingViewWidgetContainer=Oe;exports.TradingViewWidgetProvider=We;exports.TvChartErrorResetType=qe;exports.TvChartFeature=ae;exports.TvChartHandle=ce;exports.TvChartKlineStyle=re;exports.TvChartLayout=I;exports.TvChartPriceType=Ue;exports.TvChartQuoteType=ze;exports.TvChartTheme=$e;exports.TvChartType=te;exports.chartAreasFamily=y;exports.chartFullscreenFamily=_;exports.chartLoadingFamily=M;exports.chartPinnedResolutionsFamily=x;exports.chartSelectedIndexFamily=b;exports.chartShowDrawingToolbarFamily=L;exports.getTvChartLayoutReverse=fe;exports.getTvChartLibraryLayout=$;exports.getTvChartLibraryLocale=It;exports.getTvChartLibraryResolution=f;exports.getTvChartLibraryTheme=B;exports.getTvChartResolutionFrame=ge;exports.getTvChartResolutionReverse=z;exports.getTvChartTickTimestamp=ve;exports.isTvChartMobileViewport=Ct;exports.parseSymbol=de;exports.settingsBackgroundColorFamily=le;exports.settingsChartTypeFamily=A;exports.settingsDataFamily=N;exports.settingsDisabledFeaturesFamily=V;exports.settingsEnabledFeaturesFamily=F;exports.settingsLayoutFamily=P;exports.settingsLocaleFamily=ie;exports.settingsReverseColorFamily=ne;exports.settingsStorageIdFamily=O;exports.settingsThemeFamily=D;exports.settingsTickerSymbolFamily=se;exports.settingsTimezoneFamily=oe;exports.stringifySymbol=wt;exports.stringifySymbolShort=he;exports.useActiveAreaManager=Er;exports.useChartManager=kr;exports.useSymbolInfo=Or;exports.useTvChartContext=h;exports.useTvChartManager=Ot;exports.useTvChartPrefix=Wt;exports.useTvChartToolbarContext=G;exports.widgetReadyFamily=W;//# sourceMappingURL=index.js.map
|
|
1
|
+
'use strict';var react=require('react'),jotai=require('jotai'),utils=require('jotai/utils'),lodashEs=require('lodash-es'),jsxRuntime=require('react/jsx-runtime'),i18n=require('@liberfi.io/i18n'),client=require('react-dom/client');var he=(t=>(t.TradingView="TradingView",t.Original="Original",t))(he||{}),ce=(t=>(t.Price="price",t.MarketCap="market_cap",t))(ce||{}),ue=(i=>(i.USD="USD",i.SOL="SOL",i.ETH="ETH",i.TRX="TRX",i.BNB="BNB",i))(ue||{}),ge=(g=>(g[g.Bars=0]="Bars",g[g.Candles=1]="Candles",g[g.Line=2]="Line",g[g.Area=3]="Area",g[g.HeikenAshi=8]="HeikenAshi",g[g.HollowCandles=9]="HollowCandles",g[g.Baseline=10]="Baseline",g[g.HiLo=12]="HiLo",g[g.Column=13]="Column",g[g.LineWithMarkers=14]="LineWithMarkers",g[g.Stepline=15]="Stepline",g[g.HLCArea=16]="HLCArea",g[g.VolCandle=19]="VolCandle",g[g.Renko=4]="Renko",g[g.Kagi=5]="Kagi",g[g.PointAndFigure=6]="PointAndFigure",g[g.LineBreak=7]="LineBreak",g))(ge||{}),ct=(t=>(t.Light="light",t.Dark="dark",t))(ct||{}),me=(m=>(m.IframeLoadingCompatibilityMode="iframe_loading_compatibility_mode",m.HeaderWidget="header_widget",m.HeaderCandleStyleMenu="header_candle_style_menu",m.HeaderFullscreenButton="header_fullscreen_button",m.TradingAccountManager="trading_account_manager",m.MultiCharts="multi_charts",m.CreateVolumeIndicatorByDefault="create_volume_indicator_by_default",m.VolumeForceOverlay="volume_force_overlay",m.HideDrawingToolsByDefault="hide_drawing_tools_by_default",m.LegendSeriesTitle="legend_series_title",m.LegendVolume="legend_volume",m.TimeframesToolbar="timeframes_toolbar",m.SaveDrawingToServer="save_drawing_to_server",m))(me||{}),M=(p=>(p.Layout1A="1A",p.Layout2A="2A",p.Layout2B="2B",p.Layout3A="3A",p.Layout3B="3B",p.Layout3C="3C",p.Layout3D="3D",p.Layout3E="3E",p.Layout3F="3F",p.Layout4A="4A",p.Layout4B="4B",p.Layout4C="4C",p.Layout4D="4D",p.Layout4E="4E",p.Layout4F="4F",p.Layout5A="5A",p.Layout5B="5B",p.Layout5C="5C",p.Layout5D="5D",p.Layout6A="6A",p.Layout6B="6B",p.Layout6C="6C",p.Layout7A="7A",p.Layout8A="8A",p.Layout8B="8B",p.Layout8C="8C",p))(M||{}),ut=(a=>(a[a.None=0]="None",a[a.ResetData=1]="ResetData",a[a.ResetChart=2]="ResetChart",a))(ut||{});var Ae=["header_widget","header_candle_style_menu","header_fullscreen_button","multi_charts","volume_force_overlay","legend_series_title","timeframes_toolbar","save_drawing_to_server"],_=["1s","30s","1m","1h","4h","1d"],A=["1s","15s","30s","1m","5m","15m","1h","4h","12h","1d"],ke=["1A","2A","2B","3A","3B","3C","3D","3E","3F","4A","4B","4C","4D","4E","4F","5A","5B","5C","5D","6A","6B","6C","7A","8A","8B","8C"],gt=["click","keydown","mousedown","mouseup","contextmenu"],V={decrease:"#f76816",increase:"#c7ff2e",chartBg:"#050807",card:"#0e1211"},mt={card:"#242424"};var W=utils.atomFamily(r=>jotai.atom(true)),P=utils.atomFamily(r=>jotai.atom(false)),T=utils.atomFamily(r=>jotai.atom(0)),k=utils.atomFamily(r=>jotai.atom([..._])),f=utils.atomFamily(r=>jotai.atom([])),F=utils.atomFamily(r=>jotai.atom(false)),I=utils.atomFamily(r=>jotai.atom("1A")),N=utils.atomFamily(r=>jotai.atom("TradingView")),J=utils.atomFamily(r=>jotai.atom("dark")),pe=utils.atomFamily(r=>jotai.atom("en")),ye=utils.atomFamily(r=>jotai.atom("Etc/UTC")),Ce=utils.atomFamily(r=>jotai.atom("")),Z=utils.atomFamily(r=>jotai.atom("kline")),fe=utils.atomFamily(r=>jotai.atom(false)),be=utils.atomFamily(r=>jotai.atom(null)),Fe=utils.atomFamily(r=>jotai.atom(null)),Ee=utils.atomFamily(r=>jotai.atom(null)),O=utils.atomFamily(r=>jotai.atom([])),H=utils.atomFamily(r=>jotai.atom([])),E=utils.atomFamily(r=>jotai.atom(false)),Q=utils.atomFamily(r=>jotai.atom(e=>{let t=e(I(r)),a=e(N(r)),o=e(T(r)),i=e(k(r)),s=e(F(r)),l=e(f(r));return {layout:t,chartType:a,selectedIndex:o,pinnedResolutions:i,showDrawingToolbar:s,areaContents:l}}),lodashEs.isEqual);var U=class{settings;chartManager;chartIndex;store;prefix;pendingTickerSymbol=null;pendingResolution=null;constructor(e,t,a,o,i,s){this.settings=e,this.chartManager=t,this.chartIndex=a,this.store=o,this.prefix=i;let n={...{resolution:"1m",chartStyle:1,symbol:"",tickerSymbol:"",rightOffset:10,barSpacing:6,dataReady:false},...s};this.patchArea(n);}get state(){return this.store.get(f(this.prefix))[this.chartIndex]??{resolution:"1m",chartStyle:1,symbol:"",tickerSymbol:"",rightOffset:10,barSpacing:6,dataReady:false}}patchArea(e){let t=[...this.store.get(f(this.prefix))],a=t[this.chartIndex]??{resolution:"1m",chartStyle:1,symbol:"",tickerSymbol:"",rightOffset:10,barSpacing:6,dataReady:false};t[this.chartIndex]={...a,...e},this.store.set(f(this.prefix),t);}setState(e,t){t!=null&&this.patchArea({[e]:t});}get tickerSymbol(){return this.state.tickerSymbol}get symbol(){return this.state.symbol}get resolution(){return this.state.resolution}get chartStyle(){return this.state.chartStyle}get rightOffset(){return this.state.rightOffset}get barSpacing(){return this.state.barSpacing}get dataReady(){return this.state.dataReady}get internalChartWidget(){return this.chartManager.internalWidget?.chartByIndex(this.chartIndex)}setChartStyle(e){this.setState("chartStyle",e),this.applyChartStyle();}async setSymbol(e){if(this.state.tickerSymbol!==e){this.setState("tickerSymbol",e),this.setState("dataReady",false),this.pendingTickerSymbol=e;try{let t=[this.internalChartWidget?.handleSymbolChange(e,this.tickerSymbol),this.chartManager.symbolResolver?.resolveSymbolInfo(e).then(a=>{a&&this.setState("symbol",a.name);})];for(let a of await Promise.allSettled(t))if(a.status==="rejected")throw a.reason}catch(t){console.error(t);}finally{this.pendingTickerSymbol===e&&(this.pendingTickerSymbol=null);}this.tickerSymbol===e&&this.setState("dataReady",true);}}async setResolution(e){let t=this.resolution;if(t!==e){this.setState("resolution",e),this.setState("dataReady",false),this.pendingResolution=e;try{await this.internalChartWidget?.handleResolutionChange(e,t);}finally{this.pendingResolution===e&&(this.pendingResolution=null);}}}toJSON(){return {...this.state}}widgetReady(){this.internalChartWidget?.dataReady()?.then(()=>this.handleChartReady())?.catch(()=>{});}get active(){return this.chartIndex<this.chartManager.chartCount}get selected(){return this.chartManager.selectedIndex===this.chartIndex}get symbolInfo(){return this.chartManager.symbolResolver?.getSymbolInfo(this.tickerSymbol)??null}destroy(){}async handleChartReady(){this.internalChartWidget&&(this.setState("dataReady",true),this.applyChartStyle(),this.selected&&this.internalChartWidget.setBarSpacing(this.barSpacing));}applyChartStyle(){try{this.internalChartWidget?.setChartStyle(this.chartStyle);}catch{}}};var K=class{prefix;settings;store;initialized=false;focused=false;reloadId=0;internalWidget=null;datafeed=null;symbolResolver=null;unsubAutoSave=null;constructor(e,t,a){this.prefix=e,this.store=t,this.settings=a;}get loading(){return this.store.get(W(this.prefix))}get fullscreen(){return this.store.get(P(this.prefix))}set fullscreen(e){this.store.set(P(this.prefix),e),e?document.body.classList.add("fullScreen"):document.body.classList.remove("fullScreen");}get selectedIndex(){return this.store.get(T(this.prefix))}set selectedIndex(e){this.store.set(T(this.prefix),e);}get pinnedResolutions(){return this.store.get(k(this.prefix))}set pinnedResolutions(e){this.store.set(k(this.prefix),e);}get showDrawingToolbar(){return this.store.get(F(this.prefix))}get chartCount(){return parseInt(this.settings.layout,10)||1}get areas(){let e=this.store.get(f(this.prefix));return this._areaManagers.slice(0,e.length)}_areaManagers=[];areaByIndex(e){return this.initialized&&this.updateChartContents(),this._areaManagers[e]??null}get activeArea(){return this.areaByIndex(this.selectedIndex)}async init(){if(this.initialized)return;let e=this.settings.saveLoadAdapter.getSettings();if(e?.selectedIndex!=null&&(this.selectedIndex=e.selectedIndex),e?.pinnedResolutions){let i=e.pinnedResolutions;i.length===_.length&&i.every(s=>_.includes(s))?this.pinnedResolutions=[..._]:this.pinnedResolutions=i;}e?.areaContents&&e.areaContents.forEach((i,s)=>{let l=new U(this.settings,this,s,this.store,this.prefix,i);this._areaManagers[s]=l;}),e?.showDrawingToolbar!=null&&this.store.set(F(this.prefix),e.showDrawingToolbar),this.settings.updateValue("layout",e?.layout),this.settings.updateValue("chartType",e?.chartType),this.settings.enableMultiCharts||this.settings.updateValue("layout","1A"),this.settings.enableHideDrawingToolsByDefault&&this.store.set(F(this.prefix),false),this.updateChartContents();let t=this.activeArea?.resolution;t&&await this.setResolution(t);let a=this.activeArea?.chartStyle;if(a!=null&&this.setChartStyle(a),this.settings.tickerSymbol&&this.activeArea)try{await this.activeArea.setSymbol(this.settings.tickerSymbol);}catch(i){console.warn("ChartManager init failed to set symbol",i);}this.initialized=true;let o=lodashEs.debounce(()=>{let i=this.store.get(Q(this.prefix));this.settings.saveLoadAdapter.saveSettings(i).catch(console.error);},1e3);this.unsubAutoSave=this.store.sub(Q(this.prefix),o);}destroy(){this.unsubAutoSave?.(),this._areaManagers.forEach(e=>e.destroy()),this._areaManagers=[];}setLoading(e){this.store.set(W(this.prefix),e);}setLocale(e){this.settings.updateValue("locale",e);}setTimezone(e){this.settings.updateValue("timezone",e);}setFocused(e){this.focused=e;}setShowDrawingToolbar(e){this.store.set(F(this.prefix),e);}setInternalWidget(e){this.internalWidget=e,this.store.set(E(this.prefix),false);}onInternalWidgetReady(){this.store.set(E(this.prefix),true),this.areas.forEach((e,t)=>{t<this.chartCount&&e.widgetReady();});}setChartType(e){this.settings.updateValue("chartType",e);}setTheme(e){this.settings.theme!==e&&(this.settings.updateValue("theme",e),this.internalWidget?.onThemeChange?.(e,this.settings.reverseColor));}setColorPalette(e){this.settings.updateValue("backgroundColor",e.backgroundColor),this.settings.updateValue("increaseColor",e.increaseColor),this.settings.updateValue("decreaseColor",e.decreaseColor),this.internalWidget?.bridge.applyColorPaletteOverrides();}setReverseColor(e){this.settings.reverseColor!==e&&(this.settings.updateValue("reverseColor",e),this.internalWidget?.onThemeChange?.(this.settings.theme,e));}setLayout(e){let t=this.settings.enableMultiCharts?e:"1A";if(this.settings.layout!==t){let a=this.chartCount,o=this.activeArea?.resolution,i=this.activeArea?.chartStyle;this.settings.updateValue("layout",t),this.updateChartContents(),o&&this.setResolution(o),i!=null&&this.setChartStyle(i),this.internalWidget?.onLayoutChange?.(t),setTimeout(()=>{if(this.store.get(E(this.prefix)))for(let s=a;s<this.chartCount;s++)this.areaByIndex(s)?.widgetReady();});}}reloadChart(){this.reloadId+=1;}async setResolution(e){await Promise.all(this.getAllCharts().map(t=>t.setResolution(e)));}setChartStyle(e){this.getAllCharts().forEach(t=>t.setChartStyle(e));}updateChartContents(){if(this.chartCount>this._areaManagers.length)for(let e=this._areaManagers.length;e<this.chartCount;e++){let t=this._areaManagers[this.selectedIndex],a=t?.toJSON(),o=new U(this.settings,this,e,this.store,this.prefix,a);this._areaManagers[e]=o,this.selectedIndex!==e&&!t&&o.setSymbol(this.settings.tickerSymbol).catch(()=>{});}this.selectedIndex>=this.chartCount&&(this.selectedIndex=this.chartCount-1);}get settingsData(){return this.store.get(Q(this.prefix))}getAllCharts(){return this.updateChartContents(),this._areaManagers.slice(0,this.chartCount)}};var Y=class{storageId;constructor(e){this.storageId=e;}get settingsKey(){return `${this.storageId}.TvChart.Settings`}get shapesKey(){return `${this.storageId}.TvChart.Shapes`}getSettings(){let e=this.getLocalSettingsData(),t=this.getChartStoreData();return {layout:t?.layout,selectedIndex:t?.currentAreaIndex,chartType:t?.chartType,pinnedResolutions:t?.pinnedResolutions,areaContents:t?.areas?.map(o=>({resolution:o.resolution||o.period||"1m",chartStyle:o.chartStyle,symbol:o.symbol,tickerSymbol:o.tickerSymbol,rightOffset:o.rightOffset,barSpacing:o.barSpacing})),showDrawingToolbar:t?.drawing?.toolbarSwitch,drawing:e?.drawing?{...e.drawing,defaultStates:lodashEs.omit(e,["drawing","DrawingToolGroupLastUsedTool","riskRewardAvailableChanged","riskRewardRiskSizeChanged","drawingShapeTemplate"]),lastUsedTools:e.DrawingToolGroupLastUsedTool,riskRewardAvailableChanged:e.riskRewardAvailableChanged,riskRewardRiskSizeChanged:e.riskRewardRiskSizeChanged,drawingShapeTemplate:e.drawingShapeTemplate}:void 0}}getChartStoreData(){return this.getLocalData(this.storageId)}setChartStoreData(e){this.setLocalData(this.storageId,e);}async saveSettings(e){let t=this.getChartStoreData(),a={...t,layout:e.layout,currentAreaIndex:e.selectedIndex,chartType:e.chartType,pinnedResolutions:e.pinnedResolutions,areas:e.areaContents?.map((o,i)=>({...t?.areas?.[i],...o})),drawing:{...t?.drawing,toolbarSwitch:e.showDrawingToolbar}};this.setChartStoreData(a);}async getShapes(e){let t=this.getLocalShapesData();return !t||!t[e]?[]:Object.values(t[e])}async saveShapes(e,t){let a=this.getLocalShapesData()||{};a[e]={...a[e],...t},Object.keys(a[e]).forEach(o=>{a[e][o]||delete a[e][o];}),this.setLocalShapesData(a);}getLocalData(e){try{let t=localStorage.getItem(e);return t?JSON.parse(t):null}catch{return null}}setLocalData(e,t){localStorage.setItem(e,JSON.stringify(t));}getLocalSettingsData(){return this.getLocalData(this.settingsKey)}getLocalShapesData(){return this.getLocalData(this.shapesKey)}setLocalShapesData(e){this.setLocalData(this.shapesKey,e);}};function x(r){let[e,t,a,o]=r.split("/");return {address:t,chain:e,quote:a,priceType:o}}function j(r){return !r.quote||!r.priceType?`${r.chain}/${r.address}`:`${r.chain}/${r.address}/${r.quote}/${r.priceType}`}function ve(r){return `${r.chain}/${r.address}`}var ar={dark:"Dark",light:"Light"};function z(r){return ar[r.toLowerCase()]??"Dark"}var pt={"1s":"1S","5s":"5S","15s":"15S","30s":"30S","1m":"1","5m":"5","15m":"15","30m":"30","1h":"60","4h":"240","12h":"720","1d":"1D"};function R(r="1m"){return pt[r]??pt["1m"]}var or={"1S":"1s","5S":"5s","15S":"15s","30S":"30s",1:"1m",5:"5m",15:"15m",30:"30m",60:"1h",240:"4h",720:"12h","1D":"1d"};function X(r){return or[r]??"1s"}var ir={en:"en","zh-CN":"zh","zh-TW":"zh"};function sr(r){return ir[r]??r}var yt={"1A":"s","2A":"2h","2B":"2v","3A":"3s","3B":"3h","3C":"3v","3D":"2-1","3E":"1-2","3F":"3r","4A":"4","4B":"4h","4C":"4v","4D":"4s","4E":"1-3","4F":"2-2","5A":"1-4","5B":"5s","5C":"2-3","5D":"5h","6A":"6","6B":"6c","6C":"6h","7A":"7h","8A":"8","8B":"8c","8C":"8h"};function ee(r){return yt[r]??"s"}var nr=Object.fromEntries(Object.entries(yt).map(([r,e])=>[e,r]));function De(r){return nr[r]??"1A"}var lr={"1s":1e3,"5s":5e3,"15s":15e3,"30s":3e4,"1m":6e4,"5m":3e5,"15m":9e5,"30m":18e5,"1h":36e5,"4h":144e5,"12h":432e5,"1d":864e5};function Se(r){let e=lr[r];if(!e)throw new Error(`Invalid interval: ${r}`);return e}function Be(r,e){let t=r.toString().length>10?r:1e3*r;return Math.floor(t/e)*e}var te=class{prefix;store;supportedResolutions=A.map(R);supportedLayouts=ke;supportedChartTypes=["TradingView"];chartNames={};priceFormatterFactory=null;saveLoadAdapter;constructor(e,t){this.prefix=e,this.store=t,this.saveLoadAdapter=new Y(e),this.store.set(Z(e),e);}get layout(){return this.store.get(I(this.prefix))}get chartType(){return this.store.get(N(this.prefix))}get theme(){return this.store.get(J(this.prefix))}get reverseColor(){return this.store.get(fe(this.prefix))}get locale(){return this.store.get(pe(this.prefix))}get timezone(){return this.store.get(ye(this.prefix))}get tickerSymbol(){return this.store.get(Ce(this.prefix))}get storageId(){return this.store.get(Z(this.prefix))}get backgroundColor(){return this.store.get(be(this.prefix))}get increaseColor(){return this.store.get(Fe(this.prefix))}get decreaseColor(){return this.store.get(Ee(this.prefix))}get enabledFeatures(){return this.store.get(O(this.prefix))}get disabledFeatures(){return this.store.get(H(this.prefix))}updateValue(e,t){if(t==null)return;let o={layout:()=>this.store.set(I(this.prefix),t),chartType:()=>this.store.set(N(this.prefix),t),theme:()=>this.store.set(J(this.prefix),t),reverseColor:()=>this.store.set(fe(this.prefix),t),locale:()=>this.store.set(pe(this.prefix),t),timezone:()=>this.store.set(ye(this.prefix),t),tickerSymbol:()=>this.store.set(Ce(this.prefix),t),storageId:()=>this.store.set(Z(this.prefix),t),backgroundColor:()=>this.store.set(be(this.prefix),t),increaseColor:()=>this.store.set(Fe(this.prefix),t),decreaseColor:()=>this.store.set(Ee(this.prefix),t),enabledFeatures:()=>this.store.set(O(this.prefix),t),disabledFeatures:()=>this.store.set(H(this.prefix),t)}[e];o&&o();}isFeatureEnabled(e){return !this.disabledFeatures.includes(e)&&this.enabledFeatures.includes(e)||Ae.includes(e)}setFeature(e,t){this.resetFeature(e),t?this.store.set(O(this.prefix),[...this.enabledFeatures,e]):this.store.set(H(this.prefix),[...this.disabledFeatures,e]);}resetFeature(e){this.store.set(O(this.prefix),this.enabledFeatures.filter(t=>t!==e)),this.store.set(H(this.prefix),this.disabledFeatures.filter(t=>t!==e));}get enableMultiCharts(){return this.isFeatureEnabled("multi_charts")}get enableCreateVolumeIndicatorByDefault(){return this.isFeatureEnabled("create_volume_indicator_by_default")}get enableHideDrawingToolsByDefault(){return this.isFeatureEnabled("hide_drawing_tools_by_default")}get enableLegendSeriesTitle(){return this.isFeatureEnabled("legend_series_title")}get enableLegendVolume(){return this.isFeatureEnabled("legend_volume")}get enableTimeframesToolbar(){return this.isFeatureEnabled("timeframes_toolbar")}get enableVolumeForceOverlay(){return this.isFeatureEnabled("volume_force_overlay")}sub(e,t){let o={layout:I(this.prefix),chartType:N(this.prefix),theme:J(this.prefix)}[e];return o?this.store.sub(o,t):()=>{}}};var re=class{datafeed;cache=new Map;pendingRequests=new Map;constructor(e){this.datafeed=e;}async resolveSymbolInfo(e){let t=this.cache.get(e);if(t)return t;let a=this.pendingRequests.get(e);if(a)return a;let o=this.datafeed.resolveSymbol(e).then(i=>(i&&this.cache.set(e,i),i)).finally(()=>this.pendingRequests.delete(e));return this.pendingRequests.set(e,o),o}async resolveSymbolInfos(e){return (await Promise.all(e.map(a=>this.resolveSymbolInfo(a)))).filter(a=>a!==null)}getSymbolInfo(e){return this.resolveSymbolInfo(e).catch(t=>{console.error("ChartSymbolResolver.getSymbolInfo",t);}),this.cache.get(e)??null}};var Ne=({initConfig:r,children:e})=>{let{chartManager:t,chartSettings:a}=c(),[o,i]=react.useState(false);return react.useEffect(()=>{t.initialized||(a.updateValue("tickerSymbol",r.tickerSymbol),a.updateValue("theme",r.theme),a.updateValue("reverseColor",r.reverseColor),a.updateValue("layout",r.layout),a.updateValue("chartType",r.chartType),a.updateValue("timezone",r.timezone),a.updateValue("locale",r.locale),a.updateValue("backgroundColor",r.backgroundColor),a.updateValue("increaseColor",r.increaseColor),a.updateValue("decreaseColor",r.decreaseColor),a.updateValue("storageId",r.storageId),a.updateValue("enabledFeatures",r.enabledFeatures),a.updateValue("disabledFeatures",r.disabledFeatures),r.chartNames&&(a.chartNames=r.chartNames),r.priceFormatterFactory&&(a.priceFormatterFactory=r.priceFormatterFactory),r.supportedResolutions&&(a.supportedResolutions=r.supportedResolutions),r.supportedLayouts&&(a.supportedLayouts=r.supportedLayouts),r.supportedChartTypes&&(a.supportedChartTypes=r.supportedChartTypes),t.datafeed=r.datafeed,t.symbolResolver=new re(r.datafeed));},[t,a,r]),react.useEffect(()=>{o&&(t.setTheme(r.theme),t.setColorPalette({backgroundColor:r.backgroundColor,increaseColor:r.increaseColor,decreaseColor:r.decreaseColor}));},[t,o,r.backgroundColor,r.decreaseColor,r.increaseColor,r.theme]),react.useEffect(()=>(t.init().then(()=>i(true)).catch(s=>{console.error("TradingViewConfig chartManager init error",s);}),()=>{t.destroy();}),[t]),o&&t.initialized?jsxRuntime.jsx(jsxRuntime.Fragment,{children:e}):null};var ft=react.createContext(null);function c(){let r=react.useContext(ft);if(!r)throw new Error("useTvChartContext must be used within TradingViewProvider");return r}function Cr(){return c().chartManager}function fr(){return c().prefix}var we=class{setting;chartManager;constructor(e,t){this.setting=e,this.chartManager=t;}get internalWidget(){return this.chartManager.internalWidget}chartCount(){return this.chartManager.chartCount}setActiveChart(e){e<this.chartCount()&&(this.chartManager.selectedIndex=e);}layout(){return this.setting.layout}setLayout(e){this.chartManager.setLayout(e);}theme(){return this.setting.theme}setTheme(e){this.chartManager.setTheme(e);}setChartType(e){this.chartManager.setChartType(e);}getSetting(){return this.setting}getChartManager(){return this.chartManager}},Oe=react.forwardRef(({children:r,initConfig:e,widgetConstructor:t,libraryPath:a,customCssUrl:o},i)=>{let s=jotai.useStore(),l=e.storageId,n=react.useMemo(()=>new te(l,s),[l,s]),h=react.useMemo(()=>new K(l,s,n),[l,s,n]),d=react.useMemo(()=>new we(n,h),[n,h]);react.useImperativeHandle(i,()=>d,[d]);let u=react.useMemo(()=>({prefix:l,chartSettings:n,chartManager:h,widgetConstructor:t,libraryPath:a,customCssUrl:o}),[l,n,h,t,a,o]);return jsxRuntime.jsx(ft.Provider,{value:u,children:jsxRuntime.jsx(Ne,{initConfig:e,children:r})})});function bt(r){return jsxRuntime.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 20 20",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor","aria-hidden":"true",...r,children:[jsxRuntime.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M6.86509 3.91271C7.23373 3.34358 7.86564 3 8.54372 3H11.4563C12.1344 3 12.7663 3.34358 13.1349 3.91271L13.7312 4.83333H16C17.1046 4.83333 18 5.72876 18 6.83333V14C18 15.1046 17.1046 16 16 16H4C2.89543 16 2 15.1046 2 14V6.83333C2 5.72877 2.89543 4.83333 4 4.83333L6.26878 4.83333L6.86509 3.91271ZM7.70441 4.45635C7.88873 4.17179 8.20468 4 8.54372 4H11.4563C11.7953 4 12.1113 4.17179 12.2956 4.45635L12.8919 5.37698C13.0762 5.66154 13.3922 5.83333 13.7312 5.83333H16C16.5523 5.83333 17 6.28105 17 6.83333V14C17 14.5523 16.5523 15 16 15H4C3.44772 15 3 14.5523 3 14V6.83333C3 6.28105 3.44772 5.83333 4 5.83333H6.26878C6.60782 5.83333 6.92377 5.66154 7.10809 5.37698L7.70441 4.45635Z"}),jsxRuntime.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M13 10C13 11.6569 11.6569 13 10 13C8.34315 13 7 11.6569 7 10C7 8.34315 8.34315 7 10 7C11.6569 7 13 8.34315 13 10ZM10 12C11.1046 12 12 11.1046 12 10C12 8.89543 11.1046 8 10 8C8.89543 8 8 8.89543 8 10C8 11.1046 8.89543 12 10 12Z"})]})}function vt(r){return jsxRuntime.jsx("svg",{"data-icon":"fullscreen",width:"20",height:"20",viewBox:"0 0 20 20",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor","aria-hidden":"true",...r,children:jsxRuntime.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M16.5 4C16.5 3.72386 16.2761 3.5 16 3.5H10.6154C10.3392 3.5 10.1154 3.72386 10.1154 4 10.1154 4.27614 10.3392 4.5 10.6154 4.5H14.7929L10.6464 8.64645C10.4512 8.84171 10.4512 9.15829 10.6464 9.35355 10.8417 9.54882 11.1583 9.54882 11.3536 9.35355L15.5 5.20711V9.38462C15.5 9.66076 15.7239 9.88462 16 9.88462 16.2761 9.88462 16.5 9.66076 16.5 9.38462V4ZM3.5 16C3.5 16.2761 3.72386 16.5 4 16.5H9.38462C9.66076 16.5 9.88462 16.2761 9.88462 16 9.88462 15.7239 9.66076 15.5 9.38462 15.5H5.20711L9.35355 11.3536C9.54882 11.1583 9.54882 10.8417 9.35355 10.6464 9.15829 10.4512 8.84171 10.4512 8.64645 10.6464L4.5 14.7929V10.6154C4.5 10.3392 4.27614 10.1154 4 10.1154 3.72386 10.1154 3.5 10.3392 3.5 10.6154V16Z"})})}function St(r){return jsxRuntime.jsx("svg",{"data-icon":"restore-screen",width:"20",height:"20",viewBox:"0 0 20 20",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor","aria-hidden":"true",...r,children:jsxRuntime.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M10.1154 9.38461C10.1154 9.66076 10.3392 9.88461 10.6154 9.88461L16 9.88461C16.2761 9.88461 16.5 9.66076 16.5 9.38461 16.5 9.10847 16.2761 8.88461 16 8.88461L11.8225 8.88461 15.9689 4.73817C16.1642 4.54291 16.1642 4.22632 15.9689 4.03106 15.7737 3.8358 15.4571 3.8358 15.2618 4.03106L11.1154 8.17751 11.1154 4C11.1154 3.72385 10.8915 3.5 10.6154 3.5 10.3392 3.5 10.1154 3.72385 10.1154 4L10.1154 9.38461ZM9.88464 10.6154C9.88464 10.3392 9.66079 10.1154 9.38464 10.1154L4.00003 10.1154C3.72389 10.1154 3.50003 10.3392 3.50003 10.6154 3.50003 10.8915 3.72388 11.1154 4.00003 11.1154L8.17754 11.1154 4.03109 15.2618C3.83583 15.4571 3.83583 15.7737 4.03109 15.9689 4.22635 16.1642 4.54293 16.1642 4.7382 15.9689L8.88464 11.8225 8.88464 16C8.88464 16.2761 9.1085 16.5 9.38464 16.5 9.66079 16.5 9.88464 16.2761 9.88464 16L9.88464 10.6154Z"})})}function Tt(r){return jsxRuntime.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 20 20",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor","aria-hidden":"true",...r,children:[jsxRuntime.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M11 2.42264L16.0622 5.34529C16.681 5.70256 17.0622 6.36281 17.0622 7.07734V12.9226C17.0622 13.6372 16.681 14.2974 16.0622 14.6547L11 17.5773C10.3812 17.9346 9.6188 17.9346 9 17.5773L3.93782 14.6547C3.31902 14.2974 2.93782 13.6372 2.93782 12.9226V7.07734C2.93782 6.36281 3.31902 5.70256 3.93782 5.34529L9 2.42264C9.6188 2.06538 10.3812 2.06538 11 2.42264ZM10.5 3.28867C10.1906 3.11004 9.8094 3.11004 9.5 3.28867L4.43782 6.21132C4.12842 6.38995 3.93782 6.72008 3.93782 7.07734V12.9226C3.93782 13.2799 4.12842 13.61 4.43782 13.7887L9.5 16.7113C9.8094 16.89 10.1906 16.89 10.5 16.7113L15.5622 13.7887C15.8716 13.61 16.0622 13.2799 16.0622 12.9226V7.07734C16.0622 6.72008 15.8716 6.38995 15.5622 6.21132L10.5 3.28867Z"}),jsxRuntime.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M13 10C13 11.6569 11.6569 13 10 13C8.34315 13 7 11.6569 7 10C7 8.34315 8.34315 7 10 7C11.6569 7 13 8.34315 13 10ZM10 12C11.1046 12 12 11.1046 12 10C12 8.89543 11.1046 8 10 8C8.89543 8 8 8.89543 8 10C8 11.1046 8.89543 12 10 12Z"})]})}function wt(r){return jsxRuntime.jsx("svg",{width:"18",height:"18",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",...r,children:jsxRuntime.jsx("path",{d:"M10 2.5v10m0 0 3.5-3.5M10 12.5 6.5 9M3 13.5v2A1.5 1.5 0 0 0 4.5 17h11a1.5 1.5 0 0 0 1.5-1.5v-2",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"})})}function xt(r){return jsxRuntime.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",...r,children:[jsxRuntime.jsx("rect",{x:"6.5",y:"6.5",width:"10",height:"10",rx:"1.5",stroke:"currentColor",strokeWidth:"1.4"}),jsxRuntime.jsx("path",{d:"M13.5 6.5v-2A1.5 1.5 0 0 0 12 3H4.5A1.5 1.5 0 0 0 3 4.5V12A1.5 1.5 0 0 0 4.5 13.5h2",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"})]})}var ze=react.memo(()=>{let{t:r}=i18n.useTranslation(),{prefix:e,chartManager:t}=c(),a=jotai.useAtomValue(P(e)),o=react.useCallback(()=>{t.fullscreen=!t.fullscreen;},[t]);return jsxRuntime.jsx("button",{type:"button",onClick:o,"aria-label":r(a?"tradingView.exitFullscreen":"tradingView.fullscreen"),className:"inline-flex h-6 w-6 cursor-pointer items-center justify-center bg-transparent p-0 text-text-muted transition-colors hover:text-text-primary",title:r(a?"tradingView.exitFullscreen":"tradingView.fullscreen"),children:a?jsxRuntime.jsx(St,{}):jsxRuntime.jsx(vt,{})})});var Pr=[[0,"tradingView.style.bars"],[1,"tradingView.style.candles"],[2,"tradingView.style.line"],[3,"tradingView.style.area"],[8,"tradingView.style.heikenAshi"],[9,"tradingView.style.hollowCandles"],[10,"tradingView.style.baseline"],[12,"tradingView.style.highLow"],[13,"tradingView.style.columns"]],Ge={width:256,borderRadius:14,border:"1px solid var(--color-border-control)",background:"var(--color-surface-interactive)",boxShadow:"0 25px 50px -12px rgba(0,0,0,0.5)"},xe="flex w-full cursor-pointer items-center gap-2.5 rounded-[10px] px-3 py-2 text-sm transition-all";function Rt({chartStyle:r,...e}){if(r===2||r===3||r===10)return jsxRuntime.jsxs("svg",{viewBox:"0 0 20 20",fill:"none",...e,children:[jsxRuntime.jsx("path",{d:"M2.5 14.5 7 9.5l3.5 2.5L15 5.5h2.5",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"}),r!==2&&jsxRuntime.jsx("path",{d:"M2.5 14.5 7 9.5l3.5 2.5L15 5.5h2.5V17h-15Z",fill:"currentColor",opacity:r===3?.25:.12}),r===10&&jsxRuntime.jsx("path",{d:"M2 12h16",stroke:"currentColor",strokeDasharray:"2 2"})]});if(r===13)return jsxRuntime.jsxs("svg",{viewBox:"0 0 20 20",fill:"none",...e,children:[jsxRuntime.jsx("rect",{x:"2.5",y:"8",width:"4",height:"9",rx:".5",stroke:"currentColor"}),jsxRuntime.jsx("rect",{x:"8",y:"3",width:"4",height:"14",rx:".5",stroke:"currentColor"}),jsxRuntime.jsx("rect",{x:"13.5",y:"11",width:"4",height:"6",rx:".5",stroke:"currentColor"})]});let t=r===9||r===12,a=r===0;return jsxRuntime.jsxs("svg",{viewBox:"0 0 20 20",fill:"none",...e,children:[jsxRuntime.jsx("path",{d:"M6 2.5v15M14 4v12",stroke:"currentColor"}),a?jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx("path",{d:"M3 7h3M6 13h3M11 8h3M14 12h3",stroke:"currentColor"})}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("rect",{x:"3.5",y:r===8?"6.5":"5",width:"5",height:r===8?"8":"10",rx:".5",fill:t?"none":"currentColor",stroke:"currentColor"}),jsxRuntime.jsx("rect",{x:"11.5",y:r===8?"5":"7",width:"5",height:r===8?"7":"6",rx:".5",fill:"none",stroke:"currentColor"})]})]})}var Le=react.memo(()=>{let{t:r}=i18n.useTranslation(),{prefix:e,chartManager:t}=c(),a=jotai.useAtomValue(f(e)),o=jotai.useAtomValue(T(e)),[i,s]=react.useState(false),l=react.useRef(null),n=a[o]?.chartStyle??1,h=react.useCallback(d=>{s(false),t.setChartStyle(d);},[t]);return react.useEffect(()=>{if(!i)return;let d=C=>{l.current?.contains(C.target)||s(false);},u=C=>{C.key==="Escape"&&s(false);};return document.addEventListener("mousedown",d),document.addEventListener("keydown",u),()=>{document.removeEventListener("mousedown",d),document.removeEventListener("keydown",u);}},[i]),jsxRuntime.jsxs("div",{ref:l,className:"relative inline-flex",children:[jsxRuntime.jsx("button",{type:"button","aria-label":r("tradingView.klineStyle"),"aria-haspopup":"menu","aria-expanded":i,onClick:()=>s(d=>!d),className:"inline-flex h-6 min-h-0 min-w-0 cursor-pointer items-center bg-transparent p-0 text-foreground transition-opacity hover:opacity-80",title:r("tradingView.klineStyle"),children:jsxRuntime.jsx(Rt,{chartStyle:n,width:20,height:20})}),i&&jsxRuntime.jsx("div",{role:"menu","aria-label":r("tradingView.klineStyle"),className:"absolute left-0 top-full z-50 mt-2 w-64 overflow-hidden",style:Ge,children:jsxRuntime.jsx("div",{className:"p-1",children:Pr.map(([d,u])=>{let C=n===d;return jsxRuntime.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":C,"data-active":C,"data-style":d,onMouseDown:m=>m.stopPropagation(),onClick:m=>{m.preventDefault(),m.stopPropagation(),h(d);},className:[xe,C?"bg-action-primary/[0.08] text-brand-primary":"text-text-secondary hover:bg-surface-strong/50 hover:text-text-primary"].join(" "),children:[jsxRuntime.jsx(Rt,{chartStyle:d,width:20,height:20}),jsxRuntime.jsx("span",{className:"flex-1 text-left",children:r(u)}),C&&jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",width:16,height:16,fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",className:"flex-shrink-0","aria-hidden":"true",children:jsxRuntime.jsx("path",{d:"M20 6 9 17l-5-5"})})]},d)})})})]})});var Pt=react.createContext(null);function D(){let r=react.useContext(Pt);if(!r)throw new Error("useTvChartToolbarContext must be used within TradingViewToolbarProvider");return r}var qe=({children:r})=>{let{prefix:e,chartManager:t}=c(),a=jotai.useAtomValue(T(e)),o=jotai.useAtomValue(f(e)),i=react.useMemo(()=>o.length?t.areaByIndex(a):null,[t,a,o]),s=react.useMemo(()=>i?.symbolInfo??null,[i]),l=o[a]?.tickerSymbol??"",n=react.useMemo(()=>({activeAreaManager:i,activeTickerSymbol:l,symbolInfo:s}),[i,l,s]);return jsxRuntime.jsx(Pt.Provider,{value:n,children:r})};var It={1:"2A",2:"3E",3:"4A",4:"5C",5:"6A",6:"7A",7:"8A"},Ze=react.memo(({onSelectSymbol:r})=>{let{t:e}=i18n.useTranslation(),{chartManager:t}=c(),{activeTickerSymbol:a}=D(),[o,i]=react.useState(false),s=react.useCallback(async()=>{let n=t.chartCount,h=It[n];if(!(!r||!h||o)){i(true);try{let d=await r(a);if(!d)return;let u=t.chartCount,C=It[u];if(!C)return;t.setLayout(C),await t.areaByIndex(u)?.setSymbol(d);}finally{i(false);}}},[a,t,r,o]),l=!r||o||t.chartCount===0||t.chartCount>=8;return jsxRuntime.jsxs("button",{type:"button","data-testid":"multi-chart",disabled:l,onClick:()=>{s();},className:"inline-flex h-6 min-h-0 min-w-0 cursor-pointer items-center gap-1 bg-transparent p-0 text-xs text-foreground transition-opacity hover:opacity-80 disabled:cursor-not-allowed disabled:opacity-40",title:e("tradingView.multiCharts"),children:[jsxRuntime.jsx("svg",{"aria-hidden":"true",width:"16",height:"16",viewBox:"0 0 20 20",fill:"none",children:jsxRuntime.jsx("path",{d:"M17.3846 2C17.5478 2 17.7044 2.06483 17.8198 2.18024C17.9352 2.29565 18 2.45217 18 2.61538V17.3846C18 17.5478 17.9352 17.7044 17.8198 17.8198C17.7044 17.9352 17.5478 18 17.3846 18H2.61538C2.45217 18 2.29565 17.9352 2.18024 17.8198C2.06483 17.7044 2 17.5478 2 17.3846V2.61538C2 2.45217 2.06483 2.29565 2.18024 2.18024C2.29565 2.06483 2.45217 2 2.61538 2H17.3846ZM9.58954 3.23077H3.23077V16.7692H9.58974L9.58954 3.23077ZM16.7692 3.23077H10.4101L10.4103 16.7692H16.7692V10.4103H10.4103V9.58974H16.7692V3.23077Z",fill:"currentColor"})}),jsxRuntime.jsx("span",{children:e("tradingView.multiCharts")})]})});var Re=react.memo(()=>{let{t:r}=i18n.useTranslation(),{chartManager:e}=c(),t=react.useCallback(()=>{e.internalWidget?.openIndicatorSettingsDialog();},[e]);return jsxRuntime.jsx("button",{type:"button",onClick:t,"aria-label":r("tradingView.indicators"),className:"inline-flex h-6 min-h-0 min-w-0 cursor-pointer items-center bg-transparent p-0 text-foreground transition-opacity hover:opacity-80",title:r("tradingView.indicators"),children:jsxRuntime.jsx("svg",{"aria-hidden":"true",width:"20",height:"20",viewBox:"0 0 20 20",fill:"currentColor",children:jsxRuntime.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7.5 5.5C7.5 4.11929 8.61929 3 10 3C11.3807 3 12.5 4.11929 12.5 5.5V5.82143C12.5 6.09757 12.2761 6.32143 12 6.32143C11.7239 6.32143 11.5 6.09757 11.5 5.82143V5.5C11.5 4.67157 10.8284 4 10 4C9.17157 4 8.5 4.67157 8.5 5.5V8H11C11.2761 8 11.5 8.22386 11.5 8.5C11.5 8.77614 11.2761 9 11 9H8.5V14.4999C8.5 15.8806 7.38071 16.9999 6 16.9999C4.61929 16.9999 3.5 15.8806 3.5 14.4999C3.5 14.2237 3.72386 13.9999 4 13.9999C4.27614 13.9999 4.5 14.2237 4.5 14.4999C4.5 15.3283 5.17157 15.9999 6 15.9999C6.82843 15.9999 7.5 15.3283 7.5 14.4999V9H5C4.72386 9 4.5 8.77614 4.5 8.5C4.5 8.22386 4.72386 8 5 8H7.5V5.5ZM14.2071 14.5001L15.8536 16.1465C16.0488 16.3418 16.0488 16.6584 15.8536 16.8536C15.6583 17.0489 15.3417 17.0489 15.1464 16.8536L13.5 15.2072L11.8536 16.8536C11.6583 17.0489 11.3417 17.0489 11.1464 16.8536C10.9512 16.6584 10.9512 16.3418 11.1464 16.1465L12.7929 14.5001L11.1464 12.8536C10.9512 12.6584 10.9512 12.3418 11.1464 12.1465C11.3417 11.9513 11.6583 11.9513 11.8536 12.1465L13.5 13.793L15.1464 12.1465C15.3417 11.9513 15.6583 11.9513 15.8536 12.1465C16.0488 12.3418 16.0488 12.6584 15.8536 12.8536L14.2071 14.5001Z"})})})});var Ke=react.memo(()=>{let{t:r}=i18n.useTranslation(),{chartManager:e}=c(),t=react.useCallback(()=>{e.internalWidget?.openSettingsDialog();},[e]);return jsxRuntime.jsx("button",{type:"button",onClick:t,"aria-label":r("tradingView.chartSettings"),className:"inline-flex h-6 w-6 cursor-pointer items-center justify-center bg-transparent p-0 text-text-muted transition-colors hover:text-text-primary",title:r("tradingView.chartSettings"),children:jsxRuntime.jsx(Tt,{})})});var Me=react.memo(({className:r})=>{let{t:e}=i18n.useTranslation(),{chartManager:t}=c(),{activeTickerSymbol:a}=D(),o=x(a),i=o.priceType??"price",s=react.useCallback(()=>{if(!o.chain||!o.address)return;let l=i==="price"?"market_cap":"price";Promise.all(t.getAllCharts().map(n=>{let h=x(n.tickerSymbol);return !h.chain||!h.address?Promise.resolve():n.setSymbol(j({...h,quote:h.quote??"USD",priceType:l}))}));},[i,t,o]);return a?jsxRuntime.jsxs("div",{role:"button",tabIndex:0,"data-testid":"price-type",onClick:s,onKeyDown:l=>{(l.key==="Enter"||l.key===" ")&&(l.preventDefault(),s());},className:`cursor-pointer items-center gap-0.5 text-xs ${r??"flex"}`,"aria-label":e("tradingView.priceType"),children:[jsxRuntime.jsx("span",{className:i==="price"?"text-text-primary":"text-text-muted",children:e("tradingView.price")}),jsxRuntime.jsx("span",{className:"text-text-disabled","aria-hidden":"true",children:"/"}),jsxRuntime.jsx("span",{className:i==="market_cap"?"text-text-primary":"text-text-muted",children:e("tradingView.marketCap")})]}):null});var Xe=react.memo(({nativeQuote:r,className:e})=>{let{t}=i18n.useTranslation(),{chartManager:a}=c(),{activeTickerSymbol:o}=D(),i=x(o),s=i.quote??"USD",l=react.useCallback(()=>{if(!i.chain||!i.address)return;let n=s==="USD"?r:"USD";Promise.all(a.getAllCharts().map(h=>{let d=x(h.tickerSymbol);return !d.chain||!d.address?Promise.resolve():h.setSymbol(j({...d,quote:n,priceType:d.priceType??"price"}))}));},[s,a,r,i]);return o?jsxRuntime.jsxs("div",{role:"button",tabIndex:0,"data-testid":"quote-type",onClick:l,onKeyDown:n=>{(n.key==="Enter"||n.key===" ")&&(n.preventDefault(),l());},className:`cursor-pointer items-center gap-0.5 text-xs ${e??"flex"}`,"aria-label":t("tradingView.quoteType"),children:[jsxRuntime.jsx("span",{className:s==="USD"?"text-text-primary":"text-text-muted",children:"USD"}),jsxRuntime.jsx("span",{className:"text-text-disabled","aria-hidden":"true",children:"/"}),jsxRuntime.jsx("span",{className:s!=="USD"?"text-text-primary":"text-text-muted",children:r})]}):null});var tt=react.memo(()=>{let{t:r}=i18n.useTranslation(),{prefix:e,chartManager:t}=c(),a=jotai.useAtomValue(k(e)),o=jotai.useAtomValue(f(e)),i=jotai.useAtomValue(T(e)),s=o[i]?.resolution,l=react.useCallback(n=>{t.setResolution(n);},[t]);return jsxRuntime.jsx("div",{className:"flex items-center gap-0.5",children:a.map(n=>jsxRuntime.jsx("button",{type:"button",onClick:()=>l(n),className:`px-2 py-0.5 text-xs rounded cursor-pointer transition-colors ${s===n?"bg-primary text-primary-foreground":"text-muted-foreground hover:text-foreground hover:bg-muted"}`,children:r(`common.resolution.${n}`)},n))})});var rt=react.memo(()=>{let{t:r}=i18n.useTranslation(),{chartManager:e}=c(),[t,a]=react.useState(false),o=react.useRef(null),i=react.useCallback(async()=>{a(false);try{let l=await e.internalWidget?.takeClientScreenshot();if(!l)return;let n=document.createElement("a");n.download=`chart-${Date.now()}.png`,n.href=l.toDataURL("image/png"),document.body.appendChild(n),n.click(),document.body.removeChild(n);}catch(l){console.error("TradingViewSnapshot",l);}},[e]),s=react.useCallback(async()=>{a(false);try{let l=await e.internalWidget?.takeClientScreenshot();if(!l)return;let n=await new Promise(h=>l.toBlob(h,"image/png"));if(!n||!navigator.clipboard?.write||!globalThis.ClipboardItem)throw new Error("Image clipboard API is not available");await navigator.clipboard.write([new ClipboardItem({"image/png":n})]);}catch(l){console.error("TradingViewSnapshot",l);}},[e]);return react.useEffect(()=>{if(!t)return;let l=h=>{o.current?.contains(h.target)||a(false);},n=h=>{h.key==="Escape"&&a(false);};return document.addEventListener("mousedown",l),document.addEventListener("keydown",n),()=>{document.removeEventListener("mousedown",l),document.removeEventListener("keydown",n);}},[t]),jsxRuntime.jsxs("div",{ref:o,className:"relative inline-flex",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>a(l=>!l),"aria-label":r("tradingView.takeSnapshot"),"aria-haspopup":"menu","aria-expanded":t,className:"inline-flex h-6 w-6 cursor-pointer items-center justify-center bg-transparent p-0 text-text-muted transition-colors hover:text-text-primary",title:r("tradingView.takeSnapshot"),children:jsxRuntime.jsx(bt,{})}),t&&jsxRuntime.jsxs("div",{role:"menu","aria-label":r("tradingView.snapshot"),className:"absolute right-0 top-full z-50 mt-2 w-64 overflow-hidden p-1",style:Ge,children:[jsxRuntime.jsxs("button",{type:"button",role:"menuitem",onClick:i,className:`${xe} text-text-secondary hover:bg-surface-strong/50 hover:text-text-primary`,children:[jsxRuntime.jsx(wt,{}),jsxRuntime.jsx("span",{children:r("tradingView.downloadSnapshot")})]}),jsxRuntime.jsxs("button",{type:"button",role:"menuitem",onClick:s,className:`${xe} text-text-secondary hover:bg-surface-strong/50 hover:text-text-primary`,children:[jsxRuntime.jsx(xt,{}),jsxRuntime.jsx("span",{children:r("tradingView.copySnapshot")})]})]})]})});var at=react.memo(({children:r,prefix:e,suffix:t,showResolutions:a=true,showKlineStyleSelect:o=true,showOpenIndicator:i=true,showOpenSettings:s=true,showFullscreen:l=true,showSnapshot:n=true,showMultiChartSelect:h=false,showPriceTypeSwitch:d=false,showQuoteTypeSwitch:u=false,nativeQuote:C,onSelectMultiChartSymbol:m})=>jsxRuntime.jsx(qe,{children:jsxRuntime.jsxs("div",{className:"flex h-9 w-full flex-none items-center border-b border-border px-4",children:[e,r??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex min-w-0 flex-1 items-center justify-start gap-2.5",children:[a&&jsxRuntime.jsx(tt,{}),h&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"hidden h-4 w-px bg-border sm:block"}),jsxRuntime.jsx(Ze,{onSelectSymbol:m})]}),(o||i)&&jsxRuntime.jsx("div",{className:"hidden h-4 w-px bg-border sm:block"}),o&&jsxRuntime.jsx("div",{className:"hidden sm:block",children:jsxRuntime.jsx(Le,{})}),i&&jsxRuntime.jsx("div",{className:"hidden sm:block",children:jsxRuntime.jsx(Re,{})}),d&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"hidden h-4 w-px bg-border sm:block"}),jsxRuntime.jsx(Me,{className:"hidden sm:flex"})]}),u&&C&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"hidden h-4 w-px bg-border sm:block"}),jsxRuntime.jsx(Xe,{nativeQuote:C,className:"hidden sm:flex"})]})]}),jsxRuntime.jsxs("div",{className:"flex flex-none items-center justify-end gap-2.5",children:[d&&jsxRuntime.jsx(Me,{className:"flex sm:hidden"}),o&&jsxRuntime.jsx("div",{className:"sm:hidden",children:jsxRuntime.jsx(Le,{})}),i&&jsxRuntime.jsx("div",{className:"sm:hidden",children:jsxRuntime.jsx(Re,{})}),n&&jsxRuntime.jsx("div",{className:"hidden sm:flex",children:jsxRuntime.jsx(rt,{})}),l&&jsxRuntime.jsx("div",{className:"hidden sm:flex",children:jsxRuntime.jsx(ze,{})}),s&&jsxRuntime.jsx("div",{className:"hidden sm:flex",children:jsxRuntime.jsx(Ke,{})})]})]}),t]})}));var ae=class{settings;chartManager;bridge;chartIndex;constructor(e,t,a,o){this.settings=e,this.chartManager=t,this.bridge=a,this.chartIndex=o;}get chartAreaManager(){return this.chartManager.areaByIndex(this.chartIndex)}get widget(){return this.bridge.getWidget()}get chartWidget(){return this.widget?.chart(this.chartIndex)??null}setChartStyle(e){this.chartWidget?.setChartType(e);}getChartStyle(){return this.chartWidget?.chartType()??1}handleSymbolChange(e,t){return this.bridge.asyncWidgetMethodContext((a,o)=>{a.chart(this.chartIndex).setSymbol(e,{dataReady:()=>o(),doNotActivateChart:false});})}handleResolutionChange(e,t){return this.bridge.asyncWidgetMethodContext((a,o)=>{let i=a.chart(this.chartIndex);i.dataReady(()=>{i.setResolution(R(e),{dataReady:o,doNotActivateChart:true}).catch(()=>{});});})}setPrecision(e){this.widget?.applyOverrides({"mainSeriesProperties.minTick":e===null?"default":`${Math.pow(10,e)},1,false`});}async dataReady(){if(await this.bridge.onReady(),!this.chartWidget)throw Error("ChartWidget: chartWidget is null");return new Promise(e=>{this.chartWidget?.dataReady(()=>setTimeout(e));})}timeScaleWidth(){return this.chartWidget?.getTimeScale()?.width()??NaN}rightOffset(){return this.chartWidget?.getTimeScale()?.rightOffset()??NaN}setRightOffset(e){this.chartWidget?.getTimeScale()?.setRightOffset(e);}barSpacing(){return this.chartWidget?.getTimeScale()?.barSpacing()??NaN}setBarSpacing(e){this.chartWidget?.getTimeScale()?.setBarSpacing(e);}};var oe=class{settings;chartManager;bridge;constructor(e,t,a){this.settings=e,this.chartManager=t,this.bridge=a;}get widget(){return this.bridge.getWidget()}chartByIndex(e){return new ae(this.settings,this.chartManager,this.bridge,e)}activeChart(){let e=this.widget?.activeChartIndex();return e===void 0?void 0:this.chartByIndex(e)}openIndicatorSettingsDialog(){this.widget?.activeChart().executeActionById("insertIndicator");}openSettingsDialog(){this.widget?.activeChart().executeActionById("chartProperties");}takeClientScreenshot(){return this.widget?.takeClientScreenshot()}onLayoutChange(e){this.widget?.setLayout(ee(e));}async onThemeChange(e,t){let a=z(e);await this.widget?.changeTheme(a,{disableUndo:true}),this.bridge.applyColorPaletteOverrides();}};var ie=class{listeners=new Map;on(e,t){return this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(t),()=>{this.listeners.get(e)?.delete(t);}}emit(e,t){this.listeners.get(e)?.forEach(a=>a(t));}off(e,t){this.listeners.get(e)?.delete(t);}clear(){this.listeners.clear();}};var se=class{settings;chartManager;bridge;abortController=new AbortController;constructor(e,t,a){this.settings=e,this.chartManager=t,this.bridge=a;}toJSON(){return null}async onReady(e){setTimeout(()=>{e({supported_resolutions:A.map(R),supports_marks:true,exchanges:[]});}),await this.chartManager.datafeed?.onReady({setting:this.settings,chartManager:this.chartManager,instance:this.bridge});}destroy(){this.abortController.abort();}async resolveSymbol(e,t,a,o){try{let i=await this.chartManager.datafeed?.resolveSymbol(e,o);i&&t(i);}catch(i){console.error("ChartDataFeed.resolveSymbol",i),a(i);}}async getBars(e,t,a,o,i){try{let s=await this.chartManager.datafeed?.getBars(e,t,a);s&&o(s,{noData:s.length===0});}catch(s){console.error("ChartDataFeed.getBars",s),i(s);}}subscribeBars(e,t,a,o,i){this.chartManager.datafeed?.subscribeBars(e,t,a,o,i);}unsubscribeBars(e){this.chartManager.datafeed?.unsubscribeBars(e);}async getMarks(e,t,a,o,i){this.chartManager.datafeed?.getMarks?.(e,t,a,o,i);}getQuotes(e,t,a){t(e.map(o=>({s:"ok",n:o,v:{}})));}subscribeQuotes(e,t,a,o){}unsubscribeQuotes(e){}};var ne=class{settings;chartManager;bridge;data;drawings;constructor(e,t,a){this.settings=e,this.chartManager=t,this.bridge=a,this.data=null,this.drawings=null,this.loadDataFromLocalStorage();}get layoutId(){return this.settings.storageId}get shouldResetColorPalette(){let e=this.data?.theme,t=this.data?.reverseColor;return e!==this.settings.theme||t!==this.settings.reverseColor}toJSON(){return null}getAllCharts(){return new Promise(e=>{let t=[];this.data&&t.push({id:this.data.id,name:this.data.name,symbol:this.data.symbol,resolution:this.data.resolution,timestamp:this.data.timestamp}),e(t);})}removeChart(e){throw Error("Method not implemented.")}async saveChart(e){return this.data={...e,theme:this.settings.theme,reverseColor:this.settings.reverseColor,id:this.layoutId,timestamp:0},this.saveDataToLocalStorage(),this.data.id}getChartContent(e){return new Promise(t=>{let a=JSON.parse(this.data.content),o=JSON.parse(a.charts_symbols),i=JSON.parse(a.content);t(JSON.stringify({...a,chart_symbols:JSON.stringify(o),content:JSON.stringify(i)}));})}async saveLineToolsAndGroups(e,t,a){this.drawings=this.drawings||{data:{},timestamp:0},this.drawings.data=this.drawings.data||{},this.drawings.data[t]=this.drawings.data[t]||{};try{if(!a.sources)return;for(let[o,i]of a.sources)if(!i||!i.symbol||!i.state||Object.keys(i.state).length===0||o.includes("/"))i===null&&delete this.drawings.data[t][o];else {let{address:s,chain:l}=x(i.symbol),n=ve({address:s,chain:l}),h={...i,symbol:n,id:i.id.indexOf("/")>0?i.id.split("/")[0]:i.id};this.drawings.data[t][o]=h;}this.saveDataToLocalStorage();}catch(o){console.error("saveLineToolsAndGroups",o);}}async loadLineToolsAndGroups(e,t,a,o){if(!o?.symbol||!this.drawings?.data?.[t])return null;let i=o.symbol,{address:s,chain:l}=x(i),n=ve({address:s,chain:l}),h=lodashEs.uniqBy(Object.values(lodashEs.cloneDeep(this.drawings.data[t])).filter(d=>d.symbol===n),"id");try{return {sources:new Map(h.map(d=>{let u=lodashEs.cloneDeep({...d,symbol:i});return [u.id,u]}))}}catch(d){return console.error("ChartSaveLoadAdapter.loadLineToolsAndGroups",d),null}}getLayoutKey(e){return `charts.tradingview.data.${e}`}getDrawingKey(e){return `charts.tradingview.drawing.${e}`}loadDataFromLocalStorage(){let e=this.getLayoutKey(this.layoutId),t=this.getDrawingKey(this.layoutId),a=localStorage.getItem(e),o=localStorage.getItem(t);if(a)try{let i=JSON.parse(a),s=JSON.parse(i.content);i.content=JSON.stringify(s),this.data=i;}catch(i){console.error("ChartSaveLoadAdapter loadDataFromLocalStorage parse layout error",i);}if(o)try{this.drawings=JSON.parse(o);}catch(i){console.error("ChartSaveLoadAdapter loadDataFromLocalStorage parse drawing error",i);}}saveDataToLocalStorage(){let e=this.getLayoutKey(this.layoutId),t=this.getDrawingKey(this.layoutId),a=Math.round(Date.now()/1e3);this.data&&(this.data.timestamp=a,localStorage.setItem(e,JSON.stringify(this.data))),this.drawings&&(this.drawings.timestamp=a,localStorage.setItem(t,JSON.stringify(this.drawings)));}};var ot="trading.chart.proterty",le=class{storagePrefix;initialSettings;constructor(e,t,a){this.storagePrefix=`tradingview.${e.storageId}.`,this.initialSettings={};for(let i=0;i<localStorage.length;i++){let s=localStorage.key(i);if(s&&s.startsWith(this.storagePrefix)){let l=s.slice(this.storagePrefix.length);this.initialSettings[l]=localStorage.getItem(s);}}let o={noConfirmEnabled:1};if(this.initialSettings[ot])try{let i=JSON.parse(this.initialSettings[ot]);Object.assign(o,i),Object.assign(o,{noConfirmEnabled:!0});}catch(i){console.error("ChartSettingsAdapter: failed to parse chart settings",i);}this.initialSettings[ot]=JSON.stringify(o);}toJSON(){return null}removeValue(e){delete this.initialSettings[e],localStorage.removeItem(`${this.storagePrefix}${e}`);}setValue(e,t){this.initialSettings[e]=t,localStorage.setItem(`${this.storagePrefix}${e}`,t);}};var de=class{settings;chartManager;WidgetCtor;moduleInstances=new Map;symbolIntervalSubs=new Map;abortController=new AbortController;widgetReadyPromise=null;readyPromise=null;widget=null;container=null;ready=false;layoutReady=true;events=new ie;libraryPath;customCssUrl;constructor(e,t,a,o){this.settings=e,this.chartManager=t,this.WidgetCtor=a,this.libraryPath=o?.libraryPath??"/static/charting_library/",this.customCssUrl=o?.customCssUrl??"custom-styles.css",this.initModules();}getWidget(){return this.widget}async init(e){if(this.widgetReadyPromise)throw new Error("ChartWidgetBridge already initialized.");let t=this.getWidgetOptions();this.container=e,this.widget=new this.WidgetCtor({...t,container:e});let a=new Promise(o=>{this.widget?.onChartReady(()=>o());});this.widgetReadyPromise=a,this.readyPromise=a.then(()=>(this.ready=true,this.handleChartReady())).catch(o=>{console.warn("ChartWidgetBridge widget ready failed",o);}),this.moduleInstances.forEach((o,i)=>{try{o.init?.call(o);}catch(s){console.warn(`ChartWidgetBridge init module ${i}`,s);}}),await Promise.race([this.readyPromise,new Promise((o,i)=>setTimeout(i,6e4,new Error("ChartWidgetBridge init timeout")))]);}async destroy(){this.moduleInstances.forEach(e=>e.destroy?.call(e)),this.symbolIntervalSubs.forEach(e=>e()),this.symbolIntervalSubs.clear(),this.events.clear(),this.abortController.abort(),this.ready=false,this.widgetReadyPromise=null,this.readyPromise=null,this.widget?.remove(),this.widget=null;}async onReady(){return new Promise((e,t)=>{this.widget?this.widget.onChartReady(()=>this.readyPromise?.then(e).catch(t)):t(Error("cannot call `onReady` before `init`"));})}async asyncWidgetMethodContext(e){return new Promise((t,a)=>{if(!this.widgetReadyPromise){a(new Error("ChartWidgetBridge: widget not ready"));return}let o=this.widgetReadyPromise.then(()=>this.waitForLayout()),i=this.abortController.signal,s=()=>a(i.reason);i.addEventListener("abort",s),o.then(()=>e(this.widget,t)).catch(a).finally(()=>i.removeEventListener("abort",s));})}getModule(e){return this.moduleInstances.get(e)}applyColorPaletteOverrides(){this.widget?.applyOverrides(this.getColorPaletteOverrides()),this.widget?.applyStudiesOverrides(this.getColorPaletteStudiesOverrides());}getWidgetOptions(){let e=["header_widget","legend_inplace_edit","display_market_status","save_shortcut","show_interval_dialog_on_key_press","symbol_info","symbol_search_hot_key","uppercase_instrument_names","show_symbol_logo_in_legend","show_symbol_logo_for_compare_studies","drawing_templates",...this.settings.disabledFeatures],t=["determine_first_data_request_size_using_visible_range","request_only_visible_range_on_reset","show_exchange_logos","show_symbol_logos","dont_show_boolean_study_arguments","hide_last_na_study_output","hide_right_toolbar","seconds_resolution","saveload_separate_drawings_storage","volume_force_overlay","create_volume_indicator_by_default","two_character_bar_marks_labels",...this.settings.enabledFeatures];return this.settings.enableHideDrawingToolsByDefault&&t.push("hide_left_toolbar_by_default"),this.settings.enableTimeframesToolbar||e.push("timeframes_toolbar"),this.settings.enableCreateVolumeIndicatorByDefault||e.push("create_volume_indicator_by_default"),this.settings.enableVolumeForceOverlay||e.push("volume_force_overlay"),{container:"",autosize:true,debug:false,load_last_chart:true,auto_save_delay:1,timezone:this.localTimezone,library_path:this.libraryPath,custom_css_url:this.customCssUrl,theme:z(this.settings.theme),custom_font_family:window.getComputedStyle(document.body).fontFamily,symbol:this.chartManager.activeArea?.tickerSymbol,interval:R(this.chartManager.activeArea?.resolution),locale:this.settings.locale,datafeed:this.getModule("datafeed"),save_load_adapter:this.getModule("saveLoadAdapter"),settings_adapter:this.getModule("settingsAdapter"),custom_formatters:{priceFormatterFactory:this.settings.priceFormatterFactory?(a,o)=>this.settings.priceFormatterFactory(a,o):()=>null},overrides:{...this.getSettingsOverrides(),...this.getColorPaletteOverrides()},studies_overrides:this.getColorPaletteStudiesOverrides(),disabled_features:[...new Set(e)],enabled_features:[...new Set(t)].filter(a=>!e.includes(a)),supported_resolutions:A.map(R)}}async handleChartReady(){let e=ee(this.settings.layout);e!==this.widget?.layout()&&await this.waitForLayout(e),this.widget?.setActiveChart(this.chartManager.selectedIndex),this.getModule("saveLoadAdapter")?.shouldResetColorPalette&&await this.widget?.changeTheme(z(this.settings.theme),{disableUndo:true}),this.applyColorPaletteOverrides(),this.widget?.subscribe("onAutoSaveNeeded",this.onAutoSaveNeeded.bind(this)),this.widget?.subscribe("activeChartChanged",this.activeChartChanged.bind(this)),this.widget?.subscribe("layout_about_to_be_changed",this.layoutWillChange.bind(this)),this.widget?.subscribe("layout_changed",this.layoutChanged.bind(this)),this.syncChartsChanges(),this.subscribeChartsChanges(),this.installEventHooks(),this.resetTimezone();}onAutoSaveNeeded(){try{this.widget?.saveChartToServer(void 0,void 0,{defaultChartName:"DEFAULT"});}catch(e){console.warn("ChartWidgetBridge.onAutoSaveNeeded",e);}}activeChartChanged(e){this.chartManager.selectedIndex=e,this.chartManager.settings.saveLoadAdapter.saveSettings(this.chartManager.settingsData).catch(console.error);}layoutWillChange(e){this.layoutReady=false,this.chartManager.setLayout(De(e));}layoutChanged(){this.layoutReady=true,this.syncChartsChanges(),this.subscribeChartsChanges(),this.widget?.unloadUnusedCharts(),this.widget?.saveChartToServer();}syncChartsChanges(){this.widget?.symbolSync()?.setValue(false),this.widget?.intervalSync()?.setValue(false);let e=this.widget?.chartsCount()??0;for(let t=0;t<e;t++){let a=this.chartManager.areaByIndex(t),o=this.widget.chart(t);o.setSymbol(a?.tickerSymbol??"",{doNotActivateChart:true}),o.setResolution(R(a?.resolution),{doNotActivateChart:true});}}subscribeChartsChanges(){let e=this.widget?.chartsCount()??0;this.symbolIntervalSubs.forEach((t,a)=>{parseInt(a)>=e&&(t(),this.symbolIntervalSubs.delete(a));});for(let t=0;t<e;t++){if(this.symbolIntervalSubs.has(`${t}`))continue;let a=this.chartManager.areaByIndex(t),o=this.widget.chart(t);o.getPanes().forEach(h=>h.getMainSourcePriceScale()?.setAutoScale(true));let i=o.onSymbolChanged(),s=o.onIntervalChanged(),l=()=>{this.events.emit("symbolChanged",[t,o.symbol()]),a?.setSymbol(o.symbol()).catch(()=>{}),this.onAutoSaveNeeded();},n=h=>{let d=X(h);this.events.emit("resolutionChanged",[t,d]),this.chartManager.setResolution(d).catch(()=>{});};i.subscribe(a,l),s.subscribe(a,n),this.symbolIntervalSubs.set(`${t}`,()=>{i.unsubscribe(a,l),s.unsubscribe(a,n);});}}installEventHooks(){let e=this.container?.lastElementChild,t=e?.contentWindow?.document;if(t&&(t.addEventListener("click",()=>e?.click()),t.defaultView?.MutationObserver)){let a=new WeakSet,o=t.querySelector(".layout__area--center");if(o){let i=()=>{o.querySelectorAll(".chart-container").forEach((s,l)=>{a.has(s)||(a.add(s),gt.forEach(n=>{s.addEventListener(n,h=>this.events.emit("domEvent",[l,n,h]),{passive:true});}));});};new t.defaultView.MutationObserver(i).observe(o,{childList:true}),i();}}}resetTimezone(){try{let e=this.widget?.chartsCount()??0;for(let t=0;t<e;t++)this.widget?.chart(t)?.getTimezoneApi()?.setTimezone(this.localTimezone);}catch(e){console.error("ChartWidgetBridge: Reset timezone",e);}}get localTimezone(){return Intl.DateTimeFormat().resolvedOptions().timeZone}async waitForLayout(e){if(!this.widget||this.layoutReady&&!e)return;let t;return new Promise(o=>{t=o,this.widget.subscribe("layout_changed",o),e&&this.widget.setLayout(e);}).finally(()=>{this.widget.unsubscribe("layout_changed",t);})}getSettingsOverrides(){return {"mainSeriesProperties.minTick":"default","paneProperties.legendProperties.showSeriesTitle":this.settings.enableLegendSeriesTitle}}getColorPaletteOverrides(){let e=this.resolveThemeColor(this.settings.backgroundColor,V.chartBg),t=this.resolveThemeColor(this.settings.increaseColor,V.increase),a=this.resolveThemeColor(this.settings.decreaseColor,V.decrease),o=this.settings.theme==="dark"?V.card:mt.card;return {"paneProperties.background":e,"paneProperties.backgroundType":"solid",volumePaneSize:"medium","mainSeriesProperties.candleStyle.upColor":t,"mainSeriesProperties.barStyle.upColor":t,"mainSeriesProperties.columnStyle.upColor":t,"mainSeriesProperties.candleStyle.downColor":a,"mainSeriesProperties.barStyle.downColor":a,"mainSeriesProperties.columnStyle.downColor":a,"mainSeriesProperties.candleStyle.borderUpColor":t,"mainSeriesProperties.candleStyle.borderDownColor":a,"mainSeriesProperties.candleStyle.wickUpColor":t,"mainSeriesProperties.candleStyle.wickDownColor":a,"mainSeriesProperties.hollowCandleStyle.upColor":t,"mainSeriesProperties.hollowCandleStyle.downColor":a,"mainSeriesProperties.hollowCandleStyle.borderUpColor":t,"mainSeriesProperties.hollowCandleStyle.borderDownColor":a,"mainSeriesProperties.hollowCandleStyle.wickUpColor":t,"mainSeriesProperties.hollowCandleStyle.wickDownColor":a,"mainSeriesProperties.haStyle.upColor":t,"mainSeriesProperties.haStyle.downColor":a,"mainSeriesProperties.haStyle.borderUpColor":t,"mainSeriesProperties.haStyle.borderDownColor":a,"mainSeriesProperties.haStyle.wickUpColor":t,"mainSeriesProperties.haStyle.wickDownColor":a,"mainSeriesProperties.lineStyle.color":t,"mainSeriesProperties.areaStyle.color1":t,"mainSeriesProperties.areaStyle.color2":e,"mainSeriesProperties.areaStyle.linecolor":t,"mainSeriesProperties.areaStyle.transparency":65,"mainSeriesProperties.baselineStyle.topFillColor1":t,"mainSeriesProperties.baselineStyle.topFillColor2":e,"mainSeriesProperties.baselineStyle.bottomFillColor1":a,"mainSeriesProperties.baselineStyle.bottomFillColor2":e,"mainSeriesProperties.baselineStyle.topLineColor":t,"mainSeriesProperties.baselineStyle.bottomLineColor":a,"mainSeriesProperties.baselineStyle.transparency":65,"linetoolorder.bodyBackgroundColor":o,"linetoolorder.bodyBackgroundTransparency":0}}getColorPaletteStudiesOverrides(){let e=this.resolveThemeColor(this.settings.increaseColor,V.increase);return {"volume.volume.color.0":this.resolveThemeColor(this.settings.decreaseColor,V.decrease),"volume.volume.color.1":e,"volume.volume.transparency":80}}resolveThemeColor(e,t){if(!e||!e.includes("var("))return e??t;if(typeof document>"u"||!document.body)return t;let a=document.createElement("span");a.style.color=e,a.style.display="none",document.body.appendChild(a);let o=window.getComputedStyle(a).color;return a.remove(),o||t}initModules(){Object.entries({datafeed:se,saveLoadAdapter:ne,settingsAdapter:le}).forEach(([t,a])=>{this.moduleInstances.set(t,new a(this.settings,this.chartManager,this));});}};var da={2:"1A",3:"2A",4:"3E",5:"4A",6:"5C",7:"6A",8:"7A"};function ha({chartManager:r,index:e,onClose:t}){let a=react.useRef(null),o=r.areaByIndex(e),i=x(o?.tickerSymbol??""),s=o?.symbolInfo,l=s?.description||s?.name||i.address||o?.tickerSymbol||"-";return react.useEffect(()=>{let n=a.current;if(!n)return;let h=u=>{u.preventDefault(),u.stopPropagation();},d=u=>{h(u),t(e);};return n.addEventListener("mousedown",h,true),n.addEventListener("click",d,true),()=>{n.removeEventListener("mousedown",h,true),n.removeEventListener("click",d,true);}},[e,t]),jsxRuntime.jsxs("div",{style:{alignItems:"center",background:"var(--tv-color-pane-background, #050807)",boxSizing:"border-box",color:"var(--tv-color-toolbar-button-text-hover, #f5f5f5)",display:"flex",fontFamily:"inherit",height:"32px",justifyContent:"space-between",padding:"6px 8px",width:"100%"},children:[jsxRuntime.jsxs("div",{style:{alignItems:"center",display:"flex",gap:"8px",minWidth:0},children:[jsxRuntime.jsx("span",{style:{fontSize:"12px",fontWeight:500,maxWidth:"220px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:l,children:l}),jsxRuntime.jsx("span",{style:{color:"var(--tv-color-toolbar-button-text, #8b949e)",fontSize:"11px"},children:o?.resolution})]}),e>0&&jsxRuntime.jsx("button",{ref:a,type:"button","aria-label":"Close chart",style:{alignItems:"center",background:"transparent",border:0,color:"var(--tv-color-toolbar-button-text, #8b949e)",cursor:"pointer",display:"flex",fontSize:"18px",height:"20px",justifyContent:"center",lineHeight:1,padding:0,width:"20px"},children:"\xD7"})]})}function st(){let{prefix:r,chartManager:e}=c(),t=jotai.useAtomValue(E(r)),a=jotai.useAtomValue(I(r)),o=jotai.useAtomValue(f(r)),i=react.useRef(new Map),s=react.useCallback(n=>{let h=e.chartCount,d=da[h];if(!d||n<=0||n>=h)return;let u=e.internalWidget?.widget,C=Array.from({length:h},(m,w)=>u?.chart(w)?.symbol()).filter((m,w)=>w!==n&&!!m);e.setLayout(d),setTimeout(()=>{C.forEach((m,w)=>{e.areaByIndex(w)?.setSymbol(m);});});},[e]),l=react.useCallback(()=>{let n=e.internalWidget?.widget,h=e.chartCount;if(i.current.forEach((d,u)=>{(h===1||u>=h||!d.element.isConnected)&&(d.root.unmount(),i.current.delete(u));}),!(!n||h<=1))for(let d=0;d<h;d+=1){let u=i.current.get(d);if(!u){let m=n.chart(d)?._chartWidget?._mainDiv;if(!m)continue;let w=m.ownerDocument.createElement("div");w.style.width="100%",w.style.zIndex="100",m.prepend(w),u={element:w,root:client.createRoot(w)},i.current.set(d,u);}u.root.render(jsxRuntime.jsx(ha,{chartManager:e,index:d,onClose:s}));}},[e,s]);return react.useEffect(()=>{if(!t)return;let n=e.internalWidget?.widget;if(!n)return;let h=()=>setTimeout(l);return h(),n.subscribe("layout_changed",h),()=>n.unsubscribe("layout_changed",h)},[e,t,l]),react.useEffect(()=>{t&&setTimeout(l);},[o,a,t,l]),react.useEffect(()=>()=>{let n=[...i.current.values()];i.current.clear(),queueMicrotask(()=>n.forEach(h=>h.root.unmount()));},[]),null}var lt=react.forwardRef(({onReady:r},e)=>{let{chartManager:t,chartSettings:a,widgetConstructor:o,libraryPath:i,customCssUrl:s}=c(),l=react.useRef(r),[n,h]=react.useState(),[d,u]=react.useState(null),[C,m]=react.useState(false);return react.useEffect(()=>{C&&l.current&&setTimeout(l.current);},[C]),react.useImperativeHandle(e,()=>n,[n]),react.useEffect(()=>{if(!d)return;let w=new de(a,t,o,{libraryPath:i,customCssUrl:s}),jt=new oe(a,t,w);return h(jt),w.init(d).then(()=>m(true)).catch(Xt=>{console.error("TradingViewWidgetContainer: failed to init bridge",Xt);}),()=>{w.destroy().then(()=>{h(void 0),m(false);}).catch(()=>{console.error("TradingViewWidgetContainer: failed to destroy bridge");});}},[d,a,t,o,i,s]),jsxRuntime.jsxs("div",{className:"w-full h-full",children:[jsxRuntime.jsx(st,{}),jsxRuntime.jsx("div",{id:"tv_chart_container",className:"w-full h-full",ref:u})]})});var dt=react.memo(({onReady:r})=>{let{chartManager:e,chartSettings:t}=c(),a=react.useMemo(()=>`${t.timezone}_${e.reloadId}`,[t.timezone,e.reloadId]);react.useLayoutEffect(()=>{e.setLoading(true);},[e,t.chartType,a]);let o=react.useCallback(()=>{r?.(),e.onInternalWidgetReady(),e.setLoading(false);},[e,r]);return jsxRuntime.jsx("div",{className:"h-full min-h-0 w-full overflow-hidden",children:jsxRuntime.jsx(lt,{onReady:o,ref:i=>e.setInternalWidget(i??null)})})});var Ta=react.memo(({toolbar:r,loadingOverlay:e,onReady:t,children:a})=>{let{prefix:o}=c(),i=jotai.useAtomValue(W(o)),s=jotai.useAtomValue(P(o));return react.useEffect(()=>{if(!s)return;let l=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=l;}},[s]),jsxRuntime.jsxs("div",{"data-fullscreen":s,style:s?{background:"var(--color-background, #050807)",display:"flex",flexDirection:"column",height:"100vh",inset:0,minHeight:0,position:"fixed",width:"100vw",zIndex:9999}:{display:"contents"},children:[r!==false&&jsxRuntime.jsx(at,{...r||{}}),jsxRuntime.jsxs("div",{className:"relative flex-1 w-full overflow-hidden",children:[i&&e&&jsxRuntime.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center bg-background/80",children:e}),jsxRuntime.jsx(dt,{onReady:t})]}),a]})}),wa=react.forwardRef(({initConfig:r,widgetConstructor:e,libraryPath:t,customCssUrl:a,toolbar:o,loadingOverlay:i,onReady:s,children:l,className:n},h)=>jsxRuntime.jsx("div",{className:`flex flex-col w-full h-full ${n??""}`,children:jsxRuntime.jsx(Oe,{ref:h,initConfig:r,widgetConstructor:e,libraryPath:t,customCssUrl:a,children:jsxRuntime.jsx(Ta,{toolbar:o,loadingOverlay:i,onReady:s,children:l})})}));var La=react.memo(({index:r})=>{let{prefix:e}=c(),t=jotai.useAtomValue(f(e)),a=jotai.useAtomValue(T(e)),i=t[r??a];return i?jsxRuntime.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[jsxRuntime.jsx("span",{className:"font-medium text-foreground",children:i.tickerSymbol||i.symbol}),jsxRuntime.jsx("span",{children:i.resolution})]}):null});function Ma(){return c().chartManager}function Pa(){let{prefix:r,chartManager:e}=c(),t=jotai.useAtomValue(T(r)),a=jotai.useAtomValue(f(r));return react.useMemo(()=>a.length?e.areaByIndex(t):null,[e,t,a])}function _a(){let{prefix:r,chartManager:e}=c(),t=jotai.useAtomValue(T(r)),o=jotai.useAtomValue(f(r))[t];return react.useMemo(()=>o?.tickerSymbol?e.symbolResolver?.getSymbolInfo(o.tickerSymbol)??null:null,[e,o?.tickerSymbol])}var Kt=768;function Yt(r,e=Kt){return r>0&&r<e}function Jt(r){try{return Se(r)}catch{return Se(X(r))}}function Aa(r){return r instanceof Date?r.getTime():r}function Zt(r,e){let t={time:Be(Aa(r.time),e),open:r.open,high:r.high,low:r.low,close:r.close};return r.volume!==void 0&&(t.volume=r.volume),t}function Qt(r,e){return `${r.ticker??r.name}:${e}`}var ht=class{source;options;liveListeners=new Map;lastHistoryBarTime=new Map;liveGeneration=0;constructor(e,t={}){this.source=e,this.options=t;}isMobileViewport(e){return Yt(e,this.options.mobileBreakpointPx)}async onReady(e){await this.options.onReady?.(e);}onDestroy(){for(let e of [...this.liveListeners.keys()])this.unsubscribeLiveBars(e);this.lastHistoryBarTime.clear(),this.options.onDestroy?.();}async resolveSymbol(e,t){return await this.options.resolveSymbol?.(e,t)??null}async getBars(e,t,a){return this.getHistoryBars(e,t,a)}subscribeBars(e,t,a,o,i){this.subscribeLiveBars(e,t,a,o,i);}unsubscribeBars(e){this.unsubscribeLiveBars(e);}getMarks(e,t,a,o,i){this.options.getMarks?.(e,t,a,o,i);}getFirstBarTime(e,t,a){return this.options.getFirstBarTime?.(e,t,a)??Promise.resolve()}async getHistoryBars(e,t,a){let o=await this.source.getHistory({symbolInfo:e,resolution:t,periodParams:a}),i=Jt(t),s=(o??[]).map(l=>Zt(l,i));if(s.length>0){let l=Qt(e,t),n=Math.max(...s.map(d=>d.time)),h=this.lastHistoryBarTime.get(l)??0;n>h&&this.lastHistoryBarTime.set(l,n);}return s}subscribeLiveBars(e,t,a,o,i){this.unsubscribeLiveBars(o);let s=Qt(e,t),l=Jt(t),n=++this.liveGeneration;this.liveListeners.set(o,{symbolKey:s,lastBarTime:this.lastHistoryBarTime.get(s)??0,generation:n}),this.source.subscribe({symbolInfo:e,resolution:t,listenerGuid:o,onResetCacheNeededCallback:i},h=>{let d=this.liveListeners.get(o);if(!d||d.generation!==n)return;let u=Zt(h,l),C=Math.max(d.lastBarTime,this.lastHistoryBarTime.get(d.symbolKey)??0);u.time<C||(d.lastBarTime=u.time,a(u));});}unsubscribeLiveBars(e){this.liveListeners.has(e)&&(this.liveListeners.delete(e),this.source.unsubscribe(e));}};
|
|
2
|
+
exports.ALL_TV_CHART_RESOLUTIONS=A;exports.ChartAreaManager=U;exports.ChartDataFeed=se;exports.ChartLibraryWidget=oe;exports.ChartManager=K;exports.ChartSaveLoadAdapter=ne;exports.ChartSettings=te;exports.ChartSettingsAdapter=le;exports.ChartSettingsStore=Y;exports.ChartSymbolResolver=re;exports.ChartWidget=ae;exports.ChartWidgetBridge=de;exports.DEFAULT_TV_CHART_MOBILE_BREAKPOINT_PX=Kt;exports.DEFAULT_TV_CHART_RESOLUTIONS=_;exports.ENABLED_TV_CHART_FEATURES=Ae;exports.EventEmitter=ie;exports.SUPPORTED_TV_CHART_LAYOUTS=ke;exports.TV_CHART_THEME_COLORS=V;exports.TradingView=wa;exports.TradingViewAreaTitle=La;exports.TradingViewConfig=Ne;exports.TradingViewDatafeedAdapter=ht;exports.TradingViewFullscreen=ze;exports.TradingViewKlineStyleSelect=Le;exports.TradingViewLayout=st;exports.TradingViewMultiChartSelect=Ze;exports.TradingViewOpenIndicator=Re;exports.TradingViewOpenSettings=Ke;exports.TradingViewPriceTypeSwitch=Me;exports.TradingViewProvider=Oe;exports.TradingViewQuoteTypeSwitch=Xe;exports.TradingViewResolutions=tt;exports.TradingViewSnapshot=rt;exports.TradingViewToolbar=at;exports.TradingViewToolbarProvider=qe;exports.TradingViewWidgetContainer=lt;exports.TradingViewWidgetProvider=dt;exports.TvChartErrorResetType=ut;exports.TvChartFeature=me;exports.TvChartHandle=we;exports.TvChartKlineStyle=ge;exports.TvChartLayout=M;exports.TvChartPriceType=ce;exports.TvChartQuoteType=ue;exports.TvChartTheme=ct;exports.TvChartType=he;exports.chartAreasFamily=f;exports.chartFullscreenFamily=P;exports.chartLoadingFamily=W;exports.chartPinnedResolutionsFamily=k;exports.chartSelectedIndexFamily=T;exports.chartShowDrawingToolbarFamily=F;exports.getTvChartLayoutReverse=De;exports.getTvChartLibraryLayout=ee;exports.getTvChartLibraryLocale=sr;exports.getTvChartLibraryResolution=R;exports.getTvChartLibraryTheme=z;exports.getTvChartResolutionFrame=Se;exports.getTvChartResolutionReverse=X;exports.getTvChartTickTimestamp=Be;exports.isTvChartMobileViewport=Yt;exports.parseSymbol=x;exports.settingsBackgroundColorFamily=be;exports.settingsChartTypeFamily=N;exports.settingsDataFamily=Q;exports.settingsDisabledFeaturesFamily=H;exports.settingsEnabledFeaturesFamily=O;exports.settingsLayoutFamily=I;exports.settingsLocaleFamily=pe;exports.settingsReverseColorFamily=fe;exports.settingsStorageIdFamily=Z;exports.settingsThemeFamily=J;exports.settingsTickerSymbolFamily=Ce;exports.settingsTimezoneFamily=ye;exports.stringifySymbol=j;exports.stringifySymbolShort=ve;exports.useActiveAreaManager=Pa;exports.useChartManager=Ma;exports.useSymbolInfo=_a;exports.useTvChartContext=c;exports.useTvChartManager=Cr;exports.useTvChartPrefix=fr;exports.useTvChartToolbarContext=D;exports.widgetReadyFamily=E;//# sourceMappingURL=index.js.map
|
|
2
3
|
//# sourceMappingURL=index.js.map
|