"use client"
import { D as useApiConfig, W as getExperimentTrackingBreakingChangeEnabled, p as submitRun, st as axiosClient, w as cacheKeys } from "./state-Sc2b4jri.mjs";
import { useEffect, useState } from "react";
import { useQuery } from "@tanstack/react-query";
import axios from "axios";

//#region recce-source/js/src/lib/api/cll.ts
async function getCll(input, client = axiosClient) {
	return (await client.post("/api/cll", input)).data;
}

//#endregion
//#region recce-source/js/src/lib/api/lineagecheck.ts
async function createLineageDiffCheck(viewOptions, client = axiosClient) {
	return (await client.post("/api/checks", {
		type: "lineage_diff",
		params: {},
		view_options: viewOptions
	})).data;
}

//#endregion
//#region recce-source/js/src/lib/api/schemacheck.ts
async function createSchemaDiffCheck(params, client = axiosClient) {
	return (await client.post("/api/checks", {
		type: "schema_diff",
		params
	})).data;
}

//#endregion
//#region recce-source/js/src/lib/api/select.ts
async function select(input, client = axiosClient) {
	return (await client.post(`/api/select`, input)).data;
}

//#endregion
//#region recce-source/js/src/lib/api/sessionStorageKeys.ts
const prefix$1 = "recce";
const sessionStorageKeys = {
	recommendationIgnored: `${prefix$1}-recommendation-ignored`,
	recommendationShowed: `${prefix$1}-recommendation-showed`,
	prevRefreshTimeStamp: `${prefix$1}-prev-refresh-timestamp`,
	lineageNotificationDismissed: `${prefix$1}-lineage-notification-dismissed`
};

//#endregion
//#region recce-source/js/src/lib/api/adhocQuery.ts
async function submitQuery(params, options, client = axiosClient) {
	return await submitRun("query", params, options, client);
}
async function submitQueryBase(params, options, client = axiosClient) {
	return await submitRun("query_base", params, options, client);
}
async function submitQueryDiff(params, options, client = axiosClient) {
	return await submitRun("query_diff", params, options, client);
}

//#endregion
//#region recce-source/js/src/lib/api/localStorageKeys.ts
const prefix = "recce-";
const localStorageKeys = {
	bypassSaveOverwrite: `${prefix}-bypass-save-overwrite`,
	previewChangeFeedbackID: `${prefix}-preview-change-feedback`,
	prepareEnvGuideID: `${prefix}-prepare-env`
};

//#endregion
//#region recce-source/js/src/lib/api/connectToCloud.ts
async function connectToCloud(client = axiosClient) {
	return (await client.post("/api/connect")).data;
}

//#endregion
//#region recce-source/js/src/lib/api/checks.ts
async function createSimpleCheck(client = axiosClient) {
	return (await client.post("/api/checks", { type: "simple" })).data;
}
async function createCheckByRun(runId, viewOptions, client = axiosClient) {
	const track_props = getExperimentTrackingBreakingChangeEnabled() ? { breaking_change_analysis: true } : {};
	return (await client.post("/api/checks", {
		run_id: runId,
		view_options: viewOptions,
		track_props
	})).data;
}
async function listChecks(client = axiosClient) {
	return (await client.get("/api/checks")).data;
}
function useChecks(enabled) {
	const { apiClient } = useApiConfig();
	return useQuery({
		queryKey: cacheKeys.checks(),
		queryFn: () => listChecks(apiClient),
		enabled
	});
}
async function getCheck(checkId, client = axiosClient) {
	return (await client.get(`/api/checks/${checkId}`)).data;
}
async function updateCheck(checkId, payload, client = axiosClient) {
	return (await client.patch(`/api/checks/${checkId}`, payload)).data;
}
async function deleteCheck(checkId, client = axiosClient) {
	return (await client.delete(`/api/checks/${checkId}`)).data;
}
async function reorderChecks(order, client = axiosClient) {
	return await client.post("/api/checks/reorder", order);
}
async function markAsPresetCheck(checkId, client = axiosClient) {
	await client.post(`/api/checks/${checkId}/mark-as-preset`);
}

//#endregion
//#region recce-source/js/src/lib/api/user.ts
async function fetchUser(client = axiosClient) {
	try {
		return (await client.get("/api/users")).data;
	} catch (error) {
		console.error("Error fetching user data:", error);
		throw error;
	}
}
async function fetchGitHubAvatar(userId) {
	try {
		return (await axios.get(`https://api.github.com/user/${userId}`)).data.avatar_url;
	} catch (error) {
		console.warn("Failed to fetch GitHub avatar:", error);
		return null;
	}
}

//#endregion
//#region recce-source/js/src/lib/api/version.ts
async function getVersion(client = axiosClient) {
	return (await client.get("/api/version")).data;
}
function useVersionNumber() {
	const [version, setVersion] = useState("");
	const [latestVersion, setLatestVersion] = useState("");
	const { apiClient } = useApiConfig();
	useEffect(() => {
		async function fetchVersion() {
			try {
				const { version: version$1, latestVersion: latestVersion$1 } = await getVersion(apiClient);
				setVersion(version$1);
				setLatestVersion(latestVersion$1);
			} catch (error) {
				console.error("Error fetching version number:", error);
			}
		}
		fetchVersion();
	}, [apiClient]);
	return {
		version,
		latestVersion
	};
}

//#endregion
export { getCll as C, createLineageDiffCheck as S, submitQueryBase as _, createCheckByRun as a, select as b, getCheck as c, reorderChecks as d, updateCheck as f, submitQuery as g, localStorageKeys as h, fetchUser as i, listChecks as l, connectToCloud as m, useVersionNumber as n, createSimpleCheck as o, useChecks as p, fetchGitHubAvatar as r, deleteCheck as s, getVersion as t, markAsPresetCheck as u, submitQueryDiff as v, createSchemaDiffCheck as x, sessionStorageKeys as y };
//# sourceMappingURL=version-DP1kU_7v.mjs.map