require("./chunk-9hOWP6kD.cjs");
let react = require("react");
let react_jsx_runtime = require("react/jsx-runtime");
let react_dom = require("react-dom");
//#region ../react/src/shell/ScreenHeaderContext.tsx
const SlotContext = (0, react.createContext)(null);
function ScreenHeaderProvider({ children }) {
	const [breadcrumbsEl, setBreadcrumbsEl] = (0, react.useState)(null);
	const [actionsEl, setActionsEl] = (0, react.useState)(null);
	const [breadcrumbCount, setBreadcrumbCount] = (0, react.useState)(0);
	const incrementBreadcrumbs = (0, react.useCallback)(() => setBreadcrumbCount((c) => c + 1), []);
	const decrementBreadcrumbs = (0, react.useCallback)(() => setBreadcrumbCount((c) => c - 1), []);
	const value = (0, react.useMemo)(() => ({
		breadcrumbsEl,
		actionsEl,
		breadcrumbCount,
		incrementBreadcrumbs,
		decrementBreadcrumbs,
		setBreadcrumbsEl,
		setActionsEl
	}), [
		breadcrumbsEl,
		actionsEl,
		breadcrumbCount,
		incrementBreadcrumbs,
		decrementBreadcrumbs,
		setBreadcrumbsEl,
		setActionsEl
	]);
	return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SlotContext.Provider, {
		value,
		children
	});
}
function ScreenHeaderBreadcrumbs({ children }) {
	const ctx = (0, react.useContext)(SlotContext);
	const increment = ctx?.incrementBreadcrumbs;
	const decrement = ctx?.decrementBreadcrumbs;
	(0, react.useLayoutEffect)(() => {
		increment?.();
		return () => decrement?.();
	}, [increment, decrement]);
	if (!ctx?.breadcrumbsEl) return null;
	return (0, react_dom.createPortal)(children, ctx.breadcrumbsEl);
}
function ScreenHeaderActions({ children }) {
	const ctx = (0, react.useContext)(SlotContext);
	if (!ctx?.actionsEl) return null;
	return (0, react_dom.createPortal)(children, ctx.actionsEl);
}
function useScreenHeaderSlotRefs() {
	const ctx = (0, react.useContext)(SlotContext);
	if (!ctx) throw new Error("useScreenHeaderSlotRefs must be used within a ScreenHeaderProvider");
	return {
		breadcrumbsRef: ctx.setBreadcrumbsEl,
		actionsRef: ctx.setActionsEl,
		hasBreadcrumbs: ctx.breadcrumbCount > 0
	};
}
//#endregion
Object.defineProperty(exports, "ScreenHeaderActions", {
	enumerable: true,
	get: function() {
		return ScreenHeaderActions;
	}
});
Object.defineProperty(exports, "ScreenHeaderBreadcrumbs", {
	enumerable: true,
	get: function() {
		return ScreenHeaderBreadcrumbs;
	}
});
Object.defineProperty(exports, "ScreenHeaderProvider", {
	enumerable: true,
	get: function() {
		return ScreenHeaderProvider;
	}
});
Object.defineProperty(exports, "useScreenHeaderSlotRefs", {
	enumerable: true,
	get: function() {
		return useScreenHeaderSlotRefs;
	}
});

//# sourceMappingURL=ScreenHeaderContext-CsfhnuJk.cjs.map