/**
 * TypeScript декларации для Material Web Components (React 19 / Next.js 16)
 * Расширяем react/jsx-runtime для кастомных элементов.
 */
import type {
  DetailedHTMLProps,
  HTMLAttributes,
  InputHTMLAttributes,
  ButtonHTMLAttributes,
  SelectHTMLAttributes,
} from 'react';

declare module 'react/jsx-runtime' {
  namespace JSX {
    interface IntrinsicElements {
      // Buttons
      'md-filled-button': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement> & {
        type?: 'submit' | 'button' | 'reset';
        disabled?: boolean;
        href?: string;
        target?: string;
        trailingIcon?: boolean;
        variant?: string;
      };
      'md-outlined-button': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement> & {
        type?: 'submit' | 'button' | 'reset';
        disabled?: boolean;
        href?: string;
        target?: string;
        trailingIcon?: boolean;
        variant?: string;
      };
      'md-text-button': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement> & {
        type?: 'submit' | 'button' | 'reset';
        disabled?: boolean;
        href?: string;
        target?: string;
        trailingIcon?: boolean;
        variant?: string;
      };
      'md-elevated-button': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement> & {
        type?: 'submit' | 'button' | 'reset';
        disabled?: boolean;
        href?: string;
        target?: string;
        trailingIcon?: boolean;
        variant?: string;
      };
      'md-tonal-button': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement> & {
        type?: 'submit' | 'button' | 'reset';
        disabled?: boolean;
        href?: string;
        target?: string;
        trailingIcon?: boolean;
        variant?: string;
      };

      // Text Fields
      'md-filled-text-field': DetailedHTMLProps<InputHTMLAttributes<HTMLInputElement>, HTMLElement> & {
        label?: string;
        supportingText?: string;
        errorText?: string;
        error?: boolean;
        required?: boolean;
        disabled?: boolean;
        prefixText?: string;
        suffixText?: string;
        type?: string;
        value?: string;
      };
      'md-outlined-text-field': DetailedHTMLProps<InputHTMLAttributes<HTMLInputElement>, HTMLElement> & {
        label?: string;
        supportingText?: string;
        errorText?: string;
        error?: boolean;
        required?: boolean;
        disabled?: boolean;
        prefixText?: string;
        suffixText?: string;
        type?: string;
        value?: string;
      };
    'md-outlined-field': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement> & {
        label?: string;
        supportingText?: string;
        error?: boolean;
        required?: boolean;
        disabled?: boolean;
      };

      // Cards
      'md-filled-card': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
      'md-elevated-card': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
      'md-outlined-card': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;

      // Navigation
      'md-navigation-bar': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement> & {
        activeIndex?: number;
      };
      'md-navigation-tab': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement> & {
        label?: string;
        active?: boolean;
        inactiveIcon?: string;
        activeIcon?: string;
      };

      // Icons
      'md-icon': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement> & {
        font?: string;
      };
      'md-icon-button': DetailedHTMLProps<ButtonHTMLAttributes<HTMLButtonElement>, HTMLElement> & {
        disabled?: boolean;
        href?: string;
        target?: string;
        toggle?: boolean;
        selected?: boolean;
      };

      // Lists
      'md-list': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
      'md-list-item': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement> & {
        headline?: string;
        supportingText?: string;
        trailingSupportingText?: string;
      };

      // Dialogs
      'md-dialog': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement> & {
        open?: boolean;
        returnValue?: string;
        onCancel?: () => void;
      };

      // Chips
      'md-chip-set': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
      'md-assist-chip': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement> & {
        label?: string;
        selected?: boolean;
        disabled?: boolean;
        href?: string;
        target?: string;
      };

      // Form Controls
      'md-checkbox': DetailedHTMLProps<InputHTMLAttributes<HTMLInputElement>, HTMLElement> & {
        checked?: boolean;
        indeterminate?: boolean;
        disabled?: boolean;
        value?: string;
      };
      'md-switch': DetailedHTMLProps<InputHTMLAttributes<HTMLInputElement>, HTMLElement> & {
        checked?: boolean;
        disabled?: boolean;
        value?: string;
      };
      'md-filled-select': DetailedHTMLProps<SelectHTMLAttributes<HTMLSelectElement>, HTMLElement> & {
        label?: string;
        supportingText?: string;
        errorText?: string;
        error?: boolean;
        required?: boolean;
        disabled?: boolean;
        quick?: boolean;
        menuFixed?: boolean;
      };
      'md-select-option': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement> & {
        value?: string;
        selected?: boolean;
      };

      // Progress
      'md-circular-progress': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement> & {
        indeterminate?: boolean;
        value?: number;
        max?: number;
        fourColor?: boolean;
      };
      'md-linear-progress': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement> & {
        indeterminate?: boolean;
        value?: number;
        max?: number;
        buffer?: number;
        fourColor?: boolean;
      };

      // Badge
      'md-badge': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement> & {
        value?: string | number;
      };

      // Tabs
      'md-tabs': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement> & {
        activeTabIndex?: number;
        autoActivate?: boolean;
      };
      'md-primary-tab': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement> & {
        active?: boolean;
        inlineIcon?: boolean;
        isTab?: boolean;
        selected?: boolean;
      };
      'md-secondary-tab': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement> & {
        active?: boolean;
        inlineIcon?: boolean;
        isTab?: boolean;
        selected?: boolean;
      };
    }
  }
}
