"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__, {
    highlightSearchResult: ()=>highlightSearchResult,
    shouldDisplaySearchResults: ()=>shouldDisplaySearchResults,
    shouldUpdateFacetSearchComponent: ()=>shouldUpdateFacetSearchComponent
});
const external_escape_html_namespaceObject = require("escape-html");
var external_escape_html_default = /*#__PURE__*/ __webpack_require__.n(external_escape_html_namespaceObject);
const string_utils_cjs_namespaceObject = require("../../../../utils/string-utils.cjs");
function shouldUpdateFacetSearchComponent(nextFacetSearchState, prevFacetSearchState) {
    const hasQuery = '' !== nextFacetSearchState.query;
    const stillNoValues = !nextFacetSearchState.values.length && !prevFacetSearchState.values.length;
    const hasFinishedLoading = !nextFacetSearchState.isLoading && prevFacetSearchState.isLoading;
    if (hasQuery && stillNoValues) return hasFinishedLoading;
    return true;
}
function shouldDisplaySearchResults(facetSearchState) {
    const hasQuery = '' !== facetSearchState.query;
    const isLoading = facetSearchState.isLoading;
    const hasValues = !!facetSearchState.values.length;
    if (!hasQuery) return false;
    if (hasValues) return true;
    return !isLoading;
}
function highlightSearchResult(resultValue, searchQuery = '') {
    const sanitizedResult = external_escape_html_default()(resultValue);
    if ('' === searchQuery.trim()) return sanitizedResult;
    const regex = new RegExp(`(${(0, string_utils_cjs_namespaceObject.regexEncode)(external_escape_html_default()(searchQuery))})`, 'i');
    return external_escape_html_default()(resultValue).replace(regex, '<span part="search-highlight" class="font-bold">$1</span>');
}
exports.highlightSearchResult = __webpack_exports__.highlightSearchResult;
exports.shouldDisplaySearchResults = __webpack_exports__.shouldDisplaySearchResults;
exports.shouldUpdateFacetSearchComponent = __webpack_exports__.shouldUpdateFacetSearchComponent;
for(var __rspack_i in __webpack_exports__)if (-1 === [
    "highlightSearchResult",
    "shouldDisplaySearchResults",
    "shouldUpdateFacetSearchComponent"
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
Object.defineProperty(exports, '__esModule', {
    value: true
});
