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 { appShellTemplate } from './app-shell.template.js';
import { appShellStyles } from './app-shell.styles.js';
/**
 * ml-app-shell - Application shell layout component
 *
 * Provides a sidebar + header + content area layout using CSS Grid.
 *
 * @example
 * ```html
 * <ml-app-shell>
 *   <ml-sidebar slot="sidebar">...</ml-sidebar>
 *   <div slot="header">Page Header</div>
 *   <main>Content</main>
 * </ml-app-shell>
 * ```
 *
 * @slot sidebar - Sidebar navigation area (full height)
 * @slot header - Top header bar in the main area
 * @slot default - Main content area (scrolls independently)
 */
let AppShellComponent = class AppShellComponent {
    constructor() {
        /** Position of the sidebar: 'left' or 'right' */
        this['sidebar-position'] = 'left';
        /** Whether the sidebar is collapsed */
        this['sidebar-collapsed'] = false;
        /** Whether the header is fixed/sticky */
        this['header-fixed'] = false;
        /** Whether the viewport is mobile-sized (<768px) */
        this.mobile = false;
        /** Whether the mobile sidebar drawer is open */
        this.mobileOpen = false;
        /** Media query for responsive behavior */
        this._mediaQuery = null;
        this._handleMediaChange = this.onMediaChange.bind(this);
        /** Toggle mobile sidebar drawer */
        this.toggleMobileSidebar = () => {
            this.mobileOpen = !this.mobileOpen;
        };
        /** Close mobile sidebar */
        this.closeMobileSidebar = () => {
            this.mobileOpen = false;
        };
    }
    onCreate() {
        this._mediaQuery = window.matchMedia('(min-width: 768px)');
        this._mediaQuery.addEventListener('change', this._handleMediaChange);
        this.mobile = !this._mediaQuery.matches;
    }
    onDestroy() {
        this._mediaQuery?.removeEventListener('change', this._handleMediaChange);
    }
    onMediaChange(event) {
        this.mobile = !event.matches;
        if (event.matches) {
            // Switched to desktop: close mobile drawer
            this.mobileOpen = false;
        }
    }
};
AppShellComponent = __decorate([
    MelodicComponent({
        selector: 'ml-app-shell',
        template: appShellTemplate,
        styles: appShellStyles,
        attributes: ['sidebar-position', 'sidebar-collapsed', 'header-fixed']
    })
], AppShellComponent);
export { AppShellComponent };
