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 spinner so it's registered
import '../../feedback/spinner/spinner.component.js';
import { buttonTemplate } from './button.template.js';
import { buttonStyles } from './button.styles.js';
/**
 * ml-button - A versatile button component with multiple variants and sizes
 *
 * @example
 * ```html
 * <ml-button>Click me</ml-button>
 * <ml-button variant="secondary">Secondary</ml-button>
 * <ml-button variant="outline" size="lg">Large Outline</ml-button>
 * <ml-button loading>Loading...</ml-button>
 * <ml-button disabled>Disabled</ml-button>
 * ```
 *
 * @slot default - Button label content
 * @slot icon-start - Icon before the label
 * @slot icon-end - Icon after the label
 *
 * @fires ml:click - Emitted when button is clicked (not disabled/loading)
 */
let ButtonComponent = class ButtonComponent {
    constructor() {
        /** Button variant style */
        this.variant = 'primary';
        /** Button size */
        this.size = 'md';
        /** HTML button type */
        this.type = 'button';
        /** Disable the button */
        this.disabled = false;
        /** Show loading state */
        this.loading = false;
        /** Make button full width */
        this.fullWidth = false;
        /** Handle click events */
        this.handleClick = (event) => {
            if (this.isDisabled) {
                event.preventDefault();
                event.stopPropagation();
                return;
            }
            // Dispatch custom event
            this.elementRef.dispatchEvent(new CustomEvent('ml:click', {
                bubbles: true,
                composed: true,
                detail: { originalEvent: event }
            }));
        };
    }
    onInit() {
        // Ensure proper ARIA role
        if (!this.elementRef.hasAttribute('role')) {
            this.elementRef.setAttribute('role', 'button');
        }
    }
    /** Whether the button is effectively disabled */
    get isDisabled() {
        return this.disabled || this.loading;
    }
};
ButtonComponent = __decorate([
    MelodicComponent({
        selector: 'ml-button',
        template: buttonTemplate,
        styles: buttonStyles,
        attributes: ['variant', 'size', 'type', 'disabled', 'loading', 'full-width']
    })
], ButtonComponent);
export { ButtonComponent };
