@qfo/qfchart 0.8.1 → 0.8.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +216 -1
- package/dist/qfchart.min.browser.js +20 -19
- package/dist/qfchart.min.es.js +18 -17
- package/package.json +1 -1
- package/src/QFChart.ts +146 -11
- package/src/components/LayoutManager.ts +76 -28
- package/src/components/PluginManager.ts +229 -229
- package/src/components/SeriesBuilder.ts +21 -14
- package/src/components/renderers/LabelRenderer.ts +6 -3
- package/src/components/renderers/ScatterRenderer.ts +92 -54
- package/src/components/renderers/ShapeRenderer.ts +12 -0
- package/src/index.ts +8 -0
- package/src/plugins/CrossLineTool/CrossLineDrawingRenderer.ts +49 -0
- package/src/plugins/CrossLineTool/CrossLineTool.ts +52 -0
- package/src/plugins/CrossLineTool/index.ts +2 -0
- package/src/plugins/ExtendedLineTool/ExtendedLineDrawingRenderer.ts +73 -0
- package/src/plugins/ExtendedLineTool/ExtendedLineTool.ts +173 -0
- package/src/plugins/ExtendedLineTool/index.ts +2 -0
- package/src/plugins/HorizontalLineTool/HorizontalLineDrawingRenderer.ts +54 -0
- package/src/plugins/HorizontalLineTool/HorizontalLineTool.ts +52 -0
- package/src/plugins/HorizontalLineTool/index.ts +2 -0
- package/src/plugins/HorizontalRayTool/HorizontalRayDrawingRenderer.ts +34 -0
- package/src/plugins/HorizontalRayTool/HorizontalRayTool.ts +52 -0
- package/src/plugins/HorizontalRayTool/index.ts +2 -0
- package/src/plugins/InfoLineTool/InfoLineDrawingRenderer.ts +72 -0
- package/src/plugins/InfoLineTool/InfoLineTool.ts +130 -0
- package/src/plugins/InfoLineTool/index.ts +2 -0
- package/src/plugins/LineTool/LineDrawingRenderer.ts +2 -2
- package/src/plugins/LineTool/LineTool.ts +5 -5
- package/src/plugins/RayTool/RayDrawingRenderer.ts +69 -0
- package/src/plugins/RayTool/RayTool.ts +162 -0
- package/src/plugins/RayTool/index.ts +2 -0
- package/src/plugins/TrendAngleTool/TrendAngleDrawingRenderer.ts +87 -0
- package/src/plugins/TrendAngleTool/TrendAngleTool.ts +176 -0
- package/src/plugins/TrendAngleTool/index.ts +2 -0
- package/src/plugins/VerticalLineTool/VerticalLineDrawingRenderer.ts +35 -0
- package/src/plugins/VerticalLineTool/VerticalLineTool.ts +52 -0
- package/src/plugins/VerticalLineTool/index.ts +2 -0
- package/src/types.ts +2 -0
|
@@ -14,30 +14,31 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
|
-
(function(N,At){typeof exports=="object"&&typeof module<"u"?At(exports,require("echarts")):typeof define=="function"&&define.amd?define(["exports","echarts"],At):(N=typeof globalThis<"u"?globalThis:N||self,At(N.QFChart={},N.echarts))})(this,function(N,At){"use strict";function Te(d){var t=Object.create(null);return d&&Object.keys(d).forEach(function(e){if(e!=="default"){var i=Object.getOwnPropertyDescriptor(d,e);Object.defineProperty(t,e,i.get?i:{enumerable:!0,get:function(){return d[e]}})}}),t.default=d,Object.freeze(t)}var G=Te(At),We=Object.defineProperty,Ne=(d,t,e)=>t in d?We(d,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):d[t]=e,xt=(d,t,e)=>(Ne(d,typeof t!="symbol"?t+"":t,e),e);class Fe{constructor(t,e,i,s={}){xt(this,"id"),xt(this,"plots"),xt(this,"paneIndex"),xt(this,"height"),xt(this,"collapsed"),xt(this,"titleColor"),xt(this,"controls"),this.id=t,this.plots=e,this.paneIndex=i,this.height=s.height,this.collapsed=s.collapsed||!1,this.titleColor=s.titleColor,this.controls=s.controls}toggleCollapse(){this.collapsed=!this.collapsed}isVisible(){return!this.collapsed}updateData(t){Object.keys(t).forEach(e=>{if(!this.plots[e])this.plots[e]=t[e];else{const i=this.plots[e],s=t[e];if(!i.data)return;s.options&&(i.options={...i.options,...s.options});const a=new Map;i.data?.forEach(n=>{a.set(n.time,n)}),s.data?.forEach(n=>{a.set(n.time,n)}),i.data=Array.from(a.values()).sort((n,l)=>n.time-l.time)}})}}class B{static createMinFunction(t){return e=>{const i=(e.max-e.min)*(t/100);return e.min-i}}static createMaxFunction(t){return e=>{const i=(e.max-e.min)*(t/100);return e.max+i}}static autoDetectDecimals(t){if(!t||t.length===0)return 2;const e=t[t.length-1].close;if(e===0||!isFinite(e)||isNaN(e))return 2;const i=Math.abs(e);if(i>=1)return 2;const s=Math.ceil(-Math.log10(i));return Math.min(s+4,10)}static formatValue(t,e){return typeof t=="number"?t.toFixed(e):String(t)}}class Bt{static calculate(t,e,i,s=!1,a=null,n,l){let r=0;t>0&&(r=1/t*100);const o=i.yAxisPadding!==void 0?i.yAxisPadding:5,u=i.grid?.show===!0,p=i.grid?.lineColor??"#334155",c=i.grid?.lineOpacity??.5,g=i.grid?.borderColor??"#334155",h=i.grid?.borderShow===!0,f=i.layout?.left??"10%",y=i.layout?.right??"10%",x=Array.from(e.values()).map(E=>E.paneIndex).filter(E=>E>0).sort((E,R)=>E-R).filter((E,R,q)=>q.indexOf(E)===R),b=x.length>0,D=i.dataZoom?.visible??!0,w=i.dataZoom?.position??"top",P=i.dataZoom?.height??6,m=i.dataZoom?.start??0,C=i.dataZoom?.end??100;let v=8,_=92,k=-1;if(a)if(a==="main")k=0;else{const E=e.get(a);E&&(k=E.paneIndex)}if(k!==-1){const E=[],R=[],q=[],J=[],at=i.dataZoom?.start??50,Y=i.dataZoom?.end??100;(i.dataZoom?.zoomOnTouch??!0)&&J.push({type:"inside",xAxisIndex:"all",start:at,end:Y,filterMode:"weakFilter"});const rt=b?Math.max(...x):0,ut=[];for(let tt=0;tt<=rt;tt++){const it=tt===k;E.push({left:f,right:y,top:it?"5%":"0%",height:it?"90%":"0%",show:it,containLabel:!1}),R.push({type:"category",gridIndex:tt,data:[],show:it,axisLabel:{show:it,color:"#94a3b8",fontFamily:i.fontFamily},axisLine:{show:it&&h,lineStyle:{color:g}},splitLine:{show:it&&u,lineStyle:{color:p,opacity:c}}});let Et,Lt;if(tt===0&&k===0?(Et=i.yAxisMin!==void 0&&i.yAxisMin!=="auto"?i.yAxisMin:B.createMinFunction(o),Lt=i.yAxisMax!==void 0&&i.yAxisMax!=="auto"?i.yAxisMax:B.createMaxFunction(o)):(Et=B.createMinFunction(o),Lt=B.createMaxFunction(o)),q.push({position:"right",gridIndex:tt,show:it,scale:!0,min:Et,max:Lt,axisLabel:{show:it,color:"#94a3b8",fontFamily:i.fontFamily,formatter:gt=>{if(i.yAxisLabelFormatter)return i.yAxisLabelFormatter(gt);const Tt=i.yAxisDecimalPlaces!==void 0?i.yAxisDecimalPlaces:B.autoDetectDecimals(n);return B.formatValue(gt,Tt)}},splitLine:{show:it&&u,lineStyle:{color:p,opacity:c}}}),tt>0){const gt=Array.from(e.values()).find(Tt=>Tt.paneIndex===tt);gt&&ut.push({index:tt,height:it?90:0,top:it?5:0,isCollapsed:!1,indicatorId:gt.id,titleColor:gt.titleColor,controls:gt.controls})}}return{grid:E,xAxis:R,yAxis:q,dataZoom:J,paneLayout:ut,mainPaneHeight:k===0?90:0,mainPaneTop:k===0?5:0,pixelToPercent:r,overlayYAxisMap:new Map,separatePaneYAxisOffset:1}}D?w==="top"?(v=P+4,_=95):(_=100-P-2,v=8):(v=5,_=95);let M=5;t>0&&(M=20/t*100);let S=75,z=[];if(b){const E=x.map(Y=>{const rt=Array.from(e.values()).find(ut=>ut.paneIndex===Y);return{index:Y,requestedHeight:rt?.height,isCollapsed:rt?.collapsed??!1,indicatorId:rt?.id,titleColor:rt?.titleColor,controls:rt?.controls}}).map(Y=>({...Y,height:Y.isCollapsed?3:Y.requestedHeight!==void 0?Y.requestedHeight:15})),R=E.reduce((Y,rt)=>Y+rt.height,0),q=E.length*M,J=R+q;S=_-v-J,l!==void 0&&l>0&&!s?S=l:s?S=3:S<20&&(S=Math.max(S,10));let at=v+S+M;z=E.map(Y=>{const rt={index:Y.index,height:Y.height,top:at,isCollapsed:Y.isCollapsed,indicatorId:Y.indicatorId,titleColor:Y.titleColor,controls:Y.controls};return at+=Y.height+M,rt})}else S=_-v,s&&(S=3);const T=[];if(z.length>0){T.push({yPercent:v+S+M/2,aboveId:"main",belowId:z[0].indicatorId||""});for(let E=0;E<z.length-1;E++)T.push({yPercent:z[E].top+z[E].height+M/2,aboveId:z[E].indicatorId||"",belowId:z[E+1].indicatorId||""})}const I=[];I.push({left:f,right:y,top:v+"%",height:S+"%",containLabel:!1}),z.forEach(E=>{I.push({left:f,right:y,top:E.top+"%",height:E.height+"%",containLabel:!1})});const $=[0,...z.map((E,R)=>R+1)],A=[],O=z.length===0;A.push({type:"category",data:[],gridIndex:0,scale:!0,axisLine:{onZero:!1,show:!s&&h,lineStyle:{color:g}},splitLine:{show:!s&&u,lineStyle:{color:p,opacity:c}},axisLabel:{show:!s,color:"#94a3b8",fontFamily:i.fontFamily||"sans-serif",formatter:E=>{if(i.yAxisLabelFormatter)return i.yAxisLabelFormatter(E);const R=i.yAxisDecimalPlaces!==void 0?i.yAxisDecimalPlaces:B.autoDetectDecimals(n);return B.formatValue(E,R)}},axisTick:{show:!s},axisPointer:{label:{show:O,fontSize:11,backgroundColor:"#475569"}}}),z.forEach((E,R)=>{const q=R===z.length-1;A.push({type:"category",gridIndex:R+1,data:[],axisLabel:{show:!1},axisLine:{show:!E.isCollapsed&&h,lineStyle:{color:g}},axisTick:{show:!1},splitLine:{show:!1},axisPointer:{label:{show:q,fontSize:11,backgroundColor:"#475569"}}})});const W=[];let j,Z;i.yAxisMin!==void 0&&i.yAxisMin!=="auto"?j=i.yAxisMin:j=B.createMinFunction(o),i.yAxisMax!==void 0&&i.yAxisMax!=="auto"?Z=i.yAxisMax:Z=B.createMaxFunction(o),W.push({position:"right",scale:!0,min:j,max:Z,gridIndex:0,splitLine:{show:!s&&u,lineStyle:{color:p,opacity:c}},axisLine:{show:!s&&h,lineStyle:{color:g}},axisLabel:{show:!s,color:"#94a3b8",fontFamily:i.fontFamily||"sans-serif",formatter:E=>{if(i.yAxisLabelFormatter)return i.yAxisLabelFormatter(E);const R=i.yAxisDecimalPlaces!==void 0?i.yAxisDecimalPlaces:B.autoDetectDecimals(n);return B.formatValue(E,R)}}});let F=1,U=-1/0,H=1/0;n&&n.length>0&&(U=Math.min(...n.map(E=>E.low)),H=Math.max(...n.map(E=>E.high)));const X=new Map;e.forEach((E,R)=>{E.paneIndex===0&&!E.collapsed&&n&&n.length>0&&Object.entries(E.plots).forEach(([q,J])=>{const at=`${R}::${q}`,Y=["background","barcolor","char"],rt=J.options.style==="shape"&&(J.options.location==="abovebar"||J.options.location==="AboveBar"||J.options.location==="belowbar"||J.options.location==="BelowBar");if(Y.includes(J.options.style)){X.has(at)||(X.set(at,F),F++);return}if(J.options.style==="shape"&&!rt){X.has(at)||(X.set(at,F),F++);return}const ut=[];if(J.data&&Object.values(J.data).forEach(tt=>{typeof tt=="number"&&!isNaN(tt)&&isFinite(tt)&&ut.push(tt)}),ut.length>0){const tt=Math.min(...ut),it=Math.max(...ut),Et=it-tt,Lt=H-U,gt=tt>=U*.5&&it<=H*1.5,Tt=Et>Lt*.01;gt&&Tt||X.has(at)||(X.set(at,F),F++)}})});const ht=X.size>0?F-1:0,dt=new Set;X.forEach((E,R)=>{e.forEach(q=>{Object.entries(q.plots).forEach(([J,at])=>{`${q.id}::${J}`===R&&["background","barcolor","char"].includes(at.options.style)&&dt.add(E)})})});for(let E=0;E<ht;E++){const R=E+1,q=dt.has(R);W.push({position:"left",scale:!q,min:q?0:B.createMinFunction(o),max:q?1:B.createMaxFunction(o),gridIndex:0,show:!1,splitLine:{show:!1},axisLine:{show:!1},axisLabel:{show:!1}})}const te=F;z.forEach((E,R)=>{W.push({position:"right",scale:!0,min:B.createMinFunction(o),max:B.createMaxFunction(o),gridIndex:R+1,splitLine:{show:!E.isCollapsed&&u,lineStyle:{color:p,opacity:c*.6}},axisLabel:{show:!E.isCollapsed,color:"#94a3b8",fontFamily:i.fontFamily||"sans-serif",fontSize:10,formatter:q=>{if(i.yAxisLabelFormatter)return i.yAxisLabelFormatter(q);const J=i.yAxisDecimalPlaces!==void 0?i.yAxisDecimalPlaces:B.autoDetectDecimals(n);return B.formatValue(q,J)}},axisLine:{show:!E.isCollapsed&&h,lineStyle:{color:g}}})});const Pt=[],Ht=i.dataZoom?.zoomOnTouch??!0,Rt=i.dataZoom?.pannable??!0;return Ht&&Rt&&Pt.push({type:"inside",xAxisIndex:$,start:m,end:C,filterMode:"weakFilter"}),D&&(w==="top"?Pt.push({type:"slider",xAxisIndex:$,top:"1%",height:P+"%",start:m,end:C,borderColor:"#334155",textStyle:{color:"#cbd5e1"},brushSelect:!1,filterMode:"weakFilter"}):Pt.push({type:"slider",xAxisIndex:$,bottom:"1%",height:P+"%",start:m,end:C,borderColor:"#334155",textStyle:{color:"#cbd5e1"},brushSelect:!1,filterMode:"weakFilter"})),{grid:I,xAxis:A,yAxis:W,dataZoom:Pt,paneLayout:z,mainPaneHeight:S,mainPaneTop:v,pixelToPercent:r,paneBoundaries:T,overlayYAxisMap:X,separatePaneYAxisOffset:te}}static calculateMaximized(t,e,i){return{grid:[],xAxis:[],yAxis:[],dataZoom:[],paneLayout:[],mainPaneHeight:0,mainPaneTop:0,pixelToPercent:0,paneBoundaries:[]}}}class Ze{render(t){const{seriesName:e,xAxisIndex:i,yAxisIndex:s,dataArray:a,colorArray:n,plotOptions:l}=t,r="#2962ff";return{name:e,type:"custom",xAxisIndex:i,yAxisIndex:s,renderItem:(o,u)=>{const p=o.dataIndex;if(p===0)return;const c=u.value(1),g=u.value(2);if(c===null||isNaN(c)||g===null||isNaN(g))return;const h=u.coord([p-1,g]),f=u.coord([p,c]);return{type:"line",shape:{x1:h[0],y1:h[1],x2:f[0],y2:f[1]},style:{stroke:n[p]||l.color||r,lineWidth:l.linewidth||1},silent:!0}},data:a.map((o,u)=>[u,o,u>0?a[u-1]:null])}}}class Oe{render(t){const{seriesName:e,xAxisIndex:i,yAxisIndex:s,dataArray:a,colorArray:n,plotOptions:l}=t,r="#2962ff";return{name:e,type:"custom",xAxisIndex:i,yAxisIndex:s,renderItem:(o,u)=>{const p=u.value(0),c=u.value(1);if(isNaN(c)||c===null)return;const g=u.coord([p,c]),h=u.size([1,0])[0];return{type:"line",shape:{x1:g[0]-h/2,y1:g[1],x2:g[0]+h/2,y2:g[1]},style:{stroke:n[o.dataIndex]||l.color||r,lineWidth:l.linewidth||1},silent:!0}},data:a.map((o,u)=>[u,o])}}}class ie{render(t){const{seriesName:e,xAxisIndex:i,yAxisIndex:s,dataArray:a,colorArray:n,plotOptions:l}=t,r="#2962ff",o=l.histbase??0,u=l.style==="columns",p=l.linewidth??1,c=a.map((g,h)=>g==null||typeof g=="number"&&isNaN(g)?null:[h,g,n[h]||l.color||r]);return{name:e,type:"custom",xAxisIndex:i,yAxisIndex:s,renderItem:(g,h)=>{const f=h.value(0),y=h.value(1),x=h.value(2);if(y==null||isNaN(y))return null;const b=h.coord([f,o]),D=h.coord([f,y]),w=h.size([1,0])[0];let P;u?P=w*.6:P=Math.max(1,p);const m=b[0],C=b[1],v=D[1],_=Math.min(C,v),k=Math.abs(v-C);return{type:"rect",shape:{x:m-P/2,y:_,width:P,height:k||1},style:{fill:x}}},data:c.filter(g=>g!==null)}}}const jt=new Map;function He(d,t="#00da3c",e="64px"){if(typeof document>"u")return"";const i=`${d}-${t}-${e}`;if(jt.has(i))return jt.get(i);const s=document.createElement("canvas"),a=s.getContext("2d");if(s.width=32,s.height=32,a){a.font="bold "+e+" Arial",a.fillStyle=t,a.textAlign="center",a.textBaseline="middle",a.fillText(d,16,16);const n=s.toDataURL("image/png");return jt.set(i,n),n}return""}class Yt{render(t){const{seriesName:e,xAxisIndex:i,yAxisIndex:s,dataArray:a,colorArray:n,plotOptions:l}=t,r="#2962ff",o=l.style;if(o==="char")return{name:e,type:"scatter",xAxisIndex:i,yAxisIndex:s,symbolSize:0,data:a.map((p,c)=>({value:[c,p],itemStyle:{opacity:0}})),silent:!0};const u=a.map((p,c)=>{if(p===null)return null;const g=n[c]||l.color||r,h={value:[c,p],itemStyle:{color:g}};return o==="cross"?(h.symbol=`image://${He("+",g,"24px")}`,h.symbolSize=16):(h.symbol="circle",h.symbolSize=6),h}).filter(p=>p!==null);return{name:e,type:"scatter",xAxisIndex:i,yAxisIndex:s,data:u}}}class se{render(t){const{seriesName:e,xAxisIndex:i,yAxisIndex:s,dataArray:a,colorArray:n,optionsArray:l,plotOptions:r}=t,o="#2962ff",u=r.style==="candle",p=[],c=a.map((g,h)=>{if(g===null||!Array.isArray(g)||g.length!==4)return null;const[f,y,x,b]=g,D=l[h]||{},w=D.color||n[h]||r.color||o,P=D.wickcolor||r.wickcolor||w,m=D.bordercolor||r.bordercolor||P;return p[h]={color:w,wickColor:P,borderColor:m},[h,f,b,x,y]}).filter(g=>g!==null);return{name:e,type:"custom",xAxisIndex:i,yAxisIndex:s,renderItem:(g,h)=>{const f=h.value(0),y=h.value(1),x=h.value(2),b=h.value(3),D=h.value(4);if(isNaN(y)||isNaN(x)||isNaN(b)||isNaN(D))return null;const w=p[f]||{color:o,wickColor:o,borderColor:o},P=w.color,m=w.wickColor,C=w.borderColor,v=h.coord([f,0])[0],_=h.coord([f,y])[1],k=h.coord([f,x])[1],M=h.coord([f,b])[1],S=h.coord([f,D])[1],z=h.size([1,0])[0]*.6;if(u){const T=Math.min(_,k),I=Math.max(_,k),$=Math.abs(k-_);return{type:"group",children:[{type:"line",shape:{x1:v,y1:S,x2:v,y2:T},style:{stroke:m,lineWidth:1}},{type:"line",shape:{x1:v,y1:I,x2:v,y2:M},style:{stroke:m,lineWidth:1}},{type:"rect",shape:{x:v-z/2,y:T,width:z,height:$||1},style:{fill:P,stroke:C,lineWidth:1}}]}}else{const T=z*.5;return{type:"group",children:[{type:"line",shape:{x1:v,y1:M,x2:v,y2:S},style:{stroke:P,lineWidth:1}},{type:"line",shape:{x1:v-T,y1:_,x2:v,y2:_},style:{stroke:P,lineWidth:1}},{type:"line",shape:{x1:v,y1:k,x2:v+T,y2:k},style:{stroke:P,lineWidth:1}}]}}},data:c}}}class vt{static getShapeSymbol(t){switch(t){case"arrowdown":case"shape_arrow_down":return"path://M12 24l-12-12h8v-12h8v12h8z";case"arrowup":case"shape_arrow_up":return"path://M12 0l12 12h-8v12h-8v-12h-8z";case"circle":case"shape_circle":return"circle";case"cross":case"shape_cross":return"path://M11 2h2v9h9v2h-9v9h-2v-9h-9v-2h9z";case"diamond":case"shape_diamond":return"diamond";case"flag":case"shape_flag":return"path://M6 2v20h2v-8h12l-2-6 2-6h-12z";case"labeldown":case"shape_label_down":return"path://M2 1h20a1 1 0 0 1 1 1v14a1 1 0 0 1-1 1h-8l-2 3-2-3h-8a1 1 0 0 1-1-1v-14a1 1 0 0 1 1-1z";case"labelleft":case"shape_label_left":return"path://M0 10l3-3v-5a1 1 0 0 1 1-1h18a1 1 0 0 1 1 1v16a1 1 0 0 1-1 1h-18a1 1 0 0 1-1-1v-5z";case"labelright":case"shape_label_right":return"path://M24 10l-3-3v-5a1 1 0 0 0-1-1h-18a1 1 0 0 0-1 1v16a1 1 0 0 0 1 1h18a1 1 0 0 0 1-1v-5z";case"labelup":case"shape_label_up":return"path://M12 1l2 3h8a1 1 0 0 1 1 1v14a1 1 0 0 1-1 1h-20a1 1 0 0 1-1-1v-14a1 1 0 0 1 1-1h8z";case"square":case"shape_square":return"rect";case"triangledown":case"shape_triangle_down":return"path://M12 21l-10-18h20z";case"triangleup":case"shape_triangle_up":return"triangle";case"xcross":case"shape_xcross":return"path://M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z";default:return"circle"}}static getShapeRotation(t){return 0}static getShapeSize(t,e,i){if(e!==void 0&&i!==void 0)return[e,i];let s;switch(t){case"tiny":s=8;break;case"small":s=12;break;case"normal":case"auto":s=16;break;case"large":s=24;break;case"huge":s=32;break;default:s=16}return e!==void 0?[e,e]:i!==void 0?[i,i]:s}static getLabelConfig(t,e){switch(e){case"abovebar":case"AboveBar":return{position:"top",distance:5};case"belowbar":case"BelowBar":return{position:"bottom",distance:5};case"top":case"Top":return{position:"bottom",distance:5};case"bottom":case"Bottom":return{position:"top",distance:5};case"absolute":case"Absolute":default:return t==="labelup"||t==="labeldown"||t==="shape_label_up"||t==="shape_label_down"?{position:"inside",distance:0}:{position:"top",distance:5}}}}class Re{render(t){const{seriesName:e,xAxisIndex:i,yAxisIndex:s,dataArray:a,colorArray:n,optionsArray:l,plotOptions:r,candlestickData:o}=t,u="#2962ff",p=a.map((c,g)=>{const h=l[g]||{},f=r,y=h.location||f.location||"absolute";if(y!=="absolute"&&y!=="Absolute"&&!c||c==null)return null;const x=h.color||f.color||u,b=h.shape||f.shape||"circle",D=h.size||f.size||"normal",w=h.text||f.text,P=h.textcolor||f.textcolor||"white",m=h.width||f.width,C=h.height||f.height;let v=c,_=[0,0];y==="abovebar"||y==="AboveBar"||y==="ab"?(o&&o[g]&&(v=o[g].high),_=[0,"-150%"]):y==="belowbar"||y==="BelowBar"||y==="bl"?(o&&o[g]&&(v=o[g].low),_=[0,"150%"]):y==="top"||y==="Top"?(v=c,_=[0,0]):(y==="bottom"||y==="Bottom")&&(v=c,_=[0,0]);const k=vt.getShapeSymbol(b),M=vt.getShapeSize(D,m,C),S=vt.getShapeRotation(b);let z=M;b.includes("label")&&(Array.isArray(M)?z=[M[0]*2.5,M[1]*2.5]:z=M*2.5);const T=vt.getLabelConfig(b,y);return{value:[g,v],symbol:k,symbolSize:z,symbolRotate:S,symbolOffset:_,itemStyle:{color:x},label:{show:!!w,position:T.position,distance:T.distance,formatter:w,color:P,fontSize:10,fontWeight:"bold"}}}).filter(c=>c!==null);return{name:e,type:"scatter",xAxisIndex:i,yAxisIndex:s,data:p}}}class ot{static parseColor(t){if(!t||typeof t!="string")return{color:"#888888",opacity:.2};const e=t.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?\)/);if(e){const s=e[1],a=e[2],n=e[3],l=e[4]?parseFloat(e[4]):1;return{color:`rgb(${s},${a},${n})`,opacity:l}}const i=t.match(/^#([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/);if(i){const s=parseInt(i[1],16),a=parseInt(i[2],16),n=parseInt(i[3],16),l=parseInt(i[4],16)/255;return{color:`rgb(${s},${a},${n})`,opacity:l}}return{color:t,opacity:.3}}static toRgba(t,e){const i=t.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(i)return`rgba(${i[1]},${i[2]},${i[3]},${e})`;const s=t.match(/^#([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/);if(s){const n=parseInt(s[1],16),l=parseInt(s[2],16),r=parseInt(s[3],16);return`rgba(${n},${l},${r},${e})`}const a=t.match(/^#([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/);if(a){const n=parseInt(a[1],16),l=parseInt(a[2],16),r=parseInt(a[3],16);return`rgba(${n},${l},${r},${e})`}return t}}class Be{render(t){const{seriesName:e,xAxisIndex:i,yAxisIndex:s,dataArray:a,colorArray:n}=t,l=[];for(let r=0;r<n.length;r++)l[r]=n[r]?ot.parseColor(n[r]):{color:"",opacity:0};return{name:e,type:"custom",xAxisIndex:i,yAxisIndex:s,z:-10,renderItem:(r,o)=>{const u=o.value(0);if(isNaN(u))return;const p=o.coord([u,.5]),c=o.size([1,0])[0],g=r.coordSys,h=p[0]-c/2,f=n[r.dataIndex],y=o.value(1);if(!f||y===null||y===void 0||isNaN(y))return;const x=l[r.dataIndex];if(!(!x||x.opacity<=0))return{type:"rect",shape:{x:h,y:g.y,width:c,height:g.height},style:{fill:x.color,opacity:x.opacity},silent:!0}},data:a.map((r,o)=>[o,r!=null&&!isNaN(r)?.5:null])}}}class ne{render(t){const{seriesName:e,xAxisIndex:i,yAxisIndex:s,plotOptions:a,plotDataArrays:n,indicatorId:l,plotName:r,optionsArray:o}=t,u=t.dataArray.length,p=a.plot1?`${l}::${a.plot1}`:null,c=a.plot2?`${l}::${a.plot2}`:null;if(!p||!c)return console.warn(`Fill plot "${r}" missing plot1 or plot2 reference`),null;const g=n?.get(p),h=n?.get(c);if(!g||!h)return console.warn(`Fill plot "${r}" references non-existent plots: ${a.plot1}, ${a.plot2}`),null;if(a.gradient===!0)return this.renderGradientFill(e,i,s,g,h,u,o,a);const{color:f,opacity:y}=ot.parseColor(a.color||"rgba(128, 128, 128, 0.2)"),x=o?.some(w=>w&&w.color!==void 0);let b=null;if(x){b=[];for(let w=0;w<u;w++){const P=o?.[w];P&&P.color!==void 0?b[w]=ot.parseColor(P.color):b[w]={color:f,opacity:y}}}const D=[];for(let w=0;w<u;w++){const P=g[w],m=h[w],C=w>0?g[w-1]:null,v=w>0?h[w-1]:null;D.push([w,P,m,C,v])}return{name:e,type:"custom",xAxisIndex:i,yAxisIndex:s,z:1,clip:!0,encode:{x:0},animation:!1,renderItem:(w,P)=>{const m=w.dataIndex;if(m===0)return null;const C=P.value(1),v=P.value(2),_=P.value(3),k=P.value(4);if(C===null||v===null||_===null||k===null||isNaN(C)||isNaN(v)||isNaN(_)||isNaN(k))return null;const M=b?b[m]:null,S=M?M.opacity:y;if(S<.01)return null;const z=P.coord([m-1,_]),T=P.coord([m,C]),I=P.coord([m,v]),$=P.coord([m-1,k]);return{type:"polygon",shape:{points:[z,T,I,$]},style:{fill:M?M.color:f,opacity:S},silent:!0}},data:D,silent:!0}}renderBatched(t,e,i,s,a){const n=Array.from({length:s},(l,r)=>[r]);return{name:t,type:"custom",xAxisIndex:e,yAxisIndex:i,z:1,clip:!0,encode:{x:0},animation:!1,renderItem:(l,r)=>{const o=l.dataIndex;if(o===0)return null;const u=[];for(let p=0;p<a.length;p++){const c=a[p],g=c.plot1Data[o],h=c.plot2Data[o],f=c.plot1Data[o-1],y=c.plot2Data[o-1];if(g==null||h==null||f==null||y==null||isNaN(g)||isNaN(h)||isNaN(f)||isNaN(y))continue;const x=c.barColors[o];if(!x||x.opacity<.01)continue;const b=r.coord([o-1,f]),D=r.coord([o,g]),w=r.coord([o,h]),P=r.coord([o-1,y]);u.push({type:"polygon",shape:{points:[b,D,w,P]},style:{fill:x.color,opacity:x.opacity},silent:!0})}return u.length>0?{type:"group",children:u,silent:!0}:null},data:n,silent:!0}}renderGradientFill(t,e,i,s,a,n,l,r){const o=[];for(let p=0;p<n;p++){const c=l?.[p];if(c&&c.top_color!==void 0){const g=ot.parseColor(c.top_color),h=ot.parseColor(c.bottom_color);o[p]={topColor:g.color,topOpacity:g.opacity,bottomColor:h.color,bottomOpacity:h.opacity}}else o[p]={topColor:"rgba(128,128,128,0.2)",topOpacity:.2,bottomColor:"rgba(128,128,128,0.2)",bottomOpacity:.2}}const u=[];for(let p=0;p<n;p++){const c=s[p],g=a[p],h=p>0?s[p-1]:null,f=p>0?a[p-1]:null;u.push([p,c,g,h,f])}return{name:t,type:"custom",xAxisIndex:e,yAxisIndex:i,z:1,clip:!0,encode:{x:0},animation:!1,renderItem:(p,c)=>{const g=p.dataIndex;if(g===0)return null;const h=c.value(1),f=c.value(2),y=c.value(3),x=c.value(4);if(h===null||f===null||y===null||x===null||isNaN(h)||isNaN(f)||isNaN(y)||isNaN(x))return null;const b=c.coord([g-1,y]),D=c.coord([g,h]),w=c.coord([g,f]),P=c.coord([g-1,x]),m=o[g]||o[g-1];if(!m||m.topOpacity<.01&&m.bottomOpacity<.01)return null;const C=ot.toRgba(m.topColor,m.topOpacity),v=ot.toRgba(m.bottomColor,m.bottomOpacity),_=h>=f;return{type:"polygon",shape:{points:[b,D,w,P]},style:{fill:{type:"linear",x:0,y:0,x2:0,y2:1,colorStops:[{offset:0,color:_?C:v},{offset:1,color:_?v:C}]}},silent:!0}},data:u,silent:!0}}}class je{render(t){const{seriesName:e,xAxisIndex:i,yAxisIndex:s,dataArray:a,candlestickData:n,dataIndexOffset:l}=t,r=l||0,o=[];for(let p=0;p<a.length;p++){const c=a[p];if(!c)continue;const g=Array.isArray(c)?c:[c];for(const h of g)h&&typeof h=="object"&&!h._deleted&&o.push(h)}const u=o.map(p=>{const c=W=>typeof W=="function"?W():W,g=c(p.text)||"",h=c(p.color),f=h!=null&&h!==""?h:"transparent",y=c(p.textcolor)||"#ffffff",x=c(p.yloc)||"price",b=c(p.style)||"style_label_down",D=c(p.size)||"normal",w=c(p.textalign)||"align_center",P=c(p.tooltip)||"",m=this.styleToShape(b),C=p.xloc==="bar_index"||p.xloc==="bi"?p.x+r:p.x;let v=p.y,_=[0,0];x==="abovebar"||x==="AboveBar"||x==="ab"?(n&&n[C]&&(v=n[C].high),_=[0,"-150%"]):(x==="belowbar"||x==="BelowBar"||x==="bl")&&(n&&n[C]&&(v=n[C].low),_=[0,"150%"]);const k=vt.getShapeSymbol(m),M=vt.getShapeSize(D),S=this.getSizePx(D);let z;const T=m==="labeldown"||m==="shape_label_down"||m==="labelup"||m==="shape_label_up"||m==="labelleft"||m==="labelright";let I=[0,0];if(T){const W=g.length*S*.65,j=S*2.5,Z=Math.max(j,W+S*1.6),F=S*2.8,U=3/24;if(m==="labelleft"||m==="labelright"){const H=Z/(1-U);z=[H,F];const X=typeof _[0]=="string"?0:_[0];m==="labelleft"?(_=[X+H*.42,_[1]],I=[H*U*.5,0]):(_=[X-H*.42,_[1]],I=[-H*U*.5,0])}else{const H=F/(1-U);z=[Z,H],m==="labeldown"?(_=[_[0],typeof _[1]=="string"?_[1]:_[1]-H*.42],I=[0,-H*U*.5]):(_=[_[0],typeof _[1]=="string"?_[1]:_[1]+H*.42],I=[0,H*U*.5])}}else m==="none"?z=0:Array.isArray(M)?z=[M[0]*1.5,M[1]*1.5]:z=M*1.5;const $=this.getLabelPosition(b,x),A=$==="inside"||$.startsWith("inside"),O={value:[C,v],symbol:k,symbolSize:z,symbolOffset:_,itemStyle:{color:f},label:{show:!!g,position:$,distance:A?0:5,offset:I,formatter:g,color:y,fontSize:S,fontWeight:"bold",align:A?"center":w==="align_left"||w==="left"?"left":w==="align_right"||w==="right"?"right":"center",verticalAlign:"middle",padding:[2,6]}};return P?(O._tooltipText=P,O.emphasis={scale:!1,itemStyle:{color:f},label:{show:O.label.show,color:y,fontSize:S,fontWeight:"bold"}}):O.emphasis={disabled:!0},O}).filter(p=>p!==null);return{name:e,type:"scatter",xAxisIndex:i,yAxisIndex:s,data:u,z:20,animation:!1,clip:!1}}styleToShape(t){switch(t.startsWith("style_")?t.substring(6):t){case"label_down":return"labeldown";case"label_up":return"labelup";case"label_left":return"labelleft";case"label_right":return"labelright";case"label_lower_left":return"labeldown";case"label_lower_right":return"labeldown";case"label_upper_left":return"labelup";case"label_upper_right":return"labelup";case"label_center":return"labeldown";case"circle":return"circle";case"square":return"square";case"diamond":return"diamond";case"flag":return"flag";case"arrowup":return"arrowup";case"arrowdown":return"arrowdown";case"cross":return"cross";case"xcross":return"xcross";case"triangleup":return"triangleup";case"triangledown":return"triangledown";case"text_outline":return"none";case"none":return"none";default:return"labeldown"}}getLabelPosition(t,e){switch(t.startsWith("style_")?t.substring(6):t){case"label_down":case"label_up":case"label_left":case"label_right":case"label_lower_left":case"label_lower_right":case"label_upper_left":case"label_upper_right":case"label_center":return"inside";case"text_outline":case"none":return e==="abovebar"||e==="AboveBar"||e==="ab"?"top":e==="belowbar"||e==="BelowBar"||e==="bl"?"bottom":"top";default:return e==="belowbar"||e==="BelowBar"||e==="bl"?"bottom":"top"}}getSizePx(t){switch(t){case"tiny":return 8;case"small":return 9;case"normal":case"auto":return 10;case"large":return 12;case"huge":return 14;default:return 10}}}class Ye{render(t){const{seriesName:e,xAxisIndex:i,yAxisIndex:s,dataArray:a,dataIndexOffset:n}=t,l=n||0,r="#2962ff",o=[];for(let c=0;c<a.length;c++){const g=a[c];if(!g)continue;const h=Array.isArray(g)?g:[g];for(const f of h)f&&typeof f=="object"&&!f._deleted&&o.push(f)}if(o.length===0)return{name:e,type:"custom",xAxisIndex:i,yAxisIndex:s,data:[],silent:!0};const u=(t.candlestickData?.length||0)+l,p=Math.max(0,u-1);return{name:e,type:"custom",xAxisIndex:i,yAxisIndex:s,renderItem:(c,g)=>{const h=[];for(const f of o){if(f._deleted)continue;const y=f.xloc==="bar_index"||f.xloc==="bi"?l:0;let x=g.coord([f.x1+y,f.y1]),b=g.coord([f.x2+y,f.y2]);const D=f.extend||"none";if(D!=="none"&&D!=="n"){const C=c.coordSys;[x,b]=this.extendLine(x,b,D,C.x,C.x+C.width,C.y,C.y+C.height)}const w=f.color||r,P=f.width||1;h.push({type:"line",shape:{x1:x[0],y1:x[1],x2:b[0],y2:b[1]},style:{fill:"none",stroke:w,lineWidth:P,lineDash:this.getDashPattern(f.style)}});const m=f.style||"style_solid";if(m==="style_arrow_left"||m==="style_arrow_both"){const C=this.arrowHead(b,x,P,w);C&&h.push(C)}if(m==="style_arrow_right"||m==="style_arrow_both"){const C=this.arrowHead(x,b,P,w);C&&h.push(C)}}return{type:"group",children:h}},data:[[0,p]],clip:!0,encode:{x:[0,1]},itemStyle:{color:"transparent",borderColor:"transparent"},z:15,silent:!0,emphasis:{disabled:!0}}}getDashPattern(t){switch(t){case"style_dotted":return[2,2];case"style_dashed":return[6,4];default:return}}extendLine(t,e,i,s,a,n,l){const r=e[0]-t[0],o=e[1]-t[1];if(r===0&&o===0)return[t,e];const u=(g,h)=>{let f=1/0;if(h[0]!==0){const y=h[0]>0?(a-g[0])/h[0]:(s-g[0])/h[0];f=Math.min(f,y)}if(h[1]!==0){const y=h[1]>0?(l-g[1])/h[1]:(n-g[1])/h[1];f=Math.min(f,y)}return isFinite(f)||(f=0),[g[0]+f*h[0],g[1]+f*h[1]]};let p=t,c=e;return(i==="right"||i==="r"||i==="both"||i==="b")&&(c=u(t,[r,o])),(i==="left"||i==="l"||i==="both"||i==="b")&&(p=u(e,[-r,-o])),[p,c]}arrowHead(t,e,i,s){const a=e[0]-t[0],n=e[1]-t[1],l=Math.sqrt(a*a+n*n);if(l<1)return null;const r=Math.max(8,i*4),o=a/l,u=n/l,p=e[0]-o*r,c=e[1]-u*r,g=-u*r*.4,h=o*r*.4;return{type:"polygon",shape:{points:[[e[0],e[1]],[p+g,c+h],[p-g,c-h]]},style:{fill:s}}}}class Xe{render(t){const{seriesName:e,xAxisIndex:i,yAxisIndex:s,dataArray:a,dataIndexOffset:n}=t,l=n||0,r=[];for(let p=0;p<a.length;p++){const c=a[p];if(!c)continue;const g=Array.isArray(c)?c:[c];for(const h of g){if(!h||typeof h!="object"||h._deleted)continue;const f=h.line1,y=h.line2;!f||!y||f._deleted||y._deleted||r.push(h)}}if(r.length===0)return{name:e,type:"custom",xAxisIndex:i,yAxisIndex:s,data:[],silent:!0};const o=(t.candlestickData?.length||0)+l,u=Math.max(0,o-1);return{name:e,type:"custom",xAxisIndex:i,yAxisIndex:s,renderItem:(p,c)=>{const g=[];for(const h of r){if(h._deleted)continue;const f=h.line1,y=h.line2;if(!f||!y||f._deleted||y._deleted)continue;const x=f.xloc==="bar_index"||f.xloc==="bi"?l:0,b=y.xloc==="bar_index"||y.xloc==="bi"?l:0;let D=c.coord([f.x1+x,f.y1]),w=c.coord([f.x2+x,f.y2]),P=c.coord([y.x1+b,y.y1]),m=c.coord([y.x2+b,y.y2]);const C=f.extend||"none",v=y.extend||"none";if(C!=="none"||v!=="none"){const M=p.coordSys,S=M.x,z=M.x+M.width,T=M.y,I=M.y+M.height;C!=="none"&&([D,w]=this.extendLine(D,w,C,S,z,T,I)),v!=="none"&&([P,m]=this.extendLine(P,m,v,S,z,T,I))}const{color:_,opacity:k}=ot.parseColor(h.color||"rgba(128, 128, 128, 0.2)");g.push({type:"polygon",shape:{points:[D,w,m,P]},style:{fill:_,opacity:k},silent:!0})}return{type:"group",children:g}},data:[[0,u]],clip:!0,encode:{x:[0,1]},z:10,silent:!0,emphasis:{disabled:!0}}}extendLine(t,e,i,s,a,n,l){const r=e[0]-t[0],o=e[1]-t[1];if(r===0&&o===0)return[t,e];const u=(g,h)=>{let f=1/0;if(h[0]!==0){const y=h[0]>0?(a-g[0])/h[0]:(s-g[0])/h[0];f=Math.min(f,y)}if(h[1]!==0){const y=h[1]>0?(l-g[1])/h[1]:(n-g[1])/h[1];f=Math.min(f,y)}return isFinite(f)||(f=0),[g[0]+f*h[0],g[1]+f*h[1]]};let p=t,c=e;return(i==="right"||i==="both")&&(c=u(t,[r,o])),(i==="left"||i==="both")&&(p=u(e,[-r,-o])),[p,c]}}class qe{render(t){const{seriesName:e,xAxisIndex:i,yAxisIndex:s,dataArray:a,dataIndexOffset:n}=t,l=n||0,r=[];for(let p=0;p<a.length;p++){const c=a[p];if(!c)continue;const g=Array.isArray(c)?c:[c];for(const h of g)h&&typeof h=="object"&&!h._deleted&&h.points&&h.points.length>=2&&r.push(h)}if(r.length===0)return{name:e,type:"custom",xAxisIndex:i,yAxisIndex:s,data:[],silent:!0};const o=(t.candlestickData?.length||0)+l,u=Math.max(0,o-1);return{name:e,type:"custom",xAxisIndex:i,yAxisIndex:s,renderItem:(p,c)=>{const g=[];for(const h of r){if(h._deleted)continue;const f=h.points;if(!f||f.length<2)continue;const y=h.xloc==="bi"||h.xloc==="bar_index",x=y?l:0,b=[];for(const C of f){const v=y?(C.index??0)+x:C.time??0,_=C.price??0;b.push(c.coord([v,_]))}if(b.length<2)continue;const D=h.line_color,w=D==null||typeof D=="number"&&isNaN(D)||D==="na"||D==="NaN"?null:D||"#2962ff",P=h.line_width||1,m=this.getDashPattern(h.line_style);if(h.fill_color&&h.fill_color!==""&&h.fill_color!=="na"){const{color:C,opacity:v}=ot.parseColor(h.fill_color);if(h.curved){const _=this.buildCurvedPath(b,h.closed);g.push({type:"path",shape:{pathData:_+" Z"},style:{fill:C,opacity:v,stroke:"none"},silent:!0})}else g.push({type:"polygon",shape:{points:b},style:{fill:C,opacity:v,stroke:"none"},silent:!0})}if(w&&P>0)if(h.curved){const C=this.buildCurvedPath(b,h.closed);g.push({type:"path",shape:{pathData:C},style:{fill:"none",stroke:w,lineWidth:P,lineDash:m},silent:!0})}else{const C=h.closed?[...b,b[0]]:b;g.push({type:"polyline",shape:{points:C},style:{fill:"none",stroke:w,lineWidth:P,lineDash:m},silent:!0})}}return{type:"group",children:g}},data:[[0,u]],clip:!0,encode:{x:[0,1]},itemStyle:{color:"transparent",borderColor:"transparent"},z:15,silent:!0,emphasis:{disabled:!0}}}buildCurvedPath(t,e){const i=t.length;if(i<2)return"";if(i===2)return`M ${t[0][0]} ${t[0][1]} L ${t[1][0]} ${t[1][1]}`;const s=.5;let a=`M ${t[0][0]} ${t[0][1]}`;const n=r=>e?t[(r%i+i)%i]:r<0?t[0]:r>=i?t[i-1]:t[r],l=e?i:i-1;for(let r=0;r<l;r++){const o=n(r-1),u=n(r),p=n(r+1),c=n(r+2),g=u[0]+(p[0]-o[0])*s/3,h=u[1]+(p[1]-o[1])*s/3,f=p[0]-(c[0]-u[0])*s/3,y=p[1]-(c[1]-u[1])*s/3;a+=` C ${g} ${h}, ${f} ${y}, ${p[0]} ${p[1]}`}return e&&(a+=" Z"),a}getDashPattern(t){switch(t){case"style_dotted":return[2,2];case"style_dashed":return[6,4];default:return}}}function Xt(d){if(!d||typeof d!="string")return d;if(d.startsWith("#")){const t=d.slice(1);if(t.length===8){const e=parseInt(t.slice(0,2),16),i=parseInt(t.slice(2,4),16),s=parseInt(t.slice(4,6),16),a=parseInt(t.slice(6,8),16)/255;return`rgba(${e},${i},${s},${a.toFixed(3)})`}}return d}function Ve(d){if(!d||typeof d!="string")return null;if(d.startsWith("#")){const e=d.slice(1);if(e.length>=6){const i=parseInt(e.slice(0,2),16),s=parseInt(e.slice(2,4),16),a=parseInt(e.slice(4,6),16);if(!isNaN(i)&&!isNaN(s)&&!isNaN(a))return{r:i,g:s,b:a}}if(e.length===3){const i=parseInt(e[0]+e[0],16),s=parseInt(e[1]+e[1],16),a=parseInt(e[2]+e[2],16);if(!isNaN(i)&&!isNaN(s)&&!isNaN(a))return{r:i,g:s,b:a}}return null}const t=d.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?{r:+t[1],g:+t[2],b:+t[3]}:null}function Ue(d,t,e){return(.299*d+.587*t+.114*e)/255}class Ke{render(t){const{seriesName:e,xAxisIndex:i,yAxisIndex:s,dataArray:a,dataIndexOffset:n}=t,l=n||0,r=[];for(let p=0;p<a.length;p++){const c=a[p];if(!c)continue;const g=Array.isArray(c)?c:[c];for(const h of g)h&&typeof h=="object"&&!h._deleted&&r.push(h)}if(r.length===0)return{name:e,type:"custom",xAxisIndex:i,yAxisIndex:s,data:[],silent:!0};const o=(t.candlestickData?.length||0)+l,u=Math.max(0,o-1);return{name:e,type:"custom",xAxisIndex:i,yAxisIndex:s,renderItem:(p,c)=>{const g=[];for(const h of r){if(h._deleted)continue;const f=h.xloc==="bar_index"||h.xloc==="bi"?l:0,y=c.coord([h.left+f,h.top]),x=c.coord([h.right+f,h.bottom]);let b=y[0],D=y[1],w=x[0]-y[0],P=x[1]-y[1];const m=h.extend||"none";if(m!=="none"&&m!=="n"){const S=p.coordSys;(m==="left"||m==="l"||m==="both"||m==="b")&&(b=S.x,w=m==="both"||m==="b"?S.width:x[0]-S.x),(m==="right"||m==="r"||m==="both"||m==="b")&&(m==="right"||m==="r")&&(w=S.x+S.width-y[0])}const C=h.bgcolor,v=C==null||typeof C=="number"&&isNaN(C)||C==="na"||C==="NaN"||C===""?null:Xt(C)||"#2962ff";v&&g.push({type:"rect",shape:{x:b,y:D,width:w,height:P},style:{fill:v,stroke:"none"}});const _=h.border_color,k=_==null||typeof _=="number"&&isNaN(_)||_==="na"||_==="NaN"?null:Xt(_)||"#2962ff",M=h.border_width??1;if(M>0&&k&&g.push({type:"rect",shape:{x:b,y:D,width:w,height:P},style:{fill:"none",stroke:k,lineWidth:M,lineDash:this.getDashPattern(h.border_style)}}),h.text){const S=this.getTextX(b,w,h.text_halign),z=this.getTextY(D,P,h.text_valign);let T=Xt(h.text_color)||"#000000";if((!h.text_color||h.text_color==="#000000"||h.text_color==="black"||h.text_color==="color.black")&&v){const A=Ve(v);A&&Ue(A.r,A.g,A.b)<.5&&(T="#FFFFFF")}const I=!h.text_formatting||h.text_formatting==="format_none"||h.text_formatting==="format_bold",$=this.computeFontSize(h.text_size,h.text,Math.abs(w),Math.abs(P),I);g.push({type:"text",style:{x:S,y:z,text:h.text,fill:T,fontSize:$,fontFamily:h.text_font_family==="monospace"?"monospace":"sans-serif",fontWeight:I?"bold":"normal",fontStyle:h.text_formatting==="format_italic"?"italic":"normal",textAlign:this.mapHAlign(h.text_halign),textVerticalAlign:this.mapVAlign(h.text_valign)}})}}return{type:"group",children:g}},data:[[0,u]],clip:!0,encode:{x:[0,1]},itemStyle:{color:"transparent",borderColor:"transparent"},z:14,silent:!0,emphasis:{disabled:!0}}}getDashPattern(t){switch(t){case"style_dotted":return[2,2];case"style_dashed":return[6,4];default:return}}computeFontSize(t,e,i,s,a){if(typeof t=="number"&&t>0)return t;switch(t){case"tiny":case"size.tiny":return 8;case"small":case"size.small":return 10;case"normal":case"size.normal":return 14;case"large":case"size.large":return 20;case"huge":case"size.huge":return 36}if(!e||i<=0||s<=0)return 12;const n=6,l=i-n*2,r=s-n*2;if(l<=0||r<=0)return 6;const o=e.split(`
|
|
18
|
-
`),u=o.length;let p=1;for(const f of o)f.length>p&&(p=f.length);const c=l/(p*(a?.62:.55)),g=r/(u*1.3),h=Math.min(c,g);return Math.max(6,Math.min(h,48))}mapHAlign(t){switch(t){case"left":case"text.align_left":return"left";case"right":case"text.align_right":return"right";case"center":case"text.align_center":default:return"center"}}mapVAlign(t){switch(t){case"top":case"text.align_top":return"top";case"bottom":case"text.align_bottom":return"bottom";case"center":case"text.align_center":default:return"middle"}}getTextX(t,e,i){switch(i){case"left":case"text.align_left":return t+4;case"right":case"text.align_right":return t+e-4;case"center":case"text.align_center":default:return t+e/2}}getTextY(t,e,i){switch(i){case"top":case"text.align_top":return t+4;case"bottom":case"text.align_bottom":return t+e-4;case"center":case"text.align_center":default:return t+e/2}}}var Je=Object.defineProperty,Qe=(d,t,e)=>t in d?Je(d,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):d[t]=e,ti=(d,t,e)=>(Qe(d,typeof t!="symbol"?t+"":t,e),e);const V=class{static register(t,e){this.renderers.set(t,e)}static get(t){return this.renderers.get(t)||this.renderers.get("line")}};ti(V,"renderers",new Map),V.register("line",new Ze),V.register("step",new Oe),V.register("histogram",new ie),V.register("columns",new ie),V.register("circles",new Yt),V.register("cross",new Yt),V.register("char",new Yt),V.register("bar",new se),V.register("candle",new se),V.register("shape",new Re),V.register("background",new Be),V.register("fill",new ne),V.register("label",new je),V.register("drawing_line",new Ye),V.register("linefill",new Xe),V.register("drawing_polyline",new qe),V.register("drawing_box",new Ke);let ei=V;var ii=Object.defineProperty,si=(d,t,e)=>t in d?ii(d,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):d[t]=e,ni=(d,t,e)=>(si(d,typeof t!="symbol"?t+"":t,e),e);const oe=class ee{static buildCandlestickSeries(t,e,i){const s=e.upColor||"#00da3c",a=e.downColor||"#ec0000",n=t.map(r=>[r.open,r.close,r.low,r.high]);if(i&&i>n.length){const r=i-n.length;for(let o=0;o<r;o++)n.push(null)}let l;if(e.lastPriceLine?.visible!==!1&&t.length>0){const r=t[t.length-1],o=r.close,u=r.close>=r.open,p=e.lastPriceLine?.color||(u?s:a);let c=e.lastPriceLine?.lineStyle||"dashed";c.startsWith("linestyle_")&&(c=c.replace("linestyle_",""));const g=e.yAxisDecimalPlaces!==void 0?e.yAxisDecimalPlaces:B.autoDetectDecimals(t);l={symbol:["none","none"],precision:g,data:[{yAxis:o,label:{show:!0,position:"end",formatter:h=>e.yAxisLabelFormatter?e.yAxisLabelFormatter(h.value):B.formatValue(h.value,g),color:"#fff",backgroundColor:p,padding:[2,4],borderRadius:2,fontSize:11,fontWeight:"bold"},lineStyle:{color:p,type:c,width:1,opacity:.8}}],animation:!1,silent:!0}}return{type:"candlestick",id:"__candlestick__",name:e.title,data:n,itemStyle:{color:s,color0:a,borderColor:s,borderColor0:a},markLine:l,xAxisIndex:0,yAxisIndex:0,z:5}}static buildIndicatorSeries(t,e,i,s,a=0,n,l,r=1){const o=[],u=new Array(s).fill(null),p=new Map;return t.forEach((c,g)=>{if(c.collapsed)return;const h=Object.keys(c.plots).sort((y,x)=>{const b=c.plots[y],D=c.plots[x],w=b.options.style==="fill",P=D.options.style==="fill";return w&&!P?1:!w&&P?-1:0}),f=new Map;if(h.forEach(y=>{const x=c.plots[y],b=x.options.display==="none",D=`${g}::${y}`;let w=0,P=0,m=x.options.overlay;if(x.options.style==="fill"&&m===void 0){const S=x.options.plot1,z=x.options.plot2;if(S&&z){const T=c.plots[S],I=c.plots[z];T?.options?.overlay===!0&&I?.options?.overlay===!0&&(m=!0)}}if(c.paneIndex===0||m===!0)w=0,l&&l.has(D)?P=l.get(D):P=0;else{const S=i.findIndex(z=>z.index===c.paneIndex);S!==-1&&(w=S+1,P=r+S)}const C=new Array(s).fill(null),v=new Array(s).fill(null),_=new Array(s).fill(null),k=new Array(s).fill(null);if(x.data?.forEach(S=>{const z=e.get(S.time);if(z!==void 0){const T=S.options?.offset??x.options.offset??0,I=z+a+T;if(I>=0&&I<s){let $=S.value;const A=S.options?.color;v[I]=$;const O=S.options!=null&&"color"in S.options,W=A===null||A==="na"||A==="NaN"||typeof A=="number"&&isNaN(A)||O&&A===void 0;W&&($=null),C[I]=$,_[I]=W?null:A||x.options.color||ee.DEFAULT_COLOR,k[I]=S.options||{}}}}),p.set(`${g}::${y}`,v),b)return;if(x.options?.style?.startsWith("style_")&&(x.options.style=x.options.style.replace("style_","")),x.options.style==="barcolor"){x.data?.forEach(S=>{const z=e.get(S.time);if(z!==void 0){const T=S.options?.offset??x.options.offset??0,I=z+a+T;if(I>=0&&I<s){const $=S.options?.color||x.options.color||ee.DEFAULT_COLOR;!($===null||$==="na"||$==="NaN"||typeof $=="number"&&isNaN($))&&S.value!==null&&S.value!==void 0&&(u[I]=$)}}});return}if(x.options.style==="table")return;if(x.options.style==="fill"&&x.options.gradient!==!0){const S=x.options.plot1?`${g}::${x.options.plot1}`:null,z=x.options.plot2?`${g}::${x.options.plot2}`:null;if(S&&z){const T=p.get(S),I=p.get(z);if(T&&I){const{color:$,opacity:A}=ot.parseColor(x.options.color||"rgba(128, 128, 128, 0.2)"),O=k.some(Z=>Z&&Z.color!==void 0),W=[];for(let Z=0;Z<s;Z++){const F=k[Z];O&&F&&F.color!==void 0?W[Z]=ot.parseColor(F.color):W[Z]={color:$,opacity:A}}const j=`${w}:${P}`;f.has(j)||f.set(j,{entries:[],xAxisIndex:w,yAxisIndex:P}),f.get(j).entries.push({plot1Data:T,plot2Data:I,barColors:W});return}}}if(x.options.color&&typeof x.options.color=="string"&&ot.parseColor(x.options.color).opacity<.01&&!_.some(S=>S==null?!1:ot.parseColor(S).opacity>=.01))return;const M=ei.get(x.options.style).render({seriesName:D,xAxisIndex:w,yAxisIndex:P,dataArray:C,colorArray:_,optionsArray:k,plotOptions:x.options,candlestickData:n,plotDataArrays:p,indicatorId:g,plotName:y,dataIndexOffset:a});M&&o.push(M)}),f.size>0){const y=new ne;f.forEach(({entries:x,xAxisIndex:b,yAxisIndex:D},w)=>{if(x.length>=2){const P=y.renderBatched(`${g}::fills_batch_${w}`,b,D,s,x);P&&o.push(P)}else if(x.length===1){const P=y.renderBatched(`${g}::fills_batch_${w}`,b,D,s,x);P&&o.push(P)}})}}),{series:o,barColors:u}}};ni(oe,"DEFAULT_COLOR","#2962ff");let wt=oe;class oi{static build(t,e,i,s=!1,a=null,n=[]){const l=[],r=t.pixelToPercent,o=t.mainPaneTop;if(!a||a==="main"){const u=10*r;if(l.push({type:"text",left:"8.5%",top:o+u+"%",z:10,style:{text:e.title||"",fill:e.titleColor||"#fff",font:`bold 16px ${e.fontFamily||"sans-serif"}`,textVerticalAlign:"top"}}),n.length>0){const c=20*r,g=16*r;n.forEach((h,f)=>{l.push({type:"text",left:"8.5%",top:o+u+c+f*g+"%",z:10,style:{text:h.id,fill:h.titleColor||"#9e9e9e",font:`bold 12px ${e.fontFamily||"sans-serif"}`,textVerticalAlign:"top"}})})}if(e.watermark!==!1){const c=t.mainPaneTop+t.mainPaneHeight;l.push({type:"text",right:"11%",top:c-3+"%",z:10,style:{text:"QFChart",fill:e.fontColor||"#cbd5e1",font:"bold 16px sans-serif",opacity:.1},cursor:"pointer",onclick:()=>{window.open("https://quantforge.org","_blank")}})}const p=[];if(e.controls?.collapse&&p.push({type:"group",children:[{type:"rect",shape:{width:20,height:20,r:2},style:{fill:"#334155",stroke:"#475569",lineWidth:1},onclick:()=>i("main","collapse")},{type:"text",style:{text:s?"+":"\u2212",fill:"#cbd5e1",font:`bold 14px ${e.fontFamily}`,x:10,y:10,textAlign:"center",textVerticalAlign:"middle"},silent:!0}]}),e.controls?.maximize){const c=a==="main",g=e.controls?.collapse?25:0;p.push({type:"group",x:g,children:[{type:"rect",shape:{width:20,height:20,r:2},style:{fill:"#334155",stroke:"#475569",lineWidth:1},onclick:()=>i("main","maximize")},{type:"text",style:{text:c?"\u2750":"\u25A1",fill:"#cbd5e1",font:`14px ${e.fontFamily}`,x:10,y:10,textAlign:"center",textVerticalAlign:"middle"},silent:!0}]})}if(e.controls?.fullscreen){let c=0;e.controls?.collapse&&(c+=25),e.controls?.maximize&&(c+=25),p.push({type:"group",x:c,children:[{type:"rect",shape:{width:20,height:20,r:2},style:{fill:"#334155",stroke:"#475569",lineWidth:1},onclick:()=>i("main","fullscreen")},{type:"text",style:{text:"\u26F6",fill:"#cbd5e1",font:`14px ${e.fontFamily}`,x:10,y:10,textAlign:"center",textVerticalAlign:"middle"},silent:!0}]})}p.length>0&&l.push({type:"group",right:"10.5%",top:o+"%",children:p})}return t.paneLayout.forEach(u=>{if(a&&u.indicatorId!==a)return;l.push({type:"text",left:"8.5%",top:u.top+10*r+"%",z:10,style:{text:u.indicatorId||"",fill:u.titleColor||"#fff",font:`bold 12px ${e.fontFamily||"sans-serif"}`,textVerticalAlign:"top"}});const p=[];if(u.controls?.collapse&&p.push({type:"group",children:[{type:"rect",shape:{width:20,height:20,r:2},style:{fill:"#334155",stroke:"#475569",lineWidth:1},onclick:()=>u.indicatorId&&i(u.indicatorId,"collapse")},{type:"text",style:{text:u.isCollapsed?"+":"\u2212",fill:"#cbd5e1",font:`bold 14px ${e.fontFamily}`,x:10,y:10,textAlign:"center",textVerticalAlign:"middle"},silent:!0}]}),u.controls?.maximize){const c=a===u.indicatorId,g=u.controls?.collapse?25:0;p.push({type:"group",x:g,children:[{type:"rect",shape:{width:20,height:20,r:2},style:{fill:"#334155",stroke:"#475569",lineWidth:1},onclick:()=>u.indicatorId&&i(u.indicatorId,"maximize")},{type:"text",style:{text:c?"\u2750":"\u25A1",fill:"#cbd5e1",font:`14px ${e.fontFamily}`,x:10,y:10,textAlign:"center",textVerticalAlign:"middle"},silent:!0}]})}p.length>0&&l.push({type:"group",right:"10.5%",top:u.top+"%",children:p})}),l}}class ai{static format(t,e){if(!t||t.length===0)return"";const i=e.title||"",s=e.upColor||"#00da3c",a=e.downColor||"#ec0000",n=e.fontFamily||"sans-serif",l=t[0].axisValue;let r=`<div style="font-weight: bold; margin-bottom: 5px; color: #cbd5e1; font-family: ${n};">${l}</div>`;const o=t.find(p=>p.seriesType==="candlestick"),u=t.filter(p=>p.seriesType!=="candlestick");if(o){const[p,c,g,h,f]=o.value,y=g>=c?s:a;r+=`
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
(function(T,$t){typeof exports=="object"&&typeof module<"u"?$t(exports,require("echarts")):typeof define=="function"&&define.amd?define(["exports","echarts"],$t):(T=typeof globalThis<"u"?globalThis:T||self,$t(T.QFChart={},T.echarts))})(this,function(T,$t){"use strict";function ii(h){var t=Object.create(null);return h&&Object.keys(h).forEach(function(e){if(e!=="default"){var i=Object.getOwnPropertyDescriptor(h,e);Object.defineProperty(t,e,i.get?i:{enumerable:!0,get:function(){return h[e]}})}}),t.default=h,Object.freeze(t)}var D=ii($t),ni=Object.defineProperty,si=(h,t,e)=>t in h?ni(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,vt=(h,t,e)=>(si(h,typeof t!="symbol"?t+"":t,e),e);class oi{constructor(t,e,i,n={}){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=n.height,this.collapsed=n.collapsed||!1,this.titleColor=n.titleColor,this.controls=n.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],n=t[e];if(!i.data)return;n.options&&(i.options={...i.options,...n.options});const r=new Map;i.data?.forEach(s=>{r.set(s.time,s)}),n.data?.forEach(s=>{r.set(s.time,s)}),i.data=Array.from(r.values()).sort((s,l)=>s.time-l.time)}})}}class X{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 n=Math.ceil(-Math.log10(i));return Math.min(n+4,10)}static formatValue(t,e){return typeof t=="number"?t.toFixed(e):String(t)}}class Kt{static calculate(t,e,i,n=!1,r=null,s,l){let a=0;t>0&&(a=1/t*100);const o=i.yAxisPadding!==void 0?i.yAxisPadding:5,p=i.grid?.show===!0,u=i.grid?.lineColor??"#334155",d=i.grid?.lineOpacity??.5,g=i.grid?.borderColor??"#334155",c=i.grid?.borderShow===!0,y=i.layout?.left??"10%",f=i.layout?.right??"10%",x=Array.from(e.values()).map(E=>E.paneIndex).filter(E=>E>0).sort((E,Z)=>E-Z).filter((E,Z,K)=>K.indexOf(E)===Z),m=x.length>0,I=i.dataZoom?.visible??!0,v=i.dataZoom?.position??"top",k=i.dataZoom?.height??6,A=i.dataZoom?.start??0,w=i.dataZoom?.end??100;let b=8,C=92,_=-1;if(r)if(r==="main")_=0;else{const E=e.get(r);E&&(_=E.paneIndex)}if(_!==-1){const E=[],Z=[],K=[],B=[],lt=i.dataZoom?.start??50,zt=i.dataZoom?.end??100;(i.dataZoom?.zoomOnTouch??!0)&&B.push({type:"inside",xAxisIndex:"all",start:lt,end:zt,filterMode:"weakFilter"});const j=m?Math.max(...x):0,Q=[];for(let N=0;N<=j;N++){const et=N===_;E.push({left:y,right:f,top:et?"5%":"0%",height:et?"90%":"0%",show:et,containLabel:!1}),Z.push({type:"category",gridIndex:N,data:[],show:et,axisLabel:{show:et,color:"#94a3b8",fontFamily:i.fontFamily},axisLine:{show:et&&c,lineStyle:{color:g}},splitLine:{show:et&&p,lineStyle:{color:u,opacity:d}}});let Rt,Ot;if(N===0&&_===0?(Rt=i.yAxisMin!==void 0&&i.yAxisMin!=="auto"?i.yAxisMin:X.createMinFunction(o),Ot=i.yAxisMax!==void 0&&i.yAxisMax!=="auto"?i.yAxisMax:X.createMaxFunction(o)):(Rt=X.createMinFunction(o),Ot=X.createMaxFunction(o)),K.push({position:"right",gridIndex:N,show:et,scale:!0,min:Rt,max:Ot,axisLabel:{show:et,color:"#94a3b8",fontFamily:i.fontFamily,formatter:xt=>{if(i.yAxisLabelFormatter)return i.yAxisLabelFormatter(xt);const Ht=i.yAxisDecimalPlaces!==void 0?i.yAxisDecimalPlaces:X.autoDetectDecimals(s);return X.formatValue(xt,Ht)}},splitLine:{show:et&&p,lineStyle:{color:u,opacity:d}}}),N>0){const xt=Array.from(e.values()).find(Ht=>Ht.paneIndex===N);xt&&Q.push({index:N,height:et?90:0,top:et?5:0,isCollapsed:!1,indicatorId:xt.id,titleColor:xt.titleColor,controls:xt.controls})}}return{grid:E,xAxis:Z,yAxis:K,dataZoom:B,paneLayout:Q,mainPaneHeight:_===0?90:0,mainPaneTop:_===0?5:0,pixelToPercent:a,overlayYAxisMap:new Map,separatePaneYAxisOffset:1}}I?v==="top"?(b=k+4,C=95):(C=100-k-2,b=8):(b=5,C=95);let z=5;t>0&&(z=20/t*100);let S=75,$;if(i.layout?.mainPaneHeight!==void 0){const E=i.layout.mainPaneHeight;if(typeof E=="string"){const Z=parseFloat(E);isNaN(Z)||($=Z)}else typeof E=="number"&&($=E)}let L=[];if(m){const E=x.map(j=>{const Q=Array.from(e.values()).find(N=>N.paneIndex===j);return{index:j,requestedHeight:Q?.height,isCollapsed:Q?.collapsed??!1,indicatorId:Q?.id,titleColor:Q?.titleColor,controls:Q?.controls}}).map(j=>({...j,rawHeight:j.isCollapsed?3:j.requestedHeight!==void 0?j.requestedHeight:15})),Z=C-b,K=E.length*z;if(l!==void 0&&l>0&&!n)S=l;else if(n)S=3;else if($!==void 0&&$>0)S=$;else{const j=E.reduce((Q,N)=>Q+N.rawHeight,0);S=Z-j-K,S<20&&(S=Math.max(S,10))}const B=l!==void 0&&l>0&&!n||$!==void 0&&$>0&&!n;let lt;if(B){const j=Z-S-K,Q=E.filter(N=>!N.isCollapsed).reduce((N,et)=>N+et.rawHeight,0);lt=E.map(N=>({...N,height:N.isCollapsed?3:Q>0?Math.max(5,N.rawHeight/Q*j):j/E.filter(et=>!et.isCollapsed).length}))}else lt=E.map(j=>({...j,height:j.rawHeight}));let zt=b+S+z;L=lt.map(j=>{const Q={index:j.index,height:j.height,top:zt,isCollapsed:j.isCollapsed,indicatorId:j.indicatorId,titleColor:j.titleColor,controls:j.controls};return zt+=j.height+z,Q})}else S=C-b,n&&(S=3);const P=[];if(L.length>0){P.push({yPercent:b+S+z/2,aboveId:"main",belowId:L[0].indicatorId||""});for(let E=0;E<L.length-1;E++)P.push({yPercent:L[E].top+L[E].height+z/2,aboveId:L[E].indicatorId||"",belowId:L[E+1].indicatorId||""})}const G=[];G.push({left:y,right:f,top:b+"%",height:S+"%",containLabel:!1}),L.forEach(E=>{G.push({left:y,right:f,top:E.top+"%",height:E.height+"%",containLabel:!1})});const M=[0,...L.map((E,Z)=>Z+1)],R=[],F=L.length===0,J=!n&&F;R.push({type:"category",data:[],gridIndex:0,scale:!0,axisLine:{onZero:!1,show:!n&&c,lineStyle:{color:g}},splitLine:{show:!n&&p,lineStyle:{color:u,opacity:d}},axisLabel:{show:J,color:"#94a3b8",fontFamily:i.fontFamily||"sans-serif",formatter:E=>{if(i.yAxisLabelFormatter)return i.yAxisLabelFormatter(E);const Z=i.yAxisDecimalPlaces!==void 0?i.yAxisDecimalPlaces:X.autoDetectDecimals(s);return X.formatValue(E,Z)}},axisTick:{show:J},axisPointer:{label:{show:F,fontSize:11,backgroundColor:"#475569"}}}),L.forEach((E,Z)=>{const K=Z===L.length-1,B=K&&!E.isCollapsed;R.push({type:"category",gridIndex:Z+1,data:[],axisLabel:{show:B,color:"#94a3b8",fontFamily:i.fontFamily||"sans-serif"},axisLine:{show:!E.isCollapsed&&c,lineStyle:{color:g}},axisTick:{show:B},splitLine:{show:!1},axisPointer:{label:{show:K,fontSize:11,backgroundColor:"#475569"}}})});const H=[];let Y,at;i.yAxisMin!==void 0&&i.yAxisMin!=="auto"?Y=i.yAxisMin:Y=X.createMinFunction(o),i.yAxisMax!==void 0&&i.yAxisMax!=="auto"?at=i.yAxisMax:at=X.createMaxFunction(o),H.push({position:"right",scale:!0,min:Y,max:at,gridIndex:0,splitLine:{show:!n&&p,lineStyle:{color:u,opacity:d}},axisLine:{show:!n&&c,lineStyle:{color:g}},axisLabel:{show:!n,color:"#94a3b8",fontFamily:i.fontFamily||"sans-serif",formatter:E=>{if(i.yAxisLabelFormatter)return i.yAxisLabelFormatter(E);const Z=i.yAxisDecimalPlaces!==void 0?i.yAxisDecimalPlaces:X.autoDetectDecimals(s);return X.formatValue(E,Z)}}});let U=1,nt=-1/0,O=1/0;s&&s.length>0&&(nt=Math.min(...s.map(E=>E.low)),O=Math.max(...s.map(E=>E.high)));const V=new Map;e.forEach((E,Z)=>{E.paneIndex===0&&!E.collapsed&&s&&s.length>0&&Object.entries(E.plots).forEach(([K,B])=>{const lt=`${Z}::${K}`,zt=["background","barcolor"],j=(B.options.style==="shape"||B.options.style==="char")&&(B.options.location==="abovebar"||B.options.location==="AboveBar"||B.options.location==="ab"||B.options.location==="belowbar"||B.options.location==="BelowBar"||B.options.location==="bl"||B.options.location==="absolute"||B.options.location==="Absolute");if(zt.includes(B.options.style)){V.has(lt)||(V.set(lt,U),U++);return}if((B.options.style==="shape"||B.options.style==="char")&&!j){V.has(lt)||(V.set(lt,U),U++);return}const Q=[];if(B.data&&Object.values(B.data).forEach(N=>{typeof N=="number"&&!isNaN(N)&&isFinite(N)&&Q.push(N)}),Q.length>0){const N=Math.min(...Q),et=Math.max(...Q),Rt=et-N,Ot=O-nt,xt=N>=nt*.5&&et<=O*1.5,Ht=Rt>Ot*.01;xt&&Ht||V.has(lt)||(V.set(lt,U),U++)}})});const ae=V.size>0?U-1:0,qt=new Set;V.forEach((E,Z)=>{e.forEach(K=>{Object.entries(K.plots).forEach(([B,lt])=>{`${K.id}::${B}`===Z&&["background","barcolor","char"].includes(lt.options.style)&&qt.add(E)})})});for(let E=0;E<ae;E++){const Z=E+1,K=qt.has(Z);H.push({position:"left",scale:!K,min:K?0:X.createMinFunction(o),max:K?1:X.createMaxFunction(o),gridIndex:0,show:!1,splitLine:{show:!1},axisLine:{show:!1},axisLabel:{show:!1}})}const Ut=U;L.forEach((E,Z)=>{H.push({position:"right",scale:!0,min:X.createMinFunction(o),max:X.createMaxFunction(o),gridIndex:Z+1,splitLine:{show:!E.isCollapsed&&p,lineStyle:{color:u,opacity:d*.6}},axisLabel:{show:!E.isCollapsed,color:"#94a3b8",fontFamily:i.fontFamily||"sans-serif",fontSize:10,formatter:K=>{if(i.yAxisLabelFormatter)return i.yAxisLabelFormatter(K);const B=i.yAxisDecimalPlaces!==void 0?i.yAxisDecimalPlaces:X.autoDetectDecimals(s);return X.formatValue(K,B)}},axisLine:{show:!E.isCollapsed&&c,lineStyle:{color:g}}})});const kt=[],po=i.dataZoom?.zoomOnTouch??!0,uo=i.dataZoom?.pannable??!0;return po&&uo&&kt.push({type:"inside",xAxisIndex:M,start:A,end:w,filterMode:"weakFilter"}),I&&(v==="top"?kt.push({type:"slider",xAxisIndex:M,top:"1%",height:k+"%",start:A,end:w,borderColor:"#334155",textStyle:{color:"#cbd5e1"},brushSelect:!1,filterMode:"weakFilter"}):kt.push({type:"slider",xAxisIndex:M,bottom:"1%",height:k+"%",start:A,end:w,borderColor:"#334155",textStyle:{color:"#cbd5e1"},brushSelect:!1,filterMode:"weakFilter"})),{grid:G,xAxis:R,yAxis:H,dataZoom:kt,paneLayout:L,mainPaneHeight:S,mainPaneTop:b,pixelToPercent:a,paneBoundaries:P,overlayYAxisMap:V,separatePaneYAxisOffset:Ut}}static calculateMaximized(t,e,i){return{grid:[],xAxis:[],yAxis:[],dataZoom:[],paneLayout:[],mainPaneHeight:0,mainPaneTop:0,pixelToPercent:0,paneBoundaries:[]}}}class ri{render(t){const{seriesName:e,xAxisIndex:i,yAxisIndex:n,dataArray:r,colorArray:s,plotOptions:l}=t,a="#2962ff";return{name:e,type:"custom",xAxisIndex:i,yAxisIndex:n,renderItem:(o,p)=>{const u=o.dataIndex;if(u===0)return;const d=p.value(1),g=p.value(2);if(d===null||isNaN(d)||g===null||isNaN(g))return;const c=p.coord([u-1,g]),y=p.coord([u,d]);return{type:"line",shape:{x1:c[0],y1:c[1],x2:y[0],y2:y[1]},style:{stroke:s[u]||l.color||a,lineWidth:l.linewidth||1},silent:!0}},data:r.map((o,p)=>[p,o,p>0?r[p-1]:null])}}}class ai{render(t){const{seriesName:e,xAxisIndex:i,yAxisIndex:n,dataArray:r,colorArray:s,plotOptions:l}=t,a="#2962ff";return{name:e,type:"custom",xAxisIndex:i,yAxisIndex:n,renderItem:(o,p)=>{const u=p.value(0),d=p.value(1);if(isNaN(d)||d===null)return;const g=p.coord([u,d]),c=p.size([1,0])[0];return{type:"line",shape:{x1:g[0]-c/2,y1:g[1],x2:g[0]+c/2,y2:g[1]},style:{stroke:s[o.dataIndex]||l.color||a,lineWidth:l.linewidth||1},silent:!0}},data:r.map((o,p)=>[p,o])}}}class he{render(t){const{seriesName:e,xAxisIndex:i,yAxisIndex:n,dataArray:r,colorArray:s,plotOptions:l}=t,a="#2962ff",o=l.histbase??0,p=l.style==="columns",u=l.linewidth??1,d=r.map((g,c)=>g==null||typeof g=="number"&&isNaN(g)?null:[c,g,s[c]||l.color||a]);return{name:e,type:"custom",xAxisIndex:i,yAxisIndex:n,renderItem:(g,c)=>{const y=c.value(0),f=c.value(1),x=c.value(2);if(f==null||isNaN(f))return null;const m=c.coord([y,o]),I=c.coord([y,f]),v=c.size([1,0])[0];let k;p?k=v*.6:k=Math.max(1,u);const A=m[0],w=m[1],b=I[1],C=Math.min(w,b),_=Math.abs(b-w);return{type:"rect",shape:{x:A-k/2,y:C,width:k,height:_||1},style:{fill:x}}},data:d.filter(g=>g!==null)}}}const Jt=new Map;function ce(h,t="#00da3c",e="64px"){if(typeof document>"u")return"";const i=`${h}-${t}-${e}`;if(Jt.has(i))return Jt.get(i);const n=document.createElement("canvas"),r=n.getContext("2d");if(n.width=32,n.height=32,r){r.font="bold "+e+" Arial",r.fillStyle=t,r.textAlign="center",r.textBaseline="middle",r.fillText(h,16,16);const s=n.toDataURL("image/png");return Jt.set(i,s),s}return""}class Qt{render(t){const{seriesName:e,xAxisIndex:i,yAxisIndex:n,dataArray:r,colorArray:s,plotOptions:l}=t,a="#2962ff",o=l.style;if(o==="char"){const{optionsArray:u,candlestickData:d}=t,g=l.char||"\u2022",c=l.location||"abovebar",y=r.map((f,x)=>{if(f==null||typeof f=="number"&&isNaN(f))return null;const m=u?.[x]||{},I=m.char||g,v=m.color||s[x]||l.color||a,k=m.location||c,A=m.size||l.size||"normal";let w=f,b=[0,0];k==="abovebar"||k==="AboveBar"||k==="ab"?(d&&d[x]&&(w=d[x].high),b=[0,"-150%"]):(k==="belowbar"||k==="BelowBar"||k==="bl")&&(d&&d[x]&&(w=d[x].low),b=[0,"150%"]);const C={tiny:"18px",small:"26px",normal:"34px",large:"42px",huge:"54px",auto:"28px"}[A]||"34px";return{value:[x,w],symbol:`image://${ce(I,v,C)}`,symbolSize:parseInt(C)+8,symbolOffset:b}}).filter(f=>f!==null);return{name:e,type:"scatter",xAxisIndex:i,yAxisIndex:n,z:10,data:y}}const p=r.map((u,d)=>{if(u===null)return null;const g=s[d]||l.color||a,c={value:[d,u],itemStyle:{color:g}};return o==="cross"?(c.symbol=`image://${ce("+",g,"24px")}`,c.symbolSize=16):(c.symbol="circle",c.symbolSize=6),c}).filter(u=>u!==null);return{name:e,type:"scatter",xAxisIndex:i,yAxisIndex:n,data:p}}}class de{render(t){const{seriesName:e,xAxisIndex:i,yAxisIndex:n,dataArray:r,colorArray:s,optionsArray:l,plotOptions:a}=t,o="#2962ff",p=a.style==="candle",u=[],d=r.map((g,c)=>{if(g===null||!Array.isArray(g)||g.length!==4)return null;const[y,f,x,m]=g,I=l[c]||{},v=I.color||s[c]||a.color||o,k=I.wickcolor||a.wickcolor||v,A=I.bordercolor||a.bordercolor||k;return u[c]={color:v,wickColor:k,borderColor:A},[c,y,m,x,f]}).filter(g=>g!==null);return{name:e,type:"custom",xAxisIndex:i,yAxisIndex:n,renderItem:(g,c)=>{const y=c.value(0),f=c.value(1),x=c.value(2),m=c.value(3),I=c.value(4);if(isNaN(f)||isNaN(x)||isNaN(m)||isNaN(I))return null;const v=u[y]||{color:o,wickColor:o,borderColor:o},k=v.color,A=v.wickColor,w=v.borderColor,b=c.coord([y,0])[0],C=c.coord([y,f])[1],_=c.coord([y,x])[1],z=c.coord([y,m])[1],S=c.coord([y,I])[1],$=c.size([1,0])[0]*.6;if(p){const L=Math.min(C,_),P=Math.max(C,_),G=Math.abs(_-C);return{type:"group",children:[{type:"line",shape:{x1:b,y1:S,x2:b,y2:L},style:{stroke:A,lineWidth:1}},{type:"line",shape:{x1:b,y1:P,x2:b,y2:z},style:{stroke:A,lineWidth:1}},{type:"rect",shape:{x:b-$/2,y:L,width:$,height:G||1},style:{fill:k,stroke:w,lineWidth:1}}]}}else{const L=$*.5;return{type:"group",children:[{type:"line",shape:{x1:b,y1:z,x2:b,y2:S},style:{stroke:k,lineWidth:1}},{type:"line",shape:{x1:b-L,y1:C,x2:b,y2:C},style:{stroke:k,lineWidth:1}},{type:"line",shape:{x1:b,y1:_,x2:b+L,y2:_},style:{stroke:k,lineWidth:1}}]}}},data:d}}}class Dt{static getShapeSymbol(t){switch(t){case"arrowdown":case"shape_arrow_down":return"path://M12 24l-12-12h8v-12h8v12h8z";case"arrowup":case"shape_arrow_up":return"path://M12 0l12 12h-8v12h-8v-12h-8z";case"circle":case"shape_circle":return"circle";case"cross":case"shape_cross":return"path://M11 2h2v9h9v2h-9v9h-2v-9h-9v-2h9z";case"diamond":case"shape_diamond":return"diamond";case"flag":case"shape_flag":return"path://M6 2v20h2v-8h12l-2-6 2-6h-12z";case"labeldown":case"shape_label_down":return"path://M2 1h20a1 1 0 0 1 1 1v14a1 1 0 0 1-1 1h-8l-2 3-2-3h-8a1 1 0 0 1-1-1v-14a1 1 0 0 1 1-1z";case"labelleft":case"shape_label_left":return"path://M0 10l3-3v-5a1 1 0 0 1 1-1h18a1 1 0 0 1 1 1v16a1 1 0 0 1-1 1h-18a1 1 0 0 1-1-1v-5z";case"labelright":case"shape_label_right":return"path://M24 10l-3-3v-5a1 1 0 0 0-1-1h-18a1 1 0 0 0-1 1v16a1 1 0 0 0 1 1h18a1 1 0 0 0 1-1v-5z";case"labelup":case"shape_label_up":return"path://M12 1l2 3h8a1 1 0 0 1 1 1v14a1 1 0 0 1-1 1h-20a1 1 0 0 1-1-1v-14a1 1 0 0 1 1-1h8z";case"square":case"shape_square":return"rect";case"triangledown":case"shape_triangle_down":return"path://M12 21l-10-18h20z";case"triangleup":case"shape_triangle_up":return"triangle";case"xcross":case"shape_xcross":return"path://M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z";default:return"circle"}}static getShapeRotation(t){return 0}static getShapeSize(t,e,i){if(e!==void 0&&i!==void 0)return[e,i];let n;switch(t){case"tiny":n=8;break;case"small":n=12;break;case"normal":case"auto":n=16;break;case"large":n=24;break;case"huge":n=32;break;default:n=16}return e!==void 0?[e,e]:i!==void 0?[i,i]:n}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 li{render(t){const{seriesName:e,xAxisIndex:i,yAxisIndex:n,dataArray:r,colorArray:s,optionsArray:l,plotOptions:a,candlestickData:o}=t,p="#2962ff",u=r.map((d,g)=>{const c=l[g]||{},y=a,f=c.location||y.location||"absolute";if(f!=="absolute"&&f!=="Absolute"&&!d||d==null)return null;const x=c.color||y.color||p,m=c.shape||y.shape||"circle",I=c.size||y.size||"normal",v=c.text||y.text,k=c.textcolor||y.textcolor||"white",A=c.width||y.width,w=c.height||y.height;let b=d,C=[0,0];const _=m.includes("label_up")||m==="labelup",z=m.includes("label_down")||m==="labeldown";f==="abovebar"||f==="AboveBar"||f==="ab"?(o&&o[g]&&(b=o[g].high),C=[0,"-150%"]):f==="belowbar"||f==="BelowBar"||f==="bl"?(o&&o[g]&&(b=o[g].low),C=[0,"150%"]):f==="top"||f==="Top"?(b=d,C=[0,0]):(f==="bottom"||f==="Bottom")&&(b=d,C=[0,0]);const S=Dt.getShapeSymbol(m),$=Dt.getShapeSize(I,A,w),L=Dt.getShapeRotation(m);let P=$;m.includes("label")&&(Array.isArray($)?P=[$[0]*2.5,$[1]*2.5]:P=$*2.5),_?C=[C[0],"50%"]:z&&(C=[C[0],"-50%"]);const G=Dt.getLabelConfig(m,f);return{value:[g,b],symbol:S,symbolSize:P,symbolRotate:L,symbolOffset:C,itemStyle:{color:x},label:{show:!!v,position:G.position,distance:G.distance,formatter:v,color:k,fontSize:10,fontWeight:"bold"}}}).filter(d=>d!==null);return{name:e,type:"scatter",xAxisIndex:i,yAxisIndex:n,z:10,data:u}}}class ht{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 n=e[1],r=e[2],s=e[3],l=e[4]?parseFloat(e[4]):1;return{color:`rgb(${n},${r},${s})`,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 n=parseInt(i[1],16),r=parseInt(i[2],16),s=parseInt(i[3],16),l=parseInt(i[4],16)/255;return{color:`rgb(${n},${r},${s})`,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 n=t.match(/^#([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/);if(n){const s=parseInt(n[1],16),l=parseInt(n[2],16),a=parseInt(n[3],16);return`rgba(${s},${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 s=parseInt(r[1],16),l=parseInt(r[2],16),a=parseInt(r[3],16);return`rgba(${s},${l},${a},${e})`}return t}}class hi{render(t){const{seriesName:e,xAxisIndex:i,yAxisIndex:n,dataArray:r,colorArray:s}=t,l=[];for(let a=0;a<s.length;a++)l[a]=s[a]?ht.parseColor(s[a]):{color:"",opacity:0};return{name:e,type:"custom",xAxisIndex:i,yAxisIndex:n,z:-10,renderItem:(a,o)=>{const p=o.value(0);if(isNaN(p))return;const u=o.coord([p,.5]),d=o.size([1,0])[0],g=a.coordSys,c=u[0]-d/2,y=s[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:c,y:g.y,width:d,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 pe{render(t){const{seriesName:e,xAxisIndex:i,yAxisIndex:n,plotOptions:r,plotDataArrays:s,indicatorId:l,plotName:a,optionsArray:o}=t,p=t.dataArray.length,u=r.plot1?`${l}::${r.plot1}`:null,d=r.plot2?`${l}::${r.plot2}`:null;if(!u||!d)return console.warn(`Fill plot "${a}" missing plot1 or plot2 reference`),null;const g=s?.get(u),c=s?.get(d);if(!g||!c)return console.warn(`Fill plot "${a}" references non-existent plots: ${r.plot1}, ${r.plot2}`),null;if(r.gradient===!0)return this.renderGradientFill(e,i,n,g,c,p,o,r);const{color:y,opacity:f}=ht.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<p;v++){const k=o?.[v];k&&k.color!==void 0?m[v]=ht.parseColor(k.color):m[v]={color:y,opacity:f}}}const I=[];for(let v=0;v<p;v++){const k=g[v],A=c[v],w=v>0?g[v-1]:null,b=v>0?c[v-1]:null;I.push([v,k,A,w,b])}return{name:e,type:"custom",xAxisIndex:i,yAxisIndex:n,z:1,clip:!0,encode:{x:0},animation:!1,renderItem:(v,k)=>{const A=v.dataIndex;if(A===0)return null;const w=k.value(1),b=k.value(2),C=k.value(3),_=k.value(4);if(w===null||b===null||C===null||_===null||isNaN(w)||isNaN(b)||isNaN(C)||isNaN(_))return null;const z=m?m[A]:null,S=z?z.opacity:f;if(S<.01)return null;const $=k.coord([A-1,C]),L=k.coord([A,w]),P=k.coord([A,b]),G=k.coord([A-1,_]);return{type:"polygon",shape:{points:[$,L,P,G]},style:{fill:z?z.color:y,opacity:S},silent:!0}},data:I,silent:!0}}renderBatched(t,e,i,n,r){const s=Array.from({length:n},(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 p=[];for(let u=0;u<r.length;u++){const d=r[u],g=d.plot1Data[o],c=d.plot2Data[o],y=d.plot1Data[o-1],f=d.plot2Data[o-1];if(g==null||c==null||y==null||f==null||isNaN(g)||isNaN(c)||isNaN(y)||isNaN(f))continue;const x=d.barColors[o];if(!x||x.opacity<.01)continue;const m=a.coord([o-1,y]),I=a.coord([o,g]),v=a.coord([o,c]),k=a.coord([o-1,f]);p.push({type:"polygon",shape:{points:[m,I,v,k]},style:{fill:x.color,opacity:x.opacity},silent:!0})}return p.length>0?{type:"group",children:p,silent:!0}:null},data:s,silent:!0}}renderGradientFill(t,e,i,n,r,s,l,a){const o=[];for(let u=0;u<s;u++){const d=l?.[u];if(d&&d.top_color!==void 0){const g=ht.parseColor(d.top_color),c=ht.parseColor(d.bottom_color);o[u]={topColor:g.color,topOpacity:g.opacity,bottomColor:c.color,bottomOpacity:c.opacity}}else o[u]={topColor:"rgba(128,128,128,0.2)",topOpacity:.2,bottomColor:"rgba(128,128,128,0.2)",bottomOpacity:.2}}const p=[];for(let u=0;u<s;u++){const d=n[u],g=r[u],c=u>0?n[u-1]:null,y=u>0?r[u-1]:null;p.push([u,d,g,c,y])}return{name:t,type:"custom",xAxisIndex:e,yAxisIndex:i,z:1,clip:!0,encode:{x:0},animation:!1,renderItem:(u,d)=>{const g=u.dataIndex;if(g===0)return null;const c=d.value(1),y=d.value(2),f=d.value(3),x=d.value(4);if(c===null||y===null||f===null||x===null||isNaN(c)||isNaN(y)||isNaN(f)||isNaN(x))return null;const m=d.coord([g-1,f]),I=d.coord([g,c]),v=d.coord([g,y]),k=d.coord([g-1,x]),A=o[g]||o[g-1];if(!A||A.topOpacity<.01&&A.bottomOpacity<.01)return null;const w=ht.toRgba(A.topColor,A.topOpacity),b=ht.toRgba(A.bottomColor,A.bottomOpacity),C=c>=y;return{type:"polygon",shape:{points:[m,I,v,k]},style:{fill:{type:"linear",x:0,y:0,x2:0,y2:1,colorStops:[{offset:0,color:C?w:b},{offset:1,color:C?b:w}]}},silent:!0}},data:p,silent:!0}}}class ci{render(t){const{seriesName:e,xAxisIndex:i,yAxisIndex:n,dataArray:r,candlestickData:s,dataIndexOffset:l}=t,a=l||0,o=[];for(let u=0;u<r.length;u++){const d=r[u];if(!d)continue;const g=Array.isArray(d)?d:[d];for(const c of g)c&&typeof c=="object"&&!c._deleted&&o.push(c)}const p=o.map(u=>{const d=F=>typeof F=="function"?F():F,g=d(u.text)||"",c=d(u.color),y=c!=null&&c!==""?c:"transparent",f=d(u.textcolor)||"#ffffff",x=d(u.yloc)||"price",m=d(u.style)||"style_label_down",I=d(u.size)||"normal",v=d(u.textalign)||"align_center",k=d(u.tooltip)||"",A=this.styleToShape(m),w=u.xloc==="bar_index"||u.xloc==="bi"?u.x+a:u.x;let b=u.y,C=[0,0];x==="abovebar"||x==="AboveBar"||x==="ab"?(s&&s[w]&&(b=s[w].high),C=[0,"-150%"]):(x==="belowbar"||x==="BelowBar"||x==="bl")&&(s&&s[w]&&(b=s[w].low),C=[0,"150%"]);const _=Dt.getShapeSymbol(A),z=Dt.getShapeSize(I),S=this.getSizePx(I);let $;const L=A==="labeldown"||A==="shape_label_down"||A==="labelup"||A==="shape_label_up"||A==="labelleft"||A==="labelright";let P=[0,0];if(L){const F=g.split(`
|
|
18
|
+
`),J=F.reduce((O,V)=>O.length>V.length?O:V,"").length*S*.65,H=S*2.5,Y=Math.max(H,J+S*1.6),at=S*1.4,U=Math.max(S*2.8,F.length*at+S*1.2),nt=3/24;if(A==="labelleft"||A==="labelright"){const O=Y/(1-nt);$=[O,U];const V=typeof C[0]=="string"?0:C[0];A==="labelleft"?(C=[V+O*.42,C[1]],P=[O*nt*.5,0]):(C=[V-O*.42,C[1]],P=[-O*nt*.5,0])}else{const O=U/(1-nt);$=[Y,O],A==="labeldown"?(C=[C[0],typeof C[1]=="string"?C[1]:C[1]-O*.42],P=[0,-O*nt*.5]):(C=[C[0],typeof C[1]=="string"?C[1]:C[1]+O*.42],P=[0,O*nt*.5])}}else A==="none"?$=0:Array.isArray(z)?$=[z[0]*1.5,z[1]*1.5]:$=z*1.5;const G=this.getLabelPosition(m,x),M=G==="inside"||G.startsWith("inside"),R={value:[w,b],symbol:_,symbolSize:$,symbolOffset:C,itemStyle:{color:y},label:{show:!!g,position:G,distance:M?0:5,offset:P,formatter:g,color:f,fontSize:S,fontWeight:"bold",align:M?"center":v==="align_left"||v==="left"?"left":v==="align_right"||v==="right"?"right":"center",verticalAlign:"middle",padding:[2,6]}};return k?(R._tooltipText=k,R.emphasis={scale:!1,itemStyle:{color:y},label:{show:R.label.show,color:f,fontSize:S,fontWeight:"bold"}}):R.emphasis={disabled:!0},R}).filter(u=>u!==null);return{name:e,type:"scatter",xAxisIndex:i,yAxisIndex:n,data:p,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 di{render(t){const{seriesName:e,xAxisIndex:i,yAxisIndex:n,dataArray:r,dataIndexOffset:s}=t,l=s||0,a="#2962ff",o=[];for(let d=0;d<r.length;d++){const g=r[d];if(!g)continue;const c=Array.isArray(g)?g:[g];for(const y of c)y&&typeof y=="object"&&!y._deleted&&o.push(y)}if(o.length===0)return{name:e,type:"custom",xAxisIndex:i,yAxisIndex:n,data:[],silent:!0};const p=(t.candlestickData?.length||0)+l,u=Math.max(0,p-1);return{name:e,type:"custom",xAxisIndex:i,yAxisIndex:n,renderItem:(d,g)=>{const c=[];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 I=y.extend||"none";if(I!=="none"&&I!=="n"){const w=d.coordSys;[x,m]=this.extendLine(x,m,I,w.x,w.x+w.width,w.y,w.y+w.height)}const v=y.color||a,k=y.width||1;c.push({type:"line",shape:{x1:x[0],y1:x[1],x2:m[0],y2:m[1]},style:{fill:"none",stroke:v,lineWidth:k,lineDash:this.getDashPattern(y.style)}});const A=y.style||"style_solid";if(A==="style_arrow_left"||A==="style_arrow_both"){const w=this.arrowHead(m,x,k,v);w&&c.push(w)}if(A==="style_arrow_right"||A==="style_arrow_both"){const w=this.arrowHead(x,m,k,v);w&&c.push(w)}}return{type:"group",children:c}},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,n,r,s,l){const a=e[0]-t[0],o=e[1]-t[1];if(a===0&&o===0)return[t,e];const p=(g,c)=>{let y=1/0;if(c[0]!==0){const f=c[0]>0?(r-g[0])/c[0]:(n-g[0])/c[0];y=Math.min(y,f)}if(c[1]!==0){const f=c[1]>0?(l-g[1])/c[1]:(s-g[1])/c[1];y=Math.min(y,f)}return isFinite(y)||(y=0),[g[0]+y*c[0],g[1]+y*c[1]]};let u=t,d=e;return(i==="right"||i==="r"||i==="both"||i==="b")&&(d=p(t,[a,o])),(i==="left"||i==="l"||i==="both"||i==="b")&&(u=p(e,[-a,-o])),[u,d]}arrowHead(t,e,i,n){const r=e[0]-t[0],s=e[1]-t[1],l=Math.sqrt(r*r+s*s);if(l<1)return null;const a=Math.max(8,i*4),o=r/l,p=s/l,u=e[0]-o*a,d=e[1]-p*a,g=-p*a*.4,c=o*a*.4;return{type:"polygon",shape:{points:[[e[0],e[1]],[u+g,d+c],[u-g,d-c]]},style:{fill:n}}}}class pi{render(t){const{seriesName:e,xAxisIndex:i,yAxisIndex:n,dataArray:r,dataIndexOffset:s}=t,l=s||0,a=[];for(let u=0;u<r.length;u++){const d=r[u];if(!d)continue;const g=Array.isArray(d)?d:[d];for(const c of g){if(!c||typeof c!="object"||c._deleted)continue;const y=c.line1,f=c.line2;!y||!f||y._deleted||f._deleted||a.push(c)}}if(a.length===0)return{name:e,type:"custom",xAxisIndex:i,yAxisIndex:n,data:[],silent:!0};const o=(t.candlestickData?.length||0)+l,p=Math.max(0,o-1);return{name:e,type:"custom",xAxisIndex:i,yAxisIndex:n,renderItem:(u,d)=>{const g=[];for(const c of a){if(c._deleted)continue;const y=c.line1,f=c.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 I=d.coord([y.x1+x,y.y1]),v=d.coord([y.x2+x,y.y2]),k=d.coord([f.x1+m,f.y1]),A=d.coord([f.x2+m,f.y2]);const w=y.extend||"none",b=f.extend||"none";if(w!=="none"||b!=="none"){const z=u.coordSys,S=z.x,$=z.x+z.width,L=z.y,P=z.y+z.height;w!=="none"&&([I,v]=this.extendLine(I,v,w,S,$,L,P)),b!=="none"&&([k,A]=this.extendLine(k,A,b,S,$,L,P))}const{color:C,opacity:_}=ht.parseColor(c.color||"rgba(128, 128, 128, 0.2)");g.push({type:"polygon",shape:{points:[I,v,A,k]},style:{fill:C,opacity:_},silent:!0})}return{type:"group",children:g}},data:[[0,p]],clip:!0,encode:{x:[0,1]},z:10,silent:!0,emphasis:{disabled:!0}}}extendLine(t,e,i,n,r,s,l){const a=e[0]-t[0],o=e[1]-t[1];if(a===0&&o===0)return[t,e];const p=(g,c)=>{let y=1/0;if(c[0]!==0){const f=c[0]>0?(r-g[0])/c[0]:(n-g[0])/c[0];y=Math.min(y,f)}if(c[1]!==0){const f=c[1]>0?(l-g[1])/c[1]:(s-g[1])/c[1];y=Math.min(y,f)}return isFinite(y)||(y=0),[g[0]+y*c[0],g[1]+y*c[1]]};let u=t,d=e;return(i==="right"||i==="both")&&(d=p(t,[a,o])),(i==="left"||i==="both")&&(u=p(e,[-a,-o])),[u,d]}}class ui{render(t){const{seriesName:e,xAxisIndex:i,yAxisIndex:n,dataArray:r,dataIndexOffset:s}=t,l=s||0,a=[];for(let u=0;u<r.length;u++){const d=r[u];if(!d)continue;const g=Array.isArray(d)?d:[d];for(const c of g)c&&typeof c=="object"&&!c._deleted&&c.points&&c.points.length>=2&&a.push(c)}if(a.length===0)return{name:e,type:"custom",xAxisIndex:i,yAxisIndex:n,data:[],silent:!0};const o=(t.candlestickData?.length||0)+l,p=Math.max(0,o-1);return{name:e,type:"custom",xAxisIndex:i,yAxisIndex:n,renderItem:(u,d)=>{const g=[];for(const c of a){if(c._deleted)continue;const y=c.points;if(!y||y.length<2)continue;const f=c.xloc==="bi"||c.xloc==="bar_index",x=f?l:0,m=[];for(const w of y){const b=f?(w.index??0)+x:w.time??0,C=w.price??0;m.push(d.coord([b,C]))}if(m.length<2)continue;const I=c.line_color,v=I==null||typeof I=="number"&&isNaN(I)||I==="na"||I==="NaN"?null:I||"#2962ff",k=c.line_width||1,A=this.getDashPattern(c.line_style);if(c.fill_color&&c.fill_color!==""&&c.fill_color!=="na"){const{color:w,opacity:b}=ht.parseColor(c.fill_color);if(c.curved){const C=this.buildCurvedPath(m,c.closed);g.push({type:"path",shape:{pathData:C+" Z"},style:{fill:w,opacity:b,stroke:"none"},silent:!0})}else g.push({type:"polygon",shape:{points:m},style:{fill:w,opacity:b,stroke:"none"},silent:!0})}if(v&&k>0)if(c.curved){const w=this.buildCurvedPath(m,c.closed);g.push({type:"path",shape:{pathData:w},style:{fill:"none",stroke:v,lineWidth:k,lineDash:A},silent:!0})}else{const w=c.closed?[...m,m[0]]:m;g.push({type:"polyline",shape:{points:w},style:{fill:"none",stroke:v,lineWidth:k,lineDash:A},silent:!0})}}return{type:"group",children:g}},data:[[0,p]],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 n=.5;let r=`M ${t[0][0]} ${t[0][1]}`;const s=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=s(a-1),p=s(a),u=s(a+1),d=s(a+2),g=p[0]+(u[0]-o[0])*n/3,c=p[1]+(u[1]-o[1])*n/3,y=u[0]-(d[0]-p[0])*n/3,f=u[1]-(d[1]-p[1])*n/3;r+=` C ${g} ${c}, ${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 te(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),n=parseInt(t.slice(4,6),16),r=parseInt(t.slice(6,8),16)/255;return`rgba(${e},${i},${n},${r.toFixed(3)})`}}return h}function gi(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),n=parseInt(e.slice(2,4),16),r=parseInt(e.slice(4,6),16);if(!isNaN(i)&&!isNaN(n)&&!isNaN(r))return{r:i,g:n,b:r}}if(e.length===3){const i=parseInt(e[0]+e[0],16),n=parseInt(e[1]+e[1],16),r=parseInt(e[2]+e[2],16);if(!isNaN(i)&&!isNaN(n)&&!isNaN(r))return{r:i,g:n,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 yi(h,t,e){return(.299*h+.587*t+.114*e)/255}class fi{render(t){const{seriesName:e,xAxisIndex:i,yAxisIndex:n,dataArray:r,dataIndexOffset:s}=t,l=s||0,a=[];for(let u=0;u<r.length;u++){const d=r[u];if(!d)continue;const g=Array.isArray(d)?d:[d];for(const c of g)c&&typeof c=="object"&&!c._deleted&&a.push(c)}if(a.length===0)return{name:e,type:"custom",xAxisIndex:i,yAxisIndex:n,data:[],silent:!0};const o=(t.candlestickData?.length||0)+l,p=Math.max(0,o-1);return{name:e,type:"custom",xAxisIndex:i,yAxisIndex:n,renderItem:(u,d)=>{const g=[];for(const c of a){if(c._deleted)continue;const y=c.xloc==="bar_index"||c.xloc==="bi"?l:0,f=d.coord([c.left+y,c.top]),x=d.coord([c.right+y,c.bottom]);let m=f[0],I=f[1],v=x[0]-f[0],k=x[1]-f[1];const A=c.extend||"none";if(A!=="none"&&A!=="n"){const S=u.coordSys;(A==="left"||A==="l"||A==="both"||A==="b")&&(m=S.x,v=A==="both"||A==="b"?S.width:x[0]-S.x),(A==="right"||A==="r"||A==="both"||A==="b")&&(A==="right"||A==="r")&&(v=S.x+S.width-f[0])}const w=c.bgcolor,b=w==null||typeof w=="number"&&isNaN(w)||w==="na"||w==="NaN"||w===""?null:te(w)||"#2962ff";b&&g.push({type:"rect",shape:{x:m,y:I,width:v,height:k},style:{fill:b,stroke:"none"}});const C=c.border_color,_=C==null||typeof C=="number"&&isNaN(C)||C==="na"||C==="NaN"?null:te(C)||"#2962ff",z=c.border_width??1;if(z>0&&_&&g.push({type:"rect",shape:{x:m,y:I,width:v,height:k},style:{fill:"none",stroke:_,lineWidth:z,lineDash:this.getDashPattern(c.border_style)}}),c.text){const S=this.getTextX(m,v,c.text_halign),$=this.getTextY(I,k,c.text_valign);let L=te(c.text_color)||"#000000";if((!c.text_color||c.text_color==="#000000"||c.text_color==="black"||c.text_color==="color.black")&&b){const M=gi(b);M&&yi(M.r,M.g,M.b)<.5&&(L="#FFFFFF")}const P=!c.text_formatting||c.text_formatting==="format_none"||c.text_formatting==="format_bold",G=this.computeFontSize(c.text_size,c.text,Math.abs(v),Math.abs(k),P);g.push({type:"text",style:{x:S,y:$,text:c.text,fill:L,fontSize:G,fontFamily:c.text_font_family==="monospace"?"monospace":"sans-serif",fontWeight:P?"bold":"normal",fontStyle:c.text_formatting==="format_italic"?"italic":"normal",textAlign:this.mapHAlign(c.text_halign),textVerticalAlign:this.mapVAlign(c.text_valign)}})}}return{type:"group",children:g}},data:[[0,p]],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,n,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||n<=0)return 12;const s=6,l=i-s*2,a=n-s*2;if(l<=0||a<=0)return 6;const o=e.split(`
|
|
19
|
+
`),p=o.length;let u=1;for(const y of o)y.length>u&&(u=y.length);const d=l/(u*(r?.62:.55)),g=a/(p*1.3),c=Math.min(d,g);return Math.max(6,Math.min(c,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 xi=Object.defineProperty,mi=(h,t,e)=>t in h?xi(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,bi=(h,t,e)=>(mi(h,typeof t!="symbol"?t+"":t,e),e);const tt=class{static register(t,e){this.renderers.set(t,e)}static get(t){return this.renderers.get(t)||this.renderers.get("line")}};bi(tt,"renderers",new Map),tt.register("line",new ri),tt.register("step",new ai),tt.register("histogram",new he),tt.register("columns",new he),tt.register("circles",new Qt),tt.register("cross",new Qt),tt.register("char",new Qt),tt.register("bar",new de),tt.register("candle",new de),tt.register("shape",new li),tt.register("background",new hi),tt.register("fill",new pe),tt.register("label",new ci),tt.register("drawing_line",new di),tt.register("linefill",new pi),tt.register("drawing_polyline",new ui),tt.register("drawing_box",new fi);let vi=tt;var wi=Object.defineProperty,Ci=(h,t,e)=>t in h?wi(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,Pi=(h,t,e)=>(Ci(h,typeof t!="symbol"?t+"":t,e),e);const ue=class le{static buildCandlestickSeries(t,e,i){const n=e.upColor||"#00da3c",r=e.downColor||"#ec0000",s=t.map(a=>[a.open,a.close,a.low,a.high]);if(i&&i>s.length){const a=i-s.length;for(let o=0;o<a;o++)s.push(null)}let l;if(e.lastPriceLine?.visible!==!1&&t.length>0){const a=t[t.length-1],o=a.close,p=a.close>=a.open,u=e.lastPriceLine?.color||(p?n:r);let d=e.lastPriceLine?.lineStyle||"dashed";d.startsWith("linestyle_")&&(d=d.replace("linestyle_",""));const g=e.yAxisDecimalPlaces!==void 0?e.yAxisDecimalPlaces:X.autoDetectDecimals(t);l={symbol:["none","none"],precision:g,data:[{yAxis:o,label:{show:!0,position:"end",formatter:c=>e.yAxisLabelFormatter?e.yAxisLabelFormatter(c.value):X.formatValue(c.value,g),color:"#fff",backgroundColor:u,padding:[2,4],borderRadius:2,fontSize:11,fontWeight:"bold"},lineStyle:{color:u,type:d,width:1,opacity:.8}}],animation:!1,silent:!0}}return{type:"candlestick",id:"__candlestick__",name:e.title,data:s,itemStyle:{color:n,color0:r,borderColor:n,borderColor0:r},markLine:l,xAxisIndex:0,yAxisIndex:0,z:5}}static buildIndicatorSeries(t,e,i,n,r=0,s,l,a=1){const o=[],p=new Array(n).fill(null),u=new Map;return t.forEach((d,g)=>{if(d.collapsed)return;const c=Object.keys(d.plots).sort((f,x)=>{const m=d.plots[f],I=d.plots[x],v=m.options.style==="fill",k=I.options.style==="fill";return v&&!k?1:!v&&k?-1:0}),y=new Map;if(c.forEach(f=>{const x=d.plots[f],m=x.options.display==="none",I=`${g}::${f}`;let v=0,k=0,A=x.options.overlay;if(x.options.style==="fill"&&A===void 0){const S=x.options.plot1,$=x.options.plot2;if(S&&$){const L=d.plots[S],P=d.plots[$];(L?.options?.overlay===!0||P?.options?.overlay===!0)&&(A=!0)}}if(d.paneIndex===0||A===!0)v=0,l&&l.has(I)?k=l.get(I):k=0;else{const S=i.findIndex($=>$.index===d.paneIndex);S!==-1&&(v=S+1,k=a+S)}const w=new Array(n).fill(null),b=new Array(n).fill(null),C=new Array(n).fill(null),_=new Array(n).fill(null);if(x.data?.forEach(S=>{const $=e.get(S.time);if($!==void 0){const L=S.options?.offset??x.options.offset??0,P=$+r+L;if(P>=0&&P<n){let G=S.value;const M=S.options?.color;b[P]=G;const R=S.options!=null&&"color"in S.options,F=M===null||M==="na"||M==="NaN"||typeof M=="number"&&isNaN(M)||R&&M===void 0;F&&(G=null),w[P]=G,C[P]=F?null:M||x.options.color||le.DEFAULT_COLOR,_[P]=S.options||{}}}}),u.set(`${g}::${f}`,b),m)return;if(x.options?.style?.startsWith("style_")&&(x.options.style=x.options.style.replace("style_","")),x.options.style==="barcolor"){x.data?.forEach(S=>{const $=e.get(S.time);if($!==void 0){const L=S.options?.offset??x.options.offset??0,P=$+r+L;if(P>=0&&P<n){const G=S.options?.color||x.options.color||le.DEFAULT_COLOR;!(G===null||G==="na"||G==="NaN"||typeof G=="number"&&isNaN(G))&&S.value!==null&&S.value!==void 0&&(p[P]=G)}}});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,$=x.options.plot2?`${g}::${x.options.plot2}`:null;if(S&&$){const L=u.get(S),P=u.get($);if(L&&P){const{color:G,opacity:M}=ht.parseColor(x.options.color||"rgba(128, 128, 128, 0.2)"),R=_.some(H=>H&&H.color!==void 0),F=[];for(let H=0;H<n;H++){const Y=_[H];R&&Y&&Y.color!==void 0?F[H]=ht.parseColor(Y.color):F[H]={color:G,opacity:M}}const J=`${v}:${k}`;y.has(J)||y.set(J,{entries:[],xAxisIndex:v,yAxisIndex:k}),y.get(J).entries.push({plot1Data:L,plot2Data:P,barColors:F});return}}}{const S=x.options.color;let $=!1;if(S==null?$=!C.some(L=>L!=null):typeof S=="string"&&ht.parseColor(S).opacity<.01&&($=!C.some(L=>L==null?!1:ht.parseColor(L).opacity>=.01)),$)return}const z=vi.get(x.options.style).render({seriesName:I,xAxisIndex:v,yAxisIndex:k,dataArray:w,colorArray:C,optionsArray:_,plotOptions:x.options,candlestickData:s,plotDataArrays:u,indicatorId:g,plotName:f,dataIndexOffset:r});z&&o.push(z)}),y.size>0){const f=new pe;y.forEach(({entries:x,xAxisIndex:m,yAxisIndex:I},v)=>{if(x.length>=2){const k=f.renderBatched(`${g}::fills_batch_${v}`,m,I,n,x);k&&o.push(k)}else if(x.length===1){const k=f.renderBatched(`${g}::fills_batch_${v}`,m,I,n,x);k&&o.push(k)}})}}),{series:o,barColors:p}}};Pi(ue,"DEFAULT_COLOR","#2962ff");let Mt=ue;class ki{static build(t,e,i,n=!1,r=null,s=[]){const l=[],a=t.pixelToPercent,o=t.mainPaneTop;if(!r||r==="main"){const p=10*a;if(l.push({type:"text",left:"8.5%",top:o+p+"%",z:10,style:{text:e.title||"",fill:e.titleColor||"#fff",font:`bold 16px ${e.fontFamily||"sans-serif"}`,textVerticalAlign:"top"}}),s.length>0){const d=20*a,g=16*a;s.forEach((c,y)=>{l.push({type:"text",left:"8.5%",top:o+p+d+y*g+"%",z:10,style:{text:c.id,fill:c.titleColor||"#9e9e9e",font:`bold 12px ${e.fontFamily||"sans-serif"}`,textVerticalAlign:"top"}})})}if(e.watermark!==!1){const d=t.mainPaneTop+t.mainPaneHeight;l.push({type:"text",right:"11%",top:d-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:n?"+":"\u2212",fill:"#cbd5e1",font:`bold 14px ${e.fontFamily}`,x:10,y:10,textAlign:"center",textVerticalAlign:"middle"},silent:!0}]}),e.controls?.maximize){const d=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:d?"\u2750":"\u25A1",fill:"#cbd5e1",font:`14px ${e.fontFamily}`,x:10,y:10,textAlign:"center",textVerticalAlign:"middle"},silent:!0}]})}if(e.controls?.fullscreen){let d=0;e.controls?.collapse&&(d+=25),e.controls?.maximize&&(d+=25),u.push({type:"group",x:d,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(p=>{if(r&&p.indicatorId!==r)return;l.push({type:"text",left:"8.5%",top:p.top+10*a+"%",z:10,style:{text:p.indicatorId||"",fill:p.titleColor||"#fff",font:`bold 12px ${e.fontFamily||"sans-serif"}`,textVerticalAlign:"top"}});const u=[];if(p.controls?.collapse&&u.push({type:"group",children:[{type:"rect",shape:{width:20,height:20,r:2},style:{fill:"#334155",stroke:"#475569",lineWidth:1},onclick:()=>p.indicatorId&&i(p.indicatorId,"collapse")},{type:"text",style:{text:p.isCollapsed?"+":"\u2212",fill:"#cbd5e1",font:`bold 14px ${e.fontFamily}`,x:10,y:10,textAlign:"center",textVerticalAlign:"middle"},silent:!0}]}),p.controls?.maximize){const d=r===p.indicatorId,g=p.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:()=>p.indicatorId&&i(p.indicatorId,"maximize")},{type:"text",style:{text:d?"\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:p.top+"%",children:u})}),l}}class Di{static format(t,e){if(!t||t.length===0)return"";const i=e.title||"",n=e.upColor||"#00da3c",r=e.downColor||"#ec0000",s=e.fontFamily||"sans-serif",l=t[0].axisValue;let a=`<div style="font-weight: bold; margin-bottom: 5px; color: #cbd5e1; font-family: ${s};">${l}</div>`;const o=t.find(u=>u.seriesType==="candlestick"),p=t.filter(u=>u.seriesType!=="candlestick");if(o){const[u,d,g,c,y]=o.value,f=g>=d?n:r;a+=`
|
|
20
|
+
<div style="margin-bottom: 8px; font-family: ${s};">
|
|
21
|
+
<div style="display:flex; justify-content:space-between; color:${f}; font-weight:bold;">
|
|
21
22
|
<span>${i}</span>
|
|
22
23
|
</div>
|
|
23
24
|
<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>=
|
|
25
|
-
<span>High:</span> <span style="text-align: right; color: ${
|
|
26
|
-
<span>Low:</span> <span style="text-align: right; color: ${
|
|
27
|
-
<span>Close:</span> <span style="text-align: right; color: ${g>=
|
|
25
|
+
<span>Open:</span> <span style="text-align: right; color: ${g>=d?n:r}">${d}</span>
|
|
26
|
+
<span>High:</span> <span style="text-align: right; color: ${n}">${y}</span>
|
|
27
|
+
<span>Low:</span> <span style="text-align: right; color: ${r}">${c}</span>
|
|
28
|
+
<span>Close:</span> <span style="text-align: right; color: ${g>=d?n:r}">${g}</span>
|
|
28
29
|
</div>
|
|
29
30
|
</div>
|
|
30
|
-
`}if(
|
|
31
|
-
<div style="margin-top: 8px; font-family: ${
|
|
32
|
-
<div style="font-weight:bold; color: #fff; margin-bottom: 2px;">${
|
|
33
|
-
`,
|
|
31
|
+
`}if(p.length>0){a+='<div style="border-top: 1px solid #334155; margin: 5px 0; padding-top: 5px;"></div>';const u={};p.forEach(d=>{const g=d.seriesName.split("::"),c=g.length>1?g[0]:"Unknown",y=g.length>1?g[1]:d.seriesName;u[c]||(u[c]=[]),u[c].push({...d,displayName:y})}),Object.keys(u).forEach(d=>{a+=`
|
|
32
|
+
<div style="margin-top: 8px; font-family: ${s};">
|
|
33
|
+
<div style="font-weight:bold; color: #fff; margin-bottom: 2px;">${d}</div>
|
|
34
|
+
`,u[d].forEach(g=>{let c=g.value;if(Array.isArray(c)&&(c=c[1]),c==null)return;const y=typeof c=="number"?c.toLocaleString(void 0,{maximumFractionDigits:4}):c;a+=`
|
|
34
35
|
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 2px; padding-left: 8px;">
|
|
35
36
|
<div>${g.marker} <span style="color: #cbd5e1;">${g.displayName}</span></div>
|
|
36
|
-
<div style="font-size: 10px; color: #fff;padding-left:10px;">${
|
|
37
|
-
</div>`}),r+="</div>"})}return r}}var ri=Object.defineProperty,li=(d,t,e)=>t in d?ri(d,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):d[t]=e,Ct=(d,t,e)=>(li(d,typeof t!="symbol"?t+"":t,e),e);class hi{constructor(t,e){Ct(this,"plugins",new Map),Ct(this,"activePluginId",null),Ct(this,"context"),Ct(this,"toolbarContainer"),Ct(this,"tooltipElement",null),Ct(this,"hideTimeout",null),this.context=t,this.toolbarContainer=e,this.createTooltip(),this.renderToolbar()}createTooltip(){this.tooltipElement=document.createElement("div"),Object.assign(this.tooltipElement.style,{position:"fixed",display:"none",backgroundColor:"#1e293b",color:"#e2e8f0",padding:"6px 10px",borderRadius:"6px",fontSize:"13px",lineHeight:"1.4",fontWeight:"500",border:"1px solid #334155",zIndex:"9999",pointerEvents:"none",whiteSpace:"nowrap",boxShadow:"0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.15)",fontFamily:this.context.getOptions().fontFamily||"sans-serif",transition:"opacity 0.15s ease-in-out, transform 0.15s ease-in-out",opacity:"0",transform:"translateX(-5px)"}),document.body.appendChild(this.tooltipElement)}destroy(){this.tooltipElement&&this.tooltipElement.parentNode&&this.tooltipElement.parentNode.removeChild(this.tooltipElement),this.tooltipElement=null}showTooltip(t,e){if(!this.tooltipElement)return;this.hideTimeout&&(clearTimeout(this.hideTimeout),this.hideTimeout=null);const i=t.getBoundingClientRect();this.tooltipElement.textContent=e,this.tooltipElement.style.display="block";const s=this.tooltipElement.getBoundingClientRect(),a=i.top+(i.height-s.height)/2,n=i.right+10;this.tooltipElement.style.top=`${a}px`,this.tooltipElement.style.left=`${n}px`,requestAnimationFrame(()=>{this.tooltipElement&&(this.tooltipElement.style.opacity="1",this.tooltipElement.style.transform="translateX(0)")})}hideTooltip(){this.tooltipElement&&(this.tooltipElement.style.opacity="0",this.tooltipElement.style.transform="translateX(-5px)",this.hideTimeout&&clearTimeout(this.hideTimeout),this.hideTimeout=setTimeout(()=>{this.tooltipElement&&(this.tooltipElement.style.display="none"),this.hideTimeout=null},150))}register(t){if(this.plugins.has(t.id)){console.warn(`Plugin with id ${t.id} is already registered.`);return}this.plugins.set(t.id,t),t.init(this.context),this.addButton(t)}unregister(t){const e=this.plugins.get(t);e&&(this.activePluginId===t&&this.deactivatePlugin(),e.destroy?.(),this.plugins.delete(t),this.removeButton(t))}activatePlugin(t){if(this.activePluginId===t){this.deactivatePlugin();return}this.activePluginId&&this.deactivatePlugin();const e=this.plugins.get(t);e&&(this.activePluginId=t,this.setButtonActive(t,!0),e.activate?.())}deactivatePlugin(){this.activePluginId&&(this.plugins.get(this.activePluginId)?.deactivate?.(),this.setButtonActive(this.activePluginId,!1),this.activePluginId=null)}renderToolbar(){this.toolbarContainer.innerHTML="",this.toolbarContainer.classList.add("qfchart-toolbar"),this.toolbarContainer.style.display="flex",this.toolbarContainer.style.flexDirection="column",this.toolbarContainer.style.width="40px",this.toolbarContainer.style.backgroundColor=this.context.getOptions().backgroundColor||"#1e293b",this.toolbarContainer.style.borderRight="1px solid #334155",this.toolbarContainer.style.padding="5px",this.toolbarContainer.style.boxSizing="border-box",this.toolbarContainer.style.gap="5px",this.toolbarContainer.style.flexShrink="0"}addButton(t){const e=document.createElement("button");e.id=`qfchart-plugin-btn-${t.id}`,e.style.width="30px",e.style.height="30px",e.style.padding="4px",e.style.border="1px solid transparent",e.style.borderRadius="4px",e.style.backgroundColor="transparent",e.style.cursor="pointer",e.style.color=this.context.getOptions().fontColor||"#cbd5e1",e.style.display="flex",e.style.alignItems="center",e.style.justifyContent="center",t.icon?e.innerHTML=t.icon:e.innerText=(t.name||t.id).substring(0,2).toUpperCase(),e.addEventListener("mouseenter",()=>{this.activePluginId!==t.id&&(e.style.backgroundColor="rgba(255, 255, 255, 0.1)"),this.showTooltip(e,t.name||t.id)}),e.addEventListener("mouseleave",()=>{this.activePluginId!==t.id&&(e.style.backgroundColor="transparent"),this.hideTooltip()}),e.onclick=()=>this.activatePlugin(t.id),this.toolbarContainer.appendChild(e)}removeButton(t){const e=this.toolbarContainer.querySelector(`#qfchart-plugin-btn-${t}`);e&&e.remove()}setButtonActive(t,e){const i=this.toolbarContainer.querySelector(`#qfchart-plugin-btn-${t}`);i&&(e?(i.style.backgroundColor="#2563eb",i.style.color="#ffffff"):(i.style.backgroundColor="transparent",i.style.color=this.context.getOptions().fontColor||"#cbd5e1"))}}var ci=Object.defineProperty,di=(d,t,e)=>t in d?ci(d,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):d[t]=e,et=(d,t,e)=>(di(d,typeof t!="symbol"?t+"":t,e),e);class pi{constructor(t){et(this,"context"),et(this,"isEditing",!1),et(this,"currentDrawing",null),et(this,"editingPointIndex",null),et(this,"zr"),et(this,"editGroup",null),et(this,"editLines",[]),et(this,"editPoints",[]),et(this,"isMovingShape",!1),et(this,"dragStart",null),et(this,"initialPixelPoints",[]),et(this,"onDrawingMouseDown",e=>{if(this.isEditing)return;const i=this.context.getDrawing(e.id);i&&(this.isEditing=!0,this.isMovingShape=!0,this.currentDrawing=JSON.parse(JSON.stringify(i)),this.dragStart={x:e.x,y:e.y},this.initialPixelPoints=i.points.map(s=>{const a=this.context.coordinateConversion.dataToPixel(s);return a?{x:a.x,y:a.y}:{x:0,y:0}}),this.context.lockChart(),this.createEditGraphic(),this.zr.on("mousemove",this.onMouseMove),this.zr.on("mouseup",this.onMouseUp),window.addEventListener("mouseup",this.onWindowMouseUp))}),et(this,"onPointMouseDown",e=>{if(this.isEditing)return;const i=this.context.getDrawing(e.id);i&&(this.isEditing=!0,this.currentDrawing=JSON.parse(JSON.stringify(i)),this.editingPointIndex=e.pointIndex,this.initialPixelPoints=i.points.map(s=>{const a=this.context.coordinateConversion.dataToPixel(s);return a?{x:a.x,y:a.y}:{x:0,y:0}}),this.context.lockChart(),this.createEditGraphic(),this.zr.on("mousemove",this.onMouseMove),this.zr.on("mouseup",this.onMouseUp),window.addEventListener("mouseup",this.onWindowMouseUp))}),et(this,"onMouseMove",e=>{if(!this.isEditing||!this.currentDrawing)return;const i=e.offsetX,s=e.offsetY;if(this.isMovingShape&&this.dragStart){const a=i-this.dragStart.x,n=s-this.dragStart.y,l=this.initialPixelPoints.map(r=>({x:r.x+a,y:r.y+n}));for(let r=0;r<this.editLines.length;r++)this.editLines[r].setShape({x1:l[r].x,y1:l[r].y,x2:l[r+1].x,y2:l[r+1].y});for(let r=0;r<this.editPoints.length;r++)this.editPoints[r].setShape({cx:l[r].x,cy:l[r].y})}else if(this.editingPointIndex!==null){const a=this.initialPixelPoints.map(n=>({x:n.x,y:n.y}));a[this.editingPointIndex]={x:i,y:s};for(let n=0;n<this.editLines.length;n++)this.editLines[n].setShape({x1:a[n].x,y1:a[n].y,x2:a[n+1].x,y2:a[n+1].y});this.editPoints[this.editingPointIndex].setShape({cx:i,cy:s})}}),et(this,"onMouseUp",e=>{this.isEditing&&this.finishEditing(e.offsetX,e.offsetY)}),et(this,"onWindowMouseUp",e=>{if(!this.isEditing)return;const i=this.zr.dom;if(i){const s=i.getBoundingClientRect(),a=e.clientX-s.left,n=e.clientY-s.top;this.finishEditing(a,n)}else this.finishEditing(this.dragStart?.x??0,this.dragStart?.y??0)}),this.context=t,this.zr=this.context.getChart().getZr(),this.bindEvents()}bindEvents(){this.context.events.on("drawing:point:mousedown",this.onPointMouseDown),this.context.events.on("drawing:mousedown",this.onDrawingMouseDown)}createEditGraphic(){if(!this.currentDrawing)return;this.editGroup=new G.graphic.Group,this.editLines=[],this.editPoints=[];const t=this.currentDrawing.points.map(i=>{const s=this.context.coordinateConversion.dataToPixel(i);return s?{x:s.x,y:s.y}:null});if(t.some(i=>!i))return;const e=t;for(let i=0;i<e.length-1;i++){const s=new G.graphic.Line({shape:{x1:e[i].x,y1:e[i].y,x2:e[i+1].x,y2:e[i+1].y},style:{stroke:this.currentDrawing.style?.color||"#3b82f6",lineWidth:this.currentDrawing.style?.lineWidth||2,lineDash:[4,4]},silent:!0});this.editLines.push(s),this.editGroup.add(s)}for(let i=0;i<e.length;i++){const s=new G.graphic.Circle({shape:{cx:e[i].x,cy:e[i].y,r:5},style:{fill:"#fff",stroke:"#3b82f6",lineWidth:2},z:1e3});this.editPoints.push(s),this.editGroup.add(s)}this.zr.add(this.editGroup)}pixelToDataForPane(t,e,i){const s=this.context.coordinateConversion.pixelToData({x:t,y:e});if(s)return s;try{const a=this.context.getChart(),n=a.convertFromPixel({gridIndex:i},[t,e]);if(n){const l=a.getOption()?.xAxis?.[i]?.data,r=this.context.getMarketData(),o=l?Math.round((l.length-r.length)/2):0;return{timeIndex:Math.round(n[0])-o,value:n[1],paneIndex:i}}}catch{}return null}finishEditing(t,e){if(!this.currentDrawing){this.cleanup();return}const i=this.currentDrawing.paneIndex||0;if(this.isMovingShape&&this.dragStart){const s=t-this.dragStart.x,a=e-this.dragStart.y,n=this.initialPixelPoints.map(l=>this.pixelToDataForPane(l.x+s,l.y+a,i));if(n.every(l=>l!==null)){for(let l=0;l<n.length;l++)this.currentDrawing.points[l]=n[l];n[0]?.paneIndex!==void 0&&(this.currentDrawing.paneIndex=n[0].paneIndex),this.context.updateDrawing(this.currentDrawing)}}else if(this.editingPointIndex!==null){const s=this.pixelToDataForPane(t,e,i);s&&(this.currentDrawing.points[this.editingPointIndex]=s,this.editingPointIndex===0&&s.paneIndex!==void 0&&(this.currentDrawing.paneIndex=s.paneIndex),this.context.updateDrawing(this.currentDrawing))}this.cleanup()}cleanup(){this.isEditing=!1,this.isMovingShape=!1,this.dragStart=null,this.initialPixelPoints=[],this.currentDrawing=null,this.editingPointIndex=null,this.editLines=[],this.editPoints=[],this.editGroup&&(this.zr.remove(this.editGroup),this.editGroup=null),this.zr.off("mousemove",this.onMouseMove),this.zr.off("mouseup",this.onMouseUp),window.removeEventListener("mouseup",this.onWindowMouseUp),this.context.unlockChart()}}var ui=Object.defineProperty,gi=(d,t,e)=>t in d?ui(d,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):d[t]=e,fi=(d,t,e)=>(gi(d,typeof t!="symbol"?t+"":t,e),e);class ae{constructor(){fi(this,"renderers",new Map)}register(t){this.renderers.set(t.type,t)}get(t){return this.renderers.get(t)}}var yi=Object.defineProperty,xi=(d,t,e)=>t in d?yi(d,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):d[t]=e,mi=(d,t,e)=>(xi(d,typeof t!="symbol"?t+"":t,e),e);class bi{constructor(){mi(this,"handlers",new Map)}on(t,e){this.handlers.has(t)||this.handlers.set(t,new Set),this.handlers.get(t).add(e)}off(t,e){const i=this.handlers.get(t);i&&i.delete(e)}emit(t,e){const i=this.handlers.get(t);i&&i.forEach(s=>{try{s(e)}catch(a){console.error(`Error in EventBus handler for ${t}:`,a)}})}clear(){this.handlers.clear()}}class st{static safeParseColor(t){if(!t||typeof t!="string")return{color:"#888888",opacity:1};const e=t.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?\)/);if(e){const i=e[4]?parseFloat(e[4]):1;return{color:`rgb(${e[1]},${e[2]},${e[3]})`,opacity:i}}return{color:t,opacity:1}}static render(t,e,i){st.clearAll(t);const s=new Map;for(const a of e)a&&!a._deleted&&s.set(a.position,a);s.forEach(a=>{const n=a._paneIndex??0,l=i?i(n):void 0,r=st.buildTable(a,l);st.positionTable(r,a.position,l),t.appendChild(r)})}static clearAll(t){for(;t.firstChild;)t.removeChild(t.firstChild)}static buildTable(t,e){const i=document.createElement("table"),s=t.border_width??0,a=t.frame_width??0;if(s>0&&t.border_color||a>0&&t.frame_color?(i.style.borderCollapse="separate",i.style.borderSpacing="0"):i.style.borderCollapse="collapse",i.style.pointerEvents="none",i.style.fontSize="14px",i.style.lineHeight="1.4",i.style.fontFamily="sans-serif",i.style.margin="4px",e&&(i.style.maxHeight=e.height+"px",i.style.maxWidth=e.width+"px",i.style.overflow="hidden"),t.bgcolor){const{color:c,opacity:g}=st.safeParseColor(t.bgcolor);i.style.backgroundColor=c,g<1&&(i.style.opacity=String(g))}if(a>0&&t.frame_color){const{color:c}=st.safeParseColor(t.frame_color);i.style.border=`${a}px solid ${c}`}else i.style.border="none";const n=new Map,l=new Set;if(t.merges)for(const c of t.merges){const g=`${c.startCol},${c.startRow}`;n.set(g,{colspan:c.endCol-c.startCol+1,rowspan:c.endRow-c.startRow+1});for(let h=c.startRow;h<=c.endRow;h++)for(let f=c.startCol;f<=c.endCol;f++)h===c.startRow&&f===c.startCol||l.add(`${f},${h}`)}const r=s>0&&!!t.border_color,o=r?st.safeParseColor(t.border_color).color:"",u=t.rows||0,p=t.columns||0;for(let c=0;c<u;c++){const g=document.createElement("tr");for(let h=0;h<p;h++){const f=`${h},${c}`;if(l.has(f))continue;const y=document.createElement("td"),x=n.get(f);x&&(x.colspan>1&&(y.colSpan=x.colspan),x.rowspan>1&&(y.rowSpan=x.rowspan)),r?y.style.border=`${s}px solid ${o}`:y.style.border="none";const b=t.cells?.[c]?.[h];if(b&&!b._merged){if(y.textContent=b.text||"",b.bgcolor&&typeof b.bgcolor=="string"&&b.bgcolor.length>0){const{color:w,opacity:P}=st.safeParseColor(b.bgcolor);y.style.backgroundColor=w,P<1&&(y.style.backgroundColor=b.bgcolor)}if(b.text_color){const{color:w}=st.safeParseColor(b.text_color);y.style.color=w}if(y.style.fontSize=st.getSizePixels(b.text_size)+"px",y.style.textAlign=st.mapHAlign(b.text_halign),y.style.verticalAlign=st.mapVAlign(b.text_valign),b.text_font_family==="monospace"&&(y.style.fontFamily="monospace"),b.width>0)if(e){const w=Math.max(1,b.width*e.width/100);y.style.width=w+"px"}else y.style.width=b.width+"%";if(b.height>0)if(e){const w=Math.max(1,b.height*e.height/100);y.style.height=w+"px"}else y.style.height=b.height+"%";b.tooltip&&(y.title=b.tooltip)}const D=b?.height??0;D>0&&e&&D*e.height/100<4?y.style.padding="0":y.style.padding="4px 6px",y.style.whiteSpace="nowrap",g.appendChild(y)}i.appendChild(g)}return i}static positionTable(t,e,i){t.style.position="absolute";const s=8,a=i?i.y+"px":"0",n=i?i.x+"px":"0",l=i?i.y+i.height-s+"px":"0",r=i?i.x+i.width-s+"px":"0",o=i?i.x+i.width/2+"px":"50%",u=i?i.y+i.height/2+"px":"50%";switch(e){case"top_left":t.style.top=a,t.style.left=n;break;case"top_center":t.style.top=a,t.style.left=o,t.style.transform="translateX(-50%)";break;case"top_right":t.style.top=a,t.style.left=r,t.style.transform="translateX(-100%)";break;case"middle_left":t.style.top=u,t.style.left=n,t.style.transform="translateY(-50%)";break;case"middle_center":t.style.top=u,t.style.left=o,t.style.transform="translate(-50%, -50%)";break;case"middle_right":t.style.top=u,t.style.left=r,t.style.transform="translate(-100%, -50%)";break;case"bottom_left":t.style.top=l,t.style.left=n,t.style.transform="translateY(-100%)";break;case"bottom_center":t.style.top=l,t.style.left=o,t.style.transform="translate(-50%, -100%)";break;case"bottom_right":t.style.top=l,t.style.left=r,t.style.transform="translate(-100%, -100%)";break;default:t.style.top=a,t.style.left=r,t.style.transform="translateX(-100%)";break}}static getSizePixels(t){if(typeof t=="number"&&t>0)return t;switch(t){case"auto":case"size.auto":return 12;case"tiny":case"size.tiny":return 8;case"small":case"size.small":return 10;case"normal":case"size.normal":return 14;case"large":case"size.large":return 20;case"huge":case"size.huge":return 36;default:return 14}}static mapHAlign(t){switch(t){case"left":case"text.align_left":return"left";case"right":case"text.align_right":return"right";case"center":case"text.align_center":default:return"center"}}static mapVAlign(t){switch(t){case"top":case"text.align_top":return"top";case"bottom":case"text.align_bottom":return"bottom";case"center":case"text.align_center":default:return"middle"}}}class K{static parseColor(t){if(!t||typeof t!="string"||t.length===0)return{color:"",opacity:0};const e=t.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?\)/);if(e){const i=e[4]?parseFloat(e[4]):1;return{color:`rgb(${e[1]},${e[2]},${e[3]})`,opacity:i}}if(/^#[0-9a-fA-F]{8}$/.test(t)){const i=parseInt(t.slice(1,3),16),s=parseInt(t.slice(3,5),16),a=parseInt(t.slice(5,7),16),n=parseInt(t.slice(7,9),16)/255;return{color:`rgb(${i},${s},${a})`,opacity:n}}return{color:t,opacity:1}}static getSizePixels(t){if(typeof t=="number"&&t>0)return t;switch(t){case"auto":case"size.auto":return 11;case"tiny":case"size.tiny":return 8;case"small":case"size.small":return 10;case"normal":case"size.normal":return 12;case"large":case"size.large":return 16;case"huge":case"size.huge":return 24;default:return 12}}static mapHAlign(t){switch(t){case"left":case"text.align_left":return"left";case"right":case"text.align_right":return"right";default:return"center"}}static mapVAlign(t){switch(t){case"top":case"text.align_top":return"top";case"bottom":case"text.align_bottom":return"bottom";default:return"middle"}}static buildGraphicElements(t,e){if(!t||t.length===0)return[];const i=new Map;for(const a of t)a&&!a._deleted&&i.set(a.position,a);const s=[];return i.forEach(a=>{const n=a._paneIndex??0,l=e(n);if(!l)return;const r=K.buildTableElements(a,l);s.push(...r)}),s}static buildTableElements(t,e){const i=t.rows||0,s=t.columns||0;if(i===0||s===0)return[];const a=t.border_width??0,n=t.frame_width??0,l=a>0&&!!t.border_color,r=n>0&&!!t.frame_color,o=new Map,u=new Set;if(t.merges)for(const I of t.merges){o.set(`${I.startCol},${I.startRow}`,{colspan:I.endCol-I.startCol+1,rowspan:I.endRow-I.startRow+1});for(let $=I.startRow;$<=I.endRow;$++)for(let A=I.startCol;A<=I.endCol;A++)$===I.startRow&&A===I.startCol||u.add(`${A},${$}`)}const p=4,c=2,g=1.25,h=[];for(let I=0;I<i;I++){h[I]=[];for(let $=0;$<s;$++){if(u.has(`${$},${I}`)){h[I][$]={text:"",lines:[],fontSize:12,fontFamily:"sans-serif",textColor:{color:"",opacity:0},bgColor:{color:"",opacity:0},halign:"center",valign:"middle",explicitWidth:0,explicitHeight:0,colspan:1,rowspan:1,skip:!0,padX:0,padY:0};continue}const A=t.cells?.[I]?.[$],O=o.get(`${$},${I}`),W=O?.colspan??1,j=O?.rowspan??1,Z=A&&!A._merged&&A.text||"",F=Z?Z.split(`
|
|
38
|
-
`):[],U=A?K.getSizePixels(A.text_size):12,H=A?.text_font_family==="monospace"?"monospace":"sans-serif";let X=0,ht=0;A?.width>0&&(X=Math.max(1,A.width*e.width/100)),A?.height>0&&(ht=Math.max(1,A.height*e.height/100));const dt=ht>0&&ht<4,te=dt?0:p,Pt=dt?0:c,Ht=A&&!A._merged&&A.bgcolor&&typeof A.bgcolor=="string"&&A.bgcolor.length>0?A.bgcolor:"",Rt=A?.text_color||"";h[I][$]={text:Z,lines:F,fontSize:U,fontFamily:H,textColor:Rt?K.parseColor(Rt):{color:"#e0e0e0",opacity:1},bgColor:Ht?K.parseColor(Ht):{color:"",opacity:0},halign:A?K.mapHAlign(A.text_halign):"center",valign:A?K.mapVAlign(A.text_valign):"middle",explicitWidth:X,explicitHeight:ht,colspan:W,rowspan:j,skip:!1,padX:te,padY:Pt}}}const f=new Array(s).fill(0),y=new Array(i).fill(0);for(let I=0;I<i;I++)for(let $=0;$<s;$++){const A=h[I][$];if(A.skip||A.colspan>1||A.rowspan>1)continue;const O=K.measureMultiLineWidth(A.lines,A.fontSize,A.fontFamily),W=Math.max(A.lines.length,1),j=A.explicitWidth>0?A.explicitWidth:O+A.padX*2,Z=A.explicitHeight>0?A.explicitHeight:W*A.fontSize*g+A.padY*2;f[$]=Math.max(f[$],j),y[I]=Math.max(y[I],Z)}for(let I=0;I<s;I++)f[I]===0&&(f[I]=20);for(let I=0;I<i;I++)y[I]===0&&(y[I]=4);for(let I=0;I<i;I++)for(let $=0;$<s;$++){const A=h[I][$];if(A.skip)continue;const O=Math.max(A.lines.length,1),W=A.explicitHeight>0?A.explicitHeight:O*A.fontSize*g+A.padY*2;if(A.colspan>1){const j=K.sumRange(f,$,A.colspan),Z=K.measureMultiLineWidth(A.lines,A.fontSize,A.fontFamily),F=A.explicitWidth>0?A.explicitWidth:Z+A.padX*2;if(F>j){const U=(F-j)/A.colspan;for(let H=0;H<A.colspan;H++)f[$+H]+=U}A.rowspan===1&&(y[I]=Math.max(y[I],W))}if(A.rowspan>1){const j=K.sumRange(y,I,A.rowspan);if(W>j){const Z=(W-j)/A.rowspan;for(let F=0;F<A.rowspan;F++)y[I+F]+=Z}}}for(let I=0;I<s;I++)f[I]=Math.round(f[I]);for(let I=0;I<i;I++)y[I]=Math.round(y[I]);const x=new Array(s+1).fill(0);for(let I=0;I<s;I++)x[I+1]=x[I]+f[I];const b=new Array(i+1).fill(0);for(let I=0;I<i;I++)b[I+1]=b[I]+y[I];const D=r?n:0,w=x[s]+D*2,P=b[i]+D*2,m=Math.min(w,e.width),C=Math.min(P,e.height),v=K.computePosition(t.position,e,m,C),_=Math.round(v.x),k=Math.round(v.y),M=[],S=_+D,z=k+D;if(t.bgcolor){const{color:I,opacity:$}=K.parseColor(t.bgcolor);$>0&&M.push({type:"rect",shape:{x:_,y:k,width:m,height:C},style:{fill:I,opacity:$},silent:!0,z:0,z2:0})}if(r){const{color:I}=K.parseColor(t.frame_color),$=n/2;M.push({type:"rect",shape:{x:_+$,y:k+$,width:m-n,height:C-n},style:{fill:"none",stroke:I,lineWidth:n},silent:!0,z:0,z2:1})}const T=l?K.parseColor(t.border_color).color:"";for(let I=0;I<i;I++)for(let $=0;$<s;$++){const A=h[I][$];if(A.skip)continue;const O=S+x[$],W=z+b[I],j=K.sumRange(f,$,A.colspan),Z=K.sumRange(y,I,A.rowspan);if(O-_>=m||W-k>=C)continue;const F=Math.min(j,m-(O-_)),U=Math.min(Z,C-(W-k));if(A.bgColor.opacity>0&&M.push({type:"rect",shape:{x:O,y:W,width:F,height:U},style:{fill:A.bgColor.color,opacity:A.bgColor.opacity},silent:!0,z:0,z2:2}),l&&M.push({type:"rect",shape:{x:O,y:W,width:F,height:U},style:{fill:"none",stroke:T,lineWidth:a},silent:!0,z:0,z2:3}),A.text){let H,X;switch(A.halign){case"left":H=O+A.padX,X="left";break;case"right":H=O+F-A.padX,X="right";break;default:H=O+F/2,X="center";break}let ht,dt;switch(A.valign){case"top":ht=W+A.padY,dt="top";break;case"bottom":ht=W+U-A.padY,dt="bottom";break;default:ht=W+U/2,dt="middle";break}M.push({type:"text",x:H,y:ht,style:{text:A.text,fill:A.textColor.color,opacity:A.textColor.opacity,font:`${A.fontSize}px ${A.fontFamily}`,textAlign:X,textVerticalAlign:dt,lineHeight:Math.round(A.fontSize*g)},silent:!0,z:0,z2:4})}}return M}static computePosition(t,e,i,s){const a=e.x,n=e.y,l=e.width,r=e.height;switch(t){case"top_left":return{x:a+4,y:n+4};case"top_center":return{x:a+(l-i)/2,y:n+4};case"top_right":return{x:a+l-i-4,y:n+4};case"middle_left":return{x:a+4,y:n+(r-s)/2};case"middle_center":return{x:a+(l-i)/2,y:n+(r-s)/2};case"middle_right":return{x:a+l-i-4,y:n+(r-s)/2};case"bottom_left":return{x:a+4,y:n+r-s-4};case"bottom_center":return{x:a+(l-i)/2,y:n+r-s-4};case"bottom_right":return{x:a+l-i-4,y:n+r-s-4};default:return{x:a+l-i-4,y:n+4}}}static measureMultiLineWidth(t,e,i){if(!t||t.length===0)return 0;const s=i==="monospace"?.6:.55;let a=0;for(const n of t)a=Math.max(a,n.length*e*s);return a}static sumRange(t,e,i){let s=0;for(let a=e;a<e+i&&a<t.length;a++)s+=t[a];return s}}var vi=Object.defineProperty,wi=(d,t,e)=>t in d?vi(d,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):d[t]=e,L=(d,t,e)=>(wi(d,typeof t!="symbol"?t+"":t,e),e);class Ci{constructor(t,e={}){L(this,"chart"),L(this,"options"),L(this,"marketData",[]),L(this,"indicators",new Map),L(this,"timeToIndex",new Map),L(this,"pluginManager"),L(this,"drawingEditor"),L(this,"events",new bi),L(this,"isMainCollapsed",!1),L(this,"maximizedPaneId",null),L(this,"countdownInterval",null),L(this,"selectedDrawingId",null),L(this,"drawings",[]),L(this,"drawingRenderers",new ae),L(this,"coordinateConversion",{pixelToData:n=>{const l=this.chart.getOption();if(!l||!l.grid)return null;const r=l.grid.length;for(let o=0;o<r;o++)if(this.chart.containPixel({gridIndex:o},[n.x,n.y])){this.chart.convertFromPixel({seriesIndex:o},[n.x,n.y]);const u=this.chart.convertFromPixel({gridIndex:o},[n.x,n.y]);if(u)return{timeIndex:Math.round(u[0])-this.dataIndexOffset,value:u[1],paneIndex:o}}return null},dataToPixel:n=>{const l=n.paneIndex||0,r=this.chart.convertToPixel({gridIndex:l},[n.timeIndex+this.dataIndexOffset,n.value]);return r?{x:r[0],y:r[1]}:null}}),L(this,"upColor","#00da3c"),L(this,"downColor","#ec0000"),L(this,"defaultPadding",0),L(this,"padding"),L(this,"dataIndexOffset",0),L(this,"_paddingPoints",0),L(this,"LAZY_MIN_PADDING",5),L(this,"LAZY_MAX_PADDING",500),L(this,"LAZY_CHUNK_SIZE",50),L(this,"LAZY_EDGE_THRESHOLD",10),L(this,"_expandScheduled",!1),L(this,"rootContainer"),L(this,"layoutContainer"),L(this,"toolbarContainer"),L(this,"leftSidebar"),L(this,"rightSidebar"),L(this,"chartContainer"),L(this,"overlayContainer"),L(this,"_lastTables",[]),L(this,"_tableGraphicIds",[]),L(this,"_baseGraphics",[]),L(this,"_labelTooltipEl",null),L(this,"_lastLayout",null),L(this,"_mainHeightOverride",null),L(this,"_paneDragState",null),L(this,"_paneResizeRafId",null),L(this,"onKeyDown",n=>{(n.key==="Delete"||n.key==="Backspace")&&this.selectedDrawingId&&(this.removeDrawing(this.selectedDrawingId),this.selectedDrawingId=null,this.render())}),L(this,"onFullscreenChange",()=>{this.render()}),L(this,"isLocked",!1),L(this,"lockedState",null),this.rootContainer=t,this.options={title:void 0,height:"600px",backgroundColor:"#1e293b",upColor:"#00da3c",downColor:"#ec0000",fontColor:"#cbd5e1",fontFamily:"sans-serif",padding:.01,dataZoom:{visible:!0,position:"top",height:6},layout:{mainPaneHeight:"50%",gap:13},watermark:!0,...e},this.options.upColor&&(this.upColor=this.options.upColor),this.options.downColor&&(this.downColor=this.options.downColor),this.padding=this.options.padding!==void 0?this.options.padding:this.defaultPadding,this.options.height&&(typeof this.options.height=="number"?this.rootContainer.style.height=`${this.options.height}px`:this.rootContainer.style.height=this.options.height),this.rootContainer.innerHTML="",this.layoutContainer=document.createElement("div"),this.layoutContainer.style.display="flex",this.layoutContainer.style.width="100%",this.layoutContainer.style.height="100%",this.layoutContainer.style.overflow="hidden",this.rootContainer.appendChild(this.layoutContainer),this.leftSidebar=document.createElement("div"),this.leftSidebar.style.display="none",this.leftSidebar.style.width="250px",this.leftSidebar.style.flexShrink="0",this.leftSidebar.style.overflowY="auto",this.leftSidebar.style.backgroundColor=this.options.backgroundColor||"#1e293b",this.leftSidebar.style.borderRight="1px solid #334155",this.leftSidebar.style.padding="10px",this.leftSidebar.style.boxSizing="border-box",this.leftSidebar.style.color="#cbd5e1",this.leftSidebar.style.fontSize="12px",this.leftSidebar.style.fontFamily=this.options.fontFamily||"sans-serif",this.layoutContainer.appendChild(this.leftSidebar),this.toolbarContainer=document.createElement("div"),this.layoutContainer.appendChild(this.toolbarContainer),this.chartContainer=document.createElement("div"),this.chartContainer.style.flexGrow="1",this.chartContainer.style.height="100%",this.chartContainer.style.overflow="hidden",this.layoutContainer.appendChild(this.chartContainer),this.rightSidebar=document.createElement("div"),this.rightSidebar.style.display="none",this.rightSidebar.style.width="250px",this.rightSidebar.style.flexShrink="0",this.rightSidebar.style.overflowY="auto",this.rightSidebar.style.backgroundColor=this.options.backgroundColor||"#1e293b",this.rightSidebar.style.borderLeft="1px solid #334155",this.rightSidebar.style.padding="10px",this.rightSidebar.style.boxSizing="border-box",this.rightSidebar.style.color="#cbd5e1",this.rightSidebar.style.fontSize="12px",this.rightSidebar.style.fontFamily=this.options.fontFamily||"sans-serif",this.layoutContainer.appendChild(this.rightSidebar),this.chart=G.init(this.chartContainer),this.chartContainer.style.position="relative",this.overlayContainer=document.createElement("div"),this.overlayContainer.style.cssText="position:absolute;top:0;left:0;width:100%;height:100%;pointer-events:none;z-index:100;overflow:hidden;",this.chartContainer.appendChild(this.overlayContainer),this.pluginManager=new hi(this,this.toolbarContainer),this.drawingEditor=new pi(this),this.chart.on("dataZoom",n=>{this.events.emit("chart:dataZoom",n);const l=this.options.databox?.triggerOn,r=this.options.databox?.position;l==="click"&&r==="floating"&&this.chart.dispatchAction({type:"hideTip"}),this._checkEdgeAndExpand()}),this.chart.on("finished",n=>this.events.emit("chart:updated",n)),this.chart.getZr().on("mousedown",n=>{this._paneDragState||this.events.emit("mouse:down",n)}),this.chart.getZr().on("mousemove",n=>{this._paneDragState||this.events.emit("mouse:move",n)}),this.chart.getZr().on("mouseup",n=>this.events.emit("mouse:up",n)),this.chart.getZr().on("click",n=>{this._paneDragState||this.events.emit("mouse:click",n)});const i=this.chart.getZr(),s=i.setCursorStyle,a=this;i.setCursorStyle=function(n){if(a._paneDragState){s.call(this,"row-resize");return}n==="grab"&&(n="crosshair"),s.call(this,n)},this.bindDrawingEvents(),this.bindPaneResizeEvents(),window.addEventListener("resize",this.resize.bind(this)),document.addEventListener("fullscreenchange",this.onFullscreenChange),document.addEventListener("keydown",this.onKeyDown)}bindPaneResizeEvents(){const t=this.chart.getZr(),e=s=>{if(!this._lastLayout||this._lastLayout.paneBoundaries.length===0||this.maximizedPaneId)return null;const a=this.chart.getHeight();if(a<=0)return null;for(const n of this._lastLayout.paneBoundaries){const l=n.yPercent/100*a;if(Math.abs(s-l)<=6){if(n.aboveId==="main"&&this.isMainCollapsed||this.indicators.get(n.belowId)?.collapsed||n.aboveId!=="main"&&this.indicators.get(n.aboveId)?.collapsed)continue;return n}}return null},i=s=>s==="main"?this._lastLayout?.mainPaneHeight??50:this.indicators.get(s)?.height??15;t.on("mousemove",s=>{if(this._paneDragState){const a=s.offsetY-this._paneDragState.startY,n=this.chart.getHeight();if(n<=0)return;const l=a/n*100,r=this._paneDragState.aboveId==="main"?10:5,o=5;let u=this._paneDragState.startAboveHeight+l,p=this._paneDragState.startBelowHeight-l;if(u<r&&(u=r,p=this._paneDragState.startAboveHeight+this._paneDragState.startBelowHeight-r),p<o&&(p=o,u=this._paneDragState.startAboveHeight+this._paneDragState.startBelowHeight-o),this._paneDragState.aboveId==="main")this._mainHeightOverride=u;else{const g=this.indicators.get(this._paneDragState.aboveId);g&&(g.height=u)}const c=this.indicators.get(this._paneDragState.belowId);c&&(c.height=p),this._paneResizeRafId||(this._paneResizeRafId=requestAnimationFrame(()=>{this._paneResizeRafId=null,this.render()})),t.setCursorStyle("row-resize"),s.stop?.();return}e(s.offsetY)&&t.setCursorStyle("row-resize")}),t.on("mousedown",s=>{const a=e(s.offsetY);a&&(this._paneDragState={startY:s.offsetY,aboveId:a.aboveId,belowId:a.belowId,startAboveHeight:i(a.aboveId),startBelowHeight:i(a.belowId)},t.setCursorStyle("row-resize"),s.stop?.())}),t.on("mouseup",()=>{this._paneDragState&&(this._paneDragState=null,this._paneResizeRafId&&(cancelAnimationFrame(this._paneResizeRafId),this._paneResizeRafId=null),this.render())})}bindDrawingEvents(){let t=null;const e=i=>{if(!i||i.componentType!=="series"||!i.seriesName?.startsWith("drawings"))return null;i.seriesIndex;const s=i.seriesName.match(/drawings-pane-(\d+)/);if(!s)return null;const a=parseInt(s[1]),n=this.drawings.filter(r=>(r.paneIndex||0)===a)[i.dataIndex];if(!n)return null;const l=i.event?.target?.name;return{drawing:n,targetName:l,paneIdx:a}};this.chart.on("mouseover",i=>{const s=e(i);if(!s)return;const a=i.event?.target?.parent;if(a){const n=s.drawing.id===this.selectedDrawingId;t&&(clearTimeout(t),t=null),n||a.children().forEach(l=>{l.name&&l.name.startsWith("point")&&l.attr("style",{opacity:1})})}if(s.targetName==="line")this.events.emit("drawing:hover",{id:s.drawing.id,type:s.drawing.type}),this.chart.getZr().setCursorStyle("move");else if(s.targetName?.startsWith("point-")){const n=parseInt(s.targetName.split("-")[1])||0;this.events.emit("drawing:point:hover",{id:s.drawing.id,pointIndex:n}),this.chart.getZr().setCursorStyle("pointer")}}),this.chart.on("mouseout",i=>{const s=e(i);if(!s)return;const a=i.event?.target?.parent;if(s.drawing.id!==this.selectedDrawingId){if(t=setTimeout(()=>{if(a){if(this.selectedDrawingId===s.drawing.id)return;a.children().forEach(n=>{n.name&&n.name.startsWith("point")&&n.attr("style",{opacity:0})})}},50),s.targetName==="line")this.events.emit("drawing:mouseout",{id:s.drawing.id});else if(s.targetName?.startsWith("point-")){const n=parseInt(s.targetName.split("-")[1])||0;this.events.emit("drawing:point:mouseout",{id:s.drawing.id,pointIndex:n})}this.chart.getZr().setCursorStyle("default")}}),this.chart.on("mousedown",i=>{const s=e(i);if(!s)return;const a=i.event?.event||i.event,n=a?.offsetX,l=a?.offsetY;if(s.targetName==="line")this.events.emit("drawing:mousedown",{id:s.drawing.id,x:n,y:l});else if(s.targetName?.startsWith("point-")){const r=parseInt(s.targetName.split("-")[1])||0;this.events.emit("drawing:point:mousedown",{id:s.drawing.id,pointIndex:r,x:n,y:l})}}),this.chart.on("click",i=>{const s=e(i);if(s){if(this.selectedDrawingId!==s.drawing.id&&(this.selectedDrawingId=s.drawing.id,this.events.emit("drawing:selected",{id:s.drawing.id}),this.render()),s.targetName==="line")this.events.emit("drawing:click",{id:s.drawing.id});else if(s.targetName?.startsWith("point-")){const a=parseInt(s.targetName.split("-")[1])||0;this.events.emit("drawing:point:click",{id:s.drawing.id,pointIndex:a})}}}),this.chart.getZr().on("click",i=>{i.target||this.selectedDrawingId&&(this.events.emit("drawing:deselected",{id:this.selectedDrawingId}),this.selectedDrawingId=null,this.render())}),this._labelTooltipEl=document.createElement("div"),this._labelTooltipEl.style.cssText="position:absolute;display:none;pointer-events:none;z-index:200;background:rgba(30,41,59,0.95);color:#fff;border:1px solid #475569;border-radius:4px;padding:6px 10px;font-size:12px;line-height:1.5;white-space:pre-wrap;max-width:350px;box-shadow:0 2px 8px rgba(0,0,0,0.3);font-family:"+(this.options.fontFamily||"sans-serif")+";",this.chartContainer.appendChild(this._labelTooltipEl),this.chart.on("mouseover",{seriesType:"scatter"},i=>{const s=i.data?._tooltipText;if(!s||!this._labelTooltipEl)return;this._labelTooltipEl.textContent=s,this._labelTooltipEl.style.display="block";const a=this.chartContainer.getBoundingClientRect(),n=i.event?.event;if(n){const l=n.clientX-a.left,r=n.clientY-a.top,o=this._labelTooltipEl.offsetWidth,u=Math.min(l-o/2,a.width-o-8);this._labelTooltipEl.style.left=Math.max(4,u)+"px",this._labelTooltipEl.style.top=r+18+"px"}}),this.chart.on("mouseout",{seriesType:"scatter"},()=>{this._labelTooltipEl&&(this._labelTooltipEl.style.display="none")})}getChart(){return this.chart}getMarketData(){return this.marketData}getTimeToIndex(){return this.timeToIndex}getOptions(){return this.options}disableTools(){this.pluginManager.deactivatePlugin()}registerPlugin(t){this.pluginManager.register(t)}registerDrawingRenderer(t){this.drawingRenderers.register(t)}snapToCandle(t){const e=this.coordinateConversion.pixelToData(t);if(!e)return t;const i=e.paneIndex||0;if(i!==0)return t;const s=Math.round(e.timeIndex);if(s<0||s>=this.marketData.length)return t;const a=this.marketData[s];if(!a)return t;const n=this.chart.convertToPixel({gridIndex:i},[s+this.dataIndexOffset,a.close]);if(!n)return t;const l=n[0],r=[a.open,a.high,a.low,a.close];let o=r[0],u=1/0;for(const c of r){const g=this.chart.convertToPixel({gridIndex:i},[s+this.dataIndexOffset,c]);if(g){const h=Math.abs(g[1]-t.y);h<u&&(u=h,o=c)}}const p=this.chart.convertToPixel({gridIndex:i},[s+this.dataIndexOffset,o]);return{x:l,y:p?p[1]:t.y}}addDrawing(t){this.drawings.push(t),this.render()}removeDrawing(t){const e=this.drawings.findIndex(i=>i.id===t);if(e!==-1){const i=this.drawings[e];this.drawings.splice(e,1),this.events.emit("drawing:deleted",{id:i.id}),this.render()}}getDrawing(t){return this.drawings.find(e=>e.id===t)}updateDrawing(t){const e=this.drawings.findIndex(i=>i.id===t.id);e!==-1&&(this.drawings[e]=t,this.render())}lockChart(){if(this.isLocked)return;this.isLocked=!0;const t=this.chart.getOption();this.chart.setOption({dataZoom:t.dataZoom.map(e=>({...e,disabled:!0})),tooltip:{show:!1}})}unlockChart(){if(!this.isLocked)return;this.isLocked=!1;const t=this.chart.getOption();(this.options.dataZoom||{}).visible,t.dataZoom&&this.chart.setOption({dataZoom:t.dataZoom.map(e=>({...e,disabled:!1})),tooltip:{show:!0}})}setZoom(t,e){this.chart.dispatchAction({type:"dataZoom",start:t,end:e})}setMarketData(t){this.marketData=t,this.rebuildTimeIndex(),this.render()}updateData(t){if(t.length===0)return;const e=new Map;this.marketData.forEach(y=>{e.set(y.time,y)}),t.forEach(y=>{e.has(y.time),e.set(y.time,y)}),this.marketData=Array.from(e.values()).sort((y,x)=>y.time-x.time),this.rebuildTimeIndex();const i=this.dataIndexOffset,s=wt.buildCandlestickSeries(this.marketData,this.options),a={value:[NaN,NaN,NaN,NaN],itemStyle:{opacity:0}},n=[...Array(i).fill(a),...s.data,...Array(i).fill(a)],l=[...Array(i).fill(""),...this.marketData.map(y=>new Date(y.time).toLocaleString()),...Array(i).fill("")],r=this.chart.getOption(),o=Bt.calculate(this.chart.getHeight(),this.indicators,this.options,this.isMainCollapsed,this.maximizedPaneId,this.marketData,this._mainHeightOverride??void 0);this._lastLayout=o;const u=[...Array(i).fill(null),...this.marketData,...Array(i).fill(null)],{series:p,barColors:c}=wt.buildIndicatorSeries(this.indicators,this.timeToIndex,o.paneLayout,l.length,i,u,o.overlayYAxisMap,o.separatePaneYAxisOffset),g=n.map((y,x)=>c[x]?{value:y.value||y,itemStyle:{color:c[x],color0:c[x]}}:y),h={xAxis:r.xAxis.map((y,x)=>({data:l})),series:[{data:g,markLine:s.markLine},...p]};this.chart.setOption(h,{notMerge:!1});const f=[];this.indicators.forEach(y=>{Object.values(y.plots).forEach(x=>{x.options?.style==="table"&&x.data?.forEach(b=>{(Array.isArray(b.value)?b.value:[b.value]).forEach(D=>{D&&!D._deleted&&(D._paneIndex=D.force_overlay?0:y.paneIndex,f.push(D))})})})}),this._lastTables=f,this._renderTableOverlays(),this.startCountdown()}startCountdown(){if(this.stopCountdown(),!this.options.lastPriceLine?.showCountdown||this.marketData.length===0)return;let t=this.options.interval;if(!t&&this.marketData.length>=2){const i=this.marketData[this.marketData.length-1],s=this.marketData[this.marketData.length-2];t=i.time-s.time}if(!t)return;const e=()=>{if(this.marketData.length===0)return;const i=this.marketData[this.marketData.length-1].time+t,s=Date.now(),a=i-s;if(a<=0)return;const n=Math.abs(a),l=Math.floor(n/36e5),r=Math.floor(n%36e5/6e4),o=Math.floor(n%6e4/1e3),u=`${l>0?l.toString().padStart(2,"0")+":":""}${r.toString().padStart(2,"0")}:${o.toString().padStart(2,"0")}`,p=this.chart.getOption();if(!p||!p.series)return;const c=p.series.findIndex(b=>b.type==="candlestick");if(c===-1)return;const g=p.series[c];if(!g.markLine||!g.markLine.data||!g.markLine.data[0])return;const h=g.markLine.data[0];h.label.formatter;const f=h.yAxis;let y="";if(this.options.yAxisLabelFormatter)y=this.options.yAxisLabelFormatter(f);else{const b=this.options.yAxisDecimalPlaces!==void 0?this.options.yAxisDecimalPlaces:B.autoDetectDecimals(this.marketData);y=B.formatValue(f,b)}const x=`${y}
|
|
39
|
-
${u}`;this.chart.setOption({series:[{id:"__candlestick__",markLine:{data:[{...h,label:{...h.label,formatter:x}}]}}]})};e(),this.countdownInterval=setInterval(e,1e3)}stopCountdown(){this.countdownInterval&&(clearInterval(this.countdownInterval),this.countdownInterval=null)}addIndicator(t,e,i={}){const s=i.overlay!==void 0?i.overlay:i.isOverlay??!1;let a=0;if(!s){let l=0;this.indicators.forEach(r=>{r.paneIndex>l&&(l=r.paneIndex)}),a=l+1}const n=new Fe(t,e,a,{height:i.height,collapsed:!1,titleColor:i.titleColor,controls:i.controls});return this.indicators.set(t,n),this.render(),n}setIndicator(t,e,i=!1){this.addIndicator(t,{[t]:e},{overlay:i})}removeIndicator(t){this.indicators.delete(t),this.render()}toggleIndicator(t,e="collapse"){if(e==="fullscreen"){document.fullscreenElement?document.exitFullscreen():this.rootContainer.requestFullscreen();return}if(e==="maximize"){this.maximizedPaneId===t?this.maximizedPaneId=null:this.maximizedPaneId=t,this.render();return}if(t==="main"){this.isMainCollapsed=!this.isMainCollapsed,this.render();return}const i=this.indicators.get(t);i&&(i.toggleCollapse(),this.render())}resize(){this.chart.resize(),this._renderTableOverlays()}_buildTableGraphics(){const t=this.chart.getModel(),e=s=>t.getComponent("grid",s)?.coordinateSystem?.getRect(),i=K.buildGraphicElements(this._lastTables,e);this._tableGraphicIds=[];for(let s=0;s<i.length;s++){const a=`__qf_table_${s}`;i[s].id=a,this._tableGraphicIds.push(a)}return i}_renderTableOverlays(){const t=this._buildTableGraphics(),e=[...this._baseGraphics,...t];this.chart.setOption({graphic:e},{replaceMerge:["graphic"]}),st.clearAll(this.overlayContainer)}destroy(){this.stopCountdown(),window.removeEventListener("resize",this.resize.bind(this)),document.removeEventListener("fullscreenchange",this.onFullscreenChange),document.removeEventListener("keydown",this.onKeyDown),this.pluginManager.deactivatePlugin(),this.pluginManager.destroy(),this.chart.dispose()}rebuildTimeIndex(){this.timeToIndex.clear(),this.marketData.forEach((i,s)=>{this.timeToIndex.set(i.time,s)});const t=this.marketData.length,e=Math.ceil(t*this.padding);this._paddingPoints=Math.max(this._paddingPoints,e,this.LAZY_MIN_PADDING),this.dataIndexOffset=this._paddingPoints}expandPadding(t){this._resizePadding(t)}_resizePadding(t){const e=Math.ceil(this.marketData.length*this.padding);if(t=Math.max(t,e,this.LAZY_MIN_PADDING),t=Math.min(t,this.LAZY_MAX_PADDING),t===this._paddingPoints)return;const i=this._paddingPoints,s=this.marketData.length+2*i,a=this.chart.getOption(),n=a?.dataZoom?.find(k=>k.type==="slider"||k.type==="inside"),l=n?n.start/100*s:0,r=n?n.end/100*s:s,o=t-i;this._paddingPoints=t,this.dataIndexOffset=this._paddingPoints;const u=this._paddingPoints,p={value:[NaN,NaN,NaN,NaN],itemStyle:{opacity:0}},c=wt.buildCandlestickSeries(this.marketData,this.options),g=[...Array(u).fill(p),...c.data,...Array(u).fill(p)],h=[...Array(u).fill(""),...this.marketData.map(k=>new Date(k.time).toLocaleString()),...Array(u).fill("")],f=[...Array(u).fill(null),...this.marketData,...Array(u).fill(null)],y=Bt.calculate(this.chart.getHeight(),this.indicators,this.options,this.isMainCollapsed,this.maximizedPaneId,this.marketData,this._mainHeightOverride??void 0),{series:x,barColors:b}=wt.buildIndicatorSeries(this.indicators,this.timeToIndex,y.paneLayout,h.length,u,f,y.overlayYAxisMap,y.separatePaneYAxisOffset),D=g.map((k,M)=>b[M]?{value:k.value||k,itemStyle:{color:b[M],color0:b[M]}}:k),w=this.marketData.length+2*t,P=Math.max(0,(l+o)/w*100),m=Math.min(100,(r+o)/w*100),C=[],v=new Map;this.drawings.forEach(k=>{const M=k.paneIndex||0;v.has(M)||v.set(M,[]),v.get(M).push(k)}),v.forEach(k=>{C.push({data:k.map(M=>[M.points[0].timeIndex+this.dataIndexOffset,M.points[0].value,M.points[1].timeIndex+this.dataIndexOffset,M.points[1].value])})});const _={xAxis:a.xAxis.map(()=>({data:h})),dataZoom:[{start:P,end:m},{start:P,end:m}],series:[{data:D,markLine:c.markLine},...x.map(k=>{const M={data:k.data};return k.renderItem&&(M.renderItem=k.renderItem),M}),...C]};this.chart.setOption(_,{notMerge:!1})}_checkEdgeAndExpand(){if(this._expandScheduled)return;const t=this.chart.getOption()?.dataZoom?.find(f=>f.type==="slider"||f.type==="inside");if(!t)return;const e=this._paddingPoints,i=this.marketData.length,s=i+2*e,a=Math.round(t.start/100*s),n=Math.round(t.end/100*s),l=e,r=e+i-1,o=Math.max(0,Math.min(n,r)-Math.max(a,l)+1),u=a<this.LAZY_EDGE_THRESHOLD,p=n>s-this.LAZY_EDGE_THRESHOLD;if((u||p)&&e<this.LAZY_MAX_PADDING&&o>=3){this._expandScheduled=!0,requestAnimationFrame(()=>{this._expandScheduled=!1,this._resizePadding(e+this.LAZY_CHUNK_SIZE)});return}const c=Math.max(0,e-a),g=Math.max(0,n-(e+i-1)),h=Math.max(c+this.LAZY_CHUNK_SIZE,g+this.LAZY_CHUNK_SIZE);e>h+this.LAZY_CHUNK_SIZE&&(this._expandScheduled=!0,requestAnimationFrame(()=>{this._expandScheduled=!1,this._resizePadding(h)}))}render(){if(this.marketData.length===0)return;let t=null;try{const m=this.chart.getOption();if(m&&m.dataZoom&&m.dataZoom.length>0){const C=m.dataZoom.find(v=>v.type==="slider"||v.type==="inside");C&&(t={start:C.start,end:C.end})}}catch{}const e=this.options.databox?.position,i=this.leftSidebar.style.display,s=this.rightSidebar.style.display,a=e==="left"?"block":"none",n=e==="right"?"block":"none";(i!==a||s!==n)&&(this.leftSidebar.style.display=a,this.rightSidebar.style.display=n,this.chart.resize());const l=this.dataIndexOffset,r=[...Array(l).fill(""),...this.marketData.map(m=>new Date(m.time).toLocaleString()),...Array(l).fill("")],o=Bt.calculate(this.chart.getHeight(),this.indicators,this.options,this.isMainCollapsed,this.maximizedPaneId,this.marketData,this._mainHeightOverride??void 0);if(this._lastLayout=o,!t&&o.dataZoom&&this.marketData.length>0){const m=this.marketData.length,C=r.length,v=l/C,_=m/C;o.dataZoom.forEach(k=>{if(k.start!==void 0){const M=k.start/100,S=v+M*_;k.start=S*100}if(k.end!==void 0){const M=k.end/100,S=v+M*_;k.end=S*100}})}t&&o.dataZoom&&o.dataZoom.forEach(m=>{m.start=t.start,m.end=t.end}),o.xAxis.forEach(m=>{m.data=r,m.boundaryGap=!1});const u=wt.buildCandlestickSeries(this.marketData,this.options),p={value:[NaN,NaN,NaN,NaN],itemStyle:{opacity:0}};u.data=[...Array(l).fill(p),...u.data,...Array(l).fill(p)];const c=[...Array(l).fill(null),...this.marketData,...Array(l).fill(null)],{series:g,barColors:h}=wt.buildIndicatorSeries(this.indicators,this.timeToIndex,o.paneLayout,r.length,l,c,o.overlayYAxisMap,o.separatePaneYAxisOffset);u.data=u.data.map((m,C)=>h[C]?{value:m.value||m,itemStyle:{color:h[C],color0:h[C]}}:m);const f=[];this.indicators.forEach((m,C)=>{m.paneIndex===0&&f.push({id:C,titleColor:m.titleColor})});const y=oi.build(o,this.options,this.toggleIndicator.bind(this),this.isMainCollapsed,this.maximizedPaneId,f),x=new Map;this.drawings.forEach(m=>{const C=m.paneIndex||0;x.has(C)||x.set(C,[]),x.get(C).push(m)});const b=[];x.forEach((m,C)=>{b.push({type:"custom",name:`drawings-pane-${C}`,xAxisIndex:C,yAxisIndex:C,clip:!0,renderItem:(v,_)=>{const k=m[v.dataIndex];if(!k)return;const M=this.drawingRenderers.get(k.type);if(!M)return;const S=this.dataIndexOffset,z=k.points.map(T=>_.coord([T.timeIndex+S,T.value]));return M.render({drawing:k,pixelPoints:z,isSelected:k.id===this.selectedDrawingId,api:_})},data:m.map(v=>{const _=[];return v.points.forEach(k=>{_.push(k.timeIndex+this.dataIndexOffset,k.value)}),_}),encode:(()=>{const v=m.reduce((M,S)=>Math.max(M,S.points.length),0),_=Array.from({length:v},(M,S)=>S*2),k=Array.from({length:v},(M,S)=>S*2+1);return{x:_,y:k}})(),z:100,silent:!1})});const D=m=>{const C=ai.format(m,this.options),v=this.options.databox?.position;return v==="left"?(this.leftSidebar.innerHTML=C,""):v==="right"?(this.rightSidebar.innerHTML=C,""):this.options.databox?`<div style="min-width: 200px;">${C}</div>`:""},w=[];this.indicators.forEach(m=>{Object.values(m.plots).forEach(C=>{C.options?.style==="table"&&C.data?.forEach(v=>{(Array.isArray(v.value)?v.value:[v.value]).forEach(_=>{_&&!_._deleted&&(_._paneIndex=_.force_overlay?0:m.paneIndex,w.push(_))})})})});const P={backgroundColor:this.options.backgroundColor,animation:!1,legend:{show:!1},tooltip:{show:!0,showContent:!!this.options.databox,trigger:"axis",triggerOn:this.options.databox?.triggerOn??"mousemove",axisPointer:{type:"cross",label:{backgroundColor:"#475569"}},backgroundColor:"rgba(30, 41, 59, 0.9)",borderWidth:1,borderColor:"#334155",padding:10,textStyle:{color:"#fff",fontFamily:this.options.fontFamily||"sans-serif"},formatter:D,extraCssText:e!=="floating"&&e!==void 0?"display: none !important;":void 0,position:(m,C,v,_,k)=>{if(this.options.databox?.position==="floating"){const M={top:10};return M[["left","right"][+(m[0]<k.viewSize[0]/2)]]=30,M}return null}},axisPointer:{link:{xAxisIndex:"all"},label:{backgroundColor:"#475569"}},graphic:y,grid:o.grid,xAxis:o.xAxis,yAxis:o.yAxis,dataZoom:o.dataZoom,series:[u,...g,...b]};if(this.chart.setOption(P,!0),this._baseGraphics=y,this._lastTables=w,w.length>0){const m=this._buildTableGraphics();if(m.length>0){const C=[...y,...m];this.chart.setOption({graphic:C},{replaceMerge:["graphic"]})}}else this._tableGraphicIds=[];st.clearAll(this.overlayContainer)}}var Ii=Object.defineProperty,_i=(d,t,e)=>t in d?Ii(d,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):d[t]=e,lt=(d,t,e)=>(_i(d,typeof t!="symbol"?t+"":t,e),e);class nt{constructor(t){lt(this,"id"),lt(this,"name"),lt(this,"icon"),lt(this,"context"),lt(this,"eventListeners",[]),lt(this,"_snapIndicator",null),lt(this,"_snapMoveHandler",null),lt(this,"_snapKeyDownHandler",null),lt(this,"_snapKeyUpHandler",null),lt(this,"_snapBlurHandler",null),lt(this,"_snapActive",!1),lt(this,"_lastMouseEvent",null),this.id=t.id,this.name=t.name,this.icon=t.icon}init(t){this.context=t,this.onInit()}onInit(){}activate(){this.onActivate(),this._bindSnapIndicator(),this.context.events.emit("plugin:activated",this.id)}onActivate(){}deactivate(){this._unbindSnapIndicator(),this.onDeactivate(),this.context.events.emit("plugin:deactivated",this.id)}onDeactivate(){}destroy(){this._unbindSnapIndicator(),this.removeAllListeners(),this.onDestroy()}onDestroy(){}on(t,e){this.context.events.on(t,e),this.eventListeners.push({event:t,handler:e})}off(t,e){this.context.events.off(t,e),this.eventListeners=this.eventListeners.filter(i=>i.event!==t||i.handler!==e)}removeAllListeners(){this.eventListeners.forEach(({event:t,handler:e})=>{this.context.events.off(t,e)}),this.eventListeners=[]}get chart(){return this.context.getChart()}get marketData(){return this.context.getMarketData()}getPoint(t){const e=t.offsetX,i=t.offsetY,s=t.event;if(s?.ctrlKey||s?.metaKey){const a=this.context.snapToCandle({x:e,y:i});return[a.x,a.y]}return[e,i]}_bindSnapIndicator(){const t=this.context.getChart().getZr();this._snapMoveHandler=e=>{this._lastMouseEvent=e,e.event?.ctrlKey||e.event?.metaKey?this._showSnapAt(e.offsetX,e.offsetY):this._hideSnap()},this._snapKeyDownHandler=e=>{(e.key==="Control"||e.key==="Meta")&&this._lastMouseEvent&&this._showSnapAt(this._lastMouseEvent.offsetX,this._lastMouseEvent.offsetY)},this._snapKeyUpHandler=e=>{(e.key==="Control"||e.key==="Meta")&&this._hideSnap()},this._snapBlurHandler=()=>{this._hideSnap()},t.on("mousemove",this._snapMoveHandler),window.addEventListener("keydown",this._snapKeyDownHandler),window.addEventListener("keyup",this._snapKeyUpHandler),window.addEventListener("blur",this._snapBlurHandler)}_unbindSnapIndicator(){if(this._snapMoveHandler){try{this.context.getChart().getZr().off("mousemove",this._snapMoveHandler)}catch{}this._snapMoveHandler=null}this._snapKeyDownHandler&&(window.removeEventListener("keydown",this._snapKeyDownHandler),this._snapKeyDownHandler=null),this._snapKeyUpHandler&&(window.removeEventListener("keyup",this._snapKeyUpHandler),this._snapKeyUpHandler=null),this._snapBlurHandler&&(window.removeEventListener("blur",this._snapBlurHandler),this._snapBlurHandler=null),this._removeSnapGraphic(),this._lastMouseEvent=null}_removeSnapGraphic(){if(this._snapIndicator){try{this.context.getChart().getZr().remove(this._snapIndicator)}catch{}this._snapIndicator=null,this._snapActive=!1}}_showSnapAt(t,e){const i=this.context.snapToCandle({x:t,y:e}),s=this.context.getChart().getZr();this._snapIndicator||(this._snapIndicator=new G.graphic.Circle({shape:{cx:0,cy:0,r:5},style:{fill:"rgba(59, 130, 246, 0.3)",stroke:"#3b82f6",lineWidth:1.5},z:9999,silent:!0}),s.add(this._snapIndicator)),this._snapIndicator.setShape({cx:i.x,cy:i.y}),this._snapIndicator.show(),this._snapActive=!0}_hideSnap(){this._snapIndicator&&this._snapActive&&(this._snapIndicator.hide(),this._snapActive=!1)}}var Pi=Object.defineProperty,Ai=(d,t,e)=>t in d?Pi(d,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):d[t]=e,Q=(d,t,e)=>(Ai(d,typeof t!="symbol"?t+"":t,e),e);class ki extends nt{constructor(t={}){super({id:"measure",name:t?.name||"Measure",icon:t?.icon||'<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="#e3e3e3"><path d="M160-240q-33 0-56.5-23.5T80-320v-320q0-33 23.5-56.5T160-720h640q33 0 56.5 23.5T880-640v320q0 33-23.5 56.5T800-240H160Zm0-80h640v-320H680v160h-80v-160h-80v160h-80v-160h-80v160h-80v-160H160v320Zm120-160h80-80Zm160 0h80-80Zm160 0h80-80Zm-120 0Z"/></svg>'}),Q(this,"zr"),Q(this,"state","idle"),Q(this,"startPoint",null),Q(this,"endPoint",null),Q(this,"group",null),Q(this,"rect",null),Q(this,"labelRect",null),Q(this,"labelText",null),Q(this,"lineV",null),Q(this,"lineH",null),Q(this,"arrowStart",null),Q(this,"arrowEnd",null),Q(this,"onMouseDown",()=>{this.state==="finished"&&this.removeGraphic()}),Q(this,"onChartInteraction",()=>{this.group&&this.removeGraphic()}),Q(this,"onClick",e=>{this.state==="idle"?(this.state="drawing",this.startPoint=this.getPoint(e),this.endPoint=this.getPoint(e),this.initGraphic(),this.updateGraphic()):this.state==="drawing"&&(this.state="finished",this.endPoint=this.getPoint(e),this.updateGraphic(),this.context.disableTools(),this.enableClearListeners())}),Q(this,"clearHandlers",{}),Q(this,"onMouseMove",e=>{this.state==="drawing"&&(this.endPoint=this.getPoint(e),this.updateGraphic())})}onInit(){this.zr=this.chart.getZr()}onActivate(){this.state="idle",this.chart.getZr().setCursorStyle("crosshair"),this.zr.on("click",this.onClick),this.zr.on("mousemove",this.onMouseMove)}onDeactivate(){this.state="idle",this.chart.getZr().setCursorStyle("default"),this.zr.off("click",this.onClick),this.zr.off("mousemove",this.onMouseMove),this.disableClearListeners(),this.state==="drawing"&&this.removeGraphic()}onDestroy(){this.removeGraphic()}enableClearListeners(){const t=()=>{this.removeGraphic()};setTimeout(()=>{this.zr.on("click",t)},10),this.zr.on("mousedown",this.onMouseDown),this.context.events.on("chart:dataZoom",this.onChartInteraction),this.clearHandlers={click:t,mousedown:this.onMouseDown,dataZoom:this.onChartInteraction}}disableClearListeners(){this.clearHandlers.click&&this.zr.off("click",this.clearHandlers.click),this.clearHandlers.mousedown&&this.zr.off("mousedown",this.clearHandlers.mousedown),this.clearHandlers.dataZoom&&this.context.events.off("chart:dataZoom",this.clearHandlers.dataZoom),this.clearHandlers={}}initGraphic(){this.group||(this.group=new G.graphic.Group,this.rect=new G.graphic.Rect({shape:{x:0,y:0,width:0,height:0},style:{fill:"rgba(0,0,0,0)",stroke:"transparent",lineWidth:0},z:100}),this.lineV=new G.graphic.Line({shape:{x1:0,y1:0,x2:0,y2:0},style:{stroke:"#fff",lineWidth:1,lineDash:[4,4]},z:101}),this.lineH=new G.graphic.Line({shape:{x1:0,y1:0,x2:0,y2:0},style:{stroke:"#fff",lineWidth:1,lineDash:[4,4]},z:101}),this.arrowStart=new G.graphic.Polygon({shape:{points:[[0,0],[-5,10],[5,10]]},style:{fill:"#fff"},z:102}),this.arrowEnd=new G.graphic.Polygon({shape:{points:[[0,0],[-5,-10],[5,-10]]},style:{fill:"#fff"},z:102}),this.labelRect=new G.graphic.Rect({shape:{x:0,y:0,width:0,height:0,r:4},style:{fill:"transparent",stroke:"transparent",lineWidth:0,shadowBlur:5,shadowColor:"rgba(0,0,0,0.3)"},z:102}),this.labelText=new G.graphic.Text({style:{x:0,y:0,text:"",fill:"#fff",font:"12px sans-serif",align:"center",verticalAlign:"middle"},z:103}),this.group.add(this.rect),this.group.add(this.lineV),this.group.add(this.lineH),this.group.add(this.arrowStart),this.group.add(this.arrowEnd),this.group.add(this.labelRect),this.group.add(this.labelText),this.zr.add(this.group))}removeGraphic(){this.group&&(this.zr.remove(this.group),this.group=null,this.disableClearListeners())}updateGraphic(){if(!this.startPoint||!this.endPoint||!this.group)return;const[t,e]=this.startPoint,[i,s]=this.endPoint,a=this.context.coordinateConversion.pixelToData({x:t,y:e}),n=this.context.coordinateConversion.pixelToData({x:i,y:s});if(!a||!n)return;const l=Math.round(a.timeIndex),r=Math.round(n.timeIndex),o=a.value,u=n.value,p=r-l,c=u-o,g=c/o*100,h=c>=0,f=h?"rgba(33, 150, 243, 0.2)":"rgba(236, 0, 0, 0.2)",y=h?"#2196F3":"#ec0000";this.rect.setShape({x:Math.min(t,i),y:Math.min(e,s),width:Math.abs(i-t),height:Math.abs(s-e)}),this.rect.setStyle({fill:f});const x=(t+i)/2,b=(e+s)/2;this.lineV.setShape({x1:x,y1:e,x2:x,y2:s}),this.lineV.setStyle({stroke:y}),this.lineH.setShape({x1:t,y1:b,x2:i,y2:b}),this.lineH.setStyle({stroke:y});const D=Math.min(e,s),w=Math.max(e,s);this.arrowStart.setStyle({fill:"none"}),this.arrowEnd.setStyle({fill:"none"}),h?(this.arrowStart.setShape({points:[[x,D],[x-4,D+6],[x+4,D+6]]}),this.arrowStart.setStyle({fill:y})):(this.arrowEnd.setShape({points:[[x,w],[x-4,w-6],[x+4,w-6]]}),this.arrowEnd.setStyle({fill:y}));const P=[`${c.toFixed(2)} (${g.toFixed(2)}%)`,`${p} bars`].join(`
|
|
40
|
-
`),m=140,C=40,v=Math.max(e,s),_=Math.min(e,s);let k=(t+i)/2-m/2,M=v+10;const S=this.chart.getHeight();M+C>S&&(M=_-C-10),this.labelRect.setShape({x:k,y:M,width:m,height:C}),this.labelRect.setStyle({fill:"#1e293b",stroke:y,lineWidth:1}),this.labelText.setStyle({x:k+m/2,y:M+C/2,text:P,fill:"#fff"})}}var Di=Object.defineProperty,Mi=(d,t,e)=>t in d?Di(d,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):d[t]=e,Si=(d,t,e)=>(Mi(d,typeof t!="symbol"?t+"":t,e),e);class re{constructor(){Si(this,"type","line")}render(t){const{drawing:e,pixelPoints:i,isSelected:s}=t,[a,n]=i[0],[l,r]=i[1],o=e.style?.color||"#3b82f6";return{type:"group",children:[{type:"line",name:"line",shape:{x1:a,y1:n,x2:l,y2:r},style:{stroke:o,lineWidth:e.style?.lineWidth||2}},{type:"circle",name:"point-0",shape:{cx:a,cy:n,r:4},style:{fill:"#fff",stroke:o,lineWidth:1,opacity:s?1:0}},{type:"circle",name:"point-1",shape:{cx:l,cy:r,r:4},style:{fill:"#fff",stroke:o,lineWidth:1,opacity:s?1:0}}]}}}var Gi=Object.defineProperty,$i=(d,t,e)=>t in d?Gi(d,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):d[t]=e,ct=(d,t,e)=>($i(d,typeof t!="symbol"?t+"":t,e),e);class zi extends nt{constructor(t={}){super({id:"trend-line",name:t?.name||"Trend Line",icon:t?.icon||'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="2" y1="22" x2="22" y2="2" /></svg>'}),ct(this,"zr"),ct(this,"state","idle"),ct(this,"startPoint",null),ct(this,"endPoint",null),ct(this,"group",null),ct(this,"line",null),ct(this,"startCircle",null),ct(this,"endCircle",null),ct(this,"onClick",e=>{if(this.state==="idle")this.state="drawing",this.startPoint=this.getPoint(e),this.endPoint=this.getPoint(e),this.initGraphic(),this.updateGraphic();else if(this.state==="drawing"){if(this.state="finished",this.endPoint=this.getPoint(e),this.updateGraphic(),this.startPoint&&this.endPoint){const i=this.context.coordinateConversion.pixelToData({x:this.startPoint[0],y:this.startPoint[1]}),s=this.context.coordinateConversion.pixelToData({x:this.endPoint[0],y:this.endPoint[1]});if(i&&s){const a=i.paneIndex||0;this.context.addDrawing({id:`line-${Date.now()}`,type:"line",points:[i,s],paneIndex:a,style:{color:"#3b82f6",lineWidth:2}})}}this.removeGraphic(),this.context.disableTools()}}),ct(this,"onMouseMove",e=>{this.state==="drawing"&&(this.endPoint=this.getPoint(e),this.updateGraphic())})}onInit(){this.zr=this.chart.getZr(),this.context.registerDrawingRenderer(new re)}onActivate(){this.state="idle",this.chart.getZr().setCursorStyle("crosshair"),this.zr.on("click",this.onClick),this.zr.on("mousemove",this.onMouseMove)}onDeactivate(){this.state="idle",this.chart.getZr().setCursorStyle("default"),this.zr.off("click",this.onClick),this.zr.off("mousemove",this.onMouseMove),this.state==="drawing"&&this.removeGraphic()}onDestroy(){this.removeGraphic()}initGraphic(){this.group||(this.group=new G.graphic.Group,this.line=new G.graphic.Line({shape:{x1:0,y1:0,x2:0,y2:0},style:{stroke:"#3b82f6",lineWidth:2},z:100}),this.startCircle=new G.graphic.Circle({shape:{cx:0,cy:0,r:4},style:{fill:"#fff",stroke:"#3b82f6",lineWidth:1},z:101}),this.endCircle=new G.graphic.Circle({shape:{cx:0,cy:0,r:4},style:{fill:"#fff",stroke:"#3b82f6",lineWidth:1},z:101}),this.group.add(this.line),this.group.add(this.startCircle),this.group.add(this.endCircle),this.zr.add(this.group))}removeGraphic(){this.group&&(this.zr.remove(this.group),this.group=null)}updateGraphic(){if(!this.startPoint||!this.endPoint||!this.group)return;const[t,e]=this.startPoint,[i,s]=this.endPoint;this.line.setShape({x1:t,y1:e,x2:i,y2:s}),this.startCircle.setShape({cx:t,cy:e}),this.endCircle.setShape({cx:i,cy:s})}}var Ei=Object.defineProperty,Li=(d,t,e)=>t in d?Ei(d,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):d[t]=e,Ti=(d,t,e)=>(Li(d,typeof t!="symbol"?t+"":t,e),e);const qt=[0,.236,.382,.5,.618,.786,1],Wt=["#787b86","#f44336","#ff9800","#4caf50","#2196f3","#00bcd4","#787b86"];class le{constructor(){Ti(this,"type","fibonacci")}render(t){const{drawing:e,pixelPoints:i,isSelected:s}=t,[a,n]=i[0],[l,r]=i[1],o=e.style?.color||"#3b82f6",u=Math.min(a,l),p=Math.max(a,l),c=p-u,g=r-n,h=e.points[0].value,f=e.points[1].value,y=f-h,x=[],b=[];return qt.forEach((D,w)=>{const P=r-g*D,m=Wt[w%Wt.length];b.push({type:"line",shape:{x1:u,y1:P,x2:p,y2:P},style:{stroke:m,lineWidth:1},silent:!0});const C=f-y*D;if(b.push({type:"text",style:{text:`${D} (${C.toFixed(2)})`,x:u+5,y:P-10,fill:m,fontSize:10},silent:!0}),w<qt.length-1){const v=qt[w+1],_=r-g*v,k=Math.abs(_-P),M=Math.min(P,_);x.push({type:"rect",name:"line",shape:{x:u,y:M,width:c,height:k},style:{fill:Wt[(w+1)%Wt.length],opacity:.1}})}}),{type:"group",children:[...x,...b,{type:"line",name:"line",shape:{x1:a,y1:n,x2:l,y2:r},style:{stroke:"#999",lineWidth:1,lineDash:[4,4]}},{type:"circle",name:"point-0",shape:{cx:a,cy:n,r:4},style:{fill:"#fff",stroke:o,lineWidth:1,opacity:s?1:0},z:100},{type:"circle",name:"point-1",shape:{cx:l,cy:r,r:4},style:{fill:"#fff",stroke:o,lineWidth:1,opacity:s?1:0},z:100}]}}}var Wi=Object.defineProperty,Ni=(d,t,e)=>t in d?Wi(d,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):d[t]=e,ft=(d,t,e)=>(Ni(d,typeof t!="symbol"?t+"":t,e),e);class Fi extends nt{constructor(t={}){super({id:"fibonacci-tool",name:t.name||"Fibonacci Retracement",icon:t.icon||'<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="#e3e3e3"><path d="M120-80v-80h720v80H120Zm0-240v-80h720v80H120Zm0-240v-80h720v80H120Zm0-240v-80h720v80H120Z"/></svg>'}),ft(this,"startPoint",null),ft(this,"endPoint",null),ft(this,"state","idle"),ft(this,"graphicGroup",null),ft(this,"levels",[0,.236,.382,.5,.618,.786,1]),ft(this,"colors",["#787b86","#f44336","#ff9800","#4caf50","#2196f3","#00bcd4","#787b86"]),ft(this,"onClick",e=>{this.state==="idle"?(this.state="drawing",this.startPoint=this.getPoint(e),this.endPoint=this.getPoint(e),this.initGraphic(),this.updateGraphic()):this.state==="drawing"&&(this.state="finished",this.endPoint=this.getPoint(e),this.updateGraphic(),this.saveDrawing(),this.removeGraphic(),this.context.disableTools())}),ft(this,"onMouseMove",e=>{this.state==="drawing"&&(this.endPoint=this.getPoint(e),this.updateGraphic())})}onInit(){this.context.registerDrawingRenderer(new le)}onActivate(){this.state="idle",this.startPoint=null,this.endPoint=null,this.context.getChart().getZr().setCursorStyle("crosshair"),this.bindEvents()}onDeactivate(){this.state="idle",this.startPoint=null,this.endPoint=null,this.removeGraphic(),this.unbindEvents(),this.context.getChart().getZr().setCursorStyle("default")}bindEvents(){const t=this.context.getChart().getZr();t.on("click",this.onClick),t.on("mousemove",this.onMouseMove)}unbindEvents(){const t=this.context.getChart().getZr();t.off("click",this.onClick),t.off("mousemove",this.onMouseMove)}initGraphic(){this.graphicGroup=new G.graphic.Group,this.context.getChart().getZr().add(this.graphicGroup)}removeGraphic(){this.graphicGroup&&(this.context.getChart().getZr().remove(this.graphicGroup),this.graphicGroup=null)}updateGraphic(){if(!this.graphicGroup||!this.startPoint||!this.endPoint)return;this.graphicGroup.removeAll();const t=this.startPoint[0],e=this.startPoint[1],i=this.endPoint[0],s=this.endPoint[1],a=new G.graphic.Line({shape:{x1:t,y1:e,x2:i,y2:s},style:{stroke:"#999",lineWidth:1,lineDash:[4,4]},silent:!0});this.graphicGroup.add(a);const n=Math.min(t,i),l=Math.max(t,i),r=l-n,o=s-e;this.levels.forEach((u,p)=>{const c=s-o*u,g=this.colors[p%this.colors.length],h=new G.graphic.Line({shape:{x1:n,y1:c,x2:l,y2:c},style:{stroke:g,lineWidth:1},silent:!0});if(this.graphicGroup.add(h),p<this.levels.length-1){const f=this.levels[p+1],y=s-o*f,x=Math.abs(y-c),b=Math.min(c,y),D=new G.graphic.Rect({shape:{x:n,y:b,width:r,height:x},style:{fill:this.colors[(p+1)%this.colors.length],opacity:.1},silent:!0});this.graphicGroup.add(D)}})}saveDrawing(){if(!this.startPoint||!this.endPoint)return;const t=this.context.coordinateConversion.pixelToData({x:this.startPoint[0],y:this.startPoint[1]}),e=this.context.coordinateConversion.pixelToData({x:this.endPoint[0],y:this.endPoint[1]});if(t&&e){const i=t.paneIndex||0;this.context.addDrawing({id:`fib-${Date.now()}`,type:"fibonacci",points:[t,e],paneIndex:i,style:{color:"#3b82f6",lineWidth:1}})}}}var Zi=Object.defineProperty,Oi=(d,t,e)=>t in d?Zi(d,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):d[t]=e,Hi=(d,t,e)=>(Oi(d,typeof t!="symbol"?t+"":t,e),e);const Nt=[0,.236,.382,.5,.618,.786,1],Ft=["#787b86","#f44336","#ff9800","#4caf50","#2196f3","#00bcd4","#787b86"];class he{constructor(){Hi(this,"type","fibonacci_channel")}render(t){const{drawing:e,pixelPoints:i,isSelected:s}=t,[a,n]=i[0],[l,r]=i[1],[o,u]=i[2],p=e.style?.color||"#3b82f6",c=l-a,g=r-n,h=Math.sqrt(c*c+g*g);if(h===0)return;const f=-g/h,y=c/h,x=(o-a)*f+(u-n)*y,b=[],D=[];return Nt.forEach((w,P)=>{const m=f*x*w,C=y*x*w,v=a+m,_=n+C,k=l+m,M=r+C;if(D.push({lx1:v,ly1:_,lx2:k,ly2:M}),P<Nt.length-1){const S=Nt[P+1],z=f*x*S,T=y*x*S;b.push({type:"polygon",name:"line",shape:{points:[[v,_],[k,M],[l+z,r+T],[a+z,n+T]]},style:{fill:Ft[(P+1)%Ft.length],opacity:.1}})}}),D.forEach((w,P)=>{const m=Ft[P%Ft.length];b.push({type:"line",shape:{x1:w.lx1,y1:w.ly1,x2:w.lx2,y2:w.ly2},style:{stroke:m,lineWidth:1},silent:!0}),b.push({type:"text",style:{text:`${Nt[P]}`,x:w.lx2+5,y:w.ly2-5,fill:m,fontSize:10},silent:!0})}),b.push({type:"line",name:"line",shape:{x1:a,y1:n,x2:l,y2:r},style:{stroke:"#999",lineWidth:1,lineDash:[4,4]}}),b.push({type:"circle",name:"point-0",shape:{cx:a,cy:n,r:4},style:{fill:"#fff",stroke:p,lineWidth:1,opacity:s?1:0},z:100}),b.push({type:"circle",name:"point-1",shape:{cx:l,cy:r,r:4},style:{fill:"#fff",stroke:p,lineWidth:1,opacity:s?1:0},z:100}),b.push({type:"circle",name:"point-2",shape:{cx:o,cy:u,r:4},style:{fill:"#fff",stroke:p,lineWidth:1,opacity:s?1:0},z:100}),{type:"group",children:b}}}var Ri=Object.defineProperty,Bi=(d,t,e)=>t in d?Ri(d,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):d[t]=e,pt=(d,t,e)=>(Bi(d,typeof t!="symbol"?t+"":t,e),e);class ji extends nt{constructor(t={}){super({id:"fibonacci-channel-tool",name:t.name||"Fibonacci Channel",icon:t.icon||'<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="#e3e3e3"><path d="M120-200v-80l80-80H120v-80h160l120-120H120v-80h360l120-120H120v-80h720v80H520l-120 120h440v80H320L200-440h640v80H280l-80 80h640v80H120Z"/></svg>'}),pt(this,"startPoint",null),pt(this,"endPoint",null),pt(this,"widthPoint",null),pt(this,"state","idle"),pt(this,"graphicGroup",null),pt(this,"levels",[0,.236,.382,.5,.618,.786,1]),pt(this,"colors",["#787b86","#f44336","#ff9800","#4caf50","#2196f3","#00bcd4","#787b86"]),pt(this,"onClick",e=>{this.state==="idle"?(this.state="drawing-baseline",this.startPoint=this.getPoint(e),this.endPoint=this.getPoint(e),this.initGraphic(),this.updateGraphic()):this.state==="drawing-baseline"?(this.state="drawing-width",this.endPoint=this.getPoint(e),this.widthPoint=this.getPoint(e),this.updateGraphic()):this.state==="drawing-width"&&(this.state="finished",this.widthPoint=this.getPoint(e),this.updateGraphic(),this.saveDrawing(),this.removeGraphic(),this.context.disableTools())}),pt(this,"onMouseMove",e=>{this.state==="drawing-baseline"?(this.endPoint=this.getPoint(e),this.updateGraphic()):this.state==="drawing-width"&&(this.widthPoint=this.getPoint(e),this.updateGraphic())})}onInit(){this.context.registerDrawingRenderer(new he)}onActivate(){this.state="idle",this.startPoint=null,this.endPoint=null,this.widthPoint=null,this.context.getChart().getZr().setCursorStyle("crosshair"),this.bindEvents()}onDeactivate(){this.state="idle",this.startPoint=null,this.endPoint=null,this.widthPoint=null,this.removeGraphic(),this.unbindEvents(),this.context.getChart().getZr().setCursorStyle("default")}bindEvents(){const t=this.context.getChart().getZr();t.on("click",this.onClick),t.on("mousemove",this.onMouseMove)}unbindEvents(){const t=this.context.getChart().getZr();t.off("click",this.onClick),t.off("mousemove",this.onMouseMove)}initGraphic(){this.graphicGroup=new G.graphic.Group,this.context.getChart().getZr().add(this.graphicGroup)}removeGraphic(){this.graphicGroup&&(this.context.getChart().getZr().remove(this.graphicGroup),this.graphicGroup=null)}updateGraphic(){if(!this.graphicGroup||!this.startPoint||!this.endPoint)return;this.graphicGroup.removeAll();const t=this.startPoint[0],e=this.startPoint[1],i=this.endPoint[0],s=this.endPoint[1];if(this.graphicGroup.add(new G.graphic.Line({shape:{x1:t,y1:e,x2:i,y2:s},style:{stroke:"#787b86",lineWidth:2},silent:!0})),this.widthPoint&&this.state!=="drawing-baseline"){const a=this.widthPoint,n=i-t,l=s-e,r=Math.sqrt(n*n+l*l);if(r===0)return;const o=-l/r,u=n/r,p=(a[0]-t)*o+(a[1]-e)*u;this.levels.forEach((c,g)=>{const h=o*p*c,f=u*p*c,y=t+h,x=e+f,b=i+h,D=s+f,w=this.colors[g%this.colors.length];if(this.graphicGroup.add(new G.graphic.Line({shape:{x1:y,y1:x,x2:b,y2:D},style:{stroke:w,lineWidth:1},silent:!0})),g<this.levels.length-1){const P=this.levels[g+1],m=o*p*P,C=u*p*P,v=t+m,_=e+C,k=i+m,M=s+C;this.graphicGroup.add(new G.graphic.Polygon({shape:{points:[[y,x],[b,D],[k,M],[v,_]]},style:{fill:this.colors[(g+1)%this.colors.length],opacity:.1},silent:!0}))}})}}saveDrawing(){if(!this.startPoint||!this.endPoint||!this.widthPoint)return;const t=this.context.coordinateConversion.pixelToData({x:this.startPoint[0],y:this.startPoint[1]}),e=this.context.coordinateConversion.pixelToData({x:this.endPoint[0],y:this.endPoint[1]}),i=this.context.coordinateConversion.pixelToData({x:this.widthPoint[0],y:this.widthPoint[1]});if(t&&e&&i){const s=t.paneIndex||0;this.context.addDrawing({id:`fib-channel-${Date.now()}`,type:"fibonacci_channel",points:[t,e,i],paneIndex:s,style:{color:"#3b82f6",lineWidth:1}})}}}var Yi=Object.defineProperty,Xi=(d,t,e)=>t in d?Yi(d,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):d[t]=e,qi=(d,t,e)=>(Xi(d,typeof t!="symbol"?t+"":t,e),e);const Vt=[0,.236,.382,.5,.618,.786,1],yt=["#787b86","#f44336","#ff9800","#4caf50","#2196f3","#00bcd4","#787b86"];class ce{constructor(){qi(this,"type","fib_speed_resistance_fan")}render(t){const{drawing:e,pixelPoints:i,isSelected:s}=t,[a,n]=i[0],[l,r]=i[1],o=e.style?.color||"#3b82f6",u=l-a,p=r-n,c=[],g=[],h=[];for(const f of Vt)g.push([a+u,n+p*f]),h.push([a+u*f,n+p]);for(let f=0;f<g.length-1;f++)c.push({type:"polygon",name:"line",shape:{points:[[a,n],g[f],g[f+1]]},style:{fill:yt[(f+1)%yt.length],opacity:.06}});for(let f=0;f<h.length-1;f++)c.push({type:"polygon",name:"line",shape:{points:[[a,n],h[f],h[f+1]]},style:{fill:yt[(f+1)%yt.length],opacity:.06}});return Vt.forEach((f,y)=>{const[x,b]=g[y],D=yt[y%yt.length];c.push({type:"line",shape:{x1:a,y1:n,x2:x,y2:b},style:{stroke:D,lineWidth:1},silent:!0}),c.push({type:"text",style:{text:`${f}`,x:x+3,y:b-2,fill:D,fontSize:9},silent:!0})}),Vt.forEach((f,y)=>{const[x,b]=h[y],D=yt[y%yt.length];c.push({type:"line",shape:{x1:a,y1:n,x2:x,y2:b},style:{stroke:D,lineWidth:1},silent:!0}),c.push({type:"text",style:{text:`${f}`,x:x-2,y:b+8,fill:D,fontSize:9},silent:!0})}),c.push({type:"line",name:"line",shape:{x1:l,y1:n,x2:l,y2:r},style:{stroke:"#555",lineWidth:1,lineDash:[3,3]}}),c.push({type:"line",name:"line",shape:{x1:a,y1:r,x2:l,y2:r},style:{stroke:"#555",lineWidth:1,lineDash:[3,3]}}),c.push({type:"line",name:"line",shape:{x1:a,y1:n,x2:l,y2:r},style:{stroke:"#999",lineWidth:1,lineDash:[4,4]}}),c.push({type:"circle",name:"point-0",shape:{cx:a,cy:n,r:4},style:{fill:"#fff",stroke:o,lineWidth:1,opacity:s?1:0},z:100}),c.push({type:"circle",name:"point-1",shape:{cx:l,cy:r,r:4},style:{fill:"#fff",stroke:o,lineWidth:1,opacity:s?1:0},z:100}),{type:"group",children:c}}}var Vi=Object.defineProperty,Ui=(d,t,e)=>t in d?Vi(d,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):d[t]=e,It=(d,t,e)=>(Ui(d,typeof t!="symbol"?t+"":t,e),e);const mt=[0,.236,.382,.5,.618,.786,1],_t=["#787b86","#f44336","#ff9800","#4caf50","#2196f3","#00bcd4","#787b86"];class Ki extends nt{constructor(t={}){super({id:"fib-speed-resistance-fan-tool",name:t.name||"Fib Speed Resistance Fan",icon:t.icon||'<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#e3e3e3"><path d="M2 21L22 3M2 21l20-6M2 21l20-9M2 21l20-12M2 21l20-15M2 21l6-18M2 21l9-18M2 21l12-18M2 21l15-18" stroke="#e3e3e3" stroke-width="1" fill="none"/></svg>'}),It(this,"startPoint",null),It(this,"endPoint",null),It(this,"state","idle"),It(this,"graphicGroup",null),It(this,"onClick",e=>{this.state==="idle"?(this.state="drawing",this.startPoint=this.getPoint(e),this.endPoint=this.getPoint(e),this.initGraphic(),this.updateGraphic()):this.state==="drawing"&&(this.state="finished",this.endPoint=this.getPoint(e),this.updateGraphic(),this.saveDrawing(),this.removeGraphic(),this.context.disableTools())}),It(this,"onMouseMove",e=>{this.state==="drawing"&&(this.endPoint=this.getPoint(e),this.updateGraphic())})}onInit(){this.context.registerDrawingRenderer(new ce)}onActivate(){this.state="idle",this.startPoint=null,this.endPoint=null,this.context.getChart().getZr().setCursorStyle("crosshair"),this.bindEvents()}onDeactivate(){this.state="idle",this.startPoint=null,this.endPoint=null,this.removeGraphic(),this.unbindEvents(),this.context.getChart().getZr().setCursorStyle("default")}bindEvents(){const t=this.context.getChart().getZr();t.on("click",this.onClick),t.on("mousemove",this.onMouseMove)}unbindEvents(){const t=this.context.getChart().getZr();t.off("click",this.onClick),t.off("mousemove",this.onMouseMove)}initGraphic(){this.graphicGroup=new G.graphic.Group,this.context.getChart().getZr().add(this.graphicGroup)}removeGraphic(){this.graphicGroup&&(this.context.getChart().getZr().remove(this.graphicGroup),this.graphicGroup=null)}updateGraphic(){if(!this.graphicGroup||!this.startPoint||!this.endPoint)return;this.graphicGroup.removeAll();const t=this.startPoint[0],e=this.startPoint[1],i=this.endPoint[0],s=this.endPoint[1],a=i-t,n=s-e;mt.forEach((l,r)=>{const o=_t[r%_t.length];this.graphicGroup.add(new G.graphic.Line({shape:{x1:t,y1:e,x2:t+a,y2:e+n*l},style:{stroke:o,lineWidth:1},silent:!0})),this.graphicGroup.add(new G.graphic.Line({shape:{x1:t,y1:e,x2:t+a*l,y2:e+n},style:{stroke:o,lineWidth:1},silent:!0}))});for(let l=0;l<mt.length-1;l++){const r=[t+a,e+n*mt[l]],o=[t+a,e+n*mt[l+1]];this.graphicGroup.add(new G.graphic.Polygon({shape:{points:[[t,e],r,o]},style:{fill:_t[(l+1)%_t.length],opacity:.06},silent:!0}))}for(let l=0;l<mt.length-1;l++){const r=[t+a*mt[l],e+n],o=[t+a*mt[l+1],e+n];this.graphicGroup.add(new G.graphic.Polygon({shape:{points:[[t,e],r,o]},style:{fill:_t[(l+1)%_t.length],opacity:.06},silent:!0}))}this.graphicGroup.add(new G.graphic.Line({shape:{x1:i,y1:e,x2:i,y2:s},style:{stroke:"#555",lineWidth:1,lineDash:[3,3]},silent:!0})),this.graphicGroup.add(new G.graphic.Line({shape:{x1:t,y1:s,x2:i,y2:s},style:{stroke:"#555",lineWidth:1,lineDash:[3,3]},silent:!0})),this.graphicGroup.add(new G.graphic.Line({shape:{x1:t,y1:e,x2:i,y2:s},style:{stroke:"#999",lineWidth:1,lineDash:[4,4]},silent:!0}))}saveDrawing(){if(!this.startPoint||!this.endPoint)return;const t=this.context.coordinateConversion.pixelToData({x:this.startPoint[0],y:this.startPoint[1]}),e=this.context.coordinateConversion.pixelToData({x:this.endPoint[0],y:this.endPoint[1]});t&&e&&this.context.addDrawing({id:`fib-fan-${Date.now()}`,type:"fib_speed_resistance_fan",points:[t,e],paneIndex:t.paneIndex||0,style:{color:"#3b82f6",lineWidth:1}})}}var Ji=Object.defineProperty,Qi=(d,t,e)=>t in d?Ji(d,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):d[t]=e,ts=(d,t,e)=>(Qi(d,typeof t!="symbol"?t+"":t,e),e);const de=[0,.236,.382,.5,.618,.786,1,1.272,1.618,2,2.618],pe=["#787b86","#f44336","#ff9800","#4caf50","#2196f3","#00bcd4","#787b86","#e91e63","#9c27b0","#673ab7","#3f51b5"];class ue{constructor(){ts(this,"type","fib_trend_extension")}render(t){const{drawing:e,pixelPoints:i,isSelected:s,api:a}=t,n=e.style?.color||"#3b82f6";if(i.length<3)return;const[l,r]=i[0],[o,u]=i[1],[p,c]=i[2],g=e.points,h=g[1].value-g[0].value,f=Math.min(l,o,p),y=Math.max(l,o,p),x=(y-f)*.5,b=f,D=y+x,w=[],P=[];for(let v=0;v<de.length;v++){const _=de[v],k=g[2].value+h*_;a.coord([g[2].timeIndex+t.drawing.points[2].timeIndex-g[2].timeIndex,k]);const M=c+(u-r)*_;P.push({level:_,y:M,price:k,color:pe[v%pe.length]})}for(let v=0;v<P.length-1;v++){const _=P[v],k=P[v+1],M=Math.min(_.y,k.y),S=Math.abs(k.y-_.y);w.push({type:"rect",name:"line",shape:{x:b,y:M,width:D-b,height:S},style:{fill:k.color,opacity:.06}})}for(const v of P)w.push({type:"line",shape:{x1:b,y1:v.y,x2:D,y2:v.y},style:{stroke:v.color,lineWidth:1},silent:!0}),w.push({type:"text",style:{text:`${v.level} (${v.price.toFixed(2)})`,x:D+4,y:v.y-6,fill:v.color,fontSize:9},silent:!0});w.push({type:"line",name:"line",shape:{x1:l,y1:r,x2:o,y2:u},style:{stroke:"#2196f3",lineWidth:1.5,lineDash:[5,4]}}),w.push({type:"line",name:"line",shape:{x1:o,y1:u,x2:p,y2:c},style:{stroke:"#ff9800",lineWidth:1.5,lineDash:[5,4]}}),w.push({type:"circle",name:"point-0",shape:{cx:l,cy:r,r:4},style:{fill:"#fff",stroke:n,lineWidth:1,opacity:s?1:0},z:100}),w.push({type:"circle",name:"point-1",shape:{cx:o,cy:u,r:4},style:{fill:"#fff",stroke:n,lineWidth:1,opacity:s?1:0},z:100}),w.push({type:"circle",name:"point-2",shape:{cx:p,cy:c,r:4},style:{fill:"#fff",stroke:n,lineWidth:1,opacity:s?1:0},z:100});const m=["1","2","3"],C=[i[0],i[1],i[2]];for(let v=0;v<3;v++){const[_,k]=C[v],M=(v===0||k<=C[v-1][1])&&(v===2||k<=C[v+1]?.[1]);w.push({type:"text",style:{text:m[v],x:_,y:M?k-14:k+16,fill:"#e2e8f0",fontSize:12,fontWeight:"bold",align:"center",verticalAlign:"middle"},silent:!0})}return{type:"group",children:w}}}var es=Object.defineProperty,is=(d,t,e)=>t in d?es(d,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):d[t]=e,kt=(d,t,e)=>(is(d,typeof t!="symbol"?t+"":t,e),e);const Zt=[0,.236,.382,.5,.618,.786,1,1.272,1.618,2,2.618],Ot=["#787b86","#f44336","#ff9800","#4caf50","#2196f3","#00bcd4","#787b86","#e91e63","#9c27b0","#673ab7","#3f51b5"];class ss extends nt{constructor(t={}){super({id:"fib-trend-extension-tool",name:t.name||"Fib Trend Extension",icon:t.icon||'<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="#e3e3e3"><path d="M120-80v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Z"/></svg>'}),kt(this,"points",[]),kt(this,"state","idle"),kt(this,"graphicGroup",null),kt(this,"onClick",e=>{const i=this.getPoint(e);this.state==="idle"?(this.state="drawing-trend",this.points=[i,[...i]],this.initGraphic(),this.updateGraphic()):this.state==="drawing-trend"?(this.state="drawing-retracement",this.points[1]=i,this.points.push([...i]),this.updateGraphic()):this.state==="drawing-retracement"&&(this.state="finished",this.points[2]=i,this.updateGraphic(),this.saveDrawing(),this.removeGraphic(),this.context.disableTools())}),kt(this,"onMouseMove",e=>{this.state==="drawing-trend"?(this.points[1]=this.getPoint(e),this.updateGraphic()):this.state==="drawing-retracement"&&(this.points[2]=this.getPoint(e),this.updateGraphic())})}onInit(){this.context.registerDrawingRenderer(new ue)}onActivate(){this.state="idle",this.points=[],this.context.getChart().getZr().setCursorStyle("crosshair"),this.bindEvents()}onDeactivate(){this.state="idle",this.points=[],this.removeGraphic(),this.unbindEvents(),this.context.getChart().getZr().setCursorStyle("default")}bindEvents(){const t=this.context.getChart().getZr();t.on("click",this.onClick),t.on("mousemove",this.onMouseMove)}unbindEvents(){const t=this.context.getChart().getZr();t.off("click",this.onClick),t.off("mousemove",this.onMouseMove)}initGraphic(){this.graphicGroup=new G.graphic.Group,this.context.getChart().getZr().add(this.graphicGroup)}removeGraphic(){this.graphicGroup&&(this.context.getChart().getZr().remove(this.graphicGroup),this.graphicGroup=null)}updateGraphic(){if(!this.graphicGroup)return;this.graphicGroup.removeAll();const[t,e]=this.points[0],[i,s]=this.points[1];if(this.graphicGroup.add(new G.graphic.Line({shape:{x1:t,y1:e,x2:i,y2:s},style:{stroke:"#2196f3",lineWidth:1.5,lineDash:[5,4]},silent:!0})),this.points.length>=3){const[a,n]=this.points[2];this.graphicGroup.add(new G.graphic.Line({shape:{x1:i,y1:s,x2:a,y2:n},style:{stroke:"#ff9800",lineWidth:1.5,lineDash:[5,4]},silent:!0}));const l=s-e,r=Math.min(t,i,a),o=Math.max(t,i,a),u=(o-r)*.5,p=r,c=o+u;for(let g=0;g<Zt.length;g++){const h=Zt[g],f=n+l*h,y=Ot[g%Ot.length];if(this.graphicGroup.add(new G.graphic.Line({shape:{x1:p,y1:f,x2:c,y2:f},style:{stroke:y,lineWidth:1},silent:!0})),this.graphicGroup.add(new G.graphic.Text({style:{text:`${h}`,x:c+4,y:f-6,fill:y,fontSize:9},silent:!0})),g<Zt.length-1){const x=n+l*Zt[g+1],b=Math.min(f,x),D=Math.abs(x-f);this.graphicGroup.add(new G.graphic.Rect({shape:{x:p,y:b,width:c-p,height:D},style:{fill:Ot[(g+1)%Ot.length],opacity:.06},silent:!0}))}}}for(const a of this.points)this.graphicGroup.add(new G.graphic.Circle({shape:{cx:a[0],cy:a[1],r:4},style:{fill:"#fff",stroke:"#3b82f6",lineWidth:1.5},z:101,silent:!0}))}saveDrawing(){const t=this.points.map(e=>this.context.coordinateConversion.pixelToData({x:e[0],y:e[1]}));t.every(e=>e!==null)&&this.context.addDrawing({id:`fib-ext-${Date.now()}`,type:"fib_trend_extension",points:t,paneIndex:t[0].paneIndex||0,style:{color:"#3b82f6",lineWidth:1}})}}var ns=Object.defineProperty,os=(d,t,e)=>t in d?ns(d,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):d[t]=e,as=(d,t,e)=>(os(d,typeof t!="symbol"?t+"":t,e),e);const ge=["X","A","B","C","D"],fe=["#2196f3","#ff9800","#4caf50","#f44336"],rs="rgba(33, 150, 243, 0.08)",ls="rgba(244, 67, 54, 0.08)";class ye{constructor(){as(this,"type","xabcd_pattern")}render(t){const{drawing:e,pixelPoints:i,isSelected:s}=t,a=e.style?.color||"#3b82f6";if(i.length<2)return;const n=[];i.length>=3&&n.push({type:"polygon",name:"line",shape:{points:i.slice(0,3).map(([r,o])=>[r,o])},style:{fill:rs,opacity:1}}),i.length>=5&&n.push({type:"polygon",name:"line",shape:{points:i.slice(2,5).map(([r,o])=>[r,o])},style:{fill:ls,opacity:1}});for(let r=0;r<i.length-1;r++){const[o,u]=i[r],[p,c]=i[r+1],g=fe[r%fe.length];n.push({type:"line",name:"line",shape:{x1:o,y1:u,x2:p,y2:c},style:{stroke:g,lineWidth:e.style?.lineWidth||2}})}const l=[[0,2],[1,3],[2,4]];for(const[r,o]of l)if(r<i.length&&o<i.length){const[u,p]=i[r],[c,g]=i[o];n.push({type:"line",shape:{x1:u,y1:p,x2:c,y2:g},style:{stroke:"#555",lineWidth:1,lineDash:[4,4]},silent:!0})}if(e.points.length>=3){const r=Math.abs(e.points[1].value-e.points[0].value),o=Math.abs(e.points[2].value-e.points[1].value);if(r!==0){const u=(o/r).toFixed(3),p=(i[1][0]+i[2][0])/2,c=(i[1][1]+i[2][1])/2;n.push({type:"text",style:{text:u,x:p+8,y:c,fill:"#ff9800",fontSize:10},silent:!0})}}if(e.points.length>=4){const r=Math.abs(e.points[2].value-e.points[1].value),o=Math.abs(e.points[3].value-e.points[2].value);if(r!==0){const u=(o/r).toFixed(3),p=(i[2][0]+i[3][0])/2,c=(i[2][1]+i[3][1])/2;n.push({type:"text",style:{text:u,x:p+8,y:c,fill:"#4caf50",fontSize:10},silent:!0})}}if(e.points.length>=5){const r=Math.abs(e.points[3].value-e.points[2].value),o=Math.abs(e.points[4].value-e.points[3].value);if(r!==0){const c=(o/r).toFixed(3),g=(i[3][0]+i[4][0])/2,h=(i[3][1]+i[4][1])/2;n.push({type:"text",style:{text:c,x:g+8,y:h,fill:"#f44336",fontSize:10},silent:!0})}const u=Math.abs(e.points[1].value-e.points[0].value),p=Math.abs(e.points[4].value-e.points[1].value);if(u!==0){const c=(p/u).toFixed(3),[g,h]=i[4];n.push({type:"text",style:{text:`AD/XA: ${c}`,x:g+10,y:h+14,fill:"#aaa",fontSize:9},silent:!0})}}for(let r=0;r<i.length&&r<ge.length;r++){const[o,u]=i[r],p=(r===0||u<=i[r-1][1])&&(r===i.length-1||u<=i[r+1]?.[1])?u-14:u+16;n.push({type:"text",style:{text:ge[r],x:o,y:p,fill:"#e2e8f0",fontSize:12,fontWeight:"bold",align:"center",verticalAlign:"middle"},silent:!0})}for(let r=0;r<i.length;r++){const[o,u]=i[r];n.push({type:"circle",name:`point-${r}`,shape:{cx:o,cy:u,r:4},style:{fill:"#fff",stroke:a,lineWidth:1,opacity:s?1:0},z:100})}return{type:"group",children:n}}}var hs=Object.defineProperty,cs=(d,t,e)=>t in d?hs(d,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):d[t]=e,Dt=(d,t,e)=>(cs(d,typeof t!="symbol"?t+"":t,e),e);const xe=["X","A","B","C","D"],me=["#2196f3","#ff9800","#4caf50","#f44336"],ds=5;class ps extends nt{constructor(t={}){super({id:"xabcd-pattern-tool",name:t.name||"XABCD Pattern",icon:t.icon||'<svg viewBox="0 0 24 24" width="24" height="24" fill="none" stroke="#e3e3e3" stroke-width="1.5"><polyline points="2,18 6,6 11,14 16,4 21,16"/><circle cx="2" cy="18" r="1.5" fill="#e3e3e3"/><circle cx="6" cy="6" r="1.5" fill="#e3e3e3"/><circle cx="11" cy="14" r="1.5" fill="#e3e3e3"/><circle cx="16" cy="4" r="1.5" fill="#e3e3e3"/><circle cx="21" cy="16" r="1.5" fill="#e3e3e3"/></svg>'}),Dt(this,"points",[]),Dt(this,"state","idle"),Dt(this,"graphicGroup",null),Dt(this,"onClick",e=>{const i=this.getPoint(e);this.state==="idle"?(this.state="drawing",this.points=[i,[...i]],this.initGraphic(),this.updateGraphic()):this.state==="drawing"&&(this.points[this.points.length-1]=i,this.points.length>=ds?(this.state="finished",this.updateGraphic(),this.saveDrawing(),this.removeGraphic(),this.context.disableTools()):(this.points.push([...i]),this.updateGraphic()))}),Dt(this,"onMouseMove",e=>{this.state!=="drawing"||this.points.length<2||(this.points[this.points.length-1]=this.getPoint(e),this.updateGraphic())})}onInit(){this.context.registerDrawingRenderer(new ye)}onActivate(){this.state="idle",this.points=[],this.context.getChart().getZr().setCursorStyle("crosshair"),this.bindEvents()}onDeactivate(){this.state="idle",this.points=[],this.removeGraphic(),this.unbindEvents(),this.context.getChart().getZr().setCursorStyle("default")}bindEvents(){const t=this.context.getChart().getZr();t.on("click",this.onClick),t.on("mousemove",this.onMouseMove)}unbindEvents(){const t=this.context.getChart().getZr();t.off("click",this.onClick),t.off("mousemove",this.onMouseMove)}initGraphic(){this.graphicGroup=new G.graphic.Group,this.context.getChart().getZr().add(this.graphicGroup)}removeGraphic(){this.graphicGroup&&(this.context.getChart().getZr().remove(this.graphicGroup),this.graphicGroup=null)}updateGraphic(){if(!this.graphicGroup)return;this.graphicGroup.removeAll();const t=this.points;t.length>=3&&this.graphicGroup.add(new G.graphic.Polygon({shape:{points:t.slice(0,3)},style:{fill:"rgba(33, 150, 243, 0.08)"},silent:!0})),t.length>=5&&this.graphicGroup.add(new G.graphic.Polygon({shape:{points:t.slice(2,5)},style:{fill:"rgba(244, 67, 54, 0.08)"},silent:!0}));for(let i=0;i<t.length-1;i++){const[s,a]=t[i],[n,l]=t[i+1];this.graphicGroup.add(new G.graphic.Line({shape:{x1:s,y1:a,x2:n,y2:l},style:{stroke:me[i%me.length],lineWidth:2},silent:!0}))}const e=[[0,2],[1,3],[2,4]];for(const[i,s]of e)if(i<t.length&&s<t.length){const[a,n]=t[i],[l,r]=t[s];this.graphicGroup.add(new G.graphic.Line({shape:{x1:a,y1:n,x2:l,y2:r},style:{stroke:"#555",lineWidth:1,lineDash:[4,4]},silent:!0}))}for(let i=0;i<t.length&&i<xe.length;i++){const[s,a]=t[i],n=(i===0||a<=t[i-1][1])&&(i===t.length-1||a<=t[i+1]?.[1])?a-14:a+16;this.graphicGroup.add(new G.graphic.Text({style:{text:xe[i],x:s,y:n,fill:"#e2e8f0",fontSize:12,fontWeight:"bold",align:"center",verticalAlign:"middle"},silent:!0}))}for(let i=0;i<t.length;i++){const[s,a]=t[i];this.graphicGroup.add(new G.graphic.Circle({shape:{cx:s,cy:a,r:4},style:{fill:"#fff",stroke:"#3b82f6",lineWidth:1.5},z:101,silent:!0}))}}saveDrawing(){const t=this.points.map(e=>this.context.coordinateConversion.pixelToData({x:e[0],y:e[1]}));t.every(e=>e!==null)&&this.context.addDrawing({id:`xabcd-${Date.now()}`,type:"xabcd_pattern",points:t,paneIndex:t[0].paneIndex||0,style:{color:"#3b82f6",lineWidth:2}})}}var us=Object.defineProperty,gs=(d,t,e)=>t in d?us(d,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):d[t]=e,fs=(d,t,e)=>(gs(d,typeof t!="symbol"?t+"":t,e),e);const be=["A","B","C","D"],ve=["#2196f3","#ff9800","#4caf50"];class we{constructor(){fs(this,"type","abcd_pattern")}render(t){const{drawing:e,pixelPoints:i,isSelected:s}=t,a=e.style?.color||"#3b82f6";if(i.length<2)return;const n=[];i.length>=3&&n.push({type:"polygon",name:"line",shape:{points:i.slice(0,3).map(([l,r])=>[l,r])},style:{fill:"rgba(33, 150, 243, 0.08)"}}),i.length>=4&&n.push({type:"polygon",name:"line",shape:{points:i.slice(1,4).map(([l,r])=>[l,r])},style:{fill:"rgba(244, 67, 54, 0.08)"}});for(let l=0;l<i.length-1;l++){const[r,o]=i[l],[u,p]=i[l+1];n.push({type:"line",name:"line",shape:{x1:r,y1:o,x2:u,y2:p},style:{stroke:ve[l%ve.length],lineWidth:e.style?.lineWidth||2}})}if(i.length>=3&&n.push({type:"line",shape:{x1:i[0][0],y1:i[0][1],x2:i[2][0],y2:i[2][1]},style:{stroke:"#555",lineWidth:1,lineDash:[4,4]},silent:!0}),i.length>=4&&n.push({type:"line",shape:{x1:i[1][0],y1:i[1][1],x2:i[3][0],y2:i[3][1]},style:{stroke:"#555",lineWidth:1,lineDash:[4,4]},silent:!0}),e.points.length>=3){const l=Math.abs(e.points[1].value-e.points[0].value),r=Math.abs(e.points[2].value-e.points[1].value);if(l!==0){const o=(r/l).toFixed(3),u=(i[1][0]+i[2][0])/2,p=(i[1][1]+i[2][1])/2;n.push({type:"text",style:{text:o,x:u+8,y:p,fill:"#ff9800",fontSize:10},silent:!0})}}if(e.points.length>=4){const l=Math.abs(e.points[2].value-e.points[1].value),r=Math.abs(e.points[3].value-e.points[2].value);if(l!==0){const o=(r/l).toFixed(3),u=(i[2][0]+i[3][0])/2,p=(i[2][1]+i[3][1])/2;n.push({type:"text",style:{text:o,x:u+8,y:p,fill:"#4caf50",fontSize:10},silent:!0})}}for(let l=0;l<i.length&&l<be.length;l++){const[r,o]=i[l],u=(l===0||o<=i[l-1][1])&&(l===i.length-1||o<=i[l+1]?.[1]);n.push({type:"text",style:{text:be[l],x:r,y:u?o-14:o+16,fill:"#e2e8f0",fontSize:12,fontWeight:"bold",align:"center",verticalAlign:"middle"},silent:!0})}for(let l=0;l<i.length;l++)n.push({type:"circle",name:`point-${l}`,shape:{cx:i[l][0],cy:i[l][1],r:4},style:{fill:"#fff",stroke:a,lineWidth:1,opacity:s?1:0},z:100});return{type:"group",children:n}}}var ys=Object.defineProperty,xs=(d,t,e)=>t in d?ys(d,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):d[t]=e,Mt=(d,t,e)=>(xs(d,typeof t!="symbol"?t+"":t,e),e);const Ce=["A","B","C","D"],Ie=["#2196f3","#ff9800","#4caf50"],ms=4;class bs extends nt{constructor(t={}){super({id:"abcd-pattern-tool",name:t.name||"ABCD Pattern",icon:t.icon||'<svg viewBox="0 0 24 24" width="24" height="24" fill="none" stroke="#e3e3e3" stroke-width="1.5"><polyline points="3,18 8,5 15,15 21,3"/><circle cx="3" cy="18" r="1.5" fill="#e3e3e3"/><circle cx="8" cy="5" r="1.5" fill="#e3e3e3"/><circle cx="15" cy="15" r="1.5" fill="#e3e3e3"/><circle cx="21" cy="3" r="1.5" fill="#e3e3e3"/></svg>'}),Mt(this,"points",[]),Mt(this,"state","idle"),Mt(this,"graphicGroup",null),Mt(this,"onClick",e=>{const i=this.getPoint(e);this.state==="idle"?(this.state="drawing",this.points=[i,[...i]],this.initGraphic(),this.updateGraphic()):this.state==="drawing"&&(this.points[this.points.length-1]=i,this.points.length>=ms?(this.state="finished",this.updateGraphic(),this.saveDrawing(),this.removeGraphic(),this.context.disableTools()):(this.points.push([...i]),this.updateGraphic()))}),Mt(this,"onMouseMove",e=>{this.state!=="drawing"||this.points.length<2||(this.points[this.points.length-1]=this.getPoint(e),this.updateGraphic())})}onInit(){this.context.registerDrawingRenderer(new we)}onActivate(){this.state="idle",this.points=[],this.context.getChart().getZr().setCursorStyle("crosshair");const t=this.context.getChart().getZr();t.on("click",this.onClick),t.on("mousemove",this.onMouseMove)}onDeactivate(){this.state="idle",this.points=[],this.removeGraphic();const t=this.context.getChart().getZr();t.off("click",this.onClick),t.off("mousemove",this.onMouseMove),this.context.getChart().getZr().setCursorStyle("default")}initGraphic(){this.graphicGroup=new G.graphic.Group,this.context.getChart().getZr().add(this.graphicGroup)}removeGraphic(){this.graphicGroup&&(this.context.getChart().getZr().remove(this.graphicGroup),this.graphicGroup=null)}updateGraphic(){if(!this.graphicGroup)return;this.graphicGroup.removeAll();const t=this.points;t.length>=3&&this.graphicGroup.add(new G.graphic.Polygon({shape:{points:t.slice(0,3)},style:{fill:"rgba(33,150,243,0.08)"},silent:!0})),t.length>=4&&this.graphicGroup.add(new G.graphic.Polygon({shape:{points:t.slice(1,4)},style:{fill:"rgba(244,67,54,0.08)"},silent:!0}));for(let e=0;e<t.length-1;e++)this.graphicGroup.add(new G.graphic.Line({shape:{x1:t[e][0],y1:t[e][1],x2:t[e+1][0],y2:t[e+1][1]},style:{stroke:Ie[e%Ie.length],lineWidth:2},silent:!0}));t.length>=3&&this.graphicGroup.add(new G.graphic.Line({shape:{x1:t[0][0],y1:t[0][1],x2:t[2][0],y2:t[2][1]},style:{stroke:"#555",lineWidth:1,lineDash:[4,4]},silent:!0})),t.length>=4&&this.graphicGroup.add(new G.graphic.Line({shape:{x1:t[1][0],y1:t[1][1],x2:t[3][0],y2:t[3][1]},style:{stroke:"#555",lineWidth:1,lineDash:[4,4]},silent:!0}));for(let e=0;e<t.length&&e<Ce.length;e++){const[i,s]=t[e],a=(e===0||s<=t[e-1][1])&&(e===t.length-1||s<=t[e+1]?.[1]);this.graphicGroup.add(new G.graphic.Text({style:{text:Ce[e],x:i,y:a?s-14:s+16,fill:"#e2e8f0",fontSize:12,fontWeight:"bold",align:"center",verticalAlign:"middle"},silent:!0})),this.graphicGroup.add(new G.graphic.Circle({shape:{cx:i,cy:s,r:4},style:{fill:"#fff",stroke:"#3b82f6",lineWidth:1.5},z:101,silent:!0}))}}saveDrawing(){const t=this.points.map(e=>this.context.coordinateConversion.pixelToData({x:e[0],y:e[1]}));t.every(e=>e!==null)&&this.context.addDrawing({id:`abcd-${Date.now()}`,type:"abcd_pattern",points:t,paneIndex:t[0].paneIndex||0,style:{color:"#3b82f6",lineWidth:2}})}}var vs=Object.defineProperty,ws=(d,t,e)=>t in d?vs(d,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):d[t]=e,Cs=(d,t,e)=>(ws(d,typeof t!="symbol"?t+"":t,e),e);const _e=["X","A","B","C","D"],Pe=["#00bcd4","#e91e63","#8bc34a","#ff5722"];class Ae{constructor(){Cs(this,"type","cypher_pattern")}render(t){const{drawing:e,pixelPoints:i,isSelected:s}=t,a=e.style?.color||"#3b82f6";if(i.length<2)return;const n=[];i.length>=3&&n.push({type:"polygon",name:"line",shape:{points:i.slice(0,3).map(([o,u])=>[o,u])},style:{fill:"rgba(0, 188, 212, 0.08)"}}),i.length>=5&&n.push({type:"polygon",name:"line",shape:{points:i.slice(2,5).map(([o,u])=>[o,u])},style:{fill:"rgba(233, 30, 99, 0.08)"}});for(let o=0;o<i.length-1;o++){const[u,p]=i[o],[c,g]=i[o+1];n.push({type:"line",name:"line",shape:{x1:u,y1:p,x2:c,y2:g},style:{stroke:Pe[o%Pe.length],lineWidth:e.style?.lineWidth||2}})}const l=[[0,2],[0,3],[1,4]];for(const[o,u]of l)o<i.length&&u<i.length&&n.push({type:"line",shape:{x1:i[o][0],y1:i[o][1],x2:i[u][0],y2:i[u][1]},style:{stroke:"#555",lineWidth:1,lineDash:[4,4]},silent:!0});const r=e.points;if(r.length>=3){const o=Math.abs(r[1].value-r[0].value),u=Math.abs(r[2].value-r[1].value);if(o!==0){const p=(u/o).toFixed(3);n.push({type:"text",style:{text:p,x:(i[1][0]+i[2][0])/2+8,y:(i[1][1]+i[2][1])/2,fill:"#e91e63",fontSize:10},silent:!0})}}if(r.length>=4){const o=Math.abs(r[1].value-r[0].value),u=Math.abs(r[3].value-r[0].value);if(o!==0){const p=(u/o).toFixed(3);n.push({type:"text",style:{text:`XC/XA: ${p}`,x:(i[0][0]+i[3][0])/2+8,y:(i[0][1]+i[3][1])/2,fill:"#8bc34a",fontSize:10},silent:!0})}}if(r.length>=5){const o=Math.abs(r[3].value-r[0].value),u=Math.abs(r[4].value-r[3].value);if(o!==0){const p=(u/o).toFixed(3);n.push({type:"text",style:{text:p,x:(i[3][0]+i[4][0])/2+8,y:(i[3][1]+i[4][1])/2,fill:"#ff5722",fontSize:10},silent:!0})}}for(let o=0;o<i.length&&o<_e.length;o++){const[u,p]=i[o],c=(o===0||p<=i[o-1][1])&&(o===i.length-1||p<=i[o+1]?.[1]);n.push({type:"text",style:{text:_e[o],x:u,y:c?p-14:p+16,fill:"#e2e8f0",fontSize:12,fontWeight:"bold",align:"center",verticalAlign:"middle"},silent:!0})}for(let o=0;o<i.length;o++)n.push({type:"circle",name:`point-${o}`,shape:{cx:i[o][0],cy:i[o][1],r:4},style:{fill:"#fff",stroke:a,lineWidth:1,opacity:s?1:0},z:100});return{type:"group",children:n}}}var Is=Object.defineProperty,_s=(d,t,e)=>t in d?Is(d,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):d[t]=e,St=(d,t,e)=>(_s(d,typeof t!="symbol"?t+"":t,e),e);const ke=["X","A","B","C","D"],De=["#00bcd4","#e91e63","#8bc34a","#ff5722"],Ps=5;class As extends nt{constructor(t={}){super({id:"cypher-pattern-tool",name:t.name||"Cypher Pattern",icon:t.icon||'<svg viewBox="0 0 24 24" width="24" height="24" fill="none" stroke="#e3e3e3" stroke-width="1.5"><polyline points="2,16 7,4 11,12 17,2 22,14"/><circle cx="2" cy="16" r="1.5" fill="#e3e3e3"/><circle cx="7" cy="4" r="1.5" fill="#e3e3e3"/><circle cx="11" cy="12" r="1.5" fill="#e3e3e3"/><circle cx="17" cy="2" r="1.5" fill="#e3e3e3"/><circle cx="22" cy="14" r="1.5" fill="#e3e3e3"/></svg>'}),St(this,"points",[]),St(this,"state","idle"),St(this,"graphicGroup",null),St(this,"onClick",e=>{const i=this.getPoint(e);this.state==="idle"?(this.state="drawing",this.points=[i,[...i]],this.initGraphic(),this.updateGraphic()):this.state==="drawing"&&(this.points[this.points.length-1]=i,this.points.length>=Ps?(this.state="finished",this.updateGraphic(),this.saveDrawing(),this.removeGraphic(),this.context.disableTools()):(this.points.push([...i]),this.updateGraphic()))}),St(this,"onMouseMove",e=>{this.state!=="drawing"||this.points.length<2||(this.points[this.points.length-1]=this.getPoint(e),this.updateGraphic())})}onInit(){this.context.registerDrawingRenderer(new Ae)}onActivate(){this.state="idle",this.points=[],this.context.getChart().getZr().setCursorStyle("crosshair");const t=this.context.getChart().getZr();t.on("click",this.onClick),t.on("mousemove",this.onMouseMove)}onDeactivate(){this.state="idle",this.points=[],this.removeGraphic();const t=this.context.getChart().getZr();t.off("click",this.onClick),t.off("mousemove",this.onMouseMove),t.setCursorStyle("default")}initGraphic(){this.graphicGroup=new G.graphic.Group,this.context.getChart().getZr().add(this.graphicGroup)}removeGraphic(){this.graphicGroup&&(this.context.getChart().getZr().remove(this.graphicGroup),this.graphicGroup=null)}updateGraphic(){if(!this.graphicGroup)return;this.graphicGroup.removeAll();const t=this.points;t.length>=3&&this.graphicGroup.add(new G.graphic.Polygon({shape:{points:t.slice(0,3)},style:{fill:"rgba(0,188,212,0.08)"},silent:!0})),t.length>=5&&this.graphicGroup.add(new G.graphic.Polygon({shape:{points:t.slice(2,5)},style:{fill:"rgba(233,30,99,0.08)"},silent:!0}));for(let e=0;e<t.length-1;e++)this.graphicGroup.add(new G.graphic.Line({shape:{x1:t[e][0],y1:t[e][1],x2:t[e+1][0],y2:t[e+1][1]},style:{stroke:De[e%De.length],lineWidth:2},silent:!0}));for(let e=0;e<t.length&&e<ke.length;e++){const[i,s]=t[e],a=(e===0||s<=t[e-1][1])&&(e===t.length-1||s<=t[e+1]?.[1]);this.graphicGroup.add(new G.graphic.Text({style:{text:ke[e],x:i,y:a?s-14:s+16,fill:"#e2e8f0",fontSize:12,fontWeight:"bold",align:"center",verticalAlign:"middle"},silent:!0})),this.graphicGroup.add(new G.graphic.Circle({shape:{cx:i,cy:s,r:4},style:{fill:"#fff",stroke:"#3b82f6",lineWidth:1.5},z:101,silent:!0}))}}saveDrawing(){const t=this.points.map(e=>this.context.coordinateConversion.pixelToData({x:e[0],y:e[1]}));t.every(e=>e!==null)&&this.context.addDrawing({id:`cypher-${Date.now()}`,type:"cypher_pattern",points:t,paneIndex:t[0].paneIndex||0,style:{color:"#3b82f6",lineWidth:2}})}}var ks=Object.defineProperty,Ds=(d,t,e)=>t in d?ks(d,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):d[t]=e,Ms=(d,t,e)=>(Ds(d,typeof t!="symbol"?t+"":t,e),e);const Ut=["","LS","","H","","RS",""];class Me{constructor(){Ms(this,"type","head_and_shoulders")}render(t){const{drawing:e,pixelPoints:i,isSelected:s}=t,a=e.style?.color||"#3b82f6";if(i.length<2)return;const n=[];i.length>=3&&n.push({type:"polygon",name:"line",shape:{points:i.slice(0,3).map(([l,r])=>[l,r])},style:{fill:"rgba(33, 150, 243, 0.06)"}}),i.length>=5&&n.push({type:"polygon",name:"line",shape:{points:i.slice(2,5).map(([l,r])=>[l,r])},style:{fill:"rgba(244, 67, 54, 0.08)"}}),i.length>=7&&n.push({type:"polygon",name:"line",shape:{points:i.slice(4,7).map(([l,r])=>[l,r])},style:{fill:"rgba(33, 150, 243, 0.06)"}});for(let l=0;l<i.length-1;l++){const[r,o]=i[l],[u,p]=i[l+1];n.push({type:"line",name:"line",shape:{x1:r,y1:o,x2:u,y2:p},style:{stroke:"#2196f3",lineWidth:e.style?.lineWidth||2}})}if(i.length>=5){const[l,r]=i[2],[o,u]=i[4],p=o-l,c=u-r,g=.3,h=.3,f=l-p*g,y=r-c*g,x=o+p*h,b=u+c*h;n.push({type:"line",shape:{x1:f,y1:y,x2:x,y2:b},style:{stroke:"#ff9800",lineWidth:2,lineDash:[6,4]},silent:!0}),n.push({type:"text",style:{text:"Neckline",x:(l+o)/2,y:(r+u)/2+14,fill:"#ff9800",fontSize:10,align:"center"},silent:!0})}for(let l=0;l<i.length&&l<Ut.length;l++){if(!Ut[l])continue;const[r,o]=i[l],u=(l===0||o<=i[l-1][1])&&(l===i.length-1||o<=i[l+1]?.[1]);n.push({type:"text",style:{text:Ut[l],x:r,y:u?o-14:o+16,fill:"#e2e8f0",fontSize:12,fontWeight:"bold",align:"center",verticalAlign:"middle"},silent:!0})}for(let l=0;l<i.length;l++)n.push({type:"circle",name:`point-${l}`,shape:{cx:i[l][0],cy:i[l][1],r:4},style:{fill:"#fff",stroke:a,lineWidth:1,opacity:s?1:0},z:100});return{type:"group",children:n}}}var Ss=Object.defineProperty,Gs=(d,t,e)=>t in d?Ss(d,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):d[t]=e,Gt=(d,t,e)=>(Gs(d,typeof t!="symbol"?t+"":t,e),e);const Kt=["","LS","","H","","RS",""],$s=7;class zs extends nt{constructor(t={}){super({id:"head-and-shoulders-tool",name:t.name||"Head & Shoulders",icon:t.icon||'<svg viewBox="0 0 24 24" width="24" height="24" fill="none" stroke="#e3e3e3" stroke-width="1.5"><polyline points="1,18 4,10 7,14 12,3 17,14 20,10 23,18"/></svg>'}),Gt(this,"points",[]),Gt(this,"state","idle"),Gt(this,"graphicGroup",null),Gt(this,"onClick",e=>{const i=this.getPoint(e);this.state==="idle"?(this.state="drawing",this.points=[i,[...i]],this.initGraphic(),this.updateGraphic()):this.state==="drawing"&&(this.points[this.points.length-1]=i,this.points.length>=$s?(this.state="finished",this.updateGraphic(),this.saveDrawing(),this.removeGraphic(),this.context.disableTools()):(this.points.push([...i]),this.updateGraphic()))}),Gt(this,"onMouseMove",e=>{this.state!=="drawing"||this.points.length<2||(this.points[this.points.length-1]=this.getPoint(e),this.updateGraphic())})}onInit(){this.context.registerDrawingRenderer(new Me)}onActivate(){this.state="idle",this.points=[],this.context.getChart().getZr().setCursorStyle("crosshair");const t=this.context.getChart().getZr();t.on("click",this.onClick),t.on("mousemove",this.onMouseMove)}onDeactivate(){this.state="idle",this.points=[],this.removeGraphic();const t=this.context.getChart().getZr();t.off("click",this.onClick),t.off("mousemove",this.onMouseMove),t.setCursorStyle("default")}initGraphic(){this.graphicGroup=new G.graphic.Group,this.context.getChart().getZr().add(this.graphicGroup)}removeGraphic(){this.graphicGroup&&(this.context.getChart().getZr().remove(this.graphicGroup),this.graphicGroup=null)}updateGraphic(){if(!this.graphicGroup)return;this.graphicGroup.removeAll();const t=this.points;t.length>=3&&this.graphicGroup.add(new G.graphic.Polygon({shape:{points:t.slice(0,3)},style:{fill:"rgba(33,150,243,0.06)"},silent:!0})),t.length>=5&&this.graphicGroup.add(new G.graphic.Polygon({shape:{points:t.slice(2,5)},style:{fill:"rgba(244,67,54,0.08)"},silent:!0})),t.length>=7&&this.graphicGroup.add(new G.graphic.Polygon({shape:{points:t.slice(4,7)},style:{fill:"rgba(33,150,243,0.06)"},silent:!0}));for(let e=0;e<t.length-1;e++)this.graphicGroup.add(new G.graphic.Line({shape:{x1:t[e][0],y1:t[e][1],x2:t[e+1][0],y2:t[e+1][1]},style:{stroke:"#2196f3",lineWidth:2},silent:!0}));if(t.length>=5){const[e,i]=t[2],[s,a]=t[4],n=s-e,l=a-i;this.graphicGroup.add(new G.graphic.Line({shape:{x1:e-n*.3,y1:i-l*.3,x2:s+n*.3,y2:a+l*.3},style:{stroke:"#ff9800",lineWidth:2,lineDash:[6,4]},silent:!0}))}for(let e=0;e<t.length&&e<Kt.length;e++){const[i,s]=t[e],a=(e===0||s<=t[e-1][1])&&(e===t.length-1||s<=t[e+1]?.[1]);Kt[e]&&this.graphicGroup.add(new G.graphic.Text({style:{text:Kt[e],x:i,y:a?s-14:s+16,fill:"#e2e8f0",fontSize:12,fontWeight:"bold",align:"center",verticalAlign:"middle"},silent:!0})),this.graphicGroup.add(new G.graphic.Circle({shape:{cx:i,cy:s,r:4},style:{fill:"#fff",stroke:"#3b82f6",lineWidth:1.5},z:101,silent:!0}))}}saveDrawing(){const t=this.points.map(e=>this.context.coordinateConversion.pixelToData({x:e[0],y:e[1]}));t.every(e=>e!==null)&&this.context.addDrawing({id:`hs-${Date.now()}`,type:"head_and_shoulders",points:t,paneIndex:t[0].paneIndex||0,style:{color:"#3b82f6",lineWidth:2}})}}var Es=Object.defineProperty,Ls=(d,t,e)=>t in d?Es(d,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):d[t]=e,Ts=(d,t,e)=>(Ls(d,typeof t!="symbol"?t+"":t,e),e);const Se=["1","2","3","4","5"];class Ge{constructor(){Ts(this,"type","triangle_pattern")}render(t){const{drawing:e,pixelPoints:i,isSelected:s}=t,a=e.style?.color||"#3b82f6";if(i.length<2)return;const n=[];i.length>=3&&n.push({type:"polygon",name:"line",shape:{points:i.map(([o,u])=>[o,u])},style:{fill:"rgba(156, 39, 176, 0.06)"}});const l=i.filter((o,u)=>u%2===0);if(l.length>=2){for(let o=0;o<l.length-1;o++)n.push({type:"line",name:"line",shape:{x1:l[o][0],y1:l[o][1],x2:l[o+1][0],y2:l[o+1][1]},style:{stroke:"#f44336",lineWidth:2}});if(l.length>=2){const o=l[l.length-1],u=l[l.length-2],p=o[0]-u[0],c=o[1]-u[1];if(p!==0){const g=o[0]+p*.5,h=o[1]+c*.5;n.push({type:"line",shape:{x1:o[0],y1:o[1],x2:g,y2:h},style:{stroke:"#f44336",lineWidth:1,lineDash:[4,4]},silent:!0})}}}const r=i.filter((o,u)=>u%2===1);if(r.length>=2){for(let o=0;o<r.length-1;o++)n.push({type:"line",name:"line",shape:{x1:r[o][0],y1:r[o][1],x2:r[o+1][0],y2:r[o+1][1]},style:{stroke:"#4caf50",lineWidth:2}});if(r.length>=2){const o=r[r.length-1],u=r[r.length-2],p=o[0]-u[0],c=o[1]-u[1];if(p!==0){const g=o[0]+p*.5,h=o[1]+c*.5;n.push({type:"line",shape:{x1:o[0],y1:o[1],x2:g,y2:h},style:{stroke:"#4caf50",lineWidth:1,lineDash:[4,4]},silent:!0})}}}for(let o=0;o<i.length-1;o++)n.push({type:"line",shape:{x1:i[o][0],y1:i[o][1],x2:i[o+1][0],y2:i[o+1][1]},style:{stroke:"#9c27b0",lineWidth:1,lineDash:[2,2]},silent:!0});for(let o=0;o<i.length&&o<Se.length;o++){const[u,p]=i[o],c=o%2===0;n.push({type:"text",style:{text:Se[o],x:u,y:c?p-14:p+16,fill:"#e2e8f0",fontSize:12,fontWeight:"bold",align:"center",verticalAlign:"middle"},silent:!0})}for(let o=0;o<i.length;o++)n.push({type:"circle",name:`point-${o}`,shape:{cx:i[o][0],cy:i[o][1],r:4},style:{fill:"#fff",stroke:a,lineWidth:1,opacity:s?1:0},z:100});return{type:"group",children:n}}}var Ws=Object.defineProperty,Ns=(d,t,e)=>t in d?Ws(d,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):d[t]=e,$t=(d,t,e)=>(Ns(d,typeof t!="symbol"?t+"":t,e),e);const $e=["1","2","3","4","5"],Fs=5;class Zs extends nt{constructor(t={}){super({id:"triangle-pattern-tool",name:t.name||"Triangle Pattern",icon:t.icon||'<svg viewBox="0 0 24 24" width="24" height="24" fill="none" stroke="#e3e3e3" stroke-width="1.5"><path d="M2,4 L22,4 L12,20 Z"/></svg>'}),$t(this,"points",[]),$t(this,"state","idle"),$t(this,"graphicGroup",null),$t(this,"onClick",e=>{const i=this.getPoint(e);this.state==="idle"?(this.state="drawing",this.points=[i,[...i]],this.initGraphic(),this.updateGraphic()):this.state==="drawing"&&(this.points[this.points.length-1]=i,this.points.length>=Fs?(this.state="finished",this.updateGraphic(),this.saveDrawing(),this.removeGraphic(),this.context.disableTools()):(this.points.push([...i]),this.updateGraphic()))}),$t(this,"onMouseMove",e=>{this.state!=="drawing"||this.points.length<2||(this.points[this.points.length-1]=this.getPoint(e),this.updateGraphic())})}onInit(){this.context.registerDrawingRenderer(new Ge)}onActivate(){this.state="idle",this.points=[],this.context.getChart().getZr().setCursorStyle("crosshair");const t=this.context.getChart().getZr();t.on("click",this.onClick),t.on("mousemove",this.onMouseMove)}onDeactivate(){this.state="idle",this.points=[],this.removeGraphic();const t=this.context.getChart().getZr();t.off("click",this.onClick),t.off("mousemove",this.onMouseMove),t.setCursorStyle("default")}initGraphic(){this.graphicGroup=new G.graphic.Group,this.context.getChart().getZr().add(this.graphicGroup)}removeGraphic(){this.graphicGroup&&(this.context.getChart().getZr().remove(this.graphicGroup),this.graphicGroup=null)}updateGraphic(){if(!this.graphicGroup)return;this.graphicGroup.removeAll();const t=this.points;t.length>=3&&this.graphicGroup.add(new G.graphic.Polygon({shape:{points:t},style:{fill:"rgba(156,39,176,0.06)"},silent:!0}));for(let s=0;s<t.length-1;s++)this.graphicGroup.add(new G.graphic.Line({shape:{x1:t[s][0],y1:t[s][1],x2:t[s+1][0],y2:t[s+1][1]},style:{stroke:"#9c27b0",lineWidth:2},silent:!0}));const e=t.filter((s,a)=>a%2===0);if(e.length>=2)for(let s=0;s<e.length-1;s++)this.graphicGroup.add(new G.graphic.Line({shape:{x1:e[s][0],y1:e[s][1],x2:e[s+1][0],y2:e[s+1][1]},style:{stroke:"#f44336",lineWidth:1,lineDash:[4,4]},silent:!0}));const i=t.filter((s,a)=>a%2===1);if(i.length>=2)for(let s=0;s<i.length-1;s++)this.graphicGroup.add(new G.graphic.Line({shape:{x1:i[s][0],y1:i[s][1],x2:i[s+1][0],y2:i[s+1][1]},style:{stroke:"#4caf50",lineWidth:1,lineDash:[4,4]},silent:!0}));for(let s=0;s<t.length&&s<$e.length;s++){const[a,n]=t[s],l=s%2===0;this.graphicGroup.add(new G.graphic.Text({style:{text:$e[s],x:a,y:l?n-14:n+16,fill:"#e2e8f0",fontSize:12,fontWeight:"bold",align:"center",verticalAlign:"middle"},silent:!0})),this.graphicGroup.add(new G.graphic.Circle({shape:{cx:a,cy:n,r:4},style:{fill:"#fff",stroke:"#3b82f6",lineWidth:1.5},z:101,silent:!0}))}}saveDrawing(){const t=this.points.map(e=>this.context.coordinateConversion.pixelToData({x:e[0],y:e[1]}));t.every(e=>e!==null)&&this.context.addDrawing({id:`triangle-${Date.now()}`,type:"triangle_pattern",points:t,paneIndex:t[0].paneIndex||0,style:{color:"#3b82f6",lineWidth:2}})}}var Os=Object.defineProperty,Hs=(d,t,e)=>t in d?Os(d,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):d[t]=e,Rs=(d,t,e)=>(Hs(d,typeof t!="symbol"?t+"":t,e),e);const Jt=["0","D1","C1","D2","C2","D3",""],ze=["#2196f3","#ff9800","#4caf50","#f44336","#00bcd4","#e91e63"];class Ee{constructor(){Rs(this,"type","three_drives_pattern")}render(t){const{drawing:e,pixelPoints:i,isSelected:s}=t,a=e.style?.color||"#3b82f6";if(i.length<2)return;const n=[];i.length>=3&&n.push({type:"polygon",name:"line",shape:{points:i.slice(0,3).map(([o,u])=>[o,u])},style:{fill:"rgba(33, 150, 243, 0.06)"}}),i.length>=5&&n.push({type:"polygon",name:"line",shape:{points:i.slice(2,5).map(([o,u])=>[o,u])},style:{fill:"rgba(76, 175, 80, 0.06)"}}),i.length>=7&&n.push({type:"polygon",name:"line",shape:{points:i.slice(4,7).map(([o,u])=>[o,u])},style:{fill:"rgba(0, 188, 212, 0.06)"}});for(let o=0;o<i.length-1;o++){const[u,p]=i[o],[c,g]=i[o+1];n.push({type:"line",name:"line",shape:{x1:u,y1:p,x2:c,y2:g},style:{stroke:ze[o%ze.length],lineWidth:e.style?.lineWidth||2}})}const l=[[1,3],[3,5],[2,4]];for(const[o,u]of l)o<i.length&&u<i.length&&n.push({type:"line",shape:{x1:i[o][0],y1:i[o][1],x2:i[u][0],y2:i[u][1]},style:{stroke:"#555",lineWidth:1,lineDash:[4,4]},silent:!0});const r=e.points;if(r.length>=4){const o=Math.abs(r[1].value-r[0].value),u=Math.abs(r[3].value-r[2].value);if(o!==0){const p=(u/o).toFixed(3),c=(i[2][0]+i[3][0])/2,g=(i[2][1]+i[3][1])/2;n.push({type:"text",style:{text:`D2/D1: ${p}`,x:c+10,y:g,fill:"#4caf50",fontSize:9},silent:!0})}}if(r.length>=6){const o=Math.abs(r[3].value-r[2].value),u=Math.abs(r[5].value-r[4].value);if(o!==0){const p=(u/o).toFixed(3),c=(i[4][0]+i[5][0])/2,g=(i[4][1]+i[5][1])/2;n.push({type:"text",style:{text:`D3/D2: ${p}`,x:c+10,y:g,fill:"#00bcd4",fontSize:9},silent:!0})}}if(r.length>=3){const o=Math.abs(r[1].value-r[0].value),u=Math.abs(r[2].value-r[1].value);if(o!==0){const p=(u/o).toFixed(3),c=(i[1][0]+i[2][0])/2,g=(i[1][1]+i[2][1])/2;n.push({type:"text",style:{text:p,x:c+8,y:g,fill:"#ff9800",fontSize:10},silent:!0})}}for(let o=0;o<i.length&&o<Jt.length;o++){if(!Jt[o])continue;const[u,p]=i[o],c=(o===0||p<=i[o-1][1])&&(o===i.length-1||p<=i[o+1]?.[1]);n.push({type:"text",style:{text:Jt[o],x:u,y:c?p-14:p+16,fill:"#e2e8f0",fontSize:11,fontWeight:"bold",align:"center",verticalAlign:"middle"},silent:!0})}for(let o=0;o<i.length;o++)n.push({type:"circle",name:`point-${o}`,shape:{cx:i[o][0],cy:i[o][1],r:4},style:{fill:"#fff",stroke:a,lineWidth:1,opacity:s?1:0},z:100});return{type:"group",children:n}}}var Bs=Object.defineProperty,js=(d,t,e)=>t in d?Bs(d,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):d[t]=e,zt=(d,t,e)=>(js(d,typeof t!="symbol"?t+"":t,e),e);const Qt=["0","D1","C1","D2","C2","D3",""],Le=["#2196f3","#ff9800","#4caf50","#f44336","#00bcd4","#e91e63"],Ys=7;class Xs extends nt{constructor(t={}){super({id:"three-drives-pattern-tool",name:t.name||"Three Drives",icon:t.icon||'<svg viewBox="0 0 24 24" width="24" height="24" fill="none" stroke="#e3e3e3" stroke-width="1.5"><polyline points="1,20 4,8 7,14 11,5 15,12 19,2 23,10"/></svg>'}),zt(this,"points",[]),zt(this,"state","idle"),zt(this,"graphicGroup",null),zt(this,"onClick",e=>{const i=this.getPoint(e);this.state==="idle"?(this.state="drawing",this.points=[i,[...i]],this.initGraphic(),this.updateGraphic()):this.state==="drawing"&&(this.points[this.points.length-1]=i,this.points.length>=Ys?(this.state="finished",this.updateGraphic(),this.saveDrawing(),this.removeGraphic(),this.context.disableTools()):(this.points.push([...i]),this.updateGraphic()))}),zt(this,"onMouseMove",e=>{this.state!=="drawing"||this.points.length<2||(this.points[this.points.length-1]=this.getPoint(e),this.updateGraphic())})}onInit(){this.context.registerDrawingRenderer(new Ee)}onActivate(){this.state="idle",this.points=[],this.context.getChart().getZr().setCursorStyle("crosshair");const t=this.context.getChart().getZr();t.on("click",this.onClick),t.on("mousemove",this.onMouseMove)}onDeactivate(){this.state="idle",this.points=[],this.removeGraphic();const t=this.context.getChart().getZr();t.off("click",this.onClick),t.off("mousemove",this.onMouseMove),t.setCursorStyle("default")}initGraphic(){this.graphicGroup=new G.graphic.Group,this.context.getChart().getZr().add(this.graphicGroup)}removeGraphic(){this.graphicGroup&&(this.context.getChart().getZr().remove(this.graphicGroup),this.graphicGroup=null)}updateGraphic(){if(!this.graphicGroup)return;this.graphicGroup.removeAll();const t=this.points;t.length>=3&&this.graphicGroup.add(new G.graphic.Polygon({shape:{points:t.slice(0,3)},style:{fill:"rgba(33,150,243,0.06)"},silent:!0})),t.length>=5&&this.graphicGroup.add(new G.graphic.Polygon({shape:{points:t.slice(2,5)},style:{fill:"rgba(76,175,80,0.06)"},silent:!0})),t.length>=7&&this.graphicGroup.add(new G.graphic.Polygon({shape:{points:t.slice(4,7)},style:{fill:"rgba(0,188,212,0.06)"},silent:!0}));for(let i=0;i<t.length-1;i++)this.graphicGroup.add(new G.graphic.Line({shape:{x1:t[i][0],y1:t[i][1],x2:t[i+1][0],y2:t[i+1][1]},style:{stroke:Le[i%Le.length],lineWidth:2},silent:!0}));const e=[[1,3],[3,5],[2,4]];for(const[i,s]of e)i<t.length&&s<t.length&&this.graphicGroup.add(new G.graphic.Line({shape:{x1:t[i][0],y1:t[i][1],x2:t[s][0],y2:t[s][1]},style:{stroke:"#555",lineWidth:1,lineDash:[4,4]},silent:!0}));for(let i=0;i<t.length&&i<Qt.length;i++){const[s,a]=t[i],n=(i===0||a<=t[i-1][1])&&(i===t.length-1||a<=t[i+1]?.[1]);Qt[i]&&this.graphicGroup.add(new G.graphic.Text({style:{text:Qt[i],x:s,y:n?a-14:a+16,fill:"#e2e8f0",fontSize:11,fontWeight:"bold",align:"center",verticalAlign:"middle"},silent:!0})),this.graphicGroup.add(new G.graphic.Circle({shape:{cx:s,cy:a,r:4},style:{fill:"#fff",stroke:"#3b82f6",lineWidth:1.5},z:101,silent:!0}))}}saveDrawing(){const t=this.points.map(e=>this.context.coordinateConversion.pixelToData({x:e[0],y:e[1]}));t.every(e=>e!==null)&&this.context.addDrawing({id:`3drives-${Date.now()}`,type:"three_drives_pattern",points:t,paneIndex:t[0].paneIndex||0,style:{color:"#3b82f6",lineWidth:2}})}}var qs=Object.defineProperty,Vs=(d,t,e)=>t in d?qs(d,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):d[t]=e,bt=(d,t,e)=>(Vs(d,typeof t!="symbol"?t+"":t,e),e);class Us extends nt{constructor(t){const e='<svg width="8" height="8" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="position: absolute; right: -4px; top: 50%; transform: translateY(-50%); opacity: 0.6;"><polyline points="9 18 15 12 9 6"></polyline></svg>';let i="";t.icon?i=`<div style="position: relative; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;">
|
|
37
|
+
<div style="font-size: 10px; color: #fff;padding-left:10px;">${y}</div>
|
|
38
|
+
</div>`}),a+="</div>"})}return a}}var Mi=Object.defineProperty,Ii=(h,t,e)=>t in h?Mi(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,It=(h,t,e)=>(Ii(h,typeof t!="symbol"?t+"":t,e),e);class Ai{constructor(t,e){It(this,"plugins",new Map),It(this,"activePluginId",null),It(this,"context"),It(this,"toolbarContainer"),It(this,"tooltipElement",null),It(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 n=this.tooltipElement.getBoundingClientRect(),r=i.top+(i.height-n.height)/2,s=i.right+10;this.tooltipElement.style.top=`${r}px`,this.tooltipElement.style.left=`${s}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 _i=Object.defineProperty,Si=(h,t,e)=>t in h?_i(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,ot=(h,t,e)=>(Si(h,typeof t!="symbol"?t+"":t,e),e);class zi{constructor(t){ot(this,"context"),ot(this,"isEditing",!1),ot(this,"currentDrawing",null),ot(this,"editingPointIndex",null),ot(this,"zr"),ot(this,"editGroup",null),ot(this,"editLines",[]),ot(this,"editPoints",[]),ot(this,"isMovingShape",!1),ot(this,"dragStart",null),ot(this,"initialPixelPoints",[]),ot(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(n=>{const r=this.context.coordinateConversion.dataToPixel(n);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))}),ot(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(n=>{const r=this.context.coordinateConversion.dataToPixel(n);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))}),ot(this,"onMouseMove",e=>{if(!this.isEditing||!this.currentDrawing)return;const i=e.offsetX,n=e.offsetY;if(this.isMovingShape&&this.dragStart){const r=i-this.dragStart.x,s=n-this.dragStart.y,l=this.initialPixelPoints.map(a=>({x:a.x+r,y:a.y+s}));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(s=>({x:s.x,y:s.y}));r[this.editingPointIndex]={x:i,y:n};for(let s=0;s<this.editLines.length;s++)this.editLines[s].setShape({x1:r[s].x,y1:r[s].y,x2:r[s+1].x,y2:r[s+1].y});this.editPoints[this.editingPointIndex].setShape({cx:i,cy:n})}}),ot(this,"onMouseUp",e=>{this.isEditing&&this.finishEditing(e.offsetX,e.offsetY)}),ot(this,"onWindowMouseUp",e=>{if(!this.isEditing)return;const i=this.zr.dom;if(i){const n=i.getBoundingClientRect(),r=e.clientX-n.left,s=e.clientY-n.top;this.finishEditing(r,s)}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 n=this.context.coordinateConversion.dataToPixel(i);return n?{x:n.x,y:n.y}:null});if(t.some(i=>!i))return;const e=t;for(let i=0;i<e.length-1;i++){const n=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(n),this.editGroup.add(n)}for(let i=0;i<e.length;i++){const n=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(n),this.editGroup.add(n)}this.zr.add(this.editGroup)}pixelToDataForPane(t,e,i){const n=this.context.coordinateConversion.pixelToData({x:t,y:e});if(n)return n;try{const r=this.context.getChart(),s=r.convertFromPixel({gridIndex:i},[t,e]);if(s){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(s[0])-o,value:s[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 n=t-this.dragStart.x,r=e-this.dragStart.y,s=this.initialPixelPoints.map(l=>this.pixelToDataForPane(l.x+n,l.y+r,i));if(s.every(l=>l!==null)){for(let l=0;l<s.length;l++)this.currentDrawing.points[l]=s[l];s[0]?.paneIndex!==void 0&&(this.currentDrawing.paneIndex=s[0].paneIndex),this.context.updateDrawing(this.currentDrawing)}}else if(this.editingPointIndex!==null){const n=this.pixelToDataForPane(t,e,i);n&&(this.currentDrawing.points[this.editingPointIndex]=n,this.editingPointIndex===0&&n.paneIndex!==void 0&&(this.currentDrawing.paneIndex=n.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,Gi=(h,t,e)=>t in h?$i(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,Ei=(h,t,e)=>(Gi(h,typeof t!="symbol"?t+"":t,e),e);class ge{constructor(){Ei(this,"renderers",new Map)}register(t){this.renderers.set(t.type,t)}get(t){return this.renderers.get(t)}}var Li=Object.defineProperty,Ti=(h,t,e)=>t in h?Li(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,Wi=(h,t,e)=>(Ti(h,typeof t!="symbol"?t+"":t,e),e);class Fi{constructor(){Wi(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(n=>{try{n(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 n=new Map;for(const r of e)r&&!r._deleted&&n.set(r.position,r);n.forEach(r=>{const s=r._paneIndex??0,l=i?i(s):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"),n=t.border_width??0,r=t.frame_width??0;if(n>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:d,opacity:g}=rt.safeParseColor(t.bgcolor);i.style.backgroundColor=d,g<1&&(i.style.opacity=String(g))}if(r>0&&t.frame_color){const{color:d}=rt.safeParseColor(t.frame_color);i.style.border=`${r}px solid ${d}`}else i.style.border="none";const s=new Map,l=new Set;if(t.merges)for(const d of t.merges){const g=`${d.startCol},${d.startRow}`;s.set(g,{colspan:d.endCol-d.startCol+1,rowspan:d.endRow-d.startRow+1});for(let c=d.startRow;c<=d.endRow;c++)for(let y=d.startCol;y<=d.endCol;y++)c===d.startRow&&y===d.startCol||l.add(`${y},${c}`)}const a=n>0&&!!t.border_color,o=a?rt.safeParseColor(t.border_color).color:"",p=t.rows||0,u=t.columns||0;for(let d=0;d<p;d++){const g=document.createElement("tr");for(let c=0;c<u;c++){const y=`${c},${d}`;if(l.has(y))continue;const f=document.createElement("td"),x=s.get(y);x&&(x.colspan>1&&(f.colSpan=x.colspan),x.rowspan>1&&(f.rowSpan=x.rowspan)),a?f.style.border=`${n}px solid ${o}`:f.style.border="none";const m=t.cells?.[d]?.[c];if(m&&!m._merged){if(f.textContent=m.text||"",m.bgcolor&&typeof m.bgcolor=="string"&&m.bgcolor.length>0){const{color:v,opacity:k}=rt.safeParseColor(m.bgcolor);f.style.backgroundColor=v,k<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 I=m?.height??0;I>0&&e&&I*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 n=8,r=i?i.y+"px":"0",s=i?i.x+"px":"0",l=i?i.y+i.height-n+"px":"0",a=i?i.x+i.width-n+"px":"0",o=i?i.x+i.width/2+"px":"50%",p=i?i.y+i.height/2+"px":"50%";switch(e){case"top_left":t.style.top=r,t.style.left=s;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=p,t.style.left=s,t.style.transform="translateY(-50%)";break;case"middle_center":t.style.top=p,t.style.left=o,t.style.transform="translate(-50%, -50%)";break;case"middle_right":t.style.top=p,t.style.left=a,t.style.transform="translate(-100%, -50%)";break;case"bottom_left":t.style.top=l,t.style.left=s,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 it{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),n=parseInt(t.slice(3,5),16),r=parseInt(t.slice(5,7),16),s=parseInt(t.slice(7,9),16)/255;return{color:`rgb(${i},${n},${r})`,opacity:s}}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 n=[];return i.forEach(r=>{const s=r._paneIndex??0,l=e(s);if(!l)return;const a=it.buildTableElements(r,l);n.push(...a)}),n}static buildTableElements(t,e){const i=t.rows||0,n=t.columns||0;if(i===0||n===0)return[];const r=t.border_width??0,s=t.frame_width??0,l=r>0&&!!t.border_color,a=s>0&&!!t.frame_color,o=new Map,p=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||p.add(`${M},${G}`)}const u=4,d=2,g=1.25,c=[];for(let P=0;P<i;P++){c[P]=[];for(let G=0;G<n;G++){if(p.has(`${G},${P}`)){c[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],R=o.get(`${G},${P}`),F=R?.colspan??1,J=R?.rowspan??1,H=M&&!M._merged&&M.text||"",Y=H?H.split(`
|
|
39
|
+
`):[],at=M?it.getSizePixels(M.text_size):12,U=M?.text_font_family==="monospace"?"monospace":"sans-serif";let nt=0,O=0;M?.width>0&&(nt=Math.max(1,M.width*e.width/100)),M?.height>0&&(O=Math.max(1,M.height*e.height/100));const V=O>0&&O<4,ae=V?0:u,qt=V?0:d,Ut=M&&!M._merged&&M.bgcolor&&typeof M.bgcolor=="string"&&M.bgcolor.length>0?M.bgcolor:"",kt=M?.text_color||"";c[P][G]={text:H,lines:Y,fontSize:at,fontFamily:U,textColor:kt?it.parseColor(kt):{color:"#e0e0e0",opacity:1},bgColor:Ut?it.parseColor(Ut):{color:"",opacity:0},halign:M?it.mapHAlign(M.text_halign):"center",valign:M?it.mapVAlign(M.text_valign):"middle",explicitWidth:nt,explicitHeight:O,colspan:F,rowspan:J,skip:!1,padX:ae,padY:qt}}}const y=new Array(n).fill(0),f=new Array(i).fill(0);for(let P=0;P<i;P++)for(let G=0;G<n;G++){const M=c[P][G];if(M.skip||M.colspan>1||M.rowspan>1)continue;const R=it.measureMultiLineWidth(M.lines,M.fontSize,M.fontFamily),F=Math.max(M.lines.length,1),J=M.explicitWidth>0?M.explicitWidth:R+M.padX*2,H=M.explicitHeight>0?M.explicitHeight:F*M.fontSize*g+M.padY*2;y[G]=Math.max(y[G],J),f[P]=Math.max(f[P],H)}for(let P=0;P<n;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<n;G++){const M=c[P][G];if(M.skip)continue;const R=Math.max(M.lines.length,1),F=M.explicitHeight>0?M.explicitHeight:R*M.fontSize*g+M.padY*2;if(M.colspan>1){const J=it.sumRange(y,G,M.colspan),H=it.measureMultiLineWidth(M.lines,M.fontSize,M.fontFamily),Y=M.explicitWidth>0?M.explicitWidth:H+M.padX*2;if(Y>J){const at=(Y-J)/M.colspan;for(let U=0;U<M.colspan;U++)y[G+U]+=at}M.rowspan===1&&(f[P]=Math.max(f[P],F))}if(M.rowspan>1){const J=it.sumRange(f,P,M.rowspan);if(F>J){const H=(F-J)/M.rowspan;for(let Y=0;Y<M.rowspan;Y++)f[P+Y]+=H}}}for(let P=0;P<n;P++)y[P]=Math.round(y[P]);for(let P=0;P<i;P++)f[P]=Math.round(f[P]);const x=new Array(n+1).fill(0);for(let P=0;P<n;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 I=a?s:0,v=x[n]+I*2,k=m[i]+I*2,A=Math.min(v,e.width),w=Math.min(k,e.height),b=it.computePosition(t.position,e,A,w),C=Math.round(b.x),_=Math.round(b.y),z=[],S=C+I,$=_+I;if(t.bgcolor){const{color:P,opacity:G}=it.parseColor(t.bgcolor);G>0&&z.push({type:"rect",shape:{x:C,y:_,width:A,height:w},style:{fill:P,opacity:G},silent:!0,z:0,z2:0})}if(a){const{color:P}=it.parseColor(t.frame_color),G=s/2;z.push({type:"rect",shape:{x:C+G,y:_+G,width:A-s,height:w-s},style:{fill:"none",stroke:P,lineWidth:s},silent:!0,z:0,z2:1})}const L=l?it.parseColor(t.border_color).color:"";for(let P=0;P<i;P++)for(let G=0;G<n;G++){const M=c[P][G];if(M.skip)continue;const R=S+x[G],F=$+m[P],J=it.sumRange(y,G,M.colspan),H=it.sumRange(f,P,M.rowspan);if(R-C>=A||F-_>=w)continue;const Y=Math.min(J,A-(R-C)),at=Math.min(H,w-(F-_));if(M.bgColor.opacity>0&&z.push({type:"rect",shape:{x:R,y:F,width:Y,height:at},style:{fill:M.bgColor.color,opacity:M.bgColor.opacity},silent:!0,z:0,z2:2}),l&&z.push({type:"rect",shape:{x:R,y:F,width:Y,height:at},style:{fill:"none",stroke:L,lineWidth:r},silent:!0,z:0,z2:3}),M.text){let U,nt;switch(M.halign){case"left":U=R+M.padX,nt="left";break;case"right":U=R+Y-M.padX,nt="right";break;default:U=R+Y/2,nt="center";break}let O,V;switch(M.valign){case"top":O=F+M.padY,V="top";break;case"bottom":O=F+at-M.padY,V="bottom";break;default:O=F+at/2,V="middle";break}z.push({type:"text",x:U,y:O,style:{text:M.text,fill:M.textColor.color,opacity:M.textColor.opacity,font:`${M.fontSize}px ${M.fontFamily}`,textAlign:nt,textVerticalAlign:V,lineHeight:Math.round(M.fontSize*g)},silent:!0,z:0,z2:4})}}return z}static computePosition(t,e,i,n){const r=e.x,s=e.y,l=e.width,a=e.height;switch(t){case"top_left":return{x:r+4,y:s+4};case"top_center":return{x:r+(l-i)/2,y:s+4};case"top_right":return{x:r+l-i-4,y:s+4};case"middle_left":return{x:r+4,y:s+(a-n)/2};case"middle_center":return{x:r+(l-i)/2,y:s+(a-n)/2};case"middle_right":return{x:r+l-i-4,y:s+(a-n)/2};case"bottom_left":return{x:r+4,y:s+a-n-4};case"bottom_center":return{x:r+(l-i)/2,y:s+a-n-4};case"bottom_right":return{x:r+l-i-4,y:s+a-n-4};default:return{x:r+l-i-4,y:s+4}}}static measureMultiLineWidth(t,e,i){if(!t||t.length===0)return 0;const n=i==="monospace"?.6:.55;let r=0;for(const s of t)r=Math.max(r,s.length*e*n);return r}static sumRange(t,e,i){let n=0;for(let r=e;r<e+i&&r<t.length;r++)n+=t[r];return n}}var Zi=Object.defineProperty,Ni=(h,t,e)=>t in h?Zi(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,W=(h,t,e)=>(Ni(h,typeof t!="symbol"?t+"":t,e),e);class Ri{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 Fi),W(this,"isMainCollapsed",!1),W(this,"maximizedPaneId",null),W(this,"countdownInterval",null),W(this,"selectedDrawingId",null),W(this,"drawings",[]),W(this,"drawingRenderers",new ge),W(this,"coordinateConversion",{pixelToData:s=>{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},[s.x,s.y])){this.chart.convertFromPixel({seriesIndex:o},[s.x,s.y]);const p=this.chart.convertFromPixel({gridIndex:o},[s.x,s.y]);if(p)return{timeIndex:Math.round(p[0])-this.dataIndexOffset,value:p[1],paneIndex:o}}return null},dataToPixel:s=>{const l=s.paneIndex||0,a=this.chart.convertToPixel({gridIndex:l},[s.timeIndex+this.dataIndexOffset,s.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",s=>{(s.key==="Delete"||s.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 Ai(this,this.toolbarContainer),this.drawingEditor=new zi(this),this.chart.on("dataZoom",s=>{this.events.emit("chart:dataZoom",s);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",s=>this.events.emit("chart:updated",s)),this.chart.getZr().on("mousedown",s=>{this._paneDragState||this.events.emit("mouse:down",s)}),this.chart.getZr().on("mousemove",s=>{this._paneDragState||this.events.emit("mouse:move",s)}),this.chart.getZr().on("mouseup",s=>this.events.emit("mouse:up",s)),this.chart.getZr().on("click",s=>{this._paneDragState||this.events.emit("mouse:click",s)});const i=this.chart.getZr(),n=i.setCursorStyle,r=this;i.setCursorStyle=function(s){if(r._paneDragState){n.call(this,"row-resize");return}s==="grab"&&(s="crosshair"),n.call(this,s)},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=n=>{if(!this._lastLayout||this._lastLayout.paneBoundaries.length===0||this.maximizedPaneId)return null;const r=this.chart.getHeight();if(r<=0)return null;for(const s of this._lastLayout.paneBoundaries){const l=s.yPercent/100*r;if(Math.abs(n-l)<=6){if(s.aboveId==="main"&&this.isMainCollapsed||this.indicators.get(s.belowId)?.collapsed||s.aboveId!=="main"&&this.indicators.get(s.aboveId)?.collapsed)continue;return s}}return null},i=n=>n==="main"?this._lastLayout?.mainPaneHeight??50:this.indicators.get(n)?.height??15;t.on("mousemove",n=>{if(this._paneDragState){const r=n.offsetY-this._paneDragState.startY,s=this.chart.getHeight();if(s<=0)return;const l=r/s*100,a=this._paneDragState.aboveId==="main"?10:5,o=5;let p=this._paneDragState.startAboveHeight+l,u=this._paneDragState.startBelowHeight-l;if(p<a&&(p=a,u=this._paneDragState.startAboveHeight+this._paneDragState.startBelowHeight-a),u<o&&(u=o,p=this._paneDragState.startAboveHeight+this._paneDragState.startBelowHeight-o),this._paneDragState.aboveId==="main")this._mainHeightOverride=p;else{const g=this.indicators.get(this._paneDragState.aboveId);g&&(g.height=p)}const d=this.indicators.get(this._paneDragState.belowId);d&&(d.height=u),this._paneResizeRafId||(this._paneResizeRafId=requestAnimationFrame(()=>{this._paneResizeRafId=null,this.render()})),t.setCursorStyle("row-resize"),n.stop?.();return}e(n.offsetY)&&t.setCursorStyle("row-resize")}),t.on("mousedown",n=>{const r=e(n.offsetY);r&&(this._paneDragState={startY:n.offsetY,aboveId:r.aboveId,belowId:r.belowId,startAboveHeight:i(r.aboveId),startBelowHeight:i(r.belowId)},t.setCursorStyle("row-resize"),n.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 n=i.seriesName.match(/drawings-pane-(\d+)/);if(!n)return null;const r=parseInt(n[1]),s=this.drawings.filter(a=>(a.paneIndex||0)===r)[i.dataIndex];if(!s)return null;const l=i.event?.target?.name;return{drawing:s,targetName:l,paneIdx:r}};this.chart.on("mouseover",i=>{const n=e(i);if(!n)return;const r=i.event?.target?.parent;if(r){const s=n.drawing.id===this.selectedDrawingId;t&&(clearTimeout(t),t=null),s||r.children().forEach(l=>{l.name&&l.name.startsWith("point")&&l.attr("style",{opacity:1})})}if(n.targetName==="line")this.events.emit("drawing:hover",{id:n.drawing.id,type:n.drawing.type}),this.chart.getZr().setCursorStyle("move");else if(n.targetName?.startsWith("point-")){const s=parseInt(n.targetName.split("-")[1])||0;this.events.emit("drawing:point:hover",{id:n.drawing.id,pointIndex:s}),this.chart.getZr().setCursorStyle("pointer")}}),this.chart.on("mouseout",i=>{const n=e(i);if(!n)return;const r=i.event?.target?.parent;if(n.drawing.id!==this.selectedDrawingId){if(t=setTimeout(()=>{if(r){if(this.selectedDrawingId===n.drawing.id)return;r.children().forEach(s=>{s.name&&s.name.startsWith("point")&&s.attr("style",{opacity:0})})}},50),n.targetName==="line")this.events.emit("drawing:mouseout",{id:n.drawing.id});else if(n.targetName?.startsWith("point-")){const s=parseInt(n.targetName.split("-")[1])||0;this.events.emit("drawing:point:mouseout",{id:n.drawing.id,pointIndex:s})}this.chart.getZr().setCursorStyle("default")}}),this.chart.on("mousedown",i=>{const n=e(i);if(!n)return;const r=i.event?.event||i.event,s=r?.offsetX,l=r?.offsetY;if(n.targetName==="line")this.events.emit("drawing:mousedown",{id:n.drawing.id,x:s,y:l});else if(n.targetName?.startsWith("point-")){const a=parseInt(n.targetName.split("-")[1])||0;this.events.emit("drawing:point:mousedown",{id:n.drawing.id,pointIndex:a,x:s,y:l})}}),this.chart.on("click",i=>{const n=e(i);if(n){if(this.selectedDrawingId!==n.drawing.id&&(this.selectedDrawingId=n.drawing.id,this.events.emit("drawing:selected",{id:n.drawing.id}),this.render()),n.targetName==="line")this.events.emit("drawing:click",{id:n.drawing.id});else if(n.targetName?.startsWith("point-")){const r=parseInt(n.targetName.split("-")[1])||0;this.events.emit("drawing:point:click",{id:n.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 n=i.data?._tooltipText;if(!n||!this._labelTooltipEl)return;this._labelTooltipEl.textContent=n,this._labelTooltipEl.style.display="block";const r=this.chartContainer.getBoundingClientRect(),s=i.event?.event;if(s){const l=s.clientX-r.left,a=s.clientY-r.top,o=this._labelTooltipEl.offsetWidth,p=Math.min(l-o/2,r.width-o-8);this._labelTooltipEl.style.left=Math.max(4,p)+"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 n=Math.round(e.timeIndex);if(n<0||n>=this.marketData.length)return t;const r=this.marketData[n];if(!r)return t;const s=this.chart.convertToPixel({gridIndex:i},[n+this.dataIndexOffset,r.close]);if(!s)return t;const l=s[0],a=[r.open,r.high,r.low,r.close];let o=a[0],p=1/0;for(const d of a){const g=this.chart.convertToPixel({gridIndex:i},[n+this.dataIndexOffset,d]);if(g){const c=Math.abs(g[1]-t.y);c<p&&(p=c,o=d)}}const u=this.chart.convertToPixel({gridIndex:i},[n+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(x=>{e.set(x.time,x)}),t.forEach(x=>{e.has(x.time),e.set(x.time,x)}),this.marketData=Array.from(e.values()).sort((x,m)=>x.time-m.time),this.rebuildTimeIndex();const i=this.dataIndexOffset,n=Mt.buildCandlestickSeries(this.marketData,this.options),r={value:[NaN,NaN,NaN,NaN],itemStyle:{opacity:0}},s=[...Array(i).fill(r),...n.data,...Array(i).fill(r)],l=[...Array(i).fill(""),...this.marketData.map(x=>new Date(x.time).toLocaleString()),...Array(i).fill("")],a=this.chart.getOption(),o=Kt.calculate(this.chart.getHeight(),this.indicators,this.options,this.isMainCollapsed,this.maximizedPaneId,this.marketData,this._mainHeightOverride??void 0);this._lastLayout=o;const p=[...Array(i).fill(null),...this.marketData,...Array(i).fill(null)],{series:u,barColors:d}=Mt.buildIndicatorSeries(this.indicators,this.timeToIndex,o.paneLayout,l.length,i,p,o.overlayYAxisMap,o.separatePaneYAxisOffset),g=s.map((x,m)=>d[m]?{value:x.value||x,itemStyle:{color:d[m],color0:d[m]}}:x),c=this._buildDrawingRangeHints(o,i),y={xAxis:a.xAxis.map((x,m)=>({data:l})),series:[{data:g,markLine:n.markLine},...u,...c]};this.chart.setOption(y,{notMerge:!1});const f=[];this.indicators.forEach(x=>{Object.values(x.plots).forEach(m=>{m.options?.style==="table"&&m.data?.forEach(I=>{(Array.isArray(I.value)?I.value:[I.value]).forEach(v=>{v&&!v._deleted&&(v._paneIndex=v.force_overlay?0:x.paneIndex,f.push(v))})})})}),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],n=this.marketData[this.marketData.length-2];t=i.time-n.time}if(!t)return;const e=()=>{if(this.marketData.length===0)return;const i=this.marketData[this.marketData.length-1].time+t,n=Date.now(),r=i-n;if(r<=0)return;const s=Math.abs(r),l=Math.floor(s/36e5),a=Math.floor(s%36e5/6e4),o=Math.floor(s%6e4/1e3),p=`${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 d=u.series.findIndex(m=>m.type==="candlestick");if(d===-1)return;const g=u.series[d];if(!g.markLine||!g.markLine.data||!g.markLine.data[0])return;const c=g.markLine.data[0];c.label.formatter;const y=c.yAxis;let f="";if(this.options.yAxisLabelFormatter)f=this.options.yAxisLabelFormatter(y);else{const m=this.options.yAxisDecimalPlaces!==void 0?this.options.yAxisDecimalPlaces:X.autoDetectDecimals(this.marketData);f=X.formatValue(y,m)}const x=`${f}
|
|
40
|
+
${p}`;this.chart.setOption({series:[{id:"__candlestick__",markLine:{data:[{...c,label:{...c.label,formatter:x}}]}}]})};e(),this.countdownInterval=setInterval(e,1e3)}stopCountdown(){this.countdownInterval&&(clearInterval(this.countdownInterval),this.countdownInterval=null)}addIndicator(t,e,i={}){const n=i.overlay!==void 0?i.overlay:i.isOverlay??!1;let r=0;if(!n){let l=0;this.indicators.forEach(a=>{a.paneIndex>l&&(l=a.paneIndex)}),r=l+1}const s=new oi(t,e,r,{height:i.height,collapsed:!1,titleColor:i.titleColor,controls:i.controls});return this.indicators.set(t,s),this.render(),s}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()}_buildDrawingRangeHints(t,e){const i=[],n=new Map;for(const s of this.indicators){if(!s.plots)continue;const l=s.paneIndex??0;n.has(l)||n.set(l,{yMin:1/0,yMax:-1/0});const a=n.get(l);for(const[o,p]of Object.entries(s.plots)){if(!p||!p.options)continue;const u=p.options?.style;if(u==="drawing_line"&&p.data)for(const d of p.data){const g=d?.value?Array.isArray(d.value)?d.value:[d.value]:[];for(const c of g)!c||c._deleted||(typeof c.y1=="number"&&isFinite(c.y1)&&(a.yMin=Math.min(a.yMin,c.y1),a.yMax=Math.max(a.yMax,c.y1)),typeof c.y2=="number"&&isFinite(c.y2)&&(a.yMin=Math.min(a.yMin,c.y2),a.yMax=Math.max(a.yMax,c.y2)))}if(u==="drawing_box"&&p.data)for(const d of p.data){const g=d?.value?Array.isArray(d.value)?d.value:[d.value]:[];for(const c of g)!c||c._deleted||(typeof c.top=="number"&&isFinite(c.top)&&(a.yMin=Math.min(a.yMin,c.top),a.yMax=Math.max(a.yMax,c.top)),typeof c.bottom=="number"&&isFinite(c.bottom)&&(a.yMin=Math.min(a.yMin,c.bottom),a.yMax=Math.max(a.yMax,c.bottom)))}if(u==="label"&&p.data)for(const d of p.data){const g=d?.value?Array.isArray(d.value)?d.value:[d.value]:[];for(const c of g)!c||c._deleted||typeof c.y=="number"&&isFinite(c.y)&&(a.yMin=Math.min(a.yMin,c.y),a.yMax=Math.max(a.yMax,c.y))}if(u==="drawing_polyline"&&p.data)for(const d of p.data){const g=d?.value?Array.isArray(d.value)?d.value:[d.value]:[];for(const c of g)if(!(!c||c._deleted||!c._points))for(const y of c._points)typeof y?.price=="number"&&isFinite(y.price)&&(a.yMin=Math.min(a.yMin,y.price),a.yMax=Math.max(a.yMax,y.price))}}}const r=e+Math.floor((this.marketData?.length||0)/2);return n.forEach((s,l)=>{if(!isFinite(s.yMin)||!isFinite(s.yMax))return;const a=l===0?0:(t.separatePaneYAxisOffset||1)+(l-1);i.push({name:`_drawingRange_pane${l}`,type:"scatter",xAxisIndex:l,yAxisIndex:a,symbol:"none",symbolSize:0,silent:!0,animation:!1,data:[[r,s.yMin],[r,s.yMax]],tooltip:{show:!1}})}),i}_buildTableGraphics(){const t=this.chart.getModel(),e=n=>t.getComponent("grid",n)?.coordinateSystem?.getRect(),i=it.buildGraphicElements(this._lastTables,e);this._tableGraphicIds=[];for(let n=0;n<i.length;n++){const r=`__qf_table_${n}`;i[n].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,n)=>{this.timeToIndex.set(i.time,n)});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,n=this.marketData.length+2*i,r=this.chart.getOption(),s=r?.dataZoom?.find(_=>_.type==="slider"||_.type==="inside"),l=s?s.start/100*n:0,a=s?s.end/100*n:n,o=t-i;this._paddingPoints=t,this.dataIndexOffset=this._paddingPoints;const p=this._paddingPoints,u={value:[NaN,NaN,NaN,NaN],itemStyle:{opacity:0}},d=Mt.buildCandlestickSeries(this.marketData,this.options),g=[...Array(p).fill(u),...d.data,...Array(p).fill(u)],c=[...Array(p).fill(""),...this.marketData.map(_=>new Date(_.time).toLocaleString()),...Array(p).fill("")],y=[...Array(p).fill(null),...this.marketData,...Array(p).fill(null)],f=Kt.calculate(this.chart.getHeight(),this.indicators,this.options,this.isMainCollapsed,this.maximizedPaneId,this.marketData,this._mainHeightOverride??void 0),{series:x,barColors:m}=Mt.buildIndicatorSeries(this.indicators,this.timeToIndex,f.paneLayout,c.length,p,y,f.overlayYAxisMap,f.separatePaneYAxisOffset),I=g.map((_,z)=>m[z]?{value:_.value||_,itemStyle:{color:m[z],color0:m[z]}}:_),v=this.marketData.length+2*t,k=Math.max(0,(l+o)/v*100),A=Math.min(100,(a+o)/v*100),w=[],b=new Map;this.drawings.forEach(_=>{const z=_.paneIndex||0;b.has(z)||b.set(z,[]),b.get(z).push(_)}),b.forEach(_=>{w.push({data:_.map(z=>{const S=[];return z.points.forEach($=>{S.push($.timeIndex+this.dataIndexOffset,$.value)}),S})})});const C={xAxis:r.xAxis.map(()=>({data:c})),dataZoom:(r.dataZoom||[]).map(()=>({start:k,end:A})),series:[{data:I,markLine:d.markLine},...x.map(_=>{const z={data:_.data};return _.renderItem&&(z.renderItem=_.renderItem),z}),...w]};this.chart.setOption(C,{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,n=i+2*e,r=Math.round(t.start/100*n),s=Math.round(t.end/100*n),l=e,a=e+i-1,o=Math.max(0,Math.min(s,a)-Math.max(r,l)+1),p=r<this.LAZY_EDGE_THRESHOLD,u=s>n-this.LAZY_EDGE_THRESHOLD;if((p||u)&&e<this.LAZY_MAX_PADDING&&o>=3){this._expandScheduled=!0,requestAnimationFrame(()=>{this._expandScheduled=!1,this._resizePadding(e+this.LAZY_CHUNK_SIZE)});return}const d=Math.max(0,e-r),g=Math.max(0,s-(e+i-1)),c=Math.max(d+this.LAZY_CHUNK_SIZE,g+this.LAZY_CHUNK_SIZE);e>c+this.LAZY_CHUNK_SIZE&&(this._expandScheduled=!0,requestAnimationFrame(()=>{this._expandScheduled=!1,this._resizePadding(c)}))}render(){if(this.marketData.length===0)return;let t=null;try{const w=this.chart.getOption();if(w&&w.dataZoom&&w.dataZoom.length>0){const b=w.dataZoom.find(C=>C.type==="slider"||C.type==="inside");b&&(t={start:b.start,end:b.end})}}catch{}const e=this.options.databox?.position,i=this.leftSidebar.style.display,n=this.rightSidebar.style.display,r=e==="left"?"block":"none",s=e==="right"?"block":"none";(i!==r||n!==s)&&(this.leftSidebar.style.display=r,this.rightSidebar.style.display=s,this.chart.resize());const l=this.dataIndexOffset,a=[...Array(l).fill(""),...this.marketData.map(w=>new Date(w.time).toLocaleString()),...Array(l).fill("")],o=Kt.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 w=this.marketData.length,b=a.length,C=l/b,_=w/b;o.dataZoom.forEach(z=>{if(z.start!==void 0){const S=z.start/100,$=C+S*_;z.start=$*100}if(z.end!==void 0){const S=z.end/100,$=C+S*_;z.end=$*100}})}t&&o.dataZoom&&o.dataZoom.forEach(w=>{w.start=t.start,w.end=t.end}),o.xAxis.forEach(w=>{w.data=a,w.boundaryGap=!1});const p=Mt.buildCandlestickSeries(this.marketData,this.options),u={value:[NaN,NaN,NaN,NaN],itemStyle:{opacity:0}};p.data=[...Array(l).fill(u),...p.data,...Array(l).fill(u)];const d=[...Array(l).fill(null),...this.marketData,...Array(l).fill(null)],{series:g,barColors:c}=Mt.buildIndicatorSeries(this.indicators,this.timeToIndex,o.paneLayout,a.length,l,d,o.overlayYAxisMap,o.separatePaneYAxisOffset),y=this._buildDrawingRangeHints(o,l);p.data=p.data.map((w,b)=>c[b]?{value:w.value||w,itemStyle:{color:c[b],color0:c[b]}}:w);const f=[];this.indicators.forEach((w,b)=>{w.paneIndex===0&&f.push({id:b,titleColor:w.titleColor})});const x=ki.build(o,this.options,this.toggleIndicator.bind(this),this.isMainCollapsed,this.maximizedPaneId,f),m=new Map;this.drawings.forEach(w=>{const b=w.paneIndex||0;m.has(b)||m.set(b,[]),m.get(b).push(w)});const I=[];m.forEach((w,b)=>{I.push({type:"custom",name:`drawings-pane-${b}`,xAxisIndex:b,yAxisIndex:b,clip:!0,renderItem:(C,_)=>{const z=w[C.dataIndex];if(!z)return;const S=this.drawingRenderers.get(z.type);if(!S)return;const $=this.dataIndexOffset,L=z.points.map(P=>_.coord([P.timeIndex+$,P.value]));return S.render({drawing:z,pixelPoints:L,isSelected:z.id===this.selectedDrawingId,api:_,coordSys:C.coordSys})},data:w.map(C=>{const _=[];return C.points.forEach(z=>{_.push(z.timeIndex+this.dataIndexOffset,z.value)}),_}),encode:(()=>{const C=w.reduce((S,$)=>Math.max(S,$.points.length),0),_=Array.from({length:C},(S,$)=>$*2),z=Array.from({length:C},(S,$)=>$*2+1);return{x:_,y:z}})(),z:100,silent:!1})});const v=w=>{const b=Di.format(w,this.options),C=this.options.databox?.position;return C==="left"?(this.leftSidebar.innerHTML=b,""):C==="right"?(this.rightSidebar.innerHTML=b,""):this.options.databox?`<div style="min-width: 200px;">${b}</div>`:""},k=[];this.indicators.forEach(w=>{Object.values(w.plots).forEach(b=>{b.options?.style==="table"&&b.data?.forEach(C=>{(Array.isArray(C.value)?C.value:[C.value]).forEach(_=>{_&&!_._deleted&&(_._paneIndex=_.force_overlay?0:w.paneIndex,k.push(_))})})})});const A={backgroundColor:this.options.backgroundColor,animation:!1,legend:{show:!1},tooltip:{show:!0,showContent:!!this.options.databox,trigger:"axis",triggerOn:this.options.databox?.triggerOn??"mousemove",axisPointer:{type:"cross",label:{backgroundColor:"#475569"}},backgroundColor:"rgba(30, 41, 59, 0.9)",borderWidth:1,borderColor:"#334155",padding:10,textStyle:{color:"#fff",fontFamily:this.options.fontFamily||"sans-serif"},formatter:v,extraCssText:e!=="floating"&&e!==void 0?"display: none !important;":void 0,position:(w,b,C,_,z)=>{if(this.options.databox?.position==="floating"){const S={top:10};return S[["left","right"][+(w[0]<z.viewSize[0]/2)]]=30,S}return null}},axisPointer:{link:{xAxisIndex:"all"},label:{backgroundColor:"#475569"}},graphic:x,grid:o.grid,xAxis:o.xAxis,yAxis:o.yAxis,dataZoom:o.dataZoom,series:[p,...g,...y,...I]};if(this.chart.setOption(A,!0),this._baseGraphics=x,this._lastTables=k,k.length>0){const w=this._buildTableGraphics();if(w.length>0){const b=[...x,...w];this.chart.setOption({graphic:b},{replaceMerge:["graphic"]})}}else this._tableGraphicIds=[];rt.clearAll(this.overlayContainer)}}var Oi=Object.defineProperty,Hi=(h,t,e)=>t in h?Oi(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,dt=(h,t,e)=>(Hi(h,typeof t!="symbol"?t+"":t,e),e);class q{constructor(t){dt(this,"id"),dt(this,"name"),dt(this,"icon"),dt(this,"context"),dt(this,"eventListeners",[]),dt(this,"_snapIndicator",null),dt(this,"_snapMoveHandler",null),dt(this,"_snapKeyDownHandler",null),dt(this,"_snapKeyUpHandler",null),dt(this,"_snapBlurHandler",null),dt(this,"_snapActive",!1),dt(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,n=t.event;if(n?.ctrlKey||n?.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}),n=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}),n.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 Bi=Object.defineProperty,ji=(h,t,e)=>t in h?Bi(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,st=(h,t,e)=>(ji(h,typeof t!="symbol"?t+"":t,e),e);class Yi extends q{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>'}),st(this,"zr"),st(this,"state","idle"),st(this,"startPoint",null),st(this,"endPoint",null),st(this,"group",null),st(this,"rect",null),st(this,"labelRect",null),st(this,"labelText",null),st(this,"lineV",null),st(this,"lineH",null),st(this,"arrowStart",null),st(this,"arrowEnd",null),st(this,"onMouseDown",()=>{this.state==="finished"&&this.removeGraphic()}),st(this,"onChartInteraction",()=>{this.group&&this.removeGraphic()}),st(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())}),st(this,"clearHandlers",{}),st(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,n]=this.endPoint,r=this.context.coordinateConversion.pixelToData({x:t,y:e}),s=this.context.coordinateConversion.pixelToData({x:i,y:n});if(!r||!s)return;const l=Math.round(r.timeIndex),a=Math.round(s.timeIndex),o=r.value,p=s.value,u=a-l,d=p-o,g=d/o*100,c=d>=0,y=c?"rgba(33, 150, 243, 0.2)":"rgba(236, 0, 0, 0.2)",f=c?"#2196F3":"#ec0000";this.rect.setShape({x:Math.min(t,i),y:Math.min(e,n),width:Math.abs(i-t),height:Math.abs(n-e)}),this.rect.setStyle({fill:y});const x=(t+i)/2,m=(e+n)/2;this.lineV.setShape({x1:x,y1:e,x2:x,y2:n}),this.lineV.setStyle({stroke:f}),this.lineH.setShape({x1:t,y1:m,x2:i,y2:m}),this.lineH.setStyle({stroke:f});const I=Math.min(e,n),v=Math.max(e,n);this.arrowStart.setStyle({fill:"none"}),this.arrowEnd.setStyle({fill:"none"}),c?(this.arrowStart.setShape({points:[[x,I],[x-4,I+6],[x+4,I+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 k=[`${d.toFixed(2)} (${g.toFixed(2)}%)`,`${u} bars`].join(`
|
|
41
|
+
`),A=140,w=40,b=Math.max(e,n),C=Math.min(e,n);let _=(t+i)/2-A/2,z=b+10;const S=this.chart.getHeight();z+w>S&&(z=C-w-10),this.labelRect.setShape({x:_,y:z,width:A,height:w}),this.labelRect.setStyle({fill:"#1e293b",stroke:f,lineWidth:1}),this.labelText.setStyle({x:_+A/2,y:z+w/2,text:k,fill:"#fff"})}}var Vi=Object.defineProperty,Xi=(h,t,e)=>t in h?Vi(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,qi=(h,t,e)=>(Xi(h,typeof t!="symbol"?t+"":t,e),e);class ye{constructor(){qi(this,"type","line")}render(t){const{drawing:e,pixelPoints:i,isSelected:n}=t,[r,s]=i[0],[l,a]=i[1],o=e.style?.color||"#d1d4dc";return{type:"group",children:[{type:"line",name:"line",shape:{x1:r,y1:s,x2:l,y2:a},style:{stroke:o,lineWidth:e.style?.lineWidth||1}},{type:"circle",name:"point-0",shape:{cx:r,cy:s,r:4},style:{fill:"#fff",stroke:o,lineWidth:1,opacity:n?1:0}},{type:"circle",name:"point-1",shape:{cx:l,cy:a,r:4},style:{fill:"#fff",stroke:o,lineWidth:1,opacity:n?1:0}}]}}}var Ui=Object.defineProperty,Ki=(h,t,e)=>t in h?Ui(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,gt=(h,t,e)=>(Ki(h,typeof t!="symbol"?t+"":t,e),e);class Ji extends q{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>'}),gt(this,"zr"),gt(this,"state","idle"),gt(this,"startPoint",null),gt(this,"endPoint",null),gt(this,"group",null),gt(this,"line",null),gt(this,"startCircle",null),gt(this,"endCircle",null),gt(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]}),n=this.context.coordinateConversion.pixelToData({x:this.endPoint[0],y:this.endPoint[1]});if(i&&n){const r=i.paneIndex||0;this.context.addDrawing({id:`line-${Date.now()}`,type:"line",points:[i,n],paneIndex:r,style:{color:"#d1d4dc",lineWidth:1}})}}this.removeGraphic(),this.context.disableTools()}}),gt(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.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,n]=this.endPoint;this.line.setShape({x1:t,y1:e,x2:i,y2:n}),this.startCircle.setShape({cx:t,cy:e}),this.endCircle.setShape({cx:i,cy:n})}}var Qi=Object.defineProperty,tn=(h,t,e)=>t in h?Qi(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,en=(h,t,e)=>(tn(h,typeof t!="symbol"?t+"":t,e),e);class fe{constructor(){en(this,"type","ray")}render(t){const{drawing:e,pixelPoints:i,isSelected:n,coordSys:r}=t,[s,l]=i[0],[a,o]=i[1],p=e.style?.color||"#d1d4dc",[u,d]=this.extendToEdge(s,l,a,o,r);return{type:"group",children:[{type:"line",name:"line",shape:{x1:s,y1:l,x2:u,y2:d},style:{stroke:p,lineWidth:e.style?.lineWidth||1}},{type:"circle",name:"point-0",shape:{cx:s,cy:l,r:4},style:{fill:"#fff",stroke:p,lineWidth:1,opacity:n?1:0}},{type:"circle",name:"point-1",shape:{cx:a,cy:o,r:4},style:{fill:"#fff",stroke:p,lineWidth:1,opacity:n?1:0}}]}}extendToEdge(t,e,i,n,r){const s=i-t,l=n-e;if(s===0&&l===0)return[i,n];const a=r.x,o=r.x+r.width,p=r.y,u=r.y+r.height;let d=1/0;if(s!==0){const g=s>0?(o-t)/s:(a-t)/s;g>0&&(d=Math.min(d,g))}if(l!==0){const g=l>0?(u-e)/l:(p-e)/l;g>0&&(d=Math.min(d,g))}return isFinite(d)||(d=1),[t+d*s,e+d*l]}}var nn=Object.defineProperty,sn=(h,t,e)=>t in h?nn(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,ut=(h,t,e)=>(sn(h,typeof t!="symbol"?t+"":t,e),e);const Gt="#d1d4dc";class on extends q{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>'}),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,"dashLine",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.startPoint&&this.endPoint){const i=this.context.coordinateConversion.pixelToData({x:this.startPoint[0],y:this.startPoint[1]}),n=this.context.coordinateConversion.pixelToData({x:this.endPoint[0],y:this.endPoint[1]});i&&n&&this.context.addDrawing({id:`ray-${Date.now()}`,type:"ray",points:[i,n],paneIndex:i.paneIndex||0,style:{color:Gt,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 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:Gt,lineWidth:1},z:100}),this.dashLine=new D.graphic.Line({shape:{x1:0,y1:0,x2:0,y2:0},style:{stroke:Gt,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:Gt,lineWidth:1},z:101}),this.endCircle=new D.graphic.Circle({shape:{cx:0,cy:0,r:4},style:{fill:"#fff",stroke:Gt,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,n]=this.endPoint;this.line.setShape({x1:t,y1:e,x2:i,y2:n}),this.startCircle.setShape({cx:t,cy:e}),this.endCircle.setShape({cx:i,cy:n});const[r,s]=this.extendToEdge(t,e,i,n);this.dashLine.setShape({x1:i,y1:n,x2:r,y2:s})}extendToEdge(t,e,i,n){const r=i-t,s=n-e;if(r===0&&s===0)return[i,n];const l=this.chart.getWidth(),a=this.chart.getHeight();let o=1/0;if(r!==0){const p=r>0?(l-t)/r:-t/r;p>0&&(o=Math.min(o,p))}if(s!==0){const p=s>0?(a-e)/s:-e/s;p>0&&(o=Math.min(o,p))}return isFinite(o)||(o=1),[t+o*r,e+o*s]}}var rn=Object.defineProperty,an=(h,t,e)=>t in h?rn(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,ln=(h,t,e)=>(an(h,typeof t!="symbol"?t+"":t,e),e);class xe{constructor(){ln(this,"type","info-line")}render(t){const{drawing:e,pixelPoints:i,isSelected:n}=t,[r,s]=i[0],[l,a]=i[1],o=e.style?.color||"#d1d4dc",p=e.points[0],u=e.points[1],d=u.value-p.value,g=p.value!==0?d/p.value*100:0,c=Math.abs(u.timeIndex-p.timeIndex),y=d>=0?"+":"",f=`${y}${d.toFixed(2)} (${y}${g.toFixed(2)}%) ${c} bars`,x=(r+l)/2,m=(s+a)/2,I=d>=0?"#26a69a":"#ef5350";return{type:"group",children:[{type:"line",name:"line",shape:{x1:r,y1:s,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:I,fontSize:11,fontFamily:"monospace"},z2:11},{type:"circle",name:"point-0",shape:{cx:r,cy:s,r:4},style:{fill:"#fff",stroke:o,lineWidth:1,opacity:n?1:0}},{type:"circle",name:"point-1",shape:{cx:l,cy:a,r:4},style:{fill:"#fff",stroke:o,lineWidth:1,opacity:n?1:0}}]}}}var hn=Object.defineProperty,cn=(h,t,e)=>t in h?hn(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,yt=(h,t,e)=>(cn(h,typeof t!="symbol"?t+"":t,e),e);class dn extends q{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>'}),yt(this,"zr"),yt(this,"state","idle"),yt(this,"startPoint",null),yt(this,"endPoint",null),yt(this,"group",null),yt(this,"line",null),yt(this,"startCircle",null),yt(this,"endCircle",null),yt(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]}),n=this.context.coordinateConversion.pixelToData({x:this.endPoint[0],y:this.endPoint[1]});i&&n&&this.context.addDrawing({id:`info-line-${Date.now()}`,type:"info-line",points:[i,n],paneIndex:i.paneIndex||0,style:{color:"#d1d4dc",lineWidth:1}})}this.removeGraphic(),this.context.disableTools()}}),yt(this,"onMouseMove",e=>{this.state==="drawing"&&(this.endPoint=this.getPoint(e),this.updateGraphic())})}onInit(){this.zr=this.chart.getZr(),this.context.registerDrawingRenderer(new xe)}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,n]=this.endPoint;this.line.setShape({x1:t,y1:e,x2:i,y2:n}),this.startCircle.setShape({cx:t,cy:e}),this.endCircle.setShape({cx:i,cy:n})}}var pn=Object.defineProperty,un=(h,t,e)=>t in h?pn(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,gn=(h,t,e)=>(un(h,typeof t!="symbol"?t+"":t,e),e);class me{constructor(){gn(this,"type","extended-line")}render(t){const{drawing:e,pixelPoints:i,isSelected:n,coordSys:r}=t,[s,l]=i[0],[a,o]=i[1],p=e.style?.color||"#d1d4dc",u=a-s,d=o-l;let g=s,c=l,y=a,f=o;if(u!==0||d!==0){const x=r.x,m=r.x+r.width,I=r.y,v=r.y+r.height;[y,f]=this.extendToEdge(s,l,u,d,x,m,I,v),[g,c]=this.extendToEdge(a,o,-u,-d,x,m,I,v)}return{type:"group",children:[{type:"line",name:"line",shape:{x1:g,y1:c,x2:y,y2:f},style:{stroke:p,lineWidth:e.style?.lineWidth||1}},{type:"circle",name:"point-0",shape:{cx:s,cy:l,r:4},style:{fill:"#fff",stroke:p,lineWidth:1,opacity:n?1:0}},{type:"circle",name:"point-1",shape:{cx:a,cy:o,r:4},style:{fill:"#fff",stroke:p,lineWidth:1,opacity:n?1:0}}]}}extendToEdge(t,e,i,n,r,s,l,a){let o=1/0;if(i!==0){const p=i>0?(s-t)/i:(r-t)/i;p>0&&(o=Math.min(o,p))}if(n!==0){const p=n>0?(a-e)/n:(l-e)/n;p>0&&(o=Math.min(o,p))}return isFinite(o)||(o=1),[t+o*i,e+o*n]}}var yn=Object.defineProperty,fn=(h,t,e)=>t in h?yn(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,pt=(h,t,e)=>(fn(h,typeof t!="symbol"?t+"":t,e),e);const At="#d1d4dc";class xn extends q{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>'}),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,"dashLineForward",null),pt(this,"dashLineBackward",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.startPoint&&this.endPoint){const i=this.context.coordinateConversion.pixelToData({x:this.startPoint[0],y:this.startPoint[1]}),n=this.context.coordinateConversion.pixelToData({x:this.endPoint[0],y:this.endPoint[1]});i&&n&&this.context.addDrawing({id:`extended-line-${Date.now()}`,type:"extended-line",points:[i,n],paneIndex:i.paneIndex||0,style:{color:At,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 me)}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:At,lineWidth:1},z:100}),this.dashLineForward=new D.graphic.Line({shape:{x1:0,y1:0,x2:0,y2:0},style:{stroke:At,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:At,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:At,lineWidth:1},z:101}),this.endCircle=new D.graphic.Circle({shape:{cx:0,cy:0,r:4},style:{fill:"#fff",stroke:At,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,n]=this.endPoint;this.line.setShape({x1:t,y1:e,x2:i,y2:n}),this.startCircle.setShape({cx:t,cy:e}),this.endCircle.setShape({cx:i,cy:n});const r=i-t,s=n-e;if(r===0&&s===0)return;const[l,a]=this.extendToEdge(t,e,r,s);this.dashLineForward.setShape({x1:i,y1:n,x2:l,y2:a});const[o,p]=this.extendToEdge(i,n,-r,-s);this.dashLineBackward.setShape({x1:t,y1:e,x2:o,y2:p})}extendToEdge(t,e,i,n){const r=this.chart.getWidth(),s=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(n!==0){const a=n>0?(s-e)/n:-e/n;a>0&&(l=Math.min(l,a))}return isFinite(l)||(l=1),[t+l*i,e+l*n]}}var mn=Object.defineProperty,bn=(h,t,e)=>t in h?mn(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,vn=(h,t,e)=>(bn(h,typeof t!="symbol"?t+"":t,e),e);class be{constructor(){vn(this,"type","trend-angle")}render(t){const{drawing:e,pixelPoints:i,isSelected:n}=t,[r,s]=i[0],[l,a]=i[1],o=e.style?.color||"#d1d4dc",p=l-r,u=a-s,d=Math.atan2(-u,p),g=(d*(180/Math.PI)).toFixed(1),c=Math.min(30,Math.sqrt(p*p+u*u)*.3),y=r+Math.max(Math.abs(p),c+20),f=0,x=-d;return{type:"group",children:[{type:"line",name:"line",shape:{x1:r,y1:s,x2:l,y2:a},style:{stroke:o,lineWidth:e.style?.lineWidth||1}},{type:"line",shape:{x1:r,y1:s,x2:y,y2:s},style:{stroke:o,lineWidth:1,opacity:.4,lineDash:[4,4]}},{type:"arc",shape:{cx:r,cy:s,r:c,startAngle:Math.min(f,x),endAngle:Math.max(f,x)},style:{stroke:o,lineWidth:1.5,fill:"none"}},{type:"text",x:r+c+6,y:s+(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:s,r:4},style:{fill:"#fff",stroke:o,lineWidth:1,opacity:n?1:0}},{type:"circle",name:"point-1",shape:{cx:l,cy:a,r:4},style:{fill:"#fff",stroke:o,lineWidth:1,opacity:n?1:0}}]}}}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,ct=(h,t,e)=>(Cn(h,typeof t!="symbol"?t+"":t,e),e);const wt="#d1d4dc";class Pn extends q{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>'}),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,"hRefLine",null),ct(this,"arc",null),ct(this,"angleText",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]}),n=this.context.coordinateConversion.pixelToData({x:this.endPoint[0],y:this.endPoint[1]});i&&n&&this.context.addDrawing({id:`trend-angle-${Date.now()}`,type:"trend-angle",points:[i,n],paneIndex:i.paneIndex||0,style:{color:wt,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 be)}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,n]=this.endPoint;this.line.setShape({x1:t,y1:e,x2:i,y2:n}),this.startCircle.setShape({cx:t,cy:e}),this.endCircle.setShape({cx:i,cy:n});const r=i-t,s=n-e,l=Math.max(Math.abs(r),40);this.hRefLine.setShape({x1:t,y1:e,x2:t+l,y2:e});const a=Math.atan2(-s,r)*(180/Math.PI),o=Math.min(25,Math.sqrt(r*r+s*s)*.3),p=Math.atan2(s,r),u=Math.min(0,p),d=Math.max(0,p);this.arc.setShape({cx:t,cy:e,r:o,startAngle:u,endAngle:d}),this.angleText.setStyle({text:`${a.toFixed(1)}\xB0`}),this.angleText.x=t+o+6,this.angleText.y=e+(s<0?-14:2),this.angleText.markRedraw()}}var kn=Object.defineProperty,Dn=(h,t,e)=>t in h?kn(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);class ve{constructor(){Mn(this,"type","horizontal-line")}render(t){const{drawing:e,pixelPoints:i,isSelected:n,coordSys:r}=t,[s,l]=i[0],a=e.style?.color||"#d1d4dc",o=r.x,p=r.x+r.width;return{type:"group",children:[{type:"line",name:"line",shape:{x1:o,y1:l,x2:p,y2:l},style:{stroke:a,lineWidth:e.style?.lineWidth||1}},{type:"rect",shape:{x:p-70,y:l-10,width:65,height:18,r:2},style:{fill:a,opacity:.9},z2:10},{type:"text",x:p-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:s,cy:l,r:4},style:{fill:"#fff",stroke:a,lineWidth:1,opacity:n?1:0}}]}}}var In=Object.defineProperty,An=(h,t,e)=>t in h?In(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,we=(h,t,e)=>(An(h,typeof t!="symbol"?t+"":t,e),e);class _n extends q{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>'}),we(this,"zr"),we(this,"onClick",e=>{const i=this.getPoint(e);if(!i)return;const n=this.context.coordinateConversion.pixelToData({x:i[0],y:i[1]});n&&this.context.addDrawing({id:`hline-${Date.now()}`,type:"horizontal-line",points:[n],paneIndex:n.paneIndex||0,style:{color:"#d1d4dc",lineWidth:1}}),this.context.disableTools()})}onInit(){this.zr=this.chart.getZr(),this.context.registerDrawingRenderer(new ve)}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 Sn=Object.defineProperty,zn=(h,t,e)=>t in h?Sn(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,$n=(h,t,e)=>(zn(h,typeof t!="symbol"?t+"":t,e),e);class Ce{constructor(){$n(this,"type","horizontal-ray")}render(t){const{drawing:e,pixelPoints:i,isSelected:n,coordSys:r}=t,[s,l]=i[0],a=e.style?.color||"#d1d4dc",o=r.x+r.width;return{type:"group",children:[{type:"line",name:"line",shape:{x1:s,y1:l,x2:o,y2:l},style:{stroke:a,lineWidth:e.style?.lineWidth||1}},{type:"circle",name:"point-0",shape:{cx:s,cy:l,r:4},style:{fill:"#fff",stroke:a,lineWidth:1,opacity:n?1:0}}]}}}var Gn=Object.defineProperty,En=(h,t,e)=>t in h?Gn(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,Pe=(h,t,e)=>(En(h,typeof t!="symbol"?t+"":t,e),e);class Ln extends q{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>'}),Pe(this,"zr"),Pe(this,"onClick",e=>{const i=this.getPoint(e);if(!i)return;const n=this.context.coordinateConversion.pixelToData({x:i[0],y:i[1]});n&&this.context.addDrawing({id:`hray-${Date.now()}`,type:"horizontal-ray",points:[n],paneIndex:n.paneIndex||0,style:{color:"#d1d4dc",lineWidth:1}}),this.context.disableTools()})}onInit(){this.zr=this.chart.getZr(),this.context.registerDrawingRenderer(new Ce)}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 Tn=Object.defineProperty,Wn=(h,t,e)=>t in h?Tn(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,Fn=(h,t,e)=>(Wn(h,typeof t!="symbol"?t+"":t,e),e);class ke{constructor(){Fn(this,"type","vertical-line")}render(t){const{drawing:e,pixelPoints:i,isSelected:n,coordSys:r}=t,[s,l]=i[0],a=e.style?.color||"#d1d4dc",o=r.y,p=r.y+r.height;return{type:"group",children:[{type:"line",name:"line",shape:{x1:s,y1:o,x2:s,y2:p},style:{stroke:a,lineWidth:e.style?.lineWidth||1}},{type:"circle",name:"point-0",shape:{cx:s,cy:l,r:4},style:{fill:"#fff",stroke:a,lineWidth:1,opacity:n?1:0}}]}}}var Zn=Object.defineProperty,Nn=(h,t,e)=>t in h?Zn(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,De=(h,t,e)=>(Nn(h,typeof t!="symbol"?t+"":t,e),e);class Rn extends q{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>'}),De(this,"zr"),De(this,"onClick",e=>{const i=this.getPoint(e);if(!i)return;const n=this.context.coordinateConversion.pixelToData({x:i[0],y:i[1]});n&&this.context.addDrawing({id:`vline-${Date.now()}`,type:"vertical-line",points:[n],paneIndex:n.paneIndex||0,style:{color:"#d1d4dc",lineWidth:1}}),this.context.disableTools()})}onInit(){this.zr=this.chart.getZr(),this.context.registerDrawingRenderer(new ke)}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 On=Object.defineProperty,Hn=(h,t,e)=>t in h?On(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,Bn=(h,t,e)=>(Hn(h,typeof t!="symbol"?t+"":t,e),e);class Me{constructor(){Bn(this,"type","cross-line")}render(t){const{drawing:e,pixelPoints:i,isSelected:n,coordSys:r}=t,[s,l]=i[0],a=e.style?.color||"#d1d4dc",o=r.x,p=r.x+r.width,u=r.y,d=r.y+r.height;return{type:"group",children:[{type:"line",name:"line-h",shape:{x1:o,y1:l,x2:p,y2:l},style:{stroke:a,lineWidth:e.style?.lineWidth||1}},{type:"line",name:"line-v",shape:{x1:s,y1:u,x2:s,y2:d},style:{stroke:a,lineWidth:e.style?.lineWidth||1}},{type:"circle",name:"point-0",shape:{cx:s,cy:l,r:4},style:{fill:"#fff",stroke:a,lineWidth:1,opacity:n?1:0}}]}}}var jn=Object.defineProperty,Yn=(h,t,e)=>t in h?jn(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,Ie=(h,t,e)=>(Yn(h,typeof t!="symbol"?t+"":t,e),e);class Vn extends q{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>'}),Ie(this,"zr"),Ie(this,"onClick",e=>{const i=this.getPoint(e);if(!i)return;const n=this.context.coordinateConversion.pixelToData({x:i[0],y:i[1]});n&&this.context.addDrawing({id:`crossline-${Date.now()}`,type:"cross-line",points:[n],paneIndex:n.paneIndex||0,style:{color:"#d1d4dc",lineWidth:1}}),this.context.disableTools()})}onInit(){this.zr=this.chart.getZr(),this.context.registerDrawingRenderer(new Me)}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 Xn=Object.defineProperty,qn=(h,t,e)=>t in h?Xn(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,Un=(h,t,e)=>(qn(h,typeof t!="symbol"?t+"":t,e),e);const ee=[0,.236,.382,.5,.618,.786,1],Bt=["#787b86","#f44336","#ff9800","#4caf50","#2196f3","#00bcd4","#787b86"];class Ae{constructor(){Un(this,"type","fibonacci")}render(t){const{drawing:e,pixelPoints:i,isSelected:n}=t,[r,s]=i[0],[l,a]=i[1],o=e.style?.color||"#3b82f6",p=Math.min(r,l),u=Math.max(r,l),d=u-p,g=a-s,c=e.points[0].value,y=e.points[1].value,f=y-c,x=[],m=[];return ee.forEach((I,v)=>{const k=a-g*I,A=Bt[v%Bt.length];m.push({type:"line",shape:{x1:p,y1:k,x2:u,y2:k},style:{stroke:A,lineWidth:1},silent:!0});const w=y-f*I;if(m.push({type:"text",style:{text:`${I} (${w.toFixed(2)})`,x:p+5,y:k-10,fill:A,fontSize:10},silent:!0}),v<ee.length-1){const b=ee[v+1],C=a-g*b,_=Math.abs(C-k),z=Math.min(k,C);x.push({type:"rect",name:"line",shape:{x:p,y:z,width:d,height:_},style:{fill:Bt[(v+1)%Bt.length],opacity:.1}})}}),{type:"group",children:[...x,...m,{type:"line",name:"line",shape:{x1:r,y1:s,x2:l,y2:a},style:{stroke:"#999",lineWidth:1,lineDash:[4,4]}},{type:"circle",name:"point-0",shape:{cx:r,cy:s,r:4},style:{fill:"#fff",stroke:o,lineWidth:1,opacity:n?1:0},z:100},{type:"circle",name:"point-1",shape:{cx:l,cy:a,r:4},style:{fill:"#fff",stroke:o,lineWidth:1,opacity:n?1:0},z:100}]}}}var Kn=Object.defineProperty,Jn=(h,t,e)=>t in h?Kn(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,mt=(h,t,e)=>(Jn(h,typeof t!="symbol"?t+"":t,e),e);class Qn extends q{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>'}),mt(this,"startPoint",null),mt(this,"endPoint",null),mt(this,"state","idle"),mt(this,"graphicGroup",null),mt(this,"levels",[0,.236,.382,.5,.618,.786,1]),mt(this,"colors",["#787b86","#f44336","#ff9800","#4caf50","#2196f3","#00bcd4","#787b86"]),mt(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())}),mt(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 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],n=this.endPoint[1],r=new D.graphic.Line({shape:{x1:t,y1:e,x2:i,y2:n},style:{stroke:"#999",lineWidth:1,lineDash:[4,4]},silent:!0});this.graphicGroup.add(r);const s=Math.min(t,i),l=Math.max(t,i),a=l-s,o=n-e;this.levels.forEach((p,u)=>{const d=n-o*p,g=this.colors[u%this.colors.length],c=new D.graphic.Line({shape:{x1:s,y1:d,x2:l,y2:d},style:{stroke:g,lineWidth:1},silent:!0});if(this.graphicGroup.add(c),u<this.levels.length-1){const y=this.levels[u+1],f=n-o*y,x=Math.abs(f-d),m=Math.min(d,f),I=new D.graphic.Rect({shape:{x:s,y:m,width:a,height:x},style:{fill:this.colors[(u+1)%this.colors.length],opacity:.1},silent:!0});this.graphicGroup.add(I)}})}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 ts=Object.defineProperty,es=(h,t,e)=>t in h?ts(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,is=(h,t,e)=>(es(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 _e{constructor(){is(this,"type","fibonacci_channel")}render(t){const{drawing:e,pixelPoints:i,isSelected:n}=t,[r,s]=i[0],[l,a]=i[1],[o,p]=i[2],u=e.style?.color||"#3b82f6",d=l-r,g=a-s,c=Math.sqrt(d*d+g*g);if(c===0)return;const y=-g/c,f=d/c,x=(o-r)*y+(p-s)*f,m=[],I=[];return jt.forEach((v,k)=>{const A=y*x*v,w=f*x*v,b=r+A,C=s+w,_=l+A,z=a+w;if(I.push({lx1:b,ly1:C,lx2:_,ly2:z}),k<jt.length-1){const S=jt[k+1],$=y*x*S,L=f*x*S;m.push({type:"polygon",name:"line",shape:{points:[[b,C],[_,z],[l+$,a+L],[r+$,s+L]]},style:{fill:Yt[(k+1)%Yt.length],opacity:.1}})}}),I.forEach((v,k)=>{const A=Yt[k%Yt.length];m.push({type:"line",shape:{x1:v.lx1,y1:v.ly1,x2:v.lx2,y2:v.ly2},style:{stroke:A,lineWidth:1},silent:!0}),m.push({type:"text",style:{text:`${jt[k]}`,x:v.lx2+5,y:v.ly2-5,fill:A,fontSize:10},silent:!0})}),m.push({type:"line",name:"line",shape:{x1:r,y1:s,x2:l,y2:a},style:{stroke:"#999",lineWidth:1,lineDash:[4,4]}}),m.push({type:"circle",name:"point-0",shape:{cx:r,cy:s,r:4},style:{fill:"#fff",stroke:u,lineWidth:1,opacity:n?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:n?1:0},z:100}),m.push({type:"circle",name:"point-2",shape:{cx:o,cy:p,r:4},style:{fill:"#fff",stroke:u,lineWidth:1,opacity:n?1:0},z:100}),{type:"group",children:m}}}var ns=Object.defineProperty,ss=(h,t,e)=>t in h?ns(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,ft=(h,t,e)=>(ss(h,typeof t!="symbol"?t+"":t,e),e);class os extends q{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 _e)}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],n=this.endPoint[1];if(this.graphicGroup.add(new D.graphic.Line({shape:{x1:t,y1:e,x2:i,y2:n},style:{stroke:"#787b86",lineWidth:2},silent:!0})),this.widthPoint&&this.state!=="drawing-baseline"){const r=this.widthPoint,s=i-t,l=n-e,a=Math.sqrt(s*s+l*l);if(a===0)return;const o=-l/a,p=s/a,u=(r[0]-t)*o+(r[1]-e)*p;this.levels.forEach((d,g)=>{const c=o*u*d,y=p*u*d,f=t+c,x=e+y,m=i+c,I=n+y,v=this.colors[g%this.colors.length];if(this.graphicGroup.add(new D.graphic.Line({shape:{x1:f,y1:x,x2:m,y2:I},style:{stroke:v,lineWidth:1},silent:!0})),g<this.levels.length-1){const k=this.levels[g+1],A=o*u*k,w=p*u*k,b=t+A,C=e+w,_=i+A,z=n+w;this.graphicGroup.add(new D.graphic.Polygon({shape:{points:[[f,x],[m,I],[_,z],[b,C]]},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 n=t.paneIndex||0;this.context.addDrawing({id:`fib-channel-${Date.now()}`,type:"fibonacci_channel",points:[t,e,i],paneIndex:n,style:{color:"#3b82f6",lineWidth:1}})}}}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,ls=(h,t,e)=>(as(h,typeof t!="symbol"?t+"":t,e),e);const ie=[0,.236,.382,.5,.618,.786,1],bt=["#787b86","#f44336","#ff9800","#4caf50","#2196f3","#00bcd4","#787b86"];class Se{constructor(){ls(this,"type","fib_speed_resistance_fan")}render(t){const{drawing:e,pixelPoints:i,isSelected:n}=t,[r,s]=i[0],[l,a]=i[1],o=e.style?.color||"#3b82f6",p=l-r,u=a-s,d=[],g=[],c=[];for(const y of ie)g.push([r+p,s+u*y]),c.push([r+p*y,s+u]);for(let y=0;y<g.length-1;y++)d.push({type:"polygon",name:"line",shape:{points:[[r,s],g[y],g[y+1]]},style:{fill:bt[(y+1)%bt.length],opacity:.06}});for(let y=0;y<c.length-1;y++)d.push({type:"polygon",name:"line",shape:{points:[[r,s],c[y],c[y+1]]},style:{fill:bt[(y+1)%bt.length],opacity:.06}});return ie.forEach((y,f)=>{const[x,m]=g[f],I=bt[f%bt.length];d.push({type:"line",shape:{x1:r,y1:s,x2:x,y2:m},style:{stroke:I,lineWidth:1},silent:!0}),d.push({type:"text",style:{text:`${y}`,x:x+3,y:m-2,fill:I,fontSize:9},silent:!0})}),ie.forEach((y,f)=>{const[x,m]=c[f],I=bt[f%bt.length];d.push({type:"line",shape:{x1:r,y1:s,x2:x,y2:m},style:{stroke:I,lineWidth:1},silent:!0}),d.push({type:"text",style:{text:`${y}`,x:x-2,y:m+8,fill:I,fontSize:9},silent:!0})}),d.push({type:"line",name:"line",shape:{x1:l,y1:s,x2:l,y2:a},style:{stroke:"#555",lineWidth:1,lineDash:[3,3]}}),d.push({type:"line",name:"line",shape:{x1:r,y1:a,x2:l,y2:a},style:{stroke:"#555",lineWidth:1,lineDash:[3,3]}}),d.push({type:"line",name:"line",shape:{x1:r,y1:s,x2:l,y2:a},style:{stroke:"#999",lineWidth:1,lineDash:[4,4]}}),d.push({type:"circle",name:"point-0",shape:{cx:r,cy:s,r:4},style:{fill:"#fff",stroke:o,lineWidth:1,opacity:n?1:0},z:100}),d.push({type:"circle",name:"point-1",shape:{cx:l,cy:a,r:4},style:{fill:"#fff",stroke:o,lineWidth:1,opacity:n?1:0},z:100}),{type:"group",children:d}}}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,_t=(h,t,e)=>(cs(h,typeof t!="symbol"?t+"":t,e),e);const Ct=[0,.236,.382,.5,.618,.786,1],St=["#787b86","#f44336","#ff9800","#4caf50","#2196f3","#00bcd4","#787b86"];class ds extends q{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>'}),_t(this,"startPoint",null),_t(this,"endPoint",null),_t(this,"state","idle"),_t(this,"graphicGroup",null),_t(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())}),_t(this,"onMouseMove",e=>{this.state==="drawing"&&(this.endPoint=this.getPoint(e),this.updateGraphic())})}onInit(){this.context.registerDrawingRenderer(new Se)}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],n=this.endPoint[1],r=i-t,s=n-e;Ct.forEach((l,a)=>{const o=St[a%St.length];this.graphicGroup.add(new D.graphic.Line({shape:{x1:t,y1:e,x2:t+r,y2:e+s*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+s},style:{stroke:o,lineWidth:1},silent:!0}))});for(let l=0;l<Ct.length-1;l++){const a=[t+r,e+s*Ct[l]],o=[t+r,e+s*Ct[l+1]];this.graphicGroup.add(new D.graphic.Polygon({shape:{points:[[t,e],a,o]},style:{fill:St[(l+1)%St.length],opacity:.06},silent:!0}))}for(let l=0;l<Ct.length-1;l++){const a=[t+r*Ct[l],e+s],o=[t+r*Ct[l+1],e+s];this.graphicGroup.add(new D.graphic.Polygon({shape:{points:[[t,e],a,o]},style:{fill:St[(l+1)%St.length],opacity:.06},silent:!0}))}this.graphicGroup.add(new D.graphic.Line({shape:{x1:i,y1:e,x2:i,y2:n},style:{stroke:"#555",lineWidth:1,lineDash:[3,3]},silent:!0})),this.graphicGroup.add(new D.graphic.Line({shape:{x1:t,y1:n,x2:i,y2:n},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:n},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 ps=Object.defineProperty,us=(h,t,e)=>t in h?ps(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,gs=(h,t,e)=>(us(h,typeof t!="symbol"?t+"":t,e),e);const ze=[0,.236,.382,.5,.618,.786,1,1.272,1.618,2,2.618],$e=["#787b86","#f44336","#ff9800","#4caf50","#2196f3","#00bcd4","#787b86","#e91e63","#9c27b0","#673ab7","#3f51b5"];class Ge{constructor(){gs(this,"type","fib_trend_extension")}render(t){const{drawing:e,pixelPoints:i,isSelected:n,api:r}=t,s=e.style?.color||"#3b82f6";if(i.length<3)return;const[l,a]=i[0],[o,p]=i[1],[u,d]=i[2],g=e.points,c=g[1].value-g[0].value,y=Math.min(l,o,u),f=Math.max(l,o,u),x=(f-y)*.5,m=y,I=f+x,v=[],k=[];for(let b=0;b<ze.length;b++){const C=ze[b],_=g[2].value+c*C;r.coord([g[2].timeIndex+t.drawing.points[2].timeIndex-g[2].timeIndex,_]);const z=d+(p-a)*C;k.push({level:C,y:z,price:_,color:$e[b%$e.length]})}for(let b=0;b<k.length-1;b++){const C=k[b],_=k[b+1],z=Math.min(C.y,_.y),S=Math.abs(_.y-C.y);v.push({type:"rect",name:"line",shape:{x:m,y:z,width:I-m,height:S},style:{fill:_.color,opacity:.06}})}for(const b of k)v.push({type:"line",shape:{x1:m,y1:b.y,x2:I,y2:b.y},style:{stroke:b.color,lineWidth:1},silent:!0}),v.push({type:"text",style:{text:`${b.level} (${b.price.toFixed(2)})`,x:I+4,y:b.y-6,fill:b.color,fontSize:9},silent:!0});v.push({type:"line",name:"line",shape:{x1:l,y1:a,x2:o,y2:p},style:{stroke:"#2196f3",lineWidth:1.5,lineDash:[5,4]}}),v.push({type:"line",name:"line",shape:{x1:o,y1:p,x2:u,y2:d},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:s,lineWidth:1,opacity:n?1:0},z:100}),v.push({type:"circle",name:"point-1",shape:{cx:o,cy:p,r:4},style:{fill:"#fff",stroke:s,lineWidth:1,opacity:n?1:0},z:100}),v.push({type:"circle",name:"point-2",shape:{cx:u,cy:d,r:4},style:{fill:"#fff",stroke:s,lineWidth:1,opacity:n?1:0},z:100});const A=["1","2","3"],w=[i[0],i[1],i[2]];for(let b=0;b<3;b++){const[C,_]=w[b],z=(b===0||_<=w[b-1][1])&&(b===2||_<=w[b+1]?.[1]);v.push({type:"text",style:{text:A[b],x:C,y:z?_-14:_+16,fill:"#e2e8f0",fontSize:12,fontWeight:"bold",align:"center",verticalAlign:"middle"},silent:!0})}return{type:"group",children:v}}}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,Et=(h,t,e)=>(fs(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 xs extends q{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>'}),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-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())}),Et(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 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 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,n]=this.points[1];if(this.graphicGroup.add(new D.graphic.Line({shape:{x1:t,y1:e,x2:i,y2:n},style:{stroke:"#2196f3",lineWidth:1.5,lineDash:[5,4]},silent:!0})),this.points.length>=3){const[r,s]=this.points[2];this.graphicGroup.add(new D.graphic.Line({shape:{x1:i,y1:n,x2:r,y2:s},style:{stroke:"#ff9800",lineWidth:1.5,lineDash:[5,4]},silent:!0}));const l=n-e,a=Math.min(t,i,r),o=Math.max(t,i,r),p=(o-a)*.5,u=a,d=o+p;for(let g=0;g<Vt.length;g++){const c=Vt[g],y=s+l*c,f=Xt[g%Xt.length];if(this.graphicGroup.add(new D.graphic.Line({shape:{x1:u,y1:y,x2:d,y2:y},style:{stroke:f,lineWidth:1},silent:!0})),this.graphicGroup.add(new D.graphic.Text({style:{text:`${c}`,x:d+4,y:y-6,fill:f,fontSize:9},silent:!0})),g<Vt.length-1){const x=s+l*Vt[g+1],m=Math.min(y,x),I=Math.abs(x-y);this.graphicGroup.add(new D.graphic.Rect({shape:{x:u,y:m,width:d-u,height:I},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 ms=Object.defineProperty,bs=(h,t,e)=>t in h?ms(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,vs=(h,t,e)=>(bs(h,typeof t!="symbol"?t+"":t,e),e);const Ee=["X","A","B","C","D"],Le=["#2196f3","#ff9800","#4caf50","#f44336"],ws="rgba(33, 150, 243, 0.08)",Cs="rgba(244, 67, 54, 0.08)";class Te{constructor(){vs(this,"type","xabcd_pattern")}render(t){const{drawing:e,pixelPoints:i,isSelected:n}=t,r=e.style?.color||"#3b82f6";if(i.length<2)return;const s=[];i.length>=3&&s.push({type:"polygon",name:"line",shape:{points:i.slice(0,3).map(([a,o])=>[a,o])},style:{fill:ws,opacity:1}}),i.length>=5&&s.push({type:"polygon",name:"line",shape:{points:i.slice(2,5).map(([a,o])=>[a,o])},style:{fill:Cs,opacity:1}});for(let a=0;a<i.length-1;a++){const[o,p]=i[a],[u,d]=i[a+1],g=Le[a%Le.length];s.push({type:"line",name:"line",shape:{x1:o,y1:p,x2:u,y2:d},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[p,u]=i[a],[d,g]=i[o];s.push({type:"line",shape:{x1:p,y1:u,x2:d,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 p=(o/a).toFixed(3),u=(i[1][0]+i[2][0])/2,d=(i[1][1]+i[2][1])/2;s.push({type:"text",style:{text:p,x:u+8,y:d,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 p=(o/a).toFixed(3),u=(i[2][0]+i[3][0])/2,d=(i[2][1]+i[3][1])/2;s.push({type:"text",style:{text:p,x:u+8,y:d,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 d=(o/a).toFixed(3),g=(i[3][0]+i[4][0])/2,c=(i[3][1]+i[4][1])/2;s.push({type:"text",style:{text:d,x:g+8,y:c,fill:"#f44336",fontSize:10},silent:!0})}const p=Math.abs(e.points[1].value-e.points[0].value),u=Math.abs(e.points[4].value-e.points[1].value);if(p!==0){const d=(u/p).toFixed(3),[g,c]=i[4];s.push({type:"text",style:{text:`AD/XA: ${d}`,x:g+10,y:c+14,fill:"#aaa",fontSize:9},silent:!0})}}for(let a=0;a<i.length&&a<Ee.length;a++){const[o,p]=i[a],u=(a===0||p<=i[a-1][1])&&(a===i.length-1||p<=i[a+1]?.[1])?p-14:p+16;s.push({type:"text",style:{text:Ee[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,p]=i[a];s.push({type:"circle",name:`point-${a}`,shape:{cx:o,cy:p,r:4},style:{fill:"#fff",stroke:r,lineWidth:1,opacity:n?1:0},z:100})}return{type:"group",children:s}}}var Ps=Object.defineProperty,ks=(h,t,e)=>t in h?Ps(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,Lt=(h,t,e)=>(ks(h,typeof t!="symbol"?t+"":t,e),e);const We=["X","A","B","C","D"],Fe=["#2196f3","#ff9800","#4caf50","#f44336"],Ds=5;class Ms extends q{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>'}),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",this.points=[i,[...i]],this.initGraphic(),this.updateGraphic()):this.state==="drawing"&&(this.points[this.points.length-1]=i,this.points.length>=Ds?(this.state="finished",this.updateGraphic(),this.saveDrawing(),this.removeGraphic(),this.context.disableTools()):(this.points.push([...i]),this.updateGraphic()))}),Lt(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 Te)}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[n,r]=t[i],[s,l]=t[i+1];this.graphicGroup.add(new D.graphic.Line({shape:{x1:n,y1:r,x2:s,y2:l},style:{stroke:Fe[i%Fe.length],lineWidth:2},silent:!0}))}const e=[[0,2],[1,3],[2,4]];for(const[i,n]of e)if(i<t.length&&n<t.length){const[r,s]=t[i],[l,a]=t[n];this.graphicGroup.add(new D.graphic.Line({shape:{x1:r,y1:s,x2:l,y2:a},style:{stroke:"#555",lineWidth:1,lineDash:[4,4]},silent:!0}))}for(let i=0;i<t.length&&i<We.length;i++){const[n,r]=t[i],s=(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:We[i],x:n,y:s,fill:"#e2e8f0",fontSize:12,fontWeight:"bold",align:"center",verticalAlign:"middle"},silent:!0}))}for(let i=0;i<t.length;i++){const[n,r]=t[i];this.graphicGroup.add(new D.graphic.Circle({shape:{cx:n,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 Is=Object.defineProperty,As=(h,t,e)=>t in h?Is(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,_s=(h,t,e)=>(As(h,typeof t!="symbol"?t+"":t,e),e);const Ze=["A","B","C","D"],Ne=["#2196f3","#ff9800","#4caf50"];class Re{constructor(){_s(this,"type","abcd_pattern")}render(t){const{drawing:e,pixelPoints:i,isSelected:n}=t,r=e.style?.color||"#3b82f6";if(i.length<2)return;const s=[];i.length>=3&&s.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&&s.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],[p,u]=i[l+1];s.push({type:"line",name:"line",shape:{x1:a,y1:o,x2:p,y2:u},style:{stroke:Ne[l%Ne.length],lineWidth:e.style?.lineWidth||2}})}if(i.length>=3&&s.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&&s.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),p=(i[1][0]+i[2][0])/2,u=(i[1][1]+i[2][1])/2;s.push({type:"text",style:{text:o,x:p+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),p=(i[2][0]+i[3][0])/2,u=(i[2][1]+i[3][1])/2;s.push({type:"text",style:{text:o,x:p+8,y:u,fill:"#4caf50",fontSize:10},silent:!0})}}for(let l=0;l<i.length&&l<Ze.length;l++){const[a,o]=i[l],p=(l===0||o<=i[l-1][1])&&(l===i.length-1||o<=i[l+1]?.[1]);s.push({type:"text",style:{text:Ze[l],x:a,y:p?o-14:o+16,fill:"#e2e8f0",fontSize:12,fontWeight:"bold",align:"center",verticalAlign:"middle"},silent:!0})}for(let l=0;l<i.length;l++)s.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:n?1:0},z:100});return{type:"group",children:s}}}var Ss=Object.defineProperty,zs=(h,t,e)=>t in h?Ss(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,Tt=(h,t,e)=>(zs(h,typeof t!="symbol"?t+"":t,e),e);const Oe=["A","B","C","D"],He=["#2196f3","#ff9800","#4caf50"],$s=4;class Gs extends q{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>=$s?(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 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),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:He[e%He.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<Oe.length;e++){const[i,n]=t[e],r=(e===0||n<=t[e-1][1])&&(e===t.length-1||n<=t[e+1]?.[1]);this.graphicGroup.add(new D.graphic.Text({style:{text:Oe[e],x:i,y:r?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:i,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:`abcd-${Date.now()}`,type:"abcd_pattern",points:t,paneIndex:t[0].paneIndex||0,style:{color:"#3b82f6",lineWidth:2}})}}var Es=Object.defineProperty,Ls=(h,t,e)=>t in h?Es(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,Ts=(h,t,e)=>(Ls(h,typeof t!="symbol"?t+"":t,e),e);const Be=["X","A","B","C","D"],je=["#00bcd4","#e91e63","#8bc34a","#ff5722"];class Ye{constructor(){Ts(this,"type","cypher_pattern")}render(t){const{drawing:e,pixelPoints:i,isSelected:n}=t,r=e.style?.color||"#3b82f6";if(i.length<2)return;const s=[];i.length>=3&&s.push({type:"polygon",name:"line",shape:{points:i.slice(0,3).map(([o,p])=>[o,p])},style:{fill:"rgba(0, 188, 212, 0.08)"}}),i.length>=5&&s.push({type:"polygon",name:"line",shape:{points:i.slice(2,5).map(([o,p])=>[o,p])},style:{fill:"rgba(233, 30, 99, 0.08)"}});for(let o=0;o<i.length-1;o++){const[p,u]=i[o],[d,g]=i[o+1];s.push({type:"line",name:"line",shape:{x1:p,y1:u,x2:d,y2:g},style:{stroke:je[o%je.length],lineWidth:e.style?.lineWidth||2}})}const l=[[0,2],[0,3],[1,4]];for(const[o,p]of l)o<i.length&&p<i.length&&s.push({type:"line",shape:{x1:i[o][0],y1:i[o][1],x2:i[p][0],y2:i[p][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),p=Math.abs(a[2].value-a[1].value);if(o!==0){const u=(p/o).toFixed(3);s.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),p=Math.abs(a[3].value-a[0].value);if(o!==0){const u=(p/o).toFixed(3);s.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),p=Math.abs(a[4].value-a[3].value);if(o!==0){const u=(p/o).toFixed(3);s.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<Be.length;o++){const[p,u]=i[o],d=(o===0||u<=i[o-1][1])&&(o===i.length-1||u<=i[o+1]?.[1]);s.push({type:"text",style:{text:Be[o],x:p,y:d?u-14:u+16,fill:"#e2e8f0",fontSize:12,fontWeight:"bold",align:"center",verticalAlign:"middle"},silent:!0})}for(let o=0;o<i.length;o++)s.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:n?1:0},z:100});return{type:"group",children:s}}}var Ws=Object.defineProperty,Fs=(h,t,e)=>t in h?Ws(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,Wt=(h,t,e)=>(Fs(h,typeof t!="symbol"?t+"":t,e),e);const Ve=["X","A","B","C","D"],Xe=["#00bcd4","#e91e63","#8bc34a","#ff5722"],Zs=5;class Ns extends q{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>'}),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>=Zs?(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 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(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:Xe[e%Xe.length],lineWidth:2},silent:!0}));for(let e=0;e<t.length&&e<Ve.length;e++){const[i,n]=t[e],r=(e===0||n<=t[e-1][1])&&(e===t.length-1||n<=t[e+1]?.[1]);this.graphicGroup.add(new D.graphic.Text({style:{text:Ve[e],x:i,y:r?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:i,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:`cypher-${Date.now()}`,type:"cypher_pattern",points:t,paneIndex:t[0].paneIndex||0,style:{color:"#3b82f6",lineWidth:2}})}}var Rs=Object.defineProperty,Os=(h,t,e)=>t in h?Rs(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,Hs=(h,t,e)=>(Os(h,typeof t!="symbol"?t+"":t,e),e);const ne=["","LS","","H","","RS",""];class qe{constructor(){Hs(this,"type","head_and_shoulders")}render(t){const{drawing:e,pixelPoints:i,isSelected:n}=t,r=e.style?.color||"#3b82f6";if(i.length<2)return;const s=[];i.length>=3&&s.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&&s.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&&s.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],[p,u]=i[l+1];s.push({type:"line",name:"line",shape:{x1:a,y1:o,x2:p,y2:u},style:{stroke:"#2196f3",lineWidth:e.style?.lineWidth||2}})}if(i.length>=5){const[l,a]=i[2],[o,p]=i[4],u=o-l,d=p-a,g=.3,c=.3,y=l-u*g,f=a-d*g,x=o+u*c,m=p+d*c;s.push({type:"line",shape:{x1:y,y1:f,x2:x,y2:m},style:{stroke:"#ff9800",lineWidth:2,lineDash:[6,4]},silent:!0}),s.push({type:"text",style:{text:"Neckline",x:(l+o)/2,y:(a+p)/2+14,fill:"#ff9800",fontSize:10,align:"center"},silent:!0})}for(let l=0;l<i.length&&l<ne.length;l++){if(!ne[l])continue;const[a,o]=i[l],p=(l===0||o<=i[l-1][1])&&(l===i.length-1||o<=i[l+1]?.[1]);s.push({type:"text",style:{text:ne[l],x:a,y:p?o-14:o+16,fill:"#e2e8f0",fontSize:12,fontWeight:"bold",align:"center",verticalAlign:"middle"},silent:!0})}for(let l=0;l<i.length;l++)s.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:n?1:0},z:100});return{type:"group",children:s}}}var Bs=Object.defineProperty,js=(h,t,e)=>t in h?Bs(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,Ft=(h,t,e)=>(js(h,typeof t!="symbol"?t+"":t,e),e);const se=["","LS","","H","","RS",""],Ys=7;class Vs extends q{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>'}),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>=Ys?(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 qe)}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],[n,r]=t[4],s=n-e,l=r-i;this.graphicGroup.add(new D.graphic.Line({shape:{x1:e-s*.3,y1:i-l*.3,x2:n+s*.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,n]=t[e],r=(e===0||n<=t[e-1][1])&&(e===t.length-1||n<=t[e+1]?.[1]);se[e]&&this.graphicGroup.add(new D.graphic.Text({style:{text:se[e],x:i,y:r?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:i,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:`hs-${Date.now()}`,type:"head_and_shoulders",points:t,paneIndex:t[0].paneIndex||0,style:{color:"#3b82f6",lineWidth:2}})}}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,Us=(h,t,e)=>(qs(h,typeof t!="symbol"?t+"":t,e),e);const Ue=["1","2","3","4","5"];class Ke{constructor(){Us(this,"type","triangle_pattern")}render(t){const{drawing:e,pixelPoints:i,isSelected:n}=t,r=e.style?.color||"#3b82f6";if(i.length<2)return;const s=[];i.length>=3&&s.push({type:"polygon",name:"line",shape:{points:i.map(([o,p])=>[o,p])},style:{fill:"rgba(156, 39, 176, 0.06)"}});const l=i.filter((o,p)=>p%2===0);if(l.length>=2){for(let o=0;o<l.length-1;o++)s.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],p=l[l.length-2],u=o[0]-p[0],d=o[1]-p[1];if(u!==0){const g=o[0]+u*.5,c=o[1]+d*.5;s.push({type:"line",shape:{x1:o[0],y1:o[1],x2:g,y2:c},style:{stroke:"#f44336",lineWidth:1,lineDash:[4,4]},silent:!0})}}}const a=i.filter((o,p)=>p%2===1);if(a.length>=2){for(let o=0;o<a.length-1;o++)s.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],p=a[a.length-2],u=o[0]-p[0],d=o[1]-p[1];if(u!==0){const g=o[0]+u*.5,c=o[1]+d*.5;s.push({type:"line",shape:{x1:o[0],y1:o[1],x2:g,y2:c},style:{stroke:"#4caf50",lineWidth:1,lineDash:[4,4]},silent:!0})}}}for(let o=0;o<i.length-1;o++)s.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<Ue.length;o++){const[p,u]=i[o],d=o%2===0;s.push({type:"text",style:{text:Ue[o],x:p,y:d?u-14:u+16,fill:"#e2e8f0",fontSize:12,fontWeight:"bold",align:"center",verticalAlign:"middle"},silent:!0})}for(let o=0;o<i.length;o++)s.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:n?1:0},z:100});return{type:"group",children:s}}}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,Zt=(h,t,e)=>(Js(h,typeof t!="symbol"?t+"":t,e),e);const Je=["1","2","3","4","5"],Qs=5;class to extends q{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>=Qs?(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 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},style:{fill:"rgba(156,39,176,0.06)"},silent:!0}));for(let n=0;n<t.length-1;n++)this.graphicGroup.add(new D.graphic.Line({shape:{x1:t[n][0],y1:t[n][1],x2:t[n+1][0],y2:t[n+1][1]},style:{stroke:"#9c27b0",lineWidth:2},silent:!0}));const e=t.filter((n,r)=>r%2===0);if(e.length>=2)for(let n=0;n<e.length-1;n++)this.graphicGroup.add(new D.graphic.Line({shape:{x1:e[n][0],y1:e[n][1],x2:e[n+1][0],y2:e[n+1][1]},style:{stroke:"#f44336",lineWidth:1,lineDash:[4,4]},silent:!0}));const i=t.filter((n,r)=>r%2===1);if(i.length>=2)for(let n=0;n<i.length-1;n++)this.graphicGroup.add(new D.graphic.Line({shape:{x1:i[n][0],y1:i[n][1],x2:i[n+1][0],y2:i[n+1][1]},style:{stroke:"#4caf50",lineWidth:1,lineDash:[4,4]},silent:!0}));for(let n=0;n<t.length&&n<Je.length;n++){const[r,s]=t[n],l=n%2===0;this.graphicGroup.add(new D.graphic.Text({style:{text:Je[n],x:r,y:l?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:r,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:`triangle-${Date.now()}`,type:"triangle_pattern",points:t,paneIndex:t[0].paneIndex||0,style:{color:"#3b82f6",lineWidth:2}})}}var eo=Object.defineProperty,io=(h,t,e)=>t in h?eo(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,no=(h,t,e)=>(io(h,typeof t!="symbol"?t+"":t,e),e);const oe=["0","D1","C1","D2","C2","D3",""],Qe=["#2196f3","#ff9800","#4caf50","#f44336","#00bcd4","#e91e63"];class ti{constructor(){no(this,"type","three_drives_pattern")}render(t){const{drawing:e,pixelPoints:i,isSelected:n}=t,r=e.style?.color||"#3b82f6";if(i.length<2)return;const s=[];i.length>=3&&s.push({type:"polygon",name:"line",shape:{points:i.slice(0,3).map(([o,p])=>[o,p])},style:{fill:"rgba(33, 150, 243, 0.06)"}}),i.length>=5&&s.push({type:"polygon",name:"line",shape:{points:i.slice(2,5).map(([o,p])=>[o,p])},style:{fill:"rgba(76, 175, 80, 0.06)"}}),i.length>=7&&s.push({type:"polygon",name:"line",shape:{points:i.slice(4,7).map(([o,p])=>[o,p])},style:{fill:"rgba(0, 188, 212, 0.06)"}});for(let o=0;o<i.length-1;o++){const[p,u]=i[o],[d,g]=i[o+1];s.push({type:"line",name:"line",shape:{x1:p,y1:u,x2:d,y2:g},style:{stroke:Qe[o%Qe.length],lineWidth:e.style?.lineWidth||2}})}const l=[[1,3],[3,5],[2,4]];for(const[o,p]of l)o<i.length&&p<i.length&&s.push({type:"line",shape:{x1:i[o][0],y1:i[o][1],x2:i[p][0],y2:i[p][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),p=Math.abs(a[3].value-a[2].value);if(o!==0){const u=(p/o).toFixed(3),d=(i[2][0]+i[3][0])/2,g=(i[2][1]+i[3][1])/2;s.push({type:"text",style:{text:`D2/D1: ${u}`,x:d+10,y:g,fill:"#4caf50",fontSize:9},silent:!0})}}if(a.length>=6){const o=Math.abs(a[3].value-a[2].value),p=Math.abs(a[5].value-a[4].value);if(o!==0){const u=(p/o).toFixed(3),d=(i[4][0]+i[5][0])/2,g=(i[4][1]+i[5][1])/2;s.push({type:"text",style:{text:`D3/D2: ${u}`,x:d+10,y:g,fill:"#00bcd4",fontSize:9},silent:!0})}}if(a.length>=3){const o=Math.abs(a[1].value-a[0].value),p=Math.abs(a[2].value-a[1].value);if(o!==0){const u=(p/o).toFixed(3),d=(i[1][0]+i[2][0])/2,g=(i[1][1]+i[2][1])/2;s.push({type:"text",style:{text:u,x:d+8,y:g,fill:"#ff9800",fontSize:10},silent:!0})}}for(let o=0;o<i.length&&o<oe.length;o++){if(!oe[o])continue;const[p,u]=i[o],d=(o===0||u<=i[o-1][1])&&(o===i.length-1||u<=i[o+1]?.[1]);s.push({type:"text",style:{text:oe[o],x:p,y:d?u-14:u+16,fill:"#e2e8f0",fontSize:11,fontWeight:"bold",align:"center",verticalAlign:"middle"},silent:!0})}for(let o=0;o<i.length;o++)s.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:n?1:0},z:100});return{type:"group",children:s}}}var so=Object.defineProperty,oo=(h,t,e)=>t in h?so(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,Nt=(h,t,e)=>(oo(h,typeof t!="symbol"?t+"":t,e),e);const re=["0","D1","C1","D2","C2","D3",""],ei=["#2196f3","#ff9800","#4caf50","#f44336","#00bcd4","#e91e63"],ro=7;class ao extends q{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>'}),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>=ro?(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 ti)}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:ei[i%ei.length],lineWidth:2},silent:!0}));const e=[[1,3],[3,5],[2,4]];for(const[i,n]of e)i<t.length&&n<t.length&&this.graphicGroup.add(new D.graphic.Line({shape:{x1:t[i][0],y1:t[i][1],x2:t[n][0],y2:t[n][1]},style:{stroke:"#555",lineWidth:1,lineDash:[4,4]},silent:!0}));for(let i=0;i<t.length&&i<re.length;i++){const[n,r]=t[i],s=(i===0||r<=t[i-1][1])&&(i===t.length-1||r<=t[i+1]?.[1]);re[i]&&this.graphicGroup.add(new D.graphic.Text({style:{text:re[i],x:n,y:s?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:n,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 lo=Object.defineProperty,ho=(h,t,e)=>t in h?lo(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,Pt=(h,t,e)=>(ho(h,typeof t!="symbol"?t+"":t,e),e);class co extends q{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
42
|
<div style="width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;">
|
|
42
43
|
${t.icon}
|
|
43
44
|
</div>
|
|
@@ -45,7 +46,7 @@ ${u}`;this.chart.setOption({series:[{id:"__candlestick__",markLine:{data:[{...h,
|
|
|
45
46
|
</div>`:i=`<div style="position: relative; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;">
|
|
46
47
|
<span>${t.name.substring(0,2).toUpperCase()}</span>
|
|
47
48
|
${e}
|
|
48
|
-
</div>`,super({id:t.id||`group-${t.name.toLowerCase().replace(/\s+/g,"-")}`,name:t.name,icon:i}),
|
|
49
|
+
</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",n=>{this.menuElement&&!this.menuElement.contains(n.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 s=r.querySelector("svg");s&&(s.style.width="100%",s.style.height="100%"),i.appendChild(r)}const n=document.createElement("span");n.textContent=e.name||e.id,i.appendChild(n),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
50
|
<div style="width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;">
|
|
50
51
|
${t.icon}
|
|
51
52
|
</div>
|
|
@@ -53,4 +54,4 @@ ${u}`;this.chart.setOption({series:[{id:"__candlestick__",markLine:{data:[{...h,
|
|
|
53
54
|
</div>`:e=`<div style="position: relative; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;">
|
|
54
55
|
<span>${(t.name||t.id).substring(0,2).toUpperCase()}</span>
|
|
55
56
|
${this.arrowSvg}
|
|
56
|
-
</div>`,this.buttonElement.innerHTML=e}}}
|
|
57
|
+
</div>`,this.buttonElement.innerHTML=e}}}T.ABCDPatternDrawingRenderer=Re,T.ABCDPatternTool=Gs,T.AbstractPlugin=q,T.CrossLineDrawingRenderer=Me,T.CrossLineTool=Vn,T.CypherPatternDrawingRenderer=Ye,T.CypherPatternTool=Ns,T.DrawingRendererRegistry=ge,T.ExtendedLineDrawingRenderer=me,T.ExtendedLineTool=xn,T.FibSpeedResistanceFanDrawingRenderer=Se,T.FibSpeedResistanceFanTool=ds,T.FibTrendExtensionDrawingRenderer=Ge,T.FibTrendExtensionTool=xs,T.FibonacciChannelDrawingRenderer=_e,T.FibonacciChannelTool=os,T.FibonacciDrawingRenderer=Ae,T.FibonacciTool=Qn,T.HeadAndShouldersDrawingRenderer=qe,T.HeadAndShouldersTool=Vs,T.HorizontalLineDrawingRenderer=ve,T.HorizontalLineTool=_n,T.HorizontalRayDrawingRenderer=Ce,T.HorizontalRayTool=Ln,T.InfoLineDrawingRenderer=xe,T.InfoLineTool=dn,T.LineDrawingRenderer=ye,T.LineTool=Ji,T.MeasureTool=Yi,T.QFChart=Ri,T.RayDrawingRenderer=fe,T.RayTool=on,T.ThreeDrivesPatternDrawingRenderer=ti,T.ThreeDrivesPatternTool=ao,T.ToolGroup=co,T.TrendAngleDrawingRenderer=be,T.TrendAngleTool=Pn,T.TrianglePatternDrawingRenderer=Ke,T.TrianglePatternTool=to,T.VerticalLineDrawingRenderer=ke,T.VerticalLineTool=Rn,T.XABCDPatternDrawingRenderer=Te,T.XABCDPatternTool=Ms});
|