/**
 * @license
 * Copyright Tyler Technologies, Inc. 
 * License: Apache-2.0
 */
import { __decorate } from "tslib";
import { CustomElement, attachShadowTemplate, coerceNumber, FoundationProperty } from '@tylertech/forge-core';
import { ViewSwitcherAdapter } from './view-switcher-adapter';
import { ViewSwitcherFoundation } from './view-switcher-foundation';
import { VIEW_SWITCHER_CONSTANTS } from './view-switcher-constants';
import { ViewComponent } from './view/view';
import { BaseComponent } from '../core/base/base-component';
const template = '<template><div class=\"forge-view-switcher\" part=\"root\"><slot></slot></div></template>';
const styles = '.forge-view-switcher{height:var(--forge-view-switcher-height,auto);width:var(--forge-view-switcher-width,auto);position:relative;overflow:hidden;-webkit-transition:height var(--forge-animation-duration-medium2, 300ms) cubic-bezier(.35, 0, .25, 1);transition:height var(--forge-animation-duration-medium2, 300ms) cubic-bezier(.35, 0, .25, 1)}.forge-view-switcher ::slotted(.forge-view-switcher__view--hidden){position:absolute;top:0;right:0;bottom:0;left:0}:host{height:var(--forge-view-switcher-height,auto);width:var(--forge-view-switcher-width,auto);display:block}:host([hidden]){display:none}:host(.forge-view-switcher--slide) ::slotted(forge-view){-webkit-transition:-webkit-transform var(--forge-animation-duration-medium2, 300ms) cubic-bezier(.35, 0, .25, 1);transition:-webkit-transform var(--forge-animation-duration-medium2, 300ms) cubic-bezier(.35, 0, .25, 1);transition:transform var(--forge-animation-duration-medium2, 300ms) cubic-bezier(.35, 0, .25, 1);transition:transform var(--forge-animation-duration-medium2, 300ms) cubic-bezier(.35, 0, .25, 1),-webkit-transform var(--forge-animation-duration-medium2, 300ms) cubic-bezier(.35, 0, .25, 1);will-change:transform}:host(.forge-view-switcher--fade) ::slotted(forge-view){-webkit-transition:opacity var(--forge-animation-duration-medium2, 300ms) cubic-bezier(.35, 0, .25, 1);transition:opacity var(--forge-animation-duration-medium2, 300ms) cubic-bezier(.35, 0, .25, 1);will-change:opacity}:host(.forge-view-switcher--fade) ::slotted(.forge-view-switcher__view--hidden){opacity:0}';
/**
 * The web component class behind the `<forge-view-switcher>` custom element.
 *
 * @tag forge-view-switcher
 */
let ViewSwitcherComponent = class ViewSwitcherComponent extends BaseComponent {
    static get observedAttributes() {
        return [
            VIEW_SWITCHER_CONSTANTS.attributes.INDEX,
            VIEW_SWITCHER_CONSTANTS.attributes.ANIMATION_TYPE
        ];
    }
    constructor() {
        super();
        attachShadowTemplate(this, template, styles);
        this._foundation = new ViewSwitcherFoundation(new ViewSwitcherAdapter(this));
    }
    connectedCallback() {
        // upgradeProperty(this, 'index');
        this._foundation.initialize();
    }
    disconnectedCallback() {
        this._foundation.disconnect();
    }
    attributeChangedCallback(name, oldValue, newValue) {
        switch (name) {
            case VIEW_SWITCHER_CONSTANTS.attributes.INDEX:
                this.index = coerceNumber(newValue);
                break;
            case VIEW_SWITCHER_CONSTANTS.attributes.ANIMATION_TYPE:
                this.animationType = newValue;
                break;
        }
    }
    /** Transitions to the next view. */
    next() {
        this._foundation.next();
    }
    /** Transitions to the previous view. */
    previous() {
        this._foundation.previous();
    }
    /** Transitions to the first view. */
    goToStart() {
        this._foundation.goToStart();
    }
    /** Transitions to the last view. */
    goToEnd() {
        this._foundation.goToEnd();
    }
};
__decorate([
    FoundationProperty()
], ViewSwitcherComponent.prototype, "index", void 0);
__decorate([
    FoundationProperty()
], ViewSwitcherComponent.prototype, "animationType", void 0);
ViewSwitcherComponent = __decorate([
    CustomElement({
        name: VIEW_SWITCHER_CONSTANTS.elementName,
        dependencies: [ViewComponent]
    })
], ViewSwitcherComponent);
export { ViewSwitcherComponent };
