"use client"
const require_state = require('./state-lPCQsWy5.js');
let react = require("react");
react = require_state.__toESM(react);
let react_jsx_runtime = require("react/jsx-runtime");
let _mui_material_Stack = require("@mui/material/Stack");
_mui_material_Stack = require_state.__toESM(_mui_material_Stack);
let _mui_material_Box = require("@mui/material/Box");
_mui_material_Box = require_state.__toESM(_mui_material_Box);
let _mui_material_Button = require("@mui/material/Button");
_mui_material_Button = require_state.__toESM(_mui_material_Button);
let _mui_material_Dialog = require("@mui/material/Dialog");
_mui_material_Dialog = require_state.__toESM(_mui_material_Dialog);
let _mui_material_DialogActions = require("@mui/material/DialogActions");
_mui_material_DialogActions = require_state.__toESM(_mui_material_DialogActions);
let _mui_material_DialogContent = require("@mui/material/DialogContent");
_mui_material_DialogContent = require_state.__toESM(_mui_material_DialogContent);
let _mui_material_DialogTitle = require("@mui/material/DialogTitle");
_mui_material_DialogTitle = require_state.__toESM(_mui_material_DialogTitle);
let _mui_material_IconButton = require("@mui/material/IconButton");
_mui_material_IconButton = require_state.__toESM(_mui_material_IconButton);
let react_icons_io5 = require("react-icons/io5");

//#region recce-source/js/src/lib/hooks/RecceQueryContext.tsx
const defaultSqlQuery = "select * from {{ ref(\"mymodel\") }}";
const RecceQueryContext = (0, react.createContext)({
	sqlQuery: defaultSqlQuery,
	setSqlQuery: () => {},
	primaryKeys: void 0,
	setPrimaryKeys: () => {},
	isCustomQueries: false,
	setCustomQueries: () => {},
	baseSqlQuery: defaultSqlQuery,
	setBaseSqlQuery: () => {}
});
function RecceQueryContextProvider({ children }) {
	const [sqlQuery, setSqlQuery] = react.default.useState(defaultSqlQuery);
	const [baseSqlQuery, setBaseSqlQuery] = react.default.useState(defaultSqlQuery);
	const [isCustomQueries, setCustomQueries] = react.default.useState(false);
	const [primaryKeys, setPrimaryKeys] = react.default.useState();
	return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RecceQueryContext.Provider, {
		value: {
			setSqlQuery,
			sqlQuery,
			setPrimaryKeys,
			primaryKeys,
			isCustomQueries,
			setCustomQueries,
			baseSqlQuery,
			setBaseSqlQuery
		},
		children
	});
}
const useRecceQueryContext = () => (0, react.useContext)(RecceQueryContext);
const RowCountStateContext = (0, react.createContext)({
	isNodesFetching: [],
	setIsNodesFetching: () => {}
});
function RowCountStateContextProvider({ children }) {
	const [isNodesFetching, setIsNodesFetching] = react.default.useState([]);
	return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RowCountStateContext.Provider, {
		value: {
			isNodesFetching,
			setIsNodesFetching
		},
		children
	});
}
const useRowCountStateContext = () => (0, react.useContext)(RowCountStateContext);

//#endregion
//#region recce-source/js/src/lib/hooks/RecceShareStateContext.tsx
const ShareState = (0, react.createContext)(void 0);
function RecceShareStateContextProvider({ children }) {
	const [shareUrl, setShareUrl] = (0, react.useState)();
	const [isLoading, setIsLoading] = (0, react.useState)(false);
	const [error, setError] = (0, react.useState)();
	const { apiClient } = require_state.useApiConfig();
	const handleShareClick = async () => {
		setIsLoading(true);
		setError(void 0);
		setShareUrl(void 0);
		try {
			const response = await require_state.shareState(apiClient);
			if (response.status !== "success") {
				setError(response.message);
				return;
			}
			setShareUrl(response.share_url);
		} catch (err) {
			setError(err.message);
		} finally {
			setIsLoading(false);
		}
	};
	return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ShareState.Provider, {
		value: {
			shareUrl,
			isLoading,
			error,
			handleShareClick
		},
		children
	});
}
const useRecceShareStateContext = () => {
	const context = (0, react.useContext)(ShareState);
	if (!context) throw new Error("useRecceShareStateContext must be used within a RecceShareStateContextProvider");
	return context;
};

//#endregion
//#region recce-source/js/src/components/lineage/useValueDiffAlertDialog.tsx
function useValueDiffAlertDialog() {
	const [open, setOpen] = (0, react.useState)(false);
	const [nodeCount, setNodeCount] = (0, react.useState)(0);
	const [resolvePromise, setResolvePromise] = (0, react.useState)();
	const cancelRef = (0, react.useRef)(null);
	const confirm = (0, react.useCallback)((nodeCount$1) => {
		setNodeCount(nodeCount$1);
		return new Promise((resolve) => {
			setResolvePromise(() => resolve);
			setOpen(true);
		});
	}, []);
	const handleConfirm = () => {
		require_state.trackExploreActionForm({
			action: require_state.EXPLORE_ACTION.VALUE_DIFF,
			event: require_state.EXPLORE_FORM_EVENT.EXECUTE
		});
		resolvePromise?.(true);
		setOpen(false);
	};
	const handleCancel = () => {
		require_state.trackExploreActionForm({
			action: require_state.EXPLORE_ACTION.VALUE_DIFF,
			event: require_state.EXPLORE_FORM_EVENT.CANCEL
		});
		resolvePromise?.(false);
		setOpen(false);
	};
	return {
		confirm,
		AlertDialog: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_mui_material_Dialog.default, {
			open,
			onClose: handleCancel,
			maxWidth: "md",
			fullWidth: true,
			"aria-labelledby": "value-diff-alert-dialog-title",
			children: [
				/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_mui_material_DialogTitle.default, {
					id: "value-diff-alert-dialog-title",
					sx: {
						fontSize: "1.125rem",
						fontWeight: "bold"
					},
					children: [
						"Value Diff on ",
						nodeCount,
						" nodes"
					]
				}),
				/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_mui_material_IconButton.default, {
					"aria-label": "close",
					onClick: handleCancel,
					sx: {
						position: "absolute",
						right: 8,
						top: 8,
						color: "grey.500"
					},
					children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_icons_io5.IoClose, {})
				}),
				/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_mui_material_DialogContent.default, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_mui_material_Stack.default, {
					spacing: "20px",
					children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_mui_material_Box.default, { children: [
						"Value diff will be executed on ",
						nodeCount,
						" nodes in the Lineage, which can add extra costs to your bill."
					] })
				}) }),
				/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_mui_material_DialogActions.default, {
					sx: { gap: .5 },
					children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_mui_material_Button.default, {
						ref: cancelRef,
						onClick: handleCancel,
						variant: "outlined",
						color: "neutral",
						children: "Cancel"
					}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_mui_material_Button.default, {
						color: "iochmara",
						variant: "contained",
						onClick: handleConfirm,
						sx: { ml: 1.5 },
						children: "Execute"
					})]
				})
			]
		})
	};
}
var useValueDiffAlertDialog_default = useValueDiffAlertDialog;

//#endregion
//#region recce-source/js/src/lib/hooks/useCheckToast.tsx
function useCheckToast() {
	function markedAsApprovedToast() {
		require_state.toaster.create({
			title: "Marked as approved",
			type: "success",
			duration: 2e3
		});
	}
	return { markedAsApprovedToast };
}

//#endregion
//#region recce-source/js/src/lib/hooks/RecceCheckContext.tsx
const RecceCheckContext = (0, react.createContext)({
	latestSelectedCheckId: "",
	setLatestSelectedCheckId: () => {}
});
function RecceCheckContextProvider({ children }) {
	const [selectCheckId, setSelectCheckId] = react.default.useState("");
	return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RecceCheckContext.Provider, {
		value: {
			setLatestSelectedCheckId: setSelectCheckId,
			latestSelectedCheckId: selectCheckId
		},
		children
	});
}
const useRecceCheckContext = () => (0, react.useContext)(RecceCheckContext);

//#endregion
Object.defineProperty(exports, 'RecceCheckContextProvider', {
  enumerable: true,
  get: function () {
    return RecceCheckContextProvider;
  }
});
Object.defineProperty(exports, 'RecceQueryContextProvider', {
  enumerable: true,
  get: function () {
    return RecceQueryContextProvider;
  }
});
Object.defineProperty(exports, 'RecceShareStateContextProvider', {
  enumerable: true,
  get: function () {
    return RecceShareStateContextProvider;
  }
});
Object.defineProperty(exports, 'RowCountStateContextProvider', {
  enumerable: true,
  get: function () {
    return RowCountStateContextProvider;
  }
});
Object.defineProperty(exports, 'defaultSqlQuery', {
  enumerable: true,
  get: function () {
    return defaultSqlQuery;
  }
});
Object.defineProperty(exports, 'useCheckToast', {
  enumerable: true,
  get: function () {
    return useCheckToast;
  }
});
Object.defineProperty(exports, 'useRecceCheckContext', {
  enumerable: true,
  get: function () {
    return useRecceCheckContext;
  }
});
Object.defineProperty(exports, 'useRecceQueryContext', {
  enumerable: true,
  get: function () {
    return useRecceQueryContext;
  }
});
Object.defineProperty(exports, 'useRecceShareStateContext', {
  enumerable: true,
  get: function () {
    return useRecceShareStateContext;
  }
});
Object.defineProperty(exports, 'useRowCountStateContext', {
  enumerable: true,
  get: function () {
    return useRowCountStateContext;
  }
});
Object.defineProperty(exports, 'useValueDiffAlertDialog_default', {
  enumerable: true,
  get: function () {
    return useValueDiffAlertDialog_default;
  }
});
//# sourceMappingURL=RecceCheckContext-DPpu9nG5.js.map