@candleview/core 3.0.2 → 3.0.5

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 CHANGED
@@ -935,8 +935,8 @@ export declare interface CandleViewConfig {
935
935
  technologyPanel?: boolean;
936
936
  drawingPanel?: boolean;
937
937
  chartType?: MainChartType;
938
- activeTimeframe?: TimeframeEnum;
939
- currentTimezone?: TimezoneEnum;
938
+ timeframe?: TimeframeEnum;
939
+ timezone?: TimezoneEnum;
940
940
  onToolSelect?: (tool: string) => void;
941
941
  onTimeframeChange?: (timeframe: TimeframeEnum) => void;
942
942
  onChartTypeChange?: (type: MainChartType) => void;
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var bt=(M=>(M.Top="Top",M.Bottom="Bottom",M))(bt||{}),Z=(M=>(M.Text="Text",M.Arrow="Arrow",M))(Z||{}),x=(M=>(M.ONE_SECOND="1s",M.FIVE_SECONDS="5s",M.FIFTEEN_SECONDS="15s",M.THIRTY_SECONDS="30s",M.ONE_MINUTE="1m",M.THREE_MINUTES="3m",M.FIVE_MINUTES="5m",M.FIFTEEN_MINUTES="15m",M.THIRTY_MINUTES="30m",M.FORTY_FIVE_MINUTES="45m",M.ONE_HOUR="1H",M.TWO_HOURS="2H",M.THREE_HOURS="3H",M.FOUR_HOURS="4H",M.SIX_HOURS="6H",M.EIGHT_HOURS="8H",M.TWELVE_HOURS="12H",M.ONE_DAY="1D",M.THREE_DAYS="3D",M.ONE_WEEK="1W",M.TWO_WEEKS="2W",M.ONE_MONTH="1M",M.THREE_MONTHS="3M",M.SIX_MONTHS="6M",M))(x||{}),Y=(M=>(M.NEW_YORK="America/New_York",M.CHICAGO="America/Chicago",M.DENVER="America/Denver",M.LOS_ANGELES="America/Los_Angeles",M.TORONTO="America/Toronto",M.LONDON="Europe/London",M.PARIS="Europe/Paris",M.FRANKFURT="Europe/Frankfurt",M.ZURICH="Europe/Zurich",M.MOSCOW="Europe/Moscow",M.DUBAI="Asia/Dubai",M.KARACHI="Asia/Karachi",M.KOLKATA="Asia/Kolkata",M.SHANGHAI="Asia/Shanghai",M.HONG_KONG="Asia/Hong_Kong",M.SINGAPORE="Asia/Singapore",M.TOKYO="Asia/Tokyo",M.SEOUL="Asia/Seoul",M.SYDNEY="Australia/Sydney",M.AUCKLAND="Pacific/Auckland",M.UTC="UTC",M))(Y||{}),j=(M=>(M.Default="default",M.Crosshair="crosshair",M.None="none",M.Circle="circle",M.Dot="dot",M))(j||{}),ms=(M=>(M.MainChart="MainChart",M.SubChart="SubChart",M))(ms||{}),R=(M=>(M.Candle="Candle",M.HollowCandle="HollowCandle",M.Bar="Bar",M.BaseLine="BaseLine",M.Line="Line",M.Area="Area",M.StepLine="StepLine",M.Histogram="Histogram",M.HeikinAshi="HeikinAshi",M.LineBreak="LineBreak",M.Mountain="Mountain",M.BaselineArea="BaselineArea",M.HighLow="HighLow",M.HLCArea="HLCArea",M))(R||{}),w=(M=>(M.MA="MA",M.EMA="EMA",M.BOLLINGER="BOLLINGER",M.ICHIMOKU="ICHIMOKU",M.DONCHIAN="DONCHIAN",M.ENVELOPE="ENVELOPE",M.VWAP="VWAP",M.HEATMAP="HEATMAP",M.MARKETPROFILE="MARKETPROFILE",M))(w||{}),B=(M=>(M.RSI="RSI",M.MACD="MACD",M.VOLUME="VOLUME",M.SAR="SAR",M.KDJ="KDJ",M.ATR="ATR",M.STOCHASTIC="STOCHASTIC",M.CCI="CCI",M.BBWIDTH="BBWIDTH",M.ADX="ADX",M.OBV="OBV",M))(B||{}),C=(M=>(M[M.Text=0]="Text",M[M.Emoji=1]="Emoji",M[M.LineSegment=2]="LineSegment",M[M.ArrowLine=3]="ArrowLine",M[M.ThickArrowLine=4]="ThickArrowLine",M[M.HorizontalLine=5]="HorizontalLine",M[M.VerticalLine=6]="VerticalLine",M[M.ParallelChannel=7]="ParallelChannel",M[M.LinearRegressionChannel=8]="LinearRegressionChannel",M[M.EquidistantChannel=9]="EquidistantChannel",M[M.DisjointChannel=10]="DisjointChannel",M[M.Pitchfork=11]="Pitchfork",M[M.AndrewPitchfork=12]="AndrewPitchfork",M[M.EnhancedAndrewPitchfork=13]="EnhancedAndrewPitchfork",M[M.SchiffPitchfork=14]="SchiffPitchfork",M[M.Rectangle=15]="Rectangle",M[M.Circle=16]="Circle",M[M.Ellipse=17]="Ellipse",M[M.Sector=18]="Sector",M[M.Curve=19]="Curve",M[M.DoubleCurve=20]="DoubleCurve",M[M.Triangle=21]="Triangle",M[M.GannFan=22]="GannFan",M[M.GannBox=23]="GannBox",M[M.GannRectangle=24]="GannRectangle",M[M.FibonacciTimeZoon=25]="FibonacciTimeZoon",M[M.FibonacciRetracement=26]="FibonacciRetracement",M[M.FibonacciArc=27]="FibonacciArc",M[M.FibonacciCircle=28]="FibonacciCircle",M[M.FibonacciSpiral=29]="FibonacciSpiral",M[M.FibonacciWedge=30]="FibonacciWedge",M[M.FibonacciFan=31]="FibonacciFan",M[M.FibonacciChannel=32]="FibonacciChannel",M[M.FibonacciExtensionBasePrice=33]="FibonacciExtensionBasePrice",M[M.FibonacciExtensionBaseTime=34]="FibonacciExtensionBaseTime",M[M.XABCD=35]="XABCD",M[M.HeadAndShoulders=36]="HeadAndShoulders",M[M.ABCD=37]="ABCD",M[M.TriangleABCD=38]="TriangleABCD",M[M.Elliott_Impulse=39]="Elliott_Impulse",M[M.Elliott_Corrective=40]="Elliott_Corrective",M[M.Elliott_Triangle=41]="Elliott_Triangle",M[M.Elliott_Double_Combination=42]="Elliott_Double_Combination",M[M.Elliott_Triple_Combination=43]="Elliott_Triple_Combination",M[M.TimeRange=44]="TimeRange",M[M.PriceRange=45]="PriceRange",M[M.TimePriceRange=46]="TimePriceRange",M[M.Pencil=47]="Pencil",M[M.Pen=48]="Pen",M[M.Brush=49]="Brush",M[M.MarkerPen=50]="MarkerPen",M[M.Eraser=51]="Eraser",M[M.Image=52]="Image",M[M.Table=53]="Table",M[M.LongPosition=54]="LongPosition",M[M.ShortPosition=55]="ShortPosition",M[M.PriceLabel=56]="PriceLabel",M[M.Flag=57]="Flag",M[M.PriceNote=58]="PriceNote",M[M.SignPost=59]="SignPost",M[M.Pin=60]="Pin",M[M.BubbleBox=61]="BubbleBox",M[M.TextEdit=62]="TextEdit",M[M.MockKLine=63]="MockKLine",M[M.HeatMap=64]="HeatMap",M[M.TimeEvent=65]="TimeEvent",M[M.PriceEvent=66]="PriceEvent",M))(C||{});function se(M){switch(M){case 0:return"text";case 0:return"emoji";case 0:return"line-segment";case 0:return"horizontal-line";case 0:return"vertical-line";case 3:return"arrow-line";case 4:return"thick-arrow-line";case 7:return"parallel-channel";case 8:return"linear-regression-channel";case 9:return"equidistant-channel";case 10:return"disjoint-channel";case 11:return"pitch-pitch-fork";case 12:return"andrew-pitch-fork";case 14:return"schiff-pitch-fork";case 13:return"enhanced-andrew-pitch-fork";case 15:return"rectangle";case 16:return"circle";case 17:return"ellipse";case 21:return"triangle";case 22:return"gann-fan";case 23:return"gann-box";case 24:return"gann-rectangle";case 25:return"fibonacci-time-zoon";case 26:return"fibonacci-retracement";case 27:return"fibonacci-fibonacci-arc";case 28:return"fibonacci-circle";case 29:return"fibonacci-spiral";case 30:return"fibonacci-wedge";case 31:return"fibonacci-fan";case 32:return"fibonacci-channel";case 33:return"fibonacci-extension-base-price";case 34:return"fibonacci-extension-base-time";case 18:return"sector";case 19:return"curve";case 20:return"double-curve";case 35:return"xabcd";case 36:return"head-and-shoulders";case 37:return"abcd";case 38:return"triangle-abcd";case 39:return"elliott-impulse";case 40:return"elliott-corrective";case 41:return"elliott-triangle";case 42:return"elliott-double-combination";case 43:return"elliott-triple-combination";case 44:return"time-range";case 45:return"price-range";case 46:return"time-price-range";case 47:return"pencil";case 48:return"pen";case 49:return"brush";case 50:return"marker-pen";case 51:return"eraser";case 52:return"image";case 53:return"table";case 54:return"long-position";case 55:return"short-position";case 56:return"price-label";case 57:return"flag";case 58:return"price-note";case 59:return"signpost";case 60:return"pin";case 61:return"bubble-box";case 62:return"text-edit";case 63:return"mock-line";case 64:return"heat-map";default:return""}}var ks=(M=>(M.Time="time",M.Price="price",M.None="none",M))(ks||{});const Ps={"America/New_York":{name:"America/New_York",offset:"-05:00",displayName:"New York"},"America/Chicago":{name:"America/Chicago",offset:"-06:00",displayName:"Chicago"},"America/Denver":{name:"America/Denver",offset:"-07:00",displayName:"Denver"},"America/Los_Angeles":{name:"America/Los_Angeles",offset:"-08:00",displayName:"Los Angeles"},"America/Toronto":{name:"America/Toronto",offset:"-05:00",displayName:"Toronto"},"Europe/London":{name:"Europe/London",offset:"+00:00",displayName:"London"},"Europe/Paris":{name:"Europe/Paris",offset:"+01:00",displayName:"Paris"},"Europe/Frankfurt":{name:"Europe/Frankfurt",offset:"+01:00",displayName:"Frankfurt"},"Europe/Zurich":{name:"Europe/Zurich",offset:"+01:00",displayName:"Zurich"},"Europe/Moscow":{name:"Europe/Moscow",offset:"+03:00",displayName:"Moscow"},"Asia/Dubai":{name:"Asia/Dubai",offset:"+04:00",displayName:"Dubai"},"Asia/Karachi":{name:"Asia/Karachi",offset:"+05:00",displayName:"Karachi"},"Asia/Kolkata":{name:"Asia/Kolkata",offset:"+05:30",displayName:"Kolkata"},"Asia/Shanghai":{name:"Asia/Shanghai",offset:"+08:00",displayName:"Shanghai"},"Asia/Hong_Kong":{name:"Asia/Hong_Kong",offset:"+08:00",displayName:"Hong Kong"},"Asia/Singapore":{name:"Asia/Singapore",offset:"+08:00",displayName:"Singapore"},"Asia/Tokyo":{name:"Asia/Tokyo",offset:"+09:00",displayName:"Tokyo"},"Asia/Seoul":{name:"Asia/Seoul",offset:"+09:00",displayName:"Seoul"},"Australia/Sydney":{name:"Australia/Sydney",offset:"+10:00",displayName:"Sydney"},"Pacific/Auckland":{name:"Pacific/Auckland",offset:"+12:00",displayName:"Auckland"},UTC:{name:"UTC",offset:"+00:00",displayName:"UTC"}},Ss={"1s":{seconds:1,groupBy:"second"},"5s":{seconds:5,groupBy:"second"},"15s":{seconds:15,groupBy:"second"},"30s":{seconds:30,groupBy:"second"},"1m":{seconds:60,groupBy:"minute"},"3m":{seconds:180,groupBy:"minute"},"5m":{seconds:300,groupBy:"minute"},"15m":{seconds:900,groupBy:"minute"},"30m":{seconds:1800,groupBy:"minute"},"45m":{seconds:2700,groupBy:"minute"},"1H":{seconds:3600,groupBy:"hour"},"2H":{seconds:7200,groupBy:"hour"},"3H":{seconds:10800,groupBy:"hour"},"4H":{seconds:14400,groupBy:"hour"},"6H":{seconds:21600,groupBy:"hour"},"8H":{seconds:28800,groupBy:"hour"},"12H":{seconds:43200,groupBy:"hour"},"1D":{seconds:86400,groupBy:"day"},"3D":{seconds:259200,groupBy:"day"},"1W":{seconds:604800,groupBy:"week"},"2W":{seconds:1209600,groupBy:"week"},"1M":{seconds:2592e3,groupBy:"month"},"3M":{seconds:7776e3,groupBy:"month"},"6M":{seconds:15552e3,groupBy:"month"}};class ca{constructor(t,e=1){this._time=t,this._count=e}attached(t){this._chart=t.chart,this._series=t.series,t.requestUpdate()}updateAllViews(){}paneViews(){return this._renderer||(this._renderer={draw:t=>{const e=t.context??t._context;if(!e||!this._chart||!this._series)return;const i=this._chart.timeScale().timeToCoordinate(this._time);if(i==null)return;const r=this._series.data().find(n=>n.time===this._time);if(!r)return;const s=r.low;let a=this._series.priceToCoordinate(s);if(a!=null){a+=20,e.save();for(let n=0;n<this._count;n++){const o=a+n*25;if(e.beginPath(),e.moveTo(i,o-12),e.lineTo(i-6,o),e.lineTo(i+6,o),e.closePath(),this._count===1)e.fillStyle="green";else if(this._count===2)e.fillStyle=n===0?"green":"lightgreen";else{const h=["green","lightgreen","lime","teal"];e.fillStyle=h[n]||"green"}e.fill(),e.beginPath(),e.moveTo(i,o),e.lineTo(i,o+8),e.strokeStyle=e.fillStyle,e.lineWidth=2,e.stroke(),this._count>=3&&(e.fillStyle="black",e.font="10px Arial",e.textAlign="center",e.textBaseline="middle",e.fillText((n+1).toString(),i,o+20))}e.restore()}}}),[{renderer:()=>this._renderer}]}}class da{constructor(t,e=[]){this._defaultIsCircular=!0,this._defaultFontSize=11,this._defaultPadding=2,this._defaultTextColor="white",this._defaultBackgroundColor="green",this._time=t,this._textItems=e}attached(t){this._chart=t.chart,this._series=t.series,t.requestUpdate()}updateAllViews(){}paneViews(){return this._renderer||(this._renderer={draw:t=>{const e=t.context??t._context;if(!e||!this._chart||!this._series)return;const i=this._chart.timeScale().timeToCoordinate(this._time);if(i==null)return;const r=this._series.data().find(n=>n.time===this._time);if(!r)return;const s=r.low;let a=this._series.priceToCoordinate(s);if(a!=null){a+=20,e.save();for(let n=0;n<this._textItems.length;n++){const o=this._textItems[n],h=a+n*40,l=o.fontSize??this._defaultFontSize,c="Arial";e.font=`${l}px ${c}`;const u=e.measureText(o.text).width,g=l,p=o.padding??this._defaultPadding,f=u+p*2,m=g+p*2,k=i-f/2,P=h-m/2;if(e.fillStyle=o.backgroundColor??this._defaultBackgroundColor,o.isCircular??this._defaultIsCircular){const S=Math.max(f,m)/2;e.beginPath(),e.arc(i,h,S,0,Math.PI*2),e.fill()}else e.fillRect(k,P,f,m);e.fillStyle=o.textColor??this._defaultTextColor,e.textAlign="center",e.textBaseline="middle",e.fillText(o.text,i,h)}e.restore()}}}),[{renderer:()=>this._renderer}]}addTextItem(t,e="white",i="blue",r=!1,s=this._defaultFontSize,a=this._defaultPadding){this._textItems.push({text:t,textColor:e,backgroundColor:i,isCircular:r,fontSize:s,padding:a}),this._chart&&this._chart.requestUpdate()}setTextItems(t){this._textItems=t,this._chart&&this._chart.requestUpdate()}updateText(t,e){this._textItems[t]&&(this._textItems[t].text=e,this._chart&&this._chart.requestUpdate())}updateColors(t,e,i){this._textItems[t]&&(this._textItems[t].textColor=e,this._textItems[t].backgroundColor=i,this._chart&&this._chart.requestUpdate())}updateCircular(t,e){this._textItems[t]&&(this._textItems[t].isCircular=e,this._chart&&this._chart.requestUpdate())}removeTextItem(t){this._textItems[t]&&(this._textItems.splice(t,1),this._chart&&this._chart.requestUpdate())}clearTextItems(){this._textItems=[],this._chart&&this._chart.requestUpdate()}getTextItemCount(){return this._textItems.length}}class ua{constructor(t,e=1){this._time=t,this._count=e}attached(t){this._chart=t.chart,this._series=t.series,t.requestUpdate()}updateAllViews(){}paneViews(){return this._renderer||(this._renderer={draw:t=>{const e=t.context??t._context;if(!e||!this._chart||!this._series)return;const i=this._chart.timeScale().timeToCoordinate(this._time);if(i==null)return;const r=this._series.data().find(n=>n.time===this._time);if(!r)return;const s=r.high;let a=this._series.priceToCoordinate(s);if(a!=null){a-=20,e.save();for(let n=0;n<this._count;n++){const o=a-n*25;if(e.beginPath(),e.moveTo(i,o+12),e.lineTo(i-6,o),e.lineTo(i+6,o),e.closePath(),this._count===1)e.fillStyle="red";else if(this._count===2)e.fillStyle=n===0?"red":"orange";else{const h=["red","orange","#1237dbff","purple"];e.fillStyle=h[n]||"red"}e.fill(),e.beginPath(),e.moveTo(i,o),e.lineTo(i,o-8),e.strokeStyle=e.fillStyle,e.lineWidth=2,e.stroke(),this._count>=3&&(e.fillStyle="black",e.font="10px Arial",e.textAlign="center",e.textBaseline="middle",e.fillText((n+1).toString(),i,o-20))}e.restore()}}}),[{renderer:()=>this._renderer}]}}class ga{constructor(t,e=[]){this._defaultIsCircular=!0,this._defaultFontSize=11,this._defaultPadding=2,this._defaultTextColor="white",this._defaultBackgroundColor="red",this._time=t,this._textItems=e}attached(t){this._chart=t.chart,this._series=t.series,t.requestUpdate()}updateAllViews(){}paneViews(){return this._renderer||(this._renderer={draw:t=>{const e=t.context??t._context;if(!e||!this._chart||!this._series)return;const i=this._chart.timeScale().timeToCoordinate(this._time);if(i==null)return;const r=this._series.data().find(n=>n.time===this._time);if(!r)return;const s=r.high;let a=this._series.priceToCoordinate(s);if(a!=null){a-=20,e.save();for(let n=0;n<this._textItems.length;n++){const o=this._textItems[n],h=a-n*40,l=o.fontSize??this._defaultFontSize,c="Arial";e.font=`${l}px ${c}`;const u=e.measureText(o.text).width,g=l,p=o.padding??this._defaultPadding,f=u+p*2,m=g+p*2,k=i-f/2,P=h-m/2;if(e.fillStyle=o.backgroundColor??this._defaultBackgroundColor,o.isCircular??this._defaultIsCircular){const S=Math.max(f,m)/2;e.beginPath(),e.arc(i,h,S,0,Math.PI*2),e.fill()}else e.fillRect(k,P,f,m);e.fillStyle=o.textColor??this._defaultTextColor,e.textAlign="center",e.textBaseline="middle",e.fillText(o.text,i,h)}e.restore()}}}),[{renderer:()=>this._renderer}]}addTextItem(t,e="white",i="blue",r=!1,s=this._defaultFontSize,a=this._defaultPadding){this._textItems.push({text:t,textColor:e,backgroundColor:i,isCircular:r,fontSize:s,padding:a}),this._chart&&this._chart.requestUpdate()}setTextItems(t){this._textItems=t,this._chart&&this._chart.requestUpdate()}updateText(t,e){this._textItems[t]&&(this._textItems[t].text=e,this._chart&&this._chart.requestUpdate())}updateColors(t,e,i){this._textItems[t]&&(this._textItems[t].textColor=e,this._textItems[t].backgroundColor=i,this._chart&&this._chart.requestUpdate())}updateCircular(t,e){this._textItems[t]&&(this._textItems[t].isCircular=e,this._chart&&this._chart.requestUpdate())}removeTextItem(t){this._textItems[t]&&(this._textItems.splice(t,1),this._chart&&this._chart.requestUpdate())}clearTextItems(){this._textItems=[],this._chart&&this._chart.requestUpdate()}getTextItemCount(){return this._textItems.length}}class pa{constructor(){this._marks=[],this._tolerance=1440*60*1e3,this._timeframe="1d",this._chartSeries=null}autoDetectTimeframe(t){if(!t||t.length<2)return"1d";const e=[];for(let r=1;r<Math.min(t.length,10);r++){const s=t[r].time-t[r-1].time;e.push(s)}const i=this.median(e);return i<=60*1e3?"1m":i<=300*1e3?"5m":i<=900*1e3?"15m":i<=3600*1e3?"1h":i<=14400*1e3?"4h":i<=1440*60*1e3?"1d":i<=10080*60*1e3?"1w":"1M"}median(t){if(t.length===0)return 0;t.sort((i,r)=>i-r);const e=Math.floor(t.length/2);return t.length%2?t[e]:(t[e-1]+t[e])/2}calculateTolerance(t){const e=t.slice(-1).toLowerCase(),i=parseInt(t.slice(0,-1))||1;switch(e){case"m":return Math.max(i*60*1e3,300*1e3);case"h":return i*60*60*1e3;case"d":return i*24*60*60*1e3;case"w":return i*7*24*60*60*1e3;case"M":return i*30*24*60*60*1e3;default:return 1440*60*1e3}}findClosestBarTime(t,e){const i=this.autoDetectTimeframe(t);i!==this._timeframe&&(this._timeframe=i,this._tolerance=this.calculateTolerance(i));let r=null,s=1/0;for(const a of t){const n=Math.abs(a.time-e);n<=this._tolerance&&n<s&&(s=n,r=a.time)}return r}isInSameTimeUnit(t,e,i){const r=new Date(t),s=new Date(e);if(i.endsWith("w")){const a=this.getWeekNumber(r),n=this.getWeekNumber(s);return a.year===n.year&&a.week===n.week}else if(i.endsWith("M"))return r.getFullYear()===s.getFullYear()&&r.getMonth()===s.getMonth();return!1}getWeekNumber(t){const e=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate())),i=e.getUTCDay()||7;e.setUTCDate(e.getUTCDate()+4-i);const r=new Date(Date.UTC(e.getUTCFullYear(),0,1));return{year:e.getUTCFullYear(),week:Math.ceil(((e.getTime()-r.getTime())/864e5+1)/7)}}addMark(t,e){if(!e||!e.series)return;this._chartSeries=e;const i=e.series.data();if(!i||i.length===0)return;const r=new Map;t.forEach(a=>{r.has(a.time)||r.set(a.time,[]),r.get(a.time).push(a)});const s=new Map;r.forEach((a,n)=>{const o=this.findClosestBarTime(i,n);o!==null&&(s.has(o)||s.set(o,[]),a.forEach(h=>{s.get(o).push({...h,time:o})}))}),s.forEach((a,n)=>{const o=new Map;a.forEach(h=>{const l=Object.values(Z).find(c=>c===h.type);l&&(o.has(l)||o.set(l,[]),o.get(l).push(h))}),o.forEach((h,l)=>{const c=h.flatMap(g=>g.data),d=c.filter(g=>Object.values(bt).find(p=>p===g.direction)===bt.Top),u=c.filter(g=>Object.values(bt).find(p=>p===g.direction)===bt.Bottom);d.length>0&&this.addTopMark([{time:n,type:l,data:d}],l,e),u.length>0&&this.addBottomMark([{time:n,type:l,data:u}],l,e)})})}recalculateMarks(){this._chartSeries&&([...this._marks],this.clearAllMarks())}refreshTimeframe(){if(!this._chartSeries)return;const t=this._chartSeries.series.data();if(!t||t.length<2)return;const e=this.autoDetectTimeframe(t);e!==this._timeframe&&(this._timeframe=e,this._tolerance=this.calculateTolerance(e),this.recalculateMarks())}addTopMark(t,e,i){switch(e){case Z.Text:t.forEach(r=>{const s=r.data.map(n=>{const o={text:n.text};return n.textColor!==void 0&&(o.textColor=n.textColor),n.backgroundColor!==void 0&&(o.backgroundColor=n.backgroundColor),n.isCircular!==void 0&&(o.isCircular=n.isCircular),n.fontSize!==void 0&&(o.fontSize=n.fontSize),n.padding!==void 0&&(o.padding=n.padding),o}),a=new ga(r.time,s);i.series.attachPrimitive(a),this._marks.push(a)});break;case Z.Arrow:t.forEach(r=>{const s=r.data.length,a=new ua(r.time,s);i.series.attachPrimitive(a),this._marks.push(a)});break;default:return}}addBottomMark(t,e,i){switch(e){case Z.Text:t.forEach(r=>{const s=r.data.map(n=>{const o={text:n.text};return n.textColor!==void 0&&(o.textColor=n.textColor),n.backgroundColor!==void 0&&(o.backgroundColor=n.backgroundColor),n.isCircular!==void 0&&(o.isCircular=n.isCircular),n.fontSize!==void 0&&(o.fontSize=n.fontSize),n.padding!==void 0&&(o.padding=n.padding),o}),a=new da(r.time,s);i.series.attachPrimitive(a),this._marks.push(a)});break;case Z.Arrow:t.forEach(r=>{const s=r.data.length,a=new ca(r.time,s);i.series.attachPrimitive(a),this._marks.push(a)});break;default:return}}removeAllMark(){this._marks=[]}getTolerance(){return this._tolerance}getTimeframe(){return this._timeframe}getMarkCount(){return this._marks.length}clearAllMarks(t){const e=t||this._chartSeries;e&&this._marks.forEach(i=>{e.series.detachPrimitive(i)}),this._marks=[]}destroy(){this.clearAllMarks(),this._chartSeries=null}}class fa{constructor(t){this.staticMarkManager=null,this.storedMarks=[],this.timezone=Y.NEW_YORK,this.chartManager=t}setTimezone(t){this.timezone=t}initStaticMarkManager(){const t=this.chartManager.getChart();if(!t||!t.chartSeries){console.warn("[CandleView] Chart not ready for static marks");return}this.staticMarkManager=new pa}ensureManager(){const t=this.chartManager.getChart();return!t||!t.chartSeries?(console.warn("[CandleView] Chart not ready for static marks"),!1):(this.staticMarkManager||this.initStaticMarkManager(),!!this.staticMarkManager)}reapplyMarks(){this.storedMarks.length!==0&&(this.staticMarkManager&&this.staticMarkManager.clearAllMarks(),this.addStaticMarks(this.storedMarks,!1))}getStoredMarks(){return[...this.storedMarks]}convertToChartTime(t){const i={[Y.NEW_YORK]:-18e3,[Y.CHICAGO]:-21600,[Y.DENVER]:-25200,[Y.LOS_ANGELES]:-28800,[Y.TORONTO]:-18e3,[Y.LONDON]:0,[Y.PARIS]:3600,[Y.FRANKFURT]:3600,[Y.ZURICH]:3600,[Y.MOSCOW]:10800,[Y.DUBAI]:14400,[Y.KARACHI]:18e3,[Y.KOLKATA]:19800,[Y.SHANGHAI]:28800,[Y.HONG_KONG]:28800,[Y.SINGAPORE]:28800,[Y.TOKYO]:32400,[Y.SEOUL]:32400,[Y.SYDNEY]:39600,[Y.AUCKLAND]:43200,[Y.UTC]:0}[this.timezone]||0,r=-new Date().getTimezoneOffset()*60;return t+(i-r)}addStaticMark(t,e,i,r,s){if(!this.ensureManager())return;const a=this.chartManager.getChart();if(!a||!a.chartSeries)return;const n={time:t,text:e,direction:i,type:r,options:s};this.storedMarks.push(n);const o={time:this.convertToChartTime(t),type:r,data:[{direction:i,text:e,textColor:s?.textColor,backgroundColor:s?.backgroundColor,isCircular:s?.isCircular,fontSize:s?.fontSize,padding:s?.padding}]};this.staticMarkManager.addMark([o],a.chartSeries)}addStaticMarks(t,e=!0){if(!this.ensureManager())return;const i=this.chartManager.getChart();if(!i||!i.chartSeries)return;e&&this.storedMarks.push(...t);const r=t.map(s=>({time:this.convertToChartTime(s.time),type:s.type,data:[{direction:s.direction,text:s.text,textColor:s.options?.textColor,backgroundColor:s.options?.backgroundColor,isCircular:s.options?.isCircular,fontSize:s.options?.fontSize,padding:s.options?.padding}]}));this.staticMarkManager.addMark(r,i.chartSeries)}addTextMark(t,e,i,r){this.addStaticMark(t,e,i,Z.Text,r)}addArrowMark(t,e,i){const r=i?.label||"";this.addStaticMark(t,r,e,Z.Arrow,i)}addTextMarks(t){this.addStaticMarks(t.map(e=>({time:e.time,text:e.text,direction:e.direction,type:Z.Text,options:e.options})))}addArrowMarks(t){this.addStaticMarks(t.map(e=>({time:e.time,text:e.options?.label||"",direction:e.direction,type:Z.Arrow,options:e.options})))}clearAllStaticMarks(){this.staticMarkManager&&this.staticMarkManager.clearAllMarks(),this.storedMarks=[]}getStaticMarkCount(){return this.staticMarkManager?.getMarkCount()||0}refreshMarks(){this.staticMarkManager?.recalculateMarks()}destroy(){this.staticMarkManager&&(this.staticMarkManager.destroy(),this.staticMarkManager=null),this.storedMarks=[]}}class Ma{constructor(){this.rootEl=null,this.chartContainerEl=null,this.technologyPanelContainer=null,this.drawingPanelContainer=null}create(t,e){t.innerHTML="",t.style.cssText="position:relative;width:100%;height:100%;overflow:hidden;";const i=document.createElement("style");i.id="candleview-no-select",i.textContent=`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var bt=(M=>(M.Top="Top",M.Bottom="Bottom",M))(bt||{}),Z=(M=>(M.Text="Text",M.Arrow="Arrow",M))(Z||{}),x=(M=>(M.ONE_SECOND="1s",M.FIVE_SECONDS="5s",M.FIFTEEN_SECONDS="15s",M.THIRTY_SECONDS="30s",M.ONE_MINUTE="1m",M.THREE_MINUTES="3m",M.FIVE_MINUTES="5m",M.FIFTEEN_MINUTES="15m",M.THIRTY_MINUTES="30m",M.FORTY_FIVE_MINUTES="45m",M.ONE_HOUR="1H",M.TWO_HOURS="2H",M.THREE_HOURS="3H",M.FOUR_HOURS="4H",M.SIX_HOURS="6H",M.EIGHT_HOURS="8H",M.TWELVE_HOURS="12H",M.ONE_DAY="1D",M.THREE_DAYS="3D",M.ONE_WEEK="1W",M.TWO_WEEKS="2W",M.ONE_MONTH="1M",M.THREE_MONTHS="3M",M.SIX_MONTHS="6M",M))(x||{}),Y=(M=>(M.NEW_YORK="America/New_York",M.CHICAGO="America/Chicago",M.DENVER="America/Denver",M.LOS_ANGELES="America/Los_Angeles",M.TORONTO="America/Toronto",M.LONDON="Europe/London",M.PARIS="Europe/Paris",M.FRANKFURT="Europe/Frankfurt",M.ZURICH="Europe/Zurich",M.MOSCOW="Europe/Moscow",M.DUBAI="Asia/Dubai",M.KARACHI="Asia/Karachi",M.KOLKATA="Asia/Kolkata",M.SHANGHAI="Asia/Shanghai",M.HONG_KONG="Asia/Hong_Kong",M.SINGAPORE="Asia/Singapore",M.TOKYO="Asia/Tokyo",M.SEOUL="Asia/Seoul",M.SYDNEY="Australia/Sydney",M.AUCKLAND="Pacific/Auckland",M.UTC="UTC",M))(Y||{}),j=(M=>(M.Default="default",M.Crosshair="crosshair",M.None="none",M.Circle="circle",M.Dot="dot",M))(j||{}),ms=(M=>(M.MainChart="MainChart",M.SubChart="SubChart",M))(ms||{}),R=(M=>(M.Candle="Candle",M.HollowCandle="HollowCandle",M.Bar="Bar",M.BaseLine="BaseLine",M.Line="Line",M.Area="Area",M.StepLine="StepLine",M.Histogram="Histogram",M.HeikinAshi="HeikinAshi",M.LineBreak="LineBreak",M.Mountain="Mountain",M.BaselineArea="BaselineArea",M.HighLow="HighLow",M.HLCArea="HLCArea",M))(R||{}),w=(M=>(M.MA="MA",M.EMA="EMA",M.BOLLINGER="BOLLINGER",M.ICHIMOKU="ICHIMOKU",M.DONCHIAN="DONCHIAN",M.ENVELOPE="ENVELOPE",M.VWAP="VWAP",M.HEATMAP="HEATMAP",M.MARKETPROFILE="MARKETPROFILE",M))(w||{}),B=(M=>(M.RSI="RSI",M.MACD="MACD",M.VOLUME="VOLUME",M.SAR="SAR",M.KDJ="KDJ",M.ATR="ATR",M.STOCHASTIC="STOCHASTIC",M.CCI="CCI",M.BBWIDTH="BBWIDTH",M.ADX="ADX",M.OBV="OBV",M))(B||{}),C=(M=>(M[M.Text=0]="Text",M[M.Emoji=1]="Emoji",M[M.LineSegment=2]="LineSegment",M[M.ArrowLine=3]="ArrowLine",M[M.ThickArrowLine=4]="ThickArrowLine",M[M.HorizontalLine=5]="HorizontalLine",M[M.VerticalLine=6]="VerticalLine",M[M.ParallelChannel=7]="ParallelChannel",M[M.LinearRegressionChannel=8]="LinearRegressionChannel",M[M.EquidistantChannel=9]="EquidistantChannel",M[M.DisjointChannel=10]="DisjointChannel",M[M.Pitchfork=11]="Pitchfork",M[M.AndrewPitchfork=12]="AndrewPitchfork",M[M.EnhancedAndrewPitchfork=13]="EnhancedAndrewPitchfork",M[M.SchiffPitchfork=14]="SchiffPitchfork",M[M.Rectangle=15]="Rectangle",M[M.Circle=16]="Circle",M[M.Ellipse=17]="Ellipse",M[M.Sector=18]="Sector",M[M.Curve=19]="Curve",M[M.DoubleCurve=20]="DoubleCurve",M[M.Triangle=21]="Triangle",M[M.GannFan=22]="GannFan",M[M.GannBox=23]="GannBox",M[M.GannRectangle=24]="GannRectangle",M[M.FibonacciTimeZoon=25]="FibonacciTimeZoon",M[M.FibonacciRetracement=26]="FibonacciRetracement",M[M.FibonacciArc=27]="FibonacciArc",M[M.FibonacciCircle=28]="FibonacciCircle",M[M.FibonacciSpiral=29]="FibonacciSpiral",M[M.FibonacciWedge=30]="FibonacciWedge",M[M.FibonacciFan=31]="FibonacciFan",M[M.FibonacciChannel=32]="FibonacciChannel",M[M.FibonacciExtensionBasePrice=33]="FibonacciExtensionBasePrice",M[M.FibonacciExtensionBaseTime=34]="FibonacciExtensionBaseTime",M[M.XABCD=35]="XABCD",M[M.HeadAndShoulders=36]="HeadAndShoulders",M[M.ABCD=37]="ABCD",M[M.TriangleABCD=38]="TriangleABCD",M[M.Elliott_Impulse=39]="Elliott_Impulse",M[M.Elliott_Corrective=40]="Elliott_Corrective",M[M.Elliott_Triangle=41]="Elliott_Triangle",M[M.Elliott_Double_Combination=42]="Elliott_Double_Combination",M[M.Elliott_Triple_Combination=43]="Elliott_Triple_Combination",M[M.TimeRange=44]="TimeRange",M[M.PriceRange=45]="PriceRange",M[M.TimePriceRange=46]="TimePriceRange",M[M.Pencil=47]="Pencil",M[M.Pen=48]="Pen",M[M.Brush=49]="Brush",M[M.MarkerPen=50]="MarkerPen",M[M.Eraser=51]="Eraser",M[M.Image=52]="Image",M[M.Table=53]="Table",M[M.LongPosition=54]="LongPosition",M[M.ShortPosition=55]="ShortPosition",M[M.PriceLabel=56]="PriceLabel",M[M.Flag=57]="Flag",M[M.PriceNote=58]="PriceNote",M[M.SignPost=59]="SignPost",M[M.Pin=60]="Pin",M[M.BubbleBox=61]="BubbleBox",M[M.TextEdit=62]="TextEdit",M[M.MockKLine=63]="MockKLine",M[M.HeatMap=64]="HeatMap",M[M.TimeEvent=65]="TimeEvent",M[M.PriceEvent=66]="PriceEvent",M))(C||{});function se(M){switch(M){case 0:return"text";case 0:return"emoji";case 0:return"line-segment";case 0:return"horizontal-line";case 0:return"vertical-line";case 3:return"arrow-line";case 4:return"thick-arrow-line";case 7:return"parallel-channel";case 8:return"linear-regression-channel";case 9:return"equidistant-channel";case 10:return"disjoint-channel";case 11:return"pitch-pitch-fork";case 12:return"andrew-pitch-fork";case 14:return"schiff-pitch-fork";case 13:return"enhanced-andrew-pitch-fork";case 15:return"rectangle";case 16:return"circle";case 17:return"ellipse";case 21:return"triangle";case 22:return"gann-fan";case 23:return"gann-box";case 24:return"gann-rectangle";case 25:return"fibonacci-time-zoon";case 26:return"fibonacci-retracement";case 27:return"fibonacci-fibonacci-arc";case 28:return"fibonacci-circle";case 29:return"fibonacci-spiral";case 30:return"fibonacci-wedge";case 31:return"fibonacci-fan";case 32:return"fibonacci-channel";case 33:return"fibonacci-extension-base-price";case 34:return"fibonacci-extension-base-time";case 18:return"sector";case 19:return"curve";case 20:return"double-curve";case 35:return"xabcd";case 36:return"head-and-shoulders";case 37:return"abcd";case 38:return"triangle-abcd";case 39:return"elliott-impulse";case 40:return"elliott-corrective";case 41:return"elliott-triangle";case 42:return"elliott-double-combination";case 43:return"elliott-triple-combination";case 44:return"time-range";case 45:return"price-range";case 46:return"time-price-range";case 47:return"pencil";case 48:return"pen";case 49:return"brush";case 50:return"marker-pen";case 51:return"eraser";case 52:return"image";case 53:return"table";case 54:return"long-position";case 55:return"short-position";case 56:return"price-label";case 57:return"flag";case 58:return"price-note";case 59:return"signpost";case 60:return"pin";case 61:return"bubble-box";case 62:return"text-edit";case 63:return"mock-line";case 64:return"heat-map";default:return""}}var ks=(M=>(M.Time="time",M.Price="price",M.None="none",M))(ks||{});const Ps={"America/New_York":{name:"America/New_York",offset:"-05:00",displayName:"New York"},"America/Chicago":{name:"America/Chicago",offset:"-06:00",displayName:"Chicago"},"America/Denver":{name:"America/Denver",offset:"-07:00",displayName:"Denver"},"America/Los_Angeles":{name:"America/Los_Angeles",offset:"-08:00",displayName:"Los Angeles"},"America/Toronto":{name:"America/Toronto",offset:"-05:00",displayName:"Toronto"},"Europe/London":{name:"Europe/London",offset:"+00:00",displayName:"London"},"Europe/Paris":{name:"Europe/Paris",offset:"+01:00",displayName:"Paris"},"Europe/Frankfurt":{name:"Europe/Frankfurt",offset:"+01:00",displayName:"Frankfurt"},"Europe/Zurich":{name:"Europe/Zurich",offset:"+01:00",displayName:"Zurich"},"Europe/Moscow":{name:"Europe/Moscow",offset:"+03:00",displayName:"Moscow"},"Asia/Dubai":{name:"Asia/Dubai",offset:"+04:00",displayName:"Dubai"},"Asia/Karachi":{name:"Asia/Karachi",offset:"+05:00",displayName:"Karachi"},"Asia/Kolkata":{name:"Asia/Kolkata",offset:"+05:30",displayName:"Kolkata"},"Asia/Shanghai":{name:"Asia/Shanghai",offset:"+08:00",displayName:"Shanghai"},"Asia/Hong_Kong":{name:"Asia/Hong_Kong",offset:"+08:00",displayName:"Hong Kong"},"Asia/Singapore":{name:"Asia/Singapore",offset:"+08:00",displayName:"Singapore"},"Asia/Tokyo":{name:"Asia/Tokyo",offset:"+09:00",displayName:"Tokyo"},"Asia/Seoul":{name:"Asia/Seoul",offset:"+09:00",displayName:"Seoul"},"Australia/Sydney":{name:"Australia/Sydney",offset:"+10:00",displayName:"Sydney"},"Pacific/Auckland":{name:"Pacific/Auckland",offset:"+12:00",displayName:"Auckland"},UTC:{name:"UTC",offset:"+00:00",displayName:"UTC"}},Ss={"1s":{seconds:1,groupBy:"second"},"5s":{seconds:5,groupBy:"second"},"15s":{seconds:15,groupBy:"second"},"30s":{seconds:30,groupBy:"second"},"1m":{seconds:60,groupBy:"minute"},"3m":{seconds:180,groupBy:"minute"},"5m":{seconds:300,groupBy:"minute"},"15m":{seconds:900,groupBy:"minute"},"30m":{seconds:1800,groupBy:"minute"},"45m":{seconds:2700,groupBy:"minute"},"1H":{seconds:3600,groupBy:"hour"},"2H":{seconds:7200,groupBy:"hour"},"3H":{seconds:10800,groupBy:"hour"},"4H":{seconds:14400,groupBy:"hour"},"6H":{seconds:21600,groupBy:"hour"},"8H":{seconds:28800,groupBy:"hour"},"12H":{seconds:43200,groupBy:"hour"},"1D":{seconds:86400,groupBy:"day"},"3D":{seconds:259200,groupBy:"day"},"1W":{seconds:604800,groupBy:"week"},"2W":{seconds:1209600,groupBy:"week"},"1M":{seconds:2592e3,groupBy:"month"},"3M":{seconds:7776e3,groupBy:"month"},"6M":{seconds:15552e3,groupBy:"month"}};class ca{constructor(t,e=1){this._time=t,this._count=e}attached(t){this._chart=t.chart,this._series=t.series,t.requestUpdate()}updateAllViews(){}paneViews(){return this._renderer||(this._renderer={draw:t=>{const e=t.context??t._context;if(!e||!this._chart||!this._series)return;const i=this._chart.timeScale().timeToCoordinate(this._time);if(i==null)return;const r=this._series.data().find(n=>n.time===this._time);if(!r)return;const s=r.low;let a=this._series.priceToCoordinate(s);if(a!=null){a+=20,e.save();for(let n=0;n<this._count;n++){const o=a+n*25;if(e.beginPath(),e.moveTo(i,o-12),e.lineTo(i-6,o),e.lineTo(i+6,o),e.closePath(),this._count===1)e.fillStyle="green";else if(this._count===2)e.fillStyle=n===0?"green":"lightgreen";else{const h=["green","lightgreen","lime","teal"];e.fillStyle=h[n]||"green"}e.fill(),e.beginPath(),e.moveTo(i,o),e.lineTo(i,o+8),e.strokeStyle=e.fillStyle,e.lineWidth=2,e.stroke(),this._count>=3&&(e.fillStyle="black",e.font="10px Arial",e.textAlign="center",e.textBaseline="middle",e.fillText((n+1).toString(),i,o+20))}e.restore()}}}),[{renderer:()=>this._renderer}]}}class da{constructor(t,e=[]){this._defaultIsCircular=!0,this._defaultFontSize=11,this._defaultPadding=2,this._defaultTextColor="white",this._defaultBackgroundColor="green",this._time=t,this._textItems=e}attached(t){this._chart=t.chart,this._series=t.series,t.requestUpdate()}updateAllViews(){}paneViews(){return this._renderer||(this._renderer={draw:t=>{const e=t.context??t._context;if(!e||!this._chart||!this._series)return;const i=this._chart.timeScale().timeToCoordinate(this._time);if(i==null)return;const r=this._series.data().find(n=>n.time===this._time);if(!r)return;const s=r.low;let a=this._series.priceToCoordinate(s);if(a!=null){a+=20,e.save();for(let n=0;n<this._textItems.length;n++){const o=this._textItems[n],h=a+n*40,l=o.fontSize??this._defaultFontSize,c="Arial";e.font=`${l}px ${c}`;const u=e.measureText(o.text).width,g=l,p=o.padding??this._defaultPadding,f=u+p*2,m=g+p*2,k=i-f/2,P=h-m/2;if(e.fillStyle=o.backgroundColor??this._defaultBackgroundColor,o.isCircular??this._defaultIsCircular){const S=Math.max(f,m)/2;e.beginPath(),e.arc(i,h,S,0,Math.PI*2),e.fill()}else e.fillRect(k,P,f,m);e.fillStyle=o.textColor??this._defaultTextColor,e.textAlign="center",e.textBaseline="middle",e.fillText(o.text,i,h)}e.restore()}}}),[{renderer:()=>this._renderer}]}addTextItem(t,e="white",i="blue",r=!1,s=this._defaultFontSize,a=this._defaultPadding){this._textItems.push({text:t,textColor:e,backgroundColor:i,isCircular:r,fontSize:s,padding:a}),this._chart&&this._chart.requestUpdate()}setTextItems(t){this._textItems=t,this._chart&&this._chart.requestUpdate()}updateText(t,e){this._textItems[t]&&(this._textItems[t].text=e,this._chart&&this._chart.requestUpdate())}updateColors(t,e,i){this._textItems[t]&&(this._textItems[t].textColor=e,this._textItems[t].backgroundColor=i,this._chart&&this._chart.requestUpdate())}updateCircular(t,e){this._textItems[t]&&(this._textItems[t].isCircular=e,this._chart&&this._chart.requestUpdate())}removeTextItem(t){this._textItems[t]&&(this._textItems.splice(t,1),this._chart&&this._chart.requestUpdate())}clearTextItems(){this._textItems=[],this._chart&&this._chart.requestUpdate()}getTextItemCount(){return this._textItems.length}}class ua{constructor(t,e=1){this._time=t,this._count=e}attached(t){this._chart=t.chart,this._series=t.series,t.requestUpdate()}updateAllViews(){}paneViews(){return this._renderer||(this._renderer={draw:t=>{const e=t.context??t._context;if(!e||!this._chart||!this._series)return;const i=this._chart.timeScale().timeToCoordinate(this._time);if(i==null)return;const r=this._series.data().find(n=>n.time===this._time);if(!r)return;const s=r.high;let a=this._series.priceToCoordinate(s);if(a!=null){a-=20,e.save();for(let n=0;n<this._count;n++){const o=a-n*25;if(e.beginPath(),e.moveTo(i,o+12),e.lineTo(i-6,o),e.lineTo(i+6,o),e.closePath(),this._count===1)e.fillStyle="red";else if(this._count===2)e.fillStyle=n===0?"red":"orange";else{const h=["red","orange","#1237dbff","purple"];e.fillStyle=h[n]||"red"}e.fill(),e.beginPath(),e.moveTo(i,o),e.lineTo(i,o-8),e.strokeStyle=e.fillStyle,e.lineWidth=2,e.stroke(),this._count>=3&&(e.fillStyle="black",e.font="10px Arial",e.textAlign="center",e.textBaseline="middle",e.fillText((n+1).toString(),i,o-20))}e.restore()}}}),[{renderer:()=>this._renderer}]}}class ga{constructor(t,e=[]){this._defaultIsCircular=!0,this._defaultFontSize=11,this._defaultPadding=2,this._defaultTextColor="white",this._defaultBackgroundColor="red",this._time=t,this._textItems=e}attached(t){this._chart=t.chart,this._series=t.series,t.requestUpdate()}updateAllViews(){}paneViews(){return this._renderer||(this._renderer={draw:t=>{const e=t.context??t._context;if(!e||!this._chart||!this._series)return;const i=this._chart.timeScale().timeToCoordinate(this._time);if(i==null)return;const r=this._series.data().find(n=>n.time===this._time);if(!r)return;const s=r.high;let a=this._series.priceToCoordinate(s);if(a!=null){a-=20,e.save();for(let n=0;n<this._textItems.length;n++){const o=this._textItems[n],h=a-n*40,l=o.fontSize??this._defaultFontSize,c="Arial";e.font=`${l}px ${c}`;const u=e.measureText(o.text).width,g=l,p=o.padding??this._defaultPadding,f=u+p*2,m=g+p*2,k=i-f/2,P=h-m/2;if(e.fillStyle=o.backgroundColor??this._defaultBackgroundColor,o.isCircular??this._defaultIsCircular){const S=Math.max(f,m)/2;e.beginPath(),e.arc(i,h,S,0,Math.PI*2),e.fill()}else e.fillRect(k,P,f,m);e.fillStyle=o.textColor??this._defaultTextColor,e.textAlign="center",e.textBaseline="middle",e.fillText(o.text,i,h)}e.restore()}}}),[{renderer:()=>this._renderer}]}addTextItem(t,e="white",i="blue",r=!1,s=this._defaultFontSize,a=this._defaultPadding){this._textItems.push({text:t,textColor:e,backgroundColor:i,isCircular:r,fontSize:s,padding:a}),this._chart&&this._chart.requestUpdate()}setTextItems(t){this._textItems=t,this._chart&&this._chart.requestUpdate()}updateText(t,e){this._textItems[t]&&(this._textItems[t].text=e,this._chart&&this._chart.requestUpdate())}updateColors(t,e,i){this._textItems[t]&&(this._textItems[t].textColor=e,this._textItems[t].backgroundColor=i,this._chart&&this._chart.requestUpdate())}updateCircular(t,e){this._textItems[t]&&(this._textItems[t].isCircular=e,this._chart&&this._chart.requestUpdate())}removeTextItem(t){this._textItems[t]&&(this._textItems.splice(t,1),this._chart&&this._chart.requestUpdate())}clearTextItems(){this._textItems=[],this._chart&&this._chart.requestUpdate()}getTextItemCount(){return this._textItems.length}}class pa{constructor(){this._marks=[],this._tolerance=1440*60*1e3,this._timeframe="1d",this._chartSeries=null}autoDetectTimeframe(t){if(!t||t.length<2)return"1d";const e=[];for(let r=1;r<Math.min(t.length,10);r++){const s=t[r].time-t[r-1].time;e.push(s)}const i=this.median(e);return i<=60*1e3?"1m":i<=300*1e3?"5m":i<=900*1e3?"15m":i<=3600*1e3?"1h":i<=14400*1e3?"4h":i<=1440*60*1e3?"1d":i<=10080*60*1e3?"1w":"1M"}median(t){if(t.length===0)return 0;t.sort((i,r)=>i-r);const e=Math.floor(t.length/2);return t.length%2?t[e]:(t[e-1]+t[e])/2}calculateTolerance(t){const e=t.slice(-1).toLowerCase(),i=parseInt(t.slice(0,-1))||1;switch(e){case"m":return Math.max(i*60*1e3,300*1e3);case"h":return i*60*60*1e3;case"d":return i*24*60*60*1e3;case"w":return i*7*24*60*60*1e3;case"M":return i*30*24*60*60*1e3;default:return 1440*60*1e3}}findClosestBarTime(t,e){const i=this.autoDetectTimeframe(t);i!==this._timeframe&&(this._timeframe=i,this._tolerance=this.calculateTolerance(i));let r=null,s=1/0;for(const a of t){const n=Math.abs(a.time-e);n<=this._tolerance&&n<s&&(s=n,r=a.time)}return r}isInSameTimeUnit(t,e,i){const r=new Date(t),s=new Date(e);if(i.endsWith("w")){const a=this.getWeekNumber(r),n=this.getWeekNumber(s);return a.year===n.year&&a.week===n.week}else if(i.endsWith("M"))return r.getFullYear()===s.getFullYear()&&r.getMonth()===s.getMonth();return!1}getWeekNumber(t){const e=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate())),i=e.getUTCDay()||7;e.setUTCDate(e.getUTCDate()+4-i);const r=new Date(Date.UTC(e.getUTCFullYear(),0,1));return{year:e.getUTCFullYear(),week:Math.ceil(((e.getTime()-r.getTime())/864e5+1)/7)}}addMark(t,e){if(!e||!e.series)return;this._chartSeries=e;const i=e.series.data();if(!i||i.length===0)return;const r=new Map;t.forEach(a=>{r.has(a.time)||r.set(a.time,[]),r.get(a.time).push(a)});const s=new Map;r.forEach((a,n)=>{const o=this.findClosestBarTime(i,n);o!==null&&(s.has(o)||s.set(o,[]),a.forEach(h=>{s.get(o).push({...h,time:o})}))}),s.forEach((a,n)=>{const o=new Map;a.forEach(h=>{const l=Object.values(Z).find(c=>c===h.type);l&&(o.has(l)||o.set(l,[]),o.get(l).push(h))}),o.forEach((h,l)=>{const c=h.flatMap(g=>g.data),d=c.filter(g=>Object.values(bt).find(p=>p===g.direction)===bt.Top),u=c.filter(g=>Object.values(bt).find(p=>p===g.direction)===bt.Bottom);d.length>0&&this.addTopMark([{time:n,type:l,data:d}],l,e),u.length>0&&this.addBottomMark([{time:n,type:l,data:u}],l,e)})})}recalculateMarks(){this._chartSeries&&([...this._marks],this.clearAllMarks())}refreshTimeframe(){if(!this._chartSeries)return;const t=this._chartSeries.series.data();if(!t||t.length<2)return;const e=this.autoDetectTimeframe(t);e!==this._timeframe&&(this._timeframe=e,this._tolerance=this.calculateTolerance(e),this.recalculateMarks())}addTopMark(t,e,i){switch(e){case Z.Text:t.forEach(r=>{const s=r.data.map(n=>{const o={text:n.text};return n.textColor!==void 0&&(o.textColor=n.textColor),n.backgroundColor!==void 0&&(o.backgroundColor=n.backgroundColor),n.isCircular!==void 0&&(o.isCircular=n.isCircular),n.fontSize!==void 0&&(o.fontSize=n.fontSize),n.padding!==void 0&&(o.padding=n.padding),o}),a=new ga(r.time,s);i.series.attachPrimitive(a),this._marks.push(a)});break;case Z.Arrow:t.forEach(r=>{const s=r.data.length,a=new ua(r.time,s);i.series.attachPrimitive(a),this._marks.push(a)});break;default:return}}addBottomMark(t,e,i){switch(e){case Z.Text:t.forEach(r=>{const s=r.data.map(n=>{const o={text:n.text};return n.textColor!==void 0&&(o.textColor=n.textColor),n.backgroundColor!==void 0&&(o.backgroundColor=n.backgroundColor),n.isCircular!==void 0&&(o.isCircular=n.isCircular),n.fontSize!==void 0&&(o.fontSize=n.fontSize),n.padding!==void 0&&(o.padding=n.padding),o}),a=new da(r.time,s);i.series.attachPrimitive(a),this._marks.push(a)});break;case Z.Arrow:t.forEach(r=>{const s=r.data.length,a=new ca(r.time,s);i.series.attachPrimitive(a),this._marks.push(a)});break;default:return}}removeAllMark(){this._marks=[]}getTolerance(){return this._tolerance}getTimeframe(){return this._timeframe}getMarkCount(){return this._marks.length}clearAllMarks(t){const e=t||this._chartSeries;e&&this._marks.forEach(i=>{e.series.detachPrimitive(i)}),this._marks=[]}destroy(){this.clearAllMarks(),this._chartSeries=null}}class fa{constructor(t){this.staticMarkManager=null,this.storedMarks=[],this.timezone=Y.NEW_YORK,this.chartManager=t}setTimezone(t){this.timezone=t}initStaticMarkManager(){const t=this.chartManager.getChart();if(!t||!t.chartSeries){console.warn("[CandleView] Chart not ready for static marks");return}this.staticMarkManager=new pa}ensureManager(){const t=this.chartManager.getChart();return!t||!t.chartSeries?(console.warn("[CandleView] Chart not ready for static marks"),!1):(this.staticMarkManager||this.initStaticMarkManager(),!!this.staticMarkManager)}reapplyMarks(){this.storedMarks.length!==0&&(this.staticMarkManager&&this.staticMarkManager.clearAllMarks(),this.addStaticMarks(this.storedMarks,!1))}getStoredMarks(){return[...this.storedMarks]}convertToChartTime(t){const i={[Y.NEW_YORK]:-18e3,[Y.CHICAGO]:-21600,[Y.DENVER]:-25200,[Y.LOS_ANGELES]:-28800,[Y.TORONTO]:-18e3,[Y.LONDON]:0,[Y.PARIS]:3600,[Y.FRANKFURT]:3600,[Y.ZURICH]:3600,[Y.MOSCOW]:10800,[Y.DUBAI]:14400,[Y.KARACHI]:18e3,[Y.KOLKATA]:19800,[Y.SHANGHAI]:28800,[Y.HONG_KONG]:28800,[Y.SINGAPORE]:28800,[Y.TOKYO]:32400,[Y.SEOUL]:32400,[Y.SYDNEY]:39600,[Y.AUCKLAND]:43200,[Y.UTC]:0}[this.timezone]||0,r=-new Date().getTimezoneOffset()*60;return t+(i-r)}addStaticMark(t,e,i,r,s){if(!this.ensureManager())return;const a=this.chartManager.getChart();if(!a||!a.chartSeries)return;const n={time:t,text:e,direction:i,type:r,options:s};this.storedMarks.push(n);const o={time:this.convertToChartTime(t),type:r,data:[{direction:i,text:e,textColor:s?.textColor,backgroundColor:s?.backgroundColor,isCircular:s?.isCircular,fontSize:s?.fontSize,padding:s?.padding}]};this.staticMarkManager.addMark([o],a.chartSeries)}addStaticMarks(t,e=!0){if(!this.ensureManager())return;const i=this.chartManager.getChart();if(!i||!i.chartSeries)return;e&&this.storedMarks.push(...t);const r=t.map(s=>({time:this.convertToChartTime(s.time),type:s.type,data:[{direction:s.direction,text:s.text,textColor:s.options?.textColor,backgroundColor:s.options?.backgroundColor,isCircular:s.options?.isCircular,fontSize:s.options?.fontSize,padding:s.options?.padding}]}));this.staticMarkManager.addMark(r,i.chartSeries)}addTextMark(t,e,i,r){this.addStaticMark(t,e,i,Z.Text,r)}addArrowMark(t,e,i){const r=i?.label||"";this.addStaticMark(t,r,e,Z.Arrow,i)}addTextMarks(t){this.addStaticMarks(t.map(e=>({time:e.time,text:e.text,direction:e.direction,type:Z.Text,options:e.options})))}addArrowMarks(t){this.addStaticMarks(t.map(e=>({time:e.time,text:e.options?.label||"",direction:e.direction,type:Z.Arrow,options:e.options})))}clearAllStaticMarks(){this.staticMarkManager&&this.staticMarkManager.clearAllMarks(),this.storedMarks=[]}getStaticMarkCount(){return this.staticMarkManager?.getMarkCount()||0}refreshMarks(){this.staticMarkManager?.recalculateMarks()}destroy(){this.staticMarkManager&&(this.staticMarkManager.destroy(),this.staticMarkManager=null),this.storedMarks=[]}}class Ma{constructor(){this.rootEl=null,this.chartContainerEl=null,this.technologyPanelContainer=null,this.drawingPanelContainer=null}create(t,e){t.innerHTML="";const i=document.createElement("style");i.id="candleview-no-select",i.textContent=`
2
2
  .candleview-root,
3
3
  .candleview-root * {
4
4
  user-select: none !important;
@@ -1777,8 +1777,8 @@
1777
1777
  align-items: center;
1778
1778
  justify-content: center;
1779
1779
  min-width: 0;
1780
- `,p.onmouseenter=()=>{p.style.background=t.buttonHover,p.style.transform="scale(1.05)",p.style.borderColor=t.panelBorder},p.onmouseleave=()=>{p.style.background="transparent",p.style.transform="scale(1)",p.style.borderColor="transparent"},p.onclick=()=>{this.setState({selectedEmoji:g.character}),this.options.onEmojiSelect?.(g.character),this.toolManager.handleDrawingToolSelect(this,"emoji"),this.closeModal("emoji")},u.appendChild(p)}),r.appendChild(u),this.emojiPickerRef=r,this.container.appendChild(r),this.bindOutsideClick(r,()=>this.closeModal("emoji"))}closeModal(t){const e={drawing:this.drawingModalRef,brush:this.brushModalRef,cursor:this.cursorModalRef,fibonacci:this.fibonacciModalRef,projectInfo:this.projectInfoModalRef,irregularShape:this.irregularShapeModalRef,textTool:this.textToolModalRef,aiTools:this.aiModalRef,script:this.scriptModalRef,emoji:this.emojiPickerRef};e[t]&&(e[t]?.remove(),e[t]=null),this.setState({isDrawingModalOpen:!1,isBrushModalOpen:!1,isCursorModalOpen:!1,isFibonacciModalOpen:!1,isProjectInfoModalOpen:!1,isIrregularShapeModalOpen:!1,isTextToolModalOpen:!1,isAIToolsModalOpen:!1,isScriptModalOpen:!1,isEmojiSelectPopUpOpen:!1,arrowButtonStates:{}})}closeAllModals(){this.closeModal("drawing"),this.closeModal("brush"),this.closeModal("cursor"),this.closeModal("fibonacci"),this.closeModal("projectInfo"),this.closeModal("irregularShape"),this.closeModal("textTool"),this.closeModal("aiTools"),this.closeModal("script"),this.closeModal("emoji"),this.setState({arrowButtonStates:{}}),this.element?.querySelectorAll(".arrow-button")?.forEach(e=>{e.innerHTML='<span style="font-size:18px;">›</span>'})}bindOutsideClick(t,e){const i=r=>{const s=r.target;t.contains(s)||s.closest(".tool-btn-drawing")||s.closest(".tool-btn-brush")||s.closest(".tool-btn-cursor")||s.closest(".tool-btn-fibonacci")||s.closest(".tool-btn-project-info")||s.closest(".tool-btn-irregular-shape")||s.closest(".tool-btn-text")||s.closest(".tool-btn-ai")||s.closest(".tool-btn-script")||s.closest(".tool-btn-emoji")||(e(),document.removeEventListener("click",i))};setTimeout(()=>{document.addEventListener("click",i)},0)}setActiveTool(t){if(t&&["emoji","text","price-event","time-event"].includes(t))return;const i=this.theme.getColors();this.element?.querySelectorAll(".tool-btn")?.forEach(s=>{const a=s;a.className.includes(`tool-btn-${t}`)?(a.style.background=i.buttonActive,a.style.color="#FFFFFF"):!a.className.includes("tool-btn-lock")&&!a.className.includes("tool-btn-eye")&&!a.className.includes("tool-btn-trash")&&!a.className.includes("tool-btn-terminal")&&(a.style.background="transparent",a.style.color=i.buttonColor)})}toggleLock(){this.setState({isMarkLocked:!this.state.isMarkLocked}),this.updateOtherTools()}toggleVisibility(){const t=!this.state.isMarkVisibility;this.setState({isMarkVisibility:t}),t?this.options.chart?.showAllMark?.():this.options.chart?.hideAllMark?.(),this.updateOtherTools()}updateOtherTools(){const t=this.element?.querySelector(".tool-btn-lock"),e=this.element?.querySelector(".tool-btn-eye");t&&(t.innerHTML=this.state.isMarkLocked?this.getIconSvg("lock"):this.getIconSvg("unlock")),e&&(e.innerHTML=this.state.isMarkVisibility?this.getIconSvg("eyeOpen"):this.getIconSvg("eyeClosed"))}getToolConfig(){return Yc(this.i18n)}findToolInGroups(t,e){for(const i of t){const r=i.tools.find(s=>s.id===e);if(r)return r}return null}getIconSvg(t){return{script:'<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M14 2H6C5.44772 2 5 2.44772 5 3V21C5 21.5523 5.44772 22 6 22H18C18.5523 22 19 21.5523 19 21V8L14 2Z"/><path d="M14 2V8H19"/><path d="M9 12H15"/><path d="M9 16H12"/></svg>',emoji:'<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><circle cx="12" cy="12" r="10"/><path d="M8 14s1.5 2 4 2 4-2 4-2"/><circle cx="9" cy="9" r="1" fill="currentColor"/><circle cx="15" cy="9" r="1" fill="currentColor"/></svg>',ai:'<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><ellipse cx="12" cy="20" rx="10" ry="3"/><circle cx="12" cy="10.5" r="8"/><path d="M7 8C9 6 15 6 17 8"/><circle cx="9" cy="9" r="1.5" fill="currentColor"/><path d="M12 5L14 2L16 5L19 6L16 7L14 10L12 7L9 6Z" fill="currentColor"/></svg>',terminal:'<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><rect x="3" y="4" width="18" height="16" rx="2"/><path d="M6 9L9 12L6 15"/><path d="M11 15H15"/></svg>',lock:'<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><rect x="3" y="10" width="18" height="12" rx="2"/><path d="M7 10V7C7 4.23858 9.23858 2 12 2C14.7614 2 17 4.23858 17 7V10"/><circle cx="12" cy="15" r="1" fill="currentColor"/><path d="M12 15V17"/></svg>',unlock:'<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><rect x="3" y="10" width="18" height="12" rx="2"/><path d="M7 10V7C7 4.23858 9.23858 2 12 2C14.7614 2 17 4.23858 17 7" stroke-dasharray="12 12"/><circle cx="12" cy="15" r="1" fill="currentColor"/><path d="M12 15V17"/></svg>',eyeOpen:'<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M1 12C1 12 5 4 12 4C19 4 23 12 23 12C23 12 19 20 12 20C5 20 1 12 1 12Z"/><circle cx="12" cy="12" r="3"/></svg>',eyeClosed:'<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M2 12C2 12 6 4 13 4C20 4 24 12 24 12C24 12 20 20 13 20C6 20 2 12 2 12Z"/><path d="M4.93 4.93L19.07 19.07"/><path d="M9.76 14.24C8.79 13.27 8.79 11.73 9.76 10.76C10.73 9.79 12.27 9.79 13.24 10.76"/></svg>',trash:'<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M3 6H5H21"/><path d="M8 6V4C8 3.44772 8.44772 3 9 3H15C15.5523 3 16 3.44772 16 4V6M19 6V20C19 20.5523 18.5523 21 18 21H6C5.44772 21 5 20.5523 5 20V6H19Z"/><path d="M10 11V17"/><path d="M14 11V17"/></svg>'}[t]||""}getModalTop(){const t=this.getContainerRect();return(this.element?.getBoundingClientRect()?.top||t.top)-t.top+50}updateContainerHeight(){if(this.element){const t=this.element.clientHeight;this.setState({containerHeight:t}),this.updateScrollButtons()}}updateScrollButtons(){if(this.scrollContainerRef){const{scrollTop:t,scrollHeight:e,clientHeight:i}=this.scrollContainerRef,r=t>10,s=t<e-i-10;this.state.scrollButtonVisibility={showTop:r,showBottom:s},this.updateScrollButtonsUI()}}updateScrollButtonsUI(){this.scrollTopBtn&&(this.scrollTopBtn.style.display=this.state.scrollButtonVisibility.showTop?"flex":"none"),this.scrollBottomBtn&&(this.scrollBottomBtn.style.display=this.state.scrollButtonVisibility.showBottom?"flex":"none")}bindEvents(){this.scrollContainerRef&&this.scrollContainerRef.addEventListener("scroll",()=>this.updateScrollButtons()),document.addEventListener("click",this.handleClickOutside)}setState(t){Object.assign(this.state,t),(t.isMarkLocked!==void 0||t.isMarkVisibility!==void 0)&&this.updateOtherTools()}updateTheme(t){this.theme=t;const e=t.getColors(),i=t.isDark(),r=i?e.buttonHover:"#E1E5E9",s=i?e.panelBorder:"#EEEEEE";if(this.element){const l=this.element.querySelector("div");l&&(l.style.background=e.panelBg,l.style.borderRightColor=e.panelBorder)}this.scrollContainerRef?.querySelectorAll("div")?.forEach(l=>{const c=l;c.style.height==="1px"&&(c.style.background=s)}),this.element?.querySelectorAll(".tool-btn")?.forEach(l=>{const c=l,d=c.style.background===e.buttonActive;d||(c.style.background="transparent"),c.style.color=d?"#FFFFFF":e.buttonColor,c.onmouseenter=()=>{d||(c.style.background=r)},c.onmouseleave=()=>{d||(c.style.background="transparent")}}),this.element?.querySelectorAll(".arrow-button")?.forEach(l=>{const c=l;c.style.background="transparent",c.style.color=e.buttonColor,c.onmouseenter=d=>{d.target.style.background=r},c.onmouseleave=d=>{d.target.style.background="transparent"}});const h=document.getElementById("candleview-scrollbar-styles");h&&h.remove(),this.injectScrollbarStyles(),this.closeAllModals()}updateI18n(t){this.i18n=t,this.closeAllModals()}destroy(){this.closeAllModals(),this.element?.remove(),document.removeEventListener("click",this.handleClickOutside)}updateState(t){Object.assign(this.state,t)}isMarkLocked(){return this.state.isMarkLocked}getContainerRect(){return this.container.getBoundingClientRect()}getState(){return this.state}}const la={isTimeframeModalOpen:!1,isIndicatorModalOpen:!1,isChartTypeModalOpen:!1,isSubChartModalOpen:!1,isTimezoneModalOpen:!1,isTimeFormatModalOpen:!1,isCloseTimeModalOpen:!1,isTradingDayModalOpen:!1,isAIModalOpen:!1,isMobileMenuOpen:!1,activeTimeframe:x.FIFTEEN_MINUTES,currentMainChartType:R.Candle,currentTimezone:Y.SHANGHAI,selectedSubChartIndicators:[],selectedMainChartIndicator:null,mainIndicatorsSearch:"",timezoneSearch:"",subChartIndicatorsSearch:"",chartTypeSearch:"",aiSearch:"",selectedMainIndicator:null,selectedChartMap:null,selectedSubIndicator:null,timeframeSections:{second:!0,minute:!0,hour:!0,day:!0,week:!0,month:!0},indicatorSections:{technicalIndicators:!0,chart:!0,subChartIndicators:!0},aiSections:{},scrollButtonVisibility:{showTop:!1,showBottom:!1},isDataLoading:!1,dataLoadProgress:0,loadError:null},ha={isDrawingModalOpen:!1,isEmojiSelectPopUpOpen:!1,isBrushModalOpen:!1,isCursorModalOpen:!1,isFibonacciModalOpen:!1,isProjectInfoModalOpen:!1,isIrregularShapeModalOpen:!1,isTextToolModalOpen:!1,isAIToolsModalOpen:!1,isScriptModalOpen:!1,selectedEmoji:"😀",selectedEmojiCategory:"smileys",selectedCursor:"crosshair",selectedAITool:null,selectedScriptTool:null,lastSelectedTools:{drawing:"line-segment",brush:"pencil",cursor:"crosshair",fibonacci:"fibonacci-retracement",projectInfo:"time-range",irregularShape:"rectangle",textTool:"text",aiTools:"describe-chart",script:"price-event"},arrowButtonStates:{},toolHoverStates:{},isMarkLocked:!1,isMarkVisibility:!0,toolSearch:"",containerHeight:0,scrollButtonVisibility:{showTop:!1,showBottom:!1},isBrushActive:!1};class $c{constructor(t){this.topPanel=null,this.leftPanel=null,this.topPanelState={...la},this.leftPanelState={...ha},this.config=t}init(){this.initTopPanel(),this.initLeftPanel()}initTopPanel(){this.config.technologyPanelContainer&&(this.topPanel=new Xc({container:this.config.technologyPanelContainer,rootContainer:this.config.rootContainer,theme:this.config.theme,i18n:this.config.i18n,state:this.topPanelState,activeTimeframe:this.topPanelState.activeTimeframe,activeMainChartType:this.topPanelState.currentMainChartType,currentTimezone:this.topPanelState.currentTimezone,onStateChange:t=>this.updateTopPanelState(t),onTimeframeSelect:t=>this.config.onTimeframeChange(t),onChartTypeSelect:t=>this.config.onChartTypeChange(t),onMainChartIndicatorSelect:t=>this.config.onMainChartIndicatorSelect(t),onSubChartIndicatorSelect:t=>this.config.onSubChartIndicatorSelect(t),onThemeToggle:()=>this.config.onThemeToggle(),onCameraClick:async()=>{if(typeof window>"u"||typeof document>"u")return;const t=await this.config.candleView.captureScreenshot(),e=document.createElement("a");e.download=`candleview-screenshot-${Date.now()}.png`,e.href=t,e.click()},onFullscreenClick:()=>{if(typeof window>"u"||typeof document>"u")return;const e=this.config.candleView.dom.getRootEl();if(!e)return;!!(document.fullscreenElement||document.webkitFullscreenElement||document.msFullscreenElement)?document.exitFullscreen?document.exitFullscreen():document.webkitExitFullscreen?document.webkitExitFullscreen():document.msExitFullscreen&&document.msExitFullscreen():e.requestFullscreen?e.requestFullscreen():e.webkitRequestFullscreen?e.webkitRequestFullscreen():e.msRequestFullscreen&&e.msRequestFullscreen()},onTimezoneSelect:t=>this.config.onTimezoneSelect(t)}))}initLeftPanel(){if(!this.config.drawingPanelContainer)return;this.leftPanel=new zc({container:this.config.drawingPanelContainer,theme:this.config.theme,i18n:this.config.i18n,state:this.leftPanelState,onStateChange:e=>{this.updateLeftPanelState(e),e.isBrushActive!==void 0&&(e.isBrushActive&&this.config.drawingPanelContainer?this.config.brushHint?.show(this.config.drawingPanelContainer):this.config.brushHint?.hide())},onToolSelect:e=>this.config.onToolSelect(e),chart:this.config.chartManager?.getChart()});const t=this.config.chartManager?.getChart();t&&(t.leftPanel=this.leftPanel)}updateTopPanelState(t){this.topPanelState={...this.topPanelState,...t}}updateLeftPanelState(t){this.leftPanelState={...this.leftPanelState,...t}}updateSubChartIndicatorsState(t){this.topPanel&&typeof this.topPanel.setSelectedSubChartIndicators=="function"&&this.topPanel.setSelectedSubChartIndicators(t)}getTopPanel(){return this.topPanel}updateTheme(t){this.topPanel?.updateTheme(t),this.leftPanel?.updateTheme(t)}updateI18n(t){this.topPanel?.updateI18n(t),this.leftPanel?.updateI18n(t)}destroy(){this.topPanel?.destroy(),this.leftPanel?.destroy(),this.topPanel=null,this.leftPanel=null}}class Qc{constructor(t,e,i){this.priceEventMarkManager=null,this.chartManager=t,this.dataManager=e,this.currentTheme=i}initManager(){const t=this.chartManager.getChart();!t||!t.chartSeries||(this.priceEventMarkManager=new oa({chartSeries:t.chartSeries,chart:t.chart,containerRef:t.containerRef?.current,onCloseDrawing:()=>{},onDoubleClick:()=>{}}))}register(t){const e=this.chartManager.getChart();if(!e||!e.chartSeries){console.warn("[CandleView] Chart not ready, will retry in 100ms"),setTimeout(()=>this.register(t),100);return}if(this.priceEventMarkManager||this.initManager(),!this.priceEventMarkManager){console.error("[CandleView] Failed to initialize PriceEventMarkManager");return}t.forEach(i=>{this.dataManager.addPriceEvent(i.price,i);const r={price:i.price,time:Date.now(),title:`Price: ${i.price}`,description:"",color:"#FF5722",backgroundColor:this.currentTheme.panel?.backgroundColor||"#1a1a2e",textColor:this.currentTheme.modal?.textColor||"#ffffff",fontSize:12,padding:8,arrowWidth:6,borderRadius:4,isPreview:!1,showPrice:!0},s=new na(r);e.chartSeries.series.attachPrimitive(s),this.priceEventMarkManager.priceEventMarks?.push(s),this.priceEventMarkManager.priceToMarkMap?.set(i.price,s)})}remove(t){if(this.priceEventMarkManager){const e=this.priceEventMarkManager.priceToMarkMap?.get(t);if(e){this.chartManager.getChart()?.chartSeries?.series.detachPrimitive(e),this.priceEventMarkManager.priceToMarkMap?.delete(t);const i=this.priceEventMarkManager.priceEventMarks?.indexOf(e);i>-1&&this.priceEventMarkManager.priceEventMarks?.splice(i,1)}}this.dataManager.removePriceEvent(t)}clearAll(){this.priceEventMarkManager&&(this.priceEventMarkManager.priceEventMarks?.forEach(t=>{this.chartManager.getChart()?.chartSeries?.series.detachPrimitive(t)}),this.priceEventMarkManager.priceEventMarks=[],this.priceEventMarkManager.priceToMarkMap?.clear()),this.dataManager.clearPriceEvents()}getAll(){return this.dataManager.getPriceEvents()}}class Gc{constructor(t,e){this.indicator=null,this.theme=t,this.i18n=e}injectStyles(){if(document.getElementById("candleview-brush-styles"))return;const t=document.createElement("style");t.id="candleview-brush-styles",t.textContent="@keyframes brush-pulse{0%{opacity:1;transform:scale(1)}50%{opacity:0.5;transform:scale(1.2)}100%{opacity:1;transform:scale(1)}}",document.head.appendChild(t)}show(t){if(this.indicator){this.indicator.style.display="flex";return}this.indicator=document.createElement("div"),this.indicator.className="candleview-brush-indicator",Object.assign(this.indicator.style,{position:"absolute",bottom:"38px",left:"60px",zIndex:"100",display:"flex",alignItems:"center",gap:"6px",padding:"4px 10px",borderRadius:"20px",fontSize:"12px",pointerEvents:"none",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',whiteSpace:"nowrap"}),this.indicator.innerHTML=`
1780
+ `,p.onmouseenter=()=>{p.style.background=t.buttonHover,p.style.transform="scale(1.05)",p.style.borderColor=t.panelBorder},p.onmouseleave=()=>{p.style.background="transparent",p.style.transform="scale(1)",p.style.borderColor="transparent"},p.onclick=()=>{this.setState({selectedEmoji:g.character}),this.options.onEmojiSelect?.(g.character),this.toolManager.handleDrawingToolSelect(this,"emoji"),this.closeModal("emoji")},u.appendChild(p)}),r.appendChild(u),this.emojiPickerRef=r,this.container.appendChild(r),this.bindOutsideClick(r,()=>this.closeModal("emoji"))}closeModal(t){const e={drawing:this.drawingModalRef,brush:this.brushModalRef,cursor:this.cursorModalRef,fibonacci:this.fibonacciModalRef,projectInfo:this.projectInfoModalRef,irregularShape:this.irregularShapeModalRef,textTool:this.textToolModalRef,aiTools:this.aiModalRef,script:this.scriptModalRef,emoji:this.emojiPickerRef};e[t]&&(e[t]?.remove(),e[t]=null),this.setState({isDrawingModalOpen:!1,isBrushModalOpen:!1,isCursorModalOpen:!1,isFibonacciModalOpen:!1,isProjectInfoModalOpen:!1,isIrregularShapeModalOpen:!1,isTextToolModalOpen:!1,isAIToolsModalOpen:!1,isScriptModalOpen:!1,isEmojiSelectPopUpOpen:!1,arrowButtonStates:{}})}closeAllModals(){this.closeModal("drawing"),this.closeModal("brush"),this.closeModal("cursor"),this.closeModal("fibonacci"),this.closeModal("projectInfo"),this.closeModal("irregularShape"),this.closeModal("textTool"),this.closeModal("aiTools"),this.closeModal("script"),this.closeModal("emoji"),this.setState({arrowButtonStates:{}}),this.element?.querySelectorAll(".arrow-button")?.forEach(e=>{e.innerHTML='<span style="font-size:18px;">›</span>'})}bindOutsideClick(t,e){const i=r=>{const s=r.target;t.contains(s)||s.closest(".tool-btn-drawing")||s.closest(".tool-btn-brush")||s.closest(".tool-btn-cursor")||s.closest(".tool-btn-fibonacci")||s.closest(".tool-btn-project-info")||s.closest(".tool-btn-irregular-shape")||s.closest(".tool-btn-text")||s.closest(".tool-btn-ai")||s.closest(".tool-btn-script")||s.closest(".tool-btn-emoji")||(e(),document.removeEventListener("click",i))};setTimeout(()=>{document.addEventListener("click",i)},0)}setActiveTool(t){if(t&&["emoji","text","price-event","time-event"].includes(t))return;const i=this.theme.getColors();this.element?.querySelectorAll(".tool-btn")?.forEach(s=>{const a=s;a.className.includes(`tool-btn-${t}`)?(a.style.background=i.buttonActive,a.style.color="#FFFFFF"):!a.className.includes("tool-btn-lock")&&!a.className.includes("tool-btn-eye")&&!a.className.includes("tool-btn-trash")&&!a.className.includes("tool-btn-terminal")&&(a.style.background="transparent",a.style.color=i.buttonColor)})}toggleLock(){this.setState({isMarkLocked:!this.state.isMarkLocked}),this.updateOtherTools()}toggleVisibility(){const t=!this.state.isMarkVisibility;this.setState({isMarkVisibility:t}),t?this.options.chart?.showAllMark?.():this.options.chart?.hideAllMark?.(),this.updateOtherTools()}updateOtherTools(){const t=this.element?.querySelector(".tool-btn-lock"),e=this.element?.querySelector(".tool-btn-eye");t&&(t.innerHTML=this.state.isMarkLocked?this.getIconSvg("lock"):this.getIconSvg("unlock")),e&&(e.innerHTML=this.state.isMarkVisibility?this.getIconSvg("eyeOpen"):this.getIconSvg("eyeClosed"))}getToolConfig(){return Yc(this.i18n)}findToolInGroups(t,e){for(const i of t){const r=i.tools.find(s=>s.id===e);if(r)return r}return null}getIconSvg(t){return{script:'<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M14 2H6C5.44772 2 5 2.44772 5 3V21C5 21.5523 5.44772 22 6 22H18C18.5523 22 19 21.5523 19 21V8L14 2Z"/><path d="M14 2V8H19"/><path d="M9 12H15"/><path d="M9 16H12"/></svg>',emoji:'<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><circle cx="12" cy="12" r="10"/><path d="M8 14s1.5 2 4 2 4-2 4-2"/><circle cx="9" cy="9" r="1" fill="currentColor"/><circle cx="15" cy="9" r="1" fill="currentColor"/></svg>',ai:'<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><ellipse cx="12" cy="20" rx="10" ry="3"/><circle cx="12" cy="10.5" r="8"/><path d="M7 8C9 6 15 6 17 8"/><circle cx="9" cy="9" r="1.5" fill="currentColor"/><path d="M12 5L14 2L16 5L19 6L16 7L14 10L12 7L9 6Z" fill="currentColor"/></svg>',terminal:'<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><rect x="3" y="4" width="18" height="16" rx="2"/><path d="M6 9L9 12L6 15"/><path d="M11 15H15"/></svg>',lock:'<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><rect x="3" y="10" width="18" height="12" rx="2"/><path d="M7 10V7C7 4.23858 9.23858 2 12 2C14.7614 2 17 4.23858 17 7V10"/><circle cx="12" cy="15" r="1" fill="currentColor"/><path d="M12 15V17"/></svg>',unlock:'<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><rect x="3" y="10" width="18" height="12" rx="2"/><path d="M7 10V7C7 4.23858 9.23858 2 12 2C14.7614 2 17 4.23858 17 7" stroke-dasharray="12 12"/><circle cx="12" cy="15" r="1" fill="currentColor"/><path d="M12 15V17"/></svg>',eyeOpen:'<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M1 12C1 12 5 4 12 4C19 4 23 12 23 12C23 12 19 20 12 20C5 20 1 12 1 12Z"/><circle cx="12" cy="12" r="3"/></svg>',eyeClosed:'<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M2 12C2 12 6 4 13 4C20 4 24 12 24 12C24 12 20 20 13 20C6 20 2 12 2 12Z"/><path d="M4.93 4.93L19.07 19.07"/><path d="M9.76 14.24C8.79 13.27 8.79 11.73 9.76 10.76C10.73 9.79 12.27 9.79 13.24 10.76"/></svg>',trash:'<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M3 6H5H21"/><path d="M8 6V4C8 3.44772 8.44772 3 9 3H15C15.5523 3 16 3.44772 16 4V6M19 6V20C19 20.5523 18.5523 21 18 21H6C5.44772 21 5 20.5523 5 20V6H19Z"/><path d="M10 11V17"/><path d="M14 11V17"/></svg>'}[t]||""}getModalTop(){const t=this.getContainerRect();return(this.element?.getBoundingClientRect()?.top||t.top)-t.top+50}updateContainerHeight(){if(this.element){const t=this.element.clientHeight;this.setState({containerHeight:t}),this.updateScrollButtons()}}updateScrollButtons(){if(this.scrollContainerRef){const{scrollTop:t,scrollHeight:e,clientHeight:i}=this.scrollContainerRef,r=t>10,s=t<e-i-10;this.state.scrollButtonVisibility={showTop:r,showBottom:s},this.updateScrollButtonsUI()}}updateScrollButtonsUI(){this.scrollTopBtn&&(this.scrollTopBtn.style.display=this.state.scrollButtonVisibility.showTop?"flex":"none"),this.scrollBottomBtn&&(this.scrollBottomBtn.style.display=this.state.scrollButtonVisibility.showBottom?"flex":"none")}bindEvents(){this.scrollContainerRef&&this.scrollContainerRef.addEventListener("scroll",()=>this.updateScrollButtons()),document.addEventListener("click",this.handleClickOutside)}setState(t){Object.assign(this.state,t),(t.isMarkLocked!==void 0||t.isMarkVisibility!==void 0)&&this.updateOtherTools()}updateTheme(t){this.theme=t;const e=t.getColors(),i=t.isDark(),r=i?e.buttonHover:"#E1E5E9",s=i?e.panelBorder:"#EEEEEE";if(this.element){const l=this.element.querySelector("div");l&&(l.style.background=e.panelBg,l.style.borderRightColor=e.panelBorder)}this.scrollContainerRef?.querySelectorAll("div")?.forEach(l=>{const c=l;c.style.height==="1px"&&(c.style.background=s)}),this.element?.querySelectorAll(".tool-btn")?.forEach(l=>{const c=l,d=c.style.background===e.buttonActive;d||(c.style.background="transparent"),c.style.color=d?"#FFFFFF":e.buttonColor,c.onmouseenter=()=>{d||(c.style.background=r)},c.onmouseleave=()=>{d||(c.style.background="transparent")}}),this.element?.querySelectorAll(".arrow-button")?.forEach(l=>{const c=l;c.style.background="transparent",c.style.color=e.buttonColor,c.onmouseenter=d=>{d.target.style.background=r},c.onmouseleave=d=>{d.target.style.background="transparent"}});const h=document.getElementById("candleview-scrollbar-styles");h&&h.remove(),this.injectScrollbarStyles(),this.closeAllModals()}updateI18n(t){this.i18n=t,this.closeAllModals()}destroy(){this.closeAllModals(),this.element?.remove(),document.removeEventListener("click",this.handleClickOutside)}updateState(t){Object.assign(this.state,t)}isMarkLocked(){return this.state.isMarkLocked}getContainerRect(){return this.container.getBoundingClientRect()}getState(){return this.state}}const la={isTimeframeModalOpen:!1,isIndicatorModalOpen:!1,isChartTypeModalOpen:!1,isSubChartModalOpen:!1,isTimezoneModalOpen:!1,isTimeFormatModalOpen:!1,isCloseTimeModalOpen:!1,isTradingDayModalOpen:!1,isAIModalOpen:!1,isMobileMenuOpen:!1,activeTimeframe:x.FIFTEEN_MINUTES,currentMainChartType:R.Candle,currentTimezone:Y.SHANGHAI,selectedSubChartIndicators:[],selectedMainChartIndicator:null,mainIndicatorsSearch:"",timezoneSearch:"",subChartIndicatorsSearch:"",chartTypeSearch:"",aiSearch:"",selectedMainIndicator:null,selectedChartMap:null,selectedSubIndicator:null,timeframeSections:{second:!0,minute:!0,hour:!0,day:!0,week:!0,month:!0},indicatorSections:{technicalIndicators:!0,chart:!0,subChartIndicators:!0},aiSections:{},scrollButtonVisibility:{showTop:!1,showBottom:!1},isDataLoading:!1,dataLoadProgress:0,loadError:null},ha={isDrawingModalOpen:!1,isEmojiSelectPopUpOpen:!1,isBrushModalOpen:!1,isCursorModalOpen:!1,isFibonacciModalOpen:!1,isProjectInfoModalOpen:!1,isIrregularShapeModalOpen:!1,isTextToolModalOpen:!1,isAIToolsModalOpen:!1,isScriptModalOpen:!1,selectedEmoji:"😀",selectedEmojiCategory:"smileys",selectedCursor:"crosshair",selectedAITool:null,selectedScriptTool:null,lastSelectedTools:{drawing:"line-segment",brush:"pencil",cursor:"crosshair",fibonacci:"fibonacci-retracement",projectInfo:"time-range",irregularShape:"rectangle",textTool:"text",aiTools:"describe-chart",script:"price-event"},arrowButtonStates:{},toolHoverStates:{},isMarkLocked:!1,isMarkVisibility:!0,toolSearch:"",containerHeight:0,scrollButtonVisibility:{showTop:!1,showBottom:!1},isBrushActive:!1};class $c{constructor(t){this.topPanel=null,this.leftPanel=null,this.topPanelState={...la},this.leftPanelState={...ha},this.config=t,this.topPanelState=t.topPanelState,this.leftPanelState=t.leftPanelState}init(){this.initTopPanel(),this.initLeftPanel()}initTopPanel(){this.config.technologyPanelContainer&&(this.topPanel=new Xc({container:this.config.technologyPanelContainer,rootContainer:this.config.rootContainer,theme:this.config.theme,i18n:this.config.i18n,state:this.topPanelState,activeTimeframe:this.topPanelState.activeTimeframe,activeMainChartType:this.topPanelState.currentMainChartType,currentTimezone:this.topPanelState.currentTimezone,onStateChange:t=>this.updateTopPanelState(t),onTimeframeSelect:t=>this.config.onTimeframeChange(t),onChartTypeSelect:t=>this.config.onChartTypeChange(t),onMainChartIndicatorSelect:t=>this.config.onMainChartIndicatorSelect(t),onSubChartIndicatorSelect:t=>this.config.onSubChartIndicatorSelect(t),onThemeToggle:()=>this.config.onThemeToggle(),onCameraClick:async()=>{if(typeof window>"u"||typeof document>"u")return;const t=await this.config.candleView.captureScreenshot(),e=document.createElement("a");e.download=`candleview-screenshot-${Date.now()}.png`,e.href=t,e.click()},onFullscreenClick:()=>{if(typeof window>"u"||typeof document>"u")return;const e=this.config.candleView.dom.getRootEl();if(!e)return;!!(document.fullscreenElement||document.webkitFullscreenElement||document.msFullscreenElement)?document.exitFullscreen?document.exitFullscreen():document.webkitExitFullscreen?document.webkitExitFullscreen():document.msExitFullscreen&&document.msExitFullscreen():e.requestFullscreen?e.requestFullscreen():e.webkitRequestFullscreen?e.webkitRequestFullscreen():e.msRequestFullscreen&&e.msRequestFullscreen()},onTimezoneSelect:t=>this.config.onTimezoneSelect(t)}))}initLeftPanel(){if(!this.config.drawingPanelContainer)return;this.leftPanel=new zc({container:this.config.drawingPanelContainer,theme:this.config.theme,i18n:this.config.i18n,state:this.leftPanelState,onStateChange:e=>{this.updateLeftPanelState(e),e.isBrushActive!==void 0&&(e.isBrushActive&&this.config.drawingPanelContainer?this.config.brushHint?.show(this.config.drawingPanelContainer):this.config.brushHint?.hide())},onToolSelect:e=>this.config.onToolSelect(e),chart:this.config.chartManager?.getChart()});const t=this.config.chartManager?.getChart();t&&(t.leftPanel=this.leftPanel)}updateTopPanelState(t){this.topPanelState={...this.topPanelState,...t}}updateLeftPanelState(t){this.leftPanelState={...this.leftPanelState,...t}}updateSubChartIndicatorsState(t){this.topPanel&&typeof this.topPanel.setSelectedSubChartIndicators=="function"&&this.topPanel.setSelectedSubChartIndicators(t)}getTopPanel(){return this.topPanel}updateTheme(t){this.topPanel?.updateTheme(t),this.leftPanel?.updateTheme(t)}updateI18n(t){this.topPanel?.updateI18n(t),this.leftPanel?.updateI18n(t)}destroy(){this.topPanel?.destroy(),this.leftPanel?.destroy(),this.topPanel=null,this.leftPanel=null}}class Qc{constructor(t,e,i){this.priceEventMarkManager=null,this.chartManager=t,this.dataManager=e,this.currentTheme=i}initManager(){const t=this.chartManager.getChart();!t||!t.chartSeries||(this.priceEventMarkManager=new oa({chartSeries:t.chartSeries,chart:t.chart,containerRef:t.containerRef?.current,onCloseDrawing:()=>{},onDoubleClick:()=>{}}))}register(t){const e=this.chartManager.getChart();if(!e||!e.chartSeries){console.warn("[CandleView] Chart not ready, will retry in 100ms"),setTimeout(()=>this.register(t),100);return}if(this.priceEventMarkManager||this.initManager(),!this.priceEventMarkManager){console.error("[CandleView] Failed to initialize PriceEventMarkManager");return}t.forEach(i=>{this.dataManager.addPriceEvent(i.price,i);const r={price:i.price,time:Date.now(),title:`Price: ${i.price}`,description:"",color:"#FF5722",backgroundColor:this.currentTheme.panel?.backgroundColor||"#1a1a2e",textColor:this.currentTheme.modal?.textColor||"#ffffff",fontSize:12,padding:8,arrowWidth:6,borderRadius:4,isPreview:!1,showPrice:!0},s=new na(r);e.chartSeries.series.attachPrimitive(s),this.priceEventMarkManager.priceEventMarks?.push(s),this.priceEventMarkManager.priceToMarkMap?.set(i.price,s)})}remove(t){if(this.priceEventMarkManager){const e=this.priceEventMarkManager.priceToMarkMap?.get(t);if(e){this.chartManager.getChart()?.chartSeries?.series.detachPrimitive(e),this.priceEventMarkManager.priceToMarkMap?.delete(t);const i=this.priceEventMarkManager.priceEventMarks?.indexOf(e);i>-1&&this.priceEventMarkManager.priceEventMarks?.splice(i,1)}}this.dataManager.removePriceEvent(t)}clearAll(){this.priceEventMarkManager&&(this.priceEventMarkManager.priceEventMarks?.forEach(t=>{this.chartManager.getChart()?.chartSeries?.series.detachPrimitive(t)}),this.priceEventMarkManager.priceEventMarks=[],this.priceEventMarkManager.priceToMarkMap?.clear()),this.dataManager.clearPriceEvents()}getAll(){return this.dataManager.getPriceEvents()}}class Gc{constructor(t,e){this.indicator=null,this.theme=t,this.i18n=e}injectStyles(){if(document.getElementById("candleview-brush-styles"))return;const t=document.createElement("style");t.id="candleview-brush-styles",t.textContent="@keyframes brush-pulse{0%{opacity:1;transform:scale(1)}50%{opacity:0.5;transform:scale(1.2)}100%{opacity:1;transform:scale(1)}}",document.head.appendChild(t)}show(t){if(this.indicator){this.indicator.style.display="flex";return}this.indicator=document.createElement("div"),this.indicator.className="candleview-brush-indicator",Object.assign(this.indicator.style,{position:"absolute",bottom:"38px",left:"60px",zIndex:"100",display:"flex",alignItems:"center",gap:"6px",padding:"4px 10px",borderRadius:"20px",fontSize:"12px",pointerEvents:"none",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',whiteSpace:"nowrap"}),this.indicator.innerHTML=`
1781
1781
  <span class="brush-pulse" style="display:inline-block;width:8px;height:8px;border-radius:50%;animation:brush-pulse 1.5s infinite;"></span>
1782
1782
  <span class="brush-text">${this.i18n.t("brushActive")||"Brush Mode"}</span>
1783
1783
  <span class="brush-hint" style="margin-left:4px;font-size:10px;opacity:0.7;">ESC</span>
1784
- `,this.updateTheme(),t.style.position="relative",t.appendChild(this.indicator)}hide(){this.indicator&&(this.indicator.style.display="none")}updateTheme(){if(!this.indicator)return;const t=this.theme.getColors();Object.assign(this.indicator.style,{background:t.panelBg,border:`1px solid ${t.panelBorder}`,color:t.textColor});const e=this.indicator.querySelector(".brush-pulse");e&&(e.style.background=this.theme.isDark()?"#FF6B35":"#E64A19")}updateI18n(t){this.i18n=t;const e=this.indicator?.querySelector(".brush-text");e&&(e.textContent=this.i18n.t("brushActive")||"Brush Mode")}}class Jc{constructor(t){this.panels=null,this.priceEvents=null,this.marks=null,this.brushHint=null,this.topPanelState={...la},this.leftPanelState={...ha},this.onTimeframeChangeCallback=null,this.isDataLoaded=!1,this.pendingData=null,this.config=t;const{container:e,isOwn:i}=this.resolveContainer(t);this.container=e,this.isOwnContainer=i,this.chartType=t.chartType||R.Candle,this.currentTimeframe=t.activeTimeframe||x.FIFTEEN_MINUTES,this.currentTimezone=t.currentTimezone||Y.NEW_YORK,this.topPanelState.activeTimeframe=this.currentTimeframe,this.topPanelState.currentTimezone=this.currentTimezone,this.topPanelState.currentMainChartType=this.chartType,this.theme=new zs(t.theme||"dark"),this.currentTheme=this.theme.isDark()?nt:ht,Ht(t.locale||"zh-cn"),this.i18n=ge(),this.dom=new Ma,this.initDOM(),this.candleViewChart=new Oc(this.dom.getChartContainerEl(),this.theme,this.i18n,this.chartType,t.title),this.candleViewChart.showLoader(),setTimeout(()=>{this.candleViewChart.updateLoaderProgress(5,"Creating DOM...")},1),this.dataManager=new _a(t.data||[],this.currentTimeframe,this.currentTimezone),setTimeout(()=>{this.candleViewChart.updateLoaderProgress(20,"Data Manager Initialized")},2),this.candleViewChart.init(this.dataManager.getPreprocessedData()),setTimeout(()=>{this.candleViewChart.updateLoaderProgress(35,"Chart Initialized")},3),this.initPanels(),setTimeout(()=>{this.candleViewChart.updateLoaderProgress(50,"Panels Initialized")},4),this.marks=new fa(this.candleViewChart),this.marks.setTimezone(this.currentTimezone),setTimeout(()=>{this.candleViewChart.updateLoaderProgress(65,"Marks Initialized")},5),this.brushHint=new Gc(this.theme,this.i18n),this.brushHint.injectStyles(),setTimeout(()=>{this.candleViewChart.updateLoaderProgress(80,"Brush Hint Initialized")},6),this.priceEvents=new Qc(this.candleViewChart,this.dataManager,this.currentTheme),setTimeout(()=>{this.candleViewChart.updateLoaderProgress(95,"Price Events Initialized")},7),this.isDataLoaded=!0,this.candleViewChart.updateLoaderProgress(100,"Ready"),setTimeout(()=>{this.candleViewChart.hideLoader()},200),window.addEventListener("resize",()=>this.handleResize())}resolveContainer(t){if(t.container)return{container:t.container,isOwn:!1};if(t.containerSelector){const e=document.querySelector(t.containerSelector);if(!e)throw new Error(`[CandleView] Container not found: ${t.containerSelector}`);return{container:e,isOwn:!1}}if(t.id){const e=document.getElementById(t.id);if(!e)throw new Error(`[CandleView] Container not found: #${t.id}`);return{container:e,isOwn:!1}}if(t.parent){const e=this.createAutoContainer();return t.parent.appendChild(e),{container:e,isOwn:!0}}if(t.parentSelector){const e=document.querySelector(t.parentSelector);if(!e)throw new Error(`[CandleView] Parent not found: ${t.parentSelector}`);const i=this.createAutoContainer();return e.appendChild(i),{container:i,isOwn:!0}}throw new Error("[CandleView] Must provide container, containerSelector, id, parent, or parentSelector")}createAutoContainer(){const t=document.createElement("div");return t.style.cssText="width:100%;height:100%;position:relative;overflow:hidden;",t}initDOM(){this.dom.create(this.container,this.theme.getColors())}initPanels(){this.panels=new $c({technologyPanelContainer:this.config.technologyPanel!==!1?this.dom.getTechnologyPanelContainer():null,drawingPanelContainer:this.config.drawingPanel!==!1?this.dom.getDrawingPanelContainer():null,rootContainer:this.dom.getRootEl(),theme:this.theme,i18n:this.i18n,chartManager:this.candleViewChart,dataManager:this.dataManager,brushHint:this.brushHint,marks:this.marks,candleView:this,onTimeframeChange:t=>this.handleTimeframeChange(t),onChartTypeChange:t=>this.handleChartTypeChange(t),onThemeToggle:()=>this.handleThemeToggle(),onToolSelect:t=>this.config.onToolSelect?.(t),onFullscreenClick:()=>this.config.onFullscreenClick?.(),onTimezoneSelect:t=>this.handleTimezoneSelect(t),onMainChartIndicatorSelect:t=>{this.candleViewChart.getChart()?.addOrUpdateMainChartIndicator(t),this.config.onMainChartIndicatorSelect?.(t)},onSubChartIndicatorSelect:t=>{const e=this.candleViewChart.getChart();if(!e)return;const i=this.getEnabledSubChartIndicators(),r=t.filter(a=>!i.includes(a));i.filter(a=>!t.includes(a)).forEach(a=>{e.removeSubChart(a)}),r.forEach(a=>{e.addSubChart(a,n=>{if(e){const o=e.chartPanesManager?.getParamsByIndicatorType(n)||[];e.openSubChartIndicatorsModal(o,n)}},n=>{e.removeSubChart(n),this.syncSubChartIndicatorState()})}),this.config.onSubChartIndicatorSelect?.(t)}}),this.panels.init()}handleTimeframeChange(t){this.onTimeframeChangeCallback?this.onTimeframeChangeCallback(this,t):(this.currentTimeframe=t,this.isDataLoaded&&(this.candleViewChart.showLoader(),this.candleViewChart.updateLoaderProgress(100,"changingTimeframe")),this.dataManager.setTimeframe(t),this.dataManager.refresh(),this.candleViewChart.setData(this.dataManager.getPreprocessedData()),setTimeout(()=>this.marks?.reapplyMarks(),100),this.isDataLoaded&&setTimeout(()=>{this.candleViewChart.hideLoader()},300),this.config.onTimeframeChange?.(t))}handleTimezoneSelect(t){this.currentTimezone=t,this.isDataLoaded&&(this.candleViewChart.showLoader(),this.candleViewChart.updateLoaderProgress(100,"changingTimezone")),this.dataManager.setTimezone(t),this.dataManager.refresh(),this.candleViewChart.setData(this.dataManager.getPreprocessedData()),this.marks?.setTimezone(t),setTimeout(()=>this.marks?.reapplyMarks(),100),this.isDataLoaded&&setTimeout(()=>{this.candleViewChart.hideLoader()},300),this.config.onTimezoneSelect?.(t)}handleChartTypeChange(t){this.chartType=t,this.isDataLoaded&&this.candleViewChart.updateChartType(t),this.config.onChartTypeChange?.(t)}handleThemeToggle(){const t=this.theme.isDark()?"light":"dark";this.theme.setTheme(t),this.currentTheme=this.theme.isDark()?nt:ht,this.dom.getRootEl()?.style.setProperty("background",this.theme.getColors().background),this.isDataLoaded&&this.candleViewChart.updateTheme(this.theme),this.brushHint?.updateTheme(),this.panels?.updateTheme(this.theme),this.config.onThemeToggle?.(t)}handleResize(){this.candleViewChart.getChart()?.handleResize()}setData(t,e=!1){if(!this.isDataLoaded){this.pendingData=t,this.dataManager.setData(t);return}e?(this.candleViewChart.showLoader(),this.candleViewChart.updateLoaderProgress(100,"loadingData"),this.dataManager.setData(t),this.candleViewChart.setData(this.dataManager.getPreprocessedData()),setTimeout(()=>{this.candleViewChart.hideLoader()},300)):(this.dataManager.setData(t),this.candleViewChart.setData(this.dataManager.getPreprocessedData()))}updateData(t){if(!this.isDataLoaded){this.pendingData=[...this.pendingData||[],...t],this.dataManager.appendData(t);return}const e=this.candleViewChart.getChart(),i=e?.getChart()?.timeScale().getVisibleLogicalRange();this.dataManager.appendData(t),this.candleViewChart.setData(this.dataManager.getPreprocessedData()),i&&e?.getChart()&&setTimeout(()=>e.getChart()?.timeScale().setVisibleLogicalRange(i),0)}setTheme(t){this.theme.setTheme(t),this.currentTheme=this.theme.isDark()?nt:ht,this.dom.getRootEl()?.style.setProperty("background",this.theme.getColors().background),this.isDataLoaded&&this.candleViewChart.updateTheme(this.theme),this.brushHint?.updateTheme(),this.panels?.updateTheme(this.theme)}setLocale(t){Ht(t),this.i18n=ge(),this.panels?.updateI18n(this.i18n),this.isDataLoaded&&this.candleViewChart.updateI18n(this.i18n),this.brushHint?.updateI18n(this.i18n)}setOnTimeframeChangeCallback(t){this.onTimeframeChangeCallback=t}getOnTimeframeChangeCallback(){return this.onTimeframeChangeCallback}setChartType(t){this.isDataLoaded&&this.candleViewChart.updateChartType(t)}getCurrentTheme(){return this.currentTheme}getTopPanelState(){return{...this.topPanelState}}getLeftPanelState(){return{...this.leftPanelState}}getDrawingState(){return this.candleViewChart.getChart()?.getDrawingState()||null}setCursorType(t){this.candleViewChart.getChart()?.setCursorType(t)}showAllMarks(){this.candleViewChart.getChart()?.showAllMark()}hideAllMarks(){this.candleViewChart.getChart()?.hideAllMark()}clearAllMarks(){this.candleViewChart.getChart()?.clearAllMark()}clearCurrentTool(){}getCurrentTool(){return null}registerPriceEvents(t){this.isDataLoaded&&this.priceEvents?.register(t)}removePriceEventMarker(t){this.priceEvents?.remove(t)}clearAllPriceEventMarkers(){this.priceEvents?.clearAll()}getPriceEvents(){return this.priceEvents?.getAll()||[]}addStaticMark(t,e,i,r,s){this.marks?.addStaticMark(t,e,i,r,s)}addStaticMarks(t){this.marks?.addStaticMarks(t)}addTextMark(t,e,i,r){this.marks?.addTextMark(t,e,i,r)}addArrowMark(t,e,i){this.marks?.addArrowMark(t,e,i)}addTextMarks(t){this.marks?.addTextMarks(t)}addArrowMarks(t){this.marks?.addArrowMarks(t)}clearAllStaticMarks(){this.marks?.clearAllStaticMarks()}getStaticMarkCount(){return this.marks?.getStaticMarkCount()||0}getChart(){return this.candleViewChart.getChart()}setTitle(t){this.getChart()?.setTitle(t)}openMainChartIndicator(t,e){const i=this.candleViewChart.getChart();if(!i||!this.isDataLoaded)return;let r=null;switch(t){case w.MA:r={...$s,nonce:Date.now()};break;case w.EMA:r={...Qs,nonce:Date.now()};break;case w.BOLLINGER:r={...Gs,nonce:Date.now()};break;case w.ICHIMOKU:r={...Js,nonce:Date.now()};break;case w.DONCHIAN:r={...Zs,nonce:Date.now()};break;case w.ENVELOPE:r={...ta,nonce:Date.now()};break;case w.VWAP:r={...ea,nonce:Date.now()};break;case w.HEATMAP:r={...ia,nonce:Date.now()};break;case w.MARKETPROFILE:r={...ra,nonce:Date.now()};break;default:return}e&&r&&(r.parameters={...r.parameters,...e}),r&&i.addOrUpdateMainChartIndicator(r)}closeMainChartIndicator(t){const e=this.candleViewChart.getChart();if(!(!e||!this.isDataLoaded)){if(t===w.HEATMAP){e.hideHeatMap(),e.removeMainChartIndicator(t);return}if(t===w.MARKETPROFILE){e.hideMarketProfile(),e.removeMainChartIndicator(t);return}e.removeMainChartIndicator(t)}}closeAllMainChartIndicators(){const t=this.candleViewChart.getChart();if(!t||!this.isDataLoaded)return;t.hideHeatMap(),t.removeMainChartIndicator(w.HEATMAP),t.hideMarketProfile(),t.removeMainChartIndicator(w.MARKETPROFILE),[w.MA,w.EMA,w.BOLLINGER,w.ICHIMOKU,w.DONCHIAN,w.ENVELOPE,w.VWAP].forEach(i=>{t.removeMainChartIndicator(i)})}openSubChartIndicator(t,e,i){const r=this.candleViewChart.getChart();!r||!this.isDataLoaded||(r.addSubChart(t,s=>{if(r){const a=r.chartPanesManager?.getParamsByIndicatorType(s)||[];r.openSubChartIndicatorsModal(a,s)}e?.(s)},s=>{r.removeSubChart(s),i?.(s)}),this.syncSubChartIndicatorState())}closeSubChartIndicator(t){const e=this.candleViewChart.getChart();!e||!this.isDataLoaded||(e.removeSubChart(t),this.syncSubChartIndicatorState())}closeAllSubChartIndicators(){const t=this.candleViewChart.getChart();if(!t||!this.isDataLoaded)return;[B.RSI,B.MACD,B.VOLUME,B.SAR,B.KDJ,B.ATR,B.STOCHASTIC,B.CCI,B.BBWIDTH,B.ADX,B.OBV].forEach(i=>{t.removeSubChart(i)}),this.syncSubChartIndicatorState()}syncSubChartIndicatorState(){const t=this.getEnabledSubChartIndicators();if(this.panels&&this.panels.topPanel){const e=this.panels.topPanel;e&&typeof e.setSelectedSubChartIndicators=="function"&&e.setSelectedSubChartIndicators(t)}}isMainChartIndicatorEnabled(t){const e=this.candleViewChart.getChart();return e?e.isMainChartIndicatorEnabled?.(t)??!1:!1}isSubChartIndicatorEnabled(t){const e=this.candleViewChart.getChart();return e?e.isSubChartIndicatorEnabled?.(t)??!1:!1}getEnabledMainChartIndicators(){const t=this.candleViewChart.getChart();return t?t.getEnabledMainChartIndicators?.()??[]:[]}getEnabledSubChartIndicators(){const t=this.candleViewChart.getChart();return t?t.getEnabledSubChartIndicators?.()??[]:[]}async captureScreenshot(t="CandleView",e=.15){const i=this.dom.getChartContainerEl();if(!i)throw new Error("[CandleView] Chart container not found");await new Promise(l=>setTimeout(l,100));const r=i.getBoundingClientRect(),s=document.createElement("canvas");s.width=r.width*devicePixelRatio,s.height=r.height*devicePixelRatio;const a=s.getContext("2d");a.scale(devicePixelRatio,devicePixelRatio),a.fillStyle=this.theme.getColors().background,a.fillRect(0,0,r.width,r.height);const n=i.querySelectorAll("canvas");for(let l=0;l<n.length;l++){const c=n[l],d=c.getBoundingClientRect();a.drawImage(c,d.left-r.left,d.top-r.top,d.width,d.height)}const o=Math.max(40,Math.min(r.width/8,80));a.font=`${o}px Arial, sans-serif`,a.textAlign="center",a.textBaseline="middle";const h=this.theme.isDark();return a.fillStyle=h?`rgba(255, 255, 255, ${e})`:`rgba(0, 0, 0, ${e})`,a.fillText(t,r.width/2,r.height/2),s.toDataURL("image/png")}destroy(){this.panels?.destroy(),this.candleViewChart.destroy(),this.marks?.destroy(),this.dom.destroy(),this.isOwnContainer&&this.container.parentNode&&this.container.remove(),window.removeEventListener("resize",()=>this.handleResize())}}exports.CandleView=Jc;exports.ChartType=ms;exports.CursorType=j;exports.Dark=nt;exports.DataPreprocessor=Ce;exports.DrawingType=C;exports.EN=sa;exports.Light=ht;exports.MainChartIndicatorType=w;exports.MainChartType=R;exports.ScriptType=ks;exports.StaticMarkDirection=bt;exports.StaticMarkType=Z;exports.SubChartIndicatorType=B;exports.TIMEFRAME_CONFIGS=Ss;exports.TIMEZONE_CONFIGS=Ps;exports.Theme=zs;exports.TimeframeEnum=x;exports.TimezoneEnum=Y;exports.drawingTypeName=se;exports.getI18n=ge;exports.setLocale=Ht;exports.zhCN=Kt;
1784
+ `,this.updateTheme(),t.style.position="relative",t.appendChild(this.indicator)}hide(){this.indicator&&(this.indicator.style.display="none")}updateTheme(){if(!this.indicator)return;const t=this.theme.getColors();Object.assign(this.indicator.style,{background:t.panelBg,border:`1px solid ${t.panelBorder}`,color:t.textColor});const e=this.indicator.querySelector(".brush-pulse");e&&(e.style.background=this.theme.isDark()?"#FF6B35":"#E64A19")}updateI18n(t){this.i18n=t;const e=this.indicator?.querySelector(".brush-text");e&&(e.textContent=this.i18n.t("brushActive")||"Brush Mode")}}class Jc{constructor(t){this.panels=null,this.priceEvents=null,this.marks=null,this.brushHint=null,this.topPanelState={...la},this.leftPanelState={...ha},this.onTimeframeChangeCallback=null,this.isDataLoaded=!1,this.pendingData=null,this.config=t;const{container:e,isOwn:i}=this.resolveContainer(t);this.container=e,this.isOwnContainer=i,this.chartType=t.chartType||R.Candle,this.currentTimeframe=t.timeframe||x.FIFTEEN_MINUTES,this.currentTimezone=t.timezone||Y.NEW_YORK,this.topPanelState.activeTimeframe=this.currentTimeframe,this.topPanelState.currentTimezone=this.currentTimezone,this.topPanelState.currentMainChartType=this.chartType,this.theme=new zs(t.theme||"dark"),this.currentTheme=this.theme.isDark()?nt:ht,Ht(t.locale||"zh-cn"),this.i18n=ge(),this.dom=new Ma,this.initDOM(),this.candleViewChart=new Oc(this.dom.getChartContainerEl(),this.theme,this.i18n,this.chartType,t.title),this.candleViewChart.showLoader(),setTimeout(()=>{this.candleViewChart.updateLoaderProgress(5,"Creating DOM...")},1),this.dataManager=new _a(t.data||[],this.currentTimeframe,this.currentTimezone),setTimeout(()=>{this.candleViewChart.updateLoaderProgress(20,"Data Manager Initialized")},2),this.candleViewChart.init(this.dataManager.getPreprocessedData()),setTimeout(()=>{this.candleViewChart.updateLoaderProgress(35,"Chart Initialized")},3),this.initPanels(),setTimeout(()=>{this.candleViewChart.updateLoaderProgress(50,"Panels Initialized")},4),this.marks=new fa(this.candleViewChart),this.marks.setTimezone(this.currentTimezone),setTimeout(()=>{this.candleViewChart.updateLoaderProgress(65,"Marks Initialized")},5),this.brushHint=new Gc(this.theme,this.i18n),this.brushHint.injectStyles(),setTimeout(()=>{this.candleViewChart.updateLoaderProgress(80,"Brush Hint Initialized")},6),this.priceEvents=new Qc(this.candleViewChart,this.dataManager,this.currentTheme),setTimeout(()=>{this.candleViewChart.updateLoaderProgress(95,"Price Events Initialized")},7),this.isDataLoaded=!0,this.candleViewChart.updateLoaderProgress(100,"Ready"),setTimeout(()=>{this.candleViewChart.hideLoader()},200),window.addEventListener("resize",()=>this.handleResize())}resolveContainer(t){if(t.container)return{container:t.container,isOwn:!1};if(t.containerSelector){const e=document.querySelector(t.containerSelector);if(!e)throw new Error(`[CandleView] Container not found: ${t.containerSelector}`);return{container:e,isOwn:!1}}if(t.id){const e=document.getElementById(t.id);if(!e)throw new Error(`[CandleView] Container not found: #${t.id}`);return{container:e,isOwn:!1}}if(t.parent){const e=this.createAutoContainer();return t.parent.appendChild(e),{container:e,isOwn:!0}}if(t.parentSelector){const e=document.querySelector(t.parentSelector);if(!e)throw new Error(`[CandleView] Parent not found: ${t.parentSelector}`);const i=this.createAutoContainer();return e.appendChild(i),{container:i,isOwn:!0}}throw new Error("[CandleView] Must provide container, containerSelector, id, parent, or parentSelector")}createAutoContainer(){const t=document.createElement("div");return t.style.cssText="width:100%;height:100%;overflow:hidden;",t}initDOM(){this.dom.create(this.container,this.theme.getColors())}initPanels(){this.panels=new $c({technologyPanelContainer:this.config.technologyPanel!==!1?this.dom.getTechnologyPanelContainer():null,drawingPanelContainer:this.config.drawingPanel!==!1?this.dom.getDrawingPanelContainer():null,rootContainer:this.dom.getRootEl(),theme:this.theme,i18n:this.i18n,chartManager:this.candleViewChart,dataManager:this.dataManager,brushHint:this.brushHint,marks:this.marks,candleView:this,topPanelState:this.topPanelState,leftPanelState:this.leftPanelState,onTimeframeChange:t=>this.handleTimeframeChange(t),onChartTypeChange:t=>this.handleChartTypeChange(t),onThemeToggle:()=>this.handleThemeToggle(),onToolSelect:t=>this.config.onToolSelect?.(t),onFullscreenClick:()=>this.config.onFullscreenClick?.(),onTimezoneSelect:t=>this.handleTimezoneSelect(t),onMainChartIndicatorSelect:t=>{this.candleViewChart.getChart()?.addOrUpdateMainChartIndicator(t),this.config.onMainChartIndicatorSelect?.(t)},onSubChartIndicatorSelect:t=>{const e=this.candleViewChart.getChart();if(!e)return;const i=this.getEnabledSubChartIndicators(),r=t.filter(a=>!i.includes(a));i.filter(a=>!t.includes(a)).forEach(a=>{e.removeSubChart(a)}),r.forEach(a=>{e.addSubChart(a,n=>{if(e){const o=e.chartPanesManager?.getParamsByIndicatorType(n)||[];e.openSubChartIndicatorsModal(o,n)}},n=>{e.removeSubChart(n),this.syncSubChartIndicatorState()})}),this.config.onSubChartIndicatorSelect?.(t)}}),this.panels.init()}handleTimeframeChange(t){this.onTimeframeChangeCallback?this.onTimeframeChangeCallback(this,t):(this.currentTimeframe=t,this.isDataLoaded&&(this.candleViewChart.showLoader(),this.candleViewChart.updateLoaderProgress(100,"changingTimeframe")),this.dataManager.setTimeframe(t),this.dataManager.refresh(),this.candleViewChart.setData(this.dataManager.getPreprocessedData()),setTimeout(()=>this.marks?.reapplyMarks(),100),this.isDataLoaded&&setTimeout(()=>{this.candleViewChart.hideLoader()},300),this.config.onTimeframeChange?.(t))}handleTimezoneSelect(t){this.currentTimezone=t,this.isDataLoaded&&(this.candleViewChart.showLoader(),this.candleViewChart.updateLoaderProgress(100,"changingTimezone")),this.dataManager.setTimezone(t),this.dataManager.refresh(),this.candleViewChart.setData(this.dataManager.getPreprocessedData()),this.marks?.setTimezone(t),setTimeout(()=>this.marks?.reapplyMarks(),100),this.isDataLoaded&&setTimeout(()=>{this.candleViewChart.hideLoader()},300),this.config.onTimezoneSelect?.(t)}handleChartTypeChange(t){this.chartType=t,this.isDataLoaded&&this.candleViewChart.updateChartType(t),this.config.onChartTypeChange?.(t)}handleThemeToggle(){const t=this.theme.isDark()?"light":"dark";this.theme.setTheme(t),this.currentTheme=this.theme.isDark()?nt:ht,this.dom.getRootEl()?.style.setProperty("background",this.theme.getColors().background),this.isDataLoaded&&this.candleViewChart.updateTheme(this.theme),this.brushHint?.updateTheme(),this.panels?.updateTheme(this.theme),this.config.onThemeToggle?.(t)}handleResize(){this.candleViewChart.getChart()?.handleResize()}setData(t,e=!1){if(!this.isDataLoaded){this.pendingData=t,this.dataManager.setData(t);return}e?(this.candleViewChart.showLoader(),this.candleViewChart.updateLoaderProgress(100,"loadingData"),this.dataManager.setData(t),this.candleViewChart.setData(this.dataManager.getPreprocessedData()),setTimeout(()=>{this.candleViewChart.hideLoader()},300)):(this.dataManager.setData(t),this.candleViewChart.setData(this.dataManager.getPreprocessedData()))}updateData(t){if(!this.isDataLoaded){this.pendingData=[...this.pendingData||[],...t],this.dataManager.appendData(t);return}const e=this.candleViewChart.getChart(),i=e?.getChart()?.timeScale().getVisibleLogicalRange();this.dataManager.appendData(t),this.candleViewChart.setData(this.dataManager.getPreprocessedData()),i&&e?.getChart()&&setTimeout(()=>e.getChart()?.timeScale().setVisibleLogicalRange(i),0)}setTheme(t){this.theme.setTheme(t),this.currentTheme=this.theme.isDark()?nt:ht,this.dom.getRootEl()?.style.setProperty("background",this.theme.getColors().background),this.isDataLoaded&&this.candleViewChart.updateTheme(this.theme),this.brushHint?.updateTheme(),this.panels?.updateTheme(this.theme)}setLocale(t){Ht(t),this.i18n=ge(),this.panels?.updateI18n(this.i18n),this.isDataLoaded&&this.candleViewChart.updateI18n(this.i18n),this.brushHint?.updateI18n(this.i18n)}setOnTimeframeChangeCallback(t){this.onTimeframeChangeCallback=t}getOnTimeframeChangeCallback(){return this.onTimeframeChangeCallback}setChartType(t){this.isDataLoaded&&this.candleViewChart.updateChartType(t)}getCurrentTheme(){return this.currentTheme}getTopPanelState(){return{...this.topPanelState}}getLeftPanelState(){return{...this.leftPanelState}}getDrawingState(){return this.candleViewChart.getChart()?.getDrawingState()||null}setCursorType(t){this.candleViewChart.getChart()?.setCursorType(t)}showAllMarks(){this.candleViewChart.getChart()?.showAllMark()}hideAllMarks(){this.candleViewChart.getChart()?.hideAllMark()}clearAllMarks(){this.candleViewChart.getChart()?.clearAllMark()}clearCurrentTool(){}getCurrentTool(){return null}registerPriceEvents(t){this.isDataLoaded&&this.priceEvents?.register(t)}removePriceEventMarker(t){this.priceEvents?.remove(t)}clearAllPriceEventMarkers(){this.priceEvents?.clearAll()}getPriceEvents(){return this.priceEvents?.getAll()||[]}addStaticMark(t,e,i,r,s){this.marks?.addStaticMark(t,e,i,r,s)}addStaticMarks(t){this.marks?.addStaticMarks(t)}addTextMark(t,e,i,r){this.marks?.addTextMark(t,e,i,r)}addArrowMark(t,e,i){this.marks?.addArrowMark(t,e,i)}addTextMarks(t){this.marks?.addTextMarks(t)}addArrowMarks(t){this.marks?.addArrowMarks(t)}clearAllStaticMarks(){this.marks?.clearAllStaticMarks()}getStaticMarkCount(){return this.marks?.getStaticMarkCount()||0}getChart(){return this.candleViewChart.getChart()}setTitle(t){this.getChart()?.setTitle(t)}openMainChartIndicator(t,e){const i=this.candleViewChart.getChart();if(!i||!this.isDataLoaded)return;let r=null;switch(t){case w.MA:r={...$s,nonce:Date.now()};break;case w.EMA:r={...Qs,nonce:Date.now()};break;case w.BOLLINGER:r={...Gs,nonce:Date.now()};break;case w.ICHIMOKU:r={...Js,nonce:Date.now()};break;case w.DONCHIAN:r={...Zs,nonce:Date.now()};break;case w.ENVELOPE:r={...ta,nonce:Date.now()};break;case w.VWAP:r={...ea,nonce:Date.now()};break;case w.HEATMAP:r={...ia,nonce:Date.now()};break;case w.MARKETPROFILE:r={...ra,nonce:Date.now()};break;default:return}e&&r&&(r.parameters={...r.parameters,...e}),r&&i.addOrUpdateMainChartIndicator(r)}closeMainChartIndicator(t){const e=this.candleViewChart.getChart();if(!(!e||!this.isDataLoaded)){if(t===w.HEATMAP){e.hideHeatMap(),e.removeMainChartIndicator(t);return}if(t===w.MARKETPROFILE){e.hideMarketProfile(),e.removeMainChartIndicator(t);return}e.removeMainChartIndicator(t)}}closeAllMainChartIndicators(){const t=this.candleViewChart.getChart();if(!t||!this.isDataLoaded)return;t.hideHeatMap(),t.removeMainChartIndicator(w.HEATMAP),t.hideMarketProfile(),t.removeMainChartIndicator(w.MARKETPROFILE),[w.MA,w.EMA,w.BOLLINGER,w.ICHIMOKU,w.DONCHIAN,w.ENVELOPE,w.VWAP].forEach(i=>{t.removeMainChartIndicator(i)})}openSubChartIndicator(t,e,i){const r=this.candleViewChart.getChart();!r||!this.isDataLoaded||(r.addSubChart(t,s=>{if(r){const a=r.chartPanesManager?.getParamsByIndicatorType(s)||[];r.openSubChartIndicatorsModal(a,s)}e?.(s)},s=>{r.removeSubChart(s),i?.(s)}),this.syncSubChartIndicatorState())}closeSubChartIndicator(t){const e=this.candleViewChart.getChart();!e||!this.isDataLoaded||(e.removeSubChart(t),this.syncSubChartIndicatorState())}closeAllSubChartIndicators(){const t=this.candleViewChart.getChart();if(!t||!this.isDataLoaded)return;[B.RSI,B.MACD,B.VOLUME,B.SAR,B.KDJ,B.ATR,B.STOCHASTIC,B.CCI,B.BBWIDTH,B.ADX,B.OBV].forEach(i=>{t.removeSubChart(i)}),this.syncSubChartIndicatorState()}syncSubChartIndicatorState(){const t=this.getEnabledSubChartIndicators();if(this.panels&&this.panels.topPanel){const e=this.panels.topPanel;e&&typeof e.setSelectedSubChartIndicators=="function"&&e.setSelectedSubChartIndicators(t)}}isMainChartIndicatorEnabled(t){const e=this.candleViewChart.getChart();return e?e.isMainChartIndicatorEnabled?.(t)??!1:!1}isSubChartIndicatorEnabled(t){const e=this.candleViewChart.getChart();return e?e.isSubChartIndicatorEnabled?.(t)??!1:!1}getEnabledMainChartIndicators(){const t=this.candleViewChart.getChart();return t?t.getEnabledMainChartIndicators?.()??[]:[]}getEnabledSubChartIndicators(){const t=this.candleViewChart.getChart();return t?t.getEnabledSubChartIndicators?.()??[]:[]}async captureScreenshot(t="CandleView",e=.15){const i=this.dom.getChartContainerEl();if(!i)throw new Error("[CandleView] Chart container not found");await new Promise(l=>setTimeout(l,100));const r=i.getBoundingClientRect(),s=document.createElement("canvas");s.width=r.width*devicePixelRatio,s.height=r.height*devicePixelRatio;const a=s.getContext("2d");a.scale(devicePixelRatio,devicePixelRatio),a.fillStyle=this.theme.getColors().background,a.fillRect(0,0,r.width,r.height);const n=i.querySelectorAll("canvas");for(let l=0;l<n.length;l++){const c=n[l],d=c.getBoundingClientRect();a.drawImage(c,d.left-r.left,d.top-r.top,d.width,d.height)}const o=Math.max(40,Math.min(r.width/8,80));a.font=`${o}px Arial, sans-serif`,a.textAlign="center",a.textBaseline="middle";const h=this.theme.isDark();return a.fillStyle=h?`rgba(255, 255, 255, ${e})`:`rgba(0, 0, 0, ${e})`,a.fillText(t,r.width/2,r.height/2),s.toDataURL("image/png")}destroy(){this.panels?.destroy(),this.candleViewChart.destroy(),this.marks?.destroy(),this.dom.destroy(),this.isOwnContainer&&this.container.parentNode&&this.container.remove(),window.removeEventListener("resize",()=>this.handleResize())}}exports.CandleView=Jc;exports.ChartType=ms;exports.CursorType=j;exports.Dark=nt;exports.DataPreprocessor=Ce;exports.DrawingType=C;exports.EN=sa;exports.Light=ht;exports.MainChartIndicatorType=w;exports.MainChartType=R;exports.ScriptType=ks;exports.StaticMarkDirection=bt;exports.StaticMarkType=Z;exports.SubChartIndicatorType=B;exports.TIMEFRAME_CONFIGS=Ss;exports.TIMEZONE_CONFIGS=Ps;exports.Theme=zs;exports.TimeframeEnum=x;exports.TimezoneEnum=Y;exports.drawingTypeName=se;exports.getI18n=ge;exports.setLocale=Ht;exports.zhCN=Kt;
package/dist/index.mjs CHANGED
@@ -726,7 +726,7 @@ class pa {
726
726
  this.rootEl = null, this.chartContainerEl = null, this.technologyPanelContainer = null, this.drawingPanelContainer = null;
727
727
  }
728
728
  create(t, e) {
729
- t.innerHTML = "", t.style.cssText = "position:relative;width:100%;height:100%;overflow:hidden;";
729
+ t.innerHTML = "";
730
730
  const i = document.createElement("style");
731
731
  i.id = "candleview-no-select", i.textContent = `
732
732
  .candleview-root,
@@ -57482,7 +57482,7 @@ const ia = {
57482
57482
  };
57483
57483
  class $c {
57484
57484
  constructor(t) {
57485
- this.topPanel = null, this.leftPanel = null, this.topPanelState = { ...ia }, this.leftPanelState = { ...ra }, this.config = t;
57485
+ this.topPanel = null, this.leftPanel = null, this.topPanelState = { ...ia }, this.leftPanelState = { ...ra }, this.config = t, this.topPanelState = t.topPanelState, this.leftPanelState = t.leftPanelState;
57486
57486
  }
57487
57487
  init() {
57488
57488
  this.initTopPanel(), this.initLeftPanel();
@@ -57679,7 +57679,7 @@ class Zc {
57679
57679
  constructor(t) {
57680
57680
  this.panels = null, this.priceEvents = null, this.marks = null, this.brushHint = null, this.topPanelState = { ...ia }, this.leftPanelState = { ...ra }, this.onTimeframeChangeCallback = null, this.isDataLoaded = !1, this.pendingData = null, this.config = t;
57681
57681
  const { container: e, isOwn: i } = this.resolveContainer(t);
57682
- this.container = e, this.isOwnContainer = i, this.chartType = t.chartType || R.Candle, this.currentTimeframe = t.activeTimeframe || E.FIFTEEN_MINUTES, this.currentTimezone = t.currentTimezone || Y.NEW_YORK, this.topPanelState.activeTimeframe = this.currentTimeframe, this.topPanelState.currentTimezone = this.currentTimezone, this.topPanelState.currentMainChartType = this.chartType, this.theme = new Jo(t.theme || "dark"), this.currentTheme = this.theme.isDark() ? lt : ut, de(t.locale || "zh-cn"), this.i18n = ii(), this.dom = new pa(), this.initDOM(), this.candleViewChart = new Oc(this.dom.getChartContainerEl(), this.theme, this.i18n, this.chartType, t.title), this.candleViewChart.showLoader(), setTimeout(() => {
57682
+ this.container = e, this.isOwnContainer = i, this.chartType = t.chartType || R.Candle, this.currentTimeframe = t.timeframe || E.FIFTEEN_MINUTES, this.currentTimezone = t.timezone || Y.NEW_YORK, this.topPanelState.activeTimeframe = this.currentTimeframe, this.topPanelState.currentTimezone = this.currentTimezone, this.topPanelState.currentMainChartType = this.chartType, this.theme = new Jo(t.theme || "dark"), this.currentTheme = this.theme.isDark() ? lt : ut, de(t.locale || "zh-cn"), this.i18n = ii(), this.dom = new pa(), this.initDOM(), this.candleViewChart = new Oc(this.dom.getChartContainerEl(), this.theme, this.i18n, this.chartType, t.title), this.candleViewChart.showLoader(), setTimeout(() => {
57683
57683
  this.candleViewChart.updateLoaderProgress(5, "Creating DOM...");
57684
57684
  }, 1), this.dataManager = new Pa(
57685
57685
  t.data || [],
@@ -57727,7 +57727,7 @@ class Zc {
57727
57727
  }
57728
57728
  createAutoContainer() {
57729
57729
  const t = document.createElement("div");
57730
- return t.style.cssText = "width:100%;height:100%;position:relative;overflow:hidden;", t;
57730
+ return t.style.cssText = "width:100%;height:100%;overflow:hidden;", t;
57731
57731
  }
57732
57732
  initDOM() {
57733
57733
  this.dom.create(this.container, this.theme.getColors());
@@ -57744,6 +57744,8 @@ class Zc {
57744
57744
  brushHint: this.brushHint,
57745
57745
  marks: this.marks,
57746
57746
  candleView: this,
57747
+ topPanelState: this.topPanelState,
57748
+ leftPanelState: this.leftPanelState,
57747
57749
  onTimeframeChange: (t) => this.handleTimeframeChange(t),
57748
57750
  onChartTypeChange: (t) => this.handleChartTypeChange(t),
57749
57751
  onThemeToggle: () => this.handleThemeToggle(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@candleview/core",
3
- "version": "3.0.2",
3
+ "version": "3.0.5",
4
4
  "description": "A time-series data visualization and charting engine designed specifically for the financial industry.",
5
5
  "keywords": [
6
6
  "Finance",