/*
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 */
import { dlv } from "./dlv.js";
import * as z from "zod";
export const envSchema = z.object({
    CLOUDINARY_API_KEY: z.string().optional(),
    CLOUDINARY_API_SECRET: z.string().optional(),
    CLOUDINARY_CLOUD_NAME: z.string().optional(),
    CLOUDINARY_DEBUG: z.coerce.boolean().optional(),
});
let envMemo = undefined;
/**
 * Reads and validates environment variables.
 */
export function env() {
    if (envMemo) {
        return envMemo;
    }
    envMemo = envSchema.parse(dlv(globalThis, "process.env") ?? dlv(globalThis, "Deno.env") ?? {});
    return envMemo;
}
/**
 * Clears the cached env object. Useful for testing with a fresh environment.
 */
export function resetEnv() {
    envMemo = undefined;
}
/**
 * Populates global parameters with environment variables.
 */
export function fillGlobals(options) {
    const clone = { ...options };
    const envVars = env();
    if (typeof envVars.CLOUDINARY_CLOUD_NAME !== "undefined") {
        clone.cloudName ?? (clone.cloudName = envVars.CLOUDINARY_CLOUD_NAME);
    }
    return clone;
}
//# sourceMappingURL=env.js.map