"use strict";
var __webpack_require__ = {};
(()=>{
    __webpack_require__.n = (module)=>{
        var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
        __webpack_require__.d(getter, {
            a: getter
        });
        return getter;
    };
})();
(()=>{
    __webpack_require__.d = (exports1, definition)=>{
        for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
            enumerable: true,
            get: definition[key]
        });
    };
})();
(()=>{
    __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
})();
(()=>{
    __webpack_require__.r = (exports1)=>{
        if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
            value: 'Module'
        });
        Object.defineProperty(exports1, '__esModule', {
            value: true
        });
    };
})();
var __webpack_exports__ = {};
__webpack_require__.r(__webpack_exports__);
__webpack_require__.d(__webpack_exports__, {
    AtomicNotifications: ()=>AtomicNotifications
});
require("../../common/atomic-icon/atomic-icon.cjs");
const bueno_namespaceObject = require("@coveo/bueno");
const headless_namespaceObject = require("@coveo/headless");
const external_lit_namespaceObject = require("lit");
const decorators_js_namespaceObject = require("lit/decorators.js");
const map_js_namespaceObject = require("lit/directives/map.js");
const heading_cjs_namespaceObject = require("../../common/heading.cjs");
const validate_props_controller_cjs_namespaceObject = require("../../common/validate-props-controller/validate-props-controller.cjs");
const bind_state_cjs_namespaceObject = require("../../../decorators/bind-state.cjs");
const binding_guard_cjs_namespaceObject = require("../../../decorators/binding-guard.cjs");
const bindings_cjs_namespaceObject = require("../../../decorators/bindings.cjs");
const error_guard_cjs_namespaceObject = require("../../../decorators/error-guard.cjs");
const with_tailwind_styles_cjs_namespaceObject = require("../../../decorators/with-tailwind-styles.cjs");
const bindings_mixin_cjs_namespaceObject = require("../../../mixins/bindings-mixin.cjs");
const accessibility_utils_cjs_namespaceObject = require("../../../utils/accessibility-utils.cjs");
const info_cjs_namespaceObject = require("../../../images/info.cjs");
var info_cjs_default = /*#__PURE__*/ __webpack_require__.n(info_cjs_namespaceObject);
function _ts_decorate(decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) 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;
}
function _ts_metadata(k, v) {
    if ("object" == typeof Reflect && "function" == typeof Reflect.metadata) return Reflect.metadata(k, v);
}
class AtomicNotifications extends (0, bindings_mixin_cjs_namespaceObject.InitializeBindingsMixin)(external_lit_namespaceObject.LitElement) {
    initialize() {
        this.notifyTrigger = (0, headless_namespaceObject.buildNotifyTrigger)(this.bindings.engine);
    }
    get notifications() {
        return this.notifyTriggerState?.notifications || [];
    }
    generateAriaMessage() {
        if (1 === this.notifications.length) return this.notifications[0];
        return this.notifications.map((text, i)=>this.bindings.i18n.t('notification-n', {
                n: i + 1,
                text
            })).join('\n');
    }
    renderNotification(text) {
        return (0, external_lit_namespaceObject.html)`
      <div
        part="notification"
        class="bg-background border-neutral-dark flex items-center rounded-md border p-6 shadow-lg"
      >
        <atomic-icon
          icon=${this.icon ?? info_cjs_default()}
          part="icon"
          class="text-neutral-dark mr-6 h-7 w-7"
        ></atomic-icon>
        <span part="text" class="text-on-background text-base leading-5">
          ${text}
        </span>
      </div>
    `;
    }
    renderNotifications() {
        return (0, external_lit_namespaceObject.html)`
      <div part="notifications" class="flex flex-col gap-4">
        ${(0, map_js_namespaceObject.map)(this.notifications, (text)=>this.renderNotification(text))}
      </div>
    `;
    }
    render() {
        if (!this.notifications.length) return external_lit_namespaceObject.nothing;
        this.ariaMessage.message = this.generateAriaMessage();
        return (0, external_lit_namespaceObject.html)`
      ${(0, heading_cjs_namespaceObject.renderHeading)({
            props: {
                level: this.headingLevel,
                class: 'sr-only'
            }
        })((0, external_lit_namespaceObject.html)`${this.bindings.i18n.t('notifications')}`)}
      ${this.renderNotifications()}
    `;
    }
    constructor(){
        super(), this.headingLevel = 0, this.ariaMessage = new accessibility_utils_cjs_namespaceObject.AriaLiveRegionController(this, 'notifications');
        new validate_props_controller_cjs_namespaceObject.ValidatePropsController(this, ()=>({
                headingLevel: this.headingLevel
            }), AtomicNotifications.schema, false);
    }
}
AtomicNotifications.schema = new bueno_namespaceObject.Schema({
    headingLevel: new bueno_namespaceObject.NumberValue({
        min: 0,
        max: 6,
        required: false
    })
});
_ts_decorate([
    (0, decorators_js_namespaceObject.state)(),
    _ts_metadata("design:type", "u" < typeof Bindings ? Object : Bindings)
], AtomicNotifications.prototype, "bindings", void 0);
_ts_decorate([
    (0, decorators_js_namespaceObject.state)(),
    _ts_metadata("design:type", "u" < typeof Error ? Object : Error)
], AtomicNotifications.prototype, "error", void 0);
_ts_decorate([
    (0, decorators_js_namespaceObject.property)({
        type: Number,
        reflect: true,
        attribute: 'heading-level'
    })
], AtomicNotifications.prototype, "headingLevel", void 0);
_ts_decorate([
    (0, decorators_js_namespaceObject.property)({
        type: String,
        reflect: true
    }),
    _ts_metadata("design:type", String)
], AtomicNotifications.prototype, "icon", void 0);
_ts_decorate([
    (0, bind_state_cjs_namespaceObject.bindStateToController)('notifyTrigger'),
    (0, decorators_js_namespaceObject.state)(),
    _ts_metadata("design:type", "u" < typeof NotifyTriggerState ? Object : NotifyTriggerState)
], AtomicNotifications.prototype, "notifyTriggerState", void 0);
_ts_decorate([
    (0, binding_guard_cjs_namespaceObject.bindingGuard)(),
    (0, error_guard_cjs_namespaceObject.errorGuard)(),
    _ts_metadata("design:type", Function),
    _ts_metadata("design:paramtypes", []),
    _ts_metadata("design:returntype", void 0)
], AtomicNotifications.prototype, "render", null);
AtomicNotifications = _ts_decorate([
    (0, decorators_js_namespaceObject.customElement)('atomic-notifications'),
    (0, bindings_cjs_namespaceObject.bindings)(),
    with_tailwind_styles_cjs_namespaceObject.withTailwindStyles,
    _ts_metadata("design:type", Function),
    _ts_metadata("design:paramtypes", [])
], AtomicNotifications);
exports.AtomicNotifications = __webpack_exports__.AtomicNotifications;
for(var __rspack_i in __webpack_exports__)if (-1 === [
    "AtomicNotifications"
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
Object.defineProperty(exports, '__esModule', {
    value: true
});
