/**
 * Copyright Aquera Inc 2023
 *
 * This source code is licensed under the BSD-3-Clause license found in the
 * LICENSE file in the root directory of this source tree.
 */
import { __decorate } from "tslib";
import { nothing, html } from 'lit';
import { customElement, property, state, query } from 'lit/decorators.js';
import { classMap } from 'lit/directives/class-map.js';
import { styles } from './nile-stepper-item.css';
import NileElement from '../internal/nile-element';
/**
 * Nile stepper-item component.
 *
 * @tag nile-stepper-item
 *
 */
let NileStepperItem = class NileStepperItem extends NileElement {
    constructor() {
        super(...arguments);
        /* Properties passed directly */
        this.title = '';
        this.subtitle = '';
        this.completed = false;
        this.current = false;
        /* Properties passed to parent component: NileStepper */
        this.contentBelow = false;
        this.size = 'lg';
        this.icon = 'tick';
        /* Properties Computed at parent level component NileStepper */
        this.isFirst = false;
        this.isLast = false;
        this.isComplete = false;
        this.isCurrent = false;
        this.isManualMode = false;
        this.haveFlex = true;
        /* #endregion */
    }
    /**
     * The styles for nile-stepper-item
     * @remarks If you are extending this class you can extend the base styles with super. Eg `return [super(), myCustomStyles]`
     */
    static get styles() {
        return [styles];
    }
    updated(_changedProperties) {
        if (_changedProperties.has('subtitle') && this.isLast && !this.contentBelow && this.subtitle) {
            const subtitleWidth = this.absoluteSubtitle?.scrollWidth ?? '0';
            this.absoluteTitle.style.minWidth = subtitleWidth + "px";
        }
    }
    /* #endregion */
    /* #region Methods */
    /**
     * Render method
     * @slot This is a slot test
     */
    render() {
        if (!this.haveFlex)
            this.style.setProperty('--stepper-flex-val', `0`);
        const isCurrent = this.isManualMode ? this.current : this.isCurrent;
        const isComplete = this.isManualMode ? this.completed : this.isComplete;
        let showCompletedIcon = false;
        if (isComplete && !isCurrent || this.completedStepValue == this.value)
            showCompletedIcon = true;
        let suffixStepperLineActive = false;
        if (isComplete) {
            suffixStepperLineActive = true;
            if (this.calculatedCompletedStepValue == this.value)
                suffixStepperLineActive = false;
        }
        return html `
			<div part="item" class="${classMap({
            'stepper__item': true,
            'stepper__item--selected': isCurrent,
            'stepper__item--sm': this.size == 'sm',
            'stepper__item--lg': this.size == 'lg',
        })}">
				<div part="line-content" class="stepper__line__content">
					<div class="stepper__line__container">
						${this.isFirst ? nothing : html `
							<hr class="${classMap({
            'stepper__line': true,
            'stepper__line--active': isComplete || isCurrent
        })}"/>
						`}
					</div>

					<div part="bulletin" class=${classMap({ 'stepper__item__bulletin': true, 'stepper__item__bulletin--inline': !this.contentBelow })}>
						${showCompletedIcon ?
            html `<div part="bulletin-icon" class="${classMap({ 'stepper__bulletin--icon': true, 'stepper__bulletin__icon--active': isCurrent })}">${this.getSvg()}</div>`
            : html `<div part="bulletin-dot" class="${classMap({ 'stepper__bulletin--dot': true, 'stepper__bulletin__dot--active': isCurrent })}"></div>`}
					</div>
					
					<div part="line-container" class="${classMap({
            'stepper__line__container': true,
            'stepper__line--hastitle': !this.contentBelow
        })}">
						${this.contentBelow || !this.title ? nothing : html `

							<div part="content-above" class="stepper__item__content--above">
								<div part="title_above" class="${classMap({ 'stepper__content__title': true, 'stepper__content__title--active': isCurrent })}">
									${this.title}
								</div>
								<div class="${classMap({ 'stepper__content__subtitle': true, 'stepper__content__subtitle--active': isCurrent })}">${this.subtitle}</div>
							</div>
						`}
						${this.isLast ? nothing : html `
							<hr part="line" class="${classMap({
            'stepper__line': true,
            'stepper__line--active': suffixStepperLineActive
        })}" style="flex-grow:1;"/>
						`}
					</div>
				</div>
				${this.contentBelow ?
            html `
					<div part="content-below" class="stepper__item__content--below">
						<div part="title_below" class="${classMap({ 'stepper__content__title': true, 'stepper__content__title--active': isCurrent })}">
							${this.title}
						</div>
						<div part="subtitle_below" class="${classMap({ 'stepper__content__subtitle': true, 'stepper__content__subtitle--active': isCurrent })}">${this.subtitle}</div>
					</div>
				` : nothing}
			</div>
		`;
    }
    getSvg() {
        let iconSize = this.size == 'sm' ? 20 : this.size == 'lg' ? 24 : 28;
        return html `
		<svg part="bulletin-svg" width="${iconSize}" height="${iconSize}" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
			<path fill-rule="evenodd" clip-rule="evenodd" d="M22.7953 9.85334L13.2487 19.0667L10.7153 16.36C10.2487 15.92 9.51534 15.8933 8.982 16.2667C8.462 16.6533 8.31534 17.3333 8.63534 17.88L11.6353 22.76C11.9287 23.2133 12.4353 23.4933 13.0087 23.4933C13.5553 23.4933 14.0753 23.2133 14.3687 22.76C14.8487 22.1333 24.0087 11.2133 24.0087 11.2133C25.2087 9.98668 23.7553 8.90668 22.7953 9.84001V9.85334Z" fill="white"/>
		</svg>
		`;
    }
};
__decorate([
    query('.stepper__item__content--above .stepper__content__title')
], NileStepperItem.prototype, "absoluteTitle", void 0);
__decorate([
    query('.stepper__item__content--above .stepper__content__subtitle')
], NileStepperItem.prototype, "absoluteSubtitle", void 0);
__decorate([
    property({ attribute: true, reflect: true })
], NileStepperItem.prototype, "title", void 0);
__decorate([
    property({ attribute: true, reflect: true })
], NileStepperItem.prototype, "subtitle", void 0);
__decorate([
    property({ attribute: true, reflect: true })
], NileStepperItem.prototype, "completed", void 0);
__decorate([
    property({ attribute: true, reflect: true })
], NileStepperItem.prototype, "current", void 0);
__decorate([
    state()
], NileStepperItem.prototype, "contentBelow", void 0);
__decorate([
    state()
], NileStepperItem.prototype, "size", void 0);
__decorate([
    state()
], NileStepperItem.prototype, "icon", void 0);
__decorate([
    state()
], NileStepperItem.prototype, "isFirst", void 0);
__decorate([
    state()
], NileStepperItem.prototype, "isLast", void 0);
__decorate([
    state()
], NileStepperItem.prototype, "isComplete", void 0);
__decorate([
    state()
], NileStepperItem.prototype, "isCurrent", void 0);
__decorate([
    state()
], NileStepperItem.prototype, "isManualMode", void 0);
__decorate([
    state()
], NileStepperItem.prototype, "currentStepValue", void 0);
__decorate([
    state()
], NileStepperItem.prototype, "completedStepValue", void 0);
__decorate([
    state()
], NileStepperItem.prototype, "calculatedCompletedStepValue", void 0);
__decorate([
    state()
], NileStepperItem.prototype, "value", void 0);
__decorate([
    state()
], NileStepperItem.prototype, "haveFlex", void 0);
NileStepperItem = __decorate([
    customElement('nile-stepper-item')
], NileStepperItem);
export { NileStepperItem };
export default NileStepperItem;
//# sourceMappingURL=nile-stepper-item.js.map