// #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 { Attachable } from '../../../Behaviors/Attachable';
import { Disableable } from '../../../Behaviors/Disableable';
import { Themeable } from '../../../Behaviors/Themeable';
import { Attribute } from '../../../Decorators/AttributeDecorator';
import { Component } from '../../../Decorators/ComponentDecorator';
import { Watch } from '../../../Decorators/WatchDecorator';
import { ElevationWeight } from '../../../Types/ElevationWeight';
import { CustomElement } from '../../Abstracts/CustomElement';
import { elevationElementTemplate } from './ElevationElementTemplate';
import { elevationElementCosmopolitanStyle } from './Themes/ElevationElement.Cosmopolitan';
import { elevationElementJoyStyle } from './Themes/ElevationElement.Joy';
import { elevationElementMemphisStyle } from './Themes/ElevationElement.Memphis';
// #endregion
/**
 * Elevation - A visual effect indicating the depth of an element relative to its surroundings.
 *
 * @description
 * Elevation is a design technique used to create a sense of depth and hierarchy in a user interface.
 * Elements with higher elevation appear to be physically closer to the viewer, while elements with lower
 * elevation appear further away. Elevation is often used to highlight and differentiate elements, such as
 * cards, dialogs, and buttons, within a layout.
 *
 * @element mosaik-elevation
 * @category Visual Effects
 *
 * @cssprop {String} --elevation-font-family - The font family CSS custom property.
 * @cssprop {String} --elevation-font-letter-spacing - The font letter spacing CSS custom property.
 * @cssprop {String} --elevation-font-line-height - The font line height CSS custom property.
 * @cssprop {String} --elevation-font-size - The font size CSS custom property.
 * @cssprop {String} --elevation-font-text-decoration - The font text decoration CSS custom property.
 * @cssprop {String} --elevation-font-text-transform - The font text transform CSS custom property.
 * @cssprop {String} --elevation-font-weight - The font weight CSS custom property.
 * @cssprop {String} --elevation-gap - The gap CSS custom property.
 * @cssprop {String} --elevation-padding-bottom - The padding bottom CSS custom property.
 * @cssprop {String} --elevation-padding-left - The padding left CSS custom property.
 * @cssprop {String} --elevation-padding-right - The padding right CSS custom property.
 * @cssprop {String} --elevation-padding-top - The padding top CSS custom property.
 * @cssprop {String} --elevation-shadow - The shadow CSS custom property.
 * @cssprop {String} --elevation-shadow-blur - The shadow blur CSS custom property.
 * @cssprop {String} --elevation-shadow-color - The shadow color CSS custom property.
 * @cssprop {String} --elevation-shadow-offset-x - The shadow offset x CSS custom property.
 * @cssprop {String} --elevation-shadow-offset-y - The shadow offset y CSS custom property.
 * @cssprop {String} --elevation-shadow-spread - The shadow spread CSS custom property.
 * @cssprop {String} --elevation-transition-duration - The transition duration CSS custom property.
 * @cssprop {String} --elevation-transition-mode - The transition mode CSS custom property.
 * @cssprop {String} --elevation-transition-property - The transition property CSS custom property.
 * @cssprop {String} --elevation-translate - The translate CSS custom property.
 *
 * @example
 * Basic elevation effect:
 * ```html
 * <mosaik-elevation weigh="medium">
 *   <div>Elevated content</div>
 * </mosaik-elevation>
 * ```
 *
 * @example
 * High elevation for dialogs:
 * ```html
 * <mosaik-elevation weigh="high">
 *   <div>Card with high elevation</div>
 * </mosaik-elevation>
 * ```
 *
 * @public
 */
let ElevationElement = class ElevationElement extends Themeable(Disableable(Attachable(CustomElement))) {
    // #region Fields
    _weigh;
    // #endregion
    // #region Ctor
    /**
     * @public
     */
    constructor() {
        super();
        this._weigh = ElevationWeight.None;
    }
    // #endregion
    // #region Properties
    /**
     * Returns the `is` property.
     * The `is` property represents natural name of this element.
     *
     * @public
     * @static
     * @readonly
     */
    static get is() {
        return 'mosaik-elevation';
    }
    /**
     * Gets or sets the `weigh` property.
     *
     * @public
     * @attr
     */
    get weigh() {
        return this._weigh;
    }
    set weigh(value) {
        if (this._weigh !== value) {
            this._weigh = value;
            this.requestUpdate('weigh');
        }
    }
    // #endregion
    // #region Methods
    /**
     * @protected
     * @override
     */
    onApplyTemplate() {
        void this.updateComplete.then(() => {
            requestAnimationFrame(() => {
                this.applyBoxShadow();
            });
        });
    }
    /**
     * @protected
     */
    onWeighPropertyChanged(prev, next) {
        void this.updateComplete.then(() => {
            requestAnimationFrame(() => {
                this.applyBoxShadow();
            });
        });
    }
    /**
     * Reads the target box-shadow from the host's computed style and applies it to the control.
     * Temporarily disables the CSS transition so that `getComputedStyle` returns the final
     * target value instead of an in-progress transitioning value.
     *
     * @private
     */
    applyBoxShadow() {
        if (!this.control) {
            return;
        }
        // Suppress the CSS transition so we read the final target value,
        // not the interpolated value at the start of the transition.
        this.style.setProperty('transition', 'none');
        // Force a synchronous style recalculation with transitions disabled.
        const boxShadowValue = window.getComputedStyle(this).boxShadow;
        // Restore the stylesheet transition.
        this.style.removeProperty('transition');
        this.control.style.boxShadow = boxShadowValue;
    }
};
__decorate([
    Attribute({ type: ElevationWeight }),
    __metadata("design:type", String),
    __metadata("design:paramtypes", [String])
], ElevationElement.prototype, "weigh", null);
__decorate([
    Watch('weigh', { waitUntilFirstUpdate: true }),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, String]),
    __metadata("design:returntype", void 0)
], ElevationElement.prototype, "onWeighPropertyChanged", null);
ElevationElement = __decorate([
    Component({
        selector: 'mosaik-elevation',
        template: elevationElementTemplate,
        themes: {
            joy: elevationElementJoyStyle,
            memphis: elevationElementMemphisStyle,
            cosmopolitan: elevationElementCosmopolitanStyle
        },
        imports: []
    }),
    __metadata("design:paramtypes", [])
], ElevationElement);
export { ElevationElement };
//# sourceMappingURL=ElevationElement.js.map