/**
 * @license
 * Copyright 2023 Tyler Technologies, Inc. 
 * License: Apache-2.0
 */
import { __decorate } from "tslib";
import { CustomElement, attachShadowTemplate, coerceBoolean, FoundationProperty } from '@tylertech/forge-core';
import { DialogFoundation } from './dialog-foundation';
import { DialogAdapter } from './dialog-adapter';
import { DIALOG_CONSTANTS } from './dialog-constants';
import { BackdropComponent } from '../backdrop';
import { BaseComponent } from '../core/base/base-component';
const template = '<template><div class=\"forge-dialog\" part=\"root\"><forge-backdrop part=\"scrim\"></forge-backdrop><div class=\"forge-dialog__surface\" part=\"surface\"><slot></slot></div></div></template>';
const styles = '.forge-dialog{position:fixed;top:0;bottom:0;left:0;right:0;z-index:8;z-index:var(--forge-z-index-dialog,8);-webkit-box-align:center;align-items:center;-webkit-box-align:var(--forge-dialog-align-items,center);align-items:var(--forge-dialog-align-items,center);top:0;top:var(--forge-dialog-top,0);padding:24px;padding:var(--forge-dialog-padding,24px);display:-webkit-box;display:flex;-webkit-box-pack:center;justify-content:center;visibility:hidden}@media (max-width:599px){.forge-dialog{padding:0}}.forge-dialog--moveable:not(.forge-dialog--fullscreen) ::slotted([forge-dialog-move-target]){cursor:move}.forge-dialog--animating{visibility:visible}.forge-dialog--animating .forge-dialog--open .forge-dialog__surface{-webkit-transition:-webkit-transform 150ms 0s cubic-bezier(0, 0, .2, 1);transition:-webkit-transform 150ms 0s cubic-bezier(0, 0, .2, 1);transition:transform 150ms 0s cubic-bezier(0, 0, .2, 1);transition:transform 150ms 0s cubic-bezier(0, 0, .2, 1),-webkit-transform 150ms 0s cubic-bezier(0, 0, .2, 1)}.forge-dialog--animating .forge-dialog__surface{-webkit-transition:-webkit-transform 150ms 0s cubic-bezier(0, 0, .2, 1);transition:-webkit-transform 150ms 0s cubic-bezier(0, 0, .2, 1);transition:transform 150ms 0s cubic-bezier(0, 0, .2, 1);transition:transform 150ms 0s cubic-bezier(0, 0, .2, 1),-webkit-transform 150ms 0s cubic-bezier(0, 0, .2, 1)}.forge-dialog--scrollable .forge-dialog__footer,.forge-dialog--scrollable .forge-dialog__title{border-color:rgba(0,0,0,.12)}.forge-dialog--open{visibility:visible!important}.forge-dialog--open .forge-dialog__surface{-webkit-transform:scale(1);transform:scale(1);opacity:1}.forge-dialog__surface{-webkit-box-shadow:0 11px 15px -7px rgba(0,0,0,.2),0 24px 38px 3px rgba(0,0,0,.14),0 9px 46px 8px rgba(0,0,0,.12);box-shadow:0 11px 15px -7px rgba(0,0,0,.2),0 24px 38px 3px rgba(0,0,0,.14),0 9px 46px 8px rgba(0,0,0,.12);background-color:#fff;background-color:var(--mdc-theme-surface,#fff);width:auto;width:var(--forge-dialog-width,auto);height:auto;height:var(--forge-dialog-height,auto);min-width:280px;min-width:var(--forge-dialog-min-width,280px);max-width:100%;max-width:var(--forge-dialog-max-width,100%);max-height:100%;max-height:var(--forge-dialog-max-height,100%);border-radius:4px;border-radius:var(--forge-dialog-border-radius,var(--mdc-shape-medium,4px));display:-webkit-inline-box;display:inline-flex;-webkit-box-orient:vertical;-webkit-box-direction:normal;flex-direction:column;-webkit-box-sizing:border-box;box-sizing:border-box;-webkit-transform:scale(.8);transform:scale(.8);opacity:0;overflow:hidden;z-index:inherit}.forge-dialog__header{margin:0;padding:0 24px 9px;border-bottom:1px solid transparent}.forge-dialog__title{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased;font-size:1.25rem;font-size:var(--forge-typography-title-font-size, 1.25rem);line-height:2rem;line-height:var(--forge-typography-title-line-height, 2rem);font-weight:400;font-weight:var(--forge-typography-title-font-weight,400);letter-spacing:.0125em;letter-spacing:var(--forge-typography-title-letter-spacing, .0125em);text-decoration:inherit;-webkit-text-decoration:var(--forge-typography-title-text-decoration,inherit);text-decoration:var(--forge-typography-title-text-decoration,inherit);text-transform:inherit;text-transform:var(--forge-typography-title-text-transform,inherit);-webkit-box-sizing:border-box;box-sizing:border-box;margin:0}.forge-dialog__title::before{display:inline-block;width:0;height:40px;content:\"\";vertical-align:0}.forge-dialog__body{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased;font-family:Roboto,sans-serif;font-family:var(--mdc-typography-body1-font-family, var(--mdc-typography-font-family, Roboto, sans-serif));font-size:1rem;font-size:var(--mdc-typography-body1-font-size, 1rem);line-height:1.5rem;line-height:var(--mdc-typography-body1-line-height, 1.5rem);font-weight:400;font-weight:var(--mdc-typography-body1-font-weight,400);letter-spacing:.03125em;letter-spacing:var(--mdc-typography-body1-letter-spacing, .03125em);text-decoration:inherit;-webkit-text-decoration:var(--mdc-typography-body1-text-decoration,inherit);text-decoration:var(--mdc-typography-body1-text-decoration,inherit);text-transform:inherit;text-transform:var(--mdc-typography-body1-text-transform,inherit);padding-top:20px;padding:0 24px 24px;overflow:auto}.forge-dialog__body--scrollable{max-height:195px;border-top:1px solid rgba(0,0,0,.1);border-bottom:1px solid rgba(0,0,0,.1);overflow-x:auto;overflow-y:scroll;-webkit-overflow-scrolling:touch}.forge-dialog__footer{display:-webkit-box;display:flex;position:relative;flex-shrink:0;flex-wrap:wrap;-webkit-box-align:center;align-items:center;-webkit-box-pack:end;justify-content:flex-end;-webkit-box-sizing:border-box;box-sizing:border-box;min-height:52px;margin:0;padding:8px;border-top:1px solid transparent}.forge-dialog--fullscreen{padding:0}.forge-dialog--fullscreen .forge-dialog__surface{height:100%;width:100%;min-width:auto;max-width:100%;border-radius:0}:host{display:block}:host([hidden]){display:none}';
/**
 * The web component class behind the `<forge-dialog>` custom element.
 *
 * @tag forge-dialog
 */
let DialogComponent = class DialogComponent extends BaseComponent {
    constructor() {
        super();
        attachShadowTemplate(this, template, styles);
        this._foundation = new DialogFoundation(new DialogAdapter(this));
    }
    static get observedAttributes() {
        return [
            DIALOG_CONSTANTS.attributes.BACKDROP_CLOSE,
            DIALOG_CONSTANTS.attributes.ESCAPE_CLOSE,
            DIALOG_CONSTANTS.attributes.OPEN,
            DIALOG_CONSTANTS.attributes.FULLSCREEN,
            DIALOG_CONSTANTS.attributes.POSITION_TYPE,
            DIALOG_CONSTANTS.attributes.POSITION_X,
            DIALOG_CONSTANTS.attributes.POSITION_Y,
            DIALOG_CONSTANTS.attributes.MOVEABLE,
            DIALOG_CONSTANTS.attributes.MOVE_TARGET
        ];
    }
    connectedCallback() {
        this._foundation.initialize();
    }
    disconnectedCallback() {
        this._foundation.destroy();
    }
    attributeChangedCallback(name, oldValue, newValue) {
        switch (name) {
            case DIALOG_CONSTANTS.attributes.BACKDROP_CLOSE:
                this.backdropClose = newValue === 'true';
                break;
            case DIALOG_CONSTANTS.attributes.ESCAPE_CLOSE:
                this.escapeClose = newValue === 'true';
                break;
            case DIALOG_CONSTANTS.attributes.OPEN:
                this.open = coerceBoolean(newValue);
                break;
            case DIALOG_CONSTANTS.attributes.FULLSCREEN:
                this.fullscreen = coerceBoolean(newValue);
                break;
            case DIALOG_CONSTANTS.attributes.POSITION_TYPE:
                this.positionType = newValue;
                break;
            case DIALOG_CONSTANTS.attributes.POSITION_X:
                this.positionX = newValue;
                break;
            case DIALOG_CONSTANTS.attributes.POSITION_Y:
                this.positionY = newValue;
                break;
            case DIALOG_CONSTANTS.attributes.MOVEABLE:
                this.moveable = coerceBoolean(newValue);
                break;
            case DIALOG_CONSTANTS.attributes.MOVE_TARGET:
                this.moveTarget = newValue;
                break;
        }
    }
    initializeMoveTarget() {
        this._foundation.initializeMoveTarget();
    }
    resetPosition() {
        this._foundation.resetPosition();
    }
};
__decorate([
    FoundationProperty()
], DialogComponent.prototype, "backdropClose", void 0);
__decorate([
    FoundationProperty()
], DialogComponent.prototype, "escapeClose", void 0);
__decorate([
    FoundationProperty()
], DialogComponent.prototype, "open", void 0);
__decorate([
    FoundationProperty()
], DialogComponent.prototype, "fullscreen", void 0);
__decorate([
    FoundationProperty()
], DialogComponent.prototype, "openCallback", void 0);
__decorate([
    FoundationProperty()
], DialogComponent.prototype, "closeCallback", void 0);
__decorate([
    FoundationProperty()
], DialogComponent.prototype, "beforeCloseCallback", void 0);
__decorate([
    FoundationProperty()
], DialogComponent.prototype, "positionType", void 0);
__decorate([
    FoundationProperty()
], DialogComponent.prototype, "positionX", void 0);
__decorate([
    FoundationProperty()
], DialogComponent.prototype, "positionY", void 0);
__decorate([
    FoundationProperty()
], DialogComponent.prototype, "moveable", void 0);
__decorate([
    FoundationProperty()
], DialogComponent.prototype, "moveTarget", void 0);
DialogComponent = __decorate([
    CustomElement({
        name: DIALOG_CONSTANTS.elementName,
        dependencies: [BackdropComponent]
    })
], DialogComponent);
export { DialogComponent };
