/**
 * @license
 * Copyright 2023 Tyler Technologies, Inc. 
 * License: Apache-2.0
 */
import { __decorate } from "tslib";
import { CustomElement, coerceNumber, hideElementVisually, FoundationProperty } from '@tylertech/forge-core';
import { TooltipAdapter } from './tooltip-adapter';
import { TooltipFoundation } from './tooltip-foundation';
import { TOOLTIP_CONSTANTS } from './tooltip-constants';
import { BaseComponent } from '../core/base/base-component';
/**
 * The custom element class behind the `<forge-tooltip>` element.
 *
 * @tag forge-tooltip
 */
let TooltipComponent = class TooltipComponent extends BaseComponent {
    constructor() {
        super();
        this._foundation = new TooltipFoundation(new TooltipAdapter(this));
    }
    static get observedAttributes() {
        return [
            TOOLTIP_CONSTANTS.attributes.TEXT,
            TOOLTIP_CONSTANTS.attributes.TARGET,
            TOOLTIP_CONSTANTS.attributes.DELAY,
            TOOLTIP_CONSTANTS.attributes.POSITION
        ];
    }
    connectedCallback() {
        hideElementVisually(this);
        requestAnimationFrame(() => this._foundation.initialize());
    }
    disconnectedCallback() {
        this._foundation.disconnect();
    }
    attributeChangedCallback(name, oldValue, newValue) {
        switch (name) {
            case TOOLTIP_CONSTANTS.attributes.TEXT:
                this.text = newValue;
                break;
            case TOOLTIP_CONSTANTS.attributes.TARGET:
                this.target = newValue;
                break;
            case TOOLTIP_CONSTANTS.attributes.DELAY:
                this.delay = coerceNumber(newValue);
                break;
            case TOOLTIP_CONSTANTS.attributes.POSITION:
                this.position = newValue;
                break;
        }
    }
    /** Hides the tooltip if it's open. */
    hide() {
        this._foundation.hide();
    }
};
__decorate([
    FoundationProperty()
], TooltipComponent.prototype, "text", void 0);
__decorate([
    FoundationProperty()
], TooltipComponent.prototype, "builder", void 0);
__decorate([
    FoundationProperty()
], TooltipComponent.prototype, "target", void 0);
__decorate([
    FoundationProperty()
], TooltipComponent.prototype, "delay", void 0);
__decorate([
    FoundationProperty()
], TooltipComponent.prototype, "position", void 0);
__decorate([
    FoundationProperty()
], TooltipComponent.prototype, "open", void 0);
__decorate([
    FoundationProperty({ set: false })
], TooltipComponent.prototype, "tooltipElement", void 0);
TooltipComponent = __decorate([
    CustomElement({
        name: TOOLTIP_CONSTANTS.elementName
    })
], TooltipComponent);
export { TooltipComponent };
