import type { ChartPadding } from "./chart-types.js"; import { WebComponentBase } from "../web-component-base/web-component-base.js"; import { ChartGPURenderer } from "./gpu/chart-gpu-renderer.js"; /** Linearly maps a value from [domainMin, domainMax] to [rangeMin, rangeMax]. */ export declare const mapToRange: (value: number, domainMin: number, domainMax: number, rangeMin: number, rangeMax: number) => number; /** Generates an array of evenly spaced tick values between min and max (inclusive). */ export declare const generateTicks: (min: number, max: number, count: number) => number[]; /** Formats a number for axis labels (compact, no trailing zeroes). */ export declare const formatAxisValue: (value: number) => string; /** Formats a millisecond timestamp as a short date string (MM/DD). */ export declare const formatDateShort: (ms: number) => string; declare abstract class ChartBase extends WebComponentBase { /** The GPU renderer shared across frames. Created on first paint. */ protected gpuRenderer: ChartGPURenderer | null; /** WebGPU canvas context — configured on first paint. */ private _gpuCanvasCtx; /** Externally injected GPUDevice (e.g. from brainiac-engine). */ private _externalDevice; /** In-flight GPU init promise (prevents double-init). */ private _gpuInitPromise; /** Whether GPU init has completed (for fast sync path). */ private _gpuReady; constructor(); /** Inject an external GPUDevice (e.g. from brainiac-engine's presentation layer). */ set gpuDevice(device: GPUDevice | null); get gpuDevice(): GPUDevice | null; static get observedAttributes(): string[]; attributeChangedCallback(_name: string, _oldValue: string | null, _newValue: string | null): void; connectedCallback(): void; /** Returns the chart width from the attribute or a sensible default. */ getChartWidth(): number; /** Returns the chart height from the attribute or a sensible default. */ getChartHeight(): number; /** Returns the padding for the plot area. Subclasses may override. */ getPadding(): ChartPadding; /** Subclasses must implement the actual chart rendering here. */ abstract paint(): void; /** * Initialise the WebGPU device, canvas context, and renderer. * Called automatically on first paint. Safe to call multiple times * (returns cached promise on subsequent calls). */ protected initGPU(): Promise; private _doInitGPU; /** Get the current frame's texture view for endFrame(). */ protected getTargetView(): GPUTextureView | null; /** Creates or retrieves the canvas element inside the shadow root. * Sets width/height attributes to match chart dimensions. */ private _ensureGPUCanvas; /** Resolves a CSS variable from the host or returns the fallback. */ protected cssVar(name: string, fallback: string): string; /** Push a background rect covering the entire canvas. */ protected gpuDrawBackground(w: number, h: number, cssColor: string): void; /** Push horizontal grid lines in the plot area. */ protected gpuDrawHorizontalGrid(padding: ChartPadding, plotHeight: number, count: number, cssColor: string, canvasWidth: number): void; /** Push Y-axis tick labels (right-aligned to the left padding). */ protected gpuDrawYAxisLabels(padding: ChartPadding, ticks: number[], plotHeight: number, cssColor: string, fontSize: number): void; /** Parses a JSON attribute value, returning the fallback if parsing fails or the value is absent. */ protected parseJsonAttribute(name: string, fallback: T): T; } export { ChartBase as default, ChartBase };