"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.ItemComponents = void 0;
var _react = _interopRequireDefault(require("react"));
var _jsxRuntime = require("react/jsx-runtime");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
function DefaultItem({
  item,
  nameKey = 'title',
  searchValue = ''
}) {
  const name = String(item?.[nameKey] ?? '');
  const index = name.toLowerCase().indexOf(searchValue.toLowerCase());
  if (index === -1 || searchValue === '') {
    return /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
      className: "no-match",
      "test-id": "no-match",
      children: name
    });
  }
  const left = name.slice(0, index);
  const strong = name.slice(index, index + searchValue.length);
  const right = name.slice(index + searchValue.length);
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
    children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
      className: "left-of-match",
      "test-id": "left-of-match",
      children: left
    }), /*#__PURE__*/(0, _jsxRuntime.jsx)("strong", {
      className: "matched",
      "test-id": "matched",
      children: strong
    }), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
      className: "right-of-match",
      "test-id": "right-of-match",
      children: right
    })]
  });
}
const ItemComponents = exports.ItemComponents = {
  DefaultItem
};