/** @license MIT | @cube-dev/ui-kit v0.147.0 | Cube Dev Team */
import { BoardDragActiveContext, BoardRegistryContext } from "./board-context.js";
import { useBoardRegistry } from "./use-board-registry.js";
import { tasty } from "@tenphi/tasty";
import { jsx, jsxs } from "react/jsx-runtime";

//#region src/components/layout/Board/BoardProvider.tsx
const OverlayElement = tasty({
	qa: "BoardDragOverlay",
	styles: {
		position: "fixed",
		top: 0,
		left: 0,
		right: 0,
		bottom: 0,
		zIndex: 999999,
		pointerEvents: "none",
		overflow: "visible"
	}
});
/**
* Shares a single drag context across multiple `Board`s so widgets can be
* dragged from one board to another (including out of a nested board into its
* parent). Also hosts the fixed drag overlay used to render the dragged widget
* above everything, so ancestor `overflow: hidden` never clips it.
*
* A standalone `Board` provides its own registry automatically; wrap several
* boards in a `BoardProvider` only when you need cross-board dragging.
*/
function BoardProvider(props) {
	const { children, onWidgetTransfer } = props;
	const registry = useBoardRegistry({ onWidgetTransfer });
	return /* @__PURE__ */ jsx(BoardRegistryContext.Provider, {
		value: registry,
		children: /* @__PURE__ */ jsxs(BoardDragActiveContext.Provider, {
			value: registry.dragState != null,
			children: [children, /* @__PURE__ */ jsx(OverlayElement, {
				ref: registry.overlayRef,
				"aria-hidden": "true"
			})]
		})
	});
}

//#endregion
export { BoardProvider };
//# sourceMappingURL=BoardProvider.js.map