@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
- (function(nt,ut){typeof exports=="object"&&typeof module<"u"?ut(exports,require("echarts")):typeof define=="function"&&define.amd?define(["exports","echarts"],ut):(nt=typeof globalThis<"u"?globalThis:nt||self,ut(nt.QFChart={},nt.echarts))})(this,function(nt,ut){"use strict";function Pt(x){var t=Object.create(null);return x&&Object.keys(x).forEach(function(e){if(e!=="default"){var i=Object.getOwnPropertyDescriptor(x,e);Object.defineProperty(t,e,i.get?i:{enumerable:!0,get:function(){return x[e]}})}}),t.default=x,Object.freeze(t)}var H=Pt(ut),Dt=Object.defineProperty,Mt=(x,t,e)=>t in x?Dt(x,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):x[t]=e,ht=(x,t,e)=>(Mt(x,typeof t!="symbol"?t+"":t,e),e);class zt{constructor(t,e,i,s={}){ht(this,"id"),ht(this,"plots"),ht(this,"paneIndex"),ht(this,"height"),ht(this,"collapsed"),ht(this,"titleColor"),ht(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 At{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,L)=>S-L).filter((S,L,N)=>N.indexOf(S)===L),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=[],L=[],N=[],R=[],V=i.dataZoom?.start??50,E=i.dataZoom?.end??100;(i.dataZoom?.zoomOnTouch??!0)&&R.push({type:"inside",xAxisIndex:"all",start:V,end:E,filterMode:"weakFilter"});const T=r?Math.max(...g):0,B=[];for(let O=0;O<=T;O++){const j=O===C;S.push({left:"10%",right:"10%",top:j?"5%":"0%",height:j?"90%":"0%",show:j,containLabel:!1}),L.push({type:"category",gridIndex:O,data:[],show:j,axisLabel:{show:j,color:"#94a3b8",fontFamily:i.fontFamily},axisLine:{show:j,lineStyle:{color:"#334155"}},splitLine:{show:j,lineStyle:{color:"#334155",opacity:.5}}});let st,at;if(O===0&&C===0?(st=i.yAxisMin!==void 0&&i.yAxisMin!=="auto"?i.yAxisMin:Z.createMinFunction(p),at=i.yAxisMax!==void 0&&i.yAxisMax!=="auto"?i.yAxisMax:Z.createMaxFunction(p)):(st=Z.createMinFunction(p),at=Z.createMaxFunction(p)),N.push({position:"right",gridIndex:O,show:j,scale:!0,min:st,max:at,axisLabel:{show:j,color:"#94a3b8",fontFamily:i.fontFamily,formatter:Q=>{if(i.yAxisLabelFormatter)return i.yAxisLabelFormatter(Q);const rt=i.yAxisDecimalPlaces!==void 0?i.yAxisDecimalPlaces:Z.autoDetectDecimals(o);return Z.formatValue(Q,rt)}},splitLine:{show:j,lineStyle:{color:"#334155",opacity:.5}}}),O>0){const Q=Array.from(e.values()).find(rt=>rt.paneIndex===O);Q&&B.push({index:O,height:j?90:0,top:j?5:0,isCollapsed:!1,indicatorId:Q.id,titleColor:Q.titleColor,controls:Q.controls})}}return{grid:S,xAxis:L,yAxis:N,dataZoom:R,paneLayout:B,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(B=>B.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})),L=S.reduce((E,T)=>E+T.height,0),N=S.length*A,R=L+N;v=w-m-R,u!==void 0&&u>0&&!s?v=u:s?v=3:v<20&&(v=Math.max(v,10));let V=m+v+A;y=S.map(E=>{const T={index:E.index,height:E.height,top:V,isCollapsed:E.isCollapsed,indicatorId:E.indicatorId,titleColor:E.titleColor,controls:E.controls};return V+=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,L)=>L+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 L=i.yAxisDecimalPlaces!==void 0?i.yAxisDecimalPlaces:Z.autoDetectDecimals(o);return Z.formatValue(S,L)}},axisTick:{show:!s},axisPointer:{label:{show:k,fontSize:11,backgroundColor:"#475569"}}}),y.forEach((S,L)=>{const N=L===y.length-1;P.push({type:"category",gridIndex:L+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,$;i.yAxisMin!==void 0&&i.yAxisMin!=="auto"?M=i.yAxisMin:M=Z.createMinFunction(p),i.yAxisMax!==void 0&&i.yAxisMax!=="auto"?$=i.yAxisMax:$=Z.createMaxFunction(p),D.push({position:"right",scale:!0,min:M,max:$,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 L=i.yAxisDecimalPlaces!==void 0?i.yAxisDecimalPlaces:Z.autoDetectDecimals(o);return Z.formatValue(S,L)}}});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 W=new Map;e.forEach((S,L)=>{S.paneIndex===0&&!S.collapsed&&o&&o.length>0&&Object.entries(S.plots).forEach(([N,R])=>{const V=`${L}::${N}`,E=["background","barcolor","char"],T=R.options.style==="shape"&&(R.options.location==="abovebar"||R.options.location==="AboveBar"||R.options.location==="belowbar"||R.options.location==="BelowBar");if(E.includes(R.options.style)){W.has(V)||(W.set(V,F),F++);return}if(R.options.style==="shape"&&!T){W.has(V)||(W.set(V,F),F++);return}const B=[];if(R.data&&Object.values(R.data).forEach(O=>{typeof O=="number"&&!isNaN(O)&&isFinite(O)&&B.push(O)}),B.length>0){const O=Math.min(...B),j=Math.max(...B),st=j-O,at=tt-U,Q=O>=U*.5&&j<=tt*1.5,rt=st>at*.01;Q&&rt||W.has(V)||(W.set(V,F),F++)}})});const et=W.size>0?F-1:0,ot=new Set;W.forEach((S,L)=>{e.forEach(N=>{Object.entries(N.plots).forEach(([R,V])=>{`${N.id}::${R}`===L&&["background","barcolor","char"].includes(V.options.style)&&ot.add(S)})})});for(let S=0;S<et;S++){const L=S+1,N=ot.has(L);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,L)=>{D.push({position:"right",scale:!0,min:Z.createMinFunction(p),max:Z.createMaxFunction(p),gridIndex:L+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 R=i.yAxisDecimalPlaces!==void 0?i.yAxisDecimalPlaces:Z.autoDetectDecimals(o);return Z.formatValue(N,R)}},axisLine:{show:!S.isCollapsed,lineStyle:{color:"#334155"}}})});const G=[];return l&&((i.dataZoom?.zoomOnTouch??!0)&&G.push({type:"inside",xAxisIndex:I,start:c,end:f,filterMode:"weakFilter"}),h==="top"?G.push({type:"slider",xAxisIndex:I,top:"1%",height:n+"%",start:c,end:f,borderColor:"#334155",textStyle:{color:"#cbd5e1"},brushSelect:!1,filterMode:"weakFilter"}):G.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:G,paneLayout:y,mainPaneHeight:v,mainPaneTop:m,pixelToPercent:d,paneBoundaries:b,overlayYAxisMap:W,separatePaneYAxisOffset:it}}static calculateMaximized(t,e,i){return{grid:[],xAxis:[],yAxis:[],dataZoom:[],paneLayout:[],mainPaneHeight:0,mainPaneTop:0,pixelToPercent:0,paneBoundaries:[]}}}class Lt{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 $t{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 St{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 Et(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://${Et("+",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 _t{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,_),$=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:$||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 dt{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 Nt{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=dt.getShapeSymbol(w),k=dt.getShapeSize(C,y,b),D=dt.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 $=dt.getLabelConfig(w,f);return{value:[h,_],symbol:P,symbolSize:M,symbolRotate:D,symbolOffset:I,itemStyle:{color:m},label:{show:!!A,position:$.position,distance:$.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 Ft{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 ct{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 Tt{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}=ct.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=ct.parseColor(l.top_color),n=ct.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=ct.toRgba(y.topColor,y.topOpacity),_=ct.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 Ot{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 _=dt.getShapeSymbol(A),I=dt.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,W=P*2.5,et=Math.max(W,tt+P*1.6),ot=P*2.8,it=3/24;if(A==="labelleft"||A==="labelright"){const G=et/(1-it);k=[G,ot];const S=typeof b[0]=="string"?0:b[0];A==="labelleft"?(b=[S+G*.42,b[1]],M=[G*it*.5,0]):(b=[S-G*.42,b[1]],M=[-G*it*.5,0])}else{const G=ot/(1-it);k=[et,G],A==="labeldown"?(b=[b[0],typeof b[1]=="string"?b[1]:b[1]-G*.42],M=[0,-G*it*.5]):(b=[b[0],typeof b[1]=="string"?b[1]:b[1]+G*.42],M=[0,G*it*.5])}}else A==="none"?k=0:Array.isArray(I)?k=[I[0]*1.5,I[1]*1.5]:k=I*1.5;const $=this.getLabelPosition(f,c),F=$==="inside"||$.startsWith("inside"),U={value:[v,y],symbol:_,symbolSize:k,symbolOffset:b,itemStyle:{color:h},label:{show:!!l,position:$,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 Zt{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 Ht{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,$=k.y,F=k.y+k.height;b!=="none"&&([C,A]=this.extendLine(C,A,b,D,M,$,F)),_!=="none"&&([v,y]=this.extendLine(v,y,_,D,M,$,F))}const{color:I,opacity:P}=ct.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 Wt{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}=ct.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 Gt{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 Rt=Object.defineProperty,Bt=(x,t,e)=>t in x?Rt(x,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):x[t]=e,Yt=(x,t,e)=>(Bt(x,typeof t!="symbol"?t+"":t,e),e);const Y=class{static register(t,e){this.renderers.set(t,e)}static get(t){return this.renderers.get(t)||this.renderers.get("line")}};Yt(Y,"renderers",new Map),Y.register("line",new Lt),Y.register("step",new $t),Y.register("histogram",new St),Y.register("columns",new St),Y.register("circles",new bt),Y.register("cross",new bt),Y.register("char",new bt),Y.register("bar",new _t),Y.register("candle",new _t),Y.register("shape",new Nt),Y.register("background",new Ft),Y.register("fill",new Tt),Y.register("label",new Ot),Y.register("drawing_line",new Zt),Y.register("linefill",new Ht),Y.register("drawing_polyline",new Wt),Y.register("drawing_box",new Gt);let jt=Y;var qt=Object.defineProperty,Vt=(x,t,e)=>t in x?qt(x,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):x[t]=e,Xt=(x,t,e)=>(Vt(x,typeof t!="symbol"?t+"":t,e),e);const kt=class Ct{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 $=I.options?.color;v[D]=M;const F=I.options!=null&&"color"in I.options,U=$===null||$==="na"||$==="NaN"||typeof $=="number"&&isNaN($)||F&&$===void 0;U&&(M=null),A[D]=M,y[D]=U?null:$||c.options.color||Ct.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||Ct.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 _=jt.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}}};Xt(kt,"DEFAULT_COLOR","#2962ff");let gt=kt;class Ut{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 Jt{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
+ (function(N,At){typeof exports=="object"&&typeof module<"u"?At(exports,require("echarts")):typeof define=="function"&&define.amd?define(["exports","echarts"],At):(N=typeof globalThis<"u"?globalThis:N||self,At(N.QFChart={},N.echarts))})(this,function(N,At){"use strict";function Te(d){var t=Object.create(null);return d&&Object.keys(d).forEach(function(e){if(e!=="default"){var i=Object.getOwnPropertyDescriptor(d,e);Object.defineProperty(t,e,i.get?i:{enumerable:!0,get:function(){return d[e]}})}}),t.default=d,Object.freeze(t)}var G=Te(At),We=Object.defineProperty,Ne=(d,t,e)=>t in d?We(d,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):d[t]=e,xt=(d,t,e)=>(Ne(d,typeof t!="symbol"?t+"":t,e),e);class Fe{constructor(t,e,i,s={}){xt(this,"id"),xt(this,"plots"),xt(this,"paneIndex"),xt(this,"height"),xt(this,"collapsed"),xt(this,"titleColor"),xt(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 B{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 Bt{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,p=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,R)=>E-R).filter((E,R,q)=>q.indexOf(E)===R),b=x.length>0,D=i.dataZoom?.visible??!0,w=i.dataZoom?.position??"top",P=i.dataZoom?.height??6,m=i.dataZoom?.start??0,C=i.dataZoom?.end??100;let v=8,_=92,k=-1;if(a)if(a==="main")k=0;else{const E=e.get(a);E&&(k=E.paneIndex)}if(k!==-1){const E=[],R=[],q=[],J=[],at=i.dataZoom?.start??50,Y=i.dataZoom?.end??100;(i.dataZoom?.zoomOnTouch??!0)&&J.push({type:"inside",xAxisIndex:"all",start:at,end:Y,filterMode:"weakFilter"});const rt=b?Math.max(...x):0,ut=[];for(let tt=0;tt<=rt;tt++){const it=tt===k;E.push({left:f,right:y,top:it?"5%":"0%",height:it?"90%":"0%",show:it,containLabel:!1}),R.push({type:"category",gridIndex:tt,data:[],show:it,axisLabel:{show:it,color:"#94a3b8",fontFamily:i.fontFamily},axisLine:{show:it&&h,lineStyle:{color:g}},splitLine:{show:it&&u,lineStyle:{color:p,opacity:c}}});let Et,Lt;if(tt===0&&k===0?(Et=i.yAxisMin!==void 0&&i.yAxisMin!=="auto"?i.yAxisMin:B.createMinFunction(o),Lt=i.yAxisMax!==void 0&&i.yAxisMax!=="auto"?i.yAxisMax:B.createMaxFunction(o)):(Et=B.createMinFunction(o),Lt=B.createMaxFunction(o)),q.push({position:"right",gridIndex:tt,show:it,scale:!0,min:Et,max:Lt,axisLabel:{show:it,color:"#94a3b8",fontFamily:i.fontFamily,formatter:gt=>{if(i.yAxisLabelFormatter)return i.yAxisLabelFormatter(gt);const Tt=i.yAxisDecimalPlaces!==void 0?i.yAxisDecimalPlaces:B.autoDetectDecimals(n);return B.formatValue(gt,Tt)}},splitLine:{show:it&&u,lineStyle:{color:p,opacity:c}}}),tt>0){const gt=Array.from(e.values()).find(Tt=>Tt.paneIndex===tt);gt&&ut.push({index:tt,height:it?90:0,top:it?5:0,isCollapsed:!1,indicatorId:gt.id,titleColor:gt.titleColor,controls:gt.controls})}}return{grid:E,xAxis:R,yAxis:q,dataZoom:J,paneLayout:ut,mainPaneHeight:k===0?90:0,mainPaneTop:k===0?5:0,pixelToPercent:r,overlayYAxisMap:new Map,separatePaneYAxisOffset:1}}D?w==="top"?(v=P+4,_=95):(_=100-P-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(Y=>{const rt=Array.from(e.values()).find(ut=>ut.paneIndex===Y);return{index:Y,requestedHeight:rt?.height,isCollapsed:rt?.collapsed??!1,indicatorId:rt?.id,titleColor:rt?.titleColor,controls:rt?.controls}}).map(Y=>({...Y,height:Y.isCollapsed?3:Y.requestedHeight!==void 0?Y.requestedHeight:15})),R=E.reduce((Y,rt)=>Y+rt.height,0),q=E.length*M,J=R+q;S=_-v-J,l!==void 0&&l>0&&!s?S=l:s?S=3:S<20&&(S=Math.max(S,10));let at=v+S+M;z=E.map(Y=>{const rt={index:Y.index,height:Y.height,top:at,isCollapsed:Y.isCollapsed,indicatorId:Y.indicatorId,titleColor:Y.titleColor,controls:Y.controls};return at+=Y.height+M,rt})}else S=_-v,s&&(S=3);const T=[];if(z.length>0){T.push({yPercent:v+S+M/2,aboveId:"main",belowId:z[0].indicatorId||""});for(let E=0;E<z.length-1;E++)T.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,R)=>R+1)],A=[],O=z.length===0;A.push({type:"category",data:[],gridIndex:0,scale:!0,axisLine:{onZero:!1,show:!s&&h,lineStyle:{color:g}},splitLine:{show:!s&&u,lineStyle:{color:p,opacity:c}},axisLabel:{show:!s,color:"#94a3b8",fontFamily:i.fontFamily||"sans-serif",formatter:E=>{if(i.yAxisLabelFormatter)return i.yAxisLabelFormatter(E);const R=i.yAxisDecimalPlaces!==void 0?i.yAxisDecimalPlaces:B.autoDetectDecimals(n);return B.formatValue(E,R)}},axisTick:{show:!s},axisPointer:{label:{show:O,fontSize:11,backgroundColor:"#475569"}}}),z.forEach((E,R)=>{const q=R===z.length-1;A.push({type:"category",gridIndex:R+1,data:[],axisLabel:{show:!1},axisLine:{show:!E.isCollapsed&&h,lineStyle:{color:g}},axisTick:{show:!1},splitLine:{show:!1},axisPointer:{label:{show:q,fontSize:11,backgroundColor:"#475569"}}})});const W=[];let j,Z;i.yAxisMin!==void 0&&i.yAxisMin!=="auto"?j=i.yAxisMin:j=B.createMinFunction(o),i.yAxisMax!==void 0&&i.yAxisMax!=="auto"?Z=i.yAxisMax:Z=B.createMaxFunction(o),W.push({position:"right",scale:!0,min:j,max:Z,gridIndex:0,splitLine:{show:!s&&u,lineStyle:{color:p,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 R=i.yAxisDecimalPlaces!==void 0?i.yAxisDecimalPlaces:B.autoDetectDecimals(n);return B.formatValue(E,R)}}});let F=1,U=-1/0,H=1/0;n&&n.length>0&&(U=Math.min(...n.map(E=>E.low)),H=Math.max(...n.map(E=>E.high)));const X=new Map;e.forEach((E,R)=>{E.paneIndex===0&&!E.collapsed&&n&&n.length>0&&Object.entries(E.plots).forEach(([q,J])=>{const at=`${R}::${q}`,Y=["background","barcolor","char"],rt=J.options.style==="shape"&&(J.options.location==="abovebar"||J.options.location==="AboveBar"||J.options.location==="belowbar"||J.options.location==="BelowBar");if(Y.includes(J.options.style)){X.has(at)||(X.set(at,F),F++);return}if(J.options.style==="shape"&&!rt){X.has(at)||(X.set(at,F),F++);return}const ut=[];if(J.data&&Object.values(J.data).forEach(tt=>{typeof tt=="number"&&!isNaN(tt)&&isFinite(tt)&&ut.push(tt)}),ut.length>0){const tt=Math.min(...ut),it=Math.max(...ut),Et=it-tt,Lt=H-U,gt=tt>=U*.5&&it<=H*1.5,Tt=Et>Lt*.01;gt&&Tt||X.has(at)||(X.set(at,F),F++)}})});const ht=X.size>0?F-1:0,dt=new Set;X.forEach((E,R)=>{e.forEach(q=>{Object.entries(q.plots).forEach(([J,at])=>{`${q.id}::${J}`===R&&["background","barcolor","char"].includes(at.options.style)&&dt.add(E)})})});for(let E=0;E<ht;E++){const R=E+1,q=dt.has(R);W.push({position:"left",scale:!q,min:q?0:B.createMinFunction(o),max:q?1:B.createMaxFunction(o),gridIndex:0,show:!1,splitLine:{show:!1},axisLine:{show:!1},axisLabel:{show:!1}})}const te=F;z.forEach((E,R)=>{W.push({position:"right",scale:!0,min:B.createMinFunction(o),max:B.createMaxFunction(o),gridIndex:R+1,splitLine:{show:!E.isCollapsed&&u,lineStyle:{color:p,opacity:c*.6}},axisLabel:{show:!E.isCollapsed,color:"#94a3b8",fontFamily:i.fontFamily||"sans-serif",fontSize:10,formatter:q=>{if(i.yAxisLabelFormatter)return i.yAxisLabelFormatter(q);const J=i.yAxisDecimalPlaces!==void 0?i.yAxisDecimalPlaces:B.autoDetectDecimals(n);return B.formatValue(q,J)}},axisLine:{show:!E.isCollapsed&&h,lineStyle:{color:g}}})});const Pt=[],Ht=i.dataZoom?.zoomOnTouch??!0,Rt=i.dataZoom?.pannable??!0;return Ht&&Rt&&Pt.push({type:"inside",xAxisIndex:$,start:m,end:C,filterMode:"weakFilter"}),D&&(w==="top"?Pt.push({type:"slider",xAxisIndex:$,top:"1%",height:P+"%",start:m,end:C,borderColor:"#334155",textStyle:{color:"#cbd5e1"},brushSelect:!1,filterMode:"weakFilter"}):Pt.push({type:"slider",xAxisIndex:$,bottom:"1%",height:P+"%",start:m,end:C,borderColor:"#334155",textStyle:{color:"#cbd5e1"},brushSelect:!1,filterMode:"weakFilter"})),{grid:I,xAxis:A,yAxis:W,dataZoom:Pt,paneLayout:z,mainPaneHeight:S,mainPaneTop:v,pixelToPercent:r,paneBoundaries:T,overlayYAxisMap:X,separatePaneYAxisOffset:te}}static calculateMaximized(t,e,i){return{grid:[],xAxis:[],yAxis:[],dataZoom:[],paneLayout:[],mainPaneHeight:0,mainPaneTop:0,pixelToPercent:0,paneBoundaries:[]}}}class Ze{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 p=o.dataIndex;if(p===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([p-1,g]),f=u.coord([p,c]);return{type:"line",shape:{x1:h[0],y1:h[1],x2:f[0],y2:f[1]},style:{stroke:n[p]||l.color||r,lineWidth:l.linewidth||1},silent:!0}},data:a.map((o,u)=>[u,o,u>0?a[u-1]:null])}}}class Oe{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 p=u.value(0),c=u.value(1);if(isNaN(c)||c===null)return;const g=u.coord([p,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 ie{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",p=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 P;u?P=w*.6:P=Math.max(1,p);const m=b[0],C=b[1],v=D[1],_=Math.min(C,v),k=Math.abs(v-C);return{type:"rect",shape:{x:m-P/2,y:_,width:P,height:k||1},style:{fill:x}}},data:c.filter(g=>g!==null)}}}const jt=new Map;function He(d,t="#00da3c",e="64px"){if(typeof document>"u")return"";const i=`${d}-${t}-${e}`;if(jt.has(i))return jt.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(d,16,16);const n=s.toDataURL("image/png");return jt.set(i,n),n}return""}class Yt{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((p,c)=>({value:[c,p],itemStyle:{opacity:0}})),silent:!0};const u=a.map((p,c)=>{if(p===null)return null;const g=n[c]||l.color||r,h={value:[c,p],itemStyle:{color:g}};return o==="cross"?(h.symbol=`image://${He("+",g,"24px")}`,h.symbolSize=16):(h.symbol="circle",h.symbolSize=6),h}).filter(p=>p!==null);return{name:e,type:"scatter",xAxisIndex:i,yAxisIndex:s,data:u}}}class se{render(t){const{seriesName:e,xAxisIndex:i,yAxisIndex:s,dataArray:a,colorArray:n,optionsArray:l,plotOptions:r}=t,o="#2962ff",u=r.style==="candle",p=[],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,P=D.wickcolor||r.wickcolor||w,m=D.bordercolor||r.bordercolor||P;return p[h]={color:w,wickColor:P,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=p[f]||{color:o,wickColor:o,borderColor:o},P=w.color,m=w.wickColor,C=w.borderColor,v=h.coord([f,0])[0],_=h.coord([f,y])[1],k=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 T=Math.min(_,k),I=Math.max(_,k),$=Math.abs(k-_);return{type:"group",children:[{type:"line",shape:{x1:v,y1:S,x2:v,y2:T},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:T,width:z,height:$||1},style:{fill:P,stroke:C,lineWidth:1}}]}}else{const T=z*.5;return{type:"group",children:[{type:"line",shape:{x1:v,y1:M,x2:v,y2:S},style:{stroke:P,lineWidth:1}},{type:"line",shape:{x1:v-T,y1:_,x2:v,y2:_},style:{stroke:P,lineWidth:1}},{type:"line",shape:{x1:v,y1:k,x2:v+T,y2:k},style:{stroke:P,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 Re{render(t){const{seriesName:e,xAxisIndex:i,yAxisIndex:s,dataArray:a,colorArray:n,optionsArray:l,plotOptions:r,candlestickData:o}=t,u="#2962ff",p=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,P=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 k=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 T=vt.getLabelConfig(b,y);return{value:[g,v],symbol:k,symbolSize:z,symbolRotate:S,symbolOffset:_,itemStyle:{color:x},label:{show:!!w,position:T.position,distance:T.distance,formatter:w,color:P,fontSize:10,fontWeight:"bold"}}}).filter(c=>c!==null);return{name:e,type:"scatter",xAxisIndex:i,yAxisIndex:s,data:p}}}class ot{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 Be{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]?ot.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 p=o.coord([u,.5]),c=o.size([1,0])[0],g=r.coordSys,h=p[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 ne{render(t){const{seriesName:e,xAxisIndex:i,yAxisIndex:s,plotOptions:a,plotDataArrays:n,indicatorId:l,plotName:r,optionsArray:o}=t,u=t.dataArray.length,p=a.plot1?`${l}::${a.plot1}`:null,c=a.plot2?`${l}::${a.plot2}`:null;if(!p||!c)return console.warn(`Fill plot "${r}" missing plot1 or plot2 reference`),null;const g=n?.get(p),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}=ot.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 P=o?.[w];P&&P.color!==void 0?b[w]=ot.parseColor(P.color):b[w]={color:f,opacity:y}}}const D=[];for(let w=0;w<u;w++){const P=g[w],m=h[w],C=w>0?g[w-1]:null,v=w>0?h[w-1]:null;D.push([w,P,m,C,v])}return{name:e,type:"custom",xAxisIndex:i,yAxisIndex:s,z:1,clip:!0,encode:{x:0},animation:!1,renderItem:(w,P)=>{const m=w.dataIndex;if(m===0)return null;const C=P.value(1),v=P.value(2),_=P.value(3),k=P.value(4);if(C===null||v===null||_===null||k===null||isNaN(C)||isNaN(v)||isNaN(_)||isNaN(k))return null;const M=b?b[m]:null,S=M?M.opacity:y;if(S<.01)return null;const z=P.coord([m-1,_]),T=P.coord([m,C]),I=P.coord([m,v]),$=P.coord([m-1,k]);return{type:"polygon",shape:{points:[z,T,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 p=0;p<a.length;p++){const c=a[p],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]),P=r.coord([o-1,y]);u.push({type:"polygon",shape:{points:[b,D,w,P]},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 p=0;p<n;p++){const c=l?.[p];if(c&&c.top_color!==void 0){const g=ot.parseColor(c.top_color),h=ot.parseColor(c.bottom_color);o[p]={topColor:g.color,topOpacity:g.opacity,bottomColor:h.color,bottomOpacity:h.opacity}}else o[p]={topColor:"rgba(128,128,128,0.2)",topOpacity:.2,bottomColor:"rgba(128,128,128,0.2)",bottomOpacity:.2}}const u=[];for(let p=0;p<n;p++){const c=s[p],g=a[p],h=p>0?s[p-1]:null,f=p>0?a[p-1]:null;u.push([p,c,g,h,f])}return{name:t,type:"custom",xAxisIndex:e,yAxisIndex:i,z:1,clip:!0,encode:{x:0},animation:!1,renderItem:(p,c)=>{const g=p.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]),P=c.coord([g-1,x]),m=o[g]||o[g-1];if(!m||m.topOpacity<.01&&m.bottomOpacity<.01)return null;const C=ot.toRgba(m.topColor,m.topOpacity),v=ot.toRgba(m.bottomColor,m.bottomOpacity),_=h>=f;return{type:"polygon",shape:{points:[b,D,w,P]},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 je{render(t){const{seriesName:e,xAxisIndex:i,yAxisIndex:s,dataArray:a,candlestickData:n,dataIndexOffset:l}=t,r=l||0,o=[];for(let p=0;p<a.length;p++){const c=a[p];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(p=>{const c=W=>typeof W=="function"?W():W,g=c(p.text)||"",h=c(p.color),f=h!=null&&h!==""?h:"transparent",y=c(p.textcolor)||"#ffffff",x=c(p.yloc)||"price",b=c(p.style)||"style_label_down",D=c(p.size)||"normal",w=c(p.textalign)||"align_center",P=c(p.tooltip)||"",m=this.styleToShape(b),C=p.xloc==="bar_index"||p.xloc==="bi"?p.x+r:p.x;let v=p.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 k=vt.getShapeSymbol(m),M=vt.getShapeSize(D),S=this.getSizePx(D);let z;const T=m==="labeldown"||m==="shape_label_down"||m==="labelup"||m==="shape_label_up"||m==="labelleft"||m==="labelright";let I=[0,0];if(T){const W=g.length*S*.65,j=S*2.5,Z=Math.max(j,W+S*1.6),F=S*2.8,U=3/24;if(m==="labelleft"||m==="labelright"){const H=Z/(1-U);z=[H,F];const X=typeof _[0]=="string"?0:_[0];m==="labelleft"?(_=[X+H*.42,_[1]],I=[H*U*.5,0]):(_=[X-H*.42,_[1]],I=[-H*U*.5,0])}else{const H=F/(1-U);z=[Z,H],m==="labeldown"?(_=[_[0],typeof _[1]=="string"?_[1]:_[1]-H*.42],I=[0,-H*U*.5]):(_=[_[0],typeof _[1]=="string"?_[1]:_[1]+H*.42],I=[0,H*U*.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),A=$==="inside"||$.startsWith("inside"),O={value:[C,v],symbol:k,symbolSize:z,symbolOffset:_,itemStyle:{color:f},label:{show:!!g,position:$,distance:A?0:5,offset:I,formatter:g,color:y,fontSize:S,fontWeight:"bold",align:A?"center":w==="align_left"||w==="left"?"left":w==="align_right"||w==="right"?"right":"center",verticalAlign:"middle",padding:[2,6]}};return P?(O._tooltipText=P,O.emphasis={scale:!1,itemStyle:{color:f},label:{show:O.label.show,color:y,fontSize:S,fontWeight:"bold"}}):O.emphasis={disabled:!0},O}).filter(p=>p!==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 Ye{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,p=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,P=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:P,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,P,w);C&&h.push(C)}if(m==="style_arrow_right"||m==="style_arrow_both"){const C=this.arrowHead(x,b,P,w);C&&h.push(C)}}return{type:"group",children:h}},data:[[0,p]],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 p=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")&&(p=u(e,[-r,-o])),[p,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,p=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]],[p+g,c+h],[p-g,c-h]]},style:{fill:s}}}}class Xe{render(t){const{seriesName:e,xAxisIndex:i,yAxisIndex:s,dataArray:a,dataIndexOffset:n}=t,l=n||0,r=[];for(let p=0;p<a.length;p++){const c=a[p];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:(p,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]),P=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=p.coordSys,S=M.x,z=M.x+M.width,T=M.y,I=M.y+M.height;C!=="none"&&([D,w]=this.extendLine(D,w,C,S,z,T,I)),v!=="none"&&([P,m]=this.extendLine(P,m,v,S,z,T,I))}const{color:_,opacity:k}=ot.parseColor(h.color||"rgba(128, 128, 128, 0.2)");g.push({type:"polygon",shape:{points:[D,w,m,P]},style:{fill:_,opacity:k},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 p=t,c=e;return(i==="right"||i==="both")&&(c=u(t,[r,o])),(i==="left"||i==="both")&&(p=u(e,[-r,-o])),[p,c]}}class qe{render(t){const{seriesName:e,xAxisIndex:i,yAxisIndex:s,dataArray:a,dataIndexOffset:n}=t,l=n||0,r=[];for(let p=0;p<a.length;p++){const c=a[p];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:(p,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",P=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}=ot.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&&P>0)if(h.curved){const C=this.buildCurvedPath(b,h.closed);g.push({type:"path",shape:{pathData:C},style:{fill:"none",stroke:w,lineWidth:P,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:P,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),p=n(r+1),c=n(r+2),g=u[0]+(p[0]-o[0])*s/3,h=u[1]+(p[1]-o[1])*s/3,f=p[0]-(c[0]-u[0])*s/3,y=p[1]-(c[1]-u[1])*s/3;a+=` C ${g} ${h}, ${f} ${y}, ${p[0]} ${p[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 Xt(d){if(!d||typeof d!="string")return d;if(d.startsWith("#")){const t=d.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 d}function Ve(d){if(!d||typeof d!="string")return null;if(d.startsWith("#")){const e=d.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=d.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?{r:+t[1],g:+t[2],b:+t[3]}:null}function Ue(d,t,e){return(.299*d+.587*t+.114*e)/255}class Ke{render(t){const{seriesName:e,xAxisIndex:i,yAxisIndex:s,dataArray:a,dataIndexOffset:n}=t,l=n||0,r=[];for(let p=0;p<a.length;p++){const c=a[p];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:(p,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],P=x[1]-y[1];const m=h.extend||"none";if(m!=="none"&&m!=="n"){const S=p.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:Xt(C)||"#2962ff";v&&g.push({type:"rect",shape:{x:b,y:D,width:w,height:P},style:{fill:v,stroke:"none"}});const _=h.border_color,k=_==null||typeof _=="number"&&isNaN(_)||_==="na"||_==="NaN"?null:Xt(_)||"#2962ff",M=h.border_width??1;if(M>0&&k&&g.push({type:"rect",shape:{x:b,y:D,width:w,height:P},style:{fill:"none",stroke:k,lineWidth:M,lineDash:this.getDashPattern(h.border_style)}}),h.text){const S=this.getTextX(b,w,h.text_halign),z=this.getTextY(D,P,h.text_valign);let T=Xt(h.text_color)||"#000000";if((!h.text_color||h.text_color==="#000000"||h.text_color==="black"||h.text_color==="color.black")&&v){const A=Ve(v);A&&Ue(A.r,A.g,A.b)<.5&&(T="#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(P),I);g.push({type:"text",style:{x:S,y:z,text:h.text,fill:T,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 p=1;for(const f of o)f.length>p&&(p=f.length);const c=l/(p*(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 Je=Object.defineProperty,Qe=(d,t,e)=>t in d?Je(d,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):d[t]=e,ti=(d,t,e)=>(Qe(d,typeof t!="symbol"?t+"":t,e),e);const V=class{static register(t,e){this.renderers.set(t,e)}static get(t){return this.renderers.get(t)||this.renderers.get("line")}};ti(V,"renderers",new Map),V.register("line",new Ze),V.register("step",new Oe),V.register("histogram",new ie),V.register("columns",new ie),V.register("circles",new Yt),V.register("cross",new Yt),V.register("char",new Yt),V.register("bar",new se),V.register("candle",new se),V.register("shape",new Re),V.register("background",new Be),V.register("fill",new ne),V.register("label",new je),V.register("drawing_line",new Ye),V.register("linefill",new Xe),V.register("drawing_polyline",new qe),V.register("drawing_box",new Ke);let ei=V;var ii=Object.defineProperty,si=(d,t,e)=>t in d?ii(d,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):d[t]=e,ni=(d,t,e)=>(si(d,typeof t!="symbol"?t+"":t,e),e);const oe=class ee{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,p=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:B.autoDetectDecimals(t);l={symbol:["none","none"],precision:g,data:[{yAxis:o,label:{show:!0,position:"end",formatter:h=>e.yAxisLabelFormatter?e.yAxisLabelFormatter(h.value):B.formatValue(h.value,g),color:"#fff",backgroundColor:p,padding:[2,4],borderRadius:2,fontSize:11,fontWeight:"bold"},lineStyle:{color:p,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),p=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",P=D.options.style==="fill";return w&&!P?1:!w&&P?-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,P=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 T=c.plots[S],I=c.plots[z];T?.options?.overlay===!0&&I?.options?.overlay===!0&&(m=!0)}}if(c.paneIndex===0||m===!0)w=0,l&&l.has(D)?P=l.get(D):P=0;else{const S=i.findIndex(z=>z.index===c.paneIndex);S!==-1&&(w=S+1,P=r+S)}const C=new Array(s).fill(null),v=new Array(s).fill(null),_=new Array(s).fill(null),k=new Array(s).fill(null);if(x.data?.forEach(S=>{const z=e.get(S.time);if(z!==void 0){const T=S.options?.offset??x.options.offset??0,I=z+a+T;if(I>=0&&I<s){let $=S.value;const A=S.options?.color;v[I]=$;const O=S.options!=null&&"color"in S.options,W=A===null||A==="na"||A==="NaN"||typeof A=="number"&&isNaN(A)||O&&A===void 0;W&&($=null),C[I]=$,_[I]=W?null:A||x.options.color||ee.DEFAULT_COLOR,k[I]=S.options||{}}}}),p.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 T=S.options?.offset??x.options.offset??0,I=z+a+T;if(I>=0&&I<s){const $=S.options?.color||x.options.color||ee.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 T=p.get(S),I=p.get(z);if(T&&I){const{color:$,opacity:A}=ot.parseColor(x.options.color||"rgba(128, 128, 128, 0.2)"),O=k.some(Z=>Z&&Z.color!==void 0),W=[];for(let Z=0;Z<s;Z++){const F=k[Z];O&&F&&F.color!==void 0?W[Z]=ot.parseColor(F.color):W[Z]={color:$,opacity:A}}const j=`${w}:${P}`;f.has(j)||f.set(j,{entries:[],xAxisIndex:w,yAxisIndex:P}),f.get(j).entries.push({plot1Data:T,plot2Data:I,barColors:W});return}}}if(x.options.color&&typeof x.options.color=="string"&&ot.parseColor(x.options.color).opacity<.01&&!_.some(S=>S==null?!1:ot.parseColor(S).opacity>=.01))return;const M=ei.get(x.options.style).render({seriesName:D,xAxisIndex:w,yAxisIndex:P,dataArray:C,colorArray:_,optionsArray:k,plotOptions:x.options,candlestickData:n,plotDataArrays:p,indicatorId:g,plotName:y,dataIndexOffset:a});M&&o.push(M)}),f.size>0){const y=new ne;f.forEach(({entries:x,xAxisIndex:b,yAxisIndex:D},w)=>{if(x.length>=2){const P=y.renderBatched(`${g}::fills_batch_${w}`,b,D,s,x);P&&o.push(P)}else if(x.length===1){const P=y.renderBatched(`${g}::fills_batch_${w}`,b,D,s,x);P&&o.push(P)}})}}),{series:o,barColors:u}}};ni(oe,"DEFAULT_COLOR","#2962ff");let wt=oe;class oi{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 p=[];if(e.controls?.collapse&&p.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;p.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),p.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}]})}p.length>0&&l.push({type:"group",right:"10.5%",top:o+"%",children:p})}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 p=[];if(u.controls?.collapse&&p.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;p.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}]})}p.length>0&&l.push({type:"group",right:"10.5%",top:u.top+"%",children:p})}),l}}class ai{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(p=>p.seriesType==="candlestick"),u=t.filter(p=>p.seriesType!=="candlestick");if(o){const[p,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 p={};u.forEach(c=>{const g=c.seriesName.split("::"),h=g.length>1?g[0]:"Unknown",f=g.length>1?g[1]:c.seriesName;p[h]||(p[h]=[]),p[h].push({...c,displayName:f})}),Object.keys(p).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
+ `,p[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 Kt=Object.defineProperty,Qt=(x,t,e)=>t in x?Kt(x,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):x[t]=e,pt=(x,t,e)=>(Qt(x,typeof t!="symbol"?t+"":t,e),e);class te{constructor(t,e){pt(this,"plugins",new Map),pt(this,"activePluginId",null),pt(this,"context"),pt(this,"toolbarContainer"),pt(this,"tooltipElement",null),pt(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 ee=Object.defineProperty,ie=(x,t,e)=>t in x?ee(x,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):x[t]=e,X=(x,t,e)=>(ie(x,typeof t!="symbol"?t+"":t,e),e);class se{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 H.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 H.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 H.graphic.Circle({shape:{cx:i.x,cy:i.y,r:5},style:{fill:"#fff",stroke:"#3b82f6",lineWidth:2},z:1e3}),this.editEndPoint=new H.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 ne=Object.defineProperty,oe=(x,t,e)=>t in x?ne(x,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):x[t]=e,ae=(x,t,e)=>(oe(x,typeof t!="symbol"?t+"":t,e),e);class re{constructor(){ae(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 J{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){J.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=J.buildTable(a);J.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}=J.safeParseColor(t.bgcolor);e.style.backgroundColor=r,l<1&&(e.style.opacity=String(l))}if(s>0&&t.frame_color){const{color:r}=J.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?J.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}=J.safeParseColor(m.bgcolor);c.style.backgroundColor=w,C<1&&(c.style.backgroundColor=m.bgcolor)}if(m.text_color){const{color:w}=J.safeParseColor(m.text_color);c.style.color=w}c.style.fontSize=J.getSizePixels(m.text_size)+"px",c.style.textAlign=J.mapHAlign(m.text_halign),c.style.verticalAlign=J.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 le=Object.defineProperty,he=(x,t,e)=>t in x?le(x,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):x[t]=e,z=(x,t,e)=>(he(x,typeof t!="symbol"?t+"":t,e),e);class ce{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 re),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=H.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 te(this,this.toolbarContainer),this.drawingEditor=new se(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=gt.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=At.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}=gt.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 zt(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();J.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=At.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=gt.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}=gt.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=Ut.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]),$=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:$?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:$?1:0}}]};if(I.type==="fibonacci"){const F=D[0],U=D[1],tt=M[0],W=M[1],et=Math.min(F,tt),ot=Math.max(F,tt),it=ot-et,G=W-U,S=[0,.236,.382,.5,.618,.786,1],L=["#787b86","#f44336","#ff9800","#4caf50","#2196f3","#00bcd4","#787b86"],N=[];N.push({type:"line",name:"line",shape:{x1:F,y1:U,x2:tt,y2:W},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:$?1:0},z:100}),N.push({type:"circle",name:"point-end",shape:{cx:tt,cy:W,r:4},style:{fill:"#fff",stroke:I.style?.color||"#3b82f6",lineWidth:1,opacity:$?1:0},z:100}),S.forEach((E,T)=>{const B=W-G*E,O=L[T%L.length];N.push({type:"line",name:"fib-line",shape:{x1:et,y1:B,x2:ot,y2:B},style:{stroke:O,lineWidth:1},silent:!0});const j=I.points[0].value,st=I.points[1].value,at=st-j,Q=st-at*E;if(N.push({type:"text",style:{text:`${E} (${Q.toFixed(2)})`,x:et+5,y:B-10,fill:O,fontSize:10},silent:!0}),T<S.length-1){const rt=S[T+1],yt=W-G*rt,wt=Math.abs(yt-B),It=Math.min(B,yt);N.push({type:"rect",shape:{x:et,y:It,width:it,height:wt},style:{fill:L[(T+1)%L.length],opacity:.1},silent:!0})}});const R=[],V=[];return S.forEach((E,T)=>{const B=W-G*E,O=L[T%L.length];V.push({type:"line",shape:{x1:et,y1:B,x2:ot,y2:B},style:{stroke:O,lineWidth:1},silent:!0});const j=I.points[0].value,st=I.points[1].value,at=st-j,Q=st-at*E;if(V.push({type:"text",style:{text:`${E} (${Q.toFixed(2)})`,x:et+5,y:B-10,fill:O,fontSize:10},silent:!0}),T<S.length-1){const rt=S[T+1],yt=W-G*rt,wt=Math.abs(yt-B),It=Math.min(B,yt);R.push({type:"rect",name:"line",shape:{x:et,y:It,width:it,height:wt},style:{fill:L[(T+1)%L.length],opacity:.1}})}}),{type:"group",children:[...R,...V,{type:"line",name:"line",shape:{x1:F,y1:U,x2:tt,y2:W},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:$?1:0},z:100},{type:"circle",name:"point-end",shape:{cx:tt,cy:W,r:4},style:{fill:"#fff",stroke:I.style?.color||"#3b82f6",lineWidth:1,opacity:$?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=Jt.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 de=Object.defineProperty,pe=(x,t,e)=>t in x?de(x,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):x[t]=e,ft=(x,t,e)=>(pe(x,typeof t!="symbol"?t+"":t,e),e);class xt{constructor(t){ft(this,"id"),ft(this,"name"),ft(this,"icon"),ft(this,"context"),ft(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 ue=Object.defineProperty,fe=(x,t,e)=>t in x?ue(x,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):x[t]=e,q=(x,t,e)=>(fe(x,typeof t!="symbol"?t+"":t,e),e);class ye extends xt{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=[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())}),q(this,"clearHandlers",{}),q(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 H.graphic.Group,this.rect=new H.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 H.graphic.Line({shape:{x1:0,y1:0,x2:0,y2:0},style:{stroke:"#fff",lineWidth:1,lineDash:[4,4]},z:101}),this.lineH=new H.graphic.Line({shape:{x1:0,y1:0,x2:0,y2:0},style:{stroke:"#fff",lineWidth:1,lineDash:[4,4]},z:101}),this.arrowStart=new H.graphic.Polygon({shape:{points:[[0,0],[-5,10],[5,10]]},style:{fill:"#fff"},z:102}),this.arrowEnd=new H.graphic.Polygon({shape:{points:[[0,0],[-5,-10],[5,-10]]},style:{fill:"#fff"},z:102}),this.labelRect=new H.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 H.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 ge=Object.defineProperty,xe=(x,t,e)=>t in x?ge(x,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):x[t]=e,K=(x,t,e)=>(xe(x,typeof t!="symbol"?t+"":t,e),e);class me extends xt{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 H.graphic.Group,this.line=new H.graphic.Line({shape:{x1:0,y1:0,x2:0,y2:0},style:{stroke:"#3b82f6",lineWidth:2},z:100}),this.startCircle=new H.graphic.Circle({shape:{cx:0,cy:0,r:4},style:{fill:"#fff",stroke:"#3b82f6",lineWidth:1},z:101}),this.endCircle=new H.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 be=Object.defineProperty,ve=(x,t,e)=>t in x?be(x,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):x[t]=e,lt=(x,t,e)=>(ve(x,typeof t!="symbol"?t+"":t,e),e);class we extends xt{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>'}),lt(this,"startPoint",null),lt(this,"endPoint",null),lt(this,"state","idle"),lt(this,"graphicGroup",null),lt(this,"levels",[0,.236,.382,.5,.618,.786,1]),lt(this,"colors",["#787b86","#f44336","#ff9800","#4caf50","#2196f3","#00bcd4","#787b86"]),lt(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())}),lt(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 H.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 H.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 H.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 H.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}})}}}nt.AbstractPlugin=xt,nt.FibonacciTool=we,nt.LineTool=me,nt.MeasureTool=ye,nt.QFChart=ce});
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 ri=Object.defineProperty,li=(d,t,e)=>t in d?ri(d,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):d[t]=e,Ct=(d,t,e)=>(li(d,typeof t!="symbol"?t+"":t,e),e);class hi{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 ci=Object.defineProperty,di=(d,t,e)=>t in d?ci(d,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):d[t]=e,et=(d,t,e)=>(di(d,typeof t!="symbol"?t+"":t,e),e);class pi{constructor(t){et(this,"context"),et(this,"isEditing",!1),et(this,"currentDrawing",null),et(this,"editingPointIndex",null),et(this,"zr"),et(this,"editGroup",null),et(this,"editLines",[]),et(this,"editPoints",[]),et(this,"isMovingShape",!1),et(this,"dragStart",null),et(this,"initialPixelPoints",[]),et(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))}),et(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))}),et(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})}}),et(this,"onMouseUp",e=>{this.isEditing&&this.finishEditing(e.offsetX,e.offsetY)}),et(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 ui=Object.defineProperty,gi=(d,t,e)=>t in d?ui(d,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):d[t]=e,fi=(d,t,e)=>(gi(d,typeof t!="symbol"?t+"":t,e),e);class ae{constructor(){fi(this,"renderers",new Map)}register(t){this.renderers.set(t.type,t)}get(t){return this.renderers.get(t)}}var yi=Object.defineProperty,xi=(d,t,e)=>t in d?yi(d,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):d[t]=e,mi=(d,t,e)=>(xi(d,typeof t!="symbol"?t+"":t,e),e);class bi{constructor(){mi(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,p=t.columns||0;for(let c=0;c<u;c++){const g=document.createElement("tr");for(let h=0;h<p;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:P}=st.safeParseColor(b.bgcolor);y.style.backgroundColor=w,P<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 A=I.startCol;A<=I.endCol;A++)$===I.startRow&&A===I.startCol||u.add(`${A},${$}`)}const p=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 A=t.cells?.[I]?.[$],O=o.get(`${$},${I}`),W=O?.colspan??1,j=O?.rowspan??1,Z=A&&!A._merged&&A.text||"",F=Z?Z.split(`
38
+ `):[],U=A?K.getSizePixels(A.text_size):12,H=A?.text_font_family==="monospace"?"monospace":"sans-serif";let X=0,ht=0;A?.width>0&&(X=Math.max(1,A.width*e.width/100)),A?.height>0&&(ht=Math.max(1,A.height*e.height/100));const dt=ht>0&&ht<4,te=dt?0:p,Pt=dt?0:c,Ht=A&&!A._merged&&A.bgcolor&&typeof A.bgcolor=="string"&&A.bgcolor.length>0?A.bgcolor:"",Rt=A?.text_color||"";h[I][$]={text:Z,lines:F,fontSize:U,fontFamily:H,textColor:Rt?K.parseColor(Rt):{color:"#e0e0e0",opacity:1},bgColor:Ht?K.parseColor(Ht):{color:"",opacity:0},halign:A?K.mapHAlign(A.text_halign):"center",valign:A?K.mapVAlign(A.text_valign):"middle",explicitWidth:X,explicitHeight:ht,colspan:W,rowspan:j,skip:!1,padX:te,padY:Pt}}}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 A=h[I][$];if(A.skip||A.colspan>1||A.rowspan>1)continue;const O=K.measureMultiLineWidth(A.lines,A.fontSize,A.fontFamily),W=Math.max(A.lines.length,1),j=A.explicitWidth>0?A.explicitWidth:O+A.padX*2,Z=A.explicitHeight>0?A.explicitHeight:W*A.fontSize*g+A.padY*2;f[$]=Math.max(f[$],j),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 A=h[I][$];if(A.skip)continue;const O=Math.max(A.lines.length,1),W=A.explicitHeight>0?A.explicitHeight:O*A.fontSize*g+A.padY*2;if(A.colspan>1){const j=K.sumRange(f,$,A.colspan),Z=K.measureMultiLineWidth(A.lines,A.fontSize,A.fontFamily),F=A.explicitWidth>0?A.explicitWidth:Z+A.padX*2;if(F>j){const U=(F-j)/A.colspan;for(let H=0;H<A.colspan;H++)f[$+H]+=U}A.rowspan===1&&(y[I]=Math.max(y[I],W))}if(A.rowspan>1){const j=K.sumRange(y,I,A.rowspan);if(W>j){const Z=(W-j)/A.rowspan;for(let F=0;F<A.rowspan;F++)y[I+F]+=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,P=b[i]+D*2,m=Math.min(w,e.width),C=Math.min(P,e.height),v=K.computePosition(t.position,e,m,C),_=Math.round(v.x),k=Math.round(v.y),M=[],S=_+D,z=k+D;if(t.bgcolor){const{color:I,opacity:$}=K.parseColor(t.bgcolor);$>0&&M.push({type:"rect",shape:{x:_,y:k,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:k+$,width:m-n,height:C-n},style:{fill:"none",stroke:I,lineWidth:n},silent:!0,z:0,z2:1})}const T=l?K.parseColor(t.border_color).color:"";for(let I=0;I<i;I++)for(let $=0;$<s;$++){const A=h[I][$];if(A.skip)continue;const O=S+x[$],W=z+b[I],j=K.sumRange(f,$,A.colspan),Z=K.sumRange(y,I,A.rowspan);if(O-_>=m||W-k>=C)continue;const F=Math.min(j,m-(O-_)),U=Math.min(Z,C-(W-k));if(A.bgColor.opacity>0&&M.push({type:"rect",shape:{x:O,y:W,width:F,height:U},style:{fill:A.bgColor.color,opacity:A.bgColor.opacity},silent:!0,z:0,z2:2}),l&&M.push({type:"rect",shape:{x:O,y:W,width:F,height:U},style:{fill:"none",stroke:T,lineWidth:a},silent:!0,z:0,z2:3}),A.text){let H,X;switch(A.halign){case"left":H=O+A.padX,X="left";break;case"right":H=O+F-A.padX,X="right";break;default:H=O+F/2,X="center";break}let ht,dt;switch(A.valign){case"top":ht=W+A.padY,dt="top";break;case"bottom":ht=W+U-A.padY,dt="bottom";break;default:ht=W+U/2,dt="middle";break}M.push({type:"text",x:H,y:ht,style:{text:A.text,fill:A.textColor.color,opacity:A.textColor.opacity,font:`${A.fontSize}px ${A.fontFamily}`,textAlign:X,textVerticalAlign:dt,lineHeight:Math.round(A.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 vi=Object.defineProperty,wi=(d,t,e)=>t in d?vi(d,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):d[t]=e,L=(d,t,e)=>(wi(d,typeof t!="symbol"?t+"":t,e),e);class Ci{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 bi),L(this,"isMainCollapsed",!1),L(this,"maximizedPaneId",null),L(this,"countdownInterval",null),L(this,"selectedDrawingId",null),L(this,"drawings",[]),L(this,"drawingRenderers",new ae),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 hi(this,this.toolbarContainer),this.drawingEditor=new pi(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,p=this._paneDragState.startBelowHeight-l;if(u<r&&(u=r,p=this._paneDragState.startAboveHeight+this._paneDragState.startBelowHeight-r),p<o&&(p=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=p),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 p=this.chart.convertToPixel({gridIndex:i},[s+this.dataIndexOffset,o]);return{x:l,y:p?p[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=Bt.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:p,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},...p]};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")}`,p=this.chart.getOption();if(!p||!p.series)return;const c=p.series.findIndex(b=>b.type==="candlestick");if(c===-1)return;const g=p.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:B.autoDetectDecimals(this.marketData);y=B.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 Fe(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(k=>k.type==="slider"||k.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,p={value:[NaN,NaN,NaN,NaN],itemStyle:{opacity:0}},c=wt.buildCandlestickSeries(this.marketData,this.options),g=[...Array(u).fill(p),...c.data,...Array(u).fill(p)],h=[...Array(u).fill(""),...this.marketData.map(k=>new Date(k.time).toLocaleString()),...Array(u).fill("")],f=[...Array(u).fill(null),...this.marketData,...Array(u).fill(null)],y=Bt.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((k,M)=>b[M]?{value:k.value||k,itemStyle:{color:b[M],color0:b[M]}}:k),w=this.marketData.length+2*t,P=Math.max(0,(l+o)/w*100),m=Math.min(100,(r+o)/w*100),C=[],v=new Map;this.drawings.forEach(k=>{const M=k.paneIndex||0;v.has(M)||v.set(M,[]),v.get(M).push(k)}),v.forEach(k=>{C.push({data:k.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:P,end:m},{start:P,end:m}],series:[{data:D,markLine:c.markLine},...x.map(k=>{const M={data:k.data};return k.renderItem&&(M.renderItem=k.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,p=n>s-this.LAZY_EDGE_THRESHOLD;if((u||p)&&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=Bt.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(k=>{if(k.start!==void 0){const M=k.start/100,S=v+M*_;k.start=S*100}if(k.end!==void 0){const M=k.end/100,S=v+M*_;k.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),p={value:[NaN,NaN,NaN,NaN],itemStyle:{opacity:0}};u.data=[...Array(l).fill(p),...u.data,...Array(l).fill(p)];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=oi.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 k=m[v.dataIndex];if(!k)return;const M=this.drawingRenderers.get(k.type);if(!M)return;const S=this.dataIndexOffset,z=k.points.map(T=>_.coord([T.timeIndex+S,T.value]));return M.render({drawing:k,pixelPoints:z,isSelected:k.id===this.selectedDrawingId,api:_})},data:m.map(v=>{const _=[];return v.points.forEach(k=>{_.push(k.timeIndex+this.dataIndexOffset,k.value)}),_}),encode:(()=>{const v=m.reduce((M,S)=>Math.max(M,S.points.length),0),_=Array.from({length:v},(M,S)=>S*2),k=Array.from({length:v},(M,S)=>S*2+1);return{x:_,y:k}})(),z:100,silent:!1})});const D=m=>{const C=ai.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 P={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,_,k)=>{if(this.options.databox?.position==="floating"){const M={top:10};return M[["left","right"][+(m[0]<k.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(P,!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 Ii=Object.defineProperty,_i=(d,t,e)=>t in d?Ii(d,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):d[t]=e,lt=(d,t,e)=>(_i(d,typeof t!="symbol"?t+"":t,e),e);class nt{constructor(t){lt(this,"id"),lt(this,"name"),lt(this,"icon"),lt(this,"context"),lt(this,"eventListeners",[]),lt(this,"_snapIndicator",null),lt(this,"_snapMoveHandler",null),lt(this,"_snapKeyDownHandler",null),lt(this,"_snapKeyUpHandler",null),lt(this,"_snapBlurHandler",null),lt(this,"_snapActive",!1),lt(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 Pi=Object.defineProperty,Ai=(d,t,e)=>t in d?Pi(d,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):d[t]=e,Q=(d,t,e)=>(Ai(d,typeof t!="symbol"?t+"":t,e),e);class ki extends nt{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,p=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 P=[`${c.toFixed(2)} (${g.toFixed(2)}%)`,`${p} bars`].join(`
40
+ `),m=140,C=40,v=Math.max(e,s),_=Math.min(e,s);let k=(t+i)/2-m/2,M=v+10;const S=this.chart.getHeight();M+C>S&&(M=_-C-10),this.labelRect.setShape({x:k,y:M,width:m,height:C}),this.labelRect.setStyle({fill:"#1e293b",stroke:y,lineWidth:1}),this.labelText.setStyle({x:k+m/2,y:M+C/2,text:P,fill:"#fff"})}}var Di=Object.defineProperty,Mi=(d,t,e)=>t in d?Di(d,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):d[t]=e,Si=(d,t,e)=>(Mi(d,typeof t!="symbol"?t+"":t,e),e);class re{constructor(){Si(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 Gi=Object.defineProperty,$i=(d,t,e)=>t in d?Gi(d,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):d[t]=e,ct=(d,t,e)=>($i(d,typeof t!="symbol"?t+"":t,e),e);class zi extends nt{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 re)}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 Ei=Object.defineProperty,Li=(d,t,e)=>t in d?Ei(d,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):d[t]=e,Ti=(d,t,e)=>(Li(d,typeof t!="symbol"?t+"":t,e),e);const qt=[0,.236,.382,.5,.618,.786,1],Wt=["#787b86","#f44336","#ff9800","#4caf50","#2196f3","#00bcd4","#787b86"];class le{constructor(){Ti(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),p=Math.max(a,l),c=p-u,g=r-n,h=e.points[0].value,f=e.points[1].value,y=f-h,x=[],b=[];return qt.forEach((D,w)=>{const P=r-g*D,m=Wt[w%Wt.length];b.push({type:"line",shape:{x1:u,y1:P,x2:p,y2:P},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:P-10,fill:m,fontSize:10},silent:!0}),w<qt.length-1){const v=qt[w+1],_=r-g*v,k=Math.abs(_-P),M=Math.min(P,_);x.push({type:"rect",name:"line",shape:{x:u,y:M,width:c,height:k},style:{fill:Wt[(w+1)%Wt.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 Wi=Object.defineProperty,Ni=(d,t,e)=>t in d?Wi(d,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):d[t]=e,ft=(d,t,e)=>(Ni(d,typeof t!="symbol"?t+"":t,e),e);class Fi extends nt{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>'}),ft(this,"startPoint",null),ft(this,"endPoint",null),ft(this,"state","idle"),ft(this,"graphicGroup",null),ft(this,"levels",[0,.236,.382,.5,.618,.786,1]),ft(this,"colors",["#787b86","#f44336","#ff9800","#4caf50","#2196f3","#00bcd4","#787b86"]),ft(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())}),ft(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=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,p)=>{const c=s-o*u,g=this.colors[p%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),p<this.levels.length-1){const f=this.levels[p+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[(p+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 Zi=Object.defineProperty,Oi=(d,t,e)=>t in d?Zi(d,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):d[t]=e,Hi=(d,t,e)=>(Oi(d,typeof t!="symbol"?t+"":t,e),e);const Nt=[0,.236,.382,.5,.618,.786,1],Ft=["#787b86","#f44336","#ff9800","#4caf50","#2196f3","#00bcd4","#787b86"];class he{constructor(){Hi(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],p=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,P)=>{const m=f*x*w,C=y*x*w,v=a+m,_=n+C,k=l+m,M=r+C;if(D.push({lx1:v,ly1:_,lx2:k,ly2:M}),P<Nt.length-1){const S=Nt[P+1],z=f*x*S,T=y*x*S;b.push({type:"polygon",name:"line",shape:{points:[[v,_],[k,M],[l+z,r+T],[a+z,n+T]]},style:{fill:Ft[(P+1)%Ft.length],opacity:.1}})}}),D.forEach((w,P)=>{const m=Ft[P%Ft.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[P]}`,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:p,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:p,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:p,lineWidth:1,opacity:s?1:0},z:100}),{type:"group",children:b}}}var Ri=Object.defineProperty,Bi=(d,t,e)=>t in d?Ri(d,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):d[t]=e,pt=(d,t,e)=>(Bi(d,typeof t!="symbol"?t+"":t,e),e);class ji extends nt{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>'}),pt(this,"startPoint",null),pt(this,"endPoint",null),pt(this,"widthPoint",null),pt(this,"state","idle"),pt(this,"graphicGroup",null),pt(this,"levels",[0,.236,.382,.5,.618,.786,1]),pt(this,"colors",["#787b86","#f44336","#ff9800","#4caf50","#2196f3","#00bcd4","#787b86"]),pt(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())}),pt(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 he)}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,p=(a[0]-t)*o+(a[1]-e)*u;this.levels.forEach((c,g)=>{const h=o*p*c,f=u*p*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 P=this.levels[g+1],m=o*p*P,C=u*p*P,v=t+m,_=e+C,k=i+m,M=s+C;this.graphicGroup.add(new G.graphic.Polygon({shape:{points:[[y,x],[b,D],[k,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 Yi=Object.defineProperty,Xi=(d,t,e)=>t in d?Yi(d,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):d[t]=e,qi=(d,t,e)=>(Xi(d,typeof t!="symbol"?t+"":t,e),e);const Vt=[0,.236,.382,.5,.618,.786,1],yt=["#787b86","#f44336","#ff9800","#4caf50","#2196f3","#00bcd4","#787b86"];class ce{constructor(){qi(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,p=r-n,c=[],g=[],h=[];for(const f of Vt)g.push([a+u,n+p*f]),h.push([a+u*f,n+p]);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:yt[(f+1)%yt.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:yt[(f+1)%yt.length],opacity:.06}});return Vt.forEach((f,y)=>{const[x,b]=g[y],D=yt[y%yt.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=yt[y%yt.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 Vi=Object.defineProperty,Ui=(d,t,e)=>t in d?Vi(d,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):d[t]=e,It=(d,t,e)=>(Ui(d,typeof t!="symbol"?t+"":t,e),e);const mt=[0,.236,.382,.5,.618,.786,1],_t=["#787b86","#f44336","#ff9800","#4caf50","#2196f3","#00bcd4","#787b86"];class Ki extends nt{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 ce)}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;mt.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<mt.length-1;l++){const r=[t+a,e+n*mt[l]],o=[t+a,e+n*mt[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<mt.length-1;l++){const r=[t+a*mt[l],e+n],o=[t+a*mt[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 Ji=Object.defineProperty,Qi=(d,t,e)=>t in d?Ji(d,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):d[t]=e,ts=(d,t,e)=>(Qi(d,typeof t!="symbol"?t+"":t,e),e);const de=[0,.236,.382,.5,.618,.786,1,1.272,1.618,2,2.618],pe=["#787b86","#f44336","#ff9800","#4caf50","#2196f3","#00bcd4","#787b86","#e91e63","#9c27b0","#673ab7","#3f51b5"];class ue{constructor(){ts(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],[p,c]=i[2],g=e.points,h=g[1].value-g[0].value,f=Math.min(l,o,p),y=Math.max(l,o,p),x=(y-f)*.5,b=f,D=y+x,w=[],P=[];for(let v=0;v<de.length;v++){const _=de[v],k=g[2].value+h*_;a.coord([g[2].timeIndex+t.drawing.points[2].timeIndex-g[2].timeIndex,k]);const M=c+(u-r)*_;P.push({level:_,y:M,price:k,color:pe[v%pe.length]})}for(let v=0;v<P.length-1;v++){const _=P[v],k=P[v+1],M=Math.min(_.y,k.y),S=Math.abs(k.y-_.y);w.push({type:"rect",name:"line",shape:{x:b,y:M,width:D-b,height:S},style:{fill:k.color,opacity:.06}})}for(const v of P)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:p,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:p,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[_,k]=C[v],M=(v===0||k<=C[v-1][1])&&(v===2||k<=C[v+1]?.[1]);w.push({type:"text",style:{text:m[v],x:_,y:M?k-14:k+16,fill:"#e2e8f0",fontSize:12,fontWeight:"bold",align:"center",verticalAlign:"middle"},silent:!0})}return{type:"group",children:w}}}var es=Object.defineProperty,is=(d,t,e)=>t in d?es(d,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):d[t]=e,kt=(d,t,e)=>(is(d,typeof t!="symbol"?t+"":t,e),e);const Zt=[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 ss extends nt{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>'}),kt(this,"points",[]),kt(this,"state","idle"),kt(this,"graphicGroup",null),kt(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())}),kt(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 ue)}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,p=r,c=o+u;for(let g=0;g<Zt.length;g++){const h=Zt[g],f=n+l*h,y=Ot[g%Ot.length];if(this.graphicGroup.add(new G.graphic.Line({shape:{x1:p,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<Zt.length-1){const x=n+l*Zt[g+1],b=Math.min(f,x),D=Math.abs(x-f);this.graphicGroup.add(new G.graphic.Rect({shape:{x:p,y:b,width:c-p,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 ns=Object.defineProperty,os=(d,t,e)=>t in d?ns(d,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):d[t]=e,as=(d,t,e)=>(os(d,typeof t!="symbol"?t+"":t,e),e);const ge=["X","A","B","C","D"],fe=["#2196f3","#ff9800","#4caf50","#f44336"],rs="rgba(33, 150, 243, 0.08)",ls="rgba(244, 67, 54, 0.08)";class ye{constructor(){as(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:rs,opacity:1}}),i.length>=5&&n.push({type:"polygon",name:"line",shape:{points:i.slice(2,5).map(([r,o])=>[r,o])},style:{fill:ls,opacity:1}});for(let r=0;r<i.length-1;r++){const[o,u]=i[r],[p,c]=i[r+1],g=fe[r%fe.length];n.push({type:"line",name:"line",shape:{x1:o,y1:u,x2:p,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,p]=i[r],[c,g]=i[o];n.push({type:"line",shape:{x1:u,y1:p,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),p=(i[1][0]+i[2][0])/2,c=(i[1][1]+i[2][1])/2;n.push({type:"text",style:{text:u,x:p+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),p=(i[2][0]+i[3][0])/2,c=(i[2][1]+i[3][1])/2;n.push({type:"text",style:{text:u,x:p+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),p=Math.abs(e.points[4].value-e.points[1].value);if(u!==0){const c=(p/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<ge.length;r++){const[o,u]=i[r],p=(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:ge[r],x:o,y:p,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 hs=Object.defineProperty,cs=(d,t,e)=>t in d?hs(d,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):d[t]=e,Dt=(d,t,e)=>(cs(d,typeof t!="symbol"?t+"":t,e),e);const xe=["X","A","B","C","D"],me=["#2196f3","#ff9800","#4caf50","#f44336"],ds=5;class ps extends nt{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>'}),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",this.points=[i,[...i]],this.initGraphic(),this.updateGraphic()):this.state==="drawing"&&(this.points[this.points.length-1]=i,this.points.length>=ds?(this.state="finished",this.updateGraphic(),this.saveDrawing(),this.removeGraphic(),this.context.disableTools()):(this.points.push([...i]),this.updateGraphic()))}),Dt(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 ye)}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:me[i%me.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<xe.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:xe[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 us=Object.defineProperty,gs=(d,t,e)=>t in d?us(d,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):d[t]=e,fs=(d,t,e)=>(gs(d,typeof t!="symbol"?t+"":t,e),e);const be=["A","B","C","D"],ve=["#2196f3","#ff9800","#4caf50"];class we{constructor(){fs(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,p]=i[l+1];n.push({type:"line",name:"line",shape:{x1:r,y1:o,x2:u,y2:p},style:{stroke:ve[l%ve.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,p=(i[1][1]+i[2][1])/2;n.push({type:"text",style:{text:o,x:u+8,y:p,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,p=(i[2][1]+i[3][1])/2;n.push({type:"text",style:{text:o,x:u+8,y:p,fill:"#4caf50",fontSize:10},silent:!0})}}for(let l=0;l<i.length&&l<be.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:be[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 ys=Object.defineProperty,xs=(d,t,e)=>t in d?ys(d,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):d[t]=e,Mt=(d,t,e)=>(xs(d,typeof t!="symbol"?t+"":t,e),e);const Ce=["A","B","C","D"],Ie=["#2196f3","#ff9800","#4caf50"],ms=4;class bs extends nt{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>'}),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>=ms?(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 we)}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:Ie[e%Ie.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<Ce.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:Ce[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 vs=Object.defineProperty,ws=(d,t,e)=>t in d?vs(d,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):d[t]=e,Cs=(d,t,e)=>(ws(d,typeof t!="symbol"?t+"":t,e),e);const _e=["X","A","B","C","D"],Pe=["#00bcd4","#e91e63","#8bc34a","#ff5722"];class Ae{constructor(){Cs(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,p]=i[o],[c,g]=i[o+1];n.push({type:"line",name:"line",shape:{x1:u,y1:p,x2:c,y2:g},style:{stroke:Pe[o%Pe.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 p=(u/o).toFixed(3);n.push({type:"text",style:{text:p,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 p=(u/o).toFixed(3);n.push({type:"text",style:{text:`XC/XA: ${p}`,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 p=(u/o).toFixed(3);n.push({type:"text",style:{text:p,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<_e.length;o++){const[u,p]=i[o],c=(o===0||p<=i[o-1][1])&&(o===i.length-1||p<=i[o+1]?.[1]);n.push({type:"text",style:{text:_e[o],x:u,y:c?p-14:p+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 Is=Object.defineProperty,_s=(d,t,e)=>t in d?Is(d,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):d[t]=e,St=(d,t,e)=>(_s(d,typeof t!="symbol"?t+"":t,e),e);const ke=["X","A","B","C","D"],De=["#00bcd4","#e91e63","#8bc34a","#ff5722"],Ps=5;class As extends nt{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>'}),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>=Ps?(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 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(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:De[e%De.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 ks=Object.defineProperty,Ds=(d,t,e)=>t in d?ks(d,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):d[t]=e,Ms=(d,t,e)=>(Ds(d,typeof t!="symbol"?t+"":t,e),e);const Ut=["","LS","","H","","RS",""];class Me{constructor(){Ms(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,p]=i[l+1];n.push({type:"line",name:"line",shape:{x1:r,y1:o,x2:u,y2:p},style:{stroke:"#2196f3",lineWidth:e.style?.lineWidth||2}})}if(i.length>=5){const[l,r]=i[2],[o,u]=i[4],p=o-l,c=u-r,g=.3,h=.3,f=l-p*g,y=r-c*g,x=o+p*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<Ut.length;l++){if(!Ut[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:Ut[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 Ss=Object.defineProperty,Gs=(d,t,e)=>t in d?Ss(d,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):d[t]=e,Gt=(d,t,e)=>(Gs(d,typeof t!="symbol"?t+"":t,e),e);const Kt=["","LS","","H","","RS",""],$s=7;class zs extends nt{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>'}),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>=$s?(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 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.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<Kt.length;e++){const[i,s]=t[e],a=(e===0||s<=t[e-1][1])&&(e===t.length-1||s<=t[e+1]?.[1]);Kt[e]&&this.graphicGroup.add(new G.graphic.Text({style:{text:Kt[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 Es=Object.defineProperty,Ls=(d,t,e)=>t in d?Es(d,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):d[t]=e,Ts=(d,t,e)=>(Ls(d,typeof t!="symbol"?t+"":t,e),e);const Se=["1","2","3","4","5"];class Ge{constructor(){Ts(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],p=o[0]-u[0],c=o[1]-u[1];if(p!==0){const g=o[0]+p*.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],p=o[0]-u[0],c=o[1]-u[1];if(p!==0){const g=o[0]+p*.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<Se.length;o++){const[u,p]=i[o],c=o%2===0;n.push({type:"text",style:{text:Se[o],x:u,y:c?p-14:p+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 Ws=Object.defineProperty,Ns=(d,t,e)=>t in d?Ws(d,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):d[t]=e,$t=(d,t,e)=>(Ns(d,typeof t!="symbol"?t+"":t,e),e);const $e=["1","2","3","4","5"],Fs=5;class Zs extends nt{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>'}),$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>=Fs?(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 Ge)}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<$e.length;s++){const[a,n]=t[s],l=s%2===0;this.graphicGroup.add(new G.graphic.Text({style:{text:$e[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 Os=Object.defineProperty,Hs=(d,t,e)=>t in d?Os(d,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):d[t]=e,Rs=(d,t,e)=>(Hs(d,typeof t!="symbol"?t+"":t,e),e);const Jt=["0","D1","C1","D2","C2","D3",""],ze=["#2196f3","#ff9800","#4caf50","#f44336","#00bcd4","#e91e63"];class Ee{constructor(){Rs(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,p]=i[o],[c,g]=i[o+1];n.push({type:"line",name:"line",shape:{x1:u,y1:p,x2:c,y2:g},style:{stroke:ze[o%ze.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 p=(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: ${p}`,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 p=(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: ${p}`,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 p=(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:p,x:c+8,y:g,fill:"#ff9800",fontSize:10},silent:!0})}}for(let o=0;o<i.length&&o<Jt.length;o++){if(!Jt[o])continue;const[u,p]=i[o],c=(o===0||p<=i[o-1][1])&&(o===i.length-1||p<=i[o+1]?.[1]);n.push({type:"text",style:{text:Jt[o],x:u,y:c?p-14:p+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 Bs=Object.defineProperty,js=(d,t,e)=>t in d?Bs(d,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):d[t]=e,zt=(d,t,e)=>(js(d,typeof t!="symbol"?t+"":t,e),e);const Qt=["0","D1","C1","D2","C2","D3",""],Le=["#2196f3","#ff9800","#4caf50","#f44336","#00bcd4","#e91e63"],Ys=7;class Xs extends nt{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>'}),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>=Ys?(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 Ee)}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:Le[i%Le.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<Qt.length;i++){const[s,a]=t[i],n=(i===0||a<=t[i-1][1])&&(i===t.length-1||a<=t[i+1]?.[1]);Qt[i]&&this.graphicGroup.add(new G.graphic.Text({style:{text:Qt[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 qs=Object.defineProperty,Vs=(d,t,e)=>t in d?qs(d,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):d[t]=e,bt=(d,t,e)=>(Vs(d,typeof t!="symbol"?t+"":t,e),e);class Us extends nt{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}),bt(this,"plugins",[]),bt(this,"activeSubPlugin",null),bt(this,"menuElement",null),bt(this,"buttonElement",null),bt(this,"originalIcon",""),bt(this,"arrowSvg",""),bt(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}}}N.ABCDPatternDrawingRenderer=we,N.ABCDPatternTool=bs,N.AbstractPlugin=nt,N.CypherPatternDrawingRenderer=Ae,N.CypherPatternTool=As,N.DrawingRendererRegistry=ae,N.FibSpeedResistanceFanDrawingRenderer=ce,N.FibSpeedResistanceFanTool=Ki,N.FibTrendExtensionDrawingRenderer=ue,N.FibTrendExtensionTool=ss,N.FibonacciChannelDrawingRenderer=he,N.FibonacciChannelTool=ji,N.FibonacciDrawingRenderer=le,N.FibonacciTool=Fi,N.HeadAndShouldersDrawingRenderer=Me,N.HeadAndShouldersTool=zs,N.LineDrawingRenderer=re,N.LineTool=zi,N.MeasureTool=ki,N.QFChart=Ci,N.ThreeDrivesPatternDrawingRenderer=Ee,N.ThreeDrivesPatternTool=Xs,N.ToolGroup=Us,N.TrianglePatternDrawingRenderer=Ge,N.TrianglePatternTool=Zs,N.XABCDPatternDrawingRenderer=ye,N.XABCDPatternTool=ps});