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 IgcNavDrawerComponent_1;
import { LitElement, html } from 'lit';
import { property, queryAssignedElements } from 'lit/decorators.js';
import { themes } from '../../theming/theming-decorator.js';
import { registerComponent } from '../common/definitions/register.js';
import { isEmpty, partNameMap } from '../common/util.js';
import IgcNavDrawerHeaderItemComponent from './nav-drawer-header-item.js';
import IgcNavDrawerItemComponent from './nav-drawer-item.js';
import { styles } from './themes/container.base.css.js';
import { all } from './themes/container.js';
import { styles as shared } from './themes/shared/container/nav-drawer.common.css.js';
let IgcNavDrawerComponent = IgcNavDrawerComponent_1 = class IgcNavDrawerComponent extends LitElement {
    constructor() {
        super(...arguments);
        this.position = 'start';
        this.open = false;
    }
    static register() {
        registerComponent(IgcNavDrawerComponent_1, IgcNavDrawerHeaderItemComponent, IgcNavDrawerItemComponent);
    }
    createRenderRoot() {
        const root = super.createRenderRoot();
        root.addEventListener('slotchange', () => this.requestUpdate());
        return root;
    }
    _waitTransitions() {
        return new Promise((resolve) => {
            this.renderRoot.addEventListener('transitionend', resolve, {
                once: true,
            });
        });
    }
    async show() {
        if (this.open) {
            return false;
        }
        this.open = true;
        await this._waitTransitions();
        return true;
    }
    async hide() {
        if (!this.open) {
            return false;
        }
        this.open = false;
        await this._waitTransitions();
        return true;
    }
    async toggle() {
        return this.open ? this.hide() : this.show();
    }
    render() {
        const parts = partNameMap({
            mini: true,
            hidden: isEmpty(this._miniSlotElements),
        });
        return html `
      <div part="overlay" @click=${this.hide}></div>

      <div part="base" .inert=${!this.open}>
        <div part="main">
          <slot></slot>
        </div>
      </div>

      <div part=${parts}>
        <slot name="mini"></slot>
      </div>
    `;
    }
};
IgcNavDrawerComponent.tagName = 'igc-nav-drawer';
IgcNavDrawerComponent.styles = [styles, shared];
__decorate([
    queryAssignedElements({ slot: 'mini' })
], IgcNavDrawerComponent.prototype, "_miniSlotElements", void 0);
__decorate([
    property({ reflect: true })
], IgcNavDrawerComponent.prototype, "position", void 0);
__decorate([
    property({ type: Boolean, reflect: true })
], IgcNavDrawerComponent.prototype, "open", void 0);
IgcNavDrawerComponent = IgcNavDrawerComponent_1 = __decorate([
    themes(all)
], IgcNavDrawerComponent);
export default IgcNavDrawerComponent;
//# sourceMappingURL=nav-drawer.js.map