"use strict";
var __webpack_require__ = {};
(()=>{
    __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__, {
    AtomicRecsError: ()=>AtomicRecsError
});
const recommendation_namespaceObject = require("@coveo/headless/recommendation");
const external_lit_namespaceObject = require("lit");
const decorators_js_namespaceObject = require("lit/decorators.js");
const when_js_namespaceObject = require("lit/directives/when.js");
const container_cjs_namespaceObject = require("../../common/query-error/container.cjs");
const description_cjs_namespaceObject = require("../../common/query-error/description.cjs");
const details_cjs_namespaceObject = require("../../common/query-error/details.cjs");
const icon_cjs_namespaceObject = require("../../common/query-error/icon.cjs");
const link_cjs_namespaceObject = require("../../common/query-error/link.cjs");
const show_more_cjs_namespaceObject = require("../../common/query-error/show-more.cjs");
const title_cjs_namespaceObject = require("../../common/query-error/title.cjs");
const utils_cjs_namespaceObject = require("../../common/query-error/utils.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 accessibility_utils_cjs_namespaceObject = require("../../../utils/accessibility-utils.cjs");
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 AtomicRecsError extends external_lit_namespaceObject.LitElement {
    initialize() {
        this.recommendationList = (0, recommendation_namespaceObject.buildRecommendationList)(this.bindings.engine);
    }
    render() {
        const { error } = this.recommendationListState;
        const hasError = null != error;
        const i18n = this.bindings.i18n;
        const { organizationId, environment } = this.bindings.engine.state.configuration;
        const url = (0, recommendation_namespaceObject.getOrganizationEndpoint)(organizationId, environment);
        if (hasError) this.ariaMessage.message = (0, utils_cjs_namespaceObject.getAriaMessageFromErrorType)(i18n, organizationId, url, error?.type);
        const linkResult = (0, link_cjs_namespaceObject.renderQueryErrorLink)({
            props: {
                i18n,
                errorType: error?.type
            }
        });
        return (0, external_lit_namespaceObject.html)`${(0, when_js_namespaceObject.when)(hasError, ()=>(0, external_lit_namespaceObject.html)`
        ${(0, container_cjs_namespaceObject.renderQueryErrorContainer)()((0, external_lit_namespaceObject.html)`
          ${(0, icon_cjs_namespaceObject.renderQueryErrorIcon)({
                props: {
                    errorType: error?.type
                }
            })}
          ${(0, title_cjs_namespaceObject.renderQueryErrorTitle)({
                props: {
                    errorType: error?.type,
                    i18n,
                    organizationId
                }
            })}
          ${(0, description_cjs_namespaceObject.renderQueryErrorDescription)({
                props: {
                    i18n,
                    organizationId,
                    url,
                    errorType: error?.type
                }
            })}
          ${(0, show_more_cjs_namespaceObject.renderQueryErrorShowMore)({
                props: {
                    link: linkResult,
                    onShowMore: ()=>{
                        this.showMoreInfo = !this.showMoreInfo;
                    },
                    i18n
                }
            })}
          ${(0, details_cjs_namespaceObject.renderQueryErrorDetails)({
                props: {
                    error,
                    show: this.showMoreInfo
                }
            })}
        `)}
      `)}`;
    }
    constructor(...args){
        super(...args), this.ariaMessage = new accessibility_utils_cjs_namespaceObject.AriaLiveRegionController(this, 'recs-error'), this.showMoreInfo = false;
    }
}
_ts_decorate([
    (0, bind_state_cjs_namespaceObject.bindStateToController)('recommendationList'),
    (0, decorators_js_namespaceObject.state)(),
    _ts_metadata("design:type", "u" < typeof RecommendationListState ? Object : RecommendationListState)
], AtomicRecsError.prototype, "recommendationListState", void 0);
_ts_decorate([
    (0, decorators_js_namespaceObject.state)(),
    _ts_metadata("design:type", "u" < typeof RecsBindings ? Object : RecsBindings)
], AtomicRecsError.prototype, "bindings", void 0);
_ts_decorate([
    (0, decorators_js_namespaceObject.state)(),
    _ts_metadata("design:type", "u" < typeof Error ? Object : Error)
], AtomicRecsError.prototype, "error", void 0);
_ts_decorate([
    (0, decorators_js_namespaceObject.state)()
], AtomicRecsError.prototype, "showMoreInfo", void 0);
_ts_decorate([
    (0, error_guard_cjs_namespaceObject.errorGuard)(),
    (0, binding_guard_cjs_namespaceObject.bindingGuard)(),
    _ts_metadata("design:type", Function),
    _ts_metadata("design:paramtypes", []),
    _ts_metadata("design:returntype", void 0)
], AtomicRecsError.prototype, "render", null);
AtomicRecsError = _ts_decorate([
    (0, decorators_js_namespaceObject.customElement)('atomic-recs-error'),
    (0, bindings_cjs_namespaceObject.bindings)(),
    with_tailwind_styles_cjs_namespaceObject.withTailwindStyles
], AtomicRecsError);
exports.AtomicRecsError = __webpack_exports__.AtomicRecsError;
for(var __rspack_i in __webpack_exports__)if (-1 === [
    "AtomicRecsError"
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
Object.defineProperty(exports, '__esModule', {
    value: true
});
