import * as react from 'react';
import { ReactNode } from 'react';
import { CSSVariablesResolver, MantineThemeOverride } from '@mantine/core';

/** Flat + per-scheme override pattern. Flat values apply to both; `light`/`dark` win over flat. */
type WithSchemes<T> = T & {
    light?: T;
    dark?: T;
};
/**
 * Theme token overrides. Each key maps 1:1 to a CSS variable.
 * All optional — defaults come from Elevasis design system.
 */
interface ElevasisTokenOverrides {
    primary?: string;
    /** Text color that contrasts with `primary`. Defaults to '#fff'. */
    primaryContrast?: string;
    background?: string;
    surface?: string;
    surfaceHover?: string;
    /** Opaque surface for floating overlays (modals, menus, popovers) — guarantees readable contrast against decorative backgrounds. */
    elevatedSurface?: string;
    text?: string;
    textDimmed?: string;
    textSubtle?: string;
    border?: string;
    error?: string;
    warning?: string;
    success?: string;
    glassBackground?: string;
    glassBlur?: string;
    shadow?: string;
    cardShadow?: string;
    durationFast?: string;
    durationNormal?: string;
    easing?: string;
    /** Foreground text color for destructive/error buttons. Defaults to '#fff'. */
    destructiveFg?: string;
    /** Heading font family — used for titles, section headers. */
    fontHeading?: string;
    /** Body font family — used for general text. */
    fontSans?: string;
}
/**
 * Core theme config — Mantine-free.
 * Used by ElevasisCoreProvider and as the base for ElevasisThemeConfig.
 */
interface ElevasisCoreThemeConfig {
    /** Color scheme: 'light', 'dark', or 'auto'. Defaults to 'dark'. */
    colorScheme?: 'light' | 'dark' | 'auto';
    /** Named preset — bundles light/dark token defaults. Defaults to 'default'. Accepts built-in PresetName or custom preset key. */
    preset?: PresetName | (string & {});
    /**
     * Semantic token overrides fed into CSS variables.
     * Flat values apply to both schemes. `light`/`dark` nested values win over flat.
     */
    tokens?: WithSchemes<ElevasisTokenOverrides>;
    /** Custom presets map — when provided, used instead of built-in presets. Typically `{ ...presets, ...customPresets }`. */
    presets?: Record<string, ThemePreset>;
}

/** Framework-agnostic theme overrides bundled with a preset (fonts, radius, component styles). */
interface FrameworkThemeOverrides {
    fontFamily?: string;
    defaultRadius?: string;
    headings?: {
        fontFamily?: string;
        fontWeight?: string;
    };
    components?: Record<string, unknown>;
}
/** Tokens every preset must define. `elevatedSurface` is progressively adopted and stays optional. */
type PresetTokens = Required<Omit<ElevasisTokenOverrides, 'elevatedSurface'>> & Pick<ElevasisTokenOverrides, 'elevatedSurface'>;
interface ThemePreset {
    light: PresetTokens;
    dark: PresetTokens;
    /** Optional framework theme overrides bundled with this preset (fonts, radius, etc.). */
    framework?: FrameworkThemeOverrides;
    /**
     * Subtitle font family — used for card names, section labels, and nav items.
     * Sits between heading and body in the typographic hierarchy.
     */
    subtitleFontFamily?: string;
    /** Google Fonts URLs to load when this preset is active. */
    fontImports?: string[];
    /** Display label for settings UI (e.g. "Tactical"). Built-in presets define this; custom presets must provide it. */
    label?: string;
    /** Short description for settings UI (e.g. "Tactical command center aesthetic"). */
    description?: string;
    /** Three representative hex colors for swatch display: [primary, dark-bg, light-bg]. */
    colors?: [string, string, string];
    /**
     * Background layers rendered behind app content when this preset is active.
     * Overridden by `theme.background` on the provider if both are set.
     */
    background?: ReactNode;
    /**
     * Loader element used in loading states when this preset is active.
     * Overridden by `theme.loader` on the provider if both are set.
     */
    loader?: ReactNode;
}
type PresetName = 'default' | 'tactical' | 'regal' | 'cyber-volt' | 'aurora' | 'rose-gold' | 'midnight' | 'titanium' | 'canopy' | 'slate' | 'cyber-strike' | 'cyber-chrome' | 'cyber-void' | 'nirvana' | 'wave' | 'synapse' | 'cortex' | 'helios' | 'graphite' | 'quarry';

/** 10-shade color tuple (light → dark), compatible with Mantine's color format. */
type ColorShadesTuple = [string, string, string, string, string, string, string, string, string, string];
/**
 * Generate a 10-shade Mantine color tuple from a single hex color.
 * Input color maps to shade 6 (Mantine's default primary shade).
 * Shades 0-5 are progressively lighter, 7-9 are progressively darker.
 */
declare function generateShades(hex: string): ColorShadesTuple;

declare const PRESETS: Record<PresetName, ThemePreset>;

/** Look up a preset by name. Falls back to default preset for unknown names. */
declare function getPreset(name: PresetName | (string & {}), presetsMap?: Record<string, ThemePreset>): ThemePreset;

/** Token key → CSS variable name. Single source of truth for the mapping. */
declare const TOKEN_VAR_MAP: Record<keyof ElevasisTokenOverrides, string>;
/**
 * Creates a CSS variables resolver from theme config.
 *
 * Merge order per scheme: PRESET_DEFAULTS → flat overrides → scheme-specific overrides
 */
declare function createCssVariablesResolver(tokens?: ElevasisCoreThemeConfig['tokens'], preset?: PresetName | (string & {}), presetsMap?: Record<string, ThemePreset>): CSSVariablesResolver;

declare const mantineThemeOverride: MantineThemeOverride;

declare const componentThemes: MantineThemeOverride['components'];

declare const PresetsProvider: react.Provider<Record<string, ThemePreset>>;
declare function usePresetsContext(): Record<string, ThemePreset>;

/** Preset entry with display metadata for settings UI. */
interface PresetEntry {
    /** Preset key (e.g. 'tactical', 'my-custom-brand'). */
    value: string;
    /** Display label (e.g. 'Tactical'). Falls back to titlecased key. */
    label: string;
    /** Short description. Falls back to empty string. */
    description: string;
    /** Three representative hex colors for swatch: [primary, dark-bg, light-bg]. Falls back to preset's dark/light primary + backgrounds. */
    colors: [string, string, string];
    /** True for presets not in the built-in PresetName union. */
    isCustom: boolean;
}
/** Returns all available presets as UI-ready entries. */
declare function useAvailablePresets(): PresetEntry[];

export { PresetsProvider, TOKEN_VAR_MAP, componentThemes, createCssVariablesResolver, generateShades, getPreset, mantineThemeOverride, PRESETS as presets, useAvailablePresets, usePresetsContext };
export type { ColorShadesTuple, FrameworkThemeOverrides, PresetEntry, PresetName, ThemePreset };
