// #region Imports
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 __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
import { DomServiceLocator } from '../../../../Dom/Dom';
import { RendererServiceLocator } from '../../../../Dom/Renderer';
import { Attribute } from '../../../Decorators/AttributeDecorator';
import { Component } from '../../../Decorators/ComponentDecorator';
import { Watch } from '../../../Decorators/WatchDecorator';
import { CustomElement } from '../../Abstracts/CustomElement';
import { DrawerContainerElement } from './DrawerContainerElement';
import { drawerContentElementTemplate } from './DrawerContentElementTemplate';
import { drawerContentElementJoyStyle } from './Themes/DrawerContentElement.Joy';
import { drawerContentElementMemphisStyle } from './Themes/DrawerContentElement.Memphis';
import { drawerContentElementCosmopolitanStyle } from './Themes/DrawerContentElement.Cosmopolitan';
import { Themeable } from '../../../Behaviors/Themeable';
// #endregion
/**
 * Drawer Content - The content or information within a drawer component.
 *
 * @element mosaik-drawer-content
 *
 * @slot - The default content element.
 *
 * @public
 */
let DrawerContentElement = class DrawerContentElement extends Themeable(CustomElement) {
    // #region Fields
    _opened;
    // #endregion
    // #region Ctor
    /**
     * @public
     */
    constructor() {
        super();
        this._opened = false;
    }
    // #endregion
    // #region Properties
    /**
     * Returns the `{@link is}` property.
     * The `{@link is}` property represents natural name of this element.
     *
     * @public
     * @static
     * @readonly
     */
    static get is() {
        return 'mosaik-drawer-content';
    }
    /**
     * Gets or sets the `opened` property.
     *
     * @public
     * @attr
     */
    get opened() {
        return this._opened;
    }
    set opened(value) {
        if (this._opened !== value) {
            this._opened = value;
        }
    }
    // #endregion
    // #region Methods
    /**
     * @protected
     * @override
     */
    onApplyTemplate() {
        super.onApplyTemplate();
        // we use strict false here because for standalone drawers (DrawerService) the container is not necessarily.
        const container = DomServiceLocator.current.findAncestor(this, DrawerContainerElement, { strict: false });
        // If the container is not the parent of this element, then return.
        // if (container.content !== this) {
        //     return;
        // }
        container?.on('contentMarginChanged', (e) => {
            RendererServiceLocator.current.setStyle(this, 'margin-left', `${e.detail.left}px`);
            RendererServiceLocator.current.setStyle(this, 'margin-right', `${e.detail.right}px`);
            this.opened = container.drawer?.isOpen ?? false;
        }, { passive: true });
    }
    /**
     * @protected
     * @virtual
     */
    onOpenedPropertyChanged(_prev, next) {
        if (next) {
            RendererServiceLocator.current.addClass(this, 'drawer-opened');
        }
        else {
            RendererServiceLocator.current.removeClass(this, 'drawer-opened');
        }
    }
};
__decorate([
    Attribute({
        type: Boolean,
        useDefault: true
    }),
    __metadata("design:type", Boolean),
    __metadata("design:paramtypes", [Boolean])
], DrawerContentElement.prototype, "opened", null);
__decorate([
    Watch('opened'),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Boolean, Boolean]),
    __metadata("design:returntype", void 0)
], DrawerContentElement.prototype, "onOpenedPropertyChanged", null);
DrawerContentElement = __decorate([
    Component({
        selector: 'mosaik-drawer-content',
        template: drawerContentElementTemplate,
        themes: {
            joy: drawerContentElementJoyStyle,
            memphis: drawerContentElementMemphisStyle,
            cosmopolitan: drawerContentElementCosmopolitanStyle
        },
        options: {
            mode: 'open',
            delegatesFocus: true
        },
        imports: []
    }),
    __metadata("design:paramtypes", [])
], DrawerContentElement);
export { DrawerContentElement };
//# sourceMappingURL=DrawerContentElement.js.map