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;
};
import { MelodicComponent } from '@melodicdev/core';
import { toggleTemplate } from './toggle.template.js';
import { toggleStyles } from './toggle.styles.js';
/**
 * ml-toggle - Toggle/switch component
 *
 * @example
 * ```html
 * <ml-toggle label="Enable notifications"></ml-toggle>
 * <ml-toggle label="Dark mode" checked></ml-toggle>
 * <ml-toggle size="lg" label="Large toggle"></ml-toggle>
 * ```
 *
 * @fires ml:change - Emitted when toggled
 */
let ToggleComponent = class ToggleComponent {
    constructor() {
        /** Toggle label */
        this.label = '';
        /** Hint text */
        this.hint = '';
        /** Toggle size */
        this.size = 'md';
        /** Checked state */
        this.checked = false;
        /** Disabled state */
        this.disabled = false;
        this.handleChange = (event) => {
            if (this.disabled) {
                event.preventDefault();
                return;
            }
            const target = event.target;
            this.checked = target.checked;
            this.elementRef.dispatchEvent(new CustomEvent('ml:change', {
                bubbles: true,
                composed: true,
                detail: { checked: this.checked }
            }));
        };
    }
};
ToggleComponent = __decorate([
    MelodicComponent({
        selector: 'ml-toggle',
        template: toggleTemplate,
        styles: toggleStyles,
        attributes: ['label', 'hint', 'size', 'checked', 'disabled']
    })
], ToggleComponent);
export { ToggleComponent };
