// #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 { fadeOut, fadeSlideIn } from '../../../../Animations/Presets/Fade';
import { Emit } from '../../../../events/Decorators/EmitDecorator';
import { IntlController } from '../../../../Intl/IntlController';
import { Animatable } from '../../../Behaviors/Animatable';
import { Elevatable } from '../../../Behaviors/Elevatable';
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 { ButtonElement } from '../../Buttons/Button/ButtonElement';
import { BannerElement } from '../../Grouping/Banner/BannerElement';
import { cookiesConsentElementTemplate } from './CookiesConsentElementTemplate';
import { CookiesConsentElementIntl } from './Intl/CookiesConsentElementIntl';
import { cookiesConsentElementCosmopolitanStyle } from './Themes/CookiesConsentElement.Cosmopolitan';
import { cookiesConsentElementJoyStyle } from './Themes/CookiesConsentElement.Joy';
import { cookiesConsentElementMemphisStyle } from './Themes/CookiesConsentElement.Memphis';
// #endregion
/**
 * CookiesConsent - A configurable notification banner for managing user cookie consent and privacy preferences.
 *
 * @description
 * The CookiesConsent component provides a comprehensive, GDPR-compliant interface for informing users
 * about cookie usage and capturing their consent preferences. It presents an elevated banner with
 * customizable messaging, configurable action buttons for accepting or dismissing the disclaimer,
 * and intelligent state management to track user responses. The component features smooth fade-in
 * and fade-slide animations, internationalization support through the IntlController, and flexible
 * positioning capabilities. It can be configured to show or hide accept/dismiss buttons independently,
 * making it adaptable to various compliance requirements and user experience patterns. The component
 * automatically animates out when users interact with the consent options, providing a polished
 * and professional privacy management experience.
 *
 * @name CookiesConsent
 * @element mosaik-cookies-consent
 * @category Misc
 *
 * @slot actions - Custom action buttons to override or extend the default accept/dismiss buttons
 *
 * @csspart banner - The banner container element displaying the cookie consent message
 *
 * @cssprop {String} --cookies-consent-position - The positioning context for the consent banner
 * @cssprop {String} --cookies-consent-bottom - The distance from the bottom edge of the viewport
 * @cssprop {String} --cookies-consent-left - The distance from the left edge of the viewport
 * @cssprop {String} --cookies-consent-right - The distance from the right edge of the viewport
 * @cssprop {String} --cookies-consent-width - The width of the consent banner
 * @cssprop {String} --cookies-consent-z-index - The stacking order above other page content
 * @cssprop {String} --cookies-consent-margin - The outer spacing around the consent banner
 *
 * @dependency {BannerElement} - Banner container for the consent message and actions
 * @dependency {ButtonElement} - Action buttons for accept and dismiss operations
 *
 * @fires cookiesAccepted {CookiesAcceptedEvent} - Fired when the user accepts the cookies disclaimer by clicking the accept button
 * @fires cookiesDismissed {CookiesDismissedEvent} - Fired when the user dismisses the cookies disclaimer by clicking the dismiss button
 *
 * @example
 * Basic cookie consent banner (shows by default):
 * ```html
 * <mosaik-cookies-consent acceptable dismissable></mosaik-cookies-consent>
 * ```
 *
 * @example
 * Cookie consent with only accept button:
 * ```html
 * <mosaik-cookies-consent acceptable></mosaik-cookies-consent>
 * ```
 *
 * @example
 * Hidden after user has already accepted:
 * ```html
 * <mosaik-cookies-consent
 *   acceptable
 *   dismissable
 *   has-accepted-cookies>
 * </mosaik-cookies-consent>
 * ```
 *
 * @example
 * With elevated appearance:
 * ```html
 * <mosaik-cookies-consent
 *   acceptable
 *   dismissable
 *   elevation="bold">
 * </mosaik-cookies-consent>
 * ```
 *
 * @example
 * With custom action buttons:
 * ```html
 * <mosaik-cookies-consent>
 *   <mosaik-button slot="actions" variant="secondary"><span slot="label">Learn More</span></mosaik-button>
 *   <mosaik-button slot="actions" variant="primary"><span slot="label">Accept All</span></mosaik-button>
 * </mosaik-cookies-consent>
 * ```
 *
 * @public
 */
let CookiesConsentElement = class CookiesConsentElement extends Themeable(Animatable(Elevatable(CustomElement))) {
    // #region Fields
    _intl;
    _accepted;
    _dismissed;
    _hasAcceptedCookies;
    _acceptable;
    _dismissable;
    // #endregion
    // #region Ctor
    /**
     * @public
     */
    constructor() {
        super();
        this._intl = new IntlController(this, {
            factory: () => new CookiesConsentElementIntl()
        });
        this._hasAcceptedCookies = false;
        this._acceptable = false;
        this._dismissable = false;
        this._accepted = new HTMLElementEventEmitter(this, 'cookiesAccepted');
        this._dismissed = new HTMLElementEventEmitter(this, 'cookiesDismissed');
    }
    // #endregion
    // #region Properties
    /**
     * Returns the `is` property.
     * The `is` property represents natural name of this element.
     *
     * @public
     * @static
     * @readonly
     */
    static get is() {
        return 'mosaik-cookies-consent';
    }
    /**
     * Gets or sets the `hasAcceptedCookies` property.
     * Indicates whether the user has already accepted the cookies disclaimer.
     * When true, the consent banner is hidden. The default value is false.
     *
     * @public
     * @attr
     */
    get hasAcceptedCookies() {
        return this._hasAcceptedCookies;
    }
    set hasAcceptedCookies(value) {
        if (this._hasAcceptedCookies !== value) {
            this._hasAcceptedCookies = value;
            this.requestUpdate('hasAcceptedCookies');
        }
    }
    /**
     * Gets or sets the `acceptable` property.
     * Controls whether the accept button is displayed in the consent banner.
     * The default value is false.
     *
     * @public
     * @attr
     */
    get acceptable() {
        return this._acceptable;
    }
    set acceptable(value) {
        if (this._acceptable !== value) {
            this._acceptable = value;
            this.requestUpdate('acceptable');
        }
    }
    /**
     * Gets or sets the `dismissable` property.
     * Controls whether the dismiss button is displayed in the consent banner.
     * The default value is false.
     *
     * @public
     * @attr
     */
    get dismissable() {
        return this._dismissable;
    }
    set dismissable(value) {
        if (this._dismissable !== value) {
            this._dismissable = value;
            this.requestUpdate('dismissable');
        }
    }
    /**
     * Called when the user accepts the cookies disclaimer.
     * Provides reference to `IEventDetail` as event detail.
     *
     * @public
     * @readonly
     * @eventProperty
     */
    get accepted() {
        return this._accepted;
    }
    /**
     * Called when the user dismisses the cookies disclaimer.
     * Provides reference to `IEventDetail` as event detail.
     *
     * @public
     * @readonly
     * @eventProperty
     */
    get dismissed() {
        return this._dismissed;
    }
    /**
     * Gets or sets the `intl` property.
     * Provides access to the internationalization controller for localized messages.
     *
     * @public
     */
    get intl() {
        return this._intl.intl;
    }
    set intl(value) {
        this._intl.provide(value);
    }
    // #endregion
    // #region Methods
    /**
     * @public
     * @override
     */
    onEnterAnimation() {
        return this.play(fadeSlideIn);
    }
    /**
     * @public
     * @override
     */
    onExitAnimation() {
        return this.play(fadeOut);
    }
    /**
     * @public
     * @override
     */
    disconnectedCallback() {
        super.disconnectedCallback();
    }
    /**
     * Emits the `accepted` event.
     *
     * @protected
     */
    onAccepted(args) {
        this.hasAcceptedCookies = true;
        void this.onExitAnimation().then(() => {
            this._accepted.emit(args);
        });
    }
    /**
     * Emits the `dismissed` event.
     *
     * @protected
     */
    onDismissed(args) {
        this.hasAcceptedCookies = false;
        void this.onExitAnimation().then(() => {
            this._dismissed.emit(args);
        });
    }
    /**
     * @private
     * @template
     */
    onAccept() {
        this.onAccepted({});
    }
    /**
     * @private
     * @template
     */
    onDismiss() {
        this.onDismissed({});
    }
};
__decorate([
    Attribute({
        type: Boolean,
        useDefault: true
    }),
    __metadata("design:type", Boolean),
    __metadata("design:paramtypes", [Boolean])
], CookiesConsentElement.prototype, "hasAcceptedCookies", null);
__decorate([
    Attribute({
        type: Boolean,
        useDefault: true
    }),
    __metadata("design:type", Boolean),
    __metadata("design:paramtypes", [Boolean])
], CookiesConsentElement.prototype, "acceptable", null);
__decorate([
    Attribute({
        type: Boolean,
        useDefault: true
    }),
    __metadata("design:type", Boolean),
    __metadata("design:paramtypes", [Boolean])
], CookiesConsentElement.prototype, "dismissable", null);
__decorate([
    Emit({ eventName: 'cookiesAccepted' }),
    __metadata("design:type", Object),
    __metadata("design:paramtypes", [])
], CookiesConsentElement.prototype, "accepted", null);
__decorate([
    Emit({ eventName: 'cookiesDismissed' }),
    __metadata("design:type", Object),
    __metadata("design:paramtypes", [])
], CookiesConsentElement.prototype, "dismissed", null);
__decorate([
    Property({ type: Object }),
    __metadata("design:type", CookiesConsentElementIntl),
    __metadata("design:paramtypes", [CookiesConsentElementIntl])
], CookiesConsentElement.prototype, "intl", null);
CookiesConsentElement = __decorate([
    Component({
        selector: 'mosaik-cookies-consent',
        template: cookiesConsentElementTemplate,
        themes: {
            joy: cookiesConsentElementJoyStyle,
            memphis: cookiesConsentElementMemphisStyle,
            cosmopolitan: cookiesConsentElementCosmopolitanStyle
        },
        imports: [
            BannerElement,
            ButtonElement
        ]
    }),
    __metadata("design:paramtypes", [])
], CookiesConsentElement);
export { CookiesConsentElement };
//# sourceMappingURL=CookiesConsentElement.js.map