import { invariant as s } from "../../../@react-dnd/invariant/dist/index.es.js";
import { isValidElement as f, cloneElement as i } from "react";
function p(t) {
  if (typeof t.type == "string")
    return;
  const n = t.type.displayName || t.type.name || "the component";
  throw new Error(`Only native element nodes can now be passed to React DnD connectors.You can either wrap ${n} into a <div>, or turn it into a drag source or a drop target itself.`);
}
function l(t) {
  return (n = null, e = null) => {
    if (!f(n)) {
      const o = n;
      return t(o, e), o;
    }
    const r = n;
    return p(r), u(r, e ? (o) => t(o, e) : t);
  };
}
function w(t) {
  const n = {};
  return Object.keys(t).forEach((e) => {
    const r = t[e];
    if (e.endsWith("Ref"))
      n[e] = t[e];
    else {
      const a = l(r);
      n[e] = () => a;
    }
  }), n;
}
function c(t, n) {
  typeof t == "function" ? t(n) : t.current = n;
}
function u(t, n) {
  const e = t.ref;
  return s(typeof e != "string", "Cannot connect React DnD to an element with an existing string ref. Please convert it to use a callback ref instead, or wrap it into a <span> or <div>. Read more: https://reactjs.org/docs/refs-and-the-dom.html#callback-refs"), e ? i(t, {
    ref: (r) => {
      c(e, r), c(n, r);
    }
  }) : i(t, {
    ref: n
  });
}
export {
  w as wrapConnectorHooks
};
//# sourceMappingURL=wrapConnectorHooks.es.js.map
