import { invariant as i } from "../../../../../../@react-dnd_invariant@4.0.2/node_modules/@react-dnd/invariant/dist/index.js";
import { matchesType as s } from "../../utils/matchesType.js";
import { HOVER as f } from "./types.js";
function v(t) {
  return function(n, { clientOffset: e } = {}) {
    l(n);
    const r = n.slice(0), a = t.getMonitor(), c = t.getRegistry(), g = a.getItemType();
    return d(r, c, g), p(r, a, c), y(r, a, c), {
      type: f,
      payload: {
        targetIds: r,
        clientOffset: e || null
      }
    };
  };
}
function l(t) {
  i(Array.isArray(t), "Expected targetIds to be an array.");
}
function p(t, o, n) {
  i(o.isDragging(), "Cannot call hover while not dragging."), i(!o.didDrop(), "Cannot call hover after drop.");
  for (let e = 0; e < t.length; e++) {
    const r = t[e];
    i(t.lastIndexOf(r) === e, "Expected targetIds to be unique in the passed array.");
    const a = n.getTarget(r);
    i(a, "Expected targetIds to be registered.");
  }
}
function d(t, o, n) {
  for (let e = t.length - 1; e >= 0; e--) {
    const r = t[e], a = o.getTargetType(r);
    s(a, n) || t.splice(e, 1);
  }
}
function y(t, o, n) {
  t.forEach(function(e) {
    n.getTarget(e).hover(o, e);
  });
}
export {
  v as createHover
};
//# sourceMappingURL=hover.js.map
