import { invariant as a } from "../../../../../../@react-dnd_invariant@4.0.2/node_modules/@react-dnd/invariant/dist/index.js";
import { isObject as s } from "../../utils/js_utils.js";
import { DROP as d } from "./types.js";
function g(t, e, r) {
  return e in t ? Object.defineProperty(t, e, {
    value: r,
    enumerable: !0,
    configurable: !0,
    writable: !0
  }) : t[e] = r, t;
}
function l(t) {
  for (var e = 1; e < arguments.length; e++) {
    var r = arguments[e] != null ? arguments[e] : {}, n = Object.keys(r);
    typeof Object.getOwnPropertySymbols == "function" && (n = n.concat(Object.getOwnPropertySymbols(r).filter(function(o) {
      return Object.getOwnPropertyDescriptor(r, o).enumerable;
    }))), n.forEach(function(o) {
      g(t, o, r[o]);
    });
  }
  return t;
}
function h(t) {
  return function(r = {}) {
    const n = t.getMonitor(), o = t.getRegistry();
    b(n), O(n).forEach((c, u) => {
      const f = y(c, u, o, n), p = {
        type: d,
        payload: {
          dropResult: l({}, r, f)
        }
      };
      t.dispatch(p);
    });
  };
}
function b(t) {
  a(t.isDragging(), "Cannot call drop while not dragging."), a(!t.didDrop(), "Cannot call drop twice during one drag operation.");
}
function y(t, e, r, n) {
  const o = r.getTarget(t);
  let i = o ? o.drop(n, t) : void 0;
  return D(i), typeof i > "u" && (i = e === 0 ? {} : n.getDropResult()), i;
}
function D(t) {
  a(typeof t > "u" || s(t), "Drop result must either be an object or undefined.");
}
function O(t) {
  const e = t.getTargetIds().filter(t.canDropOnTarget, t);
  return e.reverse(), e;
}
export {
  h as createDrop
};
//# sourceMappingURL=drop.js.map
