'use strict';

var jsxRuntime = require('react/jsx-runtime');

function Highlight({
  className,
  value,
  query
}) {
  const content = /*#__PURE__*/jsxRuntime.jsx(HighlightContent, {
    value: value,
    query: query
  });
  return className ? /*#__PURE__*/jsxRuntime.jsx("span", {
    className: className,
    children: content
  }) : content;
}
function HighlightContent({
  value,
  query
}) {
  if (value && query) {
    const highlightStart = value.toUpperCase().indexOf(query.trim().toUpperCase());
    const highlightEnd = highlightStart + query.trim().length;
    if (highlightStart !== -1) {
      return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
        children: [value.slice(0, Math.max(0, highlightStart)), /*#__PURE__*/jsxRuntime.jsx("strong", {
          children: value.slice(highlightStart, highlightEnd)
        }), value.slice(Math.max(0, highlightEnd))]
      });
    }
  }
  return value;
}

module.exports = Highlight;
//# sourceMappingURL=highlight.js.map
