// #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 { Variantable } from '../../../Behaviors/Variantable';
import { Component } from '../../../Decorators/ComponentDecorator';
import { CustomElement } from '../../Abstracts/CustomElement';
import { patternElementTemplate } from './PatternElementTemplate';
import { patternElementJoyStyle } from './Themes/PatternElement.Joy';
import { patternElementRetroStyle } from './Themes/PatternElement.Retro';
import { patternElementCosmopolitanStyle } from './Themes/PatternElement.Cosmopolitan';
import { Themeable } from '../../../Behaviors/Themeable';
import { Property } from '../../../Decorators/PropertyDecorator';
import { on } from '@breadstone/mosaik-elements';
// #endregion
/**
 * Pattern - A component for generating random patterns with a mask effect based on mouse position.
 *
 * @description
 * The Pattern component provides a decorative pattern effect by randomly selecting predefined patterns
 * and applying a mask based on the mouse position for interactive visuals.
 *
 * @name Pattern
 * @element mosaik-pattern
 * @category Effects
 *
 * @csspart root - The root container of the pattern.
 * @csspart gradient first - The first gradient layer of the pattern.
 * @csspart gradient second - The second gradient layer of the pattern.
 *
 * @cssprop {unknown} --pattern-background-color - The background color of the pattern.
 *
 * @example
 * ```html
 * <mosaik-pattern></mosaik-pattern>
 * ```
 *
 * @public
 */
let PatternElement = class PatternElement extends Themeable(Variantable(Disableable(Attachable(CustomElement)))) {
    // #region Fields
    _gradientFirstElement;
    _gradientSecondElement;
    _mouseX;
    _mouseY;
    _mouseMoveSubscription;
    // #endregion
    // #region Ctor
    /**
     * Constructs a new instance of the `PatternElement` class.
     *
     * @public
     */
    constructor() {
        super();
        this._mouseX = 0;
        this._mouseY = 0;
        this._mouseMoveSubscription = null;
    }
    // #endregion
    // #region Properties
    /**
     * Returns the `{@link is}` property.
     * The `{@link is}` property represents the natural name of this element.
     *
     * @public
     * @static
     * @readonly
     */
    static get is() {
        return 'mosaik-pattern';
    }
    /**
     * Gets or sets the `mouseX` property.
     *
     * @public
     */
    get mouseX() {
        return this._mouseX;
    }
    set mouseX(value) {
        if (this._mouseX !== value) {
            this._mouseX = value;
            this.requestUpdate('mouseX');
        }
    }
    /**
     * Gets or sets the `mouseY` property.
     *
     * @public
     */
    get mouseY() {
        return this._mouseY;
    }
    set mouseY(value) {
        if (this._mouseY !== value) {
            this._mouseY = value;
            this.requestUpdate('mouseY');
        }
    }
    // #endregion
    // #region Methods
    /**
     * @public
     * @override
     */
    disconnectedCallback() {
        super.disconnectedCallback();
        if (this._mouseMoveSubscription) {
            this._mouseMoveSubscription.dispose();
        }
    }
    /**
     * @protected
     * @override
     */
    onApplyTemplate() {
        super.onApplyTemplate();
        this._gradientFirstElement = this.getTemplatePart('gradient first');
        this._gradientSecondElement = this.getTemplatePart('gradient second');
        if (this.control) {
            this._mouseMoveSubscription = on(this.control, 'mousemove', (e) => this.onMouseMove(e));
        }
    }
    /**
     * @private
     */
    onMouseMove(event) {
        this._mouseX = event.offsetX;
        this._mouseY = event.offsetY;
        this.updateMaskStyle();
    }
    /**
     * Updates the mask style based on the current mouse coordinates.
     *
     * @private
     */
    updateMaskStyle() {
        const maskImage = `radial-gradient(180px at ${this._mouseX}px ${this._mouseY}px, white, transparent)`;
        this._gradientFirstElement.style.maskImage = maskImage;
        this._gradientSecondElement.style.maskImage = maskImage;
    }
};
__decorate([
    Property({ type: Number }),
    __metadata("design:type", Number),
    __metadata("design:paramtypes", [Number])
], PatternElement.prototype, "mouseX", null);
__decorate([
    Property({ type: Number }),
    __metadata("design:type", Number),
    __metadata("design:paramtypes", [Number])
], PatternElement.prototype, "mouseY", null);
PatternElement = __decorate([
    Component({
        selector: 'mosaik-pattern',
        template: patternElementTemplate,
        themes: {
            joy: patternElementJoyStyle,
            retro: patternElementRetroStyle,
            cosmopolitan: patternElementCosmopolitanStyle
        },
        imports: []
    }),
    __metadata("design:paramtypes", [])
], PatternElement);
export { PatternElement };
//# sourceMappingURL=PatternElement.js.map