candleview 2.3.3 → 2.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +2 -2
- package/dist/index.mjs +4 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -18,7 +18,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
18
18
|
.indicators-scrollbar::-webkit-scrollbar-thumb:hover {
|
|
19
19
|
background: ${r?.layout?.textColor||"#000000"}80;
|
|
20
20
|
}
|
|
21
|
-
`,ht={position:"absolute",left:`${l.x}px`,top:`${l.y}px`,background:r?.toolbar?.background||"#fafafa",border:`1px solid ${r?.toolbar?.border||"#d9d9d9"}`,borderRadius:"8px",padding:"0",width:"400px",maxWidth:"90vw",height:"400px",maxHeight:"80vh",zIndex:1e4,boxShadow:"0 8px 24px rgba(0,0,0,0.3)",cursor:c?"grabbing":"default",userSelect:c?"none":"auto",display:"flex",flexDirection:"column"},ut={padding:"16px 16px 12px 16px",borderBottom:`1px solid ${r?.toolbar?.border||"#d9d9d9"}`,cursor:"grab",userSelect:"none",flexShrink:0},y={fontSize:"14px",fontWeight:"bold",color:r?.layout?.textColor||"#000000",margin:0},W={padding:"16px",flex:1,display:"flex",flexDirection:"column",overflow:"hidden"},nt={marginBottom:"16px",flex:1,overflowY:"auto",overflowX:"hidden",...j},ct={display:"flex",alignItems:"center",gap:"8px",marginBottom:"8px",padding:"8px",background:r?.toolbar?.background||"#fafafa",border:`1px solid ${r?.toolbar?.border||"#d9d9d9"}`,borderRadius:"4px"},it={fontSize:"12px",color:r?.layout?.textColor||"#000000",minWidth:"80px",fontWeight:"bold"},B={width:"60px",padding:"4px 8px",background:r?.toolbar?.background||"#fafafa",color:r?.layout?.textColor||"#000000",border:`1px solid ${r?.toolbar?.border||"#d9d9d9"}`,borderRadius:"4px",fontSize:"12px"},G={width:"60px",padding:"4px 8px",background:r?.toolbar?.background||"#fafafa",color:r?.layout?.textColor||"#000000",border:`1px solid ${r?.toolbar?.border||"#d9d9d9"}`,borderRadius:"4px",fontSize:"12px"},rt={display:"flex",alignItems:"center",gap:"4px",position:"relative"},ot={width:"24px",height:"24px",border:`1px solid ${r?.toolbar?.border||"#d9d9d9"}`,borderRadius:"4px",cursor:"pointer"},dt={position:"absolute",top:0,left:0,width:"24px",height:"24px",border:"none",background:"transparent",cursor:"pointer",opacity:0},pt={background:"transparent",border:"none",fontSize:"16px",cursor:"pointer",padding:"0",width:"20px",height:"20px",display:"flex",alignItems:"center",justifyContent:"center",color:r?.chart?.downColor||"#ff4d4f"},bt={...pt,color:`${r?.toolbar?.border||"#d9d9d9"}`,cursor:"not-allowed"},mt={width:"100%",background:"transparent",color:r?.chart?.lineColor||"#2962FF",border:`2px dashed ${r?.toolbar?.border||"#d9d9d9"}`,borderRadius:"4px",padding:"8px 16px",fontSize:"12px",cursor:"pointer",marginBottom:"16px",flexShrink:0};({...mt,color:`${r?.toolbar?.border||"#d9d9d9"}`,borderColor:`${r?.toolbar?.border||"#d9d9d9"}`});const At={display:"flex",justifyContent:"flex-end",gap:"8px",flexShrink:0},Et={background:"transparent",color:r?.layout?.textColor||"#000000",border:`1px solid ${r?.toolbar?.border||"#d9d9d9"}`,borderRadius:"4px",padding:"6px 12px",fontSize:"12px",cursor:"pointer"},Rt={background:r?.toolbar?.button?.active||"#2962FF",color:r?.toolbar?.button?.activeTextColor||"#ffffff",border:"none",borderRadius:"4px",padding:"6px 12px",fontSize:"12px",cursor:"pointer"},yt={fontSize:"10px",color:`${r?.layout?.textColor||"#000000"}80`,marginTop:"8px",textAlign:"center",flexShrink:0},Ot={position:"fixed",top:0,left:0,right:0,bottom:0,zIndex:9999,background:"transparent"};return!f||!o?null:ue.createPortal(m.jsxs(E.Fragment,{children:[m.jsx("style",{children:st}),m.jsx("div",{style:Ot,onClick:$,children:m.jsxs("div",{ref:M,style:ht,onClick:V=>V.stopPropagation(),onMouseDown:at,onKeyDown:tt,children:[m.jsx("div",{ref:k,style:ut,onMouseDown:V=>{V.target===k.current&&V.preventDefault()},children:m.jsx("div",{style:y,children:K()})}),m.jsxs("div",{style:W,children:[m.jsx("div",{style:nt,className:"indicators-scrollbar",children:o.params?.map((V,I)=>m.jsxs("div",{style:ct,children:[m.jsx("div",{style:it,children:Z(I)}),m.jsx("input",{type:"number",style:B,value:V.paramValue,onChange:q=>A(I,Number(q.target.value)),onClick:q=>q.stopPropagation()}),m.jsxs("select",{style:G,value:V.lineWidth,onChange:q=>R(I,Number(q.target.value)),onClick:q=>q.stopPropagation(),children:[m.jsx("option",{value:1,children:"1px"}),m.jsx("option",{value:2,children:"2px"}),m.jsx("option",{value:3,children:"3px"}),m.jsx("option",{value:4,children:"4px"}),m.jsx("option",{value:5,children:"5px"})]}),m.jsxs("div",{style:rt,children:[m.jsx("div",{style:{...ot,backgroundColor:V.lineColor},onClick:q=>{q.currentTarget.nextSibling?.click()}}),m.jsx("input",{type:"color",style:dt,value:V.lineColor,onChange:q=>x(I,q.target.value),onClick:q=>q.stopPropagation()})]}),S()&&o.params&&m.jsx("button",{onClick:()=>C(I),style:o.params.length<=1?bt:pt,disabled:!o.params||o.params.length<=1,type:"button",title:o.params.length<=1?n.modal?.keepAtLeastOne||"至少保留一个参数":n.modal?.deleteParameter||"删除此参数",children:"×"})]},`${o.id}-${I}`))}),S()&&m.jsxs("button",{onClick:_,style:mt,type:"button",children:["+ ",n.modal?.addParameter||"添加参数"]}),m.jsxs("div",{style:At,children:[m.jsx("button",{onClick:X,style:Et,type:"button",children:n.systemSettings?.cancel||"取消"}),m.jsx("button",{onClick:L,style:Rt,type:"button",children:n.systemSettings?.confirm||"确定"})]}),m.jsxs("div",{style:yt,children:[n.tooltips?.ctrlEnterToConfirm||"Ctrl+Enter: 确认",", ",n.tooltips?.escToCancel||"Esc: 取消",", ",n.modal?.dragToMove||"拖动标题栏移动"]})]})]})})]}),document.body)};class Hn{constructor(t,e=[]){this._defaultIsCircular=!0,this._defaultFontSize=11,this._defaultPadding=2,this._defaultTextColor="white",this._defaultBackgroundColor="green",this._time=t,this._textItems=e}attached(t){this._chart=t.chart,this._series=t.series,t.requestUpdate()}updateAllViews(){}paneViews(){return this._renderer||(this._renderer={draw:t=>{const e=t.context??t._context;if(!e||!this._chart||!this._series)return;const i=this._chart.timeScale().timeToCoordinate(this._time);if(i==null)return;const r=this._series.data().find(n=>n.time===this._time);if(!r)return;const a=r.low;let s=this._series.priceToCoordinate(a);if(s!=null){s+=20,e.save();for(let n=0;n<this._textItems.length;n++){const o=this._textItems[n],h=s+n*40,l=o.fontSize??this._defaultFontSize,g="Arial";e.font=`${l}px ${g}`;const d=e.measureText(o.text).width,u=l,p=o.padding??this._defaultPadding,M=d+p*2,k=u+p*2,P=i-M/2,S=h-k/2;if(e.fillStyle=o.backgroundColor??this._defaultBackgroundColor,o.isCircular??this._defaultIsCircular){const _=Math.max(M,k)/2;e.beginPath(),e.arc(i,h,_,0,Math.PI*2),e.fill()}else e.fillRect(P,S,M,k);e.fillStyle=o.textColor??this._defaultTextColor,e.textAlign="center",e.textBaseline="middle",e.fillText(o.text,i,h)}e.restore()}}}),[{renderer:()=>this._renderer}]}addTextItem(t,e="white",i="blue",r=!1,a=this._defaultFontSize,s=this._defaultPadding){this._textItems.push({text:t,textColor:e,backgroundColor:i,isCircular:r,fontSize:a,padding:s}),this._chart&&this._chart.requestUpdate()}setTextItems(t){this._textItems=t,this._chart&&this._chart.requestUpdate()}updateText(t,e){this._textItems[t]&&(this._textItems[t].text=e,this._chart&&this._chart.requestUpdate())}updateColors(t,e,i){this._textItems[t]&&(this._textItems[t].textColor=e,this._textItems[t].backgroundColor=i,this._chart&&this._chart.requestUpdate())}updateCircular(t,e){this._textItems[t]&&(this._textItems[t].isCircular=e,this._chart&&this._chart.requestUpdate())}removeTextItem(t){this._textItems[t]&&(this._textItems.splice(t,1),this._chart&&this._chart.requestUpdate())}clearTextItems(){this._textItems=[],this._chart&&this._chart.requestUpdate()}getTextItemCount(){return this._textItems.length}}class On{constructor(t,e=[]){this._defaultIsCircular=!0,this._defaultFontSize=11,this._defaultPadding=2,this._defaultTextColor="white",this._defaultBackgroundColor="red",this._time=t,this._textItems=e}attached(t){this._chart=t.chart,this._series=t.series,t.requestUpdate()}updateAllViews(){}paneViews(){return this._renderer||(this._renderer={draw:t=>{const e=t.context??t._context;if(!e||!this._chart||!this._series)return;const i=this._chart.timeScale().timeToCoordinate(this._time);if(i==null)return;const r=this._series.data().find(n=>n.time===this._time);if(!r)return;const a=r.high;let s=this._series.priceToCoordinate(a);if(s!=null){s-=20,e.save();for(let n=0;n<this._textItems.length;n++){const o=this._textItems[n],h=s-n*40,l=o.fontSize??this._defaultFontSize,g="Arial";e.font=`${l}px ${g}`;const d=e.measureText(o.text).width,u=l,p=o.padding??this._defaultPadding,M=d+p*2,k=u+p*2,P=i-M/2,S=h-k/2;if(e.fillStyle=o.backgroundColor??this._defaultBackgroundColor,o.isCircular??this._defaultIsCircular){const _=Math.max(M,k)/2;e.beginPath(),e.arc(i,h,_,0,Math.PI*2),e.fill()}else e.fillRect(P,S,M,k);e.fillStyle=o.textColor??this._defaultTextColor,e.textAlign="center",e.textBaseline="middle",e.fillText(o.text,i,h)}e.restore()}}}),[{renderer:()=>this._renderer}]}addTextItem(t,e="white",i="blue",r=!1,a=this._defaultFontSize,s=this._defaultPadding){this._textItems.push({text:t,textColor:e,backgroundColor:i,isCircular:r,fontSize:a,padding:s}),this._chart&&this._chart.requestUpdate()}setTextItems(t){this._textItems=t,this._chart&&this._chart.requestUpdate()}updateText(t,e){this._textItems[t]&&(this._textItems[t].text=e,this._chart&&this._chart.requestUpdate())}updateColors(t,e,i){this._textItems[t]&&(this._textItems[t].textColor=e,this._textItems[t].backgroundColor=i,this._chart&&this._chart.requestUpdate())}updateCircular(t,e){this._textItems[t]&&(this._textItems[t].isCircular=e,this._chart&&this._chart.requestUpdate())}removeTextItem(t){this._textItems[t]&&(this._textItems.splice(t,1),this._chart&&this._chart.requestUpdate())}clearTextItems(){this._textItems=[],this._chart&&this._chart.requestUpdate()}getTextItemCount(){return this._textItems.length}}var _e=(f=>(f.Top="Top",f.Bottom="Bottom",f))(_e||{}),Yi=(f=>(f.Text="Text",f.Arrow="Arrow",f))(Yi||{});class jn{constructor(){this._marks=[],this._tolerance=1440*60*1e3,this._timeframe="1d",this._chartSeries=null}autoDetectTimeframe(t){if(!t||t.length<2)return"1d";const e=[];for(let r=1;r<Math.min(t.length,10);r++){const a=t[r].time-t[r-1].time;e.push(a)}const i=this.median(e);return i<=60*1e3?"1m":i<=300*1e3?"5m":i<=900*1e3?"15m":i<=3600*1e3?"1h":i<=14400*1e3?"4h":i<=1440*60*1e3?"1d":i<=10080*60*1e3?"1w":"1M"}median(t){if(t.length===0)return 0;t.sort((i,r)=>i-r);const e=Math.floor(t.length/2);return t.length%2?t[e]:(t[e-1]+t[e])/2}calculateTolerance(t){const e=t.slice(-1).toLowerCase(),i=parseInt(t.slice(0,-1))||1;switch(e){case"m":return Math.max(i*60*1e3,300*1e3);case"h":return i*60*60*1e3;case"d":return i*24*60*60*1e3;case"w":return i*7*24*60*60*1e3;case"M":return i*30*24*60*60*1e3;default:return 1440*60*1e3}}findClosestBarTime(t,e){const i=this.autoDetectTimeframe(t);i!==this._timeframe&&(this._timeframe=i,this._tolerance=this.calculateTolerance(i));let r=null,a=1/0;for(const s of t){const n=Math.abs(s.time-e);this._timeframe.endsWith("w")||this._timeframe.endsWith("M")?this.isInSameTimeUnit(s.time,e,this._timeframe)&&n<a&&(a=n,r=s.time):n<=this._tolerance&&n<a&&(a=n,r=s.time)}return r}isInSameTimeUnit(t,e,i){const r=new Date(t),a=new Date(e);if(i.endsWith("w")){const s=this.getWeekNumber(r),n=this.getWeekNumber(a);return s.year===n.year&&s.week===n.week}else if(i.endsWith("M"))return r.getFullYear()===a.getFullYear()&&r.getMonth()===a.getMonth();return!1}getWeekNumber(t){const e=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate())),i=e.getUTCDay()||7;e.setUTCDate(e.getUTCDate()+4-i);const r=new Date(Date.UTC(e.getUTCFullYear(),0,1));return{year:e.getUTCFullYear(),week:Math.ceil(((e.getTime()-r.getTime())/864e5+1)/7)}}addMark(t,e){this._chartSeries=e;const i=e.series.data();if(!i||i.length===0)return;const r=new Map;t.forEach(s=>{r.has(s.time)||r.set(s.time,[]),r.get(s.time).push(s)});const a=new Map;r.forEach((s,n)=>{const o=this.findClosestBarTime(i,n);o!==null&&(a.has(o)||a.set(o,[]),s.forEach(h=>{a.get(o).push({...h,time:o})}))}),a.forEach((s,n)=>{const o=new Map;s.forEach(h=>{const l=Object.values(Yi).find(g=>g===h.type);l&&(o.has(l)||o.set(l,[]),o.get(l).push(h))}),o.forEach((h,l)=>{const g=h.flatMap(u=>u.data),c=g.filter(u=>Object.values(_e).find(p=>p===u.direction)==="Top"),d=g.filter(u=>Object.values(_e).find(p=>p===u.direction)==="Bottom");c.length>0&&this.addTopMark([{time:n,type:l,data:c}],l,e),d.length>0&&this.addBottomMark([{time:n,type:l,data:d}],l,e)})})}recalculateMarks(){this._chartSeries&&([...this._marks],this.clearAllMarks())}refreshTimeframe(){if(!this._chartSeries)return;const t=this._chartSeries.series.data();if(!t||t.length<2)return;const e=this.autoDetectTimeframe(t);e!==this._timeframe&&(this._timeframe=e,this._tolerance=this.calculateTolerance(e),this.recalculateMarks())}addTopMark(t,e,i){switch(e){case"Text":t.forEach(r=>{const a=r.data.map(n=>{const o={text:n.text};return n.textColor!==void 0&&(o.textColor=n.textColor),n.backgroundColor!==void 0&&(o.backgroundColor=n.backgroundColor),n.isCircular!==void 0&&(o.isCircular=n.isCircular),n.fontSize!==void 0&&(o.fontSize=n.fontSize),n.padding!==void 0&&(o.padding=n.padding),o}),s=new On(r.time,a);i.series.attachPrimitive(s),this._marks.push(s)});break;case"Arrow":break;default:return}}addBottomMark(t,e,i){switch(e){case"Text":t.forEach(r=>{const a=r.data.map(n=>{const o={text:n.text};return n.textColor!==void 0&&(o.textColor=n.textColor),n.backgroundColor!==void 0&&(o.backgroundColor=n.backgroundColor),n.isCircular!==void 0&&(o.isCircular=n.isCircular),n.fontSize!==void 0&&(o.fontSize=n.fontSize),n.padding!==void 0&&(o.padding=n.padding),o}),s=new Hn(r.time,a);i.series.attachPrimitive(s),this._marks.push(s)});break;case"Arrow":break;default:return}}removeAllMark(){this._marks=[]}getTolerance(){return this._tolerance}getTimeframe(){return this._timeframe}getMarkCount(){return this._marks.length}clearAllMarks(t){const e=t||this._chartSeries;e&&this._marks.forEach(i=>{e.series.detachPrimitive(i)}),this._marks=[]}destroy(){this.clearAllMarks(),this._chartSeries=null}}class Nn{calculateADX(t,e){if(t.length<e+1)return{ADX:[],PlusDI:[],MinusDI:[]};const i={ADX:[],PlusDI:[],MinusDI:[]},r=t.map(S=>S.time),a=[0],s=[0],n=[0];for(let S=1;S<t.length;S++){const _=t[S].high,C=t[S].low,A=t[S-1].high,x=t[S-1].low,R=t[S-1].close,U=Math.max(_-C,Math.abs(_-R),Math.abs(C-R));a.push(U);const L=_-A,X=x-C;L>X&&L>0?(s.push(L),n.push(0)):X>L&&X>0?(s.push(0),n.push(X)):(s.push(0),n.push(0))}const o=[],h=[],l=[];let g=a.slice(0,e).reduce((S,_)=>S+_,0),c=s.slice(0,e).reduce((S,_)=>S+_,0),d=n.slice(0,e).reduce((S,_)=>S+_,0);o.push(g),h.push(c),l.push(d);for(let S=e;S<a.length;S++)g=g-g/e+a[S],c=c-c/e+s[S],d=d-d/e+n[S],o.push(g),h.push(c),l.push(d);const u=[],p=[],M=[];for(let S=0;S<o.length;S++){if(o[S]===0){u.push(0),p.push(0),M.push(0);continue}const _=h[S]/o[S]*100,C=l[S]/o[S]*100;u.push(_),p.push(C);const A=_+C,x=A>0?Math.abs(_-C)/A*100:0;M.push(x)}const k=[];if(M.length>=e){let S=M.slice(0,e).reduce((_,C)=>_+C,0)/e;k.push(S);for(let _=e;_<M.length;_++)S=(S*(e-1)+M[_])/e,k.push(S)}const P=e;for(let S=0;S<k.length;S++){const _=P+S;_<t.length&&(i.ADX.push({time:r[_],value:Math.min(100,Math.max(0,k[S])),...t[_].isVirtual&&{color:"transparent"}}),S<u.length&&i.PlusDI.push({time:r[_],value:Math.min(100,Math.max(0,u[S])),...t[_].isVirtual&&{color:"transparent"}}),S<p.length&&i.MinusDI.push({time:r[_],value:Math.min(100,Math.max(0,p[S])),...t[_].isVirtual&&{color:"transparent"}}))}return i}calculate(t,e){return t.forEach(i=>{const r=this.calculateADX(e,i.paramValue);let a=[];switch(i.paramName){case"ADX":a=r.ADX;break;case"+DI":a=r.PlusDI;break;case"-DI":a=r.MinusDI;break}a.length>0&&(i.data=a)}),t}}class wt{constructor(t,e,i,r,a,s,n,o,h){this.id=t,this.size=e,this.vertPosition=i,this.indicatorType=r,this.chartInstance=a,this.paneInstance=s,this.theme=n,this.onSettingsClick=o,this.onCloseClick=h,this._infoElement=null}init(t,e){}createInfoElement(){if(!this.paneInstance)return;const t=this.paneInstance.getHTMLElement();if(!t)return;this._infoElement=document.createElement("div"),this._infoElement.className="chart-pane-info",this._infoElement.style.cssText=`
|
|
21
|
+
`,ht={position:"absolute",left:`${l.x}px`,top:`${l.y}px`,background:r?.toolbar?.background||"#fafafa",border:`1px solid ${r?.toolbar?.border||"#d9d9d9"}`,borderRadius:"8px",padding:"0",width:"400px",maxWidth:"90vw",height:"400px",maxHeight:"80vh",zIndex:1e4,boxShadow:"0 8px 24px rgba(0,0,0,0.3)",cursor:c?"grabbing":"default",userSelect:c?"none":"auto",display:"flex",flexDirection:"column"},ut={padding:"16px 16px 12px 16px",borderBottom:`1px solid ${r?.toolbar?.border||"#d9d9d9"}`,cursor:"grab",userSelect:"none",flexShrink:0},y={fontSize:"14px",fontWeight:"bold",color:r?.layout?.textColor||"#000000",margin:0},W={padding:"16px",flex:1,display:"flex",flexDirection:"column",overflow:"hidden"},nt={marginBottom:"16px",flex:1,overflowY:"auto",overflowX:"hidden",...j},ct={display:"flex",alignItems:"center",gap:"8px",marginBottom:"8px",padding:"8px",background:r?.toolbar?.background||"#fafafa",border:`1px solid ${r?.toolbar?.border||"#d9d9d9"}`,borderRadius:"4px"},it={fontSize:"12px",color:r?.layout?.textColor||"#000000",minWidth:"80px",fontWeight:"bold"},B={width:"60px",padding:"4px 8px",background:r?.toolbar?.background||"#fafafa",color:r?.layout?.textColor||"#000000",border:`1px solid ${r?.toolbar?.border||"#d9d9d9"}`,borderRadius:"4px",fontSize:"12px"},G={width:"60px",padding:"4px 8px",background:r?.toolbar?.background||"#fafafa",color:r?.layout?.textColor||"#000000",border:`1px solid ${r?.toolbar?.border||"#d9d9d9"}`,borderRadius:"4px",fontSize:"12px"},rt={display:"flex",alignItems:"center",gap:"4px",position:"relative"},ot={width:"24px",height:"24px",border:`1px solid ${r?.toolbar?.border||"#d9d9d9"}`,borderRadius:"4px",cursor:"pointer"},dt={position:"absolute",top:0,left:0,width:"24px",height:"24px",border:"none",background:"transparent",cursor:"pointer",opacity:0},pt={background:"transparent",border:"none",fontSize:"16px",cursor:"pointer",padding:"0",width:"20px",height:"20px",display:"flex",alignItems:"center",justifyContent:"center",color:r?.chart?.downColor||"#ff4d4f"},bt={...pt,color:`${r?.toolbar?.border||"#d9d9d9"}`,cursor:"not-allowed"},mt={width:"100%",background:"transparent",color:r?.chart?.lineColor||"#2962FF",border:`2px dashed ${r?.toolbar?.border||"#d9d9d9"}`,borderRadius:"4px",padding:"8px 16px",fontSize:"12px",cursor:"pointer",marginBottom:"16px",flexShrink:0};({...mt,color:`${r?.toolbar?.border||"#d9d9d9"}`,borderColor:`${r?.toolbar?.border||"#d9d9d9"}`});const At={display:"flex",justifyContent:"flex-end",gap:"8px",flexShrink:0},Et={background:"transparent",color:r?.layout?.textColor||"#000000",border:`1px solid ${r?.toolbar?.border||"#d9d9d9"}`,borderRadius:"4px",padding:"6px 12px",fontSize:"12px",cursor:"pointer"},Rt={background:r?.toolbar?.button?.active||"#2962FF",color:r?.toolbar?.button?.activeTextColor||"#ffffff",border:"none",borderRadius:"4px",padding:"6px 12px",fontSize:"12px",cursor:"pointer"},yt={fontSize:"10px",color:`${r?.layout?.textColor||"#000000"}80`,marginTop:"8px",textAlign:"center",flexShrink:0},Ot={position:"fixed",top:0,left:0,right:0,bottom:0,zIndex:9999,background:"transparent"};return!f||!o?null:ue.createPortal(m.jsxs(E.Fragment,{children:[m.jsx("style",{children:st}),m.jsx("div",{style:Ot,onClick:$,children:m.jsxs("div",{ref:M,style:ht,onClick:V=>V.stopPropagation(),onMouseDown:at,onKeyDown:tt,children:[m.jsx("div",{ref:k,style:ut,onMouseDown:V=>{V.target===k.current&&V.preventDefault()},children:m.jsx("div",{style:y,children:K()})}),m.jsxs("div",{style:W,children:[m.jsx("div",{style:nt,className:"indicators-scrollbar",children:o.params?.map((V,I)=>m.jsxs("div",{style:ct,children:[m.jsx("div",{style:it,children:Z(I)}),m.jsx("input",{type:"number",style:B,value:V.paramValue,onChange:q=>A(I,Number(q.target.value)),onClick:q=>q.stopPropagation()}),m.jsxs("select",{style:G,value:V.lineWidth,onChange:q=>R(I,Number(q.target.value)),onClick:q=>q.stopPropagation(),children:[m.jsx("option",{value:1,children:"1px"}),m.jsx("option",{value:2,children:"2px"}),m.jsx("option",{value:3,children:"3px"}),m.jsx("option",{value:4,children:"4px"}),m.jsx("option",{value:5,children:"5px"})]}),m.jsxs("div",{style:rt,children:[m.jsx("div",{style:{...ot,backgroundColor:V.lineColor},onClick:q=>{q.currentTarget.nextSibling?.click()}}),m.jsx("input",{type:"color",style:dt,value:V.lineColor,onChange:q=>x(I,q.target.value),onClick:q=>q.stopPropagation()})]}),S()&&o.params&&m.jsx("button",{onClick:()=>C(I),style:o.params.length<=1?bt:pt,disabled:!o.params||o.params.length<=1,type:"button",title:o.params.length<=1?n.modal?.keepAtLeastOne||"至少保留一个参数":n.modal?.deleteParameter||"删除此参数",children:"×"})]},`${o.id}-${I}`))}),S()&&m.jsxs("button",{onClick:_,style:mt,type:"button",children:["+ ",n.modal?.addParameter||"添加参数"]}),m.jsxs("div",{style:At,children:[m.jsx("button",{onClick:X,style:Et,type:"button",children:n.systemSettings?.cancel||"取消"}),m.jsx("button",{onClick:L,style:Rt,type:"button",children:n.systemSettings?.confirm||"确定"})]}),m.jsxs("div",{style:yt,children:[n.tooltips?.ctrlEnterToConfirm||"Ctrl+Enter: 确认",", ",n.tooltips?.escToCancel||"Esc: 取消",", ",n.modal?.dragToMove||"拖动标题栏移动"]})]})]})})]}),document.body)};class Hn{constructor(t,e=[]){this._defaultIsCircular=!0,this._defaultFontSize=11,this._defaultPadding=2,this._defaultTextColor="white",this._defaultBackgroundColor="green",this._time=t,this._textItems=e}attached(t){this._chart=t.chart,this._series=t.series,t.requestUpdate()}updateAllViews(){}paneViews(){return this._renderer||(this._renderer={draw:t=>{const e=t.context??t._context;if(!e||!this._chart||!this._series)return;const i=this._chart.timeScale().timeToCoordinate(this._time);if(i==null)return;const r=this._series.data().find(n=>n.time===this._time);if(!r)return;const a=r.low;let s=this._series.priceToCoordinate(a);if(s!=null){s+=20,e.save();for(let n=0;n<this._textItems.length;n++){const o=this._textItems[n],h=s+n*40,l=o.fontSize??this._defaultFontSize,g="Arial";e.font=`${l}px ${g}`;const d=e.measureText(o.text).width,u=l,p=o.padding??this._defaultPadding,M=d+p*2,k=u+p*2,P=i-M/2,S=h-k/2;if(e.fillStyle=o.backgroundColor??this._defaultBackgroundColor,o.isCircular??this._defaultIsCircular){const _=Math.max(M,k)/2;e.beginPath(),e.arc(i,h,_,0,Math.PI*2),e.fill()}else e.fillRect(P,S,M,k);e.fillStyle=o.textColor??this._defaultTextColor,e.textAlign="center",e.textBaseline="middle",e.fillText(o.text,i,h)}e.restore()}}}),[{renderer:()=>this._renderer}]}addTextItem(t,e="white",i="blue",r=!1,a=this._defaultFontSize,s=this._defaultPadding){this._textItems.push({text:t,textColor:e,backgroundColor:i,isCircular:r,fontSize:a,padding:s}),this._chart&&this._chart.requestUpdate()}setTextItems(t){this._textItems=t,this._chart&&this._chart.requestUpdate()}updateText(t,e){this._textItems[t]&&(this._textItems[t].text=e,this._chart&&this._chart.requestUpdate())}updateColors(t,e,i){this._textItems[t]&&(this._textItems[t].textColor=e,this._textItems[t].backgroundColor=i,this._chart&&this._chart.requestUpdate())}updateCircular(t,e){this._textItems[t]&&(this._textItems[t].isCircular=e,this._chart&&this._chart.requestUpdate())}removeTextItem(t){this._textItems[t]&&(this._textItems.splice(t,1),this._chart&&this._chart.requestUpdate())}clearTextItems(){this._textItems=[],this._chart&&this._chart.requestUpdate()}getTextItemCount(){return this._textItems.length}}class On{constructor(t,e=[]){this._defaultIsCircular=!0,this._defaultFontSize=11,this._defaultPadding=2,this._defaultTextColor="white",this._defaultBackgroundColor="red",this._time=t,this._textItems=e}attached(t){this._chart=t.chart,this._series=t.series,t.requestUpdate()}updateAllViews(){}paneViews(){return this._renderer||(this._renderer={draw:t=>{const e=t.context??t._context;if(!e||!this._chart||!this._series)return;const i=this._chart.timeScale().timeToCoordinate(this._time);if(i==null)return;const r=this._series.data().find(n=>n.time===this._time);if(!r)return;const a=r.high;let s=this._series.priceToCoordinate(a);if(s!=null){s-=20,e.save();for(let n=0;n<this._textItems.length;n++){const o=this._textItems[n],h=s-n*40,l=o.fontSize??this._defaultFontSize,g="Arial";e.font=`${l}px ${g}`;const d=e.measureText(o.text).width,u=l,p=o.padding??this._defaultPadding,M=d+p*2,k=u+p*2,P=i-M/2,S=h-k/2;if(e.fillStyle=o.backgroundColor??this._defaultBackgroundColor,o.isCircular??this._defaultIsCircular){const _=Math.max(M,k)/2;e.beginPath(),e.arc(i,h,_,0,Math.PI*2),e.fill()}else e.fillRect(P,S,M,k);e.fillStyle=o.textColor??this._defaultTextColor,e.textAlign="center",e.textBaseline="middle",e.fillText(o.text,i,h)}e.restore()}}}),[{renderer:()=>this._renderer}]}addTextItem(t,e="white",i="blue",r=!1,a=this._defaultFontSize,s=this._defaultPadding){this._textItems.push({text:t,textColor:e,backgroundColor:i,isCircular:r,fontSize:a,padding:s}),this._chart&&this._chart.requestUpdate()}setTextItems(t){this._textItems=t,this._chart&&this._chart.requestUpdate()}updateText(t,e){this._textItems[t]&&(this._textItems[t].text=e,this._chart&&this._chart.requestUpdate())}updateColors(t,e,i){this._textItems[t]&&(this._textItems[t].textColor=e,this._textItems[t].backgroundColor=i,this._chart&&this._chart.requestUpdate())}updateCircular(t,e){this._textItems[t]&&(this._textItems[t].isCircular=e,this._chart&&this._chart.requestUpdate())}removeTextItem(t){this._textItems[t]&&(this._textItems.splice(t,1),this._chart&&this._chart.requestUpdate())}clearTextItems(){this._textItems=[],this._chart&&this._chart.requestUpdate()}getTextItemCount(){return this._textItems.length}}var _e=(f=>(f.Top="Top",f.Bottom="Bottom",f))(_e||{}),Yi=(f=>(f.Text="Text",f.Arrow="Arrow",f))(Yi||{});class jn{constructor(){this._marks=[],this._tolerance=1440*60*1e3,this._timeframe="1d",this._chartSeries=null}autoDetectTimeframe(t){if(!t||t.length<2)return"1d";const e=[];for(let r=1;r<Math.min(t.length,10);r++){const a=t[r].time-t[r-1].time;e.push(a)}const i=this.median(e);return i<=60*1e3?"1m":i<=300*1e3?"5m":i<=900*1e3?"15m":i<=3600*1e3?"1h":i<=14400*1e3?"4h":i<=1440*60*1e3?"1d":i<=10080*60*1e3?"1w":"1M"}median(t){if(t.length===0)return 0;t.sort((i,r)=>i-r);const e=Math.floor(t.length/2);return t.length%2?t[e]:(t[e-1]+t[e])/2}calculateTolerance(t){const e=t.slice(-1).toLowerCase(),i=parseInt(t.slice(0,-1))||1;switch(e){case"m":return Math.max(i*60*1e3,300*1e3);case"h":return i*60*60*1e3;case"d":return i*24*60*60*1e3;case"w":return i*7*24*60*60*1e3;case"M":return i*30*24*60*60*1e3;default:return 1440*60*1e3}}findClosestBarTime(t,e){const i=this.autoDetectTimeframe(t);i!==this._timeframe&&(this._timeframe=i,this._tolerance=this.calculateTolerance(i));let r=null,a=1/0;for(const s of t){const n=Math.abs(s.time-e);this._timeframe.endsWith("w")||this._timeframe.endsWith("M")?this.isInSameTimeUnit(s.time,e,this._timeframe)&&n<a&&(a=n,r=s.time):n<=this._tolerance&&n<a&&(a=n,r=s.time)}return r}isInSameTimeUnit(t,e,i){const r=new Date(t),a=new Date(e);if(i.endsWith("w")){const s=this.getWeekNumber(r),n=this.getWeekNumber(a);return s.year===n.year&&s.week===n.week}else if(i.endsWith("M"))return r.getFullYear()===a.getFullYear()&&r.getMonth()===a.getMonth();return!1}getWeekNumber(t){const e=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate())),i=e.getUTCDay()||7;e.setUTCDate(e.getUTCDate()+4-i);const r=new Date(Date.UTC(e.getUTCFullYear(),0,1));return{year:e.getUTCFullYear(),week:Math.ceil(((e.getTime()-r.getTime())/864e5+1)/7)}}addMark(t,e){if(!e||!e.series)return;this._chartSeries=e;const i=e.series.data();if(!i||i.length===0)return;const r=new Map;t.forEach(s=>{r.has(s.time)||r.set(s.time,[]),r.get(s.time).push(s)});const a=new Map;r.forEach((s,n)=>{const o=this.findClosestBarTime(i,n);o!==null&&(a.has(o)||a.set(o,[]),s.forEach(h=>{a.get(o).push({...h,time:o})}))}),a.forEach((s,n)=>{const o=new Map;s.forEach(h=>{const l=Object.values(Yi).find(g=>g===h.type);l&&(o.has(l)||o.set(l,[]),o.get(l).push(h))}),o.forEach((h,l)=>{const g=h.flatMap(u=>u.data),c=g.filter(u=>Object.values(_e).find(p=>p===u.direction)==="Top"),d=g.filter(u=>Object.values(_e).find(p=>p===u.direction)==="Bottom");c.length>0&&this.addTopMark([{time:n,type:l,data:c}],l,e),d.length>0&&this.addBottomMark([{time:n,type:l,data:d}],l,e)})})}recalculateMarks(){this._chartSeries&&([...this._marks],this.clearAllMarks())}refreshTimeframe(){if(!this._chartSeries)return;const t=this._chartSeries.series.data();if(!t||t.length<2)return;const e=this.autoDetectTimeframe(t);e!==this._timeframe&&(this._timeframe=e,this._tolerance=this.calculateTolerance(e),this.recalculateMarks())}addTopMark(t,e,i){switch(e){case"Text":t.forEach(r=>{const a=r.data.map(n=>{const o={text:n.text};return n.textColor!==void 0&&(o.textColor=n.textColor),n.backgroundColor!==void 0&&(o.backgroundColor=n.backgroundColor),n.isCircular!==void 0&&(o.isCircular=n.isCircular),n.fontSize!==void 0&&(o.fontSize=n.fontSize),n.padding!==void 0&&(o.padding=n.padding),o}),s=new On(r.time,a);i.series.attachPrimitive(s),this._marks.push(s)});break;case"Arrow":break;default:return}}addBottomMark(t,e,i){switch(e){case"Text":t.forEach(r=>{const a=r.data.map(n=>{const o={text:n.text};return n.textColor!==void 0&&(o.textColor=n.textColor),n.backgroundColor!==void 0&&(o.backgroundColor=n.backgroundColor),n.isCircular!==void 0&&(o.isCircular=n.isCircular),n.fontSize!==void 0&&(o.fontSize=n.fontSize),n.padding!==void 0&&(o.padding=n.padding),o}),s=new Hn(r.time,a);i.series.attachPrimitive(s),this._marks.push(s)});break;case"Arrow":break;default:return}}removeAllMark(){this._marks=[]}getTolerance(){return this._tolerance}getTimeframe(){return this._timeframe}getMarkCount(){return this._marks.length}clearAllMarks(t){const e=t||this._chartSeries;e&&this._marks.forEach(i=>{e.series.detachPrimitive(i)}),this._marks=[]}destroy(){this.clearAllMarks(),this._chartSeries=null}}class Nn{calculateADX(t,e){if(t.length<e+1)return{ADX:[],PlusDI:[],MinusDI:[]};const i={ADX:[],PlusDI:[],MinusDI:[]},r=t.map(S=>S.time),a=[0],s=[0],n=[0];for(let S=1;S<t.length;S++){const _=t[S].high,C=t[S].low,A=t[S-1].high,x=t[S-1].low,R=t[S-1].close,U=Math.max(_-C,Math.abs(_-R),Math.abs(C-R));a.push(U);const L=_-A,X=x-C;L>X&&L>0?(s.push(L),n.push(0)):X>L&&X>0?(s.push(0),n.push(X)):(s.push(0),n.push(0))}const o=[],h=[],l=[];let g=a.slice(0,e).reduce((S,_)=>S+_,0),c=s.slice(0,e).reduce((S,_)=>S+_,0),d=n.slice(0,e).reduce((S,_)=>S+_,0);o.push(g),h.push(c),l.push(d);for(let S=e;S<a.length;S++)g=g-g/e+a[S],c=c-c/e+s[S],d=d-d/e+n[S],o.push(g),h.push(c),l.push(d);const u=[],p=[],M=[];for(let S=0;S<o.length;S++){if(o[S]===0){u.push(0),p.push(0),M.push(0);continue}const _=h[S]/o[S]*100,C=l[S]/o[S]*100;u.push(_),p.push(C);const A=_+C,x=A>0?Math.abs(_-C)/A*100:0;M.push(x)}const k=[];if(M.length>=e){let S=M.slice(0,e).reduce((_,C)=>_+C,0)/e;k.push(S);for(let _=e;_<M.length;_++)S=(S*(e-1)+M[_])/e,k.push(S)}const P=e;for(let S=0;S<k.length;S++){const _=P+S;_<t.length&&(i.ADX.push({time:r[_],value:Math.min(100,Math.max(0,k[S])),...t[_].isVirtual&&{color:"transparent"}}),S<u.length&&i.PlusDI.push({time:r[_],value:Math.min(100,Math.max(0,u[S])),...t[_].isVirtual&&{color:"transparent"}}),S<p.length&&i.MinusDI.push({time:r[_],value:Math.min(100,Math.max(0,p[S])),...t[_].isVirtual&&{color:"transparent"}}))}return i}calculate(t,e){return t.forEach(i=>{const r=this.calculateADX(e,i.paramValue);let a=[];switch(i.paramName){case"ADX":a=r.ADX;break;case"+DI":a=r.PlusDI;break;case"-DI":a=r.MinusDI;break}a.length>0&&(i.data=a)}),t}}class wt{constructor(t,e,i,r,a,s,n,o,h){this.id=t,this.size=e,this.vertPosition=i,this.indicatorType=r,this.chartInstance=a,this.paneInstance=s,this.theme=n,this.onSettingsClick=o,this.onCloseClick=h,this._infoElement=null}init(t,e){}createInfoElement(){if(!this.paneInstance)return;const t=this.paneInstance.getHTMLElement();if(!t)return;this._infoElement=document.createElement("div"),this._infoElement.className="chart-pane-info",this._infoElement.style.cssText=`
|
|
22
22
|
position: absolute;
|
|
23
23
|
top: 5px;
|
|
24
24
|
left: 10px;
|
|
@@ -147,7 +147,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
147
147
|
.subchart-scrollbar::-webkit-scrollbar-thumb:hover {
|
|
148
148
|
background: ${r?.layout?.textColor||"#000000"}80;
|
|
149
149
|
}
|
|
150
|
-
`,st={position:"fixed",left:`${l.x}px`,top:`${l.y}px`,background:r?.toolbar?.background||"#fafafa",border:`1px solid ${r?.toolbar?.border||"#d9d9d9"}`,borderRadius:"8px",padding:"0",width:"450px",maxWidth:"90vw",height:"500px",maxHeight:"80vh",zIndex:1e4,boxShadow:"0 8px 24px rgba(0,0,0,0.3)",cursor:c?"grabbing":"default",userSelect:c?"none":"auto",display:"flex",flexDirection:"column"},ht={padding:"16px 16px 12px 16px",borderBottom:`1px solid ${r?.toolbar?.border||"#d9d9d9"}`,cursor:"grab",userSelect:"none",flexShrink:0},ut={fontSize:"14px",fontWeight:"bold",color:r?.layout?.textColor||"#000000",margin:0},y={padding:"16px",flex:1,display:"flex",flexDirection:"column",overflow:"hidden"},W={marginBottom:"16px",flex:1,overflowY:"auto",overflowX:"hidden",...tt},nt={display:"flex",alignItems:"center",gap:"8px",marginBottom:"8px",padding:"8px",background:r?.toolbar?.background||"#fafafa",border:`1px solid ${r?.toolbar?.border||"#d9d9d9"}`,borderRadius:"4px"},ct={fontSize:"12px",color:r?.layout?.textColor||"#000000",minWidth:"80px",fontWeight:"bold"},it={width:"80px",padding:"4px 8px",background:r?.toolbar?.background||"#fafafa",color:r?.layout?.textColor||"#000000",border:`1px solid ${r?.toolbar?.border||"#d9d9d9"}`,borderRadius:"4px",fontSize:"12px"},B={width:"60px",padding:"4px 8px",background:r?.toolbar?.background||"#fafafa",color:r?.layout?.textColor||"#000000",border:`1px solid ${r?.toolbar?.border||"#d9d9d9"}`,borderRadius:"4px",fontSize:"12px"},G={display:"flex",alignItems:"center",gap:"4px",position:"relative"},rt={width:"24px",height:"24px",border:`1px solid ${r?.toolbar?.border||"#d9d9d9"}`,borderRadius:"4px",cursor:"pointer"},ot={position:"absolute",top:0,left:0,width:"24px",height:"24px",border:"none",background:"transparent",cursor:"pointer",opacity:0},dt={background:"transparent",border:"none",fontSize:"16px",cursor:"pointer",padding:"0",width:"20px",height:"20px",display:"flex",alignItems:"center",justifyContent:"center",color:r?.chart?.downColor||"#ff4d4f"},pt={...dt,color:`${r?.toolbar?.border||"#d9d9d9"}`,cursor:"not-allowed"},bt={width:"100%",background:"transparent",color:r?.chart?.lineColor||"#2962FF",border:`2px dashed ${r?.toolbar?.border||"#d9d9d9"}`,borderRadius:"4px",padding:"8px 16px",fontSize:"12px",cursor:"pointer",marginBottom:"16px",flexShrink:0},mt={...bt,color:`${r?.toolbar?.border||"#d9d9d9"}`,cursor:"not-allowed",borderColor:`${r?.toolbar?.border||"#d9d9d9"}`},At={display:"flex",justifyContent:"flex-end",gap:"8px",flexShrink:0},Et={background:"transparent",color:r?.layout?.textColor||"#000000",border:`1px solid ${r?.toolbar?.border||"#d9d9d9"}`,borderRadius:"4px",padding:"6px 12px",fontSize:"12px",cursor:"pointer"},Rt={background:r?.toolbar?.button?.active||"#2962FF",color:r?.toolbar?.button?.activeTextColor||"#ffffff",border:"none",borderRadius:"4px",padding:"6px 12px",fontSize:"12px",cursor:"pointer"},yt={fontSize:"10px",color:`${r?.layout?.textColor||"#000000"}80`,marginTop:"8px",textAlign:"center",flexShrink:0},Ot={position:"fixed",top:0,left:0,right:0,bottom:0,zIndex:9999,background:"transparent"};if(!f||!o)return null;const V=Z(s);return ue.createPortal(m.jsxs(E.Fragment,{children:[m.jsx("style",{children:j}),m.jsx("div",{style:Ot,onClick:at,children:m.jsxs("div",{ref:M,style:st,onClick:I=>I.stopPropagation(),onMouseDown:K,onKeyDown:$,children:[m.jsx("div",{ref:k,style:ht,onMouseDown:I=>{I.target===k.current&&I.preventDefault()},children:m.jsxs("div",{style:ut,children:[P()," ",n.systemSettings?.setting||"设置"]})}),m.jsxs("div",{style:y,children:[m.jsx("div",{style:W,className:"subchart-scrollbar",children:o.map((I,q)=>m.jsxs("div",{style:nt,children:[m.jsx("div",{style:ct,children:I.paramName}),m.jsx("input",{type:"text",style:it,value:I.paramName,onChange:J=>C(q,J.target.value),onClick:J=>J.stopPropagation(),placeholder:n.modal?.parameterName||"参数名"}),m.jsx("input",{type:"number",style:it,value:I.paramValue,onChange:J=>A(q,Number(J.target.value)),onClick:J=>J.stopPropagation(),min:"1",max:"100",placeholder:n.modal?.parameterValue||"数值"}),m.jsxs("select",{style:B,value:I.lineWidth,onChange:J=>R(q,Number(J.target.value)),onClick:J=>J.stopPropagation(),children:[m.jsx("option",{value:1,children:"1px"}),m.jsx("option",{value:2,children:"2px"}),m.jsx("option",{value:3,children:"3px"}),m.jsx("option",{value:4,children:"4px"}),m.jsx("option",{value:5,children:"5px"})]}),m.jsxs("div",{style:G,children:[m.jsx("div",{style:{...rt,backgroundColor:I.lineColor},onClick:J=>{J.currentTarget.nextSibling?.click()}}),m.jsx("input",{type:"color",style:ot,value:I.lineColor,onChange:J=>x(q,J.target.value),onClick:J=>J.stopPropagation()})]}),V.allowDelete&&m.jsx("button",{onClick:()=>_(q),style:o.length<=V.minParams?pt:dt,disabled:o.length<=V.minParams,type:"button",title:o.length<=V.minParams?`${n.modal?.keepAtLeastOne||"至少保留"}${V.minParams}${n.modal?.parameterName||"个参数"}`:n.modal?.deleteParameter||"删除",children:"×"})]},`${I.paramName}-${q}`))}),m.jsx("button",{onClick:S,style:o.length>=V.maxParams||!V.allowAdd?mt:bt,disabled:o.length>=V.maxParams||!V.allowAdd,type:"button",title:o.length>=V.maxParams?`${n.modal?.maximumParameters||"最多允许"}${V.maxParams}${n.modal?.parameterName||"个参数"}`:V.allowAdd?n.modal?.addParameter||"添加参数":n.modal?.keepAtLeastOne||"不允许添加参数",children:o.length>=V.maxParams?`${n.modal?.maximumParameters||"已达到最大参数数量"}(${V.maxParams}${n.modal?.parameterName||"个"})`:V.allowAdd?`+ ${n.modal?.addParameter||"添加参数"}`:n.modal?.keepAtLeastOne||"不允许添加参数"}),m.jsxs("div",{style:At,children:[m.jsx("button",{onClick:X,style:Et,type:"button",children:n.systemSettings?.cancel||"取消"}),m.jsx("button",{onClick:L,style:Rt,type:"button",children:n.systemSettings?.confirm||"确定"})]}),m.jsxs("div",{style:yt,children:[n.tooltips?.ctrlEnterToConfirm||"Ctrl+Enter: 确认",", ",n.tooltips?.escToCancel||"Esc: 取消",", ",n.modal?.dragToMove||"拖动标题栏移动"]})]})]})})]}),document.body)};class Si{constructor(t){this.volumeSeries=null,this.refreshData=e=>{if(!this.volumeSeries)return;const i=e.props.chartData.map(r=>r.isVirtual?{time:r.time,value:r.volume,color:"rgba(0, 0, 0, 0)"}:{time:r.time,value:r.volume,color:r.close>=r.open?"rgba(38, 166, 154, 0.8)":"rgba(239, 83, 80, 0.8)"});i.length>0&&this.volumeSeries&&setTimeout(()=>{this.volumeSeries.setData(i)},0)},this.volumeSeries=t.props.chart.addSeries(et.HistogramSeries,{priceScaleId:"volume_bottom",color:"#26a69a"}),t.props.chart.priceScale("volume_bottom").applyOptions({scaleMargins:{top:.9,bottom:0}})}destroy(t){if(this.volumeSeries&&t.props.chart){try{t.props.chart.removeSeries(this.volumeSeries)}catch{}this.volumeSeries=null}}}class _i{constructor(t,e){this.candleSeries=null,this.refreshData=r=>{if(!this.candleSeries)return;const a=this.transformToCandlestickData(r.props.chartData);a.length>0&&setTimeout(()=>{this.candleSeries.setData(a)},0)},this.updateStyle=r=>{this.candleSeries&&this.candleSeries.applyOptions(r)},this.destroy=r=>{if(!this.candleSeries)return;if(!r||!r.props||!r.props.chart){this.candleSeries=null;return}const a=this.candleSeries;this.candleSeries=null;try{r.props.chart.removeSeries(a)}catch{}},this.candleSeries=t.props.chart.addSeries(et.CandlestickSeries,{upColor:e.chart.candleUpColor||"#26a69a",downColor:e.chart.candleDownColor||"#ef5350",borderVisible:!1,wickUpColor:e.chart.candleUpColor||"#26a69a",wickDownColor:e.chart.candleDownColor||"#ef5350",priceLineVisible:!0,lastValueVisible:!0,priceFormat:{type:"price",precision:2,minMove:.01}}),t.props.chart.priceScale("right").applyOptions({scaleMargins:{top:.05,bottom:.1}});const i=this.transformToCandlestickData(t.props.chartData);i.length>0&&this.candleSeries&&setTimeout(()=>{this.candleSeries.setData(i)},0)}transformToCandlestickData(t){return t.map(e=>e.isVirtual?{time:e.time,open:e.open,high:e.high,low:e.low,close:e.close,color:"rgba(0, 0, 0, 0)"}:{time:e.time,open:e.open,high:e.high,low:e.low,close:e.close})}getSeries(){return this.candleSeries}}class go{constructor(t,e){this.barSeries=null,this.theme=null,this.refreshData=r=>{if(!this.barSeries)return;const a=this.transformToBarData(r.props.chartData);a.length>0&&setTimeout(()=>{this.barSeries.setData(a)},0)},this.updateStyle=r=>{this.barSeries&&this.barSeries.applyOptions(r)},this.destroy=r=>{if(!this.barSeries)return;if(!r||!r.props||!r.props.chart){this.barSeries=null;return}const a=this.barSeries;this.barSeries=null;try{r.props.chart.removeSeries(a)}catch{}},this.barSeries=t.props.chart.addSeries(et.BarSeries,{upColor:e.chart.candleUpColor||"#26a69a",downColor:e.chart.candleDownColor||"#ef5350",thinBars:!0,priceLineVisible:!0,lastValueVisible:!0,priceFormat:{type:"price",precision:2,minMove:.01}}),this.theme=e,t.props.chart.priceScale("right").applyOptions({scaleMargins:{top:.05,bottom:.1}});const i=this.transformToBarData(t.props.chartData);i.length>0&&this.barSeries&&setTimeout(()=>{this.barSeries.setData(i)},0)}transformToBarData(t){return t.map(e=>{const i={time:e.time,open:Number(e.open),high:Number(e.high),low:Number(e.low),close:Number(e.close)};return e.isVirtual?{...i,color:"transparent",borderColor:"transparent"}:i})}getSeries(){return this.barSeries}}class po{constructor(t,e){this.lineSeries=null,this._lineWidht=2,this.refreshData=r=>{if(!this.lineSeries)return;const a=this.transformToLineData(r.props.chartData);a.length>0&&setTimeout(()=>{this.lineSeries.setData(a)},0)},this.updateStyle=r=>{this.lineSeries&&this.lineSeries.applyOptions(r)},this.destroy=r=>{if(!this.lineSeries)return;if(!r||!r.props||!r.props.chart){this.lineSeries=null;return}const a=this.lineSeries;this.lineSeries=null;try{r.props.chart.removeSeries(a)}catch{}},this.lineSeries=t.props.chart.addSeries(et.LineSeries,{color:e.chart.lineColor||"#2196F3",lineWidth:this._lineWidht,priceLineVisible:!0,lastValueVisible:!0,priceFormat:{type:"price",precision:2,minMove:.01}}),t.props.chart.priceScale("right").applyOptions({scaleMargins:{top:.05,bottom:.1}});const i=this.transformToLineData(t.props.chartData);i.length>0&&this.lineSeries&&setTimeout(()=>{this.lineSeries.setData(i)},0)}transformToLineData(t){return t.map(e=>({time:e.time,value:e.close}))}getSeries(){return this.lineSeries}}class fo{constructor(t,e){this.areaSeries=null,this.theme=null,this.refreshData=r=>{if(!this.areaSeries)return;const a=this.transformToAreaData(r.props.chartData);a.length>0&&setTimeout(()=>{this.areaSeries.setData(a)},0)},this.updateStyle=r=>{this.areaSeries&&this.areaSeries.applyOptions(r)},this.destroy=r=>{if(!this.areaSeries)return;if(!r||!r.props||!r.props.chart){this.areaSeries=null;return}const a=this.areaSeries;this.areaSeries=null;try{r.props.chart.removeSeries(a)}catch{}},this.areaSeries=t.props.chart.addSeries(et.AreaSeries,{topColor:e.chart.areaTopColor||"rgba(33, 150, 243, 0.4)",bottomColor:e.chart.areaBottomColor||"rgba(33, 150, 243, 0)",lineColor:e.chart.areaLineColor||"#2196F3",lineWidth:2,priceLineVisible:!0,lastValueVisible:!0,priceFormat:{type:"price",precision:2,minMove:.01}}),this.theme=e,t.props.chart.priceScale("right").applyOptions({scaleMargins:{top:.05,bottom:.1}});const i=this.transformToAreaData(t.props.chartData);i.length>0&&this.areaSeries&&setTimeout(()=>{this.areaSeries.setData(i)},0)}transformToAreaData(t){return t.map(e=>{const i={time:e.time,value:e.close};return e.isVirtual?{...i,color:"transparent",lineColor:"transparent",topColor:"transparent",bottomColor:"transparent"}:i})}getSeries(){return this.areaSeries}}class Mo{constructor(t,e){this.stepLineSeries=null,this.refreshData=r=>{if(!this.stepLineSeries)return;const a=this.transformToStepLineData(r.props.chartData);a.length>0&&setTimeout(()=>{this.stepLineSeries.setData(a)},0)},this.updateStyle=r=>{if(this.stepLineSeries){const a={...r,lineType:1};this.stepLineSeries.applyOptions(a)}},this.destroy=r=>{if(!this.stepLineSeries)return;if(!r||!r.props||!r.props.chart){this.stepLineSeries=null;return}const a=this.stepLineSeries;this.stepLineSeries=null;try{r.props.chart.removeSeries(a)}catch{}},this.stepLineSeries=t.props.chart.addSeries(et.LineSeries,{color:e.chart.stepLineColor||"#9C27B0",lineWidth:2,priceLineVisible:!0,lastValueVisible:!0,priceFormat:{type:"price",precision:2,minMove:.01}}),this.stepLineSeries.applyOptions({lineType:1}),t.props.chart.priceScale("right").applyOptions({scaleMargins:{top:.05,bottom:.1}});const i=this.transformToStepLineData(t.props.chartData);i.length>0&&this.stepLineSeries&&setTimeout(()=>{this.stepLineSeries.setData(i)},0)}transformToStepLineData(t){return t.map(e=>{const i={time:e.time,value:e.close};return e.isVirtual?{...i,color:"transparent"}:i})}getSeries(){return this.stepLineSeries}}class mo{constructor(t,e){this.series=null,this.refreshData=r=>{if(!this.series)return;const a=r.props.chartData.filter(o=>!o.isVirtual),s=a.length>0?a.reduce((o,h)=>o+h.close,0)/a.length:0;this.series.applyOptions({baseValue:{type:"price",price:s}});const n=r.props.chartData.map(o=>o.isVirtual?{time:o.time,value:o.close,topLineColor:"rgba(0, 0, 0, 0)",bottomLineColor:"rgba(0, 0, 0, 0)"}:{time:o.time,value:o.close});n.length>0&&this.series.setData(n)},this.updateStyle=r=>{this.series&&this.series.applyOptions(r)},this.destroy=r=>{if(!this.series)return;if(!r||!r.props||!r.props.chart){this.series=null;return}const a=this.series;this.series=null;try{r.props.chart.removeSeries(a)}catch{}},this.series=t.props.chart.addSeries(et.BaselineSeries,{baseValue:{type:"price",price:0},topLineColor:e.chart.candleUpColor||"#26a69a",topFillColor1:"rgba(0, 0, 0, 0)",topFillColor2:"rgba(0, 0, 0, 0)",bottomLineColor:e.chart.candleDownColor||"#ef5350",bottomFillColor1:"rgba(0, 0, 0, 0)",bottomFillColor2:"rgba(0, 0, 0, 0)",lineWidth:2,priceLineVisible:!0,lastValueVisible:!0,priceFormat:{type:"price",precision:2,minMove:.01}}),t.props.chart.priceScale("right").applyOptions({scaleMargins:{top:.05,bottom:.1}});const i=this.transformToBaselineData(t.props.chartData);i.length>0&&this.series&&setTimeout(()=>{this.series.setData(i)},0)}transformToBaselineData(t){const e=t.filter(r=>!r.isVirtual),i=e.length>0?e.reduce((r,a)=>r+a.close,0)/e.length:0;return this.series&&this.series.applyOptions({baseValue:{type:"price",price:i}}),t.map(r=>({time:r.time,value:r.close,...r.isVirtual&&{topLineColor:"rgba(0, 0, 0, 0)",bottomLineColor:"rgba(0, 0, 0, 0)"}}))}getSeries(){return this.series}}class ko{constructor(t,e){this.series=null,this.theme=null,this.refreshData=r=>{if(!this.series)return;const a=this.transformToHistogramData(r.props.chartData);a.length>0&&setTimeout(()=>{this.series.setData(a)},0)},this.updateStyle=r=>{this.series&&this.series.applyOptions(r)},this.destroy=r=>{if(!this.series)return;if(!r||!r.props||!r.props.chart){this.series=null;return}const a=this.series;this.series=null;try{r.props.chart.removeSeries(a)}catch{}},this.series=t.props.chart.addSeries(et.HistogramSeries,{color:e.chart.histogramColor||"#4CAF50",priceLineVisible:!0,lastValueVisible:!0,priceFormat:{type:"price",precision:2,minMove:.01}}),this.theme=e,t.props.chart.priceScale("right").applyOptions({scaleMargins:{top:.05,bottom:.1}});const i=this.transformToHistogramData(t.props.chartData);i.length>0&&this.series&&setTimeout(()=>{this.series.setData(i)},0)}transformToHistogramData(t){return t.map(e=>{const i={time:e.time,value:e.close};return e.isVirtual?{...i,color:"transparent"}:{...i,color:e.close>=(e.open||0)?this.theme?.chart.candleUpColor:this.theme?.chart.candleDownColor}})}getSeries(){return this.series}}class Po{constructor(t,e){this.series=null,this.theme=null,this.refreshData=r=>{if(!this.series)return;const a=this.transformToHollowCandlestickData(r.props.chartData);a.length>0&&setTimeout(()=>{this.series.setData(a)},0)},this.updateStyle=r=>{this.series&&this.series.applyOptions(r)},this.destroy=r=>{if(!this.series)return;if(!r||!r.props||!r.props.chart){this.series=null;return}const a=this.series;this.series=null;try{r.props.chart.removeSeries(a)}catch{}},this.series=t.props.chart.addSeries(et.CandlestickSeries,{upColor:"transparent",downColor:"transparent",borderUpColor:e.chart.candleUpColor||"#26a69a",borderDownColor:e.chart.candleDownColor||"#ef5350",wickUpColor:e.chart.candleUpColor||"#26a69a",wickDownColor:e.chart.candleDownColor||"#ef5350",priceLineVisible:!0,lastValueVisible:!0,priceFormat:{type:"price",precision:2,minMove:.01}}),t.props.chart.priceScale("right").applyOptions({scaleMargins:{top:.05,bottom:.1}});const i=this.transformToHollowCandlestickData(t.props.chartData);i.length>0&&this.series&&setTimeout(()=>{this.series.setData(i)},0)}transformToHollowCandlestickData(t){return t.map(e=>{const i=e.close>e.open,r={time:e.time,open:e.open,high:e.high,low:e.low,close:e.close};return e.isVirtual?{...r,color:"transparent",borderColor:"transparent",wickColor:"transparent"}:{...r,borderColor:i?this.theme?.chart.candleUpColor:this.theme?.chart.candleDownColor,wickColor:i?this.theme?.chart.candleUpColor:this.theme?.chart.candleDownColor}})}getSeries(){return this.series}}class So{constructor(t,e){this.series=null,this.refreshData=r=>{if(!this.series)return;const a=this.transformToHeikinAshiData(r.props.chartData);a.length>0&&setTimeout(()=>{this.series.setData(a)},0)},this.updateStyle=r=>{this.series&&this.series.applyOptions(r)},this.destroy=r=>{if(!this.series)return;if(!r||!r.props||!r.props.chart){this.series=null;return}const a=this.series;this.series=null;try{r.props.chart.removeSeries(a)}catch{}},this.series=t.props.chart.addSeries(et.CandlestickSeries,{upColor:e.chart.candleUpColor||"#26a69a",downColor:e.chart.candleDownColor||"#ef5350",borderVisible:!1,wickUpColor:e.chart.candleUpColor||"#26a69a",wickDownColor:e.chart.candleDownColor||"#ef5350",priceLineVisible:!0,lastValueVisible:!0,priceFormat:{type:"price",precision:2,minMove:.01}}),t.props.chart.priceScale("right").applyOptions({scaleMargins:{top:.05,bottom:.1}});const i=this.transformToHeikinAshiData(t.props.chartData);i.length>0&&this.series&&setTimeout(()=>{this.series.setData(i)},0)}transformToHeikinAshiData(t){if(t.length===0)return[];const e=[];let i=null;for(let r=0;r<t.length;r++){const a=t[r];if(a.isVirtual){e.push({time:a.time,open:a.open,high:a.high,low:a.low,close:a.close,color:"rgba(0, 0, 0, 0)"});continue}let s,n,o,h;i===null?(s=(a.open+a.close)/2,h=(a.open+a.high+a.low+a.close)/4,n=a.high,o=a.low):(s=(i.open+i.close)/2,h=(a.open+a.high+a.low+a.close)/4,n=Math.max(a.high,s,h),o=Math.min(a.low,s,h));const l={time:a.time,open:s,high:n,low:o,close:h};e.push(l),i={open:s,close:h}}return e}getSeries(){return this.series}}class _o{constructor(t,e){this.series=null,this.lineCount=3,this.globalChartData=[],this.refreshData=r=>{if(!this.series)return;const a=r.props.chartData.map(s=>s.isVirtual?{time:s.time,value:s.close,color:"rgba(0, 0, 0, 0)"}:{time:s.time,value:s.close});a.length>0&&this.series.setData(a)},this.updateStyle=r=>{this.series&&this.series.applyOptions(r)},this.destroy=r=>{if(!this.series)return;if(!r||!r.props||!r.props.chart){this.series=null;return}const a=this.series;this.series=null;try{r.props.chart.removeSeries(a)}catch{}},this.series=t.props.chart.addSeries(et.LineSeries,{color:e.chart.lineColor||"#2196F3",lineWidth:2,priceLineVisible:!0,lastValueVisible:!0,priceFormat:{type:"price",precision:2,minMove:.01}}),this.globalChartData=t.props.chartData;const i=this.generateLineBreakData(this.globalChartData);i.length>0&&this.series&&setTimeout(()=>{this.series.setData(i)},0)}generateLineBreakData(t){if(t.length===0)return[];const e=[];let i=[];for(let r=0;r<t.length;r++){const a=t[r].close;if(e.length===0){e.push({time:t[r].time,value:a}),i.push(a);continue}(a>Math.max(...i)||a<Math.min(...i))&&(e.push({time:t[r].time,value:a}),i.push(a),i.length>this.lineCount&&i.shift())}return e}getSeries(){return this.series}setLineCount(t){this.lineCount=t}}class Co{constructor(t,e){this.series=null,this.refreshData=r=>{if(!this.series)return;const a=r.props.chartData.map(s=>s.isVirtual?{time:s.time,value:s.close,lineColor:"rgba(0, 0, 0, 0)",topColor:"rgba(0, 0, 0, 0)",bottomColor:"rgba(0, 0, 0, 0)"}:{time:s.time,value:s.close});a.length>0&&this.series.setData(a)},this.updateStyle=r=>{this.series&&this.series.applyOptions(r)},this.destroy=r=>{if(!this.series)return;if(!r||!r.props||!r.props.chart){this.series=null;return}const a=this.series;this.series=null;try{r.props.chart.removeSeries(a)}catch{}},this.series=t.props.chart.addSeries(et.AreaSeries,{topColor:e.chart.areaTopColor||"rgba(33, 150, 243, 0.4)",bottomColor:e.chart.areaBottomColor||"rgba(33, 150, 243, 0)",lineColor:e.chart.areaLineColor||"#2196F3",lineWidth:2,priceLineVisible:!0,lastValueVisible:!0,priceFormat:{type:"price",precision:2,minMove:.01}}),t.props.chart.priceScale("right").applyOptions({scaleMargins:{top:.05,bottom:.1}});const i=this.transformToMountainData(t.props.chartData);i.length>0&&this.series&&setTimeout(()=>{this.series.setData(i)},0)}transformToMountainData(t){return t.map(e=>({time:e.time,value:e.close,...e.isVirtual&&{lineColor:"rgba(0, 0, 0, 0)",topColor:"rgba(0, 0, 0, 0)",bottomColor:"rgba(0, 0, 0, 0)"}}))}getSeries(){return this.series}}class bo{constructor(t,e){this.series=null,this.refreshData=r=>{if(!this.series)return;const a=r.props.chartData.map(s=>{if(s.isVirtual)return{time:s.time,open:s.open,high:s.high,low:s.low,close:s.close,color:"rgba(0, 0, 0, 0)",wickUpColor:"rgba(0, 0, 0, 0)",wickDownColor:"rgba(0, 0, 0, 0)",borderColor:"rgba(0, 0, 0, 0)"};{const n=s.close>=s.open,o=n?s.close:s.open,h=n?s.open:s.close;return{time:s.time,open:h,high:s.high,low:s.low,close:o,wickUpColor:"rgba(0, 0, 0, 0)",wickDownColor:"rgba(0, 0, 0, 0)",borderVisible:!1}}});a.length>0&&this.series.setData(a)},this.updateStyle=r=>{this.series&&this.series.applyOptions(r)},this.destroy=r=>{if(!this.series)return;if(!r||!r.props||!r.props.chart){this.series=null;return}const a=this.series;this.series=null;try{r.props.chart.removeSeries(a)}catch{}},this.series=t.props.chart.addSeries(et.CandlestickSeries,{upColor:e.chart.candleUpColor||"#26a69a",downColor:e.chart.candleDownColor||"#ef5350",borderVisible:!1,wickUpColor:"rgba(0, 0, 0, 0)",wickDownColor:"rgba(0, 0, 0, 0)",priceLineVisible:!0,lastValueVisible:!0,priceFormat:{type:"price",precision:2,minMove:.01}}),t.props.chart.priceScale("right").applyOptions({scaleMargins:{top:.05,bottom:.1}});const i=this.transformToHighLowData(t.props.chartData);i.length>0&&this.series&&setTimeout(()=>{this.series.setData(i)},0)}transformToHighLowData(t){return t.map(e=>{if(e.isVirtual)return{time:e.time,open:e.open,high:e.high,low:e.low,close:e.close,color:"rgba(0, 0, 0, 0)",wickUpColor:"rgba(0, 0, 0, 0)",wickDownColor:"rgba(0, 0, 0, 0)",borderColor:"rgba(0, 0, 0, 0)"};{const i=e.close>=e.open,r=i?e.close:e.open,a=i?e.open:e.close;return{time:e.time,open:a,high:e.high,low:e.low,close:r,wickUpColor:"rgba(0, 0, 0, 0)",wickDownColor:"rgba(0, 0, 0, 0)",borderVisible:!1}}})}getSeries(){return this.series}}class To{constructor(t,e){this.series=null,this._chart=null,this._renderer=null,this._chartData=[],this._width=0,this._height=0,this._isAttached=!1,this.channelWidthPercent=.3,this._timeScale=null,this._lineWidth=2,this.refreshData=r=>{if(!this.series)return;this._chartData=r.props.chartData||[];const a=this.transformToBaselineData(r.props.chartData);a.length>0&&this.series.setData(a),this.requestUpdate()},this.updateStyle=r=>{this.series&&this.series.applyOptions(r)},this.destroy=r=>{if(!this.series)return;if(!r||!r.props||!r.props.chart){this.series=null;return}const a=this.series;this.series=null;try{r.props.chart.removeSeries(a)}catch{}},this._chartData=t.props.chartData||[],this._chart=t.props.chart,this._timeScale=this._chart.timeScale(),this.series=t.props.chart.addSeries(et.LineSeries,{color:e.chart.lineColor||"#2196F3",lineWidth:this._lineWidth,priceLineVisible:!0,lastValueVisible:!0,priceFormat:{type:"price",precision:2,minMove:.01}}),this.attachChannelRenderer(t),t.props.chart.priceScale("right").applyOptions({scaleMargins:{top:.05,bottom:.1}});const i=this.transformToBaselineData(t.props.chartData);i.length>0&&this.series&&setTimeout(()=>{this.series.setData(i),this.requestUpdate()},0)}attachChannelRenderer(t){t.props.chartSeries&&t.props.chartSeries.series&&(this.attached({chart:t.props.chart,series:t.props.chartSeries.series}),t.props.chartSeries.series.attachPrimitive(this),this._isAttached=!0)}transformToBaselineData(t){return t.filter(i=>!i.isVirtual).map(i=>({time:i.time,value:i.close}))}attached(t){this._chart=t.chart,this.requestUpdate()}updateAllViews(){this.requestUpdate()}time(){return this._chartData.length>0?this._chartData[0].time:0}priceValue(){return this._chartData.length>0?this._chartData[0].close:0}paneViews(){return this._renderer||(this._renderer={draw:t=>{const e=t.context??t._context;if(!e||!this._chart)return;const i=this._chart.chartElement();if(!i)return;const r=i.getBoundingClientRect();this._width=r.width,this._height=r.height-29,!(this._width<=0||this._height<=0)&&this.drawChannel(e)}}),[{renderer:()=>this._renderer}]}drawChannel(t){if(!this.series||!this._timeScale)return;const e=this._timeScale.getVisibleRange();if(!e)return;const i=this._chartData.filter(o=>!o.isVirtual&&o.time>=e.from&&o.time<=e.to);if(i.length<2)return;const r=i.map(o=>o.close),a=5,s=[];for(let o=0;o<r.length;o++){const h=Math.max(0,o-a+1),l=o+1,g=r.slice(h,l);s.push(g.reduce((c,d)=>c+d,0)/g.length)}const n=(Math.max(...s)-Math.min(...s))*this.channelWidthPercent;this.drawChannelLines(t,i,n)}drawChannelLines(t,e,i){t.save(),t.beginPath(),t.strokeStyle="#26a69a",t.lineWidth=this._lineWidth,t.setLineDash([]);let r=!0;for(const s of e){const n=this._timeScale.timeToCoordinate(s.time),o=s.close+i,h=this.series.priceToCoordinate(o);n===null||h===null||(r?(t.moveTo(n,h),r=!1):t.lineTo(n,h))}t.stroke(),t.restore(),t.save(),t.beginPath(),t.strokeStyle="rgba(255, 0, 0, 0.8)",t.lineWidth=this._lineWidth,t.setLineDash([]);let a=!0;for(const s of e){const n=this._timeScale.timeToCoordinate(s.time),o=s.close-i,h=this.series.priceToCoordinate(o);n===null||h===null||(a?(t.moveTo(n,h),a=!1):t.lineTo(n,h))}t.stroke(),t.restore(),this.drawChannelFill(t,e,i)}drawChannelFill(t,e,i){if(!(e.length<2)){t.save(),t.beginPath();for(let r=0;r<e.length;r++){const a=e[r],s=this._timeScale.timeToCoordinate(a.time),n=a.close+i,o=this.series.priceToCoordinate(n);s===null||o===null||(r===0?t.moveTo(s,o):t.lineTo(s,o))}for(let r=e.length-1;r>=0;r--){const a=e[r],s=this._timeScale.timeToCoordinate(a.time),n=this.series.priceToCoordinate(a.close);s===null||n===null||t.lineTo(s,n)}t.closePath(),t.fillStyle="rgba(38, 166, 154, 0.3)",t.fill(),t.restore(),t.save(),t.beginPath();for(let r=0;r<e.length;r++){const a=e[r],s=this._timeScale.timeToCoordinate(a.time),n=this.series.priceToCoordinate(a.close);s===null||n===null||(r===0?t.moveTo(s,n):t.lineTo(s,n))}for(let r=e.length-1;r>=0;r--){const a=e[r],s=this._timeScale.timeToCoordinate(a.time),n=a.close-i,o=this.series.priceToCoordinate(n);s===null||o===null||t.lineTo(s,o)}t.closePath(),t.fillStyle="rgba(239, 83, 80, 0.3)",t.fill(),t.restore()}}requestUpdate(){if(this._chart&&this._isAttached)try{this._chart._internal__paneUpdate&&this._chart._internal__paneUpdate()}catch{}}getSeries(){return this.series}setChannelWidth(t){this.channelWidthPercent=Math.max(.01,Math.min(1,t)),this.requestUpdate()}getChannelWidth(){return this.channelWidthPercent}}class wo{constructor(t,e){this.series=null,this.refreshData=r=>{if(!this.series)return;const a=r.props.chartData.filter(o=>!o.isVirtual),s=a.length>0?a.reduce((o,h)=>o+h.close,0)/a.length:0;this.series.applyOptions({baseValue:{type:"price",price:s}});const n=r.props.chartData.map(o=>o.isVirtual?{time:o.time,value:o.close,topLineColor:"rgba(0, 0, 0, 0)",topFillColor1:"rgba(0, 0, 0, 0)",topFillColor2:"rgba(0, 0, 0, 0)",bottomLineColor:"rgba(0, 0, 0, 0)",bottomFillColor1:"rgba(0, 0, 0, 0)",bottomFillColor2:"rgba(0, 0, 0, 0)"}:{time:o.time,value:o.close});n.length>0&&this.series.setData(n)},this.updateStyle=r=>{this.series&&this.series.applyOptions(r)},this.destroy=r=>{if(!this.series)return;if(!r||!r.props||!r.props.chart){this.series=null;return}const a=this.series;this.series=null;try{r.props.chart.removeSeries(a)}catch{}},this.series=t.props.chart.addSeries(et.BaselineSeries,{baseValue:{type:"price",price:0},topLineColor:e.chart.candleUpColor||"#26a69a",topFillColor1:"rgba(38, 166, 154, 0.28)",topFillColor2:"rgba(38, 166, 154, 0.05)",bottomLineColor:e.chart.candleDownColor||"#ef5350",bottomFillColor1:"rgba(239, 83, 80, 0.05)",bottomFillColor2:"rgba(239, 83, 80, 0.28)",priceLineVisible:!0,lastValueVisible:!0,priceFormat:{type:"price",precision:2,minMove:.01}}),t.props.chart.priceScale("right").applyOptions({scaleMargins:{top:.05,bottom:.1}});const i=this.transformToBaselineData(t.props.chartData);i.length>0&&this.series&&setTimeout(()=>{this.series.setData(i)},0)}transformToBaselineData(t){const e=t.filter(r=>!r.isVirtual),i=e.length>0?e.reduce((r,a)=>r+a.close,0)/e.length:0;return this.series&&this.series.applyOptions({baseValue:{type:"price",price:i}}),t.map(r=>({time:r.time,value:r.close,...r.isVirtual&&{topLineColor:"rgba(0, 0, 0, 0)",topFillColor1:"rgba(0, 0, 0, 0)",topFillColor2:"rgba(0, 0, 0, 0)",bottomLineColor:"rgba(0, 0, 0, 0)",bottomFillColor1:"rgba(0, 0, 0, 0)",bottomFillColor2:"rgba(0, 0, 0, 0)"}}))}getSeries(){return this.series}}class Ao{constructor(t,e){this.currentChart=null,this.currentType=null,this.chartLayer=t,this.theme=e}switchChartType(t){if(!(this.currentType===t&&this.currentChart))switch(this.destroyCurrentChart(),this.currentType=t,t){case z.Candle:this.currentChart=new _i(this.chartLayer,this.theme);break;case z.HollowCandle:this.currentChart=new Po(this.chartLayer,this.theme);break;case z.Bar:this.currentChart=new go(this.chartLayer,this.theme);break;case z.Line:this.currentChart=new po(this.chartLayer,this.theme);break;case z.Area:this.currentChart=new fo(this.chartLayer,this.theme);break;case z.StepLine:this.currentChart=new Mo(this.chartLayer,this.theme);break;case z.BaseLine:this.currentChart=new mo(this.chartLayer,this.theme);break;case z.Histogram:this.currentChart=new ko(this.chartLayer,this.theme);break;case z.HeikinAshi:this.currentChart=new So(this.chartLayer,this.theme);break;case z.LineBreak:this.currentChart=new _o(this.chartLayer,this.theme);break;case z.Mountain:this.currentChart=new Co(this.chartLayer,this.theme);break;case z.BaselineArea:this.currentChart=new wo(this.chartLayer,this.theme);break;case z.HighLow:this.currentChart=new bo(this.chartLayer,this.theme);break;case z.HLCArea:this.currentChart=new To(this.chartLayer,this.theme);break;default:console.warn(`Unknown chart type: ${t}`),this.currentChart=new _i(this.chartLayer,this.theme);break}}refreshData(){this.currentChart&&this.currentChart.refreshData(this.chartLayer)}updateStyle(t){this.currentChart&&this.currentChart.updateStyle(t)}getCurrentSeries(){return this.currentChart?this.currentChart.getSeries():null}getCurrentType(){return this.currentType}destroyCurrentChart(){this.currentChart&&(this.currentChart.destroy(this.chartLayer),this.currentChart=null)}destroy(){this.destroyCurrentChart(),this.currentType=null}}class vo{constructor(t,e,i,r){this._chart=null,this._series=null,this._renderer=null,this._chartData=[],this._width=0,this._height=0,this._isAttached=!1,this._menu=null,this._heatMapRect={x:0,y:0,width:0,height:0},this._contextMenuHandler=null,this._clickHandler=null,this._resizeHandler=null,this.refreshData=a=>{this._chartData=a.props.chartData||[],this.requestUpdate()},this._closeCallBack=r,this.initializeHeatMap(t,e,i)}initializeHeatMap(t,e,i){this._chartData=t.props.chartData||[],this._i18n=e,this._theme=i,t.props.chartSeries&&t.props.chartSeries.series&&(this.attached({chart:t.props.chart,series:t.props.chartSeries.series}),t.props.chartSeries.series.attachPrimitive(this),this._isAttached=!0,this.bindContextMenu(t.props.chart))}bindContextMenu(t){const e=t.chartElement();e&&(this._contextMenuHandler=i=>{this.isInHeatMapArea(i.offsetX,i.offsetY)&&(i.preventDefault(),this.showContextMenu(i.clientX,i.clientY))},this._clickHandler=i=>{this._menu&&!this._menu.contains(i.target)&&this.hideContextMenu()},this._resizeHandler=()=>this.updateHeatMapRect(),e.addEventListener("contextmenu",this._contextMenuHandler),document.addEventListener("click",this._clickHandler),window.addEventListener("resize",this._resizeHandler))}isInHeatMapArea(t,e){return this.updateHeatMapRect(),t>=this._heatMapRect.x&&t<=this._heatMapRect.x+this._heatMapRect.width&&e>=this._heatMapRect.y&&e<=this._heatMapRect.y+this._heatMapRect.height}updateHeatMapRect(){if(!this._chart)return;const t=this._chart.chartElement();if(!t)return;const e=t.getBoundingClientRect(),i=e.width*.25,r=e.width-i;this._heatMapRect={x:r,y:0,width:i,height:e.height-29}}showContextMenu(t,e){this.hideContextMenu(),this._menu=document.createElement("div"),this._menu.style.position="fixed",this._menu.style.left=`${t}px`,this._menu.style.top=`${e}px`,this._menu.style.background=this._theme?.panel.backgroundColor||"#FFFFFF",this._menu.style.border=`1px solid ${this._theme?.panel.borderColor||"#E1E5E9"}`,this._menu.style.borderRadius="4px",this._menu.style.boxShadow="0 2px 8px rgba(0,0,0,0.15)",this._menu.style.zIndex="1000",this._menu.style.padding="4px 0",this._menu.style.minWidth="120px",this._menu.style.fontFamily="Arial, sans-serif",this._menu.style.fontSize="14px";const i=document.createElement("button");i.textContent=this._i18n?.close||"Close",i.style.background="none",i.style.border="none",i.style.padding="6px 12px",i.style.width="100%",i.style.textAlign="left",i.style.cursor="pointer",i.style.color=this._theme?.modal.textColor||"#2D323D",i.style.transition="background-color 0.2s",i.addEventListener("mouseenter",()=>{i.style.backgroundColor=this._theme?.toolbar.button.hover||"#2D323D"}),i.addEventListener("mouseleave",()=>{i.style.backgroundColor="transparent"}),i.addEventListener("click",()=>{this.destroy(),this.hideContextMenu()}),this._menu.appendChild(i),document.body.appendChild(this._menu)}hideContextMenu(){this._menu&&(document.body.removeChild(this._menu),this._menu=null)}attached(t){this._chart=t.chart,this._series=t.series,this.requestUpdate(),setTimeout(()=>this.updateHeatMapRect(),0)}updateAllViews(){this.requestUpdate(),this.updateHeatMapRect()}time(){return this._chartData.length>0?this._chartData[0].time:0}priceValue(){return this._chartData.length>0?this._chartData[0].close:0}updateI18n(t){this._i18n=t}updateTheme(t){this._theme=t}paneViews(){return this._renderer||(this._renderer={draw:t=>{const e=t.context??t._context;if(!e||!this._chart)return;const i=this._chart.chartElement();if(!i)return;const r=i.getBoundingClientRect();this._width=r.width,this._height=r.height-29,!(this._width<=0||this._height<=0)&&(this.drawHeatMap(e),this.updateHeatMapRect())}}),[{renderer:()=>this._renderer}]}drawHeatMap(t){const e=this._chartData;if(!e||e.length===0)return;const i=e.filter(u=>!u.isVirtual&&u.volume);if(i.length===0)return;const r=Math.min(...i.map(u=>u.low)),s=Math.max(...i.map(u=>u.high))-r;if(s<=0)return;const n=this._width*.25,o=this._width-n,h=Math.min(200,Math.floor(this._height/2)),l=new Array(h).fill(0);i.forEach(u=>{const p=Math.min(h-1,Math.max(0,Math.floor((u.high-r)/s*h))),M=Math.min(h-1,Math.max(0,Math.floor((u.low-r)/s*h))),k=Math.max(1,p-M+1),P=u.volume/k;for(let S=M;S<=p;S++)l[S]+=P});const g=Math.max(...l);if(g===0)return;const c=2,d=this._height/h;t.save();for(let u=0;u<h;u++){const p=l[u];if(p===0)continue;const M=p/g,P=Math.max(M,.01),S=Math.max(c,n*P),_=Math.pow(P,.5);let C,A,x;if(_<.5){const K=_*2;C=Math.floor(0),A=Math.floor(165*K),x=Math.floor(255*(1-K)+255*K)}else{const K=(_-.5)*2;C=Math.floor(255*K),A=Math.floor(255*(1-K)),x=Math.floor(255*(1-K))}const R=.4+_*.6,U=`rgba(${C}, ${A}, ${x}, ${R})`,L=o+(n-S),X=this._height-(u+1)*d;t.fillStyle=U,t.fillRect(L,X,S,d)}t.restore()}requestUpdate(){if(this._chart&&this._isAttached)try{this._chart._internal__paneUpdate&&this._chart._internal__paneUpdate(),this._series&&this._series._internal__dataChanged&&this._series._internal__dataChanged()}catch{}}destroy(){const t=this._chart?.chartElement();if(t&&this._contextMenuHandler&&t.removeEventListener("contextmenu",this._contextMenuHandler),this._clickHandler&&document.removeEventListener("click",this._clickHandler),this._resizeHandler&&window.removeEventListener("resize",this._resizeHandler),this._series&&this._isAttached)try{this._series.detachPrimitive(this),this._isAttached=!1}catch{}this.hideContextMenu(),this._renderer=null,this._isAttached=!1,this._menu=null,this._contextMenuHandler=null,this._clickHandler=null,this._resizeHandler=null,this._closeCallBack?.()}reactivate(){if(this._chart&&this._series&&!this._isAttached)try{this._series.attachPrimitive(this),this._isAttached=!0,this.bindContextMenu(this._chart),this.requestUpdate()}catch{}}}class xo{constructor(t,e,i,r){this._chart=null,this._series=null,this._renderer=null,this._chartData=[],this._width=0,this._height=0,this._isAttached=!1,this._cachedProfile=null,this._lastDataHash="",this._widthProportion=.35,this._menu=null,this._profileRect={x:0,y:0,width:0,height:0},this._contextMenuHandler=null,this._clickHandler=null,this._resizeHandler=null,this.refreshData=a=>{this._chartData=a.props.chartData||[],this._cachedProfile=null,this.requestUpdate()},this._closeCallBack=r,this._config={profileWidth:.15,timeSlotMinutes:30,valueAreaPercent:.7,tickSize:.01,showInitialBalance:!0,showValueArea:!0,maxPriceLevels:80,simplifyTPO:!0},this.initializeMarketProfile(t,e,i)}initializeMarketProfile(t,e,i){this._chartData=t.props.chartData||[],this._i18n=e,this._theme=i,t.props.chartSeries&&t.props.chartSeries.series&&(this.attached({chart:t.props.chart,series:t.props.chartSeries.series}),t.props.chartSeries.series.attachPrimitive(this),this._isAttached=!0,this.bindContextMenu(t.props.chart))}bindContextMenu(t){const e=t.chartElement();e&&(this._contextMenuHandler=i=>{this.isInProfileArea(i.offsetX,i.offsetY)&&(i.preventDefault(),this.showContextMenu(i.clientX,i.clientY))},this._clickHandler=i=>{this._menu&&!this._menu.contains(i.target)&&this.hideContextMenu()},this._resizeHandler=()=>this.updateProfileRect(),e.addEventListener("contextmenu",this._contextMenuHandler),document.addEventListener("click",this._clickHandler),window.addEventListener("resize",this._resizeHandler))}isInProfileArea(t,e){return this.updateProfileRect(),t>=this._profileRect.x&&t<=this._profileRect.x+this._profileRect.width&&e>=this._profileRect.y&&e<=this._profileRect.y+this._profileRect.height}updateProfileRect(){if(!this._chart)return;const t=this._chart.chartElement();if(!t)return;const e=t.getBoundingClientRect(),i=e.width*this._widthProportion,r=0;this._profileRect={x:r,y:0,width:i,height:e.height-29}}showContextMenu(t,e){this.hideContextMenu(),this._menu=document.createElement("div"),this._menu.style.position="fixed",this._menu.style.left=`${t}px`,this._menu.style.top=`${e}px`,this._menu.style.background=this._theme?.panel.backgroundColor||"#FFFFFF",this._menu.style.border=`1px solid ${this._theme?.panel.borderColor||"#E1E5E9"}`,this._menu.style.borderRadius="4px",this._menu.style.boxShadow="0 2px 8px rgba(0,0,0,0.15)",this._menu.style.zIndex="1000",this._menu.style.padding="4px 0",this._menu.style.minWidth="120px",this._menu.style.fontFamily="Arial, sans-serif",this._menu.style.fontSize="14px";const i=document.createElement("button");i.textContent=this._i18n?.close||"Close",i.style.background="none",i.style.border="none",i.style.padding="6px 12px",i.style.width="100%",i.style.textAlign="left",i.style.cursor="pointer",i.style.color=this._theme?.modal.textColor||"#2D323D",i.style.transition="background-color 0.2s",i.addEventListener("mouseenter",()=>{i.style.backgroundColor=this._theme?.toolbar.button.hover||"#2D323D"}),i.addEventListener("mouseleave",()=>{i.style.backgroundColor="transparent"}),i.addEventListener("click",()=>{this.destroy(),this.hideContextMenu()}),this._menu.appendChild(i),document.body.appendChild(this._menu)}hideContextMenu(){this._menu&&(document.body.removeChild(this._menu),this._menu=null)}attached(t){this._chart=t.chart,this._series=t.series,this.requestUpdate(),setTimeout(()=>this.updateProfileRect(),0)}updateAllViews(){this.requestUpdate(),this.updateProfileRect()}time(){return this._chartData.length>0?this._chartData[0].time:0}priceValue(){return this._chartData.length>0?this._chartData[0].close:0}updateI18n(t){this._i18n=t}updateTheme(t){this._theme=t}paneViews(){return this._renderer||(this._renderer={draw:t=>{const e=t.context??t._context;if(!e||!this._chart)return;const i=this._chart.chartElement();if(!i)return;const r=i.getBoundingClientRect();this._width=r.width,this._height=r.height-29,!(this._width<=0||this._height<=0)&&(this.drawMarketProfile(e),this.updateProfileRect())}}),[{renderer:()=>this._renderer}]}drawMarketProfile(t){const e=this._chartData;if(!e||e.length===0)return;const i=this.getDataHash(e);if((!this._cachedProfile||this._lastDataHash!==i)&&(this._cachedProfile=this.calculateProfile(e),this._lastDataHash=i),!this._cachedProfile)return;const r=this._width*this._widthProportion;t.clearRect(0,0,r,this._height),this.drawProfileBars(t,this._cachedProfile,r),this._config.showValueArea&&this.drawValueArea(t,this._cachedProfile,r)}getDataHash(t){return t.length===0?"empty":`${t.length}_${t[0].time}_${t[t.length-1].time}`}calculateProfile(t){if(t.length===0)return null;const e=t.filter(c=>!c.isVirtual);if(e.length===0)return null;const i=Math.min(...e.map(c=>c.low)),r=Math.max(...e.map(c=>c.high)),a=r-i;if(a<=0)return null;const s=Math.min(this._config.maxPriceLevels,Math.floor(this._height/3)),n=a/s,o=[];for(let c=0;c<=s;c++)o.push({price:i+c*n,count:0,volume:0});e.forEach(c=>{const d=this.findPriceLevel(o,c.high),u=this.findPriceLevel(o,c.low);for(let p=u;p<=d;p++)o[p].count++,o[p].volume+=c.volume||0});const h=Math.max(...o.map(c=>c.count)),l=o.find(c=>c.count===h),g=this.calculateSimpleValueArea(o,this._config.valueAreaPercent);return{levels:o,minPrice:i,maxPrice:r,priceRange:a,poc:l?l.price:i+a/2,valueAreaHigh:g.high,valueAreaLow:g.low,maxCount:h}}findPriceLevel(t,e){const i=t[0].price,r=t[t.length-1].price,a=r-i;return e<=i?0:e>=r?t.length-1:Math.min(t.length-1,Math.max(0,Math.floor((e-i)/a*t.length)))}calculateSimpleValueArea(t,e){const r=t.reduce((l,g)=>l+g.count,0)*e,a=Math.max(...t.map(l=>l.count)),s=t.findIndex(l=>l.count===a);let n=0,o=s,h=s;for(;n<r&&(o<t.length-1||h>0);){let l=o<t.length-1?t[o+1].count:0,g=h>0?t[h-1].count:0;if(l>=g&&o<t.length-1)o++,n+=t[o].count;else if(h>0)h--,n+=t[h].count;else break}return{high:t[o].price,low:t[h].price}}drawProfileBars(t,e,i){const{levels:r,minPrice:a,maxPrice:s,priceRange:n,maxCount:o}=e;if(n<=0)return;t.save();const h=i,l=this._height/r.length;r.forEach(g=>{if(g.count===0)return;const c=(g.price-a)/n,d=this._height-c*this._height,u=g.count/o,p=l,M=this.getProfileColor(u);t.fillStyle=M;const k=Math.max(2,h*u*.8);t.fillRect(0,d-p/2,k,p)}),t.restore()}drawValueArea(t,e,i){const{valueAreaHigh:r,valueAreaLow:a,minPrice:s,maxPrice:n,priceRange:o,poc:h}=e;if(o<=0)return;const l=(r-s)/o,g=(a-s)/o,c=(h-s)/o,d=this._height-l*this._height,u=this._height-g*this._height,p=this._height-c*this._height;t.save(),t.fillStyle="rgba(255, 215, 0, 0.1)",t.fillRect(0,d,i,u-d),t.strokeStyle="rgba(255, 215, 0, 0.6)",t.lineWidth=1,t.setLineDash([3,2]),t.beginPath(),t.moveTo(0,d),t.lineTo(i,d),t.stroke(),t.beginPath(),t.moveTo(0,u),t.lineTo(i,u),t.stroke(),t.strokeStyle="rgba(255, 0, 0, 0.8)",t.setLineDash([]),t.lineWidth=1,t.beginPath(),t.moveTo(0,p),t.lineTo(i,p),t.stroke(),t.restore()}getProfileColor(t){return t<.3?"rgba(100, 150, 255, 0.4)":t<.6?"rgba(50, 100, 200, 0.6)":"rgba(0, 50, 150, 0.8)"}requestUpdate(){if(this._chart&&this._isAttached)try{this._chart._internal__paneUpdate&&this._chart._internal__paneUpdate(),this._series&&this._series._internal__dataChanged&&this._series._internal__dataChanged()}catch{}}destroy(){const t=this._chart?.chartElement();if(t&&this._contextMenuHandler&&t.removeEventListener("contextmenu",this._contextMenuHandler),this._clickHandler&&document.removeEventListener("click",this._clickHandler),this._resizeHandler&&window.removeEventListener("resize",this._resizeHandler),this._series&&this._isAttached)try{this._series.detachPrimitive(this),this._isAttached=!1}catch{}this.hideContextMenu(),this._renderer=null,this._isAttached=!1,this._menu=null,this._contextMenuHandler=null,this._clickHandler=null,this._resizeHandler=null,this._closeCallBack?.()}reactivate(){if(this._chart&&this._series&&!this._isAttached)try{this._series.attachPrimitive(this),this._isAttached=!0,this.bindContextMenu(this._chart),this.requestUpdate()}catch{}}}class Do extends E.Component{constructor(t){super(t),this.canvasRef=E.createRef(),this.containerRef=E.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.swtichMainChartType=()=>{this.mainChartManager?.switchChartType(this.props.currentMainChartType),this.mainChartManager?.refreshData(),this.updateStaticMark()},this.setCursorType=e=>{e&&this.setState({cursorType:e})},this.initializeMainChartIndicators=()=>{if(!this.mainChartTechnicalIndicatorManager)return;const{selectedMainChartIndicator:e}=this.props;e&&this.updateSelectedMainChartIndicators()},this.updateAllMainChartIndicatorData=()=>{const{selectedMainChartIndicators:e}=this.state;e.forEach(i=>{i.type!==null&&this.mainChartTechnicalIndicatorManager?.updateAllMainChartIndicatorData(this,i)})},this.updateMainChartIndicators=()=>{const{selectedMainChartIndicators:e}=this.state;e.forEach(i=>{i.type!==null&&(this.mainChartTechnicalIndicatorManager?.removeIndicator(this.props.chart,i.type),this.mainChartTechnicalIndicatorManager?.updateMainChartIndicator(this,i))})},this.updateSelectedMainChartIndicators=()=>{if(!this.mainChartTechnicalIndicatorManager||!this.props.chartData)return;const{selectedMainChartIndicator:e}=this.props;e&&(F.HEATMAP===e.type||F.MARKETPROFILE===e.type||this.setState(i=>{const r=i.selectedMainChartIndicators.some(o=>o.type===e.type);let a;r?a=i.selectedMainChartIndicators.map(o=>o.type===e.type?e:o):a=[...i.selectedMainChartIndicators,e];const s=a.map(o=>o.type).filter(o=>o!==null),n=Xt().map(o=>{if(o.type&&s.includes(o.type)){const h=a.find(l=>l.type===o.type);return{...o,visible:!0,params:h?.params||o.params}}return{...o,visible:!1}});return{selectedMainChartIndicators:a,selectedMainChartIndicatorTypes:s,modalConfirmChartInfoIndicators:n}},()=>{this.updateMainChartIndicators()}))},this.handleOpenIndicatorSettings=e=>{e.type&&this.setState({modalEditingChartInfoIndicator:e,isMainChartIndicatorsModalOpen:!0})},this.handleMainChartIndicatorsSettingConfirm=e=>{e.params&&(e.params=e.params.filter(i=>i.paramValue!==0));try{this.mainChartTechnicalIndicatorManager?.updateMainChartIndicator(this,e),this.setState(i=>({selectedMainChartIndicators:i.selectedMainChartIndicators.map(r=>r.type===e.type?e:r)})),this.setState({isMainChartIndicatorsModalOpen:!1,modalEditingChartInfoIndicator:null})}catch{this.setState({isMainChartIndicatorsModalOpen:!1,modalEditingChartInfoIndicator:null})}},this.handleRemoveIndicator=e=>{if(!(!e||!this.mainChartTechnicalIndicatorManager||!this.props.chart)){if(e===F.HEATMAP){setTimeout(()=>{this.volumeHeatMap&&(this.volumeHeatMap.destroy(),this.volumeHeatMap=null)},0);return}if(e===F.MARKETPROFILE){setTimeout(()=>{this.marketProfile&&(this.marketProfile.destroy(),this.marketProfile=null)},0);return}this.mainChartTechnicalIndicatorManager.removeIndicator(this.props.chart,e),this.setState(i=>({selectedMainChartIndicators:i.selectedMainChartIndicators.filter(r=>r.type!==e),selectedMainChartIndicatorTypes:i.selectedMainChartIndicatorTypes.filter(r=>r!==e)})),this.props.onMainChartIndicatorChange&&this.props.selectedMainChartIndicator?.type===e&&this.props.onMainChartIndicatorChange(null),this.props.onToolSelect&&this.props.selectedMainChartIndicator?.type===e&&this.props.onToolSelect("")}},this.setMockKLineMarkMode=()=>{this.chartMarkManager?.setMockKLineMarkMode(this)},this.initializeGraphManager=()=>{this.chartMarkManager?.initializeMarkManager(this)},this.initializeGraphManagerProps=()=>{this.chartMarkManager?.initializeMarkManagerProps(this)},this.destroyGraphManager=()=>{this.chartMarkManager?.destroyMarkManager()},this.showAllMark=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.showAllMarks()},this.hideAllMark=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.hideAllMarks()},this.clearAllMark=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.deleteAllMark()},this.setSchiffPitchforkMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setSchiffPitchforkMode(this)},this.setHeatMapMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setHeatMapMode(this)},this.setTextEditMarkMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setTextEditMarkMode(this)},this.setBubbleBoxMarkMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setBubbleBoxMarkMode(this)},this.setPinMarkMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setPinMarkMode(this)},this.setEmojiMarkMode=e=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setEmojiMarkMode(this,e)},this.setSignpostMarkMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setSignpostMarkMode(this)},this.setPriceNoteMarkMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setPriceNoteMarkMode(this)},this.setFlagMarkMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setFlagMarkMode(this)},this.setPriceLabelMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setPriceLabelMode(this)},this.setShortPositionMarkMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setShortPositionMarkMode(this)},this.setLongPositionMarkMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setLongPositionMarkMode(this)},this.setThickArrowLineMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setThickArrowLineMode(this)},this.setEraserMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setEraserMode(this)},this.setMarkerPenMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setMarkerPenMode(this)},this.setBrushMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setBrushMode(this)},this.setPenMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setPenMode(this)},this.setPencilMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setPencilMode(this)},this.setTimePriceRangeMarkMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setTimePriceRangeMarkMode(this)},this.setPriceRangeMarkMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setPriceRangeMarkMode(this)},this.setTimeRangeMarkMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setTimeRangeMarkMode(this)},this.setElliottTripleCombinationMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setElliottTripleCombinationMode(this)},this.setElliottDoubleCombinationMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setElliottDoubleCombinationMode(this)},this.setElliottTriangleMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setElliottTriangleMode(this)},this.setElliottCorrectiveMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setElliottCorrectiveMode(this)},this.setElliottImpulseMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setElliottImpulseMode(this)},this.setTriangleABCDMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setTriangleABCDMode(this)},this.setABCDMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setABCDMode(this)},this.setHeadAndShouldersMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setHeadAndShouldersMode(this)},this.setXABCDMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setXABCDMode(this)},this.setDoubleCurveMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setDoubleCurveMode(this)},this.setCurveMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setCurveMode(this)},this.setSectorMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setSectorMode(this)},this.setFibonacciExtensionBaseTimeMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setFibonacciExtensionBaseTimeMode(this)},this.setFibonacciExtensionBasePriceMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setFibonacciExtensionBasePriceMode(this)},this.setFibonacciChannelMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setFibonacciChannelMode(this)},this.setFibonacciFanMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setFibonacciFanMode(this)},this.setFibonacciWedgeMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setFibonacciWedgeMode(this)},this.setFibonacciSpiralMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setFibonacciSpiralMode(this)},this.setFibonacciCircleMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setFibonacciCircleMode(this)},this.setFibonacciArcMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setFibonacciArcMode(this)},this.setFibonacciRetracementMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setFibonacciRetracementMode(this)},this.setFibonacciTimeZoonMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setFibonacciTimeZoonMode(this)},this.setGannRectangleMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setGannRectangleMode(this)},this.setGannBoxMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setGannBoxMode(this)},this.setGannFanMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setGannFanMode(this)},this.setTriangleMarkMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setTriangleMarkMode(this)},this.setEllipseMarkMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setEllipseMarkMode(this)},this.setCircleMarkMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setCircleMarkMode(this)},this.setRectangleMarkMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setRectangleMarkMode(this)},this.setEnhancedAndrewPitchforkMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setEnhancedAndrewPitchforkMode(this)},this.setAndrewPitchforkMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setAndrewPitchforkMode(this)},this.setDisjointChannelMarkMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setDisjointChannelMarkMode(this)},this.setEquidistantChannelMarkMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setEquidistantChannelMarkMode(this)},this.setLinearRegressionChannelMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setLinearRegressionChannelMode(this)},this.setLineSegmentMarkMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setLineSegmentMarkMode(this)},this.setHorizontalLineMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setHorizontalLineMode(this)},this.setVerticalLineMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setVerticalLineMode(this)},this.setArrowLineMarkMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setArrowLineMarkMode(this)},this.setParallelChannelMarkMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setParallelChannelMarkMode(this)},this.showGraphMarkToolBar=e=>{if(this.state.selectedGraphMark&&this.state.selectedGraphMark.id===e.id||this.state.selectedGraphMark)return;let i={x:20,y:20};if(e.points.length>0){const r=e.points[0];i={x:Math.max(10,r.x-150),y:Math.max(10,r.y-80)}}this.setState({selectedGraphMark:e,markToolBarPosition:i,showGraphMarkToolBar:!0})},this.closeGraphMarkToolBar=()=>{this.setState({showGraphMarkToolBar:!1})},this.showTableMarkToolBar=e=>{if(this.state.selectedTableMark&&this.state.selectedTableMark.id===e.id||this.state.selectedTableMark)return;let i={x:20,y:20};if(e.points.length>0){const r=e.points[0];i={x:Math.max(10,r.x-150),y:Math.max(10,r.y-80)}}this.setState({selectedTableMark:e,markToolBarPosition:i,showTableMarkToolBar:!0})},this.closeTableMarkToolBar=()=>{this.setState({showTableMarkToolBar:!1})},this.showTextEditMarkToolBar=(e,i)=>{if(this.state.selectedTextEditMark&&this.state.selectedTextEditMark.id===e.id||this.state.selectedTextEditMark)return;let r={x:20,y:20};if(e.points.length>0){const a=e.points[0];r={x:Math.max(10,a.x-150),y:Math.max(10,a.y-80)}}this.setState({selectedTextEditMark:e,markToolBarPosition:r,showTextMarkToolBar:!0,isShowGrapTool:i})},this.closeTextMarkToolBar=()=>{this.setState({showTextMarkToolBar:!1})},this.handleMouseDown=e=>{this.chartEventManager?.mouseDown(this,e)},this.handleMouseUp=e=>{this.chartEventManager?.mouseUp(this,e)},this.handleMouseMove=e=>{this.chartEventManager?.mouseMove(this,e)},this.handleViewportShiftLeft=()=>{this.props.chart&&this.props.viewportManager&&this.props.viewportManager.scrollChart("left")},this.handleViewportShiftRight=()=>{this.props.chart&&this.props.viewportManager&&this.props.viewportManager.scrollChart("right")},this.handleZoomIn=()=>{this.props.viewportManager&&this.props.viewportManager.zoomIn()},this.handleZoomOut=()=>{this.props.viewportManager&&this.props.viewportManager.zoomOut()},this.openIndicatorsModal=()=>{this.setState({isMainChartIndicatorsModalOpen:!0})},this.handleToggleIndicator=e=>{e&&(this.mainChartTechnicalIndicatorManager?.isVisible(e)?this.mainChartTechnicalIndicatorManager?.hideIndicator(e):this.mainChartTechnicalIndicatorManager?.showIndicator(e))},this.renderChartInfo=()=>{const{currentTheme:e,title:i}=this.props,{currentOHLC:r,mousePosition:a,showOHLC:s,maIndicatorValues:n,emaIndicatorValues:o,bollingerBandsValues:h,ichimokuValues:l,donchianChannelValues:g,envelopeValues:c,vwapValue:d,selectedMainChartIndicators:u}=this.state;return m.jsx(Ln,{currentTheme:e,title:i,currentOHLC:r,mousePosition:a,showOHLC:s,onToggleOHLC:this.toggleOHLCVisibility,onOpenIndicatorsModal:this.openIndicatorsModal,onOpenIndicatorSettings:this.handleOpenIndicatorSettings,onRemoveIndicator:this.handleRemoveIndicator,onToggleIndicator:this.handleToggleIndicator,visibleIndicatorTypes:this.state.selectedMainChartIndicatorTypes,indicators:u,maIndicatorValues:n,emaIndicatorValues:o,bollingerBandsValues:h,ichimokuValues:l,donchianChannelValues:g,envelopeValues:c,vwapValue:d,i18n:this.props.i18n})},this.handleIndicatorsClose=()=>{this.setState({isMainChartIndicatorsModalOpen:!1,modalEditingChartInfoIndicator:null,selectedMainChartIndicators:[]})},this.setImageMarkMode=()=>{this.chartMarkManager?.imageMarkManager&&this.setState({isImageUploadModalOpen:!0})},this.handleImageConfirm=e=>{if(this.setSelectedImageUrl(e),this.setState({isImageUploadModalOpen:!1}),this.chartMarkManager?.imageMarkManager){this.chartMarkManager?.imageMarkManager.setSelectedImageUrl(e);const i=this.chartMarkManager?.imageMarkManager.startImageMarkMode();this.setState({isImageMarkMode:i.isImageMarkMode,imageMarkStartPoint:i.imageMarkStartPoint,currentImageMark:i.currentImageMark,currentMarkMode:w.Image})}},this.handleImageUploadClose=()=>{this.setState({isImageUploadModalOpen:!1}),this.props.onCloseDrawing&&this.props.onCloseDrawing()},this.setSelectedImageUrl=e=>{this.chartMarkManager?.imageMarkManager&&this.chartMarkManager?.imageMarkManager.setSelectedImageUrl(e),this.setState({selectedImageUrl:e})},this.handleChangeTextMarkFontColor=e=>{this.state.selectedTextEditMark&&this.currentMarkSettingsStyle&&this.currentMarkSettingsStyle.updateStyles({color:e})},this.handleChangeTextMarkStyle=e=>{let i=e.isBold,r=e.isItalic;this.state.selectedTextEditMark&&this.currentMarkSettingsStyle&&this.currentMarkSettingsStyle.updateStyles({isBold:i,isItalic:r})},this.handleChangeTextMarkFontSize=e=>{this.state.selectedTextEditMark&&this.currentMarkSettingsStyle&&this.currentMarkSettingsStyle.updateStyles({fontSize:e})},this.handleChangeTextMarkGraphColor=e=>{this.currentMarkSettingsStyle&&this.currentMarkSettingsStyle.updateStyles({graphColor:e})},this.handleChangeTextMarkGraphLineStyle=e=>{this.currentMarkSettingsStyle&&this.currentMarkSettingsStyle.updateStyles({graphLineStyle:e})},this.handleChangeTextMarkGraphLineWidth=e=>{this.currentMarkSettingsStyle&&this.currentMarkSettingsStyle.updateStyles({graphLineWidth:e})},this.handleDeleteTextEditMark=()=>{if(!this.state.selectedTextEditMark)return;const e=this.state.selectedTextEditMark,i=e.markType;this.chartMarkManager?.deleteMark(i,e.properties.originalMark),this.setState({selectedTextEditMark:null,markToolBarPosition:{x:20,y:20}})},this.handleTextMarkEditorSave=(e,i,r,a,s)=>{if(this.setState({isTextMarkEditorOpen:!1}),!!this.state.selectedTextEditMark&&(i&&this.handleChangeTextMarkFontColor(i),r&&this.handleChangeTextMarkFontSize(r),a&&this.handleChangeTextMarkStyle({isBold:a}),s&&this.handleChangeTextMarkStyle({isItalic:s}),e))switch(this.state.selectedTextEditMark.markType){case w.TextEdit:this.state.selectedTextEditMark.mark.updateText(e);break;case w.BubbleBox:this.state.selectedTextEditMark.mark.updateText(e);break;case w.Pin:this.state.selectedTextEditMark.mark.updateText(e);break;case w.SignPost:this.state.selectedTextEditMark.mark.updateText(e);break}},this.handleTextMarkEditorCancel=()=>{this.setState({isTextMarkEditorOpen:!1}),this.state.selectedTextEditMark},this.handleDeleteGraphMark=()=>{if(!this.state.selectedGraphMark)return;const e=this.state.selectedGraphMark;e.properties?.originalMark&&this.chartMarkManager?.deleteMark(e.markType,e.properties.originalMark),this.closeGraphMarkToolBar()},this.handleChangeGraphMarkColor=e=>{this.currentMarkSettingsStyle&&this.currentMarkSettingsStyle.updateStyles({color:e})},this.handleChangeGraphMarkStyle=e=>{this.currentMarkSettingsStyle&&this.currentMarkSettingsStyle.updateStyles({lineStyle:e})},this.handleChangeGraphMarkWidth=e=>{this.currentMarkSettingsStyle&&this.currentMarkSettingsStyle.updateStyles({lineWidth:e})},this.handleGraphToolbarDrag=e=>{this.setState({isGraphMarkToolbarDragging:!0,graphMarkToolbarDragStartPoint:e});const i=a=>{if(this.state.isGraphMarkToolbarDragging&&this.state.graphMarkToolbarDragStartPoint){const s=a.clientX-this.state.graphMarkToolbarDragStartPoint.x,n=a.clientY-this.state.graphMarkToolbarDragStartPoint.y;this.setState(o=>({markToolBarPosition:{x:Math.max(0,o.markToolBarPosition.x+s),y:Math.max(0,o.markToolBarPosition.y+n)},graphMarkToolbarDragStartPoint:{x:a.clientX,y:a.clientY}}))}},r=()=>{this.setState({isGraphMarkToolbarDragging:!1,graphMarkToolbarDragStartPoint:null}),document.removeEventListener("mousemove",i),document.removeEventListener("mouseup",r)};document.addEventListener("mousemove",i),document.addEventListener("mouseup",r)},this.handleKeyDown=e=>{this.chartEventManager?.handleKeyDown(this,e)},this.handleDocumentMouseUp=e=>{this.chartEventManager?.documentMouseUp(this,e)},this.handleDocumentMouseDown=e=>{this.chartEventManager?.documentMouseDown(this,e)},this.handleDocumentMouseMove=e=>{this.chartEventManager?.documentMouseMove(this,e)},this.handleDocumentMouseWheel=e=>{this.chartEventManager?.documentMouseWheel(this,e)},this.handleTextMarkToolBarDrag=e=>{this.setState({isTextMarkToolbar:!0,dragStartPoint:e});const i=a=>{if(this.state.isTextMarkToolbar&&this.state.dragStartPoint){const s=a.clientX-this.state.dragStartPoint.x,n=a.clientY-this.state.dragStartPoint.y;this.setState(o=>({markToolBarPosition:{x:Math.max(0,o.markToolBarPosition.x+s),y:Math.max(0,o.markToolBarPosition.y+n)},dragStartPoint:{x:a.clientX,y:a.clientY}}))}},r=()=>{this.setState({isTextMarkToolbar:!1,dragStartPoint:null}),document.removeEventListener("mousemove",i),document.removeEventListener("mouseup",r)};document.addEventListener("mousemove",i),document.addEventListener("mouseup",r)},this.getToolName=e=>"",this.toggleOHLCVisibility=()=>{this.setState(e=>({showOHLC:!e.showOHLC}))},this.renderMainChart=()=>m.jsx("canvas",{ref:this.canvasRef,style:{position:"absolute",top:0,left:0,width:"calc(100% - 60px)",height:"calc(100% - 60px)",pointerEvents:"none",zIndex:1}}),this.showSubChartSettingModal=(e=[],i)=>{this.setState({isSubChartIndicatorsSettingModalOpen:!0,subChartIndicatorsSettingModalParams:e,currentSubChartIndicatorType:i})},this.handleSubChartSettingClose=()=>{this.setState({isSubChartIndicatorsSettingModalOpen:!1,subChartIndicatorsSettingModalParams:[],currentSubChartIndicatorType:null})},this.handleSubChartSettingConfirm=e=>{this.state.currentSubChartIndicatorType&&this.chartPanesManager?.updateSettingsBySubChartIndicatorType(this.props.chartData,e,this.state.currentSubChartIndicatorType),this.handleSubChartSettingClose()},this.state={isDrawing:!1,drawingPoints:[],currentDrawing:null,drawingStartPoint:null,drawings:[],selectedTextEditMark:null,selectedTableMark:null,selectedGraphMark:null,markToolBarPosition:{x:20,y:20},isTextMarkToolbar:!1,dragStartPoint:null,history:[],historyIndex:-1,isDragging:!1,isResizing:!1,isRotating:!1,resizeHandle:null,isTextInputActive:!1,textInputPosition:null,textInputValue:"",textInputCursorVisible:!0,textInputCursorTimer:null,activePanel:null,editingTextId:null,isFirstTimeTextMode:!1,isEmojiInputActive:!1,emojiInputPosition:null,editingEmojiId:null,mousePosition:null,currentOHLC:null,showOHLC:!0,pendingEmojiMark:null,isTextMarkEditorOpen:!1,textMarkEditorPosition:{x:0,y:0},textMarkEditorInitialData:{text:"",color:"#000000",fontSize:14,isBold:!1,isItalic:!1},lineSegmentMarkStartPoint:null,arrowLineMarkStartPoint:null,parallelChannelMarkStartPoint:null,currentLineSegmentMark:null,currentArrowLineMark:null,currentParallelChannelMark:null,currentMarkMode:null,showGraphMarkToolBar:!1,showTableMarkToolBar:!1,showTextMarkToolBar:!1,isShowGrapTool:!1,isGraphMarkToolbarDragging:!1,graphMarkToolbarDragStartPoint:null,linearRegressionChannelStartPoint:null,currentLinearRegressionChannel:null,equidistantChannelMarkStartPoint:null,currentEquidistantChannelMark:null,disjointChannelMarkStartPoint:null,currentDisjointChannelMark:null,andrewPitchforkHandlePoint:null,andrewPitchforkBaseStartPoint:null,currentAndrewPitchfork:null,enhancedAndrewPitchforkHandlePoint:null,enhancedAndrewPitchforkBaseStartPoint:null,currentEnhancedAndrewPitchfork:null,rectangleMarkStartPoint:null,currentRectangleMark:null,circleMarkStartPoint:null,currentCircleMark:null,ellipseMarkStartPoint:null,currentEllipseMark:null,triangleMarkStartPoint:null,currentTriangleMark:null,gannFanStartPoint:null,currentGannFan:null,gannBoxStartPoint:null,currentGannBox:null,gannRectangleStartPoint:null,currentGannRectangle:null,fibonacciTimeZoonStartPoint:null,currentFibonacciTimeZoon:null,fibonacciRetracementStartPoint:null,currentFibonacciRetracement:null,fibonacciArcStartPoint:null,currentFibonacciArc:null,fibonacciCircleCenterPoint:null,currentFibonacciCircle:null,fibonacciSpiralCenterPoint:null,currentFibonacciSpiral:null,fibonacciWedgeCenterPoint:null,currentFibonacciWedge:null,fibonacciWedgeDrawingStep:0,fibonacciWedgePoints:[],fibonacciFanStartPoint:null,currentFibonacciFan:null,currentFibonacciChannel:null,isFibonacciChannelMode:!1,fibonacciChannelDrawingStep:0,fibonacciExtensionBasePricePoints:[],currentFibonacciExtensionBasePrice:null,fibonacciExtensionBaseTimePoints:[],currentFibonacciExtensionBaseTime:null,sectorPoints:[],currentSector:null,curveMarkStartPoint:null,currentCurveMark:null,doubleCurveMarkStartPoint:null,currentDoubleCurveMark:null,xabcdPoints:[],currentXABCDMark:null,headAndShouldersPoints:[],currentHeadAndShouldersMark:null,abcdPoints:[],currentABCDMark:null,triangleABCDPoints:[],currentTriangleABCDMark:null,elliottImpulsePoints:[],currentElliottImpulseMark:null,elliottCorrectivePoints:[],currentElliottCorrectiveMark:null,elliottTrianglePoints:[],currentElliottTriangleMark:null,elliottDoubleCombinationPoints:[],currentElliottDoubleCombinationMark:null,elliottTripleCombinationPoints:[],currentElliottTripleCombinationMark:null,timeRangeMarkStartPoint:null,currentTimeRangeMark:null,isTimeRangeMarkMode:!1,priceRangeMarkStartPoint:null,currentPriceRangeMark:null,isPriceRangeMarkMode:!1,timePriceRangeMarkStartPoint:null,currentTimePriceRangeMark:null,isTimePriceRangeMarkMode:!1,isPencilMode:!1,isPencilDrawing:!1,currentPencilMark:null,pencilPoints:[],isPenMode:!1,isPenDrawing:!1,currentPenMark:null,penPoints:[],isBrushMode:!1,isBrushDrawing:!1,currentBrushMark:null,brushPoints:[],isMarkerPenMode:!1,isMarkerPenDrawing:!1,currentMarkerPen:null,markerPenPoints:[],isEraserMode:!1,isErasing:!1,eraserHoveredMark:null,thickArrowLineMarkStartPoint:null,currentThickArrowLineMark:null,isImageMarkMode:!1,imageMarkStartPoint:null,currentImageMark:null,showImageModal:!1,selectedImageUrl:"",isImageUploadModalOpen:!1,isLongPositionMarkMode:!1,longPositionMarkStartPoint:null,currentLongPositionMark:null,longPositionDrawingPhase:"none",isLongPositionDragging:!1,dragTarget:null,dragPoint:null,adjustingMode:null,adjustStartData:null,isShortPositionMarkMode:!1,shortPositionMarkStartPoint:null,currentShortPositionMark:null,shortPositionDrawingPhase:"none",isShortPositionDragging:!1,shortPositionDragTarget:null,shortPositionDragPoint:null,shortPositionAdjustingMode:null,shortPositionAdjustStartData:null,isPriceLabelMarkMode:!1,priceLabelMarkPoint:null,currentPriceLabelMark:null,isPriceLabelDragging:!1,priceLabelDragTarget:null,isFlagMarkMode:!1,flagMarkPoint:null,currentFlagMark:null,isFlagDragging:!1,flagDragTarget:null,isPriceNoteMarkMode:!1,priceNoteMarkStartPoint:null,currentPriceNoteMark:null,isPriceNoteDragging:!1,priceNoteDragTarget:null,priceNoteDragPoint:null,isSignpostMarkMode:!1,signpostMarkPoint:null,currentSignpostMark:null,isSignpostDragging:!1,signpostDragTarget:null,isEmojiMarkMode:!1,emojiMarkStartPoint:null,currentEmojiMark:null,isEmojiDragging:!1,emojiDragTarget:null,emojiDragPoint:null,isPinMarkMode:!1,pinMarkPoint:null,currentPinMark:null,isPinDragging:!1,pinDragTarget:null,isBubbleBoxMarkMode:!1,bubbleBoxMarkPoints:null,currentBubbleBoxMark:null,isBubbleBoxDragging:!1,bubbleBoxDragTarget:null,bubbleBoxDragType:null,isTextEditMarkMode:!1,isTextEditDragging:!1,textEditDragTarget:null,isMainChartIndicatorsModalOpen:!1,selectedMainChartIndicators:[],selectedMainChartIndicatorTypes:[],modalEditingChartInfoIndicator:null,modalConfirmChartInfoIndicators:Xt(),maIndicatorValues:{},emaIndicatorValues:{},bollingerBandsValues:{},ichimokuValues:{},donchianChannelValues:{},envelopeValues:{},vwapValue:null,isSubChartIndicatorsSettingModalOpen:!1,subChartIndicatorsSettingModalParams:[],currentSubChartIndicatorType:null,isMockKLineMarkMode:!1,mockKLineMarkStartPoint:null,currentMockKLineMark:null,isMockKLineDragging:!1,mockKLineDragTarget:null,mockKLineDragPoint:null,isHeatMapMode:!1,heatMapStartPoint:null,currentHeatMap:null,isHeatMapDragging:!1,heatMapDragTarget:null,heatMapDragPoint:null,heatMapDrawingPhase:"none",heatMapAdjustingMode:null,isSchiffPitchforkMode:!1,schiffPitchforkHandlePoint:null,schiffPitchforkBaseStartPoint:null,currentSchiffPitchfork:null,isSchiffPitchforkDragging:!1,schiffPitchforkDragTarget:null,schiffPitchforkDragPoint:null,schiffPitchforkDrawingPhase:"none",schiffPitchforkAdjustingMode:null,cursorType:Pt.Crosshair,ai:this.props.ai||!1,aiconfigs:this.props.aiconfigs||[],currentAIFunctionType:this.props.currentAIFunctionType||null},this.chartEventManager=new Ei,this.chartMarkManager=new qs,this.chartMarkTextEditManager=new zs,this.mainChartTechnicalIndicatorManager=new In(this.props.currentTheme),this.initializeGraphManager(),this.staticMarkManager=new jn,this.chartPanesManager=new co,this.mainChartManager=new Ao(this,this.props.currentTheme)}componentDidMount(){this.setupCanvas(),this.setupAllDocumentEvents(),this.setupAllContainerEvents(),this.initializeMainChartIndicators(),this.chartMarkTextEditManager?.setupBubbleBoxMarkEvents(this),this.chartMarkTextEditManager?.setupSignPostMarkEvents(this),this.chartMarkTextEditManager?.setupPinMarkEvents(this),this.chartMarkTextEditManager?.setupTextEditMarkEvents(this),this.initStaticMark(),this.props.chart?this.chartEventManager?.registerCrosshairMoveEvent(this):setTimeout(()=>{this.props.chart&&this.chartEventManager?.registerCrosshairMoveEvent(this)},100),setTimeout(()=>{this.mainChartManager?.switchChartType(z.Candle),this.volume=new Si(this),this.props.chart&&this.chartPanesManager?.setChartInstance(this.props.chart)},50)}componentDidUpdate(t){(t.chartSeries!==this.props.chartSeries||t.chart!==this.props.chart)&&this.initializeGraphManagerProps(),t.i18n!==this.props.i18n&&(this.volumeHeatMap?.updateI18n(this.props.i18n),this.marketProfile?.updateI18n(this.props.i18n)),t.currentTheme!==this.props.currentTheme&&(this.volumeHeatMap?.updateTheme(this.props.currentTheme),this.marketProfile?.updateTheme(this.props.currentTheme)),t.ai!==this.props.ai&&this.props.ai&&this.setState({ai:this.props.ai}),t.aiconfigs!==this.props.aiconfigs&&this.props.aiconfigs&&this.setState({aiconfigs:this.props.aiconfigs}),t.currentAIFunctionType!==this.props.currentAIFunctionType&&this.props.currentAIFunctionType&&this.setState({currentAIFunctionType:this.props.currentAIFunctionType}),(t.timeframe!==this.props.timeframe||t.timezone!==this.props.timezone)&&this.volume&&(this.volume.destroy(this),this.volume=new Si(this),this.volume.refreshData(this)),this.hasChartDataChanged(t.chartData,this.props.chartData)?(setTimeout(()=>{this.updateStaticMark()},0),this.handleUpdateMainChartMaps(),this.updateAllMainChartIndicatorData(),this.chartPanesManager?.updateAllPaneData(this.props.chartData),this.volume?.refreshData(this),this.mainChartManager?.refreshData(),this.volumeHeatMap?.refreshData(this)):this.hasMainChartIndicatorChanged(t.selectedMainChartIndicator,this.props.selectedMainChartIndicator)&&(this.handleInitMainChartMaps(),this.updateSelectedMainChartIndicators(),this.chartPanesManager?.updateAllPaneData(this.props.chartData),this.volume?.refreshData(this),this.mainChartManager?.refreshData()),t.currentMainChartType!==this.props.currentMainChartType&&this.swtichMainChartType(),t.markData!==this.props.markData&&(this.staticMarkManager?.clearAllMarks(),this.updateStaticMark()),t.currentTheme!==this.props.currentTheme&&this.chartPanesManager?.updateAllPaneTheme(this.props.currentTheme),t.selectedSubChartIndicators!==this.props.selectedSubChartIndicators&&(this.chartPanesManager?.removeAllPane(),setTimeout(()=>{this.props.selectedSubChartIndicators.forEach(e=>{this.chartPanesManager?.addSubChart(this,e,i=>{this.showSubChartSettingModal(this.chartPanesManager?.getParamsByIndicatorType(i),i)},i=>{this.chartPanesManager?.removePaneBySubChartIndicatorType(i),this.props.handleRemoveSubChartIndicator&&this.props.handleRemoveSubChartIndicator(i)})})},0))}componentWillUnmount(){this.cleanupAllDocumentEvents(),document.removeEventListener("keydown",this.handleKeyDown),this.doubleClickTimeout&&clearTimeout(this.doubleClickTimeout),this.cleanupAllContainerEvents(),this.destroyGraphManager(),this.chartMarkTextEditManager?.cleanupBubbleBoxMarkEvents(),this.chartMarkTextEditManager?.cleanupSignPostMarkEvents(),this.chartMarkTextEditManager?.cleanupPinMarkEvents(),this.chartMarkTextEditManager?.cleanupTextEditMarkEvents(),this.volumeHeatMap?.destroy(),this.marketProfile?.destroy(),this.mainChartManager?.destroy(),this.volume?.destroy(this)}handleInitMainChartMaps(){this.props.selectedMainChartIndicator&&(this.props.selectedMainChartIndicator.type===F.HEATMAP&&(this.volumeHeatMap||(this.volumeHeatMap=new vo(this,this.props.i18n,this.props.currentTheme,()=>{this.volumeHeatMap=null}),this.volumeHeatMap?.refreshData(this))),this.props.selectedMainChartIndicator.type===F.MARKETPROFILE&&(this.marketProfile||(this.marketProfile=new xo(this,this.props.i18n,this.props.currentTheme,()=>{this.marketProfile=null}),this.marketProfile?.refreshData(this))))}handleUpdateMainChartMaps(){this.props.selectedMainChartIndicator&&(this.volumeHeatMap&&this.volumeHeatMap?.refreshData(this),this.marketProfile&&this.marketProfile?.refreshData(this))}hasChartDataChanged(t,e){if(t===e)return!1;if(!t||!e||t.length!==e.length)return!0;const i=Math.min(t.length,e.length,5);for(let r=0;r<i;r++)if(t[r].time!==e[r].time)return!0;return!1}hasMainChartIndicatorChanged(t,e){return t===e?!1:!t||!e?!0:t.type!==e.type||t.nonce!==e.nonce||JSON.stringify(t.params)!==JSON.stringify(e.params)}initStaticMark(){setTimeout(()=>{this.props.markData&&this.staticMarkManager?.addMark(this.props.markData,{series:this.mainChartManager?.getCurrentSeries(),type:"mark"})},200)}updateStaticMark(){this.props.markData&&this.staticMarkManager?.addMark(this.props.markData,{series:this.mainChartManager?.getCurrentSeries(),type:"mark"})}setupAllContainerEvents(){if(!this.containerRef.current)return;const t=this.containerRef.current;t.addEventListener("mousedown",this.handleMouseDown),t.addEventListener("mousemove",this.handleMouseMove),t.addEventListener("mouseup",this.handleMouseUp)}cleanupAllContainerEvents(){if(!this.containerRef.current)return;const t=this.containerRef.current;t.removeEventListener("mousedown",this.handleMouseDown),t.removeEventListener("mousemove",this.handleMouseMove),t.removeEventListener("mouseup",this.handleMouseUp)}setupAllDocumentEvents(){document.addEventListener("keydown",this.handleKeyDown),document.addEventListener("mousemove",this.handleDocumentMouseMove),document.addEventListener("mousedown",this.handleDocumentMouseDown),document.addEventListener("mouseup",this.handleDocumentMouseUp),document.addEventListener("wheel",this.handleDocumentMouseWheel)}cleanupAllDocumentEvents(){document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("mousemove",this.handleDocumentMouseMove),document.removeEventListener("mousedown",this.handleDocumentMouseDown),document.removeEventListener("mouseup",this.handleDocumentMouseUp),document.removeEventListener("wheel",this.handleDocumentMouseWheel)}serializeDrawings(){return JSON.stringify(this.allDrawings)}setupCanvas(){const t=this.canvasRef.current,e=this.containerRef.current;if(!t||!e)return;const i=e.getBoundingClientRect();t.width=i.width,t.height=i.height}getDrawingLayerElementsPosition(){const t=[];return this.containerRef.current&&(this.containerRef.current.querySelectorAll(".drawing-text-element").forEach(r=>{const a=r.getAttribute("data-text-id");if(a){const s=r,n=s.getBoundingClientRect(),o=this.containerRef.current.getBoundingClientRect();t.push({id:a,type:"text",position:{x:n.left-o.left,y:n.top-o.top},element:s})}}),this.containerRef.current.querySelectorAll(".drawing-emoji-element").forEach(r=>{const a=r.getAttribute("data-emoji-id");if(a){const s=r,n=s.getBoundingClientRect(),o=this.containerRef.current.getBoundingClientRect();t.push({id:a,type:"emoji",position:{x:n.left-o.left,y:n.top-o.top},element:s})}})),t}setDrawingLayerElementsPosition(t){this.containerRef.current&&t.forEach(e=>{let i=null;if(e.type==="text"?i=this.containerRef.current.querySelector(`[data-text-id="${e.id}"]`):e.type==="emoji"&&(i=this.containerRef.current.querySelector(`[data-emoji-id="${e.id}"]`)),i){i.style.position="absolute",i.style.left=`${e.position.x}px`,i.style.top=`${e.position.y}px`;const r=this.allDrawings.findIndex(a=>a.id===e.id);r!==-1&&this.allDrawings[r].points.length>0&&(this.allDrawings[r].points[0]={...e.position})}})}moveDrawingLayerElements(t,e){if(!this.containerRef.current)return;this.containerRef.current.querySelectorAll(".drawing-text-element").forEach(a=>{const s=a,n=parseInt(s.style.left)||0,o=parseInt(s.style.top)||0;s.style.left=`${n+t}px`,s.style.top=`${o+e}px`}),this.containerRef.current.querySelectorAll(".drawing-emoji-element").forEach(a=>{const s=a,n=parseInt(s.style.left)||0,o=parseInt(s.style.top)||0;s.style.left=`${n+t}px`,s.style.top=`${o+e}px`}),this.allDrawings.forEach(a=>{(a.type==="text"||a.type==="emoji")&&a.points.length>0&&(a.points[0].x+=t,a.points[0].y+=e)})}getDrawingLayerElementsByType(t){const e=[];if(!this.containerRef.current)return e;const i=t==="text"?".drawing-text-element":".drawing-emoji-element",r=t==="text"?"data-text-id":"data-emoji-id";return this.containerRef.current.querySelectorAll(i).forEach(s=>{const n=s,o=n.getAttribute(r);if(o){const h=n.getBoundingClientRect(),l=this.containerRef.current.getBoundingClientRect();e.push({id:o,position:{x:h.left-l.left,y:h.top-l.top},element:n})}}),e}disableChartMovement(){this.props.chart&&(this.originalChartOptions=this.props.chart.options(),this.props.chart.applyOptions({handleScroll:!1,handleScale:!1}))}enableChartMovement(){this.props.chart.applyOptions({handleScroll:!0,handleScale:!0})}render(){const{activeTool:t,currentTheme:e,showInfoLayer:i=!0}=this.props,{isTextMarkToolbar:r,showGraphMarkToolBar:a,showTableMarkToolBar:s,markToolBarPosition:n,showTextMarkToolBar:o,selectedTextEditMark:h,selectedTableMark:l,selectedGraphMark:g,isMainChartIndicatorsModalOpen:c,isSubChartIndicatorsSettingModalOpen:d,subChartIndicatorsSettingModalParams:u,currentSubChartIndicatorType:p}=this.state;return m.jsx("div",{style:{width:"100%"},children:m.jsxs("div",{style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",zIndex:5,pointerEvents:t?"auto":"none",opacity:1,display:"block"},children:[i&&m.jsx("div",{style:{position:"absolute",width:"100%",height:"100%"},children:this.renderChartInfo()}),m.jsx("div",{style:{position:"absolute",width:"100%",height:"100%"},children:this.renderMainChart()}),m.jsxs("div",{ref:this.containerRef,style:{position:"absolute",width:"100%",height:"100%",minHeight:"300px"},children:[this.state.isTextMarkEditorOpen&&m.jsx(Dr,{isOpen:this.state.isTextMarkEditorOpen,position:this.state.textMarkEditorPosition,theme:this.props.currentTheme,initialText:this.state.textMarkEditorInitialData.text,initialColor:this.state.textMarkEditorInitialData.color,initialFontSize:this.state.textMarkEditorInitialData.fontSize,initialIsBold:this.state.textMarkEditorInitialData.isBold,initialIsItalic:this.state.textMarkEditorInitialData.isItalic,onSave:this.handleTextMarkEditorSave,onCancel:this.handleTextMarkEditorCancel,i18n:this.props.i18n}),d&&m.jsx(uo,{isOpen:d,onClose:this.handleSubChartSettingClose,onConfirm:this.handleSubChartSettingConfirm,initialParams:u,theme:e,parentRef:this.containerRef,indicatorType:p,i18n:this.props.i18n}),this.state.isImageUploadModalOpen&&m.jsx(Fr,{isOpen:this.state.isImageUploadModalOpen,onClose:this.handleImageUploadClose,onConfirm:this.handleImageConfirm,theme:e,i18n:this.props.i18n}),c&&m.jsx(Kn,{isOpen:c,onClose:this.handleIndicatorsClose,onConfirm:this.handleMainChartIndicatorsSettingConfirm,initialIndicator:this.state.modalEditingChartInfoIndicator,theme:e,parentRef:this.containerRef,indicatorType:this.state.modalEditingChartInfoIndicator?.type||null,i18n:this.props.i18n}),o&&m.jsx(Bn,{position:n,selectedDrawing:h,theme:e,onClose:this.closeTextMarkToolBar,onDelete:this.handleDeleteTextEditMark,onChangeTextColor:this.handleChangeTextMarkFontColor,onChangeTextStyle:this.handleChangeTextMarkStyle,onChangeTextSize:this.handleChangeTextMarkFontSize,onDragStart:this.handleTextMarkToolBarDrag,isDragging:r,getToolName:this.getToolName,isShowGrapTool:this.state.isShowGrapTool,onChangeGraphColor:this.handleChangeTextMarkGraphColor,onChangeGraphStyle:this.handleChangeTextMarkGraphLineStyle,onChangeGraphLineWidth:this.handleChangeTextMarkGraphLineWidth,i18n:this.props.i18n}),a&&m.jsx(Un,{position:n,selectedDrawing:g,theme:e,onClose:this.closeGraphMarkToolBar,onDelete:this.handleDeleteGraphMark,onChangeColor:this.handleChangeGraphMarkColor,onChangeStyle:this.handleChangeGraphMarkStyle,onChangeWidth:this.handleChangeGraphMarkWidth,onDragStart:this.handleGraphToolbarDrag,isDragging:!1,getToolName:this.getToolName,i18n:this.props.i18n})]})]})})}}class Fo{constructor(t,e,i,r,a="en"){this.series=null,this.locale=a,this.chart=et.createChart(t,{width:e,height:i,layout:r.layout,grid:{vertLines:{color:r.grid.vertLines.color+"30",style:1,visible:!0},horzLines:{color:r.grid.horzLines.color+"30",style:1,visible:!0}},crosshair:{mode:0},timeScale:{timeVisible:!0,secondsVisible:!1,borderColor:r.grid.vertLines.color},rightPriceScale:{borderColor:r.grid.horzLines.color,scaleMargins:{top:.1,bottom:.1},entireTextOnly:!1},handleScale:{axisPressedMouseMove:!0},handleScroll:{mouseWheel:!0,pressedMouseMove:!0},localization:{locale:this.locale}})}getChart(){return this.chart}getSeries(){return this.series}getLocale(){return this.locale}}const Mt={Indicators:"Indicators",mainChartIndicators:"Main Chart Indicators",subChartIndicators:"Sub Chart Indicators",chartMaps:"Maps",close:"Close",searchIndicators:"Search indicators...",searchChartTypes:"Search chart types...",theme:"Theme",light:"Light",dark:"Dark",timeframe:"Time Frame",chartType:"Chart Type",toolBar:{color:"Color",lineSize:"Line Size",lineStyle:"Line Style",delete:"Delete",close:"Close",fontSize:"Font Size",bold:"Bold",italic:"Italic",selectColor:"Select Color",colorPicker:"Color Picker",solid:"Solid",dashed:"Dashed",dotted:"Dotted",currentColor:"Current Color"},timeframeSections:{second:"Second",minute:"Minute",hour:"Hour",day:"Day",week:"Week",month:"Month"},chartTypes:{candle:"Candlestick",line:"Line",area:"Area",baseline:"Baseline",hollowCandle:"Hollow Candle",heikinAshi:"Heikin Ashi",column:"Column",lineWithMarkers:"Line with Markers",stepLine:"Step Line",bar:"Bar",histogram:"Histogram",pointandfigure:"PointAndFigure",kagi:"Kagi",linebreak:"LineBreak",mountain:"Mountain",baselinearea:"BaseLineArea",highlow:"HighLow",equivolume:"EquiVolume",threelinebreak:"ThreeLineBreak",hlcarea:"HLCArea"},toolbarButtons:{hint:"Hint",replay:"Replay",fullScreen:"Full Screen",screenshot:"Screenshot",contrast:"Contrast"},indicators:{ma:"Moving Average",ema:"Exponential Moving Average",bollinger:"Bollinger Bands",ichimoku:"Ichimoku Cloud",donchian:"Donchian Channel",envelope:"Envelope",vwap:"VWAP",rsi:"RSI",macd:"MACD",volume:"Volume",sar:"Parabolic SAR",kdj:"KDJ",atr:"ATR",stochastic:"Stochastic",cci:"CCI",bbwidth:"BB Width",adx:"ADX",obv:"OBV"},mainIndicators:{ma:"Moving Average (MA)",ema:"Exponential Moving Average (EMA)",bollinger:"Bollinger Bands",ichimoku:"Ichimoku Cloud",donchian:"Donchian Channel",envelope:"Envelope",vwap:"Volume Weighted Average Price (VWAP)"},mainChartMaps:{heatmap:"Heat Map",marketProfile:"Market Profile"},subChartIndicatorName:{rsi:"Relative Strength Index (RSI)",macd:"MACD",volume:"Volume",sar:"Parabolic SAR (SAR)",kdj:"KDJ",atr:"Average True Range (ATR)",stochastic:"Stochastic Oscillator",cci:"Commodity Channel Index (CCI)",bbwidth:"Bollinger Bands Width",adx:"Average Directional Index (ADX)",obv:"On Balance Volume (OBV)"},modal:{parameterSettings:"Parameter Settings",parameterName:"Parameter Name",parameterValue:"Value",lineWidth:"Line Width",lineColor:"Color",addParameter:"Add Parameter",deleteParameter:"Delete",keepAtLeastOne:"Keep at least one parameter",maximumParameters:"Maximum 5 parameters allowed",dragToMove:"Drag header to move"},tooltips:{ctrlEnterToConfirm:"Ctrl+Enter: Confirm",escToCancel:"Esc: Cancel",clickToSelectColor:"Click to select color"},emoji:{categories:{smileys:"Smileys & Emotion",people:"People & Body",animals:"Animals & Nature",food:"Food & Drink",activities:"Activities",travel:"Travel & Places",objects:"Objects",symbols:"Symbols",flags:"Flags"},searchPlaceholder:"Search emojis...",selectedEmoji:"Selected",clickToPlace:"Click chart to place emoji"},leftPanel:{cursorCrosshair:"Crosshair",cursorCrosshairDesc:"Crosshair cursor with space",cursorCircle:"Cursor",cursorCircleDesc:"Cursor",cursorDot:"Dot Cursor",cursorDotDesc:"Round dot cursor style",cursorArrow:"Arrow Cursor",cursorArrowDesc:"Arrow pointer style",cursorSparkle:"Sparkle",cursorSparkleDesc:"Sparkle effect cursor",cursorEmoji:"Emoji Cursor",cursorEmojiDesc:"Emoji symbol cursor",pencil:"Pencil",pencilDesc:"Thin line drawing tool",pen:"Pen",penDesc:"Smooth line drawing",brush:"Brush",brushDesc:"Soft brush effect",markerPen:"Marker",markerPenDesc:"Bold marker pen",eraser:"Eraser",eraserDesc:"Erase drawing content",heatMap:"Heat Map",lineTools:"Lines",arrowTools:"Arrows",channelTools:"Channels",pitchforkTools:"Pitchforks",penTools:"Pens",gannTools:"Gann Tools",fibonacciTools:"Fibonacci Tools",technicalPatterns:"Technical Patterns",elliottWave:"Elliott Wave",regularShapes:"Regular Shapes",rangeTools:"Ranges",positionTools:"Positions",simulationTools:"Simulation",textTools:"Text",contentTools:"Content",lineSegment:"Line Segment",lineSegmentDesc:"Draw line segment",horizontalLine:"Horizontal Line",horizontalLineDesc:"Draw horizontal line marker",verticalLine:"Vertical Line",verticalLineDesc:"Draw vertical line marker",arrowLine:"Arrow Line",arrowLineDesc:"Draw arrow line marker",thickArrowLine:"Thick Arrow Line",thickArrowLineDesc:"Draw thick arrow line marker",parallelChannel:"Parallel Channel",parallelChannelDesc:"Draw parallel channel",linearRegressionChannel:"Linear Regression Channel",linearRegressionChannelDesc:"Draw regression channel",equidistantChannel:"Equidistant Channel",equidistantChannelDesc:"Draw equidistant channel",disjointChannel:"Disjoint Channel",disjointChannelDesc:"Draw disjoint channel",andrewPitchfork:"Andrew's Pitchfork",andrewPitchforkDesc:"Draw Andrew's pitchfork",enhancedAndrewPitchfork:"Enhanced Andrew Pitchfork",enhancedAndrewPitchforkDesc:"Draw enhanced pitchfork",schiffPitchfork:"Schiff Pitchfork",schiffPitchforkDesc:"Draw Schiff pitchfork",internalPitchfork:"Internal Pitchfork Lines",internalPitchforkDesc:"Draw internal pitchfork lines",wavePitchfork:"Wave Pitchfork",wavePitchforkDesc:"Draw wave pitchfork",gannFan:"Gann Fan",gannFanDesc:"Gann fan analysis tool",gannBox:"Gann Box",gannBoxDesc:"Gann box analysis tool",gannRectangle:"Gann Rectangle",gannRectangleDesc:"Gann Rectangle analysis",fibonacciTimeZones:"Fibonacci Time Zones",fibonacciTimeZonesDesc:"Fibonacci time zones analysis",fibonacciRetracement:"Fibonacci Retracement",fibonacciRetracementDesc:"Draw Fibonacci retracement lines",fibonacciArc:"Fibonacci Arc",fibonacciArcDesc:"Draw Fibonacci arcs",fibonacciCircle:"Fibonacci Circle",fibonacciCircleDesc:"Fibonacci circle analysis",fibonacciSpiral:"Fibonacci Spiral",fibonacciSpiralDesc:"Fibonacci spiral analysis",fibonacciWedge:"Fibonacci Wedge",fibonacciWedgeDesc:"Fibonacci wedge analysis",fibonacciFan:"Fibonacci Fan",fibonacciFanDesc:"Fibonacci fan analysis",fibonacciChannel:"Fibonacci Channel",fibonacciChannelDesc:"Fibonacci channel analysis",fibonacciExtensionPrice:"Fibonacci Extension (Price)",fibonacciExtensionPriceDesc:"Draw Fibonacci extension lines",fibonacciExtensionTime:"Fibonacci Extension (Time)",fibonacciExtensionTimeDesc:"Draw Fibonacci extension lines",xabcdPattern:"XABCD Pattern",xabcdPatternDesc:"Draw XABCD pattern",headAndShoulders:"Head and Shoulders",headAndShouldersDesc:"Draw head and shoulders pattern",abcdPattern:"ABCD Pattern",abcdPatternDesc:"Draw ABCD pattern",triangleAbcd:"ABCD Triangle",triangleAbcdDesc:"Draw ABCD triangle pattern",elliottImpulse:"Elliott Impulse Wave",elliottImpulseDesc:"Draw Elliott impulse wave",elliottCorrective:"Elliott Corrective Wave",elliottCorrectiveDesc:"Draw Elliott corrective wave",elliottTriangle:"Elliott Triangle Wave",elliottTriangleDesc:"Draw Elliott triangle wave",elliottDoubleCombo:"Elliott Double Combo",elliottDoubleComboDesc:"Draw Elliott double combo wave",elliottTripleCombo:"Elliott Triple Combo",elliottTripleComboDesc:"Draw Elliott triple combo wave",rectangle:"Rectangle",rectangleDesc:"Draw rectangular area",circle:"Circle",circleDesc:"Draw circular area",ellipse:"Ellipse",ellipseDesc:"Draw elliptical area",triangle:"Triangle",triangleDesc:"Draw triangle",sector:"Sector",sectorDesc:"Draw sector",curve:"Curve",curveDesc:"Draw curve",doubleCurve:"Double Curve",doubleCurveDesc:"Draw double curve",timeRange:"Time Range",timeRangeDesc:"Draw time range",priceRange:"Price Range",priceRangeDesc:"Draw price range",timePriceRange:"Time-Price Range",timePriceRangeDesc:"Draw time-price range",longPosition:"Long Position",longPositionDesc:"Long position marker",shortPosition:"Short Position",shortPositionDesc:"Short position marker",mockKline:"Mock K-line",mockKlineDesc:"Simulate K-line data",text:"Text",textDesc:"Text annotation",priceNote:"Price Note",priceNoteDesc:"Price annotation",bubbleBox:"Bubble Box",bubbleBoxDesc:"Bubble annotation box",pin:"Pin",pinDesc:"Pin marker",signpost:"Signpost",signpostDesc:"Signpost marker",priceLabel:"Price Label",priceLabelDesc:"Price label marker",flagMark:"Flag Mark",flagMarkDesc:"Flag marker",image:"Image",imageDesc:"Image annotation",video:"Video",videoDesc:"Video annotation",audio:"Audio",audioDesc:"Audio annotation",idea:"Idea",ideaDesc:"Idea annotation",mouseCursor:"Mouse Cursor",drawingTools:"Drawing Tools",fibonacciToolsTitle:"Fibonacci Tools",projectInfoTools:"Project Info Tools",shapeTools:"Shape Tools",brushTitle:"Brush",textMark:"Text Mark",emojiMark:"Emoji Mark",deleteTool:"Delete Tool",setting:"Setting",selectedTool:"Selected",clickToStartDrawing:"Click chart to start drawing",selectEmoji:"Select Emoji",selectedEmoji:"Selected",clickToPlaceEmoji:"Click chart to place emoji",aiTools:"AI Tools",aiModelSelection:"AI Models",aiFunctions:"AI Functions",openai:"OpenAI",openaiDesc:"GPT-4, GPT-3.5",gemini:"Gemini",geminiDesc:"Google AI",claude:"Claude",claudeDesc:"Anthropic AI",deepseek:"DeepSeek",deepseekDesc:"Chinese AI Model",describeChart:"Describe Chart",describeChartDesc:"Describe chart patterns in natural language",predictTrend:"Predict Trend",predictTrendDesc:"Predict future trends based on historical data"},systemSettings:{title:"System Settings",general:"General",appearance:"Appearance",chart:"Chart",performance:"Performance",shortcuts:"Shortcuts",saveSettings:"Save Settings",cancel:"Cancel",confirm:"Confirm",language:"Language",timezone:"Timezone",autoSave:"Auto Save",themeMode:"Theme Mode",fontSize:"Font Size",animations:"Animations",defaultTimeframe:"Default Timeframe",pricePrecision:"Price Precision",showGrid:"Show Grid",hardwareAcceleration:"Hardware Acceleration",dataPointLimit:"Data Point Limit",realtimeUpdates:"Real-time Updates",shortcutsTitle:"Keyboard Shortcuts",zoomIn:"Zoom In",zoomOut:"Zoom Out",resetZoom:"Reset Zoom",saveChart:"Save Chart",undo:"Undo",redo:"Redo",setting:"Setting"},settingsDescriptions:{language:"Select interface display language",timezone:"Set timezone for displayed times",autoSave:"Automatically save chart settings and drawings",themeMode:"Choose light or dark theme",fontSize:"Set interface font size",animations:"Enable interface animation effects",defaultTimeframe:"Set default chart display timeframe",pricePrecision:"Set number of decimal places for price display",showGrid:"Display grid lines in chart",hardwareAcceleration:"Enable GPU accelerated rendering (recommended)",dataPointLimit:"Set maximum number of data points to display in chart",realtimeUpdates:"Enable real-time data stream updates"},options:{light:"Light Mode",dark:"Dark Mode",auto:"Follow System",small:"Small",medium:"Medium",large:"Large",zhCN:"Simplified Chinese",enUS:"English",jaJP:"Japanese",beijing:"Beijing Time (UTC+8)",newYork:"New York Time (UTC-5)",london:"London Time (UTC+0)",chicago:"Chicago Time (UTC-6)",denver:"Denver Time (UTC-7)",losAngeles:"Los Angeles Time (UTC-8)",toronto:"Toronto Time (UTC-5)",paris:"Paris Time (UTC+1)",frankfurt:"Frankfurt Time (UTC+1)",zurich:"Zurich Time (UTC+1)",moscow:"Moscow Time (UTC+3)",dubai:"Dubai Time (UTC+4)",karachi:"Karachi Time (UTC+5)",kolkata:"Kolkata Time (UTC+5:30)",shanghai:"Shanghai Time (UTC+8)",hongKong:"Hong Kong Time (UTC+8)",singapore:"Singapore Time (UTC+8)",tokyo:"Tokyo Time (UTC+9)",seoul:"Seoul Time (UTC+9)",sydney:"Sydney Time (UTC+10)",auckland:"Auckland Time (UTC+12)",utc:"UTC Time"},timeframes:{"1s":"1 Second","5s":"5 Seconds","15s":"15 Seconds","30s":"30 Seconds","1m":"1 Minute","3m":"3 Minutes","5m":"5 Minutes","15m":"15 Minutes","30m":"30 Minutes","45m":"45 Minutes","1H":"1 Hour","2H":"2 Hours","3H":"3 Hours","4H":"4 Hours","6H":"6 Hours","8H":"8 Hours","12H":"12 Hours","1D":"1 Day","3D":"3 Days","1W":"1 Week","2W":"2 Weeks","1M":"1 Month","3M":"3 Months","6M":"6 Months"},timezone:"Timezone",timeFormat:"Time Format",closeTime:"Close Time",tradingDay:"Trading Day",searchTimezones:"Search timezones...",timeFormatOptions:{twentyFourHour:"24-Hour Format",twelveHour:"12-Hour Format"},closeTimeOptions:{custom:"Custom Time"},tradingDayOptions:{tradingSession:"Trading Session",calendarDay:"Calendar Day",exchangeHours:"Exchange Hours"},terminal:{isEn:"en",placeholderText:"Enter command..."},ai:{aliyun:"Aliyun"}},Eo={Indicators:"技术指标",mainChartIndicators:"主图指标",subChartIndicators:"副图指标",chartMaps:"图",close:"关闭",searchIndicators:"搜索指标...",searchChartTypes:"搜索图表类型...",theme:"主题",light:"浅色",dark:"深色",timeframe:"时间框架",chartType:"图表类型",toolBar:{color:"颜色",lineSize:"线条尺寸",lineStyle:"线条样式",delete:"删除",close:"关闭",fontSize:"字体大小",bold:"粗体",italic:"斜体",selectColor:"选择颜色",colorPicker:"拾色器",solid:"实线",dashed:"虚线",dotted:"点状线",currentColor:"当前颜色"},timeframeSections:{second:"秒",minute:"分钟",hour:"小时",day:"天",week:"周",month:"月"},chartTypes:{candle:"蜡烛图",line:"线图",area:"面积图",baseline:"基线图",hollowCandle:"空心蜡烛图",heikinAshi:"平均K线图",column:"柱状图",lineWithMarkers:"带标记线图",stepLine:"阶梯线图",bar:"美国线",histogram:"直方图",pointandfigure:"点线图",kagi:"卡吉图",linebreak:"新价线",mountain:"山脉图",baselinearea:"基准面积图",highlow:"高低图",equivolume:"等量图",threelinebreak:"三线反转图",hlcarea:"HLC区域"},toolbarButtons:{hint:"提示",replay:"回放",fullScreen:"全屏",screenshot:"截图",contrast:"对比"},indicators:{ma:"移动平均线",ema:"指数移动平均线",bollinger:"布林带",ichimoku:"一目均衡表",donchian:"唐奇安通道",envelope:"包络线",vwap:"成交量加权平均价",rsi:"RSI",macd:"MACD",volume:"成交量",sar:"抛物线转向",kdj:"KDJ",atr:"ATR",stochastic:"随机指标",cci:"CCI",bbwidth:"布林带宽度",adx:"ADX",obv:"能量潮"},mainIndicators:{ma:"移动平均线 (MA)",ema:"指数移动平均线 (EMA)",bollinger:"布林带",ichimoku:"一目均衡表",donchian:"唐奇安通道",envelope:"包络线",vwap:"成交量加权平均价 (VWAP)"},mainChartMaps:{heatmap:"热力图",marketProfile:"市场轮廓图"},subChartIndicatorName:{rsi:"相对强弱指数 (RSI)",macd:"MACD",volume:"成交量",sar:"抛物线转向指标 (SAR)",kdj:"KDJ",atr:"平均真实波幅 (ATR)",stochastic:"随机指标",cci:"顺势指标 (CCI)",bbwidth:"布林带宽度",adx:"平均趋向指数 (ADX)",obv:"能量潮 (OBV)"},modal:{parameterSettings:"参数设置",parameterName:"参数名称",parameterValue:"数值",lineWidth:"线宽",lineColor:"颜色",addParameter:"添加参数",deleteParameter:"删除",keepAtLeastOne:"至少保留一个参数",maximumParameters:"最多允许5个参数",dragToMove:"拖动标题栏移动"},tooltips:{ctrlEnterToConfirm:"Ctrl+Enter: 确认",escToCancel:"Esc: 取消",clickToSelectColor:"点击选择颜色"},emoji:{categories:{smileys:"表情与情感",people:"人物与身体",animals:"动物与自然",food:"食物与饮品",activities:"活动",travel:"旅行与地点",objects:"物品",symbols:"符号",flags:"旗帜"},searchPlaceholder:"搜索表情...",selectedEmoji:"已选择",clickToPlace:"点击图表放置表情"},leftPanel:{cursorCrosshair:"十字准星",cursorCrosshairDesc:"带空格的十字准星",cursorCircle:"圆形光标",cursorCircleDesc:"圆形光标",cursorDot:"点状光标",cursorDotDesc:"圆点光标样式",cursorArrow:"箭头光标",cursorArrowDesc:"箭头指示样式",cursorSparkle:"烟花棒",cursorSparkleDesc:"烟花效果光标",cursorEmoji:"表情光标",cursorEmojiDesc:"表情符号光标",pencil:"铅笔",pencilDesc:"细线绘制工具",pen:"钢笔",penDesc:"流畅线条绘制",brush:"刷子",brushDesc:"柔和笔刷效果",markerPen:"马克笔",markerPenDesc:"粗体标记笔",eraser:"橡皮擦",eraserDesc:"擦除绘制内容",lineTools:"线",arrowTools:"箭头",channelTools:"通道",pitchforkTools:"叉",penTools:"画笔",gannTools:"江恩分析工具",fibonacciTools:"斐波那契工具",technicalPatterns:"技术图形",elliottWave:"艾略特波浪",regularShapes:"规则图形",rangeTools:"区间",positionTools:"标尺",simulationTools:"模拟",heatMap:"热力图",textTools:"文本",contentTools:"内容",lineSegment:"线段",lineSegmentDesc:"绘制线段",horizontalLine:"水平线",horizontalLineDesc:"绘制水平线标记",verticalLine:"垂直线",verticalLineDesc:"绘制垂直线标记",arrowLine:"箭头线",arrowLineDesc:"绘制箭头线标记",thickArrowLine:"粗箭头线",thickArrowLineDesc:"绘制箭头线标记",parallelChannel:"并行通道",parallelChannelDesc:"绘制并行通道",linearRegressionChannel:"线性回归通道",linearRegressionChannelDesc:"绘制回归通道",equidistantChannel:"等距通道",equidistantChannelDesc:"绘制等距通道",disjointChannel:"不相交通道",disjointChannelDesc:"绘制不相交通道",andrewPitchfork:"安德鲁干草叉",andrewPitchforkDesc:"绘制安德鲁干草叉",enhancedAndrewPitchfork:"改良安德鲁干草叉",enhancedAndrewPitchforkDesc:"绘制叉子",schiffPitchfork:"希夫干草叉",schiffPitchforkDesc:"绘制希夫干草叉",internalPitchfork:"内部干草叉线",internalPitchforkDesc:"绘制内部干草叉线",wavePitchfork:"波浪干草叉",wavePitchforkDesc:"绘制波浪干草叉",gannFan:"江恩扇",gannFanDesc:"江恩扇形线分析工具",gannBox:"江恩箱",gannBoxDesc:"江恩箱体分析工具",gannRectangle:"江恩正方体",gannRectangleDesc:"江恩正方体分析",fibonacciTimeZones:"斐波那契时间周期",fibonacciTimeZonesDesc:"斐波那契时间周期线分析",fibonacciRetracement:"斐波那契回调",fibonacciRetracementDesc:"绘制斐波那契回调线",fibonacciArc:"斐波那契弧线",fibonacciArcDesc:"绘制斐波那契弧线",fibonacciCircle:"斐波那契圆",fibonacciCircleDesc:"斐波那契圆线分析",fibonacciSpiral:"斐波那契螺旋",fibonacciSpiralDesc:"斐波那契螺旋线分析",fibonacciWedge:"斐波那契楔形",fibonacciWedgeDesc:"斐波那契楔形线分析",fibonacciFan:"斐波那契扇形",fibonacciFanDesc:"斐波那契扇形线分析",fibonacciChannel:"斐波那契通道",fibonacciChannelDesc:"斐波那契通道线分析",fibonacciExtensionPrice:"斐波那契扩展(基于价格)",fibonacciExtensionPriceDesc:"绘制斐波那契扩展线",fibonacciExtensionTime:"斐波那契扩展(基于时间)",fibonacciExtensionTimeDesc:"绘制斐波那契扩展线",xabcdPattern:"XABCD图形",xabcdPatternDesc:"绘制XABCD图形",headAndShoulders:"头肩图形",headAndShouldersDesc:"绘制头肩图形",abcdPattern:"ABCD图形",abcdPatternDesc:"绘制ABCD图形",triangleAbcd:"ABCD三角图形",triangleAbcdDesc:"绘制ABCD三角图形",elliottImpulse:"艾略特脉冲波",elliottImpulseDesc:"绘制艾略特脉冲波",elliottCorrective:"艾略特修正浪",elliottCorrectiveDesc:"绘制艾略特修正浪",elliottTriangle:"艾略特三角波",elliottTriangleDesc:"绘制艾略特三角波",elliottDoubleCombo:"艾略特双重组合波",elliottDoubleComboDesc:"绘制艾略特双重组合波",elliottTripleCombo:"艾略特三重组合波",elliottTripleComboDesc:"绘制艾略特三重组合波",rectangle:"矩形",rectangleDesc:"绘制矩形区域",circle:"圆形",circleDesc:"绘制圆形区域",ellipse:"椭圆",ellipseDesc:"绘制椭圆区域",triangle:"三角形",triangleDesc:"绘制三角形",sector:"扇形",sectorDesc:"绘制扇形",curve:"曲线",curveDesc:"绘制曲线",doubleCurve:"双曲线",doubleCurveDesc:"绘制双曲线",timeRange:"时间区间",timeRangeDesc:"绘制时间区间",priceRange:"价格区间",priceRangeDesc:"绘制价格区间",timePriceRange:"时间价格区间",timePriceRangeDesc:"绘制时间价格区间",longPosition:"多头",longPositionDesc:"多头标记",shortPosition:"空头",shortPositionDesc:"空头标记",mockKline:"模拟K线",mockKlineDesc:"模拟K线数据",text:"文本",textDesc:"文本标注",priceNote:"价格标记",priceNoteDesc:"价格标注",bubbleBox:"气泡框",bubbleBoxDesc:"气泡标注框",pin:"定位",pinDesc:"定位标记",signpost:"路标",signpostDesc:"路标标记",priceLabel:"价格标签",priceLabelDesc:"价格标签标记",flagMark:"旗标",flagMarkDesc:"旗标标记",image:"图片",imageDesc:"图片标注",video:"视频",videoDesc:"视频标注",audio:"音频",audioDesc:"音频标注",idea:"点子",ideaDesc:"点子标注",mouseCursor:"鼠标光标",drawingTools:"绘图工具",fibonacciToolsTitle:"斐波那契工具",projectInfoTools:"项目信息工具",shapeTools:"图形工具",brushTitle:"画笔",textMark:"文字标记",emojiMark:"表情标记",deleteTool:"删除工具",setting:"设置",selectedTool:"已选择",clickToStartDrawing:"点击图表开始绘制",selectEmoji:"选择表情",selectedEmoji:"已选择",clickToPlaceEmoji:"点击图表放置表情",aiTools:"AI工具",aiModelSelection:"AI模型",aiFunctions:"AI功能",openai:"OpenAI",openaiDesc:"GPT-4, GPT-3.5",gemini:"Gemini",geminiDesc:"谷歌AI",claude:"Claude",claudeDesc:"Anthropic AI",deepseek:"DeepSeek",deepseekDesc:"国产AI模型",describeChart:"图表分析",describeChartDesc:"用自然语言分析图表走势",predictTrend:"趋势预测",predictTrendDesc:"基于历史数据预测未来趋势"},systemSettings:{title:"系统设置",general:"通用设置",appearance:"外观设置",chart:"图表设置",performance:"性能设置",shortcuts:"快捷键",saveSettings:"保存设置",cancel:"取消",confirm:"确认",language:"语言",timezone:"时区",autoSave:"自动保存",themeMode:"主题模式",fontSize:"字体大小",animations:"动画效果",defaultTimeframe:"默认时间周期",pricePrecision:"价格精度",showGrid:"显示网格",hardwareAcceleration:"硬件加速",dataPointLimit:"数据点限制",realtimeUpdates:"实时数据更新",shortcutsTitle:"键盘快捷键",zoomIn:"放大图表",zoomOut:"缩小图表",resetZoom:"重置缩放",saveChart:"保存图表",undo:"撤销操作",redo:"重做操作",setting:"设置"},settingsDescriptions:{language:"选择界面显示语言",timezone:"设置显示时间的时区",autoSave:"自动保存图表设置和绘图",themeMode:"选择浅色或深色主题",fontSize:"设置界面字体大小",animations:"启用界面动画效果",defaultTimeframe:"设置图表默认显示的时间周期",pricePrecision:"设置价格显示的小数位数",showGrid:"在图表中显示网格线",hardwareAcceleration:"启用GPU加速渲染(推荐)",dataPointLimit:"设置图表显示的最大数据点数量",realtimeUpdates:"启用实时数据流更新"},options:{light:"浅色模式",dark:"深色模式",auto:"跟随系统",small:"小",medium:"中",large:"大",zhCN:"简体中文",enUS:"English",jaJP:"日本語",beijing:"北京时间 (UTC+8)",newYork:"纽约时间 (UTC-5)",london:"伦敦时间 (UTC+0)",chicago:"芝加哥时间 (UTC-6)",denver:"丹佛时间 (UTC-7)",losAngeles:"洛杉矶时间 (UTC-8)",toronto:"多伦多时间 (UTC-5)",paris:"巴黎时间 (UTC+1)",frankfurt:"法兰克福时间 (UTC+1)",zurich:"苏黎世时间 (UTC+1)",moscow:"莫斯科时间 (UTC+3)",dubai:"迪拜时间 (UTC+4)",karachi:"卡拉奇时间 (UTC+5)",kolkata:"加尔各答时间 (UTC+5:30)",shanghai:"上海时间 (UTC+8)",hongKong:"香港时间 (UTC+8)",singapore:"新加坡时间 (UTC+8)",tokyo:"东京时间 (UTC+9)",seoul:"首尔时间 (UTC+9)",sydney:"悉尼时间 (UTC+10)",auckland:"奥克兰时间 (UTC+12)",utc:"UTC时间"},timeframes:{"1s":"1秒","5s":"5秒","15s":"15秒","30s":"30秒","1m":"1分钟","3m":"3分钟","5m":"5分钟","15m":"15分钟","30m":"30分钟","45m":"45分钟","1H":"1小时","2H":"2小时","3H":"3小时","4H":"4小时","6H":"6小时","8H":"8小时","12H":"12小时","1D":"1天","3D":"3天","1W":"1周","2W":"2周","1M":"1月","3M":"3月","6M":"6月"},timezone:"时区",timeFormat:"时间格式",closeTime:"收盘时间",tradingDay:"交易日",searchTimezones:"搜索时区...",timeFormatOptions:{twentyFourHour:"24小时制",twelveHour:"12小时制"},closeTimeOptions:{custom:"自定义时间"},tradingDayOptions:{tradingSession:"交易时段",calendarDay:"日历日",exchangeHours:"交易时间"},terminal:{isEn:"中文",placeholderText:"输入命令..."},ai:{aliyun:"阿里云"}};async function Me(f,t){const e=f.candleViewRef.current;if(!e){const i={success:!1,error:"Container not found",width:0,height:0,timestamp:Date.now()};return t?.(i),i}try{const i=document.createElement("canvas"),r=i.getContext("2d");if(!r){const c={success:!1,error:"Canvas context not available",width:0,height:0,timestamp:Date.now()};return t?.(c),c}const{width:a,height:s}=e.getBoundingClientRect();i.width=a,i.height=s,r.fillStyle=f.state.currentTheme.layout.background.color,r.fillRect(0,0,a,s);const n=e.querySelectorAll("canvas");Array.from(n).sort((c,d)=>{const u=parseInt(window.getComputedStyle(c).zIndex)||0,p=parseInt(window.getComputedStyle(d).zIndex)||0;return u-p}).forEach(c=>{try{const d=c.getBoundingClientRect(),u=e.getBoundingClientRect(),p=d.left-u.left,M=d.top-u.top;r.drawImage(c,p,M,d.width,d.height)}catch{}}),yo(f,e,r,a,s),Ro(r,a,s,f.state.currentTheme);const h=i.toDataURL("image/png"),l=await new Promise(c=>{i.toBlob(d=>{c(d)},"image/png")}),g={success:!0,dataUrl:h,blob:l,width:a,height:s,timestamp:Date.now()};if(t)t(g);else{const c=document.createElement("a");c.download=`chart-screenshot-${new Date().getTime()}.png`,c.href=h,c.click()}return g}catch(i){const r={success:!1,error:i instanceof Error?i.message:"Unknown error",width:0,height:0,timestamp:Date.now()};return t?.(r),r}}function Ro(f,t,e,i){f.save();const a=i.layout.background.color==="#0F1116"?"rgba(255, 255, 255, 0.25)":"rgba(0, 0, 0, 0.25)";f.fillStyle=a,f.font="bold 60px Arial, sans-serif",f.textAlign="center",f.textBaseline="middle";const s=t/2,n=e/2;f.fillText("CandleView",s,n),f.restore()}function yo(f,t,e,i,r){Array.from(t.querySelectorAll('.chart-info-panel, .toolbar, [candleview-container] > div:not([style*="position: absolute"])')).forEach(s=>{Bo(f,s,e,t)})}function Bo(f,t,e,i){const r=t.getBoundingClientRect(),a=i.getBoundingClientRect(),s=r.left-a.left,n=r.top-a.top,o=document.createElement("canvas"),h=o.getContext("2d");h&&(o.width=r.width,o.height=r.height,Uo(f,t,h,r.width,r.height),e.drawImage(o,s,n,r.width,r.height))}function Uo(f,t,e,i,r){const a=t.textContent||"";a.trim()&&(e.fillStyle=f.state.currentTheme.layout.textColor,e.font="12px Arial",e.textAlign="left",e.textBaseline="top",Io(f,e,a,i-20).forEach((n,o)=>{e.fillText(n,10,10+o*16)}))}function Io(f,t,e,i){const r=e.split(" "),a=[];let s=r[0];for(let n=1;n<r.length;n++){const o=r[n];t.measureText(s+" "+o).width<i?s+=" "+o:(a.push(s),s=o)}return a.push(s),a}function Lo(f){return f&&{"1s":v.ONE_SECOND,"5s":v.FIVE_SECONDS,"15s":v.FIFTEEN_SECONDS,"30s":v.THIRTY_SECONDS,"1m":v.ONE_MINUTE,"3m":v.THREE_MINUTES,"5m":v.FIVE_MINUTES,"15m":v.FIFTEEN_MINUTES,"30m":v.THIRTY_MINUTES,"45m":v.FORTY_FIVE_MINUTES,"1h":v.ONE_HOUR,"2h":v.TWO_HOURS,"3h":v.THREE_HOURS,"4h":v.FOUR_HOURS,"6h":v.SIX_HOURS,"8h":v.EIGHT_HOURS,"12h":v.TWELVE_HOURS,"1d":v.ONE_DAY,"3d":v.THREE_DAYS,"1w":v.ONE_WEEK,"2w":v.TWO_WEEKS,"1M":v.ONE_MONTH,"3M":v.THREE_MONTHS,"6M":v.SIX_MONTHS}[f]||null}function Ko(f){return f&&{"America/New_York":O.NEW_YORK,"America/Chicago":O.CHICAGO,"America/Denver":O.DENVER,"America/Los_Angeles":O.LOS_ANGELES,"America/Toronto":O.TORONTO,"Europe/London":O.LONDON,"Europe/Paris":O.PARIS,"Europe/Frankfurt":O.FRANKFURT,"Europe/Zurich":O.ZURICH,"Europe/Moscow":O.MOSCOW,"Asia/Dubai":O.DUBAI,"Asia/Karachi":O.KARACHI,"Asia/Kolkata":O.KOLKATA,"Asia/Shanghai":O.SHANGHAI,"Asia/Hong_Kong":O.HONG_KONG,"Asia/Singapore":O.SINGAPORE,"Asia/Tokyo":O.TOKYO,"Asia/Seoul":O.SEOUL,"Australia/Sydney":O.SYDNEY,"Pacific/Auckland":O.AUCKLAND,UTC:O.UTC}[f]||null}const Vi={[v.ONE_SECOND]:{seconds:1,groupBy:"second"},[v.FIVE_SECONDS]:{seconds:5,groupBy:"second"},[v.FIFTEEN_SECONDS]:{seconds:15,groupBy:"second"},[v.THIRTY_SECONDS]:{seconds:30,groupBy:"second"},[v.ONE_MINUTE]:{seconds:60,groupBy:"minute"},[v.THREE_MINUTES]:{seconds:180,groupBy:"minute"},[v.FIVE_MINUTES]:{seconds:300,groupBy:"minute"},[v.FIFTEEN_MINUTES]:{seconds:900,groupBy:"minute"},[v.THIRTY_MINUTES]:{seconds:1800,groupBy:"minute"},[v.FORTY_FIVE_MINUTES]:{seconds:2700,groupBy:"minute"},[v.ONE_HOUR]:{seconds:3600,groupBy:"hour"},[v.TWO_HOURS]:{seconds:7200,groupBy:"hour"},[v.THREE_HOURS]:{seconds:10800,groupBy:"hour"},[v.FOUR_HOURS]:{seconds:14400,groupBy:"hour"},[v.SIX_HOURS]:{seconds:21600,groupBy:"hour"},[v.EIGHT_HOURS]:{seconds:28800,groupBy:"hour"},[v.TWELVE_HOURS]:{seconds:43200,groupBy:"hour"},[v.ONE_DAY]:{seconds:86400,groupBy:"day"},[v.THREE_DAYS]:{seconds:259200,groupBy:"day"},[v.ONE_WEEK]:{seconds:604800,groupBy:"week"},[v.TWO_WEEKS]:{seconds:1209600,groupBy:"week"},[v.ONE_MONTH]:{seconds:2592e3,groupBy:"month"},[v.THREE_MONTHS]:{seconds:7776e3,groupBy:"month"},[v.SIX_MONTHS]:{seconds:15552e3,groupBy:"month"}};function Ho(f,t){return t&&f in t.timeframes?t.timeframes[f]:Ci(f)}function Ci(f){return{[v.ONE_SECOND]:"1 Second",[v.FIVE_SECONDS]:"5 Seconds",[v.FIFTEEN_SECONDS]:"15 Seconds",[v.THIRTY_SECONDS]:"30 Seconds",[v.ONE_MINUTE]:"1 Minute",[v.THREE_MINUTES]:"3 Minutes",[v.FIVE_MINUTES]:"5 Minutes",[v.FIFTEEN_MINUTES]:"15 Minutes",[v.THIRTY_MINUTES]:"30 Minutes",[v.FORTY_FIVE_MINUTES]:"45 Minutes",[v.ONE_HOUR]:"1 Hour",[v.TWO_HOURS]:"2 Hours",[v.THREE_HOURS]:"3 Hours",[v.FOUR_HOURS]:"4 Hours",[v.SIX_HOURS]:"6 Hours",[v.EIGHT_HOURS]:"8 Hours",[v.TWELVE_HOURS]:"12 Hours",[v.ONE_DAY]:"1 Day",[v.THREE_DAYS]:"3 Days",[v.ONE_WEEK]:"1 Week",[v.TWO_WEEKS]:"2 Weeks",[v.ONE_MONTH]:"1 Month",[v.THREE_MONTHS]:"3 Months",[v.SIX_MONTHS]:"6 Months"}[f]||f}function Oo(f,t,e,i=v.ONE_DAY){if(!f||f.length===0)return[];const r=Vi[i],a=r?r.seconds:86400,s=[],n=f[0],o=f[f.length-1],h=f.reduce((M,k)=>M+k.close,0)/f.length,l=typeof n.time=="string"?new Date(n.time).getTime()/1e3:n.time,g=typeof o.time=="string"?new Date(o.time).getTime()/1e3:o.time,c=1e4,d=Math.min(t,c),u=Math.min(e,c);let p=l;for(let M=d;M>0;M--){p-=a;const k={time:p,open:h,high:h,low:h,close:h,volume:-1,isVirtual:!0};s.unshift(k)}s.push(...f),p=g;for(let M=0;M<u;M++){p+=a;const k={time:p,open:h,high:h,low:h,close:h,volume:-1,isVirtual:!0};s.push(k)}return s}function jo(f,t){if(!f||f.length===0)return f;const e=No[t];return e?f.map(i=>{const r=i.time;let a;typeof r=="string"?a=new Date(r).getTime()/1e3:a=r;const s=e.offset.match(/^([+-])(\d{2}):(\d{2})$/);if(!s)return{...i,time:a};const n=s[1],o=parseInt(s[2],10),h=parseInt(s[3],10);let l=o*3600+h*60;n==="-"&&(l=-l);const d=-new Date(a*1e3).getTimezoneOffset()*60,u=l-d,p=a+u;return{...i,time:p}}):f}const No={[O.NEW_YORK]:{name:"America/New_York",offset:"-05:00",displayName:"New York"},[O.CHICAGO]:{name:"America/Chicago",offset:"-06:00",displayName:"Chicago"},[O.DENVER]:{name:"America/Denver",offset:"-07:00",displayName:"Denver"},[O.LOS_ANGELES]:{name:"America/Los_Angeles",offset:"-08:00",displayName:"Los Angeles"},[O.TORONTO]:{name:"America/Toronto",offset:"-05:00",displayName:"Toronto"},[O.LONDON]:{name:"Europe/London",offset:"+00:00",displayName:"London"},[O.PARIS]:{name:"Europe/Paris",offset:"+01:00",displayName:"Paris"},[O.FRANKFURT]:{name:"Europe/Frankfurt",offset:"+01:00",displayName:"Frankfurt"},[O.ZURICH]:{name:"Europe/Zurich",offset:"+01:00",displayName:"Zurich"},[O.MOSCOW]:{name:"Europe/Moscow",offset:"+03:00",displayName:"Moscow"},[O.DUBAI]:{name:"Asia/Dubai",offset:"+04:00",displayName:"Dubai"},[O.KARACHI]:{name:"Asia/Karachi",offset:"+05:00",displayName:"Karachi"},[O.KOLKATA]:{name:"Asia/Kolkata",offset:"+05:30",displayName:"Kolkata"},[O.SHANGHAI]:{name:"Asia/Shanghai",offset:"+08:00",displayName:"Shanghai"},[O.HONG_KONG]:{name:"Asia/Hong_Kong",offset:"+08:00",displayName:"Hong Kong"},[O.SINGAPORE]:{name:"Asia/Singapore",offset:"+08:00",displayName:"Singapore"},[O.TOKYO]:{name:"Asia/Tokyo",offset:"+09:00",displayName:"Tokyo"},[O.SEOUL]:{name:"Asia/Seoul",offset:"+09:00",displayName:"Seoul"},[O.SYDNEY]:{name:"Australia/Sydney",offset:"+10:00",displayName:"Sydney"},[O.AUCKLAND]:{name:"Pacific/Auckland",offset:"+12:00",displayName:"Auckland"},[O.UTC]:{name:"UTC",offset:"+00:00",displayName:"UTC"}};function Wo(f,t){if(!f||f.length===0)return[];try{const e=Xo(t);if(e<=0)return[...f];const i=[];let r=[],a=0;for(let s=0;s<f.length;s++){const n=f[s],o=typeof n.time=="string"?new Date(n.time).getTime()/1e3:n.time,h=Math.floor(o/e)*e;if(r.length===0)r.push(n),a=h;else if(h===a)r.push(n);else{if(r.length>0){const l=bi(r);i.push(l)}r=[n],a=h}}if(r.length>0){const s=bi(r);i.push(s)}return i}catch{return f}}function Xo(f){switch(f){case v.ONE_SECOND:return 1;case v.FIVE_SECONDS:return 5;case v.FIFTEEN_SECONDS:return 15;case v.THIRTY_SECONDS:return 30;case v.ONE_MINUTE:return 60;case v.THREE_MINUTES:return 180;case v.FIVE_MINUTES:return 300;case v.FIFTEEN_MINUTES:return 900;case v.THIRTY_MINUTES:return 1800;case v.FORTY_FIVE_MINUTES:return 2700;case v.ONE_HOUR:return 3600;case v.TWO_HOURS:return 7200;case v.THREE_HOURS:return 10800;case v.FOUR_HOURS:return 14400;case v.SIX_HOURS:return 360*60;case v.EIGHT_HOURS:return 480*60;case v.TWELVE_HOURS:return 720*60;case v.ONE_DAY:return 1440*60;case v.THREE_DAYS:return 4320*60;case v.ONE_WEEK:return 10080*60;case v.TWO_WEEKS:return 336*60*60;case v.ONE_MONTH:return 720*60*60;case v.THREE_MONTHS:return 2160*60*60;case v.SIX_MONTHS:return 4320*60*60;default:return 0}}function bi(f){if(f.length===1)return{...f[0]};const t=f[0].open,e=f[f.length-1].close;let i=-1/0,r=1/0,a=0;for(const s of f)i=Math.max(i,s.high),r=Math.min(r,s.low),a+=s.volume||0;return{time:f[0].time,open:t,high:i,low:r,close:e,volume:a,isVirtual:f.some(s=>s.isVirtual)}}function me(f,t,e,i){return{timeframe:f.timeframe||v.ONE_DAY,timezone:f.timezone||O.SHANGHAI,shouldExtendVirtualData:!0,virtualDataBeforeCount:e||0,virtualDataAfterCount:i||0,chartType:t}}class ke{static handleData(t,e,i){if(!t||t.length===0)return[];try{const r=jo(t,e.timezone),a=Wo(r,e.timeframe);return e.shouldExtendVirtualData?this.extendWithVirtualData(a,e):a}catch{return t}}static extendWithVirtualData(t,e){const i=e.virtualDataBeforeCount??this.calculateOptimalVirtualDataCount(e.timeframe,"before"),r=e.virtualDataAfterCount??this.calculateOptimalVirtualDataCount(e.timeframe,"after");return Oo(t,i,r,e.timeframe)}static calculateOptimalVirtualDataCount(t,e){const r=[v.ONE_SECOND,v.FIVE_SECONDS,v.FIFTEEN_SECONDS,v.THIRTY_SECONDS].includes(t),a=[v.ONE_MINUTE,v.THREE_MINUTES,v.FIVE_MINUTES,v.FIFTEEN_MINUTES,v.THIRTY_MINUTES,v.FORTY_FIVE_MINUTES].includes(t),s=[v.ONE_HOUR,v.TWO_HOURS,v.THREE_HOURS,v.FOUR_HOURS,v.SIX_HOURS,v.EIGHT_HOURS,v.TWELVE_HOURS].includes(t),n=[v.ONE_DAY,v.THREE_DAYS].includes(t),o=[v.ONE_WEEK,v.TWO_WEEKS].includes(t),h=[v.ONE_MONTH,v.THREE_MONTHS,v.SIX_MONTHS].includes(t);return r?Math.min(100,50):a?Math.min(100,80):s?100:n?200:o?300:h?400:100}static handleChartDisplayData(t,e){if(!t||t.length===0)return[];let i=[];try{return e===z.Candle||e===z.HollowCandle||e===z.Bar?i=t.map((r,a)=>{const s={time:r.time,open:Number(r.open),high:Number(r.high),low:Number(r.low),close:Number(r.close),volume:Number(r.volume)};return r.isVirtual?{...s,color:"transparent",borderColor:"transparent",wickColor:"transparent"}:s}):e===z.BaseLine?i=t.map(r=>{const a=r.isVirtual||r.volume===-1,s={time:r.time,value:Number(r.close)};return a?{...s,color:"transparent"}:s}):e===z.Line||e===z.Area||e===z.StepLine?i=t.map(r=>{const a=r.isVirtual||r.volume===-1,s={time:r.time,value:Number(r.close)};return a?{...s,color:"transparent"}:s}):e===z.Histogram?i=t.map(r=>{const a=r.isVirtual||r.volume===-1,s={time:r.time,value:r.volume||0};return a?{...s,color:"transparent"}:{...s,color:(r.volume||0)>100?"#26a69a":"#ef5350"}}):i=t.map(r=>{const a=r.isVirtual||r.volume===-1;return{time:r.time,value:Number(r.close),...a&&{color:"transparent"}}}),this.formatCache={key:cacheKey,result:i},i}catch{return[]}}static filterRealData(t){return t.filter(e=>!e.isVirtual&&e.volume!==-1&&e.volume!==0)}static getTimeframeConfig(t){return Vi[t]}static validateData(t){return!t||!Array.isArray(t)?!1:t.every(e=>e.time!==void 0&&e.open!==void 0&&e.high!==void 0&&e.low!==void 0&&e.close!==void 0)}static sampleData(t,e=1){if(e>=1||t.length<=1e3)return t;const i=[],r=Math.floor(1/e);for(let a=0;a<t.length;a+=r)a<t.length&&i.push(t[a]);return i}}const vt=class vt{static getRealDataRange(t){if(t.length===0)return null;let e=-1,i=-1;for(let r=0;r<t.length;r++)if(!t[r].isVirtual){e=r;break}for(let r=t.length-1;r>=0;r--)if(!t[r].isVirtual){i=r;break}return{firstIndex:e,lastIndex:i}}static checkDataPointPositions(t,e,i){if(!t||!e)return;const{firstIndex:r,lastIndex:a}=e,{from:s,to:n}=t,o=r>=s&&r<=n,h=a>=s&&a<=n,l=r<s,g=r>n,c=a<s,d=a>n,p=(n-s)*.1,M=r>=n-p&&r<=n,k=a>=s&&a<=s+p;!this.lastFirstRealDataLeftViewport&&l&&i.onFirstRealDataExitLeftViewport?.(),!this.lastFirstRealDataRightViewport&&g&&i.onFirstRealDataExitRightViewport?.(),!this.lastLastRealDataLeftViewport&&c&&i.onLastRealDataExitLeftViewport?.(),!this.lastLastRealDataRightViewport&&d&&i.onLastRealDataExitRightViewport?.(),this.lastFirstRealDataLeftViewport&&!l&&o&&i.onFirstRealDataEnterLeftViewport?.(),!this.lastFirstRealDataNearRightViewport&&M&&i.onFirstRealDataNearRightViewport?.(),!this.lastLastRealDataNearLeftViewport&&k&&i.onLastRealDataNearLeftViewport?.(),this.lastFirstRealDataNearRightViewport&&!M&&i.onFirstRealDataLeaveNearRightViewport?.(),this.lastLastRealDataNearLeftViewport&&!k&&i.onLastRealDataLeaveNearLeftViewport?.(),this.lastFirstRealDataInViewport&&!o&&i.onFirstRealDataExitViewport?.(),this.lastLastRealDataInViewport&&!h&&i.onLastRealDataExitViewport?.(),this.lastFirstRealDataInViewport=o,this.lastLastRealDataInViewport=h,this.lastFirstRealDataLeftViewport=l,this.lastFirstRealDataRightViewport=g,this.lastLastRealDataLeftViewport=c,this.lastLastRealDataRightViewport=d,this.lastFirstRealDataNearRightViewport=M,this.lastLastRealDataNearLeftViewport=k}static reset(){this.lastFirstRealDataInViewport=!0,this.lastLastRealDataInViewport=!0,this.lastFirstRealDataLeftViewport=!1,this.lastFirstRealDataRightViewport=!1,this.lastLastRealDataLeftViewport=!1,this.lastLastRealDataRightViewport=!1,this.lastFirstRealDataNearRightViewport=!1,this.lastLastRealDataNearLeftViewport=!1}static getCurrentState(){return{lastFirstRealDataInViewport:this.lastFirstRealDataInViewport,lastLastRealDataInViewport:this.lastLastRealDataInViewport,lastFirstRealDataLeftViewport:this.lastFirstRealDataLeftViewport,lastFirstRealDataRightViewport:this.lastFirstRealDataRightViewport,lastLastRealDataLeftViewport:this.lastLastRealDataLeftViewport,lastLastRealDataRightViewport:this.lastLastRealDataRightViewport,lastFirstRealDataNearRightViewport:this.lastFirstRealDataNearRightViewport,lastLastRealDataNearLeftViewport:this.lastLastRealDataNearLeftViewport}}};vt.lastFirstRealDataInViewport=!0,vt.lastLastRealDataInViewport=!0,vt.lastFirstRealDataLeftViewport=!1,vt.lastFirstRealDataRightViewport=!1,vt.lastLastRealDataLeftViewport=!1,vt.lastLastRealDataRightViewport=!1,vt.lastFirstRealDataNearRightViewport=!1,vt.lastLastRealDataNearLeftViewport=!1;let Ce=vt;class Yo{constructor(t,e){this.chart=null,this.currentSeries=null,this.beforeViewPortBuffer=100,this.afterViewPortBuffer=0,this.getViewportDataPoints=(i,r)=>{if(!r||r.length===0)return[];const a=i.from-this.beforeViewPortBuffer,s=i.to-this.afterViewPortBuffer;return r.filter(o=>o.time>=a&&o.time<=s)},this.scrollLockState={isScrollLocked:!1,lockDirection:null,safeVisibleRange:null},this.chart=t,this.currentSeries=e}zoomIn(){if(!this.chart)return;const t=this.chart.timeScale(),e=t.getVisibleRange();if(!e)return;const a=(e.to-e.from)*.8,s=(e.from+e.to)/2;t.setVisibleRange({from:s-a/2,to:s+a/2})}zoomOut(){if(!this.chart)return;const t=this.chart.timeScale(),e=t.getVisibleRange();if(!e)return;const a=(e.to-e.from)*1.2,s=(e.from+e.to)/2;t.setVisibleRange({from:s-a/2,to:s+a/2})}scrollChart(t){if(!this.chart)return;const e=this.chart.timeScale(),i=e.getVisibleRange();if(!i)return;const a=(i.to-i.from)*.2;t==="left"?e.setVisibleRange({from:i.from-a,to:i.to-a}):e.setVisibleRange({from:i.from+a,to:i.to+a})}positionChart(t){this.setOptimalBarSpacing(t),this.scrollToRealData()}getVisibleTimeRange(){if(!this.chart)return null;try{const e=this.chart.timeScale().getVisibleRange();return e?{from:e.from,to:e.to}:null}catch(t){return console.error(t),null}}setVisibleTimeRange(t){if(!this.chart||!t)return;const e=this.chart.timeScale();try{e.setVisibleRange({from:t.from,to:t.to})}catch(i){console.error(i),this.scrollToRealData()}}scrollToRealData(){if(this.chart)try{const t=this.chart.timeScale(),e=this.currentSeries?.series?.data||[];if(e.length===0){t.fitContent();return}const{firstIndex:i,lastIndex:r,virtualAfterCount:a}=this.getRealDataRange();if(i===-1||r===-1){t.fitContent();return}const s=Math.min(100,r-i+1+10),n=Math.max(0,i-5),o=Math.min(e.length-1,r+Math.min(10,a));t.setVisibleLogicalRange({from:n,to:o})}catch(t){console.error(t),this.scrollToStablePosition()}}scrollToStablePosition(){if(this.chart)try{const t=this.chart.timeScale(),e=this.currentSeries?.series?.data||[];if(e.length===0){t.fitContent();return}const{lastIndex:i}=this.getRealDataRange();if(i===-1)t.setVisibleLogicalRange({from:Math.max(0,e.length-50),to:e.length-1});else{const a=Math.max(0,i-50+1),s=Math.min(e.length-1,i+5);t.setVisibleLogicalRange({from:a,to:s})}}catch(t){console.error(t),this.chart&&this.chart.timeScale().fitContent()}}getRealDataRange(){const t=this.currentSeries?.series?.data||[];let e=-1,i=-1,r=0,a=0,s=0;for(let n=0;n<t.length;n++){const o=t[n];if(!o.isVirtual&&o.volume!==-1&&o.volume!==0&&o.open!==void 0&&o.high!==void 0&&o.low!==void 0&&o.close!==void 0){e=n,a=n;break}}for(let n=t.length-1;n>=0;n--){const o=t[n];if(!o.isVirtual&&o.volume!==-1&&o.volume!==0&&o.open!==void 0&&o.high!==void 0&&o.low!==void 0&&o.close!==void 0){i=n,s=t.length-1-n;break}}if(e!==-1&&i!==-1)for(let n=e;n<=i;n++){const o=t[n];!o.isVirtual&&o.volume!==-1&&o.volume!==0&&o.open!==void 0&&o.high!==void 0&&o.low!==void 0&&o.close!==void 0&&r++}return{firstIndex:e,lastIndex:i,realDataCount:r,virtualBeforeCount:a,virtualAfterCount:s}}setOptimalBarSpacing(t){if(!this.chart)return;const e=this.chart.timeScale(),r=e.options().barSpacing||10,s={[v.ONE_SECOND]:1,[v.FIVE_SECONDS]:2,[v.FIFTEEN_SECONDS]:3,[v.THIRTY_SECONDS]:4,[v.ONE_MINUTE]:5,[v.THREE_MINUTES]:6,[v.FIVE_MINUTES]:7,[v.FIFTEEN_MINUTES]:8,[v.THIRTY_MINUTES]:9,[v.FORTY_FIVE_MINUTES]:10,[v.ONE_HOUR]:12,[v.TWO_HOURS]:14,[v.THREE_HOURS]:16,[v.FOUR_HOURS]:18,[v.SIX_HOURS]:20,[v.EIGHT_HOURS]:22,[v.TWELVE_HOURS]:24,[v.ONE_DAY]:15,[v.THREE_DAYS]:20,[v.ONE_WEEK]:25,[v.TWO_WEEKS]:30,[v.ONE_MONTH]:35,[v.THREE_MONTHS]:40,[v.SIX_MONTHS]:45}[t]||10;let n=s;Math.abs(r-s)>2&&(n=r);try{e.applyOptions({barSpacing:n,minBarSpacing:.5,maxBarSpacing:50})}catch(o){console.error(o)}}handleChartScrollLock(t,e){const i=this.chart.timeScale(),r=Ce.getRealDataRange(e);if(!r)return;const{firstIndex:a,lastIndex:s}=r;if(a!==-1&&s!==-1&&e.length>0){const n=i.getVisibleLogicalRange();if(n){const{from:o,to:h}=n,l=a>=h-1,g=s<=o+1;if(this.scrollLockState.isScrollLocked&&this.scrollLockState.safeVisibleRange&&(this.scrollLockState.lockDirection==="right"?t.from>this.scrollLockState.safeVisibleRange.from+2&&!l&&(this.scrollLockState.isScrollLocked=!1,this.scrollLockState.lockDirection=null,this.scrollLockState.safeVisibleRange=null):this.scrollLockState.lockDirection==="left"&&t.from<this.scrollLockState.safeVisibleRange.from-2&&!g&&(this.scrollLockState.isScrollLocked=!1,this.scrollLockState.lockDirection=null,this.scrollLockState.safeVisibleRange=null),this.scrollLockState.isScrollLocked)){i.setVisibleRange(this.scrollLockState.safeVisibleRange);return}this.scrollLockState.isScrollLocked||(l?(this.scrollLockState.isScrollLocked=!0,this.scrollLockState.lockDirection="right",this.scrollLockState.safeVisibleRange={...t},i.setVisibleRange(this.scrollLockState.safeVisibleRange)):g&&(this.scrollLockState.isScrollLocked=!0,this.scrollLockState.lockDirection="left",this.scrollLockState.safeVisibleRange={...t},i.setVisibleRange(this.scrollLockState.safeVisibleRange)))}}}}const Vo={panel:{backgroundColor:"#1A1D24",borderColor:"#2D323D"},modal:{textColor:"#FFFFFF"},layout:{background:{color:"#0F1116"},textColor:"#E8EAED",attributionLogo:!1},grid:{vertLines:{visible:!1,color:"#2D323D"},horzLines:{visible:!1,color:"#2D323D"}},chart:{candleUpColor:"#26a69a",candleDownColor:"#ef5350",lineColor:"#2962FF",topColor:"rgba(41, 98, 255, 0.4)",bottomColor:"rgba(41, 98, 255, 0)",lineWidth:2,upColor:"#00C087",downColor:"#FF5B5A",background:"#0F1116",baseLineColor:"#FF9800",histogramColor:"#4CAF50",stepLineColor:"#9C27B0",areaTopColor:"rgba(33, 150, 243, 0.4)",areaBottomColor:"rgba(33, 150, 243, 0)",areaLineColor:"#2196F3",volumeColor:"#4CAF50"},toolbar:{background:"#1A1D24",border:"#2D323D",button:{backgroundColor:"#2D323D",background:"transparent",hover:"#2D323D",active:"#2962FF",color:"#E8EAED",activeTextColor:"#FFFFFF",boxShadow:"0 0 0 1px rgba(255, 255, 255, 0.1), 0 2px 4px rgba(0, 0, 0, 0.3)",sendButton:{normal:"#7A7F8B",hover:"#8F949F",disabled:"#3D4759"},inputFocus:"#8F949F",dropdown:{hover:"#2D323D",selected:"#7A7F8B30",borderActive:"#8F949F"}}},divider:{normal:"#2D323D20",hover:"#E8EAED30",dragging:"#E8EAED80"}},qo={panel:{backgroundColor:"#FFFFFF",borderColor:"#E1E5E9"},modal:{textColor:"#1A1D24"},layout:{background:{color:"#FFFFFF"},textColor:"#1A1D24",attributionLogo:!1},grid:{vertLines:{visible:!1,color:"#E1E5E9"},horzLines:{visible:!1,color:"#E1E5E9"}},chart:{candleUpColor:"#26a69a",candleDownColor:"#ef5350",lineColor:"#2962FF",topColor:"rgba(41, 98, 255, 0.4)",bottomColor:"rgba(41, 98, 255, 0)",lineWidth:2,upColor:"#00C087",downColor:"#FF5B5A",background:"#0F1116",baseLineColor:"#FF9800",histogramColor:"#4CAF50",stepLineColor:"#9C27B0",areaTopColor:"rgba(33, 150, 243, 0.4)",areaBottomColor:"rgba(33, 150, 243, 0)",areaLineColor:"#2196F3",volumeColor:"#4CAF50"},toolbar:{background:"#F8F9FA",border:"#E1E5E9",button:{backgroundColor:"#FFFFFF",background:"transparent",hover:"#E1E5E9",active:"#2962FF",color:"#495057",activeTextColor:"#FFFFFF",boxShadow:"0 0 0 1px rgba(0, 0, 0, 0.1), 0 2px 4px rgba(0, 0, 0, 0.1)",sendButton:{normal:"#6C757D",hover:"#495057",disabled:"#E1E5E9"},inputFocus:"#1A1D24",dropdown:{hover:"#F1F3F5",selected:"#6C757D15",borderActive:"#1A1D24"}}},divider:{normal:"#E1E5E920",hover:"#49505730",dragging:"#49505780"}},zo=new Map([["qwen-turbo",{name:"qwen-turbo",displayName:"Qwen-Turbo",endpoint:"https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions",endpoints:["https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions","https://dashscope.aliyuncs.com/api/v1/services/aigc/text-generation/generation"],format:"openai",description:"Lightweight version, fast response speed, suitable for general conversation scenarios",maxTokens:2e3,contextLength:8e3,capabilities:["text-generation","chat"]}],["qwen-plus",{name:"qwen-plus",displayName:"Qwen-Plus",endpoint:"https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions",endpoints:["https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions"],format:"openai",description:"Enhanced version, suitable for complex tasks and long text processing",maxTokens:6e3,contextLength:32e3,capabilities:["text-generation","chat","reasoning"]}],["qwen-max",{name:"qwen-max",displayName:"Qwen-Max",endpoint:"https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions",endpoints:["https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions"],format:"openai",description:"Maximum version, strongest capabilities, suitable for high-demand professional tasks",maxTokens:8e3,contextLength:32e3,capabilities:["text-generation","chat","reasoning","coding","analysis"]}],["qwen-max-longcontext",{name:"qwen-max-longcontext",displayName:"Qwen-Max-LongContext",endpoint:"https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions",endpoints:["https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions"],format:"openai",description:"Supports 128K long context, suitable for long document processing",maxTokens:8e3,contextLength:128e3,capabilities:["text-generation","chat","document-analysis"]}],["qwen2.5-0.5b",{name:"qwen2.5-0.5b",displayName:"Qwen2.5-0.5B",endpoint:"https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions",format:"openai",description:"Ultra-lightweight 0.5B parameter model for edge devices",maxTokens:4e3,contextLength:32e3,capabilities:["text-generation","chat"]}],["qwen2.5-0.5b-instruct",{name:"qwen2.5-0.5b-instruct",displayName:"Qwen2.5-0.5B-Instruct",endpoint:"https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions",format:"openai",description:"Instruction-tuned 0.5B model for specific tasks",maxTokens:4e3,contextLength:32e3,capabilities:["instruction-following","chat"]}],["qwen2.5-7b",{name:"qwen2.5-7b",displayName:"Qwen2.5-7B",endpoint:"https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions",format:"openai",description:"7B parameter base model, balanced performance and efficiency",maxTokens:6e3,contextLength:32e3,capabilities:["text-generation","reasoning"]}],["qwen2.5-7b-instruct",{name:"qwen2.5-7b-instruct",displayName:"Qwen2.5-7B-Instruct",endpoint:"https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions",format:"openai",description:"Instruction-tuned 7B model for chat and tasks",maxTokens:6e3,contextLength:32e3,capabilities:["chat","instruction-following","coding"]}],["qwen2.5-14b",{name:"qwen2.5-14b",displayName:"Qwen2.5-14B",endpoint:"https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions",format:"openai",description:"14B parameter model with enhanced capabilities",maxTokens:8e3,contextLength:32e3,capabilities:["text-generation","analysis","reasoning"]}],["qwen2.5-32b",{name:"qwen2.5-32b",displayName:"Qwen2.5-32B",endpoint:"https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions",format:"openai",description:"32B parameter high-performance model",maxTokens:8e3,contextLength:32e3,capabilities:["text-generation","complex-reasoning","analysis"]}],["qwen2.5-72b",{name:"qwen2.5-72b",displayName:"Qwen2.5-72B",endpoint:"https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions",format:"openai",description:"72B parameter state-of-the-art model",maxTokens:8e3,contextLength:32e3,capabilities:["text-generation","expert-analysis","research"]}],["qwen2.5-coder",{name:"qwen2.5-coder",displayName:"Qwen2.5-Coder",endpoint:"https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions",format:"openai",description:"Specialized code generation model",maxTokens:8e3,contextLength:32e3,capabilities:["code-generation","code-explanation","debugging"]}],["qwen2.5-coder-7b",{name:"qwen2.5-coder-7b",displayName:"Qwen2.5-Coder-7B",endpoint:"https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions",format:"openai",description:"7B parameter code generation model",maxTokens:8e3,contextLength:32e3,capabilities:["code-generation","programming"]}],["qwen2.5-coder-14b",{name:"qwen2.5-coder-14b",displayName:"Qwen2.5-Coder-14B",endpoint:"https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions",format:"openai",description:"14B parameter advanced code generation model",maxTokens:8e3,contextLength:32e3,capabilities:["code-generation","code-review","optimization"]}],["qwen-vl-lite",{name:"qwen-vl-lite",displayName:"Qwen-VL-Lite",endpoint:"https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions",format:"openai",description:"Lightweight vision-language model for basic image understanding",maxTokens:2e3,contextLength:8e3,capabilities:["image-understanding","visual-qa"]}],["qwen-vl-plus",{name:"qwen-vl-plus",displayName:"Qwen-VL-Plus",endpoint:"https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions",format:"openai",description:"Vision-language model supporting image understanding",maxTokens:4e3,contextLength:32e3,capabilities:["image-understanding","document-analysis","visual-reasoning"]}],["qwen-vl-max",{name:"qwen-vl-max",displayName:"Qwen-VL-Max",endpoint:"https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions",format:"openai",description:"Most powerful vision-language model",maxTokens:8e3,contextLength:32e3,capabilities:["image-understanding","video-analysis","multimodal-reasoning"]}],["qwen-audio-turbo",{name:"qwen-audio-turbo",displayName:"Qwen-Audio-Turbo",endpoint:"https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions",format:"openai",description:"Fast audio processing and speech-to-text model",maxTokens:2e3,contextLength:8e3,capabilities:["speech-recognition","audio-analysis"]}],["qwen-audio-chat",{name:"qwen-audio-chat",displayName:"Qwen-Audio-Chat",endpoint:"https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions",format:"openai",description:"Audio conversation and processing model",maxTokens:4e3,contextLength:32e3,capabilities:["audio-chat","voice-assistant","speech-synthesis"]}],["qwen-math-7b",{name:"qwen-math-7b",displayName:"Qwen-Math-7B",endpoint:"https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions",format:"openai",description:"Specialized for mathematical reasoning and problem solving",maxTokens:4e3,contextLength:32e3,capabilities:["mathematical-reasoning","problem-solving"]}],["llama2-7b-chat-v2",{name:"llama2-7b-chat-v2",displayName:"LLaMA2-7B-Chat",endpoint:"https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions",format:"openai",description:"Meta's LLaMA2-7B model",maxTokens:2e3,contextLength:8e3,capabilities:["chat","text-generation"]}],["baichuan2-7b-chat-v1",{name:"baichuan2-7b-chat-v1",displayName:"Baichuan2-7B-Chat",endpoint:"https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions",format:"openai",description:"Baichuan AI's Baichuan2-7B model",maxTokens:2e3,contextLength:8e3,capabilities:["chat","chinese-nlp"]}],["qwen-financial",{name:"qwen-financial",displayName:"Qwen-Financial",endpoint:"https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions",format:"openai",description:"Specialized for financial analysis and market insights",maxTokens:6e3,contextLength:32e3,capabilities:["financial-analysis","market-prediction","risk-assessment"]}],["qwen-medical",{name:"qwen-medical",displayName:"Qwen-Medical",endpoint:"https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions",format:"openai",description:"Specialized for medical consultation and health analysis",maxTokens:6e3,contextLength:32e3,capabilities:["medical-consultation","health-analysis","diagnostic-support"]}],["qwen-omni",{name:"qwen-omni",displayName:"Qwen-Omni",endpoint:"https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions",format:"openai",description:"Omnidirectional multimodal model supporting text, image, audio",maxTokens:8e3,contextLength:64e3,capabilities:["text-generation","image-understanding","audio-processing","multimodal"]}],["qwen-omni-pro",{name:"qwen-omni-pro",displayName:"Qwen-Omni-Pro",endpoint:"https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions",format:"openai",description:"Professional omnidirectional multimodal model with advanced capabilities",maxTokens:16e3,contextLength:128e3,capabilities:["text-generation","multimodal","complex-reasoning","expert-analysis"]}]]);function Qo(){return Array.from(zo.keys())}const Go=new Map([["deepseek-chat",{name:"deepseek-chat",displayName:"DeepSeek Chat",endpoint:"https://api.deepseek.com/v1/chat/completions",endpoints:["https://api.deepseek.com/v1/chat/completions"],format:"openai",description:"General purpose chat model for everyday conversations and tasks",maxTokens:4096,contextLength:16e3,capabilities:["chat","text-generation","reasoning"],version:"2025-01"}],["deepseek-chat-lite",{name:"deepseek-chat-lite",displayName:"DeepSeek Chat Lite",endpoint:"https://api.deepseek.com/v1/chat/completions",format:"openai",description:"Lightweight chat model optimized for speed and efficiency",maxTokens:2048,contextLength:8e3,capabilities:["chat","text-generation"],version:"2025-01"}],["deepseek-chat-pro",{name:"deepseek-chat-pro",displayName:"DeepSeek Chat Pro",endpoint:"https://api.deepseek.com/v1/chat/completions",format:"openai",description:"Professional chat model with enhanced reasoning capabilities",maxTokens:8192,contextLength:32e3,capabilities:["chat","text-generation","complex-reasoning","analysis"],version:"2025-01"}],["deepseek-chat-max",{name:"deepseek-chat-max",displayName:"DeepSeek Chat Max",endpoint:"https://api.deepseek.com/v1/chat/completions",format:"openai",description:"Maximum capability chat model for most demanding tasks",maxTokens:16384,contextLength:64e3,capabilities:["chat","text-generation","expert-analysis","research"],version:"2025-01"}],["deepseek-coder",{name:"deepseek-coder",displayName:"DeepSeek Coder",endpoint:"https://api.deepseek.com/v1/chat/completions",format:"openai",description:"Specialized model for code generation and programming tasks",maxTokens:16384,contextLength:64e3,capabilities:["code-generation","programming","debugging","code-review"],version:"2025-01"}],["deepseek-coder-lite",{name:"deepseek-coder-lite",displayName:"DeepSeek Coder Lite",endpoint:"https://api.deepseek.com/v1/chat/completions",format:"openai",description:"Lightweight code generation model",maxTokens:4096,contextLength:16e3,capabilities:["code-generation","programming"],version:"2025-01"}],["deepseek-coder-pro",{name:"deepseek-coder-pro",displayName:"DeepSeek Coder Pro",endpoint:"https://api.deepseek.com/v1/chat/completions",format:"openai",description:"Professional code generation model with advanced features",maxTokens:32768,contextLength:128e3,capabilities:["code-generation","programming","system-design","architecture"],version:"2025-01"}],["deepseek-math",{name:"deepseek-math",displayName:"DeepSeek Math",endpoint:"https://api.deepseek.com/v1/chat/completions",format:"openai",description:"Specialized model for mathematical reasoning and problem solving",maxTokens:8192,contextLength:32e3,capabilities:["mathematical-reasoning","problem-solving","calculations"],version:"2025-01"}],["deepseek-math-pro",{name:"deepseek-math-pro",displayName:"DeepSeek Math Pro",endpoint:"https://api.deepseek.com/v1/chat/completions",format:"openai",description:"Advanced mathematical reasoning model for complex problems",maxTokens:16384,contextLength:64e3,capabilities:["mathematical-reasoning","advanced-calculus","statistics"],version:"2025-01"}],["deepseek-reasoner",{name:"deepseek-reasoner",displayName:"DeepSeek Reasoner",endpoint:"https://api.deepseek.com/v1/chat/completions",format:"openai",description:"Dedicated reasoning model for logical analysis",maxTokens:8192,contextLength:32e3,capabilities:["logical-reasoning","analysis","decision-making"],version:"2025-01"}],["deepseek-reasoner-pro",{name:"deepseek-reasoner-pro",displayName:"DeepSeek Reasoner Pro",endpoint:"https://api.deepseek.com/v1/chat/completions",format:"openai",description:"Advanced reasoning model for complex logical problems",maxTokens:16384,contextLength:64e3,capabilities:["complex-reasoning","scientific-analysis","research"],version:"2025-01"}],["deepseek-vision",{name:"deepseek-vision",displayName:"DeepSeek Vision",endpoint:"https://api.deepseek.com/v1/chat/completions",format:"openai",description:"Vision model for image understanding and analysis",maxTokens:4096,contextLength:16e3,capabilities:["image-understanding","visual-qa","document-analysis"],version:"2025-01"}],["deepseek-vision-pro",{name:"deepseek-vision-pro",displayName:"DeepSeek Vision Pro",endpoint:"https://api.deepseek.com/v1/chat/completions",format:"openai",description:"Advanced vision model for complex visual tasks",maxTokens:8192,contextLength:32e3,capabilities:["image-understanding","video-analysis","visual-reasoning"],version:"2025-01"}],["deepseek-finance",{name:"deepseek-finance",displayName:"DeepSeek Finance",endpoint:"https://api.deepseek.com/v1/chat/completions",format:"openai",description:"Specialized for financial analysis, market prediction, and investment insights",maxTokens:8192,contextLength:32e3,capabilities:["financial-analysis","market-prediction","risk-assessment","investment-advice"],version:"2025-01"}],["deepseek-law",{name:"deepseek-law",displayName:"DeepSeek Law",endpoint:"https://api.deepseek.com/v1/chat/completions",format:"openai",description:"Specialized for legal analysis, contract review, and legal research",maxTokens:16384,contextLength:64e3,capabilities:["legal-analysis","contract-review","legal-research"],version:"2025-01"}],["deepseek-medical",{name:"deepseek-medical",displayName:"DeepSeek Medical",endpoint:"https://api.deepseek.com/v1/chat/completions",format:"openai",description:"Specialized for medical consultation, diagnosis support, and health analysis",maxTokens:8192,contextLength:32e3,capabilities:["medical-consultation","diagnostic-support","health-analysis"],version:"2025-01"}],["deepseek-research",{name:"deepseek-research",displayName:"DeepSeek Research",endpoint:"https://api.deepseek.com/v1/chat/completions",format:"openai",description:"Specialized for academic research and scientific analysis",maxTokens:32768,contextLength:128e3,capabilities:["academic-research","scientific-analysis","paper-writing"],version:"2025-01"}],["deepseek-omni",{name:"deepseek-omni",displayName:"DeepSeek Omni",endpoint:"https://api.deepseek.com/v1/chat/completions",format:"openai",description:"Multimodal model supporting text, image, and audio",maxTokens:16384,contextLength:64e3,capabilities:["text-generation","image-understanding","audio-processing","multimodal"],version:"2025-01"}],["deepseek-omni-pro",{name:"deepseek-omni-pro",displayName:"DeepSeek Omni Pro",endpoint:"https://api.deepseek.com/v1/chat/completions",format:"openai",description:"Professional multimodal model with advanced capabilities",maxTokens:32768,contextLength:128e3,capabilities:["text-generation","multimodal","complex-reasoning","expert-analysis"],version:"2025-01"}],["deepseek-llm",{name:"deepseek-llm",displayName:"DeepSeek LLM",endpoint:"https://api.deepseek.com/v1/chat/completions",format:"openai",description:"Base large language model",maxTokens:4096,contextLength:16e3,capabilities:["text-generation"],version:"2024-12"}]]);function Jo(){return Array.from(Go.keys())}const $o=new Map([["gpt-4",{name:"gpt-4",displayName:"GPT-4",endpoint:"https://api.openai.com/v1/chat/completions",format:"openai",description:"Powerful multi-purpose model for complex tasks",maxTokens:8192,contextLength:8192,capabilities:["chat","text-generation","reasoning","analysis"],inputCostPer1KTokens:.03,outputCostPer1KTokens:.06,supportedFeatures:["chat","function-calling"]}],["gpt-4-turbo",{name:"gpt-4-turbo",displayName:"GPT-4 Turbo",endpoint:"https://api.openai.com/v1/chat/completions",format:"openai",description:"Enhanced GPT-4 with 128K context, knowledge cutoff April 2023",maxTokens:4096,contextLength:128e3,capabilities:["chat","text-generation","reasoning","analysis","vision"],inputCostPer1KTokens:.01,outputCostPer1KTokens:.03,supportedFeatures:["chat","function-calling","vision","json-mode"]}],["gpt-4o",{name:"gpt-4o",displayName:"GPT-4o",endpoint:"https://api.openai.com/v1/chat/completions",format:"openai",description:"Versatile model supporting text, images, audio with fast response",maxTokens:4096,contextLength:128e3,capabilities:["chat","text-generation","vision","audio-processing","multimodal"],inputCostPer1KTokens:.005,outputCostPer1KTokens:.015,supportedFeatures:["chat","function-calling","vision","audio","json-mode"]}],["gpt-4o-mini",{name:"gpt-4o-mini",displayName:"GPT-4o Mini",endpoint:"https://api.openai.com/v1/chat/completions",format:"openai",description:"Compact and efficient version of GPT-4o with lower cost",maxTokens:16384,contextLength:128e3,capabilities:["chat","text-generation","vision"],inputCostPer1KTokens:15e-5,outputCostPer1KTokens:6e-4,supportedFeatures:["chat","function-calling","vision","json-mode"]}],["gpt-3.5-turbo",{name:"gpt-3.5-turbo",displayName:"GPT-3.5 Turbo",endpoint:"https://api.openai.com/v1/chat/completions",format:"openai",description:"Fast and cost-effective, suitable for most conversational tasks",maxTokens:4096,contextLength:16385,capabilities:["chat","text-generation","code-generation"],inputCostPer1KTokens:5e-4,outputCostPer1KTokens:.0015,supportedFeatures:["chat","function-calling"]}],["gpt-3.5-turbo-instruct",{name:"gpt-3.5-turbo-instruct",displayName:"GPT-3.5 Turbo Instruct",endpoint:"https://api.openai.com/v1/completions",format:"openai",description:"Instruction-tuned version for text completion tasks",maxTokens:4096,contextLength:4097,capabilities:["text-completion","instruction-following"],inputCostPer1KTokens:.0015,outputCostPer1KTokens:.002,supportedFeatures:["completions"]}],["text-embedding-ada-002",{name:"text-embedding-ada-002",displayName:"Text Embedding Ada 002",endpoint:"https://api.openai.com/v1/embeddings",format:"openai",description:"Text embedding model, 1536 dimensions, suitable for retrieval and similarity",contextLength:8191,capabilities:["embeddings","semantic-search"],inputCostPer1KTokens:1e-4,supportedFeatures:["embeddings"]}],["text-embedding-3-small",{name:"text-embedding-3-small",displayName:"Text Embedding 3 Small",endpoint:"https://api.openai.com/v1/embeddings",format:"openai",description:"Small text embedding model, 1536 dimensions, balance of performance and cost",contextLength:8191,capabilities:["embeddings","semantic-search"],inputCostPer1KTokens:2e-5,supportedFeatures:["embeddings"]}],["dall-e-3",{name:"dall-e-3",displayName:"DALL-E 3",endpoint:"https://api.openai.com/v1/images/generations",format:"openai",description:"Advanced image generation model producing high-quality, high-resolution images",capabilities:["image-generation","creative-design"],inputCostPer1KTokens:.04,supportedFeatures:["image-generation","variations","edits"]}],["whisper-1",{name:"whisper-1",displayName:"Whisper",endpoint:"https://api.openai.com/v1/audio/transcriptions",format:"openai",description:"Speech recognition model supporting multilingual transcription and translation",capabilities:["speech-recognition","audio-transcription","translation"],inputCostPer1KTokens:.006,supportedFeatures:["transcriptions","translations"]}],["tts-1-hd",{name:"tts-1-hd",displayName:"TTS-1 HD",endpoint:"https://api.openai.com/v1/audio/speech",format:"openai",description:"High-quality text-to-speech with multiple voice options",capabilities:["speech-synthesis","text-to-speech"],inputCostPer1KTokens:.015,supportedFeatures:["speech","voice-selection"]}],["text-moderation-latest",{name:"text-moderation-latest",displayName:"Moderation Latest",endpoint:"https://api.openai.com/v1/moderations",format:"openai",description:"Content moderation model for detecting harmful content",capabilities:["content-moderation","safety"],inputCostPer1KTokens:1e-4,supportedFeatures:["moderation"]}]]);function Zo(){return Array.from($o.keys())}var qi=(f=>(f.AnalyzeOHLCV="/analyzeOHLCV",f))(qi||{}),St=(f=>(f.Aliyun="aliyun",f.OpenAI="openai",f.DeepSeek="deepseek",f.Claude="claude",f.Gemini="gemini",f))(St||{});const tl={aliyun:"https://cdn.simpleicons.org/alibabacloud/FF6A00",openai:"https://cdn.simpleicons.org/openai/412991",deepseek:"https://www.deepseek.com/favicon.ico",claude:"https://cdn.simpleicons.org/anthropic/FF6B35",gemini:"https://cdn.simpleicons.org/google/4285F4"},Ti={aliyun:"Aliyun",openai:"OpenAI",deepseek:"DeepSeek",claude:"Claude",gemini:"Gemini"};function el(f){switch(f){case"openai":return Zo();case"aliyun":return Qo();case"deepseek":return Jo();case"claude":return[];case"gemini":return[];default:return[]}}var kt=(f=>(f.OpenaiChart="openai-chart",f.OpenaiPredict="openai-predict",f.AliyunChart="aliyun-chart",f.AliyunPredict="aliyun-predict",f.DeepseekChart="deepseek-chart",f.DeepseekPredict="deepseek-predict",f.ClaudeChart="claude-chart",f.ClaudePredict="claude-predict",f.GeminiChart="gemini-chart",f.GeminiPredict="gemini-predict",f))(kt||{});function il(f){return f.endsWith("/")?f.slice(0,-1):f}async function rl(f,t,e,i,r,a){const s=r.map(l=>({open:l.open,high:l.high,low:l.low,close:l.close,volume:l.volume})),n={provider:e,data:s,i18n:f===Mt?"en":"cn",modelType:i,analysisType:"comprehensive",message:a,options:{temperature:.5,maxTokens:1e3}},h=`${il(t)}${qi.AnalyzeOHLCV}`;try{const l=await fetch(h,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!l.ok){const c=await l.text();throw new Error(`HTTP error! status: ${l.status}`)}const g=await l.json();if(g.success)return g.analysis;throw new Error(g.error||"Unknown error from AI service")}catch(l){throw new Error(`AI service error: ${l.message||"Network error"}`)}}const sl=({currentTheme:f,i18n:t,currentAIFunctionType:e,aiconfigs:i,onClose:r,onSendMessage:a,isLoading:s=!1,initialMessage:n="",currentAIBrandType:o,onModelChange:h,data:l})=>{const[g,c]=E.useState(""),[d,u]=E.useState([]),[p,M]=E.useState(!1),[k,P]=E.useState(""),[S,_]=E.useState([]),[C,A]=E.useState(!1),x=E.useRef(null),R=E.useRef(null),U=E.useRef(null),[L,X]=E.useState(10),K=10,Z=E.useRef(!1),at=E.useRef(0),$=E.useRef(0);E.useEffect(()=>{const B=G=>{C&&U.current&&!U.current.contains(G.target)&&A(!1)};return document.addEventListener("mousedown",B),()=>{document.removeEventListener("mousedown",B)}},[C]),E.useEffect(()=>{if(o&&k){const B=i.find(G=>G.brand===o&&G.model===k);X(B?.maxAnalyzeData??K)}else X(K)},[o,k,i]);const tt=()=>l.length>L?l.slice(-L):l,j=()=>{if(!x.current)return;const B=x.current;!st()&&!Z.current||requestAnimationFrame(()=>{B&&(B.scrollTop=B.scrollHeight,Z.current=!1)})},st=(B=50)=>{if(!x.current)return!0;const G=x.current;return G.scrollHeight-G.scrollTop-G.clientHeight<=B},ht=(B,G)=>{const rt=[];return G.forEach(ot=>{let dt=!1;for(const pt of B)if(pt.toString()===ot){dt=!0;break}if(dt)rt.push(ot);else{const pt=ot.toLowerCase();B.find(mt=>mt.toString().toLowerCase()===pt)&&rt.push(ot)}}),rt.filter((ot,dt,pt)=>pt.indexOf(ot)===dt)};E.useEffect(()=>{if(o!=null)try{const B=el(o),G=i.filter(ot=>ot.brand===o).map(ot=>ot.model),rt=ht(B,G);if(_(rt),rt.length>0){if(!rt.includes(k)){const ot=rt[0];P(ot),h&&h(ot)}}else P(""),h&&h("")}catch{_([]),P("")}else _([]),P("")},[o,i,h,k]),E.useEffect(()=>{Z.current=!0,j()},[d]),E.useEffect(()=>{const B=x.current;if(!B)return;const G=()=>{B&&($.current=B.scrollTop,at.current=B.scrollHeight)};return B.addEventListener("scroll",G),()=>B.removeEventListener("scroll",G)},[]),E.useEffect(()=>{const B=R.current;B&&setTimeout(()=>{B.style.height="auto";const rt=Math.max(B.scrollHeight,60);B.style.height=`${rt}px`},100)},[]),E.useEffect(()=>{u([{id:"welcome",content:t===Mt?"Welcome to AI analysis. How can I help you?":"欢迎使用AI分析。有什么可以帮助您的?",sender:"ai",timestamp:new Date}])},[e,t]),E.useEffect(()=>{const B=R.current;if(!B)return;const G=60;B.style.height="auto";const rt=Math.max(B.scrollHeight,G);B.style.height=`${rt}px`},[g]),E.useEffect(()=>{if(o!=null)try{const G=i.filter(rt=>rt.brand===o).map(rt=>rt.model).filter((rt,ot,dt)=>dt.indexOf(rt)===ot);if(_(G),G.length>0){if(!G.includes(k)){const rt=G[0];P(rt),h&&h(rt)}}else P(""),h&&h("")}catch{_([]),P("")}else _([]),P("")},[o,i,h]);const ut=B=>{c(B.target.value)},y=B=>{P(B),A(!1),h&&h(B)},W=()=>!o||!k?null:i.find(G=>G.brand===o&&G.model===k)?.proxyUrl||null,nt=async()=>{if(!g.trim()||p)return;const B=g.trim(),G={id:Date.now().toString(),content:B,sender:"user",timestamp:new Date};u(ot=>[...ot,G]),c(""),M(!0);const rt={id:`loading-${Date.now()}`,content:t===Mt?"Analyzing data...":"分析数据中...",sender:"ai",timestamp:new Date,isLoading:!0};u(ot=>[...ot,rt]);try{if(!o||!k)throw new Error(t===Mt?"Please select an AI brand and model.":"请选择AI品牌和模型。");if(!i.find(At=>At.brand===o&&At.model===k))throw new Error(t===Mt?`No configuration found for ${it()}.`:`未找到${it()}的配置。`);const dt=W();if(!dt)throw new Error(t===Mt?`Proxy URL not configured for ${it()}. Please add configuration.`:`未配置${it()}的代理URL。请添加配置。`);const pt=tt();let bt,mt;switch(o){case St.Aliyun:mt="aliyun";break;case St.OpenAI:mt="openai";break;case St.DeepSeek:mt="deepseek";break;case St.Claude:mt="claude";break;case St.Gemini:mt="gemini";break;default:throw new Error(t===Mt?`Unsupported AI brand: ${o}`:`不支持的AI品牌:${o}`)}bt=await rl(t,dt,mt,k,pt,B),u(At=>{const Et=At.filter(yt=>yt.id!==rt.id),Rt={id:(Date.now()+1).toString(),content:bt,sender:"ai",timestamp:new Date};return[...Et,Rt]})}catch(ot){u(dt=>{const pt=dt.filter(mt=>mt.id!==rt.id),bt={id:(Date.now()+2).toString(),content:t===Mt?`Sorry, there was an error: ${ot.message}`:`抱歉,出现错误:${ot.message}`,sender:"ai",timestamp:new Date};return[...pt,bt]})}finally{M(!1),setTimeout(()=>{R.current?.focus()},100)}},ct=B=>{B.key==="Enter"&&!B.shiftKey&&(B.preventDefault(),nt())},it=()=>o&&{[St.OpenAI]:"OpenAI",[St.Aliyun]:t.ai.aliyun,[St.DeepSeek]:"DeepSeek",[St.Claude]:"Claude",[St.Gemini]:"Gemini"}[o]||"";return m.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",width:"100%",background:f.layout.background.color,border:`1px solid ${f.toolbar.border}30`,borderRadius:"8px",overflow:"hidden"},children:[m.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 16px",background:f.toolbar.background,borderBottom:`1px solid ${f.toolbar.border}30`,flexWrap:"wrap",gap:"12px"},children:[m.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[m.jsx("div",{style:{width:"8px",height:"8px",borderRadius:"50%",background:f.chart.candleUpColor}}),m.jsx("span",{style:{color:f.layout.textColor,fontSize:"14px",fontWeight:"600"},children:it()})]}),o!=null&&S.length>0&&m.jsxs("div",{ref:U,style:{position:"relative",flex:1,minWidth:"150px",maxWidth:"250px"},children:[m.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"6px 12px",borderRadius:"6px",border:`1px solid ${f.toolbar.border}50`,background:f.layout.background.color,color:f.layout.textColor,fontSize:"13px",cursor:"pointer",transition:"all 0.2s",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},onClick:()=>A(!C),onMouseEnter:B=>{B.currentTarget.style.borderColor=f.toolbar.button.dropdown.borderActive},onMouseLeave:B=>{C||(B.currentTarget.style.borderColor=f.toolbar.border+"50")},children:[m.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:k||(t===Mt?"Select Model":"选择模型")}),m.jsx("svg",{style:{width:"16px",height:"16px",marginLeft:"8px",flexShrink:0,transform:C?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.2s"},viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:m.jsx("polyline",{points:"6 9 12 15 18 9"})})]}),C&&m.jsx("div",{style:{position:"absolute",top:"100%",left:0,right:0,marginTop:"4px",borderRadius:"6px",border:`1px solid ${f.toolbar.border}50`,background:f.layout.background.color,boxShadow:"0 4px 12px rgba(0, 0, 0, 0.1)",zIndex:1e3,maxHeight:"200px",overflowY:"auto",overflowX:"hidden"},className:"model-dropdown",children:S.map((B,G)=>m.jsx("div",{style:{padding:"8px 12px",fontSize:"13px",color:f.layout.textColor,cursor:"pointer",transition:"background-color 0.2s",backgroundColor:B===k?f.toolbar.button.dropdown.selected:"transparent",borderBottom:G<S.length-1?`1px solid ${f.toolbar.border}20`:"none",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},onClick:()=>y(B),onMouseEnter:rt=>{rt.currentTarget.style.backgroundColor=B===k?f.toolbar.button.dropdown.selected:f.toolbar.button.dropdown.hover},onMouseLeave:rt=>{rt.currentTarget.style.backgroundColor=B===k?f.toolbar.button.dropdown.selected:"transparent"},children:B},G))})]}),m.jsx("button",{onClick:r,style:{width:"28px",height:"28px",borderRadius:"4px",border:"none",background:"transparent",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",color:f.toolbar.button.color,transition:"background-color 0.2s"},onMouseEnter:B=>{B.currentTarget.style.backgroundColor=f.toolbar.button.hover},onMouseLeave:B=>{B.currentTarget.style.backgroundColor="transparent"},children:m.jsx(Ui,{size:18})})]}),o!==void 0&&m.jsxs("div",{style:{padding:"4px 16px",background:f.toolbar.background+"80",borderBottom:`1px solid ${f.toolbar.border}20`,fontSize:"12px",color:f.layout.textColor,opacity:.8,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[m.jsx("span",{children:it()}),m.jsxs("span",{style:{fontSize:"11px",opacity:.6},children:[t===Mt?"Selected Model":"已选模型",": ",k]})]}),m.jsx("div",{ref:x,style:{flex:1,overflow:"auto",padding:"16px",display:"flex",flexDirection:"column",gap:"12px"},className:"modal-scrollbar",children:d.length===0?m.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%",color:f.toolbar.button.color,opacity:.7,textAlign:"center",padding:"20px"},children:[m.jsx("div",{style:{width:"48px",height:"48px",marginBottom:"16px",opacity:.5},children:m.jsx("div",{style:{width:"100%",height:"100%",borderRadius:"50%",background:f.toolbar.button.active,display:"flex",alignItems:"center",justifyContent:"center",color:f.layout.background.color,fontSize:"24px"},children:"AI"})}),m.jsx("div",{style:{fontSize:"14px",marginBottom:"4px"},children:t===Mt?"Select an AI function to start":"选择AI功能开始对话"}),m.jsx("div",{style:{fontSize:"12px",opacity:.6},children:t===Mt?"Choose from the left panel":"从左侧面板选择"})]}):m.jsxs(m.Fragment,{children:[d.map(B=>m.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:B.sender==="user"?"flex-end":"flex-start"},children:[m.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"8px",maxWidth:"85%",flexDirection:B.sender==="user"?"row-reverse":"row"},children:[m.jsx("div",{style:{width:"28px",height:"28px",borderRadius:"50%",background:B.sender==="user"?f.chart.candleUpColor:o?"transparent":f.toolbar.button.active,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,color:f.layout.background.color,fontSize:"12px",fontWeight:"bold",overflow:"hidden"},children:B.sender==="user"?"U":o?m.jsx("img",{src:tl[o],alt:it(),style:{width:"100%",height:"100%",objectFit:"cover",borderRadius:"50%"}}):"AI"}),m.jsxs("div",{style:{padding:"10px 14px",borderRadius:"12px",background:B.sender==="user"?f.chart.candleUpColor+"20":f.toolbar.background,border:`1px solid ${B.sender==="user"?f.chart.candleUpColor+"30":f.toolbar.border+"30"}`,color:f.layout.textColor,fontSize:"14px",lineHeight:"1.5",whiteSpace:"pre-wrap",wordBreak:"break-word",animation:B.isLoading?"pulse 1.5s infinite":"none"},children:[B.content,B.isLoading&&m.jsxs("span",{style:{display:"inline-block",marginLeft:"4px"},children:[m.jsx("span",{style:{animationDelay:"0s"},children:"."}),m.jsx("span",{style:{animationDelay:"0.2s"},children:"."}),m.jsx("span",{style:{animationDelay:"0.4s"},children:"."})]})]})]}),m.jsx("div",{style:{fontSize:"11px",color:f.toolbar.button.color,opacity:.6,marginTop:"4px",marginLeft:B.sender==="user"?"0":"36px",marginRight:B.sender==="user"?"36px":"0"},children:B.timestamp.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})})]},B.id)),m.jsx("div",{})]})}),m.jsxs("div",{style:{padding:"16px",borderTop:`1px solid ${f.toolbar.border}30`,background:f.layout.background.color},children:[m.jsxs("div",{style:{position:"relative"},children:[m.jsx("textarea",{ref:R,value:g,onChange:ut,onKeyDown:ct,placeholder:t===Mt?"Ask about analysis... (Shift+Enter for new line)":"输入关于V分析的问题... (Shift+Enter换行)",disabled:p,style:{width:"100%",height:"60px",minHeight:"60px",maxHeight:"200px",padding:"12px 48px 12px 12px",borderRadius:"8px",border:`1px solid ${f.toolbar.border}50`,background:f.toolbar.background,color:f.layout.textColor,fontSize:"14px",lineHeight:"1.5",resize:"none",fontFamily:"inherit",outline:"none",transition:"border-color 0.2s, height 0.2s",boxSizing:"border-box",overflowY:"auto"},onFocus:B=>{B.target.style.borderColor=f.toolbar.button.inputFocus},onBlur:B=>{B.target.style.borderColor=f.toolbar.border+"50"}}),m.jsx("button",{onClick:nt,disabled:!g.trim()||p,style:{position:"absolute",right:"12px",bottom:"12px",width:"32px",height:"32px",borderRadius:"6px",border:"none",background:g.trim()&&!p?f.toolbar.button.sendButton.normal:f.toolbar.button.sendButton.disabled,display:"flex",alignItems:"center",justifyContent:"center",cursor:g.trim()&&!p?"pointer":"not-allowed",opacity:g.trim()&&!p?1:.5,transition:"all 0.2s"},onMouseEnter:B=>{g.trim()&&!p&&(B.currentTarget.style.background=f.toolbar.button.sendButton.hover,B.currentTarget.style.transform="translateY(-1px)")},onMouseLeave:B=>{g.trim()&&!p&&(B.currentTarget.style.background=f.toolbar.button.sendButton.normal,B.currentTarget.style.transform="translateY(0)")},children:m.jsx(Rn,{size:18,color:g.trim()&&!p?f.layout.background.color:f.toolbar.button.color})})]}),m.jsxs("div",{style:{fontSize:"11px",color:f.toolbar.button.color,opacity:.6,marginTop:"8px",textAlign:"center"},children:[o?t===Mt?`Powered by ${Ti[o]}`:`由 ${Ti[o]} 提供支持`:null,k&&` - ${k}`]})]}),m.jsx("style",{children:`
|
|
150
|
+
`,st={position:"fixed",left:`${l.x}px`,top:`${l.y}px`,background:r?.toolbar?.background||"#fafafa",border:`1px solid ${r?.toolbar?.border||"#d9d9d9"}`,borderRadius:"8px",padding:"0",width:"450px",maxWidth:"90vw",height:"500px",maxHeight:"80vh",zIndex:1e4,boxShadow:"0 8px 24px rgba(0,0,0,0.3)",cursor:c?"grabbing":"default",userSelect:c?"none":"auto",display:"flex",flexDirection:"column"},ht={padding:"16px 16px 12px 16px",borderBottom:`1px solid ${r?.toolbar?.border||"#d9d9d9"}`,cursor:"grab",userSelect:"none",flexShrink:0},ut={fontSize:"14px",fontWeight:"bold",color:r?.layout?.textColor||"#000000",margin:0},y={padding:"16px",flex:1,display:"flex",flexDirection:"column",overflow:"hidden"},W={marginBottom:"16px",flex:1,overflowY:"auto",overflowX:"hidden",...tt},nt={display:"flex",alignItems:"center",gap:"8px",marginBottom:"8px",padding:"8px",background:r?.toolbar?.background||"#fafafa",border:`1px solid ${r?.toolbar?.border||"#d9d9d9"}`,borderRadius:"4px"},ct={fontSize:"12px",color:r?.layout?.textColor||"#000000",minWidth:"80px",fontWeight:"bold"},it={width:"80px",padding:"4px 8px",background:r?.toolbar?.background||"#fafafa",color:r?.layout?.textColor||"#000000",border:`1px solid ${r?.toolbar?.border||"#d9d9d9"}`,borderRadius:"4px",fontSize:"12px"},B={width:"60px",padding:"4px 8px",background:r?.toolbar?.background||"#fafafa",color:r?.layout?.textColor||"#000000",border:`1px solid ${r?.toolbar?.border||"#d9d9d9"}`,borderRadius:"4px",fontSize:"12px"},G={display:"flex",alignItems:"center",gap:"4px",position:"relative"},rt={width:"24px",height:"24px",border:`1px solid ${r?.toolbar?.border||"#d9d9d9"}`,borderRadius:"4px",cursor:"pointer"},ot={position:"absolute",top:0,left:0,width:"24px",height:"24px",border:"none",background:"transparent",cursor:"pointer",opacity:0},dt={background:"transparent",border:"none",fontSize:"16px",cursor:"pointer",padding:"0",width:"20px",height:"20px",display:"flex",alignItems:"center",justifyContent:"center",color:r?.chart?.downColor||"#ff4d4f"},pt={...dt,color:`${r?.toolbar?.border||"#d9d9d9"}`,cursor:"not-allowed"},bt={width:"100%",background:"transparent",color:r?.chart?.lineColor||"#2962FF",border:`2px dashed ${r?.toolbar?.border||"#d9d9d9"}`,borderRadius:"4px",padding:"8px 16px",fontSize:"12px",cursor:"pointer",marginBottom:"16px",flexShrink:0},mt={...bt,color:`${r?.toolbar?.border||"#d9d9d9"}`,cursor:"not-allowed",borderColor:`${r?.toolbar?.border||"#d9d9d9"}`},At={display:"flex",justifyContent:"flex-end",gap:"8px",flexShrink:0},Et={background:"transparent",color:r?.layout?.textColor||"#000000",border:`1px solid ${r?.toolbar?.border||"#d9d9d9"}`,borderRadius:"4px",padding:"6px 12px",fontSize:"12px",cursor:"pointer"},Rt={background:r?.toolbar?.button?.active||"#2962FF",color:r?.toolbar?.button?.activeTextColor||"#ffffff",border:"none",borderRadius:"4px",padding:"6px 12px",fontSize:"12px",cursor:"pointer"},yt={fontSize:"10px",color:`${r?.layout?.textColor||"#000000"}80`,marginTop:"8px",textAlign:"center",flexShrink:0},Ot={position:"fixed",top:0,left:0,right:0,bottom:0,zIndex:9999,background:"transparent"};if(!f||!o)return null;const V=Z(s);return ue.createPortal(m.jsxs(E.Fragment,{children:[m.jsx("style",{children:j}),m.jsx("div",{style:Ot,onClick:at,children:m.jsxs("div",{ref:M,style:st,onClick:I=>I.stopPropagation(),onMouseDown:K,onKeyDown:$,children:[m.jsx("div",{ref:k,style:ht,onMouseDown:I=>{I.target===k.current&&I.preventDefault()},children:m.jsxs("div",{style:ut,children:[P()," ",n.systemSettings?.setting||"设置"]})}),m.jsxs("div",{style:y,children:[m.jsx("div",{style:W,className:"subchart-scrollbar",children:o.map((I,q)=>m.jsxs("div",{style:nt,children:[m.jsx("div",{style:ct,children:I.paramName}),m.jsx("input",{type:"text",style:it,value:I.paramName,onChange:J=>C(q,J.target.value),onClick:J=>J.stopPropagation(),placeholder:n.modal?.parameterName||"参数名"}),m.jsx("input",{type:"number",style:it,value:I.paramValue,onChange:J=>A(q,Number(J.target.value)),onClick:J=>J.stopPropagation(),min:"1",max:"100",placeholder:n.modal?.parameterValue||"数值"}),m.jsxs("select",{style:B,value:I.lineWidth,onChange:J=>R(q,Number(J.target.value)),onClick:J=>J.stopPropagation(),children:[m.jsx("option",{value:1,children:"1px"}),m.jsx("option",{value:2,children:"2px"}),m.jsx("option",{value:3,children:"3px"}),m.jsx("option",{value:4,children:"4px"}),m.jsx("option",{value:5,children:"5px"})]}),m.jsxs("div",{style:G,children:[m.jsx("div",{style:{...rt,backgroundColor:I.lineColor},onClick:J=>{J.currentTarget.nextSibling?.click()}}),m.jsx("input",{type:"color",style:ot,value:I.lineColor,onChange:J=>x(q,J.target.value),onClick:J=>J.stopPropagation()})]}),V.allowDelete&&m.jsx("button",{onClick:()=>_(q),style:o.length<=V.minParams?pt:dt,disabled:o.length<=V.minParams,type:"button",title:o.length<=V.minParams?`${n.modal?.keepAtLeastOne||"至少保留"}${V.minParams}${n.modal?.parameterName||"个参数"}`:n.modal?.deleteParameter||"删除",children:"×"})]},`${I.paramName}-${q}`))}),m.jsx("button",{onClick:S,style:o.length>=V.maxParams||!V.allowAdd?mt:bt,disabled:o.length>=V.maxParams||!V.allowAdd,type:"button",title:o.length>=V.maxParams?`${n.modal?.maximumParameters||"最多允许"}${V.maxParams}${n.modal?.parameterName||"个参数"}`:V.allowAdd?n.modal?.addParameter||"添加参数":n.modal?.keepAtLeastOne||"不允许添加参数",children:o.length>=V.maxParams?`${n.modal?.maximumParameters||"已达到最大参数数量"}(${V.maxParams}${n.modal?.parameterName||"个"})`:V.allowAdd?`+ ${n.modal?.addParameter||"添加参数"}`:n.modal?.keepAtLeastOne||"不允许添加参数"}),m.jsxs("div",{style:At,children:[m.jsx("button",{onClick:X,style:Et,type:"button",children:n.systemSettings?.cancel||"取消"}),m.jsx("button",{onClick:L,style:Rt,type:"button",children:n.systemSettings?.confirm||"确定"})]}),m.jsxs("div",{style:yt,children:[n.tooltips?.ctrlEnterToConfirm||"Ctrl+Enter: 确认",", ",n.tooltips?.escToCancel||"Esc: 取消",", ",n.modal?.dragToMove||"拖动标题栏移动"]})]})]})})]}),document.body)};class Si{constructor(t){this.volumeSeries=null,this.refreshData=e=>{if(!this.volumeSeries)return;const i=e.props.chartData.map(r=>r.isVirtual?{time:r.time,value:r.volume,color:"rgba(0, 0, 0, 0)"}:{time:r.time,value:r.volume,color:r.close>=r.open?"rgba(38, 166, 154, 0.8)":"rgba(239, 83, 80, 0.8)"});i.length>0&&this.volumeSeries&&setTimeout(()=>{this.volumeSeries.setData(i)},0)},this.volumeSeries=t.props.chart.addSeries(et.HistogramSeries,{priceScaleId:"volume_bottom",color:"#26a69a"}),t.props.chart.priceScale("volume_bottom").applyOptions({scaleMargins:{top:.9,bottom:0}})}destroy(t){if(this.volumeSeries&&t.props.chart){try{t.props.chart.removeSeries(this.volumeSeries)}catch{}this.volumeSeries=null}}}class _i{constructor(t,e){this.candleSeries=null,this.refreshData=r=>{if(!this.candleSeries)return;const a=this.transformToCandlestickData(r.props.chartData);a.length>0&&setTimeout(()=>{this.candleSeries.setData(a)},0)},this.updateStyle=r=>{this.candleSeries&&this.candleSeries.applyOptions(r)},this.destroy=r=>{if(!this.candleSeries)return;if(!r||!r.props||!r.props.chart){this.candleSeries=null;return}const a=this.candleSeries;this.candleSeries=null;try{r.props.chart.removeSeries(a)}catch{}},this.candleSeries=t.props.chart.addSeries(et.CandlestickSeries,{upColor:e.chart.candleUpColor||"#26a69a",downColor:e.chart.candleDownColor||"#ef5350",borderVisible:!1,wickUpColor:e.chart.candleUpColor||"#26a69a",wickDownColor:e.chart.candleDownColor||"#ef5350",priceLineVisible:!0,lastValueVisible:!0,priceFormat:{type:"price",precision:2,minMove:.01}}),t.props.chart.priceScale("right").applyOptions({scaleMargins:{top:.05,bottom:.1}});const i=this.transformToCandlestickData(t.props.chartData);i.length>0&&this.candleSeries&&setTimeout(()=>{this.candleSeries.setData(i)},0)}transformToCandlestickData(t){return t.map(e=>e.isVirtual?{time:e.time,open:e.open,high:e.high,low:e.low,close:e.close,color:"rgba(0, 0, 0, 0)"}:{time:e.time,open:e.open,high:e.high,low:e.low,close:e.close})}getSeries(){return this.candleSeries}}class go{constructor(t,e){this.barSeries=null,this.theme=null,this.refreshData=r=>{if(!this.barSeries)return;const a=this.transformToBarData(r.props.chartData);a.length>0&&setTimeout(()=>{this.barSeries.setData(a)},0)},this.updateStyle=r=>{this.barSeries&&this.barSeries.applyOptions(r)},this.destroy=r=>{if(!this.barSeries)return;if(!r||!r.props||!r.props.chart){this.barSeries=null;return}const a=this.barSeries;this.barSeries=null;try{r.props.chart.removeSeries(a)}catch{}},this.barSeries=t.props.chart.addSeries(et.BarSeries,{upColor:e.chart.candleUpColor||"#26a69a",downColor:e.chart.candleDownColor||"#ef5350",thinBars:!0,priceLineVisible:!0,lastValueVisible:!0,priceFormat:{type:"price",precision:2,minMove:.01}}),this.theme=e,t.props.chart.priceScale("right").applyOptions({scaleMargins:{top:.05,bottom:.1}});const i=this.transformToBarData(t.props.chartData);i.length>0&&this.barSeries&&setTimeout(()=>{this.barSeries.setData(i)},0)}transformToBarData(t){return t.map(e=>{const i={time:e.time,open:Number(e.open),high:Number(e.high),low:Number(e.low),close:Number(e.close)};return e.isVirtual?{...i,color:"transparent",borderColor:"transparent"}:i})}getSeries(){return this.barSeries}}class po{constructor(t,e){this.lineSeries=null,this._lineWidht=2,this.refreshData=r=>{if(!this.lineSeries)return;const a=this.transformToLineData(r.props.chartData);a.length>0&&setTimeout(()=>{this.lineSeries.setData(a)},0)},this.updateStyle=r=>{this.lineSeries&&this.lineSeries.applyOptions(r)},this.destroy=r=>{if(!this.lineSeries)return;if(!r||!r.props||!r.props.chart){this.lineSeries=null;return}const a=this.lineSeries;this.lineSeries=null;try{r.props.chart.removeSeries(a)}catch{}},this.lineSeries=t.props.chart.addSeries(et.LineSeries,{color:e.chart.lineColor||"#2196F3",lineWidth:this._lineWidht,priceLineVisible:!0,lastValueVisible:!0,priceFormat:{type:"price",precision:2,minMove:.01}}),t.props.chart.priceScale("right").applyOptions({scaleMargins:{top:.05,bottom:.1}});const i=this.transformToLineData(t.props.chartData);i.length>0&&this.lineSeries&&setTimeout(()=>{this.lineSeries.setData(i)},0)}transformToLineData(t){return t.map(e=>({time:e.time,value:e.close}))}getSeries(){return this.lineSeries}}class fo{constructor(t,e){this.areaSeries=null,this.theme=null,this.refreshData=r=>{if(!this.areaSeries)return;const a=this.transformToAreaData(r.props.chartData);a.length>0&&setTimeout(()=>{this.areaSeries.setData(a)},0)},this.updateStyle=r=>{this.areaSeries&&this.areaSeries.applyOptions(r)},this.destroy=r=>{if(!this.areaSeries)return;if(!r||!r.props||!r.props.chart){this.areaSeries=null;return}const a=this.areaSeries;this.areaSeries=null;try{r.props.chart.removeSeries(a)}catch{}},this.areaSeries=t.props.chart.addSeries(et.AreaSeries,{topColor:e.chart.areaTopColor||"rgba(33, 150, 243, 0.4)",bottomColor:e.chart.areaBottomColor||"rgba(33, 150, 243, 0)",lineColor:e.chart.areaLineColor||"#2196F3",lineWidth:2,priceLineVisible:!0,lastValueVisible:!0,priceFormat:{type:"price",precision:2,minMove:.01}}),this.theme=e,t.props.chart.priceScale("right").applyOptions({scaleMargins:{top:.05,bottom:.1}});const i=this.transformToAreaData(t.props.chartData);i.length>0&&this.areaSeries&&setTimeout(()=>{this.areaSeries.setData(i)},0)}transformToAreaData(t){return t.map(e=>{const i={time:e.time,value:e.close};return e.isVirtual?{...i,color:"transparent",lineColor:"transparent",topColor:"transparent",bottomColor:"transparent"}:i})}getSeries(){return this.areaSeries}}class Mo{constructor(t,e){this.stepLineSeries=null,this.refreshData=r=>{if(!this.stepLineSeries)return;const a=this.transformToStepLineData(r.props.chartData);a.length>0&&setTimeout(()=>{this.stepLineSeries.setData(a)},0)},this.updateStyle=r=>{if(this.stepLineSeries){const a={...r,lineType:1};this.stepLineSeries.applyOptions(a)}},this.destroy=r=>{if(!this.stepLineSeries)return;if(!r||!r.props||!r.props.chart){this.stepLineSeries=null;return}const a=this.stepLineSeries;this.stepLineSeries=null;try{r.props.chart.removeSeries(a)}catch{}},this.stepLineSeries=t.props.chart.addSeries(et.LineSeries,{color:e.chart.stepLineColor||"#9C27B0",lineWidth:2,priceLineVisible:!0,lastValueVisible:!0,priceFormat:{type:"price",precision:2,minMove:.01}}),this.stepLineSeries.applyOptions({lineType:1}),t.props.chart.priceScale("right").applyOptions({scaleMargins:{top:.05,bottom:.1}});const i=this.transformToStepLineData(t.props.chartData);i.length>0&&this.stepLineSeries&&setTimeout(()=>{this.stepLineSeries.setData(i)},0)}transformToStepLineData(t){return t.map(e=>{const i={time:e.time,value:e.close};return e.isVirtual?{...i,color:"transparent"}:i})}getSeries(){return this.stepLineSeries}}class mo{constructor(t,e){this.series=null,this.refreshData=r=>{if(!this.series)return;const a=r.props.chartData.filter(o=>!o.isVirtual),s=a.length>0?a.reduce((o,h)=>o+h.close,0)/a.length:0;this.series.applyOptions({baseValue:{type:"price",price:s}});const n=r.props.chartData.map(o=>o.isVirtual?{time:o.time,value:o.close,topLineColor:"rgba(0, 0, 0, 0)",bottomLineColor:"rgba(0, 0, 0, 0)"}:{time:o.time,value:o.close});n.length>0&&this.series.setData(n)},this.updateStyle=r=>{this.series&&this.series.applyOptions(r)},this.destroy=r=>{if(!this.series)return;if(!r||!r.props||!r.props.chart){this.series=null;return}const a=this.series;this.series=null;try{r.props.chart.removeSeries(a)}catch{}},this.series=t.props.chart.addSeries(et.BaselineSeries,{baseValue:{type:"price",price:0},topLineColor:e.chart.candleUpColor||"#26a69a",topFillColor1:"rgba(0, 0, 0, 0)",topFillColor2:"rgba(0, 0, 0, 0)",bottomLineColor:e.chart.candleDownColor||"#ef5350",bottomFillColor1:"rgba(0, 0, 0, 0)",bottomFillColor2:"rgba(0, 0, 0, 0)",lineWidth:2,priceLineVisible:!0,lastValueVisible:!0,priceFormat:{type:"price",precision:2,minMove:.01}}),t.props.chart.priceScale("right").applyOptions({scaleMargins:{top:.05,bottom:.1}});const i=this.transformToBaselineData(t.props.chartData);i.length>0&&this.series&&setTimeout(()=>{this.series.setData(i)},0)}transformToBaselineData(t){const e=t.filter(r=>!r.isVirtual),i=e.length>0?e.reduce((r,a)=>r+a.close,0)/e.length:0;return this.series&&this.series.applyOptions({baseValue:{type:"price",price:i}}),t.map(r=>({time:r.time,value:r.close,...r.isVirtual&&{topLineColor:"rgba(0, 0, 0, 0)",bottomLineColor:"rgba(0, 0, 0, 0)"}}))}getSeries(){return this.series}}class ko{constructor(t,e){this.series=null,this.theme=null,this.refreshData=r=>{if(!this.series)return;const a=this.transformToHistogramData(r.props.chartData);a.length>0&&setTimeout(()=>{this.series.setData(a)},0)},this.updateStyle=r=>{this.series&&this.series.applyOptions(r)},this.destroy=r=>{if(!this.series)return;if(!r||!r.props||!r.props.chart){this.series=null;return}const a=this.series;this.series=null;try{r.props.chart.removeSeries(a)}catch{}},this.series=t.props.chart.addSeries(et.HistogramSeries,{color:e.chart.histogramColor||"#4CAF50",priceLineVisible:!0,lastValueVisible:!0,priceFormat:{type:"price",precision:2,minMove:.01}}),this.theme=e,t.props.chart.priceScale("right").applyOptions({scaleMargins:{top:.05,bottom:.1}});const i=this.transformToHistogramData(t.props.chartData);i.length>0&&this.series&&setTimeout(()=>{this.series.setData(i)},0)}transformToHistogramData(t){return t.map(e=>{const i={time:e.time,value:e.close};return e.isVirtual?{...i,color:"transparent"}:{...i,color:e.close>=(e.open||0)?this.theme?.chart.candleUpColor:this.theme?.chart.candleDownColor}})}getSeries(){return this.series}}class Po{constructor(t,e){this.series=null,this.theme=null,this.refreshData=r=>{if(!this.series)return;const a=this.transformToHollowCandlestickData(r.props.chartData);a.length>0&&setTimeout(()=>{this.series.setData(a)},0)},this.updateStyle=r=>{this.series&&this.series.applyOptions(r)},this.destroy=r=>{if(!this.series)return;if(!r||!r.props||!r.props.chart){this.series=null;return}const a=this.series;this.series=null;try{r.props.chart.removeSeries(a)}catch{}},this.series=t.props.chart.addSeries(et.CandlestickSeries,{upColor:"transparent",downColor:"transparent",borderUpColor:e.chart.candleUpColor||"#26a69a",borderDownColor:e.chart.candleDownColor||"#ef5350",wickUpColor:e.chart.candleUpColor||"#26a69a",wickDownColor:e.chart.candleDownColor||"#ef5350",priceLineVisible:!0,lastValueVisible:!0,priceFormat:{type:"price",precision:2,minMove:.01}}),t.props.chart.priceScale("right").applyOptions({scaleMargins:{top:.05,bottom:.1}});const i=this.transformToHollowCandlestickData(t.props.chartData);i.length>0&&this.series&&setTimeout(()=>{this.series.setData(i)},0)}transformToHollowCandlestickData(t){return t.map(e=>{const i=e.close>e.open,r={time:e.time,open:e.open,high:e.high,low:e.low,close:e.close};return e.isVirtual?{...r,color:"transparent",borderColor:"transparent",wickColor:"transparent"}:{...r,borderColor:i?this.theme?.chart.candleUpColor:this.theme?.chart.candleDownColor,wickColor:i?this.theme?.chart.candleUpColor:this.theme?.chart.candleDownColor}})}getSeries(){return this.series}}class So{constructor(t,e){this.series=null,this.refreshData=r=>{if(!this.series)return;const a=this.transformToHeikinAshiData(r.props.chartData);a.length>0&&setTimeout(()=>{this.series.setData(a)},0)},this.updateStyle=r=>{this.series&&this.series.applyOptions(r)},this.destroy=r=>{if(!this.series)return;if(!r||!r.props||!r.props.chart){this.series=null;return}const a=this.series;this.series=null;try{r.props.chart.removeSeries(a)}catch{}},this.series=t.props.chart.addSeries(et.CandlestickSeries,{upColor:e.chart.candleUpColor||"#26a69a",downColor:e.chart.candleDownColor||"#ef5350",borderVisible:!1,wickUpColor:e.chart.candleUpColor||"#26a69a",wickDownColor:e.chart.candleDownColor||"#ef5350",priceLineVisible:!0,lastValueVisible:!0,priceFormat:{type:"price",precision:2,minMove:.01}}),t.props.chart.priceScale("right").applyOptions({scaleMargins:{top:.05,bottom:.1}});const i=this.transformToHeikinAshiData(t.props.chartData);i.length>0&&this.series&&setTimeout(()=>{this.series.setData(i)},0)}transformToHeikinAshiData(t){if(t.length===0)return[];const e=[];let i=null;for(let r=0;r<t.length;r++){const a=t[r];if(a.isVirtual){e.push({time:a.time,open:a.open,high:a.high,low:a.low,close:a.close,color:"rgba(0, 0, 0, 0)"});continue}let s,n,o,h;i===null?(s=(a.open+a.close)/2,h=(a.open+a.high+a.low+a.close)/4,n=a.high,o=a.low):(s=(i.open+i.close)/2,h=(a.open+a.high+a.low+a.close)/4,n=Math.max(a.high,s,h),o=Math.min(a.low,s,h));const l={time:a.time,open:s,high:n,low:o,close:h};e.push(l),i={open:s,close:h}}return e}getSeries(){return this.series}}class _o{constructor(t,e){this.series=null,this.lineCount=3,this.globalChartData=[],this.refreshData=r=>{if(!this.series)return;const a=r.props.chartData.map(s=>s.isVirtual?{time:s.time,value:s.close,color:"rgba(0, 0, 0, 0)"}:{time:s.time,value:s.close});a.length>0&&this.series.setData(a)},this.updateStyle=r=>{this.series&&this.series.applyOptions(r)},this.destroy=r=>{if(!this.series)return;if(!r||!r.props||!r.props.chart){this.series=null;return}const a=this.series;this.series=null;try{r.props.chart.removeSeries(a)}catch{}},this.series=t.props.chart.addSeries(et.LineSeries,{color:e.chart.lineColor||"#2196F3",lineWidth:2,priceLineVisible:!0,lastValueVisible:!0,priceFormat:{type:"price",precision:2,minMove:.01}}),this.globalChartData=t.props.chartData;const i=this.generateLineBreakData(this.globalChartData);i.length>0&&this.series&&setTimeout(()=>{this.series.setData(i)},0)}generateLineBreakData(t){if(t.length===0)return[];const e=[];let i=[];for(let r=0;r<t.length;r++){const a=t[r].close;if(e.length===0){e.push({time:t[r].time,value:a}),i.push(a);continue}(a>Math.max(...i)||a<Math.min(...i))&&(e.push({time:t[r].time,value:a}),i.push(a),i.length>this.lineCount&&i.shift())}return e}getSeries(){return this.series}setLineCount(t){this.lineCount=t}}class Co{constructor(t,e){this.series=null,this.refreshData=r=>{if(!this.series)return;const a=r.props.chartData.map(s=>s.isVirtual?{time:s.time,value:s.close,lineColor:"rgba(0, 0, 0, 0)",topColor:"rgba(0, 0, 0, 0)",bottomColor:"rgba(0, 0, 0, 0)"}:{time:s.time,value:s.close});a.length>0&&this.series.setData(a)},this.updateStyle=r=>{this.series&&this.series.applyOptions(r)},this.destroy=r=>{if(!this.series)return;if(!r||!r.props||!r.props.chart){this.series=null;return}const a=this.series;this.series=null;try{r.props.chart.removeSeries(a)}catch{}},this.series=t.props.chart.addSeries(et.AreaSeries,{topColor:e.chart.areaTopColor||"rgba(33, 150, 243, 0.4)",bottomColor:e.chart.areaBottomColor||"rgba(33, 150, 243, 0)",lineColor:e.chart.areaLineColor||"#2196F3",lineWidth:2,priceLineVisible:!0,lastValueVisible:!0,priceFormat:{type:"price",precision:2,minMove:.01}}),t.props.chart.priceScale("right").applyOptions({scaleMargins:{top:.05,bottom:.1}});const i=this.transformToMountainData(t.props.chartData);i.length>0&&this.series&&setTimeout(()=>{this.series.setData(i)},0)}transformToMountainData(t){return t.map(e=>({time:e.time,value:e.close,...e.isVirtual&&{lineColor:"rgba(0, 0, 0, 0)",topColor:"rgba(0, 0, 0, 0)",bottomColor:"rgba(0, 0, 0, 0)"}}))}getSeries(){return this.series}}class bo{constructor(t,e){this.series=null,this.refreshData=r=>{if(!this.series)return;const a=r.props.chartData.map(s=>{if(s.isVirtual)return{time:s.time,open:s.open,high:s.high,low:s.low,close:s.close,color:"rgba(0, 0, 0, 0)",wickUpColor:"rgba(0, 0, 0, 0)",wickDownColor:"rgba(0, 0, 0, 0)",borderColor:"rgba(0, 0, 0, 0)"};{const n=s.close>=s.open,o=n?s.close:s.open,h=n?s.open:s.close;return{time:s.time,open:h,high:s.high,low:s.low,close:o,wickUpColor:"rgba(0, 0, 0, 0)",wickDownColor:"rgba(0, 0, 0, 0)",borderVisible:!1}}});a.length>0&&this.series.setData(a)},this.updateStyle=r=>{this.series&&this.series.applyOptions(r)},this.destroy=r=>{if(!this.series)return;if(!r||!r.props||!r.props.chart){this.series=null;return}const a=this.series;this.series=null;try{r.props.chart.removeSeries(a)}catch{}},this.series=t.props.chart.addSeries(et.CandlestickSeries,{upColor:e.chart.candleUpColor||"#26a69a",downColor:e.chart.candleDownColor||"#ef5350",borderVisible:!1,wickUpColor:"rgba(0, 0, 0, 0)",wickDownColor:"rgba(0, 0, 0, 0)",priceLineVisible:!0,lastValueVisible:!0,priceFormat:{type:"price",precision:2,minMove:.01}}),t.props.chart.priceScale("right").applyOptions({scaleMargins:{top:.05,bottom:.1}});const i=this.transformToHighLowData(t.props.chartData);i.length>0&&this.series&&setTimeout(()=>{this.series.setData(i)},0)}transformToHighLowData(t){return t.map(e=>{if(e.isVirtual)return{time:e.time,open:e.open,high:e.high,low:e.low,close:e.close,color:"rgba(0, 0, 0, 0)",wickUpColor:"rgba(0, 0, 0, 0)",wickDownColor:"rgba(0, 0, 0, 0)",borderColor:"rgba(0, 0, 0, 0)"};{const i=e.close>=e.open,r=i?e.close:e.open,a=i?e.open:e.close;return{time:e.time,open:a,high:e.high,low:e.low,close:r,wickUpColor:"rgba(0, 0, 0, 0)",wickDownColor:"rgba(0, 0, 0, 0)",borderVisible:!1}}})}getSeries(){return this.series}}class To{constructor(t,e){this.series=null,this._chart=null,this._renderer=null,this._chartData=[],this._width=0,this._height=0,this._isAttached=!1,this.channelWidthPercent=.3,this._timeScale=null,this._lineWidth=2,this.refreshData=r=>{if(!this.series)return;this._chartData=r.props.chartData||[];const a=this.transformToBaselineData(r.props.chartData);a.length>0&&this.series.setData(a),this.requestUpdate()},this.updateStyle=r=>{this.series&&this.series.applyOptions(r)},this.destroy=r=>{if(!this.series)return;if(!r||!r.props||!r.props.chart){this.series=null;return}const a=this.series;this.series=null;try{r.props.chart.removeSeries(a)}catch{}},this._chartData=t.props.chartData||[],this._chart=t.props.chart,this._timeScale=this._chart.timeScale(),this.series=t.props.chart.addSeries(et.LineSeries,{color:e.chart.lineColor||"#2196F3",lineWidth:this._lineWidth,priceLineVisible:!0,lastValueVisible:!0,priceFormat:{type:"price",precision:2,minMove:.01}}),this.attachChannelRenderer(t),t.props.chart.priceScale("right").applyOptions({scaleMargins:{top:.05,bottom:.1}});const i=this.transformToBaselineData(t.props.chartData);i.length>0&&this.series&&setTimeout(()=>{this.series.setData(i),this.requestUpdate()},0)}attachChannelRenderer(t){t.props.chartSeries&&t.props.chartSeries.series&&(this.attached({chart:t.props.chart,series:t.props.chartSeries.series}),t.props.chartSeries.series.attachPrimitive(this),this._isAttached=!0)}transformToBaselineData(t){return t.filter(i=>!i.isVirtual).map(i=>({time:i.time,value:i.close}))}attached(t){this._chart=t.chart,this.requestUpdate()}updateAllViews(){this.requestUpdate()}time(){return this._chartData.length>0?this._chartData[0].time:0}priceValue(){return this._chartData.length>0?this._chartData[0].close:0}paneViews(){return this._renderer||(this._renderer={draw:t=>{const e=t.context??t._context;if(!e||!this._chart)return;const i=this._chart.chartElement();if(!i)return;const r=i.getBoundingClientRect();this._width=r.width,this._height=r.height-29,!(this._width<=0||this._height<=0)&&this.drawChannel(e)}}),[{renderer:()=>this._renderer}]}drawChannel(t){if(!this.series||!this._timeScale)return;const e=this._timeScale.getVisibleRange();if(!e)return;const i=this._chartData.filter(o=>!o.isVirtual&&o.time>=e.from&&o.time<=e.to);if(i.length<2)return;const r=i.map(o=>o.close),a=5,s=[];for(let o=0;o<r.length;o++){const h=Math.max(0,o-a+1),l=o+1,g=r.slice(h,l);s.push(g.reduce((c,d)=>c+d,0)/g.length)}const n=(Math.max(...s)-Math.min(...s))*this.channelWidthPercent;this.drawChannelLines(t,i,n)}drawChannelLines(t,e,i){t.save(),t.beginPath(),t.strokeStyle="#26a69a",t.lineWidth=this._lineWidth,t.setLineDash([]);let r=!0;for(const s of e){const n=this._timeScale.timeToCoordinate(s.time),o=s.close+i,h=this.series.priceToCoordinate(o);n===null||h===null||(r?(t.moveTo(n,h),r=!1):t.lineTo(n,h))}t.stroke(),t.restore(),t.save(),t.beginPath(),t.strokeStyle="rgba(255, 0, 0, 0.8)",t.lineWidth=this._lineWidth,t.setLineDash([]);let a=!0;for(const s of e){const n=this._timeScale.timeToCoordinate(s.time),o=s.close-i,h=this.series.priceToCoordinate(o);n===null||h===null||(a?(t.moveTo(n,h),a=!1):t.lineTo(n,h))}t.stroke(),t.restore(),this.drawChannelFill(t,e,i)}drawChannelFill(t,e,i){if(!(e.length<2)){t.save(),t.beginPath();for(let r=0;r<e.length;r++){const a=e[r],s=this._timeScale.timeToCoordinate(a.time),n=a.close+i,o=this.series.priceToCoordinate(n);s===null||o===null||(r===0?t.moveTo(s,o):t.lineTo(s,o))}for(let r=e.length-1;r>=0;r--){const a=e[r],s=this._timeScale.timeToCoordinate(a.time),n=this.series.priceToCoordinate(a.close);s===null||n===null||t.lineTo(s,n)}t.closePath(),t.fillStyle="rgba(38, 166, 154, 0.3)",t.fill(),t.restore(),t.save(),t.beginPath();for(let r=0;r<e.length;r++){const a=e[r],s=this._timeScale.timeToCoordinate(a.time),n=this.series.priceToCoordinate(a.close);s===null||n===null||(r===0?t.moveTo(s,n):t.lineTo(s,n))}for(let r=e.length-1;r>=0;r--){const a=e[r],s=this._timeScale.timeToCoordinate(a.time),n=a.close-i,o=this.series.priceToCoordinate(n);s===null||o===null||t.lineTo(s,o)}t.closePath(),t.fillStyle="rgba(239, 83, 80, 0.3)",t.fill(),t.restore()}}requestUpdate(){if(this._chart&&this._isAttached)try{this._chart._internal__paneUpdate&&this._chart._internal__paneUpdate()}catch{}}getSeries(){return this.series}setChannelWidth(t){this.channelWidthPercent=Math.max(.01,Math.min(1,t)),this.requestUpdate()}getChannelWidth(){return this.channelWidthPercent}}class wo{constructor(t,e){this.series=null,this.refreshData=r=>{if(!this.series)return;const a=r.props.chartData.filter(o=>!o.isVirtual),s=a.length>0?a.reduce((o,h)=>o+h.close,0)/a.length:0;this.series.applyOptions({baseValue:{type:"price",price:s}});const n=r.props.chartData.map(o=>o.isVirtual?{time:o.time,value:o.close,topLineColor:"rgba(0, 0, 0, 0)",topFillColor1:"rgba(0, 0, 0, 0)",topFillColor2:"rgba(0, 0, 0, 0)",bottomLineColor:"rgba(0, 0, 0, 0)",bottomFillColor1:"rgba(0, 0, 0, 0)",bottomFillColor2:"rgba(0, 0, 0, 0)"}:{time:o.time,value:o.close});n.length>0&&this.series.setData(n)},this.updateStyle=r=>{this.series&&this.series.applyOptions(r)},this.destroy=r=>{if(!this.series)return;if(!r||!r.props||!r.props.chart){this.series=null;return}const a=this.series;this.series=null;try{r.props.chart.removeSeries(a)}catch{}},this.series=t.props.chart.addSeries(et.BaselineSeries,{baseValue:{type:"price",price:0},topLineColor:e.chart.candleUpColor||"#26a69a",topFillColor1:"rgba(38, 166, 154, 0.28)",topFillColor2:"rgba(38, 166, 154, 0.05)",bottomLineColor:e.chart.candleDownColor||"#ef5350",bottomFillColor1:"rgba(239, 83, 80, 0.05)",bottomFillColor2:"rgba(239, 83, 80, 0.28)",priceLineVisible:!0,lastValueVisible:!0,priceFormat:{type:"price",precision:2,minMove:.01}}),t.props.chart.priceScale("right").applyOptions({scaleMargins:{top:.05,bottom:.1}});const i=this.transformToBaselineData(t.props.chartData);i.length>0&&this.series&&setTimeout(()=>{this.series.setData(i)},0)}transformToBaselineData(t){const e=t.filter(r=>!r.isVirtual),i=e.length>0?e.reduce((r,a)=>r+a.close,0)/e.length:0;return this.series&&this.series.applyOptions({baseValue:{type:"price",price:i}}),t.map(r=>({time:r.time,value:r.close,...r.isVirtual&&{topLineColor:"rgba(0, 0, 0, 0)",topFillColor1:"rgba(0, 0, 0, 0)",topFillColor2:"rgba(0, 0, 0, 0)",bottomLineColor:"rgba(0, 0, 0, 0)",bottomFillColor1:"rgba(0, 0, 0, 0)",bottomFillColor2:"rgba(0, 0, 0, 0)"}}))}getSeries(){return this.series}}class Ao{constructor(t,e){this.currentChart=null,this.currentType=null,this.chartLayer=t,this.theme=e}switchChartType(t){if(!(this.currentType===t&&this.currentChart))switch(this.destroyCurrentChart(),this.currentType=t,t){case z.Candle:this.currentChart=new _i(this.chartLayer,this.theme);break;case z.HollowCandle:this.currentChart=new Po(this.chartLayer,this.theme);break;case z.Bar:this.currentChart=new go(this.chartLayer,this.theme);break;case z.Line:this.currentChart=new po(this.chartLayer,this.theme);break;case z.Area:this.currentChart=new fo(this.chartLayer,this.theme);break;case z.StepLine:this.currentChart=new Mo(this.chartLayer,this.theme);break;case z.BaseLine:this.currentChart=new mo(this.chartLayer,this.theme);break;case z.Histogram:this.currentChart=new ko(this.chartLayer,this.theme);break;case z.HeikinAshi:this.currentChart=new So(this.chartLayer,this.theme);break;case z.LineBreak:this.currentChart=new _o(this.chartLayer,this.theme);break;case z.Mountain:this.currentChart=new Co(this.chartLayer,this.theme);break;case z.BaselineArea:this.currentChart=new wo(this.chartLayer,this.theme);break;case z.HighLow:this.currentChart=new bo(this.chartLayer,this.theme);break;case z.HLCArea:this.currentChart=new To(this.chartLayer,this.theme);break;default:console.warn(`Unknown chart type: ${t}`),this.currentChart=new _i(this.chartLayer,this.theme);break}}refreshData(){this.currentChart&&this.currentChart.refreshData(this.chartLayer)}updateStyle(t){this.currentChart&&this.currentChart.updateStyle(t)}getCurrentSeries(){return this.currentChart?this.currentChart.getSeries():null}getCurrentType(){return this.currentType}destroyCurrentChart(){this.currentChart&&(this.currentChart.destroy(this.chartLayer),this.currentChart=null)}destroy(){this.destroyCurrentChart(),this.currentType=null}}class vo{constructor(t,e,i,r){this._chart=null,this._series=null,this._renderer=null,this._chartData=[],this._width=0,this._height=0,this._isAttached=!1,this._menu=null,this._heatMapRect={x:0,y:0,width:0,height:0},this._contextMenuHandler=null,this._clickHandler=null,this._resizeHandler=null,this.refreshData=a=>{this._chartData=a.props.chartData||[],this.requestUpdate()},this._closeCallBack=r,this.initializeHeatMap(t,e,i)}initializeHeatMap(t,e,i){this._chartData=t.props.chartData||[],this._i18n=e,this._theme=i,t.props.chartSeries&&t.props.chartSeries.series&&(this.attached({chart:t.props.chart,series:t.props.chartSeries.series}),t.props.chartSeries.series.attachPrimitive(this),this._isAttached=!0,this.bindContextMenu(t.props.chart))}bindContextMenu(t){const e=t.chartElement();e&&(this._contextMenuHandler=i=>{this.isInHeatMapArea(i.offsetX,i.offsetY)&&(i.preventDefault(),this.showContextMenu(i.clientX,i.clientY))},this._clickHandler=i=>{this._menu&&!this._menu.contains(i.target)&&this.hideContextMenu()},this._resizeHandler=()=>this.updateHeatMapRect(),e.addEventListener("contextmenu",this._contextMenuHandler),document.addEventListener("click",this._clickHandler),window.addEventListener("resize",this._resizeHandler))}isInHeatMapArea(t,e){return this.updateHeatMapRect(),t>=this._heatMapRect.x&&t<=this._heatMapRect.x+this._heatMapRect.width&&e>=this._heatMapRect.y&&e<=this._heatMapRect.y+this._heatMapRect.height}updateHeatMapRect(){if(!this._chart)return;const t=this._chart.chartElement();if(!t)return;const e=t.getBoundingClientRect(),i=e.width*.25,r=e.width-i;this._heatMapRect={x:r,y:0,width:i,height:e.height-29}}showContextMenu(t,e){this.hideContextMenu(),this._menu=document.createElement("div"),this._menu.style.position="fixed",this._menu.style.left=`${t}px`,this._menu.style.top=`${e}px`,this._menu.style.background=this._theme?.panel.backgroundColor||"#FFFFFF",this._menu.style.border=`1px solid ${this._theme?.panel.borderColor||"#E1E5E9"}`,this._menu.style.borderRadius="4px",this._menu.style.boxShadow="0 2px 8px rgba(0,0,0,0.15)",this._menu.style.zIndex="1000",this._menu.style.padding="4px 0",this._menu.style.minWidth="120px",this._menu.style.fontFamily="Arial, sans-serif",this._menu.style.fontSize="14px";const i=document.createElement("button");i.textContent=this._i18n?.close||"Close",i.style.background="none",i.style.border="none",i.style.padding="6px 12px",i.style.width="100%",i.style.textAlign="left",i.style.cursor="pointer",i.style.color=this._theme?.modal.textColor||"#2D323D",i.style.transition="background-color 0.2s",i.addEventListener("mouseenter",()=>{i.style.backgroundColor=this._theme?.toolbar.button.hover||"#2D323D"}),i.addEventListener("mouseleave",()=>{i.style.backgroundColor="transparent"}),i.addEventListener("click",()=>{this.destroy(),this.hideContextMenu()}),this._menu.appendChild(i),document.body.appendChild(this._menu)}hideContextMenu(){this._menu&&(document.body.removeChild(this._menu),this._menu=null)}attached(t){this._chart=t.chart,this._series=t.series,this.requestUpdate(),setTimeout(()=>this.updateHeatMapRect(),0)}updateAllViews(){this.requestUpdate(),this.updateHeatMapRect()}time(){return this._chartData.length>0?this._chartData[0].time:0}priceValue(){return this._chartData.length>0?this._chartData[0].close:0}updateI18n(t){this._i18n=t}updateTheme(t){this._theme=t}paneViews(){return this._renderer||(this._renderer={draw:t=>{const e=t.context??t._context;if(!e||!this._chart)return;const i=this._chart.chartElement();if(!i)return;const r=i.getBoundingClientRect();this._width=r.width,this._height=r.height-29,!(this._width<=0||this._height<=0)&&(this.drawHeatMap(e),this.updateHeatMapRect())}}),[{renderer:()=>this._renderer}]}drawHeatMap(t){const e=this._chartData;if(!e||e.length===0)return;const i=e.filter(u=>!u.isVirtual&&u.volume);if(i.length===0)return;const r=Math.min(...i.map(u=>u.low)),s=Math.max(...i.map(u=>u.high))-r;if(s<=0)return;const n=this._width*.25,o=this._width-n,h=Math.min(200,Math.floor(this._height/2)),l=new Array(h).fill(0);i.forEach(u=>{const p=Math.min(h-1,Math.max(0,Math.floor((u.high-r)/s*h))),M=Math.min(h-1,Math.max(0,Math.floor((u.low-r)/s*h))),k=Math.max(1,p-M+1),P=u.volume/k;for(let S=M;S<=p;S++)l[S]+=P});const g=Math.max(...l);if(g===0)return;const c=2,d=this._height/h;t.save();for(let u=0;u<h;u++){const p=l[u];if(p===0)continue;const M=p/g,P=Math.max(M,.01),S=Math.max(c,n*P),_=Math.pow(P,.5);let C,A,x;if(_<.5){const K=_*2;C=Math.floor(0),A=Math.floor(165*K),x=Math.floor(255*(1-K)+255*K)}else{const K=(_-.5)*2;C=Math.floor(255*K),A=Math.floor(255*(1-K)),x=Math.floor(255*(1-K))}const R=.4+_*.6,U=`rgba(${C}, ${A}, ${x}, ${R})`,L=o+(n-S),X=this._height-(u+1)*d;t.fillStyle=U,t.fillRect(L,X,S,d)}t.restore()}requestUpdate(){if(this._chart&&this._isAttached)try{this._chart._internal__paneUpdate&&this._chart._internal__paneUpdate(),this._series&&this._series._internal__dataChanged&&this._series._internal__dataChanged()}catch{}}destroy(){const t=this._chart?.chartElement();if(t&&this._contextMenuHandler&&t.removeEventListener("contextmenu",this._contextMenuHandler),this._clickHandler&&document.removeEventListener("click",this._clickHandler),this._resizeHandler&&window.removeEventListener("resize",this._resizeHandler),this._series&&this._isAttached)try{this._series.detachPrimitive(this),this._isAttached=!1}catch{}this.hideContextMenu(),this._renderer=null,this._isAttached=!1,this._menu=null,this._contextMenuHandler=null,this._clickHandler=null,this._resizeHandler=null,this._closeCallBack?.()}reactivate(){if(this._chart&&this._series&&!this._isAttached)try{this._series.attachPrimitive(this),this._isAttached=!0,this.bindContextMenu(this._chart),this.requestUpdate()}catch{}}}class xo{constructor(t,e,i,r){this._chart=null,this._series=null,this._renderer=null,this._chartData=[],this._width=0,this._height=0,this._isAttached=!1,this._cachedProfile=null,this._lastDataHash="",this._widthProportion=.35,this._menu=null,this._profileRect={x:0,y:0,width:0,height:0},this._contextMenuHandler=null,this._clickHandler=null,this._resizeHandler=null,this.refreshData=a=>{this._chartData=a.props.chartData||[],this._cachedProfile=null,this.requestUpdate()},this._closeCallBack=r,this._config={profileWidth:.15,timeSlotMinutes:30,valueAreaPercent:.7,tickSize:.01,showInitialBalance:!0,showValueArea:!0,maxPriceLevels:80,simplifyTPO:!0},this.initializeMarketProfile(t,e,i)}initializeMarketProfile(t,e,i){this._chartData=t.props.chartData||[],this._i18n=e,this._theme=i,t.props.chartSeries&&t.props.chartSeries.series&&(this.attached({chart:t.props.chart,series:t.props.chartSeries.series}),t.props.chartSeries.series.attachPrimitive(this),this._isAttached=!0,this.bindContextMenu(t.props.chart))}bindContextMenu(t){const e=t.chartElement();e&&(this._contextMenuHandler=i=>{this.isInProfileArea(i.offsetX,i.offsetY)&&(i.preventDefault(),this.showContextMenu(i.clientX,i.clientY))},this._clickHandler=i=>{this._menu&&!this._menu.contains(i.target)&&this.hideContextMenu()},this._resizeHandler=()=>this.updateProfileRect(),e.addEventListener("contextmenu",this._contextMenuHandler),document.addEventListener("click",this._clickHandler),window.addEventListener("resize",this._resizeHandler))}isInProfileArea(t,e){return this.updateProfileRect(),t>=this._profileRect.x&&t<=this._profileRect.x+this._profileRect.width&&e>=this._profileRect.y&&e<=this._profileRect.y+this._profileRect.height}updateProfileRect(){if(!this._chart)return;const t=this._chart.chartElement();if(!t)return;const e=t.getBoundingClientRect(),i=e.width*this._widthProportion,r=0;this._profileRect={x:r,y:0,width:i,height:e.height-29}}showContextMenu(t,e){this.hideContextMenu(),this._menu=document.createElement("div"),this._menu.style.position="fixed",this._menu.style.left=`${t}px`,this._menu.style.top=`${e}px`,this._menu.style.background=this._theme?.panel.backgroundColor||"#FFFFFF",this._menu.style.border=`1px solid ${this._theme?.panel.borderColor||"#E1E5E9"}`,this._menu.style.borderRadius="4px",this._menu.style.boxShadow="0 2px 8px rgba(0,0,0,0.15)",this._menu.style.zIndex="1000",this._menu.style.padding="4px 0",this._menu.style.minWidth="120px",this._menu.style.fontFamily="Arial, sans-serif",this._menu.style.fontSize="14px";const i=document.createElement("button");i.textContent=this._i18n?.close||"Close",i.style.background="none",i.style.border="none",i.style.padding="6px 12px",i.style.width="100%",i.style.textAlign="left",i.style.cursor="pointer",i.style.color=this._theme?.modal.textColor||"#2D323D",i.style.transition="background-color 0.2s",i.addEventListener("mouseenter",()=>{i.style.backgroundColor=this._theme?.toolbar.button.hover||"#2D323D"}),i.addEventListener("mouseleave",()=>{i.style.backgroundColor="transparent"}),i.addEventListener("click",()=>{this.destroy(),this.hideContextMenu()}),this._menu.appendChild(i),document.body.appendChild(this._menu)}hideContextMenu(){this._menu&&(document.body.removeChild(this._menu),this._menu=null)}attached(t){this._chart=t.chart,this._series=t.series,this.requestUpdate(),setTimeout(()=>this.updateProfileRect(),0)}updateAllViews(){this.requestUpdate(),this.updateProfileRect()}time(){return this._chartData.length>0?this._chartData[0].time:0}priceValue(){return this._chartData.length>0?this._chartData[0].close:0}updateI18n(t){this._i18n=t}updateTheme(t){this._theme=t}paneViews(){return this._renderer||(this._renderer={draw:t=>{const e=t.context??t._context;if(!e||!this._chart)return;const i=this._chart.chartElement();if(!i)return;const r=i.getBoundingClientRect();this._width=r.width,this._height=r.height-29,!(this._width<=0||this._height<=0)&&(this.drawMarketProfile(e),this.updateProfileRect())}}),[{renderer:()=>this._renderer}]}drawMarketProfile(t){const e=this._chartData;if(!e||e.length===0)return;const i=this.getDataHash(e);if((!this._cachedProfile||this._lastDataHash!==i)&&(this._cachedProfile=this.calculateProfile(e),this._lastDataHash=i),!this._cachedProfile)return;const r=this._width*this._widthProportion;t.clearRect(0,0,r,this._height),this.drawProfileBars(t,this._cachedProfile,r),this._config.showValueArea&&this.drawValueArea(t,this._cachedProfile,r)}getDataHash(t){return t.length===0?"empty":`${t.length}_${t[0].time}_${t[t.length-1].time}`}calculateProfile(t){if(t.length===0)return null;const e=t.filter(c=>!c.isVirtual);if(e.length===0)return null;const i=Math.min(...e.map(c=>c.low)),r=Math.max(...e.map(c=>c.high)),a=r-i;if(a<=0)return null;const s=Math.min(this._config.maxPriceLevels,Math.floor(this._height/3)),n=a/s,o=[];for(let c=0;c<=s;c++)o.push({price:i+c*n,count:0,volume:0});e.forEach(c=>{const d=this.findPriceLevel(o,c.high),u=this.findPriceLevel(o,c.low);for(let p=u;p<=d;p++)o[p].count++,o[p].volume+=c.volume||0});const h=Math.max(...o.map(c=>c.count)),l=o.find(c=>c.count===h),g=this.calculateSimpleValueArea(o,this._config.valueAreaPercent);return{levels:o,minPrice:i,maxPrice:r,priceRange:a,poc:l?l.price:i+a/2,valueAreaHigh:g.high,valueAreaLow:g.low,maxCount:h}}findPriceLevel(t,e){const i=t[0].price,r=t[t.length-1].price,a=r-i;return e<=i?0:e>=r?t.length-1:Math.min(t.length-1,Math.max(0,Math.floor((e-i)/a*t.length)))}calculateSimpleValueArea(t,e){const r=t.reduce((l,g)=>l+g.count,0)*e,a=Math.max(...t.map(l=>l.count)),s=t.findIndex(l=>l.count===a);let n=0,o=s,h=s;for(;n<r&&(o<t.length-1||h>0);){let l=o<t.length-1?t[o+1].count:0,g=h>0?t[h-1].count:0;if(l>=g&&o<t.length-1)o++,n+=t[o].count;else if(h>0)h--,n+=t[h].count;else break}return{high:t[o].price,low:t[h].price}}drawProfileBars(t,e,i){const{levels:r,minPrice:a,maxPrice:s,priceRange:n,maxCount:o}=e;if(n<=0)return;t.save();const h=i,l=this._height/r.length;r.forEach(g=>{if(g.count===0)return;const c=(g.price-a)/n,d=this._height-c*this._height,u=g.count/o,p=l,M=this.getProfileColor(u);t.fillStyle=M;const k=Math.max(2,h*u*.8);t.fillRect(0,d-p/2,k,p)}),t.restore()}drawValueArea(t,e,i){const{valueAreaHigh:r,valueAreaLow:a,minPrice:s,maxPrice:n,priceRange:o,poc:h}=e;if(o<=0)return;const l=(r-s)/o,g=(a-s)/o,c=(h-s)/o,d=this._height-l*this._height,u=this._height-g*this._height,p=this._height-c*this._height;t.save(),t.fillStyle="rgba(255, 215, 0, 0.1)",t.fillRect(0,d,i,u-d),t.strokeStyle="rgba(255, 215, 0, 0.6)",t.lineWidth=1,t.setLineDash([3,2]),t.beginPath(),t.moveTo(0,d),t.lineTo(i,d),t.stroke(),t.beginPath(),t.moveTo(0,u),t.lineTo(i,u),t.stroke(),t.strokeStyle="rgba(255, 0, 0, 0.8)",t.setLineDash([]),t.lineWidth=1,t.beginPath(),t.moveTo(0,p),t.lineTo(i,p),t.stroke(),t.restore()}getProfileColor(t){return t<.3?"rgba(100, 150, 255, 0.4)":t<.6?"rgba(50, 100, 200, 0.6)":"rgba(0, 50, 150, 0.8)"}requestUpdate(){if(this._chart&&this._isAttached)try{this._chart._internal__paneUpdate&&this._chart._internal__paneUpdate(),this._series&&this._series._internal__dataChanged&&this._series._internal__dataChanged()}catch{}}destroy(){const t=this._chart?.chartElement();if(t&&this._contextMenuHandler&&t.removeEventListener("contextmenu",this._contextMenuHandler),this._clickHandler&&document.removeEventListener("click",this._clickHandler),this._resizeHandler&&window.removeEventListener("resize",this._resizeHandler),this._series&&this._isAttached)try{this._series.detachPrimitive(this),this._isAttached=!1}catch{}this.hideContextMenu(),this._renderer=null,this._isAttached=!1,this._menu=null,this._contextMenuHandler=null,this._clickHandler=null,this._resizeHandler=null,this._closeCallBack?.()}reactivate(){if(this._chart&&this._series&&!this._isAttached)try{this._series.attachPrimitive(this),this._isAttached=!0,this.bindContextMenu(this._chart),this.requestUpdate()}catch{}}}class Do extends E.Component{constructor(t){super(t),this.canvasRef=E.createRef(),this.containerRef=E.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.swtichMainChartType=()=>{this.mainChartManager?.switchChartType(this.props.currentMainChartType),this.mainChartManager?.refreshData(),this.updateStaticMark()},this.setCursorType=e=>{e&&this.setState({cursorType:e})},this.initializeMainChartIndicators=()=>{if(!this.mainChartTechnicalIndicatorManager)return;const{selectedMainChartIndicator:e}=this.props;e&&this.updateSelectedMainChartIndicators()},this.updateAllMainChartIndicatorData=()=>{const{selectedMainChartIndicators:e}=this.state;e.forEach(i=>{i.type!==null&&this.mainChartTechnicalIndicatorManager?.updateAllMainChartIndicatorData(this,i)})},this.updateMainChartIndicators=()=>{const{selectedMainChartIndicators:e}=this.state;e.forEach(i=>{i.type!==null&&(this.mainChartTechnicalIndicatorManager?.removeIndicator(this.props.chart,i.type),this.mainChartTechnicalIndicatorManager?.updateMainChartIndicator(this,i))})},this.updateSelectedMainChartIndicators=()=>{if(!this.mainChartTechnicalIndicatorManager||!this.props.chartData)return;const{selectedMainChartIndicator:e}=this.props;e&&(F.HEATMAP===e.type||F.MARKETPROFILE===e.type||this.setState(i=>{const r=i.selectedMainChartIndicators.some(o=>o.type===e.type);let a;r?a=i.selectedMainChartIndicators.map(o=>o.type===e.type?e:o):a=[...i.selectedMainChartIndicators,e];const s=a.map(o=>o.type).filter(o=>o!==null),n=Xt().map(o=>{if(o.type&&s.includes(o.type)){const h=a.find(l=>l.type===o.type);return{...o,visible:!0,params:h?.params||o.params}}return{...o,visible:!1}});return{selectedMainChartIndicators:a,selectedMainChartIndicatorTypes:s,modalConfirmChartInfoIndicators:n}},()=>{this.updateMainChartIndicators()}))},this.handleOpenIndicatorSettings=e=>{e.type&&this.setState({modalEditingChartInfoIndicator:e,isMainChartIndicatorsModalOpen:!0})},this.handleMainChartIndicatorsSettingConfirm=e=>{e.params&&(e.params=e.params.filter(i=>i.paramValue!==0));try{this.mainChartTechnicalIndicatorManager?.updateMainChartIndicator(this,e),this.setState(i=>({selectedMainChartIndicators:i.selectedMainChartIndicators.map(r=>r.type===e.type?e:r)})),this.setState({isMainChartIndicatorsModalOpen:!1,modalEditingChartInfoIndicator:null})}catch{this.setState({isMainChartIndicatorsModalOpen:!1,modalEditingChartInfoIndicator:null})}},this.handleRemoveIndicator=e=>{if(!(!e||!this.mainChartTechnicalIndicatorManager||!this.props.chart)){if(e===F.HEATMAP){setTimeout(()=>{this.volumeHeatMap&&(this.volumeHeatMap.destroy(),this.volumeHeatMap=null)},0);return}if(e===F.MARKETPROFILE){setTimeout(()=>{this.marketProfile&&(this.marketProfile.destroy(),this.marketProfile=null)},0);return}this.mainChartTechnicalIndicatorManager.removeIndicator(this.props.chart,e),this.setState(i=>({selectedMainChartIndicators:i.selectedMainChartIndicators.filter(r=>r.type!==e),selectedMainChartIndicatorTypes:i.selectedMainChartIndicatorTypes.filter(r=>r!==e)})),this.props.onMainChartIndicatorChange&&this.props.selectedMainChartIndicator?.type===e&&this.props.onMainChartIndicatorChange(null),this.props.onToolSelect&&this.props.selectedMainChartIndicator?.type===e&&this.props.onToolSelect("")}},this.setMockKLineMarkMode=()=>{this.chartMarkManager?.setMockKLineMarkMode(this)},this.initializeGraphManager=()=>{this.chartMarkManager?.initializeMarkManager(this)},this.initializeGraphManagerProps=()=>{this.chartMarkManager?.initializeMarkManagerProps(this)},this.destroyGraphManager=()=>{this.chartMarkManager?.destroyMarkManager()},this.showAllMark=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.showAllMarks()},this.hideAllMark=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.hideAllMarks()},this.clearAllMark=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.deleteAllMark()},this.setSchiffPitchforkMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setSchiffPitchforkMode(this)},this.setHeatMapMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setHeatMapMode(this)},this.setTextEditMarkMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setTextEditMarkMode(this)},this.setBubbleBoxMarkMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setBubbleBoxMarkMode(this)},this.setPinMarkMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setPinMarkMode(this)},this.setEmojiMarkMode=e=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setEmojiMarkMode(this,e)},this.setSignpostMarkMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setSignpostMarkMode(this)},this.setPriceNoteMarkMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setPriceNoteMarkMode(this)},this.setFlagMarkMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setFlagMarkMode(this)},this.setPriceLabelMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setPriceLabelMode(this)},this.setShortPositionMarkMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setShortPositionMarkMode(this)},this.setLongPositionMarkMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setLongPositionMarkMode(this)},this.setThickArrowLineMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setThickArrowLineMode(this)},this.setEraserMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setEraserMode(this)},this.setMarkerPenMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setMarkerPenMode(this)},this.setBrushMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setBrushMode(this)},this.setPenMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setPenMode(this)},this.setPencilMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setPencilMode(this)},this.setTimePriceRangeMarkMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setTimePriceRangeMarkMode(this)},this.setPriceRangeMarkMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setPriceRangeMarkMode(this)},this.setTimeRangeMarkMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setTimeRangeMarkMode(this)},this.setElliottTripleCombinationMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setElliottTripleCombinationMode(this)},this.setElliottDoubleCombinationMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setElliottDoubleCombinationMode(this)},this.setElliottTriangleMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setElliottTriangleMode(this)},this.setElliottCorrectiveMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setElliottCorrectiveMode(this)},this.setElliottImpulseMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setElliottImpulseMode(this)},this.setTriangleABCDMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setTriangleABCDMode(this)},this.setABCDMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setABCDMode(this)},this.setHeadAndShouldersMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setHeadAndShouldersMode(this)},this.setXABCDMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setXABCDMode(this)},this.setDoubleCurveMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setDoubleCurveMode(this)},this.setCurveMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setCurveMode(this)},this.setSectorMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setSectorMode(this)},this.setFibonacciExtensionBaseTimeMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setFibonacciExtensionBaseTimeMode(this)},this.setFibonacciExtensionBasePriceMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setFibonacciExtensionBasePriceMode(this)},this.setFibonacciChannelMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setFibonacciChannelMode(this)},this.setFibonacciFanMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setFibonacciFanMode(this)},this.setFibonacciWedgeMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setFibonacciWedgeMode(this)},this.setFibonacciSpiralMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setFibonacciSpiralMode(this)},this.setFibonacciCircleMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setFibonacciCircleMode(this)},this.setFibonacciArcMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setFibonacciArcMode(this)},this.setFibonacciRetracementMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setFibonacciRetracementMode(this)},this.setFibonacciTimeZoonMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setFibonacciTimeZoonMode(this)},this.setGannRectangleMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setGannRectangleMode(this)},this.setGannBoxMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setGannBoxMode(this)},this.setGannFanMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setGannFanMode(this)},this.setTriangleMarkMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setTriangleMarkMode(this)},this.setEllipseMarkMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setEllipseMarkMode(this)},this.setCircleMarkMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setCircleMarkMode(this)},this.setRectangleMarkMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setRectangleMarkMode(this)},this.setEnhancedAndrewPitchforkMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setEnhancedAndrewPitchforkMode(this)},this.setAndrewPitchforkMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setAndrewPitchforkMode(this)},this.setDisjointChannelMarkMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setDisjointChannelMarkMode(this)},this.setEquidistantChannelMarkMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setEquidistantChannelMarkMode(this)},this.setLinearRegressionChannelMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setLinearRegressionChannelMode(this)},this.setLineSegmentMarkMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setLineSegmentMarkMode(this)},this.setHorizontalLineMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setHorizontalLineMode(this)},this.setVerticalLineMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setVerticalLineMode(this)},this.setArrowLineMarkMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setArrowLineMarkMode(this)},this.setParallelChannelMarkMode=()=>{this.chartMarkManager?.closeAllBrushTools(this),this.chartMarkManager?.setParallelChannelMarkMode(this)},this.showGraphMarkToolBar=e=>{if(this.state.selectedGraphMark&&this.state.selectedGraphMark.id===e.id||this.state.selectedGraphMark)return;let i={x:20,y:20};if(e.points.length>0){const r=e.points[0];i={x:Math.max(10,r.x-150),y:Math.max(10,r.y-80)}}this.setState({selectedGraphMark:e,markToolBarPosition:i,showGraphMarkToolBar:!0})},this.closeGraphMarkToolBar=()=>{this.setState({showGraphMarkToolBar:!1})},this.showTableMarkToolBar=e=>{if(this.state.selectedTableMark&&this.state.selectedTableMark.id===e.id||this.state.selectedTableMark)return;let i={x:20,y:20};if(e.points.length>0){const r=e.points[0];i={x:Math.max(10,r.x-150),y:Math.max(10,r.y-80)}}this.setState({selectedTableMark:e,markToolBarPosition:i,showTableMarkToolBar:!0})},this.closeTableMarkToolBar=()=>{this.setState({showTableMarkToolBar:!1})},this.showTextEditMarkToolBar=(e,i)=>{if(this.state.selectedTextEditMark&&this.state.selectedTextEditMark.id===e.id||this.state.selectedTextEditMark)return;let r={x:20,y:20};if(e.points.length>0){const a=e.points[0];r={x:Math.max(10,a.x-150),y:Math.max(10,a.y-80)}}this.setState({selectedTextEditMark:e,markToolBarPosition:r,showTextMarkToolBar:!0,isShowGrapTool:i})},this.closeTextMarkToolBar=()=>{this.setState({showTextMarkToolBar:!1})},this.handleMouseDown=e=>{this.chartEventManager?.mouseDown(this,e)},this.handleMouseUp=e=>{this.chartEventManager?.mouseUp(this,e)},this.handleMouseMove=e=>{this.chartEventManager?.mouseMove(this,e)},this.handleViewportShiftLeft=()=>{this.props.chart&&this.props.viewportManager&&this.props.viewportManager.scrollChart("left")},this.handleViewportShiftRight=()=>{this.props.chart&&this.props.viewportManager&&this.props.viewportManager.scrollChart("right")},this.handleZoomIn=()=>{this.props.viewportManager&&this.props.viewportManager.zoomIn()},this.handleZoomOut=()=>{this.props.viewportManager&&this.props.viewportManager.zoomOut()},this.openIndicatorsModal=()=>{this.setState({isMainChartIndicatorsModalOpen:!0})},this.handleToggleIndicator=e=>{e&&(this.mainChartTechnicalIndicatorManager?.isVisible(e)?this.mainChartTechnicalIndicatorManager?.hideIndicator(e):this.mainChartTechnicalIndicatorManager?.showIndicator(e))},this.renderChartInfo=()=>{const{currentTheme:e,title:i}=this.props,{currentOHLC:r,mousePosition:a,showOHLC:s,maIndicatorValues:n,emaIndicatorValues:o,bollingerBandsValues:h,ichimokuValues:l,donchianChannelValues:g,envelopeValues:c,vwapValue:d,selectedMainChartIndicators:u}=this.state;return m.jsx(Ln,{currentTheme:e,title:i,currentOHLC:r,mousePosition:a,showOHLC:s,onToggleOHLC:this.toggleOHLCVisibility,onOpenIndicatorsModal:this.openIndicatorsModal,onOpenIndicatorSettings:this.handleOpenIndicatorSettings,onRemoveIndicator:this.handleRemoveIndicator,onToggleIndicator:this.handleToggleIndicator,visibleIndicatorTypes:this.state.selectedMainChartIndicatorTypes,indicators:u,maIndicatorValues:n,emaIndicatorValues:o,bollingerBandsValues:h,ichimokuValues:l,donchianChannelValues:g,envelopeValues:c,vwapValue:d,i18n:this.props.i18n})},this.handleIndicatorsClose=()=>{this.setState({isMainChartIndicatorsModalOpen:!1,modalEditingChartInfoIndicator:null,selectedMainChartIndicators:[]})},this.setImageMarkMode=()=>{this.chartMarkManager?.imageMarkManager&&this.setState({isImageUploadModalOpen:!0})},this.handleImageConfirm=e=>{if(this.setSelectedImageUrl(e),this.setState({isImageUploadModalOpen:!1}),this.chartMarkManager?.imageMarkManager){this.chartMarkManager?.imageMarkManager.setSelectedImageUrl(e);const i=this.chartMarkManager?.imageMarkManager.startImageMarkMode();this.setState({isImageMarkMode:i.isImageMarkMode,imageMarkStartPoint:i.imageMarkStartPoint,currentImageMark:i.currentImageMark,currentMarkMode:w.Image})}},this.handleImageUploadClose=()=>{this.setState({isImageUploadModalOpen:!1}),this.props.onCloseDrawing&&this.props.onCloseDrawing()},this.setSelectedImageUrl=e=>{this.chartMarkManager?.imageMarkManager&&this.chartMarkManager?.imageMarkManager.setSelectedImageUrl(e),this.setState({selectedImageUrl:e})},this.handleChangeTextMarkFontColor=e=>{this.state.selectedTextEditMark&&this.currentMarkSettingsStyle&&this.currentMarkSettingsStyle.updateStyles({color:e})},this.handleChangeTextMarkStyle=e=>{let i=e.isBold,r=e.isItalic;this.state.selectedTextEditMark&&this.currentMarkSettingsStyle&&this.currentMarkSettingsStyle.updateStyles({isBold:i,isItalic:r})},this.handleChangeTextMarkFontSize=e=>{this.state.selectedTextEditMark&&this.currentMarkSettingsStyle&&this.currentMarkSettingsStyle.updateStyles({fontSize:e})},this.handleChangeTextMarkGraphColor=e=>{this.currentMarkSettingsStyle&&this.currentMarkSettingsStyle.updateStyles({graphColor:e})},this.handleChangeTextMarkGraphLineStyle=e=>{this.currentMarkSettingsStyle&&this.currentMarkSettingsStyle.updateStyles({graphLineStyle:e})},this.handleChangeTextMarkGraphLineWidth=e=>{this.currentMarkSettingsStyle&&this.currentMarkSettingsStyle.updateStyles({graphLineWidth:e})},this.handleDeleteTextEditMark=()=>{if(!this.state.selectedTextEditMark)return;const e=this.state.selectedTextEditMark,i=e.markType;this.chartMarkManager?.deleteMark(i,e.properties.originalMark),this.setState({selectedTextEditMark:null,markToolBarPosition:{x:20,y:20}})},this.handleTextMarkEditorSave=(e,i,r,a,s)=>{if(this.setState({isTextMarkEditorOpen:!1}),!!this.state.selectedTextEditMark&&(i&&this.handleChangeTextMarkFontColor(i),r&&this.handleChangeTextMarkFontSize(r),a&&this.handleChangeTextMarkStyle({isBold:a}),s&&this.handleChangeTextMarkStyle({isItalic:s}),e))switch(this.state.selectedTextEditMark.markType){case w.TextEdit:this.state.selectedTextEditMark.mark.updateText(e);break;case w.BubbleBox:this.state.selectedTextEditMark.mark.updateText(e);break;case w.Pin:this.state.selectedTextEditMark.mark.updateText(e);break;case w.SignPost:this.state.selectedTextEditMark.mark.updateText(e);break}},this.handleTextMarkEditorCancel=()=>{this.setState({isTextMarkEditorOpen:!1}),this.state.selectedTextEditMark},this.handleDeleteGraphMark=()=>{if(!this.state.selectedGraphMark)return;const e=this.state.selectedGraphMark;e.properties?.originalMark&&this.chartMarkManager?.deleteMark(e.markType,e.properties.originalMark),this.closeGraphMarkToolBar()},this.handleChangeGraphMarkColor=e=>{this.currentMarkSettingsStyle&&this.currentMarkSettingsStyle.updateStyles({color:e})},this.handleChangeGraphMarkStyle=e=>{this.currentMarkSettingsStyle&&this.currentMarkSettingsStyle.updateStyles({lineStyle:e})},this.handleChangeGraphMarkWidth=e=>{this.currentMarkSettingsStyle&&this.currentMarkSettingsStyle.updateStyles({lineWidth:e})},this.handleGraphToolbarDrag=e=>{this.setState({isGraphMarkToolbarDragging:!0,graphMarkToolbarDragStartPoint:e});const i=a=>{if(this.state.isGraphMarkToolbarDragging&&this.state.graphMarkToolbarDragStartPoint){const s=a.clientX-this.state.graphMarkToolbarDragStartPoint.x,n=a.clientY-this.state.graphMarkToolbarDragStartPoint.y;this.setState(o=>({markToolBarPosition:{x:Math.max(0,o.markToolBarPosition.x+s),y:Math.max(0,o.markToolBarPosition.y+n)},graphMarkToolbarDragStartPoint:{x:a.clientX,y:a.clientY}}))}},r=()=>{this.setState({isGraphMarkToolbarDragging:!1,graphMarkToolbarDragStartPoint:null}),document.removeEventListener("mousemove",i),document.removeEventListener("mouseup",r)};document.addEventListener("mousemove",i),document.addEventListener("mouseup",r)},this.handleKeyDown=e=>{this.chartEventManager?.handleKeyDown(this,e)},this.handleDocumentMouseUp=e=>{this.chartEventManager?.documentMouseUp(this,e)},this.handleDocumentMouseDown=e=>{this.chartEventManager?.documentMouseDown(this,e)},this.handleDocumentMouseMove=e=>{this.chartEventManager?.documentMouseMove(this,e)},this.handleDocumentMouseWheel=e=>{this.chartEventManager?.documentMouseWheel(this,e)},this.handleTextMarkToolBarDrag=e=>{this.setState({isTextMarkToolbar:!0,dragStartPoint:e});const i=a=>{if(this.state.isTextMarkToolbar&&this.state.dragStartPoint){const s=a.clientX-this.state.dragStartPoint.x,n=a.clientY-this.state.dragStartPoint.y;this.setState(o=>({markToolBarPosition:{x:Math.max(0,o.markToolBarPosition.x+s),y:Math.max(0,o.markToolBarPosition.y+n)},dragStartPoint:{x:a.clientX,y:a.clientY}}))}},r=()=>{this.setState({isTextMarkToolbar:!1,dragStartPoint:null}),document.removeEventListener("mousemove",i),document.removeEventListener("mouseup",r)};document.addEventListener("mousemove",i),document.addEventListener("mouseup",r)},this.getToolName=e=>"",this.toggleOHLCVisibility=()=>{this.setState(e=>({showOHLC:!e.showOHLC}))},this.renderMainChart=()=>m.jsx("canvas",{ref:this.canvasRef,style:{position:"absolute",top:0,left:0,width:"calc(100% - 60px)",height:"calc(100% - 60px)",pointerEvents:"none",zIndex:1}}),this.showSubChartSettingModal=(e=[],i)=>{this.setState({isSubChartIndicatorsSettingModalOpen:!0,subChartIndicatorsSettingModalParams:e,currentSubChartIndicatorType:i})},this.handleSubChartSettingClose=()=>{this.setState({isSubChartIndicatorsSettingModalOpen:!1,subChartIndicatorsSettingModalParams:[],currentSubChartIndicatorType:null})},this.handleSubChartSettingConfirm=e=>{this.state.currentSubChartIndicatorType&&this.chartPanesManager?.updateSettingsBySubChartIndicatorType(this.props.chartData,e,this.state.currentSubChartIndicatorType),this.handleSubChartSettingClose()},this.state={isDrawing:!1,drawingPoints:[],currentDrawing:null,drawingStartPoint:null,drawings:[],selectedTextEditMark:null,selectedTableMark:null,selectedGraphMark:null,markToolBarPosition:{x:20,y:20},isTextMarkToolbar:!1,dragStartPoint:null,history:[],historyIndex:-1,isDragging:!1,isResizing:!1,isRotating:!1,resizeHandle:null,isTextInputActive:!1,textInputPosition:null,textInputValue:"",textInputCursorVisible:!0,textInputCursorTimer:null,activePanel:null,editingTextId:null,isFirstTimeTextMode:!1,isEmojiInputActive:!1,emojiInputPosition:null,editingEmojiId:null,mousePosition:null,currentOHLC:null,showOHLC:!0,pendingEmojiMark:null,isTextMarkEditorOpen:!1,textMarkEditorPosition:{x:0,y:0},textMarkEditorInitialData:{text:"",color:"#000000",fontSize:14,isBold:!1,isItalic:!1},lineSegmentMarkStartPoint:null,arrowLineMarkStartPoint:null,parallelChannelMarkStartPoint:null,currentLineSegmentMark:null,currentArrowLineMark:null,currentParallelChannelMark:null,currentMarkMode:null,showGraphMarkToolBar:!1,showTableMarkToolBar:!1,showTextMarkToolBar:!1,isShowGrapTool:!1,isGraphMarkToolbarDragging:!1,graphMarkToolbarDragStartPoint:null,linearRegressionChannelStartPoint:null,currentLinearRegressionChannel:null,equidistantChannelMarkStartPoint:null,currentEquidistantChannelMark:null,disjointChannelMarkStartPoint:null,currentDisjointChannelMark:null,andrewPitchforkHandlePoint:null,andrewPitchforkBaseStartPoint:null,currentAndrewPitchfork:null,enhancedAndrewPitchforkHandlePoint:null,enhancedAndrewPitchforkBaseStartPoint:null,currentEnhancedAndrewPitchfork:null,rectangleMarkStartPoint:null,currentRectangleMark:null,circleMarkStartPoint:null,currentCircleMark:null,ellipseMarkStartPoint:null,currentEllipseMark:null,triangleMarkStartPoint:null,currentTriangleMark:null,gannFanStartPoint:null,currentGannFan:null,gannBoxStartPoint:null,currentGannBox:null,gannRectangleStartPoint:null,currentGannRectangle:null,fibonacciTimeZoonStartPoint:null,currentFibonacciTimeZoon:null,fibonacciRetracementStartPoint:null,currentFibonacciRetracement:null,fibonacciArcStartPoint:null,currentFibonacciArc:null,fibonacciCircleCenterPoint:null,currentFibonacciCircle:null,fibonacciSpiralCenterPoint:null,currentFibonacciSpiral:null,fibonacciWedgeCenterPoint:null,currentFibonacciWedge:null,fibonacciWedgeDrawingStep:0,fibonacciWedgePoints:[],fibonacciFanStartPoint:null,currentFibonacciFan:null,currentFibonacciChannel:null,isFibonacciChannelMode:!1,fibonacciChannelDrawingStep:0,fibonacciExtensionBasePricePoints:[],currentFibonacciExtensionBasePrice:null,fibonacciExtensionBaseTimePoints:[],currentFibonacciExtensionBaseTime:null,sectorPoints:[],currentSector:null,curveMarkStartPoint:null,currentCurveMark:null,doubleCurveMarkStartPoint:null,currentDoubleCurveMark:null,xabcdPoints:[],currentXABCDMark:null,headAndShouldersPoints:[],currentHeadAndShouldersMark:null,abcdPoints:[],currentABCDMark:null,triangleABCDPoints:[],currentTriangleABCDMark:null,elliottImpulsePoints:[],currentElliottImpulseMark:null,elliottCorrectivePoints:[],currentElliottCorrectiveMark:null,elliottTrianglePoints:[],currentElliottTriangleMark:null,elliottDoubleCombinationPoints:[],currentElliottDoubleCombinationMark:null,elliottTripleCombinationPoints:[],currentElliottTripleCombinationMark:null,timeRangeMarkStartPoint:null,currentTimeRangeMark:null,isTimeRangeMarkMode:!1,priceRangeMarkStartPoint:null,currentPriceRangeMark:null,isPriceRangeMarkMode:!1,timePriceRangeMarkStartPoint:null,currentTimePriceRangeMark:null,isTimePriceRangeMarkMode:!1,isPencilMode:!1,isPencilDrawing:!1,currentPencilMark:null,pencilPoints:[],isPenMode:!1,isPenDrawing:!1,currentPenMark:null,penPoints:[],isBrushMode:!1,isBrushDrawing:!1,currentBrushMark:null,brushPoints:[],isMarkerPenMode:!1,isMarkerPenDrawing:!1,currentMarkerPen:null,markerPenPoints:[],isEraserMode:!1,isErasing:!1,eraserHoveredMark:null,thickArrowLineMarkStartPoint:null,currentThickArrowLineMark:null,isImageMarkMode:!1,imageMarkStartPoint:null,currentImageMark:null,showImageModal:!1,selectedImageUrl:"",isImageUploadModalOpen:!1,isLongPositionMarkMode:!1,longPositionMarkStartPoint:null,currentLongPositionMark:null,longPositionDrawingPhase:"none",isLongPositionDragging:!1,dragTarget:null,dragPoint:null,adjustingMode:null,adjustStartData:null,isShortPositionMarkMode:!1,shortPositionMarkStartPoint:null,currentShortPositionMark:null,shortPositionDrawingPhase:"none",isShortPositionDragging:!1,shortPositionDragTarget:null,shortPositionDragPoint:null,shortPositionAdjustingMode:null,shortPositionAdjustStartData:null,isPriceLabelMarkMode:!1,priceLabelMarkPoint:null,currentPriceLabelMark:null,isPriceLabelDragging:!1,priceLabelDragTarget:null,isFlagMarkMode:!1,flagMarkPoint:null,currentFlagMark:null,isFlagDragging:!1,flagDragTarget:null,isPriceNoteMarkMode:!1,priceNoteMarkStartPoint:null,currentPriceNoteMark:null,isPriceNoteDragging:!1,priceNoteDragTarget:null,priceNoteDragPoint:null,isSignpostMarkMode:!1,signpostMarkPoint:null,currentSignpostMark:null,isSignpostDragging:!1,signpostDragTarget:null,isEmojiMarkMode:!1,emojiMarkStartPoint:null,currentEmojiMark:null,isEmojiDragging:!1,emojiDragTarget:null,emojiDragPoint:null,isPinMarkMode:!1,pinMarkPoint:null,currentPinMark:null,isPinDragging:!1,pinDragTarget:null,isBubbleBoxMarkMode:!1,bubbleBoxMarkPoints:null,currentBubbleBoxMark:null,isBubbleBoxDragging:!1,bubbleBoxDragTarget:null,bubbleBoxDragType:null,isTextEditMarkMode:!1,isTextEditDragging:!1,textEditDragTarget:null,isMainChartIndicatorsModalOpen:!1,selectedMainChartIndicators:[],selectedMainChartIndicatorTypes:[],modalEditingChartInfoIndicator:null,modalConfirmChartInfoIndicators:Xt(),maIndicatorValues:{},emaIndicatorValues:{},bollingerBandsValues:{},ichimokuValues:{},donchianChannelValues:{},envelopeValues:{},vwapValue:null,isSubChartIndicatorsSettingModalOpen:!1,subChartIndicatorsSettingModalParams:[],currentSubChartIndicatorType:null,isMockKLineMarkMode:!1,mockKLineMarkStartPoint:null,currentMockKLineMark:null,isMockKLineDragging:!1,mockKLineDragTarget:null,mockKLineDragPoint:null,isHeatMapMode:!1,heatMapStartPoint:null,currentHeatMap:null,isHeatMapDragging:!1,heatMapDragTarget:null,heatMapDragPoint:null,heatMapDrawingPhase:"none",heatMapAdjustingMode:null,isSchiffPitchforkMode:!1,schiffPitchforkHandlePoint:null,schiffPitchforkBaseStartPoint:null,currentSchiffPitchfork:null,isSchiffPitchforkDragging:!1,schiffPitchforkDragTarget:null,schiffPitchforkDragPoint:null,schiffPitchforkDrawingPhase:"none",schiffPitchforkAdjustingMode:null,cursorType:Pt.Crosshair,ai:this.props.ai||!1,aiconfigs:this.props.aiconfigs||[],currentAIFunctionType:this.props.currentAIFunctionType||null},this.chartEventManager=new Ei,this.chartMarkManager=new qs,this.chartMarkTextEditManager=new zs,this.mainChartTechnicalIndicatorManager=new In(this.props.currentTheme),this.initializeGraphManager(),this.staticMarkManager=new jn,this.chartPanesManager=new co,this.mainChartManager=new Ao(this,this.props.currentTheme)}componentDidMount(){this.setupCanvas(),this.setupAllDocumentEvents(),this.setupAllContainerEvents(),this.initializeMainChartIndicators(),this.chartMarkTextEditManager?.setupBubbleBoxMarkEvents(this),this.chartMarkTextEditManager?.setupSignPostMarkEvents(this),this.chartMarkTextEditManager?.setupPinMarkEvents(this),this.chartMarkTextEditManager?.setupTextEditMarkEvents(this),this.initStaticMark(),this.props.chart?this.chartEventManager?.registerCrosshairMoveEvent(this):setTimeout(()=>{this.props.chart&&this.chartEventManager?.registerCrosshairMoveEvent(this)},100),setTimeout(()=>{this.mainChartManager?.switchChartType(z.Candle),this.volume=new Si(this),this.props.chart&&this.chartPanesManager?.setChartInstance(this.props.chart)},50)}componentDidUpdate(t){(t.chartSeries!==this.props.chartSeries||t.chart!==this.props.chart)&&this.initializeGraphManagerProps(),t.i18n!==this.props.i18n&&(this.volumeHeatMap?.updateI18n(this.props.i18n),this.marketProfile?.updateI18n(this.props.i18n)),t.currentTheme!==this.props.currentTheme&&(this.volumeHeatMap?.updateTheme(this.props.currentTheme),this.marketProfile?.updateTheme(this.props.currentTheme)),t.ai!==this.props.ai&&this.props.ai&&this.setState({ai:this.props.ai}),t.aiconfigs!==this.props.aiconfigs&&this.props.aiconfigs&&this.setState({aiconfigs:this.props.aiconfigs}),t.currentAIFunctionType!==this.props.currentAIFunctionType&&this.props.currentAIFunctionType&&this.setState({currentAIFunctionType:this.props.currentAIFunctionType}),(t.timeframe!==this.props.timeframe||t.timezone!==this.props.timezone)&&this.volume&&(this.volume.destroy(this),this.volume=new Si(this),this.volume.refreshData(this)),this.hasChartDataChanged(t.chartData,this.props.chartData)?(setTimeout(()=>{this.updateStaticMark()},0),this.handleUpdateMainChartMaps(),this.updateAllMainChartIndicatorData(),this.chartPanesManager?.updateAllPaneData(this.props.chartData),this.volume?.refreshData(this),this.mainChartManager?.refreshData(),this.volumeHeatMap?.refreshData(this)):this.hasMainChartIndicatorChanged(t.selectedMainChartIndicator,this.props.selectedMainChartIndicator)&&(this.handleInitMainChartMaps(),this.updateSelectedMainChartIndicators(),this.chartPanesManager?.updateAllPaneData(this.props.chartData),this.volume?.refreshData(this),this.mainChartManager?.refreshData()),t.currentMainChartType!==this.props.currentMainChartType&&this.swtichMainChartType(),t.markData!==this.props.markData&&(this.staticMarkManager?.clearAllMarks(),this.updateStaticMark()),t.currentTheme!==this.props.currentTheme&&this.chartPanesManager?.updateAllPaneTheme(this.props.currentTheme),t.selectedSubChartIndicators!==this.props.selectedSubChartIndicators&&(this.chartPanesManager?.removeAllPane(),setTimeout(()=>{this.props.selectedSubChartIndicators.forEach(e=>{this.chartPanesManager?.addSubChart(this,e,i=>{this.showSubChartSettingModal(this.chartPanesManager?.getParamsByIndicatorType(i),i)},i=>{this.chartPanesManager?.removePaneBySubChartIndicatorType(i),this.props.handleRemoveSubChartIndicator&&this.props.handleRemoveSubChartIndicator(i)})})},0))}componentWillUnmount(){this.cleanupAllDocumentEvents(),document.removeEventListener("keydown",this.handleKeyDown),this.doubleClickTimeout&&clearTimeout(this.doubleClickTimeout),this.cleanupAllContainerEvents(),this.destroyGraphManager(),this.chartMarkTextEditManager?.cleanupBubbleBoxMarkEvents(),this.chartMarkTextEditManager?.cleanupSignPostMarkEvents(),this.chartMarkTextEditManager?.cleanupPinMarkEvents(),this.chartMarkTextEditManager?.cleanupTextEditMarkEvents(),this.volumeHeatMap?.destroy(),this.marketProfile?.destroy(),this.mainChartManager?.destroy(),this.volume?.destroy(this)}handleInitMainChartMaps(){this.props.selectedMainChartIndicator&&(this.props.selectedMainChartIndicator.type===F.HEATMAP&&(this.volumeHeatMap||(this.volumeHeatMap=new vo(this,this.props.i18n,this.props.currentTheme,()=>{this.volumeHeatMap=null}),this.volumeHeatMap?.refreshData(this))),this.props.selectedMainChartIndicator.type===F.MARKETPROFILE&&(this.marketProfile||(this.marketProfile=new xo(this,this.props.i18n,this.props.currentTheme,()=>{this.marketProfile=null}),this.marketProfile?.refreshData(this))))}handleUpdateMainChartMaps(){this.props.selectedMainChartIndicator&&(this.volumeHeatMap&&this.volumeHeatMap?.refreshData(this),this.marketProfile&&this.marketProfile?.refreshData(this))}hasChartDataChanged(t,e){if(t===e)return!1;if(!t||!e||t.length!==e.length)return!0;const i=Math.min(t.length,e.length,5);for(let r=0;r<i;r++)if(t[r].time!==e[r].time)return!0;return!1}hasMainChartIndicatorChanged(t,e){return t===e?!1:!t||!e?!0:t.type!==e.type||t.nonce!==e.nonce||JSON.stringify(t.params)!==JSON.stringify(e.params)}initStaticMark(){setTimeout(()=>{this.props.markData&&this.staticMarkManager?.addMark(this.props.markData,{series:this.mainChartManager?.getCurrentSeries(),type:"mark"})},200)}updateStaticMark(){this.props.markData&&this.staticMarkManager?.addMark(this.props.markData,{series:this.mainChartManager?.getCurrentSeries(),type:"mark"})}setupAllContainerEvents(){if(!this.containerRef.current)return;const t=this.containerRef.current;t.addEventListener("mousedown",this.handleMouseDown),t.addEventListener("mousemove",this.handleMouseMove),t.addEventListener("mouseup",this.handleMouseUp)}cleanupAllContainerEvents(){if(!this.containerRef.current)return;const t=this.containerRef.current;t.removeEventListener("mousedown",this.handleMouseDown),t.removeEventListener("mousemove",this.handleMouseMove),t.removeEventListener("mouseup",this.handleMouseUp)}setupAllDocumentEvents(){document.addEventListener("keydown",this.handleKeyDown),document.addEventListener("mousemove",this.handleDocumentMouseMove),document.addEventListener("mousedown",this.handleDocumentMouseDown),document.addEventListener("mouseup",this.handleDocumentMouseUp),document.addEventListener("wheel",this.handleDocumentMouseWheel)}cleanupAllDocumentEvents(){document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("mousemove",this.handleDocumentMouseMove),document.removeEventListener("mousedown",this.handleDocumentMouseDown),document.removeEventListener("mouseup",this.handleDocumentMouseUp),document.removeEventListener("wheel",this.handleDocumentMouseWheel)}serializeDrawings(){return JSON.stringify(this.allDrawings)}setupCanvas(){const t=this.canvasRef.current,e=this.containerRef.current;if(!t||!e)return;const i=e.getBoundingClientRect();t.width=i.width,t.height=i.height}getDrawingLayerElementsPosition(){const t=[];return this.containerRef.current&&(this.containerRef.current.querySelectorAll(".drawing-text-element").forEach(r=>{const a=r.getAttribute("data-text-id");if(a){const s=r,n=s.getBoundingClientRect(),o=this.containerRef.current.getBoundingClientRect();t.push({id:a,type:"text",position:{x:n.left-o.left,y:n.top-o.top},element:s})}}),this.containerRef.current.querySelectorAll(".drawing-emoji-element").forEach(r=>{const a=r.getAttribute("data-emoji-id");if(a){const s=r,n=s.getBoundingClientRect(),o=this.containerRef.current.getBoundingClientRect();t.push({id:a,type:"emoji",position:{x:n.left-o.left,y:n.top-o.top},element:s})}})),t}setDrawingLayerElementsPosition(t){this.containerRef.current&&t.forEach(e=>{let i=null;if(e.type==="text"?i=this.containerRef.current.querySelector(`[data-text-id="${e.id}"]`):e.type==="emoji"&&(i=this.containerRef.current.querySelector(`[data-emoji-id="${e.id}"]`)),i){i.style.position="absolute",i.style.left=`${e.position.x}px`,i.style.top=`${e.position.y}px`;const r=this.allDrawings.findIndex(a=>a.id===e.id);r!==-1&&this.allDrawings[r].points.length>0&&(this.allDrawings[r].points[0]={...e.position})}})}moveDrawingLayerElements(t,e){if(!this.containerRef.current)return;this.containerRef.current.querySelectorAll(".drawing-text-element").forEach(a=>{const s=a,n=parseInt(s.style.left)||0,o=parseInt(s.style.top)||0;s.style.left=`${n+t}px`,s.style.top=`${o+e}px`}),this.containerRef.current.querySelectorAll(".drawing-emoji-element").forEach(a=>{const s=a,n=parseInt(s.style.left)||0,o=parseInt(s.style.top)||0;s.style.left=`${n+t}px`,s.style.top=`${o+e}px`}),this.allDrawings.forEach(a=>{(a.type==="text"||a.type==="emoji")&&a.points.length>0&&(a.points[0].x+=t,a.points[0].y+=e)})}getDrawingLayerElementsByType(t){const e=[];if(!this.containerRef.current)return e;const i=t==="text"?".drawing-text-element":".drawing-emoji-element",r=t==="text"?"data-text-id":"data-emoji-id";return this.containerRef.current.querySelectorAll(i).forEach(s=>{const n=s,o=n.getAttribute(r);if(o){const h=n.getBoundingClientRect(),l=this.containerRef.current.getBoundingClientRect();e.push({id:o,position:{x:h.left-l.left,y:h.top-l.top},element:n})}}),e}disableChartMovement(){this.props.chart&&(this.originalChartOptions=this.props.chart.options(),this.props.chart.applyOptions({handleScroll:!1,handleScale:!1}))}enableChartMovement(){this.props.chart.applyOptions({handleScroll:!0,handleScale:!0})}render(){const{activeTool:t,currentTheme:e,showInfoLayer:i=!0}=this.props,{isTextMarkToolbar:r,showGraphMarkToolBar:a,showTableMarkToolBar:s,markToolBarPosition:n,showTextMarkToolBar:o,selectedTextEditMark:h,selectedTableMark:l,selectedGraphMark:g,isMainChartIndicatorsModalOpen:c,isSubChartIndicatorsSettingModalOpen:d,subChartIndicatorsSettingModalParams:u,currentSubChartIndicatorType:p}=this.state;return m.jsx("div",{style:{width:"100%"},children:m.jsxs("div",{style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",zIndex:5,pointerEvents:t?"auto":"none",opacity:1,display:"block"},children:[i&&m.jsx("div",{style:{position:"absolute",width:"100%",height:"100%"},children:this.renderChartInfo()}),m.jsx("div",{style:{position:"absolute",width:"100%",height:"100%"},children:this.renderMainChart()}),m.jsxs("div",{ref:this.containerRef,style:{position:"absolute",width:"100%",height:"100%",minHeight:"300px"},children:[this.state.isTextMarkEditorOpen&&m.jsx(Dr,{isOpen:this.state.isTextMarkEditorOpen,position:this.state.textMarkEditorPosition,theme:this.props.currentTheme,initialText:this.state.textMarkEditorInitialData.text,initialColor:this.state.textMarkEditorInitialData.color,initialFontSize:this.state.textMarkEditorInitialData.fontSize,initialIsBold:this.state.textMarkEditorInitialData.isBold,initialIsItalic:this.state.textMarkEditorInitialData.isItalic,onSave:this.handleTextMarkEditorSave,onCancel:this.handleTextMarkEditorCancel,i18n:this.props.i18n}),d&&m.jsx(uo,{isOpen:d,onClose:this.handleSubChartSettingClose,onConfirm:this.handleSubChartSettingConfirm,initialParams:u,theme:e,parentRef:this.containerRef,indicatorType:p,i18n:this.props.i18n}),this.state.isImageUploadModalOpen&&m.jsx(Fr,{isOpen:this.state.isImageUploadModalOpen,onClose:this.handleImageUploadClose,onConfirm:this.handleImageConfirm,theme:e,i18n:this.props.i18n}),c&&m.jsx(Kn,{isOpen:c,onClose:this.handleIndicatorsClose,onConfirm:this.handleMainChartIndicatorsSettingConfirm,initialIndicator:this.state.modalEditingChartInfoIndicator,theme:e,parentRef:this.containerRef,indicatorType:this.state.modalEditingChartInfoIndicator?.type||null,i18n:this.props.i18n}),o&&m.jsx(Bn,{position:n,selectedDrawing:h,theme:e,onClose:this.closeTextMarkToolBar,onDelete:this.handleDeleteTextEditMark,onChangeTextColor:this.handleChangeTextMarkFontColor,onChangeTextStyle:this.handleChangeTextMarkStyle,onChangeTextSize:this.handleChangeTextMarkFontSize,onDragStart:this.handleTextMarkToolBarDrag,isDragging:r,getToolName:this.getToolName,isShowGrapTool:this.state.isShowGrapTool,onChangeGraphColor:this.handleChangeTextMarkGraphColor,onChangeGraphStyle:this.handleChangeTextMarkGraphLineStyle,onChangeGraphLineWidth:this.handleChangeTextMarkGraphLineWidth,i18n:this.props.i18n}),a&&m.jsx(Un,{position:n,selectedDrawing:g,theme:e,onClose:this.closeGraphMarkToolBar,onDelete:this.handleDeleteGraphMark,onChangeColor:this.handleChangeGraphMarkColor,onChangeStyle:this.handleChangeGraphMarkStyle,onChangeWidth:this.handleChangeGraphMarkWidth,onDragStart:this.handleGraphToolbarDrag,isDragging:!1,getToolName:this.getToolName,i18n:this.props.i18n})]})]})})}}class Fo{constructor(t,e,i,r,a="en"){this.series=null,this.locale=a,this.chart=et.createChart(t,{width:e,height:i,layout:r.layout,grid:{vertLines:{color:r.grid.vertLines.color+"30",style:1,visible:!0},horzLines:{color:r.grid.horzLines.color+"30",style:1,visible:!0}},crosshair:{mode:0},timeScale:{timeVisible:!0,secondsVisible:!1,borderColor:r.grid.vertLines.color},rightPriceScale:{borderColor:r.grid.horzLines.color,scaleMargins:{top:.1,bottom:.1},entireTextOnly:!1},handleScale:{axisPressedMouseMove:!0},handleScroll:{mouseWheel:!0,pressedMouseMove:!0},localization:{locale:this.locale}})}getChart(){return this.chart}getSeries(){return this.series}getLocale(){return this.locale}}const Mt={Indicators:"Indicators",mainChartIndicators:"Main Chart Indicators",subChartIndicators:"Sub Chart Indicators",chartMaps:"Maps",close:"Close",searchIndicators:"Search indicators...",searchChartTypes:"Search chart types...",theme:"Theme",light:"Light",dark:"Dark",timeframe:"Time Frame",chartType:"Chart Type",toolBar:{color:"Color",lineSize:"Line Size",lineStyle:"Line Style",delete:"Delete",close:"Close",fontSize:"Font Size",bold:"Bold",italic:"Italic",selectColor:"Select Color",colorPicker:"Color Picker",solid:"Solid",dashed:"Dashed",dotted:"Dotted",currentColor:"Current Color"},timeframeSections:{second:"Second",minute:"Minute",hour:"Hour",day:"Day",week:"Week",month:"Month"},chartTypes:{candle:"Candlestick",line:"Line",area:"Area",baseline:"Baseline",hollowCandle:"Hollow Candle",heikinAshi:"Heikin Ashi",column:"Column",lineWithMarkers:"Line with Markers",stepLine:"Step Line",bar:"Bar",histogram:"Histogram",pointandfigure:"PointAndFigure",kagi:"Kagi",linebreak:"LineBreak",mountain:"Mountain",baselinearea:"BaseLineArea",highlow:"HighLow",equivolume:"EquiVolume",threelinebreak:"ThreeLineBreak",hlcarea:"HLCArea"},toolbarButtons:{hint:"Hint",replay:"Replay",fullScreen:"Full Screen",screenshot:"Screenshot",contrast:"Contrast"},indicators:{ma:"Moving Average",ema:"Exponential Moving Average",bollinger:"Bollinger Bands",ichimoku:"Ichimoku Cloud",donchian:"Donchian Channel",envelope:"Envelope",vwap:"VWAP",rsi:"RSI",macd:"MACD",volume:"Volume",sar:"Parabolic SAR",kdj:"KDJ",atr:"ATR",stochastic:"Stochastic",cci:"CCI",bbwidth:"BB Width",adx:"ADX",obv:"OBV"},mainIndicators:{ma:"Moving Average (MA)",ema:"Exponential Moving Average (EMA)",bollinger:"Bollinger Bands",ichimoku:"Ichimoku Cloud",donchian:"Donchian Channel",envelope:"Envelope",vwap:"Volume Weighted Average Price (VWAP)"},mainChartMaps:{heatmap:"Heat Map",marketProfile:"Market Profile"},subChartIndicatorName:{rsi:"Relative Strength Index (RSI)",macd:"MACD",volume:"Volume",sar:"Parabolic SAR (SAR)",kdj:"KDJ",atr:"Average True Range (ATR)",stochastic:"Stochastic Oscillator",cci:"Commodity Channel Index (CCI)",bbwidth:"Bollinger Bands Width",adx:"Average Directional Index (ADX)",obv:"On Balance Volume (OBV)"},modal:{parameterSettings:"Parameter Settings",parameterName:"Parameter Name",parameterValue:"Value",lineWidth:"Line Width",lineColor:"Color",addParameter:"Add Parameter",deleteParameter:"Delete",keepAtLeastOne:"Keep at least one parameter",maximumParameters:"Maximum 5 parameters allowed",dragToMove:"Drag header to move"},tooltips:{ctrlEnterToConfirm:"Ctrl+Enter: Confirm",escToCancel:"Esc: Cancel",clickToSelectColor:"Click to select color"},emoji:{categories:{smileys:"Smileys & Emotion",people:"People & Body",animals:"Animals & Nature",food:"Food & Drink",activities:"Activities",travel:"Travel & Places",objects:"Objects",symbols:"Symbols",flags:"Flags"},searchPlaceholder:"Search emojis...",selectedEmoji:"Selected",clickToPlace:"Click chart to place emoji"},leftPanel:{cursorCrosshair:"Crosshair",cursorCrosshairDesc:"Crosshair cursor with space",cursorCircle:"Cursor",cursorCircleDesc:"Cursor",cursorDot:"Dot Cursor",cursorDotDesc:"Round dot cursor style",cursorArrow:"Arrow Cursor",cursorArrowDesc:"Arrow pointer style",cursorSparkle:"Sparkle",cursorSparkleDesc:"Sparkle effect cursor",cursorEmoji:"Emoji Cursor",cursorEmojiDesc:"Emoji symbol cursor",pencil:"Pencil",pencilDesc:"Thin line drawing tool",pen:"Pen",penDesc:"Smooth line drawing",brush:"Brush",brushDesc:"Soft brush effect",markerPen:"Marker",markerPenDesc:"Bold marker pen",eraser:"Eraser",eraserDesc:"Erase drawing content",heatMap:"Heat Map",lineTools:"Lines",arrowTools:"Arrows",channelTools:"Channels",pitchforkTools:"Pitchforks",penTools:"Pens",gannTools:"Gann Tools",fibonacciTools:"Fibonacci Tools",technicalPatterns:"Technical Patterns",elliottWave:"Elliott Wave",regularShapes:"Regular Shapes",rangeTools:"Ranges",positionTools:"Positions",simulationTools:"Simulation",textTools:"Text",contentTools:"Content",lineSegment:"Line Segment",lineSegmentDesc:"Draw line segment",horizontalLine:"Horizontal Line",horizontalLineDesc:"Draw horizontal line marker",verticalLine:"Vertical Line",verticalLineDesc:"Draw vertical line marker",arrowLine:"Arrow Line",arrowLineDesc:"Draw arrow line marker",thickArrowLine:"Thick Arrow Line",thickArrowLineDesc:"Draw thick arrow line marker",parallelChannel:"Parallel Channel",parallelChannelDesc:"Draw parallel channel",linearRegressionChannel:"Linear Regression Channel",linearRegressionChannelDesc:"Draw regression channel",equidistantChannel:"Equidistant Channel",equidistantChannelDesc:"Draw equidistant channel",disjointChannel:"Disjoint Channel",disjointChannelDesc:"Draw disjoint channel",andrewPitchfork:"Andrew's Pitchfork",andrewPitchforkDesc:"Draw Andrew's pitchfork",enhancedAndrewPitchfork:"Enhanced Andrew Pitchfork",enhancedAndrewPitchforkDesc:"Draw enhanced pitchfork",schiffPitchfork:"Schiff Pitchfork",schiffPitchforkDesc:"Draw Schiff pitchfork",internalPitchfork:"Internal Pitchfork Lines",internalPitchforkDesc:"Draw internal pitchfork lines",wavePitchfork:"Wave Pitchfork",wavePitchforkDesc:"Draw wave pitchfork",gannFan:"Gann Fan",gannFanDesc:"Gann fan analysis tool",gannBox:"Gann Box",gannBoxDesc:"Gann box analysis tool",gannRectangle:"Gann Rectangle",gannRectangleDesc:"Gann Rectangle analysis",fibonacciTimeZones:"Fibonacci Time Zones",fibonacciTimeZonesDesc:"Fibonacci time zones analysis",fibonacciRetracement:"Fibonacci Retracement",fibonacciRetracementDesc:"Draw Fibonacci retracement lines",fibonacciArc:"Fibonacci Arc",fibonacciArcDesc:"Draw Fibonacci arcs",fibonacciCircle:"Fibonacci Circle",fibonacciCircleDesc:"Fibonacci circle analysis",fibonacciSpiral:"Fibonacci Spiral",fibonacciSpiralDesc:"Fibonacci spiral analysis",fibonacciWedge:"Fibonacci Wedge",fibonacciWedgeDesc:"Fibonacci wedge analysis",fibonacciFan:"Fibonacci Fan",fibonacciFanDesc:"Fibonacci fan analysis",fibonacciChannel:"Fibonacci Channel",fibonacciChannelDesc:"Fibonacci channel analysis",fibonacciExtensionPrice:"Fibonacci Extension (Price)",fibonacciExtensionPriceDesc:"Draw Fibonacci extension lines",fibonacciExtensionTime:"Fibonacci Extension (Time)",fibonacciExtensionTimeDesc:"Draw Fibonacci extension lines",xabcdPattern:"XABCD Pattern",xabcdPatternDesc:"Draw XABCD pattern",headAndShoulders:"Head and Shoulders",headAndShouldersDesc:"Draw head and shoulders pattern",abcdPattern:"ABCD Pattern",abcdPatternDesc:"Draw ABCD pattern",triangleAbcd:"ABCD Triangle",triangleAbcdDesc:"Draw ABCD triangle pattern",elliottImpulse:"Elliott Impulse Wave",elliottImpulseDesc:"Draw Elliott impulse wave",elliottCorrective:"Elliott Corrective Wave",elliottCorrectiveDesc:"Draw Elliott corrective wave",elliottTriangle:"Elliott Triangle Wave",elliottTriangleDesc:"Draw Elliott triangle wave",elliottDoubleCombo:"Elliott Double Combo",elliottDoubleComboDesc:"Draw Elliott double combo wave",elliottTripleCombo:"Elliott Triple Combo",elliottTripleComboDesc:"Draw Elliott triple combo wave",rectangle:"Rectangle",rectangleDesc:"Draw rectangular area",circle:"Circle",circleDesc:"Draw circular area",ellipse:"Ellipse",ellipseDesc:"Draw elliptical area",triangle:"Triangle",triangleDesc:"Draw triangle",sector:"Sector",sectorDesc:"Draw sector",curve:"Curve",curveDesc:"Draw curve",doubleCurve:"Double Curve",doubleCurveDesc:"Draw double curve",timeRange:"Time Range",timeRangeDesc:"Draw time range",priceRange:"Price Range",priceRangeDesc:"Draw price range",timePriceRange:"Time-Price Range",timePriceRangeDesc:"Draw time-price range",longPosition:"Long Position",longPositionDesc:"Long position marker",shortPosition:"Short Position",shortPositionDesc:"Short position marker",mockKline:"Mock K-line",mockKlineDesc:"Simulate K-line data",text:"Text",textDesc:"Text annotation",priceNote:"Price Note",priceNoteDesc:"Price annotation",bubbleBox:"Bubble Box",bubbleBoxDesc:"Bubble annotation box",pin:"Pin",pinDesc:"Pin marker",signpost:"Signpost",signpostDesc:"Signpost marker",priceLabel:"Price Label",priceLabelDesc:"Price label marker",flagMark:"Flag Mark",flagMarkDesc:"Flag marker",image:"Image",imageDesc:"Image annotation",video:"Video",videoDesc:"Video annotation",audio:"Audio",audioDesc:"Audio annotation",idea:"Idea",ideaDesc:"Idea annotation",mouseCursor:"Mouse Cursor",drawingTools:"Drawing Tools",fibonacciToolsTitle:"Fibonacci Tools",projectInfoTools:"Project Info Tools",shapeTools:"Shape Tools",brushTitle:"Brush",textMark:"Text Mark",emojiMark:"Emoji Mark",deleteTool:"Delete Tool",setting:"Setting",selectedTool:"Selected",clickToStartDrawing:"Click chart to start drawing",selectEmoji:"Select Emoji",selectedEmoji:"Selected",clickToPlaceEmoji:"Click chart to place emoji",aiTools:"AI Tools",aiModelSelection:"AI Models",aiFunctions:"AI Functions",openai:"OpenAI",openaiDesc:"GPT-4, GPT-3.5",gemini:"Gemini",geminiDesc:"Google AI",claude:"Claude",claudeDesc:"Anthropic AI",deepseek:"DeepSeek",deepseekDesc:"Chinese AI Model",describeChart:"Describe Chart",describeChartDesc:"Describe chart patterns in natural language",predictTrend:"Predict Trend",predictTrendDesc:"Predict future trends based on historical data"},systemSettings:{title:"System Settings",general:"General",appearance:"Appearance",chart:"Chart",performance:"Performance",shortcuts:"Shortcuts",saveSettings:"Save Settings",cancel:"Cancel",confirm:"Confirm",language:"Language",timezone:"Timezone",autoSave:"Auto Save",themeMode:"Theme Mode",fontSize:"Font Size",animations:"Animations",defaultTimeframe:"Default Timeframe",pricePrecision:"Price Precision",showGrid:"Show Grid",hardwareAcceleration:"Hardware Acceleration",dataPointLimit:"Data Point Limit",realtimeUpdates:"Real-time Updates",shortcutsTitle:"Keyboard Shortcuts",zoomIn:"Zoom In",zoomOut:"Zoom Out",resetZoom:"Reset Zoom",saveChart:"Save Chart",undo:"Undo",redo:"Redo",setting:"Setting"},settingsDescriptions:{language:"Select interface display language",timezone:"Set timezone for displayed times",autoSave:"Automatically save chart settings and drawings",themeMode:"Choose light or dark theme",fontSize:"Set interface font size",animations:"Enable interface animation effects",defaultTimeframe:"Set default chart display timeframe",pricePrecision:"Set number of decimal places for price display",showGrid:"Display grid lines in chart",hardwareAcceleration:"Enable GPU accelerated rendering (recommended)",dataPointLimit:"Set maximum number of data points to display in chart",realtimeUpdates:"Enable real-time data stream updates"},options:{light:"Light Mode",dark:"Dark Mode",auto:"Follow System",small:"Small",medium:"Medium",large:"Large",zhCN:"Simplified Chinese",enUS:"English",jaJP:"Japanese",beijing:"Beijing Time (UTC+8)",newYork:"New York Time (UTC-5)",london:"London Time (UTC+0)",chicago:"Chicago Time (UTC-6)",denver:"Denver Time (UTC-7)",losAngeles:"Los Angeles Time (UTC-8)",toronto:"Toronto Time (UTC-5)",paris:"Paris Time (UTC+1)",frankfurt:"Frankfurt Time (UTC+1)",zurich:"Zurich Time (UTC+1)",moscow:"Moscow Time (UTC+3)",dubai:"Dubai Time (UTC+4)",karachi:"Karachi Time (UTC+5)",kolkata:"Kolkata Time (UTC+5:30)",shanghai:"Shanghai Time (UTC+8)",hongKong:"Hong Kong Time (UTC+8)",singapore:"Singapore Time (UTC+8)",tokyo:"Tokyo Time (UTC+9)",seoul:"Seoul Time (UTC+9)",sydney:"Sydney Time (UTC+10)",auckland:"Auckland Time (UTC+12)",utc:"UTC Time"},timeframes:{"1s":"1 Second","5s":"5 Seconds","15s":"15 Seconds","30s":"30 Seconds","1m":"1 Minute","3m":"3 Minutes","5m":"5 Minutes","15m":"15 Minutes","30m":"30 Minutes","45m":"45 Minutes","1H":"1 Hour","2H":"2 Hours","3H":"3 Hours","4H":"4 Hours","6H":"6 Hours","8H":"8 Hours","12H":"12 Hours","1D":"1 Day","3D":"3 Days","1W":"1 Week","2W":"2 Weeks","1M":"1 Month","3M":"3 Months","6M":"6 Months"},timezone:"Timezone",timeFormat:"Time Format",closeTime:"Close Time",tradingDay:"Trading Day",searchTimezones:"Search timezones...",timeFormatOptions:{twentyFourHour:"24-Hour Format",twelveHour:"12-Hour Format"},closeTimeOptions:{custom:"Custom Time"},tradingDayOptions:{tradingSession:"Trading Session",calendarDay:"Calendar Day",exchangeHours:"Exchange Hours"},terminal:{isEn:"en",placeholderText:"Enter command..."},ai:{aliyun:"Aliyun"}},Eo={Indicators:"技术指标",mainChartIndicators:"主图指标",subChartIndicators:"副图指标",chartMaps:"图",close:"关闭",searchIndicators:"搜索指标...",searchChartTypes:"搜索图表类型...",theme:"主题",light:"浅色",dark:"深色",timeframe:"时间框架",chartType:"图表类型",toolBar:{color:"颜色",lineSize:"线条尺寸",lineStyle:"线条样式",delete:"删除",close:"关闭",fontSize:"字体大小",bold:"粗体",italic:"斜体",selectColor:"选择颜色",colorPicker:"拾色器",solid:"实线",dashed:"虚线",dotted:"点状线",currentColor:"当前颜色"},timeframeSections:{second:"秒",minute:"分钟",hour:"小时",day:"天",week:"周",month:"月"},chartTypes:{candle:"蜡烛图",line:"线图",area:"面积图",baseline:"基线图",hollowCandle:"空心蜡烛图",heikinAshi:"平均K线图",column:"柱状图",lineWithMarkers:"带标记线图",stepLine:"阶梯线图",bar:"美国线",histogram:"直方图",pointandfigure:"点线图",kagi:"卡吉图",linebreak:"新价线",mountain:"山脉图",baselinearea:"基准面积图",highlow:"高低图",equivolume:"等量图",threelinebreak:"三线反转图",hlcarea:"HLC区域"},toolbarButtons:{hint:"提示",replay:"回放",fullScreen:"全屏",screenshot:"截图",contrast:"对比"},indicators:{ma:"移动平均线",ema:"指数移动平均线",bollinger:"布林带",ichimoku:"一目均衡表",donchian:"唐奇安通道",envelope:"包络线",vwap:"成交量加权平均价",rsi:"RSI",macd:"MACD",volume:"成交量",sar:"抛物线转向",kdj:"KDJ",atr:"ATR",stochastic:"随机指标",cci:"CCI",bbwidth:"布林带宽度",adx:"ADX",obv:"能量潮"},mainIndicators:{ma:"移动平均线 (MA)",ema:"指数移动平均线 (EMA)",bollinger:"布林带",ichimoku:"一目均衡表",donchian:"唐奇安通道",envelope:"包络线",vwap:"成交量加权平均价 (VWAP)"},mainChartMaps:{heatmap:"热力图",marketProfile:"市场轮廓图"},subChartIndicatorName:{rsi:"相对强弱指数 (RSI)",macd:"MACD",volume:"成交量",sar:"抛物线转向指标 (SAR)",kdj:"KDJ",atr:"平均真实波幅 (ATR)",stochastic:"随机指标",cci:"顺势指标 (CCI)",bbwidth:"布林带宽度",adx:"平均趋向指数 (ADX)",obv:"能量潮 (OBV)"},modal:{parameterSettings:"参数设置",parameterName:"参数名称",parameterValue:"数值",lineWidth:"线宽",lineColor:"颜色",addParameter:"添加参数",deleteParameter:"删除",keepAtLeastOne:"至少保留一个参数",maximumParameters:"最多允许5个参数",dragToMove:"拖动标题栏移动"},tooltips:{ctrlEnterToConfirm:"Ctrl+Enter: 确认",escToCancel:"Esc: 取消",clickToSelectColor:"点击选择颜色"},emoji:{categories:{smileys:"表情与情感",people:"人物与身体",animals:"动物与自然",food:"食物与饮品",activities:"活动",travel:"旅行与地点",objects:"物品",symbols:"符号",flags:"旗帜"},searchPlaceholder:"搜索表情...",selectedEmoji:"已选择",clickToPlace:"点击图表放置表情"},leftPanel:{cursorCrosshair:"十字准星",cursorCrosshairDesc:"带空格的十字准星",cursorCircle:"圆形光标",cursorCircleDesc:"圆形光标",cursorDot:"点状光标",cursorDotDesc:"圆点光标样式",cursorArrow:"箭头光标",cursorArrowDesc:"箭头指示样式",cursorSparkle:"烟花棒",cursorSparkleDesc:"烟花效果光标",cursorEmoji:"表情光标",cursorEmojiDesc:"表情符号光标",pencil:"铅笔",pencilDesc:"细线绘制工具",pen:"钢笔",penDesc:"流畅线条绘制",brush:"刷子",brushDesc:"柔和笔刷效果",markerPen:"马克笔",markerPenDesc:"粗体标记笔",eraser:"橡皮擦",eraserDesc:"擦除绘制内容",lineTools:"线",arrowTools:"箭头",channelTools:"通道",pitchforkTools:"叉",penTools:"画笔",gannTools:"江恩分析工具",fibonacciTools:"斐波那契工具",technicalPatterns:"技术图形",elliottWave:"艾略特波浪",regularShapes:"规则图形",rangeTools:"区间",positionTools:"标尺",simulationTools:"模拟",heatMap:"热力图",textTools:"文本",contentTools:"内容",lineSegment:"线段",lineSegmentDesc:"绘制线段",horizontalLine:"水平线",horizontalLineDesc:"绘制水平线标记",verticalLine:"垂直线",verticalLineDesc:"绘制垂直线标记",arrowLine:"箭头线",arrowLineDesc:"绘制箭头线标记",thickArrowLine:"粗箭头线",thickArrowLineDesc:"绘制箭头线标记",parallelChannel:"并行通道",parallelChannelDesc:"绘制并行通道",linearRegressionChannel:"线性回归通道",linearRegressionChannelDesc:"绘制回归通道",equidistantChannel:"等距通道",equidistantChannelDesc:"绘制等距通道",disjointChannel:"不相交通道",disjointChannelDesc:"绘制不相交通道",andrewPitchfork:"安德鲁干草叉",andrewPitchforkDesc:"绘制安德鲁干草叉",enhancedAndrewPitchfork:"改良安德鲁干草叉",enhancedAndrewPitchforkDesc:"绘制叉子",schiffPitchfork:"希夫干草叉",schiffPitchforkDesc:"绘制希夫干草叉",internalPitchfork:"内部干草叉线",internalPitchforkDesc:"绘制内部干草叉线",wavePitchfork:"波浪干草叉",wavePitchforkDesc:"绘制波浪干草叉",gannFan:"江恩扇",gannFanDesc:"江恩扇形线分析工具",gannBox:"江恩箱",gannBoxDesc:"江恩箱体分析工具",gannRectangle:"江恩正方体",gannRectangleDesc:"江恩正方体分析",fibonacciTimeZones:"斐波那契时间周期",fibonacciTimeZonesDesc:"斐波那契时间周期线分析",fibonacciRetracement:"斐波那契回调",fibonacciRetracementDesc:"绘制斐波那契回调线",fibonacciArc:"斐波那契弧线",fibonacciArcDesc:"绘制斐波那契弧线",fibonacciCircle:"斐波那契圆",fibonacciCircleDesc:"斐波那契圆线分析",fibonacciSpiral:"斐波那契螺旋",fibonacciSpiralDesc:"斐波那契螺旋线分析",fibonacciWedge:"斐波那契楔形",fibonacciWedgeDesc:"斐波那契楔形线分析",fibonacciFan:"斐波那契扇形",fibonacciFanDesc:"斐波那契扇形线分析",fibonacciChannel:"斐波那契通道",fibonacciChannelDesc:"斐波那契通道线分析",fibonacciExtensionPrice:"斐波那契扩展(基于价格)",fibonacciExtensionPriceDesc:"绘制斐波那契扩展线",fibonacciExtensionTime:"斐波那契扩展(基于时间)",fibonacciExtensionTimeDesc:"绘制斐波那契扩展线",xabcdPattern:"XABCD图形",xabcdPatternDesc:"绘制XABCD图形",headAndShoulders:"头肩图形",headAndShouldersDesc:"绘制头肩图形",abcdPattern:"ABCD图形",abcdPatternDesc:"绘制ABCD图形",triangleAbcd:"ABCD三角图形",triangleAbcdDesc:"绘制ABCD三角图形",elliottImpulse:"艾略特脉冲波",elliottImpulseDesc:"绘制艾略特脉冲波",elliottCorrective:"艾略特修正浪",elliottCorrectiveDesc:"绘制艾略特修正浪",elliottTriangle:"艾略特三角波",elliottTriangleDesc:"绘制艾略特三角波",elliottDoubleCombo:"艾略特双重组合波",elliottDoubleComboDesc:"绘制艾略特双重组合波",elliottTripleCombo:"艾略特三重组合波",elliottTripleComboDesc:"绘制艾略特三重组合波",rectangle:"矩形",rectangleDesc:"绘制矩形区域",circle:"圆形",circleDesc:"绘制圆形区域",ellipse:"椭圆",ellipseDesc:"绘制椭圆区域",triangle:"三角形",triangleDesc:"绘制三角形",sector:"扇形",sectorDesc:"绘制扇形",curve:"曲线",curveDesc:"绘制曲线",doubleCurve:"双曲线",doubleCurveDesc:"绘制双曲线",timeRange:"时间区间",timeRangeDesc:"绘制时间区间",priceRange:"价格区间",priceRangeDesc:"绘制价格区间",timePriceRange:"时间价格区间",timePriceRangeDesc:"绘制时间价格区间",longPosition:"多头",longPositionDesc:"多头标记",shortPosition:"空头",shortPositionDesc:"空头标记",mockKline:"模拟K线",mockKlineDesc:"模拟K线数据",text:"文本",textDesc:"文本标注",priceNote:"价格标记",priceNoteDesc:"价格标注",bubbleBox:"气泡框",bubbleBoxDesc:"气泡标注框",pin:"定位",pinDesc:"定位标记",signpost:"路标",signpostDesc:"路标标记",priceLabel:"价格标签",priceLabelDesc:"价格标签标记",flagMark:"旗标",flagMarkDesc:"旗标标记",image:"图片",imageDesc:"图片标注",video:"视频",videoDesc:"视频标注",audio:"音频",audioDesc:"音频标注",idea:"点子",ideaDesc:"点子标注",mouseCursor:"鼠标光标",drawingTools:"绘图工具",fibonacciToolsTitle:"斐波那契工具",projectInfoTools:"项目信息工具",shapeTools:"图形工具",brushTitle:"画笔",textMark:"文字标记",emojiMark:"表情标记",deleteTool:"删除工具",setting:"设置",selectedTool:"已选择",clickToStartDrawing:"点击图表开始绘制",selectEmoji:"选择表情",selectedEmoji:"已选择",clickToPlaceEmoji:"点击图表放置表情",aiTools:"AI工具",aiModelSelection:"AI模型",aiFunctions:"AI功能",openai:"OpenAI",openaiDesc:"GPT-4, GPT-3.5",gemini:"Gemini",geminiDesc:"谷歌AI",claude:"Claude",claudeDesc:"Anthropic AI",deepseek:"DeepSeek",deepseekDesc:"国产AI模型",describeChart:"图表分析",describeChartDesc:"用自然语言分析图表走势",predictTrend:"趋势预测",predictTrendDesc:"基于历史数据预测未来趋势"},systemSettings:{title:"系统设置",general:"通用设置",appearance:"外观设置",chart:"图表设置",performance:"性能设置",shortcuts:"快捷键",saveSettings:"保存设置",cancel:"取消",confirm:"确认",language:"语言",timezone:"时区",autoSave:"自动保存",themeMode:"主题模式",fontSize:"字体大小",animations:"动画效果",defaultTimeframe:"默认时间周期",pricePrecision:"价格精度",showGrid:"显示网格",hardwareAcceleration:"硬件加速",dataPointLimit:"数据点限制",realtimeUpdates:"实时数据更新",shortcutsTitle:"键盘快捷键",zoomIn:"放大图表",zoomOut:"缩小图表",resetZoom:"重置缩放",saveChart:"保存图表",undo:"撤销操作",redo:"重做操作",setting:"设置"},settingsDescriptions:{language:"选择界面显示语言",timezone:"设置显示时间的时区",autoSave:"自动保存图表设置和绘图",themeMode:"选择浅色或深色主题",fontSize:"设置界面字体大小",animations:"启用界面动画效果",defaultTimeframe:"设置图表默认显示的时间周期",pricePrecision:"设置价格显示的小数位数",showGrid:"在图表中显示网格线",hardwareAcceleration:"启用GPU加速渲染(推荐)",dataPointLimit:"设置图表显示的最大数据点数量",realtimeUpdates:"启用实时数据流更新"},options:{light:"浅色模式",dark:"深色模式",auto:"跟随系统",small:"小",medium:"中",large:"大",zhCN:"简体中文",enUS:"English",jaJP:"日本語",beijing:"北京时间 (UTC+8)",newYork:"纽约时间 (UTC-5)",london:"伦敦时间 (UTC+0)",chicago:"芝加哥时间 (UTC-6)",denver:"丹佛时间 (UTC-7)",losAngeles:"洛杉矶时间 (UTC-8)",toronto:"多伦多时间 (UTC-5)",paris:"巴黎时间 (UTC+1)",frankfurt:"法兰克福时间 (UTC+1)",zurich:"苏黎世时间 (UTC+1)",moscow:"莫斯科时间 (UTC+3)",dubai:"迪拜时间 (UTC+4)",karachi:"卡拉奇时间 (UTC+5)",kolkata:"加尔各答时间 (UTC+5:30)",shanghai:"上海时间 (UTC+8)",hongKong:"香港时间 (UTC+8)",singapore:"新加坡时间 (UTC+8)",tokyo:"东京时间 (UTC+9)",seoul:"首尔时间 (UTC+9)",sydney:"悉尼时间 (UTC+10)",auckland:"奥克兰时间 (UTC+12)",utc:"UTC时间"},timeframes:{"1s":"1秒","5s":"5秒","15s":"15秒","30s":"30秒","1m":"1分钟","3m":"3分钟","5m":"5分钟","15m":"15分钟","30m":"30分钟","45m":"45分钟","1H":"1小时","2H":"2小时","3H":"3小时","4H":"4小时","6H":"6小时","8H":"8小时","12H":"12小时","1D":"1天","3D":"3天","1W":"1周","2W":"2周","1M":"1月","3M":"3月","6M":"6月"},timezone:"时区",timeFormat:"时间格式",closeTime:"收盘时间",tradingDay:"交易日",searchTimezones:"搜索时区...",timeFormatOptions:{twentyFourHour:"24小时制",twelveHour:"12小时制"},closeTimeOptions:{custom:"自定义时间"},tradingDayOptions:{tradingSession:"交易时段",calendarDay:"日历日",exchangeHours:"交易时间"},terminal:{isEn:"中文",placeholderText:"输入命令..."},ai:{aliyun:"阿里云"}};async function Me(f,t){const e=f.candleViewRef.current;if(!e){const i={success:!1,error:"Container not found",width:0,height:0,timestamp:Date.now()};return t?.(i),i}try{const i=document.createElement("canvas"),r=i.getContext("2d");if(!r){const c={success:!1,error:"Canvas context not available",width:0,height:0,timestamp:Date.now()};return t?.(c),c}const{width:a,height:s}=e.getBoundingClientRect();i.width=a,i.height=s,r.fillStyle=f.state.currentTheme.layout.background.color,r.fillRect(0,0,a,s);const n=e.querySelectorAll("canvas");Array.from(n).sort((c,d)=>{const u=parseInt(window.getComputedStyle(c).zIndex)||0,p=parseInt(window.getComputedStyle(d).zIndex)||0;return u-p}).forEach(c=>{try{const d=c.getBoundingClientRect(),u=e.getBoundingClientRect(),p=d.left-u.left,M=d.top-u.top;r.drawImage(c,p,M,d.width,d.height)}catch{}}),yo(f,e,r,a,s),Ro(r,a,s,f.state.currentTheme);const h=i.toDataURL("image/png"),l=await new Promise(c=>{i.toBlob(d=>{c(d)},"image/png")}),g={success:!0,dataUrl:h,blob:l,width:a,height:s,timestamp:Date.now()};if(t)t(g);else{const c=document.createElement("a");c.download=`chart-screenshot-${new Date().getTime()}.png`,c.href=h,c.click()}return g}catch(i){const r={success:!1,error:i instanceof Error?i.message:"Unknown error",width:0,height:0,timestamp:Date.now()};return t?.(r),r}}function Ro(f,t,e,i){f.save();const a=i.layout.background.color==="#0F1116"?"rgba(255, 255, 255, 0.25)":"rgba(0, 0, 0, 0.25)";f.fillStyle=a,f.font="bold 60px Arial, sans-serif",f.textAlign="center",f.textBaseline="middle";const s=t/2,n=e/2;f.fillText("CandleView",s,n),f.restore()}function yo(f,t,e,i,r){Array.from(t.querySelectorAll('.chart-info-panel, .toolbar, [candleview-container] > div:not([style*="position: absolute"])')).forEach(s=>{Bo(f,s,e,t)})}function Bo(f,t,e,i){const r=t.getBoundingClientRect(),a=i.getBoundingClientRect(),s=r.left-a.left,n=r.top-a.top,o=document.createElement("canvas"),h=o.getContext("2d");h&&(o.width=r.width,o.height=r.height,Uo(f,t,h,r.width,r.height),e.drawImage(o,s,n,r.width,r.height))}function Uo(f,t,e,i,r){const a=t.textContent||"";a.trim()&&(e.fillStyle=f.state.currentTheme.layout.textColor,e.font="12px Arial",e.textAlign="left",e.textBaseline="top",Io(f,e,a,i-20).forEach((n,o)=>{e.fillText(n,10,10+o*16)}))}function Io(f,t,e,i){const r=e.split(" "),a=[];let s=r[0];for(let n=1;n<r.length;n++){const o=r[n];t.measureText(s+" "+o).width<i?s+=" "+o:(a.push(s),s=o)}return a.push(s),a}function Lo(f){return f&&{"1s":v.ONE_SECOND,"5s":v.FIVE_SECONDS,"15s":v.FIFTEEN_SECONDS,"30s":v.THIRTY_SECONDS,"1m":v.ONE_MINUTE,"3m":v.THREE_MINUTES,"5m":v.FIVE_MINUTES,"15m":v.FIFTEEN_MINUTES,"30m":v.THIRTY_MINUTES,"45m":v.FORTY_FIVE_MINUTES,"1h":v.ONE_HOUR,"2h":v.TWO_HOURS,"3h":v.THREE_HOURS,"4h":v.FOUR_HOURS,"6h":v.SIX_HOURS,"8h":v.EIGHT_HOURS,"12h":v.TWELVE_HOURS,"1d":v.ONE_DAY,"3d":v.THREE_DAYS,"1w":v.ONE_WEEK,"2w":v.TWO_WEEKS,"1M":v.ONE_MONTH,"3M":v.THREE_MONTHS,"6M":v.SIX_MONTHS}[f]||null}function Ko(f){return f&&{"America/New_York":O.NEW_YORK,"America/Chicago":O.CHICAGO,"America/Denver":O.DENVER,"America/Los_Angeles":O.LOS_ANGELES,"America/Toronto":O.TORONTO,"Europe/London":O.LONDON,"Europe/Paris":O.PARIS,"Europe/Frankfurt":O.FRANKFURT,"Europe/Zurich":O.ZURICH,"Europe/Moscow":O.MOSCOW,"Asia/Dubai":O.DUBAI,"Asia/Karachi":O.KARACHI,"Asia/Kolkata":O.KOLKATA,"Asia/Shanghai":O.SHANGHAI,"Asia/Hong_Kong":O.HONG_KONG,"Asia/Singapore":O.SINGAPORE,"Asia/Tokyo":O.TOKYO,"Asia/Seoul":O.SEOUL,"Australia/Sydney":O.SYDNEY,"Pacific/Auckland":O.AUCKLAND,UTC:O.UTC}[f]||null}const Vi={[v.ONE_SECOND]:{seconds:1,groupBy:"second"},[v.FIVE_SECONDS]:{seconds:5,groupBy:"second"},[v.FIFTEEN_SECONDS]:{seconds:15,groupBy:"second"},[v.THIRTY_SECONDS]:{seconds:30,groupBy:"second"},[v.ONE_MINUTE]:{seconds:60,groupBy:"minute"},[v.THREE_MINUTES]:{seconds:180,groupBy:"minute"},[v.FIVE_MINUTES]:{seconds:300,groupBy:"minute"},[v.FIFTEEN_MINUTES]:{seconds:900,groupBy:"minute"},[v.THIRTY_MINUTES]:{seconds:1800,groupBy:"minute"},[v.FORTY_FIVE_MINUTES]:{seconds:2700,groupBy:"minute"},[v.ONE_HOUR]:{seconds:3600,groupBy:"hour"},[v.TWO_HOURS]:{seconds:7200,groupBy:"hour"},[v.THREE_HOURS]:{seconds:10800,groupBy:"hour"},[v.FOUR_HOURS]:{seconds:14400,groupBy:"hour"},[v.SIX_HOURS]:{seconds:21600,groupBy:"hour"},[v.EIGHT_HOURS]:{seconds:28800,groupBy:"hour"},[v.TWELVE_HOURS]:{seconds:43200,groupBy:"hour"},[v.ONE_DAY]:{seconds:86400,groupBy:"day"},[v.THREE_DAYS]:{seconds:259200,groupBy:"day"},[v.ONE_WEEK]:{seconds:604800,groupBy:"week"},[v.TWO_WEEKS]:{seconds:1209600,groupBy:"week"},[v.ONE_MONTH]:{seconds:2592e3,groupBy:"month"},[v.THREE_MONTHS]:{seconds:7776e3,groupBy:"month"},[v.SIX_MONTHS]:{seconds:15552e3,groupBy:"month"}};function Ho(f,t){return t&&f in t.timeframes?t.timeframes[f]:Ci(f)}function Ci(f){return{[v.ONE_SECOND]:"1 Second",[v.FIVE_SECONDS]:"5 Seconds",[v.FIFTEEN_SECONDS]:"15 Seconds",[v.THIRTY_SECONDS]:"30 Seconds",[v.ONE_MINUTE]:"1 Minute",[v.THREE_MINUTES]:"3 Minutes",[v.FIVE_MINUTES]:"5 Minutes",[v.FIFTEEN_MINUTES]:"15 Minutes",[v.THIRTY_MINUTES]:"30 Minutes",[v.FORTY_FIVE_MINUTES]:"45 Minutes",[v.ONE_HOUR]:"1 Hour",[v.TWO_HOURS]:"2 Hours",[v.THREE_HOURS]:"3 Hours",[v.FOUR_HOURS]:"4 Hours",[v.SIX_HOURS]:"6 Hours",[v.EIGHT_HOURS]:"8 Hours",[v.TWELVE_HOURS]:"12 Hours",[v.ONE_DAY]:"1 Day",[v.THREE_DAYS]:"3 Days",[v.ONE_WEEK]:"1 Week",[v.TWO_WEEKS]:"2 Weeks",[v.ONE_MONTH]:"1 Month",[v.THREE_MONTHS]:"3 Months",[v.SIX_MONTHS]:"6 Months"}[f]||f}function Oo(f,t,e,i=v.ONE_DAY){if(!f||f.length===0)return[];const r=Vi[i],a=r?r.seconds:86400,s=[],n=f[0],o=f[f.length-1],h=f.reduce((M,k)=>M+k.close,0)/f.length,l=typeof n.time=="string"?new Date(n.time).getTime()/1e3:n.time,g=typeof o.time=="string"?new Date(o.time).getTime()/1e3:o.time,c=1e4,d=Math.min(t,c),u=Math.min(e,c);let p=l;for(let M=d;M>0;M--){p-=a;const k={time:p,open:h,high:h,low:h,close:h,volume:-1,isVirtual:!0};s.unshift(k)}s.push(...f),p=g;for(let M=0;M<u;M++){p+=a;const k={time:p,open:h,high:h,low:h,close:h,volume:-1,isVirtual:!0};s.push(k)}return s}function jo(f,t){if(!f||f.length===0)return f;const e=No[t];return e?f.map(i=>{const r=i.time;let a;typeof r=="string"?a=new Date(r).getTime()/1e3:a=r;const s=e.offset.match(/^([+-])(\d{2}):(\d{2})$/);if(!s)return{...i,time:a};const n=s[1],o=parseInt(s[2],10),h=parseInt(s[3],10);let l=o*3600+h*60;n==="-"&&(l=-l);const d=-new Date(a*1e3).getTimezoneOffset()*60,u=l-d,p=a+u;return{...i,time:p}}):f}const No={[O.NEW_YORK]:{name:"America/New_York",offset:"-05:00",displayName:"New York"},[O.CHICAGO]:{name:"America/Chicago",offset:"-06:00",displayName:"Chicago"},[O.DENVER]:{name:"America/Denver",offset:"-07:00",displayName:"Denver"},[O.LOS_ANGELES]:{name:"America/Los_Angeles",offset:"-08:00",displayName:"Los Angeles"},[O.TORONTO]:{name:"America/Toronto",offset:"-05:00",displayName:"Toronto"},[O.LONDON]:{name:"Europe/London",offset:"+00:00",displayName:"London"},[O.PARIS]:{name:"Europe/Paris",offset:"+01:00",displayName:"Paris"},[O.FRANKFURT]:{name:"Europe/Frankfurt",offset:"+01:00",displayName:"Frankfurt"},[O.ZURICH]:{name:"Europe/Zurich",offset:"+01:00",displayName:"Zurich"},[O.MOSCOW]:{name:"Europe/Moscow",offset:"+03:00",displayName:"Moscow"},[O.DUBAI]:{name:"Asia/Dubai",offset:"+04:00",displayName:"Dubai"},[O.KARACHI]:{name:"Asia/Karachi",offset:"+05:00",displayName:"Karachi"},[O.KOLKATA]:{name:"Asia/Kolkata",offset:"+05:30",displayName:"Kolkata"},[O.SHANGHAI]:{name:"Asia/Shanghai",offset:"+08:00",displayName:"Shanghai"},[O.HONG_KONG]:{name:"Asia/Hong_Kong",offset:"+08:00",displayName:"Hong Kong"},[O.SINGAPORE]:{name:"Asia/Singapore",offset:"+08:00",displayName:"Singapore"},[O.TOKYO]:{name:"Asia/Tokyo",offset:"+09:00",displayName:"Tokyo"},[O.SEOUL]:{name:"Asia/Seoul",offset:"+09:00",displayName:"Seoul"},[O.SYDNEY]:{name:"Australia/Sydney",offset:"+10:00",displayName:"Sydney"},[O.AUCKLAND]:{name:"Pacific/Auckland",offset:"+12:00",displayName:"Auckland"},[O.UTC]:{name:"UTC",offset:"+00:00",displayName:"UTC"}};function Wo(f,t){if(!f||f.length===0)return[];try{const e=Xo(t);if(e<=0)return[...f];const i=[];let r=[],a=0;for(let s=0;s<f.length;s++){const n=f[s],o=typeof n.time=="string"?new Date(n.time).getTime()/1e3:n.time,h=Math.floor(o/e)*e;if(r.length===0)r.push(n),a=h;else if(h===a)r.push(n);else{if(r.length>0){const l=bi(r);i.push(l)}r=[n],a=h}}if(r.length>0){const s=bi(r);i.push(s)}return i}catch{return f}}function Xo(f){switch(f){case v.ONE_SECOND:return 1;case v.FIVE_SECONDS:return 5;case v.FIFTEEN_SECONDS:return 15;case v.THIRTY_SECONDS:return 30;case v.ONE_MINUTE:return 60;case v.THREE_MINUTES:return 180;case v.FIVE_MINUTES:return 300;case v.FIFTEEN_MINUTES:return 900;case v.THIRTY_MINUTES:return 1800;case v.FORTY_FIVE_MINUTES:return 2700;case v.ONE_HOUR:return 3600;case v.TWO_HOURS:return 7200;case v.THREE_HOURS:return 10800;case v.FOUR_HOURS:return 14400;case v.SIX_HOURS:return 360*60;case v.EIGHT_HOURS:return 480*60;case v.TWELVE_HOURS:return 720*60;case v.ONE_DAY:return 1440*60;case v.THREE_DAYS:return 4320*60;case v.ONE_WEEK:return 10080*60;case v.TWO_WEEKS:return 336*60*60;case v.ONE_MONTH:return 720*60*60;case v.THREE_MONTHS:return 2160*60*60;case v.SIX_MONTHS:return 4320*60*60;default:return 0}}function bi(f){if(f.length===1)return{...f[0]};const t=f[0].open,e=f[f.length-1].close;let i=-1/0,r=1/0,a=0;for(const s of f)i=Math.max(i,s.high),r=Math.min(r,s.low),a+=s.volume||0;return{time:f[0].time,open:t,high:i,low:r,close:e,volume:a,isVirtual:f.some(s=>s.isVirtual)}}function me(f,t,e,i){return{timeframe:f.timeframe||v.ONE_DAY,timezone:f.timezone||O.SHANGHAI,shouldExtendVirtualData:!0,virtualDataBeforeCount:e||0,virtualDataAfterCount:i||0,chartType:t}}class ke{static handleData(t,e,i){if(!t||t.length===0)return[];try{const r=jo(t,e.timezone),a=Wo(r,e.timeframe);return e.shouldExtendVirtualData?this.extendWithVirtualData(a,e):a}catch{return t}}static extendWithVirtualData(t,e){const i=e.virtualDataBeforeCount??this.calculateOptimalVirtualDataCount(e.timeframe,"before"),r=e.virtualDataAfterCount??this.calculateOptimalVirtualDataCount(e.timeframe,"after");return Oo(t,i,r,e.timeframe)}static calculateOptimalVirtualDataCount(t,e){const r=[v.ONE_SECOND,v.FIVE_SECONDS,v.FIFTEEN_SECONDS,v.THIRTY_SECONDS].includes(t),a=[v.ONE_MINUTE,v.THREE_MINUTES,v.FIVE_MINUTES,v.FIFTEEN_MINUTES,v.THIRTY_MINUTES,v.FORTY_FIVE_MINUTES].includes(t),s=[v.ONE_HOUR,v.TWO_HOURS,v.THREE_HOURS,v.FOUR_HOURS,v.SIX_HOURS,v.EIGHT_HOURS,v.TWELVE_HOURS].includes(t),n=[v.ONE_DAY,v.THREE_DAYS].includes(t),o=[v.ONE_WEEK,v.TWO_WEEKS].includes(t),h=[v.ONE_MONTH,v.THREE_MONTHS,v.SIX_MONTHS].includes(t);return r?Math.min(100,50):a?Math.min(100,80):s?100:n?200:o?300:h?400:100}static handleChartDisplayData(t,e){if(!t||t.length===0)return[];let i=[];try{return e===z.Candle||e===z.HollowCandle||e===z.Bar?i=t.map((r,a)=>{const s={time:r.time,open:Number(r.open),high:Number(r.high),low:Number(r.low),close:Number(r.close),volume:Number(r.volume)};return r.isVirtual?{...s,color:"transparent",borderColor:"transparent",wickColor:"transparent"}:s}):e===z.BaseLine?i=t.map(r=>{const a=r.isVirtual||r.volume===-1,s={time:r.time,value:Number(r.close)};return a?{...s,color:"transparent"}:s}):e===z.Line||e===z.Area||e===z.StepLine?i=t.map(r=>{const a=r.isVirtual||r.volume===-1,s={time:r.time,value:Number(r.close)};return a?{...s,color:"transparent"}:s}):e===z.Histogram?i=t.map(r=>{const a=r.isVirtual||r.volume===-1,s={time:r.time,value:r.volume||0};return a?{...s,color:"transparent"}:{...s,color:(r.volume||0)>100?"#26a69a":"#ef5350"}}):i=t.map(r=>{const a=r.isVirtual||r.volume===-1;return{time:r.time,value:Number(r.close),...a&&{color:"transparent"}}}),i}catch{return[]}}static filterRealData(t){return t.filter(e=>!e.isVirtual&&e.volume!==-1&&e.volume!==0)}static getTimeframeConfig(t){return Vi[t]}static validateData(t){return!t||!Array.isArray(t)?!1:t.every(e=>e.time!==void 0&&e.open!==void 0&&e.high!==void 0&&e.low!==void 0&&e.close!==void 0)}static sampleData(t,e=1){if(e>=1||t.length<=1e3)return t;const i=[],r=Math.floor(1/e);for(let a=0;a<t.length;a+=r)a<t.length&&i.push(t[a]);return i}}const vt=class vt{static getRealDataRange(t){if(t.length===0)return null;let e=-1,i=-1;for(let r=0;r<t.length;r++)if(!t[r].isVirtual){e=r;break}for(let r=t.length-1;r>=0;r--)if(!t[r].isVirtual){i=r;break}return{firstIndex:e,lastIndex:i}}static checkDataPointPositions(t,e,i){if(!t||!e)return;const{firstIndex:r,lastIndex:a}=e,{from:s,to:n}=t,o=r>=s&&r<=n,h=a>=s&&a<=n,l=r<s,g=r>n,c=a<s,d=a>n,p=(n-s)*.1,M=r>=n-p&&r<=n,k=a>=s&&a<=s+p;!this.lastFirstRealDataLeftViewport&&l&&i.onFirstRealDataExitLeftViewport?.(),!this.lastFirstRealDataRightViewport&&g&&i.onFirstRealDataExitRightViewport?.(),!this.lastLastRealDataLeftViewport&&c&&i.onLastRealDataExitLeftViewport?.(),!this.lastLastRealDataRightViewport&&d&&i.onLastRealDataExitRightViewport?.(),this.lastFirstRealDataLeftViewport&&!l&&o&&i.onFirstRealDataEnterLeftViewport?.(),!this.lastFirstRealDataNearRightViewport&&M&&i.onFirstRealDataNearRightViewport?.(),!this.lastLastRealDataNearLeftViewport&&k&&i.onLastRealDataNearLeftViewport?.(),this.lastFirstRealDataNearRightViewport&&!M&&i.onFirstRealDataLeaveNearRightViewport?.(),this.lastLastRealDataNearLeftViewport&&!k&&i.onLastRealDataLeaveNearLeftViewport?.(),this.lastFirstRealDataInViewport&&!o&&i.onFirstRealDataExitViewport?.(),this.lastLastRealDataInViewport&&!h&&i.onLastRealDataExitViewport?.(),this.lastFirstRealDataInViewport=o,this.lastLastRealDataInViewport=h,this.lastFirstRealDataLeftViewport=l,this.lastFirstRealDataRightViewport=g,this.lastLastRealDataLeftViewport=c,this.lastLastRealDataRightViewport=d,this.lastFirstRealDataNearRightViewport=M,this.lastLastRealDataNearLeftViewport=k}static reset(){this.lastFirstRealDataInViewport=!0,this.lastLastRealDataInViewport=!0,this.lastFirstRealDataLeftViewport=!1,this.lastFirstRealDataRightViewport=!1,this.lastLastRealDataLeftViewport=!1,this.lastLastRealDataRightViewport=!1,this.lastFirstRealDataNearRightViewport=!1,this.lastLastRealDataNearLeftViewport=!1}static getCurrentState(){return{lastFirstRealDataInViewport:this.lastFirstRealDataInViewport,lastLastRealDataInViewport:this.lastLastRealDataInViewport,lastFirstRealDataLeftViewport:this.lastFirstRealDataLeftViewport,lastFirstRealDataRightViewport:this.lastFirstRealDataRightViewport,lastLastRealDataLeftViewport:this.lastLastRealDataLeftViewport,lastLastRealDataRightViewport:this.lastLastRealDataRightViewport,lastFirstRealDataNearRightViewport:this.lastFirstRealDataNearRightViewport,lastLastRealDataNearLeftViewport:this.lastLastRealDataNearLeftViewport}}};vt.lastFirstRealDataInViewport=!0,vt.lastLastRealDataInViewport=!0,vt.lastFirstRealDataLeftViewport=!1,vt.lastFirstRealDataRightViewport=!1,vt.lastLastRealDataLeftViewport=!1,vt.lastLastRealDataRightViewport=!1,vt.lastFirstRealDataNearRightViewport=!1,vt.lastLastRealDataNearLeftViewport=!1;let Ce=vt;class Yo{constructor(t,e){this.chart=null,this.currentSeries=null,this.beforeViewPortBuffer=100,this.afterViewPortBuffer=0,this.getViewportDataPoints=(i,r)=>{if(!r||r.length===0)return[];const a=i.from-this.beforeViewPortBuffer,s=i.to-this.afterViewPortBuffer;return r.filter(o=>o.time>=a&&o.time<=s)},this.scrollLockState={isScrollLocked:!1,lockDirection:null,safeVisibleRange:null},this.chart=t,this.currentSeries=e}zoomIn(){if(!this.chart)return;const t=this.chart.timeScale(),e=t.getVisibleRange();if(!e)return;const a=(e.to-e.from)*.8,s=(e.from+e.to)/2;t.setVisibleRange({from:s-a/2,to:s+a/2})}zoomOut(){if(!this.chart)return;const t=this.chart.timeScale(),e=t.getVisibleRange();if(!e)return;const a=(e.to-e.from)*1.2,s=(e.from+e.to)/2;t.setVisibleRange({from:s-a/2,to:s+a/2})}scrollChart(t){if(!this.chart)return;const e=this.chart.timeScale(),i=e.getVisibleRange();if(!i)return;const a=(i.to-i.from)*.2;t==="left"?e.setVisibleRange({from:i.from-a,to:i.to-a}):e.setVisibleRange({from:i.from+a,to:i.to+a})}positionChart(t){this.setOptimalBarSpacing(t),this.scrollToRealData()}getVisibleTimeRange(){if(!this.chart)return null;try{const e=this.chart.timeScale().getVisibleRange();return e?{from:e.from,to:e.to}:null}catch(t){return console.error(t),null}}setVisibleTimeRange(t){if(!this.chart||!t)return;const e=this.chart.timeScale();try{e.setVisibleRange({from:t.from,to:t.to})}catch(i){console.error(i),this.scrollToRealData()}}scrollToRealData(){if(this.chart)try{const t=this.chart.timeScale(),e=this.currentSeries?.series?.data||[];if(e.length===0){t.fitContent();return}const{firstIndex:i,lastIndex:r,virtualAfterCount:a}=this.getRealDataRange();if(i===-1||r===-1){t.fitContent();return}const s=Math.min(100,r-i+1+10),n=Math.max(0,i-5),o=Math.min(e.length-1,r+Math.min(10,a));t.setVisibleLogicalRange({from:n,to:o})}catch(t){console.error(t),this.scrollToStablePosition()}}scrollToStablePosition(){if(this.chart)try{const t=this.chart.timeScale(),e=this.currentSeries?.series?.data||[];if(e.length===0){t.fitContent();return}const{lastIndex:i}=this.getRealDataRange();if(i===-1)t.setVisibleLogicalRange({from:Math.max(0,e.length-50),to:e.length-1});else{const a=Math.max(0,i-50+1),s=Math.min(e.length-1,i+5);t.setVisibleLogicalRange({from:a,to:s})}}catch(t){console.error(t),this.chart&&this.chart.timeScale().fitContent()}}getRealDataRange(){const t=this.currentSeries?.series?.data||[];let e=-1,i=-1,r=0,a=0,s=0;for(let n=0;n<t.length;n++){const o=t[n];if(!o.isVirtual&&o.volume!==-1&&o.volume!==0&&o.open!==void 0&&o.high!==void 0&&o.low!==void 0&&o.close!==void 0){e=n,a=n;break}}for(let n=t.length-1;n>=0;n--){const o=t[n];if(!o.isVirtual&&o.volume!==-1&&o.volume!==0&&o.open!==void 0&&o.high!==void 0&&o.low!==void 0&&o.close!==void 0){i=n,s=t.length-1-n;break}}if(e!==-1&&i!==-1)for(let n=e;n<=i;n++){const o=t[n];!o.isVirtual&&o.volume!==-1&&o.volume!==0&&o.open!==void 0&&o.high!==void 0&&o.low!==void 0&&o.close!==void 0&&r++}return{firstIndex:e,lastIndex:i,realDataCount:r,virtualBeforeCount:a,virtualAfterCount:s}}setOptimalBarSpacing(t){if(!this.chart)return;const e=this.chart.timeScale(),r=e.options().barSpacing||10,s={[v.ONE_SECOND]:1,[v.FIVE_SECONDS]:2,[v.FIFTEEN_SECONDS]:3,[v.THIRTY_SECONDS]:4,[v.ONE_MINUTE]:5,[v.THREE_MINUTES]:6,[v.FIVE_MINUTES]:7,[v.FIFTEEN_MINUTES]:8,[v.THIRTY_MINUTES]:9,[v.FORTY_FIVE_MINUTES]:10,[v.ONE_HOUR]:12,[v.TWO_HOURS]:14,[v.THREE_HOURS]:16,[v.FOUR_HOURS]:18,[v.SIX_HOURS]:20,[v.EIGHT_HOURS]:22,[v.TWELVE_HOURS]:24,[v.ONE_DAY]:15,[v.THREE_DAYS]:20,[v.ONE_WEEK]:25,[v.TWO_WEEKS]:30,[v.ONE_MONTH]:35,[v.THREE_MONTHS]:40,[v.SIX_MONTHS]:45}[t]||10;let n=s;Math.abs(r-s)>2&&(n=r);try{e.applyOptions({barSpacing:n,minBarSpacing:.5,maxBarSpacing:50})}catch(o){console.error(o)}}handleChartScrollLock(t,e){const i=this.chart.timeScale(),r=Ce.getRealDataRange(e);if(!r)return;const{firstIndex:a,lastIndex:s}=r;if(a!==-1&&s!==-1&&e.length>0){const n=i.getVisibleLogicalRange();if(n){const{from:o,to:h}=n,l=a>=h-1,g=s<=o+1;if(this.scrollLockState.isScrollLocked&&this.scrollLockState.safeVisibleRange&&(this.scrollLockState.lockDirection==="right"?t.from>this.scrollLockState.safeVisibleRange.from+2&&!l&&(this.scrollLockState.isScrollLocked=!1,this.scrollLockState.lockDirection=null,this.scrollLockState.safeVisibleRange=null):this.scrollLockState.lockDirection==="left"&&t.from<this.scrollLockState.safeVisibleRange.from-2&&!g&&(this.scrollLockState.isScrollLocked=!1,this.scrollLockState.lockDirection=null,this.scrollLockState.safeVisibleRange=null),this.scrollLockState.isScrollLocked)){i.setVisibleRange(this.scrollLockState.safeVisibleRange);return}this.scrollLockState.isScrollLocked||(l?(this.scrollLockState.isScrollLocked=!0,this.scrollLockState.lockDirection="right",this.scrollLockState.safeVisibleRange={...t},i.setVisibleRange(this.scrollLockState.safeVisibleRange)):g&&(this.scrollLockState.isScrollLocked=!0,this.scrollLockState.lockDirection="left",this.scrollLockState.safeVisibleRange={...t},i.setVisibleRange(this.scrollLockState.safeVisibleRange)))}}}}const Vo={panel:{backgroundColor:"#1A1D24",borderColor:"#2D323D"},modal:{textColor:"#FFFFFF"},layout:{background:{color:"#0F1116"},textColor:"#E8EAED",attributionLogo:!1},grid:{vertLines:{visible:!1,color:"#2D323D"},horzLines:{visible:!1,color:"#2D323D"}},chart:{candleUpColor:"#26a69a",candleDownColor:"#ef5350",lineColor:"#2962FF",topColor:"rgba(41, 98, 255, 0.4)",bottomColor:"rgba(41, 98, 255, 0)",lineWidth:2,upColor:"#00C087",downColor:"#FF5B5A",background:"#0F1116",baseLineColor:"#FF9800",histogramColor:"#4CAF50",stepLineColor:"#9C27B0",areaTopColor:"rgba(33, 150, 243, 0.4)",areaBottomColor:"rgba(33, 150, 243, 0)",areaLineColor:"#2196F3",volumeColor:"#4CAF50"},toolbar:{background:"#1A1D24",border:"#2D323D",button:{backgroundColor:"#2D323D",background:"transparent",hover:"#2D323D",active:"#2962FF",color:"#E8EAED",activeTextColor:"#FFFFFF",boxShadow:"0 0 0 1px rgba(255, 255, 255, 0.1), 0 2px 4px rgba(0, 0, 0, 0.3)",sendButton:{normal:"#7A7F8B",hover:"#8F949F",disabled:"#3D4759"},inputFocus:"#8F949F",dropdown:{hover:"#2D323D",selected:"#7A7F8B30",borderActive:"#8F949F"}}},divider:{normal:"#2D323D20",hover:"#E8EAED30",dragging:"#E8EAED80"}},qo={panel:{backgroundColor:"#FFFFFF",borderColor:"#E1E5E9"},modal:{textColor:"#1A1D24"},layout:{background:{color:"#FFFFFF"},textColor:"#1A1D24",attributionLogo:!1},grid:{vertLines:{visible:!1,color:"#E1E5E9"},horzLines:{visible:!1,color:"#E1E5E9"}},chart:{candleUpColor:"#26a69a",candleDownColor:"#ef5350",lineColor:"#2962FF",topColor:"rgba(41, 98, 255, 0.4)",bottomColor:"rgba(41, 98, 255, 0)",lineWidth:2,upColor:"#00C087",downColor:"#FF5B5A",background:"#0F1116",baseLineColor:"#FF9800",histogramColor:"#4CAF50",stepLineColor:"#9C27B0",areaTopColor:"rgba(33, 150, 243, 0.4)",areaBottomColor:"rgba(33, 150, 243, 0)",areaLineColor:"#2196F3",volumeColor:"#4CAF50"},toolbar:{background:"#F8F9FA",border:"#E1E5E9",button:{backgroundColor:"#FFFFFF",background:"transparent",hover:"#E1E5E9",active:"#2962FF",color:"#495057",activeTextColor:"#FFFFFF",boxShadow:"0 0 0 1px rgba(0, 0, 0, 0.1), 0 2px 4px rgba(0, 0, 0, 0.1)",sendButton:{normal:"#6C757D",hover:"#495057",disabled:"#E1E5E9"},inputFocus:"#1A1D24",dropdown:{hover:"#F1F3F5",selected:"#6C757D15",borderActive:"#1A1D24"}}},divider:{normal:"#E1E5E920",hover:"#49505730",dragging:"#49505780"}},zo=new Map([["qwen-turbo",{name:"qwen-turbo",displayName:"Qwen-Turbo",endpoint:"https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions",endpoints:["https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions","https://dashscope.aliyuncs.com/api/v1/services/aigc/text-generation/generation"],format:"openai",description:"Lightweight version, fast response speed, suitable for general conversation scenarios",maxTokens:2e3,contextLength:8e3,capabilities:["text-generation","chat"]}],["qwen-plus",{name:"qwen-plus",displayName:"Qwen-Plus",endpoint:"https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions",endpoints:["https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions"],format:"openai",description:"Enhanced version, suitable for complex tasks and long text processing",maxTokens:6e3,contextLength:32e3,capabilities:["text-generation","chat","reasoning"]}],["qwen-max",{name:"qwen-max",displayName:"Qwen-Max",endpoint:"https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions",endpoints:["https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions"],format:"openai",description:"Maximum version, strongest capabilities, suitable for high-demand professional tasks",maxTokens:8e3,contextLength:32e3,capabilities:["text-generation","chat","reasoning","coding","analysis"]}],["qwen-max-longcontext",{name:"qwen-max-longcontext",displayName:"Qwen-Max-LongContext",endpoint:"https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions",endpoints:["https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions"],format:"openai",description:"Supports 128K long context, suitable for long document processing",maxTokens:8e3,contextLength:128e3,capabilities:["text-generation","chat","document-analysis"]}],["qwen2.5-0.5b",{name:"qwen2.5-0.5b",displayName:"Qwen2.5-0.5B",endpoint:"https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions",format:"openai",description:"Ultra-lightweight 0.5B parameter model for edge devices",maxTokens:4e3,contextLength:32e3,capabilities:["text-generation","chat"]}],["qwen2.5-0.5b-instruct",{name:"qwen2.5-0.5b-instruct",displayName:"Qwen2.5-0.5B-Instruct",endpoint:"https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions",format:"openai",description:"Instruction-tuned 0.5B model for specific tasks",maxTokens:4e3,contextLength:32e3,capabilities:["instruction-following","chat"]}],["qwen2.5-7b",{name:"qwen2.5-7b",displayName:"Qwen2.5-7B",endpoint:"https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions",format:"openai",description:"7B parameter base model, balanced performance and efficiency",maxTokens:6e3,contextLength:32e3,capabilities:["text-generation","reasoning"]}],["qwen2.5-7b-instruct",{name:"qwen2.5-7b-instruct",displayName:"Qwen2.5-7B-Instruct",endpoint:"https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions",format:"openai",description:"Instruction-tuned 7B model for chat and tasks",maxTokens:6e3,contextLength:32e3,capabilities:["chat","instruction-following","coding"]}],["qwen2.5-14b",{name:"qwen2.5-14b",displayName:"Qwen2.5-14B",endpoint:"https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions",format:"openai",description:"14B parameter model with enhanced capabilities",maxTokens:8e3,contextLength:32e3,capabilities:["text-generation","analysis","reasoning"]}],["qwen2.5-32b",{name:"qwen2.5-32b",displayName:"Qwen2.5-32B",endpoint:"https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions",format:"openai",description:"32B parameter high-performance model",maxTokens:8e3,contextLength:32e3,capabilities:["text-generation","complex-reasoning","analysis"]}],["qwen2.5-72b",{name:"qwen2.5-72b",displayName:"Qwen2.5-72B",endpoint:"https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions",format:"openai",description:"72B parameter state-of-the-art model",maxTokens:8e3,contextLength:32e3,capabilities:["text-generation","expert-analysis","research"]}],["qwen2.5-coder",{name:"qwen2.5-coder",displayName:"Qwen2.5-Coder",endpoint:"https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions",format:"openai",description:"Specialized code generation model",maxTokens:8e3,contextLength:32e3,capabilities:["code-generation","code-explanation","debugging"]}],["qwen2.5-coder-7b",{name:"qwen2.5-coder-7b",displayName:"Qwen2.5-Coder-7B",endpoint:"https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions",format:"openai",description:"7B parameter code generation model",maxTokens:8e3,contextLength:32e3,capabilities:["code-generation","programming"]}],["qwen2.5-coder-14b",{name:"qwen2.5-coder-14b",displayName:"Qwen2.5-Coder-14B",endpoint:"https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions",format:"openai",description:"14B parameter advanced code generation model",maxTokens:8e3,contextLength:32e3,capabilities:["code-generation","code-review","optimization"]}],["qwen-vl-lite",{name:"qwen-vl-lite",displayName:"Qwen-VL-Lite",endpoint:"https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions",format:"openai",description:"Lightweight vision-language model for basic image understanding",maxTokens:2e3,contextLength:8e3,capabilities:["image-understanding","visual-qa"]}],["qwen-vl-plus",{name:"qwen-vl-plus",displayName:"Qwen-VL-Plus",endpoint:"https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions",format:"openai",description:"Vision-language model supporting image understanding",maxTokens:4e3,contextLength:32e3,capabilities:["image-understanding","document-analysis","visual-reasoning"]}],["qwen-vl-max",{name:"qwen-vl-max",displayName:"Qwen-VL-Max",endpoint:"https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions",format:"openai",description:"Most powerful vision-language model",maxTokens:8e3,contextLength:32e3,capabilities:["image-understanding","video-analysis","multimodal-reasoning"]}],["qwen-audio-turbo",{name:"qwen-audio-turbo",displayName:"Qwen-Audio-Turbo",endpoint:"https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions",format:"openai",description:"Fast audio processing and speech-to-text model",maxTokens:2e3,contextLength:8e3,capabilities:["speech-recognition","audio-analysis"]}],["qwen-audio-chat",{name:"qwen-audio-chat",displayName:"Qwen-Audio-Chat",endpoint:"https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions",format:"openai",description:"Audio conversation and processing model",maxTokens:4e3,contextLength:32e3,capabilities:["audio-chat","voice-assistant","speech-synthesis"]}],["qwen-math-7b",{name:"qwen-math-7b",displayName:"Qwen-Math-7B",endpoint:"https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions",format:"openai",description:"Specialized for mathematical reasoning and problem solving",maxTokens:4e3,contextLength:32e3,capabilities:["mathematical-reasoning","problem-solving"]}],["llama2-7b-chat-v2",{name:"llama2-7b-chat-v2",displayName:"LLaMA2-7B-Chat",endpoint:"https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions",format:"openai",description:"Meta's LLaMA2-7B model",maxTokens:2e3,contextLength:8e3,capabilities:["chat","text-generation"]}],["baichuan2-7b-chat-v1",{name:"baichuan2-7b-chat-v1",displayName:"Baichuan2-7B-Chat",endpoint:"https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions",format:"openai",description:"Baichuan AI's Baichuan2-7B model",maxTokens:2e3,contextLength:8e3,capabilities:["chat","chinese-nlp"]}],["qwen-financial",{name:"qwen-financial",displayName:"Qwen-Financial",endpoint:"https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions",format:"openai",description:"Specialized for financial analysis and market insights",maxTokens:6e3,contextLength:32e3,capabilities:["financial-analysis","market-prediction","risk-assessment"]}],["qwen-medical",{name:"qwen-medical",displayName:"Qwen-Medical",endpoint:"https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions",format:"openai",description:"Specialized for medical consultation and health analysis",maxTokens:6e3,contextLength:32e3,capabilities:["medical-consultation","health-analysis","diagnostic-support"]}],["qwen-omni",{name:"qwen-omni",displayName:"Qwen-Omni",endpoint:"https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions",format:"openai",description:"Omnidirectional multimodal model supporting text, image, audio",maxTokens:8e3,contextLength:64e3,capabilities:["text-generation","image-understanding","audio-processing","multimodal"]}],["qwen-omni-pro",{name:"qwen-omni-pro",displayName:"Qwen-Omni-Pro",endpoint:"https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions",format:"openai",description:"Professional omnidirectional multimodal model with advanced capabilities",maxTokens:16e3,contextLength:128e3,capabilities:["text-generation","multimodal","complex-reasoning","expert-analysis"]}]]);function Qo(){return Array.from(zo.keys())}const Go=new Map([["deepseek-chat",{name:"deepseek-chat",displayName:"DeepSeek Chat",endpoint:"https://api.deepseek.com/v1/chat/completions",endpoints:["https://api.deepseek.com/v1/chat/completions"],format:"openai",description:"General purpose chat model for everyday conversations and tasks",maxTokens:4096,contextLength:16e3,capabilities:["chat","text-generation","reasoning"],version:"2025-01"}],["deepseek-chat-lite",{name:"deepseek-chat-lite",displayName:"DeepSeek Chat Lite",endpoint:"https://api.deepseek.com/v1/chat/completions",format:"openai",description:"Lightweight chat model optimized for speed and efficiency",maxTokens:2048,contextLength:8e3,capabilities:["chat","text-generation"],version:"2025-01"}],["deepseek-chat-pro",{name:"deepseek-chat-pro",displayName:"DeepSeek Chat Pro",endpoint:"https://api.deepseek.com/v1/chat/completions",format:"openai",description:"Professional chat model with enhanced reasoning capabilities",maxTokens:8192,contextLength:32e3,capabilities:["chat","text-generation","complex-reasoning","analysis"],version:"2025-01"}],["deepseek-chat-max",{name:"deepseek-chat-max",displayName:"DeepSeek Chat Max",endpoint:"https://api.deepseek.com/v1/chat/completions",format:"openai",description:"Maximum capability chat model for most demanding tasks",maxTokens:16384,contextLength:64e3,capabilities:["chat","text-generation","expert-analysis","research"],version:"2025-01"}],["deepseek-coder",{name:"deepseek-coder",displayName:"DeepSeek Coder",endpoint:"https://api.deepseek.com/v1/chat/completions",format:"openai",description:"Specialized model for code generation and programming tasks",maxTokens:16384,contextLength:64e3,capabilities:["code-generation","programming","debugging","code-review"],version:"2025-01"}],["deepseek-coder-lite",{name:"deepseek-coder-lite",displayName:"DeepSeek Coder Lite",endpoint:"https://api.deepseek.com/v1/chat/completions",format:"openai",description:"Lightweight code generation model",maxTokens:4096,contextLength:16e3,capabilities:["code-generation","programming"],version:"2025-01"}],["deepseek-coder-pro",{name:"deepseek-coder-pro",displayName:"DeepSeek Coder Pro",endpoint:"https://api.deepseek.com/v1/chat/completions",format:"openai",description:"Professional code generation model with advanced features",maxTokens:32768,contextLength:128e3,capabilities:["code-generation","programming","system-design","architecture"],version:"2025-01"}],["deepseek-math",{name:"deepseek-math",displayName:"DeepSeek Math",endpoint:"https://api.deepseek.com/v1/chat/completions",format:"openai",description:"Specialized model for mathematical reasoning and problem solving",maxTokens:8192,contextLength:32e3,capabilities:["mathematical-reasoning","problem-solving","calculations"],version:"2025-01"}],["deepseek-math-pro",{name:"deepseek-math-pro",displayName:"DeepSeek Math Pro",endpoint:"https://api.deepseek.com/v1/chat/completions",format:"openai",description:"Advanced mathematical reasoning model for complex problems",maxTokens:16384,contextLength:64e3,capabilities:["mathematical-reasoning","advanced-calculus","statistics"],version:"2025-01"}],["deepseek-reasoner",{name:"deepseek-reasoner",displayName:"DeepSeek Reasoner",endpoint:"https://api.deepseek.com/v1/chat/completions",format:"openai",description:"Dedicated reasoning model for logical analysis",maxTokens:8192,contextLength:32e3,capabilities:["logical-reasoning","analysis","decision-making"],version:"2025-01"}],["deepseek-reasoner-pro",{name:"deepseek-reasoner-pro",displayName:"DeepSeek Reasoner Pro",endpoint:"https://api.deepseek.com/v1/chat/completions",format:"openai",description:"Advanced reasoning model for complex logical problems",maxTokens:16384,contextLength:64e3,capabilities:["complex-reasoning","scientific-analysis","research"],version:"2025-01"}],["deepseek-vision",{name:"deepseek-vision",displayName:"DeepSeek Vision",endpoint:"https://api.deepseek.com/v1/chat/completions",format:"openai",description:"Vision model for image understanding and analysis",maxTokens:4096,contextLength:16e3,capabilities:["image-understanding","visual-qa","document-analysis"],version:"2025-01"}],["deepseek-vision-pro",{name:"deepseek-vision-pro",displayName:"DeepSeek Vision Pro",endpoint:"https://api.deepseek.com/v1/chat/completions",format:"openai",description:"Advanced vision model for complex visual tasks",maxTokens:8192,contextLength:32e3,capabilities:["image-understanding","video-analysis","visual-reasoning"],version:"2025-01"}],["deepseek-finance",{name:"deepseek-finance",displayName:"DeepSeek Finance",endpoint:"https://api.deepseek.com/v1/chat/completions",format:"openai",description:"Specialized for financial analysis, market prediction, and investment insights",maxTokens:8192,contextLength:32e3,capabilities:["financial-analysis","market-prediction","risk-assessment","investment-advice"],version:"2025-01"}],["deepseek-law",{name:"deepseek-law",displayName:"DeepSeek Law",endpoint:"https://api.deepseek.com/v1/chat/completions",format:"openai",description:"Specialized for legal analysis, contract review, and legal research",maxTokens:16384,contextLength:64e3,capabilities:["legal-analysis","contract-review","legal-research"],version:"2025-01"}],["deepseek-medical",{name:"deepseek-medical",displayName:"DeepSeek Medical",endpoint:"https://api.deepseek.com/v1/chat/completions",format:"openai",description:"Specialized for medical consultation, diagnosis support, and health analysis",maxTokens:8192,contextLength:32e3,capabilities:["medical-consultation","diagnostic-support","health-analysis"],version:"2025-01"}],["deepseek-research",{name:"deepseek-research",displayName:"DeepSeek Research",endpoint:"https://api.deepseek.com/v1/chat/completions",format:"openai",description:"Specialized for academic research and scientific analysis",maxTokens:32768,contextLength:128e3,capabilities:["academic-research","scientific-analysis","paper-writing"],version:"2025-01"}],["deepseek-omni",{name:"deepseek-omni",displayName:"DeepSeek Omni",endpoint:"https://api.deepseek.com/v1/chat/completions",format:"openai",description:"Multimodal model supporting text, image, and audio",maxTokens:16384,contextLength:64e3,capabilities:["text-generation","image-understanding","audio-processing","multimodal"],version:"2025-01"}],["deepseek-omni-pro",{name:"deepseek-omni-pro",displayName:"DeepSeek Omni Pro",endpoint:"https://api.deepseek.com/v1/chat/completions",format:"openai",description:"Professional multimodal model with advanced capabilities",maxTokens:32768,contextLength:128e3,capabilities:["text-generation","multimodal","complex-reasoning","expert-analysis"],version:"2025-01"}],["deepseek-llm",{name:"deepseek-llm",displayName:"DeepSeek LLM",endpoint:"https://api.deepseek.com/v1/chat/completions",format:"openai",description:"Base large language model",maxTokens:4096,contextLength:16e3,capabilities:["text-generation"],version:"2024-12"}]]);function Jo(){return Array.from(Go.keys())}const $o=new Map([["gpt-4",{name:"gpt-4",displayName:"GPT-4",endpoint:"https://api.openai.com/v1/chat/completions",format:"openai",description:"Powerful multi-purpose model for complex tasks",maxTokens:8192,contextLength:8192,capabilities:["chat","text-generation","reasoning","analysis"],inputCostPer1KTokens:.03,outputCostPer1KTokens:.06,supportedFeatures:["chat","function-calling"]}],["gpt-4-turbo",{name:"gpt-4-turbo",displayName:"GPT-4 Turbo",endpoint:"https://api.openai.com/v1/chat/completions",format:"openai",description:"Enhanced GPT-4 with 128K context, knowledge cutoff April 2023",maxTokens:4096,contextLength:128e3,capabilities:["chat","text-generation","reasoning","analysis","vision"],inputCostPer1KTokens:.01,outputCostPer1KTokens:.03,supportedFeatures:["chat","function-calling","vision","json-mode"]}],["gpt-4o",{name:"gpt-4o",displayName:"GPT-4o",endpoint:"https://api.openai.com/v1/chat/completions",format:"openai",description:"Versatile model supporting text, images, audio with fast response",maxTokens:4096,contextLength:128e3,capabilities:["chat","text-generation","vision","audio-processing","multimodal"],inputCostPer1KTokens:.005,outputCostPer1KTokens:.015,supportedFeatures:["chat","function-calling","vision","audio","json-mode"]}],["gpt-4o-mini",{name:"gpt-4o-mini",displayName:"GPT-4o Mini",endpoint:"https://api.openai.com/v1/chat/completions",format:"openai",description:"Compact and efficient version of GPT-4o with lower cost",maxTokens:16384,contextLength:128e3,capabilities:["chat","text-generation","vision"],inputCostPer1KTokens:15e-5,outputCostPer1KTokens:6e-4,supportedFeatures:["chat","function-calling","vision","json-mode"]}],["gpt-3.5-turbo",{name:"gpt-3.5-turbo",displayName:"GPT-3.5 Turbo",endpoint:"https://api.openai.com/v1/chat/completions",format:"openai",description:"Fast and cost-effective, suitable for most conversational tasks",maxTokens:4096,contextLength:16385,capabilities:["chat","text-generation","code-generation"],inputCostPer1KTokens:5e-4,outputCostPer1KTokens:.0015,supportedFeatures:["chat","function-calling"]}],["gpt-3.5-turbo-instruct",{name:"gpt-3.5-turbo-instruct",displayName:"GPT-3.5 Turbo Instruct",endpoint:"https://api.openai.com/v1/completions",format:"openai",description:"Instruction-tuned version for text completion tasks",maxTokens:4096,contextLength:4097,capabilities:["text-completion","instruction-following"],inputCostPer1KTokens:.0015,outputCostPer1KTokens:.002,supportedFeatures:["completions"]}],["text-embedding-ada-002",{name:"text-embedding-ada-002",displayName:"Text Embedding Ada 002",endpoint:"https://api.openai.com/v1/embeddings",format:"openai",description:"Text embedding model, 1536 dimensions, suitable for retrieval and similarity",contextLength:8191,capabilities:["embeddings","semantic-search"],inputCostPer1KTokens:1e-4,supportedFeatures:["embeddings"]}],["text-embedding-3-small",{name:"text-embedding-3-small",displayName:"Text Embedding 3 Small",endpoint:"https://api.openai.com/v1/embeddings",format:"openai",description:"Small text embedding model, 1536 dimensions, balance of performance and cost",contextLength:8191,capabilities:["embeddings","semantic-search"],inputCostPer1KTokens:2e-5,supportedFeatures:["embeddings"]}],["dall-e-3",{name:"dall-e-3",displayName:"DALL-E 3",endpoint:"https://api.openai.com/v1/images/generations",format:"openai",description:"Advanced image generation model producing high-quality, high-resolution images",capabilities:["image-generation","creative-design"],inputCostPer1KTokens:.04,supportedFeatures:["image-generation","variations","edits"]}],["whisper-1",{name:"whisper-1",displayName:"Whisper",endpoint:"https://api.openai.com/v1/audio/transcriptions",format:"openai",description:"Speech recognition model supporting multilingual transcription and translation",capabilities:["speech-recognition","audio-transcription","translation"],inputCostPer1KTokens:.006,supportedFeatures:["transcriptions","translations"]}],["tts-1-hd",{name:"tts-1-hd",displayName:"TTS-1 HD",endpoint:"https://api.openai.com/v1/audio/speech",format:"openai",description:"High-quality text-to-speech with multiple voice options",capabilities:["speech-synthesis","text-to-speech"],inputCostPer1KTokens:.015,supportedFeatures:["speech","voice-selection"]}],["text-moderation-latest",{name:"text-moderation-latest",displayName:"Moderation Latest",endpoint:"https://api.openai.com/v1/moderations",format:"openai",description:"Content moderation model for detecting harmful content",capabilities:["content-moderation","safety"],inputCostPer1KTokens:1e-4,supportedFeatures:["moderation"]}]]);function Zo(){return Array.from($o.keys())}var qi=(f=>(f.AnalyzeOHLCV="/analyzeOHLCV",f))(qi||{}),St=(f=>(f.Aliyun="aliyun",f.OpenAI="openai",f.DeepSeek="deepseek",f.Claude="claude",f.Gemini="gemini",f))(St||{});const tl={aliyun:"https://cdn.simpleicons.org/alibabacloud/FF6A00",openai:"https://cdn.simpleicons.org/openai/412991",deepseek:"https://www.deepseek.com/favicon.ico",claude:"https://cdn.simpleicons.org/anthropic/FF6B35",gemini:"https://cdn.simpleicons.org/google/4285F4"},Ti={aliyun:"Aliyun",openai:"OpenAI",deepseek:"DeepSeek",claude:"Claude",gemini:"Gemini"};function el(f){switch(f){case"openai":return Zo();case"aliyun":return Qo();case"deepseek":return Jo();case"claude":return[];case"gemini":return[];default:return[]}}var kt=(f=>(f.OpenaiChart="openai-chart",f.OpenaiPredict="openai-predict",f.AliyunChart="aliyun-chart",f.AliyunPredict="aliyun-predict",f.DeepseekChart="deepseek-chart",f.DeepseekPredict="deepseek-predict",f.ClaudeChart="claude-chart",f.ClaudePredict="claude-predict",f.GeminiChart="gemini-chart",f.GeminiPredict="gemini-predict",f))(kt||{});function il(f){return f.endsWith("/")?f.slice(0,-1):f}async function rl(f,t,e,i,r,a){const s=r.map(l=>({open:l.open,high:l.high,low:l.low,close:l.close,volume:l.volume})),n={provider:e,data:s,i18n:f===Mt?"en":"cn",modelType:i,analysisType:"comprehensive",message:a,options:{temperature:.5,maxTokens:1e3}},h=`${il(t)}${qi.AnalyzeOHLCV}`;try{const l=await fetch(h,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!l.ok){const c=await l.text();throw new Error(`HTTP error! status: ${l.status}`)}const g=await l.json();if(g.success)return g.analysis;throw new Error(g.error||"Unknown error from AI service")}catch(l){throw new Error(`AI service error: ${l.message||"Network error"}`)}}const sl=({currentTheme:f,i18n:t,currentAIFunctionType:e,aiconfigs:i,onClose:r,onSendMessage:a,isLoading:s=!1,initialMessage:n="",currentAIBrandType:o,onModelChange:h,data:l})=>{const[g,c]=E.useState(""),[d,u]=E.useState([]),[p,M]=E.useState(!1),[k,P]=E.useState(""),[S,_]=E.useState([]),[C,A]=E.useState(!1),x=E.useRef(null),R=E.useRef(null),U=E.useRef(null),[L,X]=E.useState(10),K=10,Z=E.useRef(!1),at=E.useRef(0),$=E.useRef(0);E.useEffect(()=>{const B=G=>{C&&U.current&&!U.current.contains(G.target)&&A(!1)};return document.addEventListener("mousedown",B),()=>{document.removeEventListener("mousedown",B)}},[C]),E.useEffect(()=>{if(o&&k){const B=i.find(G=>G.brand===o&&G.model===k);X(B?.maxAnalyzeData??K)}else X(K)},[o,k,i]);const tt=()=>l.length>L?l.slice(-L):l,j=()=>{if(!x.current)return;const B=x.current;!st()&&!Z.current||requestAnimationFrame(()=>{B&&(B.scrollTop=B.scrollHeight,Z.current=!1)})},st=(B=50)=>{if(!x.current)return!0;const G=x.current;return G.scrollHeight-G.scrollTop-G.clientHeight<=B},ht=(B,G)=>{const rt=[];return G.forEach(ot=>{let dt=!1;for(const pt of B)if(pt.toString()===ot){dt=!0;break}if(dt)rt.push(ot);else{const pt=ot.toLowerCase();B.find(mt=>mt.toString().toLowerCase()===pt)&&rt.push(ot)}}),rt.filter((ot,dt,pt)=>pt.indexOf(ot)===dt)};E.useEffect(()=>{if(o!=null)try{const B=el(o),G=i.filter(ot=>ot.brand===o).map(ot=>ot.model),rt=ht(B,G);if(_(rt),rt.length>0){if(!rt.includes(k)){const ot=rt[0];P(ot),h&&h(ot)}}else P(""),h&&h("")}catch{_([]),P("")}else _([]),P("")},[o,i,h,k]),E.useEffect(()=>{Z.current=!0,j()},[d]),E.useEffect(()=>{const B=x.current;if(!B)return;const G=()=>{B&&($.current=B.scrollTop,at.current=B.scrollHeight)};return B.addEventListener("scroll",G),()=>B.removeEventListener("scroll",G)},[]),E.useEffect(()=>{const B=R.current;B&&setTimeout(()=>{B.style.height="auto";const rt=Math.max(B.scrollHeight,60);B.style.height=`${rt}px`},100)},[]),E.useEffect(()=>{u([{id:"welcome",content:t===Mt?"Welcome to AI analysis. How can I help you?":"欢迎使用AI分析。有什么可以帮助您的?",sender:"ai",timestamp:new Date}])},[e,t]),E.useEffect(()=>{const B=R.current;if(!B)return;const G=60;B.style.height="auto";const rt=Math.max(B.scrollHeight,G);B.style.height=`${rt}px`},[g]),E.useEffect(()=>{if(o!=null)try{const G=i.filter(rt=>rt.brand===o).map(rt=>rt.model).filter((rt,ot,dt)=>dt.indexOf(rt)===ot);if(_(G),G.length>0){if(!G.includes(k)){const rt=G[0];P(rt),h&&h(rt)}}else P(""),h&&h("")}catch{_([]),P("")}else _([]),P("")},[o,i,h]);const ut=B=>{c(B.target.value)},y=B=>{P(B),A(!1),h&&h(B)},W=()=>!o||!k?null:i.find(G=>G.brand===o&&G.model===k)?.proxyUrl||null,nt=async()=>{if(!g.trim()||p)return;const B=g.trim(),G={id:Date.now().toString(),content:B,sender:"user",timestamp:new Date};u(ot=>[...ot,G]),c(""),M(!0);const rt={id:`loading-${Date.now()}`,content:t===Mt?"Analyzing data...":"分析数据中...",sender:"ai",timestamp:new Date,isLoading:!0};u(ot=>[...ot,rt]);try{if(!o||!k)throw new Error(t===Mt?"Please select an AI brand and model.":"请选择AI品牌和模型。");if(!i.find(At=>At.brand===o&&At.model===k))throw new Error(t===Mt?`No configuration found for ${it()}.`:`未找到${it()}的配置。`);const dt=W();if(!dt)throw new Error(t===Mt?`Proxy URL not configured for ${it()}. Please add configuration.`:`未配置${it()}的代理URL。请添加配置。`);const pt=tt();let bt,mt;switch(o){case St.Aliyun:mt="aliyun";break;case St.OpenAI:mt="openai";break;case St.DeepSeek:mt="deepseek";break;case St.Claude:mt="claude";break;case St.Gemini:mt="gemini";break;default:throw new Error(t===Mt?`Unsupported AI brand: ${o}`:`不支持的AI品牌:${o}`)}bt=await rl(t,dt,mt,k,pt,B),u(At=>{const Et=At.filter(yt=>yt.id!==rt.id),Rt={id:(Date.now()+1).toString(),content:bt,sender:"ai",timestamp:new Date};return[...Et,Rt]})}catch(ot){u(dt=>{const pt=dt.filter(mt=>mt.id!==rt.id),bt={id:(Date.now()+2).toString(),content:t===Mt?`Sorry, there was an error: ${ot.message}`:`抱歉,出现错误:${ot.message}`,sender:"ai",timestamp:new Date};return[...pt,bt]})}finally{M(!1),setTimeout(()=>{R.current?.focus()},100)}},ct=B=>{B.key==="Enter"&&!B.shiftKey&&(B.preventDefault(),nt())},it=()=>o&&{[St.OpenAI]:"OpenAI",[St.Aliyun]:t.ai.aliyun,[St.DeepSeek]:"DeepSeek",[St.Claude]:"Claude",[St.Gemini]:"Gemini"}[o]||"";return m.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",width:"100%",background:f.layout.background.color,border:`1px solid ${f.toolbar.border}30`,borderRadius:"8px",overflow:"hidden"},children:[m.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 16px",background:f.toolbar.background,borderBottom:`1px solid ${f.toolbar.border}30`,flexWrap:"wrap",gap:"12px"},children:[m.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[m.jsx("div",{style:{width:"8px",height:"8px",borderRadius:"50%",background:f.chart.candleUpColor}}),m.jsx("span",{style:{color:f.layout.textColor,fontSize:"14px",fontWeight:"600"},children:it()})]}),o!=null&&S.length>0&&m.jsxs("div",{ref:U,style:{position:"relative",flex:1,minWidth:"150px",maxWidth:"250px"},children:[m.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"6px 12px",borderRadius:"6px",border:`1px solid ${f.toolbar.border}50`,background:f.layout.background.color,color:f.layout.textColor,fontSize:"13px",cursor:"pointer",transition:"all 0.2s",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},onClick:()=>A(!C),onMouseEnter:B=>{B.currentTarget.style.borderColor=f.toolbar.button.dropdown.borderActive},onMouseLeave:B=>{C||(B.currentTarget.style.borderColor=f.toolbar.border+"50")},children:[m.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:k||(t===Mt?"Select Model":"选择模型")}),m.jsx("svg",{style:{width:"16px",height:"16px",marginLeft:"8px",flexShrink:0,transform:C?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.2s"},viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:m.jsx("polyline",{points:"6 9 12 15 18 9"})})]}),C&&m.jsx("div",{style:{position:"absolute",top:"100%",left:0,right:0,marginTop:"4px",borderRadius:"6px",border:`1px solid ${f.toolbar.border}50`,background:f.layout.background.color,boxShadow:"0 4px 12px rgba(0, 0, 0, 0.1)",zIndex:1e3,maxHeight:"200px",overflowY:"auto",overflowX:"hidden"},className:"model-dropdown",children:S.map((B,G)=>m.jsx("div",{style:{padding:"8px 12px",fontSize:"13px",color:f.layout.textColor,cursor:"pointer",transition:"background-color 0.2s",backgroundColor:B===k?f.toolbar.button.dropdown.selected:"transparent",borderBottom:G<S.length-1?`1px solid ${f.toolbar.border}20`:"none",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},onClick:()=>y(B),onMouseEnter:rt=>{rt.currentTarget.style.backgroundColor=B===k?f.toolbar.button.dropdown.selected:f.toolbar.button.dropdown.hover},onMouseLeave:rt=>{rt.currentTarget.style.backgroundColor=B===k?f.toolbar.button.dropdown.selected:"transparent"},children:B},G))})]}),m.jsx("button",{onClick:r,style:{width:"28px",height:"28px",borderRadius:"4px",border:"none",background:"transparent",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",color:f.toolbar.button.color,transition:"background-color 0.2s"},onMouseEnter:B=>{B.currentTarget.style.backgroundColor=f.toolbar.button.hover},onMouseLeave:B=>{B.currentTarget.style.backgroundColor="transparent"},children:m.jsx(Ui,{size:18})})]}),o!==void 0&&m.jsxs("div",{style:{padding:"4px 16px",background:f.toolbar.background+"80",borderBottom:`1px solid ${f.toolbar.border}20`,fontSize:"12px",color:f.layout.textColor,opacity:.8,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[m.jsx("span",{children:it()}),m.jsxs("span",{style:{fontSize:"11px",opacity:.6},children:[t===Mt?"Selected Model":"已选模型",": ",k]})]}),m.jsx("div",{ref:x,style:{flex:1,overflow:"auto",padding:"16px",display:"flex",flexDirection:"column",gap:"12px"},className:"modal-scrollbar",children:d.length===0?m.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%",color:f.toolbar.button.color,opacity:.7,textAlign:"center",padding:"20px"},children:[m.jsx("div",{style:{width:"48px",height:"48px",marginBottom:"16px",opacity:.5},children:m.jsx("div",{style:{width:"100%",height:"100%",borderRadius:"50%",background:f.toolbar.button.active,display:"flex",alignItems:"center",justifyContent:"center",color:f.layout.background.color,fontSize:"24px"},children:"AI"})}),m.jsx("div",{style:{fontSize:"14px",marginBottom:"4px"},children:t===Mt?"Select an AI function to start":"选择AI功能开始对话"}),m.jsx("div",{style:{fontSize:"12px",opacity:.6},children:t===Mt?"Choose from the left panel":"从左侧面板选择"})]}):m.jsxs(m.Fragment,{children:[d.map(B=>m.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:B.sender==="user"?"flex-end":"flex-start"},children:[m.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"8px",maxWidth:"85%",flexDirection:B.sender==="user"?"row-reverse":"row"},children:[m.jsx("div",{style:{width:"28px",height:"28px",borderRadius:"50%",background:B.sender==="user"?f.chart.candleUpColor:o?"transparent":f.toolbar.button.active,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,color:f.layout.background.color,fontSize:"12px",fontWeight:"bold",overflow:"hidden"},children:B.sender==="user"?"U":o?m.jsx("img",{src:tl[o],alt:it(),style:{width:"100%",height:"100%",objectFit:"cover",borderRadius:"50%"}}):"AI"}),m.jsxs("div",{style:{padding:"10px 14px",borderRadius:"12px",background:B.sender==="user"?f.chart.candleUpColor+"20":f.toolbar.background,border:`1px solid ${B.sender==="user"?f.chart.candleUpColor+"30":f.toolbar.border+"30"}`,color:f.layout.textColor,fontSize:"14px",lineHeight:"1.5",whiteSpace:"pre-wrap",wordBreak:"break-word",animation:B.isLoading?"pulse 1.5s infinite":"none"},children:[B.content,B.isLoading&&m.jsxs("span",{style:{display:"inline-block",marginLeft:"4px"},children:[m.jsx("span",{style:{animationDelay:"0s"},children:"."}),m.jsx("span",{style:{animationDelay:"0.2s"},children:"."}),m.jsx("span",{style:{animationDelay:"0.4s"},children:"."})]})]})]}),m.jsx("div",{style:{fontSize:"11px",color:f.toolbar.button.color,opacity:.6,marginTop:"4px",marginLeft:B.sender==="user"?"0":"36px",marginRight:B.sender==="user"?"36px":"0"},children:B.timestamp.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})})]},B.id)),m.jsx("div",{})]})}),m.jsxs("div",{style:{padding:"16px",borderTop:`1px solid ${f.toolbar.border}30`,background:f.layout.background.color},children:[m.jsxs("div",{style:{position:"relative"},children:[m.jsx("textarea",{ref:R,value:g,onChange:ut,onKeyDown:ct,placeholder:t===Mt?"Ask about analysis... (Shift+Enter for new line)":"输入关于V分析的问题... (Shift+Enter换行)",disabled:p,style:{width:"100%",height:"60px",minHeight:"60px",maxHeight:"200px",padding:"12px 48px 12px 12px",borderRadius:"8px",border:`1px solid ${f.toolbar.border}50`,background:f.toolbar.background,color:f.layout.textColor,fontSize:"14px",lineHeight:"1.5",resize:"none",fontFamily:"inherit",outline:"none",transition:"border-color 0.2s, height 0.2s",boxSizing:"border-box",overflowY:"auto"},onFocus:B=>{B.target.style.borderColor=f.toolbar.button.inputFocus},onBlur:B=>{B.target.style.borderColor=f.toolbar.border+"50"}}),m.jsx("button",{onClick:nt,disabled:!g.trim()||p,style:{position:"absolute",right:"12px",bottom:"12px",width:"32px",height:"32px",borderRadius:"6px",border:"none",background:g.trim()&&!p?f.toolbar.button.sendButton.normal:f.toolbar.button.sendButton.disabled,display:"flex",alignItems:"center",justifyContent:"center",cursor:g.trim()&&!p?"pointer":"not-allowed",opacity:g.trim()&&!p?1:.5,transition:"all 0.2s"},onMouseEnter:B=>{g.trim()&&!p&&(B.currentTarget.style.background=f.toolbar.button.sendButton.hover,B.currentTarget.style.transform="translateY(-1px)")},onMouseLeave:B=>{g.trim()&&!p&&(B.currentTarget.style.background=f.toolbar.button.sendButton.normal,B.currentTarget.style.transform="translateY(0)")},children:m.jsx(Rn,{size:18,color:g.trim()&&!p?f.layout.background.color:f.toolbar.button.color})})]}),m.jsxs("div",{style:{fontSize:"11px",color:f.toolbar.button.color,opacity:.6,marginTop:"8px",textAlign:"center"},children:[o?t===Mt?`Powered by ${Ti[o]}`:`由 ${Ti[o]} 提供支持`:null,k&&` - ${k}`]})]}),m.jsx("style",{children:`
|
|
151
151
|
.model-dropdown::-webkit-scrollbar { width: 8px; }
|
|
152
152
|
.model-dropdown::-webkit-scrollbar-track { background: ${f.toolbar.background}; border-radius: 4px; margin: 4px 0; }
|
|
153
153
|
.model-dropdown::-webkit-scrollbar-thumb {
|
package/dist/index.mjs
CHANGED
|
@@ -39568,6 +39568,8 @@ class Qn {
|
|
|
39568
39568
|
};
|
|
39569
39569
|
}
|
|
39570
39570
|
addMark(t, e) {
|
|
39571
|
+
if (!e || !e.series)
|
|
39572
|
+
return;
|
|
39571
39573
|
this._chartSeries = e;
|
|
39572
39574
|
const i = e.series.data();
|
|
39573
39575
|
if (!i || i.length === 0)
|
|
@@ -46271,7 +46273,7 @@ function Ce(f, t, e, i) {
|
|
|
46271
46273
|
};
|
|
46272
46274
|
}
|
|
46273
46275
|
class be {
|
|
46274
|
-
// The raw data undergoes time zone conversion, time frame data aggregation, and virtual data expansion processing.
|
|
46276
|
+
// The raw data undergoes time zone conversion, time frame data aggregation, and virtual data expansion processing.
|
|
46275
46277
|
// This data is generally used for charts other than the main chart.
|
|
46276
46278
|
static handleData(t, e, i) {
|
|
46277
46279
|
if (!t || t.length === 0)
|
|
@@ -46382,7 +46384,7 @@ class be {
|
|
|
46382
46384
|
value: Number(r.close),
|
|
46383
46385
|
...a && { color: "transparent" }
|
|
46384
46386
|
};
|
|
46385
|
-
}),
|
|
46387
|
+
}), i;
|
|
46386
46388
|
} catch {
|
|
46387
46389
|
return [];
|
|
46388
46390
|
}
|