import { appIsDev } from "@kksh/api/commands"
import { appDataDir, join } from "@tauri-apps/api/path"
import * as fs from "@tauri-apps/plugin-fs"
import { PUBLIC_SUPABASE_ANON_KEY, PUBLIC_SUPABASE_URL } from "$env/static/public"

export const SUPABASE_ANON_KEY = PUBLIC_SUPABASE_ANON_KEY
export const SUPABASE_URL = PUBLIC_SUPABASE_URL
export const SUPABASE_GRAPHQL_ENDPOINT = `${SUPABASE_URL}/graphql/v1`
export function getExtensionsFolder() {
	return appDataDir()
		.then((appDataDirPath) => join(appDataDirPath, "extensions"))
		.then(async (path) => {
			if (!(await fs.exists(path))) {
				await fs.mkdir(path)
			}
			return path
		})
}
export const IS_IN_TAURI =
	// eslint-disable-next-line @typescript-eslint/no-explicit-any
	typeof window !== "undefined" && (window as any).__TAURI_INTERNALS__ !== undefined

export const LanguageMap = {
	en: "English",
	zh: "中文",
	ru: "Русский"
}
