import { jsx as u } from "react/jsx-runtime";
import { memo as g, useEffect as d } from "react";
import { DndContext as m } from "./DndContext.js";
import { createDragDropManager as b } from "../../../../../dnd-core@16.0.1/node_modules/dnd-core/dist/createDragDropManager.js";
function v(n, r) {
  if (n == null) return {};
  var o = s(n, r), e, t;
  if (Object.getOwnPropertySymbols) {
    var a = Object.getOwnPropertySymbols(n);
    for (t = 0; t < a.length; t++)
      e = a[t], !(r.indexOf(e) >= 0) && Object.prototype.propertyIsEnumerable.call(n, e) && (o[e] = n[e]);
  }
  return o;
}
function s(n, r) {
  if (n == null) return {};
  var o = {}, e = Object.keys(n), t, a;
  for (a = 0; a < e.length; a++)
    t = e[a], !(r.indexOf(t) >= 0) && (o[t] = n[t]);
  return o;
}
let f = 0;
const i = Symbol.for("__REACT_DND_CONTEXT_INSTANCE__");
var h = /* @__PURE__ */ g(function(r) {
  var { children: o } = r, e = v(r, [
    "children"
  ]);
  const [t, a] = D(e);
  return d(() => {
    if (a) {
      const c = l();
      return ++f, () => {
        --f === 0 && (c[i] = null);
      };
    }
  }, []), /* @__PURE__ */ u(m.Provider, {
    value: t,
    children: o
  });
});
function D(n) {
  if ("manager" in n)
    return [
      {
        dragDropManager: n.manager
      },
      !1
    ];
  const r = x(n.backend, n.context, n.options, n.debugMode), o = !n.context;
  return [
    r,
    o
  ];
}
function x(n, r = l(), o, e) {
  const t = r;
  return t[i] || (t[i] = {
    dragDropManager: b(n, r, o, e)
  }), t[i];
}
function l() {
  return typeof global < "u" ? global : window;
}
export {
  h as DndProvider
};
//# sourceMappingURL=DndProvider.js.map
