velo-plot 3.1.0 → 4.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{ChartCore-AnR_3Xkb.js → ChartCore-KYG2HTcK.js} +1349 -1213
- package/dist/ChartCore-KYG2HTcK.js.map +1 -0
- package/dist/{PluginRegistry-CzMHebYP.js → PluginRegistry-CDf_jcnp.js} +2 -2
- package/dist/{PluginRegistry-CzMHebYP.js.map → PluginRegistry-CDf_jcnp.js.map} +1 -1
- package/dist/SVGDocumentBuilder-C-uLkcFW.js +83 -0
- package/dist/SVGDocumentBuilder-C-uLkcFW.js.map +1 -0
- package/dist/angular-hooks.js +1 -1
- package/dist/angular.js +4 -4
- package/dist/{chartSyncBridge-D_rCtbFq.js → chartSyncBridge-C1uRy0ZS.js} +3 -3
- package/dist/{chartSyncBridge-D_rCtbFq.js.map → chartSyncBridge-C1uRy0ZS.js.map} +1 -1
- package/dist/core/chart/ChartCore.d.ts +7 -3
- package/dist/core/chart/ChartRenderLoop.d.ts +5 -0
- package/dist/core/chart/ChartRenderer.d.ts +9 -0
- package/dist/core/chart/ChartSetup.d.ts +1 -0
- package/dist/core/chart/exporter/SVGExporter.d.ts +9 -7
- package/dist/core/chart/exporter/svg/SVGDocumentBuilder.d.ts +27 -0
- package/dist/core/chart/exporter/svg/SVGExportContext.d.ts +147 -0
- package/dist/core/chart/exporter/svg/SVGOrchestrator.d.ts +3 -0
- package/dist/core/chart/exporter/svg/SVGThemeAdapter.d.ts +22 -0
- package/dist/core/chart/exporter/svg/__tests__/testFixtures.d.ts +46 -0
- package/dist/core/chart/exporter/svg/__tests__/visualTestUtils.d.ts +12 -0
- package/dist/core/chart/exporter/svg/overlay/axes.d.ts +4 -0
- package/dist/core/chart/exporter/svg/overlay/border.d.ts +4 -0
- package/dist/core/chart/exporter/svg/overlay/errorBars.d.ts +7 -0
- package/dist/core/chart/exporter/svg/overlay/grid.d.ts +4 -0
- package/dist/core/chart/exporter/svg/overlay/index.d.ts +12 -0
- package/dist/core/chart/exporter/svg/overlay/legend.d.ts +4 -0
- package/dist/core/chart/exporter/svg/overlay/pluginCharts.d.ts +6 -0
- package/dist/core/chart/exporter/svg/overlay/polarGrid.d.ts +4 -0
- package/dist/core/chart/exporter/svg/overlay/specialChart.d.ts +15 -0
- package/dist/core/chart/exporter/svg/overlay/title.d.ts +4 -0
- package/dist/core/chart/exporter/svg/plugins/annotations.d.ts +5 -0
- package/dist/core/chart/exporter/svg/plugins/brokenAxis.d.ts +20 -0
- package/dist/core/chart/exporter/svg/plugins/latex.d.ts +9 -0
- package/dist/core/chart/exporter/svg/plugins/register.d.ts +8 -0
- package/dist/core/chart/exporter/svg/plugins/regression.d.ts +33 -0
- package/dist/core/chart/exporter/svg/plugins/roi.d.ts +12 -0
- package/dist/core/chart/exporter/svg/plugins/tradeMarkers.d.ts +3 -0
- package/dist/core/chart/exporter/svg/plugins/types.d.ts +28 -0
- package/dist/core/chart/exporter/svg/plugins/watermark.d.ts +13 -0
- package/dist/core/chart/exporter/svg/series/band.d.ts +6 -0
- package/dist/core/chart/exporter/svg/series/bar.d.ts +6 -0
- package/dist/core/chart/exporter/svg/series/boxplot.d.ts +6 -0
- package/dist/core/chart/exporter/svg/series/candlestick.d.ts +6 -0
- package/dist/core/chart/exporter/svg/series/finitePoints.d.ts +6 -0
- package/dist/core/chart/exporter/svg/series/gauge.d.ts +5 -0
- package/dist/core/chart/exporter/svg/series/heatmap.d.ts +6 -0
- package/dist/core/chart/exporter/svg/series/indicator.d.ts +6 -0
- package/dist/core/chart/exporter/svg/series/line.d.ts +12 -0
- package/dist/core/chart/exporter/svg/series/polar.d.ts +6 -0
- package/dist/core/chart/exporter/svg/series/radar.d.ts +5 -0
- package/dist/core/chart/exporter/svg/series/registry.d.ts +10 -0
- package/dist/core/chart/exporter/svg/series/sankey.d.ts +5 -0
- package/dist/core/chart/exporter/svg/series/scatter.d.ts +1 -0
- package/dist/core/chart/exporter/svg/series/ternary.d.ts +7 -0
- package/dist/core/chart/exporter/svg/series/waterfall.d.ts +6 -0
- package/dist/core/chart/exporter/svg/seriesAtTimestamp.d.ts +4 -0
- package/dist/core/chart/exporter/svg/seriesUtils.d.ts +3 -0
- package/dist/core/chart/exporter/svg/symbols.d.ts +5 -0
- package/dist/core/chart/exporter/svg/tickUtils.d.ts +9 -0
- package/dist/core/chart/mountSVGString.d.ts +5 -0
- package/dist/core/chart/types.d.ts +2 -2
- package/dist/core/stacked/StackSVGComposer.d.ts +14 -0
- package/dist/core/stacked/index.d.ts +3 -2
- package/dist/core/stacked/types.d.ts +12 -4
- package/dist/createStackedChart-DjA3aJAu.js +2761 -0
- package/dist/createStackedChart-DjA3aJAu.js.map +1 -0
- package/dist/{hooks-DH-3bewj.js → hooks-4wQH27r9.js} +3 -3
- package/dist/{hooks-DH-3bewj.js.map → hooks-4wQH27r9.js.map} +1 -1
- package/dist/index-Bj-xyXY6.js +582 -0
- package/dist/index-Bj-xyXY6.js.map +1 -0
- package/dist/plugins/PluginManager.d.ts +5 -0
- package/dist/plugins/annotations.js +8 -7
- package/dist/plugins/annotations.js.map +1 -1
- package/dist/plugins/broken-axis.js +198 -152
- package/dist/plugins/broken-axis.js.map +1 -1
- package/dist/plugins/forecasting.js +273 -258
- package/dist/plugins/forecasting.js.map +1 -1
- package/dist/plugins/ml-integration.js +107 -93
- package/dist/plugins/ml-integration.js.map +1 -1
- package/dist/plugins/radar/types.d.ts +11 -0
- package/dist/plugins/radar.js +64 -53
- package/dist/plugins/radar.js.map +1 -1
- package/dist/plugins/roi/index.d.ts +2 -0
- package/dist/plugins/roi.js +184 -145
- package/dist/plugins/roi.js.map +1 -1
- package/dist/plugins/snapshot.js +20 -15
- package/dist/plugins/snapshot.js.map +1 -1
- package/dist/plugins/types.d.ts +4 -0
- package/dist/react.js +2 -2
- package/dist/regression-HNdyk1Dm.js +28 -0
- package/dist/regression-HNdyk1Dm.js.map +1 -0
- package/dist/renderer/ChartSeriesRenderer.d.ts +3 -2
- package/dist/renderer/SVGChartRenderer.d.ts +15 -0
- package/dist/renderer/SankeyRenderer.d.ts +1 -0
- package/dist/renderer/registerSVG.d.ts +5 -0
- package/dist/renderer/sankeyLayout.d.ts +29 -0
- package/dist/scientific.js +2 -2
- package/dist/solid.js +2 -2
- package/dist/svelte.js +2 -2
- package/dist/tickUtils-B_X-ha13.js +41 -0
- package/dist/tickUtils-B_X-ha13.js.map +1 -0
- package/dist/trading.js +3 -3
- package/dist/types.d.ts +2 -1
- package/dist/velo-plot.full.js +1107 -1292
- package/dist/velo-plot.full.js.map +1 -1
- package/dist/velo-plot.js +2 -2
- package/dist/vue/VeloPlot.vue.d.ts +1 -1
- package/dist/vue/index.d.ts +33 -33
- package/dist/vue.js +2 -2
- package/package.json +6 -1
- package/dist/ChartCore-AnR_3Xkb.js.map +0 -1
- package/dist/createStackedChart-DqcLCFGS.js +0 -1338
- package/dist/createStackedChart-DqcLCFGS.js.map +0 -1
- package/dist/index-Cv6ZDLWf.js +0 -521
- package/dist/index-Cv6ZDLWf.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createStackedChart-DjA3aJAu.js","sources":["../src/renderer/BarRenderer.ts","../src/renderer/sankeyLayout.ts","../src/core/chart/exporter/svg/seriesAtTimestamp.ts","../src/core/chart/exporter/svg/SVGExportContext.ts","../src/core/chart/exporter/svg/SVGThemeAdapter.ts","../src/core/chart/exporter/svg/overlay/grid.ts","../src/core/chart/exporter/svg/overlay/axes.ts","../src/core/chart/exporter/svg/overlay/title.ts","../src/core/chart/exporter/svg/overlay/border.ts","../src/core/chart/exporter/svg/symbols.ts","../src/core/chart/exporter/svg/overlay/legend.ts","../src/core/chart/exporter/svg/seriesUtils.ts","../src/core/chart/exporter/svg/overlay/errorBars.ts","../src/core/chart/exporter/svg/overlay/specialChart.ts","../src/core/chart/exporter/svg/overlay/polarGrid.ts","../src/core/chart/exporter/svg/overlay/pluginCharts.ts","../src/core/chart/exporter/svg/overlay/index.ts","../src/core/chart/exporter/svg/series/finitePoints.ts","../src/core/chart/exporter/svg/series/line.ts","../src/core/chart/exporter/svg/series/bar.ts","../src/core/chart/exporter/svg/series/band.ts","../src/core/chart/exporter/svg/series/candlestick.ts","../src/core/chart/exporter/svg/series/heatmap.ts","../src/core/chart/exporter/svg/series/polar.ts","../src/core/chart/exporter/svg/series/gauge.ts","../src/core/chart/exporter/svg/series/sankey.ts","../src/core/chart/exporter/svg/series/ternary.ts","../src/core/chart/exporter/svg/series/waterfall.ts","../src/core/chart/exporter/svg/series/boxplot.ts","../src/core/indicator/buildIndicatorSeries.ts","../src/core/chart/exporter/svg/series/indicator.ts","../src/core/chart/exporter/svg/series/registry.ts","../src/core/chart/exporter/svg/plugins/annotations.ts","../src/core/chart/exporter/svg/plugins/tradeMarkers.ts","../src/core/chart/exporter/svg/series/radar.ts","../src/core/chart/exporter/svg/plugins/types.ts","../src/core/chart/exporter/svg/plugins/register.ts","../src/core/chart/exporter/svg/plugins/watermark.ts","../src/core/chart/exporter/svg/SVGOrchestrator.ts","../src/core/indicator/buildIndicatorPane.ts","../src/workers/indicatorsAsync.ts","../src/core/indicator/indicatorPresets.ts","../src/core/indicator/addIndicator.ts","../src/core/stacked/types.ts","../src/core/stacked/stackExport.ts","../src/core/stacked/StackSVGComposer.ts","../src/core/stacked/paneResize.ts","../src/core/stacked/paneAxis.ts","../src/core/stacked/createStackedChart.ts"],"sourcesContent":["/**\n * Prepare bar chart data for WebGL rendering\n * Creates rectangle vertices for each bar (2 triangles per bar = 6 vertices)\n * \n * @param x - X positions of bar centers\n * @param y - Y heights of bars\n * @param barWidth - Width of each bar in data units\n * @returns Interleaved vertex data ready for gl.TRIANGLES\n */\nexport function interleaveBarData(\n x: Float32Array | Float64Array | number[],\n y: Float32Array | Float64Array | number[],\n barWidth: number\n): Float32Array {\n const n = Math.min(x.length, y.length);\n // Each bar = 2 triangles = 6 vertices, 2 floats per vertex\n const result = new Float32Array(n * 6 * 2);\n \n const halfWidth = barWidth * 0.5;\n \n for (let i = 0; i < n; i++) {\n const xi = x[i];\n const yi = y[i];\n const base = i * 12; // 6 vertices * 2 floats\n \n // Define bar corners\n const x0 = xi - halfWidth; // Left\n const x1 = xi + halfWidth; // Right\n const y0 = 0; // Bottom\n const y1 = yi; // Top\n \n // First triangle (bottom-left, bottom-right, top-left)\n result[base + 0] = x0;\n result[base + 1] = y0;\n result[base + 2] = x1;\n result[base + 3] = y0;\n result[base + 4] = x0;\n result[base + 5] = y1;\n \n // Second triangle (top-left, bottom-right, top-right)\n result[base + 6] = x0;\n result[base + 7] = y1;\n result[base + 8] = x1;\n result[base + 9] = y0;\n result[base + 10] = x1;\n result[base + 11] = y1;\n }\n \n return result;\n}\n\n/**\n * Calculate automatic bar width based on data spacing\n */\nexport function calculateBarWidth(x: Float32Array | Float64Array | number[]): number {\n if (x.length < 2) return 1.0;\n \n // Find minimum spacing between consecutive bars\n let minSpacing = Infinity;\n for (let i = 1; i < x.length; i++) {\n const spacing = Math.abs(x[i] - x[i - 1]);\n if (spacing > 0 && spacing < minSpacing) {\n minSpacing = spacing;\n }\n }\n \n // Bar width is 80% of minimum spacing (20% gap)\n return minSpacing === Infinity ? 1.0 : minSpacing * 0.8;\n}\n","import type {\n SankeyData,\n SankeyStyle,\n PlotArea,\n SankeyNode,\n SankeyLink,\n} from \"../types\";\n\nexport interface SankeyNodeLayout {\n x: number;\n y: number;\n width: number;\n height: number;\n color: string;\n value: number;\n}\n\nexport interface SankeyLinkLayout {\n source: SankeyNodeLayout;\n target: SankeyNodeLayout;\n sourceOffset: number;\n targetOffset: number;\n sourceTotal: number;\n targetTotal: number;\n value: number;\n link: SankeyLink;\n}\n\nexport interface SankeyLayoutResult {\n workingArea: PlotArea;\n nodeRegistry: Map<string | number, SankeyNodeLayout>;\n links: SankeyLinkLayout[];\n nodeInValue: Map<string | number, number>;\n nodeOutValue: Map<string | number, number>;\n style: Required<\n Pick<SankeyStyle, \"nodeWidth\" | \"nodePadding\" | \"palette\" | \"linkOpacity\" | \"showLabels\">\n >;\n}\n\nexport function computeSankeyLayout(\n data: SankeyData,\n style: SankeyStyle,\n plotArea: PlotArea,\n): SankeyLayoutResult | null {\n const { nodes, links } = data;\n const {\n nodeWidth = 18,\n nodePadding = 12,\n palette = [\"#6366f1\", \"#10b981\", \"#3b82f6\", \"#f43f5e\", \"#f59e0b\"],\n linkOpacity = 0.4,\n showLabels = true,\n } = style;\n\n if (!links.length) return null;\n\n const zoomFactor = 1.8;\n const effectiveWidth = plotArea.width / zoomFactor;\n const effectiveHeight = plotArea.height / zoomFactor;\n const offsetX = (plotArea.width - effectiveWidth) / 2;\n const offsetY = (plotArea.height - effectiveHeight) / 2;\n\n const workingArea = {\n x: plotArea.x + offsetX,\n y: plotArea.y + offsetY,\n width: effectiveWidth,\n height: effectiveHeight,\n };\n\n const allNodeIds = new Set<string | number>();\n links.forEach((l: SankeyLink) => {\n allNodeIds.add(l.source);\n allNodeIds.add(l.target);\n });\n const nodeIds = Array.from(allNodeIds);\n\n const nodeLevels = new Map<string | number, number>();\n const targets = new Set(links.map((l: SankeyLink) => l.target));\n const roots = nodeIds.filter((id) => !targets.has(id));\n\n roots.forEach((id) => nodeLevels.set(id, 0));\n\n let changed = true;\n while (changed) {\n changed = false;\n links.forEach((l: SankeyLink) => {\n const srcLevel = nodeLevels.get(l.source);\n if (srcLevel !== undefined) {\n const currentDstLevel = nodeLevels.get(l.target);\n const newDstLevel = srcLevel + 1;\n if (currentDstLevel === undefined || newDstLevel > currentDstLevel) {\n nodeLevels.set(l.target, newDstLevel);\n changed = true;\n }\n }\n });\n }\n\n nodeIds.forEach((id) => {\n if (nodeLevels.get(id) === undefined) nodeLevels.set(id, 0);\n });\n\n const maxLevel = Math.max(...Array.from(nodeLevels.values()));\n const layers: (string | number)[][] = Array.from({ length: maxLevel + 1 }, () => []);\n nodeIds.forEach((id) => layers[nodeLevels.get(id)!].push(id));\n\n const nodeInValue = new Map<string | number, number>();\n const nodeOutValue = new Map<string | number, number>();\n\n links.forEach((l: SankeyLink) => {\n nodeOutValue.set(l.source, (nodeOutValue.get(l.source) || 0) + l.value);\n nodeInValue.set(l.target, (nodeInValue.get(l.target) || 0) + l.value);\n });\n\n const getNodeValue = (id: string | number) =>\n Math.max(nodeInValue.get(id) || 0, nodeOutValue.get(id) || 0);\n\n let maxLayerTotal = 0;\n layers.forEach((layerNodes) => {\n let layerTotal = 0;\n layerNodes.forEach((id) => {\n layerTotal += getNodeValue(id);\n });\n if (layerTotal > maxLayerTotal) maxLayerTotal = layerTotal;\n });\n\n const nodeRegistry = new Map<string | number, SankeyNodeLayout>();\n const numLayers = layers.length;\n const horizontalSpacing = (workingArea.width - nodeWidth) / Math.max(1, numLayers - 1);\n\n layers.forEach((layerNodes, lIdx) => {\n const x = workingArea.x + lIdx * horizontalSpacing;\n\n const nodeHeights: number[] = [];\n let layerHeightSum = 0;\n layerNodes.forEach((id) => {\n const val = getNodeValue(id);\n const h = maxLayerTotal > 0 ? (val / maxLayerTotal) * (workingArea.height * 0.9) : 20;\n nodeHeights.push(h);\n layerHeightSum += h;\n });\n\n const totalPadding = (layerNodes.length - 1) * nodePadding;\n const totalContentHeight = layerHeightSum + totalPadding;\n let currentY = workingArea.y + (workingArea.height - totalContentHeight) / 2;\n\n layerNodes.forEach((id, nIdx) => {\n const height = nodeHeights[nIdx];\n\n let color = palette[nIdx % palette.length];\n if (nodes.length > 0) {\n const found = (nodes as SankeyNode[]).find((n) => n.id === id);\n if (found?.color) color = found.color;\n }\n\n nodeRegistry.set(id, {\n x,\n y: currentY,\n width: nodeWidth,\n height,\n color,\n value: getNodeValue(id),\n });\n currentY += height + nodePadding;\n });\n });\n\n const sourceOffsets = new Map<string | number, number>();\n const targetOffsets = new Map<string | number, number>();\n const linkLayouts: SankeyLinkLayout[] = [];\n\n links.forEach((link: SankeyLink) => {\n const src = nodeRegistry.get(link.source);\n const dst = nodeRegistry.get(link.target);\n if (!src || !dst) return;\n\n const sOffset = sourceOffsets.get(link.source) || 0;\n const tOffset = targetOffsets.get(link.target) || 0;\n\n const sValue = nodeOutValue.get(link.source) || 1;\n const tValue = nodeInValue.get(link.target) || 1;\n\n const srcFlowHeight = (link.value / sValue) * src.height;\n const dstFlowHeight = (link.value / tValue) * dst.height;\n\n linkLayouts.push({\n source: src,\n target: dst,\n sourceOffset: sOffset,\n targetOffset: tOffset,\n sourceTotal: sValue,\n targetTotal: tValue,\n value: link.value,\n link,\n });\n\n sourceOffsets.set(link.source, sOffset + srcFlowHeight);\n targetOffsets.set(link.target, tOffset + dstFlowHeight);\n });\n\n return {\n workingArea,\n nodeRegistry,\n links: linkLayouts,\n nodeInValue,\n nodeOutValue,\n style: { nodeWidth, nodePadding, palette, linkOpacity, showLabels },\n };\n}\n","/**\n * Truncate series data for replay-style SVG export (`exportSVG({ at })`).\n */\nimport { Series } from \"../../../Series\";\nimport type { SeriesData } from \"../../../../types\";\n\nfunction findEndIndex(x: ArrayLike<number>, at: number): number {\n let end = x.length;\n for (let i = 0; i < x.length; i++) {\n if (x[i] > at) {\n end = Math.max(1, i);\n break;\n }\n }\n return end;\n}\n\nfunction sliceField(\n arr: Float32Array | Float64Array | undefined,\n end: number,\n): Float32Array | Float64Array | undefined {\n if (!arr) return undefined;\n return Float32Array.from(arr.subarray(0, end));\n}\n\nfunction sliceSeriesData(data: SeriesData, end: number): SeriesData {\n return {\n x: Float32Array.from(data.x.subarray(0, end)),\n y: data.y ? Float32Array.from(data.y.subarray(0, end)) : new Float32Array(0),\n yError: sliceField(data.yError, end),\n yErrorPlus: sliceField(data.yErrorPlus, end),\n yErrorMinus: sliceField(data.yErrorMinus, end),\n xError: sliceField(data.xError, end),\n xErrorPlus: sliceField(data.xErrorPlus, end),\n xErrorMinus: sliceField(data.xErrorMinus, end),\n y2: sliceField(data.y2, end),\n open: sliceField(data.open, end),\n high: sliceField(data.high, end),\n low: sliceField(data.low, end),\n close: sliceField(data.close, end),\n };\n}\n\n/** Return series truncated to points with x ≤ `at` (data units). */\nexport function filterSeriesAtTimestamp(series: Series[], at: number): Series[] {\n return series.map((s) => {\n const data = s.getData();\n if (!data.x?.length) return s;\n\n const end = findEndIndex(data.x, at);\n if (end >= data.x.length) return s;\n\n return new Series({\n id: s.getId(),\n type: s.getType(),\n name: s.getName(),\n yAxisId: s.getYAxisId(),\n style: s.getStyle(),\n visible: s.isVisible(),\n data: sliceSeriesData(data, end),\n markers: s.getMarkers(),\n });\n });\n}\n","/**\n * Immutable layout snapshot for SVG export — mirrors ChartRenderLoop state at capture time.\n */\n\nimport type { Series } from \"../../../Series\";\nimport type { Scale } from \"../../../../scales\";\nimport type { ChartTheme } from \"../../../../theme\";\nimport type {\n AxisOptions,\n Bounds,\n PlotArea,\n} from \"../../../../types\";\nimport type { ChartTitleOptions } from \"../../../layout/types\";\nimport type { LayoutOptions } from \"../../../layout\";\nimport type { BusinessDayMapping } from \"../../../time/TimeScale\";\nimport type { SVGExportPluginContext } from \"./plugins/types\";\nimport { filterSeriesAtTimestamp } from \"./seriesAtTimestamp\";\nimport { reorderForHoveredSeries, syncScalesForRender } from \"../../ChartRenderer\";\n\nexport interface SVGExportOptions {\n xAxis?: AxisOptions;\n yAxis?: AxisOptions;\n primaryYAxisId?: string;\n /** Include plugin overlays (annotations, regression, etc.) */\n includeOverlays?: boolean;\n /** Include legend in SVG */\n includeLegend?: boolean;\n /** Include annotation plugin content */\n includeAnnotations?: boolean;\n /** Include crosshair at capture position */\n includeCursor?: boolean;\n /** Include selection rectangle */\n includeSelection?: boolean;\n /** Export state at specific timestamp (replay) */\n at?: number;\n /** Optional watermark text (snapshot / export) */\n watermarkText?: string;\n /** Embed web fonts in defs (P2) */\n embedFonts?: boolean;\n /** Accessible label for root SVG */\n ariaLabel?: string;\n /** 3D export mode — deferred */\n svgExport3DMode?: \"raster\" | \"project\";\n /** Legacy raster fallback during development */\n svgExportMode?: \"vector\" | \"legacy-raster\";\n}\n\nexport interface YAxisLayoutEntry {\n id: string;\n scale: Scale;\n options?: AxisOptions;\n position: \"left\" | \"right\";\n offset: number;\n}\n\nexport interface CursorSnapshot {\n x: number;\n y: number;\n}\n\nexport interface SelectionSnapshot {\n x: number;\n y: number;\n width: number;\n height: number;\n}\n\nexport interface PriceAlertSnapshot {\n price: number;\n direction?: string;\n}\n\nexport interface SVGExportContext {\n series: Series[];\n viewBounds: Bounds;\n plotArea: PlotArea;\n xScale: Scale;\n yAxes: Map<string, Scale>;\n yAxisLayouts: YAxisLayoutEntry[];\n theme: ChartTheme;\n width: number;\n height: number;\n xAxisOptions?: AxisOptions;\n yAxisOptionsMap: Map<string, AxisOptions>;\n primaryYAxisId?: string;\n titleOptions?: ChartTitleOptions;\n layout: LayoutOptions;\n businessDayMapping?: BusinessDayMapping | null;\n showLegend: boolean;\n legendSeries: Series[];\n cursor?: CursorSnapshot | null;\n selection?: SelectionSnapshot | null;\n alerts?: PriceAlertSnapshot[];\n options: SVGExportOptions;\n pluginContexts: SVGExportPluginContext[];\n pluginManager?: {\n get: (name: string) => import(\"../../../../plugins/types\").ChartPlugin | undefined;\n notifyExportSVG?: (ctx: SVGExportPluginContext) => void;\n };\n}\n\nexport interface SVGExportInput {\n series: Series[];\n viewBounds: Bounds;\n plotArea: PlotArea;\n xScale: Scale;\n yAxes: Map<string, Scale>;\n theme: ChartTheme;\n width: number;\n height: number;\n options?: SVGExportOptions;\n xAxisOptions?: AxisOptions;\n yAxisOptionsMap?: Map<string, AxisOptions>;\n primaryYAxisId?: string;\n titleOptions?: ChartTitleOptions;\n layout?: LayoutOptions;\n businessDayMapping?: BusinessDayMapping | null;\n showLegend?: boolean;\n cursor?: CursorSnapshot | null;\n selection?: SelectionSnapshot | null;\n alerts?: PriceAlertSnapshot[];\n pluginContexts?: SVGExportPluginContext[];\n pluginManager?: SVGExportContext[\"pluginManager\"];\n}\n\n/** Build Y-axis layout entries with left/right offsets matching OverlayRenderer. */\nexport function buildYAxisLayouts(\n _plotArea: PlotArea,\n yAxes: Map<string, Scale>,\n yAxisOptionsMap: Map<string, AxisOptions>,\n primaryYAxisId?: string,\n): YAxisLayoutEntry[] {\n const entries: YAxisLayoutEntry[] = [];\n let leftOffset = 0;\n let rightOffset = 0;\n const axisWidth = 65;\n\n const ids = Array.from(yAxes.keys());\n const ordered = primaryYAxisId && ids.includes(primaryYAxisId)\n ? [primaryYAxisId, ...ids.filter((id) => id !== primaryYAxisId)]\n : ids;\n\n for (const id of ordered) {\n const scale = yAxes.get(id);\n if (!scale) continue;\n const opts = yAxisOptionsMap.get(id);\n const position = opts?.position === \"right\" ? \"right\" : \"left\";\n const offset = position === \"left\" ? leftOffset : rightOffset;\n entries.push({ id, scale, options: opts, position, offset });\n if (position === \"left\") leftOffset += axisWidth;\n else rightOffset += axisWidth;\n }\n\n return entries;\n}\n\n/** Avoid throwing when trading hooks are not registered (core bundle). */\nfunction safeChartAlerts(\n chart: { getAlerts?: () => Array<{ price: number; direction?: string }> },\n): Array<{ price: number; direction?: string }> | undefined {\n if (!chart.getAlerts) return undefined;\n try {\n return chart.getAlerts();\n } catch {\n return [];\n }\n}\n\nexport function buildSVGExportContext(input: SVGExportInput): SVGExportContext {\n const yAxisOptionsMap = input.yAxisOptionsMap ?? new Map();\n const options = input.options ?? {};\n const yAxes = input.yAxes;\n\n if (yAxes.size === 0) {\n throw new Error(\"SVG export requires at least one Y scale\");\n }\n\n return {\n series: input.series,\n viewBounds: input.viewBounds,\n plotArea: input.plotArea,\n xScale: input.xScale,\n yAxes,\n yAxisLayouts: buildYAxisLayouts(\n input.plotArea,\n yAxes,\n yAxisOptionsMap,\n options.primaryYAxisId ?? input.primaryYAxisId,\n ),\n theme: input.theme,\n width: input.width,\n height: input.height,\n xAxisOptions: input.xAxisOptions ?? options.xAxis,\n yAxisOptionsMap,\n primaryYAxisId: options.primaryYAxisId ?? input.primaryYAxisId,\n titleOptions: input.titleOptions,\n layout: input.layout ?? {},\n businessDayMapping: input.businessDayMapping,\n showLegend: input.showLegend ?? false,\n legendSeries: input.series.filter((s) => s.isVisible()),\n cursor: input.cursor,\n selection: input.selection,\n alerts: input.alerts,\n options,\n pluginContexts: input.pluginContexts ?? [],\n pluginManager: input.pluginManager,\n };\n}\n\n/** Capture layout snapshot from a live ChartImpl instance. */\nexport function captureLayoutSnapshot(chart: {\n getAllSeries: () => Series[];\n viewBounds: Bounds;\n getPlotArea: () => PlotArea;\n xScale: Scale;\n yScales: Map<string, Scale>;\n theme: ChartTheme;\n container: HTMLElement;\n xAxisOptions: AxisOptions;\n yAxisOptionsMap: Map<string, AxisOptions>;\n primaryYAxisId: string;\n getLayout?: () => LayoutOptions;\n getBusinessDayMapping?: () => BusinessDayMapping | null;\n showLegend?: boolean;\n getCursorPosition?: () => { x: number; y: number } | null;\n selectionRect?: { x: number; y: number; width: number; height: number } | null;\n getAlerts?: () => Array<{ price: number; direction?: string }>;\n getHoveredSeriesId?: () => string | null;\n pluginManager?: {\n get: (name: string) => unknown;\n notifyExportSVG?: (ctx: SVGExportPluginContext) => void;\n };\n titleOptions?: ChartTitleOptions;\n}, exportOptions: SVGExportOptions = {}): SVGExportContext {\n const rect = chart.container.getBoundingClientRect();\n let series = chart.getAllSeries();\n const hoveredId = chart.getHoveredSeriesId?.() ?? null;\n series = reorderForHoveredSeries(series, hoveredId, (s) => s.getId());\n if (exportOptions.at != null && Number.isFinite(exportOptions.at)) {\n series = filterSeriesAtTimestamp(series, exportOptions.at);\n }\n\n const plotArea = chart.getPlotArea();\n syncScalesForRender(\n plotArea,\n chart.viewBounds,\n chart.xScale,\n chart.yScales,\n chart.yAxisOptionsMap,\n chart.xAxisOptions,\n chart.primaryYAxisId,\n chart.getLayout?.() ?? {},\n );\n\n return buildSVGExportContext({\n series,\n viewBounds: chart.viewBounds,\n plotArea,\n xScale: chart.xScale,\n yAxes: chart.yScales,\n theme: chart.theme,\n width: rect.width || chart.container.clientWidth,\n height: rect.height || chart.container.clientHeight,\n options: exportOptions,\n xAxisOptions: chart.xAxisOptions,\n yAxisOptionsMap: chart.yAxisOptionsMap,\n primaryYAxisId: chart.primaryYAxisId,\n titleOptions: chart.titleOptions ?? chart.getLayout?.()?.title,\n layout: chart.getLayout?.(),\n businessDayMapping: chart.getBusinessDayMapping?.() ?? null,\n showLegend: (chart as { showLegend?: boolean }).showLegend ?? false,\n cursor: chart.getCursorPosition?.() ?? null,\n selection: chart.selectionRect ?? null,\n alerts: safeChartAlerts(chart),\n pluginManager: chart.pluginManager as SVGExportContext[\"pluginManager\"],\n });\n}\n","/**\n * Maps ChartTheme tokens to SVG stroke/fill attributes.\n */\n\nimport type { ChartTheme } from \"../../../../theme\";\n\nexport function dashArrayToSvg(dash: number[] | undefined): string | undefined {\n if (!dash || dash.length === 0) return undefined;\n return dash.join(\",\");\n}\n\nexport interface SvgStrokeStyle {\n stroke: string;\n strokeWidth: number;\n strokeOpacity?: number;\n strokeDasharray?: string;\n}\n\nexport interface SvgTextStyle {\n fill: string;\n fontSize: number;\n fontFamily: string;\n fontWeight?: string | number;\n}\n\nexport function gridMajorStyle(theme: ChartTheme): SvgStrokeStyle {\n return {\n stroke: theme.grid.majorColor,\n strokeWidth: theme.grid.majorWidth,\n strokeDasharray: dashArrayToSvg(theme.grid.majorDash),\n };\n}\n\nexport function gridMinorStyle(theme: ChartTheme): SvgStrokeStyle {\n return {\n stroke: theme.grid.minorColor,\n strokeWidth: theme.grid.minorWidth,\n strokeDasharray: dashArrayToSvg(theme.grid.minorDash),\n };\n}\n\nexport function axisLineStyle(theme: ChartTheme, orientation: \"x\" | \"y\"): SvgStrokeStyle {\n const axis = orientation === \"x\" ? theme.xAxis : theme.yAxis;\n return {\n stroke: axis.lineColor,\n strokeWidth: axis.lineWidth ?? 2,\n };\n}\n\nexport function axisTickStyle(theme: ChartTheme, orientation: \"x\" | \"y\"): SvgStrokeStyle {\n const axis = orientation === \"x\" ? theme.xAxis : theme.yAxis;\n return {\n stroke: axis.tickColor,\n strokeWidth: 1,\n };\n}\n\nexport function axisLabelStyle(theme: ChartTheme, orientation: \"x\" | \"y\"): SvgTextStyle {\n const axis = orientation === \"x\" ? theme.xAxis : theme.yAxis;\n return {\n fill: axis.labelColor,\n fontSize: axis.labelSize,\n fontFamily: axis.fontFamily || \"sans-serif\",\n };\n}\n\nexport function strokeAttrs(style: SvgStrokeStyle): string {\n const parts = [\n `stroke=\"${style.stroke}\"`,\n `stroke-width=\"${style.strokeWidth}\"`,\n ];\n if (style.strokeOpacity !== undefined) parts.push(`stroke-opacity=\"${style.strokeOpacity}\"`);\n if (style.strokeDasharray) parts.push(`stroke-dasharray=\"${style.strokeDasharray}\"`);\n return parts.join(\" \");\n}\n\nexport function textAttrs(style: SvgTextStyle, anchor?: string, baseline?: string): string {\n const parts = [\n `fill=\"${style.fill}\"`,\n `font-size=\"${style.fontSize}\"`,\n `font-family=\"${style.fontFamily}\"`,\n ];\n if (style.fontWeight) parts.push(`font-weight=\"${style.fontWeight}\"`);\n if (anchor) parts.push(`text-anchor=\"${anchor}\"`);\n if (baseline) parts.push(`dominant-baseline=\"${baseline}\"`);\n return parts.join(\" \");\n}\n","import type { SVGExportContext } from \"../SVGExportContext\";\nimport type { SVGDocumentBuilder } from \"../SVGDocumentBuilder\";\nimport { fmt } from \"../SVGDocumentBuilder\";\nimport { gridMajorStyle, gridMinorStyle, strokeAttrs } from \"../SVGThemeAdapter\";\nimport { generateMinorTicks, primaryYScale, resolveGridXTicks } from \"../tickUtils\";\nimport { snapLineCoord } from \"../../../../render/pixelSnap\";\n\nexport function exportGrid(ctx: SVGExportContext, builder: SVGDocumentBuilder): void {\n if (!ctx.theme.grid.visible) return;\n\n const yScale = primaryYScale(ctx.yAxes, ctx.primaryYAxisId);\n if (!yScale) return;\n\n const { plotArea, xScale, theme } = ctx;\n const xTickCount = ctx.xAxisOptions?.tickCount ?? 8;\n const yTickCount = ctx.yAxisOptionsMap.get(ctx.primaryYAxisId ?? \"default\")?.tickCount ?? 6;\n const xTicks = resolveGridXTicks(xScale, xTickCount);\n const yTicks = yScale.ticks(yTickCount);\n const major = strokeAttrs(gridMajorStyle(theme));\n\n for (const tick of xTicks) {\n const x = snapLineCoord(xScale.transform(tick));\n if (x >= plotArea.x && x <= plotArea.x + plotArea.width) {\n builder.push(\n \"grid\",\n `<line x1=\"${fmt(x)}\" y1=\"${fmt(plotArea.y)}\" x2=\"${fmt(x)}\" y2=\"${fmt(plotArea.y + plotArea.height)}\" ${major}/>`,\n );\n }\n }\n\n for (const tick of yTicks) {\n const y = snapLineCoord(yScale.transform(tick));\n if (y >= plotArea.y && y <= plotArea.y + plotArea.height) {\n builder.push(\n \"grid\",\n `<line x1=\"${fmt(plotArea.x)}\" y1=\"${fmt(y)}\" x2=\"${fmt(plotArea.x + plotArea.width)}\" y2=\"${fmt(y)}\" ${major}/>`,\n );\n }\n }\n\n if (theme.grid.showMinor) {\n const minor = strokeAttrs(gridMinorStyle(theme));\n const minorXTicks = generateMinorTicks(xTicks, theme.grid.minorDivisions);\n const minorYTicks = generateMinorTicks(yTicks, theme.grid.minorDivisions);\n\n for (const tick of minorXTicks) {\n const x = snapLineCoord(xScale.transform(tick));\n if (x >= plotArea.x && x <= plotArea.x + plotArea.width) {\n builder.push(\n \"grid\",\n `<line x1=\"${fmt(x)}\" y1=\"${fmt(plotArea.y)}\" x2=\"${fmt(x)}\" y2=\"${fmt(plotArea.y + plotArea.height)}\" ${minor}/>`,\n );\n }\n }\n\n for (const tick of minorYTicks) {\n const y = snapLineCoord(yScale.transform(tick));\n if (y >= plotArea.y && y <= plotArea.y + plotArea.height) {\n builder.push(\n \"grid\",\n `<line x1=\"${fmt(plotArea.x)}\" y1=\"${fmt(y)}\" x2=\"${fmt(plotArea.x + plotArea.width)}\" y2=\"${fmt(y)}\" ${minor}/>`,\n );\n }\n }\n }\n}\n","import type { SVGExportContext } from \"../SVGExportContext\";\nimport type { SVGDocumentBuilder } from \"../SVGDocumentBuilder\";\nimport { escapeXml, fmt } from \"../SVGDocumentBuilder\";\nimport { axisLabelStyle, axisLineStyle, axisTickStyle, strokeAttrs, textAttrs } from \"../SVGThemeAdapter\";\nimport { resolveXTicks } from \"../tickUtils\";\nimport { formatXTickValue, formatYTickValue } from \"../../../../format/axisFormat\";\nimport { snapLabelCoord, snapLineCoord } from \"../../../../render/pixelSnap\";\n\nexport function exportAxes(ctx: SVGExportContext, builder: SVGDocumentBuilder): void {\n exportXAxis(ctx, builder);\n for (const layout of ctx.yAxisLayouts) {\n exportYAxis(ctx, builder, layout);\n }\n}\n\nfunction exportXAxis(ctx: SVGExportContext, builder: SVGDocumentBuilder): void {\n const { plotArea, xScale, theme, xAxisOptions } = ctx;\n if (xAxisOptions?.visible === false) return;\n const axis = theme.xAxis;\n const xTickCount = xAxisOptions?.tickCount ?? 8;\n const xTicks = resolveXTicks(xScale, xTickCount, ctx.businessDayMapping);\n const axisY = snapLineCoord(plotArea.y + plotArea.height);\n const showLine = xAxisOptions?.showLine !== false;\n const showTicks = xAxisOptions?.showTicks !== false;\n const showLabels = xAxisOptions?.showLabels !== false;\n const domainSpan = xScale.domain[1] - xScale.domain[0];\n\n if (showLine) {\n builder.push(\n \"axes\",\n `<line x1=\"${fmt(plotArea.x)}\" y1=\"${fmt(axisY)}\" x2=\"${fmt(plotArea.x + plotArea.width)}\" y2=\"${fmt(axisY)}\" ${strokeAttrs(axisLineStyle(theme, \"x\"))}/>`,\n );\n }\n\n const labelStyle = axisLabelStyle(theme, \"x\");\n const tickStyle = strokeAttrs(axisTickStyle(theme, \"x\"));\n\n const visibleTicks: Array<{ x: number; label: string }> = [];\n for (const tick of xTicks) {\n const x = snapLabelCoord(xScale.transform(tick));\n if (x >= plotArea.x && x <= plotArea.x + plotArea.width) {\n const label = showLabels ? formatXTickValue(tick, xAxisOptions, domainSpan, ctx.businessDayMapping ?? undefined) : \"\";\n if (!showLabels || label) visibleTicks.push({ x, label });\n }\n }\n\n let rotateLabels = false;\n if (showLabels && visibleTicks.length > 1) {\n const maxLabelLen = Math.max(...visibleTicks.map((t) => t.label.length));\n const approxWidth = maxLabelLen * axis.labelSize * 0.6;\n let minSpacing = Infinity;\n for (let i = 1; i < visibleTicks.length; i++) {\n minSpacing = Math.min(minSpacing, visibleTicks[i].x - visibleTicks[i - 1].x);\n }\n rotateLabels = approxWidth + 8 > minSpacing;\n }\n\n for (const item of visibleTicks) {\n if (showTicks) {\n builder.push(\n \"axes\",\n `<line x1=\"${fmt(item.x)}\" y1=\"${fmt(axisY)}\" x2=\"${fmt(item.x)}\" y2=\"${fmt(axisY + axis.tickLength)}\" ${tickStyle}/>`,\n );\n }\n if (showLabels && item.label) {\n const labelY = axisY + axis.tickLength + (rotateLabels ? 6 : 3) + axis.labelSize * 0.75;\n if (rotateLabels) {\n builder.push(\n \"axes\",\n `<text x=\"${fmt(item.x)}\" y=\"${fmt(labelY)}\" ${textAttrs(labelStyle, \"end\", \"auto\")} transform=\"rotate(-45 ${fmt(item.x)} ${fmt(labelY)})\">${escapeXml(item.label)}</text>`,\n );\n } else {\n builder.push(\n \"axes\",\n `<text x=\"${fmt(item.x)}\" y=\"${fmt(labelY)}\" ${textAttrs(labelStyle, \"middle\")}>${escapeXml(item.label)}</text>`,\n );\n }\n }\n }\n\n const xLabel = xAxisOptions?.label;\n if (xLabel) {\n const titleY = plotArea.y + plotArea.height + (ctx.layout.xAxisLayout?.titleGap ?? 45);\n builder.push(\n \"axes\",\n `<text x=\"${fmt(plotArea.x + plotArea.width / 2)}\" y=\"${fmt(titleY)}\" ${textAttrs({ ...labelStyle, fill: axis.titleColor, fontSize: axis.titleSize }, \"middle\")}>${escapeXml(xLabel)}</text>`,\n );\n }\n}\n\nfunction exportYAxis(\n ctx: SVGExportContext,\n builder: SVGDocumentBuilder,\n layout: import(\"../SVGExportContext\").YAxisLayoutEntry,\n): void {\n const { plotArea, theme } = ctx;\n const { scale: yScale, options, position, offset } = layout;\n if (options?.visible === false) return;\n const axis = theme.yAxis;\n const yTickCount = options?.tickCount ?? 6;\n const yTicks = yScale.ticks(yTickCount);\n const showLine = options?.showLine !== false;\n const showTicks = options?.showTicks !== false;\n const showLabels = options?.showLabels !== false;\n const axisX = snapLineCoord(\n position === \"left\" ? plotArea.x - offset : plotArea.x + plotArea.width + offset,\n );\n const tickDir = position === \"left\" ? -1 : 1;\n\n if (showLine) {\n builder.push(\n \"axes\",\n `<line x1=\"${fmt(axisX)}\" y1=\"${fmt(plotArea.y)}\" x2=\"${fmt(axisX)}\" y2=\"${fmt(plotArea.y + plotArea.height)}\" ${strokeAttrs(axisLineStyle(theme, \"y\"))}/>`,\n );\n }\n\n const labelStyle = axisLabelStyle(theme, \"y\");\n const tickStyle = strokeAttrs(axisTickStyle(theme, \"y\"));\n\n for (const tick of yTicks) {\n const y = snapLabelCoord(yScale.transform(tick));\n if (y < plotArea.y || y > plotArea.y + plotArea.height) continue;\n\n if (showTicks) {\n builder.push(\n \"axes\",\n `<line x1=\"${fmt(axisX)}\" y1=\"${fmt(y)}\" x2=\"${fmt(axisX + axis.tickLength * tickDir)}\" y2=\"${fmt(y)}\" ${tickStyle}/>`,\n );\n }\n if (showLabels) {\n const labelX = axisX + (axis.tickLength + 3) * tickDir;\n const anchor = position === \"left\" ? \"end\" : \"start\";\n builder.push(\n \"axes\",\n `<text x=\"${fmt(labelX)}\" y=\"${fmt(y + axis.labelSize * 0.35)}\" ${textAttrs(labelStyle, anchor)}>${escapeXml(formatYTickValue(tick, options))}</text>`,\n );\n }\n }\n\n const label = options?.label;\n if (label) {\n const titleGap = ctx.layout.yAxisLayout?.titleGap ?? 50;\n const titleX = position === \"left\" ? axisX - titleGap : axisX + titleGap;\n const titleY = plotArea.y + plotArea.height / 2;\n const rotation = position === \"left\" ? -90 : 90;\n builder.push(\n \"axes\",\n `<text x=\"${fmt(titleX)}\" y=\"${fmt(titleY)}\" ${textAttrs({ ...labelStyle, fill: axis.titleColor, fontSize: axis.titleSize }, \"middle\")} transform=\"rotate(${rotation} ${fmt(titleX)} ${fmt(titleY)})\">${escapeXml(label)}</text>`,\n );\n }\n}\n","import type { SVGExportContext } from \"../SVGExportContext\";\nimport type { SVGDocumentBuilder } from \"../SVGDocumentBuilder\";\nimport { escapeXml, fmt } from \"../SVGDocumentBuilder\";\nimport type { ChartTitleOptions } from \"../../../../layout/types\";\n\nexport function exportTitle(ctx: SVGExportContext, builder: SVGDocumentBuilder): void {\n const options = ctx.titleOptions;\n if (!options?.visible || !options.text) return;\n\n const { plotArea } = ctx;\n const fontSize = options.fontSize ?? 16;\n const fontFamily = options.fontFamily ?? \"Inter, system-ui, sans-serif\";\n const fontWeight = options.fontWeight ?? 600;\n const color = options.color ?? \"#ffffff\";\n const align = options.align ?? \"center\";\n\n let x: number;\n if (align === \"left\") x = plotArea.x;\n else if (align === \"right\") x = plotArea.x + plotArea.width;\n else x = plotArea.x + plotArea.width / 2;\n\n const padding = typeof options.padding === \"number\" ? options.padding : 10;\n const padTop = (options.padding as ChartTitleOptions[\"padding\"] & { top?: number })?.top ?? padding;\n const padBottom = (options.padding as ChartTitleOptions[\"padding\"] & { bottom?: number })?.bottom ?? padding;\n\n const y =\n options.position === \"bottom\"\n ? plotArea.y + plotArea.height + padBottom + fontSize\n : plotArea.y - padTop;\n\n const anchor = align === \"left\" ? \"start\" : align === \"right\" ? \"end\" : \"middle\";\n\n builder.push(\n \"title\",\n `<text x=\"${fmt(x)}\" y=\"${fmt(y)}\" fill=\"${color}\" font-size=\"${fontSize}\" font-family=\"${escapeXml(fontFamily)}\" font-weight=\"${fontWeight}\" text-anchor=\"${anchor}\">${escapeXml(options.text)}</text>`,\n );\n}\n","import type { SVGExportContext } from \"../SVGExportContext\";\nimport type { SVGDocumentBuilder } from \"../SVGDocumentBuilder\";\nimport { fmt } from \"../SVGDocumentBuilder\";\n\nexport function exportPlotBorder(ctx: SVGExportContext, builder: SVGDocumentBuilder): void {\n const { plotArea, theme } = ctx;\n builder.push(\n \"border\",\n `<rect x=\"${fmt(plotArea.x)}\" y=\"${fmt(plotArea.y)}\" width=\"${fmt(plotArea.width)}\" height=\"${fmt(plotArea.height)}\" fill=\"none\" stroke=\"${theme.plotBorderColor}\" stroke-width=\"1\"/>`,\n );\n}\n","/**\n * Scatter / legend symbol paths for SVG export.\n */\n\nimport { fmt } from \"./SVGDocumentBuilder\";\n\nexport type ScatterSymbol =\n | \"circle\"\n | \"square\"\n | \"diamond\"\n | \"triangle\"\n | \"triangleDown\"\n | \"cross\"\n | \"x\"\n | \"star\";\n\nexport function symbolSvg(\n symbol: string,\n cx: number,\n cy: number,\n size: number,\n fill: string,\n opacity = 1,\n stroke?: string,\n): string {\n const r = size / 2;\n const fillAttr = `fill=\"${fill}\" fill-opacity=\"${opacity}\"`;\n const strokeAttr = stroke ? ` stroke=\"${stroke}\" stroke-width=\"1\"` : \"\";\n\n switch (symbol as ScatterSymbol) {\n case \"square\":\n return `<rect x=\"${fmt(cx - r)}\" y=\"${fmt(cy - r)}\" width=\"${fmt(size)}\" height=\"${fmt(size)}\" ${fillAttr}${strokeAttr}/>`;\n case \"diamond\":\n return `<polygon points=\"${fmt(cx)},${fmt(cy - r)} ${fmt(cx + r)},${fmt(cy)} ${fmt(cx)},${fmt(cy + r)} ${fmt(cx - r)},${fmt(cy)}\" ${fillAttr}${strokeAttr}/>`;\n case \"triangle\":\n return `<polygon points=\"${fmt(cx)},${fmt(cy - r)} ${fmt(cx + r)},${fmt(cy + r)} ${fmt(cx - r)},${fmt(cy + r)}\" ${fillAttr}${strokeAttr}/>`;\n case \"triangleDown\":\n return `<polygon points=\"${fmt(cx)},${fmt(cy + r)} ${fmt(cx + r)},${fmt(cy - r)} ${fmt(cx - r)},${fmt(cy - r)}\" ${fillAttr}${strokeAttr}/>`;\n case \"cross\": {\n const s = stroke ?? fill;\n return `<g stroke=\"${s}\" stroke-width=\"1\" stroke-opacity=\"${opacity}\"><line x1=\"${fmt(cx - r)}\" y1=\"${fmt(cy)}\" x2=\"${fmt(cx + r)}\" y2=\"${fmt(cy)}\"/><line x1=\"${fmt(cx)}\" y1=\"${fmt(cy - r)}\" x2=\"${fmt(cx)}\" y2=\"${fmt(cy + r)}\"/></g>`;\n }\n case \"x\": {\n const d = r * 0.707;\n const s = stroke ?? fill;\n return `<g stroke=\"${s}\" stroke-width=\"1\" stroke-opacity=\"${opacity}\"><line x1=\"${fmt(cx - d)}\" y1=\"${fmt(cy - d)}\" x2=\"${fmt(cx + d)}\" y2=\"${fmt(cy + d)}\"/><line x1=\"${fmt(cx + d)}\" y1=\"${fmt(cy - d)}\" x2=\"${fmt(cx - d)}\" y2=\"${fmt(cy + d)}\"/></g>`;\n }\n case \"star\": {\n const pts: string[] = [];\n for (let i = 0; i < 5; i++) {\n const outer = ((18 + i * 72) / 180) * Math.PI;\n const inner = ((54 + i * 72) / 180) * Math.PI;\n pts.push(`${fmt(cx + r * Math.cos(outer))},${fmt(cy - r * Math.sin(outer))}`);\n pts.push(`${fmt(cx + r * 0.4 * Math.cos(inner))},${fmt(cy - r * 0.4 * Math.sin(inner))}`);\n }\n return `<polygon points=\"${pts.join(\" \")}\" ${fillAttr}${strokeAttr}/>`;\n }\n case \"circle\":\n default:\n return `<circle cx=\"${fmt(cx)}\" cy=\"${fmt(cy)}\" r=\"${fmt(r)}\" ${fillAttr}${strokeAttr}/>`;\n }\n}\n","import type { SVGExportContext } from \"../SVGExportContext\";\nimport type { SVGDocumentBuilder } from \"../SVGDocumentBuilder\";\nimport { escapeXml, fmt } from \"../SVGDocumentBuilder\";\nimport { symbolSvg } from \"../symbols\";\n\nexport function exportLegend(ctx: SVGExportContext, builder: SVGDocumentBuilder): void {\n if (ctx.options.includeLegend === false) return;\n if (!ctx.showLegend && ctx.options.includeLegend !== true) return;\n\n const legend = ctx.theme.legend;\n if (!legend?.visible) return;\n\n const items = ctx.legendSeries;\n if (items.length === 0) return;\n\n const { plotArea } = ctx;\n const legendWidth = 160;\n const legendHeight =\n legend.padding * 2 + items.length * (legend.swatchSize + legend.itemGap) - legend.itemGap;\n\n let x = plotArea.x + plotArea.width - legendWidth - 10;\n let y = plotArea.y + 10;\n\n const position = legend.position ?? \"top-right\";\n if (position.includes(\"left\")) x = plotArea.x + 10;\n if (position.includes(\"bottom\")) y = plotArea.y + plotArea.height - legendHeight - 10;\n\n builder.push(\n \"legend\",\n `<rect x=\"${fmt(x)}\" y=\"${fmt(y)}\" width=\"${fmt(legendWidth)}\" height=\"${fmt(legendHeight)}\" fill=\"${legend.backgroundColor}\" fill-opacity=\"0.8\" stroke=\"${legend.borderColor ?? \"transparent\"}\" rx=\"4\"/>`,\n );\n\n items.forEach((series, i) => {\n const style = series.getStyle() as Record<string, unknown>;\n const color = (style.color as string) ?? \"#fff\";\n const opacity = (style.opacity as number) ?? 1;\n const itemY = y + legend.padding + i * (legend.swatchSize + legend.itemGap);\n const swatchX = x + legend.padding;\n const centerY = itemY + legend.swatchSize / 2;\n const centerX = swatchX + legend.swatchSize / 2;\n const size = legend.swatchSize;\n const type = String(series.getType()).toLowerCase();\n const symbol = (style.symbol as string) ?? \"circle\";\n\n if (type === \"scatter\" || type.includes(\"scatter\")) {\n builder.push(\"legend\", symbolSvg(symbol, centerX, centerY, size * 0.9, color, opacity));\n if (type.includes(\"+\")) {\n builder.push(\n \"legend\",\n `<line x1=\"${fmt(swatchX)}\" y1=\"${fmt(centerY)}\" x2=\"${fmt(swatchX + size)}\" y2=\"${fmt(centerY)}\" stroke=\"${color}\" stroke-width=\"2\" stroke-opacity=\"${opacity}\"/>`,\n );\n }\n } else {\n builder.push(\n \"legend\",\n `<line x1=\"${fmt(swatchX)}\" y1=\"${fmt(centerY)}\" x2=\"${fmt(swatchX + size)}\" y2=\"${fmt(centerY)}\" stroke=\"${color}\" stroke-width=\"2\" stroke-opacity=\"${opacity}\"/>`,\n );\n }\n\n builder.push(\n \"legend\",\n `<text x=\"${fmt(x + legend.padding + legend.swatchSize + 8)}\" y=\"${fmt(centerY + legend.fontSize * 0.35)}\" fill=\"${legend.textColor}\" font-size=\"${legend.fontSize}\" font-family=\"${legend.fontFamily}\">${escapeXml(series.getName())}</text>`,\n );\n });\n}\n","import type { Series } from \"../../../Series\";\n\nexport function seriesId(series: Series, fallback = \"series\"): string {\n if (typeof series.getId === \"function\") return series.getId();\n return fallback;\n}\n","import type { Series } from \"../../../../Series\";\nimport { seriesId } from \"../seriesUtils\";\nimport type { Scale } from \"../../../../../scales\";\nimport type { PlotArea } from \"../../../../../types\";\nimport type { SVGDocumentBuilder } from \"../SVGDocumentBuilder\";\nimport { fmt } from \"../SVGDocumentBuilder\";\nimport { resolveYScale } from \"../tickUtils\";\n\nexport function exportErrorBarsForSeries(\n series: Series,\n plotArea: PlotArea,\n xScale: Scale,\n yScale: Scale,\n builder: SVGDocumentBuilder,\n): void {\n if (typeof series.hasErrorData !== \"function\" || !series.hasErrorData()) return;\n\n const data = series.getData();\n const style = series.getStyle();\n const errorStyle = style.errorBars ?? {};\n if (errorStyle.visible === false) return;\n\n const color = errorStyle.color ?? style.color ?? \"#ff0055\";\n const lineWidth = errorStyle.width ?? 1;\n const capWidth = errorStyle.capWidth ?? 6;\n const showCaps = errorStyle.showCaps !== false;\n const opacity = errorStyle.opacity ?? 0.7;\n const direction = errorStyle.direction ?? \"both\";\n\n const clipId = `vp-clip-eb-${seriesId(series)}`;\n builder.registerClipPath(\n clipId,\n `<rect x=\"${fmt(plotArea.x)}\" y=\"${fmt(plotArea.y)}\" width=\"${fmt(plotArea.width)}\" height=\"${fmt(plotArea.height)}\"/>`,\n );\n\n for (let i = 0; i < data.x.length; i++) {\n const x = xScale.transform(data.x[i]);\n const y = yScale.transform(data.y[i]);\n if (x < plotArea.x || x > plotArea.x + plotArea.width) continue;\n if (y < plotArea.y || y > plotArea.y + plotArea.height) continue;\n\n const yError = series.getYError(i);\n if (yError) {\n const [errorMinus, errorPlus] = yError;\n const yBase = data.y[i];\n const yTop = yScale.transform(yBase + errorPlus);\n const yBottom = yScale.transform(yBase - errorMinus);\n\n if (direction === \"both\" || direction === \"positive\") {\n builder.push(\n \"errorBars\",\n `<g clip-path=\"url(#${clipId})\" stroke=\"${color}\" stroke-width=\"${lineWidth}\" stroke-opacity=\"${opacity}\"><line x1=\"${fmt(x)}\" y1=\"${fmt(y)}\" x2=\"${fmt(x)}\" y2=\"${fmt(yTop)}\"/>${showCaps ? `<line x1=\"${fmt(x - capWidth / 2)}\" y1=\"${fmt(yTop)}\" x2=\"${fmt(x + capWidth / 2)}\" y2=\"${fmt(yTop)}\"/>` : \"\"}</g>`,\n );\n }\n if (direction === \"both\" || direction === \"negative\") {\n builder.push(\n \"errorBars\",\n `<g clip-path=\"url(#${clipId})\" stroke=\"${color}\" stroke-width=\"${lineWidth}\" stroke-opacity=\"${opacity}\"><line x1=\"${fmt(x)}\" y1=\"${fmt(y)}\" x2=\"${fmt(x)}\" y2=\"${fmt(yBottom)}\"/>${showCaps ? `<line x1=\"${fmt(x - capWidth / 2)}\" y1=\"${fmt(yBottom)}\" x2=\"${fmt(x + capWidth / 2)}\" y2=\"${fmt(yBottom)}\"/>` : \"\"}</g>`,\n );\n }\n }\n\n const xError = series.getXError(i);\n if (xError) {\n const [errorMinus, errorPlus] = xError;\n const xBase = data.x[i];\n const xRight = xScale.transform(xBase + errorPlus);\n const xLeft = xScale.transform(xBase - errorMinus);\n\n if (direction === \"both\" || direction === \"positive\") {\n builder.push(\n \"errorBars\",\n `<g clip-path=\"url(#${clipId})\" stroke=\"${color}\" stroke-width=\"${lineWidth}\" stroke-opacity=\"${opacity}\"><line x1=\"${fmt(x)}\" y1=\"${fmt(y)}\" x2=\"${fmt(xRight)}\" y2=\"${fmt(y)}\"/>${showCaps ? `<line x1=\"${fmt(xRight)}\" y1=\"${fmt(y - capWidth / 2)}\" x2=\"${fmt(xRight)}\" y2=\"${fmt(y + capWidth / 2)}\"/>` : \"\"}</g>`,\n );\n }\n if (direction === \"both\" || direction === \"negative\") {\n builder.push(\n \"errorBars\",\n `<g clip-path=\"url(#${clipId})\" stroke=\"${color}\" stroke-width=\"${lineWidth}\" stroke-opacity=\"${opacity}\"><line x1=\"${fmt(x)}\" y1=\"${fmt(y)}\" x2=\"${fmt(xLeft)}\" y2=\"${fmt(y)}\"/>${showCaps ? `<line x1=\"${fmt(xLeft)}\" y1=\"${fmt(y - capWidth / 2)}\" x2=\"${fmt(xLeft)}\" y2=\"${fmt(y + capWidth / 2)}\"/>` : \"\"}</g>`,\n );\n }\n }\n }\n}\n\nexport function exportErrorBars(\n ctx: import(\"../SVGExportContext\").SVGExportContext,\n builder: SVGDocumentBuilder,\n): void {\n for (const series of ctx.series) {\n if (!series.isVisible()) continue;\n const yScale = resolveYScale(ctx.yAxes, series.getYAxisId(), ctx.primaryYAxisId);\n if (!yScale) continue;\n exportErrorBarsForSeries(series, ctx.plotArea, ctx.xScale, yScale, builder);\n }\n}\n","import type { Series } from \"../../../../Series\";\nimport type { SVGExportContext } from \"../SVGExportContext\";\n\nexport interface SpecialChartInfo {\n isSpecialChart: boolean;\n hasPolarSeries: boolean;\n hasGaugeSeries: boolean;\n hasSankeySeries: boolean;\n maxRadius: number;\n polarAngleMode: \"degrees\" | \"radians\";\n polarRadialDivisions: number;\n polarAngularDivisions: number;\n}\n\nexport function detectSpecialChart(series: Series[]): SpecialChartInfo {\n let hasPolarSeries = false;\n let hasGaugeSeries = false;\n let hasSankeySeries = false;\n let maxRadius = 0;\n let polarAngleMode: \"degrees\" | \"radians\" = \"degrees\";\n let polarRadialDivisions = 5;\n let polarAngularDivisions = 12;\n\n for (const s of series) {\n if (!s.isVisible()) continue;\n const type = s.getType();\n if (type === \"polar\") {\n hasPolarSeries = true;\n const polarData = s.getPolarData?.();\n if (polarData) {\n for (let i = 0; i < polarData.r.length; i++) {\n maxRadius = Math.max(maxRadius, Math.abs(polarData.r[i]));\n }\n const style = s.getStyle() as {\n angleMode?: \"degrees\" | \"radians\";\n radialDivisions?: number;\n angularDivisions?: number;\n };\n if (style.angleMode) polarAngleMode = style.angleMode;\n if (style.radialDivisions) polarRadialDivisions = style.radialDivisions;\n if (style.angularDivisions) polarAngularDivisions = style.angularDivisions;\n }\n } else if (type === \"gauge\") {\n hasGaugeSeries = true;\n } else if (type === \"sankey\") {\n hasSankeySeries = true;\n }\n }\n\n return {\n isSpecialChart: hasPolarSeries || hasGaugeSeries || hasSankeySeries,\n hasPolarSeries,\n hasGaugeSeries,\n hasSankeySeries,\n maxRadius,\n polarAngleMode,\n polarRadialDivisions,\n polarAngularDivisions,\n };\n}\n\nexport function detectSpecialChartFromContext(ctx: SVGExportContext): SpecialChartInfo {\n return detectSpecialChart(ctx.series);\n}\n","import type { SVGExportContext } from \"../SVGExportContext\";\nimport type { SVGDocumentBuilder } from \"../SVGDocumentBuilder\";\nimport { fmt } from \"../SVGDocumentBuilder\";\nimport { gridMajorStyle, strokeAttrs } from \"../SVGThemeAdapter\";\nimport { primaryYScale } from \"../tickUtils\";\n\nexport function exportPolarGrid(\n ctx: SVGExportContext,\n builder: SVGDocumentBuilder,\n radialDivisions: number,\n angularDivisions: number,\n angleMode: \"degrees\" | \"radians\",\n): void {\n if (!ctx.theme.grid.visible) return;\n\n const yScale = primaryYScale(ctx.yAxes, ctx.primaryYAxisId);\n if (!yScale) return;\n\n const { plotArea, xScale } = ctx;\n const centerX = xScale.transform(0);\n const centerY = yScale.transform(0);\n const grid = strokeAttrs(gridMajorStyle(ctx.theme));\n\n const corners = [\n { x: plotArea.x, y: plotArea.y },\n { x: plotArea.x + plotArea.width, y: plotArea.y },\n { x: plotArea.x, y: plotArea.y + plotArea.height },\n { x: plotArea.x + plotArea.width, y: plotArea.y + plotArea.height },\n ];\n\n let maxPixelRadius = 0;\n for (const corner of corners) {\n const dist = Math.hypot(corner.x - centerX, corner.y - centerY);\n maxPixelRadius = Math.max(maxPixelRadius, dist);\n }\n\n const clipId = \"vp-clip-polar-grid\";\n builder.registerClipPath(\n clipId,\n `<rect x=\"${fmt(plotArea.x)}\" y=\"${fmt(plotArea.y)}\" width=\"${fmt(plotArea.width)}\" height=\"${fmt(plotArea.height)}\"/>`,\n );\n\n for (let i = 1; i <= radialDivisions; i++) {\n const radiusPixels = (i / radialDivisions) * maxPixelRadius;\n builder.push(\n \"grid\",\n `<circle clip-path=\"url(#${clipId})\" cx=\"${fmt(centerX)}\" cy=\"${fmt(centerY)}\" r=\"${fmt(radiusPixels)}\" fill=\"none\" ${grid}/>`,\n );\n }\n\n const angleStep =\n angleMode === \"degrees\"\n ? (360 / angularDivisions) * (Math.PI / 180)\n : (2 * Math.PI) / angularDivisions;\n\n for (let i = 0; i < angularDivisions; i++) {\n const angle = i * angleStep;\n builder.push(\n \"grid\",\n `<line clip-path=\"url(#${clipId})\" x1=\"${fmt(centerX)}\" y1=\"${fmt(centerY)}\" x2=\"${fmt(centerX + maxPixelRadius * Math.cos(angle))}\" y2=\"${fmt(centerY - maxPixelRadius * Math.sin(angle))}\" ${grid}/>`,\n );\n }\n}\n","import type { SVGExportContext } from \"../SVGExportContext\";\nimport type { RadarSVGExportData } from \"../../../../../plugins/radar/types\";\n\nexport function getRadarSVGExportData(ctx: SVGExportContext): RadarSVGExportData | null {\n const radarPlugin = ctx.pluginManager?.get(\"velo-plot-radar\") as\n | { api?: { getSVGExportData?: () => RadarSVGExportData | null } }\n | undefined;\n return radarPlugin?.api?.getSVGExportData?.() ?? null;\n}\n\nexport function hasActiveRadarPlugin(ctx: SVGExportContext): boolean {\n const data = getRadarSVGExportData(ctx);\n return data != null && data.categories.length > 0;\n}\n\nexport function shouldSkipCartesianOverlays(ctx: SVGExportContext, isSpecialSeriesChart: boolean): boolean {\n if (isSpecialSeriesChart || hasActiveRadarPlugin(ctx)) return true;\n\n if (ctx.xAxisOptions?.visible === false) {\n let allYHidden = true;\n ctx.yAxisOptionsMap.forEach((opts) => {\n if (opts.visible !== false) allYHidden = false;\n });\n if (allYHidden) return true;\n }\n\n return false;\n}\n","export { exportGrid } from \"./grid\";\nexport { exportAxes } from \"./axes\";\nexport { exportTitle } from \"./title\";\nexport { exportPlotBorder } from \"./border\";\nexport { exportLegend } from \"./legend\";\nexport { exportErrorBars } from \"./errorBars\";\n\nimport type { SVGExportContext } from \"../SVGExportContext\";\nimport type { SVGDocumentBuilder } from \"../SVGDocumentBuilder\";\nimport { exportGrid } from \"./grid\";\nimport { exportAxes } from \"./axes\";\nimport { exportTitle } from \"./title\";\nimport { exportPlotBorder } from \"./border\";\nimport { exportLegend } from \"./legend\";\nimport { exportErrorBars } from \"./errorBars\";\nimport { detectSpecialChartFromContext } from \"./specialChart\";\nimport { exportPolarGrid } from \"./polarGrid\";\nimport { shouldSkipCartesianOverlays } from \"./pluginCharts\";\nimport { fmt } from \"../SVGDocumentBuilder\";\n\nexport function exportCursor(ctx: SVGExportContext, builder: SVGDocumentBuilder): void {\n if (!ctx.options.includeCursor || !ctx.cursor) return;\n const { plotArea, cursor, theme } = ctx;\n const color = theme.cursor?.lineColor ?? \"rgba(255,255,255,0.5)\";\n builder.push(\n \"cursor\",\n `<line x1=\"${fmt(cursor.x)}\" y1=\"${fmt(plotArea.y)}\" x2=\"${fmt(cursor.x)}\" y2=\"${fmt(plotArea.y + plotArea.height)}\" stroke=\"${color}\" stroke-width=\"1\" stroke-dasharray=\"4,4\"/>`,\n );\n builder.push(\n \"cursor\",\n `<line x1=\"${fmt(plotArea.x)}\" y1=\"${fmt(cursor.y)}\" x2=\"${fmt(plotArea.x + plotArea.width)}\" y2=\"${fmt(cursor.y)}\" stroke=\"${color}\" stroke-width=\"1\" stroke-dasharray=\"4,4\"/>`,\n );\n}\n\nexport function exportSelection(ctx: SVGExportContext, builder: SVGDocumentBuilder): void {\n if (!ctx.options.includeSelection || !ctx.selection) return;\n const { selection } = ctx;\n builder.push(\n \"cursor\",\n `<rect x=\"${fmt(selection.x)}\" y=\"${fmt(selection.y)}\" width=\"${fmt(selection.width)}\" height=\"${fmt(selection.height)}\" fill=\"rgba(100,149,237,0.15)\" stroke=\"cornflowerblue\" stroke-width=\"1\"/>`,\n );\n}\n\nexport function exportPriceAlerts(ctx: SVGExportContext, builder: SVGDocumentBuilder): void {\n if (!ctx.alerts?.length) return;\n const { plotArea, alerts } = ctx;\n const yScale = ctx.yAxes.get(ctx.primaryYAxisId ?? \"default\");\n if (!yScale) return;\n\n for (const alert of alerts) {\n const y = yScale.transform(alert.price);\n if (y < plotArea.y || y > plotArea.y + plotArea.height) continue;\n const color = alert.direction === \"below\" ? \"#ef5350\" : \"#26a69a\";\n builder.push(\n \"plugins\",\n `<line x1=\"${fmt(plotArea.x)}\" y1=\"${fmt(y)}\" x2=\"${fmt(plotArea.x + plotArea.width)}\" y2=\"${fmt(y)}\" stroke=\"${color}\" stroke-width=\"1\" stroke-dasharray=\"6,4\"/>`,\n );\n }\n}\n\nexport function exportAllOverlays(ctx: SVGExportContext, builder: SVGDocumentBuilder): void {\n const special = detectSpecialChartFromContext(ctx);\n const skipCartesian = shouldSkipCartesianOverlays(ctx, special.isSpecialChart);\n\n if (special.hasPolarSeries && special.maxRadius > 0) {\n exportPolarGrid(\n ctx,\n builder,\n special.polarRadialDivisions,\n special.polarAngularDivisions,\n special.polarAngleMode,\n );\n } else if (!skipCartesian) {\n exportGrid(ctx, builder);\n }\n\n exportErrorBars(ctx, builder);\n\n if (!skipCartesian) {\n exportAxes(ctx, builder);\n }\n\n exportPlotBorder(ctx, builder);\n exportTitle(ctx, builder);\n exportLegend(ctx, builder);\n exportCursor(ctx, builder);\n exportSelection(ctx, builder);\n exportPriceAlerts(ctx, builder);\n}\n","import type { Scale } from \"../../../../../scales\";\nimport { fmt } from \"../SVGDocumentBuilder\";\n\n/** Indices where x/y (and optional y2) are finite. */\nexport function collectFiniteIndices(\n x: Float32Array | Float64Array,\n y: Float32Array | Float64Array,\n y2?: Float32Array | Float64Array,\n): number[] {\n const out: number[] = [];\n for (let i = 0; i < x.length; i++) {\n if (!Number.isFinite(x[i]) || !Number.isFinite(y[i])) continue;\n if (y2 && !Number.isFinite(y2[i])) continue;\n out.push(i);\n }\n return out;\n}\n\n/** Split finite samples into contiguous polyline segments (breaks at NaN gaps). */\nexport function buildLineSegments(\n indices: number[],\n x: Float32Array | Float64Array,\n y: Float32Array | Float64Array,\n xScale: Scale,\n yScale: Scale,\n): string[][] {\n const segments: string[][] = [];\n let current: string[] = [];\n let prev = -2;\n\n for (const i of indices) {\n if (prev >= 0 && i !== prev + 1) {\n if (current.length >= 2) segments.push(current);\n current = [];\n }\n current.push(`${fmt(xScale.transform(x[i]))},${fmt(yScale.transform(y[i]))}`);\n prev = i;\n }\n\n if (current.length >= 2) segments.push(current);\n return segments;\n}\n","import type { Series } from \"../../../../Series\";\nimport { seriesId } from \"../seriesUtils\";\nimport type { Scale } from \"../../../../../scales\";\nimport type { PlotArea } from \"../../../../../types\";\nimport type { SVGDocumentBuilder } from \"../SVGDocumentBuilder\";\nimport { fmt } from \"../SVGDocumentBuilder\";\nimport { symbolSvg } from \"../symbols\";\nimport { buildLineSegments, collectFiniteIndices } from \"./finitePoints\";\n\nexport function buildStepPoints(\n data: { x: Float32Array | Float64Array; y: Float32Array | Float64Array },\n xScale: Scale,\n yScale: Scale,\n stepMode: string,\n): string[] {\n const points: string[] = [];\n const mode = stepMode === \"before\" || stepMode === \"center\" ? stepMode : \"after\";\n\n for (let i = 0; i < data.x.length; i++) {\n const px = xScale.transform(data.x[i]);\n const py = yScale.transform(data.y[i]);\n\n if (i === 0) {\n points.push(`${fmt(px)},${fmt(py)}`);\n continue;\n }\n\n const prevPx = xScale.transform(data.x[i - 1]);\n const prevPy = yScale.transform(data.y[i - 1]);\n\n if (mode === \"after\") {\n points.push(`${fmt(px)},${fmt(prevPy)}`);\n points.push(`${fmt(px)},${fmt(py)}`);\n } else if (mode === \"before\") {\n points.push(`${fmt(prevPx)},${fmt(py)}`);\n points.push(`${fmt(px)},${fmt(py)}`);\n } else {\n const midX = (prevPx + px) / 2;\n points.push(`${fmt(midX)},${fmt(prevPy)}`);\n points.push(`${fmt(midX)},${fmt(py)}`);\n points.push(`${fmt(px)},${fmt(py)}`);\n }\n }\n\n return points;\n}\n\nexport function exportLineSeries(\n series: Series,\n plotArea: PlotArea,\n xScale: Scale,\n yScale: Scale,\n builder: SVGDocumentBuilder,\n): void {\n const data = series.getData();\n if (!data || data.x.length === 0) return;\n\n const style = series.getStyle() as Record<string, unknown>;\n const type = series.getType();\n const color = (style.color as string) ?? \"#ff0055\";\n const width = (style.width as number) ?? 1.5;\n const opacity = (style.opacity as number) ?? 1;\n const dash = style.dash as number[] | undefined;\n\n const clipId = `vp-clip-${seriesId(series)}`;\n builder.registerClipPath(\n clipId,\n `<rect x=\"${fmt(plotArea.x)}\" y=\"${fmt(plotArea.y)}\" width=\"${fmt(plotArea.width)}\" height=\"${fmt(plotArea.height)}\"/>`,\n );\n\n const dashAttr = dash?.length ? ` stroke-dasharray=\"${dash.join(\",\")}\"` : \"\";\n const isStep = type === \"step\" || type === \"step+scatter\";\n const lineJoin = isStep ? \"miter\" : \"round\";\n\n if (type === \"step\" || type === \"step+scatter\") {\n const points = buildStepPoints(data, xScale, yScale, (style.stepMode as string) || \"after\");\n if (points.length >= 2) {\n builder.push(\n \"series\",\n `<polyline clip-path=\"url(#${clipId})\" points=\"${points.join(\" \")}\" fill=\"none\" stroke=\"${color}\" stroke-width=\"${width}\" stroke-opacity=\"${opacity}\" stroke-linejoin=\"${lineJoin}\"${dashAttr}/>`,\n );\n }\n } else {\n const segments = buildLineSegments(\n collectFiniteIndices(data.x, data.y),\n data.x,\n data.y,\n xScale,\n yScale,\n );\n for (const points of segments) {\n builder.push(\n \"series\",\n `<polyline clip-path=\"url(#${clipId})\" points=\"${points.join(\" \")}\" fill=\"none\" stroke=\"${color}\" stroke-width=\"${width}\" stroke-opacity=\"${opacity}\" stroke-linejoin=\"${lineJoin}\"${dashAttr}/>`,\n );\n }\n }\n\n if (type === \"line+scatter\" || type === \"step+scatter\") {\n exportScatterPoints(series, plotArea, xScale, yScale, builder, true);\n }\n}\n\nexport function exportScatterPoints(\n series: Series,\n _plotArea: PlotArea,\n xScale: Scale,\n yScale: Scale,\n builder: SVGDocumentBuilder,\n skipLine = false,\n): void {\n if (!skipLine && series.getType() === \"scatter\") {\n // pure scatter only\n }\n const data = series.getData();\n if (!data || data.x.length === 0) return;\n const style = series.getStyle() as Record<string, unknown>;\n const color = (style.color as string) ?? \"#ff0055\";\n const opacity = (style.opacity as number) ?? 1;\n const pointSize = (style.pointSize as number) ?? 4;\n const symbol = (style.symbol as string) ?? \"circle\";\n\n for (let i = 0; i < data.x.length; i++) {\n const px = xScale.transform(data.x[i]);\n const py = yScale.transform(data.y[i]);\n builder.push(\"series\", symbolSvg(symbol, px, py, pointSize, color, opacity));\n }\n}\n\nexport function exportScatterSeries(\n series: Series,\n plotArea: PlotArea,\n xScale: Scale,\n yScale: Scale,\n builder: SVGDocumentBuilder,\n): void {\n exportScatterPoints(series, plotArea, xScale, yScale, builder);\n}\n","import type { Series } from \"../../../../Series\";\nimport { seriesId } from \"../seriesUtils\";\nimport type { Scale } from \"../../../../../scales\";\nimport type { PlotArea } from \"../../../../../types\";\nimport type { SVGDocumentBuilder } from \"../SVGDocumentBuilder\";\nimport { fmt } from \"../SVGDocumentBuilder\";\nimport { calculateBarWidth } from \"../../../../../renderer/BarRenderer\";\n\nexport function exportBarSeries(\n series: Series,\n plotArea: PlotArea,\n xScale: Scale,\n yScale: Scale,\n builder: SVGDocumentBuilder,\n): void {\n const data = series.getData();\n if (!data || data.x.length === 0) return;\n\n const style = series.getStyle() as Record<string, unknown>;\n const color = (style.color as string) ?? \"#ff0055\";\n const opacity = (style.opacity as number) ?? 1;\n const domainSpan = xScale.domain[1] - xScale.domain[0];\n const barWidthData =\n (style.barWidth as number | undefined) ?? calculateBarWidth(data.x);\n const barWidthPx =\n domainSpan > 0\n ? (barWidthData / domainSpan) * plotArea.width\n : ((style.barWidth as number) || 5);\n\n const baseline = (style.baseline as number) ?? 0;\n const p0 = yScale.transform(baseline);\n\n const clipId = `vp-clip-bar-${seriesId(series)}`;\n builder.registerClipPath(\n clipId,\n `<rect x=\"${fmt(plotArea.x)}\" y=\"${fmt(plotArea.y)}\" width=\"${fmt(plotArea.width)}\" height=\"${fmt(plotArea.height)}\"/>`,\n );\n\n for (let i = 0; i < data.x.length; i++) {\n const px = xScale.transform(data.x[i]);\n const py = yScale.transform(data.y[i]);\n const yTop = Math.min(py, p0);\n const yHeight = Math.max(1, Math.abs(py - p0));\n builder.push(\n \"series\",\n `<rect clip-path=\"url(#${clipId})\" x=\"${fmt(px - barWidthPx / 2)}\" y=\"${fmt(yTop)}\" width=\"${fmt(barWidthPx)}\" height=\"${fmt(yHeight)}\" fill=\"${color}\" fill-opacity=\"${opacity}\"/>`,\n );\n }\n}\n","import type { Series } from \"../../../../Series\";\nimport { seriesId } from \"../seriesUtils\";\nimport type { Scale } from \"../../../../../scales\";\nimport type { PlotArea } from \"../../../../../types\";\nimport type { SVGDocumentBuilder } from \"../SVGDocumentBuilder\";\nimport { fmt } from \"../SVGDocumentBuilder\";\nimport { collectFiniteIndices } from \"./finitePoints\";\n\nexport function exportBandSeries(\n series: Series,\n plotArea: PlotArea,\n xScale: Scale,\n yScale: Scale,\n builder: SVGDocumentBuilder,\n): void {\n const data = series.getData();\n if (!data || data.x.length === 0) return;\n\n const style = series.getStyle() as Record<string, unknown>;\n const type = series.getType();\n const color = (style.color as string) ?? \"#ff0055\";\n const opacity = (style.opacity as number) ?? 1;\n const width = (style.width as number) ?? 1;\n const fillOpacity = (style.fillOpacity as number) ?? opacity * 0.3;\n\n const y2 =\n type === \"area\"\n ? new Float32Array(data.x.length).fill((style.baseline as number) ?? 0)\n : data.y2 ?? new Float32Array(data.x.length).fill(0);\n\n const indices = collectFiniteIndices(data.x, data.y, y2);\n if (indices.length < 2) return;\n\n const points: string[] = [];\n for (const i of indices) {\n points.push(`${fmt(xScale.transform(data.x[i]))},${fmt(yScale.transform(data.y[i]))}`);\n }\n for (let j = indices.length - 1; j >= 0; j--) {\n const i = indices[j];\n points.push(`${fmt(xScale.transform(data.x[i]))},${fmt(yScale.transform(y2[i]))}`);\n }\n\n const clipId = `vp-clip-band-${seriesId(series)}`;\n builder.registerClipPath(\n clipId,\n `<rect x=\"${fmt(plotArea.x)}\" y=\"${fmt(plotArea.y)}\" width=\"${fmt(plotArea.width)}\" height=\"${fmt(plotArea.height)}\"/>`,\n );\n\n let fillAttr = `fill=\"${color}\" fill-opacity=\"${fillOpacity}\"`;\n if (style.gradient) {\n const gradId = builder.registerLinearGradient(0, 0, 0, 1, [\n { offset: \"0%\", color, opacity: fillOpacity },\n { offset: \"100%\", color, opacity: 0 },\n ]);\n fillAttr = `fill=\"url(#${gradId})\"`;\n }\n\n builder.push(\n \"series\",\n `<polygon clip-path=\"url(#${clipId})\" points=\"${points.join(\" \")}\" ${fillAttr} stroke=\"${color}\" stroke-width=\"${width}\" stroke-opacity=\"${opacity}\"/>`,\n );\n}\n","import type { Series } from \"../../../../Series\";\nimport { seriesId } from \"../seriesUtils\";\nimport type { Scale } from \"../../../../../scales\";\nimport type { PlotArea } from \"../../../../../types\";\nimport type { SVGDocumentBuilder } from \"../SVGDocumentBuilder\";\nimport { fmt } from \"../SVGDocumentBuilder\";\n\nexport function exportCandlestickSeries(\n series: Series,\n plotArea: PlotArea,\n xScale: Scale,\n yScale: Scale,\n builder: SVGDocumentBuilder,\n): void {\n const data = series.getData();\n if (!data?.open || !data.high || !data.low || !data.close || data.x.length === 0) return;\n\n const style = series.getStyle() as Record<string, unknown>;\n const domainSpan = xScale.domain[1] - xScale.domain[0];\n const barWidthData = (style.barWidth as number) ?? 0.8;\n const bw =\n domainSpan > 0\n ? (barWidthData / domainSpan) * plotArea.width\n : ((style.barWidth as number) || 5);\n const bullishColor = (style.bullishColor as string) || \"#26a69a\";\n const bearishColor = (style.bearishColor as string) || \"#ef5350\";\n const hollow = style.hollow === true;\n\n const clipId = `vp-clip-candle-${seriesId(series)}`;\n builder.registerClipPath(\n clipId,\n `<rect x=\"${fmt(plotArea.x)}\" y=\"${fmt(plotArea.y)}\" width=\"${fmt(plotArea.width)}\" height=\"${fmt(plotArea.height)}\"/>`,\n );\n\n for (let i = 0; i < data.x.length; i++) {\n const isBull = data.close[i] >= data.open[i];\n const px = xScale.transform(data.x[i]);\n const pyOpen = yScale.transform(data.open[i]);\n const pyClose = yScale.transform(data.close[i]);\n const pyHigh = yScale.transform(data.high[i]);\n const pyLow = yScale.transform(data.low[i]);\n const color = isBull ? bullishColor : bearishColor;\n\n builder.push(\n \"series\",\n `<line clip-path=\"url(#${clipId})\" x1=\"${fmt(px)}\" y1=\"${fmt(pyHigh)}\" x2=\"${fmt(px)}\" y2=\"${fmt(pyLow)}\" stroke=\"${color}\" stroke-width=\"1\"/>`,\n );\n\n const yTop = Math.min(pyOpen, pyClose);\n const yHeight = Math.max(1, Math.abs(pyOpen - pyClose));\n const fill = hollow && isBull ? \"none\" : color;\n const stroke = hollow && isBull ? color : \"none\";\n builder.push(\n \"series\",\n `<rect clip-path=\"url(#${clipId})\" x=\"${fmt(px - bw / 2)}\" y=\"${fmt(yTop)}\" width=\"${fmt(bw)}\" height=\"${fmt(yHeight)}\" fill=\"${fill}\" stroke=\"${stroke}\" stroke-width=\"1\"/>`,\n );\n }\n}\n","import type { Series } from \"../../../../Series\";\nimport { seriesId } from \"../seriesUtils\";\nimport type { Scale } from \"../../../../../scales\";\nimport type { PlotArea } from \"../../../../../types\";\nimport type { SVGDocumentBuilder } from \"../SVGDocumentBuilder\";\nimport { fmt } from \"../SVGDocumentBuilder\";\n\nconst HEATMAP_CELL_BUDGET = 10_000;\n\nfunction heatmapColor(value: number, min: number, max: number, colormap: string): string {\n const t = max === min ? 0.5 : (value - min) / (max - min);\n if (colormap === \"viridis\") {\n const r = Math.round(68 + t * 150);\n const g = Math.round(1 + t * 180);\n const b = Math.round(84 + (1 - t) * 50);\n return `rgb(${r},${g},${b})`;\n }\n const v = Math.round(t * 255);\n return `rgb(${v},${Math.round(v * 0.4)},${255 - v})`;\n}\n\nexport function exportHeatmapSeries(\n series: Series,\n plotArea: PlotArea,\n xScale: Scale,\n yScale: Scale,\n builder: SVGDocumentBuilder,\n): void {\n const hm = series.getHeatmapData?.();\n if (!hm) return;\n\n const { xValues, yValues, zValues } = hm;\n const nx = xValues.length;\n const ny = yValues.length;\n const cellCount = nx * ny;\n\n const style = series.getHeatmapStyle?.() ?? series.getStyle();\n const colorScale = (style as { colorScale?: { name?: string; min?: number; max?: number } }).colorScale;\n const colormap =\n colorScale?.name ??\n (style as { colormap?: string }).colormap ??\n \"viridis\";\n\n let zMin = colorScale?.min;\n let zMax = colorScale?.max;\n if (zMin === undefined || zMax === undefined) {\n zMin = Infinity;\n zMax = -Infinity;\n for (let i = 0; i < zValues.length; i++) {\n if (zValues[i] < zMin) zMin = zValues[i];\n if (zValues[i] > zMax) zMax = zValues[i];\n }\n }\n if (!Number.isFinite(zMin) || !Number.isFinite(zMax)) {\n zMin = 0;\n zMax = 1;\n }\n\n const xStep = nx > 1 ? Math.abs(xValues[1] - xValues[0]) : 1;\n const yStep = ny > 1 ? Math.abs(yValues[1] - yValues[0]) : 1;\n const xHalf = xStep / 2;\n const yHalf = yStep / 2;\n\n if (cellCount > HEATMAP_CELL_BUDGET) {\n console.warn(\n `[VeloPlot] Heatmap SVG export: ${cellCount} cells exceeds budget (${HEATMAP_CELL_BUDGET}). Consider raster fallback.`,\n );\n }\n\n const clipId = `vp-clip-hm-${seriesId(series)}`;\n builder.registerClipPath(\n clipId,\n `<rect x=\"${fmt(plotArea.x)}\" y=\"${fmt(plotArea.y)}\" width=\"${fmt(plotArea.width)}\" height=\"${fmt(plotArea.height)}\"/>`,\n );\n\n for (let j = 0; j < ny; j++) {\n for (let i = 0; i < nx; i++) {\n const z = zValues[j * nx + i];\n const xLo = xScale.transform(xValues[i] - xHalf);\n const xHi = xScale.transform(xValues[i] + xHalf);\n const yLo = yScale.transform(yValues[j] - yHalf);\n const yHi = yScale.transform(yValues[j] + yHalf);\n const left = Math.min(xLo, xHi);\n const top = Math.min(yLo, yHi);\n const w = Math.max(1, Math.abs(xHi - xLo));\n const h = Math.max(1, Math.abs(yHi - yLo));\n const color = heatmapColor(z, zMin, zMax, colormap);\n builder.push(\n \"series\",\n `<rect clip-path=\"url(#${clipId})\" x=\"${fmt(left)}\" y=\"${fmt(top)}\" width=\"${fmt(w)}\" height=\"${fmt(h)}\" fill=\"${color}\"/>`,\n );\n }\n }\n}\n","import type { Series } from \"../../../../Series\";\nimport { seriesId } from \"../seriesUtils\";\nimport type { Scale } from \"../../../../../scales\";\nimport type { PlotArea } from \"../../../../../types\";\nimport type { PolarMode } from \"../../../../../types\";\nimport type { SVGDocumentBuilder } from \"../SVGDocumentBuilder\";\nimport { fmt } from \"../SVGDocumentBuilder\";\nimport {\n interleavePolarFillData,\n interleavePolarLineData,\n} from \"../../../../../renderer/PolarRenderer\";\n\nfunction dataToPixelPoints(\n cartesian: Float32Array,\n xScale: Scale,\n yScale: Scale,\n): string[] {\n const points: string[] = [];\n for (let i = 0; i < cartesian.length / 2; i++) {\n const px = xScale.transform(cartesian[i * 2]);\n const py = yScale.transform(cartesian[i * 2 + 1]);\n points.push(`${fmt(px)},${fmt(py)}`);\n }\n return points;\n}\n\nexport function exportPolarSeries(\n series: Series,\n plotArea: PlotArea,\n xScale: Scale,\n yScale: Scale,\n builder: SVGDocumentBuilder,\n): void {\n const polar = series.getPolarData?.();\n if (!polar) return;\n\n const style = series.getStyle() as Record<string, unknown>;\n const color = (style.color as string) ?? \"#ff0055\";\n const opacity = (style.opacity as number) ?? 1;\n const width = (style.width as number) ?? 1.5;\n const fillOpacity = (style.fillOpacity as number) ?? opacity * 0.2;\n const angleMode = (style.angleMode as PolarMode) ?? \"degrees\";\n const closePath = style.closePath !== false;\n const fill = Boolean(style.fill);\n\n const clipId = `vp-clip-polar-${seriesId(series)}`;\n builder.registerClipPath(\n clipId,\n `<rect x=\"${fmt(plotArea.x)}\" y=\"${fmt(plotArea.y)}\" width=\"${fmt(plotArea.width)}\" height=\"${fmt(plotArea.height)}\"/>`,\n );\n\n if (fill) {\n const fillData = interleavePolarFillData(polar, angleMode, closePath);\n const centerX = xScale.transform(0);\n const centerY = yScale.transform(0);\n const numTriangles = fillData.length / 6;\n\n for (let i = 0; i < numTriangles; i++) {\n const base = i * 6;\n const pts = [\n `${fmt(centerX)},${fmt(centerY)}`,\n `${fmt(xScale.transform(fillData[base + 2]))},${fmt(yScale.transform(fillData[base + 3]))}`,\n `${fmt(xScale.transform(fillData[base + 4]))},${fmt(yScale.transform(fillData[base + 5]))}`,\n ];\n builder.push(\n \"series\",\n `<polygon clip-path=\"url(#${clipId})\" points=\"${pts.join(\" \")}\" fill=\"${color}\" fill-opacity=\"${fillOpacity}\" stroke=\"none\"/>`,\n );\n }\n }\n\n const lineData = interleavePolarLineData(polar, angleMode, closePath);\n const points = dataToPixelPoints(lineData, xScale, yScale);\n if (points.length === 0) return;\n\n builder.push(\n \"series\",\n `<polyline clip-path=\"url(#${clipId})\" points=\"${points.join(\" \")}\" fill=\"none\" stroke=\"${color}\" stroke-width=\"${width}\" stroke-opacity=\"${opacity}\"/>`,\n );\n}\n","import type { Series } from \"../../../../Series\";\nimport type { PlotArea } from \"../../../../../types\";\nimport type { SVGDocumentBuilder } from \"../SVGDocumentBuilder\";\nimport { fmt, escapeXml } from \"../SVGDocumentBuilder\";\n\nexport function exportGaugeSeries(\n series: Series,\n plotArea: PlotArea,\n builder: SVGDocumentBuilder,\n): void {\n const data = series.getGaugeData?.();\n const style = series.getGaugeStyle?.() ?? series.getStyle();\n if (!data) return;\n\n const cx = plotArea.x + plotArea.width / 2;\n const cy = plotArea.y + plotArea.height * 0.65;\n const radius = Math.min(plotArea.width, plotArea.height) * 0.35;\n const min = data.min ?? 0;\n const max = data.max ?? 100;\n const value = data.value ?? 0;\n const startAngle = Math.PI;\n const endAngle = 0;\n const t = Math.max(0, Math.min(1, (value - min) / (max - min)));\n\n const arcPath = (r: number, a0: number, a1: number) => {\n const x0 = cx + r * Math.cos(a0);\n const y0 = cy - r * Math.sin(a0);\n const x1 = cx + r * Math.cos(a1);\n const y1 = cy - r * Math.sin(a1);\n const large = a1 - a0 > Math.PI ? 1 : 0;\n return `M ${fmt(x0)} ${fmt(y0)} A ${fmt(r)} ${fmt(r)} 0 ${large} 1 ${fmt(x1)} ${fmt(y1)}`;\n };\n\n const trackColor = (style as { trackColor?: string }).trackColor ?? \"#333\";\n const fillColor = (style as { color?: string }).color ?? \"#3b82f6\";\n\n builder.push(\"series\", `<path d=\"${arcPath(radius, startAngle, endAngle)}\" fill=\"none\" stroke=\"${trackColor}\" stroke-width=\"12\" stroke-linecap=\"round\"/>`);\n\n const valueAngle = startAngle - t * Math.PI;\n builder.push(\"series\", `<path d=\"${arcPath(radius, startAngle, valueAngle)}\" fill=\"none\" stroke=\"${fillColor}\" stroke-width=\"12\" stroke-linecap=\"round\"/>`);\n\n const needleLen = radius - 8;\n const nx = cx + needleLen * Math.cos(valueAngle);\n const ny = cy - needleLen * Math.sin(valueAngle);\n builder.push(\"series\", `<line x1=\"${fmt(cx)}\" y1=\"${fmt(cy)}\" x2=\"${fmt(nx)}\" y2=\"${fmt(ny)}\" stroke=\"${fillColor}\" stroke-width=\"2\"/>`);\n builder.push(\"series\", `<circle cx=\"${fmt(cx)}\" cy=\"${fmt(cy)}\" r=\"4\" fill=\"${fillColor}\"/>`);\n\n const label = (style as { label?: string }).label ?? `${value}`;\n builder.push(\n \"series\",\n `<text x=\"${fmt(cx)}\" y=\"${fmt(cy + 30)}\" fill=\"${fillColor}\" font-size=\"18\" font-weight=\"600\" text-anchor=\"middle\">${escapeXml(String(label))}</text>`,\n );\n}\n","import type { Series } from \"../../../../Series\";\nimport type { PlotArea } from \"../../../../../types\";\nimport type { SankeyNode } from \"../../../../../types\";\nimport type { SVGDocumentBuilder } from \"../SVGDocumentBuilder\";\nimport { fmt, escapeXml } from \"../SVGDocumentBuilder\";\nimport { computeSankeyLayout } from \"../../../../../renderer/sankeyLayout\";\n\nexport function exportSankeySeries(\n series: Series,\n plotArea: PlotArea,\n builder: SVGDocumentBuilder,\n): void {\n const data = series.getSankeyData?.();\n const style = series.getSankeyStyle?.() ?? series.getStyle();\n if (!data?.links?.length) return;\n\n const layout = computeSankeyLayout(data, style as import(\"../../../../../types\").SankeyStyle, plotArea);\n if (!layout) return;\n\n const { nodeRegistry, links, nodeOutValue, nodeInValue, workingArea } = layout;\n const { linkOpacity, showLabels, nodeWidth } = layout.style;\n\n const clipId = \"vp-clip-sankey\";\n builder.registerClipPath(\n clipId,\n `<rect x=\"${fmt(plotArea.x)}\" y=\"${fmt(plotArea.y)}\" width=\"${fmt(plotArea.width)}\" height=\"${fmt(plotArea.height)}\"/>`,\n );\n\n for (const entry of links) {\n const src = entry.source;\n const dst = entry.target;\n const sOffset = entry.sourceOffset;\n const tOffset = entry.targetOffset;\n\n const sValue = nodeOutValue.get(entry.link.source) || 1;\n const tValue = nodeInValue.get(entry.link.target) || 1;\n\n const srcFlowHeight = (entry.link.value / sValue) * src.height;\n const dstFlowHeight = (entry.link.value / tValue) * dst.height;\n\n const x0 = src.x + src.width;\n const y0 = src.y + sOffset;\n const y1 = y0 + srcFlowHeight;\n const x2 = dst.x;\n const y2 = dst.y + tOffset;\n const y3 = y2 + dstFlowHeight;\n const cpOffset = (x2 - x0) * 0.5;\n\n const gradId = builder.registerLinearGradient(x0, (y0 + y1) / 2, x2, (y2 + y3) / 2, [\n { offset: \"0%\", color: src.color },\n { offset: \"100%\", color: dst.color },\n ]);\n\n builder.push(\n \"series\",\n `<path clip-path=\"url(#${clipId})\" d=\"M ${fmt(x0)} ${fmt(y0)} C ${fmt(x0 + cpOffset)} ${fmt(y0)}, ${fmt(x2 - cpOffset)} ${fmt(y2)}, ${fmt(x2)} ${fmt(y2)} L ${fmt(x2)} ${fmt(y3)} C ${fmt(x2 - cpOffset)} ${fmt(y3)}, ${fmt(x0 + cpOffset)} ${fmt(y1)}, ${fmt(x0)} ${fmt(y1)} Z\" fill=\"url(#${gradId})\" fill-opacity=\"${linkOpacity}\" stroke=\"${src.color}\" stroke-opacity=\"${linkOpacity * 0.3}\" stroke-width=\"0.5\"/>`,\n );\n }\n\n nodeRegistry.forEach((node) => {\n builder.push(\n \"series\",\n `<rect clip-path=\"url(#${clipId})\" x=\"${fmt(node.x)}\" y=\"${fmt(node.y)}\" width=\"${fmt(node.width)}\" height=\"${fmt(node.height)}\" fill=\"${node.color}\"/>`,\n );\n });\n\n if (showLabels) {\n nodeRegistry.forEach((node, id) => {\n let nodeName = String(id);\n const found = (data.nodes as SankeyNode[]).find((n) => n.id === id);\n if (found?.name) nodeName = found.name;\n\n const isFirstLayer = node.x <= workingArea.x + 5;\n const isLastLayer = node.x >= workingArea.x + workingArea.width - nodeWidth - 5;\n\n if (isFirstLayer) {\n builder.push(\n \"series\",\n `<text clip-path=\"url(#${clipId})\" x=\"${fmt(node.x - 10)}\" y=\"${fmt(node.y + node.height / 2)}\" fill=\"#ffffff\" font-size=\"11\" font-weight=\"700\" text-anchor=\"end\" dominant-baseline=\"middle\">${escapeXml(nodeName)}</text>`,\n );\n } else if (isLastLayer) {\n builder.push(\n \"series\",\n `<text clip-path=\"url(#${clipId})\" x=\"${fmt(node.x + node.width + 10)}\" y=\"${fmt(node.y + node.height / 2)}\" fill=\"#ffffff\" font-size=\"11\" font-weight=\"700\" text-anchor=\"start\" dominant-baseline=\"middle\">${escapeXml(nodeName)}</text>`,\n );\n } else {\n builder.push(\n \"series\",\n `<text clip-path=\"url(#${clipId})\" x=\"${fmt(node.x + node.width / 2)}\" y=\"${fmt(node.y - 10)}\" fill=\"#ffffff\" font-size=\"11\" font-weight=\"700\" text-anchor=\"middle\">${escapeXml(nodeName)}</text>`,\n );\n }\n });\n }\n}\n","import type { Series } from \"../../../../Series\";\nimport type { Scale } from \"../../../../../scales\";\nimport type { PlotArea } from \"../../../../../types\";\nimport type { SVGDocumentBuilder } from \"../SVGDocumentBuilder\";\nimport { fmt } from \"../SVGDocumentBuilder\";\nimport { symbolSvg } from \"../symbols\";\n\n/** Ternary plot: equilateral triangle with normalized (a,b,c) components. */\nexport function exportTernarySeries(\n series: Series,\n plotArea: PlotArea,\n _xScale: Scale,\n _yScale: Scale,\n builder: SVGDocumentBuilder,\n): void {\n const data = series.getData();\n const style = series.getStyle() as Record<string, unknown>;\n const color = (style.color as string) ?? \"#ff0055\";\n\n const ax = plotArea.x + plotArea.width / 2;\n const ay = plotArea.y + plotArea.height - 20;\n const side = Math.min(plotArea.width, plotArea.height) - 40;\n const h = (side * Math.sqrt(3)) / 2;\n\n const v0 = { x: ax, y: ay };\n const v1 = { x: ax - side / 2, y: ay - h };\n const v2 = { x: ax + side / 2, y: ay - h };\n\n builder.push(\n \"series\",\n `<polygon points=\"${fmt(v0.x)},${fmt(v0.y)} ${fmt(v1.x)},${fmt(v1.y)} ${fmt(v2.x)},${fmt(v2.y)}\" fill=\"none\" stroke=\"${color}\" stroke-width=\"1\"/>`,\n );\n\n for (let i = 1; i <= 4; i++) {\n const t = i / 5;\n const a = { x: v0.x + (v1.x - v0.x) * t, y: v0.y + (v1.y - v0.y) * t };\n const b = { x: v0.x + (v2.x - v0.x) * t, y: v0.y + (v2.y - v0.y) * t };\n builder.push(\"grid\", `<line x1=\"${fmt(a.x)}\" y1=\"${fmt(a.y)}\" x2=\"${fmt(b.x)}\" y2=\"${fmt(b.y)}\" stroke=\"${color}\" stroke-opacity=\"0.2\"/>`);\n }\n\n if (!data?.x?.length) return;\n for (let i = 0; i < data.x.length; i++) {\n const a = data.x[i];\n const b = data.y[i];\n const c = 1 - a - b;\n const px = a * v1.x + b * v2.x + c * v0.x;\n const py = a * v1.y + b * v2.y + c * v0.y;\n builder.push(\"series\", symbolSvg(\"circle\", px, py, 6, color));\n }\n}\n","import type { Series } from \"../../../../Series\";\nimport { seriesId } from \"../seriesUtils\";\nimport type { Scale } from \"../../../../../scales\";\nimport type { PlotArea } from \"../../../../../types\";\nimport type { SVGDocumentBuilder } from \"../SVGDocumentBuilder\";\nimport { fmt } from \"../SVGDocumentBuilder\";\n\nexport function exportWaterfallSeries(\n series: Series,\n plotArea: PlotArea,\n xScale: Scale,\n yScale: Scale,\n builder: SVGDocumentBuilder,\n): void {\n const data = series.getData();\n if (!data?.x?.length) return;\n\n const style = series.getStyle() as Record<string, unknown>;\n const positiveColor = (style.positiveColor as string) ?? \"#22c55e\";\n const negativeColor = (style.negativeColor as string) ?? \"#ef4444\";\n const subtotalColor = (style.subtotalColor as string) ?? \"#3b82f6\";\n const connectorColor = (style.connectorColor as string) ?? \"#64748b\";\n const types = (style.waterfallTypes as string[]) ?? [];\n const domainSpan = xScale.domain[1] - xScale.domain[0];\n const barWidth =\n domainSpan > 0\n ? (((style.barWidth as number) ?? 0.8) / domainSpan) * plotArea.width\n : 20;\n\n let running = 0;\n const clipId = `vp-clip-wf-${seriesId(series)}`;\n builder.registerClipPath(\n clipId,\n `<rect x=\"${fmt(plotArea.x)}\" y=\"${fmt(plotArea.y)}\" width=\"${fmt(plotArea.width)}\" height=\"${fmt(plotArea.height)}\"/>`,\n );\n\n for (let i = 0; i < data.x.length; i++) {\n const val = data.y[i];\n const type = types[i] ?? (val >= 0 ? \"positive\" : \"negative\");\n const px = xScale.transform(data.x[i]);\n let y0: number;\n let y1: number;\n let color: string;\n\n if (type === \"subtotal\") {\n y0 = yScale.transform(0);\n y1 = yScale.transform(running);\n color = subtotalColor;\n } else if (type === \"total\") {\n y0 = yScale.transform(0);\n y1 = yScale.transform(running + val);\n running += val;\n color = subtotalColor;\n } else {\n y0 = yScale.transform(running);\n running += val;\n y1 = yScale.transform(running);\n color = val >= 0 ? positiveColor : negativeColor;\n }\n\n const top = Math.min(y0, y1);\n const height = Math.max(1, Math.abs(y1 - y0));\n builder.push(\n \"series\",\n `<rect clip-path=\"url(#${clipId})\" x=\"${fmt(px - barWidth / 2)}\" y=\"${fmt(top)}\" width=\"${fmt(barWidth)}\" height=\"${fmt(height)}\" fill=\"${color}\" fill-opacity=\"0.9\"/>`,\n );\n\n if (i > 0 && style.showConnectors !== false) {\n const prevPx = xScale.transform(data.x[i - 1]);\n const prevTop = yScale.transform(running - val);\n builder.push(\n \"series\",\n `<line x1=\"${fmt(prevPx + barWidth / 2)}\" y1=\"${fmt(prevTop)}\" x2=\"${fmt(px - barWidth / 2)}\" y2=\"${fmt(prevTop)}\" stroke=\"${connectorColor}\" stroke-width=\"1\" stroke-opacity=\"0.6\"/>`,\n );\n }\n }\n}\n","import type { Series } from \"../../../../Series\";\nimport { seriesId } from \"../seriesUtils\";\nimport type { Scale } from \"../../../../../scales\";\nimport type { PlotArea } from \"../../../../../types\";\nimport type { SVGDocumentBuilder } from \"../SVGDocumentBuilder\";\nimport { fmt } from \"../SVGDocumentBuilder\";\nimport { symbolSvg } from \"../symbols\";\n\nexport function exportBoxplotSeries(\n series: Series,\n plotArea: PlotArea,\n xScale: Scale,\n yScale: Scale,\n builder: SVGDocumentBuilder,\n): void {\n const data = series.getData();\n if (!data?.x?.length || !data.median) return;\n\n const style = series.getStyle() as Record<string, unknown>;\n const color = (style.color as string) ?? \"#ff0055\";\n const opacity = (style.opacity as number) ?? 1;\n const domainSpan = xScale.domain[1] - xScale.domain[0];\n const boxWidth =\n domainSpan > 0\n ? (((style.barWidth as number) ?? 0.6) / domainSpan) * plotArea.width\n : 16;\n\n const q1 = (data as { q1?: Float32Array }).q1;\n const q3 = (data as { q3?: Float32Array }).q3;\n const low = data.low;\n const high = data.high;\n\n const clipId = `vp-clip-box-${seriesId(series)}`;\n builder.registerClipPath(\n clipId,\n `<rect x=\"${fmt(plotArea.x)}\" y=\"${fmt(plotArea.y)}\" width=\"${fmt(plotArea.width)}\" height=\"${fmt(plotArea.height)}\"/>`,\n );\n\n for (let i = 0; i < data.x.length; i++) {\n const px = xScale.transform(data.x[i]);\n const yQ1 = q1 ? yScale.transform(q1[i]) : yScale.transform(data.y[i]);\n const yQ3 = q3 ? yScale.transform(q3[i]) : yScale.transform(data.y2?.[i] ?? data.y[i]);\n const yMed = yScale.transform(data.median![i]);\n const yLow = low ? yScale.transform(low[i]) : yQ1;\n const yHigh = high ? yScale.transform(high[i]) : yQ3;\n\n const boxTop = Math.min(yQ1, yQ3);\n const boxH = Math.max(1, Math.abs(yQ3 - yQ1));\n\n builder.push(\"series\", `<line clip-path=\"url(#${clipId})\" x1=\"${fmt(px)}\" y1=\"${fmt(yLow)}\" x2=\"${fmt(px)}\" y2=\"${fmt(yHigh)}\" stroke=\"${color}\" stroke-width=\"1\"/>`);\n builder.push(\"series\", `<rect clip-path=\"url(#${clipId})\" x=\"${fmt(px - boxWidth / 2)}\" y=\"${fmt(boxTop)}\" width=\"${fmt(boxWidth)}\" height=\"${fmt(boxH)}\" fill=\"${color}\" fill-opacity=\"${opacity * 0.3}\" stroke=\"${color}\"/>`);\n builder.push(\"series\", `<line clip-path=\"url(#${clipId})\" x1=\"${fmt(px - boxWidth / 2)}\" y1=\"${fmt(yMed)}\" x2=\"${fmt(px + boxWidth / 2)}\" y2=\"${fmt(yMed)}\" stroke=\"${color}\" stroke-width=\"2\"/>`);\n\n const outliers = (data as { outliers?: { x: number; y: number }[][] }).outliers?.[i];\n if (outliers) {\n for (const o of outliers) {\n builder.push(\"series\", symbolSvg(\"circle\", xScale.transform(o.x), yScale.transform(o.y), 4, color, opacity));\n }\n }\n }\n}\n","/**\n * Expands a composite indicator definition into native series (bar, line, band, scatter).\n */\nimport type { SeriesOptions } from \"../../types\";\nimport type { IndicatorSeriesOptions, IndicatorStyle, IndicatorLineLayer } from \"./types\";\n\nfunction toF32(data: Float32Array | Float64Array | number[]): Float32Array | Float64Array {\n if (data instanceof Float32Array || data instanceof Float64Array) return data;\n return Float32Array.from(data);\n}\n\nfunction splitSignedHistogram(\n hist: Float32Array | Float64Array,\n): { positive: Float32Array; negative: Float32Array } {\n const positive = new Float32Array(hist.length);\n const negative = new Float32Array(hist.length);\n for (let i = 0; i < hist.length; i++) {\n const v = hist[i];\n positive[i] = v > 0 ? v : 0;\n negative[i] = v < 0 ? v : 0;\n }\n return { positive, negative };\n}\n\ninterface ColorSegment {\n points: { x: number; y: number }[];\n color: string;\n}\n\nfunction resolveLineRefY(\n ref: number | \"zero\" | string | undefined,\n index: number,\n lines: IndicatorLineLayer[],\n): number {\n if (ref === undefined || ref === \"zero\") return 0;\n if (typeof ref === \"number\") return ref;\n const other = lines.find((l) => l.id === ref);\n if (!other) return 0;\n const yRef = toF32(other.y);\n return yRef[index] ?? 0;\n}\n\nfunction splitLineIntoColorSegments(\n x: Float32Array | Float64Array,\n y: Float32Array | Float64Array,\n refAt: (i: number) => number,\n aboveColor: string,\n belowColor: string,\n): ColorSegment[] {\n const n = x.length;\n if (n === 0) return [];\n if (n === 1) {\n const color = y[0] >= refAt(0) ? aboveColor : belowColor;\n return [{ points: [{ x: x[0], y: y[0] }], color }];\n }\n\n const segments: ColorSegment[] = [];\n let current: ColorSegment | null = null;\n\n const colorAt = (i: number) => (y[i] >= refAt(i) ? aboveColor : belowColor);\n\n const addPoint = (px: number, py: number, color: string) => {\n if (!current || current.color !== color) {\n if (current?.points.length) segments.push(current);\n current = { points: [{ x: px, y: py }], color };\n } else {\n current.points.push({ x: px, y: py });\n }\n };\n\n const flush = () => {\n if (current?.points.length) {\n segments.push(current);\n current = null;\n }\n };\n\n addPoint(x[0], y[0], colorAt(0));\n\n for (let i = 1; i < n; i++) {\n const y0 = y[i - 1];\n const y1 = y[i];\n const r0 = refAt(i - 1);\n const r1 = refAt(i);\n const above0 = y0 >= r0;\n const above1 = y1 >= r1;\n\n if (above0 === above1) {\n addPoint(x[i], y[i], colorAt(i));\n continue;\n }\n\n // A sign change (above0 !== above1) guarantees the line and its reference\n // cross, so the slope difference here is always non-zero. The clamp below is\n // the safety net for any floating-point overshoot.\n const denom = y1 - y0 - (r1 - r0);\n const t = Math.max(0, Math.min(1, (r0 - y0) / denom));\n const xc = x[i - 1] + t * (x[i] - x[i - 1]);\n const yc = y0 + t * (y1 - y0);\n const colorBefore = above0 ? aboveColor : belowColor;\n const colorAfter = above1 ? aboveColor : belowColor;\n\n addPoint(xc, yc, colorBefore);\n flush();\n addPoint(xc, yc, colorAfter);\n addPoint(x[i], y[i], colorAt(i));\n }\n\n flush();\n return segments;\n}\n\nfunction pushColoredLineSeries(\n out: SeriesOptions[],\n lineId: string,\n x: Float32Array | Float64Array,\n y: Float32Array | Float64Array,\n line: IndicatorLineLayer,\n lines: IndicatorLineLayer[],\n visible: boolean,\n segmentKey: string,\n): void {\n // Caller guarantees colorZones is present (see the `if (line.colorZones)` guard).\n const zones = line.colorZones!;\n\n const refAt = (i: number) => resolveLineRefY(zones.ref, i, lines);\n const segments = splitLineIntoColorSegments(\n x,\n y,\n refAt,\n zones.aboveColor,\n zones.belowColor,\n );\n\n for (let si = 0; si < segments.length; si++) {\n const seg = segments[si];\n if (seg.points.length < 2) continue;\n out.push({\n id: `${lineId}-${segmentKey}-${si}`,\n type: \"line\",\n visible,\n data: {\n x: Float32Array.from(seg.points.map((p) => p.x)),\n y: Float32Array.from(seg.points.map((p) => p.y)),\n },\n style: {\n color: seg.color,\n width: line.width ?? 2,\n opacity: line.opacity ?? 1,\n },\n });\n }\n}\n\nconst DEFAULT_STYLE: Required<\n Pick<\n IndicatorStyle,\n | \"baselineColor\"\n | \"baselineWidth\"\n | \"baselineDash\"\n | \"peakColor\"\n | \"troughColor\"\n | \"peakSize\"\n | \"troughSize\"\n >\n> = {\n baselineColor: \"rgba(255,255,255,0.35)\",\n baselineWidth: 1,\n baselineDash: [4, 4],\n peakColor: \"#ff00ff\",\n troughColor: \"#00ffff\",\n peakSize: 6,\n troughSize: 6,\n};\n\n/**\n * Build native series options from an indicator definition.\n * Use in any chart pane — standalone or inside createStackedChart.\n */\nexport function buildIndicatorSeries(options: IndicatorSeriesOptions): SeriesOptions[] {\n const { id, data, style = {}, visible = true } = options;\n const merged = { ...DEFAULT_STYLE, ...style };\n const x = toF32(data.x);\n const n = x.length;\n const out: SeriesOptions[] = [];\n\n if (data.fills?.length) {\n for (let i = 0; i < data.fills.length; i++) {\n const fill = data.fills[i];\n const fillId = fill.id ?? `${id}-fill-${i}`;\n out.push({\n id: fillId,\n type: \"band\",\n visible,\n data: {\n x,\n y: toF32(fill.upper),\n y2: toF32(fill.lower),\n },\n style: {\n color: fill.color ?? \"rgba(100, 80, 180, 0.25)\",\n opacity: fill.opacity ?? 0.35,\n },\n });\n }\n }\n\n if (data.histogram) {\n const hist = toF32(data.histogram.y);\n const { positive, negative } = splitSignedHistogram(hist);\n const barWidth = data.histogram.barWidth;\n const barStyle = barWidth !== undefined ? { barWidth } : {};\n\n out.push({\n id: `${id}-hist-pos`,\n type: \"bar\",\n visible,\n data: { x, y: positive },\n style: {\n color: data.histogram.positiveColor ?? \"#26a69a\",\n opacity: data.histogram.opacity ?? 0.85,\n ...barStyle,\n } as SeriesOptions[\"style\"],\n });\n out.push({\n id: `${id}-hist-neg`,\n type: \"bar\",\n visible,\n data: { x, y: negative },\n style: {\n color: data.histogram.negativeColor ?? \"#ef5350\",\n opacity: data.histogram.opacity ?? 0.85,\n ...barStyle,\n } as SeriesOptions[\"style\"],\n });\n }\n\n if (data.lines?.length) {\n for (let i = 0; i < data.lines.length; i++) {\n const line = data.lines[i];\n const lineId = line.id ?? `${id}-line-${i}`;\n const yData = toF32(line.y);\n\n if (line.colorZones) {\n pushColoredLineSeries(out, lineId, x, yData, line, data.lines, visible, \"zone\");\n continue;\n }\n\n out.push({\n id: lineId,\n type: \"line\",\n visible,\n data: { x, y: yData },\n style: {\n color: line.color ?? (i === 0 ? \"#00e5ff\" : \"#e040fb\"),\n width: line.width ?? 2,\n opacity: line.opacity ?? 1,\n },\n });\n }\n }\n\n if (data.baseline !== undefined && n >= 2) {\n const baseline = data.baseline;\n out.push({\n id: `${id}-baseline`,\n type: \"line\",\n visible,\n data: {\n x: Float32Array.from([x[0], x[n - 1]]),\n y: Float32Array.from([baseline, baseline]),\n },\n style: {\n color: merged.baselineColor,\n width: merged.baselineWidth,\n lineDash: merged.baselineDash,\n opacity: 1,\n },\n });\n }\n\n if (data.referenceLines?.length) {\n for (let i = 0; i < data.referenceLines.length; i++) {\n const ref = data.referenceLines[i];\n out.push({\n id: `${id}-ref-${i}`,\n type: \"line\",\n visible,\n data: {\n x: Float32Array.from([x[0], x[n - 1]]),\n y: Float32Array.from([ref.y, ref.y]),\n },\n style: {\n color: ref.color ?? \"rgba(255,255,255,0.2)\",\n width: ref.width ?? 1,\n lineDash: ref.dash ?? [2, 4],\n opacity: 0.8,\n },\n });\n }\n }\n\n if (data.markers?.length) {\n const peaks = data.markers.filter((m) => m.kind === \"peak\");\n const troughs = data.markers.filter((m) => m.kind === \"trough\");\n\n if (peaks.length) {\n out.push({\n id: `${id}-peaks`,\n type: \"scatter\",\n visible,\n data: {\n x: Float32Array.from(peaks.map((m) => m.x)),\n y: Float32Array.from(peaks.map((m) => m.y)),\n },\n style: {\n color: merged.peakColor,\n pointSize: merged.peakSize,\n opacity: 1,\n },\n });\n }\n if (troughs.length) {\n out.push({\n id: `${id}-troughs`,\n type: \"scatter\",\n visible,\n data: {\n x: Float32Array.from(troughs.map((m) => m.x)),\n y: Float32Array.from(troughs.map((m) => m.y)),\n },\n style: {\n color: merged.troughColor,\n pointSize: merged.troughSize,\n opacity: 1,\n },\n });\n }\n }\n\n return out;\n}\n\n/** Convenience: one call returns all series for chart.addSeries / stacked pane config. */\nexport function createIndicatorSeries(options: IndicatorSeriesOptions): SeriesOptions[] {\n return buildIndicatorSeries(options);\n}\n\n/**\n * Detect local extrema on a line for peak/trough markers.\n */\nexport function detectIndicatorMarkers(\n x: Float32Array | Float64Array | number[],\n y: Float32Array | Float64Array | number[],\n window = 3,\n): import(\"./types\").IndicatorMarker[] {\n const xArr = toF32(x);\n const yArr = toF32(y);\n const markers: import(\"./types\").IndicatorMarker[] = [];\n const w = Math.max(1, window);\n\n for (let i = w; i < yArr.length - w; i++) {\n let isPeak = true;\n let isTrough = true;\n for (let j = i - w; j <= i + w; j++) {\n if (j === i) continue;\n if (yArr[j] >= yArr[i]) isPeak = false;\n if (yArr[j] <= yArr[i]) isTrough = false;\n }\n if (isPeak) markers.push({ x: xArr[i], y: yArr[i], kind: \"peak\" });\n else if (isTrough) markers.push({ x: xArr[i], y: yArr[i], kind: \"trough\" });\n }\n return markers;\n}\n","import type { Series } from \"../../../../Series\";\nimport { seriesId } from \"../seriesUtils\";\nimport type { Scale } from \"../../../../../scales\";\nimport type { PlotArea } from \"../../../../../types\";\nimport type { SVGDocumentBuilder } from \"../SVGDocumentBuilder\";\nimport { buildIndicatorSeries } from \"../../../../indicator/buildIndicatorSeries\";\nimport type { IndicatorSeriesOptions } from \"../../../../indicator/types\";\nimport { exportLineSeries } from \"./line\";\nimport { exportBarSeries } from \"./bar\";\nimport { exportBandSeries } from \"./band\";\nimport { exportScatterSeries } from \"./scatter\";\n\nexport function exportIndicatorSeries(\n series: Series,\n plotArea: PlotArea,\n xScale: Scale,\n yScale: Scale,\n builder: SVGDocumentBuilder,\n): void {\n const indicatorOpts = (series as unknown as { indicatorOptions?: IndicatorSeriesOptions }).indicatorOptions;\n if (!indicatorOpts) {\n console.warn(`[VeloPlot] Indicator series \"${seriesId(series)}\" missing indicatorOptions for SVG export`);\n return;\n }\n\n const childOptions = buildIndicatorSeries(indicatorOpts);\n for (const child of childOptions) {\n const mockSeries = {\n isVisible: () => true,\n getYAxisId: () => series.getYAxisId(),\n getData: () => child.data ?? { x: new Float32Array(0), y: new Float32Array(0) },\n getStyle: () => child.style ?? {},\n getType: () => child.type ?? \"line\",\n getId: () => `${seriesId(series)}-${child.id ?? child.type}`,\n getName: () => child.name ?? child.id ?? \"indicator\",\n hasErrorData: () => false,\n } as unknown as Series;\n\n const type = child.type ?? \"line\";\n if (type === \"bar\") exportBarSeries(mockSeries, plotArea, xScale, yScale, builder);\n else if (type === \"band\" || type === \"area\") exportBandSeries(mockSeries, plotArea, xScale, yScale, builder);\n else if (type === \"scatter\") exportScatterSeries(mockSeries, plotArea, xScale, yScale, builder);\n else exportLineSeries(mockSeries, plotArea, xScale, yScale, builder);\n }\n}\n","import type { SeriesType } from \"../../../../../types\";\nimport type { Series } from \"../../../../Series\";\nimport type { Scale } from \"../../../../../scales\";\nimport type { PlotArea } from \"../../../../../types\";\nimport type { SVGDocumentBuilder } from \"../SVGDocumentBuilder\";\nimport type { SVGExportContext } from \"../SVGExportContext\";\nimport { exportLineSeries } from \"./line\";\nimport { exportScatterSeries } from \"./scatter\";\nimport { exportBarSeries } from \"./bar\";\nimport { exportBandSeries } from \"./band\";\nimport { exportCandlestickSeries } from \"./candlestick\";\nimport { exportHeatmapSeries } from \"./heatmap\";\nimport { exportPolarSeries } from \"./polar\";\nimport { exportGaugeSeries } from \"./gauge\";\nimport { exportSankeySeries } from \"./sankey\";\nimport { exportTernarySeries } from \"./ternary\";\nimport { exportWaterfallSeries } from \"./waterfall\";\nimport { exportBoxplotSeries } from \"./boxplot\";\nimport { exportIndicatorSeries } from \"./indicator\";\nimport { resolveYScale } from \"../tickUtils\";\n\nexport type SeriesSVGExporter = (\n series: Series,\n plotArea: PlotArea,\n xScale: Scale,\n yScale: Scale,\n builder: SVGDocumentBuilder,\n ctx?: SVGExportContext,\n) => void;\n\nconst registry = new Map<SeriesType, SeriesSVGExporter>();\n\nfunction register(type: SeriesType, exporter: SeriesSVGExporter): void {\n registry.set(type, exporter);\n}\n\nregister(\"line\", (s, pa, xs, ys, b) => exportLineSeries(s, pa, xs, ys, b));\nregister(\"step\", (s, pa, xs, ys, b) => exportLineSeries(s, pa, xs, ys, b));\nregister(\"step+scatter\", (s, pa, xs, ys, b) => exportLineSeries(s, pa, xs, ys, b));\nregister(\"line+scatter\", (s, pa, xs, ys, b) => exportLineSeries(s, pa, xs, ys, b));\nregister(\"scatter\", (s, pa, xs, ys, b) => exportScatterSeries(s, pa, xs, ys, b));\nregister(\"bar\", (s, pa, xs, ys, b) => exportBarSeries(s, pa, xs, ys, b));\nregister(\"band\", (s, pa, xs, ys, b) => exportBandSeries(s, pa, xs, ys, b));\nregister(\"area\", (s, pa, xs, ys, b) => exportBandSeries(s, pa, xs, ys, b));\nregister(\"candlestick\", (s, pa, xs, ys, b) => exportCandlestickSeries(s, pa, xs, ys, b));\nregister(\"heikin-ashi\", (s, pa, xs, ys, b) => exportCandlestickSeries(s, pa, xs, ys, b));\nregister(\"heatmap\", (s, pa, xs, ys, b) => exportHeatmapSeries(s, pa, xs, ys, b));\nregister(\"polar\", (s, pa, xs, ys, b) => exportPolarSeries(s, pa, xs, ys, b));\nregister(\"gauge\", (s, pa, _xs, _ys, b) => exportGaugeSeries(s, pa, b));\nregister(\"sankey\", (s, pa, _xs, _ys, b) => exportSankeySeries(s, pa, b));\nregister(\"ternary\", (s, pa, xs, ys, b) => exportTernarySeries(s, pa, xs, ys, b));\nregister(\"waterfall\", (s, pa, xs, ys, b) => exportWaterfallSeries(s, pa, xs, ys, b));\nregister(\"boxplot\", (s, pa, xs, ys, b) => exportBoxplotSeries(s, pa, xs, ys, b));\nregister(\"indicator\", (s, pa, xs, ys, b) => exportIndicatorSeries(s, pa, xs, ys, b));\nregister(\"radar\", () => {\n /* rendered via PluginRadar SVG exporter */\n});\n\nexport function getSeriesSVGExporter(type: SeriesType): SeriesSVGExporter | undefined {\n return registry.get(type);\n}\n\nexport function exportAllSeries(ctx: SVGExportContext, builder: SVGDocumentBuilder): void {\n const warned = new Set<string>();\n\n for (const series of ctx.series) {\n if (!series.isVisible()) continue;\n\n const type = series.getType();\n const exporter = registry.get(type);\n const yScale = resolveYScale(ctx.yAxes, series.getYAxisId(), ctx.primaryYAxisId);\n if (!yScale) continue;\n\n if (!exporter) {\n if (!warned.has(type)) {\n console.warn(`[VeloPlot] No SVG exporter for series type \"${type}\"`);\n warned.add(type);\n }\n continue;\n }\n\n const data = series.getData();\n const isEmpty =\n type === \"heatmap\"\n ? !series.getHeatmapData?.()\n : type === \"polar\"\n ? !series.getPolarData?.()\n : type === \"gauge\"\n ? !series.getGaugeData?.()\n : type === \"sankey\"\n ? !series.getSankeyData?.()\n : type === \"indicator\"\n ? false\n : !data || data.x.length === 0;\n\n if (isEmpty && type !== \"gauge\" && type !== \"indicator\") continue;\n\n exporter(series, ctx.plotArea, ctx.xScale, yScale, builder, ctx);\n }\n}\n\nexport function getRegisteredSeriesTypes(): SeriesType[] {\n return Array.from(registry.keys());\n}\n","import type { Annotation } from \"../../../../annotations/types\";\nimport type { SVGExportPluginContext } from \"./types\";\nimport type { SVGDocumentBuilder } from \"../SVGDocumentBuilder\";\nimport { escapeXml, fmt } from \"../SVGDocumentBuilder\";\nimport { primaryYScale } from \"../tickUtils\";\n\nconst arrowMarkers = new WeakMap<SVGDocumentBuilder, Map<string, string>>();\n\nfunction arrowMarkerId(builder: SVGDocumentBuilder, color: string): string {\n let map = arrowMarkers.get(builder);\n if (!map) {\n map = new Map();\n arrowMarkers.set(builder, map);\n }\n let id = map.get(color);\n if (!id) {\n id = `vp-arrow-${map.size}`;\n builder.registerArrowMarker(id, color);\n map.set(color, id);\n }\n return id;\n}\n\nfunction dataToPixel(\n ctx: SVGExportPluginContext,\n x: number,\n y: number,\n yAxisId?: string,\n): { px: number; py: number } {\n const yScale =\n (yAxisId && ctx.yScales.get(yAxisId)) || primaryYScale(ctx.yScales) || [...ctx.yScales.values()][0];\n if (!yScale) return { px: 0, py: 0 };\n return { px: ctx.xScale.transform(x), py: yScale.transform(y) };\n}\n\nexport function exportAnnotationToSVG(annotation: Annotation, ctx: SVGExportPluginContext): string[] {\n if (annotation.visible === false) return [];\n const { plotArea } = ctx;\n const elements: string[] = [];\n const clipId = \"vp-clip-ann\";\n const clip = `clip-path=\"url(#${clipId})\"`;\n\n switch (annotation.type) {\n case \"horizontal-line\": {\n const y = dataToPixel(ctx, 0, annotation.y).py;\n const x0 = ctx.xScale.transform(annotation.xMin ?? ctx.viewBounds.xMin);\n const x1 = ctx.xScale.transform(annotation.xMax ?? ctx.viewBounds.xMax);\n const color = annotation.color ?? \"#ff0055\";\n const dash = annotation.lineDash?.length ? ` stroke-dasharray=\"${annotation.lineDash.join(\",\")}\"` : \"\";\n elements.push(\n `<line x1=\"${fmt(x0)}\" y1=\"${fmt(y)}\" x2=\"${fmt(x1)}\" y2=\"${fmt(y)}\" stroke=\"${color}\" stroke-width=\"${annotation.lineWidth ?? 1}\"${dash}/>`,\n );\n if (annotation.label) {\n const lx = annotation.labelPosition === \"right\" ? x1 - 4 : annotation.labelPosition === \"left\" ? x0 + 4 : (x0 + x1) / 2;\n elements.push(\n `<text x=\"${fmt(lx)}\" y=\"${fmt(y - 4)}\" fill=\"${color}\" font-size=\"11\" text-anchor=\"${annotation.labelPosition === \"right\" ? \"end\" : annotation.labelPosition === \"left\" ? \"start\" : \"middle\"}\">${escapeXml(annotation.label)}</text>`,\n );\n }\n break;\n }\n case \"vertical-line\": {\n const x = dataToPixel(ctx, annotation.x, 0).px;\n const y0 = ctx.yScales.values().next().value!.transform(annotation.yMin ?? ctx.viewBounds.yMin);\n const y1 = ctx.yScales.values().next().value!.transform(annotation.yMax ?? ctx.viewBounds.yMax);\n const color = annotation.color ?? \"#ff0055\";\n elements.push(\n `<line x1=\"${fmt(x)}\" y1=\"${fmt(Math.min(y0, y1))}\" x2=\"${fmt(x)}\" y2=\"${fmt(Math.max(y0, y1))}\" stroke=\"${color}\" stroke-width=\"${annotation.lineWidth ?? 1}\"/>`,\n );\n break;\n }\n case \"rectangle\": {\n const p0 = dataToPixel(ctx, annotation.xMin, annotation.yMax);\n const p1 = dataToPixel(ctx, annotation.xMax, annotation.yMin);\n const x = Math.min(p0.px, p1.px);\n const y = Math.min(p0.py, p1.py);\n const w = Math.abs(p1.px - p0.px);\n const h = Math.abs(p1.py - p0.py);\n elements.push(\n `<rect x=\"${fmt(x)}\" y=\"${fmt(y)}\" width=\"${fmt(w)}\" height=\"${fmt(h)}\" fill=\"${annotation.fillColor ?? \"rgba(100,149,237,0.2)\"}\" stroke=\"${annotation.strokeColor ?? \"#6495ed\"}\" stroke-width=\"${annotation.strokeWidth ?? 1}\"/>`,\n );\n break;\n }\n case \"band\": {\n const yMin = annotation.yMin ?? ctx.viewBounds.yMin;\n const yMax = annotation.yMax ?? ctx.viewBounds.yMax;\n const y0 = dataToPixel(ctx, 0, yMin).py;\n const y1 = dataToPixel(ctx, 0, yMax).py;\n const top = Math.min(y0, y1);\n const height = Math.abs(y1 - y0);\n elements.push(\n `<rect x=\"${fmt(plotArea.x)}\" y=\"${fmt(top)}\" width=\"${fmt(plotArea.width)}\" height=\"${fmt(height)}\" fill=\"${annotation.fillColor ?? \"rgba(100,149,237,0.15)\"}\"/>`,\n );\n break;\n }\n case \"text\": {\n const p = dataToPixel(ctx, annotation.x, annotation.y);\n const color = annotation.color ?? \"#fff\";\n const rotation = annotation.rotation ? ` transform=\"rotate(${annotation.rotation} ${fmt(p.px)} ${fmt(p.py)})\"` : \"\";\n elements.push(\n `<text x=\"${fmt(p.px)}\" y=\"${fmt(p.py)}\" fill=\"${color}\" font-size=\"${annotation.fontSize ?? 12}\" font-family=\"${annotation.fontFamily ?? \"sans-serif\"}\" text-anchor=\"middle\"${rotation}>${escapeXml(annotation.text)}</text>`,\n );\n break;\n }\n case \"arrow\": {\n const from = dataToPixel(ctx, annotation.x1, annotation.y1);\n const to = dataToPixel(ctx, annotation.x2, annotation.y2);\n const color = annotation.color ?? \"#ff0055\";\n const markerId = ctx.builder ? arrowMarkerId(ctx.builder, color) : \"vp-arrow\";\n elements.push(\n `<line x1=\"${fmt(from.px)}\" y1=\"${fmt(from.py)}\" x2=\"${fmt(to.px)}\" y2=\"${fmt(to.py)}\" stroke=\"${color}\" stroke-width=\"${annotation.lineWidth ?? 2}\" marker-end=\"url(#${markerId})\"/>`,\n );\n break;\n }\n }\n\n return elements.map((el) => `<g ${clip}>${el}</g>`);\n}\n\nexport function exportAnnotations(ctx: SVGExportPluginContext, annotations: Annotation[]): void {\n if (!ctx.builder || !annotations.length) return;\n const { plotArea } = ctx;\n ctx.builder.registerClipPath(\n \"vp-clip-ann\",\n `<rect x=\"${fmt(plotArea.x)}\" y=\"${fmt(plotArea.y)}\" width=\"${fmt(plotArea.width)}\" height=\"${fmt(plotArea.height)}\"/>`,\n );\n\n const sorted = [...annotations].filter((a) => a.visible !== false).sort((a, b) => (a.zIndex ?? 0) - (b.zIndex ?? 0));\n for (const ann of sorted) {\n for (const el of exportAnnotationToSVG(ann, ctx)) {\n ctx.builder.push(\"plugins\", el);\n }\n }\n}\n","import type { SVGExportPluginContext } from \"./types\";\nimport { fmt } from \"../SVGDocumentBuilder\";\nimport { primaryYScale } from \"../tickUtils\";\n\nexport function exportCandlestickMarkers(ctx: SVGExportPluginContext): void {\n if (!ctx.builder) return;\n const yScale = primaryYScale(ctx.yScales);\n if (!yScale) return;\n\n for (const series of ctx.series) {\n if (!series.isVisible() || series.getType() !== \"candlestick\") continue;\n const markers = series.getMarkers?.() ?? [];\n const data = series.getData();\n if (!data?.x?.length) continue;\n\n for (const marker of markers) {\n let idx = 0;\n let bestDist = Infinity;\n for (let i = 0; i < data.x.length; i++) {\n const d = Math.abs(data.x[i] - marker.time);\n if (d < bestDist) {\n bestDist = d;\n idx = i;\n }\n }\n\n const px = ctx.xScale.transform(data.x[idx]);\n const py = yScale.transform(data.high?.[idx] ?? data.y[idx]);\n const isBuy = marker.shape === \"arrowUp\" || marker.position === \"belowBar\";\n const color = marker.color ?? (isBuy ? \"#26a69a\" : \"#ef5350\");\n const y = isBuy ? py + 12 : py - 12;\n const points = isBuy\n ? `${fmt(px)},${fmt(y - 6)} ${fmt(px - 5)},${fmt(y + 4)} ${fmt(px + 5)},${fmt(y + 4)}`\n : `${fmt(px)},${fmt(y + 6)} ${fmt(px - 5)},${fmt(y - 4)} ${fmt(px + 5)},${fmt(y - 4)}`;\n ctx.builder.push(\"plugins\", `<polygon points=\"${points}\" fill=\"${color}\"/>`);\n }\n }\n}\n","import type { SVGExportContext } from \"../SVGExportContext\";\nimport type { SVGDocumentBuilder } from \"../SVGDocumentBuilder\";\nimport { fmt, escapeXml } from \"../SVGDocumentBuilder\";\nimport type { RadarSeriesData, RadarSVGExportData } from \"../../../../../plugins/radar/types\";\n\nfunction labelAnchor(angle: number): \"start\" | \"middle\" | \"end\" {\n if (Math.abs(Math.cos(angle)) < 0.1) return \"middle\";\n return Math.cos(angle) > 0 ? \"start\" : \"end\";\n}\n\nfunction labelBaseline(angle: number): \"auto\" | \"middle\" | \"hanging\" | \"alphabetic\" {\n if (Math.abs(Math.sin(angle)) < 0.1) return \"middle\";\n return Math.sin(angle) > 0 ? \"hanging\" : \"alphabetic\";\n}\n\nexport function exportRadarChart(\n ctx: SVGExportContext,\n builder: SVGDocumentBuilder,\n data: RadarSVGExportData,\n): void {\n const { plotArea } = ctx;\n const centerX = plotArea.x + plotArea.width / 2;\n const centerY = plotArea.y + plotArea.height / 2;\n const maxRadiusPixels = (Math.min(plotArea.width, plotArea.height) / 2) * 0.8;\n const numCategories = data.categories.length;\n if (numCategories === 0) return;\n\n const angleStep = (2 * Math.PI) / numCategories;\n const gridColor = data.gridStyle?.color ?? \"rgba(255, 255, 255, 0.1)\";\n const gridWidth = data.gridStyle?.width ?? 1;\n const gridDash = data.gridStyle?.lineDash?.length\n ? ` stroke-dasharray=\"${data.gridStyle.lineDash.join(\",\")}\"`\n : \"\";\n\n for (let level = 1; level <= data.gridLevels; level++) {\n const radius = (level / data.gridLevels) * maxRadiusPixels;\n const pts: string[] = [];\n for (let i = 0; i < numCategories; i++) {\n const angle = i * angleStep - Math.PI / 2;\n pts.push(`${fmt(centerX + radius * Math.cos(angle))},${fmt(centerY + radius * Math.sin(angle))}`);\n }\n builder.push(\n \"grid\",\n `<polygon points=\"${pts.join(\" \")}\" fill=\"none\" stroke=\"${gridColor}\" stroke-width=\"${gridWidth}\"${gridDash}/>`,\n );\n }\n\n for (let i = 0; i < numCategories; i++) {\n const angle = i * angleStep - Math.PI / 2;\n const px = centerX + maxRadiusPixels * Math.cos(angle);\n const py = centerY + maxRadiusPixels * Math.sin(angle);\n builder.push(\n \"grid\",\n `<line x1=\"${fmt(centerX)}\" y1=\"${fmt(centerY)}\" x2=\"${fmt(px)}\" y2=\"${fmt(py)}\" stroke=\"${gridColor}\" stroke-width=\"${gridWidth}\"/>`,\n );\n\n if (data.showLabels) {\n const labelRadius = maxRadiusPixels + 25;\n const lx = centerX + labelRadius * Math.cos(angle);\n const ly = centerY + labelRadius * Math.sin(angle);\n const labelColor = data.labelStyle?.color ?? \"#94a3b8\";\n const labelSize = data.labelStyle?.fontSize ?? 12;\n const labelFamily = data.labelStyle?.fontFamily ?? \"sans-serif\";\n builder.push(\n \"axes\",\n `<text x=\"${fmt(lx)}\" y=\"${fmt(ly)}\" fill=\"${labelColor}\" font-size=\"${labelSize}\" font-family=\"${escapeXml(labelFamily)}\" text-anchor=\"${labelAnchor(angle)}\" dominant-baseline=\"${labelBaseline(angle)}\">${escapeXml(data.categories[i])}</text>`,\n );\n }\n }\n\n for (const series of data.series) {\n exportRadarSeries(builder, data, series, centerX, centerY, maxRadiusPixels, angleStep);\n }\n}\n\nfunction exportRadarSeries(\n builder: SVGDocumentBuilder,\n data: RadarSVGExportData,\n series: RadarSeriesData,\n centerX: number,\n centerY: number,\n maxRadiusPixels: number,\n angleStep: number,\n): void {\n if (series.points.length === 0) return;\n\n const dataPts: string[] = [];\n for (let idx = 0; idx < data.categories.length; idx++) {\n const cat = data.categories[idx];\n const point = series.points.find((p) => p.category === cat);\n const val = point ? point.value : 0;\n const radius = (val / data.maxValue) * maxRadiusPixels;\n const angle = idx * angleStep - Math.PI / 2;\n dataPts.push(`${fmt(centerX + radius * Math.cos(angle))},${fmt(centerY + radius * Math.sin(angle))}`);\n }\n\n const color = series.style?.color ?? \"#00f2ff\";\n const fillColor =\n series.style?.fillColor ?? (series.style?.color ? `${series.style.color}33` : \"rgba(0, 242, 255, 0.2)\");\n const opacity = series.style?.opacity ?? 1;\n const width = series.style?.width ?? 2;\n const pointSize = series.style?.pointSize ?? 0;\n\n builder.push(\n \"series\",\n `<polygon points=\"${dataPts.join(\" \")}\" fill=\"${fillColor}\" stroke=\"${color}\" stroke-width=\"${width}\" stroke-opacity=\"${opacity}\" fill-opacity=\"${opacity}\"/>`,\n );\n\n if (pointSize > 0) {\n const r = pointSize / 2;\n for (let idx = 0; idx < data.categories.length; idx++) {\n const cat = data.categories[idx];\n const point = series.points.find((p) => p.category === cat);\n const val = point ? point.value : 0;\n const radius = (val / data.maxValue) * maxRadiusPixels;\n const angle = idx * angleStep - Math.PI / 2;\n const px = centerX + radius * Math.cos(angle);\n const py = centerY + radius * Math.sin(angle);\n builder.push(\"series\", `<circle cx=\"${fmt(px)}\" cy=\"${fmt(py)}\" r=\"${fmt(r)}\" fill=\"${color}\"/>`);\n }\n }\n}\n","/**\n * Plugin SVG export context types.\n */\n\nimport type { Series } from \"../../../../Series\";\nimport type { Scale } from \"../../../../../scales\";\nimport type { ChartTheme } from \"../../../../../theme\";\nimport type { Bounds, PlotArea } from \"../../../../../types\";\nimport type { SVGDocumentBuilder } from \"../SVGDocumentBuilder\";\nimport type { SVGExportContext } from \"../SVGExportContext\";\n\nexport interface SVGExportPluginContext {\n series: Series[];\n viewBounds: Bounds;\n plotArea: PlotArea;\n xScale: Scale;\n yScales: Map<string, Scale>;\n theme: ChartTheme;\n width: number;\n height: number;\n builder?: SVGDocumentBuilder;\n exportContext?: SVGExportContext;\n pushElements?: (layer: string, elements: string[]) => void;\n /** @internal */\n _layer?: string;\n /** @internal */\n _elements?: string[];\n}\n\nexport type SVGPluginExporter = (ctx: SVGExportPluginContext) => void;\n\nconst pluginExporters = new Map<string, SVGPluginExporter>();\n\nexport function registerSVGPluginExporter(pluginName: string, exporter: SVGPluginExporter): void {\n pluginExporters.set(pluginName, exporter);\n}\n\nexport function getSVGPluginExporters(): Map<string, SVGPluginExporter> {\n return pluginExporters;\n}\n\nexport function runSVGPluginExporters(ctx: SVGExportPluginContext, builder: SVGDocumentBuilder): void {\n for (const [, exporter] of pluginExporters) {\n exporter({ ...ctx, builder });\n }\n if (ctx._elements && ctx._layer) {\n for (const el of ctx._elements) {\n builder.push(ctx._layer, el);\n }\n }\n}\n","/**\n * Registers built-in SVG plugin exporters and collects plugin overlay data at export time.\n */\nimport type { ChartPlugin } from \"../../../../../plugins/types\";\nimport type { Annotation } from \"../../../../annotations/types\";\nimport { exportAnnotations } from \"./annotations\";\nimport { exportCandlestickMarkers } from \"./tradeMarkers\";\nimport { exportRadarChart } from \"../series/radar\";\nimport type { SVGExportPluginContext } from \"./types\";\nimport { registerSVGPluginExporter, runSVGPluginExporters } from \"./types\";\n\nregisterSVGPluginExporter(\"velo-plot-annotations\", (ctx) => {\n const annotations = (ctx as SVGExportPluginContext & { _annotations?: Annotation[] })._annotations;\n if (annotations?.length) exportAnnotations(ctx, annotations);\n});\n\nregisterSVGPluginExporter(\"velo-plot-trade-markers\", exportCandlestickMarkers);\n\n/** Collect plugin overlay data from chart plugin manager during export. */\nexport function collectPluginSVGData(\n pluginManager: {\n get: (name: string) => ChartPlugin | undefined;\n notifyExportSVG?: (ctx: SVGExportPluginContext) => void;\n },\n ctx: SVGExportPluginContext,\n): void {\n const annPlugin = pluginManager.get(\"velo-plot-annotations\") as\n | { api?: { getManager?: () => { getAll: () => Annotation[] } } }\n | undefined;\n const manager = annPlugin?.api?.getManager?.();\n if (manager && ctx.builder && ctx.exportContext?.options.includeAnnotations !== false) {\n exportAnnotations(ctx, manager.getAll());\n }\n\n exportCandlestickMarkers(ctx);\n\n const radarPlugin = pluginManager.get(\"velo-plot-radar\") as\n | {\n api?: {\n getSVGExportData?: () => import(\"../../../../../plugins/radar/types\").RadarSVGExportData | null;\n };\n }\n | undefined;\n const radarData = radarPlugin?.api?.getSVGExportData?.();\n if (radarData && ctx.builder && ctx.exportContext) {\n exportRadarChart(ctx.exportContext, ctx.builder, radarData);\n }\n\n runSVGPluginExporters(ctx, ctx.builder!);\n pluginManager.notifyExportSVG?.(ctx);\n}\n","import type { SVGExportPluginContext } from \"./types\";\nimport { escapeXml, fmt } from \"../SVGDocumentBuilder\";\n\nexport function exportWatermark(\n ctx: SVGExportPluginContext,\n text: string,\n options?: { opacity?: number; rotation?: number; color?: string },\n): void {\n if (!ctx.builder) return;\n const cx = ctx.plotArea.x + ctx.plotArea.width / 2;\n const cy = ctx.plotArea.y + ctx.plotArea.height / 2;\n const opacity = options?.opacity ?? 0.12;\n const rotation = options?.rotation ?? -30;\n const color = options?.color ?? \"#ffffff\";\n ctx.builder.push(\n \"plugins\",\n `<text x=\"${fmt(cx)}\" y=\"${fmt(cy)}\" fill=\"${color}\" fill-opacity=\"${opacity}\" font-size=\"48\" font-weight=\"700\" text-anchor=\"middle\" transform=\"rotate(${rotation} ${fmt(cx)} ${fmt(cy)})\">${escapeXml(text)}</text>`,\n );\n}\n\nexport function exportGridHighlight(\n ctx: SVGExportPluginContext,\n bands: Array<{ axis: \"x\" | \"y\"; min: number; max: number; color?: string }>,\n): void {\n if (!ctx.builder) return;\n const { plotArea } = ctx;\n const yScale = ctx.yScales.values().next().value;\n\n for (const band of bands) {\n const color = band.color ?? \"rgba(59,130,246,0.1)\";\n if (band.axis === \"x\") {\n const x0 = ctx.xScale.transform(band.min);\n const x1 = ctx.xScale.transform(band.max);\n ctx.builder.push(\n \"plugins\",\n `<rect x=\"${fmt(Math.min(x0, x1))}\" y=\"${fmt(plotArea.y)}\" width=\"${fmt(Math.abs(x1 - x0))}\" height=\"${fmt(plotArea.height)}\" fill=\"${color}\"/>`,\n );\n } else if (yScale) {\n const y0 = yScale.transform(band.min);\n const y1 = yScale.transform(band.max);\n ctx.builder.push(\n \"plugins\",\n `<rect x=\"${fmt(plotArea.x)}\" y=\"${fmt(Math.min(y0, y1))}\" width=\"${fmt(plotArea.width)}\" height=\"${fmt(Math.abs(y1 - y0))}\" fill=\"${color}\"/>`,\n );\n }\n }\n}\n","import type { SVGExportContext } from \"./SVGExportContext\";\nimport { SVGDocumentBuilder } from \"./SVGDocumentBuilder\";\nimport { exportAllOverlays } from \"./overlay\";\nimport { exportAllSeries } from \"./series/registry\";\nimport { collectPluginSVGData } from \"./plugins/register\";\nimport { exportWatermark } from \"./plugins/watermark\";\nimport \"./plugins/register\";\n\nexport function renderSVG(ctx: SVGExportContext): string {\n const builder = new SVGDocumentBuilder(\n ctx.width,\n ctx.height,\n ctx.theme.xAxis.fontFamily || \"sans-serif\",\n );\n builder.resetGradientCounter();\n\n exportAllOverlays(ctx, builder);\n exportAllSeries(ctx, builder);\n\n if (ctx.options.includeOverlays !== false) {\n const pluginCtx = {\n series: ctx.series,\n viewBounds: ctx.viewBounds,\n plotArea: ctx.plotArea,\n xScale: ctx.xScale,\n yScales: ctx.yAxes,\n theme: ctx.theme,\n width: ctx.width,\n height: ctx.height,\n builder,\n exportContext: ctx,\n };\n if (ctx.pluginManager) {\n collectPluginSVGData(ctx.pluginManager, pluginCtx);\n }\n if (ctx.options.watermarkText) {\n exportWatermark(pluginCtx, ctx.options.watermarkText, { opacity: 0.4, rotation: 0, color: \"rgba(128,128,128,0.4)\" });\n }\n }\n\n return builder.build(ctx.theme.backgroundColor, ctx.options.ariaLabel);\n}\n","import type { Range, SeriesOptions } from \"../../types\";\nimport type { StackedPaneConfig } from \"../stacked/types\";\nimport type { IndicatorData, IndicatorSeriesOptions, IndicatorStyle } from \"./types\";\nimport { buildIndicatorSeries } from \"./buildIndicatorSeries\";\n\nexport interface BuildIndicatorPaneOptions {\n id: string;\n /** Flex ratio inside createStackedChart (default 0.25) */\n height?: number | string;\n label?: string;\n data: IndicatorData;\n style?: IndicatorStyle;\n /** Lock Y range (recommended for oscillators) */\n yRange?: Range | \"auto\";\n tickCount?: number;\n showXAxis?: boolean;\n seriesId?: string;\n}\n\n/**\n * Build a stacked pane pre-configured for a trading indicator\n * (histogram + lines + fills + markers).\n */\nexport function buildIndicatorPane(options: BuildIndicatorPaneOptions): StackedPaneConfig {\n const seriesId = options.seriesId ?? `${options.id}-indicator`;\n const indicatorOpts: IndicatorSeriesOptions = {\n id: seriesId,\n type: \"indicator\",\n data: options.data,\n style: options.style,\n name: options.label,\n };\n const series: SeriesOptions[] = buildIndicatorSeries(indicatorOpts);\n\n return {\n id: options.id,\n height: options.height ?? 0.25,\n showXAxis: options.showXAxis,\n yRange: options.yRange,\n chart: {\n yAxis: {\n label: options.label ?? \"Indicator\",\n auto: options.yRange === undefined || options.yRange === \"auto\",\n tickCount: options.tickCount ?? 5,\n scientific: false,\n },\n // X-axis visibility is owned by createStackedChart (sharedXAxis / showXAxis).\n // Do not force labels off here — the new bottom pane must show dates.\n animations: false,\n loading: false,\n showLegend: false,\n },\n series,\n };\n}\n","/**\n * Async indicator API backed by a shared worker pool.\n * Falls back to synchronous calculation when Workers are unavailable.\n * @module workers/indicatorsAsync\n */\n\nimport type { IndicatorResult } from \"../plugins/analysis/indicators\";\nimport { rsi, macd, bollingerBands, sma, ema } from \"../plugins/analysis/indicators\";\nimport { WorkerPool, nextTaskId } from \"./pool\";\n\ntype IndicatorName = \"rsi\" | \"macd\" | \"bollingerBands\" | \"sma\" | \"ema\";\n\ninterface IndicatorTaskPayload {\n id: string;\n type: \"indicator\";\n indicator: IndicatorName;\n data: Float32Array | Float64Array;\n period?: number;\n fastPeriod?: number;\n slowPeriod?: number;\n signalPeriod?: number;\n stdDev?: number;\n}\n\ninterface IndicatorTaskResult extends IndicatorResult {\n id: string;\n type: \"indicator-result\";\n indicator: string;\n duration: number;\n}\n\n/**\n * Below this point count, always compute on the main thread.\n * Trading demos (~100 bars) and typical charts stay instant — workers only help\n * for very large series, and VitePress often never answers worker messages.\n */\nconst SYNC_THRESHOLD = 5_000;\n\nlet pool: WorkerPool<IndicatorTaskPayload, IndicatorTaskResult> | null = null;\n/** After a silent-worker timeout, skip the pool for the rest of the session. */\nlet preferSync = false;\n\n/**\n * Synchronous indicator computation shared by the sync fallback path.\n * Exported so the parameter defaults and dispatch can be unit-tested directly.\n */\nexport function computeIndicatorSync(task: IndicatorTaskPayload): IndicatorTaskResult {\n const start = performance.now();\n switch (task.indicator) {\n case \"rsi\":\n return {\n id: task.id,\n type: \"indicator-result\",\n indicator: \"rsi\",\n values: rsi(task.data, task.period ?? 14),\n duration: performance.now() - start,\n };\n case \"sma\":\n return {\n id: task.id,\n type: \"indicator-result\",\n indicator: \"sma\",\n values: sma(task.data, task.period ?? 14),\n duration: performance.now() - start,\n };\n case \"ema\":\n return {\n id: task.id,\n type: \"indicator-result\",\n indicator: \"ema\",\n values: ema(task.data, task.period ?? 14),\n duration: performance.now() - start,\n };\n case \"macd\": {\n const result = macd(\n task.data,\n task.fastPeriod ?? 12,\n task.slowPeriod ?? 26,\n task.signalPeriod ?? 9,\n );\n return {\n id: task.id,\n type: \"indicator-result\",\n indicator: \"macd\",\n ...result,\n duration: performance.now() - start,\n };\n }\n case \"bollingerBands\": {\n const result = bollingerBands(task.data, task.period ?? 20, task.stdDev ?? 2);\n return {\n id: task.id,\n type: \"indicator-result\",\n indicator: \"bollingerBands\",\n ...result,\n duration: performance.now() - start,\n };\n }\n default:\n throw new Error(`Unknown indicator: ${task.indicator}`);\n }\n}\n\nfunction getPool(): WorkerPool<IndicatorTaskPayload, IndicatorTaskResult> {\n if (!pool) {\n pool = new WorkerPool<IndicatorTaskPayload, IndicatorTaskResult>(\n () => new Worker(new URL(\"./indicator.worker.ts\", import.meta.url), { type: \"module\" }),\n {\n poolSize: 2,\n syncFallback: true,\n // Short timeout — if the worker is silent (broken Vite URL), don't stall UI.\n timeoutMs: 250,\n syncHandler: computeIndicatorSync,\n },\n );\n }\n return pool;\n}\n\nfunction toTypedArray(data: Float32Array | Float64Array | number[]): Float32Array | Float64Array {\n if (data instanceof Float32Array || data instanceof Float64Array) return data;\n return Float32Array.from(data);\n}\n\nfunction toPublicResult(\n result: IndicatorResult & { duration: number },\n): IndicatorResult & { duration: number } {\n return {\n values: result.values,\n signal: result.signal,\n upper: result.upper,\n lower: result.lower,\n histogram: result.histogram,\n duration: result.duration,\n };\n}\n\nasync function runIndicator(\n task: Omit<IndicatorTaskPayload, \"id\" | \"type\">,\n): Promise<IndicatorResult & { duration: number }> {\n const id = nextTaskId(task.indicator);\n const fullTask: IndicatorTaskPayload = { id, type: \"indicator\", ...task };\n\n // Small series: sync is microseconds — avoid worker round-trip / docs hang.\n if (preferSync || task.data.length < SYNC_THRESHOLD) {\n return toPublicResult(computeIndicatorSync(fullTask));\n }\n\n const started = performance.now();\n const result = await getPool().run(fullTask);\n // Worker answered after our soft timeout window → it was silent; prefer sync next time.\n if (performance.now() - started >= 200) {\n preferSync = true;\n }\n return toPublicResult(result);\n}\n\n/** Async RSI — non-blocking for large datasets */\nexport async function rsiAsync(\n data: Float32Array | Float64Array | number[],\n period = 14,\n): Promise<IndicatorResult & { duration: number }> {\n return runIndicator({ indicator: \"rsi\", data: toTypedArray(data), period });\n}\n\n/** Async SMA */\nexport async function smaAsync(\n data: Float32Array | Float64Array | number[],\n period = 14,\n): Promise<IndicatorResult & { duration: number }> {\n return runIndicator({ indicator: \"sma\", data: toTypedArray(data), period });\n}\n\n/** Async EMA */\nexport async function emaAsync(\n data: Float32Array | Float64Array | number[],\n period = 14,\n): Promise<IndicatorResult & { duration: number }> {\n return runIndicator({ indicator: \"ema\", data: toTypedArray(data), period });\n}\n\n/** Async MACD */\nexport async function macdAsync(\n data: Float32Array | Float64Array | number[],\n fastPeriod = 12,\n slowPeriod = 26,\n signalPeriod = 9,\n): Promise<IndicatorResult & { duration: number }> {\n return runIndicator({\n indicator: \"macd\",\n data: toTypedArray(data),\n fastPeriod,\n slowPeriod,\n signalPeriod,\n });\n}\n\n/** Async Bollinger Bands */\nexport async function bollingerBandsAsync(\n data: Float32Array | Float64Array | number[],\n period = 20,\n stdDev = 2,\n): Promise<IndicatorResult & { duration: number }> {\n return runIndicator({ indicator: \"bollingerBands\", data: toTypedArray(data), period, stdDev });\n}\n\n/** Destroy the shared indicator worker pool (for tests) */\nexport function destroyIndicatorPool(): void {\n pool?.destroy();\n pool = null;\n preferSync = false;\n}\n\n/** Exposed for tests */\nexport function getIndicatorPoolSize(): number {\n return getPool().size();\n}\n\n/** Exposed for tests */\nexport function isIndicatorPreferSync(): boolean {\n return preferSync;\n}\n","/**\n * Trading indicator presets — compute IndicatorData from OHLC/price series.\n * Stage 2: high-level indicator API (RSI, MACD, Bollinger, EMA, SMA).\n */\n\nimport type { IndicatorData } from \"./types\";\nimport {\n rsiAsync,\n macdAsync,\n bollingerBandsAsync,\n emaAsync,\n smaAsync,\n} from \"../../workers/indicatorsAsync\";\nimport { stochastic } from \"../../plugins/analysis/indicators\";\nimport type { Series } from \"../Series\";\n\nexport type IndicatorPresetName =\n | \"rsi\"\n | \"macd\"\n | \"bollinger\"\n | \"bollingerBands\"\n | \"ema\"\n | \"sma\"\n | \"stochastic\";\n\nexport interface IndicatorPresetOptions {\n period?: number;\n fastPeriod?: number;\n slowPeriod?: number;\n signalPeriod?: number;\n stdDev?: number;\n /** Root id for generated series (default: preset name) */\n id?: string;\n label?: string;\n}\n\nexport interface ComputedIndicatorPreset {\n id: string;\n preset: IndicatorPresetName;\n /** overlay = price chart bands/lines; oscillator = separate pane layers */\n placement: \"overlay\" | \"oscillator\";\n yRange?: [number, number];\n data: IndicatorData;\n}\n\nconst OVERLAY_PRESETS = new Set<IndicatorPresetName>([\n \"bollinger\",\n \"bollingerBands\",\n \"ema\",\n \"sma\",\n]);\n\nfunction normalizePreset(name: IndicatorPresetName): Exclude<IndicatorPresetName, \"bollingerBands\"> | \"bollinger\" {\n return name === \"bollingerBands\" ? \"bollinger\" : name;\n}\n\n/** Extract X and close/price array from a source series. */\nexport function extractPriceSeries(source: Series): {\n x: Float32Array | Float64Array;\n prices: Float32Array | Float64Array;\n} {\n const data = source.getData();\n const x = data.x;\n if (!x?.length) {\n throw new Error(\"[addIndicator] Source series has no X data\");\n }\n\n const type = source.getType();\n let prices: Float32Array | Float64Array | undefined;\n if (type === \"candlestick\") {\n prices = data.close ?? data.y;\n } else {\n prices = data.y;\n }\n\n if (!prices?.length) {\n throw new Error(\"[addIndicator] Source series has no price/Y data\");\n }\n return { x, prices };\n}\n\n/** Extract OHLC from candlestick series for stochastic and similar presets. */\nexport function extractOhlcSeries(source: Series): {\n x: Float32Array | Float64Array;\n open: Float32Array | Float64Array;\n high: Float32Array | Float64Array;\n low: Float32Array | Float64Array;\n close: Float32Array | Float64Array;\n} {\n const data = source.getData();\n const x = data.x;\n if (!x?.length) {\n throw new Error(\"[addIndicator] Source series has no X data\");\n }\n const open = data.open ?? data.y;\n const high = data.high ?? data.y;\n const low = data.low ?? data.y;\n const close = data.close ?? data.y;\n if (!open?.length || !high?.length || !low?.length || !close?.length) {\n throw new Error(\"[addIndicator] Source series has no OHLC data — use candlestick\");\n }\n return { x, open, high, low, close };\n}\n\n/** Resolve source series from chart API surface. */\nexport function resolveSourceSeries(\n chart: { getSeries(id: string): Series | undefined; getAllSeries(): Series[] },\n sourceSeriesId?: string,\n): Series {\n if (sourceSeriesId) {\n const s = chart.getSeries(sourceSeriesId);\n if (!s) throw new Error(`[addIndicator] Source series \"${sourceSeriesId}\" not found`);\n return s;\n }\n\n const all = chart.getAllSeries();\n const preferred = all.find((s) => {\n const t = s.getType();\n return t === \"candlestick\" || t === \"line\" || t === \"bar\";\n });\n if (!preferred) {\n throw new Error(\"[addIndicator] No line/candlestick/bar series found — pass sourceSeriesId\");\n }\n return preferred;\n}\n\n/**\n * Compute composite indicator layers for a preset (async worker path when available).\n */\nexport async function computeIndicatorPreset(\n preset: IndicatorPresetName,\n x: Float32Array | Float64Array,\n prices: Float32Array | Float64Array,\n options: IndicatorPresetOptions = {},\n source?: Series,\n): Promise<ComputedIndicatorPreset> {\n const kind = normalizePreset(preset);\n const id = options.id ?? kind;\n const xArr = x instanceof Float32Array || x instanceof Float64Array ? x : Float32Array.from(x);\n\n switch (kind) {\n case \"rsi\": {\n const period = options.period ?? 14;\n const { values } = await rsiAsync(prices, period);\n return {\n id,\n preset: \"rsi\",\n placement: \"oscillator\",\n yRange: [0, 100],\n data: {\n x: xArr,\n lines: [{ id: \"rsi\", y: values, color: \"#ab47bc\", width: 1.5 }],\n referenceLines: [\n { y: 70, color: \"rgba(239, 83, 80, 0.5)\", dash: [4, 4] },\n { y: 30, color: \"rgba(38, 166, 154, 0.5)\", dash: [4, 4] },\n ],\n },\n };\n }\n\n case \"macd\": {\n const fast = options.fastPeriod ?? 12;\n const slow = options.slowPeriod ?? 26;\n const signal = options.signalPeriod ?? 9;\n const result = await macdAsync(prices, fast, slow, signal);\n return {\n id,\n preset: \"macd\",\n placement: \"oscillator\",\n data: {\n x: xArr,\n histogram: {\n y: result.histogram ?? new Float32Array(prices.length),\n positiveColor: \"#26a69a\",\n negativeColor: \"#ef5350\",\n },\n lines: [\n { id: \"macd\", y: result.values, color: \"#42a5f5\", width: 1.5 },\n { id: \"signal\", y: result.signal ?? result.values, color: \"#ff9800\", width: 1 },\n ],\n baseline: 0,\n },\n };\n }\n\n case \"bollinger\": {\n const period = options.period ?? 20;\n const stdDev = options.stdDev ?? 2;\n const result = await bollingerBandsAsync(prices, period, stdDev);\n const upper = result.upper ?? result.values;\n const lower = result.lower ?? result.values;\n return {\n id,\n preset: \"bollinger\",\n placement: \"overlay\",\n data: {\n x: xArr,\n lines: [{ id: \"mid\", y: result.values, color: \"rgba(99, 102, 241, 0.9)\", width: 1 }],\n fills: [\n {\n id: \"band\",\n upper,\n lower,\n color: \"rgba(99, 102, 241, 0.15)\",\n },\n ],\n },\n };\n }\n\n case \"ema\": {\n const period = options.period ?? 14;\n const { values } = await emaAsync(prices, period);\n return {\n id,\n preset: \"ema\",\n placement: \"overlay\",\n data: {\n x: xArr,\n lines: [{ id: \"ema\", y: values, color: \"#ffd54f\", width: 1.5 }],\n },\n };\n }\n\n case \"sma\": {\n const period = options.period ?? 14;\n const { values } = await smaAsync(prices, period);\n return {\n id,\n preset: \"sma\",\n placement: \"overlay\",\n data: {\n x: xArr,\n lines: [{ id: \"sma\", y: values, color: \"#4fc3f7\", width: 1.5 }],\n },\n };\n }\n\n case \"stochastic\": {\n if (!source) {\n throw new Error(\"[addIndicator] stochastic requires a candlestick source series\");\n }\n const ohlc = extractOhlcSeries(source);\n const kPeriod = options.period ?? 14;\n const dPeriod = options.signalPeriod ?? 3;\n const result = stochastic(ohlc, kPeriod, dPeriod);\n return {\n id,\n preset: \"stochastic\",\n placement: \"oscillator\",\n yRange: [0, 100],\n data: {\n x: xArr,\n lines: [\n { id: \"k\", y: result.values, color: \"#42a5f5\", width: 1.5 },\n { id: \"d\", y: result.signal ?? result.values, color: \"#ff9800\", width: 1 },\n ],\n referenceLines: [\n { y: 80, color: \"rgba(239, 83, 80, 0.5)\", dash: [4, 4] },\n { y: 20, color: \"rgba(38, 166, 154, 0.5)\", dash: [4, 4] },\n ],\n },\n };\n }\n\n default:\n throw new Error(`[addIndicator] Unknown preset: ${preset}`);\n }\n}\n\nexport function isOverlayPreset(preset: IndicatorPresetName): boolean {\n return OVERLAY_PRESETS.has(preset) || preset === \"bollingerBands\";\n}\n","/**\n * High-level indicator API — calculate + render on a chart or stacked pane config.\n */\n\nimport type { Chart } from \"../chart/types\";\nimport type { StackedPaneConfig } from \"../stacked/types\";\nimport { buildIndicatorSeries } from \"./buildIndicatorSeries\";\nimport { buildIndicatorPane, type BuildIndicatorPaneOptions } from \"./buildIndicatorPane\";\nimport {\n computeIndicatorPreset,\n extractPriceSeries,\n resolveSourceSeries,\n type ComputedIndicatorPreset,\n type IndicatorPresetName,\n type IndicatorPresetOptions,\n} from \"./indicatorPresets\";\n\nexport interface AddIndicatorOptions extends IndicatorPresetOptions {\n /** Series to derive prices from (default: first line/candlestick/bar) */\n sourceSeriesId?: string;\n /** Y axis for overlay lines (default: same as source series) */\n yAxisId?: string;\n /** For stacked charts — build a new pane config instead of mutating chart */\n pane?: \"inline\" | \"new\";\n /** Pane flex ratio when pane: 'new' (default 0.25) */\n paneHeight?: number | string;\n showXAxis?: boolean;\n}\n\nexport interface AddIndicatorResult {\n id: string;\n preset: IndicatorPresetName;\n placement: \"overlay\" | \"oscillator\";\n seriesIds: string[];\n}\n\ntype ChartIndicatorHost = Pick<\n Chart,\n \"getSeries\" | \"getAllSeries\" | \"addSeries\" | \"removeSeries\"\n>;\n\nfunction removeIndicatorSeries(chart: ChartIndicatorHost, rootId: string): void {\n for (const s of [...chart.getAllSeries()]) {\n const sid = s.getId();\n if (sid === rootId || sid.startsWith(`${rootId}-`)) {\n chart.removeSeries(sid);\n }\n }\n}\n\n/**\n * Calculate indicator preset from a source series (no render).\n */\nexport async function computeIndicatorFromSeries(\n chart: ChartIndicatorHost,\n preset: IndicatorPresetName,\n options: AddIndicatorOptions = {},\n): Promise<ComputedIndicatorPreset> {\n const source = resolveSourceSeries(chart, options.sourceSeriesId);\n const { x, prices } = extractPriceSeries(source);\n return computeIndicatorPreset(preset, x, prices, options, source);\n}\n\n/**\n * Add a trading indicator to an existing chart (overlay or inline oscillator layers).\n */\nexport async function addIndicatorToChart(\n chart: ChartIndicatorHost,\n preset: IndicatorPresetName,\n options: AddIndicatorOptions = {},\n): Promise<AddIndicatorResult> {\n if (options.pane === \"new\") {\n throw new Error(\n \"[addIndicator] pane: 'new' requires createStackedChart — use buildIndicatorPaneFromPreset() instead\",\n );\n }\n\n const source = resolveSourceSeries(chart, options.sourceSeriesId);\n const yAxisId = options.yAxisId ?? source.getYAxisId?.();\n\n const computed = await computeIndicatorFromSeries(chart, preset, options);\n removeIndicatorSeries(chart, computed.id);\n\n const expanded = buildIndicatorSeries({\n id: computed.id,\n type: \"indicator\",\n data: computed.data,\n name: options.label ?? computed.id.toUpperCase(),\n });\n\n const seriesIds: string[] = [];\n for (const s of expanded) {\n chart.addSeries({\n ...s,\n yAxisId: yAxisId ?? s.yAxisId,\n });\n seriesIds.push(s.id);\n }\n\n return {\n id: computed.id,\n preset,\n placement: computed.placement,\n seriesIds,\n };\n}\n\n/**\n * Build a stacked pane config for an indicator (use when creating or extending stacks).\n */\nexport async function buildIndicatorPaneFromPreset(\n preset: IndicatorPresetName,\n x: Float32Array | Float64Array,\n prices: Float32Array | Float64Array,\n options: IndicatorPresetOptions &\n Pick<\n BuildIndicatorPaneOptions,\n \"id\" | \"height\" | \"label\" | \"yRange\" | \"tickCount\" | \"showXAxis\" | \"seriesId\" | \"style\"\n >,\n source?: import(\"../Series\").Series,\n): Promise<StackedPaneConfig> {\n const computed = await computeIndicatorPreset(preset, x, prices, options, source);\n return buildIndicatorPane({\n id: options.id ?? computed.id,\n height: options.height ?? 0.25,\n label: options.label ?? computed.id.toUpperCase(),\n yRange: options.yRange ?? computed.yRange ?? \"auto\",\n tickCount: options.tickCount,\n showXAxis: options.showXAxis,\n seriesId: options.seriesId,\n style: options.style,\n data: computed.data,\n });\n}\n\n// Re-export for convenience\nexport type { IndicatorPresetName, IndicatorPresetOptions, ComputedIndicatorPreset };\n","import type { Chart } from \"../chart/types\";\nimport type { ChartGroup } from \"../sync\";\nimport type { SyncAxis, SyncOptions } from \"../sync\";\nimport type { ChartOptions as RootChartOptions, Range, SeriesOptions } from \"../../types\";\nimport type { LayoutOptions } from \"../layout\";\nimport type { AddIndicatorResult } from \"../indicator/addIndicator\";\nimport type { SVGExportOptions } from \"../chart/exporter/SVGExporter\";\n\n/** Stack layout direction */\nexport type StackDirection = \"vertical\" | \"horizontal\";\n\n/** Per-pane configuration (max 5 panes per stack) */\nexport interface StackedPaneConfig {\n id: string;\n /** Flex ratio (e.g. 0.6) or CSS length (\"24%\", \"80px\") — height ratio when vertical, width ratio when horizontal */\n height: number | string;\n /** Chart options excluding container/id (series added via chart API or `series`) */\n chart?: Omit<RootChartOptions, \"container\" | \"id\">;\n /** Series to add immediately after pane chart is created */\n series?: SeriesOptions[];\n /** Show native X axis (default: only bottom pane when vertical + sharedXAxis; each pane when horizontal) */\n showXAxis?: boolean;\n /** Show native Y axis (default: only first pane when horizontal + sharedYAxis) */\n showYAxis?: boolean;\n /** Receive pan/zoom (default: true on every pane) */\n interactive?: boolean;\n /** Lock Y range — skips auto fit on Y for this pane */\n yRange?: Range | \"auto\";\n}\n\nexport interface StackedChartOptions {\n /** Root container (will be cleared and filled with pane layout) */\n container: HTMLDivElement;\n /** 1–5 stacked panes */\n panes: StackedPaneConfig[];\n /** Layout direction (default: vertical — panes top to bottom) */\n direction?: StackDirection;\n /** Pane that drives sync (default: first pane) */\n masterPaneId?: string;\n /** Shared date/time row on bottom pane only (vertical layout) */\n sharedXAxis?: \"bottom\" | \"none\";\n /** Shared Y axis on left pane only (horizontal layout) */\n sharedYAxis?: \"left\" | \"none\";\n /**\n * Shared X-axis defaults applied to every pane (e.g. `type: 'time'`, timeScale).\n * Per-pane `chart.xAxis` overrides these. Visibility (labels/ticks/line) is still\n * controlled by `sharedXAxis` / `showXAxis`.\n */\n xAxis?: Omit<NonNullable<RootChartOptions[\"xAxis\"]>, \"showLabels\" | \"showTicks\" | \"showLine\">;\n /** Shared theme applied to every pane */\n theme?: string | object;\n devicePixelRatio?: number;\n /** Gap between panes in CSS pixels (default: 0) */\n gap?: number;\n /** Enable VS Code–style drag resize between panes (default: false) */\n resizable?:\n | boolean\n | {\n /** Min pane height as fraction of available stack height (default: 1/6) */\n minPaneRatio?: number;\n /** Absolute min pane height in px — overrides ratio when larger */\n minPanePx?: number;\n dividerSize?: number;\n };\n /** Show legend on panes (default: false — set true on stack or per-pane chart) */\n showLegend?: boolean;\n /**\n * Pan/zoom sync between panes.\n * Default: X-axis sync via master pane (`axis: 'x'`, Y independent).\n * Pass `false` for fully independent panes.\n */\n sync?: boolean | StackedSyncOptions;\n /** Shared margin overrides — left/right aligned automatically across panes */\n layout?: Partial<LayoutOptions>;\n}\n\nexport interface StackedChart {\n readonly container: HTMLDivElement;\n getPane(id: string): Chart | undefined;\n /**\n * @deprecated Prefer `getPane(id)`. Alias kept for docs / Trading Experience. **Removed in v4.0.**\n */\n getChart(id: string): Chart | undefined;\n getPanes(): Chart[];\n getMaster(): Chart;\n getGroup(): ChartGroup;\n fitAll(options?: { x?: Range; padding?: number }): void;\n resetAll(): void;\n resize(): void;\n /** Current flex ratios keyed by pane id */\n getPaneRatios(): Record<string, number>;\n /** Set flex ratios (same keys as pane ids); triggers resize */\n setPaneRatios(ratios: Record<string, number>): void;\n /** Sync axis mode: `x` (default), `y`, `xy`, or `none` */\n setSyncAxis(axis: SyncAxis): void;\n getSyncAxis(): SyncAxis;\n /** Update pan/zoom/cursor sync options at runtime */\n setSyncOptions(options: Partial<StackedSyncOptions>): void;\n /** Resolves when all pane charts have started rendering */\n whenReady(): Promise<void>;\n /** Append a pane at runtime (max 5 panes) */\n addPane(pane: StackedPaneConfig): Chart;\n /** Calculate + mount indicator pane or overlay on master price chart */\n addIndicator(\n preset: import(\"../indicator/addIndicator\").IndicatorPresetName,\n options?: import(\"../indicator/addIndicator\").AddIndicatorOptions,\n ): Promise<AddIndicatorResult & { paneId?: string; chart?: Chart }>;\n /** Export the entire stack as one PNG/JPEG/WebP/SVG (WYSIWYG layout) */\n exportImage(options?: StackSnapshotOptions): Promise<string>;\n /** Export the entire stack as vector SVG */\n exportSVG(options?: StackSVGExportOptions): string;\n /** Alias for exportImage */\n snapshot(options?: StackSnapshotOptions): Promise<string>;\n destroy(): void;\n}\n\n/** Stack SVG export options */\nexport type StackSVGExportOptions = SVGExportOptions & {\n includeDividers?: boolean;\n includeBackground?: boolean;\n backgroundColor?: string;\n};\n\nexport const STACKED_MAX_PANES = 5;\n/** Default minimum pane height as a fraction of available stack height (1/6). */\nexport const STACKED_DEFAULT_MIN_PANE_RATIO = 1 / 6;\nexport const STACKED_COMPACT_MARGIN = { top: 4, bottom: 8, left: 4 };\nexport const STACKED_FULL_X_MARGIN = { bottom: 55 };\nexport const STACKED_FULL_Y_MARGIN = { left: 55 };\n\nexport type StackSnapshotFormat = \"png\" | \"jpeg\" | \"webp\" | \"svg\";\nexport type StackSnapshotResolution = \"standard\" | \"2k\" | \"4k\" | \"8k\" | number;\n\nexport interface StackSnapshotOptions extends Partial<StackSVGExportOptions> {\n format?: StackSnapshotFormat;\n quality?: number;\n resolution?: StackSnapshotResolution;\n includeBackground?: boolean;\n includeDividers?: boolean;\n transparent?: boolean;\n download?: boolean;\n fileName?: string;\n}\n\n/** Pan/zoom sync between stacked panes (Y stays independent when axis is `x`). */\nexport type StackedSyncOptions = Pick<\n SyncOptions,\n | \"axis\"\n | \"syncCursor\"\n | \"syncSelection\"\n | \"syncZoom\"\n | \"syncPan\"\n | \"bidirectional\"\n | \"debounce\"\n>;\n","/**\n * Full-stack snapshot export — composes all pane charts at exact layout positions.\n */\n\nimport type { Chart } from \"../chart/types\";\n\nexport type StackExportFormat = \"png\" | \"jpeg\" | \"webp\";\nexport type StackExportResolution = \"standard\" | \"2k\" | \"4k\" | \"8k\" | number;\n\nexport interface StackExportOptions {\n format?: StackExportFormat;\n quality?: number;\n resolution?: StackExportResolution;\n includeBackground?: boolean;\n includeDividers?: boolean;\n transparent?: boolean;\n}\n\n/** @internal Exported for unit tests */\nexport function stackResolutionScale(res: StackExportResolution): number {\n if (typeof res === \"number\") return res;\n switch (res) {\n case \"8k\":\n return 8;\n case \"4k\":\n return 4;\n case \"2k\":\n return 2;\n default:\n return 1;\n }\n}\n\nfunction loadImage(src: string): Promise<HTMLImageElement> {\n return new Promise((resolve, reject) => {\n const img = new Image();\n img.onload = () => resolve(img);\n img.onerror = reject;\n img.src = src;\n });\n}\n\nfunction relativeRect(\n el: HTMLElement,\n containerRect: DOMRect,\n): { x: number; y: number; width: number; height: number } {\n const r = el.getBoundingClientRect();\n return {\n x: r.left - containerRect.left,\n y: r.top - containerRect.top,\n width: r.width,\n height: r.height,\n };\n}\n\n/**\n * Compose every pane chart into one raster image matching the on-screen stack layout.\n */\nexport async function exportStackImage(\n container: HTMLDivElement,\n paneWrappers: HTMLDivElement[],\n paneCharts: Chart[],\n dividers: HTMLDivElement[],\n backgroundColor: string,\n options: StackExportOptions = {},\n): Promise<string> {\n const {\n format = \"png\",\n quality = 0.92,\n resolution = \"standard\",\n includeBackground = true,\n includeDividers = true,\n transparent = false,\n } = options;\n\n const scale = stackResolutionScale(resolution);\n const baseDpr = paneCharts[0]?.getDPR() ?? (typeof window !== \"undefined\" ? window.devicePixelRatio : 1);\n const exportDpr = baseDpr * scale;\n const originalDprs = paneCharts.map((c) => c.getDPR());\n\n try {\n if (scale > 1) {\n for (const chart of paneCharts) {\n // Lock the DPR so the enlarged backing store survives the resize() that\n // setDPR/exportImage would otherwise revert (see ChartCore.resize).\n if (typeof chart.setDevicePixelRatioOverride === \"function\") {\n chart.setDevicePixelRatioOverride(exportDpr);\n } else {\n chart.setDPR(exportDpr);\n }\n chart.render();\n }\n await new Promise((r) => requestAnimationFrame(r));\n await new Promise((r) => requestAnimationFrame(r));\n await new Promise((r) => setTimeout(r, 50));\n }\n\n const containerRect = container.getBoundingClientRect();\n const outW = Math.max(1, Math.round(containerRect.width * exportDpr));\n const outH = Math.max(1, Math.round(containerRect.height * exportDpr));\n\n const canvas = document.createElement(\"canvas\");\n canvas.width = outW;\n canvas.height = outH;\n const ctx = canvas.getContext(\"2d\");\n if (!ctx) throw new Error(\"Failed to create export canvas\");\n\n if (!transparent && includeBackground) {\n ctx.fillStyle = backgroundColor || \"#ffffff\";\n ctx.fillRect(0, 0, outW, outH);\n }\n\n const imageType = format === \"jpeg\" ? \"jpeg\" : \"png\";\n\n for (let i = 0; i < paneWrappers.length; i++) {\n const rect = relativeRect(paneWrappers[i], containerRect);\n const dataUrl = paneCharts[i].exportImage(imageType);\n const img = await loadImage(dataUrl);\n ctx.drawImage(\n img,\n Math.round(rect.x * exportDpr),\n Math.round(rect.y * exportDpr),\n Math.round(rect.width * exportDpr),\n Math.round(rect.height * exportDpr),\n );\n }\n\n if (includeDividers && dividers.length) {\n ctx.fillStyle = \"rgba(128, 128, 128, 0.35)\";\n for (const divider of dividers) {\n const rect = relativeRect(divider, containerRect);\n ctx.fillRect(\n Math.round(rect.x * exportDpr),\n Math.round(rect.y * exportDpr),\n Math.max(1, Math.round(rect.width * exportDpr)),\n Math.max(1, Math.round(rect.height * exportDpr)),\n );\n }\n }\n\n const mime = format === \"jpeg\" ? \"image/jpeg\" : format === \"webp\" ? \"image/webp\" : \"image/png\";\n return canvas.toDataURL(mime, quality);\n } finally {\n if (scale > 1) {\n for (let i = 0; i < paneCharts.length; i++) {\n if (typeof paneCharts[i].setDevicePixelRatioOverride === \"function\") {\n paneCharts[i].setDevicePixelRatioOverride!(null);\n } else {\n paneCharts[i].setDPR(originalDprs[i]);\n }\n paneCharts[i].render();\n }\n }\n }\n}\n","/**\n * Composes multiple pane chart SVG exports into a single stacked SVG document.\n */\n\nimport type { Chart } from \"../chart/types\";\nimport { captureLayoutSnapshot } from \"../chart/exporter/svg/SVGExportContext\";\nimport { renderSVG } from \"../chart/exporter/svg/SVGOrchestrator\";\nimport type { StackSVGExportOptions } from \"./types\";\n\nexport interface StackSVGPaneLayout {\n chart: Chart;\n wrapper: HTMLElement;\n offsetX: number;\n offsetY: number;\n width: number;\n height: number;\n}\n\nfunction relativeOffset(\n el: HTMLElement,\n containerRect: DOMRect,\n): { x: number; y: number; width: number; height: number } {\n const r = el.getBoundingClientRect();\n return {\n x: r.left - containerRect.left,\n y: r.top - containerRect.top,\n width: r.width,\n height: r.height,\n };\n}\n\nexport function buildStackPaneLayouts(\n container: HTMLDivElement,\n paneWrappers: HTMLDivElement[],\n paneCharts: Chart[],\n): StackSVGPaneLayout[] {\n const containerRect = container.getBoundingClientRect();\n return paneWrappers.map((wrapper, i) => {\n const rect = relativeOffset(wrapper, containerRect);\n return {\n chart: paneCharts[i],\n wrapper,\n offsetX: rect.x,\n offsetY: rect.y,\n width: rect.width,\n height: rect.height,\n };\n });\n}\n\nexport function composeStackSVG(\n container: HTMLDivElement,\n paneWrappers: HTMLDivElement[],\n paneCharts: Chart[],\n dividers: HTMLElement[],\n options: StackSVGExportOptions = {},\n): string {\n const containerRect = container.getBoundingClientRect();\n const outW = Math.max(1, Math.round(containerRect.width));\n const outH = Math.max(1, Math.round(containerRect.height));\n const bg = options.backgroundColor ?? paneCharts[0]?.theme?.backgroundColor ?? \"#111111\";\n const includeBg = options.includeBackground !== false;\n\n const layouts = buildStackPaneLayouts(container, paneWrappers, paneCharts);\n const parts: string[] = [\n `<svg width=\"${outW}\" height=\"${outH}\" viewBox=\"0 0 ${outW} ${outH}\" xmlns=\"http://www.w3.org/2000/svg\">`,\n ];\n\n if (includeBg) {\n parts.push(`<rect width=\"100%\" height=\"100%\" fill=\"${bg}\"/>`);\n }\n\n for (const layout of layouts) {\n const chart = layout.chart as unknown as Parameters<typeof captureLayoutSnapshot>[0];\n const paneSvg = renderSVG(\n captureLayoutSnapshot(chart, {\n ...options,\n includeLegend: options.includeLegend ?? (chart as { showLegend?: boolean }).showLegend,\n }),\n );\n const inner = paneSvg.replace(/^<svg[^>]*>/, \"\").replace(/<\\/svg>\\s*$/, \"\");\n parts.push(`<g transform=\"translate(${layout.offsetX.toFixed(1)},${layout.offsetY.toFixed(1)})\">`);\n parts.push(inner);\n parts.push(\"</g>\");\n }\n\n if (options.includeDividers !== false) {\n for (const divider of dividers) {\n const r = relativeOffset(divider, containerRect);\n const isHorizontal = r.height <= r.width;\n if (isHorizontal) {\n parts.push(\n `<line x1=\"${r.x.toFixed(1)}\" y1=\"${(r.y + r.height / 2).toFixed(1)}\" x2=\"${(r.x + r.width).toFixed(1)}\" y2=\"${(r.y + r.height / 2).toFixed(1)}\" stroke=\"rgba(128,128,128,0.5)\" stroke-width=\"1\"/>`,\n );\n } else {\n parts.push(\n `<line x1=\"${(r.x + r.width / 2).toFixed(1)}\" y1=\"${r.y.toFixed(1)}\" x2=\"${(r.x + r.width / 2).toFixed(1)}\" y2=\"${(r.y + r.height).toFixed(1)}\" stroke=\"rgba(128,128,128,0.5)\" stroke-width=\"1\"/>`,\n );\n }\n }\n }\n\n parts.push(\"</svg>\");\n return parts.join(\"\\n\");\n}\n\nexport function exportStackSVG(\n container: HTMLDivElement,\n paneWrappers: HTMLDivElement[],\n paneCharts: Chart[],\n dividers: HTMLElement[],\n backgroundColor: string,\n options: StackSVGExportOptions = {},\n): string {\n return composeStackSVG(container, paneWrappers, paneCharts, dividers, {\n ...options,\n backgroundColor: options.backgroundColor ?? backgroundColor,\n });\n}\n","/**\n * VS Code–style drag dividers between stacked chart panes (vertical or horizontal).\n */\n\nimport { STACKED_DEFAULT_MIN_PANE_RATIO } from \"./types\";\nimport type { StackDirection } from \"./types\";\n\nexport interface PaneResizeOptions {\n /** Stack layout direction */\n direction?: StackDirection;\n /** Min pane size as fraction of available stack dimension (default 1/6) */\n minPaneRatio?: number;\n /** Absolute min pane size in px */\n minPanePx?: number;\n /** Divider hit area size (default 6) */\n dividerSize?: number;\n onResize?: (ratiosById: Record<string, number>) => void;\n onDragStart?: (leadingIdx: number, trailingIdx: number) => number[];\n onDragMove?: (sizesPx: number[], leadingIdx: number, trailingIdx: number) => void;\n onDragEnd?: (finalSizesPx: number[]) => void;\n}\n\nconst DIVIDER_CLASS = \"velo-pane-divider\";\nconst RESIZING_CLASS = \"velo-pane-resizing\";\n\nexport function injectDividerStyles(direction: StackDirection): void {\n if (typeof document === \"undefined\") return;\n let style = document.getElementById(\"velo-pane-divider-styles\") as HTMLStyleElement | null;\n if (!style) {\n style = document.createElement(\"style\");\n style.id = \"velo-pane-divider-styles\";\n document.head.appendChild(style);\n }\n\n const isHorizontal = direction === \"horizontal\";\n const cursor = isHorizontal ? \"ew-resize\" : \"ns-resize\";\n const handleGlyph = isHorizontal ? \"⇔\" : \"⇕\";\n\n style.textContent = `\n .${DIVIDER_CLASS} {\n flex: 0 0 var(--velo-divider-size, 6px);\n position: relative;\n cursor: ${cursor};\n touch-action: none;\n z-index: 20;\n background: transparent;\n user-select: none;\n }\n .${DIVIDER_CLASS}::after {\n content: \"\";\n position: absolute;\n background: rgba(128, 128, 128, 0.35);\n transition: background 0.15s;\n }\n .${DIVIDER_CLASS}[data-direction=\"vertical\"]::after {\n left: 0;\n right: 0;\n top: 50%;\n transform: translateY(-50%);\n height: 1px;\n }\n .${DIVIDER_CLASS}[data-direction=\"horizontal\"]::after {\n top: 0;\n bottom: 0;\n left: 50%;\n transform: translateX(-50%);\n width: 1px;\n }\n .${DIVIDER_CLASS}:hover::after,\n .${RESIZING_CLASS} .${DIVIDER_CLASS}::after {\n background: rgba(0, 242, 255, 0.65);\n }\n .${DIVIDER_CLASS}[data-direction=\"vertical\"]:hover::after,\n .${RESIZING_CLASS} .${DIVIDER_CLASS}[data-direction=\"vertical\"]::after {\n height: 2px;\n }\n .${DIVIDER_CLASS}[data-direction=\"horizontal\"]:hover::after,\n .${RESIZING_CLASS} .${DIVIDER_CLASS}[data-direction=\"horizontal\"]::after {\n width: 2px;\n }\n .${DIVIDER_CLASS}-handle {\n position: absolute;\n left: 50%;\n top: 50%;\n transform: translate(-50%, -50%);\n width: 32px;\n height: 12px;\n display: flex;\n align-items: center;\n justify-content: center;\n opacity: 0;\n transition: opacity 0.15s;\n pointer-events: none;\n color: rgba(0, 242, 255, 0.9);\n font-size: 10px;\n line-height: 1;\n }\n .${DIVIDER_CLASS}:hover .${DIVIDER_CLASS}-handle,\n .${RESIZING_CLASS} .${DIVIDER_CLASS}-handle {\n opacity: 1;\n }\n .${RESIZING_CLASS} {\n cursor: ${cursor} !important;\n }\n .${RESIZING_CLASS} * {\n cursor: ${cursor} !important;\n }\n .${RESIZING_CLASS} [data-pane-id] {\n position: relative !important;\n overflow: hidden !important;\n }\n `;\n\n void handleGlyph;\n}\n\nexport function measurePaneSizes(\n paneWrappers: HTMLDivElement[],\n isHorizontal: boolean,\n): number[] {\n return paneWrappers.map((w) =>\n isHorizontal ? w.getBoundingClientRect().width : w.getBoundingClientRect().height,\n );\n}\n\nexport function resolveDragStartSizes(\n onDragStart: PaneResizeOptions[\"onDragStart\"],\n leadingIdx: number,\n trailingIdx: number,\n paneWrappers: HTMLDivElement[],\n isHorizontal: boolean,\n): number[] {\n return onDragStart?.(leadingIdx, trailingIdx) ?? measurePaneSizes(paneWrappers, isHorizontal);\n}\n\nfunction createDividerElement(index: number, size: number, direction: StackDirection): HTMLDivElement {\n const divider = document.createElement(\"div\");\n divider.className = DIVIDER_CLASS;\n divider.dataset.dividerIndex = String(index);\n divider.dataset.direction = direction;\n divider.style.setProperty(\"--velo-divider-size\", `${size}px`);\n\n const handle = document.createElement(\"div\");\n handle.className = `${DIVIDER_CLASS}-handle`;\n handle.textContent = direction === \"horizontal\" ? \"⇔\" : \"⇕\";\n divider.appendChild(handle);\n\n return divider;\n}\n\nexport interface PaneResizeController {\n dividers: HTMLDivElement[];\n destroy: () => void;\n}\n\nfunction paneFlexStyle(ratio: number | string, direction: StackDirection): string {\n const minDim = direction === \"horizontal\" ? \"min-width:0;\" : \"min-height:0;\";\n if (typeof ratio === \"number\") {\n return `flex:${ratio} 1 0;${minDim}`;\n }\n return `flex:1 1 ${ratio};${minDim}`;\n}\n\nexport function resolveMinPaneHeightPx(\n availHeight: number,\n paneCount: number,\n minPaneRatio = STACKED_DEFAULT_MIN_PANE_RATIO,\n minPanePx = 0,\n): number {\n if (paneCount < 1 || availHeight <= 0) return 1;\n const byRatio = availHeight * minPaneRatio;\n const minH = Math.max(minPanePx, byRatio);\n return Math.min(minH, availHeight / paneCount);\n}\n\nexport function resolveMinPaneWidthPx(\n availWidth: number,\n paneCount: number,\n minPaneRatio = STACKED_DEFAULT_MIN_PANE_RATIO,\n minPanePx = 0,\n): number {\n return resolveMinPaneHeightPx(availWidth, paneCount, minPaneRatio, minPanePx);\n}\n\nexport function normalizePaneHeights(heightsPx: number[], targetTotal: number): number[] {\n const n = heightsPx.length;\n if (n === 0) return heightsPx;\n const total = Math.max(1, Math.round(targetTotal));\n const sum = heightsPx.reduce((s, h) => s + h, 0);\n if (sum <= 0) {\n const even = Math.floor(total / n);\n const out = heightsPx.map(() => even);\n out[n - 1] = total - even * (n - 1);\n return out;\n }\n\n const scaled = heightsPx.map((h) => (h / sum) * total);\n const out: number[] = [];\n let allocated = 0;\n for (let i = 0; i < n - 1; i++) {\n out.push(Math.max(1, Math.round(scaled[i])));\n allocated += out[i];\n }\n out.push(Math.max(1, total - allocated));\n return out;\n}\n\nexport const normalizePaneWidths = normalizePaneHeights;\n\nexport function attachPaneResize(\n container: HTMLDivElement,\n paneWrappers: HTMLDivElement[],\n paneIds: string[],\n ratios: number[],\n options: PaneResizeOptions = {},\n): PaneResizeController {\n const direction = options.direction ?? \"vertical\";\n const isHorizontal = direction === \"horizontal\";\n injectDividerStyles(direction);\n\n const minPaneRatio = options.minPaneRatio ?? STACKED_DEFAULT_MIN_PANE_RATIO;\n const minPanePx = options.minPanePx ?? 0;\n const dividerSize = options.dividerSize ?? 6;\n const paneCount = paneWrappers.length;\n\n const minPaneSize = (avail: number) =>\n isHorizontal\n ? resolveMinPaneWidthPx(avail, paneCount, minPaneRatio, minPanePx)\n : resolveMinPaneHeightPx(avail, paneCount, minPaneRatio, minPanePx);\n\n const dividers: HTMLDivElement[] = [];\n const cleanups: (() => void)[] = [];\n\n if (paneWrappers.length < 2) {\n return { dividers, destroy: () => {} };\n }\n\n const availableSize = (): number => {\n const dividerTotal = dividers.length * dividerSize;\n const main = isHorizontal ? container.clientWidth : container.clientHeight;\n return Math.max(1, main - dividerTotal);\n };\n\n const applyRatios = (\n leadingIdx: number,\n trailingIdx: number,\n delta: number,\n sizesPx: number[],\n ) => {\n const avail = availableSize();\n const minS = minPaneSize(avail);\n\n const othersSum = sizesPx.reduce(\n (s, h, idx) => (idx === leadingIdx || idx === trailingIdx ? s : s + h),\n 0,\n );\n const pairTotal = avail - othersSum;\n\n let leadingSize = sizesPx[leadingIdx] + delta;\n leadingSize = Math.max(minS, Math.min(pairTotal - minS, leadingSize));\n const trailingSize = pairTotal - leadingSize;\n\n sizesPx[leadingIdx] = leadingSize;\n sizesPx[trailingIdx] = trailingSize;\n\n const total = ratios.reduce((s, r) => s + r, 0);\n ratios[leadingIdx] = (leadingSize / avail) * total;\n ratios[trailingIdx] = (trailingSize / avail) * total;\n\n options.onDragMove?.(sizesPx, leadingIdx, trailingIdx);\n\n if (options.onResize) {\n const byId: Record<string, number> = {};\n for (let i = 0; i < paneIds.length; i++) {\n byId[paneIds[i]] = ratios[i];\n }\n options.onResize(byId);\n }\n };\n\n for (let i = 0; i < paneWrappers.length - 1; i++) {\n const divider = createDividerElement(i, dividerSize, direction);\n const leadingWrapper = paneWrappers[i];\n leadingWrapper.after(divider);\n dividers.push(divider);\n\n const onPointerDown = (e: PointerEvent) => {\n e.preventDefault();\n divider.setPointerCapture(e.pointerId);\n container.classList.add(RESIZING_CLASS);\n\n const sizesPx = resolveDragStartSizes(\n options.onDragStart,\n i,\n i + 1,\n paneWrappers,\n isHorizontal,\n );\n\n options.onDragMove?.(sizesPx, i, i + 1);\n\n let lastCoord = isHorizontal ? e.clientX : e.clientY;\n\n const onMove = (ev: PointerEvent) => {\n const coord = isHorizontal ? ev.clientX : ev.clientY;\n const d = coord - lastCoord;\n lastCoord = coord;\n if (d !== 0) applyRatios(i, i + 1, d, sizesPx);\n };\n\n const onUp = (ev: PointerEvent) => {\n divider.releasePointerCapture(ev.pointerId);\n container.classList.remove(RESIZING_CLASS);\n divider.removeEventListener(\"pointermove\", onMove);\n divider.removeEventListener(\"pointerup\", onUp);\n divider.removeEventListener(\"pointercancel\", onUp);\n options.onDragEnd?.(sizesPx);\n };\n\n divider.addEventListener(\"pointermove\", onMove);\n divider.addEventListener(\"pointerup\", onUp);\n divider.addEventListener(\"pointercancel\", onUp);\n };\n\n divider.addEventListener(\"pointerdown\", onPointerDown);\n cleanups.push(() => divider.removeEventListener(\"pointerdown\", onPointerDown));\n }\n\n return {\n dividers,\n destroy: () => {\n for (const fn of cleanups) fn();\n for (const d of dividers) d.remove();\n container.classList.remove(RESIZING_CLASS);\n },\n };\n}\n\nexport function applyPaneFlexRatios(\n paneWrappers: HTMLDivElement[],\n ratios: number[],\n direction: StackDirection = \"vertical\",\n): void {\n for (let i = 0; i < paneWrappers.length; i++) {\n paneWrappers[i].style.cssText = `${paneFlexStyle(ratios[i], direction)}position:relative;overflow:hidden;`;\n }\n}\n\nexport function initialPaneRatio(height: number | string): number {\n return typeof height === \"number\" ? height : 1;\n}\n\nexport { paneFlexStyle };\n","import type { Chart } from \"../chart/types\";\n\n/** Adaptive Y tick count from pane height (~1 tick per 36px, capped by base). */\nexport function tickCountForPaneHeight(heightPx: number, base = 6): number {\n if (!Number.isFinite(heightPx) || heightPx <= 0) return base;\n const adaptive = Math.floor(heightPx / 36);\n return Math.max(2, Math.min(base, adaptive));\n}\n\n/** Adaptive X tick count from pane width. */\nexport function tickCountForPaneWidth(widthPx: number, base = 8): number {\n if (!Number.isFinite(widthPx) || widthPx <= 0) return base;\n const adaptive = Math.floor(widthPx / 72);\n return Math.max(2, Math.min(base, adaptive));\n}\n\nexport interface PaneAxisMeta {\n chart: Chart;\n wrapper: HTMLDivElement;\n baseYTickCount: number;\n baseXTickCount: number;\n showXAxis: boolean;\n}\n\nexport function readBaseYTickCount(yAxis?: { tickCount?: number } | { tickCount?: number }[]): number {\n if (!yAxis) return 6;\n const axes = Array.isArray(yAxis) ? yAxis : [yAxis];\n return axes[0]?.tickCount ?? 6;\n}\n\nexport function adaptPaneAxes(meta: PaneAxisMeta): void {\n const h = meta.wrapper.clientHeight;\n const w = meta.wrapper.clientWidth;\n const yTicks = tickCountForPaneHeight(h, meta.baseYTickCount);\n\n meta.chart.updateYAxis(\"default\", { tickCount: yTicks });\n\n if (meta.showXAxis) {\n const xTicks = tickCountForPaneWidth(w, meta.baseXTickCount);\n meta.chart.updateXAxis({ tickCount: xTicks });\n }\n}\n\nexport function adaptAllPaneAxes(metas: PaneAxisMeta[]): void {\n for (const m of metas) adaptPaneAxes(m);\n}\n","import { createChart } from \"../Chart\";\nimport type { Chart } from \"../chart/types\";\nimport { MARGINS } from \"../chart/types\";\nimport { createChartGroup } from \"../sync\";\nimport type { SyncOptions } from \"../sync\";\nimport type { AxisOptions, ChartOptions, SeriesOptions } from \"../../types\";\nimport { mergeLayoutOptions } from \"../layout\";\nimport { buildIndicatorSeries } from \"../indicator/buildIndicatorSeries\";\nimport type { IndicatorSeriesOptions } from \"../indicator/types\";\nimport type {\n StackedChart,\n StackedChartOptions,\n StackedPaneConfig,\n StackedSyncOptions,\n StackSnapshotOptions,\n StackDirection,\n} from \"./types\";\nimport {\n STACKED_MAX_PANES,\n STACKED_COMPACT_MARGIN,\n STACKED_FULL_X_MARGIN,\n} from \"./types\";\nimport { exportStackImage, type StackExportOptions } from \"./stackExport\";\nimport { exportStackSVG } from \"./StackSVGComposer\";\nimport { getInitQueueStatus } from \"../ChartInitQueue\";\nimport {\n addIndicatorToChart,\n buildIndicatorPaneFromPreset,\n type AddIndicatorOptions,\n type IndicatorPresetName,\n} from \"../indicator/addIndicator\";\nimport { extractPriceSeries, resolveSourceSeries } from \"../indicator/indicatorPresets\";\nimport {\n attachPaneResize,\n applyPaneFlexRatios,\n initialPaneRatio,\n normalizePaneHeights,\n type PaneResizeController,\n} from \"./paneResize\";\nimport {\n adaptAllPaneAxes,\n readBaseYTickCount,\n type PaneAxisMeta,\n} from \"./paneAxis\";\n\nfunction countYAxes(yAxis?: AxisOptions | AxisOptions[]): { left: number; right: number } {\n const axes = yAxis ? (Array.isArray(yAxis) ? yAxis : [yAxis]) : [{}];\n let left = 0;\n let right = 0;\n for (const a of axes) {\n if (a.position === \"right\") right++;\n else left++;\n }\n return { left: Math.max(1, left), right };\n}\n\nfunction computeAlignedLeftMargin(panes: StackedPaneConfig[], baseLeft: number): number {\n let maxExtra = 0;\n for (const pane of panes) {\n const { left } = countYAxes(pane.chart?.yAxis);\n maxExtra = Math.max(maxExtra, (left - 1) * 65);\n }\n return baseLeft + maxExtra;\n}\n\nfunction computeAlignedRightMargin(panes: StackedPaneConfig[], baseRight: number): number {\n let maxExtra = 0;\n for (const pane of panes) {\n const { right } = countYAxes(pane.chart?.yAxis);\n maxExtra = Math.max(maxExtra, right * 65);\n }\n return baseRight + maxExtra;\n}\n\n// Pane ratios are always numeric (see initialPaneRatio), so this only handles\n// the numeric flex-grow form.\nfunction paneFlexStyle(ratio: number, direction: StackDirection): string {\n const minDim = direction === \"horizontal\" ? \"min-width:0;\" : \"min-height:0;\";\n // Grow factors must sum to ≥1 across siblings or free space stays empty\n // (CSS: grow < 1 only absorbs that fraction of free space).\n return `flex:${ratio} 1 0;${minDim}`;\n}\n\n/** Keep ratios summing to 1 so a lone pane always fills the host. */\nfunction normalizePaneRatios(ratios: number[]): void {\n const sum = ratios.reduce((a, b) => a + b, 0);\n if (sum <= 0) {\n const even = 1 / Math.max(1, ratios.length);\n for (let i = 0; i < ratios.length; i++) ratios[i] = even;\n return;\n }\n for (let i = 0; i < ratios.length; i++) ratios[i] /= sum;\n}\n\nfunction expandPaneSeries(series?: SeriesOptions[]): SeriesOptions[] {\n if (!series?.length) return [];\n const out: SeriesOptions[] = [];\n for (const s of series) {\n if (s.type === \"indicator\") {\n out.push(...buildIndicatorSeries(s as IndicatorSeriesOptions));\n } else {\n out.push(s);\n }\n }\n return out;\n}\n\nfunction buildPaneChartOptions(\n pane: StackedPaneConfig,\n chartContainer: HTMLDivElement,\n stack: StackedChartOptions,\n index: number,\n total: number,\n alignedMargins: { left: number; right: number; top: number; bottom: number },\n showXAxis: boolean,\n showYAxis: boolean,\n direction: StackDirection,\n stackRenderer?: ChartOptions[\"renderer\"],\n sharedTimeXAxis?: AxisOptions,\n): Parameters<typeof createChart>[0] {\n const isFirst = index === 0;\n const isLast = index === total - 1;\n const isHorizontal = direction === \"horizontal\";\n const sharedBottom = !isHorizontal && stack.sharedXAxis !== \"none\";\n const compactX = sharedBottom && !showXAxis;\n const sharedLeft = isHorizontal && (stack.sharedYAxis ?? \"left\") !== \"none\";\n const compactY = sharedLeft && !showYAxis;\n const paneGap = stack.gap ?? 0;\n const compactMargin = paneGap > 0 ? STACKED_COMPACT_MARGIN : { top: 0, bottom: 0, left: 0 };\n\n const margins = isHorizontal\n ? {\n top: alignedMargins.top,\n right: isLast ? alignedMargins.right : compactMargin.left,\n left: compactY ? compactMargin.left : alignedMargins.left,\n bottom: alignedMargins.bottom,\n }\n : {\n top: isFirst ? alignedMargins.top : compactMargin.top,\n right: alignedMargins.right,\n left: alignedMargins.left,\n bottom: compactX\n ? compactMargin.bottom\n : isLast\n ? (stack.layout?.margins?.bottom ?? STACKED_FULL_X_MARGIN.bottom)\n : alignedMargins.bottom,\n };\n\n const baseX = {\n ...(sharedTimeXAxis && pane.chart?.xAxis?.type !== \"time\" ? sharedTimeXAxis : {}),\n ...(stack.xAxis ?? {}),\n ...(pane.chart?.xAxis ?? {}),\n };\n const xAxis = {\n ...baseX,\n showLine: showXAxis ? baseX.showLine ?? true : false,\n showTicks: showXAxis ? baseX.showTicks ?? true : false,\n showLabels: showXAxis ? baseX.showLabels ?? true : false,\n };\n\n const baseY = pane.chart?.yAxis ?? {};\n const yAxisRaw = Array.isArray(baseY) ? baseY : [baseY];\n const yAxis = yAxisRaw.map((axis) => ({\n ...axis,\n showLine: showYAxis ? axis.showLine ?? true : false,\n showTicks: showYAxis ? axis.showTicks ?? true : false,\n showLabels: showYAxis ? axis.showLabels ?? true : false,\n }));\n const yAxisOption = Array.isArray(pane.chart?.yAxis) ? yAxis : yAxis[0];\n\n const isInteractive = pane.interactive ?? true;\n if (!isInteractive) {\n chartContainer.style.pointerEvents = \"none\";\n }\n\n const paneChart = pane.chart ?? {};\n const chartOpts =\n stackRenderer && !paneChart.renderer\n ? { ...paneChart, renderer: stackRenderer }\n : paneChart;\n\n return {\n ...chartOpts,\n id: pane.id,\n container: chartContainer,\n showLegend: pane.chart?.showLegend ?? stack.showLegend ?? false,\n theme: pane.chart?.theme ?? stack.theme,\n devicePixelRatio: stack.devicePixelRatio ?? pane.chart?.devicePixelRatio,\n loading: pane.chart?.loading ?? false,\n xAxis,\n yAxis: yAxisOption,\n layout: mergeLayoutOptions({\n ...stack.layout,\n ...pane.chart?.layout,\n margins: { ...margins, ...stack.layout?.margins, ...pane.chart?.layout?.margins },\n }),\n };\n}\n\nfunction paneChartDivStyle(): string {\n return \"position:absolute;inset:0;width:100%;height:100%;min-width:0;min-height:0;\";\n}\n\nfunction wrapperStyle(ratio: number, gap: number, index: number, direction: StackDirection): string {\n const gapStyle =\n gap > 0 && index > 0\n ? direction === \"horizontal\"\n ? `margin-left:${gap}px;`\n : `margin-top:${gap}px;`\n : \"\";\n return `${paneFlexStyle(ratio, direction)}position:relative;overflow:hidden;${gapStyle}`;\n}\n\nfunction resolveStackSyncOptions(\n sync: StackedChartOptions[\"sync\"],\n masterPaneId: string,\n direction: StackDirection,\n): SyncOptions {\n if (sync === false) {\n return {\n axis: \"none\",\n syncCursor: false,\n syncZoom: false,\n syncPan: false,\n bidirectional: true,\n masterId: undefined,\n };\n }\n\n const defaultAxis: SyncOptions[\"axis\"] = direction === \"horizontal\" ? \"y\" : \"x\";\n\n return {\n axis: defaultAxis,\n bidirectional: true,\n masterId: masterPaneId,\n syncCursor: true,\n syncZoom: true,\n syncPan: true,\n ...(typeof sync === \"object\" ? sync : {}),\n };\n}\n\nexport function createStackedChart(options: StackedChartOptions): StackedChart {\n const { container, panes } = options;\n if (!container) throw new Error(\"[StackedChart] container is required\");\n if (panes.length < 1 || panes.length > STACKED_MAX_PANES) {\n throw new Error(`[StackedChart] panes must be 1–${STACKED_MAX_PANES}`);\n }\n\n const masterPaneId = options.masterPaneId ?? panes[0].id;\n const direction: StackDirection = options.direction ?? \"vertical\";\n const isHorizontal = direction === \"horizontal\";\n const sharedXAxis = options.sharedXAxis ?? \"bottom\";\n const sharedYAxis = options.sharedYAxis ?? \"left\";\n const gap = options.gap ?? 0;\n const resizableOpt = options.resizable;\n const resizable = !!resizableOpt;\n const resizeDividerSize =\n typeof resizableOpt === \"object\" ? (resizableOpt.dividerSize ?? 6) : 6;\n const stackRenderer = panes.find((p) => p.chart?.renderer)?.chart?.renderer;\n const masterPaneConfig = panes.find((p) => p.id === masterPaneId) ?? panes[0];\n const sharedTimeXAxis =\n masterPaneConfig?.chart?.xAxis?.type === \"time\"\n ? masterPaneConfig.chart.xAxis\n : undefined;\n\n const baseLayout = mergeLayoutOptions(options.layout);\n const baseLeft = baseLayout.margins?.left ?? MARGINS.left;\n const baseRight = baseLayout.margins?.right ?? MARGINS.right;\n const baseTop = baseLayout.margins?.top ?? MARGINS.top;\n const alignedLeft = computeAlignedLeftMargin(panes, baseLeft);\n const alignedRight = computeAlignedRightMargin(panes, baseRight);\n\n // Capture host-owned size BEFORE mutating styles. Demos often set\n // style=\"height:480px\" / CSS height on this same element.\n const hostInlineHeight = container.style.height;\n const hostInlineWidth = container.style.width;\n const hostInlineMinHeight = container.style.minHeight;\n const hostInlineMinWidth = container.style.minWidth;\n const computed = getComputedStyle(container);\n const measuredHeight =\n container.offsetHeight || parseInt(computed.height, 10) || 0;\n\n container.replaceChildren();\n // Fill the host box exactly — never invent a new size or freeze max-* during drag.\n // The host (inline style / CSS class / parent layout) owns width & height.\n container.style.display = \"flex\";\n container.style.flexDirection = isHorizontal ? \"row\" : \"column\";\n container.style.boxSizing = \"border-box\";\n container.style.overflow = \"hidden\";\n container.style.position = \"relative\";\n container.style.maxWidth = \"none\";\n container.style.maxHeight = \"none\";\n container.style.width = hostInlineWidth || \"100%\";\n container.style.minWidth = hostInlineMinWidth || \"0\";\n\n if (hostInlineHeight) {\n container.style.height = hostInlineHeight;\n } else if (measuredHeight > 0) {\n // CSS-class sized host: pin the measured height so flex children have a\n // definite size (plain height:100% collapses without an ancestor height).\n container.style.height = `${measuredHeight}px`;\n } else {\n container.style.height = \"100%\";\n container.style.minHeight = hostInlineMinHeight || \"320px\";\n }\n if (hostInlineMinHeight) container.style.minHeight = hostInlineMinHeight;\n else if (!container.style.minHeight) container.style.minHeight = \"0\";\n\n const paneIds = panes.map((p) => p.id);\n const paneRatios = panes.map((p) => initialPaneRatio(p.height));\n normalizePaneRatios(paneRatios);\n const paneCharts = new Map<string, Chart>();\n const paneWrappers: HTMLDivElement[] = [];\n const paneAxisMetas: PaneAxisMeta[] = [];\n let paneResizeCtrl: PaneResizeController | null = null;\n let isPaneDragging = false;\n let resizeRaf = 0;\n let dragLayoutRaf = 0;\n let pendingDragLayout: {\n sizes: number[];\n leadingIdx: number;\n trailingIdx: number;\n } | null = null;\n\n const commitPaneLayout = (affected?: number[]) => {\n const indices =\n affected ??\n Array.from({ length: paneWrappers.length }, (_, i) => i);\n\n for (const i of indices) {\n const chart = paneCharts.get(paneIds[i]);\n if (chart) {\n chart.resize();\n }\n }\n adaptAllPaneAxes(\n indices.map((i) => paneAxisMetas[i]).filter(Boolean),\n );\n };\n\n const scheduleStackResize = () => {\n if (resizeRaf) return;\n resizeRaf = requestAnimationFrame(() => {\n resizeRaf = 0;\n if (isPaneDragging) return;\n commitPaneLayout();\n });\n };\n\n const resizeObserver = new ResizeObserver(() => {\n if (isPaneDragging) return;\n scheduleStackResize();\n });\n resizeObserver.observe(container);\n\n const applyFlexCss = () => {\n for (let i = 0; i < paneWrappers.length; i++) {\n paneWrappers[i].style.cssText = wrapperStyle(paneRatios[i], gap, i, direction);\n }\n };\n\n const stackAvailSize = () => {\n const dividerTotal = (paneWrappers.length - 1) * resizeDividerSize;\n if (isHorizontal) {\n return Math.max(1, container.clientWidth - dividerTotal);\n }\n return Math.max(1, container.clientHeight - dividerTotal);\n };\n\n const restorePaneChartDivs = () => {\n for (const wrapper of paneWrappers) {\n const chartDiv = wrapper.firstElementChild as HTMLDivElement | null;\n if (chartDiv) {\n chartDiv.style.cssText = paneChartDivStyle();\n }\n }\n };\n\n const initDragSizes = (): number[] => {\n const avail = stackAvailSize();\n const measured = paneWrappers.map((w) =>\n isHorizontal ? w.getBoundingClientRect().width : w.getBoundingClientRect().height,\n );\n const sum = measured.reduce((s, h) => s + h, 0);\n if (sum <= 0) {\n const even = Math.floor(avail / Math.max(1, paneWrappers.length));\n return paneWrappers.map((_, i) =>\n i === paneWrappers.length - 1 ? avail - even * (paneWrappers.length - 1) : even,\n );\n }\n // Keep integer px that sum exactly to avail so panes always fill the host.\n return normalizePaneHeights(measured, avail);\n };\n\n const applyDragPaneSizes = (sizesPx: number[]) => {\n // Always redistribute inside the current host box — never grow/shrink it.\n const normalized = normalizePaneHeights(sizesPx, stackAvailSize());\n for (let i = 0; i < paneWrappers.length; i++) {\n const size = Math.max(1, normalized[i]);\n const gapStyle =\n gap > 0 && i > 0\n ? isHorizontal\n ? `margin-left:${gap}px;`\n : `margin-top:${gap}px;`\n : \"\";\n const dim = isHorizontal ? \"width\" : \"height\";\n paneWrappers[i].style.cssText = `${dim}:${size}px;flex:0 0 auto;min-height:0;min-width:0;position:relative;overflow:hidden;${gapStyle}`;\n const chartDiv = paneWrappers[i].firstElementChild as HTMLDivElement | null;\n if (chartDiv) chartDiv.style.cssText = paneChartDivStyle();\n }\n for (let i = 0; i < sizesPx.length; i++) sizesPx[i] = normalized[i];\n };\n\n const flushDragLayout = () => {\n dragLayoutRaf = 0;\n if (!isPaneDragging || !pendingDragLayout) return;\n\n const { sizes, leadingIdx, trailingIdx } = pendingDragLayout;\n applyDragPaneSizes(sizes);\n\n for (const i of [leadingIdx, trailingIdx]) {\n const chart = paneCharts.get(paneIds[i]);\n if (chart) {\n chart.resize();\n adaptAllPaneAxes([paneAxisMetas[i]]);\n }\n }\n };\n\n const scheduleDragLayout = (\n sizesPx: number[],\n leadingIdx: number,\n trailingIdx: number,\n ) => {\n pendingDragLayout = { sizes: sizesPx, leadingIdx, trailingIdx };\n if (dragLayoutRaf) return;\n dragLayoutRaf = requestAnimationFrame(flushDragLayout);\n };\n\n const syncRatiosFromSizes = (sizesPx: number[]) => {\n const total = sizesPx.reduce((s, h) => s + h, 0);\n if (total <= 0) return;\n const totalR = paneRatios.reduce((s, r) => s + r, 0);\n for (let i = 0; i < paneRatios.length; i++) {\n paneRatios[i] = (sizesPx[i] / total) * totalR;\n }\n };\n\n const setAllChartsResizeSuspended = (suspended: boolean) => {\n for (const chart of paneCharts.values()) {\n chart.setResizeSuspended?.(suspended);\n }\n };\n\n const setInactiveChartsResizeSuspended = (\n topIdx: number,\n bottomIdx: number,\n ) => {\n for (let i = 0; i < paneIds.length; i++) {\n if (i === topIdx || i === bottomIdx) continue;\n paneCharts.get(paneIds[i])?.setResizeSuspended?.(true);\n }\n paneCharts.get(paneIds[topIdx])?.setResizeSuspended?.(false);\n paneCharts.get(paneIds[bottomIdx])?.setResizeSuspended?.(false);\n };\n\n const alignedBottom = isHorizontal\n ? (options.layout?.margins?.bottom ?? STACKED_FULL_X_MARGIN.bottom)\n : MARGINS.bottom;\n\n for (let i = 0; i < panes.length; i++) {\n const pane = panes[i];\n const isFirst = i === 0;\n const isLast = i === panes.length - 1;\n\n const showXAxis = isHorizontal\n ? (pane.showXAxis ?? true)\n : (pane.showXAxis ?? (sharedXAxis === \"bottom\" ? isLast : true));\n\n const showYAxis = isHorizontal\n ? (pane.showYAxis ?? (sharedYAxis === \"left\" ? isFirst : true))\n : (pane.showYAxis ?? true);\n\n const wrapper = document.createElement(\"div\");\n wrapper.dataset.paneId = pane.id;\n wrapper.style.cssText = wrapperStyle(paneRatios[i], gap, i, direction);\n\n const chartDiv = document.createElement(\"div\");\n chartDiv.style.cssText = paneChartDivStyle();\n\n wrapper.appendChild(chartDiv);\n container.appendChild(wrapper);\n paneWrappers.push(wrapper);\n\n const chart = createChart(\n buildPaneChartOptions(\n pane,\n chartDiv,\n options,\n i,\n panes.length,\n {\n left: isHorizontal && !showYAxis ? MARGINS.left : alignedLeft,\n right: alignedRight,\n top: baseTop,\n bottom: alignedBottom,\n },\n showXAxis,\n showYAxis,\n direction,\n stackRenderer,\n sharedTimeXAxis,\n ),\n );\n // createChart may touch container styles — keep the absolute fill for flex panes.\n chartDiv.style.cssText = paneChartDivStyle();\n\n const seriesList = expandPaneSeries(pane.series);\n if (seriesList.length) {\n for (const s of seriesList) chart.addSeries(s);\n }\n\n if (pane.yRange && pane.yRange !== \"auto\") {\n chart.zoom({ y: pane.yRange, animate: false });\n }\n\n paneCharts.set(pane.id, chart);\n\n paneAxisMetas.push({\n chart,\n wrapper,\n baseYTickCount: readBaseYTickCount(pane.chart?.yAxis),\n baseXTickCount: pane.chart?.xAxis?.tickCount ?? 8,\n showXAxis,\n });\n }\n\n const rebuildPaneResize = () => {\n paneResizeCtrl?.destroy();\n paneResizeCtrl = null;\n if (!resizable || paneWrappers.length < 2) return;\n\n const resizeOpts =\n typeof resizableOpt === \"object\"\n ? {\n minPaneRatio: resizableOpt.minPaneRatio,\n minPanePx: resizableOpt.minPanePx,\n dividerSize: resizableOpt.dividerSize,\n }\n : {};\n paneResizeCtrl = attachPaneResize(\n container,\n paneWrappers,\n paneIds,\n paneRatios,\n {\n direction,\n ...resizeOpts,\n onDragStart: (leadingIdx, trailingIdx) => {\n isPaneDragging = true;\n setAllChartsResizeSuspended(true);\n setInactiveChartsResizeSuspended(leadingIdx, trailingIdx);\n return initDragSizes();\n },\n onDragMove: (sizes, leadingIdx, trailingIdx) => {\n scheduleDragLayout(sizes, leadingIdx, trailingIdx);\n },\n onDragEnd: (finalSizes) => {\n if (dragLayoutRaf) {\n cancelAnimationFrame(dragLayoutRaf);\n dragLayoutRaf = 0;\n }\n pendingDragLayout = null;\n isPaneDragging = false;\n const normalized = normalizePaneHeights(finalSizes, stackAvailSize());\n syncRatiosFromSizes(normalized);\n restorePaneChartDivs();\n applyFlexCss();\n setAllChartsResizeSuspended(false);\n commitPaneLayout();\n },\n },\n );\n };\n\n rebuildPaneResize();\n\n const master = paneCharts.get(masterPaneId);\n if (!master) {\n throw new Error(`[StackedChart] masterPaneId \"${masterPaneId}\" not found in panes`);\n }\n\n const group = createChartGroup(\n Array.from(paneCharts.values()),\n resolveStackSyncOptions(options.sync, masterPaneId, direction),\n );\n\n const getBackgroundColor = (): string => {\n const theme = master.theme ?? master.baseTheme;\n return theme?.backgroundColor ?? \"#ffffff\";\n };\n\n const waitForStackReady = (): Promise<void> => {\n const maxWait = 8000;\n const started = Date.now();\n\n const waitForInitQueue = (): Promise<void> =>\n new Promise((resolve) => {\n const poll = () => {\n const q = getInitQueueStatus();\n if ((q.pending === 0 && !q.isProcessing) || Date.now() - started > maxWait) {\n resolve();\n return;\n }\n setTimeout(poll, 50);\n };\n poll();\n });\n\n return waitForInitQueue().then(() => {\n return new Promise<void>((resolve) => {\n requestAnimationFrame(() => {\n commitPaneLayout();\n resolve();\n });\n });\n });\n };\n\n const runStackExport = async (opts: StackSnapshotOptions = {}): Promise<string> => {\n if (opts.format === \"svg\") {\n for (const c of paneCharts.values()) c.render();\n const svg = exportStackSVG(\n container,\n paneWrappers,\n Array.from(paneCharts.values()),\n paneResizeCtrl?.dividers ?? [],\n getBackgroundColor(),\n opts,\n );\n if (opts.download) {\n const link = document.createElement(\"a\");\n link.download = `${opts.fileName ?? \"velo-plot-stack\"}.svg`;\n link.href = `data:image/svg+xml;charset=utf-8,${encodeURIComponent(svg)}`;\n document.body.appendChild(link);\n link.click();\n document.body.removeChild(link);\n }\n return `data:image/svg+xml;charset=utf-8,${encodeURIComponent(svg)}`;\n }\n\n await waitForStackReady();\n for (const c of paneCharts.values()) c.render();\n await new Promise((r) => requestAnimationFrame(r));\n\n const dataUrl = await exportStackImage(\n container,\n paneWrappers,\n Array.from(paneCharts.values()),\n paneResizeCtrl?.dividers ?? [],\n getBackgroundColor(),\n opts as StackExportOptions,\n );\n\n if (opts.download) {\n const ext = opts.format === \"jpeg\" ? \"jpg\" : opts.format ?? \"png\";\n const link = document.createElement(\"a\");\n link.download = `${opts.fileName ?? \"velo-plot-stack\"}.${ext}`;\n link.href = dataUrl;\n document.body.appendChild(link);\n link.click();\n document.body.removeChild(link);\n }\n\n return dataUrl;\n };\n\n const mountPane = (pane: StackedPaneConfig): Chart => {\n if (paneCharts.size >= STACKED_MAX_PANES) {\n throw new Error(`[StackedChart] Cannot exceed ${STACKED_MAX_PANES} panes`);\n }\n if (paneCharts.has(pane.id)) {\n throw new Error(`[StackedChart] Pane \"${pane.id}\" already exists`);\n }\n\n if (!isHorizontal && sharedXAxis === \"bottom\" && paneIds.length > 0) {\n const prevId = paneIds[paneIds.length - 1];\n const prevChart = paneCharts.get(prevId);\n const prevMeta = paneAxisMetas[paneAxisMetas.length - 1];\n // Hide shared X labels on the previous bottom pane and reclaim the\n // ~55px date-row margin so panes sit flush (no empty strip).\n prevChart?.updateXAxis({\n showLabels: false,\n showTicks: false,\n showLine: false,\n });\n prevChart?.updateLayout({\n margins: {\n bottom: gap > 0 ? STACKED_COMPACT_MARGIN.bottom : 0,\n },\n });\n if (prevMeta) prevMeta.showXAxis = false;\n }\n\n const newRatio = initialPaneRatio(pane.height ?? 0.25);\n const total = paneRatios.reduce((a, b) => a + b, 0);\n const scale = total > 0 ? (1 - newRatio) / total : 1;\n for (let j = 0; j < paneRatios.length; j++) paneRatios[j] *= scale;\n\n const index = paneIds.length;\n paneIds.push(pane.id);\n paneRatios.push(newRatio);\n normalizePaneRatios(paneRatios);\n\n const wrapper = document.createElement(\"div\");\n wrapper.dataset.paneId = pane.id;\n wrapper.style.cssText = wrapperStyle(paneRatios[index], gap, index, direction);\n\n const chartDiv = document.createElement(\"div\");\n chartDiv.style.cssText = paneChartDivStyle();\n wrapper.appendChild(chartDiv);\n container.appendChild(wrapper);\n paneWrappers.push(wrapper);\n\n // Rebalance flex on existing panes before createChart so the new\n // container has a non-zero size on first render (avoids zero-size overlay skip).\n applyFlexCss();\n\n const isLast = true;\n const showXAxis = isHorizontal\n ? (pane.showXAxis ?? true)\n : (pane.showXAxis ?? (sharedXAxis === \"bottom\" ? isLast : true));\n const showYAxis = isHorizontal\n ? (pane.showYAxis ?? (sharedYAxis === \"left\" ? index === 0 : true))\n : (pane.showYAxis ?? true);\n\n const chart = createChart(\n buildPaneChartOptions(\n pane,\n chartDiv,\n options,\n index,\n paneIds.length,\n {\n left: isHorizontal && !showYAxis ? MARGINS.left : alignedLeft,\n right: alignedRight,\n top: baseTop,\n bottom: alignedBottom,\n },\n showXAxis,\n showYAxis,\n direction,\n stackRenderer,\n sharedTimeXAxis,\n ),\n );\n chartDiv.style.cssText = paneChartDivStyle();\n\n const seriesList = expandPaneSeries(pane.series);\n for (const s of seriesList) chart.addSeries(s);\n if (pane.yRange && pane.yRange !== \"auto\") {\n chart.zoom({ y: pane.yRange, animate: false });\n }\n\n paneCharts.set(pane.id, chart);\n paneAxisMetas.push({\n chart,\n wrapper,\n baseYTickCount: readBaseYTickCount(pane.chart?.yAxis),\n baseXTickCount: pane.chart?.xAxis?.tickCount ?? 8,\n showXAxis,\n });\n\n group.add(chart);\n rebuildPaneResize();\n commitPaneLayout();\n return chart;\n };\n\n const stack: StackedChart = {\n container,\n getPane(id: string) {\n return paneCharts.get(id);\n },\n /** @deprecated Prefer `getPane(id)`. **Removed in v4.0.** */\n getChart(id: string) {\n return paneCharts.get(id);\n },\n getPanes() {\n return Array.from(paneCharts.values());\n },\n getMaster() {\n return master;\n },\n getGroup() {\n return group;\n },\n fitAll(opts) {\n group.fitAll(opts);\n },\n resetAll() {\n group.resetAll();\n },\n resize() {\n commitPaneLayout();\n },\n getPaneRatios() {\n const out: Record<string, number> = {};\n for (let i = 0; i < paneIds.length; i++) {\n out[paneIds[i]] = paneRatios[i];\n }\n return out;\n },\n setPaneRatios(ratios: Record<string, number>) {\n for (let i = 0; i < paneIds.length; i++) {\n const id = paneIds[i];\n if (ratios[id] !== undefined) paneRatios[i] = ratios[id];\n }\n applyPaneFlexRatios(paneWrappers, paneRatios, direction);\n commitPaneLayout();\n },\n setSyncAxis(axis) {\n group.syncAxis(axis);\n },\n getSyncAxis() {\n return group.getOptions().axis ?? \"x\";\n },\n setSyncOptions(syncOpts: Partial<StackedSyncOptions>) {\n group.updateOptions(syncOpts);\n },\n whenReady() {\n return waitForStackReady();\n },\n exportImage(opts) {\n return runStackExport(opts);\n },\n exportSVG(opts) {\n for (const c of paneCharts.values()) c.render();\n return exportStackSVG(\n container,\n paneWrappers,\n Array.from(paneCharts.values()),\n paneResizeCtrl?.dividers ?? [],\n getBackgroundColor(),\n opts,\n );\n },\n snapshot(opts) {\n return runStackExport(opts);\n },\n addPane(pane: StackedPaneConfig): Chart {\n return mountPane(pane);\n },\n async addIndicator(preset: IndicatorPresetName, opts: AddIndicatorOptions = {}) {\n const priceChart = master;\n if (opts.pane !== \"new\") {\n const overlay = await addIndicatorToChart(priceChart, preset, opts);\n return { ...overlay, chart: priceChart };\n }\n\n const source = resolveSourceSeries(priceChart, opts.sourceSeriesId);\n const { x, prices } = extractPriceSeries(source);\n const paneConfig = await buildIndicatorPaneFromPreset(preset, x, prices, {\n id: opts.id ?? preset,\n label: opts.label ?? preset.toUpperCase(),\n height: opts.paneHeight ?? 0.25,\n showXAxis: opts.showXAxis,\n period: opts.period,\n fastPeriod: opts.fastPeriod,\n slowPeriod: opts.slowPeriod,\n signalPeriod: opts.signalPeriod,\n stdDev: opts.stdDev,\n }, source);\n\n const chart = mountPane(paneConfig);\n return {\n id: paneConfig.id,\n preset,\n placement: \"oscillator\" as const,\n seriesIds: paneConfig.series?.map((s) => s.id) ?? [],\n paneId: paneConfig.id,\n chart,\n };\n },\n destroy() {\n if (resizeRaf) cancelAnimationFrame(resizeRaf);\n if (dragLayoutRaf) cancelAnimationFrame(dragLayoutRaf);\n resizeObserver.disconnect();\n paneResizeCtrl?.destroy();\n group.destroy();\n for (const c of paneCharts.values()) c.destroy();\n paneCharts.clear();\n container.replaceChildren();\n },\n };\n\n return stack;\n}\n"],"names":["interleaveBarData","x","y","barWidth","result","halfWidth","i","xi","yi","base","x0","x1","y0","y1","calculateBarWidth","minSpacing","spacing","computeSankeyLayout","data","style","plotArea","nodes","links","nodeWidth","nodePadding","palette","linkOpacity","showLabels","zoomFactor","effectiveWidth","effectiveHeight","offsetX","offsetY","workingArea","allNodeIds","l","nodeIds","nodeLevels","targets","id","changed","srcLevel","currentDstLevel","newDstLevel","maxLevel","layers","nodeInValue","nodeOutValue","getNodeValue","maxLayerTotal","layerNodes","layerTotal","nodeRegistry","numLayers","horizontalSpacing","lIdx","nodeHeights","layerHeightSum","val","h","totalPadding","totalContentHeight","currentY","nIdx","height","color","found","n","sourceOffsets","targetOffsets","linkLayouts","link","src","dst","sOffset","tOffset","sValue","tValue","srcFlowHeight","dstFlowHeight","findEndIndex","at","end","sliceField","arr","sliceSeriesData","filterSeriesAtTimestamp","series","s","_a","Series","buildYAxisLayouts","_plotArea","yAxes","yAxisOptionsMap","primaryYAxisId","entries","leftOffset","rightOffset","axisWidth","ids","ordered","scale","opts","position","offset","safeChartAlerts","chart","buildSVGExportContext","input","options","captureLayoutSnapshot","exportOptions","rect","hoveredId","reorderForHoveredSeries","syncScalesForRender","_b","_d","_c","_e","_f","_g","dashArrayToSvg","dash","gridMajorStyle","theme","gridMinorStyle","axisLineStyle","orientation","axis","axisTickStyle","axisLabelStyle","strokeAttrs","parts","textAttrs","anchor","baseline","exportGrid","ctx","builder","yScale","primaryYScale","xScale","xTickCount","yTickCount","xTicks","resolveGridXTicks","yTicks","major","tick","snapLineCoord","fmt","minor","minorXTicks","generateMinorTicks","minorYTicks","exportAxes","exportXAxis","layout","exportYAxis","xAxisOptions","resolveXTicks","axisY","showLine","showTicks","domainSpan","labelStyle","tickStyle","visibleTicks","snapLabelCoord","label","formatXTickValue","rotateLabels","approxWidth","t","item","labelY","escapeXml","xLabel","titleY","axisX","tickDir","labelX","formatYTickValue","titleGap","titleX","rotation","exportTitle","fontSize","fontFamily","fontWeight","align","padding","padTop","padBottom","exportPlotBorder","symbolSvg","symbol","cx","cy","size","fill","opacity","stroke","r","fillAttr","strokeAttr","pts","outer","inner","exportLegend","legend","items","legendWidth","legendHeight","itemY","swatchX","centerY","centerX","type","seriesId","fallback","exportErrorBarsForSeries","errorStyle","lineWidth","capWidth","showCaps","direction","clipId","yError","errorMinus","errorPlus","yBase","yTop","yBottom","xError","xBase","xRight","xLeft","exportErrorBars","resolveYScale","detectSpecialChart","hasPolarSeries","hasGaugeSeries","hasSankeySeries","maxRadius","polarAngleMode","polarRadialDivisions","polarAngularDivisions","polarData","detectSpecialChartFromContext","exportPolarGrid","radialDivisions","angularDivisions","angleMode","grid","corners","maxPixelRadius","corner","dist","radiusPixels","angleStep","angle","getRadarSVGExportData","radarPlugin","hasActiveRadarPlugin","shouldSkipCartesianOverlays","isSpecialSeriesChart","allYHidden","exportCursor","cursor","exportSelection","selection","exportPriceAlerts","alerts","alert","exportAllOverlays","special","skipCartesian","collectFiniteIndices","y2","out","buildLineSegments","indices","segments","current","prev","buildStepPoints","stepMode","points","mode","px","py","prevPx","prevPy","midX","exportLineSeries","width","dashAttr","lineJoin","exportScatterPoints","skipLine","pointSize","exportScatterSeries","exportBarSeries","barWidthData","barWidthPx","p0","yHeight","exportBandSeries","fillOpacity","j","exportCandlestickSeries","bw","bullishColor","bearishColor","hollow","isBull","pyOpen","pyClose","pyHigh","pyLow","HEATMAP_CELL_BUDGET","heatmapColor","value","min","max","colormap","g","b","v","exportHeatmapSeries","hm","xValues","yValues","zValues","nx","ny","cellCount","colorScale","zMin","zMax","xStep","yStep","xHalf","yHalf","z","xLo","xHi","yLo","yHi","left","top","w","dataToPixelPoints","cartesian","exportPolarSeries","polar","closePath","fillData","interleavePolarFillData","numTriangles","lineData","interleavePolarLineData","exportGaugeSeries","radius","startAngle","endAngle","arcPath","a0","a1","large","trackColor","fillColor","valueAngle","needleLen","exportSankeySeries","entry","x2","y3","cpOffset","gradId","node","nodeName","isFirstLayer","isLastLayer","exportTernarySeries","_xScale","_yScale","ax","ay","side","v0","v1","v2","a","c","exportWaterfallSeries","positiveColor","negativeColor","subtotalColor","connectorColor","types","running","prevTop","exportBoxplotSeries","boxWidth","q1","q3","low","high","yQ1","yQ3","yMed","yLow","yHigh","boxTop","boxH","outliers","o","toF32","splitSignedHistogram","hist","positive","negative","resolveLineRefY","ref","index","lines","other","splitLineIntoColorSegments","refAt","aboveColor","belowColor","colorAt","addPoint","flush","r0","r1","above0","above1","denom","xc","yc","colorBefore","colorAfter","pushColoredLineSeries","lineId","line","visible","segmentKey","zones","si","seg","p","DEFAULT_STYLE","buildIndicatorSeries","merged","fillId","barStyle","yData","peaks","m","troughs","createIndicatorSeries","detectIndicatorMarkers","window","xArr","yArr","markers","isPeak","isTrough","exportIndicatorSeries","indicatorOpts","childOptions","child","mockSeries","registry","register","exporter","pa","xs","ys","_xs","_ys","exportAllSeries","warned","arrowMarkers","arrowMarkerId","map","dataToPixel","yAxisId","exportAnnotationToSVG","annotation","elements","clip","lx","p1","yMin","yMax","from","to","markerId","el","exportAnnotations","annotations","sorted","ann","exportCandlestickMarkers","marker","idx","bestDist","d","isBuy","labelAnchor","labelBaseline","exportRadarChart","maxRadiusPixels","numCategories","gridColor","gridWidth","gridDash","level","labelRadius","ly","labelColor","labelSize","labelFamily","exportRadarSeries","dataPts","cat","point","pluginExporters","registerSVGPluginExporter","pluginName","runSVGPluginExporters","collectPluginSVGData","pluginManager","annPlugin","manager","radarData","exportWatermark","text","exportGridHighlight","bands","band","renderSVG","SVGDocumentBuilder","pluginCtx","buildIndicatorPane","SYNC_THRESHOLD","pool","preferSync","computeIndicatorSync","task","start","rsi","sma","ema","macd","bollingerBands","getPool","WorkerPool","toTypedArray","toPublicResult","runIndicator","fullTask","nextTaskId","started","rsiAsync","period","smaAsync","emaAsync","macdAsync","fastPeriod","slowPeriod","signalPeriod","bollingerBandsAsync","stdDev","destroyIndicatorPool","normalizePreset","name","extractPriceSeries","source","prices","extractOhlcSeries","open","close","resolveSourceSeries","sourceSeriesId","preferred","computeIndicatorPreset","preset","kind","values","fast","slow","signal","upper","lower","ohlc","kPeriod","dPeriod","stochastic","removeIndicatorSeries","rootId","sid","computeIndicatorFromSeries","addIndicatorToChart","computed","expanded","seriesIds","buildIndicatorPaneFromPreset","STACKED_MAX_PANES","STACKED_DEFAULT_MIN_PANE_RATIO","STACKED_COMPACT_MARGIN","STACKED_FULL_X_MARGIN","stackResolutionScale","res","loadImage","resolve","reject","img","relativeRect","containerRect","exportStackImage","container","paneWrappers","paneCharts","dividers","backgroundColor","format","quality","resolution","includeBackground","includeDividers","transparent","exportDpr","originalDprs","outW","outH","canvas","imageType","dataUrl","divider","mime","relativeOffset","buildStackPaneLayouts","wrapper","composeStackSVG","bg","includeBg","layouts","exportStackSVG","DIVIDER_CLASS","RESIZING_CLASS","injectDividerStyles","measurePaneSizes","isHorizontal","resolveDragStartSizes","onDragStart","leadingIdx","trailingIdx","createDividerElement","handle","paneFlexStyle","ratio","minDim","resolveMinPaneHeightPx","availHeight","paneCount","minPaneRatio","minPanePx","byRatio","minH","resolveMinPaneWidthPx","availWidth","normalizePaneHeights","heightsPx","targetTotal","total","sum","even","scaled","allocated","attachPaneResize","paneIds","ratios","dividerSize","minPaneSize","avail","cleanups","availableSize","dividerTotal","main","applyRatios","delta","sizesPx","minS","othersSum","pairTotal","leadingSize","trailingSize","byId","onPointerDown","e","lastCoord","onMove","ev","coord","onUp","fn","applyPaneFlexRatios","initialPaneRatio","tickCountForPaneHeight","heightPx","adaptive","tickCountForPaneWidth","widthPx","readBaseYTickCount","yAxis","adaptPaneAxes","meta","adaptAllPaneAxes","metas","countYAxes","axes","right","computeAlignedLeftMargin","panes","baseLeft","maxExtra","pane","computeAlignedRightMargin","baseRight","normalizePaneRatios","expandPaneSeries","buildPaneChartOptions","chartContainer","stack","alignedMargins","showXAxis","showYAxis","stackRenderer","sharedTimeXAxis","isFirst","isLast","compactX","compactY","compactMargin","margins","baseX","xAxis","baseY","yAxisOption","paneChart","_h","_i","_j","_k","mergeLayoutOptions","_l","_m","_o","_n","paneChartDivStyle","wrapperStyle","gap","gapStyle","resolveStackSyncOptions","sync","masterPaneId","createStackedChart","sharedXAxis","sharedYAxis","resizableOpt","resizable","resizeDividerSize","masterPaneConfig","baseLayout","MARGINS","baseTop","alignedLeft","alignedRight","hostInlineHeight","hostInlineWidth","hostInlineMinHeight","hostInlineMinWidth","measuredHeight","paneRatios","paneAxisMetas","paneResizeCtrl","isPaneDragging","resizeRaf","dragLayoutRaf","pendingDragLayout","commitPaneLayout","affected","_","scheduleStackResize","resizeObserver","applyFlexCss","stackAvailSize","restorePaneChartDivs","chartDiv","initDragSizes","measured","applyDragPaneSizes","normalized","dim","flushDragLayout","sizes","scheduleDragLayout","syncRatiosFromSizes","totalR","setAllChartsResizeSuspended","suspended","setInactiveChartsResizeSuspended","topIdx","bottomIdx","alignedBottom","createChart","seriesList","rebuildPaneResize","resizeOpts","finalSizes","master","group","createChartGroup","getBackgroundColor","waitForStackReady","poll","q","getInitQueueStatus","runStackExport","svg","ext","mountPane","prevId","prevChart","prevMeta","newRatio","syncOpts","priceChart","paneConfig"],"mappings":";;;;;;;AASO,SAASA,GACdC,GACAC,GACAC,GACc;AACd,QAAM,IAAI,KAAK,IAAIF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