/**
 * Item-equality helpers for Select. Mirrors Base UI React's
 * `packages/react/src/internals/itemEquality.ts`. The Solid port copies
 * the three functions the select machinery needs (default comparison,
 * find-index, remove-from-array). Kept local under `select/utils/` rather
 * than promoted to `src/internals/` since no other compound uses them yet.
 */

export function defaultItemEquality(a, b) {
  return Object.is(a, b);
}
export function compareItemEquality(itemValue, selectedValue, comparer) {
  try {
    return comparer(itemValue, selectedValue);
  } catch {
    return false;
  }
}
export function findItemIndex(values, target, comparer) {
  for (let i = 0; i < values.length; i += 1) {
    if (compareItemEquality(values[i], target, comparer)) return i;
  }
  return -1;
}
export function removeItem(list, item, comparer) {
  const idx = findItemIndex(list, item, comparer);
  if (idx === -1) return list.slice();
  const next = list.slice();
  next.splice(idx, 1);
  return next;
}
//# sourceMappingURL=item-equality.jsx.map
