/**
 * @license
 * Copyright 2023 Tyler Technologies, Inc. 
 * License: Apache-2.0
 */
import { __decorate } from "tslib";
import { attachShadowTemplate, coerceBoolean, CustomElement, FoundationProperty, isDefined } from '@tylertech/forge-core';
import { BaseComponent } from '../core/base/base-component';
import { PopupAdapter } from './popup-adapter';
import { POPUP_CONSTANTS } from './popup-constants';
import { PopupFoundation } from './popup-foundation';
const template = '<template><div class=\"forge-popup\" part=\"root\"><slot></slot></div></template>';
const styles = '.forge-popup{min-width:112px;min-width:var(--min-width,112px);background-color:#fff;background-color:var(--forge-theme-elevated-surface,#fff);-webkit-box-shadow:0 3px 1px -2px rgba(0,0,0,.2),0 2px 2px 0 rgba(0,0,0,.14),0 1px 5px 0 rgba(0,0,0,.12);box-shadow:0 3px 1px -2px rgba(0,0,0,.2),0 2px 2px 0 rgba(0,0,0,.14),0 1px 5px 0 rgba(0,0,0,.12);-webkit-box-shadow:var(--forge-theme-popup-elevation,0 3px 1px -2px rgba(0,0,0,.2),0 2px 2px 0 rgba(0,0,0,.14),0 1px 5px 0 rgba(0,0,0,.12));box-shadow:var(--forge-theme-popup-elevation,0 3px 1px -2px rgba(0,0,0,.2),0 2px 2px 0 rgba(0,0,0,.14),0 1px 5px 0 rgba(0,0,0,.12));color:#000;color:var(--mdc-theme-on-surface,#000);border-radius:4px;border-radius:var(--mdc-shape-medium,4px);display:none;-webkit-box-sizing:border-box;box-sizing:border-box;min-width:100%;margin:0;padding:0;-webkit-transform:scale(1);transform:scale(1);-webkit-transform-origin:50% 24px 0;transform-origin:50% 24px 0;opacity:0;will-change:transform,opacity;-webkit-transition:opacity 120ms linear,-webkit-transform 120ms cubic-bezier(0, 0, .2, 1);transition:opacity 120ms linear,-webkit-transform 120ms cubic-bezier(0, 0, .2, 1);transition:opacity 120ms linear,transform 120ms cubic-bezier(0, 0, .2, 1);transition:opacity 120ms linear,transform 120ms cubic-bezier(0, 0, .2, 1),-webkit-transform 120ms cubic-bezier(0, 0, .2, 1)}.forge-popup::-webkit-scrollbar{width:16px;width:var(--forge-scrollbar-width,16px);height:16px;height:var(--forge-scrollbar-height,16px)}.forge-popup::-webkit-scrollbar-corner{background-color:#f0f0f0;background-color:var(--forge-theme-scrollbar-track,#f0f0f0)}.forge-popup::-webkit-scrollbar-track{background-color:#f0f0f0;background-color:var(--forge-theme-scrollbar-track,#f0f0f0)}.forge-popup::-webkit-scrollbar-track:hover{background-color:#ececec;background-color:var(--forge-theme-scrollbar-track-hover,#ececec)}.forge-popup::-webkit-scrollbar-thumb{background-color:#bdbdbd;background-color:var(--forge-theme-scrollbar-thumb,#bdbdbd);height:32px;height:var(--forge-scrollbar-min-height,32px);width:32px;width:var(--forge-scrollbar-min-width,32px);border-radius:10px;border-radius:var(--forge-scrollbar-border-radius,10px);border-width:3px;border-width:var(--forge-scrollbar-border-width,3px);border-style:solid;border-color:transparent;background-clip:content-box}.forge-popup::-webkit-scrollbar-thumb:hover{background-color:#9e9e9e;background-color:var(--forge-theme-scrollbar-thumb-hover,#9e9e9e)}.forge-popup--opening{display:block;-webkit-transform:scale(.8);transform:scale(.8);opacity:0}.forge-popup--closed{display:block;opacity:0;-webkit-transition:opacity 120ms linear;transition:opacity 120ms linear}.forge-popup--open{display:block;-webkit-transform:scale(1);transform:scale(1);opacity:1}.forge-popup--select{border-top-left-radius:0;border-top-right-radius:0;max-height:256px;overflow-y:auto}:host{z-index:10;z-index:var(--forge-z-index-popup,10);border-radius:4px;border-radius:var(--mdc-shape-medium,4px);display:inline-block;-webkit-box-sizing:border-box;box-sizing:border-box;outline:0;position:absolute;overflow:visible}:host([hidden]){display:none}:host([constrain-viewport-width]){max-width:100vw}';
/**
 * The web component class behind the `<forge-popup>` custom element.
 *
 * @tag forge-popup
 */
let PopupComponent = class PopupComponent extends BaseComponent {
    constructor() {
        super();
        attachShadowTemplate(this, template, styles);
        this._foundation = new PopupFoundation(new PopupAdapter(this));
    }
    static get observedAttributes() {
        return [
            POPUP_CONSTANTS.attributes.OPEN,
            POPUP_CONSTANTS.attributes.PLACEMENT,
            POPUP_CONSTANTS.attributes.MANAGE_FOCUS,
            POPUP_CONSTANTS.attributes.ANIMATION_TYPE,
            POPUP_CONSTANTS.attributes.STATIC,
            POPUP_CONSTANTS.attributes.HIDE_WHEN_CLIPPED
        ];
    }
    disconnectedCallback() {
        this._foundation.disconnect();
    }
    attributeChangedCallback(name, oldValue, newValue) {
        switch (name) {
            case POPUP_CONSTANTS.attributes.OPEN:
                this.open = isDefined(newValue);
                break;
            case POPUP_CONSTANTS.attributes.PLACEMENT:
                this.placement = newValue;
                break;
            case POPUP_CONSTANTS.attributes.MANAGE_FOCUS:
                this.manageFocus = coerceBoolean(newValue);
                break;
            case POPUP_CONSTANTS.attributes.ANIMATION_TYPE:
                this.animationType = newValue;
                break;
            case POPUP_CONSTANTS.attributes.STATIC:
                this.static = coerceBoolean(newValue);
                break;
            case POPUP_CONSTANTS.attributes.HIDE_WHEN_CLIPPED:
                this.hideWhenClipped = coerceBoolean(newValue);
                break;
        }
    }
    position() {
        this._foundation.position();
    }
};
__decorate([
    FoundationProperty()
], PopupComponent.prototype, "targetElement", void 0);
__decorate([
    FoundationProperty()
], PopupComponent.prototype, "placement", void 0);
__decorate([
    FoundationProperty()
], PopupComponent.prototype, "fallbackPlacements", void 0);
__decorate([
    FoundationProperty()
], PopupComponent.prototype, "open", void 0);
__decorate([
    FoundationProperty()
], PopupComponent.prototype, "manageFocus", void 0);
__decorate([
    FoundationProperty()
], PopupComponent.prototype, "animationType", void 0);
__decorate([
    FoundationProperty()
], PopupComponent.prototype, "static", void 0);
__decorate([
    FoundationProperty()
], PopupComponent.prototype, "hideWhenClipped", void 0);
__decorate([
    FoundationProperty()
], PopupComponent.prototype, "openCallback", void 0);
__decorate([
    FoundationProperty()
], PopupComponent.prototype, "closeCallback", void 0);
__decorate([
    FoundationProperty()
], PopupComponent.prototype, "offset", void 0);
PopupComponent = __decorate([
    CustomElement({
        name: POPUP_CONSTANTS.elementName
    })
], PopupComponent);
export { PopupComponent };
