UNPKG

@dbs-portal/core-config

Version:

Advanced configuration management for DBS Portal with convict schema validation and deepmerge support

3 lines 82.9 kB
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Ve=require("fs"),tt=require("path");var Fe=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Kt(f){return f&&f.__esModule&&Object.prototype.hasOwnProperty.call(f,"default")?f.default:f}function on(f){if(Object.prototype.hasOwnProperty.call(f,"__esModule"))return f;var e=f.default;if(typeof e=="function"){var t=function n(){return this instanceof n?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(f).forEach(function(n){var l=Object.getOwnPropertyDescriptor(f,n);Object.defineProperty(t,n,l.get?l:{enumerable:!0,get:function(){return f[n]}})}),t}function Vt(f){throw new Error('Could not dynamically require "'+f+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}const sn={},an=Object.freeze(Object.defineProperty({__proto__:null,default:sn},Symbol.toStringTag,{value:"Module"})),cn=on(an);var mt,Ut;function ln(){if(Ut)return mt;Ut=1;var f=cn,e=Ve,t=tt;function n(h){if(h!==h.toLowerCase()&&h!==h.toUpperCase()||(h=h.toLowerCase()),h.indexOf("-")===-1&&h.indexOf("_")===-1)return h;{let M="",T=!1;const v=h.match(/^-+/);for(let U=v?v[0].length:0;U<h.length;U++){let P=h.charAt(U);T&&(T=!1,P=P.toUpperCase()),U!==0&&(P==="-"||P==="_")?T=!0:P!=="-"&&P!=="_"&&(M+=P)}return M}}function l(h,S){const M=h.toLowerCase();S=S||"-";let T="";for(let v=0;v<h.length;v++){const U=M.charAt(v),P=h.charAt(v);U!==P&&v>0?T+=`${S}${M.charAt(v)}`:T+=P}return T}function _(h){return h==null?!1:typeof h=="number"||/^0x[0-9a-f]+$/i.test(h)?!0:/^0[^.]/.test(h)?!1:/^[-]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(h)}function N(h){if(Array.isArray(h))return h.map(P=>typeof P!="string"?P+"":P);h=h.trim();let S=0,M=null,T=null,v=null;const U=[];for(let P=0;P<h.length;P++){if(M=T,T=h.charAt(P),T===" "&&!v){M!==" "&&S++;continue}T===v?v=null:(T==="'"||T==='"')&&!v&&(v=T),U[S]||(U[S]=""),U[S]+=T}return U}var I;(function(h){h.BOOLEAN="boolean",h.STRING="string",h.NUMBER="number",h.ARRAY="array"})(I||(I={}));let j;class H{constructor(S){j=S}parse(S,M){const T=Object.assign({alias:void 0,array:void 0,boolean:void 0,config:void 0,configObjects:void 0,configuration:void 0,coerce:void 0,count:void 0,default:void 0,envPrefix:void 0,narg:void 0,normalize:void 0,string:void 0,number:void 0,__:void 0,key:void 0},M),v=N(S),U=z(Object.assign(Object.create(null),T.alias)),P=Object.assign({"boolean-negation":!0,"camel-case-expansion":!0,"combine-arrays":!1,"dot-notation":!0,"duplicate-arguments-array":!0,"flatten-duplicate-arrays":!0,"greedy-arrays":!0,"halt-at-non-option":!1,"nargs-eats-options":!1,"negation-prefix":"no-","parse-numbers":!0,"parse-positional-numbers":!0,"populate--":!1,"set-placeholder-key":!1,"short-option-groups":!0,"strip-aliased":!1,"strip-dashed":!1,"unknown-options-as-args":!1},T.configuration),k=Object.assign(Object.create(null),T.default),pe=T.configObjects||[],ue=T.envPrefix,_e=P["populate--"],ae=_e?"--":"_",se=Object.create(null),p=Object.create(null),g=T.__||j.format,a={aliases:Object.create(null),arrays:Object.create(null),bools:Object.create(null),strings:Object.create(null),numbers:Object.create(null),counts:Object.create(null),normalize:Object.create(null),configs:Object.create(null),nargs:Object.create(null),coercions:Object.create(null),keys:[]},m=/^-([0-9]+(\.[0-9]+)?|\.[0-9]+)$/,b=new RegExp("^--"+P["negation-prefix"]+"(.+)");[].concat(T.array||[]).filter(Boolean).forEach(function(o){const s=typeof o=="object"?o.key:o,E=Object.keys(o).map(function(u){return{boolean:"bools",string:"strings",number:"numbers"}[u]}).filter(Boolean).pop();E&&(a[E][s]=!0),a.arrays[s]=!0,a.keys.push(s)}),[].concat(T.boolean||[]).filter(Boolean).forEach(function(o){a.bools[o]=!0,a.keys.push(o)}),[].concat(T.string||[]).filter(Boolean).forEach(function(o){a.strings[o]=!0,a.keys.push(o)}),[].concat(T.number||[]).filter(Boolean).forEach(function(o){a.numbers[o]=!0,a.keys.push(o)}),[].concat(T.count||[]).filter(Boolean).forEach(function(o){a.counts[o]=!0,a.keys.push(o)}),[].concat(T.normalize||[]).filter(Boolean).forEach(function(o){a.normalize[o]=!0,a.keys.push(o)}),typeof T.narg=="object"&&Object.entries(T.narg).forEach(([o,s])=>{typeof s=="number"&&(a.nargs[o]=s,a.keys.push(o))}),typeof T.coerce=="object"&&Object.entries(T.coerce).forEach(([o,s])=>{typeof s=="function"&&(a.coercions[o]=s,a.keys.push(o))}),typeof T.config<"u"&&(Array.isArray(T.config)||typeof T.config=="string"?[].concat(T.config).filter(Boolean).forEach(function(o){a.configs[o]=!0}):typeof T.config=="object"&&Object.entries(T.config).forEach(([o,s])=>{(typeof s=="boolean"||typeof s=="function")&&(a.configs[o]=s)})),ct(T.key,U,T.default,a.arrays),Object.keys(k).forEach(function(o){(a.aliases[o]||[]).forEach(function(s){k[s]=k[o]})});let x=null;lt();let y=[];const O=Object.assign(Object.create(null),{_:[]}),V={};for(let o=0;o<v.length;o++){const s=v[o],E=s.replace(/^-{3,}/,"---");let u,i,A,w,D,W;if(s!=="--"&&ie(s))$(s);else if(E.match(/---+(=|$)/)){$(s);continue}else if(s.match(/^--.+=/)||!P["short-option-groups"]&&s.match(/^-.+=/))w=s.match(/^--?([^=]+)=([\s\S]*)$/),w!==null&&Array.isArray(w)&&w.length>=3&&(L(w[1],a.arrays)?o=G(o,w[1],v,w[2]):L(w[1],a.nargs)!==!1?o=B(o,w[1],v,w[2]):F(w[1],w[2]));else if(s.match(b)&&P["boolean-negation"])w=s.match(b),w!==null&&Array.isArray(w)&&w.length>=2&&(i=w[1],F(i,L(i,a.arrays)?[!1]:!1));else if(s.match(/^--.+/)||!P["short-option-groups"]&&s.match(/^-[^-]+/))w=s.match(/^--?(.+)/),w!==null&&Array.isArray(w)&&w.length>=2&&(i=w[1],L(i,a.arrays)?o=G(o,i,v):L(i,a.nargs)!==!1?o=B(o,i,v):(D=v[o+1],D!==void 0&&(!D.match(/^-/)||D.match(m))&&!L(i,a.bools)&&!L(i,a.counts)||/^(true|false)$/.test(D)?(F(i,D),o++):F(i,ye(i))));else if(s.match(/^-.\..+=/))w=s.match(/^-([^=]+)=([\s\S]*)$/),w!==null&&Array.isArray(w)&&w.length>=3&&F(w[1],w[2]);else if(s.match(/^-.\..+/)&&!s.match(m))D=v[o+1],w=s.match(/^-(.\..+)/),w!==null&&Array.isArray(w)&&w.length>=2&&(i=w[1],D!==void 0&&!D.match(/^-/)&&!L(i,a.bools)&&!L(i,a.counts)?(F(i,D),o++):F(i,ye(i)));else if(s.match(/^-[^-]+/)&&!s.match(m)){A=s.slice(1,-1).split(""),u=!1;for(let K=0;K<A.length;K++){if(D=s.slice(K+2),A[K+1]&&A[K+1]==="="){W=s.slice(K+3),i=A[K],L(i,a.arrays)?o=G(o,i,v,W):L(i,a.nargs)!==!1?o=B(o,i,v,W):F(i,W),u=!0;break}if(D==="-"){F(A[K],D);continue}if(/[A-Za-z]/.test(A[K])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(D)&&L(D,a.bools)===!1){F(A[K],D),u=!0;break}if(A[K+1]&&A[K+1].match(/\W/)){F(A[K],D),u=!0;break}else F(A[K],ye(A[K]))}i=s.slice(-1)[0],!u&&i!=="-"&&(L(i,a.arrays)?o=G(o,i,v):L(i,a.nargs)!==!1?o=B(o,i,v):(D=v[o+1],D!==void 0&&(!/^(-|--)[^-]/.test(D)||D.match(m))&&!L(i,a.bools)&&!L(i,a.counts)||/^(true|false)$/.test(D)?(F(i,D),o++):F(i,ye(i))))}else if(s.match(/^-[0-9]$/)&&s.match(m)&&L(s.slice(1),a.bools))i=s.slice(1),F(i,ye(i));else if(s==="--"){y=v.slice(o+1);break}else if(P["halt-at-non-option"]){y=v.slice(o);break}else $(s)}ke(O,!0),ke(O,!1),Ee(O),at(),Pe(O,a.aliases,k,!0),He(O),P["set-placeholder-key"]&&Ge(O),Object.keys(a.counts).forEach(function(o){be(O,o.split("."))||F(o,0)}),_e&&y.length&&(O[ae]=[]),y.forEach(function(o){O[ae].push(o)}),P["camel-case-expansion"]&&P["strip-dashed"]&&Object.keys(O).filter(o=>o!=="--"&&o.includes("-")).forEach(o=>{delete O[o]}),P["strip-aliased"]&&[].concat(...Object.keys(U).map(o=>U[o])).forEach(o=>{P["camel-case-expansion"]&&o.includes("-")&&delete O[o.split(".").map(s=>n(s)).join(".")],delete O[o]});function $(o){const s=Z("_",o);(typeof s=="string"||typeof s=="number")&&O._.push(s)}function B(o,s,E,u){let i,A=L(s,a.nargs);if(A=typeof A!="number"||isNaN(A)?1:A,A===0)return ce(u)||(x=Error(g("Argument unexpected for: %s",s))),F(s,ye(s)),o;let w=ce(u)?0:1;if(P["nargs-eats-options"])E.length-(o+1)+w<A&&(x=Error(g("Not enough arguments following: %s",s))),w=A;else{for(i=o+1;i<E.length&&(!E[i].match(/^-[^0-9]/)||E[i].match(m)||ie(E[i]));i++)w++;w<A&&(x=Error(g("Not enough arguments following: %s",s)))}let D=Math.min(w,A);for(!ce(u)&&D>0&&(F(s,u),D--),i=o+1;i<D+o+1;i++)F(s,E[i]);return o+D}function G(o,s,E,u){let i=[],A=u||E[o+1];const w=L(s,a.nargs);if(L(s,a.bools)&&!/^(true|false)$/.test(A))i.push(!0);else if(ce(A)||ce(u)&&/^-/.test(A)&&!m.test(A)&&!ie(A)){if(k[s]!==void 0){const D=k[s];i=Array.isArray(D)?D:[D]}}else{ce(u)||i.push(X(s,u));for(let D=o+1;D<E.length&&!(!P["greedy-arrays"]&&i.length>0||w&&typeof w=="number"&&i.length>=w||(A=E[D],/^-/.test(A)&&!m.test(A)&&!ie(A)));D++)o=D,i.push(X(s,A))}return typeof w=="number"&&(w&&i.length<w||isNaN(w)&&i.length===0)&&(x=Error(g("Not enough arguments following: %s",s))),F(s,i),o}function F(o,s){if(/-/.test(o)&&P["camel-case-expansion"]){const i=o.split(".").map(function(A){return n(A)}).join(".");ve(o,i)}const E=X(o,s),u=o.split(".");we(O,u,E),a.aliases[o]&&a.aliases[o].forEach(function(i){const A=i.split(".");we(O,A,E)}),u.length>1&&P["dot-notation"]&&(a.aliases[u[0]]||[]).forEach(function(i){let A=i.split(".");const w=[].concat(u);w.shift(),A=A.concat(w),(a.aliases[o]||[]).includes(A.join("."))||we(O,A,E)}),L(o,a.normalize)&&!L(o,a.arrays)&&[o].concat(a.aliases[o]||[]).forEach(function(A){Object.defineProperty(V,A,{enumerable:!0,get(){return s},set(w){s=typeof w=="string"?j.normalize(w):w}})})}function ve(o,s){a.aliases[o]&&a.aliases[o].length||(a.aliases[o]=[s],se[s]=!0),a.aliases[s]&&a.aliases[s].length||ve(s,o)}function X(o,s){typeof s=="string"&&(s[0]==="'"||s[0]==='"')&&s[s.length-1]===s[0]&&(s=s.substring(1,s.length-1)),(L(o,a.bools)||L(o,a.counts))&&typeof s=="string"&&(s=s==="true");let E=Array.isArray(s)?s.map(function(u){return Z(o,u)}):Z(o,s);return L(o,a.counts)&&(ce(E)||typeof E=="boolean")&&(E=re()),L(o,a.normalize)&&L(o,a.arrays)&&(Array.isArray(s)?E=s.map(u=>j.normalize(u)):E=j.normalize(s)),E}function Z(o,s){return!P["parse-positional-numbers"]&&o==="_"||!L(o,a.strings)&&!L(o,a.bools)&&!Array.isArray(s)&&(_(s)&&P["parse-numbers"]&&Number.isSafeInteger(Math.floor(parseFloat(`${s}`)))||!ce(s)&&L(o,a.numbers))&&(s=Number(s)),s}function Ee(o){const s=Object.create(null);Pe(s,a.aliases,k),Object.keys(a.configs).forEach(function(E){const u=o[E]||s[E];if(u)try{let i=null;const A=j.resolve(j.cwd(),u),w=a.configs[E];if(typeof w=="function"){try{i=w(A)}catch(D){i=D}if(i instanceof Error){x=i;return}}else i=j.require(A);Q(i)}catch(i){i.name==="PermissionDenied"?x=i:o[E]&&(x=Error(g("Invalid JSON config file: %s",u)))}})}function Q(o,s){Object.keys(o).forEach(function(E){const u=o[E],i=s?s+"."+E:E;typeof u=="object"&&u!==null&&!Array.isArray(u)&&P["dot-notation"]?Q(u,i):(!be(O,i.split("."))||L(i,a.arrays)&&P["combine-arrays"])&&F(i,u)})}function at(){typeof pe<"u"&&pe.forEach(function(o){Q(o)})}function ke(o,s){if(typeof ue>"u")return;const E=typeof ue=="string"?ue:"",u=j.env();Object.keys(u).forEach(function(i){if(E===""||i.lastIndexOf(E,0)===0){const A=i.split("__").map(function(w,D){return D===0&&(w=w.substring(E.length)),n(w)});(s&&a.configs[A.join(".")]||!s)&&!be(o,A)&&F(A.join("."),u[i])}})}function He(o){let s;const E=new Set;Object.keys(o).forEach(function(u){if(!E.has(u)&&(s=L(u,a.coercions),typeof s=="function"))try{const i=Z(u,s(o[u]));[].concat(a.aliases[u]||[],u).forEach(A=>{E.add(A),o[A]=i})}catch(i){x=i}})}function Ge(o){return a.keys.forEach(s=>{~s.indexOf(".")||typeof o[s]>"u"&&(o[s]=void 0)}),o}function Pe(o,s,E,u=!1){Object.keys(E).forEach(function(i){be(o,i.split("."))||(we(o,i.split("."),E[i]),u&&(p[i]=!0),(s[i]||[]).forEach(function(A){be(o,A.split("."))||we(o,A.split("."),E[i])}))})}function be(o,s){let E=o;P["dot-notation"]||(s=[s.join(".")]),s.slice(0,-1).forEach(function(i){E=E[i]||{}});const u=s[s.length-1];return typeof E!="object"?!1:u in E}function we(o,s,E){let u=o;P["dot-notation"]||(s=[s.join(".")]),s.slice(0,-1).forEach(function(W){W=ne(W),typeof u=="object"&&u[W]===void 0&&(u[W]={}),typeof u[W]!="object"||Array.isArray(u[W])?(Array.isArray(u[W])?u[W].push({}):u[W]=[u[W],{}],u=u[W][u[W].length-1]):u=u[W]});const i=ne(s[s.length-1]),A=L(s.join("."),a.arrays),w=Array.isArray(E);let D=P["duplicate-arguments-array"];!D&&L(i,a.nargs)&&(D=!0,(!ce(u[i])&&a.nargs[i]===1||Array.isArray(u[i])&&u[i].length===a.nargs[i])&&(u[i]=void 0)),E===re()?u[i]=re(u[i]):Array.isArray(u[i])?D&&A&&w?u[i]=P["flatten-duplicate-arrays"]?u[i].concat(E):(Array.isArray(u[i][0])?u[i]:[u[i]]).concat([E]):!D&&!!A==!!w?u[i]=E:u[i]=u[i].concat([E]):u[i]===void 0&&A?u[i]=w?E:[E]:D&&!(u[i]===void 0||L(i,a.counts)||L(i,a.bools))?u[i]=[u[i],E]:u[i]=E}function ct(...o){o.forEach(function(s){Object.keys(s||{}).forEach(function(E){a.aliases[E]||(a.aliases[E]=[].concat(U[E]||[]),a.aliases[E].concat(E).forEach(function(u){if(/-/.test(u)&&P["camel-case-expansion"]){const i=n(u);i!==E&&a.aliases[E].indexOf(i)===-1&&(a.aliases[E].push(i),se[i]=!0)}}),a.aliases[E].concat(E).forEach(function(u){if(u.length>1&&/[A-Z]/.test(u)&&P["camel-case-expansion"]){const i=l(u,"-");i!==E&&a.aliases[E].indexOf(i)===-1&&(a.aliases[E].push(i),se[i]=!0)}}),a.aliases[E].forEach(function(u){a.aliases[u]=[E].concat(a.aliases[E].filter(function(i){return u!==i}))}))})})}function L(o,s){const E=[].concat(a.aliases[o]||[],o),u=Object.keys(s),i=E.find(A=>u.includes(A));return i?s[i]:!1}function De(o){const s=Object.keys(a);return[].concat(s.map(u=>a[u])).some(function(u){return Array.isArray(u)?u.includes(o):u[o]})}function qe(o,...s){return[].concat(...s).some(function(u){const i=o.match(u);return i&&De(i[1])})}function Ye(o){if(o.match(m)||!o.match(/^-[^-]+/))return!1;let s=!0,E;const u=o.slice(1).split("");for(let i=0;i<u.length;i++){if(E=o.slice(i+2),!De(u[i])){s=!1;break}if(u[i+1]&&u[i+1]==="="||E==="-"||/[A-Za-z]/.test(u[i])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(E)||u[i+1]&&u[i+1].match(/\W/))break}return s}function ie(o){return P["unknown-options-as-args"]&&Ne(o)}function Ne(o){return o=o.replace(/^-{3,}/,"--"),o.match(m)||Ye(o)?!1:!qe(o,/^-+([^=]+?)=[\s\S]*$/,b,/^-+([^=]+?)$/,/^-+([^=]+?)-$/,/^-+([^=]+?\d+)$/,/^-+([^=]+?)\W+.*$/)}function ye(o){return!L(o,a.bools)&&!L(o,a.counts)&&`${o}`in k?k[o]:Je(ze(o))}function Je(o){return{[I.BOOLEAN]:!0,[I.STRING]:"",[I.NUMBER]:void 0,[I.ARRAY]:[]}[o]}function ze(o){let s=I.BOOLEAN;return L(o,a.strings)?s=I.STRING:L(o,a.numbers)?s=I.NUMBER:L(o,a.bools)?s=I.BOOLEAN:L(o,a.arrays)&&(s=I.ARRAY),s}function ce(o){return o===void 0}function lt(){Object.keys(a.counts).find(o=>L(o,a.arrays)?(x=Error(g("Invalid configuration: %s, opts.count excludes opts.array.",o)),!0):L(o,a.nargs)?(x=Error(g("Invalid configuration: %s, opts.count excludes opts.narg.",o)),!0):!1)}return{aliases:Object.assign({},a.aliases),argv:Object.assign(V,O),configuration:P,defaulted:Object.assign({},p),error:x,newAliases:Object.assign({},se)}}}function z(h){const S=[],M=Object.create(null);let T=!0;for(Object.keys(h).forEach(function(v){S.push([].concat(h[v],v))});T;){T=!1;for(let v=0;v<S.length;v++)for(let U=v+1;U<S.length;U++)if(S[v].filter(function(k){return S[U].indexOf(k)!==-1}).length){S[v]=S[v].concat(S[U]),S.splice(U,1),T=!0;break}}return S.forEach(function(v){v=v.filter(function(P,k,pe){return pe.indexOf(P)===k});const U=v.pop();U!==void 0&&typeof U=="string"&&(M[U]=v)}),M}function re(h){return h!==void 0?h+1:1}function ne(h){return h==="__proto__"?"___proto___":h}const de=process&&process.env&&process.env.YARGS_MIN_NODE_VERSION?Number(process.env.YARGS_MIN_NODE_VERSION):10;if(process&&process.version&&Number(process.version.match(/v([^.]+)/)[1])<de)throw Error(`yargs parser supports a minimum Node.js version of ${de}. Read our version support policy: https://github.com/yargs/yargs-parser#supported-nodejs-versions`);const he=process?process.env:{},Y=new H({cwd:process.cwd,env:()=>he,format:f.format,normalize:t.normalize,resolve:t.resolve,require:h=>{if(typeof Vt<"u")return Vt(h);if(h.match(/\.json$/))return e.readFileSync(h,"utf8");throw Error("only .json config files are supported in ESM")}}),oe=function(S,M){return Y.parse(S.slice(),M).argv};return oe.detailed=function(h,S){return Y.parse(h.slice(),S)},oe.camelCase=n,oe.decamelize=l,oe.looksLikeNumber=_,mt=oe,mt}var We={exports:{}};We.exports;var $t;function un(){return $t||($t=1,function(f,e){var t=200,n="__lodash_hash_undefined__",l=9007199254740991,_="[object Arguments]",N="[object Array]",I="[object Boolean]",j="[object Date]",H="[object Error]",z="[object Function]",re="[object GeneratorFunction]",ne="[object Map]",de="[object Number]",he="[object Object]",Y="[object Promise]",oe="[object RegExp]",h="[object Set]",S="[object String]",M="[object Symbol]",T="[object WeakMap]",v="[object ArrayBuffer]",U="[object DataView]",P="[object Float32Array]",k="[object Float64Array]",pe="[object Int8Array]",ue="[object Int16Array]",_e="[object Int32Array]",ae="[object Uint8Array]",se="[object Uint8ClampedArray]",p="[object Uint16Array]",g="[object Uint32Array]",a=/[\\^$.*+?()[\]{}|]/g,m=/\w*$/,b=/^\[object .+?Constructor\]$/,x=/^(?:0|[1-9]\d*)$/,y={};y[_]=y[N]=y[v]=y[U]=y[I]=y[j]=y[P]=y[k]=y[pe]=y[ue]=y[_e]=y[ne]=y[de]=y[he]=y[oe]=y[h]=y[S]=y[M]=y[ae]=y[se]=y[p]=y[g]=!0,y[H]=y[z]=y[T]=!1;var O=typeof Fe=="object"&&Fe&&Fe.Object===Object&&Fe,V=typeof self=="object"&&self&&self.Object===Object&&self,$=O||V||Function("return this")(),B=e&&!e.nodeType&&e,G=B&&!0&&f&&!f.nodeType&&f,F=G&&G.exports===B;function ve(r,c){return r.set(c[0],c[1]),r}function X(r,c){return r.add(c),r}function Z(r,c){for(var d=-1,R=r?r.length:0;++d<R&&c(r[d],d,r)!==!1;);return r}function Ee(r,c){for(var d=-1,R=c.length,q=r.length;++d<R;)r[q+d]=c[d];return r}function Q(r,c,d,R){for(var q=-1,ee=r?r.length:0;++q<ee;)d=c(d,r[q],q,r);return d}function at(r,c){for(var d=-1,R=Array(r);++d<r;)R[d]=c(d);return R}function ke(r,c){return r==null?void 0:r[c]}function He(r){var c=!1;if(r!=null&&typeof r.toString!="function")try{c=!!(r+"")}catch{}return c}function Ge(r){var c=-1,d=Array(r.size);return r.forEach(function(R,q){d[++c]=[q,R]}),d}function Pe(r,c){return function(d){return r(c(d))}}function be(r){var c=-1,d=Array(r.size);return r.forEach(function(R){d[++c]=R}),d}var we=Array.prototype,ct=Function.prototype,L=Object.prototype,De=$["__core-js_shared__"],qe=function(){var r=/[^.]+$/.exec(De&&De.keys&&De.keys.IE_PROTO||"");return r?"Symbol(src)_1."+r:""}(),Ye=ct.toString,ie=L.hasOwnProperty,Ne=L.toString,ye=RegExp("^"+Ye.call(ie).replace(a,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Je=F?$.Buffer:void 0,ze=$.Symbol,ce=$.Uint8Array,lt=Pe(Object.getPrototypeOf,Object),o=Object.create,s=L.propertyIsEnumerable,E=we.splice,u=Object.getOwnPropertySymbols,i=Je?Je.isBuffer:void 0,A=Pe(Object.keys,Object),w=Le($,"DataView"),D=Le($,"Map"),W=Le($,"Promise"),K=Le($,"Set"),ut=Le($,"WeakMap"),Be=Le(Object,"create"),rr=Oe(w),nr=Oe(D),or=Oe(W),sr=Oe(K),ir=Oe(ut),At=ze?ze.prototype:void 0,Tt=At?At.valueOf:void 0;function Ae(r){var c=-1,d=r?r.length:0;for(this.clear();++c<d;){var R=r[c];this.set(R[0],R[1])}}function ar(){this.__data__=Be?Be(null):{}}function cr(r){return this.has(r)&&delete this.__data__[r]}function lr(r){var c=this.__data__;if(Be){var d=c[r];return d===n?void 0:d}return ie.call(c,r)?c[r]:void 0}function ur(r){var c=this.__data__;return Be?c[r]!==void 0:ie.call(c,r)}function fr(r,c){var d=this.__data__;return d[r]=Be&&c===void 0?n:c,this}Ae.prototype.clear=ar,Ae.prototype.delete=cr,Ae.prototype.get=lr,Ae.prototype.has=ur,Ae.prototype.set=fr;function ge(r){var c=-1,d=r?r.length:0;for(this.clear();++c<d;){var R=r[c];this.set(R[0],R[1])}}function dr(){this.__data__=[]}function hr(r){var c=this.__data__,d=Xe(c,r);if(d<0)return!1;var R=c.length-1;return d==R?c.pop():E.call(c,d,1),!0}function pr(r){var c=this.__data__,d=Xe(c,r);return d<0?void 0:c[d][1]}function gr(r){return Xe(this.__data__,r)>-1}function mr(r,c){var d=this.__data__,R=Xe(d,r);return R<0?d.push([r,c]):d[R][1]=c,this}ge.prototype.clear=dr,ge.prototype.delete=hr,ge.prototype.get=pr,ge.prototype.has=gr,ge.prototype.set=mr;function je(r){var c=-1,d=r?r.length:0;for(this.clear();++c<d;){var R=r[c];this.set(R[0],R[1])}}function _r(){this.__data__={hash:new Ae,map:new(D||ge),string:new Ae}}function Er(r){return Ze(this,r).delete(r)}function br(r){return Ze(this,r).get(r)}function yr(r){return Ze(this,r).has(r)}function Sr(r,c){return Ze(this,r).set(r,c),this}je.prototype.clear=_r,je.prototype.delete=Er,je.prototype.get=br,je.prototype.has=yr,je.prototype.set=Sr;function Me(r){this.__data__=new ge(r)}function vr(){this.__data__=new ge}function wr(r){return this.__data__.delete(r)}function Ar(r){return this.__data__.get(r)}function Tr(r){return this.__data__.has(r)}function Or(r,c){var d=this.__data__;if(d instanceof ge){var R=d.__data__;if(!D||R.length<t-1)return R.push([r,c]),this;d=this.__data__=new je(R)}return d.set(r,c),this}Me.prototype.clear=vr,Me.prototype.delete=wr,Me.prototype.get=Ar,Me.prototype.has=Tr,Me.prototype.set=Or;function Ir(r,c){var d=ht(r)||Xr(r)?at(r.length,String):[],R=d.length,q=!!R;for(var ee in r)ie.call(r,ee)&&!(q&&(ee=="length"||qr(ee,R)))&&d.push(ee);return d}function Ot(r,c,d){var R=r[c];(!(ie.call(r,c)&&Pt(R,d))||d===void 0&&!(c in r))&&(r[c]=d)}function Xe(r,c){for(var d=r.length;d--;)if(Pt(r[d][0],c))return d;return-1}function Rr(r,c){return r&&It(c,pt(c),r)}function ft(r,c,d,R,q,ee,me){var te;if(R&&(te=ee?R(r,q,ee,me):R(r)),te!==void 0)return te;if(!Qe(r))return r;var jt=ht(r);if(jt){if(te=kr(r),!c)return Fr(r,te)}else{var xe=Te(r),Mt=xe==z||xe==re;if(Qr(r))return Mr(r,c);if(xe==he||xe==_||Mt&&!ee){if(He(r))return ee?r:{};if(te=Hr(Mt?{}:r),!c)return Wr(r,Rr(te,r))}else{if(!y[xe])return ee?r:{};te=Gr(r,xe,ft,c)}}me||(me=new Me);var Lt=me.get(r);if(Lt)return Lt;if(me.set(r,te),!jt)var xt=d?Kr(r):pt(r);return Z(xt||r,function(gt,et){xt&&(et=gt,gt=r[et]),Ot(te,et,ft(gt,c,d,R,et,r,me))}),te}function Cr(r){return Qe(r)?o(r):{}}function Pr(r,c,d){var R=c(r);return ht(r)?R:Ee(R,d(r))}function Dr(r){return Ne.call(r)}function Nr(r){if(!Qe(r)||Jr(r))return!1;var c=Nt(r)||He(r)?ye:b;return c.test(Oe(r))}function jr(r){if(!Ct(r))return A(r);var c=[];for(var d in Object(r))ie.call(r,d)&&d!="constructor"&&c.push(d);return c}function Mr(r,c){if(c)return r.slice();var d=new r.constructor(r.length);return r.copy(d),d}function dt(r){var c=new r.constructor(r.byteLength);return new ce(c).set(new ce(r)),c}function Lr(r,c){var d=c?dt(r.buffer):r.buffer;return new r.constructor(d,r.byteOffset,r.byteLength)}function xr(r,c,d){var R=c?d(Ge(r),!0):Ge(r);return Q(R,ve,new r.constructor)}function Vr(r){var c=new r.constructor(r.source,m.exec(r));return c.lastIndex=r.lastIndex,c}function Ur(r,c,d){var R=c?d(be(r),!0):be(r);return Q(R,X,new r.constructor)}function $r(r){return Tt?Object(Tt.call(r)):{}}function Br(r,c){var d=c?dt(r.buffer):r.buffer;return new r.constructor(d,r.byteOffset,r.length)}function Fr(r,c){var d=-1,R=r.length;for(c||(c=Array(R));++d<R;)c[d]=r[d];return c}function It(r,c,d,R){d||(d={});for(var q=-1,ee=c.length;++q<ee;){var me=c[q],te=void 0;Ot(d,me,te===void 0?r[me]:te)}return d}function Wr(r,c){return It(r,Rt(r),c)}function Kr(r){return Pr(r,pt,Rt)}function Ze(r,c){var d=r.__data__;return Yr(c)?d[typeof c=="string"?"string":"hash"]:d.map}function Le(r,c){var d=ke(r,c);return Nr(d)?d:void 0}var Rt=u?Pe(u,Object):rn,Te=Dr;(w&&Te(new w(new ArrayBuffer(1)))!=U||D&&Te(new D)!=ne||W&&Te(W.resolve())!=Y||K&&Te(new K)!=h||ut&&Te(new ut)!=T)&&(Te=function(r){var c=Ne.call(r),d=c==he?r.constructor:void 0,R=d?Oe(d):void 0;if(R)switch(R){case rr:return U;case nr:return ne;case or:return Y;case sr:return h;case ir:return T}return c});function kr(r){var c=r.length,d=r.constructor(c);return c&&typeof r[0]=="string"&&ie.call(r,"index")&&(d.index=r.index,d.input=r.input),d}function Hr(r){return typeof r.constructor=="function"&&!Ct(r)?Cr(lt(r)):{}}function Gr(r,c,d,R){var q=r.constructor;switch(c){case v:return dt(r);case I:case j:return new q(+r);case U:return Lr(r,R);case P:case k:case pe:case ue:case _e:case ae:case se:case p:case g:return Br(r,R);case ne:return xr(r,R,d);case de:case S:return new q(r);case oe:return Vr(r);case h:return Ur(r,R,d);case M:return $r(r)}}function qr(r,c){return c=c??l,!!c&&(typeof r=="number"||x.test(r))&&r>-1&&r%1==0&&r<c}function Yr(r){var c=typeof r;return c=="string"||c=="number"||c=="symbol"||c=="boolean"?r!=="__proto__":r===null}function Jr(r){return!!qe&&qe in r}function Ct(r){var c=r&&r.constructor,d=typeof c=="function"&&c.prototype||L;return r===d}function Oe(r){if(r!=null){try{return Ye.call(r)}catch{}try{return r+""}catch{}}return""}function zr(r){return ft(r,!0,!0)}function Pt(r,c){return r===c||r!==r&&c!==c}function Xr(r){return Zr(r)&&ie.call(r,"callee")&&(!s.call(r,"callee")||Ne.call(r)==_)}var ht=Array.isArray;function Dt(r){return r!=null&&en(r.length)&&!Nt(r)}function Zr(r){return tn(r)&&Dt(r)}var Qr=i||nn;function Nt(r){var c=Qe(r)?Ne.call(r):"";return c==z||c==re}function en(r){return typeof r=="number"&&r>-1&&r%1==0&&r<=l}function Qe(r){var c=typeof r;return!!r&&(c=="object"||c=="function")}function tn(r){return!!r&&typeof r=="object"}function pt(r){return Dt(r)?Ir(r):jr(r)}function rn(){return[]}function nn(){return!1}f.exports=zr}(We,We.exports)),We.exports}var _t,Bt;function fn(){if(Bt)return _t;Bt=1;const f=Ve,e=ln(),t=un(),n=["__proto__.","constructor.prototype."],l="strict",_="warn";function N(p,g){if(!p)throw new Error(g)}function I(p){return Number.isInteger(p)&&p>=0&&p<=65535}function j(p){return String(p).includes("\\\\.\\pipe\\")}const H={"*":function(){},int:function(p){N(Number.isInteger(p),"must be an integer")},nat:function(p){N(Number.isInteger(p)&&p>=0,"must be a positive integer")},port:function(p){N(I(p),"ports must be within range 0 - 65535")},windows_named_pipe:function(p){N(j(p),"must be a valid pipe")},port_or_windows_named_pipe:function(p){j(p)||N(I(p),"must be a windows named pipe or a number within range 0 - 65535")}};H.integer=H.int;const z=new Map,re={"*":JSON.parse};function ne(p,g){const a=Object.keys(p);let m;const b=[];for(;a.length;){m=a.shift();let y=ae(p,m);if(typeof y=="object"&&!Array.isArray(y)&&y!=null){if(g)if("_cvtProperties"in y)y=y._cvtProperties,m=`${m}._cvtProperties`;else{b.push([m,y]);continue}const O=Object.keys(y);if(O.length>0){O.forEach(function(V){a.push(`${m}.${V}`)});continue}}b.push([m,y])}const x={};return b.forEach(function(y){let O=y[0];g&&(O=O.replace(/\._cvtProperties/g,""));const V=y[1];x[O]=V}),x}function de(p,g,a){const m={undeclared:[],invalid_type:[],missing:[]},b=ne(p),x=ne(g._cvtProperties,!0);return Object.keys(x).forEach(function(y){const O=x[y];let V=b[y];if(!(y in b))try{if(typeof O.default=="object"&&!Array.isArray(O.default))V=ae(p,y);else throw new Error("missing")}catch{const B=new Error(`configuration param '${y}' missing from config, did you override its parent?`);m.missing.push(B);return}if(delete b[y],(O.format==="object"||typeof O.default=="object")&&Object.keys(b).filter(function($){return $.lastIndexOf(`${y}.`,0)===0}).forEach(function($){delete b[$]}),!(typeof O.default>"u"&&V===O.default))try{O._format(V)}catch($){m.invalid_type.push($)}}),a&&Object.keys(b).forEach(function(y){const O=new Error(`configuration param '${y}' not declared in the schema`);m.undeclared.push(O)}),m}function he(p,g){N(p.indexOf(g)!==-1,`must be one of the possible values: ${JSON.stringify(p)}`)}const Y={Object,Array,String,Number,Boolean,RegExp},oe=Object.keys(Y),h=oe.map(function(p){return Y[p]});function S(p,g,a,m,b,x,y){if(p==="_cvtProperties")throw new Error(`'${m}': '_cvtProperties' is reserved word of convict.`);if(typeof g=="object"&&g!==null&&!Array.isArray(g)&&Object.keys(g).length>0&&!("default"in g)){a[p]={_cvtProperties:{}},Object.keys(g).forEach(function(B){S(B,g[B],a[p]._cvtProperties,`${m}.${B}`,b,x,y)});return}else(typeof g!="object"||Array.isArray(g)||g===null||Object.keys(g).length==0)&&(g={default:g});const O=t(g);if(a[p]=O,O.env&&(b[O.env]||(b[O.env]=[]),b[O.env].push(m)),O.arg){if(x[O.arg])throw new Error(`'${m}' reuses a command-line argument: ${O.arg}`);x[O.arg]=m}O.sensitive===!0&&y.add(m);const V=O.format;let $;if(h.indexOf(V)>=0||oe.indexOf(V)>=0){const B=typeof V=="string"?Y[V]:V;$=function(G){N(Object.prototype.toString.call(G)==Object.prototype.toString.call(new B),`must be of type ${B.name}`)},O.format=B.name.toLowerCase()}else if(typeof V=="string"){if(!H[V])throw new Error(`'${m}' uses an unknown format type: ${V}`);$=H[V]}else if(Array.isArray(V))$=he.bind(null,V);else if(typeof V=="function")$=V;else if(V&&typeof V!="function")throw new Error(`'${m}': "format" must be a function or a known format type.`);if(!$&&!V){const B=Object.prototype.toString.call(O.default);$=function(G){N(Object.prototype.toString.call(G)==B," should be of type "+B.replace(/\[.* |]/g,""))}}O._format=function(B){if(!(this.nullable&&B===null))try{$(B,this)}catch(G){throw G.fullName=m,G.value=B,G}}}function M(p){const g=p.getEnv();Object.keys(p._env).forEach(function(a){g[a]!==void 0&&p._env[a].forEach(function(b){p.set(b,g[a])})})}function T(p){const g=e(p.getArgs(),{configuration:{"dot-notation":!1}});Object.keys(p._argv).forEach(function(a){const m=p._argv[a];g[a]!==void 0&&p.set(m,String(g[a]))})}function v(p,g,a){Object.keys(p._cvtProperties).forEach(function(m){const b=p._cvtProperties[m];if(b._cvtProperties){const x=g[m]||{};v(b,x,a),g[m]=x}else g[m]=ue(m,t(b.default),p,a)})}function U(p){return typeof p=="object"&&p!==null}function P(p,g,a){Object.keys(p).forEach(function(m){Array.isArray(p[m])||!U(p[m])||!a||a.format==="object"?g[m]=ue(m,p[m],a):(U(g[m])||(g[m]={}),P(p[m],g[m],a._cvtProperties[m]))})}function k(p,g){const a=g.split(".");let m=p;for(;a.length>0;){const b=a.shift();if(m&&m._cvtProperties&&m._cvtProperties[b])m=m._cvtProperties[b];else{m=null;break}}return m}function pe(p,g){const a=k(p,g);return a==null?null:typeof a.format=="string"?a.format:a.default!=null?typeof a.default:null}function ue(p,g,a,m){const b=pe(a,p);if(typeof g=="string"){if(z.has(b))return z.get(b)(g,m,p);switch(b){case"port":case"nat":case"integer":case"int":g=parseInt(g,10);break;case"port_or_windows_named_pipe":g=j(g)?g:parseInt(g,10);break;case"number":g=parseFloat(g);break;case"boolean":g=String(g).toLowerCase()!=="false";break;case"array":g=g.split(",");break;case"object":g=JSON.parse(g);break;case"regexp":g=new RegExp(g);break}}return g}function _e(p){const g=p.split("."),a=g.length>1?g.pop():"";return(re[a]||re["*"])(f.readFileSync(p,"utf-8"))}function ae(p,g,a){if(g){const m=g.split(".");for(;m.length;){const b=m.shift();if(a&&p[b]==null)p[b]={},p=p[b];else if(b in p)p=p[b];else throw new Error(`cannot find configuration param '${g}'`)}}return p}const se=function(g,a){const m={getArgs:function(){return a&&a.args||process.argv.slice(2)},getEnv:function(){return a&&a.env||process.env},getProperties:function(){return t(this._instance)},toString:function(){const b=t(this._instance);return this._sensitive.forEach(function(x){const y=x.split("."),O=y.pop(),V=y.join("."),$=ae(b,V);$[O]="[Sensitive]"}),JSON.stringify(b,null,2)},getSchema:function(){return JSON.parse(JSON.stringify(this._schema))},getSchemaString:function(){return JSON.stringify(this._schema,null,2)},get:function(b){const x=ae(this._instance,b);return t(x)},default:function(b){b=b.split(".").join("._cvtProperties.")+".default";const x=ae(this._schema._cvtProperties,b);return t(x)},reset:function(b){this.set(b,this.default(b))},has:function(b){try{return typeof this.get(b)<"u"}catch{return!1}},set:function(b,x){for(const B of n)if(b.startsWith(B)||b.includes(`.${B}`))return this;x=ue(b,x,this._schema,this);const y=b.split("."),O=y.pop(),V=y.join("."),$=ae(this._instance,V,!0);return $[O]=x,this},load:function(b){return P(b,this._instance,this._schema),M(m),T(m),this},loadFile:function(b){const x=this;return Array.isArray(b)||(b=[b]),b.forEach(function(y){const O=_e(y);O&&P(O,x._instance,x._schema)}),M(m),T(m),this},validate:function(b){if(b=b||{},b.allowed=b.allowed||_,b.output&&typeof b.output!="function")throw new Error("options.output is optional and must be a function.");const x=b.output||Fe.console.log,y=de(this._instance,this._schema,b.allowed);if(y.invalid_type.length+y.undeclared.length+y.missing.length){const O=this._sensitive,V=function(X){let Z="";for(let Ee=0;Ee<X.length;Ee++){Z.length&&(Z+=` `);const Q=X[Ee];Q.fullName&&(Z+=Q.fullName+": "),Q.message&&(Z+=Q.message),Q.value&&!O.has(Q.fullName)&&(Z+=": value was "+JSON.stringify(Q.value))}return Z},$=V(y.invalid_type),B=V(y.undeclared),G=V(y.missing),F=[$,G];if(b.allowed===_&&B.length){let X="Warning:";process.stdout.isTTY&&(X="\x1B[33;1m"+X+"\x1B[0m"),x(X+" "+B)}else b.allowed===l&&F.push(B);const ve=F.filter(function(X){return X.length}).join(` `);if(ve.length)throw new Error(ve)}return this}};return typeof g=="string"?m._def=_e(g):m._def=g,m._schema={_cvtProperties:{}},m._env={},m._argv={},m._sensitive=new Set,Object.keys(m._def).forEach(function(b){S(b,m._def[b],m._schema._cvtProperties,b,m._env,m._argv,m._sensitive)}),m._instance={},v(m._schema,m._instance,m),M(m),T(m),m};return se.addFormat=function(p,g,a){if(typeof p=="object"&&(g=p.validate,a=p.coerce,p=p.name),typeof g!="function")throw new Error(`Validation function for '${p}' must be a function.`);if(a&&typeof a!="function")throw new Error(`Coerce function for '${p}' must be a function.`);H[p]=g,a&&z.set(p,a)},se.addFormats=function(p){Object.keys(p).forEach(function(g){se.addFormat(g,p[g].validate,p[g].coerce)})},se.addParser=function(p){Array.isArray(p)||(p=[p]),p.forEach(function(g){if(!g)throw new Error("Invalid parser");if(!g.extension)throw new Error("Missing parser.extension");if(!g.parse)throw new Error("Missing parser.parse function");if(typeof g.parse!="function")throw new Error("Invalid parser.parse function");(Array.isArray(g.extension)?g.extension:[g.extension]).forEach(function(m){if(typeof m!="string")throw new Error("Invalid parser.extension");re[m]=g.parse})})},_t=se,_t}var dn=fn();const J=Kt(dn);J.addFormat({name:"required-string",validate:f=>{if(typeof f!="string"||f.trim().length===0)throw new Error("must be a non-empty string")}});J.addFormat({name:"url",validate:f=>{if(typeof f!="string")throw new Error("must be a string");try{new URL(f)}catch{throw new Error("must be a valid URL")}}});J.addFormat({name:"email",validate:f=>{if(typeof f!="string")throw new Error("must be a string");if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(f))throw new Error("must be a valid email address")}});J.addFormat({name:"optional-string",validate:f=>{if(f!=null&&typeof f!="string")throw new Error("must be a string or null/undefined")}});J.addFormat({name:"positive-int",validate:f=>{if(!Number.isInteger(f)||f<=0)throw new Error("must be a positive integer")}});J.addFormat({name:"non-negative-int",validate:f=>{if(!Number.isInteger(f)||f<0)throw new Error("must be a non-negative integer")}});J.addFormat({name:"log-level",validate:f=>{const e=["error","warn","info","debug","trace"];if(!e.includes(f))throw new Error(`must be one of: ${e.join(", ")}`)}});J.addFormat({name:"environment",validate:f=>{const e=["development","staging","production","test"];if(!e.includes(f))throw new Error(`must be one of: ${e.join(", ")}`)}});J.addFormat({name:"port-number",validate:f=>{if(!Number.isInteger(f)||f<0||f>65535)throw new Error("must be a valid port number (0-65535)")}});const bt={env:{doc:"The application environment",format:"environment",default:"development",env:"NODE_ENV"},debug:{doc:"Enable debug mode",format:Boolean,default:!1,env:"DEBUG"},name:{doc:"Application name",format:"required-string",default:"DBS Portal",env:"APP_NAME"},version:{doc:"Application version",format:"required-string",default:"1.0.0",env:"APP_VERSION"},port:{doc:"Port to bind on",format:"port-number",default:3e3,env:"PORT"},host:{doc:"Host to bind on",format:"required-string",default:"localhost",env:"HOST"},logging:{level:{doc:"Logging level",format:"log-level",default:"info",env:"LOG_LEVEL"},format:{doc:"Log format",format:["json","text"],default:"text",env:"LOG_FORMAT"},file:{doc:"Log file path",format:"optional-string",default:null,env:"LOG_FILE"},maxFiles:{doc:"Maximum number of log files",format:"positive-int",default:5,env:"LOG_MAX_FILES"},maxSize:{doc:"Maximum log file size",format:"optional-string",default:null,env:"LOG_MAX_SIZE"}},database:{host:{doc:"Database host",format:"required-string",default:"localhost",env:"DB_HOST"},port:{doc:"Database port",format:"port-number",default:5432,env:"DB_PORT"},database:{doc:"Database name",format:"required-string",default:"dbs_portal",env:"DB_NAME"},username:{doc:"Database username",format:"required-string",default:"postgres",env:"DB_USER"},password:{doc:"Database password",format:"required-string",default:"password",env:"DB_PASSWORD",sensitive:!0},ssl:{doc:"Enable SSL for database connection",format:Boolean,default:!1,env:"DB_SSL"},connectionTimeout:{doc:"Database connection timeout in milliseconds",format:"positive-int",default:1e4,env:"DB_CONNECTION_TIMEOUT"},queryTimeout:{doc:"Database query timeout in milliseconds",format:"positive-int",default:3e4,env:"DB_QUERY_TIMEOUT"},maxConnections:{doc:"Maximum number of database connections",format:"positive-int",default:10,env:"DB_MAX_CONNECTIONS"},minConnections:{doc:"Minimum number of database connections",format:"non-negative-int",default:1,env:"DB_MIN_CONNECTIONS"}},redis:{host:{doc:"Redis host",format:"optional-string",default:null,env:"REDIS_HOST"},port:{doc:"Redis port",format:"port-number",default:6379,env:"REDIS_PORT"},password:{doc:"Redis password",format:"optional-string",default:null,env:"REDIS_PASSWORD",sensitive:!0},database:{doc:"Redis database number",format:"non-negative-int",default:0,env:"REDIS_DB"},keyPrefix:{doc:"Redis key prefix",format:"optional-string",default:null,env:"REDIS_KEY_PREFIX"}},auth:{jwtSecret:{doc:"JWT secret key",format:"required-string",default:"your-jwt-secret-change-in-production",env:"JWT_SECRET",sensitive:!0},jwtExpiresIn:{doc:"JWT expiration time",format:"required-string",default:"1h",env:"JWT_EXPIRES_IN"},refreshTokenExpiresIn:{doc:"Refresh token expiration time",format:"required-string",default:"7d",env:"REFRESH_TOKEN_EXPIRES_IN"},bcryptRounds:{doc:"Bcrypt rounds for password hashing",format:"positive-int",default:12,env:"BCRYPT_ROUNDS"},sessionSecret:{doc:"Session secret key",format:"required-string",default:"your-session-secret-change-in-production",env:"SESSION_SECRET",sensitive:!0},sessionMaxAge:{doc:"Session maximum age in milliseconds",format:"positive-int",default:1440*60*1e3,env:"SESSION_MAX_AGE"}},api:{baseUrl:{doc:"API base URL",format:"url",default:"http://localhost:3000",env:"API_BASE_URL"},timeout:{doc:"API request timeout in milliseconds",format:"positive-int",default:3e4,env:"API_TIMEOUT"},retries:{doc:"Number of API request retries",format:"non-negative-int",default:3,env:"API_RETRIES"}},storage:{provider:{doc:"Storage provider",format:["local","s3","azure","gcp"],default:"local",env:"STORAGE_PROVIDER"},local:{uploadPath:{doc:"Local upload path",format:"required-string",default:"./uploads",env:"STORAGE_LOCAL_UPLOAD_PATH"},maxFileSize:{doc:"Maximum file size in bytes",format:"positive-int",default:10*1024*1024,env:"STORAGE_LOCAL_MAX_FILE_SIZE"}},s3:{bucket:{doc:"S3 bucket name",format:"optional-string",default:null,env:"S3_BUCKET"},region:{doc:"S3 region",format:"optional-string",default:null,env:"AWS_REGION"},accessKeyId:{doc:"AWS access key ID",format:"optional-string",default:null,env:"AWS_ACCESS_KEY_ID",sensitive:!0},secretAccessKey:{doc:"AWS secret access key",format:"optional-string",default:null,env:"AWS_SECRET_ACCESS_KEY",sensitive:!0}}},email:{provider:{doc:"Email provider",format:["smtp","sendgrid","mailgun","ses"],default:"smtp",env:"EMAIL_PROVIDER"},from:{doc:"Default from email address",format:"email",default:"noreply@dbsportal.com",env:"EMAIL_FROM"},smtp:{host:{doc:"SMTP host",format:"optional-string",default:null,env:"SMTP_HOST"},port:{doc:"SMTP port",format:"port-number",default:587,env:"SMTP_PORT"},secure:{doc:"Use secure connection",format:Boolean,default:!1,env:"SMTP_SECURE"},auth:{user:{doc:"SMTP username",format:"optional-string",default:null,env:"SMTP_USER"},pass:{doc:"SMTP password",format:"optional-string",default:null,env:"SMTP_PASS",sensitive:!0}}},sendgrid:{apiKey:{doc:"SendGrid API key",format:"optional-string",default:null,env:"SENDGRID_API_KEY",sensitive:!0}}},monitoring:{enabled:{doc:"Enable monitoring",format:Boolean,default:!1,env:"MONITORING_ENABLED"},sentry:{dsn:{doc:"Sentry DSN",format:"optional-string",default:null,env:"SENTRY_DSN",sensitive:!0},environment:{doc:"Sentry environment",format:"optional-string",default:null,env:"SENTRY_ENVIRONMENT"},tracesSampleRate:{doc:"Sentry traces sample rate",format:Number,default:.1,env:"SENTRY_TRACES_SAMPLE_RATE"}},prometheus:{enabled:{doc:"Enable Prometheus metrics",format:Boolean,default:!1,env:"PROMETHEUS_ENABLED"},port:{doc:"Prometheus metrics port",format:"port-number",default:9090,env:"PROMETHEUS_PORT"},path:{doc:"Prometheus metrics path",format:"required-string",default:"/metrics",env:"PROMETHEUS_PATH"}},healthCheck:{enabled:{doc:"Enable health check endpoint",format:Boolean,default:!0,env:"HEALTH_CHECK_ENABLED"},path:{doc:"Health check endpoint path",format:"required-string",default:"/health",env:"HEALTH_CHECK_PATH"},interval:{doc:"Health check interval in milliseconds",format:"positive-int",default:3e4,env:"HEALTH_CHECK_INTERVAL"}}},featureFlags:{provider:{doc:"Feature flags provider",format:["local","launchdarkly","flagsmith"],default:"local",env:"FEATURE_FLAGS_PROVIDER"},local:{flags:{doc:"Local feature flags object",format:Object,default:{},env:"FEATURE_FLAGS_LOCAL"}},launchdarkly:{sdkKey:{doc:"LaunchDarkly SDK key",format:"optional-string",default:null,env:"LAUNCHDARKLY_SDK_KEY",sensitive:!0},environment:{doc:"LaunchDarkly environment",format:"optional-string",default:null,env:"LAUNCHDARKLY_ENVIRONMENT"}}},custom:{doc:"Custom configuration object",format:Object,default:{},env:"CUSTOM_CONFIG"}},rt=J(bt);function hn(){const f=JSON.parse(JSON.stringify(bt));function e(t){for(const n in t)if(t[n]&&typeof t[n]=="object"){if(t[n].env&&delete t[n].env,t[n].doc&&t[n].format)continue;e(t[n])}}return e(f),f}function it(){const f=hn(),e=J(f);return e.validate({allowed:"strict"}),e.getProperties()}function Ce(f){return rt.load(f),rt.validate({allowed:"strict"}),rt.getProperties()}function le(){return J(bt)}const Ft={env:"NODE_ENV",debug:"DEBUG",name:"APP_NAME",version:"APP_VERSION",port:"PORT",host:"HOST",logging:{level:"LOG_LEVEL",format:"LOG_FORMAT",file:"LOG_FILE"},database:{host:"DB_HOST",port:"DB_PORT",database:"DB_NAME",username:"DB_USER",password:"DB_PASSWORD",ssl:"DB_SSL"},redis:{host:"REDIS_HOST",port:"REDIS_PORT",password:"REDIS_PASSWORD",database:"REDIS_DB"},auth:{jwtSecret:"JWT_SECRET",jwtExpiresIn:"JWT_EXPIRES_IN",refreshTokenExpiresIn:"REFRESH_TOKEN_EXPIRES_IN",bcryptRounds:"BCRYPT_ROUNDS",sessionSecret:"SESSION_SECRET",sessionMaxAge:"SESSION_MAX_AGE"},api:{baseUrl:"API_BASE_URL",timeout:"API_TIMEOUT",retries:"API_RETRIES"}};class nt{constructor(e=Ft,t){this.mapping=e,this.prefix=t}name="environment";load(){return this.mapEnvironmentVariables(this.mapping,process.env)}mapEnvironmentVariables(e,t,n={}){for(const[l,_]of Object.entries(e))if(typeof _=="string"){const N=this.prefix?`${this.prefix}_${_}`:_,I=t[N];I!==void 0&&(n[l]=this.parseEnvironmentValue(I))}else typeof _=="object"&&(n[l]=this.mapEnvironmentVariables(_,t,{}));return n}parseEnvironmentValue(e){if(e.toLowerCase()==="true")return!0;if(e.toLowerCase()==="false")return!1;if(/^\d+$/.test(e))return Number.parseInt(e,10);if(/^\d+\.\d+$/.test(e))return Number.parseFloat(e);if(e.startsWith("{")||e.startsWith("["))try{return JSON.parse(e)}catch{}return e.includes(",")?e.split(",").map(t=>t.trim()):e}static withMapping(e,t){return new nt(e,t)}static withPrefix(e){return new nt(Ft,e)}}class Ue{constructor(e){this.options=e,this.options.format||(this.options.format=this.detectFormat(this.options.path))}name="file";watchCallback;isWatching=!1;load(){const e=tt.resolve(this.options.path);if(!Ve.existsSync(e)){if(this.options.optional)return{};throw new Error(`Configuration file not found: ${e}`)}try{const t=Ve.readFileSync(e,"utf-8");return this.parseContent(t,this.options.format)}catch(t){throw new Error(`Failed to load configuration from ${e}: ${t}`)}}watch(e){if(!this.options.watch)return;this.watchCallback=e,this.isWatching=!0;const t=tt.resolve(this.options.path);Ve.watchFile(t,{interval:1e3},()=>{if(this.isWatching&&this.watchCallback)try{const n=this.load();this.watchCallback(n)}catch(n){console.error("Error reloading configuration:",n)}})}unwatch(){if(this.isWatching){const e=tt.resolve(this.options.path);Ve.unwatchFile(e),this.isWatching=!1,this.watchCallback=void 0}}detectFormat(e){var n;switch((n=e.split(".").pop())==null?void 0:n.toLowerCase()){case"json":return"json";case"yaml":case"yml":return"yaml";case"toml":return"toml";case"js":return"js";case"ts":return"ts";default:return"json"}}parseContent(e,t){switch(t){case"json":return JSON.parse(e);case"yaml":throw new Error("YAML parsing not implemented. Install yaml package.");case"toml":throw new Error("TOML parsing not implemented. Install @iarna/toml package.");case"js":case"ts":throw new Error("JS/TS module loading not implemented in browser environment.");default:throw new Error(`Unsupported file format: ${t}`)}}static json(e,t={}){return new Ue({...t,path:e,format:"json"})}static yaml(e,t={}){return new Ue({...t,path:e,format:"yaml"})}static optional(e,t={}){return new Ue({...t,path:e,optional:!0})}static watching(e,t={}){return new Ue({...t,path:e,watch:!0})}}class Ie{constructor(e){this.config=e}name="object";load(){return this.config}static from(e){return new Ie(e)}static defaults(){return new Ie({env:"development",debug:!0,name:"DBS Portal",version:"1.0.0",port:3e3,host:"localhost",logging:{level:"info",format:"text"},database:{host:"localhost",port:5432,database:"dbs_portal",username:"postgres",password:"password"},auth:{jwtSecret:"your-jwt-secret-change-in-production",jwtExpiresIn:"1h",refreshTokenExpiresIn:"7d",bcryptRounds:12,sessionSecret:"your-session-secret-change-in-production",sessionMaxAge:1440*60*1e3},api:{baseUrl:"http://localhost:3000",timeout:3e4,retries:3},storage:{provider:"local",local:{uploadPath:"./uploads",maxFileSize:10*1024*1024}},email:{provider:"smtp",from:"noreply@dbsportal.com",smtp:{host:"localhost",port:587,secure:!1,auth:{user:"user",pass:"password"}}},monitoring:{enabled:!1},featureFlags:{provider:"local",local:{flags:{}}}})}static development(){return new Ie({env:"development",debug:!0,logging:{level:"debug",format:"text"},monitoring:{enabled:!1}})}static production(){return new Ie({env:"production",debug:!1,logging:{level:"warn",format:"json"},monitoring:{enabled:!0}})}static testing(){return new Ie({env:"test",debug:!1,logging:{level:"error",format:"text"},database:{host:"localhost",port:5432,database:"dbs_portal_test",username:"postgres",password:"password"},monitoring:{enabled:!1}})}}class Ke{constructor(e){this.options=e,this.options.method=this.options.method||"GET",this.options.timeout=this.options.timeout||1e4,this.options.retries=this.options.retries||3,this.options.retryDelay=this.options.retryDelay||1e3}name="remote";watchCallback;pollTimer;isWatching=!1;async load(){let e;for(let t=1;t<=this.options.retries;t++)try{return await this.fetchConfig()}catch(n){e=n instanceof Error?n:new Error(String(n)),t<this.options.retries&&await this.delay(this.options.retryDelay*t)}throw new Error(`Failed to load remote configuration after ${this.options.retries} attempts: ${e==null?void 0:e.message}`)}watch(e){this.options.pollInterval&&(this.watchCallback=e,this.isWatching=!0,this.pollTimer=setInterval(async()=>{if(this.isWatching&&this.watchCallback)try{const t=await this.load();this.watchCallback(t)}catch(t){console.error("Error polling remote configuration:",t)}},this.options.pollInterval))}unwatch(){this.pollTimer&&(clearInterval(this.pollTimer),this.pollTimer=void 0),this.isWatching=!1,this.watchCallback=void 0}async fetchConfig(){const e=this.buildHeaders(),t=new AbortController,n=setTimeout(()=>t.abort(),this.options.timeout);try{const l=await fetch(this.options.url,{method:this.options.method,headers:e,signal:t.signal});if(!l.ok)throw new Error(`HTTP ${l.status}: ${l.statusText}`);return await l.json()}finally{clearTimeout(n)}}buildHeaders(){const e={"Content-Type":"application/json",...this.options.headers};if(this.options.auth)switch(this.options.auth.type){case"bearer":this.options.auth.token&&(e.Authorization=`Bearer ${this.options.auth.token}`);break;case"basic":if(this.options.auth.username&&this.options.auth.password){const t=btoa(`${this.options.auth.username}:${this.options.auth.password}`);e.Authorization=`Basic ${t}`}break;case"api-key":if(this.options.auth.apiKey){const t=this.options.auth.apiKeyHeader||"X-API-Key";e[t]=this.options.auth.apiKey}break}return e}delay(e){return new Promise(t=>setTimeout(t,e))}static withBearerToken(e,t,n={}){return new Ke({...n,url:e,auth:{type:"bearer",token:t}})}static withApiKey(e,t,n={}){return new Ke({...n,url:e,auth:{type:"api-key",apiKey:t}})}static polling(e,t,n={}){return new Ke({...n,url:e,pollInterval:t})}}class ot{constructor(e){this.options=e,this.options.timeout=this.options.timeout||1e4,this.options.retries=this.options.retries||3,this.options.renewThreshold=this.options.renewThreshold||300}name="vault";clientToken;tokenExpiry;async load(){await this.authenticate();const e=await this.fetchSecrets();return this.mapSecretsToConfig(e)}async authenticate(){if(!(this.clientToken&&this.isTokenValid())){switch(this.options.auth.method){case"token":this.clientToken=this.options.auth.token;break;case"userpass":await this.authenticateUserPass();break;case"aws":await this.authenticateAWS();break;case"kubernetes":await this.authenticateKubernetes();break;default:throw new Error(`Unsuppo