"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__, {
    AtomicInsightResult: ()=>AtomicInsightResult
});
const bueno_namespaceObject = require("@coveo/bueno");
const external_lit_namespaceObject = require("lit");
const decorators_js_namespaceObject = require("lit/decorators.js");
const ref_js_namespaceObject = require("lit/directives/ref.js");
const unsafe_html_js_namespaceObject = require("lit/directives/unsafe-html.js");
const custom_render_controller_cjs_namespaceObject = require("../../common/layout/custom-render-controller.cjs");
const item_layout_controller_cjs_namespaceObject = require("../../common/layout/item-layout-controller.cjs");
const validate_props_controller_cjs_namespaceObject = require("../../common/validate-props-controller/validate-props-controller.cjs");
const boolean_converter_cjs_namespaceObject = require("../../../converters/boolean-converter.cjs");
const with_tailwind_styles_cjs_namespaceObject = require("../../../decorators/with-tailwind-styles.cjs");
const children_update_complete_mixin_cjs_namespaceObject = require("../../../mixins/children-update-complete-mixin.cjs");
const dom_utils_cjs_namespaceObject = require("../../../utils/dom-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 AtomicInsightResult extends (0, children_update_complete_mixin_cjs_namespaceObject.ChildrenUpdateCompleteMixin)(external_lit_namespaceObject.LitElement) {
    async connectedCallback() {
        super.connectedCallback();
        new custom_render_controller_cjs_namespaceObject.CustomRenderController(this, {
            renderingFunction: ()=>this.renderingFunction,
            itemData: ()=>this.result,
            rootElementRef: ()=>this.resultRootRef.value,
            onRenderComplete: (element, output)=>{
                this.itemLayoutController.applyLayoutClassesToElement(element, output);
            }
        });
        this.itemLayoutController = new item_layout_controller_cjs_namespaceObject.ItemLayoutController(this, {
            elementPrefix: 'atomic-insight-result',
            renderingFunction: ()=>this.renderingFunction,
            content: ()=>this.content,
            layoutConfig: ()=>({
                    display: 'list',
                    density: this.density,
                    imageSize: this.imageSize
                }),
            itemClasses: ()=>this.classes,
            classesOnly: true
        });
        this.addEventListener('atomic/resolveResult', this.resolveResult);
        this.addEventListener('atomic/resolveInteractiveResult', this.resolveInteractiveResult);
        this.addEventListener('atomic/resolveStopPropagation', this.resolveStopPropagation);
        this.addEventListener('atomic/resolveResultDisplayConfig', this.resolveResultDisplayConfig);
        await this.getUpdateComplete();
        this.classList.add('hydrated');
        this.classList.add('result-component');
    }
    disconnectedCallback() {
        super.disconnectedCallback();
        this.removeEventListener('atomic/resolveResult', this.resolveResult);
        this.removeEventListener('atomic/resolveInteractiveResult', this.resolveInteractiveResult);
        this.removeEventListener('atomic/resolveStopPropagation', this.resolveStopPropagation);
        this.removeEventListener('atomic/resolveResultDisplayConfig', this.resolveResultDisplayConfig);
    }
    getContentHTML() {
        if (!this.content) {
            console.warn('atomic-insight-result: content property is undefined. Cannot get content HTML.', this);
            return '';
        }
        return (0, dom_utils_cjs_namespaceObject.parentNodeToString)(this.content);
    }
    render() {
        if (void 0 !== this.renderingFunction) return (0, external_lit_namespaceObject.html)` <div class="result-root" ${(0, ref_js_namespaceObject.ref)(this.resultRootRef)}></div> `;
        if (!this.itemLayoutController.getLayout()) return external_lit_namespaceObject.nothing;
        return (0, external_lit_namespaceObject.html)`
      <div
        class="result-root ${this.itemLayoutController.getCombinedClasses().join(' ')}"
      >
        ${(0, unsafe_html_js_namespaceObject.unsafeHTML)(this.getContentHTML())}
      </div>
    `;
    }
    firstUpdated(_changedProperties) {
        if (this.loadingFlag && this.store) this.store.unsetLoadingFlag(this.loadingFlag);
    }
    constructor(){
        super(), this.resultRootRef = (0, ref_js_namespaceObject.createRef)(), this.density = 'normal', this.imageSize = 'icon', this.classes = '', this.resolveResult = (event)=>{
            event.preventDefault();
            event.stopPropagation();
            event.detail(this.result);
        }, this.resolveInteractiveResult = (event)=>{
            event.preventDefault();
            event.stopPropagation();
            if (this.interactiveResult) event.detail(this.interactiveResult);
        }, this.resolveStopPropagation = (event)=>{
            event.detail(this.stopPropagation);
        }, this.resolveResultDisplayConfig = (event)=>{
            event.preventDefault();
            event.stopPropagation();
            event.detail({
                density: this.density,
                imageSize: this.imageSize
            });
        };
        new validate_props_controller_cjs_namespaceObject.ValidatePropsController(this, ()=>({
                density: this.density,
                imageSize: this.imageSize
            }), new bueno_namespaceObject.Schema({
            density: new bueno_namespaceObject.StringValue({
                constrainTo: [
                    'normal',
                    'comfortable',
                    'compact'
                ]
            }),
            imageSize: new bueno_namespaceObject.StringValue({
                constrainTo: [
                    'small',
                    'large',
                    'icon',
                    'none'
                ]
            })
        }));
    }
}
AtomicInsightResult.styles = (0, external_lit_namespaceObject.css)`
    @reference '../../../utils/tailwind.global.tw.css';
    @import '../../common/template-system/legacy-template-system.css';

    :host {
      @apply atomic-template-system;
      @apply relative;

      .with-sections:not(.child-result) {
        padding-top: var(--atomic-layout-spacing-y);
        padding-bottom: var(--atomic-layout-spacing-y);
        padding-right: var(--atomic-layout-spacing-x);
        padding-left: var(--atomic-layout-spacing-x);
      }
    }

    :host(:hover) .with-sections {
      @apply bg-neutral-lighter;
    }

    :host(:hover) atomic-insight-result-action-bar {
      @apply visible;
    }

    :host(:first-of-type) .with-sections:not(.child-result) {
      @apply pt-8;
    }

    :host(:first-of-type) atomic-insight-result-action-bar {
      @apply top-0;
    }
  `;
_ts_decorate([
    (0, decorators_js_namespaceObject.state)(),
    _ts_metadata("design:type", "u" < typeof Error ? Object : Error)
], AtomicInsightResult.prototype, "error", void 0);
_ts_decorate([
    (0, decorators_js_namespaceObject.property)({
        attribute: 'stop-propagation',
        type: Boolean,
        converter: boolean_converter_cjs_namespaceObject.booleanConverter,
        reflect: true
    }),
    _ts_metadata("design:type", Boolean)
], AtomicInsightResult.prototype, "stopPropagation", void 0);
_ts_decorate([
    (0, decorators_js_namespaceObject.property)({
        type: Object
    }),
    _ts_metadata("design:type", Object)
], AtomicInsightResult.prototype, "result", void 0);
_ts_decorate([
    (0, decorators_js_namespaceObject.property)({
        type: Object,
        attribute: 'interactive-result'
    }),
    _ts_metadata("design:type", "u" < typeof InsightInteractiveResult ? Object : InsightInteractiveResult)
], AtomicInsightResult.prototype, "interactiveResult", void 0);
_ts_decorate([
    (0, decorators_js_namespaceObject.property)({
        type: Object
    }),
    _ts_metadata("design:type", "u" < typeof InsightStore ? Object : InsightStore)
], AtomicInsightResult.prototype, "store", void 0);
_ts_decorate([
    (0, decorators_js_namespaceObject.property)({
        type: Object
    }),
    _ts_metadata("design:type", "u" < typeof ParentNode ? Object : ParentNode)
], AtomicInsightResult.prototype, "content", void 0);
_ts_decorate([
    (0, decorators_js_namespaceObject.property)({
        reflect: true,
        type: String
    }),
    _ts_metadata("design:type", "u" < typeof ItemDisplayDensity ? Object : ItemDisplayDensity)
], AtomicInsightResult.prototype, "density", void 0);
_ts_decorate([
    (0, decorators_js_namespaceObject.property)({
        reflect: true,
        type: String,
        attribute: 'image-size'
    }),
    _ts_metadata("design:type", "u" < typeof ItemDisplayImageSize ? Object : ItemDisplayImageSize)
], AtomicInsightResult.prototype, "imageSize", void 0);
_ts_decorate([
    (0, decorators_js_namespaceObject.property)({
        type: String
    })
], AtomicInsightResult.prototype, "classes", void 0);
_ts_decorate([
    (0, decorators_js_namespaceObject.property)({
        type: String,
        attribute: 'loading-flag'
    }),
    _ts_metadata("design:type", String)
], AtomicInsightResult.prototype, "loadingFlag", void 0);
_ts_decorate([
    (0, decorators_js_namespaceObject.property)({
        type: Object,
        attribute: 'rendering-function'
    }),
    _ts_metadata("design:type", "u" < typeof ItemRenderingFunction ? Object : ItemRenderingFunction)
], AtomicInsightResult.prototype, "renderingFunction", void 0);
AtomicInsightResult = _ts_decorate([
    (0, decorators_js_namespaceObject.customElement)('atomic-insight-result'),
    with_tailwind_styles_cjs_namespaceObject.withTailwindStyles,
    _ts_metadata("design:type", Function),
    _ts_metadata("design:paramtypes", [])
], AtomicInsightResult);
exports.AtomicInsightResult = __webpack_exports__.AtomicInsightResult;
for(var __rspack_i in __webpack_exports__)if (-1 === [
    "AtomicInsightResult"
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
Object.defineProperty(exports, '__esModule', {
    value: true
});
