import { createContext as e, useCallback as t, useContext as n, useMemo as r, useState as i } from "react";
import { jsx as a } from "react/jsx-runtime";
//#region src/features/workbench/providers/WorkbenchLayoutProvider.tsx
var o = e(null);
function s({ children: e, workflow: n, isDeveloperMode: s = !1, workspaceConfig: c, getPreviewUrl: l, getEnvironmentPreviewUrl: u, environments: d, previewPanelOpen: f, onPreviewPanelOpenChange: p }) {
	let [m, h] = i(null), [g, _] = i(null), [v, y] = i("preview"), [b, x] = i(null), [S, C] = i(""), w = f !== void 0, T = w ? f ? g ?? "preview" : null : g, E = c?.features?.previewPanel?.enabled ?? !1, D = d === void 0 || d.some((e) => !!e.connectionUrl && (!!e.workerId || e.local)), O = E && D, k = c?.features?.fileExplorer?.enabled && c?.features?.fileExplorer?.environments?.includes(d?.[0]?.slotId ?? ""), A = T !== null, j = t((e) => {
		w && p?.(e !== null), _(e);
	}, [w, p]), M = t((e) => {
		h((t) => t === e ? null : e), j(null);
	}, [j]), N = t(() => {
		h(null);
	}, []), P = t((e) => {
		let t = T === e ? null : e;
		j(t), t && h(null);
	}, [T, j]), F = t(() => {
		j(null);
	}, [j]), I = t((e) => {
		C(e), j("preview"), h(null);
	}, [j]), L = t(() => {
		P("preview");
	}, [P]), R = r(() => ({
		workflow: n,
		previewPanelEnabled: O,
		fileExplorerEnabled: k ?? !1,
		isDeveloperMode: s,
		workspaceConfig: c,
		getPreviewUrl: l,
		getEnvironmentPreviewUrl: u,
		environments: d,
		activeFloatingPanel: m,
		toggleFloatingPanel: M,
		closeFloatingPanel: N,
		activeSidePanel: T,
		toggleSidePanel: P,
		closeSidePanel: F,
		selectedSlotId: S,
		setSelectedSlotId: C,
		openPreviewWithEnvironment: I,
		previewPanelOpen: A,
		togglePreviewPanel: L,
		activePreviewTab: v,
		setActivePreviewTab: y,
		activeSectionId: b,
		setActiveSectionId: x
	}), [
		n,
		O,
		k,
		s,
		c,
		l,
		u,
		d,
		m,
		M,
		N,
		T,
		P,
		F,
		S,
		I,
		A,
		L,
		v,
		y,
		b,
		x
	]);
	return /* @__PURE__ */ a(o.Provider, {
		value: R,
		children: e
	});
}
function c() {
	let e = n(o);
	if (!e) throw Error("useWorkbenchLayout must be used within a WorkbenchLayoutProvider");
	return e;
}
//#endregion
export { s as WorkbenchLayoutProvider, c as useWorkbenchLayout };
