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 { checkboxTemplate } from './checkbox.template.js';
import { checkboxStyles } from './checkbox.styles.js';
/**
 * ml-checkbox - Checkbox input component
 *
 * @example
 * ```html
 * <ml-checkbox label="Accept terms"></ml-checkbox>
 * <ml-checkbox label="Subscribe" checked></ml-checkbox>
 * <ml-checkbox label="Indeterminate" indeterminate></ml-checkbox>
 * ```
 *
 * @fires ml:change - Emitted when checked state changes
 */
let CheckboxComponent = class CheckboxComponent {
    constructor() {
        /** Checkbox label */
        this.label = '';
        /** Hint text below the checkbox */
        this.hint = '';
        /** Checkbox size */
        this.size = 'md';
        /** Checked state */
        this.checked = false;
        /** Indeterminate state */
        this.indeterminate = false;
        /** Disabled state */
        this.disabled = false;
        this.handleChange = (event) => {
            if (this.disabled) {
                event.preventDefault();
                return;
            }
            const target = event.target;
            this.checked = target.checked;
            this.indeterminate = false;
            this.elementRef.dispatchEvent(new CustomEvent('ml:change', {
                bubbles: true,
                composed: true,
                detail: { checked: this.checked }
            }));
        };
    }
};
CheckboxComponent = __decorate([
    MelodicComponent({
        selector: 'ml-checkbox',
        template: checkboxTemplate,
        styles: checkboxStyles,
        attributes: ['label', 'hint', 'size', 'checked', 'indeterminate', 'disabled']
    })
], CheckboxComponent);
export { CheckboxComponent };
