cdk-insights 0.11.0 → 0.11.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config/config.generated.d.ts +1 -1
- package/dist/entry.js +2 -2
- package/dist/index.js +2 -2
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const API_URL = "https://
|
|
1
|
+
export declare const API_URL = "https://api.cdkinsights.dev/v1";
|
package/dist/entry.js
CHANGED
|
@@ -242,7 +242,7 @@ ${m.join(`
|
|
|
242
242
|
`,aMe=Wh.encode(Wu),cMe=2,ZP=class{constructor(t,r){let{escapeName:n}=this.constructor,s=I.isString(r),i=`Content-Disposition: form-data; name="${n(t)}"${!s&&r.name?`; filename="${n(r.name)}"`:""}${Wu}`;s?r=Wh.encode(String(r).replace(/\r?\n|\r\n?/g,Wu)):i+=`Content-Type: ${r.type||"application/octet-stream"}${Wu}`,this.headers=Wh.encode(i+Wu),this.contentLength=s?r.byteLength:r.size,this.size=this.headers.byteLength+this.contentLength+cMe,this.name=t,this.value=r}async*encode(){yield this.headers;let{value:t}=this;I.isTypedArray(t)?yield t:yield*zb(t),yield aMe}static escapeName(t){return String(t).replace(/[\r\n"]/g,r=>({"\r":"%0D","\n":"%0A",'"':"%22"})[r])}},uMe=(e,t,r)=>{let{tag:n="form-data-boundary",size:s=25,boundary:i=n+"-"+xt.generateString(s,oMe)}=r||{};if(!I.isFormData(e))throw TypeError("FormData instance required");if(i.length<1||i.length>70)throw Error("boundary must be 10-70 characters long");let o=Wh.encode("--"+i+Wu),a=Wh.encode("--"+i+"--"+Wu),c=a.byteLength,u=Array.from(e.entries()).map(([d,p])=>{let f=new ZP(d,p);return c+=f.size,f});c+=o.byteLength*u.length,c=I.toFiniteNumber(c);let l={"Content-Type":`multipart/form-data; boundary=${i}`};return Number.isFinite(c)&&(l["Content-Length"]=c),t&&t(l),JQ.Readable.from(async function*(){for(let d of u)yield o,yield*d.encode();yield a}())},ZQ=uMe;var YQ=A(require("stream"),1),YP=class extends YQ.default.Transform{__transform(t,r,n){this.push(t),n()}_transform(t,r,n){if(t.length!==0&&(this._transform=this.__transform,t[0]!==120)){let s=Buffer.alloc(2);s[0]=120,s[1]=156,this.push(s,r)}this.__transform(t,r,n)}},QQ=YP;var lMe=(e,t)=>I.isAsyncFn(e)?function(...r){let n=r.pop();e.apply(this,r).then(s=>{try{t?n(null,...t(s)):n(null,s)}catch(i){n(i)}},n)}:e,XQ=lMe;function dMe(e,t){e=e||10;let r=new Array(e),n=new Array(e),s=0,i=0,o;return t=t!==void 0?t:1e3,function(c){let u=Date.now(),l=n[i];o||(o=u),r[s]=c,n[s]=u;let d=i,p=0;for(;d!==s;)p+=r[d++],d=d%e;if(s=(s+1)%e,s===i&&(i=(i+1)%e),u-o<t)return;let f=l&&u-l;return f?Math.round(p*1e3/f):void 0}}var eX=dMe;function pMe(e,t){let r=0,n=1e3/t,s,i,o=(u,l=Date.now())=>{r=l,s=null,i&&(clearTimeout(i),i=null),e(...u)};return[(...u)=>{let l=Date.now(),d=l-r;d>=n?o(u,l):(s=u,i||(i=setTimeout(()=>{i=null,o(s)},n-d)))},()=>s&&o(s)]}var tX=pMe;var yo=(e,t,r=3)=>{let n=0,s=eX(50,250);return tX(i=>{let o=i.loaded,a=i.lengthComputable?i.total:void 0,c=o-n,u=s(c),l=o<=a;n=o;let d={loaded:o,total:a,progress:a?o/a:void 0,bytes:c,rate:u||void 0,estimated:u&&a&&l?(a-o)/u:void 0,event:i,lengthComputable:a!=null,[t?"download":"upload"]:!0};e(d)},r)},mp=(e,t)=>{let r=e!=null;return[n=>t[0]({lengthComputable:r,total:e,loaded:n}),t[1]]},hp=e=>(...t)=>I.asap(()=>e(...t));function QP(e){if(!e||typeof e!="string"||!e.startsWith("data:"))return 0;let t=e.indexOf(",");if(t<0)return 0;let r=e.slice(5,t),n=e.slice(t+1);if(/;base64/i.test(r)){let i=n.length,o=n.length;for(let p=0;p<o;p++)if(n.charCodeAt(p)===37&&p+2<o){let f=n.charCodeAt(p+1),m=n.charCodeAt(p+2);(f>=48&&f<=57||f>=65&&f<=70||f>=97&&f<=102)&&(m>=48&&m<=57||m>=65&&m<=70||m>=97&&m<=102)&&(i-=2,p+=2)}let a=0,c=o-1,u=p=>p>=2&&n.charCodeAt(p-2)===37&&n.charCodeAt(p-1)===51&&(n.charCodeAt(p)===68||n.charCodeAt(p)===100);c>=0&&(n.charCodeAt(c)===61?(a++,c--):u(c)&&(a++,c-=3)),a===1&&c>=0&&(n.charCodeAt(c)===61||u(c))&&a++;let d=Math.floor(i/4)*3-(a||0);return d>0?d:0}return Buffer.byteLength(n,"utf8")}var rX={flush:xo.default.constants.Z_SYNC_FLUSH,finishFlush:xo.default.constants.Z_SYNC_FLUSH},fMe={flush:xo.default.constants.BROTLI_OPERATION_FLUSH,finishFlush:xo.default.constants.BROTLI_OPERATION_FLUSH},nX=I.isFunction(xo.default.createBrotliDecompress),{http:mMe,https:hMe}=lX.default,gMe=/https:?/,sX=xt.protocols.map(e=>e+":"),iX=(e,[t,r])=>(e.on("end",r).on("error",r),t),XP=class{constructor(){this.sessions=Object.create(null)}getSession(t,r){r=Object.assign({sessionTimeout:1e3},r);let n=this.sessions[t];if(n){let l=n.length;for(let d=0;d<l;d++){let[p,f]=n[d];if(!p.destroyed&&!p.closed&&tR.default.isDeepStrictEqual(f,r))return p}}let s=eR.default.connect(t,r),i,o=()=>{if(i)return;i=!0;let l=n,d=l.length,p=d;for(;p--;)if(l[p][0]===s){d===1?delete this.sessions[t]:l.splice(p,1);return}},a=s.request,{sessionTimeout:c}=r;if(c!=null){let l,d=0;s.request=function(){let p=a.apply(this,arguments);return d++,l&&(clearTimeout(l),l=null),p.once("close",()=>{--d||(l=setTimeout(()=>{l=null,o()},c))}),p}}s.once("close",o);let u=[s,r];return n?n.push(u):n=this.sessions[t]=[u],s}},yMe=new XP;function vMe(e,t){e.beforeRedirects.proxy&&e.beforeRedirects.proxy(e),e.beforeRedirects.config&&e.beforeRedirects.config(e,t)}function pX(e,t,r){let n=t;if(!n&&n!==!1){let s=aX.default.getProxyForUrl(r);s&&(n=new URL(s))}if(n){if(n.username&&(n.auth=(n.username||"")+":"+(n.password||"")),n.auth){(n.auth.username||n.auth.password)&&(n.auth=(n.auth.username||"")+":"+(n.auth.password||""));let i=Buffer.from(n.auth,"utf8").toString("base64");e.headers["Proxy-Authorization"]="Basic "+i}e.headers.host=e.hostname+(e.port?":"+e.port:"");let s=n.hostname||n.host;e.hostname=s,e.host=s,e.port=n.port,e.path=r,n.protocol&&(e.protocol=n.protocol.includes(":")?n.protocol:`${n.protocol}:`)}e.beforeRedirects.proxy=function(i){pX(i,t,i.href)}}var xMe=typeof process<"u"&&I.kindOf(process)==="process",bMe=e=>new Promise((t,r)=>{let n,s,i=(c,u)=>{s||(s=!0,n&&n(c,u))},o=c=>{i(c),t(c)},a=c=>{i(c,!0),r(c)};e(o,a,c=>n=c).catch(a)}),SMe=({address:e,family:t})=>{if(!I.isString(e))throw TypeError("address must be a string");return{address:e,family:t||(e.indexOf(".")<0?6:4)}},oX=(e,t)=>SMe(I.isObject(e)?e:{address:e,family:t}),_Me={request(e,t){let r=e.protocol+"//"+e.hostname+":"+(e.port||80),{http2Options:n,headers:s}=e,i=yMe.getSession(r,n),{HTTP2_HEADER_SCHEME:o,HTTP2_HEADER_METHOD:a,HTTP2_HEADER_PATH:c,HTTP2_HEADER_STATUS:u}=eR.default.constants,l={[o]:e.protocol.replace(":",""),[a]:e.method,[c]:e.path};I.forEach(s,(p,f)=>{f.charAt(0)!==":"&&(l[f]=p)});let d=i.request(l);return d.once("response",p=>{let f=d;p=Object.assign({},p);let m=p[u];delete p[u],f.headers=p,f.statusCode=+m,t(f)}),d}},fX=xMe&&function(t){return bMe(async function(n,s,i){let{data:o,lookup:a,family:c,httpVersion:u=1,http2Options:l}=t,{responseType:d,responseEncoding:p}=t,f=t.method.toUpperCase(),m,g=!1,h;if(u=+u,Number.isNaN(u))throw TypeError(`Invalid protocol version: '${t.httpVersion}' is not a number`);if(u!==1&&u!==2)throw TypeError(`Unsupported protocol version '${u}'`);let x=u===2;if(a){let te=XQ(a,Q=>I.isArray(Q)?Q:[Q]);a=(Q,ce,rt)=>{te(Q,ce,(fe,Zt,Ce)=>{if(fe)return rt(fe);let ze=I.isArray(Zt)?Zt.map(_t=>oX(_t)):[oX(Zt,Ce)];ce.all?rt(fe,ze):rt(fe,ze[0].address,ze[0].family)})}}let v=new dX.EventEmitter;function D(te){try{v.emit("abort",!te||te.type?new Wn(null,t,h):te)}catch(Q){console.warn("emit error",Q)}}v.once("abort",s);let w=()=>{t.cancelToken&&t.cancelToken.unsubscribe(D),t.signal&&t.signal.removeEventListener("abort",D),v.removeAllListeners()};(t.cancelToken||t.signal)&&(t.cancelToken&&t.cancelToken.subscribe(D),t.signal&&(t.signal.aborted?D():t.signal.addEventListener("abort",D))),i((te,Q)=>{if(m=!0,Q){g=!0,w();return}let{data:ce}=te;if(ce instanceof vo.default.Readable||ce instanceof vo.default.Duplex){let rt=vo.default.finished(ce,()=>{rt(),w()})}else w()});let C=ju(t.baseURL,t.url,t.allowAbsoluteUrls),T=new URL(C,xt.hasBrowserEnv?xt.origin:void 0),L=T.protocol||sX[0];if(L==="data:"){if(t.maxContentLength>-1){let Q=String(t.url||C||"");if(QP(Q)>t.maxContentLength)return s(new he("maxContentLength size of "+t.maxContentLength+" exceeded",he.ERR_BAD_RESPONSE,t))}let te;if(f!=="GET")return Ai(n,s,{status:405,statusText:"method not allowed",headers:{},config:t});try{te=HP(t.url,d==="blob",{Blob:t.env&&t.env.Blob})}catch(Q){throw he.from(Q,he.ERR_BAD_REQUEST,t)}return d==="text"?(te=te.toString(p),(!p||p==="utf8")&&(te=I.stripBOM(te))):d==="stream"&&(te=vo.default.Readable.from(te)),Ai(n,s,{data:te,status:200,statusText:"OK",headers:new Gt,config:t})}if(sX.indexOf(L)===-1)return s(new he("Unsupported protocol "+L,he.ERR_BAD_REQUEST,t));let F=Gt.from(t.headers).normalize();F.set("User-Agent","axios/"+qu,!1);let{onUploadProgress:H,onDownloadProgress:W}=t,$=t.maxRate,G,q;if(I.isSpecCompliantForm(o)){let te=F.getContentType(/boundary=([-_\w\d]{10,70})/i);o=ZQ(o,Q=>{F.set(Q)},{tag:`axios-${qu}-boundary`,boundary:te&&te[1]||void 0})}else if(I.isFormData(o)&&I.isFunction(o.getHeaders)){if(F.set(o.getHeaders()),!F.hasContentLength())try{let te=await tR.default.promisify(o.getLength).call(o);Number.isFinite(te)&&te>=0&&F.setContentLength(te)}catch{}}else if(I.isBlob(o)||I.isFile(o))o.size&&F.setContentType(o.type||"application/octet-stream"),F.setContentLength(o.size||0),o=vo.default.Readable.from(zb(o));else if(o&&!I.isStream(o)){if(!Buffer.isBuffer(o))if(I.isArrayBuffer(o))o=Buffer.from(new Uint8Array(o));else if(I.isString(o))o=Buffer.from(o,"utf-8");else return s(new he("Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream",he.ERR_BAD_REQUEST,t));if(F.setContentLength(o.length,!1),t.maxBodyLength>-1&&o.length>t.maxBodyLength)return s(new he("Request body larger than maxBodyLength limit",he.ERR_BAD_REQUEST,t))}let z=I.toFiniteNumber(F.getContentLength());I.isArray($)?(G=$[0],q=$[1]):G=q=$,o&&(H||G)&&(I.isStream(o)||(o=vo.default.Readable.from(o,{objectMode:!1})),o=vo.default.pipeline([o,new JP({maxRate:I.toFiniteNumber(G)})],I.noop),H&&o.on("progress",iX(o,mp(z,yo(hp(H),!1,3)))));let O;if(t.auth){let te=t.auth.username||"",Q=t.auth.password||"";O=te+":"+Q}if(!O&&T.username){let te=T.username,Q=T.password;O=te+":"+Q}O&&F.delete("authorization");let j;try{j=Mu(T.pathname+T.search,t.params,t.paramsSerializer).replace(/^\?/,"")}catch(te){let Q=new Error(te.message);return Q.config=t,Q.url=t.url,Q.exists=!0,s(Q)}F.set("Accept-Encoding","gzip, compress, deflate"+(nX?", br":""),!1);let V={path:j,method:f,headers:F.toJSON(),agents:{http:t.httpAgent,https:t.httpsAgent},auth:O,protocol:L,family:c,beforeRedirect:vMe,beforeRedirects:{},http2Options:l};!I.isUndefined(a)&&(V.lookup=a),t.socketPath?V.socketPath=t.socketPath:(V.hostname=T.hostname.startsWith("[")?T.hostname.slice(1,-1):T.hostname,V.port=T.port,pX(V,t.proxy,L+"//"+T.hostname+(T.port?":"+T.port:"")+V.path));let ee,Le=gMe.test(V.protocol);if(V.agent=Le?t.httpsAgent:t.httpAgent,x?ee=_Me:t.transport?ee=t.transport:t.maxRedirects===0?ee=Le?uX.default:cX.default:(t.maxRedirects&&(V.maxRedirects=t.maxRedirects),t.beforeRedirect&&(V.beforeRedirects.config=t.beforeRedirect),ee=Le?hMe:mMe),t.maxBodyLength>-1?V.maxBodyLength=t.maxBodyLength:V.maxBodyLength=1/0,t.insecureHTTPParser&&(V.insecureHTTPParser=t.insecureHTTPParser),h=ee.request(V,function(Q){if(h.destroyed)return;let ce=[Q],rt=I.toFiniteNumber(Q.headers["content-length"]);if(W||q){let ze=new JP({maxRate:I.toFiniteNumber(q)});W&&ze.on("progress",iX(ze,mp(rt,yo(hp(W),!0,3)))),ce.push(ze)}let fe=Q,Zt=Q.req||h;if(t.decompress!==!1&&Q.headers["content-encoding"])switch((f==="HEAD"||Q.statusCode===204)&&delete Q.headers["content-encoding"],(Q.headers["content-encoding"]||"").toLowerCase()){case"gzip":case"x-gzip":case"compress":case"x-compress":ce.push(xo.default.createUnzip(rX)),delete Q.headers["content-encoding"];break;case"deflate":ce.push(new QQ),ce.push(xo.default.createUnzip(rX)),delete Q.headers["content-encoding"];break;case"br":nX&&(ce.push(xo.default.createBrotliDecompress(fMe)),delete Q.headers["content-encoding"])}fe=ce.length>1?vo.default.pipeline(ce,I.noop):ce[0];let Ce={status:Q.statusCode,statusText:Q.statusMessage,headers:new Gt(Q.headers),config:t,request:Zt};if(d==="stream")Ce.data=fe,Ai(n,s,Ce);else{let ze=[],_t=0;fe.on("data",function(et){ze.push(et),_t+=et.length,t.maxContentLength>-1&&_t>t.maxContentLength&&(g=!0,fe.destroy(),D(new he("maxContentLength size of "+t.maxContentLength+" exceeded",he.ERR_BAD_RESPONSE,t,Zt)))}),fe.on("aborted",function(){if(g)return;let et=new he("stream has been aborted",he.ERR_BAD_RESPONSE,t,Zt);fe.destroy(et),s(et)}),fe.on("error",function(et){h.destroyed||s(he.from(et,null,t,Zt))}),fe.on("end",function(){try{let et=ze.length===1?ze[0]:Buffer.concat(ze);d!=="arraybuffer"&&(et=et.toString(p),(!p||p==="utf8")&&(et=I.stripBOM(et))),Ce.data=et}catch(et){return s(he.from(et,null,t,Ce.request,Ce))}Ai(n,s,Ce)})}v.once("abort",ze=>{fe.destroyed||(fe.emit("error",ze),fe.destroy())})}),v.once("abort",te=>{h.close?h.close():h.destroy(te)}),h.on("error",function(Q){s(he.from(Q,null,t,h))}),h.on("socket",function(Q){Q.setKeepAlive(!0,1e3*60)}),t.timeout){let te=parseInt(t.timeout,10);if(Number.isNaN(te)){D(new he("error trying to parse `config.timeout` to int",he.ERR_BAD_OPTION_VALUE,t,h));return}h.setTimeout(te,function(){if(m)return;let ce=t.timeout?"timeout of "+t.timeout+"ms exceeded":"timeout exceeded",rt=t.transitional||ap;t.timeoutErrorMessage&&(ce=t.timeoutErrorMessage),D(new he(ce,rt.clarifyTimeoutError?he.ETIMEDOUT:he.ECONNABORTED,t,h))})}else h.setTimeout(0);if(I.isStream(o)){let te=!1,Q=!1;o.on("end",()=>{te=!0}),o.once("error",ce=>{Q=!0,h.destroy(ce)}),o.on("close",()=>{!te&&!Q&&D(new Wn("Request stream has been aborted",t,h))}),o.pipe(h)}else o&&h.write(o),h.end()})};var mX=xt.hasStandardBrowserEnv?((e,t)=>r=>(r=new URL(r,xt.origin),e.protocol===r.protocol&&e.host===r.host&&(t||e.port===r.port)))(new URL(xt.origin),xt.navigator&&/(msie|trident)/i.test(xt.navigator.userAgent)):()=>!0;var hX=xt.hasStandardBrowserEnv?{write(e,t,r,n,s,i,o){if(typeof document>"u")return;let a=[`${e}=${encodeURIComponent(t)}`];I.isNumber(r)&&a.push(`expires=${new Date(r).toUTCString()}`),I.isString(n)&&a.push(`path=${n}`),I.isString(s)&&a.push(`domain=${s}`),i===!0&&a.push("secure"),I.isString(o)&&a.push(`SameSite=${o}`),document.cookie=a.join("; ")},read(e){if(typeof document>"u")return null;let t=document.cookie.match(new RegExp("(?:^|; )"+e+"=([^;]*)"));return t?decodeURIComponent(t[1]):null},remove(e){this.write(e,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};var gX=e=>e instanceof Gt?{...e}:e;function Zs(e,t){t=t||{};let r={};function n(u,l,d,p){return I.isPlainObject(u)&&I.isPlainObject(l)?I.merge.call({caseless:p},u,l):I.isPlainObject(l)?I.merge({},l):I.isArray(l)?l.slice():l}function s(u,l,d,p){if(I.isUndefined(l)){if(!I.isUndefined(u))return n(void 0,u,d,p)}else return n(u,l,d,p)}function i(u,l){if(!I.isUndefined(l))return n(void 0,l)}function o(u,l){if(I.isUndefined(l)){if(!I.isUndefined(u))return n(void 0,u)}else return n(void 0,l)}function a(u,l,d){if(d in t)return n(u,l);if(d in e)return n(void 0,u)}let c={url:i,method:i,data:i,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,withXSRFToken:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:a,headers:(u,l,d)=>s(gX(u),gX(l),d,!0)};return I.forEach(Object.keys({...e,...t}),function(l){let d=c[l]||s,p=d(e[l],t[l],l);I.isUndefined(p)&&d!==a||(r[l]=p)}),r}var Gb=e=>{let t=Zs({},e),{data:r,withXSRFToken:n,xsrfHeaderName:s,xsrfCookieName:i,headers:o,auth:a}=t;if(t.headers=o=Gt.from(o),t.url=Mu(ju(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&o.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),I.isFormData(r)){if(xt.hasStandardBrowserEnv||xt.hasStandardBrowserWebWorkerEnv)o.setContentType(void 0);else if(I.isFunction(r.getHeaders)){let c=r.getHeaders(),u=["content-type","content-length"];Object.entries(c).forEach(([l,d])=>{u.includes(l.toLowerCase())&&o.set(l,d)})}}if(xt.hasStandardBrowserEnv&&(n&&I.isFunction(n)&&(n=n(t)),n||n!==!1&&mX(t.url))){let c=s&&i&&hX.read(i);c&&o.set(s,c)}return t};var CMe=typeof XMLHttpRequest<"u",yX=CMe&&function(e){return new Promise(function(r,n){let s=Gb(e),i=s.data,o=Gt.from(s.headers).normalize(),{responseType:a,onUploadProgress:c,onDownloadProgress:u}=s,l,d,p,f,m;function g(){f&&f(),m&&m(),s.cancelToken&&s.cancelToken.unsubscribe(l),s.signal&&s.signal.removeEventListener("abort",l)}let h=new XMLHttpRequest;h.open(s.method.toUpperCase(),s.url,!0),h.timeout=s.timeout;function x(){if(!h)return;let D=Gt.from("getAllResponseHeaders"in h&&h.getAllResponseHeaders()),C={data:!a||a==="text"||a==="json"?h.responseText:h.response,status:h.status,statusText:h.statusText,headers:D,config:e,request:h};Ai(function(L){r(L),g()},function(L){n(L),g()},C),h=null}"onloadend"in h?h.onloadend=x:h.onreadystatechange=function(){!h||h.readyState!==4||h.status===0&&!(h.responseURL&&h.responseURL.indexOf("file:")===0)||setTimeout(x)},h.onabort=function(){h&&(n(new he("Request aborted",he.ECONNABORTED,e,h)),h=null)},h.onerror=function(w){let C=w&&w.message?w.message:"Network Error",T=new he(C,he.ERR_NETWORK,e,h);T.event=w||null,n(T),h=null},h.ontimeout=function(){let w=s.timeout?"timeout of "+s.timeout+"ms exceeded":"timeout exceeded",C=s.transitional||ap;s.timeoutErrorMessage&&(w=s.timeoutErrorMessage),n(new he(w,C.clarifyTimeoutError?he.ETIMEDOUT:he.ECONNABORTED,e,h)),h=null},i===void 0&&o.setContentType(null),"setRequestHeader"in h&&I.forEach(o.toJSON(),function(w,C){h.setRequestHeader(C,w)}),I.isUndefined(s.withCredentials)||(h.withCredentials=!!s.withCredentials),a&&a!=="json"&&(h.responseType=s.responseType),u&&([p,m]=yo(u,!0),h.addEventListener("progress",p)),c&&h.upload&&([d,f]=yo(c),h.upload.addEventListener("progress",d),h.upload.addEventListener("loadend",f)),(s.cancelToken||s.signal)&&(l=D=>{h&&(n(!D||D.type?new Wn(null,e,h):D),h.abort(),h=null)},s.cancelToken&&s.cancelToken.subscribe(l),s.signal&&(s.signal.aborted?l():s.signal.addEventListener("abort",l)));let v=qh(s.url);if(v&&xt.protocols.indexOf(v)===-1){n(new he("Unsupported protocol "+v+":",he.ERR_BAD_REQUEST,e));return}h.send(i||null)})};var EMe=(e,t)=>{let{length:r}=e=e?e.filter(Boolean):[];if(t||r){let n=new AbortController,s,i=function(u){if(!s){s=!0,a();let l=u instanceof Error?u:this.reason;n.abort(l instanceof he?l:new Wn(l instanceof Error?l.message:l))}},o=t&&setTimeout(()=>{o=null,i(new he(`timeout ${t} of ms exceeded`,he.ETIMEDOUT))},t),a=()=>{e&&(o&&clearTimeout(o),o=null,e.forEach(u=>{u.unsubscribe?u.unsubscribe(i):u.removeEventListener("abort",i)}),e=null)};e.forEach(u=>u.addEventListener("abort",i));let{signal:c}=n;return c.unsubscribe=()=>I.asap(a),c}},vX=EMe;var DMe=function*(e,t){let r=e.byteLength;if(!t||r<t){yield e;return}let n=0,s;for(;n<r;)s=n+t,yield e.slice(n,s),n=s},wMe=async function*(e,t){for await(let r of AMe(e))yield*DMe(r,t)},AMe=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}let t=e.getReader();try{for(;;){let{done:r,value:n}=await t.read();if(r)break;yield n}}finally{await t.cancel()}},rR=(e,t,r,n)=>{let s=wMe(e,t),i=0,o,a=c=>{o||(o=!0,n&&n(c))};return new ReadableStream({async pull(c){try{let{done:u,value:l}=await s.next();if(u){a(),c.close();return}let d=l.byteLength;if(r){let p=i+=d;r(p)}c.enqueue(new Uint8Array(l))}catch(u){throw a(u),u}},cancel(c){return a(c),s.return()}},{highWaterMark:2})};var xX=64*1024,{isFunction:Hb}=I,TMe=(({Request:e,Response:t})=>({Request:e,Response:t}))(I.global),{ReadableStream:bX,TextEncoder:SX}=I.global,_X=(e,...t)=>{try{return!!e(...t)}catch{return!1}},IMe=e=>{e=I.merge.call({skipUndefined:!0},TMe,e);let{fetch:t,Request:r,Response:n}=e,s=t?Hb(t):typeof fetch=="function",i=Hb(r),o=Hb(n);if(!s)return!1;let a=s&&Hb(bX),c=s&&(typeof SX=="function"?(m=>g=>m.encode(g))(new SX):async m=>new Uint8Array(await new r(m).arrayBuffer())),u=i&&a&&_X(()=>{let m=!1,g=new r(xt.origin,{body:new bX,method:"POST",get duplex(){return m=!0,"half"}}).headers.has("Content-Type");return m&&!g}),l=o&&a&&_X(()=>I.isReadableStream(new n("").body)),d={stream:l&&(m=>m.body)};s&&["text","arrayBuffer","blob","formData","stream"].forEach(m=>{!d[m]&&(d[m]=(g,h)=>{let x=g&&g[m];if(x)return x.call(g);throw new he(`Response type '${m}' is not supported`,he.ERR_NOT_SUPPORT,h)})});let p=async m=>{if(m==null)return 0;if(I.isBlob(m))return m.size;if(I.isSpecCompliantForm(m))return(await new r(xt.origin,{method:"POST",body:m}).arrayBuffer()).byteLength;if(I.isArrayBufferView(m)||I.isArrayBuffer(m))return m.byteLength;if(I.isURLSearchParams(m)&&(m=m+""),I.isString(m))return(await c(m)).byteLength},f=async(m,g)=>{let h=I.toFiniteNumber(m.getContentLength());return h??p(g)};return async m=>{let{url:g,method:h,data:x,signal:v,cancelToken:D,timeout:w,onDownloadProgress:C,onUploadProgress:T,responseType:L,headers:F,withCredentials:H="same-origin",fetchOptions:W}=Gb(m),$=t||fetch;L=L?(L+"").toLowerCase():"text";let G=vX([v,D&&D.toAbortSignal()],w),q=null,z=G&&G.unsubscribe&&(()=>{G.unsubscribe()}),O;try{if(T&&u&&h!=="get"&&h!=="head"&&(O=await f(F,x))!==0){let Q=new r(g,{method:"POST",body:x,duplex:"half"}),ce;if(I.isFormData(x)&&(ce=Q.headers.get("content-type"))&&F.setContentType(ce),Q.body){let[rt,fe]=mp(O,yo(hp(T)));x=rR(Q.body,xX,rt,fe)}}I.isString(H)||(H=H?"include":"omit");let j=i&&"credentials"in r.prototype,V={...W,signal:G,method:h.toUpperCase(),headers:F.normalize().toJSON(),body:x,duplex:"half",credentials:j?H:void 0};q=i&&new r(g,V);let ee=await(i?$(q,W):$(g,V)),Le=l&&(L==="stream"||L==="response");if(l&&(C||Le&&z)){let Q={};["status","statusText","headers"].forEach(Zt=>{Q[Zt]=ee[Zt]});let ce=I.toFiniteNumber(ee.headers.get("content-length")),[rt,fe]=C&&mp(ce,yo(hp(C),!0))||[];ee=new n(rR(ee.body,xX,rt,()=>{fe&&fe(),z&&z()}),Q)}L=L||"text";let te=await d[I.findKey(d,L)||"text"](ee,m);return!Le&&z&&z(),await new Promise((Q,ce)=>{Ai(Q,ce,{data:te,headers:Gt.from(ee.headers),status:ee.status,statusText:ee.statusText,config:m,request:q})})}catch(j){throw z&&z(),j&&j.name==="TypeError"&&/Load failed|fetch/i.test(j.message)?Object.assign(new he("Network Error",he.ERR_NETWORK,m,q),{cause:j.cause||j}):he.from(j,j&&j.code,m,q)}}},PMe=new Map,nR=e=>{let t=e&&e.env||{},{fetch:r,Request:n,Response:s}=t,i=[n,s,r],o=i.length,a=o,c,u,l=PMe;for(;a--;)c=i[a],u=l.get(c),u===void 0&&l.set(c,u=a?new Map:IMe(t)),l=u;return u},H_t=nR();var sR={http:fX,xhr:yX,fetch:{get:nR}};I.forEach(sR,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});var CX=e=>`- ${e}`,FMe=e=>I.isFunction(e)||e===null||e===!1;function OMe(e,t){e=I.isArray(e)?e:[e];let{length:r}=e,n,s,i={};for(let o=0;o<r;o++){n=e[o];let a;if(s=n,!FMe(n)&&(s=sR[(a=String(n)).toLowerCase()],s===void 0))throw new he(`Unknown adapter '${a}'`);if(s&&(I.isFunction(s)||(s=s.get(t))))break;i[a||"#"+o]=s}if(!s){let o=Object.entries(i).map(([c,u])=>`adapter ${c} `+(u===!1?"is not supported by the environment":"is not available in the build")),a=r?o.length>1?`since :
|
|
243
243
|
`+o.map(CX).join(`
|
|
244
244
|
`):" "+CX(o[0]):"as no adapter specified";throw new he("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return s}var Vb={getAdapter:OMe,adapters:sR};function iR(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new Wn(null,e)}function Kb(e){return iR(e),e.headers=Gt.from(e.headers),e.data=Nh.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),Vb.getAdapter(e.adapter||cp.adapter,e)(e).then(function(n){return iR(e),n.data=Nh.call(e,e.transformResponse,n),n.headers=Gt.from(n.headers),n},function(n){return Mh(n)||(iR(e),n&&n.response&&(n.response.data=Nh.call(e,e.transformResponse,n.response),n.response.headers=Gt.from(n.response.headers))),Promise.reject(n)})}var Jb={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Jb[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}});var EX={};Jb.transitional=function(t,r,n){function s(i,o){return"[Axios v"+qu+"] Transitional option '"+i+"'"+o+(n?". "+n:"")}return(i,o,a)=>{if(t===!1)throw new he(s(o," has been removed"+(r?" in "+r:"")),he.ERR_DEPRECATED);return r&&!EX[o]&&(EX[o]=!0,console.warn(s(o," has been deprecated since v"+r+" and will be removed in the near future"))),t?t(i,o,a):!0}};Jb.spelling=function(t){return(r,n)=>(console.warn(`${n} is likely a misspelling of ${t}`),!0)};function kMe(e,t,r){if(typeof e!="object")throw new he("options must be an object",he.ERR_BAD_OPTION_VALUE);let n=Object.keys(e),s=n.length;for(;s-- >0;){let i=n[s],o=t[i];if(o){let a=e[i],c=a===void 0||o(a,i,e);if(c!==!0)throw new he("option "+i+" must be "+c,he.ERR_BAD_OPTION_VALUE);continue}if(r!==!0)throw new he("Unknown option "+i,he.ERR_BAD_OPTION)}}var zh={assertOptions:kMe,validators:Jb};var Ti=zh.validators,gp=class{constructor(t){this.defaults=t||{},this.interceptors={request:new bP,response:new bP}}async request(t,r){try{return await this._request(t,r)}catch(n){if(n instanceof Error){let s={};Error.captureStackTrace?Error.captureStackTrace(s):s=new Error;let i=s.stack?s.stack.replace(/^.+\n/,""):"";try{n.stack?i&&!String(n.stack).endsWith(i.replace(/^.+\n.+\n/,""))&&(n.stack+=`
|
|
245
|
-
`+i):n.stack=i}catch{}}throw n}}_request(t,r){typeof t=="string"?(r=r||{},r.url=t):r=t||{},r=Zs(this.defaults,r);let{transitional:n,paramsSerializer:s,headers:i}=r;n!==void 0&&zh.assertOptions(n,{silentJSONParsing:Ti.transitional(Ti.boolean),forcedJSONParsing:Ti.transitional(Ti.boolean),clarifyTimeoutError:Ti.transitional(Ti.boolean)},!1),s!=null&&(I.isFunction(s)?r.paramsSerializer={serialize:s}:zh.assertOptions(s,{encode:Ti.function,serialize:Ti.function},!0)),r.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?r.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:r.allowAbsoluteUrls=!0),zh.assertOptions(r,{baseUrl:Ti.spelling("baseURL"),withXsrfToken:Ti.spelling("withXSRFToken")},!0),r.method=(r.method||this.defaults.method||"get").toLowerCase();let o=i&&I.merge(i.common,i[r.method]);i&&I.forEach(["delete","get","head","post","put","patch","common"],m=>{delete i[m]}),r.headers=Gt.concat(o,i);let a=[],c=!0;this.interceptors.request.forEach(function(g){typeof g.runWhen=="function"&&g.runWhen(r)===!1||(c=c&&g.synchronous,a.unshift(g.fulfilled,g.rejected))});let u=[];this.interceptors.response.forEach(function(g){u.push(g.fulfilled,g.rejected)});let l,d=0,p;if(!c){let m=[Kb.bind(this),void 0];for(m.unshift(...a),m.push(...u),p=m.length,l=Promise.resolve(r);d<p;)l=l.then(m[d++],m[d++]);return l}p=a.length;let f=r;for(;d<p;){let m=a[d++],g=a[d++];try{f=m(f)}catch(h){g.call(this,h);break}}try{l=Kb.call(this,f)}catch(m){return Promise.reject(m)}for(d=0,p=u.length;d<p;)l=l.then(u[d++],u[d++]);return l}getUri(t){t=Zs(this.defaults,t);let r=ju(t.baseURL,t.url,t.allowAbsoluteUrls);return Mu(r,t.params,t.paramsSerializer)}};I.forEach(["delete","get","head","options"],function(t){gp.prototype[t]=function(r,n){return this.request(Zs(n||{},{method:t,url:r,data:(n||{}).data}))}});I.forEach(["post","put","patch"],function(t){function r(n){return function(i,o,a){return this.request(Zs(a||{},{method:t,headers:n?{"Content-Type":"multipart/form-data"}:{},url:i,data:o}))}}gp.prototype[t]=r(),gp.prototype[t+"Form"]=r(!0)});var Gh=gp;var oR=class e{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(i){r=i});let n=this;this.promise.then(s=>{if(!n._listeners)return;let i=n._listeners.length;for(;i-- >0;)n._listeners[i](s);n._listeners=null}),this.promise.then=s=>{let i,o=new Promise(a=>{n.subscribe(a),i=a}).then(s);return o.cancel=function(){n.unsubscribe(i)},o},t(function(i,o,a){n.reason||(n.reason=new Wn(i,o,a),r(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;let r=this._listeners.indexOf(t);r!==-1&&this._listeners.splice(r,1)}toAbortSignal(){let t=new AbortController,r=n=>{t.abort(n)};return this.subscribe(r),t.signal.unsubscribe=()=>this.unsubscribe(r),t.signal}static source(){let t;return{token:new e(function(s){t=s}),cancel:t}}},DX=oR;function aR(e){return function(r){return e.apply(null,r)}}function cR(e){return I.isObject(e)&&e.isAxiosError===!0}var uR={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(uR).forEach(([e,t])=>{uR[t]=e});var wX=uR;function AX(e){let t=new Gh(e),r=Ah(Gh.prototype.request,t);return I.extend(r,Gh.prototype,t,{allOwnKeys:!0}),I.extend(r,t,null,{allOwnKeys:!0}),r.create=function(s){return AX(Zs(e,s))},r}var fr=AX(cp);fr.Axios=Gh;fr.CanceledError=Wn;fr.CancelToken=DX;fr.isCancel=Mh;fr.VERSION=qu;fr.toFormData=Oa;fr.AxiosError=he;fr.Cancel=fr.CanceledError;fr.all=function(t){return Promise.all(t)};fr.spread=aR;fr.isAxiosError=cR;fr.mergeConfig=Zs;fr.AxiosHeaders=Gt;fr.formToJSON=e=>jb(I.isHTMLForm(e)?new FormData(e):e);fr.getAdapter=Vb.getAdapter;fr.HttpStatusCode=wX;fr.default=fr;var vs=fr;var{Axios:qCt,AxiosError:WCt,CanceledError:zCt,isCancel:GCt,CancelToken:HCt,VERSION:VCt,all:KCt,Cancel:JCt,isAxiosError:ZCt,spread:YCt,toFormData:QCt,AxiosHeaders:XCt,HttpStatusCode:eEt,formToJSON:tEt,getAdapter:rEt,mergeConfig:nEt}=vs;var lR=e=>{if(!e)return;let t=e.trim();if(t)return t.replace(/\/+$/,"")},Hh=e=>{let t=lR(e);return t||(lR("https://api.cdkinsights.dev/ai-analysis/v1")??"")},TX=e=>lR(e);var dR=pR.join(process.env.HOME||process.env.USERPROFILE||"",".cdk-insights"),zu=pR.join(dR,"auth-token.json"),PX=e=>{try{let t=e.split(".");return t.length!==3?null:JSON.parse(Buffer.from(t[1],"base64").toString())}catch{return null}},RX=e=>IX.createHash("sha256").update(e).digest("hex").slice(0,16),LMe=e=>{try{if(!cn.existsSync(zu))return null;let t=JSON.parse(cn.readFileSync(zu,"utf-8")),r=RX(e);if(t.licenseKeyHash!==r)return null;let n=PX(t.token),s=Math.floor(Date.now()/1e3),i=n?.exp||t.cachedAt+t.expiresIn;return s>=i?(cn.unlinkSync(zu),null):(Z.debug("Using cached auth token",{cachedAt:new Date(t.cachedAt*1e3).toISOString(),expiresAt:new Date(i*1e3).toISOString()}),t)}catch(t){return Z.debug("Failed to load cached auth token",{error:t instanceof Error?t.message:String(t)}),null}},NMe=(e,t,r)=>{try{cn.existsSync(dR)||cn.mkdirSync(dR,{recursive:!0});let n={token:e,licenseKeyHash:RX(t),cachedAt:Math.floor(Date.now()/1e3),expiresIn:r};cn.writeFileSync(zu,JSON.stringify(n),"utf-8"),process.platform!=="win32"&&cn.chmodSync(zu,384),Z.debug("Saved auth token to cache",{cachedAt:new Date(n.cachedAt*1e3).toISOString(),expiresIn:r})}catch(n){Z.debug("Failed to save auth token to cache",{error:n instanceof Error?n.message:String(n)})}};async function fR(e,t,r){let n=LMe(e);if(n){let o=Hh(),c=PX(n.token)?.fingerprint;return Z.info("\u2705 Using cached auth token",{hasToken:!0,hasJwtFingerprint:!!c,apiUrl:o}),{token:n.token,usageData:void 0,licenseInfo:void 0,fingerprint:c,apiUrl:o}}let s=Hh();if(!s){Z.error("\u274C No API endpoint configured for authentication");return}Z.info("\u{1F510} Starting authentication process",{apiUrl:s,hasLicenseKey:!!e,hasFingerprint:!!t,hasProject:!!r});let i=`${s}/login`;Z.info("\u{1F4E1} Making authentication request",{url:i,method:"POST",headers:{"x-cdk-insights-fingerprint":t?"[REDACTED]":"undefined","x-cdk-insights-client":"cli"},body:{licenseKey:e?"[REDACTED]":"undefined",project:r||"undefined"}});try{let{data:o}=await vs.post(i,{licenseKey:e,project:r},{headers:{"x-cdk-insights-fingerprint":t,"x-cdk-insights-client":"cli"},timeout:1e4});return Z.info("\u2705 Authentication successful",{hasToken:!!o.token,expiresIn:o.expiresIn,fingerprintStatus:o.fingerprintStatus,hasUsageData:!!o.usageData,hasLicenseInfo:!!o.licenseInfo,apiUrl:s}),NMe(o.token,e,o.expiresIn||3600),{token:o.token,usageData:o.usageData,licenseInfo:o.licenseInfo,fingerprint:o.fingerprint,apiUrl:s}}catch(o){let a=vs.isAxiosError(o)?o:void 0,c=TX(a?.config?.url?a.config.url.replace(/\/?login$/,""):s);if(Z.error("Authentication failed",{error:o instanceof Error?o.message:String(o),apiUrl:c}),a)if(a.code==="ECONNREFUSED")Z.error("Network error: Connection refused",{error:a.message,suggestion:"Check if the API server is running and accessible",apiUrl:c});else if(a.code==="ENOTFOUND")Z.error("Network error: Host not found",{error:a.message,apiUrl:c,suggestion:"Check if the API URL is correct"});else if(a.code==="ETIMEDOUT")Z.error("Network error: Request timed out",{error:a.message,suggestion:"The API server took too long to respond",apiUrl:c});else if(a.response){let u=a.response.status,l=a.response.data;Z.error(`HTTP ${u} error`,{status:u,apiUrl:c,error:l?.error||a.message,response:l}),u===401?Z.error("License key is invalid or expired",{status:u,apiUrl:c}):u===403?Z.error("License is already used in 3 environments",{status:u,apiUrl:c,fingerprints:l?.fingerprints}):u===404?Z.error("API endpoint not found",{status:u,apiUrl:c,suggestion:"Check if the API URL is correct"}):u>=500&&Z.error("Server error",{status:u,apiUrl:c,suggestion:"The API server may be experiencing issues"})}else Z.error("Network error",{error:a.message,apiUrl:c});else Z.error("Unexpected error",{error:o.message||String(o),apiUrl:c});return}}var Zb=()=>{try{cn.existsSync(zu)?(cn.unlinkSync(zu),Z.info("\u{1F5D1}\uFE0F Cleared auth token cache")):Z.info("\u2139\uFE0F No auth token cache to clear")}catch(e){Z.warn("Failed to clear auth token cache",{error:e instanceof Error?e.message:String(e)})}};var WX=require("node:events"),zX=require("node:fs"),yR=require("node:path"),GX=A(UD());var nr={};Xr(nr,{BRAND:()=>cje,DIRTY:()=>Gu,EMPTY_PATH:()=>UMe,INVALID:()=>Me,NEVER:()=>Hje,OK:()=>Yr,ParseStatus:()=>jr,Schema:()=>tt,ZodAny:()=>Ma,ZodArray:()=>Co,ZodBigInt:()=>Vu,ZodBoolean:()=>Ku,ZodBranded:()=>Kh,ZodCatch:()=>il,ZodDate:()=>Ju,ZodDefault:()=>sl,ZodDiscriminatedUnion:()=>Xb,ZodEffects:()=>Ss,ZodEnum:()=>rl,ZodError:()=>Cn,ZodFirstPartyTypeKind:()=>Be,ZodFunction:()=>tS,ZodIntersection:()=>Xu,ZodIssueCode:()=>X,ZodLazy:()=>el,ZodLiteral:()=>tl,ZodMap:()=>_p,ZodNaN:()=>Ep,ZodNativeEnum:()=>nl,ZodNever:()=>Ys,ZodNull:()=>Yu,ZodNullable:()=>Ri,ZodNumber:()=>Hu,ZodObject:()=>En,ZodOptional:()=>xs,ZodParsedType:()=>ve,ZodPipeline:()=>Jh,ZodPromise:()=>ja,ZodReadonly:()=>ol,ZodRecord:()=>eS,ZodSchema:()=>tt,ZodSet:()=>Cp,ZodString:()=>Na,ZodSymbol:()=>bp,ZodTransformer:()=>Ss,ZodTuple:()=>Pi,ZodType:()=>tt,ZodUndefined:()=>Zu,ZodUnion:()=>Qu,ZodUnknown:()=>_o,ZodVoid:()=>Sp,addIssueToContext:()=>ge,any:()=>yje,array:()=>Sje,bigint:()=>pje,boolean:()=>qX,coerce:()=>Gje,custom:()=>BX,date:()=>fje,datetimeRegex:()=>MX,defaultErrorMap:()=>bo,discriminatedUnion:()=>Dje,effect:()=>Mje,enum:()=>kje,function:()=>Rje,getErrorMap:()=>yp,getParsedType:()=>Ii,instanceof:()=>lje,intersection:()=>wje,isAborted:()=>Yb,isAsync:()=>vp,isDirty:()=>Qb,isValid:()=>La,late:()=>uje,lazy:()=>Fje,literal:()=>Oje,makeIssue:()=>Vh,map:()=>Ije,nan:()=>dje,nativeEnum:()=>Lje,never:()=>xje,null:()=>gje,nullable:()=>Bje,number:()=>$X,object:()=>_je,objectUtil:()=>mR,oboolean:()=>zje,onumber:()=>Wje,optional:()=>jje,ostring:()=>qje,pipeline:()=>$je,preprocess:()=>Uje,promise:()=>Nje,quotelessJson:()=>MMe,record:()=>Tje,set:()=>Pje,setErrorMap:()=>BMe,strictObject:()=>Cje,string:()=>UX,symbol:()=>mje,transformer:()=>Mje,tuple:()=>Aje,undefined:()=>hje,union:()=>Eje,unknown:()=>vje,util:()=>ct,void:()=>bje});var ct;(function(e){e.assertEqual=s=>{};function t(s){}e.assertIs=t;function r(s){throw new Error}e.assertNever=r,e.arrayToEnum=s=>{let i={};for(let o of s)i[o]=o;return i},e.getValidEnumValues=s=>{let i=e.objectKeys(s).filter(a=>typeof s[s[a]]!="number"),o={};for(let a of i)o[a]=s[a];return e.objectValues(o)},e.objectValues=s=>e.objectKeys(s).map(function(i){return s[i]}),e.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{let i=[];for(let o in s)Object.prototype.hasOwnProperty.call(s,o)&&i.push(o);return i},e.find=(s,i)=>{for(let o of s)if(i(o))return o},e.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&Number.isFinite(s)&&Math.floor(s)===s;function n(s,i=" | "){return s.map(o=>typeof o=="string"?`'${o}'`:o).join(i)}e.joinValues=n,e.jsonStringifyReplacer=(s,i)=>typeof i=="bigint"?i.toString():i})(ct||(ct={}));var mR;(function(e){e.mergeShapes=(t,r)=>({...t,...r})})(mR||(mR={}));var ve=ct.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Ii=e=>{switch(typeof e){case"undefined":return ve.undefined;case"string":return ve.string;case"number":return Number.isNaN(e)?ve.nan:ve.number;case"boolean":return ve.boolean;case"function":return ve.function;case"bigint":return ve.bigint;case"symbol":return ve.symbol;case"object":return Array.isArray(e)?ve.array:e===null?ve.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?ve.promise:typeof Map<"u"&&e instanceof Map?ve.map:typeof Set<"u"&&e instanceof Set?ve.set:typeof Date<"u"&&e instanceof Date?ve.date:ve.object;default:return ve.unknown}};var X=ct.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),MMe=e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:"),Cn=class e extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};let r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=t}format(t){let r=t||function(i){return i.message},n={_errors:[]},s=i=>{for(let o of i.issues)if(o.code==="invalid_union")o.unionErrors.map(s);else if(o.code==="invalid_return_type")s(o.returnTypeError);else if(o.code==="invalid_arguments")s(o.argumentsError);else if(o.path.length===0)n._errors.push(r(o));else{let a=n,c=0;for(;c<o.path.length;){let u=o.path[c];c===o.path.length-1?(a[u]=a[u]||{_errors:[]},a[u]._errors.push(r(o))):a[u]=a[u]||{_errors:[]},a=a[u],c++}}};return s(this),n}static assert(t){if(!(t instanceof e))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,ct.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=r=>r.message){let r={},n=[];for(let s of this.issues)if(s.path.length>0){let i=s.path[0];r[i]=r[i]||[],r[i].push(t(s))}else n.push(t(s));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}};Cn.create=e=>new Cn(e);var jMe=(e,t)=>{let r;switch(e.code){case X.invalid_type:e.received===ve.undefined?r="Required":r=`Expected ${e.expected}, received ${e.received}`;break;case X.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(e.expected,ct.jsonStringifyReplacer)}`;break;case X.unrecognized_keys:r=`Unrecognized key(s) in object: ${ct.joinValues(e.keys,", ")}`;break;case X.invalid_union:r="Invalid input";break;case X.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${ct.joinValues(e.options)}`;break;case X.invalid_enum_value:r=`Invalid enum value. Expected ${ct.joinValues(e.options)}, received '${e.received}'`;break;case X.invalid_arguments:r="Invalid function arguments";break;case X.invalid_return_type:r="Invalid function return type";break;case X.invalid_date:r="Invalid date";break;case X.invalid_string:typeof e.validation=="object"?"includes"in e.validation?(r=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?r=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?r=`Invalid input: must end with "${e.validation.endsWith}"`:ct.assertNever(e.validation):e.validation!=="regex"?r=`Invalid ${e.validation}`:r="Invalid";break;case X.too_small:e.type==="array"?r=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:e.type==="string"?r=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:e.type==="number"?r=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="bigint"?r=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="date"?r=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:r="Invalid input";break;case X.too_big:e.type==="array"?r=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:e.type==="string"?r=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:e.type==="number"?r=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="bigint"?r=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="date"?r=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:r="Invalid input";break;case X.custom:r="Invalid input";break;case X.invalid_intersection_types:r="Intersection results could not be merged";break;case X.not_multiple_of:r=`Number must be a multiple of ${e.multipleOf}`;break;case X.not_finite:r="Number must be finite";break;default:r=t.defaultError,ct.assertNever(e)}return{message:r}},bo=jMe;var FX=bo;function BMe(e){FX=e}function yp(){return FX}var Vh=e=>{let{data:t,path:r,errorMaps:n,issueData:s}=e,i=[...r,...s.path||[]],o={...s,path:i};if(s.message!==void 0)return{...s,path:i,message:s.message};let a="",c=n.filter(u=>!!u).slice().reverse();for(let u of c)a=u(o,{data:t,defaultError:a}).message;return{...s,path:i,message:a}},UMe=[];function ge(e,t){let r=yp(),n=Vh({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,r,r===bo?void 0:bo].filter(s=>!!s)});e.common.issues.push(n)}var jr=class e{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,r){let n=[];for(let s of r){if(s.status==="aborted")return Me;s.status==="dirty"&&t.dirty(),n.push(s.value)}return{status:t.value,value:n}}static async mergeObjectAsync(t,r){let n=[];for(let s of r){let i=await s.key,o=await s.value;n.push({key:i,value:o})}return e.mergeObjectSync(t,n)}static mergeObjectSync(t,r){let n={};for(let s of r){let{key:i,value:o}=s;if(i.status==="aborted"||o.status==="aborted")return Me;i.status==="dirty"&&t.dirty(),o.status==="dirty"&&t.dirty(),i.value!=="__proto__"&&(typeof o.value<"u"||s.alwaysSet)&&(n[i.value]=o.value)}return{status:t.value,value:n}}},Me=Object.freeze({status:"aborted"}),Gu=e=>({status:"dirty",value:e}),Yr=e=>({status:"valid",value:e}),Yb=e=>e.status==="aborted",Qb=e=>e.status==="dirty",La=e=>e.status==="valid",vp=e=>typeof Promise<"u"&&e instanceof Promise;var Ie;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t?.message})(Ie||(Ie={}));var bs=class{constructor(t,r,n,s){this._cachedPath=[],this.parent=t,this.data=r,this._path=n,this._key=s}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},OX=(e,t)=>{if(La(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let r=new Cn(e.common.issues);return this._error=r,this._error}}};function Ke(e){if(!e)return{};let{errorMap:t,invalid_type_error:r,required_error:n,description:s}=e;if(t&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:s}:{errorMap:(o,a)=>{let{message:c}=e;return o.code==="invalid_enum_value"?{message:c??a.defaultError}:typeof a.data>"u"?{message:c??n??a.defaultError}:o.code!=="invalid_type"?{message:a.defaultError}:{message:c??r??a.defaultError}},description:s}}var tt=class{get description(){return this._def.description}_getType(t){return Ii(t.data)}_getOrReturnCtx(t,r){return r||{common:t.parent.common,data:t.data,parsedType:Ii(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new jr,ctx:{common:t.parent.common,data:t.data,parsedType:Ii(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){let r=this._parse(t);if(vp(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(t){let r=this._parse(t);return Promise.resolve(r)}parse(t,r){let n=this.safeParse(t,r);if(n.success)return n.data;throw n.error}safeParse(t,r){let n={common:{issues:[],async:r?.async??!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Ii(t)},s=this._parseSync({data:t,path:n.path,parent:n});return OX(n,s)}"~validate"(t){let r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Ii(t)};if(!this["~standard"].async)try{let n=this._parseSync({data:t,path:[],parent:r});return La(n)?{value:n.value}:{issues:r.common.issues}}catch(n){n?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:r}).then(n=>La(n)?{value:n.value}:{issues:r.common.issues})}async parseAsync(t,r){let n=await this.safeParseAsync(t,r);if(n.success)return n.data;throw n.error}async safeParseAsync(t,r){let n={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Ii(t)},s=this._parse({data:t,path:n.path,parent:n}),i=await(vp(s)?s:Promise.resolve(s));return OX(n,i)}refine(t,r){let n=s=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(s):r;return this._refinement((s,i)=>{let o=t(s),a=()=>i.addIssue({code:X.custom,...n(s)});return typeof Promise<"u"&&o instanceof Promise?o.then(c=>c?!0:(a(),!1)):o?!0:(a(),!1)})}refinement(t,r){return this._refinement((n,s)=>t(n)?!0:(s.addIssue(typeof r=="function"?r(n,s):r),!1))}_refinement(t){return new Ss({schema:this,typeName:Be.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}constructor(t){this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:r=>this["~validate"](r)}}optional(){return xs.create(this,this._def)}nullable(){return Ri.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Co.create(this)}promise(){return ja.create(this,this._def)}or(t){return Qu.create([this,t],this._def)}and(t){return Xu.create(this,t,this._def)}transform(t){return new Ss({...Ke(this._def),schema:this,typeName:Be.ZodEffects,effect:{type:"transform",transform:t}})}default(t){let r=typeof t=="function"?t:()=>t;return new sl({...Ke(this._def),innerType:this,defaultValue:r,typeName:Be.ZodDefault})}brand(){return new Kh({typeName:Be.ZodBranded,type:this,...Ke(this._def)})}catch(t){let r=typeof t=="function"?t:()=>t;return new il({...Ke(this._def),innerType:this,catchValue:r,typeName:Be.ZodCatch})}describe(t){let r=this.constructor;return new r({...this._def,description:t})}pipe(t){return Jh.create(this,t)}readonly(){return ol.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},$Me=/^c[^\s-]{8,}$/i,qMe=/^[0-9a-z]+$/,WMe=/^[0-9A-HJKMNP-TV-Z]{26}$/i,zMe=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,GMe=/^[a-z0-9_-]{21}$/i,HMe=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,VMe=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,KMe=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,JMe="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",hR,ZMe=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,YMe=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,QMe=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,XMe=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,eje=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,tje=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,LX="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",rje=new RegExp(`^${LX}$`);function NX(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision==null&&(t=`${t}(\\.\\d+)?`);let r=e.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${r}`}function nje(e){return new RegExp(`^${NX(e)}$`)}function MX(e){let t=`${LX}T${NX(e)}`,r=[];return r.push(e.local?"Z?":"Z"),e.offset&&r.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${r.join("|")})`,new RegExp(`^${t}$`)}function sje(e,t){return!!((t==="v4"||!t)&&ZMe.test(e)||(t==="v6"||!t)&&QMe.test(e))}function ije(e,t){if(!HMe.test(e))return!1;try{let[r]=e.split(".");if(!r)return!1;let n=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),s=JSON.parse(atob(n));return!(typeof s!="object"||s===null||"typ"in s&&s?.typ!=="JWT"||!s.alg||t&&s.alg!==t)}catch{return!1}}function oje(e,t){return!!((t==="v4"||!t)&&YMe.test(e)||(t==="v6"||!t)&&XMe.test(e))}var Na=class e extends tt{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==ve.string){let i=this._getOrReturnCtx(t);return ge(i,{code:X.invalid_type,expected:ve.string,received:i.parsedType}),Me}let n=new jr,s;for(let i of this._def.checks)if(i.kind==="min")t.data.length<i.value&&(s=this._getOrReturnCtx(t,s),ge(s,{code:X.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="max")t.data.length>i.value&&(s=this._getOrReturnCtx(t,s),ge(s,{code:X.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="length"){let o=t.data.length>i.value,a=t.data.length<i.value;(o||a)&&(s=this._getOrReturnCtx(t,s),o?ge(s,{code:X.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):a&&ge(s,{code:X.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),n.dirty())}else if(i.kind==="email")KMe.test(t.data)||(s=this._getOrReturnCtx(t,s),ge(s,{validation:"email",code:X.invalid_string,message:i.message}),n.dirty());else if(i.kind==="emoji")hR||(hR=new RegExp(JMe,"u")),hR.test(t.data)||(s=this._getOrReturnCtx(t,s),ge(s,{validation:"emoji",code:X.invalid_string,message:i.message}),n.dirty());else if(i.kind==="uuid")zMe.test(t.data)||(s=this._getOrReturnCtx(t,s),ge(s,{validation:"uuid",code:X.invalid_string,message:i.message}),n.dirty());else if(i.kind==="nanoid")GMe.test(t.data)||(s=this._getOrReturnCtx(t,s),ge(s,{validation:"nanoid",code:X.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid")$Me.test(t.data)||(s=this._getOrReturnCtx(t,s),ge(s,{validation:"cuid",code:X.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid2")qMe.test(t.data)||(s=this._getOrReturnCtx(t,s),ge(s,{validation:"cuid2",code:X.invalid_string,message:i.message}),n.dirty());else if(i.kind==="ulid")WMe.test(t.data)||(s=this._getOrReturnCtx(t,s),ge(s,{validation:"ulid",code:X.invalid_string,message:i.message}),n.dirty());else if(i.kind==="url")try{new URL(t.data)}catch{s=this._getOrReturnCtx(t,s),ge(s,{validation:"url",code:X.invalid_string,message:i.message}),n.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(t.data)||(s=this._getOrReturnCtx(t,s),ge(s,{validation:"regex",code:X.invalid_string,message:i.message}),n.dirty())):i.kind==="trim"?t.data=t.data.trim():i.kind==="includes"?t.data.includes(i.value,i.position)||(s=this._getOrReturnCtx(t,s),ge(s,{code:X.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),n.dirty()):i.kind==="toLowerCase"?t.data=t.data.toLowerCase():i.kind==="toUpperCase"?t.data=t.data.toUpperCase():i.kind==="startsWith"?t.data.startsWith(i.value)||(s=this._getOrReturnCtx(t,s),ge(s,{code:X.invalid_string,validation:{startsWith:i.value},message:i.message}),n.dirty()):i.kind==="endsWith"?t.data.endsWith(i.value)||(s=this._getOrReturnCtx(t,s),ge(s,{code:X.invalid_string,validation:{endsWith:i.value},message:i.message}),n.dirty()):i.kind==="datetime"?MX(i).test(t.data)||(s=this._getOrReturnCtx(t,s),ge(s,{code:X.invalid_string,validation:"datetime",message:i.message}),n.dirty()):i.kind==="date"?rje.test(t.data)||(s=this._getOrReturnCtx(t,s),ge(s,{code:X.invalid_string,validation:"date",message:i.message}),n.dirty()):i.kind==="time"?nje(i).test(t.data)||(s=this._getOrReturnCtx(t,s),ge(s,{code:X.invalid_string,validation:"time",message:i.message}),n.dirty()):i.kind==="duration"?VMe.test(t.data)||(s=this._getOrReturnCtx(t,s),ge(s,{validation:"duration",code:X.invalid_string,message:i.message}),n.dirty()):i.kind==="ip"?sje(t.data,i.version)||(s=this._getOrReturnCtx(t,s),ge(s,{validation:"ip",code:X.invalid_string,message:i.message}),n.dirty()):i.kind==="jwt"?ije(t.data,i.alg)||(s=this._getOrReturnCtx(t,s),ge(s,{validation:"jwt",code:X.invalid_string,message:i.message}),n.dirty()):i.kind==="cidr"?oje(t.data,i.version)||(s=this._getOrReturnCtx(t,s),ge(s,{validation:"cidr",code:X.invalid_string,message:i.message}),n.dirty()):i.kind==="base64"?eje.test(t.data)||(s=this._getOrReturnCtx(t,s),ge(s,{validation:"base64",code:X.invalid_string,message:i.message}),n.dirty()):i.kind==="base64url"?tje.test(t.data)||(s=this._getOrReturnCtx(t,s),ge(s,{validation:"base64url",code:X.invalid_string,message:i.message}),n.dirty()):ct.assertNever(i);return{status:n.value,value:t.data}}_regex(t,r,n){return this.refinement(s=>t.test(s),{validation:r,code:X.invalid_string,...Ie.errToObj(n)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...Ie.errToObj(t)})}url(t){return this._addCheck({kind:"url",...Ie.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...Ie.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...Ie.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...Ie.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...Ie.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...Ie.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...Ie.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...Ie.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...Ie.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...Ie.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...Ie.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...Ie.errToObj(t)})}datetime(t){return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof t?.precision>"u"?null:t?.precision,offset:t?.offset??!1,local:t?.local??!1,...Ie.errToObj(t?.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof t?.precision>"u"?null:t?.precision,...Ie.errToObj(t?.message)})}duration(t){return this._addCheck({kind:"duration",...Ie.errToObj(t)})}regex(t,r){return this._addCheck({kind:"regex",regex:t,...Ie.errToObj(r)})}includes(t,r){return this._addCheck({kind:"includes",value:t,position:r?.position,...Ie.errToObj(r?.message)})}startsWith(t,r){return this._addCheck({kind:"startsWith",value:t,...Ie.errToObj(r)})}endsWith(t,r){return this._addCheck({kind:"endsWith",value:t,...Ie.errToObj(r)})}min(t,r){return this._addCheck({kind:"min",value:t,...Ie.errToObj(r)})}max(t,r){return this._addCheck({kind:"max",value:t,...Ie.errToObj(r)})}length(t,r){return this._addCheck({kind:"length",value:t,...Ie.errToObj(r)})}nonempty(t){return this.min(1,Ie.errToObj(t))}trim(){return new e({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new e({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new e({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isCIDR(){return!!this._def.checks.find(t=>t.kind==="cidr")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get isBase64url(){return!!this._def.checks.find(t=>t.kind==="base64url")}get minLength(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxLength(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}};Na.create=e=>new Na({checks:[],typeName:Be.ZodString,coerce:e?.coerce??!1,...Ke(e)});function aje(e,t){let r=(e.toString().split(".")[1]||"").length,n=(t.toString().split(".")[1]||"").length,s=r>n?r:n,i=Number.parseInt(e.toFixed(s).replace(".","")),o=Number.parseInt(t.toFixed(s).replace(".",""));return i%o/10**s}var Hu=class e extends tt{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==ve.number){let i=this._getOrReturnCtx(t);return ge(i,{code:X.invalid_type,expected:ve.number,received:i.parsedType}),Me}let n,s=new jr;for(let i of this._def.checks)i.kind==="int"?ct.isInteger(t.data)||(n=this._getOrReturnCtx(t,n),ge(n,{code:X.invalid_type,expected:"integer",received:"float",message:i.message}),s.dirty()):i.kind==="min"?(i.inclusive?t.data<i.value:t.data<=i.value)&&(n=this._getOrReturnCtx(t,n),ge(n,{code:X.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?t.data>i.value:t.data>=i.value)&&(n=this._getOrReturnCtx(t,n),ge(n,{code:X.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?aje(t.data,i.value)!==0&&(n=this._getOrReturnCtx(t,n),ge(n,{code:X.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(t.data)||(n=this._getOrReturnCtx(t,n),ge(n,{code:X.not_finite,message:i.message}),s.dirty()):ct.assertNever(i);return{status:s.value,value:t.data}}gte(t,r){return this.setLimit("min",t,!0,Ie.toString(r))}gt(t,r){return this.setLimit("min",t,!1,Ie.toString(r))}lte(t,r){return this.setLimit("max",t,!0,Ie.toString(r))}lt(t,r){return this.setLimit("max",t,!1,Ie.toString(r))}setLimit(t,r,n,s){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:n,message:Ie.toString(s)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:Ie.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Ie.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Ie.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Ie.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Ie.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:Ie.toString(r)})}finite(t){return this._addCheck({kind:"finite",message:Ie.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Ie.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Ie.toString(t)})}get minValue(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxValue(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&ct.isInteger(t.value))}get isFinite(){let t=null,r=null;for(let n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(t===null||n.value<t)&&(t=n.value)}return Number.isFinite(r)&&Number.isFinite(t)}};Hu.create=e=>new Hu({checks:[],typeName:Be.ZodNumber,coerce:e?.coerce||!1,...Ke(e)});var Vu=class e extends tt{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==ve.bigint)return this._getInvalidInput(t);let n,s=new jr;for(let i of this._def.checks)i.kind==="min"?(i.inclusive?t.data<i.value:t.data<=i.value)&&(n=this._getOrReturnCtx(t,n),ge(n,{code:X.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?t.data>i.value:t.data>=i.value)&&(n=this._getOrReturnCtx(t,n),ge(n,{code:X.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="multipleOf"?t.data%i.value!==BigInt(0)&&(n=this._getOrReturnCtx(t,n),ge(n,{code:X.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):ct.assertNever(i);return{status:s.value,value:t.data}}_getInvalidInput(t){let r=this._getOrReturnCtx(t);return ge(r,{code:X.invalid_type,expected:ve.bigint,received:r.parsedType}),Me}gte(t,r){return this.setLimit("min",t,!0,Ie.toString(r))}gt(t,r){return this.setLimit("min",t,!1,Ie.toString(r))}lte(t,r){return this.setLimit("max",t,!0,Ie.toString(r))}lt(t,r){return this.setLimit("max",t,!1,Ie.toString(r))}setLimit(t,r,n,s){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:n,message:Ie.toString(s)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Ie.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Ie.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Ie.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Ie.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:Ie.toString(r)})}get minValue(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxValue(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}};Vu.create=e=>new Vu({checks:[],typeName:Be.ZodBigInt,coerce:e?.coerce??!1,...Ke(e)});var Ku=class extends tt{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==ve.boolean){let n=this._getOrReturnCtx(t);return ge(n,{code:X.invalid_type,expected:ve.boolean,received:n.parsedType}),Me}return Yr(t.data)}};Ku.create=e=>new Ku({typeName:Be.ZodBoolean,coerce:e?.coerce||!1,...Ke(e)});var Ju=class e extends tt{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==ve.date){let i=this._getOrReturnCtx(t);return ge(i,{code:X.invalid_type,expected:ve.date,received:i.parsedType}),Me}if(Number.isNaN(t.data.getTime())){let i=this._getOrReturnCtx(t);return ge(i,{code:X.invalid_date}),Me}let n=new jr,s;for(let i of this._def.checks)i.kind==="min"?t.data.getTime()<i.value&&(s=this._getOrReturnCtx(t,s),ge(s,{code:X.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),n.dirty()):i.kind==="max"?t.data.getTime()>i.value&&(s=this._getOrReturnCtx(t,s),ge(s,{code:X.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),n.dirty()):ct.assertNever(i);return{status:n.value,value:new Date(t.data.getTime())}}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}min(t,r){return this._addCheck({kind:"min",value:t.getTime(),message:Ie.toString(r)})}max(t,r){return this._addCheck({kind:"max",value:t.getTime(),message:Ie.toString(r)})}get minDate(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t!=null?new Date(t):null}};Ju.create=e=>new Ju({checks:[],coerce:e?.coerce||!1,typeName:Be.ZodDate,...Ke(e)});var bp=class extends tt{_parse(t){if(this._getType(t)!==ve.symbol){let n=this._getOrReturnCtx(t);return ge(n,{code:X.invalid_type,expected:ve.symbol,received:n.parsedType}),Me}return Yr(t.data)}};bp.create=e=>new bp({typeName:Be.ZodSymbol,...Ke(e)});var Zu=class extends tt{_parse(t){if(this._getType(t)!==ve.undefined){let n=this._getOrReturnCtx(t);return ge(n,{code:X.invalid_type,expected:ve.undefined,received:n.parsedType}),Me}return Yr(t.data)}};Zu.create=e=>new Zu({typeName:Be.ZodUndefined,...Ke(e)});var Yu=class extends tt{_parse(t){if(this._getType(t)!==ve.null){let n=this._getOrReturnCtx(t);return ge(n,{code:X.invalid_type,expected:ve.null,received:n.parsedType}),Me}return Yr(t.data)}};Yu.create=e=>new Yu({typeName:Be.ZodNull,...Ke(e)});var Ma=class extends tt{constructor(){super(...arguments),this._any=!0}_parse(t){return Yr(t.data)}};Ma.create=e=>new Ma({typeName:Be.ZodAny,...Ke(e)});var _o=class extends tt{constructor(){super(...arguments),this._unknown=!0}_parse(t){return Yr(t.data)}};_o.create=e=>new _o({typeName:Be.ZodUnknown,...Ke(e)});var Ys=class extends tt{_parse(t){let r=this._getOrReturnCtx(t);return ge(r,{code:X.invalid_type,expected:ve.never,received:r.parsedType}),Me}};Ys.create=e=>new Ys({typeName:Be.ZodNever,...Ke(e)});var Sp=class extends tt{_parse(t){if(this._getType(t)!==ve.undefined){let n=this._getOrReturnCtx(t);return ge(n,{code:X.invalid_type,expected:ve.void,received:n.parsedType}),Me}return Yr(t.data)}};Sp.create=e=>new Sp({typeName:Be.ZodVoid,...Ke(e)});var Co=class e extends tt{_parse(t){let{ctx:r,status:n}=this._processInputParams(t),s=this._def;if(r.parsedType!==ve.array)return ge(r,{code:X.invalid_type,expected:ve.array,received:r.parsedType}),Me;if(s.exactLength!==null){let o=r.data.length>s.exactLength.value,a=r.data.length<s.exactLength.value;(o||a)&&(ge(r,{code:o?X.too_big:X.too_small,minimum:a?s.exactLength.value:void 0,maximum:o?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),n.dirty())}if(s.minLength!==null&&r.data.length<s.minLength.value&&(ge(r,{code:X.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),n.dirty()),s.maxLength!==null&&r.data.length>s.maxLength.value&&(ge(r,{code:X.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((o,a)=>s.type._parseAsync(new bs(r,o,r.path,a)))).then(o=>jr.mergeArray(n,o));let i=[...r.data].map((o,a)=>s.type._parseSync(new bs(r,o,r.path,a)));return jr.mergeArray(n,i)}get element(){return this._def.type}min(t,r){return new e({...this._def,minLength:{value:t,message:Ie.toString(r)}})}max(t,r){return new e({...this._def,maxLength:{value:t,message:Ie.toString(r)}})}length(t,r){return new e({...this._def,exactLength:{value:t,message:Ie.toString(r)}})}nonempty(t){return this.min(1,t)}};Co.create=(e,t)=>new Co({type:e,minLength:null,maxLength:null,exactLength:null,typeName:Be.ZodArray,...Ke(t)});function xp(e){if(e instanceof En){let t={};for(let r in e.shape){let n=e.shape[r];t[r]=xs.create(xp(n))}return new En({...e._def,shape:()=>t})}else return e instanceof Co?new Co({...e._def,type:xp(e.element)}):e instanceof xs?xs.create(xp(e.unwrap())):e instanceof Ri?Ri.create(xp(e.unwrap())):e instanceof Pi?Pi.create(e.items.map(t=>xp(t))):e}var En=class e extends tt{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let t=this._def.shape(),r=ct.objectKeys(t);return this._cached={shape:t,keys:r},this._cached}_parse(t){if(this._getType(t)!==ve.object){let u=this._getOrReturnCtx(t);return ge(u,{code:X.invalid_type,expected:ve.object,received:u.parsedType}),Me}let{status:n,ctx:s}=this._processInputParams(t),{shape:i,keys:o}=this._getCached(),a=[];if(!(this._def.catchall instanceof Ys&&this._def.unknownKeys==="strip"))for(let u in s.data)o.includes(u)||a.push(u);let c=[];for(let u of o){let l=i[u],d=s.data[u];c.push({key:{status:"valid",value:u},value:l._parse(new bs(s,d,s.path,u)),alwaysSet:u in s.data})}if(this._def.catchall instanceof Ys){let u=this._def.unknownKeys;if(u==="passthrough")for(let l of a)c.push({key:{status:"valid",value:l},value:{status:"valid",value:s.data[l]}});else if(u==="strict")a.length>0&&(ge(s,{code:X.unrecognized_keys,keys:a}),n.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let u=this._def.catchall;for(let l of a){let d=s.data[l];c.push({key:{status:"valid",value:l},value:u._parse(new bs(s,d,s.path,l)),alwaysSet:l in s.data})}}return s.common.async?Promise.resolve().then(async()=>{let u=[];for(let l of c){let d=await l.key,p=await l.value;u.push({key:d,value:p,alwaysSet:l.alwaysSet})}return u}).then(u=>jr.mergeObjectSync(n,u)):jr.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(t){return Ie.errToObj,new e({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(r,n)=>{let s=this._def.errorMap?.(r,n).message??n.defaultError;return r.code==="unrecognized_keys"?{message:Ie.errToObj(t).message??s}:{message:s}}}:{}})}strip(){return new e({...this._def,unknownKeys:"strip"})}passthrough(){return new e({...this._def,unknownKeys:"passthrough"})}extend(t){return new e({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new e({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:Be.ZodObject})}setKey(t,r){return this.augment({[t]:r})}catchall(t){return new e({...this._def,catchall:t})}pick(t){let r={};for(let n of ct.objectKeys(t))t[n]&&this.shape[n]&&(r[n]=this.shape[n]);return new e({...this._def,shape:()=>r})}omit(t){let r={};for(let n of ct.objectKeys(this.shape))t[n]||(r[n]=this.shape[n]);return new e({...this._def,shape:()=>r})}deepPartial(){return xp(this)}partial(t){let r={};for(let n of ct.objectKeys(this.shape)){let s=this.shape[n];t&&!t[n]?r[n]=s:r[n]=s.optional()}return new e({...this._def,shape:()=>r})}required(t){let r={};for(let n of ct.objectKeys(this.shape))if(t&&!t[n])r[n]=this.shape[n];else{let i=this.shape[n];for(;i instanceof xs;)i=i._def.innerType;r[n]=i}return new e({...this._def,shape:()=>r})}keyof(){return jX(ct.objectKeys(this.shape))}};En.create=(e,t)=>new En({shape:()=>e,unknownKeys:"strip",catchall:Ys.create(),typeName:Be.ZodObject,...Ke(t)});En.strictCreate=(e,t)=>new En({shape:()=>e,unknownKeys:"strict",catchall:Ys.create(),typeName:Be.ZodObject,...Ke(t)});En.lazycreate=(e,t)=>new En({shape:e,unknownKeys:"strip",catchall:Ys.create(),typeName:Be.ZodObject,...Ke(t)});var Qu=class extends tt{_parse(t){let{ctx:r}=this._processInputParams(t),n=this._def.options;function s(i){for(let a of i)if(a.result.status==="valid")return a.result;for(let a of i)if(a.result.status==="dirty")return r.common.issues.push(...a.ctx.common.issues),a.result;let o=i.map(a=>new Cn(a.ctx.common.issues));return ge(r,{code:X.invalid_union,unionErrors:o}),Me}if(r.common.async)return Promise.all(n.map(async i=>{let o={...r,common:{...r.common,issues:[]},parent:null};return{result:await i._parseAsync({data:r.data,path:r.path,parent:o}),ctx:o}})).then(s);{let i,o=[];for(let c of n){let u={...r,common:{...r.common,issues:[]},parent:null},l=c._parseSync({data:r.data,path:r.path,parent:u});if(l.status==="valid")return l;l.status==="dirty"&&!i&&(i={result:l,ctx:u}),u.common.issues.length&&o.push(u.common.issues)}if(i)return r.common.issues.push(...i.ctx.common.issues),i.result;let a=o.map(c=>new Cn(c));return ge(r,{code:X.invalid_union,unionErrors:a}),Me}}get options(){return this._def.options}};Qu.create=(e,t)=>new Qu({options:e,typeName:Be.ZodUnion,...Ke(t)});var So=e=>e instanceof el?So(e.schema):e instanceof Ss?So(e.innerType()):e instanceof tl?[e.value]:e instanceof rl?e.options:e instanceof nl?ct.objectValues(e.enum):e instanceof sl?So(e._def.innerType):e instanceof Zu?[void 0]:e instanceof Yu?[null]:e instanceof xs?[void 0,...So(e.unwrap())]:e instanceof Ri?[null,...So(e.unwrap())]:e instanceof Kh||e instanceof ol?So(e.unwrap()):e instanceof il?So(e._def.innerType):[],Xb=class e extends tt{_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==ve.object)return ge(r,{code:X.invalid_type,expected:ve.object,received:r.parsedType}),Me;let n=this.discriminator,s=r.data[n],i=this.optionsMap.get(s);return i?r.common.async?i._parseAsync({data:r.data,path:r.path,parent:r}):i._parseSync({data:r.data,path:r.path,parent:r}):(ge(r,{code:X.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),Me)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,r,n){let s=new Map;for(let i of r){let o=So(i.shape[t]);if(!o.length)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let a of o){if(s.has(a))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(a)}`);s.set(a,i)}}return new e({typeName:Be.ZodDiscriminatedUnion,discriminator:t,options:r,optionsMap:s,...Ke(n)})}};function gR(e,t){let r=Ii(e),n=Ii(t);if(e===t)return{valid:!0,data:e};if(r===ve.object&&n===ve.object){let s=ct.objectKeys(t),i=ct.objectKeys(e).filter(a=>s.indexOf(a)!==-1),o={...e,...t};for(let a of i){let c=gR(e[a],t[a]);if(!c.valid)return{valid:!1};o[a]=c.data}return{valid:!0,data:o}}else if(r===ve.array&&n===ve.array){if(e.length!==t.length)return{valid:!1};let s=[];for(let i=0;i<e.length;i++){let o=e[i],a=t[i],c=gR(o,a);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return r===ve.date&&n===ve.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}var Xu=class extends tt{_parse(t){let{status:r,ctx:n}=this._processInputParams(t),s=(i,o)=>{if(Yb(i)||Yb(o))return Me;let a=gR(i.value,o.value);return a.valid?((Qb(i)||Qb(o))&&r.dirty(),{status:r.value,value:a.data}):(ge(n,{code:X.invalid_intersection_types}),Me)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([i,o])=>s(i,o)):s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};Xu.create=(e,t,r)=>new Xu({left:e,right:t,typeName:Be.ZodIntersection,...Ke(r)});var Pi=class e extends tt{_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==ve.array)return ge(n,{code:X.invalid_type,expected:ve.array,received:n.parsedType}),Me;if(n.data.length<this._def.items.length)return ge(n,{code:X.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Me;!this._def.rest&&n.data.length>this._def.items.length&&(ge(n,{code:X.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let i=[...n.data].map((o,a)=>{let c=this._def.items[a]||this._def.rest;return c?c._parse(new bs(n,o,n.path,a)):null}).filter(o=>!!o);return n.common.async?Promise.all(i).then(o=>jr.mergeArray(r,o)):jr.mergeArray(r,i)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};Pi.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Pi({items:e,typeName:Be.ZodTuple,rest:null,...Ke(t)})};var eS=class e extends tt{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==ve.object)return ge(n,{code:X.invalid_type,expected:ve.object,received:n.parsedType}),Me;let s=[],i=this._def.keyType,o=this._def.valueType;for(let a in n.data)s.push({key:i._parse(new bs(n,a,n.path,a)),value:o._parse(new bs(n,n.data[a],n.path,a)),alwaysSet:a in n.data});return n.common.async?jr.mergeObjectAsync(r,s):jr.mergeObjectSync(r,s)}get element(){return this._def.valueType}static create(t,r,n){return r instanceof tt?new e({keyType:t,valueType:r,typeName:Be.ZodRecord,...Ke(n)}):new e({keyType:Na.create(),valueType:t,typeName:Be.ZodRecord,...Ke(r)})}},_p=class extends tt{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==ve.map)return ge(n,{code:X.invalid_type,expected:ve.map,received:n.parsedType}),Me;let s=this._def.keyType,i=this._def.valueType,o=[...n.data.entries()].map(([a,c],u)=>({key:s._parse(new bs(n,a,n.path,[u,"key"])),value:i._parse(new bs(n,c,n.path,[u,"value"]))}));if(n.common.async){let a=new Map;return Promise.resolve().then(async()=>{for(let c of o){let u=await c.key,l=await c.value;if(u.status==="aborted"||l.status==="aborted")return Me;(u.status==="dirty"||l.status==="dirty")&&r.dirty(),a.set(u.value,l.value)}return{status:r.value,value:a}})}else{let a=new Map;for(let c of o){let u=c.key,l=c.value;if(u.status==="aborted"||l.status==="aborted")return Me;(u.status==="dirty"||l.status==="dirty")&&r.dirty(),a.set(u.value,l.value)}return{status:r.value,value:a}}}};_p.create=(e,t,r)=>new _p({valueType:t,keyType:e,typeName:Be.ZodMap,...Ke(r)});var Cp=class e extends tt{_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==ve.set)return ge(n,{code:X.invalid_type,expected:ve.set,received:n.parsedType}),Me;let s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(ge(n,{code:X.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),r.dirty()),s.maxSize!==null&&n.data.size>s.maxSize.value&&(ge(n,{code:X.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),r.dirty());let i=this._def.valueType;function o(c){let u=new Set;for(let l of c){if(l.status==="aborted")return Me;l.status==="dirty"&&r.dirty(),u.add(l.value)}return{status:r.value,value:u}}let a=[...n.data.values()].map((c,u)=>i._parse(new bs(n,c,n.path,u)));return n.common.async?Promise.all(a).then(c=>o(c)):o(a)}min(t,r){return new e({...this._def,minSize:{value:t,message:Ie.toString(r)}})}max(t,r){return new e({...this._def,maxSize:{value:t,message:Ie.toString(r)}})}size(t,r){return this.min(t,r).max(t,r)}nonempty(t){return this.min(1,t)}};Cp.create=(e,t)=>new Cp({valueType:e,minSize:null,maxSize:null,typeName:Be.ZodSet,...Ke(t)});var tS=class e extends tt{constructor(){super(...arguments),this.validate=this.implement}_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==ve.function)return ge(r,{code:X.invalid_type,expected:ve.function,received:r.parsedType}),Me;function n(a,c){return Vh({data:a,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,yp(),bo].filter(u=>!!u),issueData:{code:X.invalid_arguments,argumentsError:c}})}function s(a,c){return Vh({data:a,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,yp(),bo].filter(u=>!!u),issueData:{code:X.invalid_return_type,returnTypeError:c}})}let i={errorMap:r.common.contextualErrorMap},o=r.data;if(this._def.returns instanceof ja){let a=this;return Yr(async function(...c){let u=new Cn([]),l=await a._def.args.parseAsync(c,i).catch(f=>{throw u.addIssue(n(c,f)),u}),d=await Reflect.apply(o,this,l);return await a._def.returns._def.type.parseAsync(d,i).catch(f=>{throw u.addIssue(s(d,f)),u})})}else{let a=this;return Yr(function(...c){let u=a._def.args.safeParse(c,i);if(!u.success)throw new Cn([n(c,u.error)]);let l=Reflect.apply(o,this,u.data),d=a._def.returns.safeParse(l,i);if(!d.success)throw new Cn([s(l,d.error)]);return d.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new e({...this._def,args:Pi.create(t).rest(_o.create())})}returns(t){return new e({...this._def,returns:t})}implement(t){return this.parse(t)}strictImplement(t){return this.parse(t)}static create(t,r,n){return new e({args:t||Pi.create([]).rest(_o.create()),returns:r||_o.create(),typeName:Be.ZodFunction,...Ke(n)})}},el=class extends tt{get schema(){return this._def.getter()}_parse(t){let{ctx:r}=this._processInputParams(t);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}};el.create=(e,t)=>new el({getter:e,typeName:Be.ZodLazy,...Ke(t)});var tl=class extends tt{_parse(t){if(t.data!==this._def.value){let r=this._getOrReturnCtx(t);return ge(r,{received:r.data,code:X.invalid_literal,expected:this._def.value}),Me}return{status:"valid",value:t.data}}get value(){return this._def.value}};tl.create=(e,t)=>new tl({value:e,typeName:Be.ZodLiteral,...Ke(t)});function jX(e,t){return new rl({values:e,typeName:Be.ZodEnum,...Ke(t)})}var rl=class e extends tt{_parse(t){if(typeof t.data!="string"){let r=this._getOrReturnCtx(t),n=this._def.values;return ge(r,{expected:ct.joinValues(n),received:r.parsedType,code:X.invalid_type}),Me}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){let r=this._getOrReturnCtx(t),n=this._def.values;return ge(r,{received:r.data,code:X.invalid_enum_value,options:n}),Me}return Yr(t.data)}get options(){return this._def.values}get enum(){let t={};for(let r of this._def.values)t[r]=r;return t}get Values(){let t={};for(let r of this._def.values)t[r]=r;return t}get Enum(){let t={};for(let r of this._def.values)t[r]=r;return t}extract(t,r=this._def){return e.create(t,{...this._def,...r})}exclude(t,r=this._def){return e.create(this.options.filter(n=>!t.includes(n)),{...this._def,...r})}};rl.create=jX;var nl=class extends tt{_parse(t){let r=ct.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(t);if(n.parsedType!==ve.string&&n.parsedType!==ve.number){let s=ct.objectValues(r);return ge(n,{expected:ct.joinValues(s),received:n.parsedType,code:X.invalid_type}),Me}if(this._cache||(this._cache=new Set(ct.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){let s=ct.objectValues(r);return ge(n,{received:n.data,code:X.invalid_enum_value,options:s}),Me}return Yr(t.data)}get enum(){return this._def.values}};nl.create=(e,t)=>new nl({values:e,typeName:Be.ZodNativeEnum,...Ke(t)});var ja=class extends tt{unwrap(){return this._def.type}_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==ve.promise&&r.common.async===!1)return ge(r,{code:X.invalid_type,expected:ve.promise,received:r.parsedType}),Me;let n=r.parsedType===ve.promise?r.data:Promise.resolve(r.data);return Yr(n.then(s=>this._def.type.parseAsync(s,{path:r.path,errorMap:r.common.contextualErrorMap})))}};ja.create=(e,t)=>new ja({type:e,typeName:Be.ZodPromise,...Ke(t)});var Ss=class extends tt{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Be.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){let{status:r,ctx:n}=this._processInputParams(t),s=this._def.effect||null,i={addIssue:o=>{ge(n,o),o.fatal?r.abort():r.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){let o=s.transform(n.data,i);if(n.common.async)return Promise.resolve(o).then(async a=>{if(r.value==="aborted")return Me;let c=await this._def.schema._parseAsync({data:a,path:n.path,parent:n});return c.status==="aborted"?Me:c.status==="dirty"?Gu(c.value):r.value==="dirty"?Gu(c.value):c});{if(r.value==="aborted")return Me;let a=this._def.schema._parseSync({data:o,path:n.path,parent:n});return a.status==="aborted"?Me:a.status==="dirty"?Gu(a.value):r.value==="dirty"?Gu(a.value):a}}if(s.type==="refinement"){let o=a=>{let c=s.refinement(a,i);if(n.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(n.common.async===!1){let a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?Me:(a.status==="dirty"&&r.dirty(),o(a.value),{status:r.value,value:a.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(a=>a.status==="aborted"?Me:(a.status==="dirty"&&r.dirty(),o(a.value).then(()=>({status:r.value,value:a.value}))))}if(s.type==="transform")if(n.common.async===!1){let o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!La(o))return Me;let a=s.transform(o.value,i);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:a}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>La(o)?Promise.resolve(s.transform(o.value,i)).then(a=>({status:r.value,value:a})):Me);ct.assertNever(s)}};Ss.create=(e,t,r)=>new Ss({schema:e,typeName:Be.ZodEffects,effect:t,...Ke(r)});Ss.createWithPreprocess=(e,t,r)=>new Ss({schema:t,effect:{type:"preprocess",transform:e},typeName:Be.ZodEffects,...Ke(r)});var xs=class extends tt{_parse(t){return this._getType(t)===ve.undefined?Yr(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};xs.create=(e,t)=>new xs({innerType:e,typeName:Be.ZodOptional,...Ke(t)});var Ri=class extends tt{_parse(t){return this._getType(t)===ve.null?Yr(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};Ri.create=(e,t)=>new Ri({innerType:e,typeName:Be.ZodNullable,...Ke(t)});var sl=class extends tt{_parse(t){let{ctx:r}=this._processInputParams(t),n=r.data;return r.parsedType===ve.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};sl.create=(e,t)=>new sl({innerType:e,typeName:Be.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...Ke(t)});var il=class extends tt{_parse(t){let{ctx:r}=this._processInputParams(t),n={...r,common:{...r.common,issues:[]}},s=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return vp(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Cn(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Cn(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};il.create=(e,t)=>new il({innerType:e,typeName:Be.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...Ke(t)});var Ep=class extends tt{_parse(t){if(this._getType(t)!==ve.nan){let n=this._getOrReturnCtx(t);return ge(n,{code:X.invalid_type,expected:ve.nan,received:n.parsedType}),Me}return{status:"valid",value:t.data}}};Ep.create=e=>new Ep({typeName:Be.ZodNaN,...Ke(e)});var cje=Symbol("zod_brand"),Kh=class extends tt{_parse(t){let{ctx:r}=this._processInputParams(t),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}},Jh=class e extends tt{_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.common.async)return(async()=>{let i=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?Me:i.status==="dirty"?(r.dirty(),Gu(i.value)):this._def.out._parseAsync({data:i.value,path:n.path,parent:n})})();{let s=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?Me:s.status==="dirty"?(r.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:n.path,parent:n})}}static create(t,r){return new e({in:t,out:r,typeName:Be.ZodPipeline})}},ol=class extends tt{_parse(t){let r=this._def.innerType._parse(t),n=s=>(La(s)&&(s.value=Object.freeze(s.value)),s);return vp(r)?r.then(s=>n(s)):n(r)}unwrap(){return this._def.innerType}};ol.create=(e,t)=>new ol({innerType:e,typeName:Be.ZodReadonly,...Ke(t)});function kX(e,t){let r=typeof e=="function"?e(t):typeof e=="string"?{message:e}:e;return typeof r=="string"?{message:r}:r}function BX(e,t={},r){return e?Ma.create().superRefine((n,s)=>{let i=e(n);if(i instanceof Promise)return i.then(o=>{if(!o){let a=kX(t,n),c=a.fatal??r??!0;s.addIssue({code:"custom",...a,fatal:c})}});if(!i){let o=kX(t,n),a=o.fatal??r??!0;s.addIssue({code:"custom",...o,fatal:a})}}):Ma.create()}var uje={object:En.lazycreate},Be;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(Be||(Be={}));var lje=(e,t={message:`Input not instance of ${e.name}`})=>BX(r=>r instanceof e,t),UX=Na.create,$X=Hu.create,dje=Ep.create,pje=Vu.create,qX=Ku.create,fje=Ju.create,mje=bp.create,hje=Zu.create,gje=Yu.create,yje=Ma.create,vje=_o.create,xje=Ys.create,bje=Sp.create,Sje=Co.create,_je=En.create,Cje=En.strictCreate,Eje=Qu.create,Dje=Xb.create,wje=Xu.create,Aje=Pi.create,Tje=eS.create,Ije=_p.create,Pje=Cp.create,Rje=tS.create,Fje=el.create,Oje=tl.create,kje=rl.create,Lje=nl.create,Nje=ja.create,Mje=Ss.create,jje=xs.create,Bje=Ri.create,Uje=Ss.createWithPreprocess,$je=Jh.create,qje=()=>UX().optional(),Wje=()=>$X().optional(),zje=()=>qX().optional(),Gje={string:e=>Na.create({...e,coerce:!0}),number:e=>Hu.create({...e,coerce:!0}),boolean:e=>Ku.create({...e,coerce:!0}),bigint:e=>Vu.create({...e,coerce:!0}),date:e=>Ju.create({...e,coerce:!0})};var Hje=Me;var Zh=class extends Error{constructor(t,r=[],n=[],s=void 0){super(t),this.name="EnvironmentValidationError",this.missingVars=r,this.invalidVars=n,this.context=s}},Yh=class e extends WX.EventEmitter{constructor(t,r={}){super(),this.watchers=[],this.lastConfigHash="",this.schema=t,this.options={loadEnvFiles:!0,validateStartup:!1,envFiles:[".env",".env.local"],watchFiles:!1,watchInterval:5e3,hotReload:!1,suppressWarnings:!1,...r},this.loadEnvironmentFiles(),this.config=this.validateEnvironment(t),this.lastConfigHash=this.getConfigHash(),this.options.validateStartup&&this.validateStartup(),(this.options.hotReload||this.options.watchFiles)&&this.startWatching()}static getInstance(t,r){return e.instance||(e.instance=new e(t,r)),e.instance}startWatching(){if(this.options.envFiles){for(let t of this.options.envFiles){let r=(0,yR.resolve)(process.cwd(),t);try{let n=(0,zX.watch)(r,s=>{s==="change"&&this.handleFileChange(t)});this.watchers.push({path:r,watcher:n})}catch(n){this.options.suppressWarnings||console.warn(`Warning: Could not watch ${t}: ${n}`)}}this.options.watchInterval&&this.options.watchInterval>0&&(this.reloadTimer=setInterval(()=>{this.checkForChanges()},this.options.watchInterval))}}handleFileChange(t){console.log(`\u{1F504} Configuration file changed: ${t}`),this.reloadConfiguration()}checkForChanges(){this.getConfigHash()!==this.lastConfigHash&&(console.log("\u{1F504} Configuration change detected"),this.reloadConfiguration())}getConfigHash(){return JSON.stringify(this.config)}reloadConfiguration(){let t={...this.config};try{this.loadEnvironmentFiles(),this.config=this.validateEnvironment(this.schema),this.lastConfigHash=this.getConfigHash(),this.emitConfigChanges(t,this.config),console.log("\u2705 Configuration reloaded successfully")}catch(r){console.error("\u274C Failed to reload configuration:",r),this.emit("configReloadError",r)}}emitConfigChanges(t,r){let n=new Set([...Object.keys(t),...Object.keys(r)]);for(let s of n){let i=t[s],o=r[s];if(i!==o){let a={type:i===void 0?"added":o===void 0?"removed":"modified",variable:s,oldValue:i,newValue:o,timestamp:new Date};this.emit("configChanged",a),this.emit(`configChanged:${s}`,a)}}this.emit("configReloaded",{oldConfig:t,newConfig:r,timestamp:new Date})}stopWatching(){for(let{watcher:t}of this.watchers)t.close();this.watchers=[],this.reloadTimer&&(clearInterval(this.reloadTimer),this.reloadTimer=void 0)}reload(){this.reloadConfiguration()}loadEnvironmentFiles(){if(!(!this.options.loadEnvFiles||!this.options.envFiles))for(let t of this.options.envFiles)try{let r=(0,GX.config)({path:(0,yR.resolve)(process.cwd(),t)});r.error&&!this.options.suppressWarnings&&console.warn(`Warning: Could not load ${t}: ${r.error.message}`)}catch(r){if(r instanceof Error&&r.message.includes("ENOENT"))continue;this.options.suppressWarnings||console.warn(`Warning: Error loading ${t}: ${r}`)}}get(t){return this.config[t]}getRequired(t,r){let n=this.config[t];if(n==null){let s=r?` for ${r}`:"";throw new Zh(`${String(t)} environment variable is required${s}`,[String(t)],[],r)}return n}getAll(){return{...this.config}}validateStartup(){if(this.schema)try{this.schema.parse(process.env)}catch(t){if(t instanceof nr.ZodError){let r=[],n=[];for(let o of t.errors){let a=o.path.join("."),c=process.env[a]||"undefined";o.code==="invalid_type"&&o.received==="undefined"?r.push(a):n.push({name:a,value:c,expected:"valid value",received:o.message||"invalid value"})}let s=r.length>0?`
|
|
245
|
+
`+i):n.stack=i}catch{}}throw n}}_request(t,r){typeof t=="string"?(r=r||{},r.url=t):r=t||{},r=Zs(this.defaults,r);let{transitional:n,paramsSerializer:s,headers:i}=r;n!==void 0&&zh.assertOptions(n,{silentJSONParsing:Ti.transitional(Ti.boolean),forcedJSONParsing:Ti.transitional(Ti.boolean),clarifyTimeoutError:Ti.transitional(Ti.boolean)},!1),s!=null&&(I.isFunction(s)?r.paramsSerializer={serialize:s}:zh.assertOptions(s,{encode:Ti.function,serialize:Ti.function},!0)),r.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?r.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:r.allowAbsoluteUrls=!0),zh.assertOptions(r,{baseUrl:Ti.spelling("baseURL"),withXsrfToken:Ti.spelling("withXSRFToken")},!0),r.method=(r.method||this.defaults.method||"get").toLowerCase();let o=i&&I.merge(i.common,i[r.method]);i&&I.forEach(["delete","get","head","post","put","patch","common"],m=>{delete i[m]}),r.headers=Gt.concat(o,i);let a=[],c=!0;this.interceptors.request.forEach(function(g){typeof g.runWhen=="function"&&g.runWhen(r)===!1||(c=c&&g.synchronous,a.unshift(g.fulfilled,g.rejected))});let u=[];this.interceptors.response.forEach(function(g){u.push(g.fulfilled,g.rejected)});let l,d=0,p;if(!c){let m=[Kb.bind(this),void 0];for(m.unshift(...a),m.push(...u),p=m.length,l=Promise.resolve(r);d<p;)l=l.then(m[d++],m[d++]);return l}p=a.length;let f=r;for(;d<p;){let m=a[d++],g=a[d++];try{f=m(f)}catch(h){g.call(this,h);break}}try{l=Kb.call(this,f)}catch(m){return Promise.reject(m)}for(d=0,p=u.length;d<p;)l=l.then(u[d++],u[d++]);return l}getUri(t){t=Zs(this.defaults,t);let r=ju(t.baseURL,t.url,t.allowAbsoluteUrls);return Mu(r,t.params,t.paramsSerializer)}};I.forEach(["delete","get","head","options"],function(t){gp.prototype[t]=function(r,n){return this.request(Zs(n||{},{method:t,url:r,data:(n||{}).data}))}});I.forEach(["post","put","patch"],function(t){function r(n){return function(i,o,a){return this.request(Zs(a||{},{method:t,headers:n?{"Content-Type":"multipart/form-data"}:{},url:i,data:o}))}}gp.prototype[t]=r(),gp.prototype[t+"Form"]=r(!0)});var Gh=gp;var oR=class e{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(i){r=i});let n=this;this.promise.then(s=>{if(!n._listeners)return;let i=n._listeners.length;for(;i-- >0;)n._listeners[i](s);n._listeners=null}),this.promise.then=s=>{let i,o=new Promise(a=>{n.subscribe(a),i=a}).then(s);return o.cancel=function(){n.unsubscribe(i)},o},t(function(i,o,a){n.reason||(n.reason=new Wn(i,o,a),r(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;let r=this._listeners.indexOf(t);r!==-1&&this._listeners.splice(r,1)}toAbortSignal(){let t=new AbortController,r=n=>{t.abort(n)};return this.subscribe(r),t.signal.unsubscribe=()=>this.unsubscribe(r),t.signal}static source(){let t;return{token:new e(function(s){t=s}),cancel:t}}},DX=oR;function aR(e){return function(r){return e.apply(null,r)}}function cR(e){return I.isObject(e)&&e.isAxiosError===!0}var uR={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(uR).forEach(([e,t])=>{uR[t]=e});var wX=uR;function AX(e){let t=new Gh(e),r=Ah(Gh.prototype.request,t);return I.extend(r,Gh.prototype,t,{allOwnKeys:!0}),I.extend(r,t,null,{allOwnKeys:!0}),r.create=function(s){return AX(Zs(e,s))},r}var fr=AX(cp);fr.Axios=Gh;fr.CanceledError=Wn;fr.CancelToken=DX;fr.isCancel=Mh;fr.VERSION=qu;fr.toFormData=Oa;fr.AxiosError=he;fr.Cancel=fr.CanceledError;fr.all=function(t){return Promise.all(t)};fr.spread=aR;fr.isAxiosError=cR;fr.mergeConfig=Zs;fr.AxiosHeaders=Gt;fr.formToJSON=e=>jb(I.isHTMLForm(e)?new FormData(e):e);fr.getAdapter=Vb.getAdapter;fr.HttpStatusCode=wX;fr.default=fr;var vs=fr;var{Axios:qCt,AxiosError:WCt,CanceledError:zCt,isCancel:GCt,CancelToken:HCt,VERSION:VCt,all:KCt,Cancel:JCt,isAxiosError:ZCt,spread:YCt,toFormData:QCt,AxiosHeaders:XCt,HttpStatusCode:eEt,formToJSON:tEt,getAdapter:rEt,mergeConfig:nEt}=vs;var lR=e=>{if(!e)return;let t=e.trim();if(t)return t.replace(/\/+$/,"")},Hh=e=>{let t=lR(e);return t||(lR("https://api.cdkinsights.dev/v1")??"")},TX=e=>lR(e);var dR=pR.join(process.env.HOME||process.env.USERPROFILE||"",".cdk-insights"),zu=pR.join(dR,"auth-token.json"),PX=e=>{try{let t=e.split(".");return t.length!==3?null:JSON.parse(Buffer.from(t[1],"base64").toString())}catch{return null}},RX=e=>IX.createHash("sha256").update(e).digest("hex").slice(0,16),LMe=e=>{try{if(!cn.existsSync(zu))return null;let t=JSON.parse(cn.readFileSync(zu,"utf-8")),r=RX(e);if(t.licenseKeyHash!==r)return null;let n=PX(t.token),s=Math.floor(Date.now()/1e3),i=n?.exp||t.cachedAt+t.expiresIn;return s>=i?(cn.unlinkSync(zu),null):(Z.debug("Using cached auth token",{cachedAt:new Date(t.cachedAt*1e3).toISOString(),expiresAt:new Date(i*1e3).toISOString()}),t)}catch(t){return Z.debug("Failed to load cached auth token",{error:t instanceof Error?t.message:String(t)}),null}},NMe=(e,t,r)=>{try{cn.existsSync(dR)||cn.mkdirSync(dR,{recursive:!0});let n={token:e,licenseKeyHash:RX(t),cachedAt:Math.floor(Date.now()/1e3),expiresIn:r};cn.writeFileSync(zu,JSON.stringify(n),"utf-8"),process.platform!=="win32"&&cn.chmodSync(zu,384),Z.debug("Saved auth token to cache",{cachedAt:new Date(n.cachedAt*1e3).toISOString(),expiresIn:r})}catch(n){Z.debug("Failed to save auth token to cache",{error:n instanceof Error?n.message:String(n)})}};async function fR(e,t,r){let n=LMe(e);if(n){let o=Hh(),c=PX(n.token)?.fingerprint;return Z.info("\u2705 Using cached auth token",{hasToken:!0,hasJwtFingerprint:!!c,apiUrl:o}),{token:n.token,usageData:void 0,licenseInfo:void 0,fingerprint:c,apiUrl:o}}let s=Hh();if(!s){Z.error("\u274C No API endpoint configured for authentication");return}Z.info("\u{1F510} Starting authentication process",{apiUrl:s,hasLicenseKey:!!e,hasFingerprint:!!t,hasProject:!!r});let i=`${s}/login`;Z.info("\u{1F4E1} Making authentication request",{url:i,method:"POST",headers:{"x-cdk-insights-fingerprint":t?"[REDACTED]":"undefined","x-cdk-insights-client":"cli"},body:{licenseKey:e?"[REDACTED]":"undefined",project:r||"undefined"}});try{let{data:o}=await vs.post(i,{licenseKey:e,project:r},{headers:{"x-cdk-insights-fingerprint":t,"x-cdk-insights-client":"cli"},timeout:1e4});return Z.info("\u2705 Authentication successful",{hasToken:!!o.token,expiresIn:o.expiresIn,fingerprintStatus:o.fingerprintStatus,hasUsageData:!!o.usageData,hasLicenseInfo:!!o.licenseInfo,apiUrl:s}),NMe(o.token,e,o.expiresIn||3600),{token:o.token,usageData:o.usageData,licenseInfo:o.licenseInfo,fingerprint:o.fingerprint,apiUrl:s}}catch(o){let a=vs.isAxiosError(o)?o:void 0,c=TX(a?.config?.url?a.config.url.replace(/\/?login$/,""):s);if(Z.error("Authentication failed",{error:o instanceof Error?o.message:String(o),apiUrl:c}),a)if(a.code==="ECONNREFUSED")Z.error("Network error: Connection refused",{error:a.message,suggestion:"Check if the API server is running and accessible",apiUrl:c});else if(a.code==="ENOTFOUND")Z.error("Network error: Host not found",{error:a.message,apiUrl:c,suggestion:"Check if the API URL is correct"});else if(a.code==="ETIMEDOUT")Z.error("Network error: Request timed out",{error:a.message,suggestion:"The API server took too long to respond",apiUrl:c});else if(a.response){let u=a.response.status,l=a.response.data;Z.error(`HTTP ${u} error`,{status:u,apiUrl:c,error:l?.error||a.message,response:l}),u===401?Z.error("License key is invalid or expired",{status:u,apiUrl:c}):u===403?Z.error("License is already used in 3 environments",{status:u,apiUrl:c,fingerprints:l?.fingerprints}):u===404?Z.error("API endpoint not found",{status:u,apiUrl:c,suggestion:"Check if the API URL is correct"}):u>=500&&Z.error("Server error",{status:u,apiUrl:c,suggestion:"The API server may be experiencing issues"})}else Z.error("Network error",{error:a.message,apiUrl:c});else Z.error("Unexpected error",{error:o.message||String(o),apiUrl:c});return}}var Zb=()=>{try{cn.existsSync(zu)?(cn.unlinkSync(zu),Z.info("\u{1F5D1}\uFE0F Cleared auth token cache")):Z.info("\u2139\uFE0F No auth token cache to clear")}catch(e){Z.warn("Failed to clear auth token cache",{error:e instanceof Error?e.message:String(e)})}};var WX=require("node:events"),zX=require("node:fs"),yR=require("node:path"),GX=A(UD());var nr={};Xr(nr,{BRAND:()=>cje,DIRTY:()=>Gu,EMPTY_PATH:()=>UMe,INVALID:()=>Me,NEVER:()=>Hje,OK:()=>Yr,ParseStatus:()=>jr,Schema:()=>tt,ZodAny:()=>Ma,ZodArray:()=>Co,ZodBigInt:()=>Vu,ZodBoolean:()=>Ku,ZodBranded:()=>Kh,ZodCatch:()=>il,ZodDate:()=>Ju,ZodDefault:()=>sl,ZodDiscriminatedUnion:()=>Xb,ZodEffects:()=>Ss,ZodEnum:()=>rl,ZodError:()=>Cn,ZodFirstPartyTypeKind:()=>Be,ZodFunction:()=>tS,ZodIntersection:()=>Xu,ZodIssueCode:()=>X,ZodLazy:()=>el,ZodLiteral:()=>tl,ZodMap:()=>_p,ZodNaN:()=>Ep,ZodNativeEnum:()=>nl,ZodNever:()=>Ys,ZodNull:()=>Yu,ZodNullable:()=>Ri,ZodNumber:()=>Hu,ZodObject:()=>En,ZodOptional:()=>xs,ZodParsedType:()=>ve,ZodPipeline:()=>Jh,ZodPromise:()=>ja,ZodReadonly:()=>ol,ZodRecord:()=>eS,ZodSchema:()=>tt,ZodSet:()=>Cp,ZodString:()=>Na,ZodSymbol:()=>bp,ZodTransformer:()=>Ss,ZodTuple:()=>Pi,ZodType:()=>tt,ZodUndefined:()=>Zu,ZodUnion:()=>Qu,ZodUnknown:()=>_o,ZodVoid:()=>Sp,addIssueToContext:()=>ge,any:()=>yje,array:()=>Sje,bigint:()=>pje,boolean:()=>qX,coerce:()=>Gje,custom:()=>BX,date:()=>fje,datetimeRegex:()=>MX,defaultErrorMap:()=>bo,discriminatedUnion:()=>Dje,effect:()=>Mje,enum:()=>kje,function:()=>Rje,getErrorMap:()=>yp,getParsedType:()=>Ii,instanceof:()=>lje,intersection:()=>wje,isAborted:()=>Yb,isAsync:()=>vp,isDirty:()=>Qb,isValid:()=>La,late:()=>uje,lazy:()=>Fje,literal:()=>Oje,makeIssue:()=>Vh,map:()=>Ije,nan:()=>dje,nativeEnum:()=>Lje,never:()=>xje,null:()=>gje,nullable:()=>Bje,number:()=>$X,object:()=>_je,objectUtil:()=>mR,oboolean:()=>zje,onumber:()=>Wje,optional:()=>jje,ostring:()=>qje,pipeline:()=>$je,preprocess:()=>Uje,promise:()=>Nje,quotelessJson:()=>MMe,record:()=>Tje,set:()=>Pje,setErrorMap:()=>BMe,strictObject:()=>Cje,string:()=>UX,symbol:()=>mje,transformer:()=>Mje,tuple:()=>Aje,undefined:()=>hje,union:()=>Eje,unknown:()=>vje,util:()=>ct,void:()=>bje});var ct;(function(e){e.assertEqual=s=>{};function t(s){}e.assertIs=t;function r(s){throw new Error}e.assertNever=r,e.arrayToEnum=s=>{let i={};for(let o of s)i[o]=o;return i},e.getValidEnumValues=s=>{let i=e.objectKeys(s).filter(a=>typeof s[s[a]]!="number"),o={};for(let a of i)o[a]=s[a];return e.objectValues(o)},e.objectValues=s=>e.objectKeys(s).map(function(i){return s[i]}),e.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{let i=[];for(let o in s)Object.prototype.hasOwnProperty.call(s,o)&&i.push(o);return i},e.find=(s,i)=>{for(let o of s)if(i(o))return o},e.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&Number.isFinite(s)&&Math.floor(s)===s;function n(s,i=" | "){return s.map(o=>typeof o=="string"?`'${o}'`:o).join(i)}e.joinValues=n,e.jsonStringifyReplacer=(s,i)=>typeof i=="bigint"?i.toString():i})(ct||(ct={}));var mR;(function(e){e.mergeShapes=(t,r)=>({...t,...r})})(mR||(mR={}));var ve=ct.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Ii=e=>{switch(typeof e){case"undefined":return ve.undefined;case"string":return ve.string;case"number":return Number.isNaN(e)?ve.nan:ve.number;case"boolean":return ve.boolean;case"function":return ve.function;case"bigint":return ve.bigint;case"symbol":return ve.symbol;case"object":return Array.isArray(e)?ve.array:e===null?ve.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?ve.promise:typeof Map<"u"&&e instanceof Map?ve.map:typeof Set<"u"&&e instanceof Set?ve.set:typeof Date<"u"&&e instanceof Date?ve.date:ve.object;default:return ve.unknown}};var X=ct.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),MMe=e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:"),Cn=class e extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};let r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=t}format(t){let r=t||function(i){return i.message},n={_errors:[]},s=i=>{for(let o of i.issues)if(o.code==="invalid_union")o.unionErrors.map(s);else if(o.code==="invalid_return_type")s(o.returnTypeError);else if(o.code==="invalid_arguments")s(o.argumentsError);else if(o.path.length===0)n._errors.push(r(o));else{let a=n,c=0;for(;c<o.path.length;){let u=o.path[c];c===o.path.length-1?(a[u]=a[u]||{_errors:[]},a[u]._errors.push(r(o))):a[u]=a[u]||{_errors:[]},a=a[u],c++}}};return s(this),n}static assert(t){if(!(t instanceof e))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,ct.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=r=>r.message){let r={},n=[];for(let s of this.issues)if(s.path.length>0){let i=s.path[0];r[i]=r[i]||[],r[i].push(t(s))}else n.push(t(s));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}};Cn.create=e=>new Cn(e);var jMe=(e,t)=>{let r;switch(e.code){case X.invalid_type:e.received===ve.undefined?r="Required":r=`Expected ${e.expected}, received ${e.received}`;break;case X.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(e.expected,ct.jsonStringifyReplacer)}`;break;case X.unrecognized_keys:r=`Unrecognized key(s) in object: ${ct.joinValues(e.keys,", ")}`;break;case X.invalid_union:r="Invalid input";break;case X.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${ct.joinValues(e.options)}`;break;case X.invalid_enum_value:r=`Invalid enum value. Expected ${ct.joinValues(e.options)}, received '${e.received}'`;break;case X.invalid_arguments:r="Invalid function arguments";break;case X.invalid_return_type:r="Invalid function return type";break;case X.invalid_date:r="Invalid date";break;case X.invalid_string:typeof e.validation=="object"?"includes"in e.validation?(r=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?r=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?r=`Invalid input: must end with "${e.validation.endsWith}"`:ct.assertNever(e.validation):e.validation!=="regex"?r=`Invalid ${e.validation}`:r="Invalid";break;case X.too_small:e.type==="array"?r=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:e.type==="string"?r=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:e.type==="number"?r=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="bigint"?r=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="date"?r=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:r="Invalid input";break;case X.too_big:e.type==="array"?r=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:e.type==="string"?r=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:e.type==="number"?r=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="bigint"?r=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="date"?r=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:r="Invalid input";break;case X.custom:r="Invalid input";break;case X.invalid_intersection_types:r="Intersection results could not be merged";break;case X.not_multiple_of:r=`Number must be a multiple of ${e.multipleOf}`;break;case X.not_finite:r="Number must be finite";break;default:r=t.defaultError,ct.assertNever(e)}return{message:r}},bo=jMe;var FX=bo;function BMe(e){FX=e}function yp(){return FX}var Vh=e=>{let{data:t,path:r,errorMaps:n,issueData:s}=e,i=[...r,...s.path||[]],o={...s,path:i};if(s.message!==void 0)return{...s,path:i,message:s.message};let a="",c=n.filter(u=>!!u).slice().reverse();for(let u of c)a=u(o,{data:t,defaultError:a}).message;return{...s,path:i,message:a}},UMe=[];function ge(e,t){let r=yp(),n=Vh({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,r,r===bo?void 0:bo].filter(s=>!!s)});e.common.issues.push(n)}var jr=class e{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,r){let n=[];for(let s of r){if(s.status==="aborted")return Me;s.status==="dirty"&&t.dirty(),n.push(s.value)}return{status:t.value,value:n}}static async mergeObjectAsync(t,r){let n=[];for(let s of r){let i=await s.key,o=await s.value;n.push({key:i,value:o})}return e.mergeObjectSync(t,n)}static mergeObjectSync(t,r){let n={};for(let s of r){let{key:i,value:o}=s;if(i.status==="aborted"||o.status==="aborted")return Me;i.status==="dirty"&&t.dirty(),o.status==="dirty"&&t.dirty(),i.value!=="__proto__"&&(typeof o.value<"u"||s.alwaysSet)&&(n[i.value]=o.value)}return{status:t.value,value:n}}},Me=Object.freeze({status:"aborted"}),Gu=e=>({status:"dirty",value:e}),Yr=e=>({status:"valid",value:e}),Yb=e=>e.status==="aborted",Qb=e=>e.status==="dirty",La=e=>e.status==="valid",vp=e=>typeof Promise<"u"&&e instanceof Promise;var Ie;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t?.message})(Ie||(Ie={}));var bs=class{constructor(t,r,n,s){this._cachedPath=[],this.parent=t,this.data=r,this._path=n,this._key=s}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},OX=(e,t)=>{if(La(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let r=new Cn(e.common.issues);return this._error=r,this._error}}};function Ke(e){if(!e)return{};let{errorMap:t,invalid_type_error:r,required_error:n,description:s}=e;if(t&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:s}:{errorMap:(o,a)=>{let{message:c}=e;return o.code==="invalid_enum_value"?{message:c??a.defaultError}:typeof a.data>"u"?{message:c??n??a.defaultError}:o.code!=="invalid_type"?{message:a.defaultError}:{message:c??r??a.defaultError}},description:s}}var tt=class{get description(){return this._def.description}_getType(t){return Ii(t.data)}_getOrReturnCtx(t,r){return r||{common:t.parent.common,data:t.data,parsedType:Ii(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new jr,ctx:{common:t.parent.common,data:t.data,parsedType:Ii(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){let r=this._parse(t);if(vp(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(t){let r=this._parse(t);return Promise.resolve(r)}parse(t,r){let n=this.safeParse(t,r);if(n.success)return n.data;throw n.error}safeParse(t,r){let n={common:{issues:[],async:r?.async??!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Ii(t)},s=this._parseSync({data:t,path:n.path,parent:n});return OX(n,s)}"~validate"(t){let r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Ii(t)};if(!this["~standard"].async)try{let n=this._parseSync({data:t,path:[],parent:r});return La(n)?{value:n.value}:{issues:r.common.issues}}catch(n){n?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:r}).then(n=>La(n)?{value:n.value}:{issues:r.common.issues})}async parseAsync(t,r){let n=await this.safeParseAsync(t,r);if(n.success)return n.data;throw n.error}async safeParseAsync(t,r){let n={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Ii(t)},s=this._parse({data:t,path:n.path,parent:n}),i=await(vp(s)?s:Promise.resolve(s));return OX(n,i)}refine(t,r){let n=s=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(s):r;return this._refinement((s,i)=>{let o=t(s),a=()=>i.addIssue({code:X.custom,...n(s)});return typeof Promise<"u"&&o instanceof Promise?o.then(c=>c?!0:(a(),!1)):o?!0:(a(),!1)})}refinement(t,r){return this._refinement((n,s)=>t(n)?!0:(s.addIssue(typeof r=="function"?r(n,s):r),!1))}_refinement(t){return new Ss({schema:this,typeName:Be.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}constructor(t){this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:r=>this["~validate"](r)}}optional(){return xs.create(this,this._def)}nullable(){return Ri.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Co.create(this)}promise(){return ja.create(this,this._def)}or(t){return Qu.create([this,t],this._def)}and(t){return Xu.create(this,t,this._def)}transform(t){return new Ss({...Ke(this._def),schema:this,typeName:Be.ZodEffects,effect:{type:"transform",transform:t}})}default(t){let r=typeof t=="function"?t:()=>t;return new sl({...Ke(this._def),innerType:this,defaultValue:r,typeName:Be.ZodDefault})}brand(){return new Kh({typeName:Be.ZodBranded,type:this,...Ke(this._def)})}catch(t){let r=typeof t=="function"?t:()=>t;return new il({...Ke(this._def),innerType:this,catchValue:r,typeName:Be.ZodCatch})}describe(t){let r=this.constructor;return new r({...this._def,description:t})}pipe(t){return Jh.create(this,t)}readonly(){return ol.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},$Me=/^c[^\s-]{8,}$/i,qMe=/^[0-9a-z]+$/,WMe=/^[0-9A-HJKMNP-TV-Z]{26}$/i,zMe=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,GMe=/^[a-z0-9_-]{21}$/i,HMe=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,VMe=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,KMe=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,JMe="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",hR,ZMe=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,YMe=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,QMe=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,XMe=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,eje=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,tje=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,LX="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",rje=new RegExp(`^${LX}$`);function NX(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision==null&&(t=`${t}(\\.\\d+)?`);let r=e.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${r}`}function nje(e){return new RegExp(`^${NX(e)}$`)}function MX(e){let t=`${LX}T${NX(e)}`,r=[];return r.push(e.local?"Z?":"Z"),e.offset&&r.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${r.join("|")})`,new RegExp(`^${t}$`)}function sje(e,t){return!!((t==="v4"||!t)&&ZMe.test(e)||(t==="v6"||!t)&&QMe.test(e))}function ije(e,t){if(!HMe.test(e))return!1;try{let[r]=e.split(".");if(!r)return!1;let n=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),s=JSON.parse(atob(n));return!(typeof s!="object"||s===null||"typ"in s&&s?.typ!=="JWT"||!s.alg||t&&s.alg!==t)}catch{return!1}}function oje(e,t){return!!((t==="v4"||!t)&&YMe.test(e)||(t==="v6"||!t)&&XMe.test(e))}var Na=class e extends tt{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==ve.string){let i=this._getOrReturnCtx(t);return ge(i,{code:X.invalid_type,expected:ve.string,received:i.parsedType}),Me}let n=new jr,s;for(let i of this._def.checks)if(i.kind==="min")t.data.length<i.value&&(s=this._getOrReturnCtx(t,s),ge(s,{code:X.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="max")t.data.length>i.value&&(s=this._getOrReturnCtx(t,s),ge(s,{code:X.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="length"){let o=t.data.length>i.value,a=t.data.length<i.value;(o||a)&&(s=this._getOrReturnCtx(t,s),o?ge(s,{code:X.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):a&&ge(s,{code:X.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),n.dirty())}else if(i.kind==="email")KMe.test(t.data)||(s=this._getOrReturnCtx(t,s),ge(s,{validation:"email",code:X.invalid_string,message:i.message}),n.dirty());else if(i.kind==="emoji")hR||(hR=new RegExp(JMe,"u")),hR.test(t.data)||(s=this._getOrReturnCtx(t,s),ge(s,{validation:"emoji",code:X.invalid_string,message:i.message}),n.dirty());else if(i.kind==="uuid")zMe.test(t.data)||(s=this._getOrReturnCtx(t,s),ge(s,{validation:"uuid",code:X.invalid_string,message:i.message}),n.dirty());else if(i.kind==="nanoid")GMe.test(t.data)||(s=this._getOrReturnCtx(t,s),ge(s,{validation:"nanoid",code:X.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid")$Me.test(t.data)||(s=this._getOrReturnCtx(t,s),ge(s,{validation:"cuid",code:X.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid2")qMe.test(t.data)||(s=this._getOrReturnCtx(t,s),ge(s,{validation:"cuid2",code:X.invalid_string,message:i.message}),n.dirty());else if(i.kind==="ulid")WMe.test(t.data)||(s=this._getOrReturnCtx(t,s),ge(s,{validation:"ulid",code:X.invalid_string,message:i.message}),n.dirty());else if(i.kind==="url")try{new URL(t.data)}catch{s=this._getOrReturnCtx(t,s),ge(s,{validation:"url",code:X.invalid_string,message:i.message}),n.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(t.data)||(s=this._getOrReturnCtx(t,s),ge(s,{validation:"regex",code:X.invalid_string,message:i.message}),n.dirty())):i.kind==="trim"?t.data=t.data.trim():i.kind==="includes"?t.data.includes(i.value,i.position)||(s=this._getOrReturnCtx(t,s),ge(s,{code:X.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),n.dirty()):i.kind==="toLowerCase"?t.data=t.data.toLowerCase():i.kind==="toUpperCase"?t.data=t.data.toUpperCase():i.kind==="startsWith"?t.data.startsWith(i.value)||(s=this._getOrReturnCtx(t,s),ge(s,{code:X.invalid_string,validation:{startsWith:i.value},message:i.message}),n.dirty()):i.kind==="endsWith"?t.data.endsWith(i.value)||(s=this._getOrReturnCtx(t,s),ge(s,{code:X.invalid_string,validation:{endsWith:i.value},message:i.message}),n.dirty()):i.kind==="datetime"?MX(i).test(t.data)||(s=this._getOrReturnCtx(t,s),ge(s,{code:X.invalid_string,validation:"datetime",message:i.message}),n.dirty()):i.kind==="date"?rje.test(t.data)||(s=this._getOrReturnCtx(t,s),ge(s,{code:X.invalid_string,validation:"date",message:i.message}),n.dirty()):i.kind==="time"?nje(i).test(t.data)||(s=this._getOrReturnCtx(t,s),ge(s,{code:X.invalid_string,validation:"time",message:i.message}),n.dirty()):i.kind==="duration"?VMe.test(t.data)||(s=this._getOrReturnCtx(t,s),ge(s,{validation:"duration",code:X.invalid_string,message:i.message}),n.dirty()):i.kind==="ip"?sje(t.data,i.version)||(s=this._getOrReturnCtx(t,s),ge(s,{validation:"ip",code:X.invalid_string,message:i.message}),n.dirty()):i.kind==="jwt"?ije(t.data,i.alg)||(s=this._getOrReturnCtx(t,s),ge(s,{validation:"jwt",code:X.invalid_string,message:i.message}),n.dirty()):i.kind==="cidr"?oje(t.data,i.version)||(s=this._getOrReturnCtx(t,s),ge(s,{validation:"cidr",code:X.invalid_string,message:i.message}),n.dirty()):i.kind==="base64"?eje.test(t.data)||(s=this._getOrReturnCtx(t,s),ge(s,{validation:"base64",code:X.invalid_string,message:i.message}),n.dirty()):i.kind==="base64url"?tje.test(t.data)||(s=this._getOrReturnCtx(t,s),ge(s,{validation:"base64url",code:X.invalid_string,message:i.message}),n.dirty()):ct.assertNever(i);return{status:n.value,value:t.data}}_regex(t,r,n){return this.refinement(s=>t.test(s),{validation:r,code:X.invalid_string,...Ie.errToObj(n)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...Ie.errToObj(t)})}url(t){return this._addCheck({kind:"url",...Ie.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...Ie.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...Ie.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...Ie.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...Ie.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...Ie.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...Ie.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...Ie.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...Ie.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...Ie.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...Ie.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...Ie.errToObj(t)})}datetime(t){return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof t?.precision>"u"?null:t?.precision,offset:t?.offset??!1,local:t?.local??!1,...Ie.errToObj(t?.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof t?.precision>"u"?null:t?.precision,...Ie.errToObj(t?.message)})}duration(t){return this._addCheck({kind:"duration",...Ie.errToObj(t)})}regex(t,r){return this._addCheck({kind:"regex",regex:t,...Ie.errToObj(r)})}includes(t,r){return this._addCheck({kind:"includes",value:t,position:r?.position,...Ie.errToObj(r?.message)})}startsWith(t,r){return this._addCheck({kind:"startsWith",value:t,...Ie.errToObj(r)})}endsWith(t,r){return this._addCheck({kind:"endsWith",value:t,...Ie.errToObj(r)})}min(t,r){return this._addCheck({kind:"min",value:t,...Ie.errToObj(r)})}max(t,r){return this._addCheck({kind:"max",value:t,...Ie.errToObj(r)})}length(t,r){return this._addCheck({kind:"length",value:t,...Ie.errToObj(r)})}nonempty(t){return this.min(1,Ie.errToObj(t))}trim(){return new e({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new e({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new e({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isCIDR(){return!!this._def.checks.find(t=>t.kind==="cidr")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get isBase64url(){return!!this._def.checks.find(t=>t.kind==="base64url")}get minLength(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxLength(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}};Na.create=e=>new Na({checks:[],typeName:Be.ZodString,coerce:e?.coerce??!1,...Ke(e)});function aje(e,t){let r=(e.toString().split(".")[1]||"").length,n=(t.toString().split(".")[1]||"").length,s=r>n?r:n,i=Number.parseInt(e.toFixed(s).replace(".","")),o=Number.parseInt(t.toFixed(s).replace(".",""));return i%o/10**s}var Hu=class e extends tt{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==ve.number){let i=this._getOrReturnCtx(t);return ge(i,{code:X.invalid_type,expected:ve.number,received:i.parsedType}),Me}let n,s=new jr;for(let i of this._def.checks)i.kind==="int"?ct.isInteger(t.data)||(n=this._getOrReturnCtx(t,n),ge(n,{code:X.invalid_type,expected:"integer",received:"float",message:i.message}),s.dirty()):i.kind==="min"?(i.inclusive?t.data<i.value:t.data<=i.value)&&(n=this._getOrReturnCtx(t,n),ge(n,{code:X.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?t.data>i.value:t.data>=i.value)&&(n=this._getOrReturnCtx(t,n),ge(n,{code:X.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?aje(t.data,i.value)!==0&&(n=this._getOrReturnCtx(t,n),ge(n,{code:X.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(t.data)||(n=this._getOrReturnCtx(t,n),ge(n,{code:X.not_finite,message:i.message}),s.dirty()):ct.assertNever(i);return{status:s.value,value:t.data}}gte(t,r){return this.setLimit("min",t,!0,Ie.toString(r))}gt(t,r){return this.setLimit("min",t,!1,Ie.toString(r))}lte(t,r){return this.setLimit("max",t,!0,Ie.toString(r))}lt(t,r){return this.setLimit("max",t,!1,Ie.toString(r))}setLimit(t,r,n,s){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:n,message:Ie.toString(s)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:Ie.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Ie.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Ie.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Ie.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Ie.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:Ie.toString(r)})}finite(t){return this._addCheck({kind:"finite",message:Ie.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Ie.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Ie.toString(t)})}get minValue(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxValue(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&ct.isInteger(t.value))}get isFinite(){let t=null,r=null;for(let n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(t===null||n.value<t)&&(t=n.value)}return Number.isFinite(r)&&Number.isFinite(t)}};Hu.create=e=>new Hu({checks:[],typeName:Be.ZodNumber,coerce:e?.coerce||!1,...Ke(e)});var Vu=class e extends tt{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==ve.bigint)return this._getInvalidInput(t);let n,s=new jr;for(let i of this._def.checks)i.kind==="min"?(i.inclusive?t.data<i.value:t.data<=i.value)&&(n=this._getOrReturnCtx(t,n),ge(n,{code:X.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?t.data>i.value:t.data>=i.value)&&(n=this._getOrReturnCtx(t,n),ge(n,{code:X.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="multipleOf"?t.data%i.value!==BigInt(0)&&(n=this._getOrReturnCtx(t,n),ge(n,{code:X.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):ct.assertNever(i);return{status:s.value,value:t.data}}_getInvalidInput(t){let r=this._getOrReturnCtx(t);return ge(r,{code:X.invalid_type,expected:ve.bigint,received:r.parsedType}),Me}gte(t,r){return this.setLimit("min",t,!0,Ie.toString(r))}gt(t,r){return this.setLimit("min",t,!1,Ie.toString(r))}lte(t,r){return this.setLimit("max",t,!0,Ie.toString(r))}lt(t,r){return this.setLimit("max",t,!1,Ie.toString(r))}setLimit(t,r,n,s){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:n,message:Ie.toString(s)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Ie.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Ie.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Ie.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Ie.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:Ie.toString(r)})}get minValue(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxValue(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}};Vu.create=e=>new Vu({checks:[],typeName:Be.ZodBigInt,coerce:e?.coerce??!1,...Ke(e)});var Ku=class extends tt{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==ve.boolean){let n=this._getOrReturnCtx(t);return ge(n,{code:X.invalid_type,expected:ve.boolean,received:n.parsedType}),Me}return Yr(t.data)}};Ku.create=e=>new Ku({typeName:Be.ZodBoolean,coerce:e?.coerce||!1,...Ke(e)});var Ju=class e extends tt{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==ve.date){let i=this._getOrReturnCtx(t);return ge(i,{code:X.invalid_type,expected:ve.date,received:i.parsedType}),Me}if(Number.isNaN(t.data.getTime())){let i=this._getOrReturnCtx(t);return ge(i,{code:X.invalid_date}),Me}let n=new jr,s;for(let i of this._def.checks)i.kind==="min"?t.data.getTime()<i.value&&(s=this._getOrReturnCtx(t,s),ge(s,{code:X.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),n.dirty()):i.kind==="max"?t.data.getTime()>i.value&&(s=this._getOrReturnCtx(t,s),ge(s,{code:X.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),n.dirty()):ct.assertNever(i);return{status:n.value,value:new Date(t.data.getTime())}}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}min(t,r){return this._addCheck({kind:"min",value:t.getTime(),message:Ie.toString(r)})}max(t,r){return this._addCheck({kind:"max",value:t.getTime(),message:Ie.toString(r)})}get minDate(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t!=null?new Date(t):null}};Ju.create=e=>new Ju({checks:[],coerce:e?.coerce||!1,typeName:Be.ZodDate,...Ke(e)});var bp=class extends tt{_parse(t){if(this._getType(t)!==ve.symbol){let n=this._getOrReturnCtx(t);return ge(n,{code:X.invalid_type,expected:ve.symbol,received:n.parsedType}),Me}return Yr(t.data)}};bp.create=e=>new bp({typeName:Be.ZodSymbol,...Ke(e)});var Zu=class extends tt{_parse(t){if(this._getType(t)!==ve.undefined){let n=this._getOrReturnCtx(t);return ge(n,{code:X.invalid_type,expected:ve.undefined,received:n.parsedType}),Me}return Yr(t.data)}};Zu.create=e=>new Zu({typeName:Be.ZodUndefined,...Ke(e)});var Yu=class extends tt{_parse(t){if(this._getType(t)!==ve.null){let n=this._getOrReturnCtx(t);return ge(n,{code:X.invalid_type,expected:ve.null,received:n.parsedType}),Me}return Yr(t.data)}};Yu.create=e=>new Yu({typeName:Be.ZodNull,...Ke(e)});var Ma=class extends tt{constructor(){super(...arguments),this._any=!0}_parse(t){return Yr(t.data)}};Ma.create=e=>new Ma({typeName:Be.ZodAny,...Ke(e)});var _o=class extends tt{constructor(){super(...arguments),this._unknown=!0}_parse(t){return Yr(t.data)}};_o.create=e=>new _o({typeName:Be.ZodUnknown,...Ke(e)});var Ys=class extends tt{_parse(t){let r=this._getOrReturnCtx(t);return ge(r,{code:X.invalid_type,expected:ve.never,received:r.parsedType}),Me}};Ys.create=e=>new Ys({typeName:Be.ZodNever,...Ke(e)});var Sp=class extends tt{_parse(t){if(this._getType(t)!==ve.undefined){let n=this._getOrReturnCtx(t);return ge(n,{code:X.invalid_type,expected:ve.void,received:n.parsedType}),Me}return Yr(t.data)}};Sp.create=e=>new Sp({typeName:Be.ZodVoid,...Ke(e)});var Co=class e extends tt{_parse(t){let{ctx:r,status:n}=this._processInputParams(t),s=this._def;if(r.parsedType!==ve.array)return ge(r,{code:X.invalid_type,expected:ve.array,received:r.parsedType}),Me;if(s.exactLength!==null){let o=r.data.length>s.exactLength.value,a=r.data.length<s.exactLength.value;(o||a)&&(ge(r,{code:o?X.too_big:X.too_small,minimum:a?s.exactLength.value:void 0,maximum:o?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),n.dirty())}if(s.minLength!==null&&r.data.length<s.minLength.value&&(ge(r,{code:X.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),n.dirty()),s.maxLength!==null&&r.data.length>s.maxLength.value&&(ge(r,{code:X.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((o,a)=>s.type._parseAsync(new bs(r,o,r.path,a)))).then(o=>jr.mergeArray(n,o));let i=[...r.data].map((o,a)=>s.type._parseSync(new bs(r,o,r.path,a)));return jr.mergeArray(n,i)}get element(){return this._def.type}min(t,r){return new e({...this._def,minLength:{value:t,message:Ie.toString(r)}})}max(t,r){return new e({...this._def,maxLength:{value:t,message:Ie.toString(r)}})}length(t,r){return new e({...this._def,exactLength:{value:t,message:Ie.toString(r)}})}nonempty(t){return this.min(1,t)}};Co.create=(e,t)=>new Co({type:e,minLength:null,maxLength:null,exactLength:null,typeName:Be.ZodArray,...Ke(t)});function xp(e){if(e instanceof En){let t={};for(let r in e.shape){let n=e.shape[r];t[r]=xs.create(xp(n))}return new En({...e._def,shape:()=>t})}else return e instanceof Co?new Co({...e._def,type:xp(e.element)}):e instanceof xs?xs.create(xp(e.unwrap())):e instanceof Ri?Ri.create(xp(e.unwrap())):e instanceof Pi?Pi.create(e.items.map(t=>xp(t))):e}var En=class e extends tt{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let t=this._def.shape(),r=ct.objectKeys(t);return this._cached={shape:t,keys:r},this._cached}_parse(t){if(this._getType(t)!==ve.object){let u=this._getOrReturnCtx(t);return ge(u,{code:X.invalid_type,expected:ve.object,received:u.parsedType}),Me}let{status:n,ctx:s}=this._processInputParams(t),{shape:i,keys:o}=this._getCached(),a=[];if(!(this._def.catchall instanceof Ys&&this._def.unknownKeys==="strip"))for(let u in s.data)o.includes(u)||a.push(u);let c=[];for(let u of o){let l=i[u],d=s.data[u];c.push({key:{status:"valid",value:u},value:l._parse(new bs(s,d,s.path,u)),alwaysSet:u in s.data})}if(this._def.catchall instanceof Ys){let u=this._def.unknownKeys;if(u==="passthrough")for(let l of a)c.push({key:{status:"valid",value:l},value:{status:"valid",value:s.data[l]}});else if(u==="strict")a.length>0&&(ge(s,{code:X.unrecognized_keys,keys:a}),n.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let u=this._def.catchall;for(let l of a){let d=s.data[l];c.push({key:{status:"valid",value:l},value:u._parse(new bs(s,d,s.path,l)),alwaysSet:l in s.data})}}return s.common.async?Promise.resolve().then(async()=>{let u=[];for(let l of c){let d=await l.key,p=await l.value;u.push({key:d,value:p,alwaysSet:l.alwaysSet})}return u}).then(u=>jr.mergeObjectSync(n,u)):jr.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(t){return Ie.errToObj,new e({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(r,n)=>{let s=this._def.errorMap?.(r,n).message??n.defaultError;return r.code==="unrecognized_keys"?{message:Ie.errToObj(t).message??s}:{message:s}}}:{}})}strip(){return new e({...this._def,unknownKeys:"strip"})}passthrough(){return new e({...this._def,unknownKeys:"passthrough"})}extend(t){return new e({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new e({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:Be.ZodObject})}setKey(t,r){return this.augment({[t]:r})}catchall(t){return new e({...this._def,catchall:t})}pick(t){let r={};for(let n of ct.objectKeys(t))t[n]&&this.shape[n]&&(r[n]=this.shape[n]);return new e({...this._def,shape:()=>r})}omit(t){let r={};for(let n of ct.objectKeys(this.shape))t[n]||(r[n]=this.shape[n]);return new e({...this._def,shape:()=>r})}deepPartial(){return xp(this)}partial(t){let r={};for(let n of ct.objectKeys(this.shape)){let s=this.shape[n];t&&!t[n]?r[n]=s:r[n]=s.optional()}return new e({...this._def,shape:()=>r})}required(t){let r={};for(let n of ct.objectKeys(this.shape))if(t&&!t[n])r[n]=this.shape[n];else{let i=this.shape[n];for(;i instanceof xs;)i=i._def.innerType;r[n]=i}return new e({...this._def,shape:()=>r})}keyof(){return jX(ct.objectKeys(this.shape))}};En.create=(e,t)=>new En({shape:()=>e,unknownKeys:"strip",catchall:Ys.create(),typeName:Be.ZodObject,...Ke(t)});En.strictCreate=(e,t)=>new En({shape:()=>e,unknownKeys:"strict",catchall:Ys.create(),typeName:Be.ZodObject,...Ke(t)});En.lazycreate=(e,t)=>new En({shape:e,unknownKeys:"strip",catchall:Ys.create(),typeName:Be.ZodObject,...Ke(t)});var Qu=class extends tt{_parse(t){let{ctx:r}=this._processInputParams(t),n=this._def.options;function s(i){for(let a of i)if(a.result.status==="valid")return a.result;for(let a of i)if(a.result.status==="dirty")return r.common.issues.push(...a.ctx.common.issues),a.result;let o=i.map(a=>new Cn(a.ctx.common.issues));return ge(r,{code:X.invalid_union,unionErrors:o}),Me}if(r.common.async)return Promise.all(n.map(async i=>{let o={...r,common:{...r.common,issues:[]},parent:null};return{result:await i._parseAsync({data:r.data,path:r.path,parent:o}),ctx:o}})).then(s);{let i,o=[];for(let c of n){let u={...r,common:{...r.common,issues:[]},parent:null},l=c._parseSync({data:r.data,path:r.path,parent:u});if(l.status==="valid")return l;l.status==="dirty"&&!i&&(i={result:l,ctx:u}),u.common.issues.length&&o.push(u.common.issues)}if(i)return r.common.issues.push(...i.ctx.common.issues),i.result;let a=o.map(c=>new Cn(c));return ge(r,{code:X.invalid_union,unionErrors:a}),Me}}get options(){return this._def.options}};Qu.create=(e,t)=>new Qu({options:e,typeName:Be.ZodUnion,...Ke(t)});var So=e=>e instanceof el?So(e.schema):e instanceof Ss?So(e.innerType()):e instanceof tl?[e.value]:e instanceof rl?e.options:e instanceof nl?ct.objectValues(e.enum):e instanceof sl?So(e._def.innerType):e instanceof Zu?[void 0]:e instanceof Yu?[null]:e instanceof xs?[void 0,...So(e.unwrap())]:e instanceof Ri?[null,...So(e.unwrap())]:e instanceof Kh||e instanceof ol?So(e.unwrap()):e instanceof il?So(e._def.innerType):[],Xb=class e extends tt{_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==ve.object)return ge(r,{code:X.invalid_type,expected:ve.object,received:r.parsedType}),Me;let n=this.discriminator,s=r.data[n],i=this.optionsMap.get(s);return i?r.common.async?i._parseAsync({data:r.data,path:r.path,parent:r}):i._parseSync({data:r.data,path:r.path,parent:r}):(ge(r,{code:X.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),Me)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,r,n){let s=new Map;for(let i of r){let o=So(i.shape[t]);if(!o.length)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let a of o){if(s.has(a))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(a)}`);s.set(a,i)}}return new e({typeName:Be.ZodDiscriminatedUnion,discriminator:t,options:r,optionsMap:s,...Ke(n)})}};function gR(e,t){let r=Ii(e),n=Ii(t);if(e===t)return{valid:!0,data:e};if(r===ve.object&&n===ve.object){let s=ct.objectKeys(t),i=ct.objectKeys(e).filter(a=>s.indexOf(a)!==-1),o={...e,...t};for(let a of i){let c=gR(e[a],t[a]);if(!c.valid)return{valid:!1};o[a]=c.data}return{valid:!0,data:o}}else if(r===ve.array&&n===ve.array){if(e.length!==t.length)return{valid:!1};let s=[];for(let i=0;i<e.length;i++){let o=e[i],a=t[i],c=gR(o,a);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return r===ve.date&&n===ve.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}var Xu=class extends tt{_parse(t){let{status:r,ctx:n}=this._processInputParams(t),s=(i,o)=>{if(Yb(i)||Yb(o))return Me;let a=gR(i.value,o.value);return a.valid?((Qb(i)||Qb(o))&&r.dirty(),{status:r.value,value:a.data}):(ge(n,{code:X.invalid_intersection_types}),Me)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([i,o])=>s(i,o)):s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};Xu.create=(e,t,r)=>new Xu({left:e,right:t,typeName:Be.ZodIntersection,...Ke(r)});var Pi=class e extends tt{_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==ve.array)return ge(n,{code:X.invalid_type,expected:ve.array,received:n.parsedType}),Me;if(n.data.length<this._def.items.length)return ge(n,{code:X.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Me;!this._def.rest&&n.data.length>this._def.items.length&&(ge(n,{code:X.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let i=[...n.data].map((o,a)=>{let c=this._def.items[a]||this._def.rest;return c?c._parse(new bs(n,o,n.path,a)):null}).filter(o=>!!o);return n.common.async?Promise.all(i).then(o=>jr.mergeArray(r,o)):jr.mergeArray(r,i)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};Pi.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Pi({items:e,typeName:Be.ZodTuple,rest:null,...Ke(t)})};var eS=class e extends tt{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==ve.object)return ge(n,{code:X.invalid_type,expected:ve.object,received:n.parsedType}),Me;let s=[],i=this._def.keyType,o=this._def.valueType;for(let a in n.data)s.push({key:i._parse(new bs(n,a,n.path,a)),value:o._parse(new bs(n,n.data[a],n.path,a)),alwaysSet:a in n.data});return n.common.async?jr.mergeObjectAsync(r,s):jr.mergeObjectSync(r,s)}get element(){return this._def.valueType}static create(t,r,n){return r instanceof tt?new e({keyType:t,valueType:r,typeName:Be.ZodRecord,...Ke(n)}):new e({keyType:Na.create(),valueType:t,typeName:Be.ZodRecord,...Ke(r)})}},_p=class extends tt{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==ve.map)return ge(n,{code:X.invalid_type,expected:ve.map,received:n.parsedType}),Me;let s=this._def.keyType,i=this._def.valueType,o=[...n.data.entries()].map(([a,c],u)=>({key:s._parse(new bs(n,a,n.path,[u,"key"])),value:i._parse(new bs(n,c,n.path,[u,"value"]))}));if(n.common.async){let a=new Map;return Promise.resolve().then(async()=>{for(let c of o){let u=await c.key,l=await c.value;if(u.status==="aborted"||l.status==="aborted")return Me;(u.status==="dirty"||l.status==="dirty")&&r.dirty(),a.set(u.value,l.value)}return{status:r.value,value:a}})}else{let a=new Map;for(let c of o){let u=c.key,l=c.value;if(u.status==="aborted"||l.status==="aborted")return Me;(u.status==="dirty"||l.status==="dirty")&&r.dirty(),a.set(u.value,l.value)}return{status:r.value,value:a}}}};_p.create=(e,t,r)=>new _p({valueType:t,keyType:e,typeName:Be.ZodMap,...Ke(r)});var Cp=class e extends tt{_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==ve.set)return ge(n,{code:X.invalid_type,expected:ve.set,received:n.parsedType}),Me;let s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(ge(n,{code:X.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),r.dirty()),s.maxSize!==null&&n.data.size>s.maxSize.value&&(ge(n,{code:X.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),r.dirty());let i=this._def.valueType;function o(c){let u=new Set;for(let l of c){if(l.status==="aborted")return Me;l.status==="dirty"&&r.dirty(),u.add(l.value)}return{status:r.value,value:u}}let a=[...n.data.values()].map((c,u)=>i._parse(new bs(n,c,n.path,u)));return n.common.async?Promise.all(a).then(c=>o(c)):o(a)}min(t,r){return new e({...this._def,minSize:{value:t,message:Ie.toString(r)}})}max(t,r){return new e({...this._def,maxSize:{value:t,message:Ie.toString(r)}})}size(t,r){return this.min(t,r).max(t,r)}nonempty(t){return this.min(1,t)}};Cp.create=(e,t)=>new Cp({valueType:e,minSize:null,maxSize:null,typeName:Be.ZodSet,...Ke(t)});var tS=class e extends tt{constructor(){super(...arguments),this.validate=this.implement}_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==ve.function)return ge(r,{code:X.invalid_type,expected:ve.function,received:r.parsedType}),Me;function n(a,c){return Vh({data:a,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,yp(),bo].filter(u=>!!u),issueData:{code:X.invalid_arguments,argumentsError:c}})}function s(a,c){return Vh({data:a,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,yp(),bo].filter(u=>!!u),issueData:{code:X.invalid_return_type,returnTypeError:c}})}let i={errorMap:r.common.contextualErrorMap},o=r.data;if(this._def.returns instanceof ja){let a=this;return Yr(async function(...c){let u=new Cn([]),l=await a._def.args.parseAsync(c,i).catch(f=>{throw u.addIssue(n(c,f)),u}),d=await Reflect.apply(o,this,l);return await a._def.returns._def.type.parseAsync(d,i).catch(f=>{throw u.addIssue(s(d,f)),u})})}else{let a=this;return Yr(function(...c){let u=a._def.args.safeParse(c,i);if(!u.success)throw new Cn([n(c,u.error)]);let l=Reflect.apply(o,this,u.data),d=a._def.returns.safeParse(l,i);if(!d.success)throw new Cn([s(l,d.error)]);return d.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new e({...this._def,args:Pi.create(t).rest(_o.create())})}returns(t){return new e({...this._def,returns:t})}implement(t){return this.parse(t)}strictImplement(t){return this.parse(t)}static create(t,r,n){return new e({args:t||Pi.create([]).rest(_o.create()),returns:r||_o.create(),typeName:Be.ZodFunction,...Ke(n)})}},el=class extends tt{get schema(){return this._def.getter()}_parse(t){let{ctx:r}=this._processInputParams(t);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}};el.create=(e,t)=>new el({getter:e,typeName:Be.ZodLazy,...Ke(t)});var tl=class extends tt{_parse(t){if(t.data!==this._def.value){let r=this._getOrReturnCtx(t);return ge(r,{received:r.data,code:X.invalid_literal,expected:this._def.value}),Me}return{status:"valid",value:t.data}}get value(){return this._def.value}};tl.create=(e,t)=>new tl({value:e,typeName:Be.ZodLiteral,...Ke(t)});function jX(e,t){return new rl({values:e,typeName:Be.ZodEnum,...Ke(t)})}var rl=class e extends tt{_parse(t){if(typeof t.data!="string"){let r=this._getOrReturnCtx(t),n=this._def.values;return ge(r,{expected:ct.joinValues(n),received:r.parsedType,code:X.invalid_type}),Me}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){let r=this._getOrReturnCtx(t),n=this._def.values;return ge(r,{received:r.data,code:X.invalid_enum_value,options:n}),Me}return Yr(t.data)}get options(){return this._def.values}get enum(){let t={};for(let r of this._def.values)t[r]=r;return t}get Values(){let t={};for(let r of this._def.values)t[r]=r;return t}get Enum(){let t={};for(let r of this._def.values)t[r]=r;return t}extract(t,r=this._def){return e.create(t,{...this._def,...r})}exclude(t,r=this._def){return e.create(this.options.filter(n=>!t.includes(n)),{...this._def,...r})}};rl.create=jX;var nl=class extends tt{_parse(t){let r=ct.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(t);if(n.parsedType!==ve.string&&n.parsedType!==ve.number){let s=ct.objectValues(r);return ge(n,{expected:ct.joinValues(s),received:n.parsedType,code:X.invalid_type}),Me}if(this._cache||(this._cache=new Set(ct.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){let s=ct.objectValues(r);return ge(n,{received:n.data,code:X.invalid_enum_value,options:s}),Me}return Yr(t.data)}get enum(){return this._def.values}};nl.create=(e,t)=>new nl({values:e,typeName:Be.ZodNativeEnum,...Ke(t)});var ja=class extends tt{unwrap(){return this._def.type}_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==ve.promise&&r.common.async===!1)return ge(r,{code:X.invalid_type,expected:ve.promise,received:r.parsedType}),Me;let n=r.parsedType===ve.promise?r.data:Promise.resolve(r.data);return Yr(n.then(s=>this._def.type.parseAsync(s,{path:r.path,errorMap:r.common.contextualErrorMap})))}};ja.create=(e,t)=>new ja({type:e,typeName:Be.ZodPromise,...Ke(t)});var Ss=class extends tt{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Be.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){let{status:r,ctx:n}=this._processInputParams(t),s=this._def.effect||null,i={addIssue:o=>{ge(n,o),o.fatal?r.abort():r.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){let o=s.transform(n.data,i);if(n.common.async)return Promise.resolve(o).then(async a=>{if(r.value==="aborted")return Me;let c=await this._def.schema._parseAsync({data:a,path:n.path,parent:n});return c.status==="aborted"?Me:c.status==="dirty"?Gu(c.value):r.value==="dirty"?Gu(c.value):c});{if(r.value==="aborted")return Me;let a=this._def.schema._parseSync({data:o,path:n.path,parent:n});return a.status==="aborted"?Me:a.status==="dirty"?Gu(a.value):r.value==="dirty"?Gu(a.value):a}}if(s.type==="refinement"){let o=a=>{let c=s.refinement(a,i);if(n.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(n.common.async===!1){let a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?Me:(a.status==="dirty"&&r.dirty(),o(a.value),{status:r.value,value:a.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(a=>a.status==="aborted"?Me:(a.status==="dirty"&&r.dirty(),o(a.value).then(()=>({status:r.value,value:a.value}))))}if(s.type==="transform")if(n.common.async===!1){let o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!La(o))return Me;let a=s.transform(o.value,i);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:a}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>La(o)?Promise.resolve(s.transform(o.value,i)).then(a=>({status:r.value,value:a})):Me);ct.assertNever(s)}};Ss.create=(e,t,r)=>new Ss({schema:e,typeName:Be.ZodEffects,effect:t,...Ke(r)});Ss.createWithPreprocess=(e,t,r)=>new Ss({schema:t,effect:{type:"preprocess",transform:e},typeName:Be.ZodEffects,...Ke(r)});var xs=class extends tt{_parse(t){return this._getType(t)===ve.undefined?Yr(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};xs.create=(e,t)=>new xs({innerType:e,typeName:Be.ZodOptional,...Ke(t)});var Ri=class extends tt{_parse(t){return this._getType(t)===ve.null?Yr(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};Ri.create=(e,t)=>new Ri({innerType:e,typeName:Be.ZodNullable,...Ke(t)});var sl=class extends tt{_parse(t){let{ctx:r}=this._processInputParams(t),n=r.data;return r.parsedType===ve.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};sl.create=(e,t)=>new sl({innerType:e,typeName:Be.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...Ke(t)});var il=class extends tt{_parse(t){let{ctx:r}=this._processInputParams(t),n={...r,common:{...r.common,issues:[]}},s=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return vp(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Cn(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Cn(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};il.create=(e,t)=>new il({innerType:e,typeName:Be.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...Ke(t)});var Ep=class extends tt{_parse(t){if(this._getType(t)!==ve.nan){let n=this._getOrReturnCtx(t);return ge(n,{code:X.invalid_type,expected:ve.nan,received:n.parsedType}),Me}return{status:"valid",value:t.data}}};Ep.create=e=>new Ep({typeName:Be.ZodNaN,...Ke(e)});var cje=Symbol("zod_brand"),Kh=class extends tt{_parse(t){let{ctx:r}=this._processInputParams(t),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}},Jh=class e extends tt{_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.common.async)return(async()=>{let i=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?Me:i.status==="dirty"?(r.dirty(),Gu(i.value)):this._def.out._parseAsync({data:i.value,path:n.path,parent:n})})();{let s=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?Me:s.status==="dirty"?(r.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:n.path,parent:n})}}static create(t,r){return new e({in:t,out:r,typeName:Be.ZodPipeline})}},ol=class extends tt{_parse(t){let r=this._def.innerType._parse(t),n=s=>(La(s)&&(s.value=Object.freeze(s.value)),s);return vp(r)?r.then(s=>n(s)):n(r)}unwrap(){return this._def.innerType}};ol.create=(e,t)=>new ol({innerType:e,typeName:Be.ZodReadonly,...Ke(t)});function kX(e,t){let r=typeof e=="function"?e(t):typeof e=="string"?{message:e}:e;return typeof r=="string"?{message:r}:r}function BX(e,t={},r){return e?Ma.create().superRefine((n,s)=>{let i=e(n);if(i instanceof Promise)return i.then(o=>{if(!o){let a=kX(t,n),c=a.fatal??r??!0;s.addIssue({code:"custom",...a,fatal:c})}});if(!i){let o=kX(t,n),a=o.fatal??r??!0;s.addIssue({code:"custom",...o,fatal:a})}}):Ma.create()}var uje={object:En.lazycreate},Be;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(Be||(Be={}));var lje=(e,t={message:`Input not instance of ${e.name}`})=>BX(r=>r instanceof e,t),UX=Na.create,$X=Hu.create,dje=Ep.create,pje=Vu.create,qX=Ku.create,fje=Ju.create,mje=bp.create,hje=Zu.create,gje=Yu.create,yje=Ma.create,vje=_o.create,xje=Ys.create,bje=Sp.create,Sje=Co.create,_je=En.create,Cje=En.strictCreate,Eje=Qu.create,Dje=Xb.create,wje=Xu.create,Aje=Pi.create,Tje=eS.create,Ije=_p.create,Pje=Cp.create,Rje=tS.create,Fje=el.create,Oje=tl.create,kje=rl.create,Lje=nl.create,Nje=ja.create,Mje=Ss.create,jje=xs.create,Bje=Ri.create,Uje=Ss.createWithPreprocess,$je=Jh.create,qje=()=>UX().optional(),Wje=()=>$X().optional(),zje=()=>qX().optional(),Gje={string:e=>Na.create({...e,coerce:!0}),number:e=>Hu.create({...e,coerce:!0}),boolean:e=>Ku.create({...e,coerce:!0}),bigint:e=>Vu.create({...e,coerce:!0}),date:e=>Ju.create({...e,coerce:!0})};var Hje=Me;var Zh=class extends Error{constructor(t,r=[],n=[],s=void 0){super(t),this.name="EnvironmentValidationError",this.missingVars=r,this.invalidVars=n,this.context=s}},Yh=class e extends WX.EventEmitter{constructor(t,r={}){super(),this.watchers=[],this.lastConfigHash="",this.schema=t,this.options={loadEnvFiles:!0,validateStartup:!1,envFiles:[".env",".env.local"],watchFiles:!1,watchInterval:5e3,hotReload:!1,suppressWarnings:!1,...r},this.loadEnvironmentFiles(),this.config=this.validateEnvironment(t),this.lastConfigHash=this.getConfigHash(),this.options.validateStartup&&this.validateStartup(),(this.options.hotReload||this.options.watchFiles)&&this.startWatching()}static getInstance(t,r){return e.instance||(e.instance=new e(t,r)),e.instance}startWatching(){if(this.options.envFiles){for(let t of this.options.envFiles){let r=(0,yR.resolve)(process.cwd(),t);try{let n=(0,zX.watch)(r,s=>{s==="change"&&this.handleFileChange(t)});this.watchers.push({path:r,watcher:n})}catch(n){this.options.suppressWarnings||console.warn(`Warning: Could not watch ${t}: ${n}`)}}this.options.watchInterval&&this.options.watchInterval>0&&(this.reloadTimer=setInterval(()=>{this.checkForChanges()},this.options.watchInterval))}}handleFileChange(t){console.log(`\u{1F504} Configuration file changed: ${t}`),this.reloadConfiguration()}checkForChanges(){this.getConfigHash()!==this.lastConfigHash&&(console.log("\u{1F504} Configuration change detected"),this.reloadConfiguration())}getConfigHash(){return JSON.stringify(this.config)}reloadConfiguration(){let t={...this.config};try{this.loadEnvironmentFiles(),this.config=this.validateEnvironment(this.schema),this.lastConfigHash=this.getConfigHash(),this.emitConfigChanges(t,this.config),console.log("\u2705 Configuration reloaded successfully")}catch(r){console.error("\u274C Failed to reload configuration:",r),this.emit("configReloadError",r)}}emitConfigChanges(t,r){let n=new Set([...Object.keys(t),...Object.keys(r)]);for(let s of n){let i=t[s],o=r[s];if(i!==o){let a={type:i===void 0?"added":o===void 0?"removed":"modified",variable:s,oldValue:i,newValue:o,timestamp:new Date};this.emit("configChanged",a),this.emit(`configChanged:${s}`,a)}}this.emit("configReloaded",{oldConfig:t,newConfig:r,timestamp:new Date})}stopWatching(){for(let{watcher:t}of this.watchers)t.close();this.watchers=[],this.reloadTimer&&(clearInterval(this.reloadTimer),this.reloadTimer=void 0)}reload(){this.reloadConfiguration()}loadEnvironmentFiles(){if(!(!this.options.loadEnvFiles||!this.options.envFiles))for(let t of this.options.envFiles)try{let r=(0,GX.config)({path:(0,yR.resolve)(process.cwd(),t)});r.error&&!this.options.suppressWarnings&&console.warn(`Warning: Could not load ${t}: ${r.error.message}`)}catch(r){if(r instanceof Error&&r.message.includes("ENOENT"))continue;this.options.suppressWarnings||console.warn(`Warning: Error loading ${t}: ${r}`)}}get(t){return this.config[t]}getRequired(t,r){let n=this.config[t];if(n==null){let s=r?` for ${r}`:"";throw new Zh(`${String(t)} environment variable is required${s}`,[String(t)],[],r)}return n}getAll(){return{...this.config}}validateStartup(){if(this.schema)try{this.schema.parse(process.env)}catch(t){if(t instanceof nr.ZodError){let r=[],n=[];for(let o of t.errors){let a=o.path.join("."),c=process.env[a]||"undefined";o.code==="invalid_type"&&o.received==="undefined"?r.push(a):n.push({name:a,value:c,expected:"valid value",received:o.message||"invalid value"})}let s=r.length>0?`
|
|
246
246
|
Missing required variables: ${r.join(", ")}`:"",i=n.length>0?`
|
|
247
247
|
Invalid variables: ${n.map(o=>`${o.name} (expected ${o.expected}, got '${o.value}')`).join(", ")}`:"";throw new Zh(`Environment validation failed at startup.${s}${i}`,r,n)}throw t}}get stage(){let t=this.config.STAGE;return typeof t=="string"?t:"dev"}get isProduction(){return this.stage==="prod"}get isDevelopment(){return this.stage==="dev"}get isTest(){return this.stage==="test"}validateEnvironment(t){try{return t?t.parse(process.env):process.env}catch(r){if(r instanceof nr.ZodError){let n=[],s=[];for(let a of r.errors){let c=a.path.join("."),u=process.env[c]||"undefined";a.code==="invalid_type"&&a.received==="undefined"?n.push(c):s.push({name:c,value:u,expected:"valid value",received:a.message||"invalid value"})}let i=n.length>0?`
|
|
248
248
|
Missing required variables: ${n.join(", ")}`:"",o=s.length>0?`
|
|
@@ -406,7 +406,7 @@ ${o}`)};var kle=require("node:child_process"),Lle=()=>{try{return(0,kle.execFile
|
|
|
406
406
|
`,i},Int=e=>{let t=process.env.GITHUB_STEP_SUMMARY;if(!t)return!1;try{return w6.appendFileSync(t,e),!0}catch(r){return console.error("Failed to write GitHub step summary:",r),!1}},Hle=(e,t,r,n)=>{let s=Ant(e,t);for(let a of s)console.log(a);let i=Tnt(e,t,r,n);if(Int(i)||(console.log(`
|
|
407
407
|
--- Job Summary ---`),console.log(i)),process.env.GITHUB_OUTPUT)try{let a=process.env.GITHUB_OUTPUT,c=[`total_issues=${Object.values(r).reduce((u,l)=>u+l,0)}`,`critical_issues=${r.CRITICAL}`,`high_issues=${r.HIGH}`,`has_critical=${r.CRITICAL>0}`];w6.appendFileSync(a,`${c.join(`
|
|
408
408
|
`)}
|
|
409
|
-
`)}catch(a){console.error("Failed to write GitHub outputs:",a)}};var Vle=(e,t,r,n,s)=>{switch(Ae.info(`Generating output in format: ${e}`),e){case"markdown":{let i=If(t,r,s,n),o=`${t}_analysis_report.md`;try{A6.writeFileSync(o,i),Ae.info(`\u{1F4C4} Saved Markdown report to ${o}`)}catch(a){let c=a instanceof Error?a.message:String(a);throw Ae.error(`\u274C Failed to write Markdown report to ${o}: ${c}`),new Error(`Failed to write Markdown report: ${c}`)}break}case"table":{AD(r);break}case"json":qle(t,s,r),Ae.info(`\u{1F4C4} JSON report written to: ${t}_analysis_report.json`);break;case"sarif":{let i=zle(t,r),o=`${t}_analysis_report.sarif`;try{A6.writeFileSync(o,JSON.stringify(i,null,2)),Ae.info(`\u{1F4C4} SARIF report written to: ${o}`),console.log(JSON.stringify(i,null,2))}catch(a){let c=a instanceof Error?a.message:String(a);throw Ae.error(`\u274C Failed to write SARIF report to ${o}: ${c}`),new Error(`Failed to write SARIF report: ${c}`)}break}case"github-actions":{Hle(t,r,s.severityCounts,s.totalResources);break}default:wD(t,s);break}};var T6=(e,t,r)=>{let n=0,s=0,i={CRITICAL:0,HIGH:0,MEDIUM:0,LOW:0},o={"Operational Excellence":0,Security:0,"Cost Optimization":0,Reliability:0,"Performance Efficiency":0,Sustainability:0};for(let u in e){let l=[...e[u].sources.cdkInsights?.issues??[],...e[u].sources.cdkNag?.issues??[]],d=!r||r.has(u);l.length>0&&d&&s++,n+=l.length;for(let p of l)i[p.severity]+=1,o[p.wafPillar]+=1}let a=t,c=Number.parseFloat((s/a*100).toFixed(1));return{totalResources:a,resourcesWithIssues:s,percentWithIssues:c,totalIssues:n,severityCounts:i,wafIssues:o,generatedBy:"cdk-insights",generatedAt:new Date().toISOString()}};var Kle=A(require("node:crypto")),Jle=e=>Kle.createHash("sha256").update(JSON.stringify(e)).digest("hex");var Pnt=[/depends\s*on.*(?:not\s*(?:be\s*)?available|may\s*not\s*exist|circular)/i,/dependson.*relationship/i,/resource.*depends.*another.*resource/i,/dependency.*(?:not\s*)?(?:be\s*)?ready/i,/lacks?\s*(?:meaningful\s*)?tags?(?:\s*for)?/i,/missing.*tags?.*(?:metadata|identification)/i,/no\s*tags?\s*(?:defined|configured|specified)/i,/\[redacted\].*(?:incomplete|invalid|malformed|missing)/i,/incomplete.*\[redacted\]/i,/placeholder.*value/i,/missing.*closing.*brace/i,/cdk.*metadata.*exposed/i,/metadata.*cdk.*path/i],Rnt=[/tags?/i,/naming\s*convention/i,/resource\s*name.*not.*descriptive/i,/lacks?\s*description/i,/missing\s*description/i],Fnt=e=>Pnt.some(t=>t.test(e)),Ont=e=>Rnt.some(t=>t.test(e)),Zle=(e,t=!1)=>e.filter(r=>{let n=r.issue||"";return!(Fnt(n)||t&&Ont(n))});var Yle=({staticRecommendations:e,aiRecommendations:t,recommendationMap:r,ruleFilter:n,filterIssuesByRule:s,_displayNameMap:i={}})=>{let o={...r};for(let[d,{issues:p}]of Object.entries(e))o[d]&&o[d].sources.cdkInsights.issues.push(...p);let a=0,c=0,u=0,l=0;for(let[d,p]of Object.entries(t)){if(!p||!Array.isArray(p.issues)){Ae.warn(`\u26A0\uFE0F No AI issues for resource '${d}', skipping.`);continue}let f=d;if(!o[f]){Ae.warn(`\u26A0\uFE0F AI recommendations for unknown resource '${f}', skipping enrichment.`);continue}let m=o[f],g=n.length>0?s(p.issues,n):p.issues,x=Zle(g,m.isGenerated).map(D=>{switch(D.severity||(Ae.debug(`AI recommendation missing severity for resource '${f}', defaulting to MEDIUM`),D.severity="MEDIUM"),D.severity.toUpperCase()){case"CRITICAL":a++;break;case"HIGH":c++;break;case"MEDIUM":u++;break;case"LOW":l++;break;default:Ae.warn(`\u26A0\uFE0F Unknown severity '${D.severity}' for resource '${f}', defaulting to MEDIUM`),D.severity="MEDIUM",u++;break}return{resourceName:D.resourceName||m.resourceName,resourceId:f,friendlyName:m.friendlyName,displayName:m.displayName,locationHint:D.locationHint||m.locationHint,constructPath:m.cdkPath,githubUrl:m.githubUrl,docUrl:m.docUrl,issue:D.issue||"AI analysis issue",recommendation:D.recommendation||"No specific recommendation provided",severity:D.severity,wafPillar:(()=>{if(D.wafPillar)switch(D.wafPillar.toLowerCase().trim()){case"security":return"Security";case"operational excellence":return"Operational Excellence";case"cost optimization":return"Cost Optimization";case"reliability":return"Reliability";case"performance efficiency":return"Performance Efficiency";case"sustainability":return"Sustainability";default:return"Security"}return"Security"})(),codeSnippet:D.codeSnippet||"",foundBy:D.foundBy??"cdkInsights"}}),v=gD(x,m.cdkPath);m.sources.cdkInsights.issues.push(...v)}return{updatedMap:o,criticalCount:a,highCount:c,mediumCount:u,lowCount:l}};var Qle=e=>{if(!e||e.length===0)return 0;let t=e.length,r=new Map;for(let s of e)r.set(s,(r.get(s)||0)+1);let n=0;for(let s of r.values()){let i=s/t;n-=i*Math.log2(i)}return n},I6=(e,t=!1)=>{if(e.length<16||knt(e)||Qle(e)<(t?4:4.5))return!1;let s=/[A-Z]/.test(e),i=/[a-z]/.test(e),o=/[0-9]/.test(e),a=/[^A-Za-z0-9]/.test(e),c=[s,i,o,a].filter(Boolean).length;return t?c>=1:c>=2},knt=e=>{if(/^https?:\/\//i.test(e)||/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(e)||/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e)||/^arn:aws[a-z-]*:[a-z0-9-]+:[a-z0-9-]*:\d*:/.test(e)||/^(\/|\.\/|\.\.\/|[A-Za-z]:\\)/.test(e)||/^s3:\/\/[a-z0-9.-]+\//.test(e))return!0;if(/^[A-Za-z0-9+/]{4,}={0,2}$/.test(e)){let t=new Set(e).size;if(e.length>50&&t<10)return!0}return!!Lnt(e)},Lnt=e=>{let t=e.length;for(let r=1;r<=t/2;r++)if(e.slice(0,r).repeat(Math.ceil(t/r)).slice(0,t)===e)return!0;return!1};var Nnt=[/api[_-]?key/i,/secret[_-]?key/i,/^password$/i,/^passwd$/i,/credential/i,/private[_-]?key/i,/access[_-]?key/i,/auth[_-]?token/i,/bearer[_-]?token/i,/refresh[_-]?token/i,/client[_-]?secret/i,/app[_-]?secret/i,/secret[_-]?value/i,/aws[_-]?secret/i,/aws[_-]?access[_-]?key/i,/aws[_-]?session[_-]?token/i,/db[_-]?password/i,/database[_-]?password/i,/master[_-]?password/i,/master[_-]?user[_-]?password/i,/admin[_-]?password/i,/root[_-]?password/i,/connection[_-]?string/i,/stripe[_-]?key/i,/stripe[_-]?secret/i,/github[_-]?token/i,/gitlab[_-]?token/i,/slack[_-]?token/i,/slack[_-]?webhook/i,/discord[_-]?token/i,/twilio[_-]?token/i,/sendgrid[_-]?key/i,/mailgun[_-]?key/i,/datadog[_-]?key/i,/new[_-]?relic[_-]?key/i,/sentry[_-]?dsn/i,/webhook[_-]?secret/i,/signing[_-]?key/i,/signing[_-]?secret/i,/encryption[_-]?key/i,/jwt[_-]?secret/i,/hmac[_-]?key/i,/ssh[_-]?key/i,/ssh[_-]?private/i,/pem[_-]?key/i,/rsa[_-]?key/i],Mnt=[/^A[BGIK-Z][A-Z]{2}[0-9A-Z]{16}$/,/^[A-Za-z0-9/+=]{40}$/,/-----BEGIN (RSA |EC |DSA |OPENSSH |ENCRYPTED )?PRIVATE KEY-----/,/-----BEGIN PGP PRIVATE KEY BLOCK-----/,/^eyJ[A-Za-z0-9_-]+\.eyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+$/,/^gh[pousr]_[A-Za-z0-9]{36,}$/,/^[srp]k_(live|test)_[A-Za-z0-9]{24,}$/,/^xox[bpas]-[A-Za-z0-9-]+$/,/^SK[a-f0-9]{32}$/i,/^SG\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+$/],jnt=[/\{\{resolve:secretsmanager:/,/{{resolve:secretsmanager:/,/\{\{resolve:ssm:/,/{{resolve:ssm:/,/\{\{resolve:ssm-secure:/,/{{resolve:ssm-secure:/,/!Ref\s+\w+/,/!GetAtt\s+[\w.]+/,/!Sub\s+/,/\$\{[\w:.]+\}/,/\$\{Token\[/,/\[\[token:/i,/\${Token\[TOKEN\.\d+\]\}/,/^arn:aws[a-z-]*:[a-z0-9-]+:[a-z0-9-]*:\d*:/],Bnt=[/^<[^>]+>$/,/^CHANGE[_-]?ME$/i,/^REPLACE[_-]?ME$/i,/^TODO$/i,/^TODO:/i,/^FIXME$/i,/^XXX$/i,/^YOUR[_-]/i,/^INSERT[_-]/i,/^ENTER[_-]/i,/^\*+$/,/^x+$/i,/^\s*$/,/^default$/i,/^example$/i,/^sample$/i,/^test$/i,/^demo$/i,/^dummy$/i,/^fake$/i,/^mock$/i,/^placeholder$/i],P6=e=>Nnt.some(t=>t.test(e)),R6=e=>Mnt.some(t=>t.test(e)),F6=e=>jnt.some(t=>t.test(e)),O6=e=>Bnt.some(t=>t.test(e)),TD=e=>{if(typeof e!="object"||e===null)return!1;let t=["Ref","Fn::GetAtt","Fn::Sub","Fn::Join","Fn::ImportValue","Fn::If","Fn::Select","Fn::Split","Fn::Base64","Fn::Cidr","Fn::FindInMap","Fn::GetAZs","Fn::Transform"],r=Object.keys(e);return r.length===1&&t.includes(r[0])},k6=e=>{let t=[{patterns:[/api[_-]?key/i,/access[_-]?key/i],category:"api_key"},{patterns:[/password/i,/passwd/i],category:"password"},{patterns:[/private[_-]?key/i,/ssh[_-]?key/i,/pem[_-]?key/i,/rsa[_-]?key/i],category:"private_key"},{patterns:[/aws[_-]?secret/i,/aws[_-]?access/i],category:"aws_credentials"},{patterns:[/token/i,/bearer/i],category:"token"},{patterns:[/secret/i,/credential/i],category:"secret"},{patterns:[/connection[_-]?string/i,/database/i,/db[_-]/i],category:"database"},{patterns:[/webhook/i,/signing/i,/encryption/i,/hmac/i,/jwt/i],category:"encryption_key"}];for(let{patterns:r,category:n}of t)if(r.some(s=>s.test(e)))return n;return"secret"};var zg=e=>{let t={api_key:`Use AWS Secrets Manager to store API keys securely:
|
|
409
|
+
`)}catch(a){console.error("Failed to write GitHub outputs:",a)}};var Vle=(e,t,r,n,s)=>{switch(Ae.info(`Generating output in format: ${e}`),e){case"markdown":{let i=If(t,r,s,n),o=`${t}_analysis_report.md`;try{A6.writeFileSync(o,i),Ae.info(`\u{1F4C4} Saved Markdown report to ${o}`)}catch(a){let c=a instanceof Error?a.message:String(a);throw Ae.error(`\u274C Failed to write Markdown report to ${o}: ${c}`),new Error(`Failed to write Markdown report: ${c}`)}break}case"table":{AD(r);break}case"json":qle(t,s,r),Ae.info(`\u{1F4C4} JSON report written to: ${t}_analysis_report.json`);break;case"sarif":{let i=zle(t,r),o=`${t}_analysis_report.sarif`;try{A6.writeFileSync(o,JSON.stringify(i,null,2)),Ae.info(`\u{1F4C4} SARIF report written to: ${o}`),console.log(JSON.stringify(i,null,2))}catch(a){let c=a instanceof Error?a.message:String(a);throw Ae.error(`\u274C Failed to write SARIF report to ${o}: ${c}`),new Error(`Failed to write SARIF report: ${c}`)}break}case"github-actions":{Hle(t,r,s.severityCounts,s.totalResources);break}default:wD(t,s);break}};var T6=(e,t,r)=>{let n=0,s=0,i={CRITICAL:0,HIGH:0,MEDIUM:0,LOW:0},o={"Operational Excellence":0,Security:0,"Cost Optimization":0,Reliability:0,"Performance Efficiency":0,Sustainability:0};for(let u in e){let l=[...e[u].sources.cdkInsights?.issues??[],...e[u].sources.cdkNag?.issues??[]],d=!r||r.has(u);l.length>0&&d&&s++,n+=l.length;for(let p of l)i[p.severity]+=1,o[p.wafPillar]+=1}let a=t,c=Number.parseFloat((s/a*100).toFixed(1));return{totalResources:a,resourcesWithIssues:s,percentWithIssues:c,totalIssues:n,severityCounts:i,wafIssues:o,generatedBy:"cdk-insights",generatedAt:new Date().toISOString()}};var Kle=A(require("node:crypto")),Jle=e=>Kle.createHash("sha256").update(JSON.stringify(e)).digest("hex");var Pnt=[/depends\s*on.*(?:not\s*(?:be\s*)?available|may\s*not\s*exist|circular)/i,/dependson.*relationship/i,/resource.*depends.*another.*resource/i,/dependency.*(?:not\s*)?(?:be\s*)?ready/i,/lacks?\s*(?:meaningful\s*)?tags?(?:\s*for)?/i,/missing.*tags?.*(?:metadata|identification)/i,/no\s*tags?\s*(?:defined|configured|specified)/i,/\[redacted\].*(?:incomplete|invalid|malformed|missing)/i,/incomplete.*\[redacted\]/i,/placeholder.*value/i,/missing.*closing.*brace/i,/replac(?:e|ing).*\[redacted\]/i,/\[redacted\].*(?:should|could|must)\s*be/i,/trust.*policy.*any.*service.*\[redacted\]/i,/any.*service.*within.*account.*\[redacted\]/i,/cdk.*metadata.*exposed/i,/metadata.*cdk.*path/i],Rnt=[/tags?/i,/naming\s*convention/i,/resource\s*name.*not.*descriptive/i,/lacks?\s*description/i,/missing\s*description/i],Fnt=e=>Pnt.some(t=>t.test(e)),Ont=e=>Rnt.some(t=>t.test(e)),Zle=(e,t=!1)=>e.filter(r=>{let n=r.issue||"";return!(Fnt(n)||t&&Ont(n))});var Yle=({staticRecommendations:e,aiRecommendations:t,recommendationMap:r,ruleFilter:n,filterIssuesByRule:s,_displayNameMap:i={}})=>{let o={...r};for(let[d,{issues:p}]of Object.entries(e))o[d]&&o[d].sources.cdkInsights.issues.push(...p);let a=0,c=0,u=0,l=0;for(let[d,p]of Object.entries(t)){if(!p||!Array.isArray(p.issues)){Ae.warn(`\u26A0\uFE0F No AI issues for resource '${d}', skipping.`);continue}let f=d;if(!o[f]){Ae.warn(`\u26A0\uFE0F AI recommendations for unknown resource '${f}', skipping enrichment.`);continue}let m=o[f],g=n.length>0?s(p.issues,n):p.issues,x=Zle(g,m.isGenerated).map(D=>{switch(D.severity||(Ae.debug(`AI recommendation missing severity for resource '${f}', defaulting to MEDIUM`),D.severity="MEDIUM"),D.severity.toUpperCase()){case"CRITICAL":a++;break;case"HIGH":c++;break;case"MEDIUM":u++;break;case"LOW":l++;break;default:Ae.warn(`\u26A0\uFE0F Unknown severity '${D.severity}' for resource '${f}', defaulting to MEDIUM`),D.severity="MEDIUM",u++;break}return{resourceName:D.resourceName||m.resourceName,resourceId:f,friendlyName:m.friendlyName,displayName:m.displayName,locationHint:D.locationHint||m.locationHint,constructPath:m.cdkPath,githubUrl:m.githubUrl,docUrl:m.docUrl,issue:D.issue||"AI analysis issue",recommendation:D.recommendation||"No specific recommendation provided",severity:D.severity,wafPillar:(()=>{if(D.wafPillar)switch(D.wafPillar.toLowerCase().trim()){case"security":return"Security";case"operational excellence":return"Operational Excellence";case"cost optimization":return"Cost Optimization";case"reliability":return"Reliability";case"performance efficiency":return"Performance Efficiency";case"sustainability":return"Sustainability";default:return"Security"}return"Security"})(),codeSnippet:D.codeSnippet||"",foundBy:D.foundBy??"cdkInsights"}}),v=gD(x,m.cdkPath);m.sources.cdkInsights.issues.push(...v)}return{updatedMap:o,criticalCount:a,highCount:c,mediumCount:u,lowCount:l}};var Qle=e=>{if(!e||e.length===0)return 0;let t=e.length,r=new Map;for(let s of e)r.set(s,(r.get(s)||0)+1);let n=0;for(let s of r.values()){let i=s/t;n-=i*Math.log2(i)}return n},I6=(e,t=!1)=>{if(e.length<16||knt(e)||Qle(e)<(t?4:4.5))return!1;let s=/[A-Z]/.test(e),i=/[a-z]/.test(e),o=/[0-9]/.test(e),a=/[^A-Za-z0-9]/.test(e),c=[s,i,o,a].filter(Boolean).length;return t?c>=1:c>=2},knt=e=>{if(/^https?:\/\//i.test(e)||/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(e)||/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e)||/^arn:aws[a-z-]*:[a-z0-9-]+:[a-z0-9-]*:\d*:/.test(e)||/^(\/|\.\/|\.\.\/|[A-Za-z]:\\)/.test(e)||/^s3:\/\/[a-z0-9.-]+\//.test(e))return!0;if(/^[A-Za-z0-9+/]{4,}={0,2}$/.test(e)){let t=new Set(e).size;if(e.length>50&&t<10)return!0}return!!Lnt(e)},Lnt=e=>{let t=e.length;for(let r=1;r<=t/2;r++)if(e.slice(0,r).repeat(Math.ceil(t/r)).slice(0,t)===e)return!0;return!1};var Nnt=[/api[_-]?key/i,/secret[_-]?key/i,/^password$/i,/^passwd$/i,/credential/i,/private[_-]?key/i,/access[_-]?key/i,/auth[_-]?token/i,/bearer[_-]?token/i,/refresh[_-]?token/i,/client[_-]?secret/i,/app[_-]?secret/i,/secret[_-]?value/i,/aws[_-]?secret/i,/aws[_-]?access[_-]?key/i,/aws[_-]?session[_-]?token/i,/db[_-]?password/i,/database[_-]?password/i,/master[_-]?password/i,/master[_-]?user[_-]?password/i,/admin[_-]?password/i,/root[_-]?password/i,/connection[_-]?string/i,/stripe[_-]?key/i,/stripe[_-]?secret/i,/github[_-]?token/i,/gitlab[_-]?token/i,/slack[_-]?token/i,/slack[_-]?webhook/i,/discord[_-]?token/i,/twilio[_-]?token/i,/sendgrid[_-]?key/i,/mailgun[_-]?key/i,/datadog[_-]?key/i,/new[_-]?relic[_-]?key/i,/sentry[_-]?dsn/i,/webhook[_-]?secret/i,/signing[_-]?key/i,/signing[_-]?secret/i,/encryption[_-]?key/i,/jwt[_-]?secret/i,/hmac[_-]?key/i,/ssh[_-]?key/i,/ssh[_-]?private/i,/pem[_-]?key/i,/rsa[_-]?key/i],Mnt=[/^A[BGIK-Z][A-Z]{2}[0-9A-Z]{16}$/,/^[A-Za-z0-9/+=]{40}$/,/-----BEGIN (RSA |EC |DSA |OPENSSH |ENCRYPTED )?PRIVATE KEY-----/,/-----BEGIN PGP PRIVATE KEY BLOCK-----/,/^eyJ[A-Za-z0-9_-]+\.eyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+$/,/^gh[pousr]_[A-Za-z0-9]{36,}$/,/^[srp]k_(live|test)_[A-Za-z0-9]{24,}$/,/^xox[bpas]-[A-Za-z0-9-]+$/,/^SK[a-f0-9]{32}$/i,/^SG\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+$/],jnt=[/\{\{resolve:secretsmanager:/,/{{resolve:secretsmanager:/,/\{\{resolve:ssm:/,/{{resolve:ssm:/,/\{\{resolve:ssm-secure:/,/{{resolve:ssm-secure:/,/!Ref\s+\w+/,/!GetAtt\s+[\w.]+/,/!Sub\s+/,/\$\{[\w:.]+\}/,/\$\{Token\[/,/\[\[token:/i,/\${Token\[TOKEN\.\d+\]\}/,/^arn:aws[a-z-]*:[a-z0-9-]+:[a-z0-9-]*:\d*:/],Bnt=[/^<[^>]+>$/,/^CHANGE[_-]?ME$/i,/^REPLACE[_-]?ME$/i,/^TODO$/i,/^TODO:/i,/^FIXME$/i,/^XXX$/i,/^YOUR[_-]/i,/^INSERT[_-]/i,/^ENTER[_-]/i,/^\*+$/,/^x+$/i,/^\s*$/,/^default$/i,/^example$/i,/^sample$/i,/^test$/i,/^demo$/i,/^dummy$/i,/^fake$/i,/^mock$/i,/^placeholder$/i],P6=e=>Nnt.some(t=>t.test(e)),R6=e=>Mnt.some(t=>t.test(e)),F6=e=>jnt.some(t=>t.test(e)),O6=e=>Bnt.some(t=>t.test(e)),TD=e=>{if(typeof e!="object"||e===null)return!1;let t=["Ref","Fn::GetAtt","Fn::Sub","Fn::Join","Fn::ImportValue","Fn::If","Fn::Select","Fn::Split","Fn::Base64","Fn::Cidr","Fn::FindInMap","Fn::GetAZs","Fn::Transform"],r=Object.keys(e);return r.length===1&&t.includes(r[0])},k6=e=>{let t=[{patterns:[/api[_-]?key/i,/access[_-]?key/i],category:"api_key"},{patterns:[/password/i,/passwd/i],category:"password"},{patterns:[/private[_-]?key/i,/ssh[_-]?key/i,/pem[_-]?key/i,/rsa[_-]?key/i],category:"private_key"},{patterns:[/aws[_-]?secret/i,/aws[_-]?access/i],category:"aws_credentials"},{patterns:[/token/i,/bearer/i],category:"token"},{patterns:[/secret/i,/credential/i],category:"secret"},{patterns:[/connection[_-]?string/i,/database/i,/db[_-]/i],category:"database"},{patterns:[/webhook/i,/signing/i,/encryption/i,/hmac/i,/jwt/i],category:"encryption_key"}];for(let{patterns:r,category:n}of t)if(r.some(s=>s.test(e)))return n;return"secret"};var zg=e=>{let t={api_key:`Use AWS Secrets Manager to store API keys securely:
|
|
410
410
|
|
|
411
411
|
// CDK TypeScript example:
|
|
412
412
|
import { Secret } from 'aws-cdk-lib/aws-secretsmanager';
|
package/dist/index.js
CHANGED
|
@@ -296,7 +296,7 @@ ${i}`)};var L4=require("node:child_process"),N4=()=>{try{return(0,L4.execFileSyn
|
|
|
296
296
|
`,o},aDe=e=>{let t=process.env.GITHUB_STEP_SUMMARY;if(!t)return!1;try{return y0.appendFileSync(t,e),!0}catch(r){return console.error("Failed to write GitHub step summary:",r),!1}},HH=(e,t,r,s)=>{let n=oDe(e,t);for(let a of n)console.log(a);let o=iDe(e,t,r,s);if(aDe(o)||(console.log(`
|
|
297
297
|
--- Job Summary ---`),console.log(o)),process.env.GITHUB_OUTPUT)try{let a=process.env.GITHUB_OUTPUT,c=[`total_issues=${Object.values(r).reduce((u,l)=>u+l,0)}`,`critical_issues=${r.CRITICAL}`,`high_issues=${r.HIGH}`,`has_critical=${r.CRITICAL>0}`];y0.appendFileSync(a,`${c.join(`
|
|
298
298
|
`)}
|
|
299
|
-
`)}catch(a){console.error("Failed to write GitHub outputs:",a)}};var zH=(e,t,r,s,n)=>{switch(ae.info(`Generating output in format: ${e}`),e){case"markdown":{let o=Ja(t,r,n,s),i=`${t}_analysis_report.md`;try{v0.writeFileSync(i,o),ae.info(`\u{1F4C4} Saved Markdown report to ${i}`)}catch(a){let c=a instanceof Error?a.message:String(a);throw ae.error(`\u274C Failed to write Markdown report to ${i}: ${c}`),new Error(`Failed to write Markdown report: ${c}`)}break}case"table":{Dg(r);break}case"json":jH(t,n,r),ae.info(`\u{1F4C4} JSON report written to: ${t}_analysis_report.json`);break;case"sarif":{let o=$H(t,r),i=`${t}_analysis_report.sarif`;try{v0.writeFileSync(i,JSON.stringify(o,null,2)),ae.info(`\u{1F4C4} SARIF report written to: ${i}`),console.log(JSON.stringify(o,null,2))}catch(a){let c=a instanceof Error?a.message:String(a);throw ae.error(`\u274C Failed to write SARIF report to ${i}: ${c}`),new Error(`Failed to write SARIF report: ${c}`)}break}case"github-actions":{HH(t,r,n.severityCounts,n.totalResources);break}default:yg(t,n);break}};var b0=(e,t,r)=>{let s=0,n=0,o={CRITICAL:0,HIGH:0,MEDIUM:0,LOW:0},i={"Operational Excellence":0,Security:0,"Cost Optimization":0,Reliability:0,"Performance Efficiency":0,Sustainability:0};for(let u in e){let l=[...e[u].sources.cdkInsights?.issues??[],...e[u].sources.cdkNag?.issues??[]],d=!r||r.has(u);l.length>0&&d&&n++,s+=l.length;for(let m of l)o[m.severity]+=1,i[m.wafPillar]+=1}let a=t,c=Number.parseFloat((n/a*100).toFixed(1));return{totalResources:a,resourcesWithIssues:n,percentWithIssues:c,totalIssues:s,severityCounts:o,wafIssues:i,generatedBy:"cdk-insights",generatedAt:new Date().toISOString()}};var GH=_(require("node:crypto")),qH=e=>GH.createHash("sha256").update(JSON.stringify(e)).digest("hex");var Eg=_(require("node:fs")),VH=_(require("node:path")),KH=e=>{let t=VH.join(e,"manifest.json");if(!Eg.existsSync(t))return{};try{return JSON.parse(Eg.readFileSync(t,"utf-8"))}catch{return{}}};var cDe=[/depends\s*on.*(?:not\s*(?:be\s*)?available|may\s*not\s*exist|circular)/i,/dependson.*relationship/i,/resource.*depends.*another.*resource/i,/dependency.*(?:not\s*)?(?:be\s*)?ready/i,/lacks?\s*(?:meaningful\s*)?tags?(?:\s*for)?/i,/missing.*tags?.*(?:metadata|identification)/i,/no\s*tags?\s*(?:defined|configured|specified)/i,/\[redacted\].*(?:incomplete|invalid|malformed|missing)/i,/incomplete.*\[redacted\]/i,/placeholder.*value/i,/missing.*closing.*brace/i,/cdk.*metadata.*exposed/i,/metadata.*cdk.*path/i],uDe=[/tags?/i,/naming\s*convention/i,/resource\s*name.*not.*descriptive/i,/lacks?\s*description/i,/missing\s*description/i],lDe=e=>cDe.some(t=>t.test(e)),dDe=e=>uDe.some(t=>t.test(e)),JH=(e,t=!1)=>e.filter(r=>{let s=r.issue||"";return!(lDe(s)||t&&dDe(s))});var ZH=({staticRecommendations:e,aiRecommendations:t,recommendationMap:r,ruleFilter:s,filterIssuesByRule:n,_displayNameMap:o={}})=>{let i={...r};for(let[d,{issues:m}]of Object.entries(e))i[d]&&i[d].sources.cdkInsights.issues.push(...m);let a=0,c=0,u=0,l=0;for(let[d,m]of Object.entries(t)){if(!m||!Array.isArray(m.issues)){ae.warn(`\u26A0\uFE0F No AI issues for resource '${d}', skipping.`);continue}let p=d;if(!i[p]){ae.warn(`\u26A0\uFE0F AI recommendations for unknown resource '${p}', skipping enrichment.`);continue}let f=i[p],g=s.length>0?n(m.issues,s):m.issues,S=JH(g,f.isGenerated).map(w=>{switch(w.severity||(ae.debug(`AI recommendation missing severity for resource '${p}', defaulting to MEDIUM`),w.severity="MEDIUM"),w.severity.toUpperCase()){case"CRITICAL":a++;break;case"HIGH":c++;break;case"MEDIUM":u++;break;case"LOW":l++;break;default:ae.warn(`\u26A0\uFE0F Unknown severity '${w.severity}' for resource '${p}', defaulting to MEDIUM`),w.severity="MEDIUM",u++;break}return{resourceName:w.resourceName||f.resourceName,resourceId:p,friendlyName:f.friendlyName,displayName:f.displayName,locationHint:w.locationHint||f.locationHint,constructPath:f.cdkPath,githubUrl:f.githubUrl,docUrl:f.docUrl,issue:w.issue||"AI analysis issue",recommendation:w.recommendation||"No specific recommendation provided",severity:w.severity,wafPillar:(()=>{if(w.wafPillar)switch(w.wafPillar.toLowerCase().trim()){case"security":return"Security";case"operational excellence":return"Operational Excellence";case"cost optimization":return"Cost Optimization";case"reliability":return"Reliability";case"performance efficiency":return"Performance Efficiency";case"sustainability":return"Sustainability";default:return"Security"}return"Security"})(),codeSnippet:w.codeSnippet||"",foundBy:w.foundBy??"cdkInsights"}}),b=tg(S,f.cdkPath);f.sources.cdkInsights.issues.push(...b)}return{updatedMap:i,criticalCount:a,highCount:c,mediumCount:u,lowCount:l}};var YH=e=>{if(!e||e.length===0)return 0;let t=e.length,r=new Map;for(let n of e)r.set(n,(r.get(n)||0)+1);let s=0;for(let n of r.values()){let o=n/t;s-=o*Math.log2(o)}return s},S0=(e,t=!1)=>{if(e.length<16||pDe(e)||YH(e)<(t?4:4.5))return!1;let n=/[A-Z]/.test(e),o=/[a-z]/.test(e),i=/[0-9]/.test(e),a=/[^A-Za-z0-9]/.test(e),c=[n,o,i,a].filter(Boolean).length;return t?c>=1:c>=2},pDe=e=>{if(/^https?:\/\//i.test(e)||/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(e)||/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e)||/^arn:aws[a-z-]*:[a-z0-9-]+:[a-z0-9-]*:\d*:/.test(e)||/^(\/|\.\/|\.\.\/|[A-Za-z]:\\)/.test(e)||/^s3:\/\/[a-z0-9.-]+\//.test(e))return!0;if(/^[A-Za-z0-9+/]{4,}={0,2}$/.test(e)){let t=new Set(e).size;if(e.length>50&&t<10)return!0}return!!mDe(e)},mDe=e=>{let t=e.length;for(let r=1;r<=t/2;r++)if(e.slice(0,r).repeat(Math.ceil(t/r)).slice(0,t)===e)return!0;return!1};var fDe=[/api[_-]?key/i,/secret[_-]?key/i,/^password$/i,/^passwd$/i,/credential/i,/private[_-]?key/i,/access[_-]?key/i,/auth[_-]?token/i,/bearer[_-]?token/i,/refresh[_-]?token/i,/client[_-]?secret/i,/app[_-]?secret/i,/secret[_-]?value/i,/aws[_-]?secret/i,/aws[_-]?access[_-]?key/i,/aws[_-]?session[_-]?token/i,/db[_-]?password/i,/database[_-]?password/i,/master[_-]?password/i,/master[_-]?user[_-]?password/i,/admin[_-]?password/i,/root[_-]?password/i,/connection[_-]?string/i,/stripe[_-]?key/i,/stripe[_-]?secret/i,/github[_-]?token/i,/gitlab[_-]?token/i,/slack[_-]?token/i,/slack[_-]?webhook/i,/discord[_-]?token/i,/twilio[_-]?token/i,/sendgrid[_-]?key/i,/mailgun[_-]?key/i,/datadog[_-]?key/i,/new[_-]?relic[_-]?key/i,/sentry[_-]?dsn/i,/webhook[_-]?secret/i,/signing[_-]?key/i,/signing[_-]?secret/i,/encryption[_-]?key/i,/jwt[_-]?secret/i,/hmac[_-]?key/i,/ssh[_-]?key/i,/ssh[_-]?private/i,/pem[_-]?key/i,/rsa[_-]?key/i],gDe=[/^A[BGIK-Z][A-Z]{2}[0-9A-Z]{16}$/,/^[A-Za-z0-9/+=]{40}$/,/-----BEGIN (RSA |EC |DSA |OPENSSH |ENCRYPTED )?PRIVATE KEY-----/,/-----BEGIN PGP PRIVATE KEY BLOCK-----/,/^eyJ[A-Za-z0-9_-]+\.eyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+$/,/^gh[pousr]_[A-Za-z0-9]{36,}$/,/^[srp]k_(live|test)_[A-Za-z0-9]{24,}$/,/^xox[bpas]-[A-Za-z0-9-]+$/,/^SK[a-f0-9]{32}$/i,/^SG\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+$/],hDe=[/\{\{resolve:secretsmanager:/,/{{resolve:secretsmanager:/,/\{\{resolve:ssm:/,/{{resolve:ssm:/,/\{\{resolve:ssm-secure:/,/{{resolve:ssm-secure:/,/!Ref\s+\w+/,/!GetAtt\s+[\w.]+/,/!Sub\s+/,/\$\{[\w:.]+\}/,/\$\{Token\[/,/\[\[token:/i,/\${Token\[TOKEN\.\d+\]\}/,/^arn:aws[a-z-]*:[a-z0-9-]+:[a-z0-9-]*:\d*:/],yDe=[/^<[^>]+>$/,/^CHANGE[_-]?ME$/i,/^REPLACE[_-]?ME$/i,/^TODO$/i,/^TODO:/i,/^FIXME$/i,/^XXX$/i,/^YOUR[_-]/i,/^INSERT[_-]/i,/^ENTER[_-]/i,/^\*+$/,/^x+$/i,/^\s*$/,/^default$/i,/^example$/i,/^sample$/i,/^test$/i,/^demo$/i,/^dummy$/i,/^fake$/i,/^mock$/i,/^placeholder$/i],C0=e=>fDe.some(t=>t.test(e)),D0=e=>gDe.some(t=>t.test(e)),E0=e=>hDe.some(t=>t.test(e)),x0=e=>yDe.some(t=>t.test(e)),xg=e=>{if(typeof e!="object"||e===null)return!1;let t=["Ref","Fn::GetAtt","Fn::Sub","Fn::Join","Fn::ImportValue","Fn::If","Fn::Select","Fn::Split","Fn::Base64","Fn::Cidr","Fn::FindInMap","Fn::GetAZs","Fn::Transform"],r=Object.keys(e);return r.length===1&&t.includes(r[0])},_0=e=>{let t=[{patterns:[/api[_-]?key/i,/access[_-]?key/i],category:"api_key"},{patterns:[/password/i,/passwd/i],category:"password"},{patterns:[/private[_-]?key/i,/ssh[_-]?key/i,/pem[_-]?key/i,/rsa[_-]?key/i],category:"private_key"},{patterns:[/aws[_-]?secret/i,/aws[_-]?access/i],category:"aws_credentials"},{patterns:[/token/i,/bearer/i],category:"token"},{patterns:[/secret/i,/credential/i],category:"secret"},{patterns:[/connection[_-]?string/i,/database/i,/db[_-]/i],category:"database"},{patterns:[/webhook/i,/signing/i,/encryption/i,/hmac/i,/jwt/i],category:"encryption_key"}];for(let{patterns:r,category:s}of t)if(r.some(n=>n.test(e)))return s;return"secret"};var Dl=e=>{let t={api_key:`Use AWS Secrets Manager to store API keys securely:
|
|
299
|
+
`)}catch(a){console.error("Failed to write GitHub outputs:",a)}};var zH=(e,t,r,s,n)=>{switch(ae.info(`Generating output in format: ${e}`),e){case"markdown":{let o=Ja(t,r,n,s),i=`${t}_analysis_report.md`;try{v0.writeFileSync(i,o),ae.info(`\u{1F4C4} Saved Markdown report to ${i}`)}catch(a){let c=a instanceof Error?a.message:String(a);throw ae.error(`\u274C Failed to write Markdown report to ${i}: ${c}`),new Error(`Failed to write Markdown report: ${c}`)}break}case"table":{Dg(r);break}case"json":jH(t,n,r),ae.info(`\u{1F4C4} JSON report written to: ${t}_analysis_report.json`);break;case"sarif":{let o=$H(t,r),i=`${t}_analysis_report.sarif`;try{v0.writeFileSync(i,JSON.stringify(o,null,2)),ae.info(`\u{1F4C4} SARIF report written to: ${i}`),console.log(JSON.stringify(o,null,2))}catch(a){let c=a instanceof Error?a.message:String(a);throw ae.error(`\u274C Failed to write SARIF report to ${i}: ${c}`),new Error(`Failed to write SARIF report: ${c}`)}break}case"github-actions":{HH(t,r,n.severityCounts,n.totalResources);break}default:yg(t,n);break}};var b0=(e,t,r)=>{let s=0,n=0,o={CRITICAL:0,HIGH:0,MEDIUM:0,LOW:0},i={"Operational Excellence":0,Security:0,"Cost Optimization":0,Reliability:0,"Performance Efficiency":0,Sustainability:0};for(let u in e){let l=[...e[u].sources.cdkInsights?.issues??[],...e[u].sources.cdkNag?.issues??[]],d=!r||r.has(u);l.length>0&&d&&n++,s+=l.length;for(let m of l)o[m.severity]+=1,i[m.wafPillar]+=1}let a=t,c=Number.parseFloat((n/a*100).toFixed(1));return{totalResources:a,resourcesWithIssues:n,percentWithIssues:c,totalIssues:s,severityCounts:o,wafIssues:i,generatedBy:"cdk-insights",generatedAt:new Date().toISOString()}};var GH=_(require("node:crypto")),qH=e=>GH.createHash("sha256").update(JSON.stringify(e)).digest("hex");var Eg=_(require("node:fs")),VH=_(require("node:path")),KH=e=>{let t=VH.join(e,"manifest.json");if(!Eg.existsSync(t))return{};try{return JSON.parse(Eg.readFileSync(t,"utf-8"))}catch{return{}}};var cDe=[/depends\s*on.*(?:not\s*(?:be\s*)?available|may\s*not\s*exist|circular)/i,/dependson.*relationship/i,/resource.*depends.*another.*resource/i,/dependency.*(?:not\s*)?(?:be\s*)?ready/i,/lacks?\s*(?:meaningful\s*)?tags?(?:\s*for)?/i,/missing.*tags?.*(?:metadata|identification)/i,/no\s*tags?\s*(?:defined|configured|specified)/i,/\[redacted\].*(?:incomplete|invalid|malformed|missing)/i,/incomplete.*\[redacted\]/i,/placeholder.*value/i,/missing.*closing.*brace/i,/replac(?:e|ing).*\[redacted\]/i,/\[redacted\].*(?:should|could|must)\s*be/i,/trust.*policy.*any.*service.*\[redacted\]/i,/any.*service.*within.*account.*\[redacted\]/i,/cdk.*metadata.*exposed/i,/metadata.*cdk.*path/i],uDe=[/tags?/i,/naming\s*convention/i,/resource\s*name.*not.*descriptive/i,/lacks?\s*description/i,/missing\s*description/i],lDe=e=>cDe.some(t=>t.test(e)),dDe=e=>uDe.some(t=>t.test(e)),JH=(e,t=!1)=>e.filter(r=>{let s=r.issue||"";return!(lDe(s)||t&&dDe(s))});var ZH=({staticRecommendations:e,aiRecommendations:t,recommendationMap:r,ruleFilter:s,filterIssuesByRule:n,_displayNameMap:o={}})=>{let i={...r};for(let[d,{issues:m}]of Object.entries(e))i[d]&&i[d].sources.cdkInsights.issues.push(...m);let a=0,c=0,u=0,l=0;for(let[d,m]of Object.entries(t)){if(!m||!Array.isArray(m.issues)){ae.warn(`\u26A0\uFE0F No AI issues for resource '${d}', skipping.`);continue}let p=d;if(!i[p]){ae.warn(`\u26A0\uFE0F AI recommendations for unknown resource '${p}', skipping enrichment.`);continue}let f=i[p],g=s.length>0?n(m.issues,s):m.issues,S=JH(g,f.isGenerated).map(w=>{switch(w.severity||(ae.debug(`AI recommendation missing severity for resource '${p}', defaulting to MEDIUM`),w.severity="MEDIUM"),w.severity.toUpperCase()){case"CRITICAL":a++;break;case"HIGH":c++;break;case"MEDIUM":u++;break;case"LOW":l++;break;default:ae.warn(`\u26A0\uFE0F Unknown severity '${w.severity}' for resource '${p}', defaulting to MEDIUM`),w.severity="MEDIUM",u++;break}return{resourceName:w.resourceName||f.resourceName,resourceId:p,friendlyName:f.friendlyName,displayName:f.displayName,locationHint:w.locationHint||f.locationHint,constructPath:f.cdkPath,githubUrl:f.githubUrl,docUrl:f.docUrl,issue:w.issue||"AI analysis issue",recommendation:w.recommendation||"No specific recommendation provided",severity:w.severity,wafPillar:(()=>{if(w.wafPillar)switch(w.wafPillar.toLowerCase().trim()){case"security":return"Security";case"operational excellence":return"Operational Excellence";case"cost optimization":return"Cost Optimization";case"reliability":return"Reliability";case"performance efficiency":return"Performance Efficiency";case"sustainability":return"Sustainability";default:return"Security"}return"Security"})(),codeSnippet:w.codeSnippet||"",foundBy:w.foundBy??"cdkInsights"}}),b=tg(S,f.cdkPath);f.sources.cdkInsights.issues.push(...b)}return{updatedMap:i,criticalCount:a,highCount:c,mediumCount:u,lowCount:l}};var YH=e=>{if(!e||e.length===0)return 0;let t=e.length,r=new Map;for(let n of e)r.set(n,(r.get(n)||0)+1);let s=0;for(let n of r.values()){let o=n/t;s-=o*Math.log2(o)}return s},S0=(e,t=!1)=>{if(e.length<16||pDe(e)||YH(e)<(t?4:4.5))return!1;let n=/[A-Z]/.test(e),o=/[a-z]/.test(e),i=/[0-9]/.test(e),a=/[^A-Za-z0-9]/.test(e),c=[n,o,i,a].filter(Boolean).length;return t?c>=1:c>=2},pDe=e=>{if(/^https?:\/\//i.test(e)||/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(e)||/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e)||/^arn:aws[a-z-]*:[a-z0-9-]+:[a-z0-9-]*:\d*:/.test(e)||/^(\/|\.\/|\.\.\/|[A-Za-z]:\\)/.test(e)||/^s3:\/\/[a-z0-9.-]+\//.test(e))return!0;if(/^[A-Za-z0-9+/]{4,}={0,2}$/.test(e)){let t=new Set(e).size;if(e.length>50&&t<10)return!0}return!!mDe(e)},mDe=e=>{let t=e.length;for(let r=1;r<=t/2;r++)if(e.slice(0,r).repeat(Math.ceil(t/r)).slice(0,t)===e)return!0;return!1};var fDe=[/api[_-]?key/i,/secret[_-]?key/i,/^password$/i,/^passwd$/i,/credential/i,/private[_-]?key/i,/access[_-]?key/i,/auth[_-]?token/i,/bearer[_-]?token/i,/refresh[_-]?token/i,/client[_-]?secret/i,/app[_-]?secret/i,/secret[_-]?value/i,/aws[_-]?secret/i,/aws[_-]?access[_-]?key/i,/aws[_-]?session[_-]?token/i,/db[_-]?password/i,/database[_-]?password/i,/master[_-]?password/i,/master[_-]?user[_-]?password/i,/admin[_-]?password/i,/root[_-]?password/i,/connection[_-]?string/i,/stripe[_-]?key/i,/stripe[_-]?secret/i,/github[_-]?token/i,/gitlab[_-]?token/i,/slack[_-]?token/i,/slack[_-]?webhook/i,/discord[_-]?token/i,/twilio[_-]?token/i,/sendgrid[_-]?key/i,/mailgun[_-]?key/i,/datadog[_-]?key/i,/new[_-]?relic[_-]?key/i,/sentry[_-]?dsn/i,/webhook[_-]?secret/i,/signing[_-]?key/i,/signing[_-]?secret/i,/encryption[_-]?key/i,/jwt[_-]?secret/i,/hmac[_-]?key/i,/ssh[_-]?key/i,/ssh[_-]?private/i,/pem[_-]?key/i,/rsa[_-]?key/i],gDe=[/^A[BGIK-Z][A-Z]{2}[0-9A-Z]{16}$/,/^[A-Za-z0-9/+=]{40}$/,/-----BEGIN (RSA |EC |DSA |OPENSSH |ENCRYPTED )?PRIVATE KEY-----/,/-----BEGIN PGP PRIVATE KEY BLOCK-----/,/^eyJ[A-Za-z0-9_-]+\.eyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+$/,/^gh[pousr]_[A-Za-z0-9]{36,}$/,/^[srp]k_(live|test)_[A-Za-z0-9]{24,}$/,/^xox[bpas]-[A-Za-z0-9-]+$/,/^SK[a-f0-9]{32}$/i,/^SG\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+$/],hDe=[/\{\{resolve:secretsmanager:/,/{{resolve:secretsmanager:/,/\{\{resolve:ssm:/,/{{resolve:ssm:/,/\{\{resolve:ssm-secure:/,/{{resolve:ssm-secure:/,/!Ref\s+\w+/,/!GetAtt\s+[\w.]+/,/!Sub\s+/,/\$\{[\w:.]+\}/,/\$\{Token\[/,/\[\[token:/i,/\${Token\[TOKEN\.\d+\]\}/,/^arn:aws[a-z-]*:[a-z0-9-]+:[a-z0-9-]*:\d*:/],yDe=[/^<[^>]+>$/,/^CHANGE[_-]?ME$/i,/^REPLACE[_-]?ME$/i,/^TODO$/i,/^TODO:/i,/^FIXME$/i,/^XXX$/i,/^YOUR[_-]/i,/^INSERT[_-]/i,/^ENTER[_-]/i,/^\*+$/,/^x+$/i,/^\s*$/,/^default$/i,/^example$/i,/^sample$/i,/^test$/i,/^demo$/i,/^dummy$/i,/^fake$/i,/^mock$/i,/^placeholder$/i],C0=e=>fDe.some(t=>t.test(e)),D0=e=>gDe.some(t=>t.test(e)),E0=e=>hDe.some(t=>t.test(e)),x0=e=>yDe.some(t=>t.test(e)),xg=e=>{if(typeof e!="object"||e===null)return!1;let t=["Ref","Fn::GetAtt","Fn::Sub","Fn::Join","Fn::ImportValue","Fn::If","Fn::Select","Fn::Split","Fn::Base64","Fn::Cidr","Fn::FindInMap","Fn::GetAZs","Fn::Transform"],r=Object.keys(e);return r.length===1&&t.includes(r[0])},_0=e=>{let t=[{patterns:[/api[_-]?key/i,/access[_-]?key/i],category:"api_key"},{patterns:[/password/i,/passwd/i],category:"password"},{patterns:[/private[_-]?key/i,/ssh[_-]?key/i,/pem[_-]?key/i,/rsa[_-]?key/i],category:"private_key"},{patterns:[/aws[_-]?secret/i,/aws[_-]?access/i],category:"aws_credentials"},{patterns:[/token/i,/bearer/i],category:"token"},{patterns:[/secret/i,/credential/i],category:"secret"},{patterns:[/connection[_-]?string/i,/database/i,/db[_-]/i],category:"database"},{patterns:[/webhook/i,/signing/i,/encryption/i,/hmac/i,/jwt/i],category:"encryption_key"}];for(let{patterns:r,category:s}of t)if(r.some(n=>n.test(e)))return s;return"secret"};var Dl=e=>{let t={api_key:`Use AWS Secrets Manager to store API keys securely:
|
|
300
300
|
|
|
301
301
|
// CDK TypeScript example:
|
|
302
302
|
import { Secret } from 'aws-cdk-lib/aws-secretsmanager';
|
|
@@ -451,7 +451,7 @@ ${i}`)};var L4=require("node:child_process"),N4=()=>{try{return(0,L4.execFileSyn
|
|
|
451
451
|
);
|
|
452
452
|
|
|
453
453
|
See: https://docs.aws.amazon.com/secretsmanager/latest/userguide/intro.html`};return t[e]||t.secret||`Use AWS Secrets Manager or SSM Parameter Store to securely manage this value.
|
|
454
|
-
See: https://docs.aws.amazon.com/secretsmanager/latest/userguide/intro.html`};var El=(e,t)=>{switch(e){case"property_name":return t?`Property name "${t}" suggests this contains sensitive data`:"Property name suggests sensitive data";case"value_pattern":return"Value matches a known secret pattern (API key, token, or credential format)";case"high_entropy":return"Value has high entropy (appears random), which is characteristic of secrets";default:return"Value appears to contain sensitive data"}};var Qa={SEVERITY:"CRITICAL",WAF_PILLAR:"Security",RULE_ID_PREFIX:"CDK-INSIGHTS-SENSITIVE",FOUND_BY:"cdkInsights"};var QH=(e,t,r={})=>{let s=[];return r.disabled?{hasSensitiveData:!1,resourceId:t,resourceType:e.Type,findings:[]}:(e.Properties&&_g(e.Properties,"",s,r),{hasSensitiveData:s.length>0,resourceId:t,resourceType:e.Type,findings:s})},_g=(e,t,r,s)=>{if(e!=null){if(typeof e=="string"){bDe(e,t,r,s);return}if(Array.isArray(e)){e.forEach((n,o)=>{_g(n,`${t}[${o}]`,r,s)});return}if(typeof e=="object"){if(xg(e))return;for(let[n,o]of Object.entries(e)){let i=t?`${t}.${n}`:n;if(!s.ignoreProperties?.includes(i)){if(C0(n)){if(typeof o=="string"){if(!XH(o,s)){let a=_0(n)||"secret";r.push({propertyPath:i,propertyName:n,detectionReason:"property_name",detectionReasonMessage:El("property_name",n),recommendation:Dl(a)})}}else xg(o)||_g(o,i,r,s);continue}_g(o,i,r,s)}}}}},bDe=(e,t,r,s)=>{if(!XH(e,s)){if(D0(e)){let n=t.split(".").pop()??t;r.push({propertyPath:t,propertyName:n,detectionReason:"value_pattern",detectionReasonMessage:El("value_pattern"),recommendation:Dl("secret")});return}if(S0(e,s.strictMode)){let n=t.split(".").pop()??t;r.push({propertyPath:t,propertyName:n,detectionReason:"high_entropy",detectionReasonMessage:El("high_entropy"),recommendation:Dl("secret")})}}},XH=(e,t)=>!!(!e||e.trim()===""||E0(e)||x0(e)||t.allowPatterns?.some(r=>e.includes(r)));var w0=(e,t)=>{let r=e.findings.map(n=>`"${n.propertyName}" at ${n.propertyPath}`).join(", "),s=e.findings.length;return{resourceId:e.resourceId,issue:s===1?`Sensitive data detected: ${r}. This resource was NOT sent to CDK Insights servers.`:`Sensitive data detected in ${s} properties: ${r}. This resource was NOT sent to CDK Insights servers.`,recommendation:"Use AWS Secrets Manager or SSM Parameter Store to securely manage sensitive values. See: https://docs.aws.amazon.com/secretsmanager/latest/userguide/intro.html",severity:Qa.SEVERITY,wafPillar:Qa.WAF_PILLAR,foundBy:Qa.FOUND_BY,constructPath:e.resourceId,constructType:e.resourceType,stackName:t,ruleId:Qa.RULE_ID_PREFIX,context:{property:e.findings.map(n=>n.propertyPath).join(", "),value:"[REDACTED]",expected:"AWS Secrets Manager or SSM Parameter Store reference"}}},A0=(e,t={})=>{let r=[],s=[],n=0;for(let[o,i]of Object.entries(e)){let a=QH(i,o,t);r.push(a),a.hasSensitiveData&&(s.push(o),n+=a.findings.length)}return{totalResourcesScanned:Object.keys(e).length,resourcesWithSensitiveData:s.length,totalFindings:n,hasSkippedResources:s.length>0,skippedResourceIds:s,detectionResults:r}};var ez=e=>{if(!e)return;let t=e.trim();if(t)return t.replace(/\/+$/,"")},tz=e=>{let t=ez(e);return t||(ez("https://api.cdkinsights.dev/
|
|
454
|
+
See: https://docs.aws.amazon.com/secretsmanager/latest/userguide/intro.html`};var El=(e,t)=>{switch(e){case"property_name":return t?`Property name "${t}" suggests this contains sensitive data`:"Property name suggests sensitive data";case"value_pattern":return"Value matches a known secret pattern (API key, token, or credential format)";case"high_entropy":return"Value has high entropy (appears random), which is characteristic of secrets";default:return"Value appears to contain sensitive data"}};var Qa={SEVERITY:"CRITICAL",WAF_PILLAR:"Security",RULE_ID_PREFIX:"CDK-INSIGHTS-SENSITIVE",FOUND_BY:"cdkInsights"};var QH=(e,t,r={})=>{let s=[];return r.disabled?{hasSensitiveData:!1,resourceId:t,resourceType:e.Type,findings:[]}:(e.Properties&&_g(e.Properties,"",s,r),{hasSensitiveData:s.length>0,resourceId:t,resourceType:e.Type,findings:s})},_g=(e,t,r,s)=>{if(e!=null){if(typeof e=="string"){bDe(e,t,r,s);return}if(Array.isArray(e)){e.forEach((n,o)=>{_g(n,`${t}[${o}]`,r,s)});return}if(typeof e=="object"){if(xg(e))return;for(let[n,o]of Object.entries(e)){let i=t?`${t}.${n}`:n;if(!s.ignoreProperties?.includes(i)){if(C0(n)){if(typeof o=="string"){if(!XH(o,s)){let a=_0(n)||"secret";r.push({propertyPath:i,propertyName:n,detectionReason:"property_name",detectionReasonMessage:El("property_name",n),recommendation:Dl(a)})}}else xg(o)||_g(o,i,r,s);continue}_g(o,i,r,s)}}}}},bDe=(e,t,r,s)=>{if(!XH(e,s)){if(D0(e)){let n=t.split(".").pop()??t;r.push({propertyPath:t,propertyName:n,detectionReason:"value_pattern",detectionReasonMessage:El("value_pattern"),recommendation:Dl("secret")});return}if(S0(e,s.strictMode)){let n=t.split(".").pop()??t;r.push({propertyPath:t,propertyName:n,detectionReason:"high_entropy",detectionReasonMessage:El("high_entropy"),recommendation:Dl("secret")})}}},XH=(e,t)=>!!(!e||e.trim()===""||E0(e)||x0(e)||t.allowPatterns?.some(r=>e.includes(r)));var w0=(e,t)=>{let r=e.findings.map(n=>`"${n.propertyName}" at ${n.propertyPath}`).join(", "),s=e.findings.length;return{resourceId:e.resourceId,issue:s===1?`Sensitive data detected: ${r}. This resource was NOT sent to CDK Insights servers.`:`Sensitive data detected in ${s} properties: ${r}. This resource was NOT sent to CDK Insights servers.`,recommendation:"Use AWS Secrets Manager or SSM Parameter Store to securely manage sensitive values. See: https://docs.aws.amazon.com/secretsmanager/latest/userguide/intro.html",severity:Qa.SEVERITY,wafPillar:Qa.WAF_PILLAR,foundBy:Qa.FOUND_BY,constructPath:e.resourceId,constructType:e.resourceType,stackName:t,ruleId:Qa.RULE_ID_PREFIX,context:{property:e.findings.map(n=>n.propertyPath).join(", "),value:"[REDACTED]",expected:"AWS Secrets Manager or SSM Parameter Store reference"}}},A0=(e,t={})=>{let r=[],s=[],n=0;for(let[o,i]of Object.entries(e)){let a=QH(i,o,t);r.push(a),a.hasSensitiveData&&(s.push(o),n+=a.findings.length)}return{totalResourcesScanned:Object.keys(e).length,resourcesWithSensitiveData:s.length,totalFindings:n,hasSkippedResources:s.length>0,skippedResourceIds:s,detectionResults:r}};var ez=e=>{if(!e)return;let t=e.trim();if(t)return t.replace(/\/+$/,"")},tz=e=>{let t=ez(e);return t||(ez("https://api.cdkinsights.dev/v1")??"")};var Xs=require("aws-cdk-lib"),_l=require("cdk-nag"),rs=_(require("node:fs")),yr=_(require("node:path"));var F0="2.2.0",I0="cdk-insights::",P0=()=>process.env.CDK_DEBUG==="true"||(process.env.CDK_CONTEXT_JSON?.includes('"@aws-cdk/core:stackTrace":true')??!1)||(process.env.CDK_CONTEXT_JSON?.includes('"@aws-cdk/core:stackTrace": true')??!1),T0=!1,SDe=()=>{T0||(P0()||rt.info("\u{1F4A1} Tip: Set CDK_DEBUG=true for more accurate source location detection. Run: CDK_DEBUG=true cdk synth"),T0=!0)},Ag=new Map,Xa=new Map,Kn=new Map,CDe=e=>{let o={},i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(let l=0;l<i.length;l++)o[i[l]]=l;let a=[],c=0,u=0;for(let l of e){let d=o[l];if(d!==void 0)if(u+=(d&31)<<c,(d&32)!==0)c+=5;else{let m=u&1;u>>=1,a.push(m?-u:u),u=0,c=0}}return a},DDe=e=>{let t=e;if(Kn.has(t))return Kn.get(t)??null;try{let r=rs.readFileSync(e,"utf-8"),s=r.match(/\/\/# sourceMappingURL=data:application\/json;base64,(.+)$/m);if(s){let i=Buffer.from(s[1],"base64").toString("utf-8"),a=JSON.parse(i);return Kn.set(t,a),a}let n=r.match(/\/\/# sourceMappingURL=(.+)$/m);if(n){let i=yr.resolve(yr.dirname(e),n[1]);if(rs.existsSync(i)){let a=JSON.parse(rs.readFileSync(i,"utf-8"));return Kn.set(t,a),a}}let o=`${e}.map`;if(rs.existsSync(o)){let i=JSON.parse(rs.readFileSync(o,"utf-8"));return Kn.set(t,i),i}}catch{}return Kn.set(t,null),null},EDe=(e,t,r)=>{let s=DDe(e);if(!s)return null;try{let n=s.mappings.split(";");if(t>n.length)return null;let o=0,i=0,a=0,c=0;for(let p=0;p<=Math.min(t-1,n.length-1);p++){let f=n[p].split(","),g=0;for(let h of f){if(!h)continue;let S=CDe(h);if(S.length!==0&&(g+=S[0],S.length>=4&&(o+=S[1],i+=S[2],a+=S[3],S.length>=5&&(c+=S[4])),p===t-1&&g>=r))break}}let u=s.sources[o];if(!u)return null;let l=yr.dirname(e),d=yr.resolve(l,u),m=yr.relative(process.cwd(),d);return{source:m.startsWith(".")?m:`./${m}`,line:i+1,column:a+1,name:s.names?.[c]}}catch{return null}},rz=(e,t="fallback")=>{let r=e.split(`
|
|
455
455
|
`),s=null,n;for(let o of r){if(o.includes("node_modules")||o.includes("aws-cdk-lib")||o.includes("cdk-insights"))continue;let i=o.match(/at\s+(?:new\s+)?(\w+(?:\.\w+)*)\s+\(/);i&&!n&&(n=i[1]);let a=o.match(/\(?([^()]+\.(ts|js|tsx|jsx)):(\d+):(\d+)\)?/);if(a){let[,c,u,l,d]=a,m=c.trim();!m.startsWith("/")&&!m.startsWith(".")&&(m=`./${m}`);let p=Number(l),f=Number(d);if((u==="js"||u==="jsx")&&(m.includes("/dist/")||m.includes("\\dist\\"))){let h=yr.resolve(process.cwd(),m),S=EDe(h,p,f);if(S)return{filePath:S.source,line:S.line,column:S.column,confidence:"high",method:"source_map",enclosingScope:S.name||n,originalFile:m}}let g={filePath:m,line:p,column:f,confidence:t==="creation_stack"?"high":"medium",method:t,enclosingScope:n};if(u==="ts"||u==="tsx")return g;s||(s=g)}}return s??void 0},xDe=(e,t,r,s)=>{let n=`${r}:${t}`;if(Xa.has(n))return Xa.get(n)??void 0;try{let o=process.cwd(),i=["lib","cdk","src","bin","stacks","cdk/stacks","infrastructure","apps"],a=t.split("/"),c=a.length>1?a[a.length-2]:"",u=e==="Resource"||e==="Default"?s||c||e:e||t.split("/").pop()||"";for(let l of i){let d=yr.join(o,l);if(!rs.existsSync(d))continue;let m=sz(d);for(let p of m){let f=ADe(p,u,c,o);if(f)return Xa.set(n,f),f}}}catch{}Xa.set(n,null)},sz=(e,t=[])=>{try{let r=rs.readdirSync(e,{withFileTypes:!0});for(let s of r){let n=yr.join(e,s.name);s.isDirectory()&&!s.name.startsWith(".")&&s.name!=="node_modules"?sz(n,t):s.isFile()&&(s.name.endsWith(".ts")||s.name.endsWith(".tsx"))&&t.push(n)}}catch{}return t},_De=(e,t,r=2)=>{let s=e.split(`
|
|
456
456
|
`),n=Math.max(0,t-1-r),o=Math.min(s.length,t+r);return s.slice(n,o).map((i,a)=>{let c=n+a+1;return`${c===t?">":" "}${c.toString().padStart(4)} | ${i}`}).join(`
|
|
457
457
|
`)},wDe=(e,t)=>{let r=e.split(`
|