// #region Imports
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
import { Themeable } from '../../../../Controls/Behaviors/Themeable';
import { Appearanceable } from '../../../Behaviors/Appearanceable';
import { Disableable } from '../../../Behaviors/Disableable';
import { Invalidable } from '../../../Behaviors/Invalidable';
import { Labelable } from '../../../Behaviors/Labelable';
import { TextFormattable } from '../../../Behaviors/TextFormattable';
import { Valueable } from '../../../Behaviors/Valueable';
import { Variantable } from '../../../Behaviors/Variantable';
import { Attribute } from '../../../Decorators/AttributeDecorator';
import { Component } from '../../../Decorators/ComponentDecorator';
import { LabelPosition } from '../../../Types/LabelPosition';
import { ToggableElement } from '../../Primitives/Abstracts/Toggable/ToggableElement';
import { CheckmarkElement } from '../../Primitives/Checkmark/CheckmarkElement';
import { FocusRingElement } from '../../Primitives/FocusRing/FocusRingElement';
import { TextElement } from '../../Primitives/Text/TextElement';
import { toggleSwitchElementCosmopolitanStyle } from './Themes/ToggleSwitchElement.Cosmopolitan';
import { toggleSwitchElementJoyStyle } from './Themes/ToggleSwitchElement.Joy';
import { toggleSwitchElementMemphisStyle } from './Themes/ToggleSwitchElement.Memphis';
import { toggleSwitchElementTemplate } from './ToggleSwitchElementTemplate';
// #endregion
/**
 * Toggle Switch - A binary input control for switching between on/off states with visual switch metaphor.
 *
 * @description
 * The Toggle Switch component provides an intuitive interface for binary choices, using a familiar physical
 * switch metaphor. Unlike checkboxes, toggle switches immediately apply state changes and are ideal for
 * settings that take effect instantly. Features include smooth animated transitions, accessibility support
 * with proper ARIA attributes, keyboard navigation, support for disabled states, and customizable appearance
 * with various themes. The component includes focus ring indication, label positioning options, and integrates
 * seamlessly with form validation systems. Perfect for preferences panels, feature toggles, notification
 * settings, and any interface requiring immediate binary state changes.
 *
 * @name Toggle Switch
 * @element mosaik-toggle-switch
 * @category Inputs
 *
 * @slot checkmark - Custom checkmark/switch indicator content.
 * @slot label - Custom label content.
 * @slot prefix - Content placed before the switch control.
 * @slot suffix - Content placed after the switch control.
 *
 * @csspart checkmark - The visual switch control.
 * @csspart focusRing - The focus ring indicator.
 * @csspart input - The hidden checkbox input element.
 * @csspart label - The text label element.
 *
 * @cssprop {String} --toggle-switch-background-color - The switch background color CSS custom property.
 * @cssprop {Color} --toggle-switch-border-color - The border color.
 * @cssprop {String} --toggle-switch-border-radius - The border radius.
 * @cssprop {String} --toggle-switch-border-style - The border style.
 * @cssprop {String} --toggle-switch-border-width - The border width.
 * @cssprop {String} --toggle-switch-font-family - The font family.
 * @cssprop {String} --toggle-switch-font-letter-spacing - The font letter spacing.
 * @cssprop {String} --toggle-switch-font-line-height - The font line height.
 * @cssprop {String} --toggle-switch-font-size - The font size.
 * @cssprop {String} --toggle-switch-font-text-decoration - The font text decoration.
 * @cssprop {String} --toggle-switch-font-text-transform - The font text transform.
 * @cssprop {String} --toggle-switch-font-weight - The font weight.
 * @cssprop {String} --toggle-switch-foreground-color - The switch foreground color CSS custom property.
 * @cssprop {String} --toggle-switch-gap - The gap between elements.
 * @cssprop {String} --toggle-switch-padding-bottom - The padding bottom.
 * @cssprop {String} --toggle-switch-padding-left - The padding left.
 * @cssprop {String} --toggle-switch-padding-right - The padding right.
 * @cssprop {String} --toggle-switch-padding-top - The padding top.
 * @cssprop {String} --toggle-switch-shadow - The switch shadow CSS custom property.
 * @cssprop {String} --toggle-switch-shadow-blur - The switch shadow blur CSS custom property.
 * @cssprop {String} --toggle-switch-shadow-color - The switch shadow color CSS custom property.
 * @cssprop {String} --toggle-switch-shadow-offset-x - The switch shadow offset x CSS custom property.
 * @cssprop {String} --toggle-switch-shadow-offset-y - The switch shadow offset y CSS custom property.
 * @cssprop {String} --toggle-switch-shadow-spread - The switch shadow spread CSS custom property.
 * @cssprop {String} --toggle-switch-transition-duration - The transition duration.
 * @cssprop {String} --toggle-switch-transition-mode - The switch transition mode CSS custom property.
 * @cssprop {String} --toggle-switch-transition-property - The switch transition property CSS custom property.
 * @cssprop {String} --toggle-switch-translate - The switch translate CSS custom property.
 *
 * @dependency mosaik-checkmark - Used for the visual switch control.
 * @dependency mosaik-focus-ring - Used for focus indication.
 * @dependency mosaik-text - Used for label display.
 *
 * @example
 * ```html
 * <mosaik-toggle-switch
 *   is-checked>
 * </mosaik-toggle-switch>
 * ```
 *
 * @public
 */
let ToggleSwitchElement = class ToggleSwitchElement extends Themeable(Invalidable(Valueable(Variantable(Appearanceable(Disableable(Labelable(TextFormattable(ToggableElement)))))))) {
    // #region Fields
    _inputElement;
    _labelPosition;
    _required;
    _name;
    // #endregion
    // #region Ctor
    /**
     * @public
     */
    constructor() {
        super();
        this._labelPosition = LabelPosition.After;
        this._required = false;
        this._name = '';
    }
    // #endregion
    // #region Properties
    /**
     * Returns the `is` property.
     * The `is` property represents natural name of this element.
     *
     * @public
     * @static
     * @override
     * @readonly
     */
    static get is() {
        return 'mosaik-toggle-switch';
    }
    /**
     * Gets or sets the `labelPosition` property.
     *
     * @public
     * @attr
     */
    get labelPosition() {
        return this._labelPosition;
    }
    set labelPosition(value) {
        if (this._labelPosition !== value) {
            this._labelPosition = value;
            this.requestUpdate('labelPosition');
        }
    }
    /**
     * Gets or sets the `required` property.
     *
     * @public
     * @attr
     */
    get required() {
        return this._required;
    }
    set required(value) {
        if (this._required !== value) {
            this._required = value;
            this.requestUpdate('required');
        }
    }
    /**
     * Gets or sets the `name` property.
     *
     * @public
     * @attr
     */
    get name() {
        return this._name;
    }
    set name(value) {
        if (this._name !== value) {
            this._name = value;
            this.requestUpdate('name');
        }
    }
    // #endregion
    // #region Methods
    /**
     * @public
     * @overload
     */
    connectedCallback() {
        super.connectedCallback();
        this.on('click', (event) => {
            event.stopPropagation();
            this.toggle();
        });
    }
    /**
     * Checks the validity of the element and returns `true` if it is valid; otherwise, `false`.
     *
     * @public
     * @override
     */
    checkValidity() {
        return this.shadowRoot
            ? this._inputElement.checkValidity()
            : false;
    }
    /**
     * Resets the element to its initial state.
     *
     * @public
     */
    reset() {
        this.isChecked = false;
        this.invalid = false;
    }
    /**
     * Checks the element.
     * If the element is disabled, nothing happens.
     *
     * @public
     * @override
     */
    check() {
        if (this.disabled) {
            return;
        }
        this._inputElement.focus();
        super.check();
    }
    /**
     * Unchecks the element.
     * If the element is disabled, nothing happens.
     *
     * @public
     * @override
     */
    uncheck() {
        if (this.disabled) {
            return;
        }
        this._inputElement.focus();
        super.uncheck();
    }
    /**
     * Toggles the element between checked and unchecked states.
     *
     * @public
     * @override
     */
    toggle() {
        if (this.disabled) {
            return;
        }
        this._inputElement.focus();
        super.toggle();
    }
    onApplyTemplate() {
        super.onApplyTemplate();
        this._inputElement = this.getTemplatePart('input');
    }
};
__decorate([
    Attribute({ type: LabelPosition }),
    __metadata("design:type", String),
    __metadata("design:paramtypes", [String])
], ToggleSwitchElement.prototype, "labelPosition", null);
__decorate([
    Attribute({
        type: Boolean,
        useDefault: true
    }),
    __metadata("design:type", Boolean),
    __metadata("design:paramtypes", [Boolean])
], ToggleSwitchElement.prototype, "required", null);
__decorate([
    Attribute({ type: String }),
    __metadata("design:type", String),
    __metadata("design:paramtypes", [String])
], ToggleSwitchElement.prototype, "name", null);
ToggleSwitchElement = __decorate([
    Component({
        selector: 'mosaik-toggle-switch',
        themes: {
            joy: toggleSwitchElementJoyStyle,
            memphis: toggleSwitchElementMemphisStyle,
            cosmopolitan: toggleSwitchElementCosmopolitanStyle
        },
        template: toggleSwitchElementTemplate,
        options: {
            mode: 'open',
            delegatesFocus: true
        },
        imports: [
            FocusRingElement,
            CheckmarkElement,
            TextElement
        ]
    }),
    __metadata("design:paramtypes", [])
], ToggleSwitchElement);
export { ToggleSwitchElement };
//# sourceMappingURL=ToggleSwitchElement.js.map