deepv-code 1.0.290 → 1.0.291
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/bundle/dvcode.js +9 -9
- package/package.json +1 -1
package/bundle/dvcode.js
CHANGED
|
@@ -512,7 +512,7 @@ ${h}`)}return e}),Sde=Uur(xFt);n0e=class extends t0e{create(t,r){var a;let{api_v
|
|
|
512
512
|
`):[]}};gB.NEWLINE_CHARS=new Set([`
|
|
513
513
|
`,"\r"]);gB.NEWLINE_REGEXP=/\r\n|[\n\r]/g;a0e={off:0,error:200,warn:300,info:400,debug:500},WFt=(n,t,r)=>{if(n){if(Eur(a0e,n))return n;Ab(r).warn(`${t} was set to ${JSON.stringify(n)}, expected one of ${JSON.stringify(Object.keys(a0e))}`)}};Pur={error:Oj,warn:Oj,info:Oj,debug:Oj},yFt=new WeakMap;rQ=n=>(n.options&&(n.options=Object.assign({},n.options),delete n.options.headers),n.headers&&(n.headers=Object.fromEntries((n.headers instanceof Headers?[...n.headers]:Object.entries(n.headers)).map(([t,r])=>[t,t.toLowerCase()==="x-goog-api-key"||t.toLowerCase()==="authorization"||t.toLowerCase()==="cookie"||t.toLowerCase()==="set-cookie"?"***":r]))),"retryOfRequestLogID"in n&&(n.retryOfRequestLogID&&(n.retryOf=n.retryOfRequestLogID),delete n.retryOfRequestLogID),n);wHe=class n{constructor(t,r,a){this.iterator=t,this.controller=r,this.client=a}static fromSSEResponse(t,r,a){let i=!1,s=a?Ab(a):console;function e(){return pB(this,arguments,function*(){var u,d,I,h;if(i)throw new J2("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");i=!0;let c=!1;try{try{for(var G=!0,W=aQ(jur(t,r)),y;y=yield Dc(W.next()),u=y.done,!u;G=!0){h=y.value,G=!1;let R=h;if(!c)if(R.data.startsWith("[DONE]")){c=!0;continue}else try{yield yield Dc(JSON.parse(R.data))}catch(F){throw s.error("Could not parse message into JSON:",R.data),s.error("From chunk:",R.raw),F}}}catch(R){d={error:R}}finally{try{!G&&!u&&(I=W.return)&&(yield Dc(I.call(W)))}finally{if(d)throw d.error}}c=!0}catch(R){if(yHe(R))return yield Dc(void 0);throw R}finally{c||r.abort()}})}return new n(e,r,a)}static fromReadableStream(t,r,a){let i=!1;function s(){return pB(this,arguments,function*(){var u,d,I,h;let c=new gB,G=wFt(t);try{for(var W=!0,y=aQ(G),R;R=yield Dc(y.next()),u=R.done,!u;W=!0){h=R.value,W=!1;let F=h;for(let w of c.decode(F))yield yield Dc(w)}}catch(F){d={error:F}}finally{try{!W&&!u&&(I=y.return)&&(yield Dc(I.call(y)))}finally{if(d)throw d.error}}for(let F of c.flush())yield yield Dc(F)})}function e(){return pB(this,arguments,function*(){var u,d,I,h;if(i)throw new J2("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");i=!0;let c=!1;try{try{for(var G=!0,W=aQ(s()),y;y=yield Dc(W.next()),u=y.done,!u;G=!0){h=y.value,G=!1;let R=h;c||R&&(yield yield Dc(JSON.parse(R)))}}catch(R){d={error:R}}finally{try{!G&&!u&&(I=W.return)&&(yield Dc(I.call(W)))}finally{if(d)throw d.error}}c=!0}catch(R){if(yHe(R))return yield Dc(void 0);throw R}finally{c||r.abort()}})}return new n(e,r,a)}[Symbol.asyncIterator](){return this.iterator()}tee(){let t=[],r=[],a=this.iterator(),i=s=>({next:()=>{if(s.length===0){let e=a.next();t.push(e),r.push(e)}return s.shift()}});return[new n(()=>i(t),this.controller,this.client),new n(()=>i(r),this.controller,this.client)]}toReadableStream(){let t=this,r;return RFt({async start(){r=t[Symbol.asyncIterator]()},async pull(a){try{let{value:i,done:s}=await r.next();if(s)return a.close();let e=VHe(JSON.stringify(i)+`
|
|
514
514
|
`);a.enqueue(e)}catch(i){a.error(i)}},async cancel(){var a;await((a=r.return)===null||a===void 0?void 0:a.call(r))}})}};CHe=class{constructor(){this.event=null,this.data=[],this.chunks=[]}decode(t){if(t.endsWith("\r")&&(t=t.substring(0,t.length-1)),!t){if(!this.event&&!this.data.length)return null;let s={event:this.event,data:this.data.join(`
|
|
515
|
-
`),raw:this.chunks};return this.event=null,this.data=[],this.chunks=[],s}if(this.chunks.push(t),t.startsWith(":"))return null;let[r,a,i]=qur(t,":");return i.startsWith(" ")&&(i=i.substring(1)),r==="event"?this.event=i:r==="data"&&this.data.push(i),null}};YHe=class n extends Promise{constructor(t,r,a=$ur){super(i=>{i(null)}),this.responsePromise=r,this.parseResponse=a,this.client=t}_thenUnwrap(t){return new n(this.client,this.responsePromise,async(r,a)=>t(await this.parseResponse(r,a),a))}asResponse(){return this.responsePromise.then(t=>t.response)}async withResponse(){let[t,r]=await Promise.all([this.parse(),this.asResponse()]);return{data:t,response:r}}parse(){return this.parsedPromise||(this.parsedPromise=this.responsePromise.then(t=>this.parseResponse(this.client,t))),this.parsedPromise}then(t,r){return this.parse().then(t,r)}catch(t){return this.parse().catch(t)}finally(t){return this.parse().finally(t)}};VFt=Symbol("brand.privateNullableHeaders");Dj=n=>{let t=new Headers,r=new Set;for(let a of n){let i=new Set;for(let[s,e]of eIr(a)){let o=s.toLowerCase();i.has(o)||(t.delete(s),i.add(o)),e===null?(t.delete(s),r.add(o)):(t.append(s,e),r.delete(o))}}return{[VFt]:!0,values:t,nulls:r}};WHe=n=>{var t,r,a,i,s,e;if(typeof globalThis.process<"u")return(a=(r=(t=globalThis.process.env)===null||t===void 0?void 0:t[n])===null||r===void 0?void 0:r.trim())!==null&&a!==void 0?a:void 0;if(typeof globalThis.Deno<"u")return(e=(s=(i=globalThis.Deno.env)===null||i===void 0?void 0:i.get)===null||s===void 0?void 0:s.call(i,n))===null||e===void 0?void 0:e.trim()};i0e=class n{constructor(t){var r,a,i,s,e,o,u,{baseURL:d=WHe("GEMINI_NEXT_GEN_API_BASE_URL"),apiKey:I=(r=WHe("GEMINI_API_KEY"))!==null&&r!==void 0?r:null,apiVersion:h="v1beta"}=t,c=Ode(t,["baseURL","apiKey","apiVersion"]);let G=Object.assign(Object.assign({apiKey:I,apiVersion:h},c),{baseURL:d||"https://generativelanguage.googleapis.com"});this.baseURL=G.baseURL,this.timeout=(a=G.timeout)!==null&&a!==void 0?a:n.DEFAULT_TIMEOUT,this.logger=(i=G.logger)!==null&&i!==void 0?i:console;let W="warn";this.logLevel=W,this.logLevel=(e=(s=WFt(G.logLevel,"ClientOptions.logLevel",this))!==null&&s!==void 0?s:WFt(WHe("GEMINI_NEXT_GEN_API_LOG"),"process.env['GEMINI_NEXT_GEN_API_LOG']",this))!==null&&e!==void 0?e:W,this.fetchOptions=G.fetchOptions,this.maxRetries=(o=G.maxRetries)!==null&&o!==void 0?o:2,this.fetch=(u=G.fetch)!==null&&u!==void 0?u:Hur(),this.encoder=Lur,this._options=G,this.apiKey=I,this.apiVersion=h,this.clientAdapter=G.clientAdapter}withOptions(t){return new this.constructor(Object.assign(Object.assign(Object.assign({},this._options),{baseURL:this.baseURL,maxRetries:this.maxRetries,timeout:this.timeout,logger:this.logger,logLevel:this.logLevel,fetch:this.fetch,fetchOptions:this.fetchOptions,apiKey:this.apiKey,apiVersion:this.apiVersion}),t))}baseURLOverridden(){return this.baseURL!=="https://generativelanguage.googleapis.com"}defaultQuery(){return this._options.defaultQuery}validateHeaders({values:t,nulls:r}){if(!(t.has("authorization")||t.has("x-goog-api-key"))&&!(this.apiKey&&t.get("x-goog-api-key"))&&!r.has("x-goog-api-key"))throw new Error('Could not resolve authentication method. Expected the apiKey to be set. Or for the "x-goog-api-key" headers to be explicitly omitted')}async authHeaders(t){let r=Dj([t.headers]);if(!(r.values.has("authorization")||r.values.has("x-goog-api-key"))){if(this.apiKey)return Dj([{"x-goog-api-key":this.apiKey}]);if(this.clientAdapter.isVertexAI())return Dj([await this.clientAdapter.getAuthHeaders()])}}stringifyQuery(t){return Object.entries(t).filter(([r,a])=>typeof a<"u").map(([r,a])=>{if(typeof a=="string"||typeof a=="number"||typeof a=="boolean")return`${encodeURIComponent(r)}=${encodeURIComponent(a)}`;if(a===null)return`${encodeURIComponent(r)}=`;throw new J2(`Cannot stringify type ${typeof a}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`)}).join("&")}getUserAgent(){return`${this.constructor.name}/JS ${mB}`}defaultIdempotencyKey(){return`stainless-node-retry-${Zur()}`}makeStatusError(t,r,a,i){return T2.generate(t,r,a,i)}buildURL(t,r,a){let i=!this.baseURLOverridden()&&a||this.baseURL,s=Aur(t)?new URL(t):new URL(i+(i.endsWith("/")&&t.startsWith("/")?t.slice(1):t)),e=this.defaultQuery();return Fur(e)||(r=Object.assign(Object.assign({},e),r)),typeof r=="object"&&r&&!Array.isArray(r)&&(s.search=this.stringifyQuery(r)),s.toString()}async prepareOptions(t){if(this.clientAdapter&&this.clientAdapter.isVertexAI()&&!t.path.startsWith(`/${this.apiVersion}/projects/`)){let r=t.path.slice(this.apiVersion.length+1);t.path=`/${this.apiVersion}/projects/${this.clientAdapter.getProject()}/locations/${this.clientAdapter.getLocation()}${r}`}}async prepareRequest(t,{url:r,options:a}){}get(t,r){return this.methodRequest("get",t,r)}post(t,r){return this.methodRequest("post",t,r)}patch(t,r){return this.methodRequest("patch",t,r)}put(t,r){return this.methodRequest("put",t,r)}delete(t,r){return this.methodRequest("delete",t,r)}methodRequest(t,r,a){return this.request(Promise.resolve(a).then(i=>Object.assign({method:t,path:r},i)))}request(t,r=null){return new YHe(this,this.makeRequest(t,r,void 0))}async makeRequest(t,r,a){var i,s,e;let o=await t,u=(i=o.maxRetries)!==null&&i!==void 0?i:this.maxRetries;r==null&&(r=u),await this.prepareOptions(o);let{req:d,url:I,timeout:h}=await this.buildRequest(o,{retryCount:u-r});await this.prepareRequest(d,{url:I,options:o});let c="log_"+(Math.random()*(1<<24)|0).toString(16).padStart(6,"0"),G=a===void 0?"":`, retryOf: ${a}`,W=Date.now();if(Ab(this).debug(`[${c}] sending request`,rQ({retryOfRequestLogID:a,method:o.method,url:I,options:o,headers:d.headers})),!((s=o.signal)===null||s===void 0)&&s.aborted)throw new Uj;let y=new AbortController,R=await this.fetchWithTimeout(I,d,h,y).catch(FHe),F=Date.now();if(R instanceof globalThis.Error){let A=`retrying, ${r} attempts remaining`;if(!((e=o.signal)===null||e===void 0)&&e.aborted)throw new Uj;let E=yHe(R)||/timed? ?out/i.test(String(R)+("cause"in R?String(R.cause):""));if(r)return Ab(this).info(`[${c}] connection ${E?"timed out":"failed"} - ${A}`),Ab(this).debug(`[${c}] connection ${E?"timed out":"failed"} (${A})`,rQ({retryOfRequestLogID:a,url:I,durationMs:F-W,message:R.message})),this.retryRequest(o,r,a??c);throw Ab(this).info(`[${c}] connection ${E?"timed out":"failed"} - error; no more retries left`),Ab(this).debug(`[${c}] connection ${E?"timed out":"failed"} (error; no more retries left)`,rQ({retryOfRequestLogID:a,url:I,durationMs:F-W,message:R.message})),E?new Mde:new GB({cause:R})}let w=`[${c}${G}] ${d.method} ${I} ${R.ok?"succeeded":"failed"} with status ${R.status} in ${F-W}ms`;if(!R.ok){let A=await this.shouldRetry(R);if(r&&A){let m=`retrying, ${r} attempts remaining`;return await kur(R.body),Ab(this).info(`${w} - ${m}`),Ab(this).debug(`[${c}] response error (${m})`,rQ({retryOfRequestLogID:a,url:R.url,status:R.status,headers:R.headers,durationMs:F-W})),this.retryRequest(o,r,a??c,R.headers)}let E=A?"error; no more retries left":"error; not retryable";Ab(this).info(`${w} - ${E}`);let f=await R.text().catch(m=>FHe(m).message),g=wur(f),v=g?void 0:f;throw Ab(this).debug(`[${c}] response error (${E})`,rQ({retryOfRequestLogID:a,url:R.url,status:R.status,headers:R.headers,message:v,durationMs:Date.now()-W})),this.makeStatusError(R.status,g,v,R.headers)}return Ab(this).info(w),Ab(this).debug(`[${c}] response start`,rQ({retryOfRequestLogID:a,url:R.url,status:R.status,headers:R.headers,durationMs:F-W})),{response:R,options:o,controller:y,requestLogID:c,retryOfRequestLogID:a,startTime:W}}async fetchWithTimeout(t,r,a,i){let s=r||{},{signal:e,method:o}=s,u=Ode(s,["signal","method"]);e&&e.addEventListener("abort",()=>i.abort());let d=setTimeout(()=>i.abort(),a),I=globalThis.ReadableStream&&u.body instanceof globalThis.ReadableStream||typeof u.body=="object"&&u.body!==null&&Symbol.asyncIterator in u.body,h=Object.assign(Object.assign(Object.assign({signal:i.signal},I?{duplex:"half"}:{}),{method:"GET"}),u);o&&(h.method=o.toUpperCase());try{return await this.fetch.call(void 0,t,h)}finally{clearTimeout(d)}}async shouldRetry(t){let r=t.headers.get("x-should-retry");return r==="true"?!0:r==="false"?!1:t.status===408||t.status===409||t.status===429||t.status>=500}async retryRequest(t,r,a,i){var s;let e,o=i?.get("retry-after-ms");if(o){let d=parseFloat(o);Number.isNaN(d)||(e=d)}let u=i?.get("retry-after");if(u&&!e){let d=parseFloat(u);Number.isNaN(d)?e=Date.parse(u)-Date.now():e=d*1e3}if(!(e&&0<=e&&e<60*1e3)){let d=(s=t.maxRetries)!==null&&s!==void 0?s:this.maxRetries;e=this.calculateDefaultRetryTimeoutMillis(r,d)}return await Cur(e),this.makeRequest(t,r-1,a)}calculateDefaultRetryTimeoutMillis(t,r){let s=r-t,e=Math.min(.5*Math.pow(2,s),8),o=1-Math.random()*.25;return e*o*1e3}async buildRequest(t,{retryCount:r=0}={}){var a,i,s;let e=Object.assign({},t),{method:o,path:u,query:d,defaultBaseURL:I}=e,h=this.buildURL(u,d,I);"timeout"in e&&Rur("timeout",e.timeout),e.timeout=(a=e.timeout)!==null&&a!==void 0?a:this.timeout;let{bodyHeaders:c,body:G}=this.buildBody({options:e}),W=await this.buildHeaders({options:t,method:o,bodyHeaders:c,retryCount:r});return{req:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({method:o,headers:W},e.signal&&{signal:e.signal}),globalThis.ReadableStream&&G instanceof globalThis.ReadableStream&&{duplex:"half"}),G&&{body:G}),(i=this.fetchOptions)!==null&&i!==void 0?i:{}),(s=e.fetchOptions)!==null&&s!==void 0?s:{}),url:h,timeout:e.timeout}}async buildHeaders({options:t,method:r,bodyHeaders:a,retryCount:i}){let s={};this.idempotencyHeader&&r!=="get"&&(t.idempotencyKey||(t.idempotencyKey=this.defaultIdempotencyKey()),s[this.idempotencyHeader]=t.idempotencyKey);let e=await this.authHeaders(t),o=Dj([s,Object.assign(Object.assign({Accept:"application/json","User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String(i)},t.timeout?{"X-Stainless-Timeout":String(Math.trunc(t.timeout/1e3))}:{}),Qur()),this._options.defaultHeaders,a,t.headers,e]);return this.validateHeaders(o),o.values}buildBody({options:{body:t,headers:r}}){if(!t)return{bodyHeaders:void 0,body:void 0};let a=Dj([r]);return ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof DataView||typeof t=="string"&&a.values.has("content-type")||globalThis.Blob&&t instanceof globalThis.Blob||t instanceof FormData||t instanceof URLSearchParams||globalThis.ReadableStream&&t instanceof globalThis.ReadableStream?{bodyHeaders:void 0,body:t}:typeof t=="object"&&(Symbol.asyncIterator in t||Symbol.iterator in t&&"next"in t&&typeof t.next=="function")?{bodyHeaders:void 0,body:Xur(t)}:this.encoder({body:t,headers:a})}};i0e.DEFAULT_TIMEOUT=6e4;c0=class extends i0e{constructor(){super(...arguments),this.interactions=new r0e(this)}};QFt=c0;c0.GeminiNextGenAPIClient=QFt;c0.GeminiNextGenAPIClientError=J2;c0.APIError=T2;c0.APIConnectionError=GB;c0.APIConnectionTimeoutError=Mde;c0.APIUserAbortError=Uj;c0.NotFoundError=jde;c0.ConflictError=Kde;c0.RateLimitError=$de;c0.BadRequestError=zde;c0.AuthenticationError=_de;c0.InternalServerError=e0e;c0.PermissionDeniedError=Pde;c0.UnprocessableEntityError=qde;c0.toFile=Dur;c0.Interactions=r0e;Rsi=1024*1024*8;});function tIr(n,t){return{...n,...t}}function HFt(n){let{prompt_id:t,...r}=n;return r}function iQ(n){return Array.isArray(n)?n.map(HFt):n}var l0e=ut(()=>{"use strict";Fi();});var XFt={};po(XFt,{DEFAULT_PROXY_CONFIG:()=>aIr,getActiveProxyServerUrl:()=>mW,getAvailableProxyServers:()=>nIr,getProxyServerInfo:()=>rIr,getProxyServers:()=>Mj,hasAvailableProxyServer:()=>QHe});function Mj(){return[{url:"https://api-code.deepvlab.ai",name:"Primary Development Server",region:"default",status:"active"}]}function mW(){let t=Mj().find(r=>r.status==="active");if(!t)throw new Error("No active proxy server available. Please contact support.");return t.url}function nIr(){return Mj().filter(t=>t.status==="active")}function QHe(){return Mj().some(t=>t.status==="active")}function rIr(n){return Mj().find(r=>r.url===n)}var aIr,vB=ut(()=>{"use strict";aIr={serverUrl:mW(),timeout:2e5,retryAttempts:3,retryDelay:1e3}});import*as Nc from"fs";import*as NN from"path";import*as lQ from"os";function iIr(n){ao.configure(n)}function lIr(n){ao.setUserInfo(n)}function sIr(n){ao.setCliVersion(n)}async function oIr(){return await ao.getUserHeaders()}function cIr(){return ao.getStatus()}var zj,Es,ao,tw=ut(()=>{"use strict";vB();zj=259200,Es=class n{static instance=null;config;userInfo=null;jwtTokenData=null;usageStats={totalCreditsConsumed:0,lastUpdated:new Date().toISOString()};userInfoFilePath;jwtTokenFilePath;usageStatsFilePath;refreshPromise=null;cliVersion="unknown";periodicStatusCheckIntervalId=null;onLoginSuccessCallbacks=[];getCliVersion(){return this.cliVersion}getUserAgent(){let t=this.cliVersion,r=process.platform,a=process.arch;return t.startsWith("VSCode-")?`DeepVCode/VSCode/${t.replace("VSCode-","")} (${r}; ${a})`:`DeepVCode/CLI/${t} (${r}; ${a})`}formatTimeRemaining(t){if(t<=0)return"\u5DF2\u8FC7\u671F";let r=Math.floor(t/1e3),a=Math.floor(r/(24*3600)),i=Math.floor(r%(24*3600)/3600),s=Math.floor(r%3600/60),e=r%60;return a>0?`${a}\u5929${i}\u5C0F\u65F6${s}\u5206\u949F`:i>0?`${i}\u5C0F\u65F6${s}\u5206\u949F${e}\u79D2`:s>0?`${s}\u5206\u949F${e}\u79D2`:`${e}\u79D2`}formatAbsoluteTime(t){return new Date(t).toLocaleString("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1})}constructor(){"https://api-code.deepvlab.ai"?.includes("localhost")?(this.userInfoFilePath=NN.join(lQ.homedir(),".deepv","user-info-dev.json"),this.jwtTokenFilePath=NN.join(lQ.homedir(),".deepv","jwt-token-dev.json"),this.usageStatsFilePath=NN.join(lQ.homedir(),".deepv","usage-stats-dev.json")):(this.userInfoFilePath=NN.join(lQ.homedir(),".deepv","user-info.json"),this.jwtTokenFilePath=NN.join(lQ.homedir(),".deepv","jwt-token.json"),this.usageStatsFilePath=NN.join(lQ.homedir(),".deepv","usage-stats.json")),this.cliVersion="1.0.290",this.config={proxyServerUrl:mW()},this.loadUserInfo(),this.loadJwtToken(),this.loadUsageStats(),this.startPeriodicStatusCheck()}startPeriodicStatusCheck(){this.periodicStatusCheckIntervalId=setInterval(()=>{if(this.jwtTokenData){let t=Date.now(),r=this.jwtTokenData.expiresAt-t,a=this.formatTimeRemaining(r),i=this.formatAbsoluteTime(this.jwtTokenData.expiresAt);if(r>0){let s=this.formatAbsoluteTime(this.jwtTokenData.expiresAt-zj*1e3);console.log(`[Login Check] \u{1F4CA} Periodic status check - Credential remaining: ${a} (until ${i}), next renewal: ${s}`)}else console.log(`[Login Check] \u26A0\uFE0F Periodic status check - Credential expired at: ${i}`)}},600*1e3)}static getInstance(){return n.instance||(n.instance=new n),n.instance}loadUserInfo(){try{if(Nc.existsSync(this.userInfoFilePath)){let t=Nc.readFileSync(this.userInfoFilePath,"utf8");this.userInfo=JSON.parse(t);let r=a=>{if(!a||!a.includes("@"))return a;let[i,s]=a.split("@");return i.length<=2?a:`${i[0]+"*".repeat(i.length-2)+i[i.length-1]}@${s}`}}}catch(t){console.warn("[Login Check] Failed to load user info from local file:",t),this.userInfo=null}}saveUserInfo(){try{let t=NN.dirname(this.userInfoFilePath);Nc.existsSync(t)||Nc.mkdirSync(t,{recursive:!0}),Nc.writeFileSync(this.userInfoFilePath,JSON.stringify(this.userInfo,null,2)),console.log("[Login Check] User info saved to local file")}catch(t){console.error("[Login Check] Failed to save user info:",t)}}loadJwtToken(){try{if(Nc.existsSync(this.jwtTokenFilePath)){let t=Nc.readFileSync(this.jwtTokenFilePath,"utf8");this.jwtTokenData=JSON.parse(t);let r=Date.now();this.isTokenExpired()?this.jwtTokenData=null:this.isTokenNearExpiry(300)&&console.log("\u26A0\uFE0F Access credential expiring soon, auto-renewal in progress")}else console.log("[Login Check] No stored access credential found, authentication required")}catch(t){console.warn("[Login Check] Failed to load access credential from local file:",t),this.jwtTokenData=null}}saveJwtToken(){try{if(!this.jwtTokenData)return;let t=NN.dirname(this.jwtTokenFilePath);Nc.existsSync(t)||Nc.mkdirSync(t,{recursive:!0}),Nc.writeFileSync(this.jwtTokenFilePath,JSON.stringify(this.jwtTokenData,null,2)),console.log("[Login Check] Access credential data saved to local file")}catch(t){console.error("[Login Check] Failed to save access credential:",t)}}loadUsageStats(){try{if(Nc.existsSync(this.usageStatsFilePath)){let t=Nc.readFileSync(this.usageStatsFilePath,"utf8");this.usageStats=JSON.parse(t)}}catch(t){console.warn("[Login Check] Failed to load usage stats from local file:",t),this.usageStats={totalCreditsConsumed:0,lastUpdated:new Date().toISOString()}}}saveUsageStats(){try{let t=NN.dirname(this.usageStatsFilePath);Nc.existsSync(t)||Nc.mkdirSync(t,{recursive:!0}),Nc.writeFileSync(this.usageStatsFilePath,JSON.stringify(this.usageStats,null,2)),console.log("[Login Check] Usage stats saved to local file")}catch(t){console.error("[Login Check] Failed to save usage stats:",t)}}updateUsageStats(t){t<=0||(this.usageStats.totalCreditsConsumed+=t,this.usageStats.lastUpdated=new Date().toISOString(),this.saveUsageStats(),console.log(`[Usage Stats] Updated total credits consumed: ${this.usageStats.totalCreditsConsumed} (+${t})`))}getUsageStats(){return{...this.usageStats}}checkStartupTokenStatus(){return this.jwtTokenData?{hasToken:!0,isExpired:Date.now()>=this.jwtTokenData.expiresAt,expiresAt:this.jwtTokenData.expiresAt,hasRefreshToken:!!this.jwtTokenData.refreshToken}:{hasToken:!1,isExpired:!0,expiresAt:null,hasRefreshToken:!1}}configure(t){this.config={...this.config,...t},t.userInfo&&(this.userInfo=t.userInfo,this.saveUserInfo(),console.log(`[Login Check] User info configured: ${t.userInfo.name}`)),t.proxyServerUrl&&console.log(`[Login Check] Proxy server URL: ${t.proxyServerUrl}`),t.cliVersion&&(this.cliVersion=t.cliVersion,console.log(`[Login Check] CLI version set: ${t.cliVersion}`))}setUserInfo(t){this.userInfo=t,this.saveUserInfo(),console.log(`[Login Check] User info updated: ${t.name} (${t.email||t.openId||"N/A"})`),this.triggerLoginSuccessCallbacks()}onLoginSuccess(t){this.onLoginSuccessCallbacks.push(t)}triggerLoginSuccessCallbacks(){this.onLoginSuccessCallbacks.forEach(t=>{try{t()}catch(r){console.error("[ProxyAuthManager] Error in login success callback:",r)}})}setCliVersion(t){this.cliVersion=t,console.log(`[Login Check] CLI version updated: ${t}`)}setJwtToken(t){let r=Date.now();this.jwtTokenData={accessToken:t,expiresIn:900,expiresAt:r+900*1e3,savedAt:new Date().toISOString()},this.saveJwtToken(),console.log("[Login Check] Access credential updated")}setJwtTokenData(t){let a=Date.now()+t.expiresIn*1e3;this.jwtTokenData={accessToken:t.accessToken,refreshToken:t.refreshToken,expiresIn:t.expiresIn,expiresAt:a,savedAt:new Date().toISOString()},this.saveJwtToken();let i=this.formatTimeRemaining(t.expiresIn*1e3),s=this.formatAbsoluteTime(a),e=this.formatAbsoluteTime(a-zj*1e3),u=!!t.refreshToken?", will auto-renew":", manual login required";console.log(`[Login Check] Access credential updated - valid for: ${i} (until ${s}), next renewal: ${e}${u}`)}async getAccessToken(){if(!this.jwtTokenData)return console.log("[Login Check] No access credential available, authentication required"),null;let t=Date.now(),r=this.jwtTokenData.expiresAt-t,a=this.formatTimeRemaining(r),i=this.jwtTokenData.expiresAt-zj*1e3,s=this.formatAbsoluteTime(i);if(this.isTokenNearExpiry()){console.log(`[Login Check] Access credential expiring soon (remaining: ${a}), starting auto-renewal...`);try{return await this.refreshAccessToken()}catch(e){return console.error("[Login Check] Credential renewal failed:",e),null}}return this.jwtTokenData.accessToken}isTokenExpired(){return this.jwtTokenData?Date.now()>=this.jwtTokenData.expiresAt:!0}isTokenNearExpiry(t=zj){if(!this.jwtTokenData)return!0;let r=this.jwtTokenData.expiresAt-Date.now(),a=r<=t*1e3;if(a){let i=this.formatTimeRemaining(r);console.log(`[Login Check] Credential expiry check: ${i} remaining <= ${t}s threshold, renewal needed: ${a}`)}return a}async refreshAccessToken(){if(this.refreshPromise)return await this.refreshPromise;this.refreshPromise=this.performTokenRefresh();try{return await this.refreshPromise}finally{this.refreshPromise=null}}async performTokenRefresh(){if(!this.jwtTokenData?.refreshToken)throw new Error("No refresh token available");try{console.log("[Login Check] Refreshing access credential...");let t=await fetch(`${this.config.proxyServerUrl}/auth/jwt/refresh`,{method:"POST",headers:{"Content-Type":"application/json","User-Agent":"DeepCode CLI ProxyAuthManager"},body:JSON.stringify({refreshToken:this.jwtTokenData.refreshToken})});if(!t.ok){if(t.status===401)throw this.clearTokens(),new Error("Refresh credential expired or invalid - authentication required");let u=await t.text();throw new Error(`Credential refresh failed (${t.status}): ${u}`)}let r=await t.json();if(!r.success||!r.data?.accessToken)throw new Error("Invalid refresh response from server");let a=Date.now(),i=!!r.data.refreshToken;this.jwtTokenData={accessToken:r.data.accessToken,refreshToken:r.data.refreshToken||this.jwtTokenData.refreshToken,expiresIn:r.data.expiresIn||900,expiresAt:a+(r.data.expiresIn||900)*1e3,savedAt:new Date().toISOString()},this.saveJwtToken();let s=this.formatTimeRemaining((r.data.expiresIn||900)*1e3),e=this.formatAbsoluteTime(this.jwtTokenData.expiresAt),o=this.formatAbsoluteTime(this.jwtTokenData.expiresAt-zj*1e3);return console.log(`[Login Check] \u2705 Credential renewed successfully - valid for: ${s} (until ${e}), next renewal: ${o}${i?" (refresh credential updated)":" (reusing existing refresh credential)"}`),this.jwtTokenData.accessToken}catch(t){throw console.error("[Login Check] Credential refresh error:",t),t}}clearTokens(){this.jwtTokenData=null;try{Nc.existsSync(this.jwtTokenFilePath)&&Nc.unlinkSync(this.jwtTokenFilePath)}catch(t){console.warn("[Login Check] Failed to delete access credential file:",t)}}getProxyServerUrl(){return this.config.proxyServerUrl}async getUserHeaders(){let t=await this.getAccessToken(),r=this.getCliVersion(),a=this.getUserAgent();return t?{Authorization:`Bearer ${t}`,"Content-Type":"application/json","X-Client-Version":r,"User-Agent":a}:{"X-Client-Version":r,"User-Agent":a}}getUserHeadersSync(){let t=this.getCliVersion(),r=this.getUserAgent();return this.jwtTokenData?.accessToken?{Authorization:`Bearer ${this.jwtTokenData.accessToken}`,"Content-Type":"application/json","X-Client-Version":t,"User-Agent":r}:{"X-Client-Version":t,"User-Agent":r}}getUserInfo(){return this.userInfo}isConfigured(){return!!this.userInfo}getStatus(){return{configured:this.isConfigured(),proxyServerUrl:this.config.proxyServerUrl,hasUserInfo:!!this.userInfo,userInfo:this.userInfo}}clear(){this.userInfo=null,this.jwtTokenData=null,this.periodicStatusCheckIntervalId!==null&&(clearInterval(this.periodicStatusCheckIntervalId),this.periodicStatusCheckIntervalId=null);try{Nc.existsSync(this.userInfoFilePath)&&Nc.unlinkSync(this.userInfoFilePath)}catch(t){console.warn("[Login Check] Failed to delete user info file:",t)}try{Nc.existsSync(this.jwtTokenFilePath)&&Nc.unlinkSync(this.jwtTokenFilePath)}catch(t){console.warn("[Login Check] Failed to delete access credential file:",t)}console.log("[Login Check] Authentication cleared")}},ao=Es.getInstance()});import{promises as sQ}from"node:fs";import _j from"node:path";import uIr from"os";var OG,s0e,ar,_g=ut(()=>{"use strict";(function(n){n[n.DEBUG=0]="DEBUG",n[n.INFO=1]="INFO",n[n.WARN=2]="WARN",n[n.ERROR=3]="ERROR"})(OG||(OG={}));s0e=class{config;logBuffer=[];constructor(t={}){if(this.config={level:OG.INFO,enableConsole:!0,enableFile:!1,maxFileSize:10,maxFiles:5,...t},this.config.enableFile&&!this.config.filePath){let r=new Date().toISOString().slice(0,19).replace(/[:.]/g,"-");this.config.filePath=_j.join(uIr.homedir(),".deepv","logs",`deepv-${r}.log`)}}formatMessage(t,r,...a){let i=new Date().toISOString(),s=a.map(e=>typeof e=="object"?JSON.stringify(e,null,2):String(e)).join(" ");return`[${i}] [${t}] ${r} ${s}`.trim()}async writeToFile(t){if(!(!this.config.enableFile||!this.config.filePath))try{await sQ.mkdir(_j.dirname(this.config.filePath),{recursive:!0}),await this.rotateLogIfNeeded(),await sQ.appendFile(this.config.filePath,t+`
|
|
515
|
+
`),raw:this.chunks};return this.event=null,this.data=[],this.chunks=[],s}if(this.chunks.push(t),t.startsWith(":"))return null;let[r,a,i]=qur(t,":");return i.startsWith(" ")&&(i=i.substring(1)),r==="event"?this.event=i:r==="data"&&this.data.push(i),null}};YHe=class n extends Promise{constructor(t,r,a=$ur){super(i=>{i(null)}),this.responsePromise=r,this.parseResponse=a,this.client=t}_thenUnwrap(t){return new n(this.client,this.responsePromise,async(r,a)=>t(await this.parseResponse(r,a),a))}asResponse(){return this.responsePromise.then(t=>t.response)}async withResponse(){let[t,r]=await Promise.all([this.parse(),this.asResponse()]);return{data:t,response:r}}parse(){return this.parsedPromise||(this.parsedPromise=this.responsePromise.then(t=>this.parseResponse(this.client,t))),this.parsedPromise}then(t,r){return this.parse().then(t,r)}catch(t){return this.parse().catch(t)}finally(t){return this.parse().finally(t)}};VFt=Symbol("brand.privateNullableHeaders");Dj=n=>{let t=new Headers,r=new Set;for(let a of n){let i=new Set;for(let[s,e]of eIr(a)){let o=s.toLowerCase();i.has(o)||(t.delete(s),i.add(o)),e===null?(t.delete(s),r.add(o)):(t.append(s,e),r.delete(o))}}return{[VFt]:!0,values:t,nulls:r}};WHe=n=>{var t,r,a,i,s,e;if(typeof globalThis.process<"u")return(a=(r=(t=globalThis.process.env)===null||t===void 0?void 0:t[n])===null||r===void 0?void 0:r.trim())!==null&&a!==void 0?a:void 0;if(typeof globalThis.Deno<"u")return(e=(s=(i=globalThis.Deno.env)===null||i===void 0?void 0:i.get)===null||s===void 0?void 0:s.call(i,n))===null||e===void 0?void 0:e.trim()};i0e=class n{constructor(t){var r,a,i,s,e,o,u,{baseURL:d=WHe("GEMINI_NEXT_GEN_API_BASE_URL"),apiKey:I=(r=WHe("GEMINI_API_KEY"))!==null&&r!==void 0?r:null,apiVersion:h="v1beta"}=t,c=Ode(t,["baseURL","apiKey","apiVersion"]);let G=Object.assign(Object.assign({apiKey:I,apiVersion:h},c),{baseURL:d||"https://generativelanguage.googleapis.com"});this.baseURL=G.baseURL,this.timeout=(a=G.timeout)!==null&&a!==void 0?a:n.DEFAULT_TIMEOUT,this.logger=(i=G.logger)!==null&&i!==void 0?i:console;let W="warn";this.logLevel=W,this.logLevel=(e=(s=WFt(G.logLevel,"ClientOptions.logLevel",this))!==null&&s!==void 0?s:WFt(WHe("GEMINI_NEXT_GEN_API_LOG"),"process.env['GEMINI_NEXT_GEN_API_LOG']",this))!==null&&e!==void 0?e:W,this.fetchOptions=G.fetchOptions,this.maxRetries=(o=G.maxRetries)!==null&&o!==void 0?o:2,this.fetch=(u=G.fetch)!==null&&u!==void 0?u:Hur(),this.encoder=Lur,this._options=G,this.apiKey=I,this.apiVersion=h,this.clientAdapter=G.clientAdapter}withOptions(t){return new this.constructor(Object.assign(Object.assign(Object.assign({},this._options),{baseURL:this.baseURL,maxRetries:this.maxRetries,timeout:this.timeout,logger:this.logger,logLevel:this.logLevel,fetch:this.fetch,fetchOptions:this.fetchOptions,apiKey:this.apiKey,apiVersion:this.apiVersion}),t))}baseURLOverridden(){return this.baseURL!=="https://generativelanguage.googleapis.com"}defaultQuery(){return this._options.defaultQuery}validateHeaders({values:t,nulls:r}){if(!(t.has("authorization")||t.has("x-goog-api-key"))&&!(this.apiKey&&t.get("x-goog-api-key"))&&!r.has("x-goog-api-key"))throw new Error('Could not resolve authentication method. Expected the apiKey to be set. Or for the "x-goog-api-key" headers to be explicitly omitted')}async authHeaders(t){let r=Dj([t.headers]);if(!(r.values.has("authorization")||r.values.has("x-goog-api-key"))){if(this.apiKey)return Dj([{"x-goog-api-key":this.apiKey}]);if(this.clientAdapter.isVertexAI())return Dj([await this.clientAdapter.getAuthHeaders()])}}stringifyQuery(t){return Object.entries(t).filter(([r,a])=>typeof a<"u").map(([r,a])=>{if(typeof a=="string"||typeof a=="number"||typeof a=="boolean")return`${encodeURIComponent(r)}=${encodeURIComponent(a)}`;if(a===null)return`${encodeURIComponent(r)}=`;throw new J2(`Cannot stringify type ${typeof a}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`)}).join("&")}getUserAgent(){return`${this.constructor.name}/JS ${mB}`}defaultIdempotencyKey(){return`stainless-node-retry-${Zur()}`}makeStatusError(t,r,a,i){return T2.generate(t,r,a,i)}buildURL(t,r,a){let i=!this.baseURLOverridden()&&a||this.baseURL,s=Aur(t)?new URL(t):new URL(i+(i.endsWith("/")&&t.startsWith("/")?t.slice(1):t)),e=this.defaultQuery();return Fur(e)||(r=Object.assign(Object.assign({},e),r)),typeof r=="object"&&r&&!Array.isArray(r)&&(s.search=this.stringifyQuery(r)),s.toString()}async prepareOptions(t){if(this.clientAdapter&&this.clientAdapter.isVertexAI()&&!t.path.startsWith(`/${this.apiVersion}/projects/`)){let r=t.path.slice(this.apiVersion.length+1);t.path=`/${this.apiVersion}/projects/${this.clientAdapter.getProject()}/locations/${this.clientAdapter.getLocation()}${r}`}}async prepareRequest(t,{url:r,options:a}){}get(t,r){return this.methodRequest("get",t,r)}post(t,r){return this.methodRequest("post",t,r)}patch(t,r){return this.methodRequest("patch",t,r)}put(t,r){return this.methodRequest("put",t,r)}delete(t,r){return this.methodRequest("delete",t,r)}methodRequest(t,r,a){return this.request(Promise.resolve(a).then(i=>Object.assign({method:t,path:r},i)))}request(t,r=null){return new YHe(this,this.makeRequest(t,r,void 0))}async makeRequest(t,r,a){var i,s,e;let o=await t,u=(i=o.maxRetries)!==null&&i!==void 0?i:this.maxRetries;r==null&&(r=u),await this.prepareOptions(o);let{req:d,url:I,timeout:h}=await this.buildRequest(o,{retryCount:u-r});await this.prepareRequest(d,{url:I,options:o});let c="log_"+(Math.random()*(1<<24)|0).toString(16).padStart(6,"0"),G=a===void 0?"":`, retryOf: ${a}`,W=Date.now();if(Ab(this).debug(`[${c}] sending request`,rQ({retryOfRequestLogID:a,method:o.method,url:I,options:o,headers:d.headers})),!((s=o.signal)===null||s===void 0)&&s.aborted)throw new Uj;let y=new AbortController,R=await this.fetchWithTimeout(I,d,h,y).catch(FHe),F=Date.now();if(R instanceof globalThis.Error){let A=`retrying, ${r} attempts remaining`;if(!((e=o.signal)===null||e===void 0)&&e.aborted)throw new Uj;let E=yHe(R)||/timed? ?out/i.test(String(R)+("cause"in R?String(R.cause):""));if(r)return Ab(this).info(`[${c}] connection ${E?"timed out":"failed"} - ${A}`),Ab(this).debug(`[${c}] connection ${E?"timed out":"failed"} (${A})`,rQ({retryOfRequestLogID:a,url:I,durationMs:F-W,message:R.message})),this.retryRequest(o,r,a??c);throw Ab(this).info(`[${c}] connection ${E?"timed out":"failed"} - error; no more retries left`),Ab(this).debug(`[${c}] connection ${E?"timed out":"failed"} (error; no more retries left)`,rQ({retryOfRequestLogID:a,url:I,durationMs:F-W,message:R.message})),E?new Mde:new GB({cause:R})}let w=`[${c}${G}] ${d.method} ${I} ${R.ok?"succeeded":"failed"} with status ${R.status} in ${F-W}ms`;if(!R.ok){let A=await this.shouldRetry(R);if(r&&A){let m=`retrying, ${r} attempts remaining`;return await kur(R.body),Ab(this).info(`${w} - ${m}`),Ab(this).debug(`[${c}] response error (${m})`,rQ({retryOfRequestLogID:a,url:R.url,status:R.status,headers:R.headers,durationMs:F-W})),this.retryRequest(o,r,a??c,R.headers)}let E=A?"error; no more retries left":"error; not retryable";Ab(this).info(`${w} - ${E}`);let f=await R.text().catch(m=>FHe(m).message),g=wur(f),v=g?void 0:f;throw Ab(this).debug(`[${c}] response error (${E})`,rQ({retryOfRequestLogID:a,url:R.url,status:R.status,headers:R.headers,message:v,durationMs:Date.now()-W})),this.makeStatusError(R.status,g,v,R.headers)}return Ab(this).info(w),Ab(this).debug(`[${c}] response start`,rQ({retryOfRequestLogID:a,url:R.url,status:R.status,headers:R.headers,durationMs:F-W})),{response:R,options:o,controller:y,requestLogID:c,retryOfRequestLogID:a,startTime:W}}async fetchWithTimeout(t,r,a,i){let s=r||{},{signal:e,method:o}=s,u=Ode(s,["signal","method"]);e&&e.addEventListener("abort",()=>i.abort());let d=setTimeout(()=>i.abort(),a),I=globalThis.ReadableStream&&u.body instanceof globalThis.ReadableStream||typeof u.body=="object"&&u.body!==null&&Symbol.asyncIterator in u.body,h=Object.assign(Object.assign(Object.assign({signal:i.signal},I?{duplex:"half"}:{}),{method:"GET"}),u);o&&(h.method=o.toUpperCase());try{return await this.fetch.call(void 0,t,h)}finally{clearTimeout(d)}}async shouldRetry(t){let r=t.headers.get("x-should-retry");return r==="true"?!0:r==="false"?!1:t.status===408||t.status===409||t.status===429||t.status>=500}async retryRequest(t,r,a,i){var s;let e,o=i?.get("retry-after-ms");if(o){let d=parseFloat(o);Number.isNaN(d)||(e=d)}let u=i?.get("retry-after");if(u&&!e){let d=parseFloat(u);Number.isNaN(d)?e=Date.parse(u)-Date.now():e=d*1e3}if(!(e&&0<=e&&e<60*1e3)){let d=(s=t.maxRetries)!==null&&s!==void 0?s:this.maxRetries;e=this.calculateDefaultRetryTimeoutMillis(r,d)}return await Cur(e),this.makeRequest(t,r-1,a)}calculateDefaultRetryTimeoutMillis(t,r){let s=r-t,e=Math.min(.5*Math.pow(2,s),8),o=1-Math.random()*.25;return e*o*1e3}async buildRequest(t,{retryCount:r=0}={}){var a,i,s;let e=Object.assign({},t),{method:o,path:u,query:d,defaultBaseURL:I}=e,h=this.buildURL(u,d,I);"timeout"in e&&Rur("timeout",e.timeout),e.timeout=(a=e.timeout)!==null&&a!==void 0?a:this.timeout;let{bodyHeaders:c,body:G}=this.buildBody({options:e}),W=await this.buildHeaders({options:t,method:o,bodyHeaders:c,retryCount:r});return{req:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({method:o,headers:W},e.signal&&{signal:e.signal}),globalThis.ReadableStream&&G instanceof globalThis.ReadableStream&&{duplex:"half"}),G&&{body:G}),(i=this.fetchOptions)!==null&&i!==void 0?i:{}),(s=e.fetchOptions)!==null&&s!==void 0?s:{}),url:h,timeout:e.timeout}}async buildHeaders({options:t,method:r,bodyHeaders:a,retryCount:i}){let s={};this.idempotencyHeader&&r!=="get"&&(t.idempotencyKey||(t.idempotencyKey=this.defaultIdempotencyKey()),s[this.idempotencyHeader]=t.idempotencyKey);let e=await this.authHeaders(t),o=Dj([s,Object.assign(Object.assign({Accept:"application/json","User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String(i)},t.timeout?{"X-Stainless-Timeout":String(Math.trunc(t.timeout/1e3))}:{}),Qur()),this._options.defaultHeaders,a,t.headers,e]);return this.validateHeaders(o),o.values}buildBody({options:{body:t,headers:r}}){if(!t)return{bodyHeaders:void 0,body:void 0};let a=Dj([r]);return ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof DataView||typeof t=="string"&&a.values.has("content-type")||globalThis.Blob&&t instanceof globalThis.Blob||t instanceof FormData||t instanceof URLSearchParams||globalThis.ReadableStream&&t instanceof globalThis.ReadableStream?{bodyHeaders:void 0,body:t}:typeof t=="object"&&(Symbol.asyncIterator in t||Symbol.iterator in t&&"next"in t&&typeof t.next=="function")?{bodyHeaders:void 0,body:Xur(t)}:this.encoder({body:t,headers:a})}};i0e.DEFAULT_TIMEOUT=6e4;c0=class extends i0e{constructor(){super(...arguments),this.interactions=new r0e(this)}};QFt=c0;c0.GeminiNextGenAPIClient=QFt;c0.GeminiNextGenAPIClientError=J2;c0.APIError=T2;c0.APIConnectionError=GB;c0.APIConnectionTimeoutError=Mde;c0.APIUserAbortError=Uj;c0.NotFoundError=jde;c0.ConflictError=Kde;c0.RateLimitError=$de;c0.BadRequestError=zde;c0.AuthenticationError=_de;c0.InternalServerError=e0e;c0.PermissionDeniedError=Pde;c0.UnprocessableEntityError=qde;c0.toFile=Dur;c0.Interactions=r0e;Rsi=1024*1024*8;});function tIr(n,t){return{...n,...t}}function HFt(n){let{prompt_id:t,...r}=n;return r}function iQ(n){return Array.isArray(n)?n.map(HFt):n}var l0e=ut(()=>{"use strict";Fi();});var XFt={};po(XFt,{DEFAULT_PROXY_CONFIG:()=>aIr,getActiveProxyServerUrl:()=>mW,getAvailableProxyServers:()=>nIr,getProxyServerInfo:()=>rIr,getProxyServers:()=>Mj,hasAvailableProxyServer:()=>QHe});function Mj(){return[{url:"https://api-code.deepvlab.ai",name:"Primary Development Server",region:"default",status:"active"}]}function mW(){let t=Mj().find(r=>r.status==="active");if(!t)throw new Error("No active proxy server available. Please contact support.");return t.url}function nIr(){return Mj().filter(t=>t.status==="active")}function QHe(){return Mj().some(t=>t.status==="active")}function rIr(n){return Mj().find(r=>r.url===n)}var aIr,vB=ut(()=>{"use strict";aIr={serverUrl:mW(),timeout:2e5,retryAttempts:3,retryDelay:1e3}});import*as Nc from"fs";import*as NN from"path";import*as lQ from"os";function iIr(n){ao.configure(n)}function lIr(n){ao.setUserInfo(n)}function sIr(n){ao.setCliVersion(n)}async function oIr(){return await ao.getUserHeaders()}function cIr(){return ao.getStatus()}var zj,Es,ao,tw=ut(()=>{"use strict";vB();zj=259200,Es=class n{static instance=null;config;userInfo=null;jwtTokenData=null;usageStats={totalCreditsConsumed:0,lastUpdated:new Date().toISOString()};userInfoFilePath;jwtTokenFilePath;usageStatsFilePath;refreshPromise=null;cliVersion="unknown";periodicStatusCheckIntervalId=null;onLoginSuccessCallbacks=[];getCliVersion(){return this.cliVersion}getUserAgent(){let t=this.cliVersion,r=process.platform,a=process.arch;return t.startsWith("VSCode-")?`DeepVCode/VSCode/${t.replace("VSCode-","")} (${r}; ${a})`:`DeepVCode/CLI/${t} (${r}; ${a})`}formatTimeRemaining(t){if(t<=0)return"\u5DF2\u8FC7\u671F";let r=Math.floor(t/1e3),a=Math.floor(r/(24*3600)),i=Math.floor(r%(24*3600)/3600),s=Math.floor(r%3600/60),e=r%60;return a>0?`${a}\u5929${i}\u5C0F\u65F6${s}\u5206\u949F`:i>0?`${i}\u5C0F\u65F6${s}\u5206\u949F${e}\u79D2`:s>0?`${s}\u5206\u949F${e}\u79D2`:`${e}\u79D2`}formatAbsoluteTime(t){return new Date(t).toLocaleString("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1})}constructor(){"https://api-code.deepvlab.ai"?.includes("localhost")?(this.userInfoFilePath=NN.join(lQ.homedir(),".deepv","user-info-dev.json"),this.jwtTokenFilePath=NN.join(lQ.homedir(),".deepv","jwt-token-dev.json"),this.usageStatsFilePath=NN.join(lQ.homedir(),".deepv","usage-stats-dev.json")):(this.userInfoFilePath=NN.join(lQ.homedir(),".deepv","user-info.json"),this.jwtTokenFilePath=NN.join(lQ.homedir(),".deepv","jwt-token.json"),this.usageStatsFilePath=NN.join(lQ.homedir(),".deepv","usage-stats.json")),this.cliVersion="1.0.291",this.config={proxyServerUrl:mW()},this.loadUserInfo(),this.loadJwtToken(),this.loadUsageStats(),this.startPeriodicStatusCheck()}startPeriodicStatusCheck(){this.periodicStatusCheckIntervalId=setInterval(()=>{if(this.jwtTokenData){let t=Date.now(),r=this.jwtTokenData.expiresAt-t,a=this.formatTimeRemaining(r),i=this.formatAbsoluteTime(this.jwtTokenData.expiresAt);if(r>0){let s=this.formatAbsoluteTime(this.jwtTokenData.expiresAt-zj*1e3);console.log(`[Login Check] \u{1F4CA} Periodic status check - Credential remaining: ${a} (until ${i}), next renewal: ${s}`)}else console.log(`[Login Check] \u26A0\uFE0F Periodic status check - Credential expired at: ${i}`)}},600*1e3)}static getInstance(){return n.instance||(n.instance=new n),n.instance}loadUserInfo(){try{if(Nc.existsSync(this.userInfoFilePath)){let t=Nc.readFileSync(this.userInfoFilePath,"utf8");this.userInfo=JSON.parse(t);let r=a=>{if(!a||!a.includes("@"))return a;let[i,s]=a.split("@");return i.length<=2?a:`${i[0]+"*".repeat(i.length-2)+i[i.length-1]}@${s}`}}}catch(t){console.warn("[Login Check] Failed to load user info from local file:",t),this.userInfo=null}}saveUserInfo(){try{let t=NN.dirname(this.userInfoFilePath);Nc.existsSync(t)||Nc.mkdirSync(t,{recursive:!0}),Nc.writeFileSync(this.userInfoFilePath,JSON.stringify(this.userInfo,null,2)),console.log("[Login Check] User info saved to local file")}catch(t){console.error("[Login Check] Failed to save user info:",t)}}loadJwtToken(){try{if(Nc.existsSync(this.jwtTokenFilePath)){let t=Nc.readFileSync(this.jwtTokenFilePath,"utf8");this.jwtTokenData=JSON.parse(t);let r=Date.now();this.isTokenExpired()?this.jwtTokenData=null:this.isTokenNearExpiry(300)&&console.log("\u26A0\uFE0F Access credential expiring soon, auto-renewal in progress")}else console.log("[Login Check] No stored access credential found, authentication required")}catch(t){console.warn("[Login Check] Failed to load access credential from local file:",t),this.jwtTokenData=null}}saveJwtToken(){try{if(!this.jwtTokenData)return;let t=NN.dirname(this.jwtTokenFilePath);Nc.existsSync(t)||Nc.mkdirSync(t,{recursive:!0}),Nc.writeFileSync(this.jwtTokenFilePath,JSON.stringify(this.jwtTokenData,null,2)),console.log("[Login Check] Access credential data saved to local file")}catch(t){console.error("[Login Check] Failed to save access credential:",t)}}loadUsageStats(){try{if(Nc.existsSync(this.usageStatsFilePath)){let t=Nc.readFileSync(this.usageStatsFilePath,"utf8");this.usageStats=JSON.parse(t)}}catch(t){console.warn("[Login Check] Failed to load usage stats from local file:",t),this.usageStats={totalCreditsConsumed:0,lastUpdated:new Date().toISOString()}}}saveUsageStats(){try{let t=NN.dirname(this.usageStatsFilePath);Nc.existsSync(t)||Nc.mkdirSync(t,{recursive:!0}),Nc.writeFileSync(this.usageStatsFilePath,JSON.stringify(this.usageStats,null,2)),console.log("[Login Check] Usage stats saved to local file")}catch(t){console.error("[Login Check] Failed to save usage stats:",t)}}updateUsageStats(t){t<=0||(this.usageStats.totalCreditsConsumed+=t,this.usageStats.lastUpdated=new Date().toISOString(),this.saveUsageStats(),console.log(`[Usage Stats] Updated total credits consumed: ${this.usageStats.totalCreditsConsumed} (+${t})`))}getUsageStats(){return{...this.usageStats}}checkStartupTokenStatus(){return this.jwtTokenData?{hasToken:!0,isExpired:Date.now()>=this.jwtTokenData.expiresAt,expiresAt:this.jwtTokenData.expiresAt,hasRefreshToken:!!this.jwtTokenData.refreshToken}:{hasToken:!1,isExpired:!0,expiresAt:null,hasRefreshToken:!1}}configure(t){this.config={...this.config,...t},t.userInfo&&(this.userInfo=t.userInfo,this.saveUserInfo(),console.log(`[Login Check] User info configured: ${t.userInfo.name}`)),t.proxyServerUrl&&console.log(`[Login Check] Proxy server URL: ${t.proxyServerUrl}`),t.cliVersion&&(this.cliVersion=t.cliVersion,console.log(`[Login Check] CLI version set: ${t.cliVersion}`))}setUserInfo(t){this.userInfo=t,this.saveUserInfo(),console.log(`[Login Check] User info updated: ${t.name} (${t.email||t.openId||"N/A"})`),this.triggerLoginSuccessCallbacks()}onLoginSuccess(t){this.onLoginSuccessCallbacks.push(t)}triggerLoginSuccessCallbacks(){this.onLoginSuccessCallbacks.forEach(t=>{try{t()}catch(r){console.error("[ProxyAuthManager] Error in login success callback:",r)}})}setCliVersion(t){this.cliVersion=t,console.log(`[Login Check] CLI version updated: ${t}`)}setJwtToken(t){let r=Date.now();this.jwtTokenData={accessToken:t,expiresIn:900,expiresAt:r+900*1e3,savedAt:new Date().toISOString()},this.saveJwtToken(),console.log("[Login Check] Access credential updated")}setJwtTokenData(t){let a=Date.now()+t.expiresIn*1e3;this.jwtTokenData={accessToken:t.accessToken,refreshToken:t.refreshToken,expiresIn:t.expiresIn,expiresAt:a,savedAt:new Date().toISOString()},this.saveJwtToken();let i=this.formatTimeRemaining(t.expiresIn*1e3),s=this.formatAbsoluteTime(a),e=this.formatAbsoluteTime(a-zj*1e3),u=!!t.refreshToken?", will auto-renew":", manual login required";console.log(`[Login Check] Access credential updated - valid for: ${i} (until ${s}), next renewal: ${e}${u}`)}async getAccessToken(){if(!this.jwtTokenData)return console.log("[Login Check] No access credential available, authentication required"),null;let t=Date.now(),r=this.jwtTokenData.expiresAt-t,a=this.formatTimeRemaining(r),i=this.jwtTokenData.expiresAt-zj*1e3,s=this.formatAbsoluteTime(i);if(this.isTokenNearExpiry()){console.log(`[Login Check] Access credential expiring soon (remaining: ${a}), starting auto-renewal...`);try{return await this.refreshAccessToken()}catch(e){return console.error("[Login Check] Credential renewal failed:",e),null}}return this.jwtTokenData.accessToken}isTokenExpired(){return this.jwtTokenData?Date.now()>=this.jwtTokenData.expiresAt:!0}isTokenNearExpiry(t=zj){if(!this.jwtTokenData)return!0;let r=this.jwtTokenData.expiresAt-Date.now(),a=r<=t*1e3;if(a){let i=this.formatTimeRemaining(r);console.log(`[Login Check] Credential expiry check: ${i} remaining <= ${t}s threshold, renewal needed: ${a}`)}return a}async refreshAccessToken(){if(this.refreshPromise)return await this.refreshPromise;this.refreshPromise=this.performTokenRefresh();try{return await this.refreshPromise}finally{this.refreshPromise=null}}async performTokenRefresh(){if(!this.jwtTokenData?.refreshToken)throw new Error("No refresh token available");try{console.log("[Login Check] Refreshing access credential...");let t=await fetch(`${this.config.proxyServerUrl}/auth/jwt/refresh`,{method:"POST",headers:{"Content-Type":"application/json","User-Agent":"DeepCode CLI ProxyAuthManager"},body:JSON.stringify({refreshToken:this.jwtTokenData.refreshToken})});if(!t.ok){if(t.status===401)throw this.clearTokens(),new Error("Refresh credential expired or invalid - authentication required");let u=await t.text();throw new Error(`Credential refresh failed (${t.status}): ${u}`)}let r=await t.json();if(!r.success||!r.data?.accessToken)throw new Error("Invalid refresh response from server");let a=Date.now(),i=!!r.data.refreshToken;this.jwtTokenData={accessToken:r.data.accessToken,refreshToken:r.data.refreshToken||this.jwtTokenData.refreshToken,expiresIn:r.data.expiresIn||900,expiresAt:a+(r.data.expiresIn||900)*1e3,savedAt:new Date().toISOString()},this.saveJwtToken();let s=this.formatTimeRemaining((r.data.expiresIn||900)*1e3),e=this.formatAbsoluteTime(this.jwtTokenData.expiresAt),o=this.formatAbsoluteTime(this.jwtTokenData.expiresAt-zj*1e3);return console.log(`[Login Check] \u2705 Credential renewed successfully - valid for: ${s} (until ${e}), next renewal: ${o}${i?" (refresh credential updated)":" (reusing existing refresh credential)"}`),this.jwtTokenData.accessToken}catch(t){throw console.error("[Login Check] Credential refresh error:",t),t}}clearTokens(){this.jwtTokenData=null;try{Nc.existsSync(this.jwtTokenFilePath)&&Nc.unlinkSync(this.jwtTokenFilePath)}catch(t){console.warn("[Login Check] Failed to delete access credential file:",t)}}getProxyServerUrl(){return this.config.proxyServerUrl}async getUserHeaders(){let t=await this.getAccessToken(),r=this.getCliVersion(),a=this.getUserAgent();return t?{Authorization:`Bearer ${t}`,"Content-Type":"application/json","X-Client-Version":r,"User-Agent":a}:{"X-Client-Version":r,"User-Agent":a}}getUserHeadersSync(){let t=this.getCliVersion(),r=this.getUserAgent();return this.jwtTokenData?.accessToken?{Authorization:`Bearer ${this.jwtTokenData.accessToken}`,"Content-Type":"application/json","X-Client-Version":t,"User-Agent":r}:{"X-Client-Version":t,"User-Agent":r}}getUserInfo(){return this.userInfo}isConfigured(){return!!this.userInfo}getStatus(){return{configured:this.isConfigured(),proxyServerUrl:this.config.proxyServerUrl,hasUserInfo:!!this.userInfo,userInfo:this.userInfo}}clear(){this.userInfo=null,this.jwtTokenData=null,this.periodicStatusCheckIntervalId!==null&&(clearInterval(this.periodicStatusCheckIntervalId),this.periodicStatusCheckIntervalId=null);try{Nc.existsSync(this.userInfoFilePath)&&Nc.unlinkSync(this.userInfoFilePath)}catch(t){console.warn("[Login Check] Failed to delete user info file:",t)}try{Nc.existsSync(this.jwtTokenFilePath)&&Nc.unlinkSync(this.jwtTokenFilePath)}catch(t){console.warn("[Login Check] Failed to delete access credential file:",t)}console.log("[Login Check] Authentication cleared")}},ao=Es.getInstance()});import{promises as sQ}from"node:fs";import _j from"node:path";import uIr from"os";var OG,s0e,ar,_g=ut(()=>{"use strict";(function(n){n[n.DEBUG=0]="DEBUG",n[n.INFO=1]="INFO",n[n.WARN=2]="WARN",n[n.ERROR=3]="ERROR"})(OG||(OG={}));s0e=class{config;logBuffer=[];constructor(t={}){if(this.config={level:OG.INFO,enableConsole:!0,enableFile:!1,maxFileSize:10,maxFiles:5,...t},this.config.enableFile&&!this.config.filePath){let r=new Date().toISOString().slice(0,19).replace(/[:.]/g,"-");this.config.filePath=_j.join(uIr.homedir(),".deepv","logs",`deepv-${r}.log`)}}formatMessage(t,r,...a){let i=new Date().toISOString(),s=a.map(e=>typeof e=="object"?JSON.stringify(e,null,2):String(e)).join(" ");return`[${i}] [${t}] ${r} ${s}`.trim()}async writeToFile(t){if(!(!this.config.enableFile||!this.config.filePath))try{await sQ.mkdir(_j.dirname(this.config.filePath),{recursive:!0}),await this.rotateLogIfNeeded(),await sQ.appendFile(this.config.filePath,t+`
|
|
516
516
|
`,"utf-8")}catch(r){console.error("\u5199\u5165\u65E5\u5FD7\u6587\u4EF6\u5931\u8D25:",r)}}async rotateLogIfNeeded(){if(this.config.filePath)try{if((await sQ.stat(this.config.filePath)).size/(1024*1024)>(this.config.maxFileSize||10)){let a=new Date().toISOString().slice(0,19).replace(/[:.]/g,"-"),i=this.config.filePath.replace(".log",`-${a}.log`);await sQ.rename(this.config.filePath,i),await this.cleanOldLogs()}}catch(t){t.code!=="ENOENT"&&console.error("\u65E5\u5FD7\u8F6E\u8F6C\u5931\u8D25:",t)}}async cleanOldLogs(){if(this.config.filePath)try{let t=_j.dirname(this.config.filePath),a=(await sQ.readdir(t)).filter(e=>e.startsWith("deepv-")&&e.endsWith(".log")).map(e=>({name:e,path:_j.join(t,e),time:sQ.stat(_j.join(t,e)).then(o=>o.mtime)})),i=await Promise.all(a.map(async e=>({...e,time:await e.time})));i.sort((e,o)=>o.time.getTime()-e.time.getTime());let s=i.slice(this.config.maxFiles||5);for(let e of s)await sQ.unlink(e.path)}catch(t){console.error("\u6E05\u7406\u65E7\u65E5\u5FD7\u5931\u8D25:",t)}}log(t,r,a,...i){if(t<this.config.level)return;let s=this.formatMessage(r,a,...i);this.config.enableConsole&&(t>=OG.ERROR?console.error:t>=OG.WARN?console.warn:t>=OG.INFO?console.log:console.debug)(s),this.config.enableFile&&this.writeToFile(s)}debug(t,...r){this.log(OG.DEBUG,"DEBUG",t,...r)}info(t,...r){this.log(OG.INFO,"INFO",t,...r)}warn(t,...r){this.log(OG.WARN,"WARN",t,...r)}error(t,...r){this.log(OG.ERROR,"ERROR",t,...r)}logApiRequest(t,r){this.debug("API\u8BF7\u6C42",{endpoint:t,timestamp:new Date().toISOString(),requestSize:JSON.stringify(r).length,...process.env.FILE_DEBUG==="1"?{requestData:r}:{}})}logApiResponse(t,r){this.debug("API\u54CD\u5E94",{endpoint:t,timestamp:new Date().toISOString(),responseSize:JSON.stringify(r).length,...process.env.FILE_DEBUG==="1"?{responseData:r}:{}})}},ar=new s0e({level:process.env.FILE_DEBUG==="1"?OG.DEBUG:OG.INFO,enableConsole:!0,enableFile:process.env.LOG_TO_FILE==="true",filePath:process.env.LOG_FILE_PATH})});function Yo(n){return n instanceof Error&&"code"in n}function sr(n){if(n instanceof Error)return n.message;try{return String(n)}catch{return"Failed to get error details"}}function HHe(n){if(n&&typeof n=="object"&&"response"in n){let r=IIr(n);if(r.error&&r.error.message&&r.error.code)switch(r.error.code){case 400:return new c0e(r.error.message);case 401:return new CI(r.error.message);case 403:return new o0e(r.error.message);default:}}return n}function IIr(n){return typeof n.response?.data=="string"?JSON.parse(n.response?.data):n.response?.data}var o0e,CI,c0e,Ac=ut(()=>{"use strict";o0e=class extends Error{},CI=class extends Error{},c0e=class extends Error{}});var Ha,kFt,vd,pW=ut(()=>{"use strict";(function(n){n.CHAT_CONVERSATION="chat_conversation",n.WEB_FETCH="web_fetch",n.WEB_SEARCH="web_search",n.CONTENT_SUMMARY="content_summary",n.JSON_GENERATION="json_generation",n.COMPRESSION="compression",n.SUB_AGENT="sub_agent",n.CODE_ASSIST="code_assist",n.EDIT_CORRECTION="edit_correction"})(Ha||(Ha={}));kFt={[Ha.CHAT_CONVERSATION]:"auto",[Ha.WEB_FETCH]:"gemini-2.5-flash",[Ha.WEB_SEARCH]:"gemini-2.5-flash",[Ha.CODE_ASSIST]:"auto",[Ha.CONTENT_SUMMARY]:"gemini-2.5-flash-lite",[Ha.EDIT_CORRECTION]:"gemini-2.5-flash-lite",[Ha.JSON_GENERATION]:"gemini-2.5-flash",[Ha.COMPRESSION]:"gemini-2.5-flash",[Ha.SUB_AGENT]:"auto"},vd=class{static getModelForScene(t){if(t)return kFt[t]}static isClaudeModel(t){return t.includes("claude")||t.includes("anthropic")}static isGeminiModel(t){return t.includes("gemini")&&!this.isClaudeModel(t)}static getSceneDisplayName(t){return{[Ha.CHAT_CONVERSATION]:"\u804A\u5929\u5BF9\u8BDD",[Ha.WEB_FETCH]:"Web\u5185\u5BB9\u83B7\u53D6",[Ha.WEB_SEARCH]:"Web\u641C\u7D22",[Ha.CODE_ASSIST]:"\u4EE3\u7801\u52A9\u624B",[Ha.CONTENT_SUMMARY]:"\u5185\u5BB9\u6458\u8981",[Ha.EDIT_CORRECTION]:"\u7F16\u8F91\u6821\u6B63",[Ha.JSON_GENERATION]:"JSON\u751F\u6210",[Ha.COMPRESSION]:"\u5BF9\u8BDD\u538B\u7F29",[Ha.SUB_AGENT]:"SubAgent\u5B50\u4EE3\u7406"}[t]||t}}});function y5(n){return typeof n=="object"&&n!==null&&"error"in n&&typeof n.error=="object"&&"message"in n.error}function D2(n){return typeof n=="object"&&n!==null&&"message"in n&&typeof n.message=="string"}function AN(n){let t=r=>r.includes("Quota exceeded for quota metric 'Gemini")&&r.includes("Pro Requests'");if(typeof n=="string")return t(n);if(D2(n))return t(n.message);if(y5(n))return t(n.error.message);if(n&&typeof n=="object"&&"response"in n){let r=n;if(r.response&&r.response.data){if(typeof r.response.data=="string")return t(r.response.data);if(typeof r.response.data=="object"&&r.response.data!==null&&"error"in r.response.data){let a=r.response.data;return t(a.error?.message||"")}}}return!1}function WN(n){return typeof n=="string"?n.includes("Quota exceeded for quota metric"):D2(n)?n.message.includes("Quota exceeded for quota metric"):y5(n)?n.error.message.includes("Quota exceeded for quota metric"):!1}function O2(n){if(n&&typeof n=="object"&&"response"in n){let t=n;if(t.response?.status===402&&t.response.data){let r=t.response.data;if(r&&typeof r.error=="string"&&(r.error==="Quota limit exceeded"||r.error==="No quota configuration")&&typeof r.message=="string")return!0}}if(n instanceof Error&&n.message&&n.message.includes("API request failed (402):")&&(n.message.includes('"error":"Quota limit exceeded"')||n.message.includes('"error":"No quota configuration"')))return!0;if(typeof n=="object"&&n!==null){let t=n;return t.message&&typeof t.message=="string"&&(t.message.includes("API request failed (402):")&&(t.message.includes('"error":"Quota limit exceeded"')||t.message.includes('"error":"No quota configuration"'))||t.message.includes("API error (402):")&&(t.message.includes('"error":"Quota limit exceeded"')||t.message.includes('"error":"No quota configuration"')))?!0:(t.error==="Quota limit exceeded"||t.error==="No quota configuration")&&typeof t.message=="string"}return typeof n=="string"?n.includes("Quota limit exceeded")||n.includes("No quota configuration")||n.includes("Daily token limit would be exceeded")||n.includes("Daily request limit exceeded")||n.includes("Daily cost limit would be exceeded"):!1}function Pj(n){let t=null;if(n&&typeof n=="object"&&"response"in n){let r=n;r.response?.status===402&&r.response.data&&(t=r.response.data)}else if(typeof n=="object"&&n!==null){let r=n;if(r.message&&typeof r.message=="string"&&r.message.includes("API request failed (402):")&&(r.message.includes('"error":"Quota limit exceeded"')||r.message.includes('"error":"No quota configuration"')))try{let a=r.message.match(/\{.*\}$/);a&&(t=JSON.parse(a[0]))}catch{}t||(t=n)}if(!t&&n instanceof Error&&n.message&&n.message.includes("API request failed (402):")&&(n.message.includes('"error":"Quota limit exceeded"')||n.message.includes('"error":"No quota configuration"')))try{let r=n.message.match(/\{.*\}$/);r&&(t=JSON.parse(r[0]))}catch{n.message.includes('"error":"No quota configuration"')?t={error:"No quota configuration",message:"User must be assigned a quota template by administrator"}:n.message.includes('"error":"Quota limit exceeded"')&&(t={error:"Quota limit exceeded",message:"Service quota limit exceeded"})}if(!t&&typeof n=="string"&&n.includes("API request failed (402):")&&(n.includes('"error":"Quota limit exceeded"')||n.includes('"error":"No quota configuration"')))try{let r=n.match(/\{.*\}$/);r&&(t=JSON.parse(r[0]))}catch{n.includes('"error":"No quota configuration"')?t={error:"No quota configuration",message:"User must be assigned a quota template by administrator"}:n.includes('"error":"Quota limit exceeded"')&&(t={error:"Quota limit exceeded",message:"Service quota limit exceeded"})}return t?dIr(t):null}function dIr(n){let r=(()=>{try{let a=process.env,i=a.LC_ALL||a.LC_CTYPE||a.LANG||"";return i.toLowerCase().includes("zh")||i.toLowerCase().includes("chinese")}catch{return!1}})();return n.error==="No quota configuration"?r?`\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
517
517
|
\u{1F6AB} \u5F53\u524D\u8D26\u6237\u53EF\u7528\u7684 Credit\uFF08\u79EF\u5206\uFF09\u4E0D\u8DB3\u4EE5\u7EE7\u7EED\u4F7F\u7528\u672C\u670D\u52A1
|
|
518
518
|
\u{1F4A1} \u8BF7\u8003\u8651\u8BA2\u9605\u66F4\u591A\u989D\u5EA6\u7684\u5957\u9910\u3002\u8BE6\u60C5\u8BF7\u8BBF\u95EE\u5B98\u7F51\uFF1Ahttps://dvcode.deepvlab.ai/
|
|
@@ -663,7 +663,7 @@ ${s}`;break;case"retry":yVt(s)&&(r[i]=s);break;case"id":FVt(s)&&(r[i]=s);break;c
|
|
|
663
663
|
|
|
664
664
|
Please check your Feishu authentication token and try again.
|
|
665
665
|
If the problem persists, you may need to re-authenticate.`);throw a.isAuthError=!0,a.statusCode=401,a}throw t}async generateContentStream(t,r){let a=vd.getModelForScene(r),i=this.config?.getModel(),s;if(i&&$l(i)?(t.model&&$l(t.model)?s=t.model:s=i,console.log(`[DeepV Server] (Stream) User is using custom model, overriding scene model for ${r}: ${s}`)):s=t.model||a||i||"auto",$l(s)&&this.config){let o=this.config.getCustomModelConfig(s);if(o)return console.log("[DeepV Server] Custom model detected, using streaming mode"),JVt(o,t,t.config?.abortSignal)}return process.env.DEEPV_CLOUD_MODE==="true"?this._generateContent(t,r):KAr(t.model)?this._generateContentStream(t,r):this._generateContent(t,r)}async _generateContent(t,r){let a=await this.generateContent(t,r);return(async function*(){yield a})()}async _generateContentStream(t,r){try{let a=vd.getModelForScene(r),i=this.config?.getModel(),s;i&&$l(i)?(t.model&&$l(t.model)?s=t.model:s=i,console.log(`[DeepV Server] (_Stream) User is using custom model, overriding scene model for ${r}: ${s}`)):s=t.model||a||i||"auto",process.env.DEBUG&&console.log(`[\u{1F3AF} Model Resolution (Stream)] Using model: ${s} for scene: ${r}`);let e={model:s,contents:this.cleanContents(iQ(t.contents)),config:{...t.config,stream:!0,httpOptions:{...t.config?.httpOptions,headers:{...t.config?.httpOptions?.headers,"X-Scene-Type":r,"X-Scene-Display":vd.getSceneDisplayName(r)}}}};ar.info(`[DeepV Server] Starting stream with model: ${s}`);let o=await this.callStreamAPI("/v1/chat/stream",e,t.config?.abortSignal);return this.createStreamGenerator(o,t.config?.abortSignal)}catch(a){return ar.error("[DeepV Server] Stream request failed",{error:a}),this.handleStreamError(a)}}async callStreamAPI(t,r,a){return Wb(()=>this.executeStreamAPICall(t,r,a),{shouldRetry:i=>O2(i)||i.message.includes("cancelled by user")||i.name==="AbortError"||i.message.includes("401")||i instanceof CI||i.message.includes("451")||i.message.includes("REGION_BLOCKED")?!1:!!(i.message.includes("429")||i.message.match(/5\d{2}/)||i instanceof TypeError&&(i.message.includes("fetch failed")||i.message.includes("ECONNREFUSED")))})}async executeStreamAPICall(t,r,a){let i=await ao.getUserHeaders(),s=`${ao.getProxyServerUrl()}${t}`;if(process.env.DEBUG){console.log("\u{1F50D} [DeepV Debug Stream] Proxy environment variables:"),console.log(" HTTP_PROXY:",process.env.HTTP_PROXY),console.log(" HTTPS_PROXY:",process.env.HTTPS_PROXY),console.log(" http_proxy:",process.env.http_proxy),console.log(" https_proxy:",process.env.https_proxy),console.log(" Target URL:",s);let d=(0,TVt.getGlobalDispatcher)();console.log("\u{1F50D} [DeepV Debug Stream] Global dispatcher:",d?.constructor?.name||"undefined"),d&&"uri"in d&&console.log(" Dispatcher URI:",d.uri)}let e=new AbortController,o=null;if(a)if(a.aborted)e.abort();else{let d=()=>{process.env.DEBUG&&console.log("[DeepV Server] Stream request cancelled by user"),e.abort()};a.addEventListener("abort",d),o=()=>a.removeEventListener("abort",d)}let u=Date.now();try{ar.debug("[DeepV Server] Making stream API call",{endpoint:t,url:s,model:r.model});let d=await fetch(s,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream",...i},body:JSON.stringify(r),signal:e.signal});if(!d.ok){let h=await d.text();if(d.status===401)throw console.error("[DeepV Server] Stream 401 Unauthorized - triggering auth dialog"),this.authHandler&&await this.authHandler(),new CI("Authentication required - please re-authenticate");if(d.status===451)throw console.error("[DeepV Server] Stream 451 Region Blocked - IMMEDIATE ABORT"),e.abort(),new Error(`REGION_BLOCKED_451: ${h}`);let c=new Error(`Stream API error (${d.status}): ${h}`);throw c.status=d.status,c}let I=Date.now()-u;return ar.debug("[DeepV Server] Stream API call initiated",{endpoint:t,duration:`${I}ms`,status:d.status}),d}catch(d){let I=Date.now()-u;throw o&&o(),d instanceof Error&&(d.message.includes("cancelled by user")||d.name==="AbortError")?(console.log("\u26A0\uFE0F \u6D41\u5F0F\u4EFB\u52A1\u5DF2\u53D6\u6D88"),d):(d instanceof Error&&d.message.includes("abort")?ar.warn("[DeepV Server] Stream API aborted",{endpoint:t,duration:`${I}ms`,reason:d.message}):ar.error("[DeepV Server] Stream API call failed",{endpoint:t,duration:`${I}ms`,error:d instanceof Error?d.message:d}),d)}finally{o&&o()}}async*createStreamGenerator(t,r){let a=t.body?.getReader();if(!a)throw new Error("No stream reader available");let i=new TextDecoder,s="",e=0,o=null,u=()=>{console.log("[DeepV Server] Stream cancelled by user - releasing reader and stopping consumption");try{a.cancel()}catch{}},d;r&&!r.aborted&&(d=u,r.addEventListener("abort",d));try{for(;;){if(r?.aborted){console.log("[DeepV Server] Stream generation cancelled by user - exiting loop"),o&&console.log("[DeepV Server] Partial token consumption recorded:",{inputTokens:o.promptTokenCount||0,outputTokens:o.candidatesTokenCount||0,totalTokens:o.totalTokenCount||0,stoppedReason:"user_cancelled",bytesReceived:e});break}let I;try{I=await this.withTimeout(a.read(),3e5,"[DeepV Server] Stream read timeout after 300s (no data received in this chunk)")}catch(W){if(W instanceof Error&&(W.name==="AbortError"||W.message.includes("cancelled"))){console.log("[DeepV Server] Stream read cancelled - exiting");break}throw W}let{done:h,value:c}=I;if(h)break;e+=c.length,s+=i.decode(c,{stream:!0});let G=s.split(`
|
|
666
|
-
`);s=G.pop()||"";for(let W of G)if(W.startsWith("data: ")){let y=W.slice(6);if(y==="[DONE]")return;try{let R=JSON.parse(y);if(R.type==="connection_established")continue;if(R.error)throw new Error(R.error);R.usageMetadata&&(o=R.usageMetadata);let F=this.convertStreamChunkToGenAI(R);F&&(yield F)}catch(R){ar.warn("[DeepV Server] Stream chunk parse error",{data:y.substring(0,100)+"...",error:R instanceof Error?R.message:R})}}}}finally{d&&r&&r.removeEventListener("abort",d);try{a.releaseLock()}catch{}}}convertStreamChunkToGenAI(t){if(!t.candidates||!Array.isArray(t.candidates)||t.candidates.length===0)return null;let r={candidates:t.candidates,usageMetadata:t.usageMetadata};if(r.candidates?.[0]?.content?.parts){for(let a of r.candidates[0].content.parts)if(a.functionCall&&!a.functionCall.id){let i=`call_${Date.now()}_${Math.random().toString(36).substring(2,9)}`;console.log(`[DeepV Server] \u8865\u5168\u7F3A\u5931\u7684\u5DE5\u5177 ID (Chunk): ${a.functionCall.name} -> ${i}`),a.functionCall.id=i}}return r.functionCalls||Object.defineProperty(r,"functionCalls",{get:function(){if(this.candidates?.[0]?.content?.parts?.length===0)return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning function calls from the first one.");let a=this.candidates?.[0]?.content?.parts?.filter(i=>i.functionCall).map(i=>i.functionCall).filter(i=>i!==void 0);if(a?.length!==0)return a},enumerable:!1,configurable:!0}),r}mergeStreamContent(t,r){if(!t)return r;let a=t.candidates?.[0]?.content?.parts||[],i=r.candidates?.[0]?.content?.parts||[];if(i.length>0&&i[0].text){let s=a[a.length-1];s&&s.text&&!s.functionCall?s.text+=i[0].text:a.push(...i)}else if(i.length>0&&i[0].functionCall){let s=a[a.length-1],e=i[0];if(s&&s.functionCall){let o=s.functionCall,u=e.functionCall;u&&(u.name&&(o.name=u.name),u.id&&(o.id=u.id),u.args&&(typeof u.args=="string"&&typeof o.args=="string"?o.args+=u.args:typeof u.args=="object"&&u.args!==null?o.args={...typeof o.args=="object"?o.args:{},...u.args}:o.args=u.args))}else{let o={...e};if(o.functionCall&&!o.functionCall.id){let u=`call_${Date.now()}_${Math.random().toString(36).substring(2,9)}`;console.log(`[DeepV Server] \u8865\u5168\u7F3A\u5931\u7684\u5DE5\u5177 ID: ${o.functionCall.name} -> ${u}`),o.functionCall.id=u}a.push(o)}}return r.usageMetadata&&(t.usageMetadata=r.usageMetadata),r.candidates?.[0]?.finishReason&&(t.candidates[0].finishReason=r.candidates[0].finishReason),t}buildUnifiedRequest(t,r){let a=vd.getModelForScene(r),i=this.config?.getModel(),s;return i&&$l(i)?t.model&&$l(t.model)?s=t.model:s=i:s=t.model||a||"auto",{model:s,contents:t.contents,config:{...t.config,httpOptions:{...t.config?.httpOptions,headers:{...t.config?.httpOptions?.headers,"X-Scene-Type":r,"X-Scene-Display":vd.getSceneDisplayName(r)}}}}}async*handleStreamError(t){this.handleError(t)}async countTokens(t){try{let r=t.model||this.config?.getModel()||"auto";if($l(r))return ar.debug("[DeepV Server] Custom model detected, token counting not supported"),{totalTokens:0};let a={model:r,contents:t.contents};(t.config?.systemInstruction||t.config?.tools)&&(a.config={},t.config.systemInstruction&&(a.config.systemInstruction=t.config.systemInstruction),t.config.tools&&(a.config.tools=t.config.tools));let i=await this.callUnifiedTokenCountAPI(a);return U2.emitRealTimeToken({inputTokens:i.totalTokens||0,outputTokens:0,totalTokens:i.totalTokens||0,timestamp:Date.now()}),i}catch(r){let a=t.model||this.config?.getModel()||"auto";return $l(a)?ar.debug("[DeepV Server] Token count not available for custom model, using fallback"):ar.error("[DeepV Server] Token count failed:",r),this.estimateTokensAsFailback(t)}}async callUnifiedTokenCountAPI(t){let r=await ao.getUserHeaders(),a=`${ao.getProxyServerUrl()}/v1/chat/count-tokens`;try{let i=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json",...r},body:JSON.stringify(t)});if(!i.ok){let e=await i.text();throw i.status===401?(console.error("[DeepV Server] Token count 401 Unauthorized"),this.authHandler&&await this.authHandler(),new CI("Authentication required - please re-authenticate")):new Error(`Token count API failed (${i.status}): ${e}`)}let s=await i.json();return ar.debug("[DeepV Server] Token count response",{totalTokens:s.totalTokens}),{totalTokens:s.totalTokens||0}}catch(i){throw ar.error("[DeepV Server] Token count API call failed:",i),i}}estimateTokensAsFailback(t){try{let r=Array.isArray(t.contents)?t.contents:[{role:jr.USER,parts:[{text:t.contents}]}],a=0,i=0,s=0,e=0;for(let c of r)if(typeof c=="object"&&c&&"parts"in c&&Array.isArray(c.parts)){for(let G of c.parts)if(typeof G=="object"&&G&&"text"in G&&typeof G.text=="string")a+=G.text.length,e++;else if(typeof G=="object"&&G&&"functionCall"in G&&G.functionCall){let W=G.functionCall,y=`[Tool: ${W.name}]`+JSON.stringify(W.args||{});a+=y.length,i++}else if(typeof G=="object"&&G&&"functionResponse"in G&&G.functionResponse){let R=`[Tool Result: ${G.functionResponse.response?.output||"result"}]`;a+=R.length+20,s++}}else typeof c=="string"&&(a+=c.length,e++);let o=JSON.stringify(r),u=/[\u4e00-\u9fff]/.test(o),d=/```|function|class|import|export|\{|\}|\[|\]/.test(o),I=4;return u?I=2:d&&(I=3),{totalTokens:Math.ceil(a/I)}}catch(r){return console.error("[DeepV Server] Fallback estimation error:",r),{totalTokens:1e3}}}async embedContent(t){throw new Error("Claude models do not support embedding content")}withTimeout(t,r,a){let i=null,s=new Promise((e,o)=>{i=setTimeout(()=>{o(new Error(a))},r)});return Promise.race([t,s]).finally(()=>{i!==null&&clearTimeout(i)})}}});function $Le(n,t){let r=n.getModel()||"auto",a={authType:t,proxy:n?.getProxy()};return t===es.USE_PROXY_AUTH,a}async function eSe(n,t,r){let i={headers:{"User-Agent":`GeminiCLI/1.0.290 (${process.platform}; ${process.arch})`}};if(!0){let e=t.getCustomProxyServerUrl(),o;if(e)o=e,console.log(`[DeepX] Using custom proxy server: ${o}`);else{if(!QHe())throw new Error("DeepV Code server is required for all models but is not available. Please start the DeepV Code server or use proxy authentication.");o=mW(),console.log(`[DeepX] Connecting to DeepV Code server: ${o}`)}let u=process.env.GOOGLE_CLOUD_LOCATION||"us-central1",d=process.env.GOOGLE_CLOUD_PROJECT||"default-project";return new pJ(u,d,o,t)}throw new Error(`Error creating contentGenerator: Unsupported authType: ${n.authType}`)}var es,Ime=ut(()=>{"use strict";qLe();vB();(function(n){n.USE_PROXY_AUTH="proxy-auth"})(es||(es={}))});var dme,DVt=ut(()=>{"use strict";dme=class{prompts=new Map;registerPrompt(t){if(this.prompts.has(t.name)){let r=`${t.serverName}_${t.name}`;console.warn(`Prompt with name "${t.name}" is already registered. Renaming to "${r}".`),this.prompts.set(r,{...t,name:r})}else this.prompts.set(t.name,t)}getAllPrompts(){return Array.from(this.prompts.values()).sort((t,r)=>t.name.localeCompare(r.name))}getPrompt(t){return this.prompts.get(t)}getPromptsByServer(t){let r=[];for(let a of this.prompts.values())a.serverName===t&&r.push(a);return r.sort((a,i)=>a.name.localeCompare(i.name))}removePromptsByServer(t){for(let[r,a]of this.prompts.entries())a.serverName===t&&this.prompts.delete(r)}}});function xN(n){let t={type:"subagent_update",data:n,timestamp:Date.now()};return JSON.stringify(t)}function OVt(n){let t={type:"text",data:n,timestamp:Date.now()};return JSON.stringify(t)}function hme(n){try{let t=JSON.parse(n);if(t&&typeof t=="object"&&t.type&&t.data!==void 0)return t}catch{}return{type:"text",data:n,timestamp:Date.now()}}function mme(n){return n.type==="subagent_update"}function pme(n){return n.type==="text"}var tSe=ut(()=>{"use strict";});var $r,zr,ea,Ql=ut(()=>{"use strict";tSe();$r=class{name;displayName;description;icon;parameterSchema;isOutputMarkdown;forceMarkdown;canUpdateOutput;allowSubAgentUse;constructor(t,r,a,i,s,e=!0,o=!1,u=!1,d=!0){this.name=t,this.displayName=r,this.description=a,this.icon=i,this.parameterSchema=s,this.isOutputMarkdown=e,this.forceMarkdown=o,this.canUpdateOutput=u,this.allowSubAgentUse=d}get schema(){return{name:this.name,description:this.description,parameters:this.parameterSchema}}validateToolParams(t){return null}getDescription(t){return JSON.stringify(t)}shouldConfirmExecute(t,r){return Promise.resolve(!1)}toolLocations(t){return[]}};(function(n){n.ProceedOnce="proceed_once",n.ProceedAlways="proceed_always",n.ProceedAlwaysServer="proceed_always_server",n.ProceedAlwaysTool="proceed_always_tool",n.ProceedAlwaysProject="proceed_always_project",n.ModifyWithEditor="modify_with_editor",n.Cancel="cancel"})(zr||(zr={}));(function(n){n.FileSearch="fileSearch",n.Folder="folder",n.Globe="globe",n.Hammer="hammer",n.LightBulb="lightBulb",n.Pencil="pencil",n.Regex="regex",n.Terminal="terminal",n.Clipboard="clipboard",n.Tasks="tasks",n.Wrench="wrench",n.Trash="trash",n.List="list",n.Info="info"})(ea||(ea={}))});var Hl,nSe,ta,QW,nq=ut(()=>{(function(n){n.assertEqual=i=>{};function t(i){}n.assertIs=t;function r(i){throw new Error}n.assertNever=r,n.arrayToEnum=i=>{let s={};for(let e of i)s[e]=e;return s},n.getValidEnumValues=i=>{let s=n.objectKeys(i).filter(o=>typeof i[i[o]]!="number"),e={};for(let o of s)e[o]=i[o];return n.objectValues(e)},n.objectValues=i=>n.objectKeys(i).map(function(s){return i[s]}),n.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{let s=[];for(let e in i)Object.prototype.hasOwnProperty.call(i,e)&&s.push(e);return s},n.find=(i,s)=>{for(let e of i)if(s(e))return e},n.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&Number.isFinite(i)&&Math.floor(i)===i;function a(i,s=" | "){return i.map(e=>typeof e=="string"?`'${e}'`:e).join(s)}n.joinValues=a,n.jsonStringifyReplacer=(i,s)=>typeof s=="bigint"?s.toString():s})(Hl||(Hl={}));(function(n){n.mergeShapes=(t,r)=>({...t,...r})})(nSe||(nSe={}));ta=Hl.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),QW=n=>{switch(typeof n){case"undefined":return ta.undefined;case"string":return ta.string;case"number":return Number.isNaN(n)?ta.nan:ta.number;case"boolean":return ta.boolean;case"function":return ta.function;case"bigint":return ta.bigint;case"symbol":return ta.symbol;case"object":return Array.isArray(n)?ta.array:n===null?ta.null:n.then&&typeof n.then=="function"&&n.catch&&typeof n.catch=="function"?ta.promise:typeof Map<"u"&&n instanceof Map?ta.map:typeof Set<"u"&&n instanceof Set?ta.set:typeof Date<"u"&&n instanceof Date?ta.date:ta.object;default:return ta.unknown}}});var vr,qAr,tf,bme=ut(()=>{nq();vr=Hl.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"]),qAr=n=>JSON.stringify(n,null,2).replace(/"([^"]+)":/g,"$1:"),tf=class n extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=a=>{this.issues=[...this.issues,a]},this.addIssues=(a=[])=>{this.issues=[...this.issues,...a]};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(s){return s.message},a={_errors:[]},i=s=>{for(let e of s.issues)if(e.code==="invalid_union")e.unionErrors.map(i);else if(e.code==="invalid_return_type")i(e.returnTypeError);else if(e.code==="invalid_arguments")i(e.argumentsError);else if(e.path.length===0)a._errors.push(r(e));else{let o=a,u=0;for(;u<e.path.length;){let d=e.path[u];u===e.path.length-1?(o[d]=o[d]||{_errors:[]},o[d]._errors.push(r(e))):o[d]=o[d]||{_errors:[]},o=o[d],u++}}};return i(this),a}static assert(t){if(!(t instanceof n))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Hl.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=r=>r.message){let r={},a=[];for(let i of this.issues)if(i.path.length>0){let s=i.path[0];r[s]=r[s]||[],r[s].push(t(i))}else a.push(t(i));return{formErrors:a,fieldErrors:r}}get formErrors(){return this.flatten()}};tf.create=n=>new tf(n)});var $Ar,X5,rSe=ut(()=>{bme();nq();$Ar=(n,t)=>{let r;switch(n.code){case vr.invalid_type:n.received===ta.undefined?r="Required":r=`Expected ${n.expected}, received ${n.received}`;break;case vr.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(n.expected,Hl.jsonStringifyReplacer)}`;break;case vr.unrecognized_keys:r=`Unrecognized key(s) in object: ${Hl.joinValues(n.keys,", ")}`;break;case vr.invalid_union:r="Invalid input";break;case vr.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${Hl.joinValues(n.options)}`;break;case vr.invalid_enum_value:r=`Invalid enum value. Expected ${Hl.joinValues(n.options)}, received '${n.received}'`;break;case vr.invalid_arguments:r="Invalid function arguments";break;case vr.invalid_return_type:r="Invalid function return type";break;case vr.invalid_date:r="Invalid date";break;case vr.invalid_string:typeof n.validation=="object"?"includes"in n.validation?(r=`Invalid input: must include "${n.validation.includes}"`,typeof n.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${n.validation.position}`)):"startsWith"in n.validation?r=`Invalid input: must start with "${n.validation.startsWith}"`:"endsWith"in n.validation?r=`Invalid input: must end with "${n.validation.endsWith}"`:Hl.assertNever(n.validation):n.validation!=="regex"?r=`Invalid ${n.validation}`:r="Invalid";break;case vr.too_small:n.type==="array"?r=`Array must contain ${n.exact?"exactly":n.inclusive?"at least":"more than"} ${n.minimum} element(s)`:n.type==="string"?r=`String must contain ${n.exact?"exactly":n.inclusive?"at least":"over"} ${n.minimum} character(s)`:n.type==="number"?r=`Number must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${n.minimum}`:n.type==="bigint"?r=`Number must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${n.minimum}`:n.type==="date"?r=`Date must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(n.minimum))}`:r="Invalid input";break;case vr.too_big:n.type==="array"?r=`Array must contain ${n.exact?"exactly":n.inclusive?"at most":"less than"} ${n.maximum} element(s)`:n.type==="string"?r=`String must contain ${n.exact?"exactly":n.inclusive?"at most":"under"} ${n.maximum} character(s)`:n.type==="number"?r=`Number must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="bigint"?r=`BigInt must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="date"?r=`Date must be ${n.exact?"exactly":n.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(n.maximum))}`:r="Invalid input";break;case vr.custom:r="Invalid input";break;case vr.invalid_intersection_types:r="Intersection results could not be merged";break;case vr.not_multiple_of:r=`Number must be a multiple of ${n.multipleOf}`;break;case vr.not_finite:r="Number must be finite";break;default:r=t.defaultError,Hl.assertNever(n)}return{message:r}},X5=$Ar});function e3r(n){UVt=n}function bJ(){return UVt}var UVt,fme=ut(()=>{rSe();UVt=X5});function Tr(n,t){let r=bJ(),a=rq({issueData:t,data:n.data,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,r,r===X5?void 0:X5].filter(i=>!!i)});n.common.issues.push(a)}var rq,t3r,qh,$a,kQ,ip,Gme,gme,Nw,fJ,aSe=ut(()=>{fme();rSe();rq=n=>{let{data:t,path:r,errorMaps:a,issueData:i}=n,s=[...r,...i.path||[]],e={...i,path:s};if(i.message!==void 0)return{...i,path:s,message:i.message};let o="",u=a.filter(d=>!!d).slice().reverse();for(let d of u)o=d(e,{data:t,defaultError:o}).message;return{...i,path:s,message:o}},t3r=[];qh=class n{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,r){let a=[];for(let i of r){if(i.status==="aborted")return $a;i.status==="dirty"&&t.dirty(),a.push(i.value)}return{status:t.value,value:a}}static async mergeObjectAsync(t,r){let a=[];for(let i of r){let s=await i.key,e=await i.value;a.push({key:s,value:e})}return n.mergeObjectSync(t,a)}static mergeObjectSync(t,r){let a={};for(let i of r){let{key:s,value:e}=i;if(s.status==="aborted"||e.status==="aborted")return $a;s.status==="dirty"&&t.dirty(),e.status==="dirty"&&t.dirty(),s.value!=="__proto__"&&(typeof e.value<"u"||i.alwaysSet)&&(a[s.value]=e.value)}return{status:t.value,value:a}}},$a=Object.freeze({status:"aborted"}),kQ=n=>({status:"dirty",value:n}),ip=n=>({status:"valid",value:n}),Gme=n=>n.status==="aborted",gme=n=>n.status==="dirty",Nw=n=>n.status==="valid",fJ=n=>typeof Promise<"u"&&n instanceof Promise});var MVt=ut(()=>{});var Na,zVt=ut(()=>{(function(n){n.errToObj=t=>typeof t=="string"?{message:t}:t||{},n.toString=t=>typeof t=="string"?t:t?.message})(Na||(Na={}))});function Oi(n){if(!n)return{};let{errorMap:t,invalid_type_error:r,required_error:a,description:i}=n;if(t&&(r||a))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:i}:{errorMap:(e,o)=>{let{message:u}=n;return e.code==="invalid_enum_value"?{message:u??o.defaultError}:typeof o.data>"u"?{message:u??a??o.defaultError}:e.code!=="invalid_type"?{message:o.defaultError}:{message:u??r??o.defaultError}},description:i}}function KVt(n){let t="[0-5]\\d";n.precision?t=`${t}\\.\\d{${n.precision}}`:n.precision==null&&(t=`${t}(\\.\\d+)?`);let r=n.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${r}`}function G3r(n){return new RegExp(`^${KVt(n)}$`)}function qVt(n){let t=`${jVt}T${KVt(n)}`,r=[];return r.push(n.local?"Z?":"Z"),n.offset&&r.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${r.join("|")})`,new RegExp(`^${t}$`)}function g3r(n,t){return!!((t==="v4"||!t)&&I3r.test(n)||(t==="v6"||!t)&&h3r.test(n))}function v3r(n,t){if(!s3r.test(n))return!1;try{let[r]=n.split(".");if(!r)return!1;let a=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),i=JSON.parse(atob(a));return!(typeof i!="object"||i===null||"typ"in i&&i?.typ!=="JWT"||!i.alg||t&&i.alg!==t)}catch{return!1}}function Z3r(n,t){return!!((t==="v4"||!t)&&d3r.test(n)||(t==="v6"||!t)&&m3r.test(n))}function N3r(n,t){let r=(n.toString().split(".")[1]||"").length,a=(t.toString().split(".")[1]||"").length,i=r>a?r:a,s=Number.parseInt(n.toFixed(i).replace(".","")),e=Number.parseInt(t.toFixed(i).replace(".",""));return s%e/10**i}function GJ(n){if(n instanceof nf){let t={};for(let r in n.shape){let a=n.shape[r];t[r]=sv.create(GJ(a))}return new nf({...n._def,shape:()=>t})}else return n instanceof S5?new S5({...n._def,type:GJ(n.element)}):n instanceof sv?sv.create(GJ(n.unwrap())):n instanceof XW?XW.create(GJ(n.unwrap())):n instanceof HW?HW.create(n.items.map(t=>GJ(t))):n}function lSe(n,t){let r=QW(n),a=QW(t);if(n===t)return{valid:!0,data:n};if(r===ta.object&&a===ta.object){let i=Hl.objectKeys(t),s=Hl.objectKeys(n).filter(o=>i.indexOf(o)!==-1),e={...n,...t};for(let o of s){let u=lSe(n[o],t[o]);if(!u.valid)return{valid:!1};e[o]=u.data}return{valid:!0,data:e}}else if(r===ta.array&&a===ta.array){if(n.length!==t.length)return{valid:!1};let i=[];for(let s=0;s<n.length;s++){let e=n[s],o=t[s],u=lSe(e,o);if(!u.valid)return{valid:!1};i.push(u.data)}return{valid:!0,data:i}}else return r===ta.date&&a===ta.date&&+n==+t?{valid:!0,data:n}:{valid:!1}}function $Vt(n,t){return new _Q({values:n,typeName:ai.ZodEnum,...Oi(t)})}function PVt(n,t){let r=typeof n=="function"?n(t):typeof n=="string"?{message:n}:n;return typeof r=="string"?{message:r}:r}function eQt(n,t={},r){return n?Ww.create().superRefine((a,i)=>{let s=n(a);if(s instanceof Promise)return s.then(e=>{if(!e){let o=PVt(t,a),u=o.fatal??r??!0;i.addIssue({code:"custom",...o,fatal:u})}});if(!s){let e=PVt(t,a),o=e.fatal??r??!0;i.addIssue({code:"custom",...e,fatal:o})}}):Ww.create()}var ov,_Vt,al,n3r,r3r,a3r,i3r,l3r,s3r,o3r,c3r,u3r,iSe,I3r,d3r,h3r,m3r,p3r,b3r,jVt,f3r,Aw,LQ,SQ,BQ,JQ,gJ,TQ,DQ,Ww,L5,VN,vJ,S5,nf,OQ,k5,vme,UQ,HW,Zme,ZJ,NJ,Nme,MQ,zQ,_Q,PQ,yw,cv,sv,XW,jQ,KQ,AJ,A3r,aq,iq,qQ,W3r,ai,y3r,tQt,nQt,F3r,E3r,rQt,R3r,w3r,C3r,Y3r,x3r,V3r,Q3r,H3r,X3r,k3r,L3r,S3r,B3r,J3r,T3r,D3r,O3r,U3r,M3r,z3r,_3r,P3r,j3r,K3r,q3r,$3r,eWr,tWr,nWr,rWr,aWr,iWr,lWr,sWr,aQt=ut(()=>{bme();fme();zVt();aSe();nq();ov=class{constructor(t,r,a,i){this._cachedPath=[],this.parent=t,this.data=r,this._path=a,this._key=i}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}},_Vt=(n,t)=>{if(Nw(t))return{success:!0,data:t.value};if(!n.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 tf(n.common.issues);return this._error=r,this._error}}};al=class{get description(){return this._def.description}_getType(t){return QW(t.data)}_getOrReturnCtx(t,r){return r||{common:t.parent.common,data:t.data,parsedType:QW(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new qh,ctx:{common:t.parent.common,data:t.data,parsedType:QW(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){let r=this._parse(t);if(fJ(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 a=this.safeParse(t,r);if(a.success)return a.data;throw a.error}safeParse(t,r){let a={common:{issues:[],async:r?.async??!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:QW(t)},i=this._parseSync({data:t,path:a.path,parent:a});return _Vt(a,i)}"~validate"(t){let r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:QW(t)};if(!this["~standard"].async)try{let a=this._parseSync({data:t,path:[],parent:r});return Nw(a)?{value:a.value}:{issues:r.common.issues}}catch(a){a?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:r}).then(a=>Nw(a)?{value:a.value}:{issues:r.common.issues})}async parseAsync(t,r){let a=await this.safeParseAsync(t,r);if(a.success)return a.data;throw a.error}async safeParseAsync(t,r){let a={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:QW(t)},i=this._parse({data:t,path:a.path,parent:a}),s=await(fJ(i)?i:Promise.resolve(i));return _Vt(a,s)}refine(t,r){let a=i=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(i):r;return this._refinement((i,s)=>{let e=t(i),o=()=>s.addIssue({code:vr.custom,...a(i)});return typeof Promise<"u"&&e instanceof Promise?e.then(u=>u?!0:(o(),!1)):e?!0:(o(),!1)})}refinement(t,r){return this._refinement((a,i)=>t(a)?!0:(i.addIssue(typeof r=="function"?r(a,i):r),!1))}_refinement(t){return new cv({schema:this,typeName:ai.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 sv.create(this,this._def)}nullable(){return XW.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return S5.create(this)}promise(){return yw.create(this,this._def)}or(t){return OQ.create([this,t],this._def)}and(t){return UQ.create(this,t,this._def)}transform(t){return new cv({...Oi(this._def),schema:this,typeName:ai.ZodEffects,effect:{type:"transform",transform:t}})}default(t){let r=typeof t=="function"?t:()=>t;return new jQ({...Oi(this._def),innerType:this,defaultValue:r,typeName:ai.ZodDefault})}brand(){return new aq({typeName:ai.ZodBranded,type:this,...Oi(this._def)})}catch(t){let r=typeof t=="function"?t:()=>t;return new KQ({...Oi(this._def),innerType:this,catchValue:r,typeName:ai.ZodCatch})}describe(t){let r=this.constructor;return new r({...this._def,description:t})}pipe(t){return iq.create(this,t)}readonly(){return qQ.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},n3r=/^c[^\s-]{8,}$/i,r3r=/^[0-9a-z]+$/,a3r=/^[0-9A-HJKMNP-TV-Z]{26}$/i,i3r=/^[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,l3r=/^[a-z0-9_-]{21}$/i,s3r=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,o3r=/^[-+]?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)?)??$/,c3r=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,u3r="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",I3r=/^(?:(?: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])$/,d3r=/^(?:(?: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])$/,h3r=/^(([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]))$/,m3r=/^(([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])$/,p3r=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,b3r=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,jVt="((\\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])))",f3r=new RegExp(`^${jVt}$`);Aw=class n extends al{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==ta.string){let s=this._getOrReturnCtx(t);return Tr(s,{code:vr.invalid_type,expected:ta.string,received:s.parsedType}),$a}let a=new qh,i;for(let s of this._def.checks)if(s.kind==="min")t.data.length<s.value&&(i=this._getOrReturnCtx(t,i),Tr(i,{code:vr.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),a.dirty());else if(s.kind==="max")t.data.length>s.value&&(i=this._getOrReturnCtx(t,i),Tr(i,{code:vr.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),a.dirty());else if(s.kind==="length"){let e=t.data.length>s.value,o=t.data.length<s.value;(e||o)&&(i=this._getOrReturnCtx(t,i),e?Tr(i,{code:vr.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):o&&Tr(i,{code:vr.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),a.dirty())}else if(s.kind==="email")c3r.test(t.data)||(i=this._getOrReturnCtx(t,i),Tr(i,{validation:"email",code:vr.invalid_string,message:s.message}),a.dirty());else if(s.kind==="emoji")iSe||(iSe=new RegExp(u3r,"u")),iSe.test(t.data)||(i=this._getOrReturnCtx(t,i),Tr(i,{validation:"emoji",code:vr.invalid_string,message:s.message}),a.dirty());else if(s.kind==="uuid")i3r.test(t.data)||(i=this._getOrReturnCtx(t,i),Tr(i,{validation:"uuid",code:vr.invalid_string,message:s.message}),a.dirty());else if(s.kind==="nanoid")l3r.test(t.data)||(i=this._getOrReturnCtx(t,i),Tr(i,{validation:"nanoid",code:vr.invalid_string,message:s.message}),a.dirty());else if(s.kind==="cuid")n3r.test(t.data)||(i=this._getOrReturnCtx(t,i),Tr(i,{validation:"cuid",code:vr.invalid_string,message:s.message}),a.dirty());else if(s.kind==="cuid2")r3r.test(t.data)||(i=this._getOrReturnCtx(t,i),Tr(i,{validation:"cuid2",code:vr.invalid_string,message:s.message}),a.dirty());else if(s.kind==="ulid")a3r.test(t.data)||(i=this._getOrReturnCtx(t,i),Tr(i,{validation:"ulid",code:vr.invalid_string,message:s.message}),a.dirty());else if(s.kind==="url")try{new URL(t.data)}catch{i=this._getOrReturnCtx(t,i),Tr(i,{validation:"url",code:vr.invalid_string,message:s.message}),a.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(t.data)||(i=this._getOrReturnCtx(t,i),Tr(i,{validation:"regex",code:vr.invalid_string,message:s.message}),a.dirty())):s.kind==="trim"?t.data=t.data.trim():s.kind==="includes"?t.data.includes(s.value,s.position)||(i=this._getOrReturnCtx(t,i),Tr(i,{code:vr.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),a.dirty()):s.kind==="toLowerCase"?t.data=t.data.toLowerCase():s.kind==="toUpperCase"?t.data=t.data.toUpperCase():s.kind==="startsWith"?t.data.startsWith(s.value)||(i=this._getOrReturnCtx(t,i),Tr(i,{code:vr.invalid_string,validation:{startsWith:s.value},message:s.message}),a.dirty()):s.kind==="endsWith"?t.data.endsWith(s.value)||(i=this._getOrReturnCtx(t,i),Tr(i,{code:vr.invalid_string,validation:{endsWith:s.value},message:s.message}),a.dirty()):s.kind==="datetime"?qVt(s).test(t.data)||(i=this._getOrReturnCtx(t,i),Tr(i,{code:vr.invalid_string,validation:"datetime",message:s.message}),a.dirty()):s.kind==="date"?f3r.test(t.data)||(i=this._getOrReturnCtx(t,i),Tr(i,{code:vr.invalid_string,validation:"date",message:s.message}),a.dirty()):s.kind==="time"?G3r(s).test(t.data)||(i=this._getOrReturnCtx(t,i),Tr(i,{code:vr.invalid_string,validation:"time",message:s.message}),a.dirty()):s.kind==="duration"?o3r.test(t.data)||(i=this._getOrReturnCtx(t,i),Tr(i,{validation:"duration",code:vr.invalid_string,message:s.message}),a.dirty()):s.kind==="ip"?g3r(t.data,s.version)||(i=this._getOrReturnCtx(t,i),Tr(i,{validation:"ip",code:vr.invalid_string,message:s.message}),a.dirty()):s.kind==="jwt"?v3r(t.data,s.alg)||(i=this._getOrReturnCtx(t,i),Tr(i,{validation:"jwt",code:vr.invalid_string,message:s.message}),a.dirty()):s.kind==="cidr"?Z3r(t.data,s.version)||(i=this._getOrReturnCtx(t,i),Tr(i,{validation:"cidr",code:vr.invalid_string,message:s.message}),a.dirty()):s.kind==="base64"?p3r.test(t.data)||(i=this._getOrReturnCtx(t,i),Tr(i,{validation:"base64",code:vr.invalid_string,message:s.message}),a.dirty()):s.kind==="base64url"?b3r.test(t.data)||(i=this._getOrReturnCtx(t,i),Tr(i,{validation:"base64url",code:vr.invalid_string,message:s.message}),a.dirty()):Hl.assertNever(s);return{status:a.value,value:t.data}}_regex(t,r,a){return this.refinement(i=>t.test(i),{validation:r,code:vr.invalid_string,...Na.errToObj(a)})}_addCheck(t){return new n({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...Na.errToObj(t)})}url(t){return this._addCheck({kind:"url",...Na.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...Na.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...Na.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...Na.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...Na.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...Na.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...Na.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...Na.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...Na.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...Na.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...Na.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...Na.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,...Na.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,...Na.errToObj(t?.message)})}duration(t){return this._addCheck({kind:"duration",...Na.errToObj(t)})}regex(t,r){return this._addCheck({kind:"regex",regex:t,...Na.errToObj(r)})}includes(t,r){return this._addCheck({kind:"includes",value:t,position:r?.position,...Na.errToObj(r?.message)})}startsWith(t,r){return this._addCheck({kind:"startsWith",value:t,...Na.errToObj(r)})}endsWith(t,r){return this._addCheck({kind:"endsWith",value:t,...Na.errToObj(r)})}min(t,r){return this._addCheck({kind:"min",value:t,...Na.errToObj(r)})}max(t,r){return this._addCheck({kind:"max",value:t,...Na.errToObj(r)})}length(t,r){return this._addCheck({kind:"length",value:t,...Na.errToObj(r)})}nonempty(t){return this.min(1,Na.errToObj(t))}trim(){return new n({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new n({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new n({...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}};Aw.create=n=>new Aw({checks:[],typeName:ai.ZodString,coerce:n?.coerce??!1,...Oi(n)});LQ=class n extends al{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)!==ta.number){let s=this._getOrReturnCtx(t);return Tr(s,{code:vr.invalid_type,expected:ta.number,received:s.parsedType}),$a}let a,i=new qh;for(let s of this._def.checks)s.kind==="int"?Hl.isInteger(t.data)||(a=this._getOrReturnCtx(t,a),Tr(a,{code:vr.invalid_type,expected:"integer",received:"float",message:s.message}),i.dirty()):s.kind==="min"?(s.inclusive?t.data<s.value:t.data<=s.value)&&(a=this._getOrReturnCtx(t,a),Tr(a,{code:vr.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?t.data>s.value:t.data>=s.value)&&(a=this._getOrReturnCtx(t,a),Tr(a,{code:vr.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="multipleOf"?N3r(t.data,s.value)!==0&&(a=this._getOrReturnCtx(t,a),Tr(a,{code:vr.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):s.kind==="finite"?Number.isFinite(t.data)||(a=this._getOrReturnCtx(t,a),Tr(a,{code:vr.not_finite,message:s.message}),i.dirty()):Hl.assertNever(s);return{status:i.value,value:t.data}}gte(t,r){return this.setLimit("min",t,!0,Na.toString(r))}gt(t,r){return this.setLimit("min",t,!1,Na.toString(r))}lte(t,r){return this.setLimit("max",t,!0,Na.toString(r))}lt(t,r){return this.setLimit("max",t,!1,Na.toString(r))}setLimit(t,r,a,i){return new n({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:a,message:Na.toString(i)}]})}_addCheck(t){return new n({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:Na.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Na.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Na.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Na.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Na.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:Na.toString(r)})}finite(t){return this._addCheck({kind:"finite",message:Na.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Na.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Na.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"&&Hl.isInteger(t.value))}get isFinite(){let t=null,r=null;for(let a of this._def.checks){if(a.kind==="finite"||a.kind==="int"||a.kind==="multipleOf")return!0;a.kind==="min"?(r===null||a.value>r)&&(r=a.value):a.kind==="max"&&(t===null||a.value<t)&&(t=a.value)}return Number.isFinite(r)&&Number.isFinite(t)}};LQ.create=n=>new LQ({checks:[],typeName:ai.ZodNumber,coerce:n?.coerce||!1,...Oi(n)});SQ=class n extends al{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)!==ta.bigint)return this._getInvalidInput(t);let a,i=new qh;for(let s of this._def.checks)s.kind==="min"?(s.inclusive?t.data<s.value:t.data<=s.value)&&(a=this._getOrReturnCtx(t,a),Tr(a,{code:vr.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?t.data>s.value:t.data>=s.value)&&(a=this._getOrReturnCtx(t,a),Tr(a,{code:vr.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="multipleOf"?t.data%s.value!==BigInt(0)&&(a=this._getOrReturnCtx(t,a),Tr(a,{code:vr.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):Hl.assertNever(s);return{status:i.value,value:t.data}}_getInvalidInput(t){let r=this._getOrReturnCtx(t);return Tr(r,{code:vr.invalid_type,expected:ta.bigint,received:r.parsedType}),$a}gte(t,r){return this.setLimit("min",t,!0,Na.toString(r))}gt(t,r){return this.setLimit("min",t,!1,Na.toString(r))}lte(t,r){return this.setLimit("max",t,!0,Na.toString(r))}lt(t,r){return this.setLimit("max",t,!1,Na.toString(r))}setLimit(t,r,a,i){return new n({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:a,message:Na.toString(i)}]})}_addCheck(t){return new n({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Na.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Na.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Na.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Na.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:Na.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}};SQ.create=n=>new SQ({checks:[],typeName:ai.ZodBigInt,coerce:n?.coerce??!1,...Oi(n)});BQ=class extends al{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==ta.boolean){let a=this._getOrReturnCtx(t);return Tr(a,{code:vr.invalid_type,expected:ta.boolean,received:a.parsedType}),$a}return ip(t.data)}};BQ.create=n=>new BQ({typeName:ai.ZodBoolean,coerce:n?.coerce||!1,...Oi(n)});JQ=class n extends al{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==ta.date){let s=this._getOrReturnCtx(t);return Tr(s,{code:vr.invalid_type,expected:ta.date,received:s.parsedType}),$a}if(Number.isNaN(t.data.getTime())){let s=this._getOrReturnCtx(t);return Tr(s,{code:vr.invalid_date}),$a}let a=new qh,i;for(let s of this._def.checks)s.kind==="min"?t.data.getTime()<s.value&&(i=this._getOrReturnCtx(t,i),Tr(i,{code:vr.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),a.dirty()):s.kind==="max"?t.data.getTime()>s.value&&(i=this._getOrReturnCtx(t,i),Tr(i,{code:vr.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),a.dirty()):Hl.assertNever(s);return{status:a.value,value:new Date(t.data.getTime())}}_addCheck(t){return new n({...this._def,checks:[...this._def.checks,t]})}min(t,r){return this._addCheck({kind:"min",value:t.getTime(),message:Na.toString(r)})}max(t,r){return this._addCheck({kind:"max",value:t.getTime(),message:Na.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}};JQ.create=n=>new JQ({checks:[],coerce:n?.coerce||!1,typeName:ai.ZodDate,...Oi(n)});gJ=class extends al{_parse(t){if(this._getType(t)!==ta.symbol){let a=this._getOrReturnCtx(t);return Tr(a,{code:vr.invalid_type,expected:ta.symbol,received:a.parsedType}),$a}return ip(t.data)}};gJ.create=n=>new gJ({typeName:ai.ZodSymbol,...Oi(n)});TQ=class extends al{_parse(t){if(this._getType(t)!==ta.undefined){let a=this._getOrReturnCtx(t);return Tr(a,{code:vr.invalid_type,expected:ta.undefined,received:a.parsedType}),$a}return ip(t.data)}};TQ.create=n=>new TQ({typeName:ai.ZodUndefined,...Oi(n)});DQ=class extends al{_parse(t){if(this._getType(t)!==ta.null){let a=this._getOrReturnCtx(t);return Tr(a,{code:vr.invalid_type,expected:ta.null,received:a.parsedType}),$a}return ip(t.data)}};DQ.create=n=>new DQ({typeName:ai.ZodNull,...Oi(n)});Ww=class extends al{constructor(){super(...arguments),this._any=!0}_parse(t){return ip(t.data)}};Ww.create=n=>new Ww({typeName:ai.ZodAny,...Oi(n)});L5=class extends al{constructor(){super(...arguments),this._unknown=!0}_parse(t){return ip(t.data)}};L5.create=n=>new L5({typeName:ai.ZodUnknown,...Oi(n)});VN=class extends al{_parse(t){let r=this._getOrReturnCtx(t);return Tr(r,{code:vr.invalid_type,expected:ta.never,received:r.parsedType}),$a}};VN.create=n=>new VN({typeName:ai.ZodNever,...Oi(n)});vJ=class extends al{_parse(t){if(this._getType(t)!==ta.undefined){let a=this._getOrReturnCtx(t);return Tr(a,{code:vr.invalid_type,expected:ta.void,received:a.parsedType}),$a}return ip(t.data)}};vJ.create=n=>new vJ({typeName:ai.ZodVoid,...Oi(n)});S5=class n extends al{_parse(t){let{ctx:r,status:a}=this._processInputParams(t),i=this._def;if(r.parsedType!==ta.array)return Tr(r,{code:vr.invalid_type,expected:ta.array,received:r.parsedType}),$a;if(i.exactLength!==null){let e=r.data.length>i.exactLength.value,o=r.data.length<i.exactLength.value;(e||o)&&(Tr(r,{code:e?vr.too_big:vr.too_small,minimum:o?i.exactLength.value:void 0,maximum:e?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),a.dirty())}if(i.minLength!==null&&r.data.length<i.minLength.value&&(Tr(r,{code:vr.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),a.dirty()),i.maxLength!==null&&r.data.length>i.maxLength.value&&(Tr(r,{code:vr.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),a.dirty()),r.common.async)return Promise.all([...r.data].map((e,o)=>i.type._parseAsync(new ov(r,e,r.path,o)))).then(e=>qh.mergeArray(a,e));let s=[...r.data].map((e,o)=>i.type._parseSync(new ov(r,e,r.path,o)));return qh.mergeArray(a,s)}get element(){return this._def.type}min(t,r){return new n({...this._def,minLength:{value:t,message:Na.toString(r)}})}max(t,r){return new n({...this._def,maxLength:{value:t,message:Na.toString(r)}})}length(t,r){return new n({...this._def,exactLength:{value:t,message:Na.toString(r)}})}nonempty(t){return this.min(1,t)}};S5.create=(n,t)=>new S5({type:n,minLength:null,maxLength:null,exactLength:null,typeName:ai.ZodArray,...Oi(t)});nf=class n extends al{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=Hl.objectKeys(t);return this._cached={shape:t,keys:r},this._cached}_parse(t){if(this._getType(t)!==ta.object){let d=this._getOrReturnCtx(t);return Tr(d,{code:vr.invalid_type,expected:ta.object,received:d.parsedType}),$a}let{status:a,ctx:i}=this._processInputParams(t),{shape:s,keys:e}=this._getCached(),o=[];if(!(this._def.catchall instanceof VN&&this._def.unknownKeys==="strip"))for(let d in i.data)e.includes(d)||o.push(d);let u=[];for(let d of e){let I=s[d],h=i.data[d];u.push({key:{status:"valid",value:d},value:I._parse(new ov(i,h,i.path,d)),alwaysSet:d in i.data})}if(this._def.catchall instanceof VN){let d=this._def.unknownKeys;if(d==="passthrough")for(let I of o)u.push({key:{status:"valid",value:I},value:{status:"valid",value:i.data[I]}});else if(d==="strict")o.length>0&&(Tr(i,{code:vr.unrecognized_keys,keys:o}),a.dirty());else if(d!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let d=this._def.catchall;for(let I of o){let h=i.data[I];u.push({key:{status:"valid",value:I},value:d._parse(new ov(i,h,i.path,I)),alwaysSet:I in i.data})}}return i.common.async?Promise.resolve().then(async()=>{let d=[];for(let I of u){let h=await I.key,c=await I.value;d.push({key:h,value:c,alwaysSet:I.alwaysSet})}return d}).then(d=>qh.mergeObjectSync(a,d)):qh.mergeObjectSync(a,u)}get shape(){return this._def.shape()}strict(t){return Na.errToObj,new n({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(r,a)=>{let i=this._def.errorMap?.(r,a).message??a.defaultError;return r.code==="unrecognized_keys"?{message:Na.errToObj(t).message??i}:{message:i}}}:{}})}strip(){return new n({...this._def,unknownKeys:"strip"})}passthrough(){return new n({...this._def,unknownKeys:"passthrough"})}extend(t){return new n({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new n({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:ai.ZodObject})}setKey(t,r){return this.augment({[t]:r})}catchall(t){return new n({...this._def,catchall:t})}pick(t){let r={};for(let a of Hl.objectKeys(t))t[a]&&this.shape[a]&&(r[a]=this.shape[a]);return new n({...this._def,shape:()=>r})}omit(t){let r={};for(let a of Hl.objectKeys(this.shape))t[a]||(r[a]=this.shape[a]);return new n({...this._def,shape:()=>r})}deepPartial(){return GJ(this)}partial(t){let r={};for(let a of Hl.objectKeys(this.shape)){let i=this.shape[a];t&&!t[a]?r[a]=i:r[a]=i.optional()}return new n({...this._def,shape:()=>r})}required(t){let r={};for(let a of Hl.objectKeys(this.shape))if(t&&!t[a])r[a]=this.shape[a];else{let s=this.shape[a];for(;s instanceof sv;)s=s._def.innerType;r[a]=s}return new n({...this._def,shape:()=>r})}keyof(){return $Vt(Hl.objectKeys(this.shape))}};nf.create=(n,t)=>new nf({shape:()=>n,unknownKeys:"strip",catchall:VN.create(),typeName:ai.ZodObject,...Oi(t)});nf.strictCreate=(n,t)=>new nf({shape:()=>n,unknownKeys:"strict",catchall:VN.create(),typeName:ai.ZodObject,...Oi(t)});nf.lazycreate=(n,t)=>new nf({shape:n,unknownKeys:"strip",catchall:VN.create(),typeName:ai.ZodObject,...Oi(t)});OQ=class extends al{_parse(t){let{ctx:r}=this._processInputParams(t),a=this._def.options;function i(s){for(let o of s)if(o.result.status==="valid")return o.result;for(let o of s)if(o.result.status==="dirty")return r.common.issues.push(...o.ctx.common.issues),o.result;let e=s.map(o=>new tf(o.ctx.common.issues));return Tr(r,{code:vr.invalid_union,unionErrors:e}),$a}if(r.common.async)return Promise.all(a.map(async s=>{let e={...r,common:{...r.common,issues:[]},parent:null};return{result:await s._parseAsync({data:r.data,path:r.path,parent:e}),ctx:e}})).then(i);{let s,e=[];for(let u of a){let d={...r,common:{...r.common,issues:[]},parent:null},I=u._parseSync({data:r.data,path:r.path,parent:d});if(I.status==="valid")return I;I.status==="dirty"&&!s&&(s={result:I,ctx:d}),d.common.issues.length&&e.push(d.common.issues)}if(s)return r.common.issues.push(...s.ctx.common.issues),s.result;let o=e.map(u=>new tf(u));return Tr(r,{code:vr.invalid_union,unionErrors:o}),$a}}get options(){return this._def.options}};OQ.create=(n,t)=>new OQ({options:n,typeName:ai.ZodUnion,...Oi(t)});k5=n=>n instanceof MQ?k5(n.schema):n instanceof cv?k5(n.innerType()):n instanceof zQ?[n.value]:n instanceof _Q?n.options:n instanceof PQ?Hl.objectValues(n.enum):n instanceof jQ?k5(n._def.innerType):n instanceof TQ?[void 0]:n instanceof DQ?[null]:n instanceof sv?[void 0,...k5(n.unwrap())]:n instanceof XW?[null,...k5(n.unwrap())]:n instanceof aq||n instanceof qQ?k5(n.unwrap()):n instanceof KQ?k5(n._def.innerType):[],vme=class n extends al{_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==ta.object)return Tr(r,{code:vr.invalid_type,expected:ta.object,received:r.parsedType}),$a;let a=this.discriminator,i=r.data[a],s=this.optionsMap.get(i);return s?r.common.async?s._parseAsync({data:r.data,path:r.path,parent:r}):s._parseSync({data:r.data,path:r.path,parent:r}):(Tr(r,{code:vr.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[a]}),$a)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,r,a){let i=new Map;for(let s of r){let e=k5(s.shape[t]);if(!e.length)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let o of e){if(i.has(o))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(o)}`);i.set(o,s)}}return new n({typeName:ai.ZodDiscriminatedUnion,discriminator:t,options:r,optionsMap:i,...Oi(a)})}};UQ=class extends al{_parse(t){let{status:r,ctx:a}=this._processInputParams(t),i=(s,e)=>{if(Gme(s)||Gme(e))return $a;let o=lSe(s.value,e.value);return o.valid?((gme(s)||gme(e))&&r.dirty(),{status:r.value,value:o.data}):(Tr(a,{code:vr.invalid_intersection_types}),$a)};return a.common.async?Promise.all([this._def.left._parseAsync({data:a.data,path:a.path,parent:a}),this._def.right._parseAsync({data:a.data,path:a.path,parent:a})]).then(([s,e])=>i(s,e)):i(this._def.left._parseSync({data:a.data,path:a.path,parent:a}),this._def.right._parseSync({data:a.data,path:a.path,parent:a}))}};UQ.create=(n,t,r)=>new UQ({left:n,right:t,typeName:ai.ZodIntersection,...Oi(r)});HW=class n extends al{_parse(t){let{status:r,ctx:a}=this._processInputParams(t);if(a.parsedType!==ta.array)return Tr(a,{code:vr.invalid_type,expected:ta.array,received:a.parsedType}),$a;if(a.data.length<this._def.items.length)return Tr(a,{code:vr.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),$a;!this._def.rest&&a.data.length>this._def.items.length&&(Tr(a,{code:vr.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let s=[...a.data].map((e,o)=>{let u=this._def.items[o]||this._def.rest;return u?u._parse(new ov(a,e,a.path,o)):null}).filter(e=>!!e);return a.common.async?Promise.all(s).then(e=>qh.mergeArray(r,e)):qh.mergeArray(r,s)}get items(){return this._def.items}rest(t){return new n({...this._def,rest:t})}};HW.create=(n,t)=>{if(!Array.isArray(n))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new HW({items:n,typeName:ai.ZodTuple,rest:null,...Oi(t)})};Zme=class n extends al{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:r,ctx:a}=this._processInputParams(t);if(a.parsedType!==ta.object)return Tr(a,{code:vr.invalid_type,expected:ta.object,received:a.parsedType}),$a;let i=[],s=this._def.keyType,e=this._def.valueType;for(let o in a.data)i.push({key:s._parse(new ov(a,o,a.path,o)),value:e._parse(new ov(a,a.data[o],a.path,o)),alwaysSet:o in a.data});return a.common.async?qh.mergeObjectAsync(r,i):qh.mergeObjectSync(r,i)}get element(){return this._def.valueType}static create(t,r,a){return r instanceof al?new n({keyType:t,valueType:r,typeName:ai.ZodRecord,...Oi(a)}):new n({keyType:Aw.create(),valueType:t,typeName:ai.ZodRecord,...Oi(r)})}},ZJ=class extends al{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:r,ctx:a}=this._processInputParams(t);if(a.parsedType!==ta.map)return Tr(a,{code:vr.invalid_type,expected:ta.map,received:a.parsedType}),$a;let i=this._def.keyType,s=this._def.valueType,e=[...a.data.entries()].map(([o,u],d)=>({key:i._parse(new ov(a,o,a.path,[d,"key"])),value:s._parse(new ov(a,u,a.path,[d,"value"]))}));if(a.common.async){let o=new Map;return Promise.resolve().then(async()=>{for(let u of e){let d=await u.key,I=await u.value;if(d.status==="aborted"||I.status==="aborted")return $a;(d.status==="dirty"||I.status==="dirty")&&r.dirty(),o.set(d.value,I.value)}return{status:r.value,value:o}})}else{let o=new Map;for(let u of e){let d=u.key,I=u.value;if(d.status==="aborted"||I.status==="aborted")return $a;(d.status==="dirty"||I.status==="dirty")&&r.dirty(),o.set(d.value,I.value)}return{status:r.value,value:o}}}};ZJ.create=(n,t,r)=>new ZJ({valueType:t,keyType:n,typeName:ai.ZodMap,...Oi(r)});NJ=class n extends al{_parse(t){let{status:r,ctx:a}=this._processInputParams(t);if(a.parsedType!==ta.set)return Tr(a,{code:vr.invalid_type,expected:ta.set,received:a.parsedType}),$a;let i=this._def;i.minSize!==null&&a.data.size<i.minSize.value&&(Tr(a,{code:vr.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),r.dirty()),i.maxSize!==null&&a.data.size>i.maxSize.value&&(Tr(a,{code:vr.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),r.dirty());let s=this._def.valueType;function e(u){let d=new Set;for(let I of u){if(I.status==="aborted")return $a;I.status==="dirty"&&r.dirty(),d.add(I.value)}return{status:r.value,value:d}}let o=[...a.data.values()].map((u,d)=>s._parse(new ov(a,u,a.path,d)));return a.common.async?Promise.all(o).then(u=>e(u)):e(o)}min(t,r){return new n({...this._def,minSize:{value:t,message:Na.toString(r)}})}max(t,r){return new n({...this._def,maxSize:{value:t,message:Na.toString(r)}})}size(t,r){return this.min(t,r).max(t,r)}nonempty(t){return this.min(1,t)}};NJ.create=(n,t)=>new NJ({valueType:n,minSize:null,maxSize:null,typeName:ai.ZodSet,...Oi(t)});Nme=class n extends al{constructor(){super(...arguments),this.validate=this.implement}_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==ta.function)return Tr(r,{code:vr.invalid_type,expected:ta.function,received:r.parsedType}),$a;function a(o,u){return rq({data:o,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,bJ(),X5].filter(d=>!!d),issueData:{code:vr.invalid_arguments,argumentsError:u}})}function i(o,u){return rq({data:o,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,bJ(),X5].filter(d=>!!d),issueData:{code:vr.invalid_return_type,returnTypeError:u}})}let s={errorMap:r.common.contextualErrorMap},e=r.data;if(this._def.returns instanceof yw){let o=this;return ip(async function(...u){let d=new tf([]),I=await o._def.args.parseAsync(u,s).catch(G=>{throw d.addIssue(a(u,G)),d}),h=await Reflect.apply(e,this,I);return await o._def.returns._def.type.parseAsync(h,s).catch(G=>{throw d.addIssue(i(h,G)),d})})}else{let o=this;return ip(function(...u){let d=o._def.args.safeParse(u,s);if(!d.success)throw new tf([a(u,d.error)]);let I=Reflect.apply(e,this,d.data),h=o._def.returns.safeParse(I,s);if(!h.success)throw new tf([i(I,h.error)]);return h.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new n({...this._def,args:HW.create(t).rest(L5.create())})}returns(t){return new n({...this._def,returns:t})}implement(t){return this.parse(t)}strictImplement(t){return this.parse(t)}static create(t,r,a){return new n({args:t||HW.create([]).rest(L5.create()),returns:r||L5.create(),typeName:ai.ZodFunction,...Oi(a)})}},MQ=class extends al{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})}};MQ.create=(n,t)=>new MQ({getter:n,typeName:ai.ZodLazy,...Oi(t)});zQ=class extends al{_parse(t){if(t.data!==this._def.value){let r=this._getOrReturnCtx(t);return Tr(r,{received:r.data,code:vr.invalid_literal,expected:this._def.value}),$a}return{status:"valid",value:t.data}}get value(){return this._def.value}};zQ.create=(n,t)=>new zQ({value:n,typeName:ai.ZodLiteral,...Oi(t)});_Q=class n extends al{_parse(t){if(typeof t.data!="string"){let r=this._getOrReturnCtx(t),a=this._def.values;return Tr(r,{expected:Hl.joinValues(a),received:r.parsedType,code:vr.invalid_type}),$a}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){let r=this._getOrReturnCtx(t),a=this._def.values;return Tr(r,{received:r.data,code:vr.invalid_enum_value,options:a}),$a}return ip(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 n.create(t,{...this._def,...r})}exclude(t,r=this._def){return n.create(this.options.filter(a=>!t.includes(a)),{...this._def,...r})}};_Q.create=$Vt;PQ=class extends al{_parse(t){let r=Hl.getValidEnumValues(this._def.values),a=this._getOrReturnCtx(t);if(a.parsedType!==ta.string&&a.parsedType!==ta.number){let i=Hl.objectValues(r);return Tr(a,{expected:Hl.joinValues(i),received:a.parsedType,code:vr.invalid_type}),$a}if(this._cache||(this._cache=new Set(Hl.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){let i=Hl.objectValues(r);return Tr(a,{received:a.data,code:vr.invalid_enum_value,options:i}),$a}return ip(t.data)}get enum(){return this._def.values}};PQ.create=(n,t)=>new PQ({values:n,typeName:ai.ZodNativeEnum,...Oi(t)});yw=class extends al{unwrap(){return this._def.type}_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==ta.promise&&r.common.async===!1)return Tr(r,{code:vr.invalid_type,expected:ta.promise,received:r.parsedType}),$a;let a=r.parsedType===ta.promise?r.data:Promise.resolve(r.data);return ip(a.then(i=>this._def.type.parseAsync(i,{path:r.path,errorMap:r.common.contextualErrorMap})))}};yw.create=(n,t)=>new yw({type:n,typeName:ai.ZodPromise,...Oi(t)});cv=class extends al{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===ai.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){let{status:r,ctx:a}=this._processInputParams(t),i=this._def.effect||null,s={addIssue:e=>{Tr(a,e),e.fatal?r.abort():r.dirty()},get path(){return a.path}};if(s.addIssue=s.addIssue.bind(s),i.type==="preprocess"){let e=i.transform(a.data,s);if(a.common.async)return Promise.resolve(e).then(async o=>{if(r.value==="aborted")return $a;let u=await this._def.schema._parseAsync({data:o,path:a.path,parent:a});return u.status==="aborted"?$a:u.status==="dirty"?kQ(u.value):r.value==="dirty"?kQ(u.value):u});{if(r.value==="aborted")return $a;let o=this._def.schema._parseSync({data:e,path:a.path,parent:a});return o.status==="aborted"?$a:o.status==="dirty"?kQ(o.value):r.value==="dirty"?kQ(o.value):o}}if(i.type==="refinement"){let e=o=>{let u=i.refinement(o,s);if(a.common.async)return Promise.resolve(u);if(u instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(a.common.async===!1){let o=this._def.schema._parseSync({data:a.data,path:a.path,parent:a});return o.status==="aborted"?$a:(o.status==="dirty"&&r.dirty(),e(o.value),{status:r.value,value:o.value})}else return this._def.schema._parseAsync({data:a.data,path:a.path,parent:a}).then(o=>o.status==="aborted"?$a:(o.status==="dirty"&&r.dirty(),e(o.value).then(()=>({status:r.value,value:o.value}))))}if(i.type==="transform")if(a.common.async===!1){let e=this._def.schema._parseSync({data:a.data,path:a.path,parent:a});if(!Nw(e))return $a;let o=i.transform(e.value,s);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:o}}else return this._def.schema._parseAsync({data:a.data,path:a.path,parent:a}).then(e=>Nw(e)?Promise.resolve(i.transform(e.value,s)).then(o=>({status:r.value,value:o})):$a);Hl.assertNever(i)}};cv.create=(n,t,r)=>new cv({schema:n,typeName:ai.ZodEffects,effect:t,...Oi(r)});cv.createWithPreprocess=(n,t,r)=>new cv({schema:t,effect:{type:"preprocess",transform:n},typeName:ai.ZodEffects,...Oi(r)});sv=class extends al{_parse(t){return this._getType(t)===ta.undefined?ip(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};sv.create=(n,t)=>new sv({innerType:n,typeName:ai.ZodOptional,...Oi(t)});XW=class extends al{_parse(t){return this._getType(t)===ta.null?ip(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};XW.create=(n,t)=>new XW({innerType:n,typeName:ai.ZodNullable,...Oi(t)});jQ=class extends al{_parse(t){let{ctx:r}=this._processInputParams(t),a=r.data;return r.parsedType===ta.undefined&&(a=this._def.defaultValue()),this._def.innerType._parse({data:a,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};jQ.create=(n,t)=>new jQ({innerType:n,typeName:ai.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...Oi(t)});KQ=class extends al{_parse(t){let{ctx:r}=this._processInputParams(t),a={...r,common:{...r.common,issues:[]}},i=this._def.innerType._parse({data:a.data,path:a.path,parent:{...a}});return fJ(i)?i.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new tf(a.common.issues)},input:a.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new tf(a.common.issues)},input:a.data})}}removeCatch(){return this._def.innerType}};KQ.create=(n,t)=>new KQ({innerType:n,typeName:ai.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...Oi(t)});AJ=class extends al{_parse(t){if(this._getType(t)!==ta.nan){let a=this._getOrReturnCtx(t);return Tr(a,{code:vr.invalid_type,expected:ta.nan,received:a.parsedType}),$a}return{status:"valid",value:t.data}}};AJ.create=n=>new AJ({typeName:ai.ZodNaN,...Oi(n)});A3r=Symbol("zod_brand"),aq=class extends al{_parse(t){let{ctx:r}=this._processInputParams(t),a=r.data;return this._def.type._parse({data:a,path:r.path,parent:r})}unwrap(){return this._def.type}},iq=class n extends al{_parse(t){let{status:r,ctx:a}=this._processInputParams(t);if(a.common.async)return(async()=>{let s=await this._def.in._parseAsync({data:a.data,path:a.path,parent:a});return s.status==="aborted"?$a:s.status==="dirty"?(r.dirty(),kQ(s.value)):this._def.out._parseAsync({data:s.value,path:a.path,parent:a})})();{let i=this._def.in._parseSync({data:a.data,path:a.path,parent:a});return i.status==="aborted"?$a:i.status==="dirty"?(r.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:a.path,parent:a})}}static create(t,r){return new n({in:t,out:r,typeName:ai.ZodPipeline})}},qQ=class extends al{_parse(t){let r=this._def.innerType._parse(t),a=i=>(Nw(i)&&(i.value=Object.freeze(i.value)),i);return fJ(r)?r.then(i=>a(i)):a(r)}unwrap(){return this._def.innerType}};qQ.create=(n,t)=>new qQ({innerType:n,typeName:ai.ZodReadonly,...Oi(t)});W3r={object:nf.lazycreate};(function(n){n.ZodString="ZodString",n.ZodNumber="ZodNumber",n.ZodNaN="ZodNaN",n.ZodBigInt="ZodBigInt",n.ZodBoolean="ZodBoolean",n.ZodDate="ZodDate",n.ZodSymbol="ZodSymbol",n.ZodUndefined="ZodUndefined",n.ZodNull="ZodNull",n.ZodAny="ZodAny",n.ZodUnknown="ZodUnknown",n.ZodNever="ZodNever",n.ZodVoid="ZodVoid",n.ZodArray="ZodArray",n.ZodObject="ZodObject",n.ZodUnion="ZodUnion",n.ZodDiscriminatedUnion="ZodDiscriminatedUnion",n.ZodIntersection="ZodIntersection",n.ZodTuple="ZodTuple",n.ZodRecord="ZodRecord",n.ZodMap="ZodMap",n.ZodSet="ZodSet",n.ZodFunction="ZodFunction",n.ZodLazy="ZodLazy",n.ZodLiteral="ZodLiteral",n.ZodEnum="ZodEnum",n.ZodEffects="ZodEffects",n.ZodNativeEnum="ZodNativeEnum",n.ZodOptional="ZodOptional",n.ZodNullable="ZodNullable",n.ZodDefault="ZodDefault",n.ZodCatch="ZodCatch",n.ZodPromise="ZodPromise",n.ZodBranded="ZodBranded",n.ZodPipeline="ZodPipeline",n.ZodReadonly="ZodReadonly"})(ai||(ai={}));y3r=(n,t={message:`Input not instance of ${n.name}`})=>eQt(r=>r instanceof n,t),tQt=Aw.create,nQt=LQ.create,F3r=AJ.create,E3r=SQ.create,rQt=BQ.create,R3r=JQ.create,w3r=gJ.create,C3r=TQ.create,Y3r=DQ.create,x3r=Ww.create,V3r=L5.create,Q3r=VN.create,H3r=vJ.create,X3r=S5.create,k3r=nf.create,L3r=nf.strictCreate,S3r=OQ.create,B3r=vme.create,J3r=UQ.create,T3r=HW.create,D3r=Zme.create,O3r=ZJ.create,U3r=NJ.create,M3r=Nme.create,z3r=MQ.create,_3r=zQ.create,P3r=_Q.create,j3r=PQ.create,K3r=yw.create,q3r=cv.create,$3r=sv.create,eWr=XW.create,tWr=cv.createWithPreprocess,nWr=iq.create,rWr=()=>tQt().optional(),aWr=()=>nQt().optional(),iWr=()=>rQt().optional(),lWr={string:(n=>Aw.create({...n,coerce:!0})),number:(n=>LQ.create({...n,coerce:!0})),boolean:(n=>BQ.create({...n,coerce:!0})),bigint:(n=>SQ.create({...n,coerce:!0})),date:(n=>JQ.create({...n,coerce:!0}))},sWr=$a});var Xu={};po(Xu,{BRAND:()=>A3r,DIRTY:()=>kQ,EMPTY_PATH:()=>t3r,INVALID:()=>$a,NEVER:()=>sWr,OK:()=>ip,ParseStatus:()=>qh,Schema:()=>al,ZodAny:()=>Ww,ZodArray:()=>S5,ZodBigInt:()=>SQ,ZodBoolean:()=>BQ,ZodBranded:()=>aq,ZodCatch:()=>KQ,ZodDate:()=>JQ,ZodDefault:()=>jQ,ZodDiscriminatedUnion:()=>vme,ZodEffects:()=>cv,ZodEnum:()=>_Q,ZodError:()=>tf,ZodFirstPartyTypeKind:()=>ai,ZodFunction:()=>Nme,ZodIntersection:()=>UQ,ZodIssueCode:()=>vr,ZodLazy:()=>MQ,ZodLiteral:()=>zQ,ZodMap:()=>ZJ,ZodNaN:()=>AJ,ZodNativeEnum:()=>PQ,ZodNever:()=>VN,ZodNull:()=>DQ,ZodNullable:()=>XW,ZodNumber:()=>LQ,ZodObject:()=>nf,ZodOptional:()=>sv,ZodParsedType:()=>ta,ZodPipeline:()=>iq,ZodPromise:()=>yw,ZodReadonly:()=>qQ,ZodRecord:()=>Zme,ZodSchema:()=>al,ZodSet:()=>NJ,ZodString:()=>Aw,ZodSymbol:()=>gJ,ZodTransformer:()=>cv,ZodTuple:()=>HW,ZodType:()=>al,ZodUndefined:()=>TQ,ZodUnion:()=>OQ,ZodUnknown:()=>L5,ZodVoid:()=>vJ,addIssueToContext:()=>Tr,any:()=>x3r,array:()=>X3r,bigint:()=>E3r,boolean:()=>rQt,coerce:()=>lWr,custom:()=>eQt,date:()=>R3r,datetimeRegex:()=>qVt,defaultErrorMap:()=>X5,discriminatedUnion:()=>B3r,effect:()=>q3r,enum:()=>P3r,function:()=>M3r,getErrorMap:()=>bJ,getParsedType:()=>QW,instanceof:()=>y3r,intersection:()=>J3r,isAborted:()=>Gme,isAsync:()=>fJ,isDirty:()=>gme,isValid:()=>Nw,late:()=>W3r,lazy:()=>z3r,literal:()=>_3r,makeIssue:()=>rq,map:()=>O3r,nan:()=>F3r,nativeEnum:()=>j3r,never:()=>Q3r,null:()=>Y3r,nullable:()=>eWr,number:()=>nQt,object:()=>k3r,objectUtil:()=>nSe,oboolean:()=>iWr,onumber:()=>aWr,optional:()=>$3r,ostring:()=>rWr,pipeline:()=>nWr,preprocess:()=>tWr,promise:()=>K3r,quotelessJson:()=>qAr,record:()=>D3r,set:()=>U3r,setErrorMap:()=>e3r,strictObject:()=>L3r,string:()=>tQt,symbol:()=>w3r,transformer:()=>q3r,tuple:()=>T3r,undefined:()=>C3r,union:()=>S3r,unknown:()=>V3r,util:()=>Hl,void:()=>H3r});var sSe=ut(()=>{fme();aSe();MVt();nq();aQt();bme()});function Jn(n,t,r){function a(o,u){var d;Object.defineProperty(o,"_zod",{value:o._zod??{},enumerable:!1}),(d=o._zod).traits??(d.traits=new Set),o._zod.traits.add(n),t(o,u);for(let I in e.prototype)I in o||Object.defineProperty(o,I,{value:e.prototype[I].bind(o)});o._zod.constr=e,o._zod.def=u}let i=r?.Parent??Object;class s extends i{}Object.defineProperty(s,"name",{value:n});function e(o){var u;let d=r?.Parent?new s:this;a(d,o),(u=d._zod).deferred??(u.deferred=[]);for(let I of d._zod.deferred)I();return d}return Object.defineProperty(e,"init",{value:a}),Object.defineProperty(e,Symbol.hasInstance,{value:o=>r?.Parent&&o instanceof r.Parent?!0:o?._zod?.traits?.has(n)}),Object.defineProperty(e,"name",{value:n}),e}function e1(n){return n&&Object.assign(Ame,n),Ame}var oSe,oWr,B5,Ame,WJ=ut(()=>{oSe=Object.freeze({status:"aborted"});oWr=Symbol("zod_brand"),B5=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},Ame={}});var Ts={};po(Ts,{BIGINT_FORMAT_RANGES:()=>lQt,Class:()=>uSe,NUMBER_FORMAT_RANGES:()=>GSe,aborted:()=>e9,allowsEval:()=>pSe,assert:()=>hWr,assertEqual:()=>cWr,assertIs:()=>IWr,assertNever:()=>dWr,assertNotEqual:()=>uWr,assignProp:()=>mSe,cached:()=>sq,captureStackTrace:()=>yme,cleanEnum:()=>FWr,cleanRegex:()=>cq,clone:()=>QN,createTransparentProxy:()=>gWr,defineLazy:()=>Wc,esc:()=>$Q,escapeRegex:()=>Fw,extend:()=>NWr,finalizeIssue:()=>HN,floatSafeRemainder:()=>hSe,getElementAtPath:()=>mWr,getEnumValues:()=>ISe,getLengthableOrigin:()=>uq,getParsedType:()=>GWr,getSizableOrigin:()=>sQt,isObject:()=>yJ,isPlainObject:()=>FJ,issue:()=>gSe,joinValues:()=>Wme,jsonStringifyReplacer:()=>dSe,merge:()=>AWr,normalizeParams:()=>ka,nullish:()=>oq,numKeys:()=>fWr,omit:()=>ZWr,optionalKeys:()=>fSe,partial:()=>WWr,pick:()=>vWr,prefixIssues:()=>kW,primitiveTypes:()=>iQt,promiseAllObject:()=>pWr,propertyKeyTypes:()=>bSe,randomString:()=>bWr,required:()=>yWr,stringifyPrimitive:()=>Fme,unwrapMessage:()=>lq});function cWr(n){return n}function uWr(n){return n}function IWr(n){}function dWr(n){throw new Error}function hWr(n){}function ISe(n){let t=Object.values(n).filter(a=>typeof a=="number");return Object.entries(n).filter(([a,i])=>t.indexOf(+a)===-1).map(([a,i])=>i)}function Wme(n,t="|"){return n.map(r=>Fme(r)).join(t)}function dSe(n,t){return typeof t=="bigint"?t.toString():t}function sq(n){return{get value(){{let r=n();return Object.defineProperty(this,"value",{value:r}),r}throw new Error("cached value already set")}}}function oq(n){return n==null}function cq(n){let t=n.startsWith("^")?1:0,r=n.endsWith("$")?n.length-1:n.length;return n.slice(t,r)}function hSe(n,t){let r=(n.toString().split(".")[1]||"").length,a=(t.toString().split(".")[1]||"").length,i=r>a?r:a,s=Number.parseInt(n.toFixed(i).replace(".","")),e=Number.parseInt(t.toFixed(i).replace(".",""));return s%e/10**i}function Wc(n,t,r){Object.defineProperty(n,t,{get(){{let i=r();return n[t]=i,i}throw new Error("cached value already set")},set(i){Object.defineProperty(n,t,{value:i})},configurable:!0})}function mSe(n,t,r){Object.defineProperty(n,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function mWr(n,t){return t?t.reduce((r,a)=>r?.[a],n):n}function pWr(n){let t=Object.keys(n),r=t.map(a=>n[a]);return Promise.all(r).then(a=>{let i={};for(let s=0;s<t.length;s++)i[t[s]]=a[s];return i})}function bWr(n=10){let t="abcdefghijklmnopqrstuvwxyz",r="";for(let a=0;a<n;a++)r+=t[Math.floor(Math.random()*t.length)];return r}function $Q(n){return JSON.stringify(n)}function yJ(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function FJ(n){if(yJ(n)===!1)return!1;let t=n.constructor;if(t===void 0)return!0;let r=t.prototype;return!(yJ(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function fWr(n){let t=0;for(let r in n)Object.prototype.hasOwnProperty.call(n,r)&&t++;return t}function Fw(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function QN(n,t,r){let a=new n._zod.constr(t??n._zod.def);return(!t||r?.parent)&&(a._zod.parent=n),a}function ka(n){let t=n;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function gWr(n){let t;return new Proxy({},{get(r,a,i){return t??(t=n()),Reflect.get(t,a,i)},set(r,a,i,s){return t??(t=n()),Reflect.set(t,a,i,s)},has(r,a){return t??(t=n()),Reflect.has(t,a)},deleteProperty(r,a){return t??(t=n()),Reflect.deleteProperty(t,a)},ownKeys(r){return t??(t=n()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(r,a){return t??(t=n()),Reflect.getOwnPropertyDescriptor(t,a)},defineProperty(r,a,i){return t??(t=n()),Reflect.defineProperty(t,a,i)}})}function Fme(n){return typeof n=="bigint"?n.toString()+"n":typeof n=="string"?`"${n}"`:`${n}`}function fSe(n){return Object.keys(n).filter(t=>n[t]._zod.optin==="optional"&&n[t]._zod.optout==="optional")}function vWr(n,t){let r={},a=n._zod.def;for(let i in t){if(!(i in a.shape))throw new Error(`Unrecognized key: "${i}"`);t[i]&&(r[i]=a.shape[i])}return QN(n,{...n._zod.def,shape:r,checks:[]})}function ZWr(n,t){let r={...n._zod.def.shape},a=n._zod.def;for(let i in t){if(!(i in a.shape))throw new Error(`Unrecognized key: "${i}"`);t[i]&&delete r[i]}return QN(n,{...n._zod.def,shape:r,checks:[]})}function NWr(n,t){if(!FJ(t))throw new Error("Invalid input to extend: expected a plain object");let r={...n._zod.def,get shape(){let a={...n._zod.def.shape,...t};return mSe(this,"shape",a),a},checks:[]};return QN(n,r)}function AWr(n,t){return QN(n,{...n._zod.def,get shape(){let r={...n._zod.def.shape,...t._zod.def.shape};return mSe(this,"shape",r),r},catchall:t._zod.def.catchall,checks:[]})}function WWr(n,t,r){let a=t._zod.def.shape,i={...a};if(r)for(let s in r){if(!(s in a))throw new Error(`Unrecognized key: "${s}"`);r[s]&&(i[s]=n?new n({type:"optional",innerType:a[s]}):a[s])}else for(let s in a)i[s]=n?new n({type:"optional",innerType:a[s]}):a[s];return QN(t,{...t._zod.def,shape:i,checks:[]})}function yWr(n,t,r){let a=t._zod.def.shape,i={...a};if(r)for(let s in r){if(!(s in i))throw new Error(`Unrecognized key: "${s}"`);r[s]&&(i[s]=new n({type:"nonoptional",innerType:a[s]}))}else for(let s in a)i[s]=new n({type:"nonoptional",innerType:a[s]});return QN(t,{...t._zod.def,shape:i,checks:[]})}function e9(n,t=0){for(let r=t;r<n.issues.length;r++)if(n.issues[r]?.continue!==!0)return!0;return!1}function kW(n,t){return t.map(r=>{var a;return(a=r).path??(a.path=[]),r.path.unshift(n),r})}function lq(n){return typeof n=="string"?n:n?.message}function HN(n,t,r){let a={...n,path:n.path??[]};if(!n.message){let i=lq(n.inst?._zod.def?.error?.(n))??lq(t?.error?.(n))??lq(r.customError?.(n))??lq(r.localeError?.(n))??"Invalid input";a.message=i}return delete a.inst,delete a.continue,t?.reportInput||delete a.input,a}function sQt(n){return n instanceof Set?"set":n instanceof Map?"map":n instanceof File?"file":"unknown"}function uq(n){return Array.isArray(n)?"array":typeof n=="string"?"string":"unknown"}function gSe(...n){let[t,r,a]=n;return typeof t=="string"?{message:t,code:"custom",input:r,inst:a}:{...t}}function FWr(n){return Object.entries(n).filter(([t,r])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}var yme,pSe,GWr,bSe,iQt,GSe,lQt,uSe,J5=ut(()=>{yme=Error.captureStackTrace?Error.captureStackTrace:(...n)=>{};pSe=sq(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let n=Function;return new n(""),!0}catch{return!1}});GWr=n=>{let t=typeof n;switch(t){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(n)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(n)?"array":n===null?"null":n.then&&typeof n.then=="function"&&n.catch&&typeof n.catch=="function"?"promise":typeof Map<"u"&&n instanceof Map?"map":typeof Set<"u"&&n instanceof Set?"set":typeof Date<"u"&&n instanceof Date?"date":typeof File<"u"&&n instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${t}`)}},bSe=new Set(["string","number","symbol"]),iQt=new Set(["string","number","bigint","boolean","symbol","undefined"]);GSe={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},lQt={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};uSe=class{constructor(...t){}}});function ZSe(n,t=r=>r.message){let r={},a=[];for(let i of n.issues)i.path.length>0?(r[i.path[0]]=r[i.path[0]]||[],r[i.path[0]].push(t(i))):a.push(t(i));return{formErrors:a,fieldErrors:r}}function NSe(n,t){let r=t||function(s){return s.message},a={_errors:[]},i=s=>{for(let e of s.issues)if(e.code==="invalid_union"&&e.errors.length)e.errors.map(o=>i({issues:o}));else if(e.code==="invalid_key")i({issues:e.issues});else if(e.code==="invalid_element")i({issues:e.issues});else if(e.path.length===0)a._errors.push(r(e));else{let o=a,u=0;for(;u<e.path.length;){let d=e.path[u];u===e.path.length-1?(o[d]=o[d]||{_errors:[]},o[d]._errors.push(r(e))):o[d]=o[d]||{_errors:[]},o=o[d],u++}}};return i(n),a}var oQt,Eme,vSe,ASe=ut(()=>{WJ();J5();oQt=(n,t)=>{n.name="$ZodError",Object.defineProperty(n,"_zod",{value:n._zod,enumerable:!1}),Object.defineProperty(n,"issues",{value:t,enumerable:!1}),Object.defineProperty(n,"message",{get(){return JSON.stringify(t,dSe,2)},enumerable:!0}),Object.defineProperty(n,"toString",{value:()=>n.message,enumerable:!1})},Eme=Jn("$ZodError",oQt),vSe=Jn("$ZodError",oQt,{Parent:Error})});var cQt,uQt,WSe,Iq,ySe,Rme,FSe=ut(()=>{WJ();ASe();J5();cQt=n=>(t,r,a,i)=>{let s=a?Object.assign(a,{async:!1}):{async:!1},e=t._zod.run({value:r,issues:[]},s);if(e instanceof Promise)throw new B5;if(e.issues.length){let o=new(i?.Err??n)(e.issues.map(u=>HN(u,s,e1())));throw yme(o,i?.callee),o}return e.value},uQt=n=>async(t,r,a,i)=>{let s=a?Object.assign(a,{async:!0}):{async:!0},e=t._zod.run({value:r,issues:[]},s);if(e instanceof Promise&&(e=await e),e.issues.length){let o=new(i?.Err??n)(e.issues.map(u=>HN(u,s,e1())));throw yme(o,i?.callee),o}return e.value},WSe=n=>(t,r,a)=>{let i=a?{...a,async:!1}:{async:!1},s=t._zod.run({value:r,issues:[]},i);if(s instanceof Promise)throw new B5;return s.issues.length?{success:!1,error:new(n??Eme)(s.issues.map(e=>HN(e,i,e1())))}:{success:!0,data:s.value}},Iq=WSe(vSe),ySe=n=>async(t,r,a)=>{let i=a?Object.assign(a,{async:!0}):{async:!0},s=t._zod.run({value:r,issues:[]},i);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new n(s.issues.map(e=>HN(e,i,e1())))}:{success:!0,data:s.value}},Rme=ySe(vSe)});function vQt(){return new RegExp(RWr,"u")}function CQt(n){let t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof n.precision=="number"?n.precision===-1?`${t}`:n.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${n.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function YQt(n){return new RegExp(`^${CQt(n)}$`)}function xQt(n){let t=CQt({precision:n.precision}),r=["Z"];n.local&&r.push(""),n.offset&&r.push("([+-]\\d{2}:\\d{2})");let a=`${t}(?:${r.join("|")})`;return new RegExp(`^${RQt}T(?:${a})$`)}var IQt,dQt,hQt,mQt,pQt,bQt,fQt,GQt,ESe,gQt,RWr,ZQt,NQt,AQt,WQt,yQt,RSe,FQt,EQt,RQt,wQt,VQt,QQt,HQt,XQt,kQt,LQt,SQt,BQt,Cme=ut(()=>{IQt=/^[cC][^\s-]{8,}$/,dQt=/^[0-9a-z]+$/,hQt=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,mQt=/^[0-9a-vA-V]{20}$/,pQt=/^[A-Za-z0-9]{27}$/,bQt=/^[a-zA-Z0-9_-]{21}$/,fQt=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,GQt=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,ESe=n=>n?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${n}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000)$/,gQt=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,RWr="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";ZQt=/^(?:(?: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])$/,NQt=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})$/,AQt=/^((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])\/([0-9]|[1-2][0-9]|3[0-2])$/,WQt=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,yQt=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,RSe=/^[A-Za-z0-9_-]*$/,FQt=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/,EQt=/^\+(?:[0-9]){6,14}[0-9]$/,RQt="(?:(?:\\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])))",wQt=new RegExp(`^${RQt}$`);VQt=n=>{let t=n?`[\\s\\S]{${n?.minimum??0},${n?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},QQt=/^\d+n?$/,HQt=/^\d+$/,XQt=/^-?\d+(?:\.\d+)?/i,kQt=/true|false/i,LQt=/null/i,SQt=/^[^A-Z]*$/,BQt=/^[^a-z]*$/});var lp,JQt,wSe,CSe,TQt,DQt,OQt,UQt,MQt,dq,zQt,_Qt,PQt,jQt,KQt,qQt,$Qt,Yme=ut(()=>{WJ();Cme();J5();lp=Jn("$ZodCheck",(n,t)=>{var r;n._zod??(n._zod={}),n._zod.def=t,(r=n._zod).onattach??(r.onattach=[])}),JQt={number:"number",bigint:"bigint",object:"date"},wSe=Jn("$ZodCheckLessThan",(n,t)=>{lp.init(n,t);let r=JQt[typeof t.value];n._zod.onattach.push(a=>{let i=a._zod.bag,s=(t.inclusive?i.maximum:i.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<s&&(t.inclusive?i.maximum=t.value:i.exclusiveMaximum=t.value)}),n._zod.check=a=>{(t.inclusive?a.value<=t.value:a.value<t.value)||a.issues.push({origin:r,code:"too_big",maximum:t.value,input:a.value,inclusive:t.inclusive,inst:n,continue:!t.abort})}}),CSe=Jn("$ZodCheckGreaterThan",(n,t)=>{lp.init(n,t);let r=JQt[typeof t.value];n._zod.onattach.push(a=>{let i=a._zod.bag,s=(t.inclusive?i.minimum:i.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>s&&(t.inclusive?i.minimum=t.value:i.exclusiveMinimum=t.value)}),n._zod.check=a=>{(t.inclusive?a.value>=t.value:a.value>t.value)||a.issues.push({origin:r,code:"too_small",minimum:t.value,input:a.value,inclusive:t.inclusive,inst:n,continue:!t.abort})}}),TQt=Jn("$ZodCheckMultipleOf",(n,t)=>{lp.init(n,t),n._zod.onattach.push(r=>{var a;(a=r._zod.bag).multipleOf??(a.multipleOf=t.value)}),n._zod.check=r=>{if(typeof r.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?r.value%t.value===BigInt(0):hSe(r.value,t.value)===0)||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:n,continue:!t.abort})}}),DQt=Jn("$ZodCheckNumberFormat",(n,t)=>{lp.init(n,t),t.format=t.format||"float64";let r=t.format?.includes("int"),a=r?"int":"number",[i,s]=GSe[t.format];n._zod.onattach.push(e=>{let o=e._zod.bag;o.format=t.format,o.minimum=i,o.maximum=s,r&&(o.pattern=HQt)}),n._zod.check=e=>{let o=e.value;if(r){if(!Number.isInteger(o)){e.issues.push({expected:a,format:t.format,code:"invalid_type",input:o,inst:n});return}if(!Number.isSafeInteger(o)){o>0?e.issues.push({input:o,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:n,origin:a,continue:!t.abort}):e.issues.push({input:o,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:n,origin:a,continue:!t.abort});return}}o<i&&e.issues.push({origin:"number",input:o,code:"too_small",minimum:i,inclusive:!0,inst:n,continue:!t.abort}),o>s&&e.issues.push({origin:"number",input:o,code:"too_big",maximum:s,inst:n})}}),OQt=Jn("$ZodCheckMaxLength",(n,t)=>{var r;lp.init(n,t),(r=n._zod.def).when??(r.when=a=>{let i=a.value;return!oq(i)&&i.length!==void 0}),n._zod.onattach.push(a=>{let i=a._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<i&&(a._zod.bag.maximum=t.maximum)}),n._zod.check=a=>{let i=a.value;if(i.length<=t.maximum)return;let e=uq(i);a.issues.push({origin:e,code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:n,continue:!t.abort})}}),UQt=Jn("$ZodCheckMinLength",(n,t)=>{var r;lp.init(n,t),(r=n._zod.def).when??(r.when=a=>{let i=a.value;return!oq(i)&&i.length!==void 0}),n._zod.onattach.push(a=>{let i=a._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>i&&(a._zod.bag.minimum=t.minimum)}),n._zod.check=a=>{let i=a.value;if(i.length>=t.minimum)return;let e=uq(i);a.issues.push({origin:e,code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:n,continue:!t.abort})}}),MQt=Jn("$ZodCheckLengthEquals",(n,t)=>{var r;lp.init(n,t),(r=n._zod.def).when??(r.when=a=>{let i=a.value;return!oq(i)&&i.length!==void 0}),n._zod.onattach.push(a=>{let i=a._zod.bag;i.minimum=t.length,i.maximum=t.length,i.length=t.length}),n._zod.check=a=>{let i=a.value,s=i.length;if(s===t.length)return;let e=uq(i),o=s>t.length;a.issues.push({origin:e,...o?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:a.value,inst:n,continue:!t.abort})}}),dq=Jn("$ZodCheckStringFormat",(n,t)=>{var r,a;lp.init(n,t),n._zod.onattach.push(i=>{let s=i._zod.bag;s.format=t.format,t.pattern&&(s.patterns??(s.patterns=new Set),s.patterns.add(t.pattern))}),t.pattern?(r=n._zod).check??(r.check=i=>{t.pattern.lastIndex=0,!t.pattern.test(i.value)&&i.issues.push({origin:"string",code:"invalid_format",format:t.format,input:i.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:n,continue:!t.abort})}):(a=n._zod).check??(a.check=()=>{})}),zQt=Jn("$ZodCheckRegex",(n,t)=>{dq.init(n,t),n._zod.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:n,continue:!t.abort})}}),_Qt=Jn("$ZodCheckLowerCase",(n,t)=>{t.pattern??(t.pattern=SQt),dq.init(n,t)}),PQt=Jn("$ZodCheckUpperCase",(n,t)=>{t.pattern??(t.pattern=BQt),dq.init(n,t)}),jQt=Jn("$ZodCheckIncludes",(n,t)=>{lp.init(n,t);let r=Fw(t.includes),a=new RegExp(typeof t.position=="number"?`^.{${t.position}}${r}`:r);t.pattern=a,n._zod.onattach.push(i=>{let s=i._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(a)}),n._zod.check=i=>{i.value.includes(t.includes,t.position)||i.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:i.value,inst:n,continue:!t.abort})}}),KQt=Jn("$ZodCheckStartsWith",(n,t)=>{lp.init(n,t);let r=new RegExp(`^${Fw(t.prefix)}.*`);t.pattern??(t.pattern=r),n._zod.onattach.push(a=>{let i=a._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(r)}),n._zod.check=a=>{a.value.startsWith(t.prefix)||a.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:a.value,inst:n,continue:!t.abort})}}),qQt=Jn("$ZodCheckEndsWith",(n,t)=>{lp.init(n,t);let r=new RegExp(`.*${Fw(t.suffix)}$`);t.pattern??(t.pattern=r),n._zod.onattach.push(a=>{let i=a._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(r)}),n._zod.check=a=>{a.value.endsWith(t.suffix)||a.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:a.value,inst:n,continue:!t.abort})}}),$Qt=Jn("$ZodCheckOverwrite",(n,t)=>{lp.init(n,t),n._zod.check=r=>{r.value=t.tx(r.value)}})});var xme,YSe=ut(()=>{xme=class{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}let a=t.split(`
|
|
666
|
+
`);s=G.pop()||"";for(let W of G)if(W.startsWith("data: ")){let y=W.slice(6);if(y==="[DONE]")return;try{let R=JSON.parse(y);if(R.type==="connection_established")continue;if(R.error)throw new Error(R.error);R.usageMetadata&&(o=R.usageMetadata);let F=this.convertStreamChunkToGenAI(R);F&&(yield F)}catch(R){ar.warn("[DeepV Server] Stream chunk parse error",{data:y.substring(0,100)+"...",error:R instanceof Error?R.message:R})}}}}finally{d&&r&&r.removeEventListener("abort",d);try{a.releaseLock()}catch{}}}convertStreamChunkToGenAI(t){if(!t.candidates||!Array.isArray(t.candidates)||t.candidates.length===0)return null;let r={candidates:t.candidates,usageMetadata:t.usageMetadata};if(r.candidates?.[0]?.content?.parts){for(let a of r.candidates[0].content.parts)if(a.functionCall&&!a.functionCall.id){let i=`call_${Date.now()}_${Math.random().toString(36).substring(2,9)}`;console.log(`[DeepV Server] \u8865\u5168\u7F3A\u5931\u7684\u5DE5\u5177 ID (Chunk): ${a.functionCall.name} -> ${i}`),a.functionCall.id=i}}return r.functionCalls||Object.defineProperty(r,"functionCalls",{get:function(){if(this.candidates?.[0]?.content?.parts?.length===0)return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning function calls from the first one.");let a=this.candidates?.[0]?.content?.parts?.filter(i=>i.functionCall).map(i=>i.functionCall).filter(i=>i!==void 0);if(a?.length!==0)return a},enumerable:!1,configurable:!0}),r}mergeStreamContent(t,r){if(!t)return r;let a=t.candidates?.[0]?.content?.parts||[],i=r.candidates?.[0]?.content?.parts||[];if(i.length>0&&i[0].text){let s=a[a.length-1];s&&s.text&&!s.functionCall?s.text+=i[0].text:a.push(...i)}else if(i.length>0&&i[0].functionCall){let s=a[a.length-1],e=i[0];if(s&&s.functionCall){let o=s.functionCall,u=e.functionCall;u&&(u.name&&(o.name=u.name),u.id&&(o.id=u.id),u.args&&(typeof u.args=="string"&&typeof o.args=="string"?o.args+=u.args:typeof u.args=="object"&&u.args!==null?o.args={...typeof o.args=="object"?o.args:{},...u.args}:o.args=u.args))}else{let o={...e};if(o.functionCall&&!o.functionCall.id){let u=`call_${Date.now()}_${Math.random().toString(36).substring(2,9)}`;console.log(`[DeepV Server] \u8865\u5168\u7F3A\u5931\u7684\u5DE5\u5177 ID: ${o.functionCall.name} -> ${u}`),o.functionCall.id=u}a.push(o)}}return r.usageMetadata&&(t.usageMetadata=r.usageMetadata),r.candidates?.[0]?.finishReason&&(t.candidates[0].finishReason=r.candidates[0].finishReason),t}buildUnifiedRequest(t,r){let a=vd.getModelForScene(r),i=this.config?.getModel(),s;return i&&$l(i)?t.model&&$l(t.model)?s=t.model:s=i:s=t.model||a||"auto",{model:s,contents:t.contents,config:{...t.config,httpOptions:{...t.config?.httpOptions,headers:{...t.config?.httpOptions?.headers,"X-Scene-Type":r,"X-Scene-Display":vd.getSceneDisplayName(r)}}}}}async*handleStreamError(t){this.handleError(t)}async countTokens(t){try{let r=t.model||this.config?.getModel()||"auto";if($l(r))return ar.debug("[DeepV Server] Custom model detected, token counting not supported"),{totalTokens:0};let a={model:r,contents:t.contents};(t.config?.systemInstruction||t.config?.tools)&&(a.config={},t.config.systemInstruction&&(a.config.systemInstruction=t.config.systemInstruction),t.config.tools&&(a.config.tools=t.config.tools));let i=await this.callUnifiedTokenCountAPI(a);return U2.emitRealTimeToken({inputTokens:i.totalTokens||0,outputTokens:0,totalTokens:i.totalTokens||0,timestamp:Date.now()}),i}catch(r){let a=t.model||this.config?.getModel()||"auto";return $l(a)?ar.debug("[DeepV Server] Token count not available for custom model, using fallback"):ar.error("[DeepV Server] Token count failed:",r),this.estimateTokensAsFailback(t)}}async callUnifiedTokenCountAPI(t){let r=await ao.getUserHeaders(),a=`${ao.getProxyServerUrl()}/v1/chat/count-tokens`;try{let i=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json",...r},body:JSON.stringify(t)});if(!i.ok){let e=await i.text();throw i.status===401?(console.error("[DeepV Server] Token count 401 Unauthorized"),this.authHandler&&await this.authHandler(),new CI("Authentication required - please re-authenticate")):new Error(`Token count API failed (${i.status}): ${e}`)}let s=await i.json();return ar.debug("[DeepV Server] Token count response",{totalTokens:s.totalTokens}),{totalTokens:s.totalTokens||0}}catch(i){throw ar.error("[DeepV Server] Token count API call failed:",i),i}}estimateTokensAsFailback(t){try{let r=Array.isArray(t.contents)?t.contents:[{role:jr.USER,parts:[{text:t.contents}]}],a=0,i=0,s=0,e=0;for(let c of r)if(typeof c=="object"&&c&&"parts"in c&&Array.isArray(c.parts)){for(let G of c.parts)if(typeof G=="object"&&G&&"text"in G&&typeof G.text=="string")a+=G.text.length,e++;else if(typeof G=="object"&&G&&"functionCall"in G&&G.functionCall){let W=G.functionCall,y=`[Tool: ${W.name}]`+JSON.stringify(W.args||{});a+=y.length,i++}else if(typeof G=="object"&&G&&"functionResponse"in G&&G.functionResponse){let R=`[Tool Result: ${G.functionResponse.response?.output||"result"}]`;a+=R.length+20,s++}}else typeof c=="string"&&(a+=c.length,e++);let o=JSON.stringify(r),u=/[\u4e00-\u9fff]/.test(o),d=/```|function|class|import|export|\{|\}|\[|\]/.test(o),I=4;return u?I=2:d&&(I=3),{totalTokens:Math.ceil(a/I)}}catch(r){return console.error("[DeepV Server] Fallback estimation error:",r),{totalTokens:1e3}}}async embedContent(t){throw new Error("Claude models do not support embedding content")}withTimeout(t,r,a){let i=null,s=new Promise((e,o)=>{i=setTimeout(()=>{o(new Error(a))},r)});return Promise.race([t,s]).finally(()=>{i!==null&&clearTimeout(i)})}}});function $Le(n,t){let r=n.getModel()||"auto",a={authType:t,proxy:n?.getProxy()};return t===es.USE_PROXY_AUTH,a}async function eSe(n,t,r){let i={headers:{"User-Agent":`GeminiCLI/1.0.291 (${process.platform}; ${process.arch})`}};if(!0){let e=t.getCustomProxyServerUrl(),o;if(e)o=e,console.log(`[DeepX] Using custom proxy server: ${o}`);else{if(!QHe())throw new Error("DeepV Code server is required for all models but is not available. Please start the DeepV Code server or use proxy authentication.");o=mW(),console.log(`[DeepX] Connecting to DeepV Code server: ${o}`)}let u=process.env.GOOGLE_CLOUD_LOCATION||"us-central1",d=process.env.GOOGLE_CLOUD_PROJECT||"default-project";return new pJ(u,d,o,t)}throw new Error(`Error creating contentGenerator: Unsupported authType: ${n.authType}`)}var es,Ime=ut(()=>{"use strict";qLe();vB();(function(n){n.USE_PROXY_AUTH="proxy-auth"})(es||(es={}))});var dme,DVt=ut(()=>{"use strict";dme=class{prompts=new Map;registerPrompt(t){if(this.prompts.has(t.name)){let r=`${t.serverName}_${t.name}`;console.warn(`Prompt with name "${t.name}" is already registered. Renaming to "${r}".`),this.prompts.set(r,{...t,name:r})}else this.prompts.set(t.name,t)}getAllPrompts(){return Array.from(this.prompts.values()).sort((t,r)=>t.name.localeCompare(r.name))}getPrompt(t){return this.prompts.get(t)}getPromptsByServer(t){let r=[];for(let a of this.prompts.values())a.serverName===t&&r.push(a);return r.sort((a,i)=>a.name.localeCompare(i.name))}removePromptsByServer(t){for(let[r,a]of this.prompts.entries())a.serverName===t&&this.prompts.delete(r)}}});function xN(n){let t={type:"subagent_update",data:n,timestamp:Date.now()};return JSON.stringify(t)}function OVt(n){let t={type:"text",data:n,timestamp:Date.now()};return JSON.stringify(t)}function hme(n){try{let t=JSON.parse(n);if(t&&typeof t=="object"&&t.type&&t.data!==void 0)return t}catch{}return{type:"text",data:n,timestamp:Date.now()}}function mme(n){return n.type==="subagent_update"}function pme(n){return n.type==="text"}var tSe=ut(()=>{"use strict";});var $r,zr,ea,Ql=ut(()=>{"use strict";tSe();$r=class{name;displayName;description;icon;parameterSchema;isOutputMarkdown;forceMarkdown;canUpdateOutput;allowSubAgentUse;constructor(t,r,a,i,s,e=!0,o=!1,u=!1,d=!0){this.name=t,this.displayName=r,this.description=a,this.icon=i,this.parameterSchema=s,this.isOutputMarkdown=e,this.forceMarkdown=o,this.canUpdateOutput=u,this.allowSubAgentUse=d}get schema(){return{name:this.name,description:this.description,parameters:this.parameterSchema}}validateToolParams(t){return null}getDescription(t){return JSON.stringify(t)}shouldConfirmExecute(t,r){return Promise.resolve(!1)}toolLocations(t){return[]}};(function(n){n.ProceedOnce="proceed_once",n.ProceedAlways="proceed_always",n.ProceedAlwaysServer="proceed_always_server",n.ProceedAlwaysTool="proceed_always_tool",n.ProceedAlwaysProject="proceed_always_project",n.ModifyWithEditor="modify_with_editor",n.Cancel="cancel"})(zr||(zr={}));(function(n){n.FileSearch="fileSearch",n.Folder="folder",n.Globe="globe",n.Hammer="hammer",n.LightBulb="lightBulb",n.Pencil="pencil",n.Regex="regex",n.Terminal="terminal",n.Clipboard="clipboard",n.Tasks="tasks",n.Wrench="wrench",n.Trash="trash",n.List="list",n.Info="info"})(ea||(ea={}))});var Hl,nSe,ta,QW,nq=ut(()=>{(function(n){n.assertEqual=i=>{};function t(i){}n.assertIs=t;function r(i){throw new Error}n.assertNever=r,n.arrayToEnum=i=>{let s={};for(let e of i)s[e]=e;return s},n.getValidEnumValues=i=>{let s=n.objectKeys(i).filter(o=>typeof i[i[o]]!="number"),e={};for(let o of s)e[o]=i[o];return n.objectValues(e)},n.objectValues=i=>n.objectKeys(i).map(function(s){return i[s]}),n.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{let s=[];for(let e in i)Object.prototype.hasOwnProperty.call(i,e)&&s.push(e);return s},n.find=(i,s)=>{for(let e of i)if(s(e))return e},n.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&Number.isFinite(i)&&Math.floor(i)===i;function a(i,s=" | "){return i.map(e=>typeof e=="string"?`'${e}'`:e).join(s)}n.joinValues=a,n.jsonStringifyReplacer=(i,s)=>typeof s=="bigint"?s.toString():s})(Hl||(Hl={}));(function(n){n.mergeShapes=(t,r)=>({...t,...r})})(nSe||(nSe={}));ta=Hl.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),QW=n=>{switch(typeof n){case"undefined":return ta.undefined;case"string":return ta.string;case"number":return Number.isNaN(n)?ta.nan:ta.number;case"boolean":return ta.boolean;case"function":return ta.function;case"bigint":return ta.bigint;case"symbol":return ta.symbol;case"object":return Array.isArray(n)?ta.array:n===null?ta.null:n.then&&typeof n.then=="function"&&n.catch&&typeof n.catch=="function"?ta.promise:typeof Map<"u"&&n instanceof Map?ta.map:typeof Set<"u"&&n instanceof Set?ta.set:typeof Date<"u"&&n instanceof Date?ta.date:ta.object;default:return ta.unknown}}});var vr,qAr,tf,bme=ut(()=>{nq();vr=Hl.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"]),qAr=n=>JSON.stringify(n,null,2).replace(/"([^"]+)":/g,"$1:"),tf=class n extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=a=>{this.issues=[...this.issues,a]},this.addIssues=(a=[])=>{this.issues=[...this.issues,...a]};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(s){return s.message},a={_errors:[]},i=s=>{for(let e of s.issues)if(e.code==="invalid_union")e.unionErrors.map(i);else if(e.code==="invalid_return_type")i(e.returnTypeError);else if(e.code==="invalid_arguments")i(e.argumentsError);else if(e.path.length===0)a._errors.push(r(e));else{let o=a,u=0;for(;u<e.path.length;){let d=e.path[u];u===e.path.length-1?(o[d]=o[d]||{_errors:[]},o[d]._errors.push(r(e))):o[d]=o[d]||{_errors:[]},o=o[d],u++}}};return i(this),a}static assert(t){if(!(t instanceof n))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Hl.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=r=>r.message){let r={},a=[];for(let i of this.issues)if(i.path.length>0){let s=i.path[0];r[s]=r[s]||[],r[s].push(t(i))}else a.push(t(i));return{formErrors:a,fieldErrors:r}}get formErrors(){return this.flatten()}};tf.create=n=>new tf(n)});var $Ar,X5,rSe=ut(()=>{bme();nq();$Ar=(n,t)=>{let r;switch(n.code){case vr.invalid_type:n.received===ta.undefined?r="Required":r=`Expected ${n.expected}, received ${n.received}`;break;case vr.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(n.expected,Hl.jsonStringifyReplacer)}`;break;case vr.unrecognized_keys:r=`Unrecognized key(s) in object: ${Hl.joinValues(n.keys,", ")}`;break;case vr.invalid_union:r="Invalid input";break;case vr.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${Hl.joinValues(n.options)}`;break;case vr.invalid_enum_value:r=`Invalid enum value. Expected ${Hl.joinValues(n.options)}, received '${n.received}'`;break;case vr.invalid_arguments:r="Invalid function arguments";break;case vr.invalid_return_type:r="Invalid function return type";break;case vr.invalid_date:r="Invalid date";break;case vr.invalid_string:typeof n.validation=="object"?"includes"in n.validation?(r=`Invalid input: must include "${n.validation.includes}"`,typeof n.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${n.validation.position}`)):"startsWith"in n.validation?r=`Invalid input: must start with "${n.validation.startsWith}"`:"endsWith"in n.validation?r=`Invalid input: must end with "${n.validation.endsWith}"`:Hl.assertNever(n.validation):n.validation!=="regex"?r=`Invalid ${n.validation}`:r="Invalid";break;case vr.too_small:n.type==="array"?r=`Array must contain ${n.exact?"exactly":n.inclusive?"at least":"more than"} ${n.minimum} element(s)`:n.type==="string"?r=`String must contain ${n.exact?"exactly":n.inclusive?"at least":"over"} ${n.minimum} character(s)`:n.type==="number"?r=`Number must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${n.minimum}`:n.type==="bigint"?r=`Number must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${n.minimum}`:n.type==="date"?r=`Date must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(n.minimum))}`:r="Invalid input";break;case vr.too_big:n.type==="array"?r=`Array must contain ${n.exact?"exactly":n.inclusive?"at most":"less than"} ${n.maximum} element(s)`:n.type==="string"?r=`String must contain ${n.exact?"exactly":n.inclusive?"at most":"under"} ${n.maximum} character(s)`:n.type==="number"?r=`Number must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="bigint"?r=`BigInt must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="date"?r=`Date must be ${n.exact?"exactly":n.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(n.maximum))}`:r="Invalid input";break;case vr.custom:r="Invalid input";break;case vr.invalid_intersection_types:r="Intersection results could not be merged";break;case vr.not_multiple_of:r=`Number must be a multiple of ${n.multipleOf}`;break;case vr.not_finite:r="Number must be finite";break;default:r=t.defaultError,Hl.assertNever(n)}return{message:r}},X5=$Ar});function e3r(n){UVt=n}function bJ(){return UVt}var UVt,fme=ut(()=>{rSe();UVt=X5});function Tr(n,t){let r=bJ(),a=rq({issueData:t,data:n.data,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,r,r===X5?void 0:X5].filter(i=>!!i)});n.common.issues.push(a)}var rq,t3r,qh,$a,kQ,ip,Gme,gme,Nw,fJ,aSe=ut(()=>{fme();rSe();rq=n=>{let{data:t,path:r,errorMaps:a,issueData:i}=n,s=[...r,...i.path||[]],e={...i,path:s};if(i.message!==void 0)return{...i,path:s,message:i.message};let o="",u=a.filter(d=>!!d).slice().reverse();for(let d of u)o=d(e,{data:t,defaultError:o}).message;return{...i,path:s,message:o}},t3r=[];qh=class n{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,r){let a=[];for(let i of r){if(i.status==="aborted")return $a;i.status==="dirty"&&t.dirty(),a.push(i.value)}return{status:t.value,value:a}}static async mergeObjectAsync(t,r){let a=[];for(let i of r){let s=await i.key,e=await i.value;a.push({key:s,value:e})}return n.mergeObjectSync(t,a)}static mergeObjectSync(t,r){let a={};for(let i of r){let{key:s,value:e}=i;if(s.status==="aborted"||e.status==="aborted")return $a;s.status==="dirty"&&t.dirty(),e.status==="dirty"&&t.dirty(),s.value!=="__proto__"&&(typeof e.value<"u"||i.alwaysSet)&&(a[s.value]=e.value)}return{status:t.value,value:a}}},$a=Object.freeze({status:"aborted"}),kQ=n=>({status:"dirty",value:n}),ip=n=>({status:"valid",value:n}),Gme=n=>n.status==="aborted",gme=n=>n.status==="dirty",Nw=n=>n.status==="valid",fJ=n=>typeof Promise<"u"&&n instanceof Promise});var MVt=ut(()=>{});var Na,zVt=ut(()=>{(function(n){n.errToObj=t=>typeof t=="string"?{message:t}:t||{},n.toString=t=>typeof t=="string"?t:t?.message})(Na||(Na={}))});function Oi(n){if(!n)return{};let{errorMap:t,invalid_type_error:r,required_error:a,description:i}=n;if(t&&(r||a))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:i}:{errorMap:(e,o)=>{let{message:u}=n;return e.code==="invalid_enum_value"?{message:u??o.defaultError}:typeof o.data>"u"?{message:u??a??o.defaultError}:e.code!=="invalid_type"?{message:o.defaultError}:{message:u??r??o.defaultError}},description:i}}function KVt(n){let t="[0-5]\\d";n.precision?t=`${t}\\.\\d{${n.precision}}`:n.precision==null&&(t=`${t}(\\.\\d+)?`);let r=n.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${r}`}function G3r(n){return new RegExp(`^${KVt(n)}$`)}function qVt(n){let t=`${jVt}T${KVt(n)}`,r=[];return r.push(n.local?"Z?":"Z"),n.offset&&r.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${r.join("|")})`,new RegExp(`^${t}$`)}function g3r(n,t){return!!((t==="v4"||!t)&&I3r.test(n)||(t==="v6"||!t)&&h3r.test(n))}function v3r(n,t){if(!s3r.test(n))return!1;try{let[r]=n.split(".");if(!r)return!1;let a=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),i=JSON.parse(atob(a));return!(typeof i!="object"||i===null||"typ"in i&&i?.typ!=="JWT"||!i.alg||t&&i.alg!==t)}catch{return!1}}function Z3r(n,t){return!!((t==="v4"||!t)&&d3r.test(n)||(t==="v6"||!t)&&m3r.test(n))}function N3r(n,t){let r=(n.toString().split(".")[1]||"").length,a=(t.toString().split(".")[1]||"").length,i=r>a?r:a,s=Number.parseInt(n.toFixed(i).replace(".","")),e=Number.parseInt(t.toFixed(i).replace(".",""));return s%e/10**i}function GJ(n){if(n instanceof nf){let t={};for(let r in n.shape){let a=n.shape[r];t[r]=sv.create(GJ(a))}return new nf({...n._def,shape:()=>t})}else return n instanceof S5?new S5({...n._def,type:GJ(n.element)}):n instanceof sv?sv.create(GJ(n.unwrap())):n instanceof XW?XW.create(GJ(n.unwrap())):n instanceof HW?HW.create(n.items.map(t=>GJ(t))):n}function lSe(n,t){let r=QW(n),a=QW(t);if(n===t)return{valid:!0,data:n};if(r===ta.object&&a===ta.object){let i=Hl.objectKeys(t),s=Hl.objectKeys(n).filter(o=>i.indexOf(o)!==-1),e={...n,...t};for(let o of s){let u=lSe(n[o],t[o]);if(!u.valid)return{valid:!1};e[o]=u.data}return{valid:!0,data:e}}else if(r===ta.array&&a===ta.array){if(n.length!==t.length)return{valid:!1};let i=[];for(let s=0;s<n.length;s++){let e=n[s],o=t[s],u=lSe(e,o);if(!u.valid)return{valid:!1};i.push(u.data)}return{valid:!0,data:i}}else return r===ta.date&&a===ta.date&&+n==+t?{valid:!0,data:n}:{valid:!1}}function $Vt(n,t){return new _Q({values:n,typeName:ai.ZodEnum,...Oi(t)})}function PVt(n,t){let r=typeof n=="function"?n(t):typeof n=="string"?{message:n}:n;return typeof r=="string"?{message:r}:r}function eQt(n,t={},r){return n?Ww.create().superRefine((a,i)=>{let s=n(a);if(s instanceof Promise)return s.then(e=>{if(!e){let o=PVt(t,a),u=o.fatal??r??!0;i.addIssue({code:"custom",...o,fatal:u})}});if(!s){let e=PVt(t,a),o=e.fatal??r??!0;i.addIssue({code:"custom",...e,fatal:o})}}):Ww.create()}var ov,_Vt,al,n3r,r3r,a3r,i3r,l3r,s3r,o3r,c3r,u3r,iSe,I3r,d3r,h3r,m3r,p3r,b3r,jVt,f3r,Aw,LQ,SQ,BQ,JQ,gJ,TQ,DQ,Ww,L5,VN,vJ,S5,nf,OQ,k5,vme,UQ,HW,Zme,ZJ,NJ,Nme,MQ,zQ,_Q,PQ,yw,cv,sv,XW,jQ,KQ,AJ,A3r,aq,iq,qQ,W3r,ai,y3r,tQt,nQt,F3r,E3r,rQt,R3r,w3r,C3r,Y3r,x3r,V3r,Q3r,H3r,X3r,k3r,L3r,S3r,B3r,J3r,T3r,D3r,O3r,U3r,M3r,z3r,_3r,P3r,j3r,K3r,q3r,$3r,eWr,tWr,nWr,rWr,aWr,iWr,lWr,sWr,aQt=ut(()=>{bme();fme();zVt();aSe();nq();ov=class{constructor(t,r,a,i){this._cachedPath=[],this.parent=t,this.data=r,this._path=a,this._key=i}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}},_Vt=(n,t)=>{if(Nw(t))return{success:!0,data:t.value};if(!n.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 tf(n.common.issues);return this._error=r,this._error}}};al=class{get description(){return this._def.description}_getType(t){return QW(t.data)}_getOrReturnCtx(t,r){return r||{common:t.parent.common,data:t.data,parsedType:QW(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new qh,ctx:{common:t.parent.common,data:t.data,parsedType:QW(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){let r=this._parse(t);if(fJ(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 a=this.safeParse(t,r);if(a.success)return a.data;throw a.error}safeParse(t,r){let a={common:{issues:[],async:r?.async??!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:QW(t)},i=this._parseSync({data:t,path:a.path,parent:a});return _Vt(a,i)}"~validate"(t){let r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:QW(t)};if(!this["~standard"].async)try{let a=this._parseSync({data:t,path:[],parent:r});return Nw(a)?{value:a.value}:{issues:r.common.issues}}catch(a){a?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:r}).then(a=>Nw(a)?{value:a.value}:{issues:r.common.issues})}async parseAsync(t,r){let a=await this.safeParseAsync(t,r);if(a.success)return a.data;throw a.error}async safeParseAsync(t,r){let a={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:QW(t)},i=this._parse({data:t,path:a.path,parent:a}),s=await(fJ(i)?i:Promise.resolve(i));return _Vt(a,s)}refine(t,r){let a=i=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(i):r;return this._refinement((i,s)=>{let e=t(i),o=()=>s.addIssue({code:vr.custom,...a(i)});return typeof Promise<"u"&&e instanceof Promise?e.then(u=>u?!0:(o(),!1)):e?!0:(o(),!1)})}refinement(t,r){return this._refinement((a,i)=>t(a)?!0:(i.addIssue(typeof r=="function"?r(a,i):r),!1))}_refinement(t){return new cv({schema:this,typeName:ai.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 sv.create(this,this._def)}nullable(){return XW.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return S5.create(this)}promise(){return yw.create(this,this._def)}or(t){return OQ.create([this,t],this._def)}and(t){return UQ.create(this,t,this._def)}transform(t){return new cv({...Oi(this._def),schema:this,typeName:ai.ZodEffects,effect:{type:"transform",transform:t}})}default(t){let r=typeof t=="function"?t:()=>t;return new jQ({...Oi(this._def),innerType:this,defaultValue:r,typeName:ai.ZodDefault})}brand(){return new aq({typeName:ai.ZodBranded,type:this,...Oi(this._def)})}catch(t){let r=typeof t=="function"?t:()=>t;return new KQ({...Oi(this._def),innerType:this,catchValue:r,typeName:ai.ZodCatch})}describe(t){let r=this.constructor;return new r({...this._def,description:t})}pipe(t){return iq.create(this,t)}readonly(){return qQ.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},n3r=/^c[^\s-]{8,}$/i,r3r=/^[0-9a-z]+$/,a3r=/^[0-9A-HJKMNP-TV-Z]{26}$/i,i3r=/^[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,l3r=/^[a-z0-9_-]{21}$/i,s3r=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,o3r=/^[-+]?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)?)??$/,c3r=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,u3r="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",I3r=/^(?:(?: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])$/,d3r=/^(?:(?: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])$/,h3r=/^(([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]))$/,m3r=/^(([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])$/,p3r=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,b3r=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,jVt="((\\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])))",f3r=new RegExp(`^${jVt}$`);Aw=class n extends al{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==ta.string){let s=this._getOrReturnCtx(t);return Tr(s,{code:vr.invalid_type,expected:ta.string,received:s.parsedType}),$a}let a=new qh,i;for(let s of this._def.checks)if(s.kind==="min")t.data.length<s.value&&(i=this._getOrReturnCtx(t,i),Tr(i,{code:vr.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),a.dirty());else if(s.kind==="max")t.data.length>s.value&&(i=this._getOrReturnCtx(t,i),Tr(i,{code:vr.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),a.dirty());else if(s.kind==="length"){let e=t.data.length>s.value,o=t.data.length<s.value;(e||o)&&(i=this._getOrReturnCtx(t,i),e?Tr(i,{code:vr.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):o&&Tr(i,{code:vr.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),a.dirty())}else if(s.kind==="email")c3r.test(t.data)||(i=this._getOrReturnCtx(t,i),Tr(i,{validation:"email",code:vr.invalid_string,message:s.message}),a.dirty());else if(s.kind==="emoji")iSe||(iSe=new RegExp(u3r,"u")),iSe.test(t.data)||(i=this._getOrReturnCtx(t,i),Tr(i,{validation:"emoji",code:vr.invalid_string,message:s.message}),a.dirty());else if(s.kind==="uuid")i3r.test(t.data)||(i=this._getOrReturnCtx(t,i),Tr(i,{validation:"uuid",code:vr.invalid_string,message:s.message}),a.dirty());else if(s.kind==="nanoid")l3r.test(t.data)||(i=this._getOrReturnCtx(t,i),Tr(i,{validation:"nanoid",code:vr.invalid_string,message:s.message}),a.dirty());else if(s.kind==="cuid")n3r.test(t.data)||(i=this._getOrReturnCtx(t,i),Tr(i,{validation:"cuid",code:vr.invalid_string,message:s.message}),a.dirty());else if(s.kind==="cuid2")r3r.test(t.data)||(i=this._getOrReturnCtx(t,i),Tr(i,{validation:"cuid2",code:vr.invalid_string,message:s.message}),a.dirty());else if(s.kind==="ulid")a3r.test(t.data)||(i=this._getOrReturnCtx(t,i),Tr(i,{validation:"ulid",code:vr.invalid_string,message:s.message}),a.dirty());else if(s.kind==="url")try{new URL(t.data)}catch{i=this._getOrReturnCtx(t,i),Tr(i,{validation:"url",code:vr.invalid_string,message:s.message}),a.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(t.data)||(i=this._getOrReturnCtx(t,i),Tr(i,{validation:"regex",code:vr.invalid_string,message:s.message}),a.dirty())):s.kind==="trim"?t.data=t.data.trim():s.kind==="includes"?t.data.includes(s.value,s.position)||(i=this._getOrReturnCtx(t,i),Tr(i,{code:vr.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),a.dirty()):s.kind==="toLowerCase"?t.data=t.data.toLowerCase():s.kind==="toUpperCase"?t.data=t.data.toUpperCase():s.kind==="startsWith"?t.data.startsWith(s.value)||(i=this._getOrReturnCtx(t,i),Tr(i,{code:vr.invalid_string,validation:{startsWith:s.value},message:s.message}),a.dirty()):s.kind==="endsWith"?t.data.endsWith(s.value)||(i=this._getOrReturnCtx(t,i),Tr(i,{code:vr.invalid_string,validation:{endsWith:s.value},message:s.message}),a.dirty()):s.kind==="datetime"?qVt(s).test(t.data)||(i=this._getOrReturnCtx(t,i),Tr(i,{code:vr.invalid_string,validation:"datetime",message:s.message}),a.dirty()):s.kind==="date"?f3r.test(t.data)||(i=this._getOrReturnCtx(t,i),Tr(i,{code:vr.invalid_string,validation:"date",message:s.message}),a.dirty()):s.kind==="time"?G3r(s).test(t.data)||(i=this._getOrReturnCtx(t,i),Tr(i,{code:vr.invalid_string,validation:"time",message:s.message}),a.dirty()):s.kind==="duration"?o3r.test(t.data)||(i=this._getOrReturnCtx(t,i),Tr(i,{validation:"duration",code:vr.invalid_string,message:s.message}),a.dirty()):s.kind==="ip"?g3r(t.data,s.version)||(i=this._getOrReturnCtx(t,i),Tr(i,{validation:"ip",code:vr.invalid_string,message:s.message}),a.dirty()):s.kind==="jwt"?v3r(t.data,s.alg)||(i=this._getOrReturnCtx(t,i),Tr(i,{validation:"jwt",code:vr.invalid_string,message:s.message}),a.dirty()):s.kind==="cidr"?Z3r(t.data,s.version)||(i=this._getOrReturnCtx(t,i),Tr(i,{validation:"cidr",code:vr.invalid_string,message:s.message}),a.dirty()):s.kind==="base64"?p3r.test(t.data)||(i=this._getOrReturnCtx(t,i),Tr(i,{validation:"base64",code:vr.invalid_string,message:s.message}),a.dirty()):s.kind==="base64url"?b3r.test(t.data)||(i=this._getOrReturnCtx(t,i),Tr(i,{validation:"base64url",code:vr.invalid_string,message:s.message}),a.dirty()):Hl.assertNever(s);return{status:a.value,value:t.data}}_regex(t,r,a){return this.refinement(i=>t.test(i),{validation:r,code:vr.invalid_string,...Na.errToObj(a)})}_addCheck(t){return new n({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...Na.errToObj(t)})}url(t){return this._addCheck({kind:"url",...Na.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...Na.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...Na.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...Na.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...Na.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...Na.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...Na.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...Na.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...Na.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...Na.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...Na.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...Na.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,...Na.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,...Na.errToObj(t?.message)})}duration(t){return this._addCheck({kind:"duration",...Na.errToObj(t)})}regex(t,r){return this._addCheck({kind:"regex",regex:t,...Na.errToObj(r)})}includes(t,r){return this._addCheck({kind:"includes",value:t,position:r?.position,...Na.errToObj(r?.message)})}startsWith(t,r){return this._addCheck({kind:"startsWith",value:t,...Na.errToObj(r)})}endsWith(t,r){return this._addCheck({kind:"endsWith",value:t,...Na.errToObj(r)})}min(t,r){return this._addCheck({kind:"min",value:t,...Na.errToObj(r)})}max(t,r){return this._addCheck({kind:"max",value:t,...Na.errToObj(r)})}length(t,r){return this._addCheck({kind:"length",value:t,...Na.errToObj(r)})}nonempty(t){return this.min(1,Na.errToObj(t))}trim(){return new n({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new n({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new n({...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}};Aw.create=n=>new Aw({checks:[],typeName:ai.ZodString,coerce:n?.coerce??!1,...Oi(n)});LQ=class n extends al{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)!==ta.number){let s=this._getOrReturnCtx(t);return Tr(s,{code:vr.invalid_type,expected:ta.number,received:s.parsedType}),$a}let a,i=new qh;for(let s of this._def.checks)s.kind==="int"?Hl.isInteger(t.data)||(a=this._getOrReturnCtx(t,a),Tr(a,{code:vr.invalid_type,expected:"integer",received:"float",message:s.message}),i.dirty()):s.kind==="min"?(s.inclusive?t.data<s.value:t.data<=s.value)&&(a=this._getOrReturnCtx(t,a),Tr(a,{code:vr.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?t.data>s.value:t.data>=s.value)&&(a=this._getOrReturnCtx(t,a),Tr(a,{code:vr.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="multipleOf"?N3r(t.data,s.value)!==0&&(a=this._getOrReturnCtx(t,a),Tr(a,{code:vr.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):s.kind==="finite"?Number.isFinite(t.data)||(a=this._getOrReturnCtx(t,a),Tr(a,{code:vr.not_finite,message:s.message}),i.dirty()):Hl.assertNever(s);return{status:i.value,value:t.data}}gte(t,r){return this.setLimit("min",t,!0,Na.toString(r))}gt(t,r){return this.setLimit("min",t,!1,Na.toString(r))}lte(t,r){return this.setLimit("max",t,!0,Na.toString(r))}lt(t,r){return this.setLimit("max",t,!1,Na.toString(r))}setLimit(t,r,a,i){return new n({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:a,message:Na.toString(i)}]})}_addCheck(t){return new n({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:Na.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Na.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Na.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Na.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Na.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:Na.toString(r)})}finite(t){return this._addCheck({kind:"finite",message:Na.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Na.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Na.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"&&Hl.isInteger(t.value))}get isFinite(){let t=null,r=null;for(let a of this._def.checks){if(a.kind==="finite"||a.kind==="int"||a.kind==="multipleOf")return!0;a.kind==="min"?(r===null||a.value>r)&&(r=a.value):a.kind==="max"&&(t===null||a.value<t)&&(t=a.value)}return Number.isFinite(r)&&Number.isFinite(t)}};LQ.create=n=>new LQ({checks:[],typeName:ai.ZodNumber,coerce:n?.coerce||!1,...Oi(n)});SQ=class n extends al{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)!==ta.bigint)return this._getInvalidInput(t);let a,i=new qh;for(let s of this._def.checks)s.kind==="min"?(s.inclusive?t.data<s.value:t.data<=s.value)&&(a=this._getOrReturnCtx(t,a),Tr(a,{code:vr.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?t.data>s.value:t.data>=s.value)&&(a=this._getOrReturnCtx(t,a),Tr(a,{code:vr.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="multipleOf"?t.data%s.value!==BigInt(0)&&(a=this._getOrReturnCtx(t,a),Tr(a,{code:vr.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):Hl.assertNever(s);return{status:i.value,value:t.data}}_getInvalidInput(t){let r=this._getOrReturnCtx(t);return Tr(r,{code:vr.invalid_type,expected:ta.bigint,received:r.parsedType}),$a}gte(t,r){return this.setLimit("min",t,!0,Na.toString(r))}gt(t,r){return this.setLimit("min",t,!1,Na.toString(r))}lte(t,r){return this.setLimit("max",t,!0,Na.toString(r))}lt(t,r){return this.setLimit("max",t,!1,Na.toString(r))}setLimit(t,r,a,i){return new n({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:a,message:Na.toString(i)}]})}_addCheck(t){return new n({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Na.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Na.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Na.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Na.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:Na.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}};SQ.create=n=>new SQ({checks:[],typeName:ai.ZodBigInt,coerce:n?.coerce??!1,...Oi(n)});BQ=class extends al{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==ta.boolean){let a=this._getOrReturnCtx(t);return Tr(a,{code:vr.invalid_type,expected:ta.boolean,received:a.parsedType}),$a}return ip(t.data)}};BQ.create=n=>new BQ({typeName:ai.ZodBoolean,coerce:n?.coerce||!1,...Oi(n)});JQ=class n extends al{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==ta.date){let s=this._getOrReturnCtx(t);return Tr(s,{code:vr.invalid_type,expected:ta.date,received:s.parsedType}),$a}if(Number.isNaN(t.data.getTime())){let s=this._getOrReturnCtx(t);return Tr(s,{code:vr.invalid_date}),$a}let a=new qh,i;for(let s of this._def.checks)s.kind==="min"?t.data.getTime()<s.value&&(i=this._getOrReturnCtx(t,i),Tr(i,{code:vr.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),a.dirty()):s.kind==="max"?t.data.getTime()>s.value&&(i=this._getOrReturnCtx(t,i),Tr(i,{code:vr.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),a.dirty()):Hl.assertNever(s);return{status:a.value,value:new Date(t.data.getTime())}}_addCheck(t){return new n({...this._def,checks:[...this._def.checks,t]})}min(t,r){return this._addCheck({kind:"min",value:t.getTime(),message:Na.toString(r)})}max(t,r){return this._addCheck({kind:"max",value:t.getTime(),message:Na.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}};JQ.create=n=>new JQ({checks:[],coerce:n?.coerce||!1,typeName:ai.ZodDate,...Oi(n)});gJ=class extends al{_parse(t){if(this._getType(t)!==ta.symbol){let a=this._getOrReturnCtx(t);return Tr(a,{code:vr.invalid_type,expected:ta.symbol,received:a.parsedType}),$a}return ip(t.data)}};gJ.create=n=>new gJ({typeName:ai.ZodSymbol,...Oi(n)});TQ=class extends al{_parse(t){if(this._getType(t)!==ta.undefined){let a=this._getOrReturnCtx(t);return Tr(a,{code:vr.invalid_type,expected:ta.undefined,received:a.parsedType}),$a}return ip(t.data)}};TQ.create=n=>new TQ({typeName:ai.ZodUndefined,...Oi(n)});DQ=class extends al{_parse(t){if(this._getType(t)!==ta.null){let a=this._getOrReturnCtx(t);return Tr(a,{code:vr.invalid_type,expected:ta.null,received:a.parsedType}),$a}return ip(t.data)}};DQ.create=n=>new DQ({typeName:ai.ZodNull,...Oi(n)});Ww=class extends al{constructor(){super(...arguments),this._any=!0}_parse(t){return ip(t.data)}};Ww.create=n=>new Ww({typeName:ai.ZodAny,...Oi(n)});L5=class extends al{constructor(){super(...arguments),this._unknown=!0}_parse(t){return ip(t.data)}};L5.create=n=>new L5({typeName:ai.ZodUnknown,...Oi(n)});VN=class extends al{_parse(t){let r=this._getOrReturnCtx(t);return Tr(r,{code:vr.invalid_type,expected:ta.never,received:r.parsedType}),$a}};VN.create=n=>new VN({typeName:ai.ZodNever,...Oi(n)});vJ=class extends al{_parse(t){if(this._getType(t)!==ta.undefined){let a=this._getOrReturnCtx(t);return Tr(a,{code:vr.invalid_type,expected:ta.void,received:a.parsedType}),$a}return ip(t.data)}};vJ.create=n=>new vJ({typeName:ai.ZodVoid,...Oi(n)});S5=class n extends al{_parse(t){let{ctx:r,status:a}=this._processInputParams(t),i=this._def;if(r.parsedType!==ta.array)return Tr(r,{code:vr.invalid_type,expected:ta.array,received:r.parsedType}),$a;if(i.exactLength!==null){let e=r.data.length>i.exactLength.value,o=r.data.length<i.exactLength.value;(e||o)&&(Tr(r,{code:e?vr.too_big:vr.too_small,minimum:o?i.exactLength.value:void 0,maximum:e?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),a.dirty())}if(i.minLength!==null&&r.data.length<i.minLength.value&&(Tr(r,{code:vr.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),a.dirty()),i.maxLength!==null&&r.data.length>i.maxLength.value&&(Tr(r,{code:vr.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),a.dirty()),r.common.async)return Promise.all([...r.data].map((e,o)=>i.type._parseAsync(new ov(r,e,r.path,o)))).then(e=>qh.mergeArray(a,e));let s=[...r.data].map((e,o)=>i.type._parseSync(new ov(r,e,r.path,o)));return qh.mergeArray(a,s)}get element(){return this._def.type}min(t,r){return new n({...this._def,minLength:{value:t,message:Na.toString(r)}})}max(t,r){return new n({...this._def,maxLength:{value:t,message:Na.toString(r)}})}length(t,r){return new n({...this._def,exactLength:{value:t,message:Na.toString(r)}})}nonempty(t){return this.min(1,t)}};S5.create=(n,t)=>new S5({type:n,minLength:null,maxLength:null,exactLength:null,typeName:ai.ZodArray,...Oi(t)});nf=class n extends al{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=Hl.objectKeys(t);return this._cached={shape:t,keys:r},this._cached}_parse(t){if(this._getType(t)!==ta.object){let d=this._getOrReturnCtx(t);return Tr(d,{code:vr.invalid_type,expected:ta.object,received:d.parsedType}),$a}let{status:a,ctx:i}=this._processInputParams(t),{shape:s,keys:e}=this._getCached(),o=[];if(!(this._def.catchall instanceof VN&&this._def.unknownKeys==="strip"))for(let d in i.data)e.includes(d)||o.push(d);let u=[];for(let d of e){let I=s[d],h=i.data[d];u.push({key:{status:"valid",value:d},value:I._parse(new ov(i,h,i.path,d)),alwaysSet:d in i.data})}if(this._def.catchall instanceof VN){let d=this._def.unknownKeys;if(d==="passthrough")for(let I of o)u.push({key:{status:"valid",value:I},value:{status:"valid",value:i.data[I]}});else if(d==="strict")o.length>0&&(Tr(i,{code:vr.unrecognized_keys,keys:o}),a.dirty());else if(d!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let d=this._def.catchall;for(let I of o){let h=i.data[I];u.push({key:{status:"valid",value:I},value:d._parse(new ov(i,h,i.path,I)),alwaysSet:I in i.data})}}return i.common.async?Promise.resolve().then(async()=>{let d=[];for(let I of u){let h=await I.key,c=await I.value;d.push({key:h,value:c,alwaysSet:I.alwaysSet})}return d}).then(d=>qh.mergeObjectSync(a,d)):qh.mergeObjectSync(a,u)}get shape(){return this._def.shape()}strict(t){return Na.errToObj,new n({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(r,a)=>{let i=this._def.errorMap?.(r,a).message??a.defaultError;return r.code==="unrecognized_keys"?{message:Na.errToObj(t).message??i}:{message:i}}}:{}})}strip(){return new n({...this._def,unknownKeys:"strip"})}passthrough(){return new n({...this._def,unknownKeys:"passthrough"})}extend(t){return new n({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new n({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:ai.ZodObject})}setKey(t,r){return this.augment({[t]:r})}catchall(t){return new n({...this._def,catchall:t})}pick(t){let r={};for(let a of Hl.objectKeys(t))t[a]&&this.shape[a]&&(r[a]=this.shape[a]);return new n({...this._def,shape:()=>r})}omit(t){let r={};for(let a of Hl.objectKeys(this.shape))t[a]||(r[a]=this.shape[a]);return new n({...this._def,shape:()=>r})}deepPartial(){return GJ(this)}partial(t){let r={};for(let a of Hl.objectKeys(this.shape)){let i=this.shape[a];t&&!t[a]?r[a]=i:r[a]=i.optional()}return new n({...this._def,shape:()=>r})}required(t){let r={};for(let a of Hl.objectKeys(this.shape))if(t&&!t[a])r[a]=this.shape[a];else{let s=this.shape[a];for(;s instanceof sv;)s=s._def.innerType;r[a]=s}return new n({...this._def,shape:()=>r})}keyof(){return $Vt(Hl.objectKeys(this.shape))}};nf.create=(n,t)=>new nf({shape:()=>n,unknownKeys:"strip",catchall:VN.create(),typeName:ai.ZodObject,...Oi(t)});nf.strictCreate=(n,t)=>new nf({shape:()=>n,unknownKeys:"strict",catchall:VN.create(),typeName:ai.ZodObject,...Oi(t)});nf.lazycreate=(n,t)=>new nf({shape:n,unknownKeys:"strip",catchall:VN.create(),typeName:ai.ZodObject,...Oi(t)});OQ=class extends al{_parse(t){let{ctx:r}=this._processInputParams(t),a=this._def.options;function i(s){for(let o of s)if(o.result.status==="valid")return o.result;for(let o of s)if(o.result.status==="dirty")return r.common.issues.push(...o.ctx.common.issues),o.result;let e=s.map(o=>new tf(o.ctx.common.issues));return Tr(r,{code:vr.invalid_union,unionErrors:e}),$a}if(r.common.async)return Promise.all(a.map(async s=>{let e={...r,common:{...r.common,issues:[]},parent:null};return{result:await s._parseAsync({data:r.data,path:r.path,parent:e}),ctx:e}})).then(i);{let s,e=[];for(let u of a){let d={...r,common:{...r.common,issues:[]},parent:null},I=u._parseSync({data:r.data,path:r.path,parent:d});if(I.status==="valid")return I;I.status==="dirty"&&!s&&(s={result:I,ctx:d}),d.common.issues.length&&e.push(d.common.issues)}if(s)return r.common.issues.push(...s.ctx.common.issues),s.result;let o=e.map(u=>new tf(u));return Tr(r,{code:vr.invalid_union,unionErrors:o}),$a}}get options(){return this._def.options}};OQ.create=(n,t)=>new OQ({options:n,typeName:ai.ZodUnion,...Oi(t)});k5=n=>n instanceof MQ?k5(n.schema):n instanceof cv?k5(n.innerType()):n instanceof zQ?[n.value]:n instanceof _Q?n.options:n instanceof PQ?Hl.objectValues(n.enum):n instanceof jQ?k5(n._def.innerType):n instanceof TQ?[void 0]:n instanceof DQ?[null]:n instanceof sv?[void 0,...k5(n.unwrap())]:n instanceof XW?[null,...k5(n.unwrap())]:n instanceof aq||n instanceof qQ?k5(n.unwrap()):n instanceof KQ?k5(n._def.innerType):[],vme=class n extends al{_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==ta.object)return Tr(r,{code:vr.invalid_type,expected:ta.object,received:r.parsedType}),$a;let a=this.discriminator,i=r.data[a],s=this.optionsMap.get(i);return s?r.common.async?s._parseAsync({data:r.data,path:r.path,parent:r}):s._parseSync({data:r.data,path:r.path,parent:r}):(Tr(r,{code:vr.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[a]}),$a)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,r,a){let i=new Map;for(let s of r){let e=k5(s.shape[t]);if(!e.length)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let o of e){if(i.has(o))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(o)}`);i.set(o,s)}}return new n({typeName:ai.ZodDiscriminatedUnion,discriminator:t,options:r,optionsMap:i,...Oi(a)})}};UQ=class extends al{_parse(t){let{status:r,ctx:a}=this._processInputParams(t),i=(s,e)=>{if(Gme(s)||Gme(e))return $a;let o=lSe(s.value,e.value);return o.valid?((gme(s)||gme(e))&&r.dirty(),{status:r.value,value:o.data}):(Tr(a,{code:vr.invalid_intersection_types}),$a)};return a.common.async?Promise.all([this._def.left._parseAsync({data:a.data,path:a.path,parent:a}),this._def.right._parseAsync({data:a.data,path:a.path,parent:a})]).then(([s,e])=>i(s,e)):i(this._def.left._parseSync({data:a.data,path:a.path,parent:a}),this._def.right._parseSync({data:a.data,path:a.path,parent:a}))}};UQ.create=(n,t,r)=>new UQ({left:n,right:t,typeName:ai.ZodIntersection,...Oi(r)});HW=class n extends al{_parse(t){let{status:r,ctx:a}=this._processInputParams(t);if(a.parsedType!==ta.array)return Tr(a,{code:vr.invalid_type,expected:ta.array,received:a.parsedType}),$a;if(a.data.length<this._def.items.length)return Tr(a,{code:vr.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),$a;!this._def.rest&&a.data.length>this._def.items.length&&(Tr(a,{code:vr.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let s=[...a.data].map((e,o)=>{let u=this._def.items[o]||this._def.rest;return u?u._parse(new ov(a,e,a.path,o)):null}).filter(e=>!!e);return a.common.async?Promise.all(s).then(e=>qh.mergeArray(r,e)):qh.mergeArray(r,s)}get items(){return this._def.items}rest(t){return new n({...this._def,rest:t})}};HW.create=(n,t)=>{if(!Array.isArray(n))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new HW({items:n,typeName:ai.ZodTuple,rest:null,...Oi(t)})};Zme=class n extends al{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:r,ctx:a}=this._processInputParams(t);if(a.parsedType!==ta.object)return Tr(a,{code:vr.invalid_type,expected:ta.object,received:a.parsedType}),$a;let i=[],s=this._def.keyType,e=this._def.valueType;for(let o in a.data)i.push({key:s._parse(new ov(a,o,a.path,o)),value:e._parse(new ov(a,a.data[o],a.path,o)),alwaysSet:o in a.data});return a.common.async?qh.mergeObjectAsync(r,i):qh.mergeObjectSync(r,i)}get element(){return this._def.valueType}static create(t,r,a){return r instanceof al?new n({keyType:t,valueType:r,typeName:ai.ZodRecord,...Oi(a)}):new n({keyType:Aw.create(),valueType:t,typeName:ai.ZodRecord,...Oi(r)})}},ZJ=class extends al{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:r,ctx:a}=this._processInputParams(t);if(a.parsedType!==ta.map)return Tr(a,{code:vr.invalid_type,expected:ta.map,received:a.parsedType}),$a;let i=this._def.keyType,s=this._def.valueType,e=[...a.data.entries()].map(([o,u],d)=>({key:i._parse(new ov(a,o,a.path,[d,"key"])),value:s._parse(new ov(a,u,a.path,[d,"value"]))}));if(a.common.async){let o=new Map;return Promise.resolve().then(async()=>{for(let u of e){let d=await u.key,I=await u.value;if(d.status==="aborted"||I.status==="aborted")return $a;(d.status==="dirty"||I.status==="dirty")&&r.dirty(),o.set(d.value,I.value)}return{status:r.value,value:o}})}else{let o=new Map;for(let u of e){let d=u.key,I=u.value;if(d.status==="aborted"||I.status==="aborted")return $a;(d.status==="dirty"||I.status==="dirty")&&r.dirty(),o.set(d.value,I.value)}return{status:r.value,value:o}}}};ZJ.create=(n,t,r)=>new ZJ({valueType:t,keyType:n,typeName:ai.ZodMap,...Oi(r)});NJ=class n extends al{_parse(t){let{status:r,ctx:a}=this._processInputParams(t);if(a.parsedType!==ta.set)return Tr(a,{code:vr.invalid_type,expected:ta.set,received:a.parsedType}),$a;let i=this._def;i.minSize!==null&&a.data.size<i.minSize.value&&(Tr(a,{code:vr.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),r.dirty()),i.maxSize!==null&&a.data.size>i.maxSize.value&&(Tr(a,{code:vr.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),r.dirty());let s=this._def.valueType;function e(u){let d=new Set;for(let I of u){if(I.status==="aborted")return $a;I.status==="dirty"&&r.dirty(),d.add(I.value)}return{status:r.value,value:d}}let o=[...a.data.values()].map((u,d)=>s._parse(new ov(a,u,a.path,d)));return a.common.async?Promise.all(o).then(u=>e(u)):e(o)}min(t,r){return new n({...this._def,minSize:{value:t,message:Na.toString(r)}})}max(t,r){return new n({...this._def,maxSize:{value:t,message:Na.toString(r)}})}size(t,r){return this.min(t,r).max(t,r)}nonempty(t){return this.min(1,t)}};NJ.create=(n,t)=>new NJ({valueType:n,minSize:null,maxSize:null,typeName:ai.ZodSet,...Oi(t)});Nme=class n extends al{constructor(){super(...arguments),this.validate=this.implement}_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==ta.function)return Tr(r,{code:vr.invalid_type,expected:ta.function,received:r.parsedType}),$a;function a(o,u){return rq({data:o,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,bJ(),X5].filter(d=>!!d),issueData:{code:vr.invalid_arguments,argumentsError:u}})}function i(o,u){return rq({data:o,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,bJ(),X5].filter(d=>!!d),issueData:{code:vr.invalid_return_type,returnTypeError:u}})}let s={errorMap:r.common.contextualErrorMap},e=r.data;if(this._def.returns instanceof yw){let o=this;return ip(async function(...u){let d=new tf([]),I=await o._def.args.parseAsync(u,s).catch(G=>{throw d.addIssue(a(u,G)),d}),h=await Reflect.apply(e,this,I);return await o._def.returns._def.type.parseAsync(h,s).catch(G=>{throw d.addIssue(i(h,G)),d})})}else{let o=this;return ip(function(...u){let d=o._def.args.safeParse(u,s);if(!d.success)throw new tf([a(u,d.error)]);let I=Reflect.apply(e,this,d.data),h=o._def.returns.safeParse(I,s);if(!h.success)throw new tf([i(I,h.error)]);return h.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new n({...this._def,args:HW.create(t).rest(L5.create())})}returns(t){return new n({...this._def,returns:t})}implement(t){return this.parse(t)}strictImplement(t){return this.parse(t)}static create(t,r,a){return new n({args:t||HW.create([]).rest(L5.create()),returns:r||L5.create(),typeName:ai.ZodFunction,...Oi(a)})}},MQ=class extends al{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})}};MQ.create=(n,t)=>new MQ({getter:n,typeName:ai.ZodLazy,...Oi(t)});zQ=class extends al{_parse(t){if(t.data!==this._def.value){let r=this._getOrReturnCtx(t);return Tr(r,{received:r.data,code:vr.invalid_literal,expected:this._def.value}),$a}return{status:"valid",value:t.data}}get value(){return this._def.value}};zQ.create=(n,t)=>new zQ({value:n,typeName:ai.ZodLiteral,...Oi(t)});_Q=class n extends al{_parse(t){if(typeof t.data!="string"){let r=this._getOrReturnCtx(t),a=this._def.values;return Tr(r,{expected:Hl.joinValues(a),received:r.parsedType,code:vr.invalid_type}),$a}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){let r=this._getOrReturnCtx(t),a=this._def.values;return Tr(r,{received:r.data,code:vr.invalid_enum_value,options:a}),$a}return ip(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 n.create(t,{...this._def,...r})}exclude(t,r=this._def){return n.create(this.options.filter(a=>!t.includes(a)),{...this._def,...r})}};_Q.create=$Vt;PQ=class extends al{_parse(t){let r=Hl.getValidEnumValues(this._def.values),a=this._getOrReturnCtx(t);if(a.parsedType!==ta.string&&a.parsedType!==ta.number){let i=Hl.objectValues(r);return Tr(a,{expected:Hl.joinValues(i),received:a.parsedType,code:vr.invalid_type}),$a}if(this._cache||(this._cache=new Set(Hl.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){let i=Hl.objectValues(r);return Tr(a,{received:a.data,code:vr.invalid_enum_value,options:i}),$a}return ip(t.data)}get enum(){return this._def.values}};PQ.create=(n,t)=>new PQ({values:n,typeName:ai.ZodNativeEnum,...Oi(t)});yw=class extends al{unwrap(){return this._def.type}_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==ta.promise&&r.common.async===!1)return Tr(r,{code:vr.invalid_type,expected:ta.promise,received:r.parsedType}),$a;let a=r.parsedType===ta.promise?r.data:Promise.resolve(r.data);return ip(a.then(i=>this._def.type.parseAsync(i,{path:r.path,errorMap:r.common.contextualErrorMap})))}};yw.create=(n,t)=>new yw({type:n,typeName:ai.ZodPromise,...Oi(t)});cv=class extends al{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===ai.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){let{status:r,ctx:a}=this._processInputParams(t),i=this._def.effect||null,s={addIssue:e=>{Tr(a,e),e.fatal?r.abort():r.dirty()},get path(){return a.path}};if(s.addIssue=s.addIssue.bind(s),i.type==="preprocess"){let e=i.transform(a.data,s);if(a.common.async)return Promise.resolve(e).then(async o=>{if(r.value==="aborted")return $a;let u=await this._def.schema._parseAsync({data:o,path:a.path,parent:a});return u.status==="aborted"?$a:u.status==="dirty"?kQ(u.value):r.value==="dirty"?kQ(u.value):u});{if(r.value==="aborted")return $a;let o=this._def.schema._parseSync({data:e,path:a.path,parent:a});return o.status==="aborted"?$a:o.status==="dirty"?kQ(o.value):r.value==="dirty"?kQ(o.value):o}}if(i.type==="refinement"){let e=o=>{let u=i.refinement(o,s);if(a.common.async)return Promise.resolve(u);if(u instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(a.common.async===!1){let o=this._def.schema._parseSync({data:a.data,path:a.path,parent:a});return o.status==="aborted"?$a:(o.status==="dirty"&&r.dirty(),e(o.value),{status:r.value,value:o.value})}else return this._def.schema._parseAsync({data:a.data,path:a.path,parent:a}).then(o=>o.status==="aborted"?$a:(o.status==="dirty"&&r.dirty(),e(o.value).then(()=>({status:r.value,value:o.value}))))}if(i.type==="transform")if(a.common.async===!1){let e=this._def.schema._parseSync({data:a.data,path:a.path,parent:a});if(!Nw(e))return $a;let o=i.transform(e.value,s);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:o}}else return this._def.schema._parseAsync({data:a.data,path:a.path,parent:a}).then(e=>Nw(e)?Promise.resolve(i.transform(e.value,s)).then(o=>({status:r.value,value:o})):$a);Hl.assertNever(i)}};cv.create=(n,t,r)=>new cv({schema:n,typeName:ai.ZodEffects,effect:t,...Oi(r)});cv.createWithPreprocess=(n,t,r)=>new cv({schema:t,effect:{type:"preprocess",transform:n},typeName:ai.ZodEffects,...Oi(r)});sv=class extends al{_parse(t){return this._getType(t)===ta.undefined?ip(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};sv.create=(n,t)=>new sv({innerType:n,typeName:ai.ZodOptional,...Oi(t)});XW=class extends al{_parse(t){return this._getType(t)===ta.null?ip(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};XW.create=(n,t)=>new XW({innerType:n,typeName:ai.ZodNullable,...Oi(t)});jQ=class extends al{_parse(t){let{ctx:r}=this._processInputParams(t),a=r.data;return r.parsedType===ta.undefined&&(a=this._def.defaultValue()),this._def.innerType._parse({data:a,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};jQ.create=(n,t)=>new jQ({innerType:n,typeName:ai.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...Oi(t)});KQ=class extends al{_parse(t){let{ctx:r}=this._processInputParams(t),a={...r,common:{...r.common,issues:[]}},i=this._def.innerType._parse({data:a.data,path:a.path,parent:{...a}});return fJ(i)?i.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new tf(a.common.issues)},input:a.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new tf(a.common.issues)},input:a.data})}}removeCatch(){return this._def.innerType}};KQ.create=(n,t)=>new KQ({innerType:n,typeName:ai.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...Oi(t)});AJ=class extends al{_parse(t){if(this._getType(t)!==ta.nan){let a=this._getOrReturnCtx(t);return Tr(a,{code:vr.invalid_type,expected:ta.nan,received:a.parsedType}),$a}return{status:"valid",value:t.data}}};AJ.create=n=>new AJ({typeName:ai.ZodNaN,...Oi(n)});A3r=Symbol("zod_brand"),aq=class extends al{_parse(t){let{ctx:r}=this._processInputParams(t),a=r.data;return this._def.type._parse({data:a,path:r.path,parent:r})}unwrap(){return this._def.type}},iq=class n extends al{_parse(t){let{status:r,ctx:a}=this._processInputParams(t);if(a.common.async)return(async()=>{let s=await this._def.in._parseAsync({data:a.data,path:a.path,parent:a});return s.status==="aborted"?$a:s.status==="dirty"?(r.dirty(),kQ(s.value)):this._def.out._parseAsync({data:s.value,path:a.path,parent:a})})();{let i=this._def.in._parseSync({data:a.data,path:a.path,parent:a});return i.status==="aborted"?$a:i.status==="dirty"?(r.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:a.path,parent:a})}}static create(t,r){return new n({in:t,out:r,typeName:ai.ZodPipeline})}},qQ=class extends al{_parse(t){let r=this._def.innerType._parse(t),a=i=>(Nw(i)&&(i.value=Object.freeze(i.value)),i);return fJ(r)?r.then(i=>a(i)):a(r)}unwrap(){return this._def.innerType}};qQ.create=(n,t)=>new qQ({innerType:n,typeName:ai.ZodReadonly,...Oi(t)});W3r={object:nf.lazycreate};(function(n){n.ZodString="ZodString",n.ZodNumber="ZodNumber",n.ZodNaN="ZodNaN",n.ZodBigInt="ZodBigInt",n.ZodBoolean="ZodBoolean",n.ZodDate="ZodDate",n.ZodSymbol="ZodSymbol",n.ZodUndefined="ZodUndefined",n.ZodNull="ZodNull",n.ZodAny="ZodAny",n.ZodUnknown="ZodUnknown",n.ZodNever="ZodNever",n.ZodVoid="ZodVoid",n.ZodArray="ZodArray",n.ZodObject="ZodObject",n.ZodUnion="ZodUnion",n.ZodDiscriminatedUnion="ZodDiscriminatedUnion",n.ZodIntersection="ZodIntersection",n.ZodTuple="ZodTuple",n.ZodRecord="ZodRecord",n.ZodMap="ZodMap",n.ZodSet="ZodSet",n.ZodFunction="ZodFunction",n.ZodLazy="ZodLazy",n.ZodLiteral="ZodLiteral",n.ZodEnum="ZodEnum",n.ZodEffects="ZodEffects",n.ZodNativeEnum="ZodNativeEnum",n.ZodOptional="ZodOptional",n.ZodNullable="ZodNullable",n.ZodDefault="ZodDefault",n.ZodCatch="ZodCatch",n.ZodPromise="ZodPromise",n.ZodBranded="ZodBranded",n.ZodPipeline="ZodPipeline",n.ZodReadonly="ZodReadonly"})(ai||(ai={}));y3r=(n,t={message:`Input not instance of ${n.name}`})=>eQt(r=>r instanceof n,t),tQt=Aw.create,nQt=LQ.create,F3r=AJ.create,E3r=SQ.create,rQt=BQ.create,R3r=JQ.create,w3r=gJ.create,C3r=TQ.create,Y3r=DQ.create,x3r=Ww.create,V3r=L5.create,Q3r=VN.create,H3r=vJ.create,X3r=S5.create,k3r=nf.create,L3r=nf.strictCreate,S3r=OQ.create,B3r=vme.create,J3r=UQ.create,T3r=HW.create,D3r=Zme.create,O3r=ZJ.create,U3r=NJ.create,M3r=Nme.create,z3r=MQ.create,_3r=zQ.create,P3r=_Q.create,j3r=PQ.create,K3r=yw.create,q3r=cv.create,$3r=sv.create,eWr=XW.create,tWr=cv.createWithPreprocess,nWr=iq.create,rWr=()=>tQt().optional(),aWr=()=>nQt().optional(),iWr=()=>rQt().optional(),lWr={string:(n=>Aw.create({...n,coerce:!0})),number:(n=>LQ.create({...n,coerce:!0})),boolean:(n=>BQ.create({...n,coerce:!0})),bigint:(n=>SQ.create({...n,coerce:!0})),date:(n=>JQ.create({...n,coerce:!0}))},sWr=$a});var Xu={};po(Xu,{BRAND:()=>A3r,DIRTY:()=>kQ,EMPTY_PATH:()=>t3r,INVALID:()=>$a,NEVER:()=>sWr,OK:()=>ip,ParseStatus:()=>qh,Schema:()=>al,ZodAny:()=>Ww,ZodArray:()=>S5,ZodBigInt:()=>SQ,ZodBoolean:()=>BQ,ZodBranded:()=>aq,ZodCatch:()=>KQ,ZodDate:()=>JQ,ZodDefault:()=>jQ,ZodDiscriminatedUnion:()=>vme,ZodEffects:()=>cv,ZodEnum:()=>_Q,ZodError:()=>tf,ZodFirstPartyTypeKind:()=>ai,ZodFunction:()=>Nme,ZodIntersection:()=>UQ,ZodIssueCode:()=>vr,ZodLazy:()=>MQ,ZodLiteral:()=>zQ,ZodMap:()=>ZJ,ZodNaN:()=>AJ,ZodNativeEnum:()=>PQ,ZodNever:()=>VN,ZodNull:()=>DQ,ZodNullable:()=>XW,ZodNumber:()=>LQ,ZodObject:()=>nf,ZodOptional:()=>sv,ZodParsedType:()=>ta,ZodPipeline:()=>iq,ZodPromise:()=>yw,ZodReadonly:()=>qQ,ZodRecord:()=>Zme,ZodSchema:()=>al,ZodSet:()=>NJ,ZodString:()=>Aw,ZodSymbol:()=>gJ,ZodTransformer:()=>cv,ZodTuple:()=>HW,ZodType:()=>al,ZodUndefined:()=>TQ,ZodUnion:()=>OQ,ZodUnknown:()=>L5,ZodVoid:()=>vJ,addIssueToContext:()=>Tr,any:()=>x3r,array:()=>X3r,bigint:()=>E3r,boolean:()=>rQt,coerce:()=>lWr,custom:()=>eQt,date:()=>R3r,datetimeRegex:()=>qVt,defaultErrorMap:()=>X5,discriminatedUnion:()=>B3r,effect:()=>q3r,enum:()=>P3r,function:()=>M3r,getErrorMap:()=>bJ,getParsedType:()=>QW,instanceof:()=>y3r,intersection:()=>J3r,isAborted:()=>Gme,isAsync:()=>fJ,isDirty:()=>gme,isValid:()=>Nw,late:()=>W3r,lazy:()=>z3r,literal:()=>_3r,makeIssue:()=>rq,map:()=>O3r,nan:()=>F3r,nativeEnum:()=>j3r,never:()=>Q3r,null:()=>Y3r,nullable:()=>eWr,number:()=>nQt,object:()=>k3r,objectUtil:()=>nSe,oboolean:()=>iWr,onumber:()=>aWr,optional:()=>$3r,ostring:()=>rWr,pipeline:()=>nWr,preprocess:()=>tWr,promise:()=>K3r,quotelessJson:()=>qAr,record:()=>D3r,set:()=>U3r,setErrorMap:()=>e3r,strictObject:()=>L3r,string:()=>tQt,symbol:()=>w3r,transformer:()=>q3r,tuple:()=>T3r,undefined:()=>C3r,union:()=>S3r,unknown:()=>V3r,util:()=>Hl,void:()=>H3r});var sSe=ut(()=>{fme();aSe();MVt();nq();aQt();bme()});function Jn(n,t,r){function a(o,u){var d;Object.defineProperty(o,"_zod",{value:o._zod??{},enumerable:!1}),(d=o._zod).traits??(d.traits=new Set),o._zod.traits.add(n),t(o,u);for(let I in e.prototype)I in o||Object.defineProperty(o,I,{value:e.prototype[I].bind(o)});o._zod.constr=e,o._zod.def=u}let i=r?.Parent??Object;class s extends i{}Object.defineProperty(s,"name",{value:n});function e(o){var u;let d=r?.Parent?new s:this;a(d,o),(u=d._zod).deferred??(u.deferred=[]);for(let I of d._zod.deferred)I();return d}return Object.defineProperty(e,"init",{value:a}),Object.defineProperty(e,Symbol.hasInstance,{value:o=>r?.Parent&&o instanceof r.Parent?!0:o?._zod?.traits?.has(n)}),Object.defineProperty(e,"name",{value:n}),e}function e1(n){return n&&Object.assign(Ame,n),Ame}var oSe,oWr,B5,Ame,WJ=ut(()=>{oSe=Object.freeze({status:"aborted"});oWr=Symbol("zod_brand"),B5=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},Ame={}});var Ts={};po(Ts,{BIGINT_FORMAT_RANGES:()=>lQt,Class:()=>uSe,NUMBER_FORMAT_RANGES:()=>GSe,aborted:()=>e9,allowsEval:()=>pSe,assert:()=>hWr,assertEqual:()=>cWr,assertIs:()=>IWr,assertNever:()=>dWr,assertNotEqual:()=>uWr,assignProp:()=>mSe,cached:()=>sq,captureStackTrace:()=>yme,cleanEnum:()=>FWr,cleanRegex:()=>cq,clone:()=>QN,createTransparentProxy:()=>gWr,defineLazy:()=>Wc,esc:()=>$Q,escapeRegex:()=>Fw,extend:()=>NWr,finalizeIssue:()=>HN,floatSafeRemainder:()=>hSe,getElementAtPath:()=>mWr,getEnumValues:()=>ISe,getLengthableOrigin:()=>uq,getParsedType:()=>GWr,getSizableOrigin:()=>sQt,isObject:()=>yJ,isPlainObject:()=>FJ,issue:()=>gSe,joinValues:()=>Wme,jsonStringifyReplacer:()=>dSe,merge:()=>AWr,normalizeParams:()=>ka,nullish:()=>oq,numKeys:()=>fWr,omit:()=>ZWr,optionalKeys:()=>fSe,partial:()=>WWr,pick:()=>vWr,prefixIssues:()=>kW,primitiveTypes:()=>iQt,promiseAllObject:()=>pWr,propertyKeyTypes:()=>bSe,randomString:()=>bWr,required:()=>yWr,stringifyPrimitive:()=>Fme,unwrapMessage:()=>lq});function cWr(n){return n}function uWr(n){return n}function IWr(n){}function dWr(n){throw new Error}function hWr(n){}function ISe(n){let t=Object.values(n).filter(a=>typeof a=="number");return Object.entries(n).filter(([a,i])=>t.indexOf(+a)===-1).map(([a,i])=>i)}function Wme(n,t="|"){return n.map(r=>Fme(r)).join(t)}function dSe(n,t){return typeof t=="bigint"?t.toString():t}function sq(n){return{get value(){{let r=n();return Object.defineProperty(this,"value",{value:r}),r}throw new Error("cached value already set")}}}function oq(n){return n==null}function cq(n){let t=n.startsWith("^")?1:0,r=n.endsWith("$")?n.length-1:n.length;return n.slice(t,r)}function hSe(n,t){let r=(n.toString().split(".")[1]||"").length,a=(t.toString().split(".")[1]||"").length,i=r>a?r:a,s=Number.parseInt(n.toFixed(i).replace(".","")),e=Number.parseInt(t.toFixed(i).replace(".",""));return s%e/10**i}function Wc(n,t,r){Object.defineProperty(n,t,{get(){{let i=r();return n[t]=i,i}throw new Error("cached value already set")},set(i){Object.defineProperty(n,t,{value:i})},configurable:!0})}function mSe(n,t,r){Object.defineProperty(n,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function mWr(n,t){return t?t.reduce((r,a)=>r?.[a],n):n}function pWr(n){let t=Object.keys(n),r=t.map(a=>n[a]);return Promise.all(r).then(a=>{let i={};for(let s=0;s<t.length;s++)i[t[s]]=a[s];return i})}function bWr(n=10){let t="abcdefghijklmnopqrstuvwxyz",r="";for(let a=0;a<n;a++)r+=t[Math.floor(Math.random()*t.length)];return r}function $Q(n){return JSON.stringify(n)}function yJ(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function FJ(n){if(yJ(n)===!1)return!1;let t=n.constructor;if(t===void 0)return!0;let r=t.prototype;return!(yJ(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function fWr(n){let t=0;for(let r in n)Object.prototype.hasOwnProperty.call(n,r)&&t++;return t}function Fw(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function QN(n,t,r){let a=new n._zod.constr(t??n._zod.def);return(!t||r?.parent)&&(a._zod.parent=n),a}function ka(n){let t=n;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function gWr(n){let t;return new Proxy({},{get(r,a,i){return t??(t=n()),Reflect.get(t,a,i)},set(r,a,i,s){return t??(t=n()),Reflect.set(t,a,i,s)},has(r,a){return t??(t=n()),Reflect.has(t,a)},deleteProperty(r,a){return t??(t=n()),Reflect.deleteProperty(t,a)},ownKeys(r){return t??(t=n()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(r,a){return t??(t=n()),Reflect.getOwnPropertyDescriptor(t,a)},defineProperty(r,a,i){return t??(t=n()),Reflect.defineProperty(t,a,i)}})}function Fme(n){return typeof n=="bigint"?n.toString()+"n":typeof n=="string"?`"${n}"`:`${n}`}function fSe(n){return Object.keys(n).filter(t=>n[t]._zod.optin==="optional"&&n[t]._zod.optout==="optional")}function vWr(n,t){let r={},a=n._zod.def;for(let i in t){if(!(i in a.shape))throw new Error(`Unrecognized key: "${i}"`);t[i]&&(r[i]=a.shape[i])}return QN(n,{...n._zod.def,shape:r,checks:[]})}function ZWr(n,t){let r={...n._zod.def.shape},a=n._zod.def;for(let i in t){if(!(i in a.shape))throw new Error(`Unrecognized key: "${i}"`);t[i]&&delete r[i]}return QN(n,{...n._zod.def,shape:r,checks:[]})}function NWr(n,t){if(!FJ(t))throw new Error("Invalid input to extend: expected a plain object");let r={...n._zod.def,get shape(){let a={...n._zod.def.shape,...t};return mSe(this,"shape",a),a},checks:[]};return QN(n,r)}function AWr(n,t){return QN(n,{...n._zod.def,get shape(){let r={...n._zod.def.shape,...t._zod.def.shape};return mSe(this,"shape",r),r},catchall:t._zod.def.catchall,checks:[]})}function WWr(n,t,r){let a=t._zod.def.shape,i={...a};if(r)for(let s in r){if(!(s in a))throw new Error(`Unrecognized key: "${s}"`);r[s]&&(i[s]=n?new n({type:"optional",innerType:a[s]}):a[s])}else for(let s in a)i[s]=n?new n({type:"optional",innerType:a[s]}):a[s];return QN(t,{...t._zod.def,shape:i,checks:[]})}function yWr(n,t,r){let a=t._zod.def.shape,i={...a};if(r)for(let s in r){if(!(s in i))throw new Error(`Unrecognized key: "${s}"`);r[s]&&(i[s]=new n({type:"nonoptional",innerType:a[s]}))}else for(let s in a)i[s]=new n({type:"nonoptional",innerType:a[s]});return QN(t,{...t._zod.def,shape:i,checks:[]})}function e9(n,t=0){for(let r=t;r<n.issues.length;r++)if(n.issues[r]?.continue!==!0)return!0;return!1}function kW(n,t){return t.map(r=>{var a;return(a=r).path??(a.path=[]),r.path.unshift(n),r})}function lq(n){return typeof n=="string"?n:n?.message}function HN(n,t,r){let a={...n,path:n.path??[]};if(!n.message){let i=lq(n.inst?._zod.def?.error?.(n))??lq(t?.error?.(n))??lq(r.customError?.(n))??lq(r.localeError?.(n))??"Invalid input";a.message=i}return delete a.inst,delete a.continue,t?.reportInput||delete a.input,a}function sQt(n){return n instanceof Set?"set":n instanceof Map?"map":n instanceof File?"file":"unknown"}function uq(n){return Array.isArray(n)?"array":typeof n=="string"?"string":"unknown"}function gSe(...n){let[t,r,a]=n;return typeof t=="string"?{message:t,code:"custom",input:r,inst:a}:{...t}}function FWr(n){return Object.entries(n).filter(([t,r])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}var yme,pSe,GWr,bSe,iQt,GSe,lQt,uSe,J5=ut(()=>{yme=Error.captureStackTrace?Error.captureStackTrace:(...n)=>{};pSe=sq(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let n=Function;return new n(""),!0}catch{return!1}});GWr=n=>{let t=typeof n;switch(t){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(n)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(n)?"array":n===null?"null":n.then&&typeof n.then=="function"&&n.catch&&typeof n.catch=="function"?"promise":typeof Map<"u"&&n instanceof Map?"map":typeof Set<"u"&&n instanceof Set?"set":typeof Date<"u"&&n instanceof Date?"date":typeof File<"u"&&n instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${t}`)}},bSe=new Set(["string","number","symbol"]),iQt=new Set(["string","number","bigint","boolean","symbol","undefined"]);GSe={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},lQt={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};uSe=class{constructor(...t){}}});function ZSe(n,t=r=>r.message){let r={},a=[];for(let i of n.issues)i.path.length>0?(r[i.path[0]]=r[i.path[0]]||[],r[i.path[0]].push(t(i))):a.push(t(i));return{formErrors:a,fieldErrors:r}}function NSe(n,t){let r=t||function(s){return s.message},a={_errors:[]},i=s=>{for(let e of s.issues)if(e.code==="invalid_union"&&e.errors.length)e.errors.map(o=>i({issues:o}));else if(e.code==="invalid_key")i({issues:e.issues});else if(e.code==="invalid_element")i({issues:e.issues});else if(e.path.length===0)a._errors.push(r(e));else{let o=a,u=0;for(;u<e.path.length;){let d=e.path[u];u===e.path.length-1?(o[d]=o[d]||{_errors:[]},o[d]._errors.push(r(e))):o[d]=o[d]||{_errors:[]},o=o[d],u++}}};return i(n),a}var oQt,Eme,vSe,ASe=ut(()=>{WJ();J5();oQt=(n,t)=>{n.name="$ZodError",Object.defineProperty(n,"_zod",{value:n._zod,enumerable:!1}),Object.defineProperty(n,"issues",{value:t,enumerable:!1}),Object.defineProperty(n,"message",{get(){return JSON.stringify(t,dSe,2)},enumerable:!0}),Object.defineProperty(n,"toString",{value:()=>n.message,enumerable:!1})},Eme=Jn("$ZodError",oQt),vSe=Jn("$ZodError",oQt,{Parent:Error})});var cQt,uQt,WSe,Iq,ySe,Rme,FSe=ut(()=>{WJ();ASe();J5();cQt=n=>(t,r,a,i)=>{let s=a?Object.assign(a,{async:!1}):{async:!1},e=t._zod.run({value:r,issues:[]},s);if(e instanceof Promise)throw new B5;if(e.issues.length){let o=new(i?.Err??n)(e.issues.map(u=>HN(u,s,e1())));throw yme(o,i?.callee),o}return e.value},uQt=n=>async(t,r,a,i)=>{let s=a?Object.assign(a,{async:!0}):{async:!0},e=t._zod.run({value:r,issues:[]},s);if(e instanceof Promise&&(e=await e),e.issues.length){let o=new(i?.Err??n)(e.issues.map(u=>HN(u,s,e1())));throw yme(o,i?.callee),o}return e.value},WSe=n=>(t,r,a)=>{let i=a?{...a,async:!1}:{async:!1},s=t._zod.run({value:r,issues:[]},i);if(s instanceof Promise)throw new B5;return s.issues.length?{success:!1,error:new(n??Eme)(s.issues.map(e=>HN(e,i,e1())))}:{success:!0,data:s.value}},Iq=WSe(vSe),ySe=n=>async(t,r,a)=>{let i=a?Object.assign(a,{async:!0}):{async:!0},s=t._zod.run({value:r,issues:[]},i);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new n(s.issues.map(e=>HN(e,i,e1())))}:{success:!0,data:s.value}},Rme=ySe(vSe)});function vQt(){return new RegExp(RWr,"u")}function CQt(n){let t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof n.precision=="number"?n.precision===-1?`${t}`:n.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${n.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function YQt(n){return new RegExp(`^${CQt(n)}$`)}function xQt(n){let t=CQt({precision:n.precision}),r=["Z"];n.local&&r.push(""),n.offset&&r.push("([+-]\\d{2}:\\d{2})");let a=`${t}(?:${r.join("|")})`;return new RegExp(`^${RQt}T(?:${a})$`)}var IQt,dQt,hQt,mQt,pQt,bQt,fQt,GQt,ESe,gQt,RWr,ZQt,NQt,AQt,WQt,yQt,RSe,FQt,EQt,RQt,wQt,VQt,QQt,HQt,XQt,kQt,LQt,SQt,BQt,Cme=ut(()=>{IQt=/^[cC][^\s-]{8,}$/,dQt=/^[0-9a-z]+$/,hQt=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,mQt=/^[0-9a-vA-V]{20}$/,pQt=/^[A-Za-z0-9]{27}$/,bQt=/^[a-zA-Z0-9_-]{21}$/,fQt=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,GQt=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,ESe=n=>n?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${n}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000)$/,gQt=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,RWr="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";ZQt=/^(?:(?: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])$/,NQt=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})$/,AQt=/^((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])\/([0-9]|[1-2][0-9]|3[0-2])$/,WQt=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,yQt=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,RSe=/^[A-Za-z0-9_-]*$/,FQt=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/,EQt=/^\+(?:[0-9]){6,14}[0-9]$/,RQt="(?:(?:\\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])))",wQt=new RegExp(`^${RQt}$`);VQt=n=>{let t=n?`[\\s\\S]{${n?.minimum??0},${n?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},QQt=/^\d+n?$/,HQt=/^\d+$/,XQt=/^-?\d+(?:\.\d+)?/i,kQt=/true|false/i,LQt=/null/i,SQt=/^[^A-Z]*$/,BQt=/^[^a-z]*$/});var lp,JQt,wSe,CSe,TQt,DQt,OQt,UQt,MQt,dq,zQt,_Qt,PQt,jQt,KQt,qQt,$Qt,Yme=ut(()=>{WJ();Cme();J5();lp=Jn("$ZodCheck",(n,t)=>{var r;n._zod??(n._zod={}),n._zod.def=t,(r=n._zod).onattach??(r.onattach=[])}),JQt={number:"number",bigint:"bigint",object:"date"},wSe=Jn("$ZodCheckLessThan",(n,t)=>{lp.init(n,t);let r=JQt[typeof t.value];n._zod.onattach.push(a=>{let i=a._zod.bag,s=(t.inclusive?i.maximum:i.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<s&&(t.inclusive?i.maximum=t.value:i.exclusiveMaximum=t.value)}),n._zod.check=a=>{(t.inclusive?a.value<=t.value:a.value<t.value)||a.issues.push({origin:r,code:"too_big",maximum:t.value,input:a.value,inclusive:t.inclusive,inst:n,continue:!t.abort})}}),CSe=Jn("$ZodCheckGreaterThan",(n,t)=>{lp.init(n,t);let r=JQt[typeof t.value];n._zod.onattach.push(a=>{let i=a._zod.bag,s=(t.inclusive?i.minimum:i.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>s&&(t.inclusive?i.minimum=t.value:i.exclusiveMinimum=t.value)}),n._zod.check=a=>{(t.inclusive?a.value>=t.value:a.value>t.value)||a.issues.push({origin:r,code:"too_small",minimum:t.value,input:a.value,inclusive:t.inclusive,inst:n,continue:!t.abort})}}),TQt=Jn("$ZodCheckMultipleOf",(n,t)=>{lp.init(n,t),n._zod.onattach.push(r=>{var a;(a=r._zod.bag).multipleOf??(a.multipleOf=t.value)}),n._zod.check=r=>{if(typeof r.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?r.value%t.value===BigInt(0):hSe(r.value,t.value)===0)||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:n,continue:!t.abort})}}),DQt=Jn("$ZodCheckNumberFormat",(n,t)=>{lp.init(n,t),t.format=t.format||"float64";let r=t.format?.includes("int"),a=r?"int":"number",[i,s]=GSe[t.format];n._zod.onattach.push(e=>{let o=e._zod.bag;o.format=t.format,o.minimum=i,o.maximum=s,r&&(o.pattern=HQt)}),n._zod.check=e=>{let o=e.value;if(r){if(!Number.isInteger(o)){e.issues.push({expected:a,format:t.format,code:"invalid_type",input:o,inst:n});return}if(!Number.isSafeInteger(o)){o>0?e.issues.push({input:o,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:n,origin:a,continue:!t.abort}):e.issues.push({input:o,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:n,origin:a,continue:!t.abort});return}}o<i&&e.issues.push({origin:"number",input:o,code:"too_small",minimum:i,inclusive:!0,inst:n,continue:!t.abort}),o>s&&e.issues.push({origin:"number",input:o,code:"too_big",maximum:s,inst:n})}}),OQt=Jn("$ZodCheckMaxLength",(n,t)=>{var r;lp.init(n,t),(r=n._zod.def).when??(r.when=a=>{let i=a.value;return!oq(i)&&i.length!==void 0}),n._zod.onattach.push(a=>{let i=a._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<i&&(a._zod.bag.maximum=t.maximum)}),n._zod.check=a=>{let i=a.value;if(i.length<=t.maximum)return;let e=uq(i);a.issues.push({origin:e,code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:n,continue:!t.abort})}}),UQt=Jn("$ZodCheckMinLength",(n,t)=>{var r;lp.init(n,t),(r=n._zod.def).when??(r.when=a=>{let i=a.value;return!oq(i)&&i.length!==void 0}),n._zod.onattach.push(a=>{let i=a._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>i&&(a._zod.bag.minimum=t.minimum)}),n._zod.check=a=>{let i=a.value;if(i.length>=t.minimum)return;let e=uq(i);a.issues.push({origin:e,code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:n,continue:!t.abort})}}),MQt=Jn("$ZodCheckLengthEquals",(n,t)=>{var r;lp.init(n,t),(r=n._zod.def).when??(r.when=a=>{let i=a.value;return!oq(i)&&i.length!==void 0}),n._zod.onattach.push(a=>{let i=a._zod.bag;i.minimum=t.length,i.maximum=t.length,i.length=t.length}),n._zod.check=a=>{let i=a.value,s=i.length;if(s===t.length)return;let e=uq(i),o=s>t.length;a.issues.push({origin:e,...o?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:a.value,inst:n,continue:!t.abort})}}),dq=Jn("$ZodCheckStringFormat",(n,t)=>{var r,a;lp.init(n,t),n._zod.onattach.push(i=>{let s=i._zod.bag;s.format=t.format,t.pattern&&(s.patterns??(s.patterns=new Set),s.patterns.add(t.pattern))}),t.pattern?(r=n._zod).check??(r.check=i=>{t.pattern.lastIndex=0,!t.pattern.test(i.value)&&i.issues.push({origin:"string",code:"invalid_format",format:t.format,input:i.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:n,continue:!t.abort})}):(a=n._zod).check??(a.check=()=>{})}),zQt=Jn("$ZodCheckRegex",(n,t)=>{dq.init(n,t),n._zod.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:n,continue:!t.abort})}}),_Qt=Jn("$ZodCheckLowerCase",(n,t)=>{t.pattern??(t.pattern=SQt),dq.init(n,t)}),PQt=Jn("$ZodCheckUpperCase",(n,t)=>{t.pattern??(t.pattern=BQt),dq.init(n,t)}),jQt=Jn("$ZodCheckIncludes",(n,t)=>{lp.init(n,t);let r=Fw(t.includes),a=new RegExp(typeof t.position=="number"?`^.{${t.position}}${r}`:r);t.pattern=a,n._zod.onattach.push(i=>{let s=i._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(a)}),n._zod.check=i=>{i.value.includes(t.includes,t.position)||i.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:i.value,inst:n,continue:!t.abort})}}),KQt=Jn("$ZodCheckStartsWith",(n,t)=>{lp.init(n,t);let r=new RegExp(`^${Fw(t.prefix)}.*`);t.pattern??(t.pattern=r),n._zod.onattach.push(a=>{let i=a._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(r)}),n._zod.check=a=>{a.value.startsWith(t.prefix)||a.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:a.value,inst:n,continue:!t.abort})}}),qQt=Jn("$ZodCheckEndsWith",(n,t)=>{lp.init(n,t);let r=new RegExp(`.*${Fw(t.suffix)}$`);t.pattern??(t.pattern=r),n._zod.onattach.push(a=>{let i=a._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(r)}),n._zod.check=a=>{a.value.endsWith(t.suffix)||a.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:a.value,inst:n,continue:!t.abort})}}),$Qt=Jn("$ZodCheckOverwrite",(n,t)=>{lp.init(n,t),n._zod.check=r=>{r.value=t.tx(r.value)}})});var xme,YSe=ut(()=>{xme=class{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}let a=t.split(`
|
|
667
667
|
`).filter(e=>e),i=Math.min(...a.map(e=>e.length-e.trimStart().length)),s=a.map(e=>e.slice(i)).map(e=>" ".repeat(this.indent*2)+e);for(let e of s)this.content.push(e)}compile(){let t=Function,r=this?.args,i=[...(this?.content??[""]).map(s=>` ${s}`)];return new t(...r,i.join(`
|
|
668
668
|
`))}}});var t9t,xSe=ut(()=>{t9t={major:4,minor:0,patch:0}});function C9t(n){if(n==="")return!0;if(n.length%4!==0)return!1;try{return atob(n),!0}catch{return!1}}function wWr(n){if(!RSe.test(n))return!1;let t=n.replace(/[-_]/g,a=>a==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return C9t(r)}function CWr(n,t=null){try{let r=n.split(".");if(r.length!==3)return!1;let[a]=r;if(!a)return!1;let i=JSON.parse(atob(a));return!("typ"in i&&i?.typ!=="JWT"||!i.alg||t&&(!("alg"in i)||i.alg!==t))}catch{return!1}}function n9t(n,t,r){n.issues.length&&t.issues.push(...kW(r,n.issues)),t.value[r]=n.value}function Vme(n,t,r){n.issues.length&&t.issues.push(...kW(r,n.issues)),t.value[r]=n.value}function r9t(n,t,r,a){n.issues.length?a[r]===void 0?r in a?t.value[r]=void 0:t.value[r]=n.value:t.issues.push(...kW(r,n.issues)):n.value===void 0?r in a&&(t.value[r]=void 0):t.value[r]=n.value}function a9t(n,t,r,a){for(let i of n)if(i.issues.length===0)return t.value=i.value,t;return t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:n.map(i=>i.issues.map(s=>HN(s,a,e1())))}),t}function VSe(n,t){if(n===t)return{valid:!0,data:n};if(n instanceof Date&&t instanceof Date&&+n==+t)return{valid:!0,data:n};if(FJ(n)&&FJ(t)){let r=Object.keys(t),a=Object.keys(n).filter(s=>r.indexOf(s)!==-1),i={...n,...t};for(let s of a){let e=VSe(n[s],t[s]);if(!e.valid)return{valid:!1,mergeErrorPath:[s,...e.mergeErrorPath]};i[s]=e.data}return{valid:!0,data:i}}if(Array.isArray(n)&&Array.isArray(t)){if(n.length!==t.length)return{valid:!1,mergeErrorPath:[]};let r=[];for(let a=0;a<n.length;a++){let i=n[a],s=t[a],e=VSe(i,s);if(!e.valid)return{valid:!1,mergeErrorPath:[a,...e.mergeErrorPath]};r.push(e.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function i9t(n,t,r){if(t.issues.length&&n.issues.push(...t.issues),r.issues.length&&n.issues.push(...r.issues),e9(n))return n;let a=VSe(t.value,r.value);if(!a.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(a.mergeErrorPath)}`);return n.value=a.data,n}function l9t(n,t){return n.value===void 0&&(n.value=t.defaultValue),n}function s9t(n,t){return!n.issues.length&&n.value===void 0&&n.issues.push({code:"invalid_type",expected:"nonoptional",input:n.value,inst:t}),n}function o9t(n,t,r){return e9(n)?n:t.out._zod.run({value:n.value,issues:n.issues},r)}function c9t(n){return n.value=Object.freeze(n.value),n}function u9t(n,t,r,a){if(!n){let i={code:"custom",input:r,inst:a,path:[...a._zod.def.path??[]],continue:!a._zod.def.abort};a._zod.def.params&&(i.params=a._zod.def.params),t.issues.push(gSe(i))}}var Qo,Qme,Uc,I9t,d9t,h9t,m9t,p9t,b9t,f9t,G9t,g9t,v9t,Z9t,N9t,A9t,W9t,y9t,F9t,E9t,R9t,w9t,Y9t,x9t,V9t,Q9t,QSe,H9t,X9t,k9t,L9t,S9t,B9t,J9t,T9t,D9t,O9t,HSe,U9t,M9t,z9t,_9t,P9t,j9t,K9t,q9t,$9t,eHt,tHt,nHt,rHt,aHt,iHt,lHt=ut(()=>{Yme();WJ();YSe();FSe();Cme();J5();xSe();J5();Qo=Jn("$ZodType",(n,t)=>{var r;n??(n={}),n._zod.def=t,n._zod.bag=n._zod.bag||{},n._zod.version=t9t;let a=[...n._zod.def.checks??[]];n._zod.traits.has("$ZodCheck")&&a.unshift(n);for(let i of a)for(let s of i._zod.onattach)s(n);if(a.length===0)(r=n._zod).deferred??(r.deferred=[]),n._zod.deferred?.push(()=>{n._zod.run=n._zod.parse});else{let i=(s,e,o)=>{let u=e9(s),d;for(let I of e){if(I._zod.def.when){if(!I._zod.def.when(s))continue}else if(u)continue;let h=s.issues.length,c=I._zod.check(s);if(c instanceof Promise&&o?.async===!1)throw new B5;if(d||c instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await c,s.issues.length!==h&&(u||(u=e9(s,h)))});else{if(s.issues.length===h)continue;u||(u=e9(s,h))}}return d?d.then(()=>s):s};n._zod.run=(s,e)=>{let o=n._zod.parse(s,e);if(o instanceof Promise){if(e.async===!1)throw new B5;return o.then(u=>i(u,a,e))}return i(o,a,e)}}n["~standard"]={validate:i=>{try{let s=Iq(n,i);return s.success?{value:s.data}:{issues:s.error?.issues}}catch{return Rme(n,i).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:"zod",version:1}}),Qme=Jn("$ZodString",(n,t)=>{Qo.init(n,t),n._zod.pattern=[...n?._zod.bag?.patterns??[]].pop()??VQt(n._zod.bag),n._zod.parse=(r,a)=>{if(t.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:n}),r}}),Uc=Jn("$ZodStringFormat",(n,t)=>{dq.init(n,t),Qme.init(n,t)}),I9t=Jn("$ZodGUID",(n,t)=>{t.pattern??(t.pattern=GQt),Uc.init(n,t)}),d9t=Jn("$ZodUUID",(n,t)=>{if(t.version){let a={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(a===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=ESe(a))}else t.pattern??(t.pattern=ESe());Uc.init(n,t)}),h9t=Jn("$ZodEmail",(n,t)=>{t.pattern??(t.pattern=gQt),Uc.init(n,t)}),m9t=Jn("$ZodURL",(n,t)=>{Uc.init(n,t),n._zod.check=r=>{try{let a=r.value,i=new URL(a),s=i.href;t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:FQt.source,input:r.value,inst:n,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(":")?i.protocol.slice(0,-1):i.protocol)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:n,continue:!t.abort})),!a.endsWith("/")&&s.endsWith("/")?r.value=s.slice(0,-1):r.value=s;return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:n,continue:!t.abort})}}}),p9t=Jn("$ZodEmoji",(n,t)=>{t.pattern??(t.pattern=vQt()),Uc.init(n,t)}),b9t=Jn("$ZodNanoID",(n,t)=>{t.pattern??(t.pattern=bQt),Uc.init(n,t)}),f9t=Jn("$ZodCUID",(n,t)=>{t.pattern??(t.pattern=IQt),Uc.init(n,t)}),G9t=Jn("$ZodCUID2",(n,t)=>{t.pattern??(t.pattern=dQt),Uc.init(n,t)}),g9t=Jn("$ZodULID",(n,t)=>{t.pattern??(t.pattern=hQt),Uc.init(n,t)}),v9t=Jn("$ZodXID",(n,t)=>{t.pattern??(t.pattern=mQt),Uc.init(n,t)}),Z9t=Jn("$ZodKSUID",(n,t)=>{t.pattern??(t.pattern=pQt),Uc.init(n,t)}),N9t=Jn("$ZodISODateTime",(n,t)=>{t.pattern??(t.pattern=xQt(t)),Uc.init(n,t)}),A9t=Jn("$ZodISODate",(n,t)=>{t.pattern??(t.pattern=wQt),Uc.init(n,t)}),W9t=Jn("$ZodISOTime",(n,t)=>{t.pattern??(t.pattern=YQt(t)),Uc.init(n,t)}),y9t=Jn("$ZodISODuration",(n,t)=>{t.pattern??(t.pattern=fQt),Uc.init(n,t)}),F9t=Jn("$ZodIPv4",(n,t)=>{t.pattern??(t.pattern=ZQt),Uc.init(n,t),n._zod.onattach.push(r=>{let a=r._zod.bag;a.format="ipv4"})}),E9t=Jn("$ZodIPv6",(n,t)=>{t.pattern??(t.pattern=NQt),Uc.init(n,t),n._zod.onattach.push(r=>{let a=r._zod.bag;a.format="ipv6"}),n._zod.check=r=>{try{new URL(`http://[${r.value}]`)}catch{r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:n,continue:!t.abort})}}}),R9t=Jn("$ZodCIDRv4",(n,t)=>{t.pattern??(t.pattern=AQt),Uc.init(n,t)}),w9t=Jn("$ZodCIDRv6",(n,t)=>{t.pattern??(t.pattern=WQt),Uc.init(n,t),n._zod.check=r=>{let[a,i]=r.value.split("/");try{if(!i)throw new Error;let s=Number(i);if(`${s}`!==i)throw new Error;if(s<0||s>128)throw new Error;new URL(`http://[${a}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:n,continue:!t.abort})}}});Y9t=Jn("$ZodBase64",(n,t)=>{t.pattern??(t.pattern=yQt),Uc.init(n,t),n._zod.onattach.push(r=>{r._zod.bag.contentEncoding="base64"}),n._zod.check=r=>{C9t(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:n,continue:!t.abort})}});x9t=Jn("$ZodBase64URL",(n,t)=>{t.pattern??(t.pattern=RSe),Uc.init(n,t),n._zod.onattach.push(r=>{r._zod.bag.contentEncoding="base64url"}),n._zod.check=r=>{wWr(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:n,continue:!t.abort})}}),V9t=Jn("$ZodE164",(n,t)=>{t.pattern??(t.pattern=EQt),Uc.init(n,t)});Q9t=Jn("$ZodJWT",(n,t)=>{Uc.init(n,t),n._zod.check=r=>{CWr(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:n,continue:!t.abort})}}),QSe=Jn("$ZodNumber",(n,t)=>{Qo.init(n,t),n._zod.pattern=n._zod.bag.pattern??XQt,n._zod.parse=(r,a)=>{if(t.coerce)try{r.value=Number(r.value)}catch{}let i=r.value;if(typeof i=="number"&&!Number.isNaN(i)&&Number.isFinite(i))return r;let s=typeof i=="number"?Number.isNaN(i)?"NaN":Number.isFinite(i)?void 0:"Infinity":void 0;return r.issues.push({expected:"number",code:"invalid_type",input:i,inst:n,...s?{received:s}:{}}),r}}),H9t=Jn("$ZodNumber",(n,t)=>{DQt.init(n,t),QSe.init(n,t)}),X9t=Jn("$ZodBoolean",(n,t)=>{Qo.init(n,t),n._zod.pattern=kQt,n._zod.parse=(r,a)=>{if(t.coerce)try{r.value=!!r.value}catch{}let i=r.value;return typeof i=="boolean"||r.issues.push({expected:"boolean",code:"invalid_type",input:i,inst:n}),r}}),k9t=Jn("$ZodBigInt",(n,t)=>{Qo.init(n,t),n._zod.pattern=QQt,n._zod.parse=(r,a)=>{if(t.coerce)try{r.value=BigInt(r.value)}catch{}return typeof r.value=="bigint"||r.issues.push({expected:"bigint",code:"invalid_type",input:r.value,inst:n}),r}}),L9t=Jn("$ZodNull",(n,t)=>{Qo.init(n,t),n._zod.pattern=LQt,n._zod.values=new Set([null]),n._zod.parse=(r,a)=>{let i=r.value;return i===null||r.issues.push({expected:"null",code:"invalid_type",input:i,inst:n}),r}}),S9t=Jn("$ZodAny",(n,t)=>{Qo.init(n,t),n._zod.parse=r=>r}),B9t=Jn("$ZodUnknown",(n,t)=>{Qo.init(n,t),n._zod.parse=r=>r}),J9t=Jn("$ZodNever",(n,t)=>{Qo.init(n,t),n._zod.parse=(r,a)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:n}),r)}),T9t=Jn("$ZodDate",(n,t)=>{Qo.init(n,t),n._zod.parse=(r,a)=>{if(t.coerce)try{r.value=new Date(r.value)}catch{}let i=r.value,s=i instanceof Date;return s&&!Number.isNaN(i.getTime())||r.issues.push({expected:"date",code:"invalid_type",input:i,...s?{received:"Invalid Date"}:{},inst:n}),r}});D9t=Jn("$ZodArray",(n,t)=>{Qo.init(n,t),n._zod.parse=(r,a)=>{let i=r.value;if(!Array.isArray(i))return r.issues.push({expected:"array",code:"invalid_type",input:i,inst:n}),r;r.value=Array(i.length);let s=[];for(let e=0;e<i.length;e++){let o=i[e],u=t.element._zod.run({value:o,issues:[]},a);u instanceof Promise?s.push(u.then(d=>n9t(d,r,e))):n9t(u,r,e)}return s.length?Promise.all(s).then(()=>r):r}});O9t=Jn("$ZodObject",(n,t)=>{Qo.init(n,t);let r=sq(()=>{let h=Object.keys(t.shape);for(let G of h)if(!(t.shape[G]instanceof Qo))throw new Error(`Invalid element at key "${G}": expected a Zod schema`);let c=fSe(t.shape);return{shape:t.shape,keys:h,keySet:new Set(h),numKeys:h.length,optionalKeys:new Set(c)}});Wc(n._zod,"propValues",()=>{let h=t.shape,c={};for(let G in h){let W=h[G]._zod;if(W.values){c[G]??(c[G]=new Set);for(let y of W.values)c[G].add(y)}}return c});let a=h=>{let c=new xme(["shape","payload","ctx"]),G=r.value,W=w=>{let A=$Q(w);return`shape[${A}]._zod.run({ value: input[${A}], issues: [] }, ctx)`};c.write("const input = payload.value;");let y=Object.create(null),R=0;for(let w of G.keys)y[w]=`key_${R++}`;c.write("const newResult = {}");for(let w of G.keys)if(G.optionalKeys.has(w)){let A=y[w];c.write(`const ${A} = ${W(w)};`);let E=$Q(w);c.write(`
|
|
669
669
|
if (${A}.issues.length) {
|
|
@@ -2838,14 +2838,14 @@ Example: To read a file, search for a pattern, and list files:
|
|
|
2838
2838
|
{"tool": "read_file", "parameters": {"absolute_path": "/path/to/file.ts"}},
|
|
2839
2839
|
{"tool": "search_file_content", "parameters": {"pattern": "TODO", "path": "/src"}},
|
|
2840
2840
|
{"tool": "glob", "parameters": {"pattern": "**/*.ts"}}
|
|
2841
|
-
]`,ea.Tasks,{properties:{tool_calls:{type:Gn.ARRAY,items:{type:Gn.OBJECT,properties:{tool:{type:Gn.STRING,description:"The name of the tool to execute."},parameters:{type:Gn.OBJECT,description:"Parameters for the tool."}},required:["tool","parameters"]},description:"Array of tool calls to execute."}},required:["tool_calls"],type:Gn.OBJECT}),this.config=t}validateToolParams(t){let r=Ki.validate(this.schema.parameters,t,n.Name);return r||(!t.tool_calls||t.tool_calls.length===0?"At least one tool call is required.":t.tool_calls.length>20?"Maximum 20 tool calls allowed in batch.":null)}getDescription(t){if(!t.tool_calls||t.tool_calls.length===0)return"No tools";let r=t.tool_calls.length,
|
|
2842
|
-
${
|
|
2843
|
-
${
|
|
2841
|
+
]`,ea.Tasks,{properties:{tool_calls:{type:Gn.ARRAY,items:{type:Gn.OBJECT,properties:{tool:{type:Gn.STRING,description:"The name of the tool to execute."},parameters:{type:Gn.OBJECT,description:"Parameters for the tool."}},required:["tool","parameters"]},description:"Array of tool calls to execute."}},required:["tool_calls"],type:Gn.OBJECT}),this.config=t}validateToolParams(t){let r=Ki.validate(this.schema.parameters,t,n.Name);return r||(!t.tool_calls||t.tool_calls.length===0?"At least one tool call is required.":t.tool_calls.length>20?"Maximum 20 tool calls allowed in batch.":null)}normalizeToolCalls(t){return Array.isArray(t)?t.map(r=>{let a=r;if(typeof r=="string")try{a=JSON.parse(r)}catch{return console.warn("[BatchTool] Failed to parse stringified tool call:",r),{tool:"unknown",parameters:{}}}if(!a||typeof a!="object")return{tool:"unknown",parameters:{}};let i=a.tool||a.name||a.function||a.tool_name||"unknown",s=a.parameters||a.args||a.arguments||{};return{tool:i,parameters:s}}):[]}getDescription(t){if(!t.tool_calls||t.tool_calls.length===0)return"No tools";let r=this.normalizeToolCalls(t.tool_calls),a=r.length,i=r.map(o=>o.tool).join(", "),s=60,e=i.length>s?i.substring(0,s-3)+"...":i;return`${a} tool${a>1?"s":""}: ${e}`}async execute(t,r,a,i){let s=await this.config.getToolRegistry(),e=[],o=this.normalizeToolCalls(t.tool_calls);for(let I of o){if(r.aborted)break;let h=I.tool;if(!h||h==="unknown"){console.warn("[BatchTool] Missing tool name in call:",I),e.push({tool:"unknown",success:!1,error:"Missing or invalid tool name in batch call."});continue}if(h==="batch"){e.push({tool:h,success:!1,error:"Cannot nest batch calls."});continue}let c=s.getTool(h);if(!c){e.push({tool:h,success:!1,error:`Tool ${h} not found.`});continue}if(i?.onPreToolExecution)try{await i.onPreToolExecution({callId:`batch-sub-${Date.now()}-${Math.random().toString(16).slice(2)}`,tool:c,args:I.parameters})}catch(G){console.warn(`[BatchTool] Pre-execution hook failed for ${I.tool}:`,G)}try{let G=await c.execute(I.parameters,r,a,i),W=typeof G.llmContent=="string"?G.llmContent:JSON.stringify(G.llmContent);e.push({tool:I.tool,success:!0,result:W})}catch(G){let W=G instanceof Error?G.message:String(G);e.push({tool:I.tool,success:!1,error:W})}}let u=e.filter(I=>I.success).length,d=e.map(I=>I.success?`[${I.tool}]: Success
|
|
2842
|
+
${I.result}`:`[${I.tool}]: Failed
|
|
2843
|
+
${I.error}`).join(`
|
|
2844
2844
|
|
|
2845
2845
|
---
|
|
2846
2846
|
|
|
2847
|
-
`);return{llmContent:`Batch execution: ${
|
|
2848
|
-
${
|
|
2847
|
+
`);return{llmContent:`Batch execution: ${u}/${e.length} succeeded.
|
|
2848
|
+
${d}`,returnDisplay:`Executed ${e.length} tools. ${u} succeeded.`}}}});import*as _2n from"fs/promises";import*as Yy from"path";async function tma(n,t){let a={name:Yy.basename(n),path:n,files:[],subFolders:[],totalChildren:0,totalFiles:0},i=[{folderInfo:a,currentPath:n}],s=0,e=new Set;for(;i.length>0;){let{folderInfo:o,currentPath:u}=i.shift();if(e.has(u)||(e.add(u),s>=t.maxItems))continue;let d;try{d=(await _2n.readdir(u,{withFileTypes:!0})).sort((G,W)=>G.name.localeCompare(W.name))}catch(c){if(Yo(c)&&(c.code==="EACCES"||c.code==="ENOENT")){if(console.warn(`Warning: Could not read directory ${u}: ${c.message}`),u===n&&c.code==="ENOENT")return null;continue}throw c}let I=[],h=[];for(let c of d)if(c.isFile()){if(s>=t.maxItems){o.hasMoreFiles=!0;break}let G=c.name,W=Yy.join(u,G);if(t.fileService&&(t.fileFilteringOptions.respectGitIgnore&&t.fileService.shouldGitIgnoreFile(W)||t.fileFilteringOptions.respectGeminiIgnore&&t.fileService.shouldGeminiIgnoreFile(W)))continue;(!t.fileIncludePattern||t.fileIncludePattern.test(G))&&(I.push(G),s++,o.totalFiles++,o.totalChildren++)}o.files=I;for(let c of d)if(c.isDirectory()){if(s>=t.maxItems){o.hasMoreSubfolders=!0;break}let G=c.name,W=Yy.join(u,G),y=!1;if(t.fileService&&(y=t.fileFilteringOptions.respectGitIgnore&&t.fileService.shouldGitIgnoreFile(W)||t.fileFilteringOptions.respectGeminiIgnore&&t.fileService.shouldGeminiIgnoreFile(W)),t.ignoredFolders.has(G)||y){let F={name:G,path:W,files:[],subFolders:[],totalChildren:0,totalFiles:0,isIgnored:!0};h.push(F),s++,o.totalChildren++;continue}let R={name:G,path:W,files:[],subFolders:[],totalChildren:0,totalFiles:0};h.push(R),s++,o.totalChildren++,i.push({folderInfo:R,currentPath:W})}o.subFolders=h}return a}function P2n(n,t,r,a,i){let s=r?"\u2514\u2500\u2500\u2500":"\u251C\u2500\u2500\u2500";(!a||n.isIgnored)&&i.push(`${t}${s}${n.name}${Yy.sep}${n.isIgnored?CNe:""}`);let e=a?"":t+(r?" ":"\u2502 "),o=n.files.length;for(let d=0;d<o;d++){let h=d===o-1&&n.subFolders.length===0&&!n.hasMoreSubfolders?"\u2514\u2500\u2500\u2500":"\u251C\u2500\u2500\u2500";i.push(`${e}${h}${n.files[d]}`)}if(n.hasMoreFiles){let I=n.subFolders.length===0&&!n.hasMoreSubfolders?"\u2514\u2500\u2500\u2500":"\u251C\u2500\u2500\u2500";i.push(`${e}${I}${CNe}`)}let u=n.subFolders.length;for(let d=0;d<u;d++){let I=d===u-1&&!n.hasMoreSubfolders;P2n(n.subFolders[d],e,I,!1,i)}n.hasMoreSubfolders&&i.push(`${e}\u2514\u2500\u2500\u2500${CNe}`)}async function _nt(n,t){let r=Yy.resolve(n),a={maxItems:t?.maxItems??$ha,ignoredFolders:t?.ignoredFolders??ema,fileIncludePattern:t?.fileIncludePattern,fileService:t?.fileService,fileFilteringOptions:t?.fileFilteringOptions??_E};try{let o=function(d){if(d.hasMoreFiles||d.hasMoreSubfolders||d.isIgnored)return!0;for(let I of d.subFolders)if(o(I))return!0;return!1};var i=o;let s=await tma(r,a);if(!s)return`Error: Could not read directory "${r}". Check path and permissions.`;let e=[];P2n(s,"",!0,!0,e);let u=`Showing up to ${a.maxItems} items (files + folders).`;return o(s)&&(u+=` Folders or files indicated with ${CNe} contain more items not shown, were ignored, or the display limit (${a.maxItems} items) was reached.`),`${u}
|
|
2849
2849
|
|
|
2850
2850
|
${r}${Yy.sep}
|
|
2851
2851
|
${e.join(`
|
|
@@ -4263,7 +4263,7 @@ _Tip: Press Esc to exit \u2022 Uses tokens \u2022 For command list, use /help in
|
|
|
4263
4263
|
`,a);if(i===-1)break;let s=i+2;if(!Z6n(n,s)&&!N6n(n,s))return s;a=i-1}return n.length};function W6n(n){let t=n.toLowerCase().trim();return t.includes("[plan mode active]")||t.includes("plan mode active")||/\bplan\s+mode\s+active\b/.test(t)?{modeChanged:!0,newMode:!0,source:"message"}:t.includes("[plan mode exited]")||t.includes("plan mode exited")||/plan\s+mode\s+exited/.test(t)?{modeChanged:!0,newMode:!1,source:"message"}:{modeChanged:!1,newMode:!1,source:"unknown"}}oF();var VRe=Qt(er(),1);var QRe=n=>{let[t,r]=VRe.default.useState(n),a=VRe.default.useRef(n),i=VRe.default.useCallback(s=>{let e;typeof s=="function"?e=s(a.current):e=s,r(e),a.current=e},[]);return[a,i]};var HRe=Qt(er(),1);pr();var XRe=()=>{let[n,t]=(0,HRe.useState)(null);return(0,HRe.useEffect)(()=>{let r=new $k(bx());r.initialize().then(()=>{t(r)}).catch(()=>{})},[]),n};import oLn from"path";import{spawn as DLa}from"child_process";import*as fx from"path";import*as q6n from"fs";import{fileURLToPath as K6n}from"url";var kRe=(a=>(a.RESPONSE_COMPLETE="response-complete",a.CONFIRMATION_REQUIRED="confirmation-required",a.SELECTION_MADE="selection-made",a))(kRe||{}),i3=class{static settings={enabled:!0,responseComplete:!0,confirmationRequired:!0,selectionMade:!0};static initialized=!1;static configure(t){this.settings={...this.settings,...t},this.initialized=!0}static initializeFromSettings(t){if(this.initialized)return;let r=t?.audioNotifications;r&&this.configure({enabled:r.enabled??!0,responseComplete:r.responseComplete??!0,confirmationRequired:r.confirmationRequired??!0,selectionMade:r.selectionMade??!0})}static setEnabled(t){this.settings.enabled=t}static async play(t){if(this.settings.enabled){switch(t){case"response-complete":if(!this.settings.responseComplete)return;break;case"confirmation-required":if(!this.settings.confirmationRequired)return;break;case"selection-made":if(!this.settings.selectionMade)return;break}try{await this.playCustomSound(t)}catch(r){console.debug("[AudioNotification] Custom sound failed, trying system command:",r),await this.playWithSystemCommand(t)}}}static async playCustomSound(t){let r=this.getSoundFile(t);if(!q6n.existsSync(r))throw console.debug(`[AudioNotification] Sound file not found: ${r}`),new Error(`Sound file not found: ${r}`);let a=process.platform;try{switch(a){case"win32":await this.executeCommand("powershell",["-c",`(New-Object Media.SoundPlayer "${r}").PlaySync()`]);break;case"darwin":await this.executeCommand("afplay",[r]);break;case"linux":try{await this.executeCommand("paplay",[r])}catch{try{await this.executeCommand("aplay",[r])}catch{await this.executeCommand("ffplay",["-nodisp","-autoexit",r])}}break;default:throw new Error(`Unsupported platform: ${a}`)}}catch(i){throw new Error(`Custom sound playback failed: ${i}`)}}static async playWithSystemCommand(t){let r=process.platform;try{switch(r){case"win32":let a=this.getSoundFrequency(t);await this.executeCommand("powershell",["-c",`[console]::beep(${a},200)`]);break;case"darwin":let i=this.getMacSystemSound(t);await this.executeCommand("afplay",[i]);break;case"linux":let s=this.getLinuxSystemSound(t);try{await this.executeCommand("paplay",[s])}catch{try{await this.executeCommand("aplay",[s])}catch{let e=this.getSoundFrequency(t);await this.executeCommand("speaker-test",["-t","sine","-f",e.toString(),"-l","1","-s","1"])}}break;default:console.debug(`[AudioNotification] Unsupported platform: ${r}`)}}catch(a){console.debug("[AudioNotification] System command failed:",a)}}static getSoundFrequency(t){switch(t){case"response-complete":return 800;case"confirmation-required":return 1e3;case"selection-made":return 600;default:return 800}}static getMacSystemSound(t){switch(t){case"response-complete":return"/System/Library/Sounds/Glass.aiff";case"confirmation-required":return"/System/Library/Sounds/Ping.aiff";case"selection-made":return"/System/Library/Sounds/Pop.aiff";default:return"/System/Library/Sounds/Glass.aiff"}}static getLinuxSystemSound(t){switch(t){case"response-complete":return"/usr/share/sounds/alsa/Front_Left.wav";case"confirmation-required":return"/usr/share/sounds/alsa/Front_Right.wav";case"selection-made":return"/usr/share/sounds/alsa/Front_Center.wav";default:return"/usr/share/sounds/alsa/Front_Left.wav"}}static executeCommand(t,r){return new Promise((a,i)=>{let s=DLa(t,r,{stdio:"ignore",timeout:2e3});s.on("close",e=>{this.restoreCliTitle(),a()}),s.on("error",i)})}static restoreCliTitle(){try{if($6n(),process.env.CLI_TITLE){let t=process.env.CLI_TITLE.replace(/[\x00-\x1F\x7F]/g,"");process.stdout.write(`\x1B]2;${t}\x07`)}}catch(t){console.debug("[AudioNotification] Failed to restore CLI title:",t)}}static getSoundFile(t){let r=fx.dirname(K6n(import.meta.url)),s=fx.basename(K6n(import.meta.url))==="dvcode.js"?fx.join(r,"assets/sounds"):fx.join(r,"../assets/sounds");return fx.join(s,`${t}.wav`)}static async test(){console.log("Testing audio notifications...");for(let t of Object.values(kRe))console.log(`Playing ${t}...`),await this.play(t),await new Promise(r=>setTimeout(r,1e3));console.log("Audio test completed.")}};pr();var l3=Qt(er(),1);mr();function tLn(n,t,r,a,i){let[s,e]=(0,l3.useState)([]),o=(0,l3.useCallback)((W,y)=>{let R=hme(y),F=(w,A)=>{r(E=>E?.type==="tool_group"?{...E,tools:E.tools.map(f=>f.callId===W&&f.status==="Executing"?{...f,resultDisplay:w}:f)}:E),e(E=>E.map(f=>f.request.callId===W&&f.status==="executing"?{...f,liveOutput:A??w,...typeof w=="object"&&w.type?{liveOutputType:w.type}:{}}:f))};if(mme(R)){let w=R.data;F(w,JSON.stringify(w))}else if(pme(R)){let w=R.data;F(w)}else F(y)},[r]),u=(0,l3.useCallback)(W=>{n(W)},[n]),d=(0,l3.useCallback)(W=>{console.log("[useReactToolScheduler] tool calls updated: prev=%d new=%d",s.length,W.length),console.log("[useReactToolScheduler] Updated statuses:",W.map(y=>({id:y.request.callId.slice(-8),status:y.status}))),e(y=>W.map(R=>{let F=y.find(A=>A.request.callId===R.request.callId);return{...R,responseSubmittedToGemini:F?.responseSubmittedToGemini??!1}}))},[e,s]),I=(0,l3.useMemo)(()=>new bX({toolRegistry:t.getToolRegistry(),outputUpdateHandler:o,onAllToolCallsComplete:u,onToolCallsUpdate:d,onPreToolExecution:i,approvalMode:t.getApprovalMode(),getPreferredEditor:a,config:t,hookEventHandler:t.getHookSystem().getEventHandler()}),[t,o,u,d,i,a]),h=(0,l3.useCallback)((W,y)=>{let R=Array.isArray(W)?W:[W];if(t.getPlanModeActive()){let F=new Set(["read_file","read_many_files","list_directory","search_file_content","glob","read_lints","web_fetch","google_web_search","task","todo_write","save_memory"]),w=R.filter(E=>F.has(E.name)),A=R.filter(E=>!F.has(E.name));if(A.length>0){let E=A.map(f=>f.name).join(", ");r({type:"info",text:`${jt("plan.mode.blocked.tools",{tools:E})}
|
|
4264
4264
|
${He("plan.mode.focus.message")}
|
|
4265
4265
|
${He("plan.mode.available.tools")}
|
|
4266
|
-
${He("plan.mode.exit.instruction")}`})}w.length>0&&I.schedule(w,y);return}I.schedule(W,y)},[I,t,r]),c=(0,l3.useCallback)(W=>{e(y=>y.map(R=>W.includes(R.request.callId)?{...R,responseSubmittedToGemini:!0}:R))},[]),G=(0,l3.useCallback)(async(W,y,R)=>{await I.handleConfirmationResponse(W,y,R)},[I]);return[s,h,c,G]}function OLa(n,t){switch(n){case"validating":return"Executing";case"awaiting_approval":return"Confirming";case"executing":return t==="task"?"SubAgentRunning":"Executing";case"success":return"Success";case"cancelled":return"Canceled";case"error":return"Error";case"scheduled":return"Pending";default:return console.warn(`Unknown core status encountered: ${n}`),"Error"}}function ULa(n){let t=[];function r(a){a.forEach(i=>{t.push(i),i.subToolCalls&&r(i.subToolCalls)})}return r(n),t}function MLa(n,t){switch(n){case"read_file":return gz(t.absolute_path);case"read_many_files":let r=t.paths;return r&&r.length>0?r.length===1?gz(r[0]):`${r.length} files`:"";case"write_file":return gz(t.file_path);case"replace":case"multiedit":return gz(t.file_path);case"delete_file":return gz(t.file_path);case"run_shell_command":let a=t.command;return a?a.length>30?a.substring(0,27)+"...":a:"";case"search_file_content":let i=t.pattern;return i?`"${i.substring(0,20)}${i.length>20?"...":""}"`:"";case"glob":return t.pattern||"";case"list_directory":return gz(t.path);case"web_fetch":let e=t.prompt?.match(/https?:\/\/[^\s]+/);return e?e[0].substring(0,40):"";case"google_web_search":return t.query?.substring(0,30)||"";default:return""}}function gz(n){if(!n)return"";let t=n.replace(/\\/g,"/").split("/"),r=t[t.length-1];return r.length>40?r.substring(0,37)+"...":r}var zLa={read_file:"ReadFile",read_many_files:"ReadManyFiles",write_file:"WriteFile",replace:"Edit",multiedit:"MultiEdit",delete_file:"DeleteFile",run_shell_command:"Shell",search_file_content:"SearchText",glob:"FindFiles",list_directory:"ReadFolder",web_fetch:"WebFetch",google_web_search:"WebSearch",save_memory:"SaveMemory",task:"Task",todo_write:"TodoWrite",lsp:"LSP",read_lints:"ReadLints",lint_fix:"LintFix",batch:"Batch",codesearch:"CodeSearch"};function _La(n){return zLa[n]||n}function PLa(n){let t=n.request.name,r="",a=!1,i=!1,s,e="tool"in n&&n.tool?n.tool:void 0;if(e?(t=e.displayName,r=e.getDescription(n.request.args),a=e.isOutputMarkdown,i=e.forceMarkdown):"request"in n&&"args"in n.request&&(r=JSON.stringify(n.request.args)),n.request.name==="batch"){let u=n.request.args;u.tool_calls&&Array.isArray(u.tool_calls)&&(s=u.tool_calls.map(d=>({tool:d.tool,displayName:_La(
|
|
4266
|
+
${He("plan.mode.exit.instruction")}`})}w.length>0&&I.schedule(w,y);return}I.schedule(W,y)},[I,t,r]),c=(0,l3.useCallback)(W=>{e(y=>y.map(R=>W.includes(R.request.callId)?{...R,responseSubmittedToGemini:!0}:R))},[]),G=(0,l3.useCallback)(async(W,y,R)=>{await I.handleConfirmationResponse(W,y,R)},[I]);return[s,h,c,G]}function OLa(n,t){switch(n){case"validating":return"Executing";case"awaiting_approval":return"Confirming";case"executing":return t==="task"?"SubAgentRunning":"Executing";case"success":return"Success";case"cancelled":return"Canceled";case"error":return"Error";case"scheduled":return"Pending";default:return console.warn(`Unknown core status encountered: ${n}`),"Error"}}function ULa(n){let t=[];function r(a){a.forEach(i=>{t.push(i),i.subToolCalls&&r(i.subToolCalls)})}return r(n),t}function MLa(n,t){switch(n){case"read_file":return gz(t.absolute_path);case"read_many_files":let r=t.paths;return r&&r.length>0?r.length===1?gz(r[0]):`${r.length} files`:"";case"write_file":return gz(t.file_path);case"replace":case"multiedit":return gz(t.file_path);case"delete_file":return gz(t.file_path);case"run_shell_command":let a=t.command;return a?a.length>30?a.substring(0,27)+"...":a:"";case"search_file_content":let i=t.pattern;return i?`"${i.substring(0,20)}${i.length>20?"...":""}"`:"";case"glob":return t.pattern||"";case"list_directory":return gz(t.path);case"web_fetch":let e=t.prompt?.match(/https?:\/\/[^\s]+/);return e?e[0].substring(0,40):"";case"google_web_search":return t.query?.substring(0,30)||"";default:return""}}function gz(n){if(!n)return"";let t=n.replace(/\\/g,"/").split("/"),r=t[t.length-1];return r.length>40?r.substring(0,37)+"...":r}var zLa={read_file:"ReadFile",read_many_files:"ReadManyFiles",write_file:"WriteFile",replace:"Edit",multiedit:"MultiEdit",delete_file:"DeleteFile",run_shell_command:"Shell",search_file_content:"SearchText",glob:"FindFiles",list_directory:"ReadFolder",web_fetch:"WebFetch",google_web_search:"WebSearch",save_memory:"SaveMemory",task:"Task",todo_write:"TodoWrite",lsp:"LSP",read_lints:"ReadLints",lint_fix:"LintFix",batch:"Batch",codesearch:"CodeSearch"};function _La(n){return zLa[n]||n}function PLa(n){let t=n.request.name,r="",a=!1,i=!1,s,e="tool"in n&&n.tool?n.tool:void 0;if(e?(t=e.displayName,r=e.getDescription(n.request.args),a=e.isOutputMarkdown,i=e.forceMarkdown):"request"in n&&"args"in n.request&&(r=JSON.stringify(n.request.args)),n.request.name==="batch"){let u=n.request.args;u.tool_calls&&Array.isArray(u.tool_calls)&&(s=u.tool_calls.map(d=>{let I=d;if(typeof d=="string")try{I=JSON.parse(d)}catch{console.warn("[useReactToolScheduler] Failed to parse stringified tool call:",d),I={tool:"unknown",parameters:{}}}(!I||typeof I!="object")&&(I={tool:"unknown",parameters:{}});let h=I.tool||I.name||I.function||I.tool_name||"Unknown",c=I.parameters||I.args||I.arguments||{};return{tool:h,displayName:_La(h),summary:MLa(h,c)}}))}let o={callId:n.request.callId,name:t,toolId:n.request.name,description:r,renderOutputAsMarkdown:a,forceMarkdown:i,batchSubTools:s};return{displayName:t,description:r,renderOutputAsMarkdown:a,forceMarkdown:i,baseDisplayProperties:o}}function jLa(n){let t=n.liveOutput??void 0,r=n.liveOutputType;if(n.liveOutput&&r)if(typeof n.liveOutput=="string")try{t=JSON.parse(n.liveOutput)}catch(a){console.warn("\u89E3\u6790\u6267\u884C\u4E2D\u7684\u7ED3\u6784\u5316\u6570\u636E\u5931\u8D25:",a),t=n.liveOutput}else t=n.liveOutput;return t}function eLn(n,t){let{baseDisplayProperties:r}=PLa(n),a=OLa(n.status,n.request.name);switch(n.status){case"success":case"error":case"cancelled":{let s=a;if(n.status==="success"){let o=n.response.resultDisplay;typeof o=="string"&&o.includes("Running in background")&&(s="BackgroundRunning")}return{...r,status:s,resultDisplay:n.response.resultDisplay,confirmationDetails:void 0}}case"awaiting_approval":let i=t?.request.callId===n.request.callId;return{...r,status:a,resultDisplay:void 0,confirmationDetails:i?n.confirmationDetails:void 0};case"executing":return{...r,status:a,resultDisplay:jLa(n),confirmationDetails:void 0};case"validating":case"scheduled":return{...r,status:a,resultDisplay:void 0,confirmationDetails:void 0};default:{let s=n;return{callId:s.request.callId,name:"Unknown Tool",toolId:s.request.name,description:"Encountered an unknown tool call state.",status:"Error",resultDisplay:"Unknown tool call state",confirmationDetails:void 0,renderOutputAsMarkdown:!1,forceMarkdown:!1}}}}function Wht(n){let t=Array.isArray(n)?n:[n],a=ULa(t).filter(o=>o.status==="awaiting_approval"),i=null;a.length>0&&(i=a.sort((o,u)=>{let d=o.agentContext?.agentType==="sub"?1:2,I=u.agentContext?.agentType==="sub"?1:2;return d-I})[0]);let s=o=>o.map(u=>{let d=eLn(u,i);return u.subToolCalls&&u.subToolCalls.length>0?{...d,subToolCalls:s(u.subToolCalls)}:d});return{type:"tool_group",tools:t.map(o=>{let u=eLn(o,i);return o.subToolCalls&&o.subToolCalls.length>0?{...u,subToolCalls:s(o.subToolCalls)}:u})}}var $f=Qt(er(),1);pr();var sLn=Qt(Qn(),1);function yht(n){let t=0,r=0,a=0,i=0,s=0,e=0,o=0,u=0,d=0,I=0,h=0;return Object.values(n.models).forEach(c=>{let{subAgents:G}=c;t+=G.api.totalRequests,r+=G.api.totalErrors,a+=G.api.totalLatencyMs,i+=G.tokens.total,s+=G.tokens.prompt,e+=G.tokens.candidates,o+=G.tokens.cached,u+=G.tokens.cacheWrite||0,d+=G.tokens.cacheRead||0,I+=G.tokens.thoughts,h+=G.tokens.tool}),{totalApiCalls:t,totalErrors:r,totalLatencyMs:a,totalTokens:i,promptTokens:s,candidatesTokens:e,cachedTokens:o,cacheWriteTokens:u,cacheReadTokens:d,thoughtsTokens:I,toolTokens:h}}function $La(n){let{metrics:t,subAgentStats:r}=n,a=Object.values(t.models).reduce((G,W)=>G+W.tokens.total,0),i=a+r.totalTokens,s=i>0?r.totalTokens/i*100:0,e=r.totalApiCalls>0,o=Object.values(t.models).reduce((G,W)=>G+(W.tokens.cacheWrite||0),0),u=Object.values(t.models).reduce((G,W)=>G+(W.tokens.cacheRead||0),0),d=o+u>0?u/(o+u)*100:0,I=Object.values(t.models).reduce((G,W)=>G+W.api.totalLatencyMs,0),h=t.tools,c=h.totalDecisions.accept+h.totalDecisions.reject+h.totalDecisions.modify;return{totalApiTime:I,totalToolTime:h.totalDurationMs,agentActiveTime:I+h.totalDurationMs,apiTimePercent:I+h.totalDurationMs>0?I/(I+h.totalDurationMs)*100:0,toolTimePercent:I+h.totalDurationMs>0?h.totalDurationMs/(I+h.totalDurationMs)*100:0,cacheEfficiency:a>0?Object.values(t.models).reduce((G,W)=>G+W.tokens.cached,0)/a*100:0,totalDecisions:c,successRate:h.totalCalls>0?h.totalSuccess/h.totalCalls*100:0,agreementRate:c>0?h.totalDecisions.accept/c*100:0,totalCachedTokens:Object.values(t.models).reduce((G,W)=>G+W.tokens.cached,0),totalPromptTokens:Object.values(t.models).reduce((G,W)=>G+W.tokens.prompt,0),subAgentUsagePercent:s,hasSubAgentActivity:e,totalCacheWrites:o,totalCacheReads:u,cacheHitRate:d}}var iLn=(0,$f.createContext)(void 0),lLn=({children:n})=>{let[t,r]=(0,$f.useState)({sessionStartTime:new Date,metrics:qI.getMetrics(),lastPromptTokenCount:0,promptCount:0,subAgentStats:yht(qI.getMetrics())});(0,$f.useEffect)(()=>{let o=({metrics:u,lastPromptTokenCount:d})=>{r(I=>({...I,metrics:u,lastPromptTokenCount:d,subAgentStats:yht(u)}))};return qI.on("update",o),o({metrics:qI.getMetrics(),lastPromptTokenCount:qI.getLastPromptTokenCount()}),()=>{qI.off("update",o)}},[]);let a=(0,$f.useCallback)(()=>{r(o=>({...o,promptCount:o.promptCount+1}))},[]),i=(0,$f.useCallback)(()=>t.promptCount,[t.promptCount]),s=(0,$f.useCallback)(()=>{r({sessionStartTime:new Date,metrics:qI.getMetrics(),lastPromptTokenCount:0,promptCount:0,subAgentStats:yht(qI.getMetrics())})},[]),e=(0,$f.useMemo)(()=>({stats:t,startNewPrompt:a,getPromptCount:i,computedStats:$La(t),resetStats:s}),[t,a,i,s]);return(0,sLn.jsx)(iLn.Provider,{value:e,children:n})},eG=()=>{let n=(0,$f.useContext)(iLn);if(n===void 0)throw new Error("useSessionStats must be used within a SessionStatsProvider");return n};pr();function eSa(n){let t=n.filter(u=>u.status==="success");if(t.length===0)return"\u6267\u884C\u4E86\u4EE3\u7801\u7F16\u8F91\u64CD\u4F5C";let r=[],a=[],i=[],s=[];for(let u of t){let d=u.request?.name||("tool"in u?u.tool?.name:"")||"\u672A\u77E5\u5DE5\u5177",c=((u.request?.args||{}).file_path||"").split(/[/\\]/).pop()||"";d==="replace"?r.push(c):d==="write_file"?a.push(c):d==="delete_file"?i.push(c):s.push(d)}let e=u=>{let d=u.split(".").pop()?.toLowerCase()||"";return{ts:"TS",tsx:"TSX",js:"JS",jsx:"JSX",py:"Python",java:"Java",cpp:"C++",c:"C",go:"Go",rs:"Rust",md:"MD",json:"JSON",yaml:"YAML",yml:"YAML",html:"HTML",css:"CSS",scss:"SCSS",sql:"SQL"}[d]||d.toUpperCase()},o=[];if(r.length>0)if(r.length===1)o.push(`\u4FEE\u6539${e(r[0])}\u6587\u4EF6${r[0]}`);else{let u=r.map(d=>`${d}`).join(",");o.push(`\u4FEE\u6539${r.length}\u4E2A\u6587\u4EF6(${u})`)}if(a.length>0)if(a.length===1)o.push(`\u521B\u5EFA${e(a[0])}\u6587\u4EF6${a[0]}`);else{let u=a.map(d=>`${d}`).join(",");o.push(`\u521B\u5EFA${a.length}\u4E2A\u6587\u4EF6(${u})`)}return i.length>0&&(i.length===1?o.push(`\u5220\u9664${i[0]}`):o.push(`\u5220\u9664${i.length}\u4E2A\u6587\u4EF6(${i.join(",")})`)),s.length>0&&o.push(`\u6267\u884C${s.join(",")}`),o.join("\uFF0C")}async function cLn(n,t,r){let a=Js()?"Chinese":"English",s=`Extract the core task in "Verb + Noun" format.
|
|
4267
4267
|
Must include the specific project/feature name.
|
|
4268
4268
|
Length limit: Max ${Js()?"8 Chinese characters":"3 English words"}.
|
|
4269
4269
|
CRITICAL: Use the most concise expression and the shortest possible words.
|
|
@@ -4376,7 +4376,7 @@ The DEEPV.md file already exists with content. You MUST follow these steps:
|
|
|
4376
4376
|
`,t-1),[i,s]=XSa(r);return{line:a===-1?i:n.slice(0,a+1).match(/\n/g).length+i,column:t-a-1+s}}function kht(n,t,r){if(typeof n!="string")throw new TypeError("Text parameter should be a string");if(!Number.isInteger(t))throw new TypeError("Index parameter should be an integer");if(t<0||t>n.length)throw new RangeError("Index out of bounds");return kSa(n,t,r)}var LSa=n=>`\\u{${n.codePointAt(0).toString(16)}}`,Lht=class n extends Error{name="JSONError";fileName;#e;#t;#n;#r;#a;constructor(t){if(typeof t=="string")super(),this.#n=t;else{let{jsonParseError:r,fileName:a,input:i}=t;super(void 0,{cause:r}),this.#e=i,this.#t=r,this.fileName=a}Error.captureStackTrace?.(this,n)}get message(){this.#n??=`${BSa(this.#t.message)}${this.#e===""?" while parsing empty string":""}`;let{codeFrame:t}=this;return`${this.#n}${this.fileName?` in ${this.fileName}`:""}${t?`
|
|
4377
4377
|
|
|
4378
4378
|
${t}
|
|
4379
|
-
`:""}`}set message(t){this.#n=t}#i(t){if(!this.#t)return;let r=this.#e,a=SSa(r,this.#t.message);if(a)return(0,GSn.codeFrameColumns)(r,{start:a},{highlightCode:t})}get codeFrame(){return this.#r??=this.#i(!0),this.#r}get rawCodeFrame(){return this.#a??=this.#i(!1),this.#a}},SSa=(n,t)=>{let r=t.match(/in JSON at position (?<index>\d+)(?: \(line (?<line>\d+) column (?<column>\d+)\))?$/);if(!r)return;let{index:a,line:i,column:s}=r.groups;return i&&s?{line:Number(i),column:Number(s)}:kht(n,Number(a),{oneBased:!0})},BSa=n=>n.replace(/(?<=^Unexpected token )(?<quote>')?(.)\k<quote>/,(t,r,a)=>`"${a}"(${LSa(a)})`);function Sht(n,t,r){typeof t=="string"&&(r=t,t=void 0);try{return JSON.parse(n,t)}catch(a){throw new Lht({jsonParseError:a,fileName:r,input:n})}}var pBn=Qt(hBn(),1);import{fileURLToPath as LBa}from"node:url";function mBn(n){return n instanceof URL?LBa(n):n}var JBa=n=>BBa.resolve(mBn(n)??".","package.json"),TBa=(n,t)=>{let r=typeof n=="string"?Sht(n):n;return t&&(0,pBn.default)(r),r};async function bBn({cwd:n,normalize:t=!0}={}){let r=await SBa.readFile(JBa(n),"utf8");return TBa(r,t)}async function fBn(n){let t=await zLn("package.json",n);if(t)return{packageJson:await bBn({...n,cwd:DBa.dirname(t)}),path:t}}import{fileURLToPath as OBa}from"url";import UBa from"path";var MBa=OBa(import.meta.url),zBa=UBa.dirname(MBa),KRe;async function Rz(){if(KRe)return KRe;let n=await fBn({cwd:zBa});if(n)return KRe=n.packageJson,KRe}async function Nx(){let n=await Rz();return"1.0.
|
|
4379
|
+
`:""}`}set message(t){this.#n=t}#i(t){if(!this.#t)return;let r=this.#e,a=SSa(r,this.#t.message);if(a)return(0,GSn.codeFrameColumns)(r,{start:a},{highlightCode:t})}get codeFrame(){return this.#r??=this.#i(!0),this.#r}get rawCodeFrame(){return this.#a??=this.#i(!1),this.#a}},SSa=(n,t)=>{let r=t.match(/in JSON at position (?<index>\d+)(?: \(line (?<line>\d+) column (?<column>\d+)\))?$/);if(!r)return;let{index:a,line:i,column:s}=r.groups;return i&&s?{line:Number(i),column:Number(s)}:kht(n,Number(a),{oneBased:!0})},BSa=n=>n.replace(/(?<=^Unexpected token )(?<quote>')?(.)\k<quote>/,(t,r,a)=>`"${a}"(${LSa(a)})`);function Sht(n,t,r){typeof t=="string"&&(r=t,t=void 0);try{return JSON.parse(n,t)}catch(a){throw new Lht({jsonParseError:a,fileName:r,input:n})}}var pBn=Qt(hBn(),1);import{fileURLToPath as LBa}from"node:url";function mBn(n){return n instanceof URL?LBa(n):n}var JBa=n=>BBa.resolve(mBn(n)??".","package.json"),TBa=(n,t)=>{let r=typeof n=="string"?Sht(n):n;return t&&(0,pBn.default)(r),r};async function bBn({cwd:n,normalize:t=!0}={}){let r=await SBa.readFile(JBa(n),"utf8");return TBa(r,t)}async function fBn(n){let t=await zLn("package.json",n);if(t)return{packageJson:await bBn({...n,cwd:DBa.dirname(t)}),path:t}}import{fileURLToPath as OBa}from"url";import UBa from"path";var MBa=OBa(import.meta.url),zBa=UBa.dirname(MBa),KRe;async function Rz(){if(KRe)return KRe;let n=await fBn({cwd:zBa});if(n)return KRe=n.packageJson,KRe}async function Nx(){let n=await Rz();return"1.0.291"}Ni();import d6 from"node:process";mr();var GBn={name:"about",description:He("command.about.description"),kind:"built-in",action:async n=>{let t=d6.platform,r="no sandbox";d6.env.SANDBOX&&d6.env.SANDBOX!=="sandbox-exec"?r=d6.env.SANDBOX:d6.env.SANDBOX==="sandbox-exec"&&(r=`sandbox-exec (${d6.env.SEATBELT_PROFILE||"unknown"})`);let a=n.services.config?.getModel()||"Unknown",i=await Nx(),s=n.services.settings.merged.selectedAuthType||"",e=d6.env.GOOGLE_CLOUD_PROJECT||"",o={type:"about",cliVersion:i,osVersion:t,sandboxEnv:r,modelVersion:a,selectedAuthType:s,gcpProject:e};n.ui.addItem(o,Date.now())}};Ni();mr();var gBn={name:"auth",description:He("command.auth.description"),kind:"built-in",action:(n,t)=>({type:"dialog",dialog:"auth"})};Ni();mr();var vBn={name:"clear",description:He("command.clear.description"),kind:"built-in",action:async(n,t)=>{n.ui.setDebugMessage("Clearing terminal screen."),n.ui.clear()}};Ni();mr();var ZBn={name:"compress",altNames:["summarize"],description:He("command.compress.description"),kind:"built-in",action:async n=>{let{ui:t}=n,r=n.services.config?.getGeminiClient();if(t.pendingItem){t.addItem({type:"error",text:"Already compressing, wait for previous request to complete"},Date.now());return}if(r?.isCompressionInProgress()){t.addItem({type:"error",text:"Compression already in progress at client level, please wait"},Date.now());return}t.addItem({type:"info",text:He("command.compress.starting")},Date.now());let a={type:"compression",compression:{isPending:!0,originalTokenCount:null,newTokenCount:null}};try{t.setPendingItem(a);let i=`compress-${Date.now()}`,s=await r?.tryCompressChat(i,new AbortController().signal,!0);s?t.addItem({type:"compression",compression:{isPending:!1,originalTokenCount:s.originalTokenCount,newTokenCount:s.newTokenCount}},Date.now()):t.addItem({type:"error",text:"Failed to compress chat history."},Date.now())}catch(i){t.addItem({type:"error",text:`Failed to compress chat history: ${i instanceof Error?i.message:String(i)}`},Date.now())}finally{t.setPendingItem(null)}}};Ni();mr();pr();Cu();var RBn={name:"config",altNames:["settings","preferences"],description:He("command.config.description"),kind:"built-in",action:async(n,t)=>{let{config:r,settings:a}=n.services,i=t.trim().toLowerCase();if(!r||!a)return{type:"message",messageType:"error",content:He("error.config.not.loaded")};if(!i)return{type:"dialog",dialog:"settings-menu"};let[s,...e]=i.split(/\s+/),o=e.join(" ");switch(s){case"theme":case"t":return{type:"dialog",dialog:"theme"};case"editor":case"e":return{type:"dialog",dialog:"editor"};case"model":case"m":return NBn(n,o);case"vim":case"v":return await ABn(n);case"agent-style":case"agent":case"a":return await WBn(n,o);case"yolo":case"y":return yBn(n,o);case"healthy-use":case"healthy":case"h":return FBn(n,o);case"language":case"lang":case"l":return await EBn(n,o);case"help":return _Ba(n);default:return{type:"message",messageType:"error",content:jt("command.config.unknown.subcommand",{subcommand:s})+`
|
|
4380
4380
|
|
|
4381
4381
|
`+qRe()}}},subCommands:[{name:"theme",altNames:["t"],description:He("theme.name"),kind:"built-in",action:()=>({type:"dialog",dialog:"theme"})},{name:"editor",altNames:["e"],description:He("command.editor.description"),kind:"built-in",action:()=>({type:"dialog",dialog:"editor"})},{name:"model",altNames:["m"],description:He("model.command.description"),kind:"built-in",action:async(n,t)=>NBn(n,t)},{name:"vim",altNames:["v"],description:He("command.vim.description"),kind:"built-in",action:async n=>ABn(n)},{name:"agent-style",altNames:["agent","a"],description:He("command.agentStyle.description"),kind:"built-in",action:async(n,t)=>WBn(n,t)},{name:"yolo",altNames:["y"],description:He("command.yolo.description"),kind:"built-in",action:(n,t)=>yBn(n,t)},{name:"healthy-use",altNames:["healthy","h"],description:He("command.healthyUse.description"),kind:"built-in",action:(n,t)=>FBn(n,t)},{name:"language",altNames:["lang","l"],description:He("config.menu.language"),kind:"built-in",action:async(n,t)=>EBn(n,t)}],completion:async(n,t)=>["theme","editor","model","vim","agent-style","yolo","healthy-use","language","help","t","e","m","v","a","y","h","l"].filter(a=>a.toLowerCase().startsWith(t.toLowerCase()))};async function _Ba(n){let{config:t,settings:r}=n.services;if(!t||!r)return{type:"message",messageType:"error",content:He("error.config.not.loaded")};let a=r.merged.vimMode||!1,i=t.getAgentStyle(),s=t.getApprovalMode(),e=t.getHealthyUseEnabled(),o=r.merged.preferredLanguage||He("config.value.default"),u=I=>{switch(I){case"codex":return"\u26A1";case"cursor":return"\u2197\uFE0F";case"augment":return"\u{1F680}";case"claude-code":return"\u2733\uFE0F";case"antigravity":return"\u{1F308}";case"windsurf":return"\u{1F30A}";default:return"\u{1D4E5}"}};return{type:"message",messageType:"info",content:`\u2699\uFE0F ${He("command.config.description")}
|
|
4382
4382
|
|