@qfo/qfchart 0.7.3 → 0.8.1

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.
Files changed (59) hide show
  1. package/dist/index.d.ts +368 -14
  2. package/dist/qfchart.min.browser.js +34 -16
  3. package/dist/qfchart.min.es.js +34 -16
  4. package/package.json +1 -1
  5. package/src/QFChart.ts +460 -311
  6. package/src/components/AbstractPlugin.ts +234 -104
  7. package/src/components/DrawingEditor.ts +297 -248
  8. package/src/components/DrawingRendererRegistry.ts +13 -0
  9. package/src/components/GraphicBuilder.ts +284 -263
  10. package/src/components/LayoutManager.ts +72 -55
  11. package/src/components/SeriesBuilder.ts +110 -6
  12. package/src/components/TableCanvasRenderer.ts +467 -0
  13. package/src/components/TableOverlayRenderer.ts +38 -9
  14. package/src/components/TooltipFormatter.ts +97 -97
  15. package/src/components/renderers/BackgroundRenderer.ts +59 -47
  16. package/src/components/renderers/BoxRenderer.ts +113 -17
  17. package/src/components/renderers/FillRenderer.ts +118 -3
  18. package/src/components/renderers/LabelRenderer.ts +35 -9
  19. package/src/components/renderers/OHLCBarRenderer.ts +171 -161
  20. package/src/components/renderers/PolylineRenderer.ts +26 -19
  21. package/src/index.ts +17 -6
  22. package/src/plugins/ABCDPatternTool/ABCDPatternDrawingRenderer.ts +112 -0
  23. package/src/plugins/ABCDPatternTool/ABCDPatternTool.ts +136 -0
  24. package/src/plugins/ABCDPatternTool/index.ts +2 -0
  25. package/src/plugins/CypherPatternTool/CypherPatternDrawingRenderer.ts +80 -0
  26. package/src/plugins/CypherPatternTool/CypherPatternTool.ts +84 -0
  27. package/src/plugins/CypherPatternTool/index.ts +2 -0
  28. package/src/plugins/FibSpeedResistanceFanTool/FibSpeedResistanceFanDrawingRenderer.ts +163 -0
  29. package/src/plugins/FibSpeedResistanceFanTool/FibSpeedResistanceFanTool.ts +210 -0
  30. package/src/plugins/FibSpeedResistanceFanTool/index.ts +2 -0
  31. package/src/plugins/FibTrendExtensionTool/FibTrendExtensionDrawingRenderer.ts +141 -0
  32. package/src/plugins/FibTrendExtensionTool/FibTrendExtensionTool.ts +188 -0
  33. package/src/plugins/FibTrendExtensionTool/index.ts +2 -0
  34. package/src/plugins/FibonacciChannelTool/FibonacciChannelDrawingRenderer.ts +128 -0
  35. package/src/plugins/FibonacciChannelTool/FibonacciChannelTool.ts +231 -0
  36. package/src/plugins/FibonacciChannelTool/index.ts +2 -0
  37. package/src/plugins/FibonacciTool/FibonacciDrawingRenderer.ts +107 -0
  38. package/src/plugins/{FibonacciTool.ts → FibonacciTool/FibonacciTool.ts} +195 -192
  39. package/src/plugins/FibonacciTool/index.ts +2 -0
  40. package/src/plugins/HeadAndShouldersTool/HeadAndShouldersDrawingRenderer.ts +95 -0
  41. package/src/plugins/HeadAndShouldersTool/HeadAndShouldersTool.ts +97 -0
  42. package/src/plugins/HeadAndShouldersTool/index.ts +2 -0
  43. package/src/plugins/LineTool/LineDrawingRenderer.ts +49 -0
  44. package/src/plugins/{LineTool.ts → LineTool/LineTool.ts} +161 -190
  45. package/src/plugins/LineTool/index.ts +2 -0
  46. package/src/plugins/{MeasureTool.ts → MeasureTool/MeasureTool.ts} +324 -344
  47. package/src/plugins/MeasureTool/index.ts +1 -0
  48. package/src/plugins/ThreeDrivesPatternTool/ThreeDrivesPatternDrawingRenderer.ts +106 -0
  49. package/src/plugins/ThreeDrivesPatternTool/ThreeDrivesPatternTool.ts +98 -0
  50. package/src/plugins/ThreeDrivesPatternTool/index.ts +2 -0
  51. package/src/plugins/ToolGroup.ts +211 -0
  52. package/src/plugins/TrianglePatternTool/TrianglePatternDrawingRenderer.ts +107 -0
  53. package/src/plugins/TrianglePatternTool/TrianglePatternTool.ts +98 -0
  54. package/src/plugins/TrianglePatternTool/index.ts +2 -0
  55. package/src/plugins/XABCDPatternTool/XABCDPatternDrawingRenderer.ts +178 -0
  56. package/src/plugins/XABCDPatternTool/XABCDPatternTool.ts +213 -0
  57. package/src/plugins/XABCDPatternTool/index.ts +2 -0
  58. package/src/types.ts +39 -4
  59. package/src/utils/ColorUtils.ts +1 -1
@@ -14,25 +14,43 @@
14
14
  * See the License for the specific language governing permissions and
15
15
  * limitations under the License.
16
16
  */
17
- import*as B from"echarts";var _t=Object.defineProperty,kt=(x,t,e)=>t in x?_t(x,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):x[t]=e,lt=(x,t,e)=>(kt(x,typeof t!="symbol"?t+"":t,e),e);class Pt{constructor(t,e,i,s={}){lt(this,"id"),lt(this,"plots"),lt(this,"paneIndex"),lt(this,"height"),lt(this,"collapsed"),lt(this,"titleColor"),lt(this,"controls"),this.id=t,this.plots=e,this.paneIndex=i,this.height=s.height,this.collapsed=s.collapsed||!1,this.titleColor=s.titleColor,this.controls=s.controls}toggleCollapse(){this.collapsed=!this.collapsed}isVisible(){return!this.collapsed}updateData(t){Object.keys(t).forEach(e=>{if(!this.plots[e])this.plots[e]=t[e];else{const i=this.plots[e],s=t[e];if(!i.data)return;s.options&&(i.options={...i.options,...s.options});const a=new Map;i.data?.forEach(o=>{a.set(o.time,o)}),s.data?.forEach(o=>{a.set(o.time,o)}),i.data=Array.from(a.values()).sort((o,u)=>o.time-u.time)}})}}class Z{static createMinFunction(t){return e=>{const i=(e.max-e.min)*(t/100);return e.min-i}}static createMaxFunction(t){return e=>{const i=(e.max-e.min)*(t/100);return e.max+i}}static autoDetectDecimals(t){if(!t||t.length===0)return 2;const e=t[t.length-1].close;if(e===0||!isFinite(e)||isNaN(e))return 2;const i=Math.abs(e);if(i>=1)return 2;const s=Math.ceil(-Math.log10(i));return Math.min(s+4,10)}static formatValue(t,e){return typeof t=="number"?t.toFixed(e):String(t)}}class It{static calculate(t,e,i,s=!1,a=null,o,u){let d=0;t>0&&(d=1/t*100);const p=i.yAxisPadding!==void 0?i.yAxisPadding:5,g=Array.from(e.values()).map(S=>S.paneIndex).filter(S=>S>0).sort((S,$)=>S-$).filter((S,$,N)=>N.indexOf(S)===$),r=g.length>0,l=i.dataZoom?.visible??!0,h=i.dataZoom?.position??"top",n=i.dataZoom?.height??6,c=i.dataZoom?.start??0,f=i.dataZoom?.end??100;let m=8,w=92,C=-1;if(a)if(a==="main")C=0;else{const S=e.get(a);S&&(C=S.paneIndex)}if(C!==-1){const S=[],$=[],N=[],G=[],q=i.dataZoom?.start??50,E=i.dataZoom?.end??100;(i.dataZoom?.zoomOnTouch??!0)&&G.push({type:"inside",xAxisIndex:"all",start:q,end:E,filterMode:"weakFilter"});const T=r?Math.max(...g):0,R=[];for(let O=0;O<=T;O++){const Y=O===C;S.push({left:"10%",right:"10%",top:Y?"5%":"0%",height:Y?"90%":"0%",show:Y,containLabel:!1}),$.push({type:"category",gridIndex:O,data:[],show:Y,axisLabel:{show:Y,color:"#94a3b8",fontFamily:i.fontFamily},axisLine:{show:Y,lineStyle:{color:"#334155"}},splitLine:{show:Y,lineStyle:{color:"#334155",opacity:.5}}});let st,ot;if(O===0&&C===0?(st=i.yAxisMin!==void 0&&i.yAxisMin!=="auto"?i.yAxisMin:Z.createMinFunction(p),ot=i.yAxisMax!==void 0&&i.yAxisMax!=="auto"?i.yAxisMax:Z.createMaxFunction(p)):(st=Z.createMinFunction(p),ot=Z.createMaxFunction(p)),N.push({position:"right",gridIndex:O,show:Y,scale:!0,min:st,max:ot,axisLabel:{show:Y,color:"#94a3b8",fontFamily:i.fontFamily,formatter:J=>{if(i.yAxisLabelFormatter)return i.yAxisLabelFormatter(J);const at=i.yAxisDecimalPlaces!==void 0?i.yAxisDecimalPlaces:Z.autoDetectDecimals(o);return Z.formatValue(J,at)}},splitLine:{show:Y,lineStyle:{color:"#334155",opacity:.5}}}),O>0){const J=Array.from(e.values()).find(at=>at.paneIndex===O);J&&R.push({index:O,height:Y?90:0,top:Y?5:0,isCollapsed:!1,indicatorId:J.id,titleColor:J.titleColor,controls:J.controls})}}return{grid:S,xAxis:$,yAxis:N,dataZoom:G,paneLayout:R,mainPaneHeight:C===0?90:0,mainPaneTop:C===0?5:0,pixelToPercent:d,overlayYAxisMap:new Map,separatePaneYAxisOffset:1}}l?h==="top"?(m=n+4,w=95):(w=100-n-2,m=8):(m=5,w=95);let A=5;t>0&&(A=20/t*100);let v=75,y=[];if(r){const S=g.map(E=>{const T=Array.from(e.values()).find(R=>R.paneIndex===E);return{index:E,requestedHeight:T?.height,isCollapsed:T?.collapsed??!1,indicatorId:T?.id,titleColor:T?.titleColor,controls:T?.controls}}).map(E=>({...E,height:E.isCollapsed?3:E.requestedHeight!==void 0?E.requestedHeight:15})),$=S.reduce((E,T)=>E+T.height,0),N=S.length*A,G=$+N;v=w-m-G,u!==void 0&&u>0&&!s?v=u:s?v=3:v<20&&(v=Math.max(v,10));let q=m+v+A;y=S.map(E=>{const T={index:E.index,height:E.height,top:q,isCollapsed:E.isCollapsed,indicatorId:E.indicatorId,titleColor:E.titleColor,controls:E.controls};return q+=E.height+A,T})}else v=w-m,s&&(v=3);const b=[];if(y.length>0){b.push({yPercent:m+v+A/2,aboveId:"main",belowId:y[0].indicatorId||""});for(let S=0;S<y.length-1;S++)b.push({yPercent:y[S].top+y[S].height+A/2,aboveId:y[S].indicatorId||"",belowId:y[S+1].indicatorId||""})}const _=[];_.push({left:"10%",right:"10%",top:m+"%",height:v+"%",containLabel:!1}),y.forEach(S=>{_.push({left:"10%",right:"10%",top:S.top+"%",height:S.height+"%",containLabel:!1})});const I=[0,...y.map((S,$)=>$+1)],P=[],k=y.length===0;P.push({type:"category",data:[],gridIndex:0,scale:!0,axisLine:{onZero:!1,show:!s,lineStyle:{color:"#334155"}},splitLine:{show:!s,lineStyle:{color:"#334155",opacity:.5}},axisLabel:{show:!s,color:"#94a3b8",fontFamily:i.fontFamily||"sans-serif",formatter:S=>{if(i.yAxisLabelFormatter)return i.yAxisLabelFormatter(S);const $=i.yAxisDecimalPlaces!==void 0?i.yAxisDecimalPlaces:Z.autoDetectDecimals(o);return Z.formatValue(S,$)}},axisTick:{show:!s},axisPointer:{label:{show:k,fontSize:11,backgroundColor:"#475569"}}}),y.forEach((S,$)=>{const N=$===y.length-1;P.push({type:"category",gridIndex:$+1,data:[],axisLabel:{show:!1},axisLine:{show:!S.isCollapsed,lineStyle:{color:"#334155"}},axisTick:{show:!1},splitLine:{show:!1},axisPointer:{label:{show:N,fontSize:11,backgroundColor:"#475569"}}})});const D=[];let M,L;i.yAxisMin!==void 0&&i.yAxisMin!=="auto"?M=i.yAxisMin:M=Z.createMinFunction(p),i.yAxisMax!==void 0&&i.yAxisMax!=="auto"?L=i.yAxisMax:L=Z.createMaxFunction(p),D.push({position:"right",scale:!0,min:M,max:L,gridIndex:0,splitLine:{show:!s,lineStyle:{color:"#334155",opacity:.5}},axisLine:{show:!s,lineStyle:{color:"#334155"}},axisLabel:{show:!s,color:"#94a3b8",fontFamily:i.fontFamily||"sans-serif",formatter:S=>{if(i.yAxisLabelFormatter)return i.yAxisLabelFormatter(S);const $=i.yAxisDecimalPlaces!==void 0?i.yAxisDecimalPlaces:Z.autoDetectDecimals(o);return Z.formatValue(S,$)}}});let F=1,U=-1/0,tt=1/0;o&&o.length>0&&(U=Math.min(...o.map(S=>S.low)),tt=Math.max(...o.map(S=>S.high)));const H=new Map;e.forEach((S,$)=>{S.paneIndex===0&&!S.collapsed&&o&&o.length>0&&Object.entries(S.plots).forEach(([N,G])=>{const q=`${$}::${N}`,E=["background","barcolor","char"],T=G.options.style==="shape"&&(G.options.location==="abovebar"||G.options.location==="AboveBar"||G.options.location==="belowbar"||G.options.location==="BelowBar");if(E.includes(G.options.style)){H.has(q)||(H.set(q,F),F++);return}if(G.options.style==="shape"&&!T){H.has(q)||(H.set(q,F),F++);return}const R=[];if(G.data&&Object.values(G.data).forEach(O=>{typeof O=="number"&&!isNaN(O)&&isFinite(O)&&R.push(O)}),R.length>0){const O=Math.min(...R),Y=Math.max(...R),st=Y-O,ot=tt-U,J=O>=U*.5&&Y<=tt*1.5,at=st>ot*.01;J&&at||H.has(q)||(H.set(q,F),F++)}})});const et=H.size>0?F-1:0,nt=new Set;H.forEach((S,$)=>{e.forEach(N=>{Object.entries(N.plots).forEach(([G,q])=>{`${N.id}::${G}`===$&&["background","barcolor","char"].includes(q.options.style)&&nt.add(S)})})});for(let S=0;S<et;S++){const $=S+1,N=nt.has($);D.push({position:"left",scale:!N,min:N?0:Z.createMinFunction(p),max:N?1:Z.createMaxFunction(p),gridIndex:0,show:!1,splitLine:{show:!1},axisLine:{show:!1},axisLabel:{show:!1}})}const it=F;y.forEach((S,$)=>{D.push({position:"right",scale:!0,min:Z.createMinFunction(p),max:Z.createMaxFunction(p),gridIndex:$+1,splitLine:{show:!S.isCollapsed,lineStyle:{color:"#334155",opacity:.3}},axisLabel:{show:!S.isCollapsed,color:"#94a3b8",fontFamily:i.fontFamily||"sans-serif",fontSize:10,formatter:N=>{if(i.yAxisLabelFormatter)return i.yAxisLabelFormatter(N);const G=i.yAxisDecimalPlaces!==void 0?i.yAxisDecimalPlaces:Z.autoDetectDecimals(o);return Z.formatValue(N,G)}},axisLine:{show:!S.isCollapsed,lineStyle:{color:"#334155"}}})});const W=[];return l&&((i.dataZoom?.zoomOnTouch??!0)&&W.push({type:"inside",xAxisIndex:I,start:c,end:f,filterMode:"weakFilter"}),h==="top"?W.push({type:"slider",xAxisIndex:I,top:"1%",height:n+"%",start:c,end:f,borderColor:"#334155",textStyle:{color:"#cbd5e1"},brushSelect:!1,filterMode:"weakFilter"}):W.push({type:"slider",xAxisIndex:I,bottom:"1%",height:n+"%",start:c,end:f,borderColor:"#334155",textStyle:{color:"#cbd5e1"},brushSelect:!1,filterMode:"weakFilter"})),{grid:_,xAxis:P,yAxis:D,dataZoom:W,paneLayout:y,mainPaneHeight:v,mainPaneTop:m,pixelToPercent:d,paneBoundaries:b,overlayYAxisMap:H,separatePaneYAxisOffset:it}}static calculateMaximized(t,e,i){return{grid:[],xAxis:[],yAxis:[],dataZoom:[],paneLayout:[],mainPaneHeight:0,mainPaneTop:0,pixelToPercent:0,paneBoundaries:[]}}}class Dt{render(t){const{seriesName:e,xAxisIndex:i,yAxisIndex:s,dataArray:a,colorArray:o,plotOptions:u}=t,d="#2962ff";return{name:e,type:"custom",xAxisIndex:i,yAxisIndex:s,renderItem:(p,g)=>{const r=p.dataIndex;if(r===0)return;const l=g.value(1),h=g.value(2);if(l===null||isNaN(l)||h===null||isNaN(h))return;const n=g.coord([r-1,h]),c=g.coord([r,l]);return{type:"line",shape:{x1:n[0],y1:n[1],x2:c[0],y2:c[1]},style:{stroke:o[r]||u.color||d,lineWidth:u.linewidth||1},silent:!0}},data:a.map((p,g)=>[g,p,g>0?a[g-1]:null])}}}class Mt{render(t){const{seriesName:e,xAxisIndex:i,yAxisIndex:s,dataArray:a,colorArray:o,plotOptions:u}=t,d="#2962ff";return{name:e,type:"custom",xAxisIndex:i,yAxisIndex:s,renderItem:(p,g)=>{const r=g.value(0),l=g.value(1);if(isNaN(l)||l===null)return;const h=g.coord([r,l]),n=g.size([1,0])[0];return{type:"line",shape:{x1:h[0]-n/2,y1:h[1],x2:h[0]+n/2,y2:h[1]},style:{stroke:o[p.dataIndex]||u.color||d,lineWidth:u.linewidth||1},silent:!0}},data:a.map((p,g)=>[g,p])}}}class Ct{render(t){const{seriesName:e,xAxisIndex:i,yAxisIndex:s,dataArray:a,colorArray:o,plotOptions:u}=t,d="#2962ff",p=u.histbase??0,g=u.style==="columns",r=u.linewidth??1,l=a.map((h,n)=>h==null||typeof h=="number"&&isNaN(h)?null:[n,h,o[n]||u.color||d]);return{name:e,type:"custom",xAxisIndex:i,yAxisIndex:s,renderItem:(h,n)=>{const c=n.value(0),f=n.value(1),m=n.value(2);if(f==null||isNaN(f))return null;const w=n.coord([c,p]),C=n.coord([c,f]),A=n.size([1,0])[0];let v;g?v=A*.6:v=Math.max(1,r);const y=w[0],b=w[1],_=C[1],I=Math.min(b,_),P=Math.abs(_-b);return{type:"rect",shape:{x:y-v/2,y:I,width:v,height:P||1},style:{fill:m}}},data:l.filter(h=>h!==null)}}}const mt=new Map;function zt(x,t="#00da3c",e="64px"){if(typeof document>"u")return"";const i=`${x}-${t}-${e}`;if(mt.has(i))return mt.get(i);const s=document.createElement("canvas"),a=s.getContext("2d");if(s.width=32,s.height=32,a){a.font="bold "+e+" Arial",a.fillStyle=t,a.textAlign="center",a.textBaseline="middle",a.fillText(x,16,16);const o=s.toDataURL("image/png");return mt.set(i,o),o}return""}class bt{render(t){const{seriesName:e,xAxisIndex:i,yAxisIndex:s,dataArray:a,colorArray:o,plotOptions:u}=t,d="#2962ff",p=u.style;if(p==="char")return{name:e,type:"scatter",xAxisIndex:i,yAxisIndex:s,symbolSize:0,data:a.map((r,l)=>({value:[l,r],itemStyle:{opacity:0}})),silent:!0};const g=a.map((r,l)=>{if(r===null)return null;const h=o[l]||u.color||d,n={value:[l,r],itemStyle:{color:h}};return p==="cross"?(n.symbol=`image://${zt("+",h,"24px")}`,n.symbolSize=16):(n.symbol="circle",n.symbolSize=6),n}).filter(r=>r!==null);return{name:e,type:"scatter",xAxisIndex:i,yAxisIndex:s,data:g}}}class At{render(t){const{seriesName:e,xAxisIndex:i,yAxisIndex:s,dataArray:a,colorArray:o,optionsArray:u,plotOptions:d}=t,p="#2962ff",g=d.style==="candle",r=a.map((l,h)=>{if(l===null||!Array.isArray(l)||l.length!==4)return null;const[n,c,f,m]=l,w=u[h]||{},C=w.color||o[h]||d.color||p,A=w.wickcolor||d.wickcolor||C,v=w.bordercolor||d.bordercolor||A;return[h,n,m,f,c,C,A,v]}).filter(l=>l!==null);return{name:e,type:"custom",xAxisIndex:i,yAxisIndex:s,renderItem:(l,h)=>{const n=h.value(0),c=h.value(1),f=h.value(2),m=h.value(3),w=h.value(4),C=h.value(5),A=h.value(6),v=h.value(7);if(isNaN(c)||isNaN(f)||isNaN(m)||isNaN(w))return null;const y=h.coord([n,0])[0],b=h.coord([n,c])[1],_=h.coord([n,f])[1],I=h.coord([n,m])[1],P=h.coord([n,w])[1],k=h.size([1,0])[0]*.6;if(g){const D=Math.min(b,_),M=Math.max(b,_),L=Math.abs(_-b);return{type:"group",children:[{type:"line",shape:{x1:y,y1:P,x2:y,y2:D},style:{stroke:A,lineWidth:1}},{type:"line",shape:{x1:y,y1:M,x2:y,y2:I},style:{stroke:A,lineWidth:1}},{type:"rect",shape:{x:y-k/2,y:D,width:k,height:L||1},style:{fill:C,stroke:v,lineWidth:1}}]}}else{const D=k*.5;return{type:"group",children:[{type:"line",shape:{x1:y,y1:I,x2:y,y2:P},style:{stroke:C,lineWidth:1}},{type:"line",shape:{x1:y-D,y1:b,x2:y,y2:b},style:{stroke:C,lineWidth:1}},{type:"line",shape:{x1:y,y1:_,x2:y+D,y2:_},style:{stroke:C,lineWidth:1}}]}}},data:r}}}class ct{static getShapeSymbol(t){switch(t){case"arrowdown":case"shape_arrow_down":return"path://M12 24l-12-12h8v-12h8v12h8z";case"arrowup":case"shape_arrow_up":return"path://M12 0l12 12h-8v12h-8v-12h-8z";case"circle":case"shape_circle":return"circle";case"cross":case"shape_cross":return"path://M11 2h2v9h9v2h-9v9h-2v-9h-9v-2h9z";case"diamond":case"shape_diamond":return"diamond";case"flag":case"shape_flag":return"path://M6 2v20h2v-8h12l-2-6 2-6h-12z";case"labeldown":case"shape_label_down":return"path://M2 1h20a1 1 0 0 1 1 1v14a1 1 0 0 1-1 1h-8l-2 3-2-3h-8a1 1 0 0 1-1-1v-14a1 1 0 0 1 1-1z";case"labelleft":case"shape_label_left":return"path://M0 10l3-3v-5a1 1 0 0 1 1-1h18a1 1 0 0 1 1 1v16a1 1 0 0 1-1 1h-18a1 1 0 0 1-1-1v-5z";case"labelright":case"shape_label_right":return"path://M24 10l-3-3v-5a1 1 0 0 0-1-1h-18a1 1 0 0 0-1 1v16a1 1 0 0 0 1 1h18a1 1 0 0 0 1-1v-5z";case"labelup":case"shape_label_up":return"path://M12 1l2 3h8a1 1 0 0 1 1 1v14a1 1 0 0 1-1 1h-20a1 1 0 0 1-1-1v-14a1 1 0 0 1 1-1h8z";case"square":case"shape_square":return"rect";case"triangledown":case"shape_triangle_down":return"path://M12 21l-10-18h20z";case"triangleup":case"shape_triangle_up":return"triangle";case"xcross":case"shape_xcross":return"path://M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z";default:return"circle"}}static getShapeRotation(t){return 0}static getShapeSize(t,e,i){if(e!==void 0&&i!==void 0)return[e,i];let s;switch(t){case"tiny":s=8;break;case"small":s=12;break;case"normal":case"auto":s=16;break;case"large":s=24;break;case"huge":s=32;break;default:s=16}return e!==void 0?[e,e]:i!==void 0?[i,i]:s}static getLabelConfig(t,e){switch(e){case"abovebar":case"AboveBar":return{position:"top",distance:5};case"belowbar":case"BelowBar":return{position:"bottom",distance:5};case"top":case"Top":return{position:"bottom",distance:5};case"bottom":case"Bottom":return{position:"top",distance:5};case"absolute":case"Absolute":default:return t==="labelup"||t==="labeldown"||t==="shape_label_up"||t==="shape_label_down"?{position:"inside",distance:0}:{position:"top",distance:5}}}}class $t{render(t){const{seriesName:e,xAxisIndex:i,yAxisIndex:s,dataArray:a,colorArray:o,optionsArray:u,plotOptions:d,candlestickData:p}=t,g="#2962ff",r=a.map((l,h)=>{const n=u[h]||{},c=d,f=n.location||c.location||"absolute";if(f!=="absolute"&&f!=="Absolute"&&!l||l==null)return null;const m=n.color||c.color||g,w=n.shape||c.shape||"circle",C=n.size||c.size||"normal",A=n.text||c.text,v=n.textcolor||c.textcolor||"white",y=n.width||c.width,b=n.height||c.height;let _=l,I=[0,0];f==="abovebar"||f==="AboveBar"||f==="ab"?(p&&p[h]&&(_=p[h].high),I=[0,"-150%"]):f==="belowbar"||f==="BelowBar"||f==="bl"?(p&&p[h]&&(_=p[h].low),I=[0,"150%"]):f==="top"||f==="Top"?(_=l,I=[0,0]):(f==="bottom"||f==="Bottom")&&(_=l,I=[0,0]);const P=ct.getShapeSymbol(w),k=ct.getShapeSize(C,y,b),D=ct.getShapeRotation(w);let M=k;w.includes("label")&&(Array.isArray(k)?M=[k[0]*2.5,k[1]*2.5]:M=k*2.5);const L=ct.getLabelConfig(w,f);return{value:[h,_],symbol:P,symbolSize:M,symbolRotate:D,symbolOffset:I,itemStyle:{color:m},label:{show:!!A,position:L.position,distance:L.distance,formatter:A,color:v,fontSize:10,fontWeight:"bold"}}}).filter(l=>l!==null);return{name:e,type:"scatter",xAxisIndex:i,yAxisIndex:s,data:r}}}class Lt{render(t){const{seriesName:e,xAxisIndex:i,yAxisIndex:s,dataArray:a,colorArray:o}=t;return{name:e,type:"custom",xAxisIndex:i,yAxisIndex:s,z:-10,renderItem:(u,d)=>{const p=d.value(0);if(isNaN(p))return;const g=d.coord([p,.5]),r=d.size([1,0])[0],l=u.coordSys,h=g[0]-r/2,n=o[u.dataIndex],c=d.value(1);if(!(!n||c===null||c===void 0||isNaN(c)))return{type:"rect",shape:{x:h,y:l.y,width:r,height:l.height},style:{fill:n,opacity:.3},silent:!0}},data:a.map((u,d)=>[d,u!=null&&!isNaN(u)?.5:null])}}}class ht{static parseColor(t){if(!t)return{color:"#888888",opacity:.2};const e=t.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?\)/);if(e){const s=e[1],a=e[2],o=e[3],u=e[4]?parseFloat(e[4]):1;return{color:`rgb(${s},${a},${o})`,opacity:u}}const i=t.match(/^#([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/);if(i){const s=parseInt(i[1],16),a=parseInt(i[2],16),o=parseInt(i[3],16),u=parseInt(i[4],16)/255;return{color:`rgb(${s},${a},${o})`,opacity:u}}return{color:t,opacity:.3}}static toRgba(t,e){const i=t.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(i)return`rgba(${i[1]},${i[2]},${i[3]},${e})`;const s=t.match(/^#([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/);if(s){const o=parseInt(s[1],16),u=parseInt(s[2],16),d=parseInt(s[3],16);return`rgba(${o},${u},${d},${e})`}const a=t.match(/^#([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/);if(a){const o=parseInt(a[1],16),u=parseInt(a[2],16),d=parseInt(a[3],16);return`rgba(${o},${u},${d},${e})`}return t}}class Et{render(t){const{seriesName:e,xAxisIndex:i,yAxisIndex:s,plotOptions:a,plotDataArrays:o,indicatorId:u,plotName:d,optionsArray:p}=t,g=t.dataArray.length,r=a.plot1?`${u}::${a.plot1}`:null,l=a.plot2?`${u}::${a.plot2}`:null;if(!r||!l)return console.warn(`Fill plot "${d}" missing plot1 or plot2 reference`),null;const h=o?.get(r),n=o?.get(l);if(!h||!n)return console.warn(`Fill plot "${d}" references non-existent plots: ${a.plot1}, ${a.plot2}`),null;if(a.gradient===!0)return this.renderGradientFill(e,i,s,h,n,g,p,a);const{color:c,opacity:f}=ht.parseColor(a.color||"rgba(128, 128, 128, 0.2)"),m=[];for(let w=0;w<g;w++){const C=h[w],A=n[w],v=w>0?h[w-1]:null,y=w>0?n[w-1]:null;m.push([w,C,A,v,y])}return{name:e,type:"custom",xAxisIndex:i,yAxisIndex:s,z:1,renderItem:(w,C)=>{const A=w.dataIndex;if(A===0)return null;const v=C.value(1),y=C.value(2),b=C.value(3),_=C.value(4);if(v===null||y===null||b===null||_===null||isNaN(v)||isNaN(y)||isNaN(b)||isNaN(_))return null;const I=C.coord([A-1,b]),P=C.coord([A,v]),k=C.coord([A,y]),D=C.coord([A-1,_]);return{type:"polygon",shape:{points:[I,P,k,D]},style:{fill:c,opacity:f},silent:!0}},data:m}}renderGradientFill(t,e,i,s,a,o,u,d){const p=[];for(let r=0;r<o;r++){const l=u?.[r];if(l&&l.top_color!==void 0){const h=ht.parseColor(l.top_color),n=ht.parseColor(l.bottom_color);p[r]={topColor:h.color,topOpacity:h.opacity,bottomColor:n.color,bottomOpacity:n.opacity}}else p[r]={topColor:"rgba(128,128,128,0.2)",topOpacity:.2,bottomColor:"rgba(128,128,128,0.2)",bottomOpacity:.2}}const g=[];for(let r=0;r<o;r++){const l=s[r],h=a[r],n=r>0?s[r-1]:null,c=r>0?a[r-1]:null;g.push([r,l,h,n,c])}return{name:t,type:"custom",xAxisIndex:e,yAxisIndex:i,z:1,renderItem:(r,l)=>{const h=r.dataIndex;if(h===0)return null;const n=l.value(1),c=l.value(2),f=l.value(3),m=l.value(4);if(n===null||c===null||f===null||m===null||isNaN(n)||isNaN(c)||isNaN(f)||isNaN(m))return null;const w=l.coord([h-1,f]),C=l.coord([h,n]),A=l.coord([h,c]),v=l.coord([h-1,m]),y=p[h]||p[h-1];if(!y)return null;const b=ht.toRgba(y.topColor,y.topOpacity),_=ht.toRgba(y.bottomColor,y.bottomOpacity),I=n>=c;return{type:"polygon",shape:{points:[w,C,A,v]},style:{fill:{type:"linear",x:0,y:0,x2:0,y2:1,colorStops:[{offset:0,color:I?b:_},{offset:1,color:I?_:b}]}},silent:!0}},data:g}}}class Nt{render(t){const{seriesName:e,xAxisIndex:i,yAxisIndex:s,dataArray:a,candlestickData:o,dataIndexOffset:u}=t,d=u||0,p=[];for(let r=0;r<a.length;r++){const l=a[r];if(!l)continue;const h=Array.isArray(l)?l:[l];for(const n of h)n&&typeof n=="object"&&!n._deleted&&p.push(n)}const g=p.map(r=>{const l=r.text||"",h=r.color||"#2962ff",n=r.textcolor||"#ffffff",c=r.yloc||"price",f=r.style||"style_label_down",m=r.size||"normal",w=r.textalign||"align_center",C=r.tooltip||"",A=this.styleToShape(f),v=r.xloc==="bar_index"||r.xloc==="bi"?r.x+d:r.x;let y=r.y,b=[0,0];c==="abovebar"||c==="AboveBar"||c==="ab"?(o&&o[v]&&(y=o[v].high),b=[0,"-150%"]):(c==="belowbar"||c==="BelowBar"||c==="bl")&&(o&&o[v]&&(y=o[v].low),b=[0,"150%"]);const _=ct.getShapeSymbol(A),I=ct.getShapeSize(m),P=this.getSizePx(m);let k;const D=A==="labeldown"||A==="shape_label_down"||A==="labelup"||A==="shape_label_up"||A==="labelleft"||A==="labelright";let M=[0,0];if(D){const tt=l.length*P*.65,H=P*2.5,et=Math.max(H,tt+P*1.6),nt=P*2.8,it=3/24;if(A==="labelleft"||A==="labelright"){const W=et/(1-it);k=[W,nt];const S=typeof b[0]=="string"?0:b[0];A==="labelleft"?(b=[S+W*.42,b[1]],M=[W*it*.5,0]):(b=[S-W*.42,b[1]],M=[-W*it*.5,0])}else{const W=nt/(1-it);k=[et,W],A==="labeldown"?(b=[b[0],typeof b[1]=="string"?b[1]:b[1]-W*.42],M=[0,-W*it*.5]):(b=[b[0],typeof b[1]=="string"?b[1]:b[1]+W*.42],M=[0,W*it*.5])}}else A==="none"?k=0:Array.isArray(I)?k=[I[0]*1.5,I[1]*1.5]:k=I*1.5;const L=this.getLabelPosition(f,c),F=L==="inside"||L.startsWith("inside"),U={value:[v,y],symbol:_,symbolSize:k,symbolOffset:b,itemStyle:{color:h},label:{show:!!l,position:L,distance:F?0:5,offset:M,formatter:l,color:n,fontSize:P,fontWeight:"bold",align:F?"center":w==="align_left"||w==="left"?"left":w==="align_right"||w==="right"?"right":"center",verticalAlign:"middle",padding:[2,6]}};return C&&(U.tooltip={formatter:C}),U}).filter(r=>r!==null);return{name:e,type:"scatter",xAxisIndex:i,yAxisIndex:s,data:g,z:20}}styleToShape(t){switch(t.startsWith("style_")?t.substring(6):t){case"label_down":return"labeldown";case"label_up":return"labelup";case"label_left":return"labelleft";case"label_right":return"labelright";case"label_lower_left":return"labeldown";case"label_lower_right":return"labeldown";case"label_upper_left":return"labelup";case"label_upper_right":return"labelup";case"label_center":return"labeldown";case"circle":return"circle";case"square":return"square";case"diamond":return"diamond";case"flag":return"flag";case"arrowup":return"arrowup";case"arrowdown":return"arrowdown";case"cross":return"cross";case"xcross":return"xcross";case"triangleup":return"triangleup";case"triangledown":return"triangledown";case"text_outline":return"none";case"none":return"none";default:return"labeldown"}}getLabelPosition(t,e){switch(t.startsWith("style_")?t.substring(6):t){case"label_down":case"label_up":case"label_left":case"label_right":case"label_lower_left":case"label_lower_right":case"label_upper_left":case"label_upper_right":case"label_center":return"inside";case"text_outline":case"none":return e==="abovebar"||e==="AboveBar"||e==="ab"?"top":e==="belowbar"||e==="BelowBar"||e==="bl"?"bottom":"top";default:return e==="belowbar"||e==="BelowBar"||e==="bl"?"bottom":"top"}}getSizePx(t){switch(t){case"tiny":return 8;case"small":return 9;case"normal":case"auto":return 10;case"large":return 12;case"huge":return 14;default:return 10}}}class Ft{render(t){const{seriesName:e,xAxisIndex:i,yAxisIndex:s,dataArray:a,dataIndexOffset:o}=t,u=o||0,d="#2962ff",p=[];for(let l=0;l<a.length;l++){const h=a[l];if(!h)continue;const n=Array.isArray(h)?h:[h];for(const c of n)c&&typeof c=="object"&&!c._deleted&&p.push(c)}if(p.length===0)return{name:e,type:"custom",xAxisIndex:i,yAxisIndex:s,data:[],silent:!0};const g=(t.candlestickData?.length||0)+u,r=Math.max(0,g-1);return{name:e,type:"custom",xAxisIndex:i,yAxisIndex:s,renderItem:(l,h)=>{const n=[];for(const c of p){if(c._deleted)continue;const f=c.xloc==="bar_index"||c.xloc==="bi"?u:0;let m=h.coord([c.x1+f,c.y1]),w=h.coord([c.x2+f,c.y2]);const C=c.extend||"none";if(C!=="none"&&C!=="n"){const b=l.coordSys;[m,w]=this.extendLine(m,w,C,b.x,b.x+b.width,b.y,b.y+b.height)}const A=c.color||d,v=c.width||1;n.push({type:"line",shape:{x1:m[0],y1:m[1],x2:w[0],y2:w[1]},style:{fill:"none",stroke:A,lineWidth:v,lineDash:this.getDashPattern(c.style)}});const y=c.style||"style_solid";if(y==="style_arrow_left"||y==="style_arrow_both"){const b=this.arrowHead(w,m,v,A);b&&n.push(b)}if(y==="style_arrow_right"||y==="style_arrow_both"){const b=this.arrowHead(m,w,v,A);b&&n.push(b)}}return{type:"group",children:n}},data:[[0,r]],clip:!0,encode:{x:[0,1]},itemStyle:{color:"transparent",borderColor:"transparent"},z:15,silent:!0,emphasis:{disabled:!0}}}getDashPattern(t){switch(t){case"style_dotted":return[2,2];case"style_dashed":return[6,4];default:return}}extendLine(t,e,i,s,a,o,u){const d=e[0]-t[0],p=e[1]-t[1];if(d===0&&p===0)return[t,e];const g=(h,n)=>{let c=1/0;if(n[0]!==0){const f=n[0]>0?(a-h[0])/n[0]:(s-h[0])/n[0];c=Math.min(c,f)}if(n[1]!==0){const f=n[1]>0?(u-h[1])/n[1]:(o-h[1])/n[1];c=Math.min(c,f)}return isFinite(c)||(c=0),[h[0]+c*n[0],h[1]+c*n[1]]};let r=t,l=e;return(i==="right"||i==="r"||i==="both"||i==="b")&&(l=g(t,[d,p])),(i==="left"||i==="l"||i==="both"||i==="b")&&(r=g(e,[-d,-p])),[r,l]}arrowHead(t,e,i,s){const a=e[0]-t[0],o=e[1]-t[1],u=Math.sqrt(a*a+o*o);if(u<1)return null;const d=Math.max(8,i*4),p=a/u,g=o/u,r=e[0]-p*d,l=e[1]-g*d,h=-g*d*.4,n=p*d*.4;return{type:"polygon",shape:{points:[[e[0],e[1]],[r+h,l+n],[r-h,l-n]]},style:{fill:s}}}}class Tt{render(t){const{seriesName:e,xAxisIndex:i,yAxisIndex:s,dataArray:a,dataIndexOffset:o}=t,u=o||0,d=[];for(let r=0;r<a.length;r++){const l=a[r];if(!l)continue;const h=Array.isArray(l)?l:[l];for(const n of h){if(!n||typeof n!="object"||n._deleted)continue;const c=n.line1,f=n.line2;!c||!f||c._deleted||f._deleted||d.push(n)}}if(d.length===0)return{name:e,type:"custom",xAxisIndex:i,yAxisIndex:s,data:[],silent:!0};const p=(t.candlestickData?.length||0)+u,g=Math.max(0,p-1);return{name:e,type:"custom",xAxisIndex:i,yAxisIndex:s,renderItem:(r,l)=>{const h=[];for(const n of d){if(n._deleted)continue;const c=n.line1,f=n.line2;if(!c||!f||c._deleted||f._deleted)continue;const m=c.xloc==="bar_index"||c.xloc==="bi"?u:0,w=f.xloc==="bar_index"||f.xloc==="bi"?u:0;let C=l.coord([c.x1+m,c.y1]),A=l.coord([c.x2+m,c.y2]),v=l.coord([f.x1+w,f.y1]),y=l.coord([f.x2+w,f.y2]);const b=c.extend||"none",_=f.extend||"none";if(b!=="none"||_!=="none"){const k=r.coordSys,D=k.x,M=k.x+k.width,L=k.y,F=k.y+k.height;b!=="none"&&([C,A]=this.extendLine(C,A,b,D,M,L,F)),_!=="none"&&([v,y]=this.extendLine(v,y,_,D,M,L,F))}const{color:I,opacity:P}=ht.parseColor(n.color||"rgba(128, 128, 128, 0.2)");h.push({type:"polygon",shape:{points:[C,A,y,v]},style:{fill:I,opacity:P},silent:!0})}return{type:"group",children:h}},data:[[0,g]],clip:!0,encode:{x:[0,1]},z:10,silent:!0,emphasis:{disabled:!0}}}extendLine(t,e,i,s,a,o,u){const d=e[0]-t[0],p=e[1]-t[1];if(d===0&&p===0)return[t,e];const g=(h,n)=>{let c=1/0;if(n[0]!==0){const f=n[0]>0?(a-h[0])/n[0]:(s-h[0])/n[0];c=Math.min(c,f)}if(n[1]!==0){const f=n[1]>0?(u-h[1])/n[1]:(o-h[1])/n[1];c=Math.min(c,f)}return isFinite(c)||(c=0),[h[0]+c*n[0],h[1]+c*n[1]]};let r=t,l=e;return(i==="right"||i==="both")&&(l=g(t,[d,p])),(i==="left"||i==="both")&&(r=g(e,[-d,-p])),[r,l]}}class Ot{render(t){const{seriesName:e,xAxisIndex:i,yAxisIndex:s,dataArray:a,dataIndexOffset:o}=t,u=o||0,d=[];for(let r=0;r<a.length;r++){const l=a[r];if(!l)continue;const h=Array.isArray(l)?l:[l];for(const n of h)n&&typeof n=="object"&&!n._deleted&&n.points&&n.points.length>=2&&d.push(n)}if(d.length===0)return{name:e,type:"custom",xAxisIndex:i,yAxisIndex:s,data:[],silent:!0};const p=(t.candlestickData?.length||0)+u,g=Math.max(0,p-1);return{name:e,type:"custom",xAxisIndex:i,yAxisIndex:s,renderItem:(r,l)=>{const h=[];for(const n of d){if(n._deleted)continue;const c=n.points;if(!c||c.length<2)continue;const f=n.xloc==="bi"||n.xloc==="bar_index",m=f?u:0,w=[];for(const y of c){const b=f?(y.index??0)+m:y.time??0,_=y.price??0;w.push(l.coord([b,_]))}if(w.length<2)continue;const C=n.line_color||"#2962ff",A=n.line_width||1,v=this.getDashPattern(n.line_style);if(n.fill_color&&n.fill_color!==""&&n.fill_color!=="na"){const{color:y,opacity:b}=ht.parseColor(n.fill_color);if(n.curved){const _=this.buildCurvedPath(w,n.closed);h.push({type:"path",shape:{pathData:_+" Z"},style:{fill:y,opacity:b,stroke:"none"},silent:!0})}else h.push({type:"polygon",shape:{points:w},style:{fill:y,opacity:b,stroke:"none"},silent:!0})}if(n.curved){const y=this.buildCurvedPath(w,n.closed);h.push({type:"path",shape:{pathData:y},style:{fill:"none",stroke:C,lineWidth:A,lineDash:v},silent:!0})}else{const y=n.closed?[...w,w[0]]:w;h.push({type:"polyline",shape:{points:y},style:{fill:"none",stroke:C,lineWidth:A,lineDash:v},silent:!0})}}return{type:"group",children:h}},data:[[0,g]],clip:!0,encode:{x:[0,1]},itemStyle:{color:"transparent",borderColor:"transparent"},z:12,silent:!0,emphasis:{disabled:!0}}}buildCurvedPath(t,e){const i=t.length;if(i<2)return"";if(i===2)return`M ${t[0][0]} ${t[0][1]} L ${t[1][0]} ${t[1][1]}`;const s=.5;let a=`M ${t[0][0]} ${t[0][1]}`;const o=d=>e?t[(d%i+i)%i]:d<0?t[0]:d>=i?t[i-1]:t[d],u=e?i:i-1;for(let d=0;d<u;d++){const p=o(d-1),g=o(d),r=o(d+1),l=o(d+2),h=g[0]+(r[0]-p[0])*s/3,n=g[1]+(r[1]-p[1])*s/3,c=r[0]-(l[0]-g[0])*s/3,f=r[1]-(l[1]-g[1])*s/3;a+=` C ${h} ${n}, ${c} ${f}, ${r[0]} ${r[1]}`}return e&&(a+=" Z"),a}getDashPattern(t){switch(t){case"style_dotted":return[2,2];case"style_dashed":return[6,4];default:return}}}function vt(x){if(!x||typeof x!="string")return x;if(x.startsWith("#")){const t=x.slice(1);if(t.length===8){const e=parseInt(t.slice(0,2),16),i=parseInt(t.slice(2,4),16),s=parseInt(t.slice(4,6),16),a=parseInt(t.slice(6,8),16)/255;return`rgba(${e},${i},${s},${a.toFixed(3)})`}}return x}class Zt{render(t){const{seriesName:e,xAxisIndex:i,yAxisIndex:s,dataArray:a,dataIndexOffset:o}=t,u=o||0,d=[];for(let r=0;r<a.length;r++){const l=a[r];if(!l)continue;const h=Array.isArray(l)?l:[l];for(const n of h)n&&typeof n=="object"&&!n._deleted&&d.push(n)}if(d.length===0)return{name:e,type:"custom",xAxisIndex:i,yAxisIndex:s,data:[],silent:!0};const p=(t.candlestickData?.length||0)+u,g=Math.max(0,p-1);return{name:e,type:"custom",xAxisIndex:i,yAxisIndex:s,renderItem:(r,l)=>{const h=[];for(const n of d){if(n._deleted)continue;const c=n.xloc==="bar_index"||n.xloc==="bi"?u:0,f=l.coord([n.left+c,n.top]),m=l.coord([n.right+c,n.bottom]);let w=f[0],C=f[1],A=m[0]-f[0],v=m[1]-f[1];const y=n.extend||"none";if(y!=="none"&&y!=="n"){const k=r.coordSys;(y==="left"||y==="l"||y==="both"||y==="b")&&(w=k.x,A=y==="both"||y==="b"?k.width:m[0]-k.x),(y==="right"||y==="r"||y==="both"||y==="b")&&(y==="right"||y==="r")&&(A=k.x+k.width-f[0])}const b=vt(n.bgcolor)||"#2962ff";h.push({type:"rect",shape:{x:w,y:C,width:A,height:v},style:{fill:b,stroke:"none"}});const _=n.border_color,I=_==null||typeof _=="number"&&isNaN(_)||_==="na"||_==="NaN"?null:vt(_)||"#2962ff",P=n.border_width??1;if(P>0&&I&&h.push({type:"rect",shape:{x:w,y:C,width:A,height:v},style:{fill:"none",stroke:I,lineWidth:P,lineDash:this.getDashPattern(n.border_style)}}),n.text){const k=this.getTextX(w,A,n.text_halign),D=this.getTextY(C,v,n.text_valign);h.push({type:"text",style:{x:k,y:D,text:n.text,fill:vt(n.text_color)||"#000000",fontSize:this.getSizePixels(n.text_size),fontFamily:n.text_font_family==="monospace"?"monospace":"sans-serif",fontWeight:n.text_formatting==="format_bold"?"bold":"normal",fontStyle:n.text_formatting==="format_italic"?"italic":"normal",textAlign:this.mapHAlign(n.text_halign),textVerticalAlign:this.mapVAlign(n.text_valign)}})}}return{type:"group",children:h}},data:[[0,g]],clip:!0,encode:{x:[0,1]},itemStyle:{color:"transparent",borderColor:"transparent"},z:14,silent:!0,emphasis:{disabled:!0}}}getDashPattern(t){switch(t){case"style_dotted":return[2,2];case"style_dashed":return[6,4];default:return}}getSizePixels(t){if(typeof t=="number"&&t>0)return t;switch(t){case"auto":case"size.auto":return 12;case"tiny":case"size.tiny":return 8;case"small":case"size.small":return 10;case"normal":case"size.normal":return 14;case"large":case"size.large":return 20;case"huge":case"size.huge":return 36;default:return 12}}mapHAlign(t){switch(t){case"left":case"text.align_left":return"left";case"right":case"text.align_right":return"right";case"center":case"text.align_center":default:return"center"}}mapVAlign(t){switch(t){case"top":case"text.align_top":return"top";case"bottom":case"text.align_bottom":return"bottom";case"center":case"text.align_center":default:return"middle"}}getTextX(t,e,i){switch(i){case"left":case"text.align_left":return t+4;case"right":case"text.align_right":return t+e-4;case"center":case"text.align_center":default:return t+e/2}}getTextY(t,e,i){switch(i){case"top":case"text.align_top":return t+4;case"bottom":case"text.align_bottom":return t+e-4;case"center":case"text.align_center":default:return t+e/2}}}var Ht=Object.defineProperty,Wt=(x,t,e)=>t in x?Ht(x,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):x[t]=e,Gt=(x,t,e)=>(Wt(x,typeof t!="symbol"?t+"":t,e),e);const j=class{static register(t,e){this.renderers.set(t,e)}static get(t){return this.renderers.get(t)||this.renderers.get("line")}};Gt(j,"renderers",new Map),j.register("line",new Dt),j.register("step",new Mt),j.register("histogram",new Ct),j.register("columns",new Ct),j.register("circles",new bt),j.register("cross",new bt),j.register("char",new bt),j.register("bar",new At),j.register("candle",new At),j.register("shape",new $t),j.register("background",new Lt),j.register("fill",new Et),j.register("label",new Nt),j.register("drawing_line",new Ft),j.register("linefill",new Tt),j.register("drawing_polyline",new Ot),j.register("drawing_box",new Zt);let Rt=j;var Bt=Object.defineProperty,Yt=(x,t,e)=>t in x?Bt(x,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):x[t]=e,jt=(x,t,e)=>(Yt(x,typeof t!="symbol"?t+"":t,e),e);const St=class wt{static buildCandlestickSeries(t,e,i){const s=e.upColor||"#00da3c",a=e.downColor||"#ec0000",o=t.map(d=>[d.open,d.close,d.low,d.high]);if(i&&i>o.length){const d=i-o.length;for(let p=0;p<d;p++)o.push(null)}let u;if(e.lastPriceLine?.visible!==!1&&t.length>0){const d=t[t.length-1],p=d.close,g=d.close>=d.open,r=e.lastPriceLine?.color||(g?s:a);let l=e.lastPriceLine?.lineStyle||"dashed";l.startsWith("linestyle_")&&(l=l.replace("linestyle_",""));const h=e.yAxisDecimalPlaces!==void 0?e.yAxisDecimalPlaces:Z.autoDetectDecimals(t);u={symbol:["none","none"],precision:h,data:[{yAxis:p,label:{show:!0,position:"end",formatter:n=>e.yAxisLabelFormatter?e.yAxisLabelFormatter(n.value):Z.formatValue(n.value,h),color:"#fff",backgroundColor:r,padding:[2,4],borderRadius:2,fontSize:11,fontWeight:"bold"},lineStyle:{color:r,type:l,width:1,opacity:.8}}],animation:!1,silent:!0}}return{type:"candlestick",name:e.title||"Market",data:o,itemStyle:{color:s,color0:a,borderColor:s,borderColor0:a},markLine:u,xAxisIndex:0,yAxisIndex:0,z:5}}static buildIndicatorSeries(t,e,i,s,a=0,o,u,d=1){const p=[],g=new Array(s).fill(null),r=new Map;return t.forEach((l,h)=>{l.collapsed||Object.keys(l.plots).sort((n,c)=>{const f=l.plots[n],m=l.plots[c],w=f.options.style==="fill",C=m.options.style==="fill";return w&&!C?1:!w&&C?-1:0}).forEach(n=>{const c=l.plots[n],f=`${h}::${n}`;let m=0,w=0,C=c.options.overlay;if(c.options.style==="fill"&&C===void 0){const I=c.options.plot1,P=c.options.plot2;if(I&&P){const k=l.plots[I],D=l.plots[P];k?.options?.overlay===!0&&D?.options?.overlay===!0&&(C=!0)}}if(l.paneIndex===0||C===!0)m=0,u&&u.has(f)?w=u.get(f):w=0;else{const I=i.findIndex(P=>P.index===l.paneIndex);I!==-1&&(m=I+1,w=d+I)}const A=new Array(s).fill(null),v=new Array(s).fill(null),y=new Array(s).fill(null),b=new Array(s).fill(null);if(c.data?.forEach(I=>{const P=e.get(I.time);if(P!==void 0){const k=I.options?.offset??c.options.offset??0,D=P+a+k;if(D>=0&&D<s){let M=I.value;const L=I.options?.color;v[D]=M;const F=I.options!=null&&"color"in I.options,U=L===null||L==="na"||L==="NaN"||typeof L=="number"&&isNaN(L)||F&&L===void 0;U&&(M=null),A[D]=M,y[D]=U?null:L||c.options.color||wt.DEFAULT_COLOR,b[D]=I.options||{}}}}),r.set(`${h}::${n}`,v),c.options?.style?.startsWith("style_")&&(c.options.style=c.options.style.replace("style_","")),c.options.style==="barcolor"){c.data?.forEach(I=>{const P=e.get(I.time);if(P!==void 0){const k=I.options?.offset??c.options.offset??0,D=P+a+k;if(D>=0&&D<s){const M=I.options?.color||c.options.color||wt.DEFAULT_COLOR;!(M===null||M==="na"||M==="NaN"||typeof M=="number"&&isNaN(M))&&I.value!==null&&I.value!==void 0&&(g[D]=M)}}});return}if(c.options.style==="table")return;const _=Rt.get(c.options.style).render({seriesName:f,xAxisIndex:m,yAxisIndex:w,dataArray:A,colorArray:y,optionsArray:b,plotOptions:c.options,candlestickData:o,plotDataArrays:r,indicatorId:h,plotName:n,dataIndexOffset:a});_&&p.push(_)})}),{series:p,barColors:g}}};jt(St,"DEFAULT_COLOR","#2962ff");let ft=St;class qt{static build(t,e,i,s=!1,a=null){const o=[],u=t.pixelToPercent,d=t.mainPaneTop;if(!a||a==="main"){const p=10*u;if(o.push({type:"text",left:"8.5%",top:d+p+"%",z:10,style:{text:e.title||"Market",fill:e.titleColor||"#fff",font:`bold 16px ${e.fontFamily||"sans-serif"}`,textVerticalAlign:"top"}}),e.watermark!==!1){const r=t.mainPaneTop+t.mainPaneHeight;o.push({type:"text",right:"11%",top:r-3+"%",z:10,style:{text:"QFChart",fill:e.fontColor||"#cbd5e1",font:"bold 16px sans-serif",opacity:.1},cursor:"pointer",onclick:()=>{window.open("https://quantforge.org","_blank")}})}const g=[];if(e.controls?.collapse&&g.push({type:"group",children:[{type:"rect",shape:{width:20,height:20,r:2},style:{fill:"#334155",stroke:"#475569",lineWidth:1},onclick:()=>i("main","collapse")},{type:"text",style:{text:s?"+":"\u2212",fill:"#cbd5e1",font:`bold 14px ${e.fontFamily}`,x:10,y:10,textAlign:"center",textVerticalAlign:"middle"},silent:!0}]}),e.controls?.maximize){const r=a==="main",l=e.controls?.collapse?25:0;g.push({type:"group",x:l,children:[{type:"rect",shape:{width:20,height:20,r:2},style:{fill:"#334155",stroke:"#475569",lineWidth:1},onclick:()=>i("main","maximize")},{type:"text",style:{text:r?"\u2750":"\u25A1",fill:"#cbd5e1",font:`14px ${e.fontFamily}`,x:10,y:10,textAlign:"center",textVerticalAlign:"middle"},silent:!0}]})}if(e.controls?.fullscreen){let r=0;e.controls?.collapse&&(r+=25),e.controls?.maximize&&(r+=25),g.push({type:"group",x:r,children:[{type:"rect",shape:{width:20,height:20,r:2},style:{fill:"#334155",stroke:"#475569",lineWidth:1},onclick:()=>i("main","fullscreen")},{type:"text",style:{text:"\u26F6",fill:"#cbd5e1",font:`14px ${e.fontFamily}`,x:10,y:10,textAlign:"center",textVerticalAlign:"middle"},silent:!0}]})}g.length>0&&o.push({type:"group",right:"10.5%",top:d+"%",children:g})}return t.paneLayout.forEach(p=>{if(a&&p.indicatorId!==a)return;o.push({type:"text",left:"8.5%",top:p.top+10*u+"%",z:10,style:{text:p.indicatorId||"",fill:p.titleColor||"#fff",font:`bold 12px ${e.fontFamily||"sans-serif"}`,textVerticalAlign:"top"}});const g=[];if(p.controls?.collapse&&g.push({type:"group",children:[{type:"rect",shape:{width:20,height:20,r:2},style:{fill:"#334155",stroke:"#475569",lineWidth:1},onclick:()=>p.indicatorId&&i(p.indicatorId,"collapse")},{type:"text",style:{text:p.isCollapsed?"+":"\u2212",fill:"#cbd5e1",font:`bold 14px ${e.fontFamily}`,x:10,y:10,textAlign:"center",textVerticalAlign:"middle"},silent:!0}]}),p.controls?.maximize){const r=a===p.indicatorId,l=p.controls?.collapse?25:0;g.push({type:"group",x:l,children:[{type:"rect",shape:{width:20,height:20,r:2},style:{fill:"#334155",stroke:"#475569",lineWidth:1},onclick:()=>p.indicatorId&&i(p.indicatorId,"maximize")},{type:"text",style:{text:r?"\u2750":"\u25A1",fill:"#cbd5e1",font:`14px ${e.fontFamily}`,x:10,y:10,textAlign:"center",textVerticalAlign:"middle"},silent:!0}]})}g.length>0&&o.push({type:"group",right:"10.5%",top:p.top+"%",children:g})}),o}}class Vt{static format(t,e){if(!t||t.length===0)return"";const i=e.title||"Market",s=e.upColor||"#00da3c",a=e.downColor||"#ec0000",o=e.fontFamily||"sans-serif",u=t[0].axisValue;let d=`<div style="font-weight: bold; margin-bottom: 5px; color: #cbd5e1; font-family: ${o};">${u}</div>`;const p=t.find(r=>r.seriesType==="candlestick"),g=t.filter(r=>r.seriesType!=="candlestick");if(p){const[r,l,h,n,c]=p.value,f=h>=l?s:a;d+=`
18
- <div style="margin-bottom: 8px; font-family: ${o};">
19
- <div style="display:flex; justify-content:space-between; color:${f}; font-weight:bold;">
17
+ import*as G from"echarts";var Ee=Object.defineProperty,Le=(p,t,e)=>t in p?Ee(p,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):p[t]=e,yt=(p,t,e)=>(Le(p,typeof t!="symbol"?t+"":t,e),e);class We{constructor(t,e,i,s={}){yt(this,"id"),yt(this,"plots"),yt(this,"paneIndex"),yt(this,"height"),yt(this,"collapsed"),yt(this,"titleColor"),yt(this,"controls"),this.id=t,this.plots=e,this.paneIndex=i,this.height=s.height,this.collapsed=s.collapsed||!1,this.titleColor=s.titleColor,this.controls=s.controls}toggleCollapse(){this.collapsed=!this.collapsed}isVisible(){return!this.collapsed}updateData(t){Object.keys(t).forEach(e=>{if(!this.plots[e])this.plots[e]=t[e];else{const i=this.plots[e],s=t[e];if(!i.data)return;s.options&&(i.options={...i.options,...s.options});const a=new Map;i.data?.forEach(n=>{a.set(n.time,n)}),s.data?.forEach(n=>{a.set(n.time,n)}),i.data=Array.from(a.values()).sort((n,l)=>n.time-l.time)}})}}class R{static createMinFunction(t){return e=>{const i=(e.max-e.min)*(t/100);return e.min-i}}static createMaxFunction(t){return e=>{const i=(e.max-e.min)*(t/100);return e.max+i}}static autoDetectDecimals(t){if(!t||t.length===0)return 2;const e=t[t.length-1].close;if(e===0||!isFinite(e)||isNaN(e))return 2;const i=Math.abs(e);if(i>=1)return 2;const s=Math.ceil(-Math.log10(i));return Math.min(s+4,10)}static formatValue(t,e){return typeof t=="number"?t.toFixed(e):String(t)}}class Rt{static calculate(t,e,i,s=!1,a=null,n,l){let r=0;t>0&&(r=1/t*100);const o=i.yAxisPadding!==void 0?i.yAxisPadding:5,u=i.grid?.show===!0,d=i.grid?.lineColor??"#334155",c=i.grid?.lineOpacity??.5,g=i.grid?.borderColor??"#334155",h=i.grid?.borderShow===!0,f=i.layout?.left??"10%",y=i.layout?.right??"10%",x=Array.from(e.values()).map(E=>E.paneIndex).filter(E=>E>0).sort((E,H)=>E-H).filter((E,H,X)=>X.indexOf(E)===H),b=x.length>0,D=i.dataZoom?.visible??!0,w=i.dataZoom?.position??"top",k=i.dataZoom?.height??6,m=i.dataZoom?.start??0,C=i.dataZoom?.end??100;let v=8,_=92,A=-1;if(a)if(a==="main")A=0;else{const E=e.get(a);E&&(A=E.paneIndex)}if(A!==-1){const E=[],H=[],X=[],U=[],nt=i.dataZoom?.start??50,j=i.dataZoom?.end??100;(i.dataZoom?.zoomOnTouch??!0)&&U.push({type:"inside",xAxisIndex:"all",start:nt,end:j,filterMode:"weakFilter"});const ot=b?Math.max(...x):0,pt=[];for(let J=0;J<=ot;J++){const et=J===A;E.push({left:f,right:y,top:et?"5%":"0%",height:et?"90%":"0%",show:et,containLabel:!1}),H.push({type:"category",gridIndex:J,data:[],show:et,axisLabel:{show:et,color:"#94a3b8",fontFamily:i.fontFamily},axisLine:{show:et&&h,lineStyle:{color:g}},splitLine:{show:et&&u,lineStyle:{color:d,opacity:c}}});let kt,Pt;if(J===0&&A===0?(kt=i.yAxisMin!==void 0&&i.yAxisMin!=="auto"?i.yAxisMin:R.createMinFunction(o),Pt=i.yAxisMax!==void 0&&i.yAxisMax!=="auto"?i.yAxisMax:R.createMaxFunction(o)):(kt=R.createMinFunction(o),Pt=R.createMaxFunction(o)),X.push({position:"right",gridIndex:J,show:et,scale:!0,min:kt,max:Pt,axisLabel:{show:et,color:"#94a3b8",fontFamily:i.fontFamily,formatter:dt=>{if(i.yAxisLabelFormatter)return i.yAxisLabelFormatter(dt);const At=i.yAxisDecimalPlaces!==void 0?i.yAxisDecimalPlaces:R.autoDetectDecimals(n);return R.formatValue(dt,At)}},splitLine:{show:et&&u,lineStyle:{color:d,opacity:c}}}),J>0){const dt=Array.from(e.values()).find(At=>At.paneIndex===J);dt&&pt.push({index:J,height:et?90:0,top:et?5:0,isCollapsed:!1,indicatorId:dt.id,titleColor:dt.titleColor,controls:dt.controls})}}return{grid:E,xAxis:H,yAxis:X,dataZoom:U,paneLayout:pt,mainPaneHeight:A===0?90:0,mainPaneTop:A===0?5:0,pixelToPercent:r,overlayYAxisMap:new Map,separatePaneYAxisOffset:1}}D?w==="top"?(v=k+4,_=95):(_=100-k-2,v=8):(v=5,_=95);let M=5;t>0&&(M=20/t*100);let S=75,z=[];if(b){const E=x.map(j=>{const ot=Array.from(e.values()).find(pt=>pt.paneIndex===j);return{index:j,requestedHeight:ot?.height,isCollapsed:ot?.collapsed??!1,indicatorId:ot?.id,titleColor:ot?.titleColor,controls:ot?.controls}}).map(j=>({...j,height:j.isCollapsed?3:j.requestedHeight!==void 0?j.requestedHeight:15})),H=E.reduce((j,ot)=>j+ot.height,0),X=E.length*M,U=H+X;S=_-v-U,l!==void 0&&l>0&&!s?S=l:s?S=3:S<20&&(S=Math.max(S,10));let nt=v+S+M;z=E.map(j=>{const ot={index:j.index,height:j.height,top:nt,isCollapsed:j.isCollapsed,indicatorId:j.indicatorId,titleColor:j.titleColor,controls:j.controls};return nt+=j.height+M,ot})}else S=_-v,s&&(S=3);const W=[];if(z.length>0){W.push({yPercent:v+S+M/2,aboveId:"main",belowId:z[0].indicatorId||""});for(let E=0;E<z.length-1;E++)W.push({yPercent:z[E].top+z[E].height+M/2,aboveId:z[E].indicatorId||"",belowId:z[E+1].indicatorId||""})}const I=[];I.push({left:f,right:y,top:v+"%",height:S+"%",containLabel:!1}),z.forEach(E=>{I.push({left:f,right:y,top:E.top+"%",height:E.height+"%",containLabel:!1})});const $=[0,...z.map((E,H)=>H+1)],P=[],F=z.length===0;P.push({type:"category",data:[],gridIndex:0,scale:!0,axisLine:{onZero:!1,show:!s&&h,lineStyle:{color:g}},splitLine:{show:!s&&u,lineStyle:{color:d,opacity:c}},axisLabel:{show:!s,color:"#94a3b8",fontFamily:i.fontFamily||"sans-serif",formatter:E=>{if(i.yAxisLabelFormatter)return i.yAxisLabelFormatter(E);const H=i.yAxisDecimalPlaces!==void 0?i.yAxisDecimalPlaces:R.autoDetectDecimals(n);return R.formatValue(E,H)}},axisTick:{show:!s},axisPointer:{label:{show:F,fontSize:11,backgroundColor:"#475569"}}}),z.forEach((E,H)=>{const X=H===z.length-1;P.push({type:"category",gridIndex:H+1,data:[],axisLabel:{show:!1},axisLine:{show:!E.isCollapsed&&h,lineStyle:{color:g}},axisTick:{show:!1},splitLine:{show:!1},axisPointer:{label:{show:X,fontSize:11,backgroundColor:"#475569"}}})});const T=[];let B,Z;i.yAxisMin!==void 0&&i.yAxisMin!=="auto"?B=i.yAxisMin:B=R.createMinFunction(o),i.yAxisMax!==void 0&&i.yAxisMax!=="auto"?Z=i.yAxisMax:Z=R.createMaxFunction(o),T.push({position:"right",scale:!0,min:B,max:Z,gridIndex:0,splitLine:{show:!s&&u,lineStyle:{color:d,opacity:c}},axisLine:{show:!s&&h,lineStyle:{color:g}},axisLabel:{show:!s,color:"#94a3b8",fontFamily:i.fontFamily||"sans-serif",formatter:E=>{if(i.yAxisLabelFormatter)return i.yAxisLabelFormatter(E);const H=i.yAxisDecimalPlaces!==void 0?i.yAxisDecimalPlaces:R.autoDetectDecimals(n);return R.formatValue(E,H)}}});let N=1,V=-1/0,O=1/0;n&&n.length>0&&(V=Math.min(...n.map(E=>E.low)),O=Math.max(...n.map(E=>E.high)));const Y=new Map;e.forEach((E,H)=>{E.paneIndex===0&&!E.collapsed&&n&&n.length>0&&Object.entries(E.plots).forEach(([X,U])=>{const nt=`${H}::${X}`,j=["background","barcolor","char"],ot=U.options.style==="shape"&&(U.options.location==="abovebar"||U.options.location==="AboveBar"||U.options.location==="belowbar"||U.options.location==="BelowBar");if(j.includes(U.options.style)){Y.has(nt)||(Y.set(nt,N),N++);return}if(U.options.style==="shape"&&!ot){Y.has(nt)||(Y.set(nt,N),N++);return}const pt=[];if(U.data&&Object.values(U.data).forEach(J=>{typeof J=="number"&&!isNaN(J)&&isFinite(J)&&pt.push(J)}),pt.length>0){const J=Math.min(...pt),et=Math.max(...pt),kt=et-J,Pt=O-V,dt=J>=V*.5&&et<=O*1.5,At=kt>Pt*.01;dt&&At||Y.has(nt)||(Y.set(nt,N),N++)}})});const lt=Y.size>0?N-1:0,ht=new Set;Y.forEach((E,H)=>{e.forEach(X=>{Object.entries(X.plots).forEach(([U,nt])=>{`${X.id}::${U}`===H&&["background","barcolor","char"].includes(nt.options.style)&&ht.add(E)})})});for(let E=0;E<lt;E++){const H=E+1,X=ht.has(H);T.push({position:"left",scale:!X,min:X?0:R.createMinFunction(o),max:X?1:R.createMaxFunction(o),gridIndex:0,show:!1,splitLine:{show:!1},axisLine:{show:!1},axisLabel:{show:!1}})}const Ht=N;z.forEach((E,H)=>{T.push({position:"right",scale:!0,min:R.createMinFunction(o),max:R.createMaxFunction(o),gridIndex:H+1,splitLine:{show:!E.isCollapsed&&u,lineStyle:{color:d,opacity:c*.6}},axisLabel:{show:!E.isCollapsed,color:"#94a3b8",fontFamily:i.fontFamily||"sans-serif",fontSize:10,formatter:X=>{if(i.yAxisLabelFormatter)return i.yAxisLabelFormatter(X);const U=i.yAxisDecimalPlaces!==void 0?i.yAxisDecimalPlaces:R.autoDetectDecimals(n);return R.formatValue(X,U)}},axisLine:{show:!E.isCollapsed&&h,lineStyle:{color:g}}})});const bt=[],Lt=i.dataZoom?.zoomOnTouch??!0,Wt=i.dataZoom?.pannable??!0;return Lt&&Wt&&bt.push({type:"inside",xAxisIndex:$,start:m,end:C,filterMode:"weakFilter"}),D&&(w==="top"?bt.push({type:"slider",xAxisIndex:$,top:"1%",height:k+"%",start:m,end:C,borderColor:"#334155",textStyle:{color:"#cbd5e1"},brushSelect:!1,filterMode:"weakFilter"}):bt.push({type:"slider",xAxisIndex:$,bottom:"1%",height:k+"%",start:m,end:C,borderColor:"#334155",textStyle:{color:"#cbd5e1"},brushSelect:!1,filterMode:"weakFilter"})),{grid:I,xAxis:P,yAxis:T,dataZoom:bt,paneLayout:z,mainPaneHeight:S,mainPaneTop:v,pixelToPercent:r,paneBoundaries:W,overlayYAxisMap:Y,separatePaneYAxisOffset:Ht}}static calculateMaximized(t,e,i){return{grid:[],xAxis:[],yAxis:[],dataZoom:[],paneLayout:[],mainPaneHeight:0,mainPaneTop:0,pixelToPercent:0,paneBoundaries:[]}}}class Te{render(t){const{seriesName:e,xAxisIndex:i,yAxisIndex:s,dataArray:a,colorArray:n,plotOptions:l}=t,r="#2962ff";return{name:e,type:"custom",xAxisIndex:i,yAxisIndex:s,renderItem:(o,u)=>{const d=o.dataIndex;if(d===0)return;const c=u.value(1),g=u.value(2);if(c===null||isNaN(c)||g===null||isNaN(g))return;const h=u.coord([d-1,g]),f=u.coord([d,c]);return{type:"line",shape:{x1:h[0],y1:h[1],x2:f[0],y2:f[1]},style:{stroke:n[d]||l.color||r,lineWidth:l.linewidth||1},silent:!0}},data:a.map((o,u)=>[u,o,u>0?a[u-1]:null])}}}class Ne{render(t){const{seriesName:e,xAxisIndex:i,yAxisIndex:s,dataArray:a,colorArray:n,plotOptions:l}=t,r="#2962ff";return{name:e,type:"custom",xAxisIndex:i,yAxisIndex:s,renderItem:(o,u)=>{const d=u.value(0),c=u.value(1);if(isNaN(c)||c===null)return;const g=u.coord([d,c]),h=u.size([1,0])[0];return{type:"line",shape:{x1:g[0]-h/2,y1:g[1],x2:g[0]+h/2,y2:g[1]},style:{stroke:n[o.dataIndex]||l.color||r,lineWidth:l.linewidth||1},silent:!0}},data:a.map((o,u)=>[u,o])}}}class te{render(t){const{seriesName:e,xAxisIndex:i,yAxisIndex:s,dataArray:a,colorArray:n,plotOptions:l}=t,r="#2962ff",o=l.histbase??0,u=l.style==="columns",d=l.linewidth??1,c=a.map((g,h)=>g==null||typeof g=="number"&&isNaN(g)?null:[h,g,n[h]||l.color||r]);return{name:e,type:"custom",xAxisIndex:i,yAxisIndex:s,renderItem:(g,h)=>{const f=h.value(0),y=h.value(1),x=h.value(2);if(y==null||isNaN(y))return null;const b=h.coord([f,o]),D=h.coord([f,y]),w=h.size([1,0])[0];let k;u?k=w*.6:k=Math.max(1,d);const m=b[0],C=b[1],v=D[1],_=Math.min(C,v),A=Math.abs(v-C);return{type:"rect",shape:{x:m-k/2,y:_,width:k,height:A||1},style:{fill:x}}},data:c.filter(g=>g!==null)}}}const Bt=new Map;function Ze(p,t="#00da3c",e="64px"){if(typeof document>"u")return"";const i=`${p}-${t}-${e}`;if(Bt.has(i))return Bt.get(i);const s=document.createElement("canvas"),a=s.getContext("2d");if(s.width=32,s.height=32,a){a.font="bold "+e+" Arial",a.fillStyle=t,a.textAlign="center",a.textBaseline="middle",a.fillText(p,16,16);const n=s.toDataURL("image/png");return Bt.set(i,n),n}return""}class jt{render(t){const{seriesName:e,xAxisIndex:i,yAxisIndex:s,dataArray:a,colorArray:n,plotOptions:l}=t,r="#2962ff",o=l.style;if(o==="char")return{name:e,type:"scatter",xAxisIndex:i,yAxisIndex:s,symbolSize:0,data:a.map((d,c)=>({value:[c,d],itemStyle:{opacity:0}})),silent:!0};const u=a.map((d,c)=>{if(d===null)return null;const g=n[c]||l.color||r,h={value:[c,d],itemStyle:{color:g}};return o==="cross"?(h.symbol=`image://${Ze("+",g,"24px")}`,h.symbolSize=16):(h.symbol="circle",h.symbolSize=6),h}).filter(d=>d!==null);return{name:e,type:"scatter",xAxisIndex:i,yAxisIndex:s,data:u}}}class ee{render(t){const{seriesName:e,xAxisIndex:i,yAxisIndex:s,dataArray:a,colorArray:n,optionsArray:l,plotOptions:r}=t,o="#2962ff",u=r.style==="candle",d=[],c=a.map((g,h)=>{if(g===null||!Array.isArray(g)||g.length!==4)return null;const[f,y,x,b]=g,D=l[h]||{},w=D.color||n[h]||r.color||o,k=D.wickcolor||r.wickcolor||w,m=D.bordercolor||r.bordercolor||k;return d[h]={color:w,wickColor:k,borderColor:m},[h,f,b,x,y]}).filter(g=>g!==null);return{name:e,type:"custom",xAxisIndex:i,yAxisIndex:s,renderItem:(g,h)=>{const f=h.value(0),y=h.value(1),x=h.value(2),b=h.value(3),D=h.value(4);if(isNaN(y)||isNaN(x)||isNaN(b)||isNaN(D))return null;const w=d[f]||{color:o,wickColor:o,borderColor:o},k=w.color,m=w.wickColor,C=w.borderColor,v=h.coord([f,0])[0],_=h.coord([f,y])[1],A=h.coord([f,x])[1],M=h.coord([f,b])[1],S=h.coord([f,D])[1],z=h.size([1,0])[0]*.6;if(u){const W=Math.min(_,A),I=Math.max(_,A),$=Math.abs(A-_);return{type:"group",children:[{type:"line",shape:{x1:v,y1:S,x2:v,y2:W},style:{stroke:m,lineWidth:1}},{type:"line",shape:{x1:v,y1:I,x2:v,y2:M},style:{stroke:m,lineWidth:1}},{type:"rect",shape:{x:v-z/2,y:W,width:z,height:$||1},style:{fill:k,stroke:C,lineWidth:1}}]}}else{const W=z*.5;return{type:"group",children:[{type:"line",shape:{x1:v,y1:M,x2:v,y2:S},style:{stroke:k,lineWidth:1}},{type:"line",shape:{x1:v-W,y1:_,x2:v,y2:_},style:{stroke:k,lineWidth:1}},{type:"line",shape:{x1:v,y1:A,x2:v+W,y2:A},style:{stroke:k,lineWidth:1}}]}}},data:c}}}class vt{static getShapeSymbol(t){switch(t){case"arrowdown":case"shape_arrow_down":return"path://M12 24l-12-12h8v-12h8v12h8z";case"arrowup":case"shape_arrow_up":return"path://M12 0l12 12h-8v12h-8v-12h-8z";case"circle":case"shape_circle":return"circle";case"cross":case"shape_cross":return"path://M11 2h2v9h9v2h-9v9h-2v-9h-9v-2h9z";case"diamond":case"shape_diamond":return"diamond";case"flag":case"shape_flag":return"path://M6 2v20h2v-8h12l-2-6 2-6h-12z";case"labeldown":case"shape_label_down":return"path://M2 1h20a1 1 0 0 1 1 1v14a1 1 0 0 1-1 1h-8l-2 3-2-3h-8a1 1 0 0 1-1-1v-14a1 1 0 0 1 1-1z";case"labelleft":case"shape_label_left":return"path://M0 10l3-3v-5a1 1 0 0 1 1-1h18a1 1 0 0 1 1 1v16a1 1 0 0 1-1 1h-18a1 1 0 0 1-1-1v-5z";case"labelright":case"shape_label_right":return"path://M24 10l-3-3v-5a1 1 0 0 0-1-1h-18a1 1 0 0 0-1 1v16a1 1 0 0 0 1 1h18a1 1 0 0 0 1-1v-5z";case"labelup":case"shape_label_up":return"path://M12 1l2 3h8a1 1 0 0 1 1 1v14a1 1 0 0 1-1 1h-20a1 1 0 0 1-1-1v-14a1 1 0 0 1 1-1h8z";case"square":case"shape_square":return"rect";case"triangledown":case"shape_triangle_down":return"path://M12 21l-10-18h20z";case"triangleup":case"shape_triangle_up":return"triangle";case"xcross":case"shape_xcross":return"path://M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z";default:return"circle"}}static getShapeRotation(t){return 0}static getShapeSize(t,e,i){if(e!==void 0&&i!==void 0)return[e,i];let s;switch(t){case"tiny":s=8;break;case"small":s=12;break;case"normal":case"auto":s=16;break;case"large":s=24;break;case"huge":s=32;break;default:s=16}return e!==void 0?[e,e]:i!==void 0?[i,i]:s}static getLabelConfig(t,e){switch(e){case"abovebar":case"AboveBar":return{position:"top",distance:5};case"belowbar":case"BelowBar":return{position:"bottom",distance:5};case"top":case"Top":return{position:"bottom",distance:5};case"bottom":case"Bottom":return{position:"top",distance:5};case"absolute":case"Absolute":default:return t==="labelup"||t==="labeldown"||t==="shape_label_up"||t==="shape_label_down"?{position:"inside",distance:0}:{position:"top",distance:5}}}}class Fe{render(t){const{seriesName:e,xAxisIndex:i,yAxisIndex:s,dataArray:a,colorArray:n,optionsArray:l,plotOptions:r,candlestickData:o}=t,u="#2962ff",d=a.map((c,g)=>{const h=l[g]||{},f=r,y=h.location||f.location||"absolute";if(y!=="absolute"&&y!=="Absolute"&&!c||c==null)return null;const x=h.color||f.color||u,b=h.shape||f.shape||"circle",D=h.size||f.size||"normal",w=h.text||f.text,k=h.textcolor||f.textcolor||"white",m=h.width||f.width,C=h.height||f.height;let v=c,_=[0,0];y==="abovebar"||y==="AboveBar"||y==="ab"?(o&&o[g]&&(v=o[g].high),_=[0,"-150%"]):y==="belowbar"||y==="BelowBar"||y==="bl"?(o&&o[g]&&(v=o[g].low),_=[0,"150%"]):y==="top"||y==="Top"?(v=c,_=[0,0]):(y==="bottom"||y==="Bottom")&&(v=c,_=[0,0]);const A=vt.getShapeSymbol(b),M=vt.getShapeSize(D,m,C),S=vt.getShapeRotation(b);let z=M;b.includes("label")&&(Array.isArray(M)?z=[M[0]*2.5,M[1]*2.5]:z=M*2.5);const W=vt.getLabelConfig(b,y);return{value:[g,v],symbol:A,symbolSize:z,symbolRotate:S,symbolOffset:_,itemStyle:{color:x},label:{show:!!w,position:W.position,distance:W.distance,formatter:w,color:k,fontSize:10,fontWeight:"bold"}}}).filter(c=>c!==null);return{name:e,type:"scatter",xAxisIndex:i,yAxisIndex:s,data:d}}}class at{static parseColor(t){if(!t||typeof t!="string")return{color:"#888888",opacity:.2};const e=t.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?\)/);if(e){const s=e[1],a=e[2],n=e[3],l=e[4]?parseFloat(e[4]):1;return{color:`rgb(${s},${a},${n})`,opacity:l}}const i=t.match(/^#([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/);if(i){const s=parseInt(i[1],16),a=parseInt(i[2],16),n=parseInt(i[3],16),l=parseInt(i[4],16)/255;return{color:`rgb(${s},${a},${n})`,opacity:l}}return{color:t,opacity:.3}}static toRgba(t,e){const i=t.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(i)return`rgba(${i[1]},${i[2]},${i[3]},${e})`;const s=t.match(/^#([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/);if(s){const n=parseInt(s[1],16),l=parseInt(s[2],16),r=parseInt(s[3],16);return`rgba(${n},${l},${r},${e})`}const a=t.match(/^#([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/);if(a){const n=parseInt(a[1],16),l=parseInt(a[2],16),r=parseInt(a[3],16);return`rgba(${n},${l},${r},${e})`}return t}}class Oe{render(t){const{seriesName:e,xAxisIndex:i,yAxisIndex:s,dataArray:a,colorArray:n}=t,l=[];for(let r=0;r<n.length;r++)l[r]=n[r]?at.parseColor(n[r]):{color:"",opacity:0};return{name:e,type:"custom",xAxisIndex:i,yAxisIndex:s,z:-10,renderItem:(r,o)=>{const u=o.value(0);if(isNaN(u))return;const d=o.coord([u,.5]),c=o.size([1,0])[0],g=r.coordSys,h=d[0]-c/2,f=n[r.dataIndex],y=o.value(1);if(!f||y===null||y===void 0||isNaN(y))return;const x=l[r.dataIndex];if(!(!x||x.opacity<=0))return{type:"rect",shape:{x:h,y:g.y,width:c,height:g.height},style:{fill:x.color,opacity:x.opacity},silent:!0}},data:a.map((r,o)=>[o,r!=null&&!isNaN(r)?.5:null])}}}class ie{render(t){const{seriesName:e,xAxisIndex:i,yAxisIndex:s,plotOptions:a,plotDataArrays:n,indicatorId:l,plotName:r,optionsArray:o}=t,u=t.dataArray.length,d=a.plot1?`${l}::${a.plot1}`:null,c=a.plot2?`${l}::${a.plot2}`:null;if(!d||!c)return console.warn(`Fill plot "${r}" missing plot1 or plot2 reference`),null;const g=n?.get(d),h=n?.get(c);if(!g||!h)return console.warn(`Fill plot "${r}" references non-existent plots: ${a.plot1}, ${a.plot2}`),null;if(a.gradient===!0)return this.renderGradientFill(e,i,s,g,h,u,o,a);const{color:f,opacity:y}=at.parseColor(a.color||"rgba(128, 128, 128, 0.2)"),x=o?.some(w=>w&&w.color!==void 0);let b=null;if(x){b=[];for(let w=0;w<u;w++){const k=o?.[w];k&&k.color!==void 0?b[w]=at.parseColor(k.color):b[w]={color:f,opacity:y}}}const D=[];for(let w=0;w<u;w++){const k=g[w],m=h[w],C=w>0?g[w-1]:null,v=w>0?h[w-1]:null;D.push([w,k,m,C,v])}return{name:e,type:"custom",xAxisIndex:i,yAxisIndex:s,z:1,clip:!0,encode:{x:0},animation:!1,renderItem:(w,k)=>{const m=w.dataIndex;if(m===0)return null;const C=k.value(1),v=k.value(2),_=k.value(3),A=k.value(4);if(C===null||v===null||_===null||A===null||isNaN(C)||isNaN(v)||isNaN(_)||isNaN(A))return null;const M=b?b[m]:null,S=M?M.opacity:y;if(S<.01)return null;const z=k.coord([m-1,_]),W=k.coord([m,C]),I=k.coord([m,v]),$=k.coord([m-1,A]);return{type:"polygon",shape:{points:[z,W,I,$]},style:{fill:M?M.color:f,opacity:S},silent:!0}},data:D,silent:!0}}renderBatched(t,e,i,s,a){const n=Array.from({length:s},(l,r)=>[r]);return{name:t,type:"custom",xAxisIndex:e,yAxisIndex:i,z:1,clip:!0,encode:{x:0},animation:!1,renderItem:(l,r)=>{const o=l.dataIndex;if(o===0)return null;const u=[];for(let d=0;d<a.length;d++){const c=a[d],g=c.plot1Data[o],h=c.plot2Data[o],f=c.plot1Data[o-1],y=c.plot2Data[o-1];if(g==null||h==null||f==null||y==null||isNaN(g)||isNaN(h)||isNaN(f)||isNaN(y))continue;const x=c.barColors[o];if(!x||x.opacity<.01)continue;const b=r.coord([o-1,f]),D=r.coord([o,g]),w=r.coord([o,h]),k=r.coord([o-1,y]);u.push({type:"polygon",shape:{points:[b,D,w,k]},style:{fill:x.color,opacity:x.opacity},silent:!0})}return u.length>0?{type:"group",children:u,silent:!0}:null},data:n,silent:!0}}renderGradientFill(t,e,i,s,a,n,l,r){const o=[];for(let d=0;d<n;d++){const c=l?.[d];if(c&&c.top_color!==void 0){const g=at.parseColor(c.top_color),h=at.parseColor(c.bottom_color);o[d]={topColor:g.color,topOpacity:g.opacity,bottomColor:h.color,bottomOpacity:h.opacity}}else o[d]={topColor:"rgba(128,128,128,0.2)",topOpacity:.2,bottomColor:"rgba(128,128,128,0.2)",bottomOpacity:.2}}const u=[];for(let d=0;d<n;d++){const c=s[d],g=a[d],h=d>0?s[d-1]:null,f=d>0?a[d-1]:null;u.push([d,c,g,h,f])}return{name:t,type:"custom",xAxisIndex:e,yAxisIndex:i,z:1,clip:!0,encode:{x:0},animation:!1,renderItem:(d,c)=>{const g=d.dataIndex;if(g===0)return null;const h=c.value(1),f=c.value(2),y=c.value(3),x=c.value(4);if(h===null||f===null||y===null||x===null||isNaN(h)||isNaN(f)||isNaN(y)||isNaN(x))return null;const b=c.coord([g-1,y]),D=c.coord([g,h]),w=c.coord([g,f]),k=c.coord([g-1,x]),m=o[g]||o[g-1];if(!m||m.topOpacity<.01&&m.bottomOpacity<.01)return null;const C=at.toRgba(m.topColor,m.topOpacity),v=at.toRgba(m.bottomColor,m.bottomOpacity),_=h>=f;return{type:"polygon",shape:{points:[b,D,w,k]},style:{fill:{type:"linear",x:0,y:0,x2:0,y2:1,colorStops:[{offset:0,color:_?C:v},{offset:1,color:_?v:C}]}},silent:!0}},data:u,silent:!0}}}class He{render(t){const{seriesName:e,xAxisIndex:i,yAxisIndex:s,dataArray:a,candlestickData:n,dataIndexOffset:l}=t,r=l||0,o=[];for(let d=0;d<a.length;d++){const c=a[d];if(!c)continue;const g=Array.isArray(c)?c:[c];for(const h of g)h&&typeof h=="object"&&!h._deleted&&o.push(h)}const u=o.map(d=>{const c=T=>typeof T=="function"?T():T,g=c(d.text)||"",h=c(d.color),f=h!=null&&h!==""?h:"transparent",y=c(d.textcolor)||"#ffffff",x=c(d.yloc)||"price",b=c(d.style)||"style_label_down",D=c(d.size)||"normal",w=c(d.textalign)||"align_center",k=c(d.tooltip)||"",m=this.styleToShape(b),C=d.xloc==="bar_index"||d.xloc==="bi"?d.x+r:d.x;let v=d.y,_=[0,0];x==="abovebar"||x==="AboveBar"||x==="ab"?(n&&n[C]&&(v=n[C].high),_=[0,"-150%"]):(x==="belowbar"||x==="BelowBar"||x==="bl")&&(n&&n[C]&&(v=n[C].low),_=[0,"150%"]);const A=vt.getShapeSymbol(m),M=vt.getShapeSize(D),S=this.getSizePx(D);let z;const W=m==="labeldown"||m==="shape_label_down"||m==="labelup"||m==="shape_label_up"||m==="labelleft"||m==="labelright";let I=[0,0];if(W){const T=g.length*S*.65,B=S*2.5,Z=Math.max(B,T+S*1.6),N=S*2.8,V=3/24;if(m==="labelleft"||m==="labelright"){const O=Z/(1-V);z=[O,N];const Y=typeof _[0]=="string"?0:_[0];m==="labelleft"?(_=[Y+O*.42,_[1]],I=[O*V*.5,0]):(_=[Y-O*.42,_[1]],I=[-O*V*.5,0])}else{const O=N/(1-V);z=[Z,O],m==="labeldown"?(_=[_[0],typeof _[1]=="string"?_[1]:_[1]-O*.42],I=[0,-O*V*.5]):(_=[_[0],typeof _[1]=="string"?_[1]:_[1]+O*.42],I=[0,O*V*.5])}}else m==="none"?z=0:Array.isArray(M)?z=[M[0]*1.5,M[1]*1.5]:z=M*1.5;const $=this.getLabelPosition(b,x),P=$==="inside"||$.startsWith("inside"),F={value:[C,v],symbol:A,symbolSize:z,symbolOffset:_,itemStyle:{color:f},label:{show:!!g,position:$,distance:P?0:5,offset:I,formatter:g,color:y,fontSize:S,fontWeight:"bold",align:P?"center":w==="align_left"||w==="left"?"left":w==="align_right"||w==="right"?"right":"center",verticalAlign:"middle",padding:[2,6]}};return k?(F._tooltipText=k,F.emphasis={scale:!1,itemStyle:{color:f},label:{show:F.label.show,color:y,fontSize:S,fontWeight:"bold"}}):F.emphasis={disabled:!0},F}).filter(d=>d!==null);return{name:e,type:"scatter",xAxisIndex:i,yAxisIndex:s,data:u,z:20,animation:!1,clip:!1}}styleToShape(t){switch(t.startsWith("style_")?t.substring(6):t){case"label_down":return"labeldown";case"label_up":return"labelup";case"label_left":return"labelleft";case"label_right":return"labelright";case"label_lower_left":return"labeldown";case"label_lower_right":return"labeldown";case"label_upper_left":return"labelup";case"label_upper_right":return"labelup";case"label_center":return"labeldown";case"circle":return"circle";case"square":return"square";case"diamond":return"diamond";case"flag":return"flag";case"arrowup":return"arrowup";case"arrowdown":return"arrowdown";case"cross":return"cross";case"xcross":return"xcross";case"triangleup":return"triangleup";case"triangledown":return"triangledown";case"text_outline":return"none";case"none":return"none";default:return"labeldown"}}getLabelPosition(t,e){switch(t.startsWith("style_")?t.substring(6):t){case"label_down":case"label_up":case"label_left":case"label_right":case"label_lower_left":case"label_lower_right":case"label_upper_left":case"label_upper_right":case"label_center":return"inside";case"text_outline":case"none":return e==="abovebar"||e==="AboveBar"||e==="ab"?"top":e==="belowbar"||e==="BelowBar"||e==="bl"?"bottom":"top";default:return e==="belowbar"||e==="BelowBar"||e==="bl"?"bottom":"top"}}getSizePx(t){switch(t){case"tiny":return 8;case"small":return 9;case"normal":case"auto":return 10;case"large":return 12;case"huge":return 14;default:return 10}}}class Re{render(t){const{seriesName:e,xAxisIndex:i,yAxisIndex:s,dataArray:a,dataIndexOffset:n}=t,l=n||0,r="#2962ff",o=[];for(let c=0;c<a.length;c++){const g=a[c];if(!g)continue;const h=Array.isArray(g)?g:[g];for(const f of h)f&&typeof f=="object"&&!f._deleted&&o.push(f)}if(o.length===0)return{name:e,type:"custom",xAxisIndex:i,yAxisIndex:s,data:[],silent:!0};const u=(t.candlestickData?.length||0)+l,d=Math.max(0,u-1);return{name:e,type:"custom",xAxisIndex:i,yAxisIndex:s,renderItem:(c,g)=>{const h=[];for(const f of o){if(f._deleted)continue;const y=f.xloc==="bar_index"||f.xloc==="bi"?l:0;let x=g.coord([f.x1+y,f.y1]),b=g.coord([f.x2+y,f.y2]);const D=f.extend||"none";if(D!=="none"&&D!=="n"){const C=c.coordSys;[x,b]=this.extendLine(x,b,D,C.x,C.x+C.width,C.y,C.y+C.height)}const w=f.color||r,k=f.width||1;h.push({type:"line",shape:{x1:x[0],y1:x[1],x2:b[0],y2:b[1]},style:{fill:"none",stroke:w,lineWidth:k,lineDash:this.getDashPattern(f.style)}});const m=f.style||"style_solid";if(m==="style_arrow_left"||m==="style_arrow_both"){const C=this.arrowHead(b,x,k,w);C&&h.push(C)}if(m==="style_arrow_right"||m==="style_arrow_both"){const C=this.arrowHead(x,b,k,w);C&&h.push(C)}}return{type:"group",children:h}},data:[[0,d]],clip:!0,encode:{x:[0,1]},itemStyle:{color:"transparent",borderColor:"transparent"},z:15,silent:!0,emphasis:{disabled:!0}}}getDashPattern(t){switch(t){case"style_dotted":return[2,2];case"style_dashed":return[6,4];default:return}}extendLine(t,e,i,s,a,n,l){const r=e[0]-t[0],o=e[1]-t[1];if(r===0&&o===0)return[t,e];const u=(g,h)=>{let f=1/0;if(h[0]!==0){const y=h[0]>0?(a-g[0])/h[0]:(s-g[0])/h[0];f=Math.min(f,y)}if(h[1]!==0){const y=h[1]>0?(l-g[1])/h[1]:(n-g[1])/h[1];f=Math.min(f,y)}return isFinite(f)||(f=0),[g[0]+f*h[0],g[1]+f*h[1]]};let d=t,c=e;return(i==="right"||i==="r"||i==="both"||i==="b")&&(c=u(t,[r,o])),(i==="left"||i==="l"||i==="both"||i==="b")&&(d=u(e,[-r,-o])),[d,c]}arrowHead(t,e,i,s){const a=e[0]-t[0],n=e[1]-t[1],l=Math.sqrt(a*a+n*n);if(l<1)return null;const r=Math.max(8,i*4),o=a/l,u=n/l,d=e[0]-o*r,c=e[1]-u*r,g=-u*r*.4,h=o*r*.4;return{type:"polygon",shape:{points:[[e[0],e[1]],[d+g,c+h],[d-g,c-h]]},style:{fill:s}}}}class Be{render(t){const{seriesName:e,xAxisIndex:i,yAxisIndex:s,dataArray:a,dataIndexOffset:n}=t,l=n||0,r=[];for(let d=0;d<a.length;d++){const c=a[d];if(!c)continue;const g=Array.isArray(c)?c:[c];for(const h of g){if(!h||typeof h!="object"||h._deleted)continue;const f=h.line1,y=h.line2;!f||!y||f._deleted||y._deleted||r.push(h)}}if(r.length===0)return{name:e,type:"custom",xAxisIndex:i,yAxisIndex:s,data:[],silent:!0};const o=(t.candlestickData?.length||0)+l,u=Math.max(0,o-1);return{name:e,type:"custom",xAxisIndex:i,yAxisIndex:s,renderItem:(d,c)=>{const g=[];for(const h of r){if(h._deleted)continue;const f=h.line1,y=h.line2;if(!f||!y||f._deleted||y._deleted)continue;const x=f.xloc==="bar_index"||f.xloc==="bi"?l:0,b=y.xloc==="bar_index"||y.xloc==="bi"?l:0;let D=c.coord([f.x1+x,f.y1]),w=c.coord([f.x2+x,f.y2]),k=c.coord([y.x1+b,y.y1]),m=c.coord([y.x2+b,y.y2]);const C=f.extend||"none",v=y.extend||"none";if(C!=="none"||v!=="none"){const M=d.coordSys,S=M.x,z=M.x+M.width,W=M.y,I=M.y+M.height;C!=="none"&&([D,w]=this.extendLine(D,w,C,S,z,W,I)),v!=="none"&&([k,m]=this.extendLine(k,m,v,S,z,W,I))}const{color:_,opacity:A}=at.parseColor(h.color||"rgba(128, 128, 128, 0.2)");g.push({type:"polygon",shape:{points:[D,w,m,k]},style:{fill:_,opacity:A},silent:!0})}return{type:"group",children:g}},data:[[0,u]],clip:!0,encode:{x:[0,1]},z:10,silent:!0,emphasis:{disabled:!0}}}extendLine(t,e,i,s,a,n,l){const r=e[0]-t[0],o=e[1]-t[1];if(r===0&&o===0)return[t,e];const u=(g,h)=>{let f=1/0;if(h[0]!==0){const y=h[0]>0?(a-g[0])/h[0]:(s-g[0])/h[0];f=Math.min(f,y)}if(h[1]!==0){const y=h[1]>0?(l-g[1])/h[1]:(n-g[1])/h[1];f=Math.min(f,y)}return isFinite(f)||(f=0),[g[0]+f*h[0],g[1]+f*h[1]]};let d=t,c=e;return(i==="right"||i==="both")&&(c=u(t,[r,o])),(i==="left"||i==="both")&&(d=u(e,[-r,-o])),[d,c]}}class je{render(t){const{seriesName:e,xAxisIndex:i,yAxisIndex:s,dataArray:a,dataIndexOffset:n}=t,l=n||0,r=[];for(let d=0;d<a.length;d++){const c=a[d];if(!c)continue;const g=Array.isArray(c)?c:[c];for(const h of g)h&&typeof h=="object"&&!h._deleted&&h.points&&h.points.length>=2&&r.push(h)}if(r.length===0)return{name:e,type:"custom",xAxisIndex:i,yAxisIndex:s,data:[],silent:!0};const o=(t.candlestickData?.length||0)+l,u=Math.max(0,o-1);return{name:e,type:"custom",xAxisIndex:i,yAxisIndex:s,renderItem:(d,c)=>{const g=[];for(const h of r){if(h._deleted)continue;const f=h.points;if(!f||f.length<2)continue;const y=h.xloc==="bi"||h.xloc==="bar_index",x=y?l:0,b=[];for(const C of f){const v=y?(C.index??0)+x:C.time??0,_=C.price??0;b.push(c.coord([v,_]))}if(b.length<2)continue;const D=h.line_color,w=D==null||typeof D=="number"&&isNaN(D)||D==="na"||D==="NaN"?null:D||"#2962ff",k=h.line_width||1,m=this.getDashPattern(h.line_style);if(h.fill_color&&h.fill_color!==""&&h.fill_color!=="na"){const{color:C,opacity:v}=at.parseColor(h.fill_color);if(h.curved){const _=this.buildCurvedPath(b,h.closed);g.push({type:"path",shape:{pathData:_+" Z"},style:{fill:C,opacity:v,stroke:"none"},silent:!0})}else g.push({type:"polygon",shape:{points:b},style:{fill:C,opacity:v,stroke:"none"},silent:!0})}if(w&&k>0)if(h.curved){const C=this.buildCurvedPath(b,h.closed);g.push({type:"path",shape:{pathData:C},style:{fill:"none",stroke:w,lineWidth:k,lineDash:m},silent:!0})}else{const C=h.closed?[...b,b[0]]:b;g.push({type:"polyline",shape:{points:C},style:{fill:"none",stroke:w,lineWidth:k,lineDash:m},silent:!0})}}return{type:"group",children:g}},data:[[0,u]],clip:!0,encode:{x:[0,1]},itemStyle:{color:"transparent",borderColor:"transparent"},z:15,silent:!0,emphasis:{disabled:!0}}}buildCurvedPath(t,e){const i=t.length;if(i<2)return"";if(i===2)return`M ${t[0][0]} ${t[0][1]} L ${t[1][0]} ${t[1][1]}`;const s=.5;let a=`M ${t[0][0]} ${t[0][1]}`;const n=r=>e?t[(r%i+i)%i]:r<0?t[0]:r>=i?t[i-1]:t[r],l=e?i:i-1;for(let r=0;r<l;r++){const o=n(r-1),u=n(r),d=n(r+1),c=n(r+2),g=u[0]+(d[0]-o[0])*s/3,h=u[1]+(d[1]-o[1])*s/3,f=d[0]-(c[0]-u[0])*s/3,y=d[1]-(c[1]-u[1])*s/3;a+=` C ${g} ${h}, ${f} ${y}, ${d[0]} ${d[1]}`}return e&&(a+=" Z"),a}getDashPattern(t){switch(t){case"style_dotted":return[2,2];case"style_dashed":return[6,4];default:return}}}function Yt(p){if(!p||typeof p!="string")return p;if(p.startsWith("#")){const t=p.slice(1);if(t.length===8){const e=parseInt(t.slice(0,2),16),i=parseInt(t.slice(2,4),16),s=parseInt(t.slice(4,6),16),a=parseInt(t.slice(6,8),16)/255;return`rgba(${e},${i},${s},${a.toFixed(3)})`}}return p}function Ye(p){if(!p||typeof p!="string")return null;if(p.startsWith("#")){const e=p.slice(1);if(e.length>=6){const i=parseInt(e.slice(0,2),16),s=parseInt(e.slice(2,4),16),a=parseInt(e.slice(4,6),16);if(!isNaN(i)&&!isNaN(s)&&!isNaN(a))return{r:i,g:s,b:a}}if(e.length===3){const i=parseInt(e[0]+e[0],16),s=parseInt(e[1]+e[1],16),a=parseInt(e[2]+e[2],16);if(!isNaN(i)&&!isNaN(s)&&!isNaN(a))return{r:i,g:s,b:a}}return null}const t=p.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?{r:+t[1],g:+t[2],b:+t[3]}:null}function Xe(p,t,e){return(.299*p+.587*t+.114*e)/255}class Ve{render(t){const{seriesName:e,xAxisIndex:i,yAxisIndex:s,dataArray:a,dataIndexOffset:n}=t,l=n||0,r=[];for(let d=0;d<a.length;d++){const c=a[d];if(!c)continue;const g=Array.isArray(c)?c:[c];for(const h of g)h&&typeof h=="object"&&!h._deleted&&r.push(h)}if(r.length===0)return{name:e,type:"custom",xAxisIndex:i,yAxisIndex:s,data:[],silent:!0};const o=(t.candlestickData?.length||0)+l,u=Math.max(0,o-1);return{name:e,type:"custom",xAxisIndex:i,yAxisIndex:s,renderItem:(d,c)=>{const g=[];for(const h of r){if(h._deleted)continue;const f=h.xloc==="bar_index"||h.xloc==="bi"?l:0,y=c.coord([h.left+f,h.top]),x=c.coord([h.right+f,h.bottom]);let b=y[0],D=y[1],w=x[0]-y[0],k=x[1]-y[1];const m=h.extend||"none";if(m!=="none"&&m!=="n"){const S=d.coordSys;(m==="left"||m==="l"||m==="both"||m==="b")&&(b=S.x,w=m==="both"||m==="b"?S.width:x[0]-S.x),(m==="right"||m==="r"||m==="both"||m==="b")&&(m==="right"||m==="r")&&(w=S.x+S.width-y[0])}const C=h.bgcolor,v=C==null||typeof C=="number"&&isNaN(C)||C==="na"||C==="NaN"||C===""?null:Yt(C)||"#2962ff";v&&g.push({type:"rect",shape:{x:b,y:D,width:w,height:k},style:{fill:v,stroke:"none"}});const _=h.border_color,A=_==null||typeof _=="number"&&isNaN(_)||_==="na"||_==="NaN"?null:Yt(_)||"#2962ff",M=h.border_width??1;if(M>0&&A&&g.push({type:"rect",shape:{x:b,y:D,width:w,height:k},style:{fill:"none",stroke:A,lineWidth:M,lineDash:this.getDashPattern(h.border_style)}}),h.text){const S=this.getTextX(b,w,h.text_halign),z=this.getTextY(D,k,h.text_valign);let W=Yt(h.text_color)||"#000000";if((!h.text_color||h.text_color==="#000000"||h.text_color==="black"||h.text_color==="color.black")&&v){const P=Ye(v);P&&Xe(P.r,P.g,P.b)<.5&&(W="#FFFFFF")}const I=!h.text_formatting||h.text_formatting==="format_none"||h.text_formatting==="format_bold",$=this.computeFontSize(h.text_size,h.text,Math.abs(w),Math.abs(k),I);g.push({type:"text",style:{x:S,y:z,text:h.text,fill:W,fontSize:$,fontFamily:h.text_font_family==="monospace"?"monospace":"sans-serif",fontWeight:I?"bold":"normal",fontStyle:h.text_formatting==="format_italic"?"italic":"normal",textAlign:this.mapHAlign(h.text_halign),textVerticalAlign:this.mapVAlign(h.text_valign)}})}}return{type:"group",children:g}},data:[[0,u]],clip:!0,encode:{x:[0,1]},itemStyle:{color:"transparent",borderColor:"transparent"},z:14,silent:!0,emphasis:{disabled:!0}}}getDashPattern(t){switch(t){case"style_dotted":return[2,2];case"style_dashed":return[6,4];default:return}}computeFontSize(t,e,i,s,a){if(typeof t=="number"&&t>0)return t;switch(t){case"tiny":case"size.tiny":return 8;case"small":case"size.small":return 10;case"normal":case"size.normal":return 14;case"large":case"size.large":return 20;case"huge":case"size.huge":return 36}if(!e||i<=0||s<=0)return 12;const n=6,l=i-n*2,r=s-n*2;if(l<=0||r<=0)return 6;const o=e.split(`
18
+ `),u=o.length;let d=1;for(const f of o)f.length>d&&(d=f.length);const c=l/(d*(a?.62:.55)),g=r/(u*1.3),h=Math.min(c,g);return Math.max(6,Math.min(h,48))}mapHAlign(t){switch(t){case"left":case"text.align_left":return"left";case"right":case"text.align_right":return"right";case"center":case"text.align_center":default:return"center"}}mapVAlign(t){switch(t){case"top":case"text.align_top":return"top";case"bottom":case"text.align_bottom":return"bottom";case"center":case"text.align_center":default:return"middle"}}getTextX(t,e,i){switch(i){case"left":case"text.align_left":return t+4;case"right":case"text.align_right":return t+e-4;case"center":case"text.align_center":default:return t+e/2}}getTextY(t,e,i){switch(i){case"top":case"text.align_top":return t+4;case"bottom":case"text.align_bottom":return t+e-4;case"center":case"text.align_center":default:return t+e/2}}}var qe=Object.defineProperty,Ue=(p,t,e)=>t in p?qe(p,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):p[t]=e,Ke=(p,t,e)=>(Ue(p,typeof t!="symbol"?t+"":t,e),e);const q=class{static register(t,e){this.renderers.set(t,e)}static get(t){return this.renderers.get(t)||this.renderers.get("line")}};Ke(q,"renderers",new Map),q.register("line",new Te),q.register("step",new Ne),q.register("histogram",new te),q.register("columns",new te),q.register("circles",new jt),q.register("cross",new jt),q.register("char",new jt),q.register("bar",new ee),q.register("candle",new ee),q.register("shape",new Fe),q.register("background",new Oe),q.register("fill",new ie),q.register("label",new He),q.register("drawing_line",new Re),q.register("linefill",new Be),q.register("drawing_polyline",new je),q.register("drawing_box",new Ve);let Je=q;var Qe=Object.defineProperty,ti=(p,t,e)=>t in p?Qe(p,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):p[t]=e,ei=(p,t,e)=>(ti(p,typeof t!="symbol"?t+"":t,e),e);const se=class Qt{static buildCandlestickSeries(t,e,i){const s=e.upColor||"#00da3c",a=e.downColor||"#ec0000",n=t.map(r=>[r.open,r.close,r.low,r.high]);if(i&&i>n.length){const r=i-n.length;for(let o=0;o<r;o++)n.push(null)}let l;if(e.lastPriceLine?.visible!==!1&&t.length>0){const r=t[t.length-1],o=r.close,u=r.close>=r.open,d=e.lastPriceLine?.color||(u?s:a);let c=e.lastPriceLine?.lineStyle||"dashed";c.startsWith("linestyle_")&&(c=c.replace("linestyle_",""));const g=e.yAxisDecimalPlaces!==void 0?e.yAxisDecimalPlaces:R.autoDetectDecimals(t);l={symbol:["none","none"],precision:g,data:[{yAxis:o,label:{show:!0,position:"end",formatter:h=>e.yAxisLabelFormatter?e.yAxisLabelFormatter(h.value):R.formatValue(h.value,g),color:"#fff",backgroundColor:d,padding:[2,4],borderRadius:2,fontSize:11,fontWeight:"bold"},lineStyle:{color:d,type:c,width:1,opacity:.8}}],animation:!1,silent:!0}}return{type:"candlestick",id:"__candlestick__",name:e.title,data:n,itemStyle:{color:s,color0:a,borderColor:s,borderColor0:a},markLine:l,xAxisIndex:0,yAxisIndex:0,z:5}}static buildIndicatorSeries(t,e,i,s,a=0,n,l,r=1){const o=[],u=new Array(s).fill(null),d=new Map;return t.forEach((c,g)=>{if(c.collapsed)return;const h=Object.keys(c.plots).sort((y,x)=>{const b=c.plots[y],D=c.plots[x],w=b.options.style==="fill",k=D.options.style==="fill";return w&&!k?1:!w&&k?-1:0}),f=new Map;if(h.forEach(y=>{const x=c.plots[y],b=x.options.display==="none",D=`${g}::${y}`;let w=0,k=0,m=x.options.overlay;if(x.options.style==="fill"&&m===void 0){const S=x.options.plot1,z=x.options.plot2;if(S&&z){const W=c.plots[S],I=c.plots[z];W?.options?.overlay===!0&&I?.options?.overlay===!0&&(m=!0)}}if(c.paneIndex===0||m===!0)w=0,l&&l.has(D)?k=l.get(D):k=0;else{const S=i.findIndex(z=>z.index===c.paneIndex);S!==-1&&(w=S+1,k=r+S)}const C=new Array(s).fill(null),v=new Array(s).fill(null),_=new Array(s).fill(null),A=new Array(s).fill(null);if(x.data?.forEach(S=>{const z=e.get(S.time);if(z!==void 0){const W=S.options?.offset??x.options.offset??0,I=z+a+W;if(I>=0&&I<s){let $=S.value;const P=S.options?.color;v[I]=$;const F=S.options!=null&&"color"in S.options,T=P===null||P==="na"||P==="NaN"||typeof P=="number"&&isNaN(P)||F&&P===void 0;T&&($=null),C[I]=$,_[I]=T?null:P||x.options.color||Qt.DEFAULT_COLOR,A[I]=S.options||{}}}}),d.set(`${g}::${y}`,v),b)return;if(x.options?.style?.startsWith("style_")&&(x.options.style=x.options.style.replace("style_","")),x.options.style==="barcolor"){x.data?.forEach(S=>{const z=e.get(S.time);if(z!==void 0){const W=S.options?.offset??x.options.offset??0,I=z+a+W;if(I>=0&&I<s){const $=S.options?.color||x.options.color||Qt.DEFAULT_COLOR;!($===null||$==="na"||$==="NaN"||typeof $=="number"&&isNaN($))&&S.value!==null&&S.value!==void 0&&(u[I]=$)}}});return}if(x.options.style==="table")return;if(x.options.style==="fill"&&x.options.gradient!==!0){const S=x.options.plot1?`${g}::${x.options.plot1}`:null,z=x.options.plot2?`${g}::${x.options.plot2}`:null;if(S&&z){const W=d.get(S),I=d.get(z);if(W&&I){const{color:$,opacity:P}=at.parseColor(x.options.color||"rgba(128, 128, 128, 0.2)"),F=A.some(Z=>Z&&Z.color!==void 0),T=[];for(let Z=0;Z<s;Z++){const N=A[Z];F&&N&&N.color!==void 0?T[Z]=at.parseColor(N.color):T[Z]={color:$,opacity:P}}const B=`${w}:${k}`;f.has(B)||f.set(B,{entries:[],xAxisIndex:w,yAxisIndex:k}),f.get(B).entries.push({plot1Data:W,plot2Data:I,barColors:T});return}}}if(x.options.color&&typeof x.options.color=="string"&&at.parseColor(x.options.color).opacity<.01&&!_.some(S=>S==null?!1:at.parseColor(S).opacity>=.01))return;const M=Je.get(x.options.style).render({seriesName:D,xAxisIndex:w,yAxisIndex:k,dataArray:C,colorArray:_,optionsArray:A,plotOptions:x.options,candlestickData:n,plotDataArrays:d,indicatorId:g,plotName:y,dataIndexOffset:a});M&&o.push(M)}),f.size>0){const y=new ie;f.forEach(({entries:x,xAxisIndex:b,yAxisIndex:D},w)=>{if(x.length>=2){const k=y.renderBatched(`${g}::fills_batch_${w}`,b,D,s,x);k&&o.push(k)}else if(x.length===1){const k=y.renderBatched(`${g}::fills_batch_${w}`,b,D,s,x);k&&o.push(k)}})}}),{series:o,barColors:u}}};ei(se,"DEFAULT_COLOR","#2962ff");let wt=se;class ii{static build(t,e,i,s=!1,a=null,n=[]){const l=[],r=t.pixelToPercent,o=t.mainPaneTop;if(!a||a==="main"){const u=10*r;if(l.push({type:"text",left:"8.5%",top:o+u+"%",z:10,style:{text:e.title||"",fill:e.titleColor||"#fff",font:`bold 16px ${e.fontFamily||"sans-serif"}`,textVerticalAlign:"top"}}),n.length>0){const c=20*r,g=16*r;n.forEach((h,f)=>{l.push({type:"text",left:"8.5%",top:o+u+c+f*g+"%",z:10,style:{text:h.id,fill:h.titleColor||"#9e9e9e",font:`bold 12px ${e.fontFamily||"sans-serif"}`,textVerticalAlign:"top"}})})}if(e.watermark!==!1){const c=t.mainPaneTop+t.mainPaneHeight;l.push({type:"text",right:"11%",top:c-3+"%",z:10,style:{text:"QFChart",fill:e.fontColor||"#cbd5e1",font:"bold 16px sans-serif",opacity:.1},cursor:"pointer",onclick:()=>{window.open("https://quantforge.org","_blank")}})}const d=[];if(e.controls?.collapse&&d.push({type:"group",children:[{type:"rect",shape:{width:20,height:20,r:2},style:{fill:"#334155",stroke:"#475569",lineWidth:1},onclick:()=>i("main","collapse")},{type:"text",style:{text:s?"+":"\u2212",fill:"#cbd5e1",font:`bold 14px ${e.fontFamily}`,x:10,y:10,textAlign:"center",textVerticalAlign:"middle"},silent:!0}]}),e.controls?.maximize){const c=a==="main",g=e.controls?.collapse?25:0;d.push({type:"group",x:g,children:[{type:"rect",shape:{width:20,height:20,r:2},style:{fill:"#334155",stroke:"#475569",lineWidth:1},onclick:()=>i("main","maximize")},{type:"text",style:{text:c?"\u2750":"\u25A1",fill:"#cbd5e1",font:`14px ${e.fontFamily}`,x:10,y:10,textAlign:"center",textVerticalAlign:"middle"},silent:!0}]})}if(e.controls?.fullscreen){let c=0;e.controls?.collapse&&(c+=25),e.controls?.maximize&&(c+=25),d.push({type:"group",x:c,children:[{type:"rect",shape:{width:20,height:20,r:2},style:{fill:"#334155",stroke:"#475569",lineWidth:1},onclick:()=>i("main","fullscreen")},{type:"text",style:{text:"\u26F6",fill:"#cbd5e1",font:`14px ${e.fontFamily}`,x:10,y:10,textAlign:"center",textVerticalAlign:"middle"},silent:!0}]})}d.length>0&&l.push({type:"group",right:"10.5%",top:o+"%",children:d})}return t.paneLayout.forEach(u=>{if(a&&u.indicatorId!==a)return;l.push({type:"text",left:"8.5%",top:u.top+10*r+"%",z:10,style:{text:u.indicatorId||"",fill:u.titleColor||"#fff",font:`bold 12px ${e.fontFamily||"sans-serif"}`,textVerticalAlign:"top"}});const d=[];if(u.controls?.collapse&&d.push({type:"group",children:[{type:"rect",shape:{width:20,height:20,r:2},style:{fill:"#334155",stroke:"#475569",lineWidth:1},onclick:()=>u.indicatorId&&i(u.indicatorId,"collapse")},{type:"text",style:{text:u.isCollapsed?"+":"\u2212",fill:"#cbd5e1",font:`bold 14px ${e.fontFamily}`,x:10,y:10,textAlign:"center",textVerticalAlign:"middle"},silent:!0}]}),u.controls?.maximize){const c=a===u.indicatorId,g=u.controls?.collapse?25:0;d.push({type:"group",x:g,children:[{type:"rect",shape:{width:20,height:20,r:2},style:{fill:"#334155",stroke:"#475569",lineWidth:1},onclick:()=>u.indicatorId&&i(u.indicatorId,"maximize")},{type:"text",style:{text:c?"\u2750":"\u25A1",fill:"#cbd5e1",font:`14px ${e.fontFamily}`,x:10,y:10,textAlign:"center",textVerticalAlign:"middle"},silent:!0}]})}d.length>0&&l.push({type:"group",right:"10.5%",top:u.top+"%",children:d})}),l}}class si{static format(t,e){if(!t||t.length===0)return"";const i=e.title||"",s=e.upColor||"#00da3c",a=e.downColor||"#ec0000",n=e.fontFamily||"sans-serif",l=t[0].axisValue;let r=`<div style="font-weight: bold; margin-bottom: 5px; color: #cbd5e1; font-family: ${n};">${l}</div>`;const o=t.find(d=>d.seriesType==="candlestick"),u=t.filter(d=>d.seriesType!=="candlestick");if(o){const[d,c,g,h,f]=o.value,y=g>=c?s:a;r+=`
19
+ <div style="margin-bottom: 8px; font-family: ${n};">
20
+ <div style="display:flex; justify-content:space-between; color:${y}; font-weight:bold;">
20
21
  <span>${i}</span>
21
22
  </div>
22
23
  <div style="display: grid; grid-template-columns: auto auto; gap: 2px 15px; font-size: 0.9em; color: #cbd5e1;">
23
- <span>Open:</span> <span style="text-align: right; color: ${h>=l?s:a}">${l}</span>
24
- <span>High:</span> <span style="text-align: right; color: ${s}">${c}</span>
25
- <span>Low:</span> <span style="text-align: right; color: ${a}">${n}</span>
26
- <span>Close:</span> <span style="text-align: right; color: ${h>=l?s:a}">${h}</span>
24
+ <span>Open:</span> <span style="text-align: right; color: ${g>=c?s:a}">${c}</span>
25
+ <span>High:</span> <span style="text-align: right; color: ${s}">${f}</span>
26
+ <span>Low:</span> <span style="text-align: right; color: ${a}">${h}</span>
27
+ <span>Close:</span> <span style="text-align: right; color: ${g>=c?s:a}">${g}</span>
27
28
  </div>
28
29
  </div>
29
- `}if(g.length>0){d+='<div style="border-top: 1px solid #334155; margin: 5px 0; padding-top: 5px;"></div>';const r={};g.forEach(l=>{const h=l.seriesName.split("::"),n=h.length>1?h[0]:"Unknown",c=h.length>1?h[1]:l.seriesName;r[n]||(r[n]=[]),r[n].push({...l,displayName:c})}),Object.keys(r).forEach(l=>{d+=`
30
- <div style="margin-top: 8px; font-family: ${o};">
31
- <div style="font-weight:bold; color: #fff; margin-bottom: 2px;">${l}</div>
32
- `,r[l].forEach(h=>{let n=h.value;if(Array.isArray(n)&&(n=n[1]),n==null)return;const c=typeof n=="number"?n.toLocaleString(void 0,{maximumFractionDigits:4}):n;d+=`
30
+ `}if(u.length>0){r+='<div style="border-top: 1px solid #334155; margin: 5px 0; padding-top: 5px;"></div>';const d={};u.forEach(c=>{const g=c.seriesName.split("::"),h=g.length>1?g[0]:"Unknown",f=g.length>1?g[1]:c.seriesName;d[h]||(d[h]=[]),d[h].push({...c,displayName:f})}),Object.keys(d).forEach(c=>{r+=`
31
+ <div style="margin-top: 8px; font-family: ${n};">
32
+ <div style="font-weight:bold; color: #fff; margin-bottom: 2px;">${c}</div>
33
+ `,d[c].forEach(g=>{let h=g.value;if(Array.isArray(h)&&(h=h[1]),h==null)return;const f=typeof h=="number"?h.toLocaleString(void 0,{maximumFractionDigits:4}):h;r+=`
33
34
  <div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 2px; padding-left: 8px;">
34
- <div>${h.marker} <span style="color: #cbd5e1;">${h.displayName}</span></div>
35
- <div style="font-size: 10px; color: #fff;padding-left:10px;">${c}</div>
36
- </div>`}),d+="</div>"})}return d}}var Xt=Object.defineProperty,Ut=(x,t,e)=>t in x?Xt(x,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):x[t]=e,dt=(x,t,e)=>(Ut(x,typeof t!="symbol"?t+"":t,e),e);class Jt{constructor(t,e){dt(this,"plugins",new Map),dt(this,"activePluginId",null),dt(this,"context"),dt(this,"toolbarContainer"),dt(this,"tooltipElement",null),dt(this,"hideTimeout",null),this.context=t,this.toolbarContainer=e,this.createTooltip(),this.renderToolbar()}createTooltip(){this.tooltipElement=document.createElement("div"),Object.assign(this.tooltipElement.style,{position:"fixed",display:"none",backgroundColor:"#1e293b",color:"#e2e8f0",padding:"6px 10px",borderRadius:"6px",fontSize:"13px",lineHeight:"1.4",fontWeight:"500",border:"1px solid #334155",zIndex:"9999",pointerEvents:"none",whiteSpace:"nowrap",boxShadow:"0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.15)",fontFamily:this.context.getOptions().fontFamily||"sans-serif",transition:"opacity 0.15s ease-in-out, transform 0.15s ease-in-out",opacity:"0",transform:"translateX(-5px)"}),document.body.appendChild(this.tooltipElement)}destroy(){this.tooltipElement&&this.tooltipElement.parentNode&&this.tooltipElement.parentNode.removeChild(this.tooltipElement),this.tooltipElement=null}showTooltip(t,e){if(!this.tooltipElement)return;this.hideTimeout&&(clearTimeout(this.hideTimeout),this.hideTimeout=null);const i=t.getBoundingClientRect();this.tooltipElement.textContent=e,this.tooltipElement.style.display="block";const s=this.tooltipElement.getBoundingClientRect(),a=i.top+(i.height-s.height)/2,o=i.right+10;this.tooltipElement.style.top=`${a}px`,this.tooltipElement.style.left=`${o}px`,requestAnimationFrame(()=>{this.tooltipElement&&(this.tooltipElement.style.opacity="1",this.tooltipElement.style.transform="translateX(0)")})}hideTooltip(){this.tooltipElement&&(this.tooltipElement.style.opacity="0",this.tooltipElement.style.transform="translateX(-5px)",this.hideTimeout&&clearTimeout(this.hideTimeout),this.hideTimeout=setTimeout(()=>{this.tooltipElement&&(this.tooltipElement.style.display="none"),this.hideTimeout=null},150))}register(t){if(this.plugins.has(t.id)){console.warn(`Plugin with id ${t.id} is already registered.`);return}this.plugins.set(t.id,t),t.init(this.context),this.addButton(t)}unregister(t){const e=this.plugins.get(t);e&&(this.activePluginId===t&&this.deactivatePlugin(),e.destroy?.(),this.plugins.delete(t),this.removeButton(t))}activatePlugin(t){if(this.activePluginId===t){this.deactivatePlugin();return}this.activePluginId&&this.deactivatePlugin();const e=this.plugins.get(t);e&&(this.activePluginId=t,this.setButtonActive(t,!0),e.activate?.())}deactivatePlugin(){this.activePluginId&&(this.plugins.get(this.activePluginId)?.deactivate?.(),this.setButtonActive(this.activePluginId,!1),this.activePluginId=null)}renderToolbar(){this.toolbarContainer.innerHTML="",this.toolbarContainer.classList.add("qfchart-toolbar"),this.toolbarContainer.style.display="flex",this.toolbarContainer.style.flexDirection="column",this.toolbarContainer.style.width="40px",this.toolbarContainer.style.backgroundColor=this.context.getOptions().backgroundColor||"#1e293b",this.toolbarContainer.style.borderRight="1px solid #334155",this.toolbarContainer.style.padding="5px",this.toolbarContainer.style.boxSizing="border-box",this.toolbarContainer.style.gap="5px",this.toolbarContainer.style.flexShrink="0"}addButton(t){const e=document.createElement("button");e.id=`qfchart-plugin-btn-${t.id}`,e.style.width="30px",e.style.height="30px",e.style.padding="4px",e.style.border="1px solid transparent",e.style.borderRadius="4px",e.style.backgroundColor="transparent",e.style.cursor="pointer",e.style.color=this.context.getOptions().fontColor||"#cbd5e1",e.style.display="flex",e.style.alignItems="center",e.style.justifyContent="center",t.icon?e.innerHTML=t.icon:e.innerText=(t.name||t.id).substring(0,2).toUpperCase(),e.addEventListener("mouseenter",()=>{this.activePluginId!==t.id&&(e.style.backgroundColor="rgba(255, 255, 255, 0.1)"),this.showTooltip(e,t.name||t.id)}),e.addEventListener("mouseleave",()=>{this.activePluginId!==t.id&&(e.style.backgroundColor="transparent"),this.hideTooltip()}),e.onclick=()=>this.activatePlugin(t.id),this.toolbarContainer.appendChild(e)}removeButton(t){const e=this.toolbarContainer.querySelector(`#qfchart-plugin-btn-${t}`);e&&e.remove()}setButtonActive(t,e){const i=this.toolbarContainer.querySelector(`#qfchart-plugin-btn-${t}`);i&&(e?(i.style.backgroundColor="#2563eb",i.style.color="#ffffff"):(i.style.backgroundColor="transparent",i.style.color=this.context.getOptions().fontColor||"#cbd5e1"))}}var Kt=Object.defineProperty,Qt=(x,t,e)=>t in x?Kt(x,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):x[t]=e,X=(x,t,e)=>(Qt(x,typeof t!="symbol"?t+"":t,e),e);class te{constructor(t){X(this,"context"),X(this,"isEditing",!1),X(this,"currentDrawing",null),X(this,"editingPointIndex",null),X(this,"zr"),X(this,"editGroup",null),X(this,"editLine",null),X(this,"editStartPoint",null),X(this,"editEndPoint",null),X(this,"isMovingShape",!1),X(this,"dragStart",null),X(this,"initialPixelPoints",[]),X(this,"onDrawingMouseDown",e=>{if(this.isEditing)return;const i=this.context.getDrawing(e.id);i&&(this.isEditing=!0,this.isMovingShape=!0,this.currentDrawing=JSON.parse(JSON.stringify(i)),this.dragStart={x:e.x,y:e.y},this.initialPixelPoints=i.points.map(s=>{const a=this.context.coordinateConversion.dataToPixel(s);return a?{x:a.x,y:a.y}:{x:0,y:0}}),this.context.lockChart(),this.createEditGraphic(),this.zr.on("mousemove",this.onMouseMove),this.zr.on("mouseup",this.onMouseUp))}),X(this,"onPointMouseDown",e=>{if(this.isEditing)return;const i=this.context.getDrawing(e.id);i&&(this.isEditing=!0,this.currentDrawing=JSON.parse(JSON.stringify(i)),this.editingPointIndex=e.pointIndex,this.context.lockChart(),this.createEditGraphic(),this.zr.on("mousemove",this.onMouseMove),this.zr.on("mouseup",this.onMouseUp))}),X(this,"onMouseMove",e=>{if(!this.isEditing||!this.currentDrawing)return;const i=e.offsetX,s=e.offsetY;if(this.isMovingShape&&this.dragStart){const a=i-this.dragStart.x,o=s-this.dragStart.y,u={x:this.initialPixelPoints[0].x+a,y:this.initialPixelPoints[0].y+o},d={x:this.initialPixelPoints[1].x+a,y:this.initialPixelPoints[1].y+o};this.editLine.setShape({x1:u.x,y1:u.y,x2:d.x,y2:d.y}),this.editStartPoint.setShape({cx:u.x,cy:u.y}),this.editEndPoint.setShape({cx:d.x,cy:d.y})}else this.editingPointIndex!==null&&(this.editingPointIndex===0?(this.editLine.setShape({x1:i,y1:s}),this.editStartPoint.setShape({cx:i,cy:s})):(this.editLine.setShape({x2:i,y2:s}),this.editEndPoint.setShape({cx:i,cy:s})))}),X(this,"onMouseUp",e=>{this.isEditing&&this.finishEditing(e.offsetX,e.offsetY)}),this.context=t,this.zr=this.context.getChart().getZr(),this.bindEvents()}bindEvents(){this.context.events.on("drawing:point:mousedown",this.onPointMouseDown),this.context.events.on("drawing:mousedown",this.onDrawingMouseDown)}createEditGraphic(){if(!this.currentDrawing)return;this.editGroup=new B.graphic.Group;const t=this.currentDrawing.points[0],e=this.currentDrawing.points[1],i=this.context.coordinateConversion.dataToPixel(t),s=this.context.coordinateConversion.dataToPixel(e);!i||!s||(this.editLine=new B.graphic.Line({shape:{x1:i.x,y1:i.y,x2:s.x,y2:s.y},style:{stroke:this.currentDrawing.style?.color||"#3b82f6",lineWidth:this.currentDrawing.style?.lineWidth||2,lineDash:[4,4]},silent:!0}),this.editStartPoint=new B.graphic.Circle({shape:{cx:i.x,cy:i.y,r:5},style:{fill:"#fff",stroke:"#3b82f6",lineWidth:2},z:1e3}),this.editEndPoint=new B.graphic.Circle({shape:{cx:s.x,cy:s.y,r:5},style:{fill:"#fff",stroke:"#3b82f6",lineWidth:2},z:1e3}),this.editGroup.add(this.editLine),this.editGroup.add(this.editStartPoint),this.editGroup.add(this.editEndPoint),this.zr.add(this.editGroup))}finishEditing(t,e){if(this.currentDrawing){if(this.isMovingShape&&this.dragStart){const i=t-this.dragStart.x,s=e-this.dragStart.y,a=this.initialPixelPoints.map((o,u)=>{const d=o.x+i,p=o.y+s;return this.context.coordinateConversion.pixelToData({x:d,y:p})});a.every(o=>o!==null)&&a[0]&&a[1]&&(this.currentDrawing.points[0]=a[0],this.currentDrawing.points[1]=a[1],a[0].paneIndex!==void 0&&(this.currentDrawing.paneIndex=a[0].paneIndex),this.context.updateDrawing(this.currentDrawing))}else if(this.editingPointIndex!==null){const i=this.context.coordinateConversion.pixelToData({x:t,y:e});i&&(this.currentDrawing.points[this.editingPointIndex]=i,this.editingPointIndex===0&&i.paneIndex!==void 0&&(this.currentDrawing.paneIndex=i.paneIndex),this.context.updateDrawing(this.currentDrawing))}this.isEditing=!1,this.isMovingShape=!1,this.dragStart=null,this.initialPixelPoints=[],this.currentDrawing=null,this.editingPointIndex=null,this.editGroup&&(this.zr.remove(this.editGroup),this.editGroup=null),this.zr.off("mousemove",this.onMouseMove),this.zr.off("mouseup",this.onMouseUp),this.context.unlockChart()}}}var ee=Object.defineProperty,ie=(x,t,e)=>t in x?ee(x,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):x[t]=e,se=(x,t,e)=>(ie(x,typeof t!="symbol"?t+"":t,e),e);class ne{constructor(){se(this,"handlers",new Map)}on(t,e){this.handlers.has(t)||this.handlers.set(t,new Set),this.handlers.get(t).add(e)}off(t,e){const i=this.handlers.get(t);i&&i.delete(e)}emit(t,e){const i=this.handlers.get(t);i&&i.forEach(s=>{try{s(e)}catch(a){console.error(`Error in EventBus handler for ${t}:`,a)}})}clear(){this.handlers.clear()}}class Q{static safeParseColor(t){if(!t||typeof t!="string")return{color:"#888888",opacity:1};const e=t.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?\)/);if(e){const i=e[4]?parseFloat(e[4]):1;return{color:`rgb(${e[1]},${e[2]},${e[3]})`,opacity:i}}return{color:t,opacity:1}}static render(t,e,i){Q.clearAll(t);const s=new Map;for(const a of e)a&&!a._deleted&&s.set(a.position,a);s.forEach(a=>{const o=a._paneIndex??0,u=i?i(o):void 0,d=Q.buildTable(a);Q.positionTable(d,a.position,u),t.appendChild(d)})}static clearAll(t){for(;t.firstChild;)t.removeChild(t.firstChild)}static buildTable(t){const e=document.createElement("table"),i=t.border_width??0,s=t.frame_width??0;if(i>0&&t.border_color||s>0&&t.frame_color?(e.style.borderCollapse="separate",e.style.borderSpacing="0"):e.style.borderCollapse="collapse",e.style.pointerEvents="none",e.style.fontSize="14px",e.style.lineHeight="1.4",e.style.fontFamily="sans-serif",e.style.margin="4px",t.bgcolor){const{color:r,opacity:l}=Q.safeParseColor(t.bgcolor);e.style.backgroundColor=r,l<1&&(e.style.opacity=String(l))}if(s>0&&t.frame_color){const{color:r}=Q.safeParseColor(t.frame_color);e.style.border=`${s}px solid ${r}`}else e.style.border="none";const a=new Map,o=new Set;if(t.merges)for(const r of t.merges){const l=`${r.startCol},${r.startRow}`;a.set(l,{colspan:r.endCol-r.startCol+1,rowspan:r.endRow-r.startRow+1});for(let h=r.startRow;h<=r.endRow;h++)for(let n=r.startCol;n<=r.endCol;n++)h===r.startRow&&n===r.startCol||o.add(`${n},${h}`)}const u=i>0&&!!t.border_color,d=u?Q.safeParseColor(t.border_color).color:"",p=t.rows||0,g=t.columns||0;for(let r=0;r<p;r++){const l=document.createElement("tr");for(let h=0;h<g;h++){const n=`${h},${r}`;if(o.has(n))continue;const c=document.createElement("td"),f=a.get(n);f&&(f.colspan>1&&(c.colSpan=f.colspan),f.rowspan>1&&(c.rowSpan=f.rowspan)),u?c.style.border=`${i}px solid ${d}`:c.style.border="none";const m=t.cells?.[r]?.[h];if(m&&!m._merged){if(c.textContent=m.text||"",m.bgcolor){const{color:w,opacity:C}=Q.safeParseColor(m.bgcolor);c.style.backgroundColor=w,C<1&&(c.style.backgroundColor=m.bgcolor)}if(m.text_color){const{color:w}=Q.safeParseColor(m.text_color);c.style.color=w}c.style.fontSize=Q.getSizePixels(m.text_size)+"px",c.style.textAlign=Q.mapHAlign(m.text_halign),c.style.verticalAlign=Q.mapVAlign(m.text_valign),m.text_font_family==="monospace"&&(c.style.fontFamily="monospace"),m.width>0&&(c.style.width=m.width+"%"),m.height>0&&(c.style.height=m.height+"%"),m.tooltip&&(c.title=m.tooltip)}c.style.padding="4px 6px",c.style.whiteSpace="nowrap",l.appendChild(c)}e.appendChild(l)}return e}static positionTable(t,e,i){t.style.position="absolute";const s=8,a=i?i.y+"px":"0",o=i?i.x+"px":"0",u=i?i.y+i.height-s+"px":"0",d=i?i.x+i.width-s+"px":"0",p=i?i.x+i.width/2+"px":"50%",g=i?i.y+i.height/2+"px":"50%";switch(e){case"top_left":t.style.top=a,t.style.left=o;break;case"top_center":t.style.top=a,t.style.left=p,t.style.transform="translateX(-50%)";break;case"top_right":t.style.top=a,t.style.left=d,t.style.transform="translateX(-100%)";break;case"middle_left":t.style.top=g,t.style.left=o,t.style.transform="translateY(-50%)";break;case"middle_center":t.style.top=g,t.style.left=p,t.style.transform="translate(-50%, -50%)";break;case"middle_right":t.style.top=g,t.style.left=d,t.style.transform="translate(-100%, -50%)";break;case"bottom_left":t.style.top=u,t.style.left=o,t.style.transform="translateY(-100%)";break;case"bottom_center":t.style.top=u,t.style.left=p,t.style.transform="translate(-50%, -100%)";break;case"bottom_right":t.style.top=u,t.style.left=d,t.style.transform="translate(-100%, -100%)";break;default:t.style.top=a,t.style.left=d,t.style.transform="translateX(-100%)";break}}static getSizePixels(t){if(typeof t=="number"&&t>0)return t;switch(t){case"auto":case"size.auto":return 12;case"tiny":case"size.tiny":return 8;case"small":case"size.small":return 10;case"normal":case"size.normal":return 14;case"large":case"size.large":return 20;case"huge":case"size.huge":return 36;default:return 14}}static mapHAlign(t){switch(t){case"left":case"text.align_left":return"left";case"right":case"text.align_right":return"right";case"center":case"text.align_center":default:return"center"}}static mapVAlign(t){switch(t){case"top":case"text.align_top":return"top";case"bottom":case"text.align_bottom":return"bottom";case"center":case"text.align_center":default:return"middle"}}}var oe=Object.defineProperty,ae=(x,t,e)=>t in x?oe(x,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):x[t]=e,z=(x,t,e)=>(ae(x,typeof t!="symbol"?t+"":t,e),e);class re{constructor(t,e={}){z(this,"chart"),z(this,"options"),z(this,"marketData",[]),z(this,"indicators",new Map),z(this,"timeToIndex",new Map),z(this,"pluginManager"),z(this,"drawingEditor"),z(this,"events",new ne),z(this,"isMainCollapsed",!1),z(this,"maximizedPaneId",null),z(this,"countdownInterval",null),z(this,"selectedDrawingId",null),z(this,"drawings",[]),z(this,"coordinateConversion",{pixelToData:o=>{const u=this.chart.getOption();if(!u||!u.grid)return null;const d=u.grid.length;for(let p=0;p<d;p++)if(this.chart.containPixel({gridIndex:p},[o.x,o.y])){this.chart.convertFromPixel({seriesIndex:p},[o.x,o.y]);const g=this.chart.convertFromPixel({gridIndex:p},[o.x,o.y]);if(g)return{timeIndex:Math.round(g[0]),value:g[1],paneIndex:p}}return null},dataToPixel:o=>{const u=o.paneIndex||0,d=this.chart.convertToPixel({gridIndex:u},[o.timeIndex,o.value]);return d?{x:d[0],y:d[1]}:null}}),z(this,"upColor","#00da3c"),z(this,"downColor","#ec0000"),z(this,"defaultPadding",0),z(this,"padding"),z(this,"dataIndexOffset",0),z(this,"rootContainer"),z(this,"layoutContainer"),z(this,"toolbarContainer"),z(this,"leftSidebar"),z(this,"rightSidebar"),z(this,"chartContainer"),z(this,"overlayContainer"),z(this,"_lastTables",[]),z(this,"_lastLayout",null),z(this,"_mainHeightOverride",null),z(this,"_paneDragState",null),z(this,"_paneResizeRafId",null),z(this,"onKeyDown",o=>{(o.key==="Delete"||o.key==="Backspace")&&this.selectedDrawingId&&(this.removeDrawing(this.selectedDrawingId),this.selectedDrawingId=null,this.render())}),z(this,"onFullscreenChange",()=>{this.render()}),z(this,"isLocked",!1),z(this,"lockedState",null),this.rootContainer=t,this.options={title:"Market",height:"600px",backgroundColor:"#1e293b",upColor:"#00da3c",downColor:"#ec0000",fontColor:"#cbd5e1",fontFamily:"sans-serif",padding:.01,dataZoom:{visible:!0,position:"top",height:6},layout:{mainPaneHeight:"50%",gap:13},watermark:!0,...e},this.options.upColor&&(this.upColor=this.options.upColor),this.options.downColor&&(this.downColor=this.options.downColor),this.padding=this.options.padding!==void 0?this.options.padding:this.defaultPadding,this.options.height&&(typeof this.options.height=="number"?this.rootContainer.style.height=`${this.options.height}px`:this.rootContainer.style.height=this.options.height),this.rootContainer.innerHTML="",this.layoutContainer=document.createElement("div"),this.layoutContainer.style.display="flex",this.layoutContainer.style.width="100%",this.layoutContainer.style.height="100%",this.layoutContainer.style.overflow="hidden",this.rootContainer.appendChild(this.layoutContainer),this.leftSidebar=document.createElement("div"),this.leftSidebar.style.display="none",this.leftSidebar.style.width="250px",this.leftSidebar.style.flexShrink="0",this.leftSidebar.style.overflowY="auto",this.leftSidebar.style.backgroundColor=this.options.backgroundColor||"#1e293b",this.leftSidebar.style.borderRight="1px solid #334155",this.leftSidebar.style.padding="10px",this.leftSidebar.style.boxSizing="border-box",this.leftSidebar.style.color="#cbd5e1",this.leftSidebar.style.fontSize="12px",this.leftSidebar.style.fontFamily=this.options.fontFamily||"sans-serif",this.layoutContainer.appendChild(this.leftSidebar),this.toolbarContainer=document.createElement("div"),this.layoutContainer.appendChild(this.toolbarContainer),this.chartContainer=document.createElement("div"),this.chartContainer.style.flexGrow="1",this.chartContainer.style.height="100%",this.chartContainer.style.overflow="hidden",this.layoutContainer.appendChild(this.chartContainer),this.rightSidebar=document.createElement("div"),this.rightSidebar.style.display="none",this.rightSidebar.style.width="250px",this.rightSidebar.style.flexShrink="0",this.rightSidebar.style.overflowY="auto",this.rightSidebar.style.backgroundColor=this.options.backgroundColor||"#1e293b",this.rightSidebar.style.borderLeft="1px solid #334155",this.rightSidebar.style.padding="10px",this.rightSidebar.style.boxSizing="border-box",this.rightSidebar.style.color="#cbd5e1",this.rightSidebar.style.fontSize="12px",this.rightSidebar.style.fontFamily=this.options.fontFamily||"sans-serif",this.layoutContainer.appendChild(this.rightSidebar),this.chart=B.init(this.chartContainer),this.chartContainer.style.position="relative",this.overlayContainer=document.createElement("div"),this.overlayContainer.style.cssText="position:absolute;top:0;left:0;width:100%;height:100%;pointer-events:none;z-index:100;overflow:hidden;",this.chartContainer.appendChild(this.overlayContainer),this.pluginManager=new Jt(this,this.toolbarContainer),this.drawingEditor=new te(this),this.chart.on("dataZoom",o=>{this.events.emit("chart:dataZoom",o);const u=this.options.databox?.triggerOn,d=this.options.databox?.position;u==="click"&&d==="floating"&&this.chart.dispatchAction({type:"hideTip"})}),this.chart.on("finished",o=>this.events.emit("chart:updated",o)),this.chart.getZr().on("mousedown",o=>{this._paneDragState||this.events.emit("mouse:down",o)}),this.chart.getZr().on("mousemove",o=>{this._paneDragState||this.events.emit("mouse:move",o)}),this.chart.getZr().on("mouseup",o=>this.events.emit("mouse:up",o)),this.chart.getZr().on("click",o=>{this._paneDragState||this.events.emit("mouse:click",o)});const i=this.chart.getZr(),s=i.setCursorStyle,a=this;i.setCursorStyle=function(o){if(a._paneDragState){s.call(this,"row-resize");return}o==="grab"&&(o="crosshair"),s.call(this,o)},this.bindDrawingEvents(),this.bindPaneResizeEvents(),window.addEventListener("resize",this.resize.bind(this)),document.addEventListener("fullscreenchange",this.onFullscreenChange),document.addEventListener("keydown",this.onKeyDown)}bindPaneResizeEvents(){const t=this.chart.getZr(),e=s=>{if(!this._lastLayout||this._lastLayout.paneBoundaries.length===0||this.maximizedPaneId)return null;const a=this.chart.getHeight();if(a<=0)return null;for(const o of this._lastLayout.paneBoundaries){const u=o.yPercent/100*a;if(Math.abs(s-u)<=6){if(o.aboveId==="main"&&this.isMainCollapsed||this.indicators.get(o.belowId)?.collapsed||o.aboveId!=="main"&&this.indicators.get(o.aboveId)?.collapsed)continue;return o}}return null},i=s=>s==="main"?this._lastLayout?.mainPaneHeight??50:this.indicators.get(s)?.height??15;t.on("mousemove",s=>{if(this._paneDragState){const a=s.offsetY-this._paneDragState.startY,o=this.chart.getHeight();if(o<=0)return;const u=a/o*100,d=this._paneDragState.aboveId==="main"?10:5,p=5;let g=this._paneDragState.startAboveHeight+u,r=this._paneDragState.startBelowHeight-u;if(g<d&&(g=d,r=this._paneDragState.startAboveHeight+this._paneDragState.startBelowHeight-d),r<p&&(r=p,g=this._paneDragState.startAboveHeight+this._paneDragState.startBelowHeight-p),this._paneDragState.aboveId==="main")this._mainHeightOverride=g;else{const h=this.indicators.get(this._paneDragState.aboveId);h&&(h.height=g)}const l=this.indicators.get(this._paneDragState.belowId);l&&(l.height=r),this._paneResizeRafId||(this._paneResizeRafId=requestAnimationFrame(()=>{this._paneResizeRafId=null,this.render()})),t.setCursorStyle("row-resize"),s.stop?.();return}e(s.offsetY)&&t.setCursorStyle("row-resize")}),t.on("mousedown",s=>{const a=e(s.offsetY);a&&(this._paneDragState={startY:s.offsetY,aboveId:a.aboveId,belowId:a.belowId,startAboveHeight:i(a.aboveId),startBelowHeight:i(a.belowId)},t.setCursorStyle("row-resize"),s.stop?.())}),t.on("mouseup",()=>{this._paneDragState&&(this._paneDragState=null,this._paneResizeRafId&&(cancelAnimationFrame(this._paneResizeRafId),this._paneResizeRafId=null),this.render())})}bindDrawingEvents(){let t=null;const e=i=>{if(!i||i.componentType!=="series"||!i.seriesName?.startsWith("drawings"))return null;i.seriesIndex;const s=i.seriesName.match(/drawings-pane-(\d+)/);if(!s)return null;const a=parseInt(s[1]),o=this.drawings.filter(d=>(d.paneIndex||0)===a)[i.dataIndex];if(!o)return null;const u=i.event?.target?.name;return{drawing:o,targetName:u,paneIdx:a}};this.chart.on("mouseover",i=>{const s=e(i);if(!s)return;const a=i.event?.target?.parent;if(a){const o=s.drawing.id===this.selectedDrawingId;t&&(clearTimeout(t),t=null),o||a.children().forEach(u=>{u.name&&u.name.startsWith("point")&&u.attr("style",{opacity:1})})}if(s.targetName==="line")this.events.emit("drawing:hover",{id:s.drawing.id,type:s.drawing.type}),this.chart.getZr().setCursorStyle("move");else if(s.targetName?.startsWith("point")){const o=s.targetName==="point-start"?0:1;this.events.emit("drawing:point:hover",{id:s.drawing.id,pointIndex:o}),this.chart.getZr().setCursorStyle("pointer")}}),this.chart.on("mouseout",i=>{const s=e(i);if(!s)return;const a=i.event?.target?.parent;if(s.drawing.id!==this.selectedDrawingId){if(t=setTimeout(()=>{if(a){if(this.selectedDrawingId===s.drawing.id)return;a.children().forEach(o=>{o.name&&o.name.startsWith("point")&&o.attr("style",{opacity:0})})}},50),s.targetName==="line")this.events.emit("drawing:mouseout",{id:s.drawing.id});else if(s.targetName?.startsWith("point")){const o=s.targetName==="point-start"?0:1;this.events.emit("drawing:point:mouseout",{id:s.drawing.id,pointIndex:o})}this.chart.getZr().setCursorStyle("default")}}),this.chart.on("mousedown",i=>{const s=e(i);if(!s)return;const a=i.event?.event||i.event,o=a?.offsetX,u=a?.offsetY;if(s.targetName==="line")this.events.emit("drawing:mousedown",{id:s.drawing.id,x:o,y:u});else if(s.targetName?.startsWith("point")){const d=s.targetName==="point-start"?0:1;this.events.emit("drawing:point:mousedown",{id:s.drawing.id,pointIndex:d,x:o,y:u})}}),this.chart.on("click",i=>{const s=e(i);if(s){if(this.selectedDrawingId!==s.drawing.id&&(this.selectedDrawingId=s.drawing.id,this.events.emit("drawing:selected",{id:s.drawing.id}),this.render()),s.targetName==="line")this.events.emit("drawing:click",{id:s.drawing.id});else if(s.targetName?.startsWith("point")){const a=s.targetName==="point-start"?0:1;this.events.emit("drawing:point:click",{id:s.drawing.id,pointIndex:a})}}}),this.chart.getZr().on("click",i=>{i.target||this.selectedDrawingId&&(this.events.emit("drawing:deselected",{id:this.selectedDrawingId}),this.selectedDrawingId=null,this.render())})}getChart(){return this.chart}getMarketData(){return this.marketData}getTimeToIndex(){return this.timeToIndex}getOptions(){return this.options}disableTools(){this.pluginManager.deactivatePlugin()}registerPlugin(t){this.pluginManager.register(t)}addDrawing(t){this.drawings.push(t),this.render()}removeDrawing(t){const e=this.drawings.findIndex(i=>i.id===t);if(e!==-1){const i=this.drawings[e];this.drawings.splice(e,1),this.events.emit("drawing:deleted",{id:i.id}),this.render()}}getDrawing(t){return this.drawings.find(e=>e.id===t)}updateDrawing(t){const e=this.drawings.findIndex(i=>i.id===t.id);e!==-1&&(this.drawings[e]=t,this.render())}lockChart(){if(this.isLocked)return;this.isLocked=!0;const t=this.chart.getOption();this.chart.setOption({dataZoom:t.dataZoom.map(e=>({...e,disabled:!0})),tooltip:{show:!1}})}unlockChart(){if(!this.isLocked)return;this.isLocked=!1;const t=this.chart.getOption();(this.options.dataZoom||{}).visible,t.dataZoom&&this.chart.setOption({dataZoom:t.dataZoom.map(e=>({...e,disabled:!1})),tooltip:{show:!0}})}setZoom(t,e){this.chart.dispatchAction({type:"dataZoom",start:t,end:e})}setMarketData(t){this.marketData=t,this.rebuildTimeIndex(),this.render()}updateData(t){if(t.length===0)return;const e=new Map;this.marketData.forEach(f=>{e.set(f.time,f)}),t.forEach(f=>{e.has(f.time),e.set(f.time,f)}),this.marketData=Array.from(e.values()).sort((f,m)=>f.time-m.time),this.rebuildTimeIndex();const i=this.dataIndexOffset,s=ft.buildCandlestickSeries(this.marketData,this.options),a={value:[NaN,NaN,NaN,NaN],itemStyle:{opacity:0}},o=[...Array(i).fill(a),...s.data,...Array(i).fill(a)],u=[...Array(i).fill(""),...this.marketData.map(f=>new Date(f.time).toLocaleString()),...Array(i).fill("")],d=this.chart.getOption(),p=It.calculate(this.chart.getHeight(),this.indicators,this.options,this.isMainCollapsed,this.maximizedPaneId,this.marketData,this._mainHeightOverride??void 0);this._lastLayout=p;const g=[...Array(i).fill(null),...this.marketData,...Array(i).fill(null)],{series:r,barColors:l}=ft.buildIndicatorSeries(this.indicators,this.timeToIndex,p.paneLayout,u.length,i,g,p.overlayYAxisMap,p.separatePaneYAxisOffset),h=o.map((f,m)=>l[m]?{value:f.value||f,itemStyle:{color:l[m],color0:l[m],borderColor:l[m],borderColor0:l[m]}}:f),n={xAxis:d.xAxis.map((f,m)=>({data:u})),series:[{data:h,markLine:s.markLine},...r.map(f=>{const m={data:f.data};return f.renderItem&&(m.renderItem=f.renderItem),m})]};this.chart.setOption(n,{notMerge:!1});const c=[];this.indicators.forEach(f=>{Object.values(f.plots).forEach(m=>{m.options?.style==="table"&&m.data?.forEach(w=>{(Array.isArray(w.value)?w.value:[w.value]).forEach(C=>{C&&!C._deleted&&(C._paneIndex=C.force_overlay?0:f.paneIndex,c.push(C))})})})}),this._lastTables=c,this._renderTableOverlays(),this.startCountdown()}startCountdown(){if(this.stopCountdown(),!this.options.lastPriceLine?.showCountdown||!this.options.interval||this.marketData.length===0)return;const t=()=>{if(this.marketData.length===0)return;const e=this.marketData[this.marketData.length-1].time+(this.options.interval||0),i=Date.now(),s=e-i;if(s<=0)return;const a=Math.abs(s),o=Math.floor(a/36e5),u=Math.floor(a%36e5/6e4),d=Math.floor(a%6e4/1e3),p=`${o>0?o.toString().padStart(2,"0")+":":""}${u.toString().padStart(2,"0")}:${d.toString().padStart(2,"0")}`,g=this.chart.getOption();if(!g||!g.series)return;const r=g.series.findIndex(m=>m.type==="candlestick");if(r===-1)return;const l=g.series[r];if(!l.markLine||!l.markLine.data||!l.markLine.data[0])return;const h=l.markLine.data[0];h.label.formatter;const n=h.yAxis;let c="";if(this.options.yAxisLabelFormatter)c=this.options.yAxisLabelFormatter(n);else{const m=this.options.yAxisDecimalPlaces!==void 0?this.options.yAxisDecimalPlaces:Z.autoDetectDecimals(this.marketData);c=Z.formatValue(n,m)}const f=`${c}
37
- ${p}`;this.chart.setOption({series:[{name:this.options.title||"Market",markLine:{data:[{...h,label:{...h.label,formatter:f}}]}}]})};t(),this.countdownInterval=setInterval(t,1e3)}stopCountdown(){this.countdownInterval&&(clearInterval(this.countdownInterval),this.countdownInterval=null)}addIndicator(t,e,i={}){const s=i.overlay!==void 0?i.overlay:i.isOverlay??!1;let a=0;if(!s){let u=0;this.indicators.forEach(d=>{d.paneIndex>u&&(u=d.paneIndex)}),a=u+1}const o=new Pt(t,e,a,{height:i.height,collapsed:!1,titleColor:i.titleColor,controls:i.controls});return this.indicators.set(t,o),this.render(),o}setIndicator(t,e,i=!1){this.addIndicator(t,{[t]:e},{overlay:i})}removeIndicator(t){this.indicators.delete(t),this.render()}toggleIndicator(t,e="collapse"){if(e==="fullscreen"){document.fullscreenElement?document.exitFullscreen():this.rootContainer.requestFullscreen();return}if(e==="maximize"){this.maximizedPaneId===t?this.maximizedPaneId=null:this.maximizedPaneId=t,this.render();return}if(t==="main"){this.isMainCollapsed=!this.isMainCollapsed,this.render();return}const i=this.indicators.get(t);i&&(i.toggleCollapse(),this.render())}resize(){this.chart.resize(),this._renderTableOverlays()}_renderTableOverlays(){const t=this.chart.getModel(),e=i=>t.getComponent("grid",i)?.coordinateSystem?.getRect();Q.render(this.overlayContainer,this._lastTables,e)}destroy(){this.stopCountdown(),window.removeEventListener("resize",this.resize.bind(this)),document.removeEventListener("fullscreenchange",this.onFullscreenChange),document.removeEventListener("keydown",this.onKeyDown),this.pluginManager.deactivatePlugin(),this.pluginManager.destroy(),this.chart.dispose()}rebuildTimeIndex(){this.timeToIndex.clear(),this.marketData.forEach((i,s)=>{this.timeToIndex.set(i.time,s)});const t=this.marketData.length,e=Math.ceil(t*this.padding);this.dataIndexOffset=e}render(){if(this.marketData.length===0)return;let t=null;try{const v=this.chart.getOption();if(v&&v.dataZoom&&v.dataZoom.length>0){const y=v.dataZoom.find(b=>b.type==="slider"||b.type==="inside");y&&(t={start:y.start,end:y.end})}}catch{}const e=this.options.databox?.position,i=this.leftSidebar.style.display,s=this.rightSidebar.style.display,a=e==="left"?"block":"none",o=e==="right"?"block":"none";(i!==a||s!==o)&&(this.leftSidebar.style.display=a,this.rightSidebar.style.display=o,this.chart.resize());const u=this.dataIndexOffset,d=[...Array(u).fill(""),...this.marketData.map(v=>new Date(v.time).toLocaleString()),...Array(u).fill("")],p=It.calculate(this.chart.getHeight(),this.indicators,this.options,this.isMainCollapsed,this.maximizedPaneId,this.marketData,this._mainHeightOverride??void 0);if(this._lastLayout=p,!t&&p.dataZoom&&this.marketData.length>0){const v=this.marketData.length,y=d.length,b=u/y,_=v/y;p.dataZoom.forEach(I=>{if(I.start!==void 0){const P=I.start/100,k=b+P*_;I.start=k*100}if(I.end!==void 0){const P=I.end/100,k=b+P*_;I.end=k*100}})}t&&p.dataZoom&&p.dataZoom.forEach(v=>{v.start=t.start,v.end=t.end}),p.xAxis.forEach(v=>{v.data=d,v.boundaryGap=!1});const g=ft.buildCandlestickSeries(this.marketData,this.options),r={value:[NaN,NaN,NaN,NaN],itemStyle:{opacity:0}};g.data=[...Array(u).fill(r),...g.data,...Array(u).fill(r)];const l=[...Array(u).fill(null),...this.marketData,...Array(u).fill(null)],{series:h,barColors:n}=ft.buildIndicatorSeries(this.indicators,this.timeToIndex,p.paneLayout,d.length,u,l,p.overlayYAxisMap,p.separatePaneYAxisOffset);g.data=g.data.map((v,y)=>n[y]?{value:v.value||v,itemStyle:{color:n[y],color0:n[y],borderColor:n[y],borderColor0:n[y]}}:v);const c=qt.build(p,this.options,this.toggleIndicator.bind(this),this.isMainCollapsed,this.maximizedPaneId),f=new Map;this.drawings.forEach(v=>{const y=v.paneIndex||0;f.has(y)||f.set(y,[]),f.get(y).push(v)});const m=[];f.forEach((v,y)=>{m.push({type:"custom",name:`drawings-pane-${y}`,xAxisIndex:y,yAxisIndex:y,clip:!0,renderItem:(b,_)=>{const I=v[b.dataIndex];if(!I)return;const P=I.points[0],k=I.points[1];if(!P||!k)return;const D=_.coord([P.timeIndex,P.value]),M=_.coord([k.timeIndex,k.value]),L=I.id===this.selectedDrawingId;if(I.type==="line")return{type:"group",children:[{type:"line",name:"line",shape:{x1:D[0],y1:D[1],x2:M[0],y2:M[1]},style:{stroke:I.style?.color||"#3b82f6",lineWidth:I.style?.lineWidth||2}},{type:"circle",name:"point-start",shape:{cx:D[0],cy:D[1],r:4},style:{fill:"#fff",stroke:I.style?.color||"#3b82f6",lineWidth:1,opacity:L?1:0}},{type:"circle",name:"point-end",shape:{cx:M[0],cy:M[1],r:4},style:{fill:"#fff",stroke:I.style?.color||"#3b82f6",lineWidth:1,opacity:L?1:0}}]};if(I.type==="fibonacci"){const F=D[0],U=D[1],tt=M[0],H=M[1],et=Math.min(F,tt),nt=Math.max(F,tt),it=nt-et,W=H-U,S=[0,.236,.382,.5,.618,.786,1],$=["#787b86","#f44336","#ff9800","#4caf50","#2196f3","#00bcd4","#787b86"],N=[];N.push({type:"line",name:"line",shape:{x1:F,y1:U,x2:tt,y2:H},style:{stroke:"#999",lineWidth:1,lineDash:[4,4]}}),N.push({type:"circle",name:"point-start",shape:{cx:F,cy:U,r:4},style:{fill:"#fff",stroke:I.style?.color||"#3b82f6",lineWidth:1,opacity:L?1:0},z:100}),N.push({type:"circle",name:"point-end",shape:{cx:tt,cy:H,r:4},style:{fill:"#fff",stroke:I.style?.color||"#3b82f6",lineWidth:1,opacity:L?1:0},z:100}),S.forEach((E,T)=>{const R=H-W*E,O=$[T%$.length];N.push({type:"line",name:"fib-line",shape:{x1:et,y1:R,x2:nt,y2:R},style:{stroke:O,lineWidth:1},silent:!0});const Y=I.points[0].value,st=I.points[1].value,ot=st-Y,J=st-ot*E;if(N.push({type:"text",style:{text:`${E} (${J.toFixed(2)})`,x:et+5,y:R-10,fill:O,fontSize:10},silent:!0}),T<S.length-1){const at=S[T+1],pt=H-W*at,gt=Math.abs(pt-R),xt=Math.min(R,pt);N.push({type:"rect",shape:{x:et,y:xt,width:it,height:gt},style:{fill:$[(T+1)%$.length],opacity:.1},silent:!0})}});const G=[],q=[];return S.forEach((E,T)=>{const R=H-W*E,O=$[T%$.length];q.push({type:"line",shape:{x1:et,y1:R,x2:nt,y2:R},style:{stroke:O,lineWidth:1},silent:!0});const Y=I.points[0].value,st=I.points[1].value,ot=st-Y,J=st-ot*E;if(q.push({type:"text",style:{text:`${E} (${J.toFixed(2)})`,x:et+5,y:R-10,fill:O,fontSize:10},silent:!0}),T<S.length-1){const at=S[T+1],pt=H-W*at,gt=Math.abs(pt-R),xt=Math.min(R,pt);G.push({type:"rect",name:"line",shape:{x:et,y:xt,width:it,height:gt},style:{fill:$[(T+1)%$.length],opacity:.1}})}}),{type:"group",children:[...G,...q,{type:"line",name:"line",shape:{x1:F,y1:U,x2:tt,y2:H},style:{stroke:"#999",lineWidth:1,lineDash:[4,4]}},{type:"circle",name:"point-start",shape:{cx:F,cy:U,r:4},style:{fill:"#fff",stroke:I.style?.color||"#3b82f6",lineWidth:1,opacity:L?1:0},z:100},{type:"circle",name:"point-end",shape:{cx:tt,cy:H,r:4},style:{fill:"#fff",stroke:I.style?.color||"#3b82f6",lineWidth:1,opacity:L?1:0},z:100}]}}},data:v.map(b=>[b.points[0].timeIndex,b.points[0].value,b.points[1].timeIndex,b.points[1].value]),encode:{x:[0,2],y:[1,3]},z:100,silent:!1})});const w=v=>{const y=Vt.format(v,this.options),b=this.options.databox?.position;return b==="left"?(this.leftSidebar.innerHTML=y,""):b==="right"?(this.rightSidebar.innerHTML=y,""):this.options.databox?`<div style="min-width: 200px;">${y}</div>`:""},C=[];this.indicators.forEach(v=>{Object.values(v.plots).forEach(y=>{y.options?.style==="table"&&y.data?.forEach(b=>{(Array.isArray(b.value)?b.value:[b.value]).forEach(_=>{_&&!_._deleted&&(_._paneIndex=_.force_overlay?0:v.paneIndex,C.push(_))})})})});const A={backgroundColor:this.options.backgroundColor,animation:!1,legend:{show:!1},tooltip:{show:!0,showContent:!!this.options.databox,trigger:"axis",triggerOn:this.options.databox?.triggerOn??"mousemove",axisPointer:{type:"cross",label:{backgroundColor:"#475569"}},backgroundColor:"rgba(30, 41, 59, 0.9)",borderWidth:1,borderColor:"#334155",padding:10,textStyle:{color:"#fff",fontFamily:this.options.fontFamily||"sans-serif"},formatter:w,extraCssText:e!=="floating"&&e!==void 0?"display: none !important;":void 0,position:(v,y,b,_,I)=>{if(this.options.databox?.position==="floating"){const P={top:10};return P[["left","right"][+(v[0]<I.viewSize[0]/2)]]=30,P}return null}},axisPointer:{link:{xAxisIndex:"all"},label:{backgroundColor:"#475569"}},graphic:c,grid:p.grid,xAxis:p.xAxis,yAxis:p.yAxis,dataZoom:p.dataZoom,series:[g,...h,...m]};this.chart.setOption(A,!0),this._lastTables=C,this._renderTableOverlays()}}var le=Object.defineProperty,he=(x,t,e)=>t in x?le(x,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):x[t]=e,ut=(x,t,e)=>(he(x,typeof t!="symbol"?t+"":t,e),e);class yt{constructor(t){ut(this,"id"),ut(this,"name"),ut(this,"icon"),ut(this,"context"),ut(this,"eventListeners",[]),this.id=t.id,this.name=t.name,this.icon=t.icon}init(t){this.context=t,this.onInit()}onInit(){}activate(){this.onActivate(),this.context.events.emit("plugin:activated",this.id)}onActivate(){}deactivate(){this.onDeactivate(),this.context.events.emit("plugin:deactivated",this.id)}onDeactivate(){}destroy(){this.removeAllListeners(),this.onDestroy()}onDestroy(){}on(t,e){this.context.events.on(t,e),this.eventListeners.push({event:t,handler:e})}off(t,e){this.context.events.off(t,e),this.eventListeners=this.eventListeners.filter(i=>i.event!==t||i.handler!==e)}removeAllListeners(){this.eventListeners.forEach(({event:t,handler:e})=>{this.context.events.off(t,e)}),this.eventListeners=[]}get chart(){return this.context.getChart()}get marketData(){return this.context.getMarketData()}}var ce=Object.defineProperty,de=(x,t,e)=>t in x?ce(x,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):x[t]=e,V=(x,t,e)=>(de(x,typeof t!="symbol"?t+"":t,e),e);class pe extends yt{constructor(t){super({id:"measure",name:t?.name||"Measure",icon:t?.icon||'<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="#e3e3e3"><path d="M160-240q-33 0-56.5-23.5T80-320v-320q0-33 23.5-56.5T160-720h640q33 0 56.5 23.5T880-640v320q0 33-23.5 56.5T800-240H160Zm0-80h640v-320H680v160h-80v-160h-80v160h-80v-160h-80v160h-80v-160H160v320Zm120-160h80-80Zm160 0h80-80Zm160 0h80-80Zm-120 0Z"/></svg>'}),V(this,"zr"),V(this,"state","idle"),V(this,"startPoint",null),V(this,"endPoint",null),V(this,"group",null),V(this,"rect",null),V(this,"labelRect",null),V(this,"labelText",null),V(this,"lineV",null),V(this,"lineH",null),V(this,"arrowStart",null),V(this,"arrowEnd",null),V(this,"onMouseDown",()=>{this.state==="finished"&&this.removeGraphic()}),V(this,"onChartInteraction",()=>{this.group&&this.removeGraphic()}),V(this,"onClick",e=>{this.state==="idle"?(this.state="drawing",this.startPoint=[e.offsetX,e.offsetY],this.endPoint=[e.offsetX,e.offsetY],this.initGraphic(),this.updateGraphic()):this.state==="drawing"&&(this.state="finished",this.endPoint=[e.offsetX,e.offsetY],this.updateGraphic(),this.context.disableTools(),this.enableClearListeners())}),V(this,"clearHandlers",{}),V(this,"onMouseMove",e=>{this.state==="drawing"&&(this.endPoint=[e.offsetX,e.offsetY],this.updateGraphic())})}onInit(){this.zr=this.chart.getZr()}onActivate(){this.state="idle",this.chart.getZr().setCursorStyle("crosshair"),this.zr.on("click",this.onClick),this.zr.on("mousemove",this.onMouseMove)}onDeactivate(){this.state="idle",this.chart.getZr().setCursorStyle("default"),this.zr.off("click",this.onClick),this.zr.off("mousemove",this.onMouseMove),this.disableClearListeners(),this.state==="drawing"&&this.removeGraphic()}onDestroy(){this.removeGraphic()}enableClearListeners(){const t=()=>{this.removeGraphic()};setTimeout(()=>{this.zr.on("click",t)},10),this.zr.on("mousedown",this.onMouseDown),this.context.events.on("chart:dataZoom",this.onChartInteraction),this.clearHandlers={click:t,mousedown:this.onMouseDown,dataZoom:this.onChartInteraction}}disableClearListeners(){this.clearHandlers.click&&this.zr.off("click",this.clearHandlers.click),this.clearHandlers.mousedown&&this.zr.off("mousedown",this.clearHandlers.mousedown),this.clearHandlers.dataZoom&&this.context.events.off("chart:dataZoom",this.clearHandlers.dataZoom),this.clearHandlers={}}initGraphic(){this.group||(this.group=new B.graphic.Group,this.rect=new B.graphic.Rect({shape:{x:0,y:0,width:0,height:0},style:{fill:"rgba(0,0,0,0)",stroke:"transparent",lineWidth:0},z:100}),this.lineV=new B.graphic.Line({shape:{x1:0,y1:0,x2:0,y2:0},style:{stroke:"#fff",lineWidth:1,lineDash:[4,4]},z:101}),this.lineH=new B.graphic.Line({shape:{x1:0,y1:0,x2:0,y2:0},style:{stroke:"#fff",lineWidth:1,lineDash:[4,4]},z:101}),this.arrowStart=new B.graphic.Polygon({shape:{points:[[0,0],[-5,10],[5,10]]},style:{fill:"#fff"},z:102}),this.arrowEnd=new B.graphic.Polygon({shape:{points:[[0,0],[-5,-10],[5,-10]]},style:{fill:"#fff"},z:102}),this.labelRect=new B.graphic.Rect({shape:{x:0,y:0,width:0,height:0,r:4},style:{fill:"transparent",stroke:"transparent",lineWidth:0,shadowBlur:5,shadowColor:"rgba(0,0,0,0.3)"},z:102}),this.labelText=new B.graphic.Text({style:{x:0,y:0,text:"",fill:"#fff",font:"12px sans-serif",align:"center",verticalAlign:"middle"},z:103}),this.group.add(this.rect),this.group.add(this.lineV),this.group.add(this.lineH),this.group.add(this.arrowStart),this.group.add(this.arrowEnd),this.group.add(this.labelRect),this.group.add(this.labelText),this.zr.add(this.group))}removeGraphic(){this.group&&(this.zr.remove(this.group),this.group=null,this.disableClearListeners())}updateGraphic(){if(!this.startPoint||!this.endPoint||!this.group)return;const[t,e]=this.startPoint,[i,s]=this.endPoint,a=this.context.coordinateConversion.pixelToData({x:t,y:e}),o=this.context.coordinateConversion.pixelToData({x:i,y:s});if(!a||!o)return;const u=Math.round(a.timeIndex),d=Math.round(o.timeIndex),p=a.value,g=o.value,r=d-u,l=g-p,h=l/p*100,n=l>=0,c=n?"rgba(33, 150, 243, 0.2)":"rgba(236, 0, 0, 0.2)",f=n?"#2196F3":"#ec0000";this.rect.setShape({x:Math.min(t,i),y:Math.min(e,s),width:Math.abs(i-t),height:Math.abs(s-e)}),this.rect.setStyle({fill:c});const m=(t+i)/2,w=(e+s)/2;this.lineV.setShape({x1:m,y1:e,x2:m,y2:s}),this.lineV.setStyle({stroke:f}),this.lineH.setShape({x1:t,y1:w,x2:i,y2:w}),this.lineH.setStyle({stroke:f});const C=Math.min(e,s),A=Math.max(e,s);this.arrowStart.setStyle({fill:"none"}),this.arrowEnd.setStyle({fill:"none"}),n?(this.arrowStart.setShape({points:[[m,C],[m-4,C+6],[m+4,C+6]]}),this.arrowStart.setStyle({fill:f})):(this.arrowEnd.setShape({points:[[m,A],[m-4,A-6],[m+4,A-6]]}),this.arrowEnd.setStyle({fill:f}));const v=[`${l.toFixed(2)} (${h.toFixed(2)}%)`,`${r} bars, ${(r*0).toFixed(0)}d`].join(`
38
- `),y=140,b=40,_=Math.max(e,s),I=Math.min(e,s);let P=(t+i)/2-y/2,k=_+10;const D=this.chart.getHeight();k+b>D&&(k=I-b-10),this.labelRect.setShape({x:P,y:k,width:y,height:b}),this.labelRect.setStyle({fill:"#1e293b",stroke:f,lineWidth:1}),this.labelText.setStyle({x:P+y/2,y:k+b/2,text:v,fill:"#fff"})}}var ue=Object.defineProperty,fe=(x,t,e)=>t in x?ue(x,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):x[t]=e,K=(x,t,e)=>(fe(x,typeof t!="symbol"?t+"":t,e),e);class ye extends yt{constructor(t){super({id:"trend-line",name:t?.name||"Trend Line",icon:t?.icon||'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="2" y1="22" x2="22" y2="2" /></svg>'}),K(this,"zr"),K(this,"state","idle"),K(this,"startPoint",null),K(this,"endPoint",null),K(this,"group",null),K(this,"line",null),K(this,"startCircle",null),K(this,"endCircle",null),K(this,"onMouseDown",()=>{}),K(this,"onChartInteraction",()=>{}),K(this,"onClick",e=>{if(this.state==="idle")this.state="drawing",this.startPoint=[e.offsetX,e.offsetY],this.endPoint=[e.offsetX,e.offsetY],this.initGraphic(),this.updateGraphic();else if(this.state==="drawing"){if(this.state="finished",this.endPoint=[e.offsetX,e.offsetY],this.updateGraphic(),this.startPoint&&this.endPoint){const i=this.context.coordinateConversion.pixelToData({x:this.startPoint[0],y:this.startPoint[1]}),s=this.context.coordinateConversion.pixelToData({x:this.endPoint[0],y:this.endPoint[1]});if(i&&s){const a=i.paneIndex||0;this.context.addDrawing({id:`line-${Date.now()}`,type:"line",points:[i,s],paneIndex:a,style:{color:"#3b82f6",lineWidth:2}})}}this.removeGraphic(),this.context.disableTools()}}),K(this,"clearHandlers",{}),K(this,"onMouseMove",e=>{this.state==="drawing"&&(this.endPoint=[e.offsetX,e.offsetY],this.updateGraphic())})}onInit(){this.zr=this.chart.getZr()}onActivate(){this.state="idle",this.chart.getZr().setCursorStyle("crosshair"),this.zr.on("click",this.onClick),this.zr.on("mousemove",this.onMouseMove)}onDeactivate(){this.state="idle",this.chart.getZr().setCursorStyle("default"),this.zr.off("click",this.onClick),this.zr.off("mousemove",this.onMouseMove),this.disableClearListeners(),this.state==="drawing"&&this.removeGraphic()}onDestroy(){this.removeGraphic()}saveDataCoordinates(){}updateGraphicFromData(){}enableClearListeners(){}disableClearListeners(){}initGraphic(){this.group||(this.group=new B.graphic.Group,this.line=new B.graphic.Line({shape:{x1:0,y1:0,x2:0,y2:0},style:{stroke:"#3b82f6",lineWidth:2},z:100}),this.startCircle=new B.graphic.Circle({shape:{cx:0,cy:0,r:4},style:{fill:"#fff",stroke:"#3b82f6",lineWidth:1},z:101}),this.endCircle=new B.graphic.Circle({shape:{cx:0,cy:0,r:4},style:{fill:"#fff",stroke:"#3b82f6",lineWidth:1},z:101}),this.group.add(this.line),this.group.add(this.startCircle),this.group.add(this.endCircle),this.zr.add(this.group))}removeGraphic(){this.group&&(this.zr.remove(this.group),this.group=null,this.disableClearListeners())}updateGraphic(){if(!this.startPoint||!this.endPoint||!this.group)return;const[t,e]=this.startPoint,[i,s]=this.endPoint;this.line.setShape({x1:t,y1:e,x2:i,y2:s}),this.startCircle.setShape({cx:t,cy:e}),this.endCircle.setShape({cx:i,cy:s})}}var ge=Object.defineProperty,xe=(x,t,e)=>t in x?ge(x,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):x[t]=e,rt=(x,t,e)=>(xe(x,typeof t!="symbol"?t+"":t,e),e);class me extends yt{constructor(t={}){super({id:"fibonacci-tool",name:t.name||"Fibonacci Retracement",icon:t.icon||'<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="#e3e3e3"><path d="M120-80v-80h720v80H120Zm0-240v-80h720v80H120Zm0-240v-80h720v80H120Zm0-240v-80h720v80H120Z"/></svg>'}),rt(this,"startPoint",null),rt(this,"endPoint",null),rt(this,"state","idle"),rt(this,"graphicGroup",null),rt(this,"levels",[0,.236,.382,.5,.618,.786,1]),rt(this,"colors",["#787b86","#f44336","#ff9800","#4caf50","#2196f3","#00bcd4","#787b86"]),rt(this,"onClick",e=>{this.state==="idle"?(this.state="drawing",this.startPoint=[e.offsetX,e.offsetY],this.endPoint=[e.offsetX,e.offsetY],this.initGraphic(),this.updateGraphic()):this.state==="drawing"&&(this.state="finished",this.endPoint=[e.offsetX,e.offsetY],this.updateGraphic(),this.saveDrawing(),this.removeGraphic(),this.context.disableTools())}),rt(this,"onMouseMove",e=>{this.state==="drawing"&&(this.endPoint=[e.offsetX,e.offsetY],this.updateGraphic())})}onActivate(){this.state="idle",this.startPoint=null,this.endPoint=null,this.context.getChart().getZr().setCursorStyle("crosshair"),this.bindEvents()}onDeactivate(){this.state="idle",this.startPoint=null,this.endPoint=null,this.removeGraphic(),this.unbindEvents(),this.context.getChart().getZr().setCursorStyle("default")}bindEvents(){const t=this.context.getChart().getZr();t.on("click",this.onClick),t.on("mousemove",this.onMouseMove)}unbindEvents(){const t=this.context.getChart().getZr();t.off("click",this.onClick),t.off("mousemove",this.onMouseMove)}initGraphic(){this.graphicGroup=new B.graphic.Group,this.context.getChart().getZr().add(this.graphicGroup)}removeGraphic(){this.graphicGroup&&(this.context.getChart().getZr().remove(this.graphicGroup),this.graphicGroup=null)}updateGraphic(){if(!this.graphicGroup||!this.startPoint||!this.endPoint)return;this.graphicGroup.removeAll();const t=this.startPoint[0],e=this.startPoint[1],i=this.endPoint[0],s=this.endPoint[1],a=new B.graphic.Line({shape:{x1:t,y1:e,x2:i,y2:s},style:{stroke:"#999",lineWidth:1,lineDash:[4,4]},silent:!0});this.graphicGroup.add(a);const o=Math.min(t,i),u=Math.max(t,i),d=u-o,p=s-e;this.levels.forEach((g,r)=>{const l=s-p*g,h=this.colors[r%this.colors.length],n=new B.graphic.Line({shape:{x1:o,y1:l,x2:u,y2:l},style:{stroke:h,lineWidth:1},silent:!0});if(this.graphicGroup.add(n),r<this.levels.length-1){const c=this.levels[r+1],f=s-p*c,m=Math.abs(f-l),w=Math.min(l,f),C=new B.graphic.Rect({shape:{x:o,y:w,width:d,height:m},style:{fill:this.colors[(r+1)%this.colors.length],opacity:.1},silent:!0});this.graphicGroup.add(C)}})}saveDrawing(){if(!this.startPoint||!this.endPoint)return;const t=this.context.coordinateConversion.pixelToData({x:this.startPoint[0],y:this.startPoint[1]}),e=this.context.coordinateConversion.pixelToData({x:this.endPoint[0],y:this.endPoint[1]});if(t&&e){const i=t.paneIndex||0;this.context.addDrawing({id:`fib-${Date.now()}`,type:"fibonacci",points:[t,e],paneIndex:i,style:{color:"#3b82f6",lineWidth:1}})}}}export{yt as AbstractPlugin,me as FibonacciTool,ye as LineTool,pe as MeasureTool,re as QFChart};
35
+ <div>${g.marker} <span style="color: #cbd5e1;">${g.displayName}</span></div>
36
+ <div style="font-size: 10px; color: #fff;padding-left:10px;">${f}</div>
37
+ </div>`}),r+="</div>"})}return r}}var ni=Object.defineProperty,oi=(p,t,e)=>t in p?ni(p,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):p[t]=e,Ct=(p,t,e)=>(oi(p,typeof t!="symbol"?t+"":t,e),e);class ai{constructor(t,e){Ct(this,"plugins",new Map),Ct(this,"activePluginId",null),Ct(this,"context"),Ct(this,"toolbarContainer"),Ct(this,"tooltipElement",null),Ct(this,"hideTimeout",null),this.context=t,this.toolbarContainer=e,this.createTooltip(),this.renderToolbar()}createTooltip(){this.tooltipElement=document.createElement("div"),Object.assign(this.tooltipElement.style,{position:"fixed",display:"none",backgroundColor:"#1e293b",color:"#e2e8f0",padding:"6px 10px",borderRadius:"6px",fontSize:"13px",lineHeight:"1.4",fontWeight:"500",border:"1px solid #334155",zIndex:"9999",pointerEvents:"none",whiteSpace:"nowrap",boxShadow:"0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.15)",fontFamily:this.context.getOptions().fontFamily||"sans-serif",transition:"opacity 0.15s ease-in-out, transform 0.15s ease-in-out",opacity:"0",transform:"translateX(-5px)"}),document.body.appendChild(this.tooltipElement)}destroy(){this.tooltipElement&&this.tooltipElement.parentNode&&this.tooltipElement.parentNode.removeChild(this.tooltipElement),this.tooltipElement=null}showTooltip(t,e){if(!this.tooltipElement)return;this.hideTimeout&&(clearTimeout(this.hideTimeout),this.hideTimeout=null);const i=t.getBoundingClientRect();this.tooltipElement.textContent=e,this.tooltipElement.style.display="block";const s=this.tooltipElement.getBoundingClientRect(),a=i.top+(i.height-s.height)/2,n=i.right+10;this.tooltipElement.style.top=`${a}px`,this.tooltipElement.style.left=`${n}px`,requestAnimationFrame(()=>{this.tooltipElement&&(this.tooltipElement.style.opacity="1",this.tooltipElement.style.transform="translateX(0)")})}hideTooltip(){this.tooltipElement&&(this.tooltipElement.style.opacity="0",this.tooltipElement.style.transform="translateX(-5px)",this.hideTimeout&&clearTimeout(this.hideTimeout),this.hideTimeout=setTimeout(()=>{this.tooltipElement&&(this.tooltipElement.style.display="none"),this.hideTimeout=null},150))}register(t){if(this.plugins.has(t.id)){console.warn(`Plugin with id ${t.id} is already registered.`);return}this.plugins.set(t.id,t),t.init(this.context),this.addButton(t)}unregister(t){const e=this.plugins.get(t);e&&(this.activePluginId===t&&this.deactivatePlugin(),e.destroy?.(),this.plugins.delete(t),this.removeButton(t))}activatePlugin(t){if(this.activePluginId===t){this.deactivatePlugin();return}this.activePluginId&&this.deactivatePlugin();const e=this.plugins.get(t);e&&(this.activePluginId=t,this.setButtonActive(t,!0),e.activate?.())}deactivatePlugin(){this.activePluginId&&(this.plugins.get(this.activePluginId)?.deactivate?.(),this.setButtonActive(this.activePluginId,!1),this.activePluginId=null)}renderToolbar(){this.toolbarContainer.innerHTML="",this.toolbarContainer.classList.add("qfchart-toolbar"),this.toolbarContainer.style.display="flex",this.toolbarContainer.style.flexDirection="column",this.toolbarContainer.style.width="40px",this.toolbarContainer.style.backgroundColor=this.context.getOptions().backgroundColor||"#1e293b",this.toolbarContainer.style.borderRight="1px solid #334155",this.toolbarContainer.style.padding="5px",this.toolbarContainer.style.boxSizing="border-box",this.toolbarContainer.style.gap="5px",this.toolbarContainer.style.flexShrink="0"}addButton(t){const e=document.createElement("button");e.id=`qfchart-plugin-btn-${t.id}`,e.style.width="30px",e.style.height="30px",e.style.padding="4px",e.style.border="1px solid transparent",e.style.borderRadius="4px",e.style.backgroundColor="transparent",e.style.cursor="pointer",e.style.color=this.context.getOptions().fontColor||"#cbd5e1",e.style.display="flex",e.style.alignItems="center",e.style.justifyContent="center",t.icon?e.innerHTML=t.icon:e.innerText=(t.name||t.id).substring(0,2).toUpperCase(),e.addEventListener("mouseenter",()=>{this.activePluginId!==t.id&&(e.style.backgroundColor="rgba(255, 255, 255, 0.1)"),this.showTooltip(e,t.name||t.id)}),e.addEventListener("mouseleave",()=>{this.activePluginId!==t.id&&(e.style.backgroundColor="transparent"),this.hideTooltip()}),e.onclick=()=>this.activatePlugin(t.id),this.toolbarContainer.appendChild(e)}removeButton(t){const e=this.toolbarContainer.querySelector(`#qfchart-plugin-btn-${t}`);e&&e.remove()}setButtonActive(t,e){const i=this.toolbarContainer.querySelector(`#qfchart-plugin-btn-${t}`);i&&(e?(i.style.backgroundColor="#2563eb",i.style.color="#ffffff"):(i.style.backgroundColor="transparent",i.style.color=this.context.getOptions().fontColor||"#cbd5e1"))}}var ri=Object.defineProperty,li=(p,t,e)=>t in p?ri(p,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):p[t]=e,tt=(p,t,e)=>(li(p,typeof t!="symbol"?t+"":t,e),e);class hi{constructor(t){tt(this,"context"),tt(this,"isEditing",!1),tt(this,"currentDrawing",null),tt(this,"editingPointIndex",null),tt(this,"zr"),tt(this,"editGroup",null),tt(this,"editLines",[]),tt(this,"editPoints",[]),tt(this,"isMovingShape",!1),tt(this,"dragStart",null),tt(this,"initialPixelPoints",[]),tt(this,"onDrawingMouseDown",e=>{if(this.isEditing)return;const i=this.context.getDrawing(e.id);i&&(this.isEditing=!0,this.isMovingShape=!0,this.currentDrawing=JSON.parse(JSON.stringify(i)),this.dragStart={x:e.x,y:e.y},this.initialPixelPoints=i.points.map(s=>{const a=this.context.coordinateConversion.dataToPixel(s);return a?{x:a.x,y:a.y}:{x:0,y:0}}),this.context.lockChart(),this.createEditGraphic(),this.zr.on("mousemove",this.onMouseMove),this.zr.on("mouseup",this.onMouseUp),window.addEventListener("mouseup",this.onWindowMouseUp))}),tt(this,"onPointMouseDown",e=>{if(this.isEditing)return;const i=this.context.getDrawing(e.id);i&&(this.isEditing=!0,this.currentDrawing=JSON.parse(JSON.stringify(i)),this.editingPointIndex=e.pointIndex,this.initialPixelPoints=i.points.map(s=>{const a=this.context.coordinateConversion.dataToPixel(s);return a?{x:a.x,y:a.y}:{x:0,y:0}}),this.context.lockChart(),this.createEditGraphic(),this.zr.on("mousemove",this.onMouseMove),this.zr.on("mouseup",this.onMouseUp),window.addEventListener("mouseup",this.onWindowMouseUp))}),tt(this,"onMouseMove",e=>{if(!this.isEditing||!this.currentDrawing)return;const i=e.offsetX,s=e.offsetY;if(this.isMovingShape&&this.dragStart){const a=i-this.dragStart.x,n=s-this.dragStart.y,l=this.initialPixelPoints.map(r=>({x:r.x+a,y:r.y+n}));for(let r=0;r<this.editLines.length;r++)this.editLines[r].setShape({x1:l[r].x,y1:l[r].y,x2:l[r+1].x,y2:l[r+1].y});for(let r=0;r<this.editPoints.length;r++)this.editPoints[r].setShape({cx:l[r].x,cy:l[r].y})}else if(this.editingPointIndex!==null){const a=this.initialPixelPoints.map(n=>({x:n.x,y:n.y}));a[this.editingPointIndex]={x:i,y:s};for(let n=0;n<this.editLines.length;n++)this.editLines[n].setShape({x1:a[n].x,y1:a[n].y,x2:a[n+1].x,y2:a[n+1].y});this.editPoints[this.editingPointIndex].setShape({cx:i,cy:s})}}),tt(this,"onMouseUp",e=>{this.isEditing&&this.finishEditing(e.offsetX,e.offsetY)}),tt(this,"onWindowMouseUp",e=>{if(!this.isEditing)return;const i=this.zr.dom;if(i){const s=i.getBoundingClientRect(),a=e.clientX-s.left,n=e.clientY-s.top;this.finishEditing(a,n)}else this.finishEditing(this.dragStart?.x??0,this.dragStart?.y??0)}),this.context=t,this.zr=this.context.getChart().getZr(),this.bindEvents()}bindEvents(){this.context.events.on("drawing:point:mousedown",this.onPointMouseDown),this.context.events.on("drawing:mousedown",this.onDrawingMouseDown)}createEditGraphic(){if(!this.currentDrawing)return;this.editGroup=new G.graphic.Group,this.editLines=[],this.editPoints=[];const t=this.currentDrawing.points.map(i=>{const s=this.context.coordinateConversion.dataToPixel(i);return s?{x:s.x,y:s.y}:null});if(t.some(i=>!i))return;const e=t;for(let i=0;i<e.length-1;i++){const s=new G.graphic.Line({shape:{x1:e[i].x,y1:e[i].y,x2:e[i+1].x,y2:e[i+1].y},style:{stroke:this.currentDrawing.style?.color||"#3b82f6",lineWidth:this.currentDrawing.style?.lineWidth||2,lineDash:[4,4]},silent:!0});this.editLines.push(s),this.editGroup.add(s)}for(let i=0;i<e.length;i++){const s=new G.graphic.Circle({shape:{cx:e[i].x,cy:e[i].y,r:5},style:{fill:"#fff",stroke:"#3b82f6",lineWidth:2},z:1e3});this.editPoints.push(s),this.editGroup.add(s)}this.zr.add(this.editGroup)}pixelToDataForPane(t,e,i){const s=this.context.coordinateConversion.pixelToData({x:t,y:e});if(s)return s;try{const a=this.context.getChart(),n=a.convertFromPixel({gridIndex:i},[t,e]);if(n){const l=a.getOption()?.xAxis?.[i]?.data,r=this.context.getMarketData(),o=l?Math.round((l.length-r.length)/2):0;return{timeIndex:Math.round(n[0])-o,value:n[1],paneIndex:i}}}catch{}return null}finishEditing(t,e){if(!this.currentDrawing){this.cleanup();return}const i=this.currentDrawing.paneIndex||0;if(this.isMovingShape&&this.dragStart){const s=t-this.dragStart.x,a=e-this.dragStart.y,n=this.initialPixelPoints.map(l=>this.pixelToDataForPane(l.x+s,l.y+a,i));if(n.every(l=>l!==null)){for(let l=0;l<n.length;l++)this.currentDrawing.points[l]=n[l];n[0]?.paneIndex!==void 0&&(this.currentDrawing.paneIndex=n[0].paneIndex),this.context.updateDrawing(this.currentDrawing)}}else if(this.editingPointIndex!==null){const s=this.pixelToDataForPane(t,e,i);s&&(this.currentDrawing.points[this.editingPointIndex]=s,this.editingPointIndex===0&&s.paneIndex!==void 0&&(this.currentDrawing.paneIndex=s.paneIndex),this.context.updateDrawing(this.currentDrawing))}this.cleanup()}cleanup(){this.isEditing=!1,this.isMovingShape=!1,this.dragStart=null,this.initialPixelPoints=[],this.currentDrawing=null,this.editingPointIndex=null,this.editLines=[],this.editPoints=[],this.editGroup&&(this.zr.remove(this.editGroup),this.editGroup=null),this.zr.off("mousemove",this.onMouseMove),this.zr.off("mouseup",this.onMouseUp),window.removeEventListener("mouseup",this.onWindowMouseUp),this.context.unlockChart()}}var ci=Object.defineProperty,pi=(p,t,e)=>t in p?ci(p,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):p[t]=e,di=(p,t,e)=>(pi(p,typeof t!="symbol"?t+"":t,e),e);class ne{constructor(){di(this,"renderers",new Map)}register(t){this.renderers.set(t.type,t)}get(t){return this.renderers.get(t)}}var ui=Object.defineProperty,gi=(p,t,e)=>t in p?ui(p,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):p[t]=e,fi=(p,t,e)=>(gi(p,typeof t!="symbol"?t+"":t,e),e);class yi{constructor(){fi(this,"handlers",new Map)}on(t,e){this.handlers.has(t)||this.handlers.set(t,new Set),this.handlers.get(t).add(e)}off(t,e){const i=this.handlers.get(t);i&&i.delete(e)}emit(t,e){const i=this.handlers.get(t);i&&i.forEach(s=>{try{s(e)}catch(a){console.error(`Error in EventBus handler for ${t}:`,a)}})}clear(){this.handlers.clear()}}class st{static safeParseColor(t){if(!t||typeof t!="string")return{color:"#888888",opacity:1};const e=t.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?\)/);if(e){const i=e[4]?parseFloat(e[4]):1;return{color:`rgb(${e[1]},${e[2]},${e[3]})`,opacity:i}}return{color:t,opacity:1}}static render(t,e,i){st.clearAll(t);const s=new Map;for(const a of e)a&&!a._deleted&&s.set(a.position,a);s.forEach(a=>{const n=a._paneIndex??0,l=i?i(n):void 0,r=st.buildTable(a,l);st.positionTable(r,a.position,l),t.appendChild(r)})}static clearAll(t){for(;t.firstChild;)t.removeChild(t.firstChild)}static buildTable(t,e){const i=document.createElement("table"),s=t.border_width??0,a=t.frame_width??0;if(s>0&&t.border_color||a>0&&t.frame_color?(i.style.borderCollapse="separate",i.style.borderSpacing="0"):i.style.borderCollapse="collapse",i.style.pointerEvents="none",i.style.fontSize="14px",i.style.lineHeight="1.4",i.style.fontFamily="sans-serif",i.style.margin="4px",e&&(i.style.maxHeight=e.height+"px",i.style.maxWidth=e.width+"px",i.style.overflow="hidden"),t.bgcolor){const{color:c,opacity:g}=st.safeParseColor(t.bgcolor);i.style.backgroundColor=c,g<1&&(i.style.opacity=String(g))}if(a>0&&t.frame_color){const{color:c}=st.safeParseColor(t.frame_color);i.style.border=`${a}px solid ${c}`}else i.style.border="none";const n=new Map,l=new Set;if(t.merges)for(const c of t.merges){const g=`${c.startCol},${c.startRow}`;n.set(g,{colspan:c.endCol-c.startCol+1,rowspan:c.endRow-c.startRow+1});for(let h=c.startRow;h<=c.endRow;h++)for(let f=c.startCol;f<=c.endCol;f++)h===c.startRow&&f===c.startCol||l.add(`${f},${h}`)}const r=s>0&&!!t.border_color,o=r?st.safeParseColor(t.border_color).color:"",u=t.rows||0,d=t.columns||0;for(let c=0;c<u;c++){const g=document.createElement("tr");for(let h=0;h<d;h++){const f=`${h},${c}`;if(l.has(f))continue;const y=document.createElement("td"),x=n.get(f);x&&(x.colspan>1&&(y.colSpan=x.colspan),x.rowspan>1&&(y.rowSpan=x.rowspan)),r?y.style.border=`${s}px solid ${o}`:y.style.border="none";const b=t.cells?.[c]?.[h];if(b&&!b._merged){if(y.textContent=b.text||"",b.bgcolor&&typeof b.bgcolor=="string"&&b.bgcolor.length>0){const{color:w,opacity:k}=st.safeParseColor(b.bgcolor);y.style.backgroundColor=w,k<1&&(y.style.backgroundColor=b.bgcolor)}if(b.text_color){const{color:w}=st.safeParseColor(b.text_color);y.style.color=w}if(y.style.fontSize=st.getSizePixels(b.text_size)+"px",y.style.textAlign=st.mapHAlign(b.text_halign),y.style.verticalAlign=st.mapVAlign(b.text_valign),b.text_font_family==="monospace"&&(y.style.fontFamily="monospace"),b.width>0)if(e){const w=Math.max(1,b.width*e.width/100);y.style.width=w+"px"}else y.style.width=b.width+"%";if(b.height>0)if(e){const w=Math.max(1,b.height*e.height/100);y.style.height=w+"px"}else y.style.height=b.height+"%";b.tooltip&&(y.title=b.tooltip)}const D=b?.height??0;D>0&&e&&D*e.height/100<4?y.style.padding="0":y.style.padding="4px 6px",y.style.whiteSpace="nowrap",g.appendChild(y)}i.appendChild(g)}return i}static positionTable(t,e,i){t.style.position="absolute";const s=8,a=i?i.y+"px":"0",n=i?i.x+"px":"0",l=i?i.y+i.height-s+"px":"0",r=i?i.x+i.width-s+"px":"0",o=i?i.x+i.width/2+"px":"50%",u=i?i.y+i.height/2+"px":"50%";switch(e){case"top_left":t.style.top=a,t.style.left=n;break;case"top_center":t.style.top=a,t.style.left=o,t.style.transform="translateX(-50%)";break;case"top_right":t.style.top=a,t.style.left=r,t.style.transform="translateX(-100%)";break;case"middle_left":t.style.top=u,t.style.left=n,t.style.transform="translateY(-50%)";break;case"middle_center":t.style.top=u,t.style.left=o,t.style.transform="translate(-50%, -50%)";break;case"middle_right":t.style.top=u,t.style.left=r,t.style.transform="translate(-100%, -50%)";break;case"bottom_left":t.style.top=l,t.style.left=n,t.style.transform="translateY(-100%)";break;case"bottom_center":t.style.top=l,t.style.left=o,t.style.transform="translate(-50%, -100%)";break;case"bottom_right":t.style.top=l,t.style.left=r,t.style.transform="translate(-100%, -100%)";break;default:t.style.top=a,t.style.left=r,t.style.transform="translateX(-100%)";break}}static getSizePixels(t){if(typeof t=="number"&&t>0)return t;switch(t){case"auto":case"size.auto":return 12;case"tiny":case"size.tiny":return 8;case"small":case"size.small":return 10;case"normal":case"size.normal":return 14;case"large":case"size.large":return 20;case"huge":case"size.huge":return 36;default:return 14}}static mapHAlign(t){switch(t){case"left":case"text.align_left":return"left";case"right":case"text.align_right":return"right";case"center":case"text.align_center":default:return"center"}}static mapVAlign(t){switch(t){case"top":case"text.align_top":return"top";case"bottom":case"text.align_bottom":return"bottom";case"center":case"text.align_center":default:return"middle"}}}class K{static parseColor(t){if(!t||typeof t!="string"||t.length===0)return{color:"",opacity:0};const e=t.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?\)/);if(e){const i=e[4]?parseFloat(e[4]):1;return{color:`rgb(${e[1]},${e[2]},${e[3]})`,opacity:i}}if(/^#[0-9a-fA-F]{8}$/.test(t)){const i=parseInt(t.slice(1,3),16),s=parseInt(t.slice(3,5),16),a=parseInt(t.slice(5,7),16),n=parseInt(t.slice(7,9),16)/255;return{color:`rgb(${i},${s},${a})`,opacity:n}}return{color:t,opacity:1}}static getSizePixels(t){if(typeof t=="number"&&t>0)return t;switch(t){case"auto":case"size.auto":return 11;case"tiny":case"size.tiny":return 8;case"small":case"size.small":return 10;case"normal":case"size.normal":return 12;case"large":case"size.large":return 16;case"huge":case"size.huge":return 24;default:return 12}}static mapHAlign(t){switch(t){case"left":case"text.align_left":return"left";case"right":case"text.align_right":return"right";default:return"center"}}static mapVAlign(t){switch(t){case"top":case"text.align_top":return"top";case"bottom":case"text.align_bottom":return"bottom";default:return"middle"}}static buildGraphicElements(t,e){if(!t||t.length===0)return[];const i=new Map;for(const a of t)a&&!a._deleted&&i.set(a.position,a);const s=[];return i.forEach(a=>{const n=a._paneIndex??0,l=e(n);if(!l)return;const r=K.buildTableElements(a,l);s.push(...r)}),s}static buildTableElements(t,e){const i=t.rows||0,s=t.columns||0;if(i===0||s===0)return[];const a=t.border_width??0,n=t.frame_width??0,l=a>0&&!!t.border_color,r=n>0&&!!t.frame_color,o=new Map,u=new Set;if(t.merges)for(const I of t.merges){o.set(`${I.startCol},${I.startRow}`,{colspan:I.endCol-I.startCol+1,rowspan:I.endRow-I.startRow+1});for(let $=I.startRow;$<=I.endRow;$++)for(let P=I.startCol;P<=I.endCol;P++)$===I.startRow&&P===I.startCol||u.add(`${P},${$}`)}const d=4,c=2,g=1.25,h=[];for(let I=0;I<i;I++){h[I]=[];for(let $=0;$<s;$++){if(u.has(`${$},${I}`)){h[I][$]={text:"",lines:[],fontSize:12,fontFamily:"sans-serif",textColor:{color:"",opacity:0},bgColor:{color:"",opacity:0},halign:"center",valign:"middle",explicitWidth:0,explicitHeight:0,colspan:1,rowspan:1,skip:!0,padX:0,padY:0};continue}const P=t.cells?.[I]?.[$],F=o.get(`${$},${I}`),T=F?.colspan??1,B=F?.rowspan??1,Z=P&&!P._merged&&P.text||"",N=Z?Z.split(`
38
+ `):[],V=P?K.getSizePixels(P.text_size):12,O=P?.text_font_family==="monospace"?"monospace":"sans-serif";let Y=0,lt=0;P?.width>0&&(Y=Math.max(1,P.width*e.width/100)),P?.height>0&&(lt=Math.max(1,P.height*e.height/100));const ht=lt>0&&lt<4,Ht=ht?0:d,bt=ht?0:c,Lt=P&&!P._merged&&P.bgcolor&&typeof P.bgcolor=="string"&&P.bgcolor.length>0?P.bgcolor:"",Wt=P?.text_color||"";h[I][$]={text:Z,lines:N,fontSize:V,fontFamily:O,textColor:Wt?K.parseColor(Wt):{color:"#e0e0e0",opacity:1},bgColor:Lt?K.parseColor(Lt):{color:"",opacity:0},halign:P?K.mapHAlign(P.text_halign):"center",valign:P?K.mapVAlign(P.text_valign):"middle",explicitWidth:Y,explicitHeight:lt,colspan:T,rowspan:B,skip:!1,padX:Ht,padY:bt}}}const f=new Array(s).fill(0),y=new Array(i).fill(0);for(let I=0;I<i;I++)for(let $=0;$<s;$++){const P=h[I][$];if(P.skip||P.colspan>1||P.rowspan>1)continue;const F=K.measureMultiLineWidth(P.lines,P.fontSize,P.fontFamily),T=Math.max(P.lines.length,1),B=P.explicitWidth>0?P.explicitWidth:F+P.padX*2,Z=P.explicitHeight>0?P.explicitHeight:T*P.fontSize*g+P.padY*2;f[$]=Math.max(f[$],B),y[I]=Math.max(y[I],Z)}for(let I=0;I<s;I++)f[I]===0&&(f[I]=20);for(let I=0;I<i;I++)y[I]===0&&(y[I]=4);for(let I=0;I<i;I++)for(let $=0;$<s;$++){const P=h[I][$];if(P.skip)continue;const F=Math.max(P.lines.length,1),T=P.explicitHeight>0?P.explicitHeight:F*P.fontSize*g+P.padY*2;if(P.colspan>1){const B=K.sumRange(f,$,P.colspan),Z=K.measureMultiLineWidth(P.lines,P.fontSize,P.fontFamily),N=P.explicitWidth>0?P.explicitWidth:Z+P.padX*2;if(N>B){const V=(N-B)/P.colspan;for(let O=0;O<P.colspan;O++)f[$+O]+=V}P.rowspan===1&&(y[I]=Math.max(y[I],T))}if(P.rowspan>1){const B=K.sumRange(y,I,P.rowspan);if(T>B){const Z=(T-B)/P.rowspan;for(let N=0;N<P.rowspan;N++)y[I+N]+=Z}}}for(let I=0;I<s;I++)f[I]=Math.round(f[I]);for(let I=0;I<i;I++)y[I]=Math.round(y[I]);const x=new Array(s+1).fill(0);for(let I=0;I<s;I++)x[I+1]=x[I]+f[I];const b=new Array(i+1).fill(0);for(let I=0;I<i;I++)b[I+1]=b[I]+y[I];const D=r?n:0,w=x[s]+D*2,k=b[i]+D*2,m=Math.min(w,e.width),C=Math.min(k,e.height),v=K.computePosition(t.position,e,m,C),_=Math.round(v.x),A=Math.round(v.y),M=[],S=_+D,z=A+D;if(t.bgcolor){const{color:I,opacity:$}=K.parseColor(t.bgcolor);$>0&&M.push({type:"rect",shape:{x:_,y:A,width:m,height:C},style:{fill:I,opacity:$},silent:!0,z:0,z2:0})}if(r){const{color:I}=K.parseColor(t.frame_color),$=n/2;M.push({type:"rect",shape:{x:_+$,y:A+$,width:m-n,height:C-n},style:{fill:"none",stroke:I,lineWidth:n},silent:!0,z:0,z2:1})}const W=l?K.parseColor(t.border_color).color:"";for(let I=0;I<i;I++)for(let $=0;$<s;$++){const P=h[I][$];if(P.skip)continue;const F=S+x[$],T=z+b[I],B=K.sumRange(f,$,P.colspan),Z=K.sumRange(y,I,P.rowspan);if(F-_>=m||T-A>=C)continue;const N=Math.min(B,m-(F-_)),V=Math.min(Z,C-(T-A));if(P.bgColor.opacity>0&&M.push({type:"rect",shape:{x:F,y:T,width:N,height:V},style:{fill:P.bgColor.color,opacity:P.bgColor.opacity},silent:!0,z:0,z2:2}),l&&M.push({type:"rect",shape:{x:F,y:T,width:N,height:V},style:{fill:"none",stroke:W,lineWidth:a},silent:!0,z:0,z2:3}),P.text){let O,Y;switch(P.halign){case"left":O=F+P.padX,Y="left";break;case"right":O=F+N-P.padX,Y="right";break;default:O=F+N/2,Y="center";break}let lt,ht;switch(P.valign){case"top":lt=T+P.padY,ht="top";break;case"bottom":lt=T+V-P.padY,ht="bottom";break;default:lt=T+V/2,ht="middle";break}M.push({type:"text",x:O,y:lt,style:{text:P.text,fill:P.textColor.color,opacity:P.textColor.opacity,font:`${P.fontSize}px ${P.fontFamily}`,textAlign:Y,textVerticalAlign:ht,lineHeight:Math.round(P.fontSize*g)},silent:!0,z:0,z2:4})}}return M}static computePosition(t,e,i,s){const a=e.x,n=e.y,l=e.width,r=e.height;switch(t){case"top_left":return{x:a+4,y:n+4};case"top_center":return{x:a+(l-i)/2,y:n+4};case"top_right":return{x:a+l-i-4,y:n+4};case"middle_left":return{x:a+4,y:n+(r-s)/2};case"middle_center":return{x:a+(l-i)/2,y:n+(r-s)/2};case"middle_right":return{x:a+l-i-4,y:n+(r-s)/2};case"bottom_left":return{x:a+4,y:n+r-s-4};case"bottom_center":return{x:a+(l-i)/2,y:n+r-s-4};case"bottom_right":return{x:a+l-i-4,y:n+r-s-4};default:return{x:a+l-i-4,y:n+4}}}static measureMultiLineWidth(t,e,i){if(!t||t.length===0)return 0;const s=i==="monospace"?.6:.55;let a=0;for(const n of t)a=Math.max(a,n.length*e*s);return a}static sumRange(t,e,i){let s=0;for(let a=e;a<e+i&&a<t.length;a++)s+=t[a];return s}}var xi=Object.defineProperty,mi=(p,t,e)=>t in p?xi(p,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):p[t]=e,L=(p,t,e)=>(mi(p,typeof t!="symbol"?t+"":t,e),e);class bi{constructor(t,e={}){L(this,"chart"),L(this,"options"),L(this,"marketData",[]),L(this,"indicators",new Map),L(this,"timeToIndex",new Map),L(this,"pluginManager"),L(this,"drawingEditor"),L(this,"events",new yi),L(this,"isMainCollapsed",!1),L(this,"maximizedPaneId",null),L(this,"countdownInterval",null),L(this,"selectedDrawingId",null),L(this,"drawings",[]),L(this,"drawingRenderers",new ne),L(this,"coordinateConversion",{pixelToData:n=>{const l=this.chart.getOption();if(!l||!l.grid)return null;const r=l.grid.length;for(let o=0;o<r;o++)if(this.chart.containPixel({gridIndex:o},[n.x,n.y])){this.chart.convertFromPixel({seriesIndex:o},[n.x,n.y]);const u=this.chart.convertFromPixel({gridIndex:o},[n.x,n.y]);if(u)return{timeIndex:Math.round(u[0])-this.dataIndexOffset,value:u[1],paneIndex:o}}return null},dataToPixel:n=>{const l=n.paneIndex||0,r=this.chart.convertToPixel({gridIndex:l},[n.timeIndex+this.dataIndexOffset,n.value]);return r?{x:r[0],y:r[1]}:null}}),L(this,"upColor","#00da3c"),L(this,"downColor","#ec0000"),L(this,"defaultPadding",0),L(this,"padding"),L(this,"dataIndexOffset",0),L(this,"_paddingPoints",0),L(this,"LAZY_MIN_PADDING",5),L(this,"LAZY_MAX_PADDING",500),L(this,"LAZY_CHUNK_SIZE",50),L(this,"LAZY_EDGE_THRESHOLD",10),L(this,"_expandScheduled",!1),L(this,"rootContainer"),L(this,"layoutContainer"),L(this,"toolbarContainer"),L(this,"leftSidebar"),L(this,"rightSidebar"),L(this,"chartContainer"),L(this,"overlayContainer"),L(this,"_lastTables",[]),L(this,"_tableGraphicIds",[]),L(this,"_baseGraphics",[]),L(this,"_labelTooltipEl",null),L(this,"_lastLayout",null),L(this,"_mainHeightOverride",null),L(this,"_paneDragState",null),L(this,"_paneResizeRafId",null),L(this,"onKeyDown",n=>{(n.key==="Delete"||n.key==="Backspace")&&this.selectedDrawingId&&(this.removeDrawing(this.selectedDrawingId),this.selectedDrawingId=null,this.render())}),L(this,"onFullscreenChange",()=>{this.render()}),L(this,"isLocked",!1),L(this,"lockedState",null),this.rootContainer=t,this.options={title:void 0,height:"600px",backgroundColor:"#1e293b",upColor:"#00da3c",downColor:"#ec0000",fontColor:"#cbd5e1",fontFamily:"sans-serif",padding:.01,dataZoom:{visible:!0,position:"top",height:6},layout:{mainPaneHeight:"50%",gap:13},watermark:!0,...e},this.options.upColor&&(this.upColor=this.options.upColor),this.options.downColor&&(this.downColor=this.options.downColor),this.padding=this.options.padding!==void 0?this.options.padding:this.defaultPadding,this.options.height&&(typeof this.options.height=="number"?this.rootContainer.style.height=`${this.options.height}px`:this.rootContainer.style.height=this.options.height),this.rootContainer.innerHTML="",this.layoutContainer=document.createElement("div"),this.layoutContainer.style.display="flex",this.layoutContainer.style.width="100%",this.layoutContainer.style.height="100%",this.layoutContainer.style.overflow="hidden",this.rootContainer.appendChild(this.layoutContainer),this.leftSidebar=document.createElement("div"),this.leftSidebar.style.display="none",this.leftSidebar.style.width="250px",this.leftSidebar.style.flexShrink="0",this.leftSidebar.style.overflowY="auto",this.leftSidebar.style.backgroundColor=this.options.backgroundColor||"#1e293b",this.leftSidebar.style.borderRight="1px solid #334155",this.leftSidebar.style.padding="10px",this.leftSidebar.style.boxSizing="border-box",this.leftSidebar.style.color="#cbd5e1",this.leftSidebar.style.fontSize="12px",this.leftSidebar.style.fontFamily=this.options.fontFamily||"sans-serif",this.layoutContainer.appendChild(this.leftSidebar),this.toolbarContainer=document.createElement("div"),this.layoutContainer.appendChild(this.toolbarContainer),this.chartContainer=document.createElement("div"),this.chartContainer.style.flexGrow="1",this.chartContainer.style.height="100%",this.chartContainer.style.overflow="hidden",this.layoutContainer.appendChild(this.chartContainer),this.rightSidebar=document.createElement("div"),this.rightSidebar.style.display="none",this.rightSidebar.style.width="250px",this.rightSidebar.style.flexShrink="0",this.rightSidebar.style.overflowY="auto",this.rightSidebar.style.backgroundColor=this.options.backgroundColor||"#1e293b",this.rightSidebar.style.borderLeft="1px solid #334155",this.rightSidebar.style.padding="10px",this.rightSidebar.style.boxSizing="border-box",this.rightSidebar.style.color="#cbd5e1",this.rightSidebar.style.fontSize="12px",this.rightSidebar.style.fontFamily=this.options.fontFamily||"sans-serif",this.layoutContainer.appendChild(this.rightSidebar),this.chart=G.init(this.chartContainer),this.chartContainer.style.position="relative",this.overlayContainer=document.createElement("div"),this.overlayContainer.style.cssText="position:absolute;top:0;left:0;width:100%;height:100%;pointer-events:none;z-index:100;overflow:hidden;",this.chartContainer.appendChild(this.overlayContainer),this.pluginManager=new ai(this,this.toolbarContainer),this.drawingEditor=new hi(this),this.chart.on("dataZoom",n=>{this.events.emit("chart:dataZoom",n);const l=this.options.databox?.triggerOn,r=this.options.databox?.position;l==="click"&&r==="floating"&&this.chart.dispatchAction({type:"hideTip"}),this._checkEdgeAndExpand()}),this.chart.on("finished",n=>this.events.emit("chart:updated",n)),this.chart.getZr().on("mousedown",n=>{this._paneDragState||this.events.emit("mouse:down",n)}),this.chart.getZr().on("mousemove",n=>{this._paneDragState||this.events.emit("mouse:move",n)}),this.chart.getZr().on("mouseup",n=>this.events.emit("mouse:up",n)),this.chart.getZr().on("click",n=>{this._paneDragState||this.events.emit("mouse:click",n)});const i=this.chart.getZr(),s=i.setCursorStyle,a=this;i.setCursorStyle=function(n){if(a._paneDragState){s.call(this,"row-resize");return}n==="grab"&&(n="crosshair"),s.call(this,n)},this.bindDrawingEvents(),this.bindPaneResizeEvents(),window.addEventListener("resize",this.resize.bind(this)),document.addEventListener("fullscreenchange",this.onFullscreenChange),document.addEventListener("keydown",this.onKeyDown)}bindPaneResizeEvents(){const t=this.chart.getZr(),e=s=>{if(!this._lastLayout||this._lastLayout.paneBoundaries.length===0||this.maximizedPaneId)return null;const a=this.chart.getHeight();if(a<=0)return null;for(const n of this._lastLayout.paneBoundaries){const l=n.yPercent/100*a;if(Math.abs(s-l)<=6){if(n.aboveId==="main"&&this.isMainCollapsed||this.indicators.get(n.belowId)?.collapsed||n.aboveId!=="main"&&this.indicators.get(n.aboveId)?.collapsed)continue;return n}}return null},i=s=>s==="main"?this._lastLayout?.mainPaneHeight??50:this.indicators.get(s)?.height??15;t.on("mousemove",s=>{if(this._paneDragState){const a=s.offsetY-this._paneDragState.startY,n=this.chart.getHeight();if(n<=0)return;const l=a/n*100,r=this._paneDragState.aboveId==="main"?10:5,o=5;let u=this._paneDragState.startAboveHeight+l,d=this._paneDragState.startBelowHeight-l;if(u<r&&(u=r,d=this._paneDragState.startAboveHeight+this._paneDragState.startBelowHeight-r),d<o&&(d=o,u=this._paneDragState.startAboveHeight+this._paneDragState.startBelowHeight-o),this._paneDragState.aboveId==="main")this._mainHeightOverride=u;else{const g=this.indicators.get(this._paneDragState.aboveId);g&&(g.height=u)}const c=this.indicators.get(this._paneDragState.belowId);c&&(c.height=d),this._paneResizeRafId||(this._paneResizeRafId=requestAnimationFrame(()=>{this._paneResizeRafId=null,this.render()})),t.setCursorStyle("row-resize"),s.stop?.();return}e(s.offsetY)&&t.setCursorStyle("row-resize")}),t.on("mousedown",s=>{const a=e(s.offsetY);a&&(this._paneDragState={startY:s.offsetY,aboveId:a.aboveId,belowId:a.belowId,startAboveHeight:i(a.aboveId),startBelowHeight:i(a.belowId)},t.setCursorStyle("row-resize"),s.stop?.())}),t.on("mouseup",()=>{this._paneDragState&&(this._paneDragState=null,this._paneResizeRafId&&(cancelAnimationFrame(this._paneResizeRafId),this._paneResizeRafId=null),this.render())})}bindDrawingEvents(){let t=null;const e=i=>{if(!i||i.componentType!=="series"||!i.seriesName?.startsWith("drawings"))return null;i.seriesIndex;const s=i.seriesName.match(/drawings-pane-(\d+)/);if(!s)return null;const a=parseInt(s[1]),n=this.drawings.filter(r=>(r.paneIndex||0)===a)[i.dataIndex];if(!n)return null;const l=i.event?.target?.name;return{drawing:n,targetName:l,paneIdx:a}};this.chart.on("mouseover",i=>{const s=e(i);if(!s)return;const a=i.event?.target?.parent;if(a){const n=s.drawing.id===this.selectedDrawingId;t&&(clearTimeout(t),t=null),n||a.children().forEach(l=>{l.name&&l.name.startsWith("point")&&l.attr("style",{opacity:1})})}if(s.targetName==="line")this.events.emit("drawing:hover",{id:s.drawing.id,type:s.drawing.type}),this.chart.getZr().setCursorStyle("move");else if(s.targetName?.startsWith("point-")){const n=parseInt(s.targetName.split("-")[1])||0;this.events.emit("drawing:point:hover",{id:s.drawing.id,pointIndex:n}),this.chart.getZr().setCursorStyle("pointer")}}),this.chart.on("mouseout",i=>{const s=e(i);if(!s)return;const a=i.event?.target?.parent;if(s.drawing.id!==this.selectedDrawingId){if(t=setTimeout(()=>{if(a){if(this.selectedDrawingId===s.drawing.id)return;a.children().forEach(n=>{n.name&&n.name.startsWith("point")&&n.attr("style",{opacity:0})})}},50),s.targetName==="line")this.events.emit("drawing:mouseout",{id:s.drawing.id});else if(s.targetName?.startsWith("point-")){const n=parseInt(s.targetName.split("-")[1])||0;this.events.emit("drawing:point:mouseout",{id:s.drawing.id,pointIndex:n})}this.chart.getZr().setCursorStyle("default")}}),this.chart.on("mousedown",i=>{const s=e(i);if(!s)return;const a=i.event?.event||i.event,n=a?.offsetX,l=a?.offsetY;if(s.targetName==="line")this.events.emit("drawing:mousedown",{id:s.drawing.id,x:n,y:l});else if(s.targetName?.startsWith("point-")){const r=parseInt(s.targetName.split("-")[1])||0;this.events.emit("drawing:point:mousedown",{id:s.drawing.id,pointIndex:r,x:n,y:l})}}),this.chart.on("click",i=>{const s=e(i);if(s){if(this.selectedDrawingId!==s.drawing.id&&(this.selectedDrawingId=s.drawing.id,this.events.emit("drawing:selected",{id:s.drawing.id}),this.render()),s.targetName==="line")this.events.emit("drawing:click",{id:s.drawing.id});else if(s.targetName?.startsWith("point-")){const a=parseInt(s.targetName.split("-")[1])||0;this.events.emit("drawing:point:click",{id:s.drawing.id,pointIndex:a})}}}),this.chart.getZr().on("click",i=>{i.target||this.selectedDrawingId&&(this.events.emit("drawing:deselected",{id:this.selectedDrawingId}),this.selectedDrawingId=null,this.render())}),this._labelTooltipEl=document.createElement("div"),this._labelTooltipEl.style.cssText="position:absolute;display:none;pointer-events:none;z-index:200;background:rgba(30,41,59,0.95);color:#fff;border:1px solid #475569;border-radius:4px;padding:6px 10px;font-size:12px;line-height:1.5;white-space:pre-wrap;max-width:350px;box-shadow:0 2px 8px rgba(0,0,0,0.3);font-family:"+(this.options.fontFamily||"sans-serif")+";",this.chartContainer.appendChild(this._labelTooltipEl),this.chart.on("mouseover",{seriesType:"scatter"},i=>{const s=i.data?._tooltipText;if(!s||!this._labelTooltipEl)return;this._labelTooltipEl.textContent=s,this._labelTooltipEl.style.display="block";const a=this.chartContainer.getBoundingClientRect(),n=i.event?.event;if(n){const l=n.clientX-a.left,r=n.clientY-a.top,o=this._labelTooltipEl.offsetWidth,u=Math.min(l-o/2,a.width-o-8);this._labelTooltipEl.style.left=Math.max(4,u)+"px",this._labelTooltipEl.style.top=r+18+"px"}}),this.chart.on("mouseout",{seriesType:"scatter"},()=>{this._labelTooltipEl&&(this._labelTooltipEl.style.display="none")})}getChart(){return this.chart}getMarketData(){return this.marketData}getTimeToIndex(){return this.timeToIndex}getOptions(){return this.options}disableTools(){this.pluginManager.deactivatePlugin()}registerPlugin(t){this.pluginManager.register(t)}registerDrawingRenderer(t){this.drawingRenderers.register(t)}snapToCandle(t){const e=this.coordinateConversion.pixelToData(t);if(!e)return t;const i=e.paneIndex||0;if(i!==0)return t;const s=Math.round(e.timeIndex);if(s<0||s>=this.marketData.length)return t;const a=this.marketData[s];if(!a)return t;const n=this.chart.convertToPixel({gridIndex:i},[s+this.dataIndexOffset,a.close]);if(!n)return t;const l=n[0],r=[a.open,a.high,a.low,a.close];let o=r[0],u=1/0;for(const c of r){const g=this.chart.convertToPixel({gridIndex:i},[s+this.dataIndexOffset,c]);if(g){const h=Math.abs(g[1]-t.y);h<u&&(u=h,o=c)}}const d=this.chart.convertToPixel({gridIndex:i},[s+this.dataIndexOffset,o]);return{x:l,y:d?d[1]:t.y}}addDrawing(t){this.drawings.push(t),this.render()}removeDrawing(t){const e=this.drawings.findIndex(i=>i.id===t);if(e!==-1){const i=this.drawings[e];this.drawings.splice(e,1),this.events.emit("drawing:deleted",{id:i.id}),this.render()}}getDrawing(t){return this.drawings.find(e=>e.id===t)}updateDrawing(t){const e=this.drawings.findIndex(i=>i.id===t.id);e!==-1&&(this.drawings[e]=t,this.render())}lockChart(){if(this.isLocked)return;this.isLocked=!0;const t=this.chart.getOption();this.chart.setOption({dataZoom:t.dataZoom.map(e=>({...e,disabled:!0})),tooltip:{show:!1}})}unlockChart(){if(!this.isLocked)return;this.isLocked=!1;const t=this.chart.getOption();(this.options.dataZoom||{}).visible,t.dataZoom&&this.chart.setOption({dataZoom:t.dataZoom.map(e=>({...e,disabled:!1})),tooltip:{show:!0}})}setZoom(t,e){this.chart.dispatchAction({type:"dataZoom",start:t,end:e})}setMarketData(t){this.marketData=t,this.rebuildTimeIndex(),this.render()}updateData(t){if(t.length===0)return;const e=new Map;this.marketData.forEach(y=>{e.set(y.time,y)}),t.forEach(y=>{e.has(y.time),e.set(y.time,y)}),this.marketData=Array.from(e.values()).sort((y,x)=>y.time-x.time),this.rebuildTimeIndex();const i=this.dataIndexOffset,s=wt.buildCandlestickSeries(this.marketData,this.options),a={value:[NaN,NaN,NaN,NaN],itemStyle:{opacity:0}},n=[...Array(i).fill(a),...s.data,...Array(i).fill(a)],l=[...Array(i).fill(""),...this.marketData.map(y=>new Date(y.time).toLocaleString()),...Array(i).fill("")],r=this.chart.getOption(),o=Rt.calculate(this.chart.getHeight(),this.indicators,this.options,this.isMainCollapsed,this.maximizedPaneId,this.marketData,this._mainHeightOverride??void 0);this._lastLayout=o;const u=[...Array(i).fill(null),...this.marketData,...Array(i).fill(null)],{series:d,barColors:c}=wt.buildIndicatorSeries(this.indicators,this.timeToIndex,o.paneLayout,l.length,i,u,o.overlayYAxisMap,o.separatePaneYAxisOffset),g=n.map((y,x)=>c[x]?{value:y.value||y,itemStyle:{color:c[x],color0:c[x]}}:y),h={xAxis:r.xAxis.map((y,x)=>({data:l})),series:[{data:g,markLine:s.markLine},...d]};this.chart.setOption(h,{notMerge:!1});const f=[];this.indicators.forEach(y=>{Object.values(y.plots).forEach(x=>{x.options?.style==="table"&&x.data?.forEach(b=>{(Array.isArray(b.value)?b.value:[b.value]).forEach(D=>{D&&!D._deleted&&(D._paneIndex=D.force_overlay?0:y.paneIndex,f.push(D))})})})}),this._lastTables=f,this._renderTableOverlays(),this.startCountdown()}startCountdown(){if(this.stopCountdown(),!this.options.lastPriceLine?.showCountdown||this.marketData.length===0)return;let t=this.options.interval;if(!t&&this.marketData.length>=2){const i=this.marketData[this.marketData.length-1],s=this.marketData[this.marketData.length-2];t=i.time-s.time}if(!t)return;const e=()=>{if(this.marketData.length===0)return;const i=this.marketData[this.marketData.length-1].time+t,s=Date.now(),a=i-s;if(a<=0)return;const n=Math.abs(a),l=Math.floor(n/36e5),r=Math.floor(n%36e5/6e4),o=Math.floor(n%6e4/1e3),u=`${l>0?l.toString().padStart(2,"0")+":":""}${r.toString().padStart(2,"0")}:${o.toString().padStart(2,"0")}`,d=this.chart.getOption();if(!d||!d.series)return;const c=d.series.findIndex(b=>b.type==="candlestick");if(c===-1)return;const g=d.series[c];if(!g.markLine||!g.markLine.data||!g.markLine.data[0])return;const h=g.markLine.data[0];h.label.formatter;const f=h.yAxis;let y="";if(this.options.yAxisLabelFormatter)y=this.options.yAxisLabelFormatter(f);else{const b=this.options.yAxisDecimalPlaces!==void 0?this.options.yAxisDecimalPlaces:R.autoDetectDecimals(this.marketData);y=R.formatValue(f,b)}const x=`${y}
39
+ ${u}`;this.chart.setOption({series:[{id:"__candlestick__",markLine:{data:[{...h,label:{...h.label,formatter:x}}]}}]})};e(),this.countdownInterval=setInterval(e,1e3)}stopCountdown(){this.countdownInterval&&(clearInterval(this.countdownInterval),this.countdownInterval=null)}addIndicator(t,e,i={}){const s=i.overlay!==void 0?i.overlay:i.isOverlay??!1;let a=0;if(!s){let l=0;this.indicators.forEach(r=>{r.paneIndex>l&&(l=r.paneIndex)}),a=l+1}const n=new We(t,e,a,{height:i.height,collapsed:!1,titleColor:i.titleColor,controls:i.controls});return this.indicators.set(t,n),this.render(),n}setIndicator(t,e,i=!1){this.addIndicator(t,{[t]:e},{overlay:i})}removeIndicator(t){this.indicators.delete(t),this.render()}toggleIndicator(t,e="collapse"){if(e==="fullscreen"){document.fullscreenElement?document.exitFullscreen():this.rootContainer.requestFullscreen();return}if(e==="maximize"){this.maximizedPaneId===t?this.maximizedPaneId=null:this.maximizedPaneId=t,this.render();return}if(t==="main"){this.isMainCollapsed=!this.isMainCollapsed,this.render();return}const i=this.indicators.get(t);i&&(i.toggleCollapse(),this.render())}resize(){this.chart.resize(),this._renderTableOverlays()}_buildTableGraphics(){const t=this.chart.getModel(),e=s=>t.getComponent("grid",s)?.coordinateSystem?.getRect(),i=K.buildGraphicElements(this._lastTables,e);this._tableGraphicIds=[];for(let s=0;s<i.length;s++){const a=`__qf_table_${s}`;i[s].id=a,this._tableGraphicIds.push(a)}return i}_renderTableOverlays(){const t=this._buildTableGraphics(),e=[...this._baseGraphics,...t];this.chart.setOption({graphic:e},{replaceMerge:["graphic"]}),st.clearAll(this.overlayContainer)}destroy(){this.stopCountdown(),window.removeEventListener("resize",this.resize.bind(this)),document.removeEventListener("fullscreenchange",this.onFullscreenChange),document.removeEventListener("keydown",this.onKeyDown),this.pluginManager.deactivatePlugin(),this.pluginManager.destroy(),this.chart.dispose()}rebuildTimeIndex(){this.timeToIndex.clear(),this.marketData.forEach((i,s)=>{this.timeToIndex.set(i.time,s)});const t=this.marketData.length,e=Math.ceil(t*this.padding);this._paddingPoints=Math.max(this._paddingPoints,e,this.LAZY_MIN_PADDING),this.dataIndexOffset=this._paddingPoints}expandPadding(t){this._resizePadding(t)}_resizePadding(t){const e=Math.ceil(this.marketData.length*this.padding);if(t=Math.max(t,e,this.LAZY_MIN_PADDING),t=Math.min(t,this.LAZY_MAX_PADDING),t===this._paddingPoints)return;const i=this._paddingPoints,s=this.marketData.length+2*i,a=this.chart.getOption(),n=a?.dataZoom?.find(A=>A.type==="slider"||A.type==="inside"),l=n?n.start/100*s:0,r=n?n.end/100*s:s,o=t-i;this._paddingPoints=t,this.dataIndexOffset=this._paddingPoints;const u=this._paddingPoints,d={value:[NaN,NaN,NaN,NaN],itemStyle:{opacity:0}},c=wt.buildCandlestickSeries(this.marketData,this.options),g=[...Array(u).fill(d),...c.data,...Array(u).fill(d)],h=[...Array(u).fill(""),...this.marketData.map(A=>new Date(A.time).toLocaleString()),...Array(u).fill("")],f=[...Array(u).fill(null),...this.marketData,...Array(u).fill(null)],y=Rt.calculate(this.chart.getHeight(),this.indicators,this.options,this.isMainCollapsed,this.maximizedPaneId,this.marketData,this._mainHeightOverride??void 0),{series:x,barColors:b}=wt.buildIndicatorSeries(this.indicators,this.timeToIndex,y.paneLayout,h.length,u,f,y.overlayYAxisMap,y.separatePaneYAxisOffset),D=g.map((A,M)=>b[M]?{value:A.value||A,itemStyle:{color:b[M],color0:b[M]}}:A),w=this.marketData.length+2*t,k=Math.max(0,(l+o)/w*100),m=Math.min(100,(r+o)/w*100),C=[],v=new Map;this.drawings.forEach(A=>{const M=A.paneIndex||0;v.has(M)||v.set(M,[]),v.get(M).push(A)}),v.forEach(A=>{C.push({data:A.map(M=>[M.points[0].timeIndex+this.dataIndexOffset,M.points[0].value,M.points[1].timeIndex+this.dataIndexOffset,M.points[1].value])})});const _={xAxis:a.xAxis.map(()=>({data:h})),dataZoom:[{start:k,end:m},{start:k,end:m}],series:[{data:D,markLine:c.markLine},...x.map(A=>{const M={data:A.data};return A.renderItem&&(M.renderItem=A.renderItem),M}),...C]};this.chart.setOption(_,{notMerge:!1})}_checkEdgeAndExpand(){if(this._expandScheduled)return;const t=this.chart.getOption()?.dataZoom?.find(f=>f.type==="slider"||f.type==="inside");if(!t)return;const e=this._paddingPoints,i=this.marketData.length,s=i+2*e,a=Math.round(t.start/100*s),n=Math.round(t.end/100*s),l=e,r=e+i-1,o=Math.max(0,Math.min(n,r)-Math.max(a,l)+1),u=a<this.LAZY_EDGE_THRESHOLD,d=n>s-this.LAZY_EDGE_THRESHOLD;if((u||d)&&e<this.LAZY_MAX_PADDING&&o>=3){this._expandScheduled=!0,requestAnimationFrame(()=>{this._expandScheduled=!1,this._resizePadding(e+this.LAZY_CHUNK_SIZE)});return}const c=Math.max(0,e-a),g=Math.max(0,n-(e+i-1)),h=Math.max(c+this.LAZY_CHUNK_SIZE,g+this.LAZY_CHUNK_SIZE);e>h+this.LAZY_CHUNK_SIZE&&(this._expandScheduled=!0,requestAnimationFrame(()=>{this._expandScheduled=!1,this._resizePadding(h)}))}render(){if(this.marketData.length===0)return;let t=null;try{const m=this.chart.getOption();if(m&&m.dataZoom&&m.dataZoom.length>0){const C=m.dataZoom.find(v=>v.type==="slider"||v.type==="inside");C&&(t={start:C.start,end:C.end})}}catch{}const e=this.options.databox?.position,i=this.leftSidebar.style.display,s=this.rightSidebar.style.display,a=e==="left"?"block":"none",n=e==="right"?"block":"none";(i!==a||s!==n)&&(this.leftSidebar.style.display=a,this.rightSidebar.style.display=n,this.chart.resize());const l=this.dataIndexOffset,r=[...Array(l).fill(""),...this.marketData.map(m=>new Date(m.time).toLocaleString()),...Array(l).fill("")],o=Rt.calculate(this.chart.getHeight(),this.indicators,this.options,this.isMainCollapsed,this.maximizedPaneId,this.marketData,this._mainHeightOverride??void 0);if(this._lastLayout=o,!t&&o.dataZoom&&this.marketData.length>0){const m=this.marketData.length,C=r.length,v=l/C,_=m/C;o.dataZoom.forEach(A=>{if(A.start!==void 0){const M=A.start/100,S=v+M*_;A.start=S*100}if(A.end!==void 0){const M=A.end/100,S=v+M*_;A.end=S*100}})}t&&o.dataZoom&&o.dataZoom.forEach(m=>{m.start=t.start,m.end=t.end}),o.xAxis.forEach(m=>{m.data=r,m.boundaryGap=!1});const u=wt.buildCandlestickSeries(this.marketData,this.options),d={value:[NaN,NaN,NaN,NaN],itemStyle:{opacity:0}};u.data=[...Array(l).fill(d),...u.data,...Array(l).fill(d)];const c=[...Array(l).fill(null),...this.marketData,...Array(l).fill(null)],{series:g,barColors:h}=wt.buildIndicatorSeries(this.indicators,this.timeToIndex,o.paneLayout,r.length,l,c,o.overlayYAxisMap,o.separatePaneYAxisOffset);u.data=u.data.map((m,C)=>h[C]?{value:m.value||m,itemStyle:{color:h[C],color0:h[C]}}:m);const f=[];this.indicators.forEach((m,C)=>{m.paneIndex===0&&f.push({id:C,titleColor:m.titleColor})});const y=ii.build(o,this.options,this.toggleIndicator.bind(this),this.isMainCollapsed,this.maximizedPaneId,f),x=new Map;this.drawings.forEach(m=>{const C=m.paneIndex||0;x.has(C)||x.set(C,[]),x.get(C).push(m)});const b=[];x.forEach((m,C)=>{b.push({type:"custom",name:`drawings-pane-${C}`,xAxisIndex:C,yAxisIndex:C,clip:!0,renderItem:(v,_)=>{const A=m[v.dataIndex];if(!A)return;const M=this.drawingRenderers.get(A.type);if(!M)return;const S=this.dataIndexOffset,z=A.points.map(W=>_.coord([W.timeIndex+S,W.value]));return M.render({drawing:A,pixelPoints:z,isSelected:A.id===this.selectedDrawingId,api:_})},data:m.map(v=>{const _=[];return v.points.forEach(A=>{_.push(A.timeIndex+this.dataIndexOffset,A.value)}),_}),encode:(()=>{const v=m.reduce((M,S)=>Math.max(M,S.points.length),0),_=Array.from({length:v},(M,S)=>S*2),A=Array.from({length:v},(M,S)=>S*2+1);return{x:_,y:A}})(),z:100,silent:!1})});const D=m=>{const C=si.format(m,this.options),v=this.options.databox?.position;return v==="left"?(this.leftSidebar.innerHTML=C,""):v==="right"?(this.rightSidebar.innerHTML=C,""):this.options.databox?`<div style="min-width: 200px;">${C}</div>`:""},w=[];this.indicators.forEach(m=>{Object.values(m.plots).forEach(C=>{C.options?.style==="table"&&C.data?.forEach(v=>{(Array.isArray(v.value)?v.value:[v.value]).forEach(_=>{_&&!_._deleted&&(_._paneIndex=_.force_overlay?0:m.paneIndex,w.push(_))})})})});const k={backgroundColor:this.options.backgroundColor,animation:!1,legend:{show:!1},tooltip:{show:!0,showContent:!!this.options.databox,trigger:"axis",triggerOn:this.options.databox?.triggerOn??"mousemove",axisPointer:{type:"cross",label:{backgroundColor:"#475569"}},backgroundColor:"rgba(30, 41, 59, 0.9)",borderWidth:1,borderColor:"#334155",padding:10,textStyle:{color:"#fff",fontFamily:this.options.fontFamily||"sans-serif"},formatter:D,extraCssText:e!=="floating"&&e!==void 0?"display: none !important;":void 0,position:(m,C,v,_,A)=>{if(this.options.databox?.position==="floating"){const M={top:10};return M[["left","right"][+(m[0]<A.viewSize[0]/2)]]=30,M}return null}},axisPointer:{link:{xAxisIndex:"all"},label:{backgroundColor:"#475569"}},graphic:y,grid:o.grid,xAxis:o.xAxis,yAxis:o.yAxis,dataZoom:o.dataZoom,series:[u,...g,...b]};if(this.chart.setOption(k,!0),this._baseGraphics=y,this._lastTables=w,w.length>0){const m=this._buildTableGraphics();if(m.length>0){const C=[...y,...m];this.chart.setOption({graphic:C},{replaceMerge:["graphic"]})}}else this._tableGraphicIds=[];st.clearAll(this.overlayContainer)}}var vi=Object.defineProperty,wi=(p,t,e)=>t in p?vi(p,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):p[t]=e,rt=(p,t,e)=>(wi(p,typeof t!="symbol"?t+"":t,e),e);class it{constructor(t){rt(this,"id"),rt(this,"name"),rt(this,"icon"),rt(this,"context"),rt(this,"eventListeners",[]),rt(this,"_snapIndicator",null),rt(this,"_snapMoveHandler",null),rt(this,"_snapKeyDownHandler",null),rt(this,"_snapKeyUpHandler",null),rt(this,"_snapBlurHandler",null),rt(this,"_snapActive",!1),rt(this,"_lastMouseEvent",null),this.id=t.id,this.name=t.name,this.icon=t.icon}init(t){this.context=t,this.onInit()}onInit(){}activate(){this.onActivate(),this._bindSnapIndicator(),this.context.events.emit("plugin:activated",this.id)}onActivate(){}deactivate(){this._unbindSnapIndicator(),this.onDeactivate(),this.context.events.emit("plugin:deactivated",this.id)}onDeactivate(){}destroy(){this._unbindSnapIndicator(),this.removeAllListeners(),this.onDestroy()}onDestroy(){}on(t,e){this.context.events.on(t,e),this.eventListeners.push({event:t,handler:e})}off(t,e){this.context.events.off(t,e),this.eventListeners=this.eventListeners.filter(i=>i.event!==t||i.handler!==e)}removeAllListeners(){this.eventListeners.forEach(({event:t,handler:e})=>{this.context.events.off(t,e)}),this.eventListeners=[]}get chart(){return this.context.getChart()}get marketData(){return this.context.getMarketData()}getPoint(t){const e=t.offsetX,i=t.offsetY,s=t.event;if(s?.ctrlKey||s?.metaKey){const a=this.context.snapToCandle({x:e,y:i});return[a.x,a.y]}return[e,i]}_bindSnapIndicator(){const t=this.context.getChart().getZr();this._snapMoveHandler=e=>{this._lastMouseEvent=e,e.event?.ctrlKey||e.event?.metaKey?this._showSnapAt(e.offsetX,e.offsetY):this._hideSnap()},this._snapKeyDownHandler=e=>{(e.key==="Control"||e.key==="Meta")&&this._lastMouseEvent&&this._showSnapAt(this._lastMouseEvent.offsetX,this._lastMouseEvent.offsetY)},this._snapKeyUpHandler=e=>{(e.key==="Control"||e.key==="Meta")&&this._hideSnap()},this._snapBlurHandler=()=>{this._hideSnap()},t.on("mousemove",this._snapMoveHandler),window.addEventListener("keydown",this._snapKeyDownHandler),window.addEventListener("keyup",this._snapKeyUpHandler),window.addEventListener("blur",this._snapBlurHandler)}_unbindSnapIndicator(){if(this._snapMoveHandler){try{this.context.getChart().getZr().off("mousemove",this._snapMoveHandler)}catch{}this._snapMoveHandler=null}this._snapKeyDownHandler&&(window.removeEventListener("keydown",this._snapKeyDownHandler),this._snapKeyDownHandler=null),this._snapKeyUpHandler&&(window.removeEventListener("keyup",this._snapKeyUpHandler),this._snapKeyUpHandler=null),this._snapBlurHandler&&(window.removeEventListener("blur",this._snapBlurHandler),this._snapBlurHandler=null),this._removeSnapGraphic(),this._lastMouseEvent=null}_removeSnapGraphic(){if(this._snapIndicator){try{this.context.getChart().getZr().remove(this._snapIndicator)}catch{}this._snapIndicator=null,this._snapActive=!1}}_showSnapAt(t,e){const i=this.context.snapToCandle({x:t,y:e}),s=this.context.getChart().getZr();this._snapIndicator||(this._snapIndicator=new G.graphic.Circle({shape:{cx:0,cy:0,r:5},style:{fill:"rgba(59, 130, 246, 0.3)",stroke:"#3b82f6",lineWidth:1.5},z:9999,silent:!0}),s.add(this._snapIndicator)),this._snapIndicator.setShape({cx:i.x,cy:i.y}),this._snapIndicator.show(),this._snapActive=!0}_hideSnap(){this._snapIndicator&&this._snapActive&&(this._snapIndicator.hide(),this._snapActive=!1)}}var Ci=Object.defineProperty,Ii=(p,t,e)=>t in p?Ci(p,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):p[t]=e,Q=(p,t,e)=>(Ii(p,typeof t!="symbol"?t+"":t,e),e);class _i extends it{constructor(t={}){super({id:"measure",name:t?.name||"Measure",icon:t?.icon||'<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="#e3e3e3"><path d="M160-240q-33 0-56.5-23.5T80-320v-320q0-33 23.5-56.5T160-720h640q33 0 56.5 23.5T880-640v320q0 33-23.5 56.5T800-240H160Zm0-80h640v-320H680v160h-80v-160h-80v160h-80v-160h-80v160h-80v-160H160v320Zm120-160h80-80Zm160 0h80-80Zm160 0h80-80Zm-120 0Z"/></svg>'}),Q(this,"zr"),Q(this,"state","idle"),Q(this,"startPoint",null),Q(this,"endPoint",null),Q(this,"group",null),Q(this,"rect",null),Q(this,"labelRect",null),Q(this,"labelText",null),Q(this,"lineV",null),Q(this,"lineH",null),Q(this,"arrowStart",null),Q(this,"arrowEnd",null),Q(this,"onMouseDown",()=>{this.state==="finished"&&this.removeGraphic()}),Q(this,"onChartInteraction",()=>{this.group&&this.removeGraphic()}),Q(this,"onClick",e=>{this.state==="idle"?(this.state="drawing",this.startPoint=this.getPoint(e),this.endPoint=this.getPoint(e),this.initGraphic(),this.updateGraphic()):this.state==="drawing"&&(this.state="finished",this.endPoint=this.getPoint(e),this.updateGraphic(),this.context.disableTools(),this.enableClearListeners())}),Q(this,"clearHandlers",{}),Q(this,"onMouseMove",e=>{this.state==="drawing"&&(this.endPoint=this.getPoint(e),this.updateGraphic())})}onInit(){this.zr=this.chart.getZr()}onActivate(){this.state="idle",this.chart.getZr().setCursorStyle("crosshair"),this.zr.on("click",this.onClick),this.zr.on("mousemove",this.onMouseMove)}onDeactivate(){this.state="idle",this.chart.getZr().setCursorStyle("default"),this.zr.off("click",this.onClick),this.zr.off("mousemove",this.onMouseMove),this.disableClearListeners(),this.state==="drawing"&&this.removeGraphic()}onDestroy(){this.removeGraphic()}enableClearListeners(){const t=()=>{this.removeGraphic()};setTimeout(()=>{this.zr.on("click",t)},10),this.zr.on("mousedown",this.onMouseDown),this.context.events.on("chart:dataZoom",this.onChartInteraction),this.clearHandlers={click:t,mousedown:this.onMouseDown,dataZoom:this.onChartInteraction}}disableClearListeners(){this.clearHandlers.click&&this.zr.off("click",this.clearHandlers.click),this.clearHandlers.mousedown&&this.zr.off("mousedown",this.clearHandlers.mousedown),this.clearHandlers.dataZoom&&this.context.events.off("chart:dataZoom",this.clearHandlers.dataZoom),this.clearHandlers={}}initGraphic(){this.group||(this.group=new G.graphic.Group,this.rect=new G.graphic.Rect({shape:{x:0,y:0,width:0,height:0},style:{fill:"rgba(0,0,0,0)",stroke:"transparent",lineWidth:0},z:100}),this.lineV=new G.graphic.Line({shape:{x1:0,y1:0,x2:0,y2:0},style:{stroke:"#fff",lineWidth:1,lineDash:[4,4]},z:101}),this.lineH=new G.graphic.Line({shape:{x1:0,y1:0,x2:0,y2:0},style:{stroke:"#fff",lineWidth:1,lineDash:[4,4]},z:101}),this.arrowStart=new G.graphic.Polygon({shape:{points:[[0,0],[-5,10],[5,10]]},style:{fill:"#fff"},z:102}),this.arrowEnd=new G.graphic.Polygon({shape:{points:[[0,0],[-5,-10],[5,-10]]},style:{fill:"#fff"},z:102}),this.labelRect=new G.graphic.Rect({shape:{x:0,y:0,width:0,height:0,r:4},style:{fill:"transparent",stroke:"transparent",lineWidth:0,shadowBlur:5,shadowColor:"rgba(0,0,0,0.3)"},z:102}),this.labelText=new G.graphic.Text({style:{x:0,y:0,text:"",fill:"#fff",font:"12px sans-serif",align:"center",verticalAlign:"middle"},z:103}),this.group.add(this.rect),this.group.add(this.lineV),this.group.add(this.lineH),this.group.add(this.arrowStart),this.group.add(this.arrowEnd),this.group.add(this.labelRect),this.group.add(this.labelText),this.zr.add(this.group))}removeGraphic(){this.group&&(this.zr.remove(this.group),this.group=null,this.disableClearListeners())}updateGraphic(){if(!this.startPoint||!this.endPoint||!this.group)return;const[t,e]=this.startPoint,[i,s]=this.endPoint,a=this.context.coordinateConversion.pixelToData({x:t,y:e}),n=this.context.coordinateConversion.pixelToData({x:i,y:s});if(!a||!n)return;const l=Math.round(a.timeIndex),r=Math.round(n.timeIndex),o=a.value,u=n.value,d=r-l,c=u-o,g=c/o*100,h=c>=0,f=h?"rgba(33, 150, 243, 0.2)":"rgba(236, 0, 0, 0.2)",y=h?"#2196F3":"#ec0000";this.rect.setShape({x:Math.min(t,i),y:Math.min(e,s),width:Math.abs(i-t),height:Math.abs(s-e)}),this.rect.setStyle({fill:f});const x=(t+i)/2,b=(e+s)/2;this.lineV.setShape({x1:x,y1:e,x2:x,y2:s}),this.lineV.setStyle({stroke:y}),this.lineH.setShape({x1:t,y1:b,x2:i,y2:b}),this.lineH.setStyle({stroke:y});const D=Math.min(e,s),w=Math.max(e,s);this.arrowStart.setStyle({fill:"none"}),this.arrowEnd.setStyle({fill:"none"}),h?(this.arrowStart.setShape({points:[[x,D],[x-4,D+6],[x+4,D+6]]}),this.arrowStart.setStyle({fill:y})):(this.arrowEnd.setShape({points:[[x,w],[x-4,w-6],[x+4,w-6]]}),this.arrowEnd.setStyle({fill:y}));const k=[`${c.toFixed(2)} (${g.toFixed(2)}%)`,`${d} bars`].join(`
40
+ `),m=140,C=40,v=Math.max(e,s),_=Math.min(e,s);let A=(t+i)/2-m/2,M=v+10;const S=this.chart.getHeight();M+C>S&&(M=_-C-10),this.labelRect.setShape({x:A,y:M,width:m,height:C}),this.labelRect.setStyle({fill:"#1e293b",stroke:y,lineWidth:1}),this.labelText.setStyle({x:A+m/2,y:M+C/2,text:k,fill:"#fff"})}}var ki=Object.defineProperty,Pi=(p,t,e)=>t in p?ki(p,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):p[t]=e,Ai=(p,t,e)=>(Pi(p,typeof t!="symbol"?t+"":t,e),e);class oe{constructor(){Ai(this,"type","line")}render(t){const{drawing:e,pixelPoints:i,isSelected:s}=t,[a,n]=i[0],[l,r]=i[1],o=e.style?.color||"#3b82f6";return{type:"group",children:[{type:"line",name:"line",shape:{x1:a,y1:n,x2:l,y2:r},style:{stroke:o,lineWidth:e.style?.lineWidth||2}},{type:"circle",name:"point-0",shape:{cx:a,cy:n,r:4},style:{fill:"#fff",stroke:o,lineWidth:1,opacity:s?1:0}},{type:"circle",name:"point-1",shape:{cx:l,cy:r,r:4},style:{fill:"#fff",stroke:o,lineWidth:1,opacity:s?1:0}}]}}}var Di=Object.defineProperty,Mi=(p,t,e)=>t in p?Di(p,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):p[t]=e,ct=(p,t,e)=>(Mi(p,typeof t!="symbol"?t+"":t,e),e);class Si extends it{constructor(t={}){super({id:"trend-line",name:t?.name||"Trend Line",icon:t?.icon||'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="2" y1="22" x2="22" y2="2" /></svg>'}),ct(this,"zr"),ct(this,"state","idle"),ct(this,"startPoint",null),ct(this,"endPoint",null),ct(this,"group",null),ct(this,"line",null),ct(this,"startCircle",null),ct(this,"endCircle",null),ct(this,"onClick",e=>{if(this.state==="idle")this.state="drawing",this.startPoint=this.getPoint(e),this.endPoint=this.getPoint(e),this.initGraphic(),this.updateGraphic();else if(this.state==="drawing"){if(this.state="finished",this.endPoint=this.getPoint(e),this.updateGraphic(),this.startPoint&&this.endPoint){const i=this.context.coordinateConversion.pixelToData({x:this.startPoint[0],y:this.startPoint[1]}),s=this.context.coordinateConversion.pixelToData({x:this.endPoint[0],y:this.endPoint[1]});if(i&&s){const a=i.paneIndex||0;this.context.addDrawing({id:`line-${Date.now()}`,type:"line",points:[i,s],paneIndex:a,style:{color:"#3b82f6",lineWidth:2}})}}this.removeGraphic(),this.context.disableTools()}}),ct(this,"onMouseMove",e=>{this.state==="drawing"&&(this.endPoint=this.getPoint(e),this.updateGraphic())})}onInit(){this.zr=this.chart.getZr(),this.context.registerDrawingRenderer(new oe)}onActivate(){this.state="idle",this.chart.getZr().setCursorStyle("crosshair"),this.zr.on("click",this.onClick),this.zr.on("mousemove",this.onMouseMove)}onDeactivate(){this.state="idle",this.chart.getZr().setCursorStyle("default"),this.zr.off("click",this.onClick),this.zr.off("mousemove",this.onMouseMove),this.state==="drawing"&&this.removeGraphic()}onDestroy(){this.removeGraphic()}initGraphic(){this.group||(this.group=new G.graphic.Group,this.line=new G.graphic.Line({shape:{x1:0,y1:0,x2:0,y2:0},style:{stroke:"#3b82f6",lineWidth:2},z:100}),this.startCircle=new G.graphic.Circle({shape:{cx:0,cy:0,r:4},style:{fill:"#fff",stroke:"#3b82f6",lineWidth:1},z:101}),this.endCircle=new G.graphic.Circle({shape:{cx:0,cy:0,r:4},style:{fill:"#fff",stroke:"#3b82f6",lineWidth:1},z:101}),this.group.add(this.line),this.group.add(this.startCircle),this.group.add(this.endCircle),this.zr.add(this.group))}removeGraphic(){this.group&&(this.zr.remove(this.group),this.group=null)}updateGraphic(){if(!this.startPoint||!this.endPoint||!this.group)return;const[t,e]=this.startPoint,[i,s]=this.endPoint;this.line.setShape({x1:t,y1:e,x2:i,y2:s}),this.startCircle.setShape({cx:t,cy:e}),this.endCircle.setShape({cx:i,cy:s})}}var Gi=Object.defineProperty,$i=(p,t,e)=>t in p?Gi(p,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):p[t]=e,zi=(p,t,e)=>($i(p,typeof t!="symbol"?t+"":t,e),e);const Xt=[0,.236,.382,.5,.618,.786,1],Tt=["#787b86","#f44336","#ff9800","#4caf50","#2196f3","#00bcd4","#787b86"];class ae{constructor(){zi(this,"type","fibonacci")}render(t){const{drawing:e,pixelPoints:i,isSelected:s}=t,[a,n]=i[0],[l,r]=i[1],o=e.style?.color||"#3b82f6",u=Math.min(a,l),d=Math.max(a,l),c=d-u,g=r-n,h=e.points[0].value,f=e.points[1].value,y=f-h,x=[],b=[];return Xt.forEach((D,w)=>{const k=r-g*D,m=Tt[w%Tt.length];b.push({type:"line",shape:{x1:u,y1:k,x2:d,y2:k},style:{stroke:m,lineWidth:1},silent:!0});const C=f-y*D;if(b.push({type:"text",style:{text:`${D} (${C.toFixed(2)})`,x:u+5,y:k-10,fill:m,fontSize:10},silent:!0}),w<Xt.length-1){const v=Xt[w+1],_=r-g*v,A=Math.abs(_-k),M=Math.min(k,_);x.push({type:"rect",name:"line",shape:{x:u,y:M,width:c,height:A},style:{fill:Tt[(w+1)%Tt.length],opacity:.1}})}}),{type:"group",children:[...x,...b,{type:"line",name:"line",shape:{x1:a,y1:n,x2:l,y2:r},style:{stroke:"#999",lineWidth:1,lineDash:[4,4]}},{type:"circle",name:"point-0",shape:{cx:a,cy:n,r:4},style:{fill:"#fff",stroke:o,lineWidth:1,opacity:s?1:0},z:100},{type:"circle",name:"point-1",shape:{cx:l,cy:r,r:4},style:{fill:"#fff",stroke:o,lineWidth:1,opacity:s?1:0},z:100}]}}}var Ei=Object.defineProperty,Li=(p,t,e)=>t in p?Ei(p,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):p[t]=e,gt=(p,t,e)=>(Li(p,typeof t!="symbol"?t+"":t,e),e);class Wi extends it{constructor(t={}){super({id:"fibonacci-tool",name:t.name||"Fibonacci Retracement",icon:t.icon||'<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="#e3e3e3"><path d="M120-80v-80h720v80H120Zm0-240v-80h720v80H120Zm0-240v-80h720v80H120Zm0-240v-80h720v80H120Z"/></svg>'}),gt(this,"startPoint",null),gt(this,"endPoint",null),gt(this,"state","idle"),gt(this,"graphicGroup",null),gt(this,"levels",[0,.236,.382,.5,.618,.786,1]),gt(this,"colors",["#787b86","#f44336","#ff9800","#4caf50","#2196f3","#00bcd4","#787b86"]),gt(this,"onClick",e=>{this.state==="idle"?(this.state="drawing",this.startPoint=this.getPoint(e),this.endPoint=this.getPoint(e),this.initGraphic(),this.updateGraphic()):this.state==="drawing"&&(this.state="finished",this.endPoint=this.getPoint(e),this.updateGraphic(),this.saveDrawing(),this.removeGraphic(),this.context.disableTools())}),gt(this,"onMouseMove",e=>{this.state==="drawing"&&(this.endPoint=this.getPoint(e),this.updateGraphic())})}onInit(){this.context.registerDrawingRenderer(new ae)}onActivate(){this.state="idle",this.startPoint=null,this.endPoint=null,this.context.getChart().getZr().setCursorStyle("crosshair"),this.bindEvents()}onDeactivate(){this.state="idle",this.startPoint=null,this.endPoint=null,this.removeGraphic(),this.unbindEvents(),this.context.getChart().getZr().setCursorStyle("default")}bindEvents(){const t=this.context.getChart().getZr();t.on("click",this.onClick),t.on("mousemove",this.onMouseMove)}unbindEvents(){const t=this.context.getChart().getZr();t.off("click",this.onClick),t.off("mousemove",this.onMouseMove)}initGraphic(){this.graphicGroup=new G.graphic.Group,this.context.getChart().getZr().add(this.graphicGroup)}removeGraphic(){this.graphicGroup&&(this.context.getChart().getZr().remove(this.graphicGroup),this.graphicGroup=null)}updateGraphic(){if(!this.graphicGroup||!this.startPoint||!this.endPoint)return;this.graphicGroup.removeAll();const t=this.startPoint[0],e=this.startPoint[1],i=this.endPoint[0],s=this.endPoint[1],a=new G.graphic.Line({shape:{x1:t,y1:e,x2:i,y2:s},style:{stroke:"#999",lineWidth:1,lineDash:[4,4]},silent:!0});this.graphicGroup.add(a);const n=Math.min(t,i),l=Math.max(t,i),r=l-n,o=s-e;this.levels.forEach((u,d)=>{const c=s-o*u,g=this.colors[d%this.colors.length],h=new G.graphic.Line({shape:{x1:n,y1:c,x2:l,y2:c},style:{stroke:g,lineWidth:1},silent:!0});if(this.graphicGroup.add(h),d<this.levels.length-1){const f=this.levels[d+1],y=s-o*f,x=Math.abs(y-c),b=Math.min(c,y),D=new G.graphic.Rect({shape:{x:n,y:b,width:r,height:x},style:{fill:this.colors[(d+1)%this.colors.length],opacity:.1},silent:!0});this.graphicGroup.add(D)}})}saveDrawing(){if(!this.startPoint||!this.endPoint)return;const t=this.context.coordinateConversion.pixelToData({x:this.startPoint[0],y:this.startPoint[1]}),e=this.context.coordinateConversion.pixelToData({x:this.endPoint[0],y:this.endPoint[1]});if(t&&e){const i=t.paneIndex||0;this.context.addDrawing({id:`fib-${Date.now()}`,type:"fibonacci",points:[t,e],paneIndex:i,style:{color:"#3b82f6",lineWidth:1}})}}}var Ti=Object.defineProperty,Ni=(p,t,e)=>t in p?Ti(p,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):p[t]=e,Zi=(p,t,e)=>(Ni(p,typeof t!="symbol"?t+"":t,e),e);const Nt=[0,.236,.382,.5,.618,.786,1],Zt=["#787b86","#f44336","#ff9800","#4caf50","#2196f3","#00bcd4","#787b86"];class re{constructor(){Zi(this,"type","fibonacci_channel")}render(t){const{drawing:e,pixelPoints:i,isSelected:s}=t,[a,n]=i[0],[l,r]=i[1],[o,u]=i[2],d=e.style?.color||"#3b82f6",c=l-a,g=r-n,h=Math.sqrt(c*c+g*g);if(h===0)return;const f=-g/h,y=c/h,x=(o-a)*f+(u-n)*y,b=[],D=[];return Nt.forEach((w,k)=>{const m=f*x*w,C=y*x*w,v=a+m,_=n+C,A=l+m,M=r+C;if(D.push({lx1:v,ly1:_,lx2:A,ly2:M}),k<Nt.length-1){const S=Nt[k+1],z=f*x*S,W=y*x*S;b.push({type:"polygon",name:"line",shape:{points:[[v,_],[A,M],[l+z,r+W],[a+z,n+W]]},style:{fill:Zt[(k+1)%Zt.length],opacity:.1}})}}),D.forEach((w,k)=>{const m=Zt[k%Zt.length];b.push({type:"line",shape:{x1:w.lx1,y1:w.ly1,x2:w.lx2,y2:w.ly2},style:{stroke:m,lineWidth:1},silent:!0}),b.push({type:"text",style:{text:`${Nt[k]}`,x:w.lx2+5,y:w.ly2-5,fill:m,fontSize:10},silent:!0})}),b.push({type:"line",name:"line",shape:{x1:a,y1:n,x2:l,y2:r},style:{stroke:"#999",lineWidth:1,lineDash:[4,4]}}),b.push({type:"circle",name:"point-0",shape:{cx:a,cy:n,r:4},style:{fill:"#fff",stroke:d,lineWidth:1,opacity:s?1:0},z:100}),b.push({type:"circle",name:"point-1",shape:{cx:l,cy:r,r:4},style:{fill:"#fff",stroke:d,lineWidth:1,opacity:s?1:0},z:100}),b.push({type:"circle",name:"point-2",shape:{cx:o,cy:u,r:4},style:{fill:"#fff",stroke:d,lineWidth:1,opacity:s?1:0},z:100}),{type:"group",children:b}}}var Fi=Object.defineProperty,Oi=(p,t,e)=>t in p?Fi(p,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):p[t]=e,ut=(p,t,e)=>(Oi(p,typeof t!="symbol"?t+"":t,e),e);class Hi extends it{constructor(t={}){super({id:"fibonacci-channel-tool",name:t.name||"Fibonacci Channel",icon:t.icon||'<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="#e3e3e3"><path d="M120-200v-80l80-80H120v-80h160l120-120H120v-80h360l120-120H120v-80h720v80H520l-120 120h440v80H320L200-440h640v80H280l-80 80h640v80H120Z"/></svg>'}),ut(this,"startPoint",null),ut(this,"endPoint",null),ut(this,"widthPoint",null),ut(this,"state","idle"),ut(this,"graphicGroup",null),ut(this,"levels",[0,.236,.382,.5,.618,.786,1]),ut(this,"colors",["#787b86","#f44336","#ff9800","#4caf50","#2196f3","#00bcd4","#787b86"]),ut(this,"onClick",e=>{this.state==="idle"?(this.state="drawing-baseline",this.startPoint=this.getPoint(e),this.endPoint=this.getPoint(e),this.initGraphic(),this.updateGraphic()):this.state==="drawing-baseline"?(this.state="drawing-width",this.endPoint=this.getPoint(e),this.widthPoint=this.getPoint(e),this.updateGraphic()):this.state==="drawing-width"&&(this.state="finished",this.widthPoint=this.getPoint(e),this.updateGraphic(),this.saveDrawing(),this.removeGraphic(),this.context.disableTools())}),ut(this,"onMouseMove",e=>{this.state==="drawing-baseline"?(this.endPoint=this.getPoint(e),this.updateGraphic()):this.state==="drawing-width"&&(this.widthPoint=this.getPoint(e),this.updateGraphic())})}onInit(){this.context.registerDrawingRenderer(new re)}onActivate(){this.state="idle",this.startPoint=null,this.endPoint=null,this.widthPoint=null,this.context.getChart().getZr().setCursorStyle("crosshair"),this.bindEvents()}onDeactivate(){this.state="idle",this.startPoint=null,this.endPoint=null,this.widthPoint=null,this.removeGraphic(),this.unbindEvents(),this.context.getChart().getZr().setCursorStyle("default")}bindEvents(){const t=this.context.getChart().getZr();t.on("click",this.onClick),t.on("mousemove",this.onMouseMove)}unbindEvents(){const t=this.context.getChart().getZr();t.off("click",this.onClick),t.off("mousemove",this.onMouseMove)}initGraphic(){this.graphicGroup=new G.graphic.Group,this.context.getChart().getZr().add(this.graphicGroup)}removeGraphic(){this.graphicGroup&&(this.context.getChart().getZr().remove(this.graphicGroup),this.graphicGroup=null)}updateGraphic(){if(!this.graphicGroup||!this.startPoint||!this.endPoint)return;this.graphicGroup.removeAll();const t=this.startPoint[0],e=this.startPoint[1],i=this.endPoint[0],s=this.endPoint[1];if(this.graphicGroup.add(new G.graphic.Line({shape:{x1:t,y1:e,x2:i,y2:s},style:{stroke:"#787b86",lineWidth:2},silent:!0})),this.widthPoint&&this.state!=="drawing-baseline"){const a=this.widthPoint,n=i-t,l=s-e,r=Math.sqrt(n*n+l*l);if(r===0)return;const o=-l/r,u=n/r,d=(a[0]-t)*o+(a[1]-e)*u;this.levels.forEach((c,g)=>{const h=o*d*c,f=u*d*c,y=t+h,x=e+f,b=i+h,D=s+f,w=this.colors[g%this.colors.length];if(this.graphicGroup.add(new G.graphic.Line({shape:{x1:y,y1:x,x2:b,y2:D},style:{stroke:w,lineWidth:1},silent:!0})),g<this.levels.length-1){const k=this.levels[g+1],m=o*d*k,C=u*d*k,v=t+m,_=e+C,A=i+m,M=s+C;this.graphicGroup.add(new G.graphic.Polygon({shape:{points:[[y,x],[b,D],[A,M],[v,_]]},style:{fill:this.colors[(g+1)%this.colors.length],opacity:.1},silent:!0}))}})}}saveDrawing(){if(!this.startPoint||!this.endPoint||!this.widthPoint)return;const t=this.context.coordinateConversion.pixelToData({x:this.startPoint[0],y:this.startPoint[1]}),e=this.context.coordinateConversion.pixelToData({x:this.endPoint[0],y:this.endPoint[1]}),i=this.context.coordinateConversion.pixelToData({x:this.widthPoint[0],y:this.widthPoint[1]});if(t&&e&&i){const s=t.paneIndex||0;this.context.addDrawing({id:`fib-channel-${Date.now()}`,type:"fibonacci_channel",points:[t,e,i],paneIndex:s,style:{color:"#3b82f6",lineWidth:1}})}}}var Ri=Object.defineProperty,Bi=(p,t,e)=>t in p?Ri(p,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):p[t]=e,ji=(p,t,e)=>(Bi(p,typeof t!="symbol"?t+"":t,e),e);const Vt=[0,.236,.382,.5,.618,.786,1],ft=["#787b86","#f44336","#ff9800","#4caf50","#2196f3","#00bcd4","#787b86"];class le{constructor(){ji(this,"type","fib_speed_resistance_fan")}render(t){const{drawing:e,pixelPoints:i,isSelected:s}=t,[a,n]=i[0],[l,r]=i[1],o=e.style?.color||"#3b82f6",u=l-a,d=r-n,c=[],g=[],h=[];for(const f of Vt)g.push([a+u,n+d*f]),h.push([a+u*f,n+d]);for(let f=0;f<g.length-1;f++)c.push({type:"polygon",name:"line",shape:{points:[[a,n],g[f],g[f+1]]},style:{fill:ft[(f+1)%ft.length],opacity:.06}});for(let f=0;f<h.length-1;f++)c.push({type:"polygon",name:"line",shape:{points:[[a,n],h[f],h[f+1]]},style:{fill:ft[(f+1)%ft.length],opacity:.06}});return Vt.forEach((f,y)=>{const[x,b]=g[y],D=ft[y%ft.length];c.push({type:"line",shape:{x1:a,y1:n,x2:x,y2:b},style:{stroke:D,lineWidth:1},silent:!0}),c.push({type:"text",style:{text:`${f}`,x:x+3,y:b-2,fill:D,fontSize:9},silent:!0})}),Vt.forEach((f,y)=>{const[x,b]=h[y],D=ft[y%ft.length];c.push({type:"line",shape:{x1:a,y1:n,x2:x,y2:b},style:{stroke:D,lineWidth:1},silent:!0}),c.push({type:"text",style:{text:`${f}`,x:x-2,y:b+8,fill:D,fontSize:9},silent:!0})}),c.push({type:"line",name:"line",shape:{x1:l,y1:n,x2:l,y2:r},style:{stroke:"#555",lineWidth:1,lineDash:[3,3]}}),c.push({type:"line",name:"line",shape:{x1:a,y1:r,x2:l,y2:r},style:{stroke:"#555",lineWidth:1,lineDash:[3,3]}}),c.push({type:"line",name:"line",shape:{x1:a,y1:n,x2:l,y2:r},style:{stroke:"#999",lineWidth:1,lineDash:[4,4]}}),c.push({type:"circle",name:"point-0",shape:{cx:a,cy:n,r:4},style:{fill:"#fff",stroke:o,lineWidth:1,opacity:s?1:0},z:100}),c.push({type:"circle",name:"point-1",shape:{cx:l,cy:r,r:4},style:{fill:"#fff",stroke:o,lineWidth:1,opacity:s?1:0},z:100}),{type:"group",children:c}}}var Yi=Object.defineProperty,Xi=(p,t,e)=>t in p?Yi(p,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):p[t]=e,It=(p,t,e)=>(Xi(p,typeof t!="symbol"?t+"":t,e),e);const xt=[0,.236,.382,.5,.618,.786,1],_t=["#787b86","#f44336","#ff9800","#4caf50","#2196f3","#00bcd4","#787b86"];class Vi extends it{constructor(t={}){super({id:"fib-speed-resistance-fan-tool",name:t.name||"Fib Speed Resistance Fan",icon:t.icon||'<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#e3e3e3"><path d="M2 21L22 3M2 21l20-6M2 21l20-9M2 21l20-12M2 21l20-15M2 21l6-18M2 21l9-18M2 21l12-18M2 21l15-18" stroke="#e3e3e3" stroke-width="1" fill="none"/></svg>'}),It(this,"startPoint",null),It(this,"endPoint",null),It(this,"state","idle"),It(this,"graphicGroup",null),It(this,"onClick",e=>{this.state==="idle"?(this.state="drawing",this.startPoint=this.getPoint(e),this.endPoint=this.getPoint(e),this.initGraphic(),this.updateGraphic()):this.state==="drawing"&&(this.state="finished",this.endPoint=this.getPoint(e),this.updateGraphic(),this.saveDrawing(),this.removeGraphic(),this.context.disableTools())}),It(this,"onMouseMove",e=>{this.state==="drawing"&&(this.endPoint=this.getPoint(e),this.updateGraphic())})}onInit(){this.context.registerDrawingRenderer(new le)}onActivate(){this.state="idle",this.startPoint=null,this.endPoint=null,this.context.getChart().getZr().setCursorStyle("crosshair"),this.bindEvents()}onDeactivate(){this.state="idle",this.startPoint=null,this.endPoint=null,this.removeGraphic(),this.unbindEvents(),this.context.getChart().getZr().setCursorStyle("default")}bindEvents(){const t=this.context.getChart().getZr();t.on("click",this.onClick),t.on("mousemove",this.onMouseMove)}unbindEvents(){const t=this.context.getChart().getZr();t.off("click",this.onClick),t.off("mousemove",this.onMouseMove)}initGraphic(){this.graphicGroup=new G.graphic.Group,this.context.getChart().getZr().add(this.graphicGroup)}removeGraphic(){this.graphicGroup&&(this.context.getChart().getZr().remove(this.graphicGroup),this.graphicGroup=null)}updateGraphic(){if(!this.graphicGroup||!this.startPoint||!this.endPoint)return;this.graphicGroup.removeAll();const t=this.startPoint[0],e=this.startPoint[1],i=this.endPoint[0],s=this.endPoint[1],a=i-t,n=s-e;xt.forEach((l,r)=>{const o=_t[r%_t.length];this.graphicGroup.add(new G.graphic.Line({shape:{x1:t,y1:e,x2:t+a,y2:e+n*l},style:{stroke:o,lineWidth:1},silent:!0})),this.graphicGroup.add(new G.graphic.Line({shape:{x1:t,y1:e,x2:t+a*l,y2:e+n},style:{stroke:o,lineWidth:1},silent:!0}))});for(let l=0;l<xt.length-1;l++){const r=[t+a,e+n*xt[l]],o=[t+a,e+n*xt[l+1]];this.graphicGroup.add(new G.graphic.Polygon({shape:{points:[[t,e],r,o]},style:{fill:_t[(l+1)%_t.length],opacity:.06},silent:!0}))}for(let l=0;l<xt.length-1;l++){const r=[t+a*xt[l],e+n],o=[t+a*xt[l+1],e+n];this.graphicGroup.add(new G.graphic.Polygon({shape:{points:[[t,e],r,o]},style:{fill:_t[(l+1)%_t.length],opacity:.06},silent:!0}))}this.graphicGroup.add(new G.graphic.Line({shape:{x1:i,y1:e,x2:i,y2:s},style:{stroke:"#555",lineWidth:1,lineDash:[3,3]},silent:!0})),this.graphicGroup.add(new G.graphic.Line({shape:{x1:t,y1:s,x2:i,y2:s},style:{stroke:"#555",lineWidth:1,lineDash:[3,3]},silent:!0})),this.graphicGroup.add(new G.graphic.Line({shape:{x1:t,y1:e,x2:i,y2:s},style:{stroke:"#999",lineWidth:1,lineDash:[4,4]},silent:!0}))}saveDrawing(){if(!this.startPoint||!this.endPoint)return;const t=this.context.coordinateConversion.pixelToData({x:this.startPoint[0],y:this.startPoint[1]}),e=this.context.coordinateConversion.pixelToData({x:this.endPoint[0],y:this.endPoint[1]});t&&e&&this.context.addDrawing({id:`fib-fan-${Date.now()}`,type:"fib_speed_resistance_fan",points:[t,e],paneIndex:t.paneIndex||0,style:{color:"#3b82f6",lineWidth:1}})}}var qi=Object.defineProperty,Ui=(p,t,e)=>t in p?qi(p,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):p[t]=e,Ki=(p,t,e)=>(Ui(p,typeof t!="symbol"?t+"":t,e),e);const he=[0,.236,.382,.5,.618,.786,1,1.272,1.618,2,2.618],ce=["#787b86","#f44336","#ff9800","#4caf50","#2196f3","#00bcd4","#787b86","#e91e63","#9c27b0","#673ab7","#3f51b5"];class pe{constructor(){Ki(this,"type","fib_trend_extension")}render(t){const{drawing:e,pixelPoints:i,isSelected:s,api:a}=t,n=e.style?.color||"#3b82f6";if(i.length<3)return;const[l,r]=i[0],[o,u]=i[1],[d,c]=i[2],g=e.points,h=g[1].value-g[0].value,f=Math.min(l,o,d),y=Math.max(l,o,d),x=(y-f)*.5,b=f,D=y+x,w=[],k=[];for(let v=0;v<he.length;v++){const _=he[v],A=g[2].value+h*_;a.coord([g[2].timeIndex+t.drawing.points[2].timeIndex-g[2].timeIndex,A]);const M=c+(u-r)*_;k.push({level:_,y:M,price:A,color:ce[v%ce.length]})}for(let v=0;v<k.length-1;v++){const _=k[v],A=k[v+1],M=Math.min(_.y,A.y),S=Math.abs(A.y-_.y);w.push({type:"rect",name:"line",shape:{x:b,y:M,width:D-b,height:S},style:{fill:A.color,opacity:.06}})}for(const v of k)w.push({type:"line",shape:{x1:b,y1:v.y,x2:D,y2:v.y},style:{stroke:v.color,lineWidth:1},silent:!0}),w.push({type:"text",style:{text:`${v.level} (${v.price.toFixed(2)})`,x:D+4,y:v.y-6,fill:v.color,fontSize:9},silent:!0});w.push({type:"line",name:"line",shape:{x1:l,y1:r,x2:o,y2:u},style:{stroke:"#2196f3",lineWidth:1.5,lineDash:[5,4]}}),w.push({type:"line",name:"line",shape:{x1:o,y1:u,x2:d,y2:c},style:{stroke:"#ff9800",lineWidth:1.5,lineDash:[5,4]}}),w.push({type:"circle",name:"point-0",shape:{cx:l,cy:r,r:4},style:{fill:"#fff",stroke:n,lineWidth:1,opacity:s?1:0},z:100}),w.push({type:"circle",name:"point-1",shape:{cx:o,cy:u,r:4},style:{fill:"#fff",stroke:n,lineWidth:1,opacity:s?1:0},z:100}),w.push({type:"circle",name:"point-2",shape:{cx:d,cy:c,r:4},style:{fill:"#fff",stroke:n,lineWidth:1,opacity:s?1:0},z:100});const m=["1","2","3"],C=[i[0],i[1],i[2]];for(let v=0;v<3;v++){const[_,A]=C[v],M=(v===0||A<=C[v-1][1])&&(v===2||A<=C[v+1]?.[1]);w.push({type:"text",style:{text:m[v],x:_,y:M?A-14:A+16,fill:"#e2e8f0",fontSize:12,fontWeight:"bold",align:"center",verticalAlign:"middle"},silent:!0})}return{type:"group",children:w}}}var Ji=Object.defineProperty,Qi=(p,t,e)=>t in p?Ji(p,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):p[t]=e,Dt=(p,t,e)=>(Qi(p,typeof t!="symbol"?t+"":t,e),e);const Ft=[0,.236,.382,.5,.618,.786,1,1.272,1.618,2,2.618],Ot=["#787b86","#f44336","#ff9800","#4caf50","#2196f3","#00bcd4","#787b86","#e91e63","#9c27b0","#673ab7","#3f51b5"];class ts extends it{constructor(t={}){super({id:"fib-trend-extension-tool",name:t.name||"Fib Trend Extension",icon:t.icon||'<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="#e3e3e3"><path d="M120-80v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Z"/></svg>'}),Dt(this,"points",[]),Dt(this,"state","idle"),Dt(this,"graphicGroup",null),Dt(this,"onClick",e=>{const i=this.getPoint(e);this.state==="idle"?(this.state="drawing-trend",this.points=[i,[...i]],this.initGraphic(),this.updateGraphic()):this.state==="drawing-trend"?(this.state="drawing-retracement",this.points[1]=i,this.points.push([...i]),this.updateGraphic()):this.state==="drawing-retracement"&&(this.state="finished",this.points[2]=i,this.updateGraphic(),this.saveDrawing(),this.removeGraphic(),this.context.disableTools())}),Dt(this,"onMouseMove",e=>{this.state==="drawing-trend"?(this.points[1]=this.getPoint(e),this.updateGraphic()):this.state==="drawing-retracement"&&(this.points[2]=this.getPoint(e),this.updateGraphic())})}onInit(){this.context.registerDrawingRenderer(new pe)}onActivate(){this.state="idle",this.points=[],this.context.getChart().getZr().setCursorStyle("crosshair"),this.bindEvents()}onDeactivate(){this.state="idle",this.points=[],this.removeGraphic(),this.unbindEvents(),this.context.getChart().getZr().setCursorStyle("default")}bindEvents(){const t=this.context.getChart().getZr();t.on("click",this.onClick),t.on("mousemove",this.onMouseMove)}unbindEvents(){const t=this.context.getChart().getZr();t.off("click",this.onClick),t.off("mousemove",this.onMouseMove)}initGraphic(){this.graphicGroup=new G.graphic.Group,this.context.getChart().getZr().add(this.graphicGroup)}removeGraphic(){this.graphicGroup&&(this.context.getChart().getZr().remove(this.graphicGroup),this.graphicGroup=null)}updateGraphic(){if(!this.graphicGroup)return;this.graphicGroup.removeAll();const[t,e]=this.points[0],[i,s]=this.points[1];if(this.graphicGroup.add(new G.graphic.Line({shape:{x1:t,y1:e,x2:i,y2:s},style:{stroke:"#2196f3",lineWidth:1.5,lineDash:[5,4]},silent:!0})),this.points.length>=3){const[a,n]=this.points[2];this.graphicGroup.add(new G.graphic.Line({shape:{x1:i,y1:s,x2:a,y2:n},style:{stroke:"#ff9800",lineWidth:1.5,lineDash:[5,4]},silent:!0}));const l=s-e,r=Math.min(t,i,a),o=Math.max(t,i,a),u=(o-r)*.5,d=r,c=o+u;for(let g=0;g<Ft.length;g++){const h=Ft[g],f=n+l*h,y=Ot[g%Ot.length];if(this.graphicGroup.add(new G.graphic.Line({shape:{x1:d,y1:f,x2:c,y2:f},style:{stroke:y,lineWidth:1},silent:!0})),this.graphicGroup.add(new G.graphic.Text({style:{text:`${h}`,x:c+4,y:f-6,fill:y,fontSize:9},silent:!0})),g<Ft.length-1){const x=n+l*Ft[g+1],b=Math.min(f,x),D=Math.abs(x-f);this.graphicGroup.add(new G.graphic.Rect({shape:{x:d,y:b,width:c-d,height:D},style:{fill:Ot[(g+1)%Ot.length],opacity:.06},silent:!0}))}}}for(const a of this.points)this.graphicGroup.add(new G.graphic.Circle({shape:{cx:a[0],cy:a[1],r:4},style:{fill:"#fff",stroke:"#3b82f6",lineWidth:1.5},z:101,silent:!0}))}saveDrawing(){const t=this.points.map(e=>this.context.coordinateConversion.pixelToData({x:e[0],y:e[1]}));t.every(e=>e!==null)&&this.context.addDrawing({id:`fib-ext-${Date.now()}`,type:"fib_trend_extension",points:t,paneIndex:t[0].paneIndex||0,style:{color:"#3b82f6",lineWidth:1}})}}var es=Object.defineProperty,is=(p,t,e)=>t in p?es(p,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):p[t]=e,ss=(p,t,e)=>(is(p,typeof t!="symbol"?t+"":t,e),e);const de=["X","A","B","C","D"],ue=["#2196f3","#ff9800","#4caf50","#f44336"],ns="rgba(33, 150, 243, 0.08)",os="rgba(244, 67, 54, 0.08)";class ge{constructor(){ss(this,"type","xabcd_pattern")}render(t){const{drawing:e,pixelPoints:i,isSelected:s}=t,a=e.style?.color||"#3b82f6";if(i.length<2)return;const n=[];i.length>=3&&n.push({type:"polygon",name:"line",shape:{points:i.slice(0,3).map(([r,o])=>[r,o])},style:{fill:ns,opacity:1}}),i.length>=5&&n.push({type:"polygon",name:"line",shape:{points:i.slice(2,5).map(([r,o])=>[r,o])},style:{fill:os,opacity:1}});for(let r=0;r<i.length-1;r++){const[o,u]=i[r],[d,c]=i[r+1],g=ue[r%ue.length];n.push({type:"line",name:"line",shape:{x1:o,y1:u,x2:d,y2:c},style:{stroke:g,lineWidth:e.style?.lineWidth||2}})}const l=[[0,2],[1,3],[2,4]];for(const[r,o]of l)if(r<i.length&&o<i.length){const[u,d]=i[r],[c,g]=i[o];n.push({type:"line",shape:{x1:u,y1:d,x2:c,y2:g},style:{stroke:"#555",lineWidth:1,lineDash:[4,4]},silent:!0})}if(e.points.length>=3){const r=Math.abs(e.points[1].value-e.points[0].value),o=Math.abs(e.points[2].value-e.points[1].value);if(r!==0){const u=(o/r).toFixed(3),d=(i[1][0]+i[2][0])/2,c=(i[1][1]+i[2][1])/2;n.push({type:"text",style:{text:u,x:d+8,y:c,fill:"#ff9800",fontSize:10},silent:!0})}}if(e.points.length>=4){const r=Math.abs(e.points[2].value-e.points[1].value),o=Math.abs(e.points[3].value-e.points[2].value);if(r!==0){const u=(o/r).toFixed(3),d=(i[2][0]+i[3][0])/2,c=(i[2][1]+i[3][1])/2;n.push({type:"text",style:{text:u,x:d+8,y:c,fill:"#4caf50",fontSize:10},silent:!0})}}if(e.points.length>=5){const r=Math.abs(e.points[3].value-e.points[2].value),o=Math.abs(e.points[4].value-e.points[3].value);if(r!==0){const c=(o/r).toFixed(3),g=(i[3][0]+i[4][0])/2,h=(i[3][1]+i[4][1])/2;n.push({type:"text",style:{text:c,x:g+8,y:h,fill:"#f44336",fontSize:10},silent:!0})}const u=Math.abs(e.points[1].value-e.points[0].value),d=Math.abs(e.points[4].value-e.points[1].value);if(u!==0){const c=(d/u).toFixed(3),[g,h]=i[4];n.push({type:"text",style:{text:`AD/XA: ${c}`,x:g+10,y:h+14,fill:"#aaa",fontSize:9},silent:!0})}}for(let r=0;r<i.length&&r<de.length;r++){const[o,u]=i[r],d=(r===0||u<=i[r-1][1])&&(r===i.length-1||u<=i[r+1]?.[1])?u-14:u+16;n.push({type:"text",style:{text:de[r],x:o,y:d,fill:"#e2e8f0",fontSize:12,fontWeight:"bold",align:"center",verticalAlign:"middle"},silent:!0})}for(let r=0;r<i.length;r++){const[o,u]=i[r];n.push({type:"circle",name:`point-${r}`,shape:{cx:o,cy:u,r:4},style:{fill:"#fff",stroke:a,lineWidth:1,opacity:s?1:0},z:100})}return{type:"group",children:n}}}var as=Object.defineProperty,rs=(p,t,e)=>t in p?as(p,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):p[t]=e,Mt=(p,t,e)=>(rs(p,typeof t!="symbol"?t+"":t,e),e);const fe=["X","A","B","C","D"],ye=["#2196f3","#ff9800","#4caf50","#f44336"],ls=5;class hs extends it{constructor(t={}){super({id:"xabcd-pattern-tool",name:t.name||"XABCD Pattern",icon:t.icon||'<svg viewBox="0 0 24 24" width="24" height="24" fill="none" stroke="#e3e3e3" stroke-width="1.5"><polyline points="2,18 6,6 11,14 16,4 21,16"/><circle cx="2" cy="18" r="1.5" fill="#e3e3e3"/><circle cx="6" cy="6" r="1.5" fill="#e3e3e3"/><circle cx="11" cy="14" r="1.5" fill="#e3e3e3"/><circle cx="16" cy="4" r="1.5" fill="#e3e3e3"/><circle cx="21" cy="16" r="1.5" fill="#e3e3e3"/></svg>'}),Mt(this,"points",[]),Mt(this,"state","idle"),Mt(this,"graphicGroup",null),Mt(this,"onClick",e=>{const i=this.getPoint(e);this.state==="idle"?(this.state="drawing",this.points=[i,[...i]],this.initGraphic(),this.updateGraphic()):this.state==="drawing"&&(this.points[this.points.length-1]=i,this.points.length>=ls?(this.state="finished",this.updateGraphic(),this.saveDrawing(),this.removeGraphic(),this.context.disableTools()):(this.points.push([...i]),this.updateGraphic()))}),Mt(this,"onMouseMove",e=>{this.state!=="drawing"||this.points.length<2||(this.points[this.points.length-1]=this.getPoint(e),this.updateGraphic())})}onInit(){this.context.registerDrawingRenderer(new ge)}onActivate(){this.state="idle",this.points=[],this.context.getChart().getZr().setCursorStyle("crosshair"),this.bindEvents()}onDeactivate(){this.state="idle",this.points=[],this.removeGraphic(),this.unbindEvents(),this.context.getChart().getZr().setCursorStyle("default")}bindEvents(){const t=this.context.getChart().getZr();t.on("click",this.onClick),t.on("mousemove",this.onMouseMove)}unbindEvents(){const t=this.context.getChart().getZr();t.off("click",this.onClick),t.off("mousemove",this.onMouseMove)}initGraphic(){this.graphicGroup=new G.graphic.Group,this.context.getChart().getZr().add(this.graphicGroup)}removeGraphic(){this.graphicGroup&&(this.context.getChart().getZr().remove(this.graphicGroup),this.graphicGroup=null)}updateGraphic(){if(!this.graphicGroup)return;this.graphicGroup.removeAll();const t=this.points;t.length>=3&&this.graphicGroup.add(new G.graphic.Polygon({shape:{points:t.slice(0,3)},style:{fill:"rgba(33, 150, 243, 0.08)"},silent:!0})),t.length>=5&&this.graphicGroup.add(new G.graphic.Polygon({shape:{points:t.slice(2,5)},style:{fill:"rgba(244, 67, 54, 0.08)"},silent:!0}));for(let i=0;i<t.length-1;i++){const[s,a]=t[i],[n,l]=t[i+1];this.graphicGroup.add(new G.graphic.Line({shape:{x1:s,y1:a,x2:n,y2:l},style:{stroke:ye[i%ye.length],lineWidth:2},silent:!0}))}const e=[[0,2],[1,3],[2,4]];for(const[i,s]of e)if(i<t.length&&s<t.length){const[a,n]=t[i],[l,r]=t[s];this.graphicGroup.add(new G.graphic.Line({shape:{x1:a,y1:n,x2:l,y2:r},style:{stroke:"#555",lineWidth:1,lineDash:[4,4]},silent:!0}))}for(let i=0;i<t.length&&i<fe.length;i++){const[s,a]=t[i],n=(i===0||a<=t[i-1][1])&&(i===t.length-1||a<=t[i+1]?.[1])?a-14:a+16;this.graphicGroup.add(new G.graphic.Text({style:{text:fe[i],x:s,y:n,fill:"#e2e8f0",fontSize:12,fontWeight:"bold",align:"center",verticalAlign:"middle"},silent:!0}))}for(let i=0;i<t.length;i++){const[s,a]=t[i];this.graphicGroup.add(new G.graphic.Circle({shape:{cx:s,cy:a,r:4},style:{fill:"#fff",stroke:"#3b82f6",lineWidth:1.5},z:101,silent:!0}))}}saveDrawing(){const t=this.points.map(e=>this.context.coordinateConversion.pixelToData({x:e[0],y:e[1]}));t.every(e=>e!==null)&&this.context.addDrawing({id:`xabcd-${Date.now()}`,type:"xabcd_pattern",points:t,paneIndex:t[0].paneIndex||0,style:{color:"#3b82f6",lineWidth:2}})}}var cs=Object.defineProperty,ps=(p,t,e)=>t in p?cs(p,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):p[t]=e,ds=(p,t,e)=>(ps(p,typeof t!="symbol"?t+"":t,e),e);const xe=["A","B","C","D"],me=["#2196f3","#ff9800","#4caf50"];class be{constructor(){ds(this,"type","abcd_pattern")}render(t){const{drawing:e,pixelPoints:i,isSelected:s}=t,a=e.style?.color||"#3b82f6";if(i.length<2)return;const n=[];i.length>=3&&n.push({type:"polygon",name:"line",shape:{points:i.slice(0,3).map(([l,r])=>[l,r])},style:{fill:"rgba(33, 150, 243, 0.08)"}}),i.length>=4&&n.push({type:"polygon",name:"line",shape:{points:i.slice(1,4).map(([l,r])=>[l,r])},style:{fill:"rgba(244, 67, 54, 0.08)"}});for(let l=0;l<i.length-1;l++){const[r,o]=i[l],[u,d]=i[l+1];n.push({type:"line",name:"line",shape:{x1:r,y1:o,x2:u,y2:d},style:{stroke:me[l%me.length],lineWidth:e.style?.lineWidth||2}})}if(i.length>=3&&n.push({type:"line",shape:{x1:i[0][0],y1:i[0][1],x2:i[2][0],y2:i[2][1]},style:{stroke:"#555",lineWidth:1,lineDash:[4,4]},silent:!0}),i.length>=4&&n.push({type:"line",shape:{x1:i[1][0],y1:i[1][1],x2:i[3][0],y2:i[3][1]},style:{stroke:"#555",lineWidth:1,lineDash:[4,4]},silent:!0}),e.points.length>=3){const l=Math.abs(e.points[1].value-e.points[0].value),r=Math.abs(e.points[2].value-e.points[1].value);if(l!==0){const o=(r/l).toFixed(3),u=(i[1][0]+i[2][0])/2,d=(i[1][1]+i[2][1])/2;n.push({type:"text",style:{text:o,x:u+8,y:d,fill:"#ff9800",fontSize:10},silent:!0})}}if(e.points.length>=4){const l=Math.abs(e.points[2].value-e.points[1].value),r=Math.abs(e.points[3].value-e.points[2].value);if(l!==0){const o=(r/l).toFixed(3),u=(i[2][0]+i[3][0])/2,d=(i[2][1]+i[3][1])/2;n.push({type:"text",style:{text:o,x:u+8,y:d,fill:"#4caf50",fontSize:10},silent:!0})}}for(let l=0;l<i.length&&l<xe.length;l++){const[r,o]=i[l],u=(l===0||o<=i[l-1][1])&&(l===i.length-1||o<=i[l+1]?.[1]);n.push({type:"text",style:{text:xe[l],x:r,y:u?o-14:o+16,fill:"#e2e8f0",fontSize:12,fontWeight:"bold",align:"center",verticalAlign:"middle"},silent:!0})}for(let l=0;l<i.length;l++)n.push({type:"circle",name:`point-${l}`,shape:{cx:i[l][0],cy:i[l][1],r:4},style:{fill:"#fff",stroke:a,lineWidth:1,opacity:s?1:0},z:100});return{type:"group",children:n}}}var us=Object.defineProperty,gs=(p,t,e)=>t in p?us(p,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):p[t]=e,St=(p,t,e)=>(gs(p,typeof t!="symbol"?t+"":t,e),e);const ve=["A","B","C","D"],we=["#2196f3","#ff9800","#4caf50"],fs=4;class ys extends it{constructor(t={}){super({id:"abcd-pattern-tool",name:t.name||"ABCD Pattern",icon:t.icon||'<svg viewBox="0 0 24 24" width="24" height="24" fill="none" stroke="#e3e3e3" stroke-width="1.5"><polyline points="3,18 8,5 15,15 21,3"/><circle cx="3" cy="18" r="1.5" fill="#e3e3e3"/><circle cx="8" cy="5" r="1.5" fill="#e3e3e3"/><circle cx="15" cy="15" r="1.5" fill="#e3e3e3"/><circle cx="21" cy="3" r="1.5" fill="#e3e3e3"/></svg>'}),St(this,"points",[]),St(this,"state","idle"),St(this,"graphicGroup",null),St(this,"onClick",e=>{const i=this.getPoint(e);this.state==="idle"?(this.state="drawing",this.points=[i,[...i]],this.initGraphic(),this.updateGraphic()):this.state==="drawing"&&(this.points[this.points.length-1]=i,this.points.length>=fs?(this.state="finished",this.updateGraphic(),this.saveDrawing(),this.removeGraphic(),this.context.disableTools()):(this.points.push([...i]),this.updateGraphic()))}),St(this,"onMouseMove",e=>{this.state!=="drawing"||this.points.length<2||(this.points[this.points.length-1]=this.getPoint(e),this.updateGraphic())})}onInit(){this.context.registerDrawingRenderer(new be)}onActivate(){this.state="idle",this.points=[],this.context.getChart().getZr().setCursorStyle("crosshair");const t=this.context.getChart().getZr();t.on("click",this.onClick),t.on("mousemove",this.onMouseMove)}onDeactivate(){this.state="idle",this.points=[],this.removeGraphic();const t=this.context.getChart().getZr();t.off("click",this.onClick),t.off("mousemove",this.onMouseMove),this.context.getChart().getZr().setCursorStyle("default")}initGraphic(){this.graphicGroup=new G.graphic.Group,this.context.getChart().getZr().add(this.graphicGroup)}removeGraphic(){this.graphicGroup&&(this.context.getChart().getZr().remove(this.graphicGroup),this.graphicGroup=null)}updateGraphic(){if(!this.graphicGroup)return;this.graphicGroup.removeAll();const t=this.points;t.length>=3&&this.graphicGroup.add(new G.graphic.Polygon({shape:{points:t.slice(0,3)},style:{fill:"rgba(33,150,243,0.08)"},silent:!0})),t.length>=4&&this.graphicGroup.add(new G.graphic.Polygon({shape:{points:t.slice(1,4)},style:{fill:"rgba(244,67,54,0.08)"},silent:!0}));for(let e=0;e<t.length-1;e++)this.graphicGroup.add(new G.graphic.Line({shape:{x1:t[e][0],y1:t[e][1],x2:t[e+1][0],y2:t[e+1][1]},style:{stroke:we[e%we.length],lineWidth:2},silent:!0}));t.length>=3&&this.graphicGroup.add(new G.graphic.Line({shape:{x1:t[0][0],y1:t[0][1],x2:t[2][0],y2:t[2][1]},style:{stroke:"#555",lineWidth:1,lineDash:[4,4]},silent:!0})),t.length>=4&&this.graphicGroup.add(new G.graphic.Line({shape:{x1:t[1][0],y1:t[1][1],x2:t[3][0],y2:t[3][1]},style:{stroke:"#555",lineWidth:1,lineDash:[4,4]},silent:!0}));for(let e=0;e<t.length&&e<ve.length;e++){const[i,s]=t[e],a=(e===0||s<=t[e-1][1])&&(e===t.length-1||s<=t[e+1]?.[1]);this.graphicGroup.add(new G.graphic.Text({style:{text:ve[e],x:i,y:a?s-14:s+16,fill:"#e2e8f0",fontSize:12,fontWeight:"bold",align:"center",verticalAlign:"middle"},silent:!0})),this.graphicGroup.add(new G.graphic.Circle({shape:{cx:i,cy:s,r:4},style:{fill:"#fff",stroke:"#3b82f6",lineWidth:1.5},z:101,silent:!0}))}}saveDrawing(){const t=this.points.map(e=>this.context.coordinateConversion.pixelToData({x:e[0],y:e[1]}));t.every(e=>e!==null)&&this.context.addDrawing({id:`abcd-${Date.now()}`,type:"abcd_pattern",points:t,paneIndex:t[0].paneIndex||0,style:{color:"#3b82f6",lineWidth:2}})}}var xs=Object.defineProperty,ms=(p,t,e)=>t in p?xs(p,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):p[t]=e,bs=(p,t,e)=>(ms(p,typeof t!="symbol"?t+"":t,e),e);const Ce=["X","A","B","C","D"],Ie=["#00bcd4","#e91e63","#8bc34a","#ff5722"];class _e{constructor(){bs(this,"type","cypher_pattern")}render(t){const{drawing:e,pixelPoints:i,isSelected:s}=t,a=e.style?.color||"#3b82f6";if(i.length<2)return;const n=[];i.length>=3&&n.push({type:"polygon",name:"line",shape:{points:i.slice(0,3).map(([o,u])=>[o,u])},style:{fill:"rgba(0, 188, 212, 0.08)"}}),i.length>=5&&n.push({type:"polygon",name:"line",shape:{points:i.slice(2,5).map(([o,u])=>[o,u])},style:{fill:"rgba(233, 30, 99, 0.08)"}});for(let o=0;o<i.length-1;o++){const[u,d]=i[o],[c,g]=i[o+1];n.push({type:"line",name:"line",shape:{x1:u,y1:d,x2:c,y2:g},style:{stroke:Ie[o%Ie.length],lineWidth:e.style?.lineWidth||2}})}const l=[[0,2],[0,3],[1,4]];for(const[o,u]of l)o<i.length&&u<i.length&&n.push({type:"line",shape:{x1:i[o][0],y1:i[o][1],x2:i[u][0],y2:i[u][1]},style:{stroke:"#555",lineWidth:1,lineDash:[4,4]},silent:!0});const r=e.points;if(r.length>=3){const o=Math.abs(r[1].value-r[0].value),u=Math.abs(r[2].value-r[1].value);if(o!==0){const d=(u/o).toFixed(3);n.push({type:"text",style:{text:d,x:(i[1][0]+i[2][0])/2+8,y:(i[1][1]+i[2][1])/2,fill:"#e91e63",fontSize:10},silent:!0})}}if(r.length>=4){const o=Math.abs(r[1].value-r[0].value),u=Math.abs(r[3].value-r[0].value);if(o!==0){const d=(u/o).toFixed(3);n.push({type:"text",style:{text:`XC/XA: ${d}`,x:(i[0][0]+i[3][0])/2+8,y:(i[0][1]+i[3][1])/2,fill:"#8bc34a",fontSize:10},silent:!0})}}if(r.length>=5){const o=Math.abs(r[3].value-r[0].value),u=Math.abs(r[4].value-r[3].value);if(o!==0){const d=(u/o).toFixed(3);n.push({type:"text",style:{text:d,x:(i[3][0]+i[4][0])/2+8,y:(i[3][1]+i[4][1])/2,fill:"#ff5722",fontSize:10},silent:!0})}}for(let o=0;o<i.length&&o<Ce.length;o++){const[u,d]=i[o],c=(o===0||d<=i[o-1][1])&&(o===i.length-1||d<=i[o+1]?.[1]);n.push({type:"text",style:{text:Ce[o],x:u,y:c?d-14:d+16,fill:"#e2e8f0",fontSize:12,fontWeight:"bold",align:"center",verticalAlign:"middle"},silent:!0})}for(let o=0;o<i.length;o++)n.push({type:"circle",name:`point-${o}`,shape:{cx:i[o][0],cy:i[o][1],r:4},style:{fill:"#fff",stroke:a,lineWidth:1,opacity:s?1:0},z:100});return{type:"group",children:n}}}var vs=Object.defineProperty,ws=(p,t,e)=>t in p?vs(p,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):p[t]=e,Gt=(p,t,e)=>(ws(p,typeof t!="symbol"?t+"":t,e),e);const ke=["X","A","B","C","D"],Pe=["#00bcd4","#e91e63","#8bc34a","#ff5722"],Cs=5;class Is extends it{constructor(t={}){super({id:"cypher-pattern-tool",name:t.name||"Cypher Pattern",icon:t.icon||'<svg viewBox="0 0 24 24" width="24" height="24" fill="none" stroke="#e3e3e3" stroke-width="1.5"><polyline points="2,16 7,4 11,12 17,2 22,14"/><circle cx="2" cy="16" r="1.5" fill="#e3e3e3"/><circle cx="7" cy="4" r="1.5" fill="#e3e3e3"/><circle cx="11" cy="12" r="1.5" fill="#e3e3e3"/><circle cx="17" cy="2" r="1.5" fill="#e3e3e3"/><circle cx="22" cy="14" r="1.5" fill="#e3e3e3"/></svg>'}),Gt(this,"points",[]),Gt(this,"state","idle"),Gt(this,"graphicGroup",null),Gt(this,"onClick",e=>{const i=this.getPoint(e);this.state==="idle"?(this.state="drawing",this.points=[i,[...i]],this.initGraphic(),this.updateGraphic()):this.state==="drawing"&&(this.points[this.points.length-1]=i,this.points.length>=Cs?(this.state="finished",this.updateGraphic(),this.saveDrawing(),this.removeGraphic(),this.context.disableTools()):(this.points.push([...i]),this.updateGraphic()))}),Gt(this,"onMouseMove",e=>{this.state!=="drawing"||this.points.length<2||(this.points[this.points.length-1]=this.getPoint(e),this.updateGraphic())})}onInit(){this.context.registerDrawingRenderer(new _e)}onActivate(){this.state="idle",this.points=[],this.context.getChart().getZr().setCursorStyle("crosshair");const t=this.context.getChart().getZr();t.on("click",this.onClick),t.on("mousemove",this.onMouseMove)}onDeactivate(){this.state="idle",this.points=[],this.removeGraphic();const t=this.context.getChart().getZr();t.off("click",this.onClick),t.off("mousemove",this.onMouseMove),t.setCursorStyle("default")}initGraphic(){this.graphicGroup=new G.graphic.Group,this.context.getChart().getZr().add(this.graphicGroup)}removeGraphic(){this.graphicGroup&&(this.context.getChart().getZr().remove(this.graphicGroup),this.graphicGroup=null)}updateGraphic(){if(!this.graphicGroup)return;this.graphicGroup.removeAll();const t=this.points;t.length>=3&&this.graphicGroup.add(new G.graphic.Polygon({shape:{points:t.slice(0,3)},style:{fill:"rgba(0,188,212,0.08)"},silent:!0})),t.length>=5&&this.graphicGroup.add(new G.graphic.Polygon({shape:{points:t.slice(2,5)},style:{fill:"rgba(233,30,99,0.08)"},silent:!0}));for(let e=0;e<t.length-1;e++)this.graphicGroup.add(new G.graphic.Line({shape:{x1:t[e][0],y1:t[e][1],x2:t[e+1][0],y2:t[e+1][1]},style:{stroke:Pe[e%Pe.length],lineWidth:2},silent:!0}));for(let e=0;e<t.length&&e<ke.length;e++){const[i,s]=t[e],a=(e===0||s<=t[e-1][1])&&(e===t.length-1||s<=t[e+1]?.[1]);this.graphicGroup.add(new G.graphic.Text({style:{text:ke[e],x:i,y:a?s-14:s+16,fill:"#e2e8f0",fontSize:12,fontWeight:"bold",align:"center",verticalAlign:"middle"},silent:!0})),this.graphicGroup.add(new G.graphic.Circle({shape:{cx:i,cy:s,r:4},style:{fill:"#fff",stroke:"#3b82f6",lineWidth:1.5},z:101,silent:!0}))}}saveDrawing(){const t=this.points.map(e=>this.context.coordinateConversion.pixelToData({x:e[0],y:e[1]}));t.every(e=>e!==null)&&this.context.addDrawing({id:`cypher-${Date.now()}`,type:"cypher_pattern",points:t,paneIndex:t[0].paneIndex||0,style:{color:"#3b82f6",lineWidth:2}})}}var _s=Object.defineProperty,ks=(p,t,e)=>t in p?_s(p,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):p[t]=e,Ps=(p,t,e)=>(ks(p,typeof t!="symbol"?t+"":t,e),e);const qt=["","LS","","H","","RS",""];class Ae{constructor(){Ps(this,"type","head_and_shoulders")}render(t){const{drawing:e,pixelPoints:i,isSelected:s}=t,a=e.style?.color||"#3b82f6";if(i.length<2)return;const n=[];i.length>=3&&n.push({type:"polygon",name:"line",shape:{points:i.slice(0,3).map(([l,r])=>[l,r])},style:{fill:"rgba(33, 150, 243, 0.06)"}}),i.length>=5&&n.push({type:"polygon",name:"line",shape:{points:i.slice(2,5).map(([l,r])=>[l,r])},style:{fill:"rgba(244, 67, 54, 0.08)"}}),i.length>=7&&n.push({type:"polygon",name:"line",shape:{points:i.slice(4,7).map(([l,r])=>[l,r])},style:{fill:"rgba(33, 150, 243, 0.06)"}});for(let l=0;l<i.length-1;l++){const[r,o]=i[l],[u,d]=i[l+1];n.push({type:"line",name:"line",shape:{x1:r,y1:o,x2:u,y2:d},style:{stroke:"#2196f3",lineWidth:e.style?.lineWidth||2}})}if(i.length>=5){const[l,r]=i[2],[o,u]=i[4],d=o-l,c=u-r,g=.3,h=.3,f=l-d*g,y=r-c*g,x=o+d*h,b=u+c*h;n.push({type:"line",shape:{x1:f,y1:y,x2:x,y2:b},style:{stroke:"#ff9800",lineWidth:2,lineDash:[6,4]},silent:!0}),n.push({type:"text",style:{text:"Neckline",x:(l+o)/2,y:(r+u)/2+14,fill:"#ff9800",fontSize:10,align:"center"},silent:!0})}for(let l=0;l<i.length&&l<qt.length;l++){if(!qt[l])continue;const[r,o]=i[l],u=(l===0||o<=i[l-1][1])&&(l===i.length-1||o<=i[l+1]?.[1]);n.push({type:"text",style:{text:qt[l],x:r,y:u?o-14:o+16,fill:"#e2e8f0",fontSize:12,fontWeight:"bold",align:"center",verticalAlign:"middle"},silent:!0})}for(let l=0;l<i.length;l++)n.push({type:"circle",name:`point-${l}`,shape:{cx:i[l][0],cy:i[l][1],r:4},style:{fill:"#fff",stroke:a,lineWidth:1,opacity:s?1:0},z:100});return{type:"group",children:n}}}var As=Object.defineProperty,Ds=(p,t,e)=>t in p?As(p,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):p[t]=e,$t=(p,t,e)=>(Ds(p,typeof t!="symbol"?t+"":t,e),e);const Ut=["","LS","","H","","RS",""],Ms=7;class Ss extends it{constructor(t={}){super({id:"head-and-shoulders-tool",name:t.name||"Head & Shoulders",icon:t.icon||'<svg viewBox="0 0 24 24" width="24" height="24" fill="none" stroke="#e3e3e3" stroke-width="1.5"><polyline points="1,18 4,10 7,14 12,3 17,14 20,10 23,18"/></svg>'}),$t(this,"points",[]),$t(this,"state","idle"),$t(this,"graphicGroup",null),$t(this,"onClick",e=>{const i=this.getPoint(e);this.state==="idle"?(this.state="drawing",this.points=[i,[...i]],this.initGraphic(),this.updateGraphic()):this.state==="drawing"&&(this.points[this.points.length-1]=i,this.points.length>=Ms?(this.state="finished",this.updateGraphic(),this.saveDrawing(),this.removeGraphic(),this.context.disableTools()):(this.points.push([...i]),this.updateGraphic()))}),$t(this,"onMouseMove",e=>{this.state!=="drawing"||this.points.length<2||(this.points[this.points.length-1]=this.getPoint(e),this.updateGraphic())})}onInit(){this.context.registerDrawingRenderer(new Ae)}onActivate(){this.state="idle",this.points=[],this.context.getChart().getZr().setCursorStyle("crosshair");const t=this.context.getChart().getZr();t.on("click",this.onClick),t.on("mousemove",this.onMouseMove)}onDeactivate(){this.state="idle",this.points=[],this.removeGraphic();const t=this.context.getChart().getZr();t.off("click",this.onClick),t.off("mousemove",this.onMouseMove),t.setCursorStyle("default")}initGraphic(){this.graphicGroup=new G.graphic.Group,this.context.getChart().getZr().add(this.graphicGroup)}removeGraphic(){this.graphicGroup&&(this.context.getChart().getZr().remove(this.graphicGroup),this.graphicGroup=null)}updateGraphic(){if(!this.graphicGroup)return;this.graphicGroup.removeAll();const t=this.points;t.length>=3&&this.graphicGroup.add(new G.graphic.Polygon({shape:{points:t.slice(0,3)},style:{fill:"rgba(33,150,243,0.06)"},silent:!0})),t.length>=5&&this.graphicGroup.add(new G.graphic.Polygon({shape:{points:t.slice(2,5)},style:{fill:"rgba(244,67,54,0.08)"},silent:!0})),t.length>=7&&this.graphicGroup.add(new G.graphic.Polygon({shape:{points:t.slice(4,7)},style:{fill:"rgba(33,150,243,0.06)"},silent:!0}));for(let e=0;e<t.length-1;e++)this.graphicGroup.add(new G.graphic.Line({shape:{x1:t[e][0],y1:t[e][1],x2:t[e+1][0],y2:t[e+1][1]},style:{stroke:"#2196f3",lineWidth:2},silent:!0}));if(t.length>=5){const[e,i]=t[2],[s,a]=t[4],n=s-e,l=a-i;this.graphicGroup.add(new G.graphic.Line({shape:{x1:e-n*.3,y1:i-l*.3,x2:s+n*.3,y2:a+l*.3},style:{stroke:"#ff9800",lineWidth:2,lineDash:[6,4]},silent:!0}))}for(let e=0;e<t.length&&e<Ut.length;e++){const[i,s]=t[e],a=(e===0||s<=t[e-1][1])&&(e===t.length-1||s<=t[e+1]?.[1]);Ut[e]&&this.graphicGroup.add(new G.graphic.Text({style:{text:Ut[e],x:i,y:a?s-14:s+16,fill:"#e2e8f0",fontSize:12,fontWeight:"bold",align:"center",verticalAlign:"middle"},silent:!0})),this.graphicGroup.add(new G.graphic.Circle({shape:{cx:i,cy:s,r:4},style:{fill:"#fff",stroke:"#3b82f6",lineWidth:1.5},z:101,silent:!0}))}}saveDrawing(){const t=this.points.map(e=>this.context.coordinateConversion.pixelToData({x:e[0],y:e[1]}));t.every(e=>e!==null)&&this.context.addDrawing({id:`hs-${Date.now()}`,type:"head_and_shoulders",points:t,paneIndex:t[0].paneIndex||0,style:{color:"#3b82f6",lineWidth:2}})}}var Gs=Object.defineProperty,$s=(p,t,e)=>t in p?Gs(p,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):p[t]=e,zs=(p,t,e)=>($s(p,typeof t!="symbol"?t+"":t,e),e);const De=["1","2","3","4","5"];class Me{constructor(){zs(this,"type","triangle_pattern")}render(t){const{drawing:e,pixelPoints:i,isSelected:s}=t,a=e.style?.color||"#3b82f6";if(i.length<2)return;const n=[];i.length>=3&&n.push({type:"polygon",name:"line",shape:{points:i.map(([o,u])=>[o,u])},style:{fill:"rgba(156, 39, 176, 0.06)"}});const l=i.filter((o,u)=>u%2===0);if(l.length>=2){for(let o=0;o<l.length-1;o++)n.push({type:"line",name:"line",shape:{x1:l[o][0],y1:l[o][1],x2:l[o+1][0],y2:l[o+1][1]},style:{stroke:"#f44336",lineWidth:2}});if(l.length>=2){const o=l[l.length-1],u=l[l.length-2],d=o[0]-u[0],c=o[1]-u[1];if(d!==0){const g=o[0]+d*.5,h=o[1]+c*.5;n.push({type:"line",shape:{x1:o[0],y1:o[1],x2:g,y2:h},style:{stroke:"#f44336",lineWidth:1,lineDash:[4,4]},silent:!0})}}}const r=i.filter((o,u)=>u%2===1);if(r.length>=2){for(let o=0;o<r.length-1;o++)n.push({type:"line",name:"line",shape:{x1:r[o][0],y1:r[o][1],x2:r[o+1][0],y2:r[o+1][1]},style:{stroke:"#4caf50",lineWidth:2}});if(r.length>=2){const o=r[r.length-1],u=r[r.length-2],d=o[0]-u[0],c=o[1]-u[1];if(d!==0){const g=o[0]+d*.5,h=o[1]+c*.5;n.push({type:"line",shape:{x1:o[0],y1:o[1],x2:g,y2:h},style:{stroke:"#4caf50",lineWidth:1,lineDash:[4,4]},silent:!0})}}}for(let o=0;o<i.length-1;o++)n.push({type:"line",shape:{x1:i[o][0],y1:i[o][1],x2:i[o+1][0],y2:i[o+1][1]},style:{stroke:"#9c27b0",lineWidth:1,lineDash:[2,2]},silent:!0});for(let o=0;o<i.length&&o<De.length;o++){const[u,d]=i[o],c=o%2===0;n.push({type:"text",style:{text:De[o],x:u,y:c?d-14:d+16,fill:"#e2e8f0",fontSize:12,fontWeight:"bold",align:"center",verticalAlign:"middle"},silent:!0})}for(let o=0;o<i.length;o++)n.push({type:"circle",name:`point-${o}`,shape:{cx:i[o][0],cy:i[o][1],r:4},style:{fill:"#fff",stroke:a,lineWidth:1,opacity:s?1:0},z:100});return{type:"group",children:n}}}var Es=Object.defineProperty,Ls=(p,t,e)=>t in p?Es(p,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):p[t]=e,zt=(p,t,e)=>(Ls(p,typeof t!="symbol"?t+"":t,e),e);const Se=["1","2","3","4","5"],Ws=5;class Ts extends it{constructor(t={}){super({id:"triangle-pattern-tool",name:t.name||"Triangle Pattern",icon:t.icon||'<svg viewBox="0 0 24 24" width="24" height="24" fill="none" stroke="#e3e3e3" stroke-width="1.5"><path d="M2,4 L22,4 L12,20 Z"/></svg>'}),zt(this,"points",[]),zt(this,"state","idle"),zt(this,"graphicGroup",null),zt(this,"onClick",e=>{const i=this.getPoint(e);this.state==="idle"?(this.state="drawing",this.points=[i,[...i]],this.initGraphic(),this.updateGraphic()):this.state==="drawing"&&(this.points[this.points.length-1]=i,this.points.length>=Ws?(this.state="finished",this.updateGraphic(),this.saveDrawing(),this.removeGraphic(),this.context.disableTools()):(this.points.push([...i]),this.updateGraphic()))}),zt(this,"onMouseMove",e=>{this.state!=="drawing"||this.points.length<2||(this.points[this.points.length-1]=this.getPoint(e),this.updateGraphic())})}onInit(){this.context.registerDrawingRenderer(new Me)}onActivate(){this.state="idle",this.points=[],this.context.getChart().getZr().setCursorStyle("crosshair");const t=this.context.getChart().getZr();t.on("click",this.onClick),t.on("mousemove",this.onMouseMove)}onDeactivate(){this.state="idle",this.points=[],this.removeGraphic();const t=this.context.getChart().getZr();t.off("click",this.onClick),t.off("mousemove",this.onMouseMove),t.setCursorStyle("default")}initGraphic(){this.graphicGroup=new G.graphic.Group,this.context.getChart().getZr().add(this.graphicGroup)}removeGraphic(){this.graphicGroup&&(this.context.getChart().getZr().remove(this.graphicGroup),this.graphicGroup=null)}updateGraphic(){if(!this.graphicGroup)return;this.graphicGroup.removeAll();const t=this.points;t.length>=3&&this.graphicGroup.add(new G.graphic.Polygon({shape:{points:t},style:{fill:"rgba(156,39,176,0.06)"},silent:!0}));for(let s=0;s<t.length-1;s++)this.graphicGroup.add(new G.graphic.Line({shape:{x1:t[s][0],y1:t[s][1],x2:t[s+1][0],y2:t[s+1][1]},style:{stroke:"#9c27b0",lineWidth:2},silent:!0}));const e=t.filter((s,a)=>a%2===0);if(e.length>=2)for(let s=0;s<e.length-1;s++)this.graphicGroup.add(new G.graphic.Line({shape:{x1:e[s][0],y1:e[s][1],x2:e[s+1][0],y2:e[s+1][1]},style:{stroke:"#f44336",lineWidth:1,lineDash:[4,4]},silent:!0}));const i=t.filter((s,a)=>a%2===1);if(i.length>=2)for(let s=0;s<i.length-1;s++)this.graphicGroup.add(new G.graphic.Line({shape:{x1:i[s][0],y1:i[s][1],x2:i[s+1][0],y2:i[s+1][1]},style:{stroke:"#4caf50",lineWidth:1,lineDash:[4,4]},silent:!0}));for(let s=0;s<t.length&&s<Se.length;s++){const[a,n]=t[s],l=s%2===0;this.graphicGroup.add(new G.graphic.Text({style:{text:Se[s],x:a,y:l?n-14:n+16,fill:"#e2e8f0",fontSize:12,fontWeight:"bold",align:"center",verticalAlign:"middle"},silent:!0})),this.graphicGroup.add(new G.graphic.Circle({shape:{cx:a,cy:n,r:4},style:{fill:"#fff",stroke:"#3b82f6",lineWidth:1.5},z:101,silent:!0}))}}saveDrawing(){const t=this.points.map(e=>this.context.coordinateConversion.pixelToData({x:e[0],y:e[1]}));t.every(e=>e!==null)&&this.context.addDrawing({id:`triangle-${Date.now()}`,type:"triangle_pattern",points:t,paneIndex:t[0].paneIndex||0,style:{color:"#3b82f6",lineWidth:2}})}}var Ns=Object.defineProperty,Zs=(p,t,e)=>t in p?Ns(p,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):p[t]=e,Fs=(p,t,e)=>(Zs(p,typeof t!="symbol"?t+"":t,e),e);const Kt=["0","D1","C1","D2","C2","D3",""],Ge=["#2196f3","#ff9800","#4caf50","#f44336","#00bcd4","#e91e63"];class $e{constructor(){Fs(this,"type","three_drives_pattern")}render(t){const{drawing:e,pixelPoints:i,isSelected:s}=t,a=e.style?.color||"#3b82f6";if(i.length<2)return;const n=[];i.length>=3&&n.push({type:"polygon",name:"line",shape:{points:i.slice(0,3).map(([o,u])=>[o,u])},style:{fill:"rgba(33, 150, 243, 0.06)"}}),i.length>=5&&n.push({type:"polygon",name:"line",shape:{points:i.slice(2,5).map(([o,u])=>[o,u])},style:{fill:"rgba(76, 175, 80, 0.06)"}}),i.length>=7&&n.push({type:"polygon",name:"line",shape:{points:i.slice(4,7).map(([o,u])=>[o,u])},style:{fill:"rgba(0, 188, 212, 0.06)"}});for(let o=0;o<i.length-1;o++){const[u,d]=i[o],[c,g]=i[o+1];n.push({type:"line",name:"line",shape:{x1:u,y1:d,x2:c,y2:g},style:{stroke:Ge[o%Ge.length],lineWidth:e.style?.lineWidth||2}})}const l=[[1,3],[3,5],[2,4]];for(const[o,u]of l)o<i.length&&u<i.length&&n.push({type:"line",shape:{x1:i[o][0],y1:i[o][1],x2:i[u][0],y2:i[u][1]},style:{stroke:"#555",lineWidth:1,lineDash:[4,4]},silent:!0});const r=e.points;if(r.length>=4){const o=Math.abs(r[1].value-r[0].value),u=Math.abs(r[3].value-r[2].value);if(o!==0){const d=(u/o).toFixed(3),c=(i[2][0]+i[3][0])/2,g=(i[2][1]+i[3][1])/2;n.push({type:"text",style:{text:`D2/D1: ${d}`,x:c+10,y:g,fill:"#4caf50",fontSize:9},silent:!0})}}if(r.length>=6){const o=Math.abs(r[3].value-r[2].value),u=Math.abs(r[5].value-r[4].value);if(o!==0){const d=(u/o).toFixed(3),c=(i[4][0]+i[5][0])/2,g=(i[4][1]+i[5][1])/2;n.push({type:"text",style:{text:`D3/D2: ${d}`,x:c+10,y:g,fill:"#00bcd4",fontSize:9},silent:!0})}}if(r.length>=3){const o=Math.abs(r[1].value-r[0].value),u=Math.abs(r[2].value-r[1].value);if(o!==0){const d=(u/o).toFixed(3),c=(i[1][0]+i[2][0])/2,g=(i[1][1]+i[2][1])/2;n.push({type:"text",style:{text:d,x:c+8,y:g,fill:"#ff9800",fontSize:10},silent:!0})}}for(let o=0;o<i.length&&o<Kt.length;o++){if(!Kt[o])continue;const[u,d]=i[o],c=(o===0||d<=i[o-1][1])&&(o===i.length-1||d<=i[o+1]?.[1]);n.push({type:"text",style:{text:Kt[o],x:u,y:c?d-14:d+16,fill:"#e2e8f0",fontSize:11,fontWeight:"bold",align:"center",verticalAlign:"middle"},silent:!0})}for(let o=0;o<i.length;o++)n.push({type:"circle",name:`point-${o}`,shape:{cx:i[o][0],cy:i[o][1],r:4},style:{fill:"#fff",stroke:a,lineWidth:1,opacity:s?1:0},z:100});return{type:"group",children:n}}}var Os=Object.defineProperty,Hs=(p,t,e)=>t in p?Os(p,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):p[t]=e,Et=(p,t,e)=>(Hs(p,typeof t!="symbol"?t+"":t,e),e);const Jt=["0","D1","C1","D2","C2","D3",""],ze=["#2196f3","#ff9800","#4caf50","#f44336","#00bcd4","#e91e63"],Rs=7;class Bs extends it{constructor(t={}){super({id:"three-drives-pattern-tool",name:t.name||"Three Drives",icon:t.icon||'<svg viewBox="0 0 24 24" width="24" height="24" fill="none" stroke="#e3e3e3" stroke-width="1.5"><polyline points="1,20 4,8 7,14 11,5 15,12 19,2 23,10"/></svg>'}),Et(this,"points",[]),Et(this,"state","idle"),Et(this,"graphicGroup",null),Et(this,"onClick",e=>{const i=this.getPoint(e);this.state==="idle"?(this.state="drawing",this.points=[i,[...i]],this.initGraphic(),this.updateGraphic()):this.state==="drawing"&&(this.points[this.points.length-1]=i,this.points.length>=Rs?(this.state="finished",this.updateGraphic(),this.saveDrawing(),this.removeGraphic(),this.context.disableTools()):(this.points.push([...i]),this.updateGraphic()))}),Et(this,"onMouseMove",e=>{this.state!=="drawing"||this.points.length<2||(this.points[this.points.length-1]=this.getPoint(e),this.updateGraphic())})}onInit(){this.context.registerDrawingRenderer(new $e)}onActivate(){this.state="idle",this.points=[],this.context.getChart().getZr().setCursorStyle("crosshair");const t=this.context.getChart().getZr();t.on("click",this.onClick),t.on("mousemove",this.onMouseMove)}onDeactivate(){this.state="idle",this.points=[],this.removeGraphic();const t=this.context.getChart().getZr();t.off("click",this.onClick),t.off("mousemove",this.onMouseMove),t.setCursorStyle("default")}initGraphic(){this.graphicGroup=new G.graphic.Group,this.context.getChart().getZr().add(this.graphicGroup)}removeGraphic(){this.graphicGroup&&(this.context.getChart().getZr().remove(this.graphicGroup),this.graphicGroup=null)}updateGraphic(){if(!this.graphicGroup)return;this.graphicGroup.removeAll();const t=this.points;t.length>=3&&this.graphicGroup.add(new G.graphic.Polygon({shape:{points:t.slice(0,3)},style:{fill:"rgba(33,150,243,0.06)"},silent:!0})),t.length>=5&&this.graphicGroup.add(new G.graphic.Polygon({shape:{points:t.slice(2,5)},style:{fill:"rgba(76,175,80,0.06)"},silent:!0})),t.length>=7&&this.graphicGroup.add(new G.graphic.Polygon({shape:{points:t.slice(4,7)},style:{fill:"rgba(0,188,212,0.06)"},silent:!0}));for(let i=0;i<t.length-1;i++)this.graphicGroup.add(new G.graphic.Line({shape:{x1:t[i][0],y1:t[i][1],x2:t[i+1][0],y2:t[i+1][1]},style:{stroke:ze[i%ze.length],lineWidth:2},silent:!0}));const e=[[1,3],[3,5],[2,4]];for(const[i,s]of e)i<t.length&&s<t.length&&this.graphicGroup.add(new G.graphic.Line({shape:{x1:t[i][0],y1:t[i][1],x2:t[s][0],y2:t[s][1]},style:{stroke:"#555",lineWidth:1,lineDash:[4,4]},silent:!0}));for(let i=0;i<t.length&&i<Jt.length;i++){const[s,a]=t[i],n=(i===0||a<=t[i-1][1])&&(i===t.length-1||a<=t[i+1]?.[1]);Jt[i]&&this.graphicGroup.add(new G.graphic.Text({style:{text:Jt[i],x:s,y:n?a-14:a+16,fill:"#e2e8f0",fontSize:11,fontWeight:"bold",align:"center",verticalAlign:"middle"},silent:!0})),this.graphicGroup.add(new G.graphic.Circle({shape:{cx:s,cy:a,r:4},style:{fill:"#fff",stroke:"#3b82f6",lineWidth:1.5},z:101,silent:!0}))}}saveDrawing(){const t=this.points.map(e=>this.context.coordinateConversion.pixelToData({x:e[0],y:e[1]}));t.every(e=>e!==null)&&this.context.addDrawing({id:`3drives-${Date.now()}`,type:"three_drives_pattern",points:t,paneIndex:t[0].paneIndex||0,style:{color:"#3b82f6",lineWidth:2}})}}var js=Object.defineProperty,Ys=(p,t,e)=>t in p?js(p,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):p[t]=e,mt=(p,t,e)=>(Ys(p,typeof t!="symbol"?t+"":t,e),e);class Xs extends it{constructor(t){const e='<svg width="8" height="8" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="position: absolute; right: -4px; top: 50%; transform: translateY(-50%); opacity: 0.6;"><polyline points="9 18 15 12 9 6"></polyline></svg>';let i="";t.icon?i=`<div style="position: relative; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;">
41
+ <div style="width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;">
42
+ ${t.icon}
43
+ </div>
44
+ ${e}
45
+ </div>`:i=`<div style="position: relative; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;">
46
+ <span>${t.name.substring(0,2).toUpperCase()}</span>
47
+ ${e}
48
+ </div>`,super({id:t.id||`group-${t.name.toLowerCase().replace(/\s+/g,"-")}`,name:t.name,icon:i}),mt(this,"plugins",[]),mt(this,"activeSubPlugin",null),mt(this,"menuElement",null),mt(this,"buttonElement",null),mt(this,"originalIcon",""),mt(this,"arrowSvg",""),mt(this,"handleOutsideClick",s=>{this.menuElement&&!this.menuElement.contains(s.target)&&(this.hideMenu(),this.activeSubPlugin||this.buttonElement?.click())}),this.originalIcon=i,this.arrowSvg=e}add(t){this.plugins.push(t)}onInit(){this.plugins.forEach(t=>t.init(this.context))}onActivate(){this.showMenu()}onDeactivate(){this.hideMenu(),this.activeSubPlugin&&(this.activeSubPlugin.deactivate?.(),this.activeSubPlugin=null),this.buttonElement&&(this.buttonElement.innerHTML=this.originalIcon)}onDestroy(){this.hideMenu(),this.plugins.forEach(t=>t.destroy?.())}showMenu(){if(this.buttonElement=document.getElementById(`qfchart-plugin-btn-${this.id}`),!this.buttonElement)return;this.menuElement&&this.hideMenu(),this.menuElement=document.createElement("div"),Object.assign(this.menuElement.style,{position:"fixed",backgroundColor:"#1e293b",border:"1px solid #334155",borderRadius:"6px",padding:"4px",display:"flex",flexDirection:"column",gap:"2px",zIndex:"10000",boxShadow:"0 4px 6px -1px rgba(0, 0, 0, 0.3)",minWidth:"150px"}),this.plugins.forEach(e=>{const i=document.createElement("div");if(Object.assign(i.style,{display:"flex",alignItems:"center",padding:"8px 12px",cursor:"pointer",color:"#cbd5e1",borderRadius:"4px",fontSize:"13px",fontFamily:this.context.getOptions().fontFamily||"sans-serif",transition:"background-color 0.2s"}),i.addEventListener("mouseenter",()=>{i.style.backgroundColor="rgba(255, 255, 255, 0.1)"}),i.addEventListener("mouseleave",()=>{i.style.backgroundColor="transparent"}),e.icon){const a=document.createElement("div");a.innerHTML=e.icon,Object.assign(a.style,{width:"20px",height:"20px",marginRight:"10px",display:"flex",alignItems:"center",justifyContent:"center"});const n=a.querySelector("svg");n&&(n.style.width="100%",n.style.height="100%"),i.appendChild(a)}const s=document.createElement("span");s.textContent=e.name||e.id,i.appendChild(s),i.addEventListener("click",a=>{a.stopPropagation(),this.activateSubPlugin(e)}),this.menuElement.appendChild(i)}),document.body.appendChild(this.menuElement);const t=this.buttonElement.getBoundingClientRect();this.menuElement.style.top=`${t.top}px`,this.menuElement.style.left=`${t.right+5}px`,setTimeout(()=>{document.addEventListener("click",this.handleOutsideClick)},0)}hideMenu(){this.menuElement&&this.menuElement.parentNode&&this.menuElement.parentNode.removeChild(this.menuElement),this.menuElement=null,document.removeEventListener("click",this.handleOutsideClick)}activateSubPlugin(t){if(this.hideMenu(),this.activeSubPlugin&&this.activeSubPlugin.deactivate?.(),this.activeSubPlugin=t,this.activeSubPlugin.activate?.(),this.buttonElement){let e="";t.icon?e=`<div style="position: relative; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;">
49
+ <div style="width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;">
50
+ ${t.icon}
51
+ </div>
52
+ ${this.arrowSvg}
53
+ </div>`:e=`<div style="position: relative; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;">
54
+ <span>${(t.name||t.id).substring(0,2).toUpperCase()}</span>
55
+ ${this.arrowSvg}
56
+ </div>`,this.buttonElement.innerHTML=e}}}export{be as ABCDPatternDrawingRenderer,ys as ABCDPatternTool,it as AbstractPlugin,_e as CypherPatternDrawingRenderer,Is as CypherPatternTool,ne as DrawingRendererRegistry,le as FibSpeedResistanceFanDrawingRenderer,Vi as FibSpeedResistanceFanTool,pe as FibTrendExtensionDrawingRenderer,ts as FibTrendExtensionTool,re as FibonacciChannelDrawingRenderer,Hi as FibonacciChannelTool,ae as FibonacciDrawingRenderer,Wi as FibonacciTool,Ae as HeadAndShouldersDrawingRenderer,Ss as HeadAndShouldersTool,oe as LineDrawingRenderer,Si as LineTool,_i as MeasureTool,bi as QFChart,$e as ThreeDrivesPatternDrawingRenderer,Bs as ThreeDrivesPatternTool,Xs as ToolGroup,Me as TrianglePatternDrawingRenderer,Ts as TrianglePatternTool,ge as XABCDPatternDrawingRenderer,hs as XABCDPatternTool};