text: "use strict";exports.__esModule=true;exports.loadEnvConfig=loadEnvConfig;var _fs=_interopRequireDefault(require("fs"));var _path=_interopRequireDefault(require("path"));var log=_interopRequireWildcard(require("../build/output/log"));var _dotenvExpand=_interopRequireDefault(require("next/dist/compiled/dotenv-expand"));var _dotenv=_interopRequireDefault(require("next/dist/compiled/dotenv"));function _getRequireWildcardCache(){if(typeof WeakMap!=="function")return null;var cache=new WeakMap();_getRequireWildcardCache=function(){return cache;};return cache;}function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj;}if(obj===null||typeof obj!=="object"&&typeof obj!=="function"){return{default:obj};}var cache=_getRequireWildcardCache();if(cache&&cache.has(obj)){return cache.get(obj);}var newObj={};var hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;if(desc&&(desc.get||desc.set)){Object.defineProperty(newObj,key,desc);}else{newObj[key]=obj[key];}}}newObj.default=obj;if(cache){cache.set(obj,newObj);}return newObj;}function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}let combinedEnv=undefined;function loadEnvConfig(dir,dev){// don't reload env if we already have since this breaks escaped
  // environment values e.g. \$ENV_FILE_KEY
  if(combinedEnv)return combinedEnv;const isTest=process.env.NODE_ENV==='test';const mode=isTest?'test':dev?'development':'production';const dotenvFiles=[`.env.${mode}.local`,`.env.${mode}`,// Don't include `.env.local` for `test` environment
  // since normally you expect tests to produce the same
  // results for everyone
  mode!=='test'&&`.env.local`,'.env'].filter(Boolean);combinedEnv={...process.env};for(const envFile of dotenvFiles){// only load .env if the user provided has an env config file
  const dotEnvPath=_path.default.join(dir,envFile);try{const stats=_fs.default.statSync(dotEnvPath);// make sure to only attempt to read files
  if(!stats.isFile()){continue;}const contents=_fs.default.readFileSync(dotEnvPath,'utf8');let result={};result.parsed=_dotenv.default.parse(contents);result=(0,_dotenvExpand.default)(result);if(result.parsed){log.info(`Loaded env from ${envFile}`);}Object.assign(combinedEnv,result.parsed);}catch(err){if(err.code!=='ENOENT'){log.error(`Failed to load env from ${envFile}`,err);}}}// load global env values prefixed with `NEXT_PUBLIC_` to process.env
  for(const key of Object.keys(combinedEnv)){if(key.startsWith('NEXT_PUBLIC_')&&typeof process.env[key]==='undefined'){process.env[key]=combinedEnv[key];}}return combinedEnv;}
  //# sourceMappingURL=load-env-config.js.map