// #region Imports
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
import { Appearanceable } from '../../../Behaviors/Appearanceable';
import { Disableable } from '../../../Behaviors/Disableable';
import { Variantable } from '../../../Behaviors/Variantable';
import { Attribute } from '../../../Decorators/AttributeDecorator';
import { Component } from '../../../Decorators/ComponentDecorator';
import { Property } from '../../../Decorators/PropertyDecorator';
import { Watch } from '../../../Decorators/WatchDecorator';
import { InkBarPosition } from '../../../Types/InkBarPosition';
import { CustomElement } from '../../Abstracts/CustomElement';
import { inkBarElementTemplate } from './InkBarElementTemplate';
import { inkBarElementJoyStyle } from './Themes/InkBarElement.Joy';
import { inkBarElementMemphisStyle } from './Themes/InkBarElement.Memphis';
import { inkBarElementCosmopolitanStyle } from './Themes/InkBarElement.Cosmopolitan';
import { Themeable } from '../../../Behaviors/Themeable';
// #endregion
/**
 * InkBar - An animated indicator bar that highlights active tabs or navigation items.
 *
 * @description
 * The InkBar element is a visual indicator that slides smoothly between elements to show the active
 * selection in tab groups, navigation menus, or segmented controls. It automatically aligns to a target
 * element and transitions smoothly when the target changes. Commonly used in Material Design-style
 * tab interfaces to provide clear visual feedback about the current selection.
 *
 * @name InkBar
 * @element mosaik-ink-bar
 * @category Primitives
 *
 * @csspart ink-bar - The animated indicator bar element (Note: template returns nothing, styling applied to host)
 *
 * @cssprop {String} --ink-bar-background-color - Background color of the indicator bar
 * @cssprop {String} --ink-bar-border-color - Border color of the indicator bar
 * @cssprop {String} --ink-bar-border-radius - Border radius for rounded corners
 * @cssprop {String} --ink-bar-foreground-color - Foreground color (if applicable)
 * @cssprop {String} --ink-bar-thickness - Height (bottom/top) or width (left/right) of the bar
 * @cssprop {String} --ink-bar-transition-duration - Duration of the slide animation
 * @cssprop {String} --ink-bar-transition-mode - Timing function for the animation
 * @cssprop {Array} --ink-bar-transition-property - CSS properties to animate
 *
 * @example
 * Basic ink bar with tab group:
 * ```html
 * <div class="tab-group">
 *   <button id="tab1" class="tab active">Tab 1</button>
 *   <button id="tab2" class="tab">Tab 2</button>
 *   <button id="tab3" class="tab">Tab 3</button>
 *   <mosaik-ink-bar id="inkBar" position="bottom"></mosaik-ink-bar>
 * </div>
 *
 * <script>
 *   const inkBar = document.getElementById('inkBar');
 *   const activeTab = document.querySelector('.tab.active');
 *   inkBar.target = activeTab;
 *
 *   document.querySelectorAll('.tab').forEach(tab => {
 *     tab.addEventListener('click', () => {
 *       document.querySelectorAll('.tab').forEach(t => t.classList.remove('active'));
 *       tab.classList.add('active');
 *       inkBar.target = tab;
 *     });
 *   });
 * </script>
 * ```
 *
 * @example
 * Vertical navigation with left-side indicator:
 * ```html
 * <nav class="vertical-nav">
 *   <a href="#home" class="nav-item active">Home</a>
 *   <a href="#about" class="nav-item">About</a>
 *   <a href="#contact" class="nav-item">Contact</a>
 *   <mosaik-ink-bar position="left" variant="primary"></mosaik-ink-bar>
 * </nav>
 * ```
 *
 * @example
 * Programmatic alignment:
 * ```html
 * <div id="container">
 *   <div id="item1">Item 1</div>
 *   <div id="item2">Item 2</div>
 *   <mosaik-ink-bar id="bar"></mosaik-ink-bar>
 * </div>
 *
 * <script>
 *   const bar = document.getElementById('bar');
 *   bar.target = document.getElementById('item1');
 *
 *   // Later, move to item2
 *   setTimeout(() => {
 *     bar.target = document.getElementById('item2');
 *   }, 2000);
 * </script>
 * ```
 *
 * @public
 */
let InkBarElement = class InkBarElement extends Themeable(Variantable(Appearanceable(Disableable(CustomElement)))) {
    // #region Fields
    _position;
    _target;
    // #endregion
    // #region Ctor
    /**
     * @public
     */
    constructor() {
        super();
        this._position = InkBarPosition.Bottom;
        this._target = null;
    }
    // #endregion
    // #region Properties
    /**
     * Returns the `{@link is}` property.
     * The `{@link is}` property represents natural name of this element.
     *
     * @public
     * @static
     * @readonly
     */
    static get is() {
        return 'mosaik-ink-bar';
    }
    /**
     * Gets or sets the `target` property.
     *
     * @public
     */
    get target() {
        return this._target;
    }
    set target(value) {
        if (this._target !== value) {
            this._target = value;
            this.requestUpdate('target');
        }
    }
    /**
     * Gets or sets the `position` property.
     *
     * @public
     * @attr
     */
    get position() {
        return this._position;
    }
    set position(value) {
        if (this._position !== value) {
            this._position = value;
            this.requestUpdate('position');
        }
    }
    // #endregion
    // #region Methods
    /**
     * Aligns the ink bar to the target element.
     *
     * @public
     */
    align() {
        this.alignToElement();
    }
    /**
     * @protected
     * @override
     */
    onApplyTemplate() {
        super.onApplyTemplate();
        this.alignToElement();
    }
    /**
     * @protected
     */
    onPositionPropertyChanged() {
        this.alignToElement();
    }
    /**
     * @protected
     */
    onTargetPropertyChanged() {
        this.alignToElement();
    }
    /**
     * @private
     */
    alignToElement() {
        const target = this._target;
        if (target) {
            requestAnimationFrame(() => {
                if (this._position === InkBarPosition.Bottom || this._position === InkBarPosition.Top) {
                    this.style.top = '';
                    this.style.height = '';
                    this.style.left = `${target.offsetLeft}px`;
                    this.style.width = `${target.offsetWidth}px`;
                }
                else {
                    this.style.left = '';
                    this.style.width = '';
                    this.style.top = `${target.offsetTop}px`;
                    this.style.height = `${target.offsetHeight}px`;
                }
            });
        }
        else {
            this.style.top = '';
            this.style.left = '';
            this.style.width = '';
            this.style.height = '';
        }
    }
};
__decorate([
    Property({ type: Object }),
    __metadata("design:type", Object),
    __metadata("design:paramtypes", [Object])
], InkBarElement.prototype, "target", null);
__decorate([
    Attribute({ type: InkBarPosition }),
    __metadata("design:type", String),
    __metadata("design:paramtypes", [String])
], InkBarElement.prototype, "position", null);
__decorate([
    Watch('position', { waitUntilFirstUpdate: true }),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", []),
    __metadata("design:returntype", void 0)
], InkBarElement.prototype, "onPositionPropertyChanged", null);
__decorate([
    Watch('target'),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", []),
    __metadata("design:returntype", void 0)
], InkBarElement.prototype, "onTargetPropertyChanged", null);
InkBarElement = __decorate([
    Component({
        selector: 'mosaik-ink-bar',
        template: inkBarElementTemplate,
        themes: {
            joy: inkBarElementJoyStyle,
            memphis: inkBarElementMemphisStyle,
            cosmopolitan: inkBarElementCosmopolitanStyle
        },
        imports: []
    }),
    __metadata("design:paramtypes", [])
], InkBarElement);
export { InkBarElement };
//# sourceMappingURL=InkBarElement.js.map