import { ChartComparisonResult, ChartPercentagePolicy, ChartController, ChartSeries, ChartYConfig, ChartTooltipContext, NumericXConfig, TimeXConfig, ChartRange, ChartPinOptions } from '../types'; import { LegendSnapshot } from '../runtime/chart-runtime'; export type CartesianModelLegendItem = LegendSnapshot['series'][number] & { id: Id; }; export type CartesianModelObservation = LegendSnapshot['observations'][number] & { row: Row; }; export interface CartesianModelState { readonly availability: 'loading' | 'ready' | 'error'; readonly acceptedRevision: number; readonly inspection: ChartTooltipContext | null; readonly comparison: ChartComparisonResult | null; readonly visibleSeries: readonly SeriesId[]; readonly legend: readonly CartesianModelLegendItem[]; readonly observations: readonly CartesianModelObservation[]; } export interface CartesianModelFrame { readonly data: readonly Row[]; readonly x: TimeXConfig | NumericXConfig; readonly y?: ChartYConfig; readonly series: readonly (ChartSeries & { readonly id: Id; })[]; } export interface CartesianModelInput extends CartesianModelFrame { readonly status?: 'loading' | 'ready' | 'error'; readonly resetKey?: string | number; readonly control?: CartesianModelControl; } export interface CartesianModelControl { readonly inspection?: { readonly x: number; readonly pinned: boolean; } | null; readonly visibleSeries?: readonly Id[]; readonly comparison?: ChartRange | null; readonly onInspectionRequest?: (inspection: { readonly x: number; readonly pinned: boolean; } | null) => void; readonly onVisibleSeriesRequest?: (ids: readonly Id[]) => void; readonly onComparisonRequest?: (range: ChartRange | null) => void; } export interface CartesianSummaryQuery { readonly measure: Id; readonly scope?: ChartRange | null; readonly aggregate: 'sum' | 'mean' | 'min' | 'max' | 'first' | 'last' | 'change'; readonly missing?: 'exclude' | 'require-complete'; } export interface CartesianSummaryResult { readonly measure: Id; readonly value: number | null; readonly formattedValue: string; readonly unit: string | null; readonly coverage: { readonly observed: number; readonly missing: number; readonly total: number; }; readonly unavailableReason: string | null; } export interface CartesianModelActions { readonly inspect: (x: number) => void; readonly clearInspection: () => void; readonly pin: (x: number, options?: ChartPinOptions) => void; readonly release: () => void; readonly setVisibleSeries: (ids: readonly SeriesId[]) => void; readonly focusSeries: (id: SeriesId | null) => void; readonly compare: (range: ChartRange, percentage?: ChartPercentagePolicy) => void; readonly clearComparison: () => void; readonly focusComparison: () => void; readonly fullRange: () => void; } /** Carries the source row and declared series IDs across JSX component boundaries. */ export interface CartesianChartModel { readonly data: readonly Row[]; readonly x: TimeXConfig | NumericXConfig; readonly series: readonly (ChartSeries & { readonly id: SeriesId; })[]; readonly getFrame: () => CartesianModelFrame; readonly getAcceptedFrame: () => CartesianModelFrame | null; readonly getAvailability: () => CartesianModelState['availability']; readonly getResetKey: () => string | number | undefined; /** Internal view projection of persistent inspection, comparison and focus. */ readonly getController: () => ChartController; readonly update: (frame: CartesianModelInput) => void; readonly summarize: (query: CartesianSummaryQuery) => CartesianSummaryResult; readonly actions: CartesianModelActions; readonly getSnapshot: () => CartesianModelState; readonly subscribe: (listener: () => void) => () => void; } type ModelActions = { inspect: (x: number) => void; clearInspection: () => void; pin: (x: number, options?: ChartPinOptions) => void; release: () => void; setVisibleSeries: (ids: readonly string[]) => void; focusSeries: (id: string | null) => void; compare: (range: ChartRange) => void; clearComparison: () => void; focusComparison: () => void; fullRange: () => void; }; /** Internal publication from the accepted Cartesian plot; presentation never recalculates values. */ export declare function publishCartesianModel(model: CartesianChartModel, state: Pick, 'inspection' | 'comparison' | 'visibleSeries' | 'legend'>, actions: ModelActions): void; /** Release a view's callbacks without changing the model's accepted frame or persistent state. */ export declare function detachCartesianModel(model: CartesianChartModel): void; /** Subscribe from any React component that has the handle, including outside Chart. */ export declare function useCartesianModelState(model: CartesianChartModel): CartesianModelState; /** Define descriptors once; literal IDs and source-row metadata remain inferred. */ export declare function createCartesianChartModel>[]>({ data, x, y, series, status, resetKey, control, }: { readonly data: readonly Row[]; readonly x: TimeXConfig> | NumericXConfig>; readonly y?: ChartYConfig; readonly series: Series; readonly status?: 'loading' | 'ready' | 'error'; readonly resetKey?: string | number; readonly control?: CartesianModelControl; }): CartesianChartModel; /** Keep a Cartesian handle stable while ready input frames change. */ export declare function useCartesianChartModel>[]>(input: { readonly data: readonly Row[]; readonly x: TimeXConfig> | NumericXConfig>; readonly y?: ChartYConfig; readonly series: Series; readonly status?: 'loading' | 'ready' | 'error'; readonly resetKey?: string | number; readonly control?: CartesianModelControl; }, status?: 'ready' | 'loading' | 'error'): CartesianChartModel; export {};