import { reactive } from "vue";
import { environmentSchema } from "@scalar/oas-utils/entities/environment";
import { LS_KEYS } from "@scalar/helpers/object/local-storage";
import { mutationFactory } from "@scalar/object-utils/mutator-record";
//#region src/store/environment.ts
/** Generate reactive environments for the workspace */
function createStoreEnvironments(useLocalStorage) {
	/** Initialize default environment */
	const environments = reactive({});
	const environmentMutators = mutationFactory(environments, reactive({}), useLocalStorage && LS_KEYS.ENVIRONMENT);
	environmentMutators.add(environmentSchema.parse({
		uid: "default",
		name: "Default Environment",
		color: "#FFFFFF",
		value: JSON.stringify({ exampleKey: "exampleValue" }, null, 2),
		isDefault: true
	}));
	return {
		environments,
		environmentMutators
	};
}
/** Extended environment data factory where workspace access is needed */
function extendedEnvironmentDataFactory({ environmentMutators }) {
	/** prevent deletion of the default environment */
	const deleteEnvironment = (uid) => {
		if (uid === "default") {
			console.warn("Default environment cannot be deleted.");
			return;
		}
		environmentMutators.delete(uid);
	};
	return { deleteEnvironment };
}
//#endregion
export { createStoreEnvironments, extendedEnvironmentDataFactory };

//# sourceMappingURL=environment.js.map