// DO NOT EXPOSE THIS VARIABLE TO PUBLIC, IT IS USED INTERNALLY FOR CLOUDFLARE WORKER
"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
function _export(target, all) {
    for(var name in all)Object.defineProperty(target, name, {
        enumerable: true,
        get: all[name]
    });
}
_export(exports, {
    AsyncLocalStorage: function() {
        return _nodeasync_hooks.AsyncLocalStorage;
    },
    CustomEvent: function() {
        return defaultCustomEvent;
    },
    INTERNAL_ENV: function() {
        return INTERNAL_ENV;
    },
    getEnv: function() {
        return getEnv;
    },
    setEnvs: function() {
        return setEnvs;
    }
});
const _nodeasync_hooks = require("node:async_hooks");
const INTERNAL_ENV = {};
function setEnvs(envs) {
    Object.assign(INTERNAL_ENV, envs);
}
function getEnv(name) {
    if (INTERNAL_ENV[name]) {
        return INTERNAL_ENV[name];
    }
    if (typeof process === "undefined" || typeof process.env === "undefined") {
        // @ts-expect-error
        if (typeof Deno === "undefined") {
            throw new Error("Current environment is not supported");
        } else {
            // @ts-expect-error
            return Deno.env.get(name);
        }
    }
    return process.env[name];
}
// Node.js 18 doesn't have CustomEvent by default
// Refs: https://github.com/nodejs/node/issues/40678
class CustomEvent extends Event {
    #detail;
    get detail() {
        return this.#detail;
    }
    constructor(event, options){
        super(event, options);
        this.#detail = options?.detail;
    }
    /**
   * @deprecated This method is not supported
   */ initCustomEvent() {
        throw new Error("initCustomEvent is not supported");
    }
}
const defaultCustomEvent = globalThis.CustomEvent || CustomEvent;
