import{i as e,t}from"./chunk-Bdh3yLIe.js";var n=t(((e,t)=>{t.exports={name:`dotenv`,version:`16.6.1`,description:`Loads environment variables from .env file`,main:`lib/main.js`,types:`lib/main.d.ts`,exports:{".":{types:`./lib/main.d.ts`,require:`./lib/main.js`,default:`./lib/main.js`},"./config":`./config.js`,"./config.js":`./config.js`,"./lib/env-options":`./lib/env-options.js`,"./lib/env-options.js":`./lib/env-options.js`,"./lib/cli-options":`./lib/cli-options.js`,"./lib/cli-options.js":`./lib/cli-options.js`,"./package.json":`./package.json`},scripts:{"dts-check":`tsc --project tests/types/tsconfig.json`,lint:`standard`,pretest:`npm run lint && npm run dts-check`,test:`tap run --allow-empty-coverage --disable-coverage --timeout=60000`,"test:coverage":`tap run --show-full-coverage --timeout=60000 --coverage-report=text --coverage-report=lcov`,prerelease:`npm test`,release:`standard-version`},repository:{type:`git`,url:`git://github.com/motdotla/dotenv.git`},homepage:`https://github.com/motdotla/dotenv#readme`,funding:`https://dotenvx.com`,keywords:[`dotenv`,`env`,`.env`,`environment`,`variables`,`config`,`settings`],readmeFilename:`README.md`,license:`BSD-2-Clause`,devDependencies:{"@types/node":`^18.11.3`,decache:`^4.6.2`,sinon:`^14.0.1`,standard:`^17.0.0`,"standard-version":`^9.5.0`,tap:`^19.2.0`,typescript:`^4.8.4`},engines:{node:`>=12`},browser:{fs:!1}}})),r=t(((t,r)=>{let i=e(`fs`),a=e(`path`),o=e(`os`),s=e(`crypto`),c=n().version,l=/(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/gm;function u(e){let t={},n=e.toString();n=n.replace(/\r\n?/gm,`
`);let r;for(;(r=l.exec(n))!=null;){let e=r[1],n=r[2]||``;n=n.trim();let i=n[0];n=n.replace(/^(['"`])([\s\S]*)\1$/gm,`$2`),i===`"`&&(n=n.replace(/\\n/g,`
`),n=n.replace(/\\r/g,`\r`)),t[e]=n}return t}function d(e){e||={};let t=_(e);e.path=t;let n=w.configDotenv(e);if(!n.parsed){let e=Error(`MISSING_DATA: Cannot parse ${t} for an unknown reason`);throw e.code=`MISSING_DATA`,e}let r=h(e).split(`,`),i=r.length,a;for(let e=0;e<i;e++)try{let t=g(n,r[e].trim());a=w.decrypt(t.ciphertext,t.key);break}catch(t){if(e+1>=i)throw t}return w.parse(a)}function f(e){console.log(`[dotenv@${c}][WARN] ${e}`)}function p(e){console.log(`[dotenv@${c}][DEBUG] ${e}`)}function m(e){console.log(`[dotenv@${c}] ${e}`)}function h(e){return e&&e.DOTENV_KEY&&e.DOTENV_KEY.length>0?e.DOTENV_KEY:process.env.DOTENV_KEY&&process.env.DOTENV_KEY.length>0?process.env.DOTENV_KEY:``}function g(e,t){let n;try{n=new URL(t)}catch(e){if(e.code===`ERR_INVALID_URL`){let e=Error(`INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development`);throw e.code=`INVALID_DOTENV_KEY`,e}throw e}let r=n.password;if(!r){let e=Error(`INVALID_DOTENV_KEY: Missing key part`);throw e.code=`INVALID_DOTENV_KEY`,e}let i=n.searchParams.get(`environment`);if(!i){let e=Error(`INVALID_DOTENV_KEY: Missing environment part`);throw e.code=`INVALID_DOTENV_KEY`,e}let a=`DOTENV_VAULT_${i.toUpperCase()}`,o=e.parsed[a];if(!o){let e=Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${a} in your .env.vault file.`);throw e.code=`NOT_FOUND_DOTENV_ENVIRONMENT`,e}return{ciphertext:o,key:r}}function _(e){let t=null;if(e&&e.path&&e.path.length>0)if(Array.isArray(e.path))for(let n of e.path)i.existsSync(n)&&(t=n.endsWith(`.vault`)?n:`${n}.vault`);else t=e.path.endsWith(`.vault`)?e.path:`${e.path}.vault`;else t=a.resolve(process.cwd(),`.env.vault`);return i.existsSync(t)?t:null}function v(e){return e[0]===`~`?a.join(o.homedir(),e.slice(1)):e}function y(e){let t=!!(e&&e.debug),n=e&&`quiet`in e?e.quiet:!0;(t||!n)&&m(`Loading env from encrypted .env.vault`);let r=w._parseVault(e),i=process.env;return e&&e.processEnv!=null&&(i=e.processEnv),w.populate(i,r,e),{parsed:r}}function b(e){let t=a.resolve(process.cwd(),`.env`),n=`utf8`,r=!!(e&&e.debug),o=e&&`quiet`in e?e.quiet:!0;e&&e.encoding?n=e.encoding:r&&p(`No encoding is specified. UTF-8 is used by default`);let s=[t];if(e&&e.path)if(!Array.isArray(e.path))s=[v(e.path)];else{s=[];for(let t of e.path)s.push(v(t))}let c,l={};for(let t of s)try{let r=w.parse(i.readFileSync(t,{encoding:n}));w.populate(l,r,e)}catch(e){r&&p(`Failed to load ${t} ${e.message}`),c=e}let u=process.env;if(e&&e.processEnv!=null&&(u=e.processEnv),w.populate(u,l,e),r||!o){let e=Object.keys(l).length,t=[];for(let e of s)try{let n=a.relative(process.cwd(),e);t.push(n)}catch(t){r&&p(`Failed to load ${e} ${t.message}`),c=t}m(`injecting env (${e}) from ${t.join(`,`)}`)}return c?{parsed:l,error:c}:{parsed:l}}function x(e){if(h(e).length===0)return w.configDotenv(e);let t=_(e);return t?w._configVault(e):(f(`You set DOTENV_KEY but you are missing a .env.vault file at ${t}. Did you forget to build it?`),w.configDotenv(e))}function S(e,t){let n=Buffer.from(t.slice(-64),`hex`),r=Buffer.from(e,`base64`),i=r.subarray(0,12),a=r.subarray(-16);r=r.subarray(12,-16);try{let e=s.createDecipheriv(`aes-256-gcm`,n,i);return e.setAuthTag(a),`${e.update(r)}${e.final()}`}catch(e){let t=e instanceof RangeError,n=e.message===`Invalid key length`,r=e.message===`Unsupported state or unable to authenticate data`;if(t||n){let e=Error(`INVALID_DOTENV_KEY: It must be 64 characters long (or more)`);throw e.code=`INVALID_DOTENV_KEY`,e}else if(r){let e=Error(`DECRYPTION_FAILED: Please check your DOTENV_KEY`);throw e.code=`DECRYPTION_FAILED`,e}else throw e}}function C(e,t,n={}){let r=!!(n&&n.debug),i=!!(n&&n.override);if(typeof t!=`object`){let e=Error(`OBJECT_REQUIRED: Please check the processEnv argument being passed to populate`);throw e.code=`OBJECT_REQUIRED`,e}for(let n of Object.keys(t))Object.prototype.hasOwnProperty.call(e,n)?(i===!0&&(e[n]=t[n]),r&&p(i===!0?`"${n}" is already defined and WAS overwritten`:`"${n}" is already defined and was NOT overwritten`)):e[n]=t[n]}let w={configDotenv:b,_configVault:y,_parseVault:d,config:x,decrypt:S,parse:u,populate:C};r.exports.configDotenv=w.configDotenv,r.exports._configVault=w._configVault,r.exports._parseVault=w._parseVault,r.exports.config=w.config,r.exports.decrypt=w.decrypt,r.exports.parse=w.parse,r.exports.populate=w.populate,r.exports=w}));export{r as t};
//# sourceMappingURL=main-jD9cMbPj.js.map