// #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 { HTMLElementEventEmitter } from '@breadstone/mosaik-elements';
import { Emit } from '../../../../events/Decorators/EmitDecorator';
import { Disableable } from '../../../Behaviors/Disableable';
import { Focusable } from '../../../Behaviors/Focusable';
import { Themeable } from '../../../Behaviors/Themeable';
import { Attribute } from '../../../Decorators/AttributeDecorator';
import { Component } from '../../../Decorators/ComponentDecorator';
import { Property } from '../../../Decorators/PropertyDecorator';
import { CustomElement } from '../../Abstracts/CustomElement';
import { colorEditorSwatchElementTemplate } from './ColorEditorSwatchElementTemplate';
import { colorEditorSwatchElementCosmopolitanStyle } from './Themes/ColorEditorSwatchElement.Cosmopolitan';
import { colorEditorSwatchElementJoyStyle } from './Themes/ColorEditorSwatchElement.Joy';
import { colorEditorSwatchElementMemphisStyle } from './Themes/ColorEditorSwatchElement.Memphis';
// #endregion
/**
 * Color Editor Swatch - A color preview element with optional copy functionality.
 *
 * @description
 * The Color Editor Swatch component displays a preview of a color with an optional
 * copy-to-clipboard button. It includes a checkerboard background pattern to indicate
 * transparency levels and automatically adjusts border visibility based on color
 * brightness.
 *
 * @name ColorEditorSwatch
 * @element mosaik-color-editor-swatch
 * @category Media
 *
 * @csspart checkerboard - The checkerboard part.
 * @csspart color - The color display area
 * @csspart copy-button - The copy to clipboard button overlay
 *
 * @cssprop {String} --color-editor-swatch-background-color - The editor swatch background color CSS custom property.
 * @cssprop {String} --color-editor-swatch-border-color - The editor swatch border color CSS custom property.
 * @cssprop {String} --color-editor-swatch-border-radius - The editor swatch border radius CSS custom property.
 * @cssprop {String} --color-editor-swatch-border-style - The editor swatch border style CSS custom property.
 * @cssprop {String} --color-editor-swatch-border-width - The editor swatch border width CSS custom property.
 * @cssprop {String} --color-editor-swatch-checkerboard-size - The editor swatch checkerboard size CSS custom property.
 * @cssprop {String} --color-editor-swatch-font-family - The editor swatch font family CSS custom property.
 * @cssprop {String} --color-editor-swatch-font-letter-spacing - The editor swatch font letter spacing CSS custom property.
 * @cssprop {String} --color-editor-swatch-font-line-height - The editor swatch font line height CSS custom property.
 * @cssprop {String} --color-editor-swatch-font-size - The editor swatch font size CSS custom property.
 * @cssprop {String} --color-editor-swatch-font-text-decoration - The editor swatch font text decoration CSS custom property.
 * @cssprop {String} --color-editor-swatch-font-text-transform - The editor swatch font text transform CSS custom property.
 * @cssprop {String} --color-editor-swatch-font-weight - The editor swatch font weight CSS custom property.
 * @cssprop {String} --color-editor-swatch-foreground-color - The editor swatch foreground color CSS custom property.
 * @cssprop {String} --color-editor-swatch-gap - The editor swatch gap CSS custom property.
 * @cssprop {String} --color-editor-swatch-height - The editor swatch height CSS custom property.
 * @cssprop {String} --color-editor-swatch-padding-bottom - The editor swatch padding bottom CSS custom property.
 * @cssprop {String} --color-editor-swatch-padding-left - The editor swatch padding left CSS custom property.
 * @cssprop {String} --color-editor-swatch-padding-right - The editor swatch padding right CSS custom property.
 * @cssprop {String} --color-editor-swatch-padding-top - The editor swatch padding top CSS custom property.
 * @cssprop {String} --color-editor-swatch-shadow - The editor swatch shadow CSS custom property.
 * @cssprop {String} --color-editor-swatch-shadow-blur - The editor swatch shadow blur CSS custom property.
 * @cssprop {String} --color-editor-swatch-shadow-color - The editor swatch shadow color CSS custom property.
 * @cssprop {String} --color-editor-swatch-shadow-offset-x - The editor swatch shadow offset x CSS custom property.
 * @cssprop {String} --color-editor-swatch-shadow-offset-y - The editor swatch shadow offset y CSS custom property.
 * @cssprop {String} --color-editor-swatch-shadow-spread - The editor swatch shadow spread CSS custom property.
 * @cssprop {String} --color-editor-swatch-transition-duration - The editor swatch transition duration CSS custom property.
 * @cssprop {String} --color-editor-swatch-transition-mode - The editor swatch transition mode CSS custom property.
 * @cssprop {String} --color-editor-swatch-transition-property - The editor swatch transition property CSS custom property.
 * @cssprop {String} --color-editor-swatch-translate - The editor swatch translate CSS custom property.
 * @cssprop {String} --color-editor-swatch-width - The editor swatch width CSS custom property.
 *
 * @fires swatchCopy {SwatchCopyEvent} - Fired when the color is copied to clipboard
 *
 * @dependency mosaik-button - The Button element.
 *
 * @example
 * Basic usage displaying a color:
 * ```html
 * <mosaik-color-editor-swatch color="#e91e63"></mosaik-color-editor-swatch>
 * ```
 *
 * @example
 * Disabled state:
 * ```html
 * <mosaik-color-editor-swatch color="#1976d2" disabled></mosaik-color-editor-swatch>
 * ```
 *
 * @public
 */
let ColorEditorSwatchElement = class ColorEditorSwatchElement extends Themeable(Disableable(Focusable(CustomElement))) {
    // #region Fields
    _swatchCopy;
    _color;
    _copyable;
    // #endregion
    // #region Ctor
    /**
     * Constructs a new instance of the ColorEditorSwatchElement class.
     *
     * @public
     */
    constructor() {
        super();
        this._swatchCopy = new HTMLElementEventEmitter(this, 'swatchCopy');
        this._color = '#ff0000';
        this._copyable = false;
    }
    // #endregion
    // #region Properties
    /**
     * Returns the `is` property.
     * The `is` property represents natural name of this element.
     *
     * @public
     * @static
     * @readonly
     */
    static get is() {
        return 'mosaik-color-editor-swatch';
    }
    /**
     * Gets or sets the color to display.
     *
     * @public
     * @attr
     */
    get color() {
        return this._color;
    }
    set color(value) {
        if (this._color !== value) {
            this._color = value;
            this.requestUpdate('color');
        }
    }
    /**
     * Gets or sets whether the swatch shows a copy button on hover.
     *
     * @public
     */
    get copyable() {
        return this._copyable;
    }
    set copyable(value) {
        if (this._copyable !== value) {
            this._copyable = value;
            this.requestUpdate('copyable');
        }
    }
    /**
     * Called when the color is copied to clipboard.
     * Provides reference to `ISwatchCopyEventDetail` as event detail.
     *
     * @public
     * @readonly
     * @eventProperty
     */
    get swatchCopy() {
        return this._swatchCopy;
    }
    // #endregion
    // #region Methods
    /**
     * Handles click on the copy button.
     *
     * @public
     */
    async pick() {
        try {
            await navigator.clipboard.writeText(this._color);
            this._swatchCopy.emit({ color: this._color });
        }
        catch (error) {
            console.error('Failed to copy color to clipboard:', error);
        }
    }
    /**
     * @private
     */
    onPick(event) {
        event.stopPropagation();
        void this.pick();
    }
};
__decorate([
    Attribute({ type: String }),
    __metadata("design:type", String),
    __metadata("design:paramtypes", [String])
], ColorEditorSwatchElement.prototype, "color", null);
__decorate([
    Property({
        type: Boolean,
        useDefault: true
    }),
    __metadata("design:type", Boolean),
    __metadata("design:paramtypes", [Boolean])
], ColorEditorSwatchElement.prototype, "copyable", null);
__decorate([
    Emit({ eventName: 'swatchCopy' }),
    __metadata("design:type", Object),
    __metadata("design:paramtypes", [])
], ColorEditorSwatchElement.prototype, "swatchCopy", null);
ColorEditorSwatchElement = __decorate([
    Component({
        selector: 'mosaik-color-editor-swatch',
        template: colorEditorSwatchElementTemplate,
        themes: {
            joy: colorEditorSwatchElementJoyStyle,
            memphis: colorEditorSwatchElementMemphisStyle,
            cosmopolitan: colorEditorSwatchElementCosmopolitanStyle
        }
    }),
    __metadata("design:paramtypes", [])
], ColorEditorSwatchElement);
export { ColorEditorSwatchElement };
//# sourceMappingURL=ColorEditorSwatchElement.js.map