import { CortexFormControl, default as CortexElement } from '../../../../base/src/cortex-element.ts';
import { ColorFormat } from '../../../../types/src/color-picker';
import { CSSResultGroup } from 'lit';
import { default as CxButton } from '../button/button';
import { default as CxButtonGroup } from '../button-group/button-group';
import { default as CxDropdown } from '../dropdown/dropdown';
import { default as CxIcon } from '../icon/icon';
import { default as CxInput } from '../input/input';
import { default as CxSpinner } from '../spinner/spinner';
import { default as CxVisuallyHidden } from '../visually-hidden/visually-hidden';

/**
 * @summary Color pickers allow the user to select a color.
 *
 * @slot label - The color picker’s form label. Alternatively, you can use the `label` attribute.
 * @slot trigger - The color picker’s trigger button. If not provided, by default it is a circle button that shows the currently selected color.
 *
 * @event cx-blur - Emitted when the color picker loses focus.
 * @event cx-change - Emitted when the color picker’s value changes.
 * @event cx-focus - Emitted when the color picker receives focus.
 * @event cx-input - Emitted when the color picker receives input.
 * @event cx-invalid - Emitted when the form control has been checked for validity and its constraints aren’t satisfied.
 * @event {{ color: string }} cx-swatch-add - Emitted when the current color is added to the list of custom swatches.
 * @event cx-clear - Emitted when the clear button is activated.
 *
 * @csspart base - The component’s base wrapper.
 * @csspart trigger - The color picker’s dropdown trigger.
 * @csspart swatches - The container that holds the swatches.
 * @csspart custom-swatches - The container that holds the custom swatches.
 * @csspart swatch-add-button - The button that emits `cx-swatch-add` on click.
 * @csspart swatch - Each individual swatch.
 * @csspart loading-spinner - The container that holds the loading spinner.
 * @csspart grid - The color grid.
 * @csspart grid-handle - The color grid’s handle.
 * @csspart slider - Hue and opacity sliders.
 * @csspart slider-handle - Hue and opacity slider handles.
 * @csspart hue-slider - The hue slider.
 * @csspart hue-slider-handle - The hue slider’s handle.
 * @csspart opacity-slider - The opacity slider.
 * @csspart opacity-slider-handle - The opacity slider’s handle.
 * @csspart preview - The preview color.
 * @csspart input - The text input.
 * @csspart eye-dropper-button - The eye dropper button.
 * @csspart eye-dropper-button__base - The eye dropper button’s exported `button` part.
 * @csspart eye-dropper-button__prefix - The eye dropper button’s exported `prefix` part.
 * @csspart eye-dropper-button__label - The eye dropper button’s exported `label` part.
 * @csspart eye-dropper-button__suffix - The eye dropper button’s exported `suffix` part.
 * @csspart eye-dropper-button__caret - The eye dropper button’s exported `caret` part.
 * @csspart format-button - The format button.
 * @csspart format-button__base - The format button’s exported `button` part.
 * @csspart format-button__prefix - The format button’s exported `prefix` part.
 * @csspart format-button__label - The format button’s exported `label` part.
 * @csspart format-button__suffix - The format button’s exported `suffix` part.
 * @csspart format-button__caret - The format button’s exported `caret` part.
 *
 * @cssproperty --grid-width - The width of the color grid.
 * @cssproperty --grid-height - The height of the color grid.
 * @cssproperty --grid-handle-size - The size of the color grid’s handle.
 * @cssproperty --slider-height - The height of the hue and alpha sliders.
 * @cssproperty --slider-handle-size - The diameter of the slider’s handle.
 * @cssproperty --swatch-size - The size of each predefined color swatch.
 * @cssproperty --format-button-width - The width of the format button.
 * @cssproperty --eye-dropper-button-width - The width of the eye dropper button.
 * @cssproperty --control-border-color - The border color of button variant's control.
 * @cssproperty [--inline-border] - Border for `inline` pickers (defaults to the panel border token); set to `none` to remove the frame.
 * @cssproperty --control-button-color - The background color of button variant's control.
 * @cssproperty --control-caret-color - The color of button variant's control's caret.
 */
export default class CxColorPicker extends CortexElement implements CortexFormControl {
    static readonly styles: CSSResultGroup;
    static readonly dependencies: {
        'cx-button': typeof CxButton;
        'cx-button-group': typeof CxButtonGroup;
        'cx-dropdown': typeof CxDropdown;
        'cx-icon': typeof CxIcon;
        'cx-input': typeof CxInput;
        'cx-spinner': typeof CxSpinner;
        'cx-visually-hidden': typeof CxVisuallyHidden;
    };
    private readonly formControlController;
    private isSafeValue;
    private readonly localize;
    base: HTMLElement;
    input: CxInput;
    opacityInput: CxInput;
    dropdown: CxDropdown;
    previewButton: HTMLButtonElement;
    trigger: HTMLButtonElement;
    private hasFocus;
    private isDraggingGridHandle;
    private isEmpty;
    private inputColorValue;
    private inputOpacityValue;
    private hue;
    private saturation;
    private brightness;
    private alpha;
    /**
     * The current value of the color picker. The value's format will vary based the `format` attribute. To get the value
     * in a specific format, use the `getFormattedValue()` method. The value is submitted as a name/value pair with form
     * data.
     */
    value: string;
    /** The default value of the form control. Primarily used for resetting the form control. */
    defaultValue: string;
    /**
     * The color picker's label. This will not be displayed, but it will be announced by assistive devices. If you need to
     * display HTML, you can use the `label` slot` instead.
     */
    label: string;
    /** The variant of the form control. */
    variant: 'default' | 'button';
    /**
     * The format to use. If opacity is enabled, these will translate to HEXA, RGBA, HSLA, and HSVA respectively. The color
     * picker will accept user input in any format (including CSS color names) and convert it to the desired format.
     */
    format: ColorFormat;
    /**
     * The available formats that can be toggled through using the format button.
     * Pass a semicolon-separated string (e.g., "hex;rgb;hsl") or an array of format values to limit the options.
     */
    formats: ColorFormat | ColorFormat[];
    /**
     * Normally the color picker will emit the value in the format specified by the `format` attribute.
     * If you want to emit the value in a different format, you can use the `emitFormat` attribute.
     */
    emitFormat: ColorFormat | undefined;
    /** Renders the color picker inline rather than in a dropdown. */
    inline: boolean;
    /** Determines the size of the color picker's trigger. This has no effect on inline color pickers. */
    size: 'small' | 'medium' | 'large';
    /** Removes the button that lets users toggle between format.   */
    noFormatToggle: boolean;
    /** The name of the form control, submitted as a name/value pair with form data. */
    name: string;
    /** Disables the color picker. */
    disabled: boolean;
    /**
     * Enable this option to prevent the panel from being clipped when the component is placed inside a container with
     * `overflow: auto|scroll`. Hoisting uses a fixed positioning strategy that works in many, but not all, scenarios.
     */
    hoist: boolean;
    /** Shows the opacity slider. Enabling this will cause the formatted value to be HEXA, RGBA, or HSLA. */
    opacity: boolean;
    /** By default, values are lowercase. With this attribute, values will be uppercase instead. */
    uppercase: boolean;
    /** Adds a clear button when the input is not empty. */
    clearable: boolean;
    tooltip: string;
    /**
     * One or more predefined color swatches to display as presets in the color picker. Can include any format the color
     * picker can parse, including HEX(A), RGB(A), HSL(A), HSV(A), and CSS color names. Each color must be separated by a
     * semicolon (`;`). Alternatively, you can pass an array of color values to this property using JavaScript.
     */
    swatches: string | string[];
    /**
     * Similar to swatches, but for user-defined custom colors.
     */
    customSwatches: string | string[];
    /**
     *Set to true to display a loading spinner.
     */
    loading: boolean;
    /**
     * Set to true to display a button that allows user to add current color to custom swatches.
     */
    creatable: boolean;
    /**
     * By default, form controls are associated with the nearest containing `<form>` element. This attribute allows you
     * to place the form control outside of a form and associate it with the form that has this `id`. The form must be in
     * the same document or shadow root for this to work.
     */
    form: string | HTMLElement | undefined;
    /** Makes the color picker a required field. */
    required: boolean;
    /**
     * Pairing value with emitFormat attribute. This is used to emit the value in a wanted format.
     */
    emitValue: string;
    /** Gets the validity state object */
    get validity(): ValidityState;
    /** Gets the validation message */
    get validationMessage(): string;
    constructor();
    runFirstUpdated(): void;
    private handleCopy;
    private handleFocusIn;
    private handleFocusOut;
    private handleFormatToggle;
    private handleAlphaDrag;
    private handleHueDrag;
    private handleGridDrag;
    private handleAlphaKeyDown;
    private handleHueKeyDown;
    private handleGridKeyDown;
    private handleInputChange;
    private handleInputInput;
    private debouncedSetColor;
    private handleInputKeyDown;
    private handleInputInvalid;
    private handleOpacityInputChange;
    private handleOpacityInputInput;
    private setOpacity;
    private handleOpacityInputKeyDown;
    private handleTouchMove;
    private handleClear;
    private parseColor;
    private setColor;
    private setLetterCase;
    private syncValues;
    private handleAfterHide;
    private handleEyeDropper;
    private handleSwatchAdd;
    private selectSwatch;
    /** Generates a hex string from HSV values. Hue must be 0-360. All other arguments must be 0-100. */
    private getHexString;
    /**
     * Extracts the color format from a value string.
     * @param value - The value string to extract the format from.
     * @returns The color format.
     */
    private getFormatFromValue;
    private stopNestedEventPropagation;
    handleFormatChange(): void;
    handleOpacityChange(): void;
    handleValueChange(oldValue: string | undefined, newValue: string): void;
    /** Sets focus on the color picker. */
    focus(options?: FocusOptions): void;
    /** Removes focus from the color picker. */
    blur(): void;
    /** Returns the current value as a string in the specified format. */
    getFormattedValue(format?: 'hex' | 'hexa' | 'rgb' | 'rgba' | 'hsl' | 'hsla' | 'hsv' | 'hsva'): string;
    /** Checks for validity but does not show a validation message. Returns `true` when valid and `false` when invalid. */
    checkValidity(): boolean;
    /** Gets the associated form, if one exists. */
    getForm(): HTMLFormElement | null;
    /** Checks for validity and shows the browser's validation message if the control is invalid. */
    reportValidity(): boolean;
    /** Sets a custom validation message. Pass an empty string to restore validity. */
    setCustomValidity(message: string): void;
    renderSwatches(swatches: string[]): ("" | import('lit').TemplateResult<1>)[];
    render(): import('lit').TemplateResult<1>;
}
declare global {
    interface HTMLElementTagNameMap {
        'cx-color-picker': CxColorPicker;
    }
}
