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