acttrader-charts 1.3.0-beta.2 → 1.3.0-beta.21
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/README.md +405 -16
- package/dist/{MACD-D1i-sEFR.d.cts → MACD-B6SoR6iH.d.cts} +486 -18
- package/dist/{MACD-D1i-sEFR.d.ts → MACD-B6SoR6iH.d.ts} +486 -18
- package/dist/index.cjs +3792 -448
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +679 -18
- package/dist/index.d.ts +679 -18
- package/dist/index.js +3702 -374
- package/dist/index.js.map +1 -1
- package/dist/indicators/index.d.cts +2 -2
- package/dist/indicators/index.d.ts +2 -2
- package/dist/webview/chart.html +90 -82
- package/package.json +1 -1
package/dist/webview/chart.html
CHANGED
|
@@ -37,9 +37,9 @@
|
|
|
37
37
|
</head>
|
|
38
38
|
<body>
|
|
39
39
|
<div id="chart"></div>
|
|
40
|
-
<script>(function(){var e=`data:image/svg+xml,%3csvg%20width='32'%20height='32'%20viewBox='0%200%2032%2032'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%3e%3cmask%20id='mask0'%20mask-type='alpha'%20maskUnits='userSpaceOnUse'%20x='0'%20y='0'%20width='32'%20height='32'%3e%3crect%20width='32'%20height='32'%20fill='%23C4C4C4'/%3e%3c/mask%3e%3cg%20mask='url(%23mask0)'%3e%3crect%20width='82.6667'%20height='32'%20fill='url(%23pattern0)'/%3e%3c/g%3e%3cdefs%3e%3cpattern%20id='pattern0'%20patternContentUnits='objectBoundingBox'%20width='1'%20height='1'%3e%3cuse%20xlink:href='%23image0'%20transform='translate(0%20-0.015879)%20scale(0.00304878%200.00787602)'/%3e%3c/pattern%3e%3cimage%20id='image0'%20width='328'%20height='131'%20xlink:href='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAUgAAACDCAYAAADvTILwAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWF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u6QboGIqEqFo9kCjnqIW46fP0XvGSLLe89oEhKYCE3rPa8X4rPtT5OJ2nvmnbZP1mEeLJtO1rBrFYrSFlY0Ab3Wevl3h7WB1zNf6YsvFOYreJtYo6KuuM++DY7cWY8ntPlp72RiB14YtDWi4Zit6+5cI6FxYXGR2RAE2ksaxWAY1YTcHu661Nehnwd/ENAf65xGsdSNNTJEBLePmyWQOgaATUxNJNLdVo693DmvXq9+59oaG1Cfv7b6L81xFefsS/OWuZDprjdlt+szKfZ2rc+BC7It5Om9FaXvQ0TKbXLf2W/pgsYKvXaDLx37/7mXsgaNnONfzGb04h/CkC3wcr2H5mMtLck/N/2OvYWawFb5wRY4VgDy7wZwj158GpO5GacjIvgtsR9tSJq1Hl3GanC8wMTAc0I77fGyn7wWAPOM9NRcEXAHHK3es3PuzG6Paw1pbxhr1dfZl5l/IMV0GkM3ab+bOc585zdY5jYsbhP5eu6c5S9lfp5UH5cplkPtWLsPKWBml4/8LMACJdZs7j1kabAAAAABJRU5ErkJggg=='/%3e%3c/defs%3e%3c/svg%3e`,t=class{constructor(){this.bars=[]}set(e){this.bars=[...e].sort((e,t)=>e.time-t.time)}get all(){return this.bars}get length(){return this.bars.length}getVisible(e){let t=Math.max(0,Math.floor(e.startIndex)),n=Math.min(this.bars.length-1,Math.ceil(e.endIndex));return this.bars.slice(t,n+1)}getPriceRange(e,t=.05){let n=this.getVisible(e);if(n.length===0)return{min:0,max:1};let r=1/0,i=-1/0;for(let e of n)e.low<r&&(r=e.low),e.high>i&&(i=e.high);let a=i-r;return{min:r-a*t,max:i+a*t}}getVolumeRange(e){let t=this.getVisible(e);return t.length===0?{min:0,max:1}:{min:0,max:Math.max(...t.map(e=>{var t;return(t=e.volume)==null?0:t}))}}get hasVolumeData(){return this.bars.some(e=>{var t;return`volume`in e&&((t=e.volume)==null?0:t)>0})}getPricePrecision(){let e=2;for(let t of this.bars)for(let n of[t.open,t.high,t.low,t.close]){let t=n.toString(),r=t.indexOf(`.`);if(r!==-1){let n=t.length-r-1;n>e&&(e=n)}}return Math.min(e,8)}prepend(e){var t,n;let r=(t=(n=this.bars[0])==null?void 0:n.time)==null?1/0:t,i=e.filter(e=>e.time<r).sort((e,t)=>e.time-t.time);return i.length===0?0:(this.bars=[...i,...this.bars],i.length)}},n,r=class e{xToPixel(e,t,n){let r=n/Math.max(1,t.endIndex-t.startIndex);return(e-t.startIndex)*r+r/2}pixelToBarIndex(e,t,n){let r=n/Math.max(1,t.endIndex-t.startIndex);return t.startIndex+e/r-.5}candleBodyWidth(e,t){let n=t/Math.max(1,e.endIndex-e.startIndex)*.7;return Math.max(1,Math.min(n,40))}yToPixel(t,n,r){let{min:i,max:a}=n,o=e.VERTICAL_PADDING_PX,s=r-2*o;return o+s-(t-i)/(a-i)*s}pixelToPrice(t,n,r){let{min:i,max:a}=n,o=e.VERTICAL_PADDING_PX,s=r-2*o;return a-(t-o)/s*(a-i)}volumeToPixel(e,t,n){return n-e/t*n*.9}};n=r,n.VERTICAL_PADDING_PX=20;function i(e){if(!isFinite(e)||e<=0)return 1;let t=10**Math.floor(Math.log10(e)),n=e/t;return(n<1.5?1:n<3.5?2:n<7.5?5:10)*t}function a(e,t,n=48){let{min:r,max:a}=e;if(!isFinite(r)||!isFinite(a)||a<=r)return[r];let o=Math.max(2,Math.floor(t/n)),s=i((a-r)/o),c=Math.ceil(r/s)*s,l=[],u=s*1e-6;for(let e=c;e<=a+u;e+=s)l.push(e);return l}function o(e,t=0){return!isFinite(e)||e<=0?t:Math.max(t,-Math.floor(Math.log10(e)))}var s=class{constructor(){this.listeners=new Map}on(e,t){return this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(t),()=>this.off(e,t)}off(e,t){var n;(n=this.listeners.get(e))==null||n.delete(t)}emit(e,t){var n;(n=this.listeners.get(e))==null||n.forEach(e=>e(t))}};function c(e,t){var n,r,i,a,o,s;return t?{background:(n=t.background)==null?e.background:n,grid:(r=t.grid)==null?e.grid:r,axisText:(i=t.axisText)==null?e.axisText:i,axisBorder:(a=t.axisBorder)==null?e.axisBorder:a,crosshair:(o=t.crosshair)==null?e.crosshair:o,tooltip:{...e.tooltip,...t.tooltip},candle:{...e.candle,...t.candle},volume:{...e.volume,...t.volume},ui:{...e.ui,...t.ui,stream:{...e.ui.stream,...(s=t.ui)==null?void 0:s.stream}},drawingToolbar:{...e.drawingToolbar,...t.drawingToolbar},topBar:{...e.topBar,...t.topBar},bottomBar:{...e.bottomBar,...t.bottomBar},indicatorOverlay:{...e.indicatorOverlay,...t.indicatorOverlay},tradeLevels:{...e.tradeLevels,...t.tradeLevels},tradePanel:{...e.tradePanel,...t.tradePanel},drawing:l(e.drawing,t.drawing)}:e}function l(e,t){if(!t)return e;let n={...e};for(let r of Object.keys(t)){let i=t[r];i&&(n[r]={...e[r],...i})}return n}function u(e,t){let n=document.createElement(`div`);n.style.display=`none`,t.appendChild(n);let r=e=>e.includes(`var(`)?(e=e.replace(/rgba\(\s*(var\([^)]+\))\s*,\s*([0-9.]+)\s*\)/g,`rgb($1 / $2)`),n.style.color=``,n.style.color=e,getComputedStyle(n).color||e):e,i={background:r(e.background),grid:r(e.grid),axisText:r(e.axisText),axisBorder:r(e.axisBorder),crosshair:r(e.crosshair),tooltip:{background:r(e.tooltip.background),text:r(e.tooltip.text),border:r(e.tooltip.border)},candle:{up:r(e.candle.up),down:r(e.candle.down),wickUp:r(e.candle.wickUp),wickDown:r(e.candle.wickDown),...e.candle.borderUp!==void 0&&{borderUp:r(e.candle.borderUp)},...e.candle.borderDown!==void 0&&{borderDown:r(e.candle.borderDown)}},volume:{up:r(e.volume.up),down:r(e.volume.down)},ui:{accent:r(e.ui.accent),accentText:r(e.ui.accentText),accentBg:r(e.ui.accentBg),accentBgStrong:r(e.ui.accentBgStrong),disabledText:r(e.ui.disabledText),soonBadgeText:r(e.ui.soonBadgeText),stream:{connected:r(e.ui.stream.connected),reconnecting:r(e.ui.stream.reconnecting),disconnected:r(e.ui.stream.disconnected)}},drawingToolbar:{iconColor:r(e.drawingToolbar.iconColor),activeIconColor:r(e.drawingToolbar.activeIconColor),flyoutLabelColor:r(e.drawingToolbar.flyoutLabelColor),flyoutHeadingColor:r(e.drawingToolbar.flyoutHeadingColor)},topBar:{btnColor:r(e.topBar.btnColor),activeBtnColor:r(e.topBar.activeBtnColor),flyoutRowColor:r(e.topBar.flyoutRowColor),flyoutCategoryColor:r(e.topBar.flyoutCategoryColor)},bottomBar:{btnColor:r(e.bottomBar.btnColor),activeBtnBg:r(e.bottomBar.activeBtnBg),activeBtnText:r(e.bottomBar.activeBtnText),activeBtnBorder:r(e.bottomBar.activeBtnBorder)},indicatorOverlay:{pillBg:r(e.indicatorOverlay.pillBg),iconColor:r(e.indicatorOverlay.iconColor),dropdownHoverBg:r(e.indicatorOverlay.dropdownHoverBg)},tradeLevels:{buySide:r(e.tradeLevels.buySide),sellSide:r(e.tradeLevels.sellSide),tradeLine:r(e.tradeLevels.tradeLine),positionLine:r(e.tradeLevels.positionLine),pendingBuyLine:r(e.tradeLevels.pendingBuyLine),pendingSellLine:r(e.tradeLevels.pendingSellLine),labelText:r(e.tradeLevels.labelText),closeBtn:r(e.tradeLevels.closeBtn),closeBtnText:r(e.tradeLevels.closeBtnText),boxBg:r(e.tradeLevels.boxBg),boxBgHover:r(e.tradeLevels.boxBgHover),dragHandle:r(e.tradeLevels.dragHandle),dragHandleHover:r(e.tradeLevels.dragHandleHover)},tradePanel:{background:r(e.tradePanel.background),border:r(e.tradePanel.border),headerBg:r(e.tradePanel.headerBg),tabActive:r(e.tradePanel.tabActive),tabInactive:r(e.tradePanel.tabInactive),rowHoverBg:r(e.tradePanel.rowHoverBg),rowText:r(e.tradePanel.rowText),rowSubText:r(e.tradePanel.rowSubText)},drawing:d(e.drawing,r)};return t.removeChild(n),i}function d(e,t){let n={};for(let r of Object.keys(e)){let i={...e[r]};if(i.strokeColor&&(i.strokeColor=t(i.strokeColor)),i.fillColor&&(i.fillColor=t(i.fillColor)),`textColor`in i&&i.textColor&&(i.textColor=t(i.textColor)),`levels`in i&&i.levels){let e={};for(let n of Object.keys(i.levels)){let r=i.levels[n];r&&(e[n]={...r,color:t(r.color)})}i.levels=e}n[r]=i}return n}var f={horizontalLine:{strokeColor:`#e8b84b`,lineWidth:1,lineStyle:`dashed`},verticalLine:{strokeColor:`#e8b84b`,lineWidth:1,lineStyle:`dashed`},trendLine:{strokeColor:`#26c6da`,lineWidth:1,lineStyle:`solid`},crossLine:{strokeColor:`#78909c`,lineWidth:1,lineStyle:`dashed`},trendAngle:{strokeColor:`#26c6da`,lineWidth:1,lineStyle:`solid`},flatChannel:{strokeColor:`#ab47bc`,lineWidth:1,lineStyle:`solid`,fillColor:`#ab47bc`,fillOpacity:.08},parallelChannel:{strokeColor:`#26c6da`,lineWidth:1,lineStyle:`solid`,fillColor:`#26c6da`,fillOpacity:.08},disjointChannel:{strokeColor:`#ef9a9a`,lineWidth:1,lineStyle:`solid`},pitchfork:{strokeColor:`#ffa726`,lineWidth:1,lineStyle:`solid`},schiffPitchfork:{strokeColor:`#ff7043`,lineWidth:1,lineStyle:`solid`},modifiedSchiff:{strokeColor:`#ef5350`,lineWidth:1,lineStyle:`solid`},insidePitchfork:{strokeColor:`#ab47bc`,lineWidth:1,lineStyle:`solid`},fibRetracement:{lineWidth:1,lineStyle:`dashed`,levels:{0:{visible:!0,color:`#ef5350`},"0.236":{visible:!0,color:`#e8b84b`},"0.382":{visible:!0,color:`#26a69a`},"0.5":{visible:!0,color:`#2196f3`},"0.618":{visible:!0,color:`#26a69a`},"0.786":{visible:!0,color:`#e8b84b`},1:{visible:!0,color:`#ef5350`}}},fibExtension:{lineWidth:1,lineStyle:`dashed`,levels:{0:{visible:!0,color:`#888888`},"0.618":{visible:!0,color:`#26a69a`},1:{visible:!0,color:`#888888`},"1.272":{visible:!0,color:`#2196f3`},"1.618":{visible:!0,color:`#e8b84b`},2:{visible:!0,color:`#ef5350`},"2.618":{visible:!0,color:`#ef5350`}}},fibProjection:{lineWidth:1,lineStyle:`dashed`,levels:{0:{visible:!0,color:`#ef5350`},"0.618":{visible:!0,color:`#26a69a`},1:{visible:!0,color:`#2196f3`},"1.272":{visible:!0,color:`#26a69a`},"1.618":{visible:!0,color:`#e8b84b`},2:{visible:!0,color:`#ef5350`},"2.618":{visible:!0,color:`#ef5350`}}},fibChannel:{strokeColor:`#888888`,lineWidth:1,lineStyle:`dashed`},fibFan:{strokeColor:`#888888`,lineWidth:1,lineStyle:`dashed`},fibCircles:{strokeColor:`#e8b84b`,lineWidth:1,lineStyle:`dashed`},fibSpiral:{strokeColor:`#e8b84b`,lineWidth:1,lineStyle:`solid`},fibTimezone:{strokeColor:`#e8b84b`,lineWidth:1,lineStyle:`dashed`},rectangle:{strokeColor:`#9b59b6`,lineWidth:1,lineStyle:`solid`,fillColor:`#9b59b6`,fillOpacity:.09},rotatedRectangle:{strokeColor:`#9c27b0`,lineWidth:1,lineStyle:`solid`,fillColor:`#9c27b0`,fillOpacity:.09},ellipse:{strokeColor:`#2196f3`,lineWidth:1,lineStyle:`solid`,fillColor:`#2196f3`,fillOpacity:.08},circle:{strokeColor:`#4caf50`,lineWidth:1,lineStyle:`solid`,fillColor:`#4caf50`,fillOpacity:.08},triangle:{strokeColor:`#ff9800`,lineWidth:1,lineStyle:`solid`,fillColor:`#ff9800`,fillOpacity:.08},arc:{strokeColor:`#26c6da`,lineWidth:1,lineStyle:`solid`},sineLine:{strokeColor:`#ce93d8`,lineWidth:1,lineStyle:`solid`},path:{strokeColor:`#ec407a`,lineWidth:1,lineStyle:`solid`},polyline:{strokeColor:`#ff7043`,lineWidth:1,lineStyle:`solid`},brush:{strokeColor:`#ff5722`,lineWidth:2,lineStyle:`solid`},highlighter:{strokeColor:`#ffeb3b`,lineWidth:8,lineStyle:`solid`,fillOpacity:.4},text:{textColor:`#f5f5f5`,fontSize:13,strokeColor:`#2196f3`},callout:{textColor:`#f5f5f5`,fontSize:13,strokeColor:`#546e7a`,fillColor:`#546e7a`,fillOpacity:.18},priceLabel:{textColor:`#ffffff`,fontSize:11,strokeColor:`#26a69a`,fillColor:`#26a69a`,fillOpacity:1},priceNote:{textColor:`#f5f5f5`,fontSize:12,strokeColor:`#ffa726`},anchoredNote:{textColor:`#f5f5f5`,fontSize:12,strokeColor:`#42a5f5`},arrowUp:{strokeColor:`#26a69a`,lineWidth:1.5,fillColor:`#26a69a`,fillOpacity:1},arrowDown:{strokeColor:`#ef5350`,lineWidth:1.5,fillColor:`#ef5350`,fillOpacity:1},arrowMarker:{strokeColor:`#ef5350`,lineWidth:1.5,fillColor:`#ef5350`,fillOpacity:1},flag:{strokeColor:`#ef5350`,lineWidth:1,fillColor:`#ef5350`,fillOpacity:.85},volumeProfile:{strokeColor:`#26c6da`,lineWidth:1,fillColor:`#26c6da`,fillOpacity:.35},anchoredVP:{strokeColor:`#42a5f5`,lineWidth:1,fillColor:`#42a5f5`,fillOpacity:.35},fixedRangeVP:{strokeColor:`#7e57c2`,lineWidth:1,fillColor:`#7e57c2`,fillOpacity:.35},abcdPattern:{strokeColor:`#26c6da`,lineWidth:1,lineStyle:`solid`},gartleyPattern:{strokeColor:`#26c6da`,lineWidth:1,lineStyle:`solid`},batPattern:{strokeColor:`#26c6da`,lineWidth:1,lineStyle:`solid`},butterflyPattern:{strokeColor:`#26c6da`,lineWidth:1,lineStyle:`solid`},crabPattern:{strokeColor:`#26c6da`,lineWidth:1,lineStyle:`solid`},sharkPattern:{strokeColor:`#26c6da`,lineWidth:1,lineStyle:`solid`},cypherPattern:{strokeColor:`#26c6da`,lineWidth:1,lineStyle:`solid`},headShoulders:{strokeColor:`#26c6da`,lineWidth:1,lineStyle:`solid`},trianglePattern:{strokeColor:`#26c6da`,lineWidth:1,lineStyle:`solid`},threeDrives:{strokeColor:`#26c6da`,lineWidth:1,lineStyle:`solid`},elliottImpulse:{strokeColor:`#42a5f5`,lineWidth:1,lineStyle:`solid`},elliottCorrective:{strokeColor:`#42a5f5`,lineWidth:1,lineStyle:`solid`},elliottTriangle:{strokeColor:`#42a5f5`,lineWidth:1,lineStyle:`solid`},elliottWxy:{strokeColor:`#42a5f5`,lineWidth:1,lineStyle:`solid`},elliottCombination:{strokeColor:`#42a5f5`,lineWidth:1,lineStyle:`solid`},gannFan:{strokeColor:`#ffa726`,lineWidth:1,lineStyle:`solid`},gannSquare:{strokeColor:`#ab47bc`,lineWidth:1,lineStyle:`solid`},gannBox:{strokeColor:`#7e57c2`,lineWidth:1,lineStyle:`solid`},priceRange:{strokeColor:`#66bb6a`,lineWidth:1,fillColor:`#66bb6a`,fillOpacity:.07},dateRange:{strokeColor:`#66bb6a`,lineWidth:1,fillColor:`#66bb6a`,fillOpacity:.07},datePriceRange:{strokeColor:`#66bb6a`,lineWidth:1,fillColor:`#66bb6a`,fillOpacity:.07},ruler:{strokeColor:`#90a4ae`,lineWidth:1,lineStyle:`dashed`},regressionTrend:{strokeColor:`#42a5f5`,lineWidth:1,lineStyle:`solid`},projection:{strokeColor:`#9575cd`,lineWidth:1,lineStyle:`dashed`},cyclicLines:{strokeColor:`#80cbc4`,lineWidth:1,lineStyle:`dashed`},timeCycles:{strokeColor:`#80cbc4`,lineWidth:1,lineStyle:`dashed`,fillColor:`#80cbc4`,fillOpacity:.06},priceProjection:{strokeColor:`#ef9a9a`,lineWidth:1,lineStyle:`dashed`,fillColor:`#ef9a9a`,fillOpacity:.09},ghostFeed:{strokeColor:`#9e9e9e`,lineWidth:1,lineStyle:`dotted`}},p={background:`#141d22`,grid:`#243344`,axisText:`#a8bac8`,axisBorder:`#1c2a35`,crosshair:`rgba(255,255,255,0.4)`,tooltip:{background:`#1c2a35`,text:`#e8eef2`,border:`#1c2a35`},candle:{up:`#5caf79`,down:`#DF6868`,wickUp:`#5caf79`,wickDown:`#DF6868`},volume:{up:`rgba(92,175,121,0.4)`,down:`rgba(223,104,104,0.4)`},ui:{accent:`#398dff`,accentText:`#93bcff`,accentBg:`rgba(57,141,255,0.15)`,accentBgStrong:`rgba(57,141,255,0.22)`,disabledText:`#484f58`,soonBadgeText:`#30363d`,stream:{connected:`#5caf79`,reconnecting:`#e8b84b`,disconnected:`#555555`}},drawingToolbar:{iconColor:`#e8eef2`,activeIconColor:`#93bcff`,flyoutLabelColor:`#a8bac8`,flyoutHeadingColor:`#a8bac8`},topBar:{btnColor:`#a8bac8`,activeBtnColor:`#93bcff`,flyoutRowColor:`#a8bac8`,flyoutCategoryColor:`#a8bac8`},bottomBar:{btnColor:`#a8bac8`,activeBtnBg:`#5caf79`,activeBtnText:`#ffffff`,activeBtnBorder:`#5caf79`},indicatorOverlay:{pillBg:`rgba(28,42,53,0.73)`,iconColor:`#a8bac8`,dropdownHoverBg:`#1c2a35`},tradeLevels:{buySide:`#26a69a`,sellSide:`#ef5350`,tradeLine:`#5caf79`,positionLine:`#7b61ff`,pendingBuyLine:`rgba(92,175,121,0.75)`,pendingSellLine:`rgba(223,104,104,0.75)`,labelText:`#ffffff`,closeBtn:`rgba(255,255,255,0.18)`,closeBtnText:`#ffffff`,boxBg:`rgba(20, 24, 36, 0.92)`,boxBgHover:`rgba(35, 40, 58, 0.97)`,dragHandle:`rgba(255,255,255,0.3)`,dragHandleHover:`#9ca3af`},tradePanel:{background:`#1c2a35`,border:`#243344`,headerBg:`#151f28`,tabActive:`#93bcff`,tabInactive:`#a8bac8`,rowHoverBg:`rgba(255,255,255,0.04)`,rowText:`#e8eef2`,rowSubText:`#9ca3af`},drawing:f},m={background:`#ffffff`,grid:`#efefef`,axisText:`#666666`,axisBorder:`#cccccc`,crosshair:`#999999`,tooltip:{background:`#f8f8f8`,text:`#333333`,border:`#cccccc`},candle:{up:`#5caf79`,down:`#DF6868`,wickUp:`#5caf79`,wickDown:`#DF6868`},volume:{up:`rgba(92,175,121,0.6)`,down:`rgba(223,104,104,0.6)`},ui:{accent:`#398dff`,accentText:`#2a7aff`,accentBg:`rgba(57,141,255,0.10)`,accentBgStrong:`rgba(57,141,255,0.18)`,disabledText:`#94a3b8`,soonBadgeText:`#cbd5e1`,stream:{connected:`#5caf79`,reconnecting:`#d97706`,disconnected:`#94a3b8`}},drawingToolbar:{iconColor:`#333333`,activeIconColor:`#398dff`,flyoutLabelColor:`#666666`,flyoutHeadingColor:`#666666`},topBar:{btnColor:`#666666`,activeBtnColor:`#398dff`,flyoutRowColor:`#666666`,flyoutCategoryColor:`#666666`},bottomBar:{btnColor:`#666666`,activeBtnBg:`#5caf79`,activeBtnText:`#ffffff`,activeBtnBorder:`#5caf79`},indicatorOverlay:{pillBg:`rgba(248,248,248,0.85)`,iconColor:`#666666`,dropdownHoverBg:`#f0f0f0`},tradeLevels:{buySide:`#26a69a`,sellSide:`#ef5350`,tradeLine:`#5caf79`,positionLine:`#6d28d9`,pendingBuyLine:`rgba(92,175,121,0.75)`,pendingSellLine:`rgba(223,104,104,0.75)`,labelText:`#ffffff`,closeBtn:`rgba(0,0,0,0.15)`,closeBtnText:`#ffffff`,boxBg:`rgba(240, 244, 252, 0.95)`,boxBgHover:`rgba(255, 255, 255, 0.99)`,dragHandle:`#94a3b8`,dragHandleHover:`#475569`},tradePanel:{background:`#f8f8f8`,border:`#cccccc`,headerBg:`#f0f0f0`,tabActive:`#398dff`,tabInactive:`#666666`,rowHoverBg:`rgba(0,0,0,0.03)`,rowText:`#333333`,rowSubText:`#666666`},drawing:f},h=`'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif`,g={iconBtnSize:40,iconFontSize:`20px`,iconFontFamily:h,flyoutLabelFontSize:`12px`,flyoutLabelFontFamily:h,shortcutFontSize:`9px`,soonBadgeFontSize:`9px`,flyoutHeadingFontSize:`10px`,flyoutHeadingLetterSpacing:`0.08em`,scrollBtnHeight:20,scrollBtnFontSize:`9px`,barPadding:7,btnGap:4,mobileBreakpoint:480},_={height:`36px`,dropBtnFontSize:`11px`,dropBtnFontFamily:h,drawBtnSize:`26px`,drawBtnIconFontSize:`14px`,iconBtnSize:`26px`,mobileIconBtnSize:`28px`,mobileDrawBtnIconSize:`16px`,flyoutRowFontSize:`12px`,flyoutRowFontFamily:h,flyoutCategoryFontSize:`10px`,flyoutCategoryLetterSpacing:`0.08em`,flyoutCheckFontSize:`11px`,streamDotSize:`7px`},v={height:`32px`,btnFontSize:`11px`,btnFontFamily:h},y={fontSize:`11px`,fontFamily:h},b={fontSize:`11px`,fontFamily:h},x={labelHeight:18,labelPaddingX:4,fontSize:`11px`,fontFamily:h},S={pillFontSize:`13px`,pillFontFamily:h,dotFontSize:`8px`,pillIconFontSize:`12px`,collapseBtnFontSize:`13px`,collapseBtnFontFamily:h,dropdownRowFontSize:`11px`,dropdownRowFontFamily:h,dropdownIconFontSize:`10px`},C={size:22,mobileSize:24,iconSize:14,mobileIconSize:16},w={drawingToolbar:g,topBar:_,bottomBar:v,priceAxis:y,timeAxis:b,crosshair:x,indicatorOverlay:S,tradeButton:C};function T(e){return e?{drawingToolbar:{...g,...e.drawingToolbar},topBar:{..._,...e.topBar},bottomBar:{...v,...e.bottomBar},priceAxis:{...y,...e.priceAxis},timeAxis:{...b,...e.timeAxis},crosshair:{...x,...e.crosshair},indicatorOverlay:{...S,...e.indicatorOverlay},tradeButton:{...C,...e.tradeButton}}:w}var E={topBar:{series:{candlestick:`Candles`,hollow:`Hollow`,ohlc:`OHLC`,line:`Line`,area:`Area`,heikinashi:`Heikin Ashi`,volumecandles:`Volume Candles`,linemarkers:`Line with Markers`,step:`Step Line`,hlcarea:`HLC Area`,baseline:`Baseline`,columns:`Columns`,highlow:`High-low`},timeframes:{"1m":`1m`,"5m":`5m`,"15m":`15m`,"30m":`30m`,"1h":`1h`,"2h":`2h`,"4h":`4h`,"8h":`8h`,"1D":`1D`,"1W":`1W`,"1M":`1M`},indicatorsBtn:`Indicators`,indicatorsBtnActive:`Indicators ({count})`,toggleDrawingTitle:`Toggle Drawing Tools`,toggleFullscreenTitle:`Toggle Fullscreen`,exitFullscreenTitle:`Exit Fullscreen`,settingsTitle:`Settings`,tfcToggleTitle:`Trade from Charts`},bottomBar:{durations:{"1D":`1D`,"5D":`5D`,"1M":`1M`,"3M":`3M`,"6M":`6M`,"1Y":`1Y`,"5Y":`5Y`,All:`All`}},drawingToolbar:{categories:{trendLines:`Trend Lines & Channels`,fibonacci:`Fibonacci & Gann Tools`,shapes:`Geometric Shapes`,measurements:`Measurement Tools`,pitchforks:`Pitchfork Tools`,volume:`Volume & Statistical Tools`,annotations:`Annotation Tools`,patterns:`Pattern Recognition`,elliott:`Elliott Wave Tools`,brushes:`Brush & Highlighter`,advanced:`Advanced Tools`,priceProjection:`Price Projection Tools`},tools:{horizontalLine:`Horizontal Line`,verticalLine:`Vertical Line`,trendLine:`Trend Line`,trendAngle:`Trend Angle`,crossLine:`Cross Line`,parallelChannel:`Parallel Channel`,flatChannel:`Flat Top/Bottom Channel`,disjointChannel:`Disjoint Channel`,fibRetracement:`Fibonacci Retracement`,fibExtension:`Fibonacci Extension`,fibChannel:`Fibonacci Channel`,fibTimezone:`Fibonacci Timezone`,fibCircles:`Fibonacci Circles`,fibSpiral:`Fibonacci Spiral`,fibFan:`Fibonacci Speed Resistance Fan`,fibProjection:`Fibonacci Projection`,gannFan:`Gann Fan`,gannSquare:`Gann Square`,gannBox:`Gann Box`,rectangle:`Rectangle`,rotatedRectangle:`Rotated Rectangle`,ellipse:`Ellipse`,triangle:`Triangle`,circle:`Circle`,arc:`Arc`,polyline:`Polyline`,path:`Path`,priceRange:`Price Range`,dateRange:`Date Range`,datePriceRange:`Date & Price Range`,ruler:`Ruler`,pitchfork:`Pitchfork`,schiffPitchfork:`Schiff Pitchfork`,modifiedSchiff:`Modified Schiff Pitchfork`,insidePitchfork:`Inside Pitchfork`,fixedRangeVP:`Fixed Range Volume Profile`,anchoredVP:`Anchored Volume Profile`,volumeProfile:`Volume Profile`,regressionTrend:`Regression Trend`,text:`Text`,callout:`Callout`,priceLabel:`Price Label`,arrowMarker:`Arrow Marker`,flag:`Flag`,priceNote:`Price Note`,anchoredNote:`Anchored Note`,arrowUp:`Arrow Up`,arrowDown:`Arrow Down`,headShoulders:`Head & Shoulders`,trianglePattern:`Triangle Pattern`,threeDrives:`3 Drives Pattern`,abcdPattern:`ABCD Pattern`,cypherPattern:`Cypher Pattern`,butterflyPattern:`Butterfly Pattern`,batPattern:`Bat Pattern`,gartleyPattern:`Gartley Pattern`,crabPattern:`Crab Pattern`,sharkPattern:`Shark Pattern`,elliottImpulse:`Elliott Impulse (12345)`,elliottCorrective:`Elliott Corrective (ABC)`,elliottTriangle:`Elliott Wave Triangle`,elliottCombination:`Elliott Wave Combination`,elliottWxy:`Elliott Double Three (WXY)`,brush:`Brush`,highlighter:`Highlighter`,ghostFeed:`Ghost Feed`,projection:`Projection`,sineLine:`Sine Line`,cyclicLines:`Cyclic Lines`,timeCycles:`Time Cycles`,priceProjection:`Price Projection`},actions:{undo:`Undo (Ctrl+Z)`,redo:`Redo (Ctrl+Y)`,deleteSelected:`Delete Selected (Del)`,clearAll:`Clear All`,showAll:`Show All`,hideAll:`Hide All`,lockAll:`Lock All`,unlockAll:`Unlock All`,moreActions:`Actions`},soonBadge:`soon`,scrollUp:`Scroll up`,scrollDown:`Scroll down`},ohlc:{open:`O`,high:`H`,low:`L`,close:`C`,volume:`V`},trade:{buy:`Buy`,sell:`Sell`,limit:`Limit`,stop:`Stop`,market:`Market`,at:`at`,qty:`Qty`,placeOrderTitle:`Place order at this price`},dialogs:{settings:{title:`Chart Settings`,tfcSection:`Trade from Charts`,showLabel:`Show`,positionStyleLabel:`Position Style`,showAll:`All`,showPositions:`Positions Only`,showOrders:`Orders Only`,showNone:`None`,styleLine:`Full Line`,styleDot:`Dot`,resetBtn:`Reset to Defaults`},indicator:{titleSuffix:`Settings`,noParams:`No configurable parameters.`}},chart:{loading:`Loading…`,noData:`No data available`,scrollToLatest:`Scroll to latest`,nIndicators:`{count} indicators`}};function D(e){var t,n,r,i,a,o,s,c;if(!e)return E;let l=E;return{topBar:{...l.topBar,...e.topBar,series:{...l.topBar.series,...(t=e.topBar)==null?void 0:t.series},timeframes:{...l.topBar.timeframes,...(n=e.topBar)==null?void 0:n.timeframes}},bottomBar:{durations:{...l.bottomBar.durations,...(r=e.bottomBar)==null?void 0:r.durations}},drawingToolbar:{...l.drawingToolbar,...e.drawingToolbar,categories:{...l.drawingToolbar.categories,...(i=e.drawingToolbar)==null?void 0:i.categories},tools:{...l.drawingToolbar.tools,...(a=e.drawingToolbar)==null?void 0:a.tools},actions:{...l.drawingToolbar.actions,...(o=e.drawingToolbar)==null?void 0:o.actions}},ohlc:{...l.ohlc,...e.ohlc},trade:{...l.trade,...e.trade},dialogs:{settings:{...l.dialogs.settings,...(s=e.dialogs)==null?void 0:s.settings},indicator:{...l.dialogs.indicator,...(c=e.dialogs)==null?void 0:c.indicator}},chart:{...l.chart,...e.chart}}}var O,k=class e{constructor(t,n,r,i,a,o=()=>!1,s,c,l,u){var d,f,p,m;this.canvas=t,this.getViewport=n,this.setViewport=r,this.totalBars=i,this.onUpdate=a,this.isLocked=o,this.panY=s,this.onDragStart=c,this.onDragEnd=l,this.isDragging=!1,this.isTouchDrag=!1,this.lastX=0,this.lastY=0,this.dragStartX=0,this.dragStartY=0,this.hasPanned=!1,this.dragStartFired=!1,this._velBuffer=[],this._momentumRafId=null,this.onMouseDown=e=>{this._stopMomentum(),!this.isLocked()&&(this.isDragging=!0,this.isTouchDrag=!1,this.lastX=e.clientX,this.lastY=e.clientY,this.dragStartX=e.clientX,this.dragStartY=e.clientY,this.hasPanned=!1,this._velBuffer.length=0)},this.onTouchStart=e=>{var t;if(e.touches.length!==1){this._stopMomentum();return}this._stopMomentum(),!this.isLocked()&&(this.isDragging=!0,this.isTouchDrag=!0,this.lastX=e.touches[0].clientX,this.lastY=e.touches[0].clientY,this.dragStartX=e.touches[0].clientX,this.dragStartY=e.touches[0].clientY,this.dragStartFired=!0,this._velBuffer.length=0,(t=this.onDragStart)==null||t.call(this))},this.onMouseMove=t=>{if(!this.isDragging)return;if(this.isLocked()){this.isDragging=!1,this.hasPanned=!1;return}let n=t.clientX-this.lastX,r=t.clientY-this.lastY;this.lastX=t.clientX,this.lastY=t.clientY;let i=Math.abs(t.clientX-this.dragStartX),a=Math.abs(t.clientY-this.dragStartY);if(!this.hasPanned&&(i>e.DRAG_THRESHOLD||a>e.DRAG_THRESHOLD)){var o;this.hasPanned=!0,this.dragStartFired=!0,(o=this.onDragStart)==null||o.call(this),this.canvas.style.cursor=`grabbing`}this.hasPanned&&(this._recordVelocitySample(n,performance.now()),this.pan(n),this.panY&&this.panY(r))},this.onTouchMove=e=>{if(!this.isDragging||e.touches.length!==1)return;if(this.isLocked()){this.isDragging=!1;return}e.preventDefault();let t=e.touches[0].clientX-this.lastX,n=e.touches[0].clientY-this.lastY;this._recordVelocitySample(t,performance.now()),this.pan(t),this.panY&&this.panY(n),this.lastX=e.touches[0].clientX,this.lastY=e.touches[0].clientY},this.onMouseUp=()=>{if(this.hasPanned&&(this.canvas.style.cursor=`crosshair`),this.isDragging=!1,this.hasPanned=!1,this.dragStartFired){var e;this.dragStartFired=!1;let t=this._computeReleaseVelocity();this._velBuffer.length=0,this._startMomentum(t)||(e=this.onDragEnd)==null||e.call(this)}},this._momentumEnabled=(d=u==null?void 0:u.enabled)==null?!0:d,this._momentumDecay=Math.min(.99,Math.max(.8,(f=u==null?void 0:u.decay)==null?.95:f)),this._momentumThreshold=(p=u==null?void 0:u.threshold)==null?.3:p,this._momentumMaxVelocity=(m=u==null?void 0:u.maxVelocity)==null?6:m,this.attach()}attach(){this.canvas.addEventListener(`mousedown`,this.onMouseDown),window.addEventListener(`mousemove`,this.onMouseMove),window.addEventListener(`mouseup`,this.onMouseUp),this.canvas.addEventListener(`touchstart`,this.onTouchStart,{passive:!1}),window.addEventListener(`touchmove`,this.onTouchMove,{passive:!1}),window.addEventListener(`touchend`,this.onMouseUp)}cancel(){this._stopMomentum(),this.isDragging=!1,this.hasPanned=!1}destroy(){this._stopMomentum(),this.canvas.removeEventListener(`mousedown`,this.onMouseDown),window.removeEventListener(`mousemove`,this.onMouseMove),window.removeEventListener(`mouseup`,this.onMouseUp),this.canvas.removeEventListener(`touchstart`,this.onTouchStart),window.removeEventListener(`touchmove`,this.onTouchMove),window.removeEventListener(`touchend`,this.onMouseUp)}_recordVelocitySample(t,n){this._velBuffer.push({dx:t,t:n});let r=n-e.VEL_WINDOW_MS,i=0;for(;i<this._velBuffer.length&&this._velBuffer[i].t<r;)i++;i>0&&this._velBuffer.splice(0,i)}_computeReleaseVelocity(){let e=this._velBuffer;if(e.length<2)return 0;let t=e.reduce((e,t)=>e+t.dx,0),n=e[e.length-1].t-e[0].t;if(n<=0)return 0;let r=t/n;return Math.sign(r)*Math.min(Math.abs(r),this._momentumMaxVelocity)}_startMomentum(e){if(!this._momentumEnabled||Math.abs(e)<this._momentumThreshold)return!1;let t=null,n=e,r=this._momentumDecay,i=e=>{if(t===null){t=e,this._momentumRafId=requestAnimationFrame(i);return}let a=e-t;t=e,n*=r**(a/16.67);let o=n*a;if(Math.abs(o)<.5){var s;this._stopMomentum(),(s=this.onDragEnd)==null||s.call(this);return}if(this.isLocked()){var c;this._stopMomentum(),(c=this.onDragEnd)==null||c.call(this);return}let l=this.getViewport().startIndex;if(this.pan(o),this.getViewport().startIndex===l){var u;this._stopMomentum(),(u=this.onDragEnd)==null||u.call(this);return}this._momentumRafId=requestAnimationFrame(i)};return this._momentumRafId=requestAnimationFrame(i),!0}_stopMomentum(){this._momentumRafId!==null&&(cancelAnimationFrame(this._momentumRafId),this._momentumRafId=null)}pan(e){let t=this.getViewport(),n=t.endIndex-t.startIndex,r=n/(this.isTouchDrag?this.canvas.clientWidth||this.canvas.width/(window.devicePixelRatio||1):this.canvas.width),i=-e*r,a=Math.max(0,this.totalBars()-Math.floor(n/2)),o=Math.max(0,Math.min(a,t.startIndex+i));this.setViewport({...t,startIndex:o,endIndex:o+n}),this.onUpdate()}};O=k,O.DRAG_THRESHOLD=4,O.VEL_WINDOW_MS=100;var A=10,ee=500,j=class{constructor(e,t,n,r,i,a=()=>e.getBoundingClientRect(),o=()=>e.offsetWidth,s){this.canvas=e,this.getViewport=t,this.setViewport=n,this.totalBars=r,this.onUpdate=i,this.getCanvasRect=a,this.getChartWidth=o,this.panByPixelDelta=s,this._pinchStartDist=0,this._pinchStartRatio=0,this._pinchStartViewport=null,this.onWheel=e=>{e.preventDefault();let t=this.getViewport(),n=t.endIndex-t.startIndex,r;if(e.ctrlKey){let t=Math.max(-50,Math.min(50,e.deltaY));r=Math.exp(t*.01)}else{if(e.deltaX!==0&&Math.abs(e.deltaX)>Math.abs(e.deltaY)*.5){this.panByPixelDelta&&this.panByPixelDelta(e.deltaX),this.onUpdate();return}if(e.deltaY===0)return;r=e.deltaY>0?1.1:.9}let i=Math.round(Math.max(A,Math.min(ee,n*r)));if(t.endIndex>=this.totalBars()){let e=Math.min(t.endIndex,this.totalBars()+Math.floor(i/2)),n=Math.max(0,e-i);this.setViewport({...t,startIndex:n,endIndex:n+i})}else{let r=e.offsetX/this.getChartWidth(),a=t.startIndex+n*r,o=Math.max(0,a-i*r);this.setViewport({...t,startIndex:o,endIndex:o+i})}this.onUpdate()},this.onTouchStart=e=>{if(e.touches.length!==2)return;let t=this.pinchDist(e.touches[0],e.touches[1]);this._pinchStartDist=t,this._pinchStartViewport={...this.getViewport()};let n=this.getCanvasRect(),r=(e.touches[0].clientX+e.touches[1].clientX)/2-n.left;this._pinchStartRatio=Math.max(0,Math.min(1,r/this.getChartWidth()))},this.onTouchMove=e=>{if(e.touches.length!==2)return;e.preventDefault();let t=this.pinchDist(e.touches[0],e.touches[1]);if(this._pinchStartDist===0||!this._pinchStartViewport){this._pinchStartDist=t,this._pinchStartViewport={...this.getViewport()};let n=this.getCanvasRect(),r=(e.touches[0].clientX+e.touches[1].clientX)/2;this._pinchStartRatio=Math.max(0,Math.min(1,(r-n.left)/this.getChartWidth()));return}let n=this._pinchStartDist/t,r=this._pinchStartViewport,i=r.endIndex-r.startIndex,a=Math.round(Math.max(A,Math.min(ee,i*n))),o=this._pinchStartRatio,s=r.startIndex+i*o,c=Math.max(0,s-a*o);this.setViewport({...r,startIndex:c,endIndex:c+a}),this.onUpdate()},this.onTouchEnd=()=>{this._pinchStartDist=0,this._pinchStartViewport=null},this.attach()}attach(){this.canvas.addEventListener(`wheel`,this.onWheel,{passive:!1}),this.canvas.addEventListener(`touchstart`,this.onTouchStart,{passive:!1}),this.canvas.addEventListener(`touchmove`,this.onTouchMove,{passive:!1}),this.canvas.addEventListener(`touchend`,this.onTouchEnd)}destroy(){this.canvas.removeEventListener(`wheel`,this.onWheel),this.canvas.removeEventListener(`touchstart`,this.onTouchStart),this.canvas.removeEventListener(`touchmove`,this.onTouchMove),this.canvas.removeEventListener(`touchend`,this.onTouchEnd)}pinchDist(e,t){let n=t.clientX-e.clientX,r=t.clientY-e.clientY;return Math.sqrt(n*n+r*r)}};function te(e,t,n,r,i,a,o,s){let c=i.candleBodyWidth(n,o),l=t.length,u=new Float32Array(l),d=new Float32Array(l),f=new Float32Array(l),p=new Float32Array(l),m=new Float32Array(l),h=new Uint8Array(l),g=Math.floor(n.startIndex);for(let e=0;e<l;e++){let a=t[e];u[e]=i.xToPixel(g+e,n,o),d[e]=i.yToPixel(a.high,r,s),f[e]=i.yToPixel(a.low,r,s),p[e]=i.yToPixel(a.open,r,s),m[e]=i.yToPixel(a.close,r,s),h[e]=+(a.close>=a.open)}e.lineWidth=1,e.strokeStyle=a.candle.wickUp,e.beginPath();for(let t=0;t<l;t++)h[t]&&(e.moveTo(u[t],d[t]),e.lineTo(u[t],f[t]));e.stroke(),e.strokeStyle=a.candle.wickDown,e.beginPath();for(let t=0;t<l;t++)h[t]||(e.moveTo(u[t],d[t]),e.lineTo(u[t],f[t]));e.stroke();for(let t=0;t<l;t++){var _,v;let n=Math.min(p[t],m[t]),r=Math.max(Math.abs(m[t]-p[t]),1),i=h[t]===1,o=i?a.candle.up:a.candle.down,s=i?(_=a.candle.borderUp)==null?a.candle.up:_:(v=a.candle.borderDown)==null?a.candle.down:v;e.fillStyle=o,e.fillRect(u[t]-c/2,n,c,r),s!==o&&(e.strokeStyle=s,e.lineWidth=1,e.strokeRect(u[t]-c/2,n,c,r))}}function ne(e,t,n,r,i,a,o,s){let c=i.candleBodyWidth(n,o),l=Math.floor(n.startIndex);for(let d=0;d<t.length;d++){let f=t[d],p=l+d,m=i.xToPixel(p,n,o),h=f.close>=f.open,g=i.yToPixel(f.open,r,s),_=i.yToPixel(f.close,r,s),v=i.yToPixel(f.high,r,s),y=i.yToPixel(f.low,r,s),b=h?a.candle.up:a.candle.down,x=h?a.candle.wickUp:a.candle.wickDown;e.beginPath(),e.strokeStyle=x,e.lineWidth=1,e.moveTo(m,v),e.lineTo(m,y),e.stroke();let S=Math.min(g,_),C=Math.max(Math.abs(_-g),1);if(h)e.strokeStyle=b,e.lineWidth=1,e.strokeRect(m-c/2,S,c,C);else{var u;let t=(u=a.candle.borderDown)==null?a.candle.down:u;e.fillStyle=b,e.fillRect(m-c/2,S,c,C),t!==b&&(e.strokeStyle=t,e.lineWidth=1,e.strokeRect(m-c/2,S,c,C))}}}function M(e,t){let n=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);if(n)return`rgba(${n[1]},${n[2]},${n[3]},${t})`;let r=e.replace(`#`,``),i=r.length===3?r.split(``).map(e=>e+e).join(``):r;return`rgba(${parseInt(i.slice(0,2),16)},${parseInt(i.slice(2,4),16)},${parseInt(i.slice(4,6),16)},${t})`}var N=null;function P(e,t,n,r,i,a,o,s,c=!1){if(t.length===0)return;let l=Math.floor(n.startIndex);if(c){let c=i.xToPixel(l+t.length-1,n,o),u=i.xToPixel(l,n,o);e.beginPath();for(let a=0;a<t.length;a++){let c=i.xToPixel(l+a,n,o),u=i.yToPixel(t[a].close,r,s);a===0?e.moveTo(c,u):e.lineTo(c,u)}if(e.lineTo(c,s),e.lineTo(u,s),e.closePath(),!N||N.height!==s||N.color!==a.candle.up){let t=e.createLinearGradient(0,0,0,s);t.addColorStop(0,M(a.candle.up,.15)),t.addColorStop(1,M(a.candle.up,0)),N={gradient:t,height:s,color:a.candle.up}}e.fillStyle=N.gradient,e.fill()}e.beginPath(),e.strokeStyle=a.candle.up,e.lineWidth=1.5,e.lineJoin=`round`;for(let a=0;a<t.length;a++){let c=i.xToPixel(l+a,n,o),u=i.yToPixel(t[a].close,r,s);a===0?e.moveTo(c,u):e.lineTo(c,u)}e.stroke()}function re(e,t,n,r,i,a,o,s){let c=Math.max(2,i.candleBodyWidth(n,o)*.4),l=Math.floor(n.startIndex);for(let u=0;u<t.length;u++){let d=t[u],f=l+u,p=i.xToPixel(f,n,o),m=d.close>=d.open?a.candle.up:a.candle.down,h=i.yToPixel(d.open,r,s),g=i.yToPixel(d.close,r,s),_=i.yToPixel(d.high,r,s),v=i.yToPixel(d.low,r,s);e.strokeStyle=m,e.lineWidth=1,e.beginPath(),e.moveTo(p,_),e.lineTo(p,v),e.stroke(),e.beginPath(),e.moveTo(p-c,h),e.lineTo(p,h),e.stroke(),e.beginPath(),e.moveTo(p,g),e.lineTo(p+c,g),e.stroke()}}function ie(e,t,n,r,i,a,o,s,c){let l=i.candleBodyWidth(n,o),u=Math.floor(n.startIndex);for(let d=0;d<t.length;d++){let f=t[d];if(f.volume==null)continue;let p=u+d,m=i.xToPixel(p,n,o),h=f.close>=f.open,g=s-i.volumeToPixel(f.volume,r,s),_=c+s-g;e.fillStyle=h?a.volume.up:a.volume.down,e.fillRect(m-l/2,_,l,g)}}function ae(e){let t=[];for(let n=0;n<e.length;n++){let r=e[n],i=(r.open+r.high+r.low+r.close)/4,a=n===0?(r.open+r.close)/2:(t[n-1].open+t[n-1].close)/2;t.push({time:r.time,open:a,close:i,high:Math.max(r.high,a,i),low:Math.min(r.low,a,i),volume:r.volume})}return t}function oe(e,t,n,r,i,a,o,s){let c=ae(t),l=i.candleBodyWidth(n,o),u=Math.floor(n.startIndex);for(let t=0;t<c.length;t++){var d,f;let p=c[t],m=u+t,h=i.xToPixel(m,n,o),g=p.close>=p.open,_=i.yToPixel(p.open,r,s),v=i.yToPixel(p.close,r,s),y=i.yToPixel(p.high,r,s),b=i.yToPixel(p.low,r,s),x=g?a.candle.up:a.candle.down,S=g?a.candle.wickUp:a.candle.wickDown,C=g?(d=a.candle.borderUp)==null?a.candle.up:d:(f=a.candle.borderDown)==null?a.candle.down:f;e.beginPath(),e.strokeStyle=S,e.lineWidth=1,e.moveTo(h,y),e.lineTo(h,b),e.stroke();let w=Math.min(_,v),T=Math.max(Math.abs(v-_),1);e.fillStyle=x,e.fillRect(h-l/2,w,l,T),C!==x&&(e.strokeStyle=C,e.lineWidth=1,e.strokeRect(h-l/2,w,l,T))}}function se(e,t,n,r,i,a,o,s){let c=i.candleBodyWidth(n,o),l=Math.max(...t.map(e=>{var t;return(t=e.volume)==null?0:t}),1),u=Math.floor(n.startIndex);for(let m=0;m<t.length;m++){var d,f,p;let h=t[m],g=u+m,_=i.xToPixel(g,n,o),v=h.close>=h.open,y=l>0?((d=h.volume)==null?l:d)/l:1,b=Math.max(1,y*c),x=i.yToPixel(h.open,r,s),S=i.yToPixel(h.close,r,s),C=i.yToPixel(h.high,r,s),w=i.yToPixel(h.low,r,s),T=v?a.candle.up:a.candle.down,E=v?a.candle.wickUp:a.candle.wickDown,D=v?(f=a.candle.borderUp)==null?a.candle.up:f:(p=a.candle.borderDown)==null?a.candle.down:p;e.beginPath(),e.strokeStyle=E,e.lineWidth=1,e.moveTo(_,C),e.lineTo(_,w),e.stroke();let O=Math.min(x,S),k=Math.max(Math.abs(S-x),1);e.fillStyle=T,e.fillRect(_-b/2,O,b,k),D!==T&&(e.strokeStyle=D,e.lineWidth=1,e.strokeRect(_-b/2,O,b,k))}}function ce(e,t,n,r,i,a,o,s){if(t.length===0)return;e.beginPath(),e.strokeStyle=a.candle.up,e.lineWidth=1.5,e.lineJoin=`round`;let c=Math.floor(n.startIndex);for(let a=0;a<t.length;a++){let l=c+a,u=i.xToPixel(l,n,o),d=i.yToPixel(t[a].close,r,s);a===0?e.moveTo(u,d):e.lineTo(u,d)}e.stroke();let l=Math.min(3,i.candleBodyWidth(n,o)*.35);if(!(l<.5)){e.fillStyle=a.candle.up;for(let a=0;a<t.length;a++){let u=c+a,d=i.xToPixel(u,n,o),f=i.yToPixel(t[a].close,r,s);e.beginPath(),e.arc(d,f,l,0,Math.PI*2),e.fill()}}}function le(e,t,n,r,i,a,o,s){if(t.length===0)return;e.beginPath(),e.strokeStyle=a.candle.up,e.lineWidth=1.5,e.lineJoin=`round`;let c=Math.floor(n.startIndex),l=0;for(let a=0;a<t.length;a++){let u=c+a,d=i.xToPixel(u,n,o),f=i.yToPixel(t[a].close,r,s);a===0?e.moveTo(d,f):(e.lineTo(d,l),e.lineTo(d,f)),l=f}e.stroke()}function ue(e,t){let n=e.replace(`#`,``),r=n.length===3?n.split(``).map(e=>e+e).join(``):n;return`rgba(${parseInt(r.slice(0,2),16)},${parseInt(r.slice(2,4),16)},${parseInt(r.slice(4,6),16)},${t})`}function de(e,t,n,r,i,a,o,s){if(t.length===0)return;let c=Math.floor(n.startIndex);e.beginPath();for(let a=0;a<t.length;a++){let l=i.xToPixel(c+a,n,o),u=i.yToPixel(t[a].high,r,s);a===0?e.moveTo(l,u):e.lineTo(l,u)}for(let a=t.length-1;a>=0;a--){let l=i.xToPixel(c+a,n,o),u=i.yToPixel(t[a].low,r,s);e.lineTo(l,u)}e.closePath(),e.fillStyle=ue(a.candle.up,.12),e.fill(),e.beginPath(),e.strokeStyle=a.candle.up,e.lineWidth=1.5,e.lineJoin=`round`;for(let a=0;a<t.length;a++){let l=i.xToPixel(c+a,n,o),u=i.yToPixel(t[a].close,r,s);a===0?e.moveTo(l,u):e.lineTo(l,u)}e.stroke()}function F(e,t){let n=e.replace(`#`,``),r=n.length===3?n.split(``).map(e=>e+e).join(``):n;return`rgba(${parseInt(r.slice(0,2),16)},${parseInt(r.slice(2,4),16)},${parseInt(r.slice(4,6),16)},${t})`}function I(e,t,n,r,i,a,o,s){if(t.length===0)return;let c=(r.min+r.max)/2,l=i.yToPixel(c,r,s),u=Math.floor(n.startIndex),d=t.map((e,t)=>({x:i.xToPixel(u+t,n,o),y:i.yToPixel(e.close,r,s)})),f=d[0].x,p=d[d.length-1].x,m=()=>{e.beginPath();for(let t=0;t<d.length;t++)t===0?e.moveTo(d[t].x,d[t].y):e.lineTo(d[t].x,d[t].y);e.lineTo(p,l),e.lineTo(f,l),e.closePath()};e.save(),e.beginPath(),e.rect(0,0,o,l),e.clip(),m(),e.fillStyle=F(a.candle.up,.15),e.fill(),e.restore(),e.save(),e.beginPath(),e.rect(0,l,o,s-l),e.clip(),m(),e.fillStyle=F(a.candle.down,.15),e.fill(),e.restore(),e.beginPath(),e.strokeStyle=a.candle.up,e.lineWidth=1.5,e.lineJoin=`round`;for(let t=0;t<d.length;t++)t===0?e.moveTo(d[t].x,d[t].y):e.lineTo(d[t].x,d[t].y);e.stroke(),e.beginPath(),e.strokeStyle=F(a.candle.up,.4),e.lineWidth=1,e.setLineDash([4,4]),e.moveTo(f,l),e.lineTo(p,l),e.stroke(),e.setLineDash([])}function fe(e,t,n,r,i,a,o,s){let c=i.candleBodyWidth(n,o),l=Math.floor(n.startIndex);for(let u=0;u<t.length;u++){let d=t[u],f=l+u,p=i.xToPixel(f,n,o),m=d.close>=d.open,h=i.yToPixel(d.close,r,s),g=Math.max(1,s-h);e.fillStyle=m?a.candle.up:a.candle.down,e.fillRect(p-c/2,h,c,g)}}function pe(e,t,n,r,i,a,o,s){e.lineWidth=1.5;let c=Math.floor(n.startIndex);for(let l=0;l<t.length;l++){let u=t[l],d=c+l,f=i.xToPixel(d,n,o),p=u.close>=u.open,m=i.yToPixel(u.high,r,s),h=i.yToPixel(u.low,r,s);e.strokeStyle=p?a.candle.up:a.candle.down,e.beginPath(),e.moveTo(f,m),e.lineTo(f,h),e.stroke()}}function me(e,t,n,r,i,o,s){if(e.save(),e.globalAlpha=.6,e.strokeStyle=r.grid,e.lineWidth=1,e.beginPath(),s===void 0)for(let r of a(t,o)){let a=Math.round(n.yToPixel(r,t,o))+.5;e.moveTo(0,a),e.lineTo(i,a)}else{let r=(t.max-t.min)/s;for(let a=0;a<=s;a++){let s=t.min+r*a,c=Math.round(n.yToPixel(s,t,o))+.5;e.moveTo(0,c),e.lineTo(i,c)}}e.stroke();let c=Math.max(1,Math.floor(i/80)),l=i/c;e.beginPath();for(let t=1;t<c;t++){let n=Math.round(t*l)+.5;e.moveTo(n,0),e.lineTo(n,o)}e.stroke(),e.restore()}var he=[`1m`,`5m`,`15m`,`30m`,`1h`,`4h`];function ge(e,t,n=`UTC`){let r=new Date(e);return he.includes(t)?`${r.toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,year:`numeric`,timeZone:n})} ${r.toLocaleTimeString(`en-US`,{hour:`2-digit`,minute:`2-digit`,hour12:!1,timeZone:n})}`:t===`1M`?r.toLocaleDateString(`en-US`,{month:`short`,year:`numeric`,timeZone:n}):r.toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,year:`numeric`,timeZone:n})}function _e(e,t,n,r,i,a,o,s,c,l,u,d=2,f=x,p=`UTC`){let m=i.xToPixel(t.barIndex,r,o),h=i.yToPixel(t.price,n,s);e.setLineDash([4,4]),e.strokeStyle=a.crosshair,e.lineWidth=1,e.beginPath(),e.moveTo(m,0),e.lineTo(m,l),e.stroke(),e.beginPath(),e.moveTo(0,h),e.lineTo(o,h),e.stroke(),e.setLineDash([]);let g=f.labelHeight,_=f.labelPaddingX;e.font=`${f.fontSize} ${f.fontFamily}`;let v=t.price.toFixed(d);if(e.fillStyle=a.tooltip.background,e.fillRect(o,h-g/2,c,g),e.strokeStyle=a.crosshair,e.lineWidth=1,e.strokeRect(o,h-g/2,c,g),e.fillStyle=a.tooltip.text,e.textAlign=`left`,e.fillText(v,o+_,h+4),t.bar){let n=ge(t.bar.time,u,p),r=e.measureText(n).width+_*2,i=Math.max(0,Math.min(o-r,m-r/2));e.fillStyle=a.tooltip.background,e.fillRect(i,l,r,g),e.strokeStyle=a.crosshair,e.lineWidth=1,e.strokeRect(i,l,r,g),e.fillStyle=a.tooltip.text,e.textAlign=`left`,e.fillText(n,i+_,l+13)}}function ve(e,t,n=new Set){let r=e.filter(e=>!n.has(e.level.label)).sort((e,t)=>e.y-t.y);if(r.length<2)return[];let i=[],a=[r[0]],o=r[0].y;for(let e=1;e<r.length;e++){let n=r[e];n.y-o<=t?a.push(n):(i.push(a),a=[n],o=n.y)}return i.push(a),i.filter(e=>e.length>=2).map(e=>({id:`cluster:`+e.map(e=>e.level.label).sort().join(`|`),members:e,centerY:e.reduce((e,t)=>e+t.y,0)/e.length,centerPrice:e.reduce((e,t)=>e+t.price,0)/e.length}))}function ye(e,t,n=4){let r=e.members.length,i=r*t+(r-1)*n,a=e.centerY-i/2,o=[...e.members].sort((e,t)=>e.y-t.y),s=new Map;for(let e=0;e<o.length;e++)s.set(o[e].level.label,a+e*(t+n));return s}function be(e,t,n){let r=e.members.filter(e=>e.level.type===`position`&&!e.level.entryPriceEditable).length,i=e.members.filter(e=>e.level.type===`pending`||e.level.entryPriceEditable===!0).length,a=e.members.filter(e=>e.level.type===`trade`).length,o=[];r>0&&o.push(`${r} Position${r>1?`s`:``}`),i>0&&o.push(`${i} Order${i>1?`s`:``}`),a>0&&o.push(`${a} Trade${a>1?`s`:``}`);let s=o.join(` / `),c=12+n.measureText(s).width+16+12;return{badgeX:(t-c)/2,badgeY:e.centerY-24/2,badgeW:c,badgeH:24,text:s}}function xe(e,t,n){var r;return(r=n.find(n=>e>=n.x&&e<=n.x+n.w&&t>=n.y&&t<=n.y+n.h))==null?null:r}var Se=8,Ce=6,we=6,Te=4,Ee=16,De=3,Oe=1,ke=7,Ae=7,je=4,Me=7,Ne=4,Pe=6,Fe=`13px 'Inter', system-ui, sans-serif`,Ie=`13px 'Inter', system-ui, sans-serif`,Le=14,L=1.5,Re=1,R=5,ze=3,Be=Ee+ze*2,Ve=`12px 'Inter', system-ui, sans-serif`,He=.68,Ue=[0,-.08,.08],We=30,Ge=[],Ke=``;function qe(e){return e.type===`position`&&!!e.pnlText}function Je(e,t,n,r){return e<n+r&&e+t>n}function Ye(e,t,n,r,i){let a=[];e&&a.push(e);for(let e of i)a.push(e);let o=t,s=0,c=a.length+2;for(;s<c&&a.some(e=>Je(o,n,e.boxY,e.boxH));)o+=r*(n+2),s++;return o}function Xe(e,t,n,r=!1){var i,a,o;if((i=e.data)!=null&&i._isDraft){let t=e;return`${t.side.charAt(0).toUpperCase()+t.side.slice(1)} ${t.orderType.charAt(0).toUpperCase()+t.orderType.slice(1)}`}if(e.type===`pending`){var s;let i=e,a=!r&&i.lots!==void 0?` ${i.lots}`:``;return(s=e.text)==null?`${i.side.toUpperCase()}${a} @${t.toFixed(n)}`:s}if(e.type===`position`&&e.entryPriceEditable){var c;let i=e,a=i.side?i.side.toUpperCase():``,o=!r&&i.lots!==void 0?` ${i.lots}`:``;return(c=e.text)==null?`${a}${o} @${t.toFixed(n)}`:c}return e.type===`position`?(a=e.text)==null?``:a:(o=e.text)==null?e.label:o}function Ze(e,t,n,r,i,a,o,s,c,l=Be){let u=[],d=s==null?c:s;for(let i of e){if(i.label!==d)continue;let e=i;if(e.stopLossPrice!==void 0){let s=`${i.label}:stopLoss`,c=a===s&&o!==null?o:e.stopLossPrice;u.push({key:s,y:t.yToPixel(c,n,r)})}if(e.takeProfitPrice!==void 0){let s=`${i.label}:takeProfit`,c=a===s&&o!==null?o:e.takeProfitPrice;u.push({key:s,y:t.yToPixel(c,n,r)})}}u.sort((e,t)=>e.y-t.y);let f=i*He,p=Ue.map(e=>f+e*i),m=p.map(()=>-1/0),h=new Map;for(let e of u){let t=!1;for(let n=0;n<p.length;n++)if(e.y>=m[n]+l){h.set(e.key,p[n]),m[n]=e.y,t=!0;break}if(!t){let t=m.indexOf(Math.min(...m));h.set(e.key,p[t]),m[t]=e.y}}return h}function Qe(e){let t=e.trim(),n=-1,r=-1,i=-1;if(t.startsWith(`#`)){let e=t.slice(1);e.length===3||e.length===4?(n=parseInt(e[0]+e[0],16),r=parseInt(e[1]+e[1],16),i=parseInt(e[2]+e[2],16)):(e.length===6||e.length===8)&&(n=parseInt(e.slice(0,2),16),r=parseInt(e.slice(2,4),16),i=parseInt(e.slice(4,6),16))}else{let e=t.match(/rgba?\(\s*([\d.]+)[\s,]+([\d.]+)[\s,]+([\d.]+)/i);e&&(n=parseFloat(e[1]),r=parseFloat(e[2]),i=parseFloat(e[3]))}return n<0||r<0||i<0||Number.isNaN(n)||Number.isNaN(r)||Number.isNaN(i)?!0:(.2126*n+.7152*r+.0722*i)/255>=.5}function z(e){return Qe(e.background)?`#000000`:`#ffffff`}function $e(e,t){return Qe(e.background)?t?`rgb(230,230,230)`:`rgb(255,255,255)`:t?`rgb(30,30,30)`:`rgb(0,0,0)`}function et(e,t,n){if(e.type===`position`){let r=e;if(r.entryPriceEditable&&r.side)return r.side===`buy`?t.pendingBuyLine:t.pendingSellLine;let i=e.pnl;return i===void 0?t.positionLine:i>=0?n.candle.up:n.candle.down}return e.type===`pending`?e.side===`buy`?t.pendingBuyLine:t.pendingSellLine:t.tradeLine}function tt(e){return e.type===`pending`?!0:e.type===`position`?!!e.entryPriceEditable:!1}function nt(e,t){return e&&t===null}function rt(e,t,n,r,i,a,o,s,c=null,l=null,u=null,d=null,f=new Set,p=`line`,m=!1,h=null,g={},_=new Set,v=0,y=!1,b=null,x=null,S=1,C=!1,w=null,T=!1){if(t.length===0)return{hitAreas:[],editAreas:[],hoverAreas:[],dragAreas:[],confirmAreas:[],addBracketAreas:[],clusterBadgeAreas:[],clusters:[]};let E=i.tradeLevels;Ge=[];let D=Math.min(Math.max(S,1),3),O=ke*D,k=Ae*D,A=Me*D,ee=je*D,j=Ne*D,te=Math.max(O,k,A),ne=Math.max(Ee+Te*2,te*2+Te*2),M=Math.max(Be,O*2+ze*2);e.save(),e.font=Fe;let N=[];for(let i of t){var P,re;let t=l===i.label&&u!==null?u:i.price,a=n.yToPixel(t,r,o);if(a<-40||a>o+40)continue;if(p===`dot`&&i.type===`position`&&i.label!==d){N.push({level:i,price:t,y:a,boxW:0,boxH:0});continue}if(i.type===`pending`&&i.orderType===`market`&&((P=i.data)==null?void 0:P._isDraft)===!0){N.push({level:i,price:t,y:a,boxW:0,boxH:0});continue}let c=qe(i)?i.pnlText:null,h=f.has(i.label),g=c?e.measureText(c).width+Pe:0,_=h&&!m,v=_?(A*2+j)*2:0,b=_||m?0:k*2+ee+O*2+Se/2,x=((re=i.data)==null?void 0:re._isDraft)===!0,S=i.label===d||h,C=i.type===`position`&&i.entryPriceEditable===!0,w=i.type===`pending`||C,T=i.lots,E=y&&(x||S)&&w&&T!==void 0?String(T):null,D=Xe(i,t,s,E!==null),te=e.measureText(D).width,M=Se+(E?Ce+e.measureText(E).width+Ce+we:0)+g+te+Se+v+b;N.push({level:i,price:t,y:a,boxW:M,boxH:ne})}let ie=new Set;h&&ie.add(h);let ae=v>0?ve(N,v,ie):[],oe=ae.filter(e=>!_.has(e.id)),se=ae.filter(e=>_.has(e.id)),ce=new Set;for(let e of oe)for(let t of e.members)ce.add(t.level.label);let le=new Map;for(let e of se)le.set(e.id,ye(e,ne,4));let ue=new Map;for(let e of se)for(let t of e.members)ue.set(t.level.label,e);N.sort((e,t)=>e.y-t.y);let de=[],F=new Map;for(let e of N){if(ce.has(e.level.label))continue;let t=ue.get(e.level.label);if(t){let n=le.get(t.id),r=n==null?void 0:n.get(e.level.label);if(r!==void 0){de.push({label:e.level.label,boxY:r,boxH:e.boxH}),F.set(e.level.label,{price:e.price,y:e.y,boxY:r,boxW:e.boxW,boxH:e.boxH});continue}}let n=e.y-e.boxH/2,r=0;for(;r<de.length+1&&de.some(t=>Je(n,e.boxH,t.boxY,t.boxH));)n-=e.boxH+2,r++;de.push({label:e.level.label,boxY:n,boxH:e.boxH}),F.set(e.level.label,{price:e.price,y:e.y,boxY:n,boxW:e.boxW,boxH:e.boxH})}let I=Ze(t,n,r,o,a,l,u,c,d,M),fe=[],pe=a*He,me=c==null?d:c;for(let e of t){if(e.label!==me)continue;let t=e,i=l===e.label;if(t.stopLossPrice!==void 0){var he;let a=`${e.label}:stopLoss`,s=l===a&&u!==null?u:i&&b!==null?b:t.stopLossPrice;fe.push({key:a,label:e.label,y:n.yToPixel(s,r,o),columnX:(he=I.get(a))==null?pe:he})}if(t.takeProfitPrice!==void 0){var ge;let a=`${e.label}:takeProfit`,s=l===a&&u!==null?u:i&&x!==null?x:t.takeProfitPrice;fe.push({key:a,label:e.label,y:n.yToPixel(s,r,o),columnX:(ge=I.get(a))==null?pe:ge})}}fe.sort((e,t)=>e.y-t.y);let _e=new Map,be=[];for(let e of fe){let t=F.get(e.label),n=e.y-M/2,r=Ye(t?{boxY:t.boxY,boxH:t.boxH}:null,n,M,t&&Math.sign(e.y-t.y)||1,be.filter(t=>t.columnX===e.columnX));_e.set(e.key,r),be.push({columnX:e.columnX,boxY:r,boxH:M})}let xe=c==null?d:c,De=h==null?d:h,Oe=nt(C,xe),Ie=N.filter(e=>!ce.has(e.level.label)),Le=[...Ie.filter(e=>e.level.label!==xe),...Ie.filter(e=>e.level.label===xe)],L=[],Re=[],Ue=[],We=[],Qe=[],z=[],$e=[],et=[];for(let t of oe)V(e,t,a,i,$e);for(let{level:t}of Le){let h=F.get(t.label);h&&(ut(e,t,h,a,E,i,s,t.label===c,t.label===d,n,r,o,l,u,I,f.has(t.label),p,L,Re,Ue,We,Qe,z,m,t.label===De?g:void 0,y,et,b,x,S,_e,Oe,T&&w?w(t):null,T,t.label===xe),ue.get(t.label)&&h.boxY!==h.y-ne/2&&st(e,h.boxY+ne/2,h.y,a,i))}if(d!==null&&!F.has(d)){let c=t.find(e=>e.label===d);if(c){let t=c,d=`${c.label}:stopLoss`,f=`${c.label}:takeProfit`,p=l===c.label,h=p&&b!==null?b:t.stopLossPrice,g=p&&x!==null?x:t.takeProfitPrice;if(h!==void 0&&g!==void 0){var tt,rt,it,at;let t=n.yToPixel(h,r,o),a=n.yToPixel(g,r,o),c=Math.max(Be,ke*2+ze*2);e.save(),e.font=Ve;let l=ke*2+R/2,u=R+e.measureText(`SL ${h.toFixed(s)}`).width+R+l,p=R+e.measureText(`TP ${g.toFixed(s)}`).width+R+l;e.restore();let m=(((tt=I.get(d))==null?pe:tt)-u/2-2+(((rt=I.get(f))==null?pe:rt)-p/2-2))/2,_=(it=_e.get(d))==null?t-c/2:it,v=(at=_e.get(f))==null?a-c/2:at,[y,b]=v<_?[v,_]:[_,v];ct(e,m,y+c,b,i)}if(h!==void 0){var ot;ft(e,t,`stopLoss`,h,n,r,o,(ot=I.get(d))==null?pe:ot,a,i,s,l,u,L,We,m,t._slOrderLabel,void 0,S,_e.get(d))}if(g!==void 0){var B;ft(e,t,`takeProfit`,g,n,r,o,(B=I.get(f))==null?pe:B,a,i,s,l,u,L,We,m,t._tpOrderLabel,void 0,S,_e.get(f))}}}{globalThis.__bracketDrawsLast=Ge.slice();let e=new Map;for(let t of Ge){var lt;let n=`${t.bracketType}@${t.price}`;e.set(n,((lt=e.get(n))==null?0:lt)+1)}let n=[...e.entries()].filter(([,e])=>e>1).map(([e])=>e);if(n.length>0){let e=n.join(`,`)+`|`+Ge.map(e=>`${e.label}/${e.levelType}/${e.bW}`).join(`,`);if(e!==Ke){Ke=e;let r={hoveredLabel:c,selectedLabel:d,draftOrderLabel:h,draftBracketPnl:g,levels:t.map(e=>{var t;return{label:e.label,type:e.type,price:e.price,sl:e.stopLossPrice,tp:e.takeProfitPrice,isDraft:!!((t=e.data)!=null&&t._isDraft)}})};console.warn(`[ActCharts] DUPLICATE BRACKET BOX → ${n.join(`, `)}\n hovered=${c==null?`null`:c} selected=${d==null?`null`:d} draft=${h==null?`null`:h}\n`+Ge.map((e,t)=>` box#${t+1} label=${e.label} type=${e.levelType} draft=${e.isDraft} ${e.bracketType}@${e.price} bX=${e.bX} bW=${e.bW} right=${e.rightEdge} boxY=${e.boxY} pnl=${e.pnlText===null?`none`:JSON.stringify(e.pnlText)} hideCC=${e.hideConfirmCancel}`).join(`
|
|
40
|
+
<script>(function(){var e=`data:image/svg+xml,%3csvg%20width='32'%20height='32'%20viewBox='0%200%2032%2032'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%3e%3cmask%20id='mask0'%20mask-type='alpha'%20maskUnits='userSpaceOnUse'%20x='0'%20y='0'%20width='32'%20height='32'%3e%3crect%20width='32'%20height='32'%20fill='%23C4C4C4'/%3e%3c/mask%3e%3cg%20mask='url(%23mask0)'%3e%3crect%20width='82.6667'%20height='32'%20fill='url(%23pattern0)'/%3e%3c/g%3e%3cdefs%3e%3cpattern%20id='pattern0'%20patternContentUnits='objectBoundingBox'%20width='1'%20height='1'%3e%3cuse%20xlink:href='%23image0'%20transform='translate(0%20-0.015879)%20scale(0.00304878%200.00787602)'/%3e%3c/pattern%3e%3cimage%20id='image0'%20width='328'%20height='131'%20xlink:href='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAUgAAACDCAYAAADvTILwAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyBpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMC1jMDYwIDYxLjEzNDc3NywgMjAxMC8wMi8xMi0xNzozMjowMCAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuM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,t=class{constructor(){this.bars=[]}set(e){this.bars=[...e].sort((e,t)=>e.time-t.time)}get all(){return this.bars}get length(){return this.bars.length}getVisible(e){let t=Math.max(0,Math.floor(e.startIndex)),n=Math.min(this.bars.length-1,Math.ceil(e.endIndex));return this.bars.slice(t,n+1)}getPriceRange(e,t=.05){let n=this.getVisible(e);if(n.length===0)return{min:0,max:1};let r=1/0,i=-1/0;for(let e of n)e.low<r&&(r=e.low),e.high>i&&(i=e.high);let a=i-r;return{min:r-a*t,max:i+a*t}}getVolumeRange(e){let t=this.getVisible(e);return t.length===0?{min:0,max:1}:{min:0,max:Math.max(...t.map(e=>{var t;return(t=e.volume)==null?0:t}))}}get hasVolumeData(){return this.bars.some(e=>{var t;return`volume`in e&&((t=e.volume)==null?0:t)>0})}getPricePrecision(){let e=2;for(let t of this.bars)for(let n of[t.open,t.high,t.low,t.close]){let t=n.toString(),r=t.indexOf(`.`);if(r!==-1){let n=t.length-r-1;n>e&&(e=n)}}return Math.min(e,8)}prepend(e){var t,n;let r=(t=(n=this.bars[0])==null?void 0:n.time)==null?1/0:t,i=e.filter(e=>e.time<r).sort((e,t)=>e.time-t.time);return i.length===0?0:(this.bars=[...i,...this.bars],i.length)}},n,r=class e{xToPixel(e,t,n){let r=n/Math.max(1,t.endIndex-t.startIndex);return(e-t.startIndex)*r+r/2}pixelToBarIndex(e,t,n){let r=n/Math.max(1,t.endIndex-t.startIndex);return t.startIndex+e/r-.5}candleBodyWidth(e,t){let n=t/Math.max(1,e.endIndex-e.startIndex)*.7;return Math.max(1,Math.min(n,40))}yToPixel(t,n,r){let{min:i,max:a}=n,o=e.VERTICAL_PADDING_PX,s=r-2*o;return o+s-(t-i)/(a-i)*s}pixelToPrice(t,n,r){let{min:i,max:a}=n,o=e.VERTICAL_PADDING_PX,s=r-2*o;return a-(t-o)/s*(a-i)}volumeToPixel(e,t,n){return n-e/t*n*.9}};n=r,n.VERTICAL_PADDING_PX=20;function i(e){if(!isFinite(e)||e<=0)return 1;let t=10**Math.floor(Math.log10(e)),n=e/t;return(n<1.5?1:n<3.5?2:n<7.5?5:10)*t}function a(e,t,n=48){let{min:r,max:a}=e;if(!isFinite(r)||!isFinite(a)||a<=r)return[r];let o=Math.max(2,Math.floor(t/n)),s=i((a-r)/o),c=Math.ceil(r/s)*s,l=[],u=s*1e-6;for(let e=c;e<=a+u;e+=s)l.push(e);return l}function o(e,t=0){return!isFinite(e)||e<=0?t:Math.max(t,-Math.floor(Math.log10(e)))}var s=class{constructor(){this.listeners=new Map}on(e,t){return this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(t),()=>this.off(e,t)}off(e,t){var n;(n=this.listeners.get(e))==null||n.delete(t)}emit(e,t){var n;(n=this.listeners.get(e))==null||n.forEach(e=>e(t))}};function c(e){let t=e.trim(),n=-1,r=-1,i=-1;if(t.startsWith(`#`)){let e=t.slice(1);e.length===3||e.length===4?(n=parseInt(e[0]+e[0],16),r=parseInt(e[1]+e[1],16),i=parseInt(e[2]+e[2],16)):(e.length===6||e.length===8)&&(n=parseInt(e.slice(0,2),16),r=parseInt(e.slice(2,4),16),i=parseInt(e.slice(4,6),16))}else{let e=t.match(/rgba?\(\s*([\d.]+)[\s,]+([\d.]+)[\s,]+([\d.]+)/i);e&&(n=parseFloat(e[1]),r=parseFloat(e[2]),i=parseFloat(e[3]))}return n<0||r<0||i<0||Number.isNaN(n)||Number.isNaN(r)||Number.isNaN(i)?!0:(.2126*n+.7152*r+.0722*i)/255>=.5}function l(e,t=.45){return c(e)?`rgba(0, 0, 0, ${t})`:`rgba(255, 255, 255, ${t})`}function u(e){return c(e)?`#000000`:`#ffffff`}function d(e,t){var n,r,i,a,o,s;return t?{background:(n=t.background)==null?e.background:n,grid:(r=t.grid)==null?e.grid:r,axisText:(i=t.axisText)==null?e.axisText:i,axisBorder:(a=t.axisBorder)==null?e.axisBorder:a,crosshair:(o=t.crosshair)==null?e.crosshair:o,tooltip:{...e.tooltip,...t.tooltip},candle:{...e.candle,...t.candle},volume:{...e.volume,...t.volume},ui:{...e.ui,...t.ui,stream:{...e.ui.stream,...(s=t.ui)==null?void 0:s.stream}},drawingToolbar:{...e.drawingToolbar,...t.drawingToolbar},topBar:{...e.topBar,...t.topBar},bottomBar:{...e.bottomBar,...t.bottomBar},indicatorOverlay:{...e.indicatorOverlay,...t.indicatorOverlay},tradeLevels:{...e.tradeLevels,...t.tradeLevels},tradePanel:{...e.tradePanel,...t.tradePanel},drawing:f(e.drawing,t.drawing)}:e}function f(e,t){if(!t)return e;let n={...e};for(let r of Object.keys(t)){let i=t[r];i&&(n[r]={...e[r],...i})}return n}function p(e,t){let n=document.createElement(`div`);n.style.display=`none`,t.appendChild(n);let r=e=>e.includes(`var(`)?(e=e.replace(/rgba\(\s*(var\([^)]+\))\s*,\s*([0-9.]+)\s*\)/g,`rgb($1 / $2)`),n.style.color=``,n.style.color=e,getComputedStyle(n).color||e):e,i={background:r(e.background),grid:r(e.grid),axisText:r(e.axisText),axisBorder:r(e.axisBorder),crosshair:r(e.crosshair),tooltip:{background:r(e.tooltip.background),text:r(e.tooltip.text),border:r(e.tooltip.border)},candle:{up:r(e.candle.up),down:r(e.candle.down),wickUp:r(e.candle.wickUp),wickDown:r(e.candle.wickDown),...e.candle.borderUp!==void 0&&{borderUp:r(e.candle.borderUp)},...e.candle.borderDown!==void 0&&{borderDown:r(e.candle.borderDown)}},volume:{up:r(e.volume.up),down:r(e.volume.down)},ui:{accent:r(e.ui.accent),accentText:r(e.ui.accentText),accentBg:r(e.ui.accentBg),accentBgStrong:r(e.ui.accentBgStrong),disabledText:r(e.ui.disabledText),soonBadgeText:r(e.ui.soonBadgeText),stream:{connected:r(e.ui.stream.connected),reconnecting:r(e.ui.stream.reconnecting),disconnected:r(e.ui.stream.disconnected)}},drawingToolbar:{iconColor:r(e.drawingToolbar.iconColor),activeIconColor:r(e.drawingToolbar.activeIconColor),flyoutLabelColor:r(e.drawingToolbar.flyoutLabelColor),flyoutHeadingColor:r(e.drawingToolbar.flyoutHeadingColor)},topBar:{btnColor:r(e.topBar.btnColor),activeBtnColor:r(e.topBar.activeBtnColor),flyoutRowColor:r(e.topBar.flyoutRowColor),flyoutCategoryColor:r(e.topBar.flyoutCategoryColor)},bottomBar:{btnColor:r(e.bottomBar.btnColor),activeBtnBg:r(e.bottomBar.activeBtnBg),activeBtnText:r(e.bottomBar.activeBtnText),activeBtnBorder:r(e.bottomBar.activeBtnBorder)},indicatorOverlay:{pillBg:r(e.indicatorOverlay.pillBg),iconColor:r(e.indicatorOverlay.iconColor),dropdownHoverBg:r(e.indicatorOverlay.dropdownHoverBg)},tradeLevels:{buySide:r(e.tradeLevels.buySide),sellSide:r(e.tradeLevels.sellSide),tradeLine:r(e.tradeLevels.tradeLine),positionLine:r(e.tradeLevels.positionLine),pendingBuyLine:r(e.tradeLevels.pendingBuyLine),pendingSellLine:r(e.tradeLevels.pendingSellLine),labelText:r(e.tradeLevels.labelText),closeBtn:r(e.tradeLevels.closeBtn),closeBtnText:r(e.tradeLevels.closeBtnText),boxBg:r(e.tradeLevels.boxBg),boxBgHover:r(e.tradeLevels.boxBgHover),dragHandle:r(e.tradeLevels.dragHandle),dragHandleHover:r(e.tradeLevels.dragHandleHover)},tradePanel:{background:r(e.tradePanel.background),border:r(e.tradePanel.border),headerBg:r(e.tradePanel.headerBg),tabActive:r(e.tradePanel.tabActive),tabInactive:r(e.tradePanel.tabInactive),rowHoverBg:r(e.tradePanel.rowHoverBg),rowText:r(e.tradePanel.rowText),rowSubText:r(e.tradePanel.rowSubText)},drawing:m(e.drawing,r)};return t.removeChild(n),n.remove(),i}function m(e,t){let n={};for(let r of Object.keys(e)){let i={...e[r]};if(i.strokeColor&&(i.strokeColor=t(i.strokeColor)),i.fillColor&&(i.fillColor=t(i.fillColor)),`textColor`in i&&i.textColor&&(i.textColor=t(i.textColor)),`levels`in i&&i.levels){let e={};for(let n of Object.keys(i.levels)){let r=i.levels[n];r&&(e[n]={...r,color:t(r.color)})}i.levels=e}n[r]=i}return n}var h={horizontalLine:{strokeColor:`#e8b84b`,lineWidth:1,lineStyle:`dashed`},verticalLine:{strokeColor:`#e8b84b`,lineWidth:1,lineStyle:`dashed`},trendLine:{strokeColor:`#26c6da`,lineWidth:1,lineStyle:`solid`},crossLine:{strokeColor:`#78909c`,lineWidth:1,lineStyle:`dashed`},trendAngle:{strokeColor:`#26c6da`,lineWidth:1,lineStyle:`solid`},flatChannel:{strokeColor:`#ab47bc`,lineWidth:1,lineStyle:`solid`,fillColor:`#ab47bc`,fillOpacity:.08},parallelChannel:{strokeColor:`#26c6da`,lineWidth:1,lineStyle:`solid`,fillColor:`#26c6da`,fillOpacity:.08},disjointChannel:{strokeColor:`#ef9a9a`,lineWidth:1,lineStyle:`solid`},pitchfork:{strokeColor:`#ffa726`,lineWidth:1,lineStyle:`solid`},schiffPitchfork:{strokeColor:`#ff7043`,lineWidth:1,lineStyle:`solid`},modifiedSchiff:{strokeColor:`#ef5350`,lineWidth:1,lineStyle:`solid`},insidePitchfork:{strokeColor:`#ab47bc`,lineWidth:1,lineStyle:`solid`},fibRetracement:{lineWidth:1,lineStyle:`dashed`,levels:{0:{visible:!0,color:`#ef5350`},"0.236":{visible:!0,color:`#e8b84b`},"0.382":{visible:!0,color:`#26a69a`},"0.5":{visible:!0,color:`#2196f3`},"0.618":{visible:!0,color:`#26a69a`},"0.786":{visible:!0,color:`#e8b84b`},1:{visible:!0,color:`#ef5350`}}},fibExtension:{lineWidth:1,lineStyle:`dashed`,levels:{0:{visible:!0,color:`#888888`},"0.618":{visible:!0,color:`#26a69a`},1:{visible:!0,color:`#888888`},"1.272":{visible:!0,color:`#2196f3`},"1.618":{visible:!0,color:`#e8b84b`},2:{visible:!0,color:`#ef5350`},"2.618":{visible:!0,color:`#ef5350`}}},fibProjection:{lineWidth:1,lineStyle:`dashed`,levels:{0:{visible:!0,color:`#ef5350`},"0.618":{visible:!0,color:`#26a69a`},1:{visible:!0,color:`#2196f3`},"1.272":{visible:!0,color:`#26a69a`},"1.618":{visible:!0,color:`#e8b84b`},2:{visible:!0,color:`#ef5350`},"2.618":{visible:!0,color:`#ef5350`}}},fibChannel:{strokeColor:`#888888`,lineWidth:1,lineStyle:`dashed`},fibFan:{strokeColor:`#888888`,lineWidth:1,lineStyle:`dashed`},fibCircles:{strokeColor:`#e8b84b`,lineWidth:1,lineStyle:`dashed`},fibSpiral:{strokeColor:`#e8b84b`,lineWidth:1,lineStyle:`solid`},fibTimezone:{strokeColor:`#e8b84b`,lineWidth:1,lineStyle:`dashed`},rectangle:{strokeColor:`#9b59b6`,lineWidth:1,lineStyle:`solid`,fillColor:`#9b59b6`,fillOpacity:.09},rotatedRectangle:{strokeColor:`#9c27b0`,lineWidth:1,lineStyle:`solid`,fillColor:`#9c27b0`,fillOpacity:.09},ellipse:{strokeColor:`#2196f3`,lineWidth:1,lineStyle:`solid`,fillColor:`#2196f3`,fillOpacity:.08},circle:{strokeColor:`#4caf50`,lineWidth:1,lineStyle:`solid`,fillColor:`#4caf50`,fillOpacity:.08},triangle:{strokeColor:`#ff9800`,lineWidth:1,lineStyle:`solid`,fillColor:`#ff9800`,fillOpacity:.08},arc:{strokeColor:`#26c6da`,lineWidth:1,lineStyle:`solid`},sineLine:{strokeColor:`#ce93d8`,lineWidth:1,lineStyle:`solid`},path:{strokeColor:`#ec407a`,lineWidth:1,lineStyle:`solid`},polyline:{strokeColor:`#ff7043`,lineWidth:1,lineStyle:`solid`},brush:{strokeColor:`#ff5722`,lineWidth:2,lineStyle:`solid`},highlighter:{strokeColor:`#ffeb3b`,lineWidth:8,lineStyle:`solid`,fillOpacity:.4},text:{textColor:`#f5f5f5`,fontSize:13,strokeColor:`#2196f3`},callout:{textColor:`#f5f5f5`,fontSize:13,strokeColor:`#546e7a`,fillColor:`#546e7a`,fillOpacity:.18},priceLabel:{textColor:`#ffffff`,fontSize:11,strokeColor:`#26a69a`,fillColor:`#26a69a`,fillOpacity:1},priceNote:{textColor:`#f5f5f5`,fontSize:12,strokeColor:`#ffa726`},anchoredNote:{textColor:`#f5f5f5`,fontSize:12,strokeColor:`#42a5f5`},arrowUp:{strokeColor:`#26a69a`,lineWidth:1.5,fillColor:`#26a69a`,fillOpacity:1},arrowDown:{strokeColor:`#ef5350`,lineWidth:1.5,fillColor:`#ef5350`,fillOpacity:1},arrowMarker:{strokeColor:`#ef5350`,lineWidth:1.5,fillColor:`#ef5350`,fillOpacity:1},flag:{strokeColor:`#ef5350`,lineWidth:1,fillColor:`#ef5350`,fillOpacity:.85},volumeProfile:{strokeColor:`#26c6da`,lineWidth:1,fillColor:`#26c6da`,fillOpacity:.35},anchoredVP:{strokeColor:`#42a5f5`,lineWidth:1,fillColor:`#42a5f5`,fillOpacity:.35},fixedRangeVP:{strokeColor:`#7e57c2`,lineWidth:1,fillColor:`#7e57c2`,fillOpacity:.35},abcdPattern:{strokeColor:`#26c6da`,lineWidth:1,lineStyle:`solid`},gartleyPattern:{strokeColor:`#26c6da`,lineWidth:1,lineStyle:`solid`},batPattern:{strokeColor:`#26c6da`,lineWidth:1,lineStyle:`solid`},butterflyPattern:{strokeColor:`#26c6da`,lineWidth:1,lineStyle:`solid`},crabPattern:{strokeColor:`#26c6da`,lineWidth:1,lineStyle:`solid`},sharkPattern:{strokeColor:`#26c6da`,lineWidth:1,lineStyle:`solid`},cypherPattern:{strokeColor:`#26c6da`,lineWidth:1,lineStyle:`solid`},headShoulders:{strokeColor:`#26c6da`,lineWidth:1,lineStyle:`solid`},trianglePattern:{strokeColor:`#26c6da`,lineWidth:1,lineStyle:`solid`},threeDrives:{strokeColor:`#26c6da`,lineWidth:1,lineStyle:`solid`},elliottImpulse:{strokeColor:`#42a5f5`,lineWidth:1,lineStyle:`solid`},elliottCorrective:{strokeColor:`#42a5f5`,lineWidth:1,lineStyle:`solid`},elliottTriangle:{strokeColor:`#42a5f5`,lineWidth:1,lineStyle:`solid`},elliottWxy:{strokeColor:`#42a5f5`,lineWidth:1,lineStyle:`solid`},elliottCombination:{strokeColor:`#42a5f5`,lineWidth:1,lineStyle:`solid`},gannFan:{strokeColor:`#ffa726`,lineWidth:1,lineStyle:`solid`},gannSquare:{strokeColor:`#ab47bc`,lineWidth:1,lineStyle:`solid`},gannBox:{strokeColor:`#7e57c2`,lineWidth:1,lineStyle:`solid`},priceRange:{strokeColor:`#66bb6a`,lineWidth:1,fillColor:`#66bb6a`,fillOpacity:.07},dateRange:{strokeColor:`#66bb6a`,lineWidth:1,fillColor:`#66bb6a`,fillOpacity:.07},datePriceRange:{strokeColor:`#66bb6a`,lineWidth:1,fillColor:`#66bb6a`,fillOpacity:.07},ruler:{strokeColor:`#90a4ae`,lineWidth:1,lineStyle:`dashed`,fillOpacity:.15},regressionTrend:{strokeColor:`#42a5f5`,lineWidth:1,lineStyle:`solid`},projection:{strokeColor:`#9575cd`,lineWidth:1,lineStyle:`dashed`},cyclicLines:{strokeColor:`#80cbc4`,lineWidth:1,lineStyle:`dashed`},timeCycles:{strokeColor:`#80cbc4`,lineWidth:1,lineStyle:`dashed`,fillColor:`#80cbc4`,fillOpacity:.06},priceProjection:{strokeColor:`#ef9a9a`,lineWidth:1,lineStyle:`dashed`,fillColor:`#ef9a9a`,fillOpacity:.09},ghostFeed:{strokeColor:`#9e9e9e`,lineWidth:1,lineStyle:`dotted`},longPosition:{strokeColor:`#b0bec5`,lineWidth:1,lineStyle:`solid`,fillOpacity:.18},shortPosition:{strokeColor:`#b0bec5`,lineWidth:1,lineStyle:`solid`,fillOpacity:.18}},g={background:`#141d22`,grid:`#243344`,axisText:`#a8bac8`,axisBorder:`#1c2a35`,crosshair:`rgba(255,255,255,0.4)`,tooltip:{background:`#1c2a35`,text:`#e8eef2`,border:`#1c2a35`},candle:{up:`#5caf79`,down:`#DF6868`,wickUp:`#5caf79`,wickDown:`#DF6868`},volume:{up:`rgba(92,175,121,0.4)`,down:`rgba(223,104,104,0.4)`},ui:{accent:`#398dff`,accentText:`#93bcff`,accentBg:`rgba(57,141,255,0.15)`,accentBgStrong:`rgba(57,141,255,0.22)`,disabledText:`#484f58`,soonBadgeText:`#30363d`,stream:{connected:`#5caf79`,reconnecting:`#e8b84b`,disconnected:`#555555`}},drawingToolbar:{iconColor:`#e8eef2`,activeIconColor:`#93bcff`,flyoutLabelColor:`#a8bac8`,flyoutHeadingColor:`#a8bac8`},topBar:{btnColor:`#a8bac8`,activeBtnColor:`#93bcff`,flyoutRowColor:`#a8bac8`,flyoutCategoryColor:`#a8bac8`},bottomBar:{btnColor:`#a8bac8`,activeBtnBg:`#5caf79`,activeBtnText:`#ffffff`,activeBtnBorder:`#5caf79`},indicatorOverlay:{pillBg:`rgba(28,42,53,0.73)`,iconColor:`#a8bac8`,dropdownHoverBg:`#1c2a35`},tradeLevels:{buySide:`#26a69a`,sellSide:`#ef5350`,tradeLine:`#5caf79`,positionLine:`#7b61ff`,pendingBuyLine:`rgba(92,175,121,0.75)`,pendingSellLine:`rgba(223,104,104,0.75)`,labelText:`#ffffff`,closeBtn:`rgba(255,255,255,0.18)`,closeBtnText:`#ffffff`,boxBg:`rgba(20, 24, 36, 0.92)`,boxBgHover:`rgba(35, 40, 58, 0.97)`,dragHandle:`rgba(255,255,255,0.3)`,dragHandleHover:`#9ca3af`},tradePanel:{background:`#1c2a35`,border:`#243344`,headerBg:`#151f28`,tabActive:`#93bcff`,tabInactive:`#a8bac8`,rowHoverBg:`rgba(255,255,255,0.04)`,rowText:`#e8eef2`,rowSubText:`#9ca3af`},drawing:h},_={background:`#ffffff`,grid:`#efefef`,axisText:`#666666`,axisBorder:`#cccccc`,crosshair:`#999999`,tooltip:{background:`#f8f8f8`,text:`#333333`,border:`#cccccc`},candle:{up:`#5caf79`,down:`#DF6868`,wickUp:`#5caf79`,wickDown:`#DF6868`},volume:{up:`rgba(92,175,121,0.6)`,down:`rgba(223,104,104,0.6)`},ui:{accent:`#398dff`,accentText:`#2a7aff`,accentBg:`rgba(57,141,255,0.10)`,accentBgStrong:`rgba(57,141,255,0.18)`,disabledText:`#94a3b8`,soonBadgeText:`#cbd5e1`,stream:{connected:`#5caf79`,reconnecting:`#d97706`,disconnected:`#94a3b8`}},drawingToolbar:{iconColor:`#333333`,activeIconColor:`#398dff`,flyoutLabelColor:`#666666`,flyoutHeadingColor:`#666666`},topBar:{btnColor:`#666666`,activeBtnColor:`#398dff`,flyoutRowColor:`#666666`,flyoutCategoryColor:`#666666`},bottomBar:{btnColor:`#666666`,activeBtnBg:`#5caf79`,activeBtnText:`#ffffff`,activeBtnBorder:`#5caf79`},indicatorOverlay:{pillBg:`rgba(248,248,248,0.85)`,iconColor:`#666666`,dropdownHoverBg:`#f0f0f0`},tradeLevels:{buySide:`#26a69a`,sellSide:`#ef5350`,tradeLine:`#5caf79`,positionLine:`#6d28d9`,pendingBuyLine:`rgba(92,175,121,0.75)`,pendingSellLine:`rgba(223,104,104,0.75)`,labelText:`#ffffff`,closeBtn:`rgba(0,0,0,0.15)`,closeBtnText:`#ffffff`,boxBg:`rgba(240, 244, 252, 0.95)`,boxBgHover:`rgba(255, 255, 255, 0.99)`,dragHandle:`#94a3b8`,dragHandleHover:`#475569`},tradePanel:{background:`#f8f8f8`,border:`#cccccc`,headerBg:`#f0f0f0`,tabActive:`#398dff`,tabInactive:`#666666`,rowHoverBg:`rgba(0,0,0,0.03)`,rowText:`#333333`,rowSubText:`#666666`},drawing:h},v=`'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif`,y={iconBtnSize:40,iconFontSize:`20px`,iconFontFamily:v,flyoutLabelFontSize:`12px`,flyoutLabelFontFamily:v,shortcutFontSize:`9px`,soonBadgeFontSize:`9px`,flyoutHeadingFontSize:`10px`,flyoutHeadingLetterSpacing:`0.08em`,scrollBtnHeight:20,scrollBtnFontSize:`9px`,barPadding:7,btnGap:4,mobileBreakpoint:480},b={height:`36px`,dropBtnFontSize:`11px`,dropBtnFontFamily:v,drawBtnSize:`26px`,drawBtnIconFontSize:`14px`,iconBtnSize:`26px`,mobileIconBtnSize:`28px`,mobileDrawBtnIconSize:`16px`,flyoutRowFontSize:`12px`,flyoutRowFontFamily:v,flyoutCategoryFontSize:`10px`,flyoutCategoryLetterSpacing:`0.08em`,flyoutCheckFontSize:`11px`,streamDotSize:`7px`},x={height:`32px`,btnFontSize:`11px`,btnFontFamily:v},S={fontSize:`11px`,fontFamily:v},C={fontSize:`11px`,fontFamily:v},w={labelHeight:18,labelPaddingX:4,fontSize:`11px`,fontFamily:v},T={pillFontSize:`13px`,pillFontFamily:v,dotFontSize:`8px`,pillIconFontSize:`12px`,collapseBtnFontSize:`13px`,collapseBtnFontFamily:v,dropdownRowFontSize:`11px`,dropdownRowFontFamily:v,dropdownIconFontSize:`10px`},E={size:22,mobileSize:24,iconSize:14,mobileIconSize:16},D={drawingToolbar:y,topBar:b,bottomBar:x,priceAxis:S,timeAxis:C,crosshair:w,indicatorOverlay:T,tradeButton:E};function O(e){return e?{drawingToolbar:{...y,...e.drawingToolbar},topBar:{...b,...e.topBar},bottomBar:{...x,...e.bottomBar},priceAxis:{...S,...e.priceAxis},timeAxis:{...C,...e.timeAxis},crosshair:{...w,...e.crosshair},indicatorOverlay:{...T,...e.indicatorOverlay},tradeButton:{...E,...e.tradeButton}}:D}var k={pnlPill:{positionsAbbrev:`POS`,showPositionsTitle:`Show positions on chart · drag handle to move · double-click to reset`,hidePositionsTitle:`Hide positions on chart · drag handle to move · double-click to reset`,bulkLevelsTitle:`Set SL · TP · TSL on all {count} {symbol} positions`,bulkLevelsMixedTitle:`Bulk levels need all {count} {symbol} positions in one direction`,closeAllTitle:`Close all {symbol} positions`},topBar:{series:{candlestick:`Candles`,hollow:`Hollow`,ohlc:`OHLC`,line:`Line`,area:`Area`,heikinashi:`Heikin Ashi`,volumecandles:`Volume Candles`,linemarkers:`Line with Markers`,step:`Step Line`,hlcarea:`HLC Area`,baseline:`Baseline`,columns:`Columns`,highlow:`High-low`},timeframes:{"1m":`1m`,"3m":`3m`,"4m":`4m`,"5m":`5m`,"10m":`10m`,"15m":`15m`,"30m":`30m`,"1h":`1h`,"2h":`2h`,"4h":`4h`,"8h":`8h`,"1D":`1D`,"1W":`1W`,"1M":`1M`},indicatorsBtn:`Indicators`,indicatorsBtnActive:`Indicators ({count})`,toggleDrawingTitle:`Toggle Drawing Tools`,toggleFullscreenTitle:`Toggle Fullscreen`,exitFullscreenTitle:`Exit Fullscreen`,settingsTitle:`Settings`,tfcToggleTitle:`Trade from Charts`,disableCrosshairTitle:`Disable crosshair`,enableCrosshairTitle:`Enable crosshair`,pnlPillBtn:`P/L`,hidePnlPillTitle:`Hide P/L pill for {symbol}`,showPnlPillTitle:`Show P/L pill for {symbol}`},bottomBar:{durations:{"1D":`1D`,"5D":`5D`,"1M":`1M`,"3M":`3M`,"6M":`6M`,"1Y":`1Y`,"5Y":`5Y`,All:`All`}},drawingToolbar:{categories:{trendLines:`Trend Lines & Channels`,fibonacci:`Fibonacci & Gann Tools`,shapes:`Geometric Shapes`,measurements:`Measurement Tools`,pitchforks:`Pitchfork Tools`,volume:`Volume & Statistical Tools`,annotations:`Annotation Tools`,patterns:`Pattern Recognition`,elliott:`Elliott Wave Tools`,brushes:`Brush & Highlighter`,advanced:`Advanced Tools`,forecasting:`Forecasting`,priceProjection:`Price Projection Tools`},tools:{horizontalLine:`Horizontal Line`,verticalLine:`Vertical Line`,trendLine:`Trend Line`,trendAngle:`Trend Angle`,crossLine:`Cross Line`,parallelChannel:`Parallel Channel`,flatChannel:`Flat Top/Bottom Channel`,disjointChannel:`Disjoint Channel`,fibRetracement:`Fibonacci Retracement`,fibExtension:`Fibonacci Extension`,fibChannel:`Fibonacci Channel`,fibTimezone:`Fibonacci Timezone`,fibCircles:`Fibonacci Circles`,fibSpiral:`Fibonacci Spiral`,fibFan:`Fibonacci Speed Resistance Fan`,fibProjection:`Fibonacci Projection`,gannFan:`Gann Fan`,gannSquare:`Gann Square`,gannBox:`Gann Box`,rectangle:`Rectangle`,rotatedRectangle:`Rotated Rectangle`,ellipse:`Ellipse`,triangle:`Triangle`,circle:`Circle`,arc:`Arc`,polyline:`Polyline`,path:`Path`,priceRange:`Price Range`,dateRange:`Date Range`,datePriceRange:`Date & Price Range`,ruler:`Ruler`,pitchfork:`Pitchfork`,schiffPitchfork:`Schiff Pitchfork`,modifiedSchiff:`Modified Schiff Pitchfork`,insidePitchfork:`Inside Pitchfork`,fixedRangeVP:`Fixed Range Volume Profile`,anchoredVP:`Anchored Volume Profile`,volumeProfile:`Volume Profile`,regressionTrend:`Regression Trend`,text:`Text`,callout:`Callout`,priceLabel:`Price Label`,arrowMarker:`Arrow Marker`,flag:`Flag`,priceNote:`Price Note`,anchoredNote:`Anchored Note`,arrowUp:`Arrow Up`,arrowDown:`Arrow Down`,headShoulders:`Head & Shoulders`,trianglePattern:`Triangle Pattern`,threeDrives:`3 Drives Pattern`,abcdPattern:`ABCD Pattern`,cypherPattern:`Cypher Pattern`,butterflyPattern:`Butterfly Pattern`,batPattern:`Bat Pattern`,gartleyPattern:`Gartley Pattern`,crabPattern:`Crab Pattern`,sharkPattern:`Shark Pattern`,elliottImpulse:`Elliott Impulse (12345)`,elliottCorrective:`Elliott Corrective (ABC)`,elliottTriangle:`Elliott Wave Triangle`,elliottCombination:`Elliott Wave Combination`,elliottWxy:`Elliott Double Three (WXY)`,brush:`Brush`,highlighter:`Highlighter`,ghostFeed:`Ghost Feed`,longPosition:`Long Position`,shortPosition:`Short Position`,projection:`Projection`,sineLine:`Sine Line`,cyclicLines:`Cyclic Lines`,timeCycles:`Time Cycles`,priceProjection:`Price Projection`},actions:{undo:`Undo (Ctrl+Z)`,redo:`Redo (Ctrl+Y)`,deleteSelected:`Delete Selected (Del)`,clearAll:`Clear All`,showAll:`Show All`,hideAll:`Hide All`,lockAll:`Lock All`,unlockAll:`Unlock All`,moreActions:`Actions`},soonBadge:`soon`,scrollUp:`Scroll up`,scrollDown:`Scroll down`},ohlc:{open:`O`,high:`H`,low:`L`,close:`C`,volume:`V`},trade:{buy:`Buy`,sell:`Sell`,limit:`Limit`,stop:`Stop`,market:`Market`,at:`at`,qty:`Qty`,placeOrderTitle:`Place order at this price`,actionAlert:`Alert`,actionPending:`Pending`,actionSl:`SL`,actionTp:`TP`,actionTsl:`TSL`,actionCloseTitle:`Close`,directionAbove:`Above`,directionBelow:`Below`,actionBulkNoPositionsTitle:`No open {symbol} positions`,actionBulkMixedTitle:`Bulk levels need all {symbol} positions in one direction`},dialogs:{settings:{title:`Chart Settings`,tfcSection:`Trade from Charts`,showLabel:`Show`,positionStyleLabel:`Position Style`,showAll:`All`,showPositions:`Positions Only`,showOrders:`Orders Only`,showNone:`None`,styleLine:`Full Line`,styleDot:`Dot`,resetBtn:`Reset to Defaults`},indicator:{titleSuffix:`Settings`,noParams:`No configurable parameters.`}},chart:{loading:`Loading…`,noData:`No data available`,scrollToLatest:`Scroll to latest`,nIndicators:`{count} indicators`}};function A(e){var t,n,r,i,a,o,s,c;if(!e)return k;let l=k;return{topBar:{...l.topBar,...e.topBar,series:{...l.topBar.series,...(t=e.topBar)==null?void 0:t.series},timeframes:{...l.topBar.timeframes,...(n=e.topBar)==null?void 0:n.timeframes}},bottomBar:{durations:{...l.bottomBar.durations,...(r=e.bottomBar)==null?void 0:r.durations}},drawingToolbar:{...l.drawingToolbar,...e.drawingToolbar,categories:{...l.drawingToolbar.categories,...(i=e.drawingToolbar)==null?void 0:i.categories},tools:{...l.drawingToolbar.tools,...(a=e.drawingToolbar)==null?void 0:a.tools},actions:{...l.drawingToolbar.actions,...(o=e.drawingToolbar)==null?void 0:o.actions}},ohlc:{...l.ohlc,...e.ohlc},trade:{...l.trade,...e.trade},dialogs:{settings:{...l.dialogs.settings,...(s=e.dialogs)==null?void 0:s.settings},indicator:{...l.dialogs.indicator,...(c=e.dialogs)==null?void 0:c.indicator}},chart:{...l.chart,...e.chart},pnlPill:{...l.pnlPill,...e.pnlPill}}}function j(e){let t=Math.max(0,Math.min(8,Math.round(e)));return 10**-(t===3||t===5?t-1:t)}function M(e,t){var n,r,i;let a=typeof(e==null?void 0:e.pipSize)==`number`&&Number.isFinite(e.pipSize)&&e.pipSize>0;return{pipSize:a?e.pipSize:j(t),contractSize:(n=e==null?void 0:e.contractSize)==null?1:n,valuePerPoint:(r=e==null?void 0:e.valuePerPoint)==null?1:r,currencySymbol:(i=e==null?void 0:e.currencySymbol)==null?`$`:i,pipSizeInferred:!a}}function N(e,t){return!Number.isFinite(e)||!(t>0)?0:e/t}function P(e){if(!Number.isFinite(e)||e===0)return`0`;let t=Math.abs(e);return t>=1e9?`${(e/1e9).toFixed(2)}B`:t>=1e6?`${(e/1e6).toFixed(2)}M`:t>=1e3?`${(e/1e3).toFixed(2)}K`:e.toFixed(t<10?2:0)}function F(e){let t=Math.abs(Math.round(e/1e3));if(t===0)return`0m`;let n=Math.floor(t/86400),r=Math.floor(t%86400/3600),i=Math.floor(t%3600/60),a=t%60;return n>0?r>0?`${n}d ${r}h`:`${n}d`:r>0?i>0?`${r}h ${i}m`:`${r}h`:i>0?a>0?`${i}m ${a}s`:`${i}m`:`${a}s`}var I,L=class e{constructor(t,n,r,i,a,o=()=>!1,s,c,l,u){var d,f,p,m;this.canvas=t,this.getViewport=n,this.setViewport=r,this.totalBars=i,this.onUpdate=a,this.isLocked=o,this.panY=s,this.onDragStart=c,this.onDragEnd=l,this.isDragging=!1,this.isTouchDrag=!1,this.lastX=0,this.lastY=0,this.dragStartX=0,this.dragStartY=0,this.hasPanned=!1,this.dragStartFired=!1,this._velBuffer=[],this._momentumRafId=null,this.onMouseDown=e=>{this._stopMomentum(),!this.isLocked()&&(this.isDragging=!0,this.isTouchDrag=!1,this.lastX=e.clientX,this.lastY=e.clientY,this.dragStartX=e.clientX,this.dragStartY=e.clientY,this.hasPanned=!1,this._velBuffer.length=0)},this.onTouchStart=e=>{var t;if(e.touches.length!==1){this._stopMomentum();return}this._stopMomentum(),!this.isLocked()&&(this.isDragging=!0,this.isTouchDrag=!0,this.lastX=e.touches[0].clientX,this.lastY=e.touches[0].clientY,this.dragStartX=e.touches[0].clientX,this.dragStartY=e.touches[0].clientY,this.dragStartFired=!0,this._velBuffer.length=0,(t=this.onDragStart)==null||t.call(this))},this.onMouseMove=t=>{if(!this.isDragging)return;if(this.isLocked()){this.isDragging=!1,this.hasPanned=!1;return}let n=t.clientX-this.lastX,r=t.clientY-this.lastY;this.lastX=t.clientX,this.lastY=t.clientY;let i=Math.abs(t.clientX-this.dragStartX),a=Math.abs(t.clientY-this.dragStartY);if(!this.hasPanned&&(i>e.DRAG_THRESHOLD||a>e.DRAG_THRESHOLD)){var o;this.hasPanned=!0,this.dragStartFired=!0,(o=this.onDragStart)==null||o.call(this),this.canvas.style.cursor=`grabbing`}this.hasPanned&&(this._recordVelocitySample(n,performance.now()),this.pan(n),this.panY&&this.panY(r))},this.onTouchMove=e=>{if(!this.isDragging||e.touches.length!==1)return;if(this.isLocked()){this.isDragging=!1;return}e.preventDefault();let t=e.touches[0].clientX-this.lastX,n=e.touches[0].clientY-this.lastY;this._recordVelocitySample(t,performance.now()),this.pan(t),this.panY&&this.panY(n),this.lastX=e.touches[0].clientX,this.lastY=e.touches[0].clientY},this.onMouseUp=()=>{if(this.hasPanned&&(this.canvas.style.cursor=`crosshair`),this.isDragging=!1,this.hasPanned=!1,this.dragStartFired){var e;this.dragStartFired=!1;let t=this._computeReleaseVelocity();this._velBuffer.length=0,this._startMomentum(t)||(e=this.onDragEnd)==null||e.call(this)}},this._momentumEnabled=(d=u==null?void 0:u.enabled)==null?!0:d,this._momentumDecay=Math.min(.99,Math.max(.8,(f=u==null?void 0:u.decay)==null?.95:f)),this._momentumThreshold=(p=u==null?void 0:u.threshold)==null?.3:p,this._momentumMaxVelocity=(m=u==null?void 0:u.maxVelocity)==null?6:m,this.attach()}attach(){this.canvas.addEventListener(`mousedown`,this.onMouseDown),window.addEventListener(`mousemove`,this.onMouseMove),window.addEventListener(`mouseup`,this.onMouseUp),this.canvas.addEventListener(`touchstart`,this.onTouchStart,{passive:!1}),window.addEventListener(`touchmove`,this.onTouchMove,{passive:!1}),window.addEventListener(`touchend`,this.onMouseUp)}cancel(){this._stopMomentum(),this.isDragging=!1,this.hasPanned=!1}destroy(){this._stopMomentum(),this.canvas.removeEventListener(`mousedown`,this.onMouseDown),window.removeEventListener(`mousemove`,this.onMouseMove),window.removeEventListener(`mouseup`,this.onMouseUp),this.canvas.removeEventListener(`touchstart`,this.onTouchStart),window.removeEventListener(`touchmove`,this.onTouchMove),window.removeEventListener(`touchend`,this.onMouseUp)}_recordVelocitySample(t,n){this._velBuffer.push({dx:t,t:n});let r=n-e.VEL_WINDOW_MS,i=0;for(;i<this._velBuffer.length&&this._velBuffer[i].t<r;)i++;i>0&&this._velBuffer.splice(0,i)}_computeReleaseVelocity(){let e=this._velBuffer;if(e.length<2)return 0;let t=e.reduce((e,t)=>e+t.dx,0),n=e[e.length-1].t-e[0].t;if(n<=0)return 0;let r=t/n;return Math.sign(r)*Math.min(Math.abs(r),this._momentumMaxVelocity)}_startMomentum(e){if(!this._momentumEnabled||Math.abs(e)<this._momentumThreshold)return!1;let t=null,n=e,r=this._momentumDecay,i=e=>{if(t===null){t=e,this._momentumRafId=requestAnimationFrame(i);return}let a=e-t;t=e,n*=r**(a/16.67);let o=n*a;if(Math.abs(o)<.5){var s;this._stopMomentum(),(s=this.onDragEnd)==null||s.call(this);return}if(this.isLocked()){var c;this._stopMomentum(),(c=this.onDragEnd)==null||c.call(this);return}let l=this.getViewport().startIndex;if(this.pan(o),this.getViewport().startIndex===l){var u;this._stopMomentum(),(u=this.onDragEnd)==null||u.call(this);return}this._momentumRafId=requestAnimationFrame(i)};return this._momentumRafId=requestAnimationFrame(i),!0}_stopMomentum(){this._momentumRafId!==null&&(cancelAnimationFrame(this._momentumRafId),this._momentumRafId=null)}pan(e){let t=this.getViewport(),n=t.endIndex-t.startIndex,r=n/(this.isTouchDrag?this.canvas.clientWidth||this.canvas.width/(window.devicePixelRatio||1):this.canvas.width),i=-e*r,a=Math.max(0,this.totalBars()-Math.floor(n/2)),o=Math.max(0,Math.min(a,t.startIndex+i));this.setViewport({...t,startIndex:o,endIndex:o+n}),this.onUpdate()}};I=L,I.DRAG_THRESHOLD=4,I.VEL_WINDOW_MS=100;var R=10,z=500,B=class{constructor(e,t,n,r,i,a=()=>e.getBoundingClientRect(),o=()=>e.offsetWidth,s){this.canvas=e,this.getViewport=t,this.setViewport=n,this.totalBars=r,this.onUpdate=i,this.getCanvasRect=a,this.getChartWidth=o,this.panByPixelDelta=s,this._pinchStartDist=0,this._pinchStartRatio=0,this._pinchStartViewport=null,this.onWheel=e=>{e.preventDefault();let t=this.getViewport(),n=t.endIndex-t.startIndex,r;if(e.ctrlKey){let t=Math.max(-50,Math.min(50,e.deltaY));r=Math.exp(t*.01)}else{if(e.deltaX!==0&&Math.abs(e.deltaX)>Math.abs(e.deltaY)*.5){this.panByPixelDelta&&this.panByPixelDelta(e.deltaX),this.onUpdate();return}if(e.deltaY===0)return;r=e.deltaY>0?1.1:.9}let i=Math.round(Math.max(R,Math.min(z,n*r)));if(t.endIndex>=this.totalBars()){let e=Math.min(t.endIndex,this.totalBars()+Math.floor(i/2)),n=Math.max(0,e-i);this.setViewport({...t,startIndex:n,endIndex:n+i})}else{let r=e.offsetX/this.getChartWidth(),a=t.startIndex+n*r,o=Math.max(0,a-i*r);this.setViewport({...t,startIndex:o,endIndex:o+i})}this.onUpdate()},this.onTouchStart=e=>{if(e.touches.length!==2)return;let t=this.pinchDist(e.touches[0],e.touches[1]);this._pinchStartDist=t,this._pinchStartViewport={...this.getViewport()};let n=this.getCanvasRect(),r=(e.touches[0].clientX+e.touches[1].clientX)/2-n.left;this._pinchStartRatio=Math.max(0,Math.min(1,r/this.getChartWidth()))},this.onTouchMove=e=>{if(e.touches.length!==2)return;e.preventDefault();let t=this.pinchDist(e.touches[0],e.touches[1]);if(this._pinchStartDist===0||!this._pinchStartViewport){this._pinchStartDist=t,this._pinchStartViewport={...this.getViewport()};let n=this.getCanvasRect(),r=(e.touches[0].clientX+e.touches[1].clientX)/2;this._pinchStartRatio=Math.max(0,Math.min(1,(r-n.left)/this.getChartWidth()));return}let n=this._pinchStartDist/t,r=this._pinchStartViewport,i=r.endIndex-r.startIndex,a=Math.round(Math.max(R,Math.min(z,i*n))),o=this._pinchStartRatio,s=r.startIndex+i*o,c=Math.max(0,s-a*o);this.setViewport({...r,startIndex:c,endIndex:c+a}),this.onUpdate()},this.onTouchEnd=()=>{this._pinchStartDist=0,this._pinchStartViewport=null},this.attach()}attach(){this.canvas.addEventListener(`wheel`,this.onWheel,{passive:!1}),this.canvas.addEventListener(`touchstart`,this.onTouchStart,{passive:!1}),this.canvas.addEventListener(`touchmove`,this.onTouchMove,{passive:!1}),this.canvas.addEventListener(`touchend`,this.onTouchEnd)}destroy(){this.canvas.removeEventListener(`wheel`,this.onWheel),this.canvas.removeEventListener(`touchstart`,this.onTouchStart),this.canvas.removeEventListener(`touchmove`,this.onTouchMove),this.canvas.removeEventListener(`touchend`,this.onTouchEnd)}pinchDist(e,t){let n=t.clientX-e.clientX,r=t.clientY-e.clientY;return Math.sqrt(n*n+r*r)}};function ee(e,t,n,r,i,a,o,s){let c=i.candleBodyWidth(n,o),l=t.length,u=new Float32Array(l),d=new Float32Array(l),f=new Float32Array(l),p=new Float32Array(l),m=new Float32Array(l),h=new Uint8Array(l),g=Math.floor(n.startIndex);for(let e=0;e<l;e++){let a=t[e];u[e]=i.xToPixel(g+e,n,o),d[e]=i.yToPixel(a.high,r,s),f[e]=i.yToPixel(a.low,r,s),p[e]=i.yToPixel(a.open,r,s),m[e]=i.yToPixel(a.close,r,s),h[e]=+(a.close>=a.open)}e.lineWidth=1,e.strokeStyle=a.candle.wickUp,e.beginPath();for(let t=0;t<l;t++)h[t]&&(e.moveTo(u[t],d[t]),e.lineTo(u[t],f[t]));e.stroke(),e.strokeStyle=a.candle.wickDown,e.beginPath();for(let t=0;t<l;t++)h[t]||(e.moveTo(u[t],d[t]),e.lineTo(u[t],f[t]));e.stroke();for(let t=0;t<l;t++){var _,v;let n=Math.min(p[t],m[t]),r=Math.max(Math.abs(m[t]-p[t]),1),i=h[t]===1,o=i?a.candle.up:a.candle.down,s=i?(_=a.candle.borderUp)==null?a.candle.up:_:(v=a.candle.borderDown)==null?a.candle.down:v;e.fillStyle=o,e.fillRect(u[t]-c/2,n,c,r),s!==o&&(e.strokeStyle=s,e.lineWidth=1,e.strokeRect(u[t]-c/2,n,c,r))}}function te(e,t,n,r,i,a,o,s){let c=i.candleBodyWidth(n,o),l=Math.floor(n.startIndex);for(let d=0;d<t.length;d++){let f=t[d],p=l+d,m=i.xToPixel(p,n,o),h=f.close>=f.open,g=i.yToPixel(f.open,r,s),_=i.yToPixel(f.close,r,s),v=i.yToPixel(f.high,r,s),y=i.yToPixel(f.low,r,s),b=h?a.candle.up:a.candle.down,x=h?a.candle.wickUp:a.candle.wickDown;e.beginPath(),e.strokeStyle=x,e.lineWidth=1,e.moveTo(m,v),e.lineTo(m,y),e.stroke();let S=Math.min(g,_),C=Math.max(Math.abs(_-g),1);if(h)e.strokeStyle=b,e.lineWidth=1,e.strokeRect(m-c/2,S,c,C);else{var u;let t=(u=a.candle.borderDown)==null?a.candle.down:u;e.fillStyle=b,e.fillRect(m-c/2,S,c,C),t!==b&&(e.strokeStyle=t,e.lineWidth=1,e.strokeRect(m-c/2,S,c,C))}}}function ne(e,t){let n=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);if(n)return`rgba(${n[1]},${n[2]},${n[3]},${t})`;let r=e.replace(`#`,``),i=r.length===3?r.split(``).map(e=>e+e).join(``):r;return`rgba(${parseInt(i.slice(0,2),16)},${parseInt(i.slice(2,4),16)},${parseInt(i.slice(4,6),16)},${t})`}var re=null;function ie(e,t,n,r,i,a,o,s,c=!1){if(t.length===0)return;let l=Math.floor(n.startIndex);if(c){let c=i.xToPixel(l+t.length-1,n,o),u=i.xToPixel(l,n,o);e.beginPath();for(let a=0;a<t.length;a++){let c=i.xToPixel(l+a,n,o),u=i.yToPixel(t[a].close,r,s);a===0?e.moveTo(c,u):e.lineTo(c,u)}if(e.lineTo(c,s),e.lineTo(u,s),e.closePath(),!re||re.height!==s||re.color!==a.candle.up){let t=e.createLinearGradient(0,0,0,s);t.addColorStop(0,ne(a.candle.up,.15)),t.addColorStop(1,ne(a.candle.up,0)),re={gradient:t,height:s,color:a.candle.up}}e.fillStyle=re.gradient,e.fill()}e.beginPath(),e.strokeStyle=a.candle.up,e.lineWidth=1.5,e.lineJoin=`round`;for(let a=0;a<t.length;a++){let c=i.xToPixel(l+a,n,o),u=i.yToPixel(t[a].close,r,s);a===0?e.moveTo(c,u):e.lineTo(c,u)}e.stroke()}function ae(e,t,n,r,i,a,o,s){let c=Math.max(2,i.candleBodyWidth(n,o)*.4),l=Math.floor(n.startIndex);for(let u=0;u<t.length;u++){let d=t[u],f=l+u,p=i.xToPixel(f,n,o),m=d.close>=d.open?a.candle.up:a.candle.down,h=i.yToPixel(d.open,r,s),g=i.yToPixel(d.close,r,s),_=i.yToPixel(d.high,r,s),v=i.yToPixel(d.low,r,s);e.strokeStyle=m,e.lineWidth=1,e.beginPath(),e.moveTo(p,_),e.lineTo(p,v),e.stroke(),e.beginPath(),e.moveTo(p-c,h),e.lineTo(p,h),e.stroke(),e.beginPath(),e.moveTo(p,g),e.lineTo(p+c,g),e.stroke()}}function oe(e,t,n,r,i,a,o,s,c){let l=i.candleBodyWidth(n,o),u=Math.floor(n.startIndex);for(let d=0;d<t.length;d++){let f=t[d];if(f.volume==null)continue;let p=u+d,m=i.xToPixel(p,n,o),h=f.close>=f.open,g=s-i.volumeToPixel(f.volume,r,s),_=c+s-g;e.fillStyle=h?a.volume.up:a.volume.down,e.fillRect(m-l/2,_,l,g)}}function se(e){let t=[];for(let n=0;n<e.length;n++){let r=e[n],i=(r.open+r.high+r.low+r.close)/4,a=n===0?(r.open+r.close)/2:(t[n-1].open+t[n-1].close)/2;t.push({time:r.time,open:a,close:i,high:Math.max(r.high,a,i),low:Math.min(r.low,a,i),volume:r.volume})}return t}function ce(e,t,n,r,i,a,o,s){let c=se(t),l=i.candleBodyWidth(n,o),u=Math.floor(n.startIndex);for(let t=0;t<c.length;t++){var d,f;let p=c[t],m=u+t,h=i.xToPixel(m,n,o),g=p.close>=p.open,_=i.yToPixel(p.open,r,s),v=i.yToPixel(p.close,r,s),y=i.yToPixel(p.high,r,s),b=i.yToPixel(p.low,r,s),x=g?a.candle.up:a.candle.down,S=g?a.candle.wickUp:a.candle.wickDown,C=g?(d=a.candle.borderUp)==null?a.candle.up:d:(f=a.candle.borderDown)==null?a.candle.down:f;e.beginPath(),e.strokeStyle=S,e.lineWidth=1,e.moveTo(h,y),e.lineTo(h,b),e.stroke();let w=Math.min(_,v),T=Math.max(Math.abs(v-_),1);e.fillStyle=x,e.fillRect(h-l/2,w,l,T),C!==x&&(e.strokeStyle=C,e.lineWidth=1,e.strokeRect(h-l/2,w,l,T))}}function V(e,t,n,r,i,a,o,s){let c=i.candleBodyWidth(n,o),l=Math.max(...t.map(e=>{var t;return(t=e.volume)==null?0:t}),1),u=Math.floor(n.startIndex);for(let m=0;m<t.length;m++){var d,f,p;let h=t[m],g=u+m,_=i.xToPixel(g,n,o),v=h.close>=h.open,y=l>0?((d=h.volume)==null?l:d)/l:1,b=Math.max(1,y*c),x=i.yToPixel(h.open,r,s),S=i.yToPixel(h.close,r,s),C=i.yToPixel(h.high,r,s),w=i.yToPixel(h.low,r,s),T=v?a.candle.up:a.candle.down,E=v?a.candle.wickUp:a.candle.wickDown,D=v?(f=a.candle.borderUp)==null?a.candle.up:f:(p=a.candle.borderDown)==null?a.candle.down:p;e.beginPath(),e.strokeStyle=E,e.lineWidth=1,e.moveTo(_,C),e.lineTo(_,w),e.stroke();let O=Math.min(x,S),k=Math.max(Math.abs(S-x),1);e.fillStyle=T,e.fillRect(_-b/2,O,b,k),D!==T&&(e.strokeStyle=D,e.lineWidth=1,e.strokeRect(_-b/2,O,b,k))}}function le(e,t,n,r,i,a,o,s){if(t.length===0)return;e.beginPath(),e.strokeStyle=a.candle.up,e.lineWidth=1.5,e.lineJoin=`round`;let c=Math.floor(n.startIndex);for(let a=0;a<t.length;a++){let l=c+a,u=i.xToPixel(l,n,o),d=i.yToPixel(t[a].close,r,s);a===0?e.moveTo(u,d):e.lineTo(u,d)}e.stroke();let l=Math.min(3,i.candleBodyWidth(n,o)*.35);if(!(l<.5)){e.fillStyle=a.candle.up;for(let a=0;a<t.length;a++){let u=c+a,d=i.xToPixel(u,n,o),f=i.yToPixel(t[a].close,r,s);e.beginPath(),e.arc(d,f,l,0,Math.PI*2),e.fill()}}}function ue(e,t,n,r,i,a,o,s){if(t.length===0)return;e.beginPath(),e.strokeStyle=a.candle.up,e.lineWidth=1.5,e.lineJoin=`round`;let c=Math.floor(n.startIndex),l=0;for(let a=0;a<t.length;a++){let u=c+a,d=i.xToPixel(u,n,o),f=i.yToPixel(t[a].close,r,s);a===0?e.moveTo(d,f):(e.lineTo(d,l),e.lineTo(d,f)),l=f}e.stroke()}function de(e,t){let n=e.replace(`#`,``),r=n.length===3?n.split(``).map(e=>e+e).join(``):n;return`rgba(${parseInt(r.slice(0,2),16)},${parseInt(r.slice(2,4),16)},${parseInt(r.slice(4,6),16)},${t})`}function fe(e,t,n,r,i,a,o,s){if(t.length===0)return;let c=Math.floor(n.startIndex);e.beginPath();for(let a=0;a<t.length;a++){let l=i.xToPixel(c+a,n,o),u=i.yToPixel(t[a].high,r,s);a===0?e.moveTo(l,u):e.lineTo(l,u)}for(let a=t.length-1;a>=0;a--){let l=i.xToPixel(c+a,n,o),u=i.yToPixel(t[a].low,r,s);e.lineTo(l,u)}e.closePath(),e.fillStyle=de(a.candle.up,.12),e.fill(),e.beginPath(),e.strokeStyle=a.candle.up,e.lineWidth=1.5,e.lineJoin=`round`;for(let a=0;a<t.length;a++){let l=i.xToPixel(c+a,n,o),u=i.yToPixel(t[a].close,r,s);a===0?e.moveTo(l,u):e.lineTo(l,u)}e.stroke()}function pe(e,t){let n=e.replace(`#`,``),r=n.length===3?n.split(``).map(e=>e+e).join(``):n;return`rgba(${parseInt(r.slice(0,2),16)},${parseInt(r.slice(2,4),16)},${parseInt(r.slice(4,6),16)},${t})`}function me(e,t,n,r,i,a,o,s){if(t.length===0)return;let c=(r.min+r.max)/2,l=i.yToPixel(c,r,s),u=Math.floor(n.startIndex),d=t.map((e,t)=>({x:i.xToPixel(u+t,n,o),y:i.yToPixel(e.close,r,s)})),f=d[0].x,p=d[d.length-1].x,m=()=>{e.beginPath();for(let t=0;t<d.length;t++)t===0?e.moveTo(d[t].x,d[t].y):e.lineTo(d[t].x,d[t].y);e.lineTo(p,l),e.lineTo(f,l),e.closePath()};e.save(),e.beginPath(),e.rect(0,0,o,l),e.clip(),m(),e.fillStyle=pe(a.candle.up,.15),e.fill(),e.restore(),e.save(),e.beginPath(),e.rect(0,l,o,s-l),e.clip(),m(),e.fillStyle=pe(a.candle.down,.15),e.fill(),e.restore(),e.beginPath(),e.strokeStyle=a.candle.up,e.lineWidth=1.5,e.lineJoin=`round`;for(let t=0;t<d.length;t++)t===0?e.moveTo(d[t].x,d[t].y):e.lineTo(d[t].x,d[t].y);e.stroke(),e.beginPath(),e.strokeStyle=pe(a.candle.up,.4),e.lineWidth=1,e.setLineDash([4,4]),e.moveTo(f,l),e.lineTo(p,l),e.stroke(),e.setLineDash([])}function he(e,t,n,r,i,a,o,s){let c=i.candleBodyWidth(n,o),l=Math.floor(n.startIndex);for(let u=0;u<t.length;u++){let d=t[u],f=l+u,p=i.xToPixel(f,n,o),m=d.close>=d.open,h=i.yToPixel(d.close,r,s),g=Math.max(1,s-h);e.fillStyle=m?a.candle.up:a.candle.down,e.fillRect(p-c/2,h,c,g)}}function ge(e,t,n,r,i,a,o,s){e.lineWidth=1.5;let c=Math.floor(n.startIndex);for(let l=0;l<t.length;l++){let u=t[l],d=c+l,f=i.xToPixel(d,n,o),p=u.close>=u.open,m=i.yToPixel(u.high,r,s),h=i.yToPixel(u.low,r,s);e.strokeStyle=p?a.candle.up:a.candle.down,e.beginPath(),e.moveTo(f,m),e.lineTo(f,h),e.stroke()}}function _e(e,t,n,r,i,o,s){if(e.save(),e.globalAlpha=.6,e.strokeStyle=r.grid,e.lineWidth=1,e.beginPath(),s===void 0)for(let r of a(t,o)){let a=Math.round(n.yToPixel(r,t,o))+.5;e.moveTo(0,a),e.lineTo(i,a)}else{let r=(t.max-t.min)/s;for(let a=0;a<=s;a++){let s=t.min+r*a,c=Math.round(n.yToPixel(s,t,o))+.5;e.moveTo(0,c),e.lineTo(i,c)}}e.stroke();let c=Math.max(1,Math.floor(i/80)),l=i/c;e.beginPath();for(let t=1;t<c;t++){let n=Math.round(t*l)+.5;e.moveTo(n,0),e.lineTo(n,o)}e.stroke(),e.restore()}var ve=[`1m`,`3m`,`4m`,`5m`,`10m`,`15m`,`30m`,`1h`,`4h`];function ye(e,t,n=`UTC`){let r=new Date(e);return ve.includes(t)?`${r.toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,year:`numeric`,timeZone:n})} ${r.toLocaleTimeString(`en-US`,{hour:`2-digit`,minute:`2-digit`,hour12:!1,timeZone:n})}`:t===`1M`?r.toLocaleDateString(`en-US`,{month:`short`,year:`numeric`,timeZone:n}):r.toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,year:`numeric`,timeZone:n})}function be(e,t,n,r,i,a,o,s,c,l,u,d=2,f=w,p=`UTC`){let m=i.xToPixel(t.barIndex,r,o),h=i.yToPixel(t.price,n,s);e.setLineDash([4,4]),e.strokeStyle=a.crosshair,e.lineWidth=1,e.beginPath(),e.moveTo(m,0),e.lineTo(m,l),e.stroke(),e.beginPath(),e.moveTo(0,h),e.lineTo(o,h),e.stroke(),e.setLineDash([]);let g=f.labelHeight,_=f.labelPaddingX;e.font=`${f.fontSize} ${f.fontFamily}`;let v=t.price.toFixed(d);if(e.fillStyle=a.tooltip.background,e.fillRect(o,h-g/2,c,g),e.strokeStyle=a.crosshair,e.lineWidth=1,e.strokeRect(o,h-g/2,c,g),e.fillStyle=a.tooltip.text,e.textAlign=`left`,e.fillText(v,o+_,h+4),t.bar){let n=ye(t.bar.time,u,p),r=e.measureText(n).width+_*2,i=Math.max(0,Math.min(o-r,m-r/2));e.fillStyle=a.tooltip.background,e.fillRect(i,l,r,g),e.strokeStyle=a.crosshair,e.lineWidth=1,e.strokeRect(i,l,r,g),e.fillStyle=a.tooltip.text,e.textAlign=`left`,e.fillText(n,i+_,l+13)}}function xe(e){var t,n;let{entryPrice:r,bracketPrice:i,side:a,lots:o}=e,s=(t=e.contractSize)==null?1:t,c=(n=e.valuePerPoint)==null?1:n;for(let e of[r,i,o,s,c])if(typeof e!=`number`||!Number.isFinite(e))return null;let l=a===`sell`?-1:1;return(i-r)*l*o*s*c}function Se(e,t=`$`,n=2){let r=Number(e.toFixed(n)),i=Math.abs(r).toFixed(n);return r===0?`${t}${i}`:`${r>0?`+`:`-`}${t}${i}`}function Ce(e){var t;let{entryPrice:n,stopPrice:r,accountSize:i,riskPercent:a}=e,o=(t=e.valuePerPoint)==null?1:t;for(let e of[n,r,i,a,o])if(typeof e!=`number`||!Number.isFinite(e))return null;if(i<=0||a<=0||o<=0)return null;let s=Math.abs(n-r);return s===0?null:a/100*i/(s*o)}function we(e,t,n){for(let r of[e,t,n])if(typeof r!=`number`||!Number.isFinite(r))return null;let r=Math.abs(e-n);return r===0?null:Math.abs(t-e)/r}function Te(e,t,n=new Set){let r=e.filter(e=>!n.has(e.level.label)).sort((e,t)=>e.y-t.y);if(r.length<2)return[];let i=[],a=[r[0]],o=r[0].y;for(let e=1;e<r.length;e++){let n=r[e];n.y-o<=t?a.push(n):(i.push(a),a=[n],o=n.y)}return i.push(a),i.filter(e=>e.length>=2).map(e=>({id:`cluster:`+e.map(e=>e.level.label).sort().join(`|`),members:e,centerY:e.reduce((e,t)=>e+t.y,0)/e.length,centerPrice:e.reduce((e,t)=>e+t.price,0)/e.length}))}function Ee(e,t,n=4){let r=e.members.length,i=r*t+(r-1)*n,a=e.centerY-i/2,o=[...e.members].sort((e,t)=>e.y-t.y),s=new Map;for(let e=0;e<o.length;e++)s.set(o[e].level.label,a+e*(t+n));return s}function De(e,t,n){let r=e.members.filter(e=>e.level.type===`position`&&!e.level.entryPriceEditable).length,i=e.members.filter(e=>e.level.type===`pending`||e.level.entryPriceEditable===!0).length,a=e.members.filter(e=>e.level.type===`trade`).length,o=[];r>0&&o.push(`${r} Position${r>1?`s`:``}`),i>0&&o.push(`${i} Order${i>1?`s`:``}`),a>0&&o.push(`${a} Trade${a>1?`s`:``}`);let s=o.join(` / `),c=12+n.measureText(s).width+16+12;return{badgeX:(t-c)/2,badgeY:e.centerY-24/2,badgeW:c,badgeH:24,text:s}}function Oe(e,t,n){var r;return(r=n.find(n=>e>=n.x&&e<=n.x+n.w&&t>=n.y&&t<=n.y+n.h))==null?null:r}var ke=8,Ae=6,je=6,Me=4,Ne=16,Pe=3,Fe=1,Ie=7,Le=7,Re=4,ze=7,Be=4,Ve=6,He=`13px 'Inter', system-ui, sans-serif`,Ue=14,H=1.5,We=1,U=5,Ge=3,Ke=Ne+Ge*2,qe=`12px 'Inter', system-ui, sans-serif`;function Je(e){let t=Math.min(1,Math.max(.5,Number.isFinite(e)&&e>0?e:1)),n=`${Math.max(8,Math.round(13*t))}px 'Inter', system-ui, sans-serif`;return{k:t,padX:ke*t,padY:Me*t,rowH:Ne*t,pillPadX:Ae*t,pillGap:je*t,pnlGap:Ve*t,fontMain:n,fontPnl:n,gripW:Math.round(Ue*t),gripDotR:H*t,leftMargin:6}}var Ye={mode:`price`,currencySymbol:`$`};function Xe(e,t,n,r,i=Ye,a=!1){var o;let s=e===`stopLoss`?r!=null&&r.stopLossTrailing?`TSL`:`SL`:`TP`,c=(o=r==null?void 0:r.currencySymbol)==null?i.currencySymbol:o,l=()=>!r||!r.side||typeof r.lots!=`number`?null:xe({entryPrice:r.price,bracketPrice:t,side:r.side,lots:r.lots,contractSize:r.contractSize,valuePerPoint:r.valuePerPoint});if(i.mode===`amount`){let e=l();if(e!==null)return`${s} ${Se(e,c)}`}if(i.mode===`priceAndAmount`){let e=`${s} ${c}${t.toFixed(n)}`;if(!a)return e;let r=l();return r===null?e:`${e} ${Se(r,c)}`}return`${s} ${t.toFixed(n)}`}var Ze=.68,Qe=[0,-.08,.08],$e=30,et=[],tt=``;function nt(e){return e.type===`position`&&!!e.pnlText}function rt(e,t,n,r){return e<n+r&&e+t>n}function it(e,t,n,r,i){let a=[];e&&a.push(e);for(let e of i)a.push(e);let o=t,s=0,c=a.length+2;for(;s<c&&a.some(e=>rt(o,n,e.boxY,e.boxH));)o+=r*(n+2),s++;return o}function at(e,t,n,r=!1){var i,a,o;if((i=e.data)!=null&&i._isDraft){let t=e;return`${t.side.charAt(0).toUpperCase()+t.side.slice(1)} ${t.orderType.charAt(0).toUpperCase()+t.orderType.slice(1)}`}if(e.type===`pending`){var s;let i=e,a=!r&&i.lots!==void 0?` ${i.lots}`:``;return(s=e.text)==null?`${i.side.toUpperCase()}${a} @${t.toFixed(n)}`:s}if(e.type===`position`&&e.entryPriceEditable){var c;let i=e,a=i.side?i.side.toUpperCase():``,o=!r&&i.lots!==void 0?` ${i.lots}`:``;return(c=e.text)==null?`${a}${o} @${t.toFixed(n)}`:c}return e.type===`position`?(a=e.text)==null?``:a:(o=e.text)==null?e.label:o}function ot(e,t,n,r,i,a,o,s,c,l=Ke){let u=[],d=s==null?c:s;for(let i of e){if(i.label!==d)continue;let e=i;if(e.stopLossPrice!==void 0){let s=`${i.label}:stopLoss`,c=a===s&&o!==null?o:e.stopLossPrice;u.push({key:s,y:t.yToPixel(c,n,r)})}if(e.takeProfitPrice!==void 0){let s=`${i.label}:takeProfit`,c=a===s&&o!==null?o:e.takeProfitPrice;u.push({key:s,y:t.yToPixel(c,n,r)})}}u.sort((e,t)=>e.y-t.y);let f=i*Ze,p=Qe.map(e=>f+e*i),m=p.map(()=>-1/0),h=new Map;for(let e of u){let t=!1;for(let n=0;n<p.length;n++)if(e.y>=m[n]+l){h.set(e.key,p[n]),m[n]=e.y,t=!0;break}if(!t){let t=m.indexOf(Math.min(...m));h.set(e.key,p[t]),m[t]=e.y}}return h}function st(e){return c(e.background)?`#000000`:`#ffffff`}function ct(e,t){return c(e.background)?t?`rgb(230,230,230)`:`rgb(255,255,255)`:t?`rgb(30,30,30)`:`rgb(0,0,0)`}function lt(e,t,n){if(e.type===`position`){let r=e;if(r.entryPriceEditable&&r.side)return r.side===`buy`?t.pendingBuyLine:t.pendingSellLine;let i=e.pnl;return i===void 0?t.positionLine:i>=0?n.candle.up:n.candle.down}return e.type===`pending`?e.side===`buy`?t.pendingBuyLine:t.pendingSellLine:t.tradeLine}function ut(e){return e.type===`pending`?!0:e.type===`position`?!!e.entryPriceEditable:!1}function dt(e,t){return e&&t===null}function ft(e,t,n,r,i,a,o,s,c=null,l=null,u=null,d=null,f=new Set,p=`line`,m=!1,h=null,g={},_=new Set,v=0,y=!1,b=null,x=null,S=1,C=!1,w=null,T=!1,E=Ye,D=1,O=`auto`){if(t.length===0)return{hitAreas:[],editAreas:[],hoverAreas:[],dragAreas:[],confirmAreas:[],addBracketAreas:[],clusterBadgeAreas:[],clusters:[]};let k=i.tradeLevels;et=[];let A=Je(D),j=Math.min(Math.max(S,1),3)*A.k,M=Ie*j,N=Le*j,P=ze*j,F=Re*j,I=Be*j,L=Math.max(M,N,P),R=Math.max(A.rowH+A.padY*2,L*2+A.padY*2),z=Math.max(Ke,M*2+Ge*2);e.save(),e.font=A.fontMain;let B=[];for(let i of t){var ee,te;let t=l===i.label&&u!==null?u:i.price,a=n.yToPixel(t,r,o);if(a<-40||a>o+40)continue;if(p===`dot`&&i.type===`position`&&i.label!==d){B.push({level:i,price:t,y:a,boxW:0,boxH:0});continue}if(i.type===`pending`&&i.orderType===`market`&&((ee=i.data)==null?void 0:ee._isDraft)===!0){B.push({level:i,price:t,y:a,boxW:0,boxH:0});continue}let c=nt(i)?i.pnlText:null,h=f.has(i.label),g=c?e.measureText(c).width+A.pnlGap:0,_=h&&!m,v=_?(P*2+I)*2:0,b=_||m?0:N*2+F+M*2+A.padX/2,x=((te=i.data)==null?void 0:te._isDraft)===!0,S=i.label===d||h,C=i.type===`position`&&i.entryPriceEditable===!0,w=i.type===`pending`||C,T=i.lots,E=y&&(x||S)&&w&&T!==void 0?String(T):null,D=at(i,t,s,E!==null),O=e.measureText(D).width,k=E?A.pillPadX+e.measureText(E).width+A.pillPadX+A.pillGap:0,j=A.padX+k+g+O+A.padX+v+b;B.push({level:i,price:t,y:a,boxW:j,boxH:R})}let ne=new Set;h&&ne.add(h);let re=v>0?Te(B,v,ne):[],ie=re.filter(e=>!_.has(e.id)),ae=re.filter(e=>_.has(e.id)),oe=new Set;for(let e of ie)for(let t of e.members)oe.add(t.level.label);let se=new Map;for(let e of ae)se.set(e.id,Ee(e,R,4));let ce=new Map;for(let e of ae)for(let t of e.members)ce.set(t.level.label,e);B.sort((e,t)=>e.y-t.y);let V=[],le=new Map;for(let e of B){if(oe.has(e.level.label))continue;let t=ce.get(e.level.label);if(t){let n=se.get(t.id),r=n==null?void 0:n.get(e.level.label);if(r!==void 0){V.push({label:e.level.label,boxY:r,boxH:e.boxH}),le.set(e.level.label,{price:e.price,y:e.y,boxY:r,boxW:e.boxW,boxH:e.boxH});continue}}let n=e.y-e.boxH/2,r=0;for(;r<V.length+1&&V.some(t=>rt(n,e.boxH,t.boxY,t.boxH));)n-=e.boxH+2,r++;V.push({label:e.level.label,boxY:n,boxH:e.boxH}),le.set(e.level.label,{price:e.price,y:e.y,boxY:n,boxW:e.boxW,boxH:e.boxH})}let ue=ot(t,n,r,o,a,l,u,c,d,z),de=[],fe=a*Ze,pe=c==null?d:c;for(let e of t){if(e.label!==pe)continue;let t=e,i=l===e.label;if(t.stopLossPrice!==void 0){var me;let a=`${e.label}:stopLoss`,s=l===a&&u!==null?u:i&&b!==null?b:t.stopLossPrice;de.push({key:a,label:e.label,y:n.yToPixel(s,r,o),columnX:(me=ue.get(a))==null?fe:me})}if(t.takeProfitPrice!==void 0){var he;let a=`${e.label}:takeProfit`,s=l===a&&u!==null?u:i&&x!==null?x:t.takeProfitPrice;de.push({key:a,label:e.label,y:n.yToPixel(s,r,o),columnX:(he=ue.get(a))==null?fe:he})}}de.sort((e,t)=>e.y-t.y);let ge=new Map,_e=[];for(let e of de){let t=le.get(e.label),n=e.y-z/2,r=it(t?{boxY:t.boxY,boxH:t.boxH}:null,n,z,t&&Math.sign(e.y-t.y)||1,_e.filter(t=>t.columnX===e.columnX));ge.set(e.key,r),_e.push({columnX:e.columnX,boxY:r,boxH:z})}let ve=c==null?d:c,ye=h==null?d:h,be=dt(C,ve),xe=B.filter(e=>!oe.has(e.level.label)),Se=[...xe.filter(e=>e.level.label!==ve),...xe.filter(e=>e.level.label===ve)],Ce=[],we=[],De=[],Oe=[],ke=[],Ae=[],je=[],Me=[];for(let t of ie)_t(e,t,a,i,je);for(let{level:t}of Se){let h=le.get(t.label);h&&(xt(e,t,h,a,k,i,s,t.label===c,t.label===d,n,r,o,l,u,ue,f.has(t.label),p,Ce,we,De,Oe,ke,Ae,m,t.label===ye?g:void 0,y,Me,b,x,S,ge,be,T&&w?w(t):null,T,t.label===ve,E,A,O),ce.get(t.label)&&h.boxY!==h.y-R/2&&vt(e,h.boxY+R/2,h.y,a,i))}if(d!==null&&!le.has(d)){let c=t.find(e=>e.label===d);if(c){let t=c,d=`${c.label}:stopLoss`,f=`${c.label}:takeProfit`,p=l===c.label,h=p&&b!==null?b:t.stopLossPrice,g=p&&x!==null?x:t.takeProfitPrice;if(h!==void 0&&g!==void 0){var Ne,Pe,Fe,Ve;let a=n.yToPixel(h,r,o),c=n.yToPixel(g,r,o),u=Math.max(Ke,Ie*2+Ge*2);e.save(),e.font=qe;let p=Ie*2+U/2,m=t.stopLossTrailing?0:p,_=U+e.measureText(Xe(`stopLoss`,h,s,t,E,l===d)).width+U+m,v=U+e.measureText(Xe(`takeProfit`,g,s,t,E,l===f)).width+U+p;e.restore();let y=(((Ne=ue.get(d))==null?fe:Ne)-_/2-2+(((Pe=ue.get(f))==null?fe:Pe)-v/2-2))/2,b=(Fe=ge.get(d))==null?a-u/2:Fe,x=(Ve=ge.get(f))==null?c-u/2:Ve,[S,C]=x<b?[x,b]:[b,x];yt(e,y,S+u,C,i)}if(h!==void 0){var He;Ct(e,t,`stopLoss`,h,n,r,o,(He=ue.get(d))==null?fe:He,a,i,s,l,u,Ce,Oe,m,t._slOrderLabel,void 0,S,ge.get(d),E)}if(g!==void 0){var Ue;Ct(e,t,`takeProfit`,g,n,r,o,(Ue=ue.get(f))==null?fe:Ue,a,i,s,l,u,Ce,Oe,m,t._tpOrderLabel,void 0,S,ge.get(f),E)}}}{globalThis.__bracketDrawsLast=et.slice();let e=new Map;for(let t of et){var H;let n=`${t.bracketType}@${t.price}`;e.set(n,((H=e.get(n))==null?0:H)+1)}let n=[...e.entries()].filter(([,e])=>e>1).map(([e])=>e);if(n.length>0){let e=n.join(`,`)+`|`+et.map(e=>`${e.label}/${e.levelType}/${e.bW}`).join(`,`);if(e!==tt){tt=e;let r={hoveredLabel:c,selectedLabel:d,draftOrderLabel:h,draftBracketPnl:g,levels:t.map(e=>{var t;return{label:e.label,type:e.type,price:e.price,sl:e.stopLossPrice,tp:e.takeProfitPrice,isDraft:!!((t=e.data)!=null&&t._isDraft)}})};console.warn(`[ActCharts] DUPLICATE BRACKET BOX → ${n.join(`, `)}\n hovered=${c==null?`null`:c} selected=${d==null?`null`:d} draft=${h==null?`null`:h}\n`+et.map((e,t)=>` box#${t+1} label=${e.label} type=${e.levelType} draft=${e.isDraft} ${e.bracketType}@${e.price} bX=${e.bX} bW=${e.bW} right=${e.rightEdge} boxY=${e.boxY} pnl=${e.pnlText===null?`none`:JSON.stringify(e.pnlText)} hideCC=${e.hideConfirmCancel}`).join(`
|
|
41
41
|
`)+`
|
|
42
|
-
levels this frame: `+r.levels.map(e=>`${e.label}/${e.type}${e.isDraft?`/DRAFT`:``} price=${e.price} sl=${e.sl} tp=${e.tp}`).join(` | `)),typeof window<`u`&&(window.__bracketDupe={dupeKeys:n,frame:r,draws:Ge.slice()})}}}return e.restore(),{hitAreas:L,editAreas:Re,hoverAreas:Ue,dragAreas:We,confirmAreas:Qe,addBracketAreas:z,clusterBadgeAreas:$e,clusters:ae,draftQtyPillArea:et[0]}}var it=`bold 12px 'Inter', system-ui, sans-serif`,at=12,ot=24,B=12;function V(e,t,n,r,i){let a=z(r),o=!Qe(r.background);e.save(),e.strokeStyle=a,e.globalAlpha=.12,e.lineWidth=1,e.setLineDash([4,4]);for(let r of t.members)e.beginPath(),e.moveTo(0,r.y),e.lineTo(n,r.y),e.stroke();e.setLineDash([]),e.restore(),e.save(),e.font=it;let{badgeX:s,badgeY:c,badgeW:l,text:u}=be(t,n,e);e.fillStyle=o?`rgba(40,40,40,0.92)`:`rgba(240,240,240,0.92)`,e.beginPath(),e.roundRect(s,c,l,ot,B),e.fill(),e.strokeStyle=a,e.globalAlpha=.3,e.lineWidth=1,e.stroke(),e.globalAlpha=1,e.fillStyle=a,e.globalAlpha=.85,e.textBaseline=`middle`,e.textAlign=`left`,e.fillText(u+` ▸`,s+at,c+ot/2),e.globalAlpha=1,e.restore(),i.push({clusterId:t.id,x:s,y:c,w:l,h:ot})}function st(e,t,n,r,i){if(Math.abs(t-n)<2)return;let a=z(i);e.save(),e.strokeStyle=a,e.globalAlpha=.25,e.lineWidth=1,e.setLineDash([2,3]);let o=r-8;e.beginPath(),e.moveTo(o,t),e.lineTo(o,n),e.stroke(),e.setLineDash([]),e.beginPath(),e.moveTo(o-4,n),e.lineTo(o+4,n),e.stroke(),e.restore()}function ct(e,t,n,r,i){r-n<2||(e.save(),e.strokeStyle=z(i),e.globalAlpha=.5,e.lineWidth=1,e.setLineDash([3,4]),e.beginPath(),e.moveTo(t,n),e.lineTo(t,r),e.stroke(),e.setLineDash([]),e.restore())}function lt(e,t,n,r,i,a,o){let s=t,c=[],l=t;if(s.orderType!==void 0)c.push({label:`Price`,value:t.price.toFixed(o)}),l.stopLossPrice!==void 0&&c.push({label:`SL`,value:l.stopLossPrice.toFixed(o)}),l.takeProfitPrice!==void 0&&c.push({label:`TP`,value:l.takeProfitPrice.toFixed(o)});else{if(s.pnlText!==void 0){let e=s.pnl===void 0?void 0:s.pnl>=0?a.candle.up:a.candle.down;c.push({label:`PnL`,value:s.pnlText,pnlColor:e})}s.side!==void 0&&c.push({label:`Side`,value:s.side===`buy`?`Buy`:`Sell`}),s.lots!==void 0&&c.push({label:`Lots`,value:String(s.lots)}),c.length===0&&c.push({label:`Price`,value:t.price.toFixed(o)})}let u=Se,d=Te,f=Ee+3;e.save(),e.font=Fe;let p=Math.max(...c.map(t=>e.measureText(t.label).width)),m=Math.max(...c.map(t=>e.measureText(t.value).width)),h=u+p+8+m+u,g=d+c.length*f-3+d,_=r-i-8-h,v=n-g/2;e.fillStyle=$e(a,!0),e.strokeStyle=z(a),e.lineWidth=1,ht(e,_,v,h,g,De),e.fill(),e.stroke(),e.textBaseline=`top`,c.forEach((t,n)=>{var r;let i=v+d+n*f;e.textAlign=`left`,e.fillStyle=z(a),e.globalAlpha=.55,e.fillText(t.label,_+u,i),e.globalAlpha=1,e.textAlign=`right`,e.fillStyle=(r=t.pnlColor)==null?z(a):r,e.fillText(t.value,_+u+p+8+m,i)}),e.restore()}function ut(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C=!1,w,T=!1,E,D=null,O=null,k=1,A,ee=!1,j=null,te=!1,ne){var M,N;let{y:P,boxY:re,boxW:ie,boxH:ae}=n,oe=et(t,i,a),se=s||c,ce=ee&&!se,le=C||ce,ue=Math.min(Math.max(k,1),3),de=ke*ue,F=Ae*ue,I=Me*ue,fe=je*ue,pe=Ne*ue;if(g===`dot`&&t.type===`position`&&!c){let n=r-6-4;s&<(e,t,P,n,6,a,o),e.save(),e.fillStyle=oe,e.globalAlpha=s?1:.75,e.beginPath(),e.arc(n,P,6,0,Math.PI*2),e.fill(),e.globalAlpha=1,e.restore(),y.push({label:t.label,boxX:n-6,boxY:P-6,boxW:12,boxH:12,lineX:n-6,lineY:P-6,lineW:12,lineH:12});return}let me=qe(t)?t.pnlText:null,he=t.type===`position`?t.pnl:void 0,ge=t.type===`pending`,_e=ge&&t.orderType===`market`&&((M=t.data)==null?void 0:M._isDraft)===!0,ve=tt(t),ye=(ve?Le+2:0)+ie,be=j===null?Math.round((r-ye)/2):Math.max(0,Math.min(r-ye,Math.round(j-ye/2))),xe=ve?be:0,Te=ve?be+Le+2:be,Ee=te&&t.timeDraggable===!0,L=t;if((ne==null?se:ne)||_e||ce){let n=`${t.label}:stopLoss`,i=`${t.label}:takeProfit`,s=f===t.label,h=s&&D!==null?D:L.stopLossPrice,g=s&&O!==null?O:L.takeProfitPrice;if(c&&h!==void 0&&g!==void 0){var Re,Ue,We,Ge;let t=l.yToPixel(h,u,d),s=l.yToPixel(g,u,d),c=C?Be:Math.max(Be,de*2+ze*2);e.save(),e.font=Ve;let f=C?0:de*2+R/2,p=R+e.measureText(`SL ${h.toFixed(o)}`).width+R+f,_=R+e.measureText(`TP ${g.toFixed(o)}`).width+R+f;e.restore();let v=(Re=m.get(n))==null?r*He:Re,y=(Ue=m.get(i))==null?r*He:Ue,b=(v-p/2-2+(y-_/2-2))/2,x=(We=A==null?void 0:A.get(n))==null?t-c/2:We,S=(Ge=A==null?void 0:A.get(i))==null?s-c/2:Ge,[w,T]=S<x?[S,x]:[x,S];ct(e,b,w+c,T,a)}if(h!==void 0){var Ke;ft(e,L,`stopLoss`,h,l,u,d,(Ke=m.get(n))==null?r*He:Ke,r,a,o,f,p,_,b,le,L._slOrderLabel,w==null?void 0:w.sl,k,A==null?void 0:A.get(n))}else f===n&&p!==null&&ft(e,L,`stopLoss`,p,l,u,d,r*He,r,a,o,f,p,_,b,le,void 0,w==null?void 0:w.sl,k);if(g!==void 0){var Je;ft(e,L,`takeProfit`,g,l,u,d,(Je=m.get(i))==null?r*He:Je,r,a,o,f,p,_,b,le,L._tpOrderLabel,w==null?void 0:w.tp,k,A==null?void 0:A.get(i))}else f===i&&p!==null&&ft(e,L,`takeProfit`,p,l,u,d,r*He,r,a,o,f,p,_,b,le,void 0,w==null?void 0:w.tp,k);if(c&&L.side!==void 0){let t=r*He;L.stopLossPrice===void 0&&f!==n&&dt(e,L,`stopLoss`,P,t,r,d,a,S),L.takeProfitPrice===void 0&&f!==i&&dt(e,L,`takeProfit`,P,t,r,d,a,S)}}if(_e)return;let Ye=t.type===`position`&&t.entryPriceEditable===!0;e.save(),e.strokeStyle=oe,e.lineWidth=Oe,e.globalAlpha=se?1:.85,(ge||Ye)&&e.setLineDash([5,4]),e.beginPath(),e.moveTo(0,P),e.lineTo(r,P),e.stroke(),e.setLineDash([]),e.globalAlpha=1,e.restore();let Ze=re+ae/2;e.save(),e.fillStyle=$e(a,se),e.strokeStyle=oe,e.lineWidth=1,ht(e,Te,re,ie,ae,De),e.fill(),e.stroke();let Qe=Te+Se,nt=((N=t.data)==null?void 0:N._isDraft)===!0,rt=t.type===`pending`||Ye,it=t.lots,at=T&&(nt||c||h)&&rt&&it!==void 0;if(at){let n=String(it);e.font=Fe;let r=Ce+e.measureText(n).width+Ce,i=Qe;e.save(),e.strokeStyle=z(a),e.globalAlpha=.35,e.lineWidth=1,e.beginPath(),e.moveTo(i+r,re+3),e.lineTo(i+r,re+ae-3),e.stroke(),e.restore(),e.fillStyle=z(a),e.textAlign=`left`,e.textBaseline=`middle`,e.fillText(n,i+Ce,Ze),E==null||E.push({label:t.label,pillX:i,pillY:re,pillW:r,pillH:ae}),Qe+=r+we}if(me){let t=he===void 0?z(a):he>=0?a.candle.up:a.candle.down;e.font=Ie,e.fillStyle=t,e.textAlign=`left`,e.textBaseline=`middle`,e.fillText(me,Qe,Ze),Qe+=e.measureText(me).width+Pe}let ot=Xe(t,n.price,o,at);e.font=Fe,e.fillStyle=z(a),e.textAlign=`left`,e.textBaseline=`middle`,e.fillText(ot,Qe,Ze);let B=Ze,V=3.5;if(!C&&h){let n=Te+ie-Se/2-I,r=n-I-pe-I;e.fillStyle=a.candle.up,e.beginPath(),e.arc(r,B,I,0,Math.PI*2),e.fill(),e.strokeStyle=a.background,e.lineWidth=1.5,e.lineCap=`round`,e.lineJoin=`round`;let i=3.1;e.beginPath(),e.moveTo(r-i,B),e.lineTo(r-i*.2,B+i*.8),e.lineTo(r+i,B-i*.7),e.stroke(),e.fillStyle=a.candle.down,e.beginPath(),e.arc(n,B,I,0,Math.PI*2),e.fill(),e.strokeStyle=a.background,e.lineWidth=1.5,e.lineCap=`round`,e.beginPath(),e.moveTo(n-V,B-V),e.lineTo(n+V,B+V),e.moveTo(n+V,B-V),e.lineTo(n-V,B+V),e.stroke(),x.push({label:t.label,type:t.type,data:t.data,action:`confirm`,x:r-I,y:B-I,w:I*2,h:I*2}),x.push({label:t.label,type:t.type,data:t.data,action:`cancel`,x:n-I,y:B-I,w:I*2,h:I*2})}else if(!C){let n=Te+ie-Se/2-de,r=n-de-fe-F;e.fillStyle=z(a),e.beginPath(),e.arc(r,B,F,0,Math.PI*2),e.fill();let i=F*.48;e.save(),e.strokeStyle=a.background,e.lineWidth=1.5,e.lineCap=`round`,e.lineJoin=`round`,e.translate(r,B),e.rotate(Math.PI/4),e.beginPath(),e.moveTo(-i*.35,-i),e.lineTo(-i*.35,i*.5),e.lineTo(i*.35,i*.5),e.lineTo(i*.35,-i),e.closePath(),e.stroke(),e.beginPath(),e.moveTo(-i*.35,i*.5),e.lineTo(0,i+i*.45),e.lineTo(i*.35,i*.5),e.stroke(),e.restore(),e.fillStyle=z(a),e.beginPath(),e.arc(n,B,de,0,Math.PI*2),e.fill(),e.strokeStyle=a.background,e.lineWidth=1.5,e.lineCap=`round`,e.beginPath(),e.moveTo(n-V,B-V),e.lineTo(n+V,B+V),e.moveTo(n+V,B-V),e.lineTo(n-V,B+V),e.stroke(),v.push({label:t.label,type:t.type,data:t.data,x:r-F,y:B-F,w:F*2,h:F*2}),_.push({label:t.label,type:t.type,data:t.data,x:n-de,y:B-de,w:de*2,h:de*2})}if(e.restore(),ve){mt(e,xe,re,ae,i,s);let n=C?0:F*2+fe+de*2+Se/2;b.push({label:t.label,type:t.type,data:t.data,price:t.price,x:xe,y:re,w:Le+2+ie-n,h:ae,isBracket:!1,isBox:!0,timeDrag:Ee}),b.push({label:t.label,type:t.type,data:t.data,price:t.price,x:0,y:P-4,w:r,h:8,isBracket:!1})}else (C||Ee)&&ie>0&&b.push({label:t.label,type:t.type,data:t.data,price:t.price,x:Te,y:re,w:ie,h:ae,isBracket:!1,isBox:!0,timeDrag:Ee});y.push({label:t.label,boxX:Te,boxY:re,boxW:ie,boxH:ae,lineX:0,lineY:P-4,lineW:r,lineH:8})}function dt(e,t,n,r,i,a,o,s,c){let l=r+(t.side===`buy`&&n===`stopLoss`||t.side===`sell`&&n===`takeProfit`?We:-We);if(l<0||l>o)return;e.save(),e.strokeStyle=z(s),e.lineWidth=.8,e.globalAlpha=.3,e.setLineDash([4,4]),e.beginPath(),e.moveTo(i,l),e.lineTo(a,l),e.stroke(),e.setLineDash([]),e.globalAlpha=1,e.restore();let u=n===`stopLoss`?`+SL`:`+TP`;e.font=Ve;let d=R+e.measureText(u).width+R,f=Be,p=i-d-2,m=l-f/2;e.save(),e.globalAlpha=.75,e.fillStyle=$e(s,!1),e.strokeStyle=z(s),e.lineWidth=.8,ht(e,p,m,d,f,De),e.fill(),e.stroke(),e.globalAlpha=1,e.fillStyle=z(s),e.textAlign=`left`,e.textBaseline=`middle`,e.fillText(u,p+R,l),e.restore(),c.push({label:t.label,type:t.type,data:t.data,bracketType:n,x:p,y:m,w:d,h:f})}function ft(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v=1,y){var b,x,S;let C=ke*Math.min(Math.max(v,1),3),w=d===`${t.label}:${n}`&&f!==null?f:r,T=i.yToPixel(w,a,o);if(T<-20||T>o+20)return;e.save(),e.strokeStyle=z(l),e.lineWidth=Re,e.globalAlpha=.8,e.beginPath(),e.moveTo(s,T),e.lineTo(c,T),e.stroke(),e.globalAlpha=1;let E=`${n===`stopLoss`?`SL`:`TP`} ${w.toFixed(u)}`;e.font=Ve;let D=e.measureText(E).width,O=_?e.measureText(_).width+R:0,k=h?0:C*2+R/2,A=R+D+O+R+k,ee=h?Be:Math.max(Be,C*2+ze*2),j=s-A-2,te=T-ee/2,ne=y==null?te:y,M=ne+ee/2,N=Math.abs(ne-te)>=2;if(Ge.push({label:t.label,levelType:t.type,isDraft:!!((b=t.data)!=null&&b._isDraft),bracketType:n,price:w,bX:Math.round(j),bW:Math.round(A),rightEdge:Math.round(j+A),boxY:Math.round(ne),pnlText:_==null?null:_,hideConfirmCancel:h}),N&&pt(e,j+A/2,M,T,l),e.fillStyle=$e(l,!1),e.strokeStyle=z(l),e.lineWidth=.8,ht(e,j,ne,A,ee,De),e.fill(),e.stroke(),e.fillStyle=z(l),e.textAlign=`left`,e.textBaseline=`middle`,e.fillText(E,j+R,M),_&&(e.fillStyle=_.trim().startsWith(`-`)?l.candle.down:l.candle.up,e.fillText(_,j+R+D+R,M)),!h){let r=j+A-R/2-C,i=M;e.fillStyle=z(l),e.beginPath(),e.arc(r,i,C,0,Math.PI*2),e.fill(),e.strokeStyle=l.background,e.lineWidth=1.5,e.lineCap=`round`;let a=3.5;e.beginPath(),e.moveTo(r-a,i-a),e.lineTo(r+a,i+a),e.moveTo(r+a,i-a),e.lineTo(r-a,i+a),e.stroke(),p.push({label:t.label,type:t.type,data:t.data,bracketType:n,bracketOrderLabel:g,x:r-C,y:i-C,w:C*2,h:C*2})}e.restore(),m.push({label:t.label,data:t.data,bracketType:n,price:w,parentPrice:t.price,parentSide:(x=t.side)==null?`buy`:x,bracketOrderLabel:g,x:s,y:T-5,w:c-s,h:10,isBracket:!0});let P=C*2+R/2;m.push({label:t.label,data:t.data,bracketType:n,price:w,parentPrice:t.price,parentSide:(S=t.side)==null?`buy`:S,bracketOrderLabel:g,x:j,y:ne,w:A-P,h:ee,isBracket:!0})}function pt(e,t,n,r,i){Math.abs(n-r)<2||(e.save(),e.strokeStyle=z(i),e.globalAlpha=.35,e.lineWidth=1,e.setLineDash([2,3]),e.beginPath(),e.moveTo(t,n),e.lineTo(t,r),e.stroke(),e.restore())}function mt(e,t,n,r,i,a){let o=a?i.dragHandleHover:i.dragHandle,s=L*2*2+3,c=L*2*3+6,l=t+(Le-s)/2+L,u=n+(r-c)/2+L;e.save(),e.fillStyle=o;for(let t=0;t<3;t++)for(let n=0;n<2;n++){let r=l+n*(L*2+3),i=u+t*(L*2+3);e.beginPath(),e.arc(r,i,L,0,Math.PI*2),e.fill()}e.restore()}function ht(e,t,n,r,i,a){e.beginPath(),e.moveTo(t+a,n),e.lineTo(t+r-a,n),e.arcTo(t+r,n,t+r,n+a,a),e.lineTo(t+r,n+i-a),e.arcTo(t+r,n+i,t+r-a,n+i,a),e.lineTo(t+a,n+i),e.arcTo(t,n+i,t,n+i-a,a),e.lineTo(t,n+a),e.arcTo(t,n,t+a,n,a),e.closePath()}function gt(e,t,n){var r;return(r=n.find(n=>e>=n.x&&e<=n.x+n.w&&t>=n.y&&t<=n.y+n.h))==null?null:r}function _t(e,t,n){var r;return(r=n.find(n=>e>=n.x&&e<=n.x+n.w&&t>=n.y&&t<=n.y+n.h))==null?null:r}function vt(e,t,n){var r;return(r=n.find(n=>e>=n.x&&e<=n.x+n.w&&t>=n.y&&t<=n.y+n.h))==null?null:r}function yt(e,t,n){var r;return(r=n.find(n=>e>=n.boxX&&e<=n.boxX+n.boxW&&t>=n.boxY&&t<=n.boxY+n.boxH||e>=n.lineX&&e<=n.lineX+n.lineW&&t>=n.lineY&&t<=n.lineY+n.lineH))==null?null:r}function bt(e,t,n){var r;return(r=n.find(n=>e>=n.x&&e<=n.x+n.w&&t>=n.y&&t<=n.y+n.h))==null?null:r}function xt(e,t,n){var r;return(r=n.find(n=>e>=n.x&&e<=n.x+n.w&&t>=n.y&&t<=n.y+n.h))==null?null:r}function St(e,t,n,r,i,a,o,s){let c=[];for(let e of t){if(e.type!==`position`)continue;let t=e;if(t.entryPriceEditable)continue;let a=n.yToPixel(t.price,r,o);a<-16||a>o+16||c.push({y:a,label:t.price.toFixed(s),color:et(e,i.tradeLevels,i)})}if(c.length===0)return;c.sort((e,t)=>e.y-t.y);let l=-1/0;for(let e of c)e.y-16/2<l&&(e.y=l+16/2),l=e.y+16/2+1;e.save(),e.font=`10px 'Inter', system-ui, sans-serif`,e.textAlign=`left`,e.textBaseline=`middle`;for(let t of c){let n=e.measureText(t.label).width;e.fillStyle=t.color,e.fillRect(a,t.y-16/2,n+12,16),e.fillStyle=`#ffffff`,e.fillText(t.label,a+4,t.y)}e.restore()}function Ct(e,t,n){let r=[],i=[],{min:a,max:o}=t;for(let t of e){var s;if(t.label===n||t.type===`pending`&&t.orderType===`market`&&((s=t.data)==null?void 0:s._isDraft)===!0)continue;isFinite(t.price)&&(t.price>o?r.push({price:t.price,label:t.label,kind:`entry`}):t.price<a&&i.push({price:t.price,label:t.label,kind:`entry`}));let e=t.stopLossPrice,c=t.takeProfitPrice;e!==void 0&&isFinite(e)&&(e>o?r.push({price:e,label:t.label,kind:`sl`}):e<a&&i.push({price:e,label:t.label,kind:`sl`})),c!==void 0&&isFinite(c)&&(c>o?r.push({price:c,label:t.label,kind:`tp`}):c<a&&i.push({price:c,label:t.label,kind:`tp`}))}return{above:r,below:i}}function wt(e){let t=0;for(let n of e)n.kind===`entry`&&t++;return t}function Tt(e,t){let n=e[0],r=Math.abs(n.price-t);for(let i=1;i<e.length;i++){let a=Math.abs(e[i].price-t);a<r&&(n=e[i],r=a)}return n}var Et=`11px 'Inter', system-ui, sans-serif`,Dt=8,Ot=8,kt=10,At=20,jt=10,Mt=`▲`,Nt=`▼`;function Pt(e,t,n,r,i,a,o,s=null){let c=[],l=a-40,u=n.max-n.min,d=l>0?u/l*20:0,{above:f,below:p}=Ct(t,{min:n.min-d,max:n.max+d},o);if(f.length===0&&p.length===0)return{hitAreas:c};e.save(),e.font=Et,e.textBaseline=`middle`,e.textAlign=`center`;let m=(t,n,a,o)=>{let s=e.measureText(n).width,l=Math.ceil(s)+Dt*2,u=i-Ot-l;return e.fillStyle=r.tooltip.background,e.strokeStyle=r.tooltip.border,e.lineWidth=1,Lt(e,u,a,l,At,jt),e.fill(),e.stroke(),e.fillStyle=r.tooltip.text,e.fillText(n,u+l/2,a+At/2+.5),c.push({direction:t,x:u,y:a,w:l,h:At,targetPrice:o.price,targetLabel:o.label,targetKind:o.kind}),l},h=(e,t,r)=>{if(t.length===0)return;let i=e===`up`?Mt:Nt,a=e===`up`?n.max:n.min,o=e===`up`?1:-1,c=r,l=wt(t);if(l>0){let n=Tt(t.filter(e=>e.kind===`entry`),a);m(e,`${i} ${l}`,c,n),c+=o*(At+4)}if(s!==null){let n=t.filter(e=>e.kind!==`entry`&&e.label===s);for(let t of n)m(e,`${i} ${t.kind.toUpperCase()}`,c,t),c+=o*(At+4)}};return h(`up`,f,kt),h(`down`,p,a-kt-At),e.restore(),{hitAreas:c}}function Ft(e,t,n){var r;return(r=n.find(n=>e>=n.x&&e<=n.x+n.w&&t>=n.y&&t<=n.y+n.h))==null?null:r}function It(e,t,n){let r=e-t,i=e+t;return n.some(e=>r<e.y+e.h&&i>e.y)}function Lt(e,t,n,r,i,a){let o=Math.min(a,r/2,i/2);e.beginPath(),e.moveTo(t+o,n),e.lineTo(t+r-o,n),e.quadraticCurveTo(t+r,n,t+r,n+o),e.lineTo(t+r,n+i-o),e.quadraticCurveTo(t+r,n+i,t+r-o,n+i),e.lineTo(t+o,n+i),e.quadraticCurveTo(t,n+i,t,n+i-o),e.lineTo(t,n+o),e.quadraticCurveTo(t,n,t+o,n),e.closePath()}var Rt=18,zt=6,Bt=3,Vt=[`1m`,`5m`,`15m`,`30m`,`1h`,`4h`];function Ht(e){return e<60?`${e}s`:e<3600?`${Math.floor(e/60)}:${(e%60).toString().padStart(2,`0`)}`:e<86400?`${Math.floor(e/3600)}h ${Math.floor(e%3600/60)}m`:e<604800?`${Math.floor(e/86400)}d ${Math.floor(e%86400/3600)}h`:`${Math.floor(e/604800)}w ${Math.floor(e%604800/86400)}d`}function Ut(e,t,n,r,i=`UTC`){let a=new Date(e);if(n&&Vt.includes(n)){let e=a.toLocaleTimeString(`en-US`,{hour:`2-digit`,minute:`2-digit`,hour12:!1,timeZone:i});return r?a.toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,timeZone:i})+` `+e:e}return n===`1Y`?a.toLocaleDateString(`en-US`,{year:`numeric`,timeZone:i}):n===`1M`?a.toLocaleDateString(`en-US`,{month:`short`,year:`numeric`,timeZone:i}):t<=365?a.toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,timeZone:i}):a.toLocaleDateString(`en-US`,{month:`short`,year:`2-digit`,timeZone:i})}function Wt(e,t,n,r,i,a,o,s=8,c=b,l,u,d=`UTC`){var f;if(t.length===0)return;let p=n.endIndex-n.startIndex,m=t[0],h=t[t.length-1],g=!!m&&!!h&&new Date(m.time).toLocaleDateString(`en-US`,{timeZone:d})!==new Date(h.time).toLocaleDateString(`en-US`,{timeZone:d});e.fillStyle=i.axisText,e.font=`${c.fontSize} ${c.fontFamily}`,e.textAlign=`center`;let _=Ut(((f=t[Math.floor(t.length/2)])==null?t[0]:f).time,p,l,g,d),v=e.measureText(_).width,y=Math.max(1,Math.floor(t.length/s));if(t.length>1){let e=a/Math.max(1,t.length),n=v+24;e*y<n&&(y=Math.ceil(n/e))}for(let i=0;i<t.length;i+=y){let s=n.startIndex+i;if(u!==void 0&&s===u)continue;let c=r.xToPixel(s,n,a),f=Ut(t[i].time,p,l,g,d),m=e.measureText(f).width/2,h=Math.max(m,Math.min(a-m,c));e.fillText(f,h,o+14)}}function Gt(e,t,n,r,i,a,o,s,c,l=b){let u=Math.max(0,t+n-Date.now()),d=Ht(Math.ceil(u/1e3));e.font=`${l.fontSize} ${l.fontFamily}`;let f=e.measureText(d).width+zt*2,p=Rt,m=a.xToPixel(r,i,s),h=Math.max(f/2,m),g=h-f/2,_=c+1;e.save(),e.beginPath(),e.rect(0,c,s,Rt+4),e.clip(),e.fillStyle=o.axisText,e.beginPath(),e.roundRect(g,_,f,p,Bt),e.fill(),e.fillStyle=o.background,e.textAlign=`center`,e.textBaseline=`middle`,e.fillText(d,h,_+p/2),e.textBaseline=`alphabetic`,e.restore()}function Kt(e,t,n,r,i,a,o,s){let c=Math.max(0,t+n-Date.now()),l=Ht(Math.ceil(c/1e3)),u=a+o;e.save(),e.fillStyle=r.axisText,e.fillRect(i,u,s,o),e.fillStyle=r.background,e.font=`10px 'Inter', system-ui, sans-serif`,e.textAlign=`left`,e.fillText(l,i+4,u+o-4),e.restore()}function qt(e,t,n,r,i,s,c,l,u=2,d=y,f=`price`){e.fillStyle=r.axisText,e.font=`${d.fontSize} ${d.fontFamily}`,e.textAlign=`left`;let p=(e,t)=>f===`percent`?`${e>=0?`+`:``}${e.toFixed(t)}%`:e.toFixed(t);if(l===void 0){let r=a(t,s),c=o(r.length>=2?r[1]-r[0]:t.max-t.min,u);for(let a of r){let r=n.yToPixel(a,t,s);if(f===`percent`&&Math.abs(a)<1e-9){let t=e.font;e.font=`bold ${d.fontSize} ${d.fontFamily}`,e.fillText(p(a,c),i+4,r+4),e.font=t}else e.fillText(p(a,c),i+4,r+4)}return}let m=(t.max-t.min)/l;for(let r=0;r<=l;r++){let a=t.min+m*r,o=n.yToPixel(a,t,s);e.fillText(p(a,u),i+4,o+4)}}function H(e,t){return`<svg viewBox="0 0 16 16" width="${t}" height="${t}" fill="none" xmlns="http://www.w3.org/2000/svg">${e}</svg>`}function Jt(e,t=16){return`<svg viewBox="0 0 24 24" width="${t}" height="${t}" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg">${e}</svg>`}var Yt=`<svg viewBox="0 0 16 16" width="14" height="14" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M6.5 1.5h3l.5 1.8a5.1 5.1 0 0 1 1.24.72l1.76-.56 1.5 2.6-1.38 1.18a5.2 5.2 0 0 1 0 1.44l1.38 1.18-1.5 2.6-1.76-.56A5.1 5.1 0 0 1 10 12.7l-.5 1.8h-3l-.5-1.8a5.1 5.1 0 0 1-1.24-.72l-1.76.56-1.5-2.6L2.88 8.76a5.2 5.2 0 0 1 0-1.44L1.5 6.14l1.5-2.6 1.76.56A5.1 5.1 0 0 1 6 3.38Z" stroke="currentColor" stroke-width="1.3" stroke-linejoin="round"/><circle cx="8" cy="8" r="2.2" stroke="currentColor" stroke-width="1.3"/></svg>`,Xt=Yt,Zt=`<svg viewBox="0 0 16 16" width="14" height="14" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M11.5 2.5a1.5 1.5 0 0 1 2.121 2.121l-8.5 8.5L2.5 13.5l.379-2.621 8.621-8.379Z" stroke="currentColor" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round"/></svg>`,Qt=`<svg viewBox="0 0 16 16" width="10" height="10" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M3 3l10 10M13 3L3 13" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/></svg>`,$t=`<svg viewBox="0 0 16 16" width="15" height="15" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M1.5 6.5V1.5h5M6.5 6.5L1.5 1.5" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.5 9.5v5h-5M9.5 9.5l5 5" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"/></svg>`,en=`<svg viewBox="0 0 16 16" width="15" height="15" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M6.5 1.5H1.5v5M1.5 1.5l5 5" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"/><path d="M9.5 14.5H14.5v-5M14.5 14.5l-5-5" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"/></svg>`,tn=`<svg viewBox="0 0 16 16" width="15" height="15" fill="none" xmlns="http://www.w3.org/2000/svg"><polyline points="3.5,5 4.5,13.5 11.5,13.5 12.5,5" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"/><line x1="2" y1="5" x2="14" y2="5" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"/><path d="M6 5V3.5C6 3 6.5 2.5 7 2.5h2C9.5 2.5 10 3 10 3.5V5" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"/></svg>`,nn={candlestick:`<svg viewBox="0 0 16 16" width="16" height="16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
42
|
+
levels this frame: `+r.levels.map(e=>`${e.label}/${e.type}${e.isDraft?`/DRAFT`:``} price=${e.price} sl=${e.sl} tp=${e.tp}`).join(` | `)),typeof window<`u`&&(window.__bracketDupe={dupeKeys:n,frame:r,draws:et.slice()})}}}return e.restore(),{hitAreas:Ce,editAreas:we,hoverAreas:De,dragAreas:Oe,confirmAreas:ke,addBracketAreas:Ae,clusterBadgeAreas:je,clusters:re,draftQtyPillArea:Me[0]}}var pt=`bold 12px 'Inter', system-ui, sans-serif`,mt=12,ht=24,gt=12;function _t(e,t,n,r,i){let a=st(r),o=!c(r.background);e.save(),e.strokeStyle=a,e.globalAlpha=.12,e.lineWidth=1,e.setLineDash([4,4]);for(let r of t.members)e.beginPath(),e.moveTo(0,r.y),e.lineTo(n,r.y),e.stroke();e.setLineDash([]),e.restore(),e.save(),e.font=pt;let{badgeX:s,badgeY:l,badgeW:u,text:d}=De(t,n,e);e.fillStyle=o?`rgba(40,40,40,0.92)`:`rgba(240,240,240,0.92)`,e.beginPath(),e.roundRect(s,l,u,ht,gt),e.fill(),e.strokeStyle=a,e.globalAlpha=.3,e.lineWidth=1,e.stroke(),e.globalAlpha=1,e.fillStyle=a,e.globalAlpha=.85,e.textBaseline=`middle`,e.textAlign=`left`,e.fillText(d+` ▸`,s+mt,l+ht/2),e.globalAlpha=1,e.restore(),i.push({clusterId:t.id,x:s,y:l,w:u,h:ht})}function vt(e,t,n,r,i){if(Math.abs(t-n)<2)return;let a=st(i);e.save(),e.strokeStyle=a,e.globalAlpha=.25,e.lineWidth=1,e.setLineDash([2,3]);let o=r-8;e.beginPath(),e.moveTo(o,t),e.lineTo(o,n),e.stroke(),e.setLineDash([]),e.beginPath(),e.moveTo(o-4,n),e.lineTo(o+4,n),e.stroke(),e.restore()}function yt(e,t,n,r,i){r-n<2||(e.save(),e.strokeStyle=st(i),e.globalAlpha=.5,e.lineWidth=1,e.setLineDash([3,4]),e.beginPath(),e.moveTo(t,n),e.lineTo(t,r),e.stroke(),e.setLineDash([]),e.restore())}function bt(e,t,n,r,i,a,o){let s=t,c=[],l=t;if(s.orderType!==void 0)c.push({label:`Price`,value:t.price.toFixed(o)}),l.stopLossPrice!==void 0&&c.push({label:l.stopLossTrailing?`TSL`:`SL`,value:l.stopLossPrice.toFixed(o)}),l.takeProfitPrice!==void 0&&c.push({label:`TP`,value:l.takeProfitPrice.toFixed(o)});else{if(s.pnlText!==void 0){let e=s.pnl===void 0?void 0:s.pnl>=0?a.candle.up:a.candle.down;c.push({label:`PnL`,value:s.pnlText,pnlColor:e})}s.side!==void 0&&c.push({label:`Side`,value:s.side===`buy`?`Buy`:`Sell`}),s.lots!==void 0&&c.push({label:`Lots`,value:String(s.lots)}),c.length===0&&c.push({label:`Price`,value:t.price.toFixed(o)})}let u=ke,d=Me,f=Ne+3;e.save(),e.font=He;let p=Math.max(...c.map(t=>e.measureText(t.label).width)),m=Math.max(...c.map(t=>e.measureText(t.value).width)),h=u+p+8+m+u,g=d+c.length*f-3+d,_=r-i-8-h,v=n-g/2;e.fillStyle=ct(a,!0),e.strokeStyle=st(a),e.lineWidth=1,Et(e,_,v,h,g,Pe),e.fill(),e.stroke(),e.textBaseline=`top`,c.forEach((t,n)=>{var r;let i=v+d+n*f;e.textAlign=`left`,e.fillStyle=st(a),e.globalAlpha=.55,e.fillText(t.label,_+u,i),e.globalAlpha=1,e.textAlign=`right`,e.fillStyle=(r=t.pnlColor)==null?st(a):r,e.fillText(t.value,_+u+p+8+m,i)}),e.restore()}function xt(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C=!1,w,T=!1,E,D=null,O=null,k=1,A,j=!1,M=null,N=!1,P,F=Ye,I=Je(1),L=`auto`){var R,z;let{y:B,boxY:ee,boxW:te,boxH:ne}=n,re=lt(t,i,a),ie=s||c,ae=j&&!ie,oe=C||ae,se=Math.min(Math.max(k,1),3)*I.k,ce=Ie*se,V=Le*se,le=ze*se,ue=Re*se,de=Be*se;if(g===`dot`&&t.type===`position`&&!c){let n=r-6-4;s&&bt(e,t,B,n,6,a,o),e.save(),e.fillStyle=re,e.globalAlpha=s?1:.75,e.beginPath(),e.arc(n,B,6,0,Math.PI*2),e.fill(),e.globalAlpha=1,e.restore(),y.push({label:t.label,boxX:n-6,boxY:B-6,boxW:12,boxH:12,lineX:n-6,lineY:B-6,lineW:12,lineH:12});return}let fe=nt(t)?t.pnlText:null,pe=t.type===`position`?t.pnl:void 0,me=t.type===`pending`,he=me&&t.orderType===`market`&&((R=t.data)==null?void 0:R._isDraft)===!0,ge=ut(t),_e=(ge?I.gripW+2:0)+te,ve=M===null?L===`left`?I.leftMargin:Math.round((r-_e)/2):Math.max(0,Math.min(r-_e,Math.round(M-_e/2))),ye=ge?ve:0,be=ge?ve+I.gripW+2:ve,xe=N&&t.timeDraggable===!0,Se=t;if((P==null?ie:P)||he||ae){let n=`${t.label}:stopLoss`,i=`${t.label}:takeProfit`,s=f===t.label,h=s&&D!==null?D:Se.stopLossPrice,g=s&&O!==null?O:Se.takeProfitPrice;if(c&&h!==void 0&&g!==void 0){var Ce,we,Te,Ee;let s=l.yToPixel(h,u,d),c=l.yToPixel(g,u,d),p=C?Ke:Math.max(Ke,ce*2+Ge*2);e.save(),e.font=qe;let _=C?0:ce*2+U/2,v=t.stopLossTrailing?0:_,y=U+e.measureText(Xe(`stopLoss`,h,o,t,F,f===n&&!(w!=null&&w.sl))).width+U+v,b=U+e.measureText(Xe(`takeProfit`,g,o,t,F,f===i&&!(w!=null&&w.tp))).width+U+_;e.restore();let x=(Ce=m.get(n))==null?r*Ze:Ce,S=(we=m.get(i))==null?r*Ze:we,T=(x-y/2-2+(S-b/2-2))/2,E=(Te=A==null?void 0:A.get(n))==null?s-p/2:Te,D=(Ee=A==null?void 0:A.get(i))==null?c-p/2:Ee,[O,k]=D<E?[D,E]:[E,D];yt(e,T,O+p,k,a)}if(h!==void 0){var De;Ct(e,Se,`stopLoss`,h,l,u,d,(De=m.get(n))==null?r*Ze:De,r,a,o,f,p,_,b,oe,Se._slOrderLabel,w==null?void 0:w.sl,k,A==null?void 0:A.get(n),F)}else f===n&&p!==null&&Ct(e,Se,`stopLoss`,p,l,u,d,r*Ze,r,a,o,f,p,_,b,oe,void 0,w==null?void 0:w.sl,k,void 0,F);if(g!==void 0){var Oe;Ct(e,Se,`takeProfit`,g,l,u,d,(Oe=m.get(i))==null?r*Ze:Oe,r,a,o,f,p,_,b,oe,Se._tpOrderLabel,w==null?void 0:w.tp,k,A==null?void 0:A.get(i),F)}else f===i&&p!==null&&Ct(e,Se,`takeProfit`,p,l,u,d,r*Ze,r,a,o,f,p,_,b,oe,void 0,w==null?void 0:w.tp,k,void 0,F);if(c&&Se.side!==void 0){let t=r*Ze;Se.stopLossPrice===void 0&&f!==n&&St(e,Se,`stopLoss`,B,t,r,d,a,S),Se.takeProfitPrice===void 0&&f!==i&&St(e,Se,`takeProfit`,B,t,r,d,a,S)}}if(he)return;let ke=t.type===`position`&&t.entryPriceEditable===!0;e.save(),e.strokeStyle=re,e.lineWidth=Fe,e.globalAlpha=ie?1:.85,(me||ke)&&e.setLineDash([5,4]),e.beginPath(),e.moveTo(0,B),e.lineTo(r,B),e.stroke(),e.setLineDash([]),e.globalAlpha=1,e.restore();let Ae=ee+ne/2;e.save(),e.fillStyle=ct(a,ie),e.strokeStyle=re,e.lineWidth=1,Et(e,be,ee,te,ne,Pe),e.fill(),e.stroke();let je=be+I.padX,Me=((z=t.data)==null?void 0:z._isDraft)===!0,Ne=t.type===`pending`||ke,Ve=t.lots,He=T&&(Me||c||h)&&Ne&&Ve!==void 0;if(He){let n=String(Ve);e.font=I.fontMain;let r=e.measureText(n).width,i=I.pillPadX+r+I.pillPadX,o=je;e.save(),e.strokeStyle=st(a),e.globalAlpha=.35,e.lineWidth=1,e.beginPath(),e.moveTo(o+i,ee+3),e.lineTo(o+i,ee+ne-3),e.stroke(),e.restore(),e.fillStyle=st(a),e.textAlign=`left`,e.textBaseline=`middle`,e.fillText(n,o+I.pillPadX,Ae),E==null||E.push({label:t.label,pillX:o,pillY:ee,pillW:i,pillH:ne}),je+=i+I.pillGap}if(fe){let t=pe===void 0?st(a):pe>=0?a.candle.up:a.candle.down;e.font=I.fontPnl,e.fillStyle=t,e.textAlign=`left`,e.textBaseline=`middle`,e.fillText(fe,je,Ae),je+=e.measureText(fe).width+I.pnlGap}let Ue=at(t,n.price,o,He);e.font=I.fontMain,e.fillStyle=st(a),e.textAlign=`left`,e.textBaseline=`middle`,e.fillText(Ue,je,Ae);let H=Ae,We=3.5*I.k;if(!C&&h){let n=be+te-I.padX/2-le,r=n-le-de-le;e.fillStyle=a.candle.up,e.beginPath(),e.arc(r,H,le,0,Math.PI*2),e.fill(),e.strokeStyle=a.background,e.lineWidth=1.5,e.lineCap=`round`,e.lineJoin=`round`;let i=3.1*I.k;e.beginPath(),e.moveTo(r-i,H),e.lineTo(r-i*.2,H+i*.8),e.lineTo(r+i,H-i*.7),e.stroke(),e.fillStyle=a.candle.down,e.beginPath(),e.arc(n,H,le,0,Math.PI*2),e.fill(),e.strokeStyle=a.background,e.lineWidth=1.5,e.lineCap=`round`,e.beginPath(),e.moveTo(n-We,H-We),e.lineTo(n+We,H+We),e.moveTo(n+We,H-We),e.lineTo(n-We,H+We),e.stroke(),x.push({label:t.label,type:t.type,data:t.data,action:`confirm`,x:r-le,y:H-le,w:le*2,h:le*2}),x.push({label:t.label,type:t.type,data:t.data,action:`cancel`,x:n-le,y:H-le,w:le*2,h:le*2})}else if(!C){let n=be+te-I.padX/2-ce,r=n-ce-ue-V;e.fillStyle=st(a),e.beginPath(),e.arc(r,H,V,0,Math.PI*2),e.fill();let i=V*.48;e.save(),e.strokeStyle=a.background,e.lineWidth=1.5,e.lineCap=`round`,e.lineJoin=`round`,e.translate(r,H),e.rotate(Math.PI/4),e.beginPath(),e.moveTo(-i*.35,-i),e.lineTo(-i*.35,i*.5),e.lineTo(i*.35,i*.5),e.lineTo(i*.35,-i),e.closePath(),e.stroke(),e.beginPath(),e.moveTo(-i*.35,i*.5),e.lineTo(0,i+i*.45),e.lineTo(i*.35,i*.5),e.stroke(),e.restore(),e.fillStyle=st(a),e.beginPath(),e.arc(n,H,ce,0,Math.PI*2),e.fill(),e.strokeStyle=a.background,e.lineWidth=1.5,e.lineCap=`round`,e.beginPath(),e.moveTo(n-We,H-We),e.lineTo(n+We,H+We),e.moveTo(n+We,H-We),e.lineTo(n-We,H+We),e.stroke(),v.push({label:t.label,type:t.type,data:t.data,x:r-V,y:H-V,w:V*2,h:V*2}),_.push({label:t.label,type:t.type,data:t.data,x:n-ce,y:H-ce,w:ce*2,h:ce*2})}if(e.restore(),ge){Tt(e,ye,ee,ne,i,s,I.gripW,I.gripDotR);let n=C?0:V*2+ue+ce*2+I.padX/2;b.push({label:t.label,type:t.type,data:t.data,price:t.price,x:ye,y:ee,w:I.gripW+2+te-n,h:ne,isBracket:!1,isBox:!0,timeDrag:xe}),b.push({label:t.label,type:t.type,data:t.data,price:t.price,x:0,y:B-4,w:r,h:8,isBracket:!1})}else (C||xe)&&te>0&&b.push({label:t.label,type:t.type,data:t.data,price:t.price,x:be,y:ee,w:te,h:ne,isBracket:!1,isBox:!0,timeDrag:xe});y.push({label:t.label,boxX:be,boxY:ee,boxW:te,boxH:ne,lineX:0,lineY:B-4,lineW:r,lineH:8})}function St(e,t,n,r,i,a,o,s,c){let l=r+(t.side===`buy`&&n===`stopLoss`||t.side===`sell`&&n===`takeProfit`?$e:-$e);if(l<0||l>o)return;e.save(),e.strokeStyle=st(s),e.lineWidth=.8,e.globalAlpha=.3,e.setLineDash([4,4]),e.beginPath(),e.moveTo(i,l),e.lineTo(a,l),e.stroke(),e.setLineDash([]),e.globalAlpha=1,e.restore();let u=n===`stopLoss`?`+SL`:`+TP`;e.font=qe;let d=U+e.measureText(u).width+U,f=Ke,p=i-d-2,m=l-f/2;e.save(),e.globalAlpha=.75,e.fillStyle=ct(s,!1),e.strokeStyle=st(s),e.lineWidth=.8,Et(e,p,m,d,f,Pe),e.fill(),e.stroke(),e.globalAlpha=1,e.fillStyle=st(s),e.textAlign=`left`,e.textBaseline=`middle`,e.fillText(u,p+U,l),e.restore(),c.push({label:t.label,type:t.type,data:t.data,bracketType:n,x:p,y:m,w:d,h:f})}function Ct(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v=1,y,b=Ye){var x,S,C;let w=Ie*Math.min(Math.max(v,1),3),T=d===`${t.label}:${n}`,E=T&&f!==null?f:r,D=i.yToPixel(E,a,o);if(D<-20||D>o+20)return;e.save(),e.strokeStyle=st(l),e.lineWidth=We,e.globalAlpha=.8,e.beginPath(),e.moveTo(s,D),e.lineTo(c,D),e.stroke(),e.globalAlpha=1;let O=Xe(n,E,u,t,b,T&&!_),k=n===`stopLoss`&&t.stopLossTrailing===!0;e.font=qe;let A=e.measureText(O).width,j=_?e.measureText(_).width+U:0,M=h||k?0:w*2+U/2,N=U+A+j+U+M,P=h?Ke:Math.max(Ke,w*2+Ge*2),F=s-N-2,I=D-P/2,L=y==null?I:y,R=L+P/2,z=Math.abs(L-I)>=2;if(et.push({label:t.label,levelType:t.type,isDraft:!!((x=t.data)!=null&&x._isDraft),bracketType:n,price:E,bX:Math.round(F),bW:Math.round(N),rightEdge:Math.round(F+N),boxY:Math.round(L),pnlText:_==null?null:_,hideConfirmCancel:h}),z&&wt(e,F+N/2,R,D,l),e.fillStyle=ct(l,!1),e.strokeStyle=st(l),e.lineWidth=.8,Et(e,F,L,N,P,Pe),e.fill(),e.stroke(),e.fillStyle=st(l),e.textAlign=`left`,e.textBaseline=`middle`,e.fillText(O,F+U,R),_&&(e.fillStyle=_.trim().startsWith(`-`)?l.candle.down:l.candle.up,e.fillText(_,F+U+A+U,R)),!h&&!k){let r=F+N-U/2-w,i=R;e.fillStyle=st(l),e.beginPath(),e.arc(r,i,w,0,Math.PI*2),e.fill(),e.strokeStyle=l.background,e.lineWidth=1.5,e.lineCap=`round`;let a=3.5;e.beginPath(),e.moveTo(r-a,i-a),e.lineTo(r+a,i+a),e.moveTo(r+a,i-a),e.lineTo(r-a,i+a),e.stroke(),p.push({label:t.label,type:t.type,data:t.data,bracketType:n,bracketOrderLabel:g,x:r-w,y:i-w,w:w*2,h:w*2})}if(e.restore(),k)return;m.push({label:t.label,data:t.data,bracketType:n,price:E,parentPrice:t.price,parentSide:(S=t.side)==null?`buy`:S,bracketOrderLabel:g,x:s,y:D-5,w:c-s,h:10,isBracket:!0});let B=w*2+U/2;m.push({label:t.label,data:t.data,bracketType:n,price:E,parentPrice:t.price,parentSide:(C=t.side)==null?`buy`:C,bracketOrderLabel:g,x:F,y:L,w:N-B,h:P,isBracket:!0})}function wt(e,t,n,r,i){Math.abs(n-r)<2||(e.save(),e.strokeStyle=st(i),e.globalAlpha=.35,e.lineWidth=1,e.setLineDash([2,3]),e.beginPath(),e.moveTo(t,n),e.lineTo(t,r),e.stroke(),e.restore())}function Tt(e,t,n,r,i,a,o=Ue,s=H){let c=a?i.dragHandleHover:i.dragHandle,l=s/H*3,u=s*2*2+1*l,d=s*2*3+2*l,f=t+(o-u)/2+s,p=n+(r-d)/2+s;e.save(),e.fillStyle=c;for(let t=0;t<3;t++)for(let n=0;n<2;n++){let r=f+n*(s*2+l),i=p+t*(s*2+l);e.beginPath(),e.arc(r,i,s,0,Math.PI*2),e.fill()}e.restore()}function Et(e,t,n,r,i,a){e.beginPath(),e.moveTo(t+a,n),e.lineTo(t+r-a,n),e.arcTo(t+r,n,t+r,n+a,a),e.lineTo(t+r,n+i-a),e.arcTo(t+r,n+i,t+r-a,n+i,a),e.lineTo(t+a,n+i),e.arcTo(t,n+i,t,n+i-a,a),e.lineTo(t,n+a),e.arcTo(t,n,t+a,n,a),e.closePath()}function Dt(e,t,n){var r;return(r=n.find(n=>e>=n.x&&e<=n.x+n.w&&t>=n.y&&t<=n.y+n.h))==null?null:r}function Ot(e,t,n){var r;return(r=n.find(n=>e>=n.x&&e<=n.x+n.w&&t>=n.y&&t<=n.y+n.h))==null?null:r}function kt(e,t,n){var r;return(r=n.find(n=>e>=n.x&&e<=n.x+n.w&&t>=n.y&&t<=n.y+n.h))==null?null:r}function At(e,t,n){var r;return(r=n.find(n=>e>=n.boxX&&e<=n.boxX+n.boxW&&t>=n.boxY&&t<=n.boxY+n.boxH||e>=n.lineX&&e<=n.lineX+n.lineW&&t>=n.lineY&&t<=n.lineY+n.lineH))==null?null:r}function jt(e,t,n){var r;return(r=n.find(n=>e>=n.x&&e<=n.x+n.w&&t>=n.y&&t<=n.y+n.h))==null?null:r}function Mt(e,t,n){var r;return(r=n.find(n=>e>=n.x&&e<=n.x+n.w&&t>=n.y&&t<=n.y+n.h))==null?null:r}function Nt(e,t,n,r,i,a,o,s){let c=[];for(let e of t){if(e.type!==`position`)continue;let t=e;if(t.entryPriceEditable)continue;let a=n.yToPixel(t.price,r,o);a<-16||a>o+16||c.push({y:a,label:t.price.toFixed(s),color:lt(e,i.tradeLevels,i)})}if(c.length===0)return;c.sort((e,t)=>e.y-t.y);let l=-1/0;for(let e of c)e.y-16/2<l&&(e.y=l+16/2),l=e.y+16/2+1;e.save(),e.font=`10px 'Inter', system-ui, sans-serif`,e.textAlign=`left`,e.textBaseline=`middle`;for(let t of c){let n=e.measureText(t.label).width;e.fillStyle=t.color,e.fillRect(a,t.y-16/2,n+12,16),e.fillStyle=`#ffffff`,e.fillText(t.label,a+4,t.y)}e.restore()}function Pt(e,t,n){let r=[],i=[],{min:a,max:o}=t;for(let t of e){var s;if(t.label===n||t.type===`pending`&&t.orderType===`market`&&((s=t.data)==null?void 0:s._isDraft)===!0)continue;isFinite(t.price)&&(t.price>o?r.push({price:t.price,label:t.label,kind:`entry`}):t.price<a&&i.push({price:t.price,label:t.label,kind:`entry`}));let e=t.stopLossPrice,c=t.takeProfitPrice;e!==void 0&&isFinite(e)&&(e>o?r.push({price:e,label:t.label,kind:`sl`}):e<a&&i.push({price:e,label:t.label,kind:`sl`})),c!==void 0&&isFinite(c)&&(c>o?r.push({price:c,label:t.label,kind:`tp`}):c<a&&i.push({price:c,label:t.label,kind:`tp`}))}return{above:r,below:i}}function Ft(e){let t=0;for(let n of e)n.kind===`entry`&&t++;return t}function It(e,t){let n=e[0],r=Math.abs(n.price-t);for(let i=1;i<e.length;i++){let a=Math.abs(e[i].price-t);a<r&&(n=e[i],r=a)}return n}var Lt=`11px 'Inter', system-ui, sans-serif`,Rt=8,zt=8,Bt=10,Vt=20,Ht=10,Ut=`▲`,Wt=`▼`;function Gt(e,t,n,r,i,a,o,s=null){let c=[],l=a-40,u=n.max-n.min,d=l>0?u/l*20:0,{above:f,below:p}=Pt(t,{min:n.min-d,max:n.max+d},o);if(f.length===0&&p.length===0)return{hitAreas:c};e.save(),e.font=Lt,e.textBaseline=`middle`,e.textAlign=`center`;let m=(t,n,a,o)=>{let s=e.measureText(n).width,l=Math.ceil(s)+Rt*2,u=i-zt-l;return e.fillStyle=r.tooltip.background,e.strokeStyle=r.tooltip.border,e.lineWidth=1,Jt(e,u,a,l,Vt,Ht),e.fill(),e.stroke(),e.fillStyle=r.tooltip.text,e.fillText(n,u+l/2,a+Vt/2+.5),c.push({direction:t,x:u,y:a,w:l,h:Vt,targetPrice:o.price,targetLabel:o.label,targetKind:o.kind}),l},h=(e,t,r)=>{if(t.length===0)return;let i=e===`up`?Ut:Wt,a=e===`up`?n.max:n.min,o=e===`up`?1:-1,c=r,l=Ft(t);if(l>0){let n=It(t.filter(e=>e.kind===`entry`),a);m(e,`${i} ${l}`,c,n),c+=o*(Vt+4)}if(s!==null){let n=t.filter(e=>e.kind!==`entry`&&e.label===s);for(let t of n)m(e,`${i} ${t.kind.toUpperCase()}`,c,t),c+=o*(Vt+4)}};return h(`up`,f,Bt),h(`down`,p,a-Bt-Vt),e.restore(),{hitAreas:c}}function Kt(e,t,n){var r;return(r=n.find(n=>e>=n.x&&e<=n.x+n.w&&t>=n.y&&t<=n.y+n.h))==null?null:r}function qt(e,t,n){let r=e-t,i=e+t;return n.some(e=>r<e.y+e.h&&i>e.y)}function Jt(e,t,n,r,i,a){let o=Math.min(a,r/2,i/2);e.beginPath(),e.moveTo(t+o,n),e.lineTo(t+r-o,n),e.quadraticCurveTo(t+r,n,t+r,n+o),e.lineTo(t+r,n+i-o),e.quadraticCurveTo(t+r,n+i,t+r-o,n+i),e.lineTo(t+o,n+i),e.quadraticCurveTo(t,n+i,t,n+i-o),e.lineTo(t,n+o),e.quadraticCurveTo(t,n,t+o,n),e.closePath()}var Yt=18,Xt=6,Zt=3,Qt=[`1m`,`3m`,`4m`,`5m`,`10m`,`15m`,`30m`,`1h`,`4h`];function $t(e){return e<60?`${e}s`:e<3600?`${Math.floor(e/60)}:${(e%60).toString().padStart(2,`0`)}`:e<86400?`${Math.floor(e/3600)}h ${Math.floor(e%3600/60)}m`:e<604800?`${Math.floor(e/86400)}d ${Math.floor(e%86400/3600)}h`:`${Math.floor(e/604800)}w ${Math.floor(e%604800/86400)}d`}function en(e,t,n,r,i=`UTC`){let a=new Date(e);if(n&&Qt.includes(n)){let e=a.toLocaleTimeString(`en-US`,{hour:`2-digit`,minute:`2-digit`,hour12:!1,timeZone:i});return r?a.toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,timeZone:i})+` `+e:e}return n===`1Y`?a.toLocaleDateString(`en-US`,{year:`numeric`,timeZone:i}):n===`1M`?a.toLocaleDateString(`en-US`,{month:`short`,year:`numeric`,timeZone:i}):t<=365?a.toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,timeZone:i}):a.toLocaleDateString(`en-US`,{month:`short`,year:`2-digit`,timeZone:i})}function tn(e,t,n,r,i,a,o,s=8,c=C,l,u,d=`UTC`){var f;if(t.length===0)return;let p=n.endIndex-n.startIndex,m=t[0],h=t[t.length-1],g=!!m&&!!h&&new Date(m.time).toLocaleDateString(`en-US`,{timeZone:d})!==new Date(h.time).toLocaleDateString(`en-US`,{timeZone:d});e.fillStyle=i.axisText,e.font=`${c.fontSize} ${c.fontFamily}`,e.textAlign=`center`;let _=en(((f=t[Math.floor(t.length/2)])==null?t[0]:f).time,p,l,g,d),v=e.measureText(_).width,y=Math.max(1,Math.floor(t.length/s));if(t.length>1){let e=a/Math.max(1,t.length),n=v+24;e*y<n&&(y=Math.ceil(n/e))}for(let i=0;i<t.length;i+=y){let s=n.startIndex+i;if(u!==void 0&&s===u)continue;let c=r.xToPixel(s,n,a),f=en(t[i].time,p,l,g,d),m=e.measureText(f).width/2,h=Math.max(m,Math.min(a-m,c));e.fillText(f,h,o+14)}}function nn(e,t,n,r,i,a,o,s,c,l=C){let u=Math.max(0,t+n-Date.now()),d=$t(Math.ceil(u/1e3));e.font=`${l.fontSize} ${l.fontFamily}`;let f=e.measureText(d).width+Xt*2,p=Yt,m=a.xToPixel(r,i,s),h=Math.max(f/2,m),g=h-f/2,_=c+1;e.save(),e.beginPath(),e.rect(0,c,s,Yt+4),e.clip(),e.fillStyle=o.axisText,e.beginPath(),e.roundRect(g,_,f,p,Zt),e.fill(),e.fillStyle=o.background,e.textAlign=`center`,e.textBaseline=`middle`,e.fillText(d,h,_+p/2),e.textBaseline=`alphabetic`,e.restore()}function rn(e,t,n,r,i,a,o,s){let c=Math.max(0,t+n-Date.now()),l=$t(Math.ceil(c/1e3)),u=a+o;e.save(),e.fillStyle=r.axisText,e.fillRect(i,u,s,o),e.fillStyle=r.background,e.font=`10px 'Inter', system-ui, sans-serif`,e.textAlign=`left`,e.fillText(l,i+4,u+o-4),e.restore()}function an(e,t,n,r,i,s,c,l,u=2,d=S,f=`price`){e.fillStyle=r.axisText,e.font=`${d.fontSize} ${d.fontFamily}`,e.textAlign=`left`;let p=(e,t)=>f===`percent`?`${e>=0?`+`:``}${e.toFixed(t)}%`:e.toFixed(t);if(l===void 0){let r=a(t,s),c=o(r.length>=2?r[1]-r[0]:t.max-t.min,u);for(let a of r){let r=n.yToPixel(a,t,s);if(f===`percent`&&Math.abs(a)<1e-9){let t=e.font;e.font=`bold ${d.fontSize} ${d.fontFamily}`,e.fillText(p(a,c),i+4,r+4),e.font=t}else e.fillText(p(a,c),i+4,r+4)}return}let m=(t.max-t.min)/l;for(let r=0;r<=l;r++){let a=t.min+m*r,o=n.yToPixel(a,t,s);e.fillText(p(a,u),i+4,o+4)}}function W(e,t){return`<svg viewBox="0 0 16 16" width="${t}" height="${t}" fill="none" xmlns="http://www.w3.org/2000/svg">${e}</svg>`}function on(e,t=16){return`<svg viewBox="0 0 24 24" width="${t}" height="${t}" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg">${e}</svg>`}var sn=`<svg viewBox="0 0 16 16" width="14" height="14" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M6.5 1.5h3l.5 1.8a5.1 5.1 0 0 1 1.24.72l1.76-.56 1.5 2.6-1.38 1.18a5.2 5.2 0 0 1 0 1.44l1.38 1.18-1.5 2.6-1.76-.56A5.1 5.1 0 0 1 10 12.7l-.5 1.8h-3l-.5-1.8a5.1 5.1 0 0 1-1.24-.72l-1.76.56-1.5-2.6L2.88 8.76a5.2 5.2 0 0 1 0-1.44L1.5 6.14l1.5-2.6 1.76.56A5.1 5.1 0 0 1 6 3.38Z" stroke="currentColor" stroke-width="1.3" stroke-linejoin="round"/><circle cx="8" cy="8" r="2.2" stroke="currentColor" stroke-width="1.3"/></svg>`,cn=sn,ln=`<svg viewBox="0 0 16 16" width="14" height="14" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M11.5 2.5a1.5 1.5 0 0 1 2.121 2.121l-8.5 8.5L2.5 13.5l.379-2.621 8.621-8.379Z" stroke="currentColor" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round"/></svg>`,un=`<svg viewBox="0 0 16 16" width="10" height="10" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M3 3l10 10M13 3L3 13" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/></svg>`,dn=`<svg viewBox="0 0 16 16" width="15" height="15" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M1.5 6.5V1.5h5M6.5 6.5L1.5 1.5" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.5 9.5v5h-5M9.5 9.5l5 5" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"/></svg>`,fn=`<svg viewBox="0 0 16 16" width="15" height="15" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M6.5 1.5H1.5v5M1.5 1.5l5 5" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"/><path d="M9.5 14.5H14.5v-5M14.5 14.5l-5-5" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"/></svg>`,pn=`<svg viewBox="0 0 16 16" width="15" height="15" fill="none" xmlns="http://www.w3.org/2000/svg"><polyline points="3.5,5 4.5,13.5 11.5,13.5 12.5,5" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"/><line x1="2" y1="5" x2="14" y2="5" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"/><path d="M6 5V3.5C6 3 6.5 2.5 7 2.5h2C9.5 2.5 10 3 10 3.5V5" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"/></svg>`,mn={candlestick:`<svg viewBox="0 0 16 16" width="16" height="16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
43
43
|
<line x1="3" y1="1.5" x2="3" y2="3.5" stroke="currentColor" stroke-width="1.2" stroke-linecap="round"/>
|
|
44
44
|
<rect x="1.5" y="3.5" width="3" height="5" fill="currentColor" rx="0.5"/>
|
|
45
45
|
<line x1="3" y1="8.5" x2="3" y2="11" stroke="currentColor" stroke-width="1.2" stroke-linecap="round"/>
|
|
@@ -119,154 +119,162 @@
|
|
|
119
119
|
<line x1="3" y1="2" x2="3" y2="12" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
|
|
120
120
|
<line x1="8" y1="4" x2="8" y2="14" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" opacity="0.65"/>
|
|
121
121
|
<line x1="13" y1="1" x2="13" y2="10" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
|
|
122
|
-
</svg>`},
|
|
123
|
-
<polyline points="7,4 12,4 12,9" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>`,18),fibonacci_gann:
|
|
122
|
+
</svg>`},hn={trend_lines:W(`<line x1="2" y1="14" x2="12" y2="4" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
|
|
123
|
+
<polyline points="7,4 12,4 12,9" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>`,18),fibonacci_gann:W(`<line x1="3" y1="3" x2="3" y2="13" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
|
|
124
124
|
<line x1="3" y1="4" x2="13" y2="4" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
|
|
125
125
|
<line x1="3" y1="8" x2="13" y2="8" stroke="currentColor" stroke-width="1.3" stroke-linecap="round" opacity="0.7"/>
|
|
126
|
-
<line x1="3" y1="12" x2="13" y2="12" stroke="currentColor" stroke-width="1.1" stroke-linecap="round" opacity="0.5"/>`,18),geometric_shapes:
|
|
126
|
+
<line x1="3" y1="12" x2="13" y2="12" stroke="currentColor" stroke-width="1.1" stroke-linecap="round" opacity="0.5"/>`,18),geometric_shapes:W(`<rect x="2.5" y="4.5" width="11" height="7" rx="1" stroke="currentColor" stroke-width="1.5"/>`,18),measurement_tools:W(`<line x1="8" y1="2" x2="8" y2="14" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
|
|
127
127
|
<polyline points="5,5 8,2 11,5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
128
|
-
<polyline points="5,11 8,14 11,11" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>`,18),pitchfork_tools:
|
|
128
|
+
<polyline points="5,11 8,14 11,11" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>`,18),pitchfork_tools:W(`<line x1="8" y1="14" x2="8" y2="7" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
|
|
129
129
|
<line x1="8" y1="7" x2="4" y2="3" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
|
|
130
130
|
<line x1="8" y1="7" x2="8" y2="3" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
|
|
131
|
-
<line x1="8" y1="7" x2="12" y2="3" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>`,18),volume_statistics:
|
|
131
|
+
<line x1="8" y1="7" x2="12" y2="3" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>`,18),volume_statistics:W(`<rect x="2" y="9" width="3" height="5" rx="0.5" fill="currentColor"/>
|
|
132
132
|
<rect x="6.5" y="5" width="3" height="9" rx="0.5" fill="currentColor" opacity="0.75"/>
|
|
133
|
-
<rect x="11" y="2" width="3" height="12" rx="0.5" fill="currentColor" opacity="0.5"/>`,18),annotation_tools:
|
|
134
|
-
<line x1="1" y1="13" x2="15" y2="13" stroke="currentColor" stroke-width="1" stroke-linecap="round" opacity="0.4"/>`,18),elliott_wave:
|
|
135
|
-
<line x1="9.5" y1="4.5" x2="11.5" y2="6.5" stroke="currentColor" stroke-width="1" stroke-linecap="round" opacity="0.5"/>`,18),
|
|
136
|
-
<
|
|
133
|
+
<rect x="11" y="2" width="3" height="12" rx="0.5" fill="currentColor" opacity="0.5"/>`,18),annotation_tools:W(`<path d="M2 3.5C2 2.67 2.67 2 3.5 2h9C13.33 2 14 2.67 14 3.5v6c0 .83-.67 1.5-1.5 1.5H7l-3 2.5V11H3.5C2.67 11 2 10.33 2 9.5V3.5z" stroke="currentColor" stroke-width="1.4" stroke-linejoin="round"/>`,18),pattern_recognition:W(`<polyline points="1,13 3.5,9 6,11 8,4 10,11 12.5,9 15,13" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
134
|
+
<line x1="1" y1="13" x2="15" y2="13" stroke="currentColor" stroke-width="1" stroke-linecap="round" opacity="0.4"/>`,18),elliott_wave:W(`<path d="M1 9 C3 3,5 3,7 9 C9 15,11 15,13 9 C14 6,15 6,15 8" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" fill="none"/>`,18),brush_highlighter:W(`<path d="M11.5 2.5l2 2-7.5 7.5-3 1 1-3 7.5-7.5z" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"/>
|
|
135
|
+
<line x1="9.5" y1="4.5" x2="11.5" y2="6.5" stroke="currentColor" stroke-width="1" stroke-linecap="round" opacity="0.5"/>`,18),forecasting:W(`<rect x="2.5" y="3.5" width="11" height="4" fill="currentColor" opacity="0.35" stroke="none"/>
|
|
136
|
+
<rect x="2.5" y="8.5" width="11" height="3" fill="currentColor" opacity="0.15" stroke="none"/>
|
|
137
|
+
<line x1="2.5" y1="8" x2="13.5" y2="8" stroke="currentColor" stroke-width="1.4"/>`,14),advanced_tools:W(`<path d="M1 8 C3 4,5 4,7 8 C9 12,11 12,13 8" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" fill="none"/>
|
|
138
|
+
<circle cx="14.5" cy="5.5" r="1.5" stroke="currentColor" stroke-width="1.2"/>`,18),price_projections:W(`<line x1="2" y1="11" x2="8" y2="5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
|
|
137
139
|
<line x1="8" y1="5" x2="13.5" y2="5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-dasharray="2 1.5"/>
|
|
138
|
-
<polyline points="10.5,2 13.5,5 10.5,8" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>`,18)},
|
|
139
|
-
<polyline points="2,5 3,9 7,8" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"/>`,16),redo:
|
|
140
|
-
<polyline points="14,5 13,9 9,8" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"/>`,16),delete_selected:
|
|
141
|
-
<line x1="12" y1="4" x2="4" y2="12" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>`,16),clear_all:
|
|
140
|
+
<polyline points="10.5,2 13.5,5 10.5,8" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>`,18)},gn={trend_lines:on(`<polyline points="22 7 13.5 15.5 8.5 10.5 2 17"/><polyline points="16 7 22 7 22 13"/>`),fibonacci_gann:on(`<polygon points="12 2 2 7 12 12 22 7 12 2"/><polyline points="2 17 12 22 22 17"/><polyline points="2 12 12 17 22 12"/>`),geometric_shapes:on(`<rect x="3" y="3" width="18" height="18" rx="2" ry="2"/>`),measurement_tools:on(`<path d="M12 3v18M5 8l7-7 7 7M5 16l7 7 7-7"/>`),pitchfork_tools:on(`<line x1="12" y1="22" x2="12" y2="11"/><path d="M12 11L6 5"/><path d="M12 11L12 5"/><path d="M12 11L18 5"/>`),volume_statistics:on(`<line x1="18" x2="18" y1="20" y2="10"/><line x1="12" x2="12" y1="20" y2="4"/><line x1="6" x2="6" y1="20" y2="14"/>`),annotation_tools:on(`<polyline points="4 7 20 7"/><line x1="12" y1="7" x2="12" y2="17"/>`),pattern_recognition:on(`<polyline points="22 12 18 12 15 21 9 3 6 12 2 12"/>`),elliott_wave:on(`<path d="M2 12c2-5 5-5 6 0s4 5 6 0 5-5 6 0" fill="none"/>`),brush_highlighter:on(`<path d="M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z"/>`),forecasting:on(`<rect x="3" y="4" width="18" height="7" fill="currentColor" opacity="0.28" stroke="none"/><rect x="3" y="13" width="18" height="5" fill="currentColor" opacity="0.12" stroke="none"/><line x1="3" y1="12" x2="21" y2="12"/><path d="M12 9V6"/><path d="m10 8 2-2 2 2"/>`),advanced_tools:on(`<path d="M6 15A6 6 0 0 0 18 15V3H6v12"/><line x1="6" y1="3" x2="2" y2="3"/><line x1="18" y1="3" x2="22" y2="3"/>`),price_projections:on(`<line x1="3" y1="14" x2="11" y2="6"/><line x1="11" y1="6" x2="20" y2="6" stroke-dasharray="3 2"/><polyline points="17 3 20 6 17 9"/>`)},_n={undo:W(`<path d="M3 8a5 5 0 1 1 1.4 3.5" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" fill="none"/>
|
|
141
|
+
<polyline points="2,5 3,9 7,8" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"/>`,16),redo:W(`<path d="M13 8a5 5 0 1 0-1.4 3.5" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" fill="none"/>
|
|
142
|
+
<polyline points="14,5 13,9 9,8" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"/>`,16),delete_selected:W(`<line x1="4" y1="4" x2="12" y2="12" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
|
|
143
|
+
<line x1="12" y1="4" x2="4" y2="12" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>`,16),clear_all:W(`<polyline points="3.5,5 4.5,13.5 11.5,13.5 12.5,5" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"/>
|
|
142
144
|
<line x1="2" y1="5" x2="14" y2="5" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"/>
|
|
143
|
-
<path d="M6 5V3.5C6 3 6.5 2.5 7 2.5h2C9.5 2.5 10 3 10 3.5V5" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"/>`,16),toggle_visibility:
|
|
144
|
-
<circle cx="8" cy="8" r="2" stroke="currentColor" stroke-width="1.4"/>`,16),toggle_lock:
|
|
145
|
-
<path d="M5.5 7.5V5.5a2.5 2.5 0 0 1 5 0" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"/>`,16)},
|
|
146
|
-
<line x1="3" y1="3" x2="13" y2="13" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"/>`,16),toggle_lock:
|
|
147
|
-
<path d="M5.5 7.5V5.5a2.5 2.5 0 0 1 5 0v2" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"/>`,16)},
|
|
148
|
-
<polyline points="7,4 12,4 12,9" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>`,14),trend_angle:
|
|
145
|
+
<path d="M6 5V3.5C6 3 6.5 2.5 7 2.5h2C9.5 2.5 10 3 10 3.5V5" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"/>`,16),toggle_visibility:W(`<path d="M1.5 8C3 5 5.5 3.5 8 3.5S13 5 14.5 8C13 11 10.5 12.5 8 12.5S3 11 1.5 8z" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"/>
|
|
146
|
+
<circle cx="8" cy="8" r="2" stroke="currentColor" stroke-width="1.4"/>`,16),toggle_lock:W(`<rect x="3.5" y="7.5" width="9" height="7" rx="1.5" stroke="currentColor" stroke-width="1.4"/>
|
|
147
|
+
<path d="M5.5 7.5V5.5a2.5 2.5 0 0 1 5 0" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"/>`,16)},vn={toggle_visibility:W(`<path d="M1.5 8C3 5 5.5 3.5 8 3.5S13 5 14.5 8C13 11 10.5 12.5 8 12.5S3 11 1.5 8z" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" opacity="0.35"/>
|
|
148
|
+
<line x1="3" y1="3" x2="13" y2="13" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"/>`,16),toggle_lock:W(`<rect x="3.5" y="7.5" width="9" height="7" rx="1.5" stroke="currentColor" stroke-width="1.4"/>
|
|
149
|
+
<path d="M5.5 7.5V5.5a2.5 2.5 0 0 1 5 0v2" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"/>`,16)},yn=_n.toggle_visibility,bn=vn.toggle_visibility,xn={trend_line:W(`<line x1="2" y1="14" x2="12" y2="4" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
|
|
150
|
+
<polyline points="7,4 12,4 12,9" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>`,14),trend_angle:W(`<line x1="3" y1="13" x2="13" y2="3" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
|
|
149
151
|
<path d="M3 13 L9 13" stroke="currentColor" stroke-width="1.2" stroke-linecap="round" opacity="0.6"/>
|
|
150
|
-
<path d="M3 13 A6 6 0 0 0 8.5 8.5" stroke="currentColor" stroke-width="1" fill="none" opacity="0.7"/>`,14),horizontal_line:
|
|
151
|
-
<line x1="2" y1="8" x2="14" y2="8" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>`,14),parallel_channel:
|
|
152
|
-
<line x1="4" y1="14" x2="14" y2="8" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" opacity="0.6"/>`,14),disjoint_channel:
|
|
153
|
-
<line x1="3" y1="14" x2="14" y2="10" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" opacity="0.6"/>`,14),flat_channel:
|
|
154
|
-
<line x1="2" y1="11" x2="14" y2="11" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" opacity="0.6"/>`,14),fib_retracement:
|
|
152
|
+
<path d="M3 13 A6 6 0 0 0 8.5 8.5" stroke="currentColor" stroke-width="1" fill="none" opacity="0.7"/>`,14),horizontal_line:W(`<line x1="2" y1="8" x2="14" y2="8" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>`,14),vertical_line:W(`<line x1="8" y1="2" x2="8" y2="14" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>`,14),cross_line:W(`<line x1="8" y1="2" x2="8" y2="14" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
|
|
153
|
+
<line x1="2" y1="8" x2="14" y2="8" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>`,14),parallel_channel:W(`<line x1="2" y1="11" x2="12" y2="5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
|
|
154
|
+
<line x1="4" y1="14" x2="14" y2="8" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" opacity="0.6"/>`,14),disjoint_channel:W(`<line x1="2" y1="10" x2="12" y2="5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
|
|
155
|
+
<line x1="3" y1="14" x2="14" y2="10" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" opacity="0.6"/>`,14),flat_channel:W(`<line x1="2" y1="5" x2="14" y2="5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
|
|
156
|
+
<line x1="2" y1="11" x2="14" y2="11" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" opacity="0.6"/>`,14),fib_retracement:W(`<line x1="3" y1="3" x2="3" y2="13" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
|
|
155
157
|
<line x1="3" y1="4" x2="13" y2="4" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"/>
|
|
156
158
|
<line x1="3" y1="8" x2="13" y2="8" stroke="currentColor" stroke-width="1.2" stroke-linecap="round" opacity="0.7"/>
|
|
157
|
-
<line x1="3" y1="12" x2="13" y2="12" stroke="currentColor" stroke-width="1" stroke-linecap="round" opacity="0.5"/>`,14),fib_extension:
|
|
159
|
+
<line x1="3" y1="12" x2="13" y2="12" stroke="currentColor" stroke-width="1" stroke-linecap="round" opacity="0.5"/>`,14),fib_extension:W(`<line x1="3" y1="2" x2="3" y2="14" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
|
|
158
160
|
<line x1="3" y1="3" x2="13" y2="3" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"/>
|
|
159
161
|
<line x1="3" y1="7" x2="13" y2="7" stroke="currentColor" stroke-width="1.2" stroke-linecap="round" opacity="0.7"/>
|
|
160
162
|
<line x1="3" y1="11" x2="13" y2="11" stroke="currentColor" stroke-width="1" stroke-linecap="round" opacity="0.5"/>
|
|
161
|
-
<line x1="3" y1="14" x2="13" y2="14" stroke="currentColor" stroke-width="1" stroke-linecap="round" opacity="0.35"/>`,14),fib_channel:
|
|
163
|
+
<line x1="3" y1="14" x2="13" y2="14" stroke="currentColor" stroke-width="1" stroke-linecap="round" opacity="0.35"/>`,14),fib_channel:W(`<line x1="2" y1="12" x2="12" y2="4" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
|
|
162
164
|
<line x1="4" y1="14" x2="14" y2="6" stroke="currentColor" stroke-width="1" stroke-linecap="round" opacity="0.6"/>
|
|
163
|
-
<line x1="3" y1="13" x2="13" y2="5" stroke="currentColor" stroke-width="1" stroke-linecap="round" opacity="0.4"/>`,14),fib_timezone:
|
|
165
|
+
<line x1="3" y1="13" x2="13" y2="5" stroke="currentColor" stroke-width="1" stroke-linecap="round" opacity="0.4"/>`,14),fib_timezone:W(`<line x1="4" y1="3" x2="4" y2="13" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
|
|
164
166
|
<line x1="7" y1="3" x2="7" y2="13" stroke="currentColor" stroke-width="1.3" stroke-linecap="round" opacity="0.75"/>
|
|
165
|
-
<line x1="11" y1="3" x2="11" y2="13" stroke="currentColor" stroke-width="1.1" stroke-linecap="round" opacity="0.55"/>`,14),fib_circles:
|
|
166
|
-
<circle cx="8" cy="8" r="5" stroke="currentColor" stroke-width="1" opacity="0.6"/>`,14),fib_spiral:
|
|
167
|
+
<line x1="11" y1="3" x2="11" y2="13" stroke="currentColor" stroke-width="1.1" stroke-linecap="round" opacity="0.55"/>`,14),fib_circles:W(`<circle cx="8" cy="8" r="2" stroke="currentColor" stroke-width="1.4"/>
|
|
168
|
+
<circle cx="8" cy="8" r="5" stroke="currentColor" stroke-width="1" opacity="0.6"/>`,14),fib_spiral:W(`<path d="M8 8 C8 5,11 5,11 8 C11 12,5 12,5 8 C5 3,13 3,13 8" stroke="currentColor" stroke-width="1.3" fill="none" stroke-linecap="round"/>`,14),fib_fan:W(`<line x1="3" y1="13" x2="13" y2="3" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"/>
|
|
167
169
|
<line x1="3" y1="13" x2="13" y2="7" stroke="currentColor" stroke-width="1.2" stroke-linecap="round" opacity="0.7"/>
|
|
168
|
-
<line x1="3" y1="13" x2="13" y2="11" stroke="currentColor" stroke-width="1" stroke-linecap="round" opacity="0.5"/>`,14),gann_fan:
|
|
170
|
+
<line x1="3" y1="13" x2="13" y2="11" stroke="currentColor" stroke-width="1" stroke-linecap="round" opacity="0.5"/>`,14),gann_fan:W(`<line x1="3" y1="13" x2="13" y2="3" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"/>
|
|
169
171
|
<line x1="3" y1="13" x2="13" y2="6" stroke="currentColor" stroke-width="1.2" stroke-linecap="round" opacity="0.7"/>
|
|
170
|
-
<line x1="3" y1="13" x2="13" y2="10" stroke="currentColor" stroke-width="1" stroke-linecap="round" opacity="0.5"/>`,14),gann_square:
|
|
172
|
+
<line x1="3" y1="13" x2="13" y2="10" stroke="currentColor" stroke-width="1" stroke-linecap="round" opacity="0.5"/>`,14),gann_square:W(`<rect x="3" y="3" width="10" height="10" stroke="currentColor" stroke-width="1.4"/>
|
|
171
173
|
<line x1="3" y1="3" x2="13" y2="13" stroke="currentColor" stroke-width="1" opacity="0.5"/>
|
|
172
|
-
<line x1="3" y1="13" x2="13" y2="3" stroke="currentColor" stroke-width="1" opacity="0.5"/>`,14),gann_box:
|
|
174
|
+
<line x1="3" y1="13" x2="13" y2="3" stroke="currentColor" stroke-width="1" opacity="0.5"/>`,14),gann_box:W(`<rect x="3" y="3" width="10" height="10" stroke="currentColor" stroke-width="1.4"/>
|
|
173
175
|
<line x1="8" y1="3" x2="8" y2="13" stroke="currentColor" stroke-width="1" opacity="0.5"/>
|
|
174
|
-
<line x1="3" y1="8" x2="13" y2="8" stroke="currentColor" stroke-width="1" opacity="0.5"/>`,14),rectangle:
|
|
176
|
+
<line x1="3" y1="8" x2="13" y2="8" stroke="currentColor" stroke-width="1" opacity="0.5"/>`,14),rectangle:W(`<rect x="2.5" y="4.5" width="11" height="7" rx="0.5" stroke="currentColor" stroke-width="1.5"/>`,14),rotated_rectangle:W(`<rect x="4" y="4" width="8" height="8" rx="0.5" stroke="currentColor" stroke-width="1.5" transform="rotate(45 8 8)"/>`,14),ellipse:W(`<ellipse cx="8" cy="8" rx="6" ry="4" stroke="currentColor" stroke-width="1.5"/>`,14),triangle:W(`<polygon points="8,2 14,13 2,13" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round"/>`,14),circle:W(`<circle cx="8" cy="8" r="5.5" stroke="currentColor" stroke-width="1.5"/>`,14),arc:W(`<path d="M3 12 A7 7 0 0 1 13 12" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" fill="none"/>`,14),polyline:W(`<polyline points="2,12 5,5 8,10 11,5 14,9" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>`,14),path:W(`<path d="M2 12 C4 5,6 5,8 8 C10 11,12 11,14 5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" fill="none"/>`,14),price_range:W(`<line x1="8" y1="2" x2="8" y2="14" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
|
|
175
177
|
<polyline points="5,5 8,2 11,5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
176
|
-
<polyline points="5,11 8,14 11,11" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>`,14),date_range:
|
|
178
|
+
<polyline points="5,11 8,14 11,11" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>`,14),date_range:W(`<line x1="2" y1="8" x2="14" y2="8" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
|
|
177
179
|
<polyline points="5,5 2,8 5,11" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
178
|
-
<polyline points="11,5 14,8 11,11" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>`,14),date_price_range:
|
|
179
|
-
<line x1="2.5" y1="3.5" x2="13.5" y2="12.5" stroke="currentColor" stroke-width="1" stroke-linecap="round" opacity="0.6"/>`,14),
|
|
180
|
+
<polyline points="11,5 14,8 11,11" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>`,14),date_price_range:W(`<rect x="2.5" y="3.5" width="11" height="9" stroke="currentColor" stroke-width="1.4"/>
|
|
181
|
+
<line x1="2.5" y1="3.5" x2="13.5" y2="12.5" stroke="currentColor" stroke-width="1" stroke-linecap="round" opacity="0.6"/>`,14),long_position:W(`<rect x="2.5" y="3.5" width="11" height="4" fill="currentColor" opacity="0.35" stroke="none"/>
|
|
182
|
+
<rect x="2.5" y="8.5" width="11" height="3" fill="currentColor" opacity="0.15" stroke="none"/>
|
|
183
|
+
<line x1="2.5" y1="8" x2="13.5" y2="8" stroke="currentColor" stroke-width="1.4"/>
|
|
184
|
+
<path d="M8 6.2 L6.6 7.6 M8 6.2 L9.4 7.6 M8 6.2 L8 4.4" stroke="currentColor" stroke-width="1.2" fill="none" stroke-linecap="round"/>`,14),short_position:W(`<rect x="2.5" y="8.5" width="11" height="4" fill="currentColor" opacity="0.35" stroke="none"/>
|
|
185
|
+
<rect x="2.5" y="4.5" width="11" height="3" fill="currentColor" opacity="0.15" stroke="none"/>
|
|
186
|
+
<line x1="2.5" y1="8" x2="13.5" y2="8" stroke="currentColor" stroke-width="1.4"/>
|
|
187
|
+
<path d="M8 9.8 L6.6 8.4 M8 9.8 L9.4 8.4 M8 9.8 L8 11.6" stroke="currentColor" stroke-width="1.2" fill="none" stroke-linecap="round"/>`,14),ruler:W(`<line x1="2" y1="8" x2="14" y2="8" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
|
|
180
188
|
<line x1="4" y1="6" x2="4" y2="10" stroke="currentColor" stroke-width="1.2" stroke-linecap="round"/>
|
|
181
189
|
<line x1="7" y1="7" x2="7" y2="9" stroke="currentColor" stroke-width="1.2" stroke-linecap="round"/>
|
|
182
190
|
<line x1="10" y1="6" x2="10" y2="10" stroke="currentColor" stroke-width="1.2" stroke-linecap="round"/>
|
|
183
|
-
<line x1="13" y1="7" x2="13" y2="9" stroke="currentColor" stroke-width="1.2" stroke-linecap="round"/>`,14),pitchfork:
|
|
191
|
+
<line x1="13" y1="7" x2="13" y2="9" stroke="currentColor" stroke-width="1.2" stroke-linecap="round"/>`,14),pitchfork:W(`<line x1="8" y1="14" x2="8" y2="7" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
|
|
184
192
|
<line x1="8" y1="7" x2="4" y2="3" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
|
|
185
193
|
<line x1="8" y1="7" x2="8" y2="3" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
|
|
186
|
-
<line x1="8" y1="7" x2="12" y2="3" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>`,14),schiff_pitchfork:
|
|
194
|
+
<line x1="8" y1="7" x2="12" y2="3" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>`,14),schiff_pitchfork:W(`<line x1="8" y1="14" x2="8" y2="8" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
|
|
187
195
|
<line x1="8" y1="8" x2="4" y2="3" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
|
|
188
196
|
<line x1="8" y1="8" x2="9" y2="3" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
|
|
189
|
-
<line x1="8" y1="8" x2="13" y2="4" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>`,14),modified_schiff:
|
|
197
|
+
<line x1="8" y1="8" x2="13" y2="4" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>`,14),modified_schiff:W(`<line x1="8" y1="14" x2="7" y2="8" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
|
|
190
198
|
<line x1="7" y1="8" x2="3" y2="3" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
|
|
191
199
|
<line x1="7" y1="8" x2="8" y2="3" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
|
|
192
|
-
<line x1="7" y1="8" x2="13" y2="5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>`,14),inside_pitchfork:
|
|
200
|
+
<line x1="7" y1="8" x2="13" y2="5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>`,14),inside_pitchfork:W(`<line x1="8" y1="14" x2="8" y2="7" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
|
|
193
201
|
<line x1="8" y1="7" x2="4" y2="3" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
|
|
194
202
|
<line x1="8" y1="7" x2="8" y2="3" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
|
|
195
203
|
<line x1="8" y1="7" x2="12" y2="3" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
|
|
196
|
-
<line x1="6" y1="5" x2="10" y2="5" stroke="currentColor" stroke-width="1" stroke-linecap="round" opacity="0.5"/>`,14),fixed_range_vp:
|
|
204
|
+
<line x1="6" y1="5" x2="10" y2="5" stroke="currentColor" stroke-width="1" stroke-linecap="round" opacity="0.5"/>`,14),fixed_range_vp:W(`<rect x="2" y="3" width="7" height="10" stroke="currentColor" stroke-width="1.2" opacity="0.5"/>
|
|
197
205
|
<line x1="9" y1="5" x2="14" y2="5" stroke="currentColor" stroke-width="2" stroke-linecap="round"/>
|
|
198
206
|
<line x1="9" y1="8" x2="13" y2="8" stroke="currentColor" stroke-width="2" stroke-linecap="round" opacity="0.75"/>
|
|
199
|
-
<line x1="9" y1="11" x2="11" y2="11" stroke="currentColor" stroke-width="2" stroke-linecap="round" opacity="0.5"/>`,14),anchored_vp:
|
|
207
|
+
<line x1="9" y1="11" x2="11" y2="11" stroke="currentColor" stroke-width="2" stroke-linecap="round" opacity="0.5"/>`,14),anchored_vp:W(`<circle cx="5" cy="5" r="2" stroke="currentColor" stroke-width="1.3"/>
|
|
200
208
|
<line x1="5" y1="7" x2="5" y2="13" stroke="currentColor" stroke-width="1.3" stroke-linecap="round" opacity="0.5"/>
|
|
201
209
|
<line x1="7" y1="7" x2="12" y2="7" stroke="currentColor" stroke-width="2" stroke-linecap="round"/>
|
|
202
210
|
<line x1="7" y1="10" x2="11" y2="10" stroke="currentColor" stroke-width="2" stroke-linecap="round" opacity="0.7"/>
|
|
203
|
-
<line x1="7" y1="13" x2="9" y2="13" stroke="currentColor" stroke-width="2" stroke-linecap="round" opacity="0.45"/>`,14),volume_profile:
|
|
211
|
+
<line x1="7" y1="13" x2="9" y2="13" stroke="currentColor" stroke-width="2" stroke-linecap="round" opacity="0.45"/>`,14),volume_profile:W(`<line x1="3" y1="4" x2="11" y2="4" stroke="currentColor" stroke-width="2" stroke-linecap="round"/>
|
|
204
212
|
<line x1="3" y1="7" x2="14" y2="7" stroke="currentColor" stroke-width="2" stroke-linecap="round" opacity="0.75"/>
|
|
205
213
|
<line x1="3" y1="10" x2="9" y2="10" stroke="currentColor" stroke-width="2" stroke-linecap="round" opacity="0.55"/>
|
|
206
|
-
<line x1="3" y1="13" x2="7" y2="13" stroke="currentColor" stroke-width="2" stroke-linecap="round" opacity="0.35"/>`,14),regression_trend:
|
|
214
|
+
<line x1="3" y1="13" x2="7" y2="13" stroke="currentColor" stroke-width="2" stroke-linecap="round" opacity="0.35"/>`,14),regression_trend:W(`<line x1="2" y1="12" x2="13" y2="4" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
|
|
207
215
|
<line x1="2" y1="9" x2="13" y2="1" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-dasharray="2 1.5" opacity="0.6"/>
|
|
208
|
-
<line x1="2" y1="15" x2="13" y2="7" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-dasharray="2 1.5" opacity="0.6"/>`,14),text:
|
|
209
|
-
<line x1="8" y1="4" x2="8" y2="13" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>`,14),callout:
|
|
210
|
-
<polyline points="9,5 12,8 9,11" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>`,14),flag:
|
|
211
|
-
<path d="M4 3 L12 3 L10 7 L4 7z" stroke="currentColor" stroke-width="1.3" stroke-linejoin="round"/>`,14),price_note:
|
|
216
|
+
<line x1="2" y1="15" x2="13" y2="7" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-dasharray="2 1.5" opacity="0.6"/>`,14),text:W(`<line x1="3" y1="4" x2="13" y2="4" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
|
|
217
|
+
<line x1="8" y1="4" x2="8" y2="13" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>`,14),callout:W(`<path d="M2 3.5C2 2.67 2.67 2 3.5 2h9C13.33 2 14 2.67 14 3.5v5c0 .83-.67 1.5-1.5 1.5H8l-2.5 3V9H3.5C2.67 9 2 8.33 2 7.5V3.5z" stroke="currentColor" stroke-width="1.3" stroke-linejoin="round"/>`,14),price_label:W(`<path d="M2 8 L5 5 H13.5C14 5 14.5 5.5 14.5 6v4c0 .5-.5 1-1 1H5L2 8z" stroke="currentColor" stroke-width="1.3" stroke-linejoin="round"/>`,14),arrow_marker:W(`<line x1="3" y1="8" x2="12" y2="8" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
|
|
218
|
+
<polyline points="9,5 12,8 9,11" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>`,14),flag:W(`<line x1="4" y1="2" x2="4" y2="14" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
|
|
219
|
+
<path d="M4 3 L12 3 L10 7 L4 7z" stroke="currentColor" stroke-width="1.3" stroke-linejoin="round"/>`,14),price_note:W(`<rect x="2.5" y="4" width="11" height="8" rx="1" stroke="currentColor" stroke-width="1.3"/>
|
|
212
220
|
<line x1="5" y1="7" x2="11" y2="7" stroke="currentColor" stroke-width="1.2" stroke-linecap="round"/>
|
|
213
|
-
<line x1="5" y1="9.5" x2="9" y2="9.5" stroke="currentColor" stroke-width="1.2" stroke-linecap="round"/>`,14),anchored_note:
|
|
214
|
-
<line x1="8" y1="7.5" x2="8" y2="13" stroke="currentColor" stroke-width="1.3" stroke-linecap="round" stroke-dasharray="1.5 1.5"/>`,14),arrow_up:
|
|
215
|
-
<polyline points="4,7 8,3 12,7" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>`,14),arrow_down:
|
|
216
|
-
<polyline points="4,9 8,13 12,9" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>`,14),head_shoulders:
|
|
217
|
-
<line x1="1" y1="13" x2="15" y2="13" stroke="currentColor" stroke-width="1" stroke-linecap="round" opacity="0.4"/>`,14),triangle_pattern:
|
|
221
|
+
<line x1="5" y1="9.5" x2="9" y2="9.5" stroke="currentColor" stroke-width="1.2" stroke-linecap="round"/>`,14),anchored_note:W(`<circle cx="8" cy="5" r="2.5" stroke="currentColor" stroke-width="1.3"/>
|
|
222
|
+
<line x1="8" y1="7.5" x2="8" y2="13" stroke="currentColor" stroke-width="1.3" stroke-linecap="round" stroke-dasharray="1.5 1.5"/>`,14),arrow_up:W(`<line x1="8" y1="13" x2="8" y2="3" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
|
|
223
|
+
<polyline points="4,7 8,3 12,7" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>`,14),arrow_down:W(`<line x1="8" y1="3" x2="8" y2="13" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
|
|
224
|
+
<polyline points="4,9 8,13 12,9" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>`,14),head_shoulders:W(`<polyline points="1,13 3.5,10 5.5,12 8,4 10.5,12 12.5,10 15,13" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"/>
|
|
225
|
+
<line x1="1" y1="13" x2="15" y2="13" stroke="currentColor" stroke-width="1" stroke-linecap="round" opacity="0.4"/>`,14),triangle_pattern:W(`<line x1="2" y1="4" x2="14" y2="8" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"/>
|
|
218
226
|
<line x1="2" y1="12" x2="14" y2="8" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" opacity="0.7"/>
|
|
219
|
-
<line x1="2" y1="4" x2="2" y2="12" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"/>`,14),three_drives:
|
|
227
|
+
<line x1="2" y1="4" x2="2" y2="12" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"/>`,14),three_drives:W(`<polyline points="2,12 4,7 6,10 8,5 10,9 12,4 14,9" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"/>`,14),abcd_pattern:W(`<polyline points="3,12 6,4 9,10 12,3" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"/>
|
|
220
228
|
<circle cx="3" cy="12" r="1" fill="currentColor"/>
|
|
221
229
|
<circle cx="6" cy="4" r="1" fill="currentColor"/>
|
|
222
230
|
<circle cx="9" cy="10" r="1" fill="currentColor"/>
|
|
223
|
-
<circle cx="12" cy="3" r="1" fill="currentColor"/>`,14),cypher_pattern:
|
|
224
|
-
<line x1="3" y1="12" x2="13" y2="12" stroke="currentColor" stroke-width="1" stroke-linecap="round" opacity="0.4"/>`,14),bat_pattern:
|
|
225
|
-
<line x1="2" y1="4" x2="14" y2="4" stroke="currentColor" stroke-width="1" stroke-linecap="round" opacity="0.4"/>`,14),elliott_combination:
|
|
226
|
-
<line x1="9.5" y1="4.5" x2="11.5" y2="6.5" stroke="currentColor" stroke-width="1" stroke-linecap="round" opacity="0.5"/>`,14),highlighter:
|
|
227
|
-
<line x1="4" y1="13" x2="12" y2="13" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" opacity="0.6"/>`,14),ghost_feed:
|
|
228
|
-
<line x1="6.5" y1="13.5" x2="9.5" y2="13.5" stroke="currentColor" stroke-width="1.3" stroke-linecap="round"/>`,14),projection:
|
|
231
|
+
<circle cx="12" cy="3" r="1" fill="currentColor"/>`,14),cypher_pattern:W(`<polyline points="2,12 5,5 8,9 11,3 14,8" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"/>`,14),butterfly_pattern:W(`<polyline points="3,12 6,5 8,10 10,5 13,12" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"/>
|
|
232
|
+
<line x1="3" y1="12" x2="13" y2="12" stroke="currentColor" stroke-width="1" stroke-linecap="round" opacity="0.4"/>`,14),bat_pattern:W(`<polyline points="3,11 5.5,5 8,9 10.5,4 13,9" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"/>`,14),gartley_pattern:W(`<polyline points="3,12 5.5,4 8,9 10.5,3 13,8" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"/>`,14),crab_pattern:W(`<polyline points="2,11 5,5 7,9 10,3 14,11" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"/>`,14),shark_pattern:W(`<polyline points="2,12 5,6 8,11 11,4 14,10" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"/>`,14),elliott_impulse:W(`<polyline points="2,12 4,5 6,10 8,3 10,8 12,4 14,8" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"/>`,14),elliott_corrective:W(`<polyline points="2,5 5,12 8,7 11,12 14,5" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"/>`,14),elliott_triangle:W(`<polyline points="2,4 6,12 8,7 10,12 14,4" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"/>
|
|
233
|
+
<line x1="2" y1="4" x2="14" y2="4" stroke="currentColor" stroke-width="1" stroke-linecap="round" opacity="0.4"/>`,14),elliott_combination:W(`<polyline points="2,12 4,5 6,10 8,3 10,9 13,4" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"/>`,14),elliott_wxy:W(`<polyline points="2,5 5,12 8,6 11,13 14,7" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"/>`,14),brush:W(`<path d="M11.5 2.5l2 2-7.5 7.5-3 1 1-3 7.5-7.5z" stroke="currentColor" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round"/>
|
|
234
|
+
<line x1="9.5" y1="4.5" x2="11.5" y2="6.5" stroke="currentColor" stroke-width="1" stroke-linecap="round" opacity="0.5"/>`,14),highlighter:W(`<path d="M10 3l3 3-6 6H4v-3l6-6z" stroke="currentColor" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round"/>
|
|
235
|
+
<line x1="4" y1="13" x2="12" y2="13" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" opacity="0.6"/>`,14),ghost_feed:W(`<path d="M5 6a3 3 0 0 1 6 0v5l1.5 2h-9L5 11V6z" stroke="currentColor" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round"/>
|
|
236
|
+
<line x1="6.5" y1="13.5" x2="9.5" y2="13.5" stroke="currentColor" stroke-width="1.3" stroke-linecap="round"/>`,14),projection:W(`<line x1="2" y1="11" x2="8" y2="5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
|
|
229
237
|
<line x1="8" y1="5" x2="13.5" y2="5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-dasharray="2 1.5"/>
|
|
230
|
-
<polyline points="10.5,2.5 13.5,5 10.5,7.5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>`,14),sine_line:
|
|
238
|
+
<polyline points="10.5,2.5 13.5,5 10.5,7.5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>`,14),sine_line:W(`<path d="M1 8 C3 4,5 4,7 8 C9 12,11 12,13 8 C14 6,15 6,15 7" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" fill="none"/>`,14),cyclic_lines:W(`<line x1="4" y1="3" x2="4" y2="13" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-dasharray="1.5 1.5"/>
|
|
231
239
|
<line x1="8" y1="3" x2="8" y2="13" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-dasharray="1.5 1.5"/>
|
|
232
|
-
<line x1="12" y1="3" x2="12" y2="13" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-dasharray="1.5 1.5"/>`,14),time_cycles:
|
|
233
|
-
<ellipse cx="11" cy="8" rx="3" ry="5" stroke="currentColor" stroke-width="1.3" opacity="0.6"/>`,14),fib_projection:
|
|
240
|
+
<line x1="12" y1="3" x2="12" y2="13" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-dasharray="1.5 1.5"/>`,14),time_cycles:W(`<ellipse cx="5" cy="8" rx="3" ry="5" stroke="currentColor" stroke-width="1.3" opacity="0.9"/>
|
|
241
|
+
<ellipse cx="11" cy="8" rx="3" ry="5" stroke="currentColor" stroke-width="1.3" opacity="0.6"/>`,14),fib_projection:W(`<line x1="3" y1="3" x2="3" y2="13" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
|
|
234
242
|
<line x1="3" y1="4" x2="13" y2="4" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"/>
|
|
235
243
|
<line x1="3" y1="8" x2="13" y2="8" stroke="currentColor" stroke-width="1.2" stroke-linecap="round" opacity="0.7"/>
|
|
236
|
-
<line x1="3" y1="12" x2="13" y2="12" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-dasharray="2 1.5" opacity="0.5"/>`,14),price_projection:
|
|
244
|
+
<line x1="3" y1="12" x2="13" y2="12" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-dasharray="2 1.5" opacity="0.5"/>`,14),price_projection:W(`<line x1="2" y1="11" x2="8" y2="5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
|
|
237
245
|
<line x1="8" y1="5" x2="13.5" y2="5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-dasharray="2 1.5"/>
|
|
238
|
-
<polyline points="10.5,2.5 13.5,5 10.5,7.5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>`,14)},
|
|
239
|
-
<line x1="4" y1="4" x2="12.5" y2="12.5"/>`,15),
|
|
246
|
+
<polyline points="10.5,2.5 13.5,5 10.5,7.5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>`,14)},Sn=`<svg viewBox="0 0 16 16" width="14" height="14" fill="none" xmlns="http://www.w3.org/2000/svg"><polyline points="1.5,12.5 5,9 7,11 14,4" stroke="#26a69a" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/><polyline points="10,4 14,4 14,8" stroke="#26a69a" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/><polyline points="1.5,3.5 5,7 7,5 14,12" stroke="#ef5350" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/><polyline points="10,12 14,12 14,8" stroke="#ef5350" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>`,Cn=`<svg viewBox="0 0 16 16" width="14" height="14" fill="none" xmlns="http://www.w3.org/2000/svg"><polyline points="1.5,12.5 5,9 7,11 14,4" stroke="#26a69a" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" opacity="0.3"/><polyline points="10,4 14,4 14,8" stroke="#26a69a" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" opacity="0.3"/><polyline points="1.5,3.5 5,7 7,5 14,12" stroke="#ef5350" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" opacity="0.3"/><polyline points="10,12 14,12 14,8" stroke="#ef5350" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" opacity="0.3"/><line x1="3" y1="3" x2="13" y2="13" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/></svg>`,wn=(e,t=16)=>`<svg viewBox="0 0 16 16" width="${t}" height="${t}" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M1 4L6 8L1 12Z" fill="${e}"/><path d="M6 4L11 8L6 12Z" fill="${e}"/><line x1="13.5" y1="3.5" x2="13.5" y2="12.5" stroke="${e}" stroke-width="2" stroke-linecap="round"/></svg>`,Tn=(e,t=16)=>`<svg viewBox="0 0 16 16" width="${t}" height="${t}" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M8 2A6 6 0 1 1 2 8" stroke="${e}" stroke-width="1.6" stroke-linecap="round"/><path d="M4 10L2 8L1 10" stroke="${e}" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/></svg>`,En={appearance:`<svg viewBox="0 0 16 16" width="14" height="14" fill="none" xmlns="http://www.w3.org/2000/svg"><circle cx="8" cy="8" r="3" stroke="currentColor" stroke-width="1.4"/><path d="M8 1v1.5M8 13.5V15M1 8h1.5M13.5 8H15M3.05 3.05l1.06 1.06M11.89 11.89l1.06 1.06M3.05 12.95l1.06-1.06M11.89 4.11l1.06-1.06" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"/></svg>`,tools:`<svg viewBox="0 0 16 16" width="14" height="14" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M2 14l4-4M10 2l4 4-7 7-4-4z" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"/><path d="M13 3l1 1" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"/></svg>`,trading:`<svg viewBox="0 0 16 16" width="14" height="14" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M1 12l4-5 3 2 4-6" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"/><path d="M11 3h4v4" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"/></svg>`},Dn=`<svg viewBox="0 0 12 12" width="12" height="12" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M1 1l10 10M11 1L1 11" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/></svg>`,On=`<svg viewBox="0 0 10 10" width="10" height="10" fill="none" xmlns="http://www.w3.org/2000/svg"><circle cx="5" cy="5" r="4" fill="currentColor"/></svg>`,kn=`<svg viewBox="0 0 12 12" width="10" height="10" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M1.5 6l3.5 3.5 5.5-6" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/></svg>`,An=`<svg viewBox="0 0 16 16" width="14" height="14" fill="none" xmlns="http://www.w3.org/2000/svg"><circle cx="8" cy="8" r="6.5" stroke="currentColor" stroke-width="1.4"/><line x1="8" y1="4.5" x2="8" y2="11.5" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"/><line x1="4.5" y1="8" x2="11.5" y2="8" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"/></svg>`,jn=`<svg viewBox="0 0 10 10" width="10" height="10" fill="none" xmlns="http://www.w3.org/2000/svg"><polyline points="2,7 5,3 8,7" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>`,Mn=`<svg viewBox="0 0 10 10" width="10" height="10" fill="none" xmlns="http://www.w3.org/2000/svg"><polyline points="2,3 5,7 8,3" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>`,Nn=W(`<circle cx="4" cy="8" r="1.3" fill="currentColor"/><circle cx="8" cy="8" r="1.3" fill="currentColor"/><circle cx="12" cy="8" r="1.3" fill="currentColor"/>`,14),Pn=on(`<path d="M4 4l6.5 18 2.5-7.5L20.5 12z"/>
|
|
247
|
+
<line x1="4" y1="4" x2="12.5" y2="12.5"/>`,15),Fn=`<svg viewBox="0 0 16 16" width="14" height="14" fill="none" xmlns="http://www.w3.org/2000/svg"><rect x="1.5" y="1.5" width="13" height="13" rx="1.5" stroke="currentColor" stroke-width="1.3"/><line x1="8" y1="1.5" x2="8" y2="14.5" stroke="currentColor" stroke-width="1.3"/><line x1="1.5" y1="7" x2="14.5" y2="7" stroke="currentColor" stroke-width="1.3"/></svg>`,In=`<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><path d="M14 4.1 12 6"/><path d="m5.1 8-2.9-.8"/><path d="m6 12-1.9 2"/><path d="M7.2 2.2 8 5.1"/><path d="M9.037 9.69a.498.498 0 0 1 .653-.653l11 4.5a.5.5 0 0 1-.074.949l-4.349 1.041a1 1 0 0 0-.74.739l-1.04 4.35a.5.5 0 0 1-.95.074z"/></svg>`,Ln=`<svg viewBox="0 0 16 16" width="14" height="14" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M1.5 5.5C1.5 4.95 1.95 4.5 2.5 4.5H4L5 2.5H11L12 4.5H13.5C14.05 4.5 14.5 4.95 14.5 5.5V13C14.5 13.55 14.05 14 13.5 14H2.5C1.95 14 1.5 13.55 1.5 13V5.5Z" stroke="currentColor" stroke-width="1.3" stroke-linejoin="round"/><circle cx="8" cy="9" r="2.2" stroke="currentColor" stroke-width="1.3"/></svg>`,Rn=`<svg viewBox="0 0 24 24" width="12" height="12" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"><circle cx="12" cy="12" r="10"/><line x1="22" x2="18" y1="12" y2="12"/><line x1="6" x2="2" y1="12" y2="12"/><line x1="12" x2="12" y1="6" y2="2"/><line x1="12" x2="12" y1="22" y2="18"/></svg>`,zn=`<svg viewBox="0 0 24 24" width="12" height="12" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"><path d="M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1"/><path d="M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4"/></svg>`;function G(e,t){let n=e.trim(),r=/^#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.exec(n);if(r){let e=r[1];return e.length===3&&(e=e.split(``).map(e=>e+e).join(``)),`rgba(${parseInt(e.slice(0,2),16)}, ${parseInt(e.slice(2,4),16)}, ${parseInt(e.slice(4,6),16)}, ${t})`}let i=/^rgba?\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)/i.exec(n);return i?`rgba(${i[1]}, ${i[2]}, ${i[3]}, ${t})`:`color-mix(in srgb, ${n} ${Math.round(Math.min(1,Math.max(0,t))*100)}%, transparent)`}var Bn=!1;function Vn(){if(Bn)return;Bn=!0;let e=navigator.virtualKeyboard;if(e)try{e.overlaysContent=!0}catch(e){}}function Hn(e,t){let n=window.visualViewport;if(!n)return()=>{};let r=()=>{if(e.style.display===`none`||!e.isConnected)return;let r=t(),i=e.getBoundingClientRect().height,a=n.offsetTop+n.height,o=r+i<=a-8;e.style.top=o?`${r}px`:`${Math.max(8,a-i-8)}px`};return n.addEventListener(`resize`,r),n.addEventListener(`scroll`,r),()=>{n.removeEventListener(`resize`,r),n.removeEventListener(`scroll`,r)}}function Un(e){let t=window.visualViewport;if(!t)return()=>{};let n=()=>{if(!e.isConnected||e.offsetParent===null)return;e.style.transform=``;let n=e.getBoundingClientRect(),r=t.offsetTop+t.height,i=n.bottom-(r-8);i>0&&(e.style.transform=`translateY(${-i}px)`)};return t.addEventListener(`resize`,n),t.addEventListener(`scroll`,n),()=>{t.removeEventListener(`resize`,n),t.removeEventListener(`scroll`,n)}}var Wn=[`1D`,`5D`,`1M`,`3M`,`6M`,`1Y`,`5Y`,`All`],Gn=new Set([`VOL`,`VWAP`,`OBV`,`A/D`,`MFI`,`CMF`]);function Kn(){if(document.getElementById(`finchart-flyout-scrollbar`))return;let e=document.createElement(`style`);e.id=`finchart-flyout-scrollbar`,e.textContent=`
|
|
240
248
|
.finchart-flyout::-webkit-scrollbar { width: 4px; }
|
|
241
249
|
.finchart-flyout::-webkit-scrollbar-track { background: transparent; }
|
|
242
250
|
.finchart-flyout::-webkit-scrollbar-thumb { background: rgba(120,130,150,0.35); border-radius: 4px; }
|
|
243
251
|
.finchart-flyout::-webkit-scrollbar-thumb:hover { background: rgba(120,130,150,0.6); }
|
|
244
252
|
.finchart-flyout-row:hover { background: var(--finchart-row-hover) !important; }
|
|
245
|
-
`,document.head.appendChild(e)}var Pn=class{constructor(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,v,y=_,b=E.topBar,x=null,S=!1,C=!1,w=null,T=null,D=null){this.onSeriesChange=e,this.onTimeframeChange=t,this.onAddIndicator=n,this.onDurationChange=r,this.onSettingsClick=i,this.onFullscreenToggle=a,this.onDrawingToolsToggle=o,this.onTfcToggle=f,this.onDropdownChange=x,this.onLayoutBtnClick=w,this.onSnapshotBtnClick=T,this.onOneClickTradeToggle=D,this.fullscreenBtn=null,this.settingsBtn=null,this.isFullscreen=!1,this.durationBtns=new Map,this.isMobileLayout=!1,this.drawingBtn=null,this.tfcBtn=null,this.tfcActive=!0,this.layoutBtn=null,this.layoutIconEl=null,this.snapshotBtn=null,this.oneClickBtn=null,this.oneClickActive=!1,this.openDropdown=null,this.disposeFlyoutKbd=()=>{},this.indicatorOptions=[],this.activeIndicators=new Set,this.volHasData=!0,this.theme=v,this.cfg=y,this.labels=b,this.tfcActive=d,this.currentSeries=p,this.currentTf=m,this.activeDuration=h,this.durationMap=g,Nn(),this.el=document.createElement(`div`),this.applyBarStyles(v),this.flyout=document.createElement(`div`),this.flyout.classList.add(`finchart-flyout`),this.applyFlyoutStyles(),document.body.appendChild(this.flyout),this.disposeFlyoutKbd=An(this.flyout),this.leftGroup=document.createElement(`div`),Object.assign(this.leftGroup.style,{display:`flex`,alignItems:`center`,gap:`4px`,flex:`1`,minWidth:`0`,overflow:`hidden`}),s&&(this.drawingBtn=this.makeDrawingBtn(v),this.leftGroup.appendChild(this.drawingBtn)),this.seriesBtn=this.makeSeriesBtn(p,v),this.seriesBtn.addEventListener(`click`,e=>{e.stopPropagation(),this.toggleDropdown(`series`,this.seriesBtn)}),this.addBtnHover(this.seriesBtn),this.tfBtn=this.makeDropBtn(m,v,!1),this.tfBtn.addEventListener(`click`,e=>{e.stopPropagation(),this.toggleDropdown(`timeframe`,this.tfBtn)}),this.addBtnHover(this.tfBtn),this.indBtn=this.makeDropBtn(this.labels.indicatorsBtn,v,!1),this.indBtn.addEventListener(`click`,e=>{e.stopPropagation(),this.toggleDropdown(`indicators`,this.indBtn)}),this.addBtnHover(this.indBtn),this.leftGroup.append(this.seriesBtn,this.tfBtn,this.indBtn),this.rightGroup=document.createElement(`div`),Object.assign(this.rightGroup.style,{display:`flex`,alignItems:`center`,gap:`2px`,flexShrink:`0`}),this.durationDropBtn=this.makeDropBtn(h==null?jn[0]:h,v,!1),this.durationDropBtn.style.display=`none`,this.durationSep=document.createElement(`div`),this.durationSep.style.display=`none`,S&&(this.layoutBtn=document.createElement(`button`),this.layoutBtn.title=`Chart Layout`,this.layoutBtn.dataset.layoutToggle=`true`,this.layoutIconEl=document.createElement(`span`),this.layoutIconEl.style.display=`flex`,this.layoutIconEl.style.alignItems=`center`,this.layoutIconEl.style.flexShrink=`0`,this.layoutIconEl.innerHTML=wn,this.layoutBtn.appendChild(this.layoutIconEl),this.applyIconBtnStyles(this.layoutBtn,v,!1),this.layoutBtn.addEventListener(`click`,e=>{var t;e.stopPropagation(),(t=this.onLayoutBtnClick)==null||t.call(this)}),this.addBtnHover(this.layoutBtn),this.rightGroup.appendChild(this.layoutBtn)),this.onOneClickTradeToggle&&(this.oneClickBtn=document.createElement(`button`),this.oneClickBtn.title=`1-Click Trade (T)`,this.oneClickBtn.dataset.testid=`chart-toggle-floating`,this.oneClickBtn.innerHTML=Tn,this.applyIconBtnStyles(this.oneClickBtn,v,!1),this.oneClickBtn.addEventListener(`click`,e=>{var t;e.stopPropagation(),this.oneClickActive=!this.oneClickActive,this.applyIconBtnStyles(this.oneClickBtn,this.theme,this.oneClickActive),(t=this.onOneClickTradeToggle)==null||t.call(this,this.oneClickActive)}),this.addBtnHover(this.oneClickBtn),this.rightGroup.appendChild(this.oneClickBtn)),C&&(this.snapshotBtn=document.createElement(`button`),this.snapshotBtn.title=`Snapshot`,this.snapshotBtn.dataset.snapshotToggle=`true`,this.snapshotBtn.innerHTML=En,this.applyIconBtnStyles(this.snapshotBtn,v,!1),this.snapshotBtn.addEventListener(`click`,e=>{var t;e.stopPropagation(),(t=this.onSnapshotBtnClick)==null||t.call(this)}),this.addBtnHover(this.snapshotBtn),this.rightGroup.appendChild(this.snapshotBtn)),l&&(this.fullscreenBtn=document.createElement(`button`),this.fullscreenBtn.title=this.labels.toggleFullscreenTitle,this.fullscreenBtn.innerHTML=$t,this.applyIconBtnStyles(this.fullscreenBtn,v,!1),this.fullscreenBtn.addEventListener(`click`,e=>{e.stopPropagation(),this.onFullscreenToggle()}),this.addBtnHover(this.fullscreenBtn),this.rightGroup.appendChild(this.fullscreenBtn)),c&&(this.settingsBtn=document.createElement(`button`),this.settingsBtn.title=this.labels.settingsTitle,this.settingsBtn.innerHTML=Yt,this.applyIconBtnStyles(this.settingsBtn,v,!1),this.settingsBtn.addEventListener(`click`,e=>{e.stopPropagation(),this.onSettingsClick()}),this.addBtnHover(this.settingsBtn),this.rightGroup.appendChild(this.settingsBtn)),u&&(this.tfcBtn=document.createElement(`button`),this.tfcBtn.title=this.labels.tfcToggleTitle,this.tfcBtn.innerHTML=this.tfcActive?dn:fn,this.applyIconBtnStyles(this.tfcBtn,v,this.tfcActive),this.tfcBtn.addEventListener(`click`,e=>{var t;e.stopPropagation(),this.tfcActive=!this.tfcActive,this.tfcBtn.innerHTML=this.tfcActive?dn:fn,this.applyIconBtnStyles(this.tfcBtn,this.theme,this.tfcActive),(t=this.onTfcToggle)==null||t.call(this,this.tfcActive)}),this.addBtnHover(this.tfcBtn),this.rightGroup.appendChild(this.tfcBtn)),this.el.append(this.leftGroup,this.rightGroup),this.docClickHandler=e=>{!this.el.contains(e.target)&&!this.flyout.contains(e.target)&&this.closeDropdown()},document.addEventListener(`click`,this.docClickHandler,!0)}destroy(){this.disposeFlyoutKbd(),this.flyout.remove(),document.removeEventListener(`click`,this.docClickHandler,!0)}reparentFlyout(e){this.flyout.parentElement!==e&&e.appendChild(this.flyout)}setFullscreen(e){this.isFullscreen=e,this.fullscreenBtn&&(this.fullscreenBtn.innerHTML=e?en:$t,this.fullscreenBtn.title=e?this.labels.exitFullscreenTitle:this.labels.toggleFullscreenTitle,this.applyIconBtnStyles(this.fullscreenBtn,this.theme,e),this.isMobileLayout&&this.resizeSvg(this.fullscreenBtn,this.getSvgSize(this.fullscreenBtn)+2))}setDrawingsBtnActive(e){this.drawingBtn&&this.applyIconBtnStyles(this.drawingBtn,this.theme,e)}setTfcActive(e){this.tfcBtn&&(this.tfcActive=e,this.tfcBtn.innerHTML=e?dn:fn,this.applyIconBtnStyles(this.tfcBtn,this.theme,e),this.isMobileLayout&&this.resizeSvg(this.tfcBtn,this.getSvgSize(this.tfcBtn)+2))}setTheme(e){this.theme=e,this.closeDropdown(),this.applyBarStyles(e),this.applyFlyoutStyles(),this.drawingBtn&&this.applyIconBtnStyles(this.drawingBtn,e,!1),this.fullscreenBtn&&this.applyIconBtnStyles(this.fullscreenBtn,e,this.isFullscreen),this.settingsBtn&&this.applyIconBtnStyles(this.settingsBtn,e,!1),this.tfcBtn&&this.applyIconBtnStyles(this.tfcBtn,e,this.tfcActive),this.layoutBtn&&this.applyIconBtnStyles(this.layoutBtn,e,!1),this.snapshotBtn&&this.applyIconBtnStyles(this.snapshotBtn,e,!1),this.layoutIconEl&&(this.layoutIconEl.style.color=e.ui.accent),this.applySeriesBtnStyles(this.seriesBtn,e,!1),this.applyDropBtnStyles(this.tfBtn,e,!1),this.applyDropBtnStyles(this.indBtn,e,!1);for(let[t,n]of this.durationBtns)this.applyDurationBtnStyles(n,e,t===this.activeDuration);this.durationSep.style.background=e.axisBorder,this.applyDropBtnStyles(this.durationDropBtn,e,!1)}setSeries(e){this.currentSeries=e,this.updateSeriesBtnContent(this.seriesBtn,e)}setTimeframe(e){this.currentTf=e,this.tfBtn.textContent=e}setActiveDuration(e){if(this.activeDuration!==(e==null?null:e)){if(this.activeDuration){let e=this.durationBtns.get(this.activeDuration);e&&this.applyDurationBtnStyles(e,this.theme,!1)}if(this.activeDuration=e==null?null:e,e){let t=this.durationBtns.get(e);t&&this.applyDurationBtnStyles(t,this.theme,!0),this.durationDropBtn.textContent=e}}}setMobileLayout(e){if(this.isMobileLayout===e)return;this.isMobileLayout=e;let t=e?`none`:``;for(let e of this.durationBtns.values())e.style.display=t;this.durationSep.style.display=t,this.durationDropBtn.style.display=e?``:`none`;let n=e?this.cfg.mobileIconBtnSize:this.cfg.iconBtnSize;for(let e of[this.fullscreenBtn,this.settingsBtn,this.drawingBtn,this.tfcBtn,this.layoutBtn,this.snapshotBtn])e&&(e.style.width=n,e.style.height=n);let r=e?2:-2;if(this.fullscreenBtn&&this.resizeSvg(this.fullscreenBtn,this.getSvgSize(this.fullscreenBtn)+r),this.settingsBtn&&this.resizeSvg(this.settingsBtn,this.getSvgSize(this.settingsBtn)+r),this.tfcBtn&&this.resizeSvg(this.tfcBtn,this.getSvgSize(this.tfcBtn)+r),this.drawingBtn){let t=parseInt(e?this.cfg.mobileDrawBtnIconSize:this.cfg.drawBtnIconFontSize,10);this.resizeSvg(this.drawingBtn,t)}}setIndicatorOptions(e){this.indicatorOptions=e}setLayoutPresetIcon(e,t=!0){!this.layoutBtn||!this.layoutIconEl||(this.layoutIconEl.innerHTML=e,this.layoutIconEl.style.color=this.theme.ui.accent)}getLayoutBtnEl(){return this.layoutBtn}getSnapshotBtnEl(){return this.snapshotBtn}setIndicatorOptionActive(e,t,n){t?this.activeIndicators.add(e):this.activeIndicators.delete(e),this.updateIndBtnLabel()}setVolumeControl(e,t){this.volHasData=t,t&&e?this.activeIndicators.add(`VOL`):this.activeIndicators.delete(`VOL`),this.updateIndBtnLabel()}makeDrawingBtn(e){let t=document.createElement(`button`);return t.title=`Drawing Tools`,t.innerHTML=Zt,this.applyIconBtnStyles(t,e,!1),t.addEventListener(`click`,e=>{var t;e.stopPropagation(),(t=this.onDrawingToolsToggle)==null||t.call(this)}),this.addBtnHover(t),t}makeSeriesBtn(e,t){let n=document.createElement(`button`);return this.applySeriesBtnStyles(n,t,!1),this.updateSeriesBtnContent(n,e),n}updateSeriesBtnContent(e,t){var n;e.title=(n=this.labels.series[t])==null?t:n,e.innerHTML=nn[t]}applySeriesBtnStyles(e,t,n){e.dataset.active=String(n),Object.assign(e.style,{background:n?t.ui.accentBg:`transparent`,color:n?t.ui.accentText:t.topBar.btnColor,border:`1px solid ${n?t.ui.accent:t.axisBorder}`,borderRadius:`5px`,padding:`3px 7px`,cursor:`pointer`,outline:`none`,display:`flex`,alignItems:`center`,gap:`4px`,flexShrink:`0`,height:`24px`,transition:`border-color 0.12s, background 0.12s`})}applyFlyoutStyles(){Object.assign(this.flyout.style,{position:`fixed`,zIndex:`9999`,display:`none`,background:this.theme.tooltip.background,border:`1px solid ${this.theme.axisBorder}`,borderRadius:`8px`,padding:`4px 0`,minWidth:`168px`,maxHeight:`340px`,overflowY:`auto`,overflowX:`hidden`,boxShadow:`0 8px 24px rgba(0,0,0,0.55), 0 2px 8px rgba(0,0,0,0.3)`,fontFamily:this.cfg.flyoutRowFontFamily,fontSize:this.cfg.flyoutRowFontSize,scrollbarWidth:`thin`,scrollbarColor:`rgba(120,130,150,0.35) transparent`})}toggleDropdown(e,t){var n;if(this.openDropdown===e){this.closeDropdown();return}let r=this.openDropdown!==null;this.openDropdown=e,this.applySeriesBtnStyles(this.seriesBtn,this.theme,e===`series`),this.applyDropBtnStyles(this.tfBtn,this.theme,e===`timeframe`),this.applyDropBtnStyles(this.indBtn,this.theme,e===`indicators`),this.applyDropBtnStyles(this.durationDropBtn,this.theme,e===`duration`),this.buildDropdownContent(e);let i=t.getBoundingClientRect();Object.assign(this.flyout.style,{display:`block`,left:`${i.left}px`,top:`${i.bottom+6}px`}),requestAnimationFrame(()=>{let e=this.flyout.getBoundingClientRect();e.right>window.innerWidth-8&&(this.flyout.style.left=`${window.innerWidth-e.width-8}px`),e.bottom>window.innerHeight-8&&(this.flyout.style.top=`${i.top-e.height-6}px`)}),r||(n=this.onDropdownChange)==null||n.call(this)}buildDropdownContent(e){if(this.flyout.innerHTML=``,this.flyout.style.minWidth=e===`series`?`152px`:e===`timeframe`?`160px`:e===`duration`?`120px`:`180px`,e===`series`){let e=[{value:`candlestick`,label:this.labels.series.candlestick},{value:`hollow`,label:this.labels.series.hollow},{value:`ohlc`,label:this.labels.series.ohlc},{value:`line`,label:this.labels.series.line},{value:`area`,label:this.labels.series.area},{value:`heikinashi`,label:this.labels.series.heikinashi},{value:`volumecandles`,label:this.labels.series.volumecandles},{value:`linemarkers`,label:this.labels.series.linemarkers},{value:`step`,label:this.labels.series.step},{value:`hlcarea`,label:this.labels.series.hlcarea},{value:`baseline`,label:this.labels.series.baseline},{value:`columns`,label:this.labels.series.columns},{value:`highlow`,label:this.labels.series.highlow}];for(let t of e){let e=this.makeRow(t.label,t.value===this.currentSeries,!1,nn[t.value]);e.addEventListener(`click`,()=>{this.currentSeries=t.value,this.updateSeriesBtnContent(this.seriesBtn,t.value),this.onSeriesChange(t.value),this.closeDropdown()}),this.flyout.appendChild(e)}}else if(e===`timeframe`){let e=[`1m`,`5m`,`15m`,`30m`,`1h`,`2h`,`4h`,`8h`],r=[`1D`,`1W`,`1M`];this.flyout.appendChild(this.makeCategoryHeader(`Intraday`));for(let n of e){var t;let e=(t=this.labels.timeframes[n])==null?n:t,r=this.makeRow(e,n===this.currentTf,!1);r.addEventListener(`click`,()=>{this.currentTf=n,this.tfBtn.textContent=e,this.onTimeframeChange(n),this.closeDropdown()}),this.flyout.appendChild(r)}this.flyout.appendChild(this.makeCategoryHeader(`Daily +`));for(let e of r){var n;let t=(n=this.labels.timeframes[e])==null?e:n,r=this.makeRow(t,e===this.currentTf,!1);r.addEventListener(`click`,()=>{this.currentTf=e,this.tfBtn.textContent=t,this.onTimeframeChange(e),this.closeDropdown()}),this.flyout.appendChild(r)}}else if(e===`duration`)for(let e of jn){let t=this.makeRow(e,e===this.activeDuration,!1);t.addEventListener(`click`,()=>{this.setActiveDuration(e),this.onDurationChange(e,this.durationMap[e]),this.closeDropdown()}),this.flyout.appendChild(t)}else{let e=document.createElement(`div`);Object.assign(e.style,{position:`sticky`,top:`0`,zIndex:`1`,padding:`6px 8px`,background:this.theme.tooltip.background,borderBottom:`1px solid ${this.theme.axisBorder}`});let t=document.createElement(`input`);t.type=`text`,t.placeholder=`Search indicators…`,Object.assign(t.style,{width:`100%`,boxSizing:`border-box`,padding:`5px 8px`,background:this.theme.background,color:this.theme.tooltip.text,border:`1px solid ${this.theme.axisBorder}`,borderRadius:`4px`,fontSize:`16px`,outline:`none`}),e.appendChild(t),this.flyout.appendChild(e);let n=document.createElement(`div`);this.flyout.appendChild(n);let i=new Map;for(let e of this.indicatorOptions){var r;let t=(r=e.category)==null?``:r;i.has(t)||i.set(t,[]),i.get(t).push(e)}let a=e=>{n.innerHTML=``;let r=e.trim().toLowerCase();if(r)for(let e of this.indicatorOptions){if(!e.label.toLowerCase().includes(r)&&!e.value.toLowerCase().includes(r))continue;let i=this.activeIndicators.has(e.value),o=Mn.has(e.value)&&!this.volHasData,s=this.makeRow(e.label,i,o);o||s.addEventListener(`click`,()=>{this.onAddIndicator(e.value),a(t.value)}),n.appendChild(s)}else for(let[e,r]of i){e&&n.appendChild(this.makeCategoryHeader(e));for(let e of r){let r=this.activeIndicators.has(e.value),i=Mn.has(e.value)&&!this.volHasData,o=this.makeRow(e.label,r,i);i||o.addEventListener(`click`,()=>{this.onAddIndicator(e.value),a(t.value)}),n.appendChild(o)}}};a(``),t.addEventListener(`input`,()=>a(t.value)),requestAnimationFrame(()=>t.focus({preventScroll:!0}))}}makeCategoryHeader(e){let t=document.createElement(`div`);return Object.assign(t.style,{padding:`6px 12px 4px`,fontSize:this.cfg.flyoutCategoryFontSize,fontWeight:`600`,letterSpacing:this.cfg.flyoutCategoryLetterSpacing,color:this.theme.topBar.flyoutCategoryColor,textTransform:`uppercase`,opacity:`0.55`,marginTop:`2px`}),t.textContent=e,t}makeRow(e,t,n,r){let i=document.createElement(`button`),a=this.theme.ui.accentBg,o=this.theme.ui.accentBg;if(Object.assign(i.style,{width:`100%`,padding:`7px 12px`,background:t?o:`transparent`,border:`none`,borderLeft:t?`2px solid ${this.theme.ui.accent}`:`2px solid transparent`,color:n?this.theme.ui.disabledText:t?this.theme.ui.accentText:this.theme.topBar.flyoutRowColor,fontSize:this.cfg.flyoutRowFontSize,fontFamily:this.cfg.flyoutRowFontFamily,textAlign:`left`,cursor:n?`not-allowed`:`pointer`,display:`flex`,alignItems:`center`,gap:`8px`,boxSizing:`border-box`,opacity:n?`0.45`:`1`,transition:`background 0.1s`}),!n&&!t&&(i.addEventListener(`mouseenter`,()=>{i.style.background=a}),i.addEventListener(`mouseleave`,()=>{i.style.background=`transparent`})),r){let e=document.createElement(`span`);Object.assign(e.style,{display:`flex`,alignItems:`center`,flexShrink:`0`,opacity:t?`1`:`0.7`}),e.innerHTML=r;let n=e.querySelector(`svg`);n&&(n.setAttribute(`width`,`13`),n.setAttribute(`height`,`13`)),i.appendChild(e)}let s=document.createElement(`span`);if(s.style.flex=`1`,s.textContent=e,i.appendChild(s),t){let e=document.createElement(`span`);Object.assign(e.style,{color:this.theme.ui.accent,fontSize:this.cfg.flyoutCheckFontSize,flexShrink:`0`}),e.innerHTML=vn,i.appendChild(e)}return i}closeDropdown(){var e;let t=this.openDropdown!==null;this.flyout.style.display=`none`,this.openDropdown=null,this.applySeriesBtnStyles(this.seriesBtn,this.theme,!1),this.applyDropBtnStyles(this.tfBtn,this.theme,!1),this.applyDropBtnStyles(this.indBtn,this.theme,!1),this.applyDropBtnStyles(this.durationDropBtn,this.theme,!1),t&&((e=this.onDropdownChange)==null||e.call(this))}get hasOpenDropdown(){return this.openDropdown!==null}updateIndBtnLabel(){let e=this.activeIndicators.size;this.indBtn.textContent=e>0?this.labels.indicatorsBtnActive.replace(`{count}`,String(e)):this.labels.indicatorsBtn}addBtnHover(e){e.addEventListener(`mouseenter`,()=>{e.dataset.active!==`true`&&(e.style.background=this.theme.ui.accentBg)}),e.addEventListener(`mouseleave`,()=>{e.dataset.active!==`true`&&(e.style.background=`transparent`)})}applyBarStyles(e){Object.assign(this.el.style,{display:`flex`,alignItems:`center`,gap:`8px`,height:this.cfg.height,padding:`0 10px`,background:e.background,borderBottom:`1px solid ${e.axisBorder}`,boxSizing:`border-box`,flexShrink:`0`})}makeDropBtn(e,t,n){let r=document.createElement(`button`);return r.textContent=e,this.applyDropBtnStyles(r,t,n),r}applyDropBtnStyles(e,t,n){e.dataset.active=String(n),Object.assign(e.style,{background:n?t.ui.accentBg:`transparent`,color:n?t.ui.accentText:t.topBar.btnColor,border:`1px solid ${n?t.ui.accent:t.axisBorder}`,borderRadius:`5px`,padding:`3px 8px`,height:`24px`,fontSize:this.cfg.dropBtnFontSize,fontFamily:this.cfg.dropBtnFontFamily,cursor:`pointer`,outline:`none`,whiteSpace:`nowrap`,transition:`border-color 0.12s, background 0.12s`})}applyDurationBtnStyles(e,t,n){e.dataset.active=String(n),Object.assign(e.style,{background:n?t.bottomBar.activeBtnBg:`transparent`,color:n?t.bottomBar.activeBtnText:t.bottomBar.btnColor,border:`1px solid ${n?t.bottomBar.activeBtnBorder:`transparent`}`,borderRadius:`4px`,padding:`2px 7px`,fontSize:this.cfg.dropBtnFontSize,fontFamily:this.cfg.dropBtnFontFamily,cursor:`pointer`,outline:`none`,transition:`background 0.15s, color 0.15s`,whiteSpace:`nowrap`})}applyIconBtnStyles(e,t,n){e.dataset.active=String(n);let r=this.isMobileLayout?this.cfg.mobileIconBtnSize:this.cfg.iconBtnSize;Object.assign(e.style,{background:n?t.ui.accentBg:`transparent`,color:n?t.ui.accentText:t.topBar.btnColor,border:`1px solid ${n?t.ui.accent:t.axisBorder}`,borderRadius:`5px`,width:r,height:r,cursor:`pointer`,outline:`none`,display:`flex`,alignItems:`center`,justifyContent:`center`,padding:`0`,flexShrink:`0`,transition:`border-color 0.12s, background 0.12s`})}resizeSvg(e,t){if(!e)return;let n=e.querySelector(`svg`);n&&(n.setAttribute(`width`,String(t)),n.setAttribute(`height`,String(t)))}getSvgSize(e){var t;if(!e)return 0;let n=e.querySelector(`svg`);return n?parseInt((t=n.getAttribute(`width`))==null?`0`:t,10):0}},Fn=[`1m`,`5m`,`15m`,`1h`,`4h`,`1D`,`1W`],In={"1m":`1m`,"5m":`5m`,"15m":`15m`,"1h":`1H`,"4h":`4H`,"1D":`1D`,"1W":`1W`},Ln=new Set([`VOL`,`VWAP`,`OBV`,`A/D`,`MFI`,`CMF`]),Rn=`stroke-width="1.75"`,zn=`stroke-width="2"`;function Bn(e,t,n){return`<svg viewBox="0 0 24 24" width="${e}" height="${e}" fill="none" stroke="currentColor" ${t} stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${n}</svg>`}var Vn=(e=14)=>Bn(e,Rn,`<path d="M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z"/><path d="m15 5 4 4"/>`),Hn=(e=14)=>Bn(e,Rn,`<line x1="18" x2="18" y1="20" y2="10"/><line x1="12" x2="12" y1="20" y2="4"/><line x1="6" x2="6" y1="20" y2="14"/>`),Un=(e=14)=>Bn(e,Rn,`<path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"/><circle cx="12" cy="12" r="3"/>`),Wn=(e=12)=>Bn(e,zn,`<path d="M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z"/><path d="M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12"/><path d="M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17"/>`),Gn=(e=12)=>Bn(e,zn,`<path d="M3 3v16a2 2 0 0 0 2 2h16"/><path d="M7 11.207a.5.5 0 0 1 .146-.353l2-2a.5.5 0 0 1 .708 0l3.292 3.292a.5.5 0 0 0 .708 0l4.292-4.292a.5.5 0 0 1 .854.353V16a1 1 0 0 1-1 1H8a1 1 0 0 1-1-1z"/>`),Kn=(e=14)=>Bn(e,zn,`<path d="M14 4.1 12 6"/><path d="m5.1 8-2.9-.8"/><path d="m6 12-1.9 2"/><path d="M7.2 2.2 8 5.1"/><path d="M9.037 9.69a.498.498 0 0 1 .653-.653l11 4.5a.5.5 0 0 1-.074.949l-4.349 1.041a1 1 0 0 0-.74.739l-1.04 4.35a.5.5 0 0 1-.95.074z"/>`),qn=(e=14)=>Bn(e,Rn,`<path d="M14.5 4h-5L7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3l-2.5-3z"/><circle cx="12" cy="13" r="3"/>`),Jn=(e=14)=>Bn(e,Rn,`<polyline points="15 3 21 3 21 9"/><polyline points="9 21 3 21 3 15"/><line x1="21" x2="14" y1="3" y2="10"/><line x1="3" x2="10" y1="21" y2="14"/>`),Yn=(e=14)=>Bn(e,Rn,`<polyline points="4 14 10 14 10 20"/><polyline points="20 10 14 10 14 4"/><line x1="10" x2="3" y1="14" y2="21"/><line x1="21" x2="14" y1="3" y2="10"/>`);function Xn(e){return`<svg width="16" height="11.52" viewBox="0 0 16 11.52" class="shrink-0" aria-hidden="true" fill="none">${e}</svg>`}var Zn=Xn(`<rect x="1.5" y="1.5" width="13" height="8.52" stroke="currentColor" stroke-width="1.2" rx="1.5"/>`);function Qn(){if(document.getElementById(`act-adv-toolbar-styles`))return;let e=document.createElement(`style`);e.id=`act-adv-toolbar-styles`,e.textContent=`
|
|
253
|
+
`,document.head.appendChild(e)}var qn=class{constructor(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v=b,y=k.topBar,x=null,S=!1,C=!1,w=null,T=null,E=null,D=null,O=`bid`,A=null,j=!1,M=!0,N=null,P=!1,F=!0,I=null,L=null){if(this.onSeriesChange=e,this.onTimeframeChange=t,this.onAddIndicator=n,this.onDurationChange=r,this.onSettingsClick=i,this.onFullscreenToggle=a,this.onDrawingToolsToggle=o,this.onTfcToggle=f,this.onDropdownChange=x,this.onLayoutBtnClick=w,this.onSnapshotBtnClick=T,this.onOneClickTradeToggle=E,this.onPriceSourceChange=A,this.onCrosshairToggle=N,this.onPnlPillToggle=I,this.headerTimeframes=L,this.fullscreenBtn=null,this.settingsBtn=null,this.isFullscreen=!1,this.durationBtns=new Map,this.isMobileLayout=!1,this.drawingBtn=null,this.tfcBtn=null,this.tfcActive=!0,this.layoutBtn=null,this.layoutIconEl=null,this.snapshotBtn=null,this.oneClickBtn=null,this.oneClickActive=!1,this.crosshairBtn=null,this.crosshairEnabled=!0,this.pnlPillBtn=null,this.pnlPillVisible=!0,this.pnlPillSymbol=``,this.openDropdown=null,this.disposeFlyoutKbd=()=>{},this.indicatorOptions=[],this.activeIndicators=new Set,this.volHasData=!0,this.priceSourceBtn=null,this.priceSourceOptions=[],this.currentPriceSource=`bid`,this.theme=_,this.cfg=v,this.labels=y,this.tfcActive=d,this.currentSeries=p,this.currentTf=m,this.activeDuration=h,this.durationMap=g,Kn(),this.el=document.createElement(`div`),this.applyBarStyles(_),this.flyout=document.createElement(`div`),this.flyout.classList.add(`finchart-flyout`),this.applyFlyoutStyles(),document.body.appendChild(this.flyout),this.disposeFlyoutKbd=Un(this.flyout),this.leftGroup=document.createElement(`div`),Object.assign(this.leftGroup.style,{display:`flex`,alignItems:`center`,gap:`4px`,flex:`1`,minWidth:`0`,overflow:`hidden`}),s&&(this.drawingBtn=this.makeDrawingBtn(_),this.leftGroup.appendChild(this.drawingBtn)),this.seriesBtn=this.makeSeriesBtn(p,_),this.seriesBtn.addEventListener(`click`,e=>{e.stopPropagation(),this.toggleDropdown(`series`,this.seriesBtn)}),this.addBtnHover(this.seriesBtn),this.tfBtn=this.makeDropBtn(m,_,!1),this.tfBtn.addEventListener(`click`,e=>{e.stopPropagation(),this.toggleDropdown(`timeframe`,this.tfBtn)}),this.addBtnHover(this.tfBtn),this.indBtn=this.makeDropBtn(this.labels.indicatorsBtn,_,!1),this.indBtn.addEventListener(`click`,e=>{e.stopPropagation(),this.toggleDropdown(`indicators`,this.indBtn)}),this.addBtnHover(this.indBtn),D&&D.length>0&&(this.priceSourceOptions=D,this.currentPriceSource=O,this.priceSourceBtn=this.makeDropBtn(O.toUpperCase(),_,!1),this.priceSourceBtn.title=`Chart price source`,this.priceSourceBtn.addEventListener(`click`,e=>{e.stopPropagation(),this.toggleDropdown(`pricesource`,this.priceSourceBtn)}),this.addBtnHover(this.priceSourceBtn)),this.leftGroup.append(this.seriesBtn,this.tfBtn),this.priceSourceBtn&&this.leftGroup.appendChild(this.priceSourceBtn),this.leftGroup.appendChild(this.indBtn),this.rightGroup=document.createElement(`div`),Object.assign(this.rightGroup.style,{display:`flex`,alignItems:`center`,gap:`2px`,flexShrink:`0`}),this.durationDropBtn=this.makeDropBtn(h==null?Wn[0]:h,_,!1),this.durationDropBtn.style.display=`none`,this.durationSep=document.createElement(`div`),this.durationSep.style.display=`none`,j&&(this.crosshairEnabled=M,this.crosshairBtn=document.createElement(`button`),this.crosshairBtn.type=`button`,this.crosshairBtn.dataset.testid=`chart-crosshair-toggle`,this.crosshairBtn.innerHTML=Rn,this.applyCrosshairBtnStyles(this.crosshairBtn,_,this.crosshairEnabled),this.crosshairBtn.addEventListener(`click`,e=>{var t;e.stopPropagation(),this.setCrosshairActive(!this.crosshairEnabled),(t=this.onCrosshairToggle)==null||t.call(this,this.crosshairEnabled)}),this.crosshairBtn.addEventListener(`mouseenter`,()=>{this.crosshairBtn&&!this.crosshairEnabled&&(this.crosshairBtn.style.background=this.theme.ui.accentBg)}),this.crosshairBtn.addEventListener(`mouseleave`,()=>{this.crosshairBtn&&!this.crosshairEnabled&&(this.crosshairBtn.style.background=`transparent`)}),this.rightGroup.appendChild(this.crosshairBtn)),P){this.pnlPillVisible=F,this.pnlPillBtn=document.createElement(`button`),this.pnlPillBtn.type=`button`,this.pnlPillBtn.dataset.testid=`chart-symbol-pnl-toggle`;let e=document.createElement(`span`);e.innerHTML=zn,Object.assign(e.style,{display:`flex`,alignItems:`center`,flexShrink:`0`});let t=document.createElement(`span`);t.textContent=this.labels.pnlPillBtn,Object.assign(t.style,{lineHeight:`1`,fontSize:`9.5px`,fontFamily:`ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace`,textTransform:`uppercase`,letterSpacing:`0.05em`}),this.pnlPillBtn.append(e,t),this.applyPnlPillBtnStyles(this.pnlPillBtn,_,this.pnlPillVisible),this.pnlPillBtn.addEventListener(`click`,e=>{var t;e.stopPropagation(),this.setPnlPillActive(!this.pnlPillVisible),(t=this.onPnlPillToggle)==null||t.call(this,this.pnlPillVisible)}),this.pnlPillBtn.addEventListener(`mouseenter`,()=>{this.pnlPillBtn&&!this.pnlPillVisible&&(this.pnlPillBtn.style.background=this.theme.ui.accentBg)}),this.pnlPillBtn.addEventListener(`mouseleave`,()=>{this.pnlPillBtn&&!this.pnlPillVisible&&(this.pnlPillBtn.style.background=`transparent`)}),this.rightGroup.appendChild(this.pnlPillBtn)}S&&(this.layoutBtn=document.createElement(`button`),this.layoutBtn.title=`Chart Layout`,this.layoutBtn.dataset.layoutToggle=`true`,this.layoutIconEl=document.createElement(`span`),this.layoutIconEl.style.display=`flex`,this.layoutIconEl.style.alignItems=`center`,this.layoutIconEl.style.flexShrink=`0`,this.layoutIconEl.innerHTML=Fn,this.layoutBtn.appendChild(this.layoutIconEl),this.applyIconBtnStyles(this.layoutBtn,_,!1),this.layoutBtn.addEventListener(`click`,e=>{var t;e.stopPropagation(),(t=this.onLayoutBtnClick)==null||t.call(this)}),this.addBtnHover(this.layoutBtn),this.rightGroup.appendChild(this.layoutBtn)),this.onOneClickTradeToggle&&(this.oneClickBtn=document.createElement(`button`),this.oneClickBtn.title=`1-Click Trade (T)`,this.oneClickBtn.dataset.testid=`chart-toggle-floating`,this.oneClickBtn.innerHTML=In,this.applyIconBtnStyles(this.oneClickBtn,_,!1),this.oneClickBtn.addEventListener(`click`,e=>{var t;e.stopPropagation(),this.oneClickActive=!this.oneClickActive,this.applyIconBtnStyles(this.oneClickBtn,this.theme,this.oneClickActive),(t=this.onOneClickTradeToggle)==null||t.call(this,this.oneClickActive)}),this.addBtnHover(this.oneClickBtn),this.rightGroup.appendChild(this.oneClickBtn)),C&&(this.snapshotBtn=document.createElement(`button`),this.snapshotBtn.title=`Snapshot`,this.snapshotBtn.dataset.snapshotToggle=`true`,this.snapshotBtn.innerHTML=Ln,this.applyIconBtnStyles(this.snapshotBtn,_,!1),this.snapshotBtn.addEventListener(`click`,e=>{var t;e.stopPropagation(),(t=this.onSnapshotBtnClick)==null||t.call(this)}),this.addBtnHover(this.snapshotBtn),this.rightGroup.appendChild(this.snapshotBtn)),l&&(this.fullscreenBtn=document.createElement(`button`),this.fullscreenBtn.title=this.labels.toggleFullscreenTitle,this.fullscreenBtn.innerHTML=dn,this.applyIconBtnStyles(this.fullscreenBtn,_,!1),this.fullscreenBtn.addEventListener(`click`,e=>{e.stopPropagation(),this.onFullscreenToggle()}),this.addBtnHover(this.fullscreenBtn),this.rightGroup.appendChild(this.fullscreenBtn)),c&&(this.settingsBtn=document.createElement(`button`),this.settingsBtn.title=this.labels.settingsTitle,this.settingsBtn.innerHTML=sn,this.applyIconBtnStyles(this.settingsBtn,_,!1),this.settingsBtn.addEventListener(`click`,e=>{e.stopPropagation(),this.onSettingsClick()}),this.addBtnHover(this.settingsBtn),this.rightGroup.appendChild(this.settingsBtn)),u&&(this.tfcBtn=document.createElement(`button`),this.tfcBtn.title=this.labels.tfcToggleTitle,this.tfcBtn.innerHTML=this.tfcActive?Sn:Cn,this.applyIconBtnStyles(this.tfcBtn,_,this.tfcActive),this.tfcBtn.addEventListener(`click`,e=>{var t;e.stopPropagation(),this.tfcActive=!this.tfcActive,this.tfcBtn.innerHTML=this.tfcActive?Sn:Cn,this.applyIconBtnStyles(this.tfcBtn,this.theme,this.tfcActive),(t=this.onTfcToggle)==null||t.call(this,this.tfcActive)}),this.addBtnHover(this.tfcBtn),this.rightGroup.appendChild(this.tfcBtn)),this.el.append(this.leftGroup,this.rightGroup),this.docClickHandler=e=>{!this.el.contains(e.target)&&!this.flyout.contains(e.target)&&this.closeDropdown()},document.addEventListener(`click`,this.docClickHandler,!0)}destroy(){this.disposeFlyoutKbd(),this.flyout.remove(),document.removeEventListener(`click`,this.docClickHandler,!0)}reparentFlyout(e){this.flyout.parentElement!==e&&e.appendChild(this.flyout)}setFullscreen(e){this.isFullscreen=e,this.fullscreenBtn&&(this.fullscreenBtn.innerHTML=e?fn:dn,this.fullscreenBtn.title=e?this.labels.exitFullscreenTitle:this.labels.toggleFullscreenTitle,this.applyIconBtnStyles(this.fullscreenBtn,this.theme,e),this.isMobileLayout&&this.resizeSvg(this.fullscreenBtn,this.getSvgSize(this.fullscreenBtn)+2))}setDrawingsBtnActive(e){this.drawingBtn&&this.applyIconBtnStyles(this.drawingBtn,this.theme,e)}setCrosshairActive(e){this.crosshairEnabled=e,this.crosshairBtn&&this.applyCrosshairBtnStyles(this.crosshairBtn,this.theme,e)}setPnlPillActive(e,t){this.pnlPillVisible=e,t!==void 0&&(this.pnlPillSymbol=t),this.pnlPillBtn&&this.applyPnlPillBtnStyles(this.pnlPillBtn,this.theme,e)}setTfcActive(e){this.tfcBtn&&(this.tfcActive=e,this.tfcBtn.innerHTML=e?Sn:Cn,this.applyIconBtnStyles(this.tfcBtn,this.theme,e),this.isMobileLayout&&this.resizeSvg(this.tfcBtn,this.getSvgSize(this.tfcBtn)+2))}setTheme(e){this.theme=e,this.closeDropdown(),this.applyBarStyles(e),this.applyFlyoutStyles(),this.drawingBtn&&this.applyIconBtnStyles(this.drawingBtn,e,!1),this.fullscreenBtn&&this.applyIconBtnStyles(this.fullscreenBtn,e,this.isFullscreen),this.settingsBtn&&this.applyIconBtnStyles(this.settingsBtn,e,!1),this.tfcBtn&&this.applyIconBtnStyles(this.tfcBtn,e,this.tfcActive),this.crosshairBtn&&this.applyCrosshairBtnStyles(this.crosshairBtn,e,this.crosshairEnabled),this.pnlPillBtn&&this.applyPnlPillBtnStyles(this.pnlPillBtn,e,this.pnlPillVisible),this.layoutBtn&&this.applyIconBtnStyles(this.layoutBtn,e,!1),this.snapshotBtn&&this.applyIconBtnStyles(this.snapshotBtn,e,!1),this.layoutIconEl&&(this.layoutIconEl.style.color=e.ui.accent),this.applySeriesBtnStyles(this.seriesBtn,e,!1),this.applyDropBtnStyles(this.tfBtn,e,!1),this.applyDropBtnStyles(this.indBtn,e,!1),this.priceSourceBtn&&this.applyDropBtnStyles(this.priceSourceBtn,e,!1);for(let[t,n]of this.durationBtns)this.applyDurationBtnStyles(n,e,t===this.activeDuration);this.durationSep.style.background=e.axisBorder,this.applyDropBtnStyles(this.durationDropBtn,e,!1)}setSeries(e){this.currentSeries=e,this.updateSeriesBtnContent(this.seriesBtn,e)}setTimeframe(e){this.currentTf=e,this.tfBtn.textContent=e}setPriceSource(e){this.currentPriceSource=e,this.priceSourceBtn&&(this.priceSourceBtn.textContent=e.toUpperCase())}setActiveDuration(e){if(this.activeDuration!==(e==null?null:e)){if(this.activeDuration){let e=this.durationBtns.get(this.activeDuration);e&&this.applyDurationBtnStyles(e,this.theme,!1)}if(this.activeDuration=e==null?null:e,e){let t=this.durationBtns.get(e);t&&this.applyDurationBtnStyles(t,this.theme,!0),this.durationDropBtn.textContent=e}}}setMobileLayout(e){if(this.isMobileLayout===e)return;this.isMobileLayout=e;let t=e?`none`:``;for(let e of this.durationBtns.values())e.style.display=t;this.durationSep.style.display=t,this.durationDropBtn.style.display=e?``:`none`;let n=e?this.cfg.mobileIconBtnSize:this.cfg.iconBtnSize;for(let e of[this.fullscreenBtn,this.settingsBtn,this.drawingBtn,this.tfcBtn,this.layoutBtn,this.snapshotBtn])e&&(e.style.width=n,e.style.height=n);let r=e?2:-2;if(this.fullscreenBtn&&this.resizeSvg(this.fullscreenBtn,this.getSvgSize(this.fullscreenBtn)+r),this.settingsBtn&&this.resizeSvg(this.settingsBtn,this.getSvgSize(this.settingsBtn)+r),this.tfcBtn&&this.resizeSvg(this.tfcBtn,this.getSvgSize(this.tfcBtn)+r),this.drawingBtn){let t=parseInt(e?this.cfg.mobileDrawBtnIconSize:this.cfg.drawBtnIconFontSize,10);this.resizeSvg(this.drawingBtn,t)}}setIndicatorOptions(e){this.indicatorOptions=e}setLayoutPresetIcon(e,t=!0){!this.layoutBtn||!this.layoutIconEl||(this.layoutIconEl.innerHTML=e,this.layoutIconEl.style.color=this.theme.ui.accent)}getLayoutBtnEl(){return this.layoutBtn}getSnapshotBtnEl(){return this.snapshotBtn}setIndicatorOptionActive(e,t,n){t?this.activeIndicators.add(e):this.activeIndicators.delete(e),this.updateIndBtnLabel()}setVolumeControl(e,t){this.volHasData=t,t&&e?this.activeIndicators.add(`VOL`):this.activeIndicators.delete(`VOL`),this.updateIndBtnLabel()}makeDrawingBtn(e){let t=document.createElement(`button`);return t.title=`Drawing Tools`,t.innerHTML=ln,this.applyIconBtnStyles(t,e,!1),t.addEventListener(`click`,e=>{var t;e.stopPropagation(),(t=this.onDrawingToolsToggle)==null||t.call(this)}),this.addBtnHover(t),t}makeSeriesBtn(e,t){let n=document.createElement(`button`);return this.applySeriesBtnStyles(n,t,!1),this.updateSeriesBtnContent(n,e),n}updateSeriesBtnContent(e,t){var n;e.title=(n=this.labels.series[t])==null?t:n,e.innerHTML=mn[t]}applySeriesBtnStyles(e,t,n){e.dataset.active=String(n),Object.assign(e.style,{background:n?t.ui.accentBg:`transparent`,color:n?t.ui.accentText:t.topBar.btnColor,border:`1px solid ${n?t.ui.accent:t.axisBorder}`,borderRadius:`5px`,padding:`3px 7px`,cursor:`pointer`,outline:`none`,display:`flex`,alignItems:`center`,gap:`4px`,flexShrink:`0`,height:`24px`,transition:`border-color 0.12s, background 0.12s`})}applyFlyoutStyles(){Object.assign(this.flyout.style,{position:`fixed`,zIndex:`9999`,display:`none`,background:this.theme.tooltip.background,border:`1px solid ${this.theme.axisBorder}`,borderRadius:`8px`,padding:`4px 0`,minWidth:`168px`,maxHeight:`340px`,overflowY:`auto`,overflowX:`hidden`,boxShadow:`0 8px 24px rgba(0,0,0,0.55), 0 2px 8px rgba(0,0,0,0.3)`,fontFamily:this.cfg.flyoutRowFontFamily,fontSize:this.cfg.flyoutRowFontSize,scrollbarWidth:`thin`,scrollbarColor:`rgba(120,130,150,0.35) transparent`})}toggleDropdown(e,t){var n;if(this.openDropdown===e){this.closeDropdown();return}let r=this.openDropdown!==null;this.openDropdown=e,this.applySeriesBtnStyles(this.seriesBtn,this.theme,e===`series`),this.applyDropBtnStyles(this.tfBtn,this.theme,e===`timeframe`),this.applyDropBtnStyles(this.indBtn,this.theme,e===`indicators`),this.applyDropBtnStyles(this.durationDropBtn,this.theme,e===`duration`),this.priceSourceBtn&&this.applyDropBtnStyles(this.priceSourceBtn,this.theme,e===`pricesource`),this.buildDropdownContent(e);let i=t.getBoundingClientRect();Object.assign(this.flyout.style,{display:`block`,left:`${i.left}px`,top:`${i.bottom+6}px`}),requestAnimationFrame(()=>{let e=this.flyout.getBoundingClientRect();e.right>window.innerWidth-8&&(this.flyout.style.left=`${window.innerWidth-e.width-8}px`),e.bottom>window.innerHeight-8&&(this.flyout.style.top=`${i.top-e.height-6}px`)}),r||(n=this.onDropdownChange)==null||n.call(this)}buildDropdownContent(e){if(this.flyout.innerHTML=``,this.flyout.style.minWidth=e===`series`?`152px`:e===`timeframe`?`160px`:e===`duration`||e===`pricesource`?`120px`:`180px`,e===`pricesource`)for(let e of this.priceSourceOptions){let t=this.makeRow(e.toUpperCase(),e===this.currentPriceSource,!1);t.addEventListener(`click`,()=>{if(e!==this.currentPriceSource){var t;this.setPriceSource(e),(t=this.onPriceSourceChange)==null||t.call(this,e)}this.closeDropdown()}),this.flyout.appendChild(t)}else if(e===`series`){let e=[{value:`candlestick`,label:this.labels.series.candlestick},{value:`hollow`,label:this.labels.series.hollow},{value:`ohlc`,label:this.labels.series.ohlc},{value:`line`,label:this.labels.series.line},{value:`area`,label:this.labels.series.area},{value:`heikinashi`,label:this.labels.series.heikinashi},{value:`volumecandles`,label:this.labels.series.volumecandles},{value:`linemarkers`,label:this.labels.series.linemarkers},{value:`step`,label:this.labels.series.step},{value:`hlcarea`,label:this.labels.series.hlcarea},{value:`baseline`,label:this.labels.series.baseline},{value:`columns`,label:this.labels.series.columns},{value:`highlow`,label:this.labels.series.highlow}];for(let t of e){let e=this.makeRow(t.label,t.value===this.currentSeries,!1,mn[t.value]);e.addEventListener(`click`,()=>{this.currentSeries=t.value,this.updateSeriesBtnContent(this.seriesBtn,t.value),this.onSeriesChange(t.value),this.closeDropdown()}),this.flyout.appendChild(e)}}else if(e===`timeframe`){var t;let e=[`1m`,`3m`,`4m`,`5m`,`10m`,`15m`,`30m`,`1h`,`2h`,`4h`,`8h`],i=(t=this.headerTimeframes)==null?[`1m`,`5m`,`15m`,`30m`,`1h`,`2h`,`4h`,`8h`,`1D`,`1W`,`1M`]:t,a=i.filter(t=>e.includes(t)),o=i.filter(t=>!e.includes(t));this.flyout.appendChild(this.makeCategoryHeader(`Intraday`));for(let e of a){var n;let t=(n=this.labels.timeframes[e])==null?e:n,r=this.makeRow(t,e===this.currentTf,!1);r.addEventListener(`click`,()=>{this.currentTf=e,this.tfBtn.textContent=t,this.onTimeframeChange(e),this.closeDropdown()}),this.flyout.appendChild(r)}this.flyout.appendChild(this.makeCategoryHeader(`Daily +`));for(let e of o){var r;let t=(r=this.labels.timeframes[e])==null?e:r,n=this.makeRow(t,e===this.currentTf,!1);n.addEventListener(`click`,()=>{this.currentTf=e,this.tfBtn.textContent=t,this.onTimeframeChange(e),this.closeDropdown()}),this.flyout.appendChild(n)}}else if(e===`duration`)for(let e of Wn){let t=this.makeRow(e,e===this.activeDuration,!1);t.addEventListener(`click`,()=>{this.setActiveDuration(e),this.onDurationChange(e,this.durationMap[e]),this.closeDropdown()}),this.flyout.appendChild(t)}else{let e=document.createElement(`div`);Object.assign(e.style,{position:`sticky`,top:`0`,zIndex:`1`,padding:`6px 8px`,background:this.theme.tooltip.background,borderBottom:`1px solid ${this.theme.axisBorder}`});let t=document.createElement(`input`);t.type=`text`,t.placeholder=`Search indicators…`,Object.assign(t.style,{width:`100%`,boxSizing:`border-box`,padding:`5px 8px`,background:this.theme.background,color:this.theme.tooltip.text,border:`1px solid ${this.theme.axisBorder}`,borderRadius:`4px`,fontSize:`16px`,outline:`none`}),e.appendChild(t),this.flyout.appendChild(e);let n=document.createElement(`div`);this.flyout.appendChild(n);let r=new Map;for(let e of this.indicatorOptions){var i;let t=(i=e.category)==null?``:i;r.has(t)||r.set(t,[]),r.get(t).push(e)}let a=e=>{n.innerHTML=``;let i=e.trim().toLowerCase();if(i)for(let e of this.indicatorOptions){if(!e.label.toLowerCase().includes(i)&&!e.value.toLowerCase().includes(i))continue;let r=this.activeIndicators.has(e.value),o=Gn.has(e.value)&&!this.volHasData,s=this.makeRow(e.label,r,o);o||s.addEventListener(`click`,()=>{this.onAddIndicator(e.value),a(t.value)}),n.appendChild(s)}else for(let[e,i]of r){e&&n.appendChild(this.makeCategoryHeader(e));for(let e of i){let r=this.activeIndicators.has(e.value),i=Gn.has(e.value)&&!this.volHasData,o=this.makeRow(e.label,r,i);i||o.addEventListener(`click`,()=>{this.onAddIndicator(e.value),a(t.value)}),n.appendChild(o)}}};a(``),t.addEventListener(`input`,()=>a(t.value)),requestAnimationFrame(()=>t.focus({preventScroll:!0}))}}makeCategoryHeader(e){let t=document.createElement(`div`);return Object.assign(t.style,{padding:`6px 12px 4px`,fontSize:this.cfg.flyoutCategoryFontSize,fontWeight:`600`,letterSpacing:this.cfg.flyoutCategoryLetterSpacing,color:this.theme.topBar.flyoutCategoryColor,textTransform:`uppercase`,opacity:`0.55`,marginTop:`2px`}),t.textContent=e,t}makeRow(e,t,n,r){let i=document.createElement(`button`),a=this.theme.ui.accentBg,o=this.theme.ui.accentBg;if(Object.assign(i.style,{width:`100%`,padding:`7px 12px`,background:t?o:`transparent`,border:`none`,borderLeft:t?`2px solid ${this.theme.ui.accent}`:`2px solid transparent`,color:n?this.theme.ui.disabledText:t?this.theme.ui.accent:this.theme.topBar.flyoutRowColor,fontSize:this.cfg.flyoutRowFontSize,fontFamily:this.cfg.flyoutRowFontFamily,textAlign:`left`,cursor:n?`not-allowed`:`pointer`,display:`flex`,alignItems:`center`,gap:`8px`,boxSizing:`border-box`,opacity:n?`0.45`:`1`,transition:`background 0.1s`}),!n&&!t&&(i.addEventListener(`mouseenter`,()=>{i.style.background=a}),i.addEventListener(`mouseleave`,()=>{i.style.background=`transparent`})),r){let e=document.createElement(`span`);Object.assign(e.style,{display:`flex`,alignItems:`center`,flexShrink:`0`,opacity:t?`1`:`0.7`}),e.innerHTML=r;let n=e.querySelector(`svg`);n&&(n.setAttribute(`width`,`13`),n.setAttribute(`height`,`13`)),i.appendChild(e)}let s=document.createElement(`span`);if(s.style.flex=`1`,s.textContent=e,i.appendChild(s),t){let e=document.createElement(`span`);Object.assign(e.style,{color:this.theme.ui.accent,fontSize:this.cfg.flyoutCheckFontSize,flexShrink:`0`}),e.innerHTML=kn,i.appendChild(e)}return i}closeDropdown(){var e;let t=this.openDropdown!==null;this.flyout.style.display=`none`,this.openDropdown=null,this.applySeriesBtnStyles(this.seriesBtn,this.theme,!1),this.applyDropBtnStyles(this.tfBtn,this.theme,!1),this.applyDropBtnStyles(this.indBtn,this.theme,!1),this.applyDropBtnStyles(this.durationDropBtn,this.theme,!1),this.priceSourceBtn&&this.applyDropBtnStyles(this.priceSourceBtn,this.theme,!1),t&&((e=this.onDropdownChange)==null||e.call(this))}get hasOpenDropdown(){return this.openDropdown!==null}updateIndBtnLabel(){let e=this.activeIndicators.size;this.indBtn.textContent=e>0?this.labels.indicatorsBtnActive.replace(`{count}`,String(e)):this.labels.indicatorsBtn}addBtnHover(e){e.addEventListener(`mouseenter`,()=>{e.dataset.active!==`true`&&(e.style.background=this.theme.ui.accentBg)}),e.addEventListener(`mouseleave`,()=>{e.dataset.active!==`true`&&(e.style.background=`transparent`)})}applyBarStyles(e){Object.assign(this.el.style,{display:`flex`,alignItems:`center`,gap:`8px`,height:this.cfg.height,padding:`0 10px`,background:e.background,borderBottom:`1px solid ${e.axisBorder}`,boxSizing:`border-box`,flexShrink:`0`})}makeDropBtn(e,t,n){let r=document.createElement(`button`);return r.textContent=e,this.applyDropBtnStyles(r,t,n),r}applyDropBtnStyles(e,t,n){e.dataset.active=String(n),Object.assign(e.style,{background:n?t.ui.accentBg:`transparent`,color:n?t.ui.accentText:t.topBar.btnColor,border:`1px solid ${n?t.ui.accent:t.axisBorder}`,borderRadius:`5px`,padding:`3px 8px`,height:`24px`,fontSize:this.cfg.dropBtnFontSize,fontFamily:this.cfg.dropBtnFontFamily,cursor:`pointer`,outline:`none`,whiteSpace:`nowrap`,transition:`border-color 0.12s, background 0.12s`})}applyDurationBtnStyles(e,t,n){e.dataset.active=String(n),Object.assign(e.style,{background:n?t.bottomBar.activeBtnBg:`transparent`,color:n?t.bottomBar.activeBtnText:t.bottomBar.btnColor,border:`1px solid ${n?t.bottomBar.activeBtnBorder:`transparent`}`,borderRadius:`4px`,padding:`2px 7px`,fontSize:this.cfg.dropBtnFontSize,fontFamily:this.cfg.dropBtnFontFamily,cursor:`pointer`,outline:`none`,transition:`background 0.15s, color 0.15s`,whiteSpace:`nowrap`})}applyIconBtnStyles(e,t,n){e.dataset.active=String(n);let r=this.isMobileLayout?this.cfg.mobileIconBtnSize:this.cfg.iconBtnSize;Object.assign(e.style,{background:n?t.ui.accentBg:`transparent`,color:n?t.ui.accentText:t.topBar.btnColor,border:`1px solid ${n?t.ui.accent:t.axisBorder}`,borderRadius:`5px`,width:r,height:r,cursor:`pointer`,outline:`none`,display:`flex`,alignItems:`center`,justifyContent:`center`,padding:`0`,flexShrink:`0`,transition:`border-color 0.12s, background 0.12s`})}applyCrosshairBtnStyles(e,t,n){e.dataset.active=String(n);let r=n?this.labels.disableCrosshairTitle:this.labels.enableCrosshairTitle;e.title=r,e.setAttribute(`aria-label`,r),e.setAttribute(`aria-pressed`,String(n)),Object.assign(e.style,{height:`24px`,width:`24px`,boxSizing:`border-box`,display:`flex`,alignItems:`center`,justifyContent:`center`,borderRadius:`2px`,border:`1px solid ${n?G(t.ui.accent,.3):`transparent`}`,background:n?G(t.ui.accent,.1):`transparent`,color:n?t.ui.accent:t.topBar.btnColor,cursor:`pointer`,padding:`0`,flexShrink:`0`,transition:`color 0.15s, background-color 0.15s, border-color 0.15s`})}applyPnlPillBtnStyles(e,t,n){e.dataset.active=String(n);let r=(n?this.labels.hidePnlPillTitle:this.labels.showPnlPillTitle).replace(/\{symbol\}/g,this.pnlPillSymbol);e.title=r,e.setAttribute(`aria-label`,r),e.setAttribute(`aria-pressed`,String(n)),Object.assign(e.style,{height:`24px`,boxSizing:`border-box`,display:`flex`,alignItems:`center`,gap:`4px`,padding:`0 6px`,borderRadius:`2px`,border:`1px solid ${n?G(t.ui.accent,.3):`transparent`}`,background:n?G(t.ui.accent,.1):`transparent`,color:n?t.ui.accent:t.topBar.btnColor,cursor:`pointer`,flexShrink:`0`,transition:`color 0.15s, background-color 0.15s, border-color 0.15s`})}resizeSvg(e,t){if(!e)return;let n=e.querySelector(`svg`);n&&(n.setAttribute(`width`,String(t)),n.setAttribute(`height`,String(t)))}getSvgSize(e){var t;if(!e)return 0;let n=e.querySelector(`svg`);return n?parseInt((t=n.getAttribute(`width`))==null?`0`:t,10):0}};function Jn(e){if(typeof document>`u`||!document.body)return e;try{return p(e,document.body)}catch(t){return e}}var Yn=[`1m`,`5m`,`15m`,`1h`,`4h`,`1D`,`1W`],Xn=[`1m`,`5m`,`15m`,`1h`,`4h`,`1D`],Zn=[`30m`,`2h`,`8h`,`1W`,`1M`],Qn={"1m":`1m`,"3m":`3m`,"4m":`4m`,"5m":`5m`,"10m":`10m`,"15m":`15m`,"30m":`30m`,"1h":`1h`,"2h":`2h`,"4h":`4h`,"8h":`8h`,"1D":`1d`,"1W":`1w`,"1M":`1M`},$n={"1m":`1m`,"3m":`3m`,"4m":`4m`,"5m":`5m`,"10m":`10m`,"15m":`15m`,"30m":`30m`,"1h":`1H`,"4h":`4H`,"1D":`1D`,"1W":`1W`},er=new Set([`VOL`,`VWAP`,`OBV`,`A/D`,`MFI`,`CMF`]),tr=`stroke-width="1.75"`,nr=`stroke-width="2"`;function rr(e,t,n){return`<svg viewBox="0 0 24 24" width="${e}" height="${e}" fill="none" stroke="currentColor" ${t} stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${n}</svg>`}var ir=(e=14)=>rr(e,tr,`<path d="M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z"/><path d="m15 5 4 4"/>`),ar=(e=14)=>rr(e,tr,`<line x1="18" x2="18" y1="20" y2="10"/><line x1="12" x2="12" y1="20" y2="4"/><line x1="6" x2="6" y1="20" y2="14"/>`),or=(e=14)=>rr(e,tr,`<path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"/><circle cx="12" cy="12" r="3"/>`),sr=(e=12)=>rr(e,nr,`<path d="M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z"/><path d="M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12"/><path d="M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17"/>`),cr=(e=12)=>rr(e,nr,`<path d="M3 3v16a2 2 0 0 0 2 2h16"/><path d="M7 11.207a.5.5 0 0 1 .146-.353l2-2a.5.5 0 0 1 .708 0l3.292 3.292a.5.5 0 0 0 .708 0l4.292-4.292a.5.5 0 0 1 .854.353V16a1 1 0 0 1-1 1H8a1 1 0 0 1-1-1z"/>`),lr=(e=14)=>rr(e,nr,`<path d="M14 4.1 12 6"/><path d="m5.1 8-2.9-.8"/><path d="m6 12-1.9 2"/><path d="M7.2 2.2 8 5.1"/><path d="M9.037 9.69a.498.498 0 0 1 .653-.653l11 4.5a.5.5 0 0 1-.074.949l-4.349 1.041a1 1 0 0 0-.74.739l-1.04 4.35a.5.5 0 0 1-.95.074z"/>`),ur=(e=14)=>rr(e,tr,`<path d="M14.5 4h-5L7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3l-2.5-3z"/><circle cx="12" cy="13" r="3"/>`),dr=(e=14)=>rr(e,tr,`<path d="M10.268 21a2 2 0 0 0 3.464 0"/><path d="M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326"/>`),fr=(e=14)=>rr(e,tr,`<polyline points="15 3 21 3 21 9"/><polyline points="9 21 3 21 3 15"/><line x1="21" x2="14" y1="3" y2="10"/><line x1="3" x2="10" y1="21" y2="14"/>`),pr=(e=14)=>rr(e,tr,`<polyline points="4 14 10 14 10 20"/><polyline points="20 10 14 10 14 4"/><line x1="10" x2="3" y1="14" y2="21"/><line x1="21" x2="14" y1="3" y2="10"/>`),mr=(e=12)=>rr(e,tr,`<rect width="7" height="7" x="3" y="3" rx="1"/><rect width="7" height="7" x="14" y="3" rx="1"/><rect width="7" height="7" x="14" y="14" rx="1"/><rect width="7" height="7" x="3" y="14" rx="1"/>`),hr=(e=12)=>rr(e,nr,`<path d="m6 9 6 6 6-6"/>`),gr=(e=14)=>rr(e,nr,`<circle cx="12" cy="12" r="1"/><circle cx="19" cy="12" r="1"/><circle cx="5" cy="12" r="1"/>`);function _r(e){return`<svg width="16" height="11.52" viewBox="0 0 16 11.52" class="shrink-0" aria-hidden="true" fill="none">${e}</svg>`}var vr=_r(`<rect x="1.5" y="1.5" width="13" height="8.52" stroke="currentColor" stroke-width="1.2" rx="1.5"/>`);function yr(){if(document.getElementById(`act-adv-toolbar-styles`))return;let e=document.createElement(`style`);e.id=`act-adv-toolbar-styles`,e.textContent=`
|
|
246
254
|
.act-adv-flyout::-webkit-scrollbar { width: 4px; }
|
|
247
255
|
.act-adv-flyout::-webkit-scrollbar-track { background: transparent; }
|
|
248
256
|
.act-adv-flyout::-webkit-scrollbar-thumb { background: rgba(120,130,150,0.35); border-radius: 4px; }
|
|
249
257
|
.act-adv-flyout::-webkit-scrollbar-thumb:hover { background: rgba(120,130,150,0.6); }
|
|
250
258
|
.act-adv-flyout-row:hover { background: var(--act-adv-row-hover) !important; }
|
|
251
|
-
`,document.head.appendChild(e)}var $n=class{constructor(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g=!0,_=!0){this.onSeriesChange=e,this.onAddIndicator=n,this.onCompareClick=f,this.onLayoutClick=p,this.onOneClickTradeToggle=m,this.onScreenshotClick=h,this.oneClickActive=!1,this.drawingBtn=null,this.fullscreenBtn=null,this.layoutBtn=null,this.layoutIconEl=null,this.snapshotBtn=null,this.tfBtns=new Map,this.indicatorOptions=[],this.activeIndicators=new Set,this.volHasData=!0,this.openFlyout=null,this.theme=d,this.currentSeries=l,this.currentTf=u,Qn(),this.flyout=document.createElement(`div`),this.flyout.classList.add(`act-adv-flyout`),this.applyFlyoutStyles(d),document.body.appendChild(this.flyout),this.el=document.createElement(`div`),this.applyBarStyles(d);let v=this.makeGroup();this.el.appendChild(v),o&&a&&(this.drawingBtn=this.makeIconBtn(Vn(),`Draw`,d,!1),this.drawingBtn.addEventListener(`click`,e=>{e.stopPropagation(),a()}),v.appendChild(this.drawingBtn)),this.seriesBtn=this.makeIconBtn(this.seriesIcon(l),`Chart type`,d,!1),this.seriesBtn.title=`Candles`,this.seriesBtn.addEventListener(`click`,e=>{e.stopPropagation(),this.toggleFlyout(`series`,this.seriesBtn)}),v.appendChild(this.seriesBtn);let y=this.makeGroup();y.setAttribute(`role`,`group`),y.setAttribute(`aria-label`,`Timeframe`),this.el.appendChild(y);for(let e of Fn){var b;let n=(b=In[e])==null?e:b,r=document.createElement(`button`);r.dataset.testid=`tf-${n}`,r.textContent=n,r.setAttribute(`aria-pressed`,e===u?`true`:`false`),this.applyTfPillStyles(r,d,e===u),r.addEventListener(`click`,n=>{n.stopPropagation(),this.setTimeframe(e),t(e)}),this.tfBtns.set(e,r),y.appendChild(r)}if(this.indBtn=this.makeTextBtn(Wn(),`Indicators`,d,!1),this.indBtn.dataset.testid=`indicators-btn`,this.indBtn.addEventListener(`click`,e=>{e.stopPropagation(),this.toggleFlyout(`indicators`,this.indBtn)}),this.el.appendChild(this.indBtn),this.onCompareClick){let e=this.makeTextBtn(Gn(),`Compare`,d,!1);e.addEventListener(`click`,e=>{var t;e.stopPropagation(),(t=this.onCompareClick)==null||t.call(this)}),this.el.appendChild(e)}let x=document.createElement(`div`);if(x.style.flex=`1`,this.el.appendChild(x),g){let e=document.createElement(`div`);e.style.position=`relative`,this.layoutBtn=document.createElement(`button`);let t=this.layoutBtn;t.dataset.testid=`chart-layout-btn`,t.dataset.layoutToggle=`true`,t.title=`Chart Layout`,this.applyTextBtnStyles(t,d,!1),t.style.gap=`6px`,this.layoutIconEl=document.createElement(`span`),this.layoutIconEl.style.display=`flex`,this.layoutIconEl.style.alignItems=`center`,this.layoutIconEl.style.flexShrink=`0`,this.layoutIconEl.style.color=d.ui.accent,this.layoutIconEl.innerHTML=Zn;let n=document.createElement(`span`);n.textContent=`Layout`,n.style.fontSize=`10px`,n.style.fontFamily=`"JetBrains Mono",ui-monospace,Menlo,Monaco,monospace`,n.style.textTransform=`uppercase`,n.style.letterSpacing=`0.05em`,t.appendChild(this.layoutIconEl),t.appendChild(n),t.addEventListener(`click`,e=>{var t;e.stopPropagation(),(t=this.onLayoutClick)==null||t.call(this)}),this.addHover(t,d),e.appendChild(t),this.el.appendChild(e)}if(this.onOneClickTradeToggle){let e=document.createElement(`button`);e.dataset.testid=`chart-toggle-floating`,e.title=`Show 1-click trade (T)`,this.applyTextBtnStyles(e,d,!1),e.style.gap=`6px`;let t=document.createElement(`span`);t.style.display=`flex`,t.style.alignItems=`center`,t.innerHTML=Kn();let n=document.createElement(`span`);n.textContent=`1-Click`,n.style.fontSize=`10px`,n.style.fontFamily=`ui-monospace,monospace`,n.style.textTransform=`uppercase`,n.style.letterSpacing=`0.05em`,e.appendChild(t),e.appendChild(n);let r=t=>{e.dataset.active=String(t),t?(e.style.background=d.ui.accentBg,e.style.color=d.ui.accent,e.style.border=`1px solid ${d.ui.accent}`,e.style.borderRadius=`2px`):(e.style.background=`transparent`,e.style.color=d.topBar.btnColor,e.style.border=`1px solid transparent`)};r(!1),e.addEventListener(`click`,e=>{var t;e.stopPropagation(),this.oneClickActive=!this.oneClickActive,r(this.oneClickActive),(t=this.onOneClickTradeToggle)==null||t.call(this,this.oneClickActive)}),this.addHover(e,d),this.el.appendChild(e)}_&&(this.snapshotBtn=this.makeIconBtn(qn(),`Snapshot`,d,!1),this.snapshotBtn.dataset.snapshotToggle=`true`,this.snapshotBtn.addEventListener(`click`,e=>{var t;e.stopPropagation(),(t=this.onScreenshotClick)==null||t.call(this)}),this.el.appendChild(this.snapshotBtn));let S=this.makeIconBtn(Un(),`Settings`,d,!1);S.addEventListener(`click`,e=>{e.stopPropagation(),r()}),this.el.appendChild(S),c&&(this.fullscreenBtn=this.makeIconBtn(Jn(),`Fullscreen (F)`,d,!1),this.fullscreenBtn.dataset.testid=`chart-fullscreen-toggle`,this.fullscreenBtn.addEventListener(`click`,e=>{e.stopPropagation(),i()}),this.el.appendChild(this.fullscreenBtn)),this.docClickHandler=()=>this.closeDropdown(),document.addEventListener(`click`,this.docClickHandler)}setTimeframe(e){let t=this.tfBtns.get(this.currentTf);t&&(this.applyTfPillStyles(t,this.theme,!1),t.setAttribute(`aria-pressed`,`false`)),this.currentTf=e;let n=this.tfBtns.get(e);n&&(this.applyTfPillStyles(n,this.theme,!0),n.setAttribute(`aria-pressed`,`true`))}setFullscreen(e){this.fullscreenBtn&&(this.fullscreenBtn.innerHTML=e?Yn():Jn())}setDrawingsBtnActive(e){this.drawingBtn&&this.applyIconBtnStyles(this.drawingBtn,this.theme,e)}setIndicatorOptions(e){this.indicatorOptions=e}setIndicatorOptionActive(e,t,n){t?this.activeIndicators.add(e):this.activeIndicators.delete(e),this.updateIndBtnLabel()}setVolumeControl(e,t){this.volHasData=t}setTheme(e){this.theme=e,this.applyBarStyles(e),this.applyFlyoutStyles(e);for(let[t,n]of this.tfBtns)this.applyTfPillStyles(n,e,t===this.currentTf);this.flyout.style.setProperty(`--act-adv-row-hover`,e.ui.accentBg)}setSeries(e){this.currentSeries=e,this.seriesBtn.innerHTML=this.seriesIcon(e)}setLayoutPresetIcon(e,t=!0){!this.layoutBtn||!this.layoutIconEl||(this.layoutIconEl.innerHTML=e,this.layoutIconEl.style.color=this.theme.ui.accent,this.applyTextBtnStyles(this.layoutBtn,this.theme,t))}setLayoutActive(e){this.layoutBtn&&this.applyTextBtnStyles(this.layoutBtn,this.theme,e)}getLayoutBtnEl(){return this.layoutBtn}getSnapshotBtnEl(){return this.snapshotBtn}setTfcActive(e){}setActiveDuration(e){}reparentFlyout(e){this.flyout.parentElement!==e&&e.appendChild(this.flyout)}setMobileLayout(e){}closeDropdown(){this.flyout.style.display=`none`,this.openFlyout=null}get hasOpenDropdown(){return this.openFlyout!==null}destroy(){document.removeEventListener(`click`,this.docClickHandler),this.flyout.remove(),this.el.remove()}seriesIcon(e){return nn[e]?nn[e].replace(/width="\d+" height="\d+"/,`width="14" height="14"`):Hn()}toggleFlyout(e,t){if(this.openFlyout===e){this.closeDropdown();return}this.closeDropdown(),this.openFlyout=e,this.buildFlyoutContent(e);let n=t.getBoundingClientRect();Object.assign(this.flyout.style,{display:`block`,left:`${n.left}px`,top:`${n.bottom+6}px`}),requestAnimationFrame(()=>{let e=this.flyout.getBoundingClientRect();e.right>window.innerWidth-8&&(this.flyout.style.left=`${window.innerWidth-e.width-8}px`),e.bottom>window.innerHeight-8&&(this.flyout.style.top=`${n.top-e.height-6}px`)})}buildFlyoutContent(e){if(this.flyout.innerHTML=``,this.flyout.style.minWidth=e===`series`?`152px`:`180px`,this.flyout.style.setProperty(`--act-adv-row-hover`,this.theme.ui.accentBg),e===`series`)for(let e of[{value:`candlestick`,label:`Candlestick`},{value:`hollow`,label:`Hollow Candles`},{value:`ohlc`,label:`OHLC Bars`},{value:`line`,label:`Line`},{value:`area`,label:`Area`},{value:`heikinashi`,label:`Heikin Ashi`},{value:`volumecandles`,label:`Volume Candles`},{value:`linemarkers`,label:`Line with Markers`},{value:`step`,label:`Step Line`},{value:`hlcarea`,label:`HLC Area`},{value:`baseline`,label:`Baseline`},{value:`columns`,label:`Columns`},{value:`highlow`,label:`High Low`}]){let t=this.makeRow(e.label,e.value===this.currentSeries,!1,nn[e.value]);t.addEventListener(`click`,()=>{this.currentSeries=e.value,this.seriesBtn.innerHTML=this.seriesIcon(e.value),this.onSeriesChange(e.value),this.closeDropdown()}),this.flyout.appendChild(t)}else{let e=document.createElement(`div`);Object.assign(e.style,{position:`sticky`,top:`0`,zIndex:`1`,padding:`6px 8px`,background:this.theme.tooltip.background,borderBottom:`1px solid ${this.theme.axisBorder}`});let n=document.createElement(`input`);n.type=`text`,n.placeholder=`Search indicators…`,Object.assign(n.style,{width:`100%`,boxSizing:`border-box`,padding:`5px 8px`,background:this.theme.background,color:this.theme.tooltip.text,border:`1px solid ${this.theme.axisBorder}`,borderRadius:`4px`,fontSize:`16px`,outline:`none`}),e.appendChild(n),this.flyout.appendChild(e);let r=document.createElement(`div`);this.flyout.appendChild(r);let i=new Map;for(let e of this.indicatorOptions){var t;let n=(t=e.category)==null?``:t;i.has(n)||i.set(n,[]),i.get(n).push(e)}let a=e=>{r.innerHTML=``;let t=e.trim().toLowerCase();if(t)for(let e of this.indicatorOptions){if(!e.label.toLowerCase().includes(t)&&!e.value.toLowerCase().includes(t))continue;let i=this.activeIndicators.has(e.value),o=Ln.has(e.value)&&!this.volHasData,s=this.makeRow(e.label,i,o);o||s.addEventListener(`click`,()=>{this.onAddIndicator(e.value),a(n.value)}),r.appendChild(s)}else for(let[e,t]of i){e&&r.appendChild(this.makeCategoryHeader(e));for(let e of t){let t=this.activeIndicators.has(e.value),i=Ln.has(e.value)&&!this.volHasData,o=this.makeRow(e.label,t,i);i||o.addEventListener(`click`,()=>{this.onAddIndicator(e.value),a(n.value)}),r.appendChild(o)}}};a(``),n.addEventListener(`input`,()=>a(n.value)),requestAnimationFrame(()=>n.focus({preventScroll:!0}))}}updateIndBtnLabel(){let e=this.activeIndicators.size,t=this.indBtn.querySelector(`span:last-child`);t&&(t.textContent=e>0?`Indicators (${e})`:`Indicators`)}applyBarStyles(e){Object.assign(this.el.style,{display:`flex`,alignItems:`center`,gap:`4px`,paddingLeft:`8px`,paddingRight:`8px`,height:`36px`,borderBottom:`1px solid ${e.axisBorder}`,boxSizing:`border-box`,flexShrink:`0`,background:e.background})}applyFlyoutStyles(e){Object.assign(this.flyout.style,{position:`fixed`,display:`none`,zIndex:`10000`,background:e.tooltip.background,border:`1px solid ${e.axisBorder}`,borderRadius:`6px`,boxShadow:`0 4px 16px rgba(0,0,0,0.35)`,overflowY:`auto`,maxHeight:`320px`})}makeGroup(){let e=document.createElement(`div`);return Object.assign(e.style,{display:`flex`,alignItems:`center`,gap:`2px`,paddingRight:`8px`,borderRight:`1px solid ${this.theme.axisBorder}`}),e}makeIconBtn(e,t,n,r){let i=document.createElement(`button`);return i.title=t,i.innerHTML=e,this.applyIconBtnStyles(i,n,r),this.addHover(i,n),i}applyIconBtnStyles(e,t,n){e.dataset.active=String(n),Object.assign(e.style,{height:`28px`,width:`28px`,display:`flex`,alignItems:`center`,justifyContent:`center`,borderRadius:`2px`,border:`none`,background:n?t.ui.accentBg:`transparent`,color:n?t.ui.accent:t.topBar.btnColor,cursor:`pointer`,padding:`0`,flexShrink:`0`,transition:`color 0.15s, background-color 0.15s`})}makeTextBtn(e,t,n,r){let i=document.createElement(`button`);i.setAttribute(`aria-label`,t),this.applyTextBtnStyles(i,n,r);let a=document.createElement(`span`);a.style.display=`flex`,a.style.alignItems=`center`,a.innerHTML=e;let o=document.createElement(`span`);return o.textContent=t,i.appendChild(a),i.appendChild(o),this.addHover(i,n),i}applyTextBtnStyles(e,t,n){e.dataset.active=String(n),Object.assign(e.style,{display:`flex`,alignItems:`center`,gap:`4px`,paddingLeft:`8px`,paddingRight:`8px`,height:`28px`,fontSize:`12px`,fontWeight:`600`,fontFamily:`inherit`,borderRadius:`2px`,border:`none`,background:n?t.ui.accentBg:`transparent`,color:n?t.ui.accent:t.topBar.btnColor,cursor:`pointer`,padding:`0 8px`,flexShrink:`0`,whiteSpace:`nowrap`,transition:`color 0.15s, background-color 0.15s`})}applyTfPillStyles(e,t,n){e.dataset.active=String(n),Object.assign(e.style,{paddingLeft:`8px`,paddingRight:`8px`,height:`28px`,fontSize:`12px`,fontFamily:`"JetBrains Mono",ui-monospace,Menlo,Monaco,monospace`,fontWeight:`600`,borderRadius:`2px`,border:`none`,background:n?t.ui.accentBg:`transparent`,color:n?t.ui.accent:t.topBar.btnColor,cursor:`pointer`,transition:`color 0.15s, background-color 0.15s`})}addHover(e,t){e.addEventListener(`mouseenter`,()=>{e.dataset.active!==`true`&&(e.style.background=`rgb(var(--color-secondary-700,36 36 41))`,e.style.color=`rgb(var(--color-secondary-100,250 250 250))`)}),e.addEventListener(`mouseleave`,()=>{e.dataset.active!==`true`&&(e.style.background=`transparent`,e.style.color=t.topBar.btnColor)})}makeCategoryHeader(e){var t;let n=document.createElement(`div`);return Object.assign(n.style,{padding:`6px 12px 4px`,fontSize:`10px`,fontWeight:`600`,letterSpacing:`0.08em`,color:(t=this.theme.topBar.flyoutCategoryColor)==null?this.theme.axisText:t,textTransform:`uppercase`,opacity:`0.55`,marginTop:`2px`}),n.textContent=e,n}makeRow(e,t,n,r){let i=document.createElement(`button`);if(i.classList.add(`act-adv-flyout-row`),Object.assign(i.style,{width:`100%`,padding:`7px 12px`,background:t?this.theme.ui.accentBg:`transparent`,border:`none`,borderLeft:t?`2px solid ${this.theme.ui.accent}`:`2px solid transparent`,color:n?this.theme.ui.disabledText:t?this.theme.ui.accentText:this.theme.topBar.flyoutRowColor,fontSize:`13px`,fontFamily:`inherit`,textAlign:`left`,cursor:n?`not-allowed`:`pointer`,display:`flex`,alignItems:`center`,gap:`8px`,boxSizing:`border-box`,opacity:n?`0.45`:`1`,transition:`background 0.1s`}),r){let e=document.createElement(`span`);Object.assign(e.style,{display:`flex`,alignItems:`center`,flexShrink:`0`,opacity:t?`1`:`0.7`}),e.innerHTML=r;let n=e.querySelector(`svg`);n&&(n.setAttribute(`width`,`13`),n.setAttribute(`height`,`13`)),i.appendChild(e)}let a=document.createElement(`span`);if(a.style.flex=`1`,a.textContent=e,i.appendChild(a),t){let e=document.createElement(`span`);e.style.color=this.theme.ui.accent,e.innerHTML=vn,i.appendChild(e)}return i}},er=[`1m`,`5m`,`15m`,`1h`,`4h`,`1D`,`1W`],tr={"1m":`1m`,"5m":`5m`,"15m":`15m`,"1h":`1H`,"4h":`4H`,"1D":`1D`,"1W":`1W`},nr=new Set([`VOL`,`VWAP`,`OBV`,`A/D`,`MFI`,`CMF`]);function rr(e,t){return`<svg viewBox="0 0 24 24" width="${e}" height="${e}" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${t}</svg>`}var ir=(e=12)=>rr(e,`<line x1="18" x2="18" y1="20" y2="10"/><line x1="12" x2="12" y1="20" y2="4"/><line x1="6" x2="6" y1="20" y2="14"/>`),ar=(e=12)=>`<svg viewBox="0 0 24 24" width="${e}" height="${e}" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M4 5h6c1 0 1.5.5 1.5 1.5v0c0 1-.5 1.5-1.5 1.5H5"/><path d="M5 12h5"/><path d="M5 19V5"/><path d="m13 9 6 10"/><path d="M19 9 13 19"/></svg>`;function or(){if(document.getElementById(`act-compact-toolbar-styles`))return;let e=document.createElement(`style`);e.id=`act-compact-toolbar-styles`,e.textContent=`
|
|
259
|
+
`,document.head.appendChild(e)}var br=class{constructor(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g=!0,_=!0,v=null,y=`bid`,b=null,x=!1,S=!0,C=null,w=!1,T=!0,E=null,D=!1,O=null,k=null){this.onSeriesChange=e,this.onAddIndicator=n,this.onCompareClick=f,this.onLayoutClick=p,this.onOneClickTradeToggle=m,this.onScreenshotClick=h,this.onPriceSourceChange=b,this.onCrosshairToggle=C,this.onPnlPillToggle=E,this.onAlertClick=k,this.oneClickActive=!1,this.drawingBtn=null,this.fullscreenBtn=null,this.layoutBtn=null,this.layoutIconEl=null,this.snapshotBtn=null,this.crosshairBtn=null,this.crosshairEnabled=!0,this.pnlPillBtn=null,this.pnlPillVisible=!0,this.pnlPillSymbol=``,this.overflowMenu=!1,this.moreBtn=null,this.showSnapshotItem=!1,this.onSettingsClickCb=()=>{},this.onDrawingToolsToggleCb=null,this.drawingActive=!1,this.tfMoreBtn=null,this.tfMore=Zn,this.onTimeframeChangeCb=()=>{},this.tfBtns=new Map,this.indicatorOptions=[],this.activeIndicators=new Set,this.volHasData=!0,this.priceSourceBtn=null,this.priceSourceOptions=[],this.currentPriceSource=`bid`,this.openFlyout=null,d=Jn(d),this.theme=d,this.overflowMenu=D,this.showSnapshotItem=_,this.onSettingsClickCb=r,this.onDrawingToolsToggleCb=a,this.onTimeframeChangeCb=t,this.currentSeries=l,this.currentTf=u,yr(),this.flyout=document.createElement(`div`),this.flyout.classList.add(`act-adv-flyout`),this.applyFlyoutStyles(d),document.body.appendChild(this.flyout),this.el=document.createElement(`div`),this.applyBarStyles(d);let A=this.makeGroup();D||this.el.appendChild(A),o&&a&&(this.drawingBtn=this.makeIconBtn(ir(),`Draw`,d,!1),this.drawingBtn.addEventListener(`click`,e=>{e.stopPropagation(),a()}),A.appendChild(this.drawingBtn)),this.seriesBtn=this.makeIconBtn(this.seriesIcon(l),`Chart type`,d,!1),this.seriesBtn.title=`Candles`,this.seriesBtn.addEventListener(`click`,e=>{e.stopPropagation(),this.toggleFlyout(`series`,this.seriesBtn)}),A.appendChild(this.seriesBtn);let j=this.makeGroup();j.setAttribute(`role`,`group`),j.setAttribute(`aria-label`,`Timeframe`),D&&Object.assign(j.style,{paddingRight:`6px`,marginRight:`6px`,borderRight:`1px solid ${G(d.axisBorder,.6)}`}),this.el.appendChild(j);let M=D?Xn:O==null?Yn:O;this.tfMore=O?O.filter(e=>!Xn.includes(e)):Zn;for(let e of M){var N,P;let n=(N=$n[e])==null?e:N,r=document.createElement(`button`);r.dataset.testid=`tf-${n}`,r.textContent=D?(P=Qn[e])==null?n:P:n,r.setAttribute(`aria-pressed`,e===u?`true`:`false`),this.applyTfPillStyles(r,d,e===u),r.addEventListener(`click`,n=>{n.stopPropagation(),this.setTimeframe(e),t(e)}),this.tfBtns.set(e,r),j.appendChild(r)}if(D&&(this.tfMoreBtn=document.createElement(`button`),this.tfMoreBtn.type=`button`,this.tfMoreBtn.dataset.testid=`tf-more`,this.tfMoreBtn.title=`More timeframes`,this.tfMoreBtn.setAttribute(`aria-label`,`More timeframes`),this.tfMoreBtn.setAttribute(`aria-haspopup`,`menu`),this.tfMoreBtn.innerHTML=hr(),this.applyTfMoreStyles(d,this.tfMore.includes(u)),this.tfMoreBtn.addEventListener(`click`,e=>{e.stopPropagation(),this.toggleFlyout(`timeframes`,this.tfMoreBtn)}),j.appendChild(this.tfMoreBtn)),v&&v.length>0&&(this.priceSourceOptions=v,this.currentPriceSource=y,this.priceSourceBtn=document.createElement(`button`),this.priceSourceBtn.title=`Chart price source`,this.priceSourceBtn.dataset.testid=`price-source-btn`,this.priceSourceBtn.textContent=y.toUpperCase(),this.applyTfPillStyles(this.priceSourceBtn,d,!1),this.priceSourceBtn.addEventListener(`click`,e=>{e.stopPropagation(),this.toggleFlyout(`pricesource`,this.priceSourceBtn)}),this.addHover(this.priceSourceBtn,d),this.el.appendChild(this.priceSourceBtn)),this.indBtn=this.makeTextBtn(sr(),`Indicators`,d,!1),this.indBtn.dataset.testid=`indicators-btn`,this.indBtn.addEventListener(`click`,e=>{e.stopPropagation(),this.toggleFlyout(`indicators`,this.indBtn)}),D||this.el.appendChild(this.indBtn),this.onCompareClick){let e=this.makeTextBtn(cr(),`Compare`,d,!1);e.addEventListener(`click`,e=>{var t;e.stopPropagation(),(t=this.onCompareClick)==null||t.call(this)}),D||this.el.appendChild(e)}let F=document.createElement(`div`);if(F.style.flex=`1`,this.el.appendChild(F),x&&(this.crosshairEnabled=S,this.crosshairBtn=document.createElement(`button`),this.crosshairBtn.type=`button`,this.crosshairBtn.dataset.testid=`chart-crosshair-toggle`,this.crosshairBtn.innerHTML=Rn,this.applyCrosshairBtnStyles(this.crosshairBtn,d,this.crosshairEnabled),this.crosshairBtn.addEventListener(`click`,e=>{var t;e.stopPropagation(),this.setCrosshairActive(!this.crosshairEnabled),(t=this.onCrosshairToggle)==null||t.call(this,this.crosshairEnabled)}),this.crosshairBtn.addEventListener(`mouseenter`,()=>{this.crosshairBtn&&!this.crosshairEnabled&&(this.crosshairBtn.style.background=this.theme.ui.accentBg)}),this.crosshairBtn.addEventListener(`mouseleave`,()=>{this.crosshairBtn&&!this.crosshairEnabled&&(this.crosshairBtn.style.background=`transparent`)}),this.el.appendChild(this.crosshairBtn)),w){this.pnlPillVisible=T,this.pnlPillBtn=document.createElement(`button`),this.pnlPillBtn.type=`button`,this.pnlPillBtn.dataset.testid=`chart-symbol-pnl-toggle`;let e=document.createElement(`span`);e.innerHTML=zn,Object.assign(e.style,{display:`flex`,alignItems:`center`,flexShrink:`0`});let t=document.createElement(`span`);t.textContent=`P/L`,Object.assign(t.style,{lineHeight:`1`,fontSize:`9.5px`,fontFamily:`ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace`,textTransform:`uppercase`,letterSpacing:`0.05em`}),this.pnlPillBtn.append(e,t),this.applyPnlPillBtnStyles(this.pnlPillBtn,d,this.pnlPillVisible),this.pnlPillBtn.addEventListener(`click`,e=>{var t;e.stopPropagation(),this.setPnlPillActive(!this.pnlPillVisible),(t=this.onPnlPillToggle)==null||t.call(this,this.pnlPillVisible)}),this.pnlPillBtn.addEventListener(`mouseenter`,()=>{this.pnlPillBtn&&!this.pnlPillVisible&&(this.pnlPillBtn.style.background=this.theme.ui.accentBg)}),this.pnlPillBtn.addEventListener(`mouseleave`,()=>{this.pnlPillBtn&&!this.pnlPillVisible&&(this.pnlPillBtn.style.background=`transparent`)}),this.el.appendChild(this.pnlPillBtn)}if(g){let e=document.createElement(`div`);e.style.position=`relative`,this.layoutBtn=document.createElement(`button`);let t=this.layoutBtn;t.dataset.testid=`chart-layout-btn`,t.dataset.layoutToggle=`true`,t.title=D?`Multi-chart`:`Chart Layout`,t.setAttribute(`aria-label`,t.title),this.styleLayoutBtn(t,d,!1),D||(t.style.gap=`6px`),this.layoutIconEl=document.createElement(`span`),this.layoutIconEl.style.display=`flex`,this.layoutIconEl.style.alignItems=`center`,this.layoutIconEl.style.flexShrink=`0`,this.layoutIconEl.style.color=D?`inherit`:d.ui.accent,this.layoutIconEl.innerHTML=D?mr():vr;let n=document.createElement(`span`);n.textContent=`Layout`,n.style.fontSize=`10px`,n.style.fontFamily=`"JetBrains Mono",ui-monospace,Menlo,Monaco,monospace`,n.style.textTransform=`uppercase`,n.style.letterSpacing=`0.05em`,t.appendChild(this.layoutIconEl),D||t.appendChild(n),t.addEventListener(`click`,e=>{var t;e.stopPropagation(),(t=this.onLayoutClick)==null||t.call(this)}),this.addHover(t,d),e.appendChild(t),this.el.appendChild(e)}if(this.onOneClickTradeToggle){let e=document.createElement(`button`);e.dataset.testid=`chart-toggle-floating`,e.title=`Show 1-click trade (T)`,this.applyTextBtnStyles(e,d,!1),e.style.gap=`6px`;let t=document.createElement(`span`);t.style.display=`flex`,t.style.alignItems=`center`,t.innerHTML=lr();let n=document.createElement(`span`);n.textContent=`1-Click`,n.style.fontSize=`10px`,n.style.fontFamily=`ui-monospace,monospace`,n.style.textTransform=`uppercase`,n.style.letterSpacing=`0.05em`,e.appendChild(t),e.appendChild(n);let r=t=>{e.dataset.active=String(t),t?(e.style.background=d.ui.accentBg,e.style.color=d.ui.accent,e.style.border=`1px solid ${d.ui.accent}`,e.style.borderRadius=`2px`):(e.style.background=`transparent`,e.style.color=d.topBar.btnColor,e.style.border=`1px solid transparent`)};r(!1),e.addEventListener(`click`,e=>{var t;e.stopPropagation(),this.oneClickActive=!this.oneClickActive,r(this.oneClickActive),(t=this.onOneClickTradeToggle)==null||t.call(this,this.oneClickActive)}),this.addHover(e,d),this.el.appendChild(e)}if(_&&!D&&(this.snapshotBtn=this.makeIconBtn(ur(),`Snapshot`,d,!1),this.snapshotBtn.dataset.snapshotToggle=`true`,this.snapshotBtn.addEventListener(`click`,e=>{var t;e.stopPropagation(),(t=this.onScreenshotClick)==null||t.call(this)}),this.el.appendChild(this.snapshotBtn)),!D){let e=this.makeIconBtn(or(),`Settings`,d,!1);e.addEventListener(`click`,e=>{e.stopPropagation(),r()}),this.el.appendChild(e)}D&&(this.moreBtn=document.createElement(`button`),this.moreBtn.type=`button`,this.moreBtn.dataset.testid=`chart-more-btn`,this.moreBtn.title=`More tools`,this.moreBtn.setAttribute(`aria-label`,`More tools`),this.moreBtn.setAttribute(`aria-haspopup`,`menu`),this.moreBtn.innerHTML=gr(12),this.applyOverflowIconBtnStyles(this.moreBtn,d,!1),this.moreBtn.addEventListener(`click`,e=>{e.stopPropagation(),this.toggleFlyout(`more`,this.moreBtn)}),this.addHover(this.moreBtn,d),this.el.appendChild(this.moreBtn)),c&&(this.fullscreenBtn=this.makeIconBtn(fr(this.iconSize()),`Fullscreen (F)`,d,!1),this.fullscreenBtn.dataset.testid=`chart-fullscreen-toggle`,D&&this.applyOverflowIconBtnStyles(this.fullscreenBtn,d,!1),this.fullscreenBtn.addEventListener(`click`,e=>{e.stopPropagation(),i()}),this.el.appendChild(this.fullscreenBtn)),this.docClickHandler=()=>this.closeDropdown(),document.addEventListener(`click`,this.docClickHandler)}setTimeframe(e){let t=this.tfBtns.get(this.currentTf);t&&(this.applyTfPillStyles(t,this.theme,!1),t.setAttribute(`aria-pressed`,`false`)),this.currentTf=e;let n=this.tfBtns.get(e);n&&(this.applyTfPillStyles(n,this.theme,!0),n.setAttribute(`aria-pressed`,`true`)),this.tfMoreBtn&&this.applyTfMoreStyles(this.theme,!n)}setFullscreen(e){this.fullscreenBtn&&(this.fullscreenBtn.innerHTML=e?pr(this.iconSize()):fr(this.iconSize()))}setDrawingsBtnActive(e){this.drawingActive=e,this.drawingBtn&&this.applyIconBtnStyles(this.drawingBtn,this.theme,e)}iconSize(){return this.overflowMenu?12:14}setCrosshairActive(e){this.crosshairEnabled=e,this.crosshairBtn&&this.applyCrosshairBtnStyles(this.crosshairBtn,this.theme,e)}setPnlPillActive(e,t){this.pnlPillVisible=e,t!==void 0&&(this.pnlPillSymbol=t),this.pnlPillBtn&&this.applyPnlPillBtnStyles(this.pnlPillBtn,this.theme,e)}setIndicatorOptions(e){this.indicatorOptions=e}setIndicatorOptionActive(e,t,n){t?this.activeIndicators.add(e):this.activeIndicators.delete(e),this.updateIndBtnLabel()}setVolumeControl(e,t){this.volHasData=t}setTheme(e){e=Jn(e),this.theme=e,this.applyBarStyles(e),this.applyFlyoutStyles(e);for(let[t,n]of this.tfBtns)this.applyTfPillStyles(n,e,t===this.currentTf);this.crosshairBtn&&this.applyCrosshairBtnStyles(this.crosshairBtn,e,this.crosshairEnabled),this.pnlPillBtn&&this.applyPnlPillBtnStyles(this.pnlPillBtn,e,this.pnlPillVisible),this.moreBtn&&this.applyOverflowIconBtnStyles(this.moreBtn,e,this.openFlyout===`more`),this.tfMoreBtn&&this.applyTfMoreStyles(e,!this.tfBtns.has(this.currentTf)),this.priceSourceBtn&&this.applyTfPillStyles(this.priceSourceBtn,e,!1),this.flyout.style.setProperty(`--act-adv-row-hover`,e.ui.accentBg)}setSeries(e){this.currentSeries=e,this.seriesBtn.innerHTML=this.seriesIcon(e)}setPriceSource(e){this.currentPriceSource=e,this.priceSourceBtn&&(this.priceSourceBtn.textContent=e.toUpperCase())}setLayoutPresetIcon(e,t=!0){!this.layoutBtn||!this.layoutIconEl||(this.overflowMenu||(this.layoutIconEl.innerHTML=e,this.layoutIconEl.style.color=this.theme.ui.accent),this.styleLayoutBtn(this.layoutBtn,this.theme,t))}setLayoutActive(e){this.layoutBtn&&this.styleLayoutBtn(this.layoutBtn,this.theme,e)}getLayoutBtnEl(){return this.layoutBtn}getSnapshotBtnEl(){var e;return(e=this.snapshotBtn)==null?this.moreBtn:e}setTfcActive(e){}setActiveDuration(e){}reparentFlyout(e){this.flyout.parentElement!==e&&e.appendChild(this.flyout)}setMobileLayout(e){}closeDropdown(){this.flyout.style.display=`none`,this.openFlyout=null,this.flyout.style.padding=``,this.moreBtn&&this.applyOverflowIconBtnStyles(this.moreBtn,this.theme,!1)}get hasOpenDropdown(){return this.openFlyout!==null}destroy(){document.removeEventListener(`click`,this.docClickHandler),this.flyout.remove(),this.el.remove()}seriesIcon(e){return mn[e]?mn[e].replace(/width="\d+" height="\d+"/,`width="14" height="14"`):ar()}toggleFlyout(e,t){if(this.openFlyout===e){this.closeDropdown();return}this.closeDropdown(),this.openFlyout=e,this.buildFlyoutContent(e);let n=t.getBoundingClientRect();Object.assign(this.flyout.style,{display:`block`,left:`${n.left}px`,top:`${n.bottom+6}px`}),this.moreBtn&&this.applyOverflowIconBtnStyles(this.moreBtn,this.theme,e===`more`),requestAnimationFrame(()=>{let e=this.flyout.getBoundingClientRect();t===this.moreBtn&&(this.flyout.style.left=`${Math.max(8,n.right-e.width)}px`),e.right>window.innerWidth-8&&(this.flyout.style.left=`${window.innerWidth-e.width-8}px`),e.bottom>window.innerHeight-8&&(this.flyout.style.top=`${n.top-e.height-6}px`)})}buildFlyoutContent(e){if(this.flyout.innerHTML=``,this.flyout.style.minWidth=e===`series`?`152px`:e===`pricesource`?`120px`:e===`more`?`168px`:e===`timeframes`?`120px`:`180px`,this.flyout.style.setProperty(`--act-adv-row-hover`,this.theme.ui.accentBg),this.flyout.style.padding=e===`more`?`4px 0`:``,e===`timeframes`)for(let e of this.tfMore){var t;let n=this.makeRow((t=Qn[e])==null?e:t,e===this.currentTf,!1);n.dataset.testid=`tf-more-${e}`,n.setAttribute(`role`,`menuitem`),n.addEventListener(`click`,()=>{this.setTimeframe(e),this.onTimeframeChangeCb(e),this.closeDropdown()}),this.flyout.appendChild(n)}else if(e===`more`){let e=(e,t,n,r=!1)=>{let i=this.makeRow(e,r,!1,t);i.setAttribute(`role`,`menuitem`),i.addEventListener(`click`,e=>{e.stopPropagation(),n()}),this.flyout.appendChild(i)},t=()=>{let e=document.createElement(`div`);e.setAttribute(`role`,`separator`),Object.assign(e.style,{height:`1px`,background:this.theme.axisBorder,margin:`4px 0`}),this.flyout.appendChild(e)};e(`Chart type`,this.seriesIcon(this.currentSeries),()=>this.toggleFlyout(`series`,this.moreBtn)),this.onDrawingToolsToggleCb&&e(`Drawing tools`,ir(14),()=>{var e;this.closeDropdown(),(e=this.onDrawingToolsToggleCb)==null||e.call(this)},this.drawingActive),t(),e(`Indicators`,sr(14),()=>this.toggleFlyout(`indicators`,this.moreBtn)),this.onCompareClick&&e(`Compare`,cr(14),()=>{var e;this.closeDropdown(),(e=this.onCompareClick)==null||e.call(this)}),this.onAlertClick&&(t(),e(`Alert`,dr(14),()=>{var e;this.closeDropdown(),(e=this.onAlertClick)==null||e.call(this)})),t(),this.showSnapshotItem&&e(`Snapshot`,ur(14),()=>{var e;this.closeDropdown(),(e=this.onScreenshotClick)==null||e.call(this)}),e(`Chart settings`,or(14),()=>{this.closeDropdown(),this.onSettingsClickCb()})}else if(e===`pricesource`)for(let e of this.priceSourceOptions){let t=this.makeRow(e.toUpperCase(),e===this.currentPriceSource,!1);t.addEventListener(`click`,()=>{if(e!==this.currentPriceSource){var t;this.setPriceSource(e),(t=this.onPriceSourceChange)==null||t.call(this,e)}this.closeDropdown()}),this.flyout.appendChild(t)}else if(e===`series`)for(let e of[{value:`candlestick`,label:`Candlestick`},{value:`hollow`,label:`Hollow Candles`},{value:`ohlc`,label:`OHLC Bars`},{value:`line`,label:`Line`},{value:`area`,label:`Area`},{value:`heikinashi`,label:`Heikin Ashi`},{value:`volumecandles`,label:`Volume Candles`},{value:`linemarkers`,label:`Line with Markers`},{value:`step`,label:`Step Line`},{value:`hlcarea`,label:`HLC Area`},{value:`baseline`,label:`Baseline`},{value:`columns`,label:`Columns`},{value:`highlow`,label:`High Low`}]){let t=this.makeRow(e.label,e.value===this.currentSeries,!1,mn[e.value]);t.addEventListener(`click`,()=>{this.currentSeries=e.value,this.seriesBtn.innerHTML=this.seriesIcon(e.value),this.onSeriesChange(e.value),this.closeDropdown()}),this.flyout.appendChild(t)}else{let e=document.createElement(`div`);Object.assign(e.style,{position:`sticky`,top:`0`,zIndex:`1`,padding:`6px 8px`,background:this.theme.tooltip.background,borderBottom:`1px solid ${this.theme.axisBorder}`});let t=document.createElement(`input`);t.type=`text`,t.placeholder=`Search indicators…`,Object.assign(t.style,{width:`100%`,boxSizing:`border-box`,padding:`5px 8px`,background:this.theme.background,color:this.theme.tooltip.text,border:`1px solid ${this.theme.axisBorder}`,borderRadius:`4px`,fontSize:`16px`,outline:`none`}),e.appendChild(t),this.flyout.appendChild(e);let r=document.createElement(`div`);this.flyout.appendChild(r);let i=new Map;for(let e of this.indicatorOptions){var n;let t=(n=e.category)==null?``:n;i.has(t)||i.set(t,[]),i.get(t).push(e)}let a=e=>{r.innerHTML=``;let n=e.trim().toLowerCase();if(n)for(let e of this.indicatorOptions){if(!e.label.toLowerCase().includes(n)&&!e.value.toLowerCase().includes(n))continue;let i=this.activeIndicators.has(e.value),o=er.has(e.value)&&!this.volHasData,s=this.makeRow(e.label,i,o);o||s.addEventListener(`click`,()=>{this.onAddIndicator(e.value),a(t.value)}),r.appendChild(s)}else for(let[e,n]of i){e&&r.appendChild(this.makeCategoryHeader(e));for(let e of n){let n=this.activeIndicators.has(e.value),i=er.has(e.value)&&!this.volHasData,o=this.makeRow(e.label,n,i);i||o.addEventListener(`click`,()=>{this.onAddIndicator(e.value),a(t.value)}),r.appendChild(o)}}};a(``),t.addEventListener(`input`,()=>a(t.value)),requestAnimationFrame(()=>t.focus({preventScroll:!0}))}}updateIndBtnLabel(){let e=this.activeIndicators.size,t=this.indBtn.querySelector(`span:last-child`);t&&(t.textContent=e>0?`Indicators (${e})`:`Indicators`)}applyBarStyles(e){let t=this.overflowMenu;Object.assign(this.el.style,{display:`flex`,alignItems:`center`,gap:t?`2px`:`4px`,paddingLeft:t?`6px`:`8px`,paddingRight:t?`6px`:`8px`,height:t?`32px`:`36px`,borderBottom:`1px solid ${e.axisBorder}`,boxSizing:`border-box`,flexShrink:`0`,background:e.background})}applyFlyoutStyles(e){Object.assign(this.flyout.style,{position:`fixed`,display:`none`,zIndex:`10000`,background:e.tooltip.background,border:`1px solid ${e.axisBorder}`,borderRadius:`6px`,boxShadow:`0 4px 16px rgba(0,0,0,0.35)`,overflowY:`auto`,maxHeight:`320px`})}makeGroup(){let e=document.createElement(`div`);return Object.assign(e.style,{display:`flex`,alignItems:`center`,gap:`2px`,paddingRight:`8px`,borderRight:`1px solid ${this.theme.axisBorder}`}),e}makeIconBtn(e,t,n,r){let i=document.createElement(`button`);return i.title=t,i.innerHTML=e,this.applyIconBtnStyles(i,n,r),this.addHover(i,n),i}applyIconBtnStyles(e,t,n){e.dataset.active=String(n),Object.assign(e.style,{height:`28px`,width:`28px`,display:`flex`,alignItems:`center`,justifyContent:`center`,borderRadius:`2px`,border:`none`,background:n?t.ui.accentBg:`transparent`,color:n?t.ui.accent:t.topBar.btnColor,cursor:`pointer`,padding:`0`,flexShrink:`0`,transition:`color 0.15s, background-color 0.15s`})}applyCrosshairBtnStyles(e,t,n){e.dataset.active=String(n);let r=n?`Disable crosshair`:`Enable crosshair`;e.title=r,e.setAttribute(`aria-label`,r),e.setAttribute(`aria-pressed`,String(n)),Object.assign(e.style,{height:`24px`,width:`24px`,boxSizing:`border-box`,display:`flex`,alignItems:`center`,justifyContent:`center`,borderRadius:`2px`,border:`1px solid ${n?G(t.ui.accent,.3):`transparent`}`,background:n?G(t.ui.accent,.1):`transparent`,color:n?t.ui.accent:t.topBar.btnColor,cursor:`pointer`,padding:`0`,flexShrink:`0`,transition:`color 0.15s, background-color 0.15s, border-color 0.15s`})}applyPnlPillBtnStyles(e,t,n){e.dataset.active=String(n);let r=(n?`Hide P/L pill for {symbol}`:`Show P/L pill for {symbol}`).replace(/\{symbol\}/g,this.pnlPillSymbol);e.title=r,e.setAttribute(`aria-label`,r),e.setAttribute(`aria-pressed`,String(n)),Object.assign(e.style,{height:`24px`,boxSizing:`border-box`,display:`flex`,alignItems:`center`,gap:`4px`,padding:`0 6px`,borderRadius:`2px`,border:`1px solid ${n?G(t.ui.accent,.3):`transparent`}`,background:n?G(t.ui.accent,.1):`transparent`,color:n?t.ui.accent:t.topBar.btnColor,cursor:`pointer`,flexShrink:`0`,transition:`color 0.15s, background-color 0.15s, border-color 0.15s`})}applyOverflowIconBtnStyles(e,t,n){e.dataset.active=String(n),Object.assign(e.style,{height:`24px`,width:`24px`,boxSizing:`border-box`,display:`flex`,alignItems:`center`,justifyContent:`center`,gap:`0`,padding:`0`,borderRadius:`2px`,border:`1px solid ${n?G(t.ui.accent,.3):`transparent`}`,background:n?G(t.ui.accent,.1):`transparent`,color:n?t.ui.accent:t.topBar.btnColor,cursor:`pointer`,flexShrink:`0`,whiteSpace:`nowrap`,transition:`color 0.15s, background-color 0.15s, border-color 0.15s`})}styleLayoutBtn(e,t,n){this.overflowMenu?this.applyOverflowIconBtnStyles(e,t,n):this.applyTextBtnStyles(e,t,n)}makeTextBtn(e,t,n,r){let i=document.createElement(`button`);i.setAttribute(`aria-label`,t),this.applyTextBtnStyles(i,n,r);let a=document.createElement(`span`);a.style.display=`flex`,a.style.alignItems=`center`,a.innerHTML=e;let o=document.createElement(`span`);return o.textContent=t,i.appendChild(a),i.appendChild(o),this.addHover(i,n),i}applyTextBtnStyles(e,t,n){e.dataset.active=String(n),Object.assign(e.style,{display:`flex`,alignItems:`center`,gap:`4px`,paddingLeft:`8px`,paddingRight:`8px`,height:`28px`,fontSize:`12px`,fontWeight:`600`,fontFamily:`inherit`,borderRadius:`2px`,border:`none`,background:n?t.ui.accentBg:`transparent`,color:n?t.ui.accent:t.topBar.btnColor,cursor:`pointer`,padding:`0 8px`,flexShrink:`0`,whiteSpace:`nowrap`,transition:`color 0.15s, background-color 0.15s`})}applyTfPillStyles(e,t,n){if(e.dataset.active=String(n),this.overflowMenu){Object.assign(e.style,{paddingLeft:`6px`,paddingRight:`6px`,height:`24px`,fontSize:`10.5px`,fontFamily:`inherit`,fontWeight:`600`,borderRadius:`2px`,border:`none`,background:`transparent`,color:n?t.tooltip.text:t.topBar.btnColor,cursor:`pointer`,transition:`color 0.15s, background-color 0.15s`});return}Object.assign(e.style,{paddingLeft:`8px`,paddingRight:`8px`,height:`28px`,fontSize:`12px`,fontFamily:`"JetBrains Mono",ui-monospace,Menlo,Monaco,monospace`,fontWeight:`600`,borderRadius:`2px`,border:`none`,background:n?t.ui.accentBg:`transparent`,color:n?t.ui.accent:t.topBar.btnColor,cursor:`pointer`,transition:`color 0.15s, background-color 0.15s`})}applyTfMoreStyles(e,t){this.tfMoreBtn&&(this.tfMoreBtn.dataset.active=String(t),Object.assign(this.tfMoreBtn.style,{height:`24px`,width:`20px`,display:`flex`,alignItems:`center`,justifyContent:`center`,padding:`0`,borderRadius:`2px`,border:`none`,background:`transparent`,color:t?e.tooltip.text:e.topBar.btnColor,cursor:`pointer`,flexShrink:`0`,transition:`color 0.15s, background-color 0.15s`}))}addHover(e,t){e.addEventListener(`mouseenter`,()=>{e.dataset.active!==`true`&&(e.style.background=`rgb(var(--color-secondary-700,36 36 41))`,e.style.color=`rgb(var(--color-secondary-100,250 250 250))`)}),e.addEventListener(`mouseleave`,()=>{e.dataset.active!==`true`&&(e.style.background=`transparent`,e.style.color=t.topBar.btnColor)})}makeCategoryHeader(e){var t;let n=document.createElement(`div`);return Object.assign(n.style,{padding:`6px 12px 4px`,fontSize:`10px`,fontWeight:`600`,letterSpacing:`0.08em`,color:(t=this.theme.topBar.flyoutCategoryColor)==null?this.theme.axisText:t,textTransform:`uppercase`,opacity:`0.55`,marginTop:`2px`}),n.textContent=e,n}makeRow(e,t,n,r){let i=document.createElement(`button`);if(i.classList.add(`act-adv-flyout-row`),Object.assign(i.style,{width:`100%`,padding:`7px 12px`,background:t?this.theme.ui.accentBg:`transparent`,border:`none`,borderLeft:t?`2px solid ${this.theme.ui.accent}`:`2px solid transparent`,color:n?this.theme.ui.disabledText:t?this.theme.ui.accent:this.theme.topBar.flyoutRowColor,fontSize:`13px`,fontFamily:`inherit`,textAlign:`left`,cursor:n?`not-allowed`:`pointer`,display:`flex`,alignItems:`center`,gap:`8px`,boxSizing:`border-box`,opacity:n?`0.45`:`1`,transition:`background 0.1s`}),r){let e=document.createElement(`span`);Object.assign(e.style,{display:`flex`,alignItems:`center`,flexShrink:`0`,opacity:t?`1`:`0.7`}),e.innerHTML=r;let n=e.querySelector(`svg`);n&&(n.setAttribute(`width`,`13`),n.setAttribute(`height`,`13`)),i.appendChild(e)}let a=document.createElement(`span`);if(a.style.flex=`1`,a.textContent=e,i.appendChild(a),t){let e=document.createElement(`span`);e.style.color=this.theme.ui.accent,e.innerHTML=kn,i.appendChild(e)}return i}},xr=[`1m`,`5m`,`15m`,`1h`,`4h`,`1D`,`1W`],Sr={"1m":`1m`,"3m":`3m`,"4m":`4m`,"5m":`5m`,"10m":`10m`,"15m":`15m`,"30m":`30m`,"1h":`1H`,"4h":`4H`,"1D":`1D`,"1W":`1W`},Cr=new Set([`VOL`,`VWAP`,`OBV`,`A/D`,`MFI`,`CMF`]);function wr(e,t){return`<svg viewBox="0 0 24 24" width="${e}" height="${e}" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${t}</svg>`}var Tr=(e=12)=>wr(e,`<line x1="18" x2="18" y1="20" y2="10"/><line x1="12" x2="12" y1="20" y2="4"/><line x1="6" x2="6" y1="20" y2="14"/>`),Er=(e=12)=>`<svg viewBox="0 0 24 24" width="${e}" height="${e}" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M4 5h6c1 0 1.5.5 1.5 1.5v0c0 1-.5 1.5-1.5 1.5H5"/><path d="M5 12h5"/><path d="M5 19V5"/><path d="m13 9 6 10"/><path d="M19 9 13 19"/></svg>`;function Dr(){if(document.getElementById(`act-compact-toolbar-styles`))return;let e=document.createElement(`style`);e.id=`act-compact-toolbar-styles`,e.textContent=`
|
|
252
260
|
.act-compact-flyout::-webkit-scrollbar { width: 4px; }
|
|
253
261
|
.act-compact-flyout::-webkit-scrollbar-track { background: transparent; }
|
|
254
262
|
.act-compact-flyout::-webkit-scrollbar-thumb { background: rgba(120,130,150,0.35); border-radius: 4px; }
|
|
255
263
|
.act-compact-flyout::-webkit-scrollbar-thumb:hover { background: rgba(120,130,150,0.6); }
|
|
256
264
|
.act-compact-flyout-row:hover { background: var(--act-compact-row-hover) !important; }
|
|
257
|
-
`,document.head.appendChild(e)}var sr=class{constructor(e,t,n,r,i,a){this.onSeriesChange=e,this.onAddIndicator=n,this.tfBtns=new Map,this.indicatorOptions=[],this.activeIndicators=new Set,this.volHasData=!0,this.openFlyout=null,this.theme=a,this.currentSeries=r,this.currentTf=i,or(),this.flyout=document.createElement(`div`),this.flyout.classList.add(`act-compact-flyout`),this.applyFlyoutStyles(a),document.body.appendChild(this.flyout),this.el=document.createElement(`div`),this.applyBarStyles(a);for(let e of er){var o;let n=(o=tr[e])==null?e:o,r=document.createElement(`button`);r.dataset.testid=`compact-tf-${n}`,r.textContent=n,this.applyTfPillStyles(r,a,e===i),r.addEventListener(`click`,n=>{n.stopPropagation(),this.setTimeframe(e),t(e)}),this.tfBtns.set(e,r),this.el.appendChild(r)}this.seriesBtn=this.makeIconBtn(this.seriesIcon(r),`Chart type`,a),this.seriesBtn.addEventListener(`click`,e=>{e.stopPropagation(),this.toggleFlyout(`series`,this.seriesBtn)}),this.el.appendChild(this.seriesBtn),this.indBtn=this.makeIconBtn(ar(),`Indicators`,a),this.indBtn.dataset.testid=`compact-indicators-btn`,this.indBtn.addEventListener(`click`,e=>{e.stopPropagation(),this.toggleFlyout(`indicators`,this.indBtn)}),this.el.appendChild(this.indBtn),this.docClickHandler=()=>this.closeDropdown(),document.addEventListener(`click`,this.docClickHandler)}setTimeframe(e){let t=this.tfBtns.get(this.currentTf);t&&this.applyTfPillStyles(t,this.theme,!1),this.currentTf=e;let n=this.tfBtns.get(e);n&&this.applyTfPillStyles(n,this.theme,!0)}setSeries(e){this.currentSeries=e,this.seriesBtn.innerHTML=this.seriesIcon(e)}setIndicatorOptions(e){this.indicatorOptions=e}setIndicatorOptionActive(e,t,n){t?this.activeIndicators.add(e):this.activeIndicators.delete(e),this.updateIndBadge()}setVolumeControl(e,t){this.volHasData=t}setTheme(e){this.theme=e,this.applyBarStyles(e),this.applyFlyoutStyles(e);for(let[t,n]of this.tfBtns)this.applyTfPillStyles(n,e,t===this.currentTf);this.applyIconBtnStyles(this.seriesBtn,e),this.applyIconBtnStyles(this.indBtn,e),this.flyout.style.setProperty(`--act-compact-row-hover`,e.ui.accentBg)}closeDropdown(){this.flyout.style.display=`none`,this.openFlyout=null}get hasOpenDropdown(){return this.openFlyout!==null}destroy(){document.removeEventListener(`click`,this.docClickHandler),this.flyout.remove(),this.el.remove()}setFullscreen(e){}setDrawingsBtnActive(e){}setActiveDuration(e){}setTfcActive(e){}setLayoutPresetIcon(e,t){}setLayoutActive(e){}getLayoutBtnEl(){return null}getSnapshotBtnEl(){return null}reparentFlyout(e){this.flyout.parentElement!==e&&e.appendChild(this.flyout)}setMobileLayout(e){}seriesIcon(e){return nn[e]?nn[e].replace(/width="\d+" height="\d+"/,`width="12" height="12"`):ir()}toggleFlyout(e,t){if(this.openFlyout===e){this.closeDropdown();return}this.closeDropdown(),this.openFlyout=e,this.buildFlyoutContent(e);let n=t.getBoundingClientRect();Object.assign(this.flyout.style,{display:`block`,left:`${n.left}px`,top:`${n.bottom+4}px`}),requestAnimationFrame(()=>{let e=this.flyout.getBoundingClientRect();e.right>window.innerWidth-8&&(this.flyout.style.left=`${window.innerWidth-e.width-8}px`),e.bottom>window.innerHeight-8&&(this.flyout.style.top=`${n.top-e.height-4}px`)})}buildFlyoutContent(e){if(this.flyout.innerHTML=``,this.flyout.style.minWidth=e===`series`?`152px`:`200px`,this.flyout.style.setProperty(`--act-compact-row-hover`,this.theme.ui.accentBg),e===`series`)for(let e of[{value:`candlestick`,label:`Candlestick`},{value:`hollow`,label:`Hollow Candles`},{value:`ohlc`,label:`OHLC Bars`},{value:`line`,label:`Line`},{value:`area`,label:`Area`},{value:`heikinashi`,label:`Heikin Ashi`},{value:`volumecandles`,label:`Volume Candles`},{value:`linemarkers`,label:`Line with Markers`},{value:`step`,label:`Step Line`},{value:`hlcarea`,label:`HLC Area`},{value:`baseline`,label:`Baseline`},{value:`columns`,label:`Columns`},{value:`highlow`,label:`High Low`}]){let t=this.makeRow(e.label,e.value===this.currentSeries,!1,nn[e.value]);t.addEventListener(`click`,()=>{this.currentSeries=e.value,this.seriesBtn.innerHTML=this.seriesIcon(e.value),this.onSeriesChange(e.value),this.closeDropdown()}),this.flyout.appendChild(t)}else{let e=document.createElement(`div`);Object.assign(e.style,{position:`sticky`,top:`0`,zIndex:`1`,padding:`6px 8px`,background:this.theme.tooltip.background,borderBottom:`1px solid ${this.theme.axisBorder}`});let n=document.createElement(`input`);n.type=`text`,n.placeholder=`Search indicators…`,Object.assign(n.style,{width:`100%`,boxSizing:`border-box`,padding:`5px 8px`,background:this.theme.background,color:this.theme.tooltip.text,border:`1px solid ${this.theme.axisBorder}`,borderRadius:`4px`,fontSize:`13px`,outline:`none`}),e.appendChild(n),this.flyout.appendChild(e);let r=document.createElement(`div`);this.flyout.appendChild(r);let i=new Map;for(let e of this.indicatorOptions){var t;let n=(t=e.category)==null?``:t;i.has(n)||i.set(n,[]),i.get(n).push(e)}let a=e=>{r.innerHTML=``;let t=e.trim().toLowerCase();if(t)for(let e of this.indicatorOptions){if(!e.label.toLowerCase().includes(t)&&!e.value.toLowerCase().includes(t))continue;let i=this.activeIndicators.has(e.value),o=nr.has(e.value)&&!this.volHasData,s=this.makeRow(e.label,i,o);o||s.addEventListener(`click`,()=>{this.onAddIndicator(e.value),a(n.value)}),r.appendChild(s)}else for(let[e,t]of i){e&&r.appendChild(this.makeCategoryHeader(e));for(let e of t){let t=this.activeIndicators.has(e.value),i=nr.has(e.value)&&!this.volHasData,o=this.makeRow(e.label,t,i);i||o.addEventListener(`click`,()=>{this.onAddIndicator(e.value),a(n.value)}),r.appendChild(o)}}};a(``),n.addEventListener(`input`,()=>a(n.value)),requestAnimationFrame(()=>n.focus({preventScroll:!0}))}}updateIndBadge(){let e=this.activeIndicators.size;this.indBtn.dataset.count=String(e),this.indBtn.style.boxShadow=e>0?`inset 0 -2px 0 0 ${this.theme.ui.accent}`:`none`}applyBarStyles(e){Object.assign(this.el.style,{display:`flex`,alignItems:`center`,gap:`2px`,paddingLeft:`6px`,paddingRight:`6px`,height:`26px`,borderBottom:`1px solid ${e.axisBorder}`,boxSizing:`border-box`,flexShrink:`0`,background:e.background,fontFamily:`inherit`})}applyFlyoutStyles(e){Object.assign(this.flyout.style,{position:`fixed`,display:`none`,zIndex:`10000`,background:e.tooltip.background,border:`1px solid ${e.axisBorder}`,borderRadius:`6px`,boxShadow:`0 4px 16px rgba(0,0,0,0.35)`,overflowY:`auto`,maxHeight:`320px`})}makeIconBtn(e,t,n){let r=document.createElement(`button`);return r.title=t,r.innerHTML=e,this.applyIconBtnStyles(r,n),this.addHover(r,n),r}applyIconBtnStyles(e,t){Object.assign(e.style,{height:`20px`,width:`20px`,display:`flex`,alignItems:`center`,justifyContent:`center`,borderRadius:`2px`,border:`none`,background:`transparent`,color:t.topBar.btnColor,cursor:`pointer`,padding:`0`,flexShrink:`0`,transition:`color 0.15s, background-color 0.15s`})}applyTfPillStyles(e,t,n){e.dataset.active=String(n),Object.assign(e.style,{paddingLeft:`6px`,paddingRight:`6px`,height:`20px`,fontSize:`11px`,fontFamily:`"JetBrains Mono",ui-monospace,Menlo,Monaco,monospace`,fontWeight:`600`,borderRadius:`2px`,border:`none`,background:n?t.ui.accentBg:`transparent`,color:n?t.ui.accent:t.topBar.btnColor,cursor:`pointer`,transition:`color 0.15s, background-color 0.15s`})}addHover(e,t){e.addEventListener(`mouseenter`,()=>{e.style.background=t.ui.accentBg,e.style.color=t.ui.accent}),e.addEventListener(`mouseleave`,()=>{e.style.background=`transparent`,e.style.color=t.topBar.btnColor})}makeCategoryHeader(e){let t=document.createElement(`div`);return Object.assign(t.style,{padding:`6px 12px 4px`,fontSize:`10px`,fontWeight:`600`,letterSpacing:`0.08em`,color:this.theme.axisText,textTransform:`uppercase`,opacity:`0.55`,marginTop:`2px`}),t.textContent=e,t}makeRow(e,t,n,r){let i=document.createElement(`button`);if(i.classList.add(`act-compact-flyout-row`),Object.assign(i.style,{width:`100%`,padding:`7px 12px`,background:t?this.theme.ui.accentBg:`transparent`,border:`none`,borderLeft:t?`2px solid ${this.theme.ui.accent}`:`2px solid transparent`,color:n?this.theme.axisText:t?this.theme.ui.accent:this.theme.topBar.btnColor,fontSize:`13px`,fontFamily:`inherit`,textAlign:`left`,cursor:n?`not-allowed`:`pointer`,display:`flex`,alignItems:`center`,gap:`8px`,boxSizing:`border-box`,opacity:n?`0.45`:`1`,transition:`background 0.1s`}),r){let e=document.createElement(`span`);Object.assign(e.style,{display:`flex`,alignItems:`center`,flexShrink:`0`,opacity:t?`1`:`0.7`}),e.innerHTML=r;let n=e.querySelector(`svg`);n&&(n.setAttribute(`width`,`13`),n.setAttribute(`height`,`13`)),i.appendChild(e)}let a=document.createElement(`span`);return a.textContent=e,i.appendChild(a),i}},cr=`JetBrains Mono, ui-monospace, Menlo, Monaco, monospace`,lr=`"calt" 0, "liga" 0, "tnum"`,ur=`system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif`;function dr(e,t,n=1.75){return`<svg viewBox="0 0 24 24" width="${e}" height="${e}" fill="none" stroke="currentColor" stroke-width="${n}" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${t}</svg>`}var fr={crosshair:()=>dr(16,`<circle cx="12" cy="12" r="10"/><line x1="22" x2="18" y1="12" y2="12"/><line x1="6" x2="2" y1="12" y2="12"/><line x1="12" x2="12" y1="6" y2="2"/><line x1="12" x2="12" y1="22" y2="18"/>`),trend:()=>dr(16,`<polyline points="22 7 13.5 15.5 8.5 10.5 2 17"/><polyline points="16 7 22 7 22 13"/>`),fib:()=>dr(16,`<path d="M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z"/><path d="M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12"/><path d="M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17"/>`),rect:()=>dr(16,`<rect width="18" height="18" x="3" y="3" rx="2"/>`),ruler:()=>dr(16,`<path d="M21.3 15.3a2.4 2.4 0 0 1 0 3.4l-2.6 2.6a2.4 2.4 0 0 1-3.4 0L2.7 8.7a2.41 2.41 0 0 1 0-3.4l2.6-2.6a2.41 2.41 0 0 1 3.4 0Z"/><path d="m14.5 12.5 2-2"/><path d="m11.5 9.5 2-2"/><path d="m8.5 6.5 2-2"/><path d="m17.5 15.5 2-2"/>`),text:()=>dr(16,`<polyline points="4 7 4 4 20 4 20 7"/><line x1="9" x2="15" y1="20" y2="20"/><line x1="12" x2="12" y1="4" y2="20"/>`),wave:()=>dr(16,`<path d="M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2"/>`),magnet:()=>dr(16,`<path d="m6 15-4-4 6.75-6.77a7.79 7.79 0 0 1 11 11L13 22l-4-4 6.39-6.36a2.14 2.14 0 0 0-3-3L6 15"/><path d="m5 8 4 4"/><path d="m12 15 4 4"/>`),eraser:()=>dr(16,`<path d="m7 21-4.3-4.3c-1-1-1-2.5 0-3.4l9.6-9.6c1-1 2.5-1 3.4 0l5.6 5.6c1 1 1 2.5 0 3.4L13 21"/><path d="M22 21H7"/><path d="m5 11 9 9"/>`),close:()=>dr(16,`<path d="M18 6 6 18"/><path d="m6 6 12 12"/>`,2),plus:()=>dr(18,`<path d="M5 12h14"/><path d="M12 5v14"/>`,2)},pr=[{id:`cross`,label:`Crosshair`,testid:`m-tool-cross`,icon:fr.crosshair,action:{kind:`tool`,tool:null}},{id:`trend`,label:`Trend Line`,testid:`m-tool-trend`,icon:fr.trend,action:{kind:`tool`,tool:`trendLine`}},{id:`fib`,label:`Fibonacci`,testid:`m-tool-fib`,icon:fr.fib,action:{kind:`tool`,tool:`fibRetracement`}},{id:`rect`,label:`Rectangle`,testid:`m-tool-rect`,icon:fr.rect,action:{kind:`tool`,tool:`rectangle`}},{id:`measure`,label:`Ruler`,testid:`m-tool-measure`,icon:fr.ruler,action:{kind:`tool`,tool:`ruler`}},{id:`text`,label:`Text`,testid:`m-tool-text`,icon:fr.text,action:{kind:`tool`,tool:`text`}},{id:`wave`,label:`Elliott Wave`,testid:`m-tool-wave`,icon:fr.wave,action:{kind:`tool`,tool:`elliottImpulse`}},{id:`magnet`,label:`Magnet`,testid:`m-tool-magnet`,icon:fr.magnet,action:{kind:`magnet`}},{id:`eraser`,label:`Eraser`,testid:`m-tool-eraser`,icon:fr.eraser,action:{kind:`clearDrawings`}}],mr=[{shortName:`MA`,title:`MA 20`,subtitle:`Moving Average (20)`,testid:`m-indicator-MA20`,params:{period:20}},{shortName:`EMA`,title:`EMA 50`,subtitle:`Exp. Moving Avg (50)`,testid:`m-indicator-EMA50`,params:{period:50}},{shortName:`BB`,title:`Bollinger`,subtitle:`Bollinger Bands`,testid:`m-indicator-BB`},{shortName:`RSI`,title:`RSI`,subtitle:`Relative Strength Index`,testid:`m-indicator-RSI`},{shortName:`MACD`,title:`MACD`,subtitle:`MACD 12/26/9`,testid:`m-indicator-MACD`},{shortName:`VOL`,title:`Volume`,subtitle:`Volume Histogram`,testid:`m-indicator-VOL`,isVolume:!0}],hr=class{constructor(e,t,n){this.backdrop=null,this.sheet=null,this.open=!1,this.activeTool=null,this.indicatorCounts=new Map,this.toolCells=new Map,this.indicatorRows=new Map,this.theme=e,this.controller=t,this.fontFamily=n==null?cr:n}get isOpen(){return this.open}toggle(){this.open?this.close():this.show()}show(){this.open||(this.build(!0),this.open=!0)}close(){if(!this.open)return;this.open=!1;let e=this.backdrop,t=this.sheet;if(this.backdrop=null,this.sheet=null,this.toolCells.clear(),this.indicatorRows.clear(),!e)return;e.style.opacity=`0`,t&&(t.style.transform=`translateY(100%)`);let n=()=>e.remove();e.addEventListener(`transitionend`,n,{once:!0}),setTimeout(n,280)}build(e){let t=this.theme,n=document.createElement(`div`);Object.assign(n.style,{position:`fixed`,inset:`0`,zIndex:`2147483000`,background:`rgba(0,0,0,0.45)`,display:`flex`,alignItems:`flex-end`,justifyContent:`center`,fontFamily:this.fontFamily,fontFeatureSettings:lr,fontVariantNumeric:`tabular-nums`,opacity:e?`0`:`1`,transition:`opacity 0.22s ease`}),n.addEventListener(`click`,e=>{e.target===n&&this.close()});let r=document.createElement(`div`);Object.assign(r.style,{width:`100%`,maxWidth:`520px`,maxHeight:`85vh`,display:`flex`,flexDirection:`column`,background:t.background,borderTopLeftRadius:`14px`,borderTopRightRadius:`14px`,borderTop:`1px solid ${t.axisBorder}`,paddingBottom:`env(safe-area-inset-bottom)`,boxShadow:`0 -8px 32px rgba(0,0,0,0.45)`,transform:e?`translateY(100%)`:`translateY(0)`,transition:`transform 0.26s cubic-bezier(0.32, 0.72, 0, 1)`,willChange:`transform`}),r.addEventListener(`click`,e=>e.stopPropagation()),r.appendChild(this.buildHeader());let i=document.createElement(`div`);Object.assign(i.style,{flex:`1`,overflowY:`auto`}),i.appendChild(this.buildDrawingSection()),i.appendChild(this.buildIndicatorSection()),r.appendChild(i),n.appendChild(r),document.body.appendChild(n),this.backdrop=n,this.sheet=r,e&&requestAnimationFrame(()=>requestAnimationFrame(()=>{n.style.opacity=`1`,r.style.transform=`translateY(0)`}))}sectionLabel(e){let t=document.createElement(`div`);return t.className=`font-mono`,t.textContent=e,Object.assign(t.style,{fontSize:`10px`,textTransform:`uppercase`,letterSpacing:`0.14em`,color:this.theme.topBar.btnColor,fontFamily:this.fontFamily}),t}buildHeader(){let e=this.theme,t=document.createElement(`div`);Object.assign(t.style,{display:`flex`,alignItems:`center`,justifyContent:`space-between`,padding:`16px`,borderBottom:`1px solid ${e.axisBorder}`,flexShrink:`0`});let n=document.createElement(`div`),r=this.sectionLabel(`Chart Tools`),i=document.createElement(`div`);i.textContent=`Draw & Indicators`,Object.assign(i.style,{fontSize:`16px`,fontWeight:`700`,letterSpacing:`-0.01em`,color:e.axisText,marginTop:`2px`,fontFamily:ur}),n.appendChild(r),n.appendChild(i);let a=document.createElement(`button`);return a.setAttribute(`data-testid`,`m-tools-close`),a.innerHTML=fr.close(),Object.assign(a.style,{height:`32px`,width:`32px`,borderRadius:`50%`,border:`none`,background:e.ui.accentBg,color:e.axisText,cursor:`pointer`,display:`flex`,alignItems:`center`,justifyContent:`center`,flexShrink:`0`}),a.addEventListener(`click`,e=>{e.stopPropagation(),this.close()}),t.appendChild(n),t.appendChild(a),t}buildDrawingSection(){let e=this.theme,t=document.createElement(`div`);Object.assign(t.style,{padding:`16px`,borderBottom:`1px solid ${e.axisBorder}`});let n=document.createElement(`div`);Object.assign(n.style,{marginBottom:`12px`}),n.appendChild(this.sectionLabel(`Drawing`)),t.appendChild(n);let r=document.createElement(`div`);Object.assign(r.style,{display:`grid`,gridTemplateColumns:`repeat(3, 1fr)`,gap:`8px`});for(let e of pr){let t=document.createElement(`button`);t.setAttribute(`data-testid`,e.testid),t.innerHTML=`${e.icon()}<span class="font-mono" style="font-size:10px;font-weight:600;">${e.label}</span>`,Object.assign(t.style,{display:`flex`,flexDirection:`column`,alignItems:`center`,gap:`6px`,padding:`12px 4px`,borderRadius:`8px`,cursor:`pointer`,fontFamily:this.fontFamily,transition:`background 0.15s, color 0.15s, border-color 0.15s`}),t.addEventListener(`click`,t=>{t.stopPropagation(),this.onToolTap(e)}),this.toolCells.set(e.id,t),r.appendChild(t)}return t.appendChild(r),this.refreshToolStyles(),t}buildIndicatorSection(){let e=this.theme,t=document.createElement(`div`);Object.assign(t.style,{padding:`16px`});let n=document.createElement(`div`);Object.assign(n.style,{display:`flex`,alignItems:`center`,justifyContent:`space-between`,marginBottom:`12px`}),n.appendChild(this.sectionLabel(`Indicators`));let r=document.createElement(`button`);r.setAttribute(`data-testid`,`m-tools-clear-indicators`),r.className=`font-mono`,r.textContent=`Clear All`,Object.assign(r.style,{fontSize:`10px`,textTransform:`uppercase`,letterSpacing:`0.14em`,color:e.ui.accent,background:`none`,border:`none`,cursor:`pointer`,fontFamily:this.fontFamily}),r.addEventListener(`click`,e=>{e.stopPropagation(),this.clearIndicators()}),n.appendChild(r),t.appendChild(n);let i=document.createElement(`div`);Object.assign(i.style,{display:`flex`,flexDirection:`column`,gap:`6px`});for(let t of mr){let n=document.createElement(`button`);n.setAttribute(`data-testid`,t.testid),n.innerHTML=`
|
|
265
|
+
`,document.head.appendChild(e)}var Or=class{constructor(e,t,n,r,i,a,o=!1,s=!0,c=null){this.onSeriesChange=e,this.onAddIndicator=n,this.onCrosshairToggle=c,this.crosshairBtn=null,this.crosshairEnabled=!0,this.tfBtns=new Map,this.indicatorOptions=[],this.activeIndicators=new Set,this.volHasData=!0,this.openFlyout=null,this.theme=a,this.currentSeries=r,this.currentTf=i,Dr(),this.flyout=document.createElement(`div`),this.flyout.classList.add(`act-compact-flyout`),this.applyFlyoutStyles(a),document.body.appendChild(this.flyout),this.el=document.createElement(`div`),this.applyBarStyles(a);for(let e of xr){var l;let n=(l=Sr[e])==null?e:l,r=document.createElement(`button`);r.dataset.testid=`compact-tf-${n}`,r.textContent=n,this.applyTfPillStyles(r,a,e===i),r.addEventListener(`click`,n=>{n.stopPropagation(),this.setTimeframe(e),t(e)}),this.tfBtns.set(e,r),this.el.appendChild(r)}this.seriesBtn=this.makeIconBtn(this.seriesIcon(r),`Chart type`,a),this.seriesBtn.addEventListener(`click`,e=>{e.stopPropagation(),this.toggleFlyout(`series`,this.seriesBtn)}),this.el.appendChild(this.seriesBtn),this.indBtn=this.makeIconBtn(Er(),`Indicators`,a),this.indBtn.dataset.testid=`compact-indicators-btn`,this.indBtn.addEventListener(`click`,e=>{e.stopPropagation(),this.toggleFlyout(`indicators`,this.indBtn)}),this.el.appendChild(this.indBtn),o&&(this.crosshairEnabled=s,this.crosshairBtn=document.createElement(`button`),this.crosshairBtn.type=`button`,this.crosshairBtn.dataset.testid=`chart-crosshair-toggle`,this.crosshairBtn.innerHTML=Rn,this.applyCrosshairBtnStyles(this.crosshairBtn,a,this.crosshairEnabled),this.crosshairBtn.addEventListener(`click`,e=>{var t;e.stopPropagation(),this.setCrosshairActive(!this.crosshairEnabled),(t=this.onCrosshairToggle)==null||t.call(this,this.crosshairEnabled)}),this.crosshairBtn.addEventListener(`mouseenter`,()=>{this.crosshairBtn&&!this.crosshairEnabled&&(this.crosshairBtn.style.background=this.theme.ui.accentBg)}),this.crosshairBtn.addEventListener(`mouseleave`,()=>{this.crosshairBtn&&!this.crosshairEnabled&&(this.crosshairBtn.style.background=`transparent`)}),this.el.appendChild(this.crosshairBtn)),this.docClickHandler=()=>this.closeDropdown(),document.addEventListener(`click`,this.docClickHandler)}setTimeframe(e){let t=this.tfBtns.get(this.currentTf);t&&this.applyTfPillStyles(t,this.theme,!1),this.currentTf=e;let n=this.tfBtns.get(e);n&&this.applyTfPillStyles(n,this.theme,!0)}setSeries(e){this.currentSeries=e,this.seriesBtn.innerHTML=this.seriesIcon(e)}setIndicatorOptions(e){this.indicatorOptions=e}setIndicatorOptionActive(e,t,n){t?this.activeIndicators.add(e):this.activeIndicators.delete(e),this.updateIndBadge()}setVolumeControl(e,t){this.volHasData=t}setCrosshairActive(e){this.crosshairEnabled=e,this.crosshairBtn&&this.applyCrosshairBtnStyles(this.crosshairBtn,this.theme,e)}setTheme(e){this.theme=e,this.applyBarStyles(e),this.applyFlyoutStyles(e);for(let[t,n]of this.tfBtns)this.applyTfPillStyles(n,e,t===this.currentTf);this.applyIconBtnStyles(this.seriesBtn,e),this.applyIconBtnStyles(this.indBtn,e),this.crosshairBtn&&this.applyCrosshairBtnStyles(this.crosshairBtn,e,this.crosshairEnabled),this.flyout.style.setProperty(`--act-compact-row-hover`,e.ui.accentBg)}closeDropdown(){this.flyout.style.display=`none`,this.openFlyout=null}get hasOpenDropdown(){return this.openFlyout!==null}destroy(){document.removeEventListener(`click`,this.docClickHandler),this.flyout.remove(),this.el.remove()}setFullscreen(e){}setDrawingsBtnActive(e){}setActiveDuration(e){}setTfcActive(e){}setLayoutPresetIcon(e,t){}setLayoutActive(e){}getLayoutBtnEl(){return null}getSnapshotBtnEl(){return null}reparentFlyout(e){this.flyout.parentElement!==e&&e.appendChild(this.flyout)}setMobileLayout(e){}seriesIcon(e){return mn[e]?mn[e].replace(/width="\d+" height="\d+"/,`width="12" height="12"`):Tr()}toggleFlyout(e,t){if(this.openFlyout===e){this.closeDropdown();return}this.closeDropdown(),this.openFlyout=e,this.buildFlyoutContent(e);let n=t.getBoundingClientRect();Object.assign(this.flyout.style,{display:`block`,left:`${n.left}px`,top:`${n.bottom+4}px`}),requestAnimationFrame(()=>{let e=this.flyout.getBoundingClientRect();e.right>window.innerWidth-8&&(this.flyout.style.left=`${window.innerWidth-e.width-8}px`),e.bottom>window.innerHeight-8&&(this.flyout.style.top=`${n.top-e.height-4}px`)})}buildFlyoutContent(e){if(this.flyout.innerHTML=``,this.flyout.style.minWidth=e===`series`?`152px`:`200px`,this.flyout.style.setProperty(`--act-compact-row-hover`,this.theme.ui.accentBg),e===`series`)for(let e of[{value:`candlestick`,label:`Candlestick`},{value:`hollow`,label:`Hollow Candles`},{value:`ohlc`,label:`OHLC Bars`},{value:`line`,label:`Line`},{value:`area`,label:`Area`},{value:`heikinashi`,label:`Heikin Ashi`},{value:`volumecandles`,label:`Volume Candles`},{value:`linemarkers`,label:`Line with Markers`},{value:`step`,label:`Step Line`},{value:`hlcarea`,label:`HLC Area`},{value:`baseline`,label:`Baseline`},{value:`columns`,label:`Columns`},{value:`highlow`,label:`High Low`}]){let t=this.makeRow(e.label,e.value===this.currentSeries,!1,mn[e.value]);t.addEventListener(`click`,()=>{this.currentSeries=e.value,this.seriesBtn.innerHTML=this.seriesIcon(e.value),this.onSeriesChange(e.value),this.closeDropdown()}),this.flyout.appendChild(t)}else{let e=document.createElement(`div`);Object.assign(e.style,{position:`sticky`,top:`0`,zIndex:`1`,padding:`6px 8px`,background:this.theme.tooltip.background,borderBottom:`1px solid ${this.theme.axisBorder}`});let n=document.createElement(`input`);n.type=`text`,n.placeholder=`Search indicators…`,Object.assign(n.style,{width:`100%`,boxSizing:`border-box`,padding:`5px 8px`,background:this.theme.background,color:this.theme.tooltip.text,border:`1px solid ${this.theme.axisBorder}`,borderRadius:`4px`,fontSize:`13px`,outline:`none`}),e.appendChild(n),this.flyout.appendChild(e);let r=document.createElement(`div`);this.flyout.appendChild(r);let i=new Map;for(let e of this.indicatorOptions){var t;let n=(t=e.category)==null?``:t;i.has(n)||i.set(n,[]),i.get(n).push(e)}let a=e=>{r.innerHTML=``;let t=e.trim().toLowerCase();if(t)for(let e of this.indicatorOptions){if(!e.label.toLowerCase().includes(t)&&!e.value.toLowerCase().includes(t))continue;let i=this.activeIndicators.has(e.value),o=Cr.has(e.value)&&!this.volHasData,s=this.makeRow(e.label,i,o);o||s.addEventListener(`click`,()=>{this.onAddIndicator(e.value),a(n.value)}),r.appendChild(s)}else for(let[e,t]of i){e&&r.appendChild(this.makeCategoryHeader(e));for(let e of t){let t=this.activeIndicators.has(e.value),i=Cr.has(e.value)&&!this.volHasData,o=this.makeRow(e.label,t,i);i||o.addEventListener(`click`,()=>{this.onAddIndicator(e.value),a(n.value)}),r.appendChild(o)}}};a(``),n.addEventListener(`input`,()=>a(n.value)),requestAnimationFrame(()=>n.focus({preventScroll:!0}))}}updateIndBadge(){let e=this.activeIndicators.size;this.indBtn.dataset.count=String(e),this.indBtn.style.boxShadow=e>0?`inset 0 -2px 0 0 ${this.theme.ui.accent}`:`none`}applyBarStyles(e){Object.assign(this.el.style,{display:`flex`,alignItems:`center`,gap:`2px`,paddingLeft:`6px`,paddingRight:`6px`,height:`26px`,borderBottom:`1px solid ${e.axisBorder}`,boxSizing:`border-box`,flexShrink:`0`,background:e.background,fontFamily:`inherit`})}applyFlyoutStyles(e){Object.assign(this.flyout.style,{position:`fixed`,display:`none`,zIndex:`10000`,background:e.tooltip.background,border:`1px solid ${e.axisBorder}`,borderRadius:`6px`,boxShadow:`0 4px 16px rgba(0,0,0,0.35)`,overflowY:`auto`,maxHeight:`320px`})}makeIconBtn(e,t,n){let r=document.createElement(`button`);return r.title=t,r.innerHTML=e,this.applyIconBtnStyles(r,n),this.addHover(r,n),r}applyCrosshairBtnStyles(e,t,n){e.dataset.active=String(n);let r=n?`Disable crosshair`:`Enable crosshair`;e.title=r,e.setAttribute(`aria-label`,r),e.setAttribute(`aria-pressed`,String(n)),Object.assign(e.style,{height:`20px`,width:`20px`,boxSizing:`border-box`,display:`flex`,alignItems:`center`,justifyContent:`center`,borderRadius:`2px`,border:`1px solid ${n?G(t.ui.accent,.3):`transparent`}`,background:n?G(t.ui.accent,.1):`transparent`,color:n?t.ui.accent:t.topBar.btnColor,cursor:`pointer`,padding:`0`,flexShrink:`0`,transition:`color 0.15s, background-color 0.15s, border-color 0.15s`})}applyIconBtnStyles(e,t){Object.assign(e.style,{height:`20px`,width:`20px`,display:`flex`,alignItems:`center`,justifyContent:`center`,borderRadius:`2px`,border:`none`,background:`transparent`,color:t.topBar.btnColor,cursor:`pointer`,padding:`0`,flexShrink:`0`,transition:`color 0.15s, background-color 0.15s`})}applyTfPillStyles(e,t,n){e.dataset.active=String(n),Object.assign(e.style,{paddingLeft:`6px`,paddingRight:`6px`,height:`20px`,fontSize:`11px`,fontFamily:`"JetBrains Mono",ui-monospace,Menlo,Monaco,monospace`,fontWeight:`600`,borderRadius:`2px`,border:`none`,background:n?t.ui.accentBg:`transparent`,color:n?t.ui.accent:t.topBar.btnColor,cursor:`pointer`,transition:`color 0.15s, background-color 0.15s`})}addHover(e,t){e.addEventListener(`mouseenter`,()=>{e.style.background=t.ui.accentBg,e.style.color=t.ui.accent}),e.addEventListener(`mouseleave`,()=>{e.style.background=`transparent`,e.style.color=t.topBar.btnColor})}makeCategoryHeader(e){let t=document.createElement(`div`);return Object.assign(t.style,{padding:`6px 12px 4px`,fontSize:`10px`,fontWeight:`600`,letterSpacing:`0.08em`,color:this.theme.axisText,textTransform:`uppercase`,opacity:`0.55`,marginTop:`2px`}),t.textContent=e,t}makeRow(e,t,n,r){let i=document.createElement(`button`);if(i.classList.add(`act-compact-flyout-row`),Object.assign(i.style,{width:`100%`,padding:`7px 12px`,background:t?this.theme.ui.accentBg:`transparent`,border:`none`,borderLeft:t?`2px solid ${this.theme.ui.accent}`:`2px solid transparent`,color:n?this.theme.axisText:t?this.theme.ui.accent:this.theme.topBar.btnColor,fontSize:`13px`,fontFamily:`inherit`,textAlign:`left`,cursor:n?`not-allowed`:`pointer`,display:`flex`,alignItems:`center`,gap:`8px`,boxSizing:`border-box`,opacity:n?`0.45`:`1`,transition:`background 0.1s`}),r){let e=document.createElement(`span`);Object.assign(e.style,{display:`flex`,alignItems:`center`,flexShrink:`0`,opacity:t?`1`:`0.7`}),e.innerHTML=r;let n=e.querySelector(`svg`);n&&(n.setAttribute(`width`,`13`),n.setAttribute(`height`,`13`)),i.appendChild(e)}let a=document.createElement(`span`);return a.textContent=e,i.appendChild(a),i}},kr=`JetBrains Mono, ui-monospace, Menlo, Monaco, monospace`,Ar=`"calt" 0, "liga" 0, "tnum"`,jr=`system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif`;function Mr(e,t,n=1.75){return`<svg viewBox="0 0 24 24" width="${e}" height="${e}" fill="none" stroke="currentColor" stroke-width="${n}" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${t}</svg>`}var Nr={crosshair:()=>Mr(16,`<circle cx="12" cy="12" r="10"/><line x1="22" x2="18" y1="12" y2="12"/><line x1="6" x2="2" y1="12" y2="12"/><line x1="12" x2="12" y1="6" y2="2"/><line x1="12" x2="12" y1="22" y2="18"/>`),trend:()=>Mr(16,`<polyline points="22 7 13.5 15.5 8.5 10.5 2 17"/><polyline points="16 7 22 7 22 13"/>`),fib:()=>Mr(16,`<path d="M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z"/><path d="M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12"/><path d="M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17"/>`),rect:()=>Mr(16,`<rect width="18" height="18" x="3" y="3" rx="2"/>`),longPos:()=>Mr(16,`<path d="M3 14h18"/><path d="M12 11V4"/><path d="m9 7 3-3 3 3"/><rect x="3" y="4" width="18" height="10" opacity="0.25"/>`),shortPos:()=>Mr(16,`<path d="M3 10h18"/><path d="M12 13v7"/><path d="m9 17 3 3 3-3"/><rect x="3" y="10" width="18" height="10" opacity="0.25"/>`),ruler:()=>Mr(16,`<path d="M21.3 15.3a2.4 2.4 0 0 1 0 3.4l-2.6 2.6a2.4 2.4 0 0 1-3.4 0L2.7 8.7a2.41 2.41 0 0 1 0-3.4l2.6-2.6a2.41 2.41 0 0 1 3.4 0Z"/><path d="m14.5 12.5 2-2"/><path d="m11.5 9.5 2-2"/><path d="m8.5 6.5 2-2"/><path d="m17.5 15.5 2-2"/>`),text:()=>Mr(16,`<polyline points="4 7 4 4 20 4 20 7"/><line x1="9" x2="15" y1="20" y2="20"/><line x1="12" x2="12" y1="4" y2="20"/>`),wave:()=>Mr(16,`<path d="M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2"/>`),magnet:()=>Mr(16,`<path d="m6 15-4-4 6.75-6.77a7.79 7.79 0 0 1 11 11L13 22l-4-4 6.39-6.36a2.14 2.14 0 0 0-3-3L6 15"/><path d="m5 8 4 4"/><path d="m12 15 4 4"/>`),eraser:()=>Mr(16,`<path d="m7 21-4.3-4.3c-1-1-1-2.5 0-3.4l9.6-9.6c1-1 2.5-1 3.4 0l5.6 5.6c1 1 1 2.5 0 3.4L13 21"/><path d="M22 21H7"/><path d="m5 11 9 9"/>`),close:()=>Mr(16,`<path d="M18 6 6 18"/><path d="m6 6 12 12"/>`,2),plus:()=>Mr(18,`<path d="M5 12h14"/><path d="M12 5v14"/>`,2)},Pr=[{id:`cross`,label:`Crosshair`,testid:`m-tool-cross`,icon:Nr.crosshair,action:{kind:`tool`,tool:null}},{id:`trend`,label:`Trend Line`,testid:`m-tool-trend`,icon:Nr.trend,action:{kind:`tool`,tool:`trendLine`}},{id:`fib`,label:`Fibonacci`,testid:`m-tool-fib`,icon:Nr.fib,action:{kind:`tool`,tool:`fibRetracement`}},{id:`rect`,label:`Rectangle`,testid:`m-tool-rect`,icon:Nr.rect,action:{kind:`tool`,tool:`rectangle`}},{id:`measure`,label:`Ruler`,testid:`m-tool-measure`,icon:Nr.ruler,action:{kind:`tool`,tool:`ruler`}},{id:`long`,label:`Long`,testid:`m-tool-long`,icon:Nr.longPos,action:{kind:`tool`,tool:`longPosition`},gate:`enableForecasting`},{id:`short`,label:`Short`,testid:`m-tool-short`,icon:Nr.shortPos,action:{kind:`tool`,tool:`shortPosition`},gate:`enableForecasting`},{id:`text`,label:`Text`,testid:`m-tool-text`,icon:Nr.text,action:{kind:`tool`,tool:`text`}},{id:`wave`,label:`Elliott Wave`,testid:`m-tool-wave`,icon:Nr.wave,action:{kind:`tool`,tool:`elliottImpulse`}},{id:`magnet`,label:`Magnet`,testid:`m-tool-magnet`,icon:Nr.magnet,action:{kind:`magnet`}},{id:`eraser`,label:`Eraser`,testid:`m-tool-eraser`,icon:Nr.eraser,action:{kind:`clearDrawings`}}],Fr=[{shortName:`MA`,title:`MA 20`,subtitle:`Moving Average (20)`,testid:`m-indicator-MA20`,params:{period:20}},{shortName:`EMA`,title:`EMA 50`,subtitle:`Exp. Moving Avg (50)`,testid:`m-indicator-EMA50`,params:{period:50}},{shortName:`BB`,title:`Bollinger`,subtitle:`Bollinger Bands`,testid:`m-indicator-BB`},{shortName:`RSI`,title:`RSI`,subtitle:`Relative Strength Index`,testid:`m-indicator-RSI`},{shortName:`MACD`,title:`MACD`,subtitle:`MACD 12/26/9`,testid:`m-indicator-MACD`},{shortName:`VOL`,title:`Volume`,subtitle:`Volume Histogram`,testid:`m-indicator-VOL`,isVolume:!0}],Ir=class{constructor(e,t,n,r=[]){this.backdrop=null,this.sheet=null,this.open=!1,this.activeTool=null,this.crosshairEnabled=!0,this.indicatorCounts=new Map,this.toolCells=new Map,this.indicatorRows=new Map,this.theme=e,this.controller=t,this.fontFamily=n==null?kr:n,this.enabledGates=new Set(r)}get isOpen(){return this.open}toggle(){this.open?this.close():this.show()}show(){this.open||(this.build(!0),this.open=!0)}close(){if(!this.open)return;this.open=!1;let e=this.backdrop,t=this.sheet;if(this.backdrop=null,this.sheet=null,this.toolCells.clear(),this.indicatorRows.clear(),!e)return;e.style.opacity=`0`,t&&(t.style.transform=`translateY(100%)`);let n=()=>e.remove();e.addEventListener(`transitionend`,n,{once:!0}),setTimeout(n,280)}build(e){let t=this.theme,n=document.createElement(`div`);Object.assign(n.style,{position:`fixed`,inset:`0`,zIndex:`2147483000`,background:`rgba(0,0,0,0.45)`,display:`flex`,alignItems:`flex-end`,justifyContent:`center`,fontFamily:this.fontFamily,fontFeatureSettings:Ar,fontVariantNumeric:`tabular-nums`,opacity:e?`0`:`1`,transition:`opacity 0.22s ease`}),n.addEventListener(`click`,e=>{e.target===n&&this.close()});let r=document.createElement(`div`);Object.assign(r.style,{width:`100%`,maxWidth:`520px`,maxHeight:`85vh`,display:`flex`,flexDirection:`column`,background:t.background,borderTopLeftRadius:`14px`,borderTopRightRadius:`14px`,borderTop:`1px solid ${t.axisBorder}`,paddingBottom:`env(safe-area-inset-bottom)`,boxShadow:`0 -8px 32px rgba(0,0,0,0.45)`,transform:e?`translateY(100%)`:`translateY(0)`,transition:`transform 0.26s cubic-bezier(0.32, 0.72, 0, 1)`,willChange:`transform`}),r.addEventListener(`click`,e=>e.stopPropagation()),r.appendChild(this.buildHeader());let i=document.createElement(`div`);Object.assign(i.style,{flex:`1`,overflowY:`auto`}),i.appendChild(this.buildDrawingSection()),i.appendChild(this.buildIndicatorSection()),r.appendChild(i),n.appendChild(r),document.body.appendChild(n),this.backdrop=n,this.sheet=r,e&&requestAnimationFrame(()=>requestAnimationFrame(()=>{n.style.opacity=`1`,r.style.transform=`translateY(0)`}))}sectionLabel(e){let t=document.createElement(`div`);return t.className=`font-mono`,t.textContent=e,Object.assign(t.style,{fontSize:`10px`,textTransform:`uppercase`,letterSpacing:`0.14em`,color:this.theme.topBar.btnColor,fontFamily:this.fontFamily}),t}buildHeader(){let e=this.theme,t=document.createElement(`div`);Object.assign(t.style,{display:`flex`,alignItems:`center`,justifyContent:`space-between`,padding:`16px`,borderBottom:`1px solid ${e.axisBorder}`,flexShrink:`0`});let n=document.createElement(`div`),r=this.sectionLabel(`Chart Tools`),i=document.createElement(`div`);i.textContent=`Draw & Indicators`,Object.assign(i.style,{fontSize:`16px`,fontWeight:`700`,letterSpacing:`-0.01em`,color:e.axisText,marginTop:`2px`,fontFamily:jr}),n.appendChild(r),n.appendChild(i);let a=document.createElement(`button`);return a.setAttribute(`data-testid`,`m-tools-close`),a.innerHTML=Nr.close(),Object.assign(a.style,{height:`32px`,width:`32px`,borderRadius:`50%`,border:`none`,background:e.ui.accentBg,color:e.axisText,cursor:`pointer`,display:`flex`,alignItems:`center`,justifyContent:`center`,flexShrink:`0`}),a.addEventListener(`click`,e=>{e.stopPropagation(),this.close()}),t.appendChild(n),t.appendChild(a),t}buildDrawingSection(){let e=this.theme,t=document.createElement(`div`);Object.assign(t.style,{padding:`16px`,borderBottom:`1px solid ${e.axisBorder}`});let n=document.createElement(`div`);Object.assign(n.style,{marginBottom:`12px`}),n.appendChild(this.sectionLabel(`Drawing`)),t.appendChild(n);let r=document.createElement(`div`);Object.assign(r.style,{display:`grid`,gridTemplateColumns:`repeat(3, 1fr)`,gap:`8px`});for(let e of Pr){if(e.gate&&!this.enabledGates.has(e.gate))continue;let t=document.createElement(`button`);t.setAttribute(`data-testid`,e.testid),t.innerHTML=`${e.icon()}<span class="font-mono" style="font-size:10px;font-weight:600;">${e.label}</span>`,Object.assign(t.style,{display:`flex`,flexDirection:`column`,alignItems:`center`,gap:`6px`,padding:`12px 4px`,borderRadius:`8px`,cursor:`pointer`,fontFamily:this.fontFamily,transition:`background 0.15s, color 0.15s, border-color 0.15s`}),t.addEventListener(`click`,t=>{t.stopPropagation(),this.onToolTap(e)}),this.toolCells.set(e.id,t),r.appendChild(t)}return t.appendChild(r),this.refreshToolStyles(),t}buildIndicatorSection(){let e=this.theme,t=document.createElement(`div`);Object.assign(t.style,{padding:`16px`});let n=document.createElement(`div`);Object.assign(n.style,{display:`flex`,alignItems:`center`,justifyContent:`space-between`,marginBottom:`12px`}),n.appendChild(this.sectionLabel(`Indicators`));let r=document.createElement(`button`);r.setAttribute(`data-testid`,`m-tools-clear-indicators`),r.className=`font-mono`,r.textContent=`Clear All`,Object.assign(r.style,{fontSize:`10px`,textTransform:`uppercase`,letterSpacing:`0.14em`,color:e.ui.accent,background:`none`,border:`none`,cursor:`pointer`,fontFamily:this.fontFamily}),r.addEventListener(`click`,e=>{e.stopPropagation(),this.clearIndicators()}),n.appendChild(r),t.appendChild(n);let i=document.createElement(`div`);Object.assign(i.style,{display:`flex`,flexDirection:`column`,gap:`6px`});for(let t of Fr){let n=document.createElement(`button`);n.setAttribute(`data-testid`,t.testid),n.innerHTML=`
|
|
258
266
|
<div style="text-align:left;">
|
|
259
|
-
<div class="hk-ind-title" style="font-size:13px;font-weight:600;font-family:${
|
|
267
|
+
<div class="hk-ind-title" style="font-size:13px;font-weight:600;font-family:${jr};">${t.title}</div>
|
|
260
268
|
<div class="font-mono" style="font-size:10px;color:${e.topBar.btnColor};">${t.subtitle}</div>
|
|
261
|
-
</div>`,Object.assign(n.style,{width:`100%`,display:`flex`,alignItems:`center`,justifyContent:`space-between`,padding:`12px`,borderRadius:`8px`,cursor:`pointer`,textAlign:`left`,fontFamily:`inherit`,transition:`background 0.15s, border-color 0.15s`}),n.appendChild(this.buildRowControl(t)),n.addEventListener(`click`,e=>{e.stopPropagation(),this.onIndicatorTap(t)}),this.indicatorRows.set(t.shortName,n),i.appendChild(n)}return t.appendChild(i),this.refreshIndicatorStyles(),t}buildRowControl(e){return e.isVolume?this.buildToggle(this.getCount(e.shortName)>0):this.buildCounter(this.getCount(e.shortName))}buildToggle(e){let t=this.theme,n=document.createElement(`span`);n.className=`hk-toggle`,Object.assign(n.style,{display:`inline-block`,height:`20px`,width:`36px`,borderRadius:`9999px`,position:`relative`,flexShrink:`0`,transition:`background 0.15s`,background:e?t.ui.accent:t.axisBorder});let r=document.createElement(`span`);return Object.assign(r.style,{position:`absolute`,top:`2px`,height:`16px`,width:`16px`,borderRadius:`50%`,background:t.background,transition:`left 0.15s`,left:e?`18px`:`2px`}),n.appendChild(r),n}buildCounter(e){let t=this.theme,n=document.createElement(`span`);n.className=`hk-ind-counter`,Object.assign(n.style,{display:`inline-flex`,alignItems:`center`,gap:`8px`,flexShrink:`0`});let r=document.createElement(`span`);r.className=`hk-ind-count`,r.textContent=String(e),Object.assign(r.style,{minWidth:`20px`,height:`20px`,padding:`0 6px`,borderRadius:`9999px`,display:e>0?`inline-flex`:`none`,alignItems:`center`,justifyContent:`center`,fontSize:`11px`,fontWeight:`700`,fontFamily:this.fontFamily,fontVariantNumeric:`tabular-nums`,background:t.ui.accent,color:t.background});let i=document.createElement(`span`);return i.className=`hk-ind-plus`,i.innerHTML=
|
|
262
|
-
.${
|
|
263
|
-
.${
|
|
264
|
-
.${
|
|
265
|
-
.${
|
|
266
|
-
`,document.head.appendChild(e)}function wr(e,t,n=2){return`<svg viewBox="0 0 24 24" width="${e}" height="${e}" fill="none" stroke="currentColor" stroke-width="${n}" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${t}</svg>`}var Tr=(e=14)=>wr(e,`<path d="M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z"/><path d="m15 5 4 4"/>`),Er=(e=12)=>wr(e,`<path d="M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z"/><path d="M20 3v4"/><path d="M22 5h-4"/><path d="M4 17v2"/><path d="M5 18H3"/>`,2.5),Dr=(e=16)=>wr(e,`<path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"/><circle cx="12" cy="12" r="3"/>`,1.75),Or=class{constructor(e,t,n,r,i,a,o,s,c){this.toolsBtn=null,this.tfBtns=new Map,this.toolsActive=!1,this.seriesBtn=null,this.seriesMenu=null,this.seriesMenuOpen=!1,this.onDocPointerDown=null,this.onWinReposition=null,this.onTimeframeChange=e,this.onAskAiClick=n,this.onSettingsClick=r,this.onSeriesChange=i,this.currentTf=a,this.currentSeries=o,this.theme=s,this.fontFamily=c==null?yr:c,this.sheet=t?new hr(s,t,this.fontFamily):null,Cr(),this.el=document.createElement(`div`),this.el.className=Sr,this.build()}build(){if(this.closeSeriesMenu(),this.el.innerHTML=``,this.tfBtns.clear(),this.toolsBtn=null,this.seriesBtn=null,Object.assign(this.el.style,{display:`flex`,alignItems:`center`,gap:`8px`,overflowX:`auto`,overflowY:`hidden`,padding:`8px 12px`,borderBottom:`1px solid ${this.theme.axisBorder}`,background:this.theme.background,flexShrink:`0`,width:`100%`,maxWidth:`100%`,minWidth:`0`,boxSizing:`border-box`,scrollbarWidth:`thin`,scrollbarColor:`rgba(120,130,150,0.55) transparent`,WebkitOverflowScrolling:`touch`,fontFamily:this.fontFamily,fontFeatureSettings:br,fontVariantNumeric:`tabular-nums`}),this.sheet){let e=document.createElement(`button`);e.setAttribute(`data-testid`,`m-chart-tools-btn`),e.className=xr,e.innerHTML=`${Tr(14)}<span class="text-[11px] font-mono font-semibold uppercase tracking-widest">Tools</span>`,Object.assign(e.style,{borderWidth:`1px`,borderStyle:`solid`,cursor:`pointer`,outline:`none`,transition:`color 0.15s, background 0.15s, border-color 0.15s`}),e.addEventListener(`click`,e=>{var t,n,r;e.stopPropagation(),(t=this.sheet)==null||t.toggle(),this.toolsActive=(n=(r=this.sheet)==null?void 0:r.isOpen)==null?!1:n,this.styleToolsBtn()}),this.toolsBtn=e,this.el.appendChild(e),this.styleToolsBtn();let t=document.createElement(`div`);Object.assign(t.style,{width:`1px`,height:`20px`,background:this.theme.axisBorder,flexShrink:`0`}),this.el.appendChild(t)}if(this.onSeriesChange){let e=document.createElement(`button`);e.setAttribute(`data-testid`,`m-chart-type-btn`),e.title=`Chart type`,e.innerHTML=this.seriesIconHtml(this.currentSeries),Object.assign(e.style,{display:`flex`,alignItems:`center`,justifyContent:`center`,padding:`6px`,borderRadius:`4px`,border:`none`,whiteSpace:`nowrap`,flexShrink:`0`,cursor:`pointer`,outline:`none`,background:`transparent`,color:this.theme.axisText,transition:`color 0.15s, background 0.15s`}),e.addEventListener(`click`,e=>{e.stopPropagation(),this.toggleSeriesMenu()}),this.seriesBtn=e,this.el.appendChild(e);let t=document.createElement(`div`);Object.assign(t.style,{width:`1px`,height:`20px`,background:this.theme.axisBorder,flexShrink:`0`}),this.el.appendChild(t)}for(let n of _r){var e,t;let r=document.createElement(`button`);r.setAttribute(`data-testid`,`m-tf-${(e=vr[n])==null?n:e}`),r.className=`font-mono`,r.textContent=(t=vr[n])==null?n:t,Object.assign(r.style,{padding:`6px 12px`,borderRadius:`4px`,border:`none`,fontSize:`11px`,fontWeight:`600`,whiteSpace:`nowrap`,flexShrink:`0`,cursor:`pointer`,outline:`none`,fontFamily:this.fontFamily,transition:`background 0.15s, color 0.15s`}),r.addEventListener(`click`,e=>{e.stopPropagation(),this.currentTf!==n&&(this.currentTf=n,this.refreshTfStyles(),this.onTimeframeChange(n))}),this.tfBtns.set(n,r),this.el.appendChild(r)}this.refreshTfStyles();let n=document.createElement(`div`);if(n.style.flex=`1 0 8px`,this.el.appendChild(n),this.onAskAiClick){let e=document.createElement(`button`);e.setAttribute(`data-testid`,`m-chart-ai-btn`),e.className=`font-mono`,e.innerHTML=`${Er(12)}<span class="font-mono" style="font-size:11px;font-weight:600;">AI</span>`,Object.assign(e.style,{display:`flex`,alignItems:`center`,gap:`4px`,padding:`6px 12px`,borderRadius:`4px`,border:`none`,whiteSpace:`nowrap`,flexShrink:`0`,cursor:`pointer`,outline:`none`,fontFamily:this.fontFamily,background:this.theme.ui.accentBg,color:this.theme.ui.accent}),e.addEventListener(`click`,e=>{var t;e.stopPropagation(),(t=this.onAskAiClick)==null||t.call(this)}),this.el.appendChild(e)}if(this.onSettingsClick){let e=document.createElement(`button`);e.setAttribute(`data-testid`,`m-chart-settings-btn`),e.title=`Settings`,e.innerHTML=Dr(16),Object.assign(e.style,{display:`flex`,alignItems:`center`,justifyContent:`center`,padding:`6px`,borderRadius:`4px`,border:`none`,whiteSpace:`nowrap`,flexShrink:`0`,cursor:`pointer`,outline:`none`,background:`transparent`,color:this.theme.axisText,transition:`color 0.15s, background 0.15s`}),e.addEventListener(`click`,e=>{var t;e.stopPropagation(),(t=this.onSettingsClick)==null||t.call(this)}),this.el.appendChild(e)}}styleToolsBtn(){if(!this.toolsBtn)return;let e=this.toolsActive?this.theme.ui.accent:this.theme.axisText;this.toolsBtn.style.color=e,this.toolsBtn.style.borderColor=e}refreshTfStyles(){let e=this.theme;for(let[t,n]of this.tfBtns){let r=t===this.currentTf;n.style.background=r?e.ui.accentBg:`transparent`,n.style.color=r?e.ui.accent:e.topBar.btnColor}}seriesIconHtml(e){var t;return((t=nn[e])==null?nn.candlestick:t).replace(/width="\d+" height="\d+"/,`width="18" height="18"`)}toggleSeriesMenu(){this.seriesMenuOpen?this.closeSeriesMenu():this.openSeriesMenu()}openSeriesMenu(){this.seriesMenuOpen||!this.seriesBtn||typeof document>`u`||(this.seriesMenu=this.buildSeriesMenu(),document.body.appendChild(this.seriesMenu),this.seriesMenuOpen=!0,this.positionSeriesMenu(),this.styleSeriesBtnActive(!0),this.onDocPointerDown=e=>{var t,n;let r=e.target;(t=this.seriesMenu)!=null&&t.contains(r)||(n=this.seriesBtn)!=null&&n.contains(r)||this.closeSeriesMenu()},this.onWinReposition=()=>this.closeSeriesMenu(),setTimeout(()=>{this.seriesMenuOpen&&(document.addEventListener(`pointerdown`,this.onDocPointerDown,!0),window.addEventListener(`resize`,this.onWinReposition,!0),window.addEventListener(`scroll`,this.onWinReposition,!0),this.el.addEventListener(`scroll`,this.onWinReposition,!0))},0))}closeSeriesMenu(){var e;this.onDocPointerDown&&(document.removeEventListener(`pointerdown`,this.onDocPointerDown,!0),this.onDocPointerDown=null),this.onWinReposition&&(window.removeEventListener(`resize`,this.onWinReposition,!0),window.removeEventListener(`scroll`,this.onWinReposition,!0),this.el.removeEventListener(`scroll`,this.onWinReposition,!0),this.onWinReposition=null),(e=this.seriesMenu)==null||e.remove(),this.seriesMenu=null,this.seriesMenuOpen=!1,this.styleSeriesBtnActive(!1)}buildSeriesMenu(){let e=this.theme,t=document.createElement(`div`);t.setAttribute(`data-testid`,`m-chart-type-menu`),Object.assign(t.style,{position:`fixed`,zIndex:`2147483000`,minWidth:`184px`,maxHeight:`60vh`,overflowY:`auto`,padding:`4px`,borderRadius:`8px`,border:`1px solid ${e.axisBorder}`,background:e.background,boxShadow:`0 8px 28px rgba(0,0,0,0.35)`,fontFamily:this.fontFamily,WebkitOverflowScrolling:`touch`});for(let r of gr){var n;let i=r.value===this.currentSeries,a=document.createElement(`button`);a.type=`button`,a.setAttribute(`data-testid`,`m-chart-type-${r.value}`),Object.assign(a.style,{display:`flex`,alignItems:`center`,gap:`10px`,width:`100%`,padding:`9px 10px`,borderRadius:`6px`,border:`none`,cursor:`pointer`,outline:`none`,textAlign:`left`,fontSize:`13px`,fontFamily:this.fontFamily,background:i?e.ui.accentBg:`transparent`,color:i?e.ui.accent:e.axisText});let o=((n=nn[r.value])==null?``:n).replace(/width="\d+" height="\d+"/,`width="16" height="16"`),s=i?vn.replace(/width="\d+" height="\d+"/,`width="16" height="16"`):``;a.innerHTML=`<span style="display:flex;flex-shrink:0;">${o}</span><span style="flex:1;">${r.label}</span><span style="display:flex;flex-shrink:0;width:16px;">${s}</span>`,a.addEventListener(`mouseenter`,()=>{r.value!==this.currentSeries&&(a.style.background=e.ui.accentBg)}),a.addEventListener(`mouseleave`,()=>{r.value!==this.currentSeries&&(a.style.background=`transparent`)}),a.addEventListener(`click`,e=>{e.stopPropagation(),this.selectSeries(r.value)}),t.appendChild(a)}return t}positionSeriesMenu(){if(!this.seriesMenu||!this.seriesBtn)return;let e=this.seriesBtn.getBoundingClientRect(),t=this.seriesMenu;t.style.top=`${e.bottom+6}px`,t.style.left=`${e.left}px`;let n=t.getBoundingClientRect();n.right>window.innerWidth-8&&(t.style.left=`${Math.max(8,window.innerWidth-8-n.width)}px`),n.bottom>window.innerHeight-8&&(t.style.top=`${Math.max(8,e.top-6-n.height)}px`)}selectSeries(e){var t;this.closeSeriesMenu(),e!==this.currentSeries&&(this.currentSeries=e,this.seriesBtn&&(this.seriesBtn.innerHTML=this.seriesIconHtml(e)),(t=this.onSeriesChange)==null||t.call(this,e))}styleSeriesBtnActive(e){this.seriesBtn&&(this.seriesBtn.style.color=e?this.theme.ui.accent:this.theme.axisText,this.seriesBtn.style.background=e?this.theme.ui.accentBg:`transparent`)}setTimeframe(e){this.currentTf=e,this.refreshTfStyles()}setDrawingsBtnActive(e){this.toolsActive=e,this.styleToolsBtn()}setTheme(e){var t;this.theme=e,this.build(),this.setDrawingsBtnActive(this.toolsActive),(t=this.sheet)==null||t.setTheme(e)}destroy(){var e;this.closeSeriesMenu(),(e=this.sheet)==null||e.destroy(),this.el.remove(),this.tfBtns.clear(),this.toolsBtn=null,this.seriesBtn=null}setIndicatorOptionActive(e,t,n){var r;(r=this.sheet)==null||r.syncIndicator(e,t,n)}setVolumeControl(e,t){var n;(n=this.sheet)==null||n.syncVolume(e)}setSeries(e){this.currentSeries=e,this.seriesBtn&&(this.seriesBtn.innerHTML=this.seriesIconHtml(e)),this.seriesMenuOpen&&(this.closeSeriesMenu(),this.openSeriesMenu())}setIndicatorOptions(e){}closeDropdown(){var e;(e=this.sheet)==null||e.close(),this.closeSeriesMenu()}get hasOpenDropdown(){var e,t;return((e=(t=this.sheet)==null?void 0:t.isOpen)==null?!1:e)||this.seriesMenuOpen}setFullscreen(e){}setActiveDuration(e){}setTfcActive(e){}setLayoutPresetIcon(e,t){}setLayoutActive(e){}getLayoutBtnEl(){return null}getSnapshotBtnEl(){return null}reparentFlyout(e){}setMobileLayout(e){}},kr=22,Ar=15.84,U=1.5,W=1,jr=kr-2*U,Mr=Ar-2*U,G=(...e)=>`<svg width="${kr}" height="${Ar}" viewBox="0 0 ${kr} ${Ar}" class="shrink-0" aria-hidden="true">${e.join(``)}</svg>`,K=(e,t,n,r)=>`<rect x="${e}" y="${t}" width="${n}" height="${r}" fill="none" stroke="currentColor" stroke-width="1.2" rx="1.5"/>`;function Nr(e,t,n,r){let i=(jr-(n-1)*W)/n,a=(Mr-(r-1)*W)/r;return K(U+e*(i+W),U+t*(a+W),i,a)}function Pr(e,t){let n=[];for(let r=0;r<t;r++)for(let i=0;i<e;i++)n.push(Nr(i,r,e,t));return n}var q=(jr-W)/2,J=(Mr-W)/2,Fr=U+q+W,Ir=U+J+W,Lr=(Mr-2*W)/3,Rr=(jr-2*W)/3,zr=[{id:`1`,count:1,cols:`1fr`,rows:`1fr`,icon:G(K(U,U,jr,Mr))},{id:`2-h`,count:2,cols:`1fr 1fr`,rows:`1fr`,icon:G(K(U,U,q,Mr),K(Fr,U,q,Mr))},{id:`2-v`,count:2,cols:`1fr`,rows:`1fr 1fr`,icon:G(K(U,U,jr,J),K(U,Ir,jr,J))},{id:`3-cols`,count:3,cols:`1fr 1fr 1fr`,rows:`1fr`,icon:G(...Pr(3,1))},{id:`3-rows`,count:3,cols:`1fr`,rows:`1fr 1fr 1fr`,icon:G(...Pr(1,3))},{id:`3-l1r2`,count:3,cols:`1fr 1fr`,rows:`1fr 1fr`,areas:`"a b" "a c"`,areaOrder:[`a`,`b`,`c`],icon:G(K(U,U,q,Mr),K(Fr,U,q,J),K(Fr,Ir,q,J))},{id:`3-l2r1`,count:3,cols:`1fr 1fr`,rows:`1fr 1fr`,areas:`"a c" "b c"`,areaOrder:[`a`,`b`,`c`],icon:G(K(U,U,q,J),K(U,Ir,q,J),K(Fr,U,q,Mr))},{id:`3-t1b2`,count:3,cols:`1fr 1fr`,rows:`1fr 1fr`,areas:`"a a" "b c"`,areaOrder:[`a`,`b`,`c`],icon:G(K(U,U,jr,J),K(U,Ir,q,J),K(Fr,Ir,q,J))},{id:`3-t2b1`,count:3,cols:`1fr 1fr`,rows:`1fr 1fr`,areas:`"a b" "c c"`,areaOrder:[`a`,`b`,`c`],icon:G(K(U,U,q,J),K(Fr,U,q,J),K(U,Ir,jr,J))},{id:`4-2x2`,count:4,cols:`1fr 1fr`,rows:`1fr 1fr`,icon:G(...Pr(2,2))},{id:`4-rows`,count:4,cols:`1fr`,rows:`1fr 1fr 1fr 1fr`,icon:G(...Pr(1,4))},{id:`4-cols`,count:4,cols:`1fr 1fr 1fr 1fr`,rows:`1fr`,icon:G(...Pr(4,1))},{id:`4-l1r3`,count:4,cols:`1fr 1fr`,rows:`1fr 1fr 1fr`,areas:`"a b" "a c" "a d"`,areaOrder:[`a`,`b`,`c`,`d`],icon:G(K(U,U,q,Mr),...[0,1,2].map(e=>K(Fr,U+e*(Lr+W),q,Lr)))},{id:`4-l3r1`,count:4,cols:`1fr 1fr`,rows:`1fr 1fr 1fr`,areas:`"a d" "b d" "c d"`,areaOrder:[`a`,`b`,`c`,`d`],icon:G(...[0,1,2].map(e=>K(U,U+e*(Lr+W),q,Lr)),K(Fr,U,q,Mr))},{id:`4-t1b3`,count:4,cols:`1fr 1fr 1fr`,rows:`1fr 1fr`,areas:`"a a a" "b c d"`,areaOrder:[`a`,`b`,`c`,`d`],icon:G(K(U,U,jr,J),...[0,1,2].map(e=>K(U+e*(Rr+W),Ir,Rr,J)))},{id:`4-t3b1`,count:4,cols:`1fr 1fr 1fr`,rows:`1fr 1fr`,areas:`"a b c" "d d d"`,areaOrder:[`a`,`b`,`c`,`d`],icon:G(...[0,1,2].map(e=>K(U+e*(Rr+W),U,Rr,J)),K(U,Ir,jr,J))},{id:`5-t1b4`,count:5,cols:`1fr 1fr 1fr 1fr`,rows:`1fr 1fr`,areas:`"a a a a" "b c d e"`,areaOrder:[`a`,`b`,`c`,`d`,`e`],icon:G(K(U,U,jr,J),...[0,1,2,3].map(e=>{let t=(jr-3*W)/4;return K(U+e*(t+W),Ir,t,J)}))},{id:`5-cols`,count:5,cols:`1fr 1fr 1fr 1fr 1fr`,rows:`1fr`,icon:G(...Pr(5,1))},{id:`5-rows`,count:5,cols:`1fr`,rows:`1fr 1fr 1fr 1fr 1fr`,icon:G(...Pr(1,5))},{id:`5-l1r4`,count:5,cols:`1fr 1fr`,rows:`1fr 1fr 1fr 1fr`,areas:`"a b" "a c" "a d" "a e"`,areaOrder:[`a`,`b`,`c`,`d`,`e`],icon:G(K(U,U,q,Mr),...[0,1,2,3].map(e=>{let t=(Mr-3*W)/4;return K(Fr,U+e*(t+W),q,t)}))},{id:`6-2x3`,count:6,cols:`1fr 1fr 1fr`,rows:`1fr 1fr`,icon:G(...Pr(3,2))},{id:`6-3x2`,count:6,cols:`1fr 1fr`,rows:`1fr 1fr 1fr`,icon:G(...Pr(2,3))},{id:`6-cols`,count:6,cols:`1fr 1fr 1fr 1fr 1fr 1fr`,rows:`1fr`,icon:G(...Pr(6,1))},{id:`6-rows`,count:6,cols:`1fr`,rows:`1fr 1fr 1fr 1fr 1fr 1fr`,icon:G(...Pr(1,6))},{id:`8-2x4`,count:8,cols:`1fr 1fr 1fr 1fr`,rows:`1fr 1fr`,icon:G(...Pr(4,2))},{id:`8-4x2`,count:8,cols:`1fr 1fr`,rows:`1fr 1fr 1fr 1fr`,icon:G(...Pr(2,4))}];zr.reduce((e,t)=>{var n,r;return((r=e[n=t.count])==null?e[n]=[]:r).push(t),e},{});var Br=new Map;function Vr(){return Br.size===0?zr:[...zr,...Br.values()]}function Hr(e){var t,n;return(t=(n=Br.get(e))==null?zr.find(t=>t.id===e):n)==null?zr[0]:t}var Ur={symbol:!1,interval:!0,crosshair:!0,time:!0,dateRange:!0},Wr=[{key:`symbol`,label:`Symbol`,info:`All charts mirror the selected symbol`},{key:`interval`,label:`Interval`,info:`All charts use the same timeframe`},{key:`crosshair`,label:`Crosshair`,info:`Crosshair position mirrors across all charts`},{key:`time`,label:`Time`,info:`Panning and zoom are linked`},{key:`dateRange`,label:`Date range`,info:`All charts use the same visible range`}],Gr=class{constructor(e,t,n,r,i,a){this.theme=e,this.currentPresetId=t,this.sync={...n},this.onSelectPreset=r,this.onToggleSync=i,this.onVisibilityChange=a,this.el=document.createElement(`div`),this.el.setAttribute(`role`,`dialog`),this.el.setAttribute(`aria-label`,`Chart layout picker`),this.applyBaseStyles(),this.el.addEventListener(`pointerdown`,e=>e.stopPropagation()),document.body.appendChild(this.el),this.build(),this.docPointerDownHandler=e=>{if(!this.isVisible)return;let t=e.target;t&&(t.closest(`[data-layout-toggle]`)||this.hide())},this.escapeHandler=e=>{e.key===`Escape`&&this.isVisible&&this.hide()},document.addEventListener(`pointerdown`,this.docPointerDownHandler),document.addEventListener(`keydown`,this.escapeHandler)}show(e){var t;let n=this.isVisible,r=e.getBoundingClientRect(),i=r.bottom+6,a=Math.max(8,window.innerWidth-r.right);this.el.style.top=`${i}px`,this.el.style.right=`${a}px`,this.el.style.display=`block`,n||(t=this.onVisibilityChange)==null||t.call(this)}hide(){var e;let t=this.isVisible;this.el.style.display=`none`,t&&((e=this.onVisibilityChange)==null||e.call(this))}get isVisible(){return this.el.style.display!==`none`}setPreset(e){e!==this.currentPresetId&&(this.currentPresetId=e,this.build())}setSync(e){this.sync={...e},this.build()}setTheme(e){this.theme=e,this.applyBaseStyles(),this.build()}destroy(){document.removeEventListener(`pointerdown`,this.docPointerDownHandler),document.removeEventListener(`keydown`,this.escapeHandler),this.el.remove()}applyBaseStyles(){Object.assign(this.el.style,{position:`fixed`,display:`none`,width:`480px`,maxWidth:`calc(100vw - 16px)`,maxHeight:`80vh`,overflowY:`auto`,borderRadius:`6px`,background:this.theme.tooltip.background,border:`1px solid ${this.theme.axisBorder}`,boxShadow:`0 8px 32px rgba(0,0,0,0.45)`,zIndex:`10000`,fontFamily:`'Inter', system-ui, sans-serif`,fontSize:`13px`,color:this.theme.topBar.btnColor,pointerEvents:`auto`})}build(){this.el.innerHTML=``,this.el.appendChild(this.buildHeader()),this.el.appendChild(this.buildPresetGrid()),this.el.appendChild(this.buildSyncSection())}buildHeader(){let e=document.createElement(`div`);Object.assign(e.style,{display:`flex`,alignItems:`center`,justifyContent:`space-between`,padding:`10px 12px 8px`,borderBottom:`1px solid ${this.theme.axisBorder}`});let t=document.createElement(`span`);t.textContent=`Chart Layout`,Object.assign(t.style,{fontSize:`10px`,fontWeight:`600`,letterSpacing:`0.1em`,textTransform:`uppercase`,color:this.theme.axisText}),e.appendChild(t);let n=document.createElement(`button`);return n.setAttribute(`aria-label`,`Close layout picker`),Object.assign(n.style,{background:`none`,border:`none`,color:this.theme.axisText,cursor:`pointer`,padding:`2px`,display:`flex`,alignItems:`center`,borderRadius:`4px`}),n.innerHTML=`<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" aria-hidden="true"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>`,n.addEventListener(`click`,e=>{e.stopPropagation(),this.hide()}),e.appendChild(n),e}buildPresetGrid(){let e=document.createElement(`div`);e.style.padding=`10px 12px 8px`;let t=new Map;for(let e of Vr()){let n=t.get(e.count);n?n.push(e):t.set(e.count,[e])}let n=Array.from(t.keys()).sort((e,t)=>e-t);for(let r of n){let n=t.get(r);if(!(n!=null&&n.length))continue;let i=document.createElement(`div`);Object.assign(i.style,{display:`flex`,alignItems:`flex-start`,gap:`10px`,marginBottom:`8px`});let a=document.createElement(`span`);a.textContent=String(r),Object.assign(a.style,{width:`14px`,fontSize:`11px`,fontWeight:`700`,color:this.theme.axisText,paddingTop:`6px`,textAlign:`right`,flexShrink:`0`}),i.appendChild(a);let o=document.createElement(`div`);Object.assign(o.style,{display:`flex`,flexWrap:`wrap`,gap:`5px`,flex:`1`});for(let e of n){let t=e.id===this.currentPresetId,n=document.createElement(`button`);n.dataset.testid=`chart-layout-${e.id}`,n.title=e.id,n.setAttribute(`aria-pressed`,String(t)),Object.assign(n.style,{height:`36px`,width:`44px`,borderRadius:`4px`,border:`1.5px solid ${t?this.theme.ui.accent:this.theme.axisBorder}`,background:t?this.theme.ui.accentBg:`transparent`,boxShadow:t?`0 0 0 1px ${this.theme.ui.accentBg}`:`none`,cursor:`pointer`,display:`flex`,alignItems:`center`,justifyContent:`center`,transition:`border-color 0.1s, background 0.1s`,padding:`0`}),n.innerHTML=e.icon.replace(/stroke="currentColor"/g,`stroke="${t?this.theme.ui.accent:this.theme.axisText}"`),n.addEventListener(`pointerdown`,t=>{t.stopPropagation(),e.id!==this.currentPresetId&&(this.setPreset(e.id),this.onSelectPreset(e.id))}),o.appendChild(n)}i.appendChild(o),e.appendChild(i)}return e}buildSyncSection(){let e=document.createElement(`div`);Object.assign(e.style,{padding:`8px 12px 12px`,borderTop:`1px solid ${this.theme.axisBorder}`});let t=document.createElement(`div`);t.textContent=`Sync in Layout`,Object.assign(t.style,{fontSize:`10px`,fontWeight:`600`,letterSpacing:`0.1em`,textTransform:`uppercase`,color:this.theme.axisText,marginBottom:`8px`}),e.appendChild(t);for(let t of Wr)e.appendChild(this.makeSyncRow(t));return e}makeSyncRow({key:e,label:t,info:n}){let r=document.createElement(`div`);Object.assign(r.style,{display:`flex`,alignItems:`center`,justifyContent:`space-between`,padding:`5px 0`});let i=document.createElement(`div`);Object.assign(i.style,{display:`flex`,alignItems:`center`,gap:`5px`});let a=document.createElement(`span`);a.textContent=t,Object.assign(a.style,{fontSize:`12px`,color:this.theme.topBar.btnColor}),i.appendChild(a);let o=document.createElement(`span`);return o.textContent=`ⓘ`,o.title=n,Object.assign(o.style,{fontSize:`10px`,color:this.theme.axisText,cursor:`help`}),i.appendChild(o),r.appendChild(i),r.appendChild(this.makeToggleSwitch(e)),r}makeToggleSwitch(e){let t=this.sync[e],n=document.createElement(`label`);n.dataset.testid=`sync-${e}`,Object.assign(n.style,{position:`relative`,display:`inline-block`,width:`32px`,height:`16px`,cursor:`pointer`,flexShrink:`0`});let r=document.createElement(`input`);r.type=`checkbox`,r.checked=t,r.setAttribute(`role`,`switch`),r.setAttribute(`aria-checked`,String(t)),Object.assign(r.style,{opacity:`0`,width:`0`,height:`0`,position:`absolute`}),r.addEventListener(`change`,t=>{t.stopPropagation(),this.sync={...this.sync,[e]:!this.sync[e]},this.build(),this.onToggleSync(e)});let i=document.createElement(`span`);Object.assign(i.style,{position:`absolute`,top:`0`,left:`0`,right:`0`,bottom:`0`,borderRadius:`40px`,border:`1px solid ${t?this.theme.ui.accent:this.theme.axisBorder}`,background:t?this.theme.ui.accent:`transparent`,transition:`border-color 0.2s, background 0.2s`});let a=document.createElement(`span`);return Object.assign(a.style,{position:`absolute`,height:`12px`,width:`12px`,left:t?`16px`:`2px`,bottom:`1px`,borderRadius:`50%`,background:t?`#ffffff`:this.theme.axisText,transition:`left 0.2s, background 0.2s`}),n.append(r,i,a),n}},Kr=class{constructor(e,t,n){this.theme=e,this.onAction=t,this.onVisibilityChange=n,this.el=document.createElement(`div`),this.el.setAttribute(`role`,`menu`),this.el.setAttribute(`aria-label`,`Snapshot options`),this.applyBaseStyles(),this.el.addEventListener(`pointerdown`,e=>e.stopPropagation()),document.body.appendChild(this.el),this.build(),this.docPointerDownHandler=e=>{if(!this.isVisible)return;let t=e.target;t&&(t.closest(`[data-snapshot-toggle]`)||this.hide())},this.escapeHandler=e=>{e.key===`Escape`&&this.isVisible&&this.hide()},document.addEventListener(`pointerdown`,this.docPointerDownHandler),document.addEventListener(`keydown`,this.escapeHandler)}show(e){var t;let n=this.isVisible,r=e.getBoundingClientRect(),i=r.bottom+6,a=Math.max(8,window.innerWidth-r.right);this.el.style.top=`${i}px`,this.el.style.right=`${a}px`,this.el.style.display=`flex`,n||(t=this.onVisibilityChange)==null||t.call(this)}hide(){var e;let t=this.isVisible;this.el.style.display=`none`,t&&((e=this.onVisibilityChange)==null||e.call(this))}get isVisible(){return this.el.style.display!==`none`}setTheme(e){this.theme=e,this.applyBaseStyles(),this.build()}destroy(){document.removeEventListener(`pointerdown`,this.docPointerDownHandler),document.removeEventListener(`keydown`,this.escapeHandler),this.el.remove()}applyBaseStyles(){Object.assign(this.el.style,{position:`fixed`,display:`none`,flexDirection:`column`,background:this.theme.tooltip.background,border:`1px solid ${this.theme.axisBorder}`,borderRadius:`5px`,padding:`4px`,zIndex:`10000`,boxShadow:`0 4px 16px rgba(0,0,0,0.25)`,fontFamily:`'Inter', system-ui, sans-serif`,fontSize:`12px`,width:`max-content`,minWidth:`140px`,pointerEvents:`auto`})}build(){this.el.innerHTML=``,this.el.append(this.makeRow(`Download`,this.iconDownload(),`download`),this.makeRow(`Copy`,this.iconCopy(),`copy`))}makeRow(e,t,n){let r=document.createElement(`button`);r.dataset.testid=`chart-snapshot-${n}`,Object.assign(r.style,{display:`flex`,alignItems:`center`,gap:`8px`,width:`100%`,background:`transparent`,border:`none`,borderRadius:`3px`,padding:`8px 10px`,cursor:`pointer`,fontFamily:`'Inter', system-ui, sans-serif`,fontSize:`12px`,color:this.theme.topBar.btnColor,textAlign:`left`});let i=document.createElement(`span`);i.style.display=`flex`,i.style.alignItems=`center`,i.style.flexShrink=`0`,i.innerHTML=t,r.appendChild(i);let a=document.createElement(`span`);return a.textContent=e,a.style.fontWeight=`500`,r.appendChild(a),r.addEventListener(`mouseenter`,()=>{r.style.background=this.theme.ui.accentBg}),r.addEventListener(`mouseleave`,()=>{r.style.background=`transparent`}),r.addEventListener(`click`,e=>{e.stopPropagation(),this.onAction(n)}),r}iconDownload(){return`<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>`}iconCopy(){return`<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg>`}},qr={"1D":`5m`,"5D":`15m`,"1M":`30m`,"3M":`30m`,"6M":`1D`,"1Y":`1D`,"5Y":`1W`,All:`1M`},Jr=[`1D`,`5D`,`1M`,`3M`,`6M`,`1Y`,`5Y`,`All`],Yr=class{constructor(e,t,n,r,i=v,a=E.bottomBar){this.onDurationChange=e,this.buttons=new Map,this.activeDuration=t,this.theme=n,this.cfg=i,this.labels=a,this.map={...qr,...r},this.el=document.createElement(`div`),this.applyBarStyles(n);for(let e of Jr){var o;let r=document.createElement(`button`);r.textContent=(o=this.labels.durations[e])==null?e:o,this.applyButtonStyles(r,n,e===t),r.addEventListener(`click`,()=>{this.setActive(e),this.onDurationChange(e,this.map[e])}),this.buttons.set(e,r),this.el.appendChild(r)}}setTheme(e){this.theme=e,this.applyBarStyles(e);for(let[t,n]of this.buttons)this.applyButtonStyles(n,e,this.activeDuration!==null&&t===this.activeDuration)}setActive(e){if(this.activeDuration!==(e==null?null:e)){if(this.activeDuration){let e=this.buttons.get(this.activeDuration);e&&this.applyButtonStyles(e,this.theme,!1)}if(this.activeDuration=e==null?null:e,e){let t=this.buttons.get(e);t&&this.applyButtonStyles(t,this.theme,!0)}}}applyBarStyles(e){Object.assign(this.el.style,{display:`flex`,alignItems:`center`,justifyContent:`flex-end`,gap:`2px`,height:this.cfg.height,padding:`0 10px`,background:e.background,borderTop:`1px solid ${e.axisBorder}`,boxSizing:`border-box`,flexShrink:`0`})}applyButtonStyles(e,t,n){Object.assign(e.style,{background:n?t.bottomBar.activeBtnBg:`transparent`,color:n?t.bottomBar.activeBtnText:t.bottomBar.btnColor,border:`1px solid ${n?t.bottomBar.activeBtnBorder:`transparent`}`,borderRadius:`3px`,padding:`2px 7px`,fontSize:this.cfg.btnFontSize,fontFamily:this.cfg.btnFontFamily,cursor:`pointer`,outline:`none`,transition:`background 0.15s`})}},Xr={horizontal_line:`horizontalLine`,vertical_line:`verticalLine`,trend_line:`trendLine`,trend_angle:`trendAngle`,cross_line:`crossLine`,parallel_channel:`parallelChannel`,disjoint_channel:`disjointChannel`,flat_channel:`flatChannel`,fib_retracement:`fibRetracement`,fib_extension:`fibExtension`,fib_channel:`fibChannel`,fib_timezone:`fibTimezone`,fib_circles:`fibCircles`,fib_spiral:`fibSpiral`,fib_fan:`fibFan`,gann_fan:`gannFan`,gann_square:`gannSquare`,gann_box:`gannBox`,rectangle:`rectangle`,rotated_rectangle:`rotatedRectangle`,ellipse:`ellipse`,triangle:`triangle`,circle:`circle`,arc:`arc`,polyline:`polyline`,path:`path`,price_range:`priceRange`,date_range:`dateRange`,date_price_range:`datePriceRange`,ruler:`ruler`,pitchfork:`pitchfork`,schiff_pitchfork:`schiffPitchfork`,modified_schiff:`modifiedSchiff`,inside_pitchfork:`insidePitchfork`,fixed_range_vp:`fixedRangeVP`,anchored_vp:`anchoredVP`,volume_profile:`volumeProfile`,regression_trend:`regressionTrend`,text:`text`,callout:`callout`,price_label:`priceLabel`,arrow_marker:`arrowMarker`,flag:`flag`,price_note:`priceNote`,anchored_note:`anchoredNote`,arrow_up:`arrowUp`,arrow_down:`arrowDown`,head_shoulders:`headShoulders`,triangle_pattern:`trianglePattern`,three_drives:`threeDrives`,abcd_pattern:`abcdPattern`,cypher_pattern:`cypherPattern`,butterfly_pattern:`butterflyPattern`,bat_pattern:`batPattern`,gartley_pattern:`gartleyPattern`,crab_pattern:`crabPattern`,shark_pattern:`sharkPattern`,elliott_impulse:`elliottImpulse`,elliott_corrective:`elliottCorrective`,elliott_triangle:`elliottTriangle`,elliott_combination:`elliottCombination`,elliott_wxy:`elliottWxy`,brush:`brush`,highlighter:`highlighter`,ghost_feed:`ghostFeed`,projection:`projection`,sine_line:`sineLine`,cyclic_lines:`cyclicLines`,time_cycles:`timeCycles`,fib_projection:`fibProjection`,price_projection:`priceProjection`},Zr=[{id:`trend_lines`,name:`Trend Lines & Channels`,icon:`↗`,tools:[{id:`trend_line`,name:`Trend Line`,icon:`↗`,shortcut:`Alt+T`},{id:`trend_angle`,name:`Trend Angle`,icon:`∠`},{id:`horizontal_line`,name:`Horizontal Line`,icon:`—`,shortcut:`Alt+H`},{id:`vertical_line`,name:`Vertical Line`,icon:`⏐`,shortcut:`Alt+V`},{id:`cross_line`,name:`Cross Line`,icon:`✚`},{id:`parallel_channel`,name:`Parallel Channel`,icon:`⫿`},{id:`disjoint_channel`,name:`Disjoint Channel`,icon:`≠`},{id:`flat_channel`,name:`Flat Top/Bottom Channel`,icon:`⊓`}]},{id:`fibonacci_gann`,name:`Fibonacci & Gann Tools`,icon:`φ`,tools:[{id:`fib_retracement`,name:`Fibonacci Retracement`,icon:`φ`,shortcut:`Alt+F`},{id:`fib_extension`,name:`Fibonacci Extension`,icon:`φ`},{id:`fib_channel`,name:`Fibonacci Channel`,icon:`φ`},{id:`fib_timezone`,name:`Fibonacci Timezone`,icon:`φ`},{id:`fib_circles`,name:`Fibonacci Circles`,icon:`⊙`},{id:`fib_spiral`,name:`Fibonacci Spiral`,icon:`@`},{id:`fib_fan`,name:`Fibonacci Speed Resistance Fan`,icon:`⌇`},{id:`gann_fan`,name:`Gann Fan`,icon:`⌇`},{id:`gann_square`,name:`Gann Square`,icon:`⊞`},{id:`gann_box`,name:`Gann Box`,icon:`⊡`}]},{id:`geometric_shapes`,name:`Geometric Shapes`,icon:`▭`,tools:[{id:`rectangle`,name:`Rectangle`,icon:`▭`},{id:`rotated_rectangle`,name:`Rotated Rectangle`,icon:`◇`},{id:`ellipse`,name:`Ellipse`,icon:`⬭`},{id:`triangle`,name:`Triangle`,icon:`△`},{id:`circle`,name:`Circle`,icon:`○`},{id:`arc`,name:`Arc`,icon:`⌒`},{id:`polyline`,name:`Polyline`,icon:`⚡`},{id:`path`,name:`Path`,icon:`〰`}]},{id:`measurement_tools`,name:`Measurement Tools`,icon:`⇕`,tools:[{id:`price_range`,name:`Price Range`,icon:`⇕`},{id:`date_range`,name:`Date Range`,icon:`⇔`},{id:`date_price_range`,name:`Date & Price Range`,icon:`⊞`},{id:`ruler`,name:`Ruler`,icon:`⊢`}]},{id:`pitchfork_tools`,name:`Pitchfork Tools`,icon:`⑁`,tools:[{id:`pitchfork`,name:`Pitchfork`,icon:`⑁`},{id:`schiff_pitchfork`,name:`Schiff Pitchfork`,icon:`⑁`},{id:`modified_schiff`,name:`Modified Schiff Pitchfork`,icon:`⑁`},{id:`inside_pitchfork`,name:`Inside Pitchfork`,icon:`⑁`}]},{id:`volume_statistics`,name:`Volume & Statistical Tools`,icon:`▤`,tools:[{id:`fixed_range_vp`,name:`Fixed Range Volume Profile`,icon:`▤`},{id:`anchored_vp`,name:`Anchored Volume Profile`,icon:`▤`},{id:`volume_profile`,name:`Volume Profile`,icon:`▤`},{id:`regression_trend`,name:`Regression Trend`,icon:`↗`}]},{id:`annotation_tools`,name:`Annotation Tools`,icon:`A`,tools:[{id:`text`,name:`Text`,icon:`A`},{id:`callout`,name:`Callout`,icon:`⬕`},{id:`price_label`,name:`Price Label`,icon:`$`},{id:`arrow_marker`,name:`Arrow Marker`,icon:`→`},{id:`flag`,name:`Flag`,icon:`⚑`},{id:`price_note`,name:`Price Note`,icon:`≡`},{id:`anchored_note`,name:`Anchored Note`,icon:`⊕`},{id:`arrow_up`,name:`Arrow Up`,icon:`↑`},{id:`arrow_down`,name:`Arrow Down`,icon:`↓`}]},{id:`pattern_recognition`,name:`Pattern Recognition`,icon:`◬`,tools:[{id:`head_shoulders`,name:`Head & Shoulders`,icon:`⌢`},{id:`triangle_pattern`,name:`Triangle Pattern`,icon:`◬`},{id:`three_drives`,name:`3 Drives Pattern`,icon:`⋎`},{id:`abcd_pattern`,name:`ABCD Pattern`,icon:`⊿`},{id:`cypher_pattern`,name:`Cypher Pattern`,icon:`C`},{id:`butterfly_pattern`,name:`Butterfly Pattern`,icon:`⋈`},{id:`bat_pattern`,name:`Bat Pattern`,icon:`⌓`},{id:`gartley_pattern`,name:`Gartley Pattern`,icon:`G`},{id:`crab_pattern`,name:`Crab Pattern`,icon:`⊓`},{id:`shark_pattern`,name:`Shark Pattern`,icon:`⊳`}]},{id:`elliott_wave`,name:`Elliott Wave Tools`,icon:`∿`,tools:[{id:`elliott_impulse`,name:`Elliott Impulse (12345)`,icon:`∿`},{id:`elliott_corrective`,name:`Elliott Corrective (ABC)`,icon:`∿`},{id:`elliott_triangle`,name:`Elliott Wave Triangle`,icon:`△`},{id:`elliott_combination`,name:`Elliott Wave Combination`,icon:`∿`},{id:`elliott_wxy`,name:`Elliott Double Three (WXY)`,icon:`∿`}]},{id:`brush_highlighter`,name:`Brush & Highlighter`,icon:`∫`,tools:[{id:`brush`,name:`Brush`,icon:`∫`},{id:`highlighter`,name:`Highlighter`,icon:`▬`}]},{id:`advanced_tools`,name:`Advanced Tools`,icon:`⊛`,tools:[{id:`ghost_feed`,name:`Ghost Feed`,icon:`◑`},{id:`projection`,name:`Projection`,icon:`→`},{id:`sine_line`,name:`Sine Line`,icon:`∿`},{id:`cyclic_lines`,name:`Cyclic Lines`,icon:`⟳`},{id:`time_cycles`,name:`Time Cycles`,icon:`⊙`}]},{id:`price_projections`,name:`Price Projection Tools`,icon:`⊿`,tools:[{id:`fib_projection`,name:`Fibonacci Projection`,icon:`φ`},{id:`price_projection`,name:`Price Projection`,icon:`⊿`}]}],Qr=[{id:`undo`,icon:`↶`,title:`Undo (Ctrl+Z)`},{id:`redo`,icon:`↷`,title:`Redo (Ctrl+Y)`},{id:`delete_selected`,icon:`✕`,title:`Delete Selected (Del)`},{id:`clear_all`,icon:`⊡`,title:`Clear All`},{id:`toggle_visibility`,icon:`◌`,title:`Hide All`},{id:`toggle_lock`,icon:`⊠`,title:`Lock All`}],$r=class{constructor(e,t,n,r,i=g,a=E.drawingToolbar){this.onToolChange=e,this.onAction=t,this.onMobileClose=n,this.activeTool=null,this.openCategoryId=null,this.openActionsMenu=!1,this.catButtons=new Map,this.drawingsHidden=!1,this.drawingsLocked=!1,this.mobileMode=!1,this.settingsVisible=!0,this.theme=r,this.cfg=i,this.labels=a,this.el=document.createElement(`div`),this.flyout=document.createElement(`div`),this.applyBarStyles(),this.applyWidth(),this.buildToolbar(),this.buildFlyout(),document.body.appendChild(this.flyout),this.docClickHandler=e=>{!this.el.contains(e.target)&&!this.flyout.contains(e.target)&&this.closeFlyout()},document.addEventListener(`click`,this.docClickHandler,!0)}setTheme(e){this.theme=e,this.closeFlyout(),this.applyBarStyles(),this.applyWidth(),this.buildFlyout(),this.applyScrollBtnStyles(this.scrollUpBtn,`up`),this.applyScrollBtnStyles(this.scrollDownBtn,`down`),this.topSection.innerHTML=``,this.topSection.appendChild(this.buildMobileActionsBtn());for(let[e,n]of this.catButtons){var t;let r=this.activeTool!==null&&((t=Zr.find(t=>t.id===e))==null?void 0:t.tools.some(e=>Xr[e.id]===this.activeTool))===!0;this.applyCatBtnStyles(n,r)}}setActiveTool(e){if(this.activeTool!==null){let e=Zr.find(e=>e.tools.some(e=>Xr[e.id]===this.activeTool));e&&this.applyCatBtnStyles(this.catButtons.get(e.id),!1)}if(this.activeTool=e,e!==null){let t=Zr.find(t=>t.tools.some(t=>Xr[t.id]===e));t&&this.applyCatBtnStyles(this.catButtons.get(t.id),!0)}}setVisible(e){this.settingsVisible=e,this.applyWidth()}setMobileMode(e){if(this.mobileMode===e)return;this.mobileMode=e,this.closeFlyout(),this.topSection.innerHTML=``,this.topSection.appendChild(this.buildMobileActionsBtn()),this.catButtons.clear();let t=this.makeGrid();if(this.populateCategoryGrid(t),this.toolsGrid.replaceWith(t),this.toolsGrid=t,this.activeTool!==null){let e=Zr.find(e=>e.tools.some(e=>Xr[e.id]===this.activeTool));if(e){let t=this.catButtons.get(e.id);t&&this.applyCatBtnStyles(t,!0)}}e?(Object.assign(this.el.style,{position:`absolute`,left:`0`,top:`0`,height:`100%`,zIndex:`50`}),this.settingsVisible=!1):(Object.assign(this.el.style,{position:``,left:``,top:``,height:``,zIndex:``}),this.settingsVisible=!0),this.applyBarStyles(),this.applyWidth(),requestAnimationFrame(()=>this.updateScrollIndicators())}reparentFlyout(e){this.flyout.parentElement!==e&&e.appendChild(this.flyout)}destroy(){this.flyout.remove(),document.removeEventListener(`click`,this.docClickHandler,!0)}get barWidth(){return this.cfg.barPadding*2+this.cfg.iconBtnSize}applyBarStyles(){Object.assign(this.el.style,{display:`flex`,flexDirection:`column`,flexShrink:`0`,position:`relative`,height:`100%`,background:this.theme.background,borderRight:`1px solid ${this.theme.axisBorder}`,boxSizing:`border-box`,userSelect:`none`,fontFamily:this.cfg.flyoutLabelFontFamily,overflow:`hidden`,transition:`width 0.2s ease`})}applyWidth(){this.settingsVisible?this.el.style.width=`${this.barWidth}px`:this.el.style.width=`0`}buildToolbar(){this.topSection=document.createElement(`div`),Object.assign(this.topSection.style,{borderBottom:`1px solid ${this.theme.axisBorder}`,padding:`10px ${this.cfg.barPadding}px 10px`,boxSizing:`border-box`,flexShrink:`0`}),this.topSection.appendChild(this.buildMobileActionsBtn()),this.el.appendChild(this.topSection),this.scrollUpBtn=document.createElement(`button`),this.applyScrollBtnStyles(this.scrollUpBtn,`up`),this.scrollUpBtn.addEventListener(`click`,()=>{this.toolsArea.scrollBy({top:-(this.cfg.iconBtnSize+this.cfg.btnGap)*3,behavior:`smooth`})}),this.el.appendChild(this.scrollUpBtn),this.toolsArea=document.createElement(`div`),Object.assign(this.toolsArea.style,{flex:`1`,overflowY:`scroll`,padding:`10px ${this.cfg.barPadding}px 4px`,boxSizing:`border-box`,scrollbarWidth:`none`,msOverflowStyle:`none`});let e=document.createElement(`style`);e.textContent=`.lb-tools::-webkit-scrollbar{display:none}`,document.head.appendChild(e),this.toolsArea.classList.add(`lb-tools`),this.toolsGrid=this.makeGrid(),this.populateCategoryGrid(this.toolsGrid),this.toolsArea.appendChild(this.toolsGrid),this.toolsArea.addEventListener(`scroll`,()=>this.updateScrollIndicators()),this.el.appendChild(this.toolsArea),this.scrollDownBtn=document.createElement(`button`),this.applyScrollBtnStyles(this.scrollDownBtn,`down`),this.scrollDownBtn.addEventListener(`click`,()=>{this.toolsArea.scrollBy({top:(this.cfg.iconBtnSize+this.cfg.btnGap)*3,behavior:`smooth`})}),this.el.appendChild(this.scrollDownBtn),requestAnimationFrame(()=>this.updateScrollIndicators())}buildMobileActionsBtn(){let e=document.createElement(`button`);return e.title=this.labels.actions.moreActions,e.innerHTML=this.cfg.modernIcons?Cn:Sn,this.applyActionBtnStyles(e,!1),this.addBtnHover(e),e.addEventListener(`click`,t=>{t.stopPropagation(),this.toggleActionsFlyout(e)}),e}populateCategoryGrid(e){this.catButtons.clear();for(let r of Zr){var t,n;let i=document.createElement(`button`);i.title=this.getCategoryLabel(r.id),i.innerHTML=(t=(n=(this.cfg.modernIcons?an:rn)[r.id])==null?rn[r.id]:n)==null?r.icon:t,this.applyCatBtnStyles(i,!1),this.addBtnHover(i),i.addEventListener(`click`,e=>{e.stopPropagation(),this.toggleCategory(r,i)}),this.catButtons.set(r.id,i),e.appendChild(i)}}updateScrollIndicators(){let{scrollTop:e,scrollHeight:t,clientHeight:n}=this.toolsArea,r=e>2,i=e+n<t-2;this.mobileMode?(this.scrollUpBtn.style.display=`flex`,this.scrollDownBtn.style.display=`flex`,this.scrollUpBtn.style.opacity=r?`0.9`:`0.2`,this.scrollDownBtn.style.opacity=i?`0.9`:`0.2`):(this.scrollUpBtn.style.display=r?`flex`:`none`,this.scrollDownBtn.style.display=i?`flex`:`none`)}buildFlyout(){Object.assign(this.flyout.style,{position:`fixed`,zIndex:`9999`,display:`none`,background:this.theme.background,border:`1px solid ${this.theme.axisBorder}`,borderRadius:`6px`,padding:`6px 0`,minWidth:`200px`,boxShadow:`0 4px 16px rgba(0,0,0,0.45)`,fontFamily:this.cfg.flyoutLabelFontFamily,fontSize:this.cfg.flyoutLabelFontSize})}makeGrid(e=1){let t=document.createElement(`div`);return Object.assign(t.style,{display:`grid`,gridTemplateColumns:`repeat(${e}, ${this.cfg.iconBtnSize}px)`,gap:`${this.cfg.btnGap}px`}),t}applyScrollBtnStyles(e,t){e.innerHTML=t===`up`?bn:xn,e.title=t===`up`?this.labels.scrollUp:this.labels.scrollDown;let n=e.style.display||`none`;Object.assign(e.style,{display:n,width:`100%`,height:`${this.cfg.scrollBtnHeight}px`,background:this.theme.background,color:this.theme.tooltip.text,border:`none`,borderBottom:t===`up`?`1px solid ${this.theme.axisBorder}`:`none`,borderTop:t===`down`?`1px solid ${this.theme.axisBorder}`:`none`,fontSize:this.cfg.scrollBtnFontSize,cursor:`pointer`,outline:`none`,alignItems:`center`,justifyContent:`center`,flexShrink:`0`,opacity:`0.6`})}toggleCategory(e,t){if(this.openCategoryId===e.id){this.closeFlyout();return}this.openCategoryId=e.id;let n=t.getBoundingClientRect();Object.assign(this.flyout.style,{display:`block`,left:`${n.right+4}px`,top:`${n.top}px`}),this.flyout.innerHTML=``;let r=document.createElement(`div`);Object.assign(r.style,{padding:`4px 12px 8px`,fontSize:this.cfg.flyoutHeadingFontSize,fontWeight:`600`,letterSpacing:this.cfg.flyoutHeadingLetterSpacing,color:this.theme.drawingToolbar.flyoutHeadingColor,textTransform:`uppercase`,borderBottom:`1px solid ${this.theme.axisBorder}`,marginBottom:`4px`,opacity:`0.6`}),r.textContent=this.getCategoryLabel(e.id),this.flyout.appendChild(r);for(let t of e.tools){var i,a;let n=t.id in Xr,r=this.activeTool!==null&&Xr[t.id]===this.activeTool,o=document.createElement(`button`);Object.assign(o.style,{width:`100%`,padding:`5px 12px`,background:r?this.theme.ui.accentBg:`transparent`,border:`none`,borderLeft:r?`2px solid ${this.theme.ui.accent}`:`2px solid transparent`,color:r?this.theme.ui.accentText:n?this.theme.drawingToolbar.flyoutLabelColor:this.theme.ui.disabledText,fontSize:this.cfg.flyoutLabelFontSize,fontFamily:this.cfg.flyoutLabelFontFamily,textAlign:`left`,cursor:n?`pointer`:`default`,display:`flex`,alignItems:`center`,gap:`8px`,boxSizing:`border-box`});let s=document.createElement(`span`);Object.assign(s.style,{width:`16px`,display:`flex`,alignItems:`center`,flexShrink:`0`}),s.innerHTML=(i=(a=un[t.id])==null?rn[e.id]:a)==null?t.icon:i;let c=document.createElement(`span`);if(c.style.flex=`1`,c.textContent=this.getToolLabel(t),o.appendChild(s),o.appendChild(c),t.shortcut&&n){let e=document.createElement(`span`);Object.assign(e.style,{fontSize:this.cfg.shortcutFontSize,color:this.theme.ui.disabledText,flexShrink:`0`}),e.textContent=t.shortcut,o.appendChild(e)}else if(!n){let e=document.createElement(`span`);Object.assign(e.style,{fontSize:this.cfg.soonBadgeFontSize,color:this.theme.ui.soonBadgeText,flexShrink:`0`}),e.textContent=this.labels.soonBadge,o.appendChild(e)}if(n){if(!r){let e=this.theme.ui.accentBg;o.addEventListener(`mouseenter`,()=>{o.style.background=e}),o.addEventListener(`mouseleave`,()=>{o.style.background=`transparent`})}o.addEventListener(`click`,()=>{let e=Xr[t.id],n=this.activeTool===e?null:e;if(this.setActiveTool(n),this.onToolChange(n),this.closeFlyout(),this.mobileMode&&n!==null){var r;this.settingsVisible=!1,this.applyWidth(),(r=this.onMobileClose)==null||r.call(this)}})}this.flyout.appendChild(o)}requestAnimationFrame(()=>{let e=this.flyout.getBoundingClientRect();e.bottom>window.innerHeight-8&&(this.flyout.style.top=`${window.innerHeight-e.height-8}px`)})}closeFlyout(){this.flyout.style.display=`none`,this.openCategoryId=null,this.openActionsMenu=!1}toggleActionsFlyout(e){if(this.openActionsMenu){this.closeFlyout();return}this.closeFlyout(),this.openActionsMenu=!0,this.flyout.innerHTML=``;let t=document.createElement(`div`);Object.assign(t.style,{padding:`4px 12px 8px`,fontSize:this.cfg.flyoutHeadingFontSize,fontWeight:`600`,letterSpacing:this.cfg.flyoutHeadingLetterSpacing,color:this.theme.drawingToolbar.flyoutHeadingColor,textTransform:`uppercase`,borderBottom:`1px solid ${this.theme.axisBorder}`,marginBottom:`4px`,opacity:`0.6`}),t.textContent=this.labels.actions.moreActions,this.flyout.appendChild(t);for(let e of Qr){var n,r,i;let t=e.id===`toggle_visibility`?this.drawingsHidden:e.id===`toggle_lock`?this.drawingsLocked:!1,a=t?(n=(r=sn[e.id])==null?on[e.id]:r)==null?e.icon:n:(i=on[e.id])==null?e.icon:i,o=e.id===`toggle_visibility`?this.drawingsHidden?this.labels.actions.showAll:this.labels.actions.hideAll:e.id===`toggle_lock`?this.drawingsLocked?this.labels.actions.unlockAll:this.labels.actions.lockAll:this.getActionLabel(e.id),s=document.createElement(`button`);Object.assign(s.style,{width:`100%`,padding:`6px 12px`,background:t?this.theme.ui.accentBg:`transparent`,border:`none`,borderLeft:t?`2px solid ${this.theme.ui.accent}`:`2px solid transparent`,color:t?this.theme.ui.accentText:this.theme.drawingToolbar.flyoutLabelColor,fontSize:this.cfg.flyoutLabelFontSize,fontFamily:this.cfg.flyoutLabelFontFamily,textAlign:`left`,cursor:`pointer`,display:`flex`,alignItems:`center`,gap:`8px`,boxSizing:`border-box`});let c=document.createElement(`span`);Object.assign(c.style,{width:`16px`,display:`flex`,alignItems:`center`,flexShrink:`0`}),c.innerHTML=a;let l=document.createElement(`span`);l.style.flex=`1`,l.textContent=o,s.appendChild(c),s.appendChild(l);let u=this.theme.ui.accentBg;t||(s.addEventListener(`mouseenter`,()=>{s.style.background=u}),s.addEventListener(`mouseleave`,()=>{s.style.background=`transparent`})),s.addEventListener(`click`,()=>{e.id===`toggle_visibility`?(this.drawingsHidden=!this.drawingsHidden,this.onAction(this.drawingsHidden?`hide_all`:`show_all`)):e.id===`toggle_lock`?(this.drawingsLocked=!this.drawingsLocked,this.onAction(this.drawingsLocked?`lock_all`:`unlock_all`)):this.onAction(e.id),this.closeFlyout()}),this.flyout.appendChild(s)}let a=e.getBoundingClientRect(),o=this.el.getBoundingClientRect();Object.assign(this.flyout.style,{display:`block`,left:`${o.right+4}px`,top:`${a.top}px`}),requestAnimationFrame(()=>{let e=this.flyout.getBoundingClientRect();e.bottom>window.innerHeight-8&&(this.flyout.style.top=`${window.innerHeight-e.height-8}px`)})}getCategoryLabel(e){let t={trend_lines:`trendLines`,fibonacci_gann:`fibonacci`,geometric_shapes:`shapes`,measurement_tools:`measurements`,pitchfork_tools:`pitchforks`,volume_statistics:`volume`,annotation_tools:`annotations`,pattern_recognition:`patterns`,elliott_wave:`elliott`,brush_highlighter:`brushes`,advanced_tools:`advanced`,price_projections:`priceProjection`}[e];return t?this.labels.categories[t]:e}getToolLabel(e){let t=Xr[e.id];return t&&this.labels.tools[t]?this.labels.tools[t]:e.name}getActionLabel(e){let t={undo:`undo`,redo:`redo`,delete_selected:`deleteSelected`,clear_all:`clearAll`,toggle_visibility:`hideAll`,toggle_lock:`lockAll`}[e];return t?this.labels.actions[t]:e}addBtnHover(e){e.addEventListener(`mouseenter`,()=>{e.dataset.active!==`true`&&(e.style.background=this.theme.ui.accentBg)}),e.addEventListener(`mouseleave`,()=>{e.dataset.active!==`true`&&(e.style.background=`transparent`)})}applyCatBtnStyles(e,t){e.dataset.active=String(t),Object.assign(e.style,{width:`${this.cfg.iconBtnSize}px`,height:`${this.cfg.iconBtnSize}px`,background:t?this.theme.ui.accentBgStrong:`transparent`,color:t?this.theme.drawingToolbar.activeIconColor:this.theme.drawingToolbar.iconColor,border:t?`1px solid ${this.theme.ui.accent}`:this.cfg.modernIcons?`1px solid transparent`:`1px solid ${this.theme.axisBorder}`,borderRadius:this.cfg.modernIcons?`6px`:`5px`,cursor:`pointer`,outline:`none`,display:`flex`,alignItems:`center`,justifyContent:`center`,padding:`0`,transition:`background 0.15s, color 0.15s`})}applyActionBtnStyles(e,t){e.dataset.active=String(t),Object.assign(e.style,{width:`${this.cfg.iconBtnSize}px`,height:`${this.cfg.iconBtnSize}px`,background:t?this.theme.ui.accentBgStrong:`transparent`,color:t?this.theme.drawingToolbar.activeIconColor:this.theme.drawingToolbar.iconColor,border:t?`1px solid ${this.theme.ui.accent}`:this.cfg.modernIcons?`1px solid transparent`:`1px solid ${this.theme.axisBorder}`,borderRadius:this.cfg.modernIcons?`6px`:`5px`,cursor:`pointer`,outline:`none`,display:`flex`,alignItems:`center`,justifyContent:`center`,padding:`0`,transition:`background 0.15s, color 0.15s`})}};function Y(e,t,n){var r,i,a,o,s,c,l,u;let d=(r=n==null||(i=n.drawing)==null?void 0:i[e])==null?{}:r,f={...d,...t==null?{}:t},p=d.levels,m=t==null?void 0:t.levels;if(p||m){let e={};for(let t of Object.keys(p==null?{}:p)){let n=p==null?void 0:p[t];n&&(e[t]=n)}if(m)for(let t of Object.keys(m)){var h;let n=m[t];if(n===null){delete e[t];continue}e[t]={...(h=e[t])==null?{visible:!0,color:`#888888`}:h,...n}}f.levels=e}return{strokeColor:(a=f.strokeColor)==null?`#888888`:a,lineWidth:(o=f.lineWidth)==null?1:o,lineStyle:(s=f.lineStyle)==null?`solid`:s,fillColor:(c=(l=f.fillColor)==null?f.strokeColor:l)==null?`#888888`:c,fillOpacity:(u=f.fillOpacity)==null?.1:u,...f.textColor!==void 0&&{textColor:f.textColor},...f.fontSize!==void 0&&{fontSize:f.fontSize},...f.levels!==void 0&&{levels:f.levels}}}function X(e,t,n){let r=Math.max(1,n);t===`dashed`?e.setLineDash([6*r,3*r]):t===`dotted`?e.setLineDash([2*r,3*r]):e.setLineDash([])}function Z(e,t){if(!e.startsWith(`#`))return e;let n=Math.round(Math.max(0,Math.min(1,t))*255).toString(16).padStart(2,`0`),r=e.slice(1);return r.length===3?r=r.split(``).map(e=>e+e).join(``):r.length===4?r=r.slice(0,3).split(``).map(e=>e+e).join(``):r.length===8&&(r=r.slice(0,6)),r.length===6?`#${r}${n}`:e}var ei=6,ti=class{constructor(e){this.type=`horizontalLine`,this.id=`hl_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e],this.complete=!0}render(e,t,n,r,i,a,o,s=2,c){let l=this.points[0].price,u=t.yToPixel(l,r,a),d=Y(`horizontalLine`,this.style,c);e.save(),e.strokeStyle=d.strokeColor,e.lineWidth=o?d.lineWidth+.5:d.lineWidth,X(e,o?`solid`:d.lineStyle,e.lineWidth),e.beginPath(),e.moveTo(0,u),e.lineTo(i,u),e.stroke(),e.setLineDash([]);let f=l.toFixed(s);e.font=`10px 'Inter', system-ui, sans-serif`;let p=e.measureText(f).width;e.fillStyle=d.strokeColor,e.fillText(f,i-p-4,u-3),e.restore()}hitTest(e,t,n,r,i,a,o){let s=n.yToPixel(this.points[0].price,i,o);return Math.abs(t-s)<=ei}getHandle(){return null}},ni=6,ri=class{constructor(e){this.type=`verticalLine`,this.id=`vl_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e],this.complete=!0}render(e,t,n,r,i,a,o,s,c){let l=t.xToPixel(this.points[0].barIndex,n,i),u=Y(`verticalLine`,this.style,c);e.save(),e.strokeStyle=u.strokeColor,e.lineWidth=o?u.lineWidth+.5:u.lineWidth,X(e,o?`solid`:u.lineStyle,e.lineWidth),e.beginPath(),e.moveTo(l,0),e.lineTo(l,a),e.stroke(),e.setLineDash([]),e.restore()}hitTest(e,t,n,r,i,a,o){let s=n.xToPixel(this.points[0].barIndex,r,a);return Math.abs(e-s)<=ni}getHandle(){return null}},ii=6;function ai(e,t,n,r,i,a){let o=i-n,s=a-r,c=o*o+s*s;if(c===0)return Math.hypot(e-n,t-r);let l=Math.max(0,Math.min(1,((e-n)*o+(t-r)*s)/c));return Math.hypot(e-(n+l*o),t-(r+l*s))}var oi=class{constructor(e){this.type=`trendLine`,this.id=`tl_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let[l,u]=this.points,d=t.xToPixel(l.barIndex,n,i),f=t.yToPixel(l.price,r,a),p=t.xToPixel(u.barIndex,n,i),m=t.yToPixel(u.price,r,a),h=Y(`trendLine`,this.style,c);e.save(),e.strokeStyle=h.strokeColor,e.lineWidth=o?h.lineWidth+.5:h.lineWidth,X(e,o?`solid`:h.lineStyle,e.lineWidth),e.beginPath(),e.moveTo(d,f),e.lineTo(p,m),e.stroke(),e.setLineDash([]);for(let[t,n]of[[d,f],[p,m]])e.beginPath(),e.arc(t,n,o?4:3,0,Math.PI*2),e.fillStyle=h.strokeColor,e.fill();e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let[s,c]=this.points;return ai(e,t,n.xToPixel(s.barIndex,r,a),n.yToPixel(s.price,i,o),n.xToPixel(c.barIndex,r,a),n.yToPixel(c.price,i,o))<=ii}getHandle(e,t,n,r,i,a,o){if(this.points.length<2)return null;let s=[{px:n.xToPixel(this.points[0].barIndex,r,a),py:n.yToPixel(this.points[0].price,i,o)},{px:n.xToPixel(this.points[1].barIndex,r,a),py:n.yToPixel(this.points[1].price,i,o)}];for(let n=0;n<s.length;n++)if(Math.hypot(e-s[n].px,t-s[n].py)<=ii+2)return{pointIndex:n,cursor:`grab`};return null}},si=6;function ci(e,t,n,r,i,a){let o=i-n,s=a-r,c=o*o+s*s;if(c===0)return Math.hypot(e-n,t-r);let l=Math.max(0,Math.min(1,((e-n)*o+(t-r)*s)/c));return Math.hypot(e-(n+l*o),t-(r+l*s))}var li=class{constructor(e){this.type=`trendAngle`,this.id=`ta_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let[l,u]=this.points,d=t.xToPixel(l.barIndex,n,i),f=t.yToPixel(l.price,r,a),p=t.xToPixel(u.barIndex,n,i),m=t.yToPixel(u.price,r,a),h=Math.atan2(-(m-f),p-d)*180/Math.PI,g=Math.atan2(-(m-f),p-d),_=Y(`trendAngle`,this.style,c);e.save(),e.strokeStyle=_.strokeColor,e.fillStyle=_.strokeColor,e.lineWidth=o?_.lineWidth+.5:_.lineWidth,X(e,o?`solid`:_.lineStyle,e.lineWidth),e.beginPath(),e.moveTo(d,f),e.lineTo(p,m),e.stroke(),e.beginPath(),e.arc(d,f,28,-g,0,g<0),e.stroke(),e.setLineDash([4,3]),e.globalAlpha=.5,e.beginPath(),e.moveTo(d,f),e.lineTo(d+28+8,f),e.stroke(),e.setLineDash([]),e.globalAlpha=1;let v=d+28+6,y=f-(g>=0?6:-14);if(e.font=`bold 11px 'Inter', system-ui, sans-serif`,e.fillText(`${h.toFixed(1)}°`,v,y),o)for(let[t,n]of[[d,f],[p,m]])e.beginPath(),e.arc(t,n,4,0,Math.PI*2),e.fill();e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let[s,c]=this.points;return ci(e,t,n.xToPixel(s.barIndex,r,a),n.yToPixel(s.price,i,o),n.xToPixel(c.barIndex,r,a),n.yToPixel(c.price,i,o))<=si}getHandle(e,t,n,r,i,a,o){if(this.points.length<2)return null;let s=[{px:n.xToPixel(this.points[0].barIndex,r,a),py:n.yToPixel(this.points[0].price,i,o)},{px:n.xToPixel(this.points[1].barIndex,r,a),py:n.yToPixel(this.points[1].price,i,o)}];for(let n=0;n<s.length;n++)if(Math.hypot(e-s[n].px,t-s[n].py)<=si+2)return{pointIndex:n,cursor:`grab`};return null}},ui=6,di=class{constructor(e){this.type=`crossLine`,this.id=`xl_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e],this.complete=!0}render(e,t,n,r,i,a,o,s,c){let l=this.points[0],u=t.xToPixel(l.barIndex,n,i),d=t.yToPixel(l.price,r,a),f=Y(`crossLine`,this.style,c);e.save(),e.strokeStyle=f.strokeColor,e.lineWidth=o?f.lineWidth+.5:f.lineWidth,X(e,o?`solid`:f.lineStyle,e.lineWidth),e.beginPath(),e.moveTo(0,d),e.lineTo(i,d),e.stroke(),e.beginPath(),e.moveTo(u,0),e.lineTo(u,a),e.stroke(),e.setLineDash([]),e.restore()}hitTest(e,t,n,r,i,a,o){let s=this.points[0],c=n.xToPixel(s.barIndex,r,a),l=n.yToPixel(s.price,i,o);return Math.abs(t-l)<=ui||Math.abs(e-c)<=ui}getHandle(){return null}},fi=6;function pi(e,t,n,r,i,a){let o=i-n,s=a-r,c=o*o+s*s;if(c===0)return Math.hypot(e-n,t-r);let l=Math.max(0,Math.min(1,((e-n)*o+(t-r)*s)/c));return Math.hypot(e-(n+l*o),t-(r+l*s))}var mi=class{constructor(e){this.type=`parallelChannel`,this.requiredPoints=3,this.id=`pch_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let[l,u,d]=this.points,f=t.xToPixel(l.barIndex,n,i),p=t.yToPixel(l.price,r,a),m=t.xToPixel(u.barIndex,n,i),h=t.yToPixel(u.price,r,a),g=0;if(d){let e=(l.price+u.price)/2,n=t.yToPixel(e,r,a);g=t.yToPixel(d.price,r,a)-n}let _=f,v=p+g,y=m,b=h+g,x=Y(`parallelChannel`,this.style,c);if(e.save(),e.strokeStyle=x.strokeColor,e.lineWidth=o?x.lineWidth+.5:x.lineWidth,X(e,o?`solid`:x.lineStyle,e.lineWidth),e.beginPath(),e.moveTo(f,p),e.lineTo(m,h),e.lineTo(y,b),e.lineTo(_,v),e.closePath(),e.fillStyle=Z(x.fillColor,x.fillOpacity),e.fill(),e.beginPath(),e.moveTo(f,p),e.lineTo(m,h),e.stroke(),d&&(e.beginPath(),e.moveTo(_,v),e.lineTo(y,b),e.stroke()),e.setLineDash([]),o){let o=[[f,p],[m,h]];if(d){let e=t.xToPixel(d.barIndex,n,i),s=t.yToPixel(d.price,r,a);o.push([e,s])}e.fillStyle=x.strokeColor;for(let[t,n]of o)e.beginPath(),e.arc(t,n,4,0,Math.PI*2),e.fill()}e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let[s,c,l]=this.points,u=n.xToPixel(s.barIndex,r,a),d=n.yToPixel(s.price,i,o),f=n.xToPixel(c.barIndex,r,a),p=n.yToPixel(c.price,i,o);if(pi(e,t,u,d,f,p)<=fi)return!0;if(l){let r=(s.price+c.price)/2,a=n.yToPixel(r,i,o),m=n.yToPixel(l.price,i,o)-a;if(pi(e,t,u,d+m,f,p+m)<=fi)return!0}return!1}getHandle(e,t,n,r,i,a,o){let s=this.points.map((e,t)=>({i:t,px:n.xToPixel(e.barIndex,r,a),py:n.yToPixel(e.price,i,o)}));for(let{i:n,px:r,py:i}of s)if(Math.hypot(e-r,t-i)<=fi+2)return{pointIndex:n,cursor:`grab`};return null}},hi=6;function gi(e,t,n,r,i,a){let o=i-n,s=a-r,c=o*o+s*s;if(c===0)return Math.hypot(e-n,t-r);let l=Math.max(0,Math.min(1,((e-n)*o+(t-r)*s)/c));return Math.hypot(e-(n+l*o),t-(r+l*s))}var _i=class{constructor(e){this.type=`flatChannel`,this.requiredPoints=3,this.id=`fch_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let[l,u,d]=this.points,f=t.xToPixel(l.barIndex,n,i),p=t.xToPixel(u.barIndex,n,i),m=t.yToPixel(l.price,r,a),h=d?d.price-l.price:0,g=t.yToPixel(l.price+h,r,a),_=Y(`flatChannel`,this.style,c);if(e.save(),e.strokeStyle=_.strokeColor,e.lineWidth=o?_.lineWidth+.5:_.lineWidth,X(e,o?`solid`:_.lineStyle,e.lineWidth),e.beginPath(),e.rect(Math.min(f,p),Math.min(m,g),Math.abs(p-f),Math.abs(g-m)),e.fillStyle=Z(_.fillColor,_.fillOpacity),e.fill(),e.beginPath(),e.moveTo(f,m),e.lineTo(p,m),e.stroke(),d&&(e.beginPath(),e.moveTo(f,g),e.lineTo(p,g),e.stroke()),e.setLineDash([]),o){e.fillStyle=_.strokeColor;let o=[[f,m],[p,m]];if(d){let e=t.xToPixel(d.barIndex,n,i),s=t.yToPixel(d.price,r,a);o.push([e,s])}for(let[t,n]of o)e.beginPath(),e.arc(t,n,4,0,Math.PI*2),e.fill()}e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let[s,c,l]=this.points,u=n.xToPixel(s.barIndex,r,a),d=n.xToPixel(c.barIndex,r,a),f=n.yToPixel(s.price,i,o);if(gi(e,t,u,f,d,f)<=hi)return!0;if(l){let r=l.price-s.price,a=n.yToPixel(s.price+r,i,o);if(gi(e,t,u,a,d,a)<=hi)return!0}return!1}getHandle(e,t,n,r,i,a,o){let s=this.points.map((e,t)=>({i:t,px:n.xToPixel(e.barIndex,r,a),py:n.yToPixel(e.price,i,o)}));for(let{i:n,px:r,py:i}of s)if(Math.hypot(e-r,t-i)<=hi+2)return{pointIndex:n,cursor:`grab`};return null}},vi=6;function yi(e,t,n,r,i,a){let o=i-n,s=a-r,c=o*o+s*s;if(c===0)return Math.hypot(e-n,t-r);let l=Math.max(0,Math.min(1,((e-n)*o+(t-r)*s)/c));return Math.hypot(e-(n+l*o),t-(r+l*s))}var bi=class{constructor(e){this.type=`disjointChannel`,this.requiredPoints=4,this.id=`dch_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let l=e=>[t.xToPixel(e.barIndex,n,i),t.yToPixel(e.price,r,a)],[u,d,f,p]=this.points,[m,h]=l(u),[g,_]=l(d),v=Y(`disjointChannel`,this.style,c);if(e.save(),e.strokeStyle=v.strokeColor,e.lineWidth=o?v.lineWidth+.5:v.lineWidth,X(e,o?`solid`:v.lineStyle,e.lineWidth),f&&p){let[t,n]=l(f),[r,i]=l(p);if(e.beginPath(),e.moveTo(m,h),e.lineTo(g,_),e.lineTo(r,i),e.lineTo(t,n),e.closePath(),e.fillStyle=Z(v.fillColor,v.fillOpacity),e.fill(),e.beginPath(),e.moveTo(m,h),e.lineTo(g,_),e.stroke(),e.beginPath(),e.moveTo(t,n),e.lineTo(r,i),e.stroke(),e.setLineDash([]),o){e.fillStyle=v.strokeColor;for(let[a,o]of[[m,h],[g,_],[t,n],[r,i]])e.beginPath(),e.arc(a,o,4,0,Math.PI*2),e.fill()}}else if(f){let[t,n]=l(f);if(e.beginPath(),e.moveTo(m,h),e.lineTo(g,_),e.stroke(),e.beginPath(),e.moveTo(t,n),e.lineTo(t,n),e.stroke(),e.setLineDash([]),o){e.fillStyle=v.strokeColor;for(let[r,i]of[[m,h],[g,_],[t,n]])e.beginPath(),e.arc(r,i,4,0,Math.PI*2),e.fill()}}else if(e.beginPath(),e.moveTo(m,h),e.lineTo(g,_),e.stroke(),e.setLineDash([]),o){e.fillStyle=v.strokeColor;for(let[t,n]of[[m,h],[g,_]])e.beginPath(),e.arc(t,n,4,0,Math.PI*2),e.fill()}e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let s=e=>[n.xToPixel(e.barIndex,r,a),n.yToPixel(e.price,i,o)],[c,l,u,d]=this.points,[f,p]=s(c),[m,h]=s(l);if(yi(e,t,f,p,m,h)<=vi)return!0;if(u&&d){let[n,r]=s(u),[i,a]=s(d);if(yi(e,t,n,r,i,a)<=vi)return!0}return!1}getHandle(e,t,n,r,i,a,o){let s=this.points.map((e,t)=>({i:t,px:n.xToPixel(e.barIndex,r,a),py:n.yToPixel(e.price,i,o)}));for(let{i:n,px:r,py:i}of s)if(Math.hypot(e-r,t-i)<=vi+2)return{pointIndex:n,cursor:`grab`};return null}},xi=[0,.236,.382,.5,.618,.786,1],Si=[`#ef5350`,`#e8b84b`,`#26a69a`,`#2196f3`,`#26a69a`,`#e8b84b`,`#ef5350`],Ci=6;function wi(e){let t=()=>xi.map(e=>({key:String(e),value:e}));if(!e)return t();let n=Object.keys(e).filter(t=>e[t]!==null).map(e=>({key:e,value:Number(e)})).filter(e=>Number.isFinite(e.value));return n.length?n.sort((e,t)=>e.value-t.value):t()}var Ti=class{constructor(e){this.type=`fibRetracement`,this.id=`fib_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s=2,c){var l;if(this.points.length<2)return;let[u,d]=this.points,f=Math.max(u.price,d.price),p=f-Math.min(u.price,d.price),m=t.xToPixel(u.barIndex,n,i),h=t.yToPixel(u.price,r,a),g=t.xToPixel(d.barIndex,n,i),_=t.yToPixel(d.price,r,a),v=Math.min(m,g),y=Math.max(m,g),b=Y(`fibRetracement`,this.style,c),x=o?b.lineWidth+.5:b.lineWidth,S=(l=b.strokeColor)==null?Si[1]:l;e.save(),e.font=`10px 'Inter', system-ui, sans-serif`,e.lineWidth=x;let C=wi(b.levels),w=[];for(let n=0;n<C.length;n++){var T,E,D;let{key:i,value:c}=C[n],l=(T=b.levels)==null?void 0:T[i];if((l==null?void 0:l.visible)===!1)continue;w.push(c);let u=f-p*c,d=t.yToPixel(u,r,a),m=Z((E=(D=l==null?void 0:l.color)==null?b.strokeColor:D)==null?Si[n%Si.length]:E,o?.8:.6);e.strokeStyle=m,X(e,o?`solid`:b.lineStyle,x),e.beginPath(),e.moveTo(v,d),e.lineTo(y,d),e.stroke(),e.setLineDash([]);let h=`${`${(c*100).toFixed(1)}%`} ${u.toFixed(s)}`;e.fillStyle=m,e.fillText(h,v+4,d-3)}this.visibleLevels=w;for(let[t,n]of[[m,h],[g,_]])e.beginPath(),e.arc(t,n,o?4:3,0,Math.PI*2),e.fillStyle=S,e.fill();e.restore()}hitTest(e,t,n,r,i,a,o){var s;if(this.points.length<2)return!1;let c=Math.max(this.points[0].price,this.points[1].price),l=c-Math.min(this.points[0].price,this.points[1].price);for(let e of(s=this.visibleLevels)==null?xi:s){let r=c-l*e,a=n.yToPixel(r,i,o);if(Math.abs(t-a)<=Ci)return!0}return!1}getHandle(e,t,n,r,i,a,o){if(this.points.length<2)return null;let s=[{px:n.xToPixel(this.points[0].barIndex,r,a),py:n.yToPixel(this.points[0].price,i,o)},{px:n.xToPixel(this.points[1].barIndex,r,a),py:n.yToPixel(this.points[1].price,i,o)}];for(let n=0;n<s.length;n++)if(Math.hypot(e-s[n].px,t-s[n].py)<=Ci+2)return{pointIndex:n,cursor:`grab`};return null}},Ei=6,Di=[0,.382,.618,1,1.382,1.618,2,2.618],Oi=[`#ef5350`,`#e8b84b`,`#26a69a`,`#2196f3`,`#26a69a`,`#e8b84b`,`#ef5350`,`#ef5350`],ki=class{constructor(e){this.type=`fibExtension`,this.requiredPoints=3,this.id=`fext_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s=2,c){var l,u;let[d,f,p]=this.points,m=t.xToPixel(d.barIndex,n,i),h=t.yToPixel(d.price,r,a),g=t.xToPixel(f.barIndex,n,i),_=t.yToPixel(f.price,r,a),v=Y(`fibExtension`,this.style,c),y=(l=v.strokeColor)==null?`#e8b84b`:l,b=Z((u=v.strokeColor)==null?`#888888`:u,.67);if(!p){e.save(),e.strokeStyle=b,e.lineWidth=1,e.setLineDash([4,3]),e.beginPath(),e.moveTo(m,h),e.lineTo(g,_),e.stroke(),e.setLineDash([]),e.fillStyle=y,e.beginPath(),e.arc(m,h,3,0,Math.PI*2),e.fill(),e.restore();return}let x=t.xToPixel(p.barIndex,n,i),S=t.yToPixel(p.price,r,a),C=Math.min(m,g,x),w=Math.max(m,g,x),T=f.price-d.price,E=o?v.lineWidth+.5:v.lineWidth;e.save(),e.font=`10px 'Inter', system-ui, sans-serif`,e.lineWidth=E,e.strokeStyle=b,e.setLineDash([4,3]),e.beginPath(),e.moveTo(m,h),e.lineTo(g,_),e.stroke(),e.beginPath(),e.moveTo(g,_),e.lineTo(x,S),e.stroke(),e.setLineDash([]);for(let n=0;n<Di.length;n++){var D,O,k;let i=Di[n],c=String(i),l=(D=v.levels)==null?void 0:D[c];if((l==null?void 0:l.visible)===!1)continue;let u=p.price+i*T,d=t.yToPixel(u,r,a),f=Z((O=(k=l==null?void 0:l.color)==null?v.strokeColor:k)==null?Oi[n]:O,o?.8:.6);e.strokeStyle=f,X(e,o?`solid`:v.lineStyle,E),e.beginPath(),e.moveTo(C,d),e.lineTo(w,d),e.stroke(),e.setLineDash([]);let m=`${`${(i*100).toFixed(1)}%`} ${u.toFixed(s)}`;e.fillStyle=f,e.fillText(m,C+4,d-3)}for(let[t,n]of[[m,h],[g,_],[x,S]])e.beginPath(),e.arc(t,n,o?4:3,0,Math.PI*2),e.fillStyle=y,e.fill();e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<3)return!1;let[s,c,l]=this.points,u=c.price-s.price;for(let e of Di){let r=l.price+e*u,a=n.yToPixel(r,i,o);if(Math.abs(t-a)<=Ei)return!0}return!1}getHandle(e,t,n,r,i,a,o){if(this.points.length<3)return null;let s=this.points.map(e=>({px:n.xToPixel(e.barIndex,r,a),py:n.yToPixel(e.price,i,o)}));for(let n=0;n<s.length;n++)if(Math.hypot(e-s[n].px,t-s[n].py)<=Ei+2)return{pointIndex:n,cursor:`grab`};return null}},Ai=6,ji=[0,.236,.382,.5,.618,.786,1];function Mi(e,t,n,r,i,a){let o=i-n,s=a-r,c=o*o+s*s;if(c===0)return Math.hypot(e-n,t-r);let l=Math.max(0,Math.min(1,((e-n)*o+(t-r)*s)/c));return Math.hypot(e-(n+l*o),t-(r+l*s))}var Ni=class{constructor(e){this.type=`fibChannel`,this.requiredPoints=3,this.id=`fchann_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s=2,c){let[l,u,d]=this.points,f=t.xToPixel(l.barIndex,n,i),p=t.yToPixel(l.price,r,a),m=t.xToPixel(u.barIndex,n,i),h=t.yToPixel(u.price,r,a),g=Y(`fibChannel`,this.style,c),_=Z(g.strokeColor,.67);if(!d){e.save(),e.strokeStyle=_,e.lineWidth=1,e.setLineDash([4,3]),e.beginPath(),e.moveTo(f,p),e.lineTo(m,h),e.stroke(),e.setLineDash([]),e.fillStyle=g.strokeColor,e.beginPath(),e.arc(f,p,3,0,Math.PI*2),e.fill(),e.restore();return}let v=t.xToPixel(d.barIndex,n,i),y=t.yToPixel(d.price,r,a),b=m-f,x=h-p,S=Math.hypot(b,x);if(S===0)return;let C=-x/S,w=b/S,T=(v-f)*C+(y-p)*w,E=o?g.lineWidth+.5:g.lineWidth;e.save(),e.font=`10px 'Inter', system-ui, sans-serif`,e.lineWidth=E;for(let t=0;t<ji.length;t++){let n=ji[t],r=n*T,i=f+r*C,a=p+r*w,s=m+r*C,c=h+r*w,l=Z(g.strokeColor,o?.8:.6);e.strokeStyle=l,X(e,o?`solid`:g.lineStyle,E),e.beginPath(),e.moveTo(i,a),e.lineTo(s,c),e.stroke(),e.setLineDash([]);let u=`${(n*100).toFixed(1)}%`;e.fillStyle=l,e.fillText(u,s+4,c+3)}e.beginPath(),e.arc(v,y,o?4:3,0,Math.PI*2),e.fillStyle=g.strokeColor,e.fill();for(let[t,n]of[[f,p],[m,h]])e.beginPath(),e.arc(t,n,o?4:3,0,Math.PI*2),e.fillStyle=g.strokeColor,e.fill();e.strokeStyle=_,e.setLineDash([3,3]),e.beginPath(),e.moveTo(f,p),e.lineTo(v,y),e.stroke(),e.setLineDash([]),e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<3)return!1;let[s,c,l]=this.points,u=n.xToPixel(s.barIndex,r,a),d=n.yToPixel(s.price,i,o),f=n.xToPixel(c.barIndex,r,a),p=n.yToPixel(c.price,i,o),m=n.xToPixel(l.barIndex,r,a),h=n.yToPixel(l.price,i,o),g=f-u,_=p-d,v=Math.hypot(g,_);if(v===0)return!1;let y=-_/v,b=g/v,x=(m-u)*y+(h-d)*b;for(let n of ji){let r=n*x;if(Mi(e,t,u+r*y,d+r*b,f+r*y,p+r*b)<=Ai)return!0}return!1}getHandle(e,t,n,r,i,a,o){if(this.points.length<3)return null;let s=this.points.map(e=>({px:n.xToPixel(e.barIndex,r,a),py:n.yToPixel(e.price,i,o)}));for(let n=0;n<s.length;n++)if(Math.hypot(e-s[n].px,t-s[n].py)<=Ai+2)return{pointIndex:n,cursor:`grab`};return null}},Pi=6,Fi=[1,2,3,5,8,13,21,34,55,89],Ii=class{constructor(e){this.type=`fibTimezone`,this.id=`ftz_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let[l,u]=this.points,d=u.barIndex-l.barIndex,f=t.xToPixel(l.barIndex,n,i),p=t.xToPixel(u.barIndex,n,i),m=Y(`fibTimezone`,this.style,c),h=o?m.lineWidth+.5:m.lineWidth,g=Z(m.strokeColor,o?.8:.53);e.save(),e.font=`10px 'Inter', system-ui, sans-serif`,e.lineWidth=h,e.strokeStyle=g,X(e,o?`solid`:m.lineStyle,h),e.beginPath(),e.moveTo(f,0),e.lineTo(f,a),e.stroke(),e.beginPath(),e.moveTo(p,0),e.lineTo(p,a),e.stroke(),e.setLineDash([]);for(let r of Fi){let s=l.barIndex+r*d,c=t.xToPixel(s,n,i);c<-50||c>i+50||(e.strokeStyle=g,X(e,o?`solid`:m.lineStyle,h),e.beginPath(),e.moveTo(c,0),e.lineTo(c,a),e.stroke(),e.setLineDash([]),e.fillStyle=g,e.fillText(String(r),c+3,12))}let _=t.yToPixel(l.price,r,a),v=t.yToPixel(u.price,r,a);for(let[t,n]of[[f,_],[p,v]])e.beginPath(),e.arc(t,n,o?4:3,0,Math.PI*2),e.fillStyle=m.strokeColor,e.fill();e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let[s,c]=this.points,l=c.barIndex-s.barIndex,u=n.xToPixel(s.barIndex,r,a);if(Math.abs(e-u)<=Pi)return!0;for(let t of Fi){let i=s.barIndex+t*l,o=n.xToPixel(i,r,a);if(Math.abs(e-o)<=Pi)return!0}return!1}getHandle(e,t,n,r,i,a,o){if(this.points.length<2)return null;let s=[{px:n.xToPixel(this.points[0].barIndex,r,a),py:n.yToPixel(this.points[0].price,i,o)},{px:n.xToPixel(this.points[1].barIndex,r,a),py:n.yToPixel(this.points[1].price,i,o)}];for(let n=0;n<s.length;n++)if(Math.hypot(e-s[n].px,t-s[n].py)<=Pi+2)return{pointIndex:n,cursor:`grab`};return null}},Li=6,Ri=[.236,.382,.5,.618,.786,1,1.618,2.618],zi=class{constructor(e){this.type=`fibCircles`,this.id=`fcirc_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let[l,u]=this.points,d=t.xToPixel(l.barIndex,n,i),f=t.yToPixel(l.price,r,a),p=t.xToPixel(u.barIndex,n,i),m=t.yToPixel(u.price,r,a),h=Math.hypot(p-d,m-f),g=Y(`fibCircles`,this.style,c),_=o?g.lineWidth+.5:g.lineWidth;e.save(),e.font=`10px 'Inter', system-ui, sans-serif`,e.lineWidth=_;for(let t=0;t<Ri.length;t++){let n=Ri[t],r=n*h,i=Z(g.strokeColor,o?.8:.53);e.strokeStyle=i,X(e,o?`solid`:g.lineStyle,_),e.beginPath(),e.arc(d,f,r,0,Math.PI*2),e.stroke(),e.setLineDash([]),e.fillStyle=i,e.fillText(`${(n*100).toFixed(1)}%`,d+3,f-r+12)}e.beginPath(),e.arc(d,f,o?4:3,0,Math.PI*2),e.fillStyle=g.strokeColor,e.fill(),e.beginPath(),e.arc(p,m,o?4:3,0,Math.PI*2),e.fillStyle=g.strokeColor,e.fill(),e.strokeStyle=Z(g.strokeColor,.4),e.setLineDash([3,3]),e.beginPath(),e.moveTo(d,f),e.lineTo(p,m),e.stroke(),e.setLineDash([]),e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let[s,c]=this.points,l=n.xToPixel(s.barIndex,r,a),u=n.yToPixel(s.price,i,o),d=n.xToPixel(c.barIndex,r,a),f=n.yToPixel(c.price,i,o),p=Math.hypot(d-l,f-u),m=Math.hypot(e-l,t-u);for(let e of Ri){let t=e*p;if(Math.abs(m-t)<=Li)return!0}return!1}getHandle(e,t,n,r,i,a,o){if(this.points.length<2)return null;let s=n.xToPixel(this.points[0].barIndex,r,a),c=n.yToPixel(this.points[0].price,i,o),l=n.xToPixel(this.points[1].barIndex,r,a),u=n.yToPixel(this.points[1].price,i,o);return Math.hypot(e-s,t-c)<=Li+2?{pointIndex:0,cursor:`move`}:Math.hypot(e-l,t-u)<=Li+2?{pointIndex:1,cursor:`grab`}:null}},Bi=6,Vi=[1,1,2,3,5,8,13,21],Hi=class{constructor(e){this.type=`fibSpiral`,this.id=`fspi_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}computeArcs(e,t,n,r){let i=Math.hypot(n,r)/Vi[Vi.length-1],a=Math.atan2(r,n),o=[],s=e,c=t,l=a;for(let e=Vi.length-1;e>=0;e--){let t=Vi[e]*i,n=l+Math.PI,r=n+Math.PI/2;if(o.unshift({ox:s,oy:c,r:t,startAngle:n,endAngle:r}),e>0){let n=Vi[e-1]*i,r=l-Math.PI/2;s+=(t-n)*Math.cos(r),c+=(t-n)*Math.sin(r),l-=Math.PI/2}}return o}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let[l,u]=this.points,d=t.xToPixel(l.barIndex,n,i),f=t.yToPixel(l.price,r,a),p=t.xToPixel(u.barIndex,n,i),m=t.yToPixel(u.price,r,a),h=p-d,g=m-f,_=Y(`fibSpiral`,this.style,c),v=o?_.lineWidth+.5:_.lineWidth;e.save(),e.font=`10px 'Inter', system-ui, sans-serif`,e.strokeStyle=Z(_.strokeColor,o?.8:.53),e.lineWidth=v,X(e,o?`solid`:_.lineStyle,v);let y=this.computeArcs(d,f,h,g);e.beginPath();for(let t=0;t<y.length;t++){let n=y[t];if(t===0){let t=n.ox+n.r*Math.cos(n.startAngle),r=n.oy+n.r*Math.sin(n.startAngle);e.moveTo(t,r)}e.arc(n.ox,n.oy,n.r,n.startAngle,n.endAngle,!1)}e.stroke(),e.setLineDash([]),e.beginPath(),e.arc(d,f,o?4:3,0,Math.PI*2),e.fillStyle=_.strokeColor,e.fill(),e.beginPath(),e.arc(p,m,o?4:3,0,Math.PI*2),e.fillStyle=_.strokeColor,e.fill(),e.strokeStyle=Z(_.strokeColor,.4),e.setLineDash([3,3]),e.beginPath(),e.moveTo(d,f),e.lineTo(p,m),e.stroke(),e.setLineDash([]),e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let[s,c]=this.points,l=n.xToPixel(s.barIndex,r,a),u=n.yToPixel(s.price,i,o),d=n.xToPixel(c.barIndex,r,a),f=n.yToPixel(c.price,i,o),p=d-l,m=f-u,h=this.computeArcs(l,u,p,m);for(let n of h){let r=n.endAngle-n.startAngle;for(let i=0;i<=16;i++){let a=i/16,o=n.startAngle+a*r,s=n.ox+n.r*Math.cos(o),c=n.oy+n.r*Math.sin(o);if(Math.hypot(e-s,t-c)<=Bi)return!0}}return!1}getHandle(e,t,n,r,i,a,o){if(this.points.length<2)return null;let s=n.xToPixel(this.points[0].barIndex,r,a),c=n.yToPixel(this.points[0].price,i,o),l=n.xToPixel(this.points[1].barIndex,r,a),u=n.yToPixel(this.points[1].price,i,o);return Math.hypot(e-s,t-c)<=Bi+2?{pointIndex:0,cursor:`move`}:Math.hypot(e-l,t-u)<=Bi+2?{pointIndex:1,cursor:`grab`}:null}},Ui=6,Wi=[.236,.382,.5,.618,.786];function Gi(e,t,n,r,i,a){let o=i-n,s=a-r,c=o*o+s*s;if(c===0)return Math.hypot(e-n,t-r);let l=Math.max(0,Math.min(1,((e-n)*o+(t-r)*s)/c));return Math.hypot(e-(n+l*o),t-(r+l*s))}function Ki(e,t,n,r,i,a){let o=n-e,s=r-t;if(o===0&&s===0)return[n,r];let c=1/0;return o>0&&(c=Math.min(c,(i-e)/o)),o<0&&(c=Math.min(c,(0-e)/o)),s>0&&(c=Math.min(c,(a-t)/s)),s<0&&(c=Math.min(c,(0-t)/s)),[e+c*o,t+c*s]}var qi=class{constructor(e){this.type=`fibFan`,this.id=`ffan_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let[l,u]=this.points,d=t.xToPixel(l.barIndex,n,i),f=t.yToPixel(l.price,r,a),p=t.xToPixel(u.barIndex,n,i),m=t.yToPixel(u.price,r,a),h=Y(`fibFan`,this.style,c),g=o?h.lineWidth+.5:h.lineWidth;e.save(),e.font=`10px 'Inter', system-ui, sans-serif`,e.lineWidth=g,e.strokeStyle=Z(h.strokeColor,.67),e.setLineDash([4,3]),e.beginPath(),e.moveTo(d,f),e.lineTo(p,m),e.stroke(),e.setLineDash([]);let _=u.price-l.price;for(let n=0;n<Wi.length;n++){let s=Wi[n],c=Z(h.strokeColor,o?.8:.6),u=l.price+s*_,[m,v]=Ki(d,f,p,t.yToPixel(u,r,a),i,a);e.strokeStyle=c,X(e,o?`solid`:h.lineStyle,g),e.beginPath(),e.moveTo(d,f),e.lineTo(m,v),e.stroke(),e.setLineDash([]),e.fillStyle=c,e.fillText(`${(s*100).toFixed(1)}%`,Math.min(m-32,i-40),v-3)}for(let[t,n]of[[d,f],[p,m]])e.beginPath(),e.arc(t,n,o?4:3,0,Math.PI*2),e.fillStyle=h.strokeColor,e.fill();e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let[s,c]=this.points,l=n.xToPixel(s.barIndex,r,a),u=n.yToPixel(s.price,i,o),d=n.xToPixel(c.barIndex,r,a),f=c.price-s.price;for(let r of Wi){let c=s.price+r*f,[p,m]=Ki(l,u,d,n.yToPixel(c,i,o),a,o);if(Gi(e,t,l,u,p,m)<=Ui)return!0}return!1}getHandle(e,t,n,r,i,a,o){if(this.points.length<2)return null;let s=[{px:n.xToPixel(this.points[0].barIndex,r,a),py:n.yToPixel(this.points[0].price,i,o)},{px:n.xToPixel(this.points[1].barIndex,r,a),py:n.yToPixel(this.points[1].price,i,o)}];for(let n=0;n<s.length;n++)if(Math.hypot(e-s[n].px,t-s[n].py)<=Ui+2)return{pointIndex:n,cursor:`grab`};return null}},Ji=6,Yi=[0,.618,1,1.272,1.618,2,2.618],Xi=[`#ef5350`,`#26a69a`,`#2196f3`,`#26a69a`,`#e8b84b`,`#ef5350`,`#ef5350`],Zi=class{constructor(e){this.type=`fibProjection`,this.requiredPoints=3,this.id=`fproj_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s=2,c){var l,u;let[d,f,p]=this.points,m=t.xToPixel(d.barIndex,n,i),h=t.yToPixel(d.price,r,a),g=t.xToPixel(f.barIndex,n,i),_=t.yToPixel(f.price,r,a),v=Y(`fibProjection`,this.style,c),y=(l=v.strokeColor)==null?`#e8b84b`:l,b=Z((u=v.strokeColor)==null?`#888888`:u,.67);if(!p){e.save(),e.strokeStyle=b,e.lineWidth=1,e.setLineDash([4,3]),e.beginPath(),e.moveTo(m,h),e.lineTo(g,_),e.stroke(),e.setLineDash([]),e.fillStyle=y,e.beginPath(),e.arc(m,h,3,0,Math.PI*2),e.fill(),e.restore();return}let x=t.xToPixel(p.barIndex,n,i),S=t.yToPixel(p.price,r,a),C=Math.min(m,x),w=Math.max(m,x),T=f.price-d.price,E=o?v.lineWidth+.5:v.lineWidth;e.save(),e.font=`10px 'Inter', system-ui, sans-serif`,e.lineWidth=E,e.strokeStyle=b,e.setLineDash([4,3]),e.beginPath(),e.moveTo(m,h),e.lineTo(g,_),e.stroke(),e.beginPath(),e.moveTo(g,_),e.lineTo(x,S),e.stroke(),e.setLineDash([]);for(let n=0;n<Yi.length;n++){var D,O,k;let i=Yi[n],c=String(i),l=(D=v.levels)==null?void 0:D[c];if((l==null?void 0:l.visible)===!1)continue;let u=p.price+i*T,d=t.yToPixel(u,r,a),f=Z((O=(k=l==null?void 0:l.color)==null?v.strokeColor:k)==null?Xi[n]:O,o?.8:.6);e.strokeStyle=f,X(e,o?`solid`:v.lineStyle,E),e.beginPath(),e.moveTo(C,d),e.lineTo(w,d),e.stroke(),e.setLineDash([]);let m=`${`${(i*100).toFixed(1)}%`} ${u.toFixed(s)}`;e.fillStyle=f,e.fillText(m,C+4,d-3)}for(let[t,n]of[[m,h],[g,_],[x,S]])e.beginPath(),e.arc(t,n,o?4:3,0,Math.PI*2),e.fillStyle=y,e.fill();e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<3)return!1;let[s,c,l]=this.points,u=c.price-s.price;for(let e of Yi){let r=l.price+e*u,a=n.yToPixel(r,i,o);if(Math.abs(t-a)<=Ji)return!0}return!1}getHandle(e,t,n,r,i,a,o){if(this.points.length<3)return null;let s=this.points.map(e=>({px:n.xToPixel(e.barIndex,r,a),py:n.yToPixel(e.price,i,o)}));for(let n=0;n<s.length;n++)if(Math.hypot(e-s[n].px,t-s[n].py)<=Ji+2)return{pointIndex:n,cursor:`grab`};return null}},Qi=6;function $i(e,t,n,r,i,a){let o=i-n,s=a-r,c=o*o+s*s;if(c===0)return Math.hypot(e-n,t-r);let l=Math.max(0,Math.min(1,((e-n)*o+(t-r)*s)/c));return Math.hypot(e-(n+l*o),t-(r+l*s))}var ea=[[1,8,`1:8`],[1,4,`1:4`],[1,3,`1:3`],[1,2,`1:2`],[1,1,`1:1`],[2,1,`2:1`],[3,1,`3:1`],[4,1,`4:1`],[8,1,`8:1`]],ta=class{constructor(e){this.type=`gannFan`,this.id=`gfan_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let[l,u]=this.points,d=t.xToPixel(l.barIndex,n,i),f=t.yToPixel(l.price,r,a),p=t.xToPixel(u.barIndex,n,i),m=t.yToPixel(u.price,r,a),h=Math.abs(p-d)||1,g=m-f,_=p>d?1:-1,v=Y(`gannFan`,this.style,c);e.save(),e.font=`10px 'Inter', system-ui, sans-serif`,e.lineWidth=o?v.lineWidth+.5:v.lineWidth,X(e,o?`solid`:v.lineStyle,e.lineWidth),ea.forEach(([t,n,r],a)=>{var o;let s=t/n*g,c=(i-d)/(h*_),l=d+h*_*c,u=f+s*c,p=(o=[.33,.4,.47,.6,.8,.6,.47,.4,.33][a])==null?.53:o,m=Z(v.strokeColor,p);e.strokeStyle=m,e.beginPath(),e.moveTo(d,f),e.lineTo(l,u),e.stroke(),e.fillStyle=m;let y=Math.min(l,i-30);e.fillText(r,y,u-3)}),e.setLineDash([]),e.fillStyle=v.strokeColor,e.beginPath(),e.arc(d,f,o?4:3,0,Math.PI*2),e.fill(),e.beginPath(),e.arc(p,m,o?4:3,0,Math.PI*2),e.fill(),e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let[s,c]=this.points,l=n.xToPixel(s.barIndex,r,a),u=n.yToPixel(s.price,i,o),d=n.xToPixel(c.barIndex,r,a),f=n.yToPixel(c.price,i,o),p=Math.abs(d-l)||1,m=f-u,h=d>l?1:-1;for(let[n,r]of ea){let i=n/r*m,o=(a-l)/(p*h);if($i(e,t,l,u,l+p*h*o,u+i*o)<=Qi)return!0}return!1}getHandle(e,t,n,r,i,a,o){if(this.points.length<2)return null;let s=[{px:n.xToPixel(this.points[0].barIndex,r,a),py:n.yToPixel(this.points[0].price,i,o)},{px:n.xToPixel(this.points[1].barIndex,r,a),py:n.yToPixel(this.points[1].price,i,o)}],c=[`move`,`grab`];for(let n=0;n<s.length;n++)if(Math.hypot(e-s[n].px,t-s[n].py)<=Qi+2)return{pointIndex:n,cursor:c[n]};return null}},na=6,ra=class{constructor(e){this.type=`gannSquare`,this.id=`gsq_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let[l,u]=this.points,d=t.xToPixel(l.barIndex,n,i),f=t.yToPixel(l.price,r,a),p=t.xToPixel(u.barIndex,n,i),m=t.yToPixel(u.price,r,a),h=Math.min(d,p),g=Math.min(f,m),_=Math.max(d,p),v=Math.max(f,m),y=_-h,b=v-g,x=Y(`gannSquare`,this.style,c);e.save(),e.lineWidth=o?x.lineWidth+.5:x.lineWidth,e.strokeStyle=x.strokeColor,X(e,o?`solid`:x.lineStyle,e.lineWidth),e.fillStyle=Z(x.fillColor,x.fillOpacity),e.fillRect(h,g,y,b),e.strokeRect(h,g,y,b),e.beginPath(),e.moveTo(h,g+b/3),e.lineTo(_,g+b/3),e.moveTo(h,g+2*b/3),e.lineTo(_,g+2*b/3),e.stroke(),e.beginPath(),e.moveTo(h+y/3,g),e.lineTo(h+y/3,v),e.moveTo(h+2*y/3,g),e.lineTo(h+2*y/3,v),e.stroke(),e.setLineDash([]),e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let[s,c]=this.points,l=n.xToPixel(s.barIndex,r,a),u=n.yToPixel(s.price,i,o),d=n.xToPixel(c.barIndex,r,a),f=n.yToPixel(c.price,i,o);return e>=Math.min(l,d)&&e<=Math.max(l,d)&&t>=Math.min(u,f)&&t<=Math.max(u,f)}getHandle(e,t,n,r,i,a,o){if(this.points.length<2)return null;let s=[{px:n.xToPixel(this.points[0].barIndex,r,a),py:n.yToPixel(this.points[0].price,i,o)},{px:n.xToPixel(this.points[1].barIndex,r,a),py:n.yToPixel(this.points[1].price,i,o)}];for(let n=0;n<s.length;n++)if(Math.hypot(e-s[n].px,t-s[n].py)<=na+2)return{pointIndex:n,cursor:`nwse-resize`};return null}},ia=6,aa=class{constructor(e){this.type=`gannBox`,this.id=`gbox_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let[l,u]=this.points,d=t.xToPixel(l.barIndex,n,i),f=t.yToPixel(l.price,r,a),p=t.xToPixel(u.barIndex,n,i),m=t.yToPixel(u.price,r,a),h=Math.min(d,p),g=Math.min(f,m),_=Math.max(d,p),v=Math.max(f,m),y=_-h,b=v-g,x=h+y/2,S=g+b/2,C=Y(`gannBox`,this.style,c);e.save(),e.lineWidth=o?C.lineWidth+.5:C.lineWidth,e.strokeStyle=C.strokeColor,X(e,o?`solid`:C.lineStyle,e.lineWidth),e.fillStyle=Z(C.fillColor,C.fillOpacity),e.fillRect(h,g,y,b),e.strokeRect(h,g,y,b),e.beginPath(),e.moveTo(h,g),e.lineTo(_,v),e.stroke(),e.beginPath(),e.moveTo(_,g),e.lineTo(h,v),e.stroke(),e.beginPath(),e.moveTo(h,S),e.lineTo(_,S),e.stroke(),e.beginPath(),e.moveTo(x,g),e.lineTo(x,v),e.stroke(),e.setLineDash([]),e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let[s,c]=this.points,l=n.xToPixel(s.barIndex,r,a),u=n.yToPixel(s.price,i,o),d=n.xToPixel(c.barIndex,r,a),f=n.yToPixel(c.price,i,o);return e>=Math.min(l,d)&&e<=Math.max(l,d)&&t>=Math.min(u,f)&&t<=Math.max(u,f)}getHandle(e,t,n,r,i,a,o){if(this.points.length<2)return null;let s=[{px:n.xToPixel(this.points[0].barIndex,r,a),py:n.yToPixel(this.points[0].price,i,o)},{px:n.xToPixel(this.points[1].barIndex,r,a),py:n.yToPixel(this.points[1].price,i,o)}];for(let n=0;n<s.length;n++)if(Math.hypot(e-s[n].px,t-s[n].py)<=ia+2)return{pointIndex:n,cursor:`nwse-resize`};return null}},oa=6,sa=class{constructor(e){this.type=`rectangle`,this.id=`rect_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let[l,u]=this.points,d=t.xToPixel(l.barIndex,n,i),f=t.yToPixel(l.price,r,a),p=t.xToPixel(u.barIndex,n,i),m=t.yToPixel(u.price,r,a),h=Math.min(d,p),g=Math.min(f,m),_=Math.abs(p-d),v=Math.abs(m-f),y=Y(`rectangle`,this.style,c);if(e.save(),e.fillStyle=Z(y.fillColor,y.fillOpacity),e.strokeStyle=y.strokeColor,e.lineWidth=o?y.lineWidth+.5:y.lineWidth,X(e,o?`solid`:y.lineStyle,e.lineWidth),e.fillRect(h,g,_,v),e.strokeRect(h,g,_,v),e.setLineDash([]),o)for(let[t,n]of[[d,f],[p,f],[d,m],[p,m]])e.beginPath(),e.arc(t,n,3.5,0,Math.PI*2),e.fillStyle=y.strokeColor,e.fill();e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let[s,c]=this.points,l=n.xToPixel(s.barIndex,r,a),u=n.yToPixel(s.price,i,o),d=n.xToPixel(c.barIndex,r,a),f=n.yToPixel(c.price,i,o),p=Math.min(l,d)-oa,m=Math.min(u,f)-oa,h=Math.abs(d-l)+oa*2,g=Math.abs(f-u)+oa*2;return e>=p&&e<=p+h&&t>=m&&t<=m+g}getHandle(e,t,n,r,i,a,o){if(this.points.length<2)return null;let[s,c]=this.points,l=n.xToPixel(s.barIndex,r,a),u=n.yToPixel(s.price,i,o),d=n.xToPixel(c.barIndex,r,a),f=n.yToPixel(c.price,i,o),p=l<=d?u<=f?`nwse-resize`:`nesw-resize`:u<=f?`nesw-resize`:`nwse-resize`,m=[[0,l,u,p],[1,d,f,p]];for(let[n,r,i,a]of m)if(Math.hypot(e-r,t-i)<=oa+2)return{pointIndex:n,cursor:a};return null}},ca=6;function la(e,t,n){let r=!1,i=n.length;for(let a=0,o=i-1;a<i;o=a++){let[i,s]=n[a],[c,l]=n[o];s>t!=l>t&&e<(c-i)*(t-s)/(l-s)+i&&(r=!r)}return r}var ua=class{constructor(e){this.type=`rotatedRectangle`,this.requiredPoints=3,this.id=`rrect_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}getCorners(e,t,n,r,i){let[a,o,s]=this.points,c=e.xToPixel(a.barIndex,t,r),l=e.yToPixel(a.price,n,i),u=e.xToPixel(o.barIndex,t,r),d=e.yToPixel(o.price,n,i),f=e.xToPixel(s.barIndex,t,r),p=e.yToPixel(s.price,n,i),m=Math.hypot(u-c,d-l);if(m<1e-6)return[[c,l],[u,d],[u,d],[c,l]];let h=-(d-l)/m,g=(u-c)/m,_=(f-c)*h+(p-l)*g,v=c,y=l,b=u,x=d,S=b+h*_,C=x+g*_,w=v+h*_,T=y+g*_;return[[v,y],[b,x],[S,C],[w,T]]}render(e,t,n,r,i,a,o,s,c){if(this.points.length<3)return;let l=this.getCorners(t,n,r,i,a),u=Y(`rotatedRectangle`,this.style,c);e.save(),e.beginPath(),e.moveTo(l[0][0],l[0][1]);for(let t=1;t<l.length;t++)e.lineTo(l[t][0],l[t][1]);e.closePath(),e.fillStyle=Z(u.fillColor,u.fillOpacity),e.fill(),e.strokeStyle=u.strokeColor,e.lineWidth=o?u.lineWidth+.5:u.lineWidth,X(e,o?`solid`:u.lineStyle,e.lineWidth),e.stroke(),e.setLineDash([]),e.fillStyle=u.strokeColor;for(let[t,n]of l)e.beginPath(),e.arc(t,n,o?4:3,0,Math.PI*2),e.fill();e.restore()}hitTest(e,t,n,r,i,a,o){return this.points.length<3?!1:la(e,t,this.getCorners(n,r,i,a,o))}getHandle(e,t,n,r,i,a,o){for(let s=0;s<this.points.length;s++){let c=n.xToPixel(this.points[s].barIndex,r,a),l=n.yToPixel(this.points[s].price,i,o);if(Math.hypot(e-c,t-l)<=ca+2)return{pointIndex:s,cursor:`grab`}}return null}},da=6,fa=class{constructor(e){this.type=`ellipse`,this.id=`ell_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let[l,u]=this.points,d=t.xToPixel(l.barIndex,n,i),f=t.yToPixel(l.price,r,a),p=t.xToPixel(u.barIndex,n,i),m=t.yToPixel(u.price,r,a),h=(d+p)/2,g=(f+m)/2,_=Math.abs(p-d)/2,v=Math.abs(m-f)/2;if(_<1||v<1)return;let y=Y(`ellipse`,this.style,c);if(e.save(),e.fillStyle=Z(y.fillColor,y.fillOpacity),e.strokeStyle=y.strokeColor,e.lineWidth=o?y.lineWidth+.5:y.lineWidth,X(e,o?`solid`:y.lineStyle,e.lineWidth),e.beginPath(),e.ellipse(h,g,_,v,0,0,Math.PI*2),e.fill(),e.stroke(),e.setLineDash([]),o)for(let[t,n]of[[d,f],[p,m]])e.beginPath(),e.arc(t,n,3.5,0,Math.PI*2),e.fillStyle=y.strokeColor,e.fill();e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let[s,c]=this.points,l=n.xToPixel(s.barIndex,r,a),u=n.yToPixel(s.price,i,o),d=n.xToPixel(c.barIndex,r,a),f=n.yToPixel(c.price,i,o),p=(l+d)/2,m=(u+f)/2,h=Math.abs(d-l)/2+da,g=Math.abs(f-u)/2+da;if(h<1||g<1)return!1;let _=(e-p)/h,v=(t-m)/g;return _*_+v*v<=1}getHandle(e,t,n,r,i,a,o){if(this.points.length<2)return null;let[s,c]=this.points,l=n.xToPixel(s.barIndex,r,a),u=n.yToPixel(s.price,i,o),d=n.xToPixel(c.barIndex,r,a),f=n.yToPixel(c.price,i,o),p=l<=d?u<=f?`nwse-resize`:`nesw-resize`:u<=f?`nesw-resize`:`nwse-resize`,m=[[0,l,u,p],[1,d,f,p]];for(let[n,r,i,a]of m)if(Math.hypot(e-r,t-i)<=da+2)return{pointIndex:n,cursor:a};return null}},pa=6;function ma(e,t,n,r,i,a){let o=i-n,s=a-r,c=o*o+s*s;if(c===0)return Math.hypot(e-n,t-r);let l=Math.max(0,Math.min(1,((e-n)*o+(t-r)*s)/c));return Math.hypot(e-(n+l*o),t-(r+l*s))}var ha=class{constructor(e){this.type=`triangle`,this.requiredPoints=3,this.id=`tri_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let l=this.points.map(e=>t.xToPixel(e.barIndex,n,i)),u=this.points.map(e=>t.yToPixel(e.price,r,a)),d=Y(`triangle`,this.style,c);e.save(),e.strokeStyle=d.strokeColor,e.lineWidth=o?d.lineWidth+.5:d.lineWidth,X(e,o?`solid`:d.lineStyle,e.lineWidth),e.beginPath(),e.moveTo(l[0],u[0]);for(let t=1;t<l.length;t++)e.lineTo(l[t],u[t]);if(this.complete&&(e.closePath(),e.fillStyle=Z(d.fillColor,d.fillOpacity),e.fill()),e.stroke(),e.setLineDash([]),o)for(let t=0;t<l.length;t++)e.beginPath(),e.arc(l[t],u[t],4,0,Math.PI*2),e.fillStyle=d.strokeColor,e.fill();e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<3)return!1;let s=this.points.map(e=>n.xToPixel(e.barIndex,r,a)),c=this.points.map(e=>n.yToPixel(e.price,i,o)),l=s.length;for(let n=0;n<l;n++){let r=(n+1)%l;if(ma(e,t,s[n],c[n],s[r],c[r])<=pa)return!0}return!1}getHandle(e,t,n,r,i,a,o){if(this.points.length<3)return null;for(let s=0;s<this.points.length;s++){let c=n.xToPixel(this.points[s].barIndex,r,a),l=n.yToPixel(this.points[s].price,i,o);if(Math.hypot(e-c,t-l)<=pa+2)return{pointIndex:s,cursor:`grab`}}return null}},ga=6,_a=class{constructor(e){this.type=`circle`,this.id=`circ_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let[l,u]=this.points,d=t.xToPixel(l.barIndex,n,i),f=t.yToPixel(l.price,r,a),p=t.xToPixel(u.barIndex,n,i),m=t.yToPixel(u.price,r,a),h=Math.hypot(p-d,m-f);if(h<1)return;let g=Y(`circle`,this.style,c);e.save(),e.fillStyle=Z(g.fillColor,g.fillOpacity),e.strokeStyle=g.strokeColor,e.lineWidth=o?g.lineWidth+.5:g.lineWidth,X(e,o?`solid`:g.lineStyle,e.lineWidth),e.beginPath(),e.arc(d,f,h,0,Math.PI*2),e.fill(),e.stroke(),e.setLineDash([]),o&&(e.beginPath(),e.arc(d,f,3,0,Math.PI*2),e.fillStyle=g.strokeColor,e.fill(),e.beginPath(),e.arc(p,m,3.5,0,Math.PI*2),e.fillStyle=g.strokeColor,e.fill()),e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let[s,c]=this.points,l=n.xToPixel(s.barIndex,r,a),u=n.yToPixel(s.price,i,o),d=n.xToPixel(c.barIndex,r,a),f=n.yToPixel(c.price,i,o),p=Math.hypot(d-l,f-u);return Math.hypot(e-l,t-u)<=p+ga}getHandle(e,t,n,r,i,a,o){if(this.points.length<2)return null;let[s,c]=this.points,l=n.xToPixel(s.barIndex,r,a),u=n.yToPixel(s.price,i,o),d=n.xToPixel(c.barIndex,r,a),f=n.yToPixel(c.price,i,o);return Math.hypot(e-l,t-u)<=ga+2?{pointIndex:0,cursor:`move`}:Math.hypot(e-d,t-f)<=ga+2?{pointIndex:1,cursor:`grab`}:null}},va=6;function ya(e,t,n,r,i,a){let o=i-n,s=a-r,c=o*o+s*s;if(c===0)return Math.hypot(e-n,t-r);let l=Math.max(0,Math.min(1,((e-n)*o+(t-r)*s)/c));return Math.hypot(e-(n+l*o),t-(r+l*s))}var ba=class{constructor(e){this.type=`arc`,this.requiredPoints=3,this.id=`arc_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<3)return;let[l,u,d]=this.points,f=t.xToPixel(l.barIndex,n,i),p=t.yToPixel(l.price,r,a),m=t.xToPixel(u.barIndex,n,i),h=t.yToPixel(u.price,r,a),g=t.xToPixel(d.barIndex,n,i),_=t.yToPixel(d.price,r,a),v=Y(`arc`,this.style,c);e.save(),e.strokeStyle=v.strokeColor,e.lineWidth=o?v.lineWidth+.5:v.lineWidth,X(e,o?`solid`:v.lineStyle,e.lineWidth);let y=f,b=p,x=m,S=h,C=g,w=_,T=2*(y*(S-w)+x*(w-b)+C*(b-S));if(Math.abs(T)<1e-6)e.beginPath(),e.moveTo(f,p),e.lineTo(g,_),e.stroke();else{let t=y*y,n=b*b,r=x*x,i=S*S,a=C*C,o=w*w,s=((t+n)*(S-w)+(r+i)*(w-b)+(a+o)*(b-S))/T,c=((t+n)*(C-x)+(r+i)*(y-C)+(a+o)*(x-y))/T,l=Math.hypot(y-s,b-c),u=Math.atan2(b-c,y-s),d=Math.atan2(S-c,x-s),f=Math.atan2(w-c,C-s),p=(e,t)=>{let n=e-t;for(;n<0;)n+=Math.PI*2;for(;n>=Math.PI*2;)n-=Math.PI*2;return n},m=p(d,u)>p(f,u);e.beginPath(),e.arc(s,c,l,u,f,m),e.stroke()}e.setLineDash([]);let E=[[f,p],[m,h],[g,_]];e.fillStyle=v.strokeColor;for(let[t,n]of E)e.beginPath(),e.arc(t,n,o?4:3,0,Math.PI*2),e.fill();e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<3)return!1;let[s,c,l]=this.points,u=n.xToPixel(s.barIndex,r,a),d=n.yToPixel(s.price,i,o),f=n.xToPixel(c.barIndex,r,a),p=n.yToPixel(c.price,i,o),m=n.xToPixel(l.barIndex,r,a),h=n.yToPixel(l.price,i,o),g=u,_=d,v=f,y=p,b=m,x=h,S=2*(g*(y-x)+v*(x-_)+b*(_-y));if(Math.abs(S)<1e-6)return ya(e,t,u,d,m,h)<=va;let C=g*g,w=_*_,T=v*v,E=y*y,D=b*b,O=x*x,k=((C+w)*(y-x)+(T+E)*(x-_)+(D+O)*(_-y))/S,A=((C+w)*(b-v)+(T+E)*(g-b)+(D+O)*(v-g))/S,ee=Math.hypot(g-k,_-A);if(Math.abs(Math.hypot(e-k,t-A)-ee)>va)return!1;let j=Math.atan2(_-A,g-k),te=Math.atan2(y-A,v-k),ne=Math.atan2(x-A,b-k),M=Math.atan2(t-A,e-k),N=(e,t)=>{let n=e-t;for(;n<0;)n+=Math.PI*2;for(;n>=Math.PI*2;)n-=Math.PI*2;return n},P=N(te,j),re=N(ne,j),ie=N(M,j);return P>re?ie>=re||ie<=0:ie<=re}getHandle(e,t,n,r,i,a,o){for(let s=0;s<this.points.length;s++){let c=n.xToPixel(this.points[s].barIndex,r,a),l=n.yToPixel(this.points[s].price,i,o);if(Math.hypot(e-c,t-l)<=va+2)return{pointIndex:s,cursor:`grab`}}return null}},xa=6;function Sa(e,t,n,r,i,a){let o=i-n,s=a-r,c=o*o+s*s;if(c===0)return Math.hypot(e-n,t-r);let l=Math.max(0,Math.min(1,((e-n)*o+(t-r)*s)/c));return Math.hypot(e-(n+l*o),t-(r+l*s))}var Ca=class{constructor(e){this.type=`polyline`,this.openEnded=!0,this.id=`poly_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let l=this.points.map(e=>({x:t.xToPixel(e.barIndex,n,i),y:t.yToPixel(e.price,r,a)})),u=Y(`polyline`,this.style,c);e.save(),e.strokeStyle=u.strokeColor,e.lineWidth=o?u.lineWidth+.5:u.lineWidth;let d=this.complete?l.length:l.length-1;if(d>=2){X(e,o?`solid`:u.lineStyle,e.lineWidth),e.beginPath(),e.moveTo(l[0].x,l[0].y);for(let t=1;t<d;t++)e.lineTo(l[t].x,l[t].y);e.stroke(),e.setLineDash([])}if(!this.complete&&l.length>=2){let t=l.length-1;e.setLineDash([4,4]),e.beginPath(),e.moveTo(l[t-1].x,l[t-1].y),e.lineTo(l[t].x,l[t].y),e.stroke(),e.setLineDash([])}e.fillStyle=u.strokeColor;let f=this.complete?l.length:l.length-1;for(let t=0;t<f;t++)e.beginPath(),e.arc(l[t].x,l[t].y,o?4:3,0,Math.PI*2),e.fill();e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let s=this.points.map(e=>({x:n.xToPixel(e.barIndex,r,a),y:n.yToPixel(e.price,i,o)})),c=this.complete?s.length-1:s.length-2;for(let n=0;n<c;n++)if(Sa(e,t,s[n].x,s[n].y,s[n+1].x,s[n+1].y)<=xa)return!0;return!1}getHandle(e,t,n,r,i,a,o){for(let s=0;s<this.points.length;s++){let c=n.xToPixel(this.points[s].barIndex,r,a),l=n.yToPixel(this.points[s].price,i,o);if(Math.hypot(e-c,t-l)<=xa+2)return{pointIndex:s,cursor:`grab`}}return null}},wa=6;function Ta(e,t,n,r,i,a){let o=i-n,s=a-r,c=o*o+s*s;if(c===0)return Math.hypot(e-n,t-r);let l=Math.max(0,Math.min(1,((e-n)*o+(t-r)*s)/c));return Math.hypot(e-(n+l*o),t-(r+l*s))}var Ea=class{constructor(e){this.type=`path`,this.openEnded=!0,this.id=`path_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let l=this.points.map(e=>({x:t.xToPixel(e.barIndex,n,i),y:t.yToPixel(e.price,r,a)})),u=this.complete?l.length:l.length-1,d=Y(`path`,this.style,c);if(e.save(),e.strokeStyle=d.strokeColor,e.lineWidth=o?d.lineWidth+.5:d.lineWidth,u>=2){if(X(e,o?`solid`:d.lineStyle,e.lineWidth),e.beginPath(),e.moveTo(l[0].x,l[0].y),u===2)e.lineTo(l[1].x,l[1].y);else{for(let t=1;t<u-1;t++){let n=(l[t].x+l[t+1].x)/2,r=(l[t].y+l[t+1].y)/2;e.quadraticCurveTo(l[t].x,l[t].y,n,r)}e.lineTo(l[u-1].x,l[u-1].y)}e.stroke(),e.setLineDash([])}if(!this.complete&&l.length>=2){let t=l.length-1;e.setLineDash([4,4]),e.beginPath(),e.moveTo(l[t-1].x,l[t-1].y),e.lineTo(l[t].x,l[t].y),e.stroke(),e.setLineDash([])}e.fillStyle=d.strokeColor;for(let t=0;t<u;t++)e.beginPath(),e.arc(l[t].x,l[t].y,o?4:3,0,Math.PI*2),e.fill();e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let s=this.points.map(e=>({x:n.xToPixel(e.barIndex,r,a),y:n.yToPixel(e.price,i,o)})),c=this.complete?s.length-1:s.length-2;for(let n=0;n<c;n++)if(Ta(e,t,s[n].x,s[n].y,s[n+1].x,s[n+1].y)<=wa)return!0;return!1}getHandle(e,t,n,r,i,a,o){for(let s=0;s<this.points.length;s++){let c=n.xToPixel(this.points[s].barIndex,r,a),l=n.yToPixel(this.points[s].price,i,o);if(Math.hypot(e-c,t-l)<=wa+2)return{pointIndex:s,cursor:`grab`}}return null}},Da=6;function Oa(e,t,n,r,i,a=7){let o=Math.atan2(i-n,r-t);e.beginPath(),e.moveTo(r,i),e.lineTo(r-a*Math.cos(o-Math.PI/6),i-a*Math.sin(o-Math.PI/6)),e.lineTo(r-a*Math.cos(o+Math.PI/6),i-a*Math.sin(o+Math.PI/6)),e.closePath(),e.fill()}var ka=class{constructor(e){this.type=`priceRange`,this.id=`pr_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s=2,c){if(this.points.length<2)return;let[l,u]=this.points,d=t.xToPixel(l.barIndex,n,i),f=t.yToPixel(l.price,r,a),p=t.xToPixel(u.barIndex,n,i),m=t.yToPixel(u.price,r,a),h=(d+p)/2,g=(f+m)/2,_=Math.min(f,m),v=Math.max(f,m),y=Y(`priceRange`,this.style,c),b=y.strokeColor;e.save(),e.strokeStyle=b,e.fillStyle=b,e.lineWidth=o?y.lineWidth+.5:y.lineWidth,X(e,o?`solid`:y.lineStyle,e.lineWidth),e.font=`10px 'Inter', system-ui, sans-serif`,e.beginPath(),e.moveTo(h,_),e.lineTo(h,v),e.stroke(),Oa(e,h,v,h,_),Oa(e,h,_,h,v),e.beginPath(),e.moveTo(d-10,f),e.lineTo(d+10,f),e.stroke(),e.beginPath(),e.moveTo(p-10,m),e.lineTo(p+10,m),e.stroke(),e.setLineDash([]);let x=Math.abs(l.price-u.price).toFixed(s),S=((u.price-l.price)/l.price*100).toFixed(2)+`%`,C=x,w=S,T=h+8,E=g-30/2;e.fillStyle=Z(y.fillColor,y.fillOpacity),e.fillRect(T,E,70,30),e.strokeStyle=b,e.strokeRect(T,E,70,30),e.fillStyle=b,e.fillText(C,T+4,E+4+10),e.fillText(w,T+4,E+4+22),e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let[s,c]=this.points,l=n.xToPixel(s.barIndex,r,a),u=n.yToPixel(s.price,i,o),d=n.xToPixel(c.barIndex,r,a),f=n.yToPixel(c.price,i,o),p=(l+d)/2,m=Math.min(u,f),h=Math.max(u,f);return Math.abs(e-p)<=Da&&t>=m&&t<=h}getHandle(e,t,n,r,i,a,o){if(this.points.length<2)return null;let s=[{px:n.xToPixel(this.points[0].barIndex,r,a),py:n.yToPixel(this.points[0].price,i,o)},{px:n.xToPixel(this.points[1].barIndex,r,a),py:n.yToPixel(this.points[1].price,i,o)}];for(let n=0;n<s.length;n++)if(Math.hypot(e-s[n].px,t-s[n].py)<=Da+2)return{pointIndex:n,cursor:`ns-resize`};return null}},Aa=6;function ja(e,t,n,r,i,a=7){let o=Math.atan2(i-n,r-t);e.beginPath(),e.moveTo(r,i),e.lineTo(r-a*Math.cos(o-Math.PI/6),i-a*Math.sin(o-Math.PI/6)),e.lineTo(r-a*Math.cos(o+Math.PI/6),i-a*Math.sin(o+Math.PI/6)),e.closePath(),e.fill()}var Ma=class{constructor(e){this.type=`dateRange`,this.id=`dr_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let[l,u]=this.points,d=t.xToPixel(l.barIndex,n,i),f=t.yToPixel(l.price,r,a),p=t.xToPixel(u.barIndex,n,i),m=t.yToPixel(u.price,r,a),h=(f+m)/2,g=Math.min(d,p),_=Math.max(d,p),v=Y(`dateRange`,this.style,c),y=v.strokeColor;e.save(),e.strokeStyle=y,e.fillStyle=y,e.lineWidth=o?v.lineWidth+.5:v.lineWidth,X(e,o?`solid`:v.lineStyle,e.lineWidth),e.font=`10px 'Inter', system-ui, sans-serif`,e.beginPath(),e.moveTo(g,h),e.lineTo(_,h),e.stroke(),ja(e,_,h,g,h),ja(e,g,h,_,h),e.beginPath(),e.moveTo(d,f-10),e.lineTo(d,f+10),e.stroke(),e.beginPath(),e.moveTo(p,m-10),e.lineTo(p,m+10),e.stroke(),e.setLineDash([]);let b=`${Math.abs(u.barIndex-l.barIndex)} bars`,x=(d+p)/2,S=e.measureText(b).width;e.fillStyle=y,e.fillText(b,x-S/2,h-10),e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let[s,c]=this.points,l=n.xToPixel(s.barIndex,r,a),u=n.yToPixel(s.price,i,o),d=n.xToPixel(c.barIndex,r,a),f=(u+n.yToPixel(c.price,i,o))/2,p=Math.min(l,d),m=Math.max(l,d);return Math.abs(t-f)<=Aa&&e>=p&&e<=m}getHandle(e,t,n,r,i,a,o){if(this.points.length<2)return null;let s=[{px:n.xToPixel(this.points[0].barIndex,r,a),py:n.yToPixel(this.points[0].price,i,o)},{px:n.xToPixel(this.points[1].barIndex,r,a),py:n.yToPixel(this.points[1].price,i,o)}];for(let n=0;n<s.length;n++)if(Math.hypot(e-s[n].px,t-s[n].py)<=Aa+2)return{pointIndex:n,cursor:`ew-resize`};return null}},Na=6;function Pa(e,t,n,r,i,a=7){let o=Math.atan2(i-n,r-t);e.beginPath(),e.moveTo(r,i),e.lineTo(r-a*Math.cos(o-Math.PI/6),i-a*Math.sin(o-Math.PI/6)),e.lineTo(r-a*Math.cos(o+Math.PI/6),i-a*Math.sin(o+Math.PI/6)),e.closePath(),e.fill()}var Fa=class{constructor(e){this.type=`datePriceRange`,this.id=`dpr_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s=2,c){if(this.points.length<2)return;let[l,u]=this.points,d=t.xToPixel(l.barIndex,n,i),f=t.yToPixel(l.price,r,a),p=t.xToPixel(u.barIndex,n,i),m=t.yToPixel(u.price,r,a),h=Math.min(d,p),g=Math.min(f,m),_=Math.max(d,p),v=Math.max(f,m),y=_-h,b=v-g,x=Y(`datePriceRange`,this.style,c),S=x.strokeColor;e.save(),e.font=`10px 'Inter', system-ui, sans-serif`,e.lineWidth=o?x.lineWidth+.5:x.lineWidth,e.fillStyle=Z(x.fillColor,x.fillOpacity),e.fillRect(h,g,y,b),e.strokeStyle=S,X(e,o?`solid`:x.lineStyle,e.lineWidth),e.strokeRect(h,g,y,b),e.setLineDash([]),e.strokeStyle=S,e.fillStyle=S,e.beginPath(),e.moveTo(d,f),e.lineTo(p,m),e.stroke(),Pa(e,d,f,p,m);let C=`\u0394${Math.abs(l.price-u.price).toFixed(s)}`;e.fillStyle=S,e.fillText(C,_+4,(g+v)/2);let w=`${Math.abs(u.barIndex-l.barIndex)} bars`,T=e.measureText(w).width;e.fillText(w,h+y/2-T/2,v+12),e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let[s,c]=this.points,l=n.xToPixel(s.barIndex,r,a),u=n.yToPixel(s.price,i,o),d=n.xToPixel(c.barIndex,r,a),f=n.yToPixel(c.price,i,o),p=Math.min(l,d)-Na,m=Math.min(u,f)-Na,h=Math.max(l,d)+Na,g=Math.max(u,f)+Na;return e>=p&&e<=h&&t>=m&&t<=g}getHandle(e,t,n,r,i,a,o){if(this.points.length<2)return null;let s=[{px:n.xToPixel(this.points[0].barIndex,r,a),py:n.yToPixel(this.points[0].price,i,o)},{px:n.xToPixel(this.points[1].barIndex,r,a),py:n.yToPixel(this.points[1].price,i,o)}];for(let n=0;n<s.length;n++)if(Math.hypot(e-s[n].px,t-s[n].py)<=Na+2)return{pointIndex:n,cursor:`nwse-resize`};return null}},Ia=6;function La(e,t,n,r,i,a){let o=i-n,s=a-r,c=o*o+s*s;if(c===0)return Math.hypot(e-n,t-r);let l=Math.max(0,Math.min(1,((e-n)*o+(t-r)*s)/c));return Math.hypot(e-(n+l*o),t-(r+l*s))}var Ra=class{constructor(e){this.type=`ruler`,this.id=`rul_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s=2,c){if(this.points.length<2)return;let[l,u]=this.points,d=t.xToPixel(l.barIndex,n,i),f=t.yToPixel(l.price,r,a),p=t.xToPixel(u.barIndex,n,i),m=t.yToPixel(u.price,r,a),h=Y(`ruler`,this.style,c),g=h.strokeColor,_=Math.atan2(m-f,p-d),v=_+Math.PI/2;e.save(),e.strokeStyle=g,e.fillStyle=g,e.lineWidth=o?h.lineWidth+.5:h.lineWidth,X(e,o?`solid`:h.lineStyle,e.lineWidth),e.font=`10px 'Inter', system-ui, sans-serif`,e.beginPath(),e.moveTo(d,f),e.lineTo(p,m),e.stroke(),e.beginPath(),e.moveTo(d-8*Math.cos(v),f-8*Math.sin(v)),e.lineTo(d+8*Math.cos(v),f+8*Math.sin(v)),e.stroke(),e.beginPath(),e.moveTo(p-8*Math.cos(v),m-8*Math.sin(v)),e.lineTo(p+8*Math.cos(v),m+8*Math.sin(v)),e.stroke(),e.setLineDash([]);let y=(d+p)/2,b=(f+m)/2,x=Math.abs(u.barIndex-l.barIndex),S=(u.price-l.price).toFixed(s),C=`${x} bars`,w=`${S}`,T=-12*Math.sin(_),E=12*Math.cos(_);e.fillStyle=g,e.fillText(C,y+T,b+E-12),e.fillText(w,y+T,b+E),e.beginPath(),e.arc(d,f,o?4:3,0,Math.PI*2),e.fill(),e.beginPath(),e.arc(p,m,o?4:3,0,Math.PI*2),e.fill(),e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let[s,c]=this.points;return La(e,t,n.xToPixel(s.barIndex,r,a),n.yToPixel(s.price,i,o),n.xToPixel(c.barIndex,r,a),n.yToPixel(c.price,i,o))<=Ia}getHandle(e,t,n,r,i,a,o){if(this.points.length<2)return null;let s=[{px:n.xToPixel(this.points[0].barIndex,r,a),py:n.yToPixel(this.points[0].price,i,o)},{px:n.xToPixel(this.points[1].barIndex,r,a),py:n.yToPixel(this.points[1].price,i,o)}];for(let n=0;n<s.length;n++)if(Math.hypot(e-s[n].px,t-s[n].py)<=Ia+2)return{pointIndex:n,cursor:`grab`};return null}},za=6;function Ba(e,t,n,r,i,a){let o=i-n,s=a-r,c=o*o+s*s;if(c===0)return Math.hypot(e-n,t-r);let l=Math.max(0,Math.min(1,((e-n)*o+(t-r)*s)/c));return Math.hypot(e-(n+l*o),t-(r+l*s))}function Va(e,t,n,r,i){return n===0?[e,t]:[i,t+(i-e)/n*r]}var Ha=class{constructor(e){this.type=`pitchfork`,this.requiredPoints=3,this.id=`pfk_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let[l,u,d]=this.points,f=t.xToPixel(l.barIndex,n,i),p=t.yToPixel(l.price,r,a),m=t.xToPixel(u.barIndex,n,i),h=t.yToPixel(u.price,r,a),g=Y(`pitchfork`,this.style,c);if(e.save(),e.strokeStyle=g.strokeColor,e.lineWidth=o?g.lineWidth+.5:g.lineWidth,X(e,o?`solid`:g.lineStyle,e.lineWidth),d){let s=t.xToPixel(d.barIndex,n,i),c=t.yToPixel(d.price,r,a),l=(m+s)/2,u=(h+c)/2,_=l-f,v=u-p,[y,b]=Va(f,p,_,v,i);e.beginPath(),e.moveTo(f,p),e.lineTo(l,u),e.stroke(),e.beginPath(),e.moveTo(f,p),e.lineTo(y,b),e.stroke();let[x,S]=Va(m,h,_,v,i);e.beginPath(),e.moveTo(m,h),e.lineTo(x,S),e.stroke();let[C,w]=Va(s,c,_,v,i);if(e.beginPath(),e.moveTo(s,c),e.lineTo(C,w),e.stroke(),e.setLineDash([]),o){e.fillStyle=g.strokeColor;for(let[t,n]of[[f,p],[m,h],[s,c]])e.beginPath(),e.arc(t,n,4,0,Math.PI*2),e.fill()}}else e.beginPath(),e.moveTo(f,p),e.lineTo(m,h),e.stroke(),e.setLineDash([]);e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<3)return!1;let[s,c,l]=this.points,u=n.xToPixel(s.barIndex,r,a),d=n.yToPixel(s.price,i,o),f=n.xToPixel(c.barIndex,r,a),p=n.yToPixel(c.price,i,o),m=n.xToPixel(l.barIndex,r,a),h=n.yToPixel(l.price,i,o),g=(f+m)/2,_=(p+h)/2,v=g-u,y=_-d,[b,x]=Va(u,d,v,y,a),[S,C]=Va(f,p,v,y,a),[w,T]=Va(m,h,v,y,a);return Ba(e,t,u,d,b,x)<=za||Ba(e,t,f,p,S,C)<=za||Ba(e,t,m,h,w,T)<=za}getHandle(e,t,n,r,i,a,o){let s=this.points.map((e,t)=>({i:t,px:n.xToPixel(e.barIndex,r,a),py:n.yToPixel(e.price,i,o)}));for(let{i:n,px:r,py:i}of s)if(Math.hypot(e-r,t-i)<=za+2)return{pointIndex:n,cursor:`grab`};return null}},Ua=6;function Wa(e,t,n,r,i,a){let o=i-n,s=a-r,c=o*o+s*s;if(c===0)return Math.hypot(e-n,t-r);let l=Math.max(0,Math.min(1,((e-n)*o+(t-r)*s)/c));return Math.hypot(e-(n+l*o),t-(r+l*s))}function Ga(e,t,n,r,i){return n===0?[e,t]:[i,t+(i-e)/n*r]}var Ka=class{constructor(e){this.type=`schiffPitchfork`,this.requiredPoints=3,this.id=`spfk_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let[l,u,d]=this.points,f=t.xToPixel(l.barIndex,n,i),p=t.yToPixel(l.price,r,a),m=t.xToPixel(u.barIndex,n,i),h=t.yToPixel(u.price,r,a),g=Y(`schiffPitchfork`,this.style,c);if(e.save(),e.strokeStyle=g.strokeColor,e.lineWidth=o?g.lineWidth+.5:g.lineWidth,X(e,o?`solid`:g.lineStyle,e.lineWidth),d){let s=t.xToPixel(d.barIndex,n,i),c=t.yToPixel(d.price,r,a),l=(f+m)/2,u=(p+h)/2,_=(m+s)/2,v=(h+c)/2,y=_-l,b=v-u,[x,S]=Ga(l,u,y,b,i);e.beginPath(),e.moveTo(l,u),e.lineTo(_,v),e.stroke(),e.beginPath(),e.moveTo(l,u),e.lineTo(x,S),e.stroke();let[C,w]=Ga(m,h,y,b,i);e.beginPath(),e.moveTo(m,h),e.lineTo(C,w),e.stroke();let[T,E]=Ga(s,c,y,b,i);if(e.beginPath(),e.moveTo(s,c),e.lineTo(T,E),e.stroke(),e.setLineDash([]),o){e.fillStyle=g.strokeColor;for(let[t,n]of[[f,p],[m,h],[s,c]])e.beginPath(),e.arc(t,n,4,0,Math.PI*2),e.fill()}}else e.beginPath(),e.moveTo(f,p),e.lineTo(m,h),e.stroke(),e.setLineDash([]);e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<3)return!1;let[s,c,l]=this.points,u=n.xToPixel(s.barIndex,r,a),d=n.yToPixel(s.price,i,o),f=n.xToPixel(c.barIndex,r,a),p=n.yToPixel(c.price,i,o),m=n.xToPixel(l.barIndex,r,a),h=n.yToPixel(l.price,i,o),g=(u+f)/2,_=(d+p)/2,v=(f+m)/2,y=(p+h)/2,b=v-g,x=y-_,[S,C]=Ga(g,_,b,x,a),[w,T]=Ga(f,p,b,x,a),[E,D]=Ga(m,h,b,x,a);return Wa(e,t,g,_,S,C)<=Ua||Wa(e,t,f,p,w,T)<=Ua||Wa(e,t,m,h,E,D)<=Ua}getHandle(e,t,n,r,i,a,o){let s=this.points.map((e,t)=>({i:t,px:n.xToPixel(e.barIndex,r,a),py:n.yToPixel(e.price,i,o)}));for(let{i:n,px:r,py:i}of s)if(Math.hypot(e-r,t-i)<=Ua+2)return{pointIndex:n,cursor:`grab`};return null}},qa=6;function Ja(e,t,n,r,i,a){let o=i-n,s=a-r,c=o*o+s*s;if(c===0)return Math.hypot(e-n,t-r);let l=Math.max(0,Math.min(1,((e-n)*o+(t-r)*s)/c));return Math.hypot(e-(n+l*o),t-(r+l*s))}function Ya(e,t,n,r,i){return n===0?[e,t]:[i,t+(i-e)/n*r]}var Xa=class{constructor(e){this.type=`modifiedSchiff`,this.requiredPoints=3,this.id=`mspfk_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let[l,u,d]=this.points,f=t.xToPixel(l.barIndex,n,i),p=t.yToPixel(l.price,r,a),m=t.xToPixel(u.barIndex,n,i),h=t.yToPixel(u.price,r,a),g=Y(`modifiedSchiff`,this.style,c);if(e.save(),e.strokeStyle=g.strokeColor,e.lineWidth=o?g.lineWidth+.5:g.lineWidth,X(e,o?`solid`:g.lineStyle,e.lineWidth),d){let s=t.xToPixel(d.barIndex,n,i),c=t.yToPixel(d.price,r,a),l=(m+s)/2,u=(h+c)/2,_=(f+l)/2,v=(p+u)/2,y=l-_,b=u-v,[x,S]=Ya(_,v,y,b,i);e.beginPath(),e.moveTo(_,v),e.lineTo(l,u),e.stroke(),e.beginPath(),e.moveTo(_,v),e.lineTo(x,S),e.stroke();let[C,w]=Ya(m,h,y,b,i);e.beginPath(),e.moveTo(m,h),e.lineTo(C,w),e.stroke();let[T,E]=Ya(s,c,y,b,i);if(e.beginPath(),e.moveTo(s,c),e.lineTo(T,E),e.stroke(),e.setLineDash([]),o){e.fillStyle=g.strokeColor;for(let[t,n]of[[f,p],[m,h],[s,c]])e.beginPath(),e.arc(t,n,4,0,Math.PI*2),e.fill()}}else e.beginPath(),e.moveTo(f,p),e.lineTo(m,h),e.stroke(),e.setLineDash([]);e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<3)return!1;let[s,c,l]=this.points,u=n.xToPixel(s.barIndex,r,a),d=n.yToPixel(s.price,i,o),f=n.xToPixel(c.barIndex,r,a),p=n.yToPixel(c.price,i,o),m=n.xToPixel(l.barIndex,r,a),h=n.yToPixel(l.price,i,o),g=(f+m)/2,_=(p+h)/2,v=(u+g)/2,y=(d+_)/2,b=g-v,x=_-y,[S,C]=Ya(v,y,b,x,a),[w,T]=Ya(f,p,b,x,a),[E,D]=Ya(m,h,b,x,a);return Ja(e,t,v,y,S,C)<=qa||Ja(e,t,f,p,w,T)<=qa||Ja(e,t,m,h,E,D)<=qa}getHandle(e,t,n,r,i,a,o){let s=this.points.map((e,t)=>({i:t,px:n.xToPixel(e.barIndex,r,a),py:n.yToPixel(e.price,i,o)}));for(let{i:n,px:r,py:i}of s)if(Math.hypot(e-r,t-i)<=qa+2)return{pointIndex:n,cursor:`grab`};return null}},Za=6;function Qa(e,t,n,r,i,a){let o=i-n,s=a-r,c=o*o+s*s;if(c===0)return Math.hypot(e-n,t-r);let l=Math.max(0,Math.min(1,((e-n)*o+(t-r)*s)/c));return Math.hypot(e-(n+l*o),t-(r+l*s))}function $a(e,t,n,r,i){return n===0?[e,t]:[i,t+(i-e)/n*r]}var eo=class{constructor(e){this.type=`insidePitchfork`,this.requiredPoints=3,this.id=`ipfk_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let[l,u,d]=this.points,f=t.xToPixel(l.barIndex,n,i),p=t.yToPixel(l.price,r,a),m=t.xToPixel(u.barIndex,n,i),h=t.yToPixel(u.price,r,a),g=Y(`insidePitchfork`,this.style,c);if(e.save(),e.strokeStyle=g.strokeColor,e.lineWidth=o?g.lineWidth+.5:g.lineWidth,X(e,o?`solid`:g.lineStyle,e.lineWidth),d){let s=t.xToPixel(d.barIndex,n,i),c=t.yToPixel(d.price,r,a),l=(m+s)/2,u=(h+c)/2,_=l-f,v=u-p;e.beginPath(),e.moveTo(f,p),e.lineTo(l,u),e.stroke();let[y,b]=$a(f,p,_,v,i);e.beginPath(),e.moveTo(f,p),e.lineTo(y,b),e.stroke();let[x,S]=$a(m,h,_,v,i);e.beginPath(),e.moveTo(m,h),e.lineTo(x,S),e.stroke();let[C,w]=$a(s,c,_,v,i);e.beginPath(),e.moveTo(s,c),e.lineTo(C,w),e.stroke();let T=(f+m)/2,E=(p+h)/2,[D,O]=$a(T,E,_,v,i);e.globalAlpha=.55,e.setLineDash([4,3]),e.beginPath(),e.moveTo(T,E),e.lineTo(D,O),e.stroke();let k=(f+s)/2,A=(p+c)/2,[ee,j]=$a(k,A,_,v,i);if(e.beginPath(),e.moveTo(k,A),e.lineTo(ee,j),e.stroke(),e.setLineDash([]),e.globalAlpha=1,o){e.fillStyle=g.strokeColor;for(let[t,n]of[[f,p],[m,h],[s,c]])e.beginPath(),e.arc(t,n,4,0,Math.PI*2),e.fill()}}else e.beginPath(),e.moveTo(f,p),e.lineTo(m,h),e.stroke(),e.setLineDash([]);e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<3)return!1;let[s,c,l]=this.points,u=n.xToPixel(s.barIndex,r,a),d=n.yToPixel(s.price,i,o),f=n.xToPixel(c.barIndex,r,a),p=n.yToPixel(c.price,i,o),m=n.xToPixel(l.barIndex,r,a),h=n.yToPixel(l.price,i,o),g=(f+m)/2,_=(p+h)/2,v=g-u,y=_-d,[b,x]=$a(u,d,v,y,a),[S,C]=$a(f,p,v,y,a),[w,T]=$a(m,h,v,y,a);if(Qa(e,t,u,d,b,x)<=Za||Qa(e,t,f,p,S,C)<=Za||Qa(e,t,m,h,w,T)<=Za)return!0;let E=(u+f)/2,D=(d+p)/2,[O,k]=$a(E,D,v,y,a);if(Qa(e,t,E,D,O,k)<=Za)return!0;let A=(u+m)/2,ee=(d+h)/2,[j,te]=$a(A,ee,v,y,a);return Qa(e,t,A,ee,j,te)<=Za}getHandle(e,t,n,r,i,a,o){let s=this.points.map((e,t)=>({i:t,px:n.xToPixel(e.barIndex,r,a),py:n.yToPixel(e.price,i,o)}));for(let{i:n,px:r,py:i}of s)if(Math.hypot(e-r,t-i)<=Za+2)return{pointIndex:n,cursor:`grab`};return null}},to=6,no=[.35,.55,.75,1,1,.75,.55,.35],ro=class{constructor(e){this.type=`fixedRangeVP`,this.id=`frvp_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let[l,u]=this.points,d=t.xToPixel(l.barIndex,n,i),f=t.yToPixel(l.price,r,a),p=t.xToPixel(u.barIndex,n,i),m=t.yToPixel(u.price,r,a),h=Math.min(d,p),g=Math.min(f,m),_=Math.abs(p-d),v=Math.abs(m-f),y=Y(`fixedRangeVP`,this.style,c);e.save(),e.strokeStyle=y.strokeColor,e.lineWidth=o?y.lineWidth+.5:y.lineWidth,X(e,o?`solid`:y.lineStyle,e.lineWidth),e.strokeRect(h,g,_,v),e.setLineDash([]);let b=no.length,x=v/b,S=_*.6,C=Z(y.fillColor,y.fillOpacity);for(let t=0;t<b;t++){let n=S*no[t],r=g+t*x;e.fillStyle=C,e.fillRect(h,r,n,x-1)}if(e.font=`11px 'Inter', system-ui, sans-serif`,e.fillStyle=y.strokeColor,e.fillText(`Volume Profile`,h+4,g+13),o)for(let[t,n]of[[d,f],[p,m]])e.beginPath(),e.arc(t,n,3.5,0,Math.PI*2),e.fillStyle=y.strokeColor,e.fill();e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let[s,c]=this.points,l=n.xToPixel(s.barIndex,r,a),u=n.yToPixel(s.price,i,o),d=n.xToPixel(c.barIndex,r,a),f=n.yToPixel(c.price,i,o),p=Math.min(l,d)-to,m=Math.min(u,f)-to,h=Math.abs(d-l)+to*2,g=Math.abs(f-u)+to*2;return e>=p&&e<=p+h&&t>=m&&t<=m+g}getHandle(e,t,n,r,i,a,o){if(this.points.length<2)return null;let s=[[0,n.xToPixel(this.points[0].barIndex,r,a),n.yToPixel(this.points[0].price,i,o)],[1,n.xToPixel(this.points[1].barIndex,r,a),n.yToPixel(this.points[1].price,i,o)]];for(let[n,r,i]of s)if(Math.hypot(e-r,t-i)<=to+2)return{pointIndex:n,cursor:`nwse-resize`};return null}},io=6,ao=[.35,.55,.75,1,1,.75,.55,.35],oo=class{constructor(e){this.type=`anchoredVP`,this.id=`avp_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let[l,u]=this.points,d=t.xToPixel(l.barIndex,n,i),f=t.yToPixel(l.price,r,a),p=t.xToPixel(u.barIndex,n,i),m=t.yToPixel(u.price,r,a),h=Math.min(d,p),g=Math.min(f,m),_=Math.abs(p-d),v=Math.abs(m-f),y=Y(`anchoredVP`,this.style,c);e.save(),e.strokeStyle=y.strokeColor,e.lineWidth=o?y.lineWidth+.5:y.lineWidth,X(e,o?`solid`:y.lineStyle,e.lineWidth),e.strokeRect(h,g,_,v),e.setLineDash([]);let b=ao.length,x=v/b,S=_*.6,C=Z(y.fillColor,y.fillOpacity);for(let t=0;t<b;t++){let n=S*ao[t],r=g+t*x;e.fillStyle=C,e.fillRect(h,r,n,x-1)}if(e.font=`11px 'Inter', system-ui, sans-serif`,e.fillStyle=y.strokeColor,e.fillText(`Anchored VP`,h+4,g+13),e.beginPath(),e.arc(d,f,o?4:3,0,Math.PI*2),e.fillStyle=y.strokeColor,e.fill(),o)for(let[t,n]of[[d,f],[p,m]])e.beginPath(),e.arc(t,n,3.5,0,Math.PI*2),e.fillStyle=y.strokeColor,e.fill();e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let[s,c]=this.points,l=n.xToPixel(s.barIndex,r,a),u=n.yToPixel(s.price,i,o),d=n.xToPixel(c.barIndex,r,a),f=n.yToPixel(c.price,i,o),p=Math.min(l,d)-io,m=Math.min(u,f)-io,h=Math.abs(d-l)+io*2,g=Math.abs(f-u)+io*2;return e>=p&&e<=p+h&&t>=m&&t<=m+g}getHandle(e,t,n,r,i,a,o){if(this.points.length<2)return null;let s=[[0,n.xToPixel(this.points[0].barIndex,r,a),n.yToPixel(this.points[0].price,i,o)],[1,n.xToPixel(this.points[1].barIndex,r,a),n.yToPixel(this.points[1].price,i,o)]];for(let[n,r,i]of s)if(Math.hypot(e-r,t-i)<=io+2)return{pointIndex:n,cursor:`nwse-resize`};return null}},so=6,co=[.25,.45,.65,.85,1,1,.85,.65,.45,.25],lo=class{constructor(e){this.type=`volumeProfile`,this.id=`vp_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let[l,u]=this.points,d=t.xToPixel(l.barIndex,n,i),f=t.yToPixel(l.price,r,a),p=t.xToPixel(u.barIndex,n,i),m=t.yToPixel(u.price,r,a),h=Math.min(d,p),g=Math.min(f,m),_=Math.abs(p-d),v=Math.abs(m-f),y=Y(`volumeProfile`,this.style,c);e.save(),e.strokeStyle=y.strokeColor,e.lineWidth=o?y.lineWidth+.5:y.lineWidth,X(e,o?`solid`:y.lineStyle,e.lineWidth),e.strokeRect(h,g,_,v),e.setLineDash([]);let b=co.length,x=v/b,S=_*.6,C=Z(y.fillColor,y.fillOpacity);for(let t=0;t<b;t++){let n=S*co[t],r=g+t*x;e.fillStyle=C,e.fillRect(h,r,n,x-1)}if(e.font=`11px 'Inter', system-ui, sans-serif`,e.fillStyle=y.strokeColor,e.fillText(`Volume Profile`,h+4,g+13),o)for(let[t,n]of[[d,f],[p,m]])e.beginPath(),e.arc(t,n,3.5,0,Math.PI*2),e.fillStyle=y.strokeColor,e.fill();e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let[s,c]=this.points,l=n.xToPixel(s.barIndex,r,a),u=n.yToPixel(s.price,i,o),d=n.xToPixel(c.barIndex,r,a),f=n.yToPixel(c.price,i,o),p=Math.min(l,d)-so,m=Math.min(u,f)-so,h=Math.abs(d-l)+so*2,g=Math.abs(f-u)+so*2;return e>=p&&e<=p+h&&t>=m&&t<=m+g}getHandle(e,t,n,r,i,a,o){if(this.points.length<2)return null;let s=[[0,n.xToPixel(this.points[0].barIndex,r,a),n.yToPixel(this.points[0].price,i,o)],[1,n.xToPixel(this.points[1].barIndex,r,a),n.yToPixel(this.points[1].price,i,o)]];for(let[n,r,i]of s)if(Math.hypot(e-r,t-i)<=so+2)return{pointIndex:n,cursor:`nwse-resize`};return null}},uo=6;function fo(e,t,n,r,i,a){let o=i-n,s=a-r,c=o*o+s*s;if(c===0)return Math.hypot(e-n,t-r);let l=Math.max(0,Math.min(1,((e-n)*o+(t-r)*s)/c));return Math.hypot(e-(n+l*o),t-(r+l*s))}var po=class{constructor(e){this.type=`regressionTrend`,this.id=`reg_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let[l,u]=this.points,d=t.xToPixel(l.barIndex,n,i),f=t.yToPixel(l.price,r,a),p=t.xToPixel(u.barIndex,n,i),m=t.yToPixel(u.price,r,a),h=Y(`regressionTrend`,this.style,c),g=Z(h.strokeColor,.4),_=Math.hypot(p-d,m-f)||1,v=-(m-f)/_,y=(p-d)/_;e.save(),e.strokeStyle=h.strokeColor,e.fillStyle=h.strokeColor,e.lineWidth=o?h.lineWidth+.5:h.lineWidth,X(e,o?`solid`:h.lineStyle,e.lineWidth),e.beginPath(),e.moveTo(d,f),e.lineTo(p,m),e.stroke(),e.strokeStyle=g,e.setLineDash([4,3]),e.beginPath(),e.moveTo(d+v*20,f+y*20),e.lineTo(p+v*20,m+y*20),e.stroke(),e.beginPath(),e.moveTo(d-v*20,f-y*20),e.lineTo(p-v*20,m-y*20),e.stroke(),e.setLineDash([]),e.beginPath(),e.arc(d,f,o?4:3,0,Math.PI*2),e.fill(),e.beginPath(),e.arc(p,m,o?4:3,0,Math.PI*2),e.fill(),e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let[s,c]=this.points;return fo(e,t,n.xToPixel(s.barIndex,r,a),n.yToPixel(s.price,i,o),n.xToPixel(c.barIndex,r,a),n.yToPixel(c.price,i,o))<=uo}getHandle(e,t,n,r,i,a,o){if(this.points.length<2)return null;let s=[{px:n.xToPixel(this.points[0].barIndex,r,a),py:n.yToPixel(this.points[0].price,i,o)},{px:n.xToPixel(this.points[1].barIndex,r,a),py:n.yToPixel(this.points[1].price,i,o)}];for(let n=0;n<s.length;n++)if(Math.hypot(e-s[n].px,t-s[n].py)<=uo+2)return{pointIndex:n,cursor:`grab`};return null}},mo=6,ho=`Text`,go=4,_o=class{constructor(e){this.type=`text`,this.text=``,this.id=`txt_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e],this.complete=!0}render(e,t,n,r,i,a,o,s,c){var l,u;let d=t.xToPixel(this.points[0].barIndex,n,i),f=t.yToPixel(this.points[0].price,r,a),p=Y(`text`,this.style,c),m=(l=p.fontSize)==null?13:l,h=(u=p.textColor)==null?`#f5f5f5`:u;e.save(),e.font=`${m}px system-ui, sans-serif`,e.textBaseline=`top`;let g=this.text||ho,_=!this.text,v=e.measureText(g).width;o&&(e.strokeStyle=`#2196f3`,e.lineWidth=1,e.strokeRect(d-2,f-2,v+go*2,20)),e.fillStyle=_?`#888`:h,e.fillText(g,d+go,f),o&&(e.strokeStyle=h,e.lineWidth=1,e.beginPath(),e.moveTo(d,f+16),e.lineTo(d+v+go*2,f+16),e.stroke()),e.restore()}hitTest(e,t,n,r,i,a,o){var s,c;let l=n.xToPixel(this.points[0].barIndex,r,a),u=n.yToPixel(this.points[0].price,i,o),d=Math.max(40,((s=(c=this.text)==null?void 0:c.length)==null?4:s)*8);return e>=l-mo&&e<=l+d+mo&&t>=u-mo&&t<=u+16+mo}getHandle(){return null}},vo=6,yo=24,bo=8,xo=12;function So(e,t,n,r,i,a){let o=i-n,s=a-r,c=o*o+s*s;if(c===0)return Math.hypot(e-n,t-r);let l=Math.max(0,Math.min(1,((e-n)*o+(t-r)*s)/c));return Math.hypot(e-(n+l*o),t-(r+l*s))}function Co(e,t,n,r,i,a){e.beginPath(),e.moveTo(t+a,n),e.lineTo(t+r-a,n),e.arcTo(t+r,n,t+r,n+a,a),e.lineTo(t+r,n+i-a),e.arcTo(t+r,n+i,t+r-a,n+i,a),e.lineTo(t+a,n+i),e.arcTo(t,n+i,t,n+i-a,a),e.lineTo(t,n+a),e.arcTo(t,n,t+a,n,a),e.closePath()}var wo=class{constructor(e){this.type=`callout`,this.text=``,this.id=`cal_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}getBoxW(e){let t=this.text||`Note`;return Math.max(60,e.measureText(t).width+xo*2)}render(e,t,n,r,i,a,o,s,c){var l,u;if(this.points.length<2)return;let[d,f]=this.points,p=t.xToPixel(d.barIndex,n,i),m=t.yToPixel(d.price,r,a),h=t.xToPixel(f.barIndex,n,i),g=t.yToPixel(f.price,r,a),_=Y(`callout`,this.style,c),v=(l=_.fontSize)==null?11:l,y=(u=_.textColor)==null?`#f5f5f5`:u;e.save(),e.font=`${v}px system-ui, sans-serif`,e.lineWidth=o?_.lineWidth+.5:_.lineWidth,X(e,o?`solid`:_.lineStyle,e.lineWidth);let b=this.getBoxW(e),x=h-b/2,S=g-yo/2,C=Math.max(x,Math.min(x+b,p)),w=Math.max(S,Math.min(S+yo,m)),T=p<x?x:p>x+b?x+b:C,E=m<S?S:m>S+yo?S+yo:w;e.strokeStyle=_.strokeColor,e.beginPath(),e.moveTo(T,E),e.lineTo(p,m),e.stroke(),e.setLineDash([]),e.fillStyle=_.strokeColor,e.beginPath(),e.arc(p,m,3,0,Math.PI*2),e.fill(),Co(e,x,S,b,yo,bo),e.fillStyle=Z(_.fillColor,_.fillOpacity),e.fill(),e.strokeStyle=_.strokeColor,e.stroke();let D=this.text||`Note`;e.fillStyle=this.text?y:`#888`,e.textBaseline=`middle`,e.textAlign=`center`,e.fillText(D,h,g),e.restore()}hitTest(e,t,n,r,i,a,o){var s,c;if(this.points.length<2)return!1;let[l,u]=this.points,d=n.xToPixel(l.barIndex,r,a),f=n.yToPixel(l.price,i,o),p=n.xToPixel(u.barIndex,r,a),m=n.yToPixel(u.price,i,o),h=Math.max(60,((s=(c=this.text)==null?void 0:c.length)==null?4:s)*7+24),g=p-h/2,_=m-yo/2;return e>=g-vo&&e<=g+h+vo&&t>=_-vo&&t<=_+yo+vo||So(e,t,d<g?g:d>g+h?g+h:Math.max(g,Math.min(g+h,d)),f<_?_:f>_+yo?_+yo:Math.max(_,Math.min(_+yo,f)),d,f)<=vo}getHandle(e,t,n,r,i,a,o){if(this.points.length<2)return null;let s=[{px:n.xToPixel(this.points[0].barIndex,r,a),py:n.yToPixel(this.points[0].price,i,o)},{px:n.xToPixel(this.points[1].barIndex,r,a),py:n.yToPixel(this.points[1].price,i,o)}],c=[`grab`,`move`];for(let n=0;n<s.length;n++)if(Math.hypot(e-s[n].px,t-s[n].py)<=vo+4)return{pointIndex:n,cursor:c[n]};return null}},To=6,Eo=60,Do=18,Oo=7,ko=class{constructor(e){this.type=`priceLabel`,this.id=`plbl_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e],this.complete=!0}render(e,t,n,r,i,a,o,s=2,c){var l,u;let d=t.xToPixel(this.points[0].barIndex,n,i),f=t.yToPixel(this.points[0].price,r,a),p=this.points[0].price,m=Y(`priceLabel`,this.style,c),h=(l=m.fontSize)==null?11:l,g=(u=m.textColor)==null?`#ffffff`:u;e.save(),e.fillStyle=m.fillColor,e.beginPath(),e.moveTo(d,f),e.lineTo(d+Oo,f-Do/2),e.lineTo(d+Oo,f+Do/2),e.closePath(),e.fill();let _=d+Oo,v=f-Do/2;e.fillStyle=m.fillColor,e.beginPath(),e.roundRect(_,v,Eo,Do,Do/2),e.fill(),o&&(e.strokeStyle=m.strokeColor,e.lineWidth=m.lineWidth+.5,e.beginPath(),e.roundRect(_-2,v-2,Eo+4,Do+4,Do/2+2),e.stroke()),e.font=`${h}px 'Inter', system-ui, sans-serif`,e.fillStyle=g,e.textBaseline=`middle`,e.textAlign=`center`,e.fillText(p.toFixed(s),_+Eo/2,f),e.restore()}hitTest(e,t,n,r,i,a,o){let s=n.xToPixel(this.points[0].barIndex,r,a),c=n.yToPixel(this.points[0].price,i,o),l=s+Oo,u=c-Do/2;return e>=s-To&&e<=l+Eo+To&&t>=u-To&&t<=u+Do+To}getHandle(){return null}},Ao=6;function jo(e,t,n,r,i,a){let o=i-n,s=a-r,c=o*o+s*s;if(c===0)return Math.hypot(e-n,t-r);let l=Math.max(0,Math.min(1,((e-n)*o+(t-r)*s)/c));return Math.hypot(e-(n+l*o),t-(r+l*s))}var Mo=class{constructor(e){this.type=`arrowMarker`,this.id=`arw_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let[l,u]=this.points,d=t.xToPixel(l.barIndex,n,i),f=t.yToPixel(l.price,r,a),p=t.xToPixel(u.barIndex,n,i),m=t.yToPixel(u.price,r,a),h=Y(`arrowMarker`,this.style,c);e.save(),e.strokeStyle=h.strokeColor,e.fillStyle=Z(h.fillColor,h.fillOpacity),e.lineWidth=o?h.lineWidth+.5:h.lineWidth,X(e,o?`solid`:h.lineStyle,e.lineWidth),e.beginPath(),e.moveTo(d,f),e.lineTo(p,m),e.stroke(),e.setLineDash([]);let g=Math.atan2(m-f,p-d);if(e.beginPath(),e.moveTo(p,m),e.lineTo(p-10*Math.cos(g-Math.PI/6),m-10*Math.sin(g-Math.PI/6)),e.lineTo(p-10*Math.cos(g+Math.PI/6),m-10*Math.sin(g+Math.PI/6)),e.closePath(),e.fill(),o){e.fillStyle=h.strokeColor;for(let[t,n]of[[d,f],[p,m]])e.beginPath(),e.arc(t,n,4,0,Math.PI*2),e.fill()}e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let[s,c]=this.points;return jo(e,t,n.xToPixel(s.barIndex,r,a),n.yToPixel(s.price,i,o),n.xToPixel(c.barIndex,r,a),n.yToPixel(c.price,i,o))<=Ao}getHandle(e,t,n,r,i,a,o){if(this.points.length<2)return null;let s=[{px:n.xToPixel(this.points[0].barIndex,r,a),py:n.yToPixel(this.points[0].price,i,o)},{px:n.xToPixel(this.points[1].barIndex,r,a),py:n.yToPixel(this.points[1].price,i,o)}];for(let n=0;n<s.length;n++)if(Math.hypot(e-s[n].px,t-s[n].py)<=Ao+2)return{pointIndex:n,cursor:`grab`};return null}},No=class{constructor(e){this.type=`flag`,this.id=`flag_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e],this.complete=!0}render(e,t,n,r,i,a,o,s,c){let l=t.xToPixel(this.points[0].barIndex,n,i),u=t.yToPixel(this.points[0].price,r,a),d=Y(`flag`,this.style,c);e.save(),e.strokeStyle=d.strokeColor,e.lineWidth=o?d.lineWidth+.5:d.lineWidth,X(e,o?`solid`:d.lineStyle,e.lineWidth),e.beginPath(),e.moveTo(l,u+20),e.lineTo(l,u-10),e.stroke(),e.setLineDash([]);let f=l,p=u-10;e.fillStyle=Z(d.fillColor,d.fillOpacity),e.fillRect(f,p,16,10),e.font=`8px system-ui, sans-serif`,e.fillStyle=`#ffffff`,e.textBaseline=`middle`,e.textAlign=`center`,e.fillText(`F`,f+8,p+5),e.restore()}hitTest(e,t,n,r,i,a,o){let s=n.xToPixel(this.points[0].barIndex,r,a),c=n.yToPixel(this.points[0].price,i,o);return Math.hypot(e-s,t-c)<=20}getHandle(){return null}},Po=6,Fo=16,Io=6,Lo=10,Ro=class{constructor(e){this.type=`priceNote`,this.id=`pnote_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e],this.complete=!0}render(e,t,n,r,i,a,o,s=2,c){var l,u;let d=t.xToPixel(this.points[0].barIndex,n,i),f=t.yToPixel(this.points[0].price,r,a),p=this.points[0].price.toFixed(s),m=Y(`priceNote`,this.style,c),h=(l=m.fontSize)==null?11:l,g=(u=m.textColor)==null?`#ffffff`:u;e.save(),e.strokeStyle=m.strokeColor,e.lineWidth=o?m.lineWidth+.5:m.lineWidth,X(e,o?`solid`:m.lineStyle,e.lineWidth),e.beginPath(),e.moveTo(d-Lo,f),e.lineTo(d+Lo,f),e.stroke(),e.setLineDash([]),e.font=`${h}px 'Inter', system-ui, sans-serif`;let _=e.measureText(p).width+Io*2,v=d+Lo+2,y=f-Fo/2;e.fillStyle=m.fillColor,e.beginPath(),e.roundRect(v,y,_,Fo,3),e.fill(),e.fillStyle=g,e.textBaseline=`middle`,e.textAlign=`center`,e.fillText(p,v+_/2,f),e.restore()}hitTest(e,t,n,r,i,a,o){let s=n.xToPixel(this.points[0].barIndex,r,a),c=n.yToPixel(this.points[0].price,i,o);return e>=s-Lo-Po&&e<=s+Lo+Po&&Math.abs(t-c)<=Po}getHandle(){return null}},zo=6,Bo=20,Vo=10;function Ho(e,t,n,r,i,a){let o=i-n,s=a-r,c=o*o+s*s;if(c===0)return Math.hypot(e-n,t-r);let l=Math.max(0,Math.min(1,((e-n)*o+(t-r)*s)/c));return Math.hypot(e-(n+l*o),t-(r+l*s))}var Uo=class{constructor(e){this.type=`anchoredNote`,this.text=``,this.id=`anote_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}getBadgeW(e){let t=this.text||`Note`;return Math.max(50,e.measureText(t).width+Vo*2)}render(e,t,n,r,i,a,o,s,c){var l,u;if(this.points.length<2)return;let[d,f]=this.points,p=t.xToPixel(d.barIndex,n,i),m=t.yToPixel(d.price,r,a),h=t.xToPixel(f.barIndex,n,i),g=t.yToPixel(f.price,r,a),_=Y(`anchoredNote`,this.style,c),v=(l=_.fontSize)==null?11:l,y=(u=_.textColor)==null?`#f5f5f5`:u;e.save(),e.font=`${v}px system-ui, sans-serif`,e.lineWidth=o?_.lineWidth+.5:_.lineWidth;let b=this.getBadgeW(e),x=h-b/2,S=g-Bo/2;e.strokeStyle=_.strokeColor,e.setLineDash([4,3]),e.beginPath(),e.moveTo(p,m),e.lineTo(h,g),e.stroke(),e.setLineDash([]),e.fillStyle=_.strokeColor,e.beginPath(),e.arc(p,m,3,0,Math.PI*2),e.fill(),e.fillStyle=Z(_.fillColor,_.fillOpacity),e.beginPath(),e.roundRect(x,S,b,Bo,4),e.fill(),e.strokeStyle=_.strokeColor,e.lineWidth=o?_.lineWidth+.5:_.lineWidth,e.beginPath(),e.roundRect(x,S,b,Bo,4),e.stroke();let C=this.text||`Note`;e.fillStyle=this.text?y:`#888`,e.textBaseline=`middle`,e.textAlign=`center`,e.fillText(C,h,g),e.restore()}hitTest(e,t,n,r,i,a,o){var s,c;if(this.points.length<2)return!1;let[l,u]=this.points,d=n.xToPixel(l.barIndex,r,a),f=n.yToPixel(l.price,i,o),p=n.xToPixel(u.barIndex,r,a),m=n.yToPixel(u.price,i,o),h=Math.max(50,((s=(c=this.text)==null?void 0:c.length)==null?4:s)*7+20),g=p-h/2,_=m-Bo/2;return e>=g-zo&&e<=g+h+zo&&t>=_-zo&&t<=_+Bo+zo||Ho(e,t,d,f,p,m)<=zo}getHandle(e,t,n,r,i,a,o){if(this.points.length<2)return null;let s=[{px:n.xToPixel(this.points[0].barIndex,r,a),py:n.yToPixel(this.points[0].price,i,o)},{px:n.xToPixel(this.points[1].barIndex,r,a),py:n.yToPixel(this.points[1].price,i,o)}],c=[`grab`,`move`];for(let n=0;n<s.length;n++)if(Math.hypot(e-s[n].px,t-s[n].py)<=zo+4)return{pointIndex:n,cursor:c[n]};return null}},Wo=class{constructor(e){this.type=`arrowUp`,this.id=`awup_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e],this.complete=!0}render(e,t,n,r,i,a,o,s,c){let l=t.xToPixel(this.points[0].barIndex,n,i),u=t.yToPixel(this.points[0].price,r,a),d=Y(`arrowUp`,this.style,c);e.save(),e.strokeStyle=d.strokeColor,e.fillStyle=Z(d.fillColor,d.fillOpacity),e.lineWidth=o?d.lineWidth+.5:d.lineWidth,X(e,o?`solid`:d.lineStyle,e.lineWidth),e.beginPath(),e.moveTo(l,u+10),e.lineTo(l,u-2),e.stroke(),e.setLineDash([]);let f=l,p=u-10;e.beginPath(),e.moveTo(f,p),e.lineTo(f-6,p+10),e.lineTo(f+6,p+10),e.closePath(),e.fill(),e.restore()}hitTest(e,t,n,r,i,a,o){let s=n.xToPixel(this.points[0].barIndex,r,a),c=n.yToPixel(this.points[0].price,i,o);return Math.hypot(e-s,t-c)<=12}getHandle(){return null}},Go=class{constructor(e){this.type=`arrowDown`,this.id=`awdn_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e],this.complete=!0}render(e,t,n,r,i,a,o,s,c){let l=t.xToPixel(this.points[0].barIndex,n,i),u=t.yToPixel(this.points[0].price,r,a),d=Y(`arrowDown`,this.style,c);e.save(),e.strokeStyle=d.strokeColor,e.fillStyle=Z(d.fillColor,d.fillOpacity),e.lineWidth=o?d.lineWidth+.5:d.lineWidth,X(e,o?`solid`:d.lineStyle,e.lineWidth),e.beginPath(),e.moveTo(l,u-10),e.lineTo(l,u+2),e.stroke(),e.setLineDash([]);let f=l,p=u+10;e.beginPath(),e.moveTo(f,p),e.lineTo(f-6,p-10),e.lineTo(f+6,p-10),e.closePath(),e.fill(),e.restore()}hitTest(e,t,n,r,i,a,o){let s=n.xToPixel(this.points[0].barIndex,r,a),c=n.yToPixel(this.points[0].price,i,o);return Math.hypot(e-s,t-c)<=12}getHandle(){return null}},Ko=6;function qo(e,t,n,r,i,a){let o=i-n,s=a-r,c=o*o+s*s;if(c===0)return Math.hypot(e-n,t-r);let l=Math.max(0,Math.min(1,((e-n)*o+(t-r)*s)/c));return Math.hypot(e-(n+l*o),t-(r+l*s))}var Jo=class{constructor(e){this.type=`headShoulders`,this.requiredPoints=5,this.id=`hs_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let l=[`LS`,`H`,`RS`,`L1`,`L2`],u=this.points.map(e=>t.xToPixel(e.barIndex,n,i)),d=this.points.map(e=>t.yToPixel(e.price,r,a)),f=u.length,p=Y(`headShoulders`,this.style,c);e.save(),e.strokeStyle=p.strokeColor,e.lineWidth=o?p.lineWidth+.5:p.lineWidth,X(e,o?`solid`:p.lineStyle,e.lineWidth);let m=[0,3,1,4,2].filter(e=>e<f);if(m.length>=2){e.beginPath(),e.moveTo(u[m[0]],d[m[0]]);for(let t=1;t<m.length;t++)e.lineTo(u[m[t]],d[m[t]]);e.stroke()}e.setLineDash([]),this.complete&&f===5&&(e.beginPath(),e.moveTo(u[0],d[0]),e.lineTo(u[3],d[3]),e.lineTo(u[1],d[1]),e.lineTo(u[4],d[4]),e.lineTo(u[2],d[2]),e.closePath(),e.fillStyle=Z(p.fillColor,p.fillOpacity),e.fill()),f>=5&&(e.save(),e.setLineDash([5,4]),e.strokeStyle=p.strokeColor,e.lineWidth=o?p.lineWidth+.5:p.lineWidth,e.beginPath(),e.moveTo(u[3],d[3]),e.lineTo(u[4],d[4]),e.stroke(),e.restore()),e.font=`11px 'Inter', system-ui, sans-serif`,e.fillStyle=p.strokeColor;for(let t=0;t<f;t++){var h;e.beginPath(),e.arc(u[t],d[t],o?4:3,0,Math.PI*2),e.fill(),e.fillText((h=l[t])==null?String(t):h,u[t]+5,d[t]-5)}e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let s=this.points.map(e=>n.xToPixel(e.barIndex,r,a)),c=this.points.map(e=>n.yToPixel(e.price,i,o)),l=s.length,u=[0,3,1,4,2].filter(e=>e<l);for(let n=0;n<u.length-1;n++){let r=u[n],i=u[n+1];if(qo(e,t,s[r],c[r],s[i],c[i])<=Ko)return!0}return l>=5&&qo(e,t,s[3],c[3],s[4],c[4])<=Ko}getHandle(e,t,n,r,i,a,o){if(this.points.length!==this.requiredPoints)return null;for(let s=0;s<this.points.length;s++){let c=n.xToPixel(this.points[s].barIndex,r,a),l=n.yToPixel(this.points[s].price,i,o);if(Math.hypot(e-c,t-l)<=Ko+2)return{pointIndex:s,cursor:`grab`}}return null}},Yo=6;function Xo(e,t,n,r,i,a){let o=i-n,s=a-r,c=o*o+s*s;if(c===0)return Math.hypot(e-n,t-r);let l=Math.max(0,Math.min(1,((e-n)*o+(t-r)*s)/c));return Math.hypot(e-(n+l*o),t-(r+l*s))}var Zo=class{constructor(e){this.type=`trianglePattern`,this.requiredPoints=5,this.id=`tpat_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let l=[`1`,`2`,`3`,`4`,`5`],u=this.points.map(e=>t.xToPixel(e.barIndex,n,i)),d=this.points.map(e=>t.yToPixel(e.price,r,a)),f=u.length,p=Y(`trianglePattern`,this.style,c);e.save(),e.strokeStyle=p.strokeColor,e.lineWidth=o?p.lineWidth+.5:p.lineWidth,X(e,o?`solid`:p.lineStyle,e.lineWidth),e.beginPath(),e.moveTo(u[0],d[0]);for(let t=1;t<f;t++)e.lineTo(u[t],d[t]);e.stroke(),e.setLineDash([]),f>=3&&(e.save(),e.setLineDash([5,4]),e.strokeStyle=p.strokeColor,e.lineWidth=o?p.lineWidth+.5:p.lineWidth,e.beginPath(),e.moveTo(u[0],d[0]),e.lineTo(u[2],d[2]),f>=5&&e.lineTo(u[4],d[4]),e.stroke(),e.restore()),f>=4&&(e.save(),e.setLineDash([5,4]),e.strokeStyle=p.strokeColor,e.lineWidth=o?p.lineWidth+.5:p.lineWidth,e.beginPath(),e.moveTo(u[1],d[1]),e.lineTo(u[3],d[3]),e.stroke(),e.restore()),e.font=`11px 'Inter', system-ui, sans-serif`,e.fillStyle=p.strokeColor;for(let t=0;t<f;t++){var m;e.beginPath(),e.arc(u[t],d[t],o?4:3,0,Math.PI*2),e.fill(),e.fillText((m=l[t])==null?String(t+1):m,u[t]+5,d[t]-5)}e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let s=this.points.map(e=>n.xToPixel(e.barIndex,r,a)),c=this.points.map(e=>n.yToPixel(e.price,i,o)),l=s.length;for(let n=0;n<l-1;n++)if(Xo(e,t,s[n],c[n],s[n+1],c[n+1])<=Yo)return!0;return l>=3&&Xo(e,t,s[0],c[0],s[2],c[2])<=Yo||l>=5&&Xo(e,t,s[2],c[2],s[4],c[4])<=Yo||l>=4&&Xo(e,t,s[1],c[1],s[3],c[3])<=Yo}getHandle(e,t,n,r,i,a,o){if(this.points.length!==this.requiredPoints)return null;for(let s=0;s<this.points.length;s++){let c=n.xToPixel(this.points[s].barIndex,r,a),l=n.yToPixel(this.points[s].price,i,o);if(Math.hypot(e-c,t-l)<=Yo+2)return{pointIndex:s,cursor:`grab`}}return null}},Qo=6;function $o(e,t,n,r,i,a){let o=i-n,s=a-r,c=o*o+s*s;if(c===0)return Math.hypot(e-n,t-r);let l=Math.max(0,Math.min(1,((e-n)*o+(t-r)*s)/c));return Math.hypot(e-(n+l*o),t-(r+l*s))}var es=class{constructor(e){this.type=`threeDrives`,this.requiredPoints=7,this.id=`td_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let l=[`O`,`A`,`B`,`C`,`D`,`E`,`F`],u=this.points.map(e=>t.xToPixel(e.barIndex,n,i)),d=this.points.map(e=>t.yToPixel(e.price,r,a)),f=u.length,p=Y(`threeDrives`,this.style,c);e.save(),e.strokeStyle=p.strokeColor,e.lineWidth=o?p.lineWidth+.5:p.lineWidth,X(e,o?`solid`:p.lineStyle,e.lineWidth),e.beginPath(),e.moveTo(u[0],d[0]);for(let t=1;t<f;t++)e.lineTo(u[t],d[t]);if(e.stroke(),e.setLineDash([]),this.complete&&f===7){e.beginPath(),e.moveTo(u[0],d[0]);for(let t=1;t<f;t++)e.lineTo(u[t],d[t]);e.closePath(),e.fillStyle=Z(p.fillColor,p.fillOpacity),e.fill()}e.font=`11px 'Inter', system-ui, sans-serif`,e.fillStyle=p.strokeColor;for(let t=0;t<f;t++){var m;e.beginPath(),e.arc(u[t],d[t],o?4:3,0,Math.PI*2),e.fill(),e.fillText((m=l[t])==null?String(t):m,u[t]+5,d[t]-5)}e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let s=this.points.map(e=>n.xToPixel(e.barIndex,r,a)),c=this.points.map(e=>n.yToPixel(e.price,i,o)),l=s.length;for(let n=0;n<l-1;n++)if($o(e,t,s[n],c[n],s[n+1],c[n+1])<=Qo)return!0;return!1}getHandle(e,t,n,r,i,a,o){if(this.points.length!==this.requiredPoints)return null;for(let s=0;s<this.points.length;s++){let c=n.xToPixel(this.points[s].barIndex,r,a),l=n.yToPixel(this.points[s].price,i,o);if(Math.hypot(e-c,t-l)<=Qo+2)return{pointIndex:s,cursor:`grab`}}return null}},ts=6;function ns(e,t,n,r,i,a){let o=i-n,s=a-r,c=o*o+s*s;if(c===0)return Math.hypot(e-n,t-r);let l=Math.max(0,Math.min(1,((e-n)*o+(t-r)*s)/c));return Math.hypot(e-(n+l*o),t-(r+l*s))}var rs=class{constructor(e){this.type=`abcdPattern`,this.requiredPoints=4,this.id=`abcd_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let l=[`A`,`B`,`C`,`D`],u=this.points.map(e=>t.xToPixel(e.barIndex,n,i)),d=this.points.map(e=>t.yToPixel(e.price,r,a)),f=u.length,p=Y(`abcdPattern`,this.style,c);e.save(),e.strokeStyle=p.strokeColor,e.lineWidth=o?p.lineWidth+.5:p.lineWidth,X(e,o?`solid`:p.lineStyle,e.lineWidth),e.beginPath(),e.moveTo(u[0],d[0]);for(let t=1;t<f;t++)e.lineTo(u[t],d[t]);e.stroke(),e.setLineDash([]),f>=4&&(e.save(),e.setLineDash([3,4]),e.strokeStyle=p.strokeColor,e.lineWidth=o?p.lineWidth+.5:p.lineWidth,e.beginPath(),e.moveTo(u[0],d[0]),e.lineTo(u[3],d[3]),e.stroke(),e.restore()),e.font=`11px 'Inter', system-ui, sans-serif`,e.fillStyle=p.strokeColor;for(let t=0;t<f;t++){var m;e.beginPath(),e.arc(u[t],d[t],o?4:3,0,Math.PI*2),e.fill(),e.fillText((m=l[t])==null?String(t):m,u[t]+5,d[t]-5)}e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let s=this.points.map(e=>n.xToPixel(e.barIndex,r,a)),c=this.points.map(e=>n.yToPixel(e.price,i,o)),l=s.length;for(let n=0;n<l-1;n++)if(ns(e,t,s[n],c[n],s[n+1],c[n+1])<=ts)return!0;return l>=4&&ns(e,t,s[0],c[0],s[3],c[3])<=ts}getHandle(e,t,n,r,i,a,o){if(this.points.length!==this.requiredPoints)return null;for(let s=0;s<this.points.length;s++){let c=n.xToPixel(this.points[s].barIndex,r,a),l=n.yToPixel(this.points[s].price,i,o);if(Math.hypot(e-c,t-l)<=ts+2)return{pointIndex:s,cursor:`grab`}}return null}},is=6;function as(e,t,n,r,i,a){let o=i-n,s=a-r,c=o*o+s*s;if(c===0)return Math.hypot(e-n,t-r);let l=Math.max(0,Math.min(1,((e-n)*o+(t-r)*s)/c));return Math.hypot(e-(n+l*o),t-(r+l*s))}var os=class{constructor(e){this.type=`cypherPattern`,this.requiredPoints=5,this.id=`cyp_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let l=[`X`,`A`,`B`,`C`,`D`],u=this.points.map(e=>t.xToPixel(e.barIndex,n,i)),d=this.points.map(e=>t.yToPixel(e.price,r,a)),f=u.length,p=Y(`cypherPattern`,this.style,c);e.save(),e.strokeStyle=p.strokeColor,e.lineWidth=o?p.lineWidth+.5:p.lineWidth,X(e,o?`solid`:p.lineStyle,e.lineWidth),e.beginPath(),e.moveTo(u[0],d[0]);for(let t=1;t<f;t++)e.lineTo(u[t],d[t]);if(e.stroke(),e.setLineDash([]),this.complete&&f===5){e.beginPath(),e.moveTo(u[0],d[0]);for(let t=1;t<f;t++)e.lineTo(u[t],d[t]);e.closePath(),e.fillStyle=Z(p.fillColor,p.fillOpacity),e.fill()}e.font=`11px 'Inter', system-ui, sans-serif`,e.fillStyle=p.strokeColor;for(let t=0;t<f;t++){var m;e.beginPath(),e.arc(u[t],d[t],o?4:3,0,Math.PI*2),e.fill(),e.fillText((m=l[t])==null?String(t):m,u[t]+5,d[t]-5)}e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let s=this.points.map(e=>n.xToPixel(e.barIndex,r,a)),c=this.points.map(e=>n.yToPixel(e.price,i,o)),l=s.length;for(let n=0;n<l-1;n++)if(as(e,t,s[n],c[n],s[n+1],c[n+1])<=is)return!0;return!1}getHandle(e,t,n,r,i,a,o){if(this.points.length!==this.requiredPoints)return null;for(let s=0;s<this.points.length;s++){let c=n.xToPixel(this.points[s].barIndex,r,a),l=n.yToPixel(this.points[s].price,i,o);if(Math.hypot(e-c,t-l)<=is+2)return{pointIndex:s,cursor:`grab`}}return null}},ss=6;function cs(e,t,n,r,i,a){let o=i-n,s=a-r,c=o*o+s*s;if(c===0)return Math.hypot(e-n,t-r);let l=Math.max(0,Math.min(1,((e-n)*o+(t-r)*s)/c));return Math.hypot(e-(n+l*o),t-(r+l*s))}var ls=class{constructor(e){this.type=`butterflyPattern`,this.requiredPoints=5,this.id=`bfly_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let l=[`X`,`A`,`B`,`C`,`D`],u=this.points.map(e=>t.xToPixel(e.barIndex,n,i)),d=this.points.map(e=>t.yToPixel(e.price,r,a)),f=u.length,p=Y(`butterflyPattern`,this.style,c);e.save(),e.strokeStyle=p.strokeColor,e.lineWidth=o?p.lineWidth+.5:p.lineWidth,X(e,o?`solid`:p.lineStyle,e.lineWidth),e.beginPath(),e.moveTo(u[0],d[0]);for(let t=1;t<f;t++)e.lineTo(u[t],d[t]);e.stroke(),e.setLineDash([]),f>=5&&(e.save(),e.setLineDash([5,4]),e.strokeStyle=p.strokeColor,e.lineWidth=o?p.lineWidth+.5:p.lineWidth,e.beginPath(),e.moveTo(u[0],d[0]),e.lineTo(u[4],d[4]),e.stroke(),e.restore()),e.font=`11px 'Inter', system-ui, sans-serif`,e.fillStyle=p.strokeColor;for(let t=0;t<f;t++){var m;e.beginPath(),e.arc(u[t],d[t],o?4:3,0,Math.PI*2),e.fill(),e.fillText((m=l[t])==null?String(t):m,u[t]+5,d[t]-5)}e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let s=this.points.map(e=>n.xToPixel(e.barIndex,r,a)),c=this.points.map(e=>n.yToPixel(e.price,i,o)),l=s.length;for(let n=0;n<l-1;n++)if(cs(e,t,s[n],c[n],s[n+1],c[n+1])<=ss)return!0;return l>=5&&cs(e,t,s[0],c[0],s[4],c[4])<=ss}getHandle(e,t,n,r,i,a,o){if(this.points.length!==this.requiredPoints)return null;for(let s=0;s<this.points.length;s++){let c=n.xToPixel(this.points[s].barIndex,r,a),l=n.yToPixel(this.points[s].price,i,o);if(Math.hypot(e-c,t-l)<=ss+2)return{pointIndex:s,cursor:`grab`}}return null}},us=6;function ds(e,t,n,r,i,a){let o=i-n,s=a-r,c=o*o+s*s;if(c===0)return Math.hypot(e-n,t-r);let l=Math.max(0,Math.min(1,((e-n)*o+(t-r)*s)/c));return Math.hypot(e-(n+l*o),t-(r+l*s))}var fs=class{constructor(e){this.type=`batPattern`,this.requiredPoints=5,this.id=`bat_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let l=[`X`,`A`,`B`,`C`,`D`],u=this.points.map(e=>t.xToPixel(e.barIndex,n,i)),d=this.points.map(e=>t.yToPixel(e.price,r,a)),f=u.length,p=Y(`batPattern`,this.style,c);e.save(),e.strokeStyle=p.strokeColor,e.lineWidth=o?p.lineWidth+.5:p.lineWidth,X(e,o?`solid`:p.lineStyle,e.lineWidth),e.beginPath(),e.moveTo(u[0],d[0]);for(let t=1;t<f;t++)e.lineTo(u[t],d[t]);e.stroke(),e.setLineDash([]),f>=5&&(e.save(),e.setLineDash([5,4]),e.strokeStyle=p.strokeColor,e.lineWidth=o?p.lineWidth+.5:p.lineWidth,e.beginPath(),e.moveTo(u[0],d[0]),e.lineTo(u[4],d[4]),e.stroke(),e.restore()),e.font=`11px 'Inter', system-ui, sans-serif`,e.fillStyle=p.strokeColor;for(let t=0;t<f;t++){var m;e.beginPath(),e.arc(u[t],d[t],o?4:3,0,Math.PI*2),e.fill(),e.fillText((m=l[t])==null?String(t):m,u[t]+5,d[t]-5)}e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let s=this.points.map(e=>n.xToPixel(e.barIndex,r,a)),c=this.points.map(e=>n.yToPixel(e.price,i,o)),l=s.length;for(let n=0;n<l-1;n++)if(ds(e,t,s[n],c[n],s[n+1],c[n+1])<=us)return!0;return l>=5&&ds(e,t,s[0],c[0],s[4],c[4])<=us}getHandle(e,t,n,r,i,a,o){if(this.points.length!==this.requiredPoints)return null;for(let s=0;s<this.points.length;s++){let c=n.xToPixel(this.points[s].barIndex,r,a),l=n.yToPixel(this.points[s].price,i,o);if(Math.hypot(e-c,t-l)<=us+2)return{pointIndex:s,cursor:`grab`}}return null}},ps=6;function ms(e,t,n,r,i,a){let o=i-n,s=a-r,c=o*o+s*s;if(c===0)return Math.hypot(e-n,t-r);let l=Math.max(0,Math.min(1,((e-n)*o+(t-r)*s)/c));return Math.hypot(e-(n+l*o),t-(r+l*s))}var hs=class{constructor(e){this.type=`gartleyPattern`,this.requiredPoints=5,this.id=`gart_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let l=[`X`,`A`,`B`,`C`,`D`],u=this.points.map(e=>t.xToPixel(e.barIndex,n,i)),d=this.points.map(e=>t.yToPixel(e.price,r,a)),f=u.length,p=Y(`gartleyPattern`,this.style,c);e.save(),e.strokeStyle=p.strokeColor,e.lineWidth=o?p.lineWidth+.5:p.lineWidth,X(e,o?`solid`:p.lineStyle,e.lineWidth),e.beginPath(),e.moveTo(u[0],d[0]);for(let t=1;t<f;t++)e.lineTo(u[t],d[t]);e.stroke(),e.setLineDash([]),f>=5&&(e.save(),e.setLineDash([5,4]),e.strokeStyle=p.strokeColor,e.lineWidth=o?p.lineWidth+.5:p.lineWidth,e.beginPath(),e.moveTo(u[0],d[0]),e.lineTo(u[4],d[4]),e.stroke(),e.restore()),e.font=`11px 'Inter', system-ui, sans-serif`,e.fillStyle=p.strokeColor;for(let t=0;t<f;t++){var m;e.beginPath(),e.arc(u[t],d[t],o?4:3,0,Math.PI*2),e.fill(),e.fillText((m=l[t])==null?String(t):m,u[t]+5,d[t]-5)}e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let s=this.points.map(e=>n.xToPixel(e.barIndex,r,a)),c=this.points.map(e=>n.yToPixel(e.price,i,o)),l=s.length;for(let n=0;n<l-1;n++)if(ms(e,t,s[n],c[n],s[n+1],c[n+1])<=ps)return!0;return l>=5&&ms(e,t,s[0],c[0],s[4],c[4])<=ps}getHandle(e,t,n,r,i,a,o){if(this.points.length!==this.requiredPoints)return null;for(let s=0;s<this.points.length;s++){let c=n.xToPixel(this.points[s].barIndex,r,a),l=n.yToPixel(this.points[s].price,i,o);if(Math.hypot(e-c,t-l)<=ps+2)return{pointIndex:s,cursor:`grab`}}return null}},gs=6;function _s(e,t,n,r,i,a){let o=i-n,s=a-r,c=o*o+s*s;if(c===0)return Math.hypot(e-n,t-r);let l=Math.max(0,Math.min(1,((e-n)*o+(t-r)*s)/c));return Math.hypot(e-(n+l*o),t-(r+l*s))}var vs=class{constructor(e){this.type=`crabPattern`,this.requiredPoints=5,this.id=`crab_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let l=[`X`,`A`,`B`,`C`,`D`],u=this.points.map(e=>t.xToPixel(e.barIndex,n,i)),d=this.points.map(e=>t.yToPixel(e.price,r,a)),f=u.length,p=Y(`crabPattern`,this.style,c);e.save(),e.strokeStyle=p.strokeColor,e.lineWidth=o?p.lineWidth+.5:p.lineWidth,X(e,o?`solid`:p.lineStyle,e.lineWidth),e.beginPath(),e.moveTo(u[0],d[0]);for(let t=1;t<f;t++)e.lineTo(u[t],d[t]);e.stroke(),e.setLineDash([]),f>=5&&(e.save(),e.setLineDash([5,4]),e.strokeStyle=p.strokeColor,e.lineWidth=o?p.lineWidth+.5:p.lineWidth,e.beginPath(),e.moveTo(u[0],d[0]),e.lineTo(u[4],d[4]),e.stroke(),e.restore()),e.font=`11px 'Inter', system-ui, sans-serif`,e.fillStyle=p.strokeColor;for(let t=0;t<f;t++){var m;e.beginPath(),e.arc(u[t],d[t],o?4:3,0,Math.PI*2),e.fill(),e.fillText((m=l[t])==null?String(t):m,u[t]+5,d[t]-5)}e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let s=this.points.map(e=>n.xToPixel(e.barIndex,r,a)),c=this.points.map(e=>n.yToPixel(e.price,i,o)),l=s.length;for(let n=0;n<l-1;n++)if(_s(e,t,s[n],c[n],s[n+1],c[n+1])<=gs)return!0;return l>=5&&_s(e,t,s[0],c[0],s[4],c[4])<=gs}getHandle(e,t,n,r,i,a,o){if(this.points.length!==this.requiredPoints)return null;for(let s=0;s<this.points.length;s++){let c=n.xToPixel(this.points[s].barIndex,r,a),l=n.yToPixel(this.points[s].price,i,o);if(Math.hypot(e-c,t-l)<=gs+2)return{pointIndex:s,cursor:`grab`}}return null}},ys=6;function bs(e,t,n,r,i,a){let o=i-n,s=a-r,c=o*o+s*s;if(c===0)return Math.hypot(e-n,t-r);let l=Math.max(0,Math.min(1,((e-n)*o+(t-r)*s)/c));return Math.hypot(e-(n+l*o),t-(r+l*s))}var xs=class{constructor(e){this.type=`sharkPattern`,this.requiredPoints=5,this.id=`shrk_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let l=[`X`,`A`,`B`,`C`,`D`],u=this.points.map(e=>t.xToPixel(e.barIndex,n,i)),d=this.points.map(e=>t.yToPixel(e.price,r,a)),f=u.length,p=Y(`sharkPattern`,this.style,c);e.save(),e.strokeStyle=p.strokeColor,e.lineWidth=o?p.lineWidth+.5:p.lineWidth,X(e,o?`solid`:p.lineStyle,e.lineWidth),e.beginPath(),e.moveTo(u[0],d[0]);for(let t=1;t<f;t++)e.lineTo(u[t],d[t]);e.stroke(),e.setLineDash([]),f>=5&&(e.save(),e.setLineDash([5,4]),e.strokeStyle=p.strokeColor,e.lineWidth=o?p.lineWidth+.5:p.lineWidth,e.beginPath(),e.moveTo(u[0],d[0]),e.lineTo(u[4],d[4]),e.stroke(),e.restore()),e.font=`11px 'Inter', system-ui, sans-serif`,e.fillStyle=p.strokeColor;for(let t=0;t<f;t++){var m;e.beginPath(),e.arc(u[t],d[t],o?4:3,0,Math.PI*2),e.fill(),e.fillText((m=l[t])==null?String(t):m,u[t]+5,d[t]-5)}e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let s=this.points.map(e=>n.xToPixel(e.barIndex,r,a)),c=this.points.map(e=>n.yToPixel(e.price,i,o)),l=s.length;for(let n=0;n<l-1;n++)if(bs(e,t,s[n],c[n],s[n+1],c[n+1])<=ys)return!0;return l>=5&&bs(e,t,s[0],c[0],s[4],c[4])<=ys}getHandle(e,t,n,r,i,a,o){if(this.points.length!==this.requiredPoints)return null;for(let s=0;s<this.points.length;s++){let c=n.xToPixel(this.points[s].barIndex,r,a),l=n.yToPixel(this.points[s].price,i,o);if(Math.hypot(e-c,t-l)<=ys+2)return{pointIndex:s,cursor:`grab`}}return null}},Ss=6;function Cs(e,t,n,r,i,a){let o=i-n,s=a-r,c=o*o+s*s;if(c===0)return Math.hypot(e-n,t-r);let l=Math.max(0,Math.min(1,((e-n)*o+(t-r)*s)/c));return Math.hypot(e-(n+l*o),t-(r+l*s))}var ws=[`0`,`1`,`2`,`3`,`4`,`5`],Ts=class{constructor(e){this.type=`elliottImpulse`,this.requiredPoints=6,this.id=`eimp_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let l=this.points.map(e=>t.xToPixel(e.barIndex,n,i)),u=this.points.map(e=>t.yToPixel(e.price,r,a)),d=l.length,f=Y(`elliottImpulse`,this.style,c);e.save(),e.lineWidth=o?f.lineWidth+.5:f.lineWidth,X(e,o?`solid`:f.lineStyle,e.lineWidth);for(let t=0;t<d-1;t++)e.strokeStyle=t%2==0?f.strokeColor:Z(f.strokeColor,.67),e.beginPath(),e.moveTo(l[t],u[t]),e.lineTo(l[t+1],u[t+1]),e.stroke();e.setLineDash([]),e.font=`11px 'Inter', system-ui, sans-serif`;for(let t=0;t<d;t++){var p;e.beginPath(),e.arc(l[t],u[t],o?4:3,0,Math.PI*2),e.fillStyle=f.strokeColor,e.fill(),e.fillStyle=f.strokeColor,e.fillText((p=ws[t])==null?String(t):p,l[t]+5,u[t]-5)}e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let s=this.points.map(e=>n.xToPixel(e.barIndex,r,a)),c=this.points.map(e=>n.yToPixel(e.price,i,o));for(let n=0;n<s.length-1;n++)if(Cs(e,t,s[n],c[n],s[n+1],c[n+1])<=Ss)return!0;return!1}getHandle(e,t,n,r,i,a,o){if(!this.complete)return null;for(let s=0;s<this.points.length;s++){let c=n.xToPixel(this.points[s].barIndex,r,a),l=n.yToPixel(this.points[s].price,i,o);if(Math.hypot(e-c,t-l)<=Ss+2)return{pointIndex:s,cursor:`grab`}}return null}},Es=6;function Ds(e,t,n,r,i,a){let o=i-n,s=a-r,c=o*o+s*s;if(c===0)return Math.hypot(e-n,t-r);let l=Math.max(0,Math.min(1,((e-n)*o+(t-r)*s)/c));return Math.hypot(e-(n+l*o),t-(r+l*s))}var Os=[`0`,`A`,`B`,`C`],ks=class{constructor(e){this.type=`elliottCorrective`,this.requiredPoints=4,this.id=`ecor_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let l=this.points.map(e=>t.xToPixel(e.barIndex,n,i)),u=this.points.map(e=>t.yToPixel(e.price,r,a)),d=Y(`elliottCorrective`,this.style,c);e.save(),e.strokeStyle=d.strokeColor,e.lineWidth=o?d.lineWidth+.5:d.lineWidth,X(e,o?`solid`:d.lineStyle,e.lineWidth),e.beginPath(),e.moveTo(l[0],u[0]);for(let t=1;t<l.length;t++)e.lineTo(l[t],u[t]);e.stroke(),e.setLineDash([]),e.font=`11px 'Inter', system-ui, sans-serif`;for(let t=0;t<l.length;t++){var f;e.beginPath(),e.arc(l[t],u[t],o?4:3,0,Math.PI*2),e.fillStyle=d.strokeColor,e.fill(),e.fillStyle=d.strokeColor,e.fillText((f=Os[t])==null?String(t):f,l[t]+5,u[t]-5)}e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let s=this.points.map(e=>n.xToPixel(e.barIndex,r,a)),c=this.points.map(e=>n.yToPixel(e.price,i,o));for(let n=0;n<s.length-1;n++)if(Ds(e,t,s[n],c[n],s[n+1],c[n+1])<=Es)return!0;return!1}getHandle(e,t,n,r,i,a,o){if(!this.complete)return null;for(let s=0;s<this.points.length;s++){let c=n.xToPixel(this.points[s].barIndex,r,a),l=n.yToPixel(this.points[s].price,i,o);if(Math.hypot(e-c,t-l)<=Es+2)return{pointIndex:s,cursor:`grab`}}return null}},As=6;function js(e,t,n,r,i,a){let o=i-n,s=a-r,c=o*o+s*s;if(c===0)return Math.hypot(e-n,t-r);let l=Math.max(0,Math.min(1,((e-n)*o+(t-r)*s)/c));return Math.hypot(e-(n+l*o),t-(r+l*s))}var Ms=[`A`,`B`,`C`,`D`,`E`,`end`],Ns=class{constructor(e){this.type=`elliottTriangle`,this.requiredPoints=6,this.id=`etri_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let l=this.points.map(e=>t.xToPixel(e.barIndex,n,i)),u=this.points.map(e=>t.yToPixel(e.price,r,a)),d=l.length,f=Y(`elliottTriangle`,this.style,c);e.save(),e.strokeStyle=f.strokeColor,e.lineWidth=o?f.lineWidth+.5:f.lineWidth,X(e,o?`solid`:f.lineStyle,e.lineWidth),e.beginPath(),e.moveTo(l[0],u[0]);for(let t=1;t<d;t++)e.lineTo(l[t],u[t]);e.stroke(),e.setLineDash([]),d>=3&&(e.save(),e.setLineDash([5,4]),e.strokeStyle=Z(f.strokeColor,.67),e.lineWidth=f.lineWidth,e.beginPath(),e.moveTo(l[0],u[0]),d>2&&e.lineTo(l[2],u[2]),d>4&&e.lineTo(l[4],u[4]),e.stroke(),e.restore()),d>=4&&(e.save(),e.setLineDash([5,4]),e.strokeStyle=Z(f.strokeColor,.67),e.lineWidth=f.lineWidth,e.beginPath(),e.moveTo(l[1],u[1]),e.lineTo(l[3],u[3]),e.stroke(),e.restore()),e.font=`11px 'Inter', system-ui, sans-serif`;for(let t=0;t<d;t++){var p;e.beginPath(),e.arc(l[t],u[t],o?4:3,0,Math.PI*2),e.fillStyle=f.strokeColor,e.fill(),e.fillStyle=f.strokeColor,e.fillText((p=Ms[t])==null?String(t):p,l[t]+5,u[t]-5)}e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let s=this.points.map(e=>n.xToPixel(e.barIndex,r,a)),c=this.points.map(e=>n.yToPixel(e.price,i,o));for(let n=0;n<s.length-1;n++)if(js(e,t,s[n],c[n],s[n+1],c[n+1])<=As)return!0;return!1}getHandle(e,t,n,r,i,a,o){if(!this.complete)return null;for(let s=0;s<this.points.length;s++){let c=n.xToPixel(this.points[s].barIndex,r,a),l=n.yToPixel(this.points[s].price,i,o);if(Math.hypot(e-c,t-l)<=As+2)return{pointIndex:s,cursor:`grab`}}return null}},Ps=6;function Fs(e,t,n,r,i,a){let o=i-n,s=a-r,c=o*o+s*s;if(c===0)return Math.hypot(e-n,t-r);let l=Math.max(0,Math.min(1,((e-n)*o+(t-r)*s)/c));return Math.hypot(e-(n+l*o),t-(r+l*s))}var Is=[`W`,`X`,`Y`,`X2`,`Z`,`X3`,`end`],Ls=class{constructor(e){this.type=`elliottCombination`,this.requiredPoints=7,this.id=`ecom_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let l=this.points.map(e=>t.xToPixel(e.barIndex,n,i)),u=this.points.map(e=>t.yToPixel(e.price,r,a)),d=Y(`elliottCombination`,this.style,c);e.save(),e.strokeStyle=d.strokeColor,e.lineWidth=o?d.lineWidth+.5:d.lineWidth,X(e,o?`solid`:d.lineStyle,e.lineWidth),e.beginPath(),e.moveTo(l[0],u[0]);for(let t=1;t<l.length;t++)e.lineTo(l[t],u[t]);e.stroke(),e.setLineDash([]),e.font=`11px 'Inter', system-ui, sans-serif`;for(let t=0;t<l.length;t++){var f;e.beginPath(),e.arc(l[t],u[t],o?4:3,0,Math.PI*2),e.fillStyle=d.strokeColor,e.fill(),e.fillStyle=d.strokeColor,e.fillText((f=Is[t])==null?String(t):f,l[t]+5,u[t]-5)}e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let s=this.points.map(e=>n.xToPixel(e.barIndex,r,a)),c=this.points.map(e=>n.yToPixel(e.price,i,o));for(let n=0;n<s.length-1;n++)if(Fs(e,t,s[n],c[n],s[n+1],c[n+1])<=Ps)return!0;return!1}getHandle(e,t,n,r,i,a,o){if(!this.complete)return null;for(let s=0;s<this.points.length;s++){let c=n.xToPixel(this.points[s].barIndex,r,a),l=n.yToPixel(this.points[s].price,i,o);if(Math.hypot(e-c,t-l)<=Ps+2)return{pointIndex:s,cursor:`grab`}}return null}},Rs=6;function zs(e,t,n,r,i,a){let o=i-n,s=a-r,c=o*o+s*s;if(c===0)return Math.hypot(e-n,t-r);let l=Math.max(0,Math.min(1,((e-n)*o+(t-r)*s)/c));return Math.hypot(e-(n+l*o),t-(r+l*s))}var Bs=[`W`,`X`,`Y`,`end`],Vs=class{constructor(e){this.type=`elliottWxy`,this.requiredPoints=4,this.id=`ewxy_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let l=this.points.map(e=>t.xToPixel(e.barIndex,n,i)),u=this.points.map(e=>t.yToPixel(e.price,r,a)),d=Y(`elliottWxy`,this.style,c);e.save(),e.strokeStyle=d.strokeColor,e.lineWidth=o?d.lineWidth+.5:d.lineWidth,X(e,o?`solid`:d.lineStyle,e.lineWidth),e.beginPath(),e.moveTo(l[0],u[0]);for(let t=1;t<l.length;t++)e.lineTo(l[t],u[t]);e.stroke(),e.setLineDash([]),e.font=`11px 'Inter', system-ui, sans-serif`;for(let t=0;t<l.length;t++){var f;e.beginPath(),e.arc(l[t],u[t],o?4:3,0,Math.PI*2),e.fillStyle=d.strokeColor,e.fill(),e.fillStyle=d.strokeColor,e.fillText((f=Bs[t])==null?String(t):f,l[t]+5,u[t]-5)}e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let s=this.points.map(e=>n.xToPixel(e.barIndex,r,a)),c=this.points.map(e=>n.yToPixel(e.price,i,o));for(let n=0;n<s.length-1;n++)if(zs(e,t,s[n],c[n],s[n+1],c[n+1])<=Rs)return!0;return!1}getHandle(e,t,n,r,i,a,o){if(!this.complete)return null;for(let s=0;s<this.points.length;s++){let c=n.xToPixel(this.points[s].barIndex,r,a),l=n.yToPixel(this.points[s].price,i,o);if(Math.hypot(e-c,t-l)<=Rs+2)return{pointIndex:s,cursor:`grab`}}return null}},Hs=8;function Us(e,t,n,r,i,a){let o=i-n,s=a-r,c=o*o+s*s;if(c===0)return Math.hypot(e-n,t-r);let l=Math.max(0,Math.min(1,((e-n)*o+(t-r)*s)/c));return Math.hypot(e-(n+l*o),t-(r+l*s))}var Ws=class{constructor(e){this.type=`brush`,this.openEnded=!0,this.id=`brush_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let l=this.points.map(e=>({x:t.xToPixel(e.barIndex,n,i),y:t.yToPixel(e.price,r,a)})),u=this.complete?l.length:l.length-1,d=Y(`brush`,this.style,c);if(e.save(),e.strokeStyle=d.strokeColor,e.lineWidth=o?d.lineWidth+.5:d.lineWidth,e.lineCap=`round`,e.lineJoin=`round`,u>=2){e.setLineDash([]),e.beginPath(),e.moveTo(l[0].x,l[0].y);for(let t=1;t<u;t++)e.lineTo(l[t].x,l[t].y);e.stroke()}if(!this.complete&&l.length>=2){let t=l.length-1;e.setLineDash([4,4]),e.beginPath(),e.moveTo(l[t-1].x,l[t-1].y),e.lineTo(l[t].x,l[t].y),e.stroke(),e.setLineDash([])}e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let s=this.points.map(e=>({x:n.xToPixel(e.barIndex,r,a),y:n.yToPixel(e.price,i,o)})),c=this.complete?s.length-1:s.length-2;for(let n=0;n<c;n++)if(Us(e,t,s[n].x,s[n].y,s[n+1].x,s[n+1].y)<=Hs)return!0;return!1}getHandle(e,t,n,r,i,a,o){if(this.points.length===0)return null;let s=[0,this.points.length-1];for(let c of s){let s=n.xToPixel(this.points[c].barIndex,r,a),l=n.yToPixel(this.points[c].price,i,o);if(Math.hypot(e-s,t-l)<=Hs+2)return{pointIndex:c,cursor:`grab`}}return null}},Gs=12;function Ks(e,t,n,r,i,a){let o=i-n,s=a-r,c=o*o+s*s;if(c===0)return Math.hypot(e-n,t-r);let l=Math.max(0,Math.min(1,((e-n)*o+(t-r)*s)/c));return Math.hypot(e-(n+l*o),t-(r+l*s))}var qs=class{constructor(e){this.type=`highlighter`,this.openEnded=!0,this.id=`hl2_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let l=this.points.map(e=>({x:t.xToPixel(e.barIndex,n,i),y:t.yToPixel(e.price,r,a)})),u=this.complete?l.length:l.length-1,d=Y(`highlighter`,this.style,c);if(e.save(),e.strokeStyle=Z(d.strokeColor,d.fillOpacity),e.lineWidth=o?d.lineWidth+.5:d.lineWidth,e.lineCap=`round`,e.lineJoin=`round`,u>=2){e.setLineDash([]),e.beginPath(),e.moveTo(l[0].x,l[0].y);for(let t=1;t<u;t++)e.lineTo(l[t].x,l[t].y);e.stroke()}if(!this.complete&&l.length>=2){let t=l.length-1;e.setLineDash([8,6]),e.beginPath(),e.moveTo(l[t-1].x,l[t-1].y),e.lineTo(l[t].x,l[t].y),e.stroke(),e.setLineDash([])}e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let s=this.points.map(e=>({x:n.xToPixel(e.barIndex,r,a),y:n.yToPixel(e.price,i,o)})),c=this.complete?s.length-1:s.length-2;for(let n=0;n<c;n++)if(Ks(e,t,s[n].x,s[n].y,s[n+1].x,s[n+1].y)<=Gs)return!0;return!1}getHandle(e,t,n,r,i,a,o){if(this.points.length===0)return null;let s=[0,this.points.length-1];for(let c of s){let s=n.xToPixel(this.points[c].barIndex,r,a),l=n.yToPixel(this.points[c].price,i,o);if(Math.hypot(e-s,t-l)<=Gs+2)return{pointIndex:c,cursor:`grab`}}return null}},Js=6,Ys=class{constructor(e){this.type=`sineLine`,this.id=`sine_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let[l,u]=this.points,d=t.xToPixel(l.barIndex,n,i),f=t.yToPixel(l.price,r,a),p=t.xToPixel(u.barIndex,n,i),m=t.yToPixel(u.price,r,a),h=p-d,g=Math.abs(m-f)/2,_=(f+m)/2,v=Y(`sineLine`,this.style,c);if(e.save(),e.strokeStyle=v.strokeColor,e.lineWidth=o?v.lineWidth+.5:v.lineWidth,X(e,o?`solid`:v.lineStyle,e.lineWidth),e.beginPath(),Math.abs(h)<1)e.moveTo(d,f),e.lineTo(p,m);else{e.moveTo(d,_+g*Math.sin(0));let t=h>0?1:-1,n=p;for(let r=d+t;h>0?r<=n:r>=n;r+=t){let t=(r-d)/h,n=_+g*Math.sin(2*Math.PI*t);e.lineTo(r,n)}e.lineTo(p,_+g*Math.sin(2*Math.PI))}e.stroke(),e.setLineDash([]),e.fillStyle=v.strokeColor;for(let[t,n]of[[d,f],[p,m]])e.beginPath(),e.arc(t,n,o?4:3,0,Math.PI*2),e.fill();e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let[s,c]=this.points,l=n.xToPixel(s.barIndex,r,a),u=n.yToPixel(s.price,i,o),d=n.xToPixel(c.barIndex,r,a),f=n.yToPixel(c.price,i,o),p=d-l,m=Math.abs(f-u)/2,h=(u+f)/2;if(Math.abs(p)<1)return Math.hypot(e-l,t-h)<=Js;let g=p>0?5:-5,_=l,v=h+m*Math.sin(0);for(let n=l+g;p>0?n<=d+Math.abs(g):n>=d-Math.abs(g);n+=g){let r=p>0?Math.min(n,d):Math.max(n,d),i=(r-l)/p,a=h+m*Math.sin(2*Math.PI*i);if(Math.hypot(e-r,t-a)<=Js)return!0;let o=r-_,s=a-v,c=o*o+s*s;if(c>0){let n=Math.max(0,Math.min(1,((e-_)*o+(t-v)*s)/c)),r=_+n*o,i=v+n*s;if(Math.hypot(e-r,t-i)<=Js)return!0}if(_=r,v=a,r===d)break}return!1}getHandle(e,t,n,r,i,a,o){let s=[{px:n.xToPixel(this.points[0].barIndex,r,a),py:n.yToPixel(this.points[0].price,i,o)},{px:n.xToPixel(this.points[1].barIndex,r,a),py:n.yToPixel(this.points[1].price,i,o)}];for(let n=0;n<s.length;n++)if(Math.hypot(e-s[n].px,t-s[n].py)<=Js+2)return{pointIndex:n,cursor:`grab`};return null}},Xs=6,Zs=class{constructor(e){this.type=`cyclicLines`,this.id=`cyc_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let[l,u]=this.points,d=Math.abs(u.barIndex-l.barIndex);if(d===0)return;let f=t.xToPixel(l.barIndex,n,i),p=Y(`cyclicLines`,this.style,c);e.save(),e.strokeStyle=p.strokeColor,e.lineWidth=o?p.lineWidth+.5:p.lineWidth,X(e,o?`solid`:p.lineStyle,e.lineWidth);for(let r=0;r<=8;r++){let o=l.barIndex+d*r,s=t.xToPixel(o,n,i);if(s>i)break;e.beginPath(),e.moveTo(s,0),e.lineTo(s,a),e.stroke()}e.setLineDash([]);let m=t.xToPixel(u.barIndex,n,i);e.fillStyle=p.strokeColor,e.beginPath(),e.arc(f,a/2,o?4:3,0,Math.PI*2),e.fill(),e.beginPath(),e.arc(m,a/2,o?4:3,0,Math.PI*2),e.fill(),e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let[s,c]=this.points,l=Math.abs(c.barIndex-s.barIndex);if(l===0)return!1;for(let t=0;t<=8;t++){let i=s.barIndex+l*t,o=n.xToPixel(i,r,a);if(o>a)break;if(Math.abs(e-o)<=Xs)return!0}return!1}getHandle(e,t,n,r,i,a,o){if(this.points.length<2)return null;let s=[{px:n.xToPixel(this.points[0].barIndex,r,a),py:o/2},{px:n.xToPixel(this.points[1].barIndex,r,a),py:o/2}],c=[`move`,`ew-resize`];for(let n=0;n<s.length;n++)if(Math.hypot(e-s[n].px,t-s[n].py)<=Xs+2)return{pointIndex:n,cursor:c[n]};return null}},Qs=6,$s=class{constructor(e){this.type=`timeCycles`,this.id=`tcy_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let[l,u]=this.points,d=Math.abs(u.barIndex-l.barIndex);if(d===0)return;let f=Y(`timeCycles`,this.style,c),p=Z(f.fillColor,f.fillOpacity);e.save(),e.font=`10px 'Inter', system-ui, sans-serif`,e.lineWidth=o?f.lineWidth+.5:f.lineWidth;let m=[];for(let e=0;e<=6;e++){let r=l.barIndex+d*e,a=t.xToPixel(r,n,i);if(a>i)break;m.push(a)}for(let t=0;t+1<m.length;t++)t%2==0&&(e.fillStyle=p,e.fillRect(m[t],0,m[t+1]-m[t],a));e.strokeStyle=f.strokeColor,X(e,o?`solid`:f.lineStyle,e.lineWidth);for(let t=0;t<m.length;t++)e.beginPath(),e.moveTo(m[t],0),e.lineTo(m[t],a),e.stroke(),e.fillStyle=f.strokeColor,e.fillText(String(t+1),m[t]+3,14);e.setLineDash([]);let h=t.xToPixel(l.barIndex,n,i),g=t.xToPixel(u.barIndex,n,i);e.fillStyle=f.strokeColor,e.beginPath(),e.arc(h,a/2,o?4:3,0,Math.PI*2),e.fill(),e.beginPath(),e.arc(g,a/2,o?4:3,0,Math.PI*2),e.fill(),e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let[s,c]=this.points,l=Math.abs(c.barIndex-s.barIndex);if(l===0)return!1;for(let t=0;t<=6;t++){let i=s.barIndex+l*t,o=n.xToPixel(i,r,a);if(o>a)break;if(Math.abs(e-o)<=Qs)return!0;if(t<6){let i=s.barIndex+l*(t+1),c=n.xToPixel(i,r,a);if(e>=o&&e<=c)return!0}}return!1}getHandle(e,t,n,r,i,a,o){if(this.points.length<2)return null;let s=[{px:n.xToPixel(this.points[0].barIndex,r,a),py:o/2},{px:n.xToPixel(this.points[1].barIndex,r,a),py:o/2}],c=[`move`,`ew-resize`];for(let n=0;n<s.length;n++)if(Math.hypot(e-s[n].px,t-s[n].py)<=Qs+2)return{pointIndex:n,cursor:c[n]};return null}},ec=6;function tc(e,t,n,r,i,a){let o=i-n,s=a-r,c=o*o+s*s;if(c===0)return Math.hypot(e-n,t-r);let l=Math.max(0,Math.min(1,((e-n)*o+(t-r)*s)/c));return Math.hypot(e-(n+l*o),t-(r+l*s))}var nc=class{constructor(e){this.type=`projection`,this.id=`proj_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let[l,u]=this.points,d=t.xToPixel(l.barIndex,n,i),f=t.yToPixel(l.price,r,a),p=t.xToPixel(u.barIndex,n,i),m=t.yToPixel(u.price,r,a),h=Y(`projection`,this.style,c),g=p-d,_,v;if(Math.abs(g)<.001)_=p,v=m+(m-f);else{let e=(m-f)/g;_=i,v=m+e*(i-p)}e.save(),e.strokeStyle=h.strokeColor,e.fillStyle=h.strokeColor,e.lineWidth=o?h.lineWidth+.5:h.lineWidth,e.setLineDash([]),e.beginPath(),e.moveTo(d,f),e.lineTo(p,m),e.stroke(),X(e,h.lineStyle===`solid`?`dashed`:h.lineStyle,e.lineWidth),e.beginPath(),e.moveTo(p,m),e.lineTo(_,v),e.stroke(),e.setLineDash([]),e.beginPath(),e.arc(d,f,o?4:3,0,Math.PI*2),e.fill(),e.beginPath(),e.arc(p,m,o?4:3,0,Math.PI*2),e.fill(),e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let[s,c]=this.points,l=n.xToPixel(s.barIndex,r,a),u=n.yToPixel(s.price,i,o),d=n.xToPixel(c.barIndex,r,a),f=n.yToPixel(c.price,i,o),p=d-l,m,h;if(Math.abs(p)<.001)m=d,h=f+(f-u);else{let e=(f-u)/p;m=a,h=f+e*(a-d)}return tc(e,t,l,u,d,f)<=ec||tc(e,t,d,f,m,h)<=ec}getHandle(e,t,n,r,i,a,o){if(this.points.length<2)return null;let s=[{px:n.xToPixel(this.points[0].barIndex,r,a),py:n.yToPixel(this.points[0].price,i,o)},{px:n.xToPixel(this.points[1].barIndex,r,a),py:n.yToPixel(this.points[1].price,i,o)}];for(let n=0;n<s.length;n++)if(Math.hypot(e-s[n].px,t-s[n].py)<=ec+2)return{pointIndex:n,cursor:`grab`};return null}},rc=6;function ic(e,t,n,r,i,a=7){let o=Math.atan2(i-n,r-t);e.beginPath(),e.moveTo(r,i),e.lineTo(r-a*Math.cos(o-Math.PI/6),i-a*Math.sin(o-Math.PI/6)),e.lineTo(r-a*Math.cos(o+Math.PI/6),i-a*Math.sin(o+Math.PI/6)),e.closePath(),e.fill()}var ac=class{constructor(e){this.type=`priceProjection`,this.id=`pp_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s=2,c){if(this.points.length<2)return;let[l,u]=this.points,d=t.xToPixel(l.barIndex,n,i),f=t.yToPixel(l.price,r,a),p=t.xToPixel(u.barIndex,n,i),m=t.yToPixel(u.price,r,a),h=Math.min(d,p),g=Math.max(d,p),_=Math.min(f,m),v=Math.max(f,m),y=g-h,b=v-_,x=h+y/2,S=(l.price+u.price)/2,C=Y(`priceProjection`,this.style,c);e.save(),e.font=`10px 'Inter', system-ui, sans-serif`,e.lineWidth=o?C.lineWidth+.5:C.lineWidth,e.fillStyle=Z(C.fillColor,C.fillOpacity),e.fillRect(h,_,y,b),e.strokeStyle=C.strokeColor,X(e,o?`solid`:C.lineStyle,e.lineWidth),e.beginPath(),e.moveTo(h,f),e.lineTo(g,f),e.stroke();let w=t.yToPixel(S,r,a);e.beginPath(),e.moveTo(h,w),e.lineTo(g,w),e.stroke(),e.beginPath(),e.moveTo(h,m),e.lineTo(g,m),e.stroke(),e.setLineDash([]),e.fillStyle=C.strokeColor,e.fillText(l.price.toFixed(s),g+4,f+4),e.fillText(S.toFixed(s),g+4,w+4),e.fillText(u.price.toFixed(s),g+4,m+4),e.fillStyle=C.strokeColor,e.beginPath(),e.moveTo(x,_),e.lineTo(x,v),e.stroke(),ic(e,x,v,x,_),ic(e,x,_,x,v),e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let[s,c]=this.points,l=n.xToPixel(s.barIndex,r,a),u=n.yToPixel(s.price,i,o),d=n.xToPixel(c.barIndex,r,a),f=n.yToPixel(c.price,i,o);return e>=Math.min(l,d)&&e<=Math.max(l,d)&&t>=Math.min(u,f)&&t<=Math.max(u,f)}getHandle(e,t,n,r,i,a,o){if(this.points.length<2)return null;let s=[{px:n.xToPixel(this.points[0].barIndex,r,a),py:n.yToPixel(this.points[0].price,i,o)},{px:n.xToPixel(this.points[1].barIndex,r,a),py:n.yToPixel(this.points[1].price,i,o)}];for(let n=0;n<s.length;n++)if(Math.hypot(e-s[n].px,t-s[n].py)<=rc+2)return{pointIndex:n,cursor:`ns-resize`};return null}},oc=6,sc=class{constructor(e){this.type=`ghostFeed`,this.id=`gfeed_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let[l,u]=this.points,d=t.xToPixel(l.barIndex,n,i),f=t.yToPixel(l.price,r,a),p=t.xToPixel(u.barIndex,n,i),m=t.yToPixel(u.price,r,a),h=Math.min(d,p),g=Math.min(f,m),_=Math.abs(p-d),v=Math.abs(m-f),y=Y(`ghostFeed`,this.style,c);e.save(),e.fillStyle=Z(y.fillColor,y.fillOpacity),e.fillRect(h,g,_,v),e.strokeStyle=y.strokeColor,e.lineWidth=o?y.lineWidth+.5:y.lineWidth,X(e,o?`solid`:y.lineStyle,e.lineWidth),e.strokeRect(h,g,_,v),e.setLineDash([]),e.save(),e.beginPath(),e.rect(h,g,_,v),e.clip(),e.strokeStyle=Z(y.strokeColor,.19),e.lineWidth=1,e.setLineDash([4,4]);let b=_+v;for(let t=-v;t<=b;t+=20){let n=h+t,r=g,i=h+t+v,a=g+v;e.beginPath(),e.moveTo(n,r),e.lineTo(i,a),e.stroke()}if(e.setLineDash([]),e.restore(),e.font=`12px 'Inter', system-ui, sans-serif`,e.fillStyle=y.strokeColor,e.textAlign=`center`,e.textBaseline=`middle`,e.fillText(`Ghost Feed`,h+_/2,g+v/2),o){e.textAlign=`left`,e.textBaseline=`alphabetic`;for(let[t,n]of[[d,f],[p,m]])e.beginPath(),e.arc(t,n,3.5,0,Math.PI*2),e.fillStyle=y.strokeColor,e.fill()}e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let[s,c]=this.points,l=n.xToPixel(s.barIndex,r,a),u=n.yToPixel(s.price,i,o),d=n.xToPixel(c.barIndex,r,a),f=n.yToPixel(c.price,i,o),p=Math.min(l,d)-oc,m=Math.min(u,f)-oc,h=Math.abs(d-l)+oc*2,g=Math.abs(f-u)+oc*2;return e>=p&&e<=p+h&&t>=m&&t<=m+g}getHandle(e,t,n,r,i,a,o){if(this.points.length<2)return null;let s=[[0,n.xToPixel(this.points[0].barIndex,r,a),n.yToPixel(this.points[0].price,i,o)],[1,n.xToPixel(this.points[1].barIndex,r,a),n.yToPixel(this.points[1].price,i,o)]];for(let[n,r,i]of s)if(Math.hypot(e-r,t-i)<=oc+2)return{pointIndex:n,cursor:`nwse-resize`};return null}},cc=new Set([`text`,`callout`,`anchoredNote`]),lc=class{constructor(){this.drawings=[],this.activeDrawing=null,this.selectedDrawing=null,this.activeTool=null,this.state=`idle`,this.history=[],this.redoStack=[],this.onCompleteCallback=null,this.onDrawingsChange=null,this.onStartTextEdit=null,this.onPointsMutated=null,this.onSelectionChange=null,this.editingText=!1,this.dragDrawing=null,this.dragStartMouse=null,this.dragStartPoints=null,this.resizeDrawing=null,this.resizePointIndex=-1}setSelected(e){var t;this.selectedDrawing!==e&&(this.selectedDrawing=e,(t=this.onSelectionChange)==null||t.call(this,e))}setOnComplete(e){this.onCompleteCallback=e}setEditingText(e){this.editingText=e}setActiveTool(e){this.state===`placing`&&this.activeDrawing&&this.drawings.pop(),this.activeTool=e,this.state=`idle`,this.activeDrawing=null}getActiveTool(){return this.activeTool}onMouseDown(e){if(!this.activeTool)return!1;if(this.state===`idle`){if(this.snapshot(),this.activeDrawing=this.createDrawing(this.activeTool,e),this.drawings.push(this.activeDrawing),this.activeDrawing.complete){var t;let e=this.activeDrawing;if(this.setSelected(e),this.activeDrawing=null,this.activeTool=null,(t=this.onCompleteCallback)==null||t.call(this),this.notifyChange(),cc.has(e.type)){var n;(n=this.onStartTextEdit)==null||n.call(this,e)}}else this.state=`placing`;return!0}if(this.state===`placing`&&this.activeDrawing){var r,i,a;if((r=this.activeDrawing.openEnded)!=null&&r){let t=this.activeDrawing.points.length-1;return this.activeDrawing.points[t]={...e},this.activeDrawing.points.push({...e}),!0}let t=(i=this.activeDrawing.requiredPoints)==null?2:i,n=this.activeDrawing.points.length;if(this.activeDrawing.points[n-1]={...e},n<t)return this.activeDrawing.points.push({...e}),!0;this.activeDrawing.complete=!0;let s=this.activeDrawing;if(this.setSelected(s),this.activeDrawing=null,this.state=`idle`,this.activeTool=null,(a=this.onCompleteCallback)==null||a.call(this),this.notifyChange(),cc.has(s.type)){var o;(o=this.onStartTextEdit)==null||o.call(this,s)}return!0}return!1}onMouseMove(e){if(this.state===`placing`&&this.activeDrawing){let t=this.activeDrawing.points.length-1;this.activeDrawing.points[t]=e}if(this.dragDrawing&&this.dragStartMouse&&this.dragStartPoints){var t;let n=e.barIndex-this.dragStartMouse.barIndex,r=e.price-this.dragStartMouse.price;for(let e=0;e<this.dragDrawing.points.length;e++){let t=this.dragStartPoints[e];t&&(this.dragDrawing.points[e]={barIndex:t.barIndex+n,price:t.price+r})}(t=this.onPointsMutated)==null||t.call(this,this.dragDrawing)}if(this.resizeDrawing&&this.resizePointIndex>=0){var n;this.resizeDrawing.points[this.resizePointIndex]={...e},(n=this.onPointsMutated)==null||n.call(this,this.resizeDrawing)}}finalizePlacing(){var e,t;if(!(this.state!==`placing`||!this.activeDrawing)&&(e=this.activeDrawing.openEnded)!=null&&e){if(this.activeDrawing.points.length>2&&this.activeDrawing.points.pop(),this.activeDrawing.points.length<2){this.drawings.pop(),this.activeDrawing=null,this.state=`idle`,this.activeTool=null;return}this.activeDrawing.complete=!0,this.setSelected(this.activeDrawing),this.activeDrawing=null,this.state=`idle`,this.activeTool=null,(t=this.onCompleteCallback)==null||t.call(this),this.notifyChange()}}startDrag(e,t){this.snapshot(),this.dragDrawing=e,this.dragStartMouse={...t},this.dragStartPoints=e.points.map(e=>({...e}))}endDrag(){this.dragDrawing=null,this.dragStartMouse=null,this.dragStartPoints=null,this.notifyChange()}isDraggingDrawing(){return this.dragDrawing!==null}isPlacing(){return this.state===`placing`}startResize(e,t){this.snapshot(),this.resizeDrawing=e,this.resizePointIndex=t}endResize(){this.resizeDrawing=null,this.resizePointIndex=-1,this.notifyChange()}isResizingDrawing(){return this.resizeDrawing!==null}shiftBarIndices(e){for(let t of this.drawings)for(let n of t.points)n.barIndex+=e;if(this.dragStartPoints)for(let t of this.dragStartPoints)t.barIndex+=e}getHandleAtPoint(e,t,n,r,i,a,o){for(let s=this.drawings.length-1;s>=0;s--){let c=this.drawings[s];if(!c.complete||c.visible===!1||c.locked)continue;let l=c.getHandle(e,t,n,r,i,a,o);if(l)return{drawing:c,handle:l}}return null}hitTest(e,t,n,r,i,a,o){for(let s=this.drawings.length-1;s>=0;s--){let c=this.drawings[s];if(!(c.visible===!1||c.locked)&&c.hitTest(e,t,n,r,i,a,o))return c}return null}selectDrawing(e){this.setSelected(e)}getSelectedDrawing(){return this.selectedDrawing}getDrawingById(e){var t;return(t=this.drawings.find(t=>t.id===e))==null?null:t}updateDrawingStyle(e,t){var n,r;let i=this.getDrawingById(e);if(!i)return null;let a=(n=i.style)==null?void 0:n.levels;i.style={...(r=i.style)==null?{}:r,...t};let o=t.levels;return o&&a&&(i.style.levels={...a,...o}),this.notifyChange(),i}onKeyDown(e){return e===`Escape`?(this.state===`placing`&&this.activeDrawing&&(this.drawings.pop(),this.activeDrawing=null,this.state=`idle`),this.activeTool=null,this.setSelected(null),!0):(e===`Delete`||e===`Backspace`)&&this.selectedDrawing&&!this.editingText?(this.deleteSelected(),!0):e===`z`&&this.history.length>0?(this.undo(),!0):!1}deleteSelected(){this.selectedDrawing&&(this.snapshot(),this.drawings=this.drawings.filter(e=>e!==this.selectedDrawing),this.setSelected(null),this.notifyChange())}undo(){let e=this.history.pop();e!==void 0&&(this.redoStack.push(this.cloneDrawings(this.drawings)),this.drawings=e,this.setSelected(null),this.notifyChange())}redo(){let e=this.redoStack.pop();e!==void 0&&(this.history.push(this.cloneDrawings(this.drawings)),this.drawings=e,this.setSelected(null),this.notifyChange())}hideAll(){if(this.drawings.length!==0){this.snapshot();for(let e of this.drawings)e.visible=!1;this.setSelected(null),this.notifyChange()}}showAll(){if(this.drawings.length!==0){this.snapshot();for(let e of this.drawings)e.visible=!0;this.notifyChange()}}lockAll(){if(this.drawings.length!==0){this.snapshot();for(let e of this.drawings)e.locked=!0;this.setSelected(null),this.notifyChange()}}unlockAll(){if(this.drawings.length!==0){this.snapshot();for(let e of this.drawings)e.locked=!1;this.notifyChange()}}render(e,t,n,r,i,a,o=2,s){if(e.clearRect(0,0,e.canvas.width,e.canvas.height),this.drawings.length===0)return;let c=window.devicePixelRatio||1;e.save(),e.scale(c,c);for(let c of this.drawings)c.visible!==!1&&c.render(e,t,n,r,i,a,c===this.selectedDrawing,o,s);e.restore()}getDrawings(){return[...this.drawings]}getDrawingsSnapshot(){return this.drawings.map(e=>({id:e.id,type:e.type,points:e.points.map(e=>({...e})),complete:e.complete,...e.visible!==void 0&&{visible:e.visible},...e.locked!==void 0&&{locked:e.locked},...e.text!==void 0&&{text:e.text},...e.style!==void 0&&{style:{...e.style}}}))}loadDrawings(e){this.drawings=e.map(e=>{var t;let n=this.createDrawing(e.type,(t=e.points[0])==null?{barIndex:0,price:0}:t);return n.id=e.id,n.points=e.points.map(e=>({...e})),n.complete=e.complete,e.visible!==void 0&&(n.visible=e.visible),e.locked!==void 0&&(n.locked=e.locked),e.text!==void 0&&(n.text=e.text),e.style!==void 0&&(n.style={...e.style}),n}),this.setSelected(null),this.activeDrawing=null,this.history=[this.drawings.map(e=>({...e,points:e.points.map(e=>({...e}))}))],this.redoStack=[]}clearAll(){this.drawings.length!==0&&(this.snapshot(),this.drawings=[],this.setSelected(null),this.activeDrawing=null,this.notifyChange())}notifyChange(){var e;(e=this.onDrawingsChange)==null||e.call(this)}snapshot(){this.history.push(this.cloneDrawings(this.drawings)),this.history.length>50&&this.history.shift(),this.redoStack=[]}cloneDrawings(e){return e.map(e=>{let t=Object.create(Object.getPrototypeOf(e));return Object.assign(t,e),t.points=e.points.map(e=>({...e})),t})}createDrawing(e,t){switch(e){case`horizontalLine`:return new ti(t);case`verticalLine`:return new ri(t);case`trendLine`:return new oi(t);case`trendAngle`:return new li(t);case`crossLine`:return new di(t);case`parallelChannel`:return new mi(t);case`flatChannel`:return new _i(t);case`disjointChannel`:return new bi(t);case`fibRetracement`:return new Ti(t);case`fibExtension`:return new ki(t);case`fibChannel`:return new Ni(t);case`fibTimezone`:return new Ii(t);case`fibCircles`:return new zi(t);case`fibSpiral`:return new Hi(t);case`fibFan`:return new qi(t);case`fibProjection`:return new Zi(t);case`gannFan`:return new ta(t);case`gannSquare`:return new ra(t);case`gannBox`:return new aa(t);case`rectangle`:return new sa(t);case`rotatedRectangle`:return new ua(t);case`ellipse`:return new fa(t);case`triangle`:return new ha(t);case`circle`:return new _a(t);case`arc`:return new ba(t);case`polyline`:return new Ca(t);case`path`:return new Ea(t);case`priceRange`:return new ka(t);case`dateRange`:return new Ma(t);case`datePriceRange`:return new Fa(t);case`ruler`:return new Ra(t);case`pitchfork`:return new Ha(t);case`schiffPitchfork`:return new Ka(t);case`modifiedSchiff`:return new Xa(t);case`insidePitchfork`:return new eo(t);case`fixedRangeVP`:return new ro(t);case`anchoredVP`:return new oo(t);case`volumeProfile`:return new lo(t);case`regressionTrend`:return new po(t);case`text`:return new _o(t);case`callout`:return new wo(t);case`priceLabel`:return new ko(t);case`arrowMarker`:return new Mo(t);case`flag`:return new No(t);case`priceNote`:return new Ro(t);case`anchoredNote`:return new Uo(t);case`arrowUp`:return new Wo(t);case`arrowDown`:return new Go(t);case`headShoulders`:return new Jo(t);case`trianglePattern`:return new Zo(t);case`threeDrives`:return new es(t);case`abcdPattern`:return new rs(t);case`cypherPattern`:return new os(t);case`butterflyPattern`:return new ls(t);case`batPattern`:return new fs(t);case`gartleyPattern`:return new hs(t);case`crabPattern`:return new vs(t);case`sharkPattern`:return new xs(t);case`elliottImpulse`:return new Ts(t);case`elliottCorrective`:return new ks(t);case`elliottTriangle`:return new Ns(t);case`elliottCombination`:return new Ls(t);case`elliottWxy`:return new Vs(t);case`brush`:return new Ws(t);case`highlighter`:return new qs(t);case`sineLine`:return new Ys(t);case`cyclicLines`:return new Zs(t);case`timeCycles`:return new $s(t);case`projection`:return new nc(t);case`priceProjection`:return new ac(t);case`ghostFeed`:return new sc(t);default:return new oi(t)}}},uc=2,dc=class{constructor(e,t=S,n=E.chart){this.pills=new Map,this.isOpen=!1,this.onDocClick=e=>{this.isOpen&&!this.el.contains(e.target)&&(this.isOpen=!1,this.dropdownPanel.style.display=`none`,this.collapseBtn.textContent=this.labels.nIndicators.replace(`{count}`,String(this.pills.size)))},this.theme=e,this.cfg=t,this.labels=n,this.el=document.createElement(`div`),Object.assign(this.el.style,{position:`absolute`,top:`52px`,left:`6px`,zIndex:`10`,display:`none`,alignItems:`center`,gap:`10px`,pointerEvents:`auto`}),this.inlineRow=document.createElement(`div`),Object.assign(this.inlineRow.style,{display:`flex`,alignItems:`center`,gap:`10px`}),this.collapseBtn=document.createElement(`button`),Object.assign(this.collapseBtn.style,{display:`none`,alignItems:`center`,gap:`4px`,background:this.theme.indicatorOverlay.pillBg,color:this.theme.axisText,border:`1px solid ${this.theme.axisBorder}`,borderRadius:`4px`,padding:`2px 8px`,fontSize:this.cfg.collapseBtnFontSize,fontFamily:this.cfg.collapseBtnFontFamily,cursor:`pointer`,outline:`none`}),this.collapseBtn.addEventListener(`click`,e=>{e.stopPropagation(),this.toggleDropdown()}),this.dropdownPanel=document.createElement(`div`),Object.assign(this.dropdownPanel.style,{display:`none`,position:`absolute`,top:`100%`,left:`0`,marginTop:`4px`,background:this.theme.tooltip.background,border:`1px solid ${this.theme.axisBorder}`,borderRadius:`4px`,padding:`4px 0`,minWidth:`140px`,zIndex:`20`,boxShadow:`0 4px 12px rgba(0,0,0,0.15)`});let r=document.createElement(`div`);Object.assign(r.style,{position:`relative`}),r.append(this.collapseBtn,this.dropdownPanel),this.el.append(this.inlineRow,r),document.addEventListener(`click`,this.onDocClick)}addPill(e,t,n,r=`Chart`,i=!0,a,o=null,s){this.pills.has(e)||(this.pills.set(e,{color:t,label:n,timeframe:r,visible:i,onRemove:a,onEdit:o,onToggleVisibility:s}),this.refresh())}updatePillColor(e,t){let n=this.pills.get(e);n&&(n.color=t,this.refresh())}updatePillLabel(e,t){let n=this.pills.get(e);n&&(n.label=t,this.refresh())}updatePillTimeframe(e,t){let n=this.pills.get(e);n&&(n.timeframe=t,this.refresh())}updatePillVisibility(e,t){let n=this.pills.get(e);n&&(n.visible=t,this.refresh())}removePill(e){this.pills.has(e)&&(this.pills.delete(e),this.refresh())}setTheme(e){this.theme=e,Object.assign(this.collapseBtn.style,{background:e.indicatorOverlay.pillBg,color:e.axisText,border:`1px solid ${e.axisBorder}`}),Object.assign(this.dropdownPanel.style,{background:e.tooltip.background,border:`1px solid ${e.axisBorder}`}),this.refresh()}destroy(){document.removeEventListener(`click`,this.onDocClick)}refresh(){let e=Array.from(this.pills.entries());if(this.inlineRow.innerHTML=``,this.dropdownPanel.innerHTML=``,e.length===0){this.el.style.display=`none`,this.collapseBtn.style.display=`none`;return}if(this.el.style.display=`flex`,e.length<=uc){this.isOpen=!1,this.dropdownPanel.style.display=`none`,this.collapseBtn.style.display=`none`;for(let[t,n]of e)this.inlineRow.appendChild(this.makePill(t,n))}else{this.collapseBtn.style.display=`inline-flex`,this.collapseBtn.textContent=this.labels.nIndicators.replace(`{count}`,String(e.length));for(let[t,n]of e)this.dropdownPanel.appendChild(this.makeDropdownRow(t,n));this.dropdownPanel.style.display=this.isOpen?`block`:`none`}}makeTimeframeBadge(e){if(!e||e===`Chart`)return null;let t=document.createElement(`span`);return t.textContent=e,Object.assign(t.style,{fontSize:`10px`,padding:`1px 4px`,borderRadius:`3px`,background:`rgba(128,128,128,0.18)`,color:this.theme.axisText,marginLeft:`2px`,lineHeight:`1.4`}),t}makeEyeIcon(e){let t=document.createElement(`span`);return t.innerHTML=e.visible?cn:ln,Object.assign(t.style,{display:`inline-flex`,alignItems:`center`,color:this.theme.indicatorOverlay.iconColor,cursor:`pointer`,opacity:e.visible?`0.6`:`0.4`,lineHeight:`1`}),t.addEventListener(`mouseenter`,()=>{t.style.opacity=`1`}),t.addEventListener(`mouseleave`,()=>{t.style.opacity=e.visible?`0.6`:`0.4`}),t.addEventListener(`click`,t=>{t.stopPropagation(),e.onToggleVisibility()}),t}makePill(e,t){let n=document.createElement(`span`);Object.assign(n.style,{display:`inline-flex`,alignItems:`center`,gap:`4px`,fontSize:this.cfg.pillFontSize,fontFamily:this.cfg.pillFontFamily,color:t.color,whiteSpace:`nowrap`,userSelect:`none`,background:this.theme.indicatorOverlay.pillBg,borderRadius:`4px`,padding:`1px 6px 1px 5px`,opacity:t.visible?`1`:`0.4`});let r=document.createElement(`span`);r.innerHTML=_n,Object.assign(r.style,{display:`inline-flex`,alignItems:`center`});let i=document.createElement(`span`);i.textContent=t.label;let a=this.makeTimeframeBadge(t.timeframe),o=document.createElement(`span`);if(Object.assign(o.style,{display:`inline-flex`,alignItems:`center`,gap:`8px`,marginLeft:`12px`}),o.appendChild(this.makeEyeIcon(t)),t.onEdit){let e=document.createElement(`span`);e.innerHTML=Xt,Object.assign(e.style,{display:`inline-flex`,alignItems:`center`,color:this.theme.indicatorOverlay.iconColor,cursor:`pointer`,opacity:`0.6`,lineHeight:`1`}),e.addEventListener(`mouseenter`,()=>{e.style.opacity=`1`}),e.addEventListener(`mouseleave`,()=>{e.style.opacity=`0.6`}),e.addEventListener(`click`,e=>{e.stopPropagation(),t.onEdit()}),o.appendChild(e)}let s=document.createElement(`span`);return s.innerHTML=Qt,Object.assign(s.style,{display:`inline-flex`,alignItems:`center`,color:this.theme.indicatorOverlay.iconColor,cursor:`pointer`}),s.addEventListener(`click`,e=>{e.stopPropagation(),t.onRemove()}),o.appendChild(s),n.append(r,i),a&&n.appendChild(a),n.appendChild(o),n}makeDropdownRow(e,t){let n=document.createElement(`div`);Object.assign(n.style,{display:`flex`,alignItems:`center`,justifyContent:`space-between`,gap:`8px`,padding:`4px 10px`,fontSize:this.cfg.dropdownRowFontSize,fontFamily:this.cfg.dropdownRowFontFamily,color:t.color,cursor:`default`,opacity:t.visible?`1`:`0.4`}),n.addEventListener(`mouseenter`,()=>{n.style.background=this.theme.indicatorOverlay.dropdownHoverBg}),n.addEventListener(`mouseleave`,()=>{n.style.background=`transparent`});let r=document.createElement(`span`);r.innerHTML=_n,Object.assign(r.style,{display:`inline-flex`,alignItems:`center`});let i=document.createElement(`span`);Object.assign(i.style,{display:`inline-flex`,alignItems:`center`,gap:`4px`,flex:`1`});let a=document.createElement(`span`);a.textContent=t.label,i.appendChild(a);let o=this.makeTimeframeBadge(t.timeframe);o&&i.appendChild(o);let s=document.createElement(`span`);Object.assign(s.style,{display:`inline-flex`,alignItems:`center`,gap:`4px`});let c=document.createElement(`span`);if(c.innerHTML=t.visible?cn:ln,Object.assign(c.style,{display:`inline-flex`,alignItems:`center`,color:this.theme.indicatorOverlay.iconColor,cursor:`pointer`,opacity:t.visible?`0.6`:`0.4`,lineHeight:`1`}),c.addEventListener(`mouseenter`,()=>{c.style.opacity=`1`}),c.addEventListener(`mouseleave`,()=>{c.style.opacity=t.visible?`0.6`:`0.4`}),c.addEventListener(`click`,e=>{e.stopPropagation(),t.onToggleVisibility()}),s.appendChild(c),t.onEdit){let e=document.createElement(`span`);e.innerHTML=Xt,Object.assign(e.style,{display:`inline-flex`,alignItems:`center`,color:this.theme.indicatorOverlay.iconColor,cursor:`pointer`,opacity:`0.6`,lineHeight:`1`}),e.addEventListener(`mouseenter`,()=>{e.style.opacity=`1`}),e.addEventListener(`mouseleave`,()=>{e.style.opacity=`0.6`}),e.addEventListener(`click`,e=>{e.stopPropagation(),this.isOpen=!1,this.dropdownPanel.style.display=`none`,t.onEdit()}),s.appendChild(e)}let l=document.createElement(`span`);return l.innerHTML=Qt,Object.assign(l.style,{display:`inline-flex`,alignItems:`center`,color:this.theme.indicatorOverlay.iconColor,cursor:`pointer`}),l.addEventListener(`click`,e=>{e.stopPropagation(),t.onRemove()}),s.appendChild(l),n.append(r,i,s),n}toggleDropdown(){this.isOpen=!this.isOpen,this.dropdownPanel.style.display=this.isOpen?`block`:`none`,this.collapseBtn.textContent=this.labels.nIndicators.replace(`{count}`,String(this.pills.size))}},fc=class{constructor(e,t=E.dialogs,n){this.schema=null,this.currentParams={},this.onUpdate=null,this.onRemove=null,this.inputRefs=new Map,this.disposeKbd=()=>{},this.theme=e,this.labels=t,this.onVisibilityChange=n,this.el=document.createElement(`div`),Object.assign(this.el.style,{position:`fixed`,inset:`0`,background:`rgba(0,0,0,0.5)`,display:`none`,alignItems:`center`,justifyContent:`center`,zIndex:`1000`}),this.el.addEventListener(`mousedown`,e=>{e.target===this.el&&this.hide()}),this.panel=document.createElement(`div`),Object.assign(this.panel.style,{display:`flex`,flexDirection:`column`,minWidth:`300px`,maxWidth:`360px`,background:this.theme.tooltip.background,border:`1px solid ${this.theme.axisBorder}`,borderRadius:`6px`,boxShadow:`0 8px 32px rgba(0,0,0,0.45)`,fontFamily:`'Inter', system-ui, sans-serif`,fontSize:`12px`,overflow:`hidden`}),this.panel.addEventListener(`mousedown`,e=>e.stopPropagation()),this.el.appendChild(this.panel),this.disposeKbd=An(this.panel)}show(e,t,n,r){var i;let a=this.isVisible;this.schema=e,this.currentParams={...t},this.onUpdate=n,this.onRemove=r,this.rebuild(),this.el.style.display=`flex`,a||(i=this.onVisibilityChange)==null||i.call(this)}hide(){var e;let t=this.isVisible;this.el.style.display=`none`,this.schema=null,this.onUpdate=null,this.onRemove=null,t&&((e=this.onVisibilityChange)==null||e.call(this))}get isVisible(){return this.el.style.display!==`none`}setTheme(e){this.theme=e,Object.assign(this.panel.style,{background:e.tooltip.background,border:`1px solid ${e.axisBorder}`}),this.el.style.display!==`none`&&this.schema&&this.rebuild()}destroy(){this.disposeKbd(),this.el.remove()}rebuild(){this.panel.innerHTML=``,this.inputRefs.clear(),this.schema&&(this.panel.appendChild(this.buildHeader(this.schema.shortName)),this.panel.appendChild(this.buildBody(this.schema.fields)),this.panel.appendChild(this.buildFooter()))}buildHeader(e){let t=document.createElement(`div`);Object.assign(t.style,{display:`flex`,alignItems:`center`,justifyContent:`space-between`,padding:`10px 14px`,borderBottom:`1px solid ${this.theme.axisBorder}`});let n=document.createElement(`span`);n.textContent=`${e} ${this.labels.indicator.titleSuffix}`,Object.assign(n.style,{color:this.theme.tooltip.text,fontWeight:`600`,fontSize:`13px`});let r=document.createElement(`span`);return r.innerHTML=Qt,Object.assign(r.style,{display:`inline-flex`,alignItems:`center`,color:this.theme.axisText,cursor:`pointer`}),r.addEventListener(`mouseenter`,()=>{r.style.color=this.theme.tooltip.text}),r.addEventListener(`mouseleave`,()=>{r.style.color=this.theme.axisText}),r.addEventListener(`click`,()=>this.hide()),t.append(n,r),t}buildBody(e){let t=document.createElement(`div`);if(Object.assign(t.style,{padding:`12px 14px`,display:`flex`,flexDirection:`column`,gap:`8px`}),e.length===0){let e=document.createElement(`span`);return e.textContent=this.labels.indicator.noParams,Object.assign(e.style,{color:this.theme.axisText,fontSize:`11px`}),t.appendChild(e),t}for(let n of e)t.appendChild(this.buildField(n));return t}buildField(e){var t;let n=document.createElement(`div`);Object.assign(n.style,{display:`flex`,alignItems:`center`,justifyContent:`space-between`,gap:`10px`});let r=document.createElement(`label`);r.textContent=e.label,Object.assign(r.style,{color:this.theme.axisText,fontSize:`12px`,flex:`1`});let i=(t=this.currentParams[e.key])==null?e.default:t;if(e.kind===`number`){let t=document.createElement(`input`);t.type=`number`,t.min=String(e.min),t.max=String(e.max),t.step=String(e.step),t.value=String(i),Object.assign(t.style,{width:`80px`,background:this.theme.background,color:this.theme.tooltip.text,border:`1px solid ${this.theme.axisBorder}`,borderRadius:`3px`,padding:`4px 6px`,fontSize:`16px`,fontFamily:`'Inter', system-ui, sans-serif`,outline:`none`,textAlign:`right`}),this.inputRefs.set(e.key,t),n.append(r,t)}else if(e.kind===`select`){let t=document.createElement(`select`);for(let n of e.options){let e=document.createElement(`option`);e.value=n,e.textContent=n,n===String(i)&&(e.selected=!0),t.appendChild(e)}Object.assign(t.style,{minWidth:`120px`,background:this.theme.background,color:this.theme.tooltip.text,border:`1px solid ${this.theme.axisBorder}`,borderRadius:`3px`,padding:`4px 6px`,fontSize:`12px`,fontFamily:`'Inter', system-ui, sans-serif`,outline:`none`,cursor:`pointer`}),this.inputRefs.set(e.key,t),n.append(r,t)}else{let t=document.createElement(`input`);t.type=`color`,t.value=String(i),Object.assign(t.style,{width:`40px`,height:`26px`,border:`none`,padding:`0`,cursor:`pointer`,background:`transparent`,borderRadius:`3px`}),this.inputRefs.set(e.key,t),n.append(r,t)}return n}buildFooter(){let e=document.createElement(`div`);Object.assign(e.style,{display:`flex`,gap:`8px`,padding:`10px 14px`,borderTop:`1px solid ${this.theme.axisBorder}`});let t=this.makeButton(`Remove`,`#ef5350`,`transparent`,`#ef5350`);t.addEventListener(`click`,()=>{var e;(e=this.onRemove)==null||e.call(this),this.hide()});let n=this.makeButton(`Update`,`#fff`,`#2196f3`,`#2196f3`);return n.addEventListener(`click`,()=>{if(!this.schema||!this.onUpdate)return;let e={};for(let t of this.schema.fields){let n=this.inputRefs.get(t.key);n&&(e[t.key]=t.kind===`number`?Number(n.value):String(n.value))}this.onUpdate(e),this.hide()}),e.append(t,n),e}makeButton(e,t,n,r){let i=document.createElement(`button`);return i.textContent=e,Object.assign(i.style,{flex:`1`,color:t,background:n,border:`1px solid ${r}`,borderRadius:`4px`,padding:`6px 0`,cursor:`pointer`,fontSize:`12px`,fontFamily:`'Inter', system-ui, sans-serif`,fontWeight:`600`,outline:`none`}),i.addEventListener(`mouseenter`,()=>{i.style.opacity=`0.85`}),i.addEventListener(`mouseleave`,()=>{i.style.opacity=`1`}),i}},pc={appearance:`Appearance`,trading:`Trading`},mc=class{constructor(e,t,n=E.dialogs,r=!0,i=!1,a){this.activeTab=`appearance`,this.onChange=null,this.onReset=null,this.tabEls=new Map,this.theme=e,this.labels=n,this.current={...t},this.showTradingTab=r,this.enableThemeToggle=i,this.onVisibilityChange=a,!r&&this.activeTab===`trading`&&(this.activeTab=`appearance`),this.el=document.createElement(`div`),Object.assign(this.el.style,{position:`fixed`,inset:`0`,background:`rgba(0,0,0,0.5)`,display:`none`,alignItems:`center`,justifyContent:`center`,zIndex:`10000`}),this.el.addEventListener(`mousedown`,e=>{e.target===this.el&&this.hide()}),this.panel=document.createElement(`div`),Object.assign(this.panel.style,{display:`flex`,flexDirection:`column`,width:`540px`,minHeight:`340px`,maxWidth:`calc(100vw - 32px)`,maxHeight:`calc(100vh - 48px)`,background:e.tooltip.background,border:`1px solid ${e.axisBorder}`,borderRadius:`10px`,boxShadow:`0 16px 48px rgba(0,0,0,0.55), 0 4px 16px rgba(0,0,0,0.3)`,fontFamily:`'Inter', system-ui, -apple-system, sans-serif`,fontSize:`12px`,overflow:`hidden`}),this.panel.addEventListener(`mousedown`,e=>e.stopPropagation());let o=this.buildHeader();this.panel.appendChild(o);let s=document.createElement(`div`);Object.assign(s.style,{display:`flex`,flex:`1`,overflow:`hidden`}),this.sidebar=this.buildSidebar(),s.appendChild(this.sidebar),this.content=document.createElement(`div`),Object.assign(this.content.style,{flex:`1`,padding:`20px 24px`,overflowY:`auto`,scrollbarWidth:`thin`}),s.appendChild(this.content),this.panel.appendChild(s),this.panel.appendChild(this.buildFooter()),this.el.appendChild(this.panel)}show(e,t,n){var r;let i=this.isVisible;this.current={...e},this.onChange=t,this.onReset=n==null?null:n,this.renderContent(),this.el.style.display=`flex`,i||(r=this.onVisibilityChange)==null||r.call(this)}hide(){var e;let t=this.isVisible;this.el.style.display=`none`,this.onChange=null,this.onReset=null,t&&((e=this.onVisibilityChange)==null||e.call(this))}get isVisible(){return this.el.style.display!==`none`}setTheme(e){this.theme=e,this.applyPanelTheme(),this.el.style.display!==`none`&&this.renderContent()}destroy(){this.el.remove()}emit(){var e;(e=this.onChange)==null||e.call(this,{...this.current})}applyPanelTheme(){Object.assign(this.panel.style,{background:this.theme.tooltip.background,border:`1px solid ${this.theme.axisBorder}`}),this.sidebar.innerHTML=``,this.tabEls.clear(),this.buildSidebarTabs(this.sidebar),this.highlightActiveTab()}buildHeader(){let e=document.createElement(`div`);Object.assign(e.style,{display:`flex`,alignItems:`center`,justifyContent:`space-between`,padding:`14px 20px 12px`,borderBottom:`1px solid ${this.theme.axisBorder}`,flexShrink:`0`});let t=document.createElement(`span`);t.textContent=this.labels.settings.title,Object.assign(t.style,{color:this.theme.tooltip.text,fontWeight:`600`,fontSize:`14px`,letterSpacing:`-0.01em`});let n=document.createElement(`button`);return n.innerHTML=gn,Object.assign(n.style,{color:this.theme.axisText,cursor:`pointer`,background:`transparent`,border:`none`,padding:`4px`,borderRadius:`4px`,display:`flex`,alignItems:`center`,justifyContent:`center`,outline:`none`,transition:`color 0.1s, background 0.1s`}),n.addEventListener(`mouseenter`,()=>{n.style.color=this.theme.tooltip.text,n.style.background=this.theme.ui.accentBg}),n.addEventListener(`mouseleave`,()=>{n.style.color=this.theme.axisText,n.style.background=`transparent`}),n.addEventListener(`click`,()=>this.hide()),e.append(t,n),e}buildFooter(){let e=document.createElement(`div`);Object.assign(e.style,{display:`flex`,alignItems:`center`,justifyContent:`flex-end`,padding:`10px 20px`,borderTop:`1px solid ${this.theme.axisBorder}`,flexShrink:`0`});let t=document.createElement(`button`);return t.textContent=this.labels.settings.resetBtn,Object.assign(t.style,{color:this.theme.axisText,fontSize:`11px`,fontFamily:`'Inter', system-ui, sans-serif`,background:`transparent`,border:`1px solid ${this.theme.axisBorder}`,borderRadius:`5px`,padding:`5px 12px`,cursor:`pointer`,outline:`none`,transition:`color 0.1s, border-color 0.1s, background 0.1s`}),t.addEventListener(`mouseenter`,()=>{t.style.color=this.theme.tooltip.text,t.style.borderColor=this.theme.ui.accent,t.style.background=this.theme.ui.accentBg}),t.addEventListener(`mouseleave`,()=>{t.style.color=this.theme.axisText,t.style.borderColor=this.theme.axisBorder,t.style.background=`transparent`}),t.addEventListener(`click`,()=>{var e;(e=this.onReset)==null||e.call(this),this.hide()}),e.appendChild(t),e}buildSidebar(){let e=document.createElement(`div`);return Object.assign(e.style,{width:`130px`,flexShrink:`0`,borderRight:`1px solid ${this.theme.axisBorder}`,padding:`10px 0`,display:`flex`,flexDirection:`column`,gap:`2px`}),this.buildSidebarTabs(e),e}buildSidebarTabs(e){let t=this.showTradingTab?[`appearance`,`trading`]:[`appearance`];for(let n of t){let t=document.createElement(`button`);Object.assign(t.style,{display:`flex`,alignItems:`center`,gap:`8px`,padding:`8px 14px`,background:`transparent`,border:`none`,borderLeft:`2px solid transparent`,color:this.theme.axisText,fontSize:`12px`,fontFamily:`'Inter', system-ui, sans-serif`,cursor:`pointer`,width:`100%`,textAlign:`left`,outline:`none`,transition:`background 0.1s, color 0.1s`,boxSizing:`border-box`});let r=document.createElement(`span`);r.innerHTML=hn[n],Object.assign(r.style,{display:`flex`,flexShrink:`0`});let i=document.createElement(`span`);i.textContent=pc[n],t.append(r,i),t.addEventListener(`mouseenter`,()=>{this.activeTab!==n&&(t.style.background=this.theme.ui.accentBg,t.style.color=this.theme.tooltip.text)}),t.addEventListener(`mouseleave`,()=>{this.activeTab!==n&&(t.style.background=`transparent`,t.style.color=this.theme.axisText)}),t.addEventListener(`click`,()=>{this.activeTab=n,this.highlightActiveTab(),this.renderContent()}),this.tabEls.set(n,t),e.appendChild(t)}}highlightActiveTab(){for(let[e,t]of this.tabEls){let n=e===this.activeTab;Object.assign(t.style,{background:n?this.theme.ui.accentBg:`transparent`,color:n?this.theme.ui.accentText:this.theme.axisText,borderLeft:n?`2px solid ${this.theme.ui.accent}`:`2px solid transparent`,fontWeight:n?`500`:`400`})}}renderContent(){switch(this.content.innerHTML=``,this.highlightActiveTab(),this.activeTab){case`appearance`:this.buildAppearanceSection();break;case`trading`:this.buildTradingSection();break}}buildAppearanceSection(){if(this.enableThemeToggle){let e=document.createElement(`div`);Object.assign(e.style,{display:`flex`,alignItems:`center`,justifyContent:`space-between`,paddingBottom:`10px`,borderBottom:`1px solid ${this.theme.axisBorder}`});let t=document.createElement(`span`);t.textContent=`Theme`,Object.assign(t.style,{color:this.theme.tooltip.text,fontSize:`13px`,fontWeight:`600`}),e.append(t,this.makeThemeToggle()),this.content.appendChild(e)}this.content.appendChild(this.makeSectionHeader(`Colors`)),this.content.appendChild(this.buildColorRows()),this.content.appendChild(this.makeSectionHeader(`Chart elements`)),this.content.appendChild(this.makeHorizontalSettingRow(`Price-axis countdown`,`Show the candle close countdown on the right price axis.`,this.makeBooleanToggle(this.current.showPriceAxisCountdown,e=>{this.current.showPriceAxisCountdown=e,this.emit()})))}makeBooleanToggle(e,t,n){let r=e,i=document.createElement(`div`);Object.assign(i.style,{display:`flex`,alignItems:`center`,gap:`8px`});let a=n?document.createElement(`span`):null,o=n?document.createElement(`span`):null;a&&o&&n&&(a.textContent=n.off,o.textContent=n.on);let s=()=>{!a||!o||(Object.assign(a.style,{color:r?this.theme.axisText:this.theme.tooltip.text,fontWeight:r?`400`:`500`,fontSize:`11px`,cursor:`pointer`,userSelect:`none`}),Object.assign(o.style,{color:r?this.theme.tooltip.text:this.theme.axisText,fontWeight:r?`500`:`400`,fontSize:`11px`,cursor:`pointer`,userSelect:`none`}))},c=document.createElement(`div`);Object.assign(c.style,{position:`relative`,width:`36px`,height:`20px`,borderRadius:`10px`,cursor:`pointer`,flexShrink:`0`,transition:`background 0.18s`,background:this.theme.axisBorder,border:`1px solid ${this.theme.axisText}50`,boxSizing:`border-box`});let l=document.createElement(`div`);Object.assign(l.style,{position:`absolute`,top:`2px`,left:r?`18px`:`2px`,width:`14px`,height:`14px`,borderRadius:`50%`,background:this.theme.ui.accent,transition:`left 0.18s`,pointerEvents:`none`}),c.appendChild(l);let u=()=>{r=!r,l.style.left=r?`18px`:`2px`,s(),t(r)};return c.addEventListener(`click`,u),a&&o&&(a.addEventListener(`click`,()=>{r&&u()}),o.addEventListener(`click`,()=>{r||u()})),s(),a&&o?i.append(a,c,o):i.append(c),i}makeThemeToggle(){return this.makeBooleanToggle(this.current.theme===`light`,e=>{this.current.theme=e?`light`:`dark`,this.emit(),this.renderContent()},{off:`Dark`,on:`Light`})}buildColorRows(){var e,t,n,r;let i=this.current.theme,a=(e=(t=this.current.canvasColors)==null?void 0:t[i])==null?{}:e,o=document.createElement(`div`);Object.assign(o.style,{display:`grid`,gridTemplateColumns:`max-content 24px 24px`,columnGap:`8px`,rowGap:`8px`,padding:`8px 0 4px`,alignItems:`center`});let s=[{label:`Background`,s1:{field:`background`,fallback:this.theme.background}},{label:`Grid`,s1:{field:`grid`,fallback:this.theme.grid}},{label:`Axis Text`,s1:{field:`axisText`,fallback:this.theme.axisText}},{label:`Axis Border`,s1:{field:`axisBorder`,fallback:this.theme.axisBorder}},{label:`Crosshair`,s1:{field:`crosshair`,fallback:this.theme.crosshair}},{label:`Candle Body`,s1:{field:`candleUp`,fallback:this.theme.candle.up},s2:{field:`candleDown`,fallback:this.theme.candle.down}},{label:`Candle Wick`,s1:{field:`wickUp`,fallback:this.theme.candle.wickUp},s2:{field:`wickDown`,fallback:this.theme.candle.wickDown}},{label:`Candle Border`,s1:{field:`borderUp`,fallback:(n=this.theme.candle.borderUp)==null?this.theme.candle.up:n},s2:{field:`borderDown`,fallback:(r=this.theme.candle.borderDown)==null?this.theme.candle.down:r}},{label:`Volume`,s1:{field:`volumeUp`,fallback:this.theme.volume.up},s2:{field:`volumeDown`,fallback:this.theme.volume.down}}],c=e=>{var t;return this.makeColorSwatch((t=a[e.field])==null?e.fallback:t,t=>{this.current.canvasColors||(this.current.canvasColors={}),this.current.canvasColors[i]||(this.current.canvasColors[i]={}),this.current.canvasColors[i][e.field]=t,this.emit()})};for(let{label:e,s1:t,s2:n}of s){let r=document.createElement(`span`);r.textContent=e,Object.assign(r.style,{color:this.theme.axisText,fontSize:`11px`,paddingRight:`12px`});let i=c(t);i.style.width=`24px`,i.style.height=`24px`;let a;n?(a=c(n),a.style.width=`24px`,a.style.height=`24px`):a=document.createElement(`span`),o.append(r,i,a)}return o}makeColorSwatch(e,t){let n=`${this.theme.axisText}80`,r=document.createElement(`div`);Object.assign(r.style,{position:`relative`,width:`28px`,height:`28px`,borderRadius:`6px`,overflow:`hidden`,cursor:`pointer`,border:`1.5px solid ${n}`,flexShrink:`0`,boxSizing:`border-box`});let i=document.createElement(`div`);Object.assign(i.style,{position:`absolute`,inset:`0`,background:e});let a=document.createElement(`input`);a.type=`color`,a.value=e,Object.assign(a.style,{position:`absolute`,inset:`0`,opacity:`0`,width:`100%`,height:`100%`,cursor:`pointer`,padding:`0`,border:`none`});let o=null;return a.addEventListener(`input`,()=>{i.style.background=a.value,o!==null&&clearTimeout(o),o=setTimeout(()=>{o=null,t(a.value)},300)}),r.append(i,a),r}buildTradingSection(){let e=this.labels.settings;this.content.appendChild(this.makeSectionHeader(e.tfcSection)),this.content.appendChild(this.makeVerticalSettingRow(e.showLabel,`Controls which trade levels are displayed on the chart`,this.makeSegmented([{value:`all`,label:e.showAll},{value:`positions`,label:e.showPositions},{value:`orders`,label:e.showOrders},{value:`none`,label:e.showNone}],this.current.tradeDisplayFilter,e=>{this.current.tradeDisplayFilter=e,this.emit()}))),this.content.appendChild(this.makeVerticalSettingRow(e.positionStyleLabel,`How open positions are rendered on the chart`,this.makeSegmented([{value:`line`,label:e.styleLine},{value:`dot`,label:e.styleDot}],this.current.positionRenderStyle,e=>{this.current.positionRenderStyle=e,this.emit()}))),this.content.appendChild(this.makeHorizontalSettingRow(`Always show SL/TP`,`Keep stop-loss and take-profit lines visible without hovering.`,this.makeBooleanToggle(this.current.showTradeLevelsAlways,e=>{this.current.showTradeLevelsAlways=e,this.emit()})))}makeSectionHeader(e,t=!1){let n=document.createElement(`div`);return n.textContent=e,Object.assign(n.style,{color:this.theme.tooltip.text,fontSize:`13px`,fontWeight:`600`,paddingBottom:`10px`,marginTop:t?`0`:`20px`,marginBottom:`2px`,borderBottom:`1px solid ${this.theme.axisBorder}`}),n}makeVerticalSettingRow(e,t,n){let r=document.createElement(`div`);Object.assign(r.style,{display:`flex`,flexDirection:`column`,gap:`12px`,padding:`14px 0`,borderBottom:`1px solid ${this.theme.axisBorder}`});let i=document.createElement(`div`);Object.assign(i.style,{display:`flex`,flexDirection:`column`,gap:`0px`});let a=document.createElement(`span`);a.textContent=e,Object.assign(a.style,{color:this.theme.tooltip.text,fontSize:`12px`,fontWeight:`500`});let o=document.createElement(`span`);return o.textContent=t,Object.assign(o.style,{color:this.theme.axisText,fontSize:`10px`}),i.append(a,o),Object.assign(n.style,{width:`fit-content`,border:`1px solid ${this.theme.axisText}`,borderRadius:`6px`,overflow:`hidden`}),r.append(i,n),r}makeHorizontalSettingRow(e,t,n){let r=document.createElement(`div`);Object.assign(r.style,{display:`flex`,flexDirection:`row`,alignItems:`center`,justifyContent:`space-between`,gap:`12px`,padding:`14px 0`,borderBottom:`1px solid ${this.theme.axisBorder}`});let i=document.createElement(`div`);Object.assign(i.style,{display:`flex`,flexDirection:`column`,gap:`0px`,flex:`1`,minWidth:`0`});let a=document.createElement(`span`);a.textContent=e,Object.assign(a.style,{color:this.theme.tooltip.text,fontSize:`12px`,fontWeight:`500`});let o=document.createElement(`span`);o.textContent=t,Object.assign(o.style,{color:this.theme.axisText,fontSize:`10px`}),i.append(a,o);let s=document.createElement(`div`);return Object.assign(s.style,{display:`flex`,alignItems:`center`,justifyContent:`center`,flexShrink:`0`}),s.appendChild(n),r.append(i,s),r}makeSegmented(e,t,n){let r=document.createElement(`div`);Object.assign(r.style,{display:`inline-flex`,borderRadius:`6px`,border:`1px solid ${this.theme.axisText}`,overflow:`hidden`,flexShrink:`0`});let i=[];for(let a of e){let o=document.createElement(`button`),s=a.value===t;Object.assign(o.style,{padding:`5px 14px`,fontSize:`11px`,fontFamily:`'Inter', system-ui, sans-serif`,background:s?this.theme.ui.accent:`transparent`,color:s?`#ffffff`:this.theme.axisText,border:`none`,borderRight:`1px solid ${this.theme.axisText}`,cursor:`pointer`,outline:`none`,transition:`background 0.12s, color 0.12s`,whiteSpace:`nowrap`,textAlign:`center`}),a===e[e.length-1]&&(o.style.borderRight=`none`),o.textContent=a.label,o.addEventListener(`mouseenter`,()=>{t!==a.value&&(o.style.background=this.theme.ui.accentBg,o.style.color=this.theme.ui.accentText)}),o.addEventListener(`mouseleave`,()=>{t!==a.value&&(o.style.background=`transparent`,o.style.color=this.theme.axisText)}),o.addEventListener(`click`,()=>{t=a.value;for(let e of i)e.style.background=`transparent`,e.style.color=this.theme.axisText;o.style.background=this.theme.ui.accent,o.style.color=`#ffffff`,n(a.value)}),i.push(o),r.appendChild(o)}return r}},hc=class{constructor(e,t,n,r=E.trade,i=C){this._visible=!1,this._isMobile=!1,this.theme=e,this.cfg=i,this.el=document.createElement(`button`),this.el.innerHTML=yn,this.el.title=r.placeOrderTitle,Object.assign(this.el.style,{position:`absolute`,right:`${t+26}px`,top:`0`,width:`${i.size}px`,height:`${i.size}px`,borderRadius:`50%`,border:`1px solid ${e.axisBorder}`,background:e.tooltip.background,color:e.axisText,fontSize:`14px`,lineHeight:`1`,display:`none`,alignItems:`center`,justifyContent:`center`,cursor:`pointer`,padding:`0`,fontFamily:`'Inter', system-ui, sans-serif`,zIndex:`15`,transform:`translateY(-50%)`,transition:`opacity 0.1s`,pointerEvents:`auto`,userSelect:`none`}),this.applyIconSize(i.iconSize),this.el.addEventListener(`click`,e=>{e.stopPropagation(),n()}),this.el.addEventListener(`mouseenter`,()=>{this.el.style.opacity=`1`,Object.assign(this.el.style,{background:e.tooltip.background,color:e.tradeLevels.buySide,border:`1px solid ${e.tradeLevels.buySide}`})}),this.el.addEventListener(`mouseleave`,e=>{var t;Object.assign(this.el.style,{background:this.theme.tooltip.background,color:this.theme.axisText,border:`1px solid ${this.theme.axisBorder}`});let n=e.relatedTarget;(!n||!((t=this.el.parentElement)!=null&&t.contains(n)))&&this.hide()})}setY(e){this.el.style.top=`${e}px`}show(){this._visible||(this._visible=!0,this.el.style.display=`flex`)}hide(){this._visible&&(this._visible=!1,this.el.style.display=`none`)}setTheme(e,t){this.theme=e,Object.assign(this.el.style,{border:`1px solid ${e.axisBorder}`,background:e.tooltip.background,color:e.axisText,right:`${t+26}px`})}setMobileMode(e){if(this._isMobile===e)return;this._isMobile=e;let t=e?this.cfg.mobileSize:this.cfg.size,n=e?this.cfg.mobileIconSize:this.cfg.iconSize;this.el.style.width=`${t}px`,this.el.style.height=`${t}px`,this.applyIconSize(n)}applyIconSize(e){let t=this.el.querySelector(`svg`);t&&(t.setAttribute(`width`,String(e)),t.setAttribute(`height`,String(e)))}},gc=class{constructor(e,t,n,r,i=E.trade,a,o=!1){this._price=0,this._pricePrecision=2,this._buyOrderType=`limit`,this._sellOrderType=`limit`,this._compact=!1,this._adaptiveText=!1,this.onDocMouseDown=e=>{this.isVisible&&!this.el.contains(e.target)&&this.hide()},this.theme=e,this.lots=t,this.symbol=n,this.onDraftCreate=r,this.labels=i,this.onVisibilityChange=a,this._adaptiveText=o,this.el=document.createElement(`div`),Object.assign(this.el.style,{position:`absolute`,display:`none`,flexDirection:`column`,background:e.tooltip.background,border:`1px solid ${e.axisBorder}`,borderRadius:`5px`,padding:`4px`,zIndex:`20`,boxShadow:`0 4px 16px rgba(0,0,0,0.25)`,fontFamily:`'Inter', system-ui, sans-serif`,fontSize:`12px`,width:`max-content`,pointerEvents:`auto`}),document.addEventListener(`mousedown`,this.onDocMouseDown)}show(e,t,n,r=2,i=`limit`,a=`limit`){var o;let s=this.isVisible;this._price=e,this._pricePrecision=r,this._buyOrderType=i,this._sellOrderType=a,this.rebuild(),this.el.style.display=`flex`,this.el.style.right=`${n}px`,this.el.style.top=`${t-16}px`,s||(o=this.onVisibilityChange)==null||o.call(this)}hide(){var e;let t=this.isVisible;this.el.style.display=`none`,t&&((e=this.onVisibilityChange)==null||e.call(this))}get isVisible(){return this.el.style.display!==`none`}setLots(e){this.lots=e}setSymbol(e){this.symbol=e}setCompact(e){this._compact=e}setTheme(e){this.theme=e,Object.assign(this.el.style,{background:e.tooltip.background,border:`1px solid ${e.axisBorder}`})}destroy(){document.removeEventListener(`mousedown`,this.onDocMouseDown)}rebuild(){this.el.innerHTML=``;let e=document.createElement(`div`);Object.assign(e.style,{height:`1px`,background:this.theme.axisBorder,margin:`0 8px`}),this.el.append(this.makeRow(this.theme.tradeLevels.sellSide,`sell`,this._sellOrderType),e,this.makeRow(this.theme.tradeLevels.buySide,`buy`,this._buyOrderType))}makeRow(e,t,n){let r=document.createElement(`button`);Object.assign(r.style,{display:`flex`,alignItems:`center`,gap:`8px`,width:`100%`,background:`transparent`,border:`none`,borderRadius:`3px`,padding:this._compact?`5px 8px`:`8px 10px`,cursor:`pointer`,fontFamily:`'Inter', system-ui, sans-serif`,fontSize:this._compact?`11px`:`12px`}),r.appendChild(this.makeChevron(e,t));let i=t===`sell`?this.labels.sell:this.labels.buy,a=n===`limit`?this.labels.limit:this.labels.stop,o=this._price.toFixed(this._pricePrecision),s=document.createElement(`span`);s.textContent=`${i} ${a}`,Object.assign(s.style,{color:e,fontWeight:`600`});let c=document.createElement(`span`);c.textContent=` ${this.lots} ${this.symbol} ${this.labels.at} ${o}`;let l=this._adaptiveText?this.theme.tooltip.text:`#ffffff`;return Object.assign(c.style,{color:l,fontWeight:`400`}),r.append(s,c),r.addEventListener(`mouseenter`,()=>{r.style.background=`rgba(255,255,255,0.06)`}),r.addEventListener(`mouseleave`,()=>{r.style.background=`transparent`}),r.addEventListener(`mousedown`,e=>{e.stopPropagation(),this.onDraftCreate(t,this._price,n),this.hide()}),r}makeChevron(e,t){let n=`http://www.w3.org/2000/svg`,r=document.createElementNS(n,`svg`);r.setAttribute(`width`,`10`),r.setAttribute(`height`,`8`),r.setAttribute(`viewBox`,`0 0 10 8`),r.style.flexShrink=`0`;let i=document.createElementNS(n,`path`);return i.setAttribute(`d`,t===`sell`?`M1 1 L5 7 L9 1`:`M1 7 L5 1 L9 7`),i.setAttribute(`stroke`,e),i.setAttribute(`fill`,`none`),i.setAttribute(`stroke-width`,`1.5`),i.setAttribute(`stroke-linecap`,`round`),i.setAttribute(`stroke-linejoin`,`round`),r.appendChild(i),r}},_c={horizontalLine:[`stroke`,`width`,`style`],verticalLine:[`stroke`,`width`,`style`],crossLine:[`stroke`,`width`,`style`],trendLine:[`stroke`,`width`,`style`],trendAngle:[`stroke`,`width`,`style`],parallelChannel:[`stroke`,`width`,`style`,`fill`],flatChannel:[`stroke`,`width`,`style`,`fill`],disjointChannel:[`stroke`,`width`,`style`],rectangle:[`stroke`,`width`,`style`,`fill`],rotatedRectangle:[`stroke`,`width`,`style`,`fill`],ellipse:[`stroke`,`width`,`style`,`fill`],circle:[`stroke`,`width`,`style`,`fill`],triangle:[`stroke`,`width`,`style`,`fill`],arc:[`stroke`,`width`,`style`],path:[`stroke`,`width`,`style`],polyline:[`stroke`,`width`,`style`],sineLine:[`stroke`,`width`,`style`],brush:[`stroke`,`width`],highlighter:[`stroke`,`width`],fibRetracement:[`width`,`style`,`fibLevels`],fibExtension:[`width`,`style`,`fibLevels`],fibProjection:[`width`,`style`,`fibLevels`],fibChannel:[`stroke`,`width`,`style`],fibFan:[`stroke`,`width`,`style`],fibCircles:[`stroke`,`width`,`style`],fibSpiral:[`stroke`,`width`,`style`],fibTimezone:[`stroke`,`width`,`style`],gannFan:[`stroke`,`width`,`style`],gannSquare:[`stroke`,`width`,`style`],gannBox:[`stroke`,`width`,`style`,`fill`],pitchfork:[`stroke`,`width`,`style`],schiffPitchfork:[`stroke`,`width`,`style`],modifiedSchiff:[`stroke`,`width`,`style`],insidePitchfork:[`stroke`,`width`,`style`],text:[`text`],callout:[`text`,`stroke`,`fill`],priceLabel:[`text`,`fill`],priceNote:[`text`,`stroke`],anchoredNote:[`text`,`stroke`,`fill`],arrowUp:[`stroke`,`fill`],arrowDown:[`stroke`,`fill`],arrowMarker:[`stroke`,`fill`],flag:[`stroke`,`fill`],volumeProfile:[`stroke`,`fill`],anchoredVP:[`stroke`,`fill`],fixedRangeVP:[`stroke`,`fill`],priceRange:[`stroke`,`fill`],dateRange:[`stroke`,`width`,`style`],datePriceRange:[`stroke`,`fill`],ruler:[`stroke`,`width`,`style`],regressionTrend:[`stroke`,`width`,`style`],projection:[`stroke`,`width`,`style`],cyclicLines:[`stroke`,`width`,`style`],timeCycles:[`stroke`,`width`,`style`,`fill`],priceProjection:[`stroke`,`fill`],ghostFeed:[`stroke`,`fill`]},vc=[1,2,3,4],yc=[10,11,12,13,14,16,18,20,24],bc=24,xc=new Set([`fibRetracement`]);function Sc(e,t){let n={};for(let t of Object.keys(e==null?{}:e)){let r=e==null?void 0:e[t];r&&(n[t]=r)}for(let e of Object.keys(t==null?{}:t)){var r;let i=t==null?void 0:t[e];i===null?delete n[e]:i&&(n[e]={...(r=n[e])==null?{visible:!0,color:`#888888`}:r,...i})}return n}function Cc(e){return String(e)}var wc=class{constructor(e,t,n){this.currentDrawing=null,this.fibLevelsExpanded=!1,this.fibPanel=null,this.container=e,this.theme=t,this.onChange=n,this.el=document.createElement(`div`),Object.assign(this.el.style,{position:`absolute`,display:`none`,flexDirection:`row`,alignItems:`center`,gap:`10px`,background:t.tooltip.background,border:`1px solid ${t.axisBorder}`,borderRadius:`8px`,padding:`8px 10px`,zIndex:`50`,boxShadow:`0 6px 18px rgba(0,0,0,0.35)`,fontFamily:`'Inter', system-ui, sans-serif`,fontSize:`11px`,color:t.tooltip.text,pointerEvents:`auto`,userSelect:`none`,whiteSpace:`nowrap`}),e.appendChild(this.el)}setTheme(e){this.theme=e,this.el.style.background=e.tooltip.background,this.el.style.border=`1px solid ${e.axisBorder}`,this.el.style.color=e.tooltip.text,this.currentDrawing&&this.rebuild()}show(e,t,n){var r;let i=((r=this.currentDrawing)==null?void 0:r.id)===e.id;this.currentDrawing=e,i||(this.fibLevelsExpanded=!1,this.rebuild()),this.el.style.display=`flex`,this.setAnchor(t,n)}setAnchor(e,t){requestAnimationFrame(()=>{let n=this.el.getBoundingClientRect(),r=this.container.getBoundingClientRect(),i=n.width||240,a=n.height||56,o=e-i/2,s=t-a-12;s<4&&(s=t+16),o=Math.max(4,Math.min(r.width-i-4,o)),s=Math.max(4,Math.min(r.height-a-4,s)),this.el.style.left=`${o}px`,this.el.style.top=`${s}px`})}hide(){var e;this.el.style.display=`none`,this.currentDrawing=null,this.fibLevelsExpanded=!1,(e=this.fibPanel)==null||e.remove(),this.fibPanel=null}destroy(){var e;(e=this.fibPanel)==null||e.remove(),this.el.remove(),this.currentDrawing=null}rebuild(){var e,t,n;if(this.el.innerHTML=``,!this.currentDrawing)return;let r=(e=_c[this.currentDrawing.type])==null?[`stroke`,`width`,`style`]:e,i=(t=this.currentDrawing.style)==null?{}:t,a=(n=this.theme.drawing[this.currentDrawing.type])==null?{}:n,o=[];for(let e of r)switch(e){case`stroke`:var s,c;o.push(this.group(`Color`,this.makeColorSwatch((s=(c=i.strokeColor)==null?a.strokeColor:c)==null?`#888888`:s,e=>this.emit({strokeColor:e}))));break;case`width`:var l,u;o.push(this.group(`Width`,this.buildWidth((l=(u=i.lineWidth)==null?a.lineWidth:u)==null?1:l,e=>this.emit({lineWidth:e}))));break;case`style`:var d,f;o.push(this.group(`Style`,this.buildLineStyle((d=(f=i.lineStyle)==null?a.lineStyle:f)==null?`solid`:d,e=>this.emit({lineStyle:e}))));break;case`fill`:{var p,m,h,g;let e=document.createElement(`div`);Object.assign(e.style,{display:`flex`,alignItems:`center`,gap:`6px`}),e.appendChild(this.makeColorSwatch((p=(m=i.fillColor)==null?a.fillColor:m)==null?`#888888`:p,e=>this.emit({fillColor:e}))),e.appendChild(this.buildOpacity((h=(g=i.fillOpacity)==null?a.fillOpacity:g)==null?.1:h,e=>this.emit({fillOpacity:e}))),o.push(this.group(`Fill`,e));break}case`text`:{var _,v,y,b;let e=document.createElement(`div`);Object.assign(e.style,{display:`flex`,alignItems:`center`,gap:`6px`}),e.appendChild(this.makeColorSwatch((_=(v=i.textColor)==null?a.textColor:v)==null?`#f5f5f5`:_,e=>this.emit({textColor:e}))),e.appendChild(this.buildFontSize((y=(b=i.fontSize)==null?a.fontSize:b)==null?13:y,e=>this.emit({fontSize:e}))),o.push(this.group(`Text`,e));break}case`fibLevels`:o.push(this.group(`Levels`,this.buildFibLevelsButton(Sc(a.levels,i.levels))));break}o.forEach((e,t)=>{t>0&&this.el.appendChild(this.makeSeparator()),this.el.appendChild(e)})}group(e,t){let n=document.createElement(`div`);Object.assign(n.style,{display:`flex`,flexDirection:`column`,alignItems:`flex-start`,gap:`4px`});let r=document.createElement(`span`);return r.textContent=e,Object.assign(r.style,{fontSize:`10px`,color:this.theme.axisText,textTransform:`uppercase`,letterSpacing:`0.5px`,lineHeight:`1`}),n.appendChild(r),n.appendChild(t),n}makeSeparator(){let e=document.createElement(`div`);return Object.assign(e.style,{width:`1px`,height:`32px`,background:this.theme.axisBorder,opacity:`0.6`}),e}makeColorSwatch(e,t){let n=`${this.theme.axisText}80`,r=e.length===7&&e.startsWith(`#`)?e:`#888888`,i=document.createElement(`div`);Object.assign(i.style,{position:`relative`,width:`${bc}px`,height:`${bc}px`,borderRadius:`6px`,overflow:`hidden`,cursor:`pointer`,border:`1.5px solid ${n}`,flexShrink:`0`,boxSizing:`border-box`});let a=document.createElement(`div`);Object.assign(a.style,{position:`absolute`,inset:`0`,background:e});let o=document.createElement(`input`);o.type=`color`,o.value=r,Object.assign(o.style,{position:`absolute`,inset:`0`,opacity:`0`,width:`100%`,height:`100%`,cursor:`pointer`,padding:`0`,border:`none`});let s=null;return o.addEventListener(`input`,()=>{a.style.background=o.value,s!==null&&clearTimeout(s),s=setTimeout(()=>{s=null,t(o.value)},200)}),i.append(a,o),i}buildWidth(e,t){let n=document.createElement(`div`);Object.assign(n.style,{display:`flex`,gap:`2px`,alignItems:`center`});for(let r of vc){let i=this.makeIconButton(`${r}px`),a=document.createElement(`div`);Object.assign(a.style,{width:`14px`,height:`${r}px`,background:this.theme.tooltip.text,borderRadius:`1px`}),i.appendChild(a),Math.round(e)===r&&this.markActive(i),i.addEventListener(`click`,()=>t(r)),n.appendChild(i)}return n}buildLineStyle(e,t){let n=document.createElement(`div`);Object.assign(n.style,{display:`flex`,gap:`2px`,alignItems:`center`});let r=[{key:`solid`,svg:this.lineSvg(`solid`),title:`Solid`},{key:`dashed`,svg:this.lineSvg(`dashed`),title:`Dashed`},{key:`dotted`,svg:this.lineSvg(`dotted`),title:`Dotted`}];for(let{key:i,svg:a,title:o}of r){let r=this.makeIconButton(o);r.innerHTML=a,i===e&&this.markActive(r),r.addEventListener(`click`,()=>t(i)),n.appendChild(r)}return n}lineSvg(e){let t=e===`dashed`?`4,2`:e===`dotted`?`1.5,2`:``;return`<svg width="18" height="10" viewBox="0 0 18 10"><line x1="1" y1="5" x2="17" y2="5" stroke="${this.theme.tooltip.text}" stroke-width="1.5" stroke-linecap="round" ${t?`stroke-dasharray="${t}"`:``} /></svg>`}buildOpacity(e,t){let n=document.createElement(`div`);Object.assign(n.style,{display:`flex`,alignItems:`center`,gap:`4px`});let r=document.createElement(`input`);r.type=`range`,r.min=`0`,r.max=`100`,r.value=String(Math.round(e*100)),Object.assign(r.style,{width:`64px`,accentColor:this.theme.ui.accent}),r.title=`Fill opacity`;let i=document.createElement(`span`);return i.textContent=`${r.value}%`,Object.assign(i.style,{fontSize:`10px`,color:this.theme.axisText,minWidth:`26px`,textAlign:`right`}),r.addEventListener(`input`,()=>{i.textContent=`${r.value}%`,t(Number(r.value)/100)}),n.append(r,i),n}buildFontSize(e,t){let n=document.createElement(`select`);Object.assign(n.style,{background:this.theme.tooltip.background,color:this.theme.tooltip.text,border:`1px solid ${this.theme.axisBorder}`,borderRadius:`4px`,padding:`3px 4px`,fontSize:`11px`,cursor:`pointer`,height:`${bc}px`,boxSizing:`border-box`});for(let t of yc){let r=document.createElement(`option`);r.value=String(t),r.textContent=`${t}px`,t===e&&(r.selected=!0),n.appendChild(r)}return n.addEventListener(`change`,()=>t(Number(n.value))),n}buildFibLevelsButton(e){let t=document.createElement(`div`);t.style.position=`relative`;let n=this.makeIconButton(`Configure levels`);return n.style.padding=`0 8px`,n.style.height=`${bc}px`,n.style.minWidth=`64px`,n.textContent=`Configure ▾`,t.appendChild(n),n.addEventListener(`click`,t=>{t.stopPropagation(),this.fibLevelsExpanded=!this.fibLevelsExpanded,this.fibLevelsExpanded?this.openFibPanel(n,e):this.closeFibPanel()}),document.addEventListener(`mousedown`,e=>{this.fibPanel&&!this.fibPanel.contains(e.target)&&!t.contains(e.target)&&(this.closeFibPanel(),this.fibLevelsExpanded=!1)}),t}buildLevelRatioLabel(e){let t=document.createElement(`span`);return t.textContent=e,Object.assign(t.style,{fontSize:`11px`,color:this.theme.tooltip.text}),t}buildLevelRatioInput(e,t,n){let r=e,i=document.createElement(`input`);return i.type=`number`,i.step=`0.001`,i.value=r,i.title=`Level ratio — press Enter to apply`,Object.assign(i.style,{width:`58px`,padding:`2px 4px`,fontSize:`11px`,fontFamily:`inherit`,color:this.theme.tooltip.text,background:this.theme.background,border:`1px solid ${this.theme.axisBorder}`,borderRadius:`3px`,outline:`none`}),i.addEventListener(`focus`,()=>{i.style.borderColor=this.theme.ui.accent}),i.addEventListener(`blur`,()=>{i.style.borderColor=this.theme.axisBorder}),i.addEventListener(`keydown`,e=>{e.stopPropagation(),e.key===`Enter`&&i.blur()}),i.addEventListener(`change`,()=>{let e=Number(i.value),a=Number.isFinite(e)?Cc(e):null;if(a===null||a!==r&&t.has(a)){i.value=r;return}if(a===r){i.value=r;return}r=a,i.value=a,n(a)}),i}openFibPanel(e,t){this.closeFibPanel();let n=document.createElement(`div`);Object.assign(n.style,{position:`absolute`,display:`grid`,gridTemplateColumns:`auto 1fr auto`,columnGap:`10px`,rowGap:`6px`,background:this.theme.tooltip.background,border:`1px solid ${this.theme.axisBorder}`,borderRadius:`6px`,padding:`10px 12px`,zIndex:`60`,boxShadow:`0 6px 18px rgba(0,0,0,0.35)`,fontFamily:`'Inter', system-ui, sans-serif`,fontSize:`11px`,color:this.theme.tooltip.text,alignItems:`center`});let r=Object.keys(t).sort((e,t)=>Number(e)-Number(t)),i=this.currentDrawing!==null&&xc.has(this.currentDrawing.type),a=new Set(r);for(let e of r){let r=t[e],o=e,s=r.color,c=document.createElement(`input`);c.type=`checkbox`,c.checked=r.visible!==!1,c.style.accentColor=this.theme.ui.accent,c.style.cursor=`pointer`;let l=this.makeColorSwatch(s,e=>{s=e,this.emit({levels:{[o]:{visible:c.checked,color:e}}})});c.addEventListener(`change`,()=>{this.emit({levels:{[o]:{visible:c.checked,color:s}}})}),n.append(c,i?this.buildLevelRatioInput(e,a,e=>{this.emit({levels:{[o]:null,[e]:{visible:c.checked,color:s}}}),a.delete(o),a.add(e),o=e}):this.buildLevelRatioLabel(e),l)}let o=e.getBoundingClientRect(),s=this.container.getBoundingClientRect();this.container.appendChild(n);let c=n.getBoundingClientRect(),l=o.left-s.left,u=o.bottom-s.top+6;l=Math.max(4,Math.min(s.width-c.width-4,l)),u+c.height>s.height-4&&(u=Math.max(4,o.top-s.top-c.height-6)),n.style.left=`${l}px`,n.style.top=`${u}px`,this.fibPanel=n}closeFibPanel(){var e;(e=this.fibPanel)==null||e.remove(),this.fibPanel=null}makeIconButton(e){let t=document.createElement(`div`);return Object.assign(t.style,{display:`flex`,alignItems:`center`,justifyContent:`center`,minWidth:`${bc}px`,height:`${bc}px`,padding:`0 4px`,borderRadius:`4px`,cursor:`pointer`,border:`1px solid transparent`,color:this.theme.tooltip.text,background:`transparent`,fontSize:`11px`,boxSizing:`border-box`}),t.title=e,t.addEventListener(`mouseenter`,()=>{t.dataset.active!==`1`&&(t.style.background=this.theme.indicatorOverlay.dropdownHoverBg)}),t.addEventListener(`mouseleave`,()=>{t.dataset.active!==`1`&&(t.style.background=`transparent`)}),t}markActive(e){e.dataset.active=`1`,e.style.background=this.theme.ui.accentBg,e.style.borderColor=this.theme.ui.accent}emit(e){this.currentDrawing&&(this.onChange(this.currentDrawing.id,e),this.rebuild())}},Tc=class{constructor(e,t,n){this._min=1,this._max=100,this._step=1,this._intendedTop=0,this._disposeKbd=()=>{},this.onDocMouseDown=e=>{this.isVisible&&!this.el.contains(e.target)&&(this.syncIfValid(),this.hide())},this.theme=e,this.onCommit=t,this.onVisibilityChange=n,this.el=document.createElement(`div`),Object.assign(this.el.style,{position:`fixed`,display:`none`,flexDirection:`row`,alignItems:`center`,gap:`4px`,background:e.tooltip.background,border:`1px solid ${e.axisBorder}`,borderRadius:`5px`,padding:`5px 7px`,zIndex:`25`,boxShadow:`0 4px 16px rgba(0,0,0,0.3)`,fontFamily:`'Inter', system-ui, sans-serif`,fontSize:`13px`,color:e.tooltip.text,pointerEvents:`auto`});let r=this.makeStepBtn(`−`,()=>this.step(-1));this.input=this.makeInput();let i=this.makeStepBtn(`+`,()=>this.step(1));this.el.append(r,this.input,i),this.el.addEventListener(`mousedown`,e=>e.stopPropagation()),this.el.addEventListener(`touchstart`,e=>e.stopPropagation()),document.addEventListener(`mousedown`,this.onDocMouseDown),this._disposeKbd=kn(this.el,()=>this._intendedTop)}show(e,t,n,r,i){var a;let o=this.isVisible;this._min=r,this._max=i,this._step=r,this.input.min=String(r),this.input.max=String(i),this.input.step=String(r),this.input.value=String(n),this._intendedTop=t+4,this.el.style.display=`flex`,this.el.style.left=`${e}px`,this.el.style.top=`${this._intendedTop}px`,o||(a=this.onVisibilityChange)==null||a.call(this)}hide(){var e;let t=this.isVisible;this.el.style.display=`none`,t&&((e=this.onVisibilityChange)==null||e.call(this))}get isVisible(){return this.el.style.display!==`none`}setTheme(e){this.theme=e,Object.assign(this.el.style,{background:e.tooltip.background,border:`1px solid ${e.axisBorder}`,color:e.tooltip.text}),this.input.style.borderBottom=`1px solid ${e.axisBorder}`}destroy(){document.removeEventListener(`mousedown`,this.onDocMouseDown),this._disposeKbd()}makeStepBtn(e,t){let n=document.createElement(`button`);return n.textContent=e,Object.assign(n.style,{background:`transparent`,border:`none`,color:`inherit`,cursor:`pointer`,fontSize:`16px`,lineHeight:`1`,padding:`0 4px`,borderRadius:`3px`,opacity:`0.7`}),n.addEventListener(`mouseenter`,()=>{n.style.opacity=`1`}),n.addEventListener(`mouseleave`,()=>{n.style.opacity=`0.7`}),n.addEventListener(`mousedown`,e=>{e.preventDefault(),t()}),n}makeInput(){let e=document.createElement(`input`);return e.type=`number`,Object.assign(e.style,{width:`64px`,background:`transparent`,border:`none`,borderBottom:`1px solid ${this.theme.axisBorder}`,color:`inherit`,font:`16px 'Inter', system-ui, sans-serif`,outline:`none`,textAlign:`center`,padding:`1px 2px`}),e.addEventListener(`focus`,()=>{e.select()}),e.addEventListener(`input`,()=>{this.syncIfValid()}),e.addEventListener(`keydown`,e=>{e.key===`Enter`?(e.preventDefault(),this.syncIfValid(),this.hide()):e.key===`Escape`&&(e.preventDefault(),this.hide())}),e.addEventListener(`blur`,()=>{this.isVisible&&(this.syncIfValid(),this.hide())}),e}step(e){let t=parseFloat(this.input.value)||this._min,n=Math.round((t+e*this._step)*1e10)/1e10;this.input.value=String(Math.min(this._max,Math.max(this._min,n))),this.syncIfValid()}syncIfValid(){let e=parseFloat(this.input.value);!isNaN(e)&&e>=this._min&&e<=this._max&&this.onCommit(e)}},Ec=50,Dc=20,Oc=class{constructor(e,t,n){this.isins=[],this.currentSymbol=``,this.mode=`select`,this.activeSymbols=new Set,this.escHandler=null,this.disposeKbd=()=>{},this.theme=e,this.onSelect=t,this.onVisibilityChange=n,this.el=document.createElement(`div`),Object.assign(this.el.style,{position:`fixed`,inset:`0`,background:`rgba(0,0,0,0.5)`,display:`none`,alignItems:`center`,justifyContent:`center`,zIndex:`1000`}),this.el.addEventListener(`mousedown`,e=>{e.target===this.el&&this.hide()}),this.panel=document.createElement(`div`),Object.assign(this.panel.style,{display:`flex`,flexDirection:`column`,width:`360px`,maxHeight:`520px`,background:e.tooltip.background,border:`1px solid ${e.axisBorder}`,borderRadius:`6px`,boxShadow:`0 8px 32px rgba(0,0,0,0.45)`,fontFamily:`'Inter', system-ui, sans-serif`,fontSize:`12px`,overflow:`hidden`}),this.panel.addEventListener(`mousedown`,e=>e.stopPropagation()),this.el.appendChild(this.panel);let r=document.createElement(`div`);Object.assign(r.style,{display:`flex`,alignItems:`center`,justifyContent:`space-between`,padding:`10px 14px`,borderBottom:`1px solid ${e.axisBorder}`,flexShrink:`0`});let i=document.createElement(`span`);i.textContent=`Select Symbol`,Object.assign(i.style,{color:e.tooltip.text,fontWeight:`600`,fontSize:`13px`}),this.titleEl=i;let a=document.createElement(`span`);a.innerHTML=Qt,Object.assign(a.style,{display:`inline-flex`,alignItems:`center`,color:e.axisText,cursor:`pointer`}),a.addEventListener(`mouseenter`,()=>{a.style.color=e.tooltip.text}),a.addEventListener(`mouseleave`,()=>{a.style.color=e.axisText}),a.addEventListener(`click`,()=>this.hide()),r.appendChild(i),r.appendChild(a),this.panel.appendChild(r);let o=document.createElement(`div`);Object.assign(o.style,{padding:`8px 14px`,borderBottom:`1px solid ${e.axisBorder}`,flexShrink:`0`}),this.searchInput=document.createElement(`input`),this.searchInput.type=`text`,this.searchInput.placeholder=`Search symbols…`,Object.assign(this.searchInput.style,{width:`100%`,boxSizing:`border-box`,background:`transparent`,border:`1px solid ${e.axisBorder}`,borderRadius:`4px`,color:e.tooltip.text,fontSize:`16px`,padding:`5px 8px`,outline:`none`}),this.searchInput.addEventListener(`input`,()=>this.renderList()),o.appendChild(this.searchInput),this.panel.appendChild(o),this.listEl=document.createElement(`div`),Object.assign(this.listEl.style,{overflowY:`auto`,flex:`1`,scrollbarWidth:`thin`,scrollbarColor:`rgba(120,130,150,0.35) transparent`}),this.panel.appendChild(this.listEl),this.disposeKbd=An(this.panel)}show(e,t){var n;let r=this.isVisible;this.isins=e,this.currentSymbol=t,this.searchInput.value=``,this.renderList(),this.el.style.display=`flex`,requestAnimationFrame(()=>this.searchInput.focus({preventScroll:!0})),this.escHandler=e=>{e.key===`Escape`&&this.hide()},document.addEventListener(`keydown`,this.escHandler),r||(n=this.onVisibilityChange)==null||n.call(this)}hide(){var e;let t=this.isVisible;this.el.style.display=`none`,this.escHandler&&(document.removeEventListener(`keydown`,this.escHandler),this.escHandler=null),t&&((e=this.onVisibilityChange)==null||e.call(this))}get isVisible(){return this.el.style.display!==`none`}setCurrentSymbol(e){this.currentSymbol=e,this.el.style.display!==`none`&&this.renderList()}setIsins(e){this.isins=e}setMode(e){this.mode=e,this.el.style.display!==`none`&&this.renderList()}setActiveSymbols(e){this.activeSymbols=new Set(e),this.el.style.display!==`none`&&this.renderList()}setTitle(e){this.titleEl.textContent=e}setTheme(e){this.theme=e,Object.assign(this.panel.style,{background:e.tooltip.background,border:`1px solid ${e.axisBorder}`})}destroy(){this.escHandler&&document.removeEventListener(`keydown`,this.escHandler),this.disposeKbd(),this.el.remove()}sortWithCurrentFirst(e){if(!this.currentSymbol)return e;let t=e.indexOf(this.currentSymbol);if(t<=0)return e;let n=e.slice();return n.splice(t,1),n.unshift(this.currentSymbol),n}renderList(){let e=this.searchInput.value.trim().toLowerCase(),t=this.sortWithCurrentFirst(e?this.isins.filter(t=>t.toLowerCase().includes(e)).slice(0,Dc):this.isins.slice(0,Ec));if(this.listEl.innerHTML=``,t.length===0){let e=document.createElement(`div`);e.textContent=`No symbols found`,Object.assign(e.style,{padding:`16px 14px`,color:this.theme.axisText,textAlign:`center`}),this.listEl.appendChild(e);return}let n=this.mode===`toggle`;for(let e of t){let t=e===this.currentSymbol,r=n&&this.activeSymbols.has(e),i=!n||!t,a=t,o=document.createElement(`div`);if(Object.assign(o.style,{display:`flex`,alignItems:`center`,gap:`8px`,padding:`8px 14px`,cursor:i?`pointer`:`default`,color:a?this.theme.ui.accentText:this.theme.tooltip.text,background:a?this.theme.ui.accentBg:`transparent`,fontWeight:a?`600`:`400`,borderLeft:a?`2px solid ${this.theme.ui.accent}`:`2px solid transparent`,boxSizing:`border-box`,userSelect:`none`,opacity:i?`1`:`0.7`}),n){let e=document.createElement(`span`);e.textContent=t?``:r?`−`:`+`,Object.assign(e.style,{display:`inline-flex`,alignItems:`center`,justifyContent:`center`,width:`16px`,height:`16px`,fontSize:`14px`,lineHeight:`1`,fontWeight:`700`,color:r?this.theme.axisText:this.theme.ui.accent,flexShrink:`0`}),o.appendChild(e)}let s=document.createElement(`span`);s.textContent=e,s.style.flex=`1`,o.appendChild(s),o.addEventListener(`mouseenter`,()=>{!a&&i&&(o.style.background=this.theme.ui.accentBg)}),o.addEventListener(`mouseleave`,()=>{a||(o.style.background=`transparent`)}),o.addEventListener(`click`,()=>{i&&(this.onSelect(e),n||this.hide())}),this.listEl.appendChild(o)}}},kc=class{constructor(e){this.chips=new Map,this.theme=e.theme,this.onRemove=e.onRemove,this.el=document.createElement(`div`),Object.assign(this.el.style,{display:`flex`,flexWrap:`wrap`,alignItems:`center`,gap:`6px`,pointerEvents:`auto`})}setTheme(e){this.theme=e;for(let t of this.chips.values()){t.style.border=`1px solid ${e.axisBorder}`,t.style.background=e.tooltip.background;let n=t.querySelector(`[data-role="symbol"]`);n&&(n.style.color=e.tooltip.text)}}update(e){let t=new Set;for(let n of e){t.add(n.symbol);let e=this.chips.get(n.symbol);e||(e=this.createChip(n),this.chips.set(n.symbol,e),this.el.appendChild(e)),this.updateChip(e,n)}for(let[e,n]of[...this.chips.entries()])t.has(e)||(n.remove(),this.chips.delete(e))}clear(){for(let e of this.chips.values())e.remove();this.chips.clear()}destroy(){this.clear(),this.el.remove()}createChip(e){let t=document.createElement(`div`);Object.assign(t.style,{display:`inline-flex`,alignItems:`center`,gap:`6px`,padding:`2px 6px`,borderRadius:`4px`,background:this.theme.tooltip.background,border:`1px solid ${this.theme.axisBorder}`,fontSize:`11px`,fontFamily:`inherit`,lineHeight:`1`,whiteSpace:`nowrap`,userSelect:`none`});let n=document.createElement(`span`);n.dataset.role=`dot`,Object.assign(n.style,{width:`8px`,height:`8px`,borderRadius:`9999px`,background:e.color,display:`inline-block`,flexShrink:`0`});let r=document.createElement(`span`);r.dataset.role=`symbol`,r.textContent=e.symbol,Object.assign(r.style,{color:this.theme.tooltip.text,fontWeight:`600`});let i=document.createElement(`span`);i.dataset.role=`value`,Object.assign(i.style,{color:this.theme.axisText,fontVariantNumeric:`tabular-nums`});let a=document.createElement(`span`);return a.dataset.role=`close`,a.textContent=`×`,Object.assign(a.style,{color:this.theme.axisText,cursor:`pointer`,fontSize:`14px`,lineHeight:`1`,padding:`0 2px`,marginLeft:`2px`}),a.addEventListener(`click`,t=>{t.stopPropagation(),this.onRemove(e.symbol)}),a.addEventListener(`mouseenter`,()=>{a.style.color=this.theme.tooltip.text}),a.addEventListener(`mouseleave`,()=>{a.style.color=this.theme.axisText}),t.append(n,r,i,a),t}updateChip(e,t){let n=e.querySelector(`[data-role="dot"]`);n&&n.style.background!==t.color&&(n.style.background=t.color);let r=e.querySelector(`[data-role="value"]`);if(r){if(t.status===`loading`){r.textContent=`…`,r.style.color=this.theme.axisText,e.title=`Loading…`;return}if(t.status===`error`){var i;r.textContent=`error`,r.style.color=this.theme.ui.stream.disconnected,e.title=(i=t.errorMessage)==null?`Failed to load`:i;return}if(e.title=``,t.percent==null){r.textContent=`—`,r.style.color=this.theme.axisText;return}r.textContent=`${t.percent>=0?`+`:``}${t.percent.toFixed(2)}%`,r.style.color=t.percent>=0?this.theme.candle.up:this.theme.candle.down}}},Ac=[`#2962FF`,`#FF6D00`,`#00BFA5`,`#D500F9`,`#FFD600`,`#76FF03`,`#FF1744`,`#00B0FF`],jc=class{constructor(e){var t;this.entries=new Map,this.order=[],this.generation=0,this.lastParams=null,this.nextColorIndex=0,this.emitter=e.emitter,this.loader=e.loader,this.palette=e.palette&&e.palette.length>0?e.palette:Ac,this.maxCompares=Math.max(1,(t=e.maxCompares)==null?8:t)}setLoader(e){this.loader=e}setLastParams(e){this.lastParams={...e}}isActive(){return this.entries.size>0}has(e){return this.entries.has(e)}list(){return this.order.map(e=>this.entries.get(e)).filter(e=>e!==void 0)}async add(e){if(!e||this.entries.has(e))return;if(this.entries.size>=this.maxCompares){this.emitter.emit(`compareError`,{symbol:e,message:`Maximum of ${this.maxCompares} compare symbols reached`});return}if(!this.loader){this.emitter.emit(`compareError`,{symbol:e,message:`No compareDataLoader configured`});return}if(!this.lastParams){this.emitter.emit(`compareError`,{symbol:e,message:`Primary chart has no loaded range yet`});return}let t=this.assignColor(),n={symbol:e,color:t,bars:[],status:`loading`};this.entries.set(e,n),this.order.push(e),this.emitter.emit(`compareAdded`,{symbol:e,color:t}),await this.fetchOne(n,this.lastParams,this.generation)}remove(e){if(!this.entries.has(e))return;this.entries.delete(e);let t=this.order.indexOf(e);t>=0&&this.order.splice(t,1),this.emitter.emit(`compareRemoved`,{symbol:e})}clear(){let e=[...this.order];this.entries.clear(),this.order.length=0;for(let t of e)this.emitter.emit(`compareRemoved`,{symbol:t})}async refetchAll(e){if(this.setLastParams(e),!this.loader||this.entries.size===0)return;this.generation++;let t=this.generation,n=this.list();for(let e of n)e.status=`loading`,e.errorMessage=void 0;await Promise.all(n.map(n=>this.fetchOne(n,e,t)))}async fetchOne(e,t,n){let r=this.loader;if(r)try{let i=await r({...t,symbol:e.symbol});if(n!==this.generation||!this.entries.has(e.symbol))return;e.bars=[...i].sort((e,t)=>e.time-t.time),e.status=`ready`,e.errorMessage=void 0}catch(t){if(n!==this.generation||!this.entries.has(e.symbol))return;e.status=`error`,e.errorMessage=t instanceof Error?t.message:String(t),this.emitter.emit(`compareError`,{symbol:e.symbol,message:e.errorMessage})}}assignColor(){let e=new Set(this.list().map(e=>e.color));for(let t=0;t<this.palette.length;t++){let n=(this.nextColorIndex+t)%this.palette.length,r=this.palette[n];if(!e.has(r))return this.nextColorIndex=(n+1)%this.palette.length,r}let t=this.palette[this.nextColorIndex%this.palette.length];return this.nextColorIndex=(this.nextColorIndex+1)%this.palette.length,t}};function Mc(e,t){return`${e}#${t}`}function Nc(e,t){if(e.length===0)throw Error(`cycleIndicatorColor: empty palette`);let n=e[t%e.length];if(n===void 0)throw Error(`cycleIndicatorColor: index out of range`);return n}function Pc(e,t){let n=e.filter(e=>e.instanceId===t);return n.length>0?n:e.filter(e=>e.shortName===t)}function Fc(e,t){return t===0||!Number.isFinite(t)?0:(e-t)/t*100}function Ic(e,t){if(t===0||!Number.isFinite(t))return e;let n=Array(e.length);for(let r=0;r<e.length;r++){let i=e[r];n[r]={time:i.time,open:Fc(i.open,t),high:Fc(i.high,t),low:Fc(i.low,t),close:Fc(i.close,t),volume:i.volume}}return n}function Lc(e,t){if(t===0||!Number.isFinite(t))return e;let n=Array(e.length);for(let r=0;r<e.length;r++){let i=e[r];n[r]={index:i.index,value:i.value==null?i.value:Fc(i.value,t),upper:i.upper==null?i.upper:Fc(i.upper,t),lower:i.lower==null?i.lower:Fc(i.lower,t),signal:i.signal,histogram:i.histogram}}return n}function Rc(e,t,n,r=.05){let i=1/0,a=-1/0;for(let n of e){let e=Fc(n.low,t),r=Fc(n.high,t);e<i&&(i=e),r>a&&(a=r)}for(let e of n)for(let t of e)t.pct<i&&(i=t.pct),t.pct>a&&(a=t.pct);if(!Number.isFinite(i)||!Number.isFinite(a))return{min:-1,max:1};if(i===a)return{min:i-1,max:a+1};let o=a-i;return{min:i-o*r,max:a+o*r}}function zc(e,t,n){if(e.length===0||t.length===0)return[];let r=t[Math.max(0,Math.min(t.length-1,Math.floor(n)))],i=Bc(e,r),a=i>=0?e[i].close:e[0].close;return a===0||!Number.isFinite(a)?e.map(e=>({time:e.time,pct:null})):e.map(e=>({time:e.time,pct:Fc(e.close,a)}))}function Bc(e,t){let n=0,r=e.length-1,i=-1;for(;n<=r;){let a=n+r>>1;e[a].time>=t?(i=a,r=a-1):n=a+1}return i}var Vc=class e{constructor(){this._active=!1,this._isDraggingBracket=!1,this._level=null,this._startPrice=0,this._currentPrice=0,this._pixelOffset=0,this._mainMinPrice=-1/0,this._mainMaxPrice=1/0,this._bracketType=null,this._bracketStartPrice=0,this._bracketCurrentPrice=0,this._bracketPixelOffset=0,this._bracketParentPrice=0,this._bracketParentSide=`buy`,this._bracketMarketPrice=0,this._followBrackets=!1}startDrag(e,t,n,r,i,a,o,s,c,l){this._active=!0,this._isDraggingBracket=!1,this._level=e,this._pixelOffset=t-n,this._startPrice=r,this._currentPrice=r,this._bracketType=null,this._followBrackets=l===!0,this._slStartPrice=i,this._tpStartPrice=a,this._derivedSLPrice=i,this._derivedTPPrice=a,this._followBrackets?(this._mainMinPrice=-1/0,this._mainMaxPrice=1/0):i!==void 0||a!==void 0?(o==null?`buy`:o)===`buy`?(this._mainMinPrice=i==null?-1/0:i,this._mainMaxPrice=a==null?1/0:a):(this._mainMinPrice=a==null?-1/0:a,this._mainMaxPrice=i==null?1/0:i):(this._mainMinPrice=-1/0,this._mainMaxPrice=1/0),s&&s>0&&c&&c!==`market`&&o&&(o===`buy`&&c===`limit`||o===`sell`&&c===`stop`?this._mainMaxPrice=Math.min(this._mainMaxPrice,s):this._mainMinPrice=Math.max(this._mainMinPrice,s))}startBracketDrag(e,t,n,r,i,a=0,o){var s;this._active=!0,this._isDraggingBracket=!0,this._level=e,this._bracketType=t,this._bracketStartPrice=n,this._bracketCurrentPrice=n,this._bracketPixelOffset=r-i,this._bracketParentPrice=o==null?e.price:o,this._bracketParentSide=(s=e.side)==null?`buy`:s,this._bracketMarketPrice=a}onMouseMove(e,t,n,r){if(!this._active||!this._level)return null;if(this._isDraggingBracket&&this._bracketType!==null){let i=e-this._bracketPixelOffset,a=t.pixelToPrice(i,n,r),o=this._clampBracketPrice(a,this._bracketType,this._bracketParentPrice,this._bracketParentSide,this._bracketMarketPrice);return this._bracketCurrentPrice=o,{newPrice:o,label:`${this._level.label}:${this._bracketType}`,isBracket:!0}}let i=e-this._pixelOffset,a=t.pixelToPrice(i,n,r),o=Math.max(this._mainMinPrice,Math.min(this._mainMaxPrice,a));if(this._currentPrice=o,this._followBrackets){let e=o-this._startPrice;return this._derivedSLPrice=this._slStartPrice===void 0?void 0:this._slStartPrice+e,this._derivedTPPrice=this._tpStartPrice===void 0?void 0:this._tpStartPrice+e,{newPrice:o,label:this._level.label,isBracket:!1,derivedSLPrice:this._derivedSLPrice,derivedTPPrice:this._derivedTPPrice}}return{newPrice:o,label:this._level.label,isBracket:!1}}endDrag(){if(!this._active||!this._level)return null;let e=this._level,t;return t=this._isDraggingBracket&&this._bracketType!==null?{label:e.label,type:e.type,newPrice:this._bracketCurrentPrice,startPrice:this._bracketStartPrice,data:e.data,bracketType:this._bracketType}:this._followBrackets?{label:e.label,type:e.type,newPrice:this._currentPrice,startPrice:this._startPrice,data:e.data,derivedSLPrice:this._derivedSLPrice,derivedTPPrice:this._derivedTPPrice,slStartPrice:this._slStartPrice,tpStartPrice:this._tpStartPrice}:{label:e.label,type:e.type,newPrice:this._currentPrice,startPrice:this._startPrice,data:e.data},this._reset(),t}cancelDrag(){this._reset()}get active(){return this._active}get dragLabel(){return!this._active||!this._level?null:this._isDraggingBracket&&this._bracketType?`${this._level.label}:${this._bracketType}`:this._level.label}get currentPrice(){return this._active?this._isDraggingBracket?this._bracketCurrentPrice:this._currentPrice:null}static isBracketPriceValid(e,t,n,r,i=0){let a=i>0?i:n;return r===`buy`?t===`stopLoss`?e<a:e>a:t===`stopLoss`?e>a:e<a}_clampBracketPrice(t,n,r,i,a=0){return e.isBracketPriceValid(t,n,r,i,a)?t:a>0?a:r}_reset(){this._active=!1,this._isDraggingBracket=!1,this._level=null,this._bracketType=null,this._currentPrice=0,this._pixelOffset=0,this._mainMinPrice=-1/0,this._mainMaxPrice=1/0,this._bracketStartPrice=0,this._bracketCurrentPrice=0,this._bracketPixelOffset=0,this._bracketParentPrice=0,this._bracketParentSide=`buy`,this._bracketMarketPrice=0,this._followBrackets=!1,this._slStartPrice=void 0,this._tpStartPrice=void 0,this._derivedSLPrice=void 0,this._derivedTPPrice=void 0}},Hc=class e{constructor(){this._active=!1,this._level=null,this._startBarIndex=0,this._startTimestamp=0,this._currentBarIndex=0,this._pixelOffset=0}start(e,t,n,r,i){this._active=!0,this._level=e,this._pixelOffset=t-n,this._startBarIndex=r,this._startTimestamp=i,this._currentBarIndex=r}onMove(t,n,r,i){if(!this._active||!this._level)return null;let a=t-this._pixelOffset,o=n.pixelToBarIndex(a,r,i);return this._currentBarIndex=e.clampToViewport(o,r),this._currentBarIndex}end(t,n){if(!this._active||!this._level)return null;let r=this._level,i=t?Math.round(this._currentBarIndex):this._currentBarIndex,a=e.clampToViewport(i,n),o={label:r.label,type:r.type,data:r.data,startBarIndex:this._startBarIndex,startTimestamp:this._startTimestamp,newBarIndex:a};return this._reset(),o}cancel(){this._reset()}get active(){return this._active}get dragLabel(){return this._active&&this._level?this._level.label:null}get currentBarIndex(){return this._active?this._currentBarIndex:null}get startTimestamp(){return this._startTimestamp}get startBarIndex(){return this._startBarIndex}static clampToViewport(e,t){return Math.max(t.startIndex,Math.min(t.endIndex,e))}_reset(){this._active=!1,this._level=null,this._startBarIndex=0,this._startTimestamp=0,this._currentBarIndex=0,this._pixelOffset=0}};function Uc(e,t){return e[t]}var Wc=class{constructor(e,t=`#F5A623`,n=`MA`,r=`close`){this.period=e,this.source=r,this.name=n,this.color=t}compute(e){return e.map((t,n)=>{if(n<this.period-1)return{index:n,value:null};let r=0;for(let t=n-this.period+1;t<=n;t++)r+=Uc(e[t],this.source);return{index:n,value:r/this.period}})}render(e,t,n,r,i){var a;let o=Gc(e);if(!o)return;e.beginPath(),e.strokeStyle=this.color,e.lineWidth=1.5,e.lineJoin=`round`;let s=!1,c=(a=e.canvas._chartWidth)==null?e.canvas.width:a;for(let a of t){if(a.value===null){s=!1;continue}let t=n.xToPixel(a.index,r,c),l=n.yToPixel(a.value,o,i);s?e.lineTo(t,l):(e.moveTo(t,l),s=!0)}e.stroke()}};function Gc(e){var t;return(t=e.canvas._priceRange)==null?null:t}var Kc=class{constructor(e,t=`#9B59B6`,n=`EMA`,r=`close`){this.period=e,this.source=r,this.name=n,this.color=t}compute(e){let t=2/(this.period+1),n=[],r=null;for(let i=0;i<e.length;i++){if(i<this.period-1){n.push({index:i,value:null});continue}if(r===null){let t=0;for(let n=0;n<this.period;n++)t+=Uc(e[i-n],this.source);r=t/this.period}else r=Uc(e[i],this.source)*t+r*(1-t);n.push({index:i,value:r})}return n}render(e,t,n,r,i){var a;let o=e.canvas._priceRange;if(!o)return;e.beginPath(),e.strokeStyle=this.color,e.lineWidth=1.5,e.lineJoin=`round`;let s=!1,c=(a=e.canvas._chartWidth)==null?e.canvas.width:a;for(let a of t){if(a.value===null){s=!1;continue}let t=n.xToPixel(a.index,r,c),l=n.yToPixel(a.value,o,i);s?e.lineTo(t,l):(e.moveTo(t,l),s=!0)}e.stroke()}},qc=class{constructor(e=20,t=`#e91e63`,n=`WMA`,r=`close`){this.period=e,this.source=r,this.name=n,this.color=t}compute(e){let t=this.period*(this.period+1)/2,n=[];for(let r=0;r<e.length;r++){if(r<this.period-1){n.push({index:r,value:null});continue}let i=0;for(let t=0;t<this.period;t++)i+=Uc(e[r-(this.period-1-t)],this.source)*(t+1);n.push({index:r,value:i/t})}return n}render(e,t,n,r,i){var a;let o=e.canvas,s=o._priceRange;if(!s)return;let c=(a=o._chartWidth)==null?e.canvas.width:a;e.beginPath(),e.strokeStyle=this.color,e.lineWidth=1.5,e.lineJoin=`round`;let l=!1;for(let a of t){if(a.value===null){l=!1;continue}let t=n.xToPixel(a.index,r,c),o=n.yToPixel(a.value,s,i);l?e.lineTo(t,o):(e.moveTo(t,o),l=!0)}e.stroke()}};function Jc(e,t){let n=t*(t+1)/2,r=[];for(let i=0;i<e.length;i++){if(i<t-1){r.push(null);continue}let a=0;for(let n=0;n<t;n++)a+=e[i-(t-1-n)]*(n+1);r.push(a/n)}return r}var Yc=class{constructor(e=20,t=`#00bcd4`,n=`HMA`,r=`close`){this.period=e,this.source=r,this.name=n,this.color=t}compute(e){let t=e.map(e=>Uc(e,this.source)),n=Math.floor(this.period/2),r=Math.floor(Math.sqrt(this.period)),i=Jc(t,n),a=Jc(t,this.period),o=i.map((e,t)=>{let n=a[t];return e===null||n===null?null:2*e-n}),s=Jc(o.map(e=>e===null?0:e),r);return e.map((e,t)=>{let n=t-r+1;return n<0||!(o[n]!==null&&o[t]!==null)||s[t]===null?{index:t,value:null}:{index:t,value:s[t]}})}render(e,t,n,r,i){var a;let o=e.canvas,s=o._priceRange;if(!s)return;let c=(a=o._chartWidth)==null?e.canvas.width:a;e.beginPath(),e.strokeStyle=this.color,e.lineWidth=1.5,e.lineJoin=`round`;let l=!1;for(let a of t){if(a.value===null){l=!1;continue}let t=n.xToPixel(a.index,r,c),o=n.yToPixel(a.value,s,i);l?e.lineTo(t,o):(e.moveTo(t,o),l=!0)}e.stroke()}},Xc=[5,10,20,50,100],Zc=[`#ff6b6b`,`#ffd93d`,`#6bcb77`,`#4d96ff`,`#c77dff`],Qc=class{constructor(e=`#ffcc80`,t=`close`){this.source=t,this.name=`MARibbon`,this.color=e}compute(e){let t=(t,n)=>{if(t<n-1)return null;let r=0;for(let i=t-n+1;i<=t;i++)r+=Uc(e[i],this.source);return r/n};return e.map((e,n)=>({index:n,value:t(n,5),upper:t(n,10),lower:t(n,20),signal:t(n,50),histogram:t(n,100)}))}render(e,t,n,r,i){var a;let o=e.canvas,s=o._priceRange;if(!s)return;let c=(a=o._chartWidth)==null?e.canvas.width:a;e.lineWidth=1,e.lineJoin=`round`;let l=[`value`,`upper`,`lower`,`signal`,`histogram`];for(let a=0;a<Xc.length;a++){let o=l[a],u=Zc[a];e.beginPath(),e.strokeStyle=u;let d=!1;for(let a of t){let t=a[o];if(t==null){d=!1;continue}let l=n.xToPixel(a.index,r,c),u=n.yToPixel(t,s,i);d?e.lineTo(l,u):(e.moveTo(l,u),d=!0)}e.stroke()}}},$c=class{constructor(e=20,t=2,n=`#3B82F6`,r=`BB`,i=`close`){this.period=e,this.stdDevMultiplier=t,this.source=i,this.name=r,this.color=n}compute(e){return e.map((t,n)=>{if(n<this.period-1)return{index:n,value:null,upper:null,lower:null};let r=e.slice(n-this.period+1,n+1).map(e=>Uc(e,this.source)),i=r.reduce((e,t)=>e+t,0)/this.period,a=r.reduce((e,t)=>e+(t-i)**2,0)/this.period,o=Math.sqrt(a);return{index:n,value:i,upper:i+o*this.stdDevMultiplier,lower:i-o*this.stdDevMultiplier}})}render(e,t,n,r,i){var a;let o=e.canvas._priceRange;if(!o)return;let s=(a=e.canvas._chartWidth)==null?e.canvas.width:a;e.lineWidth=1,e.lineJoin=`round`;let c=(a,c=!1)=>{c&&e.setLineDash([4,3]),e.beginPath();let l=!1;for(let c of t){let t=a(c);if(t==null){l=!1;continue}let u=n.xToPixel(c.index,r,s),d=n.yToPixel(t,o,i);l?e.lineTo(u,d):(e.moveTo(u,d),l=!0)}e.stroke(),c&&e.setLineDash([])};e.strokeStyle=this.color,c(e=>e.value),e.strokeStyle=`${this.color}99`,c(e=>e.upper,!0),c(e=>e.lower,!0);let l=[],u=[];for(let e of t){if(e.upper==null||e.lower==null)continue;let t=n.xToPixel(e.index,r,s);l.push([t,n.yToPixel(e.upper,o,i)]),u.push([t,n.yToPixel(e.lower,o,i)])}l.length<2||(e.beginPath(),l.forEach(([t,n],r)=>r===0?e.moveTo(t,n):e.lineTo(t,n)),u.reverse().forEach(([t,n])=>e.lineTo(t,n)),e.closePath(),e.fillStyle=`${this.color}12`,e.fill())}},el=class{constructor(e=20,t=2,n=10,r=`#4caf50`,i=`KC`){this.period=e,this.mult=t,this.atrPeriod=n,this.name=i,this.color=r}compute(e){let t=[],n=2/(this.period+1),r=null,i=null;for(let a=0;a<e.length;a++){let o=e[a];if(a<this.period-1){t.push({index:a,value:null,upper:null,lower:null});continue}if(r===null){let t=0;for(let n=0;n<this.period;n++)t+=e[a-n].close;r=t/this.period}else r=o.close*n+r*(1-n);let s=a===0?o.high-o.low:Math.max(o.high-o.low,Math.abs(o.high-e[a-1].close),Math.abs(o.low-e[a-1].close));if(i===null){let t=0;for(let n=0;n<this.atrPeriod;n++){let r=e[a-n],i=a-n>0?e[a-n-1]:null,o=i==null?r.high-r.low:Math.max(r.high-r.low,Math.abs(r.high-i.close),Math.abs(r.low-i.close));t+=o}i=t/this.atrPeriod}else i=(i*(this.atrPeriod-1)+s)/this.atrPeriod;let c=r+this.mult*i,l=r-this.mult*i;t.push({index:a,value:r,upper:c,lower:l})}return t}render(e,t,n,r,i){var a;let o=e.canvas,s=o._priceRange;if(!s)return;let c=(a=o._chartWidth)==null?e.canvas.width:a;e.lineWidth=1,e.lineJoin=`round`;let l=(a,o=!1)=>{o&&e.setLineDash([4,3]),e.beginPath();let l=!1;for(let o of t){let t=a(o);if(t==null){l=!1;continue}let u=n.xToPixel(o.index,r,c),d=n.yToPixel(t,s,i);l?e.lineTo(u,d):(e.moveTo(u,d),l=!0)}e.stroke(),o&&e.setLineDash([])};e.strokeStyle=this.color,l(e=>e.value),e.strokeStyle=`${this.color}99`,l(e=>e.upper,!0),l(e=>e.lower,!0);let u=[],d=[];for(let e of t){if(e.upper==null||e.lower==null)continue;let t=n.xToPixel(e.index,r,c);u.push([t,n.yToPixel(e.upper,s,i)]),d.push([t,n.yToPixel(e.lower,s,i)])}u.length<2||(e.beginPath(),u.forEach(([t,n],r)=>r===0?e.moveTo(t,n):e.lineTo(t,n)),d.reverse().forEach(([t,n])=>e.lineTo(t,n)),e.closePath(),e.fillStyle=`${this.color}12`,e.fill())}},tl=class{constructor(e=20,t=`#26c6da`){this.period=e,this.name=`DC`,this.color=t}compute(e){return e.map((t,n)=>{if(n<this.period-1)return{index:n,value:null,upper:null,lower:null};let r=-1/0,i=1/0;for(let t=n-this.period+1;t<=n;t++)e[t].high>r&&(r=e[t].high),e[t].low<i&&(i=e[t].low);return{index:n,value:(r+i)/2,upper:r,lower:i}})}render(e,t,n,r,i){var a;let o=e.canvas,s=o._priceRange;if(!s)return;let c=(a=o._chartWidth)==null?e.canvas.width:a;e.lineWidth=1,e.lineJoin=`round`;let l=(a,o=!1)=>{o&&e.setLineDash([4,3]),e.beginPath();let l=!1;for(let o of t){let t=a(o);if(t==null){l=!1;continue}let u=n.xToPixel(o.index,r,c),d=n.yToPixel(t,s,i);l?e.lineTo(u,d):(e.moveTo(u,d),l=!0)}e.stroke(),o&&e.setLineDash([])};e.strokeStyle=this.color,l(e=>e.value,!0),e.strokeStyle=`${this.color}99`,l(e=>e.upper),l(e=>e.lower);let u=[],d=[];for(let e of t){if(e.upper==null||e.lower==null)continue;let t=n.xToPixel(e.index,r,c);u.push([t,n.yToPixel(e.upper,s,i)]),d.push([t,n.yToPixel(e.lower,s,i)])}u.length<2||(e.beginPath(),u.forEach(([t,n],r)=>r===0?e.moveTo(t,n):e.lineTo(t,n)),d.slice().reverse().forEach(([t,n])=>e.lineTo(t,n)),e.closePath(),e.fillStyle=`${this.color}14`,e.fill())}},nl=class{constructor(e=14,t=`#ff5722`,n=`ATR`){this.period=e,this.pane=`sub`,this.paneHeight=80,this.name=n,this.color=t}compute(e){let t=[];if(e.length===0)return t;let n=[];for(let t=0;t<e.length;t++)if(t===0)n.push(e[t].high-e[t].low);else{let r=e[t-1].close;n.push(Math.max(e[t].high-e[t].low,Math.abs(e[t].high-r),Math.abs(e[t].low-r)))}if(e.length<this.period)return e.map((e,t)=>({index:t,value:null}));let r=0;for(let e=0;e<this.period;e++)r+=n[e];r/=this.period;for(let e=0;e<this.period-1;e++)t.push({index:e,value:null});t.push({index:this.period-1,value:r});for(let i=this.period;i<e.length;i++)r=(r*(this.period-1)+n[i])/this.period,t.push({index:i,value:r});return t}getValueRange(e){let t=1e-4;for(let n of e)n.value!=null&&(t=Math.max(t,n.value));return{min:0,max:t*1.2}}render(e,t,n,r,i,a){var o;let s=(o=e.canvas._chartWidth)==null?e.canvas.width:o,c=1e-4;for(let e of t)e.value!=null&&(c=Math.max(c,e.value));let l=a==null?{min:0,max:c*1.2}:a,u=[];for(let e of t)e.value!=null&&u.push({x:n.xToPixel(e.index,r,s),y:n.yToPixel(e.value,l,i)});if(u.length===0)return;let d=n.yToPixel(0,l,i);e.beginPath(),e.moveTo(u[0].x,d);for(let t of u)e.lineTo(t.x,t.y);e.lineTo(u[u.length-1].x,d),e.closePath(),e.fillStyle=this.color+`33`,e.fill(),e.beginPath(),e.strokeStyle=this.color,e.lineWidth=1.5,e.lineJoin=`round`;let f=!1;for(let a of t){if(a.value==null){f=!1;continue}let t=n.xToPixel(a.index,r,s),o=n.yToPixel(a.value,l,i);f?e.lineTo(t,o):(e.moveTo(t,o),f=!0)}e.stroke()}},rl=class{constructor(e=14,t=`#e8b84b`,n=`RSI`,r=`close`){this.period=e,this.source=r,this.pane=`sub`,this.paneHeight=80,this.name=n,this.color=t}compute(e){let t=[];if(e.length<this.period+1)return e.map((e,t)=>({index:t,value:null}));let n=0,r=0;for(let t=1;t<=this.period;t++){let i=Uc(e[t],this.source)-Uc(e[t-1],this.source);i>0?n+=i:r+=Math.abs(i)}n/=this.period,r/=this.period;for(let e=0;e<this.period;e++)t.push({index:e,value:null});let i=r===0?1/0:n/r;t.push({index:this.period,value:r===0?100:100-100/(1+i)});for(let i=this.period+1;i<e.length;i++){let a=Uc(e[i],this.source)-Uc(e[i-1],this.source),o=a>0?a:0,s=a<0?Math.abs(a):0;n=(n*(this.period-1)+o)/this.period,r=(r*(this.period-1)+s)/this.period;let c=r===0?1/0:n/r;t.push({index:i,value:r===0?100:100-100/(1+c)})}return t}getValueRange(e){return{min:0,max:100}}render(e,t,n,r,i,a){var o;let s=(o=e.canvas._chartWidth)==null?e.canvas.width:o,c=a==null?{min:0,max:100}:a,l=n.yToPixel(70,c,i),u=n.yToPixel(30,c,i);e.fillStyle=`rgba(239,83,80,0.06)`,e.fillRect(0,0,s,l),e.fillStyle=`rgba(38,166,154,0.06)`,e.fillRect(0,u,s,i-u),e.save(),e.setLineDash([4,4]),e.strokeStyle=`rgba(150,150,150,0.35)`,e.lineWidth=1;for(let t of[70,50,30]){let r=n.yToPixel(t,c,i);e.beginPath(),e.moveTo(0,r),e.lineTo(s,r),e.stroke()}e.setLineDash([]),e.restore(),e.beginPath(),e.strokeStyle=this.color,e.lineWidth=1.5,e.lineJoin=`round`;let d=!1;for(let a of t){if(a.value===null){d=!1;continue}let t=n.xToPixel(a.index,r,s),o=n.yToPixel(a.value,c,i);d?e.lineTo(t,o):(e.moveTo(t,o),d=!0)}e.stroke()}},il=class{constructor(e=14,t=3,n=`#e040fb`){this.kPeriod=e,this.dPeriod=t,this.name=`Stoch`,this.pane=`sub`,this.paneHeight=80,this.color=n}compute(e){let t=[],n=[];for(let r=0;r<e.length;r++){if(r<this.kPeriod-1){n.push(null),t.push({index:r,value:null,upper:null});continue}let i=1/0,a=-1/0;for(let t=r-this.kPeriod+1;t<=r;t++)e[t].low<i&&(i=e[t].low),e[t].high>a&&(a=e[t].high);let o=a-i,s=o===0?50:(e[r].close-i)/o*100;n.push(s),t.push({index:r,value:s,upper:null})}for(let r=0;r<e.length;r++){if(n[r]===null)continue;let e=0,i=0;for(let t=r;t>=0&&e<this.dPeriod&&n[t]!==null;t--)i+=n[t],e++;e===this.dPeriod&&(t[r].upper=i/this.dPeriod)}return t}getValueRange(e){return{min:0,max:100}}render(e,t,n,r,i,a){var o;let s=(o=e.canvas._chartWidth)==null?e.canvas.width:o,c=a==null?{min:0,max:100}:a,l=n.yToPixel(80,c,i),u=n.yToPixel(20,c,i);e.fillStyle=`rgba(239,83,80,0.06)`,e.fillRect(0,0,s,l),e.fillStyle=`rgba(38,166,154,0.06)`,e.fillRect(0,u,s,i-u),e.save(),e.setLineDash([4,4]),e.strokeStyle=`rgba(150,150,150,0.35)`,e.lineWidth=1;for(let t of[80,50,20]){let r=n.yToPixel(t,c,i);e.beginPath(),e.moveTo(0,r),e.lineTo(s,r),e.stroke()}e.setLineDash([]),e.restore(),e.beginPath(),e.strokeStyle=this.color,e.lineWidth=1.5,e.lineJoin=`round`;let d=!1;for(let a of t){if(a.value===null){d=!1;continue}let t=n.xToPixel(a.index,r,s),o=n.yToPixel(a.value,c,i);d?e.lineTo(t,o):(e.moveTo(t,o),d=!0)}e.stroke(),e.beginPath(),e.strokeStyle=`#ff9800`,e.lineWidth=1,e.lineJoin=`round`,d=!1;for(let a of t){if(a.upper==null){d=!1;continue}let t=n.xToPixel(a.index,r,s),o=n.yToPixel(a.upper,c,i);d?e.lineTo(t,o):(e.moveTo(t,o),d=!0)}e.stroke()}};function al(e,t){let n=[];for(let r=0;r<e.length;r++){if(r<t-1){n.push(null);continue}let i=0,a=!0;for(let n=r-t+1;n<=r;n++){if(e[n]===null){a=!1;break}i+=e[n]}n.push(a?i/t:null)}return n}var ol=class{constructor(e=14,t=14,n=3,r=3,i=`#00e5ff`){this.rsiPeriod=e,this.stochPeriod=t,this.kPeriod=n,this.dPeriod=r,this.name=`StochRSI`,this.pane=`sub`,this.paneHeight=80,this.color=i}compute(e){let t=[];if(e.length<this.rsiPeriod+1)return e.map((e,t)=>({index:t,value:null,upper:null}));let n=0,r=0;for(let t=1;t<=this.rsiPeriod;t++){let i=e[t].close-e[t-1].close;i>0?n+=i:r+=Math.abs(i)}n/=this.rsiPeriod,r/=this.rsiPeriod;for(let e=0;e<this.rsiPeriod;e++)t.push(null);let i=r===0?1/0:n/r;t.push(r===0?100:100-100/(1+i));for(let i=this.rsiPeriod+1;i<e.length;i++){let a=e[i].close-e[i-1].close,o=a>0?a:0,s=a<0?Math.abs(a):0;n=(n*(this.rsiPeriod-1)+o)/this.rsiPeriod,r=(r*(this.rsiPeriod-1)+s)/this.rsiPeriod;let c=r===0?1/0:n/r;t.push(r===0?100:100-100/(1+c))}let a=[];for(let n=0;n<e.length;n++){if(t[n]===null){a.push(null);continue}if(n<this.rsiPeriod+this.stochPeriod-1){a.push(null);continue}let e=1/0,r=-1/0,i=!0;for(let a=n-this.stochPeriod+1;a<=n;a++){if(t[a]===null){i=!1;break}let n=t[a];n<e&&(e=n),n>r&&(r=n)}if(!i){a.push(null);continue}let o=r-e,s=o===0?50:(t[n]-e)/o*100;a.push(s)}let o=al(a,this.kPeriod),s=al(o,this.dPeriod);return e.map((e,t)=>{var n,r;return{index:t,value:(n=o[t])==null?null:n,upper:(r=s[t])==null?null:r}})}getValueRange(e){return{min:0,max:100}}render(e,t,n,r,i,a){var o;let s=(o=e.canvas._chartWidth)==null?e.canvas.width:o,c=a==null?{min:0,max:100}:a,l=n.yToPixel(80,c,i),u=n.yToPixel(20,c,i);e.fillStyle=`rgba(239,83,80,0.06)`,e.fillRect(0,0,s,l),e.fillStyle=`rgba(38,166,154,0.06)`,e.fillRect(0,u,s,i-u),e.save(),e.setLineDash([4,4]),e.strokeStyle=`rgba(150,150,150,0.35)`,e.lineWidth=1;for(let t of[80,50,20]){let r=n.yToPixel(t,c,i);e.beginPath(),e.moveTo(0,r),e.lineTo(s,r),e.stroke()}e.setLineDash([]),e.restore(),e.beginPath(),e.strokeStyle=this.color,e.lineWidth=1.5,e.lineJoin=`round`;let d=!1;for(let a of t){if(a.value===null){d=!1;continue}let t=n.xToPixel(a.index,r,s),o=n.yToPixel(a.value,c,i);d?e.lineTo(t,o):(e.moveTo(t,o),d=!0)}e.stroke(),e.beginPath(),e.strokeStyle=`#ff9800`,e.lineWidth=1,e.lineJoin=`round`,d=!1;for(let a of t){if(a.upper==null){d=!1;continue}let t=n.xToPixel(a.index,r,s),o=n.yToPixel(a.upper,c,i);d?e.lineTo(t,o):(e.moveTo(t,o),d=!0)}e.stroke()}};function sl(e,t){let n=2/(t+1),r=[],i=null;for(let a=0;a<e.length;a++){if(a<t-1){r.push(null);continue}if(i===null){let n=0;for(let r=0;r<t;r++)n+=e[a-r];i=n/t}else i=e[a]*n+i*(1-n);r.push(i)}return r}var cl=class{constructor(e=12,t=26,n=9,r=`#2196f3`,i=`MACD`,a=`close`){this.fast=e,this.slow=t,this.signal=n,this.source=a,this.pane=`sub`,this.paneHeight=80,this.name=i,this.color=r}compute(e){let t=e.map(e=>Uc(e,this.source)),n=sl(t,this.fast),r=sl(t,this.slow),i=t.map((e,t)=>n[t]===null||r[t]===null?null:n[t]-r[t]),a=sl(i.map(e=>e==null?0:e),this.signal);return e.map((e,t)=>{let n=i[t];if(n===null)return{index:t,value:null,upper:null,lower:null,histogram:null};let r=t>=this.slow-1+this.signal-1?a[t]:null;return{index:t,value:n,upper:r,lower:n!==null&&r!==null?n-r:null}})}getValueRange(e){let t=1e-4;for(let n of e)n.value!=null&&(t=Math.max(t,Math.abs(n.value))),n.upper!=null&&(t=Math.max(t,Math.abs(n.upper))),n.lower!=null&&(t=Math.max(t,Math.abs(n.lower)));return{min:-t*1.3,max:t*1.3}}render(e,t,n,r,i,a){var o;let s=(o=e.canvas._chartWidth)==null?e.canvas.width:o,c=1e-4;for(let e of t)e.value!=null&&(c=Math.max(c,Math.abs(e.value))),e.upper!=null&&(c=Math.max(c,Math.abs(e.upper))),e.lower!=null&&(c=Math.max(c,Math.abs(e.lower)));let l=a==null?{min:-c*1.3,max:c*1.3}:a,u=n.yToPixel(0,l,i);e.strokeStyle=`rgba(150,150,150,0.3)`,e.lineWidth=1,e.beginPath(),e.moveTo(0,u),e.lineTo(s,u),e.stroke();let d=Math.max(n.candleBodyWidth(r,s),1);for(let a of t){if(a.lower==null)continue;let t=n.xToPixel(a.index,r,s),o=n.yToPixel(a.lower,l,i),c=Math.abs(o-u),f=Math.min(o,u);e.fillStyle=a.lower>=0?`rgba(38,166,154,0.55)`:`rgba(239,83,80,0.55)`,e.fillRect(t-d/2,f,d,c)}e.beginPath(),e.strokeStyle=this.color,e.lineWidth=1.5,e.lineJoin=`round`;let f=!1;for(let a of t){if(a.value==null){f=!1;continue}let t=n.xToPixel(a.index,r,s),o=n.yToPixel(a.value,l,i);f?e.lineTo(t,o):(e.moveTo(t,o),f=!0)}e.stroke(),e.beginPath(),e.strokeStyle=`#ff6b35`,e.lineWidth=1,e.lineJoin=`round`,f=!1;for(let a of t){if(a.upper==null){f=!1;continue}let t=n.xToPixel(a.index,r,s),o=n.yToPixel(a.upper,l,i);f?e.lineTo(t,o):(e.moveTo(t,o),f=!0)}e.stroke()}},ll=class{constructor(e=20,t=`#4db6ac`){this.period=e,this.name=`CCI`,this.pane=`sub`,this.paneHeight=80,this.color=t}compute(e){return e.map((t,n)=>{if(n<this.period-1)return{index:n,value:null};let r=e.slice(n-this.period+1,n+1).map(e=>(e.high+e.low+e.close)/3),i=r[r.length-1],a=r.reduce((e,t)=>e+t,0)/this.period,o=r.reduce((e,t)=>e+Math.abs(t-a),0)/this.period;return o===0?{index:n,value:0}:{index:n,value:(i-a)/(.015*o)}})}getValueRange(e){let t=1e-4;for(let n of e)n.value!=null&&(t=Math.max(t,Math.abs(n.value)));return{min:-t*1.3,max:t*1.3}}render(e,t,n,r,i,a){var o;let s=(o=e.canvas._chartWidth)==null?e.canvas.width:o,c=1e-4;for(let e of t)e.value!=null&&(c=Math.max(c,Math.abs(e.value)));let l=a==null?{min:-c*1.3,max:c*1.3}:a,u=n.yToPixel(100,l,i),d=n.yToPixel(-100,l,i);e.fillStyle=`rgba(239,83,80,0.10)`,e.fillRect(0,0,s,u),e.fillStyle=`rgba(38,166,154,0.10)`,e.fillRect(0,d,s,i-d),e.save(),e.setLineDash([4,4]),e.strokeStyle=`rgba(150,150,150,0.35)`,e.lineWidth=1;for(let t of[100,0,-100]){let r=n.yToPixel(t,l,i);e.beginPath(),e.moveTo(0,r),e.lineTo(s,r),e.stroke()}e.setLineDash([]),e.restore(),e.beginPath(),e.strokeStyle=this.color,e.lineWidth=1.5,e.lineJoin=`round`;let f=!1;for(let a of t){if(a.value===null){f=!1;continue}let t=n.xToPixel(a.index,r,s),o=n.yToPixel(a.value,l,i);f?e.lineTo(t,o):(e.moveTo(t,o),f=!0)}e.stroke()}},ul=class{constructor(e=14,t=`#ff7043`){this.period=e,this.name=`%R`,this.pane=`sub`,this.paneHeight=80,this.color=t}compute(e){return e.map((t,n)=>{if(n<this.period-1)return{index:n,value:null};let r=-1/0,i=1/0;for(let t=n-this.period+1;t<=n;t++)e[t].high>r&&(r=e[t].high),e[t].low<i&&(i=e[t].low);let a=r-i;return{index:n,value:a===0?-50:(r-e[n].close)/a*-100}})}getValueRange(e){return{min:-100,max:0}}render(e,t,n,r,i,a){var o;let s=(o=e.canvas._chartWidth)==null?e.canvas.width:o,c=a==null?{min:-100,max:0}:a,l=n.yToPixel(-20,c,i),u=n.yToPixel(-80,c,i);e.fillStyle=`rgba(239,83,80,0.06)`,e.fillRect(0,0,s,l),e.fillStyle=`rgba(38,166,154,0.06)`,e.fillRect(0,u,s,i-u),e.save(),e.setLineDash([4,4]),e.strokeStyle=`rgba(150,150,150,0.35)`,e.lineWidth=1;for(let t of[-20,-50,-80]){let r=n.yToPixel(t,c,i);e.beginPath(),e.moveTo(0,r),e.lineTo(s,r),e.stroke()}e.setLineDash([]),e.restore(),e.beginPath(),e.strokeStyle=this.color,e.lineWidth=1.5,e.lineJoin=`round`;let d=!1;for(let a of t){if(a.value===null){d=!1;continue}let t=n.xToPixel(a.index,r,s),o=n.yToPixel(a.value,c,i);d?e.lineTo(t,o):(e.moveTo(t,o),d=!0)}e.stroke()}},dl=class{constructor(e=12,t=`#80cbc4`,n=`close`){this.period=e,this.source=n,this.pane=`sub`,this.paneHeight=80,this.name=`ROC`,this.color=t}compute(e){return e.map((t,n)=>{if(n<this.period)return{index:n,value:null};let r=Uc(e[n-this.period],this.source);return r===0?{index:n,value:null}:{index:n,value:(Uc(e[n],this.source)-r)/r*100}})}getValueRange(e){let t=1e-4;for(let n of e)n.value!=null&&(t=Math.max(t,Math.abs(n.value)));return{min:-t*1.3,max:t*1.3}}render(e,t,n,r,i,a){var o;let s=(o=e.canvas._chartWidth)==null?e.canvas.width:o,c=1e-4;for(let e of t)e.value!=null&&(c=Math.max(c,Math.abs(e.value)));let l=a==null?{min:-c*1.3,max:c*1.3}:a,u=n.yToPixel(0,l,i),d=[];for(let e of t)e.value!=null&&d.push({x:n.xToPixel(e.index,r,s),y:n.yToPixel(e.value,l,i),value:e.value});if(d.length>=2){e.beginPath(),e.moveTo(d[0].x,u);for(let t of d)e.lineTo(t.x,Math.min(t.y,u));e.lineTo(d[d.length-1].x,u),e.closePath(),e.fillStyle=`rgba(38,166,154,0.05)`,e.fill(),e.beginPath(),e.moveTo(d[0].x,u);for(let t of d)e.lineTo(t.x,Math.max(t.y,u));e.lineTo(d[d.length-1].x,u),e.closePath(),e.fillStyle=`rgba(239,83,80,0.05)`,e.fill()}e.save(),e.setLineDash([4,4]),e.strokeStyle=`rgba(150,150,150,0.35)`,e.lineWidth=1,e.beginPath(),e.moveTo(0,u),e.lineTo(s,u),e.stroke(),e.setLineDash([]),e.restore(),e.beginPath(),e.strokeStyle=this.color,e.lineWidth=1.5,e.lineJoin=`round`;let f=!1;for(let a of t){if(a.value===null){f=!1;continue}let t=n.xToPixel(a.index,r,s),o=n.yToPixel(a.value,l,i);f?e.lineTo(t,o):(e.moveTo(t,o),f=!0)}e.stroke()}},fl=class{constructor(e=`#aed581`){this.name=`OBV`,this.pane=`sub`,this.paneHeight=80,this.color=e}compute(e){let t=[],n=0;for(let o=0;o<e.length;o++){if(o===0){var r;n=(r=e[o].volume)==null?0:r}else if(e[o].close>e[o-1].close){var i;n+=(i=e[o].volume)==null?0:i}else if(e[o].close<e[o-1].close){var a;n-=(a=e[o].volume)==null?0:a}t.push({index:o,value:n})}return t}getValueRange(e){let t=1/0,n=-1/0;for(let r of e)r.value!=null&&(r.value<t&&(t=r.value),r.value>n&&(n=r.value));if(t===1/0)return{min:0,max:1};let r=(n-t)*.1||1;return{min:t-r,max:n+r}}render(e,t,n,r,i,a){var o;let s=(o=e.canvas._chartWidth)==null?e.canvas.width:o,c=1/0,l=-1/0;for(let e of t)e.value!=null&&(e.value<c&&(c=e.value),e.value>l&&(l=e.value));if(c===1/0)return;let u=(l-c)*.1||1,d=a==null?{min:c-u,max:l+u}:a,f=n.yToPixel(0,d,i),p=[];for(let e of t)e.value!=null&&p.push({x:n.xToPixel(e.index,r,s),y:n.yToPixel(e.value,d,i),value:e.value});if(p.length===0)return;if(e.save(),e.setLineDash([4,4]),e.strokeStyle=`rgba(150,150,150,0.35)`,e.lineWidth=1,e.beginPath(),e.moveTo(0,f),e.lineTo(s,f),e.stroke(),e.setLineDash([]),e.restore(),p.length>=2){e.beginPath(),e.moveTo(p[0].x,f);for(let t of p)e.lineTo(t.x,t.y);e.lineTo(p[p.length-1].x,f),e.closePath(),e.fillStyle=p[p.length-1].value>=0?`rgba(38,166,154,0.12)`:`rgba(239,83,80,0.12)`,e.fill()}e.beginPath(),e.strokeStyle=this.color,e.lineWidth=1.5,e.lineJoin=`round`;let m=!1;for(let a of t){if(a.value==null){m=!1;continue}let t=n.xToPixel(a.index,r,s),o=n.yToPixel(a.value,d,i);m?e.lineTo(t,o):(e.moveTo(t,o),m=!0)}e.stroke()}},pl=class{constructor(e=`#9c27b0`){this.name=`VWAP`,this.color=e}compute(e){let t=[],n=0,r=0;for(let o=0;o<e.length;o++){var i,a;let s=e[o],c=(s.high+s.low+s.close)/3;n+=c*((i=s.volume)==null?0:i),r+=(a=s.volume)==null?0:a,t.push({index:o,value:r===0?null:n/r})}return t}render(e,t,n,r,i){var a;let o=e.canvas,s=o._priceRange;if(!s)return;let c=(a=o._chartWidth)==null?e.canvas.width:a;e.beginPath(),e.strokeStyle=this.color,e.lineWidth=1.5,e.lineJoin=`round`,e.setLineDash([4,3]);let l=!1;for(let a of t){if(a.value===null){l=!1;continue}let t=n.xToPixel(a.index,r,c),o=n.yToPixel(a.value,s,i);l?e.lineTo(t,o):(e.moveTo(t,o),l=!0)}e.stroke(),e.setLineDash([])}},ml=class{constructor(e=`#ce93d8`){this.name=`A/D`,this.pane=`sub`,this.paneHeight=80,this.color=e}compute(e){let t=[],n=0;for(let r=0;r<e.length;r++){let{high:i,low:a,close:o,volume:s}=e[r],c=i-a,l=c===0?0:(o-a-(i-o))/c;n+=l*(s==null?0:s),t.push({index:r,value:n})}return t}getValueRange(e){let t=1/0,n=-1/0;for(let r of e)r.value!=null&&(r.value<t&&(t=r.value),r.value>n&&(n=r.value));if(t===1/0)return{min:0,max:1};let r=(n-t)*.1||1;return{min:t-r,max:n+r}}render(e,t,n,r,i,a){var o;let s=(o=e.canvas._chartWidth)==null?e.canvas.width:o,c=1/0,l=-1/0;for(let e of t)e.value!=null&&(e.value<c&&(c=e.value),e.value>l&&(l=e.value));if(c===1/0)return;let u=(l-c)*.1||1,d=a==null?{min:c-u,max:l+u}:a,f=[];for(let e of t)e.value!=null&&f.push({x:n.xToPixel(e.index,r,s),y:n.yToPixel(e.value,d,i)});if(f.length===0)return;if(f.length>=2){let t=i;e.beginPath(),e.moveTo(f[0].x,t);for(let t of f)e.lineTo(t.x,t.y);e.lineTo(f[f.length-1].x,t),e.closePath(),e.fillStyle=this.color+`20`,e.fill()}e.beginPath(),e.strokeStyle=this.color,e.lineWidth=1.5,e.lineJoin=`round`;let p=!1;for(let a of t){if(a.value==null){p=!1;continue}let t=n.xToPixel(a.index,r,s),o=n.yToPixel(a.value,d,i);p?e.lineTo(t,o):(e.moveTo(t,o),p=!0)}e.stroke()}},hl=class{constructor(e=14,t=`#ffab40`){this.period=e,this.pane=`sub`,this.paneHeight=80,this.name=`MFI`,this.color=t}compute(e){let t=[],n=e.map(e=>(e.high+e.low+e.close)/3),r=e.map((e,t)=>{var r;return n[t]*((r=e.volume)==null?0:r)});for(let i=0;i<e.length;i++){if(i<this.period){t.push({index:i,value:null});continue}let e=0,a=0;for(let t=i-this.period+1;t<=i;t++)n[t]>n[t-1]?e+=r[t]:n[t]<n[t-1]&&(a+=r[t]);if(a===0)t.push({index:i,value:100});else{let n=e/a;t.push({index:i,value:100-100/(1+n)})}}return t}getValueRange(e){return{min:0,max:100}}render(e,t,n,r,i,a){var o;let s=(o=e.canvas._chartWidth)==null?e.canvas.width:o,c=a==null?{min:0,max:100}:a,l=n.yToPixel(80,c,i),u=n.yToPixel(20,c,i);e.fillStyle=`rgba(239,83,80,0.06)`,e.fillRect(0,0,s,l),e.fillStyle=`rgba(38,166,154,0.06)`,e.fillRect(0,u,s,i-u),e.save(),e.setLineDash([4,4]),e.strokeStyle=`rgba(150,150,150,0.35)`,e.lineWidth=1;for(let t of[80,50,20]){let r=n.yToPixel(t,c,i);e.beginPath(),e.moveTo(0,r),e.lineTo(s,r),e.stroke()}e.setLineDash([]),e.restore(),e.beginPath(),e.strokeStyle=this.color,e.lineWidth=1.5,e.lineJoin=`round`;let d=!1;for(let a of t){if(a.value===null){d=!1;continue}let t=n.xToPixel(a.index,r,s),o=n.yToPixel(a.value,c,i);d?e.lineTo(t,o):(e.moveTo(t,o),d=!0)}e.stroke()}},gl=class{constructor(e=20,t=`#80deea`){this.period=e,this.pane=`sub`,this.paneHeight=80,this.name=`CMF`,this.color=t}compute(e){let t=e.map(e=>{var t;let n=e.high-e.low;return(n===0?0:(e.close-e.low-(e.high-e.close))/n)*((t=e.volume)==null?0:t)});return e.map((n,r)=>{if(r<this.period-1)return{index:r,value:null};let i=0,a=0;for(let n=r-this.period+1;n<=r;n++){var o;i+=t[n],a+=(o=e[n].volume)==null?0:o}return{index:r,value:a===0?0:i/a}})}getValueRange(e){return{min:-1,max:1}}render(e,t,n,r,i,a){var o;let s=(o=e.canvas._chartWidth)==null?e.canvas.width:o,c=a==null?{min:-1,max:1}:a,l=n.yToPixel(0,c,i),u=n.yToPixel(.2,c,i),d=n.yToPixel(-.2,c,i);e.fillStyle=`rgba(38,166,154,0.08)`,e.fillRect(0,0,s,u),e.fillStyle=`rgba(239,83,80,0.08)`,e.fillRect(0,d,s,i-d),e.save(),e.setLineDash([4,4]),e.strokeStyle=`rgba(150,150,150,0.35)`,e.lineWidth=1;for(let t of[.2,0,-.2]){let r=n.yToPixel(t,c,i);e.beginPath(),e.moveTo(0,r),e.lineTo(s,r),e.stroke()}e.setLineDash([]),e.restore();let f=Math.max(1,s/Math.max(t.length,1)*.6);for(let a of t){if(a.value==null)continue;let t=n.xToPixel(a.index,r,s),o=n.yToPixel(a.value,c,i),u=Math.abs(o-l),d=Math.min(o,l);e.fillStyle=a.value>=0?`rgba(38,166,154,0.45)`:`rgba(239,83,80,0.45)`,e.fillRect(t-f/2,d,f,u)}e.beginPath(),e.strokeStyle=this.color,e.lineWidth=1.5,e.lineJoin=`round`;let p=!1;for(let a of t){if(a.value===null){p=!1;continue}let t=n.xToPixel(a.index,r,s),o=n.yToPixel(a.value,c,i);p?e.lineTo(t,o):(e.moveTo(t,o),p=!0)}e.stroke()}},_l=class{constructor(e=`#ffd54f`){this.name=`Pivot`,this.color=e}compute(e){return e.map((t,n)=>{if(n===0)return{index:n,value:null,upper:null,lower:null,signal:null,histogram:null};let r=e[n-1],i=(r.high+r.low+r.close)/3;return{index:n,value:i,upper:2*i-r.low,lower:2*i-r.high,signal:i+(r.high-r.low),histogram:i-(r.high-r.low)}})}render(e,t,n,r,i){var a;let o=e.canvas,s=o._priceRange;if(!s)return;let c=(a=o._chartWidth)==null?e.canvas.width:a,l=null;for(let e=t.length-1;e>=0;e--)if(t[e].value!==null){l=t[e];break}if(l===null)return;let u=[{value:l.signal,label:`R2`,color:`#b71c1c`},{value:l.upper,label:`R1`,color:`#ef5350`},{value:l.value,label:`PP`,color:`#ffd54f`},{value:l.lower,label:`S1`,color:`#26a69a`},{value:l.histogram,label:`S2`,color:`#1b5e20`}];e.lineWidth=1,e.font=`10px sans-serif`,e.textBaseline=`middle`;for(let t of u){if(t.value==null)continue;let r=n.yToPixel(t.value,s,i);e.beginPath(),e.setLineDash([6,4]),e.strokeStyle=t.color,e.moveTo(0,r),e.lineTo(c,r),e.stroke(),e.setLineDash([]),e.fillStyle=t.color,e.fillText(t.label,c-28,r-6)}}},vl=[0,.236,.382,.5,.618,.786,1],yl=[`0%`,`23.6%`,`38.2%`,`50%`,`61.8%`,`78.6%`,`100%`],bl=[`#90a4ae`,`#4d96ff`,`#6bcb77`,`#ffd93d`,`#ff9800`,`#ef5350`,`#90a4ae`],xl=class{constructor(e=50,t=`#e1bee7`){this.lookback=e,this.name=`Fib`,this.color=t}compute(e){return e.map((t,n)=>{let r=Math.max(0,n-this.lookback+1),i=-1/0,a=1/0;for(let t=r;t<=n;t++)e[t].high>i&&(i=e[t].high),e[t].low<a&&(a=e[t].low);let o=i-a;return{index:n,value:i,upper:a+.618*o,lower:a+.382*o,signal:a+.5*o,histogram:a}})}render(e,t,n,r,i){var a;let o=e.canvas,s=o._priceRange;if(!s)return;let c=(a=o._chartWidth)==null?e.canvas.width:a,l=null;for(let e=t.length-1;e>=0;e--)if(t[e].value!==null){l=t[e];break}if(l===null)return;let u=l.value,d=l.histogram;if(u==null||d==null)return;let f=u-d,p=vl.map(e=>d+e*f);e.lineWidth=1,e.font=`10px sans-serif`,e.textBaseline=`middle`;for(let t=0;t<vl.length;t++){let r=p[t],a=n.yToPixel(r,s,i),o=bl[t];e.beginPath(),e.setLineDash([6,4]),e.strokeStyle=o,e.moveTo(0,a),e.lineTo(c,a),e.stroke(),e.setLineDash([]),e.fillStyle=o,e.fillText(yl[t],c-38,a-6)}}},Sl=class{constructor(e=10,t=3,n=`#26a69a`){this.atrPeriod=e,this.multiplier=t,this.name=`Supertrend`,this.color=n}compute(e){let t=e.length,n=[];if(t===0)return n;let r=Array(t).fill(0);for(let n=0;n<t;n++){let t=e[n].high,i=e[n].low,a=n>0?e[n-1].close:e[n].close;r[n]=Math.max(t-i,Math.abs(t-a),Math.abs(i-a))}let i=Array(t).fill(0);if(t<this.atrPeriod){for(let e=0;e<t;e++)n.push({index:e,value:null,upper:null});return n}let a=0;for(let e=0;e<this.atrPeriod;e++)a+=r[e];i[this.atrPeriod-1]=a/this.atrPeriod;for(let e=this.atrPeriod;e<t;e++)i[e]=(i[e-1]*(this.atrPeriod-1)+r[e])/this.atrPeriod;let o=Array(t).fill(0),s=Array(t).fill(0),c=Array(t).fill(1);for(let r=0;r<t;r++){if(r<this.atrPeriod-1){n.push({index:r,value:null,upper:null});continue}let t=(e[r].high+e[r].low)/2,a=t+this.multiplier*i[r],l=t-this.multiplier*i[r];if(r===this.atrPeriod-1){o[r]=a,s[r]=l,c[r]=1,n.push({index:r,value:s[r],upper:1});continue}let u=e[r-1].close;o[r]=a<o[r-1]||u>o[r-1]?a:o[r-1],s[r]=l>s[r-1]||u<s[r-1]?l:s[r-1],c[r-1]===-1?c[r]=e[r].close>o[r]?1:-1:c[r]=e[r].close<s[r]?-1:1;let d=c[r]===1?s[r]:o[r];n.push({index:r,value:d,upper:c[r]})}return n}render(e,t,n,r,i){var a;let o=e.canvas,s=o._priceRange;if(!s)return;let c=(a=o._chartWidth)==null?e.canvas.width:a;e.lineWidth=2,e.lineJoin=`round`;let l=null;e.beginPath(),e.strokeStyle=`#26a69a`;let u=!1;for(let a of t){if(a.value==null||a.upper==null){u=!1;continue}if(!(a.upper>=0)){u=!1;continue}l!==1&&(u=!1);let t=n.xToPixel(a.index,r,c),o=n.yToPixel(a.value,s,i);u?e.lineTo(t,o):(e.moveTo(t,o),u=!0),l=1}e.stroke(),e.beginPath(),e.strokeStyle=`#ef5350`;let d=!1;l=null;for(let a of t){if(a.value==null||a.upper==null){d=!1;continue}if(!(a.upper<0)){d=!1;continue}l!==-1&&(d=!1);let t=n.xToPixel(a.index,r,c),o=n.yToPixel(a.value,s,i);d?e.lineTo(t,o):(e.moveTo(t,o),d=!0),l=-1}e.stroke()}},Cl=class{constructor(e=.02,t=.2,n=`#ff6b9d`){this.step=e,this.maxAF=t,this.name=`PSAR`,this.color=n}compute(e){let t=e.length,n=[];if(t<2){for(let e=0;e<t;e++)n.push({index:e,value:null,upper:null});return n}let r=!0,i=this.step,a=e[0].high,o=e[0].low;n.push({index:0,value:null,upper:null});for(let s=1;s<t;s++){let t=o+i*(a-o);if(r){let n=e[s-1].low,o=s>=2?e[s-2].low:e[s-1].low;t=Math.min(t,n,o),t>e[s].low?(r=!1,t=a,a=e[s].low,i=this.step):e[s].high>a&&(a=e[s].high,i=Math.min(i+this.step,this.maxAF))}else{let n=e[s-1].high,o=s>=2?e[s-2].high:e[s-1].high;t=Math.max(t,n,o),t<e[s].high?(r=!0,t=a,a=e[s].high,i=this.step):e[s].low<a&&(a=e[s].low,i=Math.min(i+this.step,this.maxAF))}o=t,n.push({index:s,value:o,upper:r?1:-1})}return n}render(e,t,n,r,i){var a;let o=e.canvas,s=o._priceRange;if(!s)return;let c=(a=o._chartWidth)==null?e.canvas.width:a;for(let a of t){if(a.value==null||a.upper==null)continue;let t=n.xToPixel(a.index,r,c),o=n.yToPixel(a.value,s,i);e.beginPath(),e.arc(t,o,2,0,Math.PI*2),e.fillStyle=a.upper>=0?`#26a69a`:`#ef5350`,e.fill()}}};function wl(e,t,n){if(t<n-1)return null;let r=-1/0,i=1/0;for(let a=t-n+1;a<=t;a++)e[a].high>r&&(r=e[a].high),e[a].low<i&&(i=e[a].low);return{high:r,low:i}}var Tl=class{constructor(e=9,t=26,n=52,r=`#b0bec5`){this.tenkanPeriod=e,this.kijunPeriod=t,this.senkouBPeriod=n,this.name=`Ichimoku`,this.color=r}compute(e){return e.map((t,n)=>{let r=wl(e,n,this.tenkanPeriod),i=r===null?null:(r.high+r.low)/2,a=wl(e,n,this.kijunPeriod),o=a===null?null:(a.high+a.low)/2,s=i!==null&&o!==null?(i+o)/2:null,c=wl(e,n,this.senkouBPeriod);return{index:n,value:i,upper:o,lower:s,signal:c===null?null:(c.high+c.low)/2,histogram:t.close}})}render(e,t,n,r,i){var a;let o=e.canvas,s=o._priceRange;if(!s)return;let c=(a=o._chartWidth)==null?e.canvas.width:a;e.lineWidth=1,e.lineJoin=`round`;let l=(a,o,l=!1)=>{e.strokeStyle=o,l&&e.setLineDash([4,3]),e.beginPath();let u=!1;for(let o of t){let t=a(o);if(t==null){u=!1;continue}let l=n.xToPixel(o.index,r,c),d=n.yToPixel(t,s,i);u?e.lineTo(l,d):(e.moveTo(l,d),u=!0)}e.stroke(),l&&e.setLineDash([])},u=[],d=[];for(let e of t){if(e.lower==null||e.signal==null)continue;let t=n.xToPixel(e.index,r,c);u.push([t,n.yToPixel(e.lower,s,i)]),d.push([t,n.yToPixel(e.signal,s,i)])}for(let t=0;t+1<u.length;t++){let[n,r]=u[t],[i,a]=u[t+1],[,o]=d[t],[,s]=d[t+1],c=r<o;e.beginPath(),e.moveTo(n,r),e.lineTo(i,a),e.lineTo(i,s),e.lineTo(n,o),e.closePath(),e.fillStyle=c?`rgba(38, 166, 154, 0.15)`:`rgba(239, 83, 80, 0.15)`,e.fill()}l(e=>e.lower,`#26a69a`,!0),l(e=>e.signal,`#ef5350`,!0),l(e=>e.value,`#ef9a9a`),l(e=>e.upper,`#90caf9`),e.strokeStyle=`#b0bec5`,e.beginPath();let f=!1;for(let a of t){if(a.histogram==null){f=!1;continue}let t=a.index-this.kijunPeriod;if(t<0){f=!1;continue}let o=n.xToPixel(t,r,c),l=n.yToPixel(a.histogram,s,i);f?e.lineTo(o,l):(e.moveTo(o,l),f=!0)}e.stroke()}},El=class{constructor(e=14,t=`#fff176`){this.period=e,this.pane=`sub`,this.paneHeight=80,this.name=`ADX`,this.color=t}compute(e){let t=e.length;if(t<this.period+1)return e.map((e,t)=>({index:t,value:null,upper:null,lower:null}));let n=Array(t).fill(0),r=Array(t).fill(0),i=Array(t).fill(0);n[0]=e[0].high-e[0].low,r[0]=0,i[0]=0;for(let a=1;a<t;a++){let t=e[a-1].close,o=e[a-1].high,s=e[a-1].low,c=e[a].high,l=e[a].low;n[a]=Math.max(c-l,Math.abs(c-t),Math.abs(l-t));let u=c-o,d=s-l;r[a]=u>d&&u>0?u:0,i[a]=d>u&&d>0?d:0}let a=0,o=0,s=0;for(let e=0;e<this.period;e++)a+=n[e],o+=r[e],s+=i[e];let c=[];for(let e=0;e<this.period;e++)c.push({index:e,value:null,upper:null,lower:null});let l=Array(t).fill(0),u=Array(t).fill(0),d=Array(t).fill(0),f=a===0?0:100*o/a,p=a===0?0:100*s/a,m=f+p===0?0:100*Math.abs(f-p)/(f+p);l[this.period-1]=f,u[this.period-1]=p,d[this.period-1]=m,c[this.period-1]={index:this.period-1,value:null,upper:f,lower:p};for(let e=this.period;e<t;e++){a=a-a/this.period+n[e],o=o-o/this.period+r[e],s=s-s/this.period+i[e];let t=a===0?0:100*o/a,f=a===0?0:100*s/a,p=t+f===0?0:100*Math.abs(t-f)/(t+f);l[e]=t,u[e]=f,d[e]=p,c.push({index:e,value:null,upper:t,lower:f})}let h=2*this.period-2;if(h>=t)return c;let g=0;for(let e=this.period-1;e<=h;e++)g+=d[e];g/=this.period,c[h].value=g;for(let e=h+1;e<t;e++)g=(g*(this.period-1)+d[e])/this.period,c[e].value=g;return c}getValueRange(e){return{min:0,max:100}}render(e,t,n,r,i,a){var o;let s=(o=e.canvas._chartWidth)==null?e.canvas.width:o,c=a==null?{min:0,max:100}:a;e.save(),e.setLineDash([4,4]),e.strokeStyle=`rgba(150,150,150,0.35)`,e.lineWidth=1;let l=n.yToPixel(25,c,i);e.beginPath(),e.moveTo(0,l),e.lineTo(s,l),e.stroke(),e.setLineDash([]),e.restore();let u=(a,o,l)=>{e.beginPath(),e.strokeStyle=o,e.lineWidth=l,e.lineJoin=`round`;let u=!1;for(let o of t){let t=a(o);if(t==null){u=!1;continue}let l=n.xToPixel(o.index,r,s),d=n.yToPixel(t,c,i);u?e.lineTo(l,d):(e.moveTo(l,d),u=!0)}e.stroke()};u(e=>e.upper,`#26a69a`,1),u(e=>e.lower,`#ef5350`,1),u(e=>e.value,this.color,1.5)}},Dl=class{constructor(e=5,t=34,n=`#b0bec5`){this.fastPeriod=e,this.slowPeriod=t,this.name=`AO`,this.pane=`sub`,this.paneHeight=80,this.color=n}compute(e){let t=e.map(e=>(e.high+e.low)/2),n=(e,t,n)=>{if(t<n-1)return null;let r=0;for(let i=t-n+1;i<=t;i++)r+=e[i];return r/n};return e.map((e,r)=>{let i=n(t,r,this.fastPeriod),a=n(t,r,this.slowPeriod);return i===null||a===null?{index:r,value:null}:{index:r,value:i-a}})}getValueRange(e){let t=1e-4;for(let n of e)n.value!=null&&(t=Math.max(t,Math.abs(n.value)));return{min:-t*1.2,max:t*1.2}}render(e,t,n,r,i,a){var o;let s=(o=e.canvas._chartWidth)==null?e.canvas.width:o,c=1e-4;for(let e of t)e.value!=null&&(c=Math.max(c,Math.abs(e.value)));let l=a==null?{min:-c*1.2,max:c*1.2}:a,u=n.yToPixel(0,l,i);e.save(),e.setLineDash([4,4]),e.strokeStyle=`rgba(150,150,150,0.35)`,e.lineWidth=1,e.beginPath(),e.moveTo(0,u),e.lineTo(s,u),e.stroke(),e.setLineDash([]),e.restore();let d=Math.max(n.candleBodyWidth(r,s),1),f=null;for(let a of t){if(a.value==null){f=null;continue}let t=f===null?!0:a.value>=f,o=n.xToPixel(a.index,r,s),c=n.yToPixel(a.value,l,i),p=Math.abs(c-u),m=Math.min(c,u);e.fillStyle=t?`rgba(38,166,154,0.70)`:`rgba(239,83,80,0.70)`,e.fillRect(o-d/2,m,d,p),f=a.value}}},Ol=class{constructor(e=`#90a4ae`,t=`#26a69a`,n=`#ef5350`){this.name=`HA`,this.color=e,this.upColor=t,this.downColor=n}compute(e){let t=[],n=0,r=0;for(let i=0;i<e.length;i++){let a=e[i],o=(a.open+a.high+a.low+a.close)/4,s;s=i===0?(a.open+a.close)/2:(n+r)/2;let c=Math.max(a.high,s,o),l=Math.min(a.low,s,o);n=s,r=o,t.push({index:i,value:o,upper:c,lower:l,signal:s})}return t}render(e,t,n,r,i){var a;let o=e.canvas,s=o._priceRange;if(!s)return;let c=(a=o._chartWidth)==null?e.canvas.width:a,l=n.candleBodyWidth(r,c),u=l/2;for(let a of t){if(a.value==null||a.upper==null||a.lower==null||a.signal==null)continue;let t=a.value,o=a.upper,d=a.lower,f=a.signal,p=t>=f?this.upColor:this.downColor,m=n.xToPixel(a.index,r,c),h=n.yToPixel(o,s,i),g=n.yToPixel(d,s,i),_=n.yToPixel(f,s,i),v=n.yToPixel(t,s,i),y=Math.min(_,v),b=Math.max(1,Math.max(_,v)-y);e.beginPath(),e.strokeStyle=p,e.lineWidth=1,e.moveTo(m,h),e.lineTo(m,g),e.stroke(),e.fillStyle=p,e.strokeStyle=p,e.lineWidth=1,e.fillRect(m-u,y,l,b),e.strokeRect(m-u,y,l,b)}}},kl=class{constructor(e=`#26a69a`,t=`#ef5350`){this.name=`VOL`,this.pane=`sub`,this.paneHeight=80,this.upColor=e,this.downColor=t,this.color=e}compute(e){return e.map((e,t)=>{var n;return{index:t,value:(n=e.volume)==null?0:n,signal:+(e.close>=e.open)}})}render(e,t,n,r,i){var a;let o=(a=e.canvas._chartWidth)==null?e.canvas.width:a,s=0;for(let e of t)e.value!=null&&e.value>s&&(s=e.value);if(s===0)return;let c={min:0,max:s*1.1},l=n.yToPixel(0,c,i),u=Math.max(n.candleBodyWidth(r,o),1);for(let a of t){if(a.value==null||a.value===0)continue;let t=n.xToPixel(a.index,r,o),s=n.yToPixel(a.value,c,i),d=Math.abs(l-s);e.fillStyle=a.signal===1?`${this.upColor}99`:`${this.downColor}99`,e.fillRect(t-u/2,s,u,d)}e.fillStyle=this.upColor,e.font=`10px 'Inter', system-ui, sans-serif`,e.fillText(this.name,4,11)}},Al=class{constructor(e=14,t=`#ff9800`){this.period=e,this.name=`LinReg`,this.color=t}compute(e){let t=this.period,n=[],r=t*(t-1)/2,i=t*(t*(t-1)*(2*t-1)/6)-r*r;for(let a=0;a<e.length;a++){if(a<t-1){n.push({index:a,value:null});continue}let o=0,s=0;for(let n=0;n<t;n++){let r=e[a-(t-1-n)].close;o+=r,s+=n*r}let c=(t*s-r*o)/i,l=(o-c*r)/t+c*(t-1);n.push({index:a,value:l})}return n}render(e,t,n,r,i){var a;let o=e.canvas,s=o._priceRange;if(!s)return;let c=(a=o._chartWidth)==null?e.canvas.width:a;e.beginPath(),e.strokeStyle=this.color,e.lineWidth=1.5,e.lineJoin=`round`;let l=!1;for(let a of t){if(a.value===null){l=!1;continue}let t=n.xToPixel(a.index,r,c),o=n.yToPixel(a.value,s,i);l?e.lineTo(t,o):(e.moveTo(t,o),l=!0)}e.stroke()}},jl=[{name:`Moving Average`,short_name:`MA`,type:`Trend`,enabled:!0},{name:`Exponential Moving Average`,short_name:`EMA`,type:`Trend`,enabled:!0},{name:`Weighted Moving Average`,short_name:`WMA`,type:`Trend`,enabled:!0},{name:`Hull Moving Average`,short_name:`HMA`,type:`Trend`,enabled:!0},{name:`Moving Average Ribbon`,short_name:`MARibbon`,type:`Trend`,enabled:!0},{name:`Bollinger Bands`,short_name:`BB`,type:`Volatility`,enabled:!0},{name:`Keltner Channels`,short_name:`KC`,type:`Volatility`,enabled:!0},{name:`Donchian Channels`,short_name:`DC`,type:`Volatility`,enabled:!0},{name:`Average True Range`,short_name:`ATR`,type:`Volatility`,enabled:!0},{name:`Relative Strength Index`,short_name:`RSI`,type:`Momentum`,enabled:!0},{name:`Stochastic Oscillator`,short_name:`Stoch`,type:`Momentum`,enabled:!0},{name:`Stochastic RSI`,short_name:`StochRSI`,type:`Momentum`,enabled:!0},{name:`MACD`,short_name:`MACD`,type:`Momentum`,enabled:!0},{name:`Commodity Channel Index`,short_name:`CCI`,type:`Momentum`,enabled:!0},{name:`Williams %R`,short_name:`%R`,type:`Momentum`,enabled:!0},{name:`Rate of Change`,short_name:`ROC`,type:`Momentum`,enabled:!0},{name:`On Balance Volume`,short_name:`OBV`,type:`Volume`,enabled:!0},{name:`Volume`,short_name:`VOL`,type:`Volume`,enabled:!0},{name:`Volume Weighted Average Price`,short_name:`VWAP`,type:`Volume`,enabled:!0},{name:`Accumulation/Distribution`,short_name:`A/D`,type:`Volume`,enabled:!0},{name:`Money Flow Index`,short_name:`MFI`,type:`Volume`,enabled:!0},{name:`Chaikin Money Flow`,short_name:`CMF`,type:`Volume`,enabled:!0},{name:`Pivot Points Standard`,short_name:`Pivot`,type:`Support/Resistance`,enabled:!0},{name:`Fibonacci Retracement`,short_name:`Fib`,type:`Support/Resistance`,enabled:!0},{name:`Supertrend`,short_name:`Supertrend`,type:`Trend`,enabled:!0},{name:`Parabolic SAR`,short_name:`PSAR`,type:`Trend`,enabled:!0},{name:`Ichimoku Cloud`,short_name:`Ichimoku`,type:`Trend`,enabled:!0},{name:`ADX`,short_name:`ADX`,type:`Trend Strength`,enabled:!0},{name:`Awesome Oscillator`,short_name:`AO`,type:`Momentum`,enabled:!0},{name:`Heikin Ashi`,short_name:`HA`,type:`Price Transformation`,enabled:!1},{name:`Linear Regression`,short_name:`LinReg`,type:`Trend`,enabled:!0}];function Ml(e,t){if(e.length===0||t<=0)return e;let n=new Map;for(let r of e){let e=Math.floor(r.time/t)*t,i=n.get(e);i?i.push(r):n.set(e,[r])}let r=[];for(let[e,t]of n){let n=t[0].high,a=t[0].low,o=0;for(let e of t){var i;e.high>n&&(n=e.high),e.low<a&&(a=e.low),o+=(i=e.volume)==null?0:i}r.push({time:e,open:t[0].open,high:n,low:a,close:t[t.length-1].close,volume:o})}return r.sort((e,t)=>e.time-t.time),r}var Nl,Pl=new Set([`VOL`,`HA`,`OBV`,`A/D`,`AO`,`VWAP`,`Ichimoku`,`PSAR`,`Pivot`]),Fl=[`#2962FF`,`#FF6D00`,`#00BFA5`,`#D500F9`,`#FFD600`,`#26A69A`,`#EF5350`,`#AB47BC`],Il=[{shortName:`MA`,factory:()=>new Wc(20)},{shortName:`EMA`,factory:()=>new Kc(20)},{shortName:`WMA`,factory:()=>new qc(20)},{shortName:`HMA`,factory:()=>new Yc(20)},{shortName:`MARibbon`,factory:()=>new Qc},{shortName:`BB`,factory:()=>new $c(20,2)},{shortName:`KC`,factory:()=>new el(20,2)},{shortName:`DC`,factory:()=>new tl(20)},{shortName:`ATR`,factory:()=>new nl(14)},{shortName:`RSI`,factory:()=>new rl(14)},{shortName:`Stoch`,factory:()=>new il(14,3)},{shortName:`StochRSI`,factory:()=>new ol(14,14,3,3)},{shortName:`MACD`,factory:()=>new cl(12,26,9)},{shortName:`CCI`,factory:()=>new ll(20)},{shortName:`%R`,factory:()=>new ul(14)},{shortName:`ROC`,factory:()=>new dl(12)},{shortName:`AO`,factory:()=>new Dl},{shortName:`OBV`,factory:()=>new fl},{shortName:`VWAP`,factory:()=>new pl},{shortName:`A/D`,factory:()=>new ml},{shortName:`MFI`,factory:()=>new hl(14)},{shortName:`CMF`,factory:()=>new gl(20)},{shortName:`Pivot`,factory:()=>new _l},{shortName:`Fib`,factory:()=>new xl(50)},{shortName:`Supertrend`,factory:()=>new Sl(10,3)},{shortName:`PSAR`,factory:()=>new Cl(.02,.2)},{shortName:`Ichimoku`,factory:()=>new Tl(9,26,52)},{shortName:`ADX`,factory:()=>new El(14)},{shortName:`HA`,factory:()=>new Ol},{shortName:`VOL`,factory:()=>new kl},{shortName:`LinReg`,factory:()=>new Al(14)}],Ll={kind:`select`,key:`timeframe`,label:`Timeframe`,options:[`Chart`,`1m`,`5m`,`15m`,`30m`,`1h`,`2h`,`4h`,`8h`,`1D`,`1W`,`1M`],default:`Chart`};function Rl(e,t,n){if(!n)return e;let r=n.fields.filter(e=>e.kind===`number`).map(e=>{var n;return(n=t[e.key])==null?e.default:n});return r.length>0?`${e}(${r.join(`, `)})`:e}var zl=[{shortName:`MA`,fields:[{kind:`number`,key:`period`,label:`Period`,min:1,max:500,step:1,default:20},{kind:`color`,key:`color`,label:`Color`,default:`#F5A623`},{kind:`select`,key:`source`,label:`Source`,options:[`open`,`high`,`low`,`close`],default:`close`}],factory:e=>new Wc(e.period,e.color,`MA`,e.source)},{shortName:`EMA`,fields:[{kind:`number`,key:`period`,label:`Period`,min:1,max:500,step:1,default:20},{kind:`color`,key:`color`,label:`Color`,default:`#9B59B6`},{kind:`select`,key:`source`,label:`Source`,options:[`open`,`high`,`low`,`close`],default:`close`}],factory:e=>new Kc(e.period,e.color,`EMA`,e.source)},{shortName:`WMA`,fields:[{kind:`number`,key:`period`,label:`Period`,min:1,max:500,step:1,default:20},{kind:`color`,key:`color`,label:`Color`,default:`#e91e63`},{kind:`select`,key:`source`,label:`Source`,options:[`open`,`high`,`low`,`close`],default:`close`}],factory:e=>new qc(e.period,e.color,`WMA`,e.source)},{shortName:`HMA`,fields:[{kind:`number`,key:`period`,label:`Period`,min:1,max:500,step:1,default:20},{kind:`color`,key:`color`,label:`Color`,default:`#00bcd4`},{kind:`select`,key:`source`,label:`Source`,options:[`open`,`high`,`low`,`close`],default:`close`}],factory:e=>new Yc(e.period,e.color,`HMA`,e.source)},{shortName:`MARibbon`,fields:[{kind:`color`,key:`color`,label:`Color`,default:`#ffcc80`},{kind:`select`,key:`source`,label:`Source`,options:[`open`,`high`,`low`,`close`],default:`close`}],factory:e=>new Qc(e.color,e.source)},{shortName:`BB`,fields:[{kind:`number`,key:`period`,label:`Period`,min:1,max:500,step:1,default:20},{kind:`number`,key:`stdDev`,label:`Std Dev`,min:.1,max:10,step:.1,default:2},{kind:`color`,key:`color`,label:`Color`,default:`#3B82F6`},{kind:`select`,key:`source`,label:`Source`,options:[`open`,`high`,`low`,`close`],default:`close`}],factory:e=>new $c(e.period,e.stdDev,e.color,`BB`,e.source)},{shortName:`KC`,fields:[{kind:`number`,key:`period`,label:`Period`,min:1,max:500,step:1,default:20},{kind:`number`,key:`mult`,label:`Multiplier`,min:.1,max:10,step:.1,default:2},{kind:`number`,key:`atrPeriod`,label:`ATR Period`,min:1,max:500,step:1,default:10},{kind:`color`,key:`color`,label:`Color`,default:`#4caf50`}],factory:e=>new el(e.period,e.mult,e.atrPeriod,e.color)},{shortName:`DC`,fields:[{kind:`number`,key:`period`,label:`Period`,min:1,max:500,step:1,default:20},{kind:`color`,key:`color`,label:`Color`,default:`#26c6da`}],factory:e=>new tl(e.period,e.color)},{shortName:`ATR`,fields:[{kind:`number`,key:`period`,label:`Period`,min:1,max:500,step:1,default:14},{kind:`color`,key:`color`,label:`Color`,default:`#ff5722`}],factory:e=>new nl(e.period,e.color)},{shortName:`RSI`,fields:[{kind:`number`,key:`period`,label:`Period`,min:1,max:500,step:1,default:14},{kind:`color`,key:`color`,label:`Color`,default:`#e8b84b`},{kind:`select`,key:`source`,label:`Source`,options:[`open`,`high`,`low`,`close`],default:`close`}],factory:e=>new rl(e.period,e.color,`RSI`,e.source)},{shortName:`Stoch`,fields:[{kind:`number`,key:`kPeriod`,label:`K Period`,min:1,max:500,step:1,default:14},{kind:`number`,key:`dPeriod`,label:`D Period`,min:1,max:100,step:1,default:3},{kind:`color`,key:`color`,label:`Color`,default:`#e040fb`}],factory:e=>new il(e.kPeriod,e.dPeriod,e.color)},{shortName:`StochRSI`,fields:[{kind:`number`,key:`rsiPeriod`,label:`RSI Period`,min:1,max:500,step:1,default:14},{kind:`number`,key:`stochPeriod`,label:`Stoch Period`,min:1,max:500,step:1,default:14},{kind:`number`,key:`kPeriod`,label:`K Smooth`,min:1,max:100,step:1,default:3},{kind:`number`,key:`dPeriod`,label:`D Smooth`,min:1,max:100,step:1,default:3},{kind:`color`,key:`color`,label:`Color`,default:`#00e5ff`}],factory:e=>new ol(e.rsiPeriod,e.stochPeriod,e.kPeriod,e.dPeriod,e.color)},{shortName:`MACD`,fields:[{kind:`number`,key:`fast`,label:`Fast Period`,min:1,max:500,step:1,default:12},{kind:`number`,key:`slow`,label:`Slow Period`,min:1,max:500,step:1,default:26},{kind:`number`,key:`signal`,label:`Signal Period`,min:1,max:100,step:1,default:9},{kind:`color`,key:`color`,label:`Color`,default:`#2196f3`},{kind:`select`,key:`source`,label:`Source`,options:[`open`,`high`,`low`,`close`],default:`close`}],factory:e=>new cl(e.fast,e.slow,e.signal,e.color,`MACD`,e.source)},{shortName:`CCI`,fields:[{kind:`number`,key:`period`,label:`Period`,min:1,max:500,step:1,default:20},{kind:`color`,key:`color`,label:`Color`,default:`#4db6ac`}],factory:e=>new ll(e.period,e.color)},{shortName:`%R`,fields:[{kind:`number`,key:`period`,label:`Period`,min:1,max:500,step:1,default:14},{kind:`color`,key:`color`,label:`Color`,default:`#ff7043`}],factory:e=>new ul(e.period,e.color)},{shortName:`ROC`,fields:[{kind:`number`,key:`period`,label:`Period`,min:1,max:500,step:1,default:12},{kind:`color`,key:`color`,label:`Color`,default:`#80cbc4`},{kind:`select`,key:`source`,label:`Source`,options:[`open`,`high`,`low`,`close`],default:`close`}],factory:e=>new dl(e.period,e.color,e.source)},{shortName:`AO`,fields:[{kind:`number`,key:`fastPeriod`,label:`Fast Period`,min:1,max:100,step:1,default:5},{kind:`number`,key:`slowPeriod`,label:`Slow Period`,min:1,max:200,step:1,default:34},{kind:`color`,key:`color`,label:`Color`,default:`#b0bec5`}],factory:e=>new Dl(e.fastPeriod,e.slowPeriod,e.color)},{shortName:`OBV`,fields:[{kind:`color`,key:`color`,label:`Color`,default:`#aed581`}],factory:e=>new fl(e.color)},{shortName:`VWAP`,fields:[{kind:`color`,key:`color`,label:`Color`,default:`#9c27b0`}],factory:e=>new pl(e.color)},{shortName:`A/D`,fields:[{kind:`color`,key:`color`,label:`Color`,default:`#ce93d8`}],factory:e=>new ml(e.color)},{shortName:`MFI`,fields:[{kind:`number`,key:`period`,label:`Period`,min:1,max:500,step:1,default:14},{kind:`color`,key:`color`,label:`Color`,default:`#ffab40`}],factory:e=>new hl(e.period,e.color)},{shortName:`CMF`,fields:[{kind:`number`,key:`period`,label:`Period`,min:1,max:500,step:1,default:20},{kind:`color`,key:`color`,label:`Color`,default:`#80deea`}],factory:e=>new gl(e.period,e.color)},{shortName:`Pivot`,fields:[{kind:`color`,key:`color`,label:`Color`,default:`#ffd54f`}],factory:e=>new _l(e.color)},{shortName:`Fib`,fields:[{kind:`number`,key:`lookback`,label:`Lookback`,min:1,max:500,step:1,default:50},{kind:`color`,key:`color`,label:`Color`,default:`#e1bee7`}],factory:e=>new xl(e.lookback,e.color)},{shortName:`Supertrend`,fields:[{kind:`number`,key:`atrPeriod`,label:`ATR Period`,min:1,max:500,step:1,default:10},{kind:`number`,key:`multiplier`,label:`Multiplier`,min:.1,max:20,step:.1,default:3},{kind:`color`,key:`color`,label:`Color`,default:`#26a69a`}],factory:e=>new Sl(e.atrPeriod,e.multiplier,e.color)},{shortName:`PSAR`,fields:[{kind:`number`,key:`step`,label:`Step`,min:.001,max:.1,step:.001,default:.02},{kind:`number`,key:`maxAF`,label:`Max AF`,min:.01,max:1,step:.01,default:.2},{kind:`color`,key:`color`,label:`Color`,default:`#ff6b9d`}],factory:e=>new Cl(e.step,e.maxAF,e.color)},{shortName:`Ichimoku`,fields:[{kind:`number`,key:`tenkan`,label:`Tenkan Period`,min:1,max:100,step:1,default:9},{kind:`number`,key:`kijun`,label:`Kijun Period`,min:1,max:200,step:1,default:26},{kind:`number`,key:`senkouB`,label:`Senkou B Period`,min:1,max:500,step:1,default:52},{kind:`color`,key:`color`,label:`Color`,default:`#b0bec5`}],factory:e=>new Tl(e.tenkan,e.kijun,e.senkouB,e.color)},{shortName:`ADX`,fields:[{kind:`number`,key:`period`,label:`Period`,min:1,max:500,step:1,default:14},{kind:`color`,key:`color`,label:`Color`,default:`#fff176`}],factory:e=>new El(e.period,e.color)},{shortName:`HA`,fields:[{kind:`color`,key:`color`,label:`Color`,default:`#90a4ae`},{kind:`color`,key:`upColor`,label:`Up Color`,default:`#26a69a`},{kind:`color`,key:`downColor`,label:`Down Color`,default:`#ef5350`}],factory:e=>new Ol(e.color,e.upColor,e.downColor)},{shortName:`VOL`,fields:[{kind:`color`,key:`upColor`,label:`Up Color`,default:`#26a69a`},{kind:`color`,key:`downColor`,label:`Down Color`,default:`#ef5350`}],factory:e=>new kl(e.upColor,e.downColor)},{shortName:`LinReg`,fields:[{kind:`number`,key:`period`,label:`Period`,min:1,max:500,step:1,default:14},{kind:`color`,key:`color`,label:`Color`,default:`#ff9800`}],factory:e=>new Al(e.period,e.color)}],Bl=70,Vl=24,Hl=.18,Ul=80,Wl=1,Gl=80,Kl=10,ql=.25,Jl=.2,Yl=`fc-symbol-link`;function Xl(){if(typeof document>`u`||document.getElementById(`fc-symbol-link-styles`))return;let e=document.createElement(`style`);e.id=`fc-symbol-link-styles`,e.textContent=`
|
|
267
|
-
.${
|
|
268
|
-
.${
|
|
269
|
-
.${
|
|
270
|
-
`,document.head.appendChild(e)}function Zl(){return typeof window<`u`&&(`ontouchstart`in window||navigator.maxTouchPoints>1)}function Ql(e=2,t=!1,n=Gl,r,i,a){if(i&&i>0&&a&&a>0){let e=Math.floor(i/a);return Math.max(10,Math.min(500,e))}return!t&&!Zl()?n:r===void 0?Math.max(10,Math.round(n/e)):r}var $l=4;function eu(e,t){let n=(e.min+e.max)/2,r=(e.max-e.min)/2;return{min:n-r*t,max:n+r*t}}function tu(e){let t=e.max-e.min;return t>=100?0:t>=10?1:t>=1?2:t>=.1?3:4}var nu=class n{get _tb(){var e,t,n;return(e=(t=(n=this.topBar)==null?this.advancedToolbar:n)==null?this.compactToolbar:t)==null?this.mobileHeader:e}visibleStates(){return this.activeIndicators.filter(e=>{if(!e.visible)return!1;let t=e.currentParams.timeframe;return!(t&&t!==`Chart`&&t!==this.timeframe)})}get indicators(){return this.visibleStates().map(e=>e.indicator)}scheduleViewportPersist(){this._viewportPersistTimer&&clearTimeout(this._viewportPersistTimer),this._viewportPersistTimer=setTimeout(()=>{this._viewportPersistTimer=null,this.emitStateChange()},500)}get isFullscreen(){return this._isCssFullscreen||!!document.fullscreenElement}get _isTradingActive(){var e,t,n,r,i,a;return((e=(t=this.tradePopover)==null?void 0:t.isVisible)==null?!1:e)||this.draftOrderLabel!==null||((n=(r=this.tradeDragHandler)==null?void 0:r.active)==null?!1:n)||((i=(a=this.orderTimeDragHandler)==null?void 0:a.active)==null?!1:i)||this.pendingLevelDrags.size>0}constructor(i){var a,o,l,u,d,f,h,g,_,v,y,b,x,S,C,w,E,O,A,ee,te,ne,M,N,P,re,ie;if(this.topBar=null,this.advancedToolbar=null,this.compactToolbar=null,this.mobileHeader=null,this.bottomBar=null,this.leftBar=null,this.leftBarVisible=!0,this.layoutPopover=null,this.snapshotPopover=null,this.currentPresetId=`1`,this.currentSync={...Ur},this.drawingToolsEnabled=!0,this.settingsEnabled=!0,this.fullscreenEnabled=!0,this._mobileLayout=!1,this.indicatorOverlay=null,this.subPaneOverlays=new Map,this.isinPickerModal=null,this.isins=[],this.compareManager=null,this.compareLegend=null,this.comparePickerModal=null,this.compareDataLoader=null,this.compareHoveredIndex=null,this.siEl=null,this.siStreamDot=null,this.siSymbolSpan=null,this.siOHLCSpan=null,this.siOHLC2Span=null,this.tickActivityTimer=null,this.tickActivityMs=3e4,this.streamStatus=`disconnected`,this._isDestroyed=!1,this.indicatorSettingsDialog=null,this.chartSettingsDialog=null,this.tradeButton=null,this.tradePopover=null,this.drawingStylePopover=null,this.draftOrderLabel=null,this._minLots=1,this._showQuantityField=!1,this._qtyFieldMin=1,this._qtyFieldMax=100,this._draftQtyFlyout=null,this._draftQtyPillArea=void 0,this._activeQtyPillLabel=void 0,this.pendingQtyChanges=new Map,this.originalQtyByLabel=new Map,this._onOrderSubmit=void 0,this.scrollToEndBtn=null,this.scrollToEndVisible=!1,this.scrollAnimId=null,this.resetViewBtn=null,this.resetViewVisible=!1,this._defaultVisibleBars=Gl,this.dataStore=new t,this.scaleManager=new r,this.emitter=new s,this.themeName=`dark`,this._debug=!1,this.symbol=``,this.showBidAskLines=!1,this.showActLogo=!1,this.hideLevelConfirmCancel=!1,this.deselectActiveOnOutsideClick=!1,this.tradeLevelButtonScale=1,this.levelClusteringEnabled=!0,this.clusterThresholdDistance=20,this.enableThemeToggle=!1,this.activeIndicators=[],this.indicatorInstanceSeq=0,this.indicatorResults=new Map,this.viewport={startIndex:0,endIndex:Ql(),candleWidth:8,candleGap:2},this._targetViewport={startIndex:0,endIndex:Ql(),candleWidth:8,candleGap:2},this._isPanning=!1,this.crosshair=null,this.drawingManager=new lc,this.textInputEl=null,this.textInputDrawing=null,this._pendingDrawDrag=null,this._pendingDrawResize=null,this._pendingTradeDrag=null,this.paneHeightOverrides=new Map,this.separatorDrag=null,this.priceAxisWidth=Bl,this.timeAxisHeight=Vl,this.priceScaleFactor=1,this.pricePanOffset=0,this._displayedPriceRange=null,this._lockedAutoFitBase=null,this._lastInCompareMode=!1,this._pendingViewportRestore=null,this._viewportPersistTimer=null,this.axisDrag=null,this.subPaneScaleFactors=new Map,this._mobileCrosshairActive=!1,this._mobileTapStartXY=null,this._longPressTimer=null,this._longPressPoint=null,this._lastTouchTime=0,this._tradeButtonClickData=null,this.disposeVvListener=()=>{},this.rafId=null,this.countdownRafId=null,this.countdownActive=!1,this._cachedWrapRect=null,this._cachedDrawRect=null,this._drawTouchAnchorActive=!1,this._lastDrawingTouchPoint=null,this._drawTouchStartXY=null,this._mobileDrawingFlyout=null,this._isCssFullscreen=!1,this.timezone=`UTC`,this.settingsCanvasColors={},this.streamAdapter=null,this.liveBidAsk=null,this.liveLtp=null,this.tickClosePriceSource=`bid`,this._suppressTicks=!1,this.levels=[],this.tradeLevelHitAreas=[],this.offViewportHitAreas=[],this.tradeLevelEditAreas=[],this.tradeHoverAreas=[],this.tradeLevelDragAreas=[],this.tradeLevelConfirmAreas=[],this.tradeAddBracketAreas=[],this.clusterBadgeAreas=[],this.lastClusters=[],this.expandedClusters=new Set,this.hoveredTradeLabel=null,this.selectedTradeLabel=null,this._editOpenLabel=null,this.draftBracketPnl={},this.tradeDragHandler=null,this.orderTimeDragHandler=null,this.tradeDragNewBarIndex=null,this._orderTimeDragEnabled=!1,this._orderLineDragSnap=!0,this._timeAnchorOverride=new Map,this.tradeDragNewPrice=null,this.tradeDragNewSLPrice=null,this.tradeDragNewTPPrice=null,this._pendingBracketOrderLabel=null,this._slSiblingOrderLabel=null,this._tpSiblingOrderLabel=null,this._isBracketNew=!1,this.pendingLevelDrags=new Map,this.tfcEnabled=!0,this.tfcActive=!0,this.tradeDisplayFilter=`all`,this.positionRenderStyle=`dot`,this.tradesThresholdForHorizontalLine=2,this.positionRenderStyleOverride=null,this.RENDER_STYLE_LS_KEY=`finchart:positionRenderStyle`,this.dataLoader=null,this.isFetching=!1,this.noMoreData=!1,this._loadGeneration=0,this.maxCandles=200,this.minInitialBars=10,this.maxLookbackMs=365*24*60*60*1e3,this.prefetchThreshold=80,this.defaultVisibleBars=Gl,this.defaultMobileVisibleBars=void 0,this.mobileBarDivisor=2,this.explicitMobileDivisor=!1,this._autoVisibleBars=!0,this.targetCandleWidth=Kl,this.maxSubPanes=3,this.showCandleCountdown=!0,this.showTradeLevelsAlways=!1,this.showPriceAxisCountdown=!1,this.SHOW_SLTP_ALWAYS_LS_KEY=`finchart.showTradeLevelsAlways`,this.PRICE_AXIS_COUNTDOWN_LS_KEY=`finchart.showPriceAxisCountdown`,this.loadingOverlayEl=null,this.noDataOverlayEl=null,this.logoImage=null,this.isRestoringState=!1,this.onMouseMove=e=>{var t,r,i,a,o,s;if(this._mobileCrosshairActive||Date.now()-this._lastTouchTime<500)return;let c=(t=this._cachedDrawRect)==null?this.drawCanvas.getBoundingClientRect():t,l=e.clientX-c.left,u=e.clientY-c.top,{chartW:d,priceH:f}=this.getChartLayout(),p=(r=this._displayedPriceRange)==null?this.getScaledPriceRange(this.viewport):r,m=c.height-this.timeAxisHeight,h=l<d&&u<m,g=this.scaleManager.pixelToBarIndex(l,this.viewport,d),_=this.scaleManager.pixelToPrice(u,p,f),v=Math.max(Math.floor(this.viewport.startIndex),Math.min(Math.ceil(this.viewport.endIndex),Math.round(g))),y=(i=this.dataStore.all[v])==null?null:i;this.crosshair=h&&!((a=this.tradePopover)!=null&&a.isVisible)&&this.selectedTradeLabel===null?{x:l,y:u,barIndex:v,price:_,bar:y}:null,this.emitter.emit(`crosshair`,this.crosshair);let b=this.positionRenderStyle===`dot`&&this.hoveredTradeLabel!==null;if(this.tradeButton&&(h&&u>=0&&u<=f&&!this._isTradingActive&&!b?(this.tradeButton.setY(u),It(u,this.uiConfig.tradeButton.size/2,this.offViewportHitAreas)?this.tradeButton.hide():this.tfcActive&&this.tradeButton.show(),this._tradeButtonClickData={price:_,y:u}):this.tradeButton.hide()),this._pendingDrawResize){let e=l-this._pendingDrawResize.startX,t=u-this._pendingDrawResize.startY;Math.sqrt(e*e+t*t)>n.DRAW_GESTURE_THRESHOLD&&(this.drawingManager.startResize(this._pendingDrawResize.drawing,this._pendingDrawResize.pointIndex),this._pendingDrawResize=null)}if(this._pendingDrawDrag){let e=l-this._pendingDrawDrag.startX,t=u-this._pendingDrawDrag.startY;Math.sqrt(e*e+t*t)>n.DRAW_GESTURE_THRESHOLD&&(this.drawingManager.startDrag(this._pendingDrawDrag.drawing,this.makeDrawingPoint(g,_)),this._pendingDrawDrag=null)}if(this.drawingManager.onMouseMove(this.makeDrawingPoint(g,_)),this.axisDrag){if(this.axisDrag.axis===`price`){let e=u-this.axisDrag.startPos;this.priceScaleFactor=Math.max(.1,Math.min(10,this.axisDrag.startSize*1.005**e))}else if(this.axisDrag.axis===`subpane`&&this.axisDrag.instanceId){let e=u-this.axisDrag.startPos,t=Math.max(.1,Math.min(20,this.axisDrag.startSize*1.005**e));this.subPaneScaleFactors.set(this.axisDrag.instanceId,t)}else{let e=l-this.axisDrag.startPos,t=Math.max(10,Math.min(500,Math.round(this.axisDrag.startSize+e*.5))),n=(this.viewport.startIndex+this.viewport.endIndex)/2,r=Math.max(0,n-t/2);this.viewport={...this.viewport,startIndex:r,endIndex:r+t},this._targetViewport={...this.viewport}}this.drawCanvas.style.cursor=this.axisDrag.axis===`time`?`ew-resize`:`ns-resize`,this.scheduleRender();return}if(this.separatorDrag){let e=this.separatorDrag.startY-u,t=Math.max(40,Math.min(300,this.separatorDrag.startH+e));this.paneHeightOverrides.set(this.separatorDrag.instanceId,t),this.drawCanvas.style.cursor=`ns-resize`,this.scheduleRender();return}if(this._pendingTradeDrag){let e=l-this._pendingTradeDrag.startX,t=u-this._pendingTradeDrag.startY;if(Math.sqrt(e*e+t*t)>n.TRADE_DRAG_PIXEL_THRESHOLD){var x;let{dragHit:e,level:t,hitY:n,startX:r}=this._pendingTradeDrag;this._pendingTradeDrag=null,this._startTradeDragFromHit(e,t,n,r),this.drawCanvas.style.cursor=(x=this.orderTimeDragHandler)!=null&&x.active?`grabbing`:`ns-resize`}else return}if((o=this.orderTimeDragHandler)!=null&&o.active){let e=this.orderTimeDragHandler.onMove(l,this.scaleManager,this.viewport,d);this.tradeDragNewBarIndex=e,this.drawCanvas.style.cursor=`grabbing`,this.renderTradeLayer();let t=this.orderTimeDragHandler.dragLabel,n=e===null?void 0:this.barIndexToTimestamp(e);t&&e!==null&&n!==void 0&&this.emitter.emit(`orderLineMoving`,{label:t,toTimestamp:n,toBarIndex:e,isFullscreen:this.isFullscreen});return}if((s=this.tradeDragHandler)!=null&&s.active){var S,C,w;let e=this.tradeDragHandler.onMouseMove(u,this.scaleManager,p,f);if(this.tradeDragNewPrice=(S=e==null?void 0:e.newPrice)==null?null:S,this.tradeDragNewSLPrice=(C=e==null?void 0:e.derivedSLPrice)==null?null:C,this.tradeDragNewTPPrice=(w=e==null?void 0:e.derivedTPPrice)==null?null:w,this.drawCanvas.style.cursor=`ns-resize`,this.renderTradeLayer(),this.tradeDragNewPrice!==null&&e){let t=e.label.indexOf(`:`),n=t===-1?e.label:e.label.slice(0,t),r=t===-1?void 0:e.label.slice(t+1),i=this.levels.find(e=>e.label===n);i&&this.emitter.emit(`tradeLevelDrag`,{label:i.label,newPrice:this.tradeDragNewPrice,data:i.data,bracketType:r,...e.derivedSLPrice===void 0?{}:{derivedSLPrice:e.derivedSLPrice},...e.derivedTPPrice===void 0?{}:{derivedTPPrice:e.derivedTPPrice},isFullscreen:this.isFullscreen})}return}if(!this.drawingManager.getActiveTool()){var T;if(xe(l,u,this.clusterBadgeAreas)||gt(l,u,this.tradeLevelHitAreas)||_t(l,u,this.tradeLevelEditAreas)||vt(l,u,this.tradeLevelConfirmAreas)||Ft(l,u,this.offViewportHitAreas)){this.drawCanvas.style.cursor=`pointer`,this.scheduleRender();return}let e=bt(l,u,this.tradeLevelDragAreas);if(e){this.drawCanvas.style.cursor=this._orderTimeDragEnabled&&e.timeDrag===!0?`grab`:`ns-resize`,e.label!==this.hoveredTradeLabel&&(this.hoveredTradeLabel=e.label,this.renderTradeLayer()),this.scheduleRender();return}let t=yt(l,u,this.tradeHoverAreas),n=(T=t==null?void 0:t.label)==null?null:T;if(n!==this.hoveredTradeLabel&&(this.hoveredTradeLabel=n,this.renderTradeLayer()),this.positionRenderStyle===`dot`&&n!==null){this.crosshair=null,this.drawCanvas.style.cursor=`pointer`,this.scheduleRender();return}if(this.getSeparatorPositions().find(e=>Math.abs(u-e.y)<=4))this.drawCanvas.style.cursor=`ns-resize`;else if(l>=d)this.drawCanvas.style.cursor=`ns-resize`;else if(u>=m)this.drawCanvas.style.cursor=`ew-resize`;else if(this.drawingManager.isDraggingDrawing()||this.drawingManager.isResizingDrawing())this.drawCanvas.style.cursor=`grabbing`;else{let e=this.drawingManager.getHandleAtPoint(l,u,this.scaleManager,this.viewport,p,d,f);if(e)this.drawCanvas.style.cursor=e.handle.cursor;else{let e=this.drawingManager.hitTest(l,u,this.scaleManager,this.viewport,p,d,f);this.drawCanvas.style.cursor=e?`move`:`default`}}}this.scheduleRender()},this.onMouseLeave=e=>{if(!(this.tradeButton&&this.tradeButton.el.contains(e.relatedTarget))&&!this._mobileCrosshairActive){if(this.crosshair=null,this.emitter.emit(`crosshair`,null),!this._isTradingActive){var t;(t=this.tradeButton)==null||t.hide()}this.hoveredTradeLabel!==null&&(this.hoveredTradeLabel=null,this.renderTradeLayer()),this.scheduleRender()}},this.onMouseUp=()=>{var e;if(this._pendingTradeDrag){let{level:e}=this._pendingTradeDrag;if(this._pendingTradeDrag=null,this._editOpenLabel===e.label&&!this.pendingLevelDrags.has(e.label)){this._cancelEditAndDeselect(e.label);return}this._openTradeLevelEditForm(e);return}if(!this._endOrderTimeDrag()){if((e=this.tradeDragHandler)!=null&&e.active){let e=this.tradeDragHandler.endDrag();if(e){var t;this._finalizeMainDragWithBrackets(e,(t=this._pendingBracketOrderLabel)==null?void 0:t)}else this.tradeDragNewPrice=null;this._pendingBracketOrderLabel=null,this.drawCanvas.style.cursor=`default`,this.renderTradeLayer();return}if(this.axisDrag){let e=this.axisDrag.axis===`price`||this.axisDrag.axis===`time`;this.axisDrag=null,this.drawCanvas.style.cursor=`default`,this.scheduleRender(),e&&this.scheduleViewportPersist()}this.separatorDrag&&(this.separatorDrag=null,this.drawCanvas.style.cursor=`default`,this.scheduleRender()),this._pendingDrawDrag=null,this._pendingDrawResize=null,this.drawingManager.isDraggingDrawing()&&(this.drawingManager.endDrag(),this.drawCanvas.style.cursor=`default`,this.scheduleRender()),this.drawingManager.isResizingDrawing()&&(this.drawingManager.endResize(),this.drawCanvas.style.cursor=`default`,this.scheduleRender())}},this.onDrawingTouchStart=e=>{var t;if(e.touches.length!==1)return;let n=e.touches[0],r=this.touchToDrawingPoint(n),i=this.drawingManager.getActiveTool(),a=this.drawingManager.isPlacing();if(i!==null||a){e.preventDefault(),this._lastDrawingTouchPoint=r,a?(this._drawTouchAnchorActive=!1,this.drawingManager.onMouseMove(r)):(this.drawingManager.onMouseDown(r),this._drawTouchAnchorActive=this.drawingManager.isPlacing()),this.scheduleRender();return}let o=(t=this._cachedDrawRect)==null?this.drawCanvas.getBoundingClientRect():t,s=n.clientX-o.left,c=n.clientY-o.top,{chartW:l,priceH:u}=this.getChartLayout(),d=this.getScaledPriceRange(this.viewport);if(s>=l){if(e.preventDefault(),c<=u)this.axisDrag={axis:`price`,startPos:c,startSize:this.priceScaleFactor};else{let e=this.activeIndicators.filter(e=>e.indicator.pane===`sub`),t=u+Wl;for(let n of e){let e=this.paneH(n);if(c>=t&&c<t+e){var f;this.axisDrag={axis:`subpane`,startPos:c,startSize:(f=this.subPaneScaleFactors.get(n.instanceId))==null?1:f,instanceId:n.instanceId};break}t+=e+Wl}}this.scheduleRender();return}let p=o.height-this.timeAxisHeight;if(c>=p){e.preventDefault(),this.axisDrag={axis:`time`,startPos:s,startSize:this.viewport.endIndex-this.viewport.startIndex},this.scheduleRender();return}let m=this.drawingManager.getHandleAtPoint(s,c,this.scaleManager,this.viewport,d,l,u);if(m){e.preventDefault(),this.panHandler.cancel(),this.drawingManager.selectDrawing(m.drawing),this.drawingManager.startResize(m.drawing,m.handle.pointIndex),this.hideMobileDrawingFlyout(),this.scheduleRender();return}let h=this.drawingManager.hitTest(s,c,this.scaleManager,this.viewport,d,l,u);if(h){e.preventDefault(),this.panHandler.cancel(),this.drawingManager.selectDrawing(h),this.drawingManager.startDrag(h,r),this._drawTouchStartXY={x:n.clientX,y:n.clientY},this.hideMobileDrawingFlyout(),this.scheduleRender();return}let g=xe(s,c,this.clusterBadgeAreas);if(g){e.preventDefault(),this.panHandler.cancel(),this.expandedClusters.has(g.clusterId)?this.expandedClusters.delete(g.clusterId):this.expandedClusters.add(g.clusterId),this.renderTradeLayer();return}let _=Ft(s,c,this.offViewportHitAreas);if(_){e.preventDefault(),this.panHandler.cancel(),this.scrollToCenterPrice(_.targetPrice);return}let v=vt(s,c,this.tradeLevelConfirmAreas);if(v){e.preventDefault(),v.action===`confirm`?this.applyPendingChanges(v.label):this.revertPendingChanges(v.label);return}if(this._showQuantityField&&this._draftQtyPillArea){let t=this._draftQtyPillArea;if(s>=t.pillX&&s<=t.pillX+t.pillW&&c>=t.pillY&&c<=t.pillY+t.pillH){e.preventDefault(),e.stopPropagation(),this.openDraftQtyFlyout(t);return}}let y=gt(s,c,this.tradeLevelHitAreas);if(y){e.preventDefault(),this._handleTradeLevelClose(y);return}if(!this.drawingManager.getActiveTool()){let t=_t(s,c,this.tradeLevelEditAreas);if(t){e.preventDefault();let n=this.levels.find(e=>e.label===t.label);n&&this._openTradeLevelEditForm(n);return}}if(this.tradeDragHandler&&!this.drawingManager.getActiveTool()){let t=bt(s,c,this.tradeLevelDragAreas);if(t){e.preventDefault();let n=this.levels.find(e=>e.label===t.label);if(n){let e=this.selectedTradeLabel===n.label,r=t.isBracket||this._orderTimeDragEnabled&&t.timeDrag===!0||n.type===`pending`&&n.orderType!==`market`&&(e||!t.isBox);if(this.hideLevelConfirmCancel&&!r){let e=this.pendingLevelDrags.has(n.label);if(this.selectedTradeLabel===n.label&&!e){this._cancelEditAndDeselect(n.label);return}this._openTradeLevelEditForm(n);return}this._startTradeDragFromHit(t,n,c,s),this.scheduleRender();return}}}if(this.tradeDragHandler&&!this.drawingManager.getActiveTool()){let t=xt(s,c,this.tradeAddBracketAreas);if(t){e.preventDefault(),this._startAddBracketFromHit(t,c),this.scheduleRender();return}}if(this.tradeDragHandler&&!this.drawingManager.getActiveTool()){let t=yt(s,c,this.tradeHoverAreas);if(t){e.preventDefault();let n=this.levels.find(e=>e.label===t.label);if(n){let e=this.pendingLevelDrags.has(t.label);if(this.selectedTradeLabel===t.label&&!e){this._cancelEditAndDeselect(t.label);return}this._openTradeLevelEditForm(n);return}}}this.drawingManager.selectDrawing(null),this.hideMobileDrawingFlyout(),this.expandedClusters.size>0&&(this.expandedClusters.clear(),this.renderTradeLayer()),s<l&&c<p&&(this._mobileCrosshairActive?(this._longPressTimer!==null&&(clearTimeout(this._longPressTimer),this._longPressTimer=null),this._mobileTapStartXY={x:s,y:c}):(this._longPressTimer!==null&&clearTimeout(this._longPressTimer),this._longPressPoint={x:s,y:c},this._longPressTimer=setTimeout(()=>{this._longPressTimer=null,this._longPressPoint&&(this._activateMobileCrosshair(this._longPressPoint.x,this._longPressPoint.y),this._longPressPoint=null)},500)))},this.onDrawingTouchMove=e=>{var t,n;if(e.touches.length!==1)return;let r=this.touchToDrawingPoint(e.touches[0]);if(this._lastDrawingTouchPoint=r,this.axisDrag){var i;e.preventDefault();let t=e.touches[0],n=(i=this._cachedDrawRect)==null?this.drawCanvas.getBoundingClientRect():i,r=t.clientX-n.left,a=t.clientY-n.top;if(this.axisDrag.axis===`price`){let e=a-this.axisDrag.startPos;this.priceScaleFactor=Math.max(.1,Math.min(10,this.axisDrag.startSize*1.005**e))}else if(this.axisDrag.axis===`subpane`&&this.axisDrag.instanceId){let e=a-this.axisDrag.startPos,t=Math.max(.1,Math.min(20,this.axisDrag.startSize*1.005**e));this.subPaneScaleFactors.set(this.axisDrag.instanceId,t)}else{let e=r-this.axisDrag.startPos,t=Math.max(10,Math.min(500,Math.round(this.axisDrag.startSize+e*.5))),n=(this.viewport.startIndex+this.viewport.endIndex)/2,i=Math.max(0,n-t/2);this.viewport={...this.viewport,startIndex:i,endIndex:i+t}}this.scheduleRender();return}if(this.drawingManager.isPlacing()&&!this._drawTouchAnchorActive){e.preventDefault(),this.drawingManager.onMouseMove(r),this.scheduleRender();return}if(this.drawingManager.isDraggingDrawing()||this.drawingManager.isResizingDrawing()){e.preventDefault(),e.stopPropagation(),this.drawingManager.onMouseMove(r),this.scheduleRender();return}if((t=this.orderTimeDragHandler)!=null&&t.active){var a;e.preventDefault();let t=e.touches[0],n=(a=this._cachedDrawRect)==null?this.drawCanvas.getBoundingClientRect():a,r=t.clientX-n.left,{chartW:i}=this.getChartLayout(),o=this.orderTimeDragHandler.onMove(r,this.scaleManager,this.viewport,i);this.tradeDragNewBarIndex=o,this.renderTradeLayer();let s=this.orderTimeDragHandler.dragLabel,c=o===null?void 0:this.barIndexToTimestamp(o);s&&o!==null&&c!==void 0&&this.emitter.emit(`orderLineMoving`,{label:s,toTimestamp:c,toBarIndex:o,isFullscreen:this.isFullscreen});return}if((n=this.tradeDragHandler)!=null&&n.active){var o,s,c,l,u;e.preventDefault();let t=e.touches[0],n=(o=this._cachedDrawRect)==null?this.drawCanvas.getBoundingClientRect():o,r=t.clientY-n.top,{priceH:i}=this.getChartLayout(),a=(s=this._displayedPriceRange)==null?this.getScaledPriceRange(this.viewport):s,d=this.tradeDragHandler.onMouseMove(r,this.scaleManager,a,i);if(this.tradeDragNewPrice=(c=d==null?void 0:d.newPrice)==null?null:c,this.tradeDragNewSLPrice=(l=d==null?void 0:d.derivedSLPrice)==null?null:l,this.tradeDragNewTPPrice=(u=d==null?void 0:d.derivedTPPrice)==null?null:u,this.renderTradeLayer(),this.tradeDragNewPrice!==null&&d){let e=d.label.indexOf(`:`),t=e===-1?d.label:d.label.slice(0,e),n=e===-1?void 0:d.label.slice(e+1),r=this.levels.find(e=>e.label===t);r&&this.emitter.emit(`tradeLevelDrag`,{label:r.label,newPrice:this.tradeDragNewPrice,data:r.data,bracketType:n,...d.derivedSLPrice===void 0?{}:{derivedSLPrice:d.derivedSLPrice},...d.derivedTPPrice===void 0?{}:{derivedTPPrice:d.derivedTPPrice},isFullscreen:this.isFullscreen})}return}if(this._mobileTapStartXY||this._longPressTimer!==null){var d,f;let t=e.touches[0],n=(d=this._cachedDrawRect)==null?this.drawCanvas.getBoundingClientRect():d,r=(f=this._mobileTapStartXY)==null?this._longPressPoint:f;if(r){let e=t.clientX-n.left-r.x,i=t.clientY-n.top-r.y;Math.sqrt(e*e+i*i)>6&&(this._mobileTapStartXY=null,this._longPressTimer!==null&&(clearTimeout(this._longPressTimer),this._longPressTimer=null,this._longPressPoint=null))}}if(this._mobileCrosshairActive){var p,m;e.preventDefault();let t=e.touches[0],n=(p=this._cachedDrawRect)==null?this.drawCanvas.getBoundingClientRect():p,r=t.clientX-n.left,i=t.clientY-n.top,{chartW:a,priceH:o}=this.getChartLayout(),s=(m=this._displayedPriceRange)==null?this.getScaledPriceRange(this.viewport):m,c=n.height-this.timeAxisHeight;if(r<a&&i<c){var h;let e=this.scaleManager.pixelToBarIndex(r,this.viewport,a),t=this.scaleManager.pixelToPrice(i,s,o),n=Math.max(Math.floor(this.viewport.startIndex),Math.min(Math.ceil(this.viewport.endIndex),Math.round(e))),c=(h=this.dataStore.all[n])==null?null:h;this.crosshair=this.selectedTradeLabel===null?{x:r,y:i,barIndex:n,price:t,bar:c}:null,this.tradeButton&&(this.tradeButton.setY(i),this._isTradingActive||It(i,this.uiConfig.tradeButton.size/2,this.offViewportHitAreas)?this.tradeButton.hide():this.tfcActive&&this.tradeButton.show(),this._tradeButtonClickData={price:t,y:i}),this.scheduleRender()}}},this.onDrawingTouchCancel=e=>{var t,n;this._longPressTimer!==null&&(clearTimeout(this._longPressTimer),this._longPressTimer=null,this._longPressPoint=null);let r=!1;(t=this.orderTimeDragHandler)!=null&&t.active&&(this.orderTimeDragHandler.cancel(),this.tradeDragNewBarIndex=null,r=!0),(n=this.tradeDragHandler)!=null&&n.active&&(this.tradeDragHandler.cancelDrag(),this.tradeDragNewPrice=null,this.tradeDragNewSLPrice=null,this.tradeDragNewTPPrice=null,this._pendingBracketOrderLabel=null,r=!0),this._pendingTradeDrag=null,r&&this.renderTradeLayer()},this.onDrawingTouchEnd=e=>{var t;if(this._lastTouchTime=Date.now(),this._longPressTimer!==null&&(clearTimeout(this._longPressTimer),this._longPressTimer=null,this._longPressPoint=null),this._endOrderTimeDrag())return;if((t=this.tradeDragHandler)!=null&&t.active){let e=this.tradeDragHandler.endDrag();if(e){var n;this._finalizeMainDragWithBrackets(e,(n=this._pendingBracketOrderLabel)==null?void 0:n)}else this.tradeDragNewPrice=null;this._pendingBracketOrderLabel=null,this.renderTradeLayer();return}if(this.axisDrag){let e=this.axisDrag.axis===`price`||this.axisDrag.axis===`time`;this.axisDrag=null,this.scheduleRender(),e&&this.scheduleViewportPersist();return}let r=this._drawTouchAnchorActive;if(this._drawTouchAnchorActive=!1,!r&&this.drawingManager.isPlacing()&&this._lastDrawingTouchPoint){this.drawingManager.onMouseDown(this._lastDrawingTouchPoint),this._lastDrawingTouchPoint=null,this.scheduleRender();return}if(this.drawingManager.isDraggingDrawing()){let t=e.changedTouches[0],n=this._drawTouchStartXY;if(this._drawTouchStartXY=null,this.drawingManager.endDrag(),t&&n&&this.drawingManager.getSelectedDrawing()){let e=t.clientX-n.x,r=t.clientY-n.y;Math.sqrt(e*e+r*r)<8&&this.showMobileDrawingFlyout(t.clientX,t.clientY)}this.scheduleRender()}if(this.drawingManager.isResizingDrawing()&&(this.drawingManager.endResize(),this.scheduleRender()),this._mobileTapStartXY){var i;this._mobileTapStartXY=null,this._mobileCrosshairActive=!1,this.crosshair=null,(i=this.tradeButton)==null||i.hide(),this.scheduleRender()}},this.onCanvasClick=e=>{var t,n;let r=(t=this._cachedDrawRect)==null?this.drawCanvas.getBoundingClientRect():t,i=e.clientX-r.left,a=e.clientY-r.top,{chartW:o,priceH:s}=this.getChartLayout(),c=(n=this._displayedPriceRange)==null?this.getScaledPriceRange(this.viewport):n,l=this.scaleManager.pixelToBarIndex(i,this.viewport,o),u=this.scaleManager.pixelToPrice(a,c,s),d=Math.round(l),f=xe(i,a,this.clusterBadgeAreas);if(f){this.expandedClusters.has(f.clusterId)?this.expandedClusters.delete(f.clusterId):this.expandedClusters.add(f.clusterId),this.renderTradeLayer();return}let p=Ft(i,a,this.offViewportHitAreas);if(p){this.scrollToCenterPrice(p.targetPrice);return}let m=vt(i,a,this.tradeLevelConfirmAreas);if(m){m.action===`confirm`?this.applyPendingChanges(m.label):this.revertPendingChanges(m.label);return}if(this._showQuantityField&&this._draftQtyPillArea){let t=this._draftQtyPillArea;if(i>=t.pillX&&i<=t.pillX+t.pillW&&a>=t.pillY&&a<=t.pillY+t.pillH){e.preventDefault(),e.stopPropagation(),this.openDraftQtyFlyout(t);return}}let h=gt(i,a,this.tradeLevelHitAreas);if(h){this._handleTradeLevelClose(h);return}if(!this.drawingManager.getActiveTool()){let e=_t(i,a,this.tradeLevelEditAreas);if(e){let t=this.levels.find(t=>t.label===e.label);t&&this._openTradeLevelEditForm(t);return}}if(this.tradeDragHandler&&!this.drawingManager.getActiveTool()){let e=xt(i,a,this.tradeAddBracketAreas);if(e){this._startAddBracketFromHit(e,a);return}}if(this.tradeDragHandler&&!this.drawingManager.getActiveTool()){let e=bt(i,a,this.tradeLevelDragAreas);if(e){let t=this.levels.find(t=>t.label===e.label);if(t&&!(this.hideLevelConfirmCancel&&!e.isBracket)){this._pendingTradeDrag={dragHit:e,level:t,hitY:a,startX:i,startY:a};return}}}let g=yt(i,a,this.tradeHoverAreas);if(g){let e=this.pendingLevelDrags.has(g.label);if(this.selectedTradeLabel===g.label&&!e){this._cancelEditAndDeselect(g.label);return}let t=this.levels.find(e=>e.label===g.label);t?this._openTradeLevelEditForm(t):(this.selectedTradeLabel=g.label,this.renderTradeLayer());return}else if(this.selectedTradeLabel!==null&&!this.hideLevelConfirmCancel&&this.deselectActiveOnOutsideClick){let e=this.selectedTradeLabel,t=this.pendingLevelDrags.get(e);!t||t.length===0?this._cancelEditAndDeselect(e):this.revertPendingChanges(e)}this.expandedClusters.size>0&&(this.expandedClusters.clear(),this.renderTradeLayer());let _=r.height-this.timeAxisHeight;if(i>=o){if(a<=s)this.axisDrag={axis:`price`,startPos:a,startSize:this.priceScaleFactor};else{let e=this.activeIndicators.filter(e=>e.indicator.pane===`sub`),t=s+Wl;for(let n of e){let e=this.paneH(n);if(a>=t&&a<t+e){var v;this.axisDrag={axis:`subpane`,startPos:a,startSize:(v=this.subPaneScaleFactors.get(n.instanceId))==null?1:v,instanceId:n.instanceId};break}t+=e+Wl}}this.scheduleRender();return}if(a>=_){this.axisDrag={axis:`time`,startPos:i,startSize:this.viewport.endIndex-this.viewport.startIndex},this.scheduleRender();return}let y=this.getSeparatorPositions().find(e=>Math.abs(a-e.y)<=4);if(y){var b,x;let e=this.activeIndicators.find(e=>e.instanceId===y.instanceId),t=(b=(x=this.paneHeightOverrides.get(y.instanceId))==null?e==null?void 0:e.indicator.paneHeight:x)==null?Ul:b;this.separatorDrag={instanceId:y.instanceId,startY:a,startH:t},this.scheduleRender();return}if(!this.drawingManager.onMouseDown(this.makeDrawingPoint(l,u))){var S;let e=this.drawingManager.getHandleAtPoint(i,a,this.scaleManager,this.viewport,c,o,s);if(e)this.drawingManager.selectDrawing(e.drawing),this._pendingDrawResize={drawing:e.drawing,pointIndex:e.handle.pointIndex,startX:i,startY:a};else{let e=this.drawingManager.hitTest(i,a,this.scaleManager,this.viewport,c,o,s);this.drawingManager.selectDrawing(e),e&&(this._pendingDrawDrag={drawing:e,startX:i,startY:a})}let t=(S=this.dataStore.all[d])==null?null:S;this.emitter.emit(`click`,{x:i,y:a,barIndex:d,price:u,bar:t})}this.scheduleRender()},this.onDoubleClick=e=>{var t;this.drawingManager.finalizePlacing();let n=(t=this._cachedDrawRect)==null?this.drawCanvas.getBoundingClientRect():t,r=e.clientX-n.left,i=e.clientY-n.top,{chartW:a,priceH:o}=this.getChartLayout(),s=n.height-this.timeAxisHeight;if(r>=a){this.resetPriceAxis();return}if(i>=s){this.resetTimeAxis();return}let c=new Set([`text`,`callout`,`anchoredNote`]),l=this.drawingManager.getSelectedDrawing();if(l&&c.has(l.type)){let e=this.getScaledPriceRange(this.viewport);if(l.hitTest(r,i,this.scaleManager,this.viewport,e,a,o)){this.showTextInput(l);return}}this.scheduleRender()},this.onKeyDown=e=>{var t;if(e.key===`Escape`&&(t=this.orderTimeDragHandler)!=null&&t.active){this.orderTimeDragHandler.cancel(),this.tradeDragNewBarIndex=null,this.drawCanvas.style.cursor=`default`,this.renderTradeLayer(),e.preventDefault();return}if(e.key===`Escape`&&this.expandedClusters.size>0){this.expandedClusters.clear(),this.renderTradeLayer(),e.preventDefault();return}if(e.key===`Escape`&&this.pendingLevelDrags.size>0){this.revertPendingChanges(),e.preventDefault();return}let n=(e.ctrlKey||e.metaKey)&&e.key===`z`?`z`:e.key;if(this.drawingManager.onKeyDown(n)){var r;e.preventDefault(),this.hideMobileDrawingFlyout(),(r=this.leftBar)==null||r.setActiveTool(this.drawingManager.getActiveTool()),this.drawCanvas.style.cursor=this.drawingManager.getActiveTool()?`crosshair`:`default`,this.scheduleRender()}},this.onTick=e=>{var t;if(this._isDestroyed)return;let n=this.dataStore.all;if(n.length===0||this._suppressTicks)return;this.liveBidAsk={bid:e.bid,ask:e.ask},e.ltp!=null&&e.ltp>0&&(this.liveLtp=e.ltp),this.setDotTickActive();let r=n[n.length-1],i=this.timeframeToMs(this.timeframe),a=this.tickClosePriceSource===`ltp`?(t=this.liveLtp)==null?e.bid:t:this.tickClosePriceSource===`ask`?e.ask:e.bid;if(e.time<r.time+i){var o;let t={...r,high:Math.max(r.high,a),low:Math.min(r.low,a),close:a,volume:((o=r.volume)==null?0:o)+e.volume};n[n.length-1]=t}else{let t=r,o=Math.floor(e.time/i)*i;n.push({time:o,open:a,high:a,low:a,close:a,volume:e.volume}),this._debug&&console.warn(`[tick] → NEW candle @ ${new Date(o).toISOString()} (closed ${new Date(t.time).toISOString()}) | total bars=${n.length}`);let s=n[n.length-1];this._targetViewport.endIndex>=n.length&&(this._targetViewport={...this._targetViewport,startIndex:this._targetViewport.startIndex+1,endIndex:this._targetViewport.endIndex+1}),this.emitter.emit(`newBar`,{completedBar:t,openingBar:s,intervalMs:i}),this.correctCompletedBar(t.time,i),o>t.time+i&&this.fillTickGap(t.time,o)}this.recomputeIndicators(),this.scheduleRender()},typeof window>`u`||typeof document>`u`)throw Error(`acttrader-charts requires a browser environment`);if(On(),window.visualViewport){let e=window.visualViewport,t=()=>{this._cachedWrapRect=null,this._cachedDrawRect=null};e.addEventListener(`resize`,t),e.addEventListener(`scroll`,t),this.disposeVvListener=()=>{e.removeEventListener(`resize`,t),e.removeEventListener(`scroll`,t)}}let{container:ae,theme:oe=`dark`,series:se=`candlestick`,showVolume:ce=!0,showUI:le=!0,timeframe:ue=`1D`,duration:de=void 0,symbol:F=``,isins:I,onIsinSelect:fe,onSymbolClick:pe,onOrderSubmit:me,dataLoader:he,durationTimeframeMap:ge,uiConfig:_e,labels:ve,tickActivityMs:ye=3e4,hideSymbolAndTick:be=!1,hideOHLCV:Se=!1,showBottomBar:Ce=!1}=i;if(this.dataLoader=he==null?null:he,this.compareDataLoader=(a=i.compareDataLoader)==null?null:a,this.compareManager=new jc({emitter:this.emitter,loader:this.compareDataLoader,maxCompares:i.maxCompares}),this.drawingToolsEnabled=i.showDrawingTools!==!1,this.settingsEnabled=i.showSettings!==!1,this.fullscreenEnabled=i.showFullscreenButton!==!1,this.uiConfig=T(_e),this.labels=D(ve),this.tickActivityMs=ye,this.maxCandles=(o=i.maxCandles)==null?200:o,this.minInitialBars=Math.max(0,(l=i.minInitialBars)==null?10:l),this.maxLookbackMs=Math.max(0,(u=i.maxLookbackMs)==null?365*24*60*60*1e3:u),this.prefetchThreshold=(d=i.prefetchThreshold)==null?80:d,this.defaultVisibleBars=(f=i.defaultVisibleBars)==null?Gl:f,this.defaultMobileVisibleBars=i.defaultMobileVisibleBars,this.explicitMobileDivisor=i.mobileBarDivisor!==void 0,this.mobileBarDivisor=(h=i.mobileBarDivisor)==null?2:h,this._autoVisibleBars=i.defaultVisibleBars==null&&i.defaultMobileVisibleBars==null,this.targetCandleWidth=(g=i.targetCandleWidth)==null?Kl:g,this.viewport={...this.viewport,endIndex:Ql(this.mobileBarDivisor,this.explicitMobileDivisor,this.defaultVisibleBars,this.defaultMobileVisibleBars)},this._targetViewport={...this.viewport},this.maxSubPanes=(_=i.maxSubPanes)==null?3:_,this.tickClosePriceSource=(v=i.tickClosePriceSource)==null?`bid`:v,this.showLtpPrice=i.showLtpPrice,this.tradesThresholdForHorizontalLine=(y=i.tradesThresholdForHorizontalLine)==null?2:y,i.positionRenderStyle===`line`||i.positionRenderStyle===`dot`)this.positionRenderStyleOverride=i.positionRenderStyle;else{let e=localStorage.getItem(this.RENDER_STYLE_LS_KEY);(e===`line`||e===`dot`)&&(this.positionRenderStyleOverride=e)}i.tradeDisplayFilter&&(this.tradeDisplayFilter=i.tradeDisplayFilter),i.canvasColors&&(this.settingsCanvasColors=i.canvasColors),this.recomputeRenderStyle(),this.showBidAskLines=(b=i.showBidAskLines)==null?!1:b,this.showAskLine=i.showAskLine,this.showBidLine=i.showBidLine,this.showActLogo=(x=i.showActLogo)==null?!1:x,this.hideLevelConfirmCancel=(S=i.hideLevelConfirmCancel)==null?!1:S,this.deselectActiveOnOutsideClick=(C=i.deselectActiveOnOutsideClick)==null?!1:C,this._orderTimeDragEnabled=((w=i.features)==null?void 0:w.orderLineTimeDrag)===!0,this._orderLineDragSnap=i.orderLineDragSnap!==!1,this.tradeLevelButtonScale=Math.min(Math.max((E=i.tradeLevelButtonScale)==null?1:E,1),3),this.levelClusteringEnabled=(O=i.levelClusteringEnabled)==null?!0:O,this.clusterThresholdDistance=(A=i.clusterThresholdDistance)==null?20:A,this.enableThemeToggle=(ee=i.enableThemeToggle)==null?!1:ee,this.tfcEnabled=i.tfcEnabled!==!1,this.tfcActive=this.tfcEnabled,this.showCandleCountdown=(te=i.showCandleCountdown)==null?!0:te,this.candleCountdownTimeframes=i.candleCountdownTimeframes,this.showTradeLevelsAlways=(ne=i.showTradeLevelsAlways)==null?!0:ne,this.showPriceAxisCountdown=(M=i.showPriceAxisCountdown)==null?!1:M;try{let e=localStorage.getItem(this.SHOW_SLTP_ALWAYS_LS_KEY);e!==null&&(this.showTradeLevelsAlways=e===`true`);let t=localStorage.getItem(this.PRICE_AXIS_COUNTDOWN_LS_KEY);t!==null&&(this.showPriceAxisCountdown=t===`true`)}catch(e){}this._onOrderSubmit=me,i.minLots!==void 0&&(console.warn(`[acttrader-charts] ChartConfig.minLots is deprecated. DraftOrderQtyInput has been removed. The value is stored and used as the submitted lot size.`),this._minLots=i.minLots),i.showQuantityField!==void 0&&(this._showQuantityField=i.showQuantityField),i.quantityFieldConfig&&(i.quantityFieldConfig.minLots!==void 0&&(this._qtyFieldMin=i.quantityFieldConfig.minLots),i.quantityFieldConfig.maxLots!==void 0&&(this._qtyFieldMax=i.quantityFieldConfig.maxLots)),i.onLotsChange!==void 0&&console.warn(`[acttrader-charts] ChartConfig.onLotsChange is deprecated. DraftOrderQtyInput has been removed; this callback will never fire.`),i.hideQtyButton!==void 0&&console.warn(`[acttrader-charts] ChartConfig.hideQtyButton is deprecated and is a no-op. DraftOrderQtyInput has been removed.`),this.themeName=oe===`dark`?`dark`:`light`,this.themeOverrides=i.themeOverrides,this.timezone=i.timezone===`local`?Intl.DateTimeFormat().resolvedOptions().timeZone:(N=i.timezone)==null?`UTC`:N,this.aggregateFrom=i.aggregateFrom;let we=this.themeName===`dark`?p:m;this.theme=c(we,(P=this.themeOverrides)==null?void 0:P[this.themeName]),this.series=se,this.showVolume=ce,this.timeframe=ue,this.duration=de,this.symbol=F,this.wrapper=document.createElement(`div`),Object.assign(this.wrapper.style,{display:`flex`,flexDirection:`column`,width:`100%`,height:`100%`,overflow:`hidden`,boxSizing:`border-box`});let Te=i.headerLayout===`advanced`||i.headerLayout===void 0&&((re=i.features)==null?void 0:re.advancedToolbar)===!0,Ee=i.headerLayout===`compact`,De=i.headerLayout===`mobile`,Oe=i.hideHeader===!0,ke=i.enableMultipleLayouts===!0,Ae=i.enableSnapshot===!0;i.layoutSync&&(this.currentSync={...Ur,...i.layoutSync}),ke&&typeof i.onLayoutClick==`function`&&console.warn("[ActCharts] `enableMultipleLayouts: true` owns the Layout button — the deprecated `onLayoutClick` callback is ignored. Listen to the `layoutChange` event instead."),Ae&&typeof i.onScreenshotClick==`function`&&console.warn("[ActCharts] `enableSnapshot: true` owns the Snapshot button — the deprecated `onScreenshotClick` callback is ignored. Listen to the `snapshot` event instead."),typeof i.onOneClickTradeToggle==`function`&&typeof i.onOneClickToggle==`function`&&console.warn("[ActCharts] Both `onOneClickTradeToggle` and the deprecated `onOneClickToggle` were provided — using `onOneClickTradeToggle`. Remove the legacy field.");let je=(ie=i.onOneClickTradeToggle)==null?i.onOneClickToggle:ie;if(le){let e=e=>{this.timeframe=e,this.emitter.emit(`timeframeChange`,{timeframe:e}),this.emitStateChange(),this.updateCountdownState(),this.triggerLoad(`timeframe`)},t=jl.filter(e=>e.enabled).map(e=>({value:e.short_name,label:`${e.name} (${e.short_name})`,category:e.type})),n=()=>{if(ke)this.openLayoutPopover();else{var e;(e=i.onLayoutClick)==null||e.call(i)}},r=()=>{if(Ae)this.openSnapshotPopover();else{var e;(e=i.onScreenshotClick)==null||e.call(i)}},a=ke||typeof i.onLayoutClick==`function`,o=Ae||typeof i.onScreenshotClick==`function`;if(!Oe)if(De){var Me,Ne;let t=this.drawingToolsEnabled?{setDrawingTool:e=>{this.setDrawingTool(e)},clearAllDrawings:()=>{this.clearAllDrawings()},addIndicator:(e,t)=>{this.addIndicatorByName(e,t)},removeIndicator:e=>{this.removeIndicator(e)}}:null;this.mobileHeader=new Or(e,t,(Me=i.onAskAiClick)==null?null:Me,this.settingsEnabled?()=>this.openChartSettings():null,e=>this.setSeries(e),this.timeframe,this.series,this.theme,(Ne=this.uiConfig.topBar)==null?void 0:Ne.dropBtnFontFamily),this.wrapper.appendChild(this.mobileHeader.el)}else if(Ee)this.compactToolbar=new sr(e=>this.setSeries(e),e,e=>this.addIndicatorByName(e),this.series,this.timeframe,this.theme),this.compactToolbar.setIndicatorOptions(t),this.wrapper.appendChild(this.compactToolbar.el);else if(Te)this.advancedToolbar=new $n(e=>this.setSeries(e),e,e=>this.addIndicatorByName(e),()=>this.openChartSettings(),()=>this.toggleFullscreen(),this.drawingToolsEnabled?()=>this.toggleDrawingTools():null,this.drawingToolsEnabled,this.settingsEnabled,this.fullscreenEnabled,this.series,this.timeframe,this.theme,this.compareDataLoader?()=>this.openComparePicker():void 0,n,je,r,a,o),this.advancedToolbar.setIndicatorOptions(t),this.wrapper.appendChild(this.advancedToolbar.el),this.advancedToolbar.setFullscreen(this.isFullscreen);else{let i={...qr,...ge};this.topBar=new Pn(e=>this.setSeries(e),e,e=>this.addIndicatorByName(e),(e,t)=>{var n,r;this.duration=e,this.timeframe=t,(n=this._tb)==null||n.setTimeframe(t),(r=this.bottomBar)==null||r.setActive(e),this.emitter.emit(`durationChange`,{duration:e,timeframe:t}),this.emitStateChange(),this.updateCountdownState(),this.triggerLoad(`duration`)},()=>this.openChartSettings(),()=>this.toggleFullscreen(),this.drawingToolsEnabled?()=>this.toggleDrawingTools():null,this.drawingToolsEnabled,this.settingsEnabled,this.fullscreenEnabled,this.tfcEnabled,this.tfcActive,this.tfcEnabled?e=>{this.setTfcActive(e)}:null,this.series,this.timeframe,null,i,this.theme,this.uiConfig.topBar,this.labels.topBar,()=>this.emitUiState(),a,o,n,r,je==null?null:je),this.topBar.setIndicatorOptions(t),this.wrapper.appendChild(this.topBar.el),this.topBar.setFullscreen(this.isFullscreen)}ke&&(this.layoutPopover=new Gr(this.theme,this.currentPresetId,this.currentSync,e=>this.handleLayoutPresetSelect(e),e=>this.handleSyncToggle(e),()=>this.emitUiState())),Ae&&(this.snapshotPopover=new Kr(this.theme,e=>this.handleSnapshot(e),()=>this.emitUiState()))}let Pe=document.createElement(`div`);if(Object.assign(Pe.style,{display:`flex`,flex:`1`,minHeight:`0`,overflow:`hidden`,position:`relative`}),le&&this.drawingToolsEnabled&&(this.leftBar=new $r(e=>this.setDrawingTool(e),e=>{switch(e){case`undo`:this.undoDrawing();break;case`redo`:this.redoDrawing();break;case`delete_selected`:this.deleteSelectedDrawing();break;case`clear_all`:this.clearAllDrawings();break;case`hide_all`:this.hideAllDrawings();break;case`show_all`:this.showAllDrawings();break;case`lock_all`:this.lockAllDrawings();break;case`unlock_all`:this.unlockAllDrawings();break}},()=>{var e;this.leftBarVisible=!1,(e=this._tb)==null||e.setDrawingsBtnActive(!1)},this.theme,this.uiConfig.drawingToolbar,this.labels.drawingToolbar),Pe.appendChild(this.leftBar.el)),this.canvasWrap=document.createElement(`div`),Object.assign(this.canvasWrap.style,{flex:`1`,position:`relative`,overflow:`hidden`,touchAction:`none`}),this.canvas=document.createElement(`canvas`),Object.assign(this.canvas.style,{position:`absolute`,top:`0`,left:`0`,width:`100%`,height:`100%`,pointerEvents:`none`}),this.canvasWrap.appendChild(this.canvas),this.tradeCanvas=document.createElement(`canvas`),Object.assign(this.tradeCanvas.style,{position:`absolute`,top:`0`,left:`0`,width:`100%`,height:`100%`,pointerEvents:`none`}),this.canvasWrap.appendChild(this.tradeCanvas),this.drawCanvas=document.createElement(`canvas`),Object.assign(this.drawCanvas.style,{position:`absolute`,top:`0`,left:`0`,width:`100%`,height:`100%`,cursor:`crosshair`,touchAction:`none`,userSelect:`none`}),this.drawCanvas.style.webkitUserSelect=`none`,this.drawCanvas.style.webkitTouchCallout=`none`,this.canvasWrap.appendChild(this.drawCanvas),this.textInputEl=document.createElement(`input`),this.textInputEl.type=`text`,Object.assign(this.textInputEl.style,{position:`absolute`,display:`none`,zIndex:`15`,background:`transparent`,border:`none`,borderBottom:`1px solid #2196f3`,color:`#f5f5f5`,font:`16px system-ui, sans-serif`,outline:`none`,minWidth:`60px`,padding:`0 2px`}),this.canvasWrap.appendChild(this.textInputEl),le){this.loadingOverlayEl=document.createElement(`div`),Object.assign(this.loadingOverlayEl.style,{display:`none`,position:`absolute`,top:`0`,left:`0`,width:`100%`,height:`100%`,alignItems:`center`,justifyContent:`center`,pointerEvents:`none`,zIndex:`20`});let e=document.createElement(`span`);e.textContent=this.labels.chart.loading,Object.assign(e.style,{color:`rgba(200,200,200,0.9)`,fontSize:`13px`,background:`rgba(0,0,0,0.45)`,padding:`4px 12px`,borderRadius:`4px`}),this.loadingOverlayEl.appendChild(e),this.canvasWrap.appendChild(this.loadingOverlayEl),this.noDataOverlayEl=document.createElement(`div`),Object.assign(this.noDataOverlayEl.style,{display:`none`,position:`absolute`,top:`0`,left:`0`,width:`100%`,height:`100%`,alignItems:`center`,justifyContent:`center`,pointerEvents:`none`,zIndex:`19`});let t=document.createElement(`span`);t.textContent=this.labels.chart.noData,Object.assign(t.style,{color:`rgba(200,200,200,0.9)`,fontSize:`13px`,background:`rgba(0,0,0,0.45)`,padding:`4px 12px`,borderRadius:`4px`}),this.noDataOverlayEl.appendChild(t),this.canvasWrap.appendChild(this.noDataOverlayEl)}if(le&&!(be&&Se)){if(this.siEl=document.createElement(`div`),Object.assign(this.siEl.style,{position:`absolute`,top:`6px`,left:`6px`,zIndex:`10`,display:`flex`,alignItems:`center`,gap:`8px`,pointerEvents:`none`}),!be){this.siSymbolSpan=document.createElement(`span`),Object.assign(this.siSymbolSpan.style,{color:this.theme.tooltip.text,fontSize:`13px`,fontFamily:`inherit`,fontWeight:`700`,letterSpacing:`-0.025em`,display:F?`inline`:`none`}),this.siSymbolSpan.textContent=F==null?``:F;let e=()=>{var e;let t=(e=i.symbolNameDecoration)==null?`underline`:e;t===`hover`?(Xl(),this.siSymbolSpan.classList.add(Yl),this.siSymbolSpan.tabIndex=0,this.siSymbolSpan.style.textDecoration=`none`):this.siSymbolSpan.style.textDecoration=t===`none`?`none`:`underline`};pe?(Object.assign(this.siSymbolSpan.style,{cursor:`pointer`,pointerEvents:`auto`}),e(),this.siSymbolSpan.addEventListener(`click`,()=>{var e,t;pe((e=(t=this.siSymbolSpan)==null?void 0:t.textContent)==null?``:e)})):fe&&(I&&(this.isins=I),this.isinPickerModal=new Oc(this.theme,fe,()=>this.emitUiState()),this.getFloatingRoot().appendChild(this.isinPickerModal.el),Object.assign(this.siSymbolSpan.style,{cursor:`pointer`,pointerEvents:`auto`}),e(),this.siSymbolSpan.addEventListener(`click`,()=>{var e;this.isinPickerModal.show(this.isins,(e=this.siSymbolSpan.textContent)==null?``:e)})),this.siStreamDot=document.createElement(`span`),this.siStreamDot.className=`live-dot`,Object.assign(this.siStreamDot.style,{width:`8px`,height:`8px`,borderRadius:`9999px`,background:this.theme.ui.stream.disconnected,display:`inline-block`,flexShrink:`0`})}Se||(this.siOHLCSpan=document.createElement(`span`),Object.assign(this.siOHLCSpan.style,{fontSize:`11px`,fontFamily:`inherit`,whiteSpace:`nowrap`}),this.siOHLC2Span=document.createElement(`span`),Object.assign(this.siOHLC2Span.style,{fontSize:`11px`,fontFamily:`inherit`,whiteSpace:`nowrap`}));let e=document.createElement(`div`);Object.assign(e.style,{display:`flex`,alignItems:`center`,gap:`8px`}),this.siStreamDot&&e.append(this.siStreamDot),this.siSymbolSpan&&e.append(this.siSymbolSpan),this.siOHLCSpan&&e.append(this.siOHLCSpan),this.siEl.append(e),this.siOHLC2Span&&this.siEl.append(this.siOHLC2Span),this.canvasWrap.appendChild(this.siEl)}if(le&&(this.indicatorOverlay=new dc(this.theme,this.uiConfig.indicatorOverlay,this.labels.chart),this.canvasWrap.appendChild(this.indicatorOverlay.el),this.indicatorSettingsDialog=new fc(this.theme,this.labels.dialogs,()=>this.emitUiState()),this.getFloatingRoot().appendChild(this.indicatorSettingsDialog.el),this.scrollToEndBtn=document.createElement(`button`),this.scrollToEndBtn.title=this.labels.chart.scrollToLatest,this.applyScrollToEndBtnStyles(),this.scrollToEndBtn.addEventListener(`click`,()=>this.scrollToEnd()),this.canvasWrap.appendChild(this.scrollToEndBtn),this.resetViewBtn=document.createElement(`button`),this.resetViewBtn.title=`Reset view`,this.applyResetViewBtnStyles(),this.resetViewBtn.addEventListener(`click`,()=>this.resetView()),this.canvasWrap.appendChild(this.resetViewBtn)),this.tradeDragHandler=new Vc,this.orderTimeDragHandler=new Hc,i.onLevelDragEnd&&this.emitter.on(`tradeLevelDragEnd`,i.onLevelDragEnd),i.onLevelEdit&&this.emitter.on(`tradeLevelEdit`,i.onLevelEdit),me&&(this.tradePopover=new gc(this.theme,.01,this.symbol,(e,t,n)=>{this.createDraftOrder(e,t,n)},this.labels.trade,()=>this.emitUiState(),i.headerLayout===`mobile`),this.canvasWrap.appendChild(this.tradePopover.el),this.tradeButton=new hc(this.theme,this.priceAxisWidth,()=>{if(this._tradeButtonClickData&&this.tradePopover){var e;(e=this.tradeButton)==null||e.hide();let t=this.priceAxisWidth+10+22+4,{price:n,y:r}=this._tradeButtonClickData;this.tradePopover.show(n,r,t,this.dataStore.getPricePrecision(),this._orderTypeForPrice(`buy`,n),this._orderTypeForPrice(`sell`,n))}},this.labels.trade,this.uiConfig.tradeButton),this.canvasWrap.appendChild(this.tradeButton.el),this.tradeButton.el.addEventListener(`mouseenter`,()=>{this.crosshair=null,this.emitter.emit(`crosshair`,null),this.scheduleRender()}),this.tradeButton.el.addEventListener(`mousemove`,e=>{var t;if(e.buttons!==0)return;let n=(t=this._cachedDrawRect)==null?this.drawCanvas.getBoundingClientRect():t,r=e.clientY-n.top,{priceH:i}=this.getChartLayout();if(It(r,this.uiConfig.tradeButton.size/2,this.offViewportHitAreas)){var a;(a=this.tradeButton)==null||a.hide();return}if(r>=0&&r<=i){var o,s;(o=this.tradeButton)==null||o.setY(r);let e=(s=this._displayedPriceRange)==null?this.getScaledPriceRange(this.viewport):s,t=this.scaleManager.pixelToPrice(r,e,i);this._tradeButtonClickData={price:t,y:r}}})),Pe.appendChild(this.canvasWrap),this.wrapper.appendChild(Pe),le&&Ce){var Fe;let e={...qr,...ge};this.bottomBar=new Yr((e,t)=>{var n;this.duration=e,this.timeframe=t,(n=this._tb)==null||n.setTimeframe(t),this.emitter.emit(`durationChange`,{duration:e,timeframe:t}),this.emitStateChange(),this.updateCountdownState(),this.triggerLoad(`duration`)},(Fe=this.duration)==null?null:Fe,this.theme,e,this.uiConfig.bottomBar,this.labels.bottomBar),this.wrapper.appendChild(this.bottomBar.el)}if(ae.appendChild(this.wrapper),this.themeOverrides){var Ie,Le,L,Re;this.theme=this.buildTheme(this.themeName),(Ie=this._tb)==null||Ie.setTheme(this.theme),(Le=this.bottomBar)==null||Le.setTheme(this.theme),(L=this.leftBar)==null||L.setTheme(this.theme),(Re=this.tradeButton)==null||Re.setTheme(this.theme,this.priceAxisWidth)}let R=this.canvas.getContext(`2d`);if(!R)throw Error(`Canvas 2D context unavailable`);this.ctx=R;let ze=this.drawCanvas.getContext(`2d`);if(!ze)throw Error(`Drawing canvas 2D context unavailable`);this.drawCtx=ze;let Be=this.tradeCanvas.getContext(`2d`);if(!Be)throw Error(`Trade canvas 2D context unavailable`);if(this.tradeCtx=Be,this.showActLogo){let t=new Image;t.onload=()=>{this.logoImage=t,this.scheduleRender()},t.src=e}this.drawingManager.setOnComplete(()=>{var e;(e=this.leftBar)==null||e.setActiveTool(null),this.drawCanvas.style.cursor=`default`}),this.drawingManager.onDrawingsChange=()=>this.emitStateChange(),this.drawingManager.onPointsMutated=e=>{for(let t of e.points){let e=this.barIndexToTimestamp(t.barIndex);e!=null&&(t.timestamp=e)}},this.drawingManager.onStartTextEdit=e=>this.showTextInput(e),this.drawingStylePopover=new wc(this.canvasWrap,this.theme,(e,t)=>this.updateDrawingStyle(e,t)),this.drawingManager.onSelectionChange=e=>{if(e&&e.complete&&e.locked!==!0){var t,n;let r=this.computeDrawingAnchorPx(e);r?(t=this.drawingStylePopover)==null||t.show(e,r.x,r.y):(n=this.drawingStylePopover)==null||n.hide()}else{var r;(r=this.drawingStylePopover)==null||r.hide()}},this.panHandler=new k(this.drawCanvas,()=>this._targetViewport,e=>{this._targetViewport=e,this.clearDuration(),this.checkNeedMoreData(),this.scheduleRender(),this.scheduleViewportPersist(),this.emitter.emit(`pan`,{viewport:e})},()=>this.dataStore.length,()=>this.scheduleRender(),()=>{var e,t,n,r;return this.drawingManager.getActiveTool()!==null||this.drawingManager.isDraggingDrawing()||this.drawingManager.isResizingDrawing()||this.separatorDrag!==null||this.axisDrag!==null||((e=(t=this.tradeDragHandler)==null?void 0:t.active)==null?!1:e)||((n=(r=this.orderTimeDragHandler)==null?void 0:r.active)==null?!1:n)||this._mobileCrosshairActive},e=>{var t;if(this.priceScaleFactor===1)return;let{priceH:n}=this.getChartLayout(),r=(t=this._displayedPriceRange)==null?this.getScaledPriceRange(this._targetViewport):t,i=(r.max-r.min)/n;this.pricePanOffset+=e*i,this.scheduleRender(),this.scheduleViewportPersist()},()=>{this._isPanning=!0},()=>{this._isPanning=!1},{enabled:i.momentumScrollEnabled,decay:i.momentumDecay,threshold:i.momentumThreshold,maxVelocity:i.momentumMaxVelocity}),this.zoomHandler=new j(this.drawCanvas,()=>this._targetViewport,e=>{this._targetViewport=e,this.clearDuration(),this.checkNeedMoreData(),this.scheduleRender(),this.scheduleViewportPersist(),this.emitter.emit(`zoom`,{viewport:e})},()=>this.dataStore.length,()=>this.scheduleRender(),()=>{var e;return(e=this._cachedDrawRect)==null?this.drawCanvas.getBoundingClientRect():e},()=>this.getChartLayout().chartW,e=>{let t=this._targetViewport,n=t.endIndex-t.startIndex,r=e*(n/this.drawCanvas.width),i=Math.max(0,this.dataStore.length-Math.floor(n/2)),a=Math.max(0,Math.min(i,t.startIndex+r));this._targetViewport={...t,startIndex:a,endIndex:a+n},this.clearDuration(),this.checkNeedMoreData(),this.scheduleRender(),this.emitter.emit(`pan`,{viewport:this._targetViewport}),this.scheduleViewportPersist()}),this.drawCanvas.addEventListener(`mousemove`,this.onMouseMove),this.drawCanvas.addEventListener(`mouseleave`,this.onMouseLeave),this.drawCanvas.addEventListener(`mousedown`,this.onCanvasClick),this.drawCanvas.addEventListener(`dblclick`,this.onDoubleClick),window.addEventListener(`mouseup`,this.onMouseUp),this.drawCanvas.addEventListener(`touchstart`,this.onDrawingTouchStart,{passive:!1}),this.drawCanvas.addEventListener(`touchmove`,this.onDrawingTouchMove,{passive:!1}),this.drawCanvas.addEventListener(`touchend`,this.onDrawingTouchEnd,{passive:!1}),this.drawCanvas.addEventListener(`touchcancel`,this.onDrawingTouchCancel,{passive:!1}),this.drawCanvas.addEventListener(`contextmenu`,e=>e.preventDefault()),document.addEventListener(`keydown`,this.onKeyDown);let Ve=()=>{var e;let t=!!document.fullscreenElement;t||(this._isCssFullscreen=!1),(e=this._tb)==null||e.setFullscreen(t),this.reparentFloatingElements()};if(this.wrapper.addEventListener(`fullscreenchange`,Ve),document.addEventListener(`fullscreenchange`,Ve),this.resizeObserver=new ResizeObserver(()=>this.onResize()),this.resizeObserver.observe(this.canvasWrap),this.onResize(),this.dataLoader&&this.triggerLoad(`initial`),this.initCompareUi(),i.initialCompares&&i.initialCompares.length>0){let e=i.initialCompares.slice(),t=this.emitter.on(`dataLoaded`,()=>{t();for(let t of e)this.addCompare(t)})}}resetData(){return++this._loadGeneration,this.setLoading(!1),this.setNoData(!1),this.drawingManager.clearAll(),this.levels=[],this._draftQtyPillArea=void 0,this._pendingBracketOrderLabel=null,this.loadData([])}loadData(e,t=!1){var n,r,i;this.isFetching=!1,this.noMoreData=!1,this._suppressTicks=!1,e.length>0&&this.setNoData(!1),this.liveBidAsk=null,this.liveLtp=null,this.pricePanOffset=0,this.priceScaleFactor=1,this._displayedPriceRange=null,this._lockedAutoFitBase=null,this.dataStore.set(e),this.updateCompareRange();let a=((n=(r=this._cachedWrapRect)==null?void 0:r.width)==null?this.canvasWrap.getBoundingClientRect().width:n)-this.priceAxisWidth,o=this._autoVisibleBars&&a>0?a:void 0,s=Ql(this.mobileBarDivisor,this.explicitMobileDivisor,this.defaultVisibleBars,this.defaultMobileVisibleBars,o,this.targetCandleWidth);this._defaultVisibleBars=s,this.viewport={...this.viewport,startIndex:t?0:Math.max(0,e.length-s+$l),endIndex:e.length+$l},this._targetViewport={...this.viewport};let c=this.dataStore.hasVolumeData;if(c||(this.showVolume=!1),(i=this._tb)==null||i.setVolumeControl(this.showVolume,c),this.showVolume&&c){var l;(l=this.indicatorOverlay)==null||l.addPill(`VOL`,this.theme.volume.up,`VOL`,`Chart`,!0,()=>{var e,t;this.setVolume(!1),(e=this.indicatorOverlay)==null||e.removePill(`VOL`),(t=this._tb)==null||t.setVolumeControl(!1,this.dataStore.hasVolumeData)},null,()=>{var e;this.setVolume(!this.showVolume),(e=this.indicatorOverlay)==null||e.updatePillVisibility(`VOL`,this.showVolume),this.scheduleRender()})}if(this.recomputeIndicators(),this.reanchorDrawingsByTimestamp(),this._pendingViewportRestore){let e=this._pendingViewportRestore;this._pendingViewportRestore=null,e.priceScale&&(this.priceScaleFactor=e.priceScale.factor,this.pricePanOffset=e.priceScale.panOffset,this._displayedPriceRange=null,this._lockedAutoFitBase=null),e.viewport&&this.applyViewportFromTimestamps(e.viewport.startTime,e.viewport.endTime)}return this.updateCountdownState(),this.scheduleRender(),this}prependData(e){if(e.length===0)return this.noMoreData=!0,this.isFetching=!1,this;let t=this.dataStore.prepend(e);return t>0&&(this.viewport={...this.viewport,startIndex:this.viewport.startIndex+t,endIndex:this.viewport.endIndex+t},this._targetViewport={...this.viewport},this.drawingManager.shiftBarIndices(t),this.reanchorDrawingsByTimestamp(),this.recomputeIndicators(),this.updateCompareRange(),this.scheduleRender()),this.isFetching=!1,this}setLoading(e){return this.loadingOverlayEl&&(this.loadingOverlayEl.style.display=e?`flex`:`none`),e&&this.setNoData(!1),this}setNoData(e){return this.noDataOverlayEl&&(this.noDataOverlayEl.style.display=e?`flex`:`none`),this}timeframeToMs(e){var t;let n=6e4;return(t={"1m":1*n,"5m":5*n,"15m":15*n,"30m":30*n,"1h":60*n,"2h":120*n,"4h":240*n,"8h":480*n,"1D":1440*n,"1W":10080*n,"1M":43200*n}[e])==null?1440*n:t}getBaseInterval(){var e,t;return(e=(t=this.aggregateFrom)==null?void 0:t[this.timeframe])==null?this.timeframe:e}shouldAggregate(){let e=this.getBaseInterval();return e!==this.timeframe&&this.timeframeToMs(e)<this.timeframeToMs(this.timeframe)}maybeAggregate(e){return this.shouldAggregate()?Ml(e,this.timeframeToMs(this.timeframe)):e}timeframeToInterval(e){var t;return(t={"1m":`1min`,"5m":`5min`,"15m":`15min`,"30m":`30min`,"1h":`1h`,"2h":`2h`,"4h":`4h`,"8h":`8h`,"1D":`1day`,"1W":`1week`,"1M":`1month`}[e])==null?`1day`:t}durationToMs(e){var t;let n=1440*60*1e3;return(t={"1D":1*n,"5D":5*n,"1M":30*n,"3M":90*n,"6M":180*n,"1Y":365*n,"5Y":5*365*n,All:20*365*n}[e])==null?365*n:t}triggerLoad(e){if(!this.dataLoader)return;let t=++this._loadGeneration;this._suppressTicks=!0,this.isFetching=!0,this.noMoreData=!1;let n=new Date,r=this.maxCandles*this.timeframeToMs(this.timeframe),i=this.duration?this.durationToMs(this.duration):r,a=Math.min(i,r),o=this.timeframeToInterval(this.getBaseInterval());this.setLoading(!0);let s=this.dataLoader,c=[1,5,25,125],l=this.minInitialBars,u=this.maxLookbackMs,d=(r,i)=>{s({start:i,end:n,interval:o}).then(s=>{if(t!==this._loadGeneration)return;let f=this.maybeAggregate(s),p=n.getTime()-i.getTime()>=u;if(f.length>=l||r+1>=c.length||p){this.loadData(f,e===`duration`),this.setLoading(!1),f.length===0&&this.setNoData(!0),this.emitter.emit(`dataLoaded`,{timeframe:this.timeframe,interval:o,start:i,end:n});return}let m=Math.min(a*c[r+1],u),h=new Date(n.getTime()-m);d(r+1,h)}).catch(()=>{t===this._loadGeneration&&(this.isFetching=!1,this.setLoading(!1))})},f=Math.min(a*c[0],u);d(0,new Date(n.getTime()-f))}checkNeedMoreData(){if(!this.dataLoader||this.isFetching||this.noMoreData)return;let e=Math.max(20,this.prefetchThreshold);if(this._targetViewport.startIndex>e||this.dataStore.length===0)return;let t=this._loadGeneration;this.isFetching=!0;let n=this.dataStore.all[0].time,r=new Date(n-1),i=this.maxCandles*this.timeframeToMs(this.timeframe),a=this.duration?this.durationToMs(this.duration):i,o=Math.min(a,i),s=this.timeframeToInterval(this.getBaseInterval());this.setLoading(!0);let c=this.dataLoader,l=[1,5,25,125],u=this.minInitialBars,d=this.maxLookbackMs,f=(e,n)=>{c({start:n,end:r,interval:s}).then(i=>{if(t!==this._loadGeneration)return;let a=this.maybeAggregate(i),s=r.getTime()-n.getTime()>=d;if(a.length>=u||e+1>=l.length||s){this.prependData(a),this.setLoading(!1);return}let c=Math.min(o*l[e+1],d),p=new Date(r.getTime()-c);f(e+1,p)}).catch(()=>{t===this._loadGeneration&&(this.isFetching=!1,this.setLoading(!1))})},p=Math.min(o*l[0],d);f(0,new Date(r.getTime()-p))}addIndicator(e,t){var n,r;if(e.pane===`sub`&&this.activeIndicators.filter(e=>e.indicator.pane===`sub`).length>=this.maxSubPanes)return this;let i=zl.find(t=>t.shortName===e.name),a=i?Object.fromEntries(i.fields.map(e=>[e.key,e.default])):{};a.timeframe=`Chart`,t&&Object.assign(a,t);let o=Mc(e.name,++this.indicatorInstanceSeq),s={instanceId:o,indicator:e,shortName:e.name,currentParams:a,visible:!0};this.activeIndicators.push(s),this.dataStore.length>0&&this.indicatorResults.set(o,e.compute(this.dataStore.all));let c=i!==void 0&&i.fields.length>0,l=Rl(e.name,a,i),u=(n=a.timeframe)==null?`Chart`:n;if(e.pane===`sub`){let t=new dc(this.theme,this.uiConfig.indicatorOverlay,this.labels.chart);Object.assign(t.el.style,{position:`absolute`,top:`6px`,left:`6px`,zIndex:`10`}),this.canvasWrap.appendChild(t.el),this.subPaneOverlays.set(o,t),t.addPill(o,e.color,l,u,s.visible,()=>this.removeIndicator(o),c?()=>this.openIndicatorSettings(o):null,()=>{s.visible=!s.visible,t.updatePillVisibility(o,s.visible),this.scheduleRender(),this.emitStateChange()})}else{var d;(d=this.indicatorOverlay)==null||d.addPill(o,e.color,l,u,s.visible,()=>this.removeIndicator(o),c?()=>this.openIndicatorSettings(o):null,()=>{var e;s.visible=!s.visible,(e=this.indicatorOverlay)==null||e.updatePillVisibility(o,s.visible),this.scheduleRender(),this.emitStateChange()})}return(r=this._tb)==null||r.setIndicatorOptionActive(e.name,!0,this.activeIndicators.filter(t=>t.shortName===e.name).length),this.scheduleRender(),this.emitStateChange(),this.isRestoringState||this.emitter.emit(`indicatorAdded`,{instanceId:o,shortName:s.shortName,params:{...s.currentParams}}),this}removeIndicator(e){let t=Pc(this.activeIndicators,e);if(t.length===0)return this;let n=new Set(t.map(e=>e.instanceId));this.activeIndicators=this.activeIndicators.filter(e=>!n.has(e.instanceId));for(let e of t){this.indicatorResults.delete(e.instanceId),this.subPaneScaleFactors.delete(e.instanceId),this.paneHeightOverrides.delete(e.instanceId);let t=this.subPaneOverlays.get(e.instanceId);if(t)t.destroy(),t.el.remove(),this.subPaneOverlays.delete(e.instanceId);else{var r;(r=this.indicatorOverlay)==null||r.removePill(e.instanceId)}}let i=new Set(t.map(e=>e.shortName));for(let e of i){var a;let t=this.activeIndicators.filter(t=>t.shortName===e).length;(a=this._tb)==null||a.setIndicatorOptionActive(e,t>0,t)}if(this.scheduleRender(),this.emitStateChange(),!this.isRestoringState)for(let e of t)this.emitter.emit(`indicatorRemoved`,{instanceId:e.instanceId,shortName:e.shortName});return this}addIndicatorByName(e,t){if(e===`VOL`){var n;if(this.setVolume(!this.showVolume),this.showVolume){var r;(r=this.indicatorOverlay)==null||r.addPill(`VOL`,this.theme.volume.up,`VOL`,`Chart`,!0,()=>{var e,t;this.setVolume(!1),(e=this.indicatorOverlay)==null||e.removePill(`VOL`),(t=this._tb)==null||t.setVolumeControl(!1,this.dataStore.hasVolumeData)},null,()=>{var e;this.setVolume(!this.showVolume),(e=this.indicatorOverlay)==null||e.updatePillVisibility(`VOL`,this.showVolume),this.scheduleRender()})}else{var i;(i=this.indicatorOverlay)==null||i.removePill(`VOL`)}(n=this._tb)==null||n.setVolumeControl(this.showVolume,this.dataStore.hasVolumeData);return}let a=zl.find(t=>t.shortName===e),o=Il.find(t=>t.shortName===e);if(!(!a&&!o)){if(Pl.has(e)&&this.activeIndicators.some(t=>t.shortName===e)){this.removeIndicator(e);return}if(a){let n=Object.fromEntries(a.fields.map(e=>[e.key,e.default]));if(a.fields.some(e=>e.key===`color`)){let t=this.activeIndicators.filter(t=>t.shortName===e).length;n.color=Nc(Fl,t)}t&&Object.assign(n,t);let r={...n};delete r.timeframe,this.addIndicator(a.factory(r),n)}else o&&this.addIndicator(o.factory(),t)}}openIndicatorSettings(e){var t;let n=this.activeIndicators.find(t=>t.instanceId===e);if(!n)return;let r=zl.find(e=>e.shortName===n.shortName);if(!r||r.fields.length===0)return;let i={...r,fields:[...r.fields,Ll]};(t=this.indicatorSettingsDialog)==null||t.show(i,n.currentParams,t=>this.updateIndicatorParams(e,t),()=>this.removeIndicator(e))}updateIndicatorParams(e,t){var n;let r=this.activeIndicators.find(t=>t.instanceId===e);if(!r)return;let i=zl.find(e=>e.shortName===r.shortName);if(!i)return;let{timeframe:a,...o}=t,s=i.factory(o);r.indicator=s,r.currentParams={...t},this.indicatorResults.delete(e),this.dataStore.length>0&&this.indicatorResults.set(e,s.compute(this.dataStore.all));let c=(n=this.subPaneOverlays.get(e))==null?this.indicatorOverlay:n;c==null||c.updatePillColor(e,s.color),c==null||c.updatePillLabel(e,Rl(r.shortName,r.currentParams,i)),c==null||c.updatePillTimeframe(e,a==null?`Chart`:a),this.scheduleRender(),this.emitStateChange()}on(e,t){return this.emitter.on(e,t)}buildTheme(e){var t,n,r,i,a,o,s;let l=e===`dark`?p:m,d=this.settingsCanvasColors[e],f=d?{...d.background!==void 0&&{background:d.background},...d.grid!==void 0&&{grid:d.grid},...d.axisText!==void 0&&{axisText:d.axisText},...d.axisBorder!==void 0&&{axisBorder:d.axisBorder},...d.crosshair!==void 0&&{crosshair:d.crosshair},...((t=(n=(r=(i=(a=d.candleUp)==null?d.candleDown:a)==null?d.wickUp:i)==null?d.wickDown:r)==null?d.borderUp:n)==null?d.borderDown:t)!==void 0&&{candle:{...d.candleUp!==void 0&&{up:d.candleUp},...d.candleDown!==void 0&&{down:d.candleDown},...d.wickUp!==void 0&&{wickUp:d.wickUp},...d.wickDown!==void 0&&{wickDown:d.wickDown},...d.borderUp!==void 0&&{borderUp:d.borderUp},...d.borderDown!==void 0&&{borderDown:d.borderDown}}},...((o=d.volumeUp)==null?d.volumeDown:o)!==void 0&&{volume:{...d.volumeUp!==void 0&&{up:d.volumeUp},...d.volumeDown!==void 0&&{down:d.volumeDown}}}}:void 0;return u(c(c(l,(s=this.themeOverrides)==null?void 0:s[e]),f),this.wrapper)}setTheme(e){var t,n,r,i,a,o,s,c,l,u,d,f,p;return this.themeName=e,this.theme=this.buildTheme(e),(t=this._tb)==null||t.setTheme(this.theme),(n=this.bottomBar)==null||n.setTheme(this.theme),(r=this.leftBar)==null||r.setTheme(this.theme),(i=this.tradeButton)==null||i.setTheme(this.theme,this.priceAxisWidth),(a=this.tradePopover)==null||a.setTheme(this.theme),(o=this.drawingStylePopover)==null||o.setTheme(this.theme),(s=this._draftQtyFlyout)==null||s.setTheme(this.theme),(c=this.indicatorSettingsDialog)==null||c.setTheme(this.theme),(l=this.chartSettingsDialog)==null||l.setTheme(this.theme),(u=this.layoutPopover)==null||u.setTheme(this.theme),(d=this.snapshotPopover)==null||d.setTheme(this.theme),this.applyScrollToEndBtnStyles(),this.applyResetViewBtnStyles(),this.applyMobileDrawingFlyoutTheme(),this.siSymbolSpan&&(this.siSymbolSpan.style.color=this.theme.axisText),this.siStreamDot&&(this.siStreamDot.style.background=this.theme.ui.stream.disconnected),(f=this.compareLegend)==null||f.setTheme(this.theme),(p=this.comparePickerModal)==null||p.setTheme(this.theme),this.scheduleRender(),this.emitStateChange(),this}getTimeframe(){return this.timeframe}setTimeframe(e){var t;return this.timeframe=e,(t=this._tb)==null||t.setTimeframe(e),this.emitter.emit(`timeframeChange`,{timeframe:e}),this.emitStateChange(),this.updateCountdownState(),this.triggerLoad(`timeframe`),this}setCrosshair(e){var t,n;if(e===null){if(this.crosshair===null)return;this.crosshair=null,this.scheduleRender();return}let{chartW:r,priceH:i}=this.getChartLayout(),a=(t=this._displayedPriceRange)==null?this.getScaledPriceRange(this.viewport):t,o=this.scaleManager.xToPixel(e.barIndex,this.viewport,r),s=this.scaleManager.yToPixel(e.price,a,i),c=this.dataStore.all,l=(n=c[Math.max(0,Math.min(c.length-1,Math.round(e.barIndex)))])==null?null:n;this.crosshair={x:o,y:s,barIndex:e.barIndex,price:e.price,bar:l},this.scheduleRender()}setViewport(e){e.startIndex===this.viewport.startIndex&&e.endIndex===this.viewport.endIndex||(this.viewport={...this.viewport,startIndex:e.startIndex,endIndex:e.endIndex},this._targetViewport={...this.viewport},this.scheduleRender())}timeToBarIndex(e){let t=this.dataStore.all;if(t.length===0)return null;let n=t[0],r=t[t.length-1];return!n||!r||e<n.time||e>r.time?null:this.timestampToBarIndex(e)}setThemeOverrides(e){var t,n,r,i,a,o,s,c,l,u,d;return this.themeOverrides=e,this.theme=this.buildTheme(this.themeName),(t=this._tb)==null||t.setTheme(this.theme),(n=this.bottomBar)==null||n.setTheme(this.theme),(r=this.leftBar)==null||r.setTheme(this.theme),(i=this.tradeButton)==null||i.setTheme(this.theme,this.priceAxisWidth),(a=this.tradePopover)==null||a.setTheme(this.theme),(o=this.drawingStylePopover)==null||o.setTheme(this.theme),(s=this._draftQtyFlyout)==null||s.setTheme(this.theme),(c=this.indicatorSettingsDialog)==null||c.setTheme(this.theme),(l=this.chartSettingsDialog)==null||l.setTheme(this.theme),(u=this.layoutPopover)==null||u.setTheme(this.theme),(d=this.snapshotPopover)==null||d.setTheme(this.theme),this.scheduleRender(),this}setTimezone(e){return this.timezone=e===`local`?Intl.DateTimeFormat().resolvedOptions().timeZone:e,this.scheduleRender(),this}setSeries(e){var t;return this.series=e,(t=this._tb)==null||t.setSeries(e),this.emitter.emit(`seriesChange`,{series:e}),this.scheduleRender(),this.emitStateChange(),this}setTfcActive(e){var t;if(!this.tfcEnabled)return this;if(this.tfcActive=e,(t=this._tb)==null||t.setTfcActive(e),!e){var n,r;(n=this.tradeButton)==null||n.hide(),(r=this.tradePopover)==null||r.hide(),this.draftOrderLabel!==null&&this.removeDraftOrder()}return this.chartSettingsDialog&&(this.chartSettingsDialog.destroy(),this.chartSettingsDialog=null),this.renderTradeLayer(),this.emitter.emit(`tfcToggle`,{enabled:e}),this.emitStateChange(),this}clearDuration(){var e,t;this.duration!==void 0&&(this.duration=void 0,(e=this._tb)==null||e.setActiveDuration(void 0),(t=this.bottomBar)==null||t.setActive(void 0),this.emitStateChange())}setVolume(e){return this.showVolume=e,this.scheduleRender(),this.emitStateChange(),this}dismissAllUI(){var e,t,n,r,i,a,o;return this.isAnyUIOpen()?((e=this._draftQtyFlyout)==null||e.hide(),(t=this.isinPickerModal)==null||t.hide(),(n=this.comparePickerModal)==null||n.hide(),(r=this.indicatorSettingsDialog)==null||r.hide(),(i=this.chartSettingsDialog)==null||i.hide(),(a=this.tradePopover)==null||a.hide(),(o=this._tb)==null||o.closeDropdown(),this.hideMobileDrawingFlyout(),!0):!1}isAnyUIOpen(){var e,t,n,r,i,a,o,s,c;return((e=this._draftQtyFlyout)==null?void 0:e.isVisible)===!0||((t=this.isinPickerModal)==null?void 0:t.isVisible)===!0||((n=this.comparePickerModal)==null?void 0:n.isVisible)===!0||((r=this.indicatorSettingsDialog)==null?void 0:r.isVisible)===!0||((i=this.chartSettingsDialog)==null?void 0:i.isVisible)===!0||((a=this.tradePopover)==null?void 0:a.isVisible)===!0||((o=this._tb)==null?void 0:o.hasOpenDropdown)===!0||((s=(c=this._mobileDrawingFlyout)==null?void 0:c.style.display)==null?`none`:s)!==`none`}emitUiState(){this.emitter.emit(`uiStateChange`,{hasOpenUI:this.isAnyUIOpen()})}emitStateChange(){this.isRestoringState||this.emitter.emit(`stateChange`,{symbol:this.symbol,state:this.getState()})}getState(){return{symbol:this.symbol,timeframe:this.timeframe,duration:this.duration,series:this.series,showVolume:this.showVolume,theme:this.themeName,indicators:this.activeIndicators.map(e=>({shortName:e.shortName,params:{...e.currentParams},visible:e.visible,instanceId:e.instanceId})),drawings:this.drawingManager.getDrawingsSnapshot().map(e=>({...e,points:e.points.map(e=>{var t;return{...e,timestamp:(t=e.timestamp)==null?this.barIndexToTimestamp(e.barIndex):t}})})),positionRenderStyle:this.positionRenderStyle,tradeDisplayFilter:this.tradeDisplayFilter,canvasColors:Object.keys(this.settingsCanvasColors).length>0?{...this.settingsCanvasColors}:void 0,tfcEnabled:this.tfcActive,viewport:this.getViewportTimestamps(),priceScale:this.priceScaleFactor!==1||this.pricePanOffset!==0?{factor:this.priceScaleFactor,panOffset:this.pricePanOffset}:void 0,compares:this.compareManager&&this.compareManager.isActive()?this.compareManager.list().map(e=>e.symbol):void 0}}getViewportTimestamps(){if(this.dataStore.all.length===0)return;let e=this.barIndexToTimestamp(this.viewport.startIndex),t=this.barIndexToTimestamp(this.viewport.endIndex);if(!(e==null||t==null))return{startTime:e,endTime:t}}applyViewportFromTimestamps(e,t){let n=this.timestampToBarIndex(e),r=this.timestampToBarIndex(t);this.viewport={...this.viewport,startIndex:n,endIndex:r},this._targetViewport={...this.viewport}}setState(e){this.isRestoringState=!0;try{if(this.setSeries(e.series),this.setVolume(e.showVolume),e.theme!=null&&this.setTheme(e.theme),e.timeframe!=null){var t,n,r;this.timeframe=e.timeframe,this.duration=e.duration,(t=this._tb)==null||t.setTimeframe(e.timeframe),(n=this._tb)==null||n.setActiveDuration(e.duration),(r=this.bottomBar)==null||r.setActive(e.duration),this.updateCountdownState()}let s=this.activeIndicators.map(e=>e.instanceId);for(let e of s)this.removeIndicator(e);for(let t of e.indicators){var i,a;let e=zl.find(e=>e.shortName===t.shortName);if(!e)continue;let n={...t.params};delete n.timeframe,this.addIndicator(e.factory(n),t.params);let r=this.activeIndicators[this.activeIndicators.length-1];if(!r)continue;r.currentParams={...t.params};let o=(i=this.subPaneOverlays.get(r.instanceId))==null?this.indicatorOverlay:i;t.visible===!1&&(r.visible=!1,o==null||o.updatePillVisibility(r.instanceId,!1));let s=(a=t.params.timeframe)==null?`Chart`:a;o==null||o.updatePillTimeframe(r.instanceId,s)}let c=e.drawings.map(e=>({...e,points:e.points.map(e=>e.timestamp==null||this.dataStore.all.length===0?e:{...e,barIndex:this.timestampToBarIndex(e.timestamp)})}));if(this.drawingManager.loadDrawings(c),e.positionRenderStyle&&(this.positionRenderStyleOverride=e.positionRenderStyle,this.positionRenderStyle=e.positionRenderStyle),e.tradeDisplayFilter&&(this.tradeDisplayFilter=e.tradeDisplayFilter),e.canvasColors&&(this.settingsCanvasColors=e.canvasColors),e.tfcEnabled!==void 0&&this.tfcEnabled){var o;this.tfcActive=e.tfcEnabled,(o=this._tb)==null||o.setTfcActive(e.tfcEnabled)}if(e.priceScale&&(this.priceScaleFactor=e.priceScale.factor,this.pricePanOffset=e.priceScale.panOffset,this._displayedPriceRange=null,this._lockedAutoFitBase=null),e.viewport&&(this.dataStore.all.length>0?this.applyViewportFromTimestamps(e.viewport.startTime,e.viewport.endTime):this._pendingViewportRestore={viewport:e.viewport,priceScale:e.priceScale}),e.compares&&e.compares.length>0&&this.compareManager){this.compareManager.clear();for(let t of e.compares)this.compareManager.add(t);this.refreshCompareLegend()}}finally{this.isRestoringState=!1}return this.emitStateChange(),this.scheduleRender(),this}barIndexToTimestamp(e){let t=this.dataStore.all,n=t.length;if(n===0)return;let r=t[0];if(!r)return;if(n===1)return r.time;let i=Math.floor(e),a=e-i;if(i<0){let n=t[1];return n?r.time+e*(n.time-r.time):r.time}if(i>=n-1){let i=t[n-1],a=t[n-2];return!i||!a?r.time:i.time+(e-(n-1))*(i.time-a.time)}let o=t[i],s=t[i+1];return!o||!s?r.time:o.time+a*(s.time-o.time)}timestampToBarIndex(e){let t=this.dataStore.all,n=t.length;if(n===0)return 0;let r=t[0];if(!r||n===1)return 0;if(e<=r.time){let n=t[1];if(!n)return 0;let i=n.time-r.time;return i>0?(e-r.time)/i:0}let i=n-1,a=t[i],o=t[i-1];if(!a||!o)return 0;if(e>=a.time){let t=a.time-o.time;return i+(t>0?(e-a.time)/t:0)}let s=0,c=i;for(;s<c;){var l,u;let n=s+c+1>>1;((l=(u=t[n])==null?void 0:u.time)==null?0:l)<=e?s=n:c=n-1}let d=t[s],f=t[s+1];if(!d||!f)return s;let p=f.time-d.time;return s+(p>0?(e-d.time)/p:0)}reanchorDrawingsByTimestamp(){if(this.dataStore.all.length!==0)for(let e of this.drawingManager.getDrawings())for(let t of e.points){if(t.timestamp==null){let e=this.barIndexToTimestamp(t.barIndex);e!=null&&(t.timestamp=e);continue}t.barIndex=this.timestampToBarIndex(t.timestamp)}}backfillDrawingTimestamps(){if(this.dataStore.all.length!==0)for(let e of this.drawingManager.getDrawings())for(let t of e.points){if(t.timestamp!=null)continue;let e=this.barIndexToTimestamp(t.barIndex);e!=null&&(t.timestamp=e)}}resetChartSettings(){return this.setState({symbol:this.symbol,series:`candlestick`,theme:`dark`,timeframe:`1D`,duration:void 0,showVolume:!0,indicators:[],drawings:[]}),this.positionRenderStyleOverride=null,localStorage.removeItem(this.RENDER_STYLE_LS_KEY),this.recomputeRenderStyle(),this.settingsCanvasColors={},this.setTheme(`dark`),this.emitStateChange(),this}setSymbol(e){var t,n;return this.symbol=e,(t=this.tradePopover)==null||t.setSymbol(e),this.siSymbolSpan&&(this.siSymbolSpan.textContent=e,this.siSymbolSpan.style.display=e?`inline`:`none`),(n=this.isinPickerModal)==null||n.setCurrentSymbol(e),this.tickActivityTimer!==null&&(clearTimeout(this.tickActivityTimer),this.tickActivityTimer=null),this.siStreamDot&&(this.siStreamDot.style.background=this.theme.ui.stream[this.streamStatus]),this.liveBidAsk=null,this.liveLtp=null,this}setIsins(e){var t;return this.isins=e,(t=this.isinPickerModal)==null||t.setIsins(e),this}renderSymbolInfoOHLC(e){if(!this.siOHLCSpan)return;if(!e){this.siOHLCSpan.innerHTML=``,this.siOHLC2Span&&(this.siOHLC2Span.innerHTML=``);return}let t=e.close>=e.open?this.theme.candle.up:this.theme.candle.down,n=e=>e.toFixed(this.dataStore.getPricePrecision()),r=e=>e>=1e6?(e/1e6).toFixed(2)+`M`:e>=1e3?(e/1e3).toFixed(1)+`K`:e.toFixed(0),i=this.labels.ohlc,a=(e,t)=>{e.innerHTML=``;for(let[n,r,i]of t){let t=document.createElement(`span`);t.style.marginRight=`8px`;let a=document.createElement(`span`);a.textContent=n+`\xA0`,a.style.color=this.theme.axisText,a.style.opacity=`0.6`;let o=document.createElement(`span`);o.textContent=r,o.style.color=i,t.append(a,o),e.appendChild(t)}};a(this.siOHLCSpan,[[i.open,n(e.open),this.theme.axisText],[i.high,n(e.high),this.theme.axisText]]),this.siOHLC2Span&&a(this.siOHLC2Span,[[i.low,n(e.low),this.theme.axisText],[i.close,n(e.close),t],...e.volume!=null&&e.volume!==0?[[i.volume,r(e.volume),this.theme.axisText]]:[]])}setMinLots(e){var t;return console.warn(`[acttrader-charts] setMinLots() is deprecated. Pass minLots in the initial ChartConfig instead.`),this._minLots=e,(t=this.tradePopover)==null||t.setLots(e),this}setDraftQty(e){return this.draftOrderLabel&&this.setLevelQty(this.draftOrderLabel,e),this}setLevelQty(e,t){var n,r;let i=this.levels.findIndex(t=>t.label===e);if(i===-1)return;let a=this.levels[i];if(a.lots===t)return;this.originalQtyByLabel.has(e)||this.originalQtyByLabel.set(e,a.lots);let o=(n=(r=this.originalQtyByLabel.get(e))==null?a.lots:r)==null?t:n;this.levels=[...this.levels.slice(0,i),{...a,lots:t},...this.levels.slice(i+1)],e!==this.draftOrderLabel&&this.pendingQtyChanges.set(e,t),this.emitter.emit(`tradeLevelQtyChange`,{label:e,type:e===this.draftOrderLabel?`draft`:a.type,newLots:t,previousLots:o,isFullscreen:this.isFullscreen}),this.renderTradeLayer()}openDraftQtyFlyout(e){var t;this._draftQtyFlyout||(this._draftQtyFlyout=new Tc(this.theme,e=>{this._activeQtyPillLabel&&this.setLevelQty(this._activeQtyPillLabel,e)},()=>this.emitUiState()),this.getFloatingRoot().appendChild(this._draftQtyFlyout.el)),this._activeQtyPillLabel=e.label;let n=this.levels.find(t=>t.label===e.label),r=(t=n==null?void 0:n.lots)==null?this._qtyFieldMin:t,i=this.canvasWrap.getBoundingClientRect(),a=i.left+e.pillX,o=i.top+e.pillY+e.pillH;this._draftQtyFlyout.show(a,o,r,this._qtyFieldMin,this._qtyFieldMax)}setDraftOrderLabels(e){return console.warn(`[acttrader-charts] setDraftOrderLabels() is deprecated and is a no-op. DraftOrderQtyInput has been removed.`),this}setDrawingTool(e){var t;return this.drawingManager.setActiveTool(e),(t=this.leftBar)==null||t.setActiveTool(e),this.drawCanvas.style.cursor=e?`crosshair`:`default`,this.scheduleRender(),this}undoDrawing(){return this.drawingManager.undo(),this.scheduleRender(),this}redoDrawing(){return this.drawingManager.redo(),this.scheduleRender(),this}hideAllDrawings(){return this.drawingManager.hideAll(),this.scheduleRender(),this}showAllDrawings(){return this.drawingManager.showAll(),this.scheduleRender(),this}lockAllDrawings(){return this.drawingManager.lockAll(),this.scheduleRender(),this}unlockAllDrawings(){return this.drawingManager.unlockAll(),this.scheduleRender(),this}deleteSelectedDrawing(){return this.drawingManager.deleteSelected(),this.hideMobileDrawingFlyout(),this.scheduleRender(),this}clearAllDrawings(){return this.drawingManager.clearAll(),this.scheduleRender(),this}getActiveTool(){return this.drawingManager.getActiveTool()}getDrawings(){return this.drawingManager.getDrawings()}getDrawingById(e){return this.drawingManager.getDrawingById(e)}getSelectedDrawing(){return this.drawingManager.getSelectedDrawing()}updateDrawingStyle(e,t){return this.drawingManager.updateDrawingStyle(e,t),this.scheduleRender(),this}connectStream(e){return this.streamAdapter=e,e.onTick(e=>this.onTick(e)),e.onStatus(e=>{this.streamStatus=e,this.siStreamDot&&(this.siStreamDot.style.background=this.theme.ui.stream[e],this.siStreamDot.title=`Stream ${e}`),this.emitter.emit(`streamStatus`,{status:e})}),e.connect(),this}disconnectStream(){var e;return(e=this.streamAdapter)==null||e.disconnect(),this.streamAdapter=null,this}setShowLtpPrice(e){return this.showLtpPrice=e,this.scheduleRender(),this}setShowAskLine(e){return this.showAskLine=e,this.scheduleRender(),this}setShowBidLine(e){return this.showBidLine=e,this.scheduleRender(),this}pushTick(e){let t=e.T==null?Date.now():typeof e.T==`string`?new Date(e.T).getTime():e.T;return this.onTick({time:t,bid:e.B,ask:e.A,volume:e.LTPV!=null&&e.LTPV>0?e.LTPV:0,ltp:e.LTP!=null&&e.LTP>0?e.LTP:void 0}),this}setLevels(e,t,n,r,i,a){let o=e.map(e=>{if(r===`position`){let r={label:String(e[t]),price:Number(e[n]),type:`position`,data:e};return e.text!==void 0&&(r.text=String(e.text)),i!==void 0&&e[i]!==void 0&&(r.pnl=Number(e[i])),a!==void 0&&e[a]!==void 0&&(r.pnlText=String(e[a])),e.side!==void 0&&(r.side=e.side),e.stopLossPrice!==void 0&&(r.stopLossPrice=Number(e.stopLossPrice)),e.takeProfitPrice!==void 0&&(r.takeProfitPrice=Number(e.takeProfitPrice)),e.entryPriceEditable&&(r.entryPriceEditable=!0),e.orderType!==void 0&&(r.orderType=e.orderType),e.lots!==void 0&&(r.lots=Number(e.lots)),e.timestamp!==void 0&&(r.timestamp=Number(e.timestamp)),e.timeDraggable&&(r.timeDraggable=!0),r}if(r===`pending`){var o,s;let r={label:String(e[t]),price:Number(e[n]),type:`pending`,side:(o=e.side)==null?`buy`:o,orderType:(s=e.orderType)==null?`limit`:s,data:e};return e.text!==void 0&&(r.text=String(e.text)),e.lots!==void 0&&(r.lots=Number(e.lots)),e.stopLossPrice!==void 0&&(r.stopLossPrice=Number(e.stopLossPrice)),e.takeProfitPrice!==void 0&&(r.takeProfitPrice=Number(e.takeProfitPrice)),e.ToClose!==void 0&&(r.ToClose=String(e.ToClose)),e.timestamp!==void 0&&(r.timestamp=Number(e.timestamp)),e.timeDraggable&&(r.timeDraggable=!0),r}return{label:String(e[t]),price:Number(e[n]),type:`trade`,text:e.text===void 0?void 0:String(e.text),data:e}});if(this.hideLevelConfirmCancel&&this.pendingLevelDrags.size>0)for(let e of o){let t=this.pendingLevelDrags.get(e.label);if(!(t!=null&&t.length))continue;let n=e;t.every(t=>t.isRemoval?t.field===`stopLoss`?n.stopLossPrice===void 0:n.takeProfitPrice===void 0:t.field===`main`?e.price===t.newPrice:t.field===`stopLoss`?n.stopLossPrice===t.newPrice:n.takeProfitPrice===t.newPrice)&&(this.pendingLevelDrags.delete(e.label),this.selectedTradeLabel===e.label&&(this.selectedTradeLabel=null))}if(this.pendingQtyChanges.size>0)for(let e=0;e<o.length;e++){let t=o[e],n=this.pendingQtyChanges.get(t.label);if(n===void 0||t.type!==`pending`&&t.type!==`position`)continue;let r=t;this.originalQtyByLabel.set(t.label,r.lots),o[e]={...r,lots:n}}let s=this.draftOrderLabel===null?void 0:this.levels.find(e=>e.type===r&&e.label===this.draftOrderLabel&&!o.some(t=>t.label===e.label));if(this.levels=[...this.levels.filter(e=>e.type!==r),...o,...s?[s]:[]],this._timeAnchorOverride.size>0)for(let e of[...this._timeAnchorOverride.keys()]){let t=this.levels.find(t=>t.label===e);if(!t){this._timeAnchorOverride.delete(e);continue}let n=t.timestamp,r=this._timeAnchorOverride.get(e);n!==void 0&&r!==void 0&&Math.round(this.timestampToBarIndex(n))===Math.round(this.timestampToBarIndex(r))&&this._timeAnchorOverride.delete(e)}return this.selectedTradeLabel!==null&&!this.levels.some(e=>e.label===this.selectedTradeLabel)&&(this.selectedTradeLabel=null),this.recomputeRenderStyle(),this.renderTradeLayer(),this}removeLevelByLabel(e){return this.levels=this.levels.filter(t=>t.label!==e),this.renderTradeLayer(),this}showDraftOrder(e,t,n){if(this.draftOrderLabel){let e=this.levels.find(e=>e.label===this.draftOrderLabel);if((e==null?void 0:e.side)===t&&(e==null?void 0:e.orderType)===n)return this}return this.clearDraftOrder(),this.createDraftOrder(t,e,n),this}showMarketDraft(e,t){this.clearDraftOrder();let n=`__draft_${Date.now()}`,r={type:`pending`,label:n,side:t,price:e,orderType:`market`,data:{_isDraft:!0}};return this.levels=[...this.levels,r],this.draftOrderLabel=n,this.renderTradeLayer(),this.emitter.emit(`draftInitiated`,{side:t,price:e,orderType:`market`,isFullscreen:this.isFullscreen}),this}clearDraftOrder(){return this.removeDraftOrder(),this}updateLevelBracket(e,t,n){var r;let i=t===`sl`?`stopLoss`:`takeProfit`,a=this.levels.find(t=>t.label===e);if(!a)return this;let o=t===`sl`?a.stopLossPrice:a.takeProfitPrice,s=(r=this.pendingLevelDrags.get(e))==null?[]:r,c=s.find(e=>e.field===i),l=s.filter(e=>e.field!==i);if(this.levels=this.levels.map(r=>{if(r.label!==e)return r;let i=r;return t===`sl`?{...i,stopLossPrice:n==null?void 0:n}:{...i,takeProfitPrice:n==null?void 0:n}}),n===null){if(o!==void 0){var u;let e=(u=c==null?void 0:c.oldPrice)==null?o:u;l.push({field:i,newPrice:o,oldPrice:e,isRemoval:!0})}l.length===0?this.pendingLevelDrags.delete(e):this.pendingLevelDrags.set(e,l)}else{var d;let t=(d=c==null?void 0:c.isNew)==null?o===void 0:d,r=c&&!c.isRemoval?c.oldPrice:o==null?n:o;l.push({field:i,newPrice:n,oldPrice:r,isNew:t}),this.pendingLevelDrags.set(e,l)}return this.renderTradeLayer(),this}addLevelBracket(e,t){var n,r,i,a,o;let s=this.levels.find(t=>t.label===e);if(!s)return this;let c=t===`sl`?`stopLoss`:`takeProfit`,l=t===`sl`?s.stopLossPrice!==void 0:s.takeProfitPrice!==void 0,u=(n=(r=this.pendingLevelDrags.get(e))==null?void 0:r.some(e=>e.field===c&&!e.isRemoval))==null?!1:n;if(l||u)return this;let{priceH:d}=this.getChartLayout(),f=(i=this._displayedPriceRange)==null?this.getScaledPriceRange(this.viewport):i,p=this.scaleManager.yToPixel(s.price,f,d),m=(a=s.side)==null?`buy`:a,h=p+(m===`buy`&&t===`sl`||m===`sell`&&t===`tp`?30:-30),g=this.scaleManager.pixelToPrice(h,f,d);this.updateLevelBracket(e,t,g);let _=((o=this.pendingLevelDrags.get(e))==null?[]:o).filter(e=>e.field!==c);return _.push({field:c,newPrice:g,oldPrice:g,isNew:!0}),this.pendingLevelDrags.set(e,_),this.emitter.emit(`tradeLevelBracketActivated`,{label:e,bracketType:t,price:g,isFullscreen:this.isFullscreen}),this.emitter.emit(`tradeLevelDrag`,{label:e,newPrice:g,data:s.data,bracketType:t===`sl`?`stopLoss`:`takeProfit`,isFullscreen:this.isFullscreen}),this}addBracket(e,t){var n,r;if(t)return this.addLevelBracket(t,e);if(!this.draftOrderLabel)return this;let i=this.draftOrderLabel,a=this.levels.find(e=>e.label===i);if(!a||(e===`sl`?a.stopLossPrice!==void 0:a.takeProfitPrice!==void 0))return this;let{priceH:o}=this.getChartLayout(),s=(n=this._displayedPriceRange)==null?this.getScaledPriceRange(this.viewport):n,c=this.scaleManager.yToPixel(a.price,s,o),l=(r=a.side)==null?`buy`:r,u=c+(l===`buy`&&e===`sl`||l===`sell`&&e===`tp`?30:-30),d=this.scaleManager.pixelToPrice(u,s,o);return this.updateDraftOrderBracket(e,d),this.emitter.emit(`tradeLevelBracketActivated`,{label:``,bracketType:e,price:d,isFullscreen:this.isFullscreen}),this.emitter.emit(`tradeLevelDrag`,{label:i,newPrice:d,data:a.data,bracketType:e===`sl`?`stopLoss`:`takeProfit`,isFullscreen:this.isFullscreen}),this}removeBracket(e,t){if(t){var n,r;let i=e===`sl`?`stopLoss`:`takeProfit`,a=this.levels.find(e=>e.label===t);if(!a)return this;let o=(n=this.pendingLevelDrags.get(t))==null?void 0:n.find(e=>e.field===i),s=o&&!o.isRemoval?o.newPrice:e===`sl`?a.stopLossPrice:a.takeProfitPrice;if(s===void 0)return this;let c=((r=this.pendingLevelDrags.get(t))==null?[]:r).filter(e=>e.field!==i);return c.push({field:i,newPrice:s,oldPrice:s,isRemoval:!0}),this.pendingLevelDrags.set(t,c),this.renderTradeLayer(),this}return e===`sl`?this.draftBracketPnl={...this.draftBracketPnl,sl:void 0}:this.draftBracketPnl={...this.draftBracketPnl,tp:void 0},this.updateDraftOrderBracket(e,null)}updateLevelMainPrice(e,t){var n;let r=this.levels.find(t=>t.label===e);if(!r)return this;let i=(n=this.pendingLevelDrags.get(e))==null?[]:n,a=i.find(e=>e.field===`main`),o=a?a.oldPrice:r.price,s=i.filter(e=>e.field!==`main`);return s.push({field:`main`,newPrice:t,oldPrice:o}),this.pendingLevelDrags.set(e,s),r.price=t,this.renderTradeLayer(),this}setDraftBracketPnl(e,t){return e===`sl`?this.draftBracketPnl={...this.draftBracketPnl,sl:t==null?void 0:t}:this.draftBracketPnl={...this.draftBracketPnl,tp:t==null?void 0:t},this.renderTradeLayer(),this}updateDraftOrderBracket(e,t){return this.draftOrderLabel?(this.levels=this.levels.map(n=>{if(n.label!==this.draftOrderLabel)return n;let r=n;return e===`sl`?{...r,stopLossPrice:t==null?void 0:t}:{...r,takeProfitPrice:t==null?void 0:t}}),this.scheduleRender(),this):this}updateDraftOrderPrice(e){if(!this.draftOrderLabel)return!1;this.levels=this.levels.map(t=>t.label===this.draftOrderLabel?{...t,price:e}:t);let t=this.pendingLevelDrags.get(this.draftOrderLabel);if(t){let n=t.find(e=>e.field===`main`);n&&(n.newPrice=e)}return this.renderTradeLayer(),!0}cancelLevelEdit(e){var t;if(this.undoIsNewBracketMutations(e),this.pendingLevelDrags.delete(e),this.pendingQtyChanges.has(e)){this.pendingQtyChanges.delete(e);let t=this.levels.findIndex(t=>t.label===e);if(t!==-1&&this.originalQtyByLabel.has(e)){let n=this.originalQtyByLabel.get(e),r=this.levels[t];this.levels=[...this.levels.slice(0,t),{...r,lots:n},...this.levels.slice(t+1)]}this.originalQtyByLabel.delete(e)}return e===((t=this.draftOrderLabel)==null?this.selectedTradeLabel:t)&&(this.draftBracketPnl={}),this.selectedTradeLabel===e&&(this.selectedTradeLabel=null),this.renderTradeLayer(),this}cancelCurrentEdit(){return this.draftOrderLabel?this.clearDraftOrder():this.selectedTradeLabel&&this.revertPendingChanges(this.selectedTradeLabel),this}selectLevel(e){if(!this.draftOrderLabel&&e!==this.selectedTradeLabel&&(this.draftBracketPnl={}),this.selectedTradeLabel=e,e!==null){this.crosshair=null;let t=this.lastClusters.find(t=>t.members.some(t=>t.level.label===e));t&&this.expandedClusters.add(t.id)}return this.renderTradeLayer(),this}setLevelClusteringEnabled(e){return this.levelClusteringEnabled=e,this.expandedClusters.clear(),this.renderTradeLayer(),this}setClusterThresholdDistance(e){return this.clusterThresholdDistance=e,this.expandedClusters.clear(),this.renderTradeLayer(),this}setTradeLevelButtonScale(e){return this.tradeLevelButtonScale=Math.min(Math.max(e,1),3),this.renderTradeLayer(),this}toDataUrl(){return this.captureToDataUrl()}drawOnto(e,t,n,r,i){e.fillStyle=this.theme.background,e.fillRect(t,n,r,i);let a=[this.canvas,this.drawCanvas];for(let o of a)o&&o.width&&o.height&&e.drawImage(o,t,n,r,i)}captureToDataUrl(){let e=this.canvas;if(!e.width||!e.height)return null;let t=document.createElement(`canvas`);t.width=e.width,t.height=e.height;let n=t.getContext(`2d`);if(!n)return null;n.fillStyle=this.theme.background,n.fillRect(0,0,t.width,t.height);let r=[this.canvas,this.drawCanvas];for(let e of r)e&&e.width&&e.height&&n.drawImage(e,0,0);return t.toDataURL(`image/png`)}openLayoutPopover(){var e,t,n;if(!this.layoutPopover)return;let r=(e=(t=this.advancedToolbar)==null?void 0:t.getLayoutBtnEl())==null?(n=this.topBar)==null?void 0:n.getLayoutBtnEl():e;if(r)if(this.layoutPopover.isVisible)this.layoutPopover.hide();else{let e=this.getFloatingRoot();this.layoutPopover.el.parentElement!==e&&e.appendChild(this.layoutPopover.el),this.layoutPopover.show(r)}}openSnapshotPopover(){var e,t,n;if(!this.snapshotPopover)return;let r=(e=(t=this.advancedToolbar)==null?void 0:t.getSnapshotBtnEl())==null?(n=this.topBar)==null?void 0:n.getSnapshotBtnEl():e;if(r)if(this.snapshotPopover.isVisible)this.snapshotPopover.hide();else{let e=this.getFloatingRoot();this.snapshotPopover.el.parentElement!==e&&e.appendChild(this.snapshotPopover.el),this.snapshotPopover.show(r)}}handleLayoutPresetSelect(e){var t,n,r,i;this.currentPresetId=e;let a=Hr(e);(t=this._tb)==null||(n=t.setLayoutPresetIcon)==null||n.call(t,a.icon,!0),(r=this.layoutPopover)==null||r.setPreset(e),(i=this.layoutPopover)==null||i.hide(),this.emitter.emit(`layoutChange`,{presetId:e,preset:a,sync:this.currentSync})}handleSyncToggle(e){var t;this.currentSync={...this.currentSync,[e]:!this.currentSync[e]},(t=this.layoutPopover)==null||t.setSync(this.currentSync),this.emitter.emit(`layoutChange`,{presetId:this.currentPresetId,preset:Hr(this.currentPresetId),sync:this.currentSync})}async handleSnapshot(e){var t;let n=this.captureToDataUrl();if(n){if(this.emitter.emit(`snapshot`,{dataUrl:n,action:e}),e===`download`){let e=document.createElement(`a`);e.download=`${this.snapshotFileName()}.png`,e.href=n,e.click()}else try{var r;let e=await(await fetch(n)).blob(),t=globalThis.ClipboardItem;t&&(r=navigator.clipboard)!=null&&r.write&&await navigator.clipboard.write([new t({"image/png":e})])}catch(e){}(t=this.snapshotPopover)==null||t.hide()}}snapshotFileName(){let e=this.symbol.trim().replace(/[\\/:*?"<>|]+/g,`_`).replace(/\s+/g,`_`);return e.length>0?e:`chart-${Date.now()}`}setLayoutPreset(e){this.handleLayoutPresetSelect(e)}getLayoutPreset(){return this.currentPresetId}getLayoutSync(){return{...this.currentSync}}setLayoutSync(e){var t;let n={...this.currentSync,...e};Object.keys(n).some(e=>n[e]!==this.currentSync[e])&&(this.currentSync=n,(t=this.layoutPopover)==null||t.setSync(this.currentSync))}destroy(){var e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_;this._isDestroyed=!0,this.panHandler.destroy(),this.zoomHandler.destroy(),this.resizeObserver.disconnect(),this.disposeVvListener(),(e=this.indicatorOverlay)==null||e.destroy();for(let e of this.subPaneOverlays.values())e.destroy();this.subPaneOverlays.clear(),(t=this.indicatorSettingsDialog)==null||t.destroy(),(n=this.chartSettingsDialog)==null||n.destroy(),(r=this.isinPickerModal)==null||r.destroy(),(i=this.comparePickerModal)==null||i.destroy(),(a=this.compareLegend)==null||a.destroy(),(o=this.tradePopover)==null||o.destroy(),(s=this.drawingStylePopover)==null||s.destroy(),(c=this._draftQtyFlyout)==null||c.destroy(),(l=this.advancedToolbar)==null||l.destroy(),(u=this.mobileHeader)==null||u.destroy(),(d=this.leftBar)==null||d.destroy(),this.drawCanvas.removeEventListener(`mousemove`,this.onMouseMove),this.drawCanvas.removeEventListener(`mouseleave`,this.onMouseLeave),this.drawCanvas.removeEventListener(`mousedown`,this.onCanvasClick),this.drawCanvas.removeEventListener(`dblclick`,this.onDoubleClick),window.removeEventListener(`mouseup`,this.onMouseUp),this.drawCanvas.removeEventListener(`touchstart`,this.onDrawingTouchStart),this.drawCanvas.removeEventListener(`touchmove`,this.onDrawingTouchMove),this.drawCanvas.removeEventListener(`touchend`,this.onDrawingTouchEnd),this.drawCanvas.removeEventListener(`touchcancel`,this.onDrawingTouchCancel),document.removeEventListener(`keydown`,this.onKeyDown),(f=this.streamAdapter)==null||f.disconnect(),this.rafId!==null&&cancelAnimationFrame(this.rafId),this.scrollAnimId!==null&&cancelAnimationFrame(this.scrollAnimId),this.stopCountdownLoop(),(p=this.resetViewBtn)==null||p.remove(),(m=this.textInputEl)==null||m.remove(),(h=this._mobileDrawingFlyout)==null||h.remove(),(g=this.layoutPopover)==null||g.destroy(),(_=this.snapshotPopover)==null||_.destroy(),this.wrapper.remove()}createMobileDrawingFlyout(){let e=document.createElement(`div`);Object.assign(e.style,{position:`fixed`,display:`none`,alignItems:`center`,gap:`2px`,zIndex:`10000`,background:this.theme.background,border:`1px solid ${this.theme.axisBorder}`,borderRadius:`8px`,padding:`4px`,boxShadow:`0 4px 16px rgba(0,0,0,0.45)`,pointerEvents:`auto`});let t=(e,t,n)=>{let r=document.createElement(`button`);return r.title=t,r.innerHTML=e,Object.assign(r.style,{display:`flex`,alignItems:`center`,justifyContent:`center`,width:`34px`,height:`34px`,padding:`0`,border:`none`,borderRadius:`6px`,background:`transparent`,color:n?this.theme.candle.down:this.theme.axisText,cursor:`pointer`,flexShrink:`0`}),r.addEventListener(`pointerenter`,()=>{r.style.background=n?`${this.theme.candle.down}22`:this.theme.axisBorder}),r.addEventListener(`pointerleave`,()=>{r.style.background=`transparent`}),r},n=t(tn,`Delete drawing`,!0);n.addEventListener(`pointerdown`,e=>{e.stopPropagation(),this.deleteSelectedDrawing(),this.hideMobileDrawingFlyout()});let r=t(Qt,`Deselect`,!1);return r.addEventListener(`pointerdown`,e=>{e.stopPropagation(),this.drawingManager.selectDrawing(null),this.hideMobileDrawingFlyout(),this.scheduleRender()}),e.appendChild(n),e.appendChild(r),this.wrapper.appendChild(e),e}showMobileDrawingFlyout(e,t){if(!Zl())return;this._mobileDrawingFlyout||(this._mobileDrawingFlyout=this.createMobileDrawingFlyout());let n=this._mobileDrawingFlyout,r=n.style.display!==`none`&&n.style.display!==``;n.style.display=`flex`,requestAnimationFrame(()=>{let r=n.offsetWidth||78,i=n.offsetHeight||42,a=window.innerWidth,o=window.innerHeight,s=Math.min(Math.max(e-r/2,8),a-r-8),c=Math.min(Math.max(t-i-12,8),o-i-8);n.style.left=`${s}px`,n.style.top=`${c}px`}),r||this.emitUiState()}hideMobileDrawingFlyout(){if(this._mobileDrawingFlyout){let e=this._mobileDrawingFlyout.style.display!==`none`&&this._mobileDrawingFlyout.style.display!==``;this._mobileDrawingFlyout.style.display=`none`,e&&this.emitUiState()}}applyMobileDrawingFlyoutTheme(){if(!this._mobileDrawingFlyout)return;let e=this._mobileDrawingFlyout;e.style.background=this.theme.background,e.style.border=`1px solid ${this.theme.axisBorder}`;let[t,n]=Array.from(e.querySelectorAll(`button`));t&&(t.style.color=this.theme.candle.down),n&&(n.style.color=this.theme.axisText)}scheduleRender(){this._isDestroyed||this.rafId===null&&(this.rafId=requestAnimationFrame(()=>{this.rafId=null,this.render(),this.renderTradeLayer()}))}startCountdownLoop(){if(this.countdownRafId!==null)return;let e=0,t=n=>{if(!this.countdownActive){this.countdownRafId=null;return}n-e>=1e3&&(e=n,this.scheduleRender()),this.countdownRafId=requestAnimationFrame(t)};this.countdownRafId=requestAnimationFrame(t)}stopCountdownLoop(){this.countdownActive=!1,this.countdownRafId!==null&&(cancelAnimationFrame(this.countdownRafId),this.countdownRafId=null)}updateCountdownState(){var e;let t=this.candleCountdownTimeframes===`all`?!0:((e=this.candleCountdownTimeframes)==null?[`1m`,`5m`,`15m`,`30m`,`1h`,`2h`,`4h`,`8h`]:e).includes(this.timeframe),n=(this.showCandleCountdown||this.showPriceAxisCountdown)&&t&&this.dataStore.length>0;n&&!this.countdownActive?(this.countdownActive=!0,this.startCountdownLoop()):!n&&this.countdownActive&&this.stopCountdownLoop()}openChartSettings(){this.chartSettingsDialog||(this.chartSettingsDialog=new mc(this.theme,{tradeDisplayFilter:this.tradeDisplayFilter,positionRenderStyle:this.positionRenderStyle,theme:this.themeName,showTradeLevelsAlways:this.showTradeLevelsAlways,showPriceAxisCountdown:this.showPriceAxisCountdown},this.labels.dialogs,!!this._onOrderSubmit&&this.tfcActive,this.enableThemeToggle,()=>this.emitUiState()),this.getFloatingRoot().appendChild(this.chartSettingsDialog.el)),this.chartSettingsDialog.show({tradeDisplayFilter:this.tradeDisplayFilter,positionRenderStyle:this.positionRenderStyle,theme:this.themeName,showTradeLevelsAlways:this.showTradeLevelsAlways,showPriceAxisCountdown:this.showPriceAxisCountdown,canvasColors:{...this.settingsCanvasColors}},e=>{if(this.tradeDisplayFilter=e.tradeDisplayFilter,this.positionRenderStyleOverride=e.positionRenderStyle,localStorage.setItem(this.RENDER_STYLE_LS_KEY,e.positionRenderStyle),this.positionRenderStyle=e.positionRenderStyle,e.canvasColors&&(this.settingsCanvasColors=e.canvasColors),this.showTradeLevelsAlways!==e.showTradeLevelsAlways){this.showTradeLevelsAlways=e.showTradeLevelsAlways;try{localStorage.setItem(this.SHOW_SLTP_ALWAYS_LS_KEY,String(e.showTradeLevelsAlways))}catch(e){}}if(this.showPriceAxisCountdown!==e.showPriceAxisCountdown){this.showPriceAxisCountdown=e.showPriceAxisCountdown;try{localStorage.setItem(this.PRICE_AXIS_COUNTDOWN_LS_KEY,String(e.showPriceAxisCountdown))}catch(e){}this.updateCountdownState(),this.scheduleRender()}this.setTheme(e.theme),this.renderTradeLayer(),this.emitStateChange()},()=>{this.resetChartSettings()})}getFloatingRoot(){var e;return(e=document.fullscreenElement)==null?document.body:e}reparentFloatingElements(){var e,t,n,r,i,a,o,s,c;let l=this.getFloatingRoot();(e=this._tb)==null||e.reparentFlyout(l),(t=this.leftBar)==null||t.reparentFlyout(l);let u=[(n=this.isinPickerModal)==null?void 0:n.el,(r=this.comparePickerModal)==null?void 0:r.el,(i=this.indicatorSettingsDialog)==null?void 0:i.el,(a=this.chartSettingsDialog)==null?void 0:a.el,(o=this._draftQtyFlyout)==null?void 0:o.el,(s=this.layoutPopover)==null?void 0:s.el,(c=this.snapshotPopover)==null?void 0:c.el];for(let e of u)e&&e.parentElement!==l&&l.appendChild(e)}toggleDrawingTools(){var e,t;this.leftBarVisible=!this.leftBarVisible,(e=this.leftBar)==null||e.setVisible(this.leftBarVisible),(t=this._tb)==null||t.setDrawingsBtnActive(this.leftBarVisible)}_applyCssFullscreen(e){var t;this._isCssFullscreen=e,e?Object.assign(this.wrapper.style,{position:`fixed`,inset:`0`,width:`100vw`,height:`100vh`,zIndex:`9999`}):Object.assign(this.wrapper.style,{position:``,inset:``,width:``,height:``,zIndex:``}),(t=this._tb)==null||t.setFullscreen(e),this.reparentFloatingElements(),requestAnimationFrame(()=>this.onResize())}toggleFullscreen(){let e=!!document.fullscreenElement;!e&&!this._isCssFullscreen?this.wrapper.requestFullscreen?this.wrapper.requestFullscreen().then(()=>{var e;(e=this._tb)==null||e.setFullscreen(!0)}).catch(()=>{this._applyCssFullscreen(!0)}):this._applyCssFullscreen(!0):e?document.exitFullscreen().catch(()=>{}):this._applyCssFullscreen(!1)}recomputeRenderStyle(){if(this.positionRenderStyleOverride!==null){this.positionRenderStyle=this.positionRenderStyleOverride;return}let e=this.levels.filter(e=>e.type===`position`||e.type===`pending`).length;this.positionRenderStyle=e>this.tradesThresholdForHorizontalLine?`dot`:`line`}renderTradeLayer(){var e,t,n,r,i,a;if(this._isDestroyed)return;let o=window.devicePixelRatio||1,{tradeCtx:s,tradeCanvas:c,theme:l,viewport:u}=this;if(s.clearRect(0,0,c.width,c.height),!this.tfcActive||this.levels.length===0||this.dataStore.length===0){this.tradeLevelHitAreas=[],this.tradeLevelEditAreas=[],this.tradeHoverAreas=[],this.tradeAddBracketAreas=[],this.offViewportHitAreas=[];return}let{chartW:d,priceH:f}=this.getChartLayout(),p=(e=this._displayedPriceRange)==null?this.getScaledPriceRange(u):e,m=this.levels.filter(e=>e.type===`pending`&&e.ToClose!=null),h=this.levels.filter(e=>!(e.type===`pending`&&e.ToClose!=null)).map(e=>{var t,n,r,i;let a=(t=this.pendingLevelDrags.get(e.label))==null?[]:t,o=a.find(e=>e.field===`stopLoss`),s=a.find(e=>e.field===`takeProfit`),c=o&&!o.isRemoval?o.newPrice:void 0,l=s&&!s.isRemoval?s.newPrice:void 0,u=(n=o==null?void 0:o.isRemoval)==null?!1:n,d=(r=s==null?void 0:s.isRemoval)==null?!1:r,f=(i=a.find(e=>e.field===`main`))==null?void 0:i.newPrice,p=m.filter(t=>t.ToClose===e.label);if(p.length===0&&c===void 0&&l===void 0&&f===void 0&&!u&&!d)return e;let h={...e};if(f!==void 0&&(h.price=f),c===void 0?u&&(h.stopLossPrice=void 0):h.stopLossPrice=c,l===void 0?d&&(h.takeProfitPrice=void 0):h.takeProfitPrice=l,p.length>0){var g;let t=(g=e.side)==null?`buy`:g;for(let n of p)if(t===`buy`?n.price<e.price:n.price>e.price){var _;h.stopLossPrice=u?void 0:(_=c==null?h.stopLossPrice:c)==null?n.price:_,h._slOrderLabel=n.label}else{var v;h.takeProfitPrice=d?void 0:(v=l==null?h.takeProfitPrice:l)==null?n.price:v,h._tpOrderLabel=n.label}}return h});s.save(),s.scale(o,o),s.save(),s.beginPath(),s.rect(0,0,d,f),s.clip();let g=e=>e.type===`position`&&!!e.entryPriceEditable,_=this.selectedTradeLabel===null?this.tradeDisplayFilter===`none`?[]:this.tradeDisplayFilter===`positions`?h.filter(e=>e.type===`position`&&!g(e)):this.tradeDisplayFilter===`orders`?h.filter(e=>e.type===`pending`||g(e)):h:h.filter(e=>e.label===this.selectedTradeLabel),v=this.levelClusteringEnabled?this.clusterThresholdDistance:0,y=(t=this.orderTimeDragHandler)!=null&&t.active?this.orderTimeDragHandler.dragLabel:null,b=y!==null&&this.hoveredTradeLabel===y?null:this.hoveredTradeLabel,x=y!==null&&this.selectedTradeLabel===y?null:this.selectedTradeLabel,S=rt(s,_,this.scaleManager,p,l,d,f,this.dataStore.getPricePrecision(),b,(n=(r=this.tradeDragHandler)==null?void 0:r.dragLabel)==null?null:n,this.tradeDragNewPrice,x,new Set([...this.pendingLevelDrags.keys(),...this._editOpenLabel===null?[]:[this._editOpenLabel]]),this.positionRenderStyle,this.hideLevelConfirmCancel,this.draftOrderLabel,this.draftBracketPnl,this.expandedClusters,v,this._showQuantityField,this.tradeDragNewSLPrice,this.tradeDragNewTPPrice,this.tradeLevelButtonScale,this.showTradeLevelsAlways,this._orderTimeDragEnabled?e=>this._orderLineAnchorX(e,d):null,this._orderTimeDragEnabled);s.restore();let C=Pt(s,_,p,l,d,f,(i=(a=this.tradeDragHandler)==null?void 0:a.dragLabel)==null?null:i,this.selectedTradeLabel);if(this.offViewportHitAreas=C.hitAreas,St(s,_,this.scaleManager,p,l,d,f,this.dataStore.getPricePrecision()),s.restore(),this.tradeLevelHitAreas=S.hitAreas,this.tradeLevelEditAreas=S.editAreas,this.tradeHoverAreas=S.hoverAreas,this.tradeLevelDragAreas=S.dragAreas,this.tradeLevelConfirmAreas=S.confirmAreas,this.tradeAddBracketAreas=S.addBracketAreas,this.clusterBadgeAreas=S.clusterBadgeAreas,this.lastClusters=S.clusters,this._draftQtyPillArea=S.draftQtyPillArea,this.expandedClusters.size>0){let e=new Set(S.clusters.map(e=>e.id));for(let t of this.expandedClusters)e.has(t)||this.expandedClusters.delete(t)}}_orderLineAnchorX(e,t){var n,r;if(!this._orderTimeDragEnabled)return null;if((n=this.orderTimeDragHandler)!=null&&n.active&&this.orderTimeDragHandler.dragLabel===e.label&&this.tradeDragNewBarIndex!==null)return this.scaleManager.xToPixel(this.tradeDragNewBarIndex,this.viewport,t);let i=(r=this._timeAnchorOverride.get(e.label))==null?e.timestamp:r;return i===void 0?null:this.scaleManager.xToPixel(this.timestampToBarIndex(i),this.viewport,t)}_effectiveEntryPrice(e,t){var n,r;let i=this.pendingLevelDrags.get(e);return(n=i==null||(r=i.find(e=>e.field===`main`))==null?void 0:r.newPrice)==null?t:n}_effectiveBracketPrice(e,t,n){var r;let i=this.pendingLevelDrags.get(e),a=i==null||(r=i.find(e=>e.field===t))==null?void 0:r.newPrice;return a==null?n:a}_resolveBracketPrices(e){let t=e.stopLossPrice,n=e.takeProfitPrice,r,i;if(t===void 0||n===void 0){let o=this.levels.filter(t=>t.type===`pending`&&t.ToClose===e.label);if(o.length>0){var a;let s=(a=e.side)==null?`buy`:a;for(let a of o){let o=s===`buy`?a.price<e.price:a.price>e.price;o&&t===void 0?(t=a.price,r=a.label):!o&&n===void 0&&(n=a.price,i=a.label)}}}return{slPrice:t,tpPrice:n,slSiblingLabel:r,tpSiblingLabel:i}}_finalizeMainDragWithBrackets(e,t){var n;let r=this.levels.find(t=>t.label===e.label),i=e.derivedSLPrice!==void 0&&e.slStartPrice!==void 0&&e.derivedSLPrice!==e.slStartPrice,a=e.derivedTPPrice!==void 0&&e.tpStartPrice!==void 0&&e.derivedTPPrice!==e.tpStartPrice,o=!i&&!a;if(this.storePendingChange(e,e.startPrice,t,!o),!((n=this.pendingLevelDrags.get(e.label))!=null&&n.some(t=>t.field===`main`&&t.newPrice===e.newPrice))){this.tradeDragNewSLPrice=null,this.tradeDragNewTPPrice=null;return}if(i){var s,c,l;let n=!a,i=r,o=r,u=(s=(c=i==null?void 0:i.stopLossData)==null?o==null?void 0:o.stopLossData:c)==null?e.data:s;this.storePendingChange({label:e.label,type:e.type,newPrice:e.derivedSLPrice,data:u,bracketType:`stopLoss`},e.slStartPrice,(l=this._slSiblingOrderLabel)==null?t:l,!n)}if(a){var u,d,f;let n=r,i=r,a=(u=(d=n==null?void 0:n.takeProfitData)==null?i==null?void 0:i.takeProfitData:d)==null?e.data:u;this.storePendingChange({label:e.label,type:e.type,newPrice:e.derivedTPPrice,data:a,bracketType:`takeProfit`},e.tpStartPrice,(f=this._tpSiblingOrderLabel)==null?t:f,!1)}this.tradeDragNewSLPrice=null,this.tradeDragNewTPPrice=null,this._slSiblingOrderLabel=null,this._tpSiblingOrderLabel=null}storePendingChange(e,t,n,r=!1){var i,a,o,s,c;if(e.bracketType){var l,u,d,f,p;let n=this.levels.find(t=>t.label===e.label),r=(l=n==null?void 0:n.side)==null?`buy`:l,i=this._effectiveEntryPrice(e.label,(u=n==null?void 0:n.price)==null?t:u),a=(n==null?void 0:n.entryPriceEditable)===!0,o=(n==null||(d=n.data)==null?void 0:d._isDraft)===!0,s=this.dataStore.all,c=e.type===`position`&&!a&&!o?(f=(p=s[s.length-1])==null?void 0:p.close)==null?0:f:0;if(!Vc.isBracketPriceValid(e.newPrice,e.bracketType,i,r,c)){this.tradeDragNewPrice=null,this.renderTradeLayer();return}}if(!e.bracketType){let t=this.levels.find(t=>t.label===e.label);if(t!=null&&t.orderType&&t!=null&&t.side){var m,h;let n=this.dataStore.all,r=(m=(h=n[n.length-1])==null?void 0:h.close)==null?0:m;if(r>0&&!(t.side===`buy`&&t.orderType===`limit`||t.side===`sell`&&t.orderType===`stop`?e.newPrice<r:e.newPrice>r)){this.tradeDragNewPrice=null,this.renderTradeLayer();return}}}if(e.newPrice===t){this.tradeDragNewPrice=null,this.renderTradeLayer();return}let g=(i=e.bracketType)==null?`main`:i,_=this._isBracketNew;this._isBracketNew=!1;let v=this.levels.find(t=>t.label===e.label);if((v==null?void 0:v.orderType)===`market`&&(v==null||(a=v.data)==null?void 0:a._isDraft)===!0){g!==`main`&&(this.updateDraftOrderBracket(g===`stopLoss`?`sl`:`tp`,e.newPrice),this.emitter.emit(`tradeLevelDrag`,{label:e.label,newPrice:e.newPrice,data:v==null?void 0:v.data,bracketType:g,isFullscreen:this.isFullscreen})),this.tradeDragNewPrice=null,this.renderTradeLayer();return}if(v!==void 0&&g!==`main`&&(v==null||(o=v.data)==null?void 0:o._isDraft)===!0){this.updateDraftOrderBracket(g===`stopLoss`?`sl`:`tp`,e.newPrice),this.emitter.emit(`tradeLevelDrag`,{label:e.label,newPrice:e.newPrice,data:v==null?void 0:v.data,bracketType:g,isFullscreen:this.isFullscreen}),this.tradeDragNewPrice=null,this.renderTradeLayer();return}if(v!==void 0&&g===`main`&&(v==null||(s=v.data)==null?void 0:s._isDraft)===!0&&v.orderType!==`market`&&this.hideLevelConfirmCancel){this.updateDraftOrderPrice(e.newPrice),this.emitter.emit(`tradeLevelDrag`,{label:e.label,newPrice:e.newPrice,data:v==null?void 0:v.data,bracketType:void 0,isFullscreen:this.isFullscreen}),this.tradeDragNewPrice=null,this.renderTradeLayer();return}let y=((c=this.pendingLevelDrags.get(e.label))==null?[]:c).filter(e=>e.field!==g);if(y.push({field:g,newPrice:e.newPrice,oldPrice:t,isNew:_,bracketOrderLabel:n}),this.pendingLevelDrags.set(e.label,y),this.tradeDragNewPrice=null,this.hideLevelConfirmCancel&&!r){this.applyPendingChanges(e.label);return}this.renderTradeLayer()}_orderTypeForPrice(e,t){let n=this.dataStore.all,r=n.length>0?n[n.length-1].close:t;return e===`buy`?t<r?`limit`:`stop`:t>r?`limit`:`stop`}createDraftOrder(e,t,n){if(this.draftOrderLabel)return;let r=`__draft_${Date.now()}`,i={type:`pending`,label:r,side:e,price:t,orderType:n,lots:this._qtyFieldMin,data:{_isDraft:!0}};this.levels=[...this.levels,i],this.draftOrderLabel=r,this.selectedTradeLabel=r,this.pendingLevelDrags.set(r,[{field:`main`,newPrice:t,oldPrice:t}]),this.crosshair=null,this.renderTradeLayer(),this.emitter.emit(`draftInitiated`,{side:e,price:t,orderType:n,isFullscreen:this.isFullscreen})}removeDraftOrder(){var e;if(!this.draftOrderLabel)return;let t=this.draftOrderLabel;this.levels=this.levels.filter(e=>e.label!==t),this.pendingLevelDrags.delete(t),this.selectedTradeLabel=null,this.draftOrderLabel=null,this.draftBracketPnl={},(e=this._draftQtyFlyout)==null||e.hide(),this._draftQtyPillArea=void 0,this.renderTradeLayer(),this.emitter.emit(`draftCancelled`,{label:t,isFullscreen:this.isFullscreen})}applyPendingChanges(e){let t=this.pendingLevelDrags.get(e);if(!t){if(this._editOpenLabel===e){let t=this.levels.find(t=>t.label===e);this._editOpenLabel=null,this.selectedTradeLabel=null,this.renderTradeLayer(),t&&this.emitter.emit(`tradeLevelConfirmed`,{label:e,type:t.type,isFullscreen:this.isFullscreen})}return}let n=this.levels.find(t=>t.label===e);if(!n)return;if(this._editOpenLabel===e&&(this._editOpenLabel=null),e===this.draftOrderLabel){var r,i,a;let o=t.find(e=>e.field===`main`),s=n;(r=this._onOrderSubmit)==null||r.call(this,{price:(i=o==null?void 0:o.newPrice)==null?s.price:i,lots:(a=s.lots)==null?this._qtyFieldMin:a,side:s.side,orderType:s.orderType,...s.stopLossPrice===void 0?{}:{stopLoss:s.stopLossPrice},...s.takeProfitPrice===void 0?{}:{takeProfit:s.takeProfitPrice}}),this.emitter.emit(`tradeLevelConfirmed`,{label:e,type:`draft`,isFullscreen:this.isFullscreen}),this.removeDraftOrder();return}let o=this.pendingQtyChanges.get(e);this.pendingQtyChanges.delete(e),this.originalQtyByLabel.delete(e);let s=o!==void 0&&n.data&&typeof n.data==`object`?{...n.data,lots:o}:n.data;this.emitter.emit(`tradeLevelEdit`,{label:e,type:n.type,data:s,isFullscreen:this.isFullscreen,...o===void 0?{}:{newLots:o},changes:t.map(e=>{let t=n.data,r=s;if(e.field===`stopLoss`){var i;r=(i=t.stopLossData)==null?n.data:i}else if(e.field===`takeProfit`){var a;r=(a=t.takeProfitData)==null?n.data:a}if(e.bracketOrderLabel){let t=this.levels.find(t=>t.label===e.bracketOrderLabel);t&&(r=t.data)}let c;return c=e.field===`main`?`MAIN`:e.field===`stopLoss`?e.isRemoval?`REMOVE_SL`:e.isNew?`ADD_SL`:`SL`:e.isRemoval?`REMOVE_TP`:e.isNew?`ADD_TP`:`TP`,{field:c,newPrice:e.newPrice,data:r,...c===`MAIN`&&o!==void 0?{newLots:o}:{},bracketOrderLabel:e.bracketOrderLabel}})}),this.emitter.emit(`tradeLevelConfirmed`,{label:e,type:n.type,isFullscreen:this.isFullscreen}),this.hideLevelConfirmCancel||(this.pendingLevelDrags.delete(e),this.selectedTradeLabel=null,this.draftBracketPnl={}),this.renderTradeLayer()}revertPendingChanges(e){var t;if(e&&e===this.draftOrderLabel){this.removeDraftOrder();return}if(!e&&this.draftOrderLabel&&this.removeDraftOrder(),e&&!this.pendingLevelDrags.has(e)&&this._editOpenLabel===e){this._cancelEditAndDeselect(e);return}let n=e?this.pendingLevelDrags.has(e)?[[e,(t=this.pendingLevelDrags.get(e))==null?[]:t]]:[]:[...this.pendingLevelDrags.entries()];for(let[e]of n){if(this.undoIsNewBracketMutations(e),this.pendingLevelDrags.delete(e),this.pendingQtyChanges.has(e)){this.pendingQtyChanges.delete(e);let t=this.levels.findIndex(t=>t.label===e);if(t!==-1&&this.originalQtyByLabel.has(e)){let n=this.originalQtyByLabel.get(e),r=this.levels[t];this.levels=[...this.levels.slice(0,t),{...r,lots:n},...this.levels.slice(t+1)]}this.originalQtyByLabel.delete(e)}let t=this.levels.find(t=>t.label===e);t&&(this._editOpenLabel===e&&(this._editOpenLabel=null),this.emitter.emit(`tradeLevelEditCancelled`,{label:e,type:t.type,isFullscreen:this.isFullscreen}))}this.selectedTradeLabel=null,this.draftBracketPnl={},this.renderTradeLayer()}undoIsNewBracketMutations(e){let t=this.pendingLevelDrags.get(e);if(!t)return;let n=t.some(e=>e.field===`stopLoss`&&e.isNew),r=t.some(e=>e.field===`takeProfit`&&e.isNew);!n&&!r||(this.levels=this.levels.map(t=>{if(t.label!==e)return t;let i={...t};return n&&(i.stopLossPrice=void 0),r&&(i.takeProfitPrice=void 0),i}))}initCompareUi(){if(!this.compareManager)return;this.siEl&&(this.compareLegend=new kc({theme:this.theme,onRemove:e=>this.removeCompare(e)}),this.siEl.appendChild(this.compareLegend.el));let e=()=>this.refreshCompareLegend();this.emitter.on(`compareAdded`,e),this.emitter.on(`compareRemoved`,e),this.emitter.on(`compareError`,e),this.emitter.on(`crosshair`,e=>{var t,n;this.compareHoveredIndex=(t=e==null?void 0:e.barIndex)==null?null:t,(n=this.compareManager)!=null&&n.isActive()&&(this.refreshCompareLegend(),this.scheduleRender())})}openComparePicker(){var e,t;if(!this.compareDataLoader)return;this.comparePickerModal||(this.comparePickerModal=new Oc(this.theme,e=>this.toggleCompare(e),()=>this.emitUiState()),this.comparePickerModal.setTitle(`Compare`),this.comparePickerModal.setMode(`toggle`),this.getFloatingRoot().appendChild(this.comparePickerModal.el)),this.refreshComparePickerState();let n=(e=(t=this.siSymbolSpan)==null?void 0:t.textContent)==null?``:e;this.comparePickerModal.show(this.isins,n)}toggleCompare(e){this.compareManager&&(this.compareManager.has(e)?this.removeCompare(e):this.addCompare(e),this.refreshComparePickerState())}refreshComparePickerState(){!this.comparePickerModal||!this.compareManager||this.comparePickerModal.setActiveSymbols(this.compareManager.list().map(e=>e.symbol))}async addCompare(e){this.compareManager&&(await this.compareManager.add(e),this.refreshCompareLegend(),this.scheduleRender(),this.emitStateChange())}removeCompare(e){this.compareManager&&(this.compareManager.remove(e),this.refreshCompareLegend(),this.scheduleRender(),this.emitStateChange())}clearCompares(){this.compareManager&&(this.compareManager.clear(),this.refreshCompareLegend(),this.scheduleRender(),this.emitStateChange())}getCompares(){return this.compareManager?this.compareManager.list().map(e=>({symbol:e.symbol,color:e.color,status:e.status})):[]}refreshCompareLegend(){var e,t;if(!this.compareLegend||!this.compareManager)return;let n=this.compareManager.list(),r=this.dataStore.all,i=this.compareBaselineIndex(r),a=i==null||(e=(t=r[i])==null?void 0:t.close)==null?null:e,o=this.compareHoveredIndex,s=r.length-1,c=n.map(e=>{let t=null;if(e.status===`ready`&&a!=null&&e.bars.length>0){let n=zc(e.bars,r.map(e=>e.time),i==null?0:i),a=r[o==null?s:o];if(a){let e=n.find(e=>e.time===a.time);if(e&&e.pct!=null)t=e.pct;else{let e=n[n.length-1];(e==null?void 0:e.pct)!=null&&(t=e.pct)}}}return{symbol:e.symbol,color:e.color,percent:t,status:e.status,errorMessage:e.errorMessage}});this.compareLegend.update(c)}compareBaselineIndex(e){return e.length===0?null:Math.max(0,Math.min(e.length-1,Math.floor(this.viewport.startIndex)))}updateCompareRange(){if(!this.compareManager)return;let e=this.dataStore.all;if(e.length===0)return;let t={start:new Date(e[0].time),end:new Date(e[e.length-1].time),interval:this.timeframe};this.compareManager.isActive()?this.compareManager.refetchAll(t).then(()=>{this.refreshCompareLegend(),this.scheduleRender()}):this.compareManager.setLastParams(t)}render(){var e,t,n;if(this._isDestroyed)return;let{ctx:r,canvas:i,theme:a,viewport:o}=this,s=window.devicePixelRatio||1,c=i.width,l=i.height,u=c/s-this.priceAxisWidth,d=this.activeIndicators.filter(e=>e.indicator.pane===`sub`),f=d.reduce((e,t)=>e+this.paneH(t)+Wl,0),p=l/s-this.timeAxisHeight-f;r.clearRect(0,0,c,l),r.fillStyle=a.background,r.fillRect(0,0,c,l);let m=this.dataStore.getVisible(o);if(m.length===0){this.drawCtx.clearRect(0,0,this.drawCanvas.width,this.drawCanvas.height);return}let h=m;if(this._isPanning)this.viewport={...this._targetViewport};else{let e=this._targetViewport.startIndex-this.viewport.startIndex,t=this._targetViewport.endIndex-this.viewport.endIndex,n=(this._targetViewport.endIndex-this._targetViewport.startIndex)*2e-4;Math.abs(e)<n&&Math.abs(t)<n?this.viewport={...this._targetViewport}:(this.viewport={...this.viewport,startIndex:this.viewport.startIndex+e*Jl,endIndex:this.viewport.endIndex+t*Jl,candleWidth:this._targetViewport.candleWidth,candleGap:this._targetViewport.candleGap},this.scheduleRender())}let g=!!((e=this.compareManager)!=null&&e.isActive()),_=null,v=[],y=[],b=null;if(g&&this.compareManager){var x,S;let e=this.dataStore.all,t=this.compareBaselineIndex(e),n=t==null||(x=(S=e[t])==null?void 0:S.close)==null?null:x;if(n!=null&&n!==0&&Number.isFinite(n)){_=n;let r=this.compareManager.list(),i=e.map(e=>e.time);v=r.map(e=>e.status===`ready`&&e.bars.length>0?zc(e.bars,i,t==null?0:t):[]),y=r.map(e=>e.color),h=Ic(m,n),b=Rc(m,n,v.map(e=>e.filter(e=>e.pct!=null)))}}let C=g&&b!==null;if(C!==this._lastInCompareMode&&(this._lastInCompareMode=C,this._displayedPriceRange=null,this._lockedAutoFitBase=null,this.pricePanOffset=0,this.priceScaleFactor=1),this.priceScaleFactor!==1||this.pricePanOffset!==0){if(!this._lockedAutoFitBase){var w,T;this._lockedAutoFitBase=(w=(T=this._displayedPriceRange)==null?b:T)==null?this.dataStore.getPriceRange(o):w}let e=this._lockedAutoFitBase,t=(e.min+e.max)/2+this.pricePanOffset,n=e.max===e.min?1:(e.max-e.min)/2;this._displayedPriceRange={min:t-n*this.priceScaleFactor,max:t+n*this.priceScaleFactor}}else{var E;this._lockedAutoFitBase=null;let e=(E=b)==null?this.getScaledPriceRange(o):E;if(!this._displayedPriceRange)this._displayedPriceRange=e;else{let t=(e.max-e.min)*1e-4,n=e.min-this._displayedPriceRange.min,r=e.max-this._displayedPriceRange.max;Math.abs(n)<t&&Math.abs(r)<t?this._displayedPriceRange=e:(this._displayedPriceRange={min:this._displayedPriceRange.min+n*ql,max:this._displayedPriceRange.max+r*ql},this.scheduleRender())}}let D=this._displayedPriceRange,O=this.showVolume?this.dataStore.getVolumeRange(o):null,k=i;switch(k._priceRange=D,k._chartWidth=u,r.save(),r.scale(s,s),r.save(),r.beginPath(),r.rect(0,0,u,p),r.clip(),me(r,D,this.scaleManager,a,u,p),this.series){case`candlestick`:te(r,h,o,D,this.scaleManager,a,u,p);break;case`hollow`:ne(r,h,o,D,this.scaleManager,a,u,p);break;case`line`:P(r,h,o,D,this.scaleManager,a,u,p,!1);break;case`area`:P(r,h,o,D,this.scaleManager,a,u,p,!0);break;case`ohlc`:re(r,h,o,D,this.scaleManager,a,u,p);break;case`heikinashi`:oe(r,h,o,D,this.scaleManager,a,u,p);break;case`volumecandles`:se(r,h,o,D,this.scaleManager,a,u,p);break;case`linemarkers`:ce(r,h,o,D,this.scaleManager,a,u,p);break;case`step`:le(r,h,o,D,this.scaleManager,a,u,p);break;case`hlcarea`:de(r,h,o,D,this.scaleManager,a,u,p);break;case`baseline`:I(r,h,o,D,this.scaleManager,a,u,p);break;case`columns`:fe(r,h,o,D,this.scaleManager,a,u,p);break;case`highlow`:pe(r,h,o,D,this.scaleManager,a,u,p);break}r.save(),r.beginPath(),r.rect(0,0,u,p),r.clip();for(let e of this.visibleStates()){let t=e.indicator;if(t.pane&&t.pane!==`main`)continue;let n=this.indicatorResults.get(e.instanceId);if(!n)continue;let i=n.slice(Math.floor(o.startIndex),Math.ceil(o.endIndex)+1),a=g&&_!=null?Lc(i,_):i;t.render(r,a,this.scaleManager,o,p)}if(g&&_!=null&&v.length>0){let e=this.dataStore.all,t=Math.floor(o.startIndex),n=Math.min(e.length-1,Math.ceil(o.endIndex)),i=new Map;for(let r=t;r<=n;r++)i.set(e[r].time,r);for(let e=0;e<v.length;e++){let t=v[e],n=y[e];if(!t||t.length===0)continue;r.save(),r.strokeStyle=n,r.lineWidth=1.5,r.lineJoin=`round`,r.lineCap=`round`,r.beginPath();let a=!1;for(let e of t){let t=i.get(e.time);if(t==null||e.pct==null){a=!1;continue}let n=this.scaleManager.xToPixel(t,o,u),s=this.scaleManager.yToPixel(e.pct,D,p);a?r.lineTo(n,s):(r.moveTo(n,s),a=!0)}r.stroke(),r.restore()}}r.restore(),r.restore(),qt(r,D,this.scaleManager,a,u,p,this.priceAxisWidth,void 0,this.dataStore.getPricePrecision(),this.uiConfig.priceAxis,g?`percent`:`price`);let A=this.dataStore.all[this.dataStore.all.length-1];if(A&&!g){let e=this.dataStore.getPricePrecision(),t=(t,n,i)=>{let a=this.scaleManager.yToPixel(t,D,p);r.save(),r.strokeStyle=n,r.lineWidth=1,r.setLineDash([3,3]),r.beginPath(),r.moveTo(0,a),r.lineTo(u,a),r.stroke(),r.setLineDash([]);let o=i+t.toFixed(e);r.font=`10px 'Inter', system-ui, sans-serif`;let s=r.measureText(o).width+12;return r.fillStyle=n,r.fillRect(u,a-16/2,s,16),r.fillStyle=`#ffffff`,r.textAlign=`left`,r.fillText(o,u+4,a+4),r.restore(),{y:a,boxW:s}},n=null,i=0;if(this.liveBidAsk){var ee,j,M,N,ae,ue,F;let{bid:e,ask:r}=this.liveBidAsk,o=this.tickClosePriceSource===`ltp`,s=((ee=this.showLtpPrice)==null?o:ee)?(j=this.liveLtp)==null?o?e:null:j:null,c=A.close>=A.open?a.candle.up:a.candle.down,l=(M=this.showAskLine)==null?this.showBidAskLines||this.tickClosePriceSource===`ask`:M,u=((N=this.showBidLine)==null?this.showBidAskLines||this.tickClosePriceSource===`bid`||o&&s==null:N)?t(e,a.candle.down,``):null,d=l?t(r,a.candle.up,``):null,f=s==null?null:t(s,c,``),p=o?(ae=f==null?u:f)==null?d:ae:this.tickClosePriceSource===`ask`?(ue=d==null?f:d)==null?u:ue:(F=u==null?f:u)==null?d:F;p&&(n=p.y,i=p.boxW)}else{let e=A.close>=A.open,r=t(A.close,e?a.candle.up:a.candle.down,``);n=r.y,i=r.boxW}if(this.showPriceAxisCountdown&&n!==null){var he;if(this.candleCountdownTimeframes===`all`||((he=this.candleCountdownTimeframes)==null?[`1m`,`5m`,`15m`,`30m`,`1h`,`2h`,`4h`,`8h`]:he).includes(this.timeframe)){let e=this.timeframeToMs(this.timeframe);Kt(r,A.time,e,a,u,n-16/2,16,i)}}}let ge=p;for(let e of d){let t=e.indicator,n=this.paneH(e);if(r.fillStyle=a.axisBorder,r.fillRect(0,ge,u+this.priceAxisWidth,Wl),ge+=Wl,r.save(),r.beginPath(),r.rect(0,ge,u+this.priceAxisWidth,n),r.clip(),r.translate(0,ge),r.fillStyle=a.background,r.fillRect(0,0,u+this.priceAxisWidth,n),e.visible&&(()=>{let t=e.currentParams.timeframe;return!t||t===`Chart`||t===this.timeframe})()){let i=this.indicatorResults.get(e.instanceId);if(i){var ve,ye;let s=i.slice(Math.floor(o.startIndex),Math.ceil(o.endIndex)+1),c=(ve=t.getValueRange)==null?void 0:ve.call(t,s),l=(ye=this.subPaneScaleFactors.get(e.instanceId))==null?1:ye,d=c?eu(c,l):void 0;t.render(r,s,this.scaleManager,o,n,d),d&&qt(r,d,this.scaleManager,a,u,n,this.priceAxisWidth,3,tu(d),this.uiConfig.priceAxis)}}r.restore(),ge+=n}if(this.showVolume&&O&&O.max>0){let e=p*Hl;ie(r,h,o,O.max,this.scaleManager,a,u,e,p-e)}{var be;let e=this.candleCountdownTimeframes===`all`?!0:((be=this.candleCountdownTimeframes)==null?[`1m`,`5m`,`15m`,`30m`,`1h`,`2h`,`4h`,`8h`]:be).includes(this.timeframe),t=this.showCandleCountdown&&!this.showPriceAxisCountdown&&e&&h.length>0&&o.endIndex>=this.dataStore.length-1,n=t?this.dataStore.length-1:void 0;if(this._debug&&console.log(`[countdown] showCandleCountdown:`,this.showCandleCountdown,`| tf:`,this.timeframe,`| allowed:`,e,`| bars:`,h.length,`| endIndex:`,o.endIndex,`| dataLen:`,this.dataStore.length,`| atLiveEdge:`,o.endIndex>=this.dataStore.length-1),Wt(r,h,o,this.scaleManager,a,u,ge,Zl()?3:void 0,this.uiConfig.timeAxis,this.timeframe,n,this.timezone),t){let e=this.dataStore.all[this.dataStore.length-1];if(e){let t=this.timeframeToMs(this.timeframe);Gt(r,e.time,t,this.dataStore.length-1,o,this.scaleManager,a,u,ge,this.uiConfig.timeAxis)}}}if(this.crosshair&&_e(r,this.crosshair,D,o,this.scaleManager,a,u,p,this.priceAxisWidth,ge,this.timeframe,this.dataStore.getPricePrecision(),this.uiConfig.crosshair,this.timezone),this.logoImage){let e=p-20-40/2;r.save(),r.globalAlpha=.6,r.beginPath(),r.rect(0,0,u,p),r.clip(),r.beginPath(),r.arc(40,e,40/2,0,Math.PI*2),r.closePath(),r.clip(),r.drawImage(this.logoImage,40-40/2,e-40/2,40,40),r.restore()}r.restore();let xe=this.crosshair?(t=this.dataStore.all[this.crosshair.barIndex])==null?null:t:(n=this.dataStore.all[this.dataStore.length-1])==null?null:n;if(this.renderSymbolInfoOHLC(xe),this.drawingManager.render(this.drawCtx,this.scaleManager,o,D,u,p,this.dataStore.getPricePrecision(),this.theme),this.drawingStylePopover){let e=this.drawingManager.getSelectedDrawing();if(e&&e.complete&&e.locked!==!0){let t=this.computeDrawingAnchorPx(e);t&&this.drawingStylePopover.setAnchor(t.x,t.y)}}if(this.scrollToEndBtn){let e=this.dataStore.length===0||this._targetViewport.endIndex>=this.dataStore.length-.5;e!==!this.scrollToEndVisible&&(this.scrollToEndVisible=!e,this.scrollToEndBtn.style.opacity=e?`0`:`0.85`,this.scrollToEndBtn.style.pointerEvents=e?`none`:`auto`)}if(this.resetViewBtn){let e=this.dataStore.length,t=this._defaultVisibleBars,n=e===0||this._targetViewport.endIndex>=e-.5,r=this._targetViewport.endIndex-this._targetViewport.startIndex,i=Math.abs(r-t)<.5,a=this.priceScaleFactor===1&&this.pricePanOffset===0&&this._lockedAutoFitBase===null,o=e===0||n&&i&&a;o===this.resetViewVisible&&(this.resetViewVisible=!o,this.resetViewBtn.style.opacity=o?`0`:`0.75`,this.resetViewBtn.style.pointerEvents=o?`none`:`auto`)}this.updateSubPaneOverlayPositions()}recomputeIndicators(){for(let e of this.visibleStates())this.indicatorResults.set(e.instanceId,e.indicator.compute(this.dataStore.all))}onResize(){if(this._isDestroyed)return;let e=window.devicePixelRatio||1,t=this.canvasWrap.getBoundingClientRect();if(t.width===0||t.height===0)return;this._cachedWrapRect=t,this._cachedDrawRect=this.drawCanvas.getBoundingClientRect();for(let n of[this.canvas,this.tradeCanvas,this.drawCanvas])n.width=t.width*e,n.height=t.height*e;let n=this.wrapper.offsetWidth,r=n>0&&n<this.uiConfig.drawingToolbar.mobileBreakpoint;if(r!==this._mobileLayout){var i,a,o,s;if(this._mobileLayout=r,(i=this.leftBar)==null||i.setMobileMode(r),(a=this._tb)==null||a.setMobileLayout(r),(o=this.tradeButton)==null||o.setMobileMode(r),(s=this.tradePopover)==null||s.setCompact(r),this.siEl&&(this.siEl.style.flexDirection=r?`column`:`row`,this.siEl.style.alignItems=r?`flex-start`:`center`,this.siEl.style.gap=r?`2px`:`8px`),r){var c;this.leftBarVisible=!1,(c=this._tb)==null||c.setDrawingsBtnActive(!1)}else{var l,u;this.leftBarVisible=!0,(l=this.leftBar)==null||l.setVisible(!0),(u=this._tb)==null||u.setDrawingsBtnActive(!0)}}this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null),this.render(),this.renderTradeLayer()}paneH(e){var t,n;return(t=(n=this.paneHeightOverrides.get(e.instanceId))==null?e.indicator.paneHeight:n)==null?Ul:t}getChartLayout(){var e;let t=this.activeIndicators.filter(e=>e.indicator.pane===`sub`).reduce((e,t)=>e+this.paneH(t)+Wl,0),n=(e=this._cachedWrapRect)==null?this.canvasWrap.getBoundingClientRect():e;return{chartW:n.width-this.priceAxisWidth,priceH:n.height-this.timeAxisHeight-t}}computeDrawingAnchorPx(e){var t;if(e.points.length===0)return null;let{chartW:n,priceH:r}=this.getChartLayout(),i=this._targetViewport,a=(t=this._displayedPriceRange)==null?this.getScaledPriceRange(i):t,o=0,s=1/0;for(let t of e.points){let e=this.scaleManager.xToPixel(t.barIndex,i,n),c=this.scaleManager.yToPixel(t.price,a,r);c<s&&(s=c,o=e)}return Number.isFinite(s)?(o=Math.max(0,Math.min(n,o)),s=Math.max(0,Math.min(r,s)),{x:o,y:s}):null}updateSubPaneOverlayPositions(){if(this.subPaneOverlays.size===0)return;let e=this.getSeparatorPositions();for(let t of e){let e=this.subPaneOverlays.get(t.instanceId);e&&(e.el.style.top=`${t.y+Wl+6}px`)}}getSeparatorPositions(){let{priceH:e}=this.getChartLayout(),t=this.activeIndicators.filter(e=>e.indicator.pane===`sub`),n=[],r=e;for(let e of t)n.push({y:r,instanceId:e.instanceId}),r+=this.paneH(e)+Wl;return n}getScaledPriceRange(e){let t=this.dataStore.getPriceRange(e),n=t.min,r=t.max;for(let t of this.visibleStates()){if(t.indicator.pane&&t.indicator.pane!==`main`)continue;let a=this.indicatorResults.get(t.instanceId);if(!a)continue;let o=Math.floor(e.startIndex),s=Math.ceil(e.endIndex)+1;for(let e=o;e<s&&e<a.length;e++){var i;let t=(i=a[e])==null?void 0:i.value;if(t==null)continue;let o=Array.isArray(t)?t.filter(e=>e!==null):[t];for(let e of o)isFinite(e)&&(e<n&&(n=e),e>r&&(r=e))}}let a=(n+r)/2+this.pricePanOffset,o=n===r?1:(r-n)/2;return{min:a-o*this.priceScaleFactor,max:a+o*this.priceScaleFactor}}touchToDrawingPoint(e){var t,n;let r=(t=this._cachedDrawRect)==null?this.drawCanvas.getBoundingClientRect():t,i=e.clientX-r.left,a=e.clientY-r.top,{chartW:o,priceH:s}=this.getChartLayout(),c=(n=this._displayedPriceRange)==null?this.getScaledPriceRange(this.viewport):n;return this.makeDrawingPoint(this.scaleManager.pixelToBarIndex(i,this.viewport,o),this.scaleManager.pixelToPrice(a,c,s))}makeDrawingPoint(e,t){let n={barIndex:e,price:t},r=this.barIndexToTimestamp(e);return r!=null&&(n.timestamp=r),n}_handleTradeLevelClose(e){if(e.bracketType){var t,n;let r=this.levels.find(t=>t.label===e.label);if((r==null||(t=r.data)==null?void 0:t._isDraft)===!0&&r){let t=e.bracketType===`stopLoss`?`sl`:`tp`;this.updateDraftOrderBracket(t,null),this.emitter.emit(`tradeLevelEdit`,{label:e.label,type:`pending`,data:r.data,isFullscreen:this.isFullscreen,changes:[{field:e.bracketType===`stopLoss`?`REMOVE_SL`:`REMOVE_TP`,newPrice:0,data:r.data,bracketOrderLabel:void 0}]});return}let i=e.bracketType,a=((n=this.pendingLevelDrags.get(e.label))==null?[]:n).filter(e=>e.field!==i);a.push({field:i,newPrice:0,oldPrice:0,isRemoval:!0,bracketOrderLabel:e.bracketOrderLabel}),this.pendingLevelDrags.set(e.label,a),this.selectedTradeLabel=e.label,this.renderTradeLayer();return}let r=e.label===this.draftOrderLabel,i=this.pendingLevelDrags.get(e.label),a=this._editOpenLabel===e.label,o=!!i&&i.length>0&&i.every(e=>e.isNew),s=!i||i.length===0,c=!r&&a&&(o||s);if(this.revertPendingChanges(e.label),this.pendingLevelDrags.delete(e.label),r)return;if(c){if(s){let t=this.levels.find(t=>t.label===e.label);this._editOpenLabel=null,this.selectedTradeLabel=null,this.renderTradeLayer(),t&&this.emitter.emit(`tradeLevelEditCancelled`,{label:e.label,type:t.type,isFullscreen:this.isFullscreen})}return}this._editOpenLabel===e.label&&(this._editOpenLabel=null);let l=this.levels.find(t=>t.label===e.label),u=(l==null?void 0:l.type)===`position`&&!!l.entryPriceEditable,d=e.type===`position`&&!u?`CLOSED`:`CANCELLED`;this.emitter.emit(`tradeLevelClose`,{label:e.label,type:e.type,action:d,data:e.data,isFullscreen:this.isFullscreen})}_activateMobileCrosshair(e,t){var n,r,i;let a=(n=this._cachedDrawRect)==null?this.drawCanvas.getBoundingClientRect():n,{chartW:o,priceH:s}=this.getChartLayout(),c=(r=this._displayedPriceRange)==null?this.getScaledPriceRange(this.viewport):r,l=a.height-this.timeAxisHeight;if(e>=o||t>=l)return;this._mobileCrosshairActive=!0;let u=this.scaleManager.pixelToBarIndex(e,this.viewport,o),d=this.scaleManager.pixelToPrice(t,c,s),f=Math.max(Math.floor(this.viewport.startIndex),Math.min(Math.ceil(this.viewport.endIndex),Math.round(u))),p=(i=this.dataStore.all[f])==null?null:i;this.crosshair=this.selectedTradeLabel===null?{x:e,y:t,barIndex:f,price:d,bar:p}:null,this.tradeButton&&(this.tradeButton.setY(t),this._isTradingActive||It(t,this.uiConfig.tradeButton.size/2,this.offViewportHitAreas)?this.tradeButton.hide():this.tfcActive&&this.tradeButton.show(),this._tradeButtonClickData={price:d,y:t}),this.scheduleRender()}_cancelEditAndDeselect(e){let t=this._editOpenLabel===e,n=this.levels.find(t=>t.label===e);this._editOpenLabel=null,this.selectedTradeLabel=null,this.draftBracketPnl={},this.renderTradeLayer(),t&&n&&this.emitter.emit(`tradeLevelEditCancelled`,{label:e,type:n.type,isFullscreen:this.isFullscreen})}_openTradeLevelEditForm(e){if(this._editOpenLabel===e.label)return;this.selectedTradeLabel=e.label,this._editOpenLabel=e.label;let{slPrice:t,tpPrice:n}=this._resolveBracketPrices(e);this.renderTradeLayer(),this.emitter.emit(`tradeLevelEditOpen`,{label:e.label,type:e.type,data:e.data,price:e.price,side:e.side,stopLossPrice:t,takeProfitPrice:n,isFullscreen:this.isFullscreen})}_startTradeDragFromHit(e,t,n,r){var i;if(!this.tradeDragHandler)return;if(this._orderTimeDragEnabled&&this.orderTimeDragHandler&&!e.isBracket&&e.timeDrag===!0){var a,o,s,c;let{chartW:n}=this.getChartLayout(),i=e,l=(a=this._orderLineAnchorX(t,n))==null?n/2:a,u=Math.max(i.x,Math.min(i.x+i.w,l)),d=this.scaleManager.pixelToBarIndex(u,this.viewport,n),f=(o=(s=(c=this._timeAnchorOverride.get(t.label))==null?t.timestamp:c)==null?this.barIndexToTimestamp(d):s)==null?0:o;this.orderTimeDragHandler.start(t,r==null?u:r,u,d,f),this.drawCanvas.style.cursor=`grabbing`,this.emitter.emit(`orderLineMoveStart`,{label:t.label,fromTimestamp:f,fromBarIndex:this.orderTimeDragHandler.startBarIndex,isFullscreen:this.isFullscreen}),this.renderTradeLayer();return}let{priceH:l}=this.getChartLayout(),u=(i=this._displayedPriceRange)==null?this.getScaledPriceRange(this.viewport):i,d=this.scaleManager.yToPixel(e.price,u,l);if(e.isBracket){var f,p,m,h;this._pendingBracketOrderLabel=(f=e.bracketOrderLabel)==null?null:f,this._isBracketNew=!1;let r=t.entryPriceEditable===!0,i=((p=t.data)==null?void 0:p._isDraft)===!0,a=this.dataStore.all,o=t.type===`position`&&!r&&!i?(m=(h=a[a.length-1])==null?void 0:h.close)==null?0:m:0;this.tradeDragHandler.startBracketDrag(t,e.bracketType,e.price,n,d,o,this._effectiveEntryPrice(t.label,t.price)),this.emitter.emit(`tradeLevelDragStart`,{label:t.label,bracketType:e.bracketType,isFullscreen:this.isFullscreen})}else if(this._pendingBracketOrderLabel=null,t.entryPriceEditable===!0){var g,_;this.selectedTradeLabel=e.label;let r=t,i=this.dataStore.all,a=(g=(_=i[i.length-1])==null?void 0:_.close)==null?0:g,o=this._effectiveBracketPrice(t.label,`stopLoss`,r.stopLossPrice),s=this._effectiveBracketPrice(t.label,`takeProfit`,r.takeProfitPrice);this.tradeDragHandler.startDrag(t,n,d,e.price,o,s,r.side,a,r.orderType,!0)}else{var v,y;let r=t,i=this.dataStore.all,a=(v=(y=i[i.length-1])==null?void 0:y.close)==null?0:v,{slPrice:o,tpPrice:s,slSiblingLabel:c,tpSiblingLabel:l}=this._resolveBracketPrices(t);this._slSiblingOrderLabel=c==null?null:c,this._tpSiblingOrderLabel=l==null?null:l;let u=this._effectiveBracketPrice(t.label,`stopLoss`,o),f=this._effectiveBracketPrice(t.label,`takeProfit`,s);this.tradeDragHandler.startDrag(t,n,d,e.price,u,f,r.side,a,r.orderType,!0)}e.isBracket&&(this._editOpenLabel=null),this._openTradeLevelEditForm(t)}_endOrderTimeDrag(){var e;if(!((e=this.orderTimeDragHandler)!=null&&e.active))return!1;let t=this.orderTimeDragHandler.end(this._orderLineDragSnap,this.viewport);if(this.tradeDragNewBarIndex=null,this.drawCanvas.style.cursor=`default`,t){let e=this.barIndexToTimestamp(t.newBarIndex),n=Math.round(t.startBarIndex);e!==void 0&&t.newBarIndex!==n&&(this._timeAnchorOverride.set(t.label,e),this.emitter.emit(`orderLineMoved`,{label:t.label,fromTimestamp:t.startTimestamp,toTimestamp:e,fromBarIndex:n,toBarIndex:t.newBarIndex,data:t.data,isFullscreen:this.isFullscreen}))}return this.renderTradeLayer(),!0}_startAddBracketFromHit(e,t){var n,r,i;let a=this.levels.find(t=>t.label===e.label);if(!a||!this.tradeDragHandler)return;let{priceH:o}=this.getChartLayout(),s=this.getScaledPriceRange(this.viewport),c=e.y+e.h/2,l=this.scaleManager.pixelToPrice(c,s,o),u=a.entryPriceEditable===!0,d=((n=a.data)==null?void 0:n._isDraft)===!0,f=this.dataStore.all,p=a.type===`position`&&!u&&!d?(r=(i=f[f.length-1])==null?void 0:i.close)==null?0:r:0;this._pendingBracketOrderLabel=null,this._isBracketNew=!0,this.tradeDragHandler.startBracketDrag(a,e.bracketType,l,t,c,p,this._effectiveEntryPrice(a.label,a.price)),this.emitter.emit(`tradeLevelDragStart`,{label:a.label,bracketType:e.bracketType,isFullscreen:this.isFullscreen})}showTextInput(e){var t;if(!this.textInputEl)return;this.textInputDrawing=e;let{chartW:n,priceH:r}=this.getChartLayout(),i=this.getScaledPriceRange(this.viewport),a,o;if(e.type===`text`)a=this.scaleManager.xToPixel(e.points[0].barIndex,this.viewport,n),o=this.scaleManager.yToPixel(e.points[0].price,i,r);else{var s;let t=(s=e.points[1])==null?e.points[0]:s;a=this.scaleManager.xToPixel(t.barIndex,this.viewport,n)-30,o=this.scaleManager.yToPixel(t.price,i,r)-10}let c=this.textInputEl;c.value=(t=e.text)==null?``:t,c.style.left=`${Math.max(0,a)}px`,c.style.top=`${Math.max(0,o)}px`,c.style.display=`block`,this.drawingManager.setEditingText(!0),c.focus(),c.select();let l=()=>{c.removeEventListener(`keydown`,d),c.removeEventListener(`blur`,f),this.commitTextInput()},u=()=>{c.removeEventListener(`keydown`,d),c.removeEventListener(`blur`,f),this.cancelTextInput()},d=e=>{e.key===`Enter`?(e.preventDefault(),l()):e.key===`Escape`&&(e.preventDefault(),u())},f=()=>l();c.addEventListener(`keydown`,d),c.addEventListener(`blur`,f,{once:!0})}commitTextInput(){var e,t;!this.textInputEl||!this.textInputDrawing||(this.textInputDrawing.text=this.textInputEl.value,this.textInputEl.style.display=`none`,this.textInputDrawing=null,this.drawingManager.setEditingText(!1),(e=(t=this.drawingManager).onDrawingsChange)==null||e.call(t),this.scheduleRender())}cancelTextInput(){this.textInputEl&&(this.textInputEl.style.display=`none`,this.textInputDrawing=null,this.drawingManager.setEditingText(!1),this.scheduleRender())}setDotTickActive(){this.siStreamDot&&(this.tickActivityTimer!==null&&clearTimeout(this.tickActivityTimer),this.siStreamDot.style.background=this.theme.candle.up,this.tickActivityTimer=setTimeout(()=>{this.tickActivityTimer=null,this.siStreamDot&&(this.siStreamDot.style.background=this.theme.ui.stream[this.streamStatus])},this.tickActivityMs))}fillTickGap(e,t){if(!this.dataLoader||this.isFetching)return;let n=this.timeframeToInterval(this.getBaseInterval());this.dataLoader({start:new Date(e),end:new Date(t),interval:n}).then(e=>{let t=this.maybeAggregate(e);if(t.length===0)return;this.backfillDrawingTimestamps();let n=this.dataStore.all,r=n[n.length-1],i=0;for(let e of t){if(e.time>=r.time)continue;let t=n.findIndex(t=>t.time===e.time);if(t!==-1)n[t]=e;else{let t=n.findIndex(t=>t.time>e.time);n.splice(t===-1?n.length-1:t,0,e),i++}}i>0&&(this.viewport={...this.viewport,startIndex:this.viewport.startIndex+i,endIndex:this.viewport.endIndex+i},this.reanchorDrawingsByTimestamp(),this.recomputeIndicators(),this.scheduleRender())}).catch(()=>{})}correctCompletedBar(e,t){if(!this.dataLoader||this.isFetching)return;let n=new Date(e),r=new Date(e+t*3),i=this.timeframeToInterval(this.getBaseInterval());this.dataLoader({start:n,end:r,interval:i}).then(e=>{let t=this.maybeAggregate(e);if(t.length===0)return;let n=this.dataStore.all,r=n.length-1,i=!1;for(let e of t){let t=n.findIndex(t=>t.time===e.time);t!==-1&&t!==r&&(n[t]=e,i=!0)}i&&(this.recomputeIndicators(),this.scheduleRender())}).catch(()=>{})}setLayoutIcon(e,t=!0){var n;return(n=this.advancedToolbar)==null||n.setLayoutPresetIcon(e,t),this}setDebug(e){return this._debug=e,this}correctBar(e,t){let n=this.dataStore.all,r=n.findIndex(t=>t.time===e);r!==-1&&(n[r]=t,this.recomputeIndicators(),this.scheduleRender())}scrollToEnd(){this.panHandler.cancel(),this.scrollAnimId!==null&&(cancelAnimationFrame(this.scrollAnimId),this.scrollAnimId=null);let e=this.viewport.endIndex-this.viewport.startIndex,t=this.dataStore.length+$l,n=this.viewport.endIndex,r=this.pricePanOffset,i=performance.now(),a=e=>e<.5?2*e*e:-1+(4-2*e)*e,o=s=>{let c=Math.min((s-i)/350,1),l=a(c),u=n+(t-n)*l;this.viewport={...this.viewport,startIndex:u-e,endIndex:u},this._targetViewport={...this.viewport},this.pricePanOffset=r*(1-l),this.render(),c<1?this.scrollAnimId=requestAnimationFrame(o):this.scrollAnimId=null};this.scrollAnimId=requestAnimationFrame(o)}scrollToCenterPrice(e){if(!isFinite(e)||this.dataStore.length===0)return;this.scrollAnimId!==null&&(cancelAnimationFrame(this.scrollAnimId),this.scrollAnimId=null);let t=this.dataStore.getPriceRange(this.viewport),n=(t.min+t.max)/2,r=this.pricePanOffset,i=e-n;if(Math.abs(i-r)<1e-9)return;let a=performance.now(),o=e=>e<.5?2*e*e:-1+(4-2*e)*e,s=e=>{let t=Math.min((e-a)/350,1),n=o(t);this.pricePanOffset=r+(i-r)*n,this.render(),t<1?this.scrollAnimId=requestAnimationFrame(s):this.scrollAnimId=null};this.scrollAnimId=requestAnimationFrame(s)}resetPriceAxis(){this.priceScaleFactor=1,this.pricePanOffset=0,this._lockedAutoFitBase=null,this.scheduleRender()}resetTimeAxis(){this.panHandler.cancel();let e=this.dataStore.length;if(e===0)return;let t=Ql(this.mobileBarDivisor,this.explicitMobileDivisor,this.defaultVisibleBars,this.defaultMobileVisibleBars);this._defaultVisibleBars=t;let n=Math.max(0,e-t+$l);this.viewport={...this.viewport,startIndex:n,endIndex:e+$l},this._targetViewport={...this.viewport},this.scheduleRender()}resetView(){this.resetPriceAxis(),this.resetTimeAxis()}applyResetViewBtnStyles(){this.resetViewBtn&&(this.resetViewBtn.innerHTML=mn(this.theme.axisText,16),Object.assign(this.resetViewBtn.style,{position:`absolute`,bottom:`${this.timeAxisHeight+8}px`,left:`50%`,transform:`translateX(-50%)`,zIndex:`100`,width:`32px`,height:`32px`,padding:`0`,display:`flex`,alignItems:`center`,justifyContent:`center`,backgroundColor:this.theme.background,border:`1px solid ${this.theme.axisBorder}`,borderRadius:`50%`,cursor:`pointer`,outline:`none`,boxShadow:`0 2px 6px rgba(0,0,0,0.25)`,opacity:`0`,pointerEvents:`none`,transition:`opacity 0.2s ease`}))}applyScrollToEndBtnStyles(){if(!this.scrollToEndBtn)return;let e=this.theme.ui.scrollToEndBtnBg,t=e?`#ffffff`:this.theme.axisText,n=e==null?this.theme.background:e,r=e==null?this.theme.axisBorder:e;this.scrollToEndBtn.innerHTML=pn(t,16),Object.assign(this.scrollToEndBtn.style,{position:`absolute`,bottom:`${this.timeAxisHeight+8}px`,right:`${this.priceAxisWidth+8}px`,zIndex:`100`,width:`32px`,height:`32px`,padding:`0`,display:`flex`,alignItems:`center`,justifyContent:`center`,backgroundColor:n,border:`1px solid ${r}`,borderRadius:`50%`,cursor:`pointer`,outline:`none`,boxShadow:`0 2px 6px rgba(0,0,0,0.25)`,opacity:`0`,pointerEvents:`none`,transition:`opacity 0.2s ease`})}};Nl=nu,Nl.DRAW_GESTURE_THRESHOLD=4,Nl.TRADE_DRAG_PIXEL_THRESHOLD=3;var Q=null,ru=new Map,iu=new Map,au=0;function ou(){return`dr_${Date.now()}_${au++}`}function su(){return`cr_${Date.now()}_${au++}`}function $(e,t){var n;let r=JSON.stringify({type:e,payload:t});window.ChartAndroidBridge?window.ChartAndroidBridge.postMessage(r):!((n=window.webkit)==null||(n=n.messageHandlers)==null)&&n.chartBridge?window.webkit.messageHandlers.chartBridge.postMessage(r):window.ReactNativeWebView&&window.ReactNativeWebView.postMessage(r)}function cu(e={}){var t;Q==null||Q.destroy();let n=document.getElementById(`chart`),{enableTrading:r,onSymbolClick:i,onAskAiClick:a,orderLineTimeDrag:o,...s}=e,c=(t=s.timeframe)==null?`1D`:t;Q=new nu({theme:`dark`,...s,...o?{features:{...s.features,orderLineTimeDrag:!0}}:{},container:n,dataLoader:e=>{for(let[,e]of ru)e.reject(Error(`cancelled`));ru.clear();let t=ou(),n=Q==null?void 0:Q.getState();return new Promise((r,i)=>{var a;ru.set(t,{resolve:r,reject:i}),$(`dataRequest`,{requestId:t,timeframe:(a=n==null?void 0:n.timeframe)==null?c:a,interval:e.interval,start:e.start.getTime(),end:e.end.getTime()})})},compareDataLoader:e=>{let t=su(),n=Q==null?void 0:Q.getState();return new Promise((r,i)=>{var a;iu.set(t,{resolve:r,reject:i}),$(`compareDataRequest`,{requestId:t,symbol:e.symbol,timeframe:(a=n==null?void 0:n.timeframe)==null?c:a,interval:e.interval,start:e.start.getTime(),end:e.end.getTime()})})},...r?{onOrderSubmit:e=>{var t;$(`placeOrder`,{price:e.price,side:e.side,orderType:(t=e.orderType)==null?`limit`:t})}}:{},...i?{onSymbolClick:e=>{$(`symbolClick`,{symbol:e})}}:{},...a?{onAskAiClick:()=>{$(`askAiClick`,{})}}:{}}),Q.on(`timeframeChange`,({timeframe:e})=>{c=e}),Q.on(`crosshair`,e=>$(`crosshair`,e)),Q.on(`click`,e=>$(`barClick`,e)),Q.on(`zoom`,({viewport:e})=>$(`viewportChange`,{viewport:e})),Q.on(`pan`,({viewport:e})=>$(`viewportChange`,{viewport:e})),Q.on(`seriesChange`,e=>$(`seriesChange`,e)),Q.on(`timeframeChange`,e=>$(`timeframeChange`,e)),Q.on(`durationChange`,e=>$(`durationChange`,e)),Q.on(`stateChange`,e=>$(`stateChange`,e)),Q.on(`dataLoaded`,e=>$(`dataLoaded`,e)),Q.on(`newBar`,e=>$(`newBar`,e)),Q.on(`streamStatus`,e=>$(`streamStatus`,e)),Q.on(`tradeLevelClose`,e=>$(`tradeLevelClose`,e)),Q.on(`tradeLevelDrag`,e=>$(`tradeLevelDrag`,e)),Q.on(`tradeLevelDragStart`,e=>$(`tradeLevelDragStart`,e)),Q.on(`tradeLevelEdit`,e=>$(`tradeLevelEdit`,e)),Q.on(`tradeLevelQtyChange`,e=>$(`tradeLevelQtyChange`,e)),Q.on(`tradeLevelConfirmed`,e=>$(`tradeLevelConfirmed`,e)),Q.on(`tradeLevelEditOpen`,e=>$(`tradeLevelEditOpen`,e)),Q.on(`tradeLevelBracketActivated`,e=>$(`tradeLevelBracketActivated`,e)),Q.on(`draftInitiated`,e=>$(`draftInitiated`,e)),Q.on(`draftCancelled`,e=>$(`draftCancelled`,e)),Q.on(`uiStateChange`,e=>$(`uiStateChange`,e)),Q.on(`orderLineMoveStart`,e=>$(`orderLineMoveStart`,e)),Q.on(`orderLineMoving`,e=>$(`orderLineMoving`,e)),Q.on(`orderLineMoved`,e=>$(`orderLineMoved`,e)),Q.on(`compareAdded`,e=>$(`compareAdded`,e)),Q.on(`compareRemoved`,e=>$(`compareRemoved`,e)),Q.on(`compareError`,e=>$(`compareError`,e)),Q.on(`indicatorAdded`,e=>$(`indicatorAdded`,e)),Q.on(`indicatorRemoved`,e=>$(`indicatorRemoved`,e))}function lu(e){if(e.type===`init`){cu(e.payload);return}if(!Q){$(`error`,{message:`Engine not initialized. Send an "init" command first.`});return}switch(e.type){case`loadData`:Q.loadData(e.payload.bars,e.payload.fitAll);break;case`pushTick`:Q.pushTick(e.payload);break;case`setTheme`:Q.setTheme(e.payload.theme);break;case`setTimezone`:Q.setTimezone(e.payload.timezone);break;case`setShowLtpPrice`:Q.setShowLtpPrice(e.payload.show);break;case`setShowAskLine`:Q.setShowAskLine(e.payload.show);break;case`setShowBidLine`:Q.setShowBidLine(e.payload.show);break;case`setLayoutSync`:Q.setLayoutSync(e.payload);break;case`setSeries`:Q.setSeries(e.payload.series);break;case`setTimeframe`:Q.setTimeframe(e.payload.timeframe);break;case`setSymbol`:Q.setSymbol(e.payload.symbol);break;case`addIndicator`:Q.addIndicatorByName(e.payload.shortName,e.payload.params);break;case`removeIndicator`:Q.removeIndicator(e.payload.name);break;case`setDrawingTool`:Q.setDrawingTool(e.payload.tool);break;case`clearAllDrawings`:Q.clearAllDrawings();break;case`getState`:$(`stateSnapshot`,Q.getState());break;case`setState`:Q.setState(e.payload);break;case`resolveDataRequest`:{let t=ru.get(e.payload.requestId);t&&(ru.delete(e.payload.requestId),t.resolve(e.payload.bars));break}case`setDebug`:Q.setDebug(e.payload.enabled);break;case`destroy`:Q.destroy(),Q=null;break;case`setLevels`:Q.setLevels(e.payload.levels,e.payload.labelKey,e.payload.priceKey,e.payload.type,e.payload.pnlKey,e.payload.pnlTextKey);break;case`removeLevelByLabel`:Q.removeLevelByLabel(e.payload.label);break;case`updateLevelMainPrice`:Q.updateLevelMainPrice(e.payload.label,e.payload.price);break;case`updateLevelBracket`:Q.updateLevelBracket(e.payload.label,e.payload.bracketType.toLowerCase(),e.payload.price);break;case`addLevelBracket`:Q.addLevelBracket(e.payload.label,e.payload.bracketType.toLowerCase());break;case`addBracket`:Q.addBracket(e.payload.bracketType.toLowerCase(),e.payload.label);break;case`removeBracket`:Q.removeBracket(e.payload.bracketType.toLowerCase(),e.payload.label);break;case`cancelLevelEdit`:Q.cancelLevelEdit(e.payload.label);break;case`selectLevel`:Q.selectLevel(e.payload.label);break;case`showDraftOrder`:Q.showDraftOrder(e.payload.price,e.payload.side,e.payload.orderType);break;case`showMarketDraft`:Q.showMarketDraft(e.payload.price,e.payload.side);break;case`clearDraftOrder`:Q.clearDraftOrder();break;case`cancelCurrentEdit`:Q.cancelCurrentEdit();break;case`updateDraftOrderPrice`:Q.updateDraftOrderPrice(e.payload.price);break;case`updateDraftOrderBracket`:Q.updateDraftOrderBracket(e.payload.bracketType,e.payload.price);break;case`setDraftBracketPnl`:Q.setDraftBracketPnl(e.payload.bracketType,e.payload.pnlText);break;case`setVolume`:Q.setVolume(e.payload.show);break;case`setIsins`:Q.setIsins(e.payload.isins);break;case`resetView`:Q.resetView();break;case`resetData`:Q.resetData();break;case`setLoading`:Q.setLoading(e.payload.loading);break;case`setThemeOverrides`:Q.setThemeOverrides(e.payload.overrides);break;case`correctBar`:Q.correctBar(e.payload.barTime,e.payload.bar);break;case`dismissAllUI`:Q.dismissAllUI();break;case`addCompare`:Q.addCompare(e.payload.symbol);break;case`removeCompare`:Q.removeCompare(e.payload.symbol);break;case`clearCompares`:Q.clearCompares();break;case`resolveCompareDataRequest`:{let t=iu.get(e.payload.requestId);t&&(iu.delete(e.payload.requestId),t.resolve(e.payload.bars));break}}}document.addEventListener(`DOMContentLoaded`,()=>{window.ChartBridge={send(e){let t;try{t=JSON.parse(e)}catch(t){$(`error`,{message:`Invalid JSON: ${e}`});return}try{lu(t)}catch(e){$(`error`,{message:String(e)})}}},$(`ready`,{})})})();</script>
|
|
269
|
+
</div>`,Object.assign(n.style,{width:`100%`,display:`flex`,alignItems:`center`,justifyContent:`space-between`,padding:`12px`,borderRadius:`8px`,cursor:`pointer`,textAlign:`left`,fontFamily:`inherit`,transition:`background 0.15s, border-color 0.15s`}),n.appendChild(this.buildRowControl(t)),n.addEventListener(`click`,e=>{e.stopPropagation(),this.onIndicatorTap(t)}),this.indicatorRows.set(t.shortName,n),i.appendChild(n)}return t.appendChild(i),this.refreshIndicatorStyles(),t}buildRowControl(e){return e.isVolume?this.buildToggle(this.getCount(e.shortName)>0):this.buildCounter(this.getCount(e.shortName))}buildToggle(e){let t=this.theme,n=document.createElement(`span`);n.className=`hk-toggle`,Object.assign(n.style,{display:`inline-block`,height:`20px`,width:`36px`,borderRadius:`9999px`,position:`relative`,flexShrink:`0`,transition:`background 0.15s`,background:e?t.ui.accent:t.axisBorder});let r=document.createElement(`span`);return Object.assign(r.style,{position:`absolute`,top:`2px`,height:`16px`,width:`16px`,borderRadius:`50%`,background:t.background,transition:`left 0.15s`,left:e?`18px`:`2px`}),n.appendChild(r),n}buildCounter(e){let t=this.theme,n=document.createElement(`span`);n.className=`hk-ind-counter`,Object.assign(n.style,{display:`inline-flex`,alignItems:`center`,gap:`8px`,flexShrink:`0`});let r=document.createElement(`span`);r.className=`hk-ind-count`,r.textContent=String(e),Object.assign(r.style,{minWidth:`20px`,height:`20px`,padding:`0 6px`,borderRadius:`9999px`,display:e>0?`inline-flex`:`none`,alignItems:`center`,justifyContent:`center`,fontSize:`11px`,fontWeight:`700`,fontFamily:this.fontFamily,fontVariantNumeric:`tabular-nums`,background:t.ui.accent,color:t.background});let i=document.createElement(`span`);return i.className=`hk-ind-plus`,i.innerHTML=Nr.plus(),Object.assign(i.style,{display:`inline-flex`,alignItems:`center`,color:e>0?t.ui.accent:t.topBar.btnColor}),n.appendChild(r),n.appendChild(i),n}getCount(e){var t;return(t=this.indicatorCounts.get(e))==null?0:t}setCount(e,t){t>0?this.indicatorCounts.set(e,t):this.indicatorCounts.delete(e),this.refreshIndicatorRow(e)}onToolTap(e){switch(e.action.kind){case`tool`:if(e.action.tool===null&&this.controller.setCrosshairEnabled){let e=this.activeTool!==null,t=e?!0:!this.crosshairEnabled;this.activeTool=null,this.controller.setDrawingTool(null),this.controller.setCrosshairEnabled(t),this.crosshairEnabled=t,this.refreshToolStyles(),e&&this.close();break}this.activeTool=e.action.tool,this.controller.setDrawingTool(e.action.tool),this.refreshToolStyles(),this.close();break;case`clearDrawings`:this.controller.clearAllDrawings();break;case`magnet`:break}}onIndicatorTap(e){if(e.isVolume){this.controller.addIndicator(`VOL`);return}this.controller.addIndicator(e.shortName,e.params)}clearIndicators(){for(let[e,t]of[...this.indicatorCounts])t<=0||(e===`VOL`?this.controller.addIndicator(`VOL`):this.controller.removeIndicator(e));this.indicatorCounts.clear(),this.refreshIndicatorStyles()}refreshToolStyles(){let e=this.theme;for(let[t,n]of this.toolCells){let r=Pr.find(e=>e.id===t),i=r.action.kind===`tool`&&r.action.tool===this.activeTool;i&&r.action.kind===`tool`&&r.action.tool===null&&this.controller.setCrosshairEnabled&&(i=this.crosshairEnabled),n.style.background=i?e.ui.accentBg:e.tooltip.background,n.style.color=i?e.ui.accent:e.topBar.btnColor,n.style.border=`1px solid ${i?e.ui.accent:e.axisBorder}`}}refreshIndicatorStyles(){for(let e of this.indicatorRows.keys())this.refreshIndicatorRow(e)}refreshIndicatorRow(e){let t=this.indicatorRows.get(e);if(!t)return;let n=this.theme,r=this.getCount(e),i=r>0;t.style.background=i?n.ui.accentBg:n.tooltip.background,t.style.border=`1px solid ${i?n.ui.accent:n.axisBorder}`;let a=t.querySelector(`.hk-ind-title`);a&&(a.style.color=i?n.ui.accent:n.axisText);let o=t.querySelector(`.hk-toggle`);if(o){let e=o.firstElementChild;o.style.background=i?n.ui.accent:n.axisBorder,e&&(e.style.left=i?`18px`:`2px`)}let s=t.querySelector(`.hk-ind-count`);s&&(s.textContent=String(r),s.style.display=r>0?`inline-flex`:`none`);let c=t.querySelector(`.hk-ind-plus`);c&&(c.style.color=i?n.ui.accent:n.topBar.btnColor)}syncIndicator(e,t,n){var r;let i=(r=Fr.find(t=>t.shortName===e))==null?void 0:r.shortName;if(!i)return;let a=n==null?t?Math.max(1,this.getCount(i)):0:n;this.setCount(i,a)}setCrosshairEnabled(e){this.crosshairEnabled=e,this.refreshToolStyles()}syncVolume(e){this.setCount(`VOL`,+!!e)}setTheme(e){if(this.theme=e,this.open){var t;(t=this.backdrop)==null||t.remove(),this.toolCells.clear(),this.indicatorRows.clear(),this.build(!1)}}destroy(){this.close(),this.indicatorCounts.clear(),this.activeTool=null}},Lr=[{value:`candlestick`,label:`Candlestick`},{value:`hollow`,label:`Hollow Candles`},{value:`ohlc`,label:`OHLC Bars`},{value:`line`,label:`Line`},{value:`area`,label:`Area`},{value:`heikinashi`,label:`Heikin Ashi`},{value:`volumecandles`,label:`Volume Candles`},{value:`linemarkers`,label:`Line with Markers`},{value:`step`,label:`Step Line`},{value:`hlcarea`,label:`HLC Area`},{value:`baseline`,label:`Baseline`},{value:`columns`,label:`Columns`},{value:`highlow`,label:`High Low`}],Rr=[`1m`,`5m`,`15m`,`1h`,`4h`,`1D`,`1W`],zr={"1m":`1m`,"3m":`3m`,"4m":`4m`,"5m":`5m`,"10m":`10m`,"15m":`15m`,"30m":`30m`,"1h":`1H`,"4h":`4H`,"1D":`1D`,"1W":`1W`},Br=`JetBrains Mono, ui-monospace, Menlo, Monaco, monospace`,Vr=`"calt" 0, "liga" 0, "tnum"`,Hr=`relative flex items-center gap-1.5 px-2.5 py-1.5 rounded-md whitespace-nowrap shrink-0 bg-card`,Ur=`act-mobile-header`;function Wr(){if(typeof document>`u`||document.getElementById(`act-mobile-header-styles`))return;let e=document.createElement(`style`);e.id=`act-mobile-header-styles`,e.textContent=`
|
|
270
|
+
.${Ur}::-webkit-scrollbar { height: 6px; }
|
|
271
|
+
.${Ur}::-webkit-scrollbar-track { background: transparent; }
|
|
272
|
+
.${Ur}::-webkit-scrollbar-thumb { background: rgba(120,130,150,0.55); border-radius: 3px; }
|
|
273
|
+
.${Ur}::-webkit-scrollbar-thumb:hover { background: rgba(120,130,150,0.8); }
|
|
274
|
+
`,document.head.appendChild(e)}function Gr(e,t,n=2){return`<svg viewBox="0 0 24 24" width="${e}" height="${e}" fill="none" stroke="currentColor" stroke-width="${n}" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${t}</svg>`}var Kr=(e=14)=>Gr(e,`<path d="M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z"/><path d="m15 5 4 4"/>`),qr=(e=12)=>Gr(e,`<path d="M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z"/><path d="M20 3v4"/><path d="M22 5h-4"/><path d="M4 17v2"/><path d="M5 18H3"/>`,2.5),Jr=(e=16)=>Gr(e,`<path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"/><circle cx="12" cy="12" r="3"/>`,1.75),Yr=class{constructor(e,t,n,r,i,a,o,s,c,l=[],u=!1,d=!0,f=null){var p;this.toolsBtn=null,this.tfBtns=new Map,this.toolsActive=!1,this.crosshairBtn=null,this.crosshairEnabled=!0,this.seriesBtn=null,this.seriesMenu=null,this.seriesMenuOpen=!1,this.onDocPointerDown=null,this.onWinReposition=null,this.onTimeframeChange=e,this.onAskAiClick=n,this.onSettingsClick=r,this.onSeriesChange=i,this.currentTf=a,this.currentSeries=o,this.theme=s,this.fontFamily=c==null?Br:c,this.showCrosshairBtn=u,this.crosshairEnabled=d,this.onCrosshairToggle=f,this.sheet=t?new Ir(s,t,this.fontFamily,l):null,(p=this.sheet)==null||p.setCrosshairEnabled(this.crosshairEnabled),Wr(),this.el=document.createElement(`div`),this.el.className=Ur,this.build()}build(){if(this.closeSeriesMenu(),this.el.innerHTML=``,this.tfBtns.clear(),this.toolsBtn=null,this.seriesBtn=null,this.crosshairBtn=null,Object.assign(this.el.style,{display:`flex`,alignItems:`center`,gap:`8px`,overflowX:`auto`,overflowY:`hidden`,padding:`8px 12px`,borderBottom:`1px solid ${this.theme.axisBorder}`,background:this.theme.background,flexShrink:`0`,width:`100%`,maxWidth:`100%`,minWidth:`0`,boxSizing:`border-box`,scrollbarWidth:`thin`,scrollbarColor:`rgba(120,130,150,0.55) transparent`,WebkitOverflowScrolling:`touch`,fontFamily:this.fontFamily,fontFeatureSettings:Vr,fontVariantNumeric:`tabular-nums`}),this.sheet){let e=document.createElement(`button`);e.setAttribute(`data-testid`,`m-chart-tools-btn`),e.className=Hr,e.innerHTML=`${Kr(14)}<span class="text-[11px] font-mono font-semibold uppercase tracking-widest">Tools</span>`,Object.assign(e.style,{borderWidth:`1px`,borderStyle:`solid`,cursor:`pointer`,outline:`none`,transition:`color 0.15s, background 0.15s, border-color 0.15s`}),e.addEventListener(`click`,e=>{var t,n,r;e.stopPropagation(),(t=this.sheet)==null||t.toggle(),this.toolsActive=(n=(r=this.sheet)==null?void 0:r.isOpen)==null?!1:n,this.styleToolsBtn()}),this.toolsBtn=e,this.el.appendChild(e),this.styleToolsBtn();let t=document.createElement(`div`);Object.assign(t.style,{width:`1px`,height:`20px`,background:this.theme.axisBorder,flexShrink:`0`}),this.el.appendChild(t)}if(this.onSeriesChange){let e=document.createElement(`button`);e.setAttribute(`data-testid`,`m-chart-type-btn`),e.title=`Chart type`,e.innerHTML=this.seriesIconHtml(this.currentSeries),Object.assign(e.style,{display:`flex`,alignItems:`center`,justifyContent:`center`,padding:`6px`,borderRadius:`4px`,border:`none`,whiteSpace:`nowrap`,flexShrink:`0`,cursor:`pointer`,outline:`none`,background:`transparent`,color:this.theme.axisText,transition:`color 0.15s, background 0.15s`}),e.addEventListener(`click`,e=>{e.stopPropagation(),this.toggleSeriesMenu()}),this.seriesBtn=e,this.el.appendChild(e);let t=document.createElement(`div`);Object.assign(t.style,{width:`1px`,height:`20px`,background:this.theme.axisBorder,flexShrink:`0`}),this.el.appendChild(t)}for(let n of Rr){var e,t;let r=document.createElement(`button`);r.setAttribute(`data-testid`,`m-tf-${(e=zr[n])==null?n:e}`),r.className=`font-mono`,r.textContent=(t=zr[n])==null?n:t,Object.assign(r.style,{padding:`6px 12px`,borderRadius:`4px`,border:`none`,fontSize:`11px`,fontWeight:`600`,whiteSpace:`nowrap`,flexShrink:`0`,cursor:`pointer`,outline:`none`,fontFamily:this.fontFamily,transition:`background 0.15s, color 0.15s`}),r.addEventListener(`click`,e=>{e.stopPropagation(),this.currentTf!==n&&(this.currentTf=n,this.refreshTfStyles(),this.onTimeframeChange(n))}),this.tfBtns.set(n,r),this.el.appendChild(r)}this.refreshTfStyles();let n=document.createElement(`div`);if(n.style.flex=`1 0 8px`,this.el.appendChild(n),this.onAskAiClick){let e=document.createElement(`button`);e.setAttribute(`data-testid`,`m-chart-ai-btn`),e.className=`font-mono`,e.innerHTML=`${qr(12)}<span class="font-mono" style="font-size:11px;font-weight:600;">AI</span>`,Object.assign(e.style,{display:`flex`,alignItems:`center`,gap:`4px`,padding:`6px 12px`,borderRadius:`4px`,border:`none`,whiteSpace:`nowrap`,flexShrink:`0`,cursor:`pointer`,outline:`none`,fontFamily:this.fontFamily,background:this.theme.ui.accentBg,color:this.theme.ui.accent}),e.addEventListener(`click`,e=>{var t;e.stopPropagation(),(t=this.onAskAiClick)==null||t.call(this)}),this.el.appendChild(e)}if(this.showCrosshairBtn){let e=document.createElement(`button`);e.type=`button`,e.setAttribute(`data-testid`,`chart-crosshair-toggle`),e.innerHTML=Rn.replace(/width="\d+" height="\d+"/,`width="16" height="16"`),this.applyCrosshairBtnStyles(e,this.crosshairEnabled),e.addEventListener(`click`,e=>{var t;e.stopPropagation(),this.setCrosshairActive(!this.crosshairEnabled),(t=this.onCrosshairToggle)==null||t.call(this,this.crosshairEnabled)}),this.crosshairBtn=e,this.el.appendChild(e)}if(this.onSettingsClick){let e=document.createElement(`button`);e.setAttribute(`data-testid`,`m-chart-settings-btn`),e.title=`Settings`,e.innerHTML=Jr(16),Object.assign(e.style,{display:`flex`,alignItems:`center`,justifyContent:`center`,padding:`6px`,borderRadius:`4px`,border:`none`,whiteSpace:`nowrap`,flexShrink:`0`,cursor:`pointer`,outline:`none`,background:`transparent`,color:this.theme.axisText,transition:`color 0.15s, background 0.15s`}),e.addEventListener(`click`,e=>{var t;e.stopPropagation(),(t=this.onSettingsClick)==null||t.call(this)}),this.el.appendChild(e)}}styleToolsBtn(){if(!this.toolsBtn)return;let e=this.toolsActive?this.theme.ui.accent:this.theme.axisText;this.toolsBtn.style.color=e,this.toolsBtn.style.borderColor=e}applyCrosshairBtnStyles(e,t){let n=this.theme;e.dataset.active=String(t);let r=t?`Disable crosshair`:`Enable crosshair`;e.title=r,e.setAttribute(`aria-label`,r),e.setAttribute(`aria-pressed`,String(t)),Object.assign(e.style,{display:`flex`,alignItems:`center`,justifyContent:`center`,padding:`6px`,borderRadius:`4px`,boxSizing:`border-box`,border:`1px solid ${t?G(n.ui.accent,.3):`transparent`}`,background:t?G(n.ui.accent,.1):`transparent`,color:t?n.ui.accent:n.axisText,whiteSpace:`nowrap`,flexShrink:`0`,cursor:`pointer`,outline:`none`,transition:`color 0.15s, background-color 0.15s, border-color 0.15s`})}refreshTfStyles(){let e=this.theme;for(let[t,n]of this.tfBtns){let r=t===this.currentTf;n.style.background=r?e.ui.accentBg:`transparent`,n.style.color=r?e.ui.accent:e.topBar.btnColor}}seriesIconHtml(e){var t;return((t=mn[e])==null?mn.candlestick:t).replace(/width="\d+" height="\d+"/,`width="18" height="18"`)}toggleSeriesMenu(){this.seriesMenuOpen?this.closeSeriesMenu():this.openSeriesMenu()}openSeriesMenu(){this.seriesMenuOpen||!this.seriesBtn||typeof document>`u`||(this.seriesMenu=this.buildSeriesMenu(),document.body.appendChild(this.seriesMenu),this.seriesMenuOpen=!0,this.positionSeriesMenu(),this.styleSeriesBtnActive(!0),this.onDocPointerDown=e=>{var t,n;let r=e.target;(t=this.seriesMenu)!=null&&t.contains(r)||(n=this.seriesBtn)!=null&&n.contains(r)||this.closeSeriesMenu()},this.onWinReposition=()=>this.closeSeriesMenu(),setTimeout(()=>{this.seriesMenuOpen&&(document.addEventListener(`pointerdown`,this.onDocPointerDown,!0),window.addEventListener(`resize`,this.onWinReposition,!0),window.addEventListener(`scroll`,this.onWinReposition,!0),this.el.addEventListener(`scroll`,this.onWinReposition,!0))},0))}closeSeriesMenu(){var e;this.onDocPointerDown&&(document.removeEventListener(`pointerdown`,this.onDocPointerDown,!0),this.onDocPointerDown=null),this.onWinReposition&&(window.removeEventListener(`resize`,this.onWinReposition,!0),window.removeEventListener(`scroll`,this.onWinReposition,!0),this.el.removeEventListener(`scroll`,this.onWinReposition,!0),this.onWinReposition=null),(e=this.seriesMenu)==null||e.remove(),this.seriesMenu=null,this.seriesMenuOpen=!1,this.styleSeriesBtnActive(!1)}buildSeriesMenu(){let e=this.theme,t=document.createElement(`div`);t.setAttribute(`data-testid`,`m-chart-type-menu`),Object.assign(t.style,{position:`fixed`,zIndex:`2147483000`,minWidth:`184px`,maxHeight:`60vh`,overflowY:`auto`,padding:`4px`,borderRadius:`8px`,border:`1px solid ${e.axisBorder}`,background:e.background,boxShadow:`0 8px 28px rgba(0,0,0,0.35)`,fontFamily:this.fontFamily,WebkitOverflowScrolling:`touch`});for(let r of Lr){var n;let i=r.value===this.currentSeries,a=document.createElement(`button`);a.type=`button`,a.setAttribute(`data-testid`,`m-chart-type-${r.value}`),Object.assign(a.style,{display:`flex`,alignItems:`center`,gap:`10px`,width:`100%`,padding:`9px 10px`,borderRadius:`6px`,border:`none`,cursor:`pointer`,outline:`none`,textAlign:`left`,fontSize:`13px`,fontFamily:this.fontFamily,background:i?e.ui.accentBg:`transparent`,color:i?e.ui.accent:e.axisText});let o=((n=mn[r.value])==null?``:n).replace(/width="\d+" height="\d+"/,`width="16" height="16"`),s=i?kn.replace(/width="\d+" height="\d+"/,`width="16" height="16"`):``;a.innerHTML=`<span style="display:flex;flex-shrink:0;">${o}</span><span style="flex:1;">${r.label}</span><span style="display:flex;flex-shrink:0;width:16px;">${s}</span>`,a.addEventListener(`mouseenter`,()=>{r.value!==this.currentSeries&&(a.style.background=e.ui.accentBg)}),a.addEventListener(`mouseleave`,()=>{r.value!==this.currentSeries&&(a.style.background=`transparent`)}),a.addEventListener(`click`,e=>{e.stopPropagation(),this.selectSeries(r.value)}),t.appendChild(a)}return t}positionSeriesMenu(){if(!this.seriesMenu||!this.seriesBtn)return;let e=this.seriesBtn.getBoundingClientRect(),t=this.seriesMenu;t.style.top=`${e.bottom+6}px`,t.style.left=`${e.left}px`;let n=t.getBoundingClientRect();n.right>window.innerWidth-8&&(t.style.left=`${Math.max(8,window.innerWidth-8-n.width)}px`),n.bottom>window.innerHeight-8&&(t.style.top=`${Math.max(8,e.top-6-n.height)}px`)}selectSeries(e){var t;this.closeSeriesMenu(),e!==this.currentSeries&&(this.currentSeries=e,this.seriesBtn&&(this.seriesBtn.innerHTML=this.seriesIconHtml(e)),(t=this.onSeriesChange)==null||t.call(this,e))}styleSeriesBtnActive(e){this.seriesBtn&&(this.seriesBtn.style.color=e?this.theme.ui.accent:this.theme.axisText,this.seriesBtn.style.background=e?this.theme.ui.accentBg:`transparent`)}setTimeframe(e){this.currentTf=e,this.refreshTfStyles()}setDrawingsBtnActive(e){this.toolsActive=e,this.styleToolsBtn()}setCrosshairActive(e){var t;this.crosshairEnabled=e,this.crosshairBtn&&this.applyCrosshairBtnStyles(this.crosshairBtn,e),(t=this.sheet)==null||t.setCrosshairEnabled(e)}setTheme(e){var t;this.theme=e,this.build(),this.setDrawingsBtnActive(this.toolsActive),(t=this.sheet)==null||t.setTheme(e)}destroy(){var e;this.closeSeriesMenu(),(e=this.sheet)==null||e.destroy(),this.el.remove(),this.tfBtns.clear(),this.toolsBtn=null,this.seriesBtn=null,this.crosshairBtn=null}setIndicatorOptionActive(e,t,n){var r;(r=this.sheet)==null||r.syncIndicator(e,t,n)}setVolumeControl(e,t){var n;(n=this.sheet)==null||n.syncVolume(e)}setSeries(e){this.currentSeries=e,this.seriesBtn&&(this.seriesBtn.innerHTML=this.seriesIconHtml(e)),this.seriesMenuOpen&&(this.closeSeriesMenu(),this.openSeriesMenu())}setIndicatorOptions(e){}closeDropdown(){var e;(e=this.sheet)==null||e.close(),this.closeSeriesMenu()}get hasOpenDropdown(){var e,t;return((e=(t=this.sheet)==null?void 0:t.isOpen)==null?!1:e)||this.seriesMenuOpen}setFullscreen(e){}setActiveDuration(e){}setTfcActive(e){}setLayoutPresetIcon(e,t){}setLayoutActive(e){}getLayoutBtnEl(){return null}getSnapshotBtnEl(){return null}reparentFlyout(e){}setMobileLayout(e){}},Xr=22,Zr=15.84,K=1.5,Qr=1,$r=Xr-2*K,ei=Zr-2*K,q=(...e)=>`<svg width="${Xr}" height="${Zr}" viewBox="0 0 ${Xr} ${Zr}" class="shrink-0" aria-hidden="true">${e.join(``)}</svg>`,J=(e,t,n,r)=>`<rect x="${e}" y="${t}" width="${n}" height="${r}" fill="none" stroke="currentColor" stroke-width="1.2" rx="1.5"/>`;function ti(e,t,n,r){let i=($r-(n-1)*Qr)/n,a=(ei-(r-1)*Qr)/r;return J(K+e*(i+Qr),K+t*(a+Qr),i,a)}function ni(e,t){let n=[];for(let r=0;r<t;r++)for(let i=0;i<e;i++)n.push(ti(i,r,e,t));return n}var ri=($r-Qr)/2,ii=(ei-Qr)/2,ai=K+ri+Qr,oi=K+ii+Qr,si=(ei-2*Qr)/3,ci=($r-2*Qr)/3,li=[{id:`1`,count:1,cols:`1fr`,rows:`1fr`,icon:q(J(K,K,$r,ei))},{id:`2-h`,count:2,cols:`1fr 1fr`,rows:`1fr`,icon:q(J(K,K,ri,ei),J(ai,K,ri,ei))},{id:`2-v`,count:2,cols:`1fr`,rows:`1fr 1fr`,icon:q(J(K,K,$r,ii),J(K,oi,$r,ii))},{id:`3-cols`,count:3,cols:`1fr 1fr 1fr`,rows:`1fr`,icon:q(...ni(3,1))},{id:`3-rows`,count:3,cols:`1fr`,rows:`1fr 1fr 1fr`,icon:q(...ni(1,3))},{id:`3-l1r2`,count:3,cols:`1fr 1fr`,rows:`1fr 1fr`,areas:`"a b" "a c"`,areaOrder:[`a`,`b`,`c`],icon:q(J(K,K,ri,ei),J(ai,K,ri,ii),J(ai,oi,ri,ii))},{id:`3-l2r1`,count:3,cols:`1fr 1fr`,rows:`1fr 1fr`,areas:`"a c" "b c"`,areaOrder:[`a`,`b`,`c`],icon:q(J(K,K,ri,ii),J(K,oi,ri,ii),J(ai,K,ri,ei))},{id:`3-t1b2`,count:3,cols:`1fr 1fr`,rows:`1fr 1fr`,areas:`"a a" "b c"`,areaOrder:[`a`,`b`,`c`],icon:q(J(K,K,$r,ii),J(K,oi,ri,ii),J(ai,oi,ri,ii))},{id:`3-t2b1`,count:3,cols:`1fr 1fr`,rows:`1fr 1fr`,areas:`"a b" "c c"`,areaOrder:[`a`,`b`,`c`],icon:q(J(K,K,ri,ii),J(ai,K,ri,ii),J(K,oi,$r,ii))},{id:`4-2x2`,count:4,cols:`1fr 1fr`,rows:`1fr 1fr`,icon:q(...ni(2,2))},{id:`4-rows`,count:4,cols:`1fr`,rows:`1fr 1fr 1fr 1fr`,icon:q(...ni(1,4))},{id:`4-cols`,count:4,cols:`1fr 1fr 1fr 1fr`,rows:`1fr`,icon:q(...ni(4,1))},{id:`4-l1r3`,count:4,cols:`1fr 1fr`,rows:`1fr 1fr 1fr`,areas:`"a b" "a c" "a d"`,areaOrder:[`a`,`b`,`c`,`d`],icon:q(J(K,K,ri,ei),...[0,1,2].map(e=>J(ai,K+e*(si+Qr),ri,si)))},{id:`4-l3r1`,count:4,cols:`1fr 1fr`,rows:`1fr 1fr 1fr`,areas:`"a d" "b d" "c d"`,areaOrder:[`a`,`b`,`c`,`d`],icon:q(...[0,1,2].map(e=>J(K,K+e*(si+Qr),ri,si)),J(ai,K,ri,ei))},{id:`4-t1b3`,count:4,cols:`1fr 1fr 1fr`,rows:`1fr 1fr`,areas:`"a a a" "b c d"`,areaOrder:[`a`,`b`,`c`,`d`],icon:q(J(K,K,$r,ii),...[0,1,2].map(e=>J(K+e*(ci+Qr),oi,ci,ii)))},{id:`4-t3b1`,count:4,cols:`1fr 1fr 1fr`,rows:`1fr 1fr`,areas:`"a b c" "d d d"`,areaOrder:[`a`,`b`,`c`,`d`],icon:q(...[0,1,2].map(e=>J(K+e*(ci+Qr),K,ci,ii)),J(K,oi,$r,ii))},{id:`5-t1b4`,count:5,cols:`1fr 1fr 1fr 1fr`,rows:`1fr 1fr`,areas:`"a a a a" "b c d e"`,areaOrder:[`a`,`b`,`c`,`d`,`e`],icon:q(J(K,K,$r,ii),...[0,1,2,3].map(e=>{let t=($r-3*Qr)/4;return J(K+e*(t+Qr),oi,t,ii)}))},{id:`5-cols`,count:5,cols:`1fr 1fr 1fr 1fr 1fr`,rows:`1fr`,icon:q(...ni(5,1))},{id:`5-rows`,count:5,cols:`1fr`,rows:`1fr 1fr 1fr 1fr 1fr`,icon:q(...ni(1,5))},{id:`5-l1r4`,count:5,cols:`1fr 1fr`,rows:`1fr 1fr 1fr 1fr`,areas:`"a b" "a c" "a d" "a e"`,areaOrder:[`a`,`b`,`c`,`d`,`e`],icon:q(J(K,K,ri,ei),...[0,1,2,3].map(e=>{let t=(ei-3*Qr)/4;return J(ai,K+e*(t+Qr),ri,t)}))},{id:`6-2x3`,count:6,cols:`1fr 1fr 1fr`,rows:`1fr 1fr`,icon:q(...ni(3,2))},{id:`6-3x2`,count:6,cols:`1fr 1fr`,rows:`1fr 1fr 1fr`,icon:q(...ni(2,3))},{id:`6-cols`,count:6,cols:`1fr 1fr 1fr 1fr 1fr 1fr`,rows:`1fr`,icon:q(...ni(6,1))},{id:`6-rows`,count:6,cols:`1fr`,rows:`1fr 1fr 1fr 1fr 1fr 1fr`,icon:q(...ni(1,6))},{id:`8-2x4`,count:8,cols:`1fr 1fr 1fr 1fr`,rows:`1fr 1fr`,icon:q(...ni(4,2))},{id:`8-4x2`,count:8,cols:`1fr 1fr`,rows:`1fr 1fr 1fr 1fr`,icon:q(...ni(2,4))}];li.reduce((e,t)=>{var n,r;return((r=e[n=t.count])==null?e[n]=[]:r).push(t),e},{});var ui=new Map;function di(){return ui.size===0?li:[...li,...ui.values()]}function fi(e){var t,n;return(t=(n=ui.get(e))==null?li.find(t=>t.id===e):n)==null?li[0]:t}var pi={symbol:!1,interval:!0,crosshair:!0,time:!0,dateRange:!0},mi=[{key:`symbol`,label:`Symbol`,info:`All charts mirror the selected symbol`},{key:`interval`,label:`Interval`,info:`All charts use the same timeframe`},{key:`crosshair`,label:`Crosshair`,info:`Crosshair position mirrors across all charts`},{key:`time`,label:`Time`,info:`Panning and zoom are linked`},{key:`dateRange`,label:`Date range`,info:`All charts use the same visible range`}],hi=class{constructor(e,t,n,r,i,a){this.theme=e,this.currentPresetId=t,this.sync={...n},this.onSelectPreset=r,this.onToggleSync=i,this.onVisibilityChange=a,this.el=document.createElement(`div`),this.el.classList.add(`act-layout-popover`),this.el.setAttribute(`role`,`dialog`),this.el.setAttribute(`aria-label`,`Chart layout picker`),this.applyBaseStyles(),this.el.addEventListener(`pointerdown`,e=>e.stopPropagation()),document.body.appendChild(this.el),this.build(),this.docPointerDownHandler=e=>{if(!this.isVisible)return;let t=e.target;t&&(t.closest(`[data-layout-toggle]`)||this.hide())},this.escapeHandler=e=>{e.key===`Escape`&&this.isVisible&&this.hide()},document.addEventListener(`pointerdown`,this.docPointerDownHandler),document.addEventListener(`keydown`,this.escapeHandler)}show(e){var t;let n=this.isVisible,r=e.getBoundingClientRect(),i=r.bottom+6,a=Math.max(8,window.innerWidth-r.right);this.el.style.top=`${i}px`,this.el.style.right=`${a}px`,this.el.style.display=`block`,n||(t=this.onVisibilityChange)==null||t.call(this)}hide(){var e;let t=this.isVisible;this.el.style.display=`none`,t&&((e=this.onVisibilityChange)==null||e.call(this))}get isVisible(){return this.el.style.display!==`none`}setPreset(e){e!==this.currentPresetId&&(this.currentPresetId=e,this.build())}setSync(e){this.sync={...e},this.build()}setTheme(e){this.theme=e,this.applyBaseStyles(),this.build()}destroy(){document.removeEventListener(`pointerdown`,this.docPointerDownHandler),document.removeEventListener(`keydown`,this.escapeHandler),this.el.remove()}applyBaseStyles(){Object.assign(this.el.style,{position:`fixed`,display:`none`,width:`480px`,maxWidth:`calc(100vw - 16px)`,maxHeight:`80vh`,overflowY:`auto`,borderRadius:`6px`,background:this.theme.tooltip.background,border:`1px solid ${this.theme.axisBorder}`,boxShadow:`0 8px 32px rgba(0,0,0,0.45)`,zIndex:`10000`,fontFamily:`'Inter', system-ui, sans-serif`,fontSize:`13px`,color:this.theme.topBar.btnColor,pointerEvents:`auto`})}build(){this.el.innerHTML=``,this.el.appendChild(this.buildHeader()),this.el.appendChild(this.buildPresetGrid()),this.el.appendChild(this.buildSyncSection())}buildHeader(){let e=document.createElement(`div`);Object.assign(e.style,{display:`flex`,alignItems:`center`,justifyContent:`space-between`,padding:`10px 12px 8px`,borderBottom:`1px solid ${this.theme.axisBorder}`});let t=document.createElement(`span`);t.textContent=`Chart Layout`,Object.assign(t.style,{fontSize:`10px`,fontWeight:`600`,letterSpacing:`0.1em`,textTransform:`uppercase`,color:this.theme.axisText}),e.appendChild(t);let n=document.createElement(`button`);return n.setAttribute(`aria-label`,`Close layout picker`),Object.assign(n.style,{background:`none`,border:`none`,color:this.theme.axisText,cursor:`pointer`,padding:`2px`,display:`flex`,alignItems:`center`,borderRadius:`4px`}),n.innerHTML=`<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" aria-hidden="true"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>`,n.addEventListener(`click`,e=>{e.stopPropagation(),this.hide()}),e.appendChild(n),e}buildPresetGrid(){let e=document.createElement(`div`);e.style.padding=`10px 12px 8px`;let t=new Map;for(let e of di()){let n=t.get(e.count);n?n.push(e):t.set(e.count,[e])}let n=Array.from(t.keys()).sort((e,t)=>e-t);for(let r of n){let n=t.get(r);if(!(n!=null&&n.length))continue;let i=document.createElement(`div`);Object.assign(i.style,{display:`flex`,alignItems:`flex-start`,gap:`10px`,marginBottom:`8px`});let a=document.createElement(`span`);a.textContent=String(r),Object.assign(a.style,{width:`14px`,fontSize:`11px`,fontWeight:`700`,color:this.theme.axisText,paddingTop:`6px`,textAlign:`right`,flexShrink:`0`}),i.appendChild(a);let o=document.createElement(`div`);Object.assign(o.style,{display:`flex`,flexWrap:`wrap`,gap:`5px`,flex:`1`});for(let e of n){let t=e.id===this.currentPresetId,n=document.createElement(`button`);n.dataset.testid=`chart-layout-${e.id}`,n.title=e.id,n.setAttribute(`aria-pressed`,String(t)),Object.assign(n.style,{height:`36px`,width:`44px`,borderRadius:`4px`,border:`1.5px solid ${t?this.theme.ui.accent:this.theme.axisBorder}`,background:t?this.theme.ui.accentBg:`transparent`,boxShadow:t?`0 0 0 1px ${this.theme.ui.accentBg}`:`none`,cursor:`pointer`,display:`flex`,alignItems:`center`,justifyContent:`center`,transition:`border-color 0.1s, background 0.1s`,padding:`0`}),n.innerHTML=e.icon.replace(/stroke="currentColor"/g,`stroke="${t?this.theme.ui.accent:this.theme.axisText}"`),n.addEventListener(`pointerdown`,t=>{t.stopPropagation(),e.id!==this.currentPresetId&&(this.setPreset(e.id),this.onSelectPreset(e.id))}),o.appendChild(n)}i.appendChild(o),e.appendChild(i)}return e}buildSyncSection(){let e=document.createElement(`div`);Object.assign(e.style,{padding:`8px 12px 12px`,borderTop:`1px solid ${this.theme.axisBorder}`});let t=document.createElement(`div`);t.textContent=`Sync in Layout`,Object.assign(t.style,{fontSize:`10px`,fontWeight:`600`,letterSpacing:`0.1em`,textTransform:`uppercase`,color:this.theme.axisText,marginBottom:`8px`}),e.appendChild(t);for(let t of mi)e.appendChild(this.makeSyncRow(t));return e}makeSyncRow({key:e,label:t,info:n}){let r=document.createElement(`div`);Object.assign(r.style,{display:`flex`,alignItems:`center`,justifyContent:`space-between`,padding:`5px 0`});let i=document.createElement(`div`);Object.assign(i.style,{display:`flex`,alignItems:`center`,gap:`5px`});let a=document.createElement(`span`);a.textContent=t,Object.assign(a.style,{fontSize:`12px`,color:this.theme.topBar.btnColor}),i.appendChild(a);let o=document.createElement(`span`);return o.textContent=`ⓘ`,o.title=n,Object.assign(o.style,{fontSize:`10px`,color:this.theme.axisText,cursor:`help`}),i.appendChild(o),r.appendChild(i),r.appendChild(this.makeToggleSwitch(e)),r}makeToggleSwitch(e){let t=this.sync[e],n=document.createElement(`label`);n.dataset.testid=`sync-${e}`,Object.assign(n.style,{position:`relative`,display:`inline-block`,width:`32px`,height:`16px`,cursor:`pointer`,flexShrink:`0`});let r=document.createElement(`input`);r.type=`checkbox`,r.checked=t,r.setAttribute(`role`,`switch`),r.setAttribute(`aria-checked`,String(t)),Object.assign(r.style,{opacity:`0`,width:`0`,height:`0`,position:`absolute`}),r.addEventListener(`change`,t=>{t.stopPropagation(),this.sync={...this.sync,[e]:!this.sync[e]},this.build(),this.onToggleSync(e)});let i=document.createElement(`span`);Object.assign(i.style,{position:`absolute`,top:`0`,left:`0`,right:`0`,bottom:`0`,borderRadius:`40px`,border:`1px solid ${t?this.theme.ui.accent:this.theme.axisBorder}`,background:t?this.theme.ui.accent:`transparent`,transition:`border-color 0.2s, background 0.2s`});let a=document.createElement(`span`);return Object.assign(a.style,{position:`absolute`,height:`12px`,width:`12px`,left:t?`16px`:`2px`,bottom:`1px`,borderRadius:`50%`,background:t?`#ffffff`:this.theme.axisText,transition:`left 0.2s, background 0.2s`}),n.append(r,i,a),n}},gi=class{constructor(e,t,n){this.theme=e,this.onAction=t,this.onVisibilityChange=n,this.el=document.createElement(`div`),this.el.setAttribute(`role`,`menu`),this.el.setAttribute(`aria-label`,`Snapshot options`),this.applyBaseStyles(),this.el.addEventListener(`pointerdown`,e=>e.stopPropagation()),document.body.appendChild(this.el),this.build(),this.docPointerDownHandler=e=>{if(!this.isVisible)return;let t=e.target;t&&(t.closest(`[data-snapshot-toggle]`)||this.hide())},this.escapeHandler=e=>{e.key===`Escape`&&this.isVisible&&this.hide()},document.addEventListener(`pointerdown`,this.docPointerDownHandler),document.addEventListener(`keydown`,this.escapeHandler)}show(e){var t;let n=this.isVisible,r=e.getBoundingClientRect(),i=r.bottom+6,a=Math.max(8,window.innerWidth-r.right);this.el.style.top=`${i}px`,this.el.style.right=`${a}px`,this.el.style.display=`flex`,n||(t=this.onVisibilityChange)==null||t.call(this)}hide(){var e;let t=this.isVisible;this.el.style.display=`none`,t&&((e=this.onVisibilityChange)==null||e.call(this))}get isVisible(){return this.el.style.display!==`none`}setTheme(e){this.theme=e,this.applyBaseStyles(),this.build()}destroy(){document.removeEventListener(`pointerdown`,this.docPointerDownHandler),document.removeEventListener(`keydown`,this.escapeHandler),this.el.remove()}applyBaseStyles(){Object.assign(this.el.style,{position:`fixed`,display:`none`,flexDirection:`column`,background:this.theme.tooltip.background,border:`1px solid ${this.theme.axisBorder}`,borderRadius:`5px`,padding:`4px`,zIndex:`10000`,boxShadow:`0 4px 16px rgba(0,0,0,0.25)`,fontFamily:`'Inter', system-ui, sans-serif`,fontSize:`12px`,width:`max-content`,minWidth:`140px`,pointerEvents:`auto`})}build(){this.el.innerHTML=``,this.el.append(this.makeRow(`Download`,this.iconDownload(),`download`),this.makeRow(`Copy`,this.iconCopy(),`copy`))}makeRow(e,t,n){let r=document.createElement(`button`);r.dataset.testid=`chart-snapshot-${n}`,Object.assign(r.style,{display:`flex`,alignItems:`center`,gap:`8px`,width:`100%`,background:`transparent`,border:`none`,borderRadius:`3px`,padding:`8px 10px`,cursor:`pointer`,fontFamily:`'Inter', system-ui, sans-serif`,fontSize:`12px`,color:this.theme.topBar.btnColor,textAlign:`left`});let i=document.createElement(`span`);i.style.display=`flex`,i.style.alignItems=`center`,i.style.flexShrink=`0`,i.innerHTML=t,r.appendChild(i);let a=document.createElement(`span`);return a.textContent=e,a.style.fontWeight=`500`,r.appendChild(a),r.addEventListener(`mouseenter`,()=>{r.style.background=this.theme.ui.accentBg}),r.addEventListener(`mouseleave`,()=>{r.style.background=`transparent`}),r.addEventListener(`click`,e=>{e.stopPropagation(),this.onAction(n)}),r}iconDownload(){return`<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>`}iconCopy(){return`<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg>`}},_i={"1D":`5m`,"5D":`15m`,"1M":`30m`,"3M":`30m`,"6M":`1D`,"1Y":`1D`,"5Y":`1W`,All:`1M`},vi=[`1D`,`5D`,`1M`,`3M`,`6M`,`1Y`,`5Y`,`All`],yi=class{constructor(e,t,n,r,i=x,a=k.bottomBar){this.onDurationChange=e,this.buttons=new Map,this.activeDuration=t,this.theme=n,this.cfg=i,this.labels=a,this.map={..._i,...r},this.el=document.createElement(`div`),this.applyBarStyles(n);for(let e of vi){var o;let r=document.createElement(`button`);r.textContent=(o=this.labels.durations[e])==null?e:o,this.applyButtonStyles(r,n,e===t),r.addEventListener(`click`,()=>{this.setActive(e),this.onDurationChange(e,this.map[e])}),this.buttons.set(e,r),this.el.appendChild(r)}}setTheme(e){this.theme=e,this.applyBarStyles(e);for(let[t,n]of this.buttons)this.applyButtonStyles(n,e,this.activeDuration!==null&&t===this.activeDuration)}setActive(e){if(this.activeDuration!==(e==null?null:e)){if(this.activeDuration){let e=this.buttons.get(this.activeDuration);e&&this.applyButtonStyles(e,this.theme,!1)}if(this.activeDuration=e==null?null:e,e){let t=this.buttons.get(e);t&&this.applyButtonStyles(t,this.theme,!0)}}}applyBarStyles(e){Object.assign(this.el.style,{display:`flex`,alignItems:`center`,justifyContent:`flex-end`,gap:`2px`,height:this.cfg.height,padding:`0 10px`,background:e.background,borderTop:`1px solid ${e.axisBorder}`,boxSizing:`border-box`,flexShrink:`0`})}applyButtonStyles(e,t,n){Object.assign(e.style,{background:n?t.bottomBar.activeBtnBg:`transparent`,color:n?t.bottomBar.activeBtnText:t.bottomBar.btnColor,border:`1px solid ${n?t.bottomBar.activeBtnBorder:`transparent`}`,borderRadius:`3px`,padding:`2px 7px`,fontSize:this.cfg.btnFontSize,fontFamily:this.cfg.btnFontFamily,cursor:`pointer`,outline:`none`,transition:`background 0.15s`})}},bi={horizontal_line:`horizontalLine`,vertical_line:`verticalLine`,trend_line:`trendLine`,trend_angle:`trendAngle`,cross_line:`crossLine`,parallel_channel:`parallelChannel`,disjoint_channel:`disjointChannel`,flat_channel:`flatChannel`,fib_retracement:`fibRetracement`,fib_extension:`fibExtension`,fib_channel:`fibChannel`,fib_timezone:`fibTimezone`,fib_circles:`fibCircles`,fib_spiral:`fibSpiral`,fib_fan:`fibFan`,gann_fan:`gannFan`,gann_square:`gannSquare`,gann_box:`gannBox`,rectangle:`rectangle`,rotated_rectangle:`rotatedRectangle`,ellipse:`ellipse`,triangle:`triangle`,circle:`circle`,arc:`arc`,polyline:`polyline`,path:`path`,price_range:`priceRange`,date_range:`dateRange`,date_price_range:`datePriceRange`,ruler:`ruler`,long_position:`longPosition`,short_position:`shortPosition`,pitchfork:`pitchfork`,schiff_pitchfork:`schiffPitchfork`,modified_schiff:`modifiedSchiff`,inside_pitchfork:`insidePitchfork`,fixed_range_vp:`fixedRangeVP`,anchored_vp:`anchoredVP`,volume_profile:`volumeProfile`,regression_trend:`regressionTrend`,text:`text`,callout:`callout`,price_label:`priceLabel`,arrow_marker:`arrowMarker`,flag:`flag`,price_note:`priceNote`,anchored_note:`anchoredNote`,arrow_up:`arrowUp`,arrow_down:`arrowDown`,head_shoulders:`headShoulders`,triangle_pattern:`trianglePattern`,three_drives:`threeDrives`,abcd_pattern:`abcdPattern`,cypher_pattern:`cypherPattern`,butterfly_pattern:`butterflyPattern`,bat_pattern:`batPattern`,gartley_pattern:`gartleyPattern`,crab_pattern:`crabPattern`,shark_pattern:`sharkPattern`,elliott_impulse:`elliottImpulse`,elliott_corrective:`elliottCorrective`,elliott_triangle:`elliottTriangle`,elliott_combination:`elliottCombination`,elliott_wxy:`elliottWxy`,brush:`brush`,highlighter:`highlighter`,ghost_feed:`ghostFeed`,projection:`projection`,sine_line:`sineLine`,cyclic_lines:`cyclicLines`,time_cycles:`timeCycles`,fib_projection:`fibProjection`,price_projection:`priceProjection`},xi=[{id:`trend_lines`,name:`Trend Lines & Channels`,icon:`↗`,tools:[{id:`trend_line`,name:`Trend Line`,icon:`↗`,shortcut:`Alt+T`},{id:`trend_angle`,name:`Trend Angle`,icon:`∠`},{id:`horizontal_line`,name:`Horizontal Line`,icon:`—`,shortcut:`Alt+H`},{id:`vertical_line`,name:`Vertical Line`,icon:`⏐`,shortcut:`Alt+V`},{id:`cross_line`,name:`Cross Line`,icon:`✚`},{id:`parallel_channel`,name:`Parallel Channel`,icon:`⫿`},{id:`disjoint_channel`,name:`Disjoint Channel`,icon:`≠`},{id:`flat_channel`,name:`Flat Top/Bottom Channel`,icon:`⊓`}]},{id:`fibonacci_gann`,name:`Fibonacci & Gann Tools`,icon:`φ`,tools:[{id:`fib_retracement`,name:`Fibonacci Retracement`,icon:`φ`,shortcut:`Alt+F`},{id:`fib_extension`,name:`Fibonacci Extension`,icon:`φ`},{id:`fib_channel`,name:`Fibonacci Channel`,icon:`φ`},{id:`fib_timezone`,name:`Fibonacci Timezone`,icon:`φ`},{id:`fib_circles`,name:`Fibonacci Circles`,icon:`⊙`},{id:`fib_spiral`,name:`Fibonacci Spiral`,icon:`@`},{id:`fib_fan`,name:`Fibonacci Speed Resistance Fan`,icon:`⌇`},{id:`gann_fan`,name:`Gann Fan`,icon:`⌇`},{id:`gann_square`,name:`Gann Square`,icon:`⊞`},{id:`gann_box`,name:`Gann Box`,icon:`⊡`}]},{id:`geometric_shapes`,name:`Geometric Shapes`,icon:`▭`,tools:[{id:`rectangle`,name:`Rectangle`,icon:`▭`},{id:`rotated_rectangle`,name:`Rotated Rectangle`,icon:`◇`},{id:`ellipse`,name:`Ellipse`,icon:`⬭`},{id:`triangle`,name:`Triangle`,icon:`△`},{id:`circle`,name:`Circle`,icon:`○`},{id:`arc`,name:`Arc`,icon:`⌒`},{id:`polyline`,name:`Polyline`,icon:`⚡`},{id:`path`,name:`Path`,icon:`〰`}]},{id:`measurement_tools`,name:`Measurement Tools`,icon:`⇕`,tools:[{id:`price_range`,name:`Price Range`,icon:`⇕`},{id:`date_range`,name:`Date Range`,icon:`⇔`},{id:`date_price_range`,name:`Date & Price Range`,icon:`⊞`},{id:`ruler`,name:`Ruler`,icon:`⊢`}]},{id:`forecasting`,name:`Forecasting`,icon:`◱`,tools:[{id:`long_position`,name:`Long Position`,icon:`◱`,gate:`enableForecasting`},{id:`short_position`,name:`Short Position`,icon:`◰`,gate:`enableForecasting`}]},{id:`pitchfork_tools`,name:`Pitchfork Tools`,icon:`⑁`,tools:[{id:`pitchfork`,name:`Pitchfork`,icon:`⑁`},{id:`schiff_pitchfork`,name:`Schiff Pitchfork`,icon:`⑁`},{id:`modified_schiff`,name:`Modified Schiff Pitchfork`,icon:`⑁`},{id:`inside_pitchfork`,name:`Inside Pitchfork`,icon:`⑁`}]},{id:`volume_statistics`,name:`Volume & Statistical Tools`,icon:`▤`,tools:[{id:`fixed_range_vp`,name:`Fixed Range Volume Profile`,icon:`▤`},{id:`anchored_vp`,name:`Anchored Volume Profile`,icon:`▤`},{id:`volume_profile`,name:`Volume Profile`,icon:`▤`},{id:`regression_trend`,name:`Regression Trend`,icon:`↗`}]},{id:`annotation_tools`,name:`Annotation Tools`,icon:`A`,tools:[{id:`text`,name:`Text`,icon:`A`},{id:`callout`,name:`Callout`,icon:`⬕`},{id:`price_label`,name:`Price Label`,icon:`$`},{id:`arrow_marker`,name:`Arrow Marker`,icon:`→`},{id:`flag`,name:`Flag`,icon:`⚑`},{id:`price_note`,name:`Price Note`,icon:`≡`},{id:`anchored_note`,name:`Anchored Note`,icon:`⊕`},{id:`arrow_up`,name:`Arrow Up`,icon:`↑`},{id:`arrow_down`,name:`Arrow Down`,icon:`↓`}]},{id:`pattern_recognition`,name:`Pattern Recognition`,icon:`◬`,tools:[{id:`head_shoulders`,name:`Head & Shoulders`,icon:`⌢`},{id:`triangle_pattern`,name:`Triangle Pattern`,icon:`◬`},{id:`three_drives`,name:`3 Drives Pattern`,icon:`⋎`},{id:`abcd_pattern`,name:`ABCD Pattern`,icon:`⊿`},{id:`cypher_pattern`,name:`Cypher Pattern`,icon:`C`},{id:`butterfly_pattern`,name:`Butterfly Pattern`,icon:`⋈`},{id:`bat_pattern`,name:`Bat Pattern`,icon:`⌓`},{id:`gartley_pattern`,name:`Gartley Pattern`,icon:`G`},{id:`crab_pattern`,name:`Crab Pattern`,icon:`⊓`},{id:`shark_pattern`,name:`Shark Pattern`,icon:`⊳`}]},{id:`elliott_wave`,name:`Elliott Wave Tools`,icon:`∿`,tools:[{id:`elliott_impulse`,name:`Elliott Impulse (12345)`,icon:`∿`},{id:`elliott_corrective`,name:`Elliott Corrective (ABC)`,icon:`∿`},{id:`elliott_triangle`,name:`Elliott Wave Triangle`,icon:`△`},{id:`elliott_combination`,name:`Elliott Wave Combination`,icon:`∿`},{id:`elliott_wxy`,name:`Elliott Double Three (WXY)`,icon:`∿`}]},{id:`brush_highlighter`,name:`Brush & Highlighter`,icon:`∫`,tools:[{id:`brush`,name:`Brush`,icon:`∫`},{id:`highlighter`,name:`Highlighter`,icon:`▬`}]},{id:`advanced_tools`,name:`Advanced Tools`,icon:`⊛`,tools:[{id:`ghost_feed`,name:`Ghost Feed`,icon:`◑`},{id:`projection`,name:`Projection`,icon:`→`},{id:`sine_line`,name:`Sine Line`,icon:`∿`},{id:`cyclic_lines`,name:`Cyclic Lines`,icon:`⟳`},{id:`time_cycles`,name:`Time Cycles`,icon:`⊙`}]},{id:`price_projections`,name:`Price Projection Tools`,icon:`⊿`,tools:[{id:`fib_projection`,name:`Fibonacci Projection`,icon:`φ`},{id:`price_projection`,name:`Price Projection`,icon:`⊿`}]}],Si=[{id:`undo`,icon:`↶`,title:`Undo (Ctrl+Z)`},{id:`redo`,icon:`↷`,title:`Redo (Ctrl+Y)`},{id:`delete_selected`,icon:`✕`,title:`Delete Selected (Del)`},{id:`clear_all`,icon:`⊡`,title:`Clear All`},{id:`toggle_visibility`,icon:`◌`,title:`Hide All`},{id:`toggle_lock`,icon:`⊠`,title:`Lock All`}],Ci=class{constructor(e,t,n,r,i=y,a=k.drawingToolbar,o=[]){this.onToolChange=e,this.onAction=t,this.onMobileClose=n,this.activeTool=null,this.openCategoryId=null,this.openActionsMenu=!1,this.catButtons=new Map,this.drawingsHidden=!1,this.drawingsLocked=!1,this.mobileMode=!1,this.settingsVisible=!0,this.enabledGates=new Set,this.theme=r,this.cfg=i,this.labels=a,this.enabledGates=new Set(o),this.el=document.createElement(`div`),this.flyout=document.createElement(`div`),this.applyBarStyles(),this.applyWidth(),this.buildToolbar(),this.buildFlyout(),document.body.appendChild(this.flyout),this.docClickHandler=e=>{!this.el.contains(e.target)&&!this.flyout.contains(e.target)&&this.closeFlyout()},document.addEventListener(`click`,this.docClickHandler,!0)}setTheme(e){this.theme=e,this.closeFlyout(),this.applyBarStyles(),this.applyWidth(),this.buildFlyout(),this.applyScrollBtnStyles(this.scrollUpBtn,`up`),this.applyScrollBtnStyles(this.scrollDownBtn,`down`),this.topSection.innerHTML=``,this.topSection.appendChild(this.buildMobileActionsBtn());for(let[e,n]of this.catButtons){var t;let r=this.activeTool!==null&&((t=xi.find(t=>t.id===e))==null?void 0:t.tools.some(e=>bi[e.id]===this.activeTool))===!0;this.applyCatBtnStyles(n,r)}}setActiveTool(e){if(this.activeTool!==null){let e=xi.find(e=>e.tools.some(e=>bi[e.id]===this.activeTool)),t=e&&this.catButtons.get(e.id);t&&this.applyCatBtnStyles(t,!1)}if(this.activeTool=e,e!==null){let t=xi.find(t=>t.tools.some(t=>bi[t.id]===e)),n=t&&this.catButtons.get(t.id);n&&this.applyCatBtnStyles(n,!0)}}setVisible(e){this.settingsVisible=e,this.applyWidth()}setMobileMode(e){if(this.mobileMode===e)return;this.mobileMode=e,this.closeFlyout(),this.topSection.innerHTML=``,this.topSection.appendChild(this.buildMobileActionsBtn()),this.catButtons.clear();let t=this.makeGrid();if(this.populateCategoryGrid(t),this.toolsGrid.replaceWith(t),this.toolsGrid=t,this.activeTool!==null){let e=xi.find(e=>e.tools.some(e=>bi[e.id]===this.activeTool));if(e){let t=this.catButtons.get(e.id);t&&this.applyCatBtnStyles(t,!0)}}e?(Object.assign(this.el.style,{position:`absolute`,left:`0`,top:`0`,height:`100%`,zIndex:`50`}),this.settingsVisible=!1):(Object.assign(this.el.style,{position:``,left:``,top:``,height:``,zIndex:``}),this.settingsVisible=!0),this.applyBarStyles(),this.applyWidth(),requestAnimationFrame(()=>this.updateScrollIndicators())}reparentFlyout(e){this.flyout.parentElement!==e&&e.appendChild(this.flyout)}destroy(){this.flyout.remove(),document.removeEventListener(`click`,this.docClickHandler,!0)}get barWidth(){return this.cfg.barPadding*2+this.cfg.iconBtnSize}applyBarStyles(){Object.assign(this.el.style,{display:`flex`,flexDirection:`column`,flexShrink:`0`,position:`relative`,height:`100%`,background:this.theme.background,borderRight:`1px solid ${this.theme.axisBorder}`,boxSizing:`border-box`,userSelect:`none`,fontFamily:this.cfg.flyoutLabelFontFamily,overflow:`hidden`,transition:`width 0.2s ease`})}applyWidth(){this.settingsVisible?this.el.style.width=`${this.barWidth}px`:this.el.style.width=`0`}buildToolbar(){this.topSection=document.createElement(`div`),Object.assign(this.topSection.style,{borderBottom:`1px solid ${this.theme.axisBorder}`,padding:`10px ${this.cfg.barPadding}px 10px`,boxSizing:`border-box`,flexShrink:`0`}),this.topSection.appendChild(this.buildMobileActionsBtn()),this.el.appendChild(this.topSection),this.scrollUpBtn=document.createElement(`button`),this.applyScrollBtnStyles(this.scrollUpBtn,`up`),this.scrollUpBtn.addEventListener(`click`,()=>{this.toolsArea.scrollBy({top:-(this.cfg.iconBtnSize+this.cfg.btnGap)*3,behavior:`smooth`})}),this.el.appendChild(this.scrollUpBtn),this.toolsArea=document.createElement(`div`),Object.assign(this.toolsArea.style,{flex:`1`,overflowY:`scroll`,padding:`10px ${this.cfg.barPadding}px 4px`,boxSizing:`border-box`,scrollbarWidth:`none`,msOverflowStyle:`none`});let e=document.createElement(`style`);e.textContent=`.lb-tools::-webkit-scrollbar{display:none}`,document.head.appendChild(e),this.toolsArea.classList.add(`lb-tools`),this.toolsGrid=this.makeGrid(),this.populateCategoryGrid(this.toolsGrid),this.toolsArea.appendChild(this.toolsGrid),this.toolsArea.addEventListener(`scroll`,()=>this.updateScrollIndicators()),this.el.appendChild(this.toolsArea),this.scrollDownBtn=document.createElement(`button`),this.applyScrollBtnStyles(this.scrollDownBtn,`down`),this.scrollDownBtn.addEventListener(`click`,()=>{this.toolsArea.scrollBy({top:(this.cfg.iconBtnSize+this.cfg.btnGap)*3,behavior:`smooth`})}),this.el.appendChild(this.scrollDownBtn),requestAnimationFrame(()=>this.updateScrollIndicators())}buildMobileActionsBtn(){var e;let t=document.createElement(`button`);return t.title=this.labels.actions.moreActions,t.dataset.testid=`drawing-actions-btn`,t.innerHTML=this.cfg.actionsButtonIcon===`lock`?(e=_n.toggle_lock)==null?Nn:e:this.cfg.modernIcons?Pn:Nn,this.applyActionBtnStyles(t,!1),this.addBtnHover(t),t.addEventListener(`click`,e=>{e.stopPropagation(),this.toggleActionsFlyout(t)}),t}setEnabledGates(e){let t=new Set(e);t.size===this.enabledGates.size&&[...t].every(e=>this.enabledGates.has(e))||(this.enabledGates=t,this.closeFlyout(),this.populateCategoryGrid(this.toolsGrid))}visibleTools(e){return e.tools.filter(e=>!e.gate||this.enabledGates.has(e.gate))}populateCategoryGrid(e){this.catButtons.clear();for(let r of xi){var t,n;if(this.visibleTools(r).length===0)continue;let i=document.createElement(`button`);i.title=this.getCategoryLabel(r.id),i.innerHTML=(t=(n=(this.cfg.modernIcons?gn:hn)[r.id])==null?hn[r.id]:n)==null?r.icon:t,this.applyCatBtnStyles(i,!1),this.addBtnHover(i),i.addEventListener(`click`,e=>{e.stopPropagation(),this.toggleCategory(r,i)}),this.catButtons.set(r.id,i),e.appendChild(i)}}updateScrollIndicators(){let{scrollTop:e,scrollHeight:t,clientHeight:n}=this.toolsArea,r=e>2,i=e+n<t-2;this.mobileMode?(this.scrollUpBtn.style.display=`flex`,this.scrollDownBtn.style.display=`flex`,this.scrollUpBtn.style.opacity=r?`0.9`:`0.2`,this.scrollDownBtn.style.opacity=i?`0.9`:`0.2`):(this.scrollUpBtn.style.display=r?`flex`:`none`,this.scrollDownBtn.style.display=i?`flex`:`none`)}buildFlyout(){Object.assign(this.flyout.style,{position:`fixed`,zIndex:`9999`,display:`none`,background:this.theme.background,border:`1px solid ${this.theme.axisBorder}`,borderRadius:`6px`,padding:`6px 0`,minWidth:`200px`,boxShadow:`0 4px 16px rgba(0,0,0,0.45)`,fontFamily:this.cfg.flyoutLabelFontFamily,fontSize:this.cfg.flyoutLabelFontSize})}makeGrid(e=1){let t=document.createElement(`div`);return Object.assign(t.style,{display:`grid`,gridTemplateColumns:`repeat(${e}, ${this.cfg.iconBtnSize}px)`,gap:`${this.cfg.btnGap}px`}),t}applyScrollBtnStyles(e,t){e.innerHTML=t===`up`?jn:Mn,e.title=t===`up`?this.labels.scrollUp:this.labels.scrollDown;let n=e.style.display||`none`;Object.assign(e.style,{display:n,width:`100%`,height:`${this.cfg.scrollBtnHeight}px`,background:this.theme.background,color:this.theme.tooltip.text,border:`none`,borderBottom:t===`up`?`1px solid ${this.theme.axisBorder}`:`none`,borderTop:t===`down`?`1px solid ${this.theme.axisBorder}`:`none`,fontSize:this.cfg.scrollBtnFontSize,cursor:`pointer`,outline:`none`,alignItems:`center`,justifyContent:`center`,flexShrink:`0`,opacity:`0.6`})}toggleCategory(e,t){if(this.openCategoryId===e.id){this.closeFlyout();return}this.openCategoryId=e.id;let n=t.getBoundingClientRect();Object.assign(this.flyout.style,{display:`block`,left:`${n.right+4}px`,top:`${n.top}px`}),this.flyout.innerHTML=``;let r=document.createElement(`div`);Object.assign(r.style,{padding:`4px 12px 8px`,fontSize:this.cfg.flyoutHeadingFontSize,fontWeight:`600`,letterSpacing:this.cfg.flyoutHeadingLetterSpacing,color:this.theme.drawingToolbar.flyoutHeadingColor,textTransform:`uppercase`,borderBottom:`1px solid ${this.theme.axisBorder}`,marginBottom:`4px`,opacity:`0.6`}),r.textContent=this.getCategoryLabel(e.id),this.flyout.appendChild(r);for(let t of this.visibleTools(e)){var i,a;let n=t.id in bi,r=this.activeTool!==null&&bi[t.id]===this.activeTool,o=document.createElement(`button`);Object.assign(o.style,{width:`100%`,padding:`5px 12px`,background:r?this.theme.ui.accentBg:`transparent`,border:`none`,borderLeft:r?`2px solid ${this.theme.ui.accent}`:`2px solid transparent`,color:r?this.theme.ui.accentText:n?this.theme.drawingToolbar.flyoutLabelColor:this.theme.ui.disabledText,fontSize:this.cfg.flyoutLabelFontSize,fontFamily:this.cfg.flyoutLabelFontFamily,textAlign:`left`,cursor:n?`pointer`:`default`,display:`flex`,alignItems:`center`,gap:`8px`,boxSizing:`border-box`});let s=document.createElement(`span`);Object.assign(s.style,{width:`16px`,display:`flex`,alignItems:`center`,flexShrink:`0`}),s.innerHTML=(i=(a=xn[t.id])==null?hn[e.id]:a)==null?t.icon:i;let c=document.createElement(`span`);if(c.style.flex=`1`,c.textContent=this.getToolLabel(t),o.appendChild(s),o.appendChild(c),t.shortcut&&n){let e=document.createElement(`span`);Object.assign(e.style,{fontSize:this.cfg.shortcutFontSize,color:this.theme.ui.disabledText,flexShrink:`0`}),e.textContent=t.shortcut,o.appendChild(e)}else if(!n){let e=document.createElement(`span`);Object.assign(e.style,{fontSize:this.cfg.soonBadgeFontSize,color:this.theme.ui.soonBadgeText,flexShrink:`0`}),e.textContent=this.labels.soonBadge,o.appendChild(e)}if(n){if(!r){let e=this.theme.ui.accentBg;o.addEventListener(`mouseenter`,()=>{o.style.background=e}),o.addEventListener(`mouseleave`,()=>{o.style.background=`transparent`})}o.addEventListener(`click`,()=>{let e=bi[t.id],n=this.activeTool===e?null:e;if(this.setActiveTool(n),this.onToolChange(n),this.closeFlyout(),this.mobileMode&&n!==null){var r;this.settingsVisible=!1,this.applyWidth(),(r=this.onMobileClose)==null||r.call(this)}})}this.flyout.appendChild(o)}requestAnimationFrame(()=>{let e=this.flyout.getBoundingClientRect();e.bottom>window.innerHeight-8&&(this.flyout.style.top=`${window.innerHeight-e.height-8}px`)})}closeFlyout(){this.flyout.style.display=`none`,this.openCategoryId=null,this.openActionsMenu=!1}toggleActionsFlyout(e){if(this.openActionsMenu){this.closeFlyout();return}this.closeFlyout(),this.openActionsMenu=!0,this.flyout.innerHTML=``;let t=document.createElement(`div`);Object.assign(t.style,{padding:`4px 12px 8px`,fontSize:this.cfg.flyoutHeadingFontSize,fontWeight:`600`,letterSpacing:this.cfg.flyoutHeadingLetterSpacing,color:this.theme.drawingToolbar.flyoutHeadingColor,textTransform:`uppercase`,borderBottom:`1px solid ${this.theme.axisBorder}`,marginBottom:`4px`,opacity:`0.6`}),t.textContent=this.labels.actions.moreActions,this.flyout.appendChild(t);for(let e of Si){var n,r,i;let t=e.id===`toggle_visibility`?this.drawingsHidden:e.id===`toggle_lock`?this.drawingsLocked:!1,a=t?(n=(r=vn[e.id])==null?_n[e.id]:r)==null?e.icon:n:(i=_n[e.id])==null?e.icon:i,o=e.id===`toggle_visibility`?this.drawingsHidden?this.labels.actions.showAll:this.labels.actions.hideAll:e.id===`toggle_lock`?this.drawingsLocked?this.labels.actions.unlockAll:this.labels.actions.lockAll:this.getActionLabel(e.id),s=document.createElement(`button`);Object.assign(s.style,{width:`100%`,padding:`6px 12px`,background:t?this.theme.ui.accentBg:`transparent`,border:`none`,borderLeft:t?`2px solid ${this.theme.ui.accent}`:`2px solid transparent`,color:t?this.theme.ui.accentText:this.theme.drawingToolbar.flyoutLabelColor,fontSize:this.cfg.flyoutLabelFontSize,fontFamily:this.cfg.flyoutLabelFontFamily,textAlign:`left`,cursor:`pointer`,display:`flex`,alignItems:`center`,gap:`8px`,boxSizing:`border-box`});let c=document.createElement(`span`);Object.assign(c.style,{width:`16px`,display:`flex`,alignItems:`center`,flexShrink:`0`}),c.innerHTML=a;let l=document.createElement(`span`);l.style.flex=`1`,l.textContent=o,s.appendChild(c),s.appendChild(l);let u=this.theme.ui.accentBg;t||(s.addEventListener(`mouseenter`,()=>{s.style.background=u}),s.addEventListener(`mouseleave`,()=>{s.style.background=`transparent`})),s.addEventListener(`click`,()=>{e.id===`toggle_visibility`?(this.drawingsHidden=!this.drawingsHidden,this.onAction(this.drawingsHidden?`hide_all`:`show_all`)):e.id===`toggle_lock`?(this.drawingsLocked=!this.drawingsLocked,this.onAction(this.drawingsLocked?`lock_all`:`unlock_all`)):this.onAction(e.id),this.closeFlyout()}),this.flyout.appendChild(s)}let a=e.getBoundingClientRect(),o=this.el.getBoundingClientRect();Object.assign(this.flyout.style,{display:`block`,left:`${o.right+4}px`,top:`${a.top}px`}),requestAnimationFrame(()=>{let e=this.flyout.getBoundingClientRect();e.bottom>window.innerHeight-8&&(this.flyout.style.top=`${window.innerHeight-e.height-8}px`)})}getCategoryLabel(e){let t={trend_lines:`trendLines`,fibonacci_gann:`fibonacci`,geometric_shapes:`shapes`,measurement_tools:`measurements`,pitchfork_tools:`pitchforks`,volume_statistics:`volume`,annotation_tools:`annotations`,pattern_recognition:`patterns`,elliott_wave:`elliott`,brush_highlighter:`brushes`,advanced_tools:`advanced`,forecasting:`forecasting`,price_projections:`priceProjection`}[e];return t?this.labels.categories[t]:e}getToolLabel(e){let t=bi[e.id];return t&&this.labels.tools[t]?this.labels.tools[t]:e.name}getActionLabel(e){let t={undo:`undo`,redo:`redo`,delete_selected:`deleteSelected`,clear_all:`clearAll`,toggle_visibility:`hideAll`,toggle_lock:`lockAll`}[e];return t?this.labels.actions[t]:e}addBtnHover(e){e.addEventListener(`mouseenter`,()=>{e.dataset.active!==`true`&&(e.style.background=this.theme.ui.accentBg)}),e.addEventListener(`mouseleave`,()=>{e.dataset.active!==`true`&&(e.style.background=`transparent`)})}applyCatBtnStyles(e,t){e.dataset.active=String(t),Object.assign(e.style,{width:`${this.cfg.iconBtnSize}px`,height:`${this.cfg.iconBtnSize}px`,background:t?this.theme.ui.accentBgStrong:`transparent`,color:t?this.theme.drawingToolbar.activeIconColor:this.theme.drawingToolbar.iconColor,border:t?`1px solid ${this.theme.ui.accent}`:this.cfg.modernIcons?`1px solid transparent`:`1px solid ${this.theme.axisBorder}`,borderRadius:this.cfg.modernIcons?`6px`:`5px`,cursor:`pointer`,outline:`none`,display:`flex`,alignItems:`center`,justifyContent:`center`,padding:`0`,transition:`background 0.15s, color 0.15s`})}applyActionBtnStyles(e,t){e.dataset.active=String(t),Object.assign(e.style,{width:`${this.cfg.iconBtnSize}px`,height:`${this.cfg.iconBtnSize}px`,background:t?this.theme.ui.accentBgStrong:`transparent`,color:t?this.theme.drawingToolbar.activeIconColor:this.theme.drawingToolbar.iconColor,border:t?`1px solid ${this.theme.ui.accent}`:this.cfg.modernIcons?`1px solid transparent`:`1px solid ${this.theme.axisBorder}`,borderRadius:this.cfg.modernIcons?`6px`:`5px`,cursor:`pointer`,outline:`none`,display:`flex`,alignItems:`center`,justifyContent:`center`,padding:`0`,transition:`background 0.15s, color 0.15s`})}};function Y(e,t,n){var r,i,a,o,s,c,l,u;let d=(r=n==null||(i=n.drawing)==null?void 0:i[e])==null?{}:r,f={...d,...t==null?{}:t},p=d.levels,m=t==null?void 0:t.levels;if(p||m){let e={};for(let t of Object.keys(p==null?{}:p)){let n=p==null?void 0:p[t];n&&(e[t]=n)}if(m)for(let t of Object.keys(m)){var h;let n=m[t];if(n===null){delete e[t];continue}e[t]={...(h=e[t])==null?{visible:!0,color:`#888888`}:h,...n}}f.levels=e}return{strokeColor:(a=f.strokeColor)==null?`#888888`:a,lineWidth:(o=f.lineWidth)==null?1:o,lineStyle:(s=f.lineStyle)==null?`solid`:s,fillColor:(c=(l=f.fillColor)==null?f.strokeColor:l)==null?`#888888`:c,fillOpacity:(u=f.fillOpacity)==null?.1:u,...f.textColor!==void 0&&{textColor:f.textColor},...f.fontSize!==void 0&&{fontSize:f.fontSize},...f.levels!==void 0&&{levels:f.levels}}}function X(e,t,n){let r=Math.max(1,n);t===`dashed`?e.setLineDash([6*r,3*r]):t===`dotted`?e.setLineDash([2*r,3*r]):e.setLineDash([])}function Z(e,t){if(!e.startsWith(`#`))return e;let n=Math.round(Math.max(0,Math.min(1,t))*255).toString(16).padStart(2,`0`),r=e.slice(1);return r.length===3?r=r.split(``).map(e=>e+e).join(``):r.length===4?r=r.slice(0,3).split(``).map(e=>e+e).join(``):r.length===8&&(r=r.slice(0,6)),r.length===6?`#${r}${n}`:e}function wi(e,t,n=t.length){if(!(n<2)){if(e.moveTo(t[0].x,t[0].y),n===2){e.lineTo(t[1].x,t[1].y);return}for(let r=1;r<n-1;r++)e.quadraticCurveTo(t[r].x,t[r].y,(t[r].x+t[r+1].x)/2,(t[r].y+t[r+1].y)/2);e.lineTo(t[n-1].x,t[n-1].y)}}var Ti=6,Ei=class{constructor(e){this.type=`horizontalLine`,this.id=`hl_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e],this.complete=!0}render(e,t,n,r,i,a,o,s=2,c){let l=this.points[0].price,u=t.yToPixel(l,r,a),d=Y(`horizontalLine`,this.style,c);e.save(),e.strokeStyle=d.strokeColor,e.lineWidth=o?d.lineWidth+.5:d.lineWidth,X(e,o?`solid`:d.lineStyle,e.lineWidth),e.beginPath(),e.moveTo(0,u),e.lineTo(i,u),e.stroke(),e.setLineDash([]);let f=l.toFixed(s);e.font=`10px 'Inter', system-ui, sans-serif`;let p=e.measureText(f).width;e.fillStyle=d.strokeColor,e.fillText(f,i-p-4,u-3),e.restore()}hitTest(e,t,n,r,i,a,o){let s=n.yToPixel(this.points[0].price,i,o);return Math.abs(t-s)<=Ti}getHandle(){return null}},Di=6,Oi=class{constructor(e){this.type=`verticalLine`,this.id=`vl_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e],this.complete=!0}render(e,t,n,r,i,a,o,s,c){let l=t.xToPixel(this.points[0].barIndex,n,i),u=Y(`verticalLine`,this.style,c);e.save(),e.strokeStyle=u.strokeColor,e.lineWidth=o?u.lineWidth+.5:u.lineWidth,X(e,o?`solid`:u.lineStyle,e.lineWidth),e.beginPath(),e.moveTo(l,0),e.lineTo(l,a),e.stroke(),e.setLineDash([]),e.restore()}hitTest(e,t,n,r,i,a,o){let s=n.xToPixel(this.points[0].barIndex,r,a);return Math.abs(e-s)<=Di}getHandle(){return null}},ki=6;function Ai(e,t,n,r,i,a){let o=i-n,s=a-r,c=o*o+s*s;if(c===0)return Math.hypot(e-n,t-r);let l=Math.max(0,Math.min(1,((e-n)*o+(t-r)*s)/c));return Math.hypot(e-(n+l*o),t-(r+l*s))}var ji=class{constructor(e){this.type=`trendLine`,this.id=`tl_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let[l,u]=this.points,d=t.xToPixel(l.barIndex,n,i),f=t.yToPixel(l.price,r,a),p=t.xToPixel(u.barIndex,n,i),m=t.yToPixel(u.price,r,a),h=Y(`trendLine`,this.style,c);e.save(),e.strokeStyle=h.strokeColor,e.lineWidth=o?h.lineWidth+.5:h.lineWidth,X(e,o?`solid`:h.lineStyle,e.lineWidth),e.beginPath(),e.moveTo(d,f),e.lineTo(p,m),e.stroke(),e.setLineDash([]);for(let[t,n]of[[d,f],[p,m]])e.beginPath(),e.arc(t,n,o?4:3,0,Math.PI*2),e.fillStyle=h.strokeColor,e.fill();e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let[s,c]=this.points;return Ai(e,t,n.xToPixel(s.barIndex,r,a),n.yToPixel(s.price,i,o),n.xToPixel(c.barIndex,r,a),n.yToPixel(c.price,i,o))<=ki}getHandle(e,t,n,r,i,a,o){if(this.points.length<2)return null;let s=[{px:n.xToPixel(this.points[0].barIndex,r,a),py:n.yToPixel(this.points[0].price,i,o)},{px:n.xToPixel(this.points[1].barIndex,r,a),py:n.yToPixel(this.points[1].price,i,o)}];for(let n=0;n<s.length;n++)if(Math.hypot(e-s[n].px,t-s[n].py)<=ki+2)return{pointIndex:n,cursor:`grab`};return null}},Mi=6;function Ni(e,t,n,r,i,a){let o=i-n,s=a-r,c=o*o+s*s;if(c===0)return Math.hypot(e-n,t-r);let l=Math.max(0,Math.min(1,((e-n)*o+(t-r)*s)/c));return Math.hypot(e-(n+l*o),t-(r+l*s))}var Pi=class{constructor(e){this.type=`trendAngle`,this.id=`ta_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let[l,u]=this.points,d=t.xToPixel(l.barIndex,n,i),f=t.yToPixel(l.price,r,a),p=t.xToPixel(u.barIndex,n,i),m=t.yToPixel(u.price,r,a),h=Math.atan2(-(m-f),p-d)*180/Math.PI,g=Math.atan2(-(m-f),p-d),_=Y(`trendAngle`,this.style,c);e.save(),e.strokeStyle=_.strokeColor,e.fillStyle=_.strokeColor,e.lineWidth=o?_.lineWidth+.5:_.lineWidth,X(e,o?`solid`:_.lineStyle,e.lineWidth),e.beginPath(),e.moveTo(d,f),e.lineTo(p,m),e.stroke(),e.beginPath(),e.arc(d,f,28,-g,0,g<0),e.stroke(),e.setLineDash([4,3]),e.globalAlpha=.5,e.beginPath(),e.moveTo(d,f),e.lineTo(d+28+8,f),e.stroke(),e.setLineDash([]),e.globalAlpha=1;let v=d+28+6,y=f-(g>=0?6:-14);if(e.font=`bold 11px 'Inter', system-ui, sans-serif`,e.fillText(`${h.toFixed(1)}°`,v,y),o)for(let[t,n]of[[d,f],[p,m]])e.beginPath(),e.arc(t,n,4,0,Math.PI*2),e.fill();e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let[s,c]=this.points;return Ni(e,t,n.xToPixel(s.barIndex,r,a),n.yToPixel(s.price,i,o),n.xToPixel(c.barIndex,r,a),n.yToPixel(c.price,i,o))<=Mi}getHandle(e,t,n,r,i,a,o){if(this.points.length<2)return null;let s=[{px:n.xToPixel(this.points[0].barIndex,r,a),py:n.yToPixel(this.points[0].price,i,o)},{px:n.xToPixel(this.points[1].barIndex,r,a),py:n.yToPixel(this.points[1].price,i,o)}];for(let n=0;n<s.length;n++)if(Math.hypot(e-s[n].px,t-s[n].py)<=Mi+2)return{pointIndex:n,cursor:`grab`};return null}},Fi=6,Ii=class{constructor(e){this.type=`crossLine`,this.id=`xl_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e],this.complete=!0}render(e,t,n,r,i,a,o,s,c){let l=this.points[0],u=t.xToPixel(l.barIndex,n,i),d=t.yToPixel(l.price,r,a),f=Y(`crossLine`,this.style,c);e.save(),e.strokeStyle=f.strokeColor,e.lineWidth=o?f.lineWidth+.5:f.lineWidth,X(e,o?`solid`:f.lineStyle,e.lineWidth),e.beginPath(),e.moveTo(0,d),e.lineTo(i,d),e.stroke(),e.beginPath(),e.moveTo(u,0),e.lineTo(u,a),e.stroke(),e.setLineDash([]),e.restore()}hitTest(e,t,n,r,i,a,o){let s=this.points[0],c=n.xToPixel(s.barIndex,r,a),l=n.yToPixel(s.price,i,o);return Math.abs(t-l)<=Fi||Math.abs(e-c)<=Fi}getHandle(){return null}},Li=6;function Ri(e,t,n,r,i,a){let o=i-n,s=a-r,c=o*o+s*s;if(c===0)return Math.hypot(e-n,t-r);let l=Math.max(0,Math.min(1,((e-n)*o+(t-r)*s)/c));return Math.hypot(e-(n+l*o),t-(r+l*s))}var zi=class{constructor(e){this.type=`parallelChannel`,this.requiredPoints=3,this.id=`pch_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let[l,u,d]=this.points,f=t.xToPixel(l.barIndex,n,i),p=t.yToPixel(l.price,r,a),m=t.xToPixel(u.barIndex,n,i),h=t.yToPixel(u.price,r,a),g=0;if(d){let e=(l.price+u.price)/2,n=t.yToPixel(e,r,a);g=t.yToPixel(d.price,r,a)-n}let _=f,v=p+g,y=m,b=h+g,x=Y(`parallelChannel`,this.style,c);if(e.save(),e.strokeStyle=x.strokeColor,e.lineWidth=o?x.lineWidth+.5:x.lineWidth,X(e,o?`solid`:x.lineStyle,e.lineWidth),e.beginPath(),e.moveTo(f,p),e.lineTo(m,h),e.lineTo(y,b),e.lineTo(_,v),e.closePath(),e.fillStyle=Z(x.fillColor,x.fillOpacity),e.fill(),e.beginPath(),e.moveTo(f,p),e.lineTo(m,h),e.stroke(),d&&(e.beginPath(),e.moveTo(_,v),e.lineTo(y,b),e.stroke()),e.setLineDash([]),o){let o=[[f,p],[m,h]];if(d){let e=t.xToPixel(d.barIndex,n,i),s=t.yToPixel(d.price,r,a);o.push([e,s])}e.fillStyle=x.strokeColor;for(let[t,n]of o)e.beginPath(),e.arc(t,n,4,0,Math.PI*2),e.fill()}e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let[s,c,l]=this.points,u=n.xToPixel(s.barIndex,r,a),d=n.yToPixel(s.price,i,o),f=n.xToPixel(c.barIndex,r,a),p=n.yToPixel(c.price,i,o);if(Ri(e,t,u,d,f,p)<=Li)return!0;if(l){let r=(s.price+c.price)/2,a=n.yToPixel(r,i,o),m=n.yToPixel(l.price,i,o)-a;if(Ri(e,t,u,d+m,f,p+m)<=Li)return!0}return!1}getHandle(e,t,n,r,i,a,o){let s=this.points.map((e,t)=>({i:t,px:n.xToPixel(e.barIndex,r,a),py:n.yToPixel(e.price,i,o)}));for(let{i:n,px:r,py:i}of s)if(Math.hypot(e-r,t-i)<=Li+2)return{pointIndex:n,cursor:`grab`};return null}},Bi=6;function Vi(e,t,n,r,i,a){let o=i-n,s=a-r,c=o*o+s*s;if(c===0)return Math.hypot(e-n,t-r);let l=Math.max(0,Math.min(1,((e-n)*o+(t-r)*s)/c));return Math.hypot(e-(n+l*o),t-(r+l*s))}var Hi=class{constructor(e){this.type=`flatChannel`,this.requiredPoints=3,this.id=`fch_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let[l,u,d]=this.points,f=t.xToPixel(l.barIndex,n,i),p=t.xToPixel(u.barIndex,n,i),m=t.yToPixel(l.price,r,a),h=d?d.price-l.price:0,g=t.yToPixel(l.price+h,r,a),_=Y(`flatChannel`,this.style,c);if(e.save(),e.strokeStyle=_.strokeColor,e.lineWidth=o?_.lineWidth+.5:_.lineWidth,X(e,o?`solid`:_.lineStyle,e.lineWidth),e.beginPath(),e.rect(Math.min(f,p),Math.min(m,g),Math.abs(p-f),Math.abs(g-m)),e.fillStyle=Z(_.fillColor,_.fillOpacity),e.fill(),e.beginPath(),e.moveTo(f,m),e.lineTo(p,m),e.stroke(),d&&(e.beginPath(),e.moveTo(f,g),e.lineTo(p,g),e.stroke()),e.setLineDash([]),o){e.fillStyle=_.strokeColor;let o=[[f,m],[p,m]];if(d){let e=t.xToPixel(d.barIndex,n,i),s=t.yToPixel(d.price,r,a);o.push([e,s])}for(let[t,n]of o)e.beginPath(),e.arc(t,n,4,0,Math.PI*2),e.fill()}e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let[s,c,l]=this.points,u=n.xToPixel(s.barIndex,r,a),d=n.xToPixel(c.barIndex,r,a),f=n.yToPixel(s.price,i,o);if(Vi(e,t,u,f,d,f)<=Bi)return!0;if(l){let r=l.price-s.price,a=n.yToPixel(s.price+r,i,o);if(Vi(e,t,u,a,d,a)<=Bi)return!0}return!1}getHandle(e,t,n,r,i,a,o){let s=this.points.map((e,t)=>({i:t,px:n.xToPixel(e.barIndex,r,a),py:n.yToPixel(e.price,i,o)}));for(let{i:n,px:r,py:i}of s)if(Math.hypot(e-r,t-i)<=Bi+2)return{pointIndex:n,cursor:`grab`};return null}},Ui=6;function Wi(e,t,n,r,i,a){let o=i-n,s=a-r,c=o*o+s*s;if(c===0)return Math.hypot(e-n,t-r);let l=Math.max(0,Math.min(1,((e-n)*o+(t-r)*s)/c));return Math.hypot(e-(n+l*o),t-(r+l*s))}var Gi=class{constructor(e){this.type=`disjointChannel`,this.requiredPoints=4,this.id=`dch_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let l=e=>[t.xToPixel(e.barIndex,n,i),t.yToPixel(e.price,r,a)],[u,d,f,p]=this.points,[m,h]=l(u),[g,_]=l(d),v=Y(`disjointChannel`,this.style,c);if(e.save(),e.strokeStyle=v.strokeColor,e.lineWidth=o?v.lineWidth+.5:v.lineWidth,X(e,o?`solid`:v.lineStyle,e.lineWidth),f&&p){let[t,n]=l(f),[r,i]=l(p);if(e.beginPath(),e.moveTo(m,h),e.lineTo(g,_),e.lineTo(r,i),e.lineTo(t,n),e.closePath(),e.fillStyle=Z(v.fillColor,v.fillOpacity),e.fill(),e.beginPath(),e.moveTo(m,h),e.lineTo(g,_),e.stroke(),e.beginPath(),e.moveTo(t,n),e.lineTo(r,i),e.stroke(),e.setLineDash([]),o){e.fillStyle=v.strokeColor;for(let[a,o]of[[m,h],[g,_],[t,n],[r,i]])e.beginPath(),e.arc(a,o,4,0,Math.PI*2),e.fill()}}else if(f){let[t,n]=l(f);if(e.beginPath(),e.moveTo(m,h),e.lineTo(g,_),e.stroke(),e.beginPath(),e.moveTo(t,n),e.lineTo(t,n),e.stroke(),e.setLineDash([]),o){e.fillStyle=v.strokeColor;for(let[r,i]of[[m,h],[g,_],[t,n]])e.beginPath(),e.arc(r,i,4,0,Math.PI*2),e.fill()}}else if(e.beginPath(),e.moveTo(m,h),e.lineTo(g,_),e.stroke(),e.setLineDash([]),o){e.fillStyle=v.strokeColor;for(let[t,n]of[[m,h],[g,_]])e.beginPath(),e.arc(t,n,4,0,Math.PI*2),e.fill()}e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let s=e=>[n.xToPixel(e.barIndex,r,a),n.yToPixel(e.price,i,o)],[c,l,u,d]=this.points,[f,p]=s(c),[m,h]=s(l);if(Wi(e,t,f,p,m,h)<=Ui)return!0;if(u&&d){let[n,r]=s(u),[i,a]=s(d);if(Wi(e,t,n,r,i,a)<=Ui)return!0}return!1}getHandle(e,t,n,r,i,a,o){let s=this.points.map((e,t)=>({i:t,px:n.xToPixel(e.barIndex,r,a),py:n.yToPixel(e.price,i,o)}));for(let{i:n,px:r,py:i}of s)if(Math.hypot(e-r,t-i)<=Ui+2)return{pointIndex:n,cursor:`grab`};return null}},Ki=[0,.236,.382,.5,.618,.786,1],qi=[`#ef5350`,`#e8b84b`,`#26a69a`,`#2196f3`,`#26a69a`,`#e8b84b`,`#ef5350`],Ji=6;function Yi(e,t,n){return t+(e-t)*n}function Xi(e){let t=()=>Ki.map(e=>({key:String(e),value:e}));if(!e)return t();let n=Object.keys(e).filter(t=>e[t]!==null).map(e=>({key:e,value:Number(e)})).filter(e=>Number.isFinite(e.value));return n.length?n.sort((e,t)=>e.value-t.value):t()}var Zi=class{constructor(e){this.type=`fibRetracement`,this.id=`fib_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s=2,c){var l;if(this.points.length<2)return;let[u,d]=this.points,f=t.xToPixel(u.barIndex,n,i),p=t.yToPixel(u.price,r,a),m=t.xToPixel(d.barIndex,n,i),h=t.yToPixel(d.price,r,a),g=Math.min(f,m),_=Math.max(f,m),v=Y(`fibRetracement`,this.style,c),y=o?v.lineWidth+.5:v.lineWidth,b=(l=v.strokeColor)==null?qi[1]:l;e.save(),e.font=`10px 'Inter', system-ui, sans-serif`,e.lineWidth=y;let x=Xi(v.levels),S=[];for(let n=0;n<x.length;n++){var C,w,T;let{key:i,value:c}=x[n],l=(C=v.levels)==null?void 0:C[i];if((l==null?void 0:l.visible)===!1)continue;S.push(c);let f=Yi(u.price,d.price,c),p=t.yToPixel(f,r,a),m=Z((w=(T=l==null?void 0:l.color)==null?v.strokeColor:T)==null?qi[n%qi.length]:w,o?.8:.6);e.strokeStyle=m,X(e,o?`solid`:v.lineStyle,y),e.beginPath(),e.moveTo(g,p),e.lineTo(_,p),e.stroke(),e.setLineDash([]);let h=`${`${(c*100).toFixed(1)}%`} ${f.toFixed(s)}`;e.fillStyle=m,e.fillText(h,g+4,p-3)}this.visibleLevels=S;for(let[t,n]of[[f,p],[m,h]])e.beginPath(),e.arc(t,n,o?4:3,0,Math.PI*2),e.fillStyle=b,e.fill();e.restore()}hitTest(e,t,n,r,i,a,o){var s;if(this.points.length<2)return!1;for(let e of(s=this.visibleLevels)==null?Ki:s){let r=Yi(this.points[0].price,this.points[1].price,e),a=n.yToPixel(r,i,o);if(Math.abs(t-a)<=Ji)return!0}return!1}getHandle(e,t,n,r,i,a,o){if(this.points.length<2)return null;let s=[{px:n.xToPixel(this.points[0].barIndex,r,a),py:n.yToPixel(this.points[0].price,i,o)},{px:n.xToPixel(this.points[1].barIndex,r,a),py:n.yToPixel(this.points[1].price,i,o)}];for(let n=0;n<s.length;n++)if(Math.hypot(e-s[n].px,t-s[n].py)<=Ji+2)return{pointIndex:n,cursor:`grab`};return null}},Qi=6,$i=[0,.382,.618,1,1.382,1.618,2,2.618],ea=[`#ef5350`,`#e8b84b`,`#26a69a`,`#2196f3`,`#26a69a`,`#e8b84b`,`#ef5350`,`#ef5350`],ta=class{constructor(e){this.type=`fibExtension`,this.requiredPoints=3,this.id=`fext_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s=2,c){var l,u;let[d,f,p]=this.points,m=t.xToPixel(d.barIndex,n,i),h=t.yToPixel(d.price,r,a),g=t.xToPixel(f.barIndex,n,i),_=t.yToPixel(f.price,r,a),v=Y(`fibExtension`,this.style,c),y=(l=v.strokeColor)==null?`#e8b84b`:l,b=Z((u=v.strokeColor)==null?`#888888`:u,.67);if(!p){e.save(),e.strokeStyle=b,e.lineWidth=1,e.setLineDash([4,3]),e.beginPath(),e.moveTo(m,h),e.lineTo(g,_),e.stroke(),e.setLineDash([]),e.fillStyle=y,e.beginPath(),e.arc(m,h,3,0,Math.PI*2),e.fill(),e.restore();return}let x=t.xToPixel(p.barIndex,n,i),S=t.yToPixel(p.price,r,a),C=Math.min(m,g,x),w=Math.max(m,g,x),T=f.price-d.price,E=o?v.lineWidth+.5:v.lineWidth;e.save(),e.font=`10px 'Inter', system-ui, sans-serif`,e.lineWidth=E,e.strokeStyle=b,e.setLineDash([4,3]),e.beginPath(),e.moveTo(m,h),e.lineTo(g,_),e.stroke(),e.beginPath(),e.moveTo(g,_),e.lineTo(x,S),e.stroke(),e.setLineDash([]);for(let n=0;n<$i.length;n++){var D,O,k;let i=$i[n],c=String(i),l=(D=v.levels)==null?void 0:D[c];if((l==null?void 0:l.visible)===!1)continue;let u=p.price+i*T,d=t.yToPixel(u,r,a),f=Z((O=(k=l==null?void 0:l.color)==null?v.strokeColor:k)==null?ea[n]:O,o?.8:.6);e.strokeStyle=f,X(e,o?`solid`:v.lineStyle,E),e.beginPath(),e.moveTo(C,d),e.lineTo(w,d),e.stroke(),e.setLineDash([]);let m=`${`${(i*100).toFixed(1)}%`} ${u.toFixed(s)}`;e.fillStyle=f,e.fillText(m,C+4,d-3)}for(let[t,n]of[[m,h],[g,_],[x,S]])e.beginPath(),e.arc(t,n,o?4:3,0,Math.PI*2),e.fillStyle=y,e.fill();e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<3)return!1;let[s,c,l]=this.points,u=c.price-s.price;for(let e of $i){let r=l.price+e*u,a=n.yToPixel(r,i,o);if(Math.abs(t-a)<=Qi)return!0}return!1}getHandle(e,t,n,r,i,a,o){if(this.points.length<3)return null;let s=this.points.map(e=>({px:n.xToPixel(e.barIndex,r,a),py:n.yToPixel(e.price,i,o)}));for(let n=0;n<s.length;n++)if(Math.hypot(e-s[n].px,t-s[n].py)<=Qi+2)return{pointIndex:n,cursor:`grab`};return null}},na=6,ra=[0,.236,.382,.5,.618,.786,1];function ia(e,t,n,r,i,a){let o=i-n,s=a-r,c=o*o+s*s;if(c===0)return Math.hypot(e-n,t-r);let l=Math.max(0,Math.min(1,((e-n)*o+(t-r)*s)/c));return Math.hypot(e-(n+l*o),t-(r+l*s))}var aa=class{constructor(e){this.type=`fibChannel`,this.requiredPoints=3,this.id=`fchann_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s=2,c){let[l,u,d]=this.points,f=t.xToPixel(l.barIndex,n,i),p=t.yToPixel(l.price,r,a),m=t.xToPixel(u.barIndex,n,i),h=t.yToPixel(u.price,r,a),g=Y(`fibChannel`,this.style,c),_=Z(g.strokeColor,.67);if(!d){e.save(),e.strokeStyle=_,e.lineWidth=1,e.setLineDash([4,3]),e.beginPath(),e.moveTo(f,p),e.lineTo(m,h),e.stroke(),e.setLineDash([]),e.fillStyle=g.strokeColor,e.beginPath(),e.arc(f,p,3,0,Math.PI*2),e.fill(),e.restore();return}let v=t.xToPixel(d.barIndex,n,i),y=t.yToPixel(d.price,r,a),b=m-f,x=h-p,S=Math.hypot(b,x);if(S===0)return;let C=-x/S,w=b/S,T=(v-f)*C+(y-p)*w,E=o?g.lineWidth+.5:g.lineWidth;e.save(),e.font=`10px 'Inter', system-ui, sans-serif`,e.lineWidth=E;for(let t=0;t<ra.length;t++){let n=ra[t],r=n*T,i=f+r*C,a=p+r*w,s=m+r*C,c=h+r*w,l=Z(g.strokeColor,o?.8:.6);e.strokeStyle=l,X(e,o?`solid`:g.lineStyle,E),e.beginPath(),e.moveTo(i,a),e.lineTo(s,c),e.stroke(),e.setLineDash([]);let u=`${(n*100).toFixed(1)}%`;e.fillStyle=l,e.fillText(u,s+4,c+3)}e.beginPath(),e.arc(v,y,o?4:3,0,Math.PI*2),e.fillStyle=g.strokeColor,e.fill();for(let[t,n]of[[f,p],[m,h]])e.beginPath(),e.arc(t,n,o?4:3,0,Math.PI*2),e.fillStyle=g.strokeColor,e.fill();e.strokeStyle=_,e.setLineDash([3,3]),e.beginPath(),e.moveTo(f,p),e.lineTo(v,y),e.stroke(),e.setLineDash([]),e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<3)return!1;let[s,c,l]=this.points,u=n.xToPixel(s.barIndex,r,a),d=n.yToPixel(s.price,i,o),f=n.xToPixel(c.barIndex,r,a),p=n.yToPixel(c.price,i,o),m=n.xToPixel(l.barIndex,r,a),h=n.yToPixel(l.price,i,o),g=f-u,_=p-d,v=Math.hypot(g,_);if(v===0)return!1;let y=-_/v,b=g/v,x=(m-u)*y+(h-d)*b;for(let n of ra){let r=n*x;if(ia(e,t,u+r*y,d+r*b,f+r*y,p+r*b)<=na)return!0}return!1}getHandle(e,t,n,r,i,a,o){if(this.points.length<3)return null;let s=this.points.map(e=>({px:n.xToPixel(e.barIndex,r,a),py:n.yToPixel(e.price,i,o)}));for(let n=0;n<s.length;n++)if(Math.hypot(e-s[n].px,t-s[n].py)<=na+2)return{pointIndex:n,cursor:`grab`};return null}},oa=6,sa=[1,2,3,5,8,13,21,34,55,89],ca=class{constructor(e){this.type=`fibTimezone`,this.id=`ftz_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let[l,u]=this.points,d=u.barIndex-l.barIndex,f=t.xToPixel(l.barIndex,n,i),p=t.xToPixel(u.barIndex,n,i),m=Y(`fibTimezone`,this.style,c),h=o?m.lineWidth+.5:m.lineWidth,g=Z(m.strokeColor,o?.8:.53);e.save(),e.font=`10px 'Inter', system-ui, sans-serif`,e.lineWidth=h,e.strokeStyle=g,X(e,o?`solid`:m.lineStyle,h),e.beginPath(),e.moveTo(f,0),e.lineTo(f,a),e.stroke(),e.beginPath(),e.moveTo(p,0),e.lineTo(p,a),e.stroke(),e.setLineDash([]);for(let r of sa){let s=l.barIndex+r*d,c=t.xToPixel(s,n,i);c<-50||c>i+50||(e.strokeStyle=g,X(e,o?`solid`:m.lineStyle,h),e.beginPath(),e.moveTo(c,0),e.lineTo(c,a),e.stroke(),e.setLineDash([]),e.fillStyle=g,e.fillText(String(r),c+3,12))}let _=t.yToPixel(l.price,r,a),v=t.yToPixel(u.price,r,a);for(let[t,n]of[[f,_],[p,v]])e.beginPath(),e.arc(t,n,o?4:3,0,Math.PI*2),e.fillStyle=m.strokeColor,e.fill();e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let[s,c]=this.points,l=c.barIndex-s.barIndex,u=n.xToPixel(s.barIndex,r,a);if(Math.abs(e-u)<=oa)return!0;for(let t of sa){let i=s.barIndex+t*l,o=n.xToPixel(i,r,a);if(Math.abs(e-o)<=oa)return!0}return!1}getHandle(e,t,n,r,i,a,o){if(this.points.length<2)return null;let s=[{px:n.xToPixel(this.points[0].barIndex,r,a),py:n.yToPixel(this.points[0].price,i,o)},{px:n.xToPixel(this.points[1].barIndex,r,a),py:n.yToPixel(this.points[1].price,i,o)}];for(let n=0;n<s.length;n++)if(Math.hypot(e-s[n].px,t-s[n].py)<=oa+2)return{pointIndex:n,cursor:`grab`};return null}},la=6,ua=[.236,.382,.5,.618,.786,1,1.618,2.618],da=class{constructor(e){this.type=`fibCircles`,this.id=`fcirc_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let[l,u]=this.points,d=t.xToPixel(l.barIndex,n,i),f=t.yToPixel(l.price,r,a),p=t.xToPixel(u.barIndex,n,i),m=t.yToPixel(u.price,r,a),h=Math.hypot(p-d,m-f),g=Y(`fibCircles`,this.style,c),_=o?g.lineWidth+.5:g.lineWidth;e.save(),e.font=`10px 'Inter', system-ui, sans-serif`,e.lineWidth=_;for(let t=0;t<ua.length;t++){let n=ua[t],r=n*h,i=Z(g.strokeColor,o?.8:.53);e.strokeStyle=i,X(e,o?`solid`:g.lineStyle,_),e.beginPath(),e.arc(d,f,r,0,Math.PI*2),e.stroke(),e.setLineDash([]),e.fillStyle=i,e.fillText(`${(n*100).toFixed(1)}%`,d+3,f-r+12)}e.beginPath(),e.arc(d,f,o?4:3,0,Math.PI*2),e.fillStyle=g.strokeColor,e.fill(),e.beginPath(),e.arc(p,m,o?4:3,0,Math.PI*2),e.fillStyle=g.strokeColor,e.fill(),e.strokeStyle=Z(g.strokeColor,.4),e.setLineDash([3,3]),e.beginPath(),e.moveTo(d,f),e.lineTo(p,m),e.stroke(),e.setLineDash([]),e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let[s,c]=this.points,l=n.xToPixel(s.barIndex,r,a),u=n.yToPixel(s.price,i,o),d=n.xToPixel(c.barIndex,r,a),f=n.yToPixel(c.price,i,o),p=Math.hypot(d-l,f-u),m=Math.hypot(e-l,t-u);for(let e of ua){let t=e*p;if(Math.abs(m-t)<=la)return!0}return!1}getHandle(e,t,n,r,i,a,o){if(this.points.length<2)return null;let s=n.xToPixel(this.points[0].barIndex,r,a),c=n.yToPixel(this.points[0].price,i,o),l=n.xToPixel(this.points[1].barIndex,r,a),u=n.yToPixel(this.points[1].price,i,o);return Math.hypot(e-s,t-c)<=la+2?{pointIndex:0,cursor:`move`}:Math.hypot(e-l,t-u)<=la+2?{pointIndex:1,cursor:`grab`}:null}},fa=6,pa=[1,1,2,3,5,8,13,21],ma=class{constructor(e){this.type=`fibSpiral`,this.id=`fspi_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}computeArcs(e,t,n,r){let i=Math.hypot(n,r)/pa[pa.length-1],a=Math.atan2(r,n),o=[],s=e,c=t,l=a;for(let e=pa.length-1;e>=0;e--){let t=pa[e]*i,n=l+Math.PI,r=n+Math.PI/2;if(o.unshift({ox:s,oy:c,r:t,startAngle:n,endAngle:r}),e>0){let n=pa[e-1]*i,r=l-Math.PI/2;s+=(t-n)*Math.cos(r),c+=(t-n)*Math.sin(r),l-=Math.PI/2}}return o}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let[l,u]=this.points,d=t.xToPixel(l.barIndex,n,i),f=t.yToPixel(l.price,r,a),p=t.xToPixel(u.barIndex,n,i),m=t.yToPixel(u.price,r,a),h=p-d,g=m-f,_=Y(`fibSpiral`,this.style,c),v=o?_.lineWidth+.5:_.lineWidth;e.save(),e.font=`10px 'Inter', system-ui, sans-serif`,e.strokeStyle=Z(_.strokeColor,o?.8:.53),e.lineWidth=v,X(e,o?`solid`:_.lineStyle,v);let y=this.computeArcs(d,f,h,g);e.beginPath();for(let t=0;t<y.length;t++){let n=y[t];if(t===0){let t=n.ox+n.r*Math.cos(n.startAngle),r=n.oy+n.r*Math.sin(n.startAngle);e.moveTo(t,r)}e.arc(n.ox,n.oy,n.r,n.startAngle,n.endAngle,!1)}e.stroke(),e.setLineDash([]),e.beginPath(),e.arc(d,f,o?4:3,0,Math.PI*2),e.fillStyle=_.strokeColor,e.fill(),e.beginPath(),e.arc(p,m,o?4:3,0,Math.PI*2),e.fillStyle=_.strokeColor,e.fill(),e.strokeStyle=Z(_.strokeColor,.4),e.setLineDash([3,3]),e.beginPath(),e.moveTo(d,f),e.lineTo(p,m),e.stroke(),e.setLineDash([]),e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let[s,c]=this.points,l=n.xToPixel(s.barIndex,r,a),u=n.yToPixel(s.price,i,o),d=n.xToPixel(c.barIndex,r,a),f=n.yToPixel(c.price,i,o),p=d-l,m=f-u,h=this.computeArcs(l,u,p,m);for(let n of h){let r=n.endAngle-n.startAngle;for(let i=0;i<=16;i++){let a=i/16,o=n.startAngle+a*r,s=n.ox+n.r*Math.cos(o),c=n.oy+n.r*Math.sin(o);if(Math.hypot(e-s,t-c)<=fa)return!0}}return!1}getHandle(e,t,n,r,i,a,o){if(this.points.length<2)return null;let s=n.xToPixel(this.points[0].barIndex,r,a),c=n.yToPixel(this.points[0].price,i,o),l=n.xToPixel(this.points[1].barIndex,r,a),u=n.yToPixel(this.points[1].price,i,o);return Math.hypot(e-s,t-c)<=fa+2?{pointIndex:0,cursor:`move`}:Math.hypot(e-l,t-u)<=fa+2?{pointIndex:1,cursor:`grab`}:null}},ha=6,ga=[.236,.382,.5,.618,.786];function _a(e,t,n,r,i,a){let o=i-n,s=a-r,c=o*o+s*s;if(c===0)return Math.hypot(e-n,t-r);let l=Math.max(0,Math.min(1,((e-n)*o+(t-r)*s)/c));return Math.hypot(e-(n+l*o),t-(r+l*s))}function va(e,t,n,r,i,a){let o=n-e,s=r-t;if(o===0&&s===0)return[n,r];let c=1/0;return o>0&&(c=Math.min(c,(i-e)/o)),o<0&&(c=Math.min(c,(0-e)/o)),s>0&&(c=Math.min(c,(a-t)/s)),s<0&&(c=Math.min(c,(0-t)/s)),[e+c*o,t+c*s]}var ya=class{constructor(e){this.type=`fibFan`,this.id=`ffan_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let[l,u]=this.points,d=t.xToPixel(l.barIndex,n,i),f=t.yToPixel(l.price,r,a),p=t.xToPixel(u.barIndex,n,i),m=t.yToPixel(u.price,r,a),h=Y(`fibFan`,this.style,c),g=o?h.lineWidth+.5:h.lineWidth;e.save(),e.font=`10px 'Inter', system-ui, sans-serif`,e.lineWidth=g,e.strokeStyle=Z(h.strokeColor,.67),e.setLineDash([4,3]),e.beginPath(),e.moveTo(d,f),e.lineTo(p,m),e.stroke(),e.setLineDash([]);let _=u.price-l.price;for(let n=0;n<ga.length;n++){let s=ga[n],c=Z(h.strokeColor,o?.8:.6),u=l.price+s*_,[m,v]=va(d,f,p,t.yToPixel(u,r,a),i,a);e.strokeStyle=c,X(e,o?`solid`:h.lineStyle,g),e.beginPath(),e.moveTo(d,f),e.lineTo(m,v),e.stroke(),e.setLineDash([]),e.fillStyle=c,e.fillText(`${(s*100).toFixed(1)}%`,Math.min(m-32,i-40),v-3)}for(let[t,n]of[[d,f],[p,m]])e.beginPath(),e.arc(t,n,o?4:3,0,Math.PI*2),e.fillStyle=h.strokeColor,e.fill();e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let[s,c]=this.points,l=n.xToPixel(s.barIndex,r,a),u=n.yToPixel(s.price,i,o),d=n.xToPixel(c.barIndex,r,a),f=c.price-s.price;for(let r of ga){let c=s.price+r*f,[p,m]=va(l,u,d,n.yToPixel(c,i,o),a,o);if(_a(e,t,l,u,p,m)<=ha)return!0}return!1}getHandle(e,t,n,r,i,a,o){if(this.points.length<2)return null;let s=[{px:n.xToPixel(this.points[0].barIndex,r,a),py:n.yToPixel(this.points[0].price,i,o)},{px:n.xToPixel(this.points[1].barIndex,r,a),py:n.yToPixel(this.points[1].price,i,o)}];for(let n=0;n<s.length;n++)if(Math.hypot(e-s[n].px,t-s[n].py)<=ha+2)return{pointIndex:n,cursor:`grab`};return null}},ba=6,xa=[0,.618,1,1.272,1.618,2,2.618],Sa=[`#ef5350`,`#26a69a`,`#2196f3`,`#26a69a`,`#e8b84b`,`#ef5350`,`#ef5350`],Ca=class{constructor(e){this.type=`fibProjection`,this.requiredPoints=3,this.id=`fproj_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s=2,c){var l,u;let[d,f,p]=this.points,m=t.xToPixel(d.barIndex,n,i),h=t.yToPixel(d.price,r,a),g=t.xToPixel(f.barIndex,n,i),_=t.yToPixel(f.price,r,a),v=Y(`fibProjection`,this.style,c),y=(l=v.strokeColor)==null?`#e8b84b`:l,b=Z((u=v.strokeColor)==null?`#888888`:u,.67);if(!p){e.save(),e.strokeStyle=b,e.lineWidth=1,e.setLineDash([4,3]),e.beginPath(),e.moveTo(m,h),e.lineTo(g,_),e.stroke(),e.setLineDash([]),e.fillStyle=y,e.beginPath(),e.arc(m,h,3,0,Math.PI*2),e.fill(),e.restore();return}let x=t.xToPixel(p.barIndex,n,i),S=t.yToPixel(p.price,r,a),C=Math.min(m,x),w=Math.max(m,x),T=f.price-d.price,E=o?v.lineWidth+.5:v.lineWidth;e.save(),e.font=`10px 'Inter', system-ui, sans-serif`,e.lineWidth=E,e.strokeStyle=b,e.setLineDash([4,3]),e.beginPath(),e.moveTo(m,h),e.lineTo(g,_),e.stroke(),e.beginPath(),e.moveTo(g,_),e.lineTo(x,S),e.stroke(),e.setLineDash([]);for(let n=0;n<xa.length;n++){var D,O,k;let i=xa[n],c=String(i),l=(D=v.levels)==null?void 0:D[c];if((l==null?void 0:l.visible)===!1)continue;let u=p.price+i*T,d=t.yToPixel(u,r,a),f=Z((O=(k=l==null?void 0:l.color)==null?v.strokeColor:k)==null?Sa[n]:O,o?.8:.6);e.strokeStyle=f,X(e,o?`solid`:v.lineStyle,E),e.beginPath(),e.moveTo(C,d),e.lineTo(w,d),e.stroke(),e.setLineDash([]);let m=`${`${(i*100).toFixed(1)}%`} ${u.toFixed(s)}`;e.fillStyle=f,e.fillText(m,C+4,d-3)}for(let[t,n]of[[m,h],[g,_],[x,S]])e.beginPath(),e.arc(t,n,o?4:3,0,Math.PI*2),e.fillStyle=y,e.fill();e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<3)return!1;let[s,c,l]=this.points,u=c.price-s.price;for(let e of xa){let r=l.price+e*u,a=n.yToPixel(r,i,o);if(Math.abs(t-a)<=ba)return!0}return!1}getHandle(e,t,n,r,i,a,o){if(this.points.length<3)return null;let s=this.points.map(e=>({px:n.xToPixel(e.barIndex,r,a),py:n.yToPixel(e.price,i,o)}));for(let n=0;n<s.length;n++)if(Math.hypot(e-s[n].px,t-s[n].py)<=ba+2)return{pointIndex:n,cursor:`grab`};return null}},wa=6;function Ta(e,t,n,r,i,a){let o=i-n,s=a-r,c=o*o+s*s;if(c===0)return Math.hypot(e-n,t-r);let l=Math.max(0,Math.min(1,((e-n)*o+(t-r)*s)/c));return Math.hypot(e-(n+l*o),t-(r+l*s))}var Ea=[[1,8,`1:8`],[1,4,`1:4`],[1,3,`1:3`],[1,2,`1:2`],[1,1,`1:1`],[2,1,`2:1`],[3,1,`3:1`],[4,1,`4:1`],[8,1,`8:1`]],Da=class{constructor(e){this.type=`gannFan`,this.id=`gfan_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let[l,u]=this.points,d=t.xToPixel(l.barIndex,n,i),f=t.yToPixel(l.price,r,a),p=t.xToPixel(u.barIndex,n,i),m=t.yToPixel(u.price,r,a),h=Math.abs(p-d)||1,g=m-f,_=p>d?1:-1,v=Y(`gannFan`,this.style,c);e.save(),e.font=`10px 'Inter', system-ui, sans-serif`,e.lineWidth=o?v.lineWidth+.5:v.lineWidth,X(e,o?`solid`:v.lineStyle,e.lineWidth),Ea.forEach(([t,n,r],a)=>{var o;let s=t/n*g,c=(i-d)/(h*_),l=d+h*_*c,u=f+s*c,p=(o=[.33,.4,.47,.6,.8,.6,.47,.4,.33][a])==null?.53:o,m=Z(v.strokeColor,p);e.strokeStyle=m,e.beginPath(),e.moveTo(d,f),e.lineTo(l,u),e.stroke(),e.fillStyle=m;let y=Math.min(l,i-30);e.fillText(r,y,u-3)}),e.setLineDash([]),e.fillStyle=v.strokeColor,e.beginPath(),e.arc(d,f,o?4:3,0,Math.PI*2),e.fill(),e.beginPath(),e.arc(p,m,o?4:3,0,Math.PI*2),e.fill(),e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let[s,c]=this.points,l=n.xToPixel(s.barIndex,r,a),u=n.yToPixel(s.price,i,o),d=n.xToPixel(c.barIndex,r,a),f=n.yToPixel(c.price,i,o),p=Math.abs(d-l)||1,m=f-u,h=d>l?1:-1;for(let[n,r]of Ea){let i=n/r*m,o=(a-l)/(p*h);if(Ta(e,t,l,u,l+p*h*o,u+i*o)<=wa)return!0}return!1}getHandle(e,t,n,r,i,a,o){if(this.points.length<2)return null;let s=[{px:n.xToPixel(this.points[0].barIndex,r,a),py:n.yToPixel(this.points[0].price,i,o)},{px:n.xToPixel(this.points[1].barIndex,r,a),py:n.yToPixel(this.points[1].price,i,o)}],c=[`move`,`grab`];for(let n=0;n<s.length;n++)if(Math.hypot(e-s[n].px,t-s[n].py)<=wa+2)return{pointIndex:n,cursor:c[n]};return null}},Oa=6,ka=class{constructor(e){this.type=`gannSquare`,this.id=`gsq_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let[l,u]=this.points,d=t.xToPixel(l.barIndex,n,i),f=t.yToPixel(l.price,r,a),p=t.xToPixel(u.barIndex,n,i),m=t.yToPixel(u.price,r,a),h=Math.min(d,p),g=Math.min(f,m),_=Math.max(d,p),v=Math.max(f,m),y=_-h,b=v-g,x=Y(`gannSquare`,this.style,c);e.save(),e.lineWidth=o?x.lineWidth+.5:x.lineWidth,e.strokeStyle=x.strokeColor,X(e,o?`solid`:x.lineStyle,e.lineWidth),e.fillStyle=Z(x.fillColor,x.fillOpacity),e.fillRect(h,g,y,b),e.strokeRect(h,g,y,b),e.beginPath(),e.moveTo(h,g+b/3),e.lineTo(_,g+b/3),e.moveTo(h,g+2*b/3),e.lineTo(_,g+2*b/3),e.stroke(),e.beginPath(),e.moveTo(h+y/3,g),e.lineTo(h+y/3,v),e.moveTo(h+2*y/3,g),e.lineTo(h+2*y/3,v),e.stroke(),e.setLineDash([]),e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let[s,c]=this.points,l=n.xToPixel(s.barIndex,r,a),u=n.yToPixel(s.price,i,o),d=n.xToPixel(c.barIndex,r,a),f=n.yToPixel(c.price,i,o);return e>=Math.min(l,d)&&e<=Math.max(l,d)&&t>=Math.min(u,f)&&t<=Math.max(u,f)}getHandle(e,t,n,r,i,a,o){if(this.points.length<2)return null;let s=[{px:n.xToPixel(this.points[0].barIndex,r,a),py:n.yToPixel(this.points[0].price,i,o)},{px:n.xToPixel(this.points[1].barIndex,r,a),py:n.yToPixel(this.points[1].price,i,o)}];for(let n=0;n<s.length;n++)if(Math.hypot(e-s[n].px,t-s[n].py)<=Oa+2)return{pointIndex:n,cursor:`nwse-resize`};return null}},Aa=6,ja=class{constructor(e){this.type=`gannBox`,this.id=`gbox_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let[l,u]=this.points,d=t.xToPixel(l.barIndex,n,i),f=t.yToPixel(l.price,r,a),p=t.xToPixel(u.barIndex,n,i),m=t.yToPixel(u.price,r,a),h=Math.min(d,p),g=Math.min(f,m),_=Math.max(d,p),v=Math.max(f,m),y=_-h,b=v-g,x=h+y/2,S=g+b/2,C=Y(`gannBox`,this.style,c);e.save(),e.lineWidth=o?C.lineWidth+.5:C.lineWidth,e.strokeStyle=C.strokeColor,X(e,o?`solid`:C.lineStyle,e.lineWidth),e.fillStyle=Z(C.fillColor,C.fillOpacity),e.fillRect(h,g,y,b),e.strokeRect(h,g,y,b),e.beginPath(),e.moveTo(h,g),e.lineTo(_,v),e.stroke(),e.beginPath(),e.moveTo(_,g),e.lineTo(h,v),e.stroke(),e.beginPath(),e.moveTo(h,S),e.lineTo(_,S),e.stroke(),e.beginPath(),e.moveTo(x,g),e.lineTo(x,v),e.stroke(),e.setLineDash([]),e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let[s,c]=this.points,l=n.xToPixel(s.barIndex,r,a),u=n.yToPixel(s.price,i,o),d=n.xToPixel(c.barIndex,r,a),f=n.yToPixel(c.price,i,o);return e>=Math.min(l,d)&&e<=Math.max(l,d)&&t>=Math.min(u,f)&&t<=Math.max(u,f)}getHandle(e,t,n,r,i,a,o){if(this.points.length<2)return null;let s=[{px:n.xToPixel(this.points[0].barIndex,r,a),py:n.yToPixel(this.points[0].price,i,o)},{px:n.xToPixel(this.points[1].barIndex,r,a),py:n.yToPixel(this.points[1].price,i,o)}];for(let n=0;n<s.length;n++)if(Math.hypot(e-s[n].px,t-s[n].py)<=Aa+2)return{pointIndex:n,cursor:`nwse-resize`};return null}},Ma=6,Na=class{constructor(e){this.type=`rectangle`,this.id=`rect_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let[l,u]=this.points,d=t.xToPixel(l.barIndex,n,i),f=t.yToPixel(l.price,r,a),p=t.xToPixel(u.barIndex,n,i),m=t.yToPixel(u.price,r,a),h=Math.min(d,p),g=Math.min(f,m),_=Math.abs(p-d),v=Math.abs(m-f),y=Y(`rectangle`,this.style,c);if(e.save(),e.fillStyle=Z(y.fillColor,y.fillOpacity),e.strokeStyle=y.strokeColor,e.lineWidth=o?y.lineWidth+.5:y.lineWidth,X(e,o?`solid`:y.lineStyle,e.lineWidth),e.fillRect(h,g,_,v),e.strokeRect(h,g,_,v),e.setLineDash([]),o)for(let[t,n]of[[d,f],[p,f],[d,m],[p,m]])e.beginPath(),e.arc(t,n,3.5,0,Math.PI*2),e.fillStyle=y.strokeColor,e.fill();e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let[s,c]=this.points,l=n.xToPixel(s.barIndex,r,a),u=n.yToPixel(s.price,i,o),d=n.xToPixel(c.barIndex,r,a),f=n.yToPixel(c.price,i,o),p=Math.min(l,d)-Ma,m=Math.min(u,f)-Ma,h=Math.abs(d-l)+Ma*2,g=Math.abs(f-u)+Ma*2;return e>=p&&e<=p+h&&t>=m&&t<=m+g}getHandle(e,t,n,r,i,a,o){if(this.points.length<2)return null;let[s,c]=this.points,l=n.xToPixel(s.barIndex,r,a),u=n.yToPixel(s.price,i,o),d=n.xToPixel(c.barIndex,r,a),f=n.yToPixel(c.price,i,o),p=l<=d?u<=f?`nwse-resize`:`nesw-resize`:u<=f?`nesw-resize`:`nwse-resize`,m=p===`nwse-resize`?`nesw-resize`:`nwse-resize`,h=[{cx:l,cy:u,handle:{pointIndex:0,cursor:p}},{cx:d,cy:f,handle:{pointIndex:1,cursor:p}},{cx:d,cy:u,handle:{pointIndex:1,cursor:m,xPointIndex:1,yPointIndex:0}},{cx:l,cy:f,handle:{pointIndex:0,cursor:m,xPointIndex:0,yPointIndex:1}}];for(let{cx:n,cy:r,handle:i}of h)if(Math.hypot(e-n,t-r)<=Ma+2)return i;return null}},Pa=6;function Fa(e,t,n){let r=!1,i=n.length;for(let a=0,o=i-1;a<i;o=a++){let[i,s]=n[a],[c,l]=n[o];s>t!=l>t&&e<(c-i)*(t-s)/(l-s)+i&&(r=!r)}return r}var Ia=class{constructor(e){this.type=`rotatedRectangle`,this.requiredPoints=3,this.id=`rrect_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}getCorners(e,t,n,r,i){let[a,o,s]=this.points,c=e.xToPixel(a.barIndex,t,r),l=e.yToPixel(a.price,n,i),u=e.xToPixel(o.barIndex,t,r),d=e.yToPixel(o.price,n,i),f=e.xToPixel(s.barIndex,t,r),p=e.yToPixel(s.price,n,i),m=Math.hypot(u-c,d-l);if(m<1e-6)return[[c,l],[u,d],[u,d],[c,l]];let h=-(d-l)/m,g=(u-c)/m,_=(f-c)*h+(p-l)*g,v=c,y=l,b=u,x=d,S=b+h*_,C=x+g*_,w=v+h*_,T=y+g*_;return[[v,y],[b,x],[S,C],[w,T]]}render(e,t,n,r,i,a,o,s,c){if(this.points.length<3)return;let l=this.getCorners(t,n,r,i,a),u=Y(`rotatedRectangle`,this.style,c);e.save(),e.beginPath(),e.moveTo(l[0][0],l[0][1]);for(let t=1;t<l.length;t++)e.lineTo(l[t][0],l[t][1]);e.closePath(),e.fillStyle=Z(u.fillColor,u.fillOpacity),e.fill(),e.strokeStyle=u.strokeColor,e.lineWidth=o?u.lineWidth+.5:u.lineWidth,X(e,o?`solid`:u.lineStyle,e.lineWidth),e.stroke(),e.setLineDash([]),e.fillStyle=u.strokeColor;for(let[t,n]of l)e.beginPath(),e.arc(t,n,o?4:3,0,Math.PI*2),e.fill();e.restore()}hitTest(e,t,n,r,i,a,o){return this.points.length<3?!1:Fa(e,t,this.getCorners(n,r,i,a,o))}getHandle(e,t,n,r,i,a,o){for(let s=0;s<this.points.length;s++){let c=n.xToPixel(this.points[s].barIndex,r,a),l=n.yToPixel(this.points[s].price,i,o);if(Math.hypot(e-c,t-l)<=Pa+2)return{pointIndex:s,cursor:`grab`}}return null}},La=6,Ra=class{constructor(e){this.type=`ellipse`,this.id=`ell_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let[l,u]=this.points,d=t.xToPixel(l.barIndex,n,i),f=t.yToPixel(l.price,r,a),p=t.xToPixel(u.barIndex,n,i),m=t.yToPixel(u.price,r,a),h=(d+p)/2,g=(f+m)/2,_=Math.abs(p-d)/2,v=Math.abs(m-f)/2;if(_<1||v<1)return;let y=Y(`ellipse`,this.style,c);if(e.save(),e.fillStyle=Z(y.fillColor,y.fillOpacity),e.strokeStyle=y.strokeColor,e.lineWidth=o?y.lineWidth+.5:y.lineWidth,X(e,o?`solid`:y.lineStyle,e.lineWidth),e.beginPath(),e.ellipse(h,g,_,v,0,0,Math.PI*2),e.fill(),e.stroke(),e.setLineDash([]),o)for(let[t,n]of[[d,f],[p,m]])e.beginPath(),e.arc(t,n,3.5,0,Math.PI*2),e.fillStyle=y.strokeColor,e.fill();e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let[s,c]=this.points,l=n.xToPixel(s.barIndex,r,a),u=n.yToPixel(s.price,i,o),d=n.xToPixel(c.barIndex,r,a),f=n.yToPixel(c.price,i,o),p=(l+d)/2,m=(u+f)/2,h=Math.abs(d-l)/2+La,g=Math.abs(f-u)/2+La;if(h<1||g<1)return!1;let _=(e-p)/h,v=(t-m)/g;return _*_+v*v<=1}getHandle(e,t,n,r,i,a,o){if(this.points.length<2)return null;let[s,c]=this.points,l=n.xToPixel(s.barIndex,r,a),u=n.yToPixel(s.price,i,o),d=n.xToPixel(c.barIndex,r,a),f=n.yToPixel(c.price,i,o),p=l<=d?u<=f?`nwse-resize`:`nesw-resize`:u<=f?`nesw-resize`:`nwse-resize`,m=[[0,l,u,p],[1,d,f,p]];for(let[n,r,i,a]of m)if(Math.hypot(e-r,t-i)<=La+2)return{pointIndex:n,cursor:a};return null}},za=6;function Ba(e,t,n,r,i,a){let o=i-n,s=a-r,c=o*o+s*s;if(c===0)return Math.hypot(e-n,t-r);let l=Math.max(0,Math.min(1,((e-n)*o+(t-r)*s)/c));return Math.hypot(e-(n+l*o),t-(r+l*s))}var Va=class{constructor(e){this.type=`triangle`,this.requiredPoints=3,this.id=`tri_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let l=this.points.map(e=>t.xToPixel(e.barIndex,n,i)),u=this.points.map(e=>t.yToPixel(e.price,r,a)),d=Y(`triangle`,this.style,c);e.save(),e.strokeStyle=d.strokeColor,e.lineWidth=o?d.lineWidth+.5:d.lineWidth,X(e,o?`solid`:d.lineStyle,e.lineWidth),e.beginPath(),e.moveTo(l[0],u[0]);for(let t=1;t<l.length;t++)e.lineTo(l[t],u[t]);if(this.complete&&(e.closePath(),e.fillStyle=Z(d.fillColor,d.fillOpacity),e.fill()),e.stroke(),e.setLineDash([]),o)for(let t=0;t<l.length;t++)e.beginPath(),e.arc(l[t],u[t],4,0,Math.PI*2),e.fillStyle=d.strokeColor,e.fill();e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<3)return!1;let s=this.points.map(e=>n.xToPixel(e.barIndex,r,a)),c=this.points.map(e=>n.yToPixel(e.price,i,o)),l=s.length;for(let n=0;n<l;n++){let r=(n+1)%l;if(Ba(e,t,s[n],c[n],s[r],c[r])<=za)return!0}return!1}getHandle(e,t,n,r,i,a,o){if(this.points.length<3)return null;for(let s=0;s<this.points.length;s++){let c=n.xToPixel(this.points[s].barIndex,r,a),l=n.yToPixel(this.points[s].price,i,o);if(Math.hypot(e-c,t-l)<=za+2)return{pointIndex:s,cursor:`grab`}}return null}},Ha=6,Ua=class{constructor(e){this.type=`circle`,this.id=`circ_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let[l,u]=this.points,d=t.xToPixel(l.barIndex,n,i),f=t.yToPixel(l.price,r,a),p=t.xToPixel(u.barIndex,n,i),m=t.yToPixel(u.price,r,a),h=Math.hypot(p-d,m-f);if(h<1)return;let g=Y(`circle`,this.style,c);e.save(),e.fillStyle=Z(g.fillColor,g.fillOpacity),e.strokeStyle=g.strokeColor,e.lineWidth=o?g.lineWidth+.5:g.lineWidth,X(e,o?`solid`:g.lineStyle,e.lineWidth),e.beginPath(),e.arc(d,f,h,0,Math.PI*2),e.fill(),e.stroke(),e.setLineDash([]),o&&(e.beginPath(),e.arc(d,f,3,0,Math.PI*2),e.fillStyle=g.strokeColor,e.fill(),e.beginPath(),e.arc(p,m,3.5,0,Math.PI*2),e.fillStyle=g.strokeColor,e.fill()),e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let[s,c]=this.points,l=n.xToPixel(s.barIndex,r,a),u=n.yToPixel(s.price,i,o),d=n.xToPixel(c.barIndex,r,a),f=n.yToPixel(c.price,i,o),p=Math.hypot(d-l,f-u);return Math.hypot(e-l,t-u)<=p+Ha}getHandle(e,t,n,r,i,a,o){if(this.points.length<2)return null;let[s,c]=this.points,l=n.xToPixel(s.barIndex,r,a),u=n.yToPixel(s.price,i,o),d=n.xToPixel(c.barIndex,r,a),f=n.yToPixel(c.price,i,o);return Math.hypot(e-l,t-u)<=Ha+2?{pointIndex:0,cursor:`move`}:Math.hypot(e-d,t-f)<=Ha+2?{pointIndex:1,cursor:`grab`}:null}},Wa=6;function Ga(e,t,n,r,i,a){let o=i-n,s=a-r,c=o*o+s*s;if(c===0)return Math.hypot(e-n,t-r);let l=Math.max(0,Math.min(1,((e-n)*o+(t-r)*s)/c));return Math.hypot(e-(n+l*o),t-(r+l*s))}var Ka=class{constructor(e){this.type=`arc`,this.requiredPoints=3,this.id=`arc_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<3)return;let[l,u,d]=this.points,f=t.xToPixel(l.barIndex,n,i),p=t.yToPixel(l.price,r,a),m=t.xToPixel(u.barIndex,n,i),h=t.yToPixel(u.price,r,a),g=t.xToPixel(d.barIndex,n,i),_=t.yToPixel(d.price,r,a),v=Y(`arc`,this.style,c);e.save(),e.strokeStyle=v.strokeColor,e.lineWidth=o?v.lineWidth+.5:v.lineWidth,X(e,o?`solid`:v.lineStyle,e.lineWidth);let y=f,b=p,x=m,S=h,C=g,w=_,T=2*(y*(S-w)+x*(w-b)+C*(b-S));if(Math.abs(T)<1e-6)e.beginPath(),e.moveTo(f,p),e.lineTo(g,_),e.stroke();else{let t=y*y,n=b*b,r=x*x,i=S*S,a=C*C,o=w*w,s=((t+n)*(S-w)+(r+i)*(w-b)+(a+o)*(b-S))/T,c=((t+n)*(C-x)+(r+i)*(y-C)+(a+o)*(x-y))/T,l=Math.hypot(y-s,b-c),u=Math.atan2(b-c,y-s),d=Math.atan2(S-c,x-s),f=Math.atan2(w-c,C-s),p=(e,t)=>{let n=e-t;for(;n<0;)n+=Math.PI*2;for(;n>=Math.PI*2;)n-=Math.PI*2;return n},m=p(d,u)>p(f,u);e.beginPath(),e.arc(s,c,l,u,f,m),e.stroke()}e.setLineDash([]);let E=[[f,p],[m,h],[g,_]];e.fillStyle=v.strokeColor;for(let[t,n]of E)e.beginPath(),e.arc(t,n,o?4:3,0,Math.PI*2),e.fill();e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<3)return!1;let[s,c,l]=this.points,u=n.xToPixel(s.barIndex,r,a),d=n.yToPixel(s.price,i,o),f=n.xToPixel(c.barIndex,r,a),p=n.yToPixel(c.price,i,o),m=n.xToPixel(l.barIndex,r,a),h=n.yToPixel(l.price,i,o),g=u,_=d,v=f,y=p,b=m,x=h,S=2*(g*(y-x)+v*(x-_)+b*(_-y));if(Math.abs(S)<1e-6)return Ga(e,t,u,d,m,h)<=Wa;let C=g*g,w=_*_,T=v*v,E=y*y,D=b*b,O=x*x,k=((C+w)*(y-x)+(T+E)*(x-_)+(D+O)*(_-y))/S,A=((C+w)*(b-v)+(T+E)*(g-b)+(D+O)*(v-g))/S,j=Math.hypot(g-k,_-A);if(Math.abs(Math.hypot(e-k,t-A)-j)>Wa)return!1;let M=Math.atan2(_-A,g-k),N=Math.atan2(y-A,v-k),P=Math.atan2(x-A,b-k),F=Math.atan2(t-A,e-k),I=(e,t)=>{let n=e-t;for(;n<0;)n+=Math.PI*2;for(;n>=Math.PI*2;)n-=Math.PI*2;return n},L=I(N,M),R=I(P,M),z=I(F,M);return L>R?z>=R||z<=0:z<=R}getHandle(e,t,n,r,i,a,o){for(let s=0;s<this.points.length;s++){let c=n.xToPixel(this.points[s].barIndex,r,a),l=n.yToPixel(this.points[s].price,i,o);if(Math.hypot(e-c,t-l)<=Wa+2)return{pointIndex:s,cursor:`grab`}}return null}},qa=6;function Ja(e,t,n,r,i,a){let o=i-n,s=a-r,c=o*o+s*s;if(c===0)return Math.hypot(e-n,t-r);let l=Math.max(0,Math.min(1,((e-n)*o+(t-r)*s)/c));return Math.hypot(e-(n+l*o),t-(r+l*s))}var Ya=class{constructor(e){this.type=`polyline`,this.openEnded=!0,this.id=`poly_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let l=this.points.map(e=>({x:t.xToPixel(e.barIndex,n,i),y:t.yToPixel(e.price,r,a)})),u=Y(`polyline`,this.style,c);e.save(),e.strokeStyle=u.strokeColor,e.lineWidth=o?u.lineWidth+.5:u.lineWidth;let d=this.complete?l.length:l.length-1;if(d>=2){X(e,o?`solid`:u.lineStyle,e.lineWidth),e.beginPath(),e.moveTo(l[0].x,l[0].y);for(let t=1;t<d;t++)e.lineTo(l[t].x,l[t].y);e.stroke(),e.setLineDash([])}if(!this.complete&&l.length>=2){let t=l.length-1;e.setLineDash([4,4]),e.beginPath(),e.moveTo(l[t-1].x,l[t-1].y),e.lineTo(l[t].x,l[t].y),e.stroke(),e.setLineDash([])}e.fillStyle=u.strokeColor;let f=this.complete?l.length:l.length-1;for(let t=0;t<f;t++)e.beginPath(),e.arc(l[t].x,l[t].y,o?4:3,0,Math.PI*2),e.fill();e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let s=this.points.map(e=>({x:n.xToPixel(e.barIndex,r,a),y:n.yToPixel(e.price,i,o)})),c=this.complete?s.length-1:s.length-2;for(let n=0;n<c;n++)if(Ja(e,t,s[n].x,s[n].y,s[n+1].x,s[n+1].y)<=qa)return!0;return!1}getHandle(e,t,n,r,i,a,o){for(let s=0;s<this.points.length;s++){let c=n.xToPixel(this.points[s].barIndex,r,a),l=n.yToPixel(this.points[s].price,i,o);if(Math.hypot(e-c,t-l)<=qa+2)return{pointIndex:s,cursor:`grab`}}return null}},Xa=6;function Za(e,t,n,r,i,a){let o=i-n,s=a-r,c=o*o+s*s;if(c===0)return Math.hypot(e-n,t-r);let l=Math.max(0,Math.min(1,((e-n)*o+(t-r)*s)/c));return Math.hypot(e-(n+l*o),t-(r+l*s))}var Qa=class{constructor(e){this.type=`path`,this.openEnded=!0,this.id=`path_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let l=this.points.map(e=>({x:t.xToPixel(e.barIndex,n,i),y:t.yToPixel(e.price,r,a)})),u=this.complete?l.length:l.length-1,d=Y(`path`,this.style,c);if(e.save(),e.strokeStyle=d.strokeColor,e.lineWidth=o?d.lineWidth+.5:d.lineWidth,u>=2){if(X(e,o?`solid`:d.lineStyle,e.lineWidth),e.beginPath(),e.moveTo(l[0].x,l[0].y),u===2)e.lineTo(l[1].x,l[1].y);else{for(let t=1;t<u-1;t++){let n=(l[t].x+l[t+1].x)/2,r=(l[t].y+l[t+1].y)/2;e.quadraticCurveTo(l[t].x,l[t].y,n,r)}e.lineTo(l[u-1].x,l[u-1].y)}e.stroke(),e.setLineDash([])}if(!this.complete&&l.length>=2){let t=l.length-1;e.setLineDash([4,4]),e.beginPath(),e.moveTo(l[t-1].x,l[t-1].y),e.lineTo(l[t].x,l[t].y),e.stroke(),e.setLineDash([])}e.fillStyle=d.strokeColor;for(let t=0;t<u;t++)e.beginPath(),e.arc(l[t].x,l[t].y,o?4:3,0,Math.PI*2),e.fill();e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let s=this.points.map(e=>({x:n.xToPixel(e.barIndex,r,a),y:n.yToPixel(e.price,i,o)})),c=this.complete?s.length-1:s.length-2;for(let n=0;n<c;n++)if(Za(e,t,s[n].x,s[n].y,s[n+1].x,s[n+1].y)<=Xa)return!0;return!1}getHandle(e,t,n,r,i,a,o){for(let s=0;s<this.points.length;s++){let c=n.xToPixel(this.points[s].barIndex,r,a),l=n.yToPixel(this.points[s].price,i,o);if(Math.hypot(e-c,t-l)<=Xa+2)return{pointIndex:s,cursor:`grab`}}return null}},$a=6;function eo(e,t,n,r,i,a=7){let o=Math.atan2(i-n,r-t);e.beginPath(),e.moveTo(r,i),e.lineTo(r-a*Math.cos(o-Math.PI/6),i-a*Math.sin(o-Math.PI/6)),e.lineTo(r-a*Math.cos(o+Math.PI/6),i-a*Math.sin(o+Math.PI/6)),e.closePath(),e.fill()}var to=class{constructor(e){this.type=`priceRange`,this.id=`pr_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s=2,c){if(this.points.length<2)return;let[l,u]=this.points,d=t.xToPixel(l.barIndex,n,i),f=t.yToPixel(l.price,r,a),p=t.xToPixel(u.barIndex,n,i),m=t.yToPixel(u.price,r,a),h=(d+p)/2,g=(f+m)/2,_=Math.min(f,m),v=Math.max(f,m),y=Y(`priceRange`,this.style,c),b=y.strokeColor;e.save(),e.strokeStyle=b,e.fillStyle=b,e.lineWidth=o?y.lineWidth+.5:y.lineWidth,X(e,o?`solid`:y.lineStyle,e.lineWidth),e.font=`10px 'Inter', system-ui, sans-serif`,e.beginPath(),e.moveTo(h,_),e.lineTo(h,v),e.stroke(),eo(e,h,v,h,_),eo(e,h,_,h,v),e.beginPath(),e.moveTo(d-10,f),e.lineTo(d+10,f),e.stroke(),e.beginPath(),e.moveTo(p-10,m),e.lineTo(p+10,m),e.stroke(),e.setLineDash([]);let x=Math.abs(l.price-u.price).toFixed(s),S=((u.price-l.price)/l.price*100).toFixed(2)+`%`,C=x,w=S,T=h+8,E=g-30/2;e.fillStyle=Z(y.fillColor,y.fillOpacity),e.fillRect(T,E,70,30),e.strokeStyle=b,e.strokeRect(T,E,70,30),e.fillStyle=b,e.fillText(C,T+4,E+4+10),e.fillText(w,T+4,E+4+22),e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let[s,c]=this.points,l=n.xToPixel(s.barIndex,r,a),u=n.yToPixel(s.price,i,o),d=n.xToPixel(c.barIndex,r,a),f=n.yToPixel(c.price,i,o),p=(l+d)/2,m=Math.min(u,f),h=Math.max(u,f);return Math.abs(e-p)<=$a&&t>=m&&t<=h}getHandle(e,t,n,r,i,a,o){if(this.points.length<2)return null;let s=[{px:n.xToPixel(this.points[0].barIndex,r,a),py:n.yToPixel(this.points[0].price,i,o)},{px:n.xToPixel(this.points[1].barIndex,r,a),py:n.yToPixel(this.points[1].price,i,o)}];for(let n=0;n<s.length;n++)if(Math.hypot(e-s[n].px,t-s[n].py)<=$a+2)return{pointIndex:n,cursor:`ns-resize`};return null}},no=6;function ro(e,t,n,r,i,a=7){let o=Math.atan2(i-n,r-t);e.beginPath(),e.moveTo(r,i),e.lineTo(r-a*Math.cos(o-Math.PI/6),i-a*Math.sin(o-Math.PI/6)),e.lineTo(r-a*Math.cos(o+Math.PI/6),i-a*Math.sin(o+Math.PI/6)),e.closePath(),e.fill()}var io=class{constructor(e){this.type=`dateRange`,this.id=`dr_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let[l,u]=this.points,d=t.xToPixel(l.barIndex,n,i),f=t.yToPixel(l.price,r,a),p=t.xToPixel(u.barIndex,n,i),m=t.yToPixel(u.price,r,a),h=(f+m)/2,g=Math.min(d,p),_=Math.max(d,p),v=Y(`dateRange`,this.style,c),y=v.strokeColor;e.save(),e.strokeStyle=y,e.fillStyle=y,e.lineWidth=o?v.lineWidth+.5:v.lineWidth,X(e,o?`solid`:v.lineStyle,e.lineWidth),e.font=`10px 'Inter', system-ui, sans-serif`,e.beginPath(),e.moveTo(g,h),e.lineTo(_,h),e.stroke(),ro(e,_,h,g,h),ro(e,g,h,_,h),e.beginPath(),e.moveTo(d,f-10),e.lineTo(d,f+10),e.stroke(),e.beginPath(),e.moveTo(p,m-10),e.lineTo(p,m+10),e.stroke(),e.setLineDash([]);let b=`${Math.abs(u.barIndex-l.barIndex)} bars`,x=(d+p)/2,S=e.measureText(b).width;e.fillStyle=y,e.fillText(b,x-S/2,h-10),e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let[s,c]=this.points,l=n.xToPixel(s.barIndex,r,a),u=n.yToPixel(s.price,i,o),d=n.xToPixel(c.barIndex,r,a),f=(u+n.yToPixel(c.price,i,o))/2,p=Math.min(l,d),m=Math.max(l,d);return Math.abs(t-f)<=no&&e>=p&&e<=m}getHandle(e,t,n,r,i,a,o){if(this.points.length<2)return null;let s=[{px:n.xToPixel(this.points[0].barIndex,r,a),py:n.yToPixel(this.points[0].price,i,o)},{px:n.xToPixel(this.points[1].barIndex,r,a),py:n.yToPixel(this.points[1].price,i,o)}];for(let n=0;n<s.length;n++)if(Math.hypot(e-s[n].px,t-s[n].py)<=no+2)return{pointIndex:n,cursor:`ew-resize`};return null}},ao=6;function oo(e,t,n,r,i,a=7){let o=Math.atan2(i-n,r-t);e.beginPath(),e.moveTo(r,i),e.lineTo(r-a*Math.cos(o-Math.PI/6),i-a*Math.sin(o-Math.PI/6)),e.lineTo(r-a*Math.cos(o+Math.PI/6),i-a*Math.sin(o+Math.PI/6)),e.closePath(),e.fill()}var so=class{constructor(e){this.type=`datePriceRange`,this.id=`dpr_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s=2,c){if(this.points.length<2)return;let[l,u]=this.points,d=t.xToPixel(l.barIndex,n,i),f=t.yToPixel(l.price,r,a),p=t.xToPixel(u.barIndex,n,i),m=t.yToPixel(u.price,r,a),h=Math.min(d,p),g=Math.min(f,m),_=Math.max(d,p),v=Math.max(f,m),y=_-h,b=v-g,x=Y(`datePriceRange`,this.style,c),S=x.strokeColor;e.save(),e.font=`10px 'Inter', system-ui, sans-serif`,e.lineWidth=o?x.lineWidth+.5:x.lineWidth,e.fillStyle=Z(x.fillColor,x.fillOpacity),e.fillRect(h,g,y,b),e.strokeStyle=S,X(e,o?`solid`:x.lineStyle,e.lineWidth),e.strokeRect(h,g,y,b),e.setLineDash([]),e.strokeStyle=S,e.fillStyle=S,e.beginPath(),e.moveTo(d,f),e.lineTo(p,m),e.stroke(),oo(e,d,f,p,m);let C=`\u0394${Math.abs(l.price-u.price).toFixed(s)}`;e.fillStyle=S,e.fillText(C,_+4,(g+v)/2);let w=`${Math.abs(u.barIndex-l.barIndex)} bars`,T=e.measureText(w).width;e.fillText(w,h+y/2-T/2,v+12),e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let[s,c]=this.points,l=n.xToPixel(s.barIndex,r,a),u=n.yToPixel(s.price,i,o),d=n.xToPixel(c.barIndex,r,a),f=n.yToPixel(c.price,i,o),p=Math.min(l,d)-ao,m=Math.min(u,f)-ao,h=Math.max(l,d)+ao,g=Math.max(u,f)+ao;return e>=p&&e<=h&&t>=m&&t<=g}getHandle(e,t,n,r,i,a,o){if(this.points.length<2)return null;let s=[{px:n.xToPixel(this.points[0].barIndex,r,a),py:n.yToPixel(this.points[0].price,i,o)},{px:n.xToPixel(this.points[1].barIndex,r,a),py:n.yToPixel(this.points[1].price,i,o)}];for(let n=0;n<s.length;n++)if(Math.hypot(e-s[n].px,t-s[n].py)<=ao+2)return{pointIndex:n,cursor:`nwse-resize`};return null}},co=6,lo=`#26a69a`,uo=`#ef5350`,fo=`11px 'Inter', system-ui, sans-serif`,po=14,mo=8,ho=6,go=8;function _o(e,t,n,r,i,a){let o=i-n,s=a-r,c=o*o+s*s;if(c===0)return Math.hypot(e-n,t-r);let l=Math.max(0,Math.min(1,((e-n)*o+(t-r)*s)/c));return Math.hypot(e-(n+l*o),t-(r+l*s))}function vo(e,t,n,r,i,a){let o=Math.min(a,r/2,i/2);e.moveTo(t+o,n),e.arcTo(t+r,n,t+r,n+i,o),e.arcTo(t+r,n+i,t,n+i,o),e.arcTo(t,n+i,t,n,o),e.arcTo(t,n,t+r,n,o),e.closePath()}var yo=class{constructor(e){this.type=`ruler`,this.detailed=!1,this.id=`rul_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}rangeVolume(e){let t=e==null?void 0:e.bars;if(!t||t.length===0)return null;let[n,r]=this.points,i=Math.max(0,Math.ceil(Math.min(n.barIndex,r.barIndex))),a=Math.min(t.length-1,Math.floor(Math.max(n.barIndex,r.barIndex)));if(a<i)return null;let o=0,s=!1;for(let e=i;e<=a;e++){var c;let n=(c=t[e])==null?void 0:c.volume;typeof n==`number`&&Number.isFinite(n)&&(o+=n,s=!0)}return s?o:null}buildLabel(e,t){var n;let[r,i]=this.points,a=i.price-r.price,o=a>=0?``:`-`,s=Math.abs(a),c=Math.abs(Math.round(i.barIndex)-Math.round(r.barIndex));if((t==null||(n=t.features)==null?void 0:n.enableForecasting)!==!0)return[`${c} bars`,a.toFixed(e)];let l=r.price===0?0:s/Math.abs(r.price)*100,u=`${o}${s.toFixed(e)} (${l.toFixed(2)}%)`,d=t==null?void 0:t.instrument;if(d){let e=Math.abs(N(a,d.pipSize));u+=` ${o}${e.toFixed(1)}`}let f=`${c} ${c===1?`bar`:`bars`}`;r.timestamp!=null&&i.timestamp!=null&&(f+=`, ${F(i.timestamp-r.timestamp)}`);let p=[u,f],m=this.rangeVolume(t);return m!=null&&p.push(`Vol ${P(m)}`),p}render(e,t,n,r,i,a,o,s=2,c,l){var u,d,f,p,m,h;if(this.points.length<2)return;this.detailed=(l==null||(u=l.features)==null?void 0:u.enableForecasting)===!0;let[g,_]=this.points,v=t.xToPixel(g.barIndex,n,i),y=t.yToPixel(g.price,r,a),b=t.xToPixel(_.barIndex,n,i),x=t.yToPixel(_.price,r,a);if(!this.detailed){this.renderClassic(e,v,y,b,x,o,s,c);return}let S=Y(`ruler`,this.style,c),C=_.price>=g.price,w=this.style,T=(d=w==null?void 0:w.strokeColor)==null?C?(f=c==null||(p=c.candle)==null?void 0:p.up)==null?lo:f:(m=c==null||(h=c.candle)==null?void 0:h.down)==null?uo:m:d,E=Math.min(v,b),D=Math.max(v,b),O=Math.min(y,x),k=Math.max(y,x),A=D-E,j=k-O;e.save(),e.fillStyle=Z(T,S.fillOpacity),e.fillRect(E,O,A,j),e.strokeStyle=T,e.lineWidth=o?S.lineWidth+1:S.lineWidth,e.setLineDash([]),e.strokeRect(E,O,A,j);let M=(E+D)/2,N=Math.min(9,Math.max(4,j/4)),P=C?1:-1;e.beginPath(),e.moveTo(M,y),e.lineTo(M,x),e.stroke(),j>N*2&&(e.beginPath(),e.moveTo(M,x),e.lineTo(M-N*.55,x+N*P),e.lineTo(M+N*.55,x+N*P),e.closePath(),e.fillStyle=T,e.fill());let F=this.buildLabel(s,l);e.font=fo,e.textBaseline=`top`,e.textAlign=`center`;let I=0;for(let t of F)I=Math.max(I,e.measureText(t).width);let L=I+mo*2,R=F.length*po+ho*2,z=C?O-go-R:k+go;(z<0||z+R>a)&&(z=C?k+go:O-go-R),z=Math.max(2,Math.min(a-R-2,z));let B=M-L/2;B=Math.max(2,Math.min(i-L-2,B)),e.beginPath(),vo(e,B,z,L,R,4),e.fillStyle=T,e.fill(),e.fillStyle=`#ffffff`;for(let t=0;t<F.length;t++)e.fillText(F[t],B+L/2,z+ho+t*po);if(o){e.fillStyle=T;for(let[t,n]of[[v,y],[b,x],[b,y],[v,x]])e.beginPath(),e.arc(t,n,3.5,0,Math.PI*2),e.fill()}e.restore()}renderClassic(e,t,n,r,i,a,o,s){let[c,l]=this.points,u=Y(`ruler`,this.style,s),d=u.strokeColor,f=Math.atan2(i-n,r-t),p=f+Math.PI/2;e.save(),e.strokeStyle=d,e.fillStyle=d,e.lineWidth=a?u.lineWidth+.5:u.lineWidth,X(e,a?`solid`:u.lineStyle,e.lineWidth),e.font=`10px 'Inter', system-ui, sans-serif`,e.textAlign=`left`,e.textBaseline=`alphabetic`,e.beginPath(),e.moveTo(t,n),e.lineTo(r,i),e.stroke(),e.beginPath(),e.moveTo(t-8*Math.cos(p),n-8*Math.sin(p)),e.lineTo(t+8*Math.cos(p),n+8*Math.sin(p)),e.stroke(),e.beginPath(),e.moveTo(r-8*Math.cos(p),i-8*Math.sin(p)),e.lineTo(r+8*Math.cos(p),i+8*Math.sin(p)),e.stroke(),e.setLineDash([]);let m=(t+r)/2,h=(n+i)/2,g=Math.abs(l.barIndex-c.barIndex),_=(l.price-c.price).toFixed(o),v=-12*Math.sin(f),y=12*Math.cos(f);e.fillStyle=d,e.fillText(`${g} bars`,m+v,h+y-12),e.fillText(_,m+v,h+y),e.beginPath(),e.arc(t,n,a?4:3,0,Math.PI*2),e.fill(),e.beginPath(),e.arc(r,i,a?4:3,0,Math.PI*2),e.fill(),e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let[s,c]=this.points,l=n.xToPixel(s.barIndex,r,a),u=n.yToPixel(s.price,i,o),d=n.xToPixel(c.barIndex,r,a),f=n.yToPixel(c.price,i,o);if(!this.detailed)return _o(e,t,l,u,d,f)<=co;let p=Math.min(l,d),m=Math.max(l,d),h=Math.min(u,f),g=Math.max(u,f),_=(p+m)/2;return[[p,h,m,h],[m,h,m,g],[m,g,p,g],[p,g,p,h],[_,h,_,g]].some(([n,r,i,a])=>_o(e,t,n,r,i,a)<=co)}getHandle(e,t,n,r,i,a,o){if(this.points.length<2)return null;let[s,c]=this.points,l=n.xToPixel(s.barIndex,r,a),u=n.yToPixel(s.price,i,o),d=n.xToPixel(c.barIndex,r,a),f=n.yToPixel(c.price,i,o);if(!this.detailed){let n=[{px:l,py:u},{px:d,py:f}];for(let r=0;r<n.length;r++)if(Math.hypot(e-n[r].px,t-n[r].py)<=co+2)return{pointIndex:r,cursor:`grab`};return null}let p=l<=d?u<=f?`nwse-resize`:`nesw-resize`:u<=f?`nesw-resize`:`nwse-resize`,m=p===`nwse-resize`?`nesw-resize`:`nwse-resize`,h=[{cx:l,cy:u,handle:{pointIndex:0,cursor:p}},{cx:d,cy:f,handle:{pointIndex:1,cursor:p}},{cx:d,cy:u,handle:{pointIndex:1,cursor:m,xPointIndex:1,yPointIndex:0}},{cx:l,cy:f,handle:{pointIndex:0,cursor:m,xPointIndex:0,yPointIndex:1}}];for(let{cx:n,cy:r,handle:i}of h)if(Math.hypot(e-n,t-r)<=co+2)return i;return null}},bo=6;function xo(e,t,n,r,i,a){let o=i-n,s=a-r,c=o*o+s*s;if(c===0)return Math.hypot(e-n,t-r);let l=Math.max(0,Math.min(1,((e-n)*o+(t-r)*s)/c));return Math.hypot(e-(n+l*o),t-(r+l*s))}function So(e,t,n,r,i){return n===0?[e,t]:[i,t+(i-e)/n*r]}var Co=class{constructor(e){this.type=`pitchfork`,this.requiredPoints=3,this.id=`pfk_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let[l,u,d]=this.points,f=t.xToPixel(l.barIndex,n,i),p=t.yToPixel(l.price,r,a),m=t.xToPixel(u.barIndex,n,i),h=t.yToPixel(u.price,r,a),g=Y(`pitchfork`,this.style,c);if(e.save(),e.strokeStyle=g.strokeColor,e.lineWidth=o?g.lineWidth+.5:g.lineWidth,X(e,o?`solid`:g.lineStyle,e.lineWidth),d){let s=t.xToPixel(d.barIndex,n,i),c=t.yToPixel(d.price,r,a),l=(m+s)/2,u=(h+c)/2,_=l-f,v=u-p,[y,b]=So(f,p,_,v,i);e.beginPath(),e.moveTo(f,p),e.lineTo(l,u),e.stroke(),e.beginPath(),e.moveTo(f,p),e.lineTo(y,b),e.stroke();let[x,S]=So(m,h,_,v,i);e.beginPath(),e.moveTo(m,h),e.lineTo(x,S),e.stroke();let[C,w]=So(s,c,_,v,i);if(e.beginPath(),e.moveTo(s,c),e.lineTo(C,w),e.stroke(),e.setLineDash([]),o){e.fillStyle=g.strokeColor;for(let[t,n]of[[f,p],[m,h],[s,c]])e.beginPath(),e.arc(t,n,4,0,Math.PI*2),e.fill()}}else e.beginPath(),e.moveTo(f,p),e.lineTo(m,h),e.stroke(),e.setLineDash([]);e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<3)return!1;let[s,c,l]=this.points,u=n.xToPixel(s.barIndex,r,a),d=n.yToPixel(s.price,i,o),f=n.xToPixel(c.barIndex,r,a),p=n.yToPixel(c.price,i,o),m=n.xToPixel(l.barIndex,r,a),h=n.yToPixel(l.price,i,o),g=(f+m)/2,_=(p+h)/2,v=g-u,y=_-d,[b,x]=So(u,d,v,y,a),[S,C]=So(f,p,v,y,a),[w,T]=So(m,h,v,y,a);return xo(e,t,u,d,b,x)<=bo||xo(e,t,f,p,S,C)<=bo||xo(e,t,m,h,w,T)<=bo}getHandle(e,t,n,r,i,a,o){let s=this.points.map((e,t)=>({i:t,px:n.xToPixel(e.barIndex,r,a),py:n.yToPixel(e.price,i,o)}));for(let{i:n,px:r,py:i}of s)if(Math.hypot(e-r,t-i)<=bo+2)return{pointIndex:n,cursor:`grab`};return null}},wo=6;function To(e,t,n,r,i,a){let o=i-n,s=a-r,c=o*o+s*s;if(c===0)return Math.hypot(e-n,t-r);let l=Math.max(0,Math.min(1,((e-n)*o+(t-r)*s)/c));return Math.hypot(e-(n+l*o),t-(r+l*s))}function Eo(e,t,n,r,i){return n===0?[e,t]:[i,t+(i-e)/n*r]}var Do=class{constructor(e){this.type=`schiffPitchfork`,this.requiredPoints=3,this.id=`spfk_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let[l,u,d]=this.points,f=t.xToPixel(l.barIndex,n,i),p=t.yToPixel(l.price,r,a),m=t.xToPixel(u.barIndex,n,i),h=t.yToPixel(u.price,r,a),g=Y(`schiffPitchfork`,this.style,c);if(e.save(),e.strokeStyle=g.strokeColor,e.lineWidth=o?g.lineWidth+.5:g.lineWidth,X(e,o?`solid`:g.lineStyle,e.lineWidth),d){let s=t.xToPixel(d.barIndex,n,i),c=t.yToPixel(d.price,r,a),l=(f+m)/2,u=(p+h)/2,_=(m+s)/2,v=(h+c)/2,y=_-l,b=v-u,[x,S]=Eo(l,u,y,b,i);e.beginPath(),e.moveTo(l,u),e.lineTo(_,v),e.stroke(),e.beginPath(),e.moveTo(l,u),e.lineTo(x,S),e.stroke();let[C,w]=Eo(m,h,y,b,i);e.beginPath(),e.moveTo(m,h),e.lineTo(C,w),e.stroke();let[T,E]=Eo(s,c,y,b,i);if(e.beginPath(),e.moveTo(s,c),e.lineTo(T,E),e.stroke(),e.setLineDash([]),o){e.fillStyle=g.strokeColor;for(let[t,n]of[[f,p],[m,h],[s,c]])e.beginPath(),e.arc(t,n,4,0,Math.PI*2),e.fill()}}else e.beginPath(),e.moveTo(f,p),e.lineTo(m,h),e.stroke(),e.setLineDash([]);e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<3)return!1;let[s,c,l]=this.points,u=n.xToPixel(s.barIndex,r,a),d=n.yToPixel(s.price,i,o),f=n.xToPixel(c.barIndex,r,a),p=n.yToPixel(c.price,i,o),m=n.xToPixel(l.barIndex,r,a),h=n.yToPixel(l.price,i,o),g=(u+f)/2,_=(d+p)/2,v=(f+m)/2,y=(p+h)/2,b=v-g,x=y-_,[S,C]=Eo(g,_,b,x,a),[w,T]=Eo(f,p,b,x,a),[E,D]=Eo(m,h,b,x,a);return To(e,t,g,_,S,C)<=wo||To(e,t,f,p,w,T)<=wo||To(e,t,m,h,E,D)<=wo}getHandle(e,t,n,r,i,a,o){let s=this.points.map((e,t)=>({i:t,px:n.xToPixel(e.barIndex,r,a),py:n.yToPixel(e.price,i,o)}));for(let{i:n,px:r,py:i}of s)if(Math.hypot(e-r,t-i)<=wo+2)return{pointIndex:n,cursor:`grab`};return null}},Oo=6;function ko(e,t,n,r,i,a){let o=i-n,s=a-r,c=o*o+s*s;if(c===0)return Math.hypot(e-n,t-r);let l=Math.max(0,Math.min(1,((e-n)*o+(t-r)*s)/c));return Math.hypot(e-(n+l*o),t-(r+l*s))}function Ao(e,t,n,r,i){return n===0?[e,t]:[i,t+(i-e)/n*r]}var jo=class{constructor(e){this.type=`modifiedSchiff`,this.requiredPoints=3,this.id=`mspfk_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let[l,u,d]=this.points,f=t.xToPixel(l.barIndex,n,i),p=t.yToPixel(l.price,r,a),m=t.xToPixel(u.barIndex,n,i),h=t.yToPixel(u.price,r,a),g=Y(`modifiedSchiff`,this.style,c);if(e.save(),e.strokeStyle=g.strokeColor,e.lineWidth=o?g.lineWidth+.5:g.lineWidth,X(e,o?`solid`:g.lineStyle,e.lineWidth),d){let s=t.xToPixel(d.barIndex,n,i),c=t.yToPixel(d.price,r,a),l=(m+s)/2,u=(h+c)/2,_=(f+l)/2,v=(p+u)/2,y=l-_,b=u-v,[x,S]=Ao(_,v,y,b,i);e.beginPath(),e.moveTo(_,v),e.lineTo(l,u),e.stroke(),e.beginPath(),e.moveTo(_,v),e.lineTo(x,S),e.stroke();let[C,w]=Ao(m,h,y,b,i);e.beginPath(),e.moveTo(m,h),e.lineTo(C,w),e.stroke();let[T,E]=Ao(s,c,y,b,i);if(e.beginPath(),e.moveTo(s,c),e.lineTo(T,E),e.stroke(),e.setLineDash([]),o){e.fillStyle=g.strokeColor;for(let[t,n]of[[f,p],[m,h],[s,c]])e.beginPath(),e.arc(t,n,4,0,Math.PI*2),e.fill()}}else e.beginPath(),e.moveTo(f,p),e.lineTo(m,h),e.stroke(),e.setLineDash([]);e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<3)return!1;let[s,c,l]=this.points,u=n.xToPixel(s.barIndex,r,a),d=n.yToPixel(s.price,i,o),f=n.xToPixel(c.barIndex,r,a),p=n.yToPixel(c.price,i,o),m=n.xToPixel(l.barIndex,r,a),h=n.yToPixel(l.price,i,o),g=(f+m)/2,_=(p+h)/2,v=(u+g)/2,y=(d+_)/2,b=g-v,x=_-y,[S,C]=Ao(v,y,b,x,a),[w,T]=Ao(f,p,b,x,a),[E,D]=Ao(m,h,b,x,a);return ko(e,t,v,y,S,C)<=Oo||ko(e,t,f,p,w,T)<=Oo||ko(e,t,m,h,E,D)<=Oo}getHandle(e,t,n,r,i,a,o){let s=this.points.map((e,t)=>({i:t,px:n.xToPixel(e.barIndex,r,a),py:n.yToPixel(e.price,i,o)}));for(let{i:n,px:r,py:i}of s)if(Math.hypot(e-r,t-i)<=Oo+2)return{pointIndex:n,cursor:`grab`};return null}},Mo=6;function No(e,t,n,r,i,a){let o=i-n,s=a-r,c=o*o+s*s;if(c===0)return Math.hypot(e-n,t-r);let l=Math.max(0,Math.min(1,((e-n)*o+(t-r)*s)/c));return Math.hypot(e-(n+l*o),t-(r+l*s))}function Po(e,t,n,r,i){return n===0?[e,t]:[i,t+(i-e)/n*r]}var Fo=class{constructor(e){this.type=`insidePitchfork`,this.requiredPoints=3,this.id=`ipfk_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let[l,u,d]=this.points,f=t.xToPixel(l.barIndex,n,i),p=t.yToPixel(l.price,r,a),m=t.xToPixel(u.barIndex,n,i),h=t.yToPixel(u.price,r,a),g=Y(`insidePitchfork`,this.style,c);if(e.save(),e.strokeStyle=g.strokeColor,e.lineWidth=o?g.lineWidth+.5:g.lineWidth,X(e,o?`solid`:g.lineStyle,e.lineWidth),d){let s=t.xToPixel(d.barIndex,n,i),c=t.yToPixel(d.price,r,a),l=(m+s)/2,u=(h+c)/2,_=l-f,v=u-p;e.beginPath(),e.moveTo(f,p),e.lineTo(l,u),e.stroke();let[y,b]=Po(f,p,_,v,i);e.beginPath(),e.moveTo(f,p),e.lineTo(y,b),e.stroke();let[x,S]=Po(m,h,_,v,i);e.beginPath(),e.moveTo(m,h),e.lineTo(x,S),e.stroke();let[C,w]=Po(s,c,_,v,i);e.beginPath(),e.moveTo(s,c),e.lineTo(C,w),e.stroke();let T=(f+m)/2,E=(p+h)/2,[D,O]=Po(T,E,_,v,i);e.globalAlpha=.55,e.setLineDash([4,3]),e.beginPath(),e.moveTo(T,E),e.lineTo(D,O),e.stroke();let k=(f+s)/2,A=(p+c)/2,[j,M]=Po(k,A,_,v,i);if(e.beginPath(),e.moveTo(k,A),e.lineTo(j,M),e.stroke(),e.setLineDash([]),e.globalAlpha=1,o){e.fillStyle=g.strokeColor;for(let[t,n]of[[f,p],[m,h],[s,c]])e.beginPath(),e.arc(t,n,4,0,Math.PI*2),e.fill()}}else e.beginPath(),e.moveTo(f,p),e.lineTo(m,h),e.stroke(),e.setLineDash([]);e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<3)return!1;let[s,c,l]=this.points,u=n.xToPixel(s.barIndex,r,a),d=n.yToPixel(s.price,i,o),f=n.xToPixel(c.barIndex,r,a),p=n.yToPixel(c.price,i,o),m=n.xToPixel(l.barIndex,r,a),h=n.yToPixel(l.price,i,o),g=(f+m)/2,_=(p+h)/2,v=g-u,y=_-d,[b,x]=Po(u,d,v,y,a),[S,C]=Po(f,p,v,y,a),[w,T]=Po(m,h,v,y,a);if(No(e,t,u,d,b,x)<=Mo||No(e,t,f,p,S,C)<=Mo||No(e,t,m,h,w,T)<=Mo)return!0;let E=(u+f)/2,D=(d+p)/2,[O,k]=Po(E,D,v,y,a);if(No(e,t,E,D,O,k)<=Mo)return!0;let A=(u+m)/2,j=(d+h)/2,[M,N]=Po(A,j,v,y,a);return No(e,t,A,j,M,N)<=Mo}getHandle(e,t,n,r,i,a,o){let s=this.points.map((e,t)=>({i:t,px:n.xToPixel(e.barIndex,r,a),py:n.yToPixel(e.price,i,o)}));for(let{i:n,px:r,py:i}of s)if(Math.hypot(e-r,t-i)<=Mo+2)return{pointIndex:n,cursor:`grab`};return null}},Io=6,Lo=[.35,.55,.75,1,1,.75,.55,.35],Ro=class{constructor(e){this.type=`fixedRangeVP`,this.id=`frvp_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let[l,u]=this.points,d=t.xToPixel(l.barIndex,n,i),f=t.yToPixel(l.price,r,a),p=t.xToPixel(u.barIndex,n,i),m=t.yToPixel(u.price,r,a),h=Math.min(d,p),g=Math.min(f,m),_=Math.abs(p-d),v=Math.abs(m-f),y=Y(`fixedRangeVP`,this.style,c);e.save(),e.strokeStyle=y.strokeColor,e.lineWidth=o?y.lineWidth+.5:y.lineWidth,X(e,o?`solid`:y.lineStyle,e.lineWidth),e.strokeRect(h,g,_,v),e.setLineDash([]);let b=Lo.length,x=v/b,S=_*.6,C=Z(y.fillColor,y.fillOpacity);for(let t=0;t<b;t++){let n=S*Lo[t],r=g+t*x;e.fillStyle=C,e.fillRect(h,r,n,x-1)}if(e.font=`11px 'Inter', system-ui, sans-serif`,e.fillStyle=y.strokeColor,e.fillText(`Volume Profile`,h+4,g+13),o)for(let[t,n]of[[d,f],[p,m]])e.beginPath(),e.arc(t,n,3.5,0,Math.PI*2),e.fillStyle=y.strokeColor,e.fill();e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let[s,c]=this.points,l=n.xToPixel(s.barIndex,r,a),u=n.yToPixel(s.price,i,o),d=n.xToPixel(c.barIndex,r,a),f=n.yToPixel(c.price,i,o),p=Math.min(l,d)-Io,m=Math.min(u,f)-Io,h=Math.abs(d-l)+Io*2,g=Math.abs(f-u)+Io*2;return e>=p&&e<=p+h&&t>=m&&t<=m+g}getHandle(e,t,n,r,i,a,o){if(this.points.length<2)return null;let s=[[0,n.xToPixel(this.points[0].barIndex,r,a),n.yToPixel(this.points[0].price,i,o)],[1,n.xToPixel(this.points[1].barIndex,r,a),n.yToPixel(this.points[1].price,i,o)]];for(let[n,r,i]of s)if(Math.hypot(e-r,t-i)<=Io+2)return{pointIndex:n,cursor:`nwse-resize`};return null}},zo=6,Bo=[.35,.55,.75,1,1,.75,.55,.35],Vo=class{constructor(e){this.type=`anchoredVP`,this.id=`avp_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let[l,u]=this.points,d=t.xToPixel(l.barIndex,n,i),f=t.yToPixel(l.price,r,a),p=t.xToPixel(u.barIndex,n,i),m=t.yToPixel(u.price,r,a),h=Math.min(d,p),g=Math.min(f,m),_=Math.abs(p-d),v=Math.abs(m-f),y=Y(`anchoredVP`,this.style,c);e.save(),e.strokeStyle=y.strokeColor,e.lineWidth=o?y.lineWidth+.5:y.lineWidth,X(e,o?`solid`:y.lineStyle,e.lineWidth),e.strokeRect(h,g,_,v),e.setLineDash([]);let b=Bo.length,x=v/b,S=_*.6,C=Z(y.fillColor,y.fillOpacity);for(let t=0;t<b;t++){let n=S*Bo[t],r=g+t*x;e.fillStyle=C,e.fillRect(h,r,n,x-1)}if(e.font=`11px 'Inter', system-ui, sans-serif`,e.fillStyle=y.strokeColor,e.fillText(`Anchored VP`,h+4,g+13),e.beginPath(),e.arc(d,f,o?4:3,0,Math.PI*2),e.fillStyle=y.strokeColor,e.fill(),o)for(let[t,n]of[[d,f],[p,m]])e.beginPath(),e.arc(t,n,3.5,0,Math.PI*2),e.fillStyle=y.strokeColor,e.fill();e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let[s,c]=this.points,l=n.xToPixel(s.barIndex,r,a),u=n.yToPixel(s.price,i,o),d=n.xToPixel(c.barIndex,r,a),f=n.yToPixel(c.price,i,o),p=Math.min(l,d)-zo,m=Math.min(u,f)-zo,h=Math.abs(d-l)+zo*2,g=Math.abs(f-u)+zo*2;return e>=p&&e<=p+h&&t>=m&&t<=m+g}getHandle(e,t,n,r,i,a,o){if(this.points.length<2)return null;let s=[[0,n.xToPixel(this.points[0].barIndex,r,a),n.yToPixel(this.points[0].price,i,o)],[1,n.xToPixel(this.points[1].barIndex,r,a),n.yToPixel(this.points[1].price,i,o)]];for(let[n,r,i]of s)if(Math.hypot(e-r,t-i)<=zo+2)return{pointIndex:n,cursor:`nwse-resize`};return null}},Ho=6,Uo=[.25,.45,.65,.85,1,1,.85,.65,.45,.25],Wo=class{constructor(e){this.type=`volumeProfile`,this.id=`vp_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let[l,u]=this.points,d=t.xToPixel(l.barIndex,n,i),f=t.yToPixel(l.price,r,a),p=t.xToPixel(u.barIndex,n,i),m=t.yToPixel(u.price,r,a),h=Math.min(d,p),g=Math.min(f,m),_=Math.abs(p-d),v=Math.abs(m-f),y=Y(`volumeProfile`,this.style,c);e.save(),e.strokeStyle=y.strokeColor,e.lineWidth=o?y.lineWidth+.5:y.lineWidth,X(e,o?`solid`:y.lineStyle,e.lineWidth),e.strokeRect(h,g,_,v),e.setLineDash([]);let b=Uo.length,x=v/b,S=_*.6,C=Z(y.fillColor,y.fillOpacity);for(let t=0;t<b;t++){let n=S*Uo[t],r=g+t*x;e.fillStyle=C,e.fillRect(h,r,n,x-1)}if(e.font=`11px 'Inter', system-ui, sans-serif`,e.fillStyle=y.strokeColor,e.fillText(`Volume Profile`,h+4,g+13),o)for(let[t,n]of[[d,f],[p,m]])e.beginPath(),e.arc(t,n,3.5,0,Math.PI*2),e.fillStyle=y.strokeColor,e.fill();e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let[s,c]=this.points,l=n.xToPixel(s.barIndex,r,a),u=n.yToPixel(s.price,i,o),d=n.xToPixel(c.barIndex,r,a),f=n.yToPixel(c.price,i,o),p=Math.min(l,d)-Ho,m=Math.min(u,f)-Ho,h=Math.abs(d-l)+Ho*2,g=Math.abs(f-u)+Ho*2;return e>=p&&e<=p+h&&t>=m&&t<=m+g}getHandle(e,t,n,r,i,a,o){if(this.points.length<2)return null;let s=[[0,n.xToPixel(this.points[0].barIndex,r,a),n.yToPixel(this.points[0].price,i,o)],[1,n.xToPixel(this.points[1].barIndex,r,a),n.yToPixel(this.points[1].price,i,o)]];for(let[n,r,i]of s)if(Math.hypot(e-r,t-i)<=Ho+2)return{pointIndex:n,cursor:`nwse-resize`};return null}},Go=6;function Ko(e,t,n,r,i,a){let o=i-n,s=a-r,c=o*o+s*s;if(c===0)return Math.hypot(e-n,t-r);let l=Math.max(0,Math.min(1,((e-n)*o+(t-r)*s)/c));return Math.hypot(e-(n+l*o),t-(r+l*s))}var qo=class{constructor(e){this.type=`regressionTrend`,this.id=`reg_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let[l,u]=this.points,d=t.xToPixel(l.barIndex,n,i),f=t.yToPixel(l.price,r,a),p=t.xToPixel(u.barIndex,n,i),m=t.yToPixel(u.price,r,a),h=Y(`regressionTrend`,this.style,c),g=Z(h.strokeColor,.4),_=Math.hypot(p-d,m-f)||1,v=-(m-f)/_,y=(p-d)/_;e.save(),e.strokeStyle=h.strokeColor,e.fillStyle=h.strokeColor,e.lineWidth=o?h.lineWidth+.5:h.lineWidth,X(e,o?`solid`:h.lineStyle,e.lineWidth),e.beginPath(),e.moveTo(d,f),e.lineTo(p,m),e.stroke(),e.strokeStyle=g,e.setLineDash([4,3]),e.beginPath(),e.moveTo(d+v*20,f+y*20),e.lineTo(p+v*20,m+y*20),e.stroke(),e.beginPath(),e.moveTo(d-v*20,f-y*20),e.lineTo(p-v*20,m-y*20),e.stroke(),e.setLineDash([]),e.beginPath(),e.arc(d,f,o?4:3,0,Math.PI*2),e.fill(),e.beginPath(),e.arc(p,m,o?4:3,0,Math.PI*2),e.fill(),e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let[s,c]=this.points;return Ko(e,t,n.xToPixel(s.barIndex,r,a),n.yToPixel(s.price,i,o),n.xToPixel(c.barIndex,r,a),n.yToPixel(c.price,i,o))<=Go}getHandle(e,t,n,r,i,a,o){if(this.points.length<2)return null;let s=[{px:n.xToPixel(this.points[0].barIndex,r,a),py:n.yToPixel(this.points[0].price,i,o)},{px:n.xToPixel(this.points[1].barIndex,r,a),py:n.yToPixel(this.points[1].price,i,o)}];for(let n=0;n<s.length;n++)if(Math.hypot(e-s[n].px,t-s[n].py)<=Go+2)return{pointIndex:n,cursor:`grab`};return null}},Jo=6,Yo=`Text`,Xo=4,Zo=class{constructor(e){this.type=`text`,this.text=``,this.id=`txt_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e],this.complete=!0}render(e,t,n,r,i,a,o,s,c){var l,u;let d=t.xToPixel(this.points[0].barIndex,n,i),f=t.yToPixel(this.points[0].price,r,a),p=Y(`text`,this.style,c),m=(l=p.fontSize)==null?13:l,h=(u=p.textColor)==null?`#f5f5f5`:u;e.save(),e.font=`${m}px system-ui, sans-serif`,e.textBaseline=`top`;let g=this.text||Yo,_=!this.text,v=e.measureText(g).width;o&&(e.strokeStyle=`#2196f3`,e.lineWidth=1,e.strokeRect(d-2,f-2,v+Xo*2,20)),e.fillStyle=_?`#888`:h,e.fillText(g,d+Xo,f),o&&(e.strokeStyle=h,e.lineWidth=1,e.beginPath(),e.moveTo(d,f+16),e.lineTo(d+v+Xo*2,f+16),e.stroke()),e.restore()}hitTest(e,t,n,r,i,a,o){var s,c;let l=n.xToPixel(this.points[0].barIndex,r,a),u=n.yToPixel(this.points[0].price,i,o),d=Math.max(40,((s=(c=this.text)==null?void 0:c.length)==null?4:s)*8);return e>=l-Jo&&e<=l+d+Jo&&t>=u-Jo&&t<=u+16+Jo}getHandle(){return null}},Qo=6,$o=24,es=8,ts=12;function ns(e,t,n,r,i,a){let o=i-n,s=a-r,c=o*o+s*s;if(c===0)return Math.hypot(e-n,t-r);let l=Math.max(0,Math.min(1,((e-n)*o+(t-r)*s)/c));return Math.hypot(e-(n+l*o),t-(r+l*s))}function rs(e,t,n,r,i,a){e.beginPath(),e.moveTo(t+a,n),e.lineTo(t+r-a,n),e.arcTo(t+r,n,t+r,n+a,a),e.lineTo(t+r,n+i-a),e.arcTo(t+r,n+i,t+r-a,n+i,a),e.lineTo(t+a,n+i),e.arcTo(t,n+i,t,n+i-a,a),e.lineTo(t,n+a),e.arcTo(t,n,t+a,n,a),e.closePath()}var is=class{constructor(e){this.type=`callout`,this.text=``,this.id=`cal_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}getBoxW(e){let t=this.text||`Note`;return Math.max(60,e.measureText(t).width+ts*2)}render(e,t,n,r,i,a,o,s,c){var l,u;if(this.points.length<2)return;let[d,f]=this.points,p=t.xToPixel(d.barIndex,n,i),m=t.yToPixel(d.price,r,a),h=t.xToPixel(f.barIndex,n,i),g=t.yToPixel(f.price,r,a),_=Y(`callout`,this.style,c),v=(l=_.fontSize)==null?11:l,y=(u=_.textColor)==null?`#f5f5f5`:u;e.save(),e.font=`${v}px system-ui, sans-serif`,e.lineWidth=o?_.lineWidth+.5:_.lineWidth,X(e,o?`solid`:_.lineStyle,e.lineWidth);let b=this.getBoxW(e),x=h-b/2,S=g-$o/2,C=Math.max(x,Math.min(x+b,p)),w=Math.max(S,Math.min(S+$o,m)),T=p<x?x:p>x+b?x+b:C,E=m<S?S:m>S+$o?S+$o:w;e.strokeStyle=_.strokeColor,e.beginPath(),e.moveTo(T,E),e.lineTo(p,m),e.stroke(),e.setLineDash([]),e.fillStyle=_.strokeColor,e.beginPath(),e.arc(p,m,3,0,Math.PI*2),e.fill(),rs(e,x,S,b,$o,es),e.fillStyle=Z(_.fillColor,_.fillOpacity),e.fill(),e.strokeStyle=_.strokeColor,e.stroke();let D=this.text||`Note`;e.fillStyle=this.text?y:`#888`,e.textBaseline=`middle`,e.textAlign=`center`,e.fillText(D,h,g),e.restore()}hitTest(e,t,n,r,i,a,o){var s,c;if(this.points.length<2)return!1;let[l,u]=this.points,d=n.xToPixel(l.barIndex,r,a),f=n.yToPixel(l.price,i,o),p=n.xToPixel(u.barIndex,r,a),m=n.yToPixel(u.price,i,o),h=Math.max(60,((s=(c=this.text)==null?void 0:c.length)==null?4:s)*7+24),g=p-h/2,_=m-$o/2;return e>=g-Qo&&e<=g+h+Qo&&t>=_-Qo&&t<=_+$o+Qo||ns(e,t,d<g?g:d>g+h?g+h:Math.max(g,Math.min(g+h,d)),f<_?_:f>_+$o?_+$o:Math.max(_,Math.min(_+$o,f)),d,f)<=Qo}getHandle(e,t,n,r,i,a,o){if(this.points.length<2)return null;let s=[{px:n.xToPixel(this.points[0].barIndex,r,a),py:n.yToPixel(this.points[0].price,i,o)},{px:n.xToPixel(this.points[1].barIndex,r,a),py:n.yToPixel(this.points[1].price,i,o)}],c=[`grab`,`move`];for(let n=0;n<s.length;n++)if(Math.hypot(e-s[n].px,t-s[n].py)<=Qo+4)return{pointIndex:n,cursor:c[n]};return null}},as=6,os=60,ss=18,cs=7,ls=class{constructor(e){this.type=`priceLabel`,this.id=`plbl_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e],this.complete=!0}render(e,t,n,r,i,a,o,s=2,c){var l,u;let d=t.xToPixel(this.points[0].barIndex,n,i),f=t.yToPixel(this.points[0].price,r,a),p=this.points[0].price,m=Y(`priceLabel`,this.style,c),h=(l=m.fontSize)==null?11:l,g=(u=m.textColor)==null?`#ffffff`:u;e.save(),e.fillStyle=m.fillColor,e.beginPath(),e.moveTo(d,f),e.lineTo(d+cs,f-ss/2),e.lineTo(d+cs,f+ss/2),e.closePath(),e.fill();let _=d+cs,v=f-ss/2;e.fillStyle=m.fillColor,e.beginPath(),e.roundRect(_,v,os,ss,ss/2),e.fill(),o&&(e.strokeStyle=m.strokeColor,e.lineWidth=m.lineWidth+.5,e.beginPath(),e.roundRect(_-2,v-2,os+4,ss+4,ss/2+2),e.stroke()),e.font=`${h}px 'Inter', system-ui, sans-serif`,e.fillStyle=g,e.textBaseline=`middle`,e.textAlign=`center`,e.fillText(p.toFixed(s),_+os/2,f),e.restore()}hitTest(e,t,n,r,i,a,o){let s=n.xToPixel(this.points[0].barIndex,r,a),c=n.yToPixel(this.points[0].price,i,o),l=s+cs,u=c-ss/2;return e>=s-as&&e<=l+os+as&&t>=u-as&&t<=u+ss+as}getHandle(){return null}},us=6;function ds(e,t,n,r,i,a){let o=i-n,s=a-r,c=o*o+s*s;if(c===0)return Math.hypot(e-n,t-r);let l=Math.max(0,Math.min(1,((e-n)*o+(t-r)*s)/c));return Math.hypot(e-(n+l*o),t-(r+l*s))}var fs=class{constructor(e){this.type=`arrowMarker`,this.id=`arw_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let[l,u]=this.points,d=t.xToPixel(l.barIndex,n,i),f=t.yToPixel(l.price,r,a),p=t.xToPixel(u.barIndex,n,i),m=t.yToPixel(u.price,r,a),h=Y(`arrowMarker`,this.style,c);e.save(),e.strokeStyle=h.strokeColor,e.fillStyle=Z(h.fillColor,h.fillOpacity),e.lineWidth=o?h.lineWidth+.5:h.lineWidth,X(e,o?`solid`:h.lineStyle,e.lineWidth),e.beginPath(),e.moveTo(d,f),e.lineTo(p,m),e.stroke(),e.setLineDash([]);let g=Math.atan2(m-f,p-d);if(e.beginPath(),e.moveTo(p,m),e.lineTo(p-10*Math.cos(g-Math.PI/6),m-10*Math.sin(g-Math.PI/6)),e.lineTo(p-10*Math.cos(g+Math.PI/6),m-10*Math.sin(g+Math.PI/6)),e.closePath(),e.fill(),o){e.fillStyle=h.strokeColor;for(let[t,n]of[[d,f],[p,m]])e.beginPath(),e.arc(t,n,4,0,Math.PI*2),e.fill()}e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let[s,c]=this.points;return ds(e,t,n.xToPixel(s.barIndex,r,a),n.yToPixel(s.price,i,o),n.xToPixel(c.barIndex,r,a),n.yToPixel(c.price,i,o))<=us}getHandle(e,t,n,r,i,a,o){if(this.points.length<2)return null;let s=[{px:n.xToPixel(this.points[0].barIndex,r,a),py:n.yToPixel(this.points[0].price,i,o)},{px:n.xToPixel(this.points[1].barIndex,r,a),py:n.yToPixel(this.points[1].price,i,o)}];for(let n=0;n<s.length;n++)if(Math.hypot(e-s[n].px,t-s[n].py)<=us+2)return{pointIndex:n,cursor:`grab`};return null}},ps=class{constructor(e){this.type=`flag`,this.id=`flag_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e],this.complete=!0}render(e,t,n,r,i,a,o,s,c){let l=t.xToPixel(this.points[0].barIndex,n,i),u=t.yToPixel(this.points[0].price,r,a),d=Y(`flag`,this.style,c);e.save(),e.strokeStyle=d.strokeColor,e.lineWidth=o?d.lineWidth+.5:d.lineWidth,X(e,o?`solid`:d.lineStyle,e.lineWidth),e.beginPath(),e.moveTo(l,u+20),e.lineTo(l,u-10),e.stroke(),e.setLineDash([]);let f=l,p=u-10;e.fillStyle=Z(d.fillColor,d.fillOpacity),e.fillRect(f,p,16,10),e.font=`8px system-ui, sans-serif`,e.fillStyle=`#ffffff`,e.textBaseline=`middle`,e.textAlign=`center`,e.fillText(`F`,f+8,p+5),e.restore()}hitTest(e,t,n,r,i,a,o){let s=n.xToPixel(this.points[0].barIndex,r,a),c=n.yToPixel(this.points[0].price,i,o);return Math.hypot(e-s,t-c)<=20}getHandle(){return null}},ms=6,hs=16,gs=6,_s=10,vs=class{constructor(e){this.type=`priceNote`,this.id=`pnote_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e],this.complete=!0}render(e,t,n,r,i,a,o,s=2,c){var l,u;let d=t.xToPixel(this.points[0].barIndex,n,i),f=t.yToPixel(this.points[0].price,r,a),p=this.points[0].price.toFixed(s),m=Y(`priceNote`,this.style,c),h=(l=m.fontSize)==null?11:l,g=(u=m.textColor)==null?`#ffffff`:u;e.save(),e.strokeStyle=m.strokeColor,e.lineWidth=o?m.lineWidth+.5:m.lineWidth,X(e,o?`solid`:m.lineStyle,e.lineWidth),e.beginPath(),e.moveTo(d-_s,f),e.lineTo(d+_s,f),e.stroke(),e.setLineDash([]),e.font=`${h}px 'Inter', system-ui, sans-serif`;let _=e.measureText(p).width+gs*2,v=d+_s+2,y=f-hs/2;e.fillStyle=m.fillColor,e.beginPath(),e.roundRect(v,y,_,hs,3),e.fill(),e.fillStyle=g,e.textBaseline=`middle`,e.textAlign=`center`,e.fillText(p,v+_/2,f),e.restore()}hitTest(e,t,n,r,i,a,o){let s=n.xToPixel(this.points[0].barIndex,r,a),c=n.yToPixel(this.points[0].price,i,o);return e>=s-_s-ms&&e<=s+_s+ms&&Math.abs(t-c)<=ms}getHandle(){return null}},ys=6,bs=20,xs=10;function Ss(e,t,n,r,i,a){let o=i-n,s=a-r,c=o*o+s*s;if(c===0)return Math.hypot(e-n,t-r);let l=Math.max(0,Math.min(1,((e-n)*o+(t-r)*s)/c));return Math.hypot(e-(n+l*o),t-(r+l*s))}var Cs=class{constructor(e){this.type=`anchoredNote`,this.text=``,this.id=`anote_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}getBadgeW(e){let t=this.text||`Note`;return Math.max(50,e.measureText(t).width+xs*2)}render(e,t,n,r,i,a,o,s,c){var l,u;if(this.points.length<2)return;let[d,f]=this.points,p=t.xToPixel(d.barIndex,n,i),m=t.yToPixel(d.price,r,a),h=t.xToPixel(f.barIndex,n,i),g=t.yToPixel(f.price,r,a),_=Y(`anchoredNote`,this.style,c),v=(l=_.fontSize)==null?11:l,y=(u=_.textColor)==null?`#f5f5f5`:u;e.save(),e.font=`${v}px system-ui, sans-serif`,e.lineWidth=o?_.lineWidth+.5:_.lineWidth;let b=this.getBadgeW(e),x=h-b/2,S=g-bs/2;e.strokeStyle=_.strokeColor,e.setLineDash([4,3]),e.beginPath(),e.moveTo(p,m),e.lineTo(h,g),e.stroke(),e.setLineDash([]),e.fillStyle=_.strokeColor,e.beginPath(),e.arc(p,m,3,0,Math.PI*2),e.fill(),e.fillStyle=Z(_.fillColor,_.fillOpacity),e.beginPath(),e.roundRect(x,S,b,bs,4),e.fill(),e.strokeStyle=_.strokeColor,e.lineWidth=o?_.lineWidth+.5:_.lineWidth,e.beginPath(),e.roundRect(x,S,b,bs,4),e.stroke();let C=this.text||`Note`;e.fillStyle=this.text?y:`#888`,e.textBaseline=`middle`,e.textAlign=`center`,e.fillText(C,h,g),e.restore()}hitTest(e,t,n,r,i,a,o){var s,c;if(this.points.length<2)return!1;let[l,u]=this.points,d=n.xToPixel(l.barIndex,r,a),f=n.yToPixel(l.price,i,o),p=n.xToPixel(u.barIndex,r,a),m=n.yToPixel(u.price,i,o),h=Math.max(50,((s=(c=this.text)==null?void 0:c.length)==null?4:s)*7+20),g=p-h/2,_=m-bs/2;return e>=g-ys&&e<=g+h+ys&&t>=_-ys&&t<=_+bs+ys||Ss(e,t,d,f,p,m)<=ys}getHandle(e,t,n,r,i,a,o){if(this.points.length<2)return null;let s=[{px:n.xToPixel(this.points[0].barIndex,r,a),py:n.yToPixel(this.points[0].price,i,o)},{px:n.xToPixel(this.points[1].barIndex,r,a),py:n.yToPixel(this.points[1].price,i,o)}],c=[`grab`,`move`];for(let n=0;n<s.length;n++)if(Math.hypot(e-s[n].px,t-s[n].py)<=ys+4)return{pointIndex:n,cursor:c[n]};return null}},ws=class{constructor(e){this.type=`arrowUp`,this.id=`awup_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e],this.complete=!0}render(e,t,n,r,i,a,o,s,c){let l=t.xToPixel(this.points[0].barIndex,n,i),u=t.yToPixel(this.points[0].price,r,a),d=Y(`arrowUp`,this.style,c);e.save(),e.strokeStyle=d.strokeColor,e.fillStyle=Z(d.fillColor,d.fillOpacity),e.lineWidth=o?d.lineWidth+.5:d.lineWidth,X(e,o?`solid`:d.lineStyle,e.lineWidth),e.beginPath(),e.moveTo(l,u+10),e.lineTo(l,u-2),e.stroke(),e.setLineDash([]);let f=l,p=u-10;e.beginPath(),e.moveTo(f,p),e.lineTo(f-6,p+10),e.lineTo(f+6,p+10),e.closePath(),e.fill(),e.restore()}hitTest(e,t,n,r,i,a,o){let s=n.xToPixel(this.points[0].barIndex,r,a),c=n.yToPixel(this.points[0].price,i,o);return Math.hypot(e-s,t-c)<=12}getHandle(){return null}},Ts=class{constructor(e){this.type=`arrowDown`,this.id=`awdn_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e],this.complete=!0}render(e,t,n,r,i,a,o,s,c){let l=t.xToPixel(this.points[0].barIndex,n,i),u=t.yToPixel(this.points[0].price,r,a),d=Y(`arrowDown`,this.style,c);e.save(),e.strokeStyle=d.strokeColor,e.fillStyle=Z(d.fillColor,d.fillOpacity),e.lineWidth=o?d.lineWidth+.5:d.lineWidth,X(e,o?`solid`:d.lineStyle,e.lineWidth),e.beginPath(),e.moveTo(l,u-10),e.lineTo(l,u+2),e.stroke(),e.setLineDash([]);let f=l,p=u+10;e.beginPath(),e.moveTo(f,p),e.lineTo(f-6,p-10),e.lineTo(f+6,p-10),e.closePath(),e.fill(),e.restore()}hitTest(e,t,n,r,i,a,o){let s=n.xToPixel(this.points[0].barIndex,r,a),c=n.yToPixel(this.points[0].price,i,o);return Math.hypot(e-s,t-c)<=12}getHandle(){return null}},Es=6;function Ds(e,t,n,r,i,a){let o=i-n,s=a-r,c=o*o+s*s;if(c===0)return Math.hypot(e-n,t-r);let l=Math.max(0,Math.min(1,((e-n)*o+(t-r)*s)/c));return Math.hypot(e-(n+l*o),t-(r+l*s))}var Os=class{constructor(e){this.type=`headShoulders`,this.requiredPoints=5,this.id=`hs_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let l=[`LS`,`H`,`RS`,`L1`,`L2`],u=this.points.map(e=>t.xToPixel(e.barIndex,n,i)),d=this.points.map(e=>t.yToPixel(e.price,r,a)),f=u.length,p=Y(`headShoulders`,this.style,c);e.save(),e.strokeStyle=p.strokeColor,e.lineWidth=o?p.lineWidth+.5:p.lineWidth,X(e,o?`solid`:p.lineStyle,e.lineWidth);let m=[0,3,1,4,2].filter(e=>e<f);if(m.length>=2){e.beginPath(),e.moveTo(u[m[0]],d[m[0]]);for(let t=1;t<m.length;t++)e.lineTo(u[m[t]],d[m[t]]);e.stroke()}e.setLineDash([]),this.complete&&f===5&&(e.beginPath(),e.moveTo(u[0],d[0]),e.lineTo(u[3],d[3]),e.lineTo(u[1],d[1]),e.lineTo(u[4],d[4]),e.lineTo(u[2],d[2]),e.closePath(),e.fillStyle=Z(p.fillColor,p.fillOpacity),e.fill()),f>=5&&(e.save(),e.setLineDash([5,4]),e.strokeStyle=p.strokeColor,e.lineWidth=o?p.lineWidth+.5:p.lineWidth,e.beginPath(),e.moveTo(u[3],d[3]),e.lineTo(u[4],d[4]),e.stroke(),e.restore()),e.font=`11px 'Inter', system-ui, sans-serif`,e.fillStyle=p.strokeColor;for(let t=0;t<f;t++){var h;e.beginPath(),e.arc(u[t],d[t],o?4:3,0,Math.PI*2),e.fill(),e.fillText((h=l[t])==null?String(t):h,u[t]+5,d[t]-5)}e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let s=this.points.map(e=>n.xToPixel(e.barIndex,r,a)),c=this.points.map(e=>n.yToPixel(e.price,i,o)),l=s.length,u=[0,3,1,4,2].filter(e=>e<l);for(let n=0;n<u.length-1;n++){let r=u[n],i=u[n+1];if(Ds(e,t,s[r],c[r],s[i],c[i])<=Es)return!0}return l>=5&&Ds(e,t,s[3],c[3],s[4],c[4])<=Es}getHandle(e,t,n,r,i,a,o){if(this.points.length!==this.requiredPoints)return null;for(let s=0;s<this.points.length;s++){let c=n.xToPixel(this.points[s].barIndex,r,a),l=n.yToPixel(this.points[s].price,i,o);if(Math.hypot(e-c,t-l)<=Es+2)return{pointIndex:s,cursor:`grab`}}return null}},ks=6;function As(e,t,n,r,i,a){let o=i-n,s=a-r,c=o*o+s*s;if(c===0)return Math.hypot(e-n,t-r);let l=Math.max(0,Math.min(1,((e-n)*o+(t-r)*s)/c));return Math.hypot(e-(n+l*o),t-(r+l*s))}var js=class{constructor(e){this.type=`trianglePattern`,this.requiredPoints=5,this.id=`tpat_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let l=[`1`,`2`,`3`,`4`,`5`],u=this.points.map(e=>t.xToPixel(e.barIndex,n,i)),d=this.points.map(e=>t.yToPixel(e.price,r,a)),f=u.length,p=Y(`trianglePattern`,this.style,c);e.save(),e.strokeStyle=p.strokeColor,e.lineWidth=o?p.lineWidth+.5:p.lineWidth,X(e,o?`solid`:p.lineStyle,e.lineWidth),e.beginPath(),e.moveTo(u[0],d[0]);for(let t=1;t<f;t++)e.lineTo(u[t],d[t]);e.stroke(),e.setLineDash([]),f>=3&&(e.save(),e.setLineDash([5,4]),e.strokeStyle=p.strokeColor,e.lineWidth=o?p.lineWidth+.5:p.lineWidth,e.beginPath(),e.moveTo(u[0],d[0]),e.lineTo(u[2],d[2]),f>=5&&e.lineTo(u[4],d[4]),e.stroke(),e.restore()),f>=4&&(e.save(),e.setLineDash([5,4]),e.strokeStyle=p.strokeColor,e.lineWidth=o?p.lineWidth+.5:p.lineWidth,e.beginPath(),e.moveTo(u[1],d[1]),e.lineTo(u[3],d[3]),e.stroke(),e.restore()),e.font=`11px 'Inter', system-ui, sans-serif`,e.fillStyle=p.strokeColor;for(let t=0;t<f;t++){var m;e.beginPath(),e.arc(u[t],d[t],o?4:3,0,Math.PI*2),e.fill(),e.fillText((m=l[t])==null?String(t+1):m,u[t]+5,d[t]-5)}e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let s=this.points.map(e=>n.xToPixel(e.barIndex,r,a)),c=this.points.map(e=>n.yToPixel(e.price,i,o)),l=s.length;for(let n=0;n<l-1;n++)if(As(e,t,s[n],c[n],s[n+1],c[n+1])<=ks)return!0;return l>=3&&As(e,t,s[0],c[0],s[2],c[2])<=ks||l>=5&&As(e,t,s[2],c[2],s[4],c[4])<=ks||l>=4&&As(e,t,s[1],c[1],s[3],c[3])<=ks}getHandle(e,t,n,r,i,a,o){if(this.points.length!==this.requiredPoints)return null;for(let s=0;s<this.points.length;s++){let c=n.xToPixel(this.points[s].barIndex,r,a),l=n.yToPixel(this.points[s].price,i,o);if(Math.hypot(e-c,t-l)<=ks+2)return{pointIndex:s,cursor:`grab`}}return null}},Ms=6;function Ns(e,t,n,r,i,a){let o=i-n,s=a-r,c=o*o+s*s;if(c===0)return Math.hypot(e-n,t-r);let l=Math.max(0,Math.min(1,((e-n)*o+(t-r)*s)/c));return Math.hypot(e-(n+l*o),t-(r+l*s))}var Ps=class{constructor(e){this.type=`threeDrives`,this.requiredPoints=7,this.id=`td_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let l=[`O`,`A`,`B`,`C`,`D`,`E`,`F`],u=this.points.map(e=>t.xToPixel(e.barIndex,n,i)),d=this.points.map(e=>t.yToPixel(e.price,r,a)),f=u.length,p=Y(`threeDrives`,this.style,c);e.save(),e.strokeStyle=p.strokeColor,e.lineWidth=o?p.lineWidth+.5:p.lineWidth,X(e,o?`solid`:p.lineStyle,e.lineWidth),e.beginPath(),e.moveTo(u[0],d[0]);for(let t=1;t<f;t++)e.lineTo(u[t],d[t]);if(e.stroke(),e.setLineDash([]),this.complete&&f===7){e.beginPath(),e.moveTo(u[0],d[0]);for(let t=1;t<f;t++)e.lineTo(u[t],d[t]);e.closePath(),e.fillStyle=Z(p.fillColor,p.fillOpacity),e.fill()}e.font=`11px 'Inter', system-ui, sans-serif`,e.fillStyle=p.strokeColor;for(let t=0;t<f;t++){var m;e.beginPath(),e.arc(u[t],d[t],o?4:3,0,Math.PI*2),e.fill(),e.fillText((m=l[t])==null?String(t):m,u[t]+5,d[t]-5)}e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let s=this.points.map(e=>n.xToPixel(e.barIndex,r,a)),c=this.points.map(e=>n.yToPixel(e.price,i,o)),l=s.length;for(let n=0;n<l-1;n++)if(Ns(e,t,s[n],c[n],s[n+1],c[n+1])<=Ms)return!0;return!1}getHandle(e,t,n,r,i,a,o){if(this.points.length!==this.requiredPoints)return null;for(let s=0;s<this.points.length;s++){let c=n.xToPixel(this.points[s].barIndex,r,a),l=n.yToPixel(this.points[s].price,i,o);if(Math.hypot(e-c,t-l)<=Ms+2)return{pointIndex:s,cursor:`grab`}}return null}},Fs=6;function Is(e,t,n,r,i,a){let o=i-n,s=a-r,c=o*o+s*s;if(c===0)return Math.hypot(e-n,t-r);let l=Math.max(0,Math.min(1,((e-n)*o+(t-r)*s)/c));return Math.hypot(e-(n+l*o),t-(r+l*s))}var Ls=class{constructor(e){this.type=`abcdPattern`,this.requiredPoints=4,this.id=`abcd_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let l=[`A`,`B`,`C`,`D`],u=this.points.map(e=>t.xToPixel(e.barIndex,n,i)),d=this.points.map(e=>t.yToPixel(e.price,r,a)),f=u.length,p=Y(`abcdPattern`,this.style,c);e.save(),e.strokeStyle=p.strokeColor,e.lineWidth=o?p.lineWidth+.5:p.lineWidth,X(e,o?`solid`:p.lineStyle,e.lineWidth),e.beginPath(),e.moveTo(u[0],d[0]);for(let t=1;t<f;t++)e.lineTo(u[t],d[t]);e.stroke(),e.setLineDash([]),f>=4&&(e.save(),e.setLineDash([3,4]),e.strokeStyle=p.strokeColor,e.lineWidth=o?p.lineWidth+.5:p.lineWidth,e.beginPath(),e.moveTo(u[0],d[0]),e.lineTo(u[3],d[3]),e.stroke(),e.restore()),e.font=`11px 'Inter', system-ui, sans-serif`,e.fillStyle=p.strokeColor;for(let t=0;t<f;t++){var m;e.beginPath(),e.arc(u[t],d[t],o?4:3,0,Math.PI*2),e.fill(),e.fillText((m=l[t])==null?String(t):m,u[t]+5,d[t]-5)}e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let s=this.points.map(e=>n.xToPixel(e.barIndex,r,a)),c=this.points.map(e=>n.yToPixel(e.price,i,o)),l=s.length;for(let n=0;n<l-1;n++)if(Is(e,t,s[n],c[n],s[n+1],c[n+1])<=Fs)return!0;return l>=4&&Is(e,t,s[0],c[0],s[3],c[3])<=Fs}getHandle(e,t,n,r,i,a,o){if(this.points.length!==this.requiredPoints)return null;for(let s=0;s<this.points.length;s++){let c=n.xToPixel(this.points[s].barIndex,r,a),l=n.yToPixel(this.points[s].price,i,o);if(Math.hypot(e-c,t-l)<=Fs+2)return{pointIndex:s,cursor:`grab`}}return null}},Rs=6;function zs(e,t,n,r,i,a){let o=i-n,s=a-r,c=o*o+s*s;if(c===0)return Math.hypot(e-n,t-r);let l=Math.max(0,Math.min(1,((e-n)*o+(t-r)*s)/c));return Math.hypot(e-(n+l*o),t-(r+l*s))}var Bs=class{constructor(e){this.type=`cypherPattern`,this.requiredPoints=5,this.id=`cyp_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let l=[`X`,`A`,`B`,`C`,`D`],u=this.points.map(e=>t.xToPixel(e.barIndex,n,i)),d=this.points.map(e=>t.yToPixel(e.price,r,a)),f=u.length,p=Y(`cypherPattern`,this.style,c);e.save(),e.strokeStyle=p.strokeColor,e.lineWidth=o?p.lineWidth+.5:p.lineWidth,X(e,o?`solid`:p.lineStyle,e.lineWidth),e.beginPath(),e.moveTo(u[0],d[0]);for(let t=1;t<f;t++)e.lineTo(u[t],d[t]);if(e.stroke(),e.setLineDash([]),this.complete&&f===5){e.beginPath(),e.moveTo(u[0],d[0]);for(let t=1;t<f;t++)e.lineTo(u[t],d[t]);e.closePath(),e.fillStyle=Z(p.fillColor,p.fillOpacity),e.fill()}e.font=`11px 'Inter', system-ui, sans-serif`,e.fillStyle=p.strokeColor;for(let t=0;t<f;t++){var m;e.beginPath(),e.arc(u[t],d[t],o?4:3,0,Math.PI*2),e.fill(),e.fillText((m=l[t])==null?String(t):m,u[t]+5,d[t]-5)}e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let s=this.points.map(e=>n.xToPixel(e.barIndex,r,a)),c=this.points.map(e=>n.yToPixel(e.price,i,o)),l=s.length;for(let n=0;n<l-1;n++)if(zs(e,t,s[n],c[n],s[n+1],c[n+1])<=Rs)return!0;return!1}getHandle(e,t,n,r,i,a,o){if(this.points.length!==this.requiredPoints)return null;for(let s=0;s<this.points.length;s++){let c=n.xToPixel(this.points[s].barIndex,r,a),l=n.yToPixel(this.points[s].price,i,o);if(Math.hypot(e-c,t-l)<=Rs+2)return{pointIndex:s,cursor:`grab`}}return null}},Vs=6;function Hs(e,t,n,r,i,a){let o=i-n,s=a-r,c=o*o+s*s;if(c===0)return Math.hypot(e-n,t-r);let l=Math.max(0,Math.min(1,((e-n)*o+(t-r)*s)/c));return Math.hypot(e-(n+l*o),t-(r+l*s))}var Us=class{constructor(e){this.type=`butterflyPattern`,this.requiredPoints=5,this.id=`bfly_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let l=[`X`,`A`,`B`,`C`,`D`],u=this.points.map(e=>t.xToPixel(e.barIndex,n,i)),d=this.points.map(e=>t.yToPixel(e.price,r,a)),f=u.length,p=Y(`butterflyPattern`,this.style,c);e.save(),e.strokeStyle=p.strokeColor,e.lineWidth=o?p.lineWidth+.5:p.lineWidth,X(e,o?`solid`:p.lineStyle,e.lineWidth),e.beginPath(),e.moveTo(u[0],d[0]);for(let t=1;t<f;t++)e.lineTo(u[t],d[t]);e.stroke(),e.setLineDash([]),f>=5&&(e.save(),e.setLineDash([5,4]),e.strokeStyle=p.strokeColor,e.lineWidth=o?p.lineWidth+.5:p.lineWidth,e.beginPath(),e.moveTo(u[0],d[0]),e.lineTo(u[4],d[4]),e.stroke(),e.restore()),e.font=`11px 'Inter', system-ui, sans-serif`,e.fillStyle=p.strokeColor;for(let t=0;t<f;t++){var m;e.beginPath(),e.arc(u[t],d[t],o?4:3,0,Math.PI*2),e.fill(),e.fillText((m=l[t])==null?String(t):m,u[t]+5,d[t]-5)}e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let s=this.points.map(e=>n.xToPixel(e.barIndex,r,a)),c=this.points.map(e=>n.yToPixel(e.price,i,o)),l=s.length;for(let n=0;n<l-1;n++)if(Hs(e,t,s[n],c[n],s[n+1],c[n+1])<=Vs)return!0;return l>=5&&Hs(e,t,s[0],c[0],s[4],c[4])<=Vs}getHandle(e,t,n,r,i,a,o){if(this.points.length!==this.requiredPoints)return null;for(let s=0;s<this.points.length;s++){let c=n.xToPixel(this.points[s].barIndex,r,a),l=n.yToPixel(this.points[s].price,i,o);if(Math.hypot(e-c,t-l)<=Vs+2)return{pointIndex:s,cursor:`grab`}}return null}},Ws=6;function Gs(e,t,n,r,i,a){let o=i-n,s=a-r,c=o*o+s*s;if(c===0)return Math.hypot(e-n,t-r);let l=Math.max(0,Math.min(1,((e-n)*o+(t-r)*s)/c));return Math.hypot(e-(n+l*o),t-(r+l*s))}var Ks=class{constructor(e){this.type=`batPattern`,this.requiredPoints=5,this.id=`bat_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let l=[`X`,`A`,`B`,`C`,`D`],u=this.points.map(e=>t.xToPixel(e.barIndex,n,i)),d=this.points.map(e=>t.yToPixel(e.price,r,a)),f=u.length,p=Y(`batPattern`,this.style,c);e.save(),e.strokeStyle=p.strokeColor,e.lineWidth=o?p.lineWidth+.5:p.lineWidth,X(e,o?`solid`:p.lineStyle,e.lineWidth),e.beginPath(),e.moveTo(u[0],d[0]);for(let t=1;t<f;t++)e.lineTo(u[t],d[t]);e.stroke(),e.setLineDash([]),f>=5&&(e.save(),e.setLineDash([5,4]),e.strokeStyle=p.strokeColor,e.lineWidth=o?p.lineWidth+.5:p.lineWidth,e.beginPath(),e.moveTo(u[0],d[0]),e.lineTo(u[4],d[4]),e.stroke(),e.restore()),e.font=`11px 'Inter', system-ui, sans-serif`,e.fillStyle=p.strokeColor;for(let t=0;t<f;t++){var m;e.beginPath(),e.arc(u[t],d[t],o?4:3,0,Math.PI*2),e.fill(),e.fillText((m=l[t])==null?String(t):m,u[t]+5,d[t]-5)}e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let s=this.points.map(e=>n.xToPixel(e.barIndex,r,a)),c=this.points.map(e=>n.yToPixel(e.price,i,o)),l=s.length;for(let n=0;n<l-1;n++)if(Gs(e,t,s[n],c[n],s[n+1],c[n+1])<=Ws)return!0;return l>=5&&Gs(e,t,s[0],c[0],s[4],c[4])<=Ws}getHandle(e,t,n,r,i,a,o){if(this.points.length!==this.requiredPoints)return null;for(let s=0;s<this.points.length;s++){let c=n.xToPixel(this.points[s].barIndex,r,a),l=n.yToPixel(this.points[s].price,i,o);if(Math.hypot(e-c,t-l)<=Ws+2)return{pointIndex:s,cursor:`grab`}}return null}},qs=6;function Js(e,t,n,r,i,a){let o=i-n,s=a-r,c=o*o+s*s;if(c===0)return Math.hypot(e-n,t-r);let l=Math.max(0,Math.min(1,((e-n)*o+(t-r)*s)/c));return Math.hypot(e-(n+l*o),t-(r+l*s))}var Ys=class{constructor(e){this.type=`gartleyPattern`,this.requiredPoints=5,this.id=`gart_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let l=[`X`,`A`,`B`,`C`,`D`],u=this.points.map(e=>t.xToPixel(e.barIndex,n,i)),d=this.points.map(e=>t.yToPixel(e.price,r,a)),f=u.length,p=Y(`gartleyPattern`,this.style,c);e.save(),e.strokeStyle=p.strokeColor,e.lineWidth=o?p.lineWidth+.5:p.lineWidth,X(e,o?`solid`:p.lineStyle,e.lineWidth),e.beginPath(),e.moveTo(u[0],d[0]);for(let t=1;t<f;t++)e.lineTo(u[t],d[t]);e.stroke(),e.setLineDash([]),f>=5&&(e.save(),e.setLineDash([5,4]),e.strokeStyle=p.strokeColor,e.lineWidth=o?p.lineWidth+.5:p.lineWidth,e.beginPath(),e.moveTo(u[0],d[0]),e.lineTo(u[4],d[4]),e.stroke(),e.restore()),e.font=`11px 'Inter', system-ui, sans-serif`,e.fillStyle=p.strokeColor;for(let t=0;t<f;t++){var m;e.beginPath(),e.arc(u[t],d[t],o?4:3,0,Math.PI*2),e.fill(),e.fillText((m=l[t])==null?String(t):m,u[t]+5,d[t]-5)}e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let s=this.points.map(e=>n.xToPixel(e.barIndex,r,a)),c=this.points.map(e=>n.yToPixel(e.price,i,o)),l=s.length;for(let n=0;n<l-1;n++)if(Js(e,t,s[n],c[n],s[n+1],c[n+1])<=qs)return!0;return l>=5&&Js(e,t,s[0],c[0],s[4],c[4])<=qs}getHandle(e,t,n,r,i,a,o){if(this.points.length!==this.requiredPoints)return null;for(let s=0;s<this.points.length;s++){let c=n.xToPixel(this.points[s].barIndex,r,a),l=n.yToPixel(this.points[s].price,i,o);if(Math.hypot(e-c,t-l)<=qs+2)return{pointIndex:s,cursor:`grab`}}return null}},Xs=6;function Zs(e,t,n,r,i,a){let o=i-n,s=a-r,c=o*o+s*s;if(c===0)return Math.hypot(e-n,t-r);let l=Math.max(0,Math.min(1,((e-n)*o+(t-r)*s)/c));return Math.hypot(e-(n+l*o),t-(r+l*s))}var Qs=class{constructor(e){this.type=`crabPattern`,this.requiredPoints=5,this.id=`crab_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let l=[`X`,`A`,`B`,`C`,`D`],u=this.points.map(e=>t.xToPixel(e.barIndex,n,i)),d=this.points.map(e=>t.yToPixel(e.price,r,a)),f=u.length,p=Y(`crabPattern`,this.style,c);e.save(),e.strokeStyle=p.strokeColor,e.lineWidth=o?p.lineWidth+.5:p.lineWidth,X(e,o?`solid`:p.lineStyle,e.lineWidth),e.beginPath(),e.moveTo(u[0],d[0]);for(let t=1;t<f;t++)e.lineTo(u[t],d[t]);e.stroke(),e.setLineDash([]),f>=5&&(e.save(),e.setLineDash([5,4]),e.strokeStyle=p.strokeColor,e.lineWidth=o?p.lineWidth+.5:p.lineWidth,e.beginPath(),e.moveTo(u[0],d[0]),e.lineTo(u[4],d[4]),e.stroke(),e.restore()),e.font=`11px 'Inter', system-ui, sans-serif`,e.fillStyle=p.strokeColor;for(let t=0;t<f;t++){var m;e.beginPath(),e.arc(u[t],d[t],o?4:3,0,Math.PI*2),e.fill(),e.fillText((m=l[t])==null?String(t):m,u[t]+5,d[t]-5)}e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let s=this.points.map(e=>n.xToPixel(e.barIndex,r,a)),c=this.points.map(e=>n.yToPixel(e.price,i,o)),l=s.length;for(let n=0;n<l-1;n++)if(Zs(e,t,s[n],c[n],s[n+1],c[n+1])<=Xs)return!0;return l>=5&&Zs(e,t,s[0],c[0],s[4],c[4])<=Xs}getHandle(e,t,n,r,i,a,o){if(this.points.length!==this.requiredPoints)return null;for(let s=0;s<this.points.length;s++){let c=n.xToPixel(this.points[s].barIndex,r,a),l=n.yToPixel(this.points[s].price,i,o);if(Math.hypot(e-c,t-l)<=Xs+2)return{pointIndex:s,cursor:`grab`}}return null}},$s=6;function ec(e,t,n,r,i,a){let o=i-n,s=a-r,c=o*o+s*s;if(c===0)return Math.hypot(e-n,t-r);let l=Math.max(0,Math.min(1,((e-n)*o+(t-r)*s)/c));return Math.hypot(e-(n+l*o),t-(r+l*s))}var tc=class{constructor(e){this.type=`sharkPattern`,this.requiredPoints=5,this.id=`shrk_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let l=[`X`,`A`,`B`,`C`,`D`],u=this.points.map(e=>t.xToPixel(e.barIndex,n,i)),d=this.points.map(e=>t.yToPixel(e.price,r,a)),f=u.length,p=Y(`sharkPattern`,this.style,c);e.save(),e.strokeStyle=p.strokeColor,e.lineWidth=o?p.lineWidth+.5:p.lineWidth,X(e,o?`solid`:p.lineStyle,e.lineWidth),e.beginPath(),e.moveTo(u[0],d[0]);for(let t=1;t<f;t++)e.lineTo(u[t],d[t]);e.stroke(),e.setLineDash([]),f>=5&&(e.save(),e.setLineDash([5,4]),e.strokeStyle=p.strokeColor,e.lineWidth=o?p.lineWidth+.5:p.lineWidth,e.beginPath(),e.moveTo(u[0],d[0]),e.lineTo(u[4],d[4]),e.stroke(),e.restore()),e.font=`11px 'Inter', system-ui, sans-serif`,e.fillStyle=p.strokeColor;for(let t=0;t<f;t++){var m;e.beginPath(),e.arc(u[t],d[t],o?4:3,0,Math.PI*2),e.fill(),e.fillText((m=l[t])==null?String(t):m,u[t]+5,d[t]-5)}e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let s=this.points.map(e=>n.xToPixel(e.barIndex,r,a)),c=this.points.map(e=>n.yToPixel(e.price,i,o)),l=s.length;for(let n=0;n<l-1;n++)if(ec(e,t,s[n],c[n],s[n+1],c[n+1])<=$s)return!0;return l>=5&&ec(e,t,s[0],c[0],s[4],c[4])<=$s}getHandle(e,t,n,r,i,a,o){if(this.points.length!==this.requiredPoints)return null;for(let s=0;s<this.points.length;s++){let c=n.xToPixel(this.points[s].barIndex,r,a),l=n.yToPixel(this.points[s].price,i,o);if(Math.hypot(e-c,t-l)<=$s+2)return{pointIndex:s,cursor:`grab`}}return null}},nc=6;function rc(e,t,n,r,i,a){let o=i-n,s=a-r,c=o*o+s*s;if(c===0)return Math.hypot(e-n,t-r);let l=Math.max(0,Math.min(1,((e-n)*o+(t-r)*s)/c));return Math.hypot(e-(n+l*o),t-(r+l*s))}var ic=[`0`,`1`,`2`,`3`,`4`,`5`],ac=class{constructor(e){this.type=`elliottImpulse`,this.requiredPoints=6,this.id=`eimp_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let l=this.points.map(e=>t.xToPixel(e.barIndex,n,i)),u=this.points.map(e=>t.yToPixel(e.price,r,a)),d=l.length,f=Y(`elliottImpulse`,this.style,c);e.save(),e.lineWidth=o?f.lineWidth+.5:f.lineWidth,X(e,o?`solid`:f.lineStyle,e.lineWidth);for(let t=0;t<d-1;t++)e.strokeStyle=t%2==0?f.strokeColor:Z(f.strokeColor,.67),e.beginPath(),e.moveTo(l[t],u[t]),e.lineTo(l[t+1],u[t+1]),e.stroke();e.setLineDash([]),e.font=`11px 'Inter', system-ui, sans-serif`;for(let t=0;t<d;t++){var p;e.beginPath(),e.arc(l[t],u[t],o?4:3,0,Math.PI*2),e.fillStyle=f.strokeColor,e.fill(),e.fillStyle=f.strokeColor,e.fillText((p=ic[t])==null?String(t):p,l[t]+5,u[t]-5)}e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let s=this.points.map(e=>n.xToPixel(e.barIndex,r,a)),c=this.points.map(e=>n.yToPixel(e.price,i,o));for(let n=0;n<s.length-1;n++)if(rc(e,t,s[n],c[n],s[n+1],c[n+1])<=nc)return!0;return!1}getHandle(e,t,n,r,i,a,o){if(!this.complete)return null;for(let s=0;s<this.points.length;s++){let c=n.xToPixel(this.points[s].barIndex,r,a),l=n.yToPixel(this.points[s].price,i,o);if(Math.hypot(e-c,t-l)<=nc+2)return{pointIndex:s,cursor:`grab`}}return null}},oc=6;function sc(e,t,n,r,i,a){let o=i-n,s=a-r,c=o*o+s*s;if(c===0)return Math.hypot(e-n,t-r);let l=Math.max(0,Math.min(1,((e-n)*o+(t-r)*s)/c));return Math.hypot(e-(n+l*o),t-(r+l*s))}var cc=[`0`,`A`,`B`,`C`],lc=class{constructor(e){this.type=`elliottCorrective`,this.requiredPoints=4,this.id=`ecor_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let l=this.points.map(e=>t.xToPixel(e.barIndex,n,i)),u=this.points.map(e=>t.yToPixel(e.price,r,a)),d=Y(`elliottCorrective`,this.style,c);e.save(),e.strokeStyle=d.strokeColor,e.lineWidth=o?d.lineWidth+.5:d.lineWidth,X(e,o?`solid`:d.lineStyle,e.lineWidth),e.beginPath(),e.moveTo(l[0],u[0]);for(let t=1;t<l.length;t++)e.lineTo(l[t],u[t]);e.stroke(),e.setLineDash([]),e.font=`11px 'Inter', system-ui, sans-serif`;for(let t=0;t<l.length;t++){var f;e.beginPath(),e.arc(l[t],u[t],o?4:3,0,Math.PI*2),e.fillStyle=d.strokeColor,e.fill(),e.fillStyle=d.strokeColor,e.fillText((f=cc[t])==null?String(t):f,l[t]+5,u[t]-5)}e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let s=this.points.map(e=>n.xToPixel(e.barIndex,r,a)),c=this.points.map(e=>n.yToPixel(e.price,i,o));for(let n=0;n<s.length-1;n++)if(sc(e,t,s[n],c[n],s[n+1],c[n+1])<=oc)return!0;return!1}getHandle(e,t,n,r,i,a,o){if(!this.complete)return null;for(let s=0;s<this.points.length;s++){let c=n.xToPixel(this.points[s].barIndex,r,a),l=n.yToPixel(this.points[s].price,i,o);if(Math.hypot(e-c,t-l)<=oc+2)return{pointIndex:s,cursor:`grab`}}return null}},uc=6;function dc(e,t,n,r,i,a){let o=i-n,s=a-r,c=o*o+s*s;if(c===0)return Math.hypot(e-n,t-r);let l=Math.max(0,Math.min(1,((e-n)*o+(t-r)*s)/c));return Math.hypot(e-(n+l*o),t-(r+l*s))}var fc=[`A`,`B`,`C`,`D`,`E`,`end`],pc=class{constructor(e){this.type=`elliottTriangle`,this.requiredPoints=6,this.id=`etri_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let l=this.points.map(e=>t.xToPixel(e.barIndex,n,i)),u=this.points.map(e=>t.yToPixel(e.price,r,a)),d=l.length,f=Y(`elliottTriangle`,this.style,c);e.save(),e.strokeStyle=f.strokeColor,e.lineWidth=o?f.lineWidth+.5:f.lineWidth,X(e,o?`solid`:f.lineStyle,e.lineWidth),e.beginPath(),e.moveTo(l[0],u[0]);for(let t=1;t<d;t++)e.lineTo(l[t],u[t]);e.stroke(),e.setLineDash([]),d>=3&&(e.save(),e.setLineDash([5,4]),e.strokeStyle=Z(f.strokeColor,.67),e.lineWidth=f.lineWidth,e.beginPath(),e.moveTo(l[0],u[0]),d>2&&e.lineTo(l[2],u[2]),d>4&&e.lineTo(l[4],u[4]),e.stroke(),e.restore()),d>=4&&(e.save(),e.setLineDash([5,4]),e.strokeStyle=Z(f.strokeColor,.67),e.lineWidth=f.lineWidth,e.beginPath(),e.moveTo(l[1],u[1]),e.lineTo(l[3],u[3]),e.stroke(),e.restore()),e.font=`11px 'Inter', system-ui, sans-serif`;for(let t=0;t<d;t++){var p;e.beginPath(),e.arc(l[t],u[t],o?4:3,0,Math.PI*2),e.fillStyle=f.strokeColor,e.fill(),e.fillStyle=f.strokeColor,e.fillText((p=fc[t])==null?String(t):p,l[t]+5,u[t]-5)}e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let s=this.points.map(e=>n.xToPixel(e.barIndex,r,a)),c=this.points.map(e=>n.yToPixel(e.price,i,o));for(let n=0;n<s.length-1;n++)if(dc(e,t,s[n],c[n],s[n+1],c[n+1])<=uc)return!0;return!1}getHandle(e,t,n,r,i,a,o){if(!this.complete)return null;for(let s=0;s<this.points.length;s++){let c=n.xToPixel(this.points[s].barIndex,r,a),l=n.yToPixel(this.points[s].price,i,o);if(Math.hypot(e-c,t-l)<=uc+2)return{pointIndex:s,cursor:`grab`}}return null}},mc=6;function hc(e,t,n,r,i,a){let o=i-n,s=a-r,c=o*o+s*s;if(c===0)return Math.hypot(e-n,t-r);let l=Math.max(0,Math.min(1,((e-n)*o+(t-r)*s)/c));return Math.hypot(e-(n+l*o),t-(r+l*s))}var gc=[`W`,`X`,`Y`,`X2`,`Z`,`X3`,`end`],_c=class{constructor(e){this.type=`elliottCombination`,this.requiredPoints=7,this.id=`ecom_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let l=this.points.map(e=>t.xToPixel(e.barIndex,n,i)),u=this.points.map(e=>t.yToPixel(e.price,r,a)),d=Y(`elliottCombination`,this.style,c);e.save(),e.strokeStyle=d.strokeColor,e.lineWidth=o?d.lineWidth+.5:d.lineWidth,X(e,o?`solid`:d.lineStyle,e.lineWidth),e.beginPath(),e.moveTo(l[0],u[0]);for(let t=1;t<l.length;t++)e.lineTo(l[t],u[t]);e.stroke(),e.setLineDash([]),e.font=`11px 'Inter', system-ui, sans-serif`;for(let t=0;t<l.length;t++){var f;e.beginPath(),e.arc(l[t],u[t],o?4:3,0,Math.PI*2),e.fillStyle=d.strokeColor,e.fill(),e.fillStyle=d.strokeColor,e.fillText((f=gc[t])==null?String(t):f,l[t]+5,u[t]-5)}e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let s=this.points.map(e=>n.xToPixel(e.barIndex,r,a)),c=this.points.map(e=>n.yToPixel(e.price,i,o));for(let n=0;n<s.length-1;n++)if(hc(e,t,s[n],c[n],s[n+1],c[n+1])<=mc)return!0;return!1}getHandle(e,t,n,r,i,a,o){if(!this.complete)return null;for(let s=0;s<this.points.length;s++){let c=n.xToPixel(this.points[s].barIndex,r,a),l=n.yToPixel(this.points[s].price,i,o);if(Math.hypot(e-c,t-l)<=mc+2)return{pointIndex:s,cursor:`grab`}}return null}},vc=6;function yc(e,t,n,r,i,a){let o=i-n,s=a-r,c=o*o+s*s;if(c===0)return Math.hypot(e-n,t-r);let l=Math.max(0,Math.min(1,((e-n)*o+(t-r)*s)/c));return Math.hypot(e-(n+l*o),t-(r+l*s))}var bc=[`W`,`X`,`Y`,`end`],xc=class{constructor(e){this.type=`elliottWxy`,this.requiredPoints=4,this.id=`ewxy_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let l=this.points.map(e=>t.xToPixel(e.barIndex,n,i)),u=this.points.map(e=>t.yToPixel(e.price,r,a)),d=Y(`elliottWxy`,this.style,c);e.save(),e.strokeStyle=d.strokeColor,e.lineWidth=o?d.lineWidth+.5:d.lineWidth,X(e,o?`solid`:d.lineStyle,e.lineWidth),e.beginPath(),e.moveTo(l[0],u[0]);for(let t=1;t<l.length;t++)e.lineTo(l[t],u[t]);e.stroke(),e.setLineDash([]),e.font=`11px 'Inter', system-ui, sans-serif`;for(let t=0;t<l.length;t++){var f;e.beginPath(),e.arc(l[t],u[t],o?4:3,0,Math.PI*2),e.fillStyle=d.strokeColor,e.fill(),e.fillStyle=d.strokeColor,e.fillText((f=bc[t])==null?String(t):f,l[t]+5,u[t]-5)}e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let s=this.points.map(e=>n.xToPixel(e.barIndex,r,a)),c=this.points.map(e=>n.yToPixel(e.price,i,o));for(let n=0;n<s.length-1;n++)if(yc(e,t,s[n],c[n],s[n+1],c[n+1])<=vc)return!0;return!1}getHandle(e,t,n,r,i,a,o){if(!this.complete)return null;for(let s=0;s<this.points.length;s++){let c=n.xToPixel(this.points[s].barIndex,r,a),l=n.yToPixel(this.points[s].price,i,o);if(Math.hypot(e-c,t-l)<=vc+2)return{pointIndex:s,cursor:`grab`}}return null}},Sc=8;function Cc(e,t,n,r,i,a){let o=i-n,s=a-r,c=o*o+s*s;if(c===0)return Math.hypot(e-n,t-r);let l=Math.max(0,Math.min(1,((e-n)*o+(t-r)*s)/c));return Math.hypot(e-(n+l*o),t-(r+l*s))}var wc=class{constructor(e){this.type=`brush`,this.freehand=!0,this.openEnded=!0,this.freehandMode=!1,this.id=`brush_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c,l){var u;if(this.points.length<2)return;this.freehandMode=(l==null||(u=l.features)==null?void 0:u.enableForecasting)===!0;let d=this.points.map(e=>({x:t.xToPixel(e.barIndex,n,i),y:t.yToPixel(e.price,r,a)})),f=Y(`brush`,this.style,c);if(e.save(),e.strokeStyle=f.strokeColor,e.lineWidth=o?f.lineWidth+.5:f.lineWidth,e.lineCap=`round`,e.lineJoin=`round`,this.freehandMode){e.setLineDash([]),e.beginPath(),wi(e,d),e.stroke(),e.restore();return}let p=this.complete?d.length:d.length-1;if(p>=2){e.setLineDash([]),e.beginPath(),e.moveTo(d[0].x,d[0].y);for(let t=1;t<p;t++)e.lineTo(d[t].x,d[t].y);e.stroke()}if(!this.complete&&d.length>=2){let t=d.length-1;e.setLineDash([4,4]),e.beginPath(),e.moveTo(d[t-1].x,d[t-1].y),e.lineTo(d[t].x,d[t].y),e.stroke(),e.setLineDash([])}e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let s=this.points.map(e=>({x:n.xToPixel(e.barIndex,r,a),y:n.yToPixel(e.price,i,o)})),c=this.freehandMode||this.complete?s.length-1:s.length-2;for(let n=0;n<c;n++)if(Cc(e,t,s[n].x,s[n].y,s[n+1].x,s[n+1].y)<=Sc)return!0;return!1}getHandle(e,t,n,r,i,a,o){if(this.points.length===0)return null;let s=[0,this.points.length-1];for(let c of s){let s=n.xToPixel(this.points[c].barIndex,r,a),l=n.yToPixel(this.points[c].price,i,o);if(Math.hypot(e-s,t-l)<=Sc+2)return{pointIndex:c,cursor:`grab`}}return null}},Tc=12;function Ec(e,t,n,r,i,a){let o=i-n,s=a-r,c=o*o+s*s;if(c===0)return Math.hypot(e-n,t-r);let l=Math.max(0,Math.min(1,((e-n)*o+(t-r)*s)/c));return Math.hypot(e-(n+l*o),t-(r+l*s))}var Dc=class{constructor(e){this.type=`highlighter`,this.freehand=!0,this.openEnded=!0,this.freehandMode=!1,this.id=`hl2_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c,l){var u;if(this.points.length<2)return;this.freehandMode=(l==null||(u=l.features)==null?void 0:u.enableForecasting)===!0;let d=this.points.map(e=>({x:t.xToPixel(e.barIndex,n,i),y:t.yToPixel(e.price,r,a)})),f=Y(`highlighter`,this.style,c);if(e.save(),e.strokeStyle=Z(f.strokeColor,f.fillOpacity),e.lineWidth=o?f.lineWidth+.5:f.lineWidth,e.lineCap=`round`,e.lineJoin=`round`,this.freehandMode){e.setLineDash([]),e.beginPath(),wi(e,d),e.stroke(),e.restore();return}let p=this.complete?d.length:d.length-1;if(p>=2){e.setLineDash([]),e.beginPath(),e.moveTo(d[0].x,d[0].y);for(let t=1;t<p;t++)e.lineTo(d[t].x,d[t].y);e.stroke()}if(!this.complete&&d.length>=2){let t=d.length-1;e.setLineDash([8,6]),e.beginPath(),e.moveTo(d[t-1].x,d[t-1].y),e.lineTo(d[t].x,d[t].y),e.stroke(),e.setLineDash([])}e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let s=this.points.map(e=>({x:n.xToPixel(e.barIndex,r,a),y:n.yToPixel(e.price,i,o)})),c=this.freehandMode||this.complete?s.length-1:s.length-2;for(let n=0;n<c;n++)if(Ec(e,t,s[n].x,s[n].y,s[n+1].x,s[n+1].y)<=Tc)return!0;return!1}getHandle(e,t,n,r,i,a,o){if(this.points.length===0)return null;let s=[0,this.points.length-1];for(let c of s){let s=n.xToPixel(this.points[c].barIndex,r,a),l=n.yToPixel(this.points[c].price,i,o);if(Math.hypot(e-s,t-l)<=Tc+2)return{pointIndex:c,cursor:`grab`}}return null}},Oc=6,kc=class{constructor(e){this.type=`sineLine`,this.id=`sine_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let[l,u]=this.points,d=t.xToPixel(l.barIndex,n,i),f=t.yToPixel(l.price,r,a),p=t.xToPixel(u.barIndex,n,i),m=t.yToPixel(u.price,r,a),h=p-d,g=Math.abs(m-f)/2,_=(f+m)/2,v=Y(`sineLine`,this.style,c);if(e.save(),e.strokeStyle=v.strokeColor,e.lineWidth=o?v.lineWidth+.5:v.lineWidth,X(e,o?`solid`:v.lineStyle,e.lineWidth),e.beginPath(),Math.abs(h)<1)e.moveTo(d,f),e.lineTo(p,m);else{e.moveTo(d,_+g*Math.sin(0));let t=h>0?1:-1,n=p;for(let r=d+t;h>0?r<=n:r>=n;r+=t){let t=(r-d)/h,n=_+g*Math.sin(2*Math.PI*t);e.lineTo(r,n)}e.lineTo(p,_+g*Math.sin(2*Math.PI))}e.stroke(),e.setLineDash([]),e.fillStyle=v.strokeColor;for(let[t,n]of[[d,f],[p,m]])e.beginPath(),e.arc(t,n,o?4:3,0,Math.PI*2),e.fill();e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let[s,c]=this.points,l=n.xToPixel(s.barIndex,r,a),u=n.yToPixel(s.price,i,o),d=n.xToPixel(c.barIndex,r,a),f=n.yToPixel(c.price,i,o),p=d-l,m=Math.abs(f-u)/2,h=(u+f)/2;if(Math.abs(p)<1)return Math.hypot(e-l,t-h)<=Oc;let g=p>0?5:-5,_=l,v=h+m*Math.sin(0);for(let n=l+g;p>0?n<=d+Math.abs(g):n>=d-Math.abs(g);n+=g){let r=p>0?Math.min(n,d):Math.max(n,d),i=(r-l)/p,a=h+m*Math.sin(2*Math.PI*i);if(Math.hypot(e-r,t-a)<=Oc)return!0;let o=r-_,s=a-v,c=o*o+s*s;if(c>0){let n=Math.max(0,Math.min(1,((e-_)*o+(t-v)*s)/c)),r=_+n*o,i=v+n*s;if(Math.hypot(e-r,t-i)<=Oc)return!0}if(_=r,v=a,r===d)break}return!1}getHandle(e,t,n,r,i,a,o){let s=[{px:n.xToPixel(this.points[0].barIndex,r,a),py:n.yToPixel(this.points[0].price,i,o)},{px:n.xToPixel(this.points[1].barIndex,r,a),py:n.yToPixel(this.points[1].price,i,o)}];for(let n=0;n<s.length;n++)if(Math.hypot(e-s[n].px,t-s[n].py)<=Oc+2)return{pointIndex:n,cursor:`grab`};return null}},Ac=6,jc=class{constructor(e){this.type=`cyclicLines`,this.id=`cyc_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let[l,u]=this.points,d=Math.abs(u.barIndex-l.barIndex);if(d===0)return;let f=t.xToPixel(l.barIndex,n,i),p=Y(`cyclicLines`,this.style,c);e.save(),e.strokeStyle=p.strokeColor,e.lineWidth=o?p.lineWidth+.5:p.lineWidth,X(e,o?`solid`:p.lineStyle,e.lineWidth);for(let r=0;r<=8;r++){let o=l.barIndex+d*r,s=t.xToPixel(o,n,i);if(s>i)break;e.beginPath(),e.moveTo(s,0),e.lineTo(s,a),e.stroke()}e.setLineDash([]);let m=t.xToPixel(u.barIndex,n,i);e.fillStyle=p.strokeColor,e.beginPath(),e.arc(f,a/2,o?4:3,0,Math.PI*2),e.fill(),e.beginPath(),e.arc(m,a/2,o?4:3,0,Math.PI*2),e.fill(),e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let[s,c]=this.points,l=Math.abs(c.barIndex-s.barIndex);if(l===0)return!1;for(let t=0;t<=8;t++){let i=s.barIndex+l*t,o=n.xToPixel(i,r,a);if(o>a)break;if(Math.abs(e-o)<=Ac)return!0}return!1}getHandle(e,t,n,r,i,a,o){if(this.points.length<2)return null;let s=[{px:n.xToPixel(this.points[0].barIndex,r,a),py:o/2},{px:n.xToPixel(this.points[1].barIndex,r,a),py:o/2}],c=[`move`,`ew-resize`];for(let n=0;n<s.length;n++)if(Math.hypot(e-s[n].px,t-s[n].py)<=Ac+2)return{pointIndex:n,cursor:c[n]};return null}},Mc=6,Nc=class{constructor(e){this.type=`timeCycles`,this.id=`tcy_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let[l,u]=this.points,d=Math.abs(u.barIndex-l.barIndex);if(d===0)return;let f=Y(`timeCycles`,this.style,c),p=Z(f.fillColor,f.fillOpacity);e.save(),e.font=`10px 'Inter', system-ui, sans-serif`,e.lineWidth=o?f.lineWidth+.5:f.lineWidth;let m=[];for(let e=0;e<=6;e++){let r=l.barIndex+d*e,a=t.xToPixel(r,n,i);if(a>i)break;m.push(a)}for(let t=0;t+1<m.length;t++)t%2==0&&(e.fillStyle=p,e.fillRect(m[t],0,m[t+1]-m[t],a));e.strokeStyle=f.strokeColor,X(e,o?`solid`:f.lineStyle,e.lineWidth);for(let t=0;t<m.length;t++)e.beginPath(),e.moveTo(m[t],0),e.lineTo(m[t],a),e.stroke(),e.fillStyle=f.strokeColor,e.fillText(String(t+1),m[t]+3,14);e.setLineDash([]);let h=t.xToPixel(l.barIndex,n,i),g=t.xToPixel(u.barIndex,n,i);e.fillStyle=f.strokeColor,e.beginPath(),e.arc(h,a/2,o?4:3,0,Math.PI*2),e.fill(),e.beginPath(),e.arc(g,a/2,o?4:3,0,Math.PI*2),e.fill(),e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let[s,c]=this.points,l=Math.abs(c.barIndex-s.barIndex);if(l===0)return!1;for(let t=0;t<=6;t++){let i=s.barIndex+l*t,o=n.xToPixel(i,r,a);if(o>a)break;if(Math.abs(e-o)<=Mc)return!0;if(t<6){let i=s.barIndex+l*(t+1),c=n.xToPixel(i,r,a);if(e>=o&&e<=c)return!0}}return!1}getHandle(e,t,n,r,i,a,o){if(this.points.length<2)return null;let s=[{px:n.xToPixel(this.points[0].barIndex,r,a),py:o/2},{px:n.xToPixel(this.points[1].barIndex,r,a),py:o/2}],c=[`move`,`ew-resize`];for(let n=0;n<s.length;n++)if(Math.hypot(e-s[n].px,t-s[n].py)<=Mc+2)return{pointIndex:n,cursor:c[n]};return null}},Pc=6;function Fc(e,t,n,r,i,a){let o=i-n,s=a-r,c=o*o+s*s;if(c===0)return Math.hypot(e-n,t-r);let l=Math.max(0,Math.min(1,((e-n)*o+(t-r)*s)/c));return Math.hypot(e-(n+l*o),t-(r+l*s))}var Ic=class{constructor(e){this.type=`projection`,this.id=`proj_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let[l,u]=this.points,d=t.xToPixel(l.barIndex,n,i),f=t.yToPixel(l.price,r,a),p=t.xToPixel(u.barIndex,n,i),m=t.yToPixel(u.price,r,a),h=Y(`projection`,this.style,c),g=p-d,_,v;if(Math.abs(g)<.001)_=p,v=m+(m-f);else{let e=(m-f)/g;_=i,v=m+e*(i-p)}e.save(),e.strokeStyle=h.strokeColor,e.fillStyle=h.strokeColor,e.lineWidth=o?h.lineWidth+.5:h.lineWidth,e.setLineDash([]),e.beginPath(),e.moveTo(d,f),e.lineTo(p,m),e.stroke(),X(e,h.lineStyle===`solid`?`dashed`:h.lineStyle,e.lineWidth),e.beginPath(),e.moveTo(p,m),e.lineTo(_,v),e.stroke(),e.setLineDash([]),e.beginPath(),e.arc(d,f,o?4:3,0,Math.PI*2),e.fill(),e.beginPath(),e.arc(p,m,o?4:3,0,Math.PI*2),e.fill(),e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let[s,c]=this.points,l=n.xToPixel(s.barIndex,r,a),u=n.yToPixel(s.price,i,o),d=n.xToPixel(c.barIndex,r,a),f=n.yToPixel(c.price,i,o),p=d-l,m,h;if(Math.abs(p)<.001)m=d,h=f+(f-u);else{let e=(f-u)/p;m=a,h=f+e*(a-d)}return Fc(e,t,l,u,d,f)<=Pc||Fc(e,t,d,f,m,h)<=Pc}getHandle(e,t,n,r,i,a,o){if(this.points.length<2)return null;let s=[{px:n.xToPixel(this.points[0].barIndex,r,a),py:n.yToPixel(this.points[0].price,i,o)},{px:n.xToPixel(this.points[1].barIndex,r,a),py:n.yToPixel(this.points[1].price,i,o)}];for(let n=0;n<s.length;n++)if(Math.hypot(e-s[n].px,t-s[n].py)<=Pc+2)return{pointIndex:n,cursor:`grab`};return null}},Lc=6;function Rc(e,t,n,r,i,a=7){let o=Math.atan2(i-n,r-t);e.beginPath(),e.moveTo(r,i),e.lineTo(r-a*Math.cos(o-Math.PI/6),i-a*Math.sin(o-Math.PI/6)),e.lineTo(r-a*Math.cos(o+Math.PI/6),i-a*Math.sin(o+Math.PI/6)),e.closePath(),e.fill()}var zc=class{constructor(e){this.type=`priceProjection`,this.id=`pp_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s=2,c){if(this.points.length<2)return;let[l,u]=this.points,d=t.xToPixel(l.barIndex,n,i),f=t.yToPixel(l.price,r,a),p=t.xToPixel(u.barIndex,n,i),m=t.yToPixel(u.price,r,a),h=Math.min(d,p),g=Math.max(d,p),_=Math.min(f,m),v=Math.max(f,m),y=g-h,b=v-_,x=h+y/2,S=(l.price+u.price)/2,C=Y(`priceProjection`,this.style,c);e.save(),e.font=`10px 'Inter', system-ui, sans-serif`,e.lineWidth=o?C.lineWidth+.5:C.lineWidth,e.fillStyle=Z(C.fillColor,C.fillOpacity),e.fillRect(h,_,y,b),e.strokeStyle=C.strokeColor,X(e,o?`solid`:C.lineStyle,e.lineWidth),e.beginPath(),e.moveTo(h,f),e.lineTo(g,f),e.stroke();let w=t.yToPixel(S,r,a);e.beginPath(),e.moveTo(h,w),e.lineTo(g,w),e.stroke(),e.beginPath(),e.moveTo(h,m),e.lineTo(g,m),e.stroke(),e.setLineDash([]),e.fillStyle=C.strokeColor,e.fillText(l.price.toFixed(s),g+4,f+4),e.fillText(S.toFixed(s),g+4,w+4),e.fillText(u.price.toFixed(s),g+4,m+4),e.fillStyle=C.strokeColor,e.beginPath(),e.moveTo(x,_),e.lineTo(x,v),e.stroke(),Rc(e,x,v,x,_),Rc(e,x,_,x,v),e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let[s,c]=this.points,l=n.xToPixel(s.barIndex,r,a),u=n.yToPixel(s.price,i,o),d=n.xToPixel(c.barIndex,r,a),f=n.yToPixel(c.price,i,o);return e>=Math.min(l,d)&&e<=Math.max(l,d)&&t>=Math.min(u,f)&&t<=Math.max(u,f)}getHandle(e,t,n,r,i,a,o){if(this.points.length<2)return null;let s=[{px:n.xToPixel(this.points[0].barIndex,r,a),py:n.yToPixel(this.points[0].price,i,o)},{px:n.xToPixel(this.points[1].barIndex,r,a),py:n.yToPixel(this.points[1].price,i,o)}];for(let n=0;n<s.length;n++)if(Math.hypot(e-s[n].px,t-s[n].py)<=Lc+2)return{pointIndex:n,cursor:`ns-resize`};return null}},Bc=6,Vc=class{constructor(e){this.type=`ghostFeed`,this.id=`gfeed_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}render(e,t,n,r,i,a,o,s,c){if(this.points.length<2)return;let[l,u]=this.points,d=t.xToPixel(l.barIndex,n,i),f=t.yToPixel(l.price,r,a),p=t.xToPixel(u.barIndex,n,i),m=t.yToPixel(u.price,r,a),h=Math.min(d,p),g=Math.min(f,m),_=Math.abs(p-d),v=Math.abs(m-f),y=Y(`ghostFeed`,this.style,c);e.save(),e.fillStyle=Z(y.fillColor,y.fillOpacity),e.fillRect(h,g,_,v),e.strokeStyle=y.strokeColor,e.lineWidth=o?y.lineWidth+.5:y.lineWidth,X(e,o?`solid`:y.lineStyle,e.lineWidth),e.strokeRect(h,g,_,v),e.setLineDash([]),e.save(),e.beginPath(),e.rect(h,g,_,v),e.clip(),e.strokeStyle=Z(y.strokeColor,.19),e.lineWidth=1,e.setLineDash([4,4]);let b=_+v;for(let t=-v;t<=b;t+=20){let n=h+t,r=g,i=h+t+v,a=g+v;e.beginPath(),e.moveTo(n,r),e.lineTo(i,a),e.stroke()}if(e.setLineDash([]),e.restore(),e.font=`12px 'Inter', system-ui, sans-serif`,e.fillStyle=y.strokeColor,e.textAlign=`center`,e.textBaseline=`middle`,e.fillText(`Ghost Feed`,h+_/2,g+v/2),o){e.textAlign=`left`,e.textBaseline=`alphabetic`;for(let[t,n]of[[d,f],[p,m]])e.beginPath(),e.arc(t,n,3.5,0,Math.PI*2),e.fillStyle=y.strokeColor,e.fill()}e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let[s,c]=this.points,l=n.xToPixel(s.barIndex,r,a),u=n.yToPixel(s.price,i,o),d=n.xToPixel(c.barIndex,r,a),f=n.yToPixel(c.price,i,o),p=Math.min(l,d)-Bc,m=Math.min(u,f)-Bc,h=Math.abs(d-l)+Bc*2,g=Math.abs(f-u)+Bc*2;return e>=p&&e<=p+h&&t>=m&&t<=m+g}getHandle(e,t,n,r,i,a,o){if(this.points.length<2)return null;let s=[[0,n.xToPixel(this.points[0].barIndex,r,a),n.yToPixel(this.points[0].price,i,o)],[1,n.xToPixel(this.points[1].barIndex,r,a),n.yToPixel(this.points[1].price,i,o)]];for(let[n,r,i]of s)if(Math.hypot(e-r,t-i)<=Bc+2)return{pointIndex:n,cursor:`nwse-resize`};return null}},Hc=6,Uc=`#26a69a`,Wc=`#ef5350`,Gc=`11px 'Inter', system-ui, sans-serif`,Kc=13,qc=7,Jc=5,Yc=2,Xc=1;function Zc(e,t,n,r,i,a){let o=i-n,s=a-r,c=o*o+s*s;if(c===0)return Math.hypot(e-n,t-r);let l=Math.max(0,Math.min(1,((e-n)*o+(t-r)*s)/c));return Math.hypot(e-(n+l*o),t-(r+l*s))}function Qc(e,t,n,r,i,a){let o=Math.min(a,r/2,i/2);e.moveTo(t+o,n),e.arcTo(t+r,n,t+r,n+i,o),e.arcTo(t+r,n+i,t,n+i,o),e.arcTo(t,n+i,t,n,o),e.arcTo(t,n,t+r,n,o),e.closePath()}var $c=class{constructor(e,t){this.requiredPoints=2,this.id=`${t}_${Date.now()}_${Math.random().toString(36).slice(2)}`,this.points=[e,{...e}],this.complete=!1}onPlaced(){if(this.points.length>=3)return;let e=this.points[0].price,t=this.points[1].price,n=Math.abs(t-e),r=n>0?n/Yc:Math.abs(e)*.001||1;this.points.push({barIndex:this.points[1].barIndex,price:this.isLong?e-r:e+r})}prices(){var e,t;let n=this.points[0].price,r=(e=(t=this.points[1])==null?void 0:t.price)==null?n:e;if(this.points[2])return{entry:n,target:r,stop:this.points[2].price};let i=Math.abs(r-n)/Yc;return{entry:n,target:r,stop:this.isLong?n-i:n+i}}render(e,t,n,r,i,a,o,s=2,c,l){var u,d,f,p,m,h,g,_,v,y,b,x;if(this.points.length<2)return;let{entry:S,target:C,stop:w}=this.prices(),T=Y(this.type,this.style,c),E=(u=c==null||(d=c.candle)==null?void 0:d.up)==null?Uc:u,D=(f=c==null||(p=c.candle)==null?void 0:p.down)==null?Wc:f,O=t.xToPixel(this.points[0].barIndex,n,i),k=t.xToPixel(this.points[1].barIndex,n,i),A=Math.min(O,k),j=Math.max(O,k),M=Math.max(1,j-A),P=t.yToPixel(S,r,a),F=t.yToPixel(C,r,a),I=t.yToPixel(w,r,a);e.save(),e.fillStyle=Z(E,T.fillOpacity),e.fillRect(A,Math.min(P,F),M,Math.abs(F-P)),e.fillStyle=Z(D,T.fillOpacity),e.fillRect(A,Math.min(P,I),M,Math.abs(I-P)),e.lineWidth=o?T.lineWidth+.5:T.lineWidth,e.setLineDash([]),e.strokeStyle=E,e.strokeRect(A,Math.min(P,F),M,Math.abs(F-P)),e.strokeStyle=D,e.strokeRect(A,Math.min(P,I),M,Math.abs(I-P)),e.strokeStyle=(m=(h=this.style)==null?void 0:h.strokeColor)==null?T.strokeColor:m,e.beginPath(),e.moveTo(A,P),e.lineTo(j,P),e.stroke();let L=l==null?void 0:l.instrument,R=l==null?void 0:l.account,z=(g=this.accountSize)==null?R==null?void 0:R.size:g,B=(_=(v=this.riskPercent)==null?R==null?void 0:R.riskPercent:v)==null?Xc:_,ee=z==null?null:Ce({entryPrice:S,stopPrice:w,accountSize:z,riskPercent:B,valuePerPoint:(y=L==null?void 0:L.valuePerPoint)==null?1:y}),te=(b=L==null?void 0:L.valuePerPoint)==null?1:b,ne=(e,t)=>{let n=Math.abs(e-S),r=S===0?0:n/Math.abs(S)*100,i=`${t}: ${n.toFixed(s)} (${r.toFixed(3)}%)`;if(L&&(i+=` ${N(n,L.pipSize).toFixed(1)}`),ee!=null){let e=n*ee*te;i+=`, Amount: ${e.toFixed(2)}`}return i};e.font=Gc,e.textBaseline=`top`,e.textAlign=`center`;let re=(A+j)/2,ie=(t,n,r,o)=>{let s=0;for(let n of t)s=Math.max(s,e.measureText(n).width);let c=s+qc*2,l=t.length*Kc+Jc*2,u=o?n-l-2:n+2;u=Math.max(2,Math.min(a-l-2,u));let d=Math.max(2,Math.min(i-c-2,re-c/2));e.beginPath(),Qc(e,d,u,c,l,3),e.fillStyle=r,e.fill(),e.fillStyle=`#ffffff`;for(let n=0;n<t.length;n++)e.fillText(t[n],d+c/2,u+Jc+n*Kc)};ie([ne(C,`Target`)],F,E,this.isLong),ie([ne(w,`Stop`)],I,D,!this.isLong);let ae=[],oe=l==null||(x=l.bars)==null||(x=x[l.bars.length-1])==null?void 0:x.close;if(typeof oe==`number`&&Number.isFinite(oe)){let e=`Open PnL: ${(this.isLong?oe-S:S-oe).toFixed(s)}`;ee!=null&&(e+=`, Qty: ${Math.round(ee)}`),ae.push(e)}else ee!=null&&ae.push(`Qty: ${Math.round(ee)}`);let se=we(S,C,w);if(se!=null&&ae.push(`Risk/reward ratio: ${se.toFixed(2)}`),ae.length>0){var ce,V;ie(ae,P,(ce=(V=this.style)==null?void 0:V.strokeColor)==null?T.strokeColor:ce,!1)}if(o){e.fillStyle=T.strokeColor;for(let[t,n]of[[O,P],[k,F],[k,I]])e.beginPath(),e.arc(t,n,3.5,0,Math.PI*2),e.fill()}e.restore()}hitTest(e,t,n,r,i,a,o){if(this.points.length<2)return!1;let{entry:s,target:c,stop:l}=this.prices(),u=n.xToPixel(this.points[0].barIndex,r,a),d=n.xToPixel(this.points[1].barIndex,r,a),f=Math.min(u,d),p=Math.max(u,d);return[s,c,l].some(r=>{let a=n.yToPixel(r,i,o);return Zc(e,t,f,a,p,a)<=Hc})}getHandle(e,t,n,r,i,a,o){if(this.points.length<2)return null;let{entry:s,target:c,stop:l}=this.prices(),u=n.xToPixel(this.points[0].barIndex,r,a),d=n.xToPixel(this.points[1].barIndex,r,a),f=[{hx:u,hy:n.yToPixel(s,i,o),handle:{pointIndex:0,cursor:`move`}},{hx:d,hy:n.yToPixel(c,i,o),handle:{pointIndex:1,cursor:`ns-resize`}}];this.points[2]&&f.push({hx:d,hy:n.yToPixel(l,i,o),handle:{pointIndex:2,cursor:`ns-resize`}});for(let{hx:n,hy:r,handle:i}of f)if(Math.hypot(e-n,t-r)<=Hc+2)return i;return null}},el=class extends $c{constructor(e){super(e,`lpos`),this.type=`longPosition`,this.isLong=!0}},tl=class extends $c{constructor(e){super(e,`spos`),this.type=`shortPosition`,this.isLong=!1}};function nl(e,t,n){let r=n.x-t.x,i=n.y-t.y,a=r*r+i*i;return a===0?Math.hypot(e.x-t.x,e.y-t.y):Math.abs(i*e.x-r*e.y+n.x*t.y-n.y*t.x)/Math.sqrt(a)}function rl(e,t){if(e.length<=2)return e.map((e,t)=>t);let n=new Uint8Array(e.length);n[0]=1,n[e.length-1]=1;let r=[[0,e.length-1]];for(;r.length>0;){let i=r.pop();if(!i)break;let[a,o]=i;if(o-a<2)continue;let s=-1,c=-1;for(let t=a+1;t<o;t++){let n=nl(e[t],e[a],e[o]);n>s&&(s=n,c=t)}c>0&&s>t&&(n[c]=1,r.push([a,c],[c,o]))}let i=[];for(let t=0;t<e.length;t++)n[t]&&i.push(t);return i}var il=new Set([`text`,`callout`,`anchoredNote`]),al=1.2,ol=3;function sl(e){return e.freehand===!0}var cl=class{constructor(){this.drawings=[],this.activeDrawing=null,this.selectedDrawing=null,this.activeTool=null,this.state=`idle`,this.freehandEnabled=!1,this.history=[],this.redoStack=[],this.onCompleteCallback=null,this.onDrawingsChange=null,this.onStartTextEdit=null,this.onPointsMutated=null,this.onSelectionChange=null,this.editingText=!1,this.dragDrawing=null,this.dragStartMouse=null,this.dragStartPoints=null,this.resizeDrawing=null,this.resizePointIndex=-1,this.resizeHandle=null}setSelected(e){var t;this.selectedDrawing!==e&&(this.selectedDrawing=e,(t=this.onSelectionChange)==null||t.call(this,e))}setOnComplete(e){this.onCompleteCallback=e}setFreehandEnabled(e){this.freehandEnabled=e}setEditingText(e){this.editingText=e}setActiveTool(e){this.state===`placing`&&this.activeDrawing&&this.drawings.pop(),this.activeTool=e,this.state=`idle`,this.activeDrawing=null}getActiveTool(){return this.activeTool}onMouseDown(e){if(!this.activeTool)return!1;if(this.state===`idle`){if(this.snapshot(),this.activeDrawing=this.createDrawing(this.activeTool,e),this.drawings.push(this.activeDrawing),this.activeDrawing.complete){var t,n;let e=this.activeDrawing;if((t=e.onPlaced)==null||t.call(e),this.setSelected(e),this.activeDrawing=null,this.activeTool=null,(n=this.onCompleteCallback)==null||n.call(this),this.notifyChange(),il.has(e.type)){var r;(r=this.onStartTextEdit)==null||r.call(this,e)}}else this.state=`placing`;return!0}if(this.state===`placing`&&this.activeDrawing){var i,a,o,s;if(this.freehandEnabled&&sl(this.activeDrawing))return!0;if((i=this.activeDrawing.openEnded)!=null&&i){let t=this.activeDrawing.points.length-1;return this.activeDrawing.points[t]={...e},this.activeDrawing.points.push({...e}),!0}let t=(a=this.activeDrawing.requiredPoints)==null?2:a,n=this.activeDrawing.points.length;if(this.activeDrawing.points[n-1]={...e},n<t)return this.activeDrawing.points.push({...e}),!0;this.activeDrawing.complete=!0;let r=this.activeDrawing;if((o=r.onPlaced)==null||o.call(r),this.setSelected(r),this.activeDrawing=null,this.state=`idle`,this.activeTool=null,(s=this.onCompleteCallback)==null||s.call(this),this.notifyChange(),il.has(r.type)){var c;(c=this.onStartTextEdit)==null||c.call(this,r)}return!0}return!1}onMouseMove(e){if(this.state===`placing`&&this.activeDrawing)if(this.freehandEnabled&&sl(this.activeDrawing)){let t=this.activeDrawing.points,n=t[t.length-1];(n.barIndex!==e.barIndex||n.price!==e.price)&&t.push({...e})}else{let t=this.activeDrawing.points.length-1;this.activeDrawing.points[t]=e}if(this.dragDrawing&&this.dragStartMouse&&this.dragStartPoints){var t;let n=e.barIndex-this.dragStartMouse.barIndex,r=e.price-this.dragStartMouse.price;for(let e=0;e<this.dragDrawing.points.length;e++){let t=this.dragStartPoints[e];t&&(this.dragDrawing.points[e]={barIndex:t.barIndex+n,price:t.price+r})}(t=this.onPointsMutated)==null||t.call(this,this.dragDrawing)}if(this.resizeDrawing&&this.resizePointIndex>=0){var n;let t=this.resizeHandle;if(t&&t.xPointIndex!==void 0&&t.yPointIndex!==void 0){let n=this.resizeDrawing.points[t.xPointIndex],r=this.resizeDrawing.points[t.yPointIndex];n&&r&&(this.resizeDrawing.points[t.xPointIndex]={...n,barIndex:e.barIndex,timestamp:e.timestamp},this.resizeDrawing.points[t.yPointIndex]={...r,price:e.price})}else this.resizeDrawing.points[this.resizePointIndex]={...e};(n=this.onPointsMutated)==null||n.call(this,this.resizeDrawing)}}isFreehandStroke(){return this.freehandEnabled&&this.state===`placing`&&this.activeDrawing!==null&&sl(this.activeDrawing)}finishFreehand(e,t,n,r,i){var a;if(this.state!==`placing`||!this.activeDrawing||!this.freehandEnabled||!sl(this.activeDrawing))return!1;let o=this.activeDrawing,s=o.points.map(a=>({x:e.xToPixel(a.barIndex,t,r),y:e.yToPixel(a.price,n,i)}));if(this.activeDrawing=null,this.state=`idle`,this.activeTool=null,!s.some(e=>Math.hypot(e.x-s[0].x,e.y-s[0].y)>ol)){let e=this.drawings.indexOf(o);return e>=0&&this.drawings.splice(e,1),this.history.pop(),!0}return o.points=rl(s,al).map(e=>o.points[e]),o.complete=!0,this.setSelected(o),(a=this.onCompleteCallback)==null||a.call(this),this.notifyChange(),!0}finalizePlacing(){var e,t;if(!(this.state!==`placing`||!this.activeDrawing)&&(e=this.activeDrawing.openEnded)!=null&&e){if(this.activeDrawing.points.length>2&&this.activeDrawing.points.pop(),this.activeDrawing.points.length<2){this.drawings.pop(),this.activeDrawing=null,this.state=`idle`,this.activeTool=null;return}this.activeDrawing.complete=!0,this.setSelected(this.activeDrawing),this.activeDrawing=null,this.state=`idle`,this.activeTool=null,(t=this.onCompleteCallback)==null||t.call(this),this.notifyChange()}}startDrag(e,t){this.snapshot(),this.dragDrawing=e,this.dragStartMouse={...t},this.dragStartPoints=e.points.map(e=>({...e}))}endDrag(){this.dragDrawing=null,this.dragStartMouse=null,this.dragStartPoints=null,this.notifyChange()}isDraggingDrawing(){return this.dragDrawing!==null}isPlacing(){return this.state===`placing`}startResize(e,t,n){this.snapshot(),this.resizeDrawing=e,this.resizePointIndex=t,this.resizeHandle=n==null?null:n}endResize(){this.resizeDrawing=null,this.resizePointIndex=-1,this.resizeHandle=null,this.notifyChange()}isResizingDrawing(){return this.resizeDrawing!==null}shiftBarIndices(e){for(let t of this.drawings)for(let n of t.points)n.barIndex+=e;if(this.dragStartPoints)for(let t of this.dragStartPoints)t.barIndex+=e}getHandleAtPoint(e,t,n,r,i,a,o,s=0){let c=(e,t)=>{for(let s=this.drawings.length-1;s>=0;s--){let c=this.drawings[s];if(!c.complete||c.visible===!1||c.locked)continue;let l=c.getHandle(e,t,n,r,i,a,o);if(l)return{drawing:c,handle:l}}return null},l=c(e,t);if(l||s<=0)return l;for(let n=1;n<=2;n++){let r=s*n/2;for(let n=0;n<8;n++){let i=n*Math.PI/4,a=c(e+Math.cos(i)*r,t+Math.sin(i)*r);if(a)return a}}return null}hitTest(e,t,n,r,i,a,o){for(let s=this.drawings.length-1;s>=0;s--){let c=this.drawings[s];if(!(c.visible===!1||c.locked)&&c.hitTest(e,t,n,r,i,a,o))return c}return null}selectDrawing(e){this.setSelected(e)}getSelectedDrawing(){return this.selectedDrawing}getDrawingById(e){var t;return(t=this.drawings.find(t=>t.id===e))==null?null:t}updateDrawingStyle(e,t){var n,r;let i=this.getDrawingById(e);if(!i)return null;let a=(n=i.style)==null?void 0:n.levels;i.style={...(r=i.style)==null?{}:r,...t};let o=t.levels;return o&&a&&(i.style.levels={...a,...o}),this.notifyChange(),i}onKeyDown(e){return e===`Escape`?(this.state===`placing`&&this.activeDrawing&&(this.drawings.pop(),this.activeDrawing=null,this.state=`idle`),this.activeTool=null,this.setSelected(null),!0):(e===`Delete`||e===`Backspace`)&&this.selectedDrawing&&!this.editingText?(this.deleteSelected(),!0):e===`z`&&this.history.length>0?(this.undo(),!0):!1}deleteSelected(){this.selectedDrawing&&(this.snapshot(),this.drawings=this.drawings.filter(e=>e!==this.selectedDrawing),this.setSelected(null),this.notifyChange())}undo(){let e=this.history.pop();e!==void 0&&(this.redoStack.push(this.cloneDrawings(this.drawings)),this.drawings=e,this.setSelected(null),this.notifyChange())}redo(){let e=this.redoStack.pop();e!==void 0&&(this.history.push(this.cloneDrawings(this.drawings)),this.drawings=e,this.setSelected(null),this.notifyChange())}hideAll(){if(this.drawings.length!==0){this.snapshot();for(let e of this.drawings)e.visible=!1;this.setSelected(null),this.notifyChange()}}showAll(){if(this.drawings.length!==0){this.snapshot();for(let e of this.drawings)e.visible=!0;this.notifyChange()}}lockAll(){if(this.drawings.length!==0){this.snapshot();for(let e of this.drawings)e.locked=!0;this.setSelected(null),this.notifyChange()}}unlockAll(){if(this.drawings.length!==0){this.snapshot();for(let e of this.drawings)e.locked=!1;this.notifyChange()}}render(e,t,n,r,i,a,o=2,s,c){if(e.clearRect(0,0,e.canvas.width,e.canvas.height),this.drawings.length===0)return;let l=window.devicePixelRatio||1;e.save(),e.scale(l,l);for(let l of this.drawings)l.visible!==!1&&l.render(e,t,n,r,i,a,l===this.selectedDrawing,o,s,c);e.restore()}getDrawings(){return[...this.drawings]}getDrawingsSnapshot(){return this.drawings.map(e=>({id:e.id,type:e.type,points:e.points.map(e=>({...e})),complete:e.complete,...e.visible!==void 0&&{visible:e.visible},...e.locked!==void 0&&{locked:e.locked},...e.text!==void 0&&{text:e.text},...e.style!==void 0&&{style:{...e.style}}}))}loadDrawings(e){this.drawings=e.map(e=>{var t;let n=this.createDrawing(e.type,(t=e.points[0])==null?{barIndex:0,price:0}:t);return n.id=e.id,n.points=e.points.map(e=>({...e})),n.complete=e.complete,e.visible!==void 0&&(n.visible=e.visible),e.locked!==void 0&&(n.locked=e.locked),e.text!==void 0&&(n.text=e.text),e.style!==void 0&&(n.style={...e.style}),n}),this.setSelected(null),this.activeDrawing=null,this.history=[this.drawings.map(e=>({...e,points:e.points.map(e=>({...e}))}))],this.redoStack=[]}clearAll(){this.drawings.length!==0&&(this.snapshot(),this.drawings=[],this.setSelected(null),this.activeDrawing=null,this.notifyChange())}notifyChange(){var e;(e=this.onDrawingsChange)==null||e.call(this)}snapshot(){this.history.push(this.cloneDrawings(this.drawings)),this.history.length>50&&this.history.shift(),this.redoStack=[]}cloneDrawings(e){return e.map(e=>{let t=Object.create(Object.getPrototypeOf(e));return Object.assign(t,e),t.points=e.points.map(e=>({...e})),t})}createDrawing(e,t){switch(e){case`horizontalLine`:return new Ei(t);case`verticalLine`:return new Oi(t);case`trendLine`:return new ji(t);case`trendAngle`:return new Pi(t);case`crossLine`:return new Ii(t);case`parallelChannel`:return new zi(t);case`flatChannel`:return new Hi(t);case`disjointChannel`:return new Gi(t);case`fibRetracement`:return new Zi(t);case`fibExtension`:return new ta(t);case`fibChannel`:return new aa(t);case`fibTimezone`:return new ca(t);case`fibCircles`:return new da(t);case`fibSpiral`:return new ma(t);case`fibFan`:return new ya(t);case`fibProjection`:return new Ca(t);case`gannFan`:return new Da(t);case`gannSquare`:return new ka(t);case`gannBox`:return new ja(t);case`rectangle`:return new Na(t);case`rotatedRectangle`:return new Ia(t);case`ellipse`:return new Ra(t);case`triangle`:return new Va(t);case`circle`:return new Ua(t);case`arc`:return new Ka(t);case`polyline`:return new Ya(t);case`path`:return new Qa(t);case`priceRange`:return new to(t);case`dateRange`:return new io(t);case`datePriceRange`:return new so(t);case`ruler`:return new yo(t);case`pitchfork`:return new Co(t);case`schiffPitchfork`:return new Do(t);case`modifiedSchiff`:return new jo(t);case`insidePitchfork`:return new Fo(t);case`fixedRangeVP`:return new Ro(t);case`anchoredVP`:return new Vo(t);case`volumeProfile`:return new Wo(t);case`regressionTrend`:return new qo(t);case`text`:return new Zo(t);case`callout`:return new is(t);case`priceLabel`:return new ls(t);case`arrowMarker`:return new fs(t);case`flag`:return new ps(t);case`priceNote`:return new vs(t);case`anchoredNote`:return new Cs(t);case`arrowUp`:return new ws(t);case`arrowDown`:return new Ts(t);case`headShoulders`:return new Os(t);case`trianglePattern`:return new js(t);case`threeDrives`:return new Ps(t);case`abcdPattern`:return new Ls(t);case`cypherPattern`:return new Bs(t);case`butterflyPattern`:return new Us(t);case`batPattern`:return new Ks(t);case`gartleyPattern`:return new Ys(t);case`crabPattern`:return new Qs(t);case`sharkPattern`:return new tc(t);case`elliottImpulse`:return new ac(t);case`elliottCorrective`:return new lc(t);case`elliottTriangle`:return new pc(t);case`elliottCombination`:return new _c(t);case`elliottWxy`:return new xc(t);case`brush`:return new wc(t);case`highlighter`:return new Dc(t);case`sineLine`:return new kc(t);case`cyclicLines`:return new jc(t);case`timeCycles`:return new Nc(t);case`projection`:return new Ic(t);case`priceProjection`:return new zc(t);case`ghostFeed`:return new Vc(t);case`longPosition`:return new el(t);case`shortPosition`:return new tl(t);default:return new ji(t)}}},ll=2,ul=class{constructor(e,t=T,n=k.chart){this.pills=new Map,this.isOpen=!1,this.onDocClick=e=>{this.isOpen&&!this.el.contains(e.target)&&(this.isOpen=!1,this.dropdownPanel.style.display=`none`,this.collapseBtn.textContent=this.labels.nIndicators.replace(`{count}`,String(this.pills.size)))},this.theme=e,this.cfg=t,this.labels=n,this.el=document.createElement(`div`),Object.assign(this.el.style,{position:`absolute`,top:`52px`,left:`6px`,zIndex:`10`,display:`none`,alignItems:`center`,gap:`10px`,pointerEvents:`auto`}),this.inlineRow=document.createElement(`div`),Object.assign(this.inlineRow.style,{display:`flex`,alignItems:`center`,gap:`10px`}),this.collapseBtn=document.createElement(`button`),Object.assign(this.collapseBtn.style,{display:`none`,alignItems:`center`,gap:`4px`,background:this.theme.indicatorOverlay.pillBg,color:this.theme.axisText,border:`1px solid ${this.theme.axisBorder}`,borderRadius:`4px`,padding:`2px 8px`,fontSize:this.cfg.collapseBtnFontSize,fontFamily:this.cfg.collapseBtnFontFamily,cursor:`pointer`,outline:`none`}),this.collapseBtn.addEventListener(`click`,e=>{e.stopPropagation(),this.toggleDropdown()}),this.dropdownPanel=document.createElement(`div`),Object.assign(this.dropdownPanel.style,{display:`none`,position:`absolute`,top:`100%`,left:`0`,marginTop:`4px`,background:this.theme.tooltip.background,border:`1px solid ${this.theme.axisBorder}`,borderRadius:`4px`,padding:`4px 0`,minWidth:`140px`,zIndex:`20`,boxShadow:`0 4px 12px rgba(0,0,0,0.15)`});let r=document.createElement(`div`);Object.assign(r.style,{position:`relative`}),r.append(this.collapseBtn,this.dropdownPanel),this.el.append(this.inlineRow,r),document.addEventListener(`click`,this.onDocClick)}addPill(e,t,n,r=`Chart`,i=!0,a,o=null,s){this.pills.has(e)||(this.pills.set(e,{color:t,label:n,timeframe:r,visible:i,onRemove:a,onEdit:o,onToggleVisibility:s}),this.refresh())}updatePillColor(e,t){let n=this.pills.get(e);n&&(n.color=t,this.refresh())}updatePillLabel(e,t){let n=this.pills.get(e);n&&(n.label=t,this.refresh())}updatePillTimeframe(e,t){let n=this.pills.get(e);n&&(n.timeframe=t,this.refresh())}updatePillVisibility(e,t){let n=this.pills.get(e);n&&(n.visible=t,this.refresh())}removePill(e){this.pills.has(e)&&(this.pills.delete(e),this.refresh())}setTheme(e){this.theme=e,Object.assign(this.collapseBtn.style,{background:e.indicatorOverlay.pillBg,color:e.axisText,border:`1px solid ${e.axisBorder}`}),Object.assign(this.dropdownPanel.style,{background:e.tooltip.background,border:`1px solid ${e.axisBorder}`}),this.refresh()}destroy(){document.removeEventListener(`click`,this.onDocClick)}refresh(){let e=Array.from(this.pills.entries());if(this.inlineRow.innerHTML=``,this.dropdownPanel.innerHTML=``,e.length===0){this.el.style.display=`none`,this.collapseBtn.style.display=`none`;return}if(this.el.style.display=`flex`,e.length<=ll){this.isOpen=!1,this.dropdownPanel.style.display=`none`,this.collapseBtn.style.display=`none`;for(let[t,n]of e)this.inlineRow.appendChild(this.makePill(t,n))}else{this.collapseBtn.style.display=`inline-flex`,this.collapseBtn.textContent=this.labels.nIndicators.replace(`{count}`,String(e.length));for(let[t,n]of e)this.dropdownPanel.appendChild(this.makeDropdownRow(t,n));this.dropdownPanel.style.display=this.isOpen?`block`:`none`}}makeTimeframeBadge(e){if(!e||e===`Chart`)return null;let t=document.createElement(`span`);return t.textContent=e,Object.assign(t.style,{fontSize:`10px`,padding:`1px 4px`,borderRadius:`3px`,background:`rgba(128,128,128,0.18)`,color:this.theme.axisText,marginLeft:`2px`,lineHeight:`1.4`}),t}makeEyeIcon(e){let t=document.createElement(`span`);return t.innerHTML=e.visible?yn:bn,Object.assign(t.style,{display:`inline-flex`,alignItems:`center`,color:this.theme.indicatorOverlay.iconColor,cursor:`pointer`,opacity:e.visible?`0.6`:`0.4`,lineHeight:`1`}),t.addEventListener(`mouseenter`,()=>{t.style.opacity=`1`}),t.addEventListener(`mouseleave`,()=>{t.style.opacity=e.visible?`0.6`:`0.4`}),t.addEventListener(`click`,t=>{t.stopPropagation(),e.onToggleVisibility()}),t}makePill(e,t){let n=document.createElement(`span`);Object.assign(n.style,{display:`inline-flex`,alignItems:`center`,gap:`4px`,fontSize:this.cfg.pillFontSize,fontFamily:this.cfg.pillFontFamily,color:t.color,whiteSpace:`nowrap`,userSelect:`none`,background:this.theme.indicatorOverlay.pillBg,borderRadius:`4px`,padding:`1px 6px 1px 5px`,opacity:t.visible?`1`:`0.4`});let r=document.createElement(`span`);r.innerHTML=On,Object.assign(r.style,{display:`inline-flex`,alignItems:`center`});let i=document.createElement(`span`);i.textContent=t.label;let a=this.makeTimeframeBadge(t.timeframe),o=document.createElement(`span`);if(Object.assign(o.style,{display:`inline-flex`,alignItems:`center`,gap:`8px`,marginLeft:`12px`}),o.appendChild(this.makeEyeIcon(t)),t.onEdit){let e=document.createElement(`span`);e.innerHTML=cn,Object.assign(e.style,{display:`inline-flex`,alignItems:`center`,color:this.theme.indicatorOverlay.iconColor,cursor:`pointer`,opacity:`0.6`,lineHeight:`1`}),e.addEventListener(`mouseenter`,()=>{e.style.opacity=`1`}),e.addEventListener(`mouseleave`,()=>{e.style.opacity=`0.6`}),e.addEventListener(`click`,e=>{e.stopPropagation(),t.onEdit()}),o.appendChild(e)}let s=document.createElement(`span`);return s.innerHTML=un,Object.assign(s.style,{display:`inline-flex`,alignItems:`center`,color:this.theme.indicatorOverlay.iconColor,cursor:`pointer`}),s.addEventListener(`click`,e=>{e.stopPropagation(),t.onRemove()}),o.appendChild(s),n.append(r,i),a&&n.appendChild(a),n.appendChild(o),n}makeDropdownRow(e,t){let n=document.createElement(`div`);Object.assign(n.style,{display:`flex`,alignItems:`center`,justifyContent:`space-between`,gap:`8px`,padding:`4px 10px`,fontSize:this.cfg.dropdownRowFontSize,fontFamily:this.cfg.dropdownRowFontFamily,color:t.color,cursor:`default`,opacity:t.visible?`1`:`0.4`}),n.addEventListener(`mouseenter`,()=>{n.style.background=this.theme.indicatorOverlay.dropdownHoverBg}),n.addEventListener(`mouseleave`,()=>{n.style.background=`transparent`});let r=document.createElement(`span`);r.innerHTML=On,Object.assign(r.style,{display:`inline-flex`,alignItems:`center`});let i=document.createElement(`span`);Object.assign(i.style,{display:`inline-flex`,alignItems:`center`,gap:`4px`,flex:`1`});let a=document.createElement(`span`);a.textContent=t.label,i.appendChild(a);let o=this.makeTimeframeBadge(t.timeframe);o&&i.appendChild(o);let s=document.createElement(`span`);Object.assign(s.style,{display:`inline-flex`,alignItems:`center`,gap:`4px`});let c=document.createElement(`span`);if(c.innerHTML=t.visible?yn:bn,Object.assign(c.style,{display:`inline-flex`,alignItems:`center`,color:this.theme.indicatorOverlay.iconColor,cursor:`pointer`,opacity:t.visible?`0.6`:`0.4`,lineHeight:`1`}),c.addEventListener(`mouseenter`,()=>{c.style.opacity=`1`}),c.addEventListener(`mouseleave`,()=>{c.style.opacity=t.visible?`0.6`:`0.4`}),c.addEventListener(`click`,e=>{e.stopPropagation(),t.onToggleVisibility()}),s.appendChild(c),t.onEdit){let e=document.createElement(`span`);e.innerHTML=cn,Object.assign(e.style,{display:`inline-flex`,alignItems:`center`,color:this.theme.indicatorOverlay.iconColor,cursor:`pointer`,opacity:`0.6`,lineHeight:`1`}),e.addEventListener(`mouseenter`,()=>{e.style.opacity=`1`}),e.addEventListener(`mouseleave`,()=>{e.style.opacity=`0.6`}),e.addEventListener(`click`,e=>{e.stopPropagation(),this.isOpen=!1,this.dropdownPanel.style.display=`none`,t.onEdit()}),s.appendChild(e)}let l=document.createElement(`span`);return l.innerHTML=un,Object.assign(l.style,{display:`inline-flex`,alignItems:`center`,color:this.theme.indicatorOverlay.iconColor,cursor:`pointer`}),l.addEventListener(`click`,e=>{e.stopPropagation(),t.onRemove()}),s.appendChild(l),n.append(r,i,s),n}toggleDropdown(){this.isOpen=!this.isOpen,this.dropdownPanel.style.display=this.isOpen?`block`:`none`,this.collapseBtn.textContent=this.labels.nIndicators.replace(`{count}`,String(this.pills.size))}},dl=class{constructor(e,t=k.dialogs,n){this.schema=null,this.currentParams={},this.onUpdate=null,this.onRemove=null,this.inputRefs=new Map,this.disposeKbd=()=>{},this.theme=e,this.labels=t,this.onVisibilityChange=n,this.el=document.createElement(`div`),Object.assign(this.el.style,{position:`fixed`,inset:`0`,background:`rgba(0,0,0,0.5)`,display:`none`,alignItems:`center`,justifyContent:`center`,zIndex:`1000`}),this.el.addEventListener(`mousedown`,e=>{e.target===this.el&&this.hide()}),this.panel=document.createElement(`div`),Object.assign(this.panel.style,{display:`flex`,flexDirection:`column`,minWidth:`300px`,maxWidth:`360px`,background:this.theme.tooltip.background,border:`1px solid ${this.theme.axisBorder}`,borderRadius:`6px`,boxShadow:`0 8px 32px rgba(0,0,0,0.45)`,fontFamily:`'Inter', system-ui, sans-serif`,fontSize:`12px`,overflow:`hidden`}),this.panel.addEventListener(`mousedown`,e=>e.stopPropagation()),this.el.appendChild(this.panel),this.disposeKbd=Un(this.panel)}show(e,t,n,r){var i;let a=this.isVisible;this.schema=e,this.currentParams={...t},this.onUpdate=n,this.onRemove=r,this.rebuild(),this.el.style.display=`flex`,a||(i=this.onVisibilityChange)==null||i.call(this)}hide(){var e;let t=this.isVisible;this.el.style.display=`none`,this.schema=null,this.onUpdate=null,this.onRemove=null,t&&((e=this.onVisibilityChange)==null||e.call(this))}get isVisible(){return this.el.style.display!==`none`}setTheme(e){this.theme=e,Object.assign(this.panel.style,{background:e.tooltip.background,border:`1px solid ${e.axisBorder}`}),this.el.style.display!==`none`&&this.schema&&this.rebuild()}destroy(){this.disposeKbd(),this.el.remove()}rebuild(){this.panel.innerHTML=``,this.inputRefs.clear(),this.schema&&(this.panel.appendChild(this.buildHeader(this.schema.shortName)),this.panel.appendChild(this.buildBody(this.schema.fields)),this.panel.appendChild(this.buildFooter()))}buildHeader(e){let t=document.createElement(`div`);Object.assign(t.style,{display:`flex`,alignItems:`center`,justifyContent:`space-between`,padding:`10px 14px`,borderBottom:`1px solid ${this.theme.axisBorder}`});let n=document.createElement(`span`);n.textContent=`${e} ${this.labels.indicator.titleSuffix}`,Object.assign(n.style,{color:this.theme.tooltip.text,fontWeight:`600`,fontSize:`13px`});let r=document.createElement(`span`);return r.innerHTML=un,Object.assign(r.style,{display:`inline-flex`,alignItems:`center`,color:this.theme.axisText,cursor:`pointer`}),r.addEventListener(`mouseenter`,()=>{r.style.color=this.theme.tooltip.text}),r.addEventListener(`mouseleave`,()=>{r.style.color=this.theme.axisText}),r.addEventListener(`click`,()=>this.hide()),t.append(n,r),t}buildBody(e){let t=document.createElement(`div`);if(Object.assign(t.style,{padding:`12px 14px`,display:`flex`,flexDirection:`column`,gap:`8px`}),e.length===0){let e=document.createElement(`span`);return e.textContent=this.labels.indicator.noParams,Object.assign(e.style,{color:this.theme.axisText,fontSize:`11px`}),t.appendChild(e),t}for(let n of e)t.appendChild(this.buildField(n));return t}buildField(e){var t;let n=document.createElement(`div`);Object.assign(n.style,{display:`flex`,alignItems:`center`,justifyContent:`space-between`,gap:`10px`});let r=document.createElement(`label`);r.textContent=e.label,Object.assign(r.style,{color:this.theme.axisText,fontSize:`12px`,flex:`1`});let i=(t=this.currentParams[e.key])==null?e.default:t;if(e.kind===`number`){let t=document.createElement(`input`);t.type=`number`,t.min=String(e.min),t.max=String(e.max),t.step=String(e.step),t.value=String(i),t.enterKeyHint=`go`,Object.assign(t.style,{width:`80px`,background:this.theme.background,color:this.theme.tooltip.text,border:`1px solid ${this.theme.axisBorder}`,borderRadius:`3px`,padding:`4px 6px`,fontSize:`16px`,fontFamily:`'Inter', system-ui, sans-serif`,outline:`none`,textAlign:`right`}),this.inputRefs.set(e.key,t),n.append(r,t)}else if(e.kind===`select`){let t=document.createElement(`select`);for(let n of e.options){let e=document.createElement(`option`);e.value=n,e.textContent=n,n===String(i)&&(e.selected=!0),t.appendChild(e)}Object.assign(t.style,{minWidth:`120px`,background:this.theme.background,color:this.theme.tooltip.text,border:`1px solid ${this.theme.axisBorder}`,borderRadius:`3px`,padding:`4px 6px`,fontSize:`12px`,fontFamily:`'Inter', system-ui, sans-serif`,outline:`none`,cursor:`pointer`}),this.inputRefs.set(e.key,t),n.append(r,t)}else{let t=document.createElement(`input`);t.type=`color`,t.value=String(i),Object.assign(t.style,{width:`40px`,height:`26px`,border:`none`,padding:`0`,cursor:`pointer`,background:`transparent`,borderRadius:`3px`}),this.inputRefs.set(e.key,t),n.append(r,t)}return n}buildFooter(){let e=document.createElement(`div`);Object.assign(e.style,{display:`flex`,gap:`8px`,padding:`10px 14px`,borderTop:`1px solid ${this.theme.axisBorder}`});let t=this.makeButton(`Remove`,`#ef5350`,`transparent`,`#ef5350`);t.addEventListener(`click`,()=>{var e;(e=this.onRemove)==null||e.call(this),this.hide()});let n=this.makeButton(`Update`,`#fff`,`#2196f3`,`#2196f3`);return n.addEventListener(`click`,()=>{if(!this.schema||!this.onUpdate)return;let e={};for(let t of this.schema.fields){let n=this.inputRefs.get(t.key);n&&(e[t.key]=t.kind===`number`?Number(n.value):String(n.value))}this.onUpdate(e),this.hide()}),e.append(t,n),e}makeButton(e,t,n,r){let i=document.createElement(`button`);return i.textContent=e,Object.assign(i.style,{flex:`1`,color:t,background:n,border:`1px solid ${r}`,borderRadius:`4px`,padding:`6px 0`,cursor:`pointer`,fontSize:`12px`,fontFamily:`'Inter', system-ui, sans-serif`,fontWeight:`600`,outline:`none`}),i.addEventListener(`mouseenter`,()=>{i.style.opacity=`0.85`}),i.addEventListener(`mouseleave`,()=>{i.style.opacity=`1`}),i}},fl={appearance:`Appearance`,trading:`Trading`},pl=class{constructor(e,t,n=k.dialogs,r=!0,i=!1,a){this.activeTab=`appearance`,this.onChange=null,this.onReset=null,this.tabEls=new Map,this.theme=e,this.labels=n,this.current={...t},this.showTradingTab=r,this.enableThemeToggle=i,this.onVisibilityChange=a,!r&&this.activeTab===`trading`&&(this.activeTab=`appearance`),this.el=document.createElement(`div`),Object.assign(this.el.style,{position:`fixed`,inset:`0`,background:`rgba(0,0,0,0.5)`,display:`none`,alignItems:`center`,justifyContent:`center`,zIndex:`10000`}),this.el.addEventListener(`mousedown`,e=>{e.target===this.el&&this.hide()}),this.panel=document.createElement(`div`),Object.assign(this.panel.style,{display:`flex`,flexDirection:`column`,width:`540px`,minHeight:`340px`,maxWidth:`calc(100vw - 32px)`,maxHeight:`calc(100vh - 48px)`,background:e.tooltip.background,border:`1px solid ${e.axisBorder}`,borderRadius:`10px`,boxShadow:`0 16px 48px rgba(0,0,0,0.55), 0 4px 16px rgba(0,0,0,0.3)`,fontFamily:`'Inter', system-ui, -apple-system, sans-serif`,fontSize:`12px`,overflow:`hidden`}),this.panel.addEventListener(`mousedown`,e=>e.stopPropagation());let o=this.buildHeader();this.panel.appendChild(o);let s=document.createElement(`div`);Object.assign(s.style,{display:`flex`,flex:`1`,overflow:`hidden`}),this.sidebar=this.buildSidebar(),s.appendChild(this.sidebar),this.content=document.createElement(`div`),Object.assign(this.content.style,{flex:`1`,padding:`20px 24px`,overflowY:`auto`,scrollbarWidth:`thin`}),s.appendChild(this.content),this.panel.appendChild(s),this.panel.appendChild(this.buildFooter()),this.el.appendChild(this.panel)}show(e,t,n){var r;let i=this.isVisible;this.current={...e},this.onChange=t,this.onReset=n==null?null:n,this.renderContent(),this.el.style.display=`flex`,i||(r=this.onVisibilityChange)==null||r.call(this)}hide(){var e;let t=this.isVisible;this.el.style.display=`none`,this.onChange=null,this.onReset=null,t&&((e=this.onVisibilityChange)==null||e.call(this))}get isVisible(){return this.el.style.display!==`none`}setTheme(e){this.theme=e,this.applyPanelTheme(),this.el.style.display!==`none`&&this.renderContent()}destroy(){this.el.remove()}emit(){var e;(e=this.onChange)==null||e.call(this,{...this.current})}applyPanelTheme(){Object.assign(this.panel.style,{background:this.theme.tooltip.background,border:`1px solid ${this.theme.axisBorder}`}),this.sidebar.innerHTML=``,this.tabEls.clear(),this.buildSidebarTabs(this.sidebar),this.highlightActiveTab()}buildHeader(){let e=document.createElement(`div`);Object.assign(e.style,{display:`flex`,alignItems:`center`,justifyContent:`space-between`,padding:`14px 20px 12px`,borderBottom:`1px solid ${this.theme.axisBorder}`,flexShrink:`0`});let t=document.createElement(`span`);t.textContent=this.labels.settings.title,Object.assign(t.style,{color:this.theme.tooltip.text,fontWeight:`600`,fontSize:`14px`,letterSpacing:`-0.01em`});let n=document.createElement(`button`);return n.innerHTML=Dn,Object.assign(n.style,{color:this.theme.axisText,cursor:`pointer`,background:`transparent`,border:`none`,padding:`4px`,borderRadius:`4px`,display:`flex`,alignItems:`center`,justifyContent:`center`,outline:`none`,transition:`color 0.1s, background 0.1s`}),n.addEventListener(`mouseenter`,()=>{n.style.color=this.theme.tooltip.text,n.style.background=this.theme.ui.accentBg}),n.addEventListener(`mouseleave`,()=>{n.style.color=this.theme.axisText,n.style.background=`transparent`}),n.addEventListener(`click`,()=>this.hide()),e.append(t,n),e}buildFooter(){let e=document.createElement(`div`);Object.assign(e.style,{display:`flex`,alignItems:`center`,justifyContent:`flex-end`,padding:`10px 20px`,borderTop:`1px solid ${this.theme.axisBorder}`,flexShrink:`0`});let t=document.createElement(`button`);return t.textContent=this.labels.settings.resetBtn,Object.assign(t.style,{color:this.theme.axisText,fontSize:`11px`,fontFamily:`'Inter', system-ui, sans-serif`,background:`transparent`,border:`1px solid ${this.theme.axisBorder}`,borderRadius:`5px`,padding:`5px 12px`,cursor:`pointer`,outline:`none`,transition:`color 0.1s, border-color 0.1s, background 0.1s`}),t.addEventListener(`mouseenter`,()=>{t.style.color=this.theme.tooltip.text,t.style.borderColor=this.theme.ui.accent,t.style.background=this.theme.ui.accentBg}),t.addEventListener(`mouseleave`,()=>{t.style.color=this.theme.axisText,t.style.borderColor=this.theme.axisBorder,t.style.background=`transparent`}),t.addEventListener(`click`,()=>{var e;(e=this.onReset)==null||e.call(this),this.hide()}),e.appendChild(t),e}buildSidebar(){let e=document.createElement(`div`);return Object.assign(e.style,{width:`130px`,flexShrink:`0`,borderRight:`1px solid ${this.theme.axisBorder}`,padding:`10px 0`,display:`flex`,flexDirection:`column`,gap:`2px`}),this.buildSidebarTabs(e),e}buildSidebarTabs(e){let t=this.showTradingTab?[`appearance`,`trading`]:[`appearance`];for(let n of t){let t=document.createElement(`button`);Object.assign(t.style,{display:`flex`,alignItems:`center`,gap:`8px`,padding:`8px 14px`,background:`transparent`,border:`none`,borderLeft:`2px solid transparent`,color:this.theme.axisText,fontSize:`12px`,fontFamily:`'Inter', system-ui, sans-serif`,cursor:`pointer`,width:`100%`,textAlign:`left`,outline:`none`,transition:`background 0.1s, color 0.1s`,boxSizing:`border-box`});let r=document.createElement(`span`);r.innerHTML=En[n],Object.assign(r.style,{display:`flex`,flexShrink:`0`});let i=document.createElement(`span`);i.textContent=fl[n],t.append(r,i),t.addEventListener(`mouseenter`,()=>{this.activeTab!==n&&(t.style.background=this.theme.ui.accentBg,t.style.color=this.theme.tooltip.text)}),t.addEventListener(`mouseleave`,()=>{this.activeTab!==n&&(t.style.background=`transparent`,t.style.color=this.theme.axisText)}),t.addEventListener(`click`,()=>{this.activeTab=n,this.highlightActiveTab(),this.renderContent()}),this.tabEls.set(n,t),e.appendChild(t)}}highlightActiveTab(){for(let[e,t]of this.tabEls){let n=e===this.activeTab;Object.assign(t.style,{background:n?this.theme.ui.accentBg:`transparent`,color:n?this.theme.ui.accentText:this.theme.axisText,borderLeft:n?`2px solid ${this.theme.ui.accent}`:`2px solid transparent`,fontWeight:n?`500`:`400`})}}renderContent(){switch(this.content.innerHTML=``,this.highlightActiveTab(),this.activeTab){case`appearance`:this.buildAppearanceSection();break;case`trading`:this.buildTradingSection();break}}buildAppearanceSection(){if(this.enableThemeToggle){let e=document.createElement(`div`);Object.assign(e.style,{display:`flex`,alignItems:`center`,justifyContent:`space-between`,paddingBottom:`10px`,borderBottom:`1px solid ${this.theme.axisBorder}`});let t=document.createElement(`span`);t.textContent=`Theme`,Object.assign(t.style,{color:this.theme.tooltip.text,fontSize:`13px`,fontWeight:`600`}),e.append(t,this.makeThemeToggle()),this.content.appendChild(e)}this.content.appendChild(this.makeSectionHeader(`Colors`)),this.content.appendChild(this.buildColorRows()),this.content.appendChild(this.makeSectionHeader(`Chart elements`)),this.content.appendChild(this.makeHorizontalSettingRow(`Price-axis countdown`,`Show the candle close countdown on the right price axis.`,this.makeBooleanToggle(this.current.showPriceAxisCountdown,e=>{this.current.showPriceAxisCountdown=e,this.emit()})))}makeBooleanToggle(e,t,n){let r=e,i=document.createElement(`div`);Object.assign(i.style,{display:`flex`,alignItems:`center`,gap:`8px`});let a=n?document.createElement(`span`):null,o=n?document.createElement(`span`):null;a&&o&&n&&(a.textContent=n.off,o.textContent=n.on);let s=()=>{!a||!o||(Object.assign(a.style,{color:r?this.theme.axisText:this.theme.tooltip.text,fontWeight:r?`400`:`500`,fontSize:`11px`,cursor:`pointer`,userSelect:`none`}),Object.assign(o.style,{color:r?this.theme.tooltip.text:this.theme.axisText,fontWeight:r?`500`:`400`,fontSize:`11px`,cursor:`pointer`,userSelect:`none`}))},c=document.createElement(`div`);Object.assign(c.style,{position:`relative`,width:`36px`,height:`20px`,borderRadius:`10px`,cursor:`pointer`,flexShrink:`0`,transition:`background 0.18s`,background:this.theme.axisBorder,border:`1px solid ${l(this.theme.tooltip.background,.3)}`,boxSizing:`border-box`});let u=document.createElement(`div`);Object.assign(u.style,{position:`absolute`,top:`2px`,left:r?`18px`:`2px`,width:`14px`,height:`14px`,borderRadius:`50%`,background:this.theme.ui.accent,transition:`left 0.18s`,pointerEvents:`none`}),c.appendChild(u);let d=()=>{r=!r,u.style.left=r?`18px`:`2px`,s(),t(r)};return c.addEventListener(`click`,d),a&&o&&(a.addEventListener(`click`,()=>{r&&d()}),o.addEventListener(`click`,()=>{r||d()})),s(),a&&o?i.append(a,c,o):i.append(c),i}makeThemeToggle(){return this.makeBooleanToggle(this.current.theme===`light`,e=>{this.current.theme=e?`light`:`dark`,this.emit(),this.renderContent()},{off:`Dark`,on:`Light`})}buildColorRows(){var e,t,n,r;let i=this.current.theme,a=(e=(t=this.current.canvasColors)==null?void 0:t[i])==null?{}:e,o=document.createElement(`div`);Object.assign(o.style,{display:`grid`,gridTemplateColumns:`max-content 24px 24px`,columnGap:`8px`,rowGap:`8px`,padding:`8px 0 4px`,alignItems:`center`});let s=[{label:`Background`,s1:{field:`background`,fallback:this.theme.background}},{label:`Grid`,s1:{field:`grid`,fallback:this.theme.grid}},{label:`Axis Text`,s1:{field:`axisText`,fallback:this.theme.axisText}},{label:`Axis Border`,s1:{field:`axisBorder`,fallback:this.theme.axisBorder}},{label:`Crosshair`,s1:{field:`crosshair`,fallback:this.theme.crosshair}},{label:`Candle Body`,s1:{field:`candleUp`,fallback:this.theme.candle.up},s2:{field:`candleDown`,fallback:this.theme.candle.down}},{label:`Candle Wick`,s1:{field:`wickUp`,fallback:this.theme.candle.wickUp},s2:{field:`wickDown`,fallback:this.theme.candle.wickDown}},{label:`Candle Border`,s1:{field:`borderUp`,fallback:(n=this.theme.candle.borderUp)==null?this.theme.candle.up:n},s2:{field:`borderDown`,fallback:(r=this.theme.candle.borderDown)==null?this.theme.candle.down:r}},{label:`Volume`,s1:{field:`volumeUp`,fallback:this.theme.volume.up},s2:{field:`volumeDown`,fallback:this.theme.volume.down}}],c=e=>{var t;return this.makeColorSwatch((t=a[e.field])==null?e.fallback:t,t=>{this.current.canvasColors||(this.current.canvasColors={}),this.current.canvasColors[i]||(this.current.canvasColors[i]={}),this.current.canvasColors[i][e.field]=t,this.emit()})};for(let{label:e,s1:t,s2:n}of s){let r=document.createElement(`span`);r.textContent=e,Object.assign(r.style,{color:this.theme.axisText,fontSize:`11px`,paddingRight:`12px`});let i=c(t);i.style.width=`24px`,i.style.height=`24px`;let a;n?(a=c(n),a.style.width=`24px`,a.style.height=`24px`):a=document.createElement(`span`),o.append(r,i,a)}return o}makeColorSwatch(e,t){let n=l(this.theme.tooltip.background),r=document.createElement(`div`);Object.assign(r.style,{position:`relative`,width:`28px`,height:`28px`,borderRadius:`6px`,overflow:`hidden`,cursor:`pointer`,border:`1.5px solid ${n}`,flexShrink:`0`,boxSizing:`border-box`});let i=document.createElement(`div`);Object.assign(i.style,{position:`absolute`,inset:`0`,background:e});let a=document.createElement(`input`);a.type=`color`,a.value=e,Object.assign(a.style,{position:`absolute`,inset:`0`,opacity:`0`,width:`100%`,height:`100%`,cursor:`pointer`,padding:`0`,border:`none`});let o=null;return a.addEventListener(`input`,()=>{i.style.background=a.value,o!==null&&clearTimeout(o),o=setTimeout(()=>{o=null,t(a.value)},300)}),r.append(i,a),r}buildTradingSection(){let e=this.labels.settings;this.content.appendChild(this.makeSectionHeader(e.tfcSection)),this.content.appendChild(this.makeVerticalSettingRow(e.showLabel,`Controls which trade levels are displayed on the chart`,this.makeSegmented([{value:`all`,label:e.showAll},{value:`positions`,label:e.showPositions},{value:`orders`,label:e.showOrders},{value:`none`,label:e.showNone}],this.current.tradeDisplayFilter,e=>{this.current.tradeDisplayFilter=e,this.emit()}))),this.content.appendChild(this.makeVerticalSettingRow(e.positionStyleLabel,`How open positions are rendered on the chart`,this.makeSegmented([{value:`line`,label:e.styleLine},{value:`dot`,label:e.styleDot}],this.current.positionRenderStyle,e=>{this.current.positionRenderStyle=e,this.emit()}))),this.content.appendChild(this.makeHorizontalSettingRow(`Always show SL/TP`,`Keep stop-loss and take-profit lines visible without hovering.`,this.makeBooleanToggle(this.current.showTradeLevelsAlways,e=>{this.current.showTradeLevelsAlways=e,this.emit()})))}makeSectionHeader(e,t=!1){let n=document.createElement(`div`);return n.textContent=e,Object.assign(n.style,{color:this.theme.tooltip.text,fontSize:`13px`,fontWeight:`600`,paddingBottom:`10px`,marginTop:t?`0`:`20px`,marginBottom:`2px`,borderBottom:`1px solid ${this.theme.axisBorder}`}),n}makeVerticalSettingRow(e,t,n){let r=document.createElement(`div`);Object.assign(r.style,{display:`flex`,flexDirection:`column`,gap:`12px`,padding:`14px 0`,borderBottom:`1px solid ${this.theme.axisBorder}`});let i=document.createElement(`div`);Object.assign(i.style,{display:`flex`,flexDirection:`column`,gap:`0px`});let a=document.createElement(`span`);a.textContent=e,Object.assign(a.style,{color:this.theme.tooltip.text,fontSize:`12px`,fontWeight:`500`});let o=document.createElement(`span`);return o.textContent=t,Object.assign(o.style,{color:this.theme.axisText,fontSize:`10px`}),i.append(a,o),Object.assign(n.style,{width:`fit-content`,border:`1px solid ${this.theme.axisText}`,borderRadius:`6px`,overflow:`hidden`}),r.append(i,n),r}makeHorizontalSettingRow(e,t,n){let r=document.createElement(`div`);Object.assign(r.style,{display:`flex`,flexDirection:`row`,alignItems:`center`,justifyContent:`space-between`,gap:`12px`,padding:`14px 0`,borderBottom:`1px solid ${this.theme.axisBorder}`});let i=document.createElement(`div`);Object.assign(i.style,{display:`flex`,flexDirection:`column`,gap:`0px`,flex:`1`,minWidth:`0`});let a=document.createElement(`span`);a.textContent=e,Object.assign(a.style,{color:this.theme.tooltip.text,fontSize:`12px`,fontWeight:`500`});let o=document.createElement(`span`);o.textContent=t,Object.assign(o.style,{color:this.theme.axisText,fontSize:`10px`}),i.append(a,o);let s=document.createElement(`div`);return Object.assign(s.style,{display:`flex`,alignItems:`center`,justifyContent:`center`,flexShrink:`0`}),s.appendChild(n),r.append(i,s),r}makeSegmented(e,t,n){let r=document.createElement(`div`);Object.assign(r.style,{display:`inline-flex`,borderRadius:`6px`,border:`1px solid ${this.theme.axisText}`,overflow:`hidden`,flexShrink:`0`});let i=[];for(let a of e){let o=document.createElement(`button`),s=a.value===t;Object.assign(o.style,{padding:`5px 14px`,fontSize:`11px`,fontFamily:`'Inter', system-ui, sans-serif`,background:s?this.theme.ui.accent:`transparent`,color:s?`#ffffff`:this.theme.axisText,border:`none`,borderRight:`1px solid ${this.theme.axisText}`,cursor:`pointer`,outline:`none`,transition:`background 0.12s, color 0.12s`,whiteSpace:`nowrap`,textAlign:`center`}),a===e[e.length-1]&&(o.style.borderRight=`none`),o.textContent=a.label,o.addEventListener(`mouseenter`,()=>{t!==a.value&&(o.style.background=this.theme.ui.accentBg,o.style.color=this.theme.ui.accentText)}),o.addEventListener(`mouseleave`,()=>{t!==a.value&&(o.style.background=`transparent`,o.style.color=this.theme.axisText)}),o.addEventListener(`click`,()=>{t=a.value;for(let e of i)e.style.background=`transparent`,e.style.color=this.theme.axisText;o.style.background=this.theme.ui.accent,o.style.color=`#ffffff`,n(a.value)}),i.push(o),r.appendChild(o)}return r}};function ml(e,t=null){let n=[],r=0,i=!1,a=0,o=0;for(let s of e){if(s.type!==`position`)continue;let e=s;e.entryPriceEditable||t!==null&&e.label===t||(n.push(e),e.side===`buy`?a++:e.side===`sell`&&o++,typeof e.pnl==`number`&&Number.isFinite(e.pnl)&&(r+=e.pnl,i=!0))}return{count:n.length,pnl:r,hasPnl:i,positions:n,buys:a,sells:o,mixed:a>0&&o>0}}function hl(e,t){let n=Math.abs(e).toFixed(2),r=e<0&&Number(n)>0?`-`:`+`;return t?`${r}${n} ${t}`:`${r}${n}`}var gl=28,_l=6,vl=8,yl=6,bl=2,xl=12,Sl=18,Cl=8,wl=12,Tl=4,El=`#eab308`,Dl=`#facc15`,Ol=`ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace`,kl=`<svg viewBox="0 0 24 24" width="12" height="12" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"><circle cx="9" cy="12" r="1"/><circle cx="9" cy="5" r="1"/><circle cx="9" cy="19" r="1"/><circle cx="15" cy="12" r="1"/><circle cx="15" cy="5" r="1"/><circle cx="15" cy="19" r="1"/></svg>`,Al=`<svg viewBox="0 0 24 24" width="12" height="12" fill="none" stroke="currentColor" stroke-width="2.25" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"><circle cx="12" cy="12" r="10"/><circle cx="12" cy="12" r="6"/><circle cx="12" cy="12" r="2"/></svg>`,jl=`<svg viewBox="0 0 24 24" width="10" height="10" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>`,Ml=class{constructor(e){this.expanded=!1,this.userHidden=!1,this.lastSummary=null,this.count=0,this.symbol=``,this.mixed=!1,this.pnlTone=`none`,this.pos=null,this.drag={active:!1,moved:!1,ox:0,oy:0,sx:0,sy:0},this.closeHover=!1,this.toggleHover=!1,this.onPointerDown=e=>{var t;if((t=e.target)!=null&&t.closest(`button`)||e.button!==void 0&&e.button!==0)return;let n=this.el.getBoundingClientRect();this.drag={active:!0,moved:!1,ox:e.clientX-n.left,oy:e.clientY-n.top,sx:e.clientX,sy:e.clientY};try{this.el.setPointerCapture(e.pointerId)}catch(e){}e.preventDefault()},this.onPointerMove=e=>{var t;if(!this.drag.active)return;if(!this.drag.moved){let t=e.clientX-this.drag.sx,n=e.clientY-this.drag.sy;if(t*t+n*n<Tl*Tl)return;this.drag.moved=!0,this.el.style.cursor=`grabbing`}let n=(t=this.el.offsetParent)==null?this.el.parentElement:t;if(!n)return;let r=n.getBoundingClientRect();this.pos=this.clamp(e.clientX-r.left-this.drag.ox,e.clientY-r.top-this.drag.oy),this.applyPosition()},this.onPointerUp=e=>{var t;if(!this.drag.active)return;let n=!this.drag.moved;this.endDrag(e),n&&!((t=e.target)!=null&&t.closest(`button`))&&this.onToggleExpand()},this.onPointerCancel=e=>{this.drag.active&&this.endDrag(e)},this.theme=e.theme,this.labels=e.labels,this.getBounds=e.getBounds,this.currency=e.currency,this.format=e.format,this.el=document.createElement(`div`),this.el.dataset.role=`pnl-pill`,this.el.dataset.testid=`chart-symbol-pnl`,this.el.dataset.active=`false`,this.el.setAttribute(`role`,`group`),Object.assign(this.el.style,{position:`absolute`,top:`${wl}px`,display:`none`,alignItems:`center`,height:`${gl}px`,boxSizing:`border-box`,padding:`0 ${yl}px 0 ${vl}px`,gap:`${_l}px`,borderRadius:`${bl}px`,fontFamily:Ol,fontSize:`11px`,lineHeight:`1`,whiteSpace:`nowrap`,userSelect:`none`,cursor:`pointer`,touchAction:`none`,zIndex:`20`,pointerEvents:`auto`,backdropFilter:`blur(12px)`,webkitBackdropFilter:`blur(12px)`}),this.gripEl=document.createElement(`span`),this.gripEl.dataset.role=`grip`,this.gripEl.innerHTML=kl,Object.assign(this.gripEl.style,{...Nl(),width:`${xl}px`,flex:`0 0 ${xl}px`,pointerEvents:`none`}),this.countEl=document.createElement(`span`),this.countEl.dataset.role=`count`,Object.assign(this.countEl.style,{...Nl(),fontSize:`9px`,letterSpacing:`0.16em`,textTransform:`uppercase`,pointerEvents:`none`}),this.valueEl=document.createElement(`span`),this.valueEl.dataset.role=`value`,this.valueEl.dataset.testid=`chart-symbol-pnl-value`,Object.assign(this.valueEl.style,{...Nl(),fontSize:`12px`,fontWeight:`700`,fontVariantNumeric:`tabular-nums`,pointerEvents:`none`}),this.sepEl=document.createElement(`span`),this.sepEl.dataset.role=`separator`,Object.assign(this.sepEl.style,{width:`1px`,flex:`0 0 1px`,height:`12px`,margin:`0 2px`,pointerEvents:`none`}),this.toggleBtn=Pl(`bulk-levels`,`chart-symbol-bulk-levels`),this.toggleBtn.innerHTML=Al,this.toggleBtn.style.borderRadius=`${bl}px`,this.toggleBtn.addEventListener(`click`,t=>{t.stopPropagation(),e.onBulkLevels()}),this.toggleBtn.addEventListener(`mouseenter`,()=>{this.toggleHover=!0,this.applyToggleColor()}),this.toggleBtn.addEventListener(`mouseleave`,()=>{this.toggleHover=!1,this.applyToggleColor()}),this.closeBtn=Pl(`close-all`,`chart-symbol-close-all`),this.closeBtn.innerHTML=jl,this.closeBtn.style.borderRadius=`50%`,this.closeBtn.addEventListener(`click`,t=>{t.stopPropagation(),e.onCloseAll()}),this.closeBtn.addEventListener(`mouseenter`,()=>{this.closeHover=!0,this.applyCloseColor()}),this.closeBtn.addEventListener(`mouseleave`,()=>{this.closeHover=!1,this.applyCloseColor()}),this.el.append(this.gripEl,this.countEl,this.valueEl,this.sepEl,this.toggleBtn,this.closeBtn),this.el.addEventListener(`pointerdown`,this.onPointerDown),this.el.addEventListener(`pointermove`,this.onPointerMove),this.el.addEventListener(`pointerup`,this.onPointerUp),this.el.addEventListener(`pointercancel`,this.onPointerCancel),this.el.addEventListener(`dblclick`,e=>{e.stopPropagation(),this.resetPosition()});for(let e of[`mousedown`,`touchstart`,`click`])this.el.addEventListener(e,e=>e.stopPropagation());this.onToggleExpand=e.onToggleExpand,this.applyTheme(),this.applyTitles(),this.setExpanded(!1)}update(e,t=``){if(this.count=e.count,this.symbol=t,this.mixed=e.mixed,this.lastSummary=e,e.count===0||this.userHidden){this.el.style.display=`none`;return}this.countEl.textContent=`${e.count} ${this.labels.positionsAbbrev}`,e.hasPnl?(this.valueEl.textContent=this.format?this.format(e.pnl):hl(e.pnl,this.currency),this.pnlTone=e.pnl<0?`loss`:`profit`):(this.valueEl.textContent=`—`,this.pnlTone=`none`),this.applyValueColor(),this.applyTitles();let n=this.el.style.display===`none`;this.el.style.display=`flex`,n?this.applyPosition():this.clampToBounds()}setHidden(e){this.userHidden!==e&&(this.userHidden=e,e?this.el.style.display=`none`:this.lastSummary&&this.update(this.lastSummary,this.symbol))}setExpanded(e){this.expanded=e,this.el.dataset.active=String(e),this.applyFrame(),this.applyTitles()}setTheme(e){this.theme=e,this.applyTheme()}setLabels(e){this.labels=e,this.count>0&&(this.countEl.textContent=`${this.count} ${e.positionsAbbrev}`),this.applyTitles()}clampToBounds(){this.pos===null||this.el.style.display===`none`||(this.pos=this.clamp(this.pos.x,this.pos.y),this.applyPosition())}resetPosition(){this.pos=null,this.applyPosition()}destroy(){this.el.removeEventListener(`pointerdown`,this.onPointerDown),this.el.removeEventListener(`pointermove`,this.onPointerMove),this.el.removeEventListener(`pointerup`,this.onPointerUp),this.el.removeEventListener(`pointercancel`,this.onPointerCancel),this.el.remove()}endDrag(e){this.drag.active=!1,this.el.style.cursor=`pointer`;try{this.el.releasePointerCapture(e.pointerId)}catch(e){}}clamp(e,t){let n=this.getBounds(),r=this.el.offsetWidth,i=this.el.offsetHeight,a=Math.max(Cl,n.width-n.right-r-Cl),o=Math.max(Cl,n.height-n.bottom-i-Cl);return{x:Math.min(Math.max(Cl,e),a),y:Math.min(Math.max(Cl,t),o)}}applyPosition(){this.pos===null?(this.el.style.left=``,this.el.style.top=`${wl}px`,this.el.style.right=`${this.getBounds().right+Cl}px`):(this.el.style.right=``,this.el.style.left=`${this.pos.x}px`,this.el.style.top=`${this.pos.y}px`)}fill(e){return e.replace(/\{symbol\}/g,this.symbol).replace(/\{count\}/g,String(this.count))}applyTitles(){this.el.title=this.fill(this.expanded?this.labels.hidePositionsTitle:this.labels.showPositionsTitle);let e=this.fill(this.mixed?this.labels.bulkLevelsMixedTitle:this.labels.bulkLevelsTitle);this.toggleBtn.title=e,this.toggleBtn.setAttribute(`aria-label`,e),this.toggleBtn.disabled=this.mixed,this.toggleBtn.setAttribute(`aria-disabled`,String(this.mixed)),this.applyToggleColor();let t=this.fill(this.labels.closeAllTitle);this.closeBtn.title=t,this.closeBtn.setAttribute(`aria-label`,t)}applyTheme(){let e=this.theme;this.el.style.color=e.tooltip.text,this.gripEl.style.color=G(e.axisText,.7),this.countEl.style.color=e.axisText,this.sepEl.style.background=e.axisBorder,this.applyFrame(),this.applyValueColor(),this.applyToggleColor(),this.applyCloseColor()}applyFrame(){let e=this.theme,t=`0 1px 2px 0 rgba(0, 0, 0, 0.05)`;Object.assign(this.el.style,{background:G(e.tooltip.background,.9),border:`1px solid ${this.expanded?G(e.ui.accent,.6):e.axisBorder}`,boxShadow:this.expanded?`${t}, 0 0 0 1px ${G(e.ui.accent,.3)}`:t})}applyValueColor(){let e=this.theme;this.valueEl.style.color=this.pnlTone===`profit`?e.tradeLevels.buySide:this.pnlTone===`loss`?e.tradeLevels.sellSide:e.axisText}applyToggleColor(){let e=this.theme;Object.assign(this.toggleBtn.style,{color:e.ui.accent,background:G(e.ui.accent,this.toggleHover&&!this.mixed?.2:.12),border:`1px solid transparent`,opacity:this.mixed?`0.4`:`1`,cursor:this.mixed?`not-allowed`:`pointer`})}applyCloseColor(){Object.assign(this.closeBtn.style,{color:El,border:`1px solid ${this.closeHover?Dl:G(El,.6)}`,background:this.closeHover?G(El,.15):`transparent`})}};function Nl(){return{display:`inline-flex`,alignItems:`center`,justifyContent:`center`,height:`100%`,lineHeight:`1`}}function Pl(e,t){let n=document.createElement(`button`);return n.type=`button`,n.dataset.role=e,n.dataset.testid=t,Object.assign(n.style,{...Nl(),width:`${Sl}px`,height:`${Sl}px`,flex:`0 0 ${Sl}px`,padding:`0`,margin:`0`,cursor:`pointer`,fontFamily:Ol,transition:`background 0.1s, border-color 0.1s`}),n}var Fl=28,Il=10,Ll=28,Rl=6,zl=`#eab308`,Bl=`'Inter', system-ui, sans-serif`,Vl=`"JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace`,Hl=180,Ul=6,Wl=32,Gl=`<svg viewBox="0 0 24 24" width="12" height="12" fill="none" stroke="currentColor" stroke-width="2.25" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>`,Kl=class{constructor(e){this.price=0,this.ctx={pricePrecision:2,buyOrderType:`limit`,sellOrderType:`stop`},this.chips=new Map,this.hovered=null,this.onDocMouseDown=e=>{if(!this.isVisible)return;let t=e.target;t&&(this.el.contains(t)||this.hide())},this.opts=e,this.theme=e.theme,this.labels=e.labels,this.el=document.createElement(`div`),this.el.dataset.role=`trade-action-bar`,Object.assign(this.el.style,{position:`absolute`,display:`none`,height:`${Fl}px`,zIndex:`20`,pointerEvents:`auto`,fontFamily:Bl,userSelect:`none`}),this.bar=document.createElement(`div`),this.bar.dataset.role=`trade-action-bar-row`,this.bar.setAttribute(`role`,`toolbar`),Object.assign(this.bar.style,{display:`flex`,alignItems:`stretch`,height:`${Fl}px`,boxSizing:`border-box`,borderRadius:`${Rl}px`,overflow:`hidden`,fontFamily:Bl,fontSize:`11px`,fontWeight:`600`,letterSpacing:`-0.025em`,lineHeight:`1`,whiteSpace:`nowrap`,backdropFilter:`blur(12px)`,webkitBackdropFilter:`blur(12px)`}),this.submenu=document.createElement(`div`),this.submenu.dataset.testid=`crosshair-pending-submenu`,this.submenu.setAttribute(`role`,`menu`),Object.assign(this.submenu.style,{position:`absolute`,bottom:`100%`,right:`0`,marginBottom:`${Ul}px`,display:`none`,flexDirection:`column`,minWidth:`${Hl}px`,boxSizing:`border-box`,borderRadius:`${Rl}px`,overflow:`hidden`,whiteSpace:`nowrap`,backdropFilter:`blur(12px)`,webkitBackdropFilter:`blur(12px)`}),this.el.append(this.submenu,this.bar);let t=[];e.onAlert&&t.push([`alert`,this.labels.actionAlert,()=>{var t;this.hide(),(t=e.onAlert)==null||t.call(e,this.price)}]),t.push([`pending`,this.labels.actionPending,()=>this.toggleSubmenu()]),t.push([`sl`,this.labels.actionSl,()=>{this.hide(),e.onBulkLevels(`sl`,this.price)}]),t.push([`tp`,this.labels.actionTp,()=>{this.hide(),e.onBulkLevels(`tp`,this.price)}]),t.push([`tsl`,this.labels.actionTsl,()=>{this.hide(),e.onBulkLevels(`tsl`,this.price)}]);for(let[e,n,r]of t){let t=document.createElement(`button`);t.type=`button`,t.dataset.testid=`crosshair-${e}`,t.dataset.kind=e;let i=document.createElement(`span`);i.textContent=n,i.style.lineHeight=`1`,t.appendChild(i),Object.assign(t.style,{display:`flex`,alignItems:`center`,padding:`0 ${Il}px`,margin:`0`,background:`transparent`,border:`none`,borderRadius:`0`,font:`inherit`,letterSpacing:`inherit`,cursor:`pointer`,transition:`background-color 0.15s, color 0.15s`}),t.addEventListener(`mouseenter`,()=>{this.hovered=e,this.applyChipColor(e)}),t.addEventListener(`mouseleave`,()=>{this.hovered=null,this.applyChipColor(e)}),t.addEventListener(`click`,e=>{e.stopPropagation(),r()}),this.chips.set(e,t),this.bar.appendChild(t)}this.closeBtn=document.createElement(`button`),this.closeBtn.type=`button`,this.closeBtn.dataset.testid=`crosshair-action-close`,this.closeBtn.title=this.labels.actionCloseTitle,this.closeBtn.setAttribute(`aria-label`,this.labels.actionCloseTitle),this.closeBtn.innerHTML=Gl,Object.assign(this.closeBtn.style,{display:`flex`,alignItems:`center`,justifyContent:`center`,width:`${Ll}px`,flex:`0 0 ${Ll}px`,padding:`0`,margin:`0`,background:`transparent`,border:`none`,borderRadius:`0`,cursor:`pointer`,transition:`background-color 0.15s, color 0.15s`}),this.closeBtn.addEventListener(`mouseenter`,()=>{this.hovered=`close`,this.applyCloseColor()}),this.closeBtn.addEventListener(`mouseleave`,()=>{this.hovered=null,this.applyCloseColor()}),this.closeBtn.addEventListener(`click`,e=>{e.stopPropagation(),this.hide()}),this.bar.appendChild(this.closeBtn);for(let e of[`mousedown`,`touchstart`,`pointerdown`])this.el.addEventListener(e,e=>e.stopPropagation());document.addEventListener(`mousedown`,this.onDocMouseDown),this.applyTheme()}show(e,t,n,r){var i,a;let o=this.isVisible;this.price=e,r&&(this.ctx=r),this.applyBulkAvailability(),this.closeSubmenu(),this.el.style.display=`block`,this.el.style.right=`${n}px`,this.el.style.top=`${Math.max(2,Math.round(t-Fl/2))}px`,o||(i=(a=this.opts).onVisibilityChange)==null||i.call(a)}hide(){var e,t;let n=this.isVisible;this.closeSubmenu(),this.el.style.display=`none`,n&&((e=(t=this.opts).onVisibilityChange)==null||e.call(t))}get isSubmenuOpen(){return this.submenu.style.display!==`none`}get isVisible(){return this.el.style.display!==`none`}get currentPrice(){return this.price}setTheme(e){this.theme=e,this.applyTheme()}destroy(){document.removeEventListener(`mousedown`,this.onDocMouseDown),this.el.remove()}applyTheme(){let e=this.theme;Object.assign(this.bar.style,{background:G(e.tooltip.background,.95),border:`1px solid ${e.axisBorder}`,boxShadow:`0 25px 50px -12px rgba(0, 0, 0, 0.25), 0 0 0 1px ${G(e.ui.accent,.2)}`,color:e.tooltip.text}),Object.assign(this.submenu.style,{background:G(e.tooltip.background,.95),border:`1px solid ${e.axisBorder}`,boxShadow:`0 25px 50px -12px rgba(0, 0, 0, 0.25)`,color:e.tooltip.text}),this.isSubmenuOpen&&this.buildSubmenu();let t=`1px solid ${G(e.axisBorder,.7)}`;for(let[e,n]of this.chips)n.style.borderRight=t,this.applyChipColor(e);let n=[...this.chips.values()].pop();n&&(n.style.borderRight=`none`),this.closeBtn.style.borderLeft=t,this.applyCloseColor()}applyBulkAvailability(){var e;let t=this.ctx.positionCount,n=this.ctx.mixedSides===!0,r=t===0||n,i=(e=this.ctx.symbol)==null?``:e,a=r?(t===0?this.labels.actionBulkNoPositionsTitle:this.labels.actionBulkMixedTitle).replace(/\{symbol\}/g,i):``;for(let e of[`sl`,`tp`,`tsl`]){let t=this.chips.get(e);t&&(t.disabled=r,t.setAttribute(`aria-disabled`,String(r)),t.title=a,t.style.opacity=r?`0.4`:`1`,t.style.cursor=r?`not-allowed`:`pointer`,this.applyChipColor(e))}}applyChipColor(e){let t=this.chips.get(e);if(!t)return;let n=this.theme,r=this.hovered===e&&!t.disabled,i,a;switch(e){case`alert`:i=zl,a=G(zl,.12);break;case`pending`:{let e=this.isSubmenuOpen;i=r||e?n.ui.accent:G(n.tooltip.text,.85),a=G(n.ui.accent,.1),t.style.color=i,t.style.background=r||e?a:`transparent`;return}case`tp`:i=n.tradeLevels.buySide,a=G(n.tradeLevels.buySide,.12);break;default:i=n.tradeLevels.sellSide,a=G(n.tradeLevels.sellSide,.12);break}t.style.color=i,t.style.background=r?a:`transparent`}toggleSubmenu(){this.isSubmenuOpen?this.closeSubmenu():(this.buildSubmenu(),this.submenu.style.display=`flex`,this.applyChipColor(`pending`))}closeSubmenu(){this.isSubmenuOpen&&(this.submenu.style.display=`none`,this.applyChipColor(`pending`))}buildSubmenu(){let e=this.theme,t=this.labels,n=this.ctx.buyOrderType===`limit`,r=this.price.toFixed(this.ctx.pricePrecision);this.submenu.innerHTML=``;let i=document.createElement(`div`);i.dataset.role=`pending-direction`,i.textContent=`${n?t.directionBelow:t.directionAbove} · ${r}`,Object.assign(i.style,{padding:`4px 10px`,fontFamily:Vl,fontSize:`8.5px`,fontWeight:`500`,textTransform:`uppercase`,letterSpacing:`0.1em`,color:G(e.axisText,.7),borderBottom:`1px solid ${G(e.axisBorder,.6)}`,background:G(e.background,.3),lineHeight:`1.4`}),this.submenu.appendChild(i);let a=n?[[`buy`,`limit`],[`sell`,`stop`]]:[[`sell`,`limit`],[`buy`,`stop`]];for(let[n,i]of a){let a=document.createElement(`button`);a.type=`button`,a.dataset.testid=`crosshair-pending-${n}_${i}`,a.setAttribute(`role`,`menuitem`);let o=n===`buy`?e.tradeLevels.buySide:e.tradeLevels.sellSide;Object.assign(a.style,{width:`100%`,display:`flex`,alignItems:`center`,justifyContent:`space-between`,gap:`16px`,padding:`0 10px`,height:`${Wl}px`,boxSizing:`border-box`,background:`transparent`,border:`none`,fontFamily:Bl,fontSize:`11px`,fontWeight:`600`,lineHeight:`1`,color:o,cursor:`pointer`,textAlign:`left`,transition:`background-color 0.15s`});let s=document.createElement(`span`);s.textContent=`${n===`buy`?t.buy:t.sell} ${i===`limit`?t.limit:t.stop}`,s.style.lineHeight=`1`;let c=document.createElement(`span`);c.textContent=`@ ${r}`,Object.assign(c.style,{lineHeight:`1`,fontFamily:Vl,fontSize:`9px`,fontWeight:`500`,textTransform:`uppercase`,letterSpacing:`0.1em`,color:G(e.axisText,.6)}),a.append(s,c),a.addEventListener(`mouseenter`,()=>{a.style.background=e.ui.accentBg}),a.addEventListener(`mouseleave`,()=>{a.style.background=`transparent`}),a.addEventListener(`click`,e=>{e.stopPropagation();let t=this.price;this.hide(),this.opts.onPendingPick(n,t,i)}),this.submenu.appendChild(a)}}applyCloseColor(){let e=this.theme,t=this.hovered===`close`;this.closeBtn.style.color=t?e.tooltip.text:e.axisText,this.closeBtn.style.background=t?e.ui.accentBg:`transparent`}},ql=class{constructor(e,t,n,r=k.trade,i=E){this._visible=!1,this._isMobile=!1,this.theme=e,this.cfg=i,this.el=document.createElement(`button`),this.el.innerHTML=An,this.el.title=r.placeOrderTitle,Object.assign(this.el.style,{position:`absolute`,right:`${t+26}px`,top:`0`,width:`${i.size}px`,height:`${i.size}px`,borderRadius:`50%`,border:`1px solid ${e.axisBorder}`,background:e.tooltip.background,color:e.axisText,fontSize:`14px`,lineHeight:`1`,display:`none`,alignItems:`center`,justifyContent:`center`,cursor:`pointer`,padding:`0`,fontFamily:`'Inter', system-ui, sans-serif`,zIndex:`15`,transform:`translateY(-50%)`,transition:`opacity 0.1s`,pointerEvents:`auto`,userSelect:`none`}),this.applyIconSize(i.iconSize),this.el.addEventListener(`click`,e=>{e.stopPropagation(),n()}),this.el.addEventListener(`mouseenter`,()=>{this.el.style.opacity=`1`,Object.assign(this.el.style,{background:e.tooltip.background,color:e.tradeLevels.buySide,border:`1px solid ${e.tradeLevels.buySide}`})}),this.el.addEventListener(`mouseleave`,e=>{var t;Object.assign(this.el.style,{background:this.theme.tooltip.background,color:this.theme.axisText,border:`1px solid ${this.theme.axisBorder}`});let n=e.relatedTarget;(!n||!((t=this.el.parentElement)!=null&&t.contains(n)))&&this.hide()})}setY(e){this.el.style.top=`${e}px`}show(){this._visible||(this._visible=!0,this.el.style.display=`flex`)}hide(){this._visible&&(this._visible=!1,this.el.style.display=`none`)}setTheme(e,t){this.theme=e,Object.assign(this.el.style,{border:`1px solid ${e.axisBorder}`,background:e.tooltip.background,color:e.axisText,right:`${t+26}px`})}setMobileMode(e){if(this._isMobile===e)return;this._isMobile=e;let t=e?this.cfg.mobileSize:this.cfg.size,n=e?this.cfg.mobileIconSize:this.cfg.iconSize;this.el.style.width=`${t}px`,this.el.style.height=`${t}px`,this.applyIconSize(n)}applyIconSize(e){let t=this.el.querySelector(`svg`);t&&(t.setAttribute(`width`,String(e)),t.setAttribute(`height`,String(e)))}},Jl=class{constructor(e,t,n,r,i=k.trade,a,o=!1){this._price=0,this._pricePrecision=2,this._buyOrderType=`limit`,this._sellOrderType=`limit`,this._compact=!1,this.onDocMouseDown=e=>{this.isVisible&&!this.el.contains(e.target)&&this.hide()},this.theme=e,this.lots=t,this.symbol=n,this.onDraftCreate=r,this.labels=i,this.onVisibilityChange=a,this.el=document.createElement(`div`),Object.assign(this.el.style,{position:`absolute`,display:`none`,flexDirection:`column`,background:e.tooltip.background,border:`1px solid ${e.axisBorder}`,borderRadius:`5px`,padding:`4px`,zIndex:`20`,boxShadow:`0 4px 16px rgba(0,0,0,0.25)`,fontFamily:`'Inter', system-ui, sans-serif`,fontSize:`12px`,width:`max-content`,pointerEvents:`auto`}),document.addEventListener(`mousedown`,this.onDocMouseDown)}show(e,t,n,r=2,i=`limit`,a=`limit`){var o;let s=this.isVisible;this._price=e,this._pricePrecision=r,this._buyOrderType=i,this._sellOrderType=a,this.rebuild(),this.el.style.display=`flex`,this.el.style.right=`${n}px`,this.el.style.top=`${t-16}px`,s||(o=this.onVisibilityChange)==null||o.call(this)}hide(){var e;let t=this.isVisible;this.el.style.display=`none`,t&&((e=this.onVisibilityChange)==null||e.call(this))}get isVisible(){return this.el.style.display!==`none`}setLots(e){this.lots=e}setSymbol(e){this.symbol=e}setCompact(e){this._compact=e}setTheme(e){this.theme=e,Object.assign(this.el.style,{background:e.tooltip.background,border:`1px solid ${e.axisBorder}`})}destroy(){document.removeEventListener(`mousedown`,this.onDocMouseDown)}rebuild(){this.el.innerHTML=``;let e=document.createElement(`div`);Object.assign(e.style,{height:`1px`,background:this.theme.axisBorder,margin:`0 8px`}),this.el.append(this.makeRow(this.theme.tradeLevels.sellSide,`sell`,this._sellOrderType),e,this.makeRow(this.theme.tradeLevels.buySide,`buy`,this._buyOrderType))}makeRow(e,t,n){let r=document.createElement(`button`);Object.assign(r.style,{display:`flex`,alignItems:`center`,gap:`8px`,width:`100%`,background:`transparent`,border:`none`,borderRadius:`3px`,padding:this._compact?`5px 8px`:`8px 10px`,cursor:`pointer`,fontFamily:`'Inter', system-ui, sans-serif`,fontSize:this._compact?`11px`:`12px`}),r.appendChild(this.makeChevron(e,t));let i=t===`sell`?this.labels.sell:this.labels.buy,a=n===`limit`?this.labels.limit:this.labels.stop,o=this._price.toFixed(this._pricePrecision),s=document.createElement(`span`);s.textContent=`${i} ${a}`,Object.assign(s.style,{color:e,fontWeight:`600`});let c=document.createElement(`span`);c.textContent=` ${this.lots} ${this.symbol} ${this.labels.at} ${o}`;let l=this.theme.tooltip.text;return Object.assign(c.style,{color:l,fontWeight:`400`}),r.append(s,c),r.addEventListener(`mouseenter`,()=>{r.style.background=this.theme.ui.accentBg}),r.addEventListener(`mouseleave`,()=>{r.style.background=`transparent`}),r.addEventListener(`mousedown`,e=>{e.stopPropagation(),this.onDraftCreate(t,this._price,n),this.hide()}),r}makeChevron(e,t){let n=`http://www.w3.org/2000/svg`,r=document.createElementNS(n,`svg`);r.setAttribute(`width`,`10`),r.setAttribute(`height`,`8`),r.setAttribute(`viewBox`,`0 0 10 8`),r.style.flexShrink=`0`;let i=document.createElementNS(n,`path`);return i.setAttribute(`d`,t===`sell`?`M1 1 L5 7 L9 1`:`M1 7 L5 1 L9 7`),i.setAttribute(`stroke`,e),i.setAttribute(`fill`,`none`),i.setAttribute(`stroke-width`,`1.5`),i.setAttribute(`stroke-linecap`,`round`),i.setAttribute(`stroke-linejoin`,`round`),r.appendChild(i),r}},Yl={horizontalLine:[`stroke`,`width`,`style`],verticalLine:[`stroke`,`width`,`style`],crossLine:[`stroke`,`width`,`style`],trendLine:[`stroke`,`width`,`style`],trendAngle:[`stroke`,`width`,`style`],parallelChannel:[`stroke`,`width`,`style`,`fill`],flatChannel:[`stroke`,`width`,`style`,`fill`],disjointChannel:[`stroke`,`width`,`style`],rectangle:[`stroke`,`width`,`style`,`fill`],rotatedRectangle:[`stroke`,`width`,`style`,`fill`],ellipse:[`stroke`,`width`,`style`,`fill`],circle:[`stroke`,`width`,`style`,`fill`],triangle:[`stroke`,`width`,`style`,`fill`],arc:[`stroke`,`width`,`style`],path:[`stroke`,`width`,`style`],polyline:[`stroke`,`width`,`style`],sineLine:[`stroke`,`width`,`style`],brush:[`stroke`,`width`],highlighter:[`stroke`,`width`],fibRetracement:[`width`,`style`,`fibLevels`],fibExtension:[`width`,`style`,`fibLevels`],fibProjection:[`width`,`style`,`fibLevels`],fibChannel:[`stroke`,`width`,`style`],fibFan:[`stroke`,`width`,`style`],fibCircles:[`stroke`,`width`,`style`],fibSpiral:[`stroke`,`width`,`style`],fibTimezone:[`stroke`,`width`,`style`],gannFan:[`stroke`,`width`,`style`],gannSquare:[`stroke`,`width`,`style`],gannBox:[`stroke`,`width`,`style`,`fill`],pitchfork:[`stroke`,`width`,`style`],schiffPitchfork:[`stroke`,`width`,`style`],modifiedSchiff:[`stroke`,`width`,`style`],insidePitchfork:[`stroke`,`width`,`style`],text:[`text`],callout:[`text`,`stroke`,`fill`],priceLabel:[`text`,`fill`],priceNote:[`text`,`stroke`],anchoredNote:[`text`,`stroke`,`fill`],arrowUp:[`stroke`,`fill`],arrowDown:[`stroke`,`fill`],arrowMarker:[`stroke`,`fill`],flag:[`stroke`,`fill`],volumeProfile:[`stroke`,`fill`],anchoredVP:[`stroke`,`fill`],fixedRangeVP:[`stroke`,`fill`],priceRange:[`stroke`,`fill`],dateRange:[`stroke`,`width`,`style`],datePriceRange:[`stroke`,`fill`],ruler:[`stroke`,`width`,`style`],longPosition:[`stroke`,`width`],shortPosition:[`stroke`,`width`],regressionTrend:[`stroke`,`width`,`style`],projection:[`stroke`,`width`,`style`],cyclicLines:[`stroke`,`width`,`style`],timeCycles:[`stroke`,`width`,`style`,`fill`],priceProjection:[`stroke`,`fill`],ghostFeed:[`stroke`,`fill`]},Xl=[1,2,3,4],Zl=[10,11,12,13,14,16,18,20,24],Ql=24,$l=new Set([`fibRetracement`]);function eu(e,t){let n={};for(let t of Object.keys(e==null?{}:e)){let r=e==null?void 0:e[t];r&&(n[t]=r)}for(let e of Object.keys(t==null?{}:t)){var r;let i=t==null?void 0:t[e];i===null?delete n[e]:i&&(n[e]={...(r=n[e])==null?{visible:!0,color:`#888888`}:r,...i})}return n}function tu(e){return String(e)}var nu=class{constructor(e,t,n){this.currentDrawing=null,this.fibLevelsExpanded=!1,this.fibPanel=null,this.container=e,this.theme=t,this.onChange=n,this.el=document.createElement(`div`),Object.assign(this.el.style,{position:`absolute`,display:`none`,flexDirection:`row`,alignItems:`center`,gap:`10px`,background:t.tooltip.background,border:`1px solid ${t.axisBorder}`,borderRadius:`8px`,padding:`8px 10px`,zIndex:`50`,boxShadow:`0 6px 18px rgba(0,0,0,0.35)`,fontFamily:`'Inter', system-ui, sans-serif`,fontSize:`11px`,color:t.tooltip.text,pointerEvents:`auto`,userSelect:`none`,whiteSpace:`nowrap`}),e.appendChild(this.el)}setTheme(e){this.theme=e,this.el.style.background=e.tooltip.background,this.el.style.border=`1px solid ${e.axisBorder}`,this.el.style.color=e.tooltip.text,this.currentDrawing&&this.rebuild()}show(e,t,n){var r;let i=((r=this.currentDrawing)==null?void 0:r.id)===e.id;this.currentDrawing=e,i||(this.fibLevelsExpanded=!1,this.rebuild()),this.el.style.display=`flex`,this.setAnchor(t,n)}setAnchor(e,t){requestAnimationFrame(()=>{let n=this.el.getBoundingClientRect(),r=this.container.getBoundingClientRect(),i=n.width||240,a=n.height||56,o=e-i/2,s=t-a-12;s<4&&(s=t+16),o=Math.max(4,Math.min(r.width-i-4,o)),s=Math.max(4,Math.min(r.height-a-4,s)),this.el.style.left=`${o}px`,this.el.style.top=`${s}px`})}hide(){var e;this.el.style.display=`none`,this.currentDrawing=null,this.fibLevelsExpanded=!1,(e=this.fibPanel)==null||e.remove(),this.fibPanel=null}destroy(){var e;(e=this.fibPanel)==null||e.remove(),this.el.remove(),this.currentDrawing=null}rebuild(){var e,t,n;if(this.el.innerHTML=``,!this.currentDrawing)return;let r=(e=Yl[this.currentDrawing.type])==null?[`stroke`,`width`,`style`]:e,i=(t=this.currentDrawing.style)==null?{}:t,a=(n=this.theme.drawing[this.currentDrawing.type])==null?{}:n,o=[];for(let e of r)switch(e){case`stroke`:var s,c;o.push(this.group(`Color`,this.makeColorSwatch((s=(c=i.strokeColor)==null?a.strokeColor:c)==null?`#888888`:s,e=>this.emit({strokeColor:e}))));break;case`width`:var l,u;o.push(this.group(`Width`,this.buildWidth((l=(u=i.lineWidth)==null?a.lineWidth:u)==null?1:l,e=>this.emit({lineWidth:e}))));break;case`style`:var d,f;o.push(this.group(`Style`,this.buildLineStyle((d=(f=i.lineStyle)==null?a.lineStyle:f)==null?`solid`:d,e=>this.emit({lineStyle:e}))));break;case`fill`:{var p,m,h,g;let e=document.createElement(`div`);Object.assign(e.style,{display:`flex`,alignItems:`center`,gap:`6px`}),e.appendChild(this.makeColorSwatch((p=(m=i.fillColor)==null?a.fillColor:m)==null?`#888888`:p,e=>this.emit({fillColor:e}))),e.appendChild(this.buildOpacity((h=(g=i.fillOpacity)==null?a.fillOpacity:g)==null?.1:h,e=>this.emit({fillOpacity:e}))),o.push(this.group(`Fill`,e));break}case`text`:{var _,v,y,b;let e=document.createElement(`div`);Object.assign(e.style,{display:`flex`,alignItems:`center`,gap:`6px`}),e.appendChild(this.makeColorSwatch((_=(v=i.textColor)==null?a.textColor:v)==null?`#f5f5f5`:_,e=>this.emit({textColor:e}))),e.appendChild(this.buildFontSize((y=(b=i.fontSize)==null?a.fontSize:b)==null?13:y,e=>this.emit({fontSize:e}))),o.push(this.group(`Text`,e));break}case`fibLevels`:o.push(this.group(`Levels`,this.buildFibLevelsButton(eu(a.levels,i.levels))));break}o.forEach((e,t)=>{t>0&&this.el.appendChild(this.makeSeparator()),this.el.appendChild(e)})}group(e,t){let n=document.createElement(`div`);Object.assign(n.style,{display:`flex`,flexDirection:`column`,alignItems:`flex-start`,gap:`4px`});let r=document.createElement(`span`);return r.textContent=e,Object.assign(r.style,{fontSize:`10px`,color:this.theme.axisText,textTransform:`uppercase`,letterSpacing:`0.5px`,lineHeight:`1`}),n.appendChild(r),n.appendChild(t),n}makeSeparator(){let e=document.createElement(`div`);return Object.assign(e.style,{width:`1px`,height:`32px`,background:this.theme.axisBorder,opacity:`0.6`}),e}makeColorSwatch(e,t){let n=l(this.theme.tooltip.background),r=e.length===7&&e.startsWith(`#`)?e:`#888888`,i=document.createElement(`div`);Object.assign(i.style,{position:`relative`,width:`${Ql}px`,height:`${Ql}px`,borderRadius:`6px`,overflow:`hidden`,cursor:`pointer`,border:`1.5px solid ${n}`,flexShrink:`0`,boxSizing:`border-box`});let a=document.createElement(`div`);Object.assign(a.style,{position:`absolute`,inset:`0`,background:e});let o=document.createElement(`input`);o.type=`color`,o.value=r,Object.assign(o.style,{position:`absolute`,inset:`0`,opacity:`0`,width:`100%`,height:`100%`,cursor:`pointer`,padding:`0`,border:`none`});let s=null;return o.addEventListener(`input`,()=>{a.style.background=o.value,s!==null&&clearTimeout(s),s=setTimeout(()=>{s=null,t(o.value)},200)}),i.append(a,o),i}buildWidth(e,t){let n=document.createElement(`div`);Object.assign(n.style,{display:`flex`,gap:`2px`,alignItems:`center`});for(let r of Xl){let i=this.makeIconButton(`${r}px`),a=document.createElement(`div`);Object.assign(a.style,{width:`14px`,height:`${r}px`,background:this.theme.tooltip.text,borderRadius:`1px`}),i.appendChild(a),Math.round(e)===r&&this.markActive(i),i.addEventListener(`click`,()=>t(r)),n.appendChild(i)}return n}buildLineStyle(e,t){let n=document.createElement(`div`);Object.assign(n.style,{display:`flex`,gap:`2px`,alignItems:`center`});let r=[{key:`solid`,svg:this.lineSvg(`solid`),title:`Solid`},{key:`dashed`,svg:this.lineSvg(`dashed`),title:`Dashed`},{key:`dotted`,svg:this.lineSvg(`dotted`),title:`Dotted`}];for(let{key:i,svg:a,title:o}of r){let r=this.makeIconButton(o);r.innerHTML=a,i===e&&this.markActive(r),r.addEventListener(`click`,()=>t(i)),n.appendChild(r)}return n}lineSvg(e){let t=e===`dashed`?`4,2`:e===`dotted`?`1.5,2`:``;return`<svg width="18" height="10" viewBox="0 0 18 10"><line x1="1" y1="5" x2="17" y2="5" stroke="${this.theme.tooltip.text}" stroke-width="1.5" stroke-linecap="round" ${t?`stroke-dasharray="${t}"`:``} /></svg>`}buildOpacity(e,t){let n=document.createElement(`div`);Object.assign(n.style,{display:`flex`,alignItems:`center`,gap:`4px`});let r=document.createElement(`input`);r.type=`range`,r.min=`0`,r.max=`100`,r.value=String(Math.round(e*100)),Object.assign(r.style,{width:`64px`,accentColor:this.theme.ui.accent}),r.title=`Fill opacity`;let i=document.createElement(`span`);return i.textContent=`${r.value}%`,Object.assign(i.style,{fontSize:`10px`,color:this.theme.axisText,minWidth:`26px`,textAlign:`right`}),r.addEventListener(`input`,()=>{i.textContent=`${r.value}%`,t(Number(r.value)/100)}),n.append(r,i),n}buildFontSize(e,t){let n=document.createElement(`select`);Object.assign(n.style,{background:this.theme.tooltip.background,color:this.theme.tooltip.text,border:`1px solid ${this.theme.axisBorder}`,borderRadius:`4px`,padding:`3px 4px`,fontSize:`11px`,cursor:`pointer`,height:`${Ql}px`,boxSizing:`border-box`});for(let t of Zl){let r=document.createElement(`option`);r.value=String(t),r.textContent=`${t}px`,t===e&&(r.selected=!0),n.appendChild(r)}return n.addEventListener(`change`,()=>t(Number(n.value))),n}buildFibLevelsButton(e){let t=document.createElement(`div`);t.style.position=`relative`;let n=this.makeIconButton(`Configure levels`);return n.style.padding=`0 8px`,n.style.height=`${Ql}px`,n.style.minWidth=`64px`,n.textContent=`Configure ▾`,t.appendChild(n),n.addEventListener(`click`,t=>{t.stopPropagation(),this.fibLevelsExpanded=!this.fibLevelsExpanded,this.fibLevelsExpanded?this.openFibPanel(n,e):this.closeFibPanel()}),document.addEventListener(`mousedown`,e=>{this.fibPanel&&!this.fibPanel.contains(e.target)&&!t.contains(e.target)&&(this.closeFibPanel(),this.fibLevelsExpanded=!1)}),t}buildLevelRatioLabel(e){let t=document.createElement(`span`);return t.textContent=e,Object.assign(t.style,{fontSize:`11px`,color:this.theme.tooltip.text}),t}buildLevelRatioInput(e,t,n){let r=e,i=document.createElement(`input`);i.type=`number`,i.step=`0.001`,i.value=r,i.title=`Level ratio — press Enter to apply`,i.enterKeyHint=`go`,i.tabIndex=-1,Object.assign(i.style,{width:`58px`,padding:`2px 4px`,fontSize:`11px`,fontFamily:`inherit`,color:this.theme.tooltip.text,background:this.theme.background,border:`1px solid ${this.theme.axisBorder}`,borderRadius:`3px`,outline:`none`});let a=()=>{let e=Number(i.value),a=Number.isFinite(e)?tu(e):null;if(a===null||a!==r&&t.has(a)){i.value=r;return}if(a===r){i.value=r;return}r=a,i.value=a,n(a)};return i.addEventListener(`focus`,()=>{i.style.borderColor=this.theme.ui.accent}),i.addEventListener(`blur`,()=>{i.style.borderColor=this.theme.axisBorder,a()}),i.addEventListener(`keydown`,e=>{e.stopPropagation(),e.key===`Enter`&&i.blur()}),i.addEventListener(`change`,a),i}openFibPanel(e,t){this.closeFibPanel();let n=document.createElement(`div`);Object.assign(n.style,{position:`absolute`,display:`grid`,gridTemplateColumns:`auto 1fr auto`,columnGap:`10px`,rowGap:`6px`,background:this.theme.tooltip.background,border:`1px solid ${this.theme.axisBorder}`,borderRadius:`6px`,padding:`10px 12px`,zIndex:`60`,boxShadow:`0 6px 18px rgba(0,0,0,0.35)`,fontFamily:`'Inter', system-ui, sans-serif`,fontSize:`11px`,color:this.theme.tooltip.text,alignItems:`center`});let r=Object.keys(t).sort((e,t)=>Number(e)-Number(t)),i=this.currentDrawing!==null&&$l.has(this.currentDrawing.type),a=new Set(r);for(let e of r){let r=t[e],o=e,s=r.color,c=document.createElement(`input`);c.type=`checkbox`,c.checked=r.visible!==!1,c.style.accentColor=this.theme.ui.accent,c.style.cursor=`pointer`;let l=this.makeColorSwatch(s,e=>{s=e,this.emit({levels:{[o]:{visible:c.checked,color:e}}})});c.addEventListener(`change`,()=>{this.emit({levels:{[o]:{visible:c.checked,color:s}}})}),c.tabIndex=-1,l.querySelectorAll(`input`).forEach(e=>{e.tabIndex=-1}),n.append(c,i?this.buildLevelRatioInput(e,a,e=>{this.emit({levels:{[o]:null,[e]:{visible:c.checked,color:s}}}),a.delete(o),a.add(e),o=e}):this.buildLevelRatioLabel(e),l)}let o=e.getBoundingClientRect(),s=this.container.getBoundingClientRect();this.container.appendChild(n);let c=n.getBoundingClientRect(),l=o.left-s.left,u=o.bottom-s.top+6;l=Math.max(4,Math.min(s.width-c.width-4,l)),u+c.height>s.height-4&&(u=Math.max(4,o.top-s.top-c.height-6)),n.style.left=`${l}px`,n.style.top=`${u}px`,this.fibPanel=n}closeFibPanel(){var e;(e=this.fibPanel)==null||e.remove(),this.fibPanel=null}makeIconButton(e){let t=document.createElement(`div`);return Object.assign(t.style,{display:`flex`,alignItems:`center`,justifyContent:`center`,minWidth:`${Ql}px`,height:`${Ql}px`,padding:`0 4px`,borderRadius:`4px`,cursor:`pointer`,border:`1px solid transparent`,color:this.theme.tooltip.text,background:`transparent`,fontSize:`11px`,boxSizing:`border-box`}),t.title=e,t.addEventListener(`mouseenter`,()=>{t.dataset.active!==`1`&&(t.style.background=this.theme.indicatorOverlay.dropdownHoverBg)}),t.addEventListener(`mouseleave`,()=>{t.dataset.active!==`1`&&(t.style.background=`transparent`)}),t}markActive(e){e.dataset.active=`1`,e.style.background=this.theme.ui.accentBg,e.style.borderColor=this.theme.ui.accent}emit(e){this.currentDrawing&&(this.onChange(this.currentDrawing.id,e),this.rebuild())}},ru=class{constructor(e,t,n){this._min=1,this._max=100,this._step=1,this._intendedTop=0,this._disposeKbd=()=>{},this.onDocMouseDown=e=>{this.isVisible&&!this.el.contains(e.target)&&(this.syncIfValid(),this.hide())},this.theme=e,this.onCommit=t,this.onVisibilityChange=n,this.el=document.createElement(`div`),Object.assign(this.el.style,{position:`fixed`,display:`none`,flexDirection:`row`,alignItems:`center`,gap:`4px`,background:e.tooltip.background,border:`1px solid ${e.axisBorder}`,borderRadius:`5px`,padding:`5px 7px`,zIndex:`25`,boxShadow:`0 4px 16px rgba(0,0,0,0.3)`,fontFamily:`'Inter', system-ui, sans-serif`,fontSize:`13px`,color:e.tooltip.text,pointerEvents:`auto`});let r=this.makeStepBtn(`−`,()=>this.step(-1));this.input=this.makeInput();let i=this.makeStepBtn(`+`,()=>this.step(1));this.el.append(r,this.input,i),this.el.addEventListener(`mousedown`,e=>e.stopPropagation()),this.el.addEventListener(`touchstart`,e=>e.stopPropagation()),document.addEventListener(`mousedown`,this.onDocMouseDown),this._disposeKbd=Hn(this.el,()=>this._intendedTop)}show(e,t,n,r,i){var a;let o=this.isVisible;this._min=r,this._max=i,this._step=r,this.input.min=String(r),this.input.max=String(i),this.input.step=String(r),this.input.value=String(n),this._intendedTop=t+4,this.el.style.display=`flex`,this.el.style.left=`${e}px`,this.el.style.top=`${this._intendedTop}px`,o||(a=this.onVisibilityChange)==null||a.call(this)}hide(){var e;let t=this.isVisible;this.el.style.display=`none`,t&&((e=this.onVisibilityChange)==null||e.call(this))}get isVisible(){return this.el.style.display!==`none`}setTheme(e){this.theme=e,Object.assign(this.el.style,{background:e.tooltip.background,border:`1px solid ${e.axisBorder}`,color:e.tooltip.text}),this.input.style.borderBottom=`1px solid ${e.axisBorder}`}destroy(){document.removeEventListener(`mousedown`,this.onDocMouseDown),this._disposeKbd()}makeStepBtn(e,t){let n=document.createElement(`button`);return n.textContent=e,Object.assign(n.style,{background:`transparent`,border:`none`,color:`inherit`,cursor:`pointer`,fontSize:`16px`,lineHeight:`1`,padding:`0 4px`,borderRadius:`3px`,opacity:`0.7`}),n.addEventListener(`mouseenter`,()=>{n.style.opacity=`1`}),n.addEventListener(`mouseleave`,()=>{n.style.opacity=`0.7`}),n.addEventListener(`mousedown`,e=>{e.preventDefault(),t()}),n}makeInput(){let e=document.createElement(`input`);return e.type=`number`,e.enterKeyHint=`go`,Object.assign(e.style,{width:`64px`,background:`transparent`,border:`none`,borderBottom:`1px solid ${this.theme.axisBorder}`,color:`inherit`,font:`16px 'Inter', system-ui, sans-serif`,outline:`none`,textAlign:`center`,padding:`1px 2px`}),e.addEventListener(`focus`,()=>{e.select()}),e.addEventListener(`input`,()=>{this.syncIfValid()}),e.addEventListener(`keydown`,e=>{e.key===`Enter`?(e.preventDefault(),this.syncIfValid(),this.hide()):e.key===`Escape`&&(e.preventDefault(),this.hide())}),e.addEventListener(`blur`,()=>{this.isVisible&&(this.syncIfValid(),this.hide())}),e}step(e){let t=parseFloat(this.input.value)||this._min,n=Math.round((t+e*this._step)*1e10)/1e10;this.input.value=String(Math.min(this._max,Math.max(this._min,n))),this.syncIfValid()}syncIfValid(){let e=parseFloat(this.input.value);!isNaN(e)&&e>=this._min&&e<=this._max&&this.onCommit(e)}},iu=50,au=20,ou=class{constructor(e,t,n){this.isins=[],this.currentSymbol=``,this.mode=`select`,this.activeSymbols=new Set,this.escHandler=null,this.disposeKbd=()=>{},this.theme=e,this.onSelect=t,this.onVisibilityChange=n,this.el=document.createElement(`div`),Object.assign(this.el.style,{position:`fixed`,inset:`0`,background:`rgba(0,0,0,0.5)`,display:`none`,alignItems:`center`,justifyContent:`center`,zIndex:`1000`}),this.el.addEventListener(`mousedown`,e=>{e.target===this.el&&this.hide()}),this.panel=document.createElement(`div`),Object.assign(this.panel.style,{display:`flex`,flexDirection:`column`,width:`360px`,maxHeight:`520px`,background:e.tooltip.background,border:`1px solid ${e.axisBorder}`,borderRadius:`6px`,boxShadow:`0 8px 32px rgba(0,0,0,0.45)`,fontFamily:`'Inter', system-ui, sans-serif`,fontSize:`12px`,overflow:`hidden`}),this.panel.addEventListener(`mousedown`,e=>e.stopPropagation()),this.el.appendChild(this.panel);let r=document.createElement(`div`);Object.assign(r.style,{display:`flex`,alignItems:`center`,justifyContent:`space-between`,padding:`10px 14px`,borderBottom:`1px solid ${e.axisBorder}`,flexShrink:`0`});let i=document.createElement(`span`);i.textContent=`Select Symbol`,Object.assign(i.style,{color:e.tooltip.text,fontWeight:`600`,fontSize:`13px`}),this.titleEl=i;let a=document.createElement(`span`);a.innerHTML=un,Object.assign(a.style,{display:`inline-flex`,alignItems:`center`,color:e.axisText,cursor:`pointer`}),a.addEventListener(`mouseenter`,()=>{a.style.color=e.tooltip.text}),a.addEventListener(`mouseleave`,()=>{a.style.color=e.axisText}),a.addEventListener(`click`,()=>this.hide()),r.appendChild(i),r.appendChild(a),this.panel.appendChild(r);let o=document.createElement(`div`);Object.assign(o.style,{padding:`8px 14px`,borderBottom:`1px solid ${e.axisBorder}`,flexShrink:`0`}),this.searchInput=document.createElement(`input`),this.searchInput.type=`text`,this.searchInput.placeholder=`Search symbols…`,Object.assign(this.searchInput.style,{width:`100%`,boxSizing:`border-box`,background:`transparent`,border:`1px solid ${e.axisBorder}`,borderRadius:`4px`,color:e.tooltip.text,fontSize:`16px`,padding:`5px 8px`,outline:`none`}),this.searchInput.addEventListener(`input`,()=>this.renderList()),o.appendChild(this.searchInput),this.panel.appendChild(o),this.listEl=document.createElement(`div`),Object.assign(this.listEl.style,{overflowY:`auto`,flex:`1`,scrollbarWidth:`thin`,scrollbarColor:`rgba(120,130,150,0.35) transparent`}),this.panel.appendChild(this.listEl),this.disposeKbd=Un(this.panel)}show(e,t){var n;let r=this.isVisible;this.isins=e,this.currentSymbol=t,this.searchInput.value=``,this.renderList(),this.el.style.display=`flex`,requestAnimationFrame(()=>this.searchInput.focus({preventScroll:!0})),this.escHandler=e=>{e.key===`Escape`&&this.hide()},document.addEventListener(`keydown`,this.escHandler),r||(n=this.onVisibilityChange)==null||n.call(this)}hide(){var e;let t=this.isVisible;this.el.style.display=`none`,this.escHandler&&(document.removeEventListener(`keydown`,this.escHandler),this.escHandler=null),t&&((e=this.onVisibilityChange)==null||e.call(this))}get isVisible(){return this.el.style.display!==`none`}setCurrentSymbol(e){this.currentSymbol=e,this.el.style.display!==`none`&&this.renderList()}setIsins(e){this.isins=e}setMode(e){this.mode=e,this.el.style.display!==`none`&&this.renderList()}setActiveSymbols(e){this.activeSymbols=new Set(e),this.el.style.display!==`none`&&this.renderList()}setTitle(e){this.titleEl.textContent=e}setTheme(e){this.theme=e,Object.assign(this.panel.style,{background:e.tooltip.background,border:`1px solid ${e.axisBorder}`})}destroy(){this.escHandler&&document.removeEventListener(`keydown`,this.escHandler),this.disposeKbd(),this.el.remove()}sortWithCurrentFirst(e){if(!this.currentSymbol)return e;let t=e.indexOf(this.currentSymbol);if(t<=0)return e;let n=e.slice();return n.splice(t,1),n.unshift(this.currentSymbol),n}renderList(){let e=this.searchInput.value.trim().toLowerCase(),t=this.sortWithCurrentFirst(e?this.isins.filter(t=>t.toLowerCase().includes(e)).slice(0,au):this.isins.slice(0,iu));if(this.listEl.innerHTML=``,t.length===0){let e=document.createElement(`div`);e.textContent=`No symbols found`,Object.assign(e.style,{padding:`16px 14px`,color:this.theme.axisText,textAlign:`center`}),this.listEl.appendChild(e);return}let n=this.mode===`toggle`;for(let e of t){let t=e===this.currentSymbol,r=n&&this.activeSymbols.has(e),i=!n||!t,a=t,o=document.createElement(`div`);if(Object.assign(o.style,{display:`flex`,alignItems:`center`,gap:`8px`,padding:`8px 14px`,cursor:i?`pointer`:`default`,color:a?this.theme.ui.accentText:this.theme.tooltip.text,background:a?this.theme.ui.accentBg:`transparent`,fontWeight:a?`600`:`400`,borderLeft:a?`2px solid ${this.theme.ui.accent}`:`2px solid transparent`,boxSizing:`border-box`,userSelect:`none`,opacity:i?`1`:`0.7`}),n){let e=document.createElement(`span`);e.textContent=t?``:r?`−`:`+`,Object.assign(e.style,{display:`inline-flex`,alignItems:`center`,justifyContent:`center`,width:`16px`,height:`16px`,fontSize:`14px`,lineHeight:`1`,fontWeight:`700`,color:r?this.theme.axisText:this.theme.ui.accent,flexShrink:`0`}),o.appendChild(e)}let s=document.createElement(`span`);s.textContent=e,s.style.flex=`1`,o.appendChild(s),o.addEventListener(`mouseenter`,()=>{!a&&i&&(o.style.background=this.theme.ui.accentBg)}),o.addEventListener(`mouseleave`,()=>{a||(o.style.background=`transparent`)}),o.addEventListener(`click`,()=>{i&&(this.onSelect(e),n||this.hide())}),this.listEl.appendChild(o)}}},su=class{constructor(e){this.chips=new Map,this.theme=e.theme,this.onRemove=e.onRemove,this.el=document.createElement(`div`),Object.assign(this.el.style,{display:`flex`,flexWrap:`wrap`,alignItems:`center`,gap:`6px`,pointerEvents:`auto`})}setTheme(e){this.theme=e;for(let t of this.chips.values()){t.style.border=`1px solid ${e.axisBorder}`,t.style.background=e.tooltip.background;let n=t.querySelector(`[data-role="symbol"]`);n&&(n.style.color=e.tooltip.text)}}update(e){let t=new Set;for(let n of e){t.add(n.symbol);let e=this.chips.get(n.symbol);e||(e=this.createChip(n),this.chips.set(n.symbol,e),this.el.appendChild(e)),this.updateChip(e,n)}for(let[e,n]of[...this.chips.entries()])t.has(e)||(n.remove(),this.chips.delete(e))}clear(){for(let e of this.chips.values())e.remove();this.chips.clear()}destroy(){this.clear(),this.el.remove()}createChip(e){let t=document.createElement(`div`);Object.assign(t.style,{display:`inline-flex`,alignItems:`center`,gap:`6px`,padding:`2px 6px`,borderRadius:`4px`,background:this.theme.tooltip.background,border:`1px solid ${this.theme.axisBorder}`,fontSize:`11px`,fontFamily:`inherit`,lineHeight:`1`,whiteSpace:`nowrap`,userSelect:`none`});let n=document.createElement(`span`);n.dataset.role=`dot`,Object.assign(n.style,{width:`8px`,height:`8px`,borderRadius:`9999px`,background:e.color,display:`inline-block`,flexShrink:`0`});let r=document.createElement(`span`);r.dataset.role=`symbol`,r.textContent=e.symbol,Object.assign(r.style,{color:this.theme.tooltip.text,fontWeight:`600`});let i=document.createElement(`span`);i.dataset.role=`value`,Object.assign(i.style,{color:this.theme.axisText,fontVariantNumeric:`tabular-nums`});let a=document.createElement(`span`);return a.dataset.role=`close`,a.textContent=`×`,Object.assign(a.style,{color:this.theme.axisText,cursor:`pointer`,fontSize:`14px`,lineHeight:`1`,padding:`0 2px`,marginLeft:`2px`}),a.addEventListener(`click`,t=>{t.stopPropagation(),this.onRemove(e.symbol)}),a.addEventListener(`mouseenter`,()=>{a.style.color=this.theme.tooltip.text}),a.addEventListener(`mouseleave`,()=>{a.style.color=this.theme.axisText}),t.append(n,r,i,a),t}updateChip(e,t){let n=e.querySelector(`[data-role="dot"]`);n&&n.style.background!==t.color&&(n.style.background=t.color);let r=e.querySelector(`[data-role="value"]`);if(r){if(t.status===`loading`){r.textContent=`…`,r.style.color=this.theme.axisText,e.title=`Loading…`;return}if(t.status===`error`){var i;r.textContent=`error`,r.style.color=this.theme.ui.stream.disconnected,e.title=(i=t.errorMessage)==null?`Failed to load`:i;return}if(e.title=``,t.percent==null){r.textContent=`—`,r.style.color=this.theme.axisText;return}r.textContent=`${t.percent>=0?`+`:``}${t.percent.toFixed(2)}%`,r.style.color=t.percent>=0?this.theme.candle.up:this.theme.candle.down}}},cu=[`#2962FF`,`#FF6D00`,`#00BFA5`,`#D500F9`,`#FFD600`,`#76FF03`,`#FF1744`,`#00B0FF`],lu=class{constructor(e){var t;this.entries=new Map,this.order=[],this.generation=0,this.lastParams=null,this.nextColorIndex=0,this.emitter=e.emitter,this.loader=e.loader,this.palette=e.palette&&e.palette.length>0?e.palette:cu,this.maxCompares=Math.max(1,(t=e.maxCompares)==null?8:t)}setLoader(e){this.loader=e}setLastParams(e){this.lastParams={...e}}isActive(){return this.entries.size>0}has(e){return this.entries.has(e)}list(){return this.order.map(e=>this.entries.get(e)).filter(e=>e!==void 0)}async add(e){if(!e||this.entries.has(e))return;if(this.entries.size>=this.maxCompares){this.emitter.emit(`compareError`,{symbol:e,message:`Maximum of ${this.maxCompares} compare symbols reached`});return}if(!this.loader){this.emitter.emit(`compareError`,{symbol:e,message:`No compareDataLoader configured`});return}if(!this.lastParams){this.emitter.emit(`compareError`,{symbol:e,message:`Primary chart has no loaded range yet`});return}let t=this.assignColor(),n={symbol:e,color:t,bars:[],status:`loading`};this.entries.set(e,n),this.order.push(e),this.emitter.emit(`compareAdded`,{symbol:e,color:t}),await this.fetchOne(n,this.lastParams,this.generation)}remove(e){if(!this.entries.has(e))return;this.entries.delete(e);let t=this.order.indexOf(e);t>=0&&this.order.splice(t,1),this.emitter.emit(`compareRemoved`,{symbol:e})}clear(){let e=[...this.order];this.entries.clear(),this.order.length=0;for(let t of e)this.emitter.emit(`compareRemoved`,{symbol:t})}async refetchAll(e){if(this.setLastParams(e),!this.loader||this.entries.size===0)return;this.generation++;let t=this.generation,n=this.list();for(let e of n)e.status=`loading`,e.errorMessage=void 0;await Promise.all(n.map(n=>this.fetchOne(n,e,t)))}async fetchOne(e,t,n){let r=this.loader;if(r)try{let i=await r({...t,symbol:e.symbol});if(n!==this.generation||!this.entries.has(e.symbol))return;e.bars=[...i].sort((e,t)=>e.time-t.time),e.status=`ready`,e.errorMessage=void 0}catch(t){if(n!==this.generation||!this.entries.has(e.symbol))return;e.status=`error`,e.errorMessage=t instanceof Error?t.message:String(t),this.emitter.emit(`compareError`,{symbol:e.symbol,message:e.errorMessage})}}assignColor(){let e=new Set(this.list().map(e=>e.color));for(let t=0;t<this.palette.length;t++){let n=(this.nextColorIndex+t)%this.palette.length,r=this.palette[n];if(!e.has(r))return this.nextColorIndex=(n+1)%this.palette.length,r}let t=this.palette[this.nextColorIndex%this.palette.length];return this.nextColorIndex=(this.nextColorIndex+1)%this.palette.length,t}};function uu(e,t){return`${e}#${t}`}function du(e,t){if(e.length===0)throw Error(`cycleIndicatorColor: empty palette`);let n=e[t%e.length];if(n===void 0)throw Error(`cycleIndicatorColor: index out of range`);return n}function fu(e,t){let n=e.filter(e=>e.instanceId===t);return n.length>0?n:e.filter(e=>e.shortName===t)}function pu(e,t){return t===0||!Number.isFinite(t)?0:(e-t)/t*100}function mu(e,t){if(t===0||!Number.isFinite(t))return e;let n=Array(e.length);for(let r=0;r<e.length;r++){let i=e[r];n[r]={time:i.time,open:pu(i.open,t),high:pu(i.high,t),low:pu(i.low,t),close:pu(i.close,t),volume:i.volume}}return n}function hu(e,t){if(t===0||!Number.isFinite(t))return e;let n=Array(e.length);for(let r=0;r<e.length;r++){let i=e[r];n[r]={index:i.index,value:i.value==null?i.value:pu(i.value,t),upper:i.upper==null?i.upper:pu(i.upper,t),lower:i.lower==null?i.lower:pu(i.lower,t),signal:i.signal,histogram:i.histogram}}return n}function gu(e,t,n,r=.05){let i=1/0,a=-1/0;for(let n of e){let e=pu(n.low,t),r=pu(n.high,t);e<i&&(i=e),r>a&&(a=r)}for(let e of n)for(let t of e)t.pct<i&&(i=t.pct),t.pct>a&&(a=t.pct);if(!Number.isFinite(i)||!Number.isFinite(a))return{min:-1,max:1};if(i===a)return{min:i-1,max:a+1};let o=a-i;return{min:i-o*r,max:a+o*r}}function _u(e,t,n){if(e.length===0||t.length===0)return[];let r=t[Math.max(0,Math.min(t.length-1,Math.floor(n)))],i=vu(e,r),a=i>=0?e[i].close:e[0].close;return a===0||!Number.isFinite(a)?e.map(e=>({time:e.time,pct:null})):e.map(e=>({time:e.time,pct:pu(e.close,a)}))}function vu(e,t){let n=0,r=e.length-1,i=-1;for(;n<=r;){let a=n+r>>1;e[a].time>=t?(i=a,r=a-1):n=a+1}return i}var yu=class e{constructor(){this._active=!1,this._isDraggingBracket=!1,this._level=null,this._startPrice=0,this._currentPrice=0,this._pixelOffset=0,this._mainMinPrice=-1/0,this._mainMaxPrice=1/0,this._bracketType=null,this._bracketStartPrice=0,this._bracketCurrentPrice=0,this._bracketPixelOffset=0,this._bracketParentPrice=0,this._bracketParentSide=`buy`,this._bracketMarketPrice=0,this._followBrackets=!1}startDrag(e,t,n,r,i,a,o,s,c,l){this._active=!0,this._isDraggingBracket=!1,this._level=e,this._pixelOffset=t-n,this._startPrice=r,this._currentPrice=r,this._bracketType=null,this._followBrackets=l===!0,this._slStartPrice=i,this._tpStartPrice=a,this._derivedSLPrice=i,this._derivedTPPrice=a,this._followBrackets?(this._mainMinPrice=-1/0,this._mainMaxPrice=1/0):i!==void 0||a!==void 0?(o==null?`buy`:o)===`buy`?(this._mainMinPrice=i==null?-1/0:i,this._mainMaxPrice=a==null?1/0:a):(this._mainMinPrice=a==null?-1/0:a,this._mainMaxPrice=i==null?1/0:i):(this._mainMinPrice=-1/0,this._mainMaxPrice=1/0),s&&s>0&&c&&c!==`market`&&o&&(o===`buy`&&c===`limit`||o===`sell`&&c===`stop`?this._mainMaxPrice=Math.min(this._mainMaxPrice,s):this._mainMinPrice=Math.max(this._mainMinPrice,s))}startBracketDrag(e,t,n,r,i,a=0,o){var s;this._active=!0,this._isDraggingBracket=!0,this._level=e,this._bracketType=t,this._bracketStartPrice=n,this._bracketCurrentPrice=n,this._bracketPixelOffset=r-i,this._bracketParentPrice=o==null?e.price:o,this._bracketParentSide=(s=e.side)==null?`buy`:s,this._bracketMarketPrice=a}onMouseMove(e,t,n,r){if(!this._active||!this._level)return null;if(this._isDraggingBracket&&this._bracketType!==null){let i=e-this._bracketPixelOffset,a=t.pixelToPrice(i,n,r),o=this._clampBracketPrice(a,this._bracketType,this._bracketParentPrice,this._bracketParentSide,this._bracketMarketPrice);return this._bracketCurrentPrice=o,{newPrice:o,label:`${this._level.label}:${this._bracketType}`,isBracket:!0}}let i=e-this._pixelOffset,a=t.pixelToPrice(i,n,r),o=Math.max(this._mainMinPrice,Math.min(this._mainMaxPrice,a));if(this._currentPrice=o,this._followBrackets){let e=o-this._startPrice;return this._derivedSLPrice=this._slStartPrice===void 0?void 0:this._slStartPrice+e,this._derivedTPPrice=this._tpStartPrice===void 0?void 0:this._tpStartPrice+e,{newPrice:o,label:this._level.label,isBracket:!1,derivedSLPrice:this._derivedSLPrice,derivedTPPrice:this._derivedTPPrice}}return{newPrice:o,label:this._level.label,isBracket:!1}}endDrag(){if(!this._active||!this._level)return null;let e=this._level,t;return t=this._isDraggingBracket&&this._bracketType!==null?{label:e.label,type:e.type,newPrice:this._bracketCurrentPrice,startPrice:this._bracketStartPrice,data:e.data,bracketType:this._bracketType}:this._followBrackets?{label:e.label,type:e.type,newPrice:this._currentPrice,startPrice:this._startPrice,data:e.data,derivedSLPrice:this._derivedSLPrice,derivedTPPrice:this._derivedTPPrice,slStartPrice:this._slStartPrice,tpStartPrice:this._tpStartPrice}:{label:e.label,type:e.type,newPrice:this._currentPrice,startPrice:this._startPrice,data:e.data},this._reset(),t}cancelDrag(){this._reset()}get active(){return this._active}get dragLabel(){return!this._active||!this._level?null:this._isDraggingBracket&&this._bracketType?`${this._level.label}:${this._bracketType}`:this._level.label}get currentPrice(){return this._active?this._isDraggingBracket?this._bracketCurrentPrice:this._currentPrice:null}static isBracketPriceValid(e,t,n,r,i=0){let a=i>0?i:n;return r===`buy`?t===`stopLoss`?e<a:e>a:t===`stopLoss`?e>a:e<a}_clampBracketPrice(t,n,r,i,a=0){return e.isBracketPriceValid(t,n,r,i,a)?t:a>0?a:r}_reset(){this._active=!1,this._isDraggingBracket=!1,this._level=null,this._bracketType=null,this._currentPrice=0,this._pixelOffset=0,this._mainMinPrice=-1/0,this._mainMaxPrice=1/0,this._bracketStartPrice=0,this._bracketCurrentPrice=0,this._bracketPixelOffset=0,this._bracketParentPrice=0,this._bracketParentSide=`buy`,this._bracketMarketPrice=0,this._followBrackets=!1,this._slStartPrice=void 0,this._tpStartPrice=void 0,this._derivedSLPrice=void 0,this._derivedTPPrice=void 0}},bu=class e{constructor(){this._active=!1,this._level=null,this._startBarIndex=0,this._startTimestamp=0,this._currentBarIndex=0,this._pixelOffset=0}static resolveDragAxis(e,t,n){return Math.sqrt(e*e+t*t)<=n?null:Math.abs(e)>=Math.abs(t)?`time`:`price`}start(e,t,n,r,i){this._active=!0,this._level=e,this._pixelOffset=t-n,this._startBarIndex=r,this._startTimestamp=i,this._currentBarIndex=r}onMove(t,n,r,i){if(!this._active||!this._level)return null;let a=t-this._pixelOffset,o=n.pixelToBarIndex(a,r,i);return this._currentBarIndex=e.clampToViewport(o,r),this._currentBarIndex}end(t,n){if(!this._active||!this._level)return null;let r=this._level,i=t?Math.round(this._currentBarIndex):this._currentBarIndex,a=e.clampToViewport(i,n),o={label:r.label,type:r.type,data:r.data,startBarIndex:this._startBarIndex,startTimestamp:this._startTimestamp,newBarIndex:a};return this._reset(),o}cancel(){this._reset()}get active(){return this._active}get dragLabel(){return this._active&&this._level?this._level.label:null}get currentBarIndex(){return this._active?this._currentBarIndex:null}get startTimestamp(){return this._startTimestamp}get startBarIndex(){return this._startBarIndex}static clampToViewport(e,t){return Math.max(t.startIndex,Math.min(t.endIndex,e))}_reset(){this._active=!1,this._level=null,this._startBarIndex=0,this._startTimestamp=0,this._currentBarIndex=0,this._pixelOffset=0}},xu=.1,Su=10;function Cu(e,t,n,r=24){let i=t.filter(e=>Number.isFinite(e)),a=e.max-e.min;if(i.length===0||!(a>0)||!(n>0))return null;let o=Math.min(...i),s=Math.max(...i);if(o>=e.min&&s<=e.max)return null;let c=e.min,l=e.max;for(let t=0;t<2;t++){let t=r*(l-c)/n;c=Math.min(e.min,o-t),l=Math.max(e.max,s+t)}return{min:c,max:l}}function wu(e,t){let n=(e.min+e.max)/2,r=e.max===e.min?1:(e.max-e.min)/2;return{factor:Math.min(Su,Math.max(xu,(t.max-t.min)/(2*r))),panOffset:(t.min+t.max)/2-n}}var Tu=`finchart.orderLineTimeAnchors`,Eu=class{constructor(e,t=Tu,n=500){this._storage=e,this._key=t,this._maxEntries=n,this._entries=new Map,this._load()}static browserStorage(){try{return typeof localStorage>`u`?null:localStorage}catch(e){return null}}get(e){var t;return(t=this._entries.get(e))==null?void 0:t.ts}has(e){return this._entries.has(e)}get size(){return this._entries.size}set(e,t,n=Date.now()){!e||!Number.isFinite(t)||(this._entries.set(e,{ts:t,at:n}),this._evict(),this._save())}delete(e){let t=this._entries.delete(e);return t&&this._save(),t}clear(){this._entries.clear();try{var e;(e=this._storage)==null||e.removeItem(this._key)}catch(e){}}_evict(){if(this._entries.size<=this._maxEntries)return;let e=[...this._entries.entries()].sort((e,t)=>e[1].at-t[1].at),t=this._entries.size-this._maxEntries;for(let n=0;n<t;n++){let t=e[n];t&&this._entries.delete(t[0])}}_load(){if(this._storage)try{let e=this._storage.getItem(this._key);if(!e)return;let t=JSON.parse(e);if(!t||typeof t!=`object`||Array.isArray(t))return;for(let[e,n]of Object.entries(t)){if(!n||typeof n!=`object`)continue;let{ts:t,at:r}=n;if(typeof t!=`number`||!Number.isFinite(t))continue;let i=typeof r==`number`&&Number.isFinite(r)?r:0;this._entries.set(e,{ts:t,at:i})}this._evict()}catch(e){}}_save(){if(this._storage)try{if(this._entries.size===0){this._storage.removeItem(this._key);return}this._storage.setItem(this._key,JSON.stringify(Object.fromEntries(this._entries)))}catch(e){}}};function Du(e,t){return e[t]}var Ou=class{constructor(e,t=`#F5A623`,n=`MA`,r=`close`){this.period=e,this.source=r,this.name=n,this.color=t}compute(e){return e.map((t,n)=>{if(n<this.period-1)return{index:n,value:null};let r=0;for(let t=n-this.period+1;t<=n;t++)r+=Du(e[t],this.source);return{index:n,value:r/this.period}})}render(e,t,n,r,i){var a;let o=ku(e);if(!o)return;e.beginPath(),e.strokeStyle=this.color,e.lineWidth=1.5,e.lineJoin=`round`;let s=!1,c=(a=e.canvas._chartWidth)==null?e.canvas.width:a;for(let a of t){if(a.value===null){s=!1;continue}let t=n.xToPixel(a.index,r,c),l=n.yToPixel(a.value,o,i);s?e.lineTo(t,l):(e.moveTo(t,l),s=!0)}e.stroke()}};function ku(e){var t;return(t=e.canvas._priceRange)==null?null:t}var Au=class{constructor(e,t=`#9B59B6`,n=`EMA`,r=`close`){this.period=e,this.source=r,this.name=n,this.color=t}compute(e){let t=2/(this.period+1),n=[],r=null;for(let i=0;i<e.length;i++){if(i<this.period-1){n.push({index:i,value:null});continue}if(r===null){let t=0;for(let n=0;n<this.period;n++)t+=Du(e[i-n],this.source);r=t/this.period}else r=Du(e[i],this.source)*t+r*(1-t);n.push({index:i,value:r})}return n}render(e,t,n,r,i){var a;let o=e.canvas._priceRange;if(!o)return;e.beginPath(),e.strokeStyle=this.color,e.lineWidth=1.5,e.lineJoin=`round`;let s=!1,c=(a=e.canvas._chartWidth)==null?e.canvas.width:a;for(let a of t){if(a.value===null){s=!1;continue}let t=n.xToPixel(a.index,r,c),l=n.yToPixel(a.value,o,i);s?e.lineTo(t,l):(e.moveTo(t,l),s=!0)}e.stroke()}},ju=class{constructor(e=20,t=`#e91e63`,n=`WMA`,r=`close`){this.period=e,this.source=r,this.name=n,this.color=t}compute(e){let t=this.period*(this.period+1)/2,n=[];for(let r=0;r<e.length;r++){if(r<this.period-1){n.push({index:r,value:null});continue}let i=0;for(let t=0;t<this.period;t++)i+=Du(e[r-(this.period-1-t)],this.source)*(t+1);n.push({index:r,value:i/t})}return n}render(e,t,n,r,i){var a;let o=e.canvas,s=o._priceRange;if(!s)return;let c=(a=o._chartWidth)==null?e.canvas.width:a;e.beginPath(),e.strokeStyle=this.color,e.lineWidth=1.5,e.lineJoin=`round`;let l=!1;for(let a of t){if(a.value===null){l=!1;continue}let t=n.xToPixel(a.index,r,c),o=n.yToPixel(a.value,s,i);l?e.lineTo(t,o):(e.moveTo(t,o),l=!0)}e.stroke()}};function Mu(e,t){let n=t*(t+1)/2,r=[];for(let i=0;i<e.length;i++){if(i<t-1){r.push(null);continue}let a=0;for(let n=0;n<t;n++)a+=e[i-(t-1-n)]*(n+1);r.push(a/n)}return r}var Nu=class{constructor(e=20,t=`#00bcd4`,n=`HMA`,r=`close`){this.period=e,this.source=r,this.name=n,this.color=t}compute(e){let t=e.map(e=>Du(e,this.source)),n=Math.floor(this.period/2),r=Math.floor(Math.sqrt(this.period)),i=Mu(t,n),a=Mu(t,this.period),o=i.map((e,t)=>{let n=a[t];return e===null||n===null?null:2*e-n}),s=Mu(o.map(e=>e===null?0:e),r);return e.map((e,t)=>{let n=t-r+1;return n<0||!(o[n]!==null&&o[t]!==null)||s[t]===null?{index:t,value:null}:{index:t,value:s[t]}})}render(e,t,n,r,i){var a;let o=e.canvas,s=o._priceRange;if(!s)return;let c=(a=o._chartWidth)==null?e.canvas.width:a;e.beginPath(),e.strokeStyle=this.color,e.lineWidth=1.5,e.lineJoin=`round`;let l=!1;for(let a of t){if(a.value===null){l=!1;continue}let t=n.xToPixel(a.index,r,c),o=n.yToPixel(a.value,s,i);l?e.lineTo(t,o):(e.moveTo(t,o),l=!0)}e.stroke()}},Pu=[5,10,20,50,100],Fu=[`#ff6b6b`,`#ffd93d`,`#6bcb77`,`#4d96ff`,`#c77dff`],Iu=class{constructor(e=`#ffcc80`,t=`close`){this.source=t,this.name=`MARibbon`,this.color=e}compute(e){let t=(t,n)=>{if(t<n-1)return null;let r=0;for(let i=t-n+1;i<=t;i++)r+=Du(e[i],this.source);return r/n};return e.map((e,n)=>({index:n,value:t(n,5),upper:t(n,10),lower:t(n,20),signal:t(n,50),histogram:t(n,100)}))}render(e,t,n,r,i){var a;let o=e.canvas,s=o._priceRange;if(!s)return;let c=(a=o._chartWidth)==null?e.canvas.width:a;e.lineWidth=1,e.lineJoin=`round`;let l=[`value`,`upper`,`lower`,`signal`,`histogram`];for(let a=0;a<Pu.length;a++){let o=l[a],u=Fu[a];e.beginPath(),e.strokeStyle=u;let d=!1;for(let a of t){let t=a[o];if(t==null){d=!1;continue}let l=n.xToPixel(a.index,r,c),u=n.yToPixel(t,s,i);d?e.lineTo(l,u):(e.moveTo(l,u),d=!0)}e.stroke()}}},Lu=class{constructor(e=20,t=2,n=`#3B82F6`,r=`BB`,i=`close`){this.period=e,this.stdDevMultiplier=t,this.source=i,this.name=r,this.color=n}compute(e){return e.map((t,n)=>{if(n<this.period-1)return{index:n,value:null,upper:null,lower:null};let r=e.slice(n-this.period+1,n+1).map(e=>Du(e,this.source)),i=r.reduce((e,t)=>e+t,0)/this.period,a=r.reduce((e,t)=>e+(t-i)**2,0)/this.period,o=Math.sqrt(a);return{index:n,value:i,upper:i+o*this.stdDevMultiplier,lower:i-o*this.stdDevMultiplier}})}render(e,t,n,r,i){var a;let o=e.canvas._priceRange;if(!o)return;let s=(a=e.canvas._chartWidth)==null?e.canvas.width:a;e.lineWidth=1,e.lineJoin=`round`;let c=(a,c=!1)=>{c&&e.setLineDash([4,3]),e.beginPath();let l=!1;for(let c of t){let t=a(c);if(t==null){l=!1;continue}let u=n.xToPixel(c.index,r,s),d=n.yToPixel(t,o,i);l?e.lineTo(u,d):(e.moveTo(u,d),l=!0)}e.stroke(),c&&e.setLineDash([])};e.strokeStyle=this.color,c(e=>e.value),e.strokeStyle=`${this.color}99`,c(e=>e.upper,!0),c(e=>e.lower,!0);let l=[],u=[];for(let e of t){if(e.upper==null||e.lower==null)continue;let t=n.xToPixel(e.index,r,s);l.push([t,n.yToPixel(e.upper,o,i)]),u.push([t,n.yToPixel(e.lower,o,i)])}l.length<2||(e.beginPath(),l.forEach(([t,n],r)=>r===0?e.moveTo(t,n):e.lineTo(t,n)),u.reverse().forEach(([t,n])=>e.lineTo(t,n)),e.closePath(),e.fillStyle=`${this.color}12`,e.fill())}},Ru=class{constructor(e=20,t=2,n=10,r=`#4caf50`,i=`KC`){this.period=e,this.mult=t,this.atrPeriod=n,this.name=i,this.color=r}compute(e){let t=[],n=2/(this.period+1),r=null,i=null;for(let a=0;a<e.length;a++){let o=e[a];if(a<this.period-1){t.push({index:a,value:null,upper:null,lower:null});continue}if(r===null){let t=0;for(let n=0;n<this.period;n++)t+=e[a-n].close;r=t/this.period}else r=o.close*n+r*(1-n);let s=a===0?o.high-o.low:Math.max(o.high-o.low,Math.abs(o.high-e[a-1].close),Math.abs(o.low-e[a-1].close));if(i===null){let t=0;for(let n=0;n<this.atrPeriod;n++){let r=e[a-n],i=a-n>0?e[a-n-1]:null,o=i==null?r.high-r.low:Math.max(r.high-r.low,Math.abs(r.high-i.close),Math.abs(r.low-i.close));t+=o}i=t/this.atrPeriod}else i=(i*(this.atrPeriod-1)+s)/this.atrPeriod;let c=r+this.mult*i,l=r-this.mult*i;t.push({index:a,value:r,upper:c,lower:l})}return t}render(e,t,n,r,i){var a;let o=e.canvas,s=o._priceRange;if(!s)return;let c=(a=o._chartWidth)==null?e.canvas.width:a;e.lineWidth=1,e.lineJoin=`round`;let l=(a,o=!1)=>{o&&e.setLineDash([4,3]),e.beginPath();let l=!1;for(let o of t){let t=a(o);if(t==null){l=!1;continue}let u=n.xToPixel(o.index,r,c),d=n.yToPixel(t,s,i);l?e.lineTo(u,d):(e.moveTo(u,d),l=!0)}e.stroke(),o&&e.setLineDash([])};e.strokeStyle=this.color,l(e=>e.value),e.strokeStyle=`${this.color}99`,l(e=>e.upper,!0),l(e=>e.lower,!0);let u=[],d=[];for(let e of t){if(e.upper==null||e.lower==null)continue;let t=n.xToPixel(e.index,r,c);u.push([t,n.yToPixel(e.upper,s,i)]),d.push([t,n.yToPixel(e.lower,s,i)])}u.length<2||(e.beginPath(),u.forEach(([t,n],r)=>r===0?e.moveTo(t,n):e.lineTo(t,n)),d.reverse().forEach(([t,n])=>e.lineTo(t,n)),e.closePath(),e.fillStyle=`${this.color}12`,e.fill())}},zu=class{constructor(e=20,t=`#26c6da`){this.period=e,this.name=`DC`,this.color=t}compute(e){return e.map((t,n)=>{if(n<this.period-1)return{index:n,value:null,upper:null,lower:null};let r=-1/0,i=1/0;for(let t=n-this.period+1;t<=n;t++)e[t].high>r&&(r=e[t].high),e[t].low<i&&(i=e[t].low);return{index:n,value:(r+i)/2,upper:r,lower:i}})}render(e,t,n,r,i){var a;let o=e.canvas,s=o._priceRange;if(!s)return;let c=(a=o._chartWidth)==null?e.canvas.width:a;e.lineWidth=1,e.lineJoin=`round`;let l=(a,o=!1)=>{o&&e.setLineDash([4,3]),e.beginPath();let l=!1;for(let o of t){let t=a(o);if(t==null){l=!1;continue}let u=n.xToPixel(o.index,r,c),d=n.yToPixel(t,s,i);l?e.lineTo(u,d):(e.moveTo(u,d),l=!0)}e.stroke(),o&&e.setLineDash([])};e.strokeStyle=this.color,l(e=>e.value,!0),e.strokeStyle=`${this.color}99`,l(e=>e.upper),l(e=>e.lower);let u=[],d=[];for(let e of t){if(e.upper==null||e.lower==null)continue;let t=n.xToPixel(e.index,r,c);u.push([t,n.yToPixel(e.upper,s,i)]),d.push([t,n.yToPixel(e.lower,s,i)])}u.length<2||(e.beginPath(),u.forEach(([t,n],r)=>r===0?e.moveTo(t,n):e.lineTo(t,n)),d.slice().reverse().forEach(([t,n])=>e.lineTo(t,n)),e.closePath(),e.fillStyle=`${this.color}14`,e.fill())}},Bu=class{constructor(e=14,t=`#ff5722`,n=`ATR`){this.period=e,this.pane=`sub`,this.paneHeight=80,this.name=n,this.color=t}compute(e){let t=[];if(e.length===0)return t;let n=[];for(let t=0;t<e.length;t++)if(t===0)n.push(e[t].high-e[t].low);else{let r=e[t-1].close;n.push(Math.max(e[t].high-e[t].low,Math.abs(e[t].high-r),Math.abs(e[t].low-r)))}if(e.length<this.period)return e.map((e,t)=>({index:t,value:null}));let r=0;for(let e=0;e<this.period;e++)r+=n[e];r/=this.period;for(let e=0;e<this.period-1;e++)t.push({index:e,value:null});t.push({index:this.period-1,value:r});for(let i=this.period;i<e.length;i++)r=(r*(this.period-1)+n[i])/this.period,t.push({index:i,value:r});return t}getValueRange(e){let t=1e-4;for(let n of e)n.value!=null&&(t=Math.max(t,n.value));return{min:0,max:t*1.2}}render(e,t,n,r,i,a){var o;let s=(o=e.canvas._chartWidth)==null?e.canvas.width:o,c=1e-4;for(let e of t)e.value!=null&&(c=Math.max(c,e.value));let l=a==null?{min:0,max:c*1.2}:a,u=[];for(let e of t)e.value!=null&&u.push({x:n.xToPixel(e.index,r,s),y:n.yToPixel(e.value,l,i)});if(u.length===0)return;let d=n.yToPixel(0,l,i);e.beginPath(),e.moveTo(u[0].x,d);for(let t of u)e.lineTo(t.x,t.y);e.lineTo(u[u.length-1].x,d),e.closePath(),e.fillStyle=this.color+`33`,e.fill(),e.beginPath(),e.strokeStyle=this.color,e.lineWidth=1.5,e.lineJoin=`round`;let f=!1;for(let a of t){if(a.value==null){f=!1;continue}let t=n.xToPixel(a.index,r,s),o=n.yToPixel(a.value,l,i);f?e.lineTo(t,o):(e.moveTo(t,o),f=!0)}e.stroke()}},Vu=class{constructor(e=14,t=`#e8b84b`,n=`RSI`,r=`close`){this.period=e,this.source=r,this.pane=`sub`,this.paneHeight=80,this.name=n,this.color=t}compute(e){let t=[];if(e.length<this.period+1)return e.map((e,t)=>({index:t,value:null}));let n=0,r=0;for(let t=1;t<=this.period;t++){let i=Du(e[t],this.source)-Du(e[t-1],this.source);i>0?n+=i:r+=Math.abs(i)}n/=this.period,r/=this.period;for(let e=0;e<this.period;e++)t.push({index:e,value:null});let i=r===0?1/0:n/r;t.push({index:this.period,value:r===0?100:100-100/(1+i)});for(let i=this.period+1;i<e.length;i++){let a=Du(e[i],this.source)-Du(e[i-1],this.source),o=a>0?a:0,s=a<0?Math.abs(a):0;n=(n*(this.period-1)+o)/this.period,r=(r*(this.period-1)+s)/this.period;let c=r===0?1/0:n/r;t.push({index:i,value:r===0?100:100-100/(1+c)})}return t}getValueRange(e){return{min:0,max:100}}render(e,t,n,r,i,a){var o;let s=(o=e.canvas._chartWidth)==null?e.canvas.width:o,c=a==null?{min:0,max:100}:a,l=n.yToPixel(70,c,i),u=n.yToPixel(30,c,i);e.fillStyle=`rgba(239,83,80,0.06)`,e.fillRect(0,0,s,l),e.fillStyle=`rgba(38,166,154,0.06)`,e.fillRect(0,u,s,i-u),e.save(),e.setLineDash([4,4]),e.strokeStyle=`rgba(150,150,150,0.35)`,e.lineWidth=1;for(let t of[70,50,30]){let r=n.yToPixel(t,c,i);e.beginPath(),e.moveTo(0,r),e.lineTo(s,r),e.stroke()}e.setLineDash([]),e.restore(),e.beginPath(),e.strokeStyle=this.color,e.lineWidth=1.5,e.lineJoin=`round`;let d=!1;for(let a of t){if(a.value===null){d=!1;continue}let t=n.xToPixel(a.index,r,s),o=n.yToPixel(a.value,c,i);d?e.lineTo(t,o):(e.moveTo(t,o),d=!0)}e.stroke()}},Hu=class{constructor(e=14,t=3,n=`#e040fb`){this.kPeriod=e,this.dPeriod=t,this.name=`Stoch`,this.pane=`sub`,this.paneHeight=80,this.color=n}compute(e){let t=[],n=[];for(let r=0;r<e.length;r++){if(r<this.kPeriod-1){n.push(null),t.push({index:r,value:null,upper:null});continue}let i=1/0,a=-1/0;for(let t=r-this.kPeriod+1;t<=r;t++)e[t].low<i&&(i=e[t].low),e[t].high>a&&(a=e[t].high);let o=a-i,s=o===0?50:(e[r].close-i)/o*100;n.push(s),t.push({index:r,value:s,upper:null})}for(let r=0;r<e.length;r++){if(n[r]===null)continue;let e=0,i=0;for(let t=r;t>=0&&e<this.dPeriod&&n[t]!==null;t--)i+=n[t],e++;e===this.dPeriod&&(t[r].upper=i/this.dPeriod)}return t}getValueRange(e){return{min:0,max:100}}render(e,t,n,r,i,a){var o;let s=(o=e.canvas._chartWidth)==null?e.canvas.width:o,c=a==null?{min:0,max:100}:a,l=n.yToPixel(80,c,i),u=n.yToPixel(20,c,i);e.fillStyle=`rgba(239,83,80,0.06)`,e.fillRect(0,0,s,l),e.fillStyle=`rgba(38,166,154,0.06)`,e.fillRect(0,u,s,i-u),e.save(),e.setLineDash([4,4]),e.strokeStyle=`rgba(150,150,150,0.35)`,e.lineWidth=1;for(let t of[80,50,20]){let r=n.yToPixel(t,c,i);e.beginPath(),e.moveTo(0,r),e.lineTo(s,r),e.stroke()}e.setLineDash([]),e.restore(),e.beginPath(),e.strokeStyle=this.color,e.lineWidth=1.5,e.lineJoin=`round`;let d=!1;for(let a of t){if(a.value===null){d=!1;continue}let t=n.xToPixel(a.index,r,s),o=n.yToPixel(a.value,c,i);d?e.lineTo(t,o):(e.moveTo(t,o),d=!0)}e.stroke(),e.beginPath(),e.strokeStyle=`#ff9800`,e.lineWidth=1,e.lineJoin=`round`,d=!1;for(let a of t){if(a.upper==null){d=!1;continue}let t=n.xToPixel(a.index,r,s),o=n.yToPixel(a.upper,c,i);d?e.lineTo(t,o):(e.moveTo(t,o),d=!0)}e.stroke()}};function Uu(e,t){let n=[];for(let r=0;r<e.length;r++){if(r<t-1){n.push(null);continue}let i=0,a=!0;for(let n=r-t+1;n<=r;n++){if(e[n]===null){a=!1;break}i+=e[n]}n.push(a?i/t:null)}return n}var Wu=class{constructor(e=14,t=14,n=3,r=3,i=`#00e5ff`){this.rsiPeriod=e,this.stochPeriod=t,this.kPeriod=n,this.dPeriod=r,this.name=`StochRSI`,this.pane=`sub`,this.paneHeight=80,this.color=i}compute(e){let t=[];if(e.length<this.rsiPeriod+1)return e.map((e,t)=>({index:t,value:null,upper:null}));let n=0,r=0;for(let t=1;t<=this.rsiPeriod;t++){let i=e[t].close-e[t-1].close;i>0?n+=i:r+=Math.abs(i)}n/=this.rsiPeriod,r/=this.rsiPeriod;for(let e=0;e<this.rsiPeriod;e++)t.push(null);let i=r===0?1/0:n/r;t.push(r===0?100:100-100/(1+i));for(let i=this.rsiPeriod+1;i<e.length;i++){let a=e[i].close-e[i-1].close,o=a>0?a:0,s=a<0?Math.abs(a):0;n=(n*(this.rsiPeriod-1)+o)/this.rsiPeriod,r=(r*(this.rsiPeriod-1)+s)/this.rsiPeriod;let c=r===0?1/0:n/r;t.push(r===0?100:100-100/(1+c))}let a=[];for(let n=0;n<e.length;n++){if(t[n]===null){a.push(null);continue}if(n<this.rsiPeriod+this.stochPeriod-1){a.push(null);continue}let e=1/0,r=-1/0,i=!0;for(let a=n-this.stochPeriod+1;a<=n;a++){if(t[a]===null){i=!1;break}let n=t[a];n<e&&(e=n),n>r&&(r=n)}if(!i){a.push(null);continue}let o=r-e,s=o===0?50:(t[n]-e)/o*100;a.push(s)}let o=Uu(a,this.kPeriod),s=Uu(o,this.dPeriod);return e.map((e,t)=>{var n,r;return{index:t,value:(n=o[t])==null?null:n,upper:(r=s[t])==null?null:r}})}getValueRange(e){return{min:0,max:100}}render(e,t,n,r,i,a){var o;let s=(o=e.canvas._chartWidth)==null?e.canvas.width:o,c=a==null?{min:0,max:100}:a,l=n.yToPixel(80,c,i),u=n.yToPixel(20,c,i);e.fillStyle=`rgba(239,83,80,0.06)`,e.fillRect(0,0,s,l),e.fillStyle=`rgba(38,166,154,0.06)`,e.fillRect(0,u,s,i-u),e.save(),e.setLineDash([4,4]),e.strokeStyle=`rgba(150,150,150,0.35)`,e.lineWidth=1;for(let t of[80,50,20]){let r=n.yToPixel(t,c,i);e.beginPath(),e.moveTo(0,r),e.lineTo(s,r),e.stroke()}e.setLineDash([]),e.restore(),e.beginPath(),e.strokeStyle=this.color,e.lineWidth=1.5,e.lineJoin=`round`;let d=!1;for(let a of t){if(a.value===null){d=!1;continue}let t=n.xToPixel(a.index,r,s),o=n.yToPixel(a.value,c,i);d?e.lineTo(t,o):(e.moveTo(t,o),d=!0)}e.stroke(),e.beginPath(),e.strokeStyle=`#ff9800`,e.lineWidth=1,e.lineJoin=`round`,d=!1;for(let a of t){if(a.upper==null){d=!1;continue}let t=n.xToPixel(a.index,r,s),o=n.yToPixel(a.upper,c,i);d?e.lineTo(t,o):(e.moveTo(t,o),d=!0)}e.stroke()}};function Gu(e,t){let n=2/(t+1),r=[],i=null;for(let a=0;a<e.length;a++){if(a<t-1){r.push(null);continue}if(i===null){let n=0;for(let r=0;r<t;r++)n+=e[a-r];i=n/t}else i=e[a]*n+i*(1-n);r.push(i)}return r}var Ku=class{constructor(e=12,t=26,n=9,r=`#2196f3`,i=`MACD`,a=`close`){this.fast=e,this.slow=t,this.signal=n,this.source=a,this.pane=`sub`,this.paneHeight=80,this.name=i,this.color=r}compute(e){let t=e.map(e=>Du(e,this.source)),n=Gu(t,this.fast),r=Gu(t,this.slow),i=t.map((e,t)=>n[t]===null||r[t]===null?null:n[t]-r[t]),a=Gu(i.map(e=>e==null?0:e),this.signal);return e.map((e,t)=>{let n=i[t];if(n===null)return{index:t,value:null,upper:null,lower:null,histogram:null};let r=t>=this.slow-1+this.signal-1?a[t]:null;return{index:t,value:n,upper:r,lower:n!==null&&r!==null?n-r:null}})}getValueRange(e){let t=1e-4;for(let n of e)n.value!=null&&(t=Math.max(t,Math.abs(n.value))),n.upper!=null&&(t=Math.max(t,Math.abs(n.upper))),n.lower!=null&&(t=Math.max(t,Math.abs(n.lower)));return{min:-t*1.3,max:t*1.3}}render(e,t,n,r,i,a){var o;let s=(o=e.canvas._chartWidth)==null?e.canvas.width:o,c=1e-4;for(let e of t)e.value!=null&&(c=Math.max(c,Math.abs(e.value))),e.upper!=null&&(c=Math.max(c,Math.abs(e.upper))),e.lower!=null&&(c=Math.max(c,Math.abs(e.lower)));let l=a==null?{min:-c*1.3,max:c*1.3}:a,u=n.yToPixel(0,l,i);e.strokeStyle=`rgba(150,150,150,0.3)`,e.lineWidth=1,e.beginPath(),e.moveTo(0,u),e.lineTo(s,u),e.stroke();let d=Math.max(n.candleBodyWidth(r,s),1);for(let a of t){if(a.lower==null)continue;let t=n.xToPixel(a.index,r,s),o=n.yToPixel(a.lower,l,i),c=Math.abs(o-u),f=Math.min(o,u);e.fillStyle=a.lower>=0?`rgba(38,166,154,0.55)`:`rgba(239,83,80,0.55)`,e.fillRect(t-d/2,f,d,c)}e.beginPath(),e.strokeStyle=this.color,e.lineWidth=1.5,e.lineJoin=`round`;let f=!1;for(let a of t){if(a.value==null){f=!1;continue}let t=n.xToPixel(a.index,r,s),o=n.yToPixel(a.value,l,i);f?e.lineTo(t,o):(e.moveTo(t,o),f=!0)}e.stroke(),e.beginPath(),e.strokeStyle=`#ff6b35`,e.lineWidth=1,e.lineJoin=`round`,f=!1;for(let a of t){if(a.upper==null){f=!1;continue}let t=n.xToPixel(a.index,r,s),o=n.yToPixel(a.upper,l,i);f?e.lineTo(t,o):(e.moveTo(t,o),f=!0)}e.stroke()}},qu=class{constructor(e=20,t=`#4db6ac`){this.period=e,this.name=`CCI`,this.pane=`sub`,this.paneHeight=80,this.color=t}compute(e){return e.map((t,n)=>{if(n<this.period-1)return{index:n,value:null};let r=e.slice(n-this.period+1,n+1).map(e=>(e.high+e.low+e.close)/3),i=r[r.length-1],a=r.reduce((e,t)=>e+t,0)/this.period,o=r.reduce((e,t)=>e+Math.abs(t-a),0)/this.period;return o===0?{index:n,value:0}:{index:n,value:(i-a)/(.015*o)}})}getValueRange(e){let t=1e-4;for(let n of e)n.value!=null&&(t=Math.max(t,Math.abs(n.value)));return{min:-t*1.3,max:t*1.3}}render(e,t,n,r,i,a){var o;let s=(o=e.canvas._chartWidth)==null?e.canvas.width:o,c=1e-4;for(let e of t)e.value!=null&&(c=Math.max(c,Math.abs(e.value)));let l=a==null?{min:-c*1.3,max:c*1.3}:a,u=n.yToPixel(100,l,i),d=n.yToPixel(-100,l,i);e.fillStyle=`rgba(239,83,80,0.10)`,e.fillRect(0,0,s,u),e.fillStyle=`rgba(38,166,154,0.10)`,e.fillRect(0,d,s,i-d),e.save(),e.setLineDash([4,4]),e.strokeStyle=`rgba(150,150,150,0.35)`,e.lineWidth=1;for(let t of[100,0,-100]){let r=n.yToPixel(t,l,i);e.beginPath(),e.moveTo(0,r),e.lineTo(s,r),e.stroke()}e.setLineDash([]),e.restore(),e.beginPath(),e.strokeStyle=this.color,e.lineWidth=1.5,e.lineJoin=`round`;let f=!1;for(let a of t){if(a.value===null){f=!1;continue}let t=n.xToPixel(a.index,r,s),o=n.yToPixel(a.value,l,i);f?e.lineTo(t,o):(e.moveTo(t,o),f=!0)}e.stroke()}},Ju=class{constructor(e=14,t=`#ff7043`){this.period=e,this.name=`%R`,this.pane=`sub`,this.paneHeight=80,this.color=t}compute(e){return e.map((t,n)=>{if(n<this.period-1)return{index:n,value:null};let r=-1/0,i=1/0;for(let t=n-this.period+1;t<=n;t++)e[t].high>r&&(r=e[t].high),e[t].low<i&&(i=e[t].low);let a=r-i;return{index:n,value:a===0?-50:(r-e[n].close)/a*-100}})}getValueRange(e){return{min:-100,max:0}}render(e,t,n,r,i,a){var o;let s=(o=e.canvas._chartWidth)==null?e.canvas.width:o,c=a==null?{min:-100,max:0}:a,l=n.yToPixel(-20,c,i),u=n.yToPixel(-80,c,i);e.fillStyle=`rgba(239,83,80,0.06)`,e.fillRect(0,0,s,l),e.fillStyle=`rgba(38,166,154,0.06)`,e.fillRect(0,u,s,i-u),e.save(),e.setLineDash([4,4]),e.strokeStyle=`rgba(150,150,150,0.35)`,e.lineWidth=1;for(let t of[-20,-50,-80]){let r=n.yToPixel(t,c,i);e.beginPath(),e.moveTo(0,r),e.lineTo(s,r),e.stroke()}e.setLineDash([]),e.restore(),e.beginPath(),e.strokeStyle=this.color,e.lineWidth=1.5,e.lineJoin=`round`;let d=!1;for(let a of t){if(a.value===null){d=!1;continue}let t=n.xToPixel(a.index,r,s),o=n.yToPixel(a.value,c,i);d?e.lineTo(t,o):(e.moveTo(t,o),d=!0)}e.stroke()}},Yu=class{constructor(e=12,t=`#80cbc4`,n=`close`){this.period=e,this.source=n,this.pane=`sub`,this.paneHeight=80,this.name=`ROC`,this.color=t}compute(e){return e.map((t,n)=>{if(n<this.period)return{index:n,value:null};let r=Du(e[n-this.period],this.source);return r===0?{index:n,value:null}:{index:n,value:(Du(e[n],this.source)-r)/r*100}})}getValueRange(e){let t=1e-4;for(let n of e)n.value!=null&&(t=Math.max(t,Math.abs(n.value)));return{min:-t*1.3,max:t*1.3}}render(e,t,n,r,i,a){var o;let s=(o=e.canvas._chartWidth)==null?e.canvas.width:o,c=1e-4;for(let e of t)e.value!=null&&(c=Math.max(c,Math.abs(e.value)));let l=a==null?{min:-c*1.3,max:c*1.3}:a,u=n.yToPixel(0,l,i),d=[];for(let e of t)e.value!=null&&d.push({x:n.xToPixel(e.index,r,s),y:n.yToPixel(e.value,l,i),value:e.value});if(d.length>=2){e.beginPath(),e.moveTo(d[0].x,u);for(let t of d)e.lineTo(t.x,Math.min(t.y,u));e.lineTo(d[d.length-1].x,u),e.closePath(),e.fillStyle=`rgba(38,166,154,0.05)`,e.fill(),e.beginPath(),e.moveTo(d[0].x,u);for(let t of d)e.lineTo(t.x,Math.max(t.y,u));e.lineTo(d[d.length-1].x,u),e.closePath(),e.fillStyle=`rgba(239,83,80,0.05)`,e.fill()}e.save(),e.setLineDash([4,4]),e.strokeStyle=`rgba(150,150,150,0.35)`,e.lineWidth=1,e.beginPath(),e.moveTo(0,u),e.lineTo(s,u),e.stroke(),e.setLineDash([]),e.restore(),e.beginPath(),e.strokeStyle=this.color,e.lineWidth=1.5,e.lineJoin=`round`;let f=!1;for(let a of t){if(a.value===null){f=!1;continue}let t=n.xToPixel(a.index,r,s),o=n.yToPixel(a.value,l,i);f?e.lineTo(t,o):(e.moveTo(t,o),f=!0)}e.stroke()}},Xu=class{constructor(e=`#aed581`){this.name=`OBV`,this.pane=`sub`,this.paneHeight=80,this.color=e}compute(e){let t=[],n=0;for(let o=0;o<e.length;o++){if(o===0){var r;n=(r=e[o].volume)==null?0:r}else if(e[o].close>e[o-1].close){var i;n+=(i=e[o].volume)==null?0:i}else if(e[o].close<e[o-1].close){var a;n-=(a=e[o].volume)==null?0:a}t.push({index:o,value:n})}return t}getValueRange(e){let t=1/0,n=-1/0;for(let r of e)r.value!=null&&(r.value<t&&(t=r.value),r.value>n&&(n=r.value));if(t===1/0)return{min:0,max:1};let r=(n-t)*.1||1;return{min:t-r,max:n+r}}render(e,t,n,r,i,a){var o;let s=(o=e.canvas._chartWidth)==null?e.canvas.width:o,c=1/0,l=-1/0;for(let e of t)e.value!=null&&(e.value<c&&(c=e.value),e.value>l&&(l=e.value));if(c===1/0)return;let u=(l-c)*.1||1,d=a==null?{min:c-u,max:l+u}:a,f=n.yToPixel(0,d,i),p=[];for(let e of t)e.value!=null&&p.push({x:n.xToPixel(e.index,r,s),y:n.yToPixel(e.value,d,i),value:e.value});if(p.length===0)return;if(e.save(),e.setLineDash([4,4]),e.strokeStyle=`rgba(150,150,150,0.35)`,e.lineWidth=1,e.beginPath(),e.moveTo(0,f),e.lineTo(s,f),e.stroke(),e.setLineDash([]),e.restore(),p.length>=2){e.beginPath(),e.moveTo(p[0].x,f);for(let t of p)e.lineTo(t.x,t.y);e.lineTo(p[p.length-1].x,f),e.closePath(),e.fillStyle=p[p.length-1].value>=0?`rgba(38,166,154,0.12)`:`rgba(239,83,80,0.12)`,e.fill()}e.beginPath(),e.strokeStyle=this.color,e.lineWidth=1.5,e.lineJoin=`round`;let m=!1;for(let a of t){if(a.value==null){m=!1;continue}let t=n.xToPixel(a.index,r,s),o=n.yToPixel(a.value,d,i);m?e.lineTo(t,o):(e.moveTo(t,o),m=!0)}e.stroke()}},Zu=class{constructor(e=`#9c27b0`){this.name=`VWAP`,this.color=e}compute(e){let t=[],n=0,r=0;for(let o=0;o<e.length;o++){var i,a;let s=e[o],c=(s.high+s.low+s.close)/3;n+=c*((i=s.volume)==null?0:i),r+=(a=s.volume)==null?0:a,t.push({index:o,value:r===0?null:n/r})}return t}render(e,t,n,r,i){var a;let o=e.canvas,s=o._priceRange;if(!s)return;let c=(a=o._chartWidth)==null?e.canvas.width:a;e.beginPath(),e.strokeStyle=this.color,e.lineWidth=1.5,e.lineJoin=`round`,e.setLineDash([4,3]);let l=!1;for(let a of t){if(a.value===null){l=!1;continue}let t=n.xToPixel(a.index,r,c),o=n.yToPixel(a.value,s,i);l?e.lineTo(t,o):(e.moveTo(t,o),l=!0)}e.stroke(),e.setLineDash([])}},Qu=class{constructor(e=`#ce93d8`){this.name=`A/D`,this.pane=`sub`,this.paneHeight=80,this.color=e}compute(e){let t=[],n=0;for(let r=0;r<e.length;r++){let{high:i,low:a,close:o,volume:s}=e[r],c=i-a,l=c===0?0:(o-a-(i-o))/c;n+=l*(s==null?0:s),t.push({index:r,value:n})}return t}getValueRange(e){let t=1/0,n=-1/0;for(let r of e)r.value!=null&&(r.value<t&&(t=r.value),r.value>n&&(n=r.value));if(t===1/0)return{min:0,max:1};let r=(n-t)*.1||1;return{min:t-r,max:n+r}}render(e,t,n,r,i,a){var o;let s=(o=e.canvas._chartWidth)==null?e.canvas.width:o,c=1/0,l=-1/0;for(let e of t)e.value!=null&&(e.value<c&&(c=e.value),e.value>l&&(l=e.value));if(c===1/0)return;let u=(l-c)*.1||1,d=a==null?{min:c-u,max:l+u}:a,f=[];for(let e of t)e.value!=null&&f.push({x:n.xToPixel(e.index,r,s),y:n.yToPixel(e.value,d,i)});if(f.length===0)return;if(f.length>=2){let t=i;e.beginPath(),e.moveTo(f[0].x,t);for(let t of f)e.lineTo(t.x,t.y);e.lineTo(f[f.length-1].x,t),e.closePath(),e.fillStyle=this.color+`20`,e.fill()}e.beginPath(),e.strokeStyle=this.color,e.lineWidth=1.5,e.lineJoin=`round`;let p=!1;for(let a of t){if(a.value==null){p=!1;continue}let t=n.xToPixel(a.index,r,s),o=n.yToPixel(a.value,d,i);p?e.lineTo(t,o):(e.moveTo(t,o),p=!0)}e.stroke()}},$u=class{constructor(e=14,t=`#ffab40`){this.period=e,this.pane=`sub`,this.paneHeight=80,this.name=`MFI`,this.color=t}compute(e){let t=[],n=e.map(e=>(e.high+e.low+e.close)/3),r=e.map((e,t)=>{var r;return n[t]*((r=e.volume)==null?0:r)});for(let i=0;i<e.length;i++){if(i<this.period){t.push({index:i,value:null});continue}let e=0,a=0;for(let t=i-this.period+1;t<=i;t++)n[t]>n[t-1]?e+=r[t]:n[t]<n[t-1]&&(a+=r[t]);if(a===0)t.push({index:i,value:100});else{let n=e/a;t.push({index:i,value:100-100/(1+n)})}}return t}getValueRange(e){return{min:0,max:100}}render(e,t,n,r,i,a){var o;let s=(o=e.canvas._chartWidth)==null?e.canvas.width:o,c=a==null?{min:0,max:100}:a,l=n.yToPixel(80,c,i),u=n.yToPixel(20,c,i);e.fillStyle=`rgba(239,83,80,0.06)`,e.fillRect(0,0,s,l),e.fillStyle=`rgba(38,166,154,0.06)`,e.fillRect(0,u,s,i-u),e.save(),e.setLineDash([4,4]),e.strokeStyle=`rgba(150,150,150,0.35)`,e.lineWidth=1;for(let t of[80,50,20]){let r=n.yToPixel(t,c,i);e.beginPath(),e.moveTo(0,r),e.lineTo(s,r),e.stroke()}e.setLineDash([]),e.restore(),e.beginPath(),e.strokeStyle=this.color,e.lineWidth=1.5,e.lineJoin=`round`;let d=!1;for(let a of t){if(a.value===null){d=!1;continue}let t=n.xToPixel(a.index,r,s),o=n.yToPixel(a.value,c,i);d?e.lineTo(t,o):(e.moveTo(t,o),d=!0)}e.stroke()}},ed=class{constructor(e=20,t=`#80deea`){this.period=e,this.pane=`sub`,this.paneHeight=80,this.name=`CMF`,this.color=t}compute(e){let t=e.map(e=>{var t;let n=e.high-e.low;return(n===0?0:(e.close-e.low-(e.high-e.close))/n)*((t=e.volume)==null?0:t)});return e.map((n,r)=>{if(r<this.period-1)return{index:r,value:null};let i=0,a=0;for(let n=r-this.period+1;n<=r;n++){var o;i+=t[n],a+=(o=e[n].volume)==null?0:o}return{index:r,value:a===0?0:i/a}})}getValueRange(e){return{min:-1,max:1}}render(e,t,n,r,i,a){var o;let s=(o=e.canvas._chartWidth)==null?e.canvas.width:o,c=a==null?{min:-1,max:1}:a,l=n.yToPixel(0,c,i),u=n.yToPixel(.2,c,i),d=n.yToPixel(-.2,c,i);e.fillStyle=`rgba(38,166,154,0.08)`,e.fillRect(0,0,s,u),e.fillStyle=`rgba(239,83,80,0.08)`,e.fillRect(0,d,s,i-d),e.save(),e.setLineDash([4,4]),e.strokeStyle=`rgba(150,150,150,0.35)`,e.lineWidth=1;for(let t of[.2,0,-.2]){let r=n.yToPixel(t,c,i);e.beginPath(),e.moveTo(0,r),e.lineTo(s,r),e.stroke()}e.setLineDash([]),e.restore();let f=Math.max(1,s/Math.max(t.length,1)*.6);for(let a of t){if(a.value==null)continue;let t=n.xToPixel(a.index,r,s),o=n.yToPixel(a.value,c,i),u=Math.abs(o-l),d=Math.min(o,l);e.fillStyle=a.value>=0?`rgba(38,166,154,0.45)`:`rgba(239,83,80,0.45)`,e.fillRect(t-f/2,d,f,u)}e.beginPath(),e.strokeStyle=this.color,e.lineWidth=1.5,e.lineJoin=`round`;let p=!1;for(let a of t){if(a.value===null){p=!1;continue}let t=n.xToPixel(a.index,r,s),o=n.yToPixel(a.value,c,i);p?e.lineTo(t,o):(e.moveTo(t,o),p=!0)}e.stroke()}},td=class{constructor(e=`#ffd54f`){this.name=`Pivot`,this.color=e}compute(e){return e.map((t,n)=>{if(n===0)return{index:n,value:null,upper:null,lower:null,signal:null,histogram:null};let r=e[n-1],i=(r.high+r.low+r.close)/3;return{index:n,value:i,upper:2*i-r.low,lower:2*i-r.high,signal:i+(r.high-r.low),histogram:i-(r.high-r.low)}})}render(e,t,n,r,i){var a;let o=e.canvas,s=o._priceRange;if(!s)return;let c=(a=o._chartWidth)==null?e.canvas.width:a,l=null;for(let e=t.length-1;e>=0;e--)if(t[e].value!==null){l=t[e];break}if(l===null)return;let u=[{value:l.signal,label:`R2`,color:`#b71c1c`},{value:l.upper,label:`R1`,color:`#ef5350`},{value:l.value,label:`PP`,color:`#ffd54f`},{value:l.lower,label:`S1`,color:`#26a69a`},{value:l.histogram,label:`S2`,color:`#1b5e20`}];e.lineWidth=1,e.font=`10px sans-serif`,e.textBaseline=`middle`;for(let t of u){if(t.value==null)continue;let r=n.yToPixel(t.value,s,i);e.beginPath(),e.setLineDash([6,4]),e.strokeStyle=t.color,e.moveTo(0,r),e.lineTo(c,r),e.stroke(),e.setLineDash([]),e.fillStyle=t.color,e.fillText(t.label,c-28,r-6)}}},nd=[0,.236,.382,.5,.618,.786,1],rd=[`0%`,`23.6%`,`38.2%`,`50%`,`61.8%`,`78.6%`,`100%`],id=[`#90a4ae`,`#4d96ff`,`#6bcb77`,`#ffd93d`,`#ff9800`,`#ef5350`,`#90a4ae`],ad=class{constructor(e=50,t=`#e1bee7`){this.lookback=e,this.name=`Fib`,this.color=t}compute(e){return e.map((t,n)=>{let r=Math.max(0,n-this.lookback+1),i=-1/0,a=1/0;for(let t=r;t<=n;t++)e[t].high>i&&(i=e[t].high),e[t].low<a&&(a=e[t].low);let o=i-a;return{index:n,value:i,upper:a+.618*o,lower:a+.382*o,signal:a+.5*o,histogram:a}})}render(e,t,n,r,i){var a;let o=e.canvas,s=o._priceRange;if(!s)return;let c=(a=o._chartWidth)==null?e.canvas.width:a,l=null;for(let e=t.length-1;e>=0;e--)if(t[e].value!==null){l=t[e];break}if(l===null)return;let u=l.value,d=l.histogram;if(u==null||d==null)return;let f=u-d,p=nd.map(e=>d+e*f);e.lineWidth=1,e.font=`10px sans-serif`,e.textBaseline=`middle`;for(let t=0;t<nd.length;t++){let r=p[t],a=n.yToPixel(r,s,i),o=id[t];e.beginPath(),e.setLineDash([6,4]),e.strokeStyle=o,e.moveTo(0,a),e.lineTo(c,a),e.stroke(),e.setLineDash([]),e.fillStyle=o,e.fillText(rd[t],c-38,a-6)}}},od=class{constructor(e=10,t=3,n=`#26a69a`){this.atrPeriod=e,this.multiplier=t,this.name=`Supertrend`,this.color=n}compute(e){let t=e.length,n=[];if(t===0)return n;let r=Array(t).fill(0);for(let n=0;n<t;n++){let t=e[n].high,i=e[n].low,a=n>0?e[n-1].close:e[n].close;r[n]=Math.max(t-i,Math.abs(t-a),Math.abs(i-a))}let i=Array(t).fill(0);if(t<this.atrPeriod){for(let e=0;e<t;e++)n.push({index:e,value:null,upper:null});return n}let a=0;for(let e=0;e<this.atrPeriod;e++)a+=r[e];i[this.atrPeriod-1]=a/this.atrPeriod;for(let e=this.atrPeriod;e<t;e++)i[e]=(i[e-1]*(this.atrPeriod-1)+r[e])/this.atrPeriod;let o=Array(t).fill(0),s=Array(t).fill(0),c=Array(t).fill(1);for(let r=0;r<t;r++){if(r<this.atrPeriod-1){n.push({index:r,value:null,upper:null});continue}let t=(e[r].high+e[r].low)/2,a=t+this.multiplier*i[r],l=t-this.multiplier*i[r];if(r===this.atrPeriod-1){o[r]=a,s[r]=l,c[r]=1,n.push({index:r,value:s[r],upper:1});continue}let u=e[r-1].close;o[r]=a<o[r-1]||u>o[r-1]?a:o[r-1],s[r]=l>s[r-1]||u<s[r-1]?l:s[r-1],c[r-1]===-1?c[r]=e[r].close>o[r]?1:-1:c[r]=e[r].close<s[r]?-1:1;let d=c[r]===1?s[r]:o[r];n.push({index:r,value:d,upper:c[r]})}return n}render(e,t,n,r,i){var a;let o=e.canvas,s=o._priceRange;if(!s)return;let c=(a=o._chartWidth)==null?e.canvas.width:a;e.lineWidth=2,e.lineJoin=`round`;let l=null;e.beginPath(),e.strokeStyle=`#26a69a`;let u=!1;for(let a of t){if(a.value==null||a.upper==null){u=!1;continue}if(!(a.upper>=0)){u=!1;continue}l!==1&&(u=!1);let t=n.xToPixel(a.index,r,c),o=n.yToPixel(a.value,s,i);u?e.lineTo(t,o):(e.moveTo(t,o),u=!0),l=1}e.stroke(),e.beginPath(),e.strokeStyle=`#ef5350`;let d=!1;l=null;for(let a of t){if(a.value==null||a.upper==null){d=!1;continue}if(!(a.upper<0)){d=!1;continue}l!==-1&&(d=!1);let t=n.xToPixel(a.index,r,c),o=n.yToPixel(a.value,s,i);d?e.lineTo(t,o):(e.moveTo(t,o),d=!0),l=-1}e.stroke()}},sd=class{constructor(e=.02,t=.2,n=`#ff6b9d`){this.step=e,this.maxAF=t,this.name=`PSAR`,this.color=n}compute(e){let t=e.length,n=[];if(t<2){for(let e=0;e<t;e++)n.push({index:e,value:null,upper:null});return n}let r=!0,i=this.step,a=e[0].high,o=e[0].low;n.push({index:0,value:null,upper:null});for(let s=1;s<t;s++){let t=o+i*(a-o);if(r){let n=e[s-1].low,o=s>=2?e[s-2].low:e[s-1].low;t=Math.min(t,n,o),t>e[s].low?(r=!1,t=a,a=e[s].low,i=this.step):e[s].high>a&&(a=e[s].high,i=Math.min(i+this.step,this.maxAF))}else{let n=e[s-1].high,o=s>=2?e[s-2].high:e[s-1].high;t=Math.max(t,n,o),t<e[s].high?(r=!0,t=a,a=e[s].high,i=this.step):e[s].low<a&&(a=e[s].low,i=Math.min(i+this.step,this.maxAF))}o=t,n.push({index:s,value:o,upper:r?1:-1})}return n}render(e,t,n,r,i){var a;let o=e.canvas,s=o._priceRange;if(!s)return;let c=(a=o._chartWidth)==null?e.canvas.width:a;for(let a of t){if(a.value==null||a.upper==null)continue;let t=n.xToPixel(a.index,r,c),o=n.yToPixel(a.value,s,i);e.beginPath(),e.arc(t,o,2,0,Math.PI*2),e.fillStyle=a.upper>=0?`#26a69a`:`#ef5350`,e.fill()}}};function cd(e,t,n){if(t<n-1)return null;let r=-1/0,i=1/0;for(let a=t-n+1;a<=t;a++)e[a].high>r&&(r=e[a].high),e[a].low<i&&(i=e[a].low);return{high:r,low:i}}var ld=class{constructor(e=9,t=26,n=52,r=`#b0bec5`){this.tenkanPeriod=e,this.kijunPeriod=t,this.senkouBPeriod=n,this.name=`Ichimoku`,this.color=r}compute(e){return e.map((t,n)=>{let r=cd(e,n,this.tenkanPeriod),i=r===null?null:(r.high+r.low)/2,a=cd(e,n,this.kijunPeriod),o=a===null?null:(a.high+a.low)/2,s=i!==null&&o!==null?(i+o)/2:null,c=cd(e,n,this.senkouBPeriod);return{index:n,value:i,upper:o,lower:s,signal:c===null?null:(c.high+c.low)/2,histogram:t.close}})}render(e,t,n,r,i){var a;let o=e.canvas,s=o._priceRange;if(!s)return;let c=(a=o._chartWidth)==null?e.canvas.width:a;e.lineWidth=1,e.lineJoin=`round`;let l=(a,o,l=!1)=>{e.strokeStyle=o,l&&e.setLineDash([4,3]),e.beginPath();let u=!1;for(let o of t){let t=a(o);if(t==null){u=!1;continue}let l=n.xToPixel(o.index,r,c),d=n.yToPixel(t,s,i);u?e.lineTo(l,d):(e.moveTo(l,d),u=!0)}e.stroke(),l&&e.setLineDash([])},u=[],d=[];for(let e of t){if(e.lower==null||e.signal==null)continue;let t=n.xToPixel(e.index,r,c);u.push([t,n.yToPixel(e.lower,s,i)]),d.push([t,n.yToPixel(e.signal,s,i)])}for(let t=0;t+1<u.length;t++){let[n,r]=u[t],[i,a]=u[t+1],[,o]=d[t],[,s]=d[t+1],c=r<o;e.beginPath(),e.moveTo(n,r),e.lineTo(i,a),e.lineTo(i,s),e.lineTo(n,o),e.closePath(),e.fillStyle=c?`rgba(38, 166, 154, 0.15)`:`rgba(239, 83, 80, 0.15)`,e.fill()}l(e=>e.lower,`#26a69a`,!0),l(e=>e.signal,`#ef5350`,!0),l(e=>e.value,`#ef9a9a`),l(e=>e.upper,`#90caf9`),e.strokeStyle=`#b0bec5`,e.beginPath();let f=!1;for(let a of t){if(a.histogram==null){f=!1;continue}let t=a.index-this.kijunPeriod;if(t<0){f=!1;continue}let o=n.xToPixel(t,r,c),l=n.yToPixel(a.histogram,s,i);f?e.lineTo(o,l):(e.moveTo(o,l),f=!0)}e.stroke()}},ud=class{constructor(e=14,t=`#fff176`){this.period=e,this.pane=`sub`,this.paneHeight=80,this.name=`ADX`,this.color=t}compute(e){let t=e.length;if(t<this.period+1)return e.map((e,t)=>({index:t,value:null,upper:null,lower:null}));let n=Array(t).fill(0),r=Array(t).fill(0),i=Array(t).fill(0);n[0]=e[0].high-e[0].low,r[0]=0,i[0]=0;for(let a=1;a<t;a++){let t=e[a-1].close,o=e[a-1].high,s=e[a-1].low,c=e[a].high,l=e[a].low;n[a]=Math.max(c-l,Math.abs(c-t),Math.abs(l-t));let u=c-o,d=s-l;r[a]=u>d&&u>0?u:0,i[a]=d>u&&d>0?d:0}let a=0,o=0,s=0;for(let e=0;e<this.period;e++)a+=n[e],o+=r[e],s+=i[e];let c=[];for(let e=0;e<this.period;e++)c.push({index:e,value:null,upper:null,lower:null});let l=Array(t).fill(0),u=Array(t).fill(0),d=Array(t).fill(0),f=a===0?0:100*o/a,p=a===0?0:100*s/a,m=f+p===0?0:100*Math.abs(f-p)/(f+p);l[this.period-1]=f,u[this.period-1]=p,d[this.period-1]=m,c[this.period-1]={index:this.period-1,value:null,upper:f,lower:p};for(let e=this.period;e<t;e++){a=a-a/this.period+n[e],o=o-o/this.period+r[e],s=s-s/this.period+i[e];let t=a===0?0:100*o/a,f=a===0?0:100*s/a,p=t+f===0?0:100*Math.abs(t-f)/(t+f);l[e]=t,u[e]=f,d[e]=p,c.push({index:e,value:null,upper:t,lower:f})}let h=2*this.period-2;if(h>=t)return c;let g=0;for(let e=this.period-1;e<=h;e++)g+=d[e];g/=this.period,c[h].value=g;for(let e=h+1;e<t;e++)g=(g*(this.period-1)+d[e])/this.period,c[e].value=g;return c}getValueRange(e){return{min:0,max:100}}render(e,t,n,r,i,a){var o;let s=(o=e.canvas._chartWidth)==null?e.canvas.width:o,c=a==null?{min:0,max:100}:a;e.save(),e.setLineDash([4,4]),e.strokeStyle=`rgba(150,150,150,0.35)`,e.lineWidth=1;let l=n.yToPixel(25,c,i);e.beginPath(),e.moveTo(0,l),e.lineTo(s,l),e.stroke(),e.setLineDash([]),e.restore();let u=(a,o,l)=>{e.beginPath(),e.strokeStyle=o,e.lineWidth=l,e.lineJoin=`round`;let u=!1;for(let o of t){let t=a(o);if(t==null){u=!1;continue}let l=n.xToPixel(o.index,r,s),d=n.yToPixel(t,c,i);u?e.lineTo(l,d):(e.moveTo(l,d),u=!0)}e.stroke()};u(e=>e.upper,`#26a69a`,1),u(e=>e.lower,`#ef5350`,1),u(e=>e.value,this.color,1.5)}},dd=class{constructor(e=5,t=34,n=`#b0bec5`){this.fastPeriod=e,this.slowPeriod=t,this.name=`AO`,this.pane=`sub`,this.paneHeight=80,this.color=n}compute(e){let t=e.map(e=>(e.high+e.low)/2),n=(e,t,n)=>{if(t<n-1)return null;let r=0;for(let i=t-n+1;i<=t;i++)r+=e[i];return r/n};return e.map((e,r)=>{let i=n(t,r,this.fastPeriod),a=n(t,r,this.slowPeriod);return i===null||a===null?{index:r,value:null}:{index:r,value:i-a}})}getValueRange(e){let t=1e-4;for(let n of e)n.value!=null&&(t=Math.max(t,Math.abs(n.value)));return{min:-t*1.2,max:t*1.2}}render(e,t,n,r,i,a){var o;let s=(o=e.canvas._chartWidth)==null?e.canvas.width:o,c=1e-4;for(let e of t)e.value!=null&&(c=Math.max(c,Math.abs(e.value)));let l=a==null?{min:-c*1.2,max:c*1.2}:a,u=n.yToPixel(0,l,i);e.save(),e.setLineDash([4,4]),e.strokeStyle=`rgba(150,150,150,0.35)`,e.lineWidth=1,e.beginPath(),e.moveTo(0,u),e.lineTo(s,u),e.stroke(),e.setLineDash([]),e.restore();let d=Math.max(n.candleBodyWidth(r,s),1),f=null;for(let a of t){if(a.value==null){f=null;continue}let t=f===null?!0:a.value>=f,o=n.xToPixel(a.index,r,s),c=n.yToPixel(a.value,l,i),p=Math.abs(c-u),m=Math.min(c,u);e.fillStyle=t?`rgba(38,166,154,0.70)`:`rgba(239,83,80,0.70)`,e.fillRect(o-d/2,m,d,p),f=a.value}}},fd=class{constructor(e=`#90a4ae`,t=`#26a69a`,n=`#ef5350`){this.name=`HA`,this.color=e,this.upColor=t,this.downColor=n}compute(e){let t=[],n=0,r=0;for(let i=0;i<e.length;i++){let a=e[i],o=(a.open+a.high+a.low+a.close)/4,s;s=i===0?(a.open+a.close)/2:(n+r)/2;let c=Math.max(a.high,s,o),l=Math.min(a.low,s,o);n=s,r=o,t.push({index:i,value:o,upper:c,lower:l,signal:s})}return t}render(e,t,n,r,i){var a;let o=e.canvas,s=o._priceRange;if(!s)return;let c=(a=o._chartWidth)==null?e.canvas.width:a,l=n.candleBodyWidth(r,c),u=l/2;for(let a of t){if(a.value==null||a.upper==null||a.lower==null||a.signal==null)continue;let t=a.value,o=a.upper,d=a.lower,f=a.signal,p=t>=f?this.upColor:this.downColor,m=n.xToPixel(a.index,r,c),h=n.yToPixel(o,s,i),g=n.yToPixel(d,s,i),_=n.yToPixel(f,s,i),v=n.yToPixel(t,s,i),y=Math.min(_,v),b=Math.max(1,Math.max(_,v)-y);e.beginPath(),e.strokeStyle=p,e.lineWidth=1,e.moveTo(m,h),e.lineTo(m,g),e.stroke(),e.fillStyle=p,e.strokeStyle=p,e.lineWidth=1,e.fillRect(m-u,y,l,b),e.strokeRect(m-u,y,l,b)}}},pd=class{constructor(e=`#26a69a`,t=`#ef5350`){this.name=`VOL`,this.pane=`sub`,this.paneHeight=80,this.upColor=e,this.downColor=t,this.color=e}compute(e){return e.map((e,t)=>{var n;return{index:t,value:(n=e.volume)==null?0:n,signal:+(e.close>=e.open)}})}render(e,t,n,r,i){var a;let o=(a=e.canvas._chartWidth)==null?e.canvas.width:a,s=0;for(let e of t)e.value!=null&&e.value>s&&(s=e.value);if(s===0)return;let c={min:0,max:s*1.1},l=n.yToPixel(0,c,i),u=Math.max(n.candleBodyWidth(r,o),1);for(let a of t){if(a.value==null||a.value===0)continue;let t=n.xToPixel(a.index,r,o),s=n.yToPixel(a.value,c,i),d=Math.abs(l-s);e.fillStyle=a.signal===1?`${this.upColor}99`:`${this.downColor}99`,e.fillRect(t-u/2,s,u,d)}e.fillStyle=this.upColor,e.font=`10px 'Inter', system-ui, sans-serif`,e.fillText(this.name,4,11)}},md=class{constructor(e=14,t=`#ff9800`){this.period=e,this.name=`LinReg`,this.color=t}compute(e){let t=this.period,n=[],r=t*(t-1)/2,i=t*(t*(t-1)*(2*t-1)/6)-r*r;for(let a=0;a<e.length;a++){if(a<t-1){n.push({index:a,value:null});continue}let o=0,s=0;for(let n=0;n<t;n++){let r=e[a-(t-1-n)].close;o+=r,s+=n*r}let c=(t*s-r*o)/i,l=(o-c*r)/t+c*(t-1);n.push({index:a,value:l})}return n}render(e,t,n,r,i){var a;let o=e.canvas,s=o._priceRange;if(!s)return;let c=(a=o._chartWidth)==null?e.canvas.width:a;e.beginPath(),e.strokeStyle=this.color,e.lineWidth=1.5,e.lineJoin=`round`;let l=!1;for(let a of t){if(a.value===null){l=!1;continue}let t=n.xToPixel(a.index,r,c),o=n.yToPixel(a.value,s,i);l?e.lineTo(t,o):(e.moveTo(t,o),l=!0)}e.stroke()}},hd=[{name:`Moving Average`,short_name:`MA`,type:`Trend`,enabled:!0},{name:`Exponential Moving Average`,short_name:`EMA`,type:`Trend`,enabled:!0},{name:`Weighted Moving Average`,short_name:`WMA`,type:`Trend`,enabled:!0},{name:`Hull Moving Average`,short_name:`HMA`,type:`Trend`,enabled:!0},{name:`Moving Average Ribbon`,short_name:`MARibbon`,type:`Trend`,enabled:!0},{name:`Bollinger Bands`,short_name:`BB`,type:`Volatility`,enabled:!0},{name:`Keltner Channels`,short_name:`KC`,type:`Volatility`,enabled:!0},{name:`Donchian Channels`,short_name:`DC`,type:`Volatility`,enabled:!0},{name:`Average True Range`,short_name:`ATR`,type:`Volatility`,enabled:!0},{name:`Relative Strength Index`,short_name:`RSI`,type:`Momentum`,enabled:!0},{name:`Stochastic Oscillator`,short_name:`Stoch`,type:`Momentum`,enabled:!0},{name:`Stochastic RSI`,short_name:`StochRSI`,type:`Momentum`,enabled:!0},{name:`MACD`,short_name:`MACD`,type:`Momentum`,enabled:!0},{name:`Commodity Channel Index`,short_name:`CCI`,type:`Momentum`,enabled:!0},{name:`Williams %R`,short_name:`%R`,type:`Momentum`,enabled:!0},{name:`Rate of Change`,short_name:`ROC`,type:`Momentum`,enabled:!0},{name:`On Balance Volume`,short_name:`OBV`,type:`Volume`,enabled:!0},{name:`Volume`,short_name:`VOL`,type:`Volume`,enabled:!0},{name:`Volume Weighted Average Price`,short_name:`VWAP`,type:`Volume`,enabled:!0},{name:`Accumulation/Distribution`,short_name:`A/D`,type:`Volume`,enabled:!0},{name:`Money Flow Index`,short_name:`MFI`,type:`Volume`,enabled:!0},{name:`Chaikin Money Flow`,short_name:`CMF`,type:`Volume`,enabled:!0},{name:`Pivot Points Standard`,short_name:`Pivot`,type:`Support/Resistance`,enabled:!0},{name:`Fibonacci Retracement`,short_name:`Fib`,type:`Support/Resistance`,enabled:!0},{name:`Supertrend`,short_name:`Supertrend`,type:`Trend`,enabled:!0},{name:`Parabolic SAR`,short_name:`PSAR`,type:`Trend`,enabled:!0},{name:`Ichimoku Cloud`,short_name:`Ichimoku`,type:`Trend`,enabled:!0},{name:`ADX`,short_name:`ADX`,type:`Trend Strength`,enabled:!0},{name:`Awesome Oscillator`,short_name:`AO`,type:`Momentum`,enabled:!0},{name:`Heikin Ashi`,short_name:`HA`,type:`Price Transformation`,enabled:!1},{name:`Linear Regression`,short_name:`LinReg`,type:`Trend`,enabled:!0}];function gd(e,t){if(e.length===0||t<=0)return e;let n=new Map;for(let r of e){let e=Math.floor(r.time/t)*t,i=n.get(e);i?i.push(r):n.set(e,[r])}let r=[];for(let[e,t]of n){let n=t[0].high,a=t[0].low,o=0;for(let e of t){var i;e.high>n&&(n=e.high),e.low<a&&(a=e.low),o+=(i=e.volume)==null?0:i}r.push({time:e,open:t[0].open,high:n,low:a,close:t[t.length-1].close,volume:o})}return r.sort((e,t)=>e.time-t.time),r}var _d,vd=new Set([`VOL`,`HA`,`OBV`,`A/D`,`AO`,`VWAP`,`Ichimoku`,`PSAR`,`Pivot`]),yd=[`#2962FF`,`#FF6D00`,`#00BFA5`,`#D500F9`,`#FFD600`,`#26A69A`,`#EF5350`,`#AB47BC`],bd=[{shortName:`MA`,factory:()=>new Ou(20)},{shortName:`EMA`,factory:()=>new Au(20)},{shortName:`WMA`,factory:()=>new ju(20)},{shortName:`HMA`,factory:()=>new Nu(20)},{shortName:`MARibbon`,factory:()=>new Iu},{shortName:`BB`,factory:()=>new Lu(20,2)},{shortName:`KC`,factory:()=>new Ru(20,2)},{shortName:`DC`,factory:()=>new zu(20)},{shortName:`ATR`,factory:()=>new Bu(14)},{shortName:`RSI`,factory:()=>new Vu(14)},{shortName:`Stoch`,factory:()=>new Hu(14,3)},{shortName:`StochRSI`,factory:()=>new Wu(14,14,3,3)},{shortName:`MACD`,factory:()=>new Ku(12,26,9)},{shortName:`CCI`,factory:()=>new qu(20)},{shortName:`%R`,factory:()=>new Ju(14)},{shortName:`ROC`,factory:()=>new Yu(12)},{shortName:`AO`,factory:()=>new dd},{shortName:`OBV`,factory:()=>new Xu},{shortName:`VWAP`,factory:()=>new Zu},{shortName:`A/D`,factory:()=>new Qu},{shortName:`MFI`,factory:()=>new $u(14)},{shortName:`CMF`,factory:()=>new ed(20)},{shortName:`Pivot`,factory:()=>new td},{shortName:`Fib`,factory:()=>new ad(50)},{shortName:`Supertrend`,factory:()=>new od(10,3)},{shortName:`PSAR`,factory:()=>new sd(.02,.2)},{shortName:`Ichimoku`,factory:()=>new ld(9,26,52)},{shortName:`ADX`,factory:()=>new ud(14)},{shortName:`HA`,factory:()=>new fd},{shortName:`VOL`,factory:()=>new pd},{shortName:`LinReg`,factory:()=>new md(14)}],xd={kind:`select`,key:`timeframe`,label:`Timeframe`,options:[`Chart`,`1m`,`5m`,`15m`,`30m`,`1h`,`2h`,`4h`,`8h`,`1D`,`1W`,`1M`],default:`Chart`};function Sd(e,t,n){if(!n)return e;let r=n.fields.filter(e=>e.kind===`number`).map(e=>{var n;return(n=t[e.key])==null?e.default:n});return r.length>0?`${e}(${r.join(`, `)})`:e}var Cd=[{shortName:`MA`,fields:[{kind:`number`,key:`period`,label:`Period`,min:1,max:500,step:1,default:20},{kind:`color`,key:`color`,label:`Color`,default:`#F5A623`},{kind:`select`,key:`source`,label:`Source`,options:[`open`,`high`,`low`,`close`],default:`close`}],factory:e=>new Ou(e.period,e.color,`MA`,e.source)},{shortName:`EMA`,fields:[{kind:`number`,key:`period`,label:`Period`,min:1,max:500,step:1,default:20},{kind:`color`,key:`color`,label:`Color`,default:`#9B59B6`},{kind:`select`,key:`source`,label:`Source`,options:[`open`,`high`,`low`,`close`],default:`close`}],factory:e=>new Au(e.period,e.color,`EMA`,e.source)},{shortName:`WMA`,fields:[{kind:`number`,key:`period`,label:`Period`,min:1,max:500,step:1,default:20},{kind:`color`,key:`color`,label:`Color`,default:`#e91e63`},{kind:`select`,key:`source`,label:`Source`,options:[`open`,`high`,`low`,`close`],default:`close`}],factory:e=>new ju(e.period,e.color,`WMA`,e.source)},{shortName:`HMA`,fields:[{kind:`number`,key:`period`,label:`Period`,min:1,max:500,step:1,default:20},{kind:`color`,key:`color`,label:`Color`,default:`#00bcd4`},{kind:`select`,key:`source`,label:`Source`,options:[`open`,`high`,`low`,`close`],default:`close`}],factory:e=>new Nu(e.period,e.color,`HMA`,e.source)},{shortName:`MARibbon`,fields:[{kind:`color`,key:`color`,label:`Color`,default:`#ffcc80`},{kind:`select`,key:`source`,label:`Source`,options:[`open`,`high`,`low`,`close`],default:`close`}],factory:e=>new Iu(e.color,e.source)},{shortName:`BB`,fields:[{kind:`number`,key:`period`,label:`Period`,min:1,max:500,step:1,default:20},{kind:`number`,key:`stdDev`,label:`Std Dev`,min:.1,max:10,step:.1,default:2},{kind:`color`,key:`color`,label:`Color`,default:`#3B82F6`},{kind:`select`,key:`source`,label:`Source`,options:[`open`,`high`,`low`,`close`],default:`close`}],factory:e=>new Lu(e.period,e.stdDev,e.color,`BB`,e.source)},{shortName:`KC`,fields:[{kind:`number`,key:`period`,label:`Period`,min:1,max:500,step:1,default:20},{kind:`number`,key:`mult`,label:`Multiplier`,min:.1,max:10,step:.1,default:2},{kind:`number`,key:`atrPeriod`,label:`ATR Period`,min:1,max:500,step:1,default:10},{kind:`color`,key:`color`,label:`Color`,default:`#4caf50`}],factory:e=>new Ru(e.period,e.mult,e.atrPeriod,e.color)},{shortName:`DC`,fields:[{kind:`number`,key:`period`,label:`Period`,min:1,max:500,step:1,default:20},{kind:`color`,key:`color`,label:`Color`,default:`#26c6da`}],factory:e=>new zu(e.period,e.color)},{shortName:`ATR`,fields:[{kind:`number`,key:`period`,label:`Period`,min:1,max:500,step:1,default:14},{kind:`color`,key:`color`,label:`Color`,default:`#ff5722`}],factory:e=>new Bu(e.period,e.color)},{shortName:`RSI`,fields:[{kind:`number`,key:`period`,label:`Period`,min:1,max:500,step:1,default:14},{kind:`color`,key:`color`,label:`Color`,default:`#e8b84b`},{kind:`select`,key:`source`,label:`Source`,options:[`open`,`high`,`low`,`close`],default:`close`}],factory:e=>new Vu(e.period,e.color,`RSI`,e.source)},{shortName:`Stoch`,fields:[{kind:`number`,key:`kPeriod`,label:`K Period`,min:1,max:500,step:1,default:14},{kind:`number`,key:`dPeriod`,label:`D Period`,min:1,max:100,step:1,default:3},{kind:`color`,key:`color`,label:`Color`,default:`#e040fb`}],factory:e=>new Hu(e.kPeriod,e.dPeriod,e.color)},{shortName:`StochRSI`,fields:[{kind:`number`,key:`rsiPeriod`,label:`RSI Period`,min:1,max:500,step:1,default:14},{kind:`number`,key:`stochPeriod`,label:`Stoch Period`,min:1,max:500,step:1,default:14},{kind:`number`,key:`kPeriod`,label:`K Smooth`,min:1,max:100,step:1,default:3},{kind:`number`,key:`dPeriod`,label:`D Smooth`,min:1,max:100,step:1,default:3},{kind:`color`,key:`color`,label:`Color`,default:`#00e5ff`}],factory:e=>new Wu(e.rsiPeriod,e.stochPeriod,e.kPeriod,e.dPeriod,e.color)},{shortName:`MACD`,fields:[{kind:`number`,key:`fast`,label:`Fast Period`,min:1,max:500,step:1,default:12},{kind:`number`,key:`slow`,label:`Slow Period`,min:1,max:500,step:1,default:26},{kind:`number`,key:`signal`,label:`Signal Period`,min:1,max:100,step:1,default:9},{kind:`color`,key:`color`,label:`Color`,default:`#2196f3`},{kind:`select`,key:`source`,label:`Source`,options:[`open`,`high`,`low`,`close`],default:`close`}],factory:e=>new Ku(e.fast,e.slow,e.signal,e.color,`MACD`,e.source)},{shortName:`CCI`,fields:[{kind:`number`,key:`period`,label:`Period`,min:1,max:500,step:1,default:20},{kind:`color`,key:`color`,label:`Color`,default:`#4db6ac`}],factory:e=>new qu(e.period,e.color)},{shortName:`%R`,fields:[{kind:`number`,key:`period`,label:`Period`,min:1,max:500,step:1,default:14},{kind:`color`,key:`color`,label:`Color`,default:`#ff7043`}],factory:e=>new Ju(e.period,e.color)},{shortName:`ROC`,fields:[{kind:`number`,key:`period`,label:`Period`,min:1,max:500,step:1,default:12},{kind:`color`,key:`color`,label:`Color`,default:`#80cbc4`},{kind:`select`,key:`source`,label:`Source`,options:[`open`,`high`,`low`,`close`],default:`close`}],factory:e=>new Yu(e.period,e.color,e.source)},{shortName:`AO`,fields:[{kind:`number`,key:`fastPeriod`,label:`Fast Period`,min:1,max:100,step:1,default:5},{kind:`number`,key:`slowPeriod`,label:`Slow Period`,min:1,max:200,step:1,default:34},{kind:`color`,key:`color`,label:`Color`,default:`#b0bec5`}],factory:e=>new dd(e.fastPeriod,e.slowPeriod,e.color)},{shortName:`OBV`,fields:[{kind:`color`,key:`color`,label:`Color`,default:`#aed581`}],factory:e=>new Xu(e.color)},{shortName:`VWAP`,fields:[{kind:`color`,key:`color`,label:`Color`,default:`#9c27b0`}],factory:e=>new Zu(e.color)},{shortName:`A/D`,fields:[{kind:`color`,key:`color`,label:`Color`,default:`#ce93d8`}],factory:e=>new Qu(e.color)},{shortName:`MFI`,fields:[{kind:`number`,key:`period`,label:`Period`,min:1,max:500,step:1,default:14},{kind:`color`,key:`color`,label:`Color`,default:`#ffab40`}],factory:e=>new $u(e.period,e.color)},{shortName:`CMF`,fields:[{kind:`number`,key:`period`,label:`Period`,min:1,max:500,step:1,default:20},{kind:`color`,key:`color`,label:`Color`,default:`#80deea`}],factory:e=>new ed(e.period,e.color)},{shortName:`Pivot`,fields:[{kind:`color`,key:`color`,label:`Color`,default:`#ffd54f`}],factory:e=>new td(e.color)},{shortName:`Fib`,fields:[{kind:`number`,key:`lookback`,label:`Lookback`,min:1,max:500,step:1,default:50},{kind:`color`,key:`color`,label:`Color`,default:`#e1bee7`}],factory:e=>new ad(e.lookback,e.color)},{shortName:`Supertrend`,fields:[{kind:`number`,key:`atrPeriod`,label:`ATR Period`,min:1,max:500,step:1,default:10},{kind:`number`,key:`multiplier`,label:`Multiplier`,min:.1,max:20,step:.1,default:3},{kind:`color`,key:`color`,label:`Color`,default:`#26a69a`}],factory:e=>new od(e.atrPeriod,e.multiplier,e.color)},{shortName:`PSAR`,fields:[{kind:`number`,key:`step`,label:`Step`,min:.001,max:.1,step:.001,default:.02},{kind:`number`,key:`maxAF`,label:`Max AF`,min:.01,max:1,step:.01,default:.2},{kind:`color`,key:`color`,label:`Color`,default:`#ff6b9d`}],factory:e=>new sd(e.step,e.maxAF,e.color)},{shortName:`Ichimoku`,fields:[{kind:`number`,key:`tenkan`,label:`Tenkan Period`,min:1,max:100,step:1,default:9},{kind:`number`,key:`kijun`,label:`Kijun Period`,min:1,max:200,step:1,default:26},{kind:`number`,key:`senkouB`,label:`Senkou B Period`,min:1,max:500,step:1,default:52},{kind:`color`,key:`color`,label:`Color`,default:`#b0bec5`}],factory:e=>new ld(e.tenkan,e.kijun,e.senkouB,e.color)},{shortName:`ADX`,fields:[{kind:`number`,key:`period`,label:`Period`,min:1,max:500,step:1,default:14},{kind:`color`,key:`color`,label:`Color`,default:`#fff176`}],factory:e=>new ud(e.period,e.color)},{shortName:`HA`,fields:[{kind:`color`,key:`color`,label:`Color`,default:`#90a4ae`},{kind:`color`,key:`upColor`,label:`Up Color`,default:`#26a69a`},{kind:`color`,key:`downColor`,label:`Down Color`,default:`#ef5350`}],factory:e=>new fd(e.color,e.upColor,e.downColor)},{shortName:`VOL`,fields:[{kind:`color`,key:`upColor`,label:`Up Color`,default:`#26a69a`},{kind:`color`,key:`downColor`,label:`Down Color`,default:`#ef5350`}],factory:e=>new pd(e.upColor,e.downColor)},{shortName:`LinReg`,fields:[{kind:`number`,key:`period`,label:`Period`,min:1,max:500,step:1,default:14},{kind:`color`,key:`color`,label:`Color`,default:`#ff9800`}],factory:e=>new md(e.period,e.color)}],wd=70,Td=24,Ed=.18,Dd=80,Od=1,kd=80,Ad=10,jd=.25,Md=.2,Nd=`fc-symbol-link`;function Pd(){if(typeof document>`u`||document.getElementById(`fc-symbol-link-styles`))return;let e=document.createElement(`style`);e.id=`fc-symbol-link-styles`,e.textContent=`
|
|
275
|
+
.${Nd}:hover,
|
|
276
|
+
.${Nd}:focus-visible { text-decoration: underline; }
|
|
277
|
+
.${Nd}:focus { outline: none; }
|
|
278
|
+
`,document.head.appendChild(e)}function Fd(){return typeof window<`u`&&(`ontouchstart`in window||navigator.maxTouchPoints>1)}function Id(e=2,t=!1,n=kd,r,i,a){if(i&&i>0&&a&&a>0){let e=Math.floor(i/a);return Math.max(10,Math.min(500,e))}return!t&&!Fd()?n:r===void 0?Math.max(10,Math.round(n/e)):r}var Ld=4;function Rd(e,t){let n=(e.min+e.max)/2,r=(e.max-e.min)/2;return{min:n-r*t,max:n+r*t}}function zd(e){let t=e.max-e.min;return t>=100?0:t>=10?1:t>=1?2:t>=.1?3:4}var Bd=class n{get _tb(){var e,t,n;return(e=(t=(n=this.topBar)==null?this.advancedToolbar:n)==null?this.compactToolbar:t)==null?this.mobileHeader:e}visibleStates(){return this.activeIndicators.filter(e=>{if(!e.visible)return!1;let t=e.currentParams.timeframe;return!(t&&t!==`Chart`&&t!==this.timeframe)})}get indicators(){return this.visibleStates().map(e=>e.indicator)}scheduleViewportPersist(){this._viewportPersistTimer&&clearTimeout(this._viewportPersistTimer),this._viewportPersistTimer=setTimeout(()=>{this._viewportPersistTimer=null,this.emitStateChange()},500)}get isFullscreen(){return this._isCssFullscreen||!!document.fullscreenElement}get _isTradingActive(){var e,t,n,r,i,a,o,s;return((e=(t=this.tradePopover)==null?void 0:t.isVisible)==null?!1:e)||((n=(r=this.tradeActionBar)==null?void 0:r.isVisible)==null?!1:n)||this.draftOrderLabel!==null||((i=(a=this.tradeDragHandler)==null?void 0:a.active)==null?!1:i)||((o=(s=this.orderTimeDragHandler)==null?void 0:s.active)==null?!1:o)||this.pendingLevelDrags.size>0}_enabledGates(){var e;return Object.entries((e=this._features)==null?{}:e).filter(([,e])=>e===!0).map(([e])=>e)}constructor(i){var a,o,c,l,u,f,p,m,h,v,y,b,x,S,C,w,T,E,D,k,j,M,N,P,F,I,R,z,ee,te,ne,re,ie;if(this.topBar=null,this.advancedToolbar=null,this.compactToolbar=null,this.mobileHeader=null,this.bottomBar=null,this.leftBar=null,this.leftBarVisible=!0,this.layoutPopover=null,this.snapshotPopover=null,this.currentPresetId=`1`,this.currentSync={...pi},this.drawingToolsEnabled=!0,this.settingsEnabled=!0,this.fullscreenEnabled=!0,this._mobileLayout=!1,this.indicatorOverlay=null,this.subPaneOverlays=new Map,this.isinPickerModal=null,this.isins=[],this.compareManager=null,this.compareLegend=null,this.comparePickerModal=null,this.compareDataLoader=null,this.compareHoveredIndex=null,this.siEl=null,this.siStreamDot=null,this.siSymbolSpan=null,this.siOHLCSpan=null,this.siOHLC2Span=null,this.tickActivityTimer=null,this.tickActivityMs=3e4,this.streamStatus=`disconnected`,this._isDestroyed=!1,this.indicatorSettingsDialog=null,this.chartSettingsDialog=null,this.tradeButton=null,this.tradePopover=null,this.tradeActionBar=null,this._onAddAlert=null,this.drawingStylePopover=null,this.draftOrderLabel=null,this._minLots=1,this._showQuantityField=!1,this._qtyFieldMin=1,this._qtyFieldMax=100,this._draftQtyFlyout=null,this._draftQtyPillArea=void 0,this._activeQtyPillLabel=void 0,this.pendingQtyChanges=new Map,this.originalQtyByLabel=new Map,this._onOrderSubmit=void 0,this.scrollToEndBtn=null,this.scrollToEndVisible=!1,this.scrollAnimId=null,this.resetViewBtn=null,this.resetViewVisible=!1,this._defaultVisibleBars=kd,this.dataStore=new t,this.scaleManager=new r,this.emitter=new s,this.themeName=`dark`,this._debug=!1,this.symbol=``,this.resolvedInstrument=null,this.resolvedInstrumentPrecision=-1,this.showBidAskLines=!1,this.showActLogo=!1,this.hideLevelConfirmCancel=!1,this.deselectActiveOnOutsideClick=!1,this.tradeLevelButtonScale=1,this.tradeLevelBadgeScale=1,this.tradeLevelBadgeAnchor=`auto`,this._bracketLabel={...Ye},this.levelClusteringEnabled=!0,this.clusterThresholdDistance=20,this.enableThemeToggle=!1,this.activeIndicators=[],this.indicatorInstanceSeq=0,this.indicatorResults=new Map,this.viewport={startIndex:0,endIndex:Id(),candleWidth:8,candleGap:2},this._targetViewport={startIndex:0,endIndex:Id(),candleWidth:8,candleGap:2},this._isPanning=!1,this.crosshair=null,this.drawingManager=new cl,this.textInputEl=null,this.textInputDrawing=null,this._pendingDrawDrag=null,this._pendingDrawResize=null,this._pendingTradeDrag=null,this.paneHeightOverrides=new Map,this.separatorDrag=null,this.priceAxisWidth=wd,this.timeAxisHeight=Td,this.priceScaleFactor=1,this.pricePanOffset=0,this._displayedPriceRange=null,this._lockedAutoFitBase=null,this._lastInCompareMode=!1,this._pendingViewportRestore=null,this._viewportPersistTimer=null,this.axisDrag=null,this.subPaneScaleFactors=new Map,this._mobileCrosshairActive=!1,this._mobileTapStartXY=null,this._longPressTimer=null,this._longPressPoint=null,this._lastTouchTime=0,this._tradeButtonClickData=null,this.disposeVvListener=()=>{},this.rafId=null,this.countdownRafId=null,this.countdownActive=!1,this._cachedWrapRect=null,this._cachedDrawRect=null,this._drawTouchAnchorActive=!1,this._lastDrawingTouchPoint=null,this._drawTouchStartXY=null,this._mobileDrawingFlyout=null,this._isCssFullscreen=!1,this.timezone=`UTC`,this.settingsCanvasColors={},this.streamAdapter=null,this.liveBidAsk=null,this.liveLtp=null,this.tickClosePriceSource=`bid`,this._reloadOnPriceSourceChange=!0,this._suppressTicks=!1,this.levels=[],this.tradeLevelHitAreas=[],this.offViewportHitAreas=[],this.tradeLevelEditAreas=[],this.tradeHoverAreas=[],this.tradeLevelDragAreas=[],this.tradeLevelConfirmAreas=[],this.tradeAddBracketAreas=[],this.clusterBadgeAreas=[],this.lastClusters=[],this.expandedClusters=new Set,this.hoveredTradeLabel=null,this.selectedTradeLabel=null,this._editOpenLabel=null,this.draftBracketPnl={},this.tradeDragHandler=null,this.orderTimeDragHandler=null,this.tradeDragNewBarIndex=null,this.pnlPill=null,this.pnlPillExpanded=!1,this._pnlPillExpandPass=!1,this.pnlPillVisible=!0,this._orderTimeDragEnabled=!1,this._orderLineDragSnap=!0,this._timeAnchorOverride=new Map,this._orderLineAnchorStore=null,this._orderLineDefaultAnchor=`timestamp`,this.tradeDragNewPrice=null,this.tradeDragNewSLPrice=null,this.tradeDragNewTPPrice=null,this._pendingBracketOrderLabel=null,this._slSiblingOrderLabel=null,this._tpSiblingOrderLabel=null,this._isBracketNew=!1,this.pendingLevelDrags=new Map,this.tfcEnabled=!0,this.crosshairEnabled=!0,this.tfcActive=!0,this.tradeDisplayFilter=`all`,this.positionRenderStyle=`dot`,this.tradesThresholdForHorizontalLine=2,this.positionRenderStyleOverride=null,this.RENDER_STYLE_LS_KEY=`finchart:positionRenderStyle`,this.dataLoader=null,this.isFetching=!1,this.noMoreData=!1,this._loadGeneration=0,this.maxCandles=200,this._durationTimeframeMap={..._i},this.minInitialBars=10,this.maxLookbackMs=365*24*60*60*1e3,this.prefetchThreshold=80,this.defaultVisibleBars=kd,this.defaultMobileVisibleBars=void 0,this.mobileBarDivisor=2,this.explicitMobileDivisor=!1,this._autoVisibleBars=!0,this.targetCandleWidth=Ad,this.maxSubPanes=3,this.showCandleCountdown=!0,this.showTradeLevelsAlways=!1,this._revealNewBrackets=!1,this.showPriceAxisCountdown=!1,this.SHOW_SLTP_ALWAYS_LS_KEY=`finchart.showTradeLevelsAlways`,this.PRICE_AXIS_COUNTDOWN_LS_KEY=`finchart.showPriceAxisCountdown`,this.loadingOverlayEl=null,this.noDataOverlayEl=null,this.loadingLabelEl=null,this.noDataLabelEl=null,this.logoImage=null,this.isRestoringState=!1,this.onMouseMove=e=>{var t,r,i,a,o,s,c;if(this._mobileCrosshairActive||Date.now()-this._lastTouchTime<500)return;let l=(t=this._cachedDrawRect)==null?this.drawCanvas.getBoundingClientRect():t,u=e.clientX-l.left,d=e.clientY-l.top,{chartW:f,priceH:p}=this.getChartLayout(),m=(r=this._displayedPriceRange)==null?this.getScaledPriceRange(this.viewport):r,h=l.height-this.timeAxisHeight,g=u<f&&d<h,_=this.scaleManager.pixelToBarIndex(u,this.viewport,f),v=this.scaleManager.pixelToPrice(d,m,p),y=Math.max(Math.floor(this.viewport.startIndex),Math.min(Math.ceil(this.viewport.endIndex),Math.round(_))),b=(i=this.dataStore.all[y])==null?null:i;this.crosshair=g&&this.crosshairEnabled&&!((a=this.tradePopover)!=null&&a.isVisible)&&!((o=this.tradeActionBar)!=null&&o.isVisible)&&this.selectedTradeLabel===null?{x:u,y:d,barIndex:y,price:v,bar:b}:null,this.emitter.emit(`crosshair`,this.crosshair);let x=this.positionRenderStyle===`dot`&&this.hoveredTradeLabel!==null;if(this.tradeButton&&(g&&this.crosshairEnabled&&d>=0&&d<=p&&!this._isTradingActive&&!x?(this.tradeButton.setY(d),qt(d,this.uiConfig.tradeButton.size/2,this.offViewportHitAreas)?this.tradeButton.hide():this.tfcActive&&this.tradeButton.show(),this._tradeButtonClickData={price:v,y:d}):this.tradeButton.hide()),this._pendingDrawResize){let e=u-this._pendingDrawResize.startX,t=d-this._pendingDrawResize.startY;Math.sqrt(e*e+t*t)>n.DRAW_GESTURE_THRESHOLD&&(this.drawingManager.startResize(this._pendingDrawResize.drawing,this._pendingDrawResize.pointIndex,this._pendingDrawResize.handle),this._pendingDrawResize=null)}if(this._pendingDrawDrag){let e=u-this._pendingDrawDrag.startX,t=d-this._pendingDrawDrag.startY;Math.sqrt(e*e+t*t)>n.DRAW_GESTURE_THRESHOLD&&(this.drawingManager.startDrag(this._pendingDrawDrag.drawing,this.makeDrawingPoint(_,v)),this._pendingDrawDrag=null)}if(this.drawingManager.onMouseMove(this.makeDrawingPoint(_,v)),this.axisDrag){if(this.axisDrag.axis===`price`){let e=d-this.axisDrag.startPos;this.priceScaleFactor=Math.max(.1,Math.min(10,this.axisDrag.startSize*1.005**e))}else if(this.axisDrag.axis===`subpane`&&this.axisDrag.instanceId){let e=d-this.axisDrag.startPos,t=Math.max(.1,Math.min(20,this.axisDrag.startSize*1.005**e));this.subPaneScaleFactors.set(this.axisDrag.instanceId,t)}else{let e=u-this.axisDrag.startPos,t=Math.max(10,Math.min(500,Math.round(this.axisDrag.startSize+e*.5))),n=(this.viewport.startIndex+this.viewport.endIndex)/2,r=Math.max(0,n-t/2);this.viewport={...this.viewport,startIndex:r,endIndex:r+t},this._targetViewport={...this.viewport}}this.drawCanvas.style.cursor=this.axisDrag.axis===`time`?`ew-resize`:`ns-resize`,this.scheduleRender();return}if(this.separatorDrag){let e=this.separatorDrag.startY-d,t=Math.max(40,Math.min(300,this.separatorDrag.startH+e));this.paneHeightOverrides.set(this.separatorDrag.instanceId,t),this.drawCanvas.style.cursor=`ns-resize`,this.scheduleRender();return}if(this._pendingTradeDrag){var S;if(!this._upgradePendingTradeDrag(u,d))return;this.drawCanvas.style.cursor=(S=this.orderTimeDragHandler)!=null&&S.active?`grabbing`:`ns-resize`}if((s=this.orderTimeDragHandler)!=null&&s.active){let e=this.orderTimeDragHandler.onMove(u,this.scaleManager,this.viewport,f);this.tradeDragNewBarIndex=e,this.drawCanvas.style.cursor=`grabbing`,this.renderTradeLayer();let t=this.orderTimeDragHandler.dragLabel,n=e===null?void 0:this.barIndexToTimestamp(e);t&&e!==null&&n!==void 0&&this.emitter.emit(`orderLineMoving`,{label:t,toTimestamp:n,toBarIndex:e,isFullscreen:this.isFullscreen});return}if((c=this.tradeDragHandler)!=null&&c.active){var C,w,T;let e=this.tradeDragHandler.onMouseMove(d,this.scaleManager,m,p);if(this.tradeDragNewPrice=(C=e==null?void 0:e.newPrice)==null?null:C,this.tradeDragNewSLPrice=(w=e==null?void 0:e.derivedSLPrice)==null?null:w,this.tradeDragNewTPPrice=(T=e==null?void 0:e.derivedTPPrice)==null?null:T,this.drawCanvas.style.cursor=`ns-resize`,this.renderTradeLayer(),this.tradeDragNewPrice!==null&&e){let t=e.label.indexOf(`:`),n=t===-1?e.label:e.label.slice(0,t),r=t===-1?void 0:e.label.slice(t+1),i=this.levels.find(e=>e.label===n);i&&this.emitter.emit(`tradeLevelDrag`,{label:i.label,newPrice:this.tradeDragNewPrice,data:i.data,bracketType:r,...e.derivedSLPrice===void 0?{}:{derivedSLPrice:e.derivedSLPrice},...e.derivedTPPrice===void 0?{}:{derivedTPPrice:e.derivedTPPrice},isFullscreen:this.isFullscreen})}return}if(!this.drawingManager.getActiveTool()){var E;if(Oe(u,d,this.clusterBadgeAreas)||Dt(u,d,this.tradeLevelHitAreas)||Ot(u,d,this.tradeLevelEditAreas)||kt(u,d,this.tradeLevelConfirmAreas)||Kt(u,d,this.offViewportHitAreas)){this.drawCanvas.style.cursor=`pointer`,this.scheduleRender();return}let e=jt(u,d,this.tradeLevelDragAreas);if(e){let t=this.levels.find(t=>t.label===e.label);this.drawCanvas.style.cursor=this._orderTimeDragEnabled&&e.timeDrag===!0?t&&this._needsDragAxisLock(e,t)?`move`:`grab`:`ns-resize`,e.label!==this.hoveredTradeLabel&&(this.hoveredTradeLabel=e.label,this.renderTradeLayer()),this.scheduleRender();return}let t=At(u,d,this.tradeHoverAreas),n=(E=t==null?void 0:t.label)==null?null:E;if(n!==this.hoveredTradeLabel&&(this.hoveredTradeLabel=n,this.renderTradeLayer()),this.positionRenderStyle===`dot`&&n!==null){this.crosshair=null,this.drawCanvas.style.cursor=`pointer`,this.scheduleRender();return}if(this.getSeparatorPositions().find(e=>Math.abs(d-e.y)<=4))this.drawCanvas.style.cursor=`ns-resize`;else if(u>=f)this.drawCanvas.style.cursor=`ns-resize`;else if(d>=h)this.drawCanvas.style.cursor=`ew-resize`;else if(this.drawingManager.isDraggingDrawing()||this.drawingManager.isResizingDrawing())this.drawCanvas.style.cursor=`grabbing`;else{let e=this.drawingManager.getHandleAtPoint(u,d,this.scaleManager,this.viewport,m,f,p);if(e)this.drawCanvas.style.cursor=e.handle.cursor;else{let e=this.drawingManager.hitTest(u,d,this.scaleManager,this.viewport,m,f,p);this.drawCanvas.style.cursor=e?`move`:`default`}}}this.scheduleRender()},this.onMouseLeave=e=>{if(!(this.tradeButton&&this.tradeButton.el.contains(e.relatedTarget))&&!this._mobileCrosshairActive){if(this.crosshair=null,this.emitter.emit(`crosshair`,null),!this._isTradingActive){var t;(t=this.tradeButton)==null||t.hide()}this.hoveredTradeLabel!==null&&(this.hoveredTradeLabel=null,this.renderTradeLayer()),this.scheduleRender()}},this.onMouseUp=()=>{var e;if(this.drawingManager.isFreehandStroke()){var t;let{chartW:e,priceH:n}=this.getChartLayout(),r=(t=this._displayedPriceRange)==null?this.getScaledPriceRange(this.viewport):t;this.drawingManager.finishFreehand(this.scaleManager,this.viewport,r,e,n),this._pendingDrawDrag=null,this._pendingDrawResize=null,this.scheduleRender();return}if(this._pendingTradeDrag){let{level:e}=this._pendingTradeDrag;if(this._pendingTradeDrag=null,this._editOpenLabel===e.label&&!this.pendingLevelDrags.has(e.label)){this._cancelEditAndDeselect(e.label);return}this._openTradeLevelEditForm(e);return}if(!this._endOrderTimeDrag()){if((e=this.tradeDragHandler)!=null&&e.active){let e=this.tradeDragHandler.endDrag();if(e){var n;this._finalizeMainDragWithBrackets(e,(n=this._pendingBracketOrderLabel)==null?void 0:n)}else this.tradeDragNewPrice=null;this._pendingBracketOrderLabel=null,this.drawCanvas.style.cursor=`default`,this.renderTradeLayer();return}if(this.axisDrag){let e=this.axisDrag.axis===`price`||this.axisDrag.axis===`time`;this.axisDrag=null,this.drawCanvas.style.cursor=`default`,this.scheduleRender(),e&&this.scheduleViewportPersist()}this.separatorDrag&&(this.separatorDrag=null,this.drawCanvas.style.cursor=`default`,this.scheduleRender()),this._pendingDrawDrag=null,this._pendingDrawResize=null,this.drawingManager.isDraggingDrawing()&&(this.drawingManager.endDrag(),this.drawCanvas.style.cursor=`default`,this.scheduleRender()),this.drawingManager.isResizingDrawing()&&(this.drawingManager.endResize(),this.drawCanvas.style.cursor=`default`,this.scheduleRender())}},this.onDrawingTouchStart=e=>{var t;if(e.touches.length!==1)return;let r=e.touches[0],i=this.touchToDrawingPoint(r),a=this.drawingManager.getActiveTool(),o=this.drawingManager.isPlacing();if(a!==null||o){e.preventDefault(),this._lastDrawingTouchPoint=i,o?(this._drawTouchAnchorActive=!1,this.drawingManager.onMouseMove(i)):(this.drawingManager.onMouseDown(i),this._drawTouchAnchorActive=this.drawingManager.isPlacing()&&!this.drawingManager.isFreehandStroke()),this.scheduleRender();return}let s=(t=this._cachedDrawRect)==null?this.drawCanvas.getBoundingClientRect():t,c=r.clientX-s.left,l=r.clientY-s.top,{chartW:u,priceH:d}=this.getChartLayout(),f=this.getScaledPriceRange(this.viewport);if(c>=u){if(e.preventDefault(),l<=d)this.axisDrag={axis:`price`,startPos:l,startSize:this.priceScaleFactor};else{let e=this.activeIndicators.filter(e=>e.indicator.pane===`sub`),t=d+Od;for(let n of e){let e=this.paneH(n);if(l>=t&&l<t+e){var p;this.axisDrag={axis:`subpane`,startPos:l,startSize:(p=this.subPaneScaleFactors.get(n.instanceId))==null?1:p,instanceId:n.instanceId};break}t+=e+Od}}this.scheduleRender();return}let m=s.height-this.timeAxisHeight;if(l>=m){e.preventDefault(),this.axisDrag={axis:`time`,startPos:c,startSize:this.viewport.endIndex-this.viewport.startIndex},this.scheduleRender();return}let h=this.drawingManager.getHandleAtPoint(c,l,this.scaleManager,this.viewport,f,u,d,n.TOUCH_HANDLE_SLOP_PX);if(h){e.preventDefault(),this.panHandler.cancel(),this.drawingManager.selectDrawing(h.drawing),this.drawingManager.startResize(h.drawing,h.handle.pointIndex,h.handle),this.hideMobileDrawingFlyout(),this.scheduleRender();return}let g=this.drawingManager.hitTest(c,l,this.scaleManager,this.viewport,f,u,d);if(g){e.preventDefault(),this.panHandler.cancel(),this.drawingManager.selectDrawing(g),this.drawingManager.startDrag(g,i),this._drawTouchStartXY={x:r.clientX,y:r.clientY},this.hideMobileDrawingFlyout(),this.scheduleRender();return}let _=Oe(c,l,this.clusterBadgeAreas);if(_){e.preventDefault(),this.panHandler.cancel(),this.expandedClusters.has(_.clusterId)?this.expandedClusters.delete(_.clusterId):this.expandedClusters.add(_.clusterId),this.renderTradeLayer();return}let v=Kt(c,l,this.offViewportHitAreas);if(v){e.preventDefault(),this.panHandler.cancel(),this.scrollToCenterPrice(v.targetPrice);return}let y=kt(c,l,this.tradeLevelConfirmAreas);if(y){e.preventDefault(),y.action===`confirm`?this.applyPendingChanges(y.label):this.revertPendingChanges(y.label);return}if(this._showQuantityField&&this._draftQtyPillArea){let t=this._draftQtyPillArea;if(c>=t.pillX&&c<=t.pillX+t.pillW&&l>=t.pillY&&l<=t.pillY+t.pillH){e.preventDefault(),e.stopPropagation(),this.openDraftQtyFlyout(t);return}}let b=Dt(c,l,this.tradeLevelHitAreas);if(b){e.preventDefault(),this._handleTradeLevelClose(b);return}if(!this.drawingManager.getActiveTool()){let t=Ot(c,l,this.tradeLevelEditAreas);if(t){e.preventDefault();let n=this.levels.find(e=>e.label===t.label);n&&this._openTradeLevelEditForm(n);return}}if(this.tradeDragHandler&&!this.drawingManager.getActiveTool()){let t=jt(c,l,this.tradeLevelDragAreas);if(t){e.preventDefault();let n=this.levels.find(e=>e.label===t.label);if(n){let e=this.selectedTradeLabel===n.label,r=t.isBracket||this._orderTimeDragEnabled&&t.timeDrag===!0||n.type===`pending`&&n.orderType!==`market`&&(e||!t.isBox);if(this.hideLevelConfirmCancel&&!r){let e=this.pendingLevelDrags.has(n.label);if(this.selectedTradeLabel===n.label&&!e){this._cancelEditAndDeselect(n.label);return}this._openTradeLevelEditForm(n);return}if(this._needsDragAxisLock(t,n)){this._pendingTradeDrag={dragHit:t,level:n,hitY:l,startX:c,startY:l,axisLock:!0};return}this._startTradeDragFromHit(t,n,l,c),this.scheduleRender();return}}}if(this.tradeDragHandler&&!this.drawingManager.getActiveTool()){let t=Mt(c,l,this.tradeAddBracketAreas);if(t){e.preventDefault(),this._startAddBracketFromHit(t,l),this.scheduleRender();return}}if(this.tradeDragHandler&&!this.drawingManager.getActiveTool()){let t=At(c,l,this.tradeHoverAreas);if(t){e.preventDefault();let n=this.levels.find(e=>e.label===t.label);if(n){let e=this.pendingLevelDrags.has(t.label);if(this.selectedTradeLabel===t.label&&!e){this._cancelEditAndDeselect(t.label);return}this._openTradeLevelEditForm(n);return}}}this.drawingManager.selectDrawing(null),this.hideMobileDrawingFlyout(),this.expandedClusters.size>0&&(this.expandedClusters.clear(),this.renderTradeLayer()),c<u&&l<m&&(this._mobileCrosshairActive?(this._longPressTimer!==null&&(clearTimeout(this._longPressTimer),this._longPressTimer=null),this._mobileTapStartXY={x:c,y:l}):(this._longPressTimer!==null&&clearTimeout(this._longPressTimer),this._longPressPoint={x:c,y:l},this._longPressTimer=setTimeout(()=>{this._longPressTimer=null,this._longPressPoint&&(this._activateMobileCrosshair(this._longPressPoint.x,this._longPressPoint.y),this._longPressPoint=null)},500)))},this.onDrawingTouchMove=e=>{var t,n;if(e.touches.length!==1)return;let r=this.touchToDrawingPoint(e.touches[0]);if(this._lastDrawingTouchPoint=r,this.axisDrag){var i;e.preventDefault();let t=e.touches[0],n=(i=this._cachedDrawRect)==null?this.drawCanvas.getBoundingClientRect():i,r=t.clientX-n.left,a=t.clientY-n.top;if(this.axisDrag.axis===`price`){let e=a-this.axisDrag.startPos;this.priceScaleFactor=Math.max(.1,Math.min(10,this.axisDrag.startSize*1.005**e))}else if(this.axisDrag.axis===`subpane`&&this.axisDrag.instanceId){let e=a-this.axisDrag.startPos,t=Math.max(.1,Math.min(20,this.axisDrag.startSize*1.005**e));this.subPaneScaleFactors.set(this.axisDrag.instanceId,t)}else{let e=r-this.axisDrag.startPos,t=Math.max(10,Math.min(500,Math.round(this.axisDrag.startSize+e*.5))),n=(this.viewport.startIndex+this.viewport.endIndex)/2,i=Math.max(0,n-t/2);this.viewport={...this.viewport,startIndex:i,endIndex:i+t}}this.scheduleRender();return}if(this.drawingManager.isPlacing()&&!this._drawTouchAnchorActive){e.preventDefault(),this.drawingManager.onMouseMove(r),this.scheduleRender();return}if(this.drawingManager.isDraggingDrawing()||this.drawingManager.isResizingDrawing()){e.preventDefault(),e.stopPropagation(),this.drawingManager.onMouseMove(r),this.scheduleRender();return}if(this._pendingTradeDrag){var a;e.preventDefault();let t=e.touches[0],n=(a=this._cachedDrawRect)==null?this.drawCanvas.getBoundingClientRect():a;if(!this._upgradePendingTradeDrag(t.clientX-n.left,t.clientY-n.top))return}if((t=this.orderTimeDragHandler)!=null&&t.active){var o;e.preventDefault();let t=e.touches[0],n=(o=this._cachedDrawRect)==null?this.drawCanvas.getBoundingClientRect():o,r=t.clientX-n.left,{chartW:i}=this.getChartLayout(),a=this.orderTimeDragHandler.onMove(r,this.scaleManager,this.viewport,i);this.tradeDragNewBarIndex=a,this.renderTradeLayer();let s=this.orderTimeDragHandler.dragLabel,c=a===null?void 0:this.barIndexToTimestamp(a);s&&a!==null&&c!==void 0&&this.emitter.emit(`orderLineMoving`,{label:s,toTimestamp:c,toBarIndex:a,isFullscreen:this.isFullscreen});return}if((n=this.tradeDragHandler)!=null&&n.active){var s,c,l,u,d;e.preventDefault();let t=e.touches[0],n=(s=this._cachedDrawRect)==null?this.drawCanvas.getBoundingClientRect():s,r=t.clientY-n.top,{priceH:i}=this.getChartLayout(),a=(c=this._displayedPriceRange)==null?this.getScaledPriceRange(this.viewport):c,o=this.tradeDragHandler.onMouseMove(r,this.scaleManager,a,i);if(this.tradeDragNewPrice=(l=o==null?void 0:o.newPrice)==null?null:l,this.tradeDragNewSLPrice=(u=o==null?void 0:o.derivedSLPrice)==null?null:u,this.tradeDragNewTPPrice=(d=o==null?void 0:o.derivedTPPrice)==null?null:d,this.renderTradeLayer(),this.tradeDragNewPrice!==null&&o){let e=o.label.indexOf(`:`),t=e===-1?o.label:o.label.slice(0,e),n=e===-1?void 0:o.label.slice(e+1),r=this.levels.find(e=>e.label===t);r&&this.emitter.emit(`tradeLevelDrag`,{label:r.label,newPrice:this.tradeDragNewPrice,data:r.data,bracketType:n,...o.derivedSLPrice===void 0?{}:{derivedSLPrice:o.derivedSLPrice},...o.derivedTPPrice===void 0?{}:{derivedTPPrice:o.derivedTPPrice},isFullscreen:this.isFullscreen})}return}if(this._mobileTapStartXY||this._longPressTimer!==null){var f,p;let t=e.touches[0],n=(f=this._cachedDrawRect)==null?this.drawCanvas.getBoundingClientRect():f,r=(p=this._mobileTapStartXY)==null?this._longPressPoint:p;if(r){let e=t.clientX-n.left-r.x,i=t.clientY-n.top-r.y;Math.sqrt(e*e+i*i)>6&&(this._mobileTapStartXY=null,this._longPressTimer!==null&&(clearTimeout(this._longPressTimer),this._longPressTimer=null,this._longPressPoint=null))}}if(this._mobileCrosshairActive){var m,h;e.preventDefault();let t=e.touches[0],n=(m=this._cachedDrawRect)==null?this.drawCanvas.getBoundingClientRect():m,r=t.clientX-n.left,i=t.clientY-n.top,{chartW:a,priceH:o}=this.getChartLayout(),s=(h=this._displayedPriceRange)==null?this.getScaledPriceRange(this.viewport):h,c=n.height-this.timeAxisHeight;if(r<a&&i<c){var g;let e=this.scaleManager.pixelToBarIndex(r,this.viewport,a),t=this.scaleManager.pixelToPrice(i,s,o),n=Math.max(Math.floor(this.viewport.startIndex),Math.min(Math.ceil(this.viewport.endIndex),Math.round(e))),c=(g=this.dataStore.all[n])==null?null:g;this.crosshair=this.selectedTradeLabel===null?{x:r,y:i,barIndex:n,price:t,bar:c}:null,this.tradeButton&&(this.tradeButton.setY(i),this._isTradingActive||qt(i,this.uiConfig.tradeButton.size/2,this.offViewportHitAreas)?this.tradeButton.hide():this.tfcActive&&this.tradeButton.show(),this._tradeButtonClickData={price:t,y:i}),this.scheduleRender()}}},this.onDrawingTouchCancel=e=>{var t,n;this._longPressTimer!==null&&(clearTimeout(this._longPressTimer),this._longPressTimer=null,this._longPressPoint=null);let r=!1;this._pendingTradeDrag=null,(t=this.orderTimeDragHandler)!=null&&t.active&&(this.orderTimeDragHandler.cancel(),this.tradeDragNewBarIndex=null,r=!0),(n=this.tradeDragHandler)!=null&&n.active&&(this.tradeDragHandler.cancelDrag(),this.tradeDragNewPrice=null,this.tradeDragNewSLPrice=null,this.tradeDragNewTPPrice=null,this._pendingBracketOrderLabel=null,r=!0),this._pendingTradeDrag=null,r&&this.renderTradeLayer()},this.onDrawingTouchEnd=e=>{var t;if(this._lastTouchTime=Date.now(),this._longPressTimer!==null&&(clearTimeout(this._longPressTimer),this._longPressTimer=null,this._longPressPoint=null),this._pendingTradeDrag){let{level:e}=this._pendingTradeDrag;this._pendingTradeDrag=null;let t=this.pendingLevelDrags.has(e.label);if(this.selectedTradeLabel===e.label&&!t){this._cancelEditAndDeselect(e.label);return}this._openTradeLevelEditForm(e);return}if(this._endOrderTimeDrag())return;if((t=this.tradeDragHandler)!=null&&t.active){let e=this.tradeDragHandler.endDrag();if(e){var n;this._finalizeMainDragWithBrackets(e,(n=this._pendingBracketOrderLabel)==null?void 0:n)}else this.tradeDragNewPrice=null;this._pendingBracketOrderLabel=null,this.renderTradeLayer();return}if(this.axisDrag){let e=this.axisDrag.axis===`price`||this.axisDrag.axis===`time`;this.axisDrag=null,this.scheduleRender(),e&&this.scheduleViewportPersist();return}let r=this._drawTouchAnchorActive;if(this._drawTouchAnchorActive=!1,this.drawingManager.isFreehandStroke()){var i;let{chartW:e,priceH:t}=this.getChartLayout(),n=(i=this._displayedPriceRange)==null?this.getScaledPriceRange(this.viewport):i;this.drawingManager.finishFreehand(this.scaleManager,this.viewport,n,e,t),this._lastDrawingTouchPoint=null,this.scheduleRender();return}if(!r&&this.drawingManager.isPlacing()&&this._lastDrawingTouchPoint){this.drawingManager.onMouseDown(this._lastDrawingTouchPoint),this._lastDrawingTouchPoint=null,this.scheduleRender();return}if(this.drawingManager.isDraggingDrawing()){let t=e.changedTouches[0],n=this._drawTouchStartXY;if(this._drawTouchStartXY=null,this.drawingManager.endDrag(),t&&n&&this.drawingManager.getSelectedDrawing()){let e=t.clientX-n.x,r=t.clientY-n.y;Math.sqrt(e*e+r*r)<8&&this.showMobileDrawingFlyout(t.clientX,t.clientY)}this.scheduleRender()}if(this.drawingManager.isResizingDrawing()&&(this.drawingManager.endResize(),this.scheduleRender()),this._mobileTapStartXY){var a;this._mobileTapStartXY=null,this._mobileCrosshairActive=!1,this.crosshair=null,(a=this.tradeButton)==null||a.hide(),this.scheduleRender()}},this.onCanvasClick=e=>{var t,n;let r=(t=this._cachedDrawRect)==null?this.drawCanvas.getBoundingClientRect():t,i=e.clientX-r.left,a=e.clientY-r.top,{chartW:o,priceH:s}=this.getChartLayout(),c=(n=this._displayedPriceRange)==null?this.getScaledPriceRange(this.viewport):n,l=this.scaleManager.pixelToBarIndex(i,this.viewport,o),u=this.scaleManager.pixelToPrice(a,c,s),d=Math.round(l),f=Oe(i,a,this.clusterBadgeAreas);if(f){this.expandedClusters.has(f.clusterId)?this.expandedClusters.delete(f.clusterId):this.expandedClusters.add(f.clusterId),this.renderTradeLayer();return}let p=Kt(i,a,this.offViewportHitAreas);if(p){this.scrollToCenterPrice(p.targetPrice);return}let m=kt(i,a,this.tradeLevelConfirmAreas);if(m){m.action===`confirm`?this.applyPendingChanges(m.label):this.revertPendingChanges(m.label);return}if(this._showQuantityField&&this._draftQtyPillArea){let t=this._draftQtyPillArea;if(i>=t.pillX&&i<=t.pillX+t.pillW&&a>=t.pillY&&a<=t.pillY+t.pillH){e.preventDefault(),e.stopPropagation(),this.openDraftQtyFlyout(t);return}}let h=Dt(i,a,this.tradeLevelHitAreas);if(h){this._handleTradeLevelClose(h);return}if(!this.drawingManager.getActiveTool()){let e=Ot(i,a,this.tradeLevelEditAreas);if(e){let t=this.levels.find(t=>t.label===e.label);t&&this._openTradeLevelEditForm(t);return}}if(this.tradeDragHandler&&!this.drawingManager.getActiveTool()){let e=Mt(i,a,this.tradeAddBracketAreas);if(e){this._startAddBracketFromHit(e,a);return}}if(this.tradeDragHandler&&!this.drawingManager.getActiveTool()){let e=jt(i,a,this.tradeLevelDragAreas);if(e){let t=this.levels.find(t=>t.label===e.label);if(t&&!(this.hideLevelConfirmCancel&&!e.isBracket)){this._pendingTradeDrag={dragHit:e,level:t,hitY:a,startX:i,startY:a,axisLock:this._needsDragAxisLock(e,t)};return}}}let g=At(i,a,this.tradeHoverAreas);if(g){let e=this.pendingLevelDrags.has(g.label);if(this.selectedTradeLabel===g.label&&!e){this._cancelEditAndDeselect(g.label);return}let t=this.levels.find(e=>e.label===g.label);t?this._openTradeLevelEditForm(t):(this.selectedTradeLabel=g.label,this.renderTradeLayer());return}else if(this.selectedTradeLabel!==null&&!this.hideLevelConfirmCancel&&this.deselectActiveOnOutsideClick){let e=this.selectedTradeLabel,t=this.pendingLevelDrags.get(e);!t||t.length===0?this._cancelEditAndDeselect(e):this.revertPendingChanges(e)}this.expandedClusters.size>0&&(this.expandedClusters.clear(),this.renderTradeLayer());let _=r.height-this.timeAxisHeight;if(i>=o){if(a<=s)this.axisDrag={axis:`price`,startPos:a,startSize:this.priceScaleFactor};else{let e=this.activeIndicators.filter(e=>e.indicator.pane===`sub`),t=s+Od;for(let n of e){let e=this.paneH(n);if(a>=t&&a<t+e){var v;this.axisDrag={axis:`subpane`,startPos:a,startSize:(v=this.subPaneScaleFactors.get(n.instanceId))==null?1:v,instanceId:n.instanceId};break}t+=e+Od}}this.scheduleRender();return}if(a>=_){this.axisDrag={axis:`time`,startPos:i,startSize:this.viewport.endIndex-this.viewport.startIndex},this.scheduleRender();return}let y=this.getSeparatorPositions().find(e=>Math.abs(a-e.y)<=4);if(y){var b,x;let e=this.activeIndicators.find(e=>e.instanceId===y.instanceId),t=(b=(x=this.paneHeightOverrides.get(y.instanceId))==null?e==null?void 0:e.indicator.paneHeight:x)==null?Dd:b;this.separatorDrag={instanceId:y.instanceId,startY:a,startH:t},this.scheduleRender();return}if(!this.drawingManager.onMouseDown(this.makeDrawingPoint(l,u))){var S;let e=this.drawingManager.getHandleAtPoint(i,a,this.scaleManager,this.viewport,c,o,s);if(e)this.drawingManager.selectDrawing(e.drawing),this._pendingDrawResize={drawing:e.drawing,pointIndex:e.handle.pointIndex,handle:e.handle,startX:i,startY:a};else{let e=this.drawingManager.hitTest(i,a,this.scaleManager,this.viewport,c,o,s);this.drawingManager.selectDrawing(e),e&&(this._pendingDrawDrag={drawing:e,startX:i,startY:a})}let t=(S=this.dataStore.all[d])==null?null:S;this.emitter.emit(`click`,{x:i,y:a,barIndex:d,price:u,bar:t})}this.scheduleRender()},this.onDoubleClick=e=>{var t;this.drawingManager.finalizePlacing();let n=(t=this._cachedDrawRect)==null?this.drawCanvas.getBoundingClientRect():t,r=e.clientX-n.left,i=e.clientY-n.top,{chartW:a,priceH:o}=this.getChartLayout(),s=n.height-this.timeAxisHeight;if(r>=a){this.resetPriceAxis();return}if(i>=s){this.resetTimeAxis();return}let c=new Set([`text`,`callout`,`anchoredNote`]),l=this.drawingManager.getSelectedDrawing();if(l&&c.has(l.type)){let e=this.getScaledPriceRange(this.viewport);if(l.hitTest(r,i,this.scaleManager,this.viewport,e,a,o)){this.showTextInput(l);return}}this.scheduleRender()},this.onKeyDown=e=>{var t;if(e.key===`Escape`&&(t=this.orderTimeDragHandler)!=null&&t.active){this.orderTimeDragHandler.cancel(),this.tradeDragNewBarIndex=null,this.drawCanvas.style.cursor=`default`,this.renderTradeLayer(),e.preventDefault();return}if(e.key===`Escape`&&this.pnlPillExpanded){var n;this.pnlPillExpanded=!1,(n=this.pnlPill)==null||n.setExpanded(!1),this.recomputeRenderStyle(),this.renderTradeLayer()}if(e.key===`Escape`&&this.expandedClusters.size>0){this.expandedClusters.clear(),this.renderTradeLayer(),e.preventDefault();return}if(e.key===`Escape`&&this.pendingLevelDrags.size>0){this.revertPendingChanges(),e.preventDefault();return}let r=(e.ctrlKey||e.metaKey)&&e.key===`z`?`z`:e.key;if(this.drawingManager.onKeyDown(r)){var i;e.preventDefault(),this.hideMobileDrawingFlyout(),(i=this.leftBar)==null||i.setActiveTool(this.drawingManager.getActiveTool()),this.drawCanvas.style.cursor=this.drawingManager.getActiveTool()?`crosshair`:`default`,this.scheduleRender()}},this.onTick=e=>{var t;if(this._isDestroyed)return;let n=this.dataStore.all;if(n.length===0||this._suppressTicks)return;this.liveBidAsk={bid:e.bid,ask:e.ask},e.ltp!=null&&e.ltp>0&&(this.liveLtp=e.ltp),this.setDotTickActive();let r=n[n.length-1],i=this.timeframeToMs(this.timeframe),a=this.tickClosePriceSource===`ltp`?(t=this.liveLtp)==null?e.bid:t:this.tickClosePriceSource===`ask`?e.ask:e.bid;if(e.time<r.time+i){var o;let t={...r,high:Math.max(r.high,a),low:Math.min(r.low,a),close:a,volume:((o=r.volume)==null?0:o)+e.volume};n[n.length-1]=t}else{let t=r,o=Math.floor(e.time/i)*i;n.push({time:o,open:a,high:a,low:a,close:a,volume:e.volume}),this._debug&&console.warn(`[tick] → NEW candle @ ${new Date(o).toISOString()} (closed ${new Date(t.time).toISOString()}) | total bars=${n.length}`);let s=n[n.length-1];this._targetViewport.endIndex>=n.length&&(this._targetViewport={...this._targetViewport,startIndex:this._targetViewport.startIndex+1,endIndex:this._targetViewport.endIndex+1}),this.emitter.emit(`newBar`,{completedBar:t,openingBar:s,intervalMs:i}),this.correctCompletedBar(t.time,i),o>t.time+i&&this.fillTickGap(t.time,o)}this.recomputeIndicators(),this.scheduleRender()},typeof window>`u`||typeof document>`u`)throw Error(`acttrader-charts requires a browser environment`);if(Vn(),window.visualViewport){let e=window.visualViewport,t=()=>{this._cachedWrapRect=null,this._cachedDrawRect=null};e.addEventListener(`resize`,t),e.addEventListener(`scroll`,t),this.disposeVvListener=()=>{e.removeEventListener(`resize`,t),e.removeEventListener(`scroll`,t)}}let{container:ae,theme:oe=`dark`,series:se=`candlestick`,showVolume:ce=!0,showUI:V=!0,timeframe:le=`1D`,duration:ue=void 0,symbol:de=``,isins:fe,onIsinSelect:pe,onSymbolClick:me,onOrderSubmit:he,dataLoader:ge,uiConfig:_e,labels:ve,tickActivityMs:ye=3e4,hideSymbolAndTick:be=!1,hideOHLCV:xe=!1,showBottomBar:Se=!1}=i;if(this.dataLoader=ge==null?null:ge,this.compareDataLoader=(a=i.compareDataLoader)==null?null:a,this.compareManager=new lu({emitter:this.emitter,loader:this.compareDataLoader,maxCompares:i.maxCompares}),this.drawingToolsEnabled=i.showDrawingTools!==!1,this.settingsEnabled=i.showSettings!==!1,this.fullscreenEnabled=i.showFullscreenButton!==!1,this.uiConfig=O(_e),this.labels=A(ve),this.tickActivityMs=ye,this.maxCandles=(o=i.maxCandles)==null?200:o,this._durationTimeframeMap={..._i,...i.durationTimeframeMap},this.minInitialBars=Math.max(0,(c=i.minInitialBars)==null?10:c),this.maxLookbackMs=Math.max(0,(l=i.maxLookbackMs)==null?365*24*60*60*1e3:l),this.prefetchThreshold=(u=i.prefetchThreshold)==null?80:u,this.defaultVisibleBars=(f=i.defaultVisibleBars)==null?kd:f,this.defaultMobileVisibleBars=i.defaultMobileVisibleBars,this.explicitMobileDivisor=i.mobileBarDivisor!==void 0,this.mobileBarDivisor=(p=i.mobileBarDivisor)==null?2:p,this._autoVisibleBars=i.defaultVisibleBars==null&&i.defaultMobileVisibleBars==null,this.targetCandleWidth=(m=i.targetCandleWidth)==null?Ad:m,this.viewport={...this.viewport,endIndex:Id(this.mobileBarDivisor,this.explicitMobileDivisor,this.defaultVisibleBars,this.defaultMobileVisibleBars)},this._targetViewport={...this.viewport},this.maxSubPanes=(h=i.maxSubPanes)==null?3:h,this.tickClosePriceSource=(v=i.tickClosePriceSource)==null?`bid`:v,this._reloadOnPriceSourceChange=i.reloadOnPriceSourceChange!==!1,this.showLtpPrice=i.showLtpPrice,this.tradesThresholdForHorizontalLine=(y=i.tradesThresholdForHorizontalLine)==null?2:y,i.positionRenderStyle===`line`||i.positionRenderStyle===`dot`)this.positionRenderStyleOverride=i.positionRenderStyle;else{let e=localStorage.getItem(this.RENDER_STYLE_LS_KEY);(e===`line`||e===`dot`)&&(this.positionRenderStyleOverride=e)}i.tradeDisplayFilter&&(this.tradeDisplayFilter=i.tradeDisplayFilter),i.canvasColors&&(this.settingsCanvasColors=i.canvasColors),this.recomputeRenderStyle(),this.showBidAskLines=(b=i.showBidAskLines)==null?!1:b,this.showAskLine=i.showAskLine,this.showBidLine=i.showBidLine,this.showActLogo=(x=i.showActLogo)==null?!1:x,this.hideLevelConfirmCancel=(S=i.hideLevelConfirmCancel)==null?!1:S,this.deselectActiveOnOutsideClick=(C=i.deselectActiveOnOutsideClick)==null?!1:C,this._orderTimeDragEnabled=((w=i.features)==null?void 0:w.orderLineTimeDrag)===!0,this._features=i.features,this.drawingManager.setFreehandEnabled(((T=i.features)==null?void 0:T.enableForecasting)===!0),this._orderLineDragSnap=i.orderLineDragSnap!==!1,this._orderLineDefaultAnchor=i.orderLineDefaultAnchor===`center`?`center`:`timestamp`,this._orderTimeDragEnabled&&i.orderLineAnchorPersistence!==!1&&(this._orderLineAnchorStore=new Eu(Eu.browserStorage())),this.tradeLevelButtonScale=Math.min(Math.max((E=i.tradeLevelButtonScale)==null?1:E,1),3),this.tradeLevelBadgeScale=Math.min(Math.max((D=i.tradeLevelBadgeScale)==null?1:D,.5),1),this.tradeLevelBadgeAnchor=i.tradeLevelBadgeAnchor===`left`?`left`:`auto`,this._bracketLabel={mode:(k=i.bracketLabelMode)==null?`price`:k,currencySymbol:(j=i.currencySymbol)==null?`$`:j},this.levelClusteringEnabled=(M=i.levelClusteringEnabled)==null?!0:M,this.clusterThresholdDistance=(N=i.clusterThresholdDistance)==null?20:N,this.enableThemeToggle=(P=i.enableThemeToggle)==null?!1:P,this.tfcEnabled=i.tfcEnabled!==!1,this.crosshairEnabled=i.crosshairEnabled!==!1,this.tfcActive=this.tfcEnabled,this.showCandleCountdown=(F=i.showCandleCountdown)==null?!0:F,this.candleCountdownTimeframes=i.candleCountdownTimeframes,this.showTradeLevelsAlways=(I=i.showTradeLevelsAlways)==null?!0:I,this.showPriceAxisCountdown=(R=i.showPriceAxisCountdown)==null?!1:R,this._revealNewBrackets=i.revealNewBrackets===!0;try{let e=localStorage.getItem(this.SHOW_SLTP_ALWAYS_LS_KEY);e!==null&&(this.showTradeLevelsAlways=e===`true`);let t=localStorage.getItem(this.PRICE_AXIS_COUNTDOWN_LS_KEY);t!==null&&(this.showPriceAxisCountdown=t===`true`)}catch(e){}this._onOrderSubmit=he,this._onAddAlert=(z=i.onAddAlert)==null?null:z,i.minLots!==void 0&&(console.warn(`[acttrader-charts] ChartConfig.minLots is deprecated. DraftOrderQtyInput has been removed. The value is stored and used as the submitted lot size.`),this._minLots=i.minLots),i.showQuantityField!==void 0&&(this._showQuantityField=i.showQuantityField),i.quantityFieldConfig&&(i.quantityFieldConfig.minLots!==void 0&&(this._qtyFieldMin=i.quantityFieldConfig.minLots),i.quantityFieldConfig.maxLots!==void 0&&(this._qtyFieldMax=i.quantityFieldConfig.maxLots)),i.onLotsChange!==void 0&&console.warn(`[acttrader-charts] ChartConfig.onLotsChange is deprecated. DraftOrderQtyInput has been removed; this callback will never fire.`),i.hideQtyButton!==void 0&&console.warn(`[acttrader-charts] ChartConfig.hideQtyButton is deprecated and is a no-op. DraftOrderQtyInput has been removed.`),this.themeName=oe===`dark`?`dark`:`light`,this.themeOverrides=i.themeOverrides,this.timezone=i.timezone===`local`?Intl.DateTimeFormat().resolvedOptions().timeZone:(ee=i.timezone)==null?`UTC`:ee,this.aggregateFrom=i.aggregateFrom;let Ce=this.themeName===`dark`?g:_;this.theme=d(Ce,(te=this.themeOverrides)==null?void 0:te[this.themeName]),this.chromeTheme=this.theme,this.series=se,this.showVolume=ce,this.timeframe=le,this.duration=ue,this.symbol=de,this.instrumentSpec=i.instrument,this.accountSpec=i.account,this.wrapper=document.createElement(`div`),Object.assign(this.wrapper.style,{display:`flex`,flexDirection:`column`,width:`100%`,height:`100%`,overflow:`hidden`,boxSizing:`border-box`});let we=i.headerLayout===`advanced`||i.headerLayout===void 0&&((ne=i.features)==null?void 0:ne.advancedToolbar)===!0,Te=i.headerLayout===`compact`,Ee=i.headerLayout===`mobile`,De=i.hideHeader===!0,ke=i.enableMultipleLayouts===!0,Ae=i.enableSnapshot===!0,je=i.enableCrossHairHeader===!0||i.enableCrosshairToggle===!0;i.layoutSync&&(this.currentSync={...pi,...i.layoutSync}),ke&&typeof i.onLayoutClick==`function`&&console.warn("[ActCharts] `enableMultipleLayouts: true` owns the Layout button — the deprecated `onLayoutClick` callback is ignored. Listen to the `layoutChange` event instead."),Ae&&typeof i.onScreenshotClick==`function`&&console.warn("[ActCharts] `enableSnapshot: true` owns the Snapshot button — the deprecated `onScreenshotClick` callback is ignored. Listen to the `snapshot` event instead."),typeof i.onOneClickTradeToggle==`function`&&typeof i.onOneClickToggle==`function`&&console.warn("[ActCharts] Both `onOneClickTradeToggle` and the deprecated `onOneClickToggle` were provided — using `onOneClickTradeToggle`. Remove the legacy field.");let Me=(re=i.onOneClickTradeToggle)==null?i.onOneClickToggle:re;if(V){let e=e=>{this.timeframe=e,this.emitter.emit(`timeframeChange`,{timeframe:e}),this.emitStateChange(),this.updateCountdownState(),this.triggerLoad(`timeframe`)},t=hd.filter(e=>e.enabled).map(e=>({value:e.short_name,label:`${e.name} (${e.short_name})`,category:e.type})),n=()=>{if(ke)this.openLayoutPopover();else{var e;(e=i.onLayoutClick)==null||e.call(i)}},r=()=>{if(Ae)this.openSnapshotPopover();else{var e;(e=i.onScreenshotClick)==null||e.call(i)}},a=ke||typeof i.onLayoutClick==`function`,o=Ae||typeof i.onScreenshotClick==`function`;if(!De)if(Ee){var Ne,Pe;let t=this.drawingToolsEnabled?{setDrawingTool:e=>{this.setDrawingTool(e)},clearAllDrawings:()=>{this.clearAllDrawings()},addIndicator:(e,t)=>{this.addIndicatorByName(e,t)},removeIndicator:e=>{this.removeIndicator(e)},...je?{setCrosshairEnabled:e=>{this.setCrosshairEnabled(e)}}:{}}:null;this.mobileHeader=new Yr(e,t,(Ne=i.onAskAiClick)==null?null:Ne,this.settingsEnabled?()=>this.openChartSettings():null,e=>this.setSeries(e),this.timeframe,this.series,this.theme,(Pe=this.uiConfig.topBar)==null?void 0:Pe.dropBtnFontFamily,this._enabledGates(),je,this.crosshairEnabled,e=>{this.setCrosshairEnabled(e)}),this.wrapper.appendChild(this.mobileHeader.el)}else if(Te)this.compactToolbar=new Or(e=>this.setSeries(e),e,e=>this.addIndicatorByName(e),this.series,this.timeframe,this.theme,je,this.crosshairEnabled,e=>{this.setCrosshairEnabled(e)}),this.compactToolbar.setIndicatorOptions(t),this.wrapper.appendChild(this.compactToolbar.el);else if(we){var Fe,Ie,Le,Re;this.advancedToolbar=new br(e=>this.setSeries(e),e,e=>this.addIndicatorByName(e),()=>this.openChartSettings(),()=>this.toggleFullscreen(),this.drawingToolsEnabled?()=>this.toggleDrawingTools():null,this.drawingToolsEnabled,this.settingsEnabled,this.fullscreenEnabled,this.series,this.timeframe,this.theme,this.compareDataLoader?()=>this.openComparePicker():void 0,n,Me,r,a,o,(Fe=i.priceSourceSelector)==null?null:Fe,this.tickClosePriceSource,e=>this._applyPriceSource(e,!0),je,this.crosshairEnabled,e=>{this.setCrosshairEnabled(e)},((Ie=i.features)==null?void 0:Ie.pnlPill)===!0,((Le=i.pnlPill)==null?void 0:Le.visible)!==!1,e=>{this.setPnlPillVisible(e)},i.headerOverflowMenu===!0,(Re=i.timeframes)==null?null:Re,this._onAddAlert?()=>{var e;(e=this._onAddAlert)==null||e.call(this,this._currentMarketPrice())}:null),this.advancedToolbar.setIndicatorOptions(t),this.wrapper.appendChild(this.advancedToolbar.el),this.advancedToolbar.setFullscreen(this.isFullscreen)}else{var ze,Be,Ve,He;let s=this._durationTimeframeMap;this.topBar=new qn(e=>this.setSeries(e),e,e=>this.addIndicatorByName(e),(e,t)=>{var n,r;this.duration=e,this.timeframe=t,(n=this._tb)==null||n.setTimeframe(t),(r=this.bottomBar)==null||r.setActive(e),this.emitter.emit(`durationChange`,{duration:e,timeframe:t}),this.emitStateChange(),this.updateCountdownState(),this.triggerLoad(`duration`)},()=>this.openChartSettings(),()=>this.toggleFullscreen(),this.drawingToolsEnabled?()=>this.toggleDrawingTools():null,this.drawingToolsEnabled,this.settingsEnabled,this.fullscreenEnabled,this.tfcEnabled,this.tfcActive,this.tfcEnabled?e=>{this.setTfcActive(e)}:null,this.series,this.timeframe,null,s,this.theme,this.uiConfig.topBar,this.labels.topBar,()=>this.emitUiState(),a,o,n,r,Me==null?null:Me,(ze=i.priceSourceSelector)==null?null:ze,this.tickClosePriceSource,e=>this._applyPriceSource(e,!0),je,this.crosshairEnabled,e=>{this.setCrosshairEnabled(e)},((Be=i.features)==null?void 0:Be.pnlPill)===!0,((Ve=i.pnlPill)==null?void 0:Ve.visible)!==!1,e=>{this.setPnlPillVisible(e)},(He=i.timeframes)==null?null:He),this.topBar.setIndicatorOptions(t),this.wrapper.appendChild(this.topBar.el),this.topBar.setFullscreen(this.isFullscreen)}ke&&(this.layoutPopover=new hi(this.theme,this.currentPresetId,this.currentSync,e=>this.handleLayoutPresetSelect(e),e=>this.handleSyncToggle(e),()=>this.emitUiState())),Ae&&(this.snapshotPopover=new gi(this.theme,e=>this.handleSnapshot(e),()=>this.emitUiState()))}let Ue=document.createElement(`div`);if(Object.assign(Ue.style,{display:`flex`,flex:`1`,minHeight:`0`,overflow:`hidden`,position:`relative`}),V&&this.drawingToolsEnabled&&(this.leftBar=new Ci(e=>this.setDrawingTool(e),e=>{switch(e){case`undo`:this.undoDrawing();break;case`redo`:this.redoDrawing();break;case`delete_selected`:this.deleteSelectedDrawing();break;case`clear_all`:this.clearAllDrawings();break;case`hide_all`:this.hideAllDrawings();break;case`show_all`:this.showAllDrawings();break;case`lock_all`:this.lockAllDrawings();break;case`unlock_all`:this.unlockAllDrawings();break}},()=>{var e;this.leftBarVisible=!1,(e=this._tb)==null||e.setDrawingsBtnActive(!1)},this.theme,this.uiConfig.drawingToolbar,this.labels.drawingToolbar,this._enabledGates()),Ue.appendChild(this.leftBar.el)),this.canvasWrap=document.createElement(`div`),Object.assign(this.canvasWrap.style,{flex:`1`,position:`relative`,overflow:`hidden`,touchAction:`none`}),this.canvas=document.createElement(`canvas`),Object.assign(this.canvas.style,{position:`absolute`,top:`0`,left:`0`,width:`100%`,height:`100%`,pointerEvents:`none`}),this.canvasWrap.appendChild(this.canvas),this.tradeCanvas=document.createElement(`canvas`),Object.assign(this.tradeCanvas.style,{position:`absolute`,top:`0`,left:`0`,width:`100%`,height:`100%`,pointerEvents:`none`}),this.canvasWrap.appendChild(this.tradeCanvas),this.drawCanvas=document.createElement(`canvas`),Object.assign(this.drawCanvas.style,{position:`absolute`,top:`0`,left:`0`,width:`100%`,height:`100%`,cursor:`crosshair`,touchAction:`none`,userSelect:`none`}),this.drawCanvas.style.webkitUserSelect=`none`,this.drawCanvas.style.webkitTouchCallout=`none`,this.canvasWrap.appendChild(this.drawCanvas),this.textInputEl=document.createElement(`input`),this.textInputEl.type=`text`,this.textInputEl.enterKeyHint=`go`,Object.assign(this.textInputEl.style,{position:`absolute`,display:`none`,zIndex:`15`,background:`transparent`,border:`none`,borderBottom:`1px solid #2196f3`,color:`#f5f5f5`,font:`16px system-ui, sans-serif`,outline:`none`,minWidth:`60px`,padding:`0 2px`}),this.canvasWrap.appendChild(this.textInputEl),V){this.loadingOverlayEl=document.createElement(`div`),Object.assign(this.loadingOverlayEl.style,{display:`none`,position:`absolute`,top:`0`,left:`0`,width:`100%`,height:`100%`,alignItems:`center`,justifyContent:`center`,pointerEvents:`none`,zIndex:`20`});let e=document.createElement(`span`);e.textContent=this.labels.chart.loading,Object.assign(e.style,{fontSize:`13px`,padding:`4px 12px`,borderRadius:`4px`}),this.loadingLabelEl=e,this.loadingOverlayEl.appendChild(e),this.canvasWrap.appendChild(this.loadingOverlayEl),this.noDataOverlayEl=document.createElement(`div`),Object.assign(this.noDataOverlayEl.style,{display:`none`,position:`absolute`,top:`0`,left:`0`,width:`100%`,height:`100%`,alignItems:`center`,justifyContent:`center`,pointerEvents:`none`,zIndex:`19`});let t=document.createElement(`span`);t.textContent=this.labels.chart.noData,Object.assign(t.style,{fontSize:`13px`,padding:`4px 12px`,borderRadius:`4px`}),this.noDataLabelEl=t,this.noDataOverlayEl.appendChild(t),this.applyOverlayLabelStyles(),this.canvasWrap.appendChild(this.noDataOverlayEl)}if(V&&!(be&&xe)){if(this.siEl=document.createElement(`div`),Object.assign(this.siEl.style,{position:`absolute`,top:`6px`,left:`6px`,zIndex:`10`,display:`flex`,alignItems:`center`,gap:`8px`,pointerEvents:`none`}),!be){this.siSymbolSpan=document.createElement(`span`),Object.assign(this.siSymbolSpan.style,{color:this.theme.tooltip.text,fontSize:`13px`,fontFamily:`inherit`,fontWeight:`700`,letterSpacing:`-0.025em`,display:de?`inline`:`none`}),this.siSymbolSpan.textContent=de==null?``:de;let e=()=>{var e;let t=(e=i.symbolNameDecoration)==null?`underline`:e;t===`hover`?(Pd(),this.siSymbolSpan.classList.add(Nd),this.siSymbolSpan.tabIndex=0,this.siSymbolSpan.style.textDecoration=`none`):this.siSymbolSpan.style.textDecoration=t===`none`?`none`:`underline`};me?(Object.assign(this.siSymbolSpan.style,{cursor:`pointer`,pointerEvents:`auto`}),e(),this.siSymbolSpan.addEventListener(`click`,()=>{var e,t;me((e=(t=this.siSymbolSpan)==null?void 0:t.textContent)==null?``:e)})):pe&&(fe&&(this.isins=fe),this.isinPickerModal=new ou(this.chromeTheme,pe,()=>this.emitUiState()),this.getFloatingRoot().appendChild(this.isinPickerModal.el),Object.assign(this.siSymbolSpan.style,{cursor:`pointer`,pointerEvents:`auto`}),e(),this.siSymbolSpan.addEventListener(`click`,()=>{var e;this.isinPickerModal.show(this.isins,(e=this.siSymbolSpan.textContent)==null?``:e)})),this.siStreamDot=document.createElement(`span`),this.siStreamDot.className=`live-dot`,Object.assign(this.siStreamDot.style,{width:`8px`,height:`8px`,borderRadius:`9999px`,background:this.theme.ui.stream.disconnected,display:`inline-block`,flexShrink:`0`})}xe||(this.siOHLCSpan=document.createElement(`span`),Object.assign(this.siOHLCSpan.style,{fontSize:`11px`,fontFamily:`inherit`,whiteSpace:`nowrap`}),this.siOHLC2Span=document.createElement(`span`),Object.assign(this.siOHLC2Span.style,{fontSize:`11px`,fontFamily:`inherit`,whiteSpace:`nowrap`}));let e=document.createElement(`div`);Object.assign(e.style,{display:`flex`,alignItems:`center`,gap:`8px`}),this.siStreamDot&&e.append(this.siStreamDot),this.siSymbolSpan&&e.append(this.siSymbolSpan),this.siOHLCSpan&&e.append(this.siOHLCSpan),this.siEl.append(e),this.siOHLC2Span&&this.siEl.append(this.siOHLC2Span),this.canvasWrap.appendChild(this.siEl)}if(V&&(this.indicatorOverlay=new ul(this.theme,this.uiConfig.indicatorOverlay,this.labels.chart),this.canvasWrap.appendChild(this.indicatorOverlay.el),this.indicatorSettingsDialog=new dl(this.chromeTheme,this.labels.dialogs,()=>this.emitUiState()),this.getFloatingRoot().appendChild(this.indicatorSettingsDialog.el),this.scrollToEndBtn=document.createElement(`button`),this.scrollToEndBtn.title=this.labels.chart.scrollToLatest,this.applyScrollToEndBtnStyles(),this.scrollToEndBtn.addEventListener(`click`,()=>this.scrollToEnd()),this.canvasWrap.appendChild(this.scrollToEndBtn),this.resetViewBtn=document.createElement(`button`),this.resetViewBtn.title=`Reset view`,this.applyResetViewBtnStyles(),this.resetViewBtn.addEventListener(`click`,()=>this.resetView()),this.canvasWrap.appendChild(this.resetViewBtn)),this.tradeDragHandler=new yu,this.orderTimeDragHandler=new bu,i.onLevelDragEnd&&this.emitter.on(`tradeLevelDragEnd`,i.onLevelDragEnd),i.onLevelEdit&&this.emitter.on(`tradeLevelEdit`,i.onLevelEdit),he){var H;this.tradePopover=new Jl(this.chromeTheme,.01,this.symbol,(e,t,n)=>{var r;(r=this.tradeActionBar)==null||r.hide(),this.createDraftOrder(e,t,n)},this.labels.trade,()=>this.emitUiState(),i.headerLayout===`mobile`),this.canvasWrap.appendChild(this.tradePopover.el),((H=i.features)==null?void 0:H.tradeActionBar)===!0&&(this.tradeActionBar=new Kl({theme:this.chromeTheme,labels:this.labels.trade,onAlert:this._onAddAlert?e=>{var t;(t=this._onAddAlert)==null||t.call(this,e)}:null,onPendingPick:(e,t,n)=>{this.createDraftOrder(e,t,n)},onBulkLevels:(e,t)=>{this.emitter.emit(`bulkLevelsRequested`,{kind:e,price:t,isFullscreen:this.isFullscreen,source:`actionBar`})},onVisibilityChange:()=>this.emitUiState()}),this.canvasWrap.appendChild(this.tradeActionBar.el)),this.tradeButton=new ql(this.theme,this.priceAxisWidth,()=>{if(this._tradeButtonClickData&&this.tradePopover){var e;(e=this.tradeButton)==null||e.hide();let t=this.priceAxisWidth+10+22+4,{price:n,y:r}=this._tradeButtonClickData;if(this.tradeActionBar){this.tradePopover.hide();let e=ml(this.levels,this.draftOrderLabel);this.tradeActionBar.show(n,r,t,{pricePrecision:this.dataStore.getPricePrecision(),buyOrderType:this._orderTypeForPrice(`buy`,n),sellOrderType:this._orderTypeForPrice(`sell`,n),symbol:this.symbol,positionCount:e.count,mixedSides:e.mixed});return}this.tradePopover.show(n,r,t,this.dataStore.getPricePrecision(),this._orderTypeForPrice(`buy`,n),this._orderTypeForPrice(`sell`,n))}},this.labels.trade,this.uiConfig.tradeButton),this.canvasWrap.appendChild(this.tradeButton.el),this.tradeButton.el.addEventListener(`mouseenter`,()=>{this.crosshair=null,this.emitter.emit(`crosshair`,null),this.scheduleRender()}),this.tradeButton.el.addEventListener(`mousemove`,e=>{var t;if(e.buttons!==0)return;let n=(t=this._cachedDrawRect)==null?this.drawCanvas.getBoundingClientRect():t,r=e.clientY-n.top,{priceH:i}=this.getChartLayout();if(qt(r,this.uiConfig.tradeButton.size/2,this.offViewportHitAreas)){var a;(a=this.tradeButton)==null||a.hide();return}if(r>=0&&r<=i){var o,s;(o=this.tradeButton)==null||o.setY(r);let e=(s=this._displayedPriceRange)==null?this.getScaledPriceRange(this.viewport):s,t=this.scaleManager.pixelToPrice(r,e,i);this._tradeButtonClickData={price:t,y:r}}})}if(Ue.appendChild(this.canvasWrap),this.wrapper.appendChild(Ue),V&&Se){var We;let e=this._durationTimeframeMap;this.bottomBar=new yi((e,t)=>{var n;this.duration=e,this.timeframe=t,(n=this._tb)==null||n.setTimeframe(t),this.emitter.emit(`durationChange`,{duration:e,timeframe:t}),this.emitStateChange(),this.updateCountdownState(),this.triggerLoad(`duration`)},(We=this.duration)==null?null:We,this.theme,e,this.uiConfig.bottomBar,this.labels.bottomBar),this.wrapper.appendChild(this.bottomBar.el)}ae.appendChild(this.wrapper),this.themeOverrides&&(this.theme=this.buildTheme(this.themeName),this.chromeTheme=this.buildChromeTheme(this.themeName),this.applyThemeToComponents());let U=this.canvas.getContext(`2d`);if(!U)throw Error(`Canvas 2D context unavailable`);this.ctx=U;let Ge=this.drawCanvas.getContext(`2d`);if(!Ge)throw Error(`Drawing canvas 2D context unavailable`);this.drawCtx=Ge;let Ke=this.tradeCanvas.getContext(`2d`);if(!Ke)throw Error(`Trade canvas 2D context unavailable`);if(this.tradeCtx=Ke,this.showActLogo){let t=new Image;t.onload=()=>{this.logoImage=t,this.scheduleRender()},t.src=e}this.drawingManager.setOnComplete(()=>{var e;(e=this.leftBar)==null||e.setActiveTool(null),this.drawCanvas.style.cursor=`default`}),this.drawingManager.onDrawingsChange=()=>this.emitStateChange(),this.drawingManager.onPointsMutated=e=>{for(let t of e.points){let e=this.barIndexToTimestamp(t.barIndex);e!=null&&(t.timestamp=e)}},this.drawingManager.onStartTextEdit=e=>this.showTextInput(e),this.drawingStylePopover=new nu(this.canvasWrap,this.chromeTheme,(e,t)=>this.updateDrawingStyle(e,t)),this.drawingManager.onSelectionChange=e=>{if(e&&e.complete&&e.locked!==!0){var t,n;let r=this.computeDrawingAnchorPx(e);r?(t=this.drawingStylePopover)==null||t.show(e,r.x,r.y):(n=this.drawingStylePopover)==null||n.hide()}else{var r;(r=this.drawingStylePopover)==null||r.hide()}},this.panHandler=new L(this.drawCanvas,()=>this._targetViewport,e=>{this._targetViewport=e,this.clearDuration(),this.checkNeedMoreData(),this.scheduleRender(),this.scheduleViewportPersist(),this.emitter.emit(`pan`,{viewport:e})},()=>this.dataStore.length,()=>this.scheduleRender(),()=>{var e,t,n,r;return this.drawingManager.getActiveTool()!==null||this.drawingManager.isDraggingDrawing()||this.drawingManager.isResizingDrawing()||this.separatorDrag!==null||this.axisDrag!==null||((e=(t=this.tradeDragHandler)==null?void 0:t.active)==null?!1:e)||((n=(r=this.orderTimeDragHandler)==null?void 0:r.active)==null?!1:n)||this._pendingTradeDrag!==null||this._mobileCrosshairActive},e=>{var t;if(this.priceScaleFactor===1)return;let{priceH:n}=this.getChartLayout(),r=(t=this._displayedPriceRange)==null?this.getScaledPriceRange(this._targetViewport):t,i=(r.max-r.min)/n;this.pricePanOffset+=e*i,this.scheduleRender(),this.scheduleViewportPersist()},()=>{this._isPanning=!0},()=>{this._isPanning=!1},{enabled:i.momentumScrollEnabled,decay:i.momentumDecay,threshold:i.momentumThreshold,maxVelocity:i.momentumMaxVelocity}),this.zoomHandler=new B(this.drawCanvas,()=>this._targetViewport,e=>{this._targetViewport=e,this.clearDuration(),this.checkNeedMoreData(),this.scheduleRender(),this.scheduleViewportPersist(),this.emitter.emit(`zoom`,{viewport:e})},()=>this.dataStore.length,()=>this.scheduleRender(),()=>{var e;return(e=this._cachedDrawRect)==null?this.drawCanvas.getBoundingClientRect():e},()=>this.getChartLayout().chartW,e=>{let t=this._targetViewport,n=t.endIndex-t.startIndex,r=e*(n/this.drawCanvas.width),i=Math.max(0,this.dataStore.length-Math.floor(n/2)),a=Math.max(0,Math.min(i,t.startIndex+r));this._targetViewport={...t,startIndex:a,endIndex:a+n},this.clearDuration(),this.checkNeedMoreData(),this.scheduleRender(),this.emitter.emit(`pan`,{viewport:this._targetViewport}),this.scheduleViewportPersist()}),this.drawCanvas.addEventListener(`mousemove`,this.onMouseMove),this.drawCanvas.addEventListener(`mouseleave`,this.onMouseLeave),this.drawCanvas.addEventListener(`mousedown`,this.onCanvasClick),this.drawCanvas.addEventListener(`dblclick`,this.onDoubleClick),window.addEventListener(`mouseup`,this.onMouseUp),this.drawCanvas.addEventListener(`touchstart`,this.onDrawingTouchStart,{passive:!1}),this.drawCanvas.addEventListener(`touchmove`,this.onDrawingTouchMove,{passive:!1}),this.drawCanvas.addEventListener(`touchend`,this.onDrawingTouchEnd,{passive:!1}),this.drawCanvas.addEventListener(`touchcancel`,this.onDrawingTouchCancel,{passive:!1}),this.drawCanvas.addEventListener(`contextmenu`,e=>e.preventDefault()),document.addEventListener(`keydown`,this.onKeyDown);let qe=()=>{var e;let t=!!document.fullscreenElement;t||(this._isCssFullscreen=!1),(e=this._tb)==null||e.setFullscreen(t),this.reparentFloatingElements()};if(this.wrapper.addEventListener(`fullscreenchange`,qe),document.addEventListener(`fullscreenchange`,qe),this.resizeObserver=new ResizeObserver(()=>this.onResize()),this.resizeObserver.observe(this.canvasWrap),this.onResize(),((ie=i.features)==null?void 0:ie.pnlPill)===!0&&this.initPnlPill(i),this.dataLoader&&this.triggerLoad(`initial`),this.initCompareUi(),i.initialCompares&&i.initialCompares.length>0){let e=i.initialCompares.slice(),t=this.emitter.on(`dataLoaded`,()=>{t();for(let t of e)this.addCompare(t)})}}resetData(){return++this._loadGeneration,this.setLoading(!1),this.setNoData(!1),this.drawingManager.clearAll(),this.levels=[],this.refreshPnlPill(),this._draftQtyPillArea=void 0,this._pendingBracketOrderLabel=null,this.loadData([])}loadData(e,t=!1){var n,r,i;this.isFetching=!1,this.noMoreData=!1,this._suppressTicks=!1,e.length>0&&this.setNoData(!1),this.liveBidAsk=null,this.liveLtp=null,this.pricePanOffset=0,this.priceScaleFactor=1,this._displayedPriceRange=null,this._lockedAutoFitBase=null,this.dataStore.set(e),this.updateCompareRange();let a=((n=(r=this._cachedWrapRect)==null?void 0:r.width)==null?this.canvasWrap.getBoundingClientRect().width:n)-this.priceAxisWidth,o=this._autoVisibleBars&&a>0?a:void 0,s=Id(this.mobileBarDivisor,this.explicitMobileDivisor,this.defaultVisibleBars,this.defaultMobileVisibleBars,o,this.targetCandleWidth);this._defaultVisibleBars=s,this.viewport={...this.viewport,startIndex:t?0:Math.max(0,e.length-s+Ld),endIndex:e.length+Ld},this._targetViewport={...this.viewport};let c=this.dataStore.hasVolumeData;if(c||(this.showVolume=!1),(i=this._tb)==null||i.setVolumeControl(this.showVolume,c),this.showVolume&&c){var l;(l=this.indicatorOverlay)==null||l.addPill(`VOL`,this.theme.volume.up,`VOL`,`Chart`,!0,()=>{var e,t;this.setVolume(!1),(e=this.indicatorOverlay)==null||e.removePill(`VOL`),(t=this._tb)==null||t.setVolumeControl(!1,this.dataStore.hasVolumeData)},null,()=>{var e;this.setVolume(!this.showVolume),(e=this.indicatorOverlay)==null||e.updatePillVisibility(`VOL`,this.showVolume),this.scheduleRender()})}if(this.recomputeIndicators(),this.reanchorDrawingsByTimestamp(),this._pendingViewportRestore){let e=this._pendingViewportRestore;this._pendingViewportRestore=null,e.priceScale&&(this.priceScaleFactor=e.priceScale.factor,this.pricePanOffset=e.priceScale.panOffset,this._displayedPriceRange=null,this._lockedAutoFitBase=null),e.viewport&&this.applyViewportFromTimestamps(e.viewport.startTime,e.viewport.endTime)}return this.updateCountdownState(),this.scheduleRender(),this}prependData(e){if(e.length===0)return this.noMoreData=!0,this.isFetching=!1,this;let t=this.dataStore.prepend(e);return t>0&&(this.viewport={...this.viewport,startIndex:this.viewport.startIndex+t,endIndex:this.viewport.endIndex+t},this._targetViewport={...this.viewport},this.drawingManager.shiftBarIndices(t),this.reanchorDrawingsByTimestamp(),this.recomputeIndicators(),this.updateCompareRange(),this.scheduleRender()),this.isFetching=!1,this}setLoading(e){return this.loadingOverlayEl&&(this.loadingOverlayEl.style.display=e?`flex`:`none`),e&&this.setNoData(!1),this}setNoData(e){return this.noDataOverlayEl&&(this.noDataOverlayEl.style.display=e?`flex`:`none`),this}timeframeToMs(e){var t;let n=6e4;return(t={"1m":1*n,"3m":3*n,"4m":4*n,"5m":5*n,"10m":10*n,"15m":15*n,"30m":30*n,"1h":60*n,"2h":120*n,"4h":240*n,"8h":480*n,"1D":1440*n,"1W":10080*n,"1M":43200*n}[e])==null?1440*n:t}getBaseInterval(){var e,t;return(e=(t=this.aggregateFrom)==null?void 0:t[this.timeframe])==null?this.timeframe:e}shouldAggregate(){let e=this.getBaseInterval();return e!==this.timeframe&&this.timeframeToMs(e)<this.timeframeToMs(this.timeframe)}maybeAggregate(e){return this.shouldAggregate()?gd(e,this.timeframeToMs(this.timeframe)):e}timeframeToInterval(e){var t;return(t={"1m":`1min`,"3m":`3min`,"4m":`4min`,"5m":`5min`,"10m":`10min`,"15m":`15min`,"30m":`30min`,"1h":`1h`,"2h":`2h`,"4h":`4h`,"8h":`8h`,"1D":`1day`,"1W":`1week`,"1M":`1month`}[e])==null?`1day`:t}durationToMs(e){var t;let n=1440*60*1e3;return(t={"1D":1*n,"5D":5*n,"1M":30*n,"3M":90*n,"6M":180*n,"1Y":365*n,"5Y":5*365*n,All:20*365*n}[e])==null?365*n:t}triggerLoad(e){if(!this.dataLoader)return;let t=++this._loadGeneration;this._suppressTicks=!0,this.isFetching=!0,this.noMoreData=!1;let n=new Date,r=this.maxCandles*this.timeframeToMs(this.timeframe),i=this.duration?this.durationToMs(this.duration):r,a=this.duration?i:r,o=this.timeframeToInterval(this.getBaseInterval());this.setLoading(!0);let s=this.dataLoader,c=[1,5,25,125],l=this.minInitialBars,u=this.maxLookbackMs,d=(r,i)=>{s({start:i,end:n,interval:o,priceSource:this.tickClosePriceSource}).then(s=>{if(t!==this._loadGeneration)return;let f=this.maybeAggregate(s),p=n.getTime()-i.getTime()>=u;if(f.length>=l||r+1>=c.length||p){this.loadData(f,e===`duration`),this.setLoading(!1),f.length===0&&this.setNoData(!0),this.emitter.emit(`dataLoaded`,{timeframe:this.timeframe,interval:o,start:i,end:n,priceSource:this.tickClosePriceSource});return}let m=Math.min(a*c[r+1],u),h=new Date(n.getTime()-m);d(r+1,h)}).catch(()=>{t===this._loadGeneration&&(this.isFetching=!1,this.setLoading(!1))})},f=Math.min(a*c[0],u);d(0,new Date(n.getTime()-f))}checkNeedMoreData(){if(!this.dataLoader||this.isFetching||this.noMoreData)return;let e=Math.max(20,this.prefetchThreshold);if(this._targetViewport.startIndex>e||this.dataStore.length===0)return;let t=this._loadGeneration;this.isFetching=!0;let n=this.dataStore.all[0].time,r=new Date(n-1),i=this.maxCandles*this.timeframeToMs(this.timeframe),a=this.duration?this.durationToMs(this.duration):i,o=this.duration?a:i,s=this.timeframeToInterval(this.getBaseInterval());this.setLoading(!0);let c=this.dataLoader,l=[1,5,25,125],u=this.minInitialBars,d=this.maxLookbackMs,f=(e,n)=>{c({start:n,end:r,interval:s,priceSource:this.tickClosePriceSource}).then(i=>{if(t!==this._loadGeneration)return;let a=this.maybeAggregate(i),s=r.getTime()-n.getTime()>=d;if(a.length>=u||e+1>=l.length||s){this.prependData(a),this.setLoading(!1);return}let c=Math.min(o*l[e+1],d),p=new Date(r.getTime()-c);f(e+1,p)}).catch(()=>{t===this._loadGeneration&&(this.isFetching=!1,this.setLoading(!1))})},p=Math.min(o*l[0],d);f(0,new Date(r.getTime()-p))}addIndicator(e,t){var n,r;if(e.pane===`sub`&&this.activeIndicators.filter(e=>e.indicator.pane===`sub`).length>=this.maxSubPanes)return this;let i=Cd.find(t=>t.shortName===e.name),a=i?Object.fromEntries(i.fields.map(e=>[e.key,e.default])):{};a.timeframe=`Chart`,t&&Object.assign(a,t);let o=uu(e.name,++this.indicatorInstanceSeq),s={instanceId:o,indicator:e,shortName:e.name,currentParams:a,visible:!0};this.activeIndicators.push(s),this.dataStore.length>0&&this.indicatorResults.set(o,e.compute(this.dataStore.all));let c=i!==void 0&&i.fields.length>0,l=Sd(e.name,a,i),u=(n=a.timeframe)==null?`Chart`:n;if(e.pane===`sub`){let t=new ul(this.theme,this.uiConfig.indicatorOverlay,this.labels.chart);Object.assign(t.el.style,{position:`absolute`,top:`6px`,left:`6px`,zIndex:`10`}),this.canvasWrap.appendChild(t.el),this.subPaneOverlays.set(o,t),t.addPill(o,e.color,l,u,s.visible,()=>this.removeIndicator(o),c?()=>this.openIndicatorSettings(o):null,()=>{s.visible=!s.visible,t.updatePillVisibility(o,s.visible),this.scheduleRender(),this.emitStateChange()})}else{var d;(d=this.indicatorOverlay)==null||d.addPill(o,e.color,l,u,s.visible,()=>this.removeIndicator(o),c?()=>this.openIndicatorSettings(o):null,()=>{var e;s.visible=!s.visible,(e=this.indicatorOverlay)==null||e.updatePillVisibility(o,s.visible),this.scheduleRender(),this.emitStateChange()})}return(r=this._tb)==null||r.setIndicatorOptionActive(e.name,!0,this.activeIndicators.filter(t=>t.shortName===e.name).length),this.scheduleRender(),this.emitStateChange(),this.isRestoringState||this.emitter.emit(`indicatorAdded`,{instanceId:o,shortName:s.shortName,params:{...s.currentParams}}),this}removeIndicator(e){let t=fu(this.activeIndicators,e);if(t.length===0)return this;let n=new Set(t.map(e=>e.instanceId));this.activeIndicators=this.activeIndicators.filter(e=>!n.has(e.instanceId));for(let e of t){this.indicatorResults.delete(e.instanceId),this.subPaneScaleFactors.delete(e.instanceId),this.paneHeightOverrides.delete(e.instanceId);let t=this.subPaneOverlays.get(e.instanceId);if(t)t.destroy(),t.el.remove(),this.subPaneOverlays.delete(e.instanceId);else{var r;(r=this.indicatorOverlay)==null||r.removePill(e.instanceId)}}let i=new Set(t.map(e=>e.shortName));for(let e of i){var a;let t=this.activeIndicators.filter(t=>t.shortName===e).length;(a=this._tb)==null||a.setIndicatorOptionActive(e,t>0,t)}if(this.scheduleRender(),this.emitStateChange(),!this.isRestoringState)for(let e of t)this.emitter.emit(`indicatorRemoved`,{instanceId:e.instanceId,shortName:e.shortName});return this}addIndicatorByName(e,t){if(e===`VOL`){var n;if(this.setVolume(!this.showVolume),this.showVolume){var r;(r=this.indicatorOverlay)==null||r.addPill(`VOL`,this.theme.volume.up,`VOL`,`Chart`,!0,()=>{var e,t;this.setVolume(!1),(e=this.indicatorOverlay)==null||e.removePill(`VOL`),(t=this._tb)==null||t.setVolumeControl(!1,this.dataStore.hasVolumeData)},null,()=>{var e;this.setVolume(!this.showVolume),(e=this.indicatorOverlay)==null||e.updatePillVisibility(`VOL`,this.showVolume),this.scheduleRender()})}else{var i;(i=this.indicatorOverlay)==null||i.removePill(`VOL`)}(n=this._tb)==null||n.setVolumeControl(this.showVolume,this.dataStore.hasVolumeData);return}let a=Cd.find(t=>t.shortName===e),o=bd.find(t=>t.shortName===e);if(!(!a&&!o)){if(vd.has(e)&&this.activeIndicators.some(t=>t.shortName===e)){this.removeIndicator(e);return}if(a){let n=Object.fromEntries(a.fields.map(e=>[e.key,e.default]));if(a.fields.some(e=>e.key===`color`)){let t=this.activeIndicators.filter(t=>t.shortName===e).length;n.color=du(yd,t)}t&&Object.assign(n,t);let r={...n};delete r.timeframe,this.addIndicator(a.factory(r),n)}else o&&this.addIndicator(o.factory(),t)}}openIndicatorSettings(e){var t;let n=this.activeIndicators.find(t=>t.instanceId===e);if(!n)return;let r=Cd.find(e=>e.shortName===n.shortName);if(!r||r.fields.length===0)return;let i={...r,fields:[...r.fields,xd]};(t=this.indicatorSettingsDialog)==null||t.show(i,n.currentParams,t=>this.updateIndicatorParams(e,t),()=>this.removeIndicator(e))}updateIndicatorParams(e,t){var n;let r=this.activeIndicators.find(t=>t.instanceId===e);if(!r)return;let i=Cd.find(e=>e.shortName===r.shortName);if(!i)return;let{timeframe:a,...o}=t,s=i.factory(o);r.indicator=s,r.currentParams={...t},this.indicatorResults.delete(e),this.dataStore.length>0&&this.indicatorResults.set(e,s.compute(this.dataStore.all));let c=(n=this.subPaneOverlays.get(e))==null?this.indicatorOverlay:n;c==null||c.updatePillColor(e,s.color),c==null||c.updatePillLabel(e,Sd(r.shortName,r.currentParams,i)),c==null||c.updatePillTimeframe(e,a==null?`Chart`:a),this.scheduleRender(),this.emitStateChange()}on(e,t){return this.emitter.on(e,t)}canvasColorOverride(e,t){var n,r,i,a,o,s;let c=this.settingsCanvasColors[e];if(c)return{...t&&{...c.background!==void 0&&{background:c.background},...c.grid!==void 0&&{grid:c.grid},...c.axisText!==void 0&&{axisText:c.axisText},...c.axisBorder!==void 0&&{axisBorder:c.axisBorder},...c.crosshair!==void 0&&{crosshair:c.crosshair}},...((n=(r=(i=(a=(o=c.candleUp)==null?c.candleDown:o)==null?c.wickUp:a)==null?c.wickDown:i)==null?c.borderUp:r)==null?c.borderDown:n)!==void 0&&{candle:{...c.candleUp!==void 0&&{up:c.candleUp},...c.candleDown!==void 0&&{down:c.candleDown},...c.wickUp!==void 0&&{wickUp:c.wickUp},...c.wickDown!==void 0&&{wickDown:c.wickDown},...c.borderUp!==void 0&&{borderUp:c.borderUp},...c.borderDown!==void 0&&{borderDown:c.borderDown}}},...((s=c.volumeUp)==null?c.volumeDown:s)!==void 0&&{volume:{...c.volumeUp!==void 0&&{up:c.volumeUp},...c.volumeDown!==void 0&&{down:c.volumeDown}}}}}overlayTextColor(e){let t=this.settingsCanvasColors[this.themeName];return(t==null?void 0:t.axisText)===void 0?(t==null?void 0:t.background)===void 0?e:u(this.theme.background):t.axisText}buildTheme(e){var t;return p(d(d(e===`dark`?g:_,(t=this.themeOverrides)==null?void 0:t[e]),this.canvasColorOverride(e,!0)),this.wrapper)}buildChromeTheme(e){var t;return p(d(d(e===`dark`?g:_,(t=this.themeOverrides)==null?void 0:t[e]),this.canvasColorOverride(e,!1)),this.wrapper)}initPnlPill(e){var t,n,r;this.pnlPill=new Ml({theme:this.theme,labels:this.labels.pnlPill,currency:(t=e.pnlPill)==null?void 0:t.currency,format:(n=e.pnlPill)==null?void 0:n.format,getBounds:()=>{var e;let t=(e=this._cachedWrapRect)==null?this.canvasWrap.getBoundingClientRect():e;return{width:t.width,height:t.height,right:this.priceAxisWidth,bottom:this.timeAxisHeight}},onToggleExpand:()=>this.togglePnlPillExpanded(),onBulkLevels:()=>{ml(this.levels,this.draftOrderLabel).mixed||this.emitter.emit(`bulkLevelsRequested`,{kind:`sl`,price:null,isFullscreen:this.isFullscreen,source:`pill`})},onCloseAll:()=>this.emitPnlPillCloseAll()}),this.canvasWrap.appendChild(this.pnlPill.el),this.pnlPillVisible=((r=e.pnlPill)==null?void 0:r.visible)!==!1,this.pnlPill.setHidden(!this.pnlPillVisible),this.pnlPill.setExpanded(this.pnlPillExpanded&&this.tfcActive),this.emitter.on(`tfcToggle`,({enabled:e})=>{var t;(t=this.pnlPill)==null||t.setExpanded(this.pnlPillExpanded&&e)}),this.refreshPnlPill()}refreshPnlPill(){var e,t;this.pnlPill&&(this.pnlPill.update(ml(this.levels,this.draftOrderLabel),this.symbol),(e=this.advancedToolbar)==null||e.setPnlPillActive(this.pnlPillVisible,this.symbol),(t=this.topBar)==null||t.setPnlPillActive(this.pnlPillVisible,this.symbol))}setPnlPillVisible(e){var t,n,r;return this.pnlPillVisible===e?this:(this.pnlPillVisible=e,(t=this.pnlPill)==null||t.setHidden(!e),(n=this.advancedToolbar)==null||n.setPnlPillActive(e,this.symbol),(r=this.topBar)==null||r.setPnlPillActive(e,this.symbol),this.emitter.emit(`pnlPillToggle`,{visible:e}),this)}togglePnlPillExpanded(){var e;this.pnlPillExpanded=!this.pnlPillExpanded,this.pnlPillExpanded&&this.tfcEnabled&&!this.tfcActive&&this.setTfcActive(!0),this.pnlPillExpanded||this.expandedClusters.clear(),(e=this.pnlPill)==null||e.setExpanded(this.pnlPillExpanded&&this.tfcActive),this.recomputeRenderStyle(),this.renderTradeLayer()}emitPnlPillCloseAll(){let e=ml(this.levels,this.draftOrderLabel);e.count!==0&&this.emitter.emit(`pnlPillCloseAll`,{count:e.count,pnl:e.hasPnl?e.pnl:null,labels:e.positions.map(e=>e.label),data:e.positions.map(e=>e.data),isFullscreen:this.isFullscreen})}applyThemeToComponents(){var e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g;(e=this._tb)==null||e.setTheme(this.chromeTheme),(t=this.bottomBar)==null||t.setTheme(this.chromeTheme),(n=this.leftBar)==null||n.setTheme(this.chromeTheme),(r=this.tradePopover)==null||r.setTheme(this.chromeTheme),(i=this.tradeActionBar)==null||i.setTheme(this.chromeTheme),(a=this.drawingStylePopover)==null||a.setTheme(this.chromeTheme),(o=this._draftQtyFlyout)==null||o.setTheme(this.chromeTheme),(s=this.indicatorSettingsDialog)==null||s.setTheme(this.chromeTheme),(c=this.chartSettingsDialog)==null||c.setTheme(this.chromeTheme),(l=this.layoutPopover)==null||l.setTheme(this.chromeTheme),(u=this.snapshotPopover)==null||u.setTheme(this.chromeTheme),(d=this.comparePickerModal)==null||d.setTheme(this.chromeTheme),(f=this.isinPickerModal)==null||f.setTheme(this.chromeTheme),(p=this.tradeButton)==null||p.setTheme(this.theme,this.priceAxisWidth),(m=this.compareLegend)==null||m.setTheme(this.theme),(h=this.pnlPill)==null||h.setTheme(this.theme),(g=this.indicatorOverlay)==null||g.setTheme(this.theme);for(let e of this.subPaneOverlays.values())e.setTheme(this.theme)}setTheme(e){return this.themeName=e,this.theme=this.buildTheme(e),this.chromeTheme=this.buildChromeTheme(e),this.applyThemeToComponents(),this.applyScrollToEndBtnStyles(),this.applyResetViewBtnStyles(),this.applyMobileDrawingFlyoutTheme(),this.siSymbolSpan&&(this.siSymbolSpan.style.color=this.overlayTextColor(this.theme.tooltip.text)),this.siStreamDot&&(this.siStreamDot.style.background=this.theme.ui.stream[this.streamStatus]),this.applyOverlayLabelStyles(),this.scheduleRender(),this.emitStateChange(),this}getTimeframe(){return this.timeframe}setDuration(e,t){var n,r,i;let a=(n=t==null?this._durationTimeframeMap[e]:t)==null?this.timeframe:n;return this.duration=e,this.timeframe=a,(r=this._tb)==null||r.setTimeframe(a),(i=this.bottomBar)==null||i.setActive(e),this.emitter.emit(`durationChange`,{duration:e,timeframe:a}),this.emitStateChange(),this.updateCountdownState(),this.triggerLoad(`duration`),this}getDuration(){var e;return(e=this.duration)==null?null:e}setTimeframe(e){var t;return this.timeframe=e,(t=this._tb)==null||t.setTimeframe(e),this.emitter.emit(`timeframeChange`,{timeframe:e}),this.emitStateChange(),this.updateCountdownState(),this.triggerLoad(`timeframe`),this}setCrosshair(e){var t,n;if(e===null||!this.crosshairEnabled){if(this.crosshair===null)return;this.crosshair=null,this.scheduleRender();return}let{chartW:r,priceH:i}=this.getChartLayout(),a=(t=this._displayedPriceRange)==null?this.getScaledPriceRange(this.viewport):t,o=this.scaleManager.xToPixel(e.barIndex,this.viewport,r),s=this.scaleManager.yToPixel(e.price,a,i),c=this.dataStore.all,l=(n=c[Math.max(0,Math.min(c.length-1,Math.round(e.barIndex)))])==null?null:n;this.crosshair={x:o,y:s,barIndex:e.barIndex,price:e.price,bar:l},this.scheduleRender()}setViewport(e){e.startIndex===this.viewport.startIndex&&e.endIndex===this.viewport.endIndex||(this.viewport={...this.viewport,startIndex:e.startIndex,endIndex:e.endIndex},this._targetViewport={...this.viewport},this.scheduleRender())}timeToBarIndex(e){let t=this.dataStore.all;if(t.length===0)return null;let n=t[0],r=t[t.length-1];return!n||!r||e<n.time||e>r.time?null:this.timestampToBarIndex(e)}setThemeOverrides(e){return this.themeOverrides=e,this.theme=this.buildTheme(this.themeName),this.chromeTheme=this.buildChromeTheme(this.themeName),this.applyThemeToComponents(),this.scheduleRender(),this}setCanvasColors(e){return this.settingsCanvasColors=e==null?{}:e,this.setTheme(this.themeName),this}setTimezone(e){return this.timezone=e===`local`?Intl.DateTimeFormat().resolvedOptions().timeZone:e,this.scheduleRender(),this}setSeries(e){var t;return this.series=e,(t=this._tb)==null||t.setSeries(e),this.emitter.emit(`seriesChange`,{series:e}),this.scheduleRender(),this.emitStateChange(),this}setTfcActive(e){var t;if(!this.tfcEnabled)return this;if(this.tfcActive=e,(t=this._tb)==null||t.setTfcActive(e),!e){var n,r,i;(n=this.tradeButton)==null||n.hide(),(r=this.tradePopover)==null||r.hide(),(i=this.tradeActionBar)==null||i.hide(),this.draftOrderLabel!==null&&this.removeDraftOrder()}return this.chartSettingsDialog&&(this.chartSettingsDialog.destroy(),this.chartSettingsDialog=null),this.renderTradeLayer(),this.emitter.emit(`tfcToggle`,{enabled:e}),this.emitStateChange(),this}setCrosshairEnabled(e){var t,n,r,i;if(this.crosshairEnabled===e)return this;if(this.crosshairEnabled=e,(t=this.advancedToolbar)==null||t.setCrosshairActive(e),(n=this.topBar)==null||n.setCrosshairActive(e),(r=this.compactToolbar)==null||r.setCrosshairActive(e),(i=this.mobileHeader)==null||i.setCrosshairActive(e),!e){var a;this.crosshair!==null&&(this.crosshair=null,this.emitter.emit(`crosshair`,null)),this._mobileCrosshairActive=!1,(a=this.tradeButton)==null||a.hide(),this.scheduleRender()}return this.emitter.emit(`crosshairToggle`,{enabled:e}),this}clearDuration(){var e,t;this.duration!==void 0&&(this.duration=void 0,(e=this._tb)==null||e.setActiveDuration(void 0),(t=this.bottomBar)==null||t.setActive(void 0),this.emitStateChange())}setVolume(e){return this.showVolume=e,this.scheduleRender(),this.emitStateChange(),this}dismissAllUI(){var e,t,n,r,i,a,o,s;return this.isAnyUIOpen()?((e=this._draftQtyFlyout)==null||e.hide(),(t=this.isinPickerModal)==null||t.hide(),(n=this.comparePickerModal)==null||n.hide(),(r=this.indicatorSettingsDialog)==null||r.hide(),(i=this.chartSettingsDialog)==null||i.hide(),(a=this.tradePopover)==null||a.hide(),(o=this.tradeActionBar)==null||o.hide(),(s=this._tb)==null||s.closeDropdown(),this.hideMobileDrawingFlyout(),!0):!1}isAnyUIOpen(){var e,t,n,r,i,a,o,s,c,l;return((e=this._draftQtyFlyout)==null?void 0:e.isVisible)===!0||((t=this.isinPickerModal)==null?void 0:t.isVisible)===!0||((n=this.comparePickerModal)==null?void 0:n.isVisible)===!0||((r=this.indicatorSettingsDialog)==null?void 0:r.isVisible)===!0||((i=this.chartSettingsDialog)==null?void 0:i.isVisible)===!0||((a=this.tradePopover)==null?void 0:a.isVisible)===!0||((o=this.tradeActionBar)==null?void 0:o.isVisible)===!0||((s=this._tb)==null?void 0:s.hasOpenDropdown)===!0||((c=(l=this._mobileDrawingFlyout)==null?void 0:l.style.display)==null?`none`:c)!==`none`}emitUiState(){this.emitter.emit(`uiStateChange`,{hasOpenUI:this.isAnyUIOpen()})}emitStateChange(){this.isRestoringState||this.emitter.emit(`stateChange`,{symbol:this.symbol,state:this.getState()})}getState(){return{symbol:this.symbol,timeframe:this.timeframe,duration:this.duration,series:this.series,showVolume:this.showVolume,theme:this.themeName,indicators:this.activeIndicators.map(e=>({shortName:e.shortName,params:{...e.currentParams},visible:e.visible,instanceId:e.instanceId})),drawings:this.drawingManager.getDrawingsSnapshot().map(e=>({...e,points:e.points.map(e=>{var t;return{...e,timestamp:(t=e.timestamp)==null?this.barIndexToTimestamp(e.barIndex):t}})})),positionRenderStyle:this.baseRenderStyle(),tradeDisplayFilter:this.tradeDisplayFilter,canvasColors:Object.keys(this.settingsCanvasColors).length>0?{...this.settingsCanvasColors}:void 0,tfcEnabled:this.tfcActive,viewport:this.getViewportTimestamps(),priceScale:this.priceScaleFactor!==1||this.pricePanOffset!==0?{factor:this.priceScaleFactor,panOffset:this.pricePanOffset}:void 0,compares:this.compareManager&&this.compareManager.isActive()?this.compareManager.list().map(e=>e.symbol):void 0}}getViewportTimestamps(){if(this.dataStore.all.length===0)return;let e=this.barIndexToTimestamp(this.viewport.startIndex),t=this.barIndexToTimestamp(this.viewport.endIndex);if(!(e==null||t==null))return{startTime:e,endTime:t}}applyViewportFromTimestamps(e,t){let n=this.timestampToBarIndex(e),r=this.timestampToBarIndex(t);this.viewport={...this.viewport,startIndex:n,endIndex:r},this._targetViewport={...this.viewport}}setState(e){this.isRestoringState=!0;try{if(this.setSeries(e.series),this.setVolume(e.showVolume),e.theme!=null&&this.setTheme(e.theme),e.timeframe!=null){var t,n,r;this.timeframe=e.timeframe,this.duration=e.duration,(t=this._tb)==null||t.setTimeframe(e.timeframe),(n=this._tb)==null||n.setActiveDuration(e.duration),(r=this.bottomBar)==null||r.setActive(e.duration),this.updateCountdownState()}let s=this.activeIndicators.map(e=>e.instanceId);for(let e of s)this.removeIndicator(e);for(let t of e.indicators){var i,a;let e=Cd.find(e=>e.shortName===t.shortName);if(!e)continue;let n={...t.params};delete n.timeframe,this.addIndicator(e.factory(n),t.params);let r=this.activeIndicators[this.activeIndicators.length-1];if(!r)continue;r.currentParams={...t.params};let o=(i=this.subPaneOverlays.get(r.instanceId))==null?this.indicatorOverlay:i;t.visible===!1&&(r.visible=!1,o==null||o.updatePillVisibility(r.instanceId,!1));let s=(a=t.params.timeframe)==null?`Chart`:a;o==null||o.updatePillTimeframe(r.instanceId,s)}let c=e.drawings.map(e=>({...e,points:e.points.map(e=>e.timestamp==null||this.dataStore.all.length===0?e:{...e,barIndex:this.timestampToBarIndex(e.timestamp)})}));if(this.drawingManager.loadDrawings(c),e.positionRenderStyle&&(this.positionRenderStyleOverride=e.positionRenderStyle,this.positionRenderStyle=e.positionRenderStyle),e.tradeDisplayFilter&&(this.tradeDisplayFilter=e.tradeDisplayFilter),e.canvasColors&&(this.settingsCanvasColors=e.canvasColors),e.tfcEnabled!==void 0&&this.tfcEnabled){var o;this.tfcActive=e.tfcEnabled,(o=this._tb)==null||o.setTfcActive(e.tfcEnabled)}if(e.priceScale&&(this.priceScaleFactor=e.priceScale.factor,this.pricePanOffset=e.priceScale.panOffset,this._displayedPriceRange=null,this._lockedAutoFitBase=null),e.viewport&&(this.dataStore.all.length>0?this.applyViewportFromTimestamps(e.viewport.startTime,e.viewport.endTime):this._pendingViewportRestore={viewport:e.viewport,priceScale:e.priceScale}),e.compares&&e.compares.length>0&&this.compareManager){this.compareManager.clear();for(let t of e.compares)this.compareManager.add(t);this.refreshCompareLegend()}}finally{this.isRestoringState=!1}return this.emitStateChange(),this.scheduleRender(),this}barIndexToTimestamp(e){let t=this.dataStore.all,n=t.length;if(n===0)return;let r=t[0];if(!r)return;if(n===1)return r.time;let i=Math.floor(e),a=e-i;if(i<0){let n=t[1];return n?r.time+e*(n.time-r.time):r.time}if(i>=n-1){let i=t[n-1],a=t[n-2];return!i||!a?r.time:i.time+(e-(n-1))*(i.time-a.time)}let o=t[i],s=t[i+1];return!o||!s?r.time:o.time+a*(s.time-o.time)}timestampToBarIndex(e){let t=this.dataStore.all,n=t.length;if(n===0)return 0;let r=t[0];if(!r||n===1)return 0;if(e<=r.time){let n=t[1];if(!n)return 0;let i=n.time-r.time;return i>0?(e-r.time)/i:0}let i=n-1,a=t[i],o=t[i-1];if(!a||!o)return 0;if(e>=a.time){let t=a.time-o.time;return i+(t>0?(e-a.time)/t:0)}let s=0,c=i;for(;s<c;){var l,u;let n=s+c+1>>1;((l=(u=t[n])==null?void 0:u.time)==null?0:l)<=e?s=n:c=n-1}let d=t[s],f=t[s+1];if(!d||!f)return s;let p=f.time-d.time;return s+(p>0?(e-d.time)/p:0)}reanchorDrawingsByTimestamp(){if(this.dataStore.all.length!==0)for(let e of this.drawingManager.getDrawings())for(let t of e.points){if(t.timestamp==null){let e=this.barIndexToTimestamp(t.barIndex);e!=null&&(t.timestamp=e);continue}t.barIndex=this.timestampToBarIndex(t.timestamp)}}backfillDrawingTimestamps(){if(this.dataStore.all.length!==0)for(let e of this.drawingManager.getDrawings())for(let t of e.points){if(t.timestamp!=null)continue;let e=this.barIndexToTimestamp(t.barIndex);e!=null&&(t.timestamp=e)}}resetChartSettings(){return this.setState({symbol:this.symbol,series:`candlestick`,theme:`dark`,timeframe:`1D`,duration:void 0,showVolume:!0,indicators:[],drawings:[]}),this.positionRenderStyleOverride=null,localStorage.removeItem(this.RENDER_STYLE_LS_KEY),this.recomputeRenderStyle(),this.settingsCanvasColors={},this.setTheme(`dark`),this.emitStateChange(),this}setInstrument(e){return this.instrumentSpec=e,this.resolvedInstrument=null,this.scheduleRender(),this}getInstrument(){let e=this.dataStore.getPricePrecision();return(!this.resolvedInstrument||this.resolvedInstrumentPrecision!==e)&&(this.resolvedInstrument=M(this.instrumentSpec,e),this.resolvedInstrumentPrecision=e),this.resolvedInstrument}setAccount(e){return this.accountSpec=e,this.scheduleRender(),this}getAccount(){return this.accountSpec}setSymbol(e){var t,n;return this.symbol=e,(t=this.tradePopover)==null||t.setSymbol(e),this.siSymbolSpan&&(this.siSymbolSpan.textContent=e,this.siSymbolSpan.style.display=e?`inline`:`none`),(n=this.isinPickerModal)==null||n.setCurrentSymbol(e),this.tickActivityTimer!==null&&(clearTimeout(this.tickActivityTimer),this.tickActivityTimer=null),this.siStreamDot&&(this.siStreamDot.style.background=this.theme.ui.stream[this.streamStatus]),this.liveBidAsk=null,this.liveLtp=null,this}setIsins(e){var t;return this.isins=e,(t=this.isinPickerModal)==null||t.setIsins(e),this}renderSymbolInfoOHLC(e){if(!this.siOHLCSpan)return;if(!e){this.siOHLCSpan.innerHTML=``,this.siOHLC2Span&&(this.siOHLC2Span.innerHTML=``);return}let t=e.close>=e.open?this.theme.candle.up:this.theme.candle.down,n=this.overlayTextColor(this.theme.axisText),r=e=>e.toFixed(this.dataStore.getPricePrecision()),i=e=>e>=1e6?(e/1e6).toFixed(2)+`M`:e>=1e3?(e/1e3).toFixed(1)+`K`:e.toFixed(0),a=this.labels.ohlc,o=(e,t)=>{e.innerHTML=``;for(let[r,i,a]of t){let t=document.createElement(`span`);t.style.marginRight=`8px`;let o=document.createElement(`span`);o.textContent=r+`\xA0`,o.style.color=n,o.style.opacity=`0.6`;let s=document.createElement(`span`);s.textContent=i,s.style.color=a,t.append(o,s),e.appendChild(t)}};o(this.siOHLCSpan,[[a.open,r(e.open),n],[a.high,r(e.high),n]]),this.siOHLC2Span&&o(this.siOHLC2Span,[[a.low,r(e.low),n],[a.close,r(e.close),t],...e.volume!=null&&e.volume!==0?[[a.volume,i(e.volume),n]]:[]])}setMinLots(e){var t;return console.warn(`[acttrader-charts] setMinLots() is deprecated. Pass minLots in the initial ChartConfig instead.`),this._minLots=e,(t=this.tradePopover)==null||t.setLots(e),this}setDraftQty(e){return this.draftOrderLabel&&this.setLevelQty(this.draftOrderLabel,e),this}updateLevelQty(e,t){return!e||e===this.draftOrderLabel||!Number.isFinite(t)||t<=0||this.setLevelQty(e,t),this}setLevelQty(e,t){var n,r;let i=this.levels.findIndex(t=>t.label===e);if(i===-1)return;let a=this.levels[i];if(a.lots===t)return;this.originalQtyByLabel.has(e)||this.originalQtyByLabel.set(e,a.lots);let o=(n=(r=this.originalQtyByLabel.get(e))==null?a.lots:r)==null?t:n;this.levels=[...this.levels.slice(0,i),{...a,lots:t},...this.levels.slice(i+1)],e!==this.draftOrderLabel&&this.pendingQtyChanges.set(e,t),this.emitter.emit(`tradeLevelQtyChange`,{label:e,type:e===this.draftOrderLabel?`draft`:a.type,newLots:t,previousLots:o,isFullscreen:this.isFullscreen}),this.renderTradeLayer()}openDraftQtyFlyout(e){var t;this._draftQtyFlyout||(this._draftQtyFlyout=new ru(this.chromeTheme,e=>{this._activeQtyPillLabel&&this.setLevelQty(this._activeQtyPillLabel,e)},()=>this.emitUiState()),this.getFloatingRoot().appendChild(this._draftQtyFlyout.el)),this._activeQtyPillLabel=e.label;let n=this.levels.find(t=>t.label===e.label),r=(t=n==null?void 0:n.lots)==null?this._qtyFieldMin:t,i=this.canvasWrap.getBoundingClientRect(),a=i.left+e.pillX,o=i.top+e.pillY+e.pillH;this._draftQtyFlyout.show(a,o,r,this._qtyFieldMin,this._qtyFieldMax)}setDraftOrderLabels(e){return console.warn(`[acttrader-charts] setDraftOrderLabels() is deprecated and is a no-op. DraftOrderQtyInput has been removed.`),this}setDrawingTool(e){var t;return this.drawingManager.setActiveTool(e),(t=this.leftBar)==null||t.setActiveTool(e),this.drawCanvas.style.cursor=e?`crosshair`:`default`,this.scheduleRender(),this}undoDrawing(){return this.drawingManager.undo(),this.scheduleRender(),this}redoDrawing(){return this.drawingManager.redo(),this.scheduleRender(),this}hideAllDrawings(){return this.drawingManager.hideAll(),this.scheduleRender(),this}showAllDrawings(){return this.drawingManager.showAll(),this.scheduleRender(),this}lockAllDrawings(){return this.drawingManager.lockAll(),this.scheduleRender(),this}unlockAllDrawings(){return this.drawingManager.unlockAll(),this.scheduleRender(),this}deleteSelectedDrawing(){return this.drawingManager.deleteSelected(),this.hideMobileDrawingFlyout(),this.scheduleRender(),this}clearAllDrawings(){return this.drawingManager.clearAll(),this.scheduleRender(),this}getActiveTool(){return this.drawingManager.getActiveTool()}getDrawings(){return this.drawingManager.getDrawings()}getDrawingById(e){return this.drawingManager.getDrawingById(e)}getSelectedDrawing(){return this.drawingManager.getSelectedDrawing()}updateDrawingStyle(e,t){return this.drawingManager.updateDrawingStyle(e,t),this.scheduleRender(),this}connectStream(e){return this.streamAdapter=e,e.onTick(e=>this.onTick(e)),e.onStatus(e=>{this.streamStatus=e,this.siStreamDot&&(this.siStreamDot.style.background=this.theme.ui.stream[e],this.siStreamDot.title=`Stream ${e}`),this.emitter.emit(`streamStatus`,{status:e})}),e.connect(),this}disconnectStream(){var e;return(e=this.streamAdapter)==null||e.disconnect(),this.streamAdapter=null,this}setTickClosePriceSource(e){return this._applyPriceSource(e,!1),this}_applyPriceSource(e,t){var n,r;let i=e!==this.tickClosePriceSource;if(this.tickClosePriceSource=e,(n=this.topBar)==null||n.setPriceSource(e),(r=this.advancedToolbar)==null||r.setPriceSource(e),this.scheduleRender(),i&&this._reloadOnPriceSourceChange&&this.dataLoader&&!this._isDestroyed){let e=this.getViewportTimestamps();if(e){var a;this._pendingViewportRestore={...(a=this._pendingViewportRestore)==null?{}:a,viewport:e}}this.triggerLoad(`priceSource`)}t&&this.emitter.emit(`priceSourceChange`,{source:e})}setShowLtpPrice(e){return this.showLtpPrice=e,this.scheduleRender(),this}setShowAskLine(e){return this.showAskLine=e,this.scheduleRender(),this}setShowBidLine(e){return this.showBidLine=e,this.scheduleRender(),this}pushTick(e){let t=e.T==null?Date.now():typeof e.T==`string`?new Date(e.T).getTime():e.T;return this.onTick({time:t,bid:e.B,ask:e.A,volume:e.LTPV!=null&&e.LTPV>0?e.LTPV:0,ltp:e.LTP!=null&&e.LTP>0?e.LTP:void 0}),this}setLevels(e,t,n,r,i,a){let o=e.map(e=>{if(r===`position`){let r={label:String(e[t]),price:Number(e[n]),type:`position`,data:e};return e.text!==void 0&&(r.text=String(e.text)),i!==void 0&&e[i]!==void 0&&(r.pnl=Number(e[i])),a!==void 0&&e[a]!==void 0&&(r.pnlText=String(e[a])),e.side!==void 0&&(r.side=e.side),e.stopLossPrice!==void 0&&(r.stopLossPrice=Number(e.stopLossPrice)),e.stopLossTrailing&&(r.stopLossTrailing=!0),e.takeProfitPrice!==void 0&&(r.takeProfitPrice=Number(e.takeProfitPrice)),e.contractSize!==void 0&&(r.contractSize=Number(e.contractSize)),e.valuePerPoint!==void 0&&(r.valuePerPoint=Number(e.valuePerPoint)),e.currencySymbol!==void 0&&(r.currencySymbol=String(e.currencySymbol)),e.entryPriceEditable&&(r.entryPriceEditable=!0),e.orderType!==void 0&&(r.orderType=e.orderType),e.lots!==void 0&&(r.lots=Number(e.lots)),e.timestamp!==void 0&&(r.timestamp=Number(e.timestamp)),e.timeDraggable&&(r.timeDraggable=!0),r}if(r===`pending`){var o,s;let r={label:String(e[t]),price:Number(e[n]),type:`pending`,side:(o=e.side)==null?`buy`:o,orderType:(s=e.orderType)==null?`limit`:s,data:e};return e.text!==void 0&&(r.text=String(e.text)),e.lots!==void 0&&(r.lots=Number(e.lots)),e.stopLossPrice!==void 0&&(r.stopLossPrice=Number(e.stopLossPrice)),e.stopLossTrailing&&(r.stopLossTrailing=!0),e.takeProfitPrice!==void 0&&(r.takeProfitPrice=Number(e.takeProfitPrice)),e.ToClose!==void 0&&(r.ToClose=String(e.ToClose)),e.timestamp!==void 0&&(r.timestamp=Number(e.timestamp)),e.timeDraggable&&(r.timeDraggable=!0),r}return{label:String(e[t]),price:Number(e[n]),type:`trade`,text:e.text===void 0?void 0:String(e.text),data:e}});if(this.hideLevelConfirmCancel&&this.pendingLevelDrags.size>0)for(let e of o){let t=this.pendingLevelDrags.get(e.label);if(!(t!=null&&t.length))continue;let n=e;t.every(t=>t.isRemoval?t.field===`stopLoss`?n.stopLossPrice===void 0:n.takeProfitPrice===void 0:t.field===`main`?e.price===t.newPrice:t.field===`stopLoss`?n.stopLossPrice===t.newPrice:n.takeProfitPrice===t.newPrice)&&(this.pendingLevelDrags.delete(e.label),this.selectedTradeLabel===e.label&&(this.selectedTradeLabel=null))}if(this.pendingQtyChanges.size>0)for(let e=0;e<o.length;e++){let t=o[e],n=this.pendingQtyChanges.get(t.label);if(n===void 0||t.type!==`pending`&&t.type!==`position`)continue;let r=t;this.originalQtyByLabel.set(t.label,r.lots),o[e]={...r,lots:n}}let s=this.draftOrderLabel===null?void 0:this.levels.find(e=>e.type===r&&e.label===this.draftOrderLabel&&!o.some(t=>t.label===e.label)),c=new Map(this.levels.map(e=>[e.label,e]));if(this.levels=[...this.levels.filter(e=>e.type!==r),...o,...s?[s]:[]],this._revealNewBrackets){let e=[];for(let t of o){let n=c.get(t.label);if(!n)continue;let r=t;r.stopLossPrice!==void 0&&n.stopLossPrice===void 0&&e.push(r.stopLossPrice),r.takeProfitPrice!==void 0&&n.takeProfitPrice===void 0&&e.push(r.takeProfitPrice)}e.length>0&&this._revealPrices(e)}if(this._timeAnchorOverride.size>0)for(let e of[...this._timeAnchorOverride.keys()]){let t=this.levels.find(t=>t.label===e);if(!t){this._timeAnchorOverride.delete(e);continue}let n=t.timestamp,r=this._timeAnchorOverride.get(e);this._honorsLevelTimestamp(t)&&n!==void 0&&r!==void 0&&Math.round(this.timestampToBarIndex(n))===Math.round(this.timestampToBarIndex(r))&&this._timeAnchorOverride.delete(e)}return this.selectedTradeLabel!==null&&!this.levels.some(e=>e.label===this.selectedTradeLabel)&&(this.selectedTradeLabel=null),this.recomputeRenderStyle(),this.renderTradeLayer(),this.refreshPnlPill(),this}removeLevelByLabel(e){return this.levels=this.levels.filter(t=>t.label!==e),this.renderTradeLayer(),this.refreshPnlPill(),this}showDraftOrder(e,t,n){if(this.draftOrderLabel){let e=this.levels.find(e=>e.label===this.draftOrderLabel);if((e==null?void 0:e.side)===t&&(e==null?void 0:e.orderType)===n)return this}return this.clearDraftOrder(),this.createDraftOrder(t,e,n),this}showMarketDraft(e,t){this.clearDraftOrder();let n=`__draft_${Date.now()}`,r={type:`pending`,label:n,side:t,price:e,orderType:`market`,data:{_isDraft:!0}};return this.levels=[...this.levels,r],this.draftOrderLabel=n,this.renderTradeLayer(),this.emitter.emit(`draftInitiated`,{side:t,price:e,orderType:`market`,isFullscreen:this.isFullscreen}),this}clearDraftOrder(){return this.removeDraftOrder(),this}updateLevelBracket(e,t,n){var r;let i=t===`sl`?`stopLoss`:`takeProfit`,a=this.levels.find(t=>t.label===e);if(!a)return this;let o=t===`sl`?a.stopLossPrice:a.takeProfitPrice,s=(r=this.pendingLevelDrags.get(e))==null?[]:r,c=s.find(e=>e.field===i),l=s.filter(e=>e.field!==i);if(this.levels=this.levels.map(r=>{if(r.label!==e)return r;let i=r;return t===`sl`?{...i,stopLossPrice:n==null?void 0:n}:{...i,takeProfitPrice:n==null?void 0:n}}),n===null){if(o!==void 0){var u;let e=(u=c==null?void 0:c.oldPrice)==null?o:u;l.push({field:i,newPrice:o,oldPrice:e,isRemoval:!0})}l.length===0?this.pendingLevelDrags.delete(e):this.pendingLevelDrags.set(e,l)}else{var d;let t=(d=c==null?void 0:c.isNew)==null?o===void 0:d,r=c&&!c.isRemoval?c.oldPrice:o==null?n:o;l.push({field:i,newPrice:n,oldPrice:r,isNew:t}),this.pendingLevelDrags.set(e,l),this._revealNewBrackets&&t&&this._revealPrices([n])}return this.renderTradeLayer(),this}addLevelBracket(e,t){var n,r,i,a,o;let s=this.levels.find(t=>t.label===e);if(!s)return this;let c=t===`sl`?`stopLoss`:`takeProfit`,l=t===`sl`?s.stopLossPrice!==void 0:s.takeProfitPrice!==void 0,u=(n=(r=this.pendingLevelDrags.get(e))==null?void 0:r.some(e=>e.field===c&&!e.isRemoval))==null?!1:n;if(l||u)return this;let{priceH:d}=this.getChartLayout(),f=(i=this._displayedPriceRange)==null?this.getScaledPriceRange(this.viewport):i,p=this.scaleManager.yToPixel(s.price,f,d),m=(a=s.side)==null?`buy`:a,h=p+(m===`buy`&&t===`sl`||m===`sell`&&t===`tp`?30:-30),g=this.scaleManager.pixelToPrice(h,f,d);this.updateLevelBracket(e,t,g);let _=((o=this.pendingLevelDrags.get(e))==null?[]:o).filter(e=>e.field!==c);return _.push({field:c,newPrice:g,oldPrice:g,isNew:!0}),this.pendingLevelDrags.set(e,_),this.emitter.emit(`tradeLevelBracketActivated`,{label:e,bracketType:t,price:g,isFullscreen:this.isFullscreen}),this.emitter.emit(`tradeLevelDrag`,{label:e,newPrice:g,data:s.data,bracketType:t===`sl`?`stopLoss`:`takeProfit`,isFullscreen:this.isFullscreen}),this}addBracket(e,t){var n,r;if(t)return this.addLevelBracket(t,e);if(!this.draftOrderLabel)return this;let i=this.draftOrderLabel,a=this.levels.find(e=>e.label===i);if(!a||(e===`sl`?a.stopLossPrice!==void 0:a.takeProfitPrice!==void 0))return this;let{priceH:o}=this.getChartLayout(),s=(n=this._displayedPriceRange)==null?this.getScaledPriceRange(this.viewport):n,c=this.scaleManager.yToPixel(a.price,s,o),l=(r=a.side)==null?`buy`:r,u=c+(l===`buy`&&e===`sl`||l===`sell`&&e===`tp`?30:-30),d=this.scaleManager.pixelToPrice(u,s,o);return this.updateDraftOrderBracket(e,d),this.emitter.emit(`tradeLevelBracketActivated`,{label:``,bracketType:e,price:d,isFullscreen:this.isFullscreen}),this.emitter.emit(`tradeLevelDrag`,{label:i,newPrice:d,data:a.data,bracketType:e===`sl`?`stopLoss`:`takeProfit`,isFullscreen:this.isFullscreen}),this}removeBracket(e,t){if(t){var n,r;let i=e===`sl`?`stopLoss`:`takeProfit`,a=this.levels.find(e=>e.label===t);if(!a)return this;let o=(n=this.pendingLevelDrags.get(t))==null?void 0:n.find(e=>e.field===i),s=o&&!o.isRemoval?o.newPrice:e===`sl`?a.stopLossPrice:a.takeProfitPrice;if(s===void 0)return this;let c=((r=this.pendingLevelDrags.get(t))==null?[]:r).filter(e=>e.field!==i);return c.push({field:i,newPrice:s,oldPrice:s,isRemoval:!0}),this.pendingLevelDrags.set(t,c),this.renderTradeLayer(),this}return e===`sl`?this.draftBracketPnl={...this.draftBracketPnl,sl:void 0}:this.draftBracketPnl={...this.draftBracketPnl,tp:void 0},this.updateDraftOrderBracket(e,null)}updateLevelMainPrice(e,t){var n;let r=this.levels.find(t=>t.label===e);if(!r)return this;let i=(n=this.pendingLevelDrags.get(e))==null?[]:n,a=i.find(e=>e.field===`main`),o=a?a.oldPrice:r.price,s=i.filter(e=>e.field!==`main`);return s.push({field:`main`,newPrice:t,oldPrice:o}),this.pendingLevelDrags.set(e,s),r.price=t,this.renderTradeLayer(),this}setBracketLabelMode(e,t){return this._bracketLabel={mode:e,currencySymbol:t==null?this._bracketLabel.currencySymbol:t},this.scheduleRender(),this}setDraftBracketPnl(e,t){return e===`sl`?this.draftBracketPnl={...this.draftBracketPnl,sl:t==null?void 0:t}:this.draftBracketPnl={...this.draftBracketPnl,tp:t==null?void 0:t},this.renderTradeLayer(),this}updateDraftOrderBracket(e,t){return this.draftOrderLabel?(this.levels=this.levels.map(n=>{if(n.label!==this.draftOrderLabel)return n;let r=n;return e===`sl`?{...r,stopLossPrice:t==null?void 0:t}:{...r,takeProfitPrice:t==null?void 0:t}}),this._revealNewBrackets&&t!==null&&this._revealPrices([t]),this.scheduleRender(),this):this}updateDraftOrderPrice(e){if(!this.draftOrderLabel)return!1;this.levels=this.levels.map(t=>t.label===this.draftOrderLabel?{...t,price:e}:t);let t=this.pendingLevelDrags.get(this.draftOrderLabel);if(t){let n=t.find(e=>e.field===`main`);n&&(n.newPrice=e)}return this.renderTradeLayer(),!0}cancelLevelEdit(e){var t;if(this.undoIsNewBracketMutations(e),this.pendingLevelDrags.delete(e),this.pendingQtyChanges.has(e)){this.pendingQtyChanges.delete(e);let t=this.levels.findIndex(t=>t.label===e);if(t!==-1&&this.originalQtyByLabel.has(e)){let n=this.originalQtyByLabel.get(e),r=this.levels[t];this.levels=[...this.levels.slice(0,t),{...r,lots:n},...this.levels.slice(t+1)]}this.originalQtyByLabel.delete(e)}return e===((t=this.draftOrderLabel)==null?this.selectedTradeLabel:t)&&(this.draftBracketPnl={}),this.selectedTradeLabel===e&&(this.selectedTradeLabel=null),this.renderTradeLayer(),this}cancelCurrentEdit(){return this.draftOrderLabel?this.clearDraftOrder():this.selectedTradeLabel&&this.revertPendingChanges(this.selectedTradeLabel),this}selectLevel(e){if(!this.draftOrderLabel&&e!==this.selectedTradeLabel&&(this.draftBracketPnl={}),this.selectedTradeLabel=e,e!==null){this.crosshair=null;let t=this.lastClusters.find(t=>t.members.some(t=>t.level.label===e));t&&this.expandedClusters.add(t.id)}return this.renderTradeLayer(),this}setLevelClusteringEnabled(e){return this.levelClusteringEnabled=e,this.expandedClusters.clear(),this.renderTradeLayer(),this}setClusterThresholdDistance(e){return this.clusterThresholdDistance=e,this.expandedClusters.clear(),this.renderTradeLayer(),this}setTradeLevelButtonScale(e){return this.tradeLevelButtonScale=Math.min(Math.max(e,1),3),this.renderTradeLayer(),this}toDataUrl(){return this.captureToDataUrl()}drawOnto(e,t,n,r,i){e.fillStyle=this.theme.background,e.fillRect(t,n,r,i);let a=[this.canvas,this.drawCanvas];for(let o of a)o&&o.width&&o.height&&e.drawImage(o,t,n,r,i)}captureToDataUrl(){let e=this.canvas;if(!e.width||!e.height)return null;let t=document.createElement(`canvas`);t.width=e.width,t.height=e.height;let n=t.getContext(`2d`);if(!n)return null;n.fillStyle=this.theme.background,n.fillRect(0,0,t.width,t.height);let r=[this.canvas,this.drawCanvas];for(let e of r)e&&e.width&&e.height&&n.drawImage(e,0,0);return t.toDataURL(`image/png`)}openLayoutPopover(){var e,t,n;if(!this.layoutPopover)return;let r=(e=(t=this.advancedToolbar)==null?void 0:t.getLayoutBtnEl())==null?(n=this.topBar)==null?void 0:n.getLayoutBtnEl():e;if(r)if(this.layoutPopover.isVisible)this.layoutPopover.hide();else{let e=this.getFloatingRoot();this.layoutPopover.el.parentElement!==e&&e.appendChild(this.layoutPopover.el),this.layoutPopover.show(r)}}openSnapshotPopover(){var e,t,n;if(!this.snapshotPopover)return;let r=(e=(t=this.advancedToolbar)==null?void 0:t.getSnapshotBtnEl())==null?(n=this.topBar)==null?void 0:n.getSnapshotBtnEl():e;if(r)if(this.snapshotPopover.isVisible)this.snapshotPopover.hide();else{let e=this.getFloatingRoot();this.snapshotPopover.el.parentElement!==e&&e.appendChild(this.snapshotPopover.el),this.snapshotPopover.show(r)}}handleLayoutPresetSelect(e){var t,n,r,i;this.currentPresetId=e;let a=fi(e);(t=this._tb)==null||(n=t.setLayoutPresetIcon)==null||n.call(t,a.icon,!0),(r=this.layoutPopover)==null||r.setPreset(e),(i=this.layoutPopover)==null||i.hide(),this.emitter.emit(`layoutChange`,{presetId:e,preset:a,sync:this.currentSync})}handleSyncToggle(e){var t;this.currentSync={...this.currentSync,[e]:!this.currentSync[e]},(t=this.layoutPopover)==null||t.setSync(this.currentSync),this.emitter.emit(`layoutChange`,{presetId:this.currentPresetId,preset:fi(this.currentPresetId),sync:this.currentSync})}async handleSnapshot(e){var t;let n=this.captureToDataUrl();if(n){if(this.emitter.emit(`snapshot`,{dataUrl:n,action:e}),e===`download`){let e=document.createElement(`a`);e.download=`${this.snapshotFileName()}.png`,e.href=n,e.click()}else try{var r;let e=await(await fetch(n)).blob(),t=globalThis.ClipboardItem;t&&(r=navigator.clipboard)!=null&&r.write&&await navigator.clipboard.write([new t({"image/png":e})])}catch(e){}(t=this.snapshotPopover)==null||t.hide()}}snapshotFileName(){let e=this.symbol.trim().replace(/[\\/:*?"<>|]+/g,`_`).replace(/\s+/g,`_`);return e.length>0?e:`chart-${Date.now()}`}setLayoutPreset(e){this.handleLayoutPresetSelect(e)}getLayoutPreset(){return this.currentPresetId}getLayoutSync(){return{...this.currentSync}}setLayoutSync(e){var t;let n={...this.currentSync,...e};Object.keys(n).some(e=>n[e]!==this.currentSync[e])&&(this.currentSync=n,(t=this.layoutPopover)==null||t.setSync(this.currentSync))}destroy(){var e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y;this._isDestroyed=!0,this.panHandler.destroy(),this.zoomHandler.destroy(),this.resizeObserver.disconnect(),this.disposeVvListener(),(e=this.indicatorOverlay)==null||e.destroy();for(let e of this.subPaneOverlays.values())e.destroy();this.subPaneOverlays.clear(),(t=this.indicatorSettingsDialog)==null||t.destroy(),(n=this.chartSettingsDialog)==null||n.destroy(),(r=this.isinPickerModal)==null||r.destroy(),(i=this.comparePickerModal)==null||i.destroy(),(a=this.compareLegend)==null||a.destroy(),(o=this.pnlPill)==null||o.destroy(),(s=this.tradePopover)==null||s.destroy(),(c=this.tradeActionBar)==null||c.destroy(),(l=this.drawingStylePopover)==null||l.destroy(),(u=this._draftQtyFlyout)==null||u.destroy(),(d=this.advancedToolbar)==null||d.destroy(),(f=this.mobileHeader)==null||f.destroy(),(p=this.leftBar)==null||p.destroy(),this.drawCanvas.removeEventListener(`mousemove`,this.onMouseMove),this.drawCanvas.removeEventListener(`mouseleave`,this.onMouseLeave),this.drawCanvas.removeEventListener(`mousedown`,this.onCanvasClick),this.drawCanvas.removeEventListener(`dblclick`,this.onDoubleClick),window.removeEventListener(`mouseup`,this.onMouseUp),this.drawCanvas.removeEventListener(`touchstart`,this.onDrawingTouchStart),this.drawCanvas.removeEventListener(`touchmove`,this.onDrawingTouchMove),this.drawCanvas.removeEventListener(`touchend`,this.onDrawingTouchEnd),this.drawCanvas.removeEventListener(`touchcancel`,this.onDrawingTouchCancel),document.removeEventListener(`keydown`,this.onKeyDown),(m=this.streamAdapter)==null||m.disconnect(),this.rafId!==null&&cancelAnimationFrame(this.rafId),this.scrollAnimId!==null&&cancelAnimationFrame(this.scrollAnimId),this.stopCountdownLoop(),(h=this.resetViewBtn)==null||h.remove(),(g=this.textInputEl)==null||g.remove(),(_=this._mobileDrawingFlyout)==null||_.remove(),(v=this.layoutPopover)==null||v.destroy(),(y=this.snapshotPopover)==null||y.destroy(),this.wrapper.remove()}createMobileDrawingFlyout(){let e=document.createElement(`div`);Object.assign(e.style,{position:`fixed`,display:`none`,alignItems:`center`,gap:`2px`,zIndex:`10000`,background:this.theme.background,border:`1px solid ${this.theme.axisBorder}`,borderRadius:`8px`,padding:`4px`,boxShadow:`0 4px 16px rgba(0,0,0,0.45)`,pointerEvents:`auto`});let t=(e,t,n)=>{let r=document.createElement(`button`);return r.title=t,r.innerHTML=e,Object.assign(r.style,{display:`flex`,alignItems:`center`,justifyContent:`center`,width:`34px`,height:`34px`,padding:`0`,border:`none`,borderRadius:`6px`,background:`transparent`,color:n?this.theme.candle.down:this.theme.axisText,cursor:`pointer`,flexShrink:`0`}),r.addEventListener(`pointerenter`,()=>{r.style.background=n?`${this.theme.candle.down}22`:this.theme.axisBorder}),r.addEventListener(`pointerleave`,()=>{r.style.background=`transparent`}),r},n=t(pn,`Delete drawing`,!0);n.addEventListener(`pointerdown`,e=>{e.stopPropagation(),this.deleteSelectedDrawing(),this.hideMobileDrawingFlyout()});let r=t(un,`Deselect`,!1);return r.addEventListener(`pointerdown`,e=>{e.stopPropagation(),this.drawingManager.selectDrawing(null),this.hideMobileDrawingFlyout(),this.scheduleRender()}),e.appendChild(n),e.appendChild(r),this.wrapper.appendChild(e),e}showMobileDrawingFlyout(e,t){if(!Fd())return;this._mobileDrawingFlyout||(this._mobileDrawingFlyout=this.createMobileDrawingFlyout());let n=this._mobileDrawingFlyout,r=n.style.display!==`none`&&n.style.display!==``;n.style.display=`flex`,requestAnimationFrame(()=>{let r=n.offsetWidth||78,i=n.offsetHeight||42,a=window.innerWidth,o=window.innerHeight,s=Math.min(Math.max(e-r/2,8),a-r-8),c=Math.min(Math.max(t-i-12,8),o-i-8);n.style.left=`${s}px`,n.style.top=`${c}px`}),r||this.emitUiState()}hideMobileDrawingFlyout(){if(this._mobileDrawingFlyout){let e=this._mobileDrawingFlyout.style.display!==`none`&&this._mobileDrawingFlyout.style.display!==``;this._mobileDrawingFlyout.style.display=`none`,e&&this.emitUiState()}}applyMobileDrawingFlyoutTheme(){if(!this._mobileDrawingFlyout)return;let e=this._mobileDrawingFlyout;e.style.background=this.theme.background,e.style.border=`1px solid ${this.theme.axisBorder}`;let[t,n]=Array.from(e.querySelectorAll(`button`));t&&(t.style.color=this.theme.candle.down),n&&(n.style.color=this.theme.axisText)}scheduleRender(){this._isDestroyed||this.rafId===null&&(this.rafId=requestAnimationFrame(()=>{this.rafId=null,this.render(),this.renderTradeLayer()}))}startCountdownLoop(){if(this.countdownRafId!==null)return;let e=0,t=n=>{if(!this.countdownActive){this.countdownRafId=null;return}n-e>=1e3&&(e=n,this.scheduleRender()),this.countdownRafId=requestAnimationFrame(t)};this.countdownRafId=requestAnimationFrame(t)}stopCountdownLoop(){this.countdownActive=!1,this.countdownRafId!==null&&(cancelAnimationFrame(this.countdownRafId),this.countdownRafId=null)}updateCountdownState(){var e;let t=this.candleCountdownTimeframes===`all`?!0:((e=this.candleCountdownTimeframes)==null?[`1m`,`3m`,`4m`,`5m`,`10m`,`15m`,`30m`,`1h`,`2h`,`4h`,`8h`]:e).includes(this.timeframe),n=(this.showCandleCountdown||this.showPriceAxisCountdown)&&t&&this.dataStore.length>0;n&&!this.countdownActive?(this.countdownActive=!0,this.startCountdownLoop()):!n&&this.countdownActive&&this.stopCountdownLoop()}openChartSettings(){this.chartSettingsDialog||(this.chartSettingsDialog=new pl(this.chromeTheme,{tradeDisplayFilter:this.tradeDisplayFilter,positionRenderStyle:this.baseRenderStyle(),theme:this.themeName,showTradeLevelsAlways:this.showTradeLevelsAlways,showPriceAxisCountdown:this.showPriceAxisCountdown},this.labels.dialogs,!!this._onOrderSubmit&&this.tfcActive,this.enableThemeToggle,()=>this.emitUiState()),this.getFloatingRoot().appendChild(this.chartSettingsDialog.el)),this.chartSettingsDialog.show({tradeDisplayFilter:this.tradeDisplayFilter,positionRenderStyle:this.baseRenderStyle(),theme:this.themeName,showTradeLevelsAlways:this.showTradeLevelsAlways,showPriceAxisCountdown:this.showPriceAxisCountdown,canvasColors:{...this.settingsCanvasColors}},e=>{if(this.tradeDisplayFilter=e.tradeDisplayFilter,this.positionRenderStyleOverride=e.positionRenderStyle,localStorage.setItem(this.RENDER_STYLE_LS_KEY,e.positionRenderStyle),this.positionRenderStyle=e.positionRenderStyle,e.canvasColors&&(this.settingsCanvasColors=e.canvasColors),this.showTradeLevelsAlways!==e.showTradeLevelsAlways){this.showTradeLevelsAlways=e.showTradeLevelsAlways;try{localStorage.setItem(this.SHOW_SLTP_ALWAYS_LS_KEY,String(e.showTradeLevelsAlways))}catch(e){}}if(this.showPriceAxisCountdown!==e.showPriceAxisCountdown){this.showPriceAxisCountdown=e.showPriceAxisCountdown;try{localStorage.setItem(this.PRICE_AXIS_COUNTDOWN_LS_KEY,String(e.showPriceAxisCountdown))}catch(e){}this.updateCountdownState(),this.scheduleRender()}this.setTheme(e.theme),this.renderTradeLayer(),this.emitStateChange()},()=>{this.resetChartSettings()})}getFloatingRoot(){var e;return(e=document.fullscreenElement)==null?document.body:e}reparentFloatingElements(){var e,t,n,r,i,a,o,s,c;let l=this.getFloatingRoot();(e=this._tb)==null||e.reparentFlyout(l),(t=this.leftBar)==null||t.reparentFlyout(l);let u=[(n=this.isinPickerModal)==null?void 0:n.el,(r=this.comparePickerModal)==null?void 0:r.el,(i=this.indicatorSettingsDialog)==null?void 0:i.el,(a=this.chartSettingsDialog)==null?void 0:a.el,(o=this._draftQtyFlyout)==null?void 0:o.el,(s=this.layoutPopover)==null?void 0:s.el,(c=this.snapshotPopover)==null?void 0:c.el];for(let e of u)e&&e.parentElement!==l&&l.appendChild(e)}toggleDrawingTools(){var e,t;this.leftBarVisible=!this.leftBarVisible,(e=this.leftBar)==null||e.setVisible(this.leftBarVisible),(t=this._tb)==null||t.setDrawingsBtnActive(this.leftBarVisible)}_applyCssFullscreen(e){var t;this._isCssFullscreen=e,e?Object.assign(this.wrapper.style,{position:`fixed`,inset:`0`,width:`100vw`,height:`100vh`,zIndex:`9999`}):Object.assign(this.wrapper.style,{position:``,inset:``,width:``,height:``,zIndex:``}),(t=this._tb)==null||t.setFullscreen(e),this.reparentFloatingElements(),requestAnimationFrame(()=>this.onResize())}toggleFullscreen(){let e=!!document.fullscreenElement;!e&&!this._isCssFullscreen?this.wrapper.requestFullscreen?this.wrapper.requestFullscreen().then(()=>{var e;(e=this._tb)==null||e.setFullscreen(!0)}).catch(()=>{this._applyCssFullscreen(!0)}):this._applyCssFullscreen(!0):e?document.exitFullscreen().catch(()=>{}):this._applyCssFullscreen(!1)}baseRenderStyle(){return this.positionRenderStyleOverride===null?this.levels.filter(e=>e.type===`position`||e.type===`pending`).length>this.tradesThresholdForHorizontalLine?`dot`:`line`:this.positionRenderStyleOverride}recomputeRenderStyle(){this.positionRenderStyle=this.pnlPillExpanded?`line`:this.baseRenderStyle()}renderTradeLayer(){var e,t,n,r,i,a;if(this._isDestroyed)return;let o=window.devicePixelRatio||1,{tradeCtx:s,tradeCanvas:c,theme:l,viewport:u}=this;if(s.clearRect(0,0,c.width,c.height),!this.tfcActive||this.levels.length===0||this.dataStore.length===0){this.tradeLevelHitAreas=[],this.tradeLevelEditAreas=[],this.tradeHoverAreas=[],this.tradeAddBracketAreas=[],this.offViewportHitAreas=[];return}let{chartW:d,priceH:f}=this.getChartLayout(),p=(e=this._displayedPriceRange)==null?this.getScaledPriceRange(u):e,m=this.levels.filter(e=>e.type===`pending`&&e.ToClose!=null),h=this.levels.filter(e=>!(e.type===`pending`&&e.ToClose!=null)).map(e=>{var t,n,r,i;let a=(t=this.pendingLevelDrags.get(e.label))==null?[]:t,o=a.find(e=>e.field===`stopLoss`),s=a.find(e=>e.field===`takeProfit`),c=o&&!o.isRemoval?o.newPrice:void 0,l=s&&!s.isRemoval?s.newPrice:void 0,u=(n=o==null?void 0:o.isRemoval)==null?!1:n,d=(r=s==null?void 0:s.isRemoval)==null?!1:r,f=(i=a.find(e=>e.field===`main`))==null?void 0:i.newPrice,p=m.filter(t=>t.ToClose===e.label);if(p.length===0&&c===void 0&&l===void 0&&f===void 0&&!u&&!d)return e;let h={...e};if(f!==void 0&&(h.price=f),c===void 0?u&&(h.stopLossPrice=void 0):h.stopLossPrice=c,l===void 0?d&&(h.takeProfitPrice=void 0):h.takeProfitPrice=l,p.length>0){var g;let t=(g=e.side)==null?`buy`:g;for(let n of p)if(t===`buy`?n.price<e.price:n.price>e.price){var _;h.stopLossPrice=u?void 0:(_=c==null?h.stopLossPrice:c)==null?n.price:_,h._slOrderLabel=n.label}else{var v;h.takeProfitPrice=d?void 0:(v=l==null?h.takeProfitPrice:l)==null?n.price:v,h._tpOrderLabel=n.label}}return h});s.save(),s.scale(o,o),s.save(),s.beginPath(),s.rect(0,0,d,f),s.clip();let g=e=>e.type===`position`&&!!e.entryPriceEditable,_=this.selectedTradeLabel===null?this.tradeDisplayFilter===`none`?[]:this.tradeDisplayFilter===`positions`?h.filter(e=>e.type===`position`&&!g(e)):this.tradeDisplayFilter===`orders`?h.filter(e=>e.type===`pending`||g(e)):h:h.filter(e=>e.label===this.selectedTradeLabel),v=this.levelClusteringEnabled?this.clusterThresholdDistance:0,y=(t=this.orderTimeDragHandler)!=null&&t.active?this.orderTimeDragHandler.dragLabel:null,b=y!==null&&this.hoveredTradeLabel===y?null:this.hoveredTradeLabel,x=y!==null&&this.selectedTradeLabel===y?null:this.selectedTradeLabel,S=ft(s,_,this.scaleManager,p,l,d,f,this.dataStore.getPricePrecision(),b,(n=(r=this.tradeDragHandler)==null?void 0:r.dragLabel)==null?null:n,this.tradeDragNewPrice,x,new Set([...this.pendingLevelDrags.keys(),...this._editOpenLabel===null?[]:[this._editOpenLabel]]),this.positionRenderStyle,this.hideLevelConfirmCancel,this.draftOrderLabel,this.draftBracketPnl,this.expandedClusters,v,this._showQuantityField,this.tradeDragNewSLPrice,this.tradeDragNewTPPrice,this.tradeLevelButtonScale,this.showTradeLevelsAlways,this._orderTimeDragEnabled?e=>this._orderLineAnchorX(e,d):null,this._orderTimeDragEnabled,this._bracketLabel,this.tradeLevelBadgeScale,this.tradeLevelBadgeAnchor);s.restore();let C=Gt(s,_,p,l,d,f,(i=(a=this.tradeDragHandler)==null?void 0:a.dragLabel)==null?null:i,this.selectedTradeLabel);if(this.offViewportHitAreas=C.hitAreas,Nt(s,_,this.scaleManager,p,l,d,f,this.dataStore.getPricePrecision()),s.restore(),this.tradeLevelHitAreas=S.hitAreas,this.tradeLevelEditAreas=S.editAreas,this.tradeHoverAreas=S.hoverAreas,this.tradeLevelDragAreas=S.dragAreas,this.tradeLevelConfirmAreas=S.confirmAreas,this.tradeAddBracketAreas=S.addBracketAreas,this.clusterBadgeAreas=S.clusterBadgeAreas,this.lastClusters=S.clusters,this._draftQtyPillArea=S.draftQtyPillArea,this.expandedClusters.size>0){let e=new Set(S.clusters.map(e=>e.id));for(let t of this.expandedClusters)e.has(t)||this.expandedClusters.delete(t)}if(this.pnlPillExpanded&&!this._pnlPillExpandPass){let e=S.clusters.filter(e=>!this.expandedClusters.has(e.id)&&e.members.some(e=>e.level.type===`position`));if(e.length>0){for(let t of e)this.expandedClusters.add(t.id);this._pnlPillExpandPass=!0;try{this.renderTradeLayer()}finally{this._pnlPillExpandPass=!1}}}}_orderLineAnchorX(e,t){var n;if(!this._orderTimeDragEnabled)return null;if((n=this.orderTimeDragHandler)!=null&&n.active&&this.orderTimeDragHandler.dragLabel===e.label&&this.tradeDragNewBarIndex!==null)return this.scaleManager.xToPixel(this.tradeDragNewBarIndex,this.viewport,t);let r=this._resolvedTimeAnchor(e);return r===void 0?null:this.scaleManager.xToPixel(this.timestampToBarIndex(r),this.viewport,t)}_resolvedTimeAnchor(e){var t;let n=this._timeAnchorOverride.get(e.label);if(n!==void 0)return n;let r=(t=this._orderLineAnchorStore)==null?void 0:t.get(e.label);return r===void 0?this._honorsLevelTimestamp(e)?e.timestamp:void 0:r}_honorsLevelTimestamp(e){return!((this._orderLineDefaultAnchor===`center`||this.tradeLevelBadgeAnchor===`left`)&&e.timeDraggable===!0)}_effectiveEntryPrice(e,t){var n,r;let i=this.pendingLevelDrags.get(e);return(n=i==null||(r=i.find(e=>e.field===`main`))==null?void 0:r.newPrice)==null?t:n}_effectiveBracketPrice(e,t,n){var r;let i=this.pendingLevelDrags.get(e),a=i==null||(r=i.find(e=>e.field===t))==null?void 0:r.newPrice;return a==null?n:a}_resolveBracketPrices(e){let t=e.stopLossPrice,n=e.takeProfitPrice,r,i;if(t===void 0||n===void 0){let o=this.levels.filter(t=>t.type===`pending`&&t.ToClose===e.label);if(o.length>0){var a;let s=(a=e.side)==null?`buy`:a;for(let a of o){let o=s===`buy`?a.price<e.price:a.price>e.price;o&&t===void 0?(t=a.price,r=a.label):!o&&n===void 0&&(n=a.price,i=a.label)}}}return{slPrice:t,tpPrice:n,slSiblingLabel:r,tpSiblingLabel:i}}_finalizeMainDragWithBrackets(e,t){var n;let r=this.levels.find(t=>t.label===e.label),i=e.derivedSLPrice!==void 0&&e.slStartPrice!==void 0&&e.derivedSLPrice!==e.slStartPrice,a=e.derivedTPPrice!==void 0&&e.tpStartPrice!==void 0&&e.derivedTPPrice!==e.tpStartPrice,o=!i&&!a;if(this.storePendingChange(e,e.startPrice,t,!o),!((n=this.pendingLevelDrags.get(e.label))!=null&&n.some(t=>t.field===`main`&&t.newPrice===e.newPrice))){this.tradeDragNewSLPrice=null,this.tradeDragNewTPPrice=null;return}if(i){var s,c,l;let n=!a,i=r,o=r,u=(s=(c=i==null?void 0:i.stopLossData)==null?o==null?void 0:o.stopLossData:c)==null?e.data:s;this.storePendingChange({label:e.label,type:e.type,newPrice:e.derivedSLPrice,data:u,bracketType:`stopLoss`},e.slStartPrice,(l=this._slSiblingOrderLabel)==null?t:l,!n)}if(a){var u,d,f;let n=r,i=r,a=(u=(d=n==null?void 0:n.takeProfitData)==null?i==null?void 0:i.takeProfitData:d)==null?e.data:u;this.storePendingChange({label:e.label,type:e.type,newPrice:e.derivedTPPrice,data:a,bracketType:`takeProfit`},e.tpStartPrice,(f=this._tpSiblingOrderLabel)==null?t:f,!1)}this.tradeDragNewSLPrice=null,this.tradeDragNewTPPrice=null,this._slSiblingOrderLabel=null,this._tpSiblingOrderLabel=null}storePendingChange(e,t,n,r=!1){var i,a,o,s,c;if(e.bracketType){var l,u,d,f,p;let n=this.levels.find(t=>t.label===e.label),r=(l=n==null?void 0:n.side)==null?`buy`:l,i=this._effectiveEntryPrice(e.label,(u=n==null?void 0:n.price)==null?t:u),a=(n==null?void 0:n.entryPriceEditable)===!0,o=(n==null||(d=n.data)==null?void 0:d._isDraft)===!0,s=this.dataStore.all,c=e.type===`position`&&!a&&!o?(f=(p=s[s.length-1])==null?void 0:p.close)==null?0:f:0;if(!yu.isBracketPriceValid(e.newPrice,e.bracketType,i,r,c)){this.tradeDragNewPrice=null,this.renderTradeLayer();return}}if(!e.bracketType){let t=this.levels.find(t=>t.label===e.label);if(t!=null&&t.orderType&&t!=null&&t.side){var m,h;let n=this.dataStore.all,r=(m=(h=n[n.length-1])==null?void 0:h.close)==null?0:m;if(r>0&&!(t.side===`buy`&&t.orderType===`limit`||t.side===`sell`&&t.orderType===`stop`?e.newPrice<r:e.newPrice>r)){this.tradeDragNewPrice=null,this.renderTradeLayer();return}}}if(e.newPrice===t){this.tradeDragNewPrice=null,this.renderTradeLayer();return}let g=(i=e.bracketType)==null?`main`:i,_=this._isBracketNew;this._isBracketNew=!1;let v=this.levels.find(t=>t.label===e.label);if((v==null?void 0:v.orderType)===`market`&&(v==null||(a=v.data)==null?void 0:a._isDraft)===!0){g!==`main`&&(this.updateDraftOrderBracket(g===`stopLoss`?`sl`:`tp`,e.newPrice),this.emitter.emit(`tradeLevelDrag`,{label:e.label,newPrice:e.newPrice,data:v==null?void 0:v.data,bracketType:g,isFullscreen:this.isFullscreen})),this.tradeDragNewPrice=null,this.renderTradeLayer();return}if(v!==void 0&&g!==`main`&&(v==null||(o=v.data)==null?void 0:o._isDraft)===!0){this.updateDraftOrderBracket(g===`stopLoss`?`sl`:`tp`,e.newPrice),this.emitter.emit(`tradeLevelDrag`,{label:e.label,newPrice:e.newPrice,data:v==null?void 0:v.data,bracketType:g,isFullscreen:this.isFullscreen}),this.tradeDragNewPrice=null,this.renderTradeLayer();return}if(v!==void 0&&g===`main`&&(v==null||(s=v.data)==null?void 0:s._isDraft)===!0&&v.orderType!==`market`&&this.hideLevelConfirmCancel){this.updateDraftOrderPrice(e.newPrice),this.emitter.emit(`tradeLevelDrag`,{label:e.label,newPrice:e.newPrice,data:v==null?void 0:v.data,bracketType:void 0,isFullscreen:this.isFullscreen}),this.tradeDragNewPrice=null,this.renderTradeLayer();return}let y=((c=this.pendingLevelDrags.get(e.label))==null?[]:c).filter(e=>e.field!==g);if(y.push({field:g,newPrice:e.newPrice,oldPrice:t,isNew:_,bracketOrderLabel:n}),this.pendingLevelDrags.set(e.label,y),this.tradeDragNewPrice=null,this.hideLevelConfirmCancel&&!r){this.applyPendingChanges(e.label);return}this.renderTradeLayer()}_orderTypeForPrice(e,t){let n=this.dataStore.all,r=n.length>0?n[n.length-1].close:t;return e===`buy`?t<r?`limit`:`stop`:t>r?`limit`:`stop`}createDraftOrder(e,t,n){if(this.draftOrderLabel)return;let r=`__draft_${Date.now()}`,i={type:`pending`,label:r,side:e,price:t,orderType:n,lots:this._qtyFieldMin,data:{_isDraft:!0}};this.levels=[...this.levels,i],this.draftOrderLabel=r,this.selectedTradeLabel=r,this.pendingLevelDrags.set(r,[{field:`main`,newPrice:t,oldPrice:t}]),this.crosshair=null,this.renderTradeLayer(),this.emitter.emit(`draftInitiated`,{side:e,price:t,orderType:n,isFullscreen:this.isFullscreen})}removeDraftOrder(){var e;if(!this.draftOrderLabel)return;let t=this.draftOrderLabel;this.levels=this.levels.filter(e=>e.label!==t),this.pendingLevelDrags.delete(t),this.selectedTradeLabel=null,this.draftOrderLabel=null,this.draftBracketPnl={},(e=this._draftQtyFlyout)==null||e.hide(),this._draftQtyPillArea=void 0,this.renderTradeLayer(),this.emitter.emit(`draftCancelled`,{label:t,isFullscreen:this.isFullscreen})}applyPendingChanges(e){let t=this.pendingLevelDrags.get(e);if(!t){if(this._editOpenLabel===e){let t=this.levels.find(t=>t.label===e);this._editOpenLabel=null,this.selectedTradeLabel=null,this.renderTradeLayer(),t&&this.emitter.emit(`tradeLevelConfirmed`,{label:e,type:t.type,isFullscreen:this.isFullscreen})}return}let n=this.levels.find(t=>t.label===e);if(!n)return;if(this._editOpenLabel===e&&(this._editOpenLabel=null),e===this.draftOrderLabel){var r,i,a;let o=t.find(e=>e.field===`main`),s=n;(r=this._onOrderSubmit)==null||r.call(this,{price:(i=o==null?void 0:o.newPrice)==null?s.price:i,lots:(a=s.lots)==null?this._qtyFieldMin:a,side:s.side,orderType:s.orderType,...s.stopLossPrice===void 0?{}:{stopLoss:s.stopLossPrice},...s.takeProfitPrice===void 0?{}:{takeProfit:s.takeProfitPrice}}),this.emitter.emit(`tradeLevelConfirmed`,{label:e,type:`draft`,isFullscreen:this.isFullscreen}),this.removeDraftOrder();return}let o=this.pendingQtyChanges.get(e);this.pendingQtyChanges.delete(e),this.originalQtyByLabel.delete(e);let s=o!==void 0&&n.data&&typeof n.data==`object`?{...n.data,lots:o}:n.data;this.emitter.emit(`tradeLevelEdit`,{label:e,type:n.type,data:s,isFullscreen:this.isFullscreen,...o===void 0?{}:{newLots:o},changes:t.map(e=>{let t=n.data,r=s;if(e.field===`stopLoss`){var i;r=(i=t.stopLossData)==null?n.data:i}else if(e.field===`takeProfit`){var a;r=(a=t.takeProfitData)==null?n.data:a}if(e.bracketOrderLabel){let t=this.levels.find(t=>t.label===e.bracketOrderLabel);t&&(r=t.data)}let c;return c=e.field===`main`?`MAIN`:e.field===`stopLoss`?e.isRemoval?`REMOVE_SL`:e.isNew?`ADD_SL`:`SL`:e.isRemoval?`REMOVE_TP`:e.isNew?`ADD_TP`:`TP`,{field:c,newPrice:e.newPrice,data:r,...c===`MAIN`&&o!==void 0?{newLots:o}:{},bracketOrderLabel:e.bracketOrderLabel}})}),this.emitter.emit(`tradeLevelConfirmed`,{label:e,type:n.type,isFullscreen:this.isFullscreen}),this.hideLevelConfirmCancel||(this.pendingLevelDrags.delete(e),this.selectedTradeLabel=null,this.draftBracketPnl={}),this.renderTradeLayer()}revertPendingChanges(e){var t;if(e&&e===this.draftOrderLabel){this.removeDraftOrder();return}if(!e&&this.draftOrderLabel&&this.removeDraftOrder(),e&&!this.pendingLevelDrags.has(e)&&this._editOpenLabel===e){this._cancelEditAndDeselect(e);return}let n=e?this.pendingLevelDrags.has(e)||this.pendingQtyChanges.has(e)?[[e,(t=this.pendingLevelDrags.get(e))==null?[]:t]]:[]:[...this.pendingLevelDrags.entries(),...[...this.pendingQtyChanges.keys()].filter(e=>!this.pendingLevelDrags.has(e)).map(e=>[e,[]])];for(let[e]of n){if(this.undoIsNewBracketMutations(e),this.pendingLevelDrags.delete(e),this.pendingQtyChanges.has(e)){this.pendingQtyChanges.delete(e);let t=this.levels.findIndex(t=>t.label===e);if(t!==-1&&this.originalQtyByLabel.has(e)){let n=this.originalQtyByLabel.get(e),r=this.levels[t];this.levels=[...this.levels.slice(0,t),{...r,lots:n},...this.levels.slice(t+1)]}this.originalQtyByLabel.delete(e)}let t=this.levels.find(t=>t.label===e);t&&(this._editOpenLabel===e&&(this._editOpenLabel=null),this.emitter.emit(`tradeLevelEditCancelled`,{label:e,type:t.type,isFullscreen:this.isFullscreen}))}this.selectedTradeLabel=null,this.draftBracketPnl={},this.renderTradeLayer()}undoIsNewBracketMutations(e){let t=this.pendingLevelDrags.get(e);if(!t)return;let n=t.some(e=>e.field===`stopLoss`&&e.isNew),r=t.some(e=>e.field===`takeProfit`&&e.isNew);!n&&!r||(this.levels=this.levels.map(t=>{if(t.label!==e)return t;let i={...t};return n&&(i.stopLossPrice=void 0),r&&(i.takeProfitPrice=void 0),i}))}initCompareUi(){if(!this.compareManager)return;this.siEl&&(this.compareLegend=new su({theme:this.theme,onRemove:e=>this.removeCompare(e)}),this.siEl.appendChild(this.compareLegend.el));let e=()=>this.refreshCompareLegend();this.emitter.on(`compareAdded`,e),this.emitter.on(`compareRemoved`,e),this.emitter.on(`compareError`,e),this.emitter.on(`crosshair`,e=>{var t,n;this.compareHoveredIndex=(t=e==null?void 0:e.barIndex)==null?null:t,(n=this.compareManager)!=null&&n.isActive()&&(this.refreshCompareLegend(),this.scheduleRender())})}openComparePicker(){var e,t;if(!this.compareDataLoader)return;this.comparePickerModal||(this.comparePickerModal=new ou(this.chromeTheme,e=>this.toggleCompare(e),()=>this.emitUiState()),this.comparePickerModal.setTitle(`Compare`),this.comparePickerModal.setMode(`toggle`),this.getFloatingRoot().appendChild(this.comparePickerModal.el)),this.refreshComparePickerState();let n=(e=(t=this.siSymbolSpan)==null?void 0:t.textContent)==null?``:e;this.comparePickerModal.show(this.isins,n)}toggleCompare(e){this.compareManager&&(this.compareManager.has(e)?this.removeCompare(e):this.addCompare(e),this.refreshComparePickerState())}refreshComparePickerState(){!this.comparePickerModal||!this.compareManager||this.comparePickerModal.setActiveSymbols(this.compareManager.list().map(e=>e.symbol))}async addCompare(e){this.compareManager&&(await this.compareManager.add(e),this.refreshCompareLegend(),this.scheduleRender(),this.emitStateChange())}removeCompare(e){this.compareManager&&(this.compareManager.remove(e),this.refreshCompareLegend(),this.scheduleRender(),this.emitStateChange())}clearCompares(){this.compareManager&&(this.compareManager.clear(),this.refreshCompareLegend(),this.scheduleRender(),this.emitStateChange())}getCompares(){return this.compareManager?this.compareManager.list().map(e=>({symbol:e.symbol,color:e.color,status:e.status})):[]}refreshCompareLegend(){var e,t;if(!this.compareLegend||!this.compareManager)return;let n=this.compareManager.list(),r=this.dataStore.all,i=this.compareBaselineIndex(r),a=i==null||(e=(t=r[i])==null?void 0:t.close)==null?null:e,o=this.compareHoveredIndex,s=r.length-1,c=n.map(e=>{let t=null;if(e.status===`ready`&&a!=null&&e.bars.length>0){let n=_u(e.bars,r.map(e=>e.time),i==null?0:i),a=r[o==null?s:o];if(a){let e=n.find(e=>e.time===a.time);if(e&&e.pct!=null)t=e.pct;else{let e=n[n.length-1];(e==null?void 0:e.pct)!=null&&(t=e.pct)}}}return{symbol:e.symbol,color:e.color,percent:t,status:e.status,errorMessage:e.errorMessage}});this.compareLegend.update(c)}compareBaselineIndex(e){return e.length===0?null:Math.max(0,Math.min(e.length-1,Math.floor(this.viewport.startIndex)))}updateCompareRange(){if(!this.compareManager)return;let e=this.dataStore.all;if(e.length===0)return;let t={start:new Date(e[0].time),end:new Date(e[e.length-1].time),interval:this.timeframe,priceSource:this.tickClosePriceSource};this.compareManager.isActive()?this.compareManager.refetchAll(t).then(()=>{this.refreshCompareLegend(),this.scheduleRender()}):this.compareManager.setLastParams(t)}render(){var e,t,n;if(this._isDestroyed)return;let{ctx:r,canvas:i,theme:a,viewport:o}=this,s=window.devicePixelRatio||1,c=i.width,l=i.height,u=c/s-this.priceAxisWidth,d=this.activeIndicators.filter(e=>e.indicator.pane===`sub`),f=d.reduce((e,t)=>e+this.paneH(t)+Od,0),p=l/s-this.timeAxisHeight-f;r.clearRect(0,0,c,l),r.fillStyle=a.background,r.fillRect(0,0,c,l);let m=this.dataStore.getVisible(o);if(m.length===0){this.drawCtx.clearRect(0,0,this.drawCanvas.width,this.drawCanvas.height);return}let h=m;if(this._isPanning)this.viewport={...this._targetViewport};else{let e=this._targetViewport.startIndex-this.viewport.startIndex,t=this._targetViewport.endIndex-this.viewport.endIndex,n=(this._targetViewport.endIndex-this._targetViewport.startIndex)*2e-4;Math.abs(e)<n&&Math.abs(t)<n?this.viewport={...this._targetViewport}:(this.viewport={...this.viewport,startIndex:this.viewport.startIndex+e*Md,endIndex:this.viewport.endIndex+t*Md,candleWidth:this._targetViewport.candleWidth,candleGap:this._targetViewport.candleGap},this.scheduleRender())}let g=!!((e=this.compareManager)!=null&&e.isActive()),_=null,v=[],y=[],b=null;if(g&&this.compareManager){var x,S;let e=this.dataStore.all,t=this.compareBaselineIndex(e),n=t==null||(x=(S=e[t])==null?void 0:S.close)==null?null:x;if(n!=null&&n!==0&&Number.isFinite(n)){_=n;let r=this.compareManager.list(),i=e.map(e=>e.time);v=r.map(e=>e.status===`ready`&&e.bars.length>0?_u(e.bars,i,t==null?0:t):[]),y=r.map(e=>e.color),h=mu(m,n),b=gu(m,n,v.map(e=>e.filter(e=>e.pct!=null)))}}let C=g&&b!==null;if(C!==this._lastInCompareMode&&(this._lastInCompareMode=C,this._displayedPriceRange=null,this._lockedAutoFitBase=null,this.pricePanOffset=0,this.priceScaleFactor=1),this.priceScaleFactor!==1||this.pricePanOffset!==0){if(!this._lockedAutoFitBase){var w,T;this._lockedAutoFitBase=(w=(T=this._displayedPriceRange)==null?b:T)==null?this.dataStore.getPriceRange(o):w}let e=this._lockedAutoFitBase,t=(e.min+e.max)/2+this.pricePanOffset,n=e.max===e.min?1:(e.max-e.min)/2;this._displayedPriceRange={min:t-n*this.priceScaleFactor,max:t+n*this.priceScaleFactor}}else{var E;this._lockedAutoFitBase=null;let e=(E=b)==null?this.getScaledPriceRange(o):E;if(!this._displayedPriceRange)this._displayedPriceRange=e;else{let t=(e.max-e.min)*1e-4,n=e.min-this._displayedPriceRange.min,r=e.max-this._displayedPriceRange.max;Math.abs(n)<t&&Math.abs(r)<t?this._displayedPriceRange=e:(this._displayedPriceRange={min:this._displayedPriceRange.min+n*jd,max:this._displayedPriceRange.max+r*jd},this.scheduleRender())}}let D=this._displayedPriceRange,O=this.showVolume?this.dataStore.getVolumeRange(o):null,k=i;switch(k._priceRange=D,k._chartWidth=u,r.save(),r.scale(s,s),r.save(),r.beginPath(),r.rect(0,0,u,p),r.clip(),_e(r,D,this.scaleManager,a,u,p),this.series){case`candlestick`:ee(r,h,o,D,this.scaleManager,a,u,p);break;case`hollow`:te(r,h,o,D,this.scaleManager,a,u,p);break;case`line`:ie(r,h,o,D,this.scaleManager,a,u,p,!1);break;case`area`:ie(r,h,o,D,this.scaleManager,a,u,p,!0);break;case`ohlc`:ae(r,h,o,D,this.scaleManager,a,u,p);break;case`heikinashi`:ce(r,h,o,D,this.scaleManager,a,u,p);break;case`volumecandles`:V(r,h,o,D,this.scaleManager,a,u,p);break;case`linemarkers`:le(r,h,o,D,this.scaleManager,a,u,p);break;case`step`:ue(r,h,o,D,this.scaleManager,a,u,p);break;case`hlcarea`:fe(r,h,o,D,this.scaleManager,a,u,p);break;case`baseline`:me(r,h,o,D,this.scaleManager,a,u,p);break;case`columns`:he(r,h,o,D,this.scaleManager,a,u,p);break;case`highlow`:ge(r,h,o,D,this.scaleManager,a,u,p);break}r.save(),r.beginPath(),r.rect(0,0,u,p),r.clip();for(let e of this.visibleStates()){let t=e.indicator;if(t.pane&&t.pane!==`main`)continue;let n=this.indicatorResults.get(e.instanceId);if(!n)continue;let i=n.slice(Math.floor(o.startIndex),Math.ceil(o.endIndex)+1),a=g&&_!=null?hu(i,_):i;t.render(r,a,this.scaleManager,o,p)}if(g&&_!=null&&v.length>0){let e=this.dataStore.all,t=Math.floor(o.startIndex),n=Math.min(e.length-1,Math.ceil(o.endIndex)),i=new Map;for(let r=t;r<=n;r++)i.set(e[r].time,r);for(let e=0;e<v.length;e++){let t=v[e],n=y[e];if(!t||t.length===0)continue;r.save(),r.strokeStyle=n,r.lineWidth=1.5,r.lineJoin=`round`,r.lineCap=`round`,r.beginPath();let a=!1;for(let e of t){let t=i.get(e.time);if(t==null||e.pct==null){a=!1;continue}let n=this.scaleManager.xToPixel(t,o,u),s=this.scaleManager.yToPixel(e.pct,D,p);a?r.lineTo(n,s):(r.moveTo(n,s),a=!0)}r.stroke(),r.restore()}}r.restore(),r.restore(),an(r,D,this.scaleManager,a,u,p,this.priceAxisWidth,void 0,this.dataStore.getPricePrecision(),this.uiConfig.priceAxis,g?`percent`:`price`);let A=this.dataStore.all[this.dataStore.all.length-1];if(A&&!g){let e=this.dataStore.getPricePrecision(),t=(t,n,i)=>{let a=this.scaleManager.yToPixel(t,D,p);r.save(),r.strokeStyle=n,r.lineWidth=1,r.setLineDash([3,3]),r.beginPath(),r.moveTo(0,a),r.lineTo(u,a),r.stroke(),r.setLineDash([]);let o=i+t.toFixed(e);r.font=`10px 'Inter', system-ui, sans-serif`;let s=r.measureText(o).width+12;return r.fillStyle=n,r.fillRect(u,a-16/2,s,16),r.fillStyle=`#ffffff`,r.textAlign=`left`,r.fillText(o,u+4,a+4),r.restore(),{y:a,boxW:s}},n=null,i=0;if(this.liveBidAsk){var j,M,N,P,F,I,L;let{bid:e,ask:r}=this.liveBidAsk,o=this.tickClosePriceSource===`ltp`,s=((j=this.showLtpPrice)==null?o:j)?(M=this.liveLtp)==null?o?e:null:M:null,c=A.close>=A.open?a.candle.up:a.candle.down,l=(N=this.showAskLine)==null?this.showBidAskLines||this.tickClosePriceSource===`ask`:N,u=((P=this.showBidLine)==null?this.showBidAskLines||this.tickClosePriceSource===`bid`||o&&s==null:P)?t(e,a.candle.down,``):null,d=l?t(r,a.candle.up,``):null,f=s==null?null:t(s,c,``),p=o?(F=f==null?u:f)==null?d:F:this.tickClosePriceSource===`ask`?(I=d==null?f:d)==null?u:I:(L=u==null?f:u)==null?d:L;p&&(n=p.y,i=p.boxW)}else{let e=A.close>=A.open,r=t(A.close,e?a.candle.up:a.candle.down,``);n=r.y,i=r.boxW}if(this.showPriceAxisCountdown&&n!==null){var R;if(this.candleCountdownTimeframes===`all`||((R=this.candleCountdownTimeframes)==null?[`1m`,`3m`,`4m`,`5m`,`10m`,`15m`,`30m`,`1h`,`2h`,`4h`,`8h`]:R).includes(this.timeframe)){let e=this.timeframeToMs(this.timeframe);rn(r,A.time,e,a,u,n-16/2,16,i)}}}let z=p;for(let e of d){let t=e.indicator,n=this.paneH(e);if(r.fillStyle=a.axisBorder,r.fillRect(0,z,u+this.priceAxisWidth,Od),z+=Od,r.save(),r.beginPath(),r.rect(0,z,u+this.priceAxisWidth,n),r.clip(),r.translate(0,z),r.fillStyle=a.background,r.fillRect(0,0,u+this.priceAxisWidth,n),e.visible&&(()=>{let t=e.currentParams.timeframe;return!t||t===`Chart`||t===this.timeframe})()){let i=this.indicatorResults.get(e.instanceId);if(i){var B,ne;let s=i.slice(Math.floor(o.startIndex),Math.ceil(o.endIndex)+1),c=(B=t.getValueRange)==null?void 0:B.call(t,s),l=(ne=this.subPaneScaleFactors.get(e.instanceId))==null?1:ne,d=c?Rd(c,l):void 0;t.render(r,s,this.scaleManager,o,n,d),d&&an(r,d,this.scaleManager,a,u,n,this.priceAxisWidth,3,zd(d),this.uiConfig.priceAxis)}}r.restore(),z+=n}if(this.showVolume&&O&&O.max>0){let e=p*Ed;oe(r,h,o,O.max,this.scaleManager,a,u,e,p-e)}{var re;let e=this.candleCountdownTimeframes===`all`?!0:((re=this.candleCountdownTimeframes)==null?[`1m`,`3m`,`4m`,`5m`,`10m`,`15m`,`30m`,`1h`,`2h`,`4h`,`8h`]:re).includes(this.timeframe),t=this.showCandleCountdown&&!this.showPriceAxisCountdown&&e&&h.length>0&&o.endIndex>=this.dataStore.length-1,n=t?this.dataStore.length-1:void 0;if(this._debug&&console.log(`[countdown] showCandleCountdown:`,this.showCandleCountdown,`| tf:`,this.timeframe,`| allowed:`,e,`| bars:`,h.length,`| endIndex:`,o.endIndex,`| dataLen:`,this.dataStore.length,`| atLiveEdge:`,o.endIndex>=this.dataStore.length-1),tn(r,h,o,this.scaleManager,a,u,z,Fd()?3:void 0,this.uiConfig.timeAxis,this.timeframe,n,this.timezone),t){let e=this.dataStore.all[this.dataStore.length-1];if(e){let t=this.timeframeToMs(this.timeframe);nn(r,e.time,t,this.dataStore.length-1,o,this.scaleManager,a,u,z,this.uiConfig.timeAxis)}}}if(this.crosshair&&be(r,this.crosshair,D,o,this.scaleManager,a,u,p,this.priceAxisWidth,z,this.timeframe,this.dataStore.getPricePrecision(),this.uiConfig.crosshair,this.timezone),this.logoImage){let e=p-20-40/2;r.save(),r.globalAlpha=.6,r.beginPath(),r.rect(0,0,u,p),r.clip(),r.beginPath(),r.arc(40,e,40/2,0,Math.PI*2),r.closePath(),r.clip(),r.drawImage(this.logoImage,40-40/2,e-40/2,40,40),r.restore()}r.restore();let se=this.crosshair?(t=this.dataStore.all[this.crosshair.barIndex])==null?null:t:(n=this.dataStore.all[this.dataStore.length-1])==null?null:n;if(this.renderSymbolInfoOHLC(se),this.drawingManager.render(this.drawCtx,this.scaleManager,o,D,u,p,this.dataStore.getPricePrecision(),this.theme,{instrument:this.getInstrument(),bars:this.dataStore.all,account:this.accountSpec,features:this._features}),this.drawingStylePopover){let e=this.drawingManager.getSelectedDrawing();if(e&&e.complete&&e.locked!==!0){let t=this.computeDrawingAnchorPx(e);t&&this.drawingStylePopover.setAnchor(t.x,t.y)}}if(this.scrollToEndBtn){let e=this.dataStore.length===0||this._targetViewport.endIndex>=this.dataStore.length-.5;e!==!this.scrollToEndVisible&&(this.scrollToEndVisible=!e,this.scrollToEndBtn.style.opacity=e?`0`:`0.85`,this.scrollToEndBtn.style.pointerEvents=e?`none`:`auto`)}if(this.resetViewBtn){let e=this.dataStore.length,t=this._defaultVisibleBars,n=e===0||this._targetViewport.endIndex>=e-.5,r=this._targetViewport.endIndex-this._targetViewport.startIndex,i=Math.abs(r-t)<.5,a=this.priceScaleFactor===1&&this.pricePanOffset===0&&this._lockedAutoFitBase===null,o=e===0||n&&i&&a;o===this.resetViewVisible&&(this.resetViewVisible=!o,this.resetViewBtn.style.opacity=o?`0`:`0.75`,this.resetViewBtn.style.pointerEvents=o?`none`:`auto`)}this.updateSubPaneOverlayPositions()}recomputeIndicators(){for(let e of this.visibleStates())this.indicatorResults.set(e.instanceId,e.indicator.compute(this.dataStore.all))}onResize(){var e;if(this._isDestroyed)return;let t=window.devicePixelRatio||1,n=this.canvasWrap.getBoundingClientRect();if(n.width===0||n.height===0)return;this._cachedWrapRect=n,this._cachedDrawRect=this.drawCanvas.getBoundingClientRect(),(e=this.pnlPill)==null||e.clampToBounds();for(let e of[this.canvas,this.tradeCanvas,this.drawCanvas])e.width=n.width*t,e.height=n.height*t;let r=this.wrapper.offsetWidth,i=r>0&&r<this.uiConfig.drawingToolbar.mobileBreakpoint;if(i!==this._mobileLayout){var a,o,s,c;if(this._mobileLayout=i,(a=this.leftBar)==null||a.setMobileMode(i),(o=this._tb)==null||o.setMobileLayout(i),(s=this.tradeButton)==null||s.setMobileMode(i),(c=this.tradePopover)==null||c.setCompact(i),this.siEl&&(this.siEl.style.flexDirection=i?`column`:`row`,this.siEl.style.alignItems=i?`flex-start`:`center`,this.siEl.style.gap=i?`2px`:`8px`),i){var l;this.leftBarVisible=!1,(l=this._tb)==null||l.setDrawingsBtnActive(!1)}else{var u,d;this.leftBarVisible=!0,(u=this.leftBar)==null||u.setVisible(!0),(d=this._tb)==null||d.setDrawingsBtnActive(!0)}}this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null),this.render(),this.renderTradeLayer()}paneH(e){var t,n;return(t=(n=this.paneHeightOverrides.get(e.instanceId))==null?e.indicator.paneHeight:n)==null?Dd:t}getChartLayout(){var e;let t=this.activeIndicators.filter(e=>e.indicator.pane===`sub`).reduce((e,t)=>e+this.paneH(t)+Od,0),n=(e=this._cachedWrapRect)==null?this.canvasWrap.getBoundingClientRect():e;return{chartW:n.width-this.priceAxisWidth,priceH:n.height-this.timeAxisHeight-t}}computeDrawingAnchorPx(e){var t;if(e.points.length===0)return null;let{chartW:n,priceH:r}=this.getChartLayout(),i=this._targetViewport,a=(t=this._displayedPriceRange)==null?this.getScaledPriceRange(i):t,o=0,s=1/0;for(let t of e.points){let e=this.scaleManager.xToPixel(t.barIndex,i,n),c=this.scaleManager.yToPixel(t.price,a,r);c<s&&(s=c,o=e)}return Number.isFinite(s)?(o=Math.max(0,Math.min(n,o)),s=Math.max(0,Math.min(r,s)),{x:o,y:s}):null}updateSubPaneOverlayPositions(){if(this.subPaneOverlays.size===0)return;let e=this.getSeparatorPositions();for(let t of e){let e=this.subPaneOverlays.get(t.instanceId);e&&(e.el.style.top=`${t.y+Od+6}px`)}}getSeparatorPositions(){let{priceH:e}=this.getChartLayout(),t=this.activeIndicators.filter(e=>e.indicator.pane===`sub`),n=[],r=e;for(let e of t)n.push({y:r,instanceId:e.instanceId}),r+=this.paneH(e)+Od;return n}getScaledPriceRange(e){let t=this.dataStore.getPriceRange(e),n=t.min,r=t.max;for(let t of this.visibleStates()){if(t.indicator.pane&&t.indicator.pane!==`main`)continue;let a=this.indicatorResults.get(t.instanceId);if(!a)continue;let o=Math.floor(e.startIndex),s=Math.ceil(e.endIndex)+1;for(let e=o;e<s&&e<a.length;e++){var i;let t=(i=a[e])==null?void 0:i.value;if(t==null)continue;let o=Array.isArray(t)?t.filter(e=>e!==null):[t];for(let e of o)isFinite(e)&&(e<n&&(n=e),e>r&&(r=e))}}let a=(n+r)/2+this.pricePanOffset,o=n===r?1:(r-n)/2;return{min:a-o*this.priceScaleFactor,max:a+o*this.priceScaleFactor}}touchToDrawingPoint(e){var t,n;let r=(t=this._cachedDrawRect)==null?this.drawCanvas.getBoundingClientRect():t,i=e.clientX-r.left,a=e.clientY-r.top,{chartW:o,priceH:s}=this.getChartLayout(),c=(n=this._displayedPriceRange)==null?this.getScaledPriceRange(this.viewport):n;return this.makeDrawingPoint(this.scaleManager.pixelToBarIndex(i,this.viewport,o),this.scaleManager.pixelToPrice(a,c,s))}makeDrawingPoint(e,t){let n={barIndex:e,price:t},r=this.barIndexToTimestamp(e);return r!=null&&(n.timestamp=r),n}_handleTradeLevelClose(e){if(e.bracketType){var t,n;let r=this.levels.find(t=>t.label===e.label);if((r==null||(t=r.data)==null?void 0:t._isDraft)===!0&&r){let t=e.bracketType===`stopLoss`?`sl`:`tp`;this.updateDraftOrderBracket(t,null),this.emitter.emit(`tradeLevelEdit`,{label:e.label,type:`pending`,data:r.data,isFullscreen:this.isFullscreen,changes:[{field:e.bracketType===`stopLoss`?`REMOVE_SL`:`REMOVE_TP`,newPrice:0,data:r.data,bracketOrderLabel:void 0}]});return}let i=e.bracketType,a=((n=this.pendingLevelDrags.get(e.label))==null?[]:n).filter(e=>e.field!==i);a.push({field:i,newPrice:0,oldPrice:0,isRemoval:!0,bracketOrderLabel:e.bracketOrderLabel}),this.pendingLevelDrags.set(e.label,a),this.selectedTradeLabel=e.label,this.renderTradeLayer();return}let r=e.label===this.draftOrderLabel,i=this.pendingLevelDrags.get(e.label),a=this._editOpenLabel===e.label,o=!!i&&i.length>0&&i.every(e=>e.isNew),s=!i||i.length===0,c=!r&&a&&(o||s);if(this.revertPendingChanges(e.label),this.pendingLevelDrags.delete(e.label),r)return;if(c){if(s){let t=this.levels.find(t=>t.label===e.label);this._editOpenLabel=null,this.selectedTradeLabel=null,this.renderTradeLayer(),t&&this.emitter.emit(`tradeLevelEditCancelled`,{label:e.label,type:t.type,isFullscreen:this.isFullscreen})}return}this._editOpenLabel===e.label&&(this._editOpenLabel=null);let l=this.levels.find(t=>t.label===e.label),u=(l==null?void 0:l.type)===`position`&&!!l.entryPriceEditable,d=e.type===`position`&&!u?`CLOSED`:`CANCELLED`;this.emitter.emit(`tradeLevelClose`,{label:e.label,type:e.type,action:d,data:e.data,isFullscreen:this.isFullscreen})}_activateMobileCrosshair(e,t){var n,r,i;if(!this.crosshairEnabled)return;let a=(n=this._cachedDrawRect)==null?this.drawCanvas.getBoundingClientRect():n,{chartW:o,priceH:s}=this.getChartLayout(),c=(r=this._displayedPriceRange)==null?this.getScaledPriceRange(this.viewport):r,l=a.height-this.timeAxisHeight;if(e>=o||t>=l)return;this._mobileCrosshairActive=!0;let u=this.scaleManager.pixelToBarIndex(e,this.viewport,o),d=this.scaleManager.pixelToPrice(t,c,s),f=Math.max(Math.floor(this.viewport.startIndex),Math.min(Math.ceil(this.viewport.endIndex),Math.round(u))),p=(i=this.dataStore.all[f])==null?null:i;this.crosshair=this.selectedTradeLabel===null&&this.crosshairEnabled?{x:e,y:t,barIndex:f,price:d,bar:p}:null,this.tradeButton&&(this.tradeButton.setY(t),this._isTradingActive||!this.crosshairEnabled||qt(t,this.uiConfig.tradeButton.size/2,this.offViewportHitAreas)?this.tradeButton.hide():this.tfcActive&&this.tradeButton.show(),this._tradeButtonClickData={price:d,y:t}),this.scheduleRender()}_cancelEditAndDeselect(e){let t=this._editOpenLabel===e,n=this.levels.find(t=>t.label===e);this._editOpenLabel=null,this.selectedTradeLabel=null,this.draftBracketPnl={},this.renderTradeLayer(),t&&n&&this.emitter.emit(`tradeLevelEditCancelled`,{label:e,type:n.type,isFullscreen:this.isFullscreen})}_openTradeLevelEditForm(e){if(this._editOpenLabel===e.label)return;this.selectedTradeLabel=e.label,this._editOpenLabel=e.label;let{slPrice:t,tpPrice:n}=this._resolveBracketPrices(e);this.renderTradeLayer(),this.emitter.emit(`tradeLevelEditOpen`,{label:e.label,type:e.type,data:e.data,price:e.price,side:e.side,stopLossPrice:t,takeProfitPrice:n,isFullscreen:this.isFullscreen})}_needsDragAxisLock(e,t){return this._orderTimeDragEnabled&&!e.isBracket&&e.timeDrag===!0&&ut(t)}_upgradePendingTradeDrag(e,t){let r=this._pendingTradeDrag;if(!r)return!1;let i=bu.resolveDragAxis(e-r.startX,t-r.startY,r.axisLock?n.AXIS_LOCK_PIXEL_THRESHOLD:n.TRADE_DRAG_PIXEL_THRESHOLD);if(i===null)return!1;this._pendingTradeDrag=null;let a=r.axisLock&&i===`price`?{...r.dragHit,timeDrag:!1}:r.dragHit;return this._startTradeDragFromHit(a,r.level,r.hitY,r.startX),!0}_startTradeDragFromHit(e,t,n,r){var i;if(!this.tradeDragHandler)return;if(this._orderTimeDragEnabled&&this.orderTimeDragHandler&&!e.isBracket&&e.timeDrag===!0){var a,o,s;let{chartW:n}=this.getChartLayout(),i=e,c=(a=this._orderLineAnchorX(t,n))==null?n/2:a,l=Math.max(i.x,Math.min(i.x+i.w,c)),u=this.scaleManager.pixelToBarIndex(l,this.viewport,n),d=(o=(s=this._resolvedTimeAnchor(t))==null?this.barIndexToTimestamp(u):s)==null?0:o;this.orderTimeDragHandler.start(t,r==null?l:r,l,u,d),this.drawCanvas.style.cursor=`grabbing`,this.emitter.emit(`orderLineMoveStart`,{label:t.label,fromTimestamp:d,fromBarIndex:this.orderTimeDragHandler.startBarIndex,isFullscreen:this.isFullscreen}),this.renderTradeLayer();return}let{priceH:c}=this.getChartLayout(),l=(i=this._displayedPriceRange)==null?this.getScaledPriceRange(this.viewport):i,u=this.scaleManager.yToPixel(e.price,l,c);if(e.isBracket){var d,f,p,m;this._pendingBracketOrderLabel=(d=e.bracketOrderLabel)==null?null:d,this._isBracketNew=!1;let r=t.entryPriceEditable===!0,i=((f=t.data)==null?void 0:f._isDraft)===!0,a=this.dataStore.all,o=t.type===`position`&&!r&&!i?(p=(m=a[a.length-1])==null?void 0:m.close)==null?0:p:0;this.tradeDragHandler.startBracketDrag(t,e.bracketType,e.price,n,u,o,this._effectiveEntryPrice(t.label,t.price)),this.emitter.emit(`tradeLevelDragStart`,{label:t.label,bracketType:e.bracketType,isFullscreen:this.isFullscreen})}else if(this._pendingBracketOrderLabel=null,t.entryPriceEditable===!0){var h,g;this.selectedTradeLabel=e.label;let r=t,i=this.dataStore.all,a=(h=(g=i[i.length-1])==null?void 0:g.close)==null?0:h,o=this._effectiveBracketPrice(t.label,`stopLoss`,r.stopLossPrice),s=this._effectiveBracketPrice(t.label,`takeProfit`,r.takeProfitPrice);this.tradeDragHandler.startDrag(t,n,u,e.price,o,s,r.side,a,r.orderType,!0)}else{var _,v;let r=t,i=this.dataStore.all,a=(_=(v=i[i.length-1])==null?void 0:v.close)==null?0:_,{slPrice:o,tpPrice:s,slSiblingLabel:c,tpSiblingLabel:l}=this._resolveBracketPrices(t);this._slSiblingOrderLabel=c==null?null:c,this._tpSiblingOrderLabel=l==null?null:l;let d=this._effectiveBracketPrice(t.label,`stopLoss`,o),f=this._effectiveBracketPrice(t.label,`takeProfit`,s);this.tradeDragHandler.startDrag(t,n,u,e.price,d,f,r.side,a,r.orderType,!0)}e.isBracket&&(this._editOpenLabel=null),this._openTradeLevelEditForm(t)}_endOrderTimeDrag(){var e;if(!((e=this.orderTimeDragHandler)!=null&&e.active))return!1;let t=this.orderTimeDragHandler.end(this._orderLineDragSnap,this.viewport);if(this.tradeDragNewBarIndex=null,this.drawCanvas.style.cursor=`default`,t){let e=this.barIndexToTimestamp(t.newBarIndex),r=Math.round(t.startBarIndex);if(e!==void 0&&t.newBarIndex!==r){var n;this._timeAnchorOverride.set(t.label,e),(n=this._orderLineAnchorStore)==null||n.set(t.label,e),this.emitter.emit(`orderLineMoved`,{label:t.label,fromTimestamp:t.startTimestamp,toTimestamp:e,fromBarIndex:r,toBarIndex:t.newBarIndex,data:t.data,isFullscreen:this.isFullscreen})}}return this.renderTradeLayer(),!0}_startAddBracketFromHit(e,t){var n,r,i;let a=this.levels.find(t=>t.label===e.label);if(!a||!this.tradeDragHandler)return;let{priceH:o}=this.getChartLayout(),s=this.getScaledPriceRange(this.viewport),c=e.y+e.h/2,l=this.scaleManager.pixelToPrice(c,s,o),u=a.entryPriceEditable===!0,d=((n=a.data)==null?void 0:n._isDraft)===!0,f=this.dataStore.all,p=a.type===`position`&&!u&&!d?(r=(i=f[f.length-1])==null?void 0:i.close)==null?0:r:0;this._pendingBracketOrderLabel=null,this._isBracketNew=!0,this.tradeDragHandler.startBracketDrag(a,e.bracketType,l,t,c,p,this._effectiveEntryPrice(a.label,a.price)),this.emitter.emit(`tradeLevelDragStart`,{label:a.label,bracketType:e.bracketType,isFullscreen:this.isFullscreen})}showTextInput(e){var t;if(!this.textInputEl)return;this.textInputDrawing=e;let{chartW:n,priceH:r}=this.getChartLayout(),i=this.getScaledPriceRange(this.viewport),a,o;if(e.type===`text`)a=this.scaleManager.xToPixel(e.points[0].barIndex,this.viewport,n),o=this.scaleManager.yToPixel(e.points[0].price,i,r);else{var s;let t=(s=e.points[1])==null?e.points[0]:s;a=this.scaleManager.xToPixel(t.barIndex,this.viewport,n)-30,o=this.scaleManager.yToPixel(t.price,i,r)-10}let c=this.textInputEl;c.value=(t=e.text)==null?``:t,c.style.left=`${Math.max(0,a)}px`,c.style.top=`${Math.max(0,o)}px`,c.style.display=`block`,this.drawingManager.setEditingText(!0),c.focus(),c.select();let l=()=>{c.removeEventListener(`keydown`,d),c.removeEventListener(`blur`,f),this.commitTextInput()},u=()=>{c.removeEventListener(`keydown`,d),c.removeEventListener(`blur`,f),this.cancelTextInput()},d=e=>{e.key===`Enter`?(e.preventDefault(),l()):e.key===`Escape`&&(e.preventDefault(),u())},f=()=>l();c.addEventListener(`keydown`,d),c.addEventListener(`blur`,f,{once:!0})}commitTextInput(){var e,t;!this.textInputEl||!this.textInputDrawing||(this.textInputDrawing.text=this.textInputEl.value,this.textInputEl.style.display=`none`,this.textInputDrawing=null,this.drawingManager.setEditingText(!1),(e=(t=this.drawingManager).onDrawingsChange)==null||e.call(t),this.scheduleRender())}cancelTextInput(){this.textInputEl&&(this.textInputEl.style.display=`none`,this.textInputDrawing=null,this.drawingManager.setEditingText(!1),this.scheduleRender())}setDotTickActive(){this.siStreamDot&&(this.tickActivityTimer!==null&&clearTimeout(this.tickActivityTimer),this.siStreamDot.style.background=this.theme.candle.up,this.tickActivityTimer=setTimeout(()=>{this.tickActivityTimer=null,this.siStreamDot&&(this.siStreamDot.style.background=this.theme.ui.stream[this.streamStatus])},this.tickActivityMs))}fillTickGap(e,t){if(!this.dataLoader||this.isFetching)return;let n=this.timeframeToInterval(this.getBaseInterval());this.dataLoader({start:new Date(e),end:new Date(t),interval:n,priceSource:this.tickClosePriceSource}).then(e=>{let t=this.maybeAggregate(e);if(t.length===0)return;this.backfillDrawingTimestamps();let n=this.dataStore.all,r=n[n.length-1],i=0;for(let e of t){if(e.time>=r.time)continue;let t=n.findIndex(t=>t.time===e.time);if(t!==-1)n[t]=e;else{let t=n.findIndex(t=>t.time>e.time);n.splice(t===-1?n.length-1:t,0,e),i++}}i>0&&(this.viewport={...this.viewport,startIndex:this.viewport.startIndex+i,endIndex:this.viewport.endIndex+i},this.reanchorDrawingsByTimestamp(),this.recomputeIndicators(),this.scheduleRender())}).catch(()=>{})}correctCompletedBar(e,t){if(!this.dataLoader||this.isFetching)return;let n=new Date(e),r=new Date(e+t*3),i=this.timeframeToInterval(this.getBaseInterval());this.dataLoader({start:n,end:r,interval:i,priceSource:this.tickClosePriceSource}).then(e=>{let t=this.maybeAggregate(e);if(t.length===0)return;let n=this.dataStore.all,r=n.length-1,i=!1;for(let e of t){let t=n.findIndex(t=>t.time===e.time);t!==-1&&t!==r&&(n[t]=e,i=!0)}i&&(this.recomputeIndicators(),this.scheduleRender())}).catch(()=>{})}setLayoutIcon(e,t=!0){var n;return(n=this.advancedToolbar)==null||n.setLayoutPresetIcon(e,t),this}setDebug(e){return this._debug=e,this}correctBar(e,t){let n=this.dataStore.all,r=n.findIndex(t=>t.time===e);r!==-1&&(n[r]=t,this.recomputeIndicators(),this.scheduleRender())}scrollToEnd(){this.panHandler.cancel(),this.scrollAnimId!==null&&(cancelAnimationFrame(this.scrollAnimId),this.scrollAnimId=null);let e=this.viewport.endIndex-this.viewport.startIndex,t=this.dataStore.length+Ld,n=this.viewport.endIndex,r=this.pricePanOffset,i=performance.now(),a=e=>e<.5?2*e*e:-1+(4-2*e)*e,o=s=>{let c=Math.min((s-i)/350,1),l=a(c),u=n+(t-n)*l;this.viewport={...this.viewport,startIndex:u-e,endIndex:u},this._targetViewport={...this.viewport},this.pricePanOffset=r*(1-l),this.render(),c<1?this.scrollAnimId=requestAnimationFrame(o):this.scrollAnimId=null};this.scrollAnimId=requestAnimationFrame(o)}scrollToCenterPrice(e){if(!isFinite(e)||this.dataStore.length===0)return;this.scrollAnimId!==null&&(cancelAnimationFrame(this.scrollAnimId),this.scrollAnimId=null);let t=this.dataStore.getPriceRange(this.viewport),n=(t.min+t.max)/2,r=this.pricePanOffset,i=e-n;if(Math.abs(i-r)<1e-9)return;let a=performance.now(),o=e=>e<.5?2*e*e:-1+(4-2*e)*e,s=e=>{let t=Math.min((e-a)/350,1),n=o(t);this.pricePanOffset=r+(i-r)*n,this.render(),t<1?this.scrollAnimId=requestAnimationFrame(s):this.scrollAnimId=null};this.scrollAnimId=requestAnimationFrame(s)}_revealPrices(e){var t;if(this.dataStore.length===0||this._lastInCompareMode)return;let{priceH:n}=this.getChartLayout(),r=(t=this._displayedPriceRange)==null?this.getScaledPriceRange(this.viewport):t,i=Cu(r,e,n);if(!i)return;this.scrollAnimId!==null&&(cancelAnimationFrame(this.scrollAnimId),this.scrollAnimId=null),this._lockedAutoFitBase||(this._lockedAutoFitBase={...r});let{factor:a,panOffset:o}=wu(this._lockedAutoFitBase,i),s=this.priceScaleFactor,c=this.pricePanOffset;if(Math.abs(a-s)<1e-9&&Math.abs(o-c)<1e-9)return;let l=performance.now(),u=e=>e<.5?2*e*e:-1+(4-2*e)*e,d=e=>{let t=Math.min((e-l)/350,1),n=u(t);this.priceScaleFactor=s+(a-s)*n,this.pricePanOffset=c+(o-c)*n,this.render(),t<1?this.scrollAnimId=requestAnimationFrame(d):(this.scrollAnimId=null,this.scheduleViewportPersist())};this.scrollAnimId=requestAnimationFrame(d)}_currentMarketPrice(){var e,t;let n=this.liveBidAsk;if(n)return n.ask||n.bid;let r=this.dataStore.all;return(e=(t=r[r.length-1])==null?void 0:t.close)==null?0:e}resetPriceAxis(){this.priceScaleFactor=1,this.pricePanOffset=0,this._lockedAutoFitBase=null,this.scheduleRender()}resetTimeAxis(){this.panHandler.cancel();let e=this.dataStore.length;if(e===0)return;let t=Id(this.mobileBarDivisor,this.explicitMobileDivisor,this.defaultVisibleBars,this.defaultMobileVisibleBars);this._defaultVisibleBars=t;let n=Math.max(0,e-t+Ld);this.viewport={...this.viewport,startIndex:n,endIndex:e+Ld},this._targetViewport={...this.viewport},this.scheduleRender()}resetView(){this.resetPriceAxis(),this.resetTimeAxis()}applyOverlayLabelStyles(){for(let e of[this.loadingLabelEl,this.noDataLabelEl])e&&Object.assign(e.style,{color:this.theme.tooltip.text,background:this.theme.tooltip.background,border:`1px solid ${this.theme.tooltip.border}`})}applyResetViewBtnStyles(){this.resetViewBtn&&(this.resetViewBtn.innerHTML=Tn(this.theme.axisText,16),Object.assign(this.resetViewBtn.style,{position:`absolute`,bottom:`${this.timeAxisHeight+8}px`,left:`50%`,transform:`translateX(-50%)`,zIndex:`100`,width:`32px`,height:`32px`,padding:`0`,display:`flex`,alignItems:`center`,justifyContent:`center`,backgroundColor:this.theme.background,border:`1px solid ${this.theme.axisBorder}`,borderRadius:`50%`,cursor:`pointer`,outline:`none`,boxShadow:`0 2px 6px rgba(0,0,0,0.25)`,opacity:`0`,pointerEvents:`none`,transition:`opacity 0.2s ease`}))}applyScrollToEndBtnStyles(){if(!this.scrollToEndBtn)return;let e=this.theme.ui.scrollToEndBtnBg,t=e?`#ffffff`:this.theme.axisText,n=e==null?this.theme.background:e,r=e==null?this.theme.axisBorder:e;this.scrollToEndBtn.innerHTML=wn(t,16),Object.assign(this.scrollToEndBtn.style,{position:`absolute`,bottom:`${this.timeAxisHeight+8}px`,right:`${this.priceAxisWidth+8}px`,zIndex:`100`,width:`32px`,height:`32px`,padding:`0`,display:`flex`,alignItems:`center`,justifyContent:`center`,backgroundColor:n,border:`1px solid ${r}`,borderRadius:`50%`,cursor:`pointer`,outline:`none`,boxShadow:`0 2px 6px rgba(0,0,0,0.25)`,opacity:`0`,pointerEvents:`none`,transition:`opacity 0.2s ease`})}};_d=Bd,_d.DRAW_GESTURE_THRESHOLD=4,_d.TOUCH_HANDLE_SLOP_PX=18,_d.TRADE_DRAG_PIXEL_THRESHOLD=3,_d.AXIS_LOCK_PIXEL_THRESHOLD=6;var Q=null,Vd=new Map,Hd=new Map,Ud=0;function Wd(){return`dr_${Date.now()}_${Ud++}`}function Gd(){return`cr_${Date.now()}_${Ud++}`}function $(e,t){var n;let r=JSON.stringify({type:e,payload:t});window.ChartAndroidBridge?window.ChartAndroidBridge.postMessage(r):!((n=window.webkit)==null||(n=n.messageHandlers)==null)&&n.chartBridge?window.webkit.messageHandlers.chartBridge.postMessage(r):window.ReactNativeWebView&&window.ReactNativeWebView.postMessage(r)}function Kd(e={}){var t;Q==null||Q.destroy();let n=document.getElementById(`chart`),{enableTrading:r,onSymbolClick:i,onAskAiClick:a,orderLineTimeDrag:o,enableForecasting:s,...c}=e,l={...c.features,...o?{orderLineTimeDrag:!0}:{},...s?{enableForecasting:!0}:{}},u=(t=c.timeframe)==null?`1D`:t;Q=new Bd({theme:`dark`,...c,...Object.keys(l).length>0?{features:l}:{},container:n,dataLoader:e=>{for(let[,e]of Vd)e.reject(Error(`cancelled`));Vd.clear();let t=Wd(),n=Q==null?void 0:Q.getState();return new Promise((r,i)=>{var a;Vd.set(t,{resolve:r,reject:i}),$(`dataRequest`,{requestId:t,timeframe:(a=n==null?void 0:n.timeframe)==null?u:a,interval:e.interval,start:e.start.getTime(),end:e.end.getTime(),priceSource:e.priceSource})})},compareDataLoader:e=>{let t=Gd(),n=Q==null?void 0:Q.getState();return new Promise((r,i)=>{var a;Hd.set(t,{resolve:r,reject:i}),$(`compareDataRequest`,{requestId:t,symbol:e.symbol,timeframe:(a=n==null?void 0:n.timeframe)==null?u:a,interval:e.interval,start:e.start.getTime(),end:e.end.getTime()})})},...r?{onOrderSubmit:e=>{var t;$(`placeOrder`,{price:e.price,side:e.side,orderType:(t=e.orderType)==null?`limit`:t})}}:{},...i?{onSymbolClick:e=>{$(`symbolClick`,{symbol:e})}}:{},...a?{onAskAiClick:()=>{$(`askAiClick`,{})}}:{}}),Q.on(`timeframeChange`,({timeframe:e})=>{u=e}),Q.on(`crosshair`,e=>$(`crosshair`,e)),Q.on(`click`,e=>$(`barClick`,e)),Q.on(`zoom`,({viewport:e})=>$(`viewportChange`,{viewport:e})),Q.on(`pan`,({viewport:e})=>$(`viewportChange`,{viewport:e})),Q.on(`seriesChange`,e=>$(`seriesChange`,e)),Q.on(`priceSourceChange`,e=>$(`priceSourceChange`,e)),Q.on(`timeframeChange`,e=>$(`timeframeChange`,e)),Q.on(`durationChange`,e=>$(`durationChange`,e)),Q.on(`stateChange`,e=>$(`stateChange`,e)),Q.on(`dataLoaded`,e=>$(`dataLoaded`,e)),Q.on(`newBar`,e=>$(`newBar`,e)),Q.on(`streamStatus`,e=>$(`streamStatus`,e)),Q.on(`tradeLevelClose`,e=>$(`tradeLevelClose`,e)),Q.on(`tradeLevelDrag`,e=>$(`tradeLevelDrag`,e)),Q.on(`tradeLevelDragStart`,e=>$(`tradeLevelDragStart`,e)),Q.on(`tradeLevelEdit`,e=>$(`tradeLevelEdit`,e)),Q.on(`tradeLevelQtyChange`,e=>$(`tradeLevelQtyChange`,e)),Q.on(`tradeLevelConfirmed`,e=>$(`tradeLevelConfirmed`,e)),Q.on(`tradeLevelEditOpen`,e=>$(`tradeLevelEditOpen`,e)),Q.on(`tradeLevelBracketActivated`,e=>$(`tradeLevelBracketActivated`,e)),Q.on(`draftInitiated`,e=>$(`draftInitiated`,e)),Q.on(`draftCancelled`,e=>$(`draftCancelled`,e)),Q.on(`uiStateChange`,e=>$(`uiStateChange`,e)),Q.on(`orderLineMoveStart`,e=>$(`orderLineMoveStart`,e)),Q.on(`orderLineMoving`,e=>$(`orderLineMoving`,e)),Q.on(`orderLineMoved`,e=>$(`orderLineMoved`,e)),Q.on(`crosshairToggle`,e=>$(`crosshairToggle`,e)),Q.on(`compareAdded`,e=>$(`compareAdded`,e)),Q.on(`compareRemoved`,e=>$(`compareRemoved`,e)),Q.on(`compareError`,e=>$(`compareError`,e)),Q.on(`indicatorAdded`,e=>$(`indicatorAdded`,e)),Q.on(`indicatorRemoved`,e=>$(`indicatorRemoved`,e))}function qd(e){if(e.type===`init`){Kd(e.payload);return}if(!Q){$(`error`,{message:`Engine not initialized. Send an "init" command first.`});return}switch(e.type){case`loadData`:Q.loadData(e.payload.bars,e.payload.fitAll);break;case`pushTick`:Q.pushTick(e.payload);break;case`setTheme`:Q.setTheme(e.payload.theme);break;case`setTimezone`:Q.setTimezone(e.payload.timezone);break;case`setShowLtpPrice`:Q.setShowLtpPrice(e.payload.show);break;case`setShowAskLine`:Q.setShowAskLine(e.payload.show);break;case`setShowBidLine`:Q.setShowBidLine(e.payload.show);break;case`setTickClosePriceSource`:Q.setTickClosePriceSource(e.payload.source);break;case`setLayoutSync`:Q.setLayoutSync(e.payload);break;case`setCrosshairEnabled`:Q.setCrosshairEnabled(e.payload.enabled===!0);break;case`setSeries`:Q.setSeries(e.payload.series);break;case`setDuration`:Q.setDuration(e.payload.duration,e.payload.timeframe);break;case`setTimeframe`:Q.setTimeframe(e.payload.timeframe);break;case`setSymbol`:Q.setSymbol(e.payload.symbol);break;case`setInstrument`:Q.setInstrument(e.payload.instrument);break;case`setAccount`:Q.setAccount(e.payload.account);break;case`addIndicator`:Q.addIndicatorByName(e.payload.shortName,e.payload.params);break;case`removeIndicator`:Q.removeIndicator(e.payload.name);break;case`setDrawingTool`:Q.setDrawingTool(e.payload.tool);break;case`clearAllDrawings`:Q.clearAllDrawings();break;case`getState`:$(`stateSnapshot`,Q.getState());break;case`setState`:Q.setState(e.payload);break;case`resolveDataRequest`:{let t=Vd.get(e.payload.requestId);t&&(Vd.delete(e.payload.requestId),t.resolve(e.payload.bars));break}case`setDebug`:Q.setDebug(e.payload.enabled);break;case`destroy`:Q.destroy(),Q=null;break;case`setLevels`:Q.setLevels(e.payload.levels,e.payload.labelKey,e.payload.priceKey,e.payload.type,e.payload.pnlKey,e.payload.pnlTextKey);break;case`removeLevelByLabel`:Q.removeLevelByLabel(e.payload.label);break;case`updateLevelMainPrice`:Q.updateLevelMainPrice(e.payload.label,e.payload.price);break;case`updateLevelQty`:Q.updateLevelQty(e.payload.label,e.payload.qty);break;case`updateLevelBracket`:Q.updateLevelBracket(e.payload.label,e.payload.bracketType.toLowerCase(),e.payload.price);break;case`addLevelBracket`:Q.addLevelBracket(e.payload.label,e.payload.bracketType.toLowerCase());break;case`addBracket`:Q.addBracket(e.payload.bracketType.toLowerCase(),e.payload.label);break;case`removeBracket`:Q.removeBracket(e.payload.bracketType.toLowerCase(),e.payload.label);break;case`cancelLevelEdit`:Q.cancelLevelEdit(e.payload.label);break;case`selectLevel`:Q.selectLevel(e.payload.label);break;case`showDraftOrder`:Q.showDraftOrder(e.payload.price,e.payload.side,e.payload.orderType);break;case`showMarketDraft`:Q.showMarketDraft(e.payload.price,e.payload.side);break;case`clearDraftOrder`:Q.clearDraftOrder();break;case`cancelCurrentEdit`:Q.cancelCurrentEdit();break;case`updateDraftOrderPrice`:Q.updateDraftOrderPrice(e.payload.price);break;case`updateDraftOrderBracket`:Q.updateDraftOrderBracket(e.payload.bracketType,e.payload.price);break;case`setBracketLabelMode`:Q.setBracketLabelMode(e.payload.mode,e.payload.currencySymbol);break;case`setDraftBracketPnl`:Q.setDraftBracketPnl(e.payload.bracketType,e.payload.pnlText);break;case`setVolume`:Q.setVolume(e.payload.show);break;case`setIsins`:Q.setIsins(e.payload.isins);break;case`resetView`:Q.resetView();break;case`resetData`:Q.resetData();break;case`setLoading`:Q.setLoading(e.payload.loading);break;case`setThemeOverrides`:Q.setThemeOverrides(e.payload.overrides);break;case`setCanvasColors`:var t;Q.setCanvasColors((t=e.payload.colors)==null?null:t);break;case`correctBar`:Q.correctBar(e.payload.barTime,e.payload.bar);break;case`dismissAllUI`:Q.dismissAllUI();break;case`addCompare`:Q.addCompare(e.payload.symbol);break;case`removeCompare`:Q.removeCompare(e.payload.symbol);break;case`clearCompares`:Q.clearCompares();break;case`resolveCompareDataRequest`:{let t=Hd.get(e.payload.requestId);t&&(Hd.delete(e.payload.requestId),t.resolve(e.payload.bars));break}}}document.addEventListener(`DOMContentLoaded`,()=>{window.ChartBridge={send(e){let t;try{t=JSON.parse(e)}catch(t){$(`error`,{message:`Invalid JSON: ${e}`});return}try{qd(t)}catch(e){$(`error`,{message:String(e)})}}},$(`ready`,{})})})();</script>
|
|
271
279
|
</body>
|
|
272
280
|
</html>
|