import React from 'react';
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
function DefaultItem({
  item,
  nameKey = 'title',
  searchValue = ''
}) {
  const name = String(item?.[nameKey] ?? '');
  const index = name.toLowerCase().indexOf(searchValue.toLowerCase());
  if (index === -1 || searchValue === '') {
    return /*#__PURE__*/_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__*/_jsxs(_Fragment, {
    children: [/*#__PURE__*/_jsx("span", {
      className: "left-of-match",
      "test-id": "left-of-match",
      children: left
    }), /*#__PURE__*/_jsx("strong", {
      className: "matched",
      "test-id": "matched",
      children: strong
    }), /*#__PURE__*/_jsx("span", {
      className: "right-of-match",
      "test-id": "right-of-match",
      children: right
    })]
  });
}
export const ItemComponents = {
  DefaultItem
};