import { LitElement } from "lit";
import { customElement, property, state } from "lit/decorators.js";
import { LayoutStylesController } from "../../common/layout/layout-styles-controller.js";
import { watch } from "../../../decorators/watch.js";
import { ChildrenUpdateCompleteMixin } from "../../../mixins/children-update-complete-mixin.js";
import { LightDomMixin } from "../../../mixins/light-dom.js";
import { buildCustomEvent } from "../../../utils/event-utils.js";
import { DEFAULT_MOBILE_BREAKPOINT } from "../../../utils/replace-breakpoint-utils.js";
import atomic_commerce_layout_tw_css from "./atomic-commerce-layout.tw.css.js";
import { buildCommerceLayout } from "./commerce-layout.js";
function _ts_decorate(decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) 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;
}
function _ts_metadata(k, v) {
    if ("object" == typeof Reflect && "function" == typeof Reflect.metadata) return Reflect.metadata(k, v);
}
class AtomicCommerceLayout extends LightDomMixin(ChildrenUpdateCompleteMixin(LitElement)) {
    connectedCallback() {
        super.connectedCallback();
        this.emitBreakpointChangeEvent();
    }
    emitBreakpointChangeEvent() {
        this.dispatchEvent(buildCustomEvent('atomic-layout-breakpoint-change', {
            breakpoint: this.mobileBreakpoint
        }));
    }
    onMobileBreakpointChange() {
        this.layoutStylesController.updateStyles();
        this.emitBreakpointChangeEvent();
    }
    constructor(...args){
        super(...args), this.mobileBreakpoint = DEFAULT_MOBILE_BREAKPOINT, this.layoutStylesController = new LayoutStylesController(this, buildCommerceLayout, 'atomic-commerce-layout-');
    }
}
AtomicCommerceLayout.styles = [
    atomic_commerce_layout_tw_css
];
_ts_decorate([
    state(),
    _ts_metadata("design:type", "u" < typeof Error ? Object : Error)
], AtomicCommerceLayout.prototype, "error", void 0);
_ts_decorate([
    property({
        type: String,
        reflect: true,
        attribute: 'mobile-breakpoint'
    }),
    _ts_metadata("design:type", String)
], AtomicCommerceLayout.prototype, "mobileBreakpoint", void 0);
_ts_decorate([
    watch('mobileBreakpoint'),
    _ts_metadata("design:type", Function),
    _ts_metadata("design:paramtypes", []),
    _ts_metadata("design:returntype", void 0)
], AtomicCommerceLayout.prototype, "onMobileBreakpointChange", null);
AtomicCommerceLayout = _ts_decorate([
    customElement('atomic-commerce-layout')
], AtomicCommerceLayout);
export { AtomicCommerceLayout };
