/**
 * @license
 * Copyright Tyler Technologies, Inc. 
 * License: Apache-2.0
 */
import { __decorate } from "tslib";
import { attachShadowTemplate, coerceBoolean, customElement, ensureChildren, coreProperty } from '@tylertech/forge-core';
import { BaseComponent } from '../../core/base/base-component';
import { StepComponent } from '../step/step';
import { StepperAdapter } from './stepper-adapter';
import { STEPPER_CONSTANTS } from './stepper-constants';
import { StepperCore } from './stepper-core';
const template = '<template><div class=\"forge-stepper\" part=\"root\"><slot></slot></div></template>';
const styles = ':host{display:block}:host([hidden]){display:none}:host([vertical]) .forge-stepper{display:unset;-webkit-box-align:unset;align-items:unset;white-space:unset;overflow:unset}.forge-stepper{display:-webkit-box;display:flex;-webkit-box-align:center;align-items:center;white-space:nowrap;overflow:hidden}.forge-stepper:not(.vertical) ::slotted(*){display:-webkit-box;display:flex;-webkit-box-align:center;align-items:center;position:relative;min-width:112px}.forge-stepper.fixed ::slotted(*){-webkit-box-flex:1;flex:1}.forge-stepper.alternative{-webkit-box-align:start;align-items:flex-start}.forge-stepper.alternative ::slotted(*){min-width:160px}.forge-stepper.align-left{-webkit-box-pack:start;justify-content:flex-start}.forge-stepper.align-center{-webkit-box-pack:center;justify-content:center}.forge-stepper.align-right{-webkit-box-pack:end;justify-content:flex-end}';
/**
 * @tag forge-stepper
 *
 * @dependency forge-step
 *
 * @event {CustomEvent<number>} forge-step-select - Emits the index when a step is selected.
 * @event {CustomEvent<IStepComponent>} forge-step-expanded-content-focusin - Emits the step component when the expanded content is focused.
 * @event {CustomEvent<IStepComponent>} forge-step-expanded-content-focusout - Emits the step component when the expanded content is blurred.
 *
 */
let StepperComponent = class StepperComponent extends BaseComponent {
    static get observedAttributes() {
        return [
            STEPPER_CONSTANTS.attributes.SELECTED_INDEX,
            STEPPER_CONSTANTS.attributes.LINEAR,
            STEPPER_CONSTANTS.attributes.ALTERNATIVE,
            STEPPER_CONSTANTS.attributes.LAYOUT_MODE,
            STEPPER_CONSTANTS.attributes.LAYOUT_ALIGN,
            STEPPER_CONSTANTS.attributes.DISABLED,
            STEPPER_CONSTANTS.attributes.VERTICAL
        ];
    }
    constructor() {
        super();
        attachShadowTemplate(this, template, styles);
        this._core = new StepperCore(new StepperAdapter(this));
    }
    async connectedCallback() {
        await ensureChildren(this);
        this._core.initialize();
    }
    disconnectedCallback() {
        this._core.destroy();
    }
    attributeChangedCallback(name, oldValue, newValue) {
        switch (name) {
            case STEPPER_CONSTANTS.attributes.SELECTED_INDEX:
                this.selectedIndex = Number(newValue) || 0;
                break;
            case STEPPER_CONSTANTS.attributes.LINEAR:
                this.linear = coerceBoolean(newValue);
                break;
            case STEPPER_CONSTANTS.attributes.ALTERNATIVE:
                this.alternative = coerceBoolean(newValue);
                break;
            case STEPPER_CONSTANTS.attributes.LAYOUT_MODE:
                this.layoutMode = newValue;
                break;
            case STEPPER_CONSTANTS.attributes.LAYOUT_ALIGN:
                this.layoutAlign = newValue;
                break;
            case STEPPER_CONSTANTS.attributes.DISABLED:
                this.disabled = coerceBoolean(newValue);
                break;
            case STEPPER_CONSTANTS.attributes.VERTICAL:
                this.vertical = coerceBoolean(newValue);
                break;
        }
    }
};
__decorate([
    coreProperty()
], StepperComponent.prototype, "steps", void 0);
__decorate([
    coreProperty()
], StepperComponent.prototype, "selectedIndex", void 0);
__decorate([
    coreProperty()
], StepperComponent.prototype, "linear", void 0);
__decorate([
    coreProperty()
], StepperComponent.prototype, "alternative", void 0);
__decorate([
    coreProperty()
], StepperComponent.prototype, "layoutMode", void 0);
__decorate([
    coreProperty()
], StepperComponent.prototype, "layoutAlign", void 0);
__decorate([
    coreProperty()
], StepperComponent.prototype, "disabled", void 0);
__decorate([
    coreProperty()
], StepperComponent.prototype, "vertical", void 0);
StepperComponent = __decorate([
    customElement({
        name: STEPPER_CONSTANTS.elementName,
        dependencies: [StepComponent]
    })
], StepperComponent);
export { StepperComponent };
