import type { VariableConfig } from './variables';
/** absolute: fixed value; percentage: 0-100% of [min, max] range */
export type ThresholdMode = 'absolute' | 'percentage';
export interface Threshold {
    value: number;
    color: string;
    label: string;
}
export interface MockDataSource {
    type: 'mock';
    metric: string;
    pattern: MetricPattern;
    seriesCount: number;
    labels?: string[];
    liveAmplitude?: number;
}
export type MetricPattern = 'sine' | 'spike' | 'step' | 'sawtooth' | 'noise' | 'trend-up' | 'trend-down' | 'plateau' | 'random-walk' | 'live';
export type ZabbixQueryType = 'metrics' | 'text' | 'services' | 'itemid' | 'triggers' | 'problems' | 'macros' | 'lld';
export type ZabbixShowProblems = 'problems' | 'recent' | 'history';
export type ArgusSignal = 'metrics' | 'logs' | 'traces';
export type ArgusFieldContext = 'tag' | 'resource' | 'scope';
export type ArgusFieldDataType = 'string' | 'float64' | 'int64' | 'bool';
export interface ArgusField {
    name: string;
    fieldDataType: ArgusFieldDataType;
    fieldContext: ArgusFieldContext;
}
export interface ArgusFilter {
    expression: string;
}
export interface ArgusHaving {
    expression: string;
}
export interface ArgusOrderItem {
    key: {
        name: string;
    };
    direction: 'asc' | 'desc';
}
export interface ArgusFunction {
    name: string;
    args: Array<{
        value: string;
    }>;
}
export type ArgusMetricType = 'sum' | 'gauge' | 'histogram' | 'exponential_histogram' | 'summary';
export interface MetricsAggregation {
    metricName: string;
    metricType: ArgusMetricType | '';
    timeAggregation: string;
    spaceAggregation: string;
}
export interface ExpressionAggregation {
    expression: string;
}
export interface ArgusBuilderQuerySpec {
    name: string;
    signal: ArgusSignal;
    source?: string;
    stepInterval: number | null;
    disabled: boolean;
    filter: ArgusFilter;
    having?: ArgusHaving;
    groupBy: ArgusField[];
    limit?: number;
    order: ArgusOrderItem[];
    legend: string;
    functions: ArgusFunction[];
    aggregations: MetricsAggregation[] | ExpressionAggregation[];
}
export interface ArgusFormulaSpec {
    name: string;
    expression: string;
    disabled: boolean;
    limit?: number;
    legend: string;
    order: ArgusOrderItem[];
}
export type ArgusQueryType = 'builder' | 'promql' | 'clickhouse_sql';
export type ArgusQueryItem = {
    type: 'builder_query';
    spec: ArgusBuilderQuerySpec;
    queryType?: ArgusQueryType;
    rawQuery?: string;
    rawLegend?: string;
} | {
    type: 'builder_formula';
    spec: ArgusFormulaSpec;
};
export interface ArgusQueryDataSource {
    type: 'argus';
    datasourceId: string;
    queries: ArgusQueryItem[];
}
export interface FuncParam {
    name: string;
    type: 'string' | 'int' | 'float';
    options?: Array<string | number>;
    optional?: boolean;
}
export interface FuncDef {
    name: string;
    category: 'Transform' | 'Aggregate' | 'Filter' | 'Trends' | 'Time' | 'Alias' | 'Special';
    params: FuncParam[];
    defaultParams: Array<string | number>;
}
export interface MetricFunc {
    def: FuncDef;
    params: Array<string | number>;
    text: string;
    added?: boolean;
}
export interface ZabbixQueryOptions {
    useTrends?: string;
    showDisabledItems?: boolean;
    useZabbixValueMapping?: boolean;
    disableDataAlignment?: boolean;
    acknowledged?: number;
    sortProblems?: string;
    useTimeRange?: boolean;
    hostsInMaintenance?: boolean;
    hostProxy?: boolean;
    limit?: number;
}
export interface ZabbixDataSource {
    type: 'zabbix';
    datasourceId: string;
    queryType: ZabbixQueryType;
    groupId: string;
    groupName: string;
    hostId: string;
    hostName: string;
    appId: string;
    appName: string;
    itemIds: string[];
    itemNames: string[];
    textFilter: string;
    useCaptureGroups: boolean;
    itemTagsFilter: string;
    itemids: string;
    triggerFilter: string;
    tagsFilter: string;
    showProblems: ZabbixShowProblems;
    severities: number[];
    itServiceFilter: string;
    slaFilter: string;
    slaProperty: string;
    slaInterval: string;
    macroFilter: string;
    lldRuleId: string;
    lldRuleName: string;
    lldItemKeys: string[];
    functions: MetricFunc[];
    options: ZabbixQueryOptions;
}
export type PanelDataSource = MockDataSource | ZabbixDataSource | ArgusQueryDataSource;
export interface QueryEntry {
    id: string;
    enabled: boolean;
    dataSource: PanelDataSource;
}
export type PanelType = 'timeseries' | 'bar' | 'histogram' | 'stat' | 'gauge' | 'table' | 'pie';
export type ColorScheme = 'classic' | 'tableau10' | 'grafana-classic' | 'blues' | 'reds' | 'GrYlRd' | 'purple-orange' | 'green-yellow-red' | 'red-yellow-green' | 'blue-yellow-red' | 'blue-purple' | 'yellow-blue' | 'fixed' | 'thresholds';
export type ColorDistribution = 'sequential' | 'distributed';
export type LineInterpolation = 'linear' | 'smooth' | 'step';
export type LineStyle = 'solid' | 'dashed' | 'dotted';
export type DrawStyle = 'lines' | 'bars' | 'points';
export type GradientMode = 'none' | 'opacity' | 'hue' | 'scheme';
export type SpanNulls = boolean | number;
export type InsertNulls = boolean | number;
export type ShowPointsMode = 'auto' | 'always' | 'never';
export type StackingMode = 'none' | 'normal' | 'percent';
export type LegendPosition = 'bottom' | 'right' | 'hidden';
export type LegendMode = 'list' | 'table';
export type LegendValue = 'last' | 'first' | 'min' | 'max' | 'mean' | 'sum';
export type TooltipMode = 'single' | 'multi' | 'none';
export type TooltipSortOrder = 'none' | 'asc' | 'desc';
export type AxisPlacement = 'left' | 'right' | 'hidden';
export type GridLines = 'all' | 'x' | 'y' | 'hidden';
export type ScaleDistribution = 'linear' | 'logarithmic' | 'symlog';
export interface PanelConfig {
    id: string;
    type: PanelType;
    title: string;
    description: string;
    queries: QueryEntry[];
    queryOptions?: {
        maxDataPoints?: number;
        minIntervalMs?: number;
        relativeTime?: string;
        timeShift?: string;
    };
    colorScheme?: ColorScheme;
    colorSingleValue?: string;
    colorDistribution?: ColorDistribution;
    drawStyle?: DrawStyle;
    lineWidth: number;
    fillOpacity: number;
    gradientMode?: GradientMode;
    lineInterpolation: LineInterpolation;
    lineStyle: LineStyle;
    spanNulls?: SpanNulls;
    insertNulls?: InsertNulls;
    showPoints: boolean;
    showPointsMode?: ShowPointsMode;
    stackingMode?: StackingMode;
    legendPosition: LegendPosition;
    legendMode?: LegendMode;
    legendValues?: LegendValue[];
    unit: string;
    decimals: number | undefined;
    thresholds: Threshold[];
    thresholdBaseColor: string;
    thresholdMode?: ThresholdMode;
    tooltipMode?: TooltipMode;
    tooltipSort?: TooltipSortOrder;
    tooltipMaxHeight?: number;
    showAxisPointer?: boolean;
    softMin: number | null;
    softMax: number | null;
    logScale: boolean;
    axisPlacement?: AxisPlacement;
    axisName?: string;
    axisWidth?: number | null;
    showGridLines?: GridLines;
    gridColor?: string;
    axisLabel?: GridLines;
    axisLabelColor?: string;
    axisTick?: GridLines;
    axisTickColor?: string;
    axisBorder?: GridLines;
    axisBorderColor?: string;
    scaleDistribution?: ScaleDistribution;
    centeredZero?: boolean;
    stacked: boolean;
    barShowValues?: 'auto' | 'always' | 'never';
    barGroupWidth?: number;
    barWidth?: number;
    barXTickRotation?: boolean;
    barXTickMaxLength?: number;
    histBucketSize?: number;
    histBucketCount?: number;
    histBucketOffset?: number;
    histCombineSeries?: boolean;
    min: number;
    max: number;
    gaugeTrackWidth?: number;
    gaugeFillWidth?: number;
    gaugeTrackColor?: string;
    sweepAngle?: number;
    gaugeCapRound?: boolean;
    gaugeStartAngle?: number;
    gaugeEndAngle?: number;
    gaugeValueColor?: string;
    gaugeValueSize?: number;
    gaugeValueVisible?: boolean;
    gaugePaddingX?: number;
    gaugePaddingY?: number;
    gaugeColorFromScheme?: boolean;
    gaugeThresholdDisplay?: 'marker' | 'track' | 'none';
    gaugeThresholdLabelDisplay?: 'label' | 'value' | 'both' | 'none';
    gaugeOrientation?: 'auto' | 'horizontal' | 'vertical';
    gaugeValueOffsetY?: number;
    statValue?: number;
    statUnit?: string;
    statTrend?: 'up' | 'down' | 'flat';
    statReducer?: StatReducer;
    showPercentChange?: boolean;
    statOrientation?: 'vertical' | 'horizontal';
    statTextMode?: 'value_and_name' | 'value' | 'name' | 'none';
    statColorMode?: 'value' | 'background_solid' | 'background';
    links?: PanelLink[];
    pieType?: 'pie' | 'donut';
    pieSliceSorting?: 'desc' | 'asc' | 'none';
    pieLabels?: Array<'name' | 'percent' | 'value'>;
    pieShow?: 'calculate' | 'all';
    pieCalculation?: StatReducer;
    pieLimit?: number;
    tableShowHeader?: boolean;
    tableFrozenColumns?: number;
    tableCellHeight?: 'small' | 'medium' | 'large';
    tableEnablePagination?: boolean;
    tablePageSize?: number;
    tableMinColumnWidth?: number;
    tableColumnFilter?: boolean;
    tableWrapText?: boolean;
    tableFooterEnabled?: boolean;
    tableFooterReducers?: string[];
    tableFooterFields?: string[];
    fieldConfigOverrides?: FieldConfigOverrideRule[];
}
export type TableCellDisplayMode = 'auto' | 'colored-text' | 'colored-background' | 'gauge' | 'data-links' | 'json-view' | 'pill';
export type FieldMatcherType = 'byName' | 'byType' | 'byRegexp' | 'byFrameRefID';
export type OverridableFieldType = 'time' | 'number' | 'string' | 'boolean';
export interface FieldMatcherConfig {
    id: FieldMatcherType;
    options?: string;
}
export interface DynamicConfigValue {
    id: string;
    value?: unknown;
}
export interface FieldConfigOverrideRule {
    id: string;
    matcher: FieldMatcherConfig;
    properties: DynamicConfigValue[];
}
export type StatReducer = 'sum' | 'min' | 'max' | 'mean' | 'count' | 'countAll' | 'first' | 'last' | 'firstNotNull' | 'lastNotNull' | 'median' | 'range' | 'diff' | 'diffperc' | 'delta' | 'step' | 'logmin' | 'variance' | 'stdDev' | 'changeCount' | 'distinctCount' | 'allIsZero' | 'allIsNull' | `p${number}`;
export interface PanelLink {
    title: string;
    url: string;
    newTab: boolean;
}
export interface DashboardConfig {
    title: string;
    panels: Record<string, PanelConfig>;
    layouts: GridItem[];
    variables?: VariableConfig[];
}
export interface GridItem {
    i: string;
    x: number;
    y: number;
    w: number;
    h: number;
    minH?: number;
    minW?: number;
}
