"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__, {
    getPartialRecentQueryClearElement: ()=>getPartialRecentQueryClearElement,
    getPartialRecentQueryElement: ()=>getPartialRecentQueryElement,
    renderRecentQuery: ()=>renderRecentQuery,
    renderRecentQueryClear: ()=>renderRecentQueryClear
});
require("../atomic-icon/atomic-icon.cjs");
const headless_namespaceObject = require("@coveo/headless");
const external_lit_namespaceObject = require("lit");
const when_js_namespaceObject = require("lit/directives/when.js");
const string_utils_cjs_namespaceObject = require("../../../utils/string-utils.cjs");
const getPartialRecentQueryElement = (value, i18n)=>({
        part: 'recent-query-item',
        query: value,
        key: `recent-${(0, string_utils_cjs_namespaceObject.encodeForDomAttribute)(value)}`,
        ariaLabel: i18n.t('recent-query-suggestion-label', {
            query: value,
            interpolation: {
                escapeValue: false
            }
        })
    });
const getPartialRecentQueryClearElement = (i18n)=>({
        key: 'recent-query-clear',
        ariaLabel: i18n.t('clear-recent-searches', {
            interpolation: {
                escapeValue: false
            }
        }),
        part: 'recent-query-title-item suggestion-divider',
        hideIfLast: true
    });
const renderRecentQuery = ({ icon, query, value })=>{
    const hasQuery = '' !== query;
    const template = (0, external_lit_namespaceObject.html)`<div
    part="recent-query-content"
    class="pointer-events-none flex items-center text-left break-all"
  >
    <atomic-icon
      part="recent-query-icon"
      icon=${icon}
      class="mr-2 h-4 w-4 shrink-0"
    ></atomic-icon>

    ${(0, when_js_namespaceObject.when)(hasQuery, ()=>(0, external_lit_namespaceObject.html)`<span
          part="recent-query-text"
          class="line-clamp-2 break-words"
          .innerHTML=${headless_namespaceObject.HighlightUtils.highlightString({
            content: value,
            openingDelimiter: '<span part="recent-query-text-highlight" class="font-bold">',
            closingDelimiter: '</span>',
            highlights: [
                {
                    offset: query.length,
                    length: value.length - query.length
                }
            ]
        })}
        ></span>`, ()=>(0, external_lit_namespaceObject.html)`<span part="recent-query-text" class="line-clamp-2 break-all">
          ${value}
        </span>`)}
  </div>`;
    const container = document.createElement('div');
    (0, external_lit_namespaceObject.render)(template, container);
    return container.firstElementChild;
};
const renderRecentQueryClear = ({ i18n })=>{
    const template = (0, external_lit_namespaceObject.html)` <div
    part="recent-query-title-content"
    class="pointer-events-none flex w-full justify-between"
  >
    <span class="font-bold" part="recent-query-title">
      ${i18n.t('recent-searches')}
    </span>
    <span part="recent-query-clear">${i18n.t('clear')}</span>
  </div>`;
    const container = document.createElement('div');
    (0, external_lit_namespaceObject.render)(template, container);
    return container.firstElementChild;
};
exports.getPartialRecentQueryClearElement = __webpack_exports__.getPartialRecentQueryClearElement;
exports.getPartialRecentQueryElement = __webpack_exports__.getPartialRecentQueryElement;
exports.renderRecentQuery = __webpack_exports__.renderRecentQuery;
exports.renderRecentQueryClear = __webpack_exports__.renderRecentQueryClear;
for(var __rspack_i in __webpack_exports__)if (-1 === [
    "getPartialRecentQueryClearElement",
    "getPartialRecentQueryElement",
    "renderRecentQuery",
    "renderRecentQueryClear"
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
Object.defineProperty(exports, '__esModule', {
    value: true
});
