candleview 2.9.2 → 2.9.3
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/README.md +38 -27
- package/dist/index.d.ts +7 -0
- package/dist/index.js +2 -2
- package/dist/index.mjs +239 -61
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
<p align="center">
|
|
2
|
-
<
|
|
3
|
-
<
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
</table>
|
|
2
|
+
<picture>
|
|
3
|
+
<source media="(prefers-color-scheme: dark)" srcset="./assets/logo/logo_imgtxt_dark_en.png">
|
|
4
|
+
<source media="(prefers-color-scheme: light)" srcset="./assets/logo/logo_imgtxt_light_en.png">
|
|
5
|
+
<img src="./assets/logo/logo_imgtxt_light_en.png" alt="Portal" width="300">
|
|
6
|
+
</picture>
|
|
8
7
|
</p>
|
|
9
8
|
<h4 align="center">
|
|
10
9
|
An AI-driven financial time-series data visualization and rendering engine.
|
|
@@ -38,8 +37,8 @@ yarn add candleview
|
|
|
38
37
|
|
|
39
38
|
# 🌐 Link
|
|
40
39
|
|
|
41
|
-
| Website
|
|
42
|
-
|
|
|
40
|
+
| Website | Website(CN) | Emulator | Markets |
|
|
41
|
+
| ---------------------------------------------------- | ---------------------------------------------------- | ---------------------------------------------------------------- | ----------------------------------------------------------- |
|
|
43
42
|
| <a href="https://candleview.vercel.app/">Website</a> | <a href="https://www.candleview.cn/">Website(CN)</a> | <a href="https://candleview.vercel.app/application">Emulator</a> | <a href="https://candleview.vercel.app/markets">Markets</a> |
|
|
44
43
|
|
|
45
44
|
# 📚 Directory
|
|
@@ -52,6 +51,33 @@ yarn add candleview
|
|
|
52
51
|
| **docs** | Documents. |
|
|
53
52
|
| **assets** | Asset Directory. |
|
|
54
53
|
|
|
54
|
+
# Props
|
|
55
|
+
|
|
56
|
+
| Parameter | Type | Default | Description | Required |
|
|
57
|
+
| ------------------------------------- | -------------------------------------------------------------------------------------------------------- | ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ | -------- |
|
|
58
|
+
| `theme` | `'dark' \| 'light'` | `'dark'` | Theme mode | No |
|
|
59
|
+
| `i18n` | `'en' \| 'zh-cn'` | `'zh-cn'` | Language setting | No |
|
|
60
|
+
| `height` | `number \| string` | `500` | Chart height (px or percentage) | No |
|
|
61
|
+
| `width` | `number \| string` | `'100%'` | Chart width (px or percentage) | No |
|
|
62
|
+
| `title` | `string` | `''` | Chart title displayed on the chart | Yes |
|
|
63
|
+
| `toppanel` | `boolean` | `false` | Show top toolbar | No |
|
|
64
|
+
| `leftpanel` | `boolean` | `false` | Show left drawing tools panel | No |
|
|
65
|
+
| `markData` | `IStaticMarkData[]` | `[]` | Pre-drawn marks data | No |
|
|
66
|
+
| `timeframe` | `string` | `'1d'` | Chart timeframe (e.g., '1m', '1h', '1d') | No |
|
|
67
|
+
| `timezone` | `string` | `'Asia/Shanghai'` | Timezone for data display | No |
|
|
68
|
+
| `data` | `ICandleViewDataPoint[]` | `[]` | K-line data array | No |
|
|
69
|
+
| `ai` | `boolean` | `false` | Enable AI function | No |
|
|
70
|
+
| `aiconfigs` | `AIConfig[]` | `[]` | AI configuration list | No |
|
|
71
|
+
| `terminal` | `boolean` | `false` | Show terminal panel | No |
|
|
72
|
+
| `isMobileMode` | `boolean` | `false` | Enable mobile mode | No |
|
|
73
|
+
| `isOpenViewportSegmentation` | `boolean` | `false` | Enable viewport data segmentation | No |
|
|
74
|
+
| `isCloseInternalTimeFrameCalculation` | `boolean` | `false` | Disable internal timeframe calculation | No |
|
|
75
|
+
| `timeframeCallbacks` | `Partial<Record<TimeframeEnum, () => void>>` | `{}` | Callbacks for custom timeframe switching | No |
|
|
76
|
+
| `mainChartIndicators` | `string[]` | `[]` | Main chart indicator names to initialize (supported: 'ma', 'ema', 'bollinger', 'ichimoku', 'donchian', 'envelope', 'vwap', 'heatmap', 'marketprofile') | No |
|
|
77
|
+
| `subChartIndicators` | `string[]` | `[]` | Sub chart indicator names to initialize (supported: 'rsi', 'macd', 'volume', 'sar', 'kdj', 'atr', 'stochastic', 'cci', 'bbwidth', 'adx', 'obv') | No |
|
|
78
|
+
| `danmakus` | `string[]` | `[]` | Danmaku messages | No |
|
|
79
|
+
| `handleScreenshotCapture` | `(imageData: { dataUrl: string; blob: Blob; width: number; height: number; timestamp: number }) => void` | `undefined` | Callback for screenshot capture | No |
|
|
80
|
+
|
|
55
81
|
# 🚀 Quick Start
|
|
56
82
|
|
|
57
83
|
```typescript
|
|
@@ -140,6 +166,10 @@ const App = () => {
|
|
|
140
166
|
};
|
|
141
167
|
```
|
|
142
168
|
|
|
169
|
+
# Danmaku System
|
|
170
|
+
|
|
171
|
+
<img src="./assets/danmaku.gif" alt="CandleView Danmaku System" width="100%">
|
|
172
|
+
|
|
143
173
|
# AI Features
|
|
144
174
|
|
|
145
175
|
<img src="./assets/ai/ai-data-analysis.gif" alt="CandleView AI" width="100%">
|
|
@@ -455,25 +485,6 @@ $ history # View recent command history
|
|
|
455
485
|
|
|
456
486
|
# 🔧 Configuration Options
|
|
457
487
|
|
|
458
|
-
## Props
|
|
459
|
-
|
|
460
|
-
| Parameter | Type | Default | Description | Required |
|
|
461
|
-
| ------------------------- | -------------------------------------------------------------------------------------------------------- | ----------------- | ---------------------------------------- | -------- |
|
|
462
|
-
| `theme` | `'dark' \| 'light'` | `'dark'` | Theme mode | No |
|
|
463
|
-
| `i18n` | `'en' \| 'zh-cn'` | `'zh-cn'` | Language setting | No |
|
|
464
|
-
| `height` | `number \| string` | `500` | Chart height (px or percentage) | No |
|
|
465
|
-
| `title` | `string` | `''` | Chart title displayed on the chart | Yes |
|
|
466
|
-
| `showToolbar` | `boolean` | `true` | Show top toolbar | No |
|
|
467
|
-
| `showLeftPanel` | `boolean` | `true` | Show left drawing tools panel | No |
|
|
468
|
-
| `showTopPanel` | `boolean` | `true` | Show top settings panel | No |
|
|
469
|
-
| `showIndicators` | `boolean` | `true` | Show indicators panel | No |
|
|
470
|
-
| `timeframe` | `string` | `'1d'` | Chart timeframe (e.g., '1m', '1h', '1d') | No |
|
|
471
|
-
| `timezone` | `string` | `'Asia/Shanghai'` | Timezone for data display | No |
|
|
472
|
-
| `data` | `ICandleViewDataPoint[]` | `[]` | K-line data array | No |
|
|
473
|
-
| `url` | `string` | `''` | URL to fetch data from | No |
|
|
474
|
-
| `markData` | `IStaticMarkData[]` | `[]` | Pre-drawn marks data | No |
|
|
475
|
-
| `handleScreenshotCapture` | `(imageData: { dataUrl: string; blob: Blob; width: number; height: number; timestamp: number }) => void` | `undefined` | Callback for screenshot capture | No |
|
|
476
|
-
|
|
477
488
|
## ⏰ Supported Timeframes
|
|
478
489
|
|
|
479
490
|
### Second-based Timeframes
|
package/dist/index.d.ts
CHANGED
|
@@ -58,10 +58,16 @@ declare class CandleView extends default_2.Component<CandleViewProps, CandleView
|
|
|
58
58
|
private preparedData;
|
|
59
59
|
private originalData;
|
|
60
60
|
private aiManager;
|
|
61
|
+
private danmakuManager;
|
|
62
|
+
private danmakuCanvasRef;
|
|
63
|
+
private danmakuContainerRef;
|
|
61
64
|
constructor(props: CandleViewProps);
|
|
62
65
|
componentDidMount(): void;
|
|
63
66
|
componentDidUpdate(prevProps: CandleViewProps, prevState: CandleViewState): void;
|
|
64
67
|
componentWillUnmount(): void;
|
|
68
|
+
private initializeDanmaku;
|
|
69
|
+
private clearDanmaku;
|
|
70
|
+
private handleDanmakuResize;
|
|
65
71
|
private initializeMainChartIndicators;
|
|
66
72
|
private initializeSubChartIndicators;
|
|
67
73
|
private handleAiMobileMouseMove;
|
|
@@ -174,6 +180,7 @@ declare interface CandleViewProps {
|
|
|
174
180
|
isThemeSelection?: boolean;
|
|
175
181
|
mainChartIndicators?: string[];
|
|
176
182
|
subChartIndicators?: string[];
|
|
183
|
+
danmakus?: string[];
|
|
177
184
|
handleScreenshotCapture?: (imageData: {
|
|
178
185
|
dataUrl: string;
|
|
179
186
|
blob: Blob;
|
package/dist/index.js
CHANGED
|
@@ -388,7 +388,7 @@ console.log("结果:", x);
|
|
|
388
388
|
-webkit-user-select: none;
|
|
389
389
|
cursor: row-resize !important;
|
|
390
390
|
}
|
|
391
|
-
`})]})};class Be{constructor(){Be.standardizedDPI()}static standardizedDPI(){Object.defineProperty(window,"devicePixelRatio",{get:()=>1,configurable:!0});const t=document.createElement.bind(document);document.createElement=function(r,a){const s=t(r,a);if(r.toLowerCase()==="canvas"){const n=()=>{if(s.parentElement){const l=s.getBoundingClientRect();if(l.width>0&&l.height>0){const h=s;(h.width!==l.width||h.height!==l.height)&&(h.width=l.width,h.height=l.height)}}};setTimeout(n,0);const o=new ResizeObserver(()=>{n()});setTimeout(()=>{s.parentElement&&o.observe(s)},100),s.addEventListener("DOMNodeRemoved",()=>{o.disconnect()})}return s};const e=()=>{document.querySelectorAll("canvas").forEach(r=>{const a=r.getBoundingClientRect();if(a.width>0&&a.height>0){const s=r;(s.width!==a.width||s.height!==a.height)&&(s.width=a.width,s.height=a.height)}})};setTimeout(e,0),setTimeout(e,100),setTimeout(e,300),new MutationObserver(r=>{let a=!1;r.forEach(s=>{s.addedNodes.forEach(n=>{n.nodeName==="CANVAS"&&(a=!0)})}),a&&setTimeout(e,50)}).observe(document.body,{childList:!0,subtree:!0}),window.addEventListener("resize",()=>{setTimeout(e,100)})}static forceFixCanvas(){document.querySelectorAll("canvas").forEach(t=>{const e=t.getBoundingClientRect();if(e.width>0&&e.height>0){const i=t;i.width=e.width,i.height=e.height}})}}class Zi extends y.Component{constructor(t){super(t),this.candleViewRef=y.createRef(),this.chartRef=y.createRef(),this.chartContainerRef=y.createRef(),this.chartLayerRef=y.createRef(),this.chart=null,this.resizeObserver=null,this.realTimeInterval=null,this.currentSeries=null,this.chartManager=null,this.updateTimeout=null,this.viewportManager=null,this.chartEventManager=null,this.aiPanelResizeRef=y.createRef(),this.isDragging=!1,this.startX=0,this.startChartWidth=0,this.containerWidth=0,this.terminalResizeRef=y.createRef(),this.isDraggingTerminal=!1,this.startY=0,this.startTerminalHeightRatio=0,this.aiMobilePanelResizeRef=y.createRef(),this.isDraggingAiMobilePanel=!1,this.startAiMobileY=0,this.startAiMobileHeightRatio=0,this.preparedData=[],this.originalData=[],this.aiManager=null,this.initializeMainChartIndicators=s=>{this.setState({selectedMainChartIndicator:null}),this.chartLayerRef.current&&Object.values(D).forEach(n=>{this.chartLayerRef.current?.handleRemoveIndicator&&this.chartLayerRef.current.handleRemoveIndicator(n)}),s.forEach(n=>{const o=n.toUpperCase();if(Object.values(D).includes(o)){let l=null;switch(o){case D.MA:l={...we,nonce:Date.now()};break;case D.EMA:l={...ve,nonce:Date.now()};break;case D.BOLLINGER:l={...xe,nonce:Date.now()};break;case D.ICHIMOKU:l={...Ae,nonce:Date.now()};break;case D.DONCHIAN:l={...De,nonce:Date.now()};break;case D.ENVELOPE:l={...Fe,nonce:Date.now()};break;case D.VWAP:l={...Ee,nonce:Date.now()};break;case D.HEATMAP:l={...ye,nonce:Date.now()};break;case D.MARKETPROFILE:l={...Re,nonce:Date.now()};break}l&&(this.setState({selectedMainChartIndicator:l}),this.chart&&this.currentSeries&&this.chartLayerRef.current&&this.chartLayerRef.current.handleMainChartIndicatorChange&&this.chartLayerRef.current.handleMainChartIndicatorChange(l))}})},this.initializeSubChartIndicators=s=>{this.setState({selectedSubChartIndicators:[]}),this.chartLayerRef.current&&this.state.selectedSubChartIndicators.forEach(o=>{this.chartLayerRef.current?.handleRemoveSubChartIndicator&&this.chartLayerRef.current.handleRemoveSubChartIndicator(o)});const n=[];s.forEach(o=>{const l=o.toUpperCase();Object.values(X).includes(l)&&(n.push(l),this.chartLayerRef.current&&this.handleExternalSelectedSubChartIndicator(l))}),this.setState({selectedSubChartIndicators:n})},this.handleAiMobileMouseMove=s=>{if(!this.isDraggingAiMobilePanel)return;const n=this.candleViewRef.current;if(!n)return;const o=n.clientHeight;if(o<=0)return;const l=this.startAiMobileY-s.clientY,h=this.startAiMobileHeightRatio+l/o,d=Math.max(.1,Math.min(.7,h));this.setState({mobileAiPanelHeightRatio:d})},this.handleAiMobileMouseUp=()=>{this.isDraggingAiMobilePanel&&(this.isDraggingAiMobilePanel=!1,this.setState({isResizingAiPanel:!1}),document.body.style.cursor="",document.body.style.userSelect="")},this.handleTerminalResizeMouseDown=s=>{s.preventDefault(),this.isDraggingTerminal=!0,this.setState({isResizingTerminal:!0}),this.candleViewRef.current&&(this.startY=s.clientY,this.startTerminalHeightRatio=this.state.terminalHeightRatio),document.body.style.cursor="row-resize",document.body.style.userSelect="none"},this.handleTerminalMouseMove=s=>{if(!this.isDraggingTerminal)return;const n=this.candleViewRef.current;if(!n)return;const o=n.clientHeight;if(o<=0)return;const l=this.startY-s.clientY,h=this.startTerminalHeightRatio+l/o,d=Math.max(.2,Math.min(.5,h));this.setState({terminalHeightRatio:d})},this.handleTerminalMouseUp=()=>{this.isDraggingTerminal&&(this.isDraggingTerminal=!1,this.setState({isResizingTerminal:!1}),document.body.style.cursor="",document.body.style.userSelect="")},this.handleResizeMouseDown=s=>{s.preventDefault(),this.isDragging=!0,this.setState({isResizingAiPanel:!0}),this.aiPanelResizeRef.current&&(this.aiPanelResizeRef.current.style.backgroundColor=this.state.currentTheme.divider.dragging);const n=this.candleViewRef.current;n&&(this.containerWidth=n.clientWidth,this.startX=s.clientX,this.startChartWidth=this.state.aiPanelWidthRatio),document.body.style.cursor="col-resize",document.body.style.userSelect="none"},this.handleMouseMove=s=>{if(!this.isDragging||!this.containerWidth)return;const n=s.clientX-this.startX;if(!this.state.ai)return;const o=Math.max(.3,Math.min(.9,this.startChartWidth+n/this.containerWidth));this.setState({aiPanelWidthRatio:o},()=>{if(this.chart){const l=this.chartContainerRef.current;if(l){const h=l.clientWidth,d=l.clientHeight;h>0&&d>0&&this.chart.applyOptions({width:h,height:d})}}})},this.handleMouseUp=()=>{this.isDragging&&(this.isDragging=!1,this.setState({isResizingAiPanel:!1}),this.aiPanelResizeRef.current&&(this.aiPanelResizeRef.current.style.backgroundColor=this.state.currentTheme.divider.normal),document.body.style.cursor="",document.body.style.userSelect="")},this.loadDataAsync=s=>{this.setState({dataLoadProgress:0,isDataLoading:!0}),this.loadExternalData().then(()=>(this.setState({dataLoadProgress:30}),this.loadInternalData())).then(()=>{this.setState({dataLoadProgress:70}),this.setState({dataLoadProgress:100,isDataLoading:!1,loadError:null},()=>{s&&s()})}).catch(n=>{this.setState({isDataLoading:!1,loadError:n.message})})},this.loadExternalData=async()=>(this.clearOriginalData(),new Promise((s,n)=>{try{this.setState({dataLoadProgress:10});const o=this.props.data||[];this.originalData=o,this.setState({dataLoadProgress:30}),s()}catch(o){n(o)}})),this.loadInternalData=async()=>new Promise(s=>{this.setState({dataLoadProgress:40}),this.clearChart(()=>{const n=ke.handleData(this.originalData,me({timeframe:this.state.timeframe,timezone:this.state.timezone},this.state.currentMainChartType,this.state.virtualDataBeforeCount,this.state.virtualDataAfterCount),this.state.currentMainChartType,this.props.isCloseInternalTimeFrameCalculation||!1);this.setState({dataLoadProgress:50}),setTimeout(()=>{this.preparedData=n,this.setState({dataLoadProgress:60}),this.setState({displayData:n,dataLoadProgress:70},()=>{s()})},50)})}),this.handleTimeFormatClick=()=>{this.setState({isTimeFormatModalOpen:!0})},this.handleCloseTimeClick=()=>{this.setState({isCloseTimeModalOpen:!0})},this.handleTradingDayClick=()=>{this.setState({isTradingDayModalOpen:!0})},this.handleTimezoneClick=()=>{this.setState({isTimezoneModalOpen:!0})},this.handleCloseModals=()=>{this.setState({isTimeframeModalOpen:!1,isIndicatorModalOpen:!1,isChartTypeModalOpen:!1,isSubChartModalOpen:!1,isTimezoneModalOpen:!1,isTimeFormatModalOpen:!1,isCloseTimeModalOpen:!1,isTradingDayModalOpen:!1,isMobileMenuOpen:!1,isAIModalOpen:!1})},this.handleTimezoneSelect=s=>{this.clearChart(),this.setState({currentTimezone:s,timezone:s,isTimezoneModalOpen:!1,isDataLoading:!0,dataLoadProgress:0},()=>{setTimeout(()=>{this.setState({dataLoadProgress:20}),this.loadInternalDataAsync(()=>{this.setState({dataLoadProgress:70}),this.initChart(),this.viewportManager?.positionChart(),setTimeout(()=>{this.setState({isDataLoading:!1,dataLoadProgress:100})},50)})},50)})},this.handleTimeframeSelect=s=>{if(this.clearChart(),this.props.isCloseInternalTimeFrameCalculation){const n=s;this.setState({activeTimeframe:n,timeframe:n},()=>{if(this.props.timeframeCallbacks){const o=this.props.timeframeCallbacks[n];o&&o()}})}else{const n=s;this.setState({activeTimeframe:n,timeframe:n,isTimeframeModalOpen:!1,isDataLoading:!0,dataLoadProgress:0},()=>{setTimeout(()=>{this.setState({dataLoadProgress:10}),this.loadInternalDataAsync(()=>{this.setState({dataLoadProgress:60}),this.initChart(),this.viewportManager?.positionChart(),setTimeout(()=>{this.setState({isDataLoading:!1,dataLoadProgress:100})},50)})},500)})}},this.loadInternalDataAsync=s=>new Promise(n=>{this.state.isDataLoading||this.setState({isDataLoading:!0}),this.setState({dataLoadProgress:10}),setTimeout(()=>{setTimeout(()=>{this.setState({dataLoadProgress:30});const h=ke.handleData(this.originalData,me({timeframe:this.state.timeframe,timezone:this.state.timezone},this.state.currentMainChartType,this.state.virtualDataBeforeCount,this.state.virtualDataAfterCount),this.state.currentMainChartType,this.props.isCloseInternalTimeFrameCalculation||!1);this.setState({dataLoadProgress:50}),setTimeout(()=>{this.preparedData=h,this.setState({displayData:h,dataLoadProgress:60},()=>{s&&s(),n()})},50)},0)},0)}),this.initChart=()=>{if(!(!this.currentSeries||!this.currentSeries.series))try{this.state.isDataLoading&&this.setState({dataLoadProgress:80}),this.currentSeries.series.setData(this.preparedData),this.state.isDataLoading&&setTimeout(()=>{this.setState({dataLoadProgress:90})},50)}catch{this.setState({isDataLoading:!1,dataLoadProgress:100})}},this.refreshChart=()=>{if(!(!this.state.displayData||this.state.displayData.length===0||!this.currentSeries||!this.currentSeries.series||!this.chart))try{const s=this.chart.timeScale(),n=s.getVisibleRange();this.state.isDataLoading&&this.setState({dataLoadProgress:85}),this.currentSeries.series.setData(this.state.displayData),n&&setTimeout(()=>{try{s.setVisibleRange(n),this.state.isDataLoading&&setTimeout(()=>{this.setState({dataLoadProgress:95})},50)}catch{this.state.isDataLoading&&this.setState({isDataLoading:!1,dataLoadProgress:100})}},10)}catch{this.state.isDataLoading&&this.setState({isDataLoading:!1,dataLoadProgress:100})}},this.handleExternalSelectedSubChartIndicator=s=>{this.setState(n=>{const o=n.selectedSubChartIndicators.includes(s);let l;return o?l=n.selectedSubChartIndicators.filter(h=>h!==s):l=[...n.selectedSubChartIndicators,s],{selectedSubChartIndicators:l}})},this.handleSelectedSubChartIndicator=s=>{this.setState({selectedSubChartIndicators:s,isSubChartModalOpen:!1})},this.handleRemoveSubChartIndicator=s=>{this.setState(n=>({selectedSubChartIndicators:n.selectedSubChartIndicators.filter(l=>l!==s)}))},this.handleCameraClick=()=>{const{handleScreenshotCapture:s}=this.props;s?Me(this,n=>{n.success&&n.dataUrl&&n.blob?s({dataUrl:n.dataUrl,blob:n.blob,width:n.width,height:n.height,timestamp:n.timestamp}):this.fallbackToDownload(n.dataUrl)}):Me(this)},this.fallbackToDownload=s=>{if(s){const n=document.createElement("a");n.download=`chart-screenshot-${new Date().getTime()}.png`,n.href=s,n.click()}else Me(this)},this.serializeDrawings=()=>this.chartLayerRef.current?this.chartLayerRef.current.serializeDrawings():"[]",this.handleSubChartClick=()=>{this.setState({isSubChartModalOpen:!this.state.isSubChartModalOpen})},this.deserializeDrawings=s=>{this.chartLayerRef.current&&this.chartLayerRef.current.deserializeDrawings(s)},this.clearAllDrawings=()=>{this.chartLayerRef.current&&this.chartLayerRef.current.clearAllDrawings()},this.viewportDataBufferSize=500,this.handleVisibleTimeRangeChange=s=>{if(!s)return;s.from>this.viewportDataBufferSize&&(s.from=s.from-this.viewportDataBufferSize);const n=this.props.isOpenViewportSegmentation?this.viewportManager?.getViewportDataPoints(s,this.preparedData)||[]:this.preparedData;this.setState({displayData:n})},this.handleEmojiSelect=s=>{this.setState({selectedEmoji:s})},this.handleThemeToggle=()=>{this.setState(s=>{const n=!s.isDarkTheme,o=n?"dark":"light";return{isDarkTheme:n,currentTheme:this.getThemeConfig(o)}},()=>{this.updateChartTheme()})},this.handleMobileMenuToggle=()=>{this.setState(s=>({isMobileMenuOpen:!s.isMobileMenuOpen}))},this.handleClickOutside=s=>{const n=s.target,o=this.state.isMobileMenuOpen&&!n.closest(".mobile-menu-button")&&!n.closest("[data-mobile-menu-modal]"),l=this.state.isTimeFormatModalOpen&&!n.closest(".time-format-button")&&!n.closest("[data-timeformat-modal]"),h=this.state.isCloseTimeModalOpen&&!n.closest(".close-time-button")&&!n.closest("[data-close-time-modal]"),d=this.state.isTradingDayModalOpen&&!n.closest(".trading-day-button")&&!n.closest("[data-trading-day-modal]"),g=this.state.isTimezoneModalOpen&&!n.closest(".timezone-button")&&!n.closest("[data-timezone-modal]"),c=this.state.isTimeframeModalOpen&&!n.closest(".timeframe-button")&&!n.closest("[data-timeframe-modal]"),u=this.state.isIndicatorModalOpen&&!n.closest(".indicator-button")&&!n.closest("[data-indicator-modal]"),p=this.state.isTradeModalOpen&&!n.closest(".trade-button")&&!n.closest("[data-trade-modal]"),M=this.state.isChartTypeModalOpen&&!n.closest(".chart-type-button")&&!n.closest("[data-chart-type-modal]"),k=this.state.isSubChartModalOpen&&!n.closest(".subchart-button")&&!n.closest("[data-subchart-modal]");this.state.isAIModalOpen&&!n.closest(".ai-button")&&!n.closest("[data-ai-modal]")&&this.setState({isAIModalOpen:!1}),o&&this.setState({isMobileMenuOpen:!1}),k&&this.setState({isSubChartModalOpen:!1}),c&&this.setState({isTimeframeModalOpen:!1}),u&&this.setState({isIndicatorModalOpen:!1}),p&&this.setState({isTradeModalOpen:!1}),M&&this.setState({isChartTypeModalOpen:!1}),g&&this.setState({isTimezoneModalOpen:!1}),l&&this.setState({isTimeFormatModalOpen:!1}),h&&this.setState({isCloseTimeModalOpen:!1}),d&&this.setState({isTradingDayModalOpen:!1})},this.handleToolSelect=s=>{this.setState({activeTool:s})},this.handleChartTypeSelect=s=>{this.setState({currentMainChartType:s,isChartTypeModalOpen:!1})},this.handleCloseChartTypeModal=()=>{this.setState({isChartTypeModalOpen:!1})},this.handleCloseDrawing=()=>{this.setState({activeTool:null})},this.handleTimeframeClick=()=>{this.setState({isTimeframeModalOpen:!this.state.isTimeframeModalOpen})},this.handleAIClick=()=>{this.setState({isAIModalOpen:!this.state.isAIModalOpen})},this.handleChartTypeClick=()=>{this.setState({isChartTypeModalOpen:!this.state.isChartTypeModalOpen})},this.handleIndicatorClick=()=>{this.setState({isIndicatorModalOpen:!this.state.isIndicatorModalOpen})},this.handleTradeClick=()=>{this.setState({isTradeModalOpen:!this.state.isTradeModalOpen})},this.handleSelectedMainChartIndicator=s=>{this.setState({selectedMainChartIndicator:s,isIndicatorModalOpen:!1})},this.handleMainChartIndicatorChange=s=>{this.setState({selectedMainChartIndicator:s})},this.handleCloseIndicatorModal=()=>{this.setState({isIndicatorModalOpen:!1})},this.handleCloseTimeframeModal=()=>{this.setState({isTimeframeModalOpen:!1})},this.handleCloseTradeModal=()=>{this.setState({isTradeModalOpen:!1})},this.handleTradeAction=s=>{this.setState({isTradeModalOpen:!1})},this.handleFullscreen=()=>{const s=this.chartContainerRef.current;s&&(document.fullscreenElement?document.exitFullscreen?.():s.requestFullscreen?.())},this.handleCompareClick=()=>{},this.handleReplayClick=()=>{},this.stopRealTimeDataSimulation=()=>{this.realTimeInterval&&(clearInterval(this.realTimeInterval),this.realTimeInterval=null)},this.handleContextMenu=s=>{s.preventDefault(),s.stopPropagation()},this.handleLeftArrowClick=()=>{this.chart&&this.viewportManager&&this.viewportManager.scrollChart("left")},this.handleRightArrowClick=()=>{this.chart&&this.viewportManager&&this.viewportManager.scrollChart("right")},this.handleRefreshClick=()=>{this.setState({isDataLoading:!0,dataLoadProgress:0}),setTimeout(()=>{this.setState({dataLoadProgress:20}),this.refreshExternalData(()=>{this.setState({dataLoadProgress:50}),this.refreshInternalData(()=>{this.setState({dataLoadProgress:80}),this.refreshChart(),this.viewportManager?.positionChart(),this.setState({isDataLoading:!1,dataLoadProgress:100})})})},100)},this.handleZoomIn=()=>{this.viewportManager&&this.viewportManager.zoomIn()},this.handleZoomOut=()=>{this.viewportManager&&this.viewportManager.zoomOut()},this.handleOpenScriptEditor=(s,n,o,l)=>{this.setState({isScriptEditorOpen:!0,currentScript:o||"",scriptName:s||"Untitled",openAiChat:!1,aiPanelWidthRatio:.7,currentScriptType:n,currentScriptMarkId:s})},this.handleCloseScriptEditor=()=>{this.setState({isScriptEditorOpen:!1,currentScript:"",aiPanelWidthRatio:1,currentAIFunctionType:null,currentAIBrandType:null})},this.handleSaveScript=async s=>{const{currentScriptType:n,currentScriptMarkId:o}=this.state;Kt.Time===n?this.chartLayerRef.current.setTimeEventScriptById(o,s):Kt.Price===n&&this.chartLayerRef.current.setPriceEventScriptById(o,s),this.handleCloseScriptEditor()},this.handleRunScript=async s=>Promise.resolve(),this.handleAIFunctionSelect=s=>{const n=this.aiManager?.aiToolIdToFunctionType(s);if(s==="script-editor"){this.setState({isScriptEditorOpen:!0,openAiChat:!1,currentAIFunctionType:null,currentAIBrandType:null,aiPanelWidthRatio:.7});return}if(n){this.setState({currentAIFunctionType:n,isScriptEditorOpen:!1},()=>{}),this.setState({openAiChat:this.aiManager?.isChartType(s)||!1},()=>{});const o=this.aiManager?.getAITypeFromFunctionType(n);o&&this.setState({currentAIBrandType:o},()=>{})}},this.handleTerminalCommand=s=>{this.setState({terminalCommand:s})},this.openTerminal=()=>{this.setState({terminal:!0})},this.closeTerminal=()=>{this.setState({terminal:!1})};const e=1,i=.3,r=.3,a=Go(t.timeframe)||E.FIFTEEN_MINUTES;this.state={isIndicatorModalOpen:!1,isTimeframeModalOpen:!1,isTradeModalOpen:!1,isChartTypeModalOpen:!1,isSubChartModalOpen:!1,isMobileMenuOpen:!1,isAIModalOpen:!1,activeTool:null,currentMainChartType:G.Candle,currentTheme:this.getThemeConfig(t.theme||"dark"),currentI18N:this.getI18nConfig(t.i18n||"zh-cn"),chartInitialized:!1,isDarkTheme:t.theme!=="light",selectedEmoji:"😀",selectedSubChartIndicators:[],selectedMainChartIndicator:null,subChartPanelHeight:200,isResizing:!1,showInfoLayer:!0,isTimezoneModalOpen:!1,currentTimezone:"Asia/Shanghai",isTimeFormatModalOpen:!1,isCloseTimeModalOpen:!1,isTradingDayModalOpen:!1,activeTimeframe:a,timeframe:a,timezone:$o(t.timezone)||W.SHANGHAI,savedVisibleRange:null,virtualDataBeforeCount:500,virtualDataAfterCount:500,displayData:[],isDataLoading:!1,dataLoadProgress:0,loadError:null,toppanel:t.toppanel||!1,leftpanel:t.leftpanel||!1,ai:t.ai||!1,aiconfigs:t.aiconfigs||[],openAiChat:!1,currentAIFunctionType:null,currentAIBrandType:null,aiPanelWidthRatio:e,isResizingAiPanel:!1,terminalCommand:"",terminal:this.props.terminal||!1,terminalHeightRatio:i,mobileAiPanelHeightRatio:r,isResizingTerminal:!1,markData:this.props.markData||[],isScriptEditorOpen:!1,currentScript:"",scriptName:"Untitled",currentScriptType:Kt.None,currentScriptMarkId:"",isIncrement:!1},this.chartEventManager=new Ni,this.aiManager=new ul}componentDidMount(){this.chart||(this.setState({isDataLoading:!0}),this.loadDataAsync(()=>{setTimeout(()=>{this.initializeChart(),this.props.mainChartIndicators&&this.props.mainChartIndicators.length>0&&setTimeout(()=>{this.initializeMainChartIndicators(this.props.mainChartIndicators||[])},100),this.props.subChartIndicators&&this.props.subChartIndicators.length>0&&setTimeout(()=>{this.initializeSubChartIndicators(this.props.subChartIndicators||[])},150)},50)}),document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("mouseup",this.handleMouseUp),document.addEventListener("mousemove",this.handleTerminalMouseMove),document.addEventListener("mouseup",this.handleTerminalMouseUp),document.addEventListener("mousemove",this.handleAiMobileMouseMove),document.addEventListener("mouseup",this.handleAiMobileMouseUp),document.addEventListener("touchstart",this.handleClickOutside,!0))}componentDidUpdate(t,e){if(Be.standardizedDPI(),t.theme!==this.props.theme){const r=this.props.theme||"dark";this.setState({currentTheme:this.getThemeConfig(r)}),this.handleThemeToggle()}if(t.data!==this.props.data){this.isIncrementalDataUpdate(t.data,this.props.data)&&this.chart&&this.currentSeries&&this.props.data?(this.setState({isIncrement:!0}),this.originalData=this.props.data,this.refreshInternalData(()=>{this.refreshChart()})):(this.clearStaticMarks(),this.setState({isDataLoading:!0,dataLoadProgress:0}),this.loadDataAsync(()=>{this.refreshChart()}));return}t.mainChartIndicators!==this.props.mainChartIndicators&&(this.props.mainChartIndicators?this.initializeMainChartIndicators(this.props.mainChartIndicators):(this.setState({selectedMainChartIndicator:null}),this.chartLayerRef.current&&Object.values(D).forEach(r=>{this.chartLayerRef.current?.handleRemoveIndicator&&this.chartLayerRef.current.handleRemoveIndicator(r)}))),t.subChartIndicators!==this.props.subChartIndicators&&(this.props.subChartIndicators?this.initializeSubChartIndicators(this.props.subChartIndicators):(this.setState({selectedSubChartIndicators:[]}),this.chartLayerRef.current&&this.state.selectedSubChartIndicators.forEach(r=>{this.chartLayerRef.current?.handleRemoveSubChartIndicator&&this.chartLayerRef.current.handleRemoveSubChartIndicator(r)}))),t.markData!==this.props.markData&&this.props.markData&&this.setState({markData:this.props.markData}),t.terminal!==this.props.terminal&&this.props.terminal&&this.setState({terminal:this.props.terminal}),e.openAiChat!==this.state.openAiChat&&this.setState({aiPanelWidthRatio:this.state.openAiChat?.7:1}),t.aiconfigs!==this.props.aiconfigs&&this.props.aiconfigs&&this.setState({aiconfigs:this.props.aiconfigs}),t.i18n!==this.props.i18n&&(this.setState({currentI18N:this.getI18nConfig(this.props.i18n||"en")}),this.updateChartI18n(this.props.i18n||"en"))}componentWillUnmount(){const t=this.viewportManager?.getVisibleTimeRange();if(t)try{localStorage.setItem("candleView_visibleRange",JSON.stringify(t))}catch{}this.updateTimeout&&clearTimeout(this.updateTimeout),this.resizeObserver&&this.chartContainerRef.current&&(this.resizeObserver.unobserve(this.chartContainerRef.current),this.resizeObserver.disconnect()),this.chart&&this.chart.remove(),this.realTimeInterval&&clearInterval(this.realTimeInterval),document.removeEventListener("mousedown",this.handleClickOutside,!0),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("mousemove",this.handleTerminalMouseMove),document.removeEventListener("mouseup",this.handleTerminalMouseUp),document.removeEventListener("mousemove",this.handleAiMobileMouseMove),document.removeEventListener("mouseup",this.handleAiMobileMouseUp)}clearStaticMarks(){this.chartLayerRef&&this.chartLayerRef.current&&this.chartLayerRef.current.staticMarkManager&&this.chartLayerRef.current.staticMarkManager.clearAllMarks&&this.chartLayerRef.current.staticMarkManager.clearAllMarks()}isIncrementalDataUpdate(t,e){if(!t||!e||t.length===0||e.length===0)return!1;if(e.length>t.length){const i=Math.min(t.length,10);for(let r=0;r<i;r++){const a=typeof t[r].time=="string"?new Date(t[r].time).getTime():t[r].time,s=typeof e[r].time=="string"?new Date(e[r].time).getTime():e[r].time;if(a!==s)return!1}return!0}if(t.length===e.length){const i=t[t.length-1],r=e[e.length-1],a=typeof i.time=="string"?new Date(i.time).getTime():i.time,s=typeof r.time=="string"?new Date(r.time).getTime():r.time;if(a===s)return!0;const n=t[0],o=e[0],l=typeof n.time=="string"?new Date(n.time).getTime():n.time,h=typeof o.time=="string"?new Date(o.time).getTime():o.time;return l===h}return!1}clearOriginalData(){this.originalData=[]}clearChart(t){this.currentSeries&&this.currentSeries.series&&this.currentSeries.series.setData([]),this.preparedData=[],this.setState({displayData:[]},()=>{t?.()})}initializeChart(){if(!this.chartRef.current||!this.chartContainerRef.current)return;const t=this.chartContainerRef.current,{currentTheme:e,chartInitialized:i}=this.state,r=t.clientWidth,a=t.clientHeight;if(!(r===0||a===0)&&!i)try{this.setState({dataLoadProgress:75}),this.chart&&(this.chart.remove(),this.currentSeries=null),this.chartManager=new qo(this.chartRef.current,r,a,e,this.props.i18n),this.chart=this.chartManager.getChart(),this.setState({dataLoadProgress:80}),this.viewportManager=new rl(this.chart,this.currentSeries),this.chartEventManager?.registerVisibleTimeRangeChangeEvent(this.chart,n=>{this.handleVisibleTimeRangeChange(n)}),this.currentSeries=Cr(this.chart,e),new wl({chartSeries:this.currentSeries,chart:this.chart}).addWatermark({src:vl,size:40,opacity:2,offsetX:20,offsetY:45}),this.state.displayData&&this.state.displayData.length>0&&(this.setState({dataLoadProgress:85}),this.refreshInternalData(()=>{this.initChart(),this.viewportManager?.positionChart(),this.setState({dataLoadProgress:90}),this.setupResizeObserver(),this.setState({chartInitialized:!0,dataLoadProgress:95}),setTimeout(()=>{this.setState({dataLoadProgress:100})},50)}))}catch{this.setState({chartInitialized:!1,dataLoadProgress:100})}}refreshExternalData(t){const e=this.props.data||[];this.originalData=e,t?.()}refreshInternalData(t){const e=ke.handleData(this.originalData,me({timeframe:this.state.timeframe,timezone:this.state.timezone},this.state.currentMainChartType,this.state.virtualDataBeforeCount,this.state.virtualDataAfterCount),this.state.currentMainChartType,this.props.isCloseInternalTimeFrameCalculation||!1);this.preparedData=e,this.setState({displayData:e},()=>{t?.()})}setupResizeObserver(){this.chartContainerRef.current&&(this.resizeObserver=new _r(t=>{for(const e of t)if(e.target===this.chartContainerRef.current&&this.chart){const{width:i,height:r}=e.contentRect,a=Math.max(i,100),s=Math.max(r,100);requestAnimationFrame(()=>{try{if(this.chart){const n=this.chart.timeScale(),o=n.getVisibleRange();this.chart.applyOptions({width:a,height:s}),o&&setTimeout(()=>{try{n.setVisibleRange(o)}catch{}},10)}}catch{}})}}),this.resizeObserver.observe(this.chartContainerRef.current))}updateChartI18n(t){this.chart&&this.chart.applyOptions({localization:{locale:t}})}updateChartTheme(){const{currentTheme:t}=this.state;if(this.chart)try{this.chart.applyOptions({layout:t.layout,grid:{vertLines:{color:t.grid.vertLines.color+"30",style:1,visible:!0},horzLines:{color:t.grid.horzLines.color+"30",style:1,visible:!0}}}),this.chart.applyOptions({timeScale:{borderColor:t.grid.vertLines.color},rightPriceScale:{borderColor:t.grid.horzLines.color}})}catch{}this.currentSeries&&Er(this.currentSeries,t)}getThemeConfig(t){return t==="light"?yr:Wi}getI18nConfig(t){return t==="en"?ot:zo}render(){const{currentTheme:t,isDataLoading:e,ai:i,openAiChat:r,terminal:a,terminalHeightRatio:s}=this.state,{height:n="100%",width:o="100%"}=this.props,l=i?this.state.aiPanelWidthRatio:1,h=i?1-this.state.aiPanelWidthRatio:0,d=`
|
|
391
|
+
`})]})};class Be{constructor(){Be.standardizedDPI()}static standardizedDPI(){Object.defineProperty(window,"devicePixelRatio",{get:()=>1,configurable:!0});const t=document.createElement.bind(document);document.createElement=function(r,a){const s=t(r,a);if(r.toLowerCase()==="canvas"){const n=()=>{if(s.parentElement){const l=s.getBoundingClientRect();if(l.width>0&&l.height>0){const h=s;(h.width!==l.width||h.height!==l.height)&&(h.width=l.width,h.height=l.height)}}};setTimeout(n,0);const o=new ResizeObserver(()=>{n()});setTimeout(()=>{s.parentElement&&o.observe(s)},100),s.addEventListener("DOMNodeRemoved",()=>{o.disconnect()})}return s};const e=()=>{document.querySelectorAll("canvas").forEach(r=>{const a=r.getBoundingClientRect();if(a.width>0&&a.height>0){const s=r;(s.width!==a.width||s.height!==a.height)&&(s.width=a.width,s.height=a.height)}})};setTimeout(e,0),setTimeout(e,100),setTimeout(e,300),new MutationObserver(r=>{let a=!1;r.forEach(s=>{s.addedNodes.forEach(n=>{n.nodeName==="CANVAS"&&(a=!0)})}),a&&setTimeout(e,50)}).observe(document.body,{childList:!0,subtree:!0}),window.addEventListener("resize",()=>{setTimeout(e,100)})}static forceFixCanvas(){document.querySelectorAll("canvas").forEach(t=>{const e=t.getBoundingClientRect();if(e.width>0&&e.height>0){const i=t;i.width=e.width,i.height=e.height}})}}class yl{constructor(t){this.danmakus=[],this.activeDanmakus=[],this.canvas=null,this.ctx=null,this.animationFrameId=null,this.lastUpdateTime=0,this.isPlaying=!1,this.containerWidth=0,this.containerHeight=0,this.danmakuPool=[],this.config={maxConcurrent:10,defaultStyle:{color:"#FFFFFF",fontSize:16,speed:60,opacity:.9,yPosition:.5},fontFamily:"Arial, sans-serif",lineHeight:1.2,autoStart:!0,...t}}initialize(t){this.canvas=t,this.ctx=t.getContext("2d"),this.ctx&&(this.ctx.textBaseline="middle"),this.updateCanvasSize(),this.config.autoStart&&this.start()}updateCanvasSize(){this.canvas&&(this.containerWidth=this.canvas.width,this.containerHeight=this.canvas.height)}setDanmakus(t){this.danmakus=[...t]}addDanmaku(t){this.danmakus.push(t)}addDanmakus(t){this.danmakus.push(...t)}start(){this.isPlaying||(this.isPlaying=!0,this.lastUpdateTime=performance.now(),this.animate())}stop(){this.isPlaying=!1,this.animationFrameId&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null)}clear(){this.danmakus=[],this.activeDanmakus=[],this.ctx&&this.canvas&&this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height)}getActiveCount(){return this.activeDanmakus.length}getPendingCount(){return this.danmakus.length}destroy(){this.stop(),this.clear(),this.canvas=null,this.ctx=null,this.danmakuPool=[]}getDanmakuItem(t){if(this.danmakuPool.length>0){const e=this.danmakuPool.pop();return e.text=t,e.isVisible=!0,e.startTime=performance.now(),e}return{id:`danmaku_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,text:t,x:0,y:0,width:0,style:this.getRandomStyle(),startTime:performance.now(),isVisible:!0}}recycleDanmakuItem(t){t.isVisible=!1,this.danmakuPool.push(t)}getRandomStyle(){const t=["#FFFFFF","#FF6B6B","#4ECDC4","#FFD166","#06D6A0","#118AB2","#EF476F","#073B4C","#7209B7","#F72585"],e=[14,16,18],i=[50,60,70,80];return{color:t[Math.floor(Math.random()*t.length)],fontSize:e[Math.floor(Math.random()*e.length)],speed:i[Math.floor(Math.random()*i.length)],opacity:.8+Math.random()*.2,yPosition:.1+Math.random()*.8}}measureTextWidth(t,e){if(!this.ctx)return 100;this.ctx.save(),this.ctx.font=`${e}px ${this.config.fontFamily}`;const i=this.ctx.measureText(t).width;return this.ctx.restore(),i}spawnDanmaku(){if(this.activeDanmakus.length>=this.config.maxConcurrent||this.danmakus.length===0)return;const t=this.danmakus.shift(),e=this.getDanmakuItem(t);e.width=this.measureTextWidth(t,e.style.fontSize),e.x=this.containerWidth,e.y=e.style.yPosition*this.containerHeight,this.activeDanmakus.push(e)}updateDanmakus(t){for(let e=this.activeDanmakus.length-1;e>=0;e--){const i=this.activeDanmakus[e];i.x-=i.style.speed*(t/1e3),i.x+i.width<0&&(this.recycleDanmakuItem(i),this.activeDanmakus.splice(e,1))}this.spawnDanmaku()}renderDanmakus(){!this.ctx||!this.canvas||(this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height),this.activeDanmakus.forEach(t=>{this.ctx.save(),this.ctx.font=`${t.style.fontSize}px ${this.config.fontFamily}`,this.ctx.fillStyle=t.style.color,this.ctx.globalAlpha=t.style.opacity,this.ctx.shadowColor="rgba(0, 0, 0, 0.5)",this.ctx.shadowBlur=2,this.ctx.shadowOffsetX=1,this.ctx.shadowOffsetY=1,this.ctx.fillText(t.text,t.x,t.y),this.ctx.restore()}))}animate(){if(!this.isPlaying)return;const t=performance.now(),e=t-this.lastUpdateTime;this.lastUpdateTime=t,this.updateDanmakus(e),this.renderDanmakus(),this.animationFrameId=requestAnimationFrame(()=>this.animate())}}class Zi extends y.Component{constructor(t){super(t),this.candleViewRef=y.createRef(),this.chartRef=y.createRef(),this.chartContainerRef=y.createRef(),this.chartLayerRef=y.createRef(),this.chart=null,this.resizeObserver=null,this.realTimeInterval=null,this.currentSeries=null,this.chartManager=null,this.updateTimeout=null,this.viewportManager=null,this.chartEventManager=null,this.aiPanelResizeRef=y.createRef(),this.isDragging=!1,this.startX=0,this.startChartWidth=0,this.containerWidth=0,this.terminalResizeRef=y.createRef(),this.isDraggingTerminal=!1,this.startY=0,this.startTerminalHeightRatio=0,this.aiMobilePanelResizeRef=y.createRef(),this.isDraggingAiMobilePanel=!1,this.startAiMobileY=0,this.startAiMobileHeightRatio=0,this.preparedData=[],this.originalData=[],this.aiManager=null,this.danmakuManager=null,this.danmakuCanvasRef=y.createRef(),this.danmakuContainerRef=y.createRef(),this.initializeDanmaku=s=>{if(!s||s.length===0)return;if(!this.danmakuContainerRef.current||!this.danmakuCanvasRef.current){setTimeout(()=>this.initializeDanmaku(s),100);return}this.clearDanmaku(),this.danmakuManager=new yl({maxConcurrent:8,defaultStyle:{color:"#FFFFFF",fontSize:14,speed:60,opacity:.85,yPosition:.5},fontFamily:"Arial, sans-serif",autoStart:!0});const n=this.danmakuCanvasRef.current,o=this.danmakuContainerRef.current;n&&o&&(n.width=o.clientWidth,n.height=o.clientHeight,this.danmakuManager.initialize(n),this.danmakuManager.setDanmakus([...s]),this.danmakuManager.start())},this.clearDanmaku=()=>{this.danmakuManager&&(this.danmakuManager.stop(),this.danmakuManager.clear(),this.danmakuManager=null)},this.handleDanmakuResize=()=>{if(this.danmakuCanvasRef.current&&this.danmakuContainerRef.current){const s=this.danmakuCanvasRef.current,n=this.danmakuContainerRef.current;s.width=n.clientWidth,s.height=n.clientHeight,this.danmakuManager&&this.danmakuManager.updateCanvasSize()}},this.initializeMainChartIndicators=s=>{this.setState({selectedMainChartIndicator:null}),this.chartLayerRef.current&&Object.values(D).forEach(n=>{this.chartLayerRef.current?.handleRemoveIndicator&&this.chartLayerRef.current.handleRemoveIndicator(n)}),s.forEach(n=>{const o=n.toUpperCase();if(Object.values(D).includes(o)){let l=null;switch(o){case D.MA:l={...we,nonce:Date.now()};break;case D.EMA:l={...ve,nonce:Date.now()};break;case D.BOLLINGER:l={...xe,nonce:Date.now()};break;case D.ICHIMOKU:l={...Ae,nonce:Date.now()};break;case D.DONCHIAN:l={...De,nonce:Date.now()};break;case D.ENVELOPE:l={...Fe,nonce:Date.now()};break;case D.VWAP:l={...Ee,nonce:Date.now()};break;case D.HEATMAP:l={...ye,nonce:Date.now()};break;case D.MARKETPROFILE:l={...Re,nonce:Date.now()};break}l&&(this.setState({selectedMainChartIndicator:l}),this.chart&&this.currentSeries&&this.chartLayerRef.current&&this.chartLayerRef.current.handleMainChartIndicatorChange&&this.chartLayerRef.current.handleMainChartIndicatorChange(l))}})},this.initializeSubChartIndicators=s=>{this.setState({selectedSubChartIndicators:[]}),this.chartLayerRef.current&&this.state.selectedSubChartIndicators.forEach(o=>{this.chartLayerRef.current?.handleRemoveSubChartIndicator&&this.chartLayerRef.current.handleRemoveSubChartIndicator(o)});const n=[];s.forEach(o=>{const l=o.toUpperCase();Object.values(X).includes(l)&&(n.push(l),this.chartLayerRef.current&&this.handleExternalSelectedSubChartIndicator(l))}),this.setState({selectedSubChartIndicators:n})},this.handleAiMobileMouseMove=s=>{if(!this.isDraggingAiMobilePanel)return;const n=this.candleViewRef.current;if(!n)return;const o=n.clientHeight;if(o<=0)return;const l=this.startAiMobileY-s.clientY,h=this.startAiMobileHeightRatio+l/o,d=Math.max(.1,Math.min(.7,h));this.setState({mobileAiPanelHeightRatio:d})},this.handleAiMobileMouseUp=()=>{this.isDraggingAiMobilePanel&&(this.isDraggingAiMobilePanel=!1,this.setState({isResizingAiPanel:!1}),document.body.style.cursor="",document.body.style.userSelect="")},this.handleTerminalResizeMouseDown=s=>{s.preventDefault(),this.isDraggingTerminal=!0,this.setState({isResizingTerminal:!0}),this.candleViewRef.current&&(this.startY=s.clientY,this.startTerminalHeightRatio=this.state.terminalHeightRatio),document.body.style.cursor="row-resize",document.body.style.userSelect="none"},this.handleTerminalMouseMove=s=>{if(!this.isDraggingTerminal)return;const n=this.candleViewRef.current;if(!n)return;const o=n.clientHeight;if(o<=0)return;const l=this.startY-s.clientY,h=this.startTerminalHeightRatio+l/o,d=Math.max(.2,Math.min(.5,h));this.setState({terminalHeightRatio:d})},this.handleTerminalMouseUp=()=>{this.isDraggingTerminal&&(this.isDraggingTerminal=!1,this.setState({isResizingTerminal:!1}),document.body.style.cursor="",document.body.style.userSelect="")},this.handleResizeMouseDown=s=>{s.preventDefault(),this.isDragging=!0,this.setState({isResizingAiPanel:!0}),this.aiPanelResizeRef.current&&(this.aiPanelResizeRef.current.style.backgroundColor=this.state.currentTheme.divider.dragging);const n=this.candleViewRef.current;n&&(this.containerWidth=n.clientWidth,this.startX=s.clientX,this.startChartWidth=this.state.aiPanelWidthRatio),document.body.style.cursor="col-resize",document.body.style.userSelect="none"},this.handleMouseMove=s=>{if(!this.isDragging||!this.containerWidth)return;const n=s.clientX-this.startX;if(!this.state.ai)return;const o=Math.max(.3,Math.min(.9,this.startChartWidth+n/this.containerWidth));this.setState({aiPanelWidthRatio:o},()=>{if(this.chart){const l=this.chartContainerRef.current;if(l){const h=l.clientWidth,d=l.clientHeight;h>0&&d>0&&this.chart.applyOptions({width:h,height:d})}}})},this.handleMouseUp=()=>{this.isDragging&&(this.isDragging=!1,this.setState({isResizingAiPanel:!1}),this.aiPanelResizeRef.current&&(this.aiPanelResizeRef.current.style.backgroundColor=this.state.currentTheme.divider.normal),document.body.style.cursor="",document.body.style.userSelect="")},this.loadDataAsync=s=>{this.setState({dataLoadProgress:0,isDataLoading:!0}),this.loadExternalData().then(()=>(this.setState({dataLoadProgress:30}),this.loadInternalData())).then(()=>{this.setState({dataLoadProgress:70}),this.setState({dataLoadProgress:100,isDataLoading:!1,loadError:null},()=>{s&&s()})}).catch(n=>{this.setState({isDataLoading:!1,loadError:n.message})})},this.loadExternalData=async()=>(this.clearOriginalData(),new Promise((s,n)=>{try{this.setState({dataLoadProgress:10});const o=this.props.data||[];this.originalData=o,this.setState({dataLoadProgress:30}),s()}catch(o){n(o)}})),this.loadInternalData=async()=>new Promise(s=>{this.setState({dataLoadProgress:40}),this.clearChart(()=>{const n=ke.handleData(this.originalData,me({timeframe:this.state.timeframe,timezone:this.state.timezone},this.state.currentMainChartType,this.state.virtualDataBeforeCount,this.state.virtualDataAfterCount),this.state.currentMainChartType,this.props.isCloseInternalTimeFrameCalculation||!1);this.setState({dataLoadProgress:50}),setTimeout(()=>{this.preparedData=n,this.setState({dataLoadProgress:60}),this.setState({displayData:n,dataLoadProgress:70},()=>{s()})},50)})}),this.handleTimeFormatClick=()=>{this.setState({isTimeFormatModalOpen:!0})},this.handleCloseTimeClick=()=>{this.setState({isCloseTimeModalOpen:!0})},this.handleTradingDayClick=()=>{this.setState({isTradingDayModalOpen:!0})},this.handleTimezoneClick=()=>{this.setState({isTimezoneModalOpen:!0})},this.handleCloseModals=()=>{this.setState({isTimeframeModalOpen:!1,isIndicatorModalOpen:!1,isChartTypeModalOpen:!1,isSubChartModalOpen:!1,isTimezoneModalOpen:!1,isTimeFormatModalOpen:!1,isCloseTimeModalOpen:!1,isTradingDayModalOpen:!1,isMobileMenuOpen:!1,isAIModalOpen:!1})},this.handleTimezoneSelect=s=>{this.clearChart(),this.setState({currentTimezone:s,timezone:s,isTimezoneModalOpen:!1,isDataLoading:!0,dataLoadProgress:0},()=>{setTimeout(()=>{this.setState({dataLoadProgress:20}),this.loadInternalDataAsync(()=>{this.setState({dataLoadProgress:70}),this.initChart(),this.viewportManager?.positionChart(),setTimeout(()=>{this.setState({isDataLoading:!1,dataLoadProgress:100})},50)})},50)})},this.handleTimeframeSelect=s=>{if(this.clearChart(),this.props.isCloseInternalTimeFrameCalculation){const n=s;this.setState({activeTimeframe:n,timeframe:n},()=>{if(this.props.timeframeCallbacks){const o=this.props.timeframeCallbacks[n];o&&o()}})}else{const n=s;this.setState({activeTimeframe:n,timeframe:n,isTimeframeModalOpen:!1,isDataLoading:!0,dataLoadProgress:0},()=>{setTimeout(()=>{this.setState({dataLoadProgress:10}),this.loadInternalDataAsync(()=>{this.setState({dataLoadProgress:60}),this.initChart(),this.viewportManager?.positionChart(),setTimeout(()=>{this.setState({isDataLoading:!1,dataLoadProgress:100})},50)})},500)})}},this.loadInternalDataAsync=s=>new Promise(n=>{this.state.isDataLoading||this.setState({isDataLoading:!0}),this.setState({dataLoadProgress:10}),setTimeout(()=>{setTimeout(()=>{this.setState({dataLoadProgress:30});const h=ke.handleData(this.originalData,me({timeframe:this.state.timeframe,timezone:this.state.timezone},this.state.currentMainChartType,this.state.virtualDataBeforeCount,this.state.virtualDataAfterCount),this.state.currentMainChartType,this.props.isCloseInternalTimeFrameCalculation||!1);this.setState({dataLoadProgress:50}),setTimeout(()=>{this.preparedData=h,this.setState({displayData:h,dataLoadProgress:60},()=>{s&&s(),n()})},50)},0)},0)}),this.initChart=()=>{if(!(!this.currentSeries||!this.currentSeries.series))try{this.state.isDataLoading&&this.setState({dataLoadProgress:80}),this.currentSeries.series.setData(this.preparedData),this.state.isDataLoading&&setTimeout(()=>{this.setState({dataLoadProgress:90})},50)}catch{this.setState({isDataLoading:!1,dataLoadProgress:100})}},this.refreshChart=()=>{if(!(!this.state.displayData||this.state.displayData.length===0||!this.currentSeries||!this.currentSeries.series||!this.chart))try{const s=this.chart.timeScale(),n=s.getVisibleRange();this.state.isDataLoading&&this.setState({dataLoadProgress:85}),this.currentSeries.series.setData(this.state.displayData),n&&setTimeout(()=>{try{s.setVisibleRange(n),this.state.isDataLoading&&setTimeout(()=>{this.setState({dataLoadProgress:95})},50)}catch{this.state.isDataLoading&&this.setState({isDataLoading:!1,dataLoadProgress:100})}},10)}catch{this.state.isDataLoading&&this.setState({isDataLoading:!1,dataLoadProgress:100})}},this.handleExternalSelectedSubChartIndicator=s=>{this.setState(n=>{const o=n.selectedSubChartIndicators.includes(s);let l;return o?l=n.selectedSubChartIndicators.filter(h=>h!==s):l=[...n.selectedSubChartIndicators,s],{selectedSubChartIndicators:l}})},this.handleSelectedSubChartIndicator=s=>{this.setState({selectedSubChartIndicators:s,isSubChartModalOpen:!1})},this.handleRemoveSubChartIndicator=s=>{this.setState(n=>({selectedSubChartIndicators:n.selectedSubChartIndicators.filter(l=>l!==s)}))},this.handleCameraClick=()=>{const{handleScreenshotCapture:s}=this.props;s?Me(this,n=>{n.success&&n.dataUrl&&n.blob?s({dataUrl:n.dataUrl,blob:n.blob,width:n.width,height:n.height,timestamp:n.timestamp}):this.fallbackToDownload(n.dataUrl)}):Me(this)},this.fallbackToDownload=s=>{if(s){const n=document.createElement("a");n.download=`chart-screenshot-${new Date().getTime()}.png`,n.href=s,n.click()}else Me(this)},this.serializeDrawings=()=>this.chartLayerRef.current?this.chartLayerRef.current.serializeDrawings():"[]",this.handleSubChartClick=()=>{this.setState({isSubChartModalOpen:!this.state.isSubChartModalOpen})},this.deserializeDrawings=s=>{this.chartLayerRef.current&&this.chartLayerRef.current.deserializeDrawings(s)},this.clearAllDrawings=()=>{this.chartLayerRef.current&&this.chartLayerRef.current.clearAllDrawings()},this.viewportDataBufferSize=500,this.handleVisibleTimeRangeChange=s=>{if(!s)return;s.from>this.viewportDataBufferSize&&(s.from=s.from-this.viewportDataBufferSize);const n=this.props.isOpenViewportSegmentation?this.viewportManager?.getViewportDataPoints(s,this.preparedData)||[]:this.preparedData;this.setState({displayData:n})},this.handleEmojiSelect=s=>{this.setState({selectedEmoji:s})},this.handleThemeToggle=()=>{this.setState(s=>{const n=!s.isDarkTheme,o=n?"dark":"light";return{isDarkTheme:n,currentTheme:this.getThemeConfig(o)}},()=>{this.updateChartTheme()})},this.handleMobileMenuToggle=()=>{this.setState(s=>({isMobileMenuOpen:!s.isMobileMenuOpen}))},this.handleClickOutside=s=>{const n=s.target,o=this.state.isMobileMenuOpen&&!n.closest(".mobile-menu-button")&&!n.closest("[data-mobile-menu-modal]"),l=this.state.isTimeFormatModalOpen&&!n.closest(".time-format-button")&&!n.closest("[data-timeformat-modal]"),h=this.state.isCloseTimeModalOpen&&!n.closest(".close-time-button")&&!n.closest("[data-close-time-modal]"),d=this.state.isTradingDayModalOpen&&!n.closest(".trading-day-button")&&!n.closest("[data-trading-day-modal]"),g=this.state.isTimezoneModalOpen&&!n.closest(".timezone-button")&&!n.closest("[data-timezone-modal]"),c=this.state.isTimeframeModalOpen&&!n.closest(".timeframe-button")&&!n.closest("[data-timeframe-modal]"),u=this.state.isIndicatorModalOpen&&!n.closest(".indicator-button")&&!n.closest("[data-indicator-modal]"),p=this.state.isTradeModalOpen&&!n.closest(".trade-button")&&!n.closest("[data-trade-modal]"),M=this.state.isChartTypeModalOpen&&!n.closest(".chart-type-button")&&!n.closest("[data-chart-type-modal]"),k=this.state.isSubChartModalOpen&&!n.closest(".subchart-button")&&!n.closest("[data-subchart-modal]");this.state.isAIModalOpen&&!n.closest(".ai-button")&&!n.closest("[data-ai-modal]")&&this.setState({isAIModalOpen:!1}),o&&this.setState({isMobileMenuOpen:!1}),k&&this.setState({isSubChartModalOpen:!1}),c&&this.setState({isTimeframeModalOpen:!1}),u&&this.setState({isIndicatorModalOpen:!1}),p&&this.setState({isTradeModalOpen:!1}),M&&this.setState({isChartTypeModalOpen:!1}),g&&this.setState({isTimezoneModalOpen:!1}),l&&this.setState({isTimeFormatModalOpen:!1}),h&&this.setState({isCloseTimeModalOpen:!1}),d&&this.setState({isTradingDayModalOpen:!1})},this.handleToolSelect=s=>{this.setState({activeTool:s})},this.handleChartTypeSelect=s=>{this.setState({currentMainChartType:s,isChartTypeModalOpen:!1})},this.handleCloseChartTypeModal=()=>{this.setState({isChartTypeModalOpen:!1})},this.handleCloseDrawing=()=>{this.setState({activeTool:null})},this.handleTimeframeClick=()=>{this.setState({isTimeframeModalOpen:!this.state.isTimeframeModalOpen})},this.handleAIClick=()=>{this.setState({isAIModalOpen:!this.state.isAIModalOpen})},this.handleChartTypeClick=()=>{this.setState({isChartTypeModalOpen:!this.state.isChartTypeModalOpen})},this.handleIndicatorClick=()=>{this.setState({isIndicatorModalOpen:!this.state.isIndicatorModalOpen})},this.handleTradeClick=()=>{this.setState({isTradeModalOpen:!this.state.isTradeModalOpen})},this.handleSelectedMainChartIndicator=s=>{this.setState({selectedMainChartIndicator:s,isIndicatorModalOpen:!1})},this.handleMainChartIndicatorChange=s=>{this.setState({selectedMainChartIndicator:s})},this.handleCloseIndicatorModal=()=>{this.setState({isIndicatorModalOpen:!1})},this.handleCloseTimeframeModal=()=>{this.setState({isTimeframeModalOpen:!1})},this.handleCloseTradeModal=()=>{this.setState({isTradeModalOpen:!1})},this.handleTradeAction=s=>{this.setState({isTradeModalOpen:!1})},this.handleFullscreen=()=>{const s=this.chartContainerRef.current;s&&(document.fullscreenElement?document.exitFullscreen?.():s.requestFullscreen?.())},this.handleCompareClick=()=>{},this.handleReplayClick=()=>{},this.stopRealTimeDataSimulation=()=>{this.realTimeInterval&&(clearInterval(this.realTimeInterval),this.realTimeInterval=null)},this.handleContextMenu=s=>{s.preventDefault(),s.stopPropagation()},this.handleLeftArrowClick=()=>{this.chart&&this.viewportManager&&this.viewportManager.scrollChart("left")},this.handleRightArrowClick=()=>{this.chart&&this.viewportManager&&this.viewportManager.scrollChart("right")},this.handleRefreshClick=()=>{this.setState({isDataLoading:!0,dataLoadProgress:0}),setTimeout(()=>{this.setState({dataLoadProgress:20}),this.refreshExternalData(()=>{this.setState({dataLoadProgress:50}),this.refreshInternalData(()=>{this.setState({dataLoadProgress:80}),this.refreshChart(),this.viewportManager?.positionChart(),this.setState({isDataLoading:!1,dataLoadProgress:100})})})},100)},this.handleZoomIn=()=>{this.viewportManager&&this.viewportManager.zoomIn()},this.handleZoomOut=()=>{this.viewportManager&&this.viewportManager.zoomOut()},this.handleOpenScriptEditor=(s,n,o,l)=>{this.setState({isScriptEditorOpen:!0,currentScript:o||"",scriptName:s||"Untitled",openAiChat:!1,aiPanelWidthRatio:.7,currentScriptType:n,currentScriptMarkId:s})},this.handleCloseScriptEditor=()=>{this.setState({isScriptEditorOpen:!1,currentScript:"",aiPanelWidthRatio:1,currentAIFunctionType:null,currentAIBrandType:null})},this.handleSaveScript=async s=>{const{currentScriptType:n,currentScriptMarkId:o}=this.state;Kt.Time===n?this.chartLayerRef.current.setTimeEventScriptById(o,s):Kt.Price===n&&this.chartLayerRef.current.setPriceEventScriptById(o,s),this.handleCloseScriptEditor()},this.handleRunScript=async s=>Promise.resolve(),this.handleAIFunctionSelect=s=>{const n=this.aiManager?.aiToolIdToFunctionType(s);if(s==="script-editor"){this.setState({isScriptEditorOpen:!0,openAiChat:!1,currentAIFunctionType:null,currentAIBrandType:null,aiPanelWidthRatio:.7});return}if(n){this.setState({currentAIFunctionType:n,isScriptEditorOpen:!1},()=>{}),this.setState({openAiChat:this.aiManager?.isChartType(s)||!1},()=>{});const o=this.aiManager?.getAITypeFromFunctionType(n);o&&this.setState({currentAIBrandType:o},()=>{})}},this.handleTerminalCommand=s=>{this.setState({terminalCommand:s})},this.openTerminal=()=>{this.setState({terminal:!0})},this.closeTerminal=()=>{this.setState({terminal:!1})};const e=1,i=.3,r=.3,a=Go(t.timeframe)||E.FIFTEEN_MINUTES;this.state={isIndicatorModalOpen:!1,isTimeframeModalOpen:!1,isTradeModalOpen:!1,isChartTypeModalOpen:!1,isSubChartModalOpen:!1,isMobileMenuOpen:!1,isAIModalOpen:!1,activeTool:null,currentMainChartType:G.Candle,currentTheme:this.getThemeConfig(t.theme||"dark"),currentI18N:this.getI18nConfig(t.i18n||"zh-cn"),chartInitialized:!1,isDarkTheme:t.theme!=="light",selectedEmoji:"😀",selectedSubChartIndicators:[],selectedMainChartIndicator:null,subChartPanelHeight:200,isResizing:!1,showInfoLayer:!0,isTimezoneModalOpen:!1,currentTimezone:"Asia/Shanghai",isTimeFormatModalOpen:!1,isCloseTimeModalOpen:!1,isTradingDayModalOpen:!1,activeTimeframe:a,timeframe:a,timezone:$o(t.timezone)||W.SHANGHAI,savedVisibleRange:null,virtualDataBeforeCount:500,virtualDataAfterCount:500,displayData:[],isDataLoading:!1,dataLoadProgress:0,loadError:null,toppanel:t.toppanel||!1,leftpanel:t.leftpanel||!1,ai:t.ai||!1,aiconfigs:t.aiconfigs||[],openAiChat:!1,currentAIFunctionType:null,currentAIBrandType:null,aiPanelWidthRatio:e,isResizingAiPanel:!1,terminalCommand:"",terminal:this.props.terminal||!1,terminalHeightRatio:i,mobileAiPanelHeightRatio:r,isResizingTerminal:!1,markData:this.props.markData||[],isScriptEditorOpen:!1,currentScript:"",scriptName:"Untitled",currentScriptType:Kt.None,currentScriptMarkId:"",isIncrement:!1},this.chartEventManager=new Ni,this.aiManager=new ul}componentDidMount(){if(this.chart)return;const{danmakus:t}=this.props;this.setState({isDataLoading:!0}),this.loadDataAsync(()=>{setTimeout(()=>{this.initializeChart(),this.props.mainChartIndicators&&this.props.mainChartIndicators.length>0&&setTimeout(()=>{this.initializeMainChartIndicators(this.props.mainChartIndicators||[])},100),this.props.subChartIndicators&&this.props.subChartIndicators.length>0&&setTimeout(()=>{this.initializeSubChartIndicators(this.props.subChartIndicators||[])},150)},50)}),t&&this.initializeDanmaku(t),document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("mouseup",this.handleMouseUp),document.addEventListener("mousemove",this.handleTerminalMouseMove),document.addEventListener("mouseup",this.handleTerminalMouseUp),document.addEventListener("mousemove",this.handleAiMobileMouseMove),document.addEventListener("mouseup",this.handleAiMobileMouseUp),document.addEventListener("touchstart",this.handleClickOutside,!0)}componentDidUpdate(t,e){if(Be.standardizedDPI(),t.theme!==this.props.theme){const r=this.props.theme||"dark";this.setState({currentTheme:this.getThemeConfig(r)}),this.handleThemeToggle()}if(t.data!==this.props.data){this.isIncrementalDataUpdate(t.data,this.props.data)&&this.chart&&this.currentSeries&&this.props.data?(this.setState({isIncrement:!0}),this.originalData=this.props.data,this.refreshInternalData(()=>{this.refreshChart()})):(this.clearStaticMarks(),this.setState({isDataLoading:!0,dataLoadProgress:0}),this.loadDataAsync(()=>{this.refreshChart()}));return}t.danmakus!==this.props.danmakus&&(this.props.danmakus?this.initializeDanmaku(this.props.danmakus):this.clearDanmaku()),t.mainChartIndicators!==this.props.mainChartIndicators&&(this.props.mainChartIndicators?this.initializeMainChartIndicators(this.props.mainChartIndicators):(this.setState({selectedMainChartIndicator:null}),this.chartLayerRef.current&&Object.values(D).forEach(r=>{this.chartLayerRef.current?.handleRemoveIndicator&&this.chartLayerRef.current.handleRemoveIndicator(r)}))),t.subChartIndicators!==this.props.subChartIndicators&&(this.props.subChartIndicators?this.initializeSubChartIndicators(this.props.subChartIndicators):(this.setState({selectedSubChartIndicators:[]}),this.chartLayerRef.current&&this.state.selectedSubChartIndicators.forEach(r=>{this.chartLayerRef.current?.handleRemoveSubChartIndicator&&this.chartLayerRef.current.handleRemoveSubChartIndicator(r)}))),t.markData!==this.props.markData&&this.props.markData&&this.setState({markData:this.props.markData}),t.terminal!==this.props.terminal&&this.props.terminal&&this.setState({terminal:this.props.terminal}),e.openAiChat!==this.state.openAiChat&&this.setState({aiPanelWidthRatio:this.state.openAiChat?.7:1}),t.aiconfigs!==this.props.aiconfigs&&this.props.aiconfigs&&this.setState({aiconfigs:this.props.aiconfigs}),t.i18n!==this.props.i18n&&(this.setState({currentI18N:this.getI18nConfig(this.props.i18n||"en")}),this.updateChartI18n(this.props.i18n||"en"))}componentWillUnmount(){const t=this.viewportManager?.getVisibleTimeRange();if(t)try{localStorage.setItem("candleView_visibleRange",JSON.stringify(t))}catch{}this.updateTimeout&&clearTimeout(this.updateTimeout),this.resizeObserver&&this.chartContainerRef.current&&(this.resizeObserver.unobserve(this.chartContainerRef.current),this.resizeObserver.disconnect()),this.chart&&this.chart.remove(),this.realTimeInterval&&clearInterval(this.realTimeInterval),this.clearDanmaku(),document.removeEventListener("mousedown",this.handleClickOutside,!0),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("mousemove",this.handleTerminalMouseMove),document.removeEventListener("mouseup",this.handleTerminalMouseUp),document.removeEventListener("mousemove",this.handleAiMobileMouseMove),document.removeEventListener("mouseup",this.handleAiMobileMouseUp)}clearStaticMarks(){this.chartLayerRef&&this.chartLayerRef.current&&this.chartLayerRef.current.staticMarkManager&&this.chartLayerRef.current.staticMarkManager.clearAllMarks&&this.chartLayerRef.current.staticMarkManager.clearAllMarks()}isIncrementalDataUpdate(t,e){if(!t||!e||t.length===0||e.length===0)return!1;if(e.length>t.length){const i=Math.min(t.length,10);for(let r=0;r<i;r++){const a=typeof t[r].time=="string"?new Date(t[r].time).getTime():t[r].time,s=typeof e[r].time=="string"?new Date(e[r].time).getTime():e[r].time;if(a!==s)return!1}return!0}if(t.length===e.length){const i=t[t.length-1],r=e[e.length-1],a=typeof i.time=="string"?new Date(i.time).getTime():i.time,s=typeof r.time=="string"?new Date(r.time).getTime():r.time;if(a===s)return!0;const n=t[0],o=e[0],l=typeof n.time=="string"?new Date(n.time).getTime():n.time,h=typeof o.time=="string"?new Date(o.time).getTime():o.time;return l===h}return!1}clearOriginalData(){this.originalData=[]}clearChart(t){this.currentSeries&&this.currentSeries.series&&this.currentSeries.series.setData([]),this.preparedData=[],this.setState({displayData:[]},()=>{t?.()})}initializeChart(){if(!this.chartRef.current||!this.chartContainerRef.current)return;const t=this.chartContainerRef.current,{currentTheme:e,chartInitialized:i}=this.state,r=t.clientWidth,a=t.clientHeight;if(!(r===0||a===0)&&!i)try{this.setState({dataLoadProgress:75}),this.chart&&(this.chart.remove(),this.currentSeries=null),this.chartManager=new qo(this.chartRef.current,r,a,e,this.props.i18n),this.chart=this.chartManager.getChart(),this.setState({dataLoadProgress:80}),this.viewportManager=new rl(this.chart,this.currentSeries),this.chartEventManager?.registerVisibleTimeRangeChangeEvent(this.chart,n=>{this.handleVisibleTimeRangeChange(n)}),this.currentSeries=Cr(this.chart,e),new wl({chartSeries:this.currentSeries,chart:this.chart}).addWatermark({src:vl,size:40,opacity:2,offsetX:20,offsetY:45}),this.state.displayData&&this.state.displayData.length>0&&(this.setState({dataLoadProgress:85}),this.refreshInternalData(()=>{this.initChart(),this.viewportManager?.positionChart(),this.setState({dataLoadProgress:90}),this.setupResizeObserver(),this.setState({chartInitialized:!0,dataLoadProgress:95}),setTimeout(()=>{this.setState({dataLoadProgress:100})},50)}))}catch{this.setState({chartInitialized:!1,dataLoadProgress:100})}}refreshExternalData(t){const e=this.props.data||[];this.originalData=e,t?.()}refreshInternalData(t){const e=ke.handleData(this.originalData,me({timeframe:this.state.timeframe,timezone:this.state.timezone},this.state.currentMainChartType,this.state.virtualDataBeforeCount,this.state.virtualDataAfterCount),this.state.currentMainChartType,this.props.isCloseInternalTimeFrameCalculation||!1);this.preparedData=e,this.setState({displayData:e},()=>{t?.()})}setupResizeObserver(){this.chartContainerRef.current&&(this.resizeObserver=new _r(t=>{for(const e of t)if(e.target===this.chartContainerRef.current&&this.chart){const{width:i,height:r}=e.contentRect,a=Math.max(i,100),s=Math.max(r,100);requestAnimationFrame(()=>{try{if(this.chart){const n=this.chart.timeScale(),o=n.getVisibleRange();this.chart.applyOptions({width:a,height:s}),o&&setTimeout(()=>{try{n.setVisibleRange(o)}catch{}},10)}}catch{}})}}),this.resizeObserver.observe(this.chartContainerRef.current))}updateChartI18n(t){this.chart&&this.chart.applyOptions({localization:{locale:t}})}updateChartTheme(){const{currentTheme:t}=this.state;if(this.chart)try{this.chart.applyOptions({layout:t.layout,grid:{vertLines:{color:t.grid.vertLines.color+"30",style:1,visible:!0},horzLines:{color:t.grid.horzLines.color+"30",style:1,visible:!0}}}),this.chart.applyOptions({timeScale:{borderColor:t.grid.vertLines.color},rightPriceScale:{borderColor:t.grid.horzLines.color}})}catch{}this.currentSeries&&Er(this.currentSeries,t)}getThemeConfig(t){return t==="light"?yr:Wi}getI18nConfig(t){return t==="en"?ot:zo}render(){const{currentTheme:t,isDataLoading:e,ai:i,openAiChat:r,terminal:a,terminalHeightRatio:s}=this.state,{height:n="100%",width:o="100%"}=this.props,l=i?this.state.aiPanelWidthRatio:1,h=i?1-this.state.aiPanelWidthRatio:0,d=`
|
|
392
392
|
.custom-scrollbar::-webkit-scrollbar {
|
|
393
393
|
width: 6px;
|
|
394
394
|
}
|
|
@@ -432,4 +432,4 @@ console.log("结果:", x);
|
|
|
432
432
|
0% { transform: rotate(0deg); }
|
|
433
433
|
100% { transform: rotate(360deg); }
|
|
434
434
|
}
|
|
435
|
-
`}),g&&m.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:2,background:"transparent"},onClick:this.handleCloseModals}),this.state.toppanel&&m.jsx(bl,{candleViewRef:this.candleViewRef,currentTheme:t,activeTimeframe:this.state.activeTimeframe,activeMainChartType:this.state.currentMainChartType,isDarkTheme:this.state.isDarkTheme,isTimeframeModalOpen:this.state.isTimeframeModalOpen,isIndicatorModalOpen:this.state.isIndicatorModalOpen,isChartTypeModalOpen:this.state.isChartTypeModalOpen,isSubChartModalOpen:this.state.isSubChartModalOpen,isTimezoneModalOpen:this.state.isTimezoneModalOpen,isAIModalOpen:this.state.isAIModalOpen,onThemeToggle:this.handleThemeToggle,onAIClick:this.handleAIClick,onTimeframeClick:this.handleTimeframeClick,onIndicatorClick:this.handleIndicatorClick,onChartTypeClick:this.handleChartTypeClick,onCompareClick:this.handleCompareClick,onFullscreenClick:this.handleFullscreen,onReplayClick:this.handleReplayClick,onTimezoneClick:this.handleTimezoneClick,onTimeframeSelect:this.handleTimeframeSelect,onChartTypeSelect:this.handleChartTypeSelect,onTimezoneSelect:this.handleTimezoneSelect,handleSelectedSubChartIndicator:this.handleSelectedSubChartIndicator,handleSelectedMainChartIndicator:this.handleSelectedMainChartIndicator,onCloseModals:this.handleCloseModals,onSubChartClick:this.handleSubChartClick,selectedSubChartIndicators:this.state.selectedSubChartIndicators,onCameraClick:this.handleCameraClick,i18n:this.state.currentI18N,currentTimezone:this.state.currentTimezone,isTimeFormatModalOpen:this.state.isTimeFormatModalOpen,isCloseTimeModalOpen:this.state.isCloseTimeModalOpen,isTradingDayModalOpen:this.state.isTradingDayModalOpen,onTimeFormatClick:this.handleTimeFormatClick,onCloseTimeClick:this.handleCloseTimeClick,onTradingDayClick:this.handleTradingDayClick,isMobileMenuOpen:this.state.isMobileMenuOpen,onMobileMenuToggle:this.handleMobileMenuToggle,timeframe:this.state.timeframe,timezone:this.state.timezone,isCloseInternalTimeFrameCalculation:this.props.isCloseInternalTimeFrameCalculation||!1,timeframeCallbacks:this.props.timeframeCallbacks||{},isMobileMode:this.props.isMobileMode||!1,candleView:this,ai:this.state.ai,aiconfigs:this.state.aiconfigs,handleAIFunctionSelect:this.handleAIFunctionSelect}),m.jsxs("div",{style:{display:"flex",flex:this.props.isMobileMode&&r?`calc(100% - ${this.state.mobileAiPanelHeightRatio*100}% - ${a&&!r?s*100:0}%)`:a&&!(this.props.isMobileMode&&r)?`calc(100% - ${s*100}%)`:"100%",minHeight:0,position:"relative"},children:[this.state.leftpanel&&!this.props.isMobileMode&&m.jsx(kl,{currentTheme:t,activeTool:this.state.activeTool,onToolSelect:this.handleToolSelect,onTradeClick:this.handleTradeClick,chartLayerRef:this.chartLayerRef,selectedEmoji:this.state.selectedEmoji,onEmojiSelect:this.handleEmojiSelect,i18n:this.state.currentI18N,candleViewRef:this.candleViewRef,ai:this.state.ai,aiconfigs:this.state.aiconfigs,handleAIFunctionSelect:this.handleAIFunctionSelect,candleView:this,isMobileMode:this.props.isMobileMode||!1}),m.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"row",minWidth:0,minHeight:0,position:"relative"},children:[m.jsx("div",{style:{flex:this.props.isMobileMode?1:l,display:"flex",flexDirection:"column",minWidth:0,minHeight:0,position:"relative"},children:m.jsxs("div",{ref:this.chartContainerRef,style:{flex:1,position:"relative",minHeight:"100px"},children:[m.jsx("div",{ref:this.chartRef,style:{width:"100%",height:"100%"}}),this.state.chartInitialized&&m.jsx(Vo,{candleView:this,ref:this.chartLayerRef,chart:this.chart,chartSeries:this.currentSeries,currentTheme:t,activeTool:this.state.activeTool,onCloseDrawing:this.handleCloseDrawing,onTextClick:this.handleToolSelect,onEmojiClick:this.handleToolSelect,selectedEmoji:this.state.selectedEmoji,chartData:this.state.displayData,title:this.props.title,selectedMainChartIndicator:this.state.selectedMainChartIndicator,selectedSubChartIndicators:this.state.selectedSubChartIndicators,showInfoLayer:this.state.showInfoLayer,i18n:this.state.currentI18N,markData:this.state.markData,onMainChartIndicatorChange:this.handleMainChartIndicatorChange,handleRemoveSubChartIndicator:this.handleRemoveSubChartIndicator,currentMainChartType:this.state.currentMainChartType,viewportManager:this.viewportManager,ai:this.state.ai,aiconfigs:this.state.aiconfigs,currentAIFunctionType:this.state.currentAIFunctionType,timeframe:this.state.timeframe,timezone:this.state.timezone,isIncrement:this.state.isIncrement}),m.jsxs("div",{style:{position:"absolute",bottom:"80px",left:"50%",transform:"translateX(-50%)",display:"flex",alignItems:"center",gap:"15px",zIndex:3,opacity:0,transition:"opacity 0.3s ease",pointerEvents:"auto"},onMouseEnter:p=>{p.currentTarget.style.opacity="1",p.stopPropagation()},onMouseLeave:p=>{p.currentTarget.style.opacity="0",p.stopPropagation()},children:[m.jsx("button",{onClick:this.handleZoomOut,style:{width:"25px",height:"25px",borderRadius:"6px",border:"none",background:t.toolbar.button.backgroundColor,display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",boxShadow:t.toolbar.button.boxShadow,pointerEvents:"auto"},onMouseDown:p=>p.stopPropagation(),children:m.jsx(yn,{size:14,color:t.toolbar.button.iconColor})}),m.jsx("button",{onClick:this.handleLeftArrowClick,style:{width:"25px",height:"25px",borderRadius:"6px",border:"none",background:t.toolbar.button.backgroundColor,display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",boxShadow:t.toolbar.button.boxShadow,pointerEvents:"auto"},onMouseDown:p=>p.stopPropagation(),children:m.jsx(An,{size:14,color:t.toolbar.button.iconColor})}),m.jsx("button",{onClick:this.handleRefreshClick,style:{width:"25px",height:"25px",borderRadius:"6px",border:"none",background:t.toolbar.button.backgroundColor,display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",boxShadow:t.toolbar.button.boxShadow,pointerEvents:"auto"},onMouseDown:p=>p.stopPropagation(),children:m.jsx(Fn,{size:16,color:t.toolbar.button.iconColor})}),m.jsx("button",{onClick:this.handleRightArrowClick,style:{width:"25px",height:"25px",borderRadius:"6px",border:"none",background:t.toolbar.button.backgroundColor,display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",boxShadow:t.toolbar.button.boxShadow,pointerEvents:"auto"},onMouseDown:p=>p.stopPropagation(),children:m.jsx(Dn,{size:14,color:t.toolbar.button.iconColor})}),m.jsx("button",{onClick:this.handleZoomIn,style:{width:"25px",height:"25px",borderRadius:"6px",border:"none",background:t.toolbar.button.backgroundColor,display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",boxShadow:t.toolbar.button.boxShadow,pointerEvents:"auto"},onMouseDown:p=>p.stopPropagation(),children:m.jsx(En,{size:14,color:t.toolbar.button.iconColor})})]})]})}),!this.props.isMobileMode&&(r||this.state.isScriptEditorOpen)&&m.jsxs(m.Fragment,{children:[m.jsx("div",{ref:this.aiPanelResizeRef,style:{width:"8px",cursor:"col-resize",backgroundColor:this.state.currentTheme.divider.normal,display:"flex",alignItems:"center",justifyContent:"center",position:"relative",transition:"background-color 0.2s"},onMouseDown:this.handleResizeMouseDown,onMouseEnter:()=>{this.isDragging||this.aiPanelResizeRef.current&&(this.aiPanelResizeRef.current.style.backgroundColor=this.state.currentTheme.divider.hover)},onMouseLeave:()=>{this.isDragging||this.aiPanelResizeRef.current&&(this.aiPanelResizeRef.current.style.backgroundColor=this.state.currentTheme.divider.normal)},children:m.jsx("div",{style:{width:"2px",height:"40px",backgroundColor:this.state.currentTheme.toolbar.button.color+"60",borderRadius:"1px"}})}),m.jsxs("div",{style:{flex:h,minWidth:"200px",display:"flex",flexDirection:"column",backgroundColor:t.layout.background.color,borderLeft:`1px solid ${t.toolbar.border}30`,overflow:"hidden"},children:[r&&m.jsx(Dl,{currentTheme:t,i18n:this.state.currentI18N,currentAIFunctionType:this.state.currentAIFunctionType,aiconfigs:this.state.aiconfigs,currentAIBrandType:this.state.currentAIBrandType,onClose:()=>{this.setState({openAiChat:!1,currentAIFunctionType:null,currentAIBrandType:null,aiPanelWidthRatio:1})},onSendMessage:async p=>new Promise(M=>{setTimeout(()=>{M()},1e3)}),data:this.originalData}),this.state.isScriptEditorOpen&&m.jsx(El,{currentTheme:t,i18n:this.state.currentI18N,initialScript:this.state.currentScript,scriptName:this.state.scriptName,onClose:this.handleCloseScriptEditor,onSave:this.handleSaveScript,onRun:this.handleRunScript,isLoading:!1})]})]})]})]}),a&&!this.props.isMobileMode&&m.jsxs(m.Fragment,{children:[m.jsx("div",{ref:this.terminalResizeRef,style:{height:"8px",cursor:"row-resize",backgroundColor:this.state.isResizingTerminal?t.divider.dragging:t.divider.normal,display:"flex",alignItems:"center",justifyContent:"center",position:"relative",transition:"background-color 0.2s"},onMouseDown:this.handleTerminalResizeMouseDown,onMouseEnter:()=>{this.isDraggingTerminal||this.terminalResizeRef.current&&(this.terminalResizeRef.current.style.backgroundColor=t.divider.hover)},onMouseLeave:()=>{this.isDraggingTerminal||this.terminalResizeRef.current&&(this.terminalResizeRef.current.style.backgroundColor=t.divider.normal)},children:m.jsx("div",{style:{width:"40px",height:"2px",backgroundColor:t.toolbar.button.color+"60",borderRadius:"1px"}})}),m.jsx("div",{style:{flex:a?`${s*100}%`:"0",minHeight:"100px",display:"flex",flexDirection:"column",backgroundColor:t.layout.background.color,borderTop:`1px solid ${t.toolbar.border}30`,overflow:"hidden"},children:m.jsx(fl,{currentTheme:t,i18n:this.state.currentI18N,placeholder:this.state.currentI18N===ot?"Enter command (e.g., 'help', 'clear', 'theme light')...":"输入命令 (例如: 'help', 'clear', 'theme light')...",onCommand:this.handleTerminalCommand,autoFocus:!1,candleView:this,chartLayerRef:this.chartLayerRef})})]})]})}}exports.CandleView=Zi;exports.default=Zi;
|
|
435
|
+
`}),g&&m.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:2,background:"transparent"},onClick:this.handleCloseModals}),this.state.toppanel&&m.jsx(bl,{candleViewRef:this.candleViewRef,currentTheme:t,activeTimeframe:this.state.activeTimeframe,activeMainChartType:this.state.currentMainChartType,isDarkTheme:this.state.isDarkTheme,isTimeframeModalOpen:this.state.isTimeframeModalOpen,isIndicatorModalOpen:this.state.isIndicatorModalOpen,isChartTypeModalOpen:this.state.isChartTypeModalOpen,isSubChartModalOpen:this.state.isSubChartModalOpen,isTimezoneModalOpen:this.state.isTimezoneModalOpen,isAIModalOpen:this.state.isAIModalOpen,onThemeToggle:this.handleThemeToggle,onAIClick:this.handleAIClick,onTimeframeClick:this.handleTimeframeClick,onIndicatorClick:this.handleIndicatorClick,onChartTypeClick:this.handleChartTypeClick,onCompareClick:this.handleCompareClick,onFullscreenClick:this.handleFullscreen,onReplayClick:this.handleReplayClick,onTimezoneClick:this.handleTimezoneClick,onTimeframeSelect:this.handleTimeframeSelect,onChartTypeSelect:this.handleChartTypeSelect,onTimezoneSelect:this.handleTimezoneSelect,handleSelectedSubChartIndicator:this.handleSelectedSubChartIndicator,handleSelectedMainChartIndicator:this.handleSelectedMainChartIndicator,onCloseModals:this.handleCloseModals,onSubChartClick:this.handleSubChartClick,selectedSubChartIndicators:this.state.selectedSubChartIndicators,onCameraClick:this.handleCameraClick,i18n:this.state.currentI18N,currentTimezone:this.state.currentTimezone,isTimeFormatModalOpen:this.state.isTimeFormatModalOpen,isCloseTimeModalOpen:this.state.isCloseTimeModalOpen,isTradingDayModalOpen:this.state.isTradingDayModalOpen,onTimeFormatClick:this.handleTimeFormatClick,onCloseTimeClick:this.handleCloseTimeClick,onTradingDayClick:this.handleTradingDayClick,isMobileMenuOpen:this.state.isMobileMenuOpen,onMobileMenuToggle:this.handleMobileMenuToggle,timeframe:this.state.timeframe,timezone:this.state.timezone,isCloseInternalTimeFrameCalculation:this.props.isCloseInternalTimeFrameCalculation||!1,timeframeCallbacks:this.props.timeframeCallbacks||{},isMobileMode:this.props.isMobileMode||!1,candleView:this,ai:this.state.ai,aiconfigs:this.state.aiconfigs,handleAIFunctionSelect:this.handleAIFunctionSelect}),m.jsxs("div",{style:{display:"flex",flex:this.props.isMobileMode&&r?`calc(100% - ${this.state.mobileAiPanelHeightRatio*100}% - ${a&&!r?s*100:0}%)`:a&&!(this.props.isMobileMode&&r)?`calc(100% - ${s*100}%)`:"100%",minHeight:0,position:"relative"},children:[this.state.leftpanel&&!this.props.isMobileMode&&m.jsx(kl,{currentTheme:t,activeTool:this.state.activeTool,onToolSelect:this.handleToolSelect,onTradeClick:this.handleTradeClick,chartLayerRef:this.chartLayerRef,selectedEmoji:this.state.selectedEmoji,onEmojiSelect:this.handleEmojiSelect,i18n:this.state.currentI18N,candleViewRef:this.candleViewRef,ai:this.state.ai,aiconfigs:this.state.aiconfigs,handleAIFunctionSelect:this.handleAIFunctionSelect,candleView:this,isMobileMode:this.props.isMobileMode||!1}),m.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"row",minWidth:0,minHeight:0,position:"relative"},children:[m.jsx("div",{style:{flex:this.props.isMobileMode?1:l,display:"flex",flexDirection:"column",minWidth:0,minHeight:0,position:"relative"},children:m.jsxs("div",{ref:this.chartContainerRef,style:{flex:1,position:"relative",minHeight:"100px"},children:[m.jsx("div",{ref:this.chartRef,style:{width:"100%",height:"100%"}}),m.jsx("div",{ref:this.danmakuContainerRef,style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:1,pointerEvents:"none",overflow:"hidden"},children:m.jsx("canvas",{ref:this.danmakuCanvasRef,style:{width:"100%",height:"100%",display:this.props.danmakus&&this.props.danmakus.length>0?"block":"none"}})}),this.state.chartInitialized&&m.jsx(Vo,{candleView:this,ref:this.chartLayerRef,chart:this.chart,chartSeries:this.currentSeries,currentTheme:t,activeTool:this.state.activeTool,onCloseDrawing:this.handleCloseDrawing,onTextClick:this.handleToolSelect,onEmojiClick:this.handleToolSelect,selectedEmoji:this.state.selectedEmoji,chartData:this.state.displayData,title:this.props.title,selectedMainChartIndicator:this.state.selectedMainChartIndicator,selectedSubChartIndicators:this.state.selectedSubChartIndicators,showInfoLayer:this.state.showInfoLayer,i18n:this.state.currentI18N,markData:this.state.markData,onMainChartIndicatorChange:this.handleMainChartIndicatorChange,handleRemoveSubChartIndicator:this.handleRemoveSubChartIndicator,currentMainChartType:this.state.currentMainChartType,viewportManager:this.viewportManager,ai:this.state.ai,aiconfigs:this.state.aiconfigs,currentAIFunctionType:this.state.currentAIFunctionType,timeframe:this.state.timeframe,timezone:this.state.timezone,isIncrement:this.state.isIncrement}),m.jsxs("div",{style:{position:"absolute",bottom:"80px",left:"50%",transform:"translateX(-50%)",display:"flex",alignItems:"center",gap:"15px",zIndex:3,opacity:0,transition:"opacity 0.3s ease",pointerEvents:"auto"},onMouseEnter:p=>{p.currentTarget.style.opacity="1",p.stopPropagation()},onMouseLeave:p=>{p.currentTarget.style.opacity="0",p.stopPropagation()},children:[m.jsx("button",{onClick:this.handleZoomOut,style:{width:"25px",height:"25px",borderRadius:"6px",border:"none",background:t.toolbar.button.backgroundColor,display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",boxShadow:t.toolbar.button.boxShadow,pointerEvents:"auto"},onMouseDown:p=>p.stopPropagation(),children:m.jsx(yn,{size:14,color:t.toolbar.button.iconColor})}),m.jsx("button",{onClick:this.handleLeftArrowClick,style:{width:"25px",height:"25px",borderRadius:"6px",border:"none",background:t.toolbar.button.backgroundColor,display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",boxShadow:t.toolbar.button.boxShadow,pointerEvents:"auto"},onMouseDown:p=>p.stopPropagation(),children:m.jsx(An,{size:14,color:t.toolbar.button.iconColor})}),m.jsx("button",{onClick:this.handleRefreshClick,style:{width:"25px",height:"25px",borderRadius:"6px",border:"none",background:t.toolbar.button.backgroundColor,display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",boxShadow:t.toolbar.button.boxShadow,pointerEvents:"auto"},onMouseDown:p=>p.stopPropagation(),children:m.jsx(Fn,{size:16,color:t.toolbar.button.iconColor})}),m.jsx("button",{onClick:this.handleRightArrowClick,style:{width:"25px",height:"25px",borderRadius:"6px",border:"none",background:t.toolbar.button.backgroundColor,display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",boxShadow:t.toolbar.button.boxShadow,pointerEvents:"auto"},onMouseDown:p=>p.stopPropagation(),children:m.jsx(Dn,{size:14,color:t.toolbar.button.iconColor})}),m.jsx("button",{onClick:this.handleZoomIn,style:{width:"25px",height:"25px",borderRadius:"6px",border:"none",background:t.toolbar.button.backgroundColor,display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",boxShadow:t.toolbar.button.boxShadow,pointerEvents:"auto"},onMouseDown:p=>p.stopPropagation(),children:m.jsx(En,{size:14,color:t.toolbar.button.iconColor})})]})]})}),!this.props.isMobileMode&&(r||this.state.isScriptEditorOpen)&&m.jsxs(m.Fragment,{children:[m.jsx("div",{ref:this.aiPanelResizeRef,style:{width:"8px",cursor:"col-resize",backgroundColor:this.state.currentTheme.divider.normal,display:"flex",alignItems:"center",justifyContent:"center",position:"relative",transition:"background-color 0.2s"},onMouseDown:this.handleResizeMouseDown,onMouseEnter:()=>{this.isDragging||this.aiPanelResizeRef.current&&(this.aiPanelResizeRef.current.style.backgroundColor=this.state.currentTheme.divider.hover)},onMouseLeave:()=>{this.isDragging||this.aiPanelResizeRef.current&&(this.aiPanelResizeRef.current.style.backgroundColor=this.state.currentTheme.divider.normal)},children:m.jsx("div",{style:{width:"2px",height:"40px",backgroundColor:this.state.currentTheme.toolbar.button.color+"60",borderRadius:"1px"}})}),m.jsxs("div",{style:{flex:h,minWidth:"200px",display:"flex",flexDirection:"column",backgroundColor:t.layout.background.color,borderLeft:`1px solid ${t.toolbar.border}30`,overflow:"hidden"},children:[r&&m.jsx(Dl,{currentTheme:t,i18n:this.state.currentI18N,currentAIFunctionType:this.state.currentAIFunctionType,aiconfigs:this.state.aiconfigs,currentAIBrandType:this.state.currentAIBrandType,onClose:()=>{this.setState({openAiChat:!1,currentAIFunctionType:null,currentAIBrandType:null,aiPanelWidthRatio:1})},onSendMessage:async p=>new Promise(M=>{setTimeout(()=>{M()},1e3)}),data:this.originalData}),this.state.isScriptEditorOpen&&m.jsx(El,{currentTheme:t,i18n:this.state.currentI18N,initialScript:this.state.currentScript,scriptName:this.state.scriptName,onClose:this.handleCloseScriptEditor,onSave:this.handleSaveScript,onRun:this.handleRunScript,isLoading:!1})]})]})]})]}),a&&!this.props.isMobileMode&&m.jsxs(m.Fragment,{children:[m.jsx("div",{ref:this.terminalResizeRef,style:{height:"8px",cursor:"row-resize",backgroundColor:this.state.isResizingTerminal?t.divider.dragging:t.divider.normal,display:"flex",alignItems:"center",justifyContent:"center",position:"relative",transition:"background-color 0.2s"},onMouseDown:this.handleTerminalResizeMouseDown,onMouseEnter:()=>{this.isDraggingTerminal||this.terminalResizeRef.current&&(this.terminalResizeRef.current.style.backgroundColor=t.divider.hover)},onMouseLeave:()=>{this.isDraggingTerminal||this.terminalResizeRef.current&&(this.terminalResizeRef.current.style.backgroundColor=t.divider.normal)},children:m.jsx("div",{style:{width:"40px",height:"2px",backgroundColor:t.toolbar.button.color+"60",borderRadius:"1px"}})}),m.jsx("div",{style:{flex:a?`${s*100}%`:"0",minHeight:"100px",display:"flex",flexDirection:"column",backgroundColor:t.layout.background.color,borderTop:`1px solid ${t.toolbar.border}30`,overflow:"hidden"},children:m.jsx(fl,{currentTheme:t,i18n:this.state.currentI18N,placeholder:this.state.currentI18N===ot?"Enter command (e.g., 'help', 'clear', 'theme light')...":"输入命令 (例如: 'help', 'clear', 'theme light')...",onCommand:this.handleTerminalCommand,autoFocus:!1,candleView:this,chartLayerRef:this.chartLayerRef})})]})]})}}exports.CandleView=Zi;exports.default=Zi;
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import it, { useState as st, useRef as Mt, useEffect as gt } from "react";
|
|
2
2
|
import { LineSeries as ut, AreaSeries as Ae, CandlestickSeries as Ht, BarSeries as Xi, BaselineSeries as De, HistogramSeries as Gt, createChart as lr } from "lightweight-charts";
|
|
3
3
|
import ke from "react-dom";
|
|
4
4
|
var Jt = { exports: {} }, qt = {};
|
|
@@ -182,10 +182,10 @@ function cr() {
|
|
|
182
182
|
else d(V);
|
|
183
183
|
if (tt.call(O, "key")) {
|
|
184
184
|
V = f(x);
|
|
185
|
-
var
|
|
185
|
+
var rt = Object.keys(O).filter(function(ft) {
|
|
186
186
|
return ft !== "key";
|
|
187
187
|
});
|
|
188
|
-
ct = 0 <
|
|
188
|
+
ct = 0 < rt.length ? "{key: someKey, " + rt.join(": ..., ") + ": ...}" : "{key: someKey}", pt[V + ct] || (rt = 0 < rt.length ? "{" + rt.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
189
189
|
`A props object containing a "key" prop is being spread into JSX:
|
|
190
190
|
let props = %s;
|
|
191
191
|
<%s {...props} />
|
|
@@ -194,7 +194,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
194
194
|
<%s key={someKey} {...props} />`,
|
|
195
195
|
ct,
|
|
196
196
|
V,
|
|
197
|
-
|
|
197
|
+
rt,
|
|
198
198
|
V
|
|
199
199
|
), pt[V + ct] = !0);
|
|
200
200
|
}
|
|
@@ -221,7 +221,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
221
221
|
function g(x) {
|
|
222
222
|
return typeof x == "object" && x !== null && x.$$typeof === u;
|
|
223
223
|
}
|
|
224
|
-
var c =
|
|
224
|
+
var c = it, u = /* @__PURE__ */ Symbol.for("react.transitional.element"), p = /* @__PURE__ */ Symbol.for("react.portal"), M = /* @__PURE__ */ Symbol.for("react.fragment"), k = /* @__PURE__ */ Symbol.for("react.strict_mode"), P = /* @__PURE__ */ Symbol.for("react.profiler"), S = /* @__PURE__ */ Symbol.for("react.consumer"), _ = /* @__PURE__ */ Symbol.for("react.context"), C = /* @__PURE__ */ Symbol.for("react.forward_ref"), v = /* @__PURE__ */ Symbol.for("react.suspense"), A = /* @__PURE__ */ Symbol.for("react.suspense_list"), y = /* @__PURE__ */ Symbol.for("react.memo"), B = /* @__PURE__ */ Symbol.for("react.lazy"), U = /* @__PURE__ */ Symbol.for("react.activity"), W = /* @__PURE__ */ Symbol.for("react.client.reference"), I = c.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, tt = Object.prototype.hasOwnProperty, at = Array.isArray, G = console.createTask ? console.createTask : function() {
|
|
225
225
|
return null;
|
|
226
226
|
};
|
|
227
227
|
c = {
|
|
@@ -3158,9 +3158,9 @@ const jr = ({
|
|
|
3158
3158
|
gt(() => {
|
|
3159
3159
|
const et = (V) => {
|
|
3160
3160
|
if (l) {
|
|
3161
|
-
const
|
|
3161
|
+
const rt = V.clientX - d.x, ht = V.clientY - d.y, ft = window.innerWidth - 350, kt = window.innerHeight - 240;
|
|
3162
3162
|
o({
|
|
3163
|
-
x: Math.max(10, Math.min(
|
|
3163
|
+
x: Math.max(10, Math.min(rt, ft)),
|
|
3164
3164
|
y: Math.max(10, Math.min(ht, kt))
|
|
3165
3165
|
});
|
|
3166
3166
|
}
|
|
@@ -36384,9 +36384,9 @@ const b = 1.5, T = "round", X = "round", Ji = ({ size: f = 29, color: t = "curre
|
|
|
36384
36384
|
]
|
|
36385
36385
|
}
|
|
36386
36386
|
);
|
|
36387
|
-
class ao extends
|
|
36387
|
+
class ao extends it.Component {
|
|
36388
36388
|
constructor(t) {
|
|
36389
|
-
super(t), this.toolbarRef =
|
|
36389
|
+
super(t), this.toolbarRef = it.createRef(), this.handleDocumentClick = (e) => {
|
|
36390
36390
|
this.toolbarRef.current && this.toolbarRef.current.contains(e.target) || this.state.activePanel && this.handleClosePanel();
|
|
36391
36391
|
}, this.stopPropagation = (e) => {
|
|
36392
36392
|
e.stopPropagation();
|
|
@@ -37392,7 +37392,7 @@ class ao extends rt.Component {
|
|
|
37392
37392
|
background: t.toolbar.border,
|
|
37393
37393
|
margin: "0 4px"
|
|
37394
37394
|
} }),
|
|
37395
|
-
r && /* @__PURE__ */ m.jsxs(
|
|
37395
|
+
r && /* @__PURE__ */ m.jsxs(it.Fragment, { children: [
|
|
37396
37396
|
/* @__PURE__ */ m.jsxs("div", { style: { position: "relative" }, children: [
|
|
37397
37397
|
/* @__PURE__ */ m.jsx(
|
|
37398
37398
|
"button",
|
|
@@ -37494,9 +37494,9 @@ class ao extends rt.Component {
|
|
|
37494
37494
|
) : null;
|
|
37495
37495
|
}
|
|
37496
37496
|
}
|
|
37497
|
-
class no extends
|
|
37497
|
+
class no extends it.Component {
|
|
37498
37498
|
constructor(t) {
|
|
37499
|
-
super(t), this.toolbarRef =
|
|
37499
|
+
super(t), this.toolbarRef = it.createRef(), this.handleDocumentClick = (e) => {
|
|
37500
37500
|
this.toolbarRef.current && this.toolbarRef.current.contains(e.target) || this.state.activePanel && this.handleClosePanel();
|
|
37501
37501
|
}, this.stopPropagation = (e) => {
|
|
37502
37502
|
e.stopPropagation();
|
|
@@ -38050,7 +38050,7 @@ class no extends rt.Component {
|
|
|
38050
38050
|
background: t.toolbar.border,
|
|
38051
38051
|
margin: "0 4px"
|
|
38052
38052
|
} }),
|
|
38053
|
-
this.props.selectedDrawing?.markType !== w.Image && this.props.selectedDrawing?.markType !== w.Emoji && /* @__PURE__ */ m.jsxs(
|
|
38053
|
+
this.props.selectedDrawing?.markType !== w.Image && this.props.selectedDrawing?.markType !== w.Emoji && /* @__PURE__ */ m.jsxs(it.Fragment, { children: [
|
|
38054
38054
|
/* @__PURE__ */ m.jsxs("div", { style: { position: "relative" }, children: [
|
|
38055
38055
|
/* @__PURE__ */ m.jsx(
|
|
38056
38056
|
"button",
|
|
@@ -39786,7 +39786,7 @@ function Qt() {
|
|
|
39786
39786
|
}
|
|
39787
39787
|
];
|
|
39788
39788
|
}
|
|
39789
|
-
class lo extends
|
|
39789
|
+
class lo extends it.Component {
|
|
39790
39790
|
constructor(t) {
|
|
39791
39791
|
super(t), this.handleRemoveIndicator = (r) => {
|
|
39792
39792
|
r && this.props.onRemoveIndicator && this.props.onRemoveIndicator(r);
|
|
@@ -40661,7 +40661,7 @@ const ho = ({
|
|
|
40661
40661
|
border: `1px solid ${r?.toolbar?.border || "#d9d9d9"}`,
|
|
40662
40662
|
borderRadius: "4px",
|
|
40663
40663
|
fontSize: "12px"
|
|
40664
|
-
},
|
|
40664
|
+
}, rt = {
|
|
40665
40665
|
display: "flex",
|
|
40666
40666
|
alignItems: "center",
|
|
40667
40667
|
gap: "4px",
|
|
@@ -40752,7 +40752,7 @@ const ho = ({
|
|
|
40752
40752
|
background: "transparent"
|
|
40753
40753
|
};
|
|
40754
40754
|
return !f || !o ? null : ke.createPortal(
|
|
40755
|
-
/* @__PURE__ */ m.jsxs(
|
|
40755
|
+
/* @__PURE__ */ m.jsxs(it.Fragment, { children: [
|
|
40756
40756
|
/* @__PURE__ */ m.jsx("style", { children: J }),
|
|
40757
40757
|
/* @__PURE__ */ m.jsx(
|
|
40758
40758
|
"div",
|
|
@@ -40813,7 +40813,7 @@ const ho = ({
|
|
|
40813
40813
|
]
|
|
40814
40814
|
}
|
|
40815
40815
|
),
|
|
40816
|
-
/* @__PURE__ */ m.jsxs("div", { style:
|
|
40816
|
+
/* @__PURE__ */ m.jsxs("div", { style: rt, children: [
|
|
40817
40817
|
/* @__PURE__ */ m.jsx(
|
|
40818
40818
|
"div",
|
|
40819
40819
|
{
|
|
@@ -43553,7 +43553,7 @@ const Lo = ({
|
|
|
43553
43553
|
alignItems: "center",
|
|
43554
43554
|
gap: "4px",
|
|
43555
43555
|
position: "relative"
|
|
43556
|
-
},
|
|
43556
|
+
}, rt = {
|
|
43557
43557
|
width: "24px",
|
|
43558
43558
|
height: "24px",
|
|
43559
43559
|
border: `1px solid ${r?.toolbar?.border || "#d9d9d9"}`,
|
|
@@ -43640,7 +43640,7 @@ const Lo = ({
|
|
|
43640
43640
|
if (!f || !o) return null;
|
|
43641
43641
|
const q = tt(s);
|
|
43642
43642
|
return ke.createPortal(
|
|
43643
|
-
/* @__PURE__ */ m.jsxs(
|
|
43643
|
+
/* @__PURE__ */ m.jsxs(it.Fragment, { children: [
|
|
43644
43644
|
/* @__PURE__ */ m.jsx("style", { children: K }),
|
|
43645
43645
|
/* @__PURE__ */ m.jsx(
|
|
43646
43646
|
"div",
|
|
@@ -43724,7 +43724,7 @@ const Lo = ({
|
|
|
43724
43724
|
"div",
|
|
43725
43725
|
{
|
|
43726
43726
|
style: {
|
|
43727
|
-
...
|
|
43727
|
+
...rt,
|
|
43728
43728
|
backgroundColor: L.lineColor
|
|
43729
43729
|
},
|
|
43730
43730
|
onClick: (Z) => {
|
|
@@ -45353,9 +45353,9 @@ class Zo {
|
|
|
45353
45353
|
}
|
|
45354
45354
|
}
|
|
45355
45355
|
}
|
|
45356
|
-
class tl extends
|
|
45356
|
+
class tl extends it.Component {
|
|
45357
45357
|
constructor(t) {
|
|
45358
|
-
super(t), this.canvasRef =
|
|
45358
|
+
super(t), this.canvasRef = it.createRef(), this.containerRef = it.createRef(), this.allDrawings = [], this.doubleClickTimeout = null, this.chartEventManager = null, this.originalChartOptions = null, this.currentMarkSettingsStyle = null, this.chartMarkManager = null, this.chartMarkTextEditManager = null, this.mainChartTechnicalIndicatorManager = null, this.staticMarkManager = null, this.volume = null, this.volumeHeatMap = null, this.marketProfile = null, this.mainChartManager = null, this.executeEventMarksScriptForChartData = () => {
|
|
45359
45359
|
const { chartData: e } = this.props, { isIncrement: i } = this.state;
|
|
45360
45360
|
if (!i || !e || !Array.isArray(e) || e.length === 0)
|
|
45361
45361
|
return;
|
|
@@ -49359,7 +49359,7 @@ Npm: <a href="https://www.npmjs.com/package/candleview" target="_blank" rel="noo
|
|
|
49359
49359
|
o?.current && !F && o?.current.handleRemoveIndicator && o?.current.handleRemoveIndicator(D.ICHIMOKU), O(
|
|
49360
49360
|
I ? `[<span style="color: #52c41a">INFO</span>] ${Y} Ichimoku Cloud indicator` : `[<span style="color: #52c41a">信息</span>] ${H}一目均衡表(Ichimoku)指标`
|
|
49361
49361
|
);
|
|
49362
|
-
},
|
|
49362
|
+
}, rt = (F) => {
|
|
49363
49363
|
const H = F ? "开启" : "关闭", Y = F ? "Opening" : "Closing";
|
|
49364
49364
|
if (l?.handleSelectedMainChartIndicator && F) {
|
|
49365
49365
|
const dt = {
|
|
@@ -49505,7 +49505,7 @@ Sub chart indicators: ${Rt}` : `[<span style="color: #c41a1aff">错误</span>]
|
|
|
49505
49505
|
V(mt);
|
|
49506
49506
|
break;
|
|
49507
49507
|
case D.DONCHIAN:
|
|
49508
|
-
|
|
49508
|
+
rt(mt);
|
|
49509
49509
|
break;
|
|
49510
49510
|
case D.ENVELOPE:
|
|
49511
49511
|
ht(mt);
|
|
@@ -50637,9 +50637,9 @@ class Ni {
|
|
|
50637
50637
|
};
|
|
50638
50638
|
}
|
|
50639
50639
|
}
|
|
50640
|
-
class vl extends
|
|
50640
|
+
class vl extends it.Component {
|
|
50641
50641
|
constructor(t) {
|
|
50642
|
-
super(t), this.scriptModalRef =
|
|
50642
|
+
super(t), this.scriptModalRef = it.createRef(), this.drawingModalRef = it.createRef(), this.emojiPickerRef = it.createRef(), this.cursorModalRef = it.createRef(), this.brushModalRef = it.createRef(), this.rulerModalRef = it.createRef(), this.fibonacciModalRef = it.createRef(), this.gannModalRef = it.createRef(), this.projectInfoModalRef = it.createRef(), this.irregularShapeModalRef = it.createRef(), this.aiModalRef = it.createRef(), this.toolManager = new Ni(), this.functionPopUpWidth = "200px", this.emojiSelectPopUpWidth = "315px", this.containerRef = it.createRef(), this.scrollContainerRef = it.createRef(), this.checkScrollPosition = () => {
|
|
50643
50643
|
const e = this.scrollContainerRef.current;
|
|
50644
50644
|
if (e) {
|
|
50645
50645
|
const { scrollTop: i, scrollHeight: r, clientHeight: a } = e;
|
|
@@ -52521,7 +52521,7 @@ class vl extends rt.Component {
|
|
|
52521
52521
|
] });
|
|
52522
52522
|
}
|
|
52523
52523
|
}
|
|
52524
|
-
class St extends
|
|
52524
|
+
class St extends it.Component {
|
|
52525
52525
|
constructor(t) {
|
|
52526
52526
|
super(t), this.toggleOpen = () => {
|
|
52527
52527
|
this.setState((e) => ({ isOpen: !e.isOpen }));
|
|
@@ -52804,9 +52804,9 @@ function Fl(f, t) {
|
|
|
52804
52804
|
};
|
|
52805
52805
|
});
|
|
52806
52806
|
}
|
|
52807
|
-
class El extends
|
|
52807
|
+
class El extends it.Component {
|
|
52808
52808
|
constructor() {
|
|
52809
|
-
super(...arguments), this.timeframeModalRef =
|
|
52809
|
+
super(...arguments), this.timeframeModalRef = it.createRef(), this.chartTypeModalRef = it.createRef(), this.indicatorModalRef = it.createRef(), this.timezoneModalRef = it.createRef(), this.scrollContainerRef = it.createRef(), this.aiModalRef = it.createRef(), this.state = {
|
|
52810
52810
|
aiSearch: "",
|
|
52811
52811
|
mainIndicatorsSearch: "",
|
|
52812
52812
|
subChartIndicatorsSearch: "",
|
|
@@ -53373,7 +53373,7 @@ class El extends rt.Component {
|
|
|
53373
53373
|
C.currentTarget.style.background = "transparent";
|
|
53374
53374
|
},
|
|
53375
53375
|
children: [
|
|
53376
|
-
P ? /* @__PURE__ */ m.jsx(
|
|
53376
|
+
P ? /* @__PURE__ */ m.jsx(it.Fragment, { children: /* @__PURE__ */ m.jsx("div", { style: {
|
|
53377
53377
|
display: "flex",
|
|
53378
53378
|
alignItems: "center",
|
|
53379
53379
|
justifyContent: "center",
|
|
@@ -54793,7 +54793,7 @@ const Ll = ({
|
|
|
54793
54793
|
const V = A.current;
|
|
54794
54794
|
return V.scrollHeight - V.scrollTop - V.clientHeight <= R;
|
|
54795
54795
|
}, lt = (R, V) => {
|
|
54796
|
-
const
|
|
54796
|
+
const rt = [];
|
|
54797
54797
|
return V.forEach((ht) => {
|
|
54798
54798
|
let ft = !1;
|
|
54799
54799
|
for (const kt of R)
|
|
@@ -54802,24 +54802,24 @@ const Ll = ({
|
|
|
54802
54802
|
break;
|
|
54803
54803
|
}
|
|
54804
54804
|
if (ft)
|
|
54805
|
-
|
|
54805
|
+
rt.push(ht);
|
|
54806
54806
|
else {
|
|
54807
54807
|
const kt = ht.toLowerCase();
|
|
54808
54808
|
R.find(
|
|
54809
54809
|
(_t) => _t.toString().toLowerCase() === kt
|
|
54810
|
-
) &&
|
|
54810
|
+
) && rt.push(ht);
|
|
54811
54811
|
}
|
|
54812
|
-
}),
|
|
54812
|
+
}), rt.filter(
|
|
54813
54813
|
(ht, ft, kt) => kt.indexOf(ht) === ft
|
|
54814
54814
|
);
|
|
54815
54815
|
};
|
|
54816
54816
|
gt(() => {
|
|
54817
54817
|
if (o != null)
|
|
54818
54818
|
try {
|
|
54819
|
-
const R = Pl(o), V = i.filter((ht) => ht.brand === o).map((ht) => ht.model),
|
|
54820
|
-
if (_(
|
|
54821
|
-
if (!
|
|
54822
|
-
const ht =
|
|
54819
|
+
const R = Pl(o), V = i.filter((ht) => ht.brand === o).map((ht) => ht.model), rt = lt(R, V);
|
|
54820
|
+
if (_(rt), rt.length > 0) {
|
|
54821
|
+
if (!rt.includes(k)) {
|
|
54822
|
+
const ht = rt[0];
|
|
54823
54823
|
P(ht), l && l(ht);
|
|
54824
54824
|
}
|
|
54825
54825
|
} else
|
|
@@ -54842,8 +54842,8 @@ const Ll = ({
|
|
|
54842
54842
|
const R = y.current;
|
|
54843
54843
|
R && setTimeout(() => {
|
|
54844
54844
|
R.style.height = "auto";
|
|
54845
|
-
const
|
|
54846
|
-
R.style.height = `${
|
|
54845
|
+
const rt = Math.max(R.scrollHeight, 60);
|
|
54846
|
+
R.style.height = `${rt}px`;
|
|
54847
54847
|
}, 100);
|
|
54848
54848
|
}, []), gt(() => {
|
|
54849
54849
|
u([
|
|
@@ -54859,16 +54859,16 @@ const Ll = ({
|
|
|
54859
54859
|
if (!R) return;
|
|
54860
54860
|
const V = 60;
|
|
54861
54861
|
R.style.height = "auto";
|
|
54862
|
-
const
|
|
54863
|
-
R.style.height = `${
|
|
54862
|
+
const rt = Math.max(R.scrollHeight, V);
|
|
54863
|
+
R.style.height = `${rt}px`;
|
|
54864
54864
|
}, [d]), gt(() => {
|
|
54865
54865
|
if (o != null)
|
|
54866
54866
|
try {
|
|
54867
|
-
const V = i.filter((
|
|
54867
|
+
const V = i.filter((rt) => rt.brand === o).map((rt) => rt.model).filter((rt, ht, ft) => ft.indexOf(rt) === ht);
|
|
54868
54868
|
if (_(V), V.length > 0) {
|
|
54869
54869
|
if (!V.includes(k)) {
|
|
54870
|
-
const
|
|
54871
|
-
P(
|
|
54870
|
+
const rt = V[0];
|
|
54871
|
+
P(rt), l && l(rt);
|
|
54872
54872
|
}
|
|
54873
54873
|
} else
|
|
54874
54874
|
P(""), l && l("");
|
|
@@ -54893,14 +54893,14 @@ const Ll = ({
|
|
|
54893
54893
|
timestamp: /* @__PURE__ */ new Date()
|
|
54894
54894
|
};
|
|
54895
54895
|
u((ht) => [...ht, V]), g(""), M(!0);
|
|
54896
|
-
const
|
|
54896
|
+
const rt = {
|
|
54897
54897
|
id: `loading-${Date.now()}`,
|
|
54898
54898
|
content: t === ot ? "Analyzing data..." : "分析数据中...",
|
|
54899
54899
|
sender: "ai",
|
|
54900
54900
|
timestamp: /* @__PURE__ */ new Date(),
|
|
54901
54901
|
isLoading: !0
|
|
54902
54902
|
};
|
|
54903
|
-
u((ht) => [...ht,
|
|
54903
|
+
u((ht) => [...ht, rt]);
|
|
54904
54904
|
try {
|
|
54905
54905
|
if (!o || !k)
|
|
54906
54906
|
throw new Error(
|
|
@@ -54941,7 +54941,7 @@ const Ll = ({
|
|
|
54941
54941
|
);
|
|
54942
54942
|
}
|
|
54943
54943
|
xt = await Il(t, ft, _t, k, kt, R), u((Ft) => {
|
|
54944
|
-
const Bt = Ft.filter((It) => It.id !==
|
|
54944
|
+
const Bt = Ft.filter((It) => It.id !== rt.id), Ut = {
|
|
54945
54945
|
id: (Date.now() + 1).toString(),
|
|
54946
54946
|
content: xt,
|
|
54947
54947
|
sender: "ai",
|
|
@@ -54951,7 +54951,7 @@ const Ll = ({
|
|
|
54951
54951
|
});
|
|
54952
54952
|
} catch (ht) {
|
|
54953
54953
|
u((ft) => {
|
|
54954
|
-
const kt = ft.filter((_t) => _t.id !==
|
|
54954
|
+
const kt = ft.filter((_t) => _t.id !== rt.id), xt = {
|
|
54955
54955
|
id: (Date.now() + 2).toString(),
|
|
54956
54956
|
content: t === ot ? `Sorry, there was an error: ${ht.message}` : `抱歉,出现错误:${ht.message}`,
|
|
54957
54957
|
sender: "ai",
|
|
@@ -55104,11 +55104,11 @@ const Ll = ({
|
|
|
55104
55104
|
whiteSpace: "nowrap"
|
|
55105
55105
|
},
|
|
55106
55106
|
onClick: () => x(R),
|
|
55107
|
-
onMouseEnter: (
|
|
55108
|
-
|
|
55107
|
+
onMouseEnter: (rt) => {
|
|
55108
|
+
rt.currentTarget.style.backgroundColor = R === k ? f.toolbar.button.dropdown.selected : f.toolbar.button.dropdown.hover;
|
|
55109
55109
|
},
|
|
55110
|
-
onMouseLeave: (
|
|
55111
|
-
|
|
55110
|
+
onMouseLeave: (rt) => {
|
|
55111
|
+
rt.currentTarget.style.backgroundColor = R === k ? f.toolbar.button.dropdown.selected : "transparent";
|
|
55112
55112
|
},
|
|
55113
55113
|
children: R
|
|
55114
55114
|
},
|
|
@@ -56150,9 +56150,158 @@ class je {
|
|
|
56150
56150
|
});
|
|
56151
56151
|
}
|
|
56152
56152
|
}
|
|
56153
|
-
class
|
|
56153
|
+
class Ol {
|
|
56154
56154
|
constructor(t) {
|
|
56155
|
-
|
|
56155
|
+
this.danmakus = [], this.activeDanmakus = [], this.canvas = null, this.ctx = null, this.animationFrameId = null, this.lastUpdateTime = 0, this.isPlaying = !1, this.containerWidth = 0, this.containerHeight = 0, this.danmakuPool = [], this.config = {
|
|
56156
|
+
maxConcurrent: 10,
|
|
56157
|
+
defaultStyle: {
|
|
56158
|
+
color: "#FFFFFF",
|
|
56159
|
+
fontSize: 16,
|
|
56160
|
+
speed: 60,
|
|
56161
|
+
opacity: 0.9,
|
|
56162
|
+
yPosition: 0.5
|
|
56163
|
+
},
|
|
56164
|
+
fontFamily: "Arial, sans-serif",
|
|
56165
|
+
lineHeight: 1.2,
|
|
56166
|
+
autoStart: !0,
|
|
56167
|
+
...t
|
|
56168
|
+
};
|
|
56169
|
+
}
|
|
56170
|
+
initialize(t) {
|
|
56171
|
+
this.canvas = t, this.ctx = t.getContext("2d"), this.ctx && (this.ctx.textBaseline = "middle"), this.updateCanvasSize(), this.config.autoStart && this.start();
|
|
56172
|
+
}
|
|
56173
|
+
updateCanvasSize() {
|
|
56174
|
+
this.canvas && (this.containerWidth = this.canvas.width, this.containerHeight = this.canvas.height);
|
|
56175
|
+
}
|
|
56176
|
+
setDanmakus(t) {
|
|
56177
|
+
this.danmakus = [...t];
|
|
56178
|
+
}
|
|
56179
|
+
addDanmaku(t) {
|
|
56180
|
+
this.danmakus.push(t);
|
|
56181
|
+
}
|
|
56182
|
+
addDanmakus(t) {
|
|
56183
|
+
this.danmakus.push(...t);
|
|
56184
|
+
}
|
|
56185
|
+
start() {
|
|
56186
|
+
this.isPlaying || (this.isPlaying = !0, this.lastUpdateTime = performance.now(), this.animate());
|
|
56187
|
+
}
|
|
56188
|
+
stop() {
|
|
56189
|
+
this.isPlaying = !1, this.animationFrameId && (cancelAnimationFrame(this.animationFrameId), this.animationFrameId = null);
|
|
56190
|
+
}
|
|
56191
|
+
clear() {
|
|
56192
|
+
this.danmakus = [], this.activeDanmakus = [], this.ctx && this.canvas && this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
|
|
56193
|
+
}
|
|
56194
|
+
getActiveCount() {
|
|
56195
|
+
return this.activeDanmakus.length;
|
|
56196
|
+
}
|
|
56197
|
+
getPendingCount() {
|
|
56198
|
+
return this.danmakus.length;
|
|
56199
|
+
}
|
|
56200
|
+
destroy() {
|
|
56201
|
+
this.stop(), this.clear(), this.canvas = null, this.ctx = null, this.danmakuPool = [];
|
|
56202
|
+
}
|
|
56203
|
+
getDanmakuItem(t) {
|
|
56204
|
+
if (this.danmakuPool.length > 0) {
|
|
56205
|
+
const e = this.danmakuPool.pop();
|
|
56206
|
+
return e.text = t, e.isVisible = !0, e.startTime = performance.now(), e;
|
|
56207
|
+
}
|
|
56208
|
+
return {
|
|
56209
|
+
id: `danmaku_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`,
|
|
56210
|
+
text: t,
|
|
56211
|
+
x: 0,
|
|
56212
|
+
y: 0,
|
|
56213
|
+
width: 0,
|
|
56214
|
+
style: this.getRandomStyle(),
|
|
56215
|
+
startTime: performance.now(),
|
|
56216
|
+
isVisible: !0
|
|
56217
|
+
};
|
|
56218
|
+
}
|
|
56219
|
+
recycleDanmakuItem(t) {
|
|
56220
|
+
t.isVisible = !1, this.danmakuPool.push(t);
|
|
56221
|
+
}
|
|
56222
|
+
getRandomStyle() {
|
|
56223
|
+
const t = [
|
|
56224
|
+
"#FFFFFF",
|
|
56225
|
+
"#FF6B6B",
|
|
56226
|
+
"#4ECDC4",
|
|
56227
|
+
"#FFD166",
|
|
56228
|
+
"#06D6A0",
|
|
56229
|
+
"#118AB2",
|
|
56230
|
+
"#EF476F",
|
|
56231
|
+
"#073B4C",
|
|
56232
|
+
"#7209B7",
|
|
56233
|
+
"#F72585"
|
|
56234
|
+
], e = [14, 16, 18], i = [50, 60, 70, 80];
|
|
56235
|
+
return {
|
|
56236
|
+
color: t[Math.floor(Math.random() * t.length)],
|
|
56237
|
+
fontSize: e[Math.floor(Math.random() * e.length)],
|
|
56238
|
+
speed: i[Math.floor(Math.random() * i.length)],
|
|
56239
|
+
opacity: 0.8 + Math.random() * 0.2,
|
|
56240
|
+
// 0.8-1.0
|
|
56241
|
+
yPosition: 0.1 + Math.random() * 0.8
|
|
56242
|
+
// 0.1-0.9
|
|
56243
|
+
};
|
|
56244
|
+
}
|
|
56245
|
+
measureTextWidth(t, e) {
|
|
56246
|
+
if (!this.ctx) return 100;
|
|
56247
|
+
this.ctx.save(), this.ctx.font = `${e}px ${this.config.fontFamily}`;
|
|
56248
|
+
const i = this.ctx.measureText(t).width;
|
|
56249
|
+
return this.ctx.restore(), i;
|
|
56250
|
+
}
|
|
56251
|
+
spawnDanmaku() {
|
|
56252
|
+
if (this.activeDanmakus.length >= this.config.maxConcurrent || this.danmakus.length === 0)
|
|
56253
|
+
return;
|
|
56254
|
+
const t = this.danmakus.shift(), e = this.getDanmakuItem(t);
|
|
56255
|
+
e.width = this.measureTextWidth(t, e.style.fontSize), e.x = this.containerWidth, e.y = e.style.yPosition * this.containerHeight, this.activeDanmakus.push(e);
|
|
56256
|
+
}
|
|
56257
|
+
updateDanmakus(t) {
|
|
56258
|
+
for (let e = this.activeDanmakus.length - 1; e >= 0; e--) {
|
|
56259
|
+
const i = this.activeDanmakus[e];
|
|
56260
|
+
i.x -= i.style.speed * (t / 1e3), i.x + i.width < 0 && (this.recycleDanmakuItem(i), this.activeDanmakus.splice(e, 1));
|
|
56261
|
+
}
|
|
56262
|
+
this.spawnDanmaku();
|
|
56263
|
+
}
|
|
56264
|
+
renderDanmakus() {
|
|
56265
|
+
!this.ctx || !this.canvas || (this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height), this.activeDanmakus.forEach((t) => {
|
|
56266
|
+
this.ctx.save(), this.ctx.font = `${t.style.fontSize}px ${this.config.fontFamily}`, this.ctx.fillStyle = t.style.color, this.ctx.globalAlpha = t.style.opacity, this.ctx.shadowColor = "rgba(0, 0, 0, 0.5)", this.ctx.shadowBlur = 2, this.ctx.shadowOffsetX = 1, this.ctx.shadowOffsetY = 1, this.ctx.fillText(t.text, t.x, t.y), this.ctx.restore();
|
|
56267
|
+
}));
|
|
56268
|
+
}
|
|
56269
|
+
animate() {
|
|
56270
|
+
if (!this.isPlaying) return;
|
|
56271
|
+
const t = performance.now(), e = t - this.lastUpdateTime;
|
|
56272
|
+
this.lastUpdateTime = t, this.updateDanmakus(e), this.renderDanmakus(), this.animationFrameId = requestAnimationFrame(() => this.animate());
|
|
56273
|
+
}
|
|
56274
|
+
}
|
|
56275
|
+
class Yl extends it.Component {
|
|
56276
|
+
constructor(t) {
|
|
56277
|
+
super(t), this.candleViewRef = it.createRef(), this.chartRef = it.createRef(), this.chartContainerRef = it.createRef(), this.chartLayerRef = it.createRef(), this.chart = null, this.resizeObserver = null, this.realTimeInterval = null, this.currentSeries = null, this.chartManager = null, this.updateTimeout = null, this.viewportManager = null, this.chartEventManager = null, this.aiPanelResizeRef = it.createRef(), this.isDragging = !1, this.startX = 0, this.startChartWidth = 0, this.containerWidth = 0, this.terminalResizeRef = it.createRef(), this.isDraggingTerminal = !1, this.startY = 0, this.startTerminalHeightRatio = 0, this.aiMobilePanelResizeRef = it.createRef(), this.isDraggingAiMobilePanel = !1, this.startAiMobileY = 0, this.startAiMobileHeightRatio = 0, this.preparedData = [], this.originalData = [], this.aiManager = null, this.danmakuManager = null, this.danmakuCanvasRef = it.createRef(), this.danmakuContainerRef = it.createRef(), this.initializeDanmaku = (s) => {
|
|
56278
|
+
if (!s || s.length === 0) return;
|
|
56279
|
+
if (!this.danmakuContainerRef.current || !this.danmakuCanvasRef.current) {
|
|
56280
|
+
setTimeout(() => this.initializeDanmaku(s), 100);
|
|
56281
|
+
return;
|
|
56282
|
+
}
|
|
56283
|
+
this.clearDanmaku(), this.danmakuManager = new Ol({
|
|
56284
|
+
maxConcurrent: 8,
|
|
56285
|
+
defaultStyle: {
|
|
56286
|
+
color: "#FFFFFF",
|
|
56287
|
+
fontSize: 14,
|
|
56288
|
+
speed: 60,
|
|
56289
|
+
opacity: 0.85,
|
|
56290
|
+
yPosition: 0.5
|
|
56291
|
+
},
|
|
56292
|
+
fontFamily: "Arial, sans-serif",
|
|
56293
|
+
autoStart: !0
|
|
56294
|
+
});
|
|
56295
|
+
const n = this.danmakuCanvasRef.current, o = this.danmakuContainerRef.current;
|
|
56296
|
+
n && o && (n.width = o.clientWidth, n.height = o.clientHeight, this.danmakuManager.initialize(n), this.danmakuManager.setDanmakus([...s]), this.danmakuManager.start());
|
|
56297
|
+
}, this.clearDanmaku = () => {
|
|
56298
|
+
this.danmakuManager && (this.danmakuManager.stop(), this.danmakuManager.clear(), this.danmakuManager = null);
|
|
56299
|
+
}, this.handleDanmakuResize = () => {
|
|
56300
|
+
if (this.danmakuCanvasRef.current && this.danmakuContainerRef.current) {
|
|
56301
|
+
const s = this.danmakuCanvasRef.current, n = this.danmakuContainerRef.current;
|
|
56302
|
+
s.width = n.clientWidth, s.height = n.clientHeight, this.danmakuManager && this.danmakuManager.updateCanvasSize();
|
|
56303
|
+
}
|
|
56304
|
+
}, this.initializeMainChartIndicators = (s) => {
|
|
56156
56305
|
this.setState({
|
|
56157
56306
|
selectedMainChartIndicator: null
|
|
56158
56307
|
}), this.chartLayerRef.current && Object.values(D).forEach((n) => {
|
|
@@ -56750,7 +56899,9 @@ class Xl extends rt.Component {
|
|
|
56750
56899
|
}
|
|
56751
56900
|
// ======================================== life cycle start ========================================
|
|
56752
56901
|
componentDidMount() {
|
|
56753
|
-
|
|
56902
|
+
if (this.chart) return;
|
|
56903
|
+
const { danmakus: t } = this.props;
|
|
56904
|
+
this.setState({ isDataLoading: !0 }), this.loadDataAsync(() => {
|
|
56754
56905
|
setTimeout(() => {
|
|
56755
56906
|
this.initializeChart(), this.props.mainChartIndicators && this.props.mainChartIndicators.length > 0 && setTimeout(() => {
|
|
56756
56907
|
this.initializeMainChartIndicators(this.props.mainChartIndicators || []);
|
|
@@ -56758,7 +56909,7 @@ class Xl extends rt.Component {
|
|
|
56758
56909
|
this.initializeSubChartIndicators(this.props.subChartIndicators || []);
|
|
56759
56910
|
}, 150);
|
|
56760
56911
|
}, 50);
|
|
56761
|
-
}), document.addEventListener("mousemove", this.handleMouseMove), document.addEventListener("mouseup", this.handleMouseUp), document.addEventListener("mousemove", this.handleTerminalMouseMove), document.addEventListener("mouseup", this.handleTerminalMouseUp), document.addEventListener("mousemove", this.handleAiMobileMouseMove), document.addEventListener("mouseup", this.handleAiMobileMouseUp), document.addEventListener("touchstart", this.handleClickOutside, !0)
|
|
56912
|
+
}), t && this.initializeDanmaku(t), document.addEventListener("mousemove", this.handleMouseMove), document.addEventListener("mouseup", this.handleMouseUp), document.addEventListener("mousemove", this.handleTerminalMouseMove), document.addEventListener("mouseup", this.handleTerminalMouseUp), document.addEventListener("mousemove", this.handleAiMobileMouseMove), document.addEventListener("mouseup", this.handleAiMobileMouseUp), document.addEventListener("touchstart", this.handleClickOutside, !0);
|
|
56762
56913
|
}
|
|
56763
56914
|
componentDidUpdate(t, e) {
|
|
56764
56915
|
if (je.standardizedDPI(), t.theme !== this.props.theme) {
|
|
@@ -56780,7 +56931,7 @@ class Xl extends rt.Component {
|
|
|
56780
56931
|
}));
|
|
56781
56932
|
return;
|
|
56782
56933
|
}
|
|
56783
|
-
t.mainChartIndicators !== this.props.mainChartIndicators && (this.props.mainChartIndicators ? this.initializeMainChartIndicators(this.props.mainChartIndicators) : (this.setState({
|
|
56934
|
+
t.danmakus !== this.props.danmakus && (this.props.danmakus ? this.initializeDanmaku(this.props.danmakus) : this.clearDanmaku()), t.mainChartIndicators !== this.props.mainChartIndicators && (this.props.mainChartIndicators ? this.initializeMainChartIndicators(this.props.mainChartIndicators) : (this.setState({
|
|
56784
56935
|
selectedMainChartIndicator: null
|
|
56785
56936
|
}), this.chartLayerRef.current && Object.values(D).forEach((r) => {
|
|
56786
56937
|
this.chartLayerRef.current?.handleRemoveIndicator && this.chartLayerRef.current.handleRemoveIndicator(r);
|
|
@@ -56807,7 +56958,7 @@ class Xl extends rt.Component {
|
|
|
56807
56958
|
localStorage.setItem("candleView_visibleRange", JSON.stringify(t));
|
|
56808
56959
|
} catch {
|
|
56809
56960
|
}
|
|
56810
|
-
this.updateTimeout && clearTimeout(this.updateTimeout), this.resizeObserver && this.chartContainerRef.current && (this.resizeObserver.unobserve(this.chartContainerRef.current), this.resizeObserver.disconnect()), this.chart && this.chart.remove(), this.realTimeInterval && clearInterval(this.realTimeInterval), document.removeEventListener("mousedown", this.handleClickOutside, !0), document.removeEventListener("mousemove", this.handleMouseMove), document.removeEventListener("mouseup", this.handleMouseUp), document.removeEventListener("mousemove", this.handleTerminalMouseMove), document.removeEventListener("mouseup", this.handleTerminalMouseUp), document.removeEventListener("mousemove", this.handleAiMobileMouseMove), document.removeEventListener("mouseup", this.handleAiMobileMouseUp);
|
|
56961
|
+
this.updateTimeout && clearTimeout(this.updateTimeout), this.resizeObserver && this.chartContainerRef.current && (this.resizeObserver.unobserve(this.chartContainerRef.current), this.resizeObserver.disconnect()), this.chart && this.chart.remove(), this.realTimeInterval && clearInterval(this.realTimeInterval), this.clearDanmaku(), document.removeEventListener("mousedown", this.handleClickOutside, !0), document.removeEventListener("mousemove", this.handleMouseMove), document.removeEventListener("mouseup", this.handleMouseUp), document.removeEventListener("mousemove", this.handleTerminalMouseMove), document.removeEventListener("mouseup", this.handleTerminalMouseUp), document.removeEventListener("mousemove", this.handleAiMobileMouseMove), document.removeEventListener("mouseup", this.handleAiMobileMouseUp);
|
|
56811
56962
|
}
|
|
56812
56963
|
// clear static marks
|
|
56813
56964
|
clearStaticMarks() {
|
|
@@ -57289,6 +57440,33 @@ class Xl extends rt.Component {
|
|
|
57289
57440
|
}
|
|
57290
57441
|
}
|
|
57291
57442
|
),
|
|
57443
|
+
/* @__PURE__ */ m.jsx(
|
|
57444
|
+
"div",
|
|
57445
|
+
{
|
|
57446
|
+
ref: this.danmakuContainerRef,
|
|
57447
|
+
style: {
|
|
57448
|
+
position: "absolute",
|
|
57449
|
+
top: 0,
|
|
57450
|
+
left: 0,
|
|
57451
|
+
right: 0,
|
|
57452
|
+
bottom: 0,
|
|
57453
|
+
zIndex: 1,
|
|
57454
|
+
pointerEvents: "none",
|
|
57455
|
+
overflow: "hidden"
|
|
57456
|
+
},
|
|
57457
|
+
children: /* @__PURE__ */ m.jsx(
|
|
57458
|
+
"canvas",
|
|
57459
|
+
{
|
|
57460
|
+
ref: this.danmakuCanvasRef,
|
|
57461
|
+
style: {
|
|
57462
|
+
width: "100%",
|
|
57463
|
+
height: "100%",
|
|
57464
|
+
display: this.props.danmakus && this.props.danmakus.length > 0 ? "block" : "none"
|
|
57465
|
+
}
|
|
57466
|
+
}
|
|
57467
|
+
)
|
|
57468
|
+
}
|
|
57469
|
+
),
|
|
57292
57470
|
this.state.chartInitialized && /* @__PURE__ */ m.jsx(
|
|
57293
57471
|
tl,
|
|
57294
57472
|
{
|
|
@@ -57602,6 +57780,6 @@ class Xl extends rt.Component {
|
|
|
57602
57780
|
}
|
|
57603
57781
|
}
|
|
57604
57782
|
export {
|
|
57605
|
-
|
|
57606
|
-
|
|
57783
|
+
Yl as CandleView,
|
|
57784
|
+
Yl as default
|
|
57607
57785
|
};
|