@qfo/qfchart 0.8.1 → 0.8.2

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 (34) hide show
  1. package/dist/index.d.ts +206 -1
  2. package/dist/qfchart.min.browser.js +16 -16
  3. package/dist/qfchart.min.es.js +16 -16
  4. package/package.json +1 -1
  5. package/src/QFChart.ts +11 -10
  6. package/src/components/LayoutManager.ts +51 -17
  7. package/src/index.ts +8 -0
  8. package/src/plugins/CrossLineTool/CrossLineDrawingRenderer.ts +49 -0
  9. package/src/plugins/CrossLineTool/CrossLineTool.ts +52 -0
  10. package/src/plugins/CrossLineTool/index.ts +2 -0
  11. package/src/plugins/ExtendedLineTool/ExtendedLineDrawingRenderer.ts +73 -0
  12. package/src/plugins/ExtendedLineTool/ExtendedLineTool.ts +173 -0
  13. package/src/plugins/ExtendedLineTool/index.ts +2 -0
  14. package/src/plugins/HorizontalLineTool/HorizontalLineDrawingRenderer.ts +54 -0
  15. package/src/plugins/HorizontalLineTool/HorizontalLineTool.ts +52 -0
  16. package/src/plugins/HorizontalLineTool/index.ts +2 -0
  17. package/src/plugins/HorizontalRayTool/HorizontalRayDrawingRenderer.ts +34 -0
  18. package/src/plugins/HorizontalRayTool/HorizontalRayTool.ts +52 -0
  19. package/src/plugins/HorizontalRayTool/index.ts +2 -0
  20. package/src/plugins/InfoLineTool/InfoLineDrawingRenderer.ts +72 -0
  21. package/src/plugins/InfoLineTool/InfoLineTool.ts +130 -0
  22. package/src/plugins/InfoLineTool/index.ts +2 -0
  23. package/src/plugins/LineTool/LineDrawingRenderer.ts +2 -2
  24. package/src/plugins/LineTool/LineTool.ts +5 -5
  25. package/src/plugins/RayTool/RayDrawingRenderer.ts +69 -0
  26. package/src/plugins/RayTool/RayTool.ts +162 -0
  27. package/src/plugins/RayTool/index.ts +2 -0
  28. package/src/plugins/TrendAngleTool/TrendAngleDrawingRenderer.ts +87 -0
  29. package/src/plugins/TrendAngleTool/TrendAngleTool.ts +176 -0
  30. package/src/plugins/TrendAngleTool/index.ts +2 -0
  31. package/src/plugins/VerticalLineTool/VerticalLineDrawingRenderer.ts +35 -0
  32. package/src/plugins/VerticalLineTool/VerticalLineTool.ts +52 -0
  33. package/src/plugins/VerticalLineTool/index.ts +2 -0
  34. package/src/types.ts +2 -0
@@ -14,30 +14,30 @@
14
14
  * See the License for the specific language governing permissions and
15
15
  * limitations under the License.
16
16
  */
17
- import*as G from"echarts";var Ee=Object.defineProperty,Le=(p,t,e)=>t in p?Ee(p,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):p[t]=e,yt=(p,t,e)=>(Le(p,typeof t!="symbol"?t+"":t,e),e);class We{constructor(t,e,i,s={}){yt(this,"id"),yt(this,"plots"),yt(this,"paneIndex"),yt(this,"height"),yt(this,"collapsed"),yt(this,"titleColor"),yt(this,"controls"),this.id=t,this.plots=e,this.paneIndex=i,this.height=s.height,this.collapsed=s.collapsed||!1,this.titleColor=s.titleColor,this.controls=s.controls}toggleCollapse(){this.collapsed=!this.collapsed}isVisible(){return!this.collapsed}updateData(t){Object.keys(t).forEach(e=>{if(!this.plots[e])this.plots[e]=t[e];else{const i=this.plots[e],s=t[e];if(!i.data)return;s.options&&(i.options={...i.options,...s.options});const a=new Map;i.data?.forEach(n=>{a.set(n.time,n)}),s.data?.forEach(n=>{a.set(n.time,n)}),i.data=Array.from(a.values()).sort((n,l)=>n.time-l.time)}})}}class R{static createMinFunction(t){return e=>{const i=(e.max-e.min)*(t/100);return e.min-i}}static createMaxFunction(t){return e=>{const i=(e.max-e.min)*(t/100);return e.max+i}}static autoDetectDecimals(t){if(!t||t.length===0)return 2;const e=t[t.length-1].close;if(e===0||!isFinite(e)||isNaN(e))return 2;const i=Math.abs(e);if(i>=1)return 2;const s=Math.ceil(-Math.log10(i));return Math.min(s+4,10)}static formatValue(t,e){return typeof t=="number"?t.toFixed(e):String(t)}}class Rt{static calculate(t,e,i,s=!1,a=null,n,l){let r=0;t>0&&(r=1/t*100);const o=i.yAxisPadding!==void 0?i.yAxisPadding:5,u=i.grid?.show===!0,d=i.grid?.lineColor??"#334155",c=i.grid?.lineOpacity??.5,g=i.grid?.borderColor??"#334155",h=i.grid?.borderShow===!0,f=i.layout?.left??"10%",y=i.layout?.right??"10%",x=Array.from(e.values()).map(E=>E.paneIndex).filter(E=>E>0).sort((E,H)=>E-H).filter((E,H,X)=>X.indexOf(E)===H),b=x.length>0,D=i.dataZoom?.visible??!0,w=i.dataZoom?.position??"top",k=i.dataZoom?.height??6,m=i.dataZoom?.start??0,C=i.dataZoom?.end??100;let v=8,_=92,A=-1;if(a)if(a==="main")A=0;else{const E=e.get(a);E&&(A=E.paneIndex)}if(A!==-1){const E=[],H=[],X=[],U=[],nt=i.dataZoom?.start??50,j=i.dataZoom?.end??100;(i.dataZoom?.zoomOnTouch??!0)&&U.push({type:"inside",xAxisIndex:"all",start:nt,end:j,filterMode:"weakFilter"});const ot=b?Math.max(...x):0,pt=[];for(let J=0;J<=ot;J++){const et=J===A;E.push({left:f,right:y,top:et?"5%":"0%",height:et?"90%":"0%",show:et,containLabel:!1}),H.push({type:"category",gridIndex:J,data:[],show:et,axisLabel:{show:et,color:"#94a3b8",fontFamily:i.fontFamily},axisLine:{show:et&&h,lineStyle:{color:g}},splitLine:{show:et&&u,lineStyle:{color:d,opacity:c}}});let kt,Pt;if(J===0&&A===0?(kt=i.yAxisMin!==void 0&&i.yAxisMin!=="auto"?i.yAxisMin:R.createMinFunction(o),Pt=i.yAxisMax!==void 0&&i.yAxisMax!=="auto"?i.yAxisMax:R.createMaxFunction(o)):(kt=R.createMinFunction(o),Pt=R.createMaxFunction(o)),X.push({position:"right",gridIndex:J,show:et,scale:!0,min:kt,max:Pt,axisLabel:{show:et,color:"#94a3b8",fontFamily:i.fontFamily,formatter:dt=>{if(i.yAxisLabelFormatter)return i.yAxisLabelFormatter(dt);const At=i.yAxisDecimalPlaces!==void 0?i.yAxisDecimalPlaces:R.autoDetectDecimals(n);return R.formatValue(dt,At)}},splitLine:{show:et&&u,lineStyle:{color:d,opacity:c}}}),J>0){const dt=Array.from(e.values()).find(At=>At.paneIndex===J);dt&&pt.push({index:J,height:et?90:0,top:et?5:0,isCollapsed:!1,indicatorId:dt.id,titleColor:dt.titleColor,controls:dt.controls})}}return{grid:E,xAxis:H,yAxis:X,dataZoom:U,paneLayout:pt,mainPaneHeight:A===0?90:0,mainPaneTop:A===0?5:0,pixelToPercent:r,overlayYAxisMap:new Map,separatePaneYAxisOffset:1}}D?w==="top"?(v=k+4,_=95):(_=100-k-2,v=8):(v=5,_=95);let M=5;t>0&&(M=20/t*100);let S=75,z=[];if(b){const E=x.map(j=>{const ot=Array.from(e.values()).find(pt=>pt.paneIndex===j);return{index:j,requestedHeight:ot?.height,isCollapsed:ot?.collapsed??!1,indicatorId:ot?.id,titleColor:ot?.titleColor,controls:ot?.controls}}).map(j=>({...j,height:j.isCollapsed?3:j.requestedHeight!==void 0?j.requestedHeight:15})),H=E.reduce((j,ot)=>j+ot.height,0),X=E.length*M,U=H+X;S=_-v-U,l!==void 0&&l>0&&!s?S=l:s?S=3:S<20&&(S=Math.max(S,10));let nt=v+S+M;z=E.map(j=>{const ot={index:j.index,height:j.height,top:nt,isCollapsed:j.isCollapsed,indicatorId:j.indicatorId,titleColor:j.titleColor,controls:j.controls};return nt+=j.height+M,ot})}else S=_-v,s&&(S=3);const W=[];if(z.length>0){W.push({yPercent:v+S+M/2,aboveId:"main",belowId:z[0].indicatorId||""});for(let E=0;E<z.length-1;E++)W.push({yPercent:z[E].top+z[E].height+M/2,aboveId:z[E].indicatorId||"",belowId:z[E+1].indicatorId||""})}const I=[];I.push({left:f,right:y,top:v+"%",height:S+"%",containLabel:!1}),z.forEach(E=>{I.push({left:f,right:y,top:E.top+"%",height:E.height+"%",containLabel:!1})});const $=[0,...z.map((E,H)=>H+1)],P=[],F=z.length===0;P.push({type:"category",data:[],gridIndex:0,scale:!0,axisLine:{onZero:!1,show:!s&&h,lineStyle:{color:g}},splitLine:{show:!s&&u,lineStyle:{color:d,opacity:c}},axisLabel:{show:!s,color:"#94a3b8",fontFamily:i.fontFamily||"sans-serif",formatter:E=>{if(i.yAxisLabelFormatter)return i.yAxisLabelFormatter(E);const H=i.yAxisDecimalPlaces!==void 0?i.yAxisDecimalPlaces:R.autoDetectDecimals(n);return R.formatValue(E,H)}},axisTick:{show:!s},axisPointer:{label:{show:F,fontSize:11,backgroundColor:"#475569"}}}),z.forEach((E,H)=>{const X=H===z.length-1;P.push({type:"category",gridIndex:H+1,data:[],axisLabel:{show:!1},axisLine:{show:!E.isCollapsed&&h,lineStyle:{color:g}},axisTick:{show:!1},splitLine:{show:!1},axisPointer:{label:{show:X,fontSize:11,backgroundColor:"#475569"}}})});const T=[];let B,Z;i.yAxisMin!==void 0&&i.yAxisMin!=="auto"?B=i.yAxisMin:B=R.createMinFunction(o),i.yAxisMax!==void 0&&i.yAxisMax!=="auto"?Z=i.yAxisMax:Z=R.createMaxFunction(o),T.push({position:"right",scale:!0,min:B,max:Z,gridIndex:0,splitLine:{show:!s&&u,lineStyle:{color:d,opacity:c}},axisLine:{show:!s&&h,lineStyle:{color:g}},axisLabel:{show:!s,color:"#94a3b8",fontFamily:i.fontFamily||"sans-serif",formatter:E=>{if(i.yAxisLabelFormatter)return i.yAxisLabelFormatter(E);const H=i.yAxisDecimalPlaces!==void 0?i.yAxisDecimalPlaces:R.autoDetectDecimals(n);return R.formatValue(E,H)}}});let N=1,V=-1/0,O=1/0;n&&n.length>0&&(V=Math.min(...n.map(E=>E.low)),O=Math.max(...n.map(E=>E.high)));const Y=new Map;e.forEach((E,H)=>{E.paneIndex===0&&!E.collapsed&&n&&n.length>0&&Object.entries(E.plots).forEach(([X,U])=>{const nt=`${H}::${X}`,j=["background","barcolor","char"],ot=U.options.style==="shape"&&(U.options.location==="abovebar"||U.options.location==="AboveBar"||U.options.location==="belowbar"||U.options.location==="BelowBar");if(j.includes(U.options.style)){Y.has(nt)||(Y.set(nt,N),N++);return}if(U.options.style==="shape"&&!ot){Y.has(nt)||(Y.set(nt,N),N++);return}const pt=[];if(U.data&&Object.values(U.data).forEach(J=>{typeof J=="number"&&!isNaN(J)&&isFinite(J)&&pt.push(J)}),pt.length>0){const J=Math.min(...pt),et=Math.max(...pt),kt=et-J,Pt=O-V,dt=J>=V*.5&&et<=O*1.5,At=kt>Pt*.01;dt&&At||Y.has(nt)||(Y.set(nt,N),N++)}})});const lt=Y.size>0?N-1:0,ht=new Set;Y.forEach((E,H)=>{e.forEach(X=>{Object.entries(X.plots).forEach(([U,nt])=>{`${X.id}::${U}`===H&&["background","barcolor","char"].includes(nt.options.style)&&ht.add(E)})})});for(let E=0;E<lt;E++){const H=E+1,X=ht.has(H);T.push({position:"left",scale:!X,min:X?0:R.createMinFunction(o),max:X?1:R.createMaxFunction(o),gridIndex:0,show:!1,splitLine:{show:!1},axisLine:{show:!1},axisLabel:{show:!1}})}const Ht=N;z.forEach((E,H)=>{T.push({position:"right",scale:!0,min:R.createMinFunction(o),max:R.createMaxFunction(o),gridIndex:H+1,splitLine:{show:!E.isCollapsed&&u,lineStyle:{color:d,opacity:c*.6}},axisLabel:{show:!E.isCollapsed,color:"#94a3b8",fontFamily:i.fontFamily||"sans-serif",fontSize:10,formatter:X=>{if(i.yAxisLabelFormatter)return i.yAxisLabelFormatter(X);const U=i.yAxisDecimalPlaces!==void 0?i.yAxisDecimalPlaces:R.autoDetectDecimals(n);return R.formatValue(X,U)}},axisLine:{show:!E.isCollapsed&&h,lineStyle:{color:g}}})});const bt=[],Lt=i.dataZoom?.zoomOnTouch??!0,Wt=i.dataZoom?.pannable??!0;return Lt&&Wt&&bt.push({type:"inside",xAxisIndex:$,start:m,end:C,filterMode:"weakFilter"}),D&&(w==="top"?bt.push({type:"slider",xAxisIndex:$,top:"1%",height:k+"%",start:m,end:C,borderColor:"#334155",textStyle:{color:"#cbd5e1"},brushSelect:!1,filterMode:"weakFilter"}):bt.push({type:"slider",xAxisIndex:$,bottom:"1%",height:k+"%",start:m,end:C,borderColor:"#334155",textStyle:{color:"#cbd5e1"},brushSelect:!1,filterMode:"weakFilter"})),{grid:I,xAxis:P,yAxis:T,dataZoom:bt,paneLayout:z,mainPaneHeight:S,mainPaneTop:v,pixelToPercent:r,paneBoundaries:W,overlayYAxisMap:Y,separatePaneYAxisOffset:Ht}}static calculateMaximized(t,e,i){return{grid:[],xAxis:[],yAxis:[],dataZoom:[],paneLayout:[],mainPaneHeight:0,mainPaneTop:0,pixelToPercent:0,paneBoundaries:[]}}}class Te{render(t){const{seriesName:e,xAxisIndex:i,yAxisIndex:s,dataArray:a,colorArray:n,plotOptions:l}=t,r="#2962ff";return{name:e,type:"custom",xAxisIndex:i,yAxisIndex:s,renderItem:(o,u)=>{const d=o.dataIndex;if(d===0)return;const c=u.value(1),g=u.value(2);if(c===null||isNaN(c)||g===null||isNaN(g))return;const h=u.coord([d-1,g]),f=u.coord([d,c]);return{type:"line",shape:{x1:h[0],y1:h[1],x2:f[0],y2:f[1]},style:{stroke:n[d]||l.color||r,lineWidth:l.linewidth||1},silent:!0}},data:a.map((o,u)=>[u,o,u>0?a[u-1]:null])}}}class Ne{render(t){const{seriesName:e,xAxisIndex:i,yAxisIndex:s,dataArray:a,colorArray:n,plotOptions:l}=t,r="#2962ff";return{name:e,type:"custom",xAxisIndex:i,yAxisIndex:s,renderItem:(o,u)=>{const d=u.value(0),c=u.value(1);if(isNaN(c)||c===null)return;const g=u.coord([d,c]),h=u.size([1,0])[0];return{type:"line",shape:{x1:g[0]-h/2,y1:g[1],x2:g[0]+h/2,y2:g[1]},style:{stroke:n[o.dataIndex]||l.color||r,lineWidth:l.linewidth||1},silent:!0}},data:a.map((o,u)=>[u,o])}}}class te{render(t){const{seriesName:e,xAxisIndex:i,yAxisIndex:s,dataArray:a,colorArray:n,plotOptions:l}=t,r="#2962ff",o=l.histbase??0,u=l.style==="columns",d=l.linewidth??1,c=a.map((g,h)=>g==null||typeof g=="number"&&isNaN(g)?null:[h,g,n[h]||l.color||r]);return{name:e,type:"custom",xAxisIndex:i,yAxisIndex:s,renderItem:(g,h)=>{const f=h.value(0),y=h.value(1),x=h.value(2);if(y==null||isNaN(y))return null;const b=h.coord([f,o]),D=h.coord([f,y]),w=h.size([1,0])[0];let k;u?k=w*.6:k=Math.max(1,d);const m=b[0],C=b[1],v=D[1],_=Math.min(C,v),A=Math.abs(v-C);return{type:"rect",shape:{x:m-k/2,y:_,width:k,height:A||1},style:{fill:x}}},data:c.filter(g=>g!==null)}}}const Bt=new Map;function Ze(p,t="#00da3c",e="64px"){if(typeof document>"u")return"";const i=`${p}-${t}-${e}`;if(Bt.has(i))return Bt.get(i);const s=document.createElement("canvas"),a=s.getContext("2d");if(s.width=32,s.height=32,a){a.font="bold "+e+" Arial",a.fillStyle=t,a.textAlign="center",a.textBaseline="middle",a.fillText(p,16,16);const n=s.toDataURL("image/png");return Bt.set(i,n),n}return""}class jt{render(t){const{seriesName:e,xAxisIndex:i,yAxisIndex:s,dataArray:a,colorArray:n,plotOptions:l}=t,r="#2962ff",o=l.style;if(o==="char")return{name:e,type:"scatter",xAxisIndex:i,yAxisIndex:s,symbolSize:0,data:a.map((d,c)=>({value:[c,d],itemStyle:{opacity:0}})),silent:!0};const u=a.map((d,c)=>{if(d===null)return null;const g=n[c]||l.color||r,h={value:[c,d],itemStyle:{color:g}};return o==="cross"?(h.symbol=`image://${Ze("+",g,"24px")}`,h.symbolSize=16):(h.symbol="circle",h.symbolSize=6),h}).filter(d=>d!==null);return{name:e,type:"scatter",xAxisIndex:i,yAxisIndex:s,data:u}}}class ee{render(t){const{seriesName:e,xAxisIndex:i,yAxisIndex:s,dataArray:a,colorArray:n,optionsArray:l,plotOptions:r}=t,o="#2962ff",u=r.style==="candle",d=[],c=a.map((g,h)=>{if(g===null||!Array.isArray(g)||g.length!==4)return null;const[f,y,x,b]=g,D=l[h]||{},w=D.color||n[h]||r.color||o,k=D.wickcolor||r.wickcolor||w,m=D.bordercolor||r.bordercolor||k;return d[h]={color:w,wickColor:k,borderColor:m},[h,f,b,x,y]}).filter(g=>g!==null);return{name:e,type:"custom",xAxisIndex:i,yAxisIndex:s,renderItem:(g,h)=>{const f=h.value(0),y=h.value(1),x=h.value(2),b=h.value(3),D=h.value(4);if(isNaN(y)||isNaN(x)||isNaN(b)||isNaN(D))return null;const w=d[f]||{color:o,wickColor:o,borderColor:o},k=w.color,m=w.wickColor,C=w.borderColor,v=h.coord([f,0])[0],_=h.coord([f,y])[1],A=h.coord([f,x])[1],M=h.coord([f,b])[1],S=h.coord([f,D])[1],z=h.size([1,0])[0]*.6;if(u){const W=Math.min(_,A),I=Math.max(_,A),$=Math.abs(A-_);return{type:"group",children:[{type:"line",shape:{x1:v,y1:S,x2:v,y2:W},style:{stroke:m,lineWidth:1}},{type:"line",shape:{x1:v,y1:I,x2:v,y2:M},style:{stroke:m,lineWidth:1}},{type:"rect",shape:{x:v-z/2,y:W,width:z,height:$||1},style:{fill:k,stroke:C,lineWidth:1}}]}}else{const W=z*.5;return{type:"group",children:[{type:"line",shape:{x1:v,y1:M,x2:v,y2:S},style:{stroke:k,lineWidth:1}},{type:"line",shape:{x1:v-W,y1:_,x2:v,y2:_},style:{stroke:k,lineWidth:1}},{type:"line",shape:{x1:v,y1:A,x2:v+W,y2:A},style:{stroke:k,lineWidth:1}}]}}},data:c}}}class vt{static getShapeSymbol(t){switch(t){case"arrowdown":case"shape_arrow_down":return"path://M12 24l-12-12h8v-12h8v12h8z";case"arrowup":case"shape_arrow_up":return"path://M12 0l12 12h-8v12h-8v-12h-8z";case"circle":case"shape_circle":return"circle";case"cross":case"shape_cross":return"path://M11 2h2v9h9v2h-9v9h-2v-9h-9v-2h9z";case"diamond":case"shape_diamond":return"diamond";case"flag":case"shape_flag":return"path://M6 2v20h2v-8h12l-2-6 2-6h-12z";case"labeldown":case"shape_label_down":return"path://M2 1h20a1 1 0 0 1 1 1v14a1 1 0 0 1-1 1h-8l-2 3-2-3h-8a1 1 0 0 1-1-1v-14a1 1 0 0 1 1-1z";case"labelleft":case"shape_label_left":return"path://M0 10l3-3v-5a1 1 0 0 1 1-1h18a1 1 0 0 1 1 1v16a1 1 0 0 1-1 1h-18a1 1 0 0 1-1-1v-5z";case"labelright":case"shape_label_right":return"path://M24 10l-3-3v-5a1 1 0 0 0-1-1h-18a1 1 0 0 0-1 1v16a1 1 0 0 0 1 1h18a1 1 0 0 0 1-1v-5z";case"labelup":case"shape_label_up":return"path://M12 1l2 3h8a1 1 0 0 1 1 1v14a1 1 0 0 1-1 1h-20a1 1 0 0 1-1-1v-14a1 1 0 0 1 1-1h8z";case"square":case"shape_square":return"rect";case"triangledown":case"shape_triangle_down":return"path://M12 21l-10-18h20z";case"triangleup":case"shape_triangle_up":return"triangle";case"xcross":case"shape_xcross":return"path://M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z";default:return"circle"}}static getShapeRotation(t){return 0}static getShapeSize(t,e,i){if(e!==void 0&&i!==void 0)return[e,i];let s;switch(t){case"tiny":s=8;break;case"small":s=12;break;case"normal":case"auto":s=16;break;case"large":s=24;break;case"huge":s=32;break;default:s=16}return e!==void 0?[e,e]:i!==void 0?[i,i]:s}static getLabelConfig(t,e){switch(e){case"abovebar":case"AboveBar":return{position:"top",distance:5};case"belowbar":case"BelowBar":return{position:"bottom",distance:5};case"top":case"Top":return{position:"bottom",distance:5};case"bottom":case"Bottom":return{position:"top",distance:5};case"absolute":case"Absolute":default:return t==="labelup"||t==="labeldown"||t==="shape_label_up"||t==="shape_label_down"?{position:"inside",distance:0}:{position:"top",distance:5}}}}class Fe{render(t){const{seriesName:e,xAxisIndex:i,yAxisIndex:s,dataArray:a,colorArray:n,optionsArray:l,plotOptions:r,candlestickData:o}=t,u="#2962ff",d=a.map((c,g)=>{const h=l[g]||{},f=r,y=h.location||f.location||"absolute";if(y!=="absolute"&&y!=="Absolute"&&!c||c==null)return null;const x=h.color||f.color||u,b=h.shape||f.shape||"circle",D=h.size||f.size||"normal",w=h.text||f.text,k=h.textcolor||f.textcolor||"white",m=h.width||f.width,C=h.height||f.height;let v=c,_=[0,0];y==="abovebar"||y==="AboveBar"||y==="ab"?(o&&o[g]&&(v=o[g].high),_=[0,"-150%"]):y==="belowbar"||y==="BelowBar"||y==="bl"?(o&&o[g]&&(v=o[g].low),_=[0,"150%"]):y==="top"||y==="Top"?(v=c,_=[0,0]):(y==="bottom"||y==="Bottom")&&(v=c,_=[0,0]);const A=vt.getShapeSymbol(b),M=vt.getShapeSize(D,m,C),S=vt.getShapeRotation(b);let z=M;b.includes("label")&&(Array.isArray(M)?z=[M[0]*2.5,M[1]*2.5]:z=M*2.5);const W=vt.getLabelConfig(b,y);return{value:[g,v],symbol:A,symbolSize:z,symbolRotate:S,symbolOffset:_,itemStyle:{color:x},label:{show:!!w,position:W.position,distance:W.distance,formatter:w,color:k,fontSize:10,fontWeight:"bold"}}}).filter(c=>c!==null);return{name:e,type:"scatter",xAxisIndex:i,yAxisIndex:s,data:d}}}class at{static parseColor(t){if(!t||typeof t!="string")return{color:"#888888",opacity:.2};const e=t.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?\)/);if(e){const s=e[1],a=e[2],n=e[3],l=e[4]?parseFloat(e[4]):1;return{color:`rgb(${s},${a},${n})`,opacity:l}}const i=t.match(/^#([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/);if(i){const s=parseInt(i[1],16),a=parseInt(i[2],16),n=parseInt(i[3],16),l=parseInt(i[4],16)/255;return{color:`rgb(${s},${a},${n})`,opacity:l}}return{color:t,opacity:.3}}static toRgba(t,e){const i=t.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(i)return`rgba(${i[1]},${i[2]},${i[3]},${e})`;const s=t.match(/^#([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/);if(s){const n=parseInt(s[1],16),l=parseInt(s[2],16),r=parseInt(s[3],16);return`rgba(${n},${l},${r},${e})`}const a=t.match(/^#([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/);if(a){const n=parseInt(a[1],16),l=parseInt(a[2],16),r=parseInt(a[3],16);return`rgba(${n},${l},${r},${e})`}return t}}class Oe{render(t){const{seriesName:e,xAxisIndex:i,yAxisIndex:s,dataArray:a,colorArray:n}=t,l=[];for(let r=0;r<n.length;r++)l[r]=n[r]?at.parseColor(n[r]):{color:"",opacity:0};return{name:e,type:"custom",xAxisIndex:i,yAxisIndex:s,z:-10,renderItem:(r,o)=>{const u=o.value(0);if(isNaN(u))return;const d=o.coord([u,.5]),c=o.size([1,0])[0],g=r.coordSys,h=d[0]-c/2,f=n[r.dataIndex],y=o.value(1);if(!f||y===null||y===void 0||isNaN(y))return;const x=l[r.dataIndex];if(!(!x||x.opacity<=0))return{type:"rect",shape:{x:h,y:g.y,width:c,height:g.height},style:{fill:x.color,opacity:x.opacity},silent:!0}},data:a.map((r,o)=>[o,r!=null&&!isNaN(r)?.5:null])}}}class ie{render(t){const{seriesName:e,xAxisIndex:i,yAxisIndex:s,plotOptions:a,plotDataArrays:n,indicatorId:l,plotName:r,optionsArray:o}=t,u=t.dataArray.length,d=a.plot1?`${l}::${a.plot1}`:null,c=a.plot2?`${l}::${a.plot2}`:null;if(!d||!c)return console.warn(`Fill plot "${r}" missing plot1 or plot2 reference`),null;const g=n?.get(d),h=n?.get(c);if(!g||!h)return console.warn(`Fill plot "${r}" references non-existent plots: ${a.plot1}, ${a.plot2}`),null;if(a.gradient===!0)return this.renderGradientFill(e,i,s,g,h,u,o,a);const{color:f,opacity:y}=at.parseColor(a.color||"rgba(128, 128, 128, 0.2)"),x=o?.some(w=>w&&w.color!==void 0);let b=null;if(x){b=[];for(let w=0;w<u;w++){const k=o?.[w];k&&k.color!==void 0?b[w]=at.parseColor(k.color):b[w]={color:f,opacity:y}}}const D=[];for(let w=0;w<u;w++){const k=g[w],m=h[w],C=w>0?g[w-1]:null,v=w>0?h[w-1]:null;D.push([w,k,m,C,v])}return{name:e,type:"custom",xAxisIndex:i,yAxisIndex:s,z:1,clip:!0,encode:{x:0},animation:!1,renderItem:(w,k)=>{const m=w.dataIndex;if(m===0)return null;const C=k.value(1),v=k.value(2),_=k.value(3),A=k.value(4);if(C===null||v===null||_===null||A===null||isNaN(C)||isNaN(v)||isNaN(_)||isNaN(A))return null;const M=b?b[m]:null,S=M?M.opacity:y;if(S<.01)return null;const z=k.coord([m-1,_]),W=k.coord([m,C]),I=k.coord([m,v]),$=k.coord([m-1,A]);return{type:"polygon",shape:{points:[z,W,I,$]},style:{fill:M?M.color:f,opacity:S},silent:!0}},data:D,silent:!0}}renderBatched(t,e,i,s,a){const n=Array.from({length:s},(l,r)=>[r]);return{name:t,type:"custom",xAxisIndex:e,yAxisIndex:i,z:1,clip:!0,encode:{x:0},animation:!1,renderItem:(l,r)=>{const o=l.dataIndex;if(o===0)return null;const u=[];for(let d=0;d<a.length;d++){const c=a[d],g=c.plot1Data[o],h=c.plot2Data[o],f=c.plot1Data[o-1],y=c.plot2Data[o-1];if(g==null||h==null||f==null||y==null||isNaN(g)||isNaN(h)||isNaN(f)||isNaN(y))continue;const x=c.barColors[o];if(!x||x.opacity<.01)continue;const b=r.coord([o-1,f]),D=r.coord([o,g]),w=r.coord([o,h]),k=r.coord([o-1,y]);u.push({type:"polygon",shape:{points:[b,D,w,k]},style:{fill:x.color,opacity:x.opacity},silent:!0})}return u.length>0?{type:"group",children:u,silent:!0}:null},data:n,silent:!0}}renderGradientFill(t,e,i,s,a,n,l,r){const o=[];for(let d=0;d<n;d++){const c=l?.[d];if(c&&c.top_color!==void 0){const g=at.parseColor(c.top_color),h=at.parseColor(c.bottom_color);o[d]={topColor:g.color,topOpacity:g.opacity,bottomColor:h.color,bottomOpacity:h.opacity}}else o[d]={topColor:"rgba(128,128,128,0.2)",topOpacity:.2,bottomColor:"rgba(128,128,128,0.2)",bottomOpacity:.2}}const u=[];for(let d=0;d<n;d++){const c=s[d],g=a[d],h=d>0?s[d-1]:null,f=d>0?a[d-1]:null;u.push([d,c,g,h,f])}return{name:t,type:"custom",xAxisIndex:e,yAxisIndex:i,z:1,clip:!0,encode:{x:0},animation:!1,renderItem:(d,c)=>{const g=d.dataIndex;if(g===0)return null;const h=c.value(1),f=c.value(2),y=c.value(3),x=c.value(4);if(h===null||f===null||y===null||x===null||isNaN(h)||isNaN(f)||isNaN(y)||isNaN(x))return null;const b=c.coord([g-1,y]),D=c.coord([g,h]),w=c.coord([g,f]),k=c.coord([g-1,x]),m=o[g]||o[g-1];if(!m||m.topOpacity<.01&&m.bottomOpacity<.01)return null;const C=at.toRgba(m.topColor,m.topOpacity),v=at.toRgba(m.bottomColor,m.bottomOpacity),_=h>=f;return{type:"polygon",shape:{points:[b,D,w,k]},style:{fill:{type:"linear",x:0,y:0,x2:0,y2:1,colorStops:[{offset:0,color:_?C:v},{offset:1,color:_?v:C}]}},silent:!0}},data:u,silent:!0}}}class He{render(t){const{seriesName:e,xAxisIndex:i,yAxisIndex:s,dataArray:a,candlestickData:n,dataIndexOffset:l}=t,r=l||0,o=[];for(let d=0;d<a.length;d++){const c=a[d];if(!c)continue;const g=Array.isArray(c)?c:[c];for(const h of g)h&&typeof h=="object"&&!h._deleted&&o.push(h)}const u=o.map(d=>{const c=T=>typeof T=="function"?T():T,g=c(d.text)||"",h=c(d.color),f=h!=null&&h!==""?h:"transparent",y=c(d.textcolor)||"#ffffff",x=c(d.yloc)||"price",b=c(d.style)||"style_label_down",D=c(d.size)||"normal",w=c(d.textalign)||"align_center",k=c(d.tooltip)||"",m=this.styleToShape(b),C=d.xloc==="bar_index"||d.xloc==="bi"?d.x+r:d.x;let v=d.y,_=[0,0];x==="abovebar"||x==="AboveBar"||x==="ab"?(n&&n[C]&&(v=n[C].high),_=[0,"-150%"]):(x==="belowbar"||x==="BelowBar"||x==="bl")&&(n&&n[C]&&(v=n[C].low),_=[0,"150%"]);const A=vt.getShapeSymbol(m),M=vt.getShapeSize(D),S=this.getSizePx(D);let z;const W=m==="labeldown"||m==="shape_label_down"||m==="labelup"||m==="shape_label_up"||m==="labelleft"||m==="labelright";let I=[0,0];if(W){const T=g.length*S*.65,B=S*2.5,Z=Math.max(B,T+S*1.6),N=S*2.8,V=3/24;if(m==="labelleft"||m==="labelright"){const O=Z/(1-V);z=[O,N];const Y=typeof _[0]=="string"?0:_[0];m==="labelleft"?(_=[Y+O*.42,_[1]],I=[O*V*.5,0]):(_=[Y-O*.42,_[1]],I=[-O*V*.5,0])}else{const O=N/(1-V);z=[Z,O],m==="labeldown"?(_=[_[0],typeof _[1]=="string"?_[1]:_[1]-O*.42],I=[0,-O*V*.5]):(_=[_[0],typeof _[1]=="string"?_[1]:_[1]+O*.42],I=[0,O*V*.5])}}else m==="none"?z=0:Array.isArray(M)?z=[M[0]*1.5,M[1]*1.5]:z=M*1.5;const $=this.getLabelPosition(b,x),P=$==="inside"||$.startsWith("inside"),F={value:[C,v],symbol:A,symbolSize:z,symbolOffset:_,itemStyle:{color:f},label:{show:!!g,position:$,distance:P?0:5,offset:I,formatter:g,color:y,fontSize:S,fontWeight:"bold",align:P?"center":w==="align_left"||w==="left"?"left":w==="align_right"||w==="right"?"right":"center",verticalAlign:"middle",padding:[2,6]}};return k?(F._tooltipText=k,F.emphasis={scale:!1,itemStyle:{color:f},label:{show:F.label.show,color:y,fontSize:S,fontWeight:"bold"}}):F.emphasis={disabled:!0},F}).filter(d=>d!==null);return{name:e,type:"scatter",xAxisIndex:i,yAxisIndex:s,data:u,z:20,animation:!1,clip:!1}}styleToShape(t){switch(t.startsWith("style_")?t.substring(6):t){case"label_down":return"labeldown";case"label_up":return"labelup";case"label_left":return"labelleft";case"label_right":return"labelright";case"label_lower_left":return"labeldown";case"label_lower_right":return"labeldown";case"label_upper_left":return"labelup";case"label_upper_right":return"labelup";case"label_center":return"labeldown";case"circle":return"circle";case"square":return"square";case"diamond":return"diamond";case"flag":return"flag";case"arrowup":return"arrowup";case"arrowdown":return"arrowdown";case"cross":return"cross";case"xcross":return"xcross";case"triangleup":return"triangleup";case"triangledown":return"triangledown";case"text_outline":return"none";case"none":return"none";default:return"labeldown"}}getLabelPosition(t,e){switch(t.startsWith("style_")?t.substring(6):t){case"label_down":case"label_up":case"label_left":case"label_right":case"label_lower_left":case"label_lower_right":case"label_upper_left":case"label_upper_right":case"label_center":return"inside";case"text_outline":case"none":return e==="abovebar"||e==="AboveBar"||e==="ab"?"top":e==="belowbar"||e==="BelowBar"||e==="bl"?"bottom":"top";default:return e==="belowbar"||e==="BelowBar"||e==="bl"?"bottom":"top"}}getSizePx(t){switch(t){case"tiny":return 8;case"small":return 9;case"normal":case"auto":return 10;case"large":return 12;case"huge":return 14;default:return 10}}}class Re{render(t){const{seriesName:e,xAxisIndex:i,yAxisIndex:s,dataArray:a,dataIndexOffset:n}=t,l=n||0,r="#2962ff",o=[];for(let c=0;c<a.length;c++){const g=a[c];if(!g)continue;const h=Array.isArray(g)?g:[g];for(const f of h)f&&typeof f=="object"&&!f._deleted&&o.push(f)}if(o.length===0)return{name:e,type:"custom",xAxisIndex:i,yAxisIndex:s,data:[],silent:!0};const u=(t.candlestickData?.length||0)+l,d=Math.max(0,u-1);return{name:e,type:"custom",xAxisIndex:i,yAxisIndex:s,renderItem:(c,g)=>{const h=[];for(const f of o){if(f._deleted)continue;const y=f.xloc==="bar_index"||f.xloc==="bi"?l:0;let x=g.coord([f.x1+y,f.y1]),b=g.coord([f.x2+y,f.y2]);const D=f.extend||"none";if(D!=="none"&&D!=="n"){const C=c.coordSys;[x,b]=this.extendLine(x,b,D,C.x,C.x+C.width,C.y,C.y+C.height)}const w=f.color||r,k=f.width||1;h.push({type:"line",shape:{x1:x[0],y1:x[1],x2:b[0],y2:b[1]},style:{fill:"none",stroke:w,lineWidth:k,lineDash:this.getDashPattern(f.style)}});const m=f.style||"style_solid";if(m==="style_arrow_left"||m==="style_arrow_both"){const C=this.arrowHead(b,x,k,w);C&&h.push(C)}if(m==="style_arrow_right"||m==="style_arrow_both"){const C=this.arrowHead(x,b,k,w);C&&h.push(C)}}return{type:"group",children:h}},data:[[0,d]],clip:!0,encode:{x:[0,1]},itemStyle:{color:"transparent",borderColor:"transparent"},z:15,silent:!0,emphasis:{disabled:!0}}}getDashPattern(t){switch(t){case"style_dotted":return[2,2];case"style_dashed":return[6,4];default:return}}extendLine(t,e,i,s,a,n,l){const r=e[0]-t[0],o=e[1]-t[1];if(r===0&&o===0)return[t,e];const u=(g,h)=>{let f=1/0;if(h[0]!==0){const y=h[0]>0?(a-g[0])/h[0]:(s-g[0])/h[0];f=Math.min(f,y)}if(h[1]!==0){const y=h[1]>0?(l-g[1])/h[1]:(n-g[1])/h[1];f=Math.min(f,y)}return isFinite(f)||(f=0),[g[0]+f*h[0],g[1]+f*h[1]]};let d=t,c=e;return(i==="right"||i==="r"||i==="both"||i==="b")&&(c=u(t,[r,o])),(i==="left"||i==="l"||i==="both"||i==="b")&&(d=u(e,[-r,-o])),[d,c]}arrowHead(t,e,i,s){const a=e[0]-t[0],n=e[1]-t[1],l=Math.sqrt(a*a+n*n);if(l<1)return null;const r=Math.max(8,i*4),o=a/l,u=n/l,d=e[0]-o*r,c=e[1]-u*r,g=-u*r*.4,h=o*r*.4;return{type:"polygon",shape:{points:[[e[0],e[1]],[d+g,c+h],[d-g,c-h]]},style:{fill:s}}}}class Be{render(t){const{seriesName:e,xAxisIndex:i,yAxisIndex:s,dataArray:a,dataIndexOffset:n}=t,l=n||0,r=[];for(let d=0;d<a.length;d++){const c=a[d];if(!c)continue;const g=Array.isArray(c)?c:[c];for(const h of g){if(!h||typeof h!="object"||h._deleted)continue;const f=h.line1,y=h.line2;!f||!y||f._deleted||y._deleted||r.push(h)}}if(r.length===0)return{name:e,type:"custom",xAxisIndex:i,yAxisIndex:s,data:[],silent:!0};const o=(t.candlestickData?.length||0)+l,u=Math.max(0,o-1);return{name:e,type:"custom",xAxisIndex:i,yAxisIndex:s,renderItem:(d,c)=>{const g=[];for(const h of r){if(h._deleted)continue;const f=h.line1,y=h.line2;if(!f||!y||f._deleted||y._deleted)continue;const x=f.xloc==="bar_index"||f.xloc==="bi"?l:0,b=y.xloc==="bar_index"||y.xloc==="bi"?l:0;let D=c.coord([f.x1+x,f.y1]),w=c.coord([f.x2+x,f.y2]),k=c.coord([y.x1+b,y.y1]),m=c.coord([y.x2+b,y.y2]);const C=f.extend||"none",v=y.extend||"none";if(C!=="none"||v!=="none"){const M=d.coordSys,S=M.x,z=M.x+M.width,W=M.y,I=M.y+M.height;C!=="none"&&([D,w]=this.extendLine(D,w,C,S,z,W,I)),v!=="none"&&([k,m]=this.extendLine(k,m,v,S,z,W,I))}const{color:_,opacity:A}=at.parseColor(h.color||"rgba(128, 128, 128, 0.2)");g.push({type:"polygon",shape:{points:[D,w,m,k]},style:{fill:_,opacity:A},silent:!0})}return{type:"group",children:g}},data:[[0,u]],clip:!0,encode:{x:[0,1]},z:10,silent:!0,emphasis:{disabled:!0}}}extendLine(t,e,i,s,a,n,l){const r=e[0]-t[0],o=e[1]-t[1];if(r===0&&o===0)return[t,e];const u=(g,h)=>{let f=1/0;if(h[0]!==0){const y=h[0]>0?(a-g[0])/h[0]:(s-g[0])/h[0];f=Math.min(f,y)}if(h[1]!==0){const y=h[1]>0?(l-g[1])/h[1]:(n-g[1])/h[1];f=Math.min(f,y)}return isFinite(f)||(f=0),[g[0]+f*h[0],g[1]+f*h[1]]};let d=t,c=e;return(i==="right"||i==="both")&&(c=u(t,[r,o])),(i==="left"||i==="both")&&(d=u(e,[-r,-o])),[d,c]}}class je{render(t){const{seriesName:e,xAxisIndex:i,yAxisIndex:s,dataArray:a,dataIndexOffset:n}=t,l=n||0,r=[];for(let d=0;d<a.length;d++){const c=a[d];if(!c)continue;const g=Array.isArray(c)?c:[c];for(const h of g)h&&typeof h=="object"&&!h._deleted&&h.points&&h.points.length>=2&&r.push(h)}if(r.length===0)return{name:e,type:"custom",xAxisIndex:i,yAxisIndex:s,data:[],silent:!0};const o=(t.candlestickData?.length||0)+l,u=Math.max(0,o-1);return{name:e,type:"custom",xAxisIndex:i,yAxisIndex:s,renderItem:(d,c)=>{const g=[];for(const h of r){if(h._deleted)continue;const f=h.points;if(!f||f.length<2)continue;const y=h.xloc==="bi"||h.xloc==="bar_index",x=y?l:0,b=[];for(const C of f){const v=y?(C.index??0)+x:C.time??0,_=C.price??0;b.push(c.coord([v,_]))}if(b.length<2)continue;const D=h.line_color,w=D==null||typeof D=="number"&&isNaN(D)||D==="na"||D==="NaN"?null:D||"#2962ff",k=h.line_width||1,m=this.getDashPattern(h.line_style);if(h.fill_color&&h.fill_color!==""&&h.fill_color!=="na"){const{color:C,opacity:v}=at.parseColor(h.fill_color);if(h.curved){const _=this.buildCurvedPath(b,h.closed);g.push({type:"path",shape:{pathData:_+" Z"},style:{fill:C,opacity:v,stroke:"none"},silent:!0})}else g.push({type:"polygon",shape:{points:b},style:{fill:C,opacity:v,stroke:"none"},silent:!0})}if(w&&k>0)if(h.curved){const C=this.buildCurvedPath(b,h.closed);g.push({type:"path",shape:{pathData:C},style:{fill:"none",stroke:w,lineWidth:k,lineDash:m},silent:!0})}else{const C=h.closed?[...b,b[0]]:b;g.push({type:"polyline",shape:{points:C},style:{fill:"none",stroke:w,lineWidth:k,lineDash:m},silent:!0})}}return{type:"group",children:g}},data:[[0,u]],clip:!0,encode:{x:[0,1]},itemStyle:{color:"transparent",borderColor:"transparent"},z:15,silent:!0,emphasis:{disabled:!0}}}buildCurvedPath(t,e){const i=t.length;if(i<2)return"";if(i===2)return`M ${t[0][0]} ${t[0][1]} L ${t[1][0]} ${t[1][1]}`;const s=.5;let a=`M ${t[0][0]} ${t[0][1]}`;const n=r=>e?t[(r%i+i)%i]:r<0?t[0]:r>=i?t[i-1]:t[r],l=e?i:i-1;for(let r=0;r<l;r++){const o=n(r-1),u=n(r),d=n(r+1),c=n(r+2),g=u[0]+(d[0]-o[0])*s/3,h=u[1]+(d[1]-o[1])*s/3,f=d[0]-(c[0]-u[0])*s/3,y=d[1]-(c[1]-u[1])*s/3;a+=` C ${g} ${h}, ${f} ${y}, ${d[0]} ${d[1]}`}return e&&(a+=" Z"),a}getDashPattern(t){switch(t){case"style_dotted":return[2,2];case"style_dashed":return[6,4];default:return}}}function Yt(p){if(!p||typeof p!="string")return p;if(p.startsWith("#")){const t=p.slice(1);if(t.length===8){const e=parseInt(t.slice(0,2),16),i=parseInt(t.slice(2,4),16),s=parseInt(t.slice(4,6),16),a=parseInt(t.slice(6,8),16)/255;return`rgba(${e},${i},${s},${a.toFixed(3)})`}}return p}function Ye(p){if(!p||typeof p!="string")return null;if(p.startsWith("#")){const e=p.slice(1);if(e.length>=6){const i=parseInt(e.slice(0,2),16),s=parseInt(e.slice(2,4),16),a=parseInt(e.slice(4,6),16);if(!isNaN(i)&&!isNaN(s)&&!isNaN(a))return{r:i,g:s,b:a}}if(e.length===3){const i=parseInt(e[0]+e[0],16),s=parseInt(e[1]+e[1],16),a=parseInt(e[2]+e[2],16);if(!isNaN(i)&&!isNaN(s)&&!isNaN(a))return{r:i,g:s,b:a}}return null}const t=p.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?{r:+t[1],g:+t[2],b:+t[3]}:null}function Xe(p,t,e){return(.299*p+.587*t+.114*e)/255}class Ve{render(t){const{seriesName:e,xAxisIndex:i,yAxisIndex:s,dataArray:a,dataIndexOffset:n}=t,l=n||0,r=[];for(let d=0;d<a.length;d++){const c=a[d];if(!c)continue;const g=Array.isArray(c)?c:[c];for(const h of g)h&&typeof h=="object"&&!h._deleted&&r.push(h)}if(r.length===0)return{name:e,type:"custom",xAxisIndex:i,yAxisIndex:s,data:[],silent:!0};const o=(t.candlestickData?.length||0)+l,u=Math.max(0,o-1);return{name:e,type:"custom",xAxisIndex:i,yAxisIndex:s,renderItem:(d,c)=>{const g=[];for(const h of r){if(h._deleted)continue;const f=h.xloc==="bar_index"||h.xloc==="bi"?l:0,y=c.coord([h.left+f,h.top]),x=c.coord([h.right+f,h.bottom]);let b=y[0],D=y[1],w=x[0]-y[0],k=x[1]-y[1];const m=h.extend||"none";if(m!=="none"&&m!=="n"){const S=d.coordSys;(m==="left"||m==="l"||m==="both"||m==="b")&&(b=S.x,w=m==="both"||m==="b"?S.width:x[0]-S.x),(m==="right"||m==="r"||m==="both"||m==="b")&&(m==="right"||m==="r")&&(w=S.x+S.width-y[0])}const C=h.bgcolor,v=C==null||typeof C=="number"&&isNaN(C)||C==="na"||C==="NaN"||C===""?null:Yt(C)||"#2962ff";v&&g.push({type:"rect",shape:{x:b,y:D,width:w,height:k},style:{fill:v,stroke:"none"}});const _=h.border_color,A=_==null||typeof _=="number"&&isNaN(_)||_==="na"||_==="NaN"?null:Yt(_)||"#2962ff",M=h.border_width??1;if(M>0&&A&&g.push({type:"rect",shape:{x:b,y:D,width:w,height:k},style:{fill:"none",stroke:A,lineWidth:M,lineDash:this.getDashPattern(h.border_style)}}),h.text){const S=this.getTextX(b,w,h.text_halign),z=this.getTextY(D,k,h.text_valign);let W=Yt(h.text_color)||"#000000";if((!h.text_color||h.text_color==="#000000"||h.text_color==="black"||h.text_color==="color.black")&&v){const P=Ye(v);P&&Xe(P.r,P.g,P.b)<.5&&(W="#FFFFFF")}const I=!h.text_formatting||h.text_formatting==="format_none"||h.text_formatting==="format_bold",$=this.computeFontSize(h.text_size,h.text,Math.abs(w),Math.abs(k),I);g.push({type:"text",style:{x:S,y:z,text:h.text,fill:W,fontSize:$,fontFamily:h.text_font_family==="monospace"?"monospace":"sans-serif",fontWeight:I?"bold":"normal",fontStyle:h.text_formatting==="format_italic"?"italic":"normal",textAlign:this.mapHAlign(h.text_halign),textVerticalAlign:this.mapVAlign(h.text_valign)}})}}return{type:"group",children:g}},data:[[0,u]],clip:!0,encode:{x:[0,1]},itemStyle:{color:"transparent",borderColor:"transparent"},z:14,silent:!0,emphasis:{disabled:!0}}}getDashPattern(t){switch(t){case"style_dotted":return[2,2];case"style_dashed":return[6,4];default:return}}computeFontSize(t,e,i,s,a){if(typeof t=="number"&&t>0)return t;switch(t){case"tiny":case"size.tiny":return 8;case"small":case"size.small":return 10;case"normal":case"size.normal":return 14;case"large":case"size.large":return 20;case"huge":case"size.huge":return 36}if(!e||i<=0||s<=0)return 12;const n=6,l=i-n*2,r=s-n*2;if(l<=0||r<=0)return 6;const o=e.split(`
18
- `),u=o.length;let d=1;for(const f of o)f.length>d&&(d=f.length);const c=l/(d*(a?.62:.55)),g=r/(u*1.3),h=Math.min(c,g);return Math.max(6,Math.min(h,48))}mapHAlign(t){switch(t){case"left":case"text.align_left":return"left";case"right":case"text.align_right":return"right";case"center":case"text.align_center":default:return"center"}}mapVAlign(t){switch(t){case"top":case"text.align_top":return"top";case"bottom":case"text.align_bottom":return"bottom";case"center":case"text.align_center":default:return"middle"}}getTextX(t,e,i){switch(i){case"left":case"text.align_left":return t+4;case"right":case"text.align_right":return t+e-4;case"center":case"text.align_center":default:return t+e/2}}getTextY(t,e,i){switch(i){case"top":case"text.align_top":return t+4;case"bottom":case"text.align_bottom":return t+e-4;case"center":case"text.align_center":default:return t+e/2}}}var qe=Object.defineProperty,Ue=(p,t,e)=>t in p?qe(p,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):p[t]=e,Ke=(p,t,e)=>(Ue(p,typeof t!="symbol"?t+"":t,e),e);const q=class{static register(t,e){this.renderers.set(t,e)}static get(t){return this.renderers.get(t)||this.renderers.get("line")}};Ke(q,"renderers",new Map),q.register("line",new Te),q.register("step",new Ne),q.register("histogram",new te),q.register("columns",new te),q.register("circles",new jt),q.register("cross",new jt),q.register("char",new jt),q.register("bar",new ee),q.register("candle",new ee),q.register("shape",new Fe),q.register("background",new Oe),q.register("fill",new ie),q.register("label",new He),q.register("drawing_line",new Re),q.register("linefill",new Be),q.register("drawing_polyline",new je),q.register("drawing_box",new Ve);let Je=q;var Qe=Object.defineProperty,ti=(p,t,e)=>t in p?Qe(p,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):p[t]=e,ei=(p,t,e)=>(ti(p,typeof t!="symbol"?t+"":t,e),e);const se=class Qt{static buildCandlestickSeries(t,e,i){const s=e.upColor||"#00da3c",a=e.downColor||"#ec0000",n=t.map(r=>[r.open,r.close,r.low,r.high]);if(i&&i>n.length){const r=i-n.length;for(let o=0;o<r;o++)n.push(null)}let l;if(e.lastPriceLine?.visible!==!1&&t.length>0){const r=t[t.length-1],o=r.close,u=r.close>=r.open,d=e.lastPriceLine?.color||(u?s:a);let c=e.lastPriceLine?.lineStyle||"dashed";c.startsWith("linestyle_")&&(c=c.replace("linestyle_",""));const g=e.yAxisDecimalPlaces!==void 0?e.yAxisDecimalPlaces:R.autoDetectDecimals(t);l={symbol:["none","none"],precision:g,data:[{yAxis:o,label:{show:!0,position:"end",formatter:h=>e.yAxisLabelFormatter?e.yAxisLabelFormatter(h.value):R.formatValue(h.value,g),color:"#fff",backgroundColor:d,padding:[2,4],borderRadius:2,fontSize:11,fontWeight:"bold"},lineStyle:{color:d,type:c,width:1,opacity:.8}}],animation:!1,silent:!0}}return{type:"candlestick",id:"__candlestick__",name:e.title,data:n,itemStyle:{color:s,color0:a,borderColor:s,borderColor0:a},markLine:l,xAxisIndex:0,yAxisIndex:0,z:5}}static buildIndicatorSeries(t,e,i,s,a=0,n,l,r=1){const o=[],u=new Array(s).fill(null),d=new Map;return t.forEach((c,g)=>{if(c.collapsed)return;const h=Object.keys(c.plots).sort((y,x)=>{const b=c.plots[y],D=c.plots[x],w=b.options.style==="fill",k=D.options.style==="fill";return w&&!k?1:!w&&k?-1:0}),f=new Map;if(h.forEach(y=>{const x=c.plots[y],b=x.options.display==="none",D=`${g}::${y}`;let w=0,k=0,m=x.options.overlay;if(x.options.style==="fill"&&m===void 0){const S=x.options.plot1,z=x.options.plot2;if(S&&z){const W=c.plots[S],I=c.plots[z];W?.options?.overlay===!0&&I?.options?.overlay===!0&&(m=!0)}}if(c.paneIndex===0||m===!0)w=0,l&&l.has(D)?k=l.get(D):k=0;else{const S=i.findIndex(z=>z.index===c.paneIndex);S!==-1&&(w=S+1,k=r+S)}const C=new Array(s).fill(null),v=new Array(s).fill(null),_=new Array(s).fill(null),A=new Array(s).fill(null);if(x.data?.forEach(S=>{const z=e.get(S.time);if(z!==void 0){const W=S.options?.offset??x.options.offset??0,I=z+a+W;if(I>=0&&I<s){let $=S.value;const P=S.options?.color;v[I]=$;const F=S.options!=null&&"color"in S.options,T=P===null||P==="na"||P==="NaN"||typeof P=="number"&&isNaN(P)||F&&P===void 0;T&&($=null),C[I]=$,_[I]=T?null:P||x.options.color||Qt.DEFAULT_COLOR,A[I]=S.options||{}}}}),d.set(`${g}::${y}`,v),b)return;if(x.options?.style?.startsWith("style_")&&(x.options.style=x.options.style.replace("style_","")),x.options.style==="barcolor"){x.data?.forEach(S=>{const z=e.get(S.time);if(z!==void 0){const W=S.options?.offset??x.options.offset??0,I=z+a+W;if(I>=0&&I<s){const $=S.options?.color||x.options.color||Qt.DEFAULT_COLOR;!($===null||$==="na"||$==="NaN"||typeof $=="number"&&isNaN($))&&S.value!==null&&S.value!==void 0&&(u[I]=$)}}});return}if(x.options.style==="table")return;if(x.options.style==="fill"&&x.options.gradient!==!0){const S=x.options.plot1?`${g}::${x.options.plot1}`:null,z=x.options.plot2?`${g}::${x.options.plot2}`:null;if(S&&z){const W=d.get(S),I=d.get(z);if(W&&I){const{color:$,opacity:P}=at.parseColor(x.options.color||"rgba(128, 128, 128, 0.2)"),F=A.some(Z=>Z&&Z.color!==void 0),T=[];for(let Z=0;Z<s;Z++){const N=A[Z];F&&N&&N.color!==void 0?T[Z]=at.parseColor(N.color):T[Z]={color:$,opacity:P}}const B=`${w}:${k}`;f.has(B)||f.set(B,{entries:[],xAxisIndex:w,yAxisIndex:k}),f.get(B).entries.push({plot1Data:W,plot2Data:I,barColors:T});return}}}if(x.options.color&&typeof x.options.color=="string"&&at.parseColor(x.options.color).opacity<.01&&!_.some(S=>S==null?!1:at.parseColor(S).opacity>=.01))return;const M=Je.get(x.options.style).render({seriesName:D,xAxisIndex:w,yAxisIndex:k,dataArray:C,colorArray:_,optionsArray:A,plotOptions:x.options,candlestickData:n,plotDataArrays:d,indicatorId:g,plotName:y,dataIndexOffset:a});M&&o.push(M)}),f.size>0){const y=new ie;f.forEach(({entries:x,xAxisIndex:b,yAxisIndex:D},w)=>{if(x.length>=2){const k=y.renderBatched(`${g}::fills_batch_${w}`,b,D,s,x);k&&o.push(k)}else if(x.length===1){const k=y.renderBatched(`${g}::fills_batch_${w}`,b,D,s,x);k&&o.push(k)}})}}),{series:o,barColors:u}}};ei(se,"DEFAULT_COLOR","#2962ff");let wt=se;class ii{static build(t,e,i,s=!1,a=null,n=[]){const l=[],r=t.pixelToPercent,o=t.mainPaneTop;if(!a||a==="main"){const u=10*r;if(l.push({type:"text",left:"8.5%",top:o+u+"%",z:10,style:{text:e.title||"",fill:e.titleColor||"#fff",font:`bold 16px ${e.fontFamily||"sans-serif"}`,textVerticalAlign:"top"}}),n.length>0){const c=20*r,g=16*r;n.forEach((h,f)=>{l.push({type:"text",left:"8.5%",top:o+u+c+f*g+"%",z:10,style:{text:h.id,fill:h.titleColor||"#9e9e9e",font:`bold 12px ${e.fontFamily||"sans-serif"}`,textVerticalAlign:"top"}})})}if(e.watermark!==!1){const c=t.mainPaneTop+t.mainPaneHeight;l.push({type:"text",right:"11%",top:c-3+"%",z:10,style:{text:"QFChart",fill:e.fontColor||"#cbd5e1",font:"bold 16px sans-serif",opacity:.1},cursor:"pointer",onclick:()=>{window.open("https://quantforge.org","_blank")}})}const d=[];if(e.controls?.collapse&&d.push({type:"group",children:[{type:"rect",shape:{width:20,height:20,r:2},style:{fill:"#334155",stroke:"#475569",lineWidth:1},onclick:()=>i("main","collapse")},{type:"text",style:{text:s?"+":"\u2212",fill:"#cbd5e1",font:`bold 14px ${e.fontFamily}`,x:10,y:10,textAlign:"center",textVerticalAlign:"middle"},silent:!0}]}),e.controls?.maximize){const c=a==="main",g=e.controls?.collapse?25:0;d.push({type:"group",x:g,children:[{type:"rect",shape:{width:20,height:20,r:2},style:{fill:"#334155",stroke:"#475569",lineWidth:1},onclick:()=>i("main","maximize")},{type:"text",style:{text:c?"\u2750":"\u25A1",fill:"#cbd5e1",font:`14px ${e.fontFamily}`,x:10,y:10,textAlign:"center",textVerticalAlign:"middle"},silent:!0}]})}if(e.controls?.fullscreen){let c=0;e.controls?.collapse&&(c+=25),e.controls?.maximize&&(c+=25),d.push({type:"group",x:c,children:[{type:"rect",shape:{width:20,height:20,r:2},style:{fill:"#334155",stroke:"#475569",lineWidth:1},onclick:()=>i("main","fullscreen")},{type:"text",style:{text:"\u26F6",fill:"#cbd5e1",font:`14px ${e.fontFamily}`,x:10,y:10,textAlign:"center",textVerticalAlign:"middle"},silent:!0}]})}d.length>0&&l.push({type:"group",right:"10.5%",top:o+"%",children:d})}return t.paneLayout.forEach(u=>{if(a&&u.indicatorId!==a)return;l.push({type:"text",left:"8.5%",top:u.top+10*r+"%",z:10,style:{text:u.indicatorId||"",fill:u.titleColor||"#fff",font:`bold 12px ${e.fontFamily||"sans-serif"}`,textVerticalAlign:"top"}});const d=[];if(u.controls?.collapse&&d.push({type:"group",children:[{type:"rect",shape:{width:20,height:20,r:2},style:{fill:"#334155",stroke:"#475569",lineWidth:1},onclick:()=>u.indicatorId&&i(u.indicatorId,"collapse")},{type:"text",style:{text:u.isCollapsed?"+":"\u2212",fill:"#cbd5e1",font:`bold 14px ${e.fontFamily}`,x:10,y:10,textAlign:"center",textVerticalAlign:"middle"},silent:!0}]}),u.controls?.maximize){const c=a===u.indicatorId,g=u.controls?.collapse?25:0;d.push({type:"group",x:g,children:[{type:"rect",shape:{width:20,height:20,r:2},style:{fill:"#334155",stroke:"#475569",lineWidth:1},onclick:()=>u.indicatorId&&i(u.indicatorId,"maximize")},{type:"text",style:{text:c?"\u2750":"\u25A1",fill:"#cbd5e1",font:`14px ${e.fontFamily}`,x:10,y:10,textAlign:"center",textVerticalAlign:"middle"},silent:!0}]})}d.length>0&&l.push({type:"group",right:"10.5%",top:u.top+"%",children:d})}),l}}class si{static format(t,e){if(!t||t.length===0)return"";const i=e.title||"",s=e.upColor||"#00da3c",a=e.downColor||"#ec0000",n=e.fontFamily||"sans-serif",l=t[0].axisValue;let r=`<div style="font-weight: bold; margin-bottom: 5px; color: #cbd5e1; font-family: ${n};">${l}</div>`;const o=t.find(d=>d.seriesType==="candlestick"),u=t.filter(d=>d.seriesType!=="candlestick");if(o){const[d,c,g,h,f]=o.value,y=g>=c?s:a;r+=`
17
+ import*as D from"echarts";var ti=Object.defineProperty,ei=(h,t,e)=>t in h?ti(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,vt=(h,t,e)=>(ei(h,typeof t!="symbol"?t+"":t,e),e);class ii{constructor(t,e,i,s={}){vt(this,"id"),vt(this,"plots"),vt(this,"paneIndex"),vt(this,"height"),vt(this,"collapsed"),vt(this,"titleColor"),vt(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 r=new Map;i.data?.forEach(n=>{r.set(n.time,n)}),s.data?.forEach(n=>{r.set(n.time,n)}),i.data=Array.from(r.values()).sort((n,l)=>n.time-l.time)}})}}class V{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 Ut{static calculate(t,e,i,s=!1,r=null,n,l){let a=0;t>0&&(a=1/t*100);const o=i.yAxisPadding!==void 0?i.yAxisPadding:5,d=i.grid?.show===!0,u=i.grid?.lineColor??"#334155",c=i.grid?.lineOpacity??.5,g=i.grid?.borderColor??"#334155",p=i.grid?.borderShow===!0,y=i.layout?.left??"10%",f=i.layout?.right??"10%",x=Array.from(e.values()).map(z=>z.paneIndex).filter(z=>z>0).sort((z,Z)=>z-Z).filter((z,Z,q)=>q.indexOf(z)===Z),m=x.length>0,S=i.dataZoom?.visible??!0,v=i.dataZoom?.position??"top",I=i.dataZoom?.height??6,b=i.dataZoom?.start??0,C=i.dataZoom?.end??100;let w=8,k=92,A=-1;if(r)if(r==="main")A=0;else{const z=e.get(r);z&&(A=z.paneIndex)}if(A!==-1){const z=[],Z=[],q=[],tt=[],ot=i.dataZoom?.start??50,kt=i.dataZoom?.end??100;(i.dataZoom?.zoomOnTouch??!0)&&tt.push({type:"inside",xAxisIndex:"all",start:ot,end:kt,filterMode:"weakFilter"});const H=m?Math.max(...x):0,U=[];for(let N=0;N<=H;N++){const J=N===A;z.push({left:y,right:f,top:J?"5%":"0%",height:J?"90%":"0%",show:J,containLabel:!1}),Z.push({type:"category",gridIndex:N,data:[],show:J,axisLabel:{show:J,color:"#94a3b8",fontFamily:i.fontFamily},axisLine:{show:J&&p,lineStyle:{color:g}},splitLine:{show:J&&d,lineStyle:{color:u,opacity:c}}});let $t,Gt;if(N===0&&A===0?($t=i.yAxisMin!==void 0&&i.yAxisMin!=="auto"?i.yAxisMin:V.createMinFunction(o),Gt=i.yAxisMax!==void 0&&i.yAxisMax!=="auto"?i.yAxisMax:V.createMaxFunction(o)):($t=V.createMinFunction(o),Gt=V.createMaxFunction(o)),q.push({position:"right",gridIndex:N,show:J,scale:!0,min:$t,max:Gt,axisLabel:{show:J,color:"#94a3b8",fontFamily:i.fontFamily,formatter:yt=>{if(i.yAxisLabelFormatter)return i.yAxisLabelFormatter(yt);const zt=i.yAxisDecimalPlaces!==void 0?i.yAxisDecimalPlaces:V.autoDetectDecimals(n);return V.formatValue(yt,zt)}},splitLine:{show:J&&d,lineStyle:{color:u,opacity:c}}}),N>0){const yt=Array.from(e.values()).find(zt=>zt.paneIndex===N);yt&&U.push({index:N,height:J?90:0,top:J?5:0,isCollapsed:!1,indicatorId:yt.id,titleColor:yt.titleColor,controls:yt.controls})}}return{grid:z,xAxis:Z,yAxis:q,dataZoom:tt,paneLayout:U,mainPaneHeight:A===0?90:0,mainPaneTop:A===0?5:0,pixelToPercent:a,overlayYAxisMap:new Map,separatePaneYAxisOffset:1}}S?v==="top"?(w=I+4,k=95):(k=100-I-2,w=8):(w=5,k=95);let $=5;t>0&&($=20/t*100);let _=75,E;if(i.layout?.mainPaneHeight!==void 0){const z=i.layout.mainPaneHeight;if(typeof z=="string"){const Z=parseFloat(z);isNaN(Z)||(E=Z)}else typeof z=="number"&&(E=z)}let L=[];if(m){const z=x.map(H=>{const U=Array.from(e.values()).find(N=>N.paneIndex===H);return{index:H,requestedHeight:U?.height,isCollapsed:U?.collapsed??!1,indicatorId:U?.id,titleColor:U?.titleColor,controls:U?.controls}}).map(H=>({...H,rawHeight:H.isCollapsed?3:H.requestedHeight!==void 0?H.requestedHeight:15})),Z=k-w,q=z.length*$;if(l!==void 0&&l>0&&!s)_=l;else if(s)_=3;else if(E!==void 0&&E>0)_=E;else{const H=z.reduce((U,N)=>U+N.rawHeight,0);_=Z-H-q,_<20&&(_=Math.max(_,10))}const tt=l!==void 0&&l>0&&!s||E!==void 0&&E>0&&!s;let ot;if(tt){const H=Z-_-q,U=z.filter(N=>!N.isCollapsed).reduce((N,J)=>N+J.rawHeight,0);ot=z.map(N=>({...N,height:N.isCollapsed?3:U>0?Math.max(5,N.rawHeight/U*H):H/z.filter(J=>!J.isCollapsed).length}))}else ot=z.map(H=>({...H,height:H.rawHeight}));let kt=w+_+$;L=ot.map(H=>{const U={index:H.index,height:H.height,top:kt,isCollapsed:H.isCollapsed,indicatorId:H.indicatorId,titleColor:H.titleColor,controls:H.controls};return kt+=H.height+$,U})}else _=k-w,s&&(_=3);const P=[];if(L.length>0){P.push({yPercent:w+_+$/2,aboveId:"main",belowId:L[0].indicatorId||""});for(let z=0;z<L.length-1;z++)P.push({yPercent:L[z].top+L[z].height+$/2,aboveId:L[z].indicatorId||"",belowId:L[z+1].indicatorId||""})}const G=[];G.push({left:y,right:f,top:w+"%",height:_+"%",containLabel:!1}),L.forEach(z=>{G.push({left:y,right:f,top:z.top+"%",height:z.height+"%",containLabel:!1})});const M=[0,...L.map((z,Z)=>Z+1)],F=[],T=L.length===0;F.push({type:"category",data:[],gridIndex:0,scale:!0,axisLine:{onZero:!1,show:!s&&p,lineStyle:{color:g}},splitLine:{show:!s&&d,lineStyle:{color:u,opacity:c}},axisLabel:{show:!s,color:"#94a3b8",fontFamily:i.fontFamily||"sans-serif",formatter:z=>{if(i.yAxisLabelFormatter)return i.yAxisLabelFormatter(z);const Z=i.yAxisDecimalPlaces!==void 0?i.yAxisDecimalPlaces:V.autoDetectDecimals(n);return V.formatValue(z,Z)}},axisTick:{show:!s},axisPointer:{label:{show:T,fontSize:11,backgroundColor:"#475569"}}}),L.forEach((z,Z)=>{const q=Z===L.length-1;F.push({type:"category",gridIndex:Z+1,data:[],axisLabel:{show:!1},axisLine:{show:!z.isCollapsed&&p,lineStyle:{color:g}},axisTick:{show:!1},splitLine:{show:!1},axisPointer:{label:{show:q,fontSize:11,backgroundColor:"#475569"}}})});const Y=[];let O,B;i.yAxisMin!==void 0&&i.yAxisMin!=="auto"?O=i.yAxisMin:O=V.createMinFunction(o),i.yAxisMax!==void 0&&i.yAxisMax!=="auto"?B=i.yAxisMax:B=V.createMaxFunction(o),Y.push({position:"right",scale:!0,min:O,max:B,gridIndex:0,splitLine:{show:!s&&d,lineStyle:{color:u,opacity:c}},axisLine:{show:!s&&p,lineStyle:{color:g}},axisLabel:{show:!s,color:"#94a3b8",fontFamily:i.fontFamily||"sans-serif",formatter:z=>{if(i.yAxisLabelFormatter)return i.yAxisLabelFormatter(z);const Z=i.yAxisDecimalPlaces!==void 0?i.yAxisDecimalPlaces:V.autoDetectDecimals(n);return V.formatValue(z,Z)}}});let j=1,R=-1/0,nt=1/0;n&&n.length>0&&(R=Math.min(...n.map(z=>z.low)),nt=Math.max(...n.map(z=>z.high)));const K=new Map;e.forEach((z,Z)=>{z.paneIndex===0&&!z.collapsed&&n&&n.length>0&&Object.entries(z.plots).forEach(([q,tt])=>{const ot=`${Z}::${q}`,kt=["background","barcolor","char"],H=tt.options.style==="shape"&&(tt.options.location==="abovebar"||tt.options.location==="AboveBar"||tt.options.location==="belowbar"||tt.options.location==="BelowBar");if(kt.includes(tt.options.style)){K.has(ot)||(K.set(ot,j),j++);return}if(tt.options.style==="shape"&&!H){K.has(ot)||(K.set(ot,j),j++);return}const U=[];if(tt.data&&Object.values(tt.data).forEach(N=>{typeof N=="number"&&!isNaN(N)&&isFinite(N)&&U.push(N)}),U.length>0){const N=Math.min(...U),J=Math.max(...U),$t=J-N,Gt=nt-R,yt=N>=R*.5&&J<=nt*1.5,zt=$t>Gt*.01;yt&&zt||K.has(ot)||(K.set(ot,j),j++)}})});const gt=K.size>0?j-1:0,Ht=new Set;K.forEach((z,Z)=>{e.forEach(q=>{Object.entries(q.plots).forEach(([tt,ot])=>{`${q.id}::${tt}`===Z&&["background","barcolor","char"].includes(ot.options.style)&&Ht.add(z)})})});for(let z=0;z<gt;z++){const Z=z+1,q=Ht.has(Z);Y.push({position:"left",scale:!q,min:q?0:V.createMinFunction(o),max:q?1:V.createMaxFunction(o),gridIndex:0,show:!1,splitLine:{show:!1},axisLine:{show:!1},axisLabel:{show:!1}})}const qt=j;L.forEach((z,Z)=>{Y.push({position:"right",scale:!0,min:V.createMinFunction(o),max:V.createMaxFunction(o),gridIndex:Z+1,splitLine:{show:!z.isCollapsed&&d,lineStyle:{color:u,opacity:c*.6}},axisLabel:{show:!z.isCollapsed,color:"#94a3b8",fontFamily:i.fontFamily||"sans-serif",fontSize:10,formatter:q=>{if(i.yAxisLabelFormatter)return i.yAxisLabelFormatter(q);const tt=i.yAxisDecimalPlaces!==void 0?i.yAxisDecimalPlaces:V.autoDetectDecimals(n);return V.formatValue(q,tt)}},axisLine:{show:!z.isCollapsed&&p,lineStyle:{color:g}}})});const bt=[],Rt=i.dataZoom?.zoomOnTouch??!0,Qe=i.dataZoom?.pannable??!0;return Rt&&Qe&&bt.push({type:"inside",xAxisIndex:M,start:b,end:C,filterMode:"weakFilter"}),S&&(v==="top"?bt.push({type:"slider",xAxisIndex:M,top:"1%",height:I+"%",start:b,end:C,borderColor:"#334155",textStyle:{color:"#cbd5e1"},brushSelect:!1,filterMode:"weakFilter"}):bt.push({type:"slider",xAxisIndex:M,bottom:"1%",height:I+"%",start:b,end:C,borderColor:"#334155",textStyle:{color:"#cbd5e1"},brushSelect:!1,filterMode:"weakFilter"})),{grid:G,xAxis:F,yAxis:Y,dataZoom:bt,paneLayout:L,mainPaneHeight:_,mainPaneTop:w,pixelToPercent:a,paneBoundaries:P,overlayYAxisMap:K,separatePaneYAxisOffset:qt}}static calculateMaximized(t,e,i){return{grid:[],xAxis:[],yAxis:[],dataZoom:[],paneLayout:[],mainPaneHeight:0,mainPaneTop:0,pixelToPercent:0,paneBoundaries:[]}}}class si{render(t){const{seriesName:e,xAxisIndex:i,yAxisIndex:s,dataArray:r,colorArray:n,plotOptions:l}=t,a="#2962ff";return{name:e,type:"custom",xAxisIndex:i,yAxisIndex:s,renderItem:(o,d)=>{const u=o.dataIndex;if(u===0)return;const c=d.value(1),g=d.value(2);if(c===null||isNaN(c)||g===null||isNaN(g))return;const p=d.coord([u-1,g]),y=d.coord([u,c]);return{type:"line",shape:{x1:p[0],y1:p[1],x2:y[0],y2:y[1]},style:{stroke:n[u]||l.color||a,lineWidth:l.linewidth||1},silent:!0}},data:r.map((o,d)=>[d,o,d>0?r[d-1]:null])}}}class ni{render(t){const{seriesName:e,xAxisIndex:i,yAxisIndex:s,dataArray:r,colorArray:n,plotOptions:l}=t,a="#2962ff";return{name:e,type:"custom",xAxisIndex:i,yAxisIndex:s,renderItem:(o,d)=>{const u=d.value(0),c=d.value(1);if(isNaN(c)||c===null)return;const g=d.coord([u,c]),p=d.size([1,0])[0];return{type:"line",shape:{x1:g[0]-p/2,y1:g[1],x2:g[0]+p/2,y2:g[1]},style:{stroke:n[o.dataIndex]||l.color||a,lineWidth:l.linewidth||1},silent:!0}},data:r.map((o,d)=>[d,o])}}}class ae{render(t){const{seriesName:e,xAxisIndex:i,yAxisIndex:s,dataArray:r,colorArray:n,plotOptions:l}=t,a="#2962ff",o=l.histbase??0,d=l.style==="columns",u=l.linewidth??1,c=r.map((g,p)=>g==null||typeof g=="number"&&isNaN(g)?null:[p,g,n[p]||l.color||a]);return{name:e,type:"custom",xAxisIndex:i,yAxisIndex:s,renderItem:(g,p)=>{const y=p.value(0),f=p.value(1),x=p.value(2);if(f==null||isNaN(f))return null;const m=p.coord([y,o]),S=p.coord([y,f]),v=p.size([1,0])[0];let I;d?I=v*.6:I=Math.max(1,u);const b=m[0],C=m[1],w=S[1],k=Math.min(C,w),A=Math.abs(w-C);return{type:"rect",shape:{x:b-I/2,y:k,width:I,height:A||1},style:{fill:x}}},data:c.filter(g=>g!==null)}}}const Kt=new Map;function oi(h,t="#00da3c",e="64px"){if(typeof document>"u")return"";const i=`${h}-${t}-${e}`;if(Kt.has(i))return Kt.get(i);const s=document.createElement("canvas"),r=s.getContext("2d");if(s.width=32,s.height=32,r){r.font="bold "+e+" Arial",r.fillStyle=t,r.textAlign="center",r.textBaseline="middle",r.fillText(h,16,16);const n=s.toDataURL("image/png");return Kt.set(i,n),n}return""}class Jt{render(t){const{seriesName:e,xAxisIndex:i,yAxisIndex:s,dataArray:r,colorArray:n,plotOptions:l}=t,a="#2962ff",o=l.style;if(o==="char")return{name:e,type:"scatter",xAxisIndex:i,yAxisIndex:s,symbolSize:0,data:r.map((u,c)=>({value:[c,u],itemStyle:{opacity:0}})),silent:!0};const d=r.map((u,c)=>{if(u===null)return null;const g=n[c]||l.color||a,p={value:[c,u],itemStyle:{color:g}};return o==="cross"?(p.symbol=`image://${oi("+",g,"24px")}`,p.symbolSize=16):(p.symbol="circle",p.symbolSize=6),p}).filter(u=>u!==null);return{name:e,type:"scatter",xAxisIndex:i,yAxisIndex:s,data:d}}}class le{render(t){const{seriesName:e,xAxisIndex:i,yAxisIndex:s,dataArray:r,colorArray:n,optionsArray:l,plotOptions:a}=t,o="#2962ff",d=a.style==="candle",u=[],c=r.map((g,p)=>{if(g===null||!Array.isArray(g)||g.length!==4)return null;const[y,f,x,m]=g,S=l[p]||{},v=S.color||n[p]||a.color||o,I=S.wickcolor||a.wickcolor||v,b=S.bordercolor||a.bordercolor||I;return u[p]={color:v,wickColor:I,borderColor:b},[p,y,m,x,f]}).filter(g=>g!==null);return{name:e,type:"custom",xAxisIndex:i,yAxisIndex:s,renderItem:(g,p)=>{const y=p.value(0),f=p.value(1),x=p.value(2),m=p.value(3),S=p.value(4);if(isNaN(f)||isNaN(x)||isNaN(m)||isNaN(S))return null;const v=u[y]||{color:o,wickColor:o,borderColor:o},I=v.color,b=v.wickColor,C=v.borderColor,w=p.coord([y,0])[0],k=p.coord([y,f])[1],A=p.coord([y,x])[1],$=p.coord([y,m])[1],_=p.coord([y,S])[1],E=p.size([1,0])[0]*.6;if(d){const L=Math.min(k,A),P=Math.max(k,A),G=Math.abs(A-k);return{type:"group",children:[{type:"line",shape:{x1:w,y1:_,x2:w,y2:L},style:{stroke:b,lineWidth:1}},{type:"line",shape:{x1:w,y1:P,x2:w,y2:$},style:{stroke:b,lineWidth:1}},{type:"rect",shape:{x:w-E/2,y:L,width:E,height:G||1},style:{fill:I,stroke:C,lineWidth:1}}]}}else{const L=E*.5;return{type:"group",children:[{type:"line",shape:{x1:w,y1:$,x2:w,y2:_},style:{stroke:I,lineWidth:1}},{type:"line",shape:{x1:w-L,y1:k,x2:w,y2:k},style:{stroke:I,lineWidth:1}},{type:"line",shape:{x1:w,y1:A,x2:w+L,y2:A},style:{stroke:I,lineWidth:1}}]}}},data:c}}}class It{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 ri{render(t){const{seriesName:e,xAxisIndex:i,yAxisIndex:s,dataArray:r,colorArray:n,optionsArray:l,plotOptions:a,candlestickData:o}=t,d="#2962ff",u=r.map((c,g)=>{const p=l[g]||{},y=a,f=p.location||y.location||"absolute";if(f!=="absolute"&&f!=="Absolute"&&!c||c==null)return null;const x=p.color||y.color||d,m=p.shape||y.shape||"circle",S=p.size||y.size||"normal",v=p.text||y.text,I=p.textcolor||y.textcolor||"white",b=p.width||y.width,C=p.height||y.height;let w=c,k=[0,0];f==="abovebar"||f==="AboveBar"||f==="ab"?(o&&o[g]&&(w=o[g].high),k=[0,"-150%"]):f==="belowbar"||f==="BelowBar"||f==="bl"?(o&&o[g]&&(w=o[g].low),k=[0,"150%"]):f==="top"||f==="Top"?(w=c,k=[0,0]):(f==="bottom"||f==="Bottom")&&(w=c,k=[0,0]);const A=It.getShapeSymbol(m),$=It.getShapeSize(S,b,C),_=It.getShapeRotation(m);let E=$;m.includes("label")&&(Array.isArray($)?E=[$[0]*2.5,$[1]*2.5]:E=$*2.5);const L=It.getLabelConfig(m,f);return{value:[g,w],symbol:A,symbolSize:E,symbolRotate:_,symbolOffset:k,itemStyle:{color:x},label:{show:!!v,position:L.position,distance:L.distance,formatter:v,color:I,fontSize:10,fontWeight:"bold"}}}).filter(c=>c!==null);return{name:e,type:"scatter",xAxisIndex:i,yAxisIndex:s,data:u}}}class at{static parseColor(t){if(!t||typeof t!="string")return{color:"#888888",opacity:.2};const e=t.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?\)/);if(e){const s=e[1],r=e[2],n=e[3],l=e[4]?parseFloat(e[4]):1;return{color:`rgb(${s},${r},${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),r=parseInt(i[2],16),n=parseInt(i[3],16),l=parseInt(i[4],16)/255;return{color:`rgb(${s},${r},${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),a=parseInt(s[3],16);return`rgba(${n},${l},${a},${e})`}const r=t.match(/^#([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/);if(r){const n=parseInt(r[1],16),l=parseInt(r[2],16),a=parseInt(r[3],16);return`rgba(${n},${l},${a},${e})`}return t}}class ai{render(t){const{seriesName:e,xAxisIndex:i,yAxisIndex:s,dataArray:r,colorArray:n}=t,l=[];for(let a=0;a<n.length;a++)l[a]=n[a]?at.parseColor(n[a]):{color:"",opacity:0};return{name:e,type:"custom",xAxisIndex:i,yAxisIndex:s,z:-10,renderItem:(a,o)=>{const d=o.value(0);if(isNaN(d))return;const u=o.coord([d,.5]),c=o.size([1,0])[0],g=a.coordSys,p=u[0]-c/2,y=n[a.dataIndex],f=o.value(1);if(!y||f===null||f===void 0||isNaN(f))return;const x=l[a.dataIndex];if(!(!x||x.opacity<=0))return{type:"rect",shape:{x:p,y:g.y,width:c,height:g.height},style:{fill:x.color,opacity:x.opacity},silent:!0}},data:r.map((a,o)=>[o,a!=null&&!isNaN(a)?.5:null])}}}class he{render(t){const{seriesName:e,xAxisIndex:i,yAxisIndex:s,plotOptions:r,plotDataArrays:n,indicatorId:l,plotName:a,optionsArray:o}=t,d=t.dataArray.length,u=r.plot1?`${l}::${r.plot1}`:null,c=r.plot2?`${l}::${r.plot2}`:null;if(!u||!c)return console.warn(`Fill plot "${a}" missing plot1 or plot2 reference`),null;const g=n?.get(u),p=n?.get(c);if(!g||!p)return console.warn(`Fill plot "${a}" references non-existent plots: ${r.plot1}, ${r.plot2}`),null;if(r.gradient===!0)return this.renderGradientFill(e,i,s,g,p,d,o,r);const{color:y,opacity:f}=at.parseColor(r.color||"rgba(128, 128, 128, 0.2)"),x=o?.some(v=>v&&v.color!==void 0);let m=null;if(x){m=[];for(let v=0;v<d;v++){const I=o?.[v];I&&I.color!==void 0?m[v]=at.parseColor(I.color):m[v]={color:y,opacity:f}}}const S=[];for(let v=0;v<d;v++){const I=g[v],b=p[v],C=v>0?g[v-1]:null,w=v>0?p[v-1]:null;S.push([v,I,b,C,w])}return{name:e,type:"custom",xAxisIndex:i,yAxisIndex:s,z:1,clip:!0,encode:{x:0},animation:!1,renderItem:(v,I)=>{const b=v.dataIndex;if(b===0)return null;const C=I.value(1),w=I.value(2),k=I.value(3),A=I.value(4);if(C===null||w===null||k===null||A===null||isNaN(C)||isNaN(w)||isNaN(k)||isNaN(A))return null;const $=m?m[b]:null,_=$?$.opacity:f;if(_<.01)return null;const E=I.coord([b-1,k]),L=I.coord([b,C]),P=I.coord([b,w]),G=I.coord([b-1,A]);return{type:"polygon",shape:{points:[E,L,P,G]},style:{fill:$?$.color:y,opacity:_},silent:!0}},data:S,silent:!0}}renderBatched(t,e,i,s,r){const n=Array.from({length:s},(l,a)=>[a]);return{name:t,type:"custom",xAxisIndex:e,yAxisIndex:i,z:1,clip:!0,encode:{x:0},animation:!1,renderItem:(l,a)=>{const o=l.dataIndex;if(o===0)return null;const d=[];for(let u=0;u<r.length;u++){const c=r[u],g=c.plot1Data[o],p=c.plot2Data[o],y=c.plot1Data[o-1],f=c.plot2Data[o-1];if(g==null||p==null||y==null||f==null||isNaN(g)||isNaN(p)||isNaN(y)||isNaN(f))continue;const x=c.barColors[o];if(!x||x.opacity<.01)continue;const m=a.coord([o-1,y]),S=a.coord([o,g]),v=a.coord([o,p]),I=a.coord([o-1,f]);d.push({type:"polygon",shape:{points:[m,S,v,I]},style:{fill:x.color,opacity:x.opacity},silent:!0})}return d.length>0?{type:"group",children:d,silent:!0}:null},data:n,silent:!0}}renderGradientFill(t,e,i,s,r,n,l,a){const o=[];for(let u=0;u<n;u++){const c=l?.[u];if(c&&c.top_color!==void 0){const g=at.parseColor(c.top_color),p=at.parseColor(c.bottom_color);o[u]={topColor:g.color,topOpacity:g.opacity,bottomColor:p.color,bottomOpacity:p.opacity}}else o[u]={topColor:"rgba(128,128,128,0.2)",topOpacity:.2,bottomColor:"rgba(128,128,128,0.2)",bottomOpacity:.2}}const d=[];for(let u=0;u<n;u++){const c=s[u],g=r[u],p=u>0?s[u-1]:null,y=u>0?r[u-1]:null;d.push([u,c,g,p,y])}return{name:t,type:"custom",xAxisIndex:e,yAxisIndex:i,z:1,clip:!0,encode:{x:0},animation:!1,renderItem:(u,c)=>{const g=u.dataIndex;if(g===0)return null;const p=c.value(1),y=c.value(2),f=c.value(3),x=c.value(4);if(p===null||y===null||f===null||x===null||isNaN(p)||isNaN(y)||isNaN(f)||isNaN(x))return null;const m=c.coord([g-1,f]),S=c.coord([g,p]),v=c.coord([g,y]),I=c.coord([g-1,x]),b=o[g]||o[g-1];if(!b||b.topOpacity<.01&&b.bottomOpacity<.01)return null;const C=at.toRgba(b.topColor,b.topOpacity),w=at.toRgba(b.bottomColor,b.bottomOpacity),k=p>=y;return{type:"polygon",shape:{points:[m,S,v,I]},style:{fill:{type:"linear",x:0,y:0,x2:0,y2:1,colorStops:[{offset:0,color:k?C:w},{offset:1,color:k?w:C}]}},silent:!0}},data:d,silent:!0}}}class li{render(t){const{seriesName:e,xAxisIndex:i,yAxisIndex:s,dataArray:r,candlestickData:n,dataIndexOffset:l}=t,a=l||0,o=[];for(let u=0;u<r.length;u++){const c=r[u];if(!c)continue;const g=Array.isArray(c)?c:[c];for(const p of g)p&&typeof p=="object"&&!p._deleted&&o.push(p)}const d=o.map(u=>{const c=T=>typeof T=="function"?T():T,g=c(u.text)||"",p=c(u.color),y=p!=null&&p!==""?p:"transparent",f=c(u.textcolor)||"#ffffff",x=c(u.yloc)||"price",m=c(u.style)||"style_label_down",S=c(u.size)||"normal",v=c(u.textalign)||"align_center",I=c(u.tooltip)||"",b=this.styleToShape(m),C=u.xloc==="bar_index"||u.xloc==="bi"?u.x+a:u.x;let w=u.y,k=[0,0];x==="abovebar"||x==="AboveBar"||x==="ab"?(n&&n[C]&&(w=n[C].high),k=[0,"-150%"]):(x==="belowbar"||x==="BelowBar"||x==="bl")&&(n&&n[C]&&(w=n[C].low),k=[0,"150%"]);const A=It.getShapeSymbol(b),$=It.getShapeSize(S),_=this.getSizePx(S);let E;const L=b==="labeldown"||b==="shape_label_down"||b==="labelup"||b==="shape_label_up"||b==="labelleft"||b==="labelright";let P=[0,0];if(L){const T=g.length*_*.65,Y=_*2.5,O=Math.max(Y,T+_*1.6),B=_*2.8,j=3/24;if(b==="labelleft"||b==="labelright"){const R=O/(1-j);E=[R,B];const nt=typeof k[0]=="string"?0:k[0];b==="labelleft"?(k=[nt+R*.42,k[1]],P=[R*j*.5,0]):(k=[nt-R*.42,k[1]],P=[-R*j*.5,0])}else{const R=B/(1-j);E=[O,R],b==="labeldown"?(k=[k[0],typeof k[1]=="string"?k[1]:k[1]-R*.42],P=[0,-R*j*.5]):(k=[k[0],typeof k[1]=="string"?k[1]:k[1]+R*.42],P=[0,R*j*.5])}}else b==="none"?E=0:Array.isArray($)?E=[$[0]*1.5,$[1]*1.5]:E=$*1.5;const G=this.getLabelPosition(m,x),M=G==="inside"||G.startsWith("inside"),F={value:[C,w],symbol:A,symbolSize:E,symbolOffset:k,itemStyle:{color:y},label:{show:!!g,position:G,distance:M?0:5,offset:P,formatter:g,color:f,fontSize:_,fontWeight:"bold",align:M?"center":v==="align_left"||v==="left"?"left":v==="align_right"||v==="right"?"right":"center",verticalAlign:"middle",padding:[2,6]}};return I?(F._tooltipText=I,F.emphasis={scale:!1,itemStyle:{color:y},label:{show:F.label.show,color:f,fontSize:_,fontWeight:"bold"}}):F.emphasis={disabled:!0},F}).filter(u=>u!==null);return{name:e,type:"scatter",xAxisIndex:i,yAxisIndex:s,data:d,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 hi{render(t){const{seriesName:e,xAxisIndex:i,yAxisIndex:s,dataArray:r,dataIndexOffset:n}=t,l=n||0,a="#2962ff",o=[];for(let c=0;c<r.length;c++){const g=r[c];if(!g)continue;const p=Array.isArray(g)?g:[g];for(const y of p)y&&typeof y=="object"&&!y._deleted&&o.push(y)}if(o.length===0)return{name:e,type:"custom",xAxisIndex:i,yAxisIndex:s,data:[],silent:!0};const d=(t.candlestickData?.length||0)+l,u=Math.max(0,d-1);return{name:e,type:"custom",xAxisIndex:i,yAxisIndex:s,renderItem:(c,g)=>{const p=[];for(const y of o){if(y._deleted)continue;const f=y.xloc==="bar_index"||y.xloc==="bi"?l:0;let x=g.coord([y.x1+f,y.y1]),m=g.coord([y.x2+f,y.y2]);const S=y.extend||"none";if(S!=="none"&&S!=="n"){const C=c.coordSys;[x,m]=this.extendLine(x,m,S,C.x,C.x+C.width,C.y,C.y+C.height)}const v=y.color||a,I=y.width||1;p.push({type:"line",shape:{x1:x[0],y1:x[1],x2:m[0],y2:m[1]},style:{fill:"none",stroke:v,lineWidth:I,lineDash:this.getDashPattern(y.style)}});const b=y.style||"style_solid";if(b==="style_arrow_left"||b==="style_arrow_both"){const C=this.arrowHead(m,x,I,v);C&&p.push(C)}if(b==="style_arrow_right"||b==="style_arrow_both"){const C=this.arrowHead(x,m,I,v);C&&p.push(C)}}return{type:"group",children:p}},data:[[0,u]],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,r,n,l){const a=e[0]-t[0],o=e[1]-t[1];if(a===0&&o===0)return[t,e];const d=(g,p)=>{let y=1/0;if(p[0]!==0){const f=p[0]>0?(r-g[0])/p[0]:(s-g[0])/p[0];y=Math.min(y,f)}if(p[1]!==0){const f=p[1]>0?(l-g[1])/p[1]:(n-g[1])/p[1];y=Math.min(y,f)}return isFinite(y)||(y=0),[g[0]+y*p[0],g[1]+y*p[1]]};let u=t,c=e;return(i==="right"||i==="r"||i==="both"||i==="b")&&(c=d(t,[a,o])),(i==="left"||i==="l"||i==="both"||i==="b")&&(u=d(e,[-a,-o])),[u,c]}arrowHead(t,e,i,s){const r=e[0]-t[0],n=e[1]-t[1],l=Math.sqrt(r*r+n*n);if(l<1)return null;const a=Math.max(8,i*4),o=r/l,d=n/l,u=e[0]-o*a,c=e[1]-d*a,g=-d*a*.4,p=o*a*.4;return{type:"polygon",shape:{points:[[e[0],e[1]],[u+g,c+p],[u-g,c-p]]},style:{fill:s}}}}class ci{render(t){const{seriesName:e,xAxisIndex:i,yAxisIndex:s,dataArray:r,dataIndexOffset:n}=t,l=n||0,a=[];for(let u=0;u<r.length;u++){const c=r[u];if(!c)continue;const g=Array.isArray(c)?c:[c];for(const p of g){if(!p||typeof p!="object"||p._deleted)continue;const y=p.line1,f=p.line2;!y||!f||y._deleted||f._deleted||a.push(p)}}if(a.length===0)return{name:e,type:"custom",xAxisIndex:i,yAxisIndex:s,data:[],silent:!0};const o=(t.candlestickData?.length||0)+l,d=Math.max(0,o-1);return{name:e,type:"custom",xAxisIndex:i,yAxisIndex:s,renderItem:(u,c)=>{const g=[];for(const p of a){if(p._deleted)continue;const y=p.line1,f=p.line2;if(!y||!f||y._deleted||f._deleted)continue;const x=y.xloc==="bar_index"||y.xloc==="bi"?l:0,m=f.xloc==="bar_index"||f.xloc==="bi"?l:0;let S=c.coord([y.x1+x,y.y1]),v=c.coord([y.x2+x,y.y2]),I=c.coord([f.x1+m,f.y1]),b=c.coord([f.x2+m,f.y2]);const C=y.extend||"none",w=f.extend||"none";if(C!=="none"||w!=="none"){const $=u.coordSys,_=$.x,E=$.x+$.width,L=$.y,P=$.y+$.height;C!=="none"&&([S,v]=this.extendLine(S,v,C,_,E,L,P)),w!=="none"&&([I,b]=this.extendLine(I,b,w,_,E,L,P))}const{color:k,opacity:A}=at.parseColor(p.color||"rgba(128, 128, 128, 0.2)");g.push({type:"polygon",shape:{points:[S,v,b,I]},style:{fill:k,opacity:A},silent:!0})}return{type:"group",children:g}},data:[[0,d]],clip:!0,encode:{x:[0,1]},z:10,silent:!0,emphasis:{disabled:!0}}}extendLine(t,e,i,s,r,n,l){const a=e[0]-t[0],o=e[1]-t[1];if(a===0&&o===0)return[t,e];const d=(g,p)=>{let y=1/0;if(p[0]!==0){const f=p[0]>0?(r-g[0])/p[0]:(s-g[0])/p[0];y=Math.min(y,f)}if(p[1]!==0){const f=p[1]>0?(l-g[1])/p[1]:(n-g[1])/p[1];y=Math.min(y,f)}return isFinite(y)||(y=0),[g[0]+y*p[0],g[1]+y*p[1]]};let u=t,c=e;return(i==="right"||i==="both")&&(c=d(t,[a,o])),(i==="left"||i==="both")&&(u=d(e,[-a,-o])),[u,c]}}class di{render(t){const{seriesName:e,xAxisIndex:i,yAxisIndex:s,dataArray:r,dataIndexOffset:n}=t,l=n||0,a=[];for(let u=0;u<r.length;u++){const c=r[u];if(!c)continue;const g=Array.isArray(c)?c:[c];for(const p of g)p&&typeof p=="object"&&!p._deleted&&p.points&&p.points.length>=2&&a.push(p)}if(a.length===0)return{name:e,type:"custom",xAxisIndex:i,yAxisIndex:s,data:[],silent:!0};const o=(t.candlestickData?.length||0)+l,d=Math.max(0,o-1);return{name:e,type:"custom",xAxisIndex:i,yAxisIndex:s,renderItem:(u,c)=>{const g=[];for(const p of a){if(p._deleted)continue;const y=p.points;if(!y||y.length<2)continue;const f=p.xloc==="bi"||p.xloc==="bar_index",x=f?l:0,m=[];for(const C of y){const w=f?(C.index??0)+x:C.time??0,k=C.price??0;m.push(c.coord([w,k]))}if(m.length<2)continue;const S=p.line_color,v=S==null||typeof S=="number"&&isNaN(S)||S==="na"||S==="NaN"?null:S||"#2962ff",I=p.line_width||1,b=this.getDashPattern(p.line_style);if(p.fill_color&&p.fill_color!==""&&p.fill_color!=="na"){const{color:C,opacity:w}=at.parseColor(p.fill_color);if(p.curved){const k=this.buildCurvedPath(m,p.closed);g.push({type:"path",shape:{pathData:k+" Z"},style:{fill:C,opacity:w,stroke:"none"},silent:!0})}else g.push({type:"polygon",shape:{points:m},style:{fill:C,opacity:w,stroke:"none"},silent:!0})}if(v&&I>0)if(p.curved){const C=this.buildCurvedPath(m,p.closed);g.push({type:"path",shape:{pathData:C},style:{fill:"none",stroke:v,lineWidth:I,lineDash:b},silent:!0})}else{const C=p.closed?[...m,m[0]]:m;g.push({type:"polyline",shape:{points:C},style:{fill:"none",stroke:v,lineWidth:I,lineDash:b},silent:!0})}}return{type:"group",children:g}},data:[[0,d]],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 r=`M ${t[0][0]} ${t[0][1]}`;const n=a=>e?t[(a%i+i)%i]:a<0?t[0]:a>=i?t[i-1]:t[a],l=e?i:i-1;for(let a=0;a<l;a++){const o=n(a-1),d=n(a),u=n(a+1),c=n(a+2),g=d[0]+(u[0]-o[0])*s/3,p=d[1]+(u[1]-o[1])*s/3,y=u[0]-(c[0]-d[0])*s/3,f=u[1]-(c[1]-d[1])*s/3;r+=` C ${g} ${p}, ${y} ${f}, ${u[0]} ${u[1]}`}return e&&(r+=" Z"),r}getDashPattern(t){switch(t){case"style_dotted":return[2,2];case"style_dashed":return[6,4];default:return}}}function Qt(h){if(!h||typeof h!="string")return h;if(h.startsWith("#")){const t=h.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),r=parseInt(t.slice(6,8),16)/255;return`rgba(${e},${i},${s},${r.toFixed(3)})`}}return h}function pi(h){if(!h||typeof h!="string")return null;if(h.startsWith("#")){const e=h.slice(1);if(e.length>=6){const i=parseInt(e.slice(0,2),16),s=parseInt(e.slice(2,4),16),r=parseInt(e.slice(4,6),16);if(!isNaN(i)&&!isNaN(s)&&!isNaN(r))return{r:i,g:s,b:r}}if(e.length===3){const i=parseInt(e[0]+e[0],16),s=parseInt(e[1]+e[1],16),r=parseInt(e[2]+e[2],16);if(!isNaN(i)&&!isNaN(s)&&!isNaN(r))return{r:i,g:s,b:r}}return null}const t=h.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?{r:+t[1],g:+t[2],b:+t[3]}:null}function ui(h,t,e){return(.299*h+.587*t+.114*e)/255}class gi{render(t){const{seriesName:e,xAxisIndex:i,yAxisIndex:s,dataArray:r,dataIndexOffset:n}=t,l=n||0,a=[];for(let u=0;u<r.length;u++){const c=r[u];if(!c)continue;const g=Array.isArray(c)?c:[c];for(const p of g)p&&typeof p=="object"&&!p._deleted&&a.push(p)}if(a.length===0)return{name:e,type:"custom",xAxisIndex:i,yAxisIndex:s,data:[],silent:!0};const o=(t.candlestickData?.length||0)+l,d=Math.max(0,o-1);return{name:e,type:"custom",xAxisIndex:i,yAxisIndex:s,renderItem:(u,c)=>{const g=[];for(const p of a){if(p._deleted)continue;const y=p.xloc==="bar_index"||p.xloc==="bi"?l:0,f=c.coord([p.left+y,p.top]),x=c.coord([p.right+y,p.bottom]);let m=f[0],S=f[1],v=x[0]-f[0],I=x[1]-f[1];const b=p.extend||"none";if(b!=="none"&&b!=="n"){const _=u.coordSys;(b==="left"||b==="l"||b==="both"||b==="b")&&(m=_.x,v=b==="both"||b==="b"?_.width:x[0]-_.x),(b==="right"||b==="r"||b==="both"||b==="b")&&(b==="right"||b==="r")&&(v=_.x+_.width-f[0])}const C=p.bgcolor,w=C==null||typeof C=="number"&&isNaN(C)||C==="na"||C==="NaN"||C===""?null:Qt(C)||"#2962ff";w&&g.push({type:"rect",shape:{x:m,y:S,width:v,height:I},style:{fill:w,stroke:"none"}});const k=p.border_color,A=k==null||typeof k=="number"&&isNaN(k)||k==="na"||k==="NaN"?null:Qt(k)||"#2962ff",$=p.border_width??1;if($>0&&A&&g.push({type:"rect",shape:{x:m,y:S,width:v,height:I},style:{fill:"none",stroke:A,lineWidth:$,lineDash:this.getDashPattern(p.border_style)}}),p.text){const _=this.getTextX(m,v,p.text_halign),E=this.getTextY(S,I,p.text_valign);let L=Qt(p.text_color)||"#000000";if((!p.text_color||p.text_color==="#000000"||p.text_color==="black"||p.text_color==="color.black")&&w){const M=pi(w);M&&ui(M.r,M.g,M.b)<.5&&(L="#FFFFFF")}const P=!p.text_formatting||p.text_formatting==="format_none"||p.text_formatting==="format_bold",G=this.computeFontSize(p.text_size,p.text,Math.abs(v),Math.abs(I),P);g.push({type:"text",style:{x:_,y:E,text:p.text,fill:L,fontSize:G,fontFamily:p.text_font_family==="monospace"?"monospace":"sans-serif",fontWeight:P?"bold":"normal",fontStyle:p.text_formatting==="format_italic"?"italic":"normal",textAlign:this.mapHAlign(p.text_halign),textVerticalAlign:this.mapVAlign(p.text_valign)}})}}return{type:"group",children:g}},data:[[0,d]],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,r){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,a=s-n*2;if(l<=0||a<=0)return 6;const o=e.split(`
18
+ `),d=o.length;let u=1;for(const y of o)y.length>u&&(u=y.length);const c=l/(u*(r?.62:.55)),g=a/(d*1.3),p=Math.min(c,g);return Math.max(6,Math.min(p,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 yi=Object.defineProperty,fi=(h,t,e)=>t in h?yi(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,xi=(h,t,e)=>(fi(h,typeof t!="symbol"?t+"":t,e),e);const Q=class{static register(t,e){this.renderers.set(t,e)}static get(t){return this.renderers.get(t)||this.renderers.get("line")}};xi(Q,"renderers",new Map),Q.register("line",new si),Q.register("step",new ni),Q.register("histogram",new ae),Q.register("columns",new ae),Q.register("circles",new Jt),Q.register("cross",new Jt),Q.register("char",new Jt),Q.register("bar",new le),Q.register("candle",new le),Q.register("shape",new ri),Q.register("background",new ai),Q.register("fill",new he),Q.register("label",new li),Q.register("drawing_line",new hi),Q.register("linefill",new ci),Q.register("drawing_polyline",new di),Q.register("drawing_box",new gi);let mi=Q;var bi=Object.defineProperty,vi=(h,t,e)=>t in h?bi(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,wi=(h,t,e)=>(vi(h,typeof t!="symbol"?t+"":t,e),e);const ce=class re{static buildCandlestickSeries(t,e,i){const s=e.upColor||"#00da3c",r=e.downColor||"#ec0000",n=t.map(a=>[a.open,a.close,a.low,a.high]);if(i&&i>n.length){const a=i-n.length;for(let o=0;o<a;o++)n.push(null)}let l;if(e.lastPriceLine?.visible!==!1&&t.length>0){const a=t[t.length-1],o=a.close,d=a.close>=a.open,u=e.lastPriceLine?.color||(d?s:r);let c=e.lastPriceLine?.lineStyle||"dashed";c.startsWith("linestyle_")&&(c=c.replace("linestyle_",""));const g=e.yAxisDecimalPlaces!==void 0?e.yAxisDecimalPlaces:V.autoDetectDecimals(t);l={symbol:["none","none"],precision:g,data:[{yAxis:o,label:{show:!0,position:"end",formatter:p=>e.yAxisLabelFormatter?e.yAxisLabelFormatter(p.value):V.formatValue(p.value,g),color:"#fff",backgroundColor:u,padding:[2,4],borderRadius:2,fontSize:11,fontWeight:"bold"},lineStyle:{color:u,type:c,width:1,opacity:.8}}],animation:!1,silent:!0}}return{type:"candlestick",id:"__candlestick__",name:e.title,data:n,itemStyle:{color:s,color0:r,borderColor:s,borderColor0:r},markLine:l,xAxisIndex:0,yAxisIndex:0,z:5}}static buildIndicatorSeries(t,e,i,s,r=0,n,l,a=1){const o=[],d=new Array(s).fill(null),u=new Map;return t.forEach((c,g)=>{if(c.collapsed)return;const p=Object.keys(c.plots).sort((f,x)=>{const m=c.plots[f],S=c.plots[x],v=m.options.style==="fill",I=S.options.style==="fill";return v&&!I?1:!v&&I?-1:0}),y=new Map;if(p.forEach(f=>{const x=c.plots[f],m=x.options.display==="none",S=`${g}::${f}`;let v=0,I=0,b=x.options.overlay;if(x.options.style==="fill"&&b===void 0){const _=x.options.plot1,E=x.options.plot2;if(_&&E){const L=c.plots[_],P=c.plots[E];L?.options?.overlay===!0&&P?.options?.overlay===!0&&(b=!0)}}if(c.paneIndex===0||b===!0)v=0,l&&l.has(S)?I=l.get(S):I=0;else{const _=i.findIndex(E=>E.index===c.paneIndex);_!==-1&&(v=_+1,I=a+_)}const C=new Array(s).fill(null),w=new Array(s).fill(null),k=new Array(s).fill(null),A=new Array(s).fill(null);if(x.data?.forEach(_=>{const E=e.get(_.time);if(E!==void 0){const L=_.options?.offset??x.options.offset??0,P=E+r+L;if(P>=0&&P<s){let G=_.value;const M=_.options?.color;w[P]=G;const F=_.options!=null&&"color"in _.options,T=M===null||M==="na"||M==="NaN"||typeof M=="number"&&isNaN(M)||F&&M===void 0;T&&(G=null),C[P]=G,k[P]=T?null:M||x.options.color||re.DEFAULT_COLOR,A[P]=_.options||{}}}}),u.set(`${g}::${f}`,w),m)return;if(x.options?.style?.startsWith("style_")&&(x.options.style=x.options.style.replace("style_","")),x.options.style==="barcolor"){x.data?.forEach(_=>{const E=e.get(_.time);if(E!==void 0){const L=_.options?.offset??x.options.offset??0,P=E+r+L;if(P>=0&&P<s){const G=_.options?.color||x.options.color||re.DEFAULT_COLOR;!(G===null||G==="na"||G==="NaN"||typeof G=="number"&&isNaN(G))&&_.value!==null&&_.value!==void 0&&(d[P]=G)}}});return}if(x.options.style==="table")return;if(x.options.style==="fill"&&x.options.gradient!==!0){const _=x.options.plot1?`${g}::${x.options.plot1}`:null,E=x.options.plot2?`${g}::${x.options.plot2}`:null;if(_&&E){const L=u.get(_),P=u.get(E);if(L&&P){const{color:G,opacity:M}=at.parseColor(x.options.color||"rgba(128, 128, 128, 0.2)"),F=A.some(O=>O&&O.color!==void 0),T=[];for(let O=0;O<s;O++){const B=A[O];F&&B&&B.color!==void 0?T[O]=at.parseColor(B.color):T[O]={color:G,opacity:M}}const Y=`${v}:${I}`;y.has(Y)||y.set(Y,{entries:[],xAxisIndex:v,yAxisIndex:I}),y.get(Y).entries.push({plot1Data:L,plot2Data:P,barColors:T});return}}}if(x.options.color&&typeof x.options.color=="string"&&at.parseColor(x.options.color).opacity<.01&&!k.some(_=>_==null?!1:at.parseColor(_).opacity>=.01))return;const $=mi.get(x.options.style).render({seriesName:S,xAxisIndex:v,yAxisIndex:I,dataArray:C,colorArray:k,optionsArray:A,plotOptions:x.options,candlestickData:n,plotDataArrays:u,indicatorId:g,plotName:f,dataIndexOffset:r});$&&o.push($)}),y.size>0){const f=new he;y.forEach(({entries:x,xAxisIndex:m,yAxisIndex:S},v)=>{if(x.length>=2){const I=f.renderBatched(`${g}::fills_batch_${v}`,m,S,s,x);I&&o.push(I)}else if(x.length===1){const I=f.renderBatched(`${g}::fills_batch_${v}`,m,S,s,x);I&&o.push(I)}})}}),{series:o,barColors:d}}};wi(ce,"DEFAULT_COLOR","#2962ff");let Dt=ce;class Ci{static build(t,e,i,s=!1,r=null,n=[]){const l=[],a=t.pixelToPercent,o=t.mainPaneTop;if(!r||r==="main"){const d=10*a;if(l.push({type:"text",left:"8.5%",top:o+d+"%",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*a,g=16*a;n.forEach((p,y)=>{l.push({type:"text",left:"8.5%",top:o+d+c+y*g+"%",z:10,style:{text:p.id,fill:p.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 u=[];if(e.controls?.collapse&&u.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=r==="main",g=e.controls?.collapse?25:0;u.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),u.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}]})}u.length>0&&l.push({type:"group",right:"10.5%",top:o+"%",children:u})}return t.paneLayout.forEach(d=>{if(r&&d.indicatorId!==r)return;l.push({type:"text",left:"8.5%",top:d.top+10*a+"%",z:10,style:{text:d.indicatorId||"",fill:d.titleColor||"#fff",font:`bold 12px ${e.fontFamily||"sans-serif"}`,textVerticalAlign:"top"}});const u=[];if(d.controls?.collapse&&u.push({type:"group",children:[{type:"rect",shape:{width:20,height:20,r:2},style:{fill:"#334155",stroke:"#475569",lineWidth:1},onclick:()=>d.indicatorId&&i(d.indicatorId,"collapse")},{type:"text",style:{text:d.isCollapsed?"+":"\u2212",fill:"#cbd5e1",font:`bold 14px ${e.fontFamily}`,x:10,y:10,textAlign:"center",textVerticalAlign:"middle"},silent:!0}]}),d.controls?.maximize){const c=r===d.indicatorId,g=d.controls?.collapse?25:0;u.push({type:"group",x:g,children:[{type:"rect",shape:{width:20,height:20,r:2},style:{fill:"#334155",stroke:"#475569",lineWidth:1},onclick:()=>d.indicatorId&&i(d.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}]})}u.length>0&&l.push({type:"group",right:"10.5%",top:d.top+"%",children:u})}),l}}class Pi{static format(t,e){if(!t||t.length===0)return"";const i=e.title||"",s=e.upColor||"#00da3c",r=e.downColor||"#ec0000",n=e.fontFamily||"sans-serif",l=t[0].axisValue;let a=`<div style="font-weight: bold; margin-bottom: 5px; color: #cbd5e1; font-family: ${n};">${l}</div>`;const o=t.find(u=>u.seriesType==="candlestick"),d=t.filter(u=>u.seriesType!=="candlestick");if(o){const[u,c,g,p,y]=o.value,f=g>=c?s:r;a+=`
19
19
  <div style="margin-bottom: 8px; font-family: ${n};">
20
- <div style="display:flex; justify-content:space-between; color:${y}; font-weight:bold;">
20
+ <div style="display:flex; justify-content:space-between; color:${f}; font-weight:bold;">
21
21
  <span>${i}</span>
22
22
  </div>
23
23
  <div style="display: grid; grid-template-columns: auto auto; gap: 2px 15px; font-size: 0.9em; color: #cbd5e1;">
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>
24
+ <span>Open:</span> <span style="text-align: right; color: ${g>=c?s:r}">${c}</span>
25
+ <span>High:</span> <span style="text-align: right; color: ${s}">${y}</span>
26
+ <span>Low:</span> <span style="text-align: right; color: ${r}">${p}</span>
27
+ <span>Close:</span> <span style="text-align: right; color: ${g>=c?s:r}">${g}</span>
28
28
  </div>
29
29
  </div>
30
- `}if(u.length>0){r+='<div style="border-top: 1px solid #334155; margin: 5px 0; padding-top: 5px;"></div>';const d={};u.forEach(c=>{const g=c.seriesName.split("::"),h=g.length>1?g[0]:"Unknown",f=g.length>1?g[1]:c.seriesName;d[h]||(d[h]=[]),d[h].push({...c,displayName:f})}),Object.keys(d).forEach(c=>{r+=`
30
+ `}if(d.length>0){a+='<div style="border-top: 1px solid #334155; margin: 5px 0; padding-top: 5px;"></div>';const u={};d.forEach(c=>{const g=c.seriesName.split("::"),p=g.length>1?g[0]:"Unknown",y=g.length>1?g[1]:c.seriesName;u[p]||(u[p]=[]),u[p].push({...c,displayName:y})}),Object.keys(u).forEach(c=>{a+=`
31
31
  <div style="margin-top: 8px; font-family: ${n};">
32
32
  <div style="font-weight:bold; color: #fff; margin-bottom: 2px;">${c}</div>
33
- `,d[c].forEach(g=>{let h=g.value;if(Array.isArray(h)&&(h=h[1]),h==null)return;const f=typeof h=="number"?h.toLocaleString(void 0,{maximumFractionDigits:4}):h;r+=`
33
+ `,u[c].forEach(g=>{let p=g.value;if(Array.isArray(p)&&(p=p[1]),p==null)return;const y=typeof p=="number"?p.toLocaleString(void 0,{maximumFractionDigits:4}):p;a+=`
34
34
  <div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 2px; padding-left: 8px;">
35
35
  <div>${g.marker} <span style="color: #cbd5e1;">${g.displayName}</span></div>
36
- <div style="font-size: 10px; color: #fff;padding-left:10px;">${f}</div>
37
- </div>`}),r+="</div>"})}return r}}var ni=Object.defineProperty,oi=(p,t,e)=>t in p?ni(p,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):p[t]=e,Ct=(p,t,e)=>(oi(p,typeof t!="symbol"?t+"":t,e),e);class ai{constructor(t,e){Ct(this,"plugins",new Map),Ct(this,"activePluginId",null),Ct(this,"context"),Ct(this,"toolbarContainer"),Ct(this,"tooltipElement",null),Ct(this,"hideTimeout",null),this.context=t,this.toolbarContainer=e,this.createTooltip(),this.renderToolbar()}createTooltip(){this.tooltipElement=document.createElement("div"),Object.assign(this.tooltipElement.style,{position:"fixed",display:"none",backgroundColor:"#1e293b",color:"#e2e8f0",padding:"6px 10px",borderRadius:"6px",fontSize:"13px",lineHeight:"1.4",fontWeight:"500",border:"1px solid #334155",zIndex:"9999",pointerEvents:"none",whiteSpace:"nowrap",boxShadow:"0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.15)",fontFamily:this.context.getOptions().fontFamily||"sans-serif",transition:"opacity 0.15s ease-in-out, transform 0.15s ease-in-out",opacity:"0",transform:"translateX(-5px)"}),document.body.appendChild(this.tooltipElement)}destroy(){this.tooltipElement&&this.tooltipElement.parentNode&&this.tooltipElement.parentNode.removeChild(this.tooltipElement),this.tooltipElement=null}showTooltip(t,e){if(!this.tooltipElement)return;this.hideTimeout&&(clearTimeout(this.hideTimeout),this.hideTimeout=null);const i=t.getBoundingClientRect();this.tooltipElement.textContent=e,this.tooltipElement.style.display="block";const s=this.tooltipElement.getBoundingClientRect(),a=i.top+(i.height-s.height)/2,n=i.right+10;this.tooltipElement.style.top=`${a}px`,this.tooltipElement.style.left=`${n}px`,requestAnimationFrame(()=>{this.tooltipElement&&(this.tooltipElement.style.opacity="1",this.tooltipElement.style.transform="translateX(0)")})}hideTooltip(){this.tooltipElement&&(this.tooltipElement.style.opacity="0",this.tooltipElement.style.transform="translateX(-5px)",this.hideTimeout&&clearTimeout(this.hideTimeout),this.hideTimeout=setTimeout(()=>{this.tooltipElement&&(this.tooltipElement.style.display="none"),this.hideTimeout=null},150))}register(t){if(this.plugins.has(t.id)){console.warn(`Plugin with id ${t.id} is already registered.`);return}this.plugins.set(t.id,t),t.init(this.context),this.addButton(t)}unregister(t){const e=this.plugins.get(t);e&&(this.activePluginId===t&&this.deactivatePlugin(),e.destroy?.(),this.plugins.delete(t),this.removeButton(t))}activatePlugin(t){if(this.activePluginId===t){this.deactivatePlugin();return}this.activePluginId&&this.deactivatePlugin();const e=this.plugins.get(t);e&&(this.activePluginId=t,this.setButtonActive(t,!0),e.activate?.())}deactivatePlugin(){this.activePluginId&&(this.plugins.get(this.activePluginId)?.deactivate?.(),this.setButtonActive(this.activePluginId,!1),this.activePluginId=null)}renderToolbar(){this.toolbarContainer.innerHTML="",this.toolbarContainer.classList.add("qfchart-toolbar"),this.toolbarContainer.style.display="flex",this.toolbarContainer.style.flexDirection="column",this.toolbarContainer.style.width="40px",this.toolbarContainer.style.backgroundColor=this.context.getOptions().backgroundColor||"#1e293b",this.toolbarContainer.style.borderRight="1px solid #334155",this.toolbarContainer.style.padding="5px",this.toolbarContainer.style.boxSizing="border-box",this.toolbarContainer.style.gap="5px",this.toolbarContainer.style.flexShrink="0"}addButton(t){const e=document.createElement("button");e.id=`qfchart-plugin-btn-${t.id}`,e.style.width="30px",e.style.height="30px",e.style.padding="4px",e.style.border="1px solid transparent",e.style.borderRadius="4px",e.style.backgroundColor="transparent",e.style.cursor="pointer",e.style.color=this.context.getOptions().fontColor||"#cbd5e1",e.style.display="flex",e.style.alignItems="center",e.style.justifyContent="center",t.icon?e.innerHTML=t.icon:e.innerText=(t.name||t.id).substring(0,2).toUpperCase(),e.addEventListener("mouseenter",()=>{this.activePluginId!==t.id&&(e.style.backgroundColor="rgba(255, 255, 255, 0.1)"),this.showTooltip(e,t.name||t.id)}),e.addEventListener("mouseleave",()=>{this.activePluginId!==t.id&&(e.style.backgroundColor="transparent"),this.hideTooltip()}),e.onclick=()=>this.activatePlugin(t.id),this.toolbarContainer.appendChild(e)}removeButton(t){const e=this.toolbarContainer.querySelector(`#qfchart-plugin-btn-${t}`);e&&e.remove()}setButtonActive(t,e){const i=this.toolbarContainer.querySelector(`#qfchart-plugin-btn-${t}`);i&&(e?(i.style.backgroundColor="#2563eb",i.style.color="#ffffff"):(i.style.backgroundColor="transparent",i.style.color=this.context.getOptions().fontColor||"#cbd5e1"))}}var ri=Object.defineProperty,li=(p,t,e)=>t in p?ri(p,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):p[t]=e,tt=(p,t,e)=>(li(p,typeof t!="symbol"?t+"":t,e),e);class hi{constructor(t){tt(this,"context"),tt(this,"isEditing",!1),tt(this,"currentDrawing",null),tt(this,"editingPointIndex",null),tt(this,"zr"),tt(this,"editGroup",null),tt(this,"editLines",[]),tt(this,"editPoints",[]),tt(this,"isMovingShape",!1),tt(this,"dragStart",null),tt(this,"initialPixelPoints",[]),tt(this,"onDrawingMouseDown",e=>{if(this.isEditing)return;const i=this.context.getDrawing(e.id);i&&(this.isEditing=!0,this.isMovingShape=!0,this.currentDrawing=JSON.parse(JSON.stringify(i)),this.dragStart={x:e.x,y:e.y},this.initialPixelPoints=i.points.map(s=>{const a=this.context.coordinateConversion.dataToPixel(s);return a?{x:a.x,y:a.y}:{x:0,y:0}}),this.context.lockChart(),this.createEditGraphic(),this.zr.on("mousemove",this.onMouseMove),this.zr.on("mouseup",this.onMouseUp),window.addEventListener("mouseup",this.onWindowMouseUp))}),tt(this,"onPointMouseDown",e=>{if(this.isEditing)return;const i=this.context.getDrawing(e.id);i&&(this.isEditing=!0,this.currentDrawing=JSON.parse(JSON.stringify(i)),this.editingPointIndex=e.pointIndex,this.initialPixelPoints=i.points.map(s=>{const a=this.context.coordinateConversion.dataToPixel(s);return a?{x:a.x,y:a.y}:{x:0,y:0}}),this.context.lockChart(),this.createEditGraphic(),this.zr.on("mousemove",this.onMouseMove),this.zr.on("mouseup",this.onMouseUp),window.addEventListener("mouseup",this.onWindowMouseUp))}),tt(this,"onMouseMove",e=>{if(!this.isEditing||!this.currentDrawing)return;const i=e.offsetX,s=e.offsetY;if(this.isMovingShape&&this.dragStart){const a=i-this.dragStart.x,n=s-this.dragStart.y,l=this.initialPixelPoints.map(r=>({x:r.x+a,y:r.y+n}));for(let r=0;r<this.editLines.length;r++)this.editLines[r].setShape({x1:l[r].x,y1:l[r].y,x2:l[r+1].x,y2:l[r+1].y});for(let r=0;r<this.editPoints.length;r++)this.editPoints[r].setShape({cx:l[r].x,cy:l[r].y})}else if(this.editingPointIndex!==null){const a=this.initialPixelPoints.map(n=>({x:n.x,y:n.y}));a[this.editingPointIndex]={x:i,y:s};for(let n=0;n<this.editLines.length;n++)this.editLines[n].setShape({x1:a[n].x,y1:a[n].y,x2:a[n+1].x,y2:a[n+1].y});this.editPoints[this.editingPointIndex].setShape({cx:i,cy:s})}}),tt(this,"onMouseUp",e=>{this.isEditing&&this.finishEditing(e.offsetX,e.offsetY)}),tt(this,"onWindowMouseUp",e=>{if(!this.isEditing)return;const i=this.zr.dom;if(i){const s=i.getBoundingClientRect(),a=e.clientX-s.left,n=e.clientY-s.top;this.finishEditing(a,n)}else this.finishEditing(this.dragStart?.x??0,this.dragStart?.y??0)}),this.context=t,this.zr=this.context.getChart().getZr(),this.bindEvents()}bindEvents(){this.context.events.on("drawing:point:mousedown",this.onPointMouseDown),this.context.events.on("drawing:mousedown",this.onDrawingMouseDown)}createEditGraphic(){if(!this.currentDrawing)return;this.editGroup=new G.graphic.Group,this.editLines=[],this.editPoints=[];const t=this.currentDrawing.points.map(i=>{const s=this.context.coordinateConversion.dataToPixel(i);return s?{x:s.x,y:s.y}:null});if(t.some(i=>!i))return;const e=t;for(let i=0;i<e.length-1;i++){const s=new G.graphic.Line({shape:{x1:e[i].x,y1:e[i].y,x2:e[i+1].x,y2:e[i+1].y},style:{stroke:this.currentDrawing.style?.color||"#3b82f6",lineWidth:this.currentDrawing.style?.lineWidth||2,lineDash:[4,4]},silent:!0});this.editLines.push(s),this.editGroup.add(s)}for(let i=0;i<e.length;i++){const s=new G.graphic.Circle({shape:{cx:e[i].x,cy:e[i].y,r:5},style:{fill:"#fff",stroke:"#3b82f6",lineWidth:2},z:1e3});this.editPoints.push(s),this.editGroup.add(s)}this.zr.add(this.editGroup)}pixelToDataForPane(t,e,i){const s=this.context.coordinateConversion.pixelToData({x:t,y:e});if(s)return s;try{const a=this.context.getChart(),n=a.convertFromPixel({gridIndex:i},[t,e]);if(n){const l=a.getOption()?.xAxis?.[i]?.data,r=this.context.getMarketData(),o=l?Math.round((l.length-r.length)/2):0;return{timeIndex:Math.round(n[0])-o,value:n[1],paneIndex:i}}}catch{}return null}finishEditing(t,e){if(!this.currentDrawing){this.cleanup();return}const i=this.currentDrawing.paneIndex||0;if(this.isMovingShape&&this.dragStart){const s=t-this.dragStart.x,a=e-this.dragStart.y,n=this.initialPixelPoints.map(l=>this.pixelToDataForPane(l.x+s,l.y+a,i));if(n.every(l=>l!==null)){for(let l=0;l<n.length;l++)this.currentDrawing.points[l]=n[l];n[0]?.paneIndex!==void 0&&(this.currentDrawing.paneIndex=n[0].paneIndex),this.context.updateDrawing(this.currentDrawing)}}else if(this.editingPointIndex!==null){const s=this.pixelToDataForPane(t,e,i);s&&(this.currentDrawing.points[this.editingPointIndex]=s,this.editingPointIndex===0&&s.paneIndex!==void 0&&(this.currentDrawing.paneIndex=s.paneIndex),this.context.updateDrawing(this.currentDrawing))}this.cleanup()}cleanup(){this.isEditing=!1,this.isMovingShape=!1,this.dragStart=null,this.initialPixelPoints=[],this.currentDrawing=null,this.editingPointIndex=null,this.editLines=[],this.editPoints=[],this.editGroup&&(this.zr.remove(this.editGroup),this.editGroup=null),this.zr.off("mousemove",this.onMouseMove),this.zr.off("mouseup",this.onMouseUp),window.removeEventListener("mouseup",this.onWindowMouseUp),this.context.unlockChart()}}var ci=Object.defineProperty,pi=(p,t,e)=>t in p?ci(p,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):p[t]=e,di=(p,t,e)=>(pi(p,typeof t!="symbol"?t+"":t,e),e);class ne{constructor(){di(this,"renderers",new Map)}register(t){this.renderers.set(t.type,t)}get(t){return this.renderers.get(t)}}var ui=Object.defineProperty,gi=(p,t,e)=>t in p?ui(p,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):p[t]=e,fi=(p,t,e)=>(gi(p,typeof t!="symbol"?t+"":t,e),e);class yi{constructor(){fi(this,"handlers",new Map)}on(t,e){this.handlers.has(t)||this.handlers.set(t,new Set),this.handlers.get(t).add(e)}off(t,e){const i=this.handlers.get(t);i&&i.delete(e)}emit(t,e){const i=this.handlers.get(t);i&&i.forEach(s=>{try{s(e)}catch(a){console.error(`Error in EventBus handler for ${t}:`,a)}})}clear(){this.handlers.clear()}}class st{static safeParseColor(t){if(!t||typeof t!="string")return{color:"#888888",opacity:1};const e=t.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?\)/);if(e){const i=e[4]?parseFloat(e[4]):1;return{color:`rgb(${e[1]},${e[2]},${e[3]})`,opacity:i}}return{color:t,opacity:1}}static render(t,e,i){st.clearAll(t);const s=new Map;for(const a of e)a&&!a._deleted&&s.set(a.position,a);s.forEach(a=>{const n=a._paneIndex??0,l=i?i(n):void 0,r=st.buildTable(a,l);st.positionTable(r,a.position,l),t.appendChild(r)})}static clearAll(t){for(;t.firstChild;)t.removeChild(t.firstChild)}static buildTable(t,e){const i=document.createElement("table"),s=t.border_width??0,a=t.frame_width??0;if(s>0&&t.border_color||a>0&&t.frame_color?(i.style.borderCollapse="separate",i.style.borderSpacing="0"):i.style.borderCollapse="collapse",i.style.pointerEvents="none",i.style.fontSize="14px",i.style.lineHeight="1.4",i.style.fontFamily="sans-serif",i.style.margin="4px",e&&(i.style.maxHeight=e.height+"px",i.style.maxWidth=e.width+"px",i.style.overflow="hidden"),t.bgcolor){const{color:c,opacity:g}=st.safeParseColor(t.bgcolor);i.style.backgroundColor=c,g<1&&(i.style.opacity=String(g))}if(a>0&&t.frame_color){const{color:c}=st.safeParseColor(t.frame_color);i.style.border=`${a}px solid ${c}`}else i.style.border="none";const n=new Map,l=new Set;if(t.merges)for(const c of t.merges){const g=`${c.startCol},${c.startRow}`;n.set(g,{colspan:c.endCol-c.startCol+1,rowspan:c.endRow-c.startRow+1});for(let h=c.startRow;h<=c.endRow;h++)for(let f=c.startCol;f<=c.endCol;f++)h===c.startRow&&f===c.startCol||l.add(`${f},${h}`)}const r=s>0&&!!t.border_color,o=r?st.safeParseColor(t.border_color).color:"",u=t.rows||0,d=t.columns||0;for(let c=0;c<u;c++){const g=document.createElement("tr");for(let h=0;h<d;h++){const f=`${h},${c}`;if(l.has(f))continue;const y=document.createElement("td"),x=n.get(f);x&&(x.colspan>1&&(y.colSpan=x.colspan),x.rowspan>1&&(y.rowSpan=x.rowspan)),r?y.style.border=`${s}px solid ${o}`:y.style.border="none";const b=t.cells?.[c]?.[h];if(b&&!b._merged){if(y.textContent=b.text||"",b.bgcolor&&typeof b.bgcolor=="string"&&b.bgcolor.length>0){const{color:w,opacity:k}=st.safeParseColor(b.bgcolor);y.style.backgroundColor=w,k<1&&(y.style.backgroundColor=b.bgcolor)}if(b.text_color){const{color:w}=st.safeParseColor(b.text_color);y.style.color=w}if(y.style.fontSize=st.getSizePixels(b.text_size)+"px",y.style.textAlign=st.mapHAlign(b.text_halign),y.style.verticalAlign=st.mapVAlign(b.text_valign),b.text_font_family==="monospace"&&(y.style.fontFamily="monospace"),b.width>0)if(e){const w=Math.max(1,b.width*e.width/100);y.style.width=w+"px"}else y.style.width=b.width+"%";if(b.height>0)if(e){const w=Math.max(1,b.height*e.height/100);y.style.height=w+"px"}else y.style.height=b.height+"%";b.tooltip&&(y.title=b.tooltip)}const D=b?.height??0;D>0&&e&&D*e.height/100<4?y.style.padding="0":y.style.padding="4px 6px",y.style.whiteSpace="nowrap",g.appendChild(y)}i.appendChild(g)}return i}static positionTable(t,e,i){t.style.position="absolute";const s=8,a=i?i.y+"px":"0",n=i?i.x+"px":"0",l=i?i.y+i.height-s+"px":"0",r=i?i.x+i.width-s+"px":"0",o=i?i.x+i.width/2+"px":"50%",u=i?i.y+i.height/2+"px":"50%";switch(e){case"top_left":t.style.top=a,t.style.left=n;break;case"top_center":t.style.top=a,t.style.left=o,t.style.transform="translateX(-50%)";break;case"top_right":t.style.top=a,t.style.left=r,t.style.transform="translateX(-100%)";break;case"middle_left":t.style.top=u,t.style.left=n,t.style.transform="translateY(-50%)";break;case"middle_center":t.style.top=u,t.style.left=o,t.style.transform="translate(-50%, -50%)";break;case"middle_right":t.style.top=u,t.style.left=r,t.style.transform="translate(-100%, -50%)";break;case"bottom_left":t.style.top=l,t.style.left=n,t.style.transform="translateY(-100%)";break;case"bottom_center":t.style.top=l,t.style.left=o,t.style.transform="translate(-50%, -100%)";break;case"bottom_right":t.style.top=l,t.style.left=r,t.style.transform="translate(-100%, -100%)";break;default:t.style.top=a,t.style.left=r,t.style.transform="translateX(-100%)";break}}static getSizePixels(t){if(typeof t=="number"&&t>0)return t;switch(t){case"auto":case"size.auto":return 12;case"tiny":case"size.tiny":return 8;case"small":case"size.small":return 10;case"normal":case"size.normal":return 14;case"large":case"size.large":return 20;case"huge":case"size.huge":return 36;default:return 14}}static mapHAlign(t){switch(t){case"left":case"text.align_left":return"left";case"right":case"text.align_right":return"right";case"center":case"text.align_center":default:return"center"}}static mapVAlign(t){switch(t){case"top":case"text.align_top":return"top";case"bottom":case"text.align_bottom":return"bottom";case"center":case"text.align_center":default:return"middle"}}}class K{static parseColor(t){if(!t||typeof t!="string"||t.length===0)return{color:"",opacity:0};const e=t.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?\)/);if(e){const i=e[4]?parseFloat(e[4]):1;return{color:`rgb(${e[1]},${e[2]},${e[3]})`,opacity:i}}if(/^#[0-9a-fA-F]{8}$/.test(t)){const i=parseInt(t.slice(1,3),16),s=parseInt(t.slice(3,5),16),a=parseInt(t.slice(5,7),16),n=parseInt(t.slice(7,9),16)/255;return{color:`rgb(${i},${s},${a})`,opacity:n}}return{color:t,opacity:1}}static getSizePixels(t){if(typeof t=="number"&&t>0)return t;switch(t){case"auto":case"size.auto":return 11;case"tiny":case"size.tiny":return 8;case"small":case"size.small":return 10;case"normal":case"size.normal":return 12;case"large":case"size.large":return 16;case"huge":case"size.huge":return 24;default:return 12}}static mapHAlign(t){switch(t){case"left":case"text.align_left":return"left";case"right":case"text.align_right":return"right";default:return"center"}}static mapVAlign(t){switch(t){case"top":case"text.align_top":return"top";case"bottom":case"text.align_bottom":return"bottom";default:return"middle"}}static buildGraphicElements(t,e){if(!t||t.length===0)return[];const i=new Map;for(const a of t)a&&!a._deleted&&i.set(a.position,a);const s=[];return i.forEach(a=>{const n=a._paneIndex??0,l=e(n);if(!l)return;const r=K.buildTableElements(a,l);s.push(...r)}),s}static buildTableElements(t,e){const i=t.rows||0,s=t.columns||0;if(i===0||s===0)return[];const a=t.border_width??0,n=t.frame_width??0,l=a>0&&!!t.border_color,r=n>0&&!!t.frame_color,o=new Map,u=new Set;if(t.merges)for(const I of t.merges){o.set(`${I.startCol},${I.startRow}`,{colspan:I.endCol-I.startCol+1,rowspan:I.endRow-I.startRow+1});for(let $=I.startRow;$<=I.endRow;$++)for(let P=I.startCol;P<=I.endCol;P++)$===I.startRow&&P===I.startCol||u.add(`${P},${$}`)}const d=4,c=2,g=1.25,h=[];for(let I=0;I<i;I++){h[I]=[];for(let $=0;$<s;$++){if(u.has(`${$},${I}`)){h[I][$]={text:"",lines:[],fontSize:12,fontFamily:"sans-serif",textColor:{color:"",opacity:0},bgColor:{color:"",opacity:0},halign:"center",valign:"middle",explicitWidth:0,explicitHeight:0,colspan:1,rowspan:1,skip:!0,padX:0,padY:0};continue}const P=t.cells?.[I]?.[$],F=o.get(`${$},${I}`),T=F?.colspan??1,B=F?.rowspan??1,Z=P&&!P._merged&&P.text||"",N=Z?Z.split(`
38
- `):[],V=P?K.getSizePixels(P.text_size):12,O=P?.text_font_family==="monospace"?"monospace":"sans-serif";let Y=0,lt=0;P?.width>0&&(Y=Math.max(1,P.width*e.width/100)),P?.height>0&&(lt=Math.max(1,P.height*e.height/100));const ht=lt>0&&lt<4,Ht=ht?0:d,bt=ht?0:c,Lt=P&&!P._merged&&P.bgcolor&&typeof P.bgcolor=="string"&&P.bgcolor.length>0?P.bgcolor:"",Wt=P?.text_color||"";h[I][$]={text:Z,lines:N,fontSize:V,fontFamily:O,textColor:Wt?K.parseColor(Wt):{color:"#e0e0e0",opacity:1},bgColor:Lt?K.parseColor(Lt):{color:"",opacity:0},halign:P?K.mapHAlign(P.text_halign):"center",valign:P?K.mapVAlign(P.text_valign):"middle",explicitWidth:Y,explicitHeight:lt,colspan:T,rowspan:B,skip:!1,padX:Ht,padY:bt}}}const f=new Array(s).fill(0),y=new Array(i).fill(0);for(let I=0;I<i;I++)for(let $=0;$<s;$++){const P=h[I][$];if(P.skip||P.colspan>1||P.rowspan>1)continue;const F=K.measureMultiLineWidth(P.lines,P.fontSize,P.fontFamily),T=Math.max(P.lines.length,1),B=P.explicitWidth>0?P.explicitWidth:F+P.padX*2,Z=P.explicitHeight>0?P.explicitHeight:T*P.fontSize*g+P.padY*2;f[$]=Math.max(f[$],B),y[I]=Math.max(y[I],Z)}for(let I=0;I<s;I++)f[I]===0&&(f[I]=20);for(let I=0;I<i;I++)y[I]===0&&(y[I]=4);for(let I=0;I<i;I++)for(let $=0;$<s;$++){const P=h[I][$];if(P.skip)continue;const F=Math.max(P.lines.length,1),T=P.explicitHeight>0?P.explicitHeight:F*P.fontSize*g+P.padY*2;if(P.colspan>1){const B=K.sumRange(f,$,P.colspan),Z=K.measureMultiLineWidth(P.lines,P.fontSize,P.fontFamily),N=P.explicitWidth>0?P.explicitWidth:Z+P.padX*2;if(N>B){const V=(N-B)/P.colspan;for(let O=0;O<P.colspan;O++)f[$+O]+=V}P.rowspan===1&&(y[I]=Math.max(y[I],T))}if(P.rowspan>1){const B=K.sumRange(y,I,P.rowspan);if(T>B){const Z=(T-B)/P.rowspan;for(let N=0;N<P.rowspan;N++)y[I+N]+=Z}}}for(let I=0;I<s;I++)f[I]=Math.round(f[I]);for(let I=0;I<i;I++)y[I]=Math.round(y[I]);const x=new Array(s+1).fill(0);for(let I=0;I<s;I++)x[I+1]=x[I]+f[I];const b=new Array(i+1).fill(0);for(let I=0;I<i;I++)b[I+1]=b[I]+y[I];const D=r?n:0,w=x[s]+D*2,k=b[i]+D*2,m=Math.min(w,e.width),C=Math.min(k,e.height),v=K.computePosition(t.position,e,m,C),_=Math.round(v.x),A=Math.round(v.y),M=[],S=_+D,z=A+D;if(t.bgcolor){const{color:I,opacity:$}=K.parseColor(t.bgcolor);$>0&&M.push({type:"rect",shape:{x:_,y:A,width:m,height:C},style:{fill:I,opacity:$},silent:!0,z:0,z2:0})}if(r){const{color:I}=K.parseColor(t.frame_color),$=n/2;M.push({type:"rect",shape:{x:_+$,y:A+$,width:m-n,height:C-n},style:{fill:"none",stroke:I,lineWidth:n},silent:!0,z:0,z2:1})}const W=l?K.parseColor(t.border_color).color:"";for(let I=0;I<i;I++)for(let $=0;$<s;$++){const P=h[I][$];if(P.skip)continue;const F=S+x[$],T=z+b[I],B=K.sumRange(f,$,P.colspan),Z=K.sumRange(y,I,P.rowspan);if(F-_>=m||T-A>=C)continue;const N=Math.min(B,m-(F-_)),V=Math.min(Z,C-(T-A));if(P.bgColor.opacity>0&&M.push({type:"rect",shape:{x:F,y:T,width:N,height:V},style:{fill:P.bgColor.color,opacity:P.bgColor.opacity},silent:!0,z:0,z2:2}),l&&M.push({type:"rect",shape:{x:F,y:T,width:N,height:V},style:{fill:"none",stroke:W,lineWidth:a},silent:!0,z:0,z2:3}),P.text){let O,Y;switch(P.halign){case"left":O=F+P.padX,Y="left";break;case"right":O=F+N-P.padX,Y="right";break;default:O=F+N/2,Y="center";break}let lt,ht;switch(P.valign){case"top":lt=T+P.padY,ht="top";break;case"bottom":lt=T+V-P.padY,ht="bottom";break;default:lt=T+V/2,ht="middle";break}M.push({type:"text",x:O,y:lt,style:{text:P.text,fill:P.textColor.color,opacity:P.textColor.opacity,font:`${P.fontSize}px ${P.fontFamily}`,textAlign:Y,textVerticalAlign:ht,lineHeight:Math.round(P.fontSize*g)},silent:!0,z:0,z2:4})}}return M}static computePosition(t,e,i,s){const a=e.x,n=e.y,l=e.width,r=e.height;switch(t){case"top_left":return{x:a+4,y:n+4};case"top_center":return{x:a+(l-i)/2,y:n+4};case"top_right":return{x:a+l-i-4,y:n+4};case"middle_left":return{x:a+4,y:n+(r-s)/2};case"middle_center":return{x:a+(l-i)/2,y:n+(r-s)/2};case"middle_right":return{x:a+l-i-4,y:n+(r-s)/2};case"bottom_left":return{x:a+4,y:n+r-s-4};case"bottom_center":return{x:a+(l-i)/2,y:n+r-s-4};case"bottom_right":return{x:a+l-i-4,y:n+r-s-4};default:return{x:a+l-i-4,y:n+4}}}static measureMultiLineWidth(t,e,i){if(!t||t.length===0)return 0;const s=i==="monospace"?.6:.55;let a=0;for(const n of t)a=Math.max(a,n.length*e*s);return a}static sumRange(t,e,i){let s=0;for(let a=e;a<e+i&&a<t.length;a++)s+=t[a];return s}}var xi=Object.defineProperty,mi=(p,t,e)=>t in p?xi(p,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):p[t]=e,L=(p,t,e)=>(mi(p,typeof t!="symbol"?t+"":t,e),e);class bi{constructor(t,e={}){L(this,"chart"),L(this,"options"),L(this,"marketData",[]),L(this,"indicators",new Map),L(this,"timeToIndex",new Map),L(this,"pluginManager"),L(this,"drawingEditor"),L(this,"events",new yi),L(this,"isMainCollapsed",!1),L(this,"maximizedPaneId",null),L(this,"countdownInterval",null),L(this,"selectedDrawingId",null),L(this,"drawings",[]),L(this,"drawingRenderers",new ne),L(this,"coordinateConversion",{pixelToData:n=>{const l=this.chart.getOption();if(!l||!l.grid)return null;const r=l.grid.length;for(let o=0;o<r;o++)if(this.chart.containPixel({gridIndex:o},[n.x,n.y])){this.chart.convertFromPixel({seriesIndex:o},[n.x,n.y]);const u=this.chart.convertFromPixel({gridIndex:o},[n.x,n.y]);if(u)return{timeIndex:Math.round(u[0])-this.dataIndexOffset,value:u[1],paneIndex:o}}return null},dataToPixel:n=>{const l=n.paneIndex||0,r=this.chart.convertToPixel({gridIndex:l},[n.timeIndex+this.dataIndexOffset,n.value]);return r?{x:r[0],y:r[1]}:null}}),L(this,"upColor","#00da3c"),L(this,"downColor","#ec0000"),L(this,"defaultPadding",0),L(this,"padding"),L(this,"dataIndexOffset",0),L(this,"_paddingPoints",0),L(this,"LAZY_MIN_PADDING",5),L(this,"LAZY_MAX_PADDING",500),L(this,"LAZY_CHUNK_SIZE",50),L(this,"LAZY_EDGE_THRESHOLD",10),L(this,"_expandScheduled",!1),L(this,"rootContainer"),L(this,"layoutContainer"),L(this,"toolbarContainer"),L(this,"leftSidebar"),L(this,"rightSidebar"),L(this,"chartContainer"),L(this,"overlayContainer"),L(this,"_lastTables",[]),L(this,"_tableGraphicIds",[]),L(this,"_baseGraphics",[]),L(this,"_labelTooltipEl",null),L(this,"_lastLayout",null),L(this,"_mainHeightOverride",null),L(this,"_paneDragState",null),L(this,"_paneResizeRafId",null),L(this,"onKeyDown",n=>{(n.key==="Delete"||n.key==="Backspace")&&this.selectedDrawingId&&(this.removeDrawing(this.selectedDrawingId),this.selectedDrawingId=null,this.render())}),L(this,"onFullscreenChange",()=>{this.render()}),L(this,"isLocked",!1),L(this,"lockedState",null),this.rootContainer=t,this.options={title:void 0,height:"600px",backgroundColor:"#1e293b",upColor:"#00da3c",downColor:"#ec0000",fontColor:"#cbd5e1",fontFamily:"sans-serif",padding:.01,dataZoom:{visible:!0,position:"top",height:6},layout:{mainPaneHeight:"50%",gap:13},watermark:!0,...e},this.options.upColor&&(this.upColor=this.options.upColor),this.options.downColor&&(this.downColor=this.options.downColor),this.padding=this.options.padding!==void 0?this.options.padding:this.defaultPadding,this.options.height&&(typeof this.options.height=="number"?this.rootContainer.style.height=`${this.options.height}px`:this.rootContainer.style.height=this.options.height),this.rootContainer.innerHTML="",this.layoutContainer=document.createElement("div"),this.layoutContainer.style.display="flex",this.layoutContainer.style.width="100%",this.layoutContainer.style.height="100%",this.layoutContainer.style.overflow="hidden",this.rootContainer.appendChild(this.layoutContainer),this.leftSidebar=document.createElement("div"),this.leftSidebar.style.display="none",this.leftSidebar.style.width="250px",this.leftSidebar.style.flexShrink="0",this.leftSidebar.style.overflowY="auto",this.leftSidebar.style.backgroundColor=this.options.backgroundColor||"#1e293b",this.leftSidebar.style.borderRight="1px solid #334155",this.leftSidebar.style.padding="10px",this.leftSidebar.style.boxSizing="border-box",this.leftSidebar.style.color="#cbd5e1",this.leftSidebar.style.fontSize="12px",this.leftSidebar.style.fontFamily=this.options.fontFamily||"sans-serif",this.layoutContainer.appendChild(this.leftSidebar),this.toolbarContainer=document.createElement("div"),this.layoutContainer.appendChild(this.toolbarContainer),this.chartContainer=document.createElement("div"),this.chartContainer.style.flexGrow="1",this.chartContainer.style.height="100%",this.chartContainer.style.overflow="hidden",this.layoutContainer.appendChild(this.chartContainer),this.rightSidebar=document.createElement("div"),this.rightSidebar.style.display="none",this.rightSidebar.style.width="250px",this.rightSidebar.style.flexShrink="0",this.rightSidebar.style.overflowY="auto",this.rightSidebar.style.backgroundColor=this.options.backgroundColor||"#1e293b",this.rightSidebar.style.borderLeft="1px solid #334155",this.rightSidebar.style.padding="10px",this.rightSidebar.style.boxSizing="border-box",this.rightSidebar.style.color="#cbd5e1",this.rightSidebar.style.fontSize="12px",this.rightSidebar.style.fontFamily=this.options.fontFamily||"sans-serif",this.layoutContainer.appendChild(this.rightSidebar),this.chart=G.init(this.chartContainer),this.chartContainer.style.position="relative",this.overlayContainer=document.createElement("div"),this.overlayContainer.style.cssText="position:absolute;top:0;left:0;width:100%;height:100%;pointer-events:none;z-index:100;overflow:hidden;",this.chartContainer.appendChild(this.overlayContainer),this.pluginManager=new ai(this,this.toolbarContainer),this.drawingEditor=new hi(this),this.chart.on("dataZoom",n=>{this.events.emit("chart:dataZoom",n);const l=this.options.databox?.triggerOn,r=this.options.databox?.position;l==="click"&&r==="floating"&&this.chart.dispatchAction({type:"hideTip"}),this._checkEdgeAndExpand()}),this.chart.on("finished",n=>this.events.emit("chart:updated",n)),this.chart.getZr().on("mousedown",n=>{this._paneDragState||this.events.emit("mouse:down",n)}),this.chart.getZr().on("mousemove",n=>{this._paneDragState||this.events.emit("mouse:move",n)}),this.chart.getZr().on("mouseup",n=>this.events.emit("mouse:up",n)),this.chart.getZr().on("click",n=>{this._paneDragState||this.events.emit("mouse:click",n)});const i=this.chart.getZr(),s=i.setCursorStyle,a=this;i.setCursorStyle=function(n){if(a._paneDragState){s.call(this,"row-resize");return}n==="grab"&&(n="crosshair"),s.call(this,n)},this.bindDrawingEvents(),this.bindPaneResizeEvents(),window.addEventListener("resize",this.resize.bind(this)),document.addEventListener("fullscreenchange",this.onFullscreenChange),document.addEventListener("keydown",this.onKeyDown)}bindPaneResizeEvents(){const t=this.chart.getZr(),e=s=>{if(!this._lastLayout||this._lastLayout.paneBoundaries.length===0||this.maximizedPaneId)return null;const a=this.chart.getHeight();if(a<=0)return null;for(const n of this._lastLayout.paneBoundaries){const l=n.yPercent/100*a;if(Math.abs(s-l)<=6){if(n.aboveId==="main"&&this.isMainCollapsed||this.indicators.get(n.belowId)?.collapsed||n.aboveId!=="main"&&this.indicators.get(n.aboveId)?.collapsed)continue;return n}}return null},i=s=>s==="main"?this._lastLayout?.mainPaneHeight??50:this.indicators.get(s)?.height??15;t.on("mousemove",s=>{if(this._paneDragState){const a=s.offsetY-this._paneDragState.startY,n=this.chart.getHeight();if(n<=0)return;const l=a/n*100,r=this._paneDragState.aboveId==="main"?10:5,o=5;let u=this._paneDragState.startAboveHeight+l,d=this._paneDragState.startBelowHeight-l;if(u<r&&(u=r,d=this._paneDragState.startAboveHeight+this._paneDragState.startBelowHeight-r),d<o&&(d=o,u=this._paneDragState.startAboveHeight+this._paneDragState.startBelowHeight-o),this._paneDragState.aboveId==="main")this._mainHeightOverride=u;else{const g=this.indicators.get(this._paneDragState.aboveId);g&&(g.height=u)}const c=this.indicators.get(this._paneDragState.belowId);c&&(c.height=d),this._paneResizeRafId||(this._paneResizeRafId=requestAnimationFrame(()=>{this._paneResizeRafId=null,this.render()})),t.setCursorStyle("row-resize"),s.stop?.();return}e(s.offsetY)&&t.setCursorStyle("row-resize")}),t.on("mousedown",s=>{const a=e(s.offsetY);a&&(this._paneDragState={startY:s.offsetY,aboveId:a.aboveId,belowId:a.belowId,startAboveHeight:i(a.aboveId),startBelowHeight:i(a.belowId)},t.setCursorStyle("row-resize"),s.stop?.())}),t.on("mouseup",()=>{this._paneDragState&&(this._paneDragState=null,this._paneResizeRafId&&(cancelAnimationFrame(this._paneResizeRafId),this._paneResizeRafId=null),this.render())})}bindDrawingEvents(){let t=null;const e=i=>{if(!i||i.componentType!=="series"||!i.seriesName?.startsWith("drawings"))return null;i.seriesIndex;const s=i.seriesName.match(/drawings-pane-(\d+)/);if(!s)return null;const a=parseInt(s[1]),n=this.drawings.filter(r=>(r.paneIndex||0)===a)[i.dataIndex];if(!n)return null;const l=i.event?.target?.name;return{drawing:n,targetName:l,paneIdx:a}};this.chart.on("mouseover",i=>{const s=e(i);if(!s)return;const a=i.event?.target?.parent;if(a){const n=s.drawing.id===this.selectedDrawingId;t&&(clearTimeout(t),t=null),n||a.children().forEach(l=>{l.name&&l.name.startsWith("point")&&l.attr("style",{opacity:1})})}if(s.targetName==="line")this.events.emit("drawing:hover",{id:s.drawing.id,type:s.drawing.type}),this.chart.getZr().setCursorStyle("move");else if(s.targetName?.startsWith("point-")){const n=parseInt(s.targetName.split("-")[1])||0;this.events.emit("drawing:point:hover",{id:s.drawing.id,pointIndex:n}),this.chart.getZr().setCursorStyle("pointer")}}),this.chart.on("mouseout",i=>{const s=e(i);if(!s)return;const a=i.event?.target?.parent;if(s.drawing.id!==this.selectedDrawingId){if(t=setTimeout(()=>{if(a){if(this.selectedDrawingId===s.drawing.id)return;a.children().forEach(n=>{n.name&&n.name.startsWith("point")&&n.attr("style",{opacity:0})})}},50),s.targetName==="line")this.events.emit("drawing:mouseout",{id:s.drawing.id});else if(s.targetName?.startsWith("point-")){const n=parseInt(s.targetName.split("-")[1])||0;this.events.emit("drawing:point:mouseout",{id:s.drawing.id,pointIndex:n})}this.chart.getZr().setCursorStyle("default")}}),this.chart.on("mousedown",i=>{const s=e(i);if(!s)return;const a=i.event?.event||i.event,n=a?.offsetX,l=a?.offsetY;if(s.targetName==="line")this.events.emit("drawing:mousedown",{id:s.drawing.id,x:n,y:l});else if(s.targetName?.startsWith("point-")){const r=parseInt(s.targetName.split("-")[1])||0;this.events.emit("drawing:point:mousedown",{id:s.drawing.id,pointIndex:r,x:n,y:l})}}),this.chart.on("click",i=>{const s=e(i);if(s){if(this.selectedDrawingId!==s.drawing.id&&(this.selectedDrawingId=s.drawing.id,this.events.emit("drawing:selected",{id:s.drawing.id}),this.render()),s.targetName==="line")this.events.emit("drawing:click",{id:s.drawing.id});else if(s.targetName?.startsWith("point-")){const a=parseInt(s.targetName.split("-")[1])||0;this.events.emit("drawing:point:click",{id:s.drawing.id,pointIndex:a})}}}),this.chart.getZr().on("click",i=>{i.target||this.selectedDrawingId&&(this.events.emit("drawing:deselected",{id:this.selectedDrawingId}),this.selectedDrawingId=null,this.render())}),this._labelTooltipEl=document.createElement("div"),this._labelTooltipEl.style.cssText="position:absolute;display:none;pointer-events:none;z-index:200;background:rgba(30,41,59,0.95);color:#fff;border:1px solid #475569;border-radius:4px;padding:6px 10px;font-size:12px;line-height:1.5;white-space:pre-wrap;max-width:350px;box-shadow:0 2px 8px rgba(0,0,0,0.3);font-family:"+(this.options.fontFamily||"sans-serif")+";",this.chartContainer.appendChild(this._labelTooltipEl),this.chart.on("mouseover",{seriesType:"scatter"},i=>{const s=i.data?._tooltipText;if(!s||!this._labelTooltipEl)return;this._labelTooltipEl.textContent=s,this._labelTooltipEl.style.display="block";const a=this.chartContainer.getBoundingClientRect(),n=i.event?.event;if(n){const l=n.clientX-a.left,r=n.clientY-a.top,o=this._labelTooltipEl.offsetWidth,u=Math.min(l-o/2,a.width-o-8);this._labelTooltipEl.style.left=Math.max(4,u)+"px",this._labelTooltipEl.style.top=r+18+"px"}}),this.chart.on("mouseout",{seriesType:"scatter"},()=>{this._labelTooltipEl&&(this._labelTooltipEl.style.display="none")})}getChart(){return this.chart}getMarketData(){return this.marketData}getTimeToIndex(){return this.timeToIndex}getOptions(){return this.options}disableTools(){this.pluginManager.deactivatePlugin()}registerPlugin(t){this.pluginManager.register(t)}registerDrawingRenderer(t){this.drawingRenderers.register(t)}snapToCandle(t){const e=this.coordinateConversion.pixelToData(t);if(!e)return t;const i=e.paneIndex||0;if(i!==0)return t;const s=Math.round(e.timeIndex);if(s<0||s>=this.marketData.length)return t;const a=this.marketData[s];if(!a)return t;const n=this.chart.convertToPixel({gridIndex:i},[s+this.dataIndexOffset,a.close]);if(!n)return t;const l=n[0],r=[a.open,a.high,a.low,a.close];let o=r[0],u=1/0;for(const c of r){const g=this.chart.convertToPixel({gridIndex:i},[s+this.dataIndexOffset,c]);if(g){const h=Math.abs(g[1]-t.y);h<u&&(u=h,o=c)}}const d=this.chart.convertToPixel({gridIndex:i},[s+this.dataIndexOffset,o]);return{x:l,y:d?d[1]:t.y}}addDrawing(t){this.drawings.push(t),this.render()}removeDrawing(t){const e=this.drawings.findIndex(i=>i.id===t);if(e!==-1){const i=this.drawings[e];this.drawings.splice(e,1),this.events.emit("drawing:deleted",{id:i.id}),this.render()}}getDrawing(t){return this.drawings.find(e=>e.id===t)}updateDrawing(t){const e=this.drawings.findIndex(i=>i.id===t.id);e!==-1&&(this.drawings[e]=t,this.render())}lockChart(){if(this.isLocked)return;this.isLocked=!0;const t=this.chart.getOption();this.chart.setOption({dataZoom:t.dataZoom.map(e=>({...e,disabled:!0})),tooltip:{show:!1}})}unlockChart(){if(!this.isLocked)return;this.isLocked=!1;const t=this.chart.getOption();(this.options.dataZoom||{}).visible,t.dataZoom&&this.chart.setOption({dataZoom:t.dataZoom.map(e=>({...e,disabled:!1})),tooltip:{show:!0}})}setZoom(t,e){this.chart.dispatchAction({type:"dataZoom",start:t,end:e})}setMarketData(t){this.marketData=t,this.rebuildTimeIndex(),this.render()}updateData(t){if(t.length===0)return;const e=new Map;this.marketData.forEach(y=>{e.set(y.time,y)}),t.forEach(y=>{e.has(y.time),e.set(y.time,y)}),this.marketData=Array.from(e.values()).sort((y,x)=>y.time-x.time),this.rebuildTimeIndex();const i=this.dataIndexOffset,s=wt.buildCandlestickSeries(this.marketData,this.options),a={value:[NaN,NaN,NaN,NaN],itemStyle:{opacity:0}},n=[...Array(i).fill(a),...s.data,...Array(i).fill(a)],l=[...Array(i).fill(""),...this.marketData.map(y=>new Date(y.time).toLocaleString()),...Array(i).fill("")],r=this.chart.getOption(),o=Rt.calculate(this.chart.getHeight(),this.indicators,this.options,this.isMainCollapsed,this.maximizedPaneId,this.marketData,this._mainHeightOverride??void 0);this._lastLayout=o;const u=[...Array(i).fill(null),...this.marketData,...Array(i).fill(null)],{series:d,barColors:c}=wt.buildIndicatorSeries(this.indicators,this.timeToIndex,o.paneLayout,l.length,i,u,o.overlayYAxisMap,o.separatePaneYAxisOffset),g=n.map((y,x)=>c[x]?{value:y.value||y,itemStyle:{color:c[x],color0:c[x]}}:y),h={xAxis:r.xAxis.map((y,x)=>({data:l})),series:[{data:g,markLine:s.markLine},...d]};this.chart.setOption(h,{notMerge:!1});const f=[];this.indicators.forEach(y=>{Object.values(y.plots).forEach(x=>{x.options?.style==="table"&&x.data?.forEach(b=>{(Array.isArray(b.value)?b.value:[b.value]).forEach(D=>{D&&!D._deleted&&(D._paneIndex=D.force_overlay?0:y.paneIndex,f.push(D))})})})}),this._lastTables=f,this._renderTableOverlays(),this.startCountdown()}startCountdown(){if(this.stopCountdown(),!this.options.lastPriceLine?.showCountdown||this.marketData.length===0)return;let t=this.options.interval;if(!t&&this.marketData.length>=2){const i=this.marketData[this.marketData.length-1],s=this.marketData[this.marketData.length-2];t=i.time-s.time}if(!t)return;const e=()=>{if(this.marketData.length===0)return;const i=this.marketData[this.marketData.length-1].time+t,s=Date.now(),a=i-s;if(a<=0)return;const n=Math.abs(a),l=Math.floor(n/36e5),r=Math.floor(n%36e5/6e4),o=Math.floor(n%6e4/1e3),u=`${l>0?l.toString().padStart(2,"0")+":":""}${r.toString().padStart(2,"0")}:${o.toString().padStart(2,"0")}`,d=this.chart.getOption();if(!d||!d.series)return;const c=d.series.findIndex(b=>b.type==="candlestick");if(c===-1)return;const g=d.series[c];if(!g.markLine||!g.markLine.data||!g.markLine.data[0])return;const h=g.markLine.data[0];h.label.formatter;const f=h.yAxis;let y="";if(this.options.yAxisLabelFormatter)y=this.options.yAxisLabelFormatter(f);else{const b=this.options.yAxisDecimalPlaces!==void 0?this.options.yAxisDecimalPlaces:R.autoDetectDecimals(this.marketData);y=R.formatValue(f,b)}const x=`${y}
39
- ${u}`;this.chart.setOption({series:[{id:"__candlestick__",markLine:{data:[{...h,label:{...h.label,formatter:x}}]}}]})};e(),this.countdownInterval=setInterval(e,1e3)}stopCountdown(){this.countdownInterval&&(clearInterval(this.countdownInterval),this.countdownInterval=null)}addIndicator(t,e,i={}){const s=i.overlay!==void 0?i.overlay:i.isOverlay??!1;let a=0;if(!s){let l=0;this.indicators.forEach(r=>{r.paneIndex>l&&(l=r.paneIndex)}),a=l+1}const n=new We(t,e,a,{height:i.height,collapsed:!1,titleColor:i.titleColor,controls:i.controls});return this.indicators.set(t,n),this.render(),n}setIndicator(t,e,i=!1){this.addIndicator(t,{[t]:e},{overlay:i})}removeIndicator(t){this.indicators.delete(t),this.render()}toggleIndicator(t,e="collapse"){if(e==="fullscreen"){document.fullscreenElement?document.exitFullscreen():this.rootContainer.requestFullscreen();return}if(e==="maximize"){this.maximizedPaneId===t?this.maximizedPaneId=null:this.maximizedPaneId=t,this.render();return}if(t==="main"){this.isMainCollapsed=!this.isMainCollapsed,this.render();return}const i=this.indicators.get(t);i&&(i.toggleCollapse(),this.render())}resize(){this.chart.resize(),this._renderTableOverlays()}_buildTableGraphics(){const t=this.chart.getModel(),e=s=>t.getComponent("grid",s)?.coordinateSystem?.getRect(),i=K.buildGraphicElements(this._lastTables,e);this._tableGraphicIds=[];for(let s=0;s<i.length;s++){const a=`__qf_table_${s}`;i[s].id=a,this._tableGraphicIds.push(a)}return i}_renderTableOverlays(){const t=this._buildTableGraphics(),e=[...this._baseGraphics,...t];this.chart.setOption({graphic:e},{replaceMerge:["graphic"]}),st.clearAll(this.overlayContainer)}destroy(){this.stopCountdown(),window.removeEventListener("resize",this.resize.bind(this)),document.removeEventListener("fullscreenchange",this.onFullscreenChange),document.removeEventListener("keydown",this.onKeyDown),this.pluginManager.deactivatePlugin(),this.pluginManager.destroy(),this.chart.dispose()}rebuildTimeIndex(){this.timeToIndex.clear(),this.marketData.forEach((i,s)=>{this.timeToIndex.set(i.time,s)});const t=this.marketData.length,e=Math.ceil(t*this.padding);this._paddingPoints=Math.max(this._paddingPoints,e,this.LAZY_MIN_PADDING),this.dataIndexOffset=this._paddingPoints}expandPadding(t){this._resizePadding(t)}_resizePadding(t){const e=Math.ceil(this.marketData.length*this.padding);if(t=Math.max(t,e,this.LAZY_MIN_PADDING),t=Math.min(t,this.LAZY_MAX_PADDING),t===this._paddingPoints)return;const i=this._paddingPoints,s=this.marketData.length+2*i,a=this.chart.getOption(),n=a?.dataZoom?.find(A=>A.type==="slider"||A.type==="inside"),l=n?n.start/100*s:0,r=n?n.end/100*s:s,o=t-i;this._paddingPoints=t,this.dataIndexOffset=this._paddingPoints;const u=this._paddingPoints,d={value:[NaN,NaN,NaN,NaN],itemStyle:{opacity:0}},c=wt.buildCandlestickSeries(this.marketData,this.options),g=[...Array(u).fill(d),...c.data,...Array(u).fill(d)],h=[...Array(u).fill(""),...this.marketData.map(A=>new Date(A.time).toLocaleString()),...Array(u).fill("")],f=[...Array(u).fill(null),...this.marketData,...Array(u).fill(null)],y=Rt.calculate(this.chart.getHeight(),this.indicators,this.options,this.isMainCollapsed,this.maximizedPaneId,this.marketData,this._mainHeightOverride??void 0),{series:x,barColors:b}=wt.buildIndicatorSeries(this.indicators,this.timeToIndex,y.paneLayout,h.length,u,f,y.overlayYAxisMap,y.separatePaneYAxisOffset),D=g.map((A,M)=>b[M]?{value:A.value||A,itemStyle:{color:b[M],color0:b[M]}}:A),w=this.marketData.length+2*t,k=Math.max(0,(l+o)/w*100),m=Math.min(100,(r+o)/w*100),C=[],v=new Map;this.drawings.forEach(A=>{const M=A.paneIndex||0;v.has(M)||v.set(M,[]),v.get(M).push(A)}),v.forEach(A=>{C.push({data:A.map(M=>[M.points[0].timeIndex+this.dataIndexOffset,M.points[0].value,M.points[1].timeIndex+this.dataIndexOffset,M.points[1].value])})});const _={xAxis:a.xAxis.map(()=>({data:h})),dataZoom:[{start:k,end:m},{start:k,end:m}],series:[{data:D,markLine:c.markLine},...x.map(A=>{const M={data:A.data};return A.renderItem&&(M.renderItem=A.renderItem),M}),...C]};this.chart.setOption(_,{notMerge:!1})}_checkEdgeAndExpand(){if(this._expandScheduled)return;const t=this.chart.getOption()?.dataZoom?.find(f=>f.type==="slider"||f.type==="inside");if(!t)return;const e=this._paddingPoints,i=this.marketData.length,s=i+2*e,a=Math.round(t.start/100*s),n=Math.round(t.end/100*s),l=e,r=e+i-1,o=Math.max(0,Math.min(n,r)-Math.max(a,l)+1),u=a<this.LAZY_EDGE_THRESHOLD,d=n>s-this.LAZY_EDGE_THRESHOLD;if((u||d)&&e<this.LAZY_MAX_PADDING&&o>=3){this._expandScheduled=!0,requestAnimationFrame(()=>{this._expandScheduled=!1,this._resizePadding(e+this.LAZY_CHUNK_SIZE)});return}const c=Math.max(0,e-a),g=Math.max(0,n-(e+i-1)),h=Math.max(c+this.LAZY_CHUNK_SIZE,g+this.LAZY_CHUNK_SIZE);e>h+this.LAZY_CHUNK_SIZE&&(this._expandScheduled=!0,requestAnimationFrame(()=>{this._expandScheduled=!1,this._resizePadding(h)}))}render(){if(this.marketData.length===0)return;let t=null;try{const m=this.chart.getOption();if(m&&m.dataZoom&&m.dataZoom.length>0){const C=m.dataZoom.find(v=>v.type==="slider"||v.type==="inside");C&&(t={start:C.start,end:C.end})}}catch{}const e=this.options.databox?.position,i=this.leftSidebar.style.display,s=this.rightSidebar.style.display,a=e==="left"?"block":"none",n=e==="right"?"block":"none";(i!==a||s!==n)&&(this.leftSidebar.style.display=a,this.rightSidebar.style.display=n,this.chart.resize());const l=this.dataIndexOffset,r=[...Array(l).fill(""),...this.marketData.map(m=>new Date(m.time).toLocaleString()),...Array(l).fill("")],o=Rt.calculate(this.chart.getHeight(),this.indicators,this.options,this.isMainCollapsed,this.maximizedPaneId,this.marketData,this._mainHeightOverride??void 0);if(this._lastLayout=o,!t&&o.dataZoom&&this.marketData.length>0){const m=this.marketData.length,C=r.length,v=l/C,_=m/C;o.dataZoom.forEach(A=>{if(A.start!==void 0){const M=A.start/100,S=v+M*_;A.start=S*100}if(A.end!==void 0){const M=A.end/100,S=v+M*_;A.end=S*100}})}t&&o.dataZoom&&o.dataZoom.forEach(m=>{m.start=t.start,m.end=t.end}),o.xAxis.forEach(m=>{m.data=r,m.boundaryGap=!1});const u=wt.buildCandlestickSeries(this.marketData,this.options),d={value:[NaN,NaN,NaN,NaN],itemStyle:{opacity:0}};u.data=[...Array(l).fill(d),...u.data,...Array(l).fill(d)];const c=[...Array(l).fill(null),...this.marketData,...Array(l).fill(null)],{series:g,barColors:h}=wt.buildIndicatorSeries(this.indicators,this.timeToIndex,o.paneLayout,r.length,l,c,o.overlayYAxisMap,o.separatePaneYAxisOffset);u.data=u.data.map((m,C)=>h[C]?{value:m.value||m,itemStyle:{color:h[C],color0:h[C]}}:m);const f=[];this.indicators.forEach((m,C)=>{m.paneIndex===0&&f.push({id:C,titleColor:m.titleColor})});const y=ii.build(o,this.options,this.toggleIndicator.bind(this),this.isMainCollapsed,this.maximizedPaneId,f),x=new Map;this.drawings.forEach(m=>{const C=m.paneIndex||0;x.has(C)||x.set(C,[]),x.get(C).push(m)});const b=[];x.forEach((m,C)=>{b.push({type:"custom",name:`drawings-pane-${C}`,xAxisIndex:C,yAxisIndex:C,clip:!0,renderItem:(v,_)=>{const A=m[v.dataIndex];if(!A)return;const M=this.drawingRenderers.get(A.type);if(!M)return;const S=this.dataIndexOffset,z=A.points.map(W=>_.coord([W.timeIndex+S,W.value]));return M.render({drawing:A,pixelPoints:z,isSelected:A.id===this.selectedDrawingId,api:_})},data:m.map(v=>{const _=[];return v.points.forEach(A=>{_.push(A.timeIndex+this.dataIndexOffset,A.value)}),_}),encode:(()=>{const v=m.reduce((M,S)=>Math.max(M,S.points.length),0),_=Array.from({length:v},(M,S)=>S*2),A=Array.from({length:v},(M,S)=>S*2+1);return{x:_,y:A}})(),z:100,silent:!1})});const D=m=>{const C=si.format(m,this.options),v=this.options.databox?.position;return v==="left"?(this.leftSidebar.innerHTML=C,""):v==="right"?(this.rightSidebar.innerHTML=C,""):this.options.databox?`<div style="min-width: 200px;">${C}</div>`:""},w=[];this.indicators.forEach(m=>{Object.values(m.plots).forEach(C=>{C.options?.style==="table"&&C.data?.forEach(v=>{(Array.isArray(v.value)?v.value:[v.value]).forEach(_=>{_&&!_._deleted&&(_._paneIndex=_.force_overlay?0:m.paneIndex,w.push(_))})})})});const k={backgroundColor:this.options.backgroundColor,animation:!1,legend:{show:!1},tooltip:{show:!0,showContent:!!this.options.databox,trigger:"axis",triggerOn:this.options.databox?.triggerOn??"mousemove",axisPointer:{type:"cross",label:{backgroundColor:"#475569"}},backgroundColor:"rgba(30, 41, 59, 0.9)",borderWidth:1,borderColor:"#334155",padding:10,textStyle:{color:"#fff",fontFamily:this.options.fontFamily||"sans-serif"},formatter:D,extraCssText:e!=="floating"&&e!==void 0?"display: none !important;":void 0,position:(m,C,v,_,A)=>{if(this.options.databox?.position==="floating"){const M={top:10};return M[["left","right"][+(m[0]<A.viewSize[0]/2)]]=30,M}return null}},axisPointer:{link:{xAxisIndex:"all"},label:{backgroundColor:"#475569"}},graphic:y,grid:o.grid,xAxis:o.xAxis,yAxis:o.yAxis,dataZoom:o.dataZoom,series:[u,...g,...b]};if(this.chart.setOption(k,!0),this._baseGraphics=y,this._lastTables=w,w.length>0){const m=this._buildTableGraphics();if(m.length>0){const C=[...y,...m];this.chart.setOption({graphic:C},{replaceMerge:["graphic"]})}}else this._tableGraphicIds=[];st.clearAll(this.overlayContainer)}}var vi=Object.defineProperty,wi=(p,t,e)=>t in p?vi(p,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):p[t]=e,rt=(p,t,e)=>(wi(p,typeof t!="symbol"?t+"":t,e),e);class it{constructor(t){rt(this,"id"),rt(this,"name"),rt(this,"icon"),rt(this,"context"),rt(this,"eventListeners",[]),rt(this,"_snapIndicator",null),rt(this,"_snapMoveHandler",null),rt(this,"_snapKeyDownHandler",null),rt(this,"_snapKeyUpHandler",null),rt(this,"_snapBlurHandler",null),rt(this,"_snapActive",!1),rt(this,"_lastMouseEvent",null),this.id=t.id,this.name=t.name,this.icon=t.icon}init(t){this.context=t,this.onInit()}onInit(){}activate(){this.onActivate(),this._bindSnapIndicator(),this.context.events.emit("plugin:activated",this.id)}onActivate(){}deactivate(){this._unbindSnapIndicator(),this.onDeactivate(),this.context.events.emit("plugin:deactivated",this.id)}onDeactivate(){}destroy(){this._unbindSnapIndicator(),this.removeAllListeners(),this.onDestroy()}onDestroy(){}on(t,e){this.context.events.on(t,e),this.eventListeners.push({event:t,handler:e})}off(t,e){this.context.events.off(t,e),this.eventListeners=this.eventListeners.filter(i=>i.event!==t||i.handler!==e)}removeAllListeners(){this.eventListeners.forEach(({event:t,handler:e})=>{this.context.events.off(t,e)}),this.eventListeners=[]}get chart(){return this.context.getChart()}get marketData(){return this.context.getMarketData()}getPoint(t){const e=t.offsetX,i=t.offsetY,s=t.event;if(s?.ctrlKey||s?.metaKey){const a=this.context.snapToCandle({x:e,y:i});return[a.x,a.y]}return[e,i]}_bindSnapIndicator(){const t=this.context.getChart().getZr();this._snapMoveHandler=e=>{this._lastMouseEvent=e,e.event?.ctrlKey||e.event?.metaKey?this._showSnapAt(e.offsetX,e.offsetY):this._hideSnap()},this._snapKeyDownHandler=e=>{(e.key==="Control"||e.key==="Meta")&&this._lastMouseEvent&&this._showSnapAt(this._lastMouseEvent.offsetX,this._lastMouseEvent.offsetY)},this._snapKeyUpHandler=e=>{(e.key==="Control"||e.key==="Meta")&&this._hideSnap()},this._snapBlurHandler=()=>{this._hideSnap()},t.on("mousemove",this._snapMoveHandler),window.addEventListener("keydown",this._snapKeyDownHandler),window.addEventListener("keyup",this._snapKeyUpHandler),window.addEventListener("blur",this._snapBlurHandler)}_unbindSnapIndicator(){if(this._snapMoveHandler){try{this.context.getChart().getZr().off("mousemove",this._snapMoveHandler)}catch{}this._snapMoveHandler=null}this._snapKeyDownHandler&&(window.removeEventListener("keydown",this._snapKeyDownHandler),this._snapKeyDownHandler=null),this._snapKeyUpHandler&&(window.removeEventListener("keyup",this._snapKeyUpHandler),this._snapKeyUpHandler=null),this._snapBlurHandler&&(window.removeEventListener("blur",this._snapBlurHandler),this._snapBlurHandler=null),this._removeSnapGraphic(),this._lastMouseEvent=null}_removeSnapGraphic(){if(this._snapIndicator){try{this.context.getChart().getZr().remove(this._snapIndicator)}catch{}this._snapIndicator=null,this._snapActive=!1}}_showSnapAt(t,e){const i=this.context.snapToCandle({x:t,y:e}),s=this.context.getChart().getZr();this._snapIndicator||(this._snapIndicator=new G.graphic.Circle({shape:{cx:0,cy:0,r:5},style:{fill:"rgba(59, 130, 246, 0.3)",stroke:"#3b82f6",lineWidth:1.5},z:9999,silent:!0}),s.add(this._snapIndicator)),this._snapIndicator.setShape({cx:i.x,cy:i.y}),this._snapIndicator.show(),this._snapActive=!0}_hideSnap(){this._snapIndicator&&this._snapActive&&(this._snapIndicator.hide(),this._snapActive=!1)}}var Ci=Object.defineProperty,Ii=(p,t,e)=>t in p?Ci(p,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):p[t]=e,Q=(p,t,e)=>(Ii(p,typeof t!="symbol"?t+"":t,e),e);class _i extends it{constructor(t={}){super({id:"measure",name:t?.name||"Measure",icon:t?.icon||'<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="#e3e3e3"><path d="M160-240q-33 0-56.5-23.5T80-320v-320q0-33 23.5-56.5T160-720h640q33 0 56.5 23.5T880-640v320q0 33-23.5 56.5T800-240H160Zm0-80h640v-320H680v160h-80v-160h-80v160h-80v-160h-80v160h-80v-160H160v320Zm120-160h80-80Zm160 0h80-80Zm160 0h80-80Zm-120 0Z"/></svg>'}),Q(this,"zr"),Q(this,"state","idle"),Q(this,"startPoint",null),Q(this,"endPoint",null),Q(this,"group",null),Q(this,"rect",null),Q(this,"labelRect",null),Q(this,"labelText",null),Q(this,"lineV",null),Q(this,"lineH",null),Q(this,"arrowStart",null),Q(this,"arrowEnd",null),Q(this,"onMouseDown",()=>{this.state==="finished"&&this.removeGraphic()}),Q(this,"onChartInteraction",()=>{this.group&&this.removeGraphic()}),Q(this,"onClick",e=>{this.state==="idle"?(this.state="drawing",this.startPoint=this.getPoint(e),this.endPoint=this.getPoint(e),this.initGraphic(),this.updateGraphic()):this.state==="drawing"&&(this.state="finished",this.endPoint=this.getPoint(e),this.updateGraphic(),this.context.disableTools(),this.enableClearListeners())}),Q(this,"clearHandlers",{}),Q(this,"onMouseMove",e=>{this.state==="drawing"&&(this.endPoint=this.getPoint(e),this.updateGraphic())})}onInit(){this.zr=this.chart.getZr()}onActivate(){this.state="idle",this.chart.getZr().setCursorStyle("crosshair"),this.zr.on("click",this.onClick),this.zr.on("mousemove",this.onMouseMove)}onDeactivate(){this.state="idle",this.chart.getZr().setCursorStyle("default"),this.zr.off("click",this.onClick),this.zr.off("mousemove",this.onMouseMove),this.disableClearListeners(),this.state==="drawing"&&this.removeGraphic()}onDestroy(){this.removeGraphic()}enableClearListeners(){const t=()=>{this.removeGraphic()};setTimeout(()=>{this.zr.on("click",t)},10),this.zr.on("mousedown",this.onMouseDown),this.context.events.on("chart:dataZoom",this.onChartInteraction),this.clearHandlers={click:t,mousedown:this.onMouseDown,dataZoom:this.onChartInteraction}}disableClearListeners(){this.clearHandlers.click&&this.zr.off("click",this.clearHandlers.click),this.clearHandlers.mousedown&&this.zr.off("mousedown",this.clearHandlers.mousedown),this.clearHandlers.dataZoom&&this.context.events.off("chart:dataZoom",this.clearHandlers.dataZoom),this.clearHandlers={}}initGraphic(){this.group||(this.group=new G.graphic.Group,this.rect=new G.graphic.Rect({shape:{x:0,y:0,width:0,height:0},style:{fill:"rgba(0,0,0,0)",stroke:"transparent",lineWidth:0},z:100}),this.lineV=new G.graphic.Line({shape:{x1:0,y1:0,x2:0,y2:0},style:{stroke:"#fff",lineWidth:1,lineDash:[4,4]},z:101}),this.lineH=new G.graphic.Line({shape:{x1:0,y1:0,x2:0,y2:0},style:{stroke:"#fff",lineWidth:1,lineDash:[4,4]},z:101}),this.arrowStart=new G.graphic.Polygon({shape:{points:[[0,0],[-5,10],[5,10]]},style:{fill:"#fff"},z:102}),this.arrowEnd=new G.graphic.Polygon({shape:{points:[[0,0],[-5,-10],[5,-10]]},style:{fill:"#fff"},z:102}),this.labelRect=new G.graphic.Rect({shape:{x:0,y:0,width:0,height:0,r:4},style:{fill:"transparent",stroke:"transparent",lineWidth:0,shadowBlur:5,shadowColor:"rgba(0,0,0,0.3)"},z:102}),this.labelText=new G.graphic.Text({style:{x:0,y:0,text:"",fill:"#fff",font:"12px sans-serif",align:"center",verticalAlign:"middle"},z:103}),this.group.add(this.rect),this.group.add(this.lineV),this.group.add(this.lineH),this.group.add(this.arrowStart),this.group.add(this.arrowEnd),this.group.add(this.labelRect),this.group.add(this.labelText),this.zr.add(this.group))}removeGraphic(){this.group&&(this.zr.remove(this.group),this.group=null,this.disableClearListeners())}updateGraphic(){if(!this.startPoint||!this.endPoint||!this.group)return;const[t,e]=this.startPoint,[i,s]=this.endPoint,a=this.context.coordinateConversion.pixelToData({x:t,y:e}),n=this.context.coordinateConversion.pixelToData({x:i,y:s});if(!a||!n)return;const l=Math.round(a.timeIndex),r=Math.round(n.timeIndex),o=a.value,u=n.value,d=r-l,c=u-o,g=c/o*100,h=c>=0,f=h?"rgba(33, 150, 243, 0.2)":"rgba(236, 0, 0, 0.2)",y=h?"#2196F3":"#ec0000";this.rect.setShape({x:Math.min(t,i),y:Math.min(e,s),width:Math.abs(i-t),height:Math.abs(s-e)}),this.rect.setStyle({fill:f});const x=(t+i)/2,b=(e+s)/2;this.lineV.setShape({x1:x,y1:e,x2:x,y2:s}),this.lineV.setStyle({stroke:y}),this.lineH.setShape({x1:t,y1:b,x2:i,y2:b}),this.lineH.setStyle({stroke:y});const D=Math.min(e,s),w=Math.max(e,s);this.arrowStart.setStyle({fill:"none"}),this.arrowEnd.setStyle({fill:"none"}),h?(this.arrowStart.setShape({points:[[x,D],[x-4,D+6],[x+4,D+6]]}),this.arrowStart.setStyle({fill:y})):(this.arrowEnd.setShape({points:[[x,w],[x-4,w-6],[x+4,w-6]]}),this.arrowEnd.setStyle({fill:y}));const k=[`${c.toFixed(2)} (${g.toFixed(2)}%)`,`${d} bars`].join(`
40
- `),m=140,C=40,v=Math.max(e,s),_=Math.min(e,s);let A=(t+i)/2-m/2,M=v+10;const S=this.chart.getHeight();M+C>S&&(M=_-C-10),this.labelRect.setShape({x:A,y:M,width:m,height:C}),this.labelRect.setStyle({fill:"#1e293b",stroke:y,lineWidth:1}),this.labelText.setStyle({x:A+m/2,y:M+C/2,text:k,fill:"#fff"})}}var ki=Object.defineProperty,Pi=(p,t,e)=>t in p?ki(p,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):p[t]=e,Ai=(p,t,e)=>(Pi(p,typeof t!="symbol"?t+"":t,e),e);class oe{constructor(){Ai(this,"type","line")}render(t){const{drawing:e,pixelPoints:i,isSelected:s}=t,[a,n]=i[0],[l,r]=i[1],o=e.style?.color||"#3b82f6";return{type:"group",children:[{type:"line",name:"line",shape:{x1:a,y1:n,x2:l,y2:r},style:{stroke:o,lineWidth:e.style?.lineWidth||2}},{type:"circle",name:"point-0",shape:{cx:a,cy:n,r:4},style:{fill:"#fff",stroke:o,lineWidth:1,opacity:s?1:0}},{type:"circle",name:"point-1",shape:{cx:l,cy:r,r:4},style:{fill:"#fff",stroke:o,lineWidth:1,opacity:s?1:0}}]}}}var Di=Object.defineProperty,Mi=(p,t,e)=>t in p?Di(p,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):p[t]=e,ct=(p,t,e)=>(Mi(p,typeof t!="symbol"?t+"":t,e),e);class Si extends it{constructor(t={}){super({id:"trend-line",name:t?.name||"Trend Line",icon:t?.icon||'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="2" y1="22" x2="22" y2="2" /></svg>'}),ct(this,"zr"),ct(this,"state","idle"),ct(this,"startPoint",null),ct(this,"endPoint",null),ct(this,"group",null),ct(this,"line",null),ct(this,"startCircle",null),ct(this,"endCircle",null),ct(this,"onClick",e=>{if(this.state==="idle")this.state="drawing",this.startPoint=this.getPoint(e),this.endPoint=this.getPoint(e),this.initGraphic(),this.updateGraphic();else if(this.state==="drawing"){if(this.state="finished",this.endPoint=this.getPoint(e),this.updateGraphic(),this.startPoint&&this.endPoint){const i=this.context.coordinateConversion.pixelToData({x:this.startPoint[0],y:this.startPoint[1]}),s=this.context.coordinateConversion.pixelToData({x:this.endPoint[0],y:this.endPoint[1]});if(i&&s){const a=i.paneIndex||0;this.context.addDrawing({id:`line-${Date.now()}`,type:"line",points:[i,s],paneIndex:a,style:{color:"#3b82f6",lineWidth:2}})}}this.removeGraphic(),this.context.disableTools()}}),ct(this,"onMouseMove",e=>{this.state==="drawing"&&(this.endPoint=this.getPoint(e),this.updateGraphic())})}onInit(){this.zr=this.chart.getZr(),this.context.registerDrawingRenderer(new oe)}onActivate(){this.state="idle",this.chart.getZr().setCursorStyle("crosshair"),this.zr.on("click",this.onClick),this.zr.on("mousemove",this.onMouseMove)}onDeactivate(){this.state="idle",this.chart.getZr().setCursorStyle("default"),this.zr.off("click",this.onClick),this.zr.off("mousemove",this.onMouseMove),this.state==="drawing"&&this.removeGraphic()}onDestroy(){this.removeGraphic()}initGraphic(){this.group||(this.group=new G.graphic.Group,this.line=new G.graphic.Line({shape:{x1:0,y1:0,x2:0,y2:0},style:{stroke:"#3b82f6",lineWidth:2},z:100}),this.startCircle=new G.graphic.Circle({shape:{cx:0,cy:0,r:4},style:{fill:"#fff",stroke:"#3b82f6",lineWidth:1},z:101}),this.endCircle=new G.graphic.Circle({shape:{cx:0,cy:0,r:4},style:{fill:"#fff",stroke:"#3b82f6",lineWidth:1},z:101}),this.group.add(this.line),this.group.add(this.startCircle),this.group.add(this.endCircle),this.zr.add(this.group))}removeGraphic(){this.group&&(this.zr.remove(this.group),this.group=null)}updateGraphic(){if(!this.startPoint||!this.endPoint||!this.group)return;const[t,e]=this.startPoint,[i,s]=this.endPoint;this.line.setShape({x1:t,y1:e,x2:i,y2:s}),this.startCircle.setShape({cx:t,cy:e}),this.endCircle.setShape({cx:i,cy:s})}}var Gi=Object.defineProperty,$i=(p,t,e)=>t in p?Gi(p,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):p[t]=e,zi=(p,t,e)=>($i(p,typeof t!="symbol"?t+"":t,e),e);const Xt=[0,.236,.382,.5,.618,.786,1],Tt=["#787b86","#f44336","#ff9800","#4caf50","#2196f3","#00bcd4","#787b86"];class ae{constructor(){zi(this,"type","fibonacci")}render(t){const{drawing:e,pixelPoints:i,isSelected:s}=t,[a,n]=i[0],[l,r]=i[1],o=e.style?.color||"#3b82f6",u=Math.min(a,l),d=Math.max(a,l),c=d-u,g=r-n,h=e.points[0].value,f=e.points[1].value,y=f-h,x=[],b=[];return Xt.forEach((D,w)=>{const k=r-g*D,m=Tt[w%Tt.length];b.push({type:"line",shape:{x1:u,y1:k,x2:d,y2:k},style:{stroke:m,lineWidth:1},silent:!0});const C=f-y*D;if(b.push({type:"text",style:{text:`${D} (${C.toFixed(2)})`,x:u+5,y:k-10,fill:m,fontSize:10},silent:!0}),w<Xt.length-1){const v=Xt[w+1],_=r-g*v,A=Math.abs(_-k),M=Math.min(k,_);x.push({type:"rect",name:"line",shape:{x:u,y:M,width:c,height:A},style:{fill:Tt[(w+1)%Tt.length],opacity:.1}})}}),{type:"group",children:[...x,...b,{type:"line",name:"line",shape:{x1:a,y1:n,x2:l,y2:r},style:{stroke:"#999",lineWidth:1,lineDash:[4,4]}},{type:"circle",name:"point-0",shape:{cx:a,cy:n,r:4},style:{fill:"#fff",stroke:o,lineWidth:1,opacity:s?1:0},z:100},{type:"circle",name:"point-1",shape:{cx:l,cy:r,r:4},style:{fill:"#fff",stroke:o,lineWidth:1,opacity:s?1:0},z:100}]}}}var Ei=Object.defineProperty,Li=(p,t,e)=>t in p?Ei(p,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):p[t]=e,gt=(p,t,e)=>(Li(p,typeof t!="symbol"?t+"":t,e),e);class Wi extends it{constructor(t={}){super({id:"fibonacci-tool",name:t.name||"Fibonacci Retracement",icon:t.icon||'<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="#e3e3e3"><path d="M120-80v-80h720v80H120Zm0-240v-80h720v80H120Zm0-240v-80h720v80H120Zm0-240v-80h720v80H120Z"/></svg>'}),gt(this,"startPoint",null),gt(this,"endPoint",null),gt(this,"state","idle"),gt(this,"graphicGroup",null),gt(this,"levels",[0,.236,.382,.5,.618,.786,1]),gt(this,"colors",["#787b86","#f44336","#ff9800","#4caf50","#2196f3","#00bcd4","#787b86"]),gt(this,"onClick",e=>{this.state==="idle"?(this.state="drawing",this.startPoint=this.getPoint(e),this.endPoint=this.getPoint(e),this.initGraphic(),this.updateGraphic()):this.state==="drawing"&&(this.state="finished",this.endPoint=this.getPoint(e),this.updateGraphic(),this.saveDrawing(),this.removeGraphic(),this.context.disableTools())}),gt(this,"onMouseMove",e=>{this.state==="drawing"&&(this.endPoint=this.getPoint(e),this.updateGraphic())})}onInit(){this.context.registerDrawingRenderer(new ae)}onActivate(){this.state="idle",this.startPoint=null,this.endPoint=null,this.context.getChart().getZr().setCursorStyle("crosshair"),this.bindEvents()}onDeactivate(){this.state="idle",this.startPoint=null,this.endPoint=null,this.removeGraphic(),this.unbindEvents(),this.context.getChart().getZr().setCursorStyle("default")}bindEvents(){const t=this.context.getChart().getZr();t.on("click",this.onClick),t.on("mousemove",this.onMouseMove)}unbindEvents(){const t=this.context.getChart().getZr();t.off("click",this.onClick),t.off("mousemove",this.onMouseMove)}initGraphic(){this.graphicGroup=new G.graphic.Group,this.context.getChart().getZr().add(this.graphicGroup)}removeGraphic(){this.graphicGroup&&(this.context.getChart().getZr().remove(this.graphicGroup),this.graphicGroup=null)}updateGraphic(){if(!this.graphicGroup||!this.startPoint||!this.endPoint)return;this.graphicGroup.removeAll();const t=this.startPoint[0],e=this.startPoint[1],i=this.endPoint[0],s=this.endPoint[1],a=new G.graphic.Line({shape:{x1:t,y1:e,x2:i,y2:s},style:{stroke:"#999",lineWidth:1,lineDash:[4,4]},silent:!0});this.graphicGroup.add(a);const n=Math.min(t,i),l=Math.max(t,i),r=l-n,o=s-e;this.levels.forEach((u,d)=>{const c=s-o*u,g=this.colors[d%this.colors.length],h=new G.graphic.Line({shape:{x1:n,y1:c,x2:l,y2:c},style:{stroke:g,lineWidth:1},silent:!0});if(this.graphicGroup.add(h),d<this.levels.length-1){const f=this.levels[d+1],y=s-o*f,x=Math.abs(y-c),b=Math.min(c,y),D=new G.graphic.Rect({shape:{x:n,y:b,width:r,height:x},style:{fill:this.colors[(d+1)%this.colors.length],opacity:.1},silent:!0});this.graphicGroup.add(D)}})}saveDrawing(){if(!this.startPoint||!this.endPoint)return;const t=this.context.coordinateConversion.pixelToData({x:this.startPoint[0],y:this.startPoint[1]}),e=this.context.coordinateConversion.pixelToData({x:this.endPoint[0],y:this.endPoint[1]});if(t&&e){const i=t.paneIndex||0;this.context.addDrawing({id:`fib-${Date.now()}`,type:"fibonacci",points:[t,e],paneIndex:i,style:{color:"#3b82f6",lineWidth:1}})}}}var Ti=Object.defineProperty,Ni=(p,t,e)=>t in p?Ti(p,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):p[t]=e,Zi=(p,t,e)=>(Ni(p,typeof t!="symbol"?t+"":t,e),e);const Nt=[0,.236,.382,.5,.618,.786,1],Zt=["#787b86","#f44336","#ff9800","#4caf50","#2196f3","#00bcd4","#787b86"];class re{constructor(){Zi(this,"type","fibonacci_channel")}render(t){const{drawing:e,pixelPoints:i,isSelected:s}=t,[a,n]=i[0],[l,r]=i[1],[o,u]=i[2],d=e.style?.color||"#3b82f6",c=l-a,g=r-n,h=Math.sqrt(c*c+g*g);if(h===0)return;const f=-g/h,y=c/h,x=(o-a)*f+(u-n)*y,b=[],D=[];return Nt.forEach((w,k)=>{const m=f*x*w,C=y*x*w,v=a+m,_=n+C,A=l+m,M=r+C;if(D.push({lx1:v,ly1:_,lx2:A,ly2:M}),k<Nt.length-1){const S=Nt[k+1],z=f*x*S,W=y*x*S;b.push({type:"polygon",name:"line",shape:{points:[[v,_],[A,M],[l+z,r+W],[a+z,n+W]]},style:{fill:Zt[(k+1)%Zt.length],opacity:.1}})}}),D.forEach((w,k)=>{const m=Zt[k%Zt.length];b.push({type:"line",shape:{x1:w.lx1,y1:w.ly1,x2:w.lx2,y2:w.ly2},style:{stroke:m,lineWidth:1},silent:!0}),b.push({type:"text",style:{text:`${Nt[k]}`,x:w.lx2+5,y:w.ly2-5,fill:m,fontSize:10},silent:!0})}),b.push({type:"line",name:"line",shape:{x1:a,y1:n,x2:l,y2:r},style:{stroke:"#999",lineWidth:1,lineDash:[4,4]}}),b.push({type:"circle",name:"point-0",shape:{cx:a,cy:n,r:4},style:{fill:"#fff",stroke:d,lineWidth:1,opacity:s?1:0},z:100}),b.push({type:"circle",name:"point-1",shape:{cx:l,cy:r,r:4},style:{fill:"#fff",stroke:d,lineWidth:1,opacity:s?1:0},z:100}),b.push({type:"circle",name:"point-2",shape:{cx:o,cy:u,r:4},style:{fill:"#fff",stroke:d,lineWidth:1,opacity:s?1:0},z:100}),{type:"group",children:b}}}var Fi=Object.defineProperty,Oi=(p,t,e)=>t in p?Fi(p,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):p[t]=e,ut=(p,t,e)=>(Oi(p,typeof t!="symbol"?t+"":t,e),e);class Hi extends it{constructor(t={}){super({id:"fibonacci-channel-tool",name:t.name||"Fibonacci Channel",icon:t.icon||'<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="#e3e3e3"><path d="M120-200v-80l80-80H120v-80h160l120-120H120v-80h360l120-120H120v-80h720v80H520l-120 120h440v80H320L200-440h640v80H280l-80 80h640v80H120Z"/></svg>'}),ut(this,"startPoint",null),ut(this,"endPoint",null),ut(this,"widthPoint",null),ut(this,"state","idle"),ut(this,"graphicGroup",null),ut(this,"levels",[0,.236,.382,.5,.618,.786,1]),ut(this,"colors",["#787b86","#f44336","#ff9800","#4caf50","#2196f3","#00bcd4","#787b86"]),ut(this,"onClick",e=>{this.state==="idle"?(this.state="drawing-baseline",this.startPoint=this.getPoint(e),this.endPoint=this.getPoint(e),this.initGraphic(),this.updateGraphic()):this.state==="drawing-baseline"?(this.state="drawing-width",this.endPoint=this.getPoint(e),this.widthPoint=this.getPoint(e),this.updateGraphic()):this.state==="drawing-width"&&(this.state="finished",this.widthPoint=this.getPoint(e),this.updateGraphic(),this.saveDrawing(),this.removeGraphic(),this.context.disableTools())}),ut(this,"onMouseMove",e=>{this.state==="drawing-baseline"?(this.endPoint=this.getPoint(e),this.updateGraphic()):this.state==="drawing-width"&&(this.widthPoint=this.getPoint(e),this.updateGraphic())})}onInit(){this.context.registerDrawingRenderer(new re)}onActivate(){this.state="idle",this.startPoint=null,this.endPoint=null,this.widthPoint=null,this.context.getChart().getZr().setCursorStyle("crosshair"),this.bindEvents()}onDeactivate(){this.state="idle",this.startPoint=null,this.endPoint=null,this.widthPoint=null,this.removeGraphic(),this.unbindEvents(),this.context.getChart().getZr().setCursorStyle("default")}bindEvents(){const t=this.context.getChart().getZr();t.on("click",this.onClick),t.on("mousemove",this.onMouseMove)}unbindEvents(){const t=this.context.getChart().getZr();t.off("click",this.onClick),t.off("mousemove",this.onMouseMove)}initGraphic(){this.graphicGroup=new G.graphic.Group,this.context.getChart().getZr().add(this.graphicGroup)}removeGraphic(){this.graphicGroup&&(this.context.getChart().getZr().remove(this.graphicGroup),this.graphicGroup=null)}updateGraphic(){if(!this.graphicGroup||!this.startPoint||!this.endPoint)return;this.graphicGroup.removeAll();const t=this.startPoint[0],e=this.startPoint[1],i=this.endPoint[0],s=this.endPoint[1];if(this.graphicGroup.add(new G.graphic.Line({shape:{x1:t,y1:e,x2:i,y2:s},style:{stroke:"#787b86",lineWidth:2},silent:!0})),this.widthPoint&&this.state!=="drawing-baseline"){const a=this.widthPoint,n=i-t,l=s-e,r=Math.sqrt(n*n+l*l);if(r===0)return;const o=-l/r,u=n/r,d=(a[0]-t)*o+(a[1]-e)*u;this.levels.forEach((c,g)=>{const h=o*d*c,f=u*d*c,y=t+h,x=e+f,b=i+h,D=s+f,w=this.colors[g%this.colors.length];if(this.graphicGroup.add(new G.graphic.Line({shape:{x1:y,y1:x,x2:b,y2:D},style:{stroke:w,lineWidth:1},silent:!0})),g<this.levels.length-1){const k=this.levels[g+1],m=o*d*k,C=u*d*k,v=t+m,_=e+C,A=i+m,M=s+C;this.graphicGroup.add(new G.graphic.Polygon({shape:{points:[[y,x],[b,D],[A,M],[v,_]]},style:{fill:this.colors[(g+1)%this.colors.length],opacity:.1},silent:!0}))}})}}saveDrawing(){if(!this.startPoint||!this.endPoint||!this.widthPoint)return;const t=this.context.coordinateConversion.pixelToData({x:this.startPoint[0],y:this.startPoint[1]}),e=this.context.coordinateConversion.pixelToData({x:this.endPoint[0],y:this.endPoint[1]}),i=this.context.coordinateConversion.pixelToData({x:this.widthPoint[0],y:this.widthPoint[1]});if(t&&e&&i){const s=t.paneIndex||0;this.context.addDrawing({id:`fib-channel-${Date.now()}`,type:"fibonacci_channel",points:[t,e,i],paneIndex:s,style:{color:"#3b82f6",lineWidth:1}})}}}var Ri=Object.defineProperty,Bi=(p,t,e)=>t in p?Ri(p,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):p[t]=e,ji=(p,t,e)=>(Bi(p,typeof t!="symbol"?t+"":t,e),e);const Vt=[0,.236,.382,.5,.618,.786,1],ft=["#787b86","#f44336","#ff9800","#4caf50","#2196f3","#00bcd4","#787b86"];class le{constructor(){ji(this,"type","fib_speed_resistance_fan")}render(t){const{drawing:e,pixelPoints:i,isSelected:s}=t,[a,n]=i[0],[l,r]=i[1],o=e.style?.color||"#3b82f6",u=l-a,d=r-n,c=[],g=[],h=[];for(const f of Vt)g.push([a+u,n+d*f]),h.push([a+u*f,n+d]);for(let f=0;f<g.length-1;f++)c.push({type:"polygon",name:"line",shape:{points:[[a,n],g[f],g[f+1]]},style:{fill:ft[(f+1)%ft.length],opacity:.06}});for(let f=0;f<h.length-1;f++)c.push({type:"polygon",name:"line",shape:{points:[[a,n],h[f],h[f+1]]},style:{fill:ft[(f+1)%ft.length],opacity:.06}});return Vt.forEach((f,y)=>{const[x,b]=g[y],D=ft[y%ft.length];c.push({type:"line",shape:{x1:a,y1:n,x2:x,y2:b},style:{stroke:D,lineWidth:1},silent:!0}),c.push({type:"text",style:{text:`${f}`,x:x+3,y:b-2,fill:D,fontSize:9},silent:!0})}),Vt.forEach((f,y)=>{const[x,b]=h[y],D=ft[y%ft.length];c.push({type:"line",shape:{x1:a,y1:n,x2:x,y2:b},style:{stroke:D,lineWidth:1},silent:!0}),c.push({type:"text",style:{text:`${f}`,x:x-2,y:b+8,fill:D,fontSize:9},silent:!0})}),c.push({type:"line",name:"line",shape:{x1:l,y1:n,x2:l,y2:r},style:{stroke:"#555",lineWidth:1,lineDash:[3,3]}}),c.push({type:"line",name:"line",shape:{x1:a,y1:r,x2:l,y2:r},style:{stroke:"#555",lineWidth:1,lineDash:[3,3]}}),c.push({type:"line",name:"line",shape:{x1:a,y1:n,x2:l,y2:r},style:{stroke:"#999",lineWidth:1,lineDash:[4,4]}}),c.push({type:"circle",name:"point-0",shape:{cx:a,cy:n,r:4},style:{fill:"#fff",stroke:o,lineWidth:1,opacity:s?1:0},z:100}),c.push({type:"circle",name:"point-1",shape:{cx:l,cy:r,r:4},style:{fill:"#fff",stroke:o,lineWidth:1,opacity:s?1:0},z:100}),{type:"group",children:c}}}var Yi=Object.defineProperty,Xi=(p,t,e)=>t in p?Yi(p,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):p[t]=e,It=(p,t,e)=>(Xi(p,typeof t!="symbol"?t+"":t,e),e);const xt=[0,.236,.382,.5,.618,.786,1],_t=["#787b86","#f44336","#ff9800","#4caf50","#2196f3","#00bcd4","#787b86"];class Vi extends it{constructor(t={}){super({id:"fib-speed-resistance-fan-tool",name:t.name||"Fib Speed Resistance Fan",icon:t.icon||'<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#e3e3e3"><path d="M2 21L22 3M2 21l20-6M2 21l20-9M2 21l20-12M2 21l20-15M2 21l6-18M2 21l9-18M2 21l12-18M2 21l15-18" stroke="#e3e3e3" stroke-width="1" fill="none"/></svg>'}),It(this,"startPoint",null),It(this,"endPoint",null),It(this,"state","idle"),It(this,"graphicGroup",null),It(this,"onClick",e=>{this.state==="idle"?(this.state="drawing",this.startPoint=this.getPoint(e),this.endPoint=this.getPoint(e),this.initGraphic(),this.updateGraphic()):this.state==="drawing"&&(this.state="finished",this.endPoint=this.getPoint(e),this.updateGraphic(),this.saveDrawing(),this.removeGraphic(),this.context.disableTools())}),It(this,"onMouseMove",e=>{this.state==="drawing"&&(this.endPoint=this.getPoint(e),this.updateGraphic())})}onInit(){this.context.registerDrawingRenderer(new le)}onActivate(){this.state="idle",this.startPoint=null,this.endPoint=null,this.context.getChart().getZr().setCursorStyle("crosshair"),this.bindEvents()}onDeactivate(){this.state="idle",this.startPoint=null,this.endPoint=null,this.removeGraphic(),this.unbindEvents(),this.context.getChart().getZr().setCursorStyle("default")}bindEvents(){const t=this.context.getChart().getZr();t.on("click",this.onClick),t.on("mousemove",this.onMouseMove)}unbindEvents(){const t=this.context.getChart().getZr();t.off("click",this.onClick),t.off("mousemove",this.onMouseMove)}initGraphic(){this.graphicGroup=new G.graphic.Group,this.context.getChart().getZr().add(this.graphicGroup)}removeGraphic(){this.graphicGroup&&(this.context.getChart().getZr().remove(this.graphicGroup),this.graphicGroup=null)}updateGraphic(){if(!this.graphicGroup||!this.startPoint||!this.endPoint)return;this.graphicGroup.removeAll();const t=this.startPoint[0],e=this.startPoint[1],i=this.endPoint[0],s=this.endPoint[1],a=i-t,n=s-e;xt.forEach((l,r)=>{const o=_t[r%_t.length];this.graphicGroup.add(new G.graphic.Line({shape:{x1:t,y1:e,x2:t+a,y2:e+n*l},style:{stroke:o,lineWidth:1},silent:!0})),this.graphicGroup.add(new G.graphic.Line({shape:{x1:t,y1:e,x2:t+a*l,y2:e+n},style:{stroke:o,lineWidth:1},silent:!0}))});for(let l=0;l<xt.length-1;l++){const r=[t+a,e+n*xt[l]],o=[t+a,e+n*xt[l+1]];this.graphicGroup.add(new G.graphic.Polygon({shape:{points:[[t,e],r,o]},style:{fill:_t[(l+1)%_t.length],opacity:.06},silent:!0}))}for(let l=0;l<xt.length-1;l++){const r=[t+a*xt[l],e+n],o=[t+a*xt[l+1],e+n];this.graphicGroup.add(new G.graphic.Polygon({shape:{points:[[t,e],r,o]},style:{fill:_t[(l+1)%_t.length],opacity:.06},silent:!0}))}this.graphicGroup.add(new G.graphic.Line({shape:{x1:i,y1:e,x2:i,y2:s},style:{stroke:"#555",lineWidth:1,lineDash:[3,3]},silent:!0})),this.graphicGroup.add(new G.graphic.Line({shape:{x1:t,y1:s,x2:i,y2:s},style:{stroke:"#555",lineWidth:1,lineDash:[3,3]},silent:!0})),this.graphicGroup.add(new G.graphic.Line({shape:{x1:t,y1:e,x2:i,y2:s},style:{stroke:"#999",lineWidth:1,lineDash:[4,4]},silent:!0}))}saveDrawing(){if(!this.startPoint||!this.endPoint)return;const t=this.context.coordinateConversion.pixelToData({x:this.startPoint[0],y:this.startPoint[1]}),e=this.context.coordinateConversion.pixelToData({x:this.endPoint[0],y:this.endPoint[1]});t&&e&&this.context.addDrawing({id:`fib-fan-${Date.now()}`,type:"fib_speed_resistance_fan",points:[t,e],paneIndex:t.paneIndex||0,style:{color:"#3b82f6",lineWidth:1}})}}var qi=Object.defineProperty,Ui=(p,t,e)=>t in p?qi(p,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):p[t]=e,Ki=(p,t,e)=>(Ui(p,typeof t!="symbol"?t+"":t,e),e);const he=[0,.236,.382,.5,.618,.786,1,1.272,1.618,2,2.618],ce=["#787b86","#f44336","#ff9800","#4caf50","#2196f3","#00bcd4","#787b86","#e91e63","#9c27b0","#673ab7","#3f51b5"];class pe{constructor(){Ki(this,"type","fib_trend_extension")}render(t){const{drawing:e,pixelPoints:i,isSelected:s,api:a}=t,n=e.style?.color||"#3b82f6";if(i.length<3)return;const[l,r]=i[0],[o,u]=i[1],[d,c]=i[2],g=e.points,h=g[1].value-g[0].value,f=Math.min(l,o,d),y=Math.max(l,o,d),x=(y-f)*.5,b=f,D=y+x,w=[],k=[];for(let v=0;v<he.length;v++){const _=he[v],A=g[2].value+h*_;a.coord([g[2].timeIndex+t.drawing.points[2].timeIndex-g[2].timeIndex,A]);const M=c+(u-r)*_;k.push({level:_,y:M,price:A,color:ce[v%ce.length]})}for(let v=0;v<k.length-1;v++){const _=k[v],A=k[v+1],M=Math.min(_.y,A.y),S=Math.abs(A.y-_.y);w.push({type:"rect",name:"line",shape:{x:b,y:M,width:D-b,height:S},style:{fill:A.color,opacity:.06}})}for(const v of k)w.push({type:"line",shape:{x1:b,y1:v.y,x2:D,y2:v.y},style:{stroke:v.color,lineWidth:1},silent:!0}),w.push({type:"text",style:{text:`${v.level} (${v.price.toFixed(2)})`,x:D+4,y:v.y-6,fill:v.color,fontSize:9},silent:!0});w.push({type:"line",name:"line",shape:{x1:l,y1:r,x2:o,y2:u},style:{stroke:"#2196f3",lineWidth:1.5,lineDash:[5,4]}}),w.push({type:"line",name:"line",shape:{x1:o,y1:u,x2:d,y2:c},style:{stroke:"#ff9800",lineWidth:1.5,lineDash:[5,4]}}),w.push({type:"circle",name:"point-0",shape:{cx:l,cy:r,r:4},style:{fill:"#fff",stroke:n,lineWidth:1,opacity:s?1:0},z:100}),w.push({type:"circle",name:"point-1",shape:{cx:o,cy:u,r:4},style:{fill:"#fff",stroke:n,lineWidth:1,opacity:s?1:0},z:100}),w.push({type:"circle",name:"point-2",shape:{cx:d,cy:c,r:4},style:{fill:"#fff",stroke:n,lineWidth:1,opacity:s?1:0},z:100});const m=["1","2","3"],C=[i[0],i[1],i[2]];for(let v=0;v<3;v++){const[_,A]=C[v],M=(v===0||A<=C[v-1][1])&&(v===2||A<=C[v+1]?.[1]);w.push({type:"text",style:{text:m[v],x:_,y:M?A-14:A+16,fill:"#e2e8f0",fontSize:12,fontWeight:"bold",align:"center",verticalAlign:"middle"},silent:!0})}return{type:"group",children:w}}}var Ji=Object.defineProperty,Qi=(p,t,e)=>t in p?Ji(p,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):p[t]=e,Dt=(p,t,e)=>(Qi(p,typeof t!="symbol"?t+"":t,e),e);const Ft=[0,.236,.382,.5,.618,.786,1,1.272,1.618,2,2.618],Ot=["#787b86","#f44336","#ff9800","#4caf50","#2196f3","#00bcd4","#787b86","#e91e63","#9c27b0","#673ab7","#3f51b5"];class ts extends it{constructor(t={}){super({id:"fib-trend-extension-tool",name:t.name||"Fib Trend Extension",icon:t.icon||'<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="#e3e3e3"><path d="M120-80v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Z"/></svg>'}),Dt(this,"points",[]),Dt(this,"state","idle"),Dt(this,"graphicGroup",null),Dt(this,"onClick",e=>{const i=this.getPoint(e);this.state==="idle"?(this.state="drawing-trend",this.points=[i,[...i]],this.initGraphic(),this.updateGraphic()):this.state==="drawing-trend"?(this.state="drawing-retracement",this.points[1]=i,this.points.push([...i]),this.updateGraphic()):this.state==="drawing-retracement"&&(this.state="finished",this.points[2]=i,this.updateGraphic(),this.saveDrawing(),this.removeGraphic(),this.context.disableTools())}),Dt(this,"onMouseMove",e=>{this.state==="drawing-trend"?(this.points[1]=this.getPoint(e),this.updateGraphic()):this.state==="drawing-retracement"&&(this.points[2]=this.getPoint(e),this.updateGraphic())})}onInit(){this.context.registerDrawingRenderer(new pe)}onActivate(){this.state="idle",this.points=[],this.context.getChart().getZr().setCursorStyle("crosshair"),this.bindEvents()}onDeactivate(){this.state="idle",this.points=[],this.removeGraphic(),this.unbindEvents(),this.context.getChart().getZr().setCursorStyle("default")}bindEvents(){const t=this.context.getChart().getZr();t.on("click",this.onClick),t.on("mousemove",this.onMouseMove)}unbindEvents(){const t=this.context.getChart().getZr();t.off("click",this.onClick),t.off("mousemove",this.onMouseMove)}initGraphic(){this.graphicGroup=new G.graphic.Group,this.context.getChart().getZr().add(this.graphicGroup)}removeGraphic(){this.graphicGroup&&(this.context.getChart().getZr().remove(this.graphicGroup),this.graphicGroup=null)}updateGraphic(){if(!this.graphicGroup)return;this.graphicGroup.removeAll();const[t,e]=this.points[0],[i,s]=this.points[1];if(this.graphicGroup.add(new G.graphic.Line({shape:{x1:t,y1:e,x2:i,y2:s},style:{stroke:"#2196f3",lineWidth:1.5,lineDash:[5,4]},silent:!0})),this.points.length>=3){const[a,n]=this.points[2];this.graphicGroup.add(new G.graphic.Line({shape:{x1:i,y1:s,x2:a,y2:n},style:{stroke:"#ff9800",lineWidth:1.5,lineDash:[5,4]},silent:!0}));const l=s-e,r=Math.min(t,i,a),o=Math.max(t,i,a),u=(o-r)*.5,d=r,c=o+u;for(let g=0;g<Ft.length;g++){const h=Ft[g],f=n+l*h,y=Ot[g%Ot.length];if(this.graphicGroup.add(new G.graphic.Line({shape:{x1:d,y1:f,x2:c,y2:f},style:{stroke:y,lineWidth:1},silent:!0})),this.graphicGroup.add(new G.graphic.Text({style:{text:`${h}`,x:c+4,y:f-6,fill:y,fontSize:9},silent:!0})),g<Ft.length-1){const x=n+l*Ft[g+1],b=Math.min(f,x),D=Math.abs(x-f);this.graphicGroup.add(new G.graphic.Rect({shape:{x:d,y:b,width:c-d,height:D},style:{fill:Ot[(g+1)%Ot.length],opacity:.06},silent:!0}))}}}for(const a of this.points)this.graphicGroup.add(new G.graphic.Circle({shape:{cx:a[0],cy:a[1],r:4},style:{fill:"#fff",stroke:"#3b82f6",lineWidth:1.5},z:101,silent:!0}))}saveDrawing(){const t=this.points.map(e=>this.context.coordinateConversion.pixelToData({x:e[0],y:e[1]}));t.every(e=>e!==null)&&this.context.addDrawing({id:`fib-ext-${Date.now()}`,type:"fib_trend_extension",points:t,paneIndex:t[0].paneIndex||0,style:{color:"#3b82f6",lineWidth:1}})}}var es=Object.defineProperty,is=(p,t,e)=>t in p?es(p,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):p[t]=e,ss=(p,t,e)=>(is(p,typeof t!="symbol"?t+"":t,e),e);const de=["X","A","B","C","D"],ue=["#2196f3","#ff9800","#4caf50","#f44336"],ns="rgba(33, 150, 243, 0.08)",os="rgba(244, 67, 54, 0.08)";class ge{constructor(){ss(this,"type","xabcd_pattern")}render(t){const{drawing:e,pixelPoints:i,isSelected:s}=t,a=e.style?.color||"#3b82f6";if(i.length<2)return;const n=[];i.length>=3&&n.push({type:"polygon",name:"line",shape:{points:i.slice(0,3).map(([r,o])=>[r,o])},style:{fill:ns,opacity:1}}),i.length>=5&&n.push({type:"polygon",name:"line",shape:{points:i.slice(2,5).map(([r,o])=>[r,o])},style:{fill:os,opacity:1}});for(let r=0;r<i.length-1;r++){const[o,u]=i[r],[d,c]=i[r+1],g=ue[r%ue.length];n.push({type:"line",name:"line",shape:{x1:o,y1:u,x2:d,y2:c},style:{stroke:g,lineWidth:e.style?.lineWidth||2}})}const l=[[0,2],[1,3],[2,4]];for(const[r,o]of l)if(r<i.length&&o<i.length){const[u,d]=i[r],[c,g]=i[o];n.push({type:"line",shape:{x1:u,y1:d,x2:c,y2:g},style:{stroke:"#555",lineWidth:1,lineDash:[4,4]},silent:!0})}if(e.points.length>=3){const r=Math.abs(e.points[1].value-e.points[0].value),o=Math.abs(e.points[2].value-e.points[1].value);if(r!==0){const u=(o/r).toFixed(3),d=(i[1][0]+i[2][0])/2,c=(i[1][1]+i[2][1])/2;n.push({type:"text",style:{text:u,x:d+8,y:c,fill:"#ff9800",fontSize:10},silent:!0})}}if(e.points.length>=4){const r=Math.abs(e.points[2].value-e.points[1].value),o=Math.abs(e.points[3].value-e.points[2].value);if(r!==0){const u=(o/r).toFixed(3),d=(i[2][0]+i[3][0])/2,c=(i[2][1]+i[3][1])/2;n.push({type:"text",style:{text:u,x:d+8,y:c,fill:"#4caf50",fontSize:10},silent:!0})}}if(e.points.length>=5){const r=Math.abs(e.points[3].value-e.points[2].value),o=Math.abs(e.points[4].value-e.points[3].value);if(r!==0){const c=(o/r).toFixed(3),g=(i[3][0]+i[4][0])/2,h=(i[3][1]+i[4][1])/2;n.push({type:"text",style:{text:c,x:g+8,y:h,fill:"#f44336",fontSize:10},silent:!0})}const u=Math.abs(e.points[1].value-e.points[0].value),d=Math.abs(e.points[4].value-e.points[1].value);if(u!==0){const c=(d/u).toFixed(3),[g,h]=i[4];n.push({type:"text",style:{text:`AD/XA: ${c}`,x:g+10,y:h+14,fill:"#aaa",fontSize:9},silent:!0})}}for(let r=0;r<i.length&&r<de.length;r++){const[o,u]=i[r],d=(r===0||u<=i[r-1][1])&&(r===i.length-1||u<=i[r+1]?.[1])?u-14:u+16;n.push({type:"text",style:{text:de[r],x:o,y:d,fill:"#e2e8f0",fontSize:12,fontWeight:"bold",align:"center",verticalAlign:"middle"},silent:!0})}for(let r=0;r<i.length;r++){const[o,u]=i[r];n.push({type:"circle",name:`point-${r}`,shape:{cx:o,cy:u,r:4},style:{fill:"#fff",stroke:a,lineWidth:1,opacity:s?1:0},z:100})}return{type:"group",children:n}}}var as=Object.defineProperty,rs=(p,t,e)=>t in p?as(p,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):p[t]=e,Mt=(p,t,e)=>(rs(p,typeof t!="symbol"?t+"":t,e),e);const fe=["X","A","B","C","D"],ye=["#2196f3","#ff9800","#4caf50","#f44336"],ls=5;class hs extends it{constructor(t={}){super({id:"xabcd-pattern-tool",name:t.name||"XABCD Pattern",icon:t.icon||'<svg viewBox="0 0 24 24" width="24" height="24" fill="none" stroke="#e3e3e3" stroke-width="1.5"><polyline points="2,18 6,6 11,14 16,4 21,16"/><circle cx="2" cy="18" r="1.5" fill="#e3e3e3"/><circle cx="6" cy="6" r="1.5" fill="#e3e3e3"/><circle cx="11" cy="14" r="1.5" fill="#e3e3e3"/><circle cx="16" cy="4" r="1.5" fill="#e3e3e3"/><circle cx="21" cy="16" r="1.5" fill="#e3e3e3"/></svg>'}),Mt(this,"points",[]),Mt(this,"state","idle"),Mt(this,"graphicGroup",null),Mt(this,"onClick",e=>{const i=this.getPoint(e);this.state==="idle"?(this.state="drawing",this.points=[i,[...i]],this.initGraphic(),this.updateGraphic()):this.state==="drawing"&&(this.points[this.points.length-1]=i,this.points.length>=ls?(this.state="finished",this.updateGraphic(),this.saveDrawing(),this.removeGraphic(),this.context.disableTools()):(this.points.push([...i]),this.updateGraphic()))}),Mt(this,"onMouseMove",e=>{this.state!=="drawing"||this.points.length<2||(this.points[this.points.length-1]=this.getPoint(e),this.updateGraphic())})}onInit(){this.context.registerDrawingRenderer(new ge)}onActivate(){this.state="idle",this.points=[],this.context.getChart().getZr().setCursorStyle("crosshair"),this.bindEvents()}onDeactivate(){this.state="idle",this.points=[],this.removeGraphic(),this.unbindEvents(),this.context.getChart().getZr().setCursorStyle("default")}bindEvents(){const t=this.context.getChart().getZr();t.on("click",this.onClick),t.on("mousemove",this.onMouseMove)}unbindEvents(){const t=this.context.getChart().getZr();t.off("click",this.onClick),t.off("mousemove",this.onMouseMove)}initGraphic(){this.graphicGroup=new G.graphic.Group,this.context.getChart().getZr().add(this.graphicGroup)}removeGraphic(){this.graphicGroup&&(this.context.getChart().getZr().remove(this.graphicGroup),this.graphicGroup=null)}updateGraphic(){if(!this.graphicGroup)return;this.graphicGroup.removeAll();const t=this.points;t.length>=3&&this.graphicGroup.add(new G.graphic.Polygon({shape:{points:t.slice(0,3)},style:{fill:"rgba(33, 150, 243, 0.08)"},silent:!0})),t.length>=5&&this.graphicGroup.add(new G.graphic.Polygon({shape:{points:t.slice(2,5)},style:{fill:"rgba(244, 67, 54, 0.08)"},silent:!0}));for(let i=0;i<t.length-1;i++){const[s,a]=t[i],[n,l]=t[i+1];this.graphicGroup.add(new G.graphic.Line({shape:{x1:s,y1:a,x2:n,y2:l},style:{stroke:ye[i%ye.length],lineWidth:2},silent:!0}))}const e=[[0,2],[1,3],[2,4]];for(const[i,s]of e)if(i<t.length&&s<t.length){const[a,n]=t[i],[l,r]=t[s];this.graphicGroup.add(new G.graphic.Line({shape:{x1:a,y1:n,x2:l,y2:r},style:{stroke:"#555",lineWidth:1,lineDash:[4,4]},silent:!0}))}for(let i=0;i<t.length&&i<fe.length;i++){const[s,a]=t[i],n=(i===0||a<=t[i-1][1])&&(i===t.length-1||a<=t[i+1]?.[1])?a-14:a+16;this.graphicGroup.add(new G.graphic.Text({style:{text:fe[i],x:s,y:n,fill:"#e2e8f0",fontSize:12,fontWeight:"bold",align:"center",verticalAlign:"middle"},silent:!0}))}for(let i=0;i<t.length;i++){const[s,a]=t[i];this.graphicGroup.add(new G.graphic.Circle({shape:{cx:s,cy:a,r:4},style:{fill:"#fff",stroke:"#3b82f6",lineWidth:1.5},z:101,silent:!0}))}}saveDrawing(){const t=this.points.map(e=>this.context.coordinateConversion.pixelToData({x:e[0],y:e[1]}));t.every(e=>e!==null)&&this.context.addDrawing({id:`xabcd-${Date.now()}`,type:"xabcd_pattern",points:t,paneIndex:t[0].paneIndex||0,style:{color:"#3b82f6",lineWidth:2}})}}var cs=Object.defineProperty,ps=(p,t,e)=>t in p?cs(p,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):p[t]=e,ds=(p,t,e)=>(ps(p,typeof t!="symbol"?t+"":t,e),e);const xe=["A","B","C","D"],me=["#2196f3","#ff9800","#4caf50"];class be{constructor(){ds(this,"type","abcd_pattern")}render(t){const{drawing:e,pixelPoints:i,isSelected:s}=t,a=e.style?.color||"#3b82f6";if(i.length<2)return;const n=[];i.length>=3&&n.push({type:"polygon",name:"line",shape:{points:i.slice(0,3).map(([l,r])=>[l,r])},style:{fill:"rgba(33, 150, 243, 0.08)"}}),i.length>=4&&n.push({type:"polygon",name:"line",shape:{points:i.slice(1,4).map(([l,r])=>[l,r])},style:{fill:"rgba(244, 67, 54, 0.08)"}});for(let l=0;l<i.length-1;l++){const[r,o]=i[l],[u,d]=i[l+1];n.push({type:"line",name:"line",shape:{x1:r,y1:o,x2:u,y2:d},style:{stroke:me[l%me.length],lineWidth:e.style?.lineWidth||2}})}if(i.length>=3&&n.push({type:"line",shape:{x1:i[0][0],y1:i[0][1],x2:i[2][0],y2:i[2][1]},style:{stroke:"#555",lineWidth:1,lineDash:[4,4]},silent:!0}),i.length>=4&&n.push({type:"line",shape:{x1:i[1][0],y1:i[1][1],x2:i[3][0],y2:i[3][1]},style:{stroke:"#555",lineWidth:1,lineDash:[4,4]},silent:!0}),e.points.length>=3){const l=Math.abs(e.points[1].value-e.points[0].value),r=Math.abs(e.points[2].value-e.points[1].value);if(l!==0){const o=(r/l).toFixed(3),u=(i[1][0]+i[2][0])/2,d=(i[1][1]+i[2][1])/2;n.push({type:"text",style:{text:o,x:u+8,y:d,fill:"#ff9800",fontSize:10},silent:!0})}}if(e.points.length>=4){const l=Math.abs(e.points[2].value-e.points[1].value),r=Math.abs(e.points[3].value-e.points[2].value);if(l!==0){const o=(r/l).toFixed(3),u=(i[2][0]+i[3][0])/2,d=(i[2][1]+i[3][1])/2;n.push({type:"text",style:{text:o,x:u+8,y:d,fill:"#4caf50",fontSize:10},silent:!0})}}for(let l=0;l<i.length&&l<xe.length;l++){const[r,o]=i[l],u=(l===0||o<=i[l-1][1])&&(l===i.length-1||o<=i[l+1]?.[1]);n.push({type:"text",style:{text:xe[l],x:r,y:u?o-14:o+16,fill:"#e2e8f0",fontSize:12,fontWeight:"bold",align:"center",verticalAlign:"middle"},silent:!0})}for(let l=0;l<i.length;l++)n.push({type:"circle",name:`point-${l}`,shape:{cx:i[l][0],cy:i[l][1],r:4},style:{fill:"#fff",stroke:a,lineWidth:1,opacity:s?1:0},z:100});return{type:"group",children:n}}}var us=Object.defineProperty,gs=(p,t,e)=>t in p?us(p,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):p[t]=e,St=(p,t,e)=>(gs(p,typeof t!="symbol"?t+"":t,e),e);const ve=["A","B","C","D"],we=["#2196f3","#ff9800","#4caf50"],fs=4;class ys extends it{constructor(t={}){super({id:"abcd-pattern-tool",name:t.name||"ABCD Pattern",icon:t.icon||'<svg viewBox="0 0 24 24" width="24" height="24" fill="none" stroke="#e3e3e3" stroke-width="1.5"><polyline points="3,18 8,5 15,15 21,3"/><circle cx="3" cy="18" r="1.5" fill="#e3e3e3"/><circle cx="8" cy="5" r="1.5" fill="#e3e3e3"/><circle cx="15" cy="15" r="1.5" fill="#e3e3e3"/><circle cx="21" cy="3" r="1.5" fill="#e3e3e3"/></svg>'}),St(this,"points",[]),St(this,"state","idle"),St(this,"graphicGroup",null),St(this,"onClick",e=>{const i=this.getPoint(e);this.state==="idle"?(this.state="drawing",this.points=[i,[...i]],this.initGraphic(),this.updateGraphic()):this.state==="drawing"&&(this.points[this.points.length-1]=i,this.points.length>=fs?(this.state="finished",this.updateGraphic(),this.saveDrawing(),this.removeGraphic(),this.context.disableTools()):(this.points.push([...i]),this.updateGraphic()))}),St(this,"onMouseMove",e=>{this.state!=="drawing"||this.points.length<2||(this.points[this.points.length-1]=this.getPoint(e),this.updateGraphic())})}onInit(){this.context.registerDrawingRenderer(new be)}onActivate(){this.state="idle",this.points=[],this.context.getChart().getZr().setCursorStyle("crosshair");const t=this.context.getChart().getZr();t.on("click",this.onClick),t.on("mousemove",this.onMouseMove)}onDeactivate(){this.state="idle",this.points=[],this.removeGraphic();const t=this.context.getChart().getZr();t.off("click",this.onClick),t.off("mousemove",this.onMouseMove),this.context.getChart().getZr().setCursorStyle("default")}initGraphic(){this.graphicGroup=new G.graphic.Group,this.context.getChart().getZr().add(this.graphicGroup)}removeGraphic(){this.graphicGroup&&(this.context.getChart().getZr().remove(this.graphicGroup),this.graphicGroup=null)}updateGraphic(){if(!this.graphicGroup)return;this.graphicGroup.removeAll();const t=this.points;t.length>=3&&this.graphicGroup.add(new G.graphic.Polygon({shape:{points:t.slice(0,3)},style:{fill:"rgba(33,150,243,0.08)"},silent:!0})),t.length>=4&&this.graphicGroup.add(new G.graphic.Polygon({shape:{points:t.slice(1,4)},style:{fill:"rgba(244,67,54,0.08)"},silent:!0}));for(let e=0;e<t.length-1;e++)this.graphicGroup.add(new G.graphic.Line({shape:{x1:t[e][0],y1:t[e][1],x2:t[e+1][0],y2:t[e+1][1]},style:{stroke:we[e%we.length],lineWidth:2},silent:!0}));t.length>=3&&this.graphicGroup.add(new G.graphic.Line({shape:{x1:t[0][0],y1:t[0][1],x2:t[2][0],y2:t[2][1]},style:{stroke:"#555",lineWidth:1,lineDash:[4,4]},silent:!0})),t.length>=4&&this.graphicGroup.add(new G.graphic.Line({shape:{x1:t[1][0],y1:t[1][1],x2:t[3][0],y2:t[3][1]},style:{stroke:"#555",lineWidth:1,lineDash:[4,4]},silent:!0}));for(let e=0;e<t.length&&e<ve.length;e++){const[i,s]=t[e],a=(e===0||s<=t[e-1][1])&&(e===t.length-1||s<=t[e+1]?.[1]);this.graphicGroup.add(new G.graphic.Text({style:{text:ve[e],x:i,y:a?s-14:s+16,fill:"#e2e8f0",fontSize:12,fontWeight:"bold",align:"center",verticalAlign:"middle"},silent:!0})),this.graphicGroup.add(new G.graphic.Circle({shape:{cx:i,cy:s,r:4},style:{fill:"#fff",stroke:"#3b82f6",lineWidth:1.5},z:101,silent:!0}))}}saveDrawing(){const t=this.points.map(e=>this.context.coordinateConversion.pixelToData({x:e[0],y:e[1]}));t.every(e=>e!==null)&&this.context.addDrawing({id:`abcd-${Date.now()}`,type:"abcd_pattern",points:t,paneIndex:t[0].paneIndex||0,style:{color:"#3b82f6",lineWidth:2}})}}var xs=Object.defineProperty,ms=(p,t,e)=>t in p?xs(p,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):p[t]=e,bs=(p,t,e)=>(ms(p,typeof t!="symbol"?t+"":t,e),e);const Ce=["X","A","B","C","D"],Ie=["#00bcd4","#e91e63","#8bc34a","#ff5722"];class _e{constructor(){bs(this,"type","cypher_pattern")}render(t){const{drawing:e,pixelPoints:i,isSelected:s}=t,a=e.style?.color||"#3b82f6";if(i.length<2)return;const n=[];i.length>=3&&n.push({type:"polygon",name:"line",shape:{points:i.slice(0,3).map(([o,u])=>[o,u])},style:{fill:"rgba(0, 188, 212, 0.08)"}}),i.length>=5&&n.push({type:"polygon",name:"line",shape:{points:i.slice(2,5).map(([o,u])=>[o,u])},style:{fill:"rgba(233, 30, 99, 0.08)"}});for(let o=0;o<i.length-1;o++){const[u,d]=i[o],[c,g]=i[o+1];n.push({type:"line",name:"line",shape:{x1:u,y1:d,x2:c,y2:g},style:{stroke:Ie[o%Ie.length],lineWidth:e.style?.lineWidth||2}})}const l=[[0,2],[0,3],[1,4]];for(const[o,u]of l)o<i.length&&u<i.length&&n.push({type:"line",shape:{x1:i[o][0],y1:i[o][1],x2:i[u][0],y2:i[u][1]},style:{stroke:"#555",lineWidth:1,lineDash:[4,4]},silent:!0});const r=e.points;if(r.length>=3){const o=Math.abs(r[1].value-r[0].value),u=Math.abs(r[2].value-r[1].value);if(o!==0){const d=(u/o).toFixed(3);n.push({type:"text",style:{text:d,x:(i[1][0]+i[2][0])/2+8,y:(i[1][1]+i[2][1])/2,fill:"#e91e63",fontSize:10},silent:!0})}}if(r.length>=4){const o=Math.abs(r[1].value-r[0].value),u=Math.abs(r[3].value-r[0].value);if(o!==0){const d=(u/o).toFixed(3);n.push({type:"text",style:{text:`XC/XA: ${d}`,x:(i[0][0]+i[3][0])/2+8,y:(i[0][1]+i[3][1])/2,fill:"#8bc34a",fontSize:10},silent:!0})}}if(r.length>=5){const o=Math.abs(r[3].value-r[0].value),u=Math.abs(r[4].value-r[3].value);if(o!==0){const d=(u/o).toFixed(3);n.push({type:"text",style:{text:d,x:(i[3][0]+i[4][0])/2+8,y:(i[3][1]+i[4][1])/2,fill:"#ff5722",fontSize:10},silent:!0})}}for(let o=0;o<i.length&&o<Ce.length;o++){const[u,d]=i[o],c=(o===0||d<=i[o-1][1])&&(o===i.length-1||d<=i[o+1]?.[1]);n.push({type:"text",style:{text:Ce[o],x:u,y:c?d-14:d+16,fill:"#e2e8f0",fontSize:12,fontWeight:"bold",align:"center",verticalAlign:"middle"},silent:!0})}for(let o=0;o<i.length;o++)n.push({type:"circle",name:`point-${o}`,shape:{cx:i[o][0],cy:i[o][1],r:4},style:{fill:"#fff",stroke:a,lineWidth:1,opacity:s?1:0},z:100});return{type:"group",children:n}}}var vs=Object.defineProperty,ws=(p,t,e)=>t in p?vs(p,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):p[t]=e,Gt=(p,t,e)=>(ws(p,typeof t!="symbol"?t+"":t,e),e);const ke=["X","A","B","C","D"],Pe=["#00bcd4","#e91e63","#8bc34a","#ff5722"],Cs=5;class Is extends it{constructor(t={}){super({id:"cypher-pattern-tool",name:t.name||"Cypher Pattern",icon:t.icon||'<svg viewBox="0 0 24 24" width="24" height="24" fill="none" stroke="#e3e3e3" stroke-width="1.5"><polyline points="2,16 7,4 11,12 17,2 22,14"/><circle cx="2" cy="16" r="1.5" fill="#e3e3e3"/><circle cx="7" cy="4" r="1.5" fill="#e3e3e3"/><circle cx="11" cy="12" r="1.5" fill="#e3e3e3"/><circle cx="17" cy="2" r="1.5" fill="#e3e3e3"/><circle cx="22" cy="14" r="1.5" fill="#e3e3e3"/></svg>'}),Gt(this,"points",[]),Gt(this,"state","idle"),Gt(this,"graphicGroup",null),Gt(this,"onClick",e=>{const i=this.getPoint(e);this.state==="idle"?(this.state="drawing",this.points=[i,[...i]],this.initGraphic(),this.updateGraphic()):this.state==="drawing"&&(this.points[this.points.length-1]=i,this.points.length>=Cs?(this.state="finished",this.updateGraphic(),this.saveDrawing(),this.removeGraphic(),this.context.disableTools()):(this.points.push([...i]),this.updateGraphic()))}),Gt(this,"onMouseMove",e=>{this.state!=="drawing"||this.points.length<2||(this.points[this.points.length-1]=this.getPoint(e),this.updateGraphic())})}onInit(){this.context.registerDrawingRenderer(new _e)}onActivate(){this.state="idle",this.points=[],this.context.getChart().getZr().setCursorStyle("crosshair");const t=this.context.getChart().getZr();t.on("click",this.onClick),t.on("mousemove",this.onMouseMove)}onDeactivate(){this.state="idle",this.points=[],this.removeGraphic();const t=this.context.getChart().getZr();t.off("click",this.onClick),t.off("mousemove",this.onMouseMove),t.setCursorStyle("default")}initGraphic(){this.graphicGroup=new G.graphic.Group,this.context.getChart().getZr().add(this.graphicGroup)}removeGraphic(){this.graphicGroup&&(this.context.getChart().getZr().remove(this.graphicGroup),this.graphicGroup=null)}updateGraphic(){if(!this.graphicGroup)return;this.graphicGroup.removeAll();const t=this.points;t.length>=3&&this.graphicGroup.add(new G.graphic.Polygon({shape:{points:t.slice(0,3)},style:{fill:"rgba(0,188,212,0.08)"},silent:!0})),t.length>=5&&this.graphicGroup.add(new G.graphic.Polygon({shape:{points:t.slice(2,5)},style:{fill:"rgba(233,30,99,0.08)"},silent:!0}));for(let e=0;e<t.length-1;e++)this.graphicGroup.add(new G.graphic.Line({shape:{x1:t[e][0],y1:t[e][1],x2:t[e+1][0],y2:t[e+1][1]},style:{stroke:Pe[e%Pe.length],lineWidth:2},silent:!0}));for(let e=0;e<t.length&&e<ke.length;e++){const[i,s]=t[e],a=(e===0||s<=t[e-1][1])&&(e===t.length-1||s<=t[e+1]?.[1]);this.graphicGroup.add(new G.graphic.Text({style:{text:ke[e],x:i,y:a?s-14:s+16,fill:"#e2e8f0",fontSize:12,fontWeight:"bold",align:"center",verticalAlign:"middle"},silent:!0})),this.graphicGroup.add(new G.graphic.Circle({shape:{cx:i,cy:s,r:4},style:{fill:"#fff",stroke:"#3b82f6",lineWidth:1.5},z:101,silent:!0}))}}saveDrawing(){const t=this.points.map(e=>this.context.coordinateConversion.pixelToData({x:e[0],y:e[1]}));t.every(e=>e!==null)&&this.context.addDrawing({id:`cypher-${Date.now()}`,type:"cypher_pattern",points:t,paneIndex:t[0].paneIndex||0,style:{color:"#3b82f6",lineWidth:2}})}}var _s=Object.defineProperty,ks=(p,t,e)=>t in p?_s(p,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):p[t]=e,Ps=(p,t,e)=>(ks(p,typeof t!="symbol"?t+"":t,e),e);const qt=["","LS","","H","","RS",""];class Ae{constructor(){Ps(this,"type","head_and_shoulders")}render(t){const{drawing:e,pixelPoints:i,isSelected:s}=t,a=e.style?.color||"#3b82f6";if(i.length<2)return;const n=[];i.length>=3&&n.push({type:"polygon",name:"line",shape:{points:i.slice(0,3).map(([l,r])=>[l,r])},style:{fill:"rgba(33, 150, 243, 0.06)"}}),i.length>=5&&n.push({type:"polygon",name:"line",shape:{points:i.slice(2,5).map(([l,r])=>[l,r])},style:{fill:"rgba(244, 67, 54, 0.08)"}}),i.length>=7&&n.push({type:"polygon",name:"line",shape:{points:i.slice(4,7).map(([l,r])=>[l,r])},style:{fill:"rgba(33, 150, 243, 0.06)"}});for(let l=0;l<i.length-1;l++){const[r,o]=i[l],[u,d]=i[l+1];n.push({type:"line",name:"line",shape:{x1:r,y1:o,x2:u,y2:d},style:{stroke:"#2196f3",lineWidth:e.style?.lineWidth||2}})}if(i.length>=5){const[l,r]=i[2],[o,u]=i[4],d=o-l,c=u-r,g=.3,h=.3,f=l-d*g,y=r-c*g,x=o+d*h,b=u+c*h;n.push({type:"line",shape:{x1:f,y1:y,x2:x,y2:b},style:{stroke:"#ff9800",lineWidth:2,lineDash:[6,4]},silent:!0}),n.push({type:"text",style:{text:"Neckline",x:(l+o)/2,y:(r+u)/2+14,fill:"#ff9800",fontSize:10,align:"center"},silent:!0})}for(let l=0;l<i.length&&l<qt.length;l++){if(!qt[l])continue;const[r,o]=i[l],u=(l===0||o<=i[l-1][1])&&(l===i.length-1||o<=i[l+1]?.[1]);n.push({type:"text",style:{text:qt[l],x:r,y:u?o-14:o+16,fill:"#e2e8f0",fontSize:12,fontWeight:"bold",align:"center",verticalAlign:"middle"},silent:!0})}for(let l=0;l<i.length;l++)n.push({type:"circle",name:`point-${l}`,shape:{cx:i[l][0],cy:i[l][1],r:4},style:{fill:"#fff",stroke:a,lineWidth:1,opacity:s?1:0},z:100});return{type:"group",children:n}}}var As=Object.defineProperty,Ds=(p,t,e)=>t in p?As(p,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):p[t]=e,$t=(p,t,e)=>(Ds(p,typeof t!="symbol"?t+"":t,e),e);const Ut=["","LS","","H","","RS",""],Ms=7;class Ss extends it{constructor(t={}){super({id:"head-and-shoulders-tool",name:t.name||"Head & Shoulders",icon:t.icon||'<svg viewBox="0 0 24 24" width="24" height="24" fill="none" stroke="#e3e3e3" stroke-width="1.5"><polyline points="1,18 4,10 7,14 12,3 17,14 20,10 23,18"/></svg>'}),$t(this,"points",[]),$t(this,"state","idle"),$t(this,"graphicGroup",null),$t(this,"onClick",e=>{const i=this.getPoint(e);this.state==="idle"?(this.state="drawing",this.points=[i,[...i]],this.initGraphic(),this.updateGraphic()):this.state==="drawing"&&(this.points[this.points.length-1]=i,this.points.length>=Ms?(this.state="finished",this.updateGraphic(),this.saveDrawing(),this.removeGraphic(),this.context.disableTools()):(this.points.push([...i]),this.updateGraphic()))}),$t(this,"onMouseMove",e=>{this.state!=="drawing"||this.points.length<2||(this.points[this.points.length-1]=this.getPoint(e),this.updateGraphic())})}onInit(){this.context.registerDrawingRenderer(new Ae)}onActivate(){this.state="idle",this.points=[],this.context.getChart().getZr().setCursorStyle("crosshair");const t=this.context.getChart().getZr();t.on("click",this.onClick),t.on("mousemove",this.onMouseMove)}onDeactivate(){this.state="idle",this.points=[],this.removeGraphic();const t=this.context.getChart().getZr();t.off("click",this.onClick),t.off("mousemove",this.onMouseMove),t.setCursorStyle("default")}initGraphic(){this.graphicGroup=new G.graphic.Group,this.context.getChart().getZr().add(this.graphicGroup)}removeGraphic(){this.graphicGroup&&(this.context.getChart().getZr().remove(this.graphicGroup),this.graphicGroup=null)}updateGraphic(){if(!this.graphicGroup)return;this.graphicGroup.removeAll();const t=this.points;t.length>=3&&this.graphicGroup.add(new G.graphic.Polygon({shape:{points:t.slice(0,3)},style:{fill:"rgba(33,150,243,0.06)"},silent:!0})),t.length>=5&&this.graphicGroup.add(new G.graphic.Polygon({shape:{points:t.slice(2,5)},style:{fill:"rgba(244,67,54,0.08)"},silent:!0})),t.length>=7&&this.graphicGroup.add(new G.graphic.Polygon({shape:{points:t.slice(4,7)},style:{fill:"rgba(33,150,243,0.06)"},silent:!0}));for(let e=0;e<t.length-1;e++)this.graphicGroup.add(new G.graphic.Line({shape:{x1:t[e][0],y1:t[e][1],x2:t[e+1][0],y2:t[e+1][1]},style:{stroke:"#2196f3",lineWidth:2},silent:!0}));if(t.length>=5){const[e,i]=t[2],[s,a]=t[4],n=s-e,l=a-i;this.graphicGroup.add(new G.graphic.Line({shape:{x1:e-n*.3,y1:i-l*.3,x2:s+n*.3,y2:a+l*.3},style:{stroke:"#ff9800",lineWidth:2,lineDash:[6,4]},silent:!0}))}for(let e=0;e<t.length&&e<Ut.length;e++){const[i,s]=t[e],a=(e===0||s<=t[e-1][1])&&(e===t.length-1||s<=t[e+1]?.[1]);Ut[e]&&this.graphicGroup.add(new G.graphic.Text({style:{text:Ut[e],x:i,y:a?s-14:s+16,fill:"#e2e8f0",fontSize:12,fontWeight:"bold",align:"center",verticalAlign:"middle"},silent:!0})),this.graphicGroup.add(new G.graphic.Circle({shape:{cx:i,cy:s,r:4},style:{fill:"#fff",stroke:"#3b82f6",lineWidth:1.5},z:101,silent:!0}))}}saveDrawing(){const t=this.points.map(e=>this.context.coordinateConversion.pixelToData({x:e[0],y:e[1]}));t.every(e=>e!==null)&&this.context.addDrawing({id:`hs-${Date.now()}`,type:"head_and_shoulders",points:t,paneIndex:t[0].paneIndex||0,style:{color:"#3b82f6",lineWidth:2}})}}var Gs=Object.defineProperty,$s=(p,t,e)=>t in p?Gs(p,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):p[t]=e,zs=(p,t,e)=>($s(p,typeof t!="symbol"?t+"":t,e),e);const De=["1","2","3","4","5"];class Me{constructor(){zs(this,"type","triangle_pattern")}render(t){const{drawing:e,pixelPoints:i,isSelected:s}=t,a=e.style?.color||"#3b82f6";if(i.length<2)return;const n=[];i.length>=3&&n.push({type:"polygon",name:"line",shape:{points:i.map(([o,u])=>[o,u])},style:{fill:"rgba(156, 39, 176, 0.06)"}});const l=i.filter((o,u)=>u%2===0);if(l.length>=2){for(let o=0;o<l.length-1;o++)n.push({type:"line",name:"line",shape:{x1:l[o][0],y1:l[o][1],x2:l[o+1][0],y2:l[o+1][1]},style:{stroke:"#f44336",lineWidth:2}});if(l.length>=2){const o=l[l.length-1],u=l[l.length-2],d=o[0]-u[0],c=o[1]-u[1];if(d!==0){const g=o[0]+d*.5,h=o[1]+c*.5;n.push({type:"line",shape:{x1:o[0],y1:o[1],x2:g,y2:h},style:{stroke:"#f44336",lineWidth:1,lineDash:[4,4]},silent:!0})}}}const r=i.filter((o,u)=>u%2===1);if(r.length>=2){for(let o=0;o<r.length-1;o++)n.push({type:"line",name:"line",shape:{x1:r[o][0],y1:r[o][1],x2:r[o+1][0],y2:r[o+1][1]},style:{stroke:"#4caf50",lineWidth:2}});if(r.length>=2){const o=r[r.length-1],u=r[r.length-2],d=o[0]-u[0],c=o[1]-u[1];if(d!==0){const g=o[0]+d*.5,h=o[1]+c*.5;n.push({type:"line",shape:{x1:o[0],y1:o[1],x2:g,y2:h},style:{stroke:"#4caf50",lineWidth:1,lineDash:[4,4]},silent:!0})}}}for(let o=0;o<i.length-1;o++)n.push({type:"line",shape:{x1:i[o][0],y1:i[o][1],x2:i[o+1][0],y2:i[o+1][1]},style:{stroke:"#9c27b0",lineWidth:1,lineDash:[2,2]},silent:!0});for(let o=0;o<i.length&&o<De.length;o++){const[u,d]=i[o],c=o%2===0;n.push({type:"text",style:{text:De[o],x:u,y:c?d-14:d+16,fill:"#e2e8f0",fontSize:12,fontWeight:"bold",align:"center",verticalAlign:"middle"},silent:!0})}for(let o=0;o<i.length;o++)n.push({type:"circle",name:`point-${o}`,shape:{cx:i[o][0],cy:i[o][1],r:4},style:{fill:"#fff",stroke:a,lineWidth:1,opacity:s?1:0},z:100});return{type:"group",children:n}}}var Es=Object.defineProperty,Ls=(p,t,e)=>t in p?Es(p,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):p[t]=e,zt=(p,t,e)=>(Ls(p,typeof t!="symbol"?t+"":t,e),e);const Se=["1","2","3","4","5"],Ws=5;class Ts extends it{constructor(t={}){super({id:"triangle-pattern-tool",name:t.name||"Triangle Pattern",icon:t.icon||'<svg viewBox="0 0 24 24" width="24" height="24" fill="none" stroke="#e3e3e3" stroke-width="1.5"><path d="M2,4 L22,4 L12,20 Z"/></svg>'}),zt(this,"points",[]),zt(this,"state","idle"),zt(this,"graphicGroup",null),zt(this,"onClick",e=>{const i=this.getPoint(e);this.state==="idle"?(this.state="drawing",this.points=[i,[...i]],this.initGraphic(),this.updateGraphic()):this.state==="drawing"&&(this.points[this.points.length-1]=i,this.points.length>=Ws?(this.state="finished",this.updateGraphic(),this.saveDrawing(),this.removeGraphic(),this.context.disableTools()):(this.points.push([...i]),this.updateGraphic()))}),zt(this,"onMouseMove",e=>{this.state!=="drawing"||this.points.length<2||(this.points[this.points.length-1]=this.getPoint(e),this.updateGraphic())})}onInit(){this.context.registerDrawingRenderer(new Me)}onActivate(){this.state="idle",this.points=[],this.context.getChart().getZr().setCursorStyle("crosshair");const t=this.context.getChart().getZr();t.on("click",this.onClick),t.on("mousemove",this.onMouseMove)}onDeactivate(){this.state="idle",this.points=[],this.removeGraphic();const t=this.context.getChart().getZr();t.off("click",this.onClick),t.off("mousemove",this.onMouseMove),t.setCursorStyle("default")}initGraphic(){this.graphicGroup=new G.graphic.Group,this.context.getChart().getZr().add(this.graphicGroup)}removeGraphic(){this.graphicGroup&&(this.context.getChart().getZr().remove(this.graphicGroup),this.graphicGroup=null)}updateGraphic(){if(!this.graphicGroup)return;this.graphicGroup.removeAll();const t=this.points;t.length>=3&&this.graphicGroup.add(new G.graphic.Polygon({shape:{points:t},style:{fill:"rgba(156,39,176,0.06)"},silent:!0}));for(let s=0;s<t.length-1;s++)this.graphicGroup.add(new G.graphic.Line({shape:{x1:t[s][0],y1:t[s][1],x2:t[s+1][0],y2:t[s+1][1]},style:{stroke:"#9c27b0",lineWidth:2},silent:!0}));const e=t.filter((s,a)=>a%2===0);if(e.length>=2)for(let s=0;s<e.length-1;s++)this.graphicGroup.add(new G.graphic.Line({shape:{x1:e[s][0],y1:e[s][1],x2:e[s+1][0],y2:e[s+1][1]},style:{stroke:"#f44336",lineWidth:1,lineDash:[4,4]},silent:!0}));const i=t.filter((s,a)=>a%2===1);if(i.length>=2)for(let s=0;s<i.length-1;s++)this.graphicGroup.add(new G.graphic.Line({shape:{x1:i[s][0],y1:i[s][1],x2:i[s+1][0],y2:i[s+1][1]},style:{stroke:"#4caf50",lineWidth:1,lineDash:[4,4]},silent:!0}));for(let s=0;s<t.length&&s<Se.length;s++){const[a,n]=t[s],l=s%2===0;this.graphicGroup.add(new G.graphic.Text({style:{text:Se[s],x:a,y:l?n-14:n+16,fill:"#e2e8f0",fontSize:12,fontWeight:"bold",align:"center",verticalAlign:"middle"},silent:!0})),this.graphicGroup.add(new G.graphic.Circle({shape:{cx:a,cy:n,r:4},style:{fill:"#fff",stroke:"#3b82f6",lineWidth:1.5},z:101,silent:!0}))}}saveDrawing(){const t=this.points.map(e=>this.context.coordinateConversion.pixelToData({x:e[0],y:e[1]}));t.every(e=>e!==null)&&this.context.addDrawing({id:`triangle-${Date.now()}`,type:"triangle_pattern",points:t,paneIndex:t[0].paneIndex||0,style:{color:"#3b82f6",lineWidth:2}})}}var Ns=Object.defineProperty,Zs=(p,t,e)=>t in p?Ns(p,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):p[t]=e,Fs=(p,t,e)=>(Zs(p,typeof t!="symbol"?t+"":t,e),e);const Kt=["0","D1","C1","D2","C2","D3",""],Ge=["#2196f3","#ff9800","#4caf50","#f44336","#00bcd4","#e91e63"];class $e{constructor(){Fs(this,"type","three_drives_pattern")}render(t){const{drawing:e,pixelPoints:i,isSelected:s}=t,a=e.style?.color||"#3b82f6";if(i.length<2)return;const n=[];i.length>=3&&n.push({type:"polygon",name:"line",shape:{points:i.slice(0,3).map(([o,u])=>[o,u])},style:{fill:"rgba(33, 150, 243, 0.06)"}}),i.length>=5&&n.push({type:"polygon",name:"line",shape:{points:i.slice(2,5).map(([o,u])=>[o,u])},style:{fill:"rgba(76, 175, 80, 0.06)"}}),i.length>=7&&n.push({type:"polygon",name:"line",shape:{points:i.slice(4,7).map(([o,u])=>[o,u])},style:{fill:"rgba(0, 188, 212, 0.06)"}});for(let o=0;o<i.length-1;o++){const[u,d]=i[o],[c,g]=i[o+1];n.push({type:"line",name:"line",shape:{x1:u,y1:d,x2:c,y2:g},style:{stroke:Ge[o%Ge.length],lineWidth:e.style?.lineWidth||2}})}const l=[[1,3],[3,5],[2,4]];for(const[o,u]of l)o<i.length&&u<i.length&&n.push({type:"line",shape:{x1:i[o][0],y1:i[o][1],x2:i[u][0],y2:i[u][1]},style:{stroke:"#555",lineWidth:1,lineDash:[4,4]},silent:!0});const r=e.points;if(r.length>=4){const o=Math.abs(r[1].value-r[0].value),u=Math.abs(r[3].value-r[2].value);if(o!==0){const d=(u/o).toFixed(3),c=(i[2][0]+i[3][0])/2,g=(i[2][1]+i[3][1])/2;n.push({type:"text",style:{text:`D2/D1: ${d}`,x:c+10,y:g,fill:"#4caf50",fontSize:9},silent:!0})}}if(r.length>=6){const o=Math.abs(r[3].value-r[2].value),u=Math.abs(r[5].value-r[4].value);if(o!==0){const d=(u/o).toFixed(3),c=(i[4][0]+i[5][0])/2,g=(i[4][1]+i[5][1])/2;n.push({type:"text",style:{text:`D3/D2: ${d}`,x:c+10,y:g,fill:"#00bcd4",fontSize:9},silent:!0})}}if(r.length>=3){const o=Math.abs(r[1].value-r[0].value),u=Math.abs(r[2].value-r[1].value);if(o!==0){const d=(u/o).toFixed(3),c=(i[1][0]+i[2][0])/2,g=(i[1][1]+i[2][1])/2;n.push({type:"text",style:{text:d,x:c+8,y:g,fill:"#ff9800",fontSize:10},silent:!0})}}for(let o=0;o<i.length&&o<Kt.length;o++){if(!Kt[o])continue;const[u,d]=i[o],c=(o===0||d<=i[o-1][1])&&(o===i.length-1||d<=i[o+1]?.[1]);n.push({type:"text",style:{text:Kt[o],x:u,y:c?d-14:d+16,fill:"#e2e8f0",fontSize:11,fontWeight:"bold",align:"center",verticalAlign:"middle"},silent:!0})}for(let o=0;o<i.length;o++)n.push({type:"circle",name:`point-${o}`,shape:{cx:i[o][0],cy:i[o][1],r:4},style:{fill:"#fff",stroke:a,lineWidth:1,opacity:s?1:0},z:100});return{type:"group",children:n}}}var Os=Object.defineProperty,Hs=(p,t,e)=>t in p?Os(p,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):p[t]=e,Et=(p,t,e)=>(Hs(p,typeof t!="symbol"?t+"":t,e),e);const Jt=["0","D1","C1","D2","C2","D3",""],ze=["#2196f3","#ff9800","#4caf50","#f44336","#00bcd4","#e91e63"],Rs=7;class Bs extends it{constructor(t={}){super({id:"three-drives-pattern-tool",name:t.name||"Three Drives",icon:t.icon||'<svg viewBox="0 0 24 24" width="24" height="24" fill="none" stroke="#e3e3e3" stroke-width="1.5"><polyline points="1,20 4,8 7,14 11,5 15,12 19,2 23,10"/></svg>'}),Et(this,"points",[]),Et(this,"state","idle"),Et(this,"graphicGroup",null),Et(this,"onClick",e=>{const i=this.getPoint(e);this.state==="idle"?(this.state="drawing",this.points=[i,[...i]],this.initGraphic(),this.updateGraphic()):this.state==="drawing"&&(this.points[this.points.length-1]=i,this.points.length>=Rs?(this.state="finished",this.updateGraphic(),this.saveDrawing(),this.removeGraphic(),this.context.disableTools()):(this.points.push([...i]),this.updateGraphic()))}),Et(this,"onMouseMove",e=>{this.state!=="drawing"||this.points.length<2||(this.points[this.points.length-1]=this.getPoint(e),this.updateGraphic())})}onInit(){this.context.registerDrawingRenderer(new $e)}onActivate(){this.state="idle",this.points=[],this.context.getChart().getZr().setCursorStyle("crosshair");const t=this.context.getChart().getZr();t.on("click",this.onClick),t.on("mousemove",this.onMouseMove)}onDeactivate(){this.state="idle",this.points=[],this.removeGraphic();const t=this.context.getChart().getZr();t.off("click",this.onClick),t.off("mousemove",this.onMouseMove),t.setCursorStyle("default")}initGraphic(){this.graphicGroup=new G.graphic.Group,this.context.getChart().getZr().add(this.graphicGroup)}removeGraphic(){this.graphicGroup&&(this.context.getChart().getZr().remove(this.graphicGroup),this.graphicGroup=null)}updateGraphic(){if(!this.graphicGroup)return;this.graphicGroup.removeAll();const t=this.points;t.length>=3&&this.graphicGroup.add(new G.graphic.Polygon({shape:{points:t.slice(0,3)},style:{fill:"rgba(33,150,243,0.06)"},silent:!0})),t.length>=5&&this.graphicGroup.add(new G.graphic.Polygon({shape:{points:t.slice(2,5)},style:{fill:"rgba(76,175,80,0.06)"},silent:!0})),t.length>=7&&this.graphicGroup.add(new G.graphic.Polygon({shape:{points:t.slice(4,7)},style:{fill:"rgba(0,188,212,0.06)"},silent:!0}));for(let i=0;i<t.length-1;i++)this.graphicGroup.add(new G.graphic.Line({shape:{x1:t[i][0],y1:t[i][1],x2:t[i+1][0],y2:t[i+1][1]},style:{stroke:ze[i%ze.length],lineWidth:2},silent:!0}));const e=[[1,3],[3,5],[2,4]];for(const[i,s]of e)i<t.length&&s<t.length&&this.graphicGroup.add(new G.graphic.Line({shape:{x1:t[i][0],y1:t[i][1],x2:t[s][0],y2:t[s][1]},style:{stroke:"#555",lineWidth:1,lineDash:[4,4]},silent:!0}));for(let i=0;i<t.length&&i<Jt.length;i++){const[s,a]=t[i],n=(i===0||a<=t[i-1][1])&&(i===t.length-1||a<=t[i+1]?.[1]);Jt[i]&&this.graphicGroup.add(new G.graphic.Text({style:{text:Jt[i],x:s,y:n?a-14:a+16,fill:"#e2e8f0",fontSize:11,fontWeight:"bold",align:"center",verticalAlign:"middle"},silent:!0})),this.graphicGroup.add(new G.graphic.Circle({shape:{cx:s,cy:a,r:4},style:{fill:"#fff",stroke:"#3b82f6",lineWidth:1.5},z:101,silent:!0}))}}saveDrawing(){const t=this.points.map(e=>this.context.coordinateConversion.pixelToData({x:e[0],y:e[1]}));t.every(e=>e!==null)&&this.context.addDrawing({id:`3drives-${Date.now()}`,type:"three_drives_pattern",points:t,paneIndex:t[0].paneIndex||0,style:{color:"#3b82f6",lineWidth:2}})}}var js=Object.defineProperty,Ys=(p,t,e)=>t in p?js(p,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):p[t]=e,mt=(p,t,e)=>(Ys(p,typeof t!="symbol"?t+"":t,e),e);class Xs extends it{constructor(t){const e='<svg width="8" height="8" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="position: absolute; right: -4px; top: 50%; transform: translateY(-50%); opacity: 0.6;"><polyline points="9 18 15 12 9 6"></polyline></svg>';let i="";t.icon?i=`<div style="position: relative; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;">
36
+ <div style="font-size: 10px; color: #fff;padding-left:10px;">${y}</div>
37
+ </div>`}),a+="</div>"})}return a}}var ki=Object.defineProperty,Ii=(h,t,e)=>t in h?ki(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,Mt=(h,t,e)=>(Ii(h,typeof t!="symbol"?t+"":t,e),e);class Di{constructor(t,e){Mt(this,"plugins",new Map),Mt(this,"activePluginId",null),Mt(this,"context"),Mt(this,"toolbarContainer"),Mt(this,"tooltipElement",null),Mt(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(),r=i.top+(i.height-s.height)/2,n=i.right+10;this.tooltipElement.style.top=`${r}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 Mi=Object.defineProperty,Si=(h,t,e)=>t in h?Mi(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,st=(h,t,e)=>(Si(h,typeof t!="symbol"?t+"":t,e),e);class Ai{constructor(t){st(this,"context"),st(this,"isEditing",!1),st(this,"currentDrawing",null),st(this,"editingPointIndex",null),st(this,"zr"),st(this,"editGroup",null),st(this,"editLines",[]),st(this,"editPoints",[]),st(this,"isMovingShape",!1),st(this,"dragStart",null),st(this,"initialPixelPoints",[]),st(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 r=this.context.coordinateConversion.dataToPixel(s);return r?{x:r.x,y:r.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))}),st(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 r=this.context.coordinateConversion.dataToPixel(s);return r?{x:r.x,y:r.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))}),st(this,"onMouseMove",e=>{if(!this.isEditing||!this.currentDrawing)return;const i=e.offsetX,s=e.offsetY;if(this.isMovingShape&&this.dragStart){const r=i-this.dragStart.x,n=s-this.dragStart.y,l=this.initialPixelPoints.map(a=>({x:a.x+r,y:a.y+n}));for(let a=0;a<this.editLines.length;a++)this.editLines[a].setShape({x1:l[a].x,y1:l[a].y,x2:l[a+1].x,y2:l[a+1].y});for(let a=0;a<this.editPoints.length;a++)this.editPoints[a].setShape({cx:l[a].x,cy:l[a].y})}else if(this.editingPointIndex!==null){const r=this.initialPixelPoints.map(n=>({x:n.x,y:n.y}));r[this.editingPointIndex]={x:i,y:s};for(let n=0;n<this.editLines.length;n++)this.editLines[n].setShape({x1:r[n].x,y1:r[n].y,x2:r[n+1].x,y2:r[n+1].y});this.editPoints[this.editingPointIndex].setShape({cx:i,cy:s})}}),st(this,"onMouseUp",e=>{this.isEditing&&this.finishEditing(e.offsetX,e.offsetY)}),st(this,"onWindowMouseUp",e=>{if(!this.isEditing)return;const i=this.zr.dom;if(i){const s=i.getBoundingClientRect(),r=e.clientX-s.left,n=e.clientY-s.top;this.finishEditing(r,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 D.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 D.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 D.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 r=this.context.getChart(),n=r.convertFromPixel({gridIndex:i},[t,e]);if(n){const l=r.getOption()?.xAxis?.[i]?.data,a=this.context.getMarketData(),o=l?Math.round((l.length-a.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,r=e-this.dragStart.y,n=this.initialPixelPoints.map(l=>this.pixelToDataForPane(l.x+s,l.y+r,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 _i=Object.defineProperty,$i=(h,t,e)=>t in h?_i(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,Gi=(h,t,e)=>($i(h,typeof t!="symbol"?t+"":t,e),e);class de{constructor(){Gi(this,"renderers",new Map)}register(t){this.renderers.set(t.type,t)}get(t){return this.renderers.get(t)}}var zi=Object.defineProperty,Ei=(h,t,e)=>t in h?zi(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,Li=(h,t,e)=>(Ei(h,typeof t!="symbol"?t+"":t,e),e);class Wi{constructor(){Li(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(r){console.error(`Error in EventBus handler for ${t}:`,r)}})}clear(){this.handlers.clear()}}class rt{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){rt.clearAll(t);const s=new Map;for(const r of e)r&&!r._deleted&&s.set(r.position,r);s.forEach(r=>{const n=r._paneIndex??0,l=i?i(n):void 0,a=rt.buildTable(r,l);rt.positionTable(a,r.position,l),t.appendChild(a)})}static clearAll(t){for(;t.firstChild;)t.removeChild(t.firstChild)}static buildTable(t,e){const i=document.createElement("table"),s=t.border_width??0,r=t.frame_width??0;if(s>0&&t.border_color||r>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}=rt.safeParseColor(t.bgcolor);i.style.backgroundColor=c,g<1&&(i.style.opacity=String(g))}if(r>0&&t.frame_color){const{color:c}=rt.safeParseColor(t.frame_color);i.style.border=`${r}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 p=c.startRow;p<=c.endRow;p++)for(let y=c.startCol;y<=c.endCol;y++)p===c.startRow&&y===c.startCol||l.add(`${y},${p}`)}const a=s>0&&!!t.border_color,o=a?rt.safeParseColor(t.border_color).color:"",d=t.rows||0,u=t.columns||0;for(let c=0;c<d;c++){const g=document.createElement("tr");for(let p=0;p<u;p++){const y=`${p},${c}`;if(l.has(y))continue;const f=document.createElement("td"),x=n.get(y);x&&(x.colspan>1&&(f.colSpan=x.colspan),x.rowspan>1&&(f.rowSpan=x.rowspan)),a?f.style.border=`${s}px solid ${o}`:f.style.border="none";const m=t.cells?.[c]?.[p];if(m&&!m._merged){if(f.textContent=m.text||"",m.bgcolor&&typeof m.bgcolor=="string"&&m.bgcolor.length>0){const{color:v,opacity:I}=rt.safeParseColor(m.bgcolor);f.style.backgroundColor=v,I<1&&(f.style.backgroundColor=m.bgcolor)}if(m.text_color){const{color:v}=rt.safeParseColor(m.text_color);f.style.color=v}if(f.style.fontSize=rt.getSizePixels(m.text_size)+"px",f.style.textAlign=rt.mapHAlign(m.text_halign),f.style.verticalAlign=rt.mapVAlign(m.text_valign),m.text_font_family==="monospace"&&(f.style.fontFamily="monospace"),m.width>0)if(e){const v=Math.max(1,m.width*e.width/100);f.style.width=v+"px"}else f.style.width=m.width+"%";if(m.height>0)if(e){const v=Math.max(1,m.height*e.height/100);f.style.height=v+"px"}else f.style.height=m.height+"%";m.tooltip&&(f.title=m.tooltip)}const S=m?.height??0;S>0&&e&&S*e.height/100<4?f.style.padding="0":f.style.padding="4px 6px",f.style.whiteSpace="nowrap",g.appendChild(f)}i.appendChild(g)}return i}static positionTable(t,e,i){t.style.position="absolute";const s=8,r=i?i.y+"px":"0",n=i?i.x+"px":"0",l=i?i.y+i.height-s+"px":"0",a=i?i.x+i.width-s+"px":"0",o=i?i.x+i.width/2+"px":"50%",d=i?i.y+i.height/2+"px":"50%";switch(e){case"top_left":t.style.top=r,t.style.left=n;break;case"top_center":t.style.top=r,t.style.left=o,t.style.transform="translateX(-50%)";break;case"top_right":t.style.top=r,t.style.left=a,t.style.transform="translateX(-100%)";break;case"middle_left":t.style.top=d,t.style.left=n,t.style.transform="translateY(-50%)";break;case"middle_center":t.style.top=d,t.style.left=o,t.style.transform="translate(-50%, -50%)";break;case"middle_right":t.style.top=d,t.style.left=a,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=a,t.style.transform="translate(-100%, -100%)";break;default:t.style.top=r,t.style.left=a,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 et{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),r=parseInt(t.slice(5,7),16),n=parseInt(t.slice(7,9),16)/255;return{color:`rgb(${i},${s},${r})`,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 r of t)r&&!r._deleted&&i.set(r.position,r);const s=[];return i.forEach(r=>{const n=r._paneIndex??0,l=e(n);if(!l)return;const a=et.buildTableElements(r,l);s.push(...a)}),s}static buildTableElements(t,e){const i=t.rows||0,s=t.columns||0;if(i===0||s===0)return[];const r=t.border_width??0,n=t.frame_width??0,l=r>0&&!!t.border_color,a=n>0&&!!t.frame_color,o=new Map,d=new Set;if(t.merges)for(const P of t.merges){o.set(`${P.startCol},${P.startRow}`,{colspan:P.endCol-P.startCol+1,rowspan:P.endRow-P.startRow+1});for(let G=P.startRow;G<=P.endRow;G++)for(let M=P.startCol;M<=P.endCol;M++)G===P.startRow&&M===P.startCol||d.add(`${M},${G}`)}const u=4,c=2,g=1.25,p=[];for(let P=0;P<i;P++){p[P]=[];for(let G=0;G<s;G++){if(d.has(`${G},${P}`)){p[P][G]={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 M=t.cells?.[P]?.[G],F=o.get(`${G},${P}`),T=F?.colspan??1,Y=F?.rowspan??1,O=M&&!M._merged&&M.text||"",B=O?O.split(`
38
+ `):[],j=M?et.getSizePixels(M.text_size):12,R=M?.text_font_family==="monospace"?"monospace":"sans-serif";let nt=0,K=0;M?.width>0&&(nt=Math.max(1,M.width*e.width/100)),M?.height>0&&(K=Math.max(1,M.height*e.height/100));const gt=K>0&&K<4,Ht=gt?0:u,qt=gt?0:c,bt=M&&!M._merged&&M.bgcolor&&typeof M.bgcolor=="string"&&M.bgcolor.length>0?M.bgcolor:"",Rt=M?.text_color||"";p[P][G]={text:O,lines:B,fontSize:j,fontFamily:R,textColor:Rt?et.parseColor(Rt):{color:"#e0e0e0",opacity:1},bgColor:bt?et.parseColor(bt):{color:"",opacity:0},halign:M?et.mapHAlign(M.text_halign):"center",valign:M?et.mapVAlign(M.text_valign):"middle",explicitWidth:nt,explicitHeight:K,colspan:T,rowspan:Y,skip:!1,padX:Ht,padY:qt}}}const y=new Array(s).fill(0),f=new Array(i).fill(0);for(let P=0;P<i;P++)for(let G=0;G<s;G++){const M=p[P][G];if(M.skip||M.colspan>1||M.rowspan>1)continue;const F=et.measureMultiLineWidth(M.lines,M.fontSize,M.fontFamily),T=Math.max(M.lines.length,1),Y=M.explicitWidth>0?M.explicitWidth:F+M.padX*2,O=M.explicitHeight>0?M.explicitHeight:T*M.fontSize*g+M.padY*2;y[G]=Math.max(y[G],Y),f[P]=Math.max(f[P],O)}for(let P=0;P<s;P++)y[P]===0&&(y[P]=20);for(let P=0;P<i;P++)f[P]===0&&(f[P]=4);for(let P=0;P<i;P++)for(let G=0;G<s;G++){const M=p[P][G];if(M.skip)continue;const F=Math.max(M.lines.length,1),T=M.explicitHeight>0?M.explicitHeight:F*M.fontSize*g+M.padY*2;if(M.colspan>1){const Y=et.sumRange(y,G,M.colspan),O=et.measureMultiLineWidth(M.lines,M.fontSize,M.fontFamily),B=M.explicitWidth>0?M.explicitWidth:O+M.padX*2;if(B>Y){const j=(B-Y)/M.colspan;for(let R=0;R<M.colspan;R++)y[G+R]+=j}M.rowspan===1&&(f[P]=Math.max(f[P],T))}if(M.rowspan>1){const Y=et.sumRange(f,P,M.rowspan);if(T>Y){const O=(T-Y)/M.rowspan;for(let B=0;B<M.rowspan;B++)f[P+B]+=O}}}for(let P=0;P<s;P++)y[P]=Math.round(y[P]);for(let P=0;P<i;P++)f[P]=Math.round(f[P]);const x=new Array(s+1).fill(0);for(let P=0;P<s;P++)x[P+1]=x[P]+y[P];const m=new Array(i+1).fill(0);for(let P=0;P<i;P++)m[P+1]=m[P]+f[P];const S=a?n:0,v=x[s]+S*2,I=m[i]+S*2,b=Math.min(v,e.width),C=Math.min(I,e.height),w=et.computePosition(t.position,e,b,C),k=Math.round(w.x),A=Math.round(w.y),$=[],_=k+S,E=A+S;if(t.bgcolor){const{color:P,opacity:G}=et.parseColor(t.bgcolor);G>0&&$.push({type:"rect",shape:{x:k,y:A,width:b,height:C},style:{fill:P,opacity:G},silent:!0,z:0,z2:0})}if(a){const{color:P}=et.parseColor(t.frame_color),G=n/2;$.push({type:"rect",shape:{x:k+G,y:A+G,width:b-n,height:C-n},style:{fill:"none",stroke:P,lineWidth:n},silent:!0,z:0,z2:1})}const L=l?et.parseColor(t.border_color).color:"";for(let P=0;P<i;P++)for(let G=0;G<s;G++){const M=p[P][G];if(M.skip)continue;const F=_+x[G],T=E+m[P],Y=et.sumRange(y,G,M.colspan),O=et.sumRange(f,P,M.rowspan);if(F-k>=b||T-A>=C)continue;const B=Math.min(Y,b-(F-k)),j=Math.min(O,C-(T-A));if(M.bgColor.opacity>0&&$.push({type:"rect",shape:{x:F,y:T,width:B,height:j},style:{fill:M.bgColor.color,opacity:M.bgColor.opacity},silent:!0,z:0,z2:2}),l&&$.push({type:"rect",shape:{x:F,y:T,width:B,height:j},style:{fill:"none",stroke:L,lineWidth:r},silent:!0,z:0,z2:3}),M.text){let R,nt;switch(M.halign){case"left":R=F+M.padX,nt="left";break;case"right":R=F+B-M.padX,nt="right";break;default:R=F+B/2,nt="center";break}let K,gt;switch(M.valign){case"top":K=T+M.padY,gt="top";break;case"bottom":K=T+j-M.padY,gt="bottom";break;default:K=T+j/2,gt="middle";break}$.push({type:"text",x:R,y:K,style:{text:M.text,fill:M.textColor.color,opacity:M.textColor.opacity,font:`${M.fontSize}px ${M.fontFamily}`,textAlign:nt,textVerticalAlign:gt,lineHeight:Math.round(M.fontSize*g)},silent:!0,z:0,z2:4})}}return $}static computePosition(t,e,i,s){const r=e.x,n=e.y,l=e.width,a=e.height;switch(t){case"top_left":return{x:r+4,y:n+4};case"top_center":return{x:r+(l-i)/2,y:n+4};case"top_right":return{x:r+l-i-4,y:n+4};case"middle_left":return{x:r+4,y:n+(a-s)/2};case"middle_center":return{x:r+(l-i)/2,y:n+(a-s)/2};case"middle_right":return{x:r+l-i-4,y:n+(a-s)/2};case"bottom_left":return{x:r+4,y:n+a-s-4};case"bottom_center":return{x:r+(l-i)/2,y:n+a-s-4};case"bottom_right":return{x:r+l-i-4,y:n+a-s-4};default:return{x:r+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 r=0;for(const n of t)r=Math.max(r,n.length*e*s);return r}static sumRange(t,e,i){let s=0;for(let r=e;r<e+i&&r<t.length;r++)s+=t[r];return s}}var Ti=Object.defineProperty,Zi=(h,t,e)=>t in h?Ti(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,W=(h,t,e)=>(Zi(h,typeof t!="symbol"?t+"":t,e),e);class Ni{constructor(t,e={}){W(this,"chart"),W(this,"options"),W(this,"marketData",[]),W(this,"indicators",new Map),W(this,"timeToIndex",new Map),W(this,"pluginManager"),W(this,"drawingEditor"),W(this,"events",new Wi),W(this,"isMainCollapsed",!1),W(this,"maximizedPaneId",null),W(this,"countdownInterval",null),W(this,"selectedDrawingId",null),W(this,"drawings",[]),W(this,"drawingRenderers",new de),W(this,"coordinateConversion",{pixelToData:n=>{const l=this.chart.getOption();if(!l||!l.grid)return null;const a=l.grid.length;for(let o=0;o<a;o++)if(this.chart.containPixel({gridIndex:o},[n.x,n.y])){this.chart.convertFromPixel({seriesIndex:o},[n.x,n.y]);const d=this.chart.convertFromPixel({gridIndex:o},[n.x,n.y]);if(d)return{timeIndex:Math.round(d[0])-this.dataIndexOffset,value:d[1],paneIndex:o}}return null},dataToPixel:n=>{const l=n.paneIndex||0,a=this.chart.convertToPixel({gridIndex:l},[n.timeIndex+this.dataIndexOffset,n.value]);return a?{x:a[0],y:a[1]}:null}}),W(this,"upColor","#00da3c"),W(this,"downColor","#ec0000"),W(this,"defaultPadding",0),W(this,"padding"),W(this,"dataIndexOffset",0),W(this,"_paddingPoints",0),W(this,"LAZY_MIN_PADDING",5),W(this,"LAZY_MAX_PADDING",500),W(this,"LAZY_CHUNK_SIZE",50),W(this,"LAZY_EDGE_THRESHOLD",10),W(this,"_expandScheduled",!1),W(this,"rootContainer"),W(this,"layoutContainer"),W(this,"toolbarContainer"),W(this,"leftSidebar"),W(this,"rightSidebar"),W(this,"chartContainer"),W(this,"overlayContainer"),W(this,"_lastTables",[]),W(this,"_tableGraphicIds",[]),W(this,"_baseGraphics",[]),W(this,"_labelTooltipEl",null),W(this,"_lastLayout",null),W(this,"_mainHeightOverride",null),W(this,"_paneDragState",null),W(this,"_paneResizeRafId",null),W(this,"onKeyDown",n=>{(n.key==="Delete"||n.key==="Backspace")&&this.selectedDrawingId&&(this.removeDrawing(this.selectedDrawingId),this.selectedDrawingId=null,this.render())}),W(this,"onFullscreenChange",()=>{this.render()}),W(this,"isLocked",!1),W(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=D.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 Di(this,this.toolbarContainer),this.drawingEditor=new Ai(this),this.chart.on("dataZoom",n=>{this.events.emit("chart:dataZoom",n);const l=this.options.databox?.triggerOn,a=this.options.databox?.position;l==="click"&&a==="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,r=this;i.setCursorStyle=function(n){if(r._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 r=this.chart.getHeight();if(r<=0)return null;for(const n of this._lastLayout.paneBoundaries){const l=n.yPercent/100*r;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 r=s.offsetY-this._paneDragState.startY,n=this.chart.getHeight();if(n<=0)return;const l=r/n*100,a=this._paneDragState.aboveId==="main"?10:5,o=5;let d=this._paneDragState.startAboveHeight+l,u=this._paneDragState.startBelowHeight-l;if(d<a&&(d=a,u=this._paneDragState.startAboveHeight+this._paneDragState.startBelowHeight-a),u<o&&(u=o,d=this._paneDragState.startAboveHeight+this._paneDragState.startBelowHeight-o),this._paneDragState.aboveId==="main")this._mainHeightOverride=d;else{const g=this.indicators.get(this._paneDragState.aboveId);g&&(g.height=d)}const c=this.indicators.get(this._paneDragState.belowId);c&&(c.height=u),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 r=e(s.offsetY);r&&(this._paneDragState={startY:s.offsetY,aboveId:r.aboveId,belowId:r.belowId,startAboveHeight:i(r.aboveId),startBelowHeight:i(r.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 r=parseInt(s[1]),n=this.drawings.filter(a=>(a.paneIndex||0)===r)[i.dataIndex];if(!n)return null;const l=i.event?.target?.name;return{drawing:n,targetName:l,paneIdx:r}};this.chart.on("mouseover",i=>{const s=e(i);if(!s)return;const r=i.event?.target?.parent;if(r){const n=s.drawing.id===this.selectedDrawingId;t&&(clearTimeout(t),t=null),n||r.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 r=i.event?.target?.parent;if(s.drawing.id!==this.selectedDrawingId){if(t=setTimeout(()=>{if(r){if(this.selectedDrawingId===s.drawing.id)return;r.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 r=i.event?.event||i.event,n=r?.offsetX,l=r?.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 a=parseInt(s.targetName.split("-")[1])||0;this.events.emit("drawing:point:mousedown",{id:s.drawing.id,pointIndex:a,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 r=parseInt(s.targetName.split("-")[1])||0;this.events.emit("drawing:point:click",{id:s.drawing.id,pointIndex:r})}}}),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 r=this.chartContainer.getBoundingClientRect(),n=i.event?.event;if(n){const l=n.clientX-r.left,a=n.clientY-r.top,o=this._labelTooltipEl.offsetWidth,d=Math.min(l-o/2,r.width-o-8);this._labelTooltipEl.style.left=Math.max(4,d)+"px",this._labelTooltipEl.style.top=a+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 r=this.marketData[s];if(!r)return t;const n=this.chart.convertToPixel({gridIndex:i},[s+this.dataIndexOffset,r.close]);if(!n)return t;const l=n[0],a=[r.open,r.high,r.low,r.close];let o=a[0],d=1/0;for(const c of a){const g=this.chart.convertToPixel({gridIndex:i},[s+this.dataIndexOffset,c]);if(g){const p=Math.abs(g[1]-t.y);p<d&&(d=p,o=c)}}const u=this.chart.convertToPixel({gridIndex:i},[s+this.dataIndexOffset,o]);return{x:l,y:u?u[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(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,x)=>f.time-x.time),this.rebuildTimeIndex();const i=this.dataIndexOffset,s=Dt.buildCandlestickSeries(this.marketData,this.options),r={value:[NaN,NaN,NaN,NaN],itemStyle:{opacity:0}},n=[...Array(i).fill(r),...s.data,...Array(i).fill(r)],l=[...Array(i).fill(""),...this.marketData.map(f=>new Date(f.time).toLocaleString()),...Array(i).fill("")],a=this.chart.getOption(),o=Ut.calculate(this.chart.getHeight(),this.indicators,this.options,this.isMainCollapsed,this.maximizedPaneId,this.marketData,this._mainHeightOverride??void 0);this._lastLayout=o;const d=[...Array(i).fill(null),...this.marketData,...Array(i).fill(null)],{series:u,barColors:c}=Dt.buildIndicatorSeries(this.indicators,this.timeToIndex,o.paneLayout,l.length,i,d,o.overlayYAxisMap,o.separatePaneYAxisOffset),g=n.map((f,x)=>c[x]?{value:f.value||f,itemStyle:{color:c[x],color0:c[x]}}:f),p={xAxis:a.xAxis.map((f,x)=>({data:l})),series:[{data:g,markLine:s.markLine},...u]};this.chart.setOption(p,{notMerge:!1});const y=[];this.indicators.forEach(f=>{Object.values(f.plots).forEach(x=>{x.options?.style==="table"&&x.data?.forEach(m=>{(Array.isArray(m.value)?m.value:[m.value]).forEach(S=>{S&&!S._deleted&&(S._paneIndex=S.force_overlay?0:f.paneIndex,y.push(S))})})})}),this._lastTables=y,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(),r=i-s;if(r<=0)return;const n=Math.abs(r),l=Math.floor(n/36e5),a=Math.floor(n%36e5/6e4),o=Math.floor(n%6e4/1e3),d=`${l>0?l.toString().padStart(2,"0")+":":""}${a.toString().padStart(2,"0")}:${o.toString().padStart(2,"0")}`,u=this.chart.getOption();if(!u||!u.series)return;const c=u.series.findIndex(m=>m.type==="candlestick");if(c===-1)return;const g=u.series[c];if(!g.markLine||!g.markLine.data||!g.markLine.data[0])return;const p=g.markLine.data[0];p.label.formatter;const y=p.yAxis;let f="";if(this.options.yAxisLabelFormatter)f=this.options.yAxisLabelFormatter(y);else{const m=this.options.yAxisDecimalPlaces!==void 0?this.options.yAxisDecimalPlaces:V.autoDetectDecimals(this.marketData);f=V.formatValue(y,m)}const x=`${f}
39
+ ${d}`;this.chart.setOption({series:[{id:"__candlestick__",markLine:{data:[{...p,label:{...p.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 r=0;if(!s){let l=0;this.indicators.forEach(a=>{a.paneIndex>l&&(l=a.paneIndex)}),r=l+1}const n=new ii(t,e,r,{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=et.buildGraphicElements(this._lastTables,e);this._tableGraphicIds=[];for(let s=0;s<i.length;s++){const r=`__qf_table_${s}`;i[s].id=r,this._tableGraphicIds.push(r)}return i}_renderTableOverlays(){const t=this._buildTableGraphics(),e=[...this._baseGraphics,...t];this.chart.setOption({graphic:e},{replaceMerge:["graphic"]}),rt.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,r=this.chart.getOption(),n=r?.dataZoom?.find(A=>A.type==="slider"||A.type==="inside"),l=n?n.start/100*s:0,a=n?n.end/100*s:s,o=t-i;this._paddingPoints=t,this.dataIndexOffset=this._paddingPoints;const d=this._paddingPoints,u={value:[NaN,NaN,NaN,NaN],itemStyle:{opacity:0}},c=Dt.buildCandlestickSeries(this.marketData,this.options),g=[...Array(d).fill(u),...c.data,...Array(d).fill(u)],p=[...Array(d).fill(""),...this.marketData.map(A=>new Date(A.time).toLocaleString()),...Array(d).fill("")],y=[...Array(d).fill(null),...this.marketData,...Array(d).fill(null)],f=Ut.calculate(this.chart.getHeight(),this.indicators,this.options,this.isMainCollapsed,this.maximizedPaneId,this.marketData,this._mainHeightOverride??void 0),{series:x,barColors:m}=Dt.buildIndicatorSeries(this.indicators,this.timeToIndex,f.paneLayout,p.length,d,y,f.overlayYAxisMap,f.separatePaneYAxisOffset),S=g.map((A,$)=>m[$]?{value:A.value||A,itemStyle:{color:m[$],color0:m[$]}}:A),v=this.marketData.length+2*t,I=Math.max(0,(l+o)/v*100),b=Math.min(100,(a+o)/v*100),C=[],w=new Map;this.drawings.forEach(A=>{const $=A.paneIndex||0;w.has($)||w.set($,[]),w.get($).push(A)}),w.forEach(A=>{C.push({data:A.map($=>{const _=[];return $.points.forEach(E=>{_.push(E.timeIndex+this.dataIndexOffset,E.value)}),_})})});const k={xAxis:r.xAxis.map(()=>({data:p})),dataZoom:(r.dataZoom||[]).map(()=>({start:I,end:b})),series:[{data:S,markLine:c.markLine},...x.map(A=>{const $={data:A.data};return A.renderItem&&($.renderItem=A.renderItem),$}),...C]};this.chart.setOption(k,{notMerge:!1})}_checkEdgeAndExpand(){if(this._expandScheduled)return;const t=this.chart.getOption()?.dataZoom?.find(y=>y.type==="slider"||y.type==="inside");if(!t)return;const e=this._paddingPoints,i=this.marketData.length,s=i+2*e,r=Math.round(t.start/100*s),n=Math.round(t.end/100*s),l=e,a=e+i-1,o=Math.max(0,Math.min(n,a)-Math.max(r,l)+1),d=r<this.LAZY_EDGE_THRESHOLD,u=n>s-this.LAZY_EDGE_THRESHOLD;if((d||u)&&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-r),g=Math.max(0,n-(e+i-1)),p=Math.max(c+this.LAZY_CHUNK_SIZE,g+this.LAZY_CHUNK_SIZE);e>p+this.LAZY_CHUNK_SIZE&&(this._expandScheduled=!0,requestAnimationFrame(()=>{this._expandScheduled=!1,this._resizePadding(p)}))}render(){if(this.marketData.length===0)return;let t=null;try{const b=this.chart.getOption();if(b&&b.dataZoom&&b.dataZoom.length>0){const C=b.dataZoom.find(w=>w.type==="slider"||w.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,r=e==="left"?"block":"none",n=e==="right"?"block":"none";(i!==r||s!==n)&&(this.leftSidebar.style.display=r,this.rightSidebar.style.display=n,this.chart.resize());const l=this.dataIndexOffset,a=[...Array(l).fill(""),...this.marketData.map(b=>new Date(b.time).toLocaleString()),...Array(l).fill("")],o=Ut.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 b=this.marketData.length,C=a.length,w=l/C,k=b/C;o.dataZoom.forEach(A=>{if(A.start!==void 0){const $=A.start/100,_=w+$*k;A.start=_*100}if(A.end!==void 0){const $=A.end/100,_=w+$*k;A.end=_*100}})}t&&o.dataZoom&&o.dataZoom.forEach(b=>{b.start=t.start,b.end=t.end}),o.xAxis.forEach(b=>{b.data=a,b.boundaryGap=!1});const d=Dt.buildCandlestickSeries(this.marketData,this.options),u={value:[NaN,NaN,NaN,NaN],itemStyle:{opacity:0}};d.data=[...Array(l).fill(u),...d.data,...Array(l).fill(u)];const c=[...Array(l).fill(null),...this.marketData,...Array(l).fill(null)],{series:g,barColors:p}=Dt.buildIndicatorSeries(this.indicators,this.timeToIndex,o.paneLayout,a.length,l,c,o.overlayYAxisMap,o.separatePaneYAxisOffset);d.data=d.data.map((b,C)=>p[C]?{value:b.value||b,itemStyle:{color:p[C],color0:p[C]}}:b);const y=[];this.indicators.forEach((b,C)=>{b.paneIndex===0&&y.push({id:C,titleColor:b.titleColor})});const f=Ci.build(o,this.options,this.toggleIndicator.bind(this),this.isMainCollapsed,this.maximizedPaneId,y),x=new Map;this.drawings.forEach(b=>{const C=b.paneIndex||0;x.has(C)||x.set(C,[]),x.get(C).push(b)});const m=[];x.forEach((b,C)=>{m.push({type:"custom",name:`drawings-pane-${C}`,xAxisIndex:C,yAxisIndex:C,clip:!0,renderItem:(w,k)=>{const A=b[w.dataIndex];if(!A)return;const $=this.drawingRenderers.get(A.type);if(!$)return;const _=this.dataIndexOffset,E=A.points.map(L=>k.coord([L.timeIndex+_,L.value]));return $.render({drawing:A,pixelPoints:E,isSelected:A.id===this.selectedDrawingId,api:k,coordSys:w.coordSys})},data:b.map(w=>{const k=[];return w.points.forEach(A=>{k.push(A.timeIndex+this.dataIndexOffset,A.value)}),k}),encode:(()=>{const w=b.reduce(($,_)=>Math.max($,_.points.length),0),k=Array.from({length:w},($,_)=>_*2),A=Array.from({length:w},($,_)=>_*2+1);return{x:k,y:A}})(),z:100,silent:!1})});const S=b=>{const C=Pi.format(b,this.options),w=this.options.databox?.position;return w==="left"?(this.leftSidebar.innerHTML=C,""):w==="right"?(this.rightSidebar.innerHTML=C,""):this.options.databox?`<div style="min-width: 200px;">${C}</div>`:""},v=[];this.indicators.forEach(b=>{Object.values(b.plots).forEach(C=>{C.options?.style==="table"&&C.data?.forEach(w=>{(Array.isArray(w.value)?w.value:[w.value]).forEach(k=>{k&&!k._deleted&&(k._paneIndex=k.force_overlay?0:b.paneIndex,v.push(k))})})})});const I={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:S,extraCssText:e!=="floating"&&e!==void 0?"display: none !important;":void 0,position:(b,C,w,k,A)=>{if(this.options.databox?.position==="floating"){const $={top:10};return $[["left","right"][+(b[0]<A.viewSize[0]/2)]]=30,$}return null}},axisPointer:{link:{xAxisIndex:"all"},label:{backgroundColor:"#475569"}},graphic:f,grid:o.grid,xAxis:o.xAxis,yAxis:o.yAxis,dataZoom:o.dataZoom,series:[d,...g,...m]};if(this.chart.setOption(I,!0),this._baseGraphics=f,this._lastTables=v,v.length>0){const b=this._buildTableGraphics();if(b.length>0){const C=[...f,...b];this.chart.setOption({graphic:C},{replaceMerge:["graphic"]})}}else this._tableGraphicIds=[];rt.clearAll(this.overlayContainer)}}var Fi=Object.defineProperty,Oi=(h,t,e)=>t in h?Fi(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,ht=(h,t,e)=>(Oi(h,typeof t!="symbol"?t+"":t,e),e);class X{constructor(t){ht(this,"id"),ht(this,"name"),ht(this,"icon"),ht(this,"context"),ht(this,"eventListeners",[]),ht(this,"_snapIndicator",null),ht(this,"_snapMoveHandler",null),ht(this,"_snapKeyDownHandler",null),ht(this,"_snapKeyUpHandler",null),ht(this,"_snapBlurHandler",null),ht(this,"_snapActive",!1),ht(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 r=this.context.snapToCandle({x:e,y:i});return[r.x,r.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 D.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 Hi=Object.defineProperty,Ri=(h,t,e)=>t in h?Hi(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,it=(h,t,e)=>(Ri(h,typeof t!="symbol"?t+"":t,e),e);class Bi extends X{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>'}),it(this,"zr"),it(this,"state","idle"),it(this,"startPoint",null),it(this,"endPoint",null),it(this,"group",null),it(this,"rect",null),it(this,"labelRect",null),it(this,"labelText",null),it(this,"lineV",null),it(this,"lineH",null),it(this,"arrowStart",null),it(this,"arrowEnd",null),it(this,"onMouseDown",()=>{this.state==="finished"&&this.removeGraphic()}),it(this,"onChartInteraction",()=>{this.group&&this.removeGraphic()}),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.context.disableTools(),this.enableClearListeners())}),it(this,"clearHandlers",{}),it(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 D.graphic.Group,this.rect=new D.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 D.graphic.Line({shape:{x1:0,y1:0,x2:0,y2:0},style:{stroke:"#fff",lineWidth:1,lineDash:[4,4]},z:101}),this.lineH=new D.graphic.Line({shape:{x1:0,y1:0,x2:0,y2:0},style:{stroke:"#fff",lineWidth:1,lineDash:[4,4]},z:101}),this.arrowStart=new D.graphic.Polygon({shape:{points:[[0,0],[-5,10],[5,10]]},style:{fill:"#fff"},z:102}),this.arrowEnd=new D.graphic.Polygon({shape:{points:[[0,0],[-5,-10],[5,-10]]},style:{fill:"#fff"},z:102}),this.labelRect=new D.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 D.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,r=this.context.coordinateConversion.pixelToData({x:t,y:e}),n=this.context.coordinateConversion.pixelToData({x:i,y:s});if(!r||!n)return;const l=Math.round(r.timeIndex),a=Math.round(n.timeIndex),o=r.value,d=n.value,u=a-l,c=d-o,g=c/o*100,p=c>=0,y=p?"rgba(33, 150, 243, 0.2)":"rgba(236, 0, 0, 0.2)",f=p?"#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:y});const x=(t+i)/2,m=(e+s)/2;this.lineV.setShape({x1:x,y1:e,x2:x,y2:s}),this.lineV.setStyle({stroke:f}),this.lineH.setShape({x1:t,y1:m,x2:i,y2:m}),this.lineH.setStyle({stroke:f});const S=Math.min(e,s),v=Math.max(e,s);this.arrowStart.setStyle({fill:"none"}),this.arrowEnd.setStyle({fill:"none"}),p?(this.arrowStart.setShape({points:[[x,S],[x-4,S+6],[x+4,S+6]]}),this.arrowStart.setStyle({fill:f})):(this.arrowEnd.setShape({points:[[x,v],[x-4,v-6],[x+4,v-6]]}),this.arrowEnd.setStyle({fill:f}));const I=[`${c.toFixed(2)} (${g.toFixed(2)}%)`,`${u} bars`].join(`
40
+ `),b=140,C=40,w=Math.max(e,s),k=Math.min(e,s);let A=(t+i)/2-b/2,$=w+10;const _=this.chart.getHeight();$+C>_&&($=k-C-10),this.labelRect.setShape({x:A,y:$,width:b,height:C}),this.labelRect.setStyle({fill:"#1e293b",stroke:f,lineWidth:1}),this.labelText.setStyle({x:A+b/2,y:$+C/2,text:I,fill:"#fff"})}}var ji=Object.defineProperty,Yi=(h,t,e)=>t in h?ji(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,Vi=(h,t,e)=>(Yi(h,typeof t!="symbol"?t+"":t,e),e);class pe{constructor(){Vi(this,"type","line")}render(t){const{drawing:e,pixelPoints:i,isSelected:s}=t,[r,n]=i[0],[l,a]=i[1],o=e.style?.color||"#d1d4dc";return{type:"group",children:[{type:"line",name:"line",shape:{x1:r,y1:n,x2:l,y2:a},style:{stroke:o,lineWidth:e.style?.lineWidth||1}},{type:"circle",name:"point-0",shape:{cx:r,cy:n,r:4},style:{fill:"#fff",stroke:o,lineWidth:1,opacity:s?1:0}},{type:"circle",name:"point-1",shape:{cx:l,cy:a,r:4},style:{fill:"#fff",stroke:o,lineWidth:1,opacity:s?1:0}}]}}}var Xi=Object.defineProperty,qi=(h,t,e)=>t in h?Xi(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,pt=(h,t,e)=>(qi(h,typeof t!="symbol"?t+"":t,e),e);class Ui extends X{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>'}),pt(this,"zr"),pt(this,"state","idle"),pt(this,"startPoint",null),pt(this,"endPoint",null),pt(this,"group",null),pt(this,"line",null),pt(this,"startCircle",null),pt(this,"endCircle",null),pt(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 r=i.paneIndex||0;this.context.addDrawing({id:`line-${Date.now()}`,type:"line",points:[i,s],paneIndex:r,style:{color:"#d1d4dc",lineWidth:1}})}}this.removeGraphic(),this.context.disableTools()}}),pt(this,"onMouseMove",e=>{this.state==="drawing"&&(this.endPoint=this.getPoint(e),this.updateGraphic())})}onInit(){this.zr=this.chart.getZr(),this.context.registerDrawingRenderer(new pe)}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 D.graphic.Group,this.line=new D.graphic.Line({shape:{x1:0,y1:0,x2:0,y2:0},style:{stroke:"#d1d4dc",lineWidth:1},z:100}),this.startCircle=new D.graphic.Circle({shape:{cx:0,cy:0,r:4},style:{fill:"#fff",stroke:"#d1d4dc",lineWidth:1},z:101}),this.endCircle=new D.graphic.Circle({shape:{cx:0,cy:0,r:4},style:{fill:"#fff",stroke:"#d1d4dc",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 Ki=Object.defineProperty,Ji=(h,t,e)=>t in h?Ki(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,Qi=(h,t,e)=>(Ji(h,typeof t!="symbol"?t+"":t,e),e);class ue{constructor(){Qi(this,"type","ray")}render(t){const{drawing:e,pixelPoints:i,isSelected:s,coordSys:r}=t,[n,l]=i[0],[a,o]=i[1],d=e.style?.color||"#d1d4dc",[u,c]=this.extendToEdge(n,l,a,o,r);return{type:"group",children:[{type:"line",name:"line",shape:{x1:n,y1:l,x2:u,y2:c},style:{stroke:d,lineWidth:e.style?.lineWidth||1}},{type:"circle",name:"point-0",shape:{cx:n,cy:l,r:4},style:{fill:"#fff",stroke:d,lineWidth:1,opacity:s?1:0}},{type:"circle",name:"point-1",shape:{cx:a,cy:o,r:4},style:{fill:"#fff",stroke:d,lineWidth:1,opacity:s?1:0}}]}}extendToEdge(t,e,i,s,r){const n=i-t,l=s-e;if(n===0&&l===0)return[i,s];const a=r.x,o=r.x+r.width,d=r.y,u=r.y+r.height;let c=1/0;if(n!==0){const g=n>0?(o-t)/n:(a-t)/n;g>0&&(c=Math.min(c,g))}if(l!==0){const g=l>0?(u-e)/l:(d-e)/l;g>0&&(c=Math.min(c,g))}return isFinite(c)||(c=1),[t+c*n,e+c*l]}}var ts=Object.defineProperty,es=(h,t,e)=>t in h?ts(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,dt=(h,t,e)=>(es(h,typeof t!="symbol"?t+"":t,e),e);const Et="#d1d4dc";class is extends X{constructor(t={}){super({id:"ray-tool",name:t?.name||"Ray",icon:t?.icon||'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="3" y1="20" x2="21" y2="4"/><circle cx="21" cy="4" r="0" fill="currentColor"/><polyline points="16,4 21,4 21,9" stroke-width="1.5"/></svg>'}),dt(this,"zr"),dt(this,"state","idle"),dt(this,"startPoint",null),dt(this,"endPoint",null),dt(this,"group",null),dt(this,"line",null),dt(this,"dashLine",null),dt(this,"startCircle",null),dt(this,"endCircle",null),dt(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.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]});i&&s&&this.context.addDrawing({id:`ray-${Date.now()}`,type:"ray",points:[i,s],paneIndex:i.paneIndex||0,style:{color:Et,lineWidth:1}})}this.removeGraphic(),this.context.disableTools()}}),dt(this,"onMouseMove",e=>{this.state==="drawing"&&(this.endPoint=this.getPoint(e),this.updateGraphic())})}onInit(){this.zr=this.chart.getZr(),this.context.registerDrawingRenderer(new ue)}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.removeGraphic()}onDestroy(){this.removeGraphic()}initGraphic(){this.group||(this.group=new D.graphic.Group,this.line=new D.graphic.Line({shape:{x1:0,y1:0,x2:0,y2:0},style:{stroke:Et,lineWidth:1},z:100}),this.dashLine=new D.graphic.Line({shape:{x1:0,y1:0,x2:0,y2:0},style:{stroke:Et,lineWidth:1,lineDash:[4,4],opacity:.5},z:99}),this.startCircle=new D.graphic.Circle({shape:{cx:0,cy:0,r:4},style:{fill:"#fff",stroke:Et,lineWidth:1},z:101}),this.endCircle=new D.graphic.Circle({shape:{cx:0,cy:0,r:4},style:{fill:"#fff",stroke:Et,lineWidth:1},z:101}),this.group.add(this.dashLine),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});const[r,n]=this.extendToEdge(t,e,i,s);this.dashLine.setShape({x1:i,y1:s,x2:r,y2:n})}extendToEdge(t,e,i,s){const r=i-t,n=s-e;if(r===0&&n===0)return[i,s];const l=this.chart.getWidth(),a=this.chart.getHeight();let o=1/0;if(r!==0){const d=r>0?(l-t)/r:-t/r;d>0&&(o=Math.min(o,d))}if(n!==0){const d=n>0?(a-e)/n:-e/n;d>0&&(o=Math.min(o,d))}return isFinite(o)||(o=1),[t+o*r,e+o*n]}}var ss=Object.defineProperty,ns=(h,t,e)=>t in h?ss(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,os=(h,t,e)=>(ns(h,typeof t!="symbol"?t+"":t,e),e);class ge{constructor(){os(this,"type","info-line")}render(t){const{drawing:e,pixelPoints:i,isSelected:s}=t,[r,n]=i[0],[l,a]=i[1],o=e.style?.color||"#d1d4dc",d=e.points[0],u=e.points[1],c=u.value-d.value,g=d.value!==0?c/d.value*100:0,p=Math.abs(u.timeIndex-d.timeIndex),y=c>=0?"+":"",f=`${y}${c.toFixed(2)} (${y}${g.toFixed(2)}%) ${p} bars`,x=(r+l)/2,m=(n+a)/2,S=c>=0?"#26a69a":"#ef5350";return{type:"group",children:[{type:"line",name:"line",shape:{x1:r,y1:n,x2:l,y2:a},style:{stroke:o,lineWidth:e.style?.lineWidth||1}},{type:"rect",shape:{x:x-2,y:m-22,width:f.length*6.5+12,height:18,r:3},style:{fill:"#1e293b",stroke:"#475569",lineWidth:1,opacity:.9},z2:10},{type:"text",x:x+4,y:m-20,style:{text:f,fill:S,fontSize:11,fontFamily:"monospace"},z2:11},{type:"circle",name:"point-0",shape:{cx:r,cy:n,r:4},style:{fill:"#fff",stroke:o,lineWidth:1,opacity:s?1:0}},{type:"circle",name:"point-1",shape:{cx:l,cy:a,r:4},style:{fill:"#fff",stroke:o,lineWidth:1,opacity:s?1:0}}]}}}var rs=Object.defineProperty,as=(h,t,e)=>t in h?rs(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,ut=(h,t,e)=>(as(h,typeof t!="symbol"?t+"":t,e),e);class ls extends X{constructor(t={}){super({id:"info-line-tool",name:t?.name||"Info 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"/><rect x="12" y="8" width="8" height="5" rx="1" fill="none" stroke-width="1.5"/></svg>'}),ut(this,"zr"),ut(this,"state","idle"),ut(this,"startPoint",null),ut(this,"endPoint",null),ut(this,"group",null),ut(this,"line",null),ut(this,"startCircle",null),ut(this,"endCircle",null),ut(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]});i&&s&&this.context.addDrawing({id:`info-line-${Date.now()}`,type:"info-line",points:[i,s],paneIndex:i.paneIndex||0,style:{color:"#d1d4dc",lineWidth:1}})}this.removeGraphic(),this.context.disableTools()}}),ut(this,"onMouseMove",e=>{this.state==="drawing"&&(this.endPoint=this.getPoint(e),this.updateGraphic())})}onInit(){this.zr=this.chart.getZr(),this.context.registerDrawingRenderer(new ge)}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.removeGraphic()}onDestroy(){this.removeGraphic()}initGraphic(){this.group||(this.group=new D.graphic.Group,this.line=new D.graphic.Line({shape:{x1:0,y1:0,x2:0,y2:0},style:{stroke:"#d1d4dc",lineWidth:1},z:100}),this.startCircle=new D.graphic.Circle({shape:{cx:0,cy:0,r:4},style:{fill:"#fff",stroke:"#d1d4dc",lineWidth:1},z:101}),this.endCircle=new D.graphic.Circle({shape:{cx:0,cy:0,r:4},style:{fill:"#fff",stroke:"#d1d4dc",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 hs=Object.defineProperty,cs=(h,t,e)=>t in h?hs(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,ds=(h,t,e)=>(cs(h,typeof t!="symbol"?t+"":t,e),e);class ye{constructor(){ds(this,"type","extended-line")}render(t){const{drawing:e,pixelPoints:i,isSelected:s,coordSys:r}=t,[n,l]=i[0],[a,o]=i[1],d=e.style?.color||"#d1d4dc",u=a-n,c=o-l;let g=n,p=l,y=a,f=o;if(u!==0||c!==0){const x=r.x,m=r.x+r.width,S=r.y,v=r.y+r.height;[y,f]=this.extendToEdge(n,l,u,c,x,m,S,v),[g,p]=this.extendToEdge(a,o,-u,-c,x,m,S,v)}return{type:"group",children:[{type:"line",name:"line",shape:{x1:g,y1:p,x2:y,y2:f},style:{stroke:d,lineWidth:e.style?.lineWidth||1}},{type:"circle",name:"point-0",shape:{cx:n,cy:l,r:4},style:{fill:"#fff",stroke:d,lineWidth:1,opacity:s?1:0}},{type:"circle",name:"point-1",shape:{cx:a,cy:o,r:4},style:{fill:"#fff",stroke:d,lineWidth:1,opacity:s?1:0}}]}}extendToEdge(t,e,i,s,r,n,l,a){let o=1/0;if(i!==0){const d=i>0?(n-t)/i:(r-t)/i;d>0&&(o=Math.min(o,d))}if(s!==0){const d=s>0?(a-e)/s:(l-e)/s;d>0&&(o=Math.min(o,d))}return isFinite(o)||(o=1),[t+o*i,e+o*s]}}var ps=Object.defineProperty,us=(h,t,e)=>t in h?ps(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,ct=(h,t,e)=>(us(h,typeof t!="symbol"?t+"":t,e),e);const St="#d1d4dc";class gs extends X{constructor(t={}){super({id:"extended-line-tool",name:t?.name||"Extended Line",icon:t?.icon||'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="1" y1="23" x2="23" y2="1" stroke-dasharray="2,2" opacity="0.4"/><line x1="6" y1="18" x2="18" y2="6"/></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,"dashLineForward",null),ct(this,"dashLineBackward",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.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]});i&&s&&this.context.addDrawing({id:`extended-line-${Date.now()}`,type:"extended-line",points:[i,s],paneIndex:i.paneIndex||0,style:{color:St,lineWidth:1}})}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 ye)}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.removeGraphic()}onDestroy(){this.removeGraphic()}initGraphic(){this.group||(this.group=new D.graphic.Group,this.line=new D.graphic.Line({shape:{x1:0,y1:0,x2:0,y2:0},style:{stroke:St,lineWidth:1},z:100}),this.dashLineForward=new D.graphic.Line({shape:{x1:0,y1:0,x2:0,y2:0},style:{stroke:St,lineWidth:1,lineDash:[4,4],opacity:.5},z:99}),this.dashLineBackward=new D.graphic.Line({shape:{x1:0,y1:0,x2:0,y2:0},style:{stroke:St,lineWidth:1,lineDash:[4,4],opacity:.5},z:99}),this.startCircle=new D.graphic.Circle({shape:{cx:0,cy:0,r:4},style:{fill:"#fff",stroke:St,lineWidth:1},z:101}),this.endCircle=new D.graphic.Circle({shape:{cx:0,cy:0,r:4},style:{fill:"#fff",stroke:St,lineWidth:1},z:101}),this.group.add(this.dashLineBackward),this.group.add(this.dashLineForward),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});const r=i-t,n=s-e;if(r===0&&n===0)return;const[l,a]=this.extendToEdge(t,e,r,n);this.dashLineForward.setShape({x1:i,y1:s,x2:l,y2:a});const[o,d]=this.extendToEdge(i,s,-r,-n);this.dashLineBackward.setShape({x1:t,y1:e,x2:o,y2:d})}extendToEdge(t,e,i,s){const r=this.chart.getWidth(),n=this.chart.getHeight();let l=1/0;if(i!==0){const a=i>0?(r-t)/i:-t/i;a>0&&(l=Math.min(l,a))}if(s!==0){const a=s>0?(n-e)/s:-e/s;a>0&&(l=Math.min(l,a))}return isFinite(l)||(l=1),[t+l*i,e+l*s]}}var ys=Object.defineProperty,fs=(h,t,e)=>t in h?ys(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,xs=(h,t,e)=>(fs(h,typeof t!="symbol"?t+"":t,e),e);class fe{constructor(){xs(this,"type","trend-angle")}render(t){const{drawing:e,pixelPoints:i,isSelected:s}=t,[r,n]=i[0],[l,a]=i[1],o=e.style?.color||"#d1d4dc",d=l-r,u=a-n,c=Math.atan2(-u,d),g=(c*(180/Math.PI)).toFixed(1),p=Math.min(30,Math.sqrt(d*d+u*u)*.3),y=r+Math.max(Math.abs(d),p+20),f=0,x=-c;return{type:"group",children:[{type:"line",name:"line",shape:{x1:r,y1:n,x2:l,y2:a},style:{stroke:o,lineWidth:e.style?.lineWidth||1}},{type:"line",shape:{x1:r,y1:n,x2:y,y2:n},style:{stroke:o,lineWidth:1,opacity:.4,lineDash:[4,4]}},{type:"arc",shape:{cx:r,cy:n,r:p,startAngle:Math.min(f,x),endAngle:Math.max(f,x)},style:{stroke:o,lineWidth:1.5,fill:"none"}},{type:"text",x:r+p+6,y:n+(u<0?-14:2),style:{text:`${g}\xB0`,fill:o,fontSize:11,fontFamily:"sans-serif"},z2:10},{type:"circle",name:"point-0",shape:{cx:r,cy:n,r:4},style:{fill:"#fff",stroke:o,lineWidth:1,opacity:s?1:0}},{type:"circle",name:"point-1",shape:{cx:l,cy:a,r:4},style:{fill:"#fff",stroke:o,lineWidth:1,opacity:s?1:0}}]}}}var ms=Object.defineProperty,bs=(h,t,e)=>t in h?ms(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,lt=(h,t,e)=>(bs(h,typeof t!="symbol"?t+"":t,e),e);const wt="#d1d4dc";class vs extends X{constructor(t={}){super({id:"trend-angle-tool",name:t?.name||"Trend Angle",icon:t?.icon||'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="3" y1="20" x2="21" y2="6"/><line x1="3" y1="20" x2="14" y2="20" opacity="0.4"/><path d="M8 20 A5 5 0 0 1 7 16" stroke-width="1.5"/></svg>'}),lt(this,"zr"),lt(this,"state","idle"),lt(this,"startPoint",null),lt(this,"endPoint",null),lt(this,"group",null),lt(this,"line",null),lt(this,"hRefLine",null),lt(this,"arc",null),lt(this,"angleText",null),lt(this,"startCircle",null),lt(this,"endCircle",null),lt(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.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]});i&&s&&this.context.addDrawing({id:`trend-angle-${Date.now()}`,type:"trend-angle",points:[i,s],paneIndex:i.paneIndex||0,style:{color:wt,lineWidth:1}})}this.removeGraphic(),this.context.disableTools()}}),lt(this,"onMouseMove",e=>{this.state==="drawing"&&(this.endPoint=this.getPoint(e),this.updateGraphic())})}onInit(){this.zr=this.chart.getZr(),this.context.registerDrawingRenderer(new fe)}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.removeGraphic()}onDestroy(){this.removeGraphic()}initGraphic(){this.group||(this.group=new D.graphic.Group,this.line=new D.graphic.Line({shape:{x1:0,y1:0,x2:0,y2:0},style:{stroke:wt,lineWidth:1},z:100}),this.hRefLine=new D.graphic.Line({shape:{x1:0,y1:0,x2:0,y2:0},style:{stroke:wt,lineWidth:1,lineDash:[4,4],opacity:.4},z:99}),this.arc=new D.graphic.Arc({shape:{cx:0,cy:0,r:25,startAngle:0,endAngle:0},style:{stroke:wt,lineWidth:1,fill:"none"},z:99}),this.angleText=new D.graphic.Text({style:{text:"",fill:wt,fontSize:11,fontFamily:"sans-serif"},z:101}),this.startCircle=new D.graphic.Circle({shape:{cx:0,cy:0,r:4},style:{fill:"#fff",stroke:wt,lineWidth:1},z:101}),this.endCircle=new D.graphic.Circle({shape:{cx:0,cy:0,r:4},style:{fill:"#fff",stroke:wt,lineWidth:1},z:101}),this.group.add(this.hRefLine),this.group.add(this.arc),this.group.add(this.line),this.group.add(this.angleText),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});const r=i-t,n=s-e,l=Math.max(Math.abs(r),40);this.hRefLine.setShape({x1:t,y1:e,x2:t+l,y2:e});const a=Math.atan2(-n,r)*(180/Math.PI),o=Math.min(25,Math.sqrt(r*r+n*n)*.3),d=Math.atan2(n,r),u=Math.min(0,d),c=Math.max(0,d);this.arc.setShape({cx:t,cy:e,r:o,startAngle:u,endAngle:c}),this.angleText.setStyle({text:`${a.toFixed(1)}\xB0`}),this.angleText.x=t+o+6,this.angleText.y=e+(n<0?-14:2),this.angleText.markRedraw()}}var ws=Object.defineProperty,Cs=(h,t,e)=>t in h?ws(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,Ps=(h,t,e)=>(Cs(h,typeof t!="symbol"?t+"":t,e),e);class xe{constructor(){Ps(this,"type","horizontal-line")}render(t){const{drawing:e,pixelPoints:i,isSelected:s,coordSys:r}=t,[n,l]=i[0],a=e.style?.color||"#d1d4dc",o=r.x,d=r.x+r.width;return{type:"group",children:[{type:"line",name:"line",shape:{x1:o,y1:l,x2:d,y2:l},style:{stroke:a,lineWidth:e.style?.lineWidth||1}},{type:"rect",shape:{x:d-70,y:l-10,width:65,height:18,r:2},style:{fill:a,opacity:.9},z2:10},{type:"text",x:d-67,y:l-8,style:{text:e.points[0].value.toFixed(2),fill:"#fff",fontSize:10,fontFamily:"monospace"},z2:11},{type:"circle",name:"point-0",shape:{cx:n,cy:l,r:4},style:{fill:"#fff",stroke:a,lineWidth:1,opacity:s?1:0}}]}}}var ks=Object.defineProperty,Is=(h,t,e)=>t in h?ks(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,me=(h,t,e)=>(Is(h,typeof t!="symbol"?t+"":t,e),e);class Ds extends X{constructor(t={}){super({id:"horizontal-line-tool",name:t?.name||"Horizontal Line",icon:t?.icon||'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="2" y1="12" x2="22" y2="12"/><circle cx="12" cy="12" r="2" fill="currentColor"/></svg>'}),me(this,"zr"),me(this,"onClick",e=>{const i=this.getPoint(e);if(!i)return;const s=this.context.coordinateConversion.pixelToData({x:i[0],y:i[1]});s&&this.context.addDrawing({id:`hline-${Date.now()}`,type:"horizontal-line",points:[s],paneIndex:s.paneIndex||0,style:{color:"#d1d4dc",lineWidth:1}}),this.context.disableTools()})}onInit(){this.zr=this.chart.getZr(),this.context.registerDrawingRenderer(new xe)}onActivate(){this.chart.getZr().setCursorStyle("crosshair"),this.zr.on("click",this.onClick)}onDeactivate(){this.chart.getZr().setCursorStyle("default"),this.zr.off("click",this.onClick)}onDestroy(){}}var Ms=Object.defineProperty,Ss=(h,t,e)=>t in h?Ms(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,As=(h,t,e)=>(Ss(h,typeof t!="symbol"?t+"":t,e),e);class be{constructor(){As(this,"type","horizontal-ray")}render(t){const{drawing:e,pixelPoints:i,isSelected:s,coordSys:r}=t,[n,l]=i[0],a=e.style?.color||"#d1d4dc",o=r.x+r.width;return{type:"group",children:[{type:"line",name:"line",shape:{x1:n,y1:l,x2:o,y2:l},style:{stroke:a,lineWidth:e.style?.lineWidth||1}},{type:"circle",name:"point-0",shape:{cx:n,cy:l,r:4},style:{fill:"#fff",stroke:a,lineWidth:1,opacity:s?1:0}}]}}}var _s=Object.defineProperty,$s=(h,t,e)=>t in h?_s(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,ve=(h,t,e)=>($s(h,typeof t!="symbol"?t+"":t,e),e);class Gs extends X{constructor(t={}){super({id:"horizontal-ray-tool",name:t?.name||"Horizontal Ray",icon:t?.icon||'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="4" y1="12" x2="22" y2="12"/><circle cx="4" cy="12" r="2" fill="currentColor"/></svg>'}),ve(this,"zr"),ve(this,"onClick",e=>{const i=this.getPoint(e);if(!i)return;const s=this.context.coordinateConversion.pixelToData({x:i[0],y:i[1]});s&&this.context.addDrawing({id:`hray-${Date.now()}`,type:"horizontal-ray",points:[s],paneIndex:s.paneIndex||0,style:{color:"#d1d4dc",lineWidth:1}}),this.context.disableTools()})}onInit(){this.zr=this.chart.getZr(),this.context.registerDrawingRenderer(new be)}onActivate(){this.chart.getZr().setCursorStyle("crosshair"),this.zr.on("click",this.onClick)}onDeactivate(){this.chart.getZr().setCursorStyle("default"),this.zr.off("click",this.onClick)}onDestroy(){}}var zs=Object.defineProperty,Es=(h,t,e)=>t in h?zs(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,Ls=(h,t,e)=>(Es(h,typeof t!="symbol"?t+"":t,e),e);class we{constructor(){Ls(this,"type","vertical-line")}render(t){const{drawing:e,pixelPoints:i,isSelected:s,coordSys:r}=t,[n,l]=i[0],a=e.style?.color||"#d1d4dc",o=r.y,d=r.y+r.height;return{type:"group",children:[{type:"line",name:"line",shape:{x1:n,y1:o,x2:n,y2:d},style:{stroke:a,lineWidth:e.style?.lineWidth||1}},{type:"circle",name:"point-0",shape:{cx:n,cy:l,r:4},style:{fill:"#fff",stroke:a,lineWidth:1,opacity:s?1:0}}]}}}var Ws=Object.defineProperty,Ts=(h,t,e)=>t in h?Ws(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,Ce=(h,t,e)=>(Ts(h,typeof t!="symbol"?t+"":t,e),e);class Zs extends X{constructor(t={}){super({id:"vertical-line-tool",name:t?.name||"Vertical Line",icon:t?.icon||'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="12" y1="2" x2="12" y2="22"/><circle cx="12" cy="12" r="2" fill="currentColor"/></svg>'}),Ce(this,"zr"),Ce(this,"onClick",e=>{const i=this.getPoint(e);if(!i)return;const s=this.context.coordinateConversion.pixelToData({x:i[0],y:i[1]});s&&this.context.addDrawing({id:`vline-${Date.now()}`,type:"vertical-line",points:[s],paneIndex:s.paneIndex||0,style:{color:"#d1d4dc",lineWidth:1}}),this.context.disableTools()})}onInit(){this.zr=this.chart.getZr(),this.context.registerDrawingRenderer(new we)}onActivate(){this.chart.getZr().setCursorStyle("crosshair"),this.zr.on("click",this.onClick)}onDeactivate(){this.chart.getZr().setCursorStyle("default"),this.zr.off("click",this.onClick)}onDestroy(){}}var Ns=Object.defineProperty,Fs=(h,t,e)=>t in h?Ns(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,Os=(h,t,e)=>(Fs(h,typeof t!="symbol"?t+"":t,e),e);class Pe{constructor(){Os(this,"type","cross-line")}render(t){const{drawing:e,pixelPoints:i,isSelected:s,coordSys:r}=t,[n,l]=i[0],a=e.style?.color||"#d1d4dc",o=r.x,d=r.x+r.width,u=r.y,c=r.y+r.height;return{type:"group",children:[{type:"line",name:"line-h",shape:{x1:o,y1:l,x2:d,y2:l},style:{stroke:a,lineWidth:e.style?.lineWidth||1}},{type:"line",name:"line-v",shape:{x1:n,y1:u,x2:n,y2:c},style:{stroke:a,lineWidth:e.style?.lineWidth||1}},{type:"circle",name:"point-0",shape:{cx:n,cy:l,r:4},style:{fill:"#fff",stroke:a,lineWidth:1,opacity:s?1:0}}]}}}var Hs=Object.defineProperty,Rs=(h,t,e)=>t in h?Hs(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,ke=(h,t,e)=>(Rs(h,typeof t!="symbol"?t+"":t,e),e);class Bs extends X{constructor(t={}){super({id:"cross-line-tool",name:t?.name||"Cross Line",icon:t?.icon||'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="12" y1="2" x2="12" y2="22"/><line x1="2" y1="12" x2="22" y2="12"/></svg>'}),ke(this,"zr"),ke(this,"onClick",e=>{const i=this.getPoint(e);if(!i)return;const s=this.context.coordinateConversion.pixelToData({x:i[0],y:i[1]});s&&this.context.addDrawing({id:`crossline-${Date.now()}`,type:"cross-line",points:[s],paneIndex:s.paneIndex||0,style:{color:"#d1d4dc",lineWidth:1}}),this.context.disableTools()})}onInit(){this.zr=this.chart.getZr(),this.context.registerDrawingRenderer(new Pe)}onActivate(){this.chart.getZr().setCursorStyle("crosshair"),this.zr.on("click",this.onClick)}onDeactivate(){this.chart.getZr().setCursorStyle("default"),this.zr.off("click",this.onClick)}onDestroy(){}}var js=Object.defineProperty,Ys=(h,t,e)=>t in h?js(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,Vs=(h,t,e)=>(Ys(h,typeof t!="symbol"?t+"":t,e),e);const te=[0,.236,.382,.5,.618,.786,1],Bt=["#787b86","#f44336","#ff9800","#4caf50","#2196f3","#00bcd4","#787b86"];class Ie{constructor(){Vs(this,"type","fibonacci")}render(t){const{drawing:e,pixelPoints:i,isSelected:s}=t,[r,n]=i[0],[l,a]=i[1],o=e.style?.color||"#3b82f6",d=Math.min(r,l),u=Math.max(r,l),c=u-d,g=a-n,p=e.points[0].value,y=e.points[1].value,f=y-p,x=[],m=[];return te.forEach((S,v)=>{const I=a-g*S,b=Bt[v%Bt.length];m.push({type:"line",shape:{x1:d,y1:I,x2:u,y2:I},style:{stroke:b,lineWidth:1},silent:!0});const C=y-f*S;if(m.push({type:"text",style:{text:`${S} (${C.toFixed(2)})`,x:d+5,y:I-10,fill:b,fontSize:10},silent:!0}),v<te.length-1){const w=te[v+1],k=a-g*w,A=Math.abs(k-I),$=Math.min(I,k);x.push({type:"rect",name:"line",shape:{x:d,y:$,width:c,height:A},style:{fill:Bt[(v+1)%Bt.length],opacity:.1}})}}),{type:"group",children:[...x,...m,{type:"line",name:"line",shape:{x1:r,y1:n,x2:l,y2:a},style:{stroke:"#999",lineWidth:1,lineDash:[4,4]}},{type:"circle",name:"point-0",shape:{cx:r,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:a,r:4},style:{fill:"#fff",stroke:o,lineWidth:1,opacity:s?1:0},z:100}]}}}var Xs=Object.defineProperty,qs=(h,t,e)=>t in h?Xs(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,xt=(h,t,e)=>(qs(h,typeof t!="symbol"?t+"":t,e),e);class Us extends X{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>'}),xt(this,"startPoint",null),xt(this,"endPoint",null),xt(this,"state","idle"),xt(this,"graphicGroup",null),xt(this,"levels",[0,.236,.382,.5,.618,.786,1]),xt(this,"colors",["#787b86","#f44336","#ff9800","#4caf50","#2196f3","#00bcd4","#787b86"]),xt(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())}),xt(this,"onMouseMove",e=>{this.state==="drawing"&&(this.endPoint=this.getPoint(e),this.updateGraphic())})}onInit(){this.context.registerDrawingRenderer(new Ie)}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 D.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],r=new D.graphic.Line({shape:{x1:t,y1:e,x2:i,y2:s},style:{stroke:"#999",lineWidth:1,lineDash:[4,4]},silent:!0});this.graphicGroup.add(r);const n=Math.min(t,i),l=Math.max(t,i),a=l-n,o=s-e;this.levels.forEach((d,u)=>{const c=s-o*d,g=this.colors[u%this.colors.length],p=new D.graphic.Line({shape:{x1:n,y1:c,x2:l,y2:c},style:{stroke:g,lineWidth:1},silent:!0});if(this.graphicGroup.add(p),u<this.levels.length-1){const y=this.levels[u+1],f=s-o*y,x=Math.abs(f-c),m=Math.min(c,f),S=new D.graphic.Rect({shape:{x:n,y:m,width:a,height:x},style:{fill:this.colors[(u+1)%this.colors.length],opacity:.1},silent:!0});this.graphicGroup.add(S)}})}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 Ks=Object.defineProperty,Js=(h,t,e)=>t in h?Ks(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,Qs=(h,t,e)=>(Js(h,typeof t!="symbol"?t+"":t,e),e);const jt=[0,.236,.382,.5,.618,.786,1],Yt=["#787b86","#f44336","#ff9800","#4caf50","#2196f3","#00bcd4","#787b86"];class De{constructor(){Qs(this,"type","fibonacci_channel")}render(t){const{drawing:e,pixelPoints:i,isSelected:s}=t,[r,n]=i[0],[l,a]=i[1],[o,d]=i[2],u=e.style?.color||"#3b82f6",c=l-r,g=a-n,p=Math.sqrt(c*c+g*g);if(p===0)return;const y=-g/p,f=c/p,x=(o-r)*y+(d-n)*f,m=[],S=[];return jt.forEach((v,I)=>{const b=y*x*v,C=f*x*v,w=r+b,k=n+C,A=l+b,$=a+C;if(S.push({lx1:w,ly1:k,lx2:A,ly2:$}),I<jt.length-1){const _=jt[I+1],E=y*x*_,L=f*x*_;m.push({type:"polygon",name:"line",shape:{points:[[w,k],[A,$],[l+E,a+L],[r+E,n+L]]},style:{fill:Yt[(I+1)%Yt.length],opacity:.1}})}}),S.forEach((v,I)=>{const b=Yt[I%Yt.length];m.push({type:"line",shape:{x1:v.lx1,y1:v.ly1,x2:v.lx2,y2:v.ly2},style:{stroke:b,lineWidth:1},silent:!0}),m.push({type:"text",style:{text:`${jt[I]}`,x:v.lx2+5,y:v.ly2-5,fill:b,fontSize:10},silent:!0})}),m.push({type:"line",name:"line",shape:{x1:r,y1:n,x2:l,y2:a},style:{stroke:"#999",lineWidth:1,lineDash:[4,4]}}),m.push({type:"circle",name:"point-0",shape:{cx:r,cy:n,r:4},style:{fill:"#fff",stroke:u,lineWidth:1,opacity:s?1:0},z:100}),m.push({type:"circle",name:"point-1",shape:{cx:l,cy:a,r:4},style:{fill:"#fff",stroke:u,lineWidth:1,opacity:s?1:0},z:100}),m.push({type:"circle",name:"point-2",shape:{cx:o,cy:d,r:4},style:{fill:"#fff",stroke:u,lineWidth:1,opacity:s?1:0},z:100}),{type:"group",children:m}}}var tn=Object.defineProperty,en=(h,t,e)=>t in h?tn(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,ft=(h,t,e)=>(en(h,typeof t!="symbol"?t+"":t,e),e);class sn extends X{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>'}),ft(this,"startPoint",null),ft(this,"endPoint",null),ft(this,"widthPoint",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-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())}),ft(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 De)}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 D.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 D.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 r=this.widthPoint,n=i-t,l=s-e,a=Math.sqrt(n*n+l*l);if(a===0)return;const o=-l/a,d=n/a,u=(r[0]-t)*o+(r[1]-e)*d;this.levels.forEach((c,g)=>{const p=o*u*c,y=d*u*c,f=t+p,x=e+y,m=i+p,S=s+y,v=this.colors[g%this.colors.length];if(this.graphicGroup.add(new D.graphic.Line({shape:{x1:f,y1:x,x2:m,y2:S},style:{stroke:v,lineWidth:1},silent:!0})),g<this.levels.length-1){const I=this.levels[g+1],b=o*u*I,C=d*u*I,w=t+b,k=e+C,A=i+b,$=s+C;this.graphicGroup.add(new D.graphic.Polygon({shape:{points:[[f,x],[m,S],[A,$],[w,k]]},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 nn=Object.defineProperty,on=(h,t,e)=>t in h?nn(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,rn=(h,t,e)=>(on(h,typeof t!="symbol"?t+"":t,e),e);const ee=[0,.236,.382,.5,.618,.786,1],mt=["#787b86","#f44336","#ff9800","#4caf50","#2196f3","#00bcd4","#787b86"];class Me{constructor(){rn(this,"type","fib_speed_resistance_fan")}render(t){const{drawing:e,pixelPoints:i,isSelected:s}=t,[r,n]=i[0],[l,a]=i[1],o=e.style?.color||"#3b82f6",d=l-r,u=a-n,c=[],g=[],p=[];for(const y of ee)g.push([r+d,n+u*y]),p.push([r+d*y,n+u]);for(let y=0;y<g.length-1;y++)c.push({type:"polygon",name:"line",shape:{points:[[r,n],g[y],g[y+1]]},style:{fill:mt[(y+1)%mt.length],opacity:.06}});for(let y=0;y<p.length-1;y++)c.push({type:"polygon",name:"line",shape:{points:[[r,n],p[y],p[y+1]]},style:{fill:mt[(y+1)%mt.length],opacity:.06}});return ee.forEach((y,f)=>{const[x,m]=g[f],S=mt[f%mt.length];c.push({type:"line",shape:{x1:r,y1:n,x2:x,y2:m},style:{stroke:S,lineWidth:1},silent:!0}),c.push({type:"text",style:{text:`${y}`,x:x+3,y:m-2,fill:S,fontSize:9},silent:!0})}),ee.forEach((y,f)=>{const[x,m]=p[f],S=mt[f%mt.length];c.push({type:"line",shape:{x1:r,y1:n,x2:x,y2:m},style:{stroke:S,lineWidth:1},silent:!0}),c.push({type:"text",style:{text:`${y}`,x:x-2,y:m+8,fill:S,fontSize:9},silent:!0})}),c.push({type:"line",name:"line",shape:{x1:l,y1:n,x2:l,y2:a},style:{stroke:"#555",lineWidth:1,lineDash:[3,3]}}),c.push({type:"line",name:"line",shape:{x1:r,y1:a,x2:l,y2:a},style:{stroke:"#555",lineWidth:1,lineDash:[3,3]}}),c.push({type:"line",name:"line",shape:{x1:r,y1:n,x2:l,y2:a},style:{stroke:"#999",lineWidth:1,lineDash:[4,4]}}),c.push({type:"circle",name:"point-0",shape:{cx:r,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:a,r:4},style:{fill:"#fff",stroke:o,lineWidth:1,opacity:s?1:0},z:100}),{type:"group",children:c}}}var an=Object.defineProperty,ln=(h,t,e)=>t in h?an(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,At=(h,t,e)=>(ln(h,typeof t!="symbol"?t+"":t,e),e);const Ct=[0,.236,.382,.5,.618,.786,1],_t=["#787b86","#f44336","#ff9800","#4caf50","#2196f3","#00bcd4","#787b86"];class hn extends X{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>'}),At(this,"startPoint",null),At(this,"endPoint",null),At(this,"state","idle"),At(this,"graphicGroup",null),At(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())}),At(this,"onMouseMove",e=>{this.state==="drawing"&&(this.endPoint=this.getPoint(e),this.updateGraphic())})}onInit(){this.context.registerDrawingRenderer(new Me)}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 D.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],r=i-t,n=s-e;Ct.forEach((l,a)=>{const o=_t[a%_t.length];this.graphicGroup.add(new D.graphic.Line({shape:{x1:t,y1:e,x2:t+r,y2:e+n*l},style:{stroke:o,lineWidth:1},silent:!0})),this.graphicGroup.add(new D.graphic.Line({shape:{x1:t,y1:e,x2:t+r*l,y2:e+n},style:{stroke:o,lineWidth:1},silent:!0}))});for(let l=0;l<Ct.length-1;l++){const a=[t+r,e+n*Ct[l]],o=[t+r,e+n*Ct[l+1]];this.graphicGroup.add(new D.graphic.Polygon({shape:{points:[[t,e],a,o]},style:{fill:_t[(l+1)%_t.length],opacity:.06},silent:!0}))}for(let l=0;l<Ct.length-1;l++){const a=[t+r*Ct[l],e+n],o=[t+r*Ct[l+1],e+n];this.graphicGroup.add(new D.graphic.Polygon({shape:{points:[[t,e],a,o]},style:{fill:_t[(l+1)%_t.length],opacity:.06},silent:!0}))}this.graphicGroup.add(new D.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 D.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 D.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 cn=Object.defineProperty,dn=(h,t,e)=>t in h?cn(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,pn=(h,t,e)=>(dn(h,typeof t!="symbol"?t+"":t,e),e);const Se=[0,.236,.382,.5,.618,.786,1,1.272,1.618,2,2.618],Ae=["#787b86","#f44336","#ff9800","#4caf50","#2196f3","#00bcd4","#787b86","#e91e63","#9c27b0","#673ab7","#3f51b5"];class _e{constructor(){pn(this,"type","fib_trend_extension")}render(t){const{drawing:e,pixelPoints:i,isSelected:s,api:r}=t,n=e.style?.color||"#3b82f6";if(i.length<3)return;const[l,a]=i[0],[o,d]=i[1],[u,c]=i[2],g=e.points,p=g[1].value-g[0].value,y=Math.min(l,o,u),f=Math.max(l,o,u),x=(f-y)*.5,m=y,S=f+x,v=[],I=[];for(let w=0;w<Se.length;w++){const k=Se[w],A=g[2].value+p*k;r.coord([g[2].timeIndex+t.drawing.points[2].timeIndex-g[2].timeIndex,A]);const $=c+(d-a)*k;I.push({level:k,y:$,price:A,color:Ae[w%Ae.length]})}for(let w=0;w<I.length-1;w++){const k=I[w],A=I[w+1],$=Math.min(k.y,A.y),_=Math.abs(A.y-k.y);v.push({type:"rect",name:"line",shape:{x:m,y:$,width:S-m,height:_},style:{fill:A.color,opacity:.06}})}for(const w of I)v.push({type:"line",shape:{x1:m,y1:w.y,x2:S,y2:w.y},style:{stroke:w.color,lineWidth:1},silent:!0}),v.push({type:"text",style:{text:`${w.level} (${w.price.toFixed(2)})`,x:S+4,y:w.y-6,fill:w.color,fontSize:9},silent:!0});v.push({type:"line",name:"line",shape:{x1:l,y1:a,x2:o,y2:d},style:{stroke:"#2196f3",lineWidth:1.5,lineDash:[5,4]}}),v.push({type:"line",name:"line",shape:{x1:o,y1:d,x2:u,y2:c},style:{stroke:"#ff9800",lineWidth:1.5,lineDash:[5,4]}}),v.push({type:"circle",name:"point-0",shape:{cx:l,cy:a,r:4},style:{fill:"#fff",stroke:n,lineWidth:1,opacity:s?1:0},z:100}),v.push({type:"circle",name:"point-1",shape:{cx:o,cy:d,r:4},style:{fill:"#fff",stroke:n,lineWidth:1,opacity:s?1:0},z:100}),v.push({type:"circle",name:"point-2",shape:{cx:u,cy:c,r:4},style:{fill:"#fff",stroke:n,lineWidth:1,opacity:s?1:0},z:100});const b=["1","2","3"],C=[i[0],i[1],i[2]];for(let w=0;w<3;w++){const[k,A]=C[w],$=(w===0||A<=C[w-1][1])&&(w===2||A<=C[w+1]?.[1]);v.push({type:"text",style:{text:b[w],x:k,y:$?A-14:A+16,fill:"#e2e8f0",fontSize:12,fontWeight:"bold",align:"center",verticalAlign:"middle"},silent:!0})}return{type:"group",children:v}}}var un=Object.defineProperty,gn=(h,t,e)=>t in h?un(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,Lt=(h,t,e)=>(gn(h,typeof t!="symbol"?t+"":t,e),e);const Vt=[0,.236,.382,.5,.618,.786,1,1.272,1.618,2,2.618],Xt=["#787b86","#f44336","#ff9800","#4caf50","#2196f3","#00bcd4","#787b86","#e91e63","#9c27b0","#673ab7","#3f51b5"];class yn extends X{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>'}),Lt(this,"points",[]),Lt(this,"state","idle"),Lt(this,"graphicGroup",null),Lt(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())}),Lt(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 _e)}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 D.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 D.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[r,n]=this.points[2];this.graphicGroup.add(new D.graphic.Line({shape:{x1:i,y1:s,x2:r,y2:n},style:{stroke:"#ff9800",lineWidth:1.5,lineDash:[5,4]},silent:!0}));const l=s-e,a=Math.min(t,i,r),o=Math.max(t,i,r),d=(o-a)*.5,u=a,c=o+d;for(let g=0;g<Vt.length;g++){const p=Vt[g],y=n+l*p,f=Xt[g%Xt.length];if(this.graphicGroup.add(new D.graphic.Line({shape:{x1:u,y1:y,x2:c,y2:y},style:{stroke:f,lineWidth:1},silent:!0})),this.graphicGroup.add(new D.graphic.Text({style:{text:`${p}`,x:c+4,y:y-6,fill:f,fontSize:9},silent:!0})),g<Vt.length-1){const x=n+l*Vt[g+1],m=Math.min(y,x),S=Math.abs(x-y);this.graphicGroup.add(new D.graphic.Rect({shape:{x:u,y:m,width:c-u,height:S},style:{fill:Xt[(g+1)%Xt.length],opacity:.06},silent:!0}))}}}for(const r of this.points)this.graphicGroup.add(new D.graphic.Circle({shape:{cx:r[0],cy:r[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 fn=Object.defineProperty,xn=(h,t,e)=>t in h?fn(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,mn=(h,t,e)=>(xn(h,typeof t!="symbol"?t+"":t,e),e);const $e=["X","A","B","C","D"],Ge=["#2196f3","#ff9800","#4caf50","#f44336"],bn="rgba(33, 150, 243, 0.08)",vn="rgba(244, 67, 54, 0.08)";class ze{constructor(){mn(this,"type","xabcd_pattern")}render(t){const{drawing:e,pixelPoints:i,isSelected:s}=t,r=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(([a,o])=>[a,o])},style:{fill:bn,opacity:1}}),i.length>=5&&n.push({type:"polygon",name:"line",shape:{points:i.slice(2,5).map(([a,o])=>[a,o])},style:{fill:vn,opacity:1}});for(let a=0;a<i.length-1;a++){const[o,d]=i[a],[u,c]=i[a+1],g=Ge[a%Ge.length];n.push({type:"line",name:"line",shape:{x1:o,y1:d,x2:u,y2:c},style:{stroke:g,lineWidth:e.style?.lineWidth||2}})}const l=[[0,2],[1,3],[2,4]];for(const[a,o]of l)if(a<i.length&&o<i.length){const[d,u]=i[a],[c,g]=i[o];n.push({type:"line",shape:{x1:d,y1:u,x2:c,y2:g},style:{stroke:"#555",lineWidth:1,lineDash:[4,4]},silent:!0})}if(e.points.length>=3){const a=Math.abs(e.points[1].value-e.points[0].value),o=Math.abs(e.points[2].value-e.points[1].value);if(a!==0){const d=(o/a).toFixed(3),u=(i[1][0]+i[2][0])/2,c=(i[1][1]+i[2][1])/2;n.push({type:"text",style:{text:d,x:u+8,y:c,fill:"#ff9800",fontSize:10},silent:!0})}}if(e.points.length>=4){const a=Math.abs(e.points[2].value-e.points[1].value),o=Math.abs(e.points[3].value-e.points[2].value);if(a!==0){const d=(o/a).toFixed(3),u=(i[2][0]+i[3][0])/2,c=(i[2][1]+i[3][1])/2;n.push({type:"text",style:{text:d,x:u+8,y:c,fill:"#4caf50",fontSize:10},silent:!0})}}if(e.points.length>=5){const a=Math.abs(e.points[3].value-e.points[2].value),o=Math.abs(e.points[4].value-e.points[3].value);if(a!==0){const c=(o/a).toFixed(3),g=(i[3][0]+i[4][0])/2,p=(i[3][1]+i[4][1])/2;n.push({type:"text",style:{text:c,x:g+8,y:p,fill:"#f44336",fontSize:10},silent:!0})}const d=Math.abs(e.points[1].value-e.points[0].value),u=Math.abs(e.points[4].value-e.points[1].value);if(d!==0){const c=(u/d).toFixed(3),[g,p]=i[4];n.push({type:"text",style:{text:`AD/XA: ${c}`,x:g+10,y:p+14,fill:"#aaa",fontSize:9},silent:!0})}}for(let a=0;a<i.length&&a<$e.length;a++){const[o,d]=i[a],u=(a===0||d<=i[a-1][1])&&(a===i.length-1||d<=i[a+1]?.[1])?d-14:d+16;n.push({type:"text",style:{text:$e[a],x:o,y:u,fill:"#e2e8f0",fontSize:12,fontWeight:"bold",align:"center",verticalAlign:"middle"},silent:!0})}for(let a=0;a<i.length;a++){const[o,d]=i[a];n.push({type:"circle",name:`point-${a}`,shape:{cx:o,cy:d,r:4},style:{fill:"#fff",stroke:r,lineWidth:1,opacity:s?1:0},z:100})}return{type:"group",children:n}}}var wn=Object.defineProperty,Cn=(h,t,e)=>t in h?wn(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,Wt=(h,t,e)=>(Cn(h,typeof t!="symbol"?t+"":t,e),e);const Ee=["X","A","B","C","D"],Le=["#2196f3","#ff9800","#4caf50","#f44336"],Pn=5;class kn extends X{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>'}),Wt(this,"points",[]),Wt(this,"state","idle"),Wt(this,"graphicGroup",null),Wt(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>=Pn?(this.state="finished",this.updateGraphic(),this.saveDrawing(),this.removeGraphic(),this.context.disableTools()):(this.points.push([...i]),this.updateGraphic()))}),Wt(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 ze)}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 D.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 D.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 D.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,r]=t[i],[n,l]=t[i+1];this.graphicGroup.add(new D.graphic.Line({shape:{x1:s,y1:r,x2:n,y2:l},style:{stroke:Le[i%Le.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[r,n]=t[i],[l,a]=t[s];this.graphicGroup.add(new D.graphic.Line({shape:{x1:r,y1:n,x2:l,y2:a},style:{stroke:"#555",lineWidth:1,lineDash:[4,4]},silent:!0}))}for(let i=0;i<t.length&&i<Ee.length;i++){const[s,r]=t[i],n=(i===0||r<=t[i-1][1])&&(i===t.length-1||r<=t[i+1]?.[1])?r-14:r+16;this.graphicGroup.add(new D.graphic.Text({style:{text:Ee[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,r]=t[i];this.graphicGroup.add(new D.graphic.Circle({shape:{cx:s,cy:r,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 In=Object.defineProperty,Dn=(h,t,e)=>t in h?In(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,Mn=(h,t,e)=>(Dn(h,typeof t!="symbol"?t+"":t,e),e);const We=["A","B","C","D"],Te=["#2196f3","#ff9800","#4caf50"];class Ze{constructor(){Mn(this,"type","abcd_pattern")}render(t){const{drawing:e,pixelPoints:i,isSelected:s}=t,r=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,a])=>[l,a])},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,a])=>[l,a])},style:{fill:"rgba(244, 67, 54, 0.08)"}});for(let l=0;l<i.length-1;l++){const[a,o]=i[l],[d,u]=i[l+1];n.push({type:"line",name:"line",shape:{x1:a,y1:o,x2:d,y2:u},style:{stroke:Te[l%Te.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),a=Math.abs(e.points[2].value-e.points[1].value);if(l!==0){const o=(a/l).toFixed(3),d=(i[1][0]+i[2][0])/2,u=(i[1][1]+i[2][1])/2;n.push({type:"text",style:{text:o,x:d+8,y:u,fill:"#ff9800",fontSize:10},silent:!0})}}if(e.points.length>=4){const l=Math.abs(e.points[2].value-e.points[1].value),a=Math.abs(e.points[3].value-e.points[2].value);if(l!==0){const o=(a/l).toFixed(3),d=(i[2][0]+i[3][0])/2,u=(i[2][1]+i[3][1])/2;n.push({type:"text",style:{text:o,x:d+8,y:u,fill:"#4caf50",fontSize:10},silent:!0})}}for(let l=0;l<i.length&&l<We.length;l++){const[a,o]=i[l],d=(l===0||o<=i[l-1][1])&&(l===i.length-1||o<=i[l+1]?.[1]);n.push({type:"text",style:{text:We[l],x:a,y:d?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:r,lineWidth:1,opacity:s?1:0},z:100});return{type:"group",children:n}}}var Sn=Object.defineProperty,An=(h,t,e)=>t in h?Sn(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,Tt=(h,t,e)=>(An(h,typeof t!="symbol"?t+"":t,e),e);const Ne=["A","B","C","D"],Fe=["#2196f3","#ff9800","#4caf50"],_n=4;class $n extends X{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>'}),Tt(this,"points",[]),Tt(this,"state","idle"),Tt(this,"graphicGroup",null),Tt(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>=_n?(this.state="finished",this.updateGraphic(),this.saveDrawing(),this.removeGraphic(),this.context.disableTools()):(this.points.push([...i]),this.updateGraphic()))}),Tt(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 Ze)}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 D.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 D.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 D.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 D.graphic.Line({shape:{x1:t[e][0],y1:t[e][1],x2:t[e+1][0],y2:t[e+1][1]},style:{stroke:Fe[e%Fe.length],lineWidth:2},silent:!0}));t.length>=3&&this.graphicGroup.add(new D.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 D.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<Ne.length;e++){const[i,s]=t[e],r=(e===0||s<=t[e-1][1])&&(e===t.length-1||s<=t[e+1]?.[1]);this.graphicGroup.add(new D.graphic.Text({style:{text:Ne[e],x:i,y:r?s-14:s+16,fill:"#e2e8f0",fontSize:12,fontWeight:"bold",align:"center",verticalAlign:"middle"},silent:!0})),this.graphicGroup.add(new D.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 Gn=Object.defineProperty,zn=(h,t,e)=>t in h?Gn(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,En=(h,t,e)=>(zn(h,typeof t!="symbol"?t+"":t,e),e);const Oe=["X","A","B","C","D"],He=["#00bcd4","#e91e63","#8bc34a","#ff5722"];class Re{constructor(){En(this,"type","cypher_pattern")}render(t){const{drawing:e,pixelPoints:i,isSelected:s}=t,r=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,d])=>[o,d])},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,d])=>[o,d])},style:{fill:"rgba(233, 30, 99, 0.08)"}});for(let o=0;o<i.length-1;o++){const[d,u]=i[o],[c,g]=i[o+1];n.push({type:"line",name:"line",shape:{x1:d,y1:u,x2:c,y2:g},style:{stroke:He[o%He.length],lineWidth:e.style?.lineWidth||2}})}const l=[[0,2],[0,3],[1,4]];for(const[o,d]of l)o<i.length&&d<i.length&&n.push({type:"line",shape:{x1:i[o][0],y1:i[o][1],x2:i[d][0],y2:i[d][1]},style:{stroke:"#555",lineWidth:1,lineDash:[4,4]},silent:!0});const a=e.points;if(a.length>=3){const o=Math.abs(a[1].value-a[0].value),d=Math.abs(a[2].value-a[1].value);if(o!==0){const u=(d/o).toFixed(3);n.push({type:"text",style:{text:u,x:(i[1][0]+i[2][0])/2+8,y:(i[1][1]+i[2][1])/2,fill:"#e91e63",fontSize:10},silent:!0})}}if(a.length>=4){const o=Math.abs(a[1].value-a[0].value),d=Math.abs(a[3].value-a[0].value);if(o!==0){const u=(d/o).toFixed(3);n.push({type:"text",style:{text:`XC/XA: ${u}`,x:(i[0][0]+i[3][0])/2+8,y:(i[0][1]+i[3][1])/2,fill:"#8bc34a",fontSize:10},silent:!0})}}if(a.length>=5){const o=Math.abs(a[3].value-a[0].value),d=Math.abs(a[4].value-a[3].value);if(o!==0){const u=(d/o).toFixed(3);n.push({type:"text",style:{text:u,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<Oe.length;o++){const[d,u]=i[o],c=(o===0||u<=i[o-1][1])&&(o===i.length-1||u<=i[o+1]?.[1]);n.push({type:"text",style:{text:Oe[o],x:d,y:c?u-14:u+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:r,lineWidth:1,opacity:s?1:0},z:100});return{type:"group",children:n}}}var Ln=Object.defineProperty,Wn=(h,t,e)=>t in h?Ln(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,Zt=(h,t,e)=>(Wn(h,typeof t!="symbol"?t+"":t,e),e);const Be=["X","A","B","C","D"],je=["#00bcd4","#e91e63","#8bc34a","#ff5722"],Tn=5;class Zn extends X{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>'}),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>=Tn?(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 Re)}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 D.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 D.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 D.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 D.graphic.Line({shape:{x1:t[e][0],y1:t[e][1],x2:t[e+1][0],y2:t[e+1][1]},style:{stroke:je[e%je.length],lineWidth:2},silent:!0}));for(let e=0;e<t.length&&e<Be.length;e++){const[i,s]=t[e],r=(e===0||s<=t[e-1][1])&&(e===t.length-1||s<=t[e+1]?.[1]);this.graphicGroup.add(new D.graphic.Text({style:{text:Be[e],x:i,y:r?s-14:s+16,fill:"#e2e8f0",fontSize:12,fontWeight:"bold",align:"center",verticalAlign:"middle"},silent:!0})),this.graphicGroup.add(new D.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 Nn=Object.defineProperty,Fn=(h,t,e)=>t in h?Nn(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,On=(h,t,e)=>(Fn(h,typeof t!="symbol"?t+"":t,e),e);const ie=["","LS","","H","","RS",""];class Ye{constructor(){On(this,"type","head_and_shoulders")}render(t){const{drawing:e,pixelPoints:i,isSelected:s}=t,r=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,a])=>[l,a])},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,a])=>[l,a])},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,a])=>[l,a])},style:{fill:"rgba(33, 150, 243, 0.06)"}});for(let l=0;l<i.length-1;l++){const[a,o]=i[l],[d,u]=i[l+1];n.push({type:"line",name:"line",shape:{x1:a,y1:o,x2:d,y2:u},style:{stroke:"#2196f3",lineWidth:e.style?.lineWidth||2}})}if(i.length>=5){const[l,a]=i[2],[o,d]=i[4],u=o-l,c=d-a,g=.3,p=.3,y=l-u*g,f=a-c*g,x=o+u*p,m=d+c*p;n.push({type:"line",shape:{x1:y,y1:f,x2:x,y2:m},style:{stroke:"#ff9800",lineWidth:2,lineDash:[6,4]},silent:!0}),n.push({type:"text",style:{text:"Neckline",x:(l+o)/2,y:(a+d)/2+14,fill:"#ff9800",fontSize:10,align:"center"},silent:!0})}for(let l=0;l<i.length&&l<ie.length;l++){if(!ie[l])continue;const[a,o]=i[l],d=(l===0||o<=i[l-1][1])&&(l===i.length-1||o<=i[l+1]?.[1]);n.push({type:"text",style:{text:ie[l],x:a,y:d?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:r,lineWidth:1,opacity:s?1:0},z:100});return{type:"group",children:n}}}var Hn=Object.defineProperty,Rn=(h,t,e)=>t in h?Hn(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,Nt=(h,t,e)=>(Rn(h,typeof t!="symbol"?t+"":t,e),e);const se=["","LS","","H","","RS",""],Bn=7;class jn extends X{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>'}),Nt(this,"points",[]),Nt(this,"state","idle"),Nt(this,"graphicGroup",null),Nt(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>=Bn?(this.state="finished",this.updateGraphic(),this.saveDrawing(),this.removeGraphic(),this.context.disableTools()):(this.points.push([...i]),this.updateGraphic()))}),Nt(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");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 D.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 D.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 D.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 D.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 D.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,r]=t[4],n=s-e,l=r-i;this.graphicGroup.add(new D.graphic.Line({shape:{x1:e-n*.3,y1:i-l*.3,x2:s+n*.3,y2:r+l*.3},style:{stroke:"#ff9800",lineWidth:2,lineDash:[6,4]},silent:!0}))}for(let e=0;e<t.length&&e<se.length;e++){const[i,s]=t[e],r=(e===0||s<=t[e-1][1])&&(e===t.length-1||s<=t[e+1]?.[1]);se[e]&&this.graphicGroup.add(new D.graphic.Text({style:{text:se[e],x:i,y:r?s-14:s+16,fill:"#e2e8f0",fontSize:12,fontWeight:"bold",align:"center",verticalAlign:"middle"},silent:!0})),this.graphicGroup.add(new D.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 Yn=Object.defineProperty,Vn=(h,t,e)=>t in h?Yn(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,Xn=(h,t,e)=>(Vn(h,typeof t!="symbol"?t+"":t,e),e);const Ve=["1","2","3","4","5"];class Xe{constructor(){Xn(this,"type","triangle_pattern")}render(t){const{drawing:e,pixelPoints:i,isSelected:s}=t,r=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,d])=>[o,d])},style:{fill:"rgba(156, 39, 176, 0.06)"}});const l=i.filter((o,d)=>d%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],d=l[l.length-2],u=o[0]-d[0],c=o[1]-d[1];if(u!==0){const g=o[0]+u*.5,p=o[1]+c*.5;n.push({type:"line",shape:{x1:o[0],y1:o[1],x2:g,y2:p},style:{stroke:"#f44336",lineWidth:1,lineDash:[4,4]},silent:!0})}}}const a=i.filter((o,d)=>d%2===1);if(a.length>=2){for(let o=0;o<a.length-1;o++)n.push({type:"line",name:"line",shape:{x1:a[o][0],y1:a[o][1],x2:a[o+1][0],y2:a[o+1][1]},style:{stroke:"#4caf50",lineWidth:2}});if(a.length>=2){const o=a[a.length-1],d=a[a.length-2],u=o[0]-d[0],c=o[1]-d[1];if(u!==0){const g=o[0]+u*.5,p=o[1]+c*.5;n.push({type:"line",shape:{x1:o[0],y1:o[1],x2:g,y2:p},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<Ve.length;o++){const[d,u]=i[o],c=o%2===0;n.push({type:"text",style:{text:Ve[o],x:d,y:c?u-14:u+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:r,lineWidth:1,opacity:s?1:0},z:100});return{type:"group",children:n}}}var qn=Object.defineProperty,Un=(h,t,e)=>t in h?qn(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,Ft=(h,t,e)=>(Un(h,typeof t!="symbol"?t+"":t,e),e);const qe=["1","2","3","4","5"],Kn=5;class Jn extends X{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>'}),Ft(this,"points",[]),Ft(this,"state","idle"),Ft(this,"graphicGroup",null),Ft(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>=Kn?(this.state="finished",this.updateGraphic(),this.saveDrawing(),this.removeGraphic(),this.context.disableTools()):(this.points.push([...i]),this.updateGraphic()))}),Ft(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 Xe)}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 D.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 D.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 D.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,r)=>r%2===0);if(e.length>=2)for(let s=0;s<e.length-1;s++)this.graphicGroup.add(new D.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,r)=>r%2===1);if(i.length>=2)for(let s=0;s<i.length-1;s++)this.graphicGroup.add(new D.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<qe.length;s++){const[r,n]=t[s],l=s%2===0;this.graphicGroup.add(new D.graphic.Text({style:{text:qe[s],x:r,y:l?n-14:n+16,fill:"#e2e8f0",fontSize:12,fontWeight:"bold",align:"center",verticalAlign:"middle"},silent:!0})),this.graphicGroup.add(new D.graphic.Circle({shape:{cx:r,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 Qn=Object.defineProperty,to=(h,t,e)=>t in h?Qn(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,eo=(h,t,e)=>(to(h,typeof t!="symbol"?t+"":t,e),e);const ne=["0","D1","C1","D2","C2","D3",""],Ue=["#2196f3","#ff9800","#4caf50","#f44336","#00bcd4","#e91e63"];class Ke{constructor(){eo(this,"type","three_drives_pattern")}render(t){const{drawing:e,pixelPoints:i,isSelected:s}=t,r=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,d])=>[o,d])},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,d])=>[o,d])},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,d])=>[o,d])},style:{fill:"rgba(0, 188, 212, 0.06)"}});for(let o=0;o<i.length-1;o++){const[d,u]=i[o],[c,g]=i[o+1];n.push({type:"line",name:"line",shape:{x1:d,y1:u,x2:c,y2:g},style:{stroke:Ue[o%Ue.length],lineWidth:e.style?.lineWidth||2}})}const l=[[1,3],[3,5],[2,4]];for(const[o,d]of l)o<i.length&&d<i.length&&n.push({type:"line",shape:{x1:i[o][0],y1:i[o][1],x2:i[d][0],y2:i[d][1]},style:{stroke:"#555",lineWidth:1,lineDash:[4,4]},silent:!0});const a=e.points;if(a.length>=4){const o=Math.abs(a[1].value-a[0].value),d=Math.abs(a[3].value-a[2].value);if(o!==0){const u=(d/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: ${u}`,x:c+10,y:g,fill:"#4caf50",fontSize:9},silent:!0})}}if(a.length>=6){const o=Math.abs(a[3].value-a[2].value),d=Math.abs(a[5].value-a[4].value);if(o!==0){const u=(d/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: ${u}`,x:c+10,y:g,fill:"#00bcd4",fontSize:9},silent:!0})}}if(a.length>=3){const o=Math.abs(a[1].value-a[0].value),d=Math.abs(a[2].value-a[1].value);if(o!==0){const u=(d/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:u,x:c+8,y:g,fill:"#ff9800",fontSize:10},silent:!0})}}for(let o=0;o<i.length&&o<ne.length;o++){if(!ne[o])continue;const[d,u]=i[o],c=(o===0||u<=i[o-1][1])&&(o===i.length-1||u<=i[o+1]?.[1]);n.push({type:"text",style:{text:ne[o],x:d,y:c?u-14:u+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:r,lineWidth:1,opacity:s?1:0},z:100});return{type:"group",children:n}}}var io=Object.defineProperty,so=(h,t,e)=>t in h?io(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,Ot=(h,t,e)=>(so(h,typeof t!="symbol"?t+"":t,e),e);const oe=["0","D1","C1","D2","C2","D3",""],Je=["#2196f3","#ff9800","#4caf50","#f44336","#00bcd4","#e91e63"],no=7;class oo extends X{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>'}),Ot(this,"points",[]),Ot(this,"state","idle"),Ot(this,"graphicGroup",null),Ot(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>=no?(this.state="finished",this.updateGraphic(),this.saveDrawing(),this.removeGraphic(),this.context.disableTools()):(this.points.push([...i]),this.updateGraphic()))}),Ot(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 Ke)}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 D.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 D.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 D.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 D.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 D.graphic.Line({shape:{x1:t[i][0],y1:t[i][1],x2:t[i+1][0],y2:t[i+1][1]},style:{stroke:Je[i%Je.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 D.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<oe.length;i++){const[s,r]=t[i],n=(i===0||r<=t[i-1][1])&&(i===t.length-1||r<=t[i+1]?.[1]);oe[i]&&this.graphicGroup.add(new D.graphic.Text({style:{text:oe[i],x:s,y:n?r-14:r+16,fill:"#e2e8f0",fontSize:11,fontWeight:"bold",align:"center",verticalAlign:"middle"},silent:!0})),this.graphicGroup.add(new D.graphic.Circle({shape:{cx:s,cy:r,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 ro=Object.defineProperty,ao=(h,t,e)=>t in h?ro(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,Pt=(h,t,e)=>(ao(h,typeof t!="symbol"?t+"":t,e),e);class lo extends X{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
41
  <div style="width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;">
42
42
  ${t.icon}
43
43
  </div>
@@ -45,7 +45,7 @@ ${u}`;this.chart.setOption({series:[{id:"__candlestick__",markLine:{data:[{...h,
45
45
  </div>`:i=`<div style="position: relative; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;">
46
46
  <span>${t.name.substring(0,2).toUpperCase()}</span>
47
47
  ${e}
48
- </div>`,super({id:t.id||`group-${t.name.toLowerCase().replace(/\s+/g,"-")}`,name:t.name,icon:i}),mt(this,"plugins",[]),mt(this,"activeSubPlugin",null),mt(this,"menuElement",null),mt(this,"buttonElement",null),mt(this,"originalIcon",""),mt(this,"arrowSvg",""),mt(this,"handleOutsideClick",s=>{this.menuElement&&!this.menuElement.contains(s.target)&&(this.hideMenu(),this.activeSubPlugin||this.buttonElement?.click())}),this.originalIcon=i,this.arrowSvg=e}add(t){this.plugins.push(t)}onInit(){this.plugins.forEach(t=>t.init(this.context))}onActivate(){this.showMenu()}onDeactivate(){this.hideMenu(),this.activeSubPlugin&&(this.activeSubPlugin.deactivate?.(),this.activeSubPlugin=null),this.buttonElement&&(this.buttonElement.innerHTML=this.originalIcon)}onDestroy(){this.hideMenu(),this.plugins.forEach(t=>t.destroy?.())}showMenu(){if(this.buttonElement=document.getElementById(`qfchart-plugin-btn-${this.id}`),!this.buttonElement)return;this.menuElement&&this.hideMenu(),this.menuElement=document.createElement("div"),Object.assign(this.menuElement.style,{position:"fixed",backgroundColor:"#1e293b",border:"1px solid #334155",borderRadius:"6px",padding:"4px",display:"flex",flexDirection:"column",gap:"2px",zIndex:"10000",boxShadow:"0 4px 6px -1px rgba(0, 0, 0, 0.3)",minWidth:"150px"}),this.plugins.forEach(e=>{const i=document.createElement("div");if(Object.assign(i.style,{display:"flex",alignItems:"center",padding:"8px 12px",cursor:"pointer",color:"#cbd5e1",borderRadius:"4px",fontSize:"13px",fontFamily:this.context.getOptions().fontFamily||"sans-serif",transition:"background-color 0.2s"}),i.addEventListener("mouseenter",()=>{i.style.backgroundColor="rgba(255, 255, 255, 0.1)"}),i.addEventListener("mouseleave",()=>{i.style.backgroundColor="transparent"}),e.icon){const a=document.createElement("div");a.innerHTML=e.icon,Object.assign(a.style,{width:"20px",height:"20px",marginRight:"10px",display:"flex",alignItems:"center",justifyContent:"center"});const n=a.querySelector("svg");n&&(n.style.width="100%",n.style.height="100%"),i.appendChild(a)}const s=document.createElement("span");s.textContent=e.name||e.id,i.appendChild(s),i.addEventListener("click",a=>{a.stopPropagation(),this.activateSubPlugin(e)}),this.menuElement.appendChild(i)}),document.body.appendChild(this.menuElement);const t=this.buttonElement.getBoundingClientRect();this.menuElement.style.top=`${t.top}px`,this.menuElement.style.left=`${t.right+5}px`,setTimeout(()=>{document.addEventListener("click",this.handleOutsideClick)},0)}hideMenu(){this.menuElement&&this.menuElement.parentNode&&this.menuElement.parentNode.removeChild(this.menuElement),this.menuElement=null,document.removeEventListener("click",this.handleOutsideClick)}activateSubPlugin(t){if(this.hideMenu(),this.activeSubPlugin&&this.activeSubPlugin.deactivate?.(),this.activeSubPlugin=t,this.activeSubPlugin.activate?.(),this.buttonElement){let e="";t.icon?e=`<div style="position: relative; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;">
48
+ </div>`,super({id:t.id||`group-${t.name.toLowerCase().replace(/\s+/g,"-")}`,name:t.name,icon:i}),Pt(this,"plugins",[]),Pt(this,"activeSubPlugin",null),Pt(this,"menuElement",null),Pt(this,"buttonElement",null),Pt(this,"originalIcon",""),Pt(this,"arrowSvg",""),Pt(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 r=document.createElement("div");r.innerHTML=e.icon,Object.assign(r.style,{width:"20px",height:"20px",marginRight:"10px",display:"flex",alignItems:"center",justifyContent:"center"});const n=r.querySelector("svg");n&&(n.style.width="100%",n.style.height="100%"),i.appendChild(r)}const s=document.createElement("span");s.textContent=e.name||e.id,i.appendChild(s),i.addEventListener("click",r=>{r.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
49
  <div style="width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;">
50
50
  ${t.icon}
51
51
  </div>
@@ -53,4 +53,4 @@ ${u}`;this.chart.setOption({series:[{id:"__candlestick__",markLine:{data:[{...h,
53
53
  </div>`:e=`<div style="position: relative; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;">
54
54
  <span>${(t.name||t.id).substring(0,2).toUpperCase()}</span>
55
55
  ${this.arrowSvg}
56
- </div>`,this.buttonElement.innerHTML=e}}}export{be as ABCDPatternDrawingRenderer,ys as ABCDPatternTool,it as AbstractPlugin,_e as CypherPatternDrawingRenderer,Is as CypherPatternTool,ne as DrawingRendererRegistry,le as FibSpeedResistanceFanDrawingRenderer,Vi as FibSpeedResistanceFanTool,pe as FibTrendExtensionDrawingRenderer,ts as FibTrendExtensionTool,re as FibonacciChannelDrawingRenderer,Hi as FibonacciChannelTool,ae as FibonacciDrawingRenderer,Wi as FibonacciTool,Ae as HeadAndShouldersDrawingRenderer,Ss as HeadAndShouldersTool,oe as LineDrawingRenderer,Si as LineTool,_i as MeasureTool,bi as QFChart,$e as ThreeDrivesPatternDrawingRenderer,Bs as ThreeDrivesPatternTool,Xs as ToolGroup,Me as TrianglePatternDrawingRenderer,Ts as TrianglePatternTool,ge as XABCDPatternDrawingRenderer,hs as XABCDPatternTool};
56
+ </div>`,this.buttonElement.innerHTML=e}}}export{Ze as ABCDPatternDrawingRenderer,$n as ABCDPatternTool,X as AbstractPlugin,Pe as CrossLineDrawingRenderer,Bs as CrossLineTool,Re as CypherPatternDrawingRenderer,Zn as CypherPatternTool,de as DrawingRendererRegistry,ye as ExtendedLineDrawingRenderer,gs as ExtendedLineTool,Me as FibSpeedResistanceFanDrawingRenderer,hn as FibSpeedResistanceFanTool,_e as FibTrendExtensionDrawingRenderer,yn as FibTrendExtensionTool,De as FibonacciChannelDrawingRenderer,sn as FibonacciChannelTool,Ie as FibonacciDrawingRenderer,Us as FibonacciTool,Ye as HeadAndShouldersDrawingRenderer,jn as HeadAndShouldersTool,xe as HorizontalLineDrawingRenderer,Ds as HorizontalLineTool,be as HorizontalRayDrawingRenderer,Gs as HorizontalRayTool,ge as InfoLineDrawingRenderer,ls as InfoLineTool,pe as LineDrawingRenderer,Ui as LineTool,Bi as MeasureTool,Ni as QFChart,ue as RayDrawingRenderer,is as RayTool,Ke as ThreeDrivesPatternDrawingRenderer,oo as ThreeDrivesPatternTool,lo as ToolGroup,fe as TrendAngleDrawingRenderer,vs as TrendAngleTool,Xe as TrianglePatternDrawingRenderer,Jn as TrianglePatternTool,we as VerticalLineDrawingRenderer,Zs as VerticalLineTool,ze as XABCDPatternDrawingRenderer,kn as XABCDPatternTool};