deepv-code 1.0.258 → 1.0.259

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.
Files changed (2) hide show
  1. package/bundle/dvcode.js +11 -11
  2. package/package.json +1 -1
package/bundle/dvcode.js CHANGED
@@ -492,7 +492,7 @@ https://cloud.google.com/docs/authentication/getting-started`,NO_CREDENTIALS_FOU
492
492
  To learn more about authentication and Google APIs, visit:
493
493
  https://cloud.google.com/docs/authentication/getting-started`,NO_ADC_FOUND:"Could not load the default credentials. Browse to https://cloud.google.com/docs/authentication/getting-started for more information.",NO_UNIVERSE_DOMAIN_FOUND:`Unable to detect a Universe Domain in the current environment.
494
494
  To learn more about Universe Domain retrieval, visit:
495
- https://cloud.google.com/compute/docs/metadata/predefined-metadata-keys`};var mve=class{checkIsGCE=void 0;useJWTAccessWithScope;defaultServicePath;get isGCE(){return this.checkIsGCE}_findProjectIdPromise;_cachedProjectId;jsonContent=null;apiKey;cachedCredential=null;#e=null;defaultScopes;keyFilename;scopes;clientOptions={};constructor(t={}){if(this._cachedProjectId=t.projectId||null,this.cachedCredential=t.authClient||null,this.keyFilename=t.keyFilename||t.keyFile,this.scopes=t.scopes,this.clientOptions=t.clientOptions||{},this.jsonContent=t.credentials||null,this.apiKey=t.apiKey||this.clientOptions.apiKey||null,this.apiKey&&(this.jsonContent||this.clientOptions.credentials))throw new RangeError(Gg.GoogleAuthExceptionMessages.API_KEY_WITH_CREDENTIALS);t.universeDomain&&(this.clientOptions.universeDomain=t.universeDomain)}setGapicJWTValues(t){t.defaultServicePath=this.defaultServicePath,t.useJWTAccessWithScope=this.useJWTAccessWithScope,t.defaultScopes=this.defaultScopes}getProjectId(t){if(t)this.getProjectIdAsync().then(r=>t(null,r),t);else return this.getProjectIdAsync()}async getProjectIdOptional(){try{return await this.getProjectId()}catch(t){if(t instanceof Error&&t.message===Gg.GoogleAuthExceptionMessages.NO_PROJECT_ID_FOUND)return null;throw t}}async findAndCacheProjectId(){let t=null;if(t||=await this.getProductionProjectId(),t||=await this.getFileProjectId(),t||=await this.getDefaultServiceProjectId(),t||=await this.getGCEProjectId(),t||=await this.getExternalAccountClientProjectId(),t)return this._cachedProjectId=t,t;throw new Error(Gg.GoogleAuthExceptionMessages.NO_PROJECT_ID_FOUND)}async getProjectIdAsync(){return this._cachedProjectId?this._cachedProjectId:(this._findProjectIdPromise||(this._findProjectIdPromise=this.findAndCacheProjectId()),this._findProjectIdPromise)}async getUniverseDomainFromMetadataServer(){let t;try{t=await S7.universe("universe-domain"),t||=hve.DEFAULT_UNIVERSE}catch(r){if(r&&r?.response?.status===404)t=hve.DEFAULT_UNIVERSE;else throw r}return t}async getUniverseDomain(){let t=(0,a$e.originalOrCamelOptions)(this.clientOptions).get("universe_domain");try{t??=(await this.getClient()).universeDomain}catch{t??=hve.DEFAULT_UNIVERSE}return t}getAnyScopes(){return this.scopes||this.defaultScopes}getApplicationDefault(t={},r){let a;if(typeof t=="function"?r=t:a=t,r)this.getApplicationDefaultAsync(a).then(i=>r(null,i.credential,i.projectId),r);else return this.getApplicationDefaultAsync(a)}async getApplicationDefaultAsync(t={}){if(this.cachedCredential)return await this.#t(this.cachedCredential,null);let r;if(r=await this._tryGetApplicationCredentialsFromEnvironmentVariable(t),r)return r instanceof Q9.JWT?r.scopes=this.scopes:r instanceof B7.BaseExternalAccountClient&&(r.scopes=this.getAnyScopes()),await this.#t(r);if(r=await this._tryGetApplicationCredentialsFromWellKnownFile(t),r)return r instanceof Q9.JWT?r.scopes=this.scopes:r instanceof B7.BaseExternalAccountClient&&(r.scopes=this.getAnyScopes()),await this.#t(r);if(await this._checkIsGCE())return t.scopes=this.getAnyScopes(),await this.#t(new XAn.Compute(t));throw new Error(Gg.GoogleAuthExceptionMessages.NO_ADC_FOUND)}async#t(t,r=process.env.GOOGLE_CLOUD_QUOTA_PROJECT||null){let a=await this.getProjectIdOptional();return r&&(t.quotaProjectId=r),this.cachedCredential=t,{credential:t,projectId:a}}async _checkIsGCE(){return this.checkIsGCE===void 0&&(this.checkIsGCE=S7.getGCPResidency()||await S7.isAvailable()),this.checkIsGCE}async _tryGetApplicationCredentialsFromEnvironmentVariable(t){let r=process.env.GOOGLE_APPLICATION_CREDENTIALS||process.env.google_application_credentials;if(!r||r.length===0)return null;try{return this._getApplicationCredentialsFromFilePath(r,t)}catch(a){throw a instanceof Error&&(a.message=`Unable to read the credential file specified by the GOOGLE_APPLICATION_CREDENTIALS environment variable: ${a.message}`),a}}async _tryGetApplicationCredentialsFromWellKnownFile(t){let r=null;if(this._isWindows())r=process.env.APPDATA;else{let i=process.env.HOME;i&&(r=dve.join(i,".config"))}return r&&(r=dve.join(r,"gcloud","application_default_credentials.json"),J7.existsSync(r)||(r=null)),r?await this._getApplicationCredentialsFromFilePath(r,t):null}async _getApplicationCredentialsFromFilePath(t,r={}){if(!t||t.length===0)throw new Error("The file path is invalid.");try{if(t=J7.realpathSync(t),!J7.lstatSync(t).isFile())throw new Error}catch(i){throw i instanceof Error&&(i.message=`The file at ${t} does not exist, or it is not a file. ${i.message}`),i}let a=J7.createReadStream(t);return this.fromStream(a,r)}fromImpersonatedJSON(t){if(!t)throw new Error("Must pass in a JSON object containing an impersonated refresh token");if(t.type!==H9.IMPERSONATED_ACCOUNT_TYPE)throw new Error(`The incoming JSON object does not have the "${H9.IMPERSONATED_ACCOUNT_TYPE}" type`);if(!t.source_credentials)throw new Error("The incoming JSON object does not contain a source_credentials field");if(!t.service_account_impersonation_url)throw new Error("The incoming JSON object does not contain a service_account_impersonation_url field");let r=this.fromJSON(t.source_credentials);if(t.service_account_impersonation_url?.length>256)throw new RangeError(`Target principal is too long: ${t.service_account_impersonation_url}`);let a=/(?<target>[^/]+):(generateAccessToken|generateIdToken)$/.exec(t.service_account_impersonation_url)?.groups?.target;if(!a)throw new RangeError(`Cannot extract target principal from ${t.service_account_impersonation_url}`);let i=(this.scopes||t.scopes||this.defaultScopes)??[];return new H9.Impersonated({...t,sourceClient:r,targetPrincipal:a,targetScopes:Array.isArray(i)?i:[i]})}fromJSON(t,r={}){let a,i=(0,a$e.originalOrCamelOptions)(r).get("universe_domain");return t.type===n$e.USER_REFRESH_ACCOUNT_TYPE?(a=new n$e.UserRefreshClient(r),a.fromJSON(t)):t.type===H9.IMPERSONATED_ACCOUNT_TYPE?a=this.fromImpersonatedJSON(t):t.type===B7.EXTERNAL_ACCOUNT_TYPE?(a=JAn.ExternalAccountClient.fromJSON({...t,...r}),a.scopes=this.getAnyScopes()):t.type===r$e.EXTERNAL_ACCOUNT_AUTHORIZED_USER_TYPE?a=new r$e.ExternalAccountAuthorizedUserClient({...t,...r}):(r.scopes=this.scopes,a=new Q9.JWT(r),this.setGapicJWTValues(a),a.fromJSON(t)),i&&(a.universeDomain=i),a}_cacheClientFromJSON(t,r){let a=this.fromJSON(t,r);return this.jsonContent=t,this.cachedCredential=a,a}fromStream(t,r={},a){let i={};if(typeof r=="function"?a=r:i=r,a)this.fromStreamAsync(t,i).then(s=>a(null,s),a);else return this.fromStreamAsync(t,i)}fromStreamAsync(t,r){return new Promise((a,i)=>{if(!t)throw new Error("Must pass in a stream containing the Google auth settings.");let s=[];t.setEncoding("utf8").on("error",i).on("data",e=>s.push(e)).on("end",()=>{try{try{let e=JSON.parse(s.join("")),c=this._cacheClientFromJSON(e,r);return a(c)}catch(e){if(!this.keyFilename)throw e;let c=new Q9.JWT({...this.clientOptions,keyFile:this.keyFilename});return this.cachedCredential=c,this.setGapicJWTValues(c),a(c)}}catch(e){return i(e)}})})}fromAPIKey(t,r={}){return new Q9.JWT({...r,apiKey:t})}_isWindows(){let t=QAn.platform();return!!(t&&t.length>=3&&t.substring(0,3).toLowerCase()==="win")}async getDefaultServiceProjectId(){return new Promise(t=>{(0,xAn.exec)("gcloud config config-helper --format json",(r,a)=>{if(!r&&a)try{let i=JSON.parse(a).configuration.properties.core.project;t(i);return}catch{}t(null)})})}getProductionProjectId(){return process.env.GCLOUD_PROJECT||process.env.GOOGLE_CLOUD_PROJECT||process.env.gcloud_project||process.env.google_cloud_project}async getFileProjectId(){if(this.cachedCredential)return this.cachedCredential.projectId;if(this.keyFilename){let r=await this.getClient();if(r&&r.projectId)return r.projectId}let t=await this._tryGetApplicationCredentialsFromEnvironmentVariable();return t?t.projectId:null}async getExternalAccountClientProjectId(){return!this.jsonContent||this.jsonContent.type!==B7.EXTERNAL_ACCOUNT_TYPE?null:await(await this.getClient()).getProjectId()}async getGCEProjectId(){try{return await S7.project("project-id")}catch{return null}}getCredentials(t){if(t)this.getCredentialsAsync().then(r=>t(null,r),t);else return this.getCredentialsAsync()}async getCredentialsAsync(){let t=await this.getClient();if(t instanceof H9.Impersonated)return{client_email:t.getTargetPrincipal()};if(t instanceof B7.BaseExternalAccountClient){let r=t.getServiceAccountEmail();if(r)return{client_email:r,universe_domain:t.universeDomain}}if(this.jsonContent)return{client_email:this.jsonContent.client_email,private_key:this.jsonContent.private_key,universe_domain:this.jsonContent.universe_domain};if(await this._checkIsGCE()){let[r,a]=await Promise.all([S7.instance("service-accounts/default/email"),this.getUniverseDomain()]);return{client_email:r,universe_domain:a}}throw new Error(Gg.GoogleAuthExceptionMessages.NO_CREDENTIALS_FOUND)}async getClient(){if(this.cachedCredential)return this.cachedCredential;this.#e=this.#e||this.#n();try{return await this.#e}finally{this.#e=null}}async#n(){if(this.jsonContent)return this._cacheClientFromJSON(this.jsonContent,this.clientOptions);if(this.keyFilename){let t=dve.resolve(this.keyFilename),r=J7.createReadStream(t);return await this.fromStreamAsync(r,this.clientOptions)}else if(this.apiKey){let t=await this.fromAPIKey(this.apiKey,this.clientOptions);t.scopes=this.scopes;let{credential:r}=await this.#t(t);return r}else{let{credential:t}=await this.getApplicationDefaultAsync(this.clientOptions);return t}}async getIdTokenClient(t){let r=await this.getClient();if(!("fetchIdToken"in r))throw new Error("Cannot fetch ID token in this environment, use GCE or set the GOOGLE_APPLICATION_CREDENTIALS environment variable to a service account credentials JSON file.");return new kAn.IdTokenClient({targetAudience:t,idTokenProvider:r})}async getAccessToken(){return(await(await this.getClient()).getAccessToken()).token}async getRequestHeaders(t){return(await this.getClient()).getRequestHeaders(t)}async authorizeRequest(t={}){let r=t.url,i=await(await this.getClient()).getRequestHeaders(r);return t.headers=VAn.Gaxios.mergeHeaders(t.headers,i),t}async fetch(...t){return(await this.getClient()).fetch(...t)}async request(t){return(await this.getClient()).request(t)}getEnv(){return(0,LAn.getEnv)()}async sign(t,r){let a=await this.getClient(),i=await this.getUniverseDomain();if(r=r||`https://iamcredentials.${i}/v1/projects/-/serviceAccounts/`,a instanceof H9.Impersonated)return(await a.sign(t)).signedBlob;let s=(0,HAn.createCrypto)();if(a instanceof Q9.JWT&&a.key)return await s.sign(a.key,t);let e=await this.getCredentials();if(!e.client_email)throw new Error("Cannot sign data without `client_email`.");return this.signBlob(s,e.client_email,t,r)}async signBlob(t,r,a,i){let s=new URL(i+`${r}:signBlob`);return(await this.request({method:"POST",url:s.href,data:{payload:t.encodeBase64StringUtf8(a)},retry:!0,retryConfig:{httpMethodsToRetry:["POST"]}})).data.signedBlob}};Gg.GoogleAuth=mve});var l$e=ke(ate=>{"use strict";Object.defineProperty(ate,"__esModule",{value:!0});ate.IAMAuth=void 0;var pve=class{selector;token;constructor(t,r){this.selector=t,this.token=r,this.selector=t,this.token=r}getRequestHeaders(){return{"x-goog-iam-authority-selector":this.selector,"x-goog-iam-authorization-token":this.token}}};ate.IAMAuth=pve});var s$e=ke(xZ=>{"use strict";Object.defineProperty(xZ,"__esModule",{value:!0});xZ.DownscopedClient=xZ.EXPIRATION_TIME_OFFSET=xZ.MAX_ACCESS_BOUNDARY_RULES_COUNT=void 0;var SAn=G0(),BAn=Ct("stream"),bve=pb(),DAn=Lee(),TAn="urn:ietf:params:oauth:grant-type:token-exchange",OAn="urn:ietf:params:oauth:token-type:access_token",UAn="urn:ietf:params:oauth:token-type:access_token";xZ.MAX_ACCESS_BOUNDARY_RULES_COUNT=10;xZ.EXPIRATION_TIME_OFFSET=300*1e3;var Gve=class extends bve.AuthClient{authClient;credentialAccessBoundary;cachedDownscopedAccessToken;stsCredential;constructor(t,r={accessBoundary:{accessBoundaryRules:[]}}){if(super(t instanceof bve.AuthClient?{}:t),t instanceof bve.AuthClient?(this.authClient=t,this.credentialAccessBoundary=r):(this.authClient=t.authClient,this.credentialAccessBoundary=t.credentialAccessBoundary),this.credentialAccessBoundary.accessBoundary.accessBoundaryRules.length===0)throw new Error("At least one access boundary rule needs to be defined.");if(this.credentialAccessBoundary.accessBoundary.accessBoundaryRules.length>xZ.MAX_ACCESS_BOUNDARY_RULES_COUNT)throw new Error(`The provided access boundary has more than ${xZ.MAX_ACCESS_BOUNDARY_RULES_COUNT} access boundary rules.`);for(let a of this.credentialAccessBoundary.accessBoundary.accessBoundaryRules)if(a.availablePermissions.length===0)throw new Error("At least one permission should be defined in access boundary rules.");this.stsCredential=new DAn.StsCredentials({tokenExchangeEndpoint:`https://sts.${this.universeDomain}/v1/token`}),this.cachedDownscopedAccessToken=null}setCredentials(t){if(!t.expiry_date)throw new Error("The access token expiry_date field is missing in the provided credentials.");super.setCredentials(t),this.cachedDownscopedAccessToken=t}async getAccessToken(){return(!this.cachedDownscopedAccessToken||this.isExpired(this.cachedDownscopedAccessToken))&&await this.refreshAccessTokenAsync(),{token:this.cachedDownscopedAccessToken.access_token,expirationTime:this.cachedDownscopedAccessToken.expiry_date,res:this.cachedDownscopedAccessToken.res}}async getRequestHeaders(){let t=await this.getAccessToken(),r=new Headers({authorization:`Bearer ${t.token}`});return this.addSharedMetadataHeaders(r)}request(t,r){if(r)this.requestAsync(t).then(a=>r(null,a),a=>r(a,a.response));else return this.requestAsync(t)}async requestAsync(t,r=!1){let a;try{let i=await this.getRequestHeaders();t.headers=SAn.Gaxios.mergeHeaders(t.headers),this.addUserProjectAndAuthHeaders(t.headers,i),a=await this.transporter.request(t)}catch(i){let s=i.response;if(s){let e=s.status,c=s.config.data instanceof BAn.Readable;if(!r&&(e===401||e===403)&&!c&&this.forceRefreshOnFailure)return await this.refreshAccessTokenAsync(),await this.requestAsync(t,!0)}throw i}return a}async refreshAccessTokenAsync(){let t=(await this.authClient.getAccessToken()).token,r={grantType:TAn,requestedTokenType:OAn,subjectToken:t,subjectTokenType:UAn},a=await this.stsCredential.exchangeToken(r,void 0,this.credentialAccessBoundary),i=this.authClient.credentials?.expiry_date||null,s=a.expires_in?new Date().getTime()+a.expires_in*1e3:i;return this.cachedDownscopedAccessToken={access_token:a.access_token,expiry_date:s,res:a.res},this.credentials={},Object.assign(this.credentials,this.cachedDownscopedAccessToken),delete this.credentials.res,this.emit("tokens",{refresh_token:null,expiry_date:this.cachedDownscopedAccessToken.expiry_date,access_token:this.cachedDownscopedAccessToken.access_token,token_type:"Bearer",id_token:null}),this.cachedDownscopedAccessToken}isExpired(t){let r=new Date().getTime();return t.expiry_date?r>=t.expiry_date-this.eagerRefreshThresholdMillis:!1}};xZ.DownscopedClient=Gve});var o$e=ke(ite=>{"use strict";Object.defineProperty(ite,"__esModule",{value:!0});ite.PassThroughClient=void 0;var MAn=pb(),fve=class extends MAn.AuthClient{async request(t){return this.transporter.request(t)}async getAccessToken(){return{}}async getRequestHeaders(){return new Headers}};ite.PassThroughClient=fve});var h$e=ke(ha=>{"use strict";Object.defineProperty(ha,"__esModule",{value:!0});ha.GoogleAuth=ha.auth=ha.PassThroughClient=ha.ExternalAccountAuthorizedUserClient=ha.EXTERNAL_ACCOUNT_AUTHORIZED_USER_TYPE=ha.ExecutableError=ha.PluggableAuthClient=ha.DownscopedClient=ha.BaseExternalAccountClient=ha.ExternalAccountClient=ha.IdentityPoolClient=ha.AwsRequestSigner=ha.AwsClient=ha.UserRefreshClient=ha.LoginTicket=ha.ClientAuthentication=ha.OAuth2Client=ha.CodeChallengeMethod=ha.Impersonated=ha.JWT=ha.JWTAccess=ha.IdTokenClient=ha.IAMAuth=ha.GCPEnv=ha.Compute=ha.DEFAULT_UNIVERSE=ha.AuthClient=ha.gaxios=ha.gcpMetadata=void 0;var c$e=i$e();Object.defineProperty(ha,"GoogleAuth",{enumerable:!0,get:function(){return c$e.GoogleAuth}});ha.gcpMetadata=F7();ha.gaxios=G0();var I$e=pb();Object.defineProperty(ha,"AuthClient",{enumerable:!0,get:function(){return I$e.AuthClient}});Object.defineProperty(ha,"DEFAULT_UNIVERSE",{enumerable:!0,get:function(){return I$e.DEFAULT_UNIVERSE}});var zAn=ige();Object.defineProperty(ha,"Compute",{enumerable:!0,get:function(){return zAn.Compute}});var _An=oge();Object.defineProperty(ha,"GCPEnv",{enumerable:!0,get:function(){return _An.GCPEnv}});var PAn=l$e();Object.defineProperty(ha,"IAMAuth",{enumerable:!0,get:function(){return PAn.IAMAuth}});var jAn=sge();Object.defineProperty(ha,"IdTokenClient",{enumerable:!0,get:function(){return jAn.IdTokenClient}});var KAn=Fge();Object.defineProperty(ha,"JWTAccess",{enumerable:!0,get:function(){return KAn.JWTAccess}});var qAn=Rge();Object.defineProperty(ha,"JWT",{enumerable:!0,get:function(){return qAn.JWT}});var $An=Cge();Object.defineProperty(ha,"Impersonated",{enumerable:!0,get:function(){return $An.Impersonated}});var gve=ME();Object.defineProperty(ha,"CodeChallengeMethod",{enumerable:!0,get:function(){return gve.CodeChallengeMethod}});Object.defineProperty(ha,"OAuth2Client",{enumerable:!0,get:function(){return gve.OAuth2Client}});Object.defineProperty(ha,"ClientAuthentication",{enumerable:!0,get:function(){return gve.ClientAuthentication}});var e5n=tge();Object.defineProperty(ha,"LoginTicket",{enumerable:!0,get:function(){return e5n.LoginTicket}});var t5n=wge();Object.defineProperty(ha,"UserRefreshClient",{enumerable:!0,get:function(){return t5n.UserRefreshClient}});var n5n=jge();Object.defineProperty(ha,"AwsClient",{enumerable:!0,get:function(){return n5n.AwsClient}});var r5n=zge();Object.defineProperty(ha,"AwsRequestSigner",{enumerable:!0,get:function(){return r5n.AwsRequestSigner}});var a5n=Uge();Object.defineProperty(ha,"IdentityPoolClient",{enumerable:!0,get:function(){return a5n.IdentityPoolClient}});var i5n=ove();Object.defineProperty(ha,"ExternalAccountClient",{enumerable:!0,get:function(){return i5n.ExternalAccountClient}});var l5n=kF();Object.defineProperty(ha,"BaseExternalAccountClient",{enumerable:!0,get:function(){return l5n.BaseExternalAccountClient}});var s5n=s$e();Object.defineProperty(ha,"DownscopedClient",{enumerable:!0,get:function(){return s5n.DownscopedClient}});var u$e=lve();Object.defineProperty(ha,"PluggableAuthClient",{enumerable:!0,get:function(){return u$e.PluggableAuthClient}});Object.defineProperty(ha,"ExecutableError",{enumerable:!0,get:function(){return u$e.ExecutableError}});var d$e=uve();Object.defineProperty(ha,"EXTERNAL_ACCOUNT_AUTHORIZED_USER_TYPE",{enumerable:!0,get:function(){return d$e.EXTERNAL_ACCOUNT_AUTHORIZED_USER_TYPE}});Object.defineProperty(ha,"ExternalAccountAuthorizedUserClient",{enumerable:!0,get:function(){return d$e.ExternalAccountAuthorizedUserClient}});var o5n=o$e();Object.defineProperty(ha,"PassThroughClient",{enumerable:!0,get:function(){return o5n.PassThroughClient}});var c5n=new c$e.GoogleAuth;ha.auth=c5n});function met(n){return{text:n}}function pet(n){return typeof n=="object"&&n!==null?"fileData"in n||"text"in n||"functionCall"in n||"functionResponse"in n||"inlineData"in n||"videoMetadata"in n||"codeExecutionResult"in n||"executableCode"in n:!1}function u5n(n){let t=[];if(typeof n=="string")t.push(met(n));else if(pet(n))t.push(n);else if(Array.isArray(n)){if(n.length===0)throw new Error("partOrString cannot be an empty array");for(let r of n)if(typeof r=="string")t.push(met(r));else if(pet(r))t.push(r);else throw new Error("element in PartUnion must be a Part object or string")}else throw new Error("partOrString must be a Part object, string, or array");return t}function vve(n){return{role:"user",parts:u5n(n)}}function d5n(n,t={}){let r=n,a={name:r.name,description:r.description,parametersJsonSchema:r.inputSchema};return r.outputSchema&&(a.responseJsonSchema=r.outputSchema),t.behavior&&(a.behavior=t.behavior),{functionDeclarations:[a]}}function h5n(n,t={}){let r=[],a=new Set;for(let i of n){let s=i.name;if(a.has(s))throw new Error(`Duplicate function name ${s} found in MCP tools. Please ensure function names are unique.`);a.add(s);let e=d5n(i,t);e.functionDeclarations&&r.push(...e.functionDeclarations)}return{functionDeclarations:r}}function Get(n){var t=typeof Symbol=="function"&&Symbol.iterator,r=t&&n[t],a=0;if(r)return r.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&a>=n.length&&(n=void 0),{value:n&&n[a++],done:!n}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function D7(n){return this instanceof D7?(this.v=n,this):new D7(n)}function m5n(n,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var a=r.apply(n,t||[]),i,s=[];return i=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),c("next"),c("throw"),c("return",e),i[Symbol.asyncIterator]=function(){return this},i;function e(v){return function(w){return Promise.resolve(w).then(v,h)}}function c(v,w){a[v]&&(i[v]=function(R){return new Promise(function(E,A){s.push([v,R,E,A])>1||u(v,R)})},w&&(i[v]=w(i[v])))}function u(v,w){try{d(a[v](w))}catch(R){o(s[0][3],R)}}function d(v){v.value instanceof D7?Promise.resolve(v.value.v).then(I,h):o(s[0][2],v)}function I(v){u("next",v)}function h(v){u("throw",v)}function o(v,w){v(w),s.shift(),s.length&&u(s[0][0],s[0][1])}}function p5n(n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=n[Symbol.asyncIterator],r;return t?t.call(n):(n=typeof Get=="function"?Get(n):n[Symbol.iterator](),r={},a("next"),a("throw"),a("return"),r[Symbol.asyncIterator]=function(){return this},r);function a(s){r[s]=n[s]&&function(e){return new Promise(function(c,u){e=n[s](e),i(c,u,e.done,e.value)})}}function i(s,e,c,u){Promise.resolve(u).then(function(d){s({value:d,done:c})},e)}}function f5n(n,t=100){return m5n(this,arguments,function*(){let a,i=0;for(;i<t;){let s=yield D7(n.listTools({cursor:a}));for(let e of s.tools)yield yield D7(e),i++;if(!s.nextCursor)break;a=s.nextCursor}})}function g5n(n){return n!==null&&typeof n=="object"&&"listTools"in n&&typeof n.listTools=="function"}function fet(...n){if(G5n=!0,n.length===0)throw new Error("No MCP clients provided");let t=n[n.length-1];return g5n(t)?ste.create(n,{}):ste.create(n.slice(0,n.length-1),t)}var I5n,m$e,p$e,b$e,Fn,G$e,f$e,g$e,v$e,Z$e,N$e,W$e,A$e,F$e,AI,y$e,R$e,E$e,w$e,Y$e,C$e,x$e,V$e,Q$e,H$e,X$e,k$e,L$e,J$e,S$e,B$e,X9,D$e,T$e,O$e,U$e,M$e,z$e,_$e,P$e,j$e,K$e,q$e,$$e,eet,tet,net,aet,iet,set,oet,cet,Iet,uet,det,het,lte,k9,bet,b5n,Ina,G5n,ste,una,Bi=It(()=>{I5n=Dt(h$e(),1);n7();(function(n){n.OUTCOME_UNSPECIFIED="OUTCOME_UNSPECIFIED",n.OUTCOME_OK="OUTCOME_OK",n.OUTCOME_FAILED="OUTCOME_FAILED",n.OUTCOME_DEADLINE_EXCEEDED="OUTCOME_DEADLINE_EXCEEDED"})(m$e||(m$e={}));(function(n){n.LANGUAGE_UNSPECIFIED="LANGUAGE_UNSPECIFIED",n.PYTHON="PYTHON"})(p$e||(p$e={}));(function(n){n.SCHEDULING_UNSPECIFIED="SCHEDULING_UNSPECIFIED",n.SILENT="SILENT",n.WHEN_IDLE="WHEN_IDLE",n.INTERRUPT="INTERRUPT"})(b$e||(b$e={}));(function(n){n.TYPE_UNSPECIFIED="TYPE_UNSPECIFIED",n.STRING="STRING",n.NUMBER="NUMBER",n.INTEGER="INTEGER",n.BOOLEAN="BOOLEAN",n.ARRAY="ARRAY",n.OBJECT="OBJECT",n.NULL="NULL"})(Fn||(Fn={}));(function(n){n.MODE_UNSPECIFIED="MODE_UNSPECIFIED",n.MODE_DYNAMIC="MODE_DYNAMIC"})(G$e||(G$e={}));(function(n){n.API_SPEC_UNSPECIFIED="API_SPEC_UNSPECIFIED",n.SIMPLE_SEARCH="SIMPLE_SEARCH",n.ELASTIC_SEARCH="ELASTIC_SEARCH"})(f$e||(f$e={}));(function(n){n.AUTH_TYPE_UNSPECIFIED="AUTH_TYPE_UNSPECIFIED",n.NO_AUTH="NO_AUTH",n.API_KEY_AUTH="API_KEY_AUTH",n.HTTP_BASIC_AUTH="HTTP_BASIC_AUTH",n.GOOGLE_SERVICE_ACCOUNT_AUTH="GOOGLE_SERVICE_ACCOUNT_AUTH",n.OAUTH="OAUTH",n.OIDC_AUTH="OIDC_AUTH"})(g$e||(g$e={}));(function(n){n.HTTP_IN_UNSPECIFIED="HTTP_IN_UNSPECIFIED",n.HTTP_IN_QUERY="HTTP_IN_QUERY",n.HTTP_IN_HEADER="HTTP_IN_HEADER",n.HTTP_IN_PATH="HTTP_IN_PATH",n.HTTP_IN_BODY="HTTP_IN_BODY",n.HTTP_IN_COOKIE="HTTP_IN_COOKIE"})(v$e||(v$e={}));(function(n){n.PHISH_BLOCK_THRESHOLD_UNSPECIFIED="PHISH_BLOCK_THRESHOLD_UNSPECIFIED",n.BLOCK_LOW_AND_ABOVE="BLOCK_LOW_AND_ABOVE",n.BLOCK_MEDIUM_AND_ABOVE="BLOCK_MEDIUM_AND_ABOVE",n.BLOCK_HIGH_AND_ABOVE="BLOCK_HIGH_AND_ABOVE",n.BLOCK_HIGHER_AND_ABOVE="BLOCK_HIGHER_AND_ABOVE",n.BLOCK_VERY_HIGH_AND_ABOVE="BLOCK_VERY_HIGH_AND_ABOVE",n.BLOCK_ONLY_EXTREMELY_HIGH="BLOCK_ONLY_EXTREMELY_HIGH"})(Z$e||(Z$e={}));(function(n){n.THINKING_LEVEL_UNSPECIFIED="THINKING_LEVEL_UNSPECIFIED",n.LOW="LOW",n.HIGH="HIGH"})(N$e||(N$e={}));(function(n){n.HARM_CATEGORY_UNSPECIFIED="HARM_CATEGORY_UNSPECIFIED",n.HARM_CATEGORY_HARASSMENT="HARM_CATEGORY_HARASSMENT",n.HARM_CATEGORY_HATE_SPEECH="HARM_CATEGORY_HATE_SPEECH",n.HARM_CATEGORY_SEXUALLY_EXPLICIT="HARM_CATEGORY_SEXUALLY_EXPLICIT",n.HARM_CATEGORY_DANGEROUS_CONTENT="HARM_CATEGORY_DANGEROUS_CONTENT",n.HARM_CATEGORY_CIVIC_INTEGRITY="HARM_CATEGORY_CIVIC_INTEGRITY",n.HARM_CATEGORY_IMAGE_HATE="HARM_CATEGORY_IMAGE_HATE",n.HARM_CATEGORY_IMAGE_DANGEROUS_CONTENT="HARM_CATEGORY_IMAGE_DANGEROUS_CONTENT",n.HARM_CATEGORY_IMAGE_HARASSMENT="HARM_CATEGORY_IMAGE_HARASSMENT",n.HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT="HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT",n.HARM_CATEGORY_JAILBREAK="HARM_CATEGORY_JAILBREAK"})(W$e||(W$e={}));(function(n){n.HARM_BLOCK_METHOD_UNSPECIFIED="HARM_BLOCK_METHOD_UNSPECIFIED",n.SEVERITY="SEVERITY",n.PROBABILITY="PROBABILITY"})(A$e||(A$e={}));(function(n){n.HARM_BLOCK_THRESHOLD_UNSPECIFIED="HARM_BLOCK_THRESHOLD_UNSPECIFIED",n.BLOCK_LOW_AND_ABOVE="BLOCK_LOW_AND_ABOVE",n.BLOCK_MEDIUM_AND_ABOVE="BLOCK_MEDIUM_AND_ABOVE",n.BLOCK_ONLY_HIGH="BLOCK_ONLY_HIGH",n.BLOCK_NONE="BLOCK_NONE",n.OFF="OFF"})(F$e||(F$e={}));(function(n){n.FINISH_REASON_UNSPECIFIED="FINISH_REASON_UNSPECIFIED",n.STOP="STOP",n.MAX_TOKENS="MAX_TOKENS",n.SAFETY="SAFETY",n.RECITATION="RECITATION",n.LANGUAGE="LANGUAGE",n.OTHER="OTHER",n.BLOCKLIST="BLOCKLIST",n.PROHIBITED_CONTENT="PROHIBITED_CONTENT",n.SPII="SPII",n.MALFORMED_FUNCTION_CALL="MALFORMED_FUNCTION_CALL",n.IMAGE_SAFETY="IMAGE_SAFETY",n.UNEXPECTED_TOOL_CALL="UNEXPECTED_TOOL_CALL",n.IMAGE_PROHIBITED_CONTENT="IMAGE_PROHIBITED_CONTENT",n.NO_IMAGE="NO_IMAGE"})(AI||(AI={}));(function(n){n.HARM_PROBABILITY_UNSPECIFIED="HARM_PROBABILITY_UNSPECIFIED",n.NEGLIGIBLE="NEGLIGIBLE",n.LOW="LOW",n.MEDIUM="MEDIUM",n.HIGH="HIGH"})(y$e||(y$e={}));(function(n){n.HARM_SEVERITY_UNSPECIFIED="HARM_SEVERITY_UNSPECIFIED",n.HARM_SEVERITY_NEGLIGIBLE="HARM_SEVERITY_NEGLIGIBLE",n.HARM_SEVERITY_LOW="HARM_SEVERITY_LOW",n.HARM_SEVERITY_MEDIUM="HARM_SEVERITY_MEDIUM",n.HARM_SEVERITY_HIGH="HARM_SEVERITY_HIGH"})(R$e||(R$e={}));(function(n){n.URL_RETRIEVAL_STATUS_UNSPECIFIED="URL_RETRIEVAL_STATUS_UNSPECIFIED",n.URL_RETRIEVAL_STATUS_SUCCESS="URL_RETRIEVAL_STATUS_SUCCESS",n.URL_RETRIEVAL_STATUS_ERROR="URL_RETRIEVAL_STATUS_ERROR",n.URL_RETRIEVAL_STATUS_PAYWALL="URL_RETRIEVAL_STATUS_PAYWALL",n.URL_RETRIEVAL_STATUS_UNSAFE="URL_RETRIEVAL_STATUS_UNSAFE"})(E$e||(E$e={}));(function(n){n.BLOCKED_REASON_UNSPECIFIED="BLOCKED_REASON_UNSPECIFIED",n.SAFETY="SAFETY",n.OTHER="OTHER",n.BLOCKLIST="BLOCKLIST",n.PROHIBITED_CONTENT="PROHIBITED_CONTENT",n.IMAGE_SAFETY="IMAGE_SAFETY",n.MODEL_ARMOR="MODEL_ARMOR",n.JAILBREAK="JAILBREAK"})(w$e||(w$e={}));(function(n){n.TRAFFIC_TYPE_UNSPECIFIED="TRAFFIC_TYPE_UNSPECIFIED",n.ON_DEMAND="ON_DEMAND",n.PROVISIONED_THROUGHPUT="PROVISIONED_THROUGHPUT"})(Y$e||(Y$e={}));(function(n){n.MODALITY_UNSPECIFIED="MODALITY_UNSPECIFIED",n.TEXT="TEXT",n.IMAGE="IMAGE",n.AUDIO="AUDIO"})(C$e||(C$e={}));(function(n){n.MEDIA_RESOLUTION_UNSPECIFIED="MEDIA_RESOLUTION_UNSPECIFIED",n.MEDIA_RESOLUTION_LOW="MEDIA_RESOLUTION_LOW",n.MEDIA_RESOLUTION_MEDIUM="MEDIA_RESOLUTION_MEDIUM",n.MEDIA_RESOLUTION_HIGH="MEDIA_RESOLUTION_HIGH"})(x$e||(x$e={}));(function(n){n.TUNING_MODE_UNSPECIFIED="TUNING_MODE_UNSPECIFIED",n.TUNING_MODE_FULL="TUNING_MODE_FULL",n.TUNING_MODE_PEFT_ADAPTER="TUNING_MODE_PEFT_ADAPTER"})(V$e||(V$e={}));(function(n){n.ADAPTER_SIZE_UNSPECIFIED="ADAPTER_SIZE_UNSPECIFIED",n.ADAPTER_SIZE_ONE="ADAPTER_SIZE_ONE",n.ADAPTER_SIZE_TWO="ADAPTER_SIZE_TWO",n.ADAPTER_SIZE_FOUR="ADAPTER_SIZE_FOUR",n.ADAPTER_SIZE_EIGHT="ADAPTER_SIZE_EIGHT",n.ADAPTER_SIZE_SIXTEEN="ADAPTER_SIZE_SIXTEEN",n.ADAPTER_SIZE_THIRTY_TWO="ADAPTER_SIZE_THIRTY_TWO"})(Q$e||(Q$e={}));(function(n){n.JOB_STATE_UNSPECIFIED="JOB_STATE_UNSPECIFIED",n.JOB_STATE_QUEUED="JOB_STATE_QUEUED",n.JOB_STATE_PENDING="JOB_STATE_PENDING",n.JOB_STATE_RUNNING="JOB_STATE_RUNNING",n.JOB_STATE_SUCCEEDED="JOB_STATE_SUCCEEDED",n.JOB_STATE_FAILED="JOB_STATE_FAILED",n.JOB_STATE_CANCELLING="JOB_STATE_CANCELLING",n.JOB_STATE_CANCELLED="JOB_STATE_CANCELLED",n.JOB_STATE_PAUSED="JOB_STATE_PAUSED",n.JOB_STATE_EXPIRED="JOB_STATE_EXPIRED",n.JOB_STATE_UPDATING="JOB_STATE_UPDATING",n.JOB_STATE_PARTIALLY_SUCCEEDED="JOB_STATE_PARTIALLY_SUCCEEDED"})(H$e||(H$e={}));(function(n){n.TUNING_TASK_UNSPECIFIED="TUNING_TASK_UNSPECIFIED",n.TUNING_TASK_I2V="TUNING_TASK_I2V",n.TUNING_TASK_T2V="TUNING_TASK_T2V",n.TUNING_TASK_R2V="TUNING_TASK_R2V"})(X$e||(X$e={}));(function(n){n.MEDIA_RESOLUTION_UNSPECIFIED="MEDIA_RESOLUTION_UNSPECIFIED",n.MEDIA_RESOLUTION_LOW="MEDIA_RESOLUTION_LOW",n.MEDIA_RESOLUTION_MEDIUM="MEDIA_RESOLUTION_MEDIUM",n.MEDIA_RESOLUTION_HIGH="MEDIA_RESOLUTION_HIGH"})(k$e||(k$e={}));(function(n){n.FEATURE_SELECTION_PREFERENCE_UNSPECIFIED="FEATURE_SELECTION_PREFERENCE_UNSPECIFIED",n.PRIORITIZE_QUALITY="PRIORITIZE_QUALITY",n.BALANCED="BALANCED",n.PRIORITIZE_COST="PRIORITIZE_COST"})(L$e||(L$e={}));(function(n){n.UNSPECIFIED="UNSPECIFIED",n.BLOCKING="BLOCKING",n.NON_BLOCKING="NON_BLOCKING"})(J$e||(J$e={}));(function(n){n.MODE_UNSPECIFIED="MODE_UNSPECIFIED",n.MODE_DYNAMIC="MODE_DYNAMIC"})(S$e||(S$e={}));(function(n){n.ENVIRONMENT_UNSPECIFIED="ENVIRONMENT_UNSPECIFIED",n.ENVIRONMENT_BROWSER="ENVIRONMENT_BROWSER"})(B$e||(B$e={}));(function(n){n.MODE_UNSPECIFIED="MODE_UNSPECIFIED",n.AUTO="AUTO",n.ANY="ANY",n.NONE="NONE",n.VALIDATED="VALIDATED"})(X9||(X9={}));(function(n){n.BLOCK_LOW_AND_ABOVE="BLOCK_LOW_AND_ABOVE",n.BLOCK_MEDIUM_AND_ABOVE="BLOCK_MEDIUM_AND_ABOVE",n.BLOCK_ONLY_HIGH="BLOCK_ONLY_HIGH",n.BLOCK_NONE="BLOCK_NONE"})(D$e||(D$e={}));(function(n){n.DONT_ALLOW="DONT_ALLOW",n.ALLOW_ADULT="ALLOW_ADULT",n.ALLOW_ALL="ALLOW_ALL"})(T$e||(T$e={}));(function(n){n.auto="auto",n.en="en",n.ja="ja",n.ko="ko",n.hi="hi",n.zh="zh",n.pt="pt",n.es="es"})(O$e||(O$e={}));(function(n){n.MASK_MODE_DEFAULT="MASK_MODE_DEFAULT",n.MASK_MODE_USER_PROVIDED="MASK_MODE_USER_PROVIDED",n.MASK_MODE_BACKGROUND="MASK_MODE_BACKGROUND",n.MASK_MODE_FOREGROUND="MASK_MODE_FOREGROUND",n.MASK_MODE_SEMANTIC="MASK_MODE_SEMANTIC"})(U$e||(U$e={}));(function(n){n.CONTROL_TYPE_DEFAULT="CONTROL_TYPE_DEFAULT",n.CONTROL_TYPE_CANNY="CONTROL_TYPE_CANNY",n.CONTROL_TYPE_SCRIBBLE="CONTROL_TYPE_SCRIBBLE",n.CONTROL_TYPE_FACE_MESH="CONTROL_TYPE_FACE_MESH"})(M$e||(M$e={}));(function(n){n.SUBJECT_TYPE_DEFAULT="SUBJECT_TYPE_DEFAULT",n.SUBJECT_TYPE_PERSON="SUBJECT_TYPE_PERSON",n.SUBJECT_TYPE_ANIMAL="SUBJECT_TYPE_ANIMAL",n.SUBJECT_TYPE_PRODUCT="SUBJECT_TYPE_PRODUCT"})(z$e||(z$e={}));(function(n){n.EDIT_MODE_DEFAULT="EDIT_MODE_DEFAULT",n.EDIT_MODE_INPAINT_REMOVAL="EDIT_MODE_INPAINT_REMOVAL",n.EDIT_MODE_INPAINT_INSERTION="EDIT_MODE_INPAINT_INSERTION",n.EDIT_MODE_OUTPAINT="EDIT_MODE_OUTPAINT",n.EDIT_MODE_CONTROLLED_EDITING="EDIT_MODE_CONTROLLED_EDITING",n.EDIT_MODE_STYLE="EDIT_MODE_STYLE",n.EDIT_MODE_BGSWAP="EDIT_MODE_BGSWAP",n.EDIT_MODE_PRODUCT_IMAGE="EDIT_MODE_PRODUCT_IMAGE"})(_$e||(_$e={}));(function(n){n.FOREGROUND="FOREGROUND",n.BACKGROUND="BACKGROUND",n.PROMPT="PROMPT",n.SEMANTIC="SEMANTIC",n.INTERACTIVE="INTERACTIVE"})(P$e||(P$e={}));(function(n){n.ASSET="ASSET",n.STYLE="STYLE"})(j$e||(j$e={}));(function(n){n.INSERT="INSERT",n.REMOVE="REMOVE",n.REMOVE_STATIC="REMOVE_STATIC",n.OUTPAINT="OUTPAINT"})(K$e||(K$e={}));(function(n){n.OPTIMIZED="OPTIMIZED",n.LOSSLESS="LOSSLESS"})(q$e||(q$e={}));(function(n){n.SUPERVISED_FINE_TUNING="SUPERVISED_FINE_TUNING",n.PREFERENCE_TUNING="PREFERENCE_TUNING"})($$e||($$e={}));(function(n){n.STATE_UNSPECIFIED="STATE_UNSPECIFIED",n.STATE_PENDING="STATE_PENDING",n.STATE_ACTIVE="STATE_ACTIVE",n.STATE_FAILED="STATE_FAILED"})(eet||(eet={}));(function(n){n.STATE_UNSPECIFIED="STATE_UNSPECIFIED",n.PROCESSING="PROCESSING",n.ACTIVE="ACTIVE",n.FAILED="FAILED"})(tet||(tet={}));(function(n){n.SOURCE_UNSPECIFIED="SOURCE_UNSPECIFIED",n.UPLOADED="UPLOADED",n.GENERATED="GENERATED"})(net||(net={}));(function(n){n.TURN_COMPLETE_REASON_UNSPECIFIED="TURN_COMPLETE_REASON_UNSPECIFIED",n.MALFORMED_FUNCTION_CALL="MALFORMED_FUNCTION_CALL",n.RESPONSE_REJECTED="RESPONSE_REJECTED",n.NEED_MORE_INPUT="NEED_MORE_INPUT"})(aet||(aet={}));(function(n){n.MODALITY_UNSPECIFIED="MODALITY_UNSPECIFIED",n.TEXT="TEXT",n.IMAGE="IMAGE",n.VIDEO="VIDEO",n.AUDIO="AUDIO",n.DOCUMENT="DOCUMENT"})(iet||(iet={}));(function(n){n.START_SENSITIVITY_UNSPECIFIED="START_SENSITIVITY_UNSPECIFIED",n.START_SENSITIVITY_HIGH="START_SENSITIVITY_HIGH",n.START_SENSITIVITY_LOW="START_SENSITIVITY_LOW"})(set||(set={}));(function(n){n.END_SENSITIVITY_UNSPECIFIED="END_SENSITIVITY_UNSPECIFIED",n.END_SENSITIVITY_HIGH="END_SENSITIVITY_HIGH",n.END_SENSITIVITY_LOW="END_SENSITIVITY_LOW"})(oet||(oet={}));(function(n){n.ACTIVITY_HANDLING_UNSPECIFIED="ACTIVITY_HANDLING_UNSPECIFIED",n.START_OF_ACTIVITY_INTERRUPTS="START_OF_ACTIVITY_INTERRUPTS",n.NO_INTERRUPTION="NO_INTERRUPTION"})(cet||(cet={}));(function(n){n.TURN_COVERAGE_UNSPECIFIED="TURN_COVERAGE_UNSPECIFIED",n.TURN_INCLUDES_ONLY_ACTIVITY="TURN_INCLUDES_ONLY_ACTIVITY",n.TURN_INCLUDES_ALL_INPUT="TURN_INCLUDES_ALL_INPUT"})(Iet||(Iet={}));(function(n){n.SCALE_UNSPECIFIED="SCALE_UNSPECIFIED",n.C_MAJOR_A_MINOR="C_MAJOR_A_MINOR",n.D_FLAT_MAJOR_B_FLAT_MINOR="D_FLAT_MAJOR_B_FLAT_MINOR",n.D_MAJOR_B_MINOR="D_MAJOR_B_MINOR",n.E_FLAT_MAJOR_C_MINOR="E_FLAT_MAJOR_C_MINOR",n.E_MAJOR_D_FLAT_MINOR="E_MAJOR_D_FLAT_MINOR",n.F_MAJOR_D_MINOR="F_MAJOR_D_MINOR",n.G_FLAT_MAJOR_E_FLAT_MINOR="G_FLAT_MAJOR_E_FLAT_MINOR",n.G_MAJOR_E_MINOR="G_MAJOR_E_MINOR",n.A_FLAT_MAJOR_F_MINOR="A_FLAT_MAJOR_F_MINOR",n.A_MAJOR_G_FLAT_MINOR="A_MAJOR_G_FLAT_MINOR",n.B_FLAT_MAJOR_G_MINOR="B_FLAT_MAJOR_G_MINOR",n.B_MAJOR_A_FLAT_MINOR="B_MAJOR_A_FLAT_MINOR"})(uet||(uet={}));(function(n){n.MUSIC_GENERATION_MODE_UNSPECIFIED="MUSIC_GENERATION_MODE_UNSPECIFIED",n.QUALITY="QUALITY",n.DIVERSITY="DIVERSITY",n.VOCALIZATION="VOCALIZATION"})(det||(det={}));(function(n){n.PLAYBACK_CONTROL_UNSPECIFIED="PLAYBACK_CONTROL_UNSPECIFIED",n.PLAY="PLAY",n.PAUSE="PAUSE",n.STOP="STOP",n.RESET_CONTEXT="RESET_CONTEXT"})(het||(het={}));lte=class{},k9=class{get text(){var t,r,a,i,s,e,c,u;if(((i=(a=(r=(t=this.candidates)===null||t===void 0?void 0:t[0])===null||r===void 0?void 0:r.content)===null||a===void 0?void 0:a.parts)===null||i===void 0?void 0:i.length)===0)return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning text from the first one.");let d="",I=!1,h=[];for(let o of(u=(c=(e=(s=this.candidates)===null||s===void 0?void 0:s[0])===null||e===void 0?void 0:e.content)===null||c===void 0?void 0:c.parts)!==null&&u!==void 0?u:[]){for(let[v,w]of Object.entries(o))v!=="text"&&v!=="thought"&&v!=="thoughtSignature"&&(w!==null||w!==void 0)&&h.push(v);if(typeof o.text=="string"){if(typeof o.thought=="boolean"&&o.thought)continue;I=!0,d+=o.text}}return h.length>0&&console.warn(`there are non-text parts ${h} in the response, returning concatenation of all text parts. Please refer to the non text parts for a full response from model.`),I?d:void 0}get data(){var t,r,a,i,s,e,c,u;if(((i=(a=(r=(t=this.candidates)===null||t===void 0?void 0:t[0])===null||r===void 0?void 0:r.content)===null||a===void 0?void 0:a.parts)===null||i===void 0?void 0:i.length)===0)return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning data from the first one.");let d="",I=[];for(let h of(u=(c=(e=(s=this.candidates)===null||s===void 0?void 0:s[0])===null||e===void 0?void 0:e.content)===null||c===void 0?void 0:c.parts)!==null&&u!==void 0?u:[]){for(let[o,v]of Object.entries(h))o!=="inlineData"&&(v!==null||v!==void 0)&&I.push(o);h.inlineData&&typeof h.inlineData.data=="string"&&(d+=atob(h.inlineData.data))}return I.length>0&&console.warn(`there are non-data parts ${I} in the response, returning concatenation of all data parts. Please refer to the non data parts for a full response from model.`),d.length>0?btoa(d):void 0}get functionCalls(){var t,r,a,i,s,e,c,u;if(((i=(a=(r=(t=this.candidates)===null||t===void 0?void 0:t[0])===null||r===void 0?void 0:r.content)===null||a===void 0?void 0:a.parts)===null||i===void 0?void 0:i.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 d=(u=(c=(e=(s=this.candidates)===null||s===void 0?void 0:s[0])===null||e===void 0?void 0:e.content)===null||c===void 0?void 0:c.parts)===null||u===void 0?void 0:u.filter(I=>I.functionCall).map(I=>I.functionCall).filter(I=>I!==void 0);if(d?.length!==0)return d}get executableCode(){var t,r,a,i,s,e,c,u,d;if(((i=(a=(r=(t=this.candidates)===null||t===void 0?void 0:t[0])===null||r===void 0?void 0:r.content)===null||a===void 0?void 0:a.parts)===null||i===void 0?void 0:i.length)===0)return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning executable code from the first one.");let I=(u=(c=(e=(s=this.candidates)===null||s===void 0?void 0:s[0])===null||e===void 0?void 0:e.content)===null||c===void 0?void 0:c.parts)===null||u===void 0?void 0:u.filter(h=>h.executableCode).map(h=>h.executableCode).filter(h=>h!==void 0);if(I?.length!==0)return(d=I?.[0])===null||d===void 0?void 0:d.code}get codeExecutionResult(){var t,r,a,i,s,e,c,u,d;if(((i=(a=(r=(t=this.candidates)===null||t===void 0?void 0:t[0])===null||r===void 0?void 0:r.content)===null||a===void 0?void 0:a.parts)===null||i===void 0?void 0:i.length)===0)return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning code execution result from the first one.");let I=(u=(c=(e=(s=this.candidates)===null||s===void 0?void 0:s[0])===null||e===void 0?void 0:e.content)===null||c===void 0?void 0:c.parts)===null||u===void 0?void 0:u.filter(h=>h.codeExecutionResult).map(h=>h.codeExecutionResult).filter(h=>h!==void 0);if(I?.length!==0)return(d=I?.[0])===null||d===void 0?void 0:d.output}};(function(n){n.PAGED_ITEM_BATCH_JOBS="batchJobs",n.PAGED_ITEM_MODELS="models",n.PAGED_ITEM_TUNING_JOBS="tuningJobs",n.PAGED_ITEM_FILES="files",n.PAGED_ITEM_CACHED_CONTENTS="cachedContents",n.PAGED_ITEM_FILE_SEARCH_STORES="fileSearchStores",n.PAGED_ITEM_DOCUMENTS="documents"})(bet||(bet={}));b5n="1.30.0",Ina=`google-genai-sdk/${b5n}`;G5n=!1;ste=class n{constructor(t=[],r){this.mcpTools=[],this.functionNameToMcpClient={},this.mcpClients=t,this.config=r}static create(t,r){return new n(t,r)}async initialize(){var t,r,a,i;if(this.mcpTools.length>0)return;let s={},e=[];for(let I of this.mcpClients)try{for(var c=!0,u=(r=void 0,p5n(f5n(I))),d;d=await u.next(),t=d.done,!t;c=!0){i=d.value,c=!1;let h=i;e.push(h);let o=h.name;if(s[o])throw new Error(`Duplicate function name ${o} found in MCP tools. Please ensure function names are unique.`);s[o]=I}}catch(h){r={error:h}}finally{try{!c&&!t&&(a=u.return)&&await a.call(u)}finally{if(r)throw r.error}}this.mcpTools=e,this.functionNameToMcpClient=s}async tool(){return await this.initialize(),h5n(this.mcpTools,this.config)}async callTool(t){await this.initialize();let r=[];for(let a of t)if(a.name in this.functionNameToMcpClient){let i=this.functionNameToMcpClient[a.name],s;this.config.timeout&&(s={timeout:this.config.timeout});let e=await i.callTool({name:a.name,arguments:a.args},void 0,s);r.push({functionResponse:{name:a.name,response:e.isError?{error:e}:e}})}return r}};una=1024*1024*8;});function v5n(n,t){return{...n,...t}}function get(n){let{prompt_id:t,...r}=n;return r}function _E(n){return Array.isArray(n)?n.map(get):n}var ote=It(()=>{"use strict";Bi();});var vet={};eo(vet,{DEFAULT_PROXY_CONFIG:()=>W5n,getActiveProxyServerUrl:()=>VZ,getAvailableProxyServers:()=>Z5n,getProxyServerInfo:()=>N5n,getProxyServers:()=>T7,hasAvailableProxyServer:()=>Zve});function T7(){return[{url:"https://api-code.deepvlab.ai",name:"Primary Development Server",region:"default",status:"active"}]}function VZ(){let t=T7().find(r=>r.status==="active");if(!t)throw new Error("No active proxy server available. Please contact support.");return t.url}function Z5n(){return T7().filter(t=>t.status==="active")}function Zve(){return T7().some(t=>t.status==="active")}function N5n(n){return T7().find(r=>r.url===n)}var W5n,L9=It(()=>{"use strict";W5n={serverUrl:VZ(),timeout:2e5,retryAttempts:3,retryDelay:1e3}});import*as Vo from"fs";import*as fg from"path";import*as PE from"os";function A5n(n){ss.configure(n)}function F5n(n){ss.setUserInfo(n)}function y5n(n){ss.setCliVersion(n)}async function R5n(){return await ss.getUserHeaders()}function E5n(){return ss.getStatus()}var O7,Vs,ss,LF=It(()=>{"use strict";L9();O7=259200,Vs=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;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=fg.join(PE.homedir(),".deepv","user-info-dev.json"),this.jwtTokenFilePath=fg.join(PE.homedir(),".deepv","jwt-token-dev.json"),this.usageStatsFilePath=fg.join(PE.homedir(),".deepv","usage-stats-dev.json")):(this.userInfoFilePath=fg.join(PE.homedir(),".deepv","user-info.json"),this.jwtTokenFilePath=fg.join(PE.homedir(),".deepv","jwt-token.json"),this.usageStatsFilePath=fg.join(PE.homedir(),".deepv","usage-stats.json")),this.cliVersion="1.0.258",this.config={proxyServerUrl:VZ()},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-O7*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(Vo.existsSync(this.userInfoFilePath)){let t=Vo.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=fg.dirname(this.userInfoFilePath);Vo.existsSync(t)||Vo.mkdirSync(t,{recursive:!0}),Vo.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(Vo.existsSync(this.jwtTokenFilePath)){let t=Vo.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=fg.dirname(this.jwtTokenFilePath);Vo.existsSync(t)||Vo.mkdirSync(t,{recursive:!0}),Vo.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(Vo.existsSync(this.usageStatsFilePath)){let t=Vo.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=fg.dirname(this.usageStatsFilePath);Vo.existsSync(t)||Vo.mkdirSync(t,{recursive:!0}),Vo.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"})`)}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-O7*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-O7*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=O7){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),c=this.formatAbsoluteTime(this.jwtTokenData.expiresAt-O7*1e3);return console.log(`[Login Check] \u2705 Credential renewed successfully - valid for: ${s} (until ${e}), next renewal: ${c}${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{Vo.existsSync(this.jwtTokenFilePath)&&Vo.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{Vo.existsSync(this.userInfoFilePath)&&Vo.unlinkSync(this.userInfoFilePath)}catch(t){console.warn("[Login Check] Failed to delete user info file:",t)}try{Vo.existsSync(this.jwtTokenFilePath)&&Vo.unlinkSync(this.jwtTokenFilePath)}catch(t){console.warn("[Login Check] Failed to delete access credential file:",t)}console.log("[Login Check] Authentication cleared")}},ss=Vs.getInstance()});import{promises as jE}from"node:fs";import U7 from"node:path";import w5n from"os";var vb,cte,nr,qG=It(()=>{"use strict";(function(n){n[n.DEBUG=0]="DEBUG",n[n.INFO=1]="INFO",n[n.WARN=2]="WARN",n[n.ERROR=3]="ERROR"})(vb||(vb={}));cte=class{config;logBuffer=[];constructor(t={}){if(this.config={level:vb.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=U7.join(w5n.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 jE.mkdir(U7.dirname(this.config.filePath),{recursive:!0}),await this.rotateLogIfNeeded(),await jE.appendFile(this.config.filePath,t+`
495
+ https://cloud.google.com/compute/docs/metadata/predefined-metadata-keys`};var mve=class{checkIsGCE=void 0;useJWTAccessWithScope;defaultServicePath;get isGCE(){return this.checkIsGCE}_findProjectIdPromise;_cachedProjectId;jsonContent=null;apiKey;cachedCredential=null;#e=null;defaultScopes;keyFilename;scopes;clientOptions={};constructor(t={}){if(this._cachedProjectId=t.projectId||null,this.cachedCredential=t.authClient||null,this.keyFilename=t.keyFilename||t.keyFile,this.scopes=t.scopes,this.clientOptions=t.clientOptions||{},this.jsonContent=t.credentials||null,this.apiKey=t.apiKey||this.clientOptions.apiKey||null,this.apiKey&&(this.jsonContent||this.clientOptions.credentials))throw new RangeError(Gg.GoogleAuthExceptionMessages.API_KEY_WITH_CREDENTIALS);t.universeDomain&&(this.clientOptions.universeDomain=t.universeDomain)}setGapicJWTValues(t){t.defaultServicePath=this.defaultServicePath,t.useJWTAccessWithScope=this.useJWTAccessWithScope,t.defaultScopes=this.defaultScopes}getProjectId(t){if(t)this.getProjectIdAsync().then(r=>t(null,r),t);else return this.getProjectIdAsync()}async getProjectIdOptional(){try{return await this.getProjectId()}catch(t){if(t instanceof Error&&t.message===Gg.GoogleAuthExceptionMessages.NO_PROJECT_ID_FOUND)return null;throw t}}async findAndCacheProjectId(){let t=null;if(t||=await this.getProductionProjectId(),t||=await this.getFileProjectId(),t||=await this.getDefaultServiceProjectId(),t||=await this.getGCEProjectId(),t||=await this.getExternalAccountClientProjectId(),t)return this._cachedProjectId=t,t;throw new Error(Gg.GoogleAuthExceptionMessages.NO_PROJECT_ID_FOUND)}async getProjectIdAsync(){return this._cachedProjectId?this._cachedProjectId:(this._findProjectIdPromise||(this._findProjectIdPromise=this.findAndCacheProjectId()),this._findProjectIdPromise)}async getUniverseDomainFromMetadataServer(){let t;try{t=await S7.universe("universe-domain"),t||=hve.DEFAULT_UNIVERSE}catch(r){if(r&&r?.response?.status===404)t=hve.DEFAULT_UNIVERSE;else throw r}return t}async getUniverseDomain(){let t=(0,a$e.originalOrCamelOptions)(this.clientOptions).get("universe_domain");try{t??=(await this.getClient()).universeDomain}catch{t??=hve.DEFAULT_UNIVERSE}return t}getAnyScopes(){return this.scopes||this.defaultScopes}getApplicationDefault(t={},r){let a;if(typeof t=="function"?r=t:a=t,r)this.getApplicationDefaultAsync(a).then(i=>r(null,i.credential,i.projectId),r);else return this.getApplicationDefaultAsync(a)}async getApplicationDefaultAsync(t={}){if(this.cachedCredential)return await this.#t(this.cachedCredential,null);let r;if(r=await this._tryGetApplicationCredentialsFromEnvironmentVariable(t),r)return r instanceof Q9.JWT?r.scopes=this.scopes:r instanceof B7.BaseExternalAccountClient&&(r.scopes=this.getAnyScopes()),await this.#t(r);if(r=await this._tryGetApplicationCredentialsFromWellKnownFile(t),r)return r instanceof Q9.JWT?r.scopes=this.scopes:r instanceof B7.BaseExternalAccountClient&&(r.scopes=this.getAnyScopes()),await this.#t(r);if(await this._checkIsGCE())return t.scopes=this.getAnyScopes(),await this.#t(new XAn.Compute(t));throw new Error(Gg.GoogleAuthExceptionMessages.NO_ADC_FOUND)}async#t(t,r=process.env.GOOGLE_CLOUD_QUOTA_PROJECT||null){let a=await this.getProjectIdOptional();return r&&(t.quotaProjectId=r),this.cachedCredential=t,{credential:t,projectId:a}}async _checkIsGCE(){return this.checkIsGCE===void 0&&(this.checkIsGCE=S7.getGCPResidency()||await S7.isAvailable()),this.checkIsGCE}async _tryGetApplicationCredentialsFromEnvironmentVariable(t){let r=process.env.GOOGLE_APPLICATION_CREDENTIALS||process.env.google_application_credentials;if(!r||r.length===0)return null;try{return this._getApplicationCredentialsFromFilePath(r,t)}catch(a){throw a instanceof Error&&(a.message=`Unable to read the credential file specified by the GOOGLE_APPLICATION_CREDENTIALS environment variable: ${a.message}`),a}}async _tryGetApplicationCredentialsFromWellKnownFile(t){let r=null;if(this._isWindows())r=process.env.APPDATA;else{let i=process.env.HOME;i&&(r=dve.join(i,".config"))}return r&&(r=dve.join(r,"gcloud","application_default_credentials.json"),J7.existsSync(r)||(r=null)),r?await this._getApplicationCredentialsFromFilePath(r,t):null}async _getApplicationCredentialsFromFilePath(t,r={}){if(!t||t.length===0)throw new Error("The file path is invalid.");try{if(t=J7.realpathSync(t),!J7.lstatSync(t).isFile())throw new Error}catch(i){throw i instanceof Error&&(i.message=`The file at ${t} does not exist, or it is not a file. ${i.message}`),i}let a=J7.createReadStream(t);return this.fromStream(a,r)}fromImpersonatedJSON(t){if(!t)throw new Error("Must pass in a JSON object containing an impersonated refresh token");if(t.type!==H9.IMPERSONATED_ACCOUNT_TYPE)throw new Error(`The incoming JSON object does not have the "${H9.IMPERSONATED_ACCOUNT_TYPE}" type`);if(!t.source_credentials)throw new Error("The incoming JSON object does not contain a source_credentials field");if(!t.service_account_impersonation_url)throw new Error("The incoming JSON object does not contain a service_account_impersonation_url field");let r=this.fromJSON(t.source_credentials);if(t.service_account_impersonation_url?.length>256)throw new RangeError(`Target principal is too long: ${t.service_account_impersonation_url}`);let a=/(?<target>[^/]+):(generateAccessToken|generateIdToken)$/.exec(t.service_account_impersonation_url)?.groups?.target;if(!a)throw new RangeError(`Cannot extract target principal from ${t.service_account_impersonation_url}`);let i=(this.scopes||t.scopes||this.defaultScopes)??[];return new H9.Impersonated({...t,sourceClient:r,targetPrincipal:a,targetScopes:Array.isArray(i)?i:[i]})}fromJSON(t,r={}){let a,i=(0,a$e.originalOrCamelOptions)(r).get("universe_domain");return t.type===n$e.USER_REFRESH_ACCOUNT_TYPE?(a=new n$e.UserRefreshClient(r),a.fromJSON(t)):t.type===H9.IMPERSONATED_ACCOUNT_TYPE?a=this.fromImpersonatedJSON(t):t.type===B7.EXTERNAL_ACCOUNT_TYPE?(a=JAn.ExternalAccountClient.fromJSON({...t,...r}),a.scopes=this.getAnyScopes()):t.type===r$e.EXTERNAL_ACCOUNT_AUTHORIZED_USER_TYPE?a=new r$e.ExternalAccountAuthorizedUserClient({...t,...r}):(r.scopes=this.scopes,a=new Q9.JWT(r),this.setGapicJWTValues(a),a.fromJSON(t)),i&&(a.universeDomain=i),a}_cacheClientFromJSON(t,r){let a=this.fromJSON(t,r);return this.jsonContent=t,this.cachedCredential=a,a}fromStream(t,r={},a){let i={};if(typeof r=="function"?a=r:i=r,a)this.fromStreamAsync(t,i).then(s=>a(null,s),a);else return this.fromStreamAsync(t,i)}fromStreamAsync(t,r){return new Promise((a,i)=>{if(!t)throw new Error("Must pass in a stream containing the Google auth settings.");let s=[];t.setEncoding("utf8").on("error",i).on("data",e=>s.push(e)).on("end",()=>{try{try{let e=JSON.parse(s.join("")),c=this._cacheClientFromJSON(e,r);return a(c)}catch(e){if(!this.keyFilename)throw e;let c=new Q9.JWT({...this.clientOptions,keyFile:this.keyFilename});return this.cachedCredential=c,this.setGapicJWTValues(c),a(c)}}catch(e){return i(e)}})})}fromAPIKey(t,r={}){return new Q9.JWT({...r,apiKey:t})}_isWindows(){let t=QAn.platform();return!!(t&&t.length>=3&&t.substring(0,3).toLowerCase()==="win")}async getDefaultServiceProjectId(){return new Promise(t=>{(0,xAn.exec)("gcloud config config-helper --format json",(r,a)=>{if(!r&&a)try{let i=JSON.parse(a).configuration.properties.core.project;t(i);return}catch{}t(null)})})}getProductionProjectId(){return process.env.GCLOUD_PROJECT||process.env.GOOGLE_CLOUD_PROJECT||process.env.gcloud_project||process.env.google_cloud_project}async getFileProjectId(){if(this.cachedCredential)return this.cachedCredential.projectId;if(this.keyFilename){let r=await this.getClient();if(r&&r.projectId)return r.projectId}let t=await this._tryGetApplicationCredentialsFromEnvironmentVariable();return t?t.projectId:null}async getExternalAccountClientProjectId(){return!this.jsonContent||this.jsonContent.type!==B7.EXTERNAL_ACCOUNT_TYPE?null:await(await this.getClient()).getProjectId()}async getGCEProjectId(){try{return await S7.project("project-id")}catch{return null}}getCredentials(t){if(t)this.getCredentialsAsync().then(r=>t(null,r),t);else return this.getCredentialsAsync()}async getCredentialsAsync(){let t=await this.getClient();if(t instanceof H9.Impersonated)return{client_email:t.getTargetPrincipal()};if(t instanceof B7.BaseExternalAccountClient){let r=t.getServiceAccountEmail();if(r)return{client_email:r,universe_domain:t.universeDomain}}if(this.jsonContent)return{client_email:this.jsonContent.client_email,private_key:this.jsonContent.private_key,universe_domain:this.jsonContent.universe_domain};if(await this._checkIsGCE()){let[r,a]=await Promise.all([S7.instance("service-accounts/default/email"),this.getUniverseDomain()]);return{client_email:r,universe_domain:a}}throw new Error(Gg.GoogleAuthExceptionMessages.NO_CREDENTIALS_FOUND)}async getClient(){if(this.cachedCredential)return this.cachedCredential;this.#e=this.#e||this.#n();try{return await this.#e}finally{this.#e=null}}async#n(){if(this.jsonContent)return this._cacheClientFromJSON(this.jsonContent,this.clientOptions);if(this.keyFilename){let t=dve.resolve(this.keyFilename),r=J7.createReadStream(t);return await this.fromStreamAsync(r,this.clientOptions)}else if(this.apiKey){let t=await this.fromAPIKey(this.apiKey,this.clientOptions);t.scopes=this.scopes;let{credential:r}=await this.#t(t);return r}else{let{credential:t}=await this.getApplicationDefaultAsync(this.clientOptions);return t}}async getIdTokenClient(t){let r=await this.getClient();if(!("fetchIdToken"in r))throw new Error("Cannot fetch ID token in this environment, use GCE or set the GOOGLE_APPLICATION_CREDENTIALS environment variable to a service account credentials JSON file.");return new kAn.IdTokenClient({targetAudience:t,idTokenProvider:r})}async getAccessToken(){return(await(await this.getClient()).getAccessToken()).token}async getRequestHeaders(t){return(await this.getClient()).getRequestHeaders(t)}async authorizeRequest(t={}){let r=t.url,i=await(await this.getClient()).getRequestHeaders(r);return t.headers=VAn.Gaxios.mergeHeaders(t.headers,i),t}async fetch(...t){return(await this.getClient()).fetch(...t)}async request(t){return(await this.getClient()).request(t)}getEnv(){return(0,LAn.getEnv)()}async sign(t,r){let a=await this.getClient(),i=await this.getUniverseDomain();if(r=r||`https://iamcredentials.${i}/v1/projects/-/serviceAccounts/`,a instanceof H9.Impersonated)return(await a.sign(t)).signedBlob;let s=(0,HAn.createCrypto)();if(a instanceof Q9.JWT&&a.key)return await s.sign(a.key,t);let e=await this.getCredentials();if(!e.client_email)throw new Error("Cannot sign data without `client_email`.");return this.signBlob(s,e.client_email,t,r)}async signBlob(t,r,a,i){let s=new URL(i+`${r}:signBlob`);return(await this.request({method:"POST",url:s.href,data:{payload:t.encodeBase64StringUtf8(a)},retry:!0,retryConfig:{httpMethodsToRetry:["POST"]}})).data.signedBlob}};Gg.GoogleAuth=mve});var l$e=ke(ate=>{"use strict";Object.defineProperty(ate,"__esModule",{value:!0});ate.IAMAuth=void 0;var pve=class{selector;token;constructor(t,r){this.selector=t,this.token=r,this.selector=t,this.token=r}getRequestHeaders(){return{"x-goog-iam-authority-selector":this.selector,"x-goog-iam-authorization-token":this.token}}};ate.IAMAuth=pve});var s$e=ke(xZ=>{"use strict";Object.defineProperty(xZ,"__esModule",{value:!0});xZ.DownscopedClient=xZ.EXPIRATION_TIME_OFFSET=xZ.MAX_ACCESS_BOUNDARY_RULES_COUNT=void 0;var SAn=G0(),BAn=Ct("stream"),bve=pb(),DAn=Lee(),TAn="urn:ietf:params:oauth:grant-type:token-exchange",OAn="urn:ietf:params:oauth:token-type:access_token",UAn="urn:ietf:params:oauth:token-type:access_token";xZ.MAX_ACCESS_BOUNDARY_RULES_COUNT=10;xZ.EXPIRATION_TIME_OFFSET=300*1e3;var Gve=class extends bve.AuthClient{authClient;credentialAccessBoundary;cachedDownscopedAccessToken;stsCredential;constructor(t,r={accessBoundary:{accessBoundaryRules:[]}}){if(super(t instanceof bve.AuthClient?{}:t),t instanceof bve.AuthClient?(this.authClient=t,this.credentialAccessBoundary=r):(this.authClient=t.authClient,this.credentialAccessBoundary=t.credentialAccessBoundary),this.credentialAccessBoundary.accessBoundary.accessBoundaryRules.length===0)throw new Error("At least one access boundary rule needs to be defined.");if(this.credentialAccessBoundary.accessBoundary.accessBoundaryRules.length>xZ.MAX_ACCESS_BOUNDARY_RULES_COUNT)throw new Error(`The provided access boundary has more than ${xZ.MAX_ACCESS_BOUNDARY_RULES_COUNT} access boundary rules.`);for(let a of this.credentialAccessBoundary.accessBoundary.accessBoundaryRules)if(a.availablePermissions.length===0)throw new Error("At least one permission should be defined in access boundary rules.");this.stsCredential=new DAn.StsCredentials({tokenExchangeEndpoint:`https://sts.${this.universeDomain}/v1/token`}),this.cachedDownscopedAccessToken=null}setCredentials(t){if(!t.expiry_date)throw new Error("The access token expiry_date field is missing in the provided credentials.");super.setCredentials(t),this.cachedDownscopedAccessToken=t}async getAccessToken(){return(!this.cachedDownscopedAccessToken||this.isExpired(this.cachedDownscopedAccessToken))&&await this.refreshAccessTokenAsync(),{token:this.cachedDownscopedAccessToken.access_token,expirationTime:this.cachedDownscopedAccessToken.expiry_date,res:this.cachedDownscopedAccessToken.res}}async getRequestHeaders(){let t=await this.getAccessToken(),r=new Headers({authorization:`Bearer ${t.token}`});return this.addSharedMetadataHeaders(r)}request(t,r){if(r)this.requestAsync(t).then(a=>r(null,a),a=>r(a,a.response));else return this.requestAsync(t)}async requestAsync(t,r=!1){let a;try{let i=await this.getRequestHeaders();t.headers=SAn.Gaxios.mergeHeaders(t.headers),this.addUserProjectAndAuthHeaders(t.headers,i),a=await this.transporter.request(t)}catch(i){let s=i.response;if(s){let e=s.status,c=s.config.data instanceof BAn.Readable;if(!r&&(e===401||e===403)&&!c&&this.forceRefreshOnFailure)return await this.refreshAccessTokenAsync(),await this.requestAsync(t,!0)}throw i}return a}async refreshAccessTokenAsync(){let t=(await this.authClient.getAccessToken()).token,r={grantType:TAn,requestedTokenType:OAn,subjectToken:t,subjectTokenType:UAn},a=await this.stsCredential.exchangeToken(r,void 0,this.credentialAccessBoundary),i=this.authClient.credentials?.expiry_date||null,s=a.expires_in?new Date().getTime()+a.expires_in*1e3:i;return this.cachedDownscopedAccessToken={access_token:a.access_token,expiry_date:s,res:a.res},this.credentials={},Object.assign(this.credentials,this.cachedDownscopedAccessToken),delete this.credentials.res,this.emit("tokens",{refresh_token:null,expiry_date:this.cachedDownscopedAccessToken.expiry_date,access_token:this.cachedDownscopedAccessToken.access_token,token_type:"Bearer",id_token:null}),this.cachedDownscopedAccessToken}isExpired(t){let r=new Date().getTime();return t.expiry_date?r>=t.expiry_date-this.eagerRefreshThresholdMillis:!1}};xZ.DownscopedClient=Gve});var o$e=ke(ite=>{"use strict";Object.defineProperty(ite,"__esModule",{value:!0});ite.PassThroughClient=void 0;var MAn=pb(),fve=class extends MAn.AuthClient{async request(t){return this.transporter.request(t)}async getAccessToken(){return{}}async getRequestHeaders(){return new Headers}};ite.PassThroughClient=fve});var h$e=ke(ha=>{"use strict";Object.defineProperty(ha,"__esModule",{value:!0});ha.GoogleAuth=ha.auth=ha.PassThroughClient=ha.ExternalAccountAuthorizedUserClient=ha.EXTERNAL_ACCOUNT_AUTHORIZED_USER_TYPE=ha.ExecutableError=ha.PluggableAuthClient=ha.DownscopedClient=ha.BaseExternalAccountClient=ha.ExternalAccountClient=ha.IdentityPoolClient=ha.AwsRequestSigner=ha.AwsClient=ha.UserRefreshClient=ha.LoginTicket=ha.ClientAuthentication=ha.OAuth2Client=ha.CodeChallengeMethod=ha.Impersonated=ha.JWT=ha.JWTAccess=ha.IdTokenClient=ha.IAMAuth=ha.GCPEnv=ha.Compute=ha.DEFAULT_UNIVERSE=ha.AuthClient=ha.gaxios=ha.gcpMetadata=void 0;var c$e=i$e();Object.defineProperty(ha,"GoogleAuth",{enumerable:!0,get:function(){return c$e.GoogleAuth}});ha.gcpMetadata=F7();ha.gaxios=G0();var I$e=pb();Object.defineProperty(ha,"AuthClient",{enumerable:!0,get:function(){return I$e.AuthClient}});Object.defineProperty(ha,"DEFAULT_UNIVERSE",{enumerable:!0,get:function(){return I$e.DEFAULT_UNIVERSE}});var zAn=ige();Object.defineProperty(ha,"Compute",{enumerable:!0,get:function(){return zAn.Compute}});var _An=oge();Object.defineProperty(ha,"GCPEnv",{enumerable:!0,get:function(){return _An.GCPEnv}});var PAn=l$e();Object.defineProperty(ha,"IAMAuth",{enumerable:!0,get:function(){return PAn.IAMAuth}});var jAn=sge();Object.defineProperty(ha,"IdTokenClient",{enumerable:!0,get:function(){return jAn.IdTokenClient}});var KAn=Fge();Object.defineProperty(ha,"JWTAccess",{enumerable:!0,get:function(){return KAn.JWTAccess}});var qAn=Rge();Object.defineProperty(ha,"JWT",{enumerable:!0,get:function(){return qAn.JWT}});var $An=Cge();Object.defineProperty(ha,"Impersonated",{enumerable:!0,get:function(){return $An.Impersonated}});var gve=ME();Object.defineProperty(ha,"CodeChallengeMethod",{enumerable:!0,get:function(){return gve.CodeChallengeMethod}});Object.defineProperty(ha,"OAuth2Client",{enumerable:!0,get:function(){return gve.OAuth2Client}});Object.defineProperty(ha,"ClientAuthentication",{enumerable:!0,get:function(){return gve.ClientAuthentication}});var e5n=tge();Object.defineProperty(ha,"LoginTicket",{enumerable:!0,get:function(){return e5n.LoginTicket}});var t5n=wge();Object.defineProperty(ha,"UserRefreshClient",{enumerable:!0,get:function(){return t5n.UserRefreshClient}});var n5n=jge();Object.defineProperty(ha,"AwsClient",{enumerable:!0,get:function(){return n5n.AwsClient}});var r5n=zge();Object.defineProperty(ha,"AwsRequestSigner",{enumerable:!0,get:function(){return r5n.AwsRequestSigner}});var a5n=Uge();Object.defineProperty(ha,"IdentityPoolClient",{enumerable:!0,get:function(){return a5n.IdentityPoolClient}});var i5n=ove();Object.defineProperty(ha,"ExternalAccountClient",{enumerable:!0,get:function(){return i5n.ExternalAccountClient}});var l5n=kF();Object.defineProperty(ha,"BaseExternalAccountClient",{enumerable:!0,get:function(){return l5n.BaseExternalAccountClient}});var s5n=s$e();Object.defineProperty(ha,"DownscopedClient",{enumerable:!0,get:function(){return s5n.DownscopedClient}});var u$e=lve();Object.defineProperty(ha,"PluggableAuthClient",{enumerable:!0,get:function(){return u$e.PluggableAuthClient}});Object.defineProperty(ha,"ExecutableError",{enumerable:!0,get:function(){return u$e.ExecutableError}});var d$e=uve();Object.defineProperty(ha,"EXTERNAL_ACCOUNT_AUTHORIZED_USER_TYPE",{enumerable:!0,get:function(){return d$e.EXTERNAL_ACCOUNT_AUTHORIZED_USER_TYPE}});Object.defineProperty(ha,"ExternalAccountAuthorizedUserClient",{enumerable:!0,get:function(){return d$e.ExternalAccountAuthorizedUserClient}});var o5n=o$e();Object.defineProperty(ha,"PassThroughClient",{enumerable:!0,get:function(){return o5n.PassThroughClient}});var c5n=new c$e.GoogleAuth;ha.auth=c5n});function met(n){return{text:n}}function pet(n){return typeof n=="object"&&n!==null?"fileData"in n||"text"in n||"functionCall"in n||"functionResponse"in n||"inlineData"in n||"videoMetadata"in n||"codeExecutionResult"in n||"executableCode"in n:!1}function u5n(n){let t=[];if(typeof n=="string")t.push(met(n));else if(pet(n))t.push(n);else if(Array.isArray(n)){if(n.length===0)throw new Error("partOrString cannot be an empty array");for(let r of n)if(typeof r=="string")t.push(met(r));else if(pet(r))t.push(r);else throw new Error("element in PartUnion must be a Part object or string")}else throw new Error("partOrString must be a Part object, string, or array");return t}function vve(n){return{role:"user",parts:u5n(n)}}function d5n(n,t={}){let r=n,a={name:r.name,description:r.description,parametersJsonSchema:r.inputSchema};return r.outputSchema&&(a.responseJsonSchema=r.outputSchema),t.behavior&&(a.behavior=t.behavior),{functionDeclarations:[a]}}function h5n(n,t={}){let r=[],a=new Set;for(let i of n){let s=i.name;if(a.has(s))throw new Error(`Duplicate function name ${s} found in MCP tools. Please ensure function names are unique.`);a.add(s);let e=d5n(i,t);e.functionDeclarations&&r.push(...e.functionDeclarations)}return{functionDeclarations:r}}function Get(n){var t=typeof Symbol=="function"&&Symbol.iterator,r=t&&n[t],a=0;if(r)return r.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&a>=n.length&&(n=void 0),{value:n&&n[a++],done:!n}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function D7(n){return this instanceof D7?(this.v=n,this):new D7(n)}function m5n(n,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var a=r.apply(n,t||[]),i,s=[];return i=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),c("next"),c("throw"),c("return",e),i[Symbol.asyncIterator]=function(){return this},i;function e(v){return function(w){return Promise.resolve(w).then(v,h)}}function c(v,w){a[v]&&(i[v]=function(R){return new Promise(function(E,A){s.push([v,R,E,A])>1||u(v,R)})},w&&(i[v]=w(i[v])))}function u(v,w){try{d(a[v](w))}catch(R){o(s[0][3],R)}}function d(v){v.value instanceof D7?Promise.resolve(v.value.v).then(I,h):o(s[0][2],v)}function I(v){u("next",v)}function h(v){u("throw",v)}function o(v,w){v(w),s.shift(),s.length&&u(s[0][0],s[0][1])}}function p5n(n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=n[Symbol.asyncIterator],r;return t?t.call(n):(n=typeof Get=="function"?Get(n):n[Symbol.iterator](),r={},a("next"),a("throw"),a("return"),r[Symbol.asyncIterator]=function(){return this},r);function a(s){r[s]=n[s]&&function(e){return new Promise(function(c,u){e=n[s](e),i(c,u,e.done,e.value)})}}function i(s,e,c,u){Promise.resolve(u).then(function(d){s({value:d,done:c})},e)}}function f5n(n,t=100){return m5n(this,arguments,function*(){let a,i=0;for(;i<t;){let s=yield D7(n.listTools({cursor:a}));for(let e of s.tools)yield yield D7(e),i++;if(!s.nextCursor)break;a=s.nextCursor}})}function g5n(n){return n!==null&&typeof n=="object"&&"listTools"in n&&typeof n.listTools=="function"}function fet(...n){if(G5n=!0,n.length===0)throw new Error("No MCP clients provided");let t=n[n.length-1];return g5n(t)?ste.create(n,{}):ste.create(n.slice(0,n.length-1),t)}var I5n,m$e,p$e,b$e,Fn,G$e,f$e,g$e,v$e,Z$e,N$e,W$e,A$e,F$e,AI,y$e,R$e,E$e,w$e,Y$e,C$e,x$e,V$e,Q$e,H$e,X$e,k$e,L$e,J$e,S$e,B$e,X9,D$e,T$e,O$e,U$e,M$e,z$e,_$e,P$e,j$e,K$e,q$e,$$e,eet,tet,net,aet,iet,set,oet,cet,Iet,uet,det,het,lte,k9,bet,b5n,Ina,G5n,ste,una,Bi=It(()=>{I5n=Dt(h$e(),1);n7();(function(n){n.OUTCOME_UNSPECIFIED="OUTCOME_UNSPECIFIED",n.OUTCOME_OK="OUTCOME_OK",n.OUTCOME_FAILED="OUTCOME_FAILED",n.OUTCOME_DEADLINE_EXCEEDED="OUTCOME_DEADLINE_EXCEEDED"})(m$e||(m$e={}));(function(n){n.LANGUAGE_UNSPECIFIED="LANGUAGE_UNSPECIFIED",n.PYTHON="PYTHON"})(p$e||(p$e={}));(function(n){n.SCHEDULING_UNSPECIFIED="SCHEDULING_UNSPECIFIED",n.SILENT="SILENT",n.WHEN_IDLE="WHEN_IDLE",n.INTERRUPT="INTERRUPT"})(b$e||(b$e={}));(function(n){n.TYPE_UNSPECIFIED="TYPE_UNSPECIFIED",n.STRING="STRING",n.NUMBER="NUMBER",n.INTEGER="INTEGER",n.BOOLEAN="BOOLEAN",n.ARRAY="ARRAY",n.OBJECT="OBJECT",n.NULL="NULL"})(Fn||(Fn={}));(function(n){n.MODE_UNSPECIFIED="MODE_UNSPECIFIED",n.MODE_DYNAMIC="MODE_DYNAMIC"})(G$e||(G$e={}));(function(n){n.API_SPEC_UNSPECIFIED="API_SPEC_UNSPECIFIED",n.SIMPLE_SEARCH="SIMPLE_SEARCH",n.ELASTIC_SEARCH="ELASTIC_SEARCH"})(f$e||(f$e={}));(function(n){n.AUTH_TYPE_UNSPECIFIED="AUTH_TYPE_UNSPECIFIED",n.NO_AUTH="NO_AUTH",n.API_KEY_AUTH="API_KEY_AUTH",n.HTTP_BASIC_AUTH="HTTP_BASIC_AUTH",n.GOOGLE_SERVICE_ACCOUNT_AUTH="GOOGLE_SERVICE_ACCOUNT_AUTH",n.OAUTH="OAUTH",n.OIDC_AUTH="OIDC_AUTH"})(g$e||(g$e={}));(function(n){n.HTTP_IN_UNSPECIFIED="HTTP_IN_UNSPECIFIED",n.HTTP_IN_QUERY="HTTP_IN_QUERY",n.HTTP_IN_HEADER="HTTP_IN_HEADER",n.HTTP_IN_PATH="HTTP_IN_PATH",n.HTTP_IN_BODY="HTTP_IN_BODY",n.HTTP_IN_COOKIE="HTTP_IN_COOKIE"})(v$e||(v$e={}));(function(n){n.PHISH_BLOCK_THRESHOLD_UNSPECIFIED="PHISH_BLOCK_THRESHOLD_UNSPECIFIED",n.BLOCK_LOW_AND_ABOVE="BLOCK_LOW_AND_ABOVE",n.BLOCK_MEDIUM_AND_ABOVE="BLOCK_MEDIUM_AND_ABOVE",n.BLOCK_HIGH_AND_ABOVE="BLOCK_HIGH_AND_ABOVE",n.BLOCK_HIGHER_AND_ABOVE="BLOCK_HIGHER_AND_ABOVE",n.BLOCK_VERY_HIGH_AND_ABOVE="BLOCK_VERY_HIGH_AND_ABOVE",n.BLOCK_ONLY_EXTREMELY_HIGH="BLOCK_ONLY_EXTREMELY_HIGH"})(Z$e||(Z$e={}));(function(n){n.THINKING_LEVEL_UNSPECIFIED="THINKING_LEVEL_UNSPECIFIED",n.LOW="LOW",n.HIGH="HIGH"})(N$e||(N$e={}));(function(n){n.HARM_CATEGORY_UNSPECIFIED="HARM_CATEGORY_UNSPECIFIED",n.HARM_CATEGORY_HARASSMENT="HARM_CATEGORY_HARASSMENT",n.HARM_CATEGORY_HATE_SPEECH="HARM_CATEGORY_HATE_SPEECH",n.HARM_CATEGORY_SEXUALLY_EXPLICIT="HARM_CATEGORY_SEXUALLY_EXPLICIT",n.HARM_CATEGORY_DANGEROUS_CONTENT="HARM_CATEGORY_DANGEROUS_CONTENT",n.HARM_CATEGORY_CIVIC_INTEGRITY="HARM_CATEGORY_CIVIC_INTEGRITY",n.HARM_CATEGORY_IMAGE_HATE="HARM_CATEGORY_IMAGE_HATE",n.HARM_CATEGORY_IMAGE_DANGEROUS_CONTENT="HARM_CATEGORY_IMAGE_DANGEROUS_CONTENT",n.HARM_CATEGORY_IMAGE_HARASSMENT="HARM_CATEGORY_IMAGE_HARASSMENT",n.HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT="HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT",n.HARM_CATEGORY_JAILBREAK="HARM_CATEGORY_JAILBREAK"})(W$e||(W$e={}));(function(n){n.HARM_BLOCK_METHOD_UNSPECIFIED="HARM_BLOCK_METHOD_UNSPECIFIED",n.SEVERITY="SEVERITY",n.PROBABILITY="PROBABILITY"})(A$e||(A$e={}));(function(n){n.HARM_BLOCK_THRESHOLD_UNSPECIFIED="HARM_BLOCK_THRESHOLD_UNSPECIFIED",n.BLOCK_LOW_AND_ABOVE="BLOCK_LOW_AND_ABOVE",n.BLOCK_MEDIUM_AND_ABOVE="BLOCK_MEDIUM_AND_ABOVE",n.BLOCK_ONLY_HIGH="BLOCK_ONLY_HIGH",n.BLOCK_NONE="BLOCK_NONE",n.OFF="OFF"})(F$e||(F$e={}));(function(n){n.FINISH_REASON_UNSPECIFIED="FINISH_REASON_UNSPECIFIED",n.STOP="STOP",n.MAX_TOKENS="MAX_TOKENS",n.SAFETY="SAFETY",n.RECITATION="RECITATION",n.LANGUAGE="LANGUAGE",n.OTHER="OTHER",n.BLOCKLIST="BLOCKLIST",n.PROHIBITED_CONTENT="PROHIBITED_CONTENT",n.SPII="SPII",n.MALFORMED_FUNCTION_CALL="MALFORMED_FUNCTION_CALL",n.IMAGE_SAFETY="IMAGE_SAFETY",n.UNEXPECTED_TOOL_CALL="UNEXPECTED_TOOL_CALL",n.IMAGE_PROHIBITED_CONTENT="IMAGE_PROHIBITED_CONTENT",n.NO_IMAGE="NO_IMAGE"})(AI||(AI={}));(function(n){n.HARM_PROBABILITY_UNSPECIFIED="HARM_PROBABILITY_UNSPECIFIED",n.NEGLIGIBLE="NEGLIGIBLE",n.LOW="LOW",n.MEDIUM="MEDIUM",n.HIGH="HIGH"})(y$e||(y$e={}));(function(n){n.HARM_SEVERITY_UNSPECIFIED="HARM_SEVERITY_UNSPECIFIED",n.HARM_SEVERITY_NEGLIGIBLE="HARM_SEVERITY_NEGLIGIBLE",n.HARM_SEVERITY_LOW="HARM_SEVERITY_LOW",n.HARM_SEVERITY_MEDIUM="HARM_SEVERITY_MEDIUM",n.HARM_SEVERITY_HIGH="HARM_SEVERITY_HIGH"})(R$e||(R$e={}));(function(n){n.URL_RETRIEVAL_STATUS_UNSPECIFIED="URL_RETRIEVAL_STATUS_UNSPECIFIED",n.URL_RETRIEVAL_STATUS_SUCCESS="URL_RETRIEVAL_STATUS_SUCCESS",n.URL_RETRIEVAL_STATUS_ERROR="URL_RETRIEVAL_STATUS_ERROR",n.URL_RETRIEVAL_STATUS_PAYWALL="URL_RETRIEVAL_STATUS_PAYWALL",n.URL_RETRIEVAL_STATUS_UNSAFE="URL_RETRIEVAL_STATUS_UNSAFE"})(E$e||(E$e={}));(function(n){n.BLOCKED_REASON_UNSPECIFIED="BLOCKED_REASON_UNSPECIFIED",n.SAFETY="SAFETY",n.OTHER="OTHER",n.BLOCKLIST="BLOCKLIST",n.PROHIBITED_CONTENT="PROHIBITED_CONTENT",n.IMAGE_SAFETY="IMAGE_SAFETY",n.MODEL_ARMOR="MODEL_ARMOR",n.JAILBREAK="JAILBREAK"})(w$e||(w$e={}));(function(n){n.TRAFFIC_TYPE_UNSPECIFIED="TRAFFIC_TYPE_UNSPECIFIED",n.ON_DEMAND="ON_DEMAND",n.PROVISIONED_THROUGHPUT="PROVISIONED_THROUGHPUT"})(Y$e||(Y$e={}));(function(n){n.MODALITY_UNSPECIFIED="MODALITY_UNSPECIFIED",n.TEXT="TEXT",n.IMAGE="IMAGE",n.AUDIO="AUDIO"})(C$e||(C$e={}));(function(n){n.MEDIA_RESOLUTION_UNSPECIFIED="MEDIA_RESOLUTION_UNSPECIFIED",n.MEDIA_RESOLUTION_LOW="MEDIA_RESOLUTION_LOW",n.MEDIA_RESOLUTION_MEDIUM="MEDIA_RESOLUTION_MEDIUM",n.MEDIA_RESOLUTION_HIGH="MEDIA_RESOLUTION_HIGH"})(x$e||(x$e={}));(function(n){n.TUNING_MODE_UNSPECIFIED="TUNING_MODE_UNSPECIFIED",n.TUNING_MODE_FULL="TUNING_MODE_FULL",n.TUNING_MODE_PEFT_ADAPTER="TUNING_MODE_PEFT_ADAPTER"})(V$e||(V$e={}));(function(n){n.ADAPTER_SIZE_UNSPECIFIED="ADAPTER_SIZE_UNSPECIFIED",n.ADAPTER_SIZE_ONE="ADAPTER_SIZE_ONE",n.ADAPTER_SIZE_TWO="ADAPTER_SIZE_TWO",n.ADAPTER_SIZE_FOUR="ADAPTER_SIZE_FOUR",n.ADAPTER_SIZE_EIGHT="ADAPTER_SIZE_EIGHT",n.ADAPTER_SIZE_SIXTEEN="ADAPTER_SIZE_SIXTEEN",n.ADAPTER_SIZE_THIRTY_TWO="ADAPTER_SIZE_THIRTY_TWO"})(Q$e||(Q$e={}));(function(n){n.JOB_STATE_UNSPECIFIED="JOB_STATE_UNSPECIFIED",n.JOB_STATE_QUEUED="JOB_STATE_QUEUED",n.JOB_STATE_PENDING="JOB_STATE_PENDING",n.JOB_STATE_RUNNING="JOB_STATE_RUNNING",n.JOB_STATE_SUCCEEDED="JOB_STATE_SUCCEEDED",n.JOB_STATE_FAILED="JOB_STATE_FAILED",n.JOB_STATE_CANCELLING="JOB_STATE_CANCELLING",n.JOB_STATE_CANCELLED="JOB_STATE_CANCELLED",n.JOB_STATE_PAUSED="JOB_STATE_PAUSED",n.JOB_STATE_EXPIRED="JOB_STATE_EXPIRED",n.JOB_STATE_UPDATING="JOB_STATE_UPDATING",n.JOB_STATE_PARTIALLY_SUCCEEDED="JOB_STATE_PARTIALLY_SUCCEEDED"})(H$e||(H$e={}));(function(n){n.TUNING_TASK_UNSPECIFIED="TUNING_TASK_UNSPECIFIED",n.TUNING_TASK_I2V="TUNING_TASK_I2V",n.TUNING_TASK_T2V="TUNING_TASK_T2V",n.TUNING_TASK_R2V="TUNING_TASK_R2V"})(X$e||(X$e={}));(function(n){n.MEDIA_RESOLUTION_UNSPECIFIED="MEDIA_RESOLUTION_UNSPECIFIED",n.MEDIA_RESOLUTION_LOW="MEDIA_RESOLUTION_LOW",n.MEDIA_RESOLUTION_MEDIUM="MEDIA_RESOLUTION_MEDIUM",n.MEDIA_RESOLUTION_HIGH="MEDIA_RESOLUTION_HIGH"})(k$e||(k$e={}));(function(n){n.FEATURE_SELECTION_PREFERENCE_UNSPECIFIED="FEATURE_SELECTION_PREFERENCE_UNSPECIFIED",n.PRIORITIZE_QUALITY="PRIORITIZE_QUALITY",n.BALANCED="BALANCED",n.PRIORITIZE_COST="PRIORITIZE_COST"})(L$e||(L$e={}));(function(n){n.UNSPECIFIED="UNSPECIFIED",n.BLOCKING="BLOCKING",n.NON_BLOCKING="NON_BLOCKING"})(J$e||(J$e={}));(function(n){n.MODE_UNSPECIFIED="MODE_UNSPECIFIED",n.MODE_DYNAMIC="MODE_DYNAMIC"})(S$e||(S$e={}));(function(n){n.ENVIRONMENT_UNSPECIFIED="ENVIRONMENT_UNSPECIFIED",n.ENVIRONMENT_BROWSER="ENVIRONMENT_BROWSER"})(B$e||(B$e={}));(function(n){n.MODE_UNSPECIFIED="MODE_UNSPECIFIED",n.AUTO="AUTO",n.ANY="ANY",n.NONE="NONE",n.VALIDATED="VALIDATED"})(X9||(X9={}));(function(n){n.BLOCK_LOW_AND_ABOVE="BLOCK_LOW_AND_ABOVE",n.BLOCK_MEDIUM_AND_ABOVE="BLOCK_MEDIUM_AND_ABOVE",n.BLOCK_ONLY_HIGH="BLOCK_ONLY_HIGH",n.BLOCK_NONE="BLOCK_NONE"})(D$e||(D$e={}));(function(n){n.DONT_ALLOW="DONT_ALLOW",n.ALLOW_ADULT="ALLOW_ADULT",n.ALLOW_ALL="ALLOW_ALL"})(T$e||(T$e={}));(function(n){n.auto="auto",n.en="en",n.ja="ja",n.ko="ko",n.hi="hi",n.zh="zh",n.pt="pt",n.es="es"})(O$e||(O$e={}));(function(n){n.MASK_MODE_DEFAULT="MASK_MODE_DEFAULT",n.MASK_MODE_USER_PROVIDED="MASK_MODE_USER_PROVIDED",n.MASK_MODE_BACKGROUND="MASK_MODE_BACKGROUND",n.MASK_MODE_FOREGROUND="MASK_MODE_FOREGROUND",n.MASK_MODE_SEMANTIC="MASK_MODE_SEMANTIC"})(U$e||(U$e={}));(function(n){n.CONTROL_TYPE_DEFAULT="CONTROL_TYPE_DEFAULT",n.CONTROL_TYPE_CANNY="CONTROL_TYPE_CANNY",n.CONTROL_TYPE_SCRIBBLE="CONTROL_TYPE_SCRIBBLE",n.CONTROL_TYPE_FACE_MESH="CONTROL_TYPE_FACE_MESH"})(M$e||(M$e={}));(function(n){n.SUBJECT_TYPE_DEFAULT="SUBJECT_TYPE_DEFAULT",n.SUBJECT_TYPE_PERSON="SUBJECT_TYPE_PERSON",n.SUBJECT_TYPE_ANIMAL="SUBJECT_TYPE_ANIMAL",n.SUBJECT_TYPE_PRODUCT="SUBJECT_TYPE_PRODUCT"})(z$e||(z$e={}));(function(n){n.EDIT_MODE_DEFAULT="EDIT_MODE_DEFAULT",n.EDIT_MODE_INPAINT_REMOVAL="EDIT_MODE_INPAINT_REMOVAL",n.EDIT_MODE_INPAINT_INSERTION="EDIT_MODE_INPAINT_INSERTION",n.EDIT_MODE_OUTPAINT="EDIT_MODE_OUTPAINT",n.EDIT_MODE_CONTROLLED_EDITING="EDIT_MODE_CONTROLLED_EDITING",n.EDIT_MODE_STYLE="EDIT_MODE_STYLE",n.EDIT_MODE_BGSWAP="EDIT_MODE_BGSWAP",n.EDIT_MODE_PRODUCT_IMAGE="EDIT_MODE_PRODUCT_IMAGE"})(_$e||(_$e={}));(function(n){n.FOREGROUND="FOREGROUND",n.BACKGROUND="BACKGROUND",n.PROMPT="PROMPT",n.SEMANTIC="SEMANTIC",n.INTERACTIVE="INTERACTIVE"})(P$e||(P$e={}));(function(n){n.ASSET="ASSET",n.STYLE="STYLE"})(j$e||(j$e={}));(function(n){n.INSERT="INSERT",n.REMOVE="REMOVE",n.REMOVE_STATIC="REMOVE_STATIC",n.OUTPAINT="OUTPAINT"})(K$e||(K$e={}));(function(n){n.OPTIMIZED="OPTIMIZED",n.LOSSLESS="LOSSLESS"})(q$e||(q$e={}));(function(n){n.SUPERVISED_FINE_TUNING="SUPERVISED_FINE_TUNING",n.PREFERENCE_TUNING="PREFERENCE_TUNING"})($$e||($$e={}));(function(n){n.STATE_UNSPECIFIED="STATE_UNSPECIFIED",n.STATE_PENDING="STATE_PENDING",n.STATE_ACTIVE="STATE_ACTIVE",n.STATE_FAILED="STATE_FAILED"})(eet||(eet={}));(function(n){n.STATE_UNSPECIFIED="STATE_UNSPECIFIED",n.PROCESSING="PROCESSING",n.ACTIVE="ACTIVE",n.FAILED="FAILED"})(tet||(tet={}));(function(n){n.SOURCE_UNSPECIFIED="SOURCE_UNSPECIFIED",n.UPLOADED="UPLOADED",n.GENERATED="GENERATED"})(net||(net={}));(function(n){n.TURN_COMPLETE_REASON_UNSPECIFIED="TURN_COMPLETE_REASON_UNSPECIFIED",n.MALFORMED_FUNCTION_CALL="MALFORMED_FUNCTION_CALL",n.RESPONSE_REJECTED="RESPONSE_REJECTED",n.NEED_MORE_INPUT="NEED_MORE_INPUT"})(aet||(aet={}));(function(n){n.MODALITY_UNSPECIFIED="MODALITY_UNSPECIFIED",n.TEXT="TEXT",n.IMAGE="IMAGE",n.VIDEO="VIDEO",n.AUDIO="AUDIO",n.DOCUMENT="DOCUMENT"})(iet||(iet={}));(function(n){n.START_SENSITIVITY_UNSPECIFIED="START_SENSITIVITY_UNSPECIFIED",n.START_SENSITIVITY_HIGH="START_SENSITIVITY_HIGH",n.START_SENSITIVITY_LOW="START_SENSITIVITY_LOW"})(set||(set={}));(function(n){n.END_SENSITIVITY_UNSPECIFIED="END_SENSITIVITY_UNSPECIFIED",n.END_SENSITIVITY_HIGH="END_SENSITIVITY_HIGH",n.END_SENSITIVITY_LOW="END_SENSITIVITY_LOW"})(oet||(oet={}));(function(n){n.ACTIVITY_HANDLING_UNSPECIFIED="ACTIVITY_HANDLING_UNSPECIFIED",n.START_OF_ACTIVITY_INTERRUPTS="START_OF_ACTIVITY_INTERRUPTS",n.NO_INTERRUPTION="NO_INTERRUPTION"})(cet||(cet={}));(function(n){n.TURN_COVERAGE_UNSPECIFIED="TURN_COVERAGE_UNSPECIFIED",n.TURN_INCLUDES_ONLY_ACTIVITY="TURN_INCLUDES_ONLY_ACTIVITY",n.TURN_INCLUDES_ALL_INPUT="TURN_INCLUDES_ALL_INPUT"})(Iet||(Iet={}));(function(n){n.SCALE_UNSPECIFIED="SCALE_UNSPECIFIED",n.C_MAJOR_A_MINOR="C_MAJOR_A_MINOR",n.D_FLAT_MAJOR_B_FLAT_MINOR="D_FLAT_MAJOR_B_FLAT_MINOR",n.D_MAJOR_B_MINOR="D_MAJOR_B_MINOR",n.E_FLAT_MAJOR_C_MINOR="E_FLAT_MAJOR_C_MINOR",n.E_MAJOR_D_FLAT_MINOR="E_MAJOR_D_FLAT_MINOR",n.F_MAJOR_D_MINOR="F_MAJOR_D_MINOR",n.G_FLAT_MAJOR_E_FLAT_MINOR="G_FLAT_MAJOR_E_FLAT_MINOR",n.G_MAJOR_E_MINOR="G_MAJOR_E_MINOR",n.A_FLAT_MAJOR_F_MINOR="A_FLAT_MAJOR_F_MINOR",n.A_MAJOR_G_FLAT_MINOR="A_MAJOR_G_FLAT_MINOR",n.B_FLAT_MAJOR_G_MINOR="B_FLAT_MAJOR_G_MINOR",n.B_MAJOR_A_FLAT_MINOR="B_MAJOR_A_FLAT_MINOR"})(uet||(uet={}));(function(n){n.MUSIC_GENERATION_MODE_UNSPECIFIED="MUSIC_GENERATION_MODE_UNSPECIFIED",n.QUALITY="QUALITY",n.DIVERSITY="DIVERSITY",n.VOCALIZATION="VOCALIZATION"})(det||(det={}));(function(n){n.PLAYBACK_CONTROL_UNSPECIFIED="PLAYBACK_CONTROL_UNSPECIFIED",n.PLAY="PLAY",n.PAUSE="PAUSE",n.STOP="STOP",n.RESET_CONTEXT="RESET_CONTEXT"})(het||(het={}));lte=class{},k9=class{get text(){var t,r,a,i,s,e,c,u;if(((i=(a=(r=(t=this.candidates)===null||t===void 0?void 0:t[0])===null||r===void 0?void 0:r.content)===null||a===void 0?void 0:a.parts)===null||i===void 0?void 0:i.length)===0)return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning text from the first one.");let d="",I=!1,h=[];for(let o of(u=(c=(e=(s=this.candidates)===null||s===void 0?void 0:s[0])===null||e===void 0?void 0:e.content)===null||c===void 0?void 0:c.parts)!==null&&u!==void 0?u:[]){for(let[v,w]of Object.entries(o))v!=="text"&&v!=="thought"&&v!=="thoughtSignature"&&(w!==null||w!==void 0)&&h.push(v);if(typeof o.text=="string"){if(typeof o.thought=="boolean"&&o.thought)continue;I=!0,d+=o.text}}return h.length>0&&console.warn(`there are non-text parts ${h} in the response, returning concatenation of all text parts. Please refer to the non text parts for a full response from model.`),I?d:void 0}get data(){var t,r,a,i,s,e,c,u;if(((i=(a=(r=(t=this.candidates)===null||t===void 0?void 0:t[0])===null||r===void 0?void 0:r.content)===null||a===void 0?void 0:a.parts)===null||i===void 0?void 0:i.length)===0)return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning data from the first one.");let d="",I=[];for(let h of(u=(c=(e=(s=this.candidates)===null||s===void 0?void 0:s[0])===null||e===void 0?void 0:e.content)===null||c===void 0?void 0:c.parts)!==null&&u!==void 0?u:[]){for(let[o,v]of Object.entries(h))o!=="inlineData"&&(v!==null||v!==void 0)&&I.push(o);h.inlineData&&typeof h.inlineData.data=="string"&&(d+=atob(h.inlineData.data))}return I.length>0&&console.warn(`there are non-data parts ${I} in the response, returning concatenation of all data parts. Please refer to the non data parts for a full response from model.`),d.length>0?btoa(d):void 0}get functionCalls(){var t,r,a,i,s,e,c,u;if(((i=(a=(r=(t=this.candidates)===null||t===void 0?void 0:t[0])===null||r===void 0?void 0:r.content)===null||a===void 0?void 0:a.parts)===null||i===void 0?void 0:i.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 d=(u=(c=(e=(s=this.candidates)===null||s===void 0?void 0:s[0])===null||e===void 0?void 0:e.content)===null||c===void 0?void 0:c.parts)===null||u===void 0?void 0:u.filter(I=>I.functionCall).map(I=>I.functionCall).filter(I=>I!==void 0);if(d?.length!==0)return d}get executableCode(){var t,r,a,i,s,e,c,u,d;if(((i=(a=(r=(t=this.candidates)===null||t===void 0?void 0:t[0])===null||r===void 0?void 0:r.content)===null||a===void 0?void 0:a.parts)===null||i===void 0?void 0:i.length)===0)return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning executable code from the first one.");let I=(u=(c=(e=(s=this.candidates)===null||s===void 0?void 0:s[0])===null||e===void 0?void 0:e.content)===null||c===void 0?void 0:c.parts)===null||u===void 0?void 0:u.filter(h=>h.executableCode).map(h=>h.executableCode).filter(h=>h!==void 0);if(I?.length!==0)return(d=I?.[0])===null||d===void 0?void 0:d.code}get codeExecutionResult(){var t,r,a,i,s,e,c,u,d;if(((i=(a=(r=(t=this.candidates)===null||t===void 0?void 0:t[0])===null||r===void 0?void 0:r.content)===null||a===void 0?void 0:a.parts)===null||i===void 0?void 0:i.length)===0)return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning code execution result from the first one.");let I=(u=(c=(e=(s=this.candidates)===null||s===void 0?void 0:s[0])===null||e===void 0?void 0:e.content)===null||c===void 0?void 0:c.parts)===null||u===void 0?void 0:u.filter(h=>h.codeExecutionResult).map(h=>h.codeExecutionResult).filter(h=>h!==void 0);if(I?.length!==0)return(d=I?.[0])===null||d===void 0?void 0:d.output}};(function(n){n.PAGED_ITEM_BATCH_JOBS="batchJobs",n.PAGED_ITEM_MODELS="models",n.PAGED_ITEM_TUNING_JOBS="tuningJobs",n.PAGED_ITEM_FILES="files",n.PAGED_ITEM_CACHED_CONTENTS="cachedContents",n.PAGED_ITEM_FILE_SEARCH_STORES="fileSearchStores",n.PAGED_ITEM_DOCUMENTS="documents"})(bet||(bet={}));b5n="1.30.0",Ina=`google-genai-sdk/${b5n}`;G5n=!1;ste=class n{constructor(t=[],r){this.mcpTools=[],this.functionNameToMcpClient={},this.mcpClients=t,this.config=r}static create(t,r){return new n(t,r)}async initialize(){var t,r,a,i;if(this.mcpTools.length>0)return;let s={},e=[];for(let I of this.mcpClients)try{for(var c=!0,u=(r=void 0,p5n(f5n(I))),d;d=await u.next(),t=d.done,!t;c=!0){i=d.value,c=!1;let h=i;e.push(h);let o=h.name;if(s[o])throw new Error(`Duplicate function name ${o} found in MCP tools. Please ensure function names are unique.`);s[o]=I}}catch(h){r={error:h}}finally{try{!c&&!t&&(a=u.return)&&await a.call(u)}finally{if(r)throw r.error}}this.mcpTools=e,this.functionNameToMcpClient=s}async tool(){return await this.initialize(),h5n(this.mcpTools,this.config)}async callTool(t){await this.initialize();let r=[];for(let a of t)if(a.name in this.functionNameToMcpClient){let i=this.functionNameToMcpClient[a.name],s;this.config.timeout&&(s={timeout:this.config.timeout});let e=await i.callTool({name:a.name,arguments:a.args},void 0,s);r.push({functionResponse:{name:a.name,response:e.isError?{error:e}:e}})}return r}};una=1024*1024*8;});function v5n(n,t){return{...n,...t}}function get(n){let{prompt_id:t,...r}=n;return r}function _E(n){return Array.isArray(n)?n.map(get):n}var ote=It(()=>{"use strict";Bi();});var vet={};eo(vet,{DEFAULT_PROXY_CONFIG:()=>W5n,getActiveProxyServerUrl:()=>VZ,getAvailableProxyServers:()=>Z5n,getProxyServerInfo:()=>N5n,getProxyServers:()=>T7,hasAvailableProxyServer:()=>Zve});function T7(){return[{url:"https://api-code.deepvlab.ai",name:"Primary Development Server",region:"default",status:"active"}]}function VZ(){let t=T7().find(r=>r.status==="active");if(!t)throw new Error("No active proxy server available. Please contact support.");return t.url}function Z5n(){return T7().filter(t=>t.status==="active")}function Zve(){return T7().some(t=>t.status==="active")}function N5n(n){return T7().find(r=>r.url===n)}var W5n,L9=It(()=>{"use strict";W5n={serverUrl:VZ(),timeout:2e5,retryAttempts:3,retryDelay:1e3}});import*as Vo from"fs";import*as fg from"path";import*as PE from"os";function A5n(n){ss.configure(n)}function F5n(n){ss.setUserInfo(n)}function y5n(n){ss.setCliVersion(n)}async function R5n(){return await ss.getUserHeaders()}function E5n(){return ss.getStatus()}var O7,Vs,ss,LF=It(()=>{"use strict";L9();O7=259200,Vs=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;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=fg.join(PE.homedir(),".deepv","user-info-dev.json"),this.jwtTokenFilePath=fg.join(PE.homedir(),".deepv","jwt-token-dev.json"),this.usageStatsFilePath=fg.join(PE.homedir(),".deepv","usage-stats-dev.json")):(this.userInfoFilePath=fg.join(PE.homedir(),".deepv","user-info.json"),this.jwtTokenFilePath=fg.join(PE.homedir(),".deepv","jwt-token.json"),this.usageStatsFilePath=fg.join(PE.homedir(),".deepv","usage-stats.json")),this.cliVersion="1.0.259",this.config={proxyServerUrl:VZ()},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-O7*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(Vo.existsSync(this.userInfoFilePath)){let t=Vo.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=fg.dirname(this.userInfoFilePath);Vo.existsSync(t)||Vo.mkdirSync(t,{recursive:!0}),Vo.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(Vo.existsSync(this.jwtTokenFilePath)){let t=Vo.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=fg.dirname(this.jwtTokenFilePath);Vo.existsSync(t)||Vo.mkdirSync(t,{recursive:!0}),Vo.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(Vo.existsSync(this.usageStatsFilePath)){let t=Vo.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=fg.dirname(this.usageStatsFilePath);Vo.existsSync(t)||Vo.mkdirSync(t,{recursive:!0}),Vo.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"})`)}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-O7*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-O7*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=O7){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),c=this.formatAbsoluteTime(this.jwtTokenData.expiresAt-O7*1e3);return console.log(`[Login Check] \u2705 Credential renewed successfully - valid for: ${s} (until ${e}), next renewal: ${c}${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{Vo.existsSync(this.jwtTokenFilePath)&&Vo.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{Vo.existsSync(this.userInfoFilePath)&&Vo.unlinkSync(this.userInfoFilePath)}catch(t){console.warn("[Login Check] Failed to delete user info file:",t)}try{Vo.existsSync(this.jwtTokenFilePath)&&Vo.unlinkSync(this.jwtTokenFilePath)}catch(t){console.warn("[Login Check] Failed to delete access credential file:",t)}console.log("[Login Check] Authentication cleared")}},ss=Vs.getInstance()});import{promises as jE}from"node:fs";import U7 from"node:path";import w5n from"os";var vb,cte,nr,qG=It(()=>{"use strict";(function(n){n[n.DEBUG=0]="DEBUG",n[n.INFO=1]="INFO",n[n.WARN=2]="WARN",n[n.ERROR=3]="ERROR"})(vb||(vb={}));cte=class{config;logBuffer=[];constructor(t={}){if(this.config={level:vb.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=U7.join(w5n.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 jE.mkdir(U7.dirname(this.config.filePath),{recursive:!0}),await this.rotateLogIfNeeded(),await jE.appendFile(this.config.filePath,t+`
496
496
  `,"utf-8")}catch(r){console.error("\u5199\u5165\u65E5\u5FD7\u6587\u4EF6\u5931\u8D25:",r)}}async rotateLogIfNeeded(){if(this.config.filePath)try{if((await jE.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 jE.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=U7.dirname(this.config.filePath),a=(await jE.readdir(t)).filter(e=>e.startsWith("deepv-")&&e.endsWith(".log")).map(e=>({name:e,path:U7.join(t,e),time:jE.stat(U7.join(t,e)).then(c=>c.mtime)})),i=await Promise.all(a.map(async e=>({...e,time:await e.time})));i.sort((e,c)=>c.time.getTime()-e.time.getTime());let s=i.slice(this.config.maxFiles||5);for(let e of s)await jE.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>=vb.ERROR?console.error:t>=vb.WARN?console.warn:t>=vb.INFO?console.log:console.debug)(s),this.config.enableFile&&this.writeToFile(s)}debug(t,...r){this.log(vb.DEBUG,"DEBUG",t,...r)}info(t,...r){this.log(vb.INFO,"INFO",t,...r)}warn(t,...r){this.log(vb.WARN,"WARN",t,...r)}error(t,...r){this.log(vb.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}:{}})}},nr=new cte({level:process.env.FILE_DEBUG==="1"?vb.DEBUG:vb.INFO,enableConsole:!0,enableFile:process.env.LOG_TO_FILE==="true",filePath:process.env.LOG_FILE_PATH})});function Os(n){return n instanceof Error&&"code"in n}function rr(n){if(n instanceof Error)return n.message;try{return String(n)}catch{return"Failed to get error details"}}function Nve(n){if(n&&typeof n=="object"&&"response"in n){let r=Y5n(n);if(r.error&&r.error.message&&r.error.code)switch(r.error.code){case 400:return new ute(r.error.message);case 401:return new FI(r.error.message);case 403:return new Ite(r.error.message);default:}}return n}function Y5n(n){return typeof n.response?.data=="string"?JSON.parse(n.response?.data):n.response?.data}var Ite,FI,ute,Qo=It(()=>{"use strict";Ite=class extends Error{},FI=class extends Error{},ute=class extends Error{}});var Fa,Zet,Mu,QZ=It(()=>{"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"})(Fa||(Fa={}));Zet={[Fa.CHAT_CONVERSATION]:"auto",[Fa.WEB_FETCH]:"gemini-2.5-flash",[Fa.WEB_SEARCH]:"gemini-2.5-flash",[Fa.CODE_ASSIST]:"auto",[Fa.CONTENT_SUMMARY]:"gemini-2.5-flash-lite",[Fa.EDIT_CORRECTION]:"gemini-2.5-flash-lite",[Fa.JSON_GENERATION]:"gemini-2.5-flash",[Fa.COMPRESSION]:"gemini-2.5-flash",[Fa.SUB_AGENT]:"auto"},Mu=class{static getModelForScene(t){if(t)return Zet[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{[Fa.CHAT_CONVERSATION]:"\u804A\u5929\u5BF9\u8BDD",[Fa.WEB_FETCH]:"Web\u5185\u5BB9\u83B7\u53D6",[Fa.WEB_SEARCH]:"Web\u641C\u7D22",[Fa.CODE_ASSIST]:"\u4EE3\u7801\u52A9\u624B",[Fa.CONTENT_SUMMARY]:"\u5185\u5BB9\u6458\u8981",[Fa.EDIT_CORRECTION]:"\u7F16\u8F91\u6821\u6B63",[Fa.JSON_GENERATION]:"JSON\u751F\u6210",[Fa.COMPRESSION]:"\u5BF9\u8BDD\u538B\u7F29",[Fa.SUB_AGENT]:"SubAgent\u5B50\u4EE3\u7406"}[t]||t}}});function JF(n){return typeof n=="object"&&n!==null&&"error"in n&&typeof n.error=="object"&&"message"in n.error}function $G(n){return typeof n=="object"&&n!==null&&"message"in n&&typeof n.message=="string"}function ZW(n){let t=r=>r.includes("Quota exceeded for quota metric 'Gemini")&&r.includes("Pro Requests'");if(typeof n=="string")return t(n);if($G(n))return t(n.message);if(JF(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 NW(n){return typeof n=="string"?n.includes("Quota exceeded for quota metric"):$G(n)?n.message.includes("Quota exceeded for quota metric"):JF(n)?n.error.message.includes("Quota exceeded for quota metric"):!1}function WW(n){if(n&&typeof n=="object"&&"response"in n){let t=n;if(t.response?.status===429&&t.response.data){let r=t.response.data;if(r&&typeof r.error=="string"&&r.error==="Quota limit exceeded"&&typeof r.message=="string")return!0}if(t.response?.status===403&&t.response.data){let r=t.response.data;if(r&&typeof r.error=="string"&&r.error==="No quota configuration"&&typeof r.message=="string")return!0}}if(n instanceof Error&&n.message&&(n.message.includes("API request failed (429):")&&n.message.includes('"error":"Quota limit exceeded"')||n.message.includes("API request failed (403):")&&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 (429):")&&t.message.includes('"error":"Quota limit exceeded"')||t.message.includes("API request failed (403):")&&t.message.includes('"error":"No quota configuration"')||t.message.includes("API error (403):")&&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 M7(n){let t=null;if(n&&typeof n=="object"&&"response"in n){let r=n;(r.response?.status===429||r.response?.status===403)&&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 (429):")&&r.message.includes('"error":"Quota limit exceeded"')||r.message.includes("API request failed (403):")&&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 (429):")&&n.message.includes('"error":"Quota limit exceeded"')||n.message.includes("API request failed (403):")&&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 (429):")&&n.includes('"error":"Quota limit exceeded"')||n.includes("API request failed (403):")&&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?C5n(t):null}function C5n(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
497
497
  \u{1F6AB} \u5F53\u524D\u8D26\u6237\u53EF\u7528\u7684 Credit\uFF08\u79EF\u5206\uFF09\u4E0D\u8DB3\u4EE5\u7EE7\u7EED\u4F7F\u7528\u672C\u670D\u52A1
498
498
  \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/
@@ -641,7 +641,7 @@ ${s}`;break;case"retry":Pot(s)&&(r[i]=s);break;case"id":jot(s)&&(r[i]=s);break;c
641
641
 
642
642
  Please check your Feishu authentication token and try again.
643
643
  If the problem persists, you may need to re-authenticate.`);throw a.isAuthError=!0,a.statusCode=401,a}throw t}async generateContentStream(t,r){return process.env.DEEPV_CLOUD_MODE==="true"?this._generateContent(t,r):F6n(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=Mu.getModelForScene(r),i=this.config?.getModel(),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(_E(t.contents)),config:{...t.config,stream:!0,httpOptions:{...t.config?.httpOptions,headers:{...t.config?.httpOptions?.headers,"X-Scene-Type":r,"X-Scene-Display":Mu.getSceneDisplayName(r)}}}};nr.info(`[DeepV Server] Starting stream with model: ${s}`);let c=await this.callStreamAPI("/v1/chat/stream",e,t.config?.abortSignal);return this.createStreamGenerator(c,t.config?.abortSignal)}catch(a){return nr.error("[DeepV Server] Stream request failed",{error:a}),this.handleStreamError(a)}}async callStreamAPI(t,r,a){return HZ(()=>this.executeStreamAPICall(t,r,a),{shouldRetry:i=>i.message.includes("cancelled by user")||i.name==="AbortError"||i.message.includes("401")||i instanceof FI||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 ss.getUserHeaders(),s=`${ss.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,Ict.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,c=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),c=()=>a.removeEventListener("abort",d)}let u=Date.now();try{nr.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 FI("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 o=new Error(`Stream API error (${d.status}): ${h}`);o.status=d.status;let v=d.headers.get("retry-after");throw v&&(o.response={status:d.status,headers:{"retry-after":v}}),o}let I=Date.now()-u;return nr.debug("[DeepV Server] Stream API call initiated",{endpoint:t,duration:`${I}ms`,status:d.status}),d}catch(d){let I=Date.now()-u;throw c&&c(),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")?nr.warn("[DeepV Server] Stream API aborted",{endpoint:t,duration:`${I}ms`,reason:d.message}):nr.error("[DeepV Server] Stream API call failed",{endpoint:t,duration:`${I}ms`,error:d instanceof Error?d.message:d}),d)}finally{c&&c()}}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,c=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"),c&&console.log("[DeepV Server] Partial token consumption recorded:",{inputTokens:c.promptTokenCount||0,outputTokens:c.candidatesTokenCount||0,totalTokens:c.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:o}=I;if(h)break;e+=o.length,s+=i.decode(o,{stream:!0});let v=s.split(`
644
- `);s=v.pop()||"";for(let w of v)if(w.startsWith("data: ")){let R=w.slice(6);if(R==="[DONE]")return;try{let E=JSON.parse(R);if(E.type==="connection_established")continue;if(E.error)throw new Error(E.error);E.usageMetadata&&(c=E.usageMetadata);let A=this.convertStreamChunkToGenAI(E);A&&(yield A)}catch(E){nr.warn("[DeepV Server] Stream chunk parse error",{data:R.substring(0,100)+"...",error:E instanceof Error?E.message:E})}}}}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 c=s.functionCall,u=e.functionCall;u&&(u.name&&(c.name=u.name),u.id&&(c.id=u.id),u.args&&(typeof u.args=="string"&&typeof c.args=="string"?c.args+=u.args:typeof u.args=="object"&&u.args!==null?c.args={...typeof c.args=="object"?c.args:{},...u.args}:c.args=u.args))}else{let c={...e};if(c.functionCall&&!c.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: ${c.functionCall.name} -> ${u}`),c.functionCall.id=u}a.push(c)}}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=Mu.getModelForScene(r);return{model:t.model||a||"auto",contents:t.contents,config:{...t.config,httpOptions:{...t.config?.httpOptions,headers:{...t.config?.httpOptions?.headers,"X-Scene-Type":r,"X-Scene-Display":Mu.getSceneDisplayName(r)}}}}}async*handleStreamError(t){this.handleError(t)}async countTokens(t){try{let r={model:t.model||"auto",contents:t.contents};(t.config?.systemInstruction||t.config?.tools)&&(r.config={},t.config.systemInstruction&&(r.config.systemInstruction=t.config.systemInstruction),t.config.tools&&(r.config.tools=t.config.tools));let a=await this.callUnifiedTokenCountAPI(r);return Tp.emitRealTimeToken({inputTokens:a.totalTokens||0,outputTokens:0,totalTokens:a.totalTokens||0,timestamp:Date.now()}),a}catch(r){return nr.error("[DeepV Server] Token count failed:",r),this.estimateTokensAsFailback(t)}}async callUnifiedTokenCountAPI(t){let r=await ss.getUserHeaders(),a=`${ss.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 FI("Authentication required - please re-authenticate")):new Error(`Token count API failed (${i.status}): ${e}`)}let s=await i.json();return nr.debug("[DeepV Server] Token count response",{totalTokens:s.totalTokens}),{totalTokens:s.totalTokens||0}}catch(i){throw nr.error("[DeepV Server] Token count API call failed:",i),i}}estimateTokensAsFailback(t){try{let r=Array.isArray(t.contents)?t.contents:[{role:la.USER,parts:[{text:t.contents}]}],a=0,i=0,s=0,e=0;for(let o of r)if(typeof o=="object"&&o&&"parts"in o&&Array.isArray(o.parts)){for(let v of o.parts)if(typeof v=="object"&&v&&"text"in v&&typeof v.text=="string")a+=v.text.length,e++;else if(typeof v=="object"&&v&&"functionCall"in v&&v.functionCall){let w=v.functionCall,R=`[Tool: ${w.name}]`+JSON.stringify(w.args||{});a+=R.length,i++}else if(typeof v=="object"&&v&&"functionResponse"in v&&v.functionResponse){let E=`[Tool Result: ${v.functionResponse.response?.output||"result"}]`;a+=E.length+20,s++}}else typeof o=="string"&&(a+=o.length,e++);let c=JSON.stringify(r),u=/[\u4e00-\u9fff]/.test(c),d=/```|function|class|import|export|\{|\}|\[|\]/.test(c),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,c)=>{i=setTimeout(()=>{c(new Error(a))},r)});return Promise.race([t,s]).finally(()=>{i!==null&&clearTimeout(i)})}}});function ZWe(n,t){let r=n.getModel()||"auto",a={authType:t,proxy:n?.getProxy()};return t===Fl.USE_PROXY_AUTH,a}async function NWe(n,t,r){let i={headers:{"User-Agent":`GeminiCLI/1.0.258 (${process.platform}; ${process.arch})`}};if(!0){let e=t.getCustomProxyServerUrl(),c;if(e)c=e,console.log(`[DeepX] Using custom proxy server: ${c}`);else{if(!Zve())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.");c=VZ(),console.log(`[DeepX] Connecting to DeepV Code server: ${c}`)}let u=process.env.GOOGLE_CLOUD_LOCATION||"us-central1",d=process.env.GOOGLE_CLOUD_PROJECT||"default-project";return new RH(u,d,c,t)}throw new Error(`Error creating contentGenerator: Unsupported authType: ${n.authType}`)}var Fl,hre=It(()=>{"use strict";vWe();L9();(function(n){n.USE_PROXY_AUTH="proxy-auth"})(Fl||(Fl={}))});var mre,uct=It(()=>{"use strict";mre=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 yg(n){let t={type:"subagent_update",data:n,timestamp:Date.now()};return JSON.stringify(t)}function dct(n){let t={type:"text",data:n,timestamp:Date.now()};return JSON.stringify(t)}function pre(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 bre(n){return n.type==="subagent_update"}function Gre(n){return n.type==="text"}var WWe=It(()=>{"use strict";});var sa,kr,oa,os=It(()=>{"use strict";WWe();sa=class{name;displayName;description;icon;parameterSchema;isOutputMarkdown;forceMarkdown;canUpdateOutput;allowSubAgentUse;constructor(t,r,a,i,s,e=!0,c=!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=c,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"})(kr||(kr={}));(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"})(oa||(oa={}))});var il,AWe,Lr,jZ,PD=It(()=>{(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(c=>typeof i[i[c]]!="number"),e={};for(let c of s)e[c]=i[c];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})(il||(il={}));(function(n){n.mergeShapes=(t,r)=>({...t,...r})})(AWe||(AWe={}));Lr=il.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),jZ=n=>{switch(typeof n){case"undefined":return Lr.undefined;case"string":return Lr.string;case"number":return Number.isNaN(n)?Lr.nan:Lr.number;case"boolean":return Lr.boolean;case"function":return Lr.function;case"bigint":return Lr.bigint;case"symbol":return Lr.symbol;case"object":return Array.isArray(n)?Lr.array:n===null?Lr.null:n.then&&typeof n.then=="function"&&n.catch&&typeof n.catch=="function"?Lr.promise:typeof Map<"u"&&n instanceof Map?Lr.map:typeof Set<"u"&&n instanceof Set?Lr.set:typeof Date<"u"&&n instanceof Date?Lr.date:Lr.object;default:return Lr.unknown}}});var dr,y6n,Pp,fre=It(()=>{PD();dr=il.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"]),y6n=n=>JSON.stringify(n,null,2).replace(/"([^"]+)":/g,"$1:"),Pp=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 c=a,u=0;for(;u<e.path.length;){let d=e.path[u];u===e.path.length-1?(c[d]=c[d]||{_errors:[]},c[d]._errors.push(r(e))):c[d]=c[d]||{_errors:[]},c=c[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,il.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()}};Pp.create=n=>new Pp(n)});var R6n,kW,FWe=It(()=>{fre();PD();R6n=(n,t)=>{let r;switch(n.code){case dr.invalid_type:n.received===Lr.undefined?r="Required":r=`Expected ${n.expected}, received ${n.received}`;break;case dr.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(n.expected,il.jsonStringifyReplacer)}`;break;case dr.unrecognized_keys:r=`Unrecognized key(s) in object: ${il.joinValues(n.keys,", ")}`;break;case dr.invalid_union:r="Invalid input";break;case dr.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${il.joinValues(n.options)}`;break;case dr.invalid_enum_value:r=`Invalid enum value. Expected ${il.joinValues(n.options)}, received '${n.received}'`;break;case dr.invalid_arguments:r="Invalid function arguments";break;case dr.invalid_return_type:r="Invalid function return type";break;case dr.invalid_date:r="Invalid date";break;case dr.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}"`:il.assertNever(n.validation):n.validation!=="regex"?r=`Invalid ${n.validation}`:r="Invalid";break;case dr.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 dr.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 dr.custom:r="Invalid input";break;case dr.invalid_intersection_types:r="Intersection results could not be merged";break;case dr.not_multiple_of:r=`Number must be a multiple of ${n.multipleOf}`;break;case dr.not_finite:r="Number must be finite";break;default:r=t.defaultError,il.assertNever(n)}return{message:r}},kW=R6n});function E6n(n){hct=n}function EH(){return hct}var hct,gre=It(()=>{FWe();hct=kW});function xr(n,t){let r=EH(),a=jD({issueData:t,data:n.data,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,r,r===kW?void 0:kW].filter(i=>!!i)});n.common.issues.push(a)}var jD,w6n,g0,Xa,Rw,gh,vre,Zre,ny,wH,yWe=It(()=>{gre();FWe();jD=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 c="",u=a.filter(d=>!!d).slice().reverse();for(let d of u)c=d(e,{data:t,defaultError:c}).message;return{...i,path:s,message:c}},w6n=[];g0=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 Xa;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 Xa;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}}},Xa=Object.freeze({status:"aborted"}),Rw=n=>({status:"dirty",value:n}),gh=n=>({status:"valid",value:n}),vre=n=>n.status==="aborted",Zre=n=>n.status==="dirty",ny=n=>n.status==="valid",wH=n=>typeof Promise<"u"&&n instanceof Promise});var mct=It(()=>{});var ca,pct=It(()=>{(function(n){n.errToObj=t=>typeof t=="string"?{message:t}:t||{},n.toString=t=>typeof t=="string"?t:t?.message})(ca||(ca={}))});function Ni(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,c)=>{let{message:u}=n;return e.code==="invalid_enum_value"?{message:u??c.defaultError}:typeof c.data>"u"?{message:u??a??c.defaultError}:e.code!=="invalid_type"?{message:c.defaultError}:{message:u??r??c.defaultError}},description:i}}function gct(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 M6n(n){return new RegExp(`^${gct(n)}$`)}function vct(n){let t=`${fct}T${gct(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 z6n(n,t){return!!((t==="v4"||!t)&&J6n.test(n)||(t==="v6"||!t)&&B6n.test(n))}function _6n(n,t){if(!H6n.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 P6n(n,t){return!!((t==="v4"||!t)&&S6n.test(n)||(t==="v6"||!t)&&D6n.test(n))}function j6n(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 YH(n){if(n instanceof jp){let t={};for(let r in n.shape){let a=n.shape[r];t[r]=u1.create(YH(a))}return new jp({...n._def,shape:()=>t})}else return n instanceof SW?new SW({...n._def,type:YH(n.element)}):n instanceof u1?u1.create(YH(n.unwrap())):n instanceof qZ?qZ.create(YH(n.unwrap())):n instanceof KZ?KZ.create(n.items.map(t=>YH(t))):n}function EWe(n,t){let r=jZ(n),a=jZ(t);if(n===t)return{valid:!0,data:n};if(r===Lr.object&&a===Lr.object){let i=il.objectKeys(t),s=il.objectKeys(n).filter(c=>i.indexOf(c)!==-1),e={...n,...t};for(let c of s){let u=EWe(n[c],t[c]);if(!u.valid)return{valid:!1};e[c]=u.data}return{valid:!0,data:e}}else if(r===Lr.array&&a===Lr.array){if(n.length!==t.length)return{valid:!1};let i=[];for(let s=0;s<n.length;s++){let e=n[s],c=t[s],u=EWe(e,c);if(!u.valid)return{valid:!1};i.push(u.data)}return{valid:!0,data:i}}else return r===Lr.date&&a===Lr.date&&+n==+t?{valid:!0,data:n}:{valid:!1}}function Zct(n,t){return new Lw({values:n,typeName:Da.ZodEnum,...Ni(t)})}function Gct(n,t){let r=typeof n=="function"?n(t):typeof n=="string"?{message:n}:n;return typeof r=="string"?{message:r}:r}function Nct(n,t={},r){return n?ay.create().superRefine((a,i)=>{let s=n(a);if(s instanceof Promise)return s.then(e=>{if(!e){let c=Gct(t,a),u=c.fatal??r??!0;i.addIssue({code:"custom",...c,fatal:u})}});if(!s){let e=Gct(t,a),c=e.fatal??r??!0;i.addIssue({code:"custom",...e,fatal:c})}}):ay.create()}var d1,bct,Qi,Y6n,C6n,x6n,V6n,Q6n,H6n,X6n,k6n,L6n,RWe,J6n,S6n,B6n,D6n,T6n,O6n,fct,U6n,ry,Ew,ww,Yw,Cw,CH,xw,Vw,ay,JW,Rg,xH,SW,jp,Qw,LW,Nre,Hw,KZ,Wre,VH,QH,Are,Xw,kw,Lw,Jw,iy,h1,u1,qZ,Sw,Bw,HH,K6n,KD,qD,Dw,q6n,Da,$6n,Wct,Act,ekn,tkn,Fct,nkn,rkn,akn,ikn,lkn,skn,okn,ckn,Ikn,ukn,dkn,hkn,mkn,pkn,bkn,Gkn,fkn,gkn,vkn,Zkn,Nkn,Wkn,Akn,Fkn,ykn,Rkn,Ekn,wkn,Ykn,Ckn,xkn,Vkn,Qkn,Hkn,yct=It(()=>{fre();gre();pct();yWe();PD();d1=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}},bct=(n,t)=>{if(ny(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 Pp(n.common.issues);return this._error=r,this._error}}};Qi=class{get description(){return this._def.description}_getType(t){return jZ(t.data)}_getOrReturnCtx(t,r){return r||{common:t.parent.common,data:t.data,parsedType:jZ(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new g0,ctx:{common:t.parent.common,data:t.data,parsedType:jZ(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){let r=this._parse(t);if(wH(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:jZ(t)},i=this._parseSync({data:t,path:a.path,parent:a});return bct(a,i)}"~validate"(t){let r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:jZ(t)};if(!this["~standard"].async)try{let a=this._parseSync({data:t,path:[],parent:r});return ny(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=>ny(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:jZ(t)},i=this._parse({data:t,path:a.path,parent:a}),s=await(wH(i)?i:Promise.resolve(i));return bct(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),c=()=>s.addIssue({code:dr.custom,...a(i)});return typeof Promise<"u"&&e instanceof Promise?e.then(u=>u?!0:(c(),!1)):e?!0:(c(),!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 h1({schema:this,typeName:Da.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 u1.create(this,this._def)}nullable(){return qZ.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return SW.create(this)}promise(){return iy.create(this,this._def)}or(t){return Qw.create([this,t],this._def)}and(t){return Hw.create(this,t,this._def)}transform(t){return new h1({...Ni(this._def),schema:this,typeName:Da.ZodEffects,effect:{type:"transform",transform:t}})}default(t){let r=typeof t=="function"?t:()=>t;return new Sw({...Ni(this._def),innerType:this,defaultValue:r,typeName:Da.ZodDefault})}brand(){return new KD({typeName:Da.ZodBranded,type:this,...Ni(this._def)})}catch(t){let r=typeof t=="function"?t:()=>t;return new Bw({...Ni(this._def),innerType:this,catchValue:r,typeName:Da.ZodCatch})}describe(t){let r=this.constructor;return new r({...this._def,description:t})}pipe(t){return qD.create(this,t)}readonly(){return Dw.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},Y6n=/^c[^\s-]{8,}$/i,C6n=/^[0-9a-z]+$/,x6n=/^[0-9A-HJKMNP-TV-Z]{26}$/i,V6n=/^[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,Q6n=/^[a-z0-9_-]{21}$/i,H6n=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,X6n=/^[-+]?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)?)??$/,k6n=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,L6n="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",J6n=/^(?:(?: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])$/,S6n=/^(?:(?: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])$/,B6n=/^(([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]))$/,D6n=/^(([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])$/,T6n=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,O6n=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,fct="((\\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])))",U6n=new RegExp(`^${fct}$`);ry=class n extends Qi{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==Lr.string){let s=this._getOrReturnCtx(t);return xr(s,{code:dr.invalid_type,expected:Lr.string,received:s.parsedType}),Xa}let a=new g0,i;for(let s of this._def.checks)if(s.kind==="min")t.data.length<s.value&&(i=this._getOrReturnCtx(t,i),xr(i,{code:dr.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),xr(i,{code:dr.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,c=t.data.length<s.value;(e||c)&&(i=this._getOrReturnCtx(t,i),e?xr(i,{code:dr.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):c&&xr(i,{code:dr.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),a.dirty())}else if(s.kind==="email")k6n.test(t.data)||(i=this._getOrReturnCtx(t,i),xr(i,{validation:"email",code:dr.invalid_string,message:s.message}),a.dirty());else if(s.kind==="emoji")RWe||(RWe=new RegExp(L6n,"u")),RWe.test(t.data)||(i=this._getOrReturnCtx(t,i),xr(i,{validation:"emoji",code:dr.invalid_string,message:s.message}),a.dirty());else if(s.kind==="uuid")V6n.test(t.data)||(i=this._getOrReturnCtx(t,i),xr(i,{validation:"uuid",code:dr.invalid_string,message:s.message}),a.dirty());else if(s.kind==="nanoid")Q6n.test(t.data)||(i=this._getOrReturnCtx(t,i),xr(i,{validation:"nanoid",code:dr.invalid_string,message:s.message}),a.dirty());else if(s.kind==="cuid")Y6n.test(t.data)||(i=this._getOrReturnCtx(t,i),xr(i,{validation:"cuid",code:dr.invalid_string,message:s.message}),a.dirty());else if(s.kind==="cuid2")C6n.test(t.data)||(i=this._getOrReturnCtx(t,i),xr(i,{validation:"cuid2",code:dr.invalid_string,message:s.message}),a.dirty());else if(s.kind==="ulid")x6n.test(t.data)||(i=this._getOrReturnCtx(t,i),xr(i,{validation:"ulid",code:dr.invalid_string,message:s.message}),a.dirty());else if(s.kind==="url")try{new URL(t.data)}catch{i=this._getOrReturnCtx(t,i),xr(i,{validation:"url",code:dr.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),xr(i,{validation:"regex",code:dr.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),xr(i,{code:dr.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),xr(i,{code:dr.invalid_string,validation:{startsWith:s.value},message:s.message}),a.dirty()):s.kind==="endsWith"?t.data.endsWith(s.value)||(i=this._getOrReturnCtx(t,i),xr(i,{code:dr.invalid_string,validation:{endsWith:s.value},message:s.message}),a.dirty()):s.kind==="datetime"?vct(s).test(t.data)||(i=this._getOrReturnCtx(t,i),xr(i,{code:dr.invalid_string,validation:"datetime",message:s.message}),a.dirty()):s.kind==="date"?U6n.test(t.data)||(i=this._getOrReturnCtx(t,i),xr(i,{code:dr.invalid_string,validation:"date",message:s.message}),a.dirty()):s.kind==="time"?M6n(s).test(t.data)||(i=this._getOrReturnCtx(t,i),xr(i,{code:dr.invalid_string,validation:"time",message:s.message}),a.dirty()):s.kind==="duration"?X6n.test(t.data)||(i=this._getOrReturnCtx(t,i),xr(i,{validation:"duration",code:dr.invalid_string,message:s.message}),a.dirty()):s.kind==="ip"?z6n(t.data,s.version)||(i=this._getOrReturnCtx(t,i),xr(i,{validation:"ip",code:dr.invalid_string,message:s.message}),a.dirty()):s.kind==="jwt"?_6n(t.data,s.alg)||(i=this._getOrReturnCtx(t,i),xr(i,{validation:"jwt",code:dr.invalid_string,message:s.message}),a.dirty()):s.kind==="cidr"?P6n(t.data,s.version)||(i=this._getOrReturnCtx(t,i),xr(i,{validation:"cidr",code:dr.invalid_string,message:s.message}),a.dirty()):s.kind==="base64"?T6n.test(t.data)||(i=this._getOrReturnCtx(t,i),xr(i,{validation:"base64",code:dr.invalid_string,message:s.message}),a.dirty()):s.kind==="base64url"?O6n.test(t.data)||(i=this._getOrReturnCtx(t,i),xr(i,{validation:"base64url",code:dr.invalid_string,message:s.message}),a.dirty()):il.assertNever(s);return{status:a.value,value:t.data}}_regex(t,r,a){return this.refinement(i=>t.test(i),{validation:r,code:dr.invalid_string,...ca.errToObj(a)})}_addCheck(t){return new n({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...ca.errToObj(t)})}url(t){return this._addCheck({kind:"url",...ca.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...ca.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...ca.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...ca.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...ca.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...ca.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...ca.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...ca.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...ca.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...ca.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...ca.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...ca.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,...ca.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,...ca.errToObj(t?.message)})}duration(t){return this._addCheck({kind:"duration",...ca.errToObj(t)})}regex(t,r){return this._addCheck({kind:"regex",regex:t,...ca.errToObj(r)})}includes(t,r){return this._addCheck({kind:"includes",value:t,position:r?.position,...ca.errToObj(r?.message)})}startsWith(t,r){return this._addCheck({kind:"startsWith",value:t,...ca.errToObj(r)})}endsWith(t,r){return this._addCheck({kind:"endsWith",value:t,...ca.errToObj(r)})}min(t,r){return this._addCheck({kind:"min",value:t,...ca.errToObj(r)})}max(t,r){return this._addCheck({kind:"max",value:t,...ca.errToObj(r)})}length(t,r){return this._addCheck({kind:"length",value:t,...ca.errToObj(r)})}nonempty(t){return this.min(1,ca.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}};ry.create=n=>new ry({checks:[],typeName:Da.ZodString,coerce:n?.coerce??!1,...Ni(n)});Ew=class n extends Qi{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)!==Lr.number){let s=this._getOrReturnCtx(t);return xr(s,{code:dr.invalid_type,expected:Lr.number,received:s.parsedType}),Xa}let a,i=new g0;for(let s of this._def.checks)s.kind==="int"?il.isInteger(t.data)||(a=this._getOrReturnCtx(t,a),xr(a,{code:dr.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),xr(a,{code:dr.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),xr(a,{code:dr.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="multipleOf"?j6n(t.data,s.value)!==0&&(a=this._getOrReturnCtx(t,a),xr(a,{code:dr.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):s.kind==="finite"?Number.isFinite(t.data)||(a=this._getOrReturnCtx(t,a),xr(a,{code:dr.not_finite,message:s.message}),i.dirty()):il.assertNever(s);return{status:i.value,value:t.data}}gte(t,r){return this.setLimit("min",t,!0,ca.toString(r))}gt(t,r){return this.setLimit("min",t,!1,ca.toString(r))}lte(t,r){return this.setLimit("max",t,!0,ca.toString(r))}lt(t,r){return this.setLimit("max",t,!1,ca.toString(r))}setLimit(t,r,a,i){return new n({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:a,message:ca.toString(i)}]})}_addCheck(t){return new n({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:ca.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:ca.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:ca.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:ca.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:ca.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:ca.toString(r)})}finite(t){return this._addCheck({kind:"finite",message:ca.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:ca.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:ca.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"&&il.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)}};Ew.create=n=>new Ew({checks:[],typeName:Da.ZodNumber,coerce:n?.coerce||!1,...Ni(n)});ww=class n extends Qi{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)!==Lr.bigint)return this._getInvalidInput(t);let a,i=new g0;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),xr(a,{code:dr.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),xr(a,{code:dr.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),xr(a,{code:dr.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):il.assertNever(s);return{status:i.value,value:t.data}}_getInvalidInput(t){let r=this._getOrReturnCtx(t);return xr(r,{code:dr.invalid_type,expected:Lr.bigint,received:r.parsedType}),Xa}gte(t,r){return this.setLimit("min",t,!0,ca.toString(r))}gt(t,r){return this.setLimit("min",t,!1,ca.toString(r))}lte(t,r){return this.setLimit("max",t,!0,ca.toString(r))}lt(t,r){return this.setLimit("max",t,!1,ca.toString(r))}setLimit(t,r,a,i){return new n({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:a,message:ca.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:ca.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:ca.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:ca.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:ca.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:ca.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}};ww.create=n=>new ww({checks:[],typeName:Da.ZodBigInt,coerce:n?.coerce??!1,...Ni(n)});Yw=class extends Qi{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==Lr.boolean){let a=this._getOrReturnCtx(t);return xr(a,{code:dr.invalid_type,expected:Lr.boolean,received:a.parsedType}),Xa}return gh(t.data)}};Yw.create=n=>new Yw({typeName:Da.ZodBoolean,coerce:n?.coerce||!1,...Ni(n)});Cw=class n extends Qi{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==Lr.date){let s=this._getOrReturnCtx(t);return xr(s,{code:dr.invalid_type,expected:Lr.date,received:s.parsedType}),Xa}if(Number.isNaN(t.data.getTime())){let s=this._getOrReturnCtx(t);return xr(s,{code:dr.invalid_date}),Xa}let a=new g0,i;for(let s of this._def.checks)s.kind==="min"?t.data.getTime()<s.value&&(i=this._getOrReturnCtx(t,i),xr(i,{code:dr.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),xr(i,{code:dr.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),a.dirty()):il.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:ca.toString(r)})}max(t,r){return this._addCheck({kind:"max",value:t.getTime(),message:ca.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}};Cw.create=n=>new Cw({checks:[],coerce:n?.coerce||!1,typeName:Da.ZodDate,...Ni(n)});CH=class extends Qi{_parse(t){if(this._getType(t)!==Lr.symbol){let a=this._getOrReturnCtx(t);return xr(a,{code:dr.invalid_type,expected:Lr.symbol,received:a.parsedType}),Xa}return gh(t.data)}};CH.create=n=>new CH({typeName:Da.ZodSymbol,...Ni(n)});xw=class extends Qi{_parse(t){if(this._getType(t)!==Lr.undefined){let a=this._getOrReturnCtx(t);return xr(a,{code:dr.invalid_type,expected:Lr.undefined,received:a.parsedType}),Xa}return gh(t.data)}};xw.create=n=>new xw({typeName:Da.ZodUndefined,...Ni(n)});Vw=class extends Qi{_parse(t){if(this._getType(t)!==Lr.null){let a=this._getOrReturnCtx(t);return xr(a,{code:dr.invalid_type,expected:Lr.null,received:a.parsedType}),Xa}return gh(t.data)}};Vw.create=n=>new Vw({typeName:Da.ZodNull,...Ni(n)});ay=class extends Qi{constructor(){super(...arguments),this._any=!0}_parse(t){return gh(t.data)}};ay.create=n=>new ay({typeName:Da.ZodAny,...Ni(n)});JW=class extends Qi{constructor(){super(...arguments),this._unknown=!0}_parse(t){return gh(t.data)}};JW.create=n=>new JW({typeName:Da.ZodUnknown,...Ni(n)});Rg=class extends Qi{_parse(t){let r=this._getOrReturnCtx(t);return xr(r,{code:dr.invalid_type,expected:Lr.never,received:r.parsedType}),Xa}};Rg.create=n=>new Rg({typeName:Da.ZodNever,...Ni(n)});xH=class extends Qi{_parse(t){if(this._getType(t)!==Lr.undefined){let a=this._getOrReturnCtx(t);return xr(a,{code:dr.invalid_type,expected:Lr.void,received:a.parsedType}),Xa}return gh(t.data)}};xH.create=n=>new xH({typeName:Da.ZodVoid,...Ni(n)});SW=class n extends Qi{_parse(t){let{ctx:r,status:a}=this._processInputParams(t),i=this._def;if(r.parsedType!==Lr.array)return xr(r,{code:dr.invalid_type,expected:Lr.array,received:r.parsedType}),Xa;if(i.exactLength!==null){let e=r.data.length>i.exactLength.value,c=r.data.length<i.exactLength.value;(e||c)&&(xr(r,{code:e?dr.too_big:dr.too_small,minimum:c?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&&(xr(r,{code:dr.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&&(xr(r,{code:dr.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,c)=>i.type._parseAsync(new d1(r,e,r.path,c)))).then(e=>g0.mergeArray(a,e));let s=[...r.data].map((e,c)=>i.type._parseSync(new d1(r,e,r.path,c)));return g0.mergeArray(a,s)}get element(){return this._def.type}min(t,r){return new n({...this._def,minLength:{value:t,message:ca.toString(r)}})}max(t,r){return new n({...this._def,maxLength:{value:t,message:ca.toString(r)}})}length(t,r){return new n({...this._def,exactLength:{value:t,message:ca.toString(r)}})}nonempty(t){return this.min(1,t)}};SW.create=(n,t)=>new SW({type:n,minLength:null,maxLength:null,exactLength:null,typeName:Da.ZodArray,...Ni(t)});jp=class n extends Qi{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=il.objectKeys(t);return this._cached={shape:t,keys:r},this._cached}_parse(t){if(this._getType(t)!==Lr.object){let d=this._getOrReturnCtx(t);return xr(d,{code:dr.invalid_type,expected:Lr.object,received:d.parsedType}),Xa}let{status:a,ctx:i}=this._processInputParams(t),{shape:s,keys:e}=this._getCached(),c=[];if(!(this._def.catchall instanceof Rg&&this._def.unknownKeys==="strip"))for(let d in i.data)e.includes(d)||c.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 d1(i,h,i.path,d)),alwaysSet:d in i.data})}if(this._def.catchall instanceof Rg){let d=this._def.unknownKeys;if(d==="passthrough")for(let I of c)u.push({key:{status:"valid",value:I},value:{status:"valid",value:i.data[I]}});else if(d==="strict")c.length>0&&(xr(i,{code:dr.unrecognized_keys,keys:c}),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 c){let h=i.data[I];u.push({key:{status:"valid",value:I},value:d._parse(new d1(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,o=await I.value;d.push({key:h,value:o,alwaysSet:I.alwaysSet})}return d}).then(d=>g0.mergeObjectSync(a,d)):g0.mergeObjectSync(a,u)}get shape(){return this._def.shape()}strict(t){return ca.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:ca.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:Da.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 il.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 il.objectKeys(this.shape))t[a]||(r[a]=this.shape[a]);return new n({...this._def,shape:()=>r})}deepPartial(){return YH(this)}partial(t){let r={};for(let a of il.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 il.objectKeys(this.shape))if(t&&!t[a])r[a]=this.shape[a];else{let s=this.shape[a];for(;s instanceof u1;)s=s._def.innerType;r[a]=s}return new n({...this._def,shape:()=>r})}keyof(){return Zct(il.objectKeys(this.shape))}};jp.create=(n,t)=>new jp({shape:()=>n,unknownKeys:"strip",catchall:Rg.create(),typeName:Da.ZodObject,...Ni(t)});jp.strictCreate=(n,t)=>new jp({shape:()=>n,unknownKeys:"strict",catchall:Rg.create(),typeName:Da.ZodObject,...Ni(t)});jp.lazycreate=(n,t)=>new jp({shape:n,unknownKeys:"strip",catchall:Rg.create(),typeName:Da.ZodObject,...Ni(t)});Qw=class extends Qi{_parse(t){let{ctx:r}=this._processInputParams(t),a=this._def.options;function i(s){for(let c of s)if(c.result.status==="valid")return c.result;for(let c of s)if(c.result.status==="dirty")return r.common.issues.push(...c.ctx.common.issues),c.result;let e=s.map(c=>new Pp(c.ctx.common.issues));return xr(r,{code:dr.invalid_union,unionErrors:e}),Xa}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 c=e.map(u=>new Pp(u));return xr(r,{code:dr.invalid_union,unionErrors:c}),Xa}}get options(){return this._def.options}};Qw.create=(n,t)=>new Qw({options:n,typeName:Da.ZodUnion,...Ni(t)});LW=n=>n instanceof Xw?LW(n.schema):n instanceof h1?LW(n.innerType()):n instanceof kw?[n.value]:n instanceof Lw?n.options:n instanceof Jw?il.objectValues(n.enum):n instanceof Sw?LW(n._def.innerType):n instanceof xw?[void 0]:n instanceof Vw?[null]:n instanceof u1?[void 0,...LW(n.unwrap())]:n instanceof qZ?[null,...LW(n.unwrap())]:n instanceof KD||n instanceof Dw?LW(n.unwrap()):n instanceof Bw?LW(n._def.innerType):[],Nre=class n extends Qi{_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==Lr.object)return xr(r,{code:dr.invalid_type,expected:Lr.object,received:r.parsedType}),Xa;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}):(xr(r,{code:dr.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[a]}),Xa)}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=LW(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 c of e){if(i.has(c))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(c)}`);i.set(c,s)}}return new n({typeName:Da.ZodDiscriminatedUnion,discriminator:t,options:r,optionsMap:i,...Ni(a)})}};Hw=class extends Qi{_parse(t){let{status:r,ctx:a}=this._processInputParams(t),i=(s,e)=>{if(vre(s)||vre(e))return Xa;let c=EWe(s.value,e.value);return c.valid?((Zre(s)||Zre(e))&&r.dirty(),{status:r.value,value:c.data}):(xr(a,{code:dr.invalid_intersection_types}),Xa)};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}))}};Hw.create=(n,t,r)=>new Hw({left:n,right:t,typeName:Da.ZodIntersection,...Ni(r)});KZ=class n extends Qi{_parse(t){let{status:r,ctx:a}=this._processInputParams(t);if(a.parsedType!==Lr.array)return xr(a,{code:dr.invalid_type,expected:Lr.array,received:a.parsedType}),Xa;if(a.data.length<this._def.items.length)return xr(a,{code:dr.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Xa;!this._def.rest&&a.data.length>this._def.items.length&&(xr(a,{code:dr.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let s=[...a.data].map((e,c)=>{let u=this._def.items[c]||this._def.rest;return u?u._parse(new d1(a,e,a.path,c)):null}).filter(e=>!!e);return a.common.async?Promise.all(s).then(e=>g0.mergeArray(r,e)):g0.mergeArray(r,s)}get items(){return this._def.items}rest(t){return new n({...this._def,rest:t})}};KZ.create=(n,t)=>{if(!Array.isArray(n))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new KZ({items:n,typeName:Da.ZodTuple,rest:null,...Ni(t)})};Wre=class n extends Qi{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!==Lr.object)return xr(a,{code:dr.invalid_type,expected:Lr.object,received:a.parsedType}),Xa;let i=[],s=this._def.keyType,e=this._def.valueType;for(let c in a.data)i.push({key:s._parse(new d1(a,c,a.path,c)),value:e._parse(new d1(a,a.data[c],a.path,c)),alwaysSet:c in a.data});return a.common.async?g0.mergeObjectAsync(r,i):g0.mergeObjectSync(r,i)}get element(){return this._def.valueType}static create(t,r,a){return r instanceof Qi?new n({keyType:t,valueType:r,typeName:Da.ZodRecord,...Ni(a)}):new n({keyType:ry.create(),valueType:t,typeName:Da.ZodRecord,...Ni(r)})}},VH=class extends Qi{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!==Lr.map)return xr(a,{code:dr.invalid_type,expected:Lr.map,received:a.parsedType}),Xa;let i=this._def.keyType,s=this._def.valueType,e=[...a.data.entries()].map(([c,u],d)=>({key:i._parse(new d1(a,c,a.path,[d,"key"])),value:s._parse(new d1(a,u,a.path,[d,"value"]))}));if(a.common.async){let c=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 Xa;(d.status==="dirty"||I.status==="dirty")&&r.dirty(),c.set(d.value,I.value)}return{status:r.value,value:c}})}else{let c=new Map;for(let u of e){let d=u.key,I=u.value;if(d.status==="aborted"||I.status==="aborted")return Xa;(d.status==="dirty"||I.status==="dirty")&&r.dirty(),c.set(d.value,I.value)}return{status:r.value,value:c}}}};VH.create=(n,t,r)=>new VH({valueType:t,keyType:n,typeName:Da.ZodMap,...Ni(r)});QH=class n extends Qi{_parse(t){let{status:r,ctx:a}=this._processInputParams(t);if(a.parsedType!==Lr.set)return xr(a,{code:dr.invalid_type,expected:Lr.set,received:a.parsedType}),Xa;let i=this._def;i.minSize!==null&&a.data.size<i.minSize.value&&(xr(a,{code:dr.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&&(xr(a,{code:dr.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 Xa;I.status==="dirty"&&r.dirty(),d.add(I.value)}return{status:r.value,value:d}}let c=[...a.data.values()].map((u,d)=>s._parse(new d1(a,u,a.path,d)));return a.common.async?Promise.all(c).then(u=>e(u)):e(c)}min(t,r){return new n({...this._def,minSize:{value:t,message:ca.toString(r)}})}max(t,r){return new n({...this._def,maxSize:{value:t,message:ca.toString(r)}})}size(t,r){return this.min(t,r).max(t,r)}nonempty(t){return this.min(1,t)}};QH.create=(n,t)=>new QH({valueType:n,minSize:null,maxSize:null,typeName:Da.ZodSet,...Ni(t)});Are=class n extends Qi{constructor(){super(...arguments),this.validate=this.implement}_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==Lr.function)return xr(r,{code:dr.invalid_type,expected:Lr.function,received:r.parsedType}),Xa;function a(c,u){return jD({data:c,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,EH(),kW].filter(d=>!!d),issueData:{code:dr.invalid_arguments,argumentsError:u}})}function i(c,u){return jD({data:c,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,EH(),kW].filter(d=>!!d),issueData:{code:dr.invalid_return_type,returnTypeError:u}})}let s={errorMap:r.common.contextualErrorMap},e=r.data;if(this._def.returns instanceof iy){let c=this;return gh(async function(...u){let d=new Pp([]),I=await c._def.args.parseAsync(u,s).catch(v=>{throw d.addIssue(a(u,v)),d}),h=await Reflect.apply(e,this,I);return await c._def.returns._def.type.parseAsync(h,s).catch(v=>{throw d.addIssue(i(h,v)),d})})}else{let c=this;return gh(function(...u){let d=c._def.args.safeParse(u,s);if(!d.success)throw new Pp([a(u,d.error)]);let I=Reflect.apply(e,this,d.data),h=c._def.returns.safeParse(I,s);if(!h.success)throw new Pp([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:KZ.create(t).rest(JW.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||KZ.create([]).rest(JW.create()),returns:r||JW.create(),typeName:Da.ZodFunction,...Ni(a)})}},Xw=class extends Qi{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})}};Xw.create=(n,t)=>new Xw({getter:n,typeName:Da.ZodLazy,...Ni(t)});kw=class extends Qi{_parse(t){if(t.data!==this._def.value){let r=this._getOrReturnCtx(t);return xr(r,{received:r.data,code:dr.invalid_literal,expected:this._def.value}),Xa}return{status:"valid",value:t.data}}get value(){return this._def.value}};kw.create=(n,t)=>new kw({value:n,typeName:Da.ZodLiteral,...Ni(t)});Lw=class n extends Qi{_parse(t){if(typeof t.data!="string"){let r=this._getOrReturnCtx(t),a=this._def.values;return xr(r,{expected:il.joinValues(a),received:r.parsedType,code:dr.invalid_type}),Xa}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 xr(r,{received:r.data,code:dr.invalid_enum_value,options:a}),Xa}return gh(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})}};Lw.create=Zct;Jw=class extends Qi{_parse(t){let r=il.getValidEnumValues(this._def.values),a=this._getOrReturnCtx(t);if(a.parsedType!==Lr.string&&a.parsedType!==Lr.number){let i=il.objectValues(r);return xr(a,{expected:il.joinValues(i),received:a.parsedType,code:dr.invalid_type}),Xa}if(this._cache||(this._cache=new Set(il.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){let i=il.objectValues(r);return xr(a,{received:a.data,code:dr.invalid_enum_value,options:i}),Xa}return gh(t.data)}get enum(){return this._def.values}};Jw.create=(n,t)=>new Jw({values:n,typeName:Da.ZodNativeEnum,...Ni(t)});iy=class extends Qi{unwrap(){return this._def.type}_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==Lr.promise&&r.common.async===!1)return xr(r,{code:dr.invalid_type,expected:Lr.promise,received:r.parsedType}),Xa;let a=r.parsedType===Lr.promise?r.data:Promise.resolve(r.data);return gh(a.then(i=>this._def.type.parseAsync(i,{path:r.path,errorMap:r.common.contextualErrorMap})))}};iy.create=(n,t)=>new iy({type:n,typeName:Da.ZodPromise,...Ni(t)});h1=class extends Qi{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Da.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=>{xr(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 c=>{if(r.value==="aborted")return Xa;let u=await this._def.schema._parseAsync({data:c,path:a.path,parent:a});return u.status==="aborted"?Xa:u.status==="dirty"?Rw(u.value):r.value==="dirty"?Rw(u.value):u});{if(r.value==="aborted")return Xa;let c=this._def.schema._parseSync({data:e,path:a.path,parent:a});return c.status==="aborted"?Xa:c.status==="dirty"?Rw(c.value):r.value==="dirty"?Rw(c.value):c}}if(i.type==="refinement"){let e=c=>{let u=i.refinement(c,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 c};if(a.common.async===!1){let c=this._def.schema._parseSync({data:a.data,path:a.path,parent:a});return c.status==="aborted"?Xa:(c.status==="dirty"&&r.dirty(),e(c.value),{status:r.value,value:c.value})}else return this._def.schema._parseAsync({data:a.data,path:a.path,parent:a}).then(c=>c.status==="aborted"?Xa:(c.status==="dirty"&&r.dirty(),e(c.value).then(()=>({status:r.value,value:c.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(!ny(e))return Xa;let c=i.transform(e.value,s);if(c instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:c}}else return this._def.schema._parseAsync({data:a.data,path:a.path,parent:a}).then(e=>ny(e)?Promise.resolve(i.transform(e.value,s)).then(c=>({status:r.value,value:c})):Xa);il.assertNever(i)}};h1.create=(n,t,r)=>new h1({schema:n,typeName:Da.ZodEffects,effect:t,...Ni(r)});h1.createWithPreprocess=(n,t,r)=>new h1({schema:t,effect:{type:"preprocess",transform:n},typeName:Da.ZodEffects,...Ni(r)});u1=class extends Qi{_parse(t){return this._getType(t)===Lr.undefined?gh(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};u1.create=(n,t)=>new u1({innerType:n,typeName:Da.ZodOptional,...Ni(t)});qZ=class extends Qi{_parse(t){return this._getType(t)===Lr.null?gh(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};qZ.create=(n,t)=>new qZ({innerType:n,typeName:Da.ZodNullable,...Ni(t)});Sw=class extends Qi{_parse(t){let{ctx:r}=this._processInputParams(t),a=r.data;return r.parsedType===Lr.undefined&&(a=this._def.defaultValue()),this._def.innerType._parse({data:a,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};Sw.create=(n,t)=>new Sw({innerType:n,typeName:Da.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...Ni(t)});Bw=class extends Qi{_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 wH(i)?i.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Pp(a.common.issues)},input:a.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Pp(a.common.issues)},input:a.data})}}removeCatch(){return this._def.innerType}};Bw.create=(n,t)=>new Bw({innerType:n,typeName:Da.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...Ni(t)});HH=class extends Qi{_parse(t){if(this._getType(t)!==Lr.nan){let a=this._getOrReturnCtx(t);return xr(a,{code:dr.invalid_type,expected:Lr.nan,received:a.parsedType}),Xa}return{status:"valid",value:t.data}}};HH.create=n=>new HH({typeName:Da.ZodNaN,...Ni(n)});K6n=Symbol("zod_brand"),KD=class extends Qi{_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}},qD=class n extends Qi{_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"?Xa:s.status==="dirty"?(r.dirty(),Rw(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"?Xa: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:Da.ZodPipeline})}},Dw=class extends Qi{_parse(t){let r=this._def.innerType._parse(t),a=i=>(ny(i)&&(i.value=Object.freeze(i.value)),i);return wH(r)?r.then(i=>a(i)):a(r)}unwrap(){return this._def.innerType}};Dw.create=(n,t)=>new Dw({innerType:n,typeName:Da.ZodReadonly,...Ni(t)});q6n={object:jp.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"})(Da||(Da={}));$6n=(n,t={message:`Input not instance of ${n.name}`})=>Nct(r=>r instanceof n,t),Wct=ry.create,Act=Ew.create,ekn=HH.create,tkn=ww.create,Fct=Yw.create,nkn=Cw.create,rkn=CH.create,akn=xw.create,ikn=Vw.create,lkn=ay.create,skn=JW.create,okn=Rg.create,ckn=xH.create,Ikn=SW.create,ukn=jp.create,dkn=jp.strictCreate,hkn=Qw.create,mkn=Nre.create,pkn=Hw.create,bkn=KZ.create,Gkn=Wre.create,fkn=VH.create,gkn=QH.create,vkn=Are.create,Zkn=Xw.create,Nkn=kw.create,Wkn=Lw.create,Akn=Jw.create,Fkn=iy.create,ykn=h1.create,Rkn=u1.create,Ekn=qZ.create,wkn=h1.createWithPreprocess,Ykn=qD.create,Ckn=()=>Wct().optional(),xkn=()=>Act().optional(),Vkn=()=>Fct().optional(),Qkn={string:(n=>ry.create({...n,coerce:!0})),number:(n=>Ew.create({...n,coerce:!0})),boolean:(n=>Yw.create({...n,coerce:!0})),bigint:(n=>ww.create({...n,coerce:!0})),date:(n=>Cw.create({...n,coerce:!0}))},Hkn=Xa});var Bc={};eo(Bc,{BRAND:()=>K6n,DIRTY:()=>Rw,EMPTY_PATH:()=>w6n,INVALID:()=>Xa,NEVER:()=>Hkn,OK:()=>gh,ParseStatus:()=>g0,Schema:()=>Qi,ZodAny:()=>ay,ZodArray:()=>SW,ZodBigInt:()=>ww,ZodBoolean:()=>Yw,ZodBranded:()=>KD,ZodCatch:()=>Bw,ZodDate:()=>Cw,ZodDefault:()=>Sw,ZodDiscriminatedUnion:()=>Nre,ZodEffects:()=>h1,ZodEnum:()=>Lw,ZodError:()=>Pp,ZodFirstPartyTypeKind:()=>Da,ZodFunction:()=>Are,ZodIntersection:()=>Hw,ZodIssueCode:()=>dr,ZodLazy:()=>Xw,ZodLiteral:()=>kw,ZodMap:()=>VH,ZodNaN:()=>HH,ZodNativeEnum:()=>Jw,ZodNever:()=>Rg,ZodNull:()=>Vw,ZodNullable:()=>qZ,ZodNumber:()=>Ew,ZodObject:()=>jp,ZodOptional:()=>u1,ZodParsedType:()=>Lr,ZodPipeline:()=>qD,ZodPromise:()=>iy,ZodReadonly:()=>Dw,ZodRecord:()=>Wre,ZodSchema:()=>Qi,ZodSet:()=>QH,ZodString:()=>ry,ZodSymbol:()=>CH,ZodTransformer:()=>h1,ZodTuple:()=>KZ,ZodType:()=>Qi,ZodUndefined:()=>xw,ZodUnion:()=>Qw,ZodUnknown:()=>JW,ZodVoid:()=>xH,addIssueToContext:()=>xr,any:()=>lkn,array:()=>Ikn,bigint:()=>tkn,boolean:()=>Fct,coerce:()=>Qkn,custom:()=>Nct,date:()=>nkn,datetimeRegex:()=>vct,defaultErrorMap:()=>kW,discriminatedUnion:()=>mkn,effect:()=>ykn,enum:()=>Wkn,function:()=>vkn,getErrorMap:()=>EH,getParsedType:()=>jZ,instanceof:()=>$6n,intersection:()=>pkn,isAborted:()=>vre,isAsync:()=>wH,isDirty:()=>Zre,isValid:()=>ny,late:()=>q6n,lazy:()=>Zkn,literal:()=>Nkn,makeIssue:()=>jD,map:()=>fkn,nan:()=>ekn,nativeEnum:()=>Akn,never:()=>okn,null:()=>ikn,nullable:()=>Ekn,number:()=>Act,object:()=>ukn,objectUtil:()=>AWe,oboolean:()=>Vkn,onumber:()=>xkn,optional:()=>Rkn,ostring:()=>Ckn,pipeline:()=>Ykn,preprocess:()=>wkn,promise:()=>Fkn,quotelessJson:()=>y6n,record:()=>Gkn,set:()=>gkn,setErrorMap:()=>E6n,strictObject:()=>dkn,string:()=>Wct,symbol:()=>rkn,transformer:()=>ykn,tuple:()=>bkn,undefined:()=>akn,union:()=>hkn,unknown:()=>skn,util:()=>il,void:()=>ckn});var wWe=It(()=>{gre();yWe();mct();PD();yct();fre()});function Ln(n,t,r){function a(c,u){var d;Object.defineProperty(c,"_zod",{value:c._zod??{},enumerable:!1}),(d=c._zod).traits??(d.traits=new Set),c._zod.traits.add(n),t(c,u);for(let I in e.prototype)I in c||Object.defineProperty(c,I,{value:e.prototype[I].bind(c)});c._zod.constr=e,c._zod.def=u}let i=r?.Parent??Object;class s extends i{}Object.defineProperty(s,"name",{value:n});function e(c){var u;let d=r?.Parent?new s:this;a(d,c),(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:c=>r?.Parent&&c instanceof r.Parent?!0:c?._zod?.traits?.has(n)}),Object.defineProperty(e,"name",{value:n}),e}function Yb(n){return n&&Object.assign(Fre,n),Fre}var YWe,Xkn,BW,Fre,XH=It(()=>{YWe=Object.freeze({status:"aborted"});Xkn=Symbol("zod_brand"),BW=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},Fre={}});var cs={};eo(cs,{BIGINT_FORMAT_RANGES:()=>Ect,Class:()=>xWe,NUMBER_FORMAT_RANGES:()=>SWe,aborted:()=>Ow,allowsEval:()=>kWe,assert:()=>Bkn,assertEqual:()=>kkn,assertIs:()=>Jkn,assertNever:()=>Skn,assertNotEqual:()=>Lkn,assignProp:()=>XWe,cached:()=>eT,captureStackTrace:()=>Rre,cleanEnum:()=>eLn,cleanRegex:()=>nT,clone:()=>Eg,createTransparentProxy:()=>zkn,defineLazy:()=>Ho,esc:()=>Tw,escapeRegex:()=>ly,extend:()=>jkn,finalizeIssue:()=>wg,floatSafeRemainder:()=>HWe,getElementAtPath:()=>Dkn,getEnumValues:()=>VWe,getLengthableOrigin:()=>rT,getParsedType:()=>Mkn,getSizableOrigin:()=>wct,isObject:()=>kH,isPlainObject:()=>LH,issue:()=>BWe,joinValues:()=>yre,jsonStringifyReplacer:()=>QWe,merge:()=>Kkn,normalizeParams:()=>Na,nullish:()=>tT,numKeys:()=>Ukn,omit:()=>Pkn,optionalKeys:()=>JWe,partial:()=>qkn,pick:()=>_kn,prefixIssues:()=>$Z,primitiveTypes:()=>Rct,promiseAllObject:()=>Tkn,propertyKeyTypes:()=>LWe,randomString:()=>Okn,required:()=>$kn,stringifyPrimitive:()=>Ere,unwrapMessage:()=>$D});function kkn(n){return n}function Lkn(n){return n}function Jkn(n){}function Skn(n){throw new Error}function Bkn(n){}function VWe(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 yre(n,t="|"){return n.map(r=>Ere(r)).join(t)}function QWe(n,t){return typeof t=="bigint"?t.toString():t}function eT(n){return{get value(){{let r=n();return Object.defineProperty(this,"value",{value:r}),r}throw new Error("cached value already set")}}}function tT(n){return n==null}function nT(n){let t=n.startsWith("^")?1:0,r=n.endsWith("$")?n.length-1:n.length;return n.slice(t,r)}function HWe(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 Ho(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 XWe(n,t,r){Object.defineProperty(n,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function Dkn(n,t){return t?t.reduce((r,a)=>r?.[a],n):n}function Tkn(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 Okn(n=10){let t="abcdefghijklmnopqrstuvwxyz",r="";for(let a=0;a<n;a++)r+=t[Math.floor(Math.random()*t.length)];return r}function Tw(n){return JSON.stringify(n)}function kH(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function LH(n){if(kH(n)===!1)return!1;let t=n.constructor;if(t===void 0)return!0;let r=t.prototype;return!(kH(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function Ukn(n){let t=0;for(let r in n)Object.prototype.hasOwnProperty.call(n,r)&&t++;return t}function ly(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Eg(n,t,r){let a=new n._zod.constr(t??n._zod.def);return(!t||r?.parent)&&(a._zod.parent=n),a}function Na(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 zkn(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 Ere(n){return typeof n=="bigint"?n.toString()+"n":typeof n=="string"?`"${n}"`:`${n}`}function JWe(n){return Object.keys(n).filter(t=>n[t]._zod.optin==="optional"&&n[t]._zod.optout==="optional")}function _kn(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 Eg(n,{...n._zod.def,shape:r,checks:[]})}function Pkn(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 Eg(n,{...n._zod.def,shape:r,checks:[]})}function jkn(n,t){if(!LH(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 XWe(this,"shape",a),a},checks:[]};return Eg(n,r)}function Kkn(n,t){return Eg(n,{...n._zod.def,get shape(){let r={...n._zod.def.shape,...t._zod.def.shape};return XWe(this,"shape",r),r},catchall:t._zod.def.catchall,checks:[]})}function qkn(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 Eg(t,{...t._zod.def,shape:i,checks:[]})}function $kn(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 Eg(t,{...t._zod.def,shape:i,checks:[]})}function Ow(n,t=0){for(let r=t;r<n.issues.length;r++)if(n.issues[r]?.continue!==!0)return!0;return!1}function $Z(n,t){return t.map(r=>{var a;return(a=r).path??(a.path=[]),r.path.unshift(n),r})}function $D(n){return typeof n=="string"?n:n?.message}function wg(n,t,r){let a={...n,path:n.path??[]};if(!n.message){let i=$D(n.inst?._zod.def?.error?.(n))??$D(t?.error?.(n))??$D(r.customError?.(n))??$D(r.localeError?.(n))??"Invalid input";a.message=i}return delete a.inst,delete a.continue,t?.reportInput||delete a.input,a}function wct(n){return n instanceof Set?"set":n instanceof Map?"map":n instanceof File?"file":"unknown"}function rT(n){return Array.isArray(n)?"array":typeof n=="string"?"string":"unknown"}function BWe(...n){let[t,r,a]=n;return typeof t=="string"?{message:t,code:"custom",input:r,inst:a}:{...t}}function eLn(n){return Object.entries(n).filter(([t,r])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}var Rre,kWe,Mkn,LWe,Rct,SWe,Ect,xWe,DW=It(()=>{Rre=Error.captureStackTrace?Error.captureStackTrace:(...n)=>{};kWe=eT(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let n=Function;return new n(""),!0}catch{return!1}});Mkn=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}`)}},LWe=new Set(["string","number","symbol"]),Rct=new Set(["string","number","bigint","boolean","symbol","undefined"]);SWe={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]},Ect={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};xWe=class{constructor(...t){}}});function TWe(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 OWe(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(c=>i({issues:c}));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 c=a,u=0;for(;u<e.path.length;){let d=e.path[u];u===e.path.length-1?(c[d]=c[d]||{_errors:[]},c[d]._errors.push(r(e))):c[d]=c[d]||{_errors:[]},c=c[d],u++}}};return i(n),a}var Yct,wre,DWe,UWe=It(()=>{XH();DW();Yct=(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,QWe,2)},enumerable:!0}),Object.defineProperty(n,"toString",{value:()=>n.message,enumerable:!1})},wre=Ln("$ZodError",Yct),DWe=Ln("$ZodError",Yct,{Parent:Error})});var Cct,xct,MWe,aT,zWe,Yre,_We=It(()=>{XH();UWe();DW();Cct=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 BW;if(e.issues.length){let c=new(i?.Err??n)(e.issues.map(u=>wg(u,s,Yb())));throw Rre(c,i?.callee),c}return e.value},xct=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 c=new(i?.Err??n)(e.issues.map(u=>wg(u,s,Yb())));throw Rre(c,i?.callee),c}return e.value},MWe=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 BW;return s.issues.length?{success:!1,error:new(n??wre)(s.issues.map(e=>wg(e,i,Yb())))}:{success:!0,data:s.value}},aT=MWe(DWe),zWe=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=>wg(e,i,Yb())))}:{success:!0,data:s.value}},Yre=zWe(DWe)});function Dct(){return new RegExp(nLn,"u")}function qct(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 $ct(n){return new RegExp(`^${qct(n)}$`)}function eIt(n){let t=qct({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(`^${jct}T(?:${a})$`)}var Vct,Qct,Hct,Xct,kct,Lct,Jct,Sct,PWe,Bct,nLn,Tct,Oct,Uct,Mct,zct,jWe,_ct,Pct,jct,Kct,tIt,nIt,rIt,aIt,iIt,lIt,sIt,oIt,xre=It(()=>{Vct=/^[cC][^\s-]{8,}$/,Qct=/^[0-9a-z]+$/,Hct=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Xct=/^[0-9a-vA-V]{20}$/,kct=/^[A-Za-z0-9]{27}$/,Lct=/^[a-zA-Z0-9_-]{21}$/,Jct=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Sct=/^([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})$/,PWe=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)$/,Bct=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,nLn="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";Tct=/^(?:(?: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])$/,Oct=/^(([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})$/,Uct=/^((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])$/,Mct=/^(([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])$/,zct=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,jWe=/^[A-Za-z0-9_-]*$/,_ct=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/,Pct=/^\+(?:[0-9]){6,14}[0-9]$/,jct="(?:(?:\\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])))",Kct=new RegExp(`^${jct}$`);tIt=n=>{let t=n?`[\\s\\S]{${n?.minimum??0},${n?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},nIt=/^\d+n?$/,rIt=/^\d+$/,aIt=/^-?\d+(?:\.\d+)?/i,iIt=/true|false/i,lIt=/null/i,sIt=/^[^A-Z]*$/,oIt=/^[^a-z]*$/});var vh,cIt,KWe,qWe,IIt,uIt,dIt,hIt,mIt,iT,pIt,bIt,GIt,fIt,gIt,vIt,ZIt,Vre=It(()=>{XH();xre();DW();vh=Ln("$ZodCheck",(n,t)=>{var r;n._zod??(n._zod={}),n._zod.def=t,(r=n._zod).onattach??(r.onattach=[])}),cIt={number:"number",bigint:"bigint",object:"date"},KWe=Ln("$ZodCheckLessThan",(n,t)=>{vh.init(n,t);let r=cIt[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})}}),qWe=Ln("$ZodCheckGreaterThan",(n,t)=>{vh.init(n,t);let r=cIt[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})}}),IIt=Ln("$ZodCheckMultipleOf",(n,t)=>{vh.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):HWe(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})}}),uIt=Ln("$ZodCheckNumberFormat",(n,t)=>{vh.init(n,t),t.format=t.format||"float64";let r=t.format?.includes("int"),a=r?"int":"number",[i,s]=SWe[t.format];n._zod.onattach.push(e=>{let c=e._zod.bag;c.format=t.format,c.minimum=i,c.maximum=s,r&&(c.pattern=rIt)}),n._zod.check=e=>{let c=e.value;if(r){if(!Number.isInteger(c)){e.issues.push({expected:a,format:t.format,code:"invalid_type",input:c,inst:n});return}if(!Number.isSafeInteger(c)){c>0?e.issues.push({input:c,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:c,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}}c<i&&e.issues.push({origin:"number",input:c,code:"too_small",minimum:i,inclusive:!0,inst:n,continue:!t.abort}),c>s&&e.issues.push({origin:"number",input:c,code:"too_big",maximum:s,inst:n})}}),dIt=Ln("$ZodCheckMaxLength",(n,t)=>{var r;vh.init(n,t),(r=n._zod.def).when??(r.when=a=>{let i=a.value;return!tT(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=rT(i);a.issues.push({origin:e,code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:n,continue:!t.abort})}}),hIt=Ln("$ZodCheckMinLength",(n,t)=>{var r;vh.init(n,t),(r=n._zod.def).when??(r.when=a=>{let i=a.value;return!tT(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=rT(i);a.issues.push({origin:e,code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:n,continue:!t.abort})}}),mIt=Ln("$ZodCheckLengthEquals",(n,t)=>{var r;vh.init(n,t),(r=n._zod.def).when??(r.when=a=>{let i=a.value;return!tT(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=rT(i),c=s>t.length;a.issues.push({origin:e,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:a.value,inst:n,continue:!t.abort})}}),iT=Ln("$ZodCheckStringFormat",(n,t)=>{var r,a;vh.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=()=>{})}),pIt=Ln("$ZodCheckRegex",(n,t)=>{iT.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})}}),bIt=Ln("$ZodCheckLowerCase",(n,t)=>{t.pattern??(t.pattern=sIt),iT.init(n,t)}),GIt=Ln("$ZodCheckUpperCase",(n,t)=>{t.pattern??(t.pattern=oIt),iT.init(n,t)}),fIt=Ln("$ZodCheckIncludes",(n,t)=>{vh.init(n,t);let r=ly(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})}}),gIt=Ln("$ZodCheckStartsWith",(n,t)=>{vh.init(n,t);let r=new RegExp(`^${ly(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})}}),vIt=Ln("$ZodCheckEndsWith",(n,t)=>{vh.init(n,t);let r=new RegExp(`.*${ly(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})}}),ZIt=Ln("$ZodCheckOverwrite",(n,t)=>{vh.init(n,t),n._zod.check=r=>{r.value=t.tx(r.value)}})});var Qre,$We=It(()=>{Qre=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(`
644
+ `);s=v.pop()||"";for(let w of v)if(w.startsWith("data: ")){let R=w.slice(6);if(R==="[DONE]")return;try{let E=JSON.parse(R);if(E.type==="connection_established")continue;if(E.error)throw new Error(E.error);E.usageMetadata&&(c=E.usageMetadata);let A=this.convertStreamChunkToGenAI(E);A&&(yield A)}catch(E){nr.warn("[DeepV Server] Stream chunk parse error",{data:R.substring(0,100)+"...",error:E instanceof Error?E.message:E})}}}}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 c=s.functionCall,u=e.functionCall;u&&(u.name&&(c.name=u.name),u.id&&(c.id=u.id),u.args&&(typeof u.args=="string"&&typeof c.args=="string"?c.args+=u.args:typeof u.args=="object"&&u.args!==null?c.args={...typeof c.args=="object"?c.args:{},...u.args}:c.args=u.args))}else{let c={...e};if(c.functionCall&&!c.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: ${c.functionCall.name} -> ${u}`),c.functionCall.id=u}a.push(c)}}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=Mu.getModelForScene(r);return{model:t.model||a||"auto",contents:t.contents,config:{...t.config,httpOptions:{...t.config?.httpOptions,headers:{...t.config?.httpOptions?.headers,"X-Scene-Type":r,"X-Scene-Display":Mu.getSceneDisplayName(r)}}}}}async*handleStreamError(t){this.handleError(t)}async countTokens(t){try{let r={model:t.model||"auto",contents:t.contents};(t.config?.systemInstruction||t.config?.tools)&&(r.config={},t.config.systemInstruction&&(r.config.systemInstruction=t.config.systemInstruction),t.config.tools&&(r.config.tools=t.config.tools));let a=await this.callUnifiedTokenCountAPI(r);return Tp.emitRealTimeToken({inputTokens:a.totalTokens||0,outputTokens:0,totalTokens:a.totalTokens||0,timestamp:Date.now()}),a}catch(r){return nr.error("[DeepV Server] Token count failed:",r),this.estimateTokensAsFailback(t)}}async callUnifiedTokenCountAPI(t){let r=await ss.getUserHeaders(),a=`${ss.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 FI("Authentication required - please re-authenticate")):new Error(`Token count API failed (${i.status}): ${e}`)}let s=await i.json();return nr.debug("[DeepV Server] Token count response",{totalTokens:s.totalTokens}),{totalTokens:s.totalTokens||0}}catch(i){throw nr.error("[DeepV Server] Token count API call failed:",i),i}}estimateTokensAsFailback(t){try{let r=Array.isArray(t.contents)?t.contents:[{role:la.USER,parts:[{text:t.contents}]}],a=0,i=0,s=0,e=0;for(let o of r)if(typeof o=="object"&&o&&"parts"in o&&Array.isArray(o.parts)){for(let v of o.parts)if(typeof v=="object"&&v&&"text"in v&&typeof v.text=="string")a+=v.text.length,e++;else if(typeof v=="object"&&v&&"functionCall"in v&&v.functionCall){let w=v.functionCall,R=`[Tool: ${w.name}]`+JSON.stringify(w.args||{});a+=R.length,i++}else if(typeof v=="object"&&v&&"functionResponse"in v&&v.functionResponse){let E=`[Tool Result: ${v.functionResponse.response?.output||"result"}]`;a+=E.length+20,s++}}else typeof o=="string"&&(a+=o.length,e++);let c=JSON.stringify(r),u=/[\u4e00-\u9fff]/.test(c),d=/```|function|class|import|export|\{|\}|\[|\]/.test(c),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,c)=>{i=setTimeout(()=>{c(new Error(a))},r)});return Promise.race([t,s]).finally(()=>{i!==null&&clearTimeout(i)})}}});function ZWe(n,t){let r=n.getModel()||"auto",a={authType:t,proxy:n?.getProxy()};return t===Fl.USE_PROXY_AUTH,a}async function NWe(n,t,r){let i={headers:{"User-Agent":`GeminiCLI/1.0.259 (${process.platform}; ${process.arch})`}};if(!0){let e=t.getCustomProxyServerUrl(),c;if(e)c=e,console.log(`[DeepX] Using custom proxy server: ${c}`);else{if(!Zve())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.");c=VZ(),console.log(`[DeepX] Connecting to DeepV Code server: ${c}`)}let u=process.env.GOOGLE_CLOUD_LOCATION||"us-central1",d=process.env.GOOGLE_CLOUD_PROJECT||"default-project";return new RH(u,d,c,t)}throw new Error(`Error creating contentGenerator: Unsupported authType: ${n.authType}`)}var Fl,hre=It(()=>{"use strict";vWe();L9();(function(n){n.USE_PROXY_AUTH="proxy-auth"})(Fl||(Fl={}))});var mre,uct=It(()=>{"use strict";mre=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 yg(n){let t={type:"subagent_update",data:n,timestamp:Date.now()};return JSON.stringify(t)}function dct(n){let t={type:"text",data:n,timestamp:Date.now()};return JSON.stringify(t)}function pre(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 bre(n){return n.type==="subagent_update"}function Gre(n){return n.type==="text"}var WWe=It(()=>{"use strict";});var sa,kr,oa,os=It(()=>{"use strict";WWe();sa=class{name;displayName;description;icon;parameterSchema;isOutputMarkdown;forceMarkdown;canUpdateOutput;allowSubAgentUse;constructor(t,r,a,i,s,e=!0,c=!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=c,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"})(kr||(kr={}));(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"})(oa||(oa={}))});var il,AWe,Lr,jZ,PD=It(()=>{(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(c=>typeof i[i[c]]!="number"),e={};for(let c of s)e[c]=i[c];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})(il||(il={}));(function(n){n.mergeShapes=(t,r)=>({...t,...r})})(AWe||(AWe={}));Lr=il.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),jZ=n=>{switch(typeof n){case"undefined":return Lr.undefined;case"string":return Lr.string;case"number":return Number.isNaN(n)?Lr.nan:Lr.number;case"boolean":return Lr.boolean;case"function":return Lr.function;case"bigint":return Lr.bigint;case"symbol":return Lr.symbol;case"object":return Array.isArray(n)?Lr.array:n===null?Lr.null:n.then&&typeof n.then=="function"&&n.catch&&typeof n.catch=="function"?Lr.promise:typeof Map<"u"&&n instanceof Map?Lr.map:typeof Set<"u"&&n instanceof Set?Lr.set:typeof Date<"u"&&n instanceof Date?Lr.date:Lr.object;default:return Lr.unknown}}});var dr,y6n,Pp,fre=It(()=>{PD();dr=il.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"]),y6n=n=>JSON.stringify(n,null,2).replace(/"([^"]+)":/g,"$1:"),Pp=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 c=a,u=0;for(;u<e.path.length;){let d=e.path[u];u===e.path.length-1?(c[d]=c[d]||{_errors:[]},c[d]._errors.push(r(e))):c[d]=c[d]||{_errors:[]},c=c[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,il.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()}};Pp.create=n=>new Pp(n)});var R6n,kW,FWe=It(()=>{fre();PD();R6n=(n,t)=>{let r;switch(n.code){case dr.invalid_type:n.received===Lr.undefined?r="Required":r=`Expected ${n.expected}, received ${n.received}`;break;case dr.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(n.expected,il.jsonStringifyReplacer)}`;break;case dr.unrecognized_keys:r=`Unrecognized key(s) in object: ${il.joinValues(n.keys,", ")}`;break;case dr.invalid_union:r="Invalid input";break;case dr.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${il.joinValues(n.options)}`;break;case dr.invalid_enum_value:r=`Invalid enum value. Expected ${il.joinValues(n.options)}, received '${n.received}'`;break;case dr.invalid_arguments:r="Invalid function arguments";break;case dr.invalid_return_type:r="Invalid function return type";break;case dr.invalid_date:r="Invalid date";break;case dr.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}"`:il.assertNever(n.validation):n.validation!=="regex"?r=`Invalid ${n.validation}`:r="Invalid";break;case dr.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 dr.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 dr.custom:r="Invalid input";break;case dr.invalid_intersection_types:r="Intersection results could not be merged";break;case dr.not_multiple_of:r=`Number must be a multiple of ${n.multipleOf}`;break;case dr.not_finite:r="Number must be finite";break;default:r=t.defaultError,il.assertNever(n)}return{message:r}},kW=R6n});function E6n(n){hct=n}function EH(){return hct}var hct,gre=It(()=>{FWe();hct=kW});function xr(n,t){let r=EH(),a=jD({issueData:t,data:n.data,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,r,r===kW?void 0:kW].filter(i=>!!i)});n.common.issues.push(a)}var jD,w6n,g0,Xa,Rw,gh,vre,Zre,ny,wH,yWe=It(()=>{gre();FWe();jD=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 c="",u=a.filter(d=>!!d).slice().reverse();for(let d of u)c=d(e,{data:t,defaultError:c}).message;return{...i,path:s,message:c}},w6n=[];g0=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 Xa;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 Xa;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}}},Xa=Object.freeze({status:"aborted"}),Rw=n=>({status:"dirty",value:n}),gh=n=>({status:"valid",value:n}),vre=n=>n.status==="aborted",Zre=n=>n.status==="dirty",ny=n=>n.status==="valid",wH=n=>typeof Promise<"u"&&n instanceof Promise});var mct=It(()=>{});var ca,pct=It(()=>{(function(n){n.errToObj=t=>typeof t=="string"?{message:t}:t||{},n.toString=t=>typeof t=="string"?t:t?.message})(ca||(ca={}))});function Ni(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,c)=>{let{message:u}=n;return e.code==="invalid_enum_value"?{message:u??c.defaultError}:typeof c.data>"u"?{message:u??a??c.defaultError}:e.code!=="invalid_type"?{message:c.defaultError}:{message:u??r??c.defaultError}},description:i}}function gct(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 M6n(n){return new RegExp(`^${gct(n)}$`)}function vct(n){let t=`${fct}T${gct(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 z6n(n,t){return!!((t==="v4"||!t)&&J6n.test(n)||(t==="v6"||!t)&&B6n.test(n))}function _6n(n,t){if(!H6n.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 P6n(n,t){return!!((t==="v4"||!t)&&S6n.test(n)||(t==="v6"||!t)&&D6n.test(n))}function j6n(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 YH(n){if(n instanceof jp){let t={};for(let r in n.shape){let a=n.shape[r];t[r]=u1.create(YH(a))}return new jp({...n._def,shape:()=>t})}else return n instanceof SW?new SW({...n._def,type:YH(n.element)}):n instanceof u1?u1.create(YH(n.unwrap())):n instanceof qZ?qZ.create(YH(n.unwrap())):n instanceof KZ?KZ.create(n.items.map(t=>YH(t))):n}function EWe(n,t){let r=jZ(n),a=jZ(t);if(n===t)return{valid:!0,data:n};if(r===Lr.object&&a===Lr.object){let i=il.objectKeys(t),s=il.objectKeys(n).filter(c=>i.indexOf(c)!==-1),e={...n,...t};for(let c of s){let u=EWe(n[c],t[c]);if(!u.valid)return{valid:!1};e[c]=u.data}return{valid:!0,data:e}}else if(r===Lr.array&&a===Lr.array){if(n.length!==t.length)return{valid:!1};let i=[];for(let s=0;s<n.length;s++){let e=n[s],c=t[s],u=EWe(e,c);if(!u.valid)return{valid:!1};i.push(u.data)}return{valid:!0,data:i}}else return r===Lr.date&&a===Lr.date&&+n==+t?{valid:!0,data:n}:{valid:!1}}function Zct(n,t){return new Lw({values:n,typeName:Da.ZodEnum,...Ni(t)})}function Gct(n,t){let r=typeof n=="function"?n(t):typeof n=="string"?{message:n}:n;return typeof r=="string"?{message:r}:r}function Nct(n,t={},r){return n?ay.create().superRefine((a,i)=>{let s=n(a);if(s instanceof Promise)return s.then(e=>{if(!e){let c=Gct(t,a),u=c.fatal??r??!0;i.addIssue({code:"custom",...c,fatal:u})}});if(!s){let e=Gct(t,a),c=e.fatal??r??!0;i.addIssue({code:"custom",...e,fatal:c})}}):ay.create()}var d1,bct,Qi,Y6n,C6n,x6n,V6n,Q6n,H6n,X6n,k6n,L6n,RWe,J6n,S6n,B6n,D6n,T6n,O6n,fct,U6n,ry,Ew,ww,Yw,Cw,CH,xw,Vw,ay,JW,Rg,xH,SW,jp,Qw,LW,Nre,Hw,KZ,Wre,VH,QH,Are,Xw,kw,Lw,Jw,iy,h1,u1,qZ,Sw,Bw,HH,K6n,KD,qD,Dw,q6n,Da,$6n,Wct,Act,ekn,tkn,Fct,nkn,rkn,akn,ikn,lkn,skn,okn,ckn,Ikn,ukn,dkn,hkn,mkn,pkn,bkn,Gkn,fkn,gkn,vkn,Zkn,Nkn,Wkn,Akn,Fkn,ykn,Rkn,Ekn,wkn,Ykn,Ckn,xkn,Vkn,Qkn,Hkn,yct=It(()=>{fre();gre();pct();yWe();PD();d1=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}},bct=(n,t)=>{if(ny(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 Pp(n.common.issues);return this._error=r,this._error}}};Qi=class{get description(){return this._def.description}_getType(t){return jZ(t.data)}_getOrReturnCtx(t,r){return r||{common:t.parent.common,data:t.data,parsedType:jZ(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new g0,ctx:{common:t.parent.common,data:t.data,parsedType:jZ(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){let r=this._parse(t);if(wH(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:jZ(t)},i=this._parseSync({data:t,path:a.path,parent:a});return bct(a,i)}"~validate"(t){let r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:jZ(t)};if(!this["~standard"].async)try{let a=this._parseSync({data:t,path:[],parent:r});return ny(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=>ny(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:jZ(t)},i=this._parse({data:t,path:a.path,parent:a}),s=await(wH(i)?i:Promise.resolve(i));return bct(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),c=()=>s.addIssue({code:dr.custom,...a(i)});return typeof Promise<"u"&&e instanceof Promise?e.then(u=>u?!0:(c(),!1)):e?!0:(c(),!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 h1({schema:this,typeName:Da.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 u1.create(this,this._def)}nullable(){return qZ.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return SW.create(this)}promise(){return iy.create(this,this._def)}or(t){return Qw.create([this,t],this._def)}and(t){return Hw.create(this,t,this._def)}transform(t){return new h1({...Ni(this._def),schema:this,typeName:Da.ZodEffects,effect:{type:"transform",transform:t}})}default(t){let r=typeof t=="function"?t:()=>t;return new Sw({...Ni(this._def),innerType:this,defaultValue:r,typeName:Da.ZodDefault})}brand(){return new KD({typeName:Da.ZodBranded,type:this,...Ni(this._def)})}catch(t){let r=typeof t=="function"?t:()=>t;return new Bw({...Ni(this._def),innerType:this,catchValue:r,typeName:Da.ZodCatch})}describe(t){let r=this.constructor;return new r({...this._def,description:t})}pipe(t){return qD.create(this,t)}readonly(){return Dw.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},Y6n=/^c[^\s-]{8,}$/i,C6n=/^[0-9a-z]+$/,x6n=/^[0-9A-HJKMNP-TV-Z]{26}$/i,V6n=/^[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,Q6n=/^[a-z0-9_-]{21}$/i,H6n=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,X6n=/^[-+]?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)?)??$/,k6n=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,L6n="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",J6n=/^(?:(?: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])$/,S6n=/^(?:(?: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])$/,B6n=/^(([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]))$/,D6n=/^(([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])$/,T6n=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,O6n=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,fct="((\\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])))",U6n=new RegExp(`^${fct}$`);ry=class n extends Qi{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==Lr.string){let s=this._getOrReturnCtx(t);return xr(s,{code:dr.invalid_type,expected:Lr.string,received:s.parsedType}),Xa}let a=new g0,i;for(let s of this._def.checks)if(s.kind==="min")t.data.length<s.value&&(i=this._getOrReturnCtx(t,i),xr(i,{code:dr.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),xr(i,{code:dr.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,c=t.data.length<s.value;(e||c)&&(i=this._getOrReturnCtx(t,i),e?xr(i,{code:dr.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):c&&xr(i,{code:dr.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),a.dirty())}else if(s.kind==="email")k6n.test(t.data)||(i=this._getOrReturnCtx(t,i),xr(i,{validation:"email",code:dr.invalid_string,message:s.message}),a.dirty());else if(s.kind==="emoji")RWe||(RWe=new RegExp(L6n,"u")),RWe.test(t.data)||(i=this._getOrReturnCtx(t,i),xr(i,{validation:"emoji",code:dr.invalid_string,message:s.message}),a.dirty());else if(s.kind==="uuid")V6n.test(t.data)||(i=this._getOrReturnCtx(t,i),xr(i,{validation:"uuid",code:dr.invalid_string,message:s.message}),a.dirty());else if(s.kind==="nanoid")Q6n.test(t.data)||(i=this._getOrReturnCtx(t,i),xr(i,{validation:"nanoid",code:dr.invalid_string,message:s.message}),a.dirty());else if(s.kind==="cuid")Y6n.test(t.data)||(i=this._getOrReturnCtx(t,i),xr(i,{validation:"cuid",code:dr.invalid_string,message:s.message}),a.dirty());else if(s.kind==="cuid2")C6n.test(t.data)||(i=this._getOrReturnCtx(t,i),xr(i,{validation:"cuid2",code:dr.invalid_string,message:s.message}),a.dirty());else if(s.kind==="ulid")x6n.test(t.data)||(i=this._getOrReturnCtx(t,i),xr(i,{validation:"ulid",code:dr.invalid_string,message:s.message}),a.dirty());else if(s.kind==="url")try{new URL(t.data)}catch{i=this._getOrReturnCtx(t,i),xr(i,{validation:"url",code:dr.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),xr(i,{validation:"regex",code:dr.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),xr(i,{code:dr.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),xr(i,{code:dr.invalid_string,validation:{startsWith:s.value},message:s.message}),a.dirty()):s.kind==="endsWith"?t.data.endsWith(s.value)||(i=this._getOrReturnCtx(t,i),xr(i,{code:dr.invalid_string,validation:{endsWith:s.value},message:s.message}),a.dirty()):s.kind==="datetime"?vct(s).test(t.data)||(i=this._getOrReturnCtx(t,i),xr(i,{code:dr.invalid_string,validation:"datetime",message:s.message}),a.dirty()):s.kind==="date"?U6n.test(t.data)||(i=this._getOrReturnCtx(t,i),xr(i,{code:dr.invalid_string,validation:"date",message:s.message}),a.dirty()):s.kind==="time"?M6n(s).test(t.data)||(i=this._getOrReturnCtx(t,i),xr(i,{code:dr.invalid_string,validation:"time",message:s.message}),a.dirty()):s.kind==="duration"?X6n.test(t.data)||(i=this._getOrReturnCtx(t,i),xr(i,{validation:"duration",code:dr.invalid_string,message:s.message}),a.dirty()):s.kind==="ip"?z6n(t.data,s.version)||(i=this._getOrReturnCtx(t,i),xr(i,{validation:"ip",code:dr.invalid_string,message:s.message}),a.dirty()):s.kind==="jwt"?_6n(t.data,s.alg)||(i=this._getOrReturnCtx(t,i),xr(i,{validation:"jwt",code:dr.invalid_string,message:s.message}),a.dirty()):s.kind==="cidr"?P6n(t.data,s.version)||(i=this._getOrReturnCtx(t,i),xr(i,{validation:"cidr",code:dr.invalid_string,message:s.message}),a.dirty()):s.kind==="base64"?T6n.test(t.data)||(i=this._getOrReturnCtx(t,i),xr(i,{validation:"base64",code:dr.invalid_string,message:s.message}),a.dirty()):s.kind==="base64url"?O6n.test(t.data)||(i=this._getOrReturnCtx(t,i),xr(i,{validation:"base64url",code:dr.invalid_string,message:s.message}),a.dirty()):il.assertNever(s);return{status:a.value,value:t.data}}_regex(t,r,a){return this.refinement(i=>t.test(i),{validation:r,code:dr.invalid_string,...ca.errToObj(a)})}_addCheck(t){return new n({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...ca.errToObj(t)})}url(t){return this._addCheck({kind:"url",...ca.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...ca.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...ca.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...ca.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...ca.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...ca.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...ca.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...ca.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...ca.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...ca.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...ca.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...ca.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,...ca.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,...ca.errToObj(t?.message)})}duration(t){return this._addCheck({kind:"duration",...ca.errToObj(t)})}regex(t,r){return this._addCheck({kind:"regex",regex:t,...ca.errToObj(r)})}includes(t,r){return this._addCheck({kind:"includes",value:t,position:r?.position,...ca.errToObj(r?.message)})}startsWith(t,r){return this._addCheck({kind:"startsWith",value:t,...ca.errToObj(r)})}endsWith(t,r){return this._addCheck({kind:"endsWith",value:t,...ca.errToObj(r)})}min(t,r){return this._addCheck({kind:"min",value:t,...ca.errToObj(r)})}max(t,r){return this._addCheck({kind:"max",value:t,...ca.errToObj(r)})}length(t,r){return this._addCheck({kind:"length",value:t,...ca.errToObj(r)})}nonempty(t){return this.min(1,ca.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}};ry.create=n=>new ry({checks:[],typeName:Da.ZodString,coerce:n?.coerce??!1,...Ni(n)});Ew=class n extends Qi{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)!==Lr.number){let s=this._getOrReturnCtx(t);return xr(s,{code:dr.invalid_type,expected:Lr.number,received:s.parsedType}),Xa}let a,i=new g0;for(let s of this._def.checks)s.kind==="int"?il.isInteger(t.data)||(a=this._getOrReturnCtx(t,a),xr(a,{code:dr.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),xr(a,{code:dr.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),xr(a,{code:dr.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="multipleOf"?j6n(t.data,s.value)!==0&&(a=this._getOrReturnCtx(t,a),xr(a,{code:dr.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):s.kind==="finite"?Number.isFinite(t.data)||(a=this._getOrReturnCtx(t,a),xr(a,{code:dr.not_finite,message:s.message}),i.dirty()):il.assertNever(s);return{status:i.value,value:t.data}}gte(t,r){return this.setLimit("min",t,!0,ca.toString(r))}gt(t,r){return this.setLimit("min",t,!1,ca.toString(r))}lte(t,r){return this.setLimit("max",t,!0,ca.toString(r))}lt(t,r){return this.setLimit("max",t,!1,ca.toString(r))}setLimit(t,r,a,i){return new n({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:a,message:ca.toString(i)}]})}_addCheck(t){return new n({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:ca.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:ca.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:ca.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:ca.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:ca.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:ca.toString(r)})}finite(t){return this._addCheck({kind:"finite",message:ca.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:ca.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:ca.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"&&il.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)}};Ew.create=n=>new Ew({checks:[],typeName:Da.ZodNumber,coerce:n?.coerce||!1,...Ni(n)});ww=class n extends Qi{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)!==Lr.bigint)return this._getInvalidInput(t);let a,i=new g0;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),xr(a,{code:dr.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),xr(a,{code:dr.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),xr(a,{code:dr.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):il.assertNever(s);return{status:i.value,value:t.data}}_getInvalidInput(t){let r=this._getOrReturnCtx(t);return xr(r,{code:dr.invalid_type,expected:Lr.bigint,received:r.parsedType}),Xa}gte(t,r){return this.setLimit("min",t,!0,ca.toString(r))}gt(t,r){return this.setLimit("min",t,!1,ca.toString(r))}lte(t,r){return this.setLimit("max",t,!0,ca.toString(r))}lt(t,r){return this.setLimit("max",t,!1,ca.toString(r))}setLimit(t,r,a,i){return new n({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:a,message:ca.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:ca.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:ca.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:ca.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:ca.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:ca.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}};ww.create=n=>new ww({checks:[],typeName:Da.ZodBigInt,coerce:n?.coerce??!1,...Ni(n)});Yw=class extends Qi{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==Lr.boolean){let a=this._getOrReturnCtx(t);return xr(a,{code:dr.invalid_type,expected:Lr.boolean,received:a.parsedType}),Xa}return gh(t.data)}};Yw.create=n=>new Yw({typeName:Da.ZodBoolean,coerce:n?.coerce||!1,...Ni(n)});Cw=class n extends Qi{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==Lr.date){let s=this._getOrReturnCtx(t);return xr(s,{code:dr.invalid_type,expected:Lr.date,received:s.parsedType}),Xa}if(Number.isNaN(t.data.getTime())){let s=this._getOrReturnCtx(t);return xr(s,{code:dr.invalid_date}),Xa}let a=new g0,i;for(let s of this._def.checks)s.kind==="min"?t.data.getTime()<s.value&&(i=this._getOrReturnCtx(t,i),xr(i,{code:dr.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),xr(i,{code:dr.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),a.dirty()):il.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:ca.toString(r)})}max(t,r){return this._addCheck({kind:"max",value:t.getTime(),message:ca.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}};Cw.create=n=>new Cw({checks:[],coerce:n?.coerce||!1,typeName:Da.ZodDate,...Ni(n)});CH=class extends Qi{_parse(t){if(this._getType(t)!==Lr.symbol){let a=this._getOrReturnCtx(t);return xr(a,{code:dr.invalid_type,expected:Lr.symbol,received:a.parsedType}),Xa}return gh(t.data)}};CH.create=n=>new CH({typeName:Da.ZodSymbol,...Ni(n)});xw=class extends Qi{_parse(t){if(this._getType(t)!==Lr.undefined){let a=this._getOrReturnCtx(t);return xr(a,{code:dr.invalid_type,expected:Lr.undefined,received:a.parsedType}),Xa}return gh(t.data)}};xw.create=n=>new xw({typeName:Da.ZodUndefined,...Ni(n)});Vw=class extends Qi{_parse(t){if(this._getType(t)!==Lr.null){let a=this._getOrReturnCtx(t);return xr(a,{code:dr.invalid_type,expected:Lr.null,received:a.parsedType}),Xa}return gh(t.data)}};Vw.create=n=>new Vw({typeName:Da.ZodNull,...Ni(n)});ay=class extends Qi{constructor(){super(...arguments),this._any=!0}_parse(t){return gh(t.data)}};ay.create=n=>new ay({typeName:Da.ZodAny,...Ni(n)});JW=class extends Qi{constructor(){super(...arguments),this._unknown=!0}_parse(t){return gh(t.data)}};JW.create=n=>new JW({typeName:Da.ZodUnknown,...Ni(n)});Rg=class extends Qi{_parse(t){let r=this._getOrReturnCtx(t);return xr(r,{code:dr.invalid_type,expected:Lr.never,received:r.parsedType}),Xa}};Rg.create=n=>new Rg({typeName:Da.ZodNever,...Ni(n)});xH=class extends Qi{_parse(t){if(this._getType(t)!==Lr.undefined){let a=this._getOrReturnCtx(t);return xr(a,{code:dr.invalid_type,expected:Lr.void,received:a.parsedType}),Xa}return gh(t.data)}};xH.create=n=>new xH({typeName:Da.ZodVoid,...Ni(n)});SW=class n extends Qi{_parse(t){let{ctx:r,status:a}=this._processInputParams(t),i=this._def;if(r.parsedType!==Lr.array)return xr(r,{code:dr.invalid_type,expected:Lr.array,received:r.parsedType}),Xa;if(i.exactLength!==null){let e=r.data.length>i.exactLength.value,c=r.data.length<i.exactLength.value;(e||c)&&(xr(r,{code:e?dr.too_big:dr.too_small,minimum:c?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&&(xr(r,{code:dr.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&&(xr(r,{code:dr.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,c)=>i.type._parseAsync(new d1(r,e,r.path,c)))).then(e=>g0.mergeArray(a,e));let s=[...r.data].map((e,c)=>i.type._parseSync(new d1(r,e,r.path,c)));return g0.mergeArray(a,s)}get element(){return this._def.type}min(t,r){return new n({...this._def,minLength:{value:t,message:ca.toString(r)}})}max(t,r){return new n({...this._def,maxLength:{value:t,message:ca.toString(r)}})}length(t,r){return new n({...this._def,exactLength:{value:t,message:ca.toString(r)}})}nonempty(t){return this.min(1,t)}};SW.create=(n,t)=>new SW({type:n,minLength:null,maxLength:null,exactLength:null,typeName:Da.ZodArray,...Ni(t)});jp=class n extends Qi{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=il.objectKeys(t);return this._cached={shape:t,keys:r},this._cached}_parse(t){if(this._getType(t)!==Lr.object){let d=this._getOrReturnCtx(t);return xr(d,{code:dr.invalid_type,expected:Lr.object,received:d.parsedType}),Xa}let{status:a,ctx:i}=this._processInputParams(t),{shape:s,keys:e}=this._getCached(),c=[];if(!(this._def.catchall instanceof Rg&&this._def.unknownKeys==="strip"))for(let d in i.data)e.includes(d)||c.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 d1(i,h,i.path,d)),alwaysSet:d in i.data})}if(this._def.catchall instanceof Rg){let d=this._def.unknownKeys;if(d==="passthrough")for(let I of c)u.push({key:{status:"valid",value:I},value:{status:"valid",value:i.data[I]}});else if(d==="strict")c.length>0&&(xr(i,{code:dr.unrecognized_keys,keys:c}),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 c){let h=i.data[I];u.push({key:{status:"valid",value:I},value:d._parse(new d1(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,o=await I.value;d.push({key:h,value:o,alwaysSet:I.alwaysSet})}return d}).then(d=>g0.mergeObjectSync(a,d)):g0.mergeObjectSync(a,u)}get shape(){return this._def.shape()}strict(t){return ca.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:ca.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:Da.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 il.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 il.objectKeys(this.shape))t[a]||(r[a]=this.shape[a]);return new n({...this._def,shape:()=>r})}deepPartial(){return YH(this)}partial(t){let r={};for(let a of il.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 il.objectKeys(this.shape))if(t&&!t[a])r[a]=this.shape[a];else{let s=this.shape[a];for(;s instanceof u1;)s=s._def.innerType;r[a]=s}return new n({...this._def,shape:()=>r})}keyof(){return Zct(il.objectKeys(this.shape))}};jp.create=(n,t)=>new jp({shape:()=>n,unknownKeys:"strip",catchall:Rg.create(),typeName:Da.ZodObject,...Ni(t)});jp.strictCreate=(n,t)=>new jp({shape:()=>n,unknownKeys:"strict",catchall:Rg.create(),typeName:Da.ZodObject,...Ni(t)});jp.lazycreate=(n,t)=>new jp({shape:n,unknownKeys:"strip",catchall:Rg.create(),typeName:Da.ZodObject,...Ni(t)});Qw=class extends Qi{_parse(t){let{ctx:r}=this._processInputParams(t),a=this._def.options;function i(s){for(let c of s)if(c.result.status==="valid")return c.result;for(let c of s)if(c.result.status==="dirty")return r.common.issues.push(...c.ctx.common.issues),c.result;let e=s.map(c=>new Pp(c.ctx.common.issues));return xr(r,{code:dr.invalid_union,unionErrors:e}),Xa}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 c=e.map(u=>new Pp(u));return xr(r,{code:dr.invalid_union,unionErrors:c}),Xa}}get options(){return this._def.options}};Qw.create=(n,t)=>new Qw({options:n,typeName:Da.ZodUnion,...Ni(t)});LW=n=>n instanceof Xw?LW(n.schema):n instanceof h1?LW(n.innerType()):n instanceof kw?[n.value]:n instanceof Lw?n.options:n instanceof Jw?il.objectValues(n.enum):n instanceof Sw?LW(n._def.innerType):n instanceof xw?[void 0]:n instanceof Vw?[null]:n instanceof u1?[void 0,...LW(n.unwrap())]:n instanceof qZ?[null,...LW(n.unwrap())]:n instanceof KD||n instanceof Dw?LW(n.unwrap()):n instanceof Bw?LW(n._def.innerType):[],Nre=class n extends Qi{_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==Lr.object)return xr(r,{code:dr.invalid_type,expected:Lr.object,received:r.parsedType}),Xa;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}):(xr(r,{code:dr.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[a]}),Xa)}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=LW(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 c of e){if(i.has(c))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(c)}`);i.set(c,s)}}return new n({typeName:Da.ZodDiscriminatedUnion,discriminator:t,options:r,optionsMap:i,...Ni(a)})}};Hw=class extends Qi{_parse(t){let{status:r,ctx:a}=this._processInputParams(t),i=(s,e)=>{if(vre(s)||vre(e))return Xa;let c=EWe(s.value,e.value);return c.valid?((Zre(s)||Zre(e))&&r.dirty(),{status:r.value,value:c.data}):(xr(a,{code:dr.invalid_intersection_types}),Xa)};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}))}};Hw.create=(n,t,r)=>new Hw({left:n,right:t,typeName:Da.ZodIntersection,...Ni(r)});KZ=class n extends Qi{_parse(t){let{status:r,ctx:a}=this._processInputParams(t);if(a.parsedType!==Lr.array)return xr(a,{code:dr.invalid_type,expected:Lr.array,received:a.parsedType}),Xa;if(a.data.length<this._def.items.length)return xr(a,{code:dr.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Xa;!this._def.rest&&a.data.length>this._def.items.length&&(xr(a,{code:dr.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let s=[...a.data].map((e,c)=>{let u=this._def.items[c]||this._def.rest;return u?u._parse(new d1(a,e,a.path,c)):null}).filter(e=>!!e);return a.common.async?Promise.all(s).then(e=>g0.mergeArray(r,e)):g0.mergeArray(r,s)}get items(){return this._def.items}rest(t){return new n({...this._def,rest:t})}};KZ.create=(n,t)=>{if(!Array.isArray(n))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new KZ({items:n,typeName:Da.ZodTuple,rest:null,...Ni(t)})};Wre=class n extends Qi{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!==Lr.object)return xr(a,{code:dr.invalid_type,expected:Lr.object,received:a.parsedType}),Xa;let i=[],s=this._def.keyType,e=this._def.valueType;for(let c in a.data)i.push({key:s._parse(new d1(a,c,a.path,c)),value:e._parse(new d1(a,a.data[c],a.path,c)),alwaysSet:c in a.data});return a.common.async?g0.mergeObjectAsync(r,i):g0.mergeObjectSync(r,i)}get element(){return this._def.valueType}static create(t,r,a){return r instanceof Qi?new n({keyType:t,valueType:r,typeName:Da.ZodRecord,...Ni(a)}):new n({keyType:ry.create(),valueType:t,typeName:Da.ZodRecord,...Ni(r)})}},VH=class extends Qi{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!==Lr.map)return xr(a,{code:dr.invalid_type,expected:Lr.map,received:a.parsedType}),Xa;let i=this._def.keyType,s=this._def.valueType,e=[...a.data.entries()].map(([c,u],d)=>({key:i._parse(new d1(a,c,a.path,[d,"key"])),value:s._parse(new d1(a,u,a.path,[d,"value"]))}));if(a.common.async){let c=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 Xa;(d.status==="dirty"||I.status==="dirty")&&r.dirty(),c.set(d.value,I.value)}return{status:r.value,value:c}})}else{let c=new Map;for(let u of e){let d=u.key,I=u.value;if(d.status==="aborted"||I.status==="aborted")return Xa;(d.status==="dirty"||I.status==="dirty")&&r.dirty(),c.set(d.value,I.value)}return{status:r.value,value:c}}}};VH.create=(n,t,r)=>new VH({valueType:t,keyType:n,typeName:Da.ZodMap,...Ni(r)});QH=class n extends Qi{_parse(t){let{status:r,ctx:a}=this._processInputParams(t);if(a.parsedType!==Lr.set)return xr(a,{code:dr.invalid_type,expected:Lr.set,received:a.parsedType}),Xa;let i=this._def;i.minSize!==null&&a.data.size<i.minSize.value&&(xr(a,{code:dr.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&&(xr(a,{code:dr.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 Xa;I.status==="dirty"&&r.dirty(),d.add(I.value)}return{status:r.value,value:d}}let c=[...a.data.values()].map((u,d)=>s._parse(new d1(a,u,a.path,d)));return a.common.async?Promise.all(c).then(u=>e(u)):e(c)}min(t,r){return new n({...this._def,minSize:{value:t,message:ca.toString(r)}})}max(t,r){return new n({...this._def,maxSize:{value:t,message:ca.toString(r)}})}size(t,r){return this.min(t,r).max(t,r)}nonempty(t){return this.min(1,t)}};QH.create=(n,t)=>new QH({valueType:n,minSize:null,maxSize:null,typeName:Da.ZodSet,...Ni(t)});Are=class n extends Qi{constructor(){super(...arguments),this.validate=this.implement}_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==Lr.function)return xr(r,{code:dr.invalid_type,expected:Lr.function,received:r.parsedType}),Xa;function a(c,u){return jD({data:c,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,EH(),kW].filter(d=>!!d),issueData:{code:dr.invalid_arguments,argumentsError:u}})}function i(c,u){return jD({data:c,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,EH(),kW].filter(d=>!!d),issueData:{code:dr.invalid_return_type,returnTypeError:u}})}let s={errorMap:r.common.contextualErrorMap},e=r.data;if(this._def.returns instanceof iy){let c=this;return gh(async function(...u){let d=new Pp([]),I=await c._def.args.parseAsync(u,s).catch(v=>{throw d.addIssue(a(u,v)),d}),h=await Reflect.apply(e,this,I);return await c._def.returns._def.type.parseAsync(h,s).catch(v=>{throw d.addIssue(i(h,v)),d})})}else{let c=this;return gh(function(...u){let d=c._def.args.safeParse(u,s);if(!d.success)throw new Pp([a(u,d.error)]);let I=Reflect.apply(e,this,d.data),h=c._def.returns.safeParse(I,s);if(!h.success)throw new Pp([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:KZ.create(t).rest(JW.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||KZ.create([]).rest(JW.create()),returns:r||JW.create(),typeName:Da.ZodFunction,...Ni(a)})}},Xw=class extends Qi{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})}};Xw.create=(n,t)=>new Xw({getter:n,typeName:Da.ZodLazy,...Ni(t)});kw=class extends Qi{_parse(t){if(t.data!==this._def.value){let r=this._getOrReturnCtx(t);return xr(r,{received:r.data,code:dr.invalid_literal,expected:this._def.value}),Xa}return{status:"valid",value:t.data}}get value(){return this._def.value}};kw.create=(n,t)=>new kw({value:n,typeName:Da.ZodLiteral,...Ni(t)});Lw=class n extends Qi{_parse(t){if(typeof t.data!="string"){let r=this._getOrReturnCtx(t),a=this._def.values;return xr(r,{expected:il.joinValues(a),received:r.parsedType,code:dr.invalid_type}),Xa}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 xr(r,{received:r.data,code:dr.invalid_enum_value,options:a}),Xa}return gh(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})}};Lw.create=Zct;Jw=class extends Qi{_parse(t){let r=il.getValidEnumValues(this._def.values),a=this._getOrReturnCtx(t);if(a.parsedType!==Lr.string&&a.parsedType!==Lr.number){let i=il.objectValues(r);return xr(a,{expected:il.joinValues(i),received:a.parsedType,code:dr.invalid_type}),Xa}if(this._cache||(this._cache=new Set(il.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){let i=il.objectValues(r);return xr(a,{received:a.data,code:dr.invalid_enum_value,options:i}),Xa}return gh(t.data)}get enum(){return this._def.values}};Jw.create=(n,t)=>new Jw({values:n,typeName:Da.ZodNativeEnum,...Ni(t)});iy=class extends Qi{unwrap(){return this._def.type}_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==Lr.promise&&r.common.async===!1)return xr(r,{code:dr.invalid_type,expected:Lr.promise,received:r.parsedType}),Xa;let a=r.parsedType===Lr.promise?r.data:Promise.resolve(r.data);return gh(a.then(i=>this._def.type.parseAsync(i,{path:r.path,errorMap:r.common.contextualErrorMap})))}};iy.create=(n,t)=>new iy({type:n,typeName:Da.ZodPromise,...Ni(t)});h1=class extends Qi{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Da.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=>{xr(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 c=>{if(r.value==="aborted")return Xa;let u=await this._def.schema._parseAsync({data:c,path:a.path,parent:a});return u.status==="aborted"?Xa:u.status==="dirty"?Rw(u.value):r.value==="dirty"?Rw(u.value):u});{if(r.value==="aborted")return Xa;let c=this._def.schema._parseSync({data:e,path:a.path,parent:a});return c.status==="aborted"?Xa:c.status==="dirty"?Rw(c.value):r.value==="dirty"?Rw(c.value):c}}if(i.type==="refinement"){let e=c=>{let u=i.refinement(c,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 c};if(a.common.async===!1){let c=this._def.schema._parseSync({data:a.data,path:a.path,parent:a});return c.status==="aborted"?Xa:(c.status==="dirty"&&r.dirty(),e(c.value),{status:r.value,value:c.value})}else return this._def.schema._parseAsync({data:a.data,path:a.path,parent:a}).then(c=>c.status==="aborted"?Xa:(c.status==="dirty"&&r.dirty(),e(c.value).then(()=>({status:r.value,value:c.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(!ny(e))return Xa;let c=i.transform(e.value,s);if(c instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:c}}else return this._def.schema._parseAsync({data:a.data,path:a.path,parent:a}).then(e=>ny(e)?Promise.resolve(i.transform(e.value,s)).then(c=>({status:r.value,value:c})):Xa);il.assertNever(i)}};h1.create=(n,t,r)=>new h1({schema:n,typeName:Da.ZodEffects,effect:t,...Ni(r)});h1.createWithPreprocess=(n,t,r)=>new h1({schema:t,effect:{type:"preprocess",transform:n},typeName:Da.ZodEffects,...Ni(r)});u1=class extends Qi{_parse(t){return this._getType(t)===Lr.undefined?gh(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};u1.create=(n,t)=>new u1({innerType:n,typeName:Da.ZodOptional,...Ni(t)});qZ=class extends Qi{_parse(t){return this._getType(t)===Lr.null?gh(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};qZ.create=(n,t)=>new qZ({innerType:n,typeName:Da.ZodNullable,...Ni(t)});Sw=class extends Qi{_parse(t){let{ctx:r}=this._processInputParams(t),a=r.data;return r.parsedType===Lr.undefined&&(a=this._def.defaultValue()),this._def.innerType._parse({data:a,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};Sw.create=(n,t)=>new Sw({innerType:n,typeName:Da.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...Ni(t)});Bw=class extends Qi{_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 wH(i)?i.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Pp(a.common.issues)},input:a.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Pp(a.common.issues)},input:a.data})}}removeCatch(){return this._def.innerType}};Bw.create=(n,t)=>new Bw({innerType:n,typeName:Da.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...Ni(t)});HH=class extends Qi{_parse(t){if(this._getType(t)!==Lr.nan){let a=this._getOrReturnCtx(t);return xr(a,{code:dr.invalid_type,expected:Lr.nan,received:a.parsedType}),Xa}return{status:"valid",value:t.data}}};HH.create=n=>new HH({typeName:Da.ZodNaN,...Ni(n)});K6n=Symbol("zod_brand"),KD=class extends Qi{_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}},qD=class n extends Qi{_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"?Xa:s.status==="dirty"?(r.dirty(),Rw(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"?Xa: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:Da.ZodPipeline})}},Dw=class extends Qi{_parse(t){let r=this._def.innerType._parse(t),a=i=>(ny(i)&&(i.value=Object.freeze(i.value)),i);return wH(r)?r.then(i=>a(i)):a(r)}unwrap(){return this._def.innerType}};Dw.create=(n,t)=>new Dw({innerType:n,typeName:Da.ZodReadonly,...Ni(t)});q6n={object:jp.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"})(Da||(Da={}));$6n=(n,t={message:`Input not instance of ${n.name}`})=>Nct(r=>r instanceof n,t),Wct=ry.create,Act=Ew.create,ekn=HH.create,tkn=ww.create,Fct=Yw.create,nkn=Cw.create,rkn=CH.create,akn=xw.create,ikn=Vw.create,lkn=ay.create,skn=JW.create,okn=Rg.create,ckn=xH.create,Ikn=SW.create,ukn=jp.create,dkn=jp.strictCreate,hkn=Qw.create,mkn=Nre.create,pkn=Hw.create,bkn=KZ.create,Gkn=Wre.create,fkn=VH.create,gkn=QH.create,vkn=Are.create,Zkn=Xw.create,Nkn=kw.create,Wkn=Lw.create,Akn=Jw.create,Fkn=iy.create,ykn=h1.create,Rkn=u1.create,Ekn=qZ.create,wkn=h1.createWithPreprocess,Ykn=qD.create,Ckn=()=>Wct().optional(),xkn=()=>Act().optional(),Vkn=()=>Fct().optional(),Qkn={string:(n=>ry.create({...n,coerce:!0})),number:(n=>Ew.create({...n,coerce:!0})),boolean:(n=>Yw.create({...n,coerce:!0})),bigint:(n=>ww.create({...n,coerce:!0})),date:(n=>Cw.create({...n,coerce:!0}))},Hkn=Xa});var Bc={};eo(Bc,{BRAND:()=>K6n,DIRTY:()=>Rw,EMPTY_PATH:()=>w6n,INVALID:()=>Xa,NEVER:()=>Hkn,OK:()=>gh,ParseStatus:()=>g0,Schema:()=>Qi,ZodAny:()=>ay,ZodArray:()=>SW,ZodBigInt:()=>ww,ZodBoolean:()=>Yw,ZodBranded:()=>KD,ZodCatch:()=>Bw,ZodDate:()=>Cw,ZodDefault:()=>Sw,ZodDiscriminatedUnion:()=>Nre,ZodEffects:()=>h1,ZodEnum:()=>Lw,ZodError:()=>Pp,ZodFirstPartyTypeKind:()=>Da,ZodFunction:()=>Are,ZodIntersection:()=>Hw,ZodIssueCode:()=>dr,ZodLazy:()=>Xw,ZodLiteral:()=>kw,ZodMap:()=>VH,ZodNaN:()=>HH,ZodNativeEnum:()=>Jw,ZodNever:()=>Rg,ZodNull:()=>Vw,ZodNullable:()=>qZ,ZodNumber:()=>Ew,ZodObject:()=>jp,ZodOptional:()=>u1,ZodParsedType:()=>Lr,ZodPipeline:()=>qD,ZodPromise:()=>iy,ZodReadonly:()=>Dw,ZodRecord:()=>Wre,ZodSchema:()=>Qi,ZodSet:()=>QH,ZodString:()=>ry,ZodSymbol:()=>CH,ZodTransformer:()=>h1,ZodTuple:()=>KZ,ZodType:()=>Qi,ZodUndefined:()=>xw,ZodUnion:()=>Qw,ZodUnknown:()=>JW,ZodVoid:()=>xH,addIssueToContext:()=>xr,any:()=>lkn,array:()=>Ikn,bigint:()=>tkn,boolean:()=>Fct,coerce:()=>Qkn,custom:()=>Nct,date:()=>nkn,datetimeRegex:()=>vct,defaultErrorMap:()=>kW,discriminatedUnion:()=>mkn,effect:()=>ykn,enum:()=>Wkn,function:()=>vkn,getErrorMap:()=>EH,getParsedType:()=>jZ,instanceof:()=>$6n,intersection:()=>pkn,isAborted:()=>vre,isAsync:()=>wH,isDirty:()=>Zre,isValid:()=>ny,late:()=>q6n,lazy:()=>Zkn,literal:()=>Nkn,makeIssue:()=>jD,map:()=>fkn,nan:()=>ekn,nativeEnum:()=>Akn,never:()=>okn,null:()=>ikn,nullable:()=>Ekn,number:()=>Act,object:()=>ukn,objectUtil:()=>AWe,oboolean:()=>Vkn,onumber:()=>xkn,optional:()=>Rkn,ostring:()=>Ckn,pipeline:()=>Ykn,preprocess:()=>wkn,promise:()=>Fkn,quotelessJson:()=>y6n,record:()=>Gkn,set:()=>gkn,setErrorMap:()=>E6n,strictObject:()=>dkn,string:()=>Wct,symbol:()=>rkn,transformer:()=>ykn,tuple:()=>bkn,undefined:()=>akn,union:()=>hkn,unknown:()=>skn,util:()=>il,void:()=>ckn});var wWe=It(()=>{gre();yWe();mct();PD();yct();fre()});function Ln(n,t,r){function a(c,u){var d;Object.defineProperty(c,"_zod",{value:c._zod??{},enumerable:!1}),(d=c._zod).traits??(d.traits=new Set),c._zod.traits.add(n),t(c,u);for(let I in e.prototype)I in c||Object.defineProperty(c,I,{value:e.prototype[I].bind(c)});c._zod.constr=e,c._zod.def=u}let i=r?.Parent??Object;class s extends i{}Object.defineProperty(s,"name",{value:n});function e(c){var u;let d=r?.Parent?new s:this;a(d,c),(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:c=>r?.Parent&&c instanceof r.Parent?!0:c?._zod?.traits?.has(n)}),Object.defineProperty(e,"name",{value:n}),e}function Yb(n){return n&&Object.assign(Fre,n),Fre}var YWe,Xkn,BW,Fre,XH=It(()=>{YWe=Object.freeze({status:"aborted"});Xkn=Symbol("zod_brand"),BW=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},Fre={}});var cs={};eo(cs,{BIGINT_FORMAT_RANGES:()=>Ect,Class:()=>xWe,NUMBER_FORMAT_RANGES:()=>SWe,aborted:()=>Ow,allowsEval:()=>kWe,assert:()=>Bkn,assertEqual:()=>kkn,assertIs:()=>Jkn,assertNever:()=>Skn,assertNotEqual:()=>Lkn,assignProp:()=>XWe,cached:()=>eT,captureStackTrace:()=>Rre,cleanEnum:()=>eLn,cleanRegex:()=>nT,clone:()=>Eg,createTransparentProxy:()=>zkn,defineLazy:()=>Ho,esc:()=>Tw,escapeRegex:()=>ly,extend:()=>jkn,finalizeIssue:()=>wg,floatSafeRemainder:()=>HWe,getElementAtPath:()=>Dkn,getEnumValues:()=>VWe,getLengthableOrigin:()=>rT,getParsedType:()=>Mkn,getSizableOrigin:()=>wct,isObject:()=>kH,isPlainObject:()=>LH,issue:()=>BWe,joinValues:()=>yre,jsonStringifyReplacer:()=>QWe,merge:()=>Kkn,normalizeParams:()=>Na,nullish:()=>tT,numKeys:()=>Ukn,omit:()=>Pkn,optionalKeys:()=>JWe,partial:()=>qkn,pick:()=>_kn,prefixIssues:()=>$Z,primitiveTypes:()=>Rct,promiseAllObject:()=>Tkn,propertyKeyTypes:()=>LWe,randomString:()=>Okn,required:()=>$kn,stringifyPrimitive:()=>Ere,unwrapMessage:()=>$D});function kkn(n){return n}function Lkn(n){return n}function Jkn(n){}function Skn(n){throw new Error}function Bkn(n){}function VWe(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 yre(n,t="|"){return n.map(r=>Ere(r)).join(t)}function QWe(n,t){return typeof t=="bigint"?t.toString():t}function eT(n){return{get value(){{let r=n();return Object.defineProperty(this,"value",{value:r}),r}throw new Error("cached value already set")}}}function tT(n){return n==null}function nT(n){let t=n.startsWith("^")?1:0,r=n.endsWith("$")?n.length-1:n.length;return n.slice(t,r)}function HWe(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 Ho(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 XWe(n,t,r){Object.defineProperty(n,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function Dkn(n,t){return t?t.reduce((r,a)=>r?.[a],n):n}function Tkn(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 Okn(n=10){let t="abcdefghijklmnopqrstuvwxyz",r="";for(let a=0;a<n;a++)r+=t[Math.floor(Math.random()*t.length)];return r}function Tw(n){return JSON.stringify(n)}function kH(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function LH(n){if(kH(n)===!1)return!1;let t=n.constructor;if(t===void 0)return!0;let r=t.prototype;return!(kH(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function Ukn(n){let t=0;for(let r in n)Object.prototype.hasOwnProperty.call(n,r)&&t++;return t}function ly(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Eg(n,t,r){let a=new n._zod.constr(t??n._zod.def);return(!t||r?.parent)&&(a._zod.parent=n),a}function Na(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 zkn(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 Ere(n){return typeof n=="bigint"?n.toString()+"n":typeof n=="string"?`"${n}"`:`${n}`}function JWe(n){return Object.keys(n).filter(t=>n[t]._zod.optin==="optional"&&n[t]._zod.optout==="optional")}function _kn(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 Eg(n,{...n._zod.def,shape:r,checks:[]})}function Pkn(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 Eg(n,{...n._zod.def,shape:r,checks:[]})}function jkn(n,t){if(!LH(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 XWe(this,"shape",a),a},checks:[]};return Eg(n,r)}function Kkn(n,t){return Eg(n,{...n._zod.def,get shape(){let r={...n._zod.def.shape,...t._zod.def.shape};return XWe(this,"shape",r),r},catchall:t._zod.def.catchall,checks:[]})}function qkn(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 Eg(t,{...t._zod.def,shape:i,checks:[]})}function $kn(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 Eg(t,{...t._zod.def,shape:i,checks:[]})}function Ow(n,t=0){for(let r=t;r<n.issues.length;r++)if(n.issues[r]?.continue!==!0)return!0;return!1}function $Z(n,t){return t.map(r=>{var a;return(a=r).path??(a.path=[]),r.path.unshift(n),r})}function $D(n){return typeof n=="string"?n:n?.message}function wg(n,t,r){let a={...n,path:n.path??[]};if(!n.message){let i=$D(n.inst?._zod.def?.error?.(n))??$D(t?.error?.(n))??$D(r.customError?.(n))??$D(r.localeError?.(n))??"Invalid input";a.message=i}return delete a.inst,delete a.continue,t?.reportInput||delete a.input,a}function wct(n){return n instanceof Set?"set":n instanceof Map?"map":n instanceof File?"file":"unknown"}function rT(n){return Array.isArray(n)?"array":typeof n=="string"?"string":"unknown"}function BWe(...n){let[t,r,a]=n;return typeof t=="string"?{message:t,code:"custom",input:r,inst:a}:{...t}}function eLn(n){return Object.entries(n).filter(([t,r])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}var Rre,kWe,Mkn,LWe,Rct,SWe,Ect,xWe,DW=It(()=>{Rre=Error.captureStackTrace?Error.captureStackTrace:(...n)=>{};kWe=eT(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let n=Function;return new n(""),!0}catch{return!1}});Mkn=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}`)}},LWe=new Set(["string","number","symbol"]),Rct=new Set(["string","number","bigint","boolean","symbol","undefined"]);SWe={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]},Ect={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};xWe=class{constructor(...t){}}});function TWe(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 OWe(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(c=>i({issues:c}));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 c=a,u=0;for(;u<e.path.length;){let d=e.path[u];u===e.path.length-1?(c[d]=c[d]||{_errors:[]},c[d]._errors.push(r(e))):c[d]=c[d]||{_errors:[]},c=c[d],u++}}};return i(n),a}var Yct,wre,DWe,UWe=It(()=>{XH();DW();Yct=(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,QWe,2)},enumerable:!0}),Object.defineProperty(n,"toString",{value:()=>n.message,enumerable:!1})},wre=Ln("$ZodError",Yct),DWe=Ln("$ZodError",Yct,{Parent:Error})});var Cct,xct,MWe,aT,zWe,Yre,_We=It(()=>{XH();UWe();DW();Cct=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 BW;if(e.issues.length){let c=new(i?.Err??n)(e.issues.map(u=>wg(u,s,Yb())));throw Rre(c,i?.callee),c}return e.value},xct=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 c=new(i?.Err??n)(e.issues.map(u=>wg(u,s,Yb())));throw Rre(c,i?.callee),c}return e.value},MWe=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 BW;return s.issues.length?{success:!1,error:new(n??wre)(s.issues.map(e=>wg(e,i,Yb())))}:{success:!0,data:s.value}},aT=MWe(DWe),zWe=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=>wg(e,i,Yb())))}:{success:!0,data:s.value}},Yre=zWe(DWe)});function Dct(){return new RegExp(nLn,"u")}function qct(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 $ct(n){return new RegExp(`^${qct(n)}$`)}function eIt(n){let t=qct({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(`^${jct}T(?:${a})$`)}var Vct,Qct,Hct,Xct,kct,Lct,Jct,Sct,PWe,Bct,nLn,Tct,Oct,Uct,Mct,zct,jWe,_ct,Pct,jct,Kct,tIt,nIt,rIt,aIt,iIt,lIt,sIt,oIt,xre=It(()=>{Vct=/^[cC][^\s-]{8,}$/,Qct=/^[0-9a-z]+$/,Hct=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Xct=/^[0-9a-vA-V]{20}$/,kct=/^[A-Za-z0-9]{27}$/,Lct=/^[a-zA-Z0-9_-]{21}$/,Jct=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Sct=/^([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})$/,PWe=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)$/,Bct=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,nLn="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";Tct=/^(?:(?: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])$/,Oct=/^(([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})$/,Uct=/^((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])$/,Mct=/^(([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])$/,zct=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,jWe=/^[A-Za-z0-9_-]*$/,_ct=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/,Pct=/^\+(?:[0-9]){6,14}[0-9]$/,jct="(?:(?:\\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])))",Kct=new RegExp(`^${jct}$`);tIt=n=>{let t=n?`[\\s\\S]{${n?.minimum??0},${n?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},nIt=/^\d+n?$/,rIt=/^\d+$/,aIt=/^-?\d+(?:\.\d+)?/i,iIt=/true|false/i,lIt=/null/i,sIt=/^[^A-Z]*$/,oIt=/^[^a-z]*$/});var vh,cIt,KWe,qWe,IIt,uIt,dIt,hIt,mIt,iT,pIt,bIt,GIt,fIt,gIt,vIt,ZIt,Vre=It(()=>{XH();xre();DW();vh=Ln("$ZodCheck",(n,t)=>{var r;n._zod??(n._zod={}),n._zod.def=t,(r=n._zod).onattach??(r.onattach=[])}),cIt={number:"number",bigint:"bigint",object:"date"},KWe=Ln("$ZodCheckLessThan",(n,t)=>{vh.init(n,t);let r=cIt[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})}}),qWe=Ln("$ZodCheckGreaterThan",(n,t)=>{vh.init(n,t);let r=cIt[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})}}),IIt=Ln("$ZodCheckMultipleOf",(n,t)=>{vh.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):HWe(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})}}),uIt=Ln("$ZodCheckNumberFormat",(n,t)=>{vh.init(n,t),t.format=t.format||"float64";let r=t.format?.includes("int"),a=r?"int":"number",[i,s]=SWe[t.format];n._zod.onattach.push(e=>{let c=e._zod.bag;c.format=t.format,c.minimum=i,c.maximum=s,r&&(c.pattern=rIt)}),n._zod.check=e=>{let c=e.value;if(r){if(!Number.isInteger(c)){e.issues.push({expected:a,format:t.format,code:"invalid_type",input:c,inst:n});return}if(!Number.isSafeInteger(c)){c>0?e.issues.push({input:c,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:c,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}}c<i&&e.issues.push({origin:"number",input:c,code:"too_small",minimum:i,inclusive:!0,inst:n,continue:!t.abort}),c>s&&e.issues.push({origin:"number",input:c,code:"too_big",maximum:s,inst:n})}}),dIt=Ln("$ZodCheckMaxLength",(n,t)=>{var r;vh.init(n,t),(r=n._zod.def).when??(r.when=a=>{let i=a.value;return!tT(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=rT(i);a.issues.push({origin:e,code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:n,continue:!t.abort})}}),hIt=Ln("$ZodCheckMinLength",(n,t)=>{var r;vh.init(n,t),(r=n._zod.def).when??(r.when=a=>{let i=a.value;return!tT(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=rT(i);a.issues.push({origin:e,code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:n,continue:!t.abort})}}),mIt=Ln("$ZodCheckLengthEquals",(n,t)=>{var r;vh.init(n,t),(r=n._zod.def).when??(r.when=a=>{let i=a.value;return!tT(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=rT(i),c=s>t.length;a.issues.push({origin:e,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:a.value,inst:n,continue:!t.abort})}}),iT=Ln("$ZodCheckStringFormat",(n,t)=>{var r,a;vh.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=()=>{})}),pIt=Ln("$ZodCheckRegex",(n,t)=>{iT.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})}}),bIt=Ln("$ZodCheckLowerCase",(n,t)=>{t.pattern??(t.pattern=sIt),iT.init(n,t)}),GIt=Ln("$ZodCheckUpperCase",(n,t)=>{t.pattern??(t.pattern=oIt),iT.init(n,t)}),fIt=Ln("$ZodCheckIncludes",(n,t)=>{vh.init(n,t);let r=ly(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})}}),gIt=Ln("$ZodCheckStartsWith",(n,t)=>{vh.init(n,t);let r=new RegExp(`^${ly(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})}}),vIt=Ln("$ZodCheckEndsWith",(n,t)=>{vh.init(n,t);let r=new RegExp(`.*${ly(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})}}),ZIt=Ln("$ZodCheckOverwrite",(n,t)=>{vh.init(n,t),n._zod.check=r=>{r.value=t.tx(r.value)}})});var Qre,$We=It(()=>{Qre=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(`
645
645
  `).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(`
646
646
  `))}}});var WIt,eAe=It(()=>{WIt={major:4,minor:0,patch:0}});function qIt(n){if(n==="")return!0;if(n.length%4!==0)return!1;try{return atob(n),!0}catch{return!1}}function rLn(n){if(!jWe.test(n))return!1;let t=n.replace(/[-_]/g,a=>a==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return qIt(r)}function aLn(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 AIt(n,t,r){n.issues.length&&t.issues.push(...$Z(r,n.issues)),t.value[r]=n.value}function Hre(n,t,r){n.issues.length&&t.issues.push(...$Z(r,n.issues)),t.value[r]=n.value}function FIt(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(...$Z(r,n.issues)):n.value===void 0?r in a&&(t.value[r]=void 0):t.value[r]=n.value}function yIt(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=>wg(s,a,Yb())))}),t}function tAe(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(LH(n)&&LH(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=tAe(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=tAe(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 RIt(n,t,r){if(t.issues.length&&n.issues.push(...t.issues),r.issues.length&&n.issues.push(...r.issues),Ow(n))return n;let a=tAe(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 EIt(n,t){return n.value===void 0&&(n.value=t.defaultValue),n}function wIt(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 YIt(n,t,r){return Ow(n)?n:t.out._zod.run({value:n.value,issues:n.issues},r)}function CIt(n){return n.value=Object.freeze(n.value),n}function xIt(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(BWe(i))}}var Ms,Xre,$o,VIt,QIt,HIt,XIt,kIt,LIt,JIt,SIt,BIt,DIt,TIt,OIt,UIt,MIt,zIt,_It,PIt,jIt,KIt,$It,eut,tut,nut,nAe,rut,aut,iut,lut,sut,out,cut,Iut,uut,dut,rAe,hut,mut,put,but,Gut,fut,gut,vut,Zut,Nut,Wut,Aut,Fut,yut,Rut,Eut=It(()=>{Vre();XH();$We();_We();xre();DW();eAe();DW();Ms=Ln("$ZodType",(n,t)=>{var r;n??(n={}),n._zod.def=t,n._zod.bag=n._zod.bag||{},n._zod.version=WIt;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,c)=>{let u=Ow(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,o=I._zod.check(s);if(o instanceof Promise&&c?.async===!1)throw new BW;if(d||o instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await o,s.issues.length!==h&&(u||(u=Ow(s,h)))});else{if(s.issues.length===h)continue;u||(u=Ow(s,h))}}return d?d.then(()=>s):s};n._zod.run=(s,e)=>{let c=n._zod.parse(s,e);if(c instanceof Promise){if(e.async===!1)throw new BW;return c.then(u=>i(u,a,e))}return i(c,a,e)}}n["~standard"]={validate:i=>{try{let s=aT(n,i);return s.success?{value:s.data}:{issues:s.error?.issues}}catch{return Yre(n,i).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:"zod",version:1}}),Xre=Ln("$ZodString",(n,t)=>{Ms.init(n,t),n._zod.pattern=[...n?._zod.bag?.patterns??[]].pop()??tIt(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}}),$o=Ln("$ZodStringFormat",(n,t)=>{iT.init(n,t),Xre.init(n,t)}),VIt=Ln("$ZodGUID",(n,t)=>{t.pattern??(t.pattern=Sct),$o.init(n,t)}),QIt=Ln("$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=PWe(a))}else t.pattern??(t.pattern=PWe());$o.init(n,t)}),HIt=Ln("$ZodEmail",(n,t)=>{t.pattern??(t.pattern=Bct),$o.init(n,t)}),XIt=Ln("$ZodURL",(n,t)=>{$o.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:_ct.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})}}}),kIt=Ln("$ZodEmoji",(n,t)=>{t.pattern??(t.pattern=Dct()),$o.init(n,t)}),LIt=Ln("$ZodNanoID",(n,t)=>{t.pattern??(t.pattern=Lct),$o.init(n,t)}),JIt=Ln("$ZodCUID",(n,t)=>{t.pattern??(t.pattern=Vct),$o.init(n,t)}),SIt=Ln("$ZodCUID2",(n,t)=>{t.pattern??(t.pattern=Qct),$o.init(n,t)}),BIt=Ln("$ZodULID",(n,t)=>{t.pattern??(t.pattern=Hct),$o.init(n,t)}),DIt=Ln("$ZodXID",(n,t)=>{t.pattern??(t.pattern=Xct),$o.init(n,t)}),TIt=Ln("$ZodKSUID",(n,t)=>{t.pattern??(t.pattern=kct),$o.init(n,t)}),OIt=Ln("$ZodISODateTime",(n,t)=>{t.pattern??(t.pattern=eIt(t)),$o.init(n,t)}),UIt=Ln("$ZodISODate",(n,t)=>{t.pattern??(t.pattern=Kct),$o.init(n,t)}),MIt=Ln("$ZodISOTime",(n,t)=>{t.pattern??(t.pattern=$ct(t)),$o.init(n,t)}),zIt=Ln("$ZodISODuration",(n,t)=>{t.pattern??(t.pattern=Jct),$o.init(n,t)}),_It=Ln("$ZodIPv4",(n,t)=>{t.pattern??(t.pattern=Tct),$o.init(n,t),n._zod.onattach.push(r=>{let a=r._zod.bag;a.format="ipv4"})}),PIt=Ln("$ZodIPv6",(n,t)=>{t.pattern??(t.pattern=Oct),$o.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})}}}),jIt=Ln("$ZodCIDRv4",(n,t)=>{t.pattern??(t.pattern=Uct),$o.init(n,t)}),KIt=Ln("$ZodCIDRv6",(n,t)=>{t.pattern??(t.pattern=Mct),$o.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})}}});$It=Ln("$ZodBase64",(n,t)=>{t.pattern??(t.pattern=zct),$o.init(n,t),n._zod.onattach.push(r=>{r._zod.bag.contentEncoding="base64"}),n._zod.check=r=>{qIt(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:n,continue:!t.abort})}});eut=Ln("$ZodBase64URL",(n,t)=>{t.pattern??(t.pattern=jWe),$o.init(n,t),n._zod.onattach.push(r=>{r._zod.bag.contentEncoding="base64url"}),n._zod.check=r=>{rLn(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:n,continue:!t.abort})}}),tut=Ln("$ZodE164",(n,t)=>{t.pattern??(t.pattern=Pct),$o.init(n,t)});nut=Ln("$ZodJWT",(n,t)=>{$o.init(n,t),n._zod.check=r=>{aLn(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:n,continue:!t.abort})}}),nAe=Ln("$ZodNumber",(n,t)=>{Ms.init(n,t),n._zod.pattern=n._zod.bag.pattern??aIt,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}}),rut=Ln("$ZodNumber",(n,t)=>{uIt.init(n,t),nAe.init(n,t)}),aut=Ln("$ZodBoolean",(n,t)=>{Ms.init(n,t),n._zod.pattern=iIt,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}}),iut=Ln("$ZodBigInt",(n,t)=>{Ms.init(n,t),n._zod.pattern=nIt,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}}),lut=Ln("$ZodNull",(n,t)=>{Ms.init(n,t),n._zod.pattern=lIt,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}}),sut=Ln("$ZodAny",(n,t)=>{Ms.init(n,t),n._zod.parse=r=>r}),out=Ln("$ZodUnknown",(n,t)=>{Ms.init(n,t),n._zod.parse=r=>r}),cut=Ln("$ZodNever",(n,t)=>{Ms.init(n,t),n._zod.parse=(r,a)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:n}),r)}),Iut=Ln("$ZodDate",(n,t)=>{Ms.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}});uut=Ln("$ZodArray",(n,t)=>{Ms.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 c=i[e],u=t.element._zod.run({value:c,issues:[]},a);u instanceof Promise?s.push(u.then(d=>AIt(d,r,e))):AIt(u,r,e)}return s.length?Promise.all(s).then(()=>r):r}});dut=Ln("$ZodObject",(n,t)=>{Ms.init(n,t);let r=eT(()=>{let h=Object.keys(t.shape);for(let v of h)if(!(t.shape[v]instanceof Ms))throw new Error(`Invalid element at key "${v}": expected a Zod schema`);let o=JWe(t.shape);return{shape:t.shape,keys:h,keySet:new Set(h),numKeys:h.length,optionalKeys:new Set(o)}});Ho(n._zod,"propValues",()=>{let h=t.shape,o={};for(let v in h){let w=h[v]._zod;if(w.values){o[v]??(o[v]=new Set);for(let R of w.values)o[v].add(R)}}return o});let a=h=>{let o=new Qre(["shape","payload","ctx"]),v=r.value,w=Y=>{let W=Tw(Y);return`shape[${W}]._zod.run({ value: input[${W}], issues: [] }, ctx)`};o.write("const input = payload.value;");let R=Object.create(null),E=0;for(let Y of v.keys)R[Y]=`key_${E++}`;o.write("const newResult = {}");for(let Y of v.keys)if(v.optionalKeys.has(Y)){let W=R[Y];o.write(`const ${W} = ${w(Y)};`);let y=Tw(Y);o.write(`
647
647
  if (${W}.issues.length) {
@@ -4102,7 +4102,7 @@ ${Ke("model.command.auto.mode")}`),a({type:"info",text:o},Date.now()),r(null)}ca
4102
4102
  `,t-1),[i,s]=ICr(r);return{line:a===-1?i:n.slice(0,a+1).match(/\n/g).length+i,column:t-a-1+s}}function oBe(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 uCr(n,t,r)}var dCr=n=>`\\u{${n.codePointAt(0).toString(16)}}`,cBe=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??=`${mCr(this.#t.message)}${this.#e===""?" while parsing empty string":""}`;let{codeFrame:t}=this;return`${this.#n}${this.fileName?` in ${this.fileName}`:""}${t?`
4103
4103
 
4104
4104
  ${t}
4105
- `:""}`}set message(t){this.#n=t}#i(t){if(!this.#t)return;let r=this.#e,a=hCr(r,this.#t.message);if(a)return(0,V$t.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}},hCr=(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)}:oBe(n,Number(a),{oneBased:!0})},mCr=n=>n.replace(/(?<=^Unexpected token )(?<quote>')?(.)\k<quote>/,(t,r,a)=>`"${a}"(${dCr(a)})`);function IBe(n,t,r){typeof t=="string"&&(r=t,t=void 0);try{return JSON.parse(n,t)}catch(a){throw new cBe({jsonParseError:a,fileName:r,input:n})}}var Ten=Dt(Ben(),1);import{fileURLToPath as kxr}from"node:url";function Den(n){return n instanceof URL?kxr(n):n}var Sxr=n=>Jxr.resolve(Den(n)??".","package.json"),Bxr=(n,t)=>{let r=typeof n=="string"?IBe(n):n;return t&&(0,Ten.default)(r),r};async function Oen({cwd:n,normalize:t=!0}={}){let r=await Lxr.readFile(Sxr(n),"utf8");return Bxr(r,t)}async function Uen(n){let t=await o$t("package.json",n);if(t)return{packageJson:await Oen({...n,cwd:Dxr.dirname(t)}),path:t}}import{fileURLToPath as Txr}from"url";import Oxr from"path";var Uxr=Txr(import.meta.url),Mxr=Oxr.dirname(Uxr),cme;async function RS(){if(cme)return cme;let n=await Uen({cwd:Mxr});if(n)return cme=n.packageJson,cme}async function ES(){let n=await RS();return"1.0.258"}Ai();import Sx from"node:process";Nr();var Men={name:"about",description:Ke("command.about.description"),kind:"built-in",action:async n=>{let t=Sx.platform,r="no sandbox";Sx.env.SANDBOX&&Sx.env.SANDBOX!=="sandbox-exec"?r=Sx.env.SANDBOX:Sx.env.SANDBOX==="sandbox-exec"&&(r=`sandbox-exec (${Sx.env.SEATBELT_PROFILE||"unknown"})`);let a=n.services.config?.getModel()||"Unknown",i=await ES(),s=n.services.settings.merged.selectedAuthType||"",e=Sx.env.GOOGLE_CLOUD_PROJECT||"",c={type:"about",cliVersion:i,osVersion:t,sandboxEnv:r,modelVersion:a,selectedAuthType:s,gcpProject:e};n.ui.addItem(c,Date.now())}};Ai();Nr();var zen={name:"auth",description:Ke("command.auth.description"),kind:"built-in",action:(n,t)=>({type:"dialog",dialog:"auth"})};Ai();Nr();var _en={name:"clear",description:Ke("command.clear.description"),kind:"built-in",action:async(n,t)=>{n.ui.setDebugMessage("Clearing terminal screen."),n.ui.clear()}};Ai();Nr();var Pen={name:"compress",altNames:["summarize"],description:Ke("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:Ke("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)}}};Ai();Nr();var jen={name:"copy",description:Ke("command.copy.description"),kind:"built-in",action:async(n,t)=>{let a=(await n.services.config?.getGeminiClient()?.getChat())?.getHistory(),i=a?a.filter(e=>e.role==="model").pop():void 0;if(!i)return{type:"message",messageType:"info",content:"No output in history"};let s=i.parts?.filter(e=>e.text).map(e=>e.text).join("");if(s)try{return await XKt(s),{type:"message",messageType:"info",content:"\u{1F4CB}\u5DF2\u590D\u5236\u5230\u7C98\u8D34\u677F"}}catch(e){let c=e instanceof Error?e.message:String(e);return console.debug(c),{type:"message",messageType:"error",content:"Failed to copy to the clipboard."}}else return{type:"message",messageType:"info",content:"Last AI output contains no text to copy."}}};Ai();Nr();var Ken={name:"editor",description:Ke("command.editor.description"),kind:"built-in",action:()=>({type:"dialog",dialog:"editor"})};Ai();Nr();Wr();import{promises as xBe}from"fs";import*as wS from"path";import{execFile as VBe}from"child_process";function zxr(n){return new Promise(t=>{let r=process.platform;try{if(r==="darwin")VBe("open",["-R",n],a=>{a&&console.warn(`Unable to open file in Finder: ${a.message}`),t()});else if(r==="win32"){let a=wS.win32.normalize(n);VBe("explorer.exe",[`/select,${a}`],i=>{i&&console.warn(`Unable to open file in Explorer: ${i.message}`),t()})}else VBe("xdg-open",[wS.dirname(n)],a=>{a&&console.warn(`Unable to open file browser: ${a.message}`),t()})}catch(a){console.warn(`Error opening file browser: ${a instanceof Error?a.message:String(a)}`),t()}})}async function Ime(n,t){try{await xBe.access(t,xBe.constants.W_OK)}catch(d){throw new Error(`No write permission for project root: ${t}. Error: ${d instanceof Error?d.message:String(d)}`)}let r=new Ls(t),a;try{a=await r.loadSession(n)}catch(d){throw new Error(`Failed to load session ${n}. Error: ${d instanceof Error?d.message:String(d)}`)}if(!a)throw new Error(`Session ${n} not found or returned null.`);if(!a.history)throw new Error(`Session ${n} has no history. Session data may be corrupted.`);if(a.history.length===0)throw new Error(`Session ${n} has empty history.`);a.metadata||(console.warn(`Session ${n} metadata is missing. Using defaults.`),a.metadata={title:n,createdAt:new Date().toISOString(),model:"Unknown"});let i=`
4105
+ `:""}`}set message(t){this.#n=t}#i(t){if(!this.#t)return;let r=this.#e,a=hCr(r,this.#t.message);if(a)return(0,V$t.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}},hCr=(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)}:oBe(n,Number(a),{oneBased:!0})},mCr=n=>n.replace(/(?<=^Unexpected token )(?<quote>')?(.)\k<quote>/,(t,r,a)=>`"${a}"(${dCr(a)})`);function IBe(n,t,r){typeof t=="string"&&(r=t,t=void 0);try{return JSON.parse(n,t)}catch(a){throw new cBe({jsonParseError:a,fileName:r,input:n})}}var Ten=Dt(Ben(),1);import{fileURLToPath as kxr}from"node:url";function Den(n){return n instanceof URL?kxr(n):n}var Sxr=n=>Jxr.resolve(Den(n)??".","package.json"),Bxr=(n,t)=>{let r=typeof n=="string"?IBe(n):n;return t&&(0,Ten.default)(r),r};async function Oen({cwd:n,normalize:t=!0}={}){let r=await Lxr.readFile(Sxr(n),"utf8");return Bxr(r,t)}async function Uen(n){let t=await o$t("package.json",n);if(t)return{packageJson:await Oen({...n,cwd:Dxr.dirname(t)}),path:t}}import{fileURLToPath as Txr}from"url";import Oxr from"path";var Uxr=Txr(import.meta.url),Mxr=Oxr.dirname(Uxr),cme;async function RS(){if(cme)return cme;let n=await Uen({cwd:Mxr});if(n)return cme=n.packageJson,cme}async function ES(){let n=await RS();return"1.0.259"}Ai();import Sx from"node:process";Nr();var Men={name:"about",description:Ke("command.about.description"),kind:"built-in",action:async n=>{let t=Sx.platform,r="no sandbox";Sx.env.SANDBOX&&Sx.env.SANDBOX!=="sandbox-exec"?r=Sx.env.SANDBOX:Sx.env.SANDBOX==="sandbox-exec"&&(r=`sandbox-exec (${Sx.env.SEATBELT_PROFILE||"unknown"})`);let a=n.services.config?.getModel()||"Unknown",i=await ES(),s=n.services.settings.merged.selectedAuthType||"",e=Sx.env.GOOGLE_CLOUD_PROJECT||"",c={type:"about",cliVersion:i,osVersion:t,sandboxEnv:r,modelVersion:a,selectedAuthType:s,gcpProject:e};n.ui.addItem(c,Date.now())}};Ai();Nr();var zen={name:"auth",description:Ke("command.auth.description"),kind:"built-in",action:(n,t)=>({type:"dialog",dialog:"auth"})};Ai();Nr();var _en={name:"clear",description:Ke("command.clear.description"),kind:"built-in",action:async(n,t)=>{n.ui.setDebugMessage("Clearing terminal screen."),n.ui.clear()}};Ai();Nr();var Pen={name:"compress",altNames:["summarize"],description:Ke("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:Ke("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)}}};Ai();Nr();var jen={name:"copy",description:Ke("command.copy.description"),kind:"built-in",action:async(n,t)=>{let a=(await n.services.config?.getGeminiClient()?.getChat())?.getHistory(),i=a?a.filter(e=>e.role==="model").pop():void 0;if(!i)return{type:"message",messageType:"info",content:"No output in history"};let s=i.parts?.filter(e=>e.text).map(e=>e.text).join("");if(s)try{return await XKt(s),{type:"message",messageType:"info",content:"\u{1F4CB}\u5DF2\u590D\u5236\u5230\u7C98\u8D34\u677F"}}catch(e){let c=e instanceof Error?e.message:String(e);return console.debug(c),{type:"message",messageType:"error",content:"Failed to copy to the clipboard."}}else return{type:"message",messageType:"info",content:"Last AI output contains no text to copy."}}};Ai();Nr();var Ken={name:"editor",description:Ke("command.editor.description"),kind:"built-in",action:()=>({type:"dialog",dialog:"editor"})};Ai();Nr();Wr();import{promises as xBe}from"fs";import*as wS from"path";import{execFile as VBe}from"child_process";function zxr(n){return new Promise(t=>{let r=process.platform;try{if(r==="darwin")VBe("open",["-R",n],a=>{a&&console.warn(`Unable to open file in Finder: ${a.message}`),t()});else if(r==="win32"){let a=wS.win32.normalize(n);VBe("explorer.exe",[`/select,${a}`],i=>{i&&console.warn(`Unable to open file in Explorer: ${i.message}`),t()})}else VBe("xdg-open",[wS.dirname(n)],a=>{a&&console.warn(`Unable to open file browser: ${a.message}`),t()})}catch(a){console.warn(`Error opening file browser: ${a instanceof Error?a.message:String(a)}`),t()}})}async function Ime(n,t){try{await xBe.access(t,xBe.constants.W_OK)}catch(d){throw new Error(`No write permission for project root: ${t}. Error: ${d instanceof Error?d.message:String(d)}`)}let r=new Ls(t),a;try{a=await r.loadSession(n)}catch(d){throw new Error(`Failed to load session ${n}. Error: ${d instanceof Error?d.message:String(d)}`)}if(!a)throw new Error(`Session ${n} not found or returned null.`);if(!a.history)throw new Error(`Session ${n} has no history. Session data may be corrupted.`);if(a.history.length===0)throw new Error(`Session ${n} has empty history.`);a.metadata||(console.warn(`Session ${n} metadata is missing. Using defaults.`),a.metadata={title:n,createdAt:new Date().toISOString(),model:"Unknown"});let i=`
4106
4106
  `,s="# Session Log: "+(a.metadata.title||n)+i+i;s+="- **Session ID:** "+n+i,s+="- **Date:** "+new Date(a.metadata.createdAt||new Date).toLocaleString()+i,s+="- **Model:** "+(a.metadata.model||"Unknown")+i+i,s+="---"+i+i;for(let d of a.history)if(d.type==="user")s+="### \u{1F464} User"+i+i+(d.text||"")+i+i;else if(d.type==="gemini"||d.type==="gemini_content")s+="### \u{1F916} Assistant"+i+i+(d.text||"")+i+i;else if(d.type==="deepv")s+="### \u{1F916} Assistant (System)"+i+i+(d.content||"")+i+i;else if(d.type==="tool_group"&&(s+="#### \u{1F6E0}\uFE0F Tool Calls"+i+i,d.tools&&Array.isArray(d.tools)))for(let I of d.tools)s+="<details>"+i+"<summary>"+I.name+" ("+(I.status||"Success")+")</summary>"+i+i,s+="**Arguments:**"+i+"```json"+i+JSON.stringify(I.confirmationDetails?.args||{},null,2)+i+"```"+i+i,I.resultDisplay&&(s+="**Result:**"+i+(I.resultDisplay.content||"")+i+i),s+="</details>"+i+i;let e=new Date().toISOString().slice(0,19).replace(/[T:]/g,"-"),c="session_export_"+n.substring(0,8)+"_"+e+".md",u=wS.resolve(t,c);try{await xBe.writeFile(u,s,"utf-8")}catch(d){throw new Error(`Failed to write session export file to ${u}. Error: ${d instanceof Error?d.message:String(d)}`)}return await zxr(u),u}var qen={name:"export",description:Ke("command.export.description"),kind:"built-in",action:async n=>{let{config:t}=n.services;if(!t)return{type:"message",messageType:"error",content:Ke("export.no_config")};let r=t.getSessionId(),a=t.getProjectRoot()||process.cwd();try{let i=await Ime(r,a);return{type:"message",messageType:"info",content:ln("export.success",{path:i})}}catch(i){return{type:"message",messageType:"error",content:ln("export.failed",{error:i instanceof Error?i.message:String(i)})}}}};Ai();Nr();import{promises as QBe}from"fs";import*as YS from"path";import{execFile as HBe}from"child_process";function _xr(n){return new Promise(t=>{let r=process.platform;try{if(r==="darwin")HBe("open",["-R",n],a=>{a&&console.warn(`Unable to open file in Finder: ${a.message}`),t()});else if(r==="win32"){let a=YS.win32.normalize(n);HBe("explorer.exe",[`/select,${a}`],i=>{i&&console.warn(`Unable to open file in Explorer: ${i.message}`),t()})}else HBe("xdg-open",[YS.dirname(n)],a=>{a&&console.warn(`Unable to open file browser: ${a.message}`),t()})}catch(a){console.warn(`Error opening file browser: ${a instanceof Error?a.message:String(a)}`),t()}})}async function $en(n,t,r){try{await QBe.access(t,QBe.constants.W_OK)}catch(d){throw new Error(`No write permission for project root: ${t}. Error: ${d instanceof Error?d.message:String(d)}`)}if(!n||n.length===0)throw new Error("No debug messages to export.");let a=n.filter(d=>!d||typeof d!="object"?(console.warn("Skipping invalid debug message item."),!1):!d.type||!d.content?(console.warn("Skipping debug message with missing type or content. Message:",d),!1):d.type==="error"||d.type==="warn");if(a.length===0)throw new Error("NO_ERRORS_OR_WARNINGS");let i=`
4107
4107
  `,s="# Debug Log: "+r+i+i;s+="- **Date:** "+new Date().toLocaleString()+i,s+="- **Platform:** "+process.platform+i,s+="- **Architecture:** "+process.arch+i,s+="- **Total Messages:** "+a.length+i+i,s+="---"+i+i;for(let d of a){let I=d.type==="error"?"\u274C ":d.type==="warn"?"\u26A0\uFE0F ":d.type==="debug"?"\u{1F50D} ":"\u{1F4DD} ",h=d.count||1;s+="### "+I+d.type.toUpperCase()+" (count: "+h+")"+i+i,s+="```"+i+d.content+i+"```"+i+i}let e=new Date().toISOString().slice(0,19).replace(/[T:]/g,"-"),c="debug_export_"+r.substring(0,8)+"_"+e+".md",u=YS.resolve(t,c);try{await QBe.writeFile(u,s,"utf-8")}catch(d){throw new Error(`Failed to write debug export file to ${u}. Error: ${d instanceof Error?d.message:String(d)}`)}return await _xr(u),u}var etn={name:"export-debug",description:Ke("command.export_debug.description"),kind:"built-in",action:async n=>{let{config:t}=n.services,{debugMessages:r}=n.ui;if(!t)return{type:"message",messageType:"error",content:Ke("export.no_config")};if(!r||r.length===0)return{type:"message",messageType:"info",content:Ke("export_debug.no_messages")};let a=t.getSessionId(),i=t.getProjectRoot()||process.cwd();try{let s=await $en(r,i,a);return{type:"message",messageType:"info",content:ln("export.success",{path:s})}}catch(s){return s instanceof Error&&s.message==="NO_ERRORS_OR_WARNINGS"?{type:"message",messageType:"info",content:Ke("export_debug.no_errors")}:{type:"message",messageType:"error",content:ln("export.failed",{error:s instanceof Error?s.message:String(s)})}}}};Ai();Nr();var Pxr={name:"list",description:"List all active extensions",kind:"built-in",action:async n=>{let t=n.services.config?.getExtensions().filter(i=>i.isActive);if(!t||t.length===0){n.ui.addItem({type:"info",text:"No active extensions."},Date.now());return}let a=`Active extensions:
4108
4108
 
@@ -4895,7 +4895,7 @@ ${B.subCommands.map(S=>` - ${S.name}: ${S.description||""}`).join(`
4895
4895
  \u2580\u2588\u2588\u2588\u2588\u2580
4896
4896
  \u2580\u2588\u2588\u2580
4897
4897
  \u2580\u2580
4898
- `;function Xsn(n,t=!1){return t?`v${n}(${process.versions.node})`:`v${n}`}function rV(n,t=!1){if(!t)return n;let r=[/^Claude-(?:3\.5-)?(.+)$/i,/^Claude-(.+)$/i,/^Gemini-(?:2\.0-)?(.+)$/i,/^Gemini-(.+)$/i,/^GPT-(.+)$/i,/^OpenAI-(.+)$/i];for(let a of r){let i=n.match(a);if(i&&i[1])return i[1]}return n}function ksn(n,t=!1){if((typeof n=="string"?parseFloat(n):n)===100)return"";let a=`${n}%`;return t?a:`(${a} context left)`}function Lsn(n){return n>=80?{showNodeVersion:!0,simplifyContext:!1,simplifyModel:!1,level:"full"}:{showNodeVersion:!1,simplifyContext:!0,simplifyModel:!0,level:"compact"}}var gs=Dt(Xn(),1);var Jsn=["tip.help","tip.theme","tip.auth","tip.stats","tip.memory","tip.mcp","tip.tools","tip.init","tip.model","tip.plan","tip.docs","tip.session","tip.restore","tip.at.filepath","tip.shell.command","tip.shell.mode","tip.ctrl.j","tip.cli.update","tip.cli.cloud"];function FJr(n){let r=new Date().getTime()-n.getTime(),a=Math.floor(r/6e4),i=Math.floor(r/36e5),s=Math.floor(r/864e5),e=Math.floor(r/6048e5);return a<1?"just now":a<60?`${a}m ago`:i<24?`${i}h ago`:s<7?`${s}d ago`:`${e}w ago`}var Ssn=({config:n,version:t,customProxyUrl:r})=>{let a=(0,B5.useMemo)(()=>Vs.getInstance().getUserInfo()?.name,[]),i=(0,B5.useMemo)(()=>{let h=n.getModel(),o=n.getCloudModelInfo(h);if(o){let R=o.creditsPerRequest;return{displayName:rV(o.displayName,!0),creditsText:`${R}x credits`}}return{displayName:rV(h==="auto"?"Gemini":h,!0),creditsText:"API Usage Billing"}},[n]),[s,e]=(0,B5.useState)([]);(0,B5.useEffect)(()=>{(async()=>{await new Promise(o=>setTimeout(o,1e3));try{let w=(await new Ls(n.getProjectRoot()).listSessions()).slice(0,4).map(R=>({time:FJr(new Date(R.lastActiveAt)),description:R.title||R.firstUserMessage?.slice(0,30)||"Untitled session"}));e(w)}catch{}})()},[n]);let c=(0,B5.useMemo)(()=>{let h=n.getProjectRoot();return AJr.basename(h)},[n]),u=n.getProjectRoot(),d=(0,B5.useMemo)(()=>{let h=Math.floor(Math.random()*Jsn.length),o=Jsn[h];return Ke(o)},[]),I=a?`Welcome back, ${a}!`:"Welcome to DeepV Code!";return(0,gs.jsxs)(Gt,{flexDirection:"column",marginBottom:1,borderStyle:"round",borderColor:"gray",paddingX:1,minWidth:80,children:[(0,gs.jsxs)(Gt,{flexDirection:"row",marginBottom:1,children:[(0,gs.jsx)(Gt,{marginRight:2,children:(0,gs.jsx)(rt,{color:pt.Foreground,children:Hsn})}),(0,gs.jsxs)(Gt,{flexDirection:"column",justifyContent:"center",children:[(0,gs.jsx)(rt,{children:"DeepV Code "}),(0,gs.jsxs)(rt,{dimColor:!0,children:["v",t]}),(0,gs.jsxs)(rt,{dimColor:!0,children:[i.displayName," \xB7 ",i.creditsText]})]})]}),(0,gs.jsx)(Gt,{children:(0,gs.jsx)(rt,{color:pt.AccentGreen,children:I})}),(0,gs.jsxs)(Gt,{flexDirection:"column",children:[(0,gs.jsx)(Gt,{children:(0,gs.jsx)(rt,{dimColor:!0,children:u})}),r&&(0,gs.jsxs)(Gt,{flexDirection:"column",marginBottom:1,children:[(0,gs.jsxs)(rt,{color:pt.AccentOrange,children:["\u{1F517} Custom server: ",r]}),(0,gs.jsx)(rt,{color:pt.AccentOrange,children:" Please verify trustworthiness and monitor your API usage."})]}),s.length>0&&(0,gs.jsxs)(Gt,{flexDirection:"column",children:[(0,gs.jsx)(rt,{color:pt.AccentOrange,children:"Recent activity"}),(0,gs.jsxs)(Gt,{flexDirection:"column",children:[s.map((h,o)=>(0,gs.jsxs)(Gt,{children:[(0,gs.jsx)(rt,{dimColor:!0,children:h.time.padEnd(10)}),(0,gs.jsx)(rt,{children:h.description.slice(0,30)})]},o)),(0,gs.jsx)(Gt,{children:(0,gs.jsx)(rt,{dimColor:!0,children:"... /resume for more"})})]})]}),(0,gs.jsxs)(Gt,{flexDirection:"column",children:[(0,gs.jsxs)(rt,{children:["\u{1F4A1} ",Ke("welcome.daily.tip.title")]}),(0,gs.jsxs)(Gt,{flexDirection:"column",children:[(0,gs.jsx)(rt,{children:d}),(0,gs.jsx)(Gt,{children:(0,gs.jsx)(rt,{dimColor:!0,children:Ke("welcome.daily.tip.more")})})]})]})]})]})};var Zpe=Dt(mr(),1);var fpe=Dt(mr(),1);var a7e=(0,fpe.createContext)(void 0),HR=()=>{let n=fpe.default.useContext(a7e);if(n===void 0)throw new Error("useStreamingContext must be used within a StreamingContextProvider");return n};var lB=Dt(mr(),1);var gpe=Dt(Xn(),1);var sB=({nonRespondingDisplay:n})=>{let t=HR(),r=Io(),[a,i]=(0,lB.useState)(!0),s=(0,lB.useRef)(null);(0,lB.useEffect)(()=>(s.current&&(clearInterval(s.current),s.current=null),t==="responding"&&!aN(r,"spinner")?s.current=setInterval(()=>{i(I=>!I)},1e3):i(!0),()=>{s.current&&(clearInterval(s.current),s.current=null)}),[t,r]);let u=Vl.getActiveTheme().colors.type==="dark"?pt.Foreground:pt.AccentBlue;return t==="responding"?aN(r,"spinner")?(0,gpe.jsx)(rt,{color:u,children:"\u25CF"},"spinner-static"):(0,gpe.jsx)(rt,{color:u,children:a?"\u25CF":"\u25CB"},"spinner-animated"):n?(0,gpe.jsx)(rt,{children:n},"spinner-static"):null};var vpe=Dt(mr(),1);Wr();var Bsn=()=>{let[n,t]=(0,vpe.useState)(null);return(0,vpe.useEffect)(()=>{let r=i=>{t({inputTokens:i.inputTokens,outputTokens:i.outputTokens,totalTokens:i.totalTokens,timestamp:i.timestamp})},a=()=>{t(null)};return Tp.onRealTimeToken(r),Tp.onClearRealTimeToken(a),()=>{Tp.offRealTimeToken(r),Tp.offClearRealTimeToken(a)}},[]),n};Nr();Nr();var oB=Dt(mr(),1);function yJr(n){if(n.length>1)return!0;let t=n.codePointAt(0);return t?t>=128512&&t<=128591||t>=127744&&t<=128511||t>=128640&&t<=128767||t>=127456&&t<=127487||t>=9728&&t<=9983||t>=9984&&t<=10175||t>=65024&&t<=65039||t>=129280&&t<=129535||t>=126976&&t<=127023||t>=127136&&t<=127231||t===8252||t===8265||t===8482||t===8505||t===8596||t===8597||t===8598||t===8599||t===8600||t===8601||t===8617||t===8618||t===8986||t===8987||t===9e3||t===9167||t===9193||t===9194||t===9195||t===9196||t===9197||t===9198||t===9199||t===9200||t===9201||t===9202||t===9203||t===9725||t===9726||t===11088||t===11093:!1}function RJr(n){return["\u{1F4A1}","\u{1F680}","\u26A1","\u{1F525}","\u2B50","\u2728","\u{1F3AF}","\u{1F389}","\u{1F38A}","\u{1F31F}","\u{1F4AF}","\u{1F527}","\u2699\uFE0F","\u{1F6E0}\uFE0F","\u{1F528}","\u2692\uFE0F","\u{1F9F0}"].includes(n)}function i7e(n){return Array.from(n).map((t,r)=>{let a=yJr(t)||RJr(t);return{char:t,index:r,isEmoji:a,shouldHighlight:!a}})}function Dsn(n){return i7e(n).filter(r=>r.shouldHighlight).length}var Tsn=(n,t)=>{let{isActive:r,interval:a=80,highlightLength:i,stepSize:s=1,highlightRatio:e=.3}=t,c=i7e(n),u=Dsn(n),I=(E=>{if(i!==void 0)return i;let A=Math.round(E*e);return Math.max(2,Math.min(A,Math.floor(E/2)))})(u),[h,o]=(0,oB.useState)(0),v=(0,oB.useRef)(null),w=a;return(0,oB.useEffect)(()=>{if(v.current&&(clearInterval(v.current),v.current=null),!r){o(0);return}if(!n||n.length===0){o(0);return}return v.current=setInterval(()=>{o(E=>{let A=E+s;return A>=u?0:A})},w),()=>{v.current&&(clearInterval(v.current),v.current=null)}},[r,n,w,I,s,u]),{highlightedChars:(()=>{if(!n||!r)return c.map((y,b)=>({char:y.char,isHighlighted:!1,index:b}));let E=0,A=0,Y=I+4,W=h-2;return c.map((y,b)=>{let f=!1,g=0;if(y.shouldHighlight){if(E>=W&&E<W+Y){let N=E-W;N<2?g=0:N<2+Math.floor(I*.3)?g=1:N<2+Math.floor(I*.7)?g=2:N<2+I?g=1:g=0,f=g>0}E++}return{char:y.char,isHighlighted:f,highlightIntensity:g,index:b}})})(),currentPosition:h,isAnimating:r&&n.length>0}};function Osn(n){return{dim:"#666666",medium:"#CCCCCC",bright:"#F2F2F2"}}var rm=Dt(Xn(),1);var Usn=({currentLoadingPhrase:n,elapsedTime:t,rightContent:r,thought:a,estimatedInputTokens:i,isExecutingTools:s=!1})=>{let e=HR(),c=Bsn(),u=Io(),d=s,I=({isToolCall:f})=>{let[g,N]=(0,Zpe.useState)(!0);return(0,Zpe.useEffect)(()=>{if(e==="waiting_for_confirmation"){N(!0);return}let p=setInterval(()=>{N(m=>!m)},800);return()=>clearInterval(p)},[e]),(0,rm.jsx)(rt,{color:pt.AccentOrange,children:g?f?"\u2692\uFE0F":"\u2191":f?" ":" "})},h=e==="waiting_for_confirmation"?to()?"\u7B49\u5F85\u7528\u6237\u786E\u8BA4...":"Waiting for user confirmation...":a?.subject||n||"",o=e==="responding"&&!aN(u,"loading"),{highlightedChars:v}=Tsn(h,{isActive:o,interval:80,highlightRatio:.3,stepSize:1}),E=Vl.getActiveTheme().colors.type==="dark"?pt.Foreground:pt.AccentBlue,A=Osn(E);if(e==="idle")return null;let Y=e==="waiting_for_confirmation"?to()?"\u7B49\u5F85\u7528\u6237\u786E\u8BA4...":"Waiting for user confirmation...":a?.subject||n,W=c?.inputTokens||i,y=!!c?.inputTokens,b=o;return(0,rm.jsx)(Gt,{marginTop:1,paddingLeft:0,flexDirection:"column",children:(0,rm.jsxs)(Gt,{width:"100%",children:[(0,rm.jsx)(Gt,{marginRight:1,children:e==="waiting_for_confirmation"?(0,rm.jsx)(rt,{children:"\u280F"},"static-indicator"):(0,rm.jsx)(sB,{},"dynamic-spinner")}),(0,rm.jsx)(Gt,{flexShrink:1,children:(0,rm.jsxs)(rt,{wrap:"wrap",color:pt.AccentOrange,children:[Y&&(b?(0,rm.jsx)(rt,{children:v.map(({char:f,highlightIntensity:g,index:N})=>{let p;switch(g){case 2:p=A.bright;break;case 1:p=A.medium;break;default:p=A.dim;break}return(0,rm.jsx)(rt,{color:p,children:f},N)})}):(0,rm.jsx)(rt,{color:pt.AccentOrange,children:Y})),(0,rm.jsx)(rt,{color:pt.Gray,children:e==="waiting_for_confirmation"?"":` (${tfe()} to cancel, ${t<60?`${t}s`:qd(t*1e3)})`})]})}),(0,rm.jsx)(Gt,{flexGrow:1}),r&&(0,rm.jsx)(Gt,{children:r})]})})};Wr();var jj=Dt(Xn(),1);var Msn=({approvalMode:n})=>{let t="",r="",a="";switch(n){case Ja.AUTO_EDIT:t=pt.AccentGreen,r="accepting edits",a=" (shift + tab to toggle)";break;case Ja.YOLO:t=pt.AccentRed,r="YOLO mode",a=" (ctrl + y to toggle)";break;case Ja.DEFAULT:default:break}return(0,jj.jsx)(Gt,{children:(0,jj.jsxs)(rt,{color:t,children:[r,a&&(0,jj.jsx)(rt,{color:pt.Gray,children:a})]})})};var Kj=Dt(Xn(),1);var zsn=()=>(0,Kj.jsx)(Gt,{children:(0,Kj.jsxs)(rt,{color:pt.AccentYellow,children:["shell mode enabled",(0,Kj.jsx)(rt,{color:pt.Gray,children:" (esc to disable)"})]})});var qj=Dt(Xn(),1);var _sn=()=>(0,qj.jsx)(Gt,{children:(0,qj.jsxs)(rt,{color:pt.AccentCyan,children:["\u{1F4A1} AI help assistant active",(0,qj.jsx)(rt,{color:pt.Gray,children:" (esc to exit \u2022 uses tokens)"})]})});Nr();var Npe=Dt(Xn(),1);var Psn=()=>(0,Npe.jsx)(Gt,{borderStyle:"round",borderColor:pt.AccentGreen,paddingX:1,children:(0,Npe.jsxs)(rt,{color:pt.AccentGreen,children:["\u{1F4CB} ",Ke("plan.mode.indicator")]})});var vs=Dt(mr(),1);Nr();var am=Dt(Xn(),1);var XR=8;function jsn({suggestions:n,activeIndex:t,isLoading:r,width:a,scrollOffset:i,userInput:s}){if(r)return(0,am.jsx)(Gt,{paddingX:1,width:a,children:(0,am.jsx)(rt,{color:"gray",children:Ke("suggestions.loading")})});if(n.length===0)return null;let e="",c=!1;if(s.startsWith("/")){c=!0;let v=s.lastIndexOf("/"),w=s.substring(v+1),R=w.indexOf(" ");e=R!==-1?w.substring(0,R):w}else if(s.includes("@")){let v=s.lastIndexOf("@"),w=s.substring(v+1),R=w.lastIndexOf("/");e=R!==-1?w.substring(R+1):w}let u=i,d=Math.min(i+XR,n.length),I=n.slice(u,d),h=Math.max(...n.map(v=>v.label.length),20),o=Math.min(h+2,a-10);return(0,am.jsxs)(Gt,{flexDirection:"column",paddingX:1,width:a,children:[i>0&&(0,am.jsx)(rt,{color:pt.Foreground,children:"\u25B2"}),I.map((v,w)=>{let R=u+w,E=R===t,A=E?pt.AccentOrange:pt.Gray,Y=E?pt.AccentYellow:pt.Foreground,W=()=>{if(!e)return(0,am.jsx)(rt,{color:A,children:v.label});let y=dnn(v.label,e);return(0,am.jsx)(rt,{children:y.map((b,f)=>(0,am.jsx)(rt,{color:b.highlighted?Y:A,bold:b.highlighted,children:b.text},f))})};return(0,am.jsx)(Gt,{width:a,children:(0,am.jsxs)(Gt,{flexDirection:"row",children:[s.startsWith("/")?(0,am.jsx)(Gt,{width:o,flexShrink:0,children:W()}):W(),v.description?(0,am.jsx)(Gt,{flexGrow:1,children:(0,am.jsx)(rt,{color:A,wrap:"wrap",children:v.description})}):null]})},`${v}-${R}`)}),d<n.length&&(0,am.jsx)(rt,{color:"gray",children:"\u25BC"}),n.length>XR&&(0,am.jsxs)(rt,{color:"gray",children:["(",t+1,"/",n.length,")"]})]})}var kR=Dt(mr(),1);function Ksn({userMessages:n,onSubmit:t,isActive:r,currentQuery:a,onChange:i}){let[s,e]=(0,kR.useState)(-1),[c,u]=(0,kR.useState)(""),d=(0,kR.useCallback)(()=>{e(-1),u("")},[]),I=(0,kR.useCallback)(v=>{let w=v.trim();w&&t(w),d()},[t,d]),h=(0,kR.useCallback)(()=>{if(!r||n.length===0)return!1;let v=s;if(s===-1)u(a),v=0;else if(s<n.length-1)v=s+1;else return!1;if(v!==s){e(v);let w=n[n.length-1-v];return i(w),!0}return!1},[s,e,i,n,r,a,u]),o=(0,kR.useCallback)(()=>{if(!r||s===-1)return!1;let v=s-1;if(e(v),v===-1)i(c);else{let w=n[n.length-1-v];i(w)}return!0},[s,e,c,i,n,r]);return{handleSubmit:I,navigateUp:h,navigateDown:o}}var $j=95,eK=85,Wpe=75,Ape=45;var aV=(n,t,r={})=>n>=t.green?pt.AccentGreen:n>=t.yellow?pt.AccentYellow:r.defaultColor||pt.AccentRed;function EJr(n,t=15){return Vx(n)<=t?n:n.split(/\r?\n/).slice(0,t).join(`
4898
+ `;function Xsn(n,t=!1){return t?`v${n}(${process.versions.node})`:`v${n}`}function rV(n,t=!1){if(!t)return n;let r=[/^Claude-(?:3\.5-)?(.+)$/i,/^Claude-(.+)$/i,/^Gemini-(?:2\.0-)?(.+)$/i,/^Gemini-(.+)$/i,/^GPT-(.+)$/i,/^OpenAI-(.+)$/i];for(let a of r){let i=n.match(a);if(i&&i[1])return i[1]}return n}function ksn(n,t=!1){if((typeof n=="string"?parseFloat(n):n)===100)return"";let a=`${n}%`;return t?a:`(${a} context left)`}function Lsn(n){return n>=80?{showNodeVersion:!0,simplifyContext:!1,simplifyModel:!1,level:"full"}:{showNodeVersion:!1,simplifyContext:!0,simplifyModel:!0,level:"compact"}}var gs=Dt(Xn(),1);var Jsn=["tip.help","tip.theme","tip.auth","tip.stats","tip.memory","tip.mcp","tip.tools","tip.init","tip.model","tip.plan","tip.docs","tip.session","tip.restore","tip.at.filepath","tip.shell.command","tip.shell.mode","tip.ctrl.j","tip.cli.update","tip.cli.cloud"];function FJr(n){let r=new Date().getTime()-n.getTime(),a=Math.floor(r/6e4),i=Math.floor(r/36e5),s=Math.floor(r/864e5),e=Math.floor(r/6048e5);return a<1?"just now":a<60?`${a}m ago`:i<24?`${i}h ago`:s<7?`${s}d ago`:`${e}w ago`}var Ssn=({config:n,version:t,customProxyUrl:r})=>{let a=(0,B5.useMemo)(()=>Vs.getInstance().getUserInfo()?.name,[]),i=(0,B5.useMemo)(()=>{let h=n.getModel(),o=n.getCloudModelInfo(h);if(o){let R=o.creditsPerRequest;return{displayName:rV(o.displayName,!0),creditsText:`${R}x credits`}}return{displayName:rV(h==="auto"?"Gemini":h,!0),creditsText:"API Usage Billing"}},[n]),[s,e]=(0,B5.useState)([]);(0,B5.useEffect)(()=>{(async()=>{await new Promise(o=>setTimeout(o,1e3));try{let w=(await new Ls(n.getProjectRoot()).listSessions()).slice(0,4).map(R=>({time:FJr(new Date(R.lastActiveAt)),description:R.title||R.firstUserMessage?.slice(0,30)||"Untitled session"}));e(w)}catch{}})()},[n]);let c=(0,B5.useMemo)(()=>{let h=n.getProjectRoot();return AJr.basename(h)},[n]),u=n.getProjectRoot(),d=(0,B5.useMemo)(()=>{let h=Math.floor(Math.random()*Jsn.length),o=Jsn[h];return Ke(o)},[]),I=a?`Welcome back, ${a}!`:"Welcome to DeepV Code!";return(0,gs.jsxs)(Gt,{flexDirection:"column",marginBottom:1,borderStyle:"round",borderColor:"gray",paddingX:1,minWidth:80,children:[(0,gs.jsxs)(Gt,{flexDirection:"row",marginBottom:1,children:[(0,gs.jsx)(Gt,{marginRight:2,children:(0,gs.jsx)(rt,{color:pt.Foreground,children:Hsn})}),(0,gs.jsxs)(Gt,{flexDirection:"column",justifyContent:"center",children:[(0,gs.jsx)(rt,{children:"DeepV Code "}),(0,gs.jsxs)(rt,{dimColor:!0,children:["v",t]}),(0,gs.jsxs)(rt,{dimColor:!0,children:[i.displayName," \xB7 ",i.creditsText]})]})]}),(0,gs.jsx)(Gt,{children:(0,gs.jsx)(rt,{color:pt.AccentGreen,children:I})}),(0,gs.jsxs)(Gt,{flexDirection:"column",children:[(0,gs.jsx)(Gt,{children:(0,gs.jsx)(rt,{dimColor:!0,children:u})}),r&&(0,gs.jsxs)(Gt,{flexDirection:"column",marginBottom:1,children:[(0,gs.jsxs)(rt,{color:pt.AccentOrange,children:["\u{1F517} Custom server: ",r]}),(0,gs.jsx)(rt,{color:pt.AccentOrange,children:" Please verify trustworthiness and monitor your API usage."})]}),s.length>0&&(0,gs.jsxs)(Gt,{flexDirection:"column",children:[(0,gs.jsx)(rt,{color:pt.AccentOrange,children:"Recent activity"}),(0,gs.jsxs)(Gt,{flexDirection:"column",children:[s.map((h,o)=>(0,gs.jsxs)(Gt,{children:[(0,gs.jsx)(rt,{dimColor:!0,children:h.time.padEnd(10)}),(0,gs.jsx)(rt,{children:h.description.slice(0,30)})]},o)),(0,gs.jsx)(Gt,{children:(0,gs.jsx)(rt,{dimColor:!0,children:"... /resume for more"})})]})]}),(0,gs.jsxs)(Gt,{flexDirection:"column",children:[(0,gs.jsxs)(rt,{children:["\u{1F4A1} ",Ke("welcome.daily.tip.title")]}),(0,gs.jsxs)(Gt,{flexDirection:"column",children:[(0,gs.jsx)(rt,{children:d}),(0,gs.jsx)(Gt,{children:(0,gs.jsx)(rt,{dimColor:!0,children:Ke("welcome.daily.tip.more")})})]})]})]})]})};var Zpe=Dt(mr(),1);var fpe=Dt(mr(),1);var a7e=(0,fpe.createContext)(void 0),HR=()=>{let n=fpe.default.useContext(a7e);if(n===void 0)throw new Error("useStreamingContext must be used within a StreamingContextProvider");return n};var lB=Dt(mr(),1);var gpe=Dt(Xn(),1);var sB=({nonRespondingDisplay:n})=>{let t=HR(),r=Io(),[a,i]=(0,lB.useState)(!0),s=(0,lB.useRef)(null);(0,lB.useEffect)(()=>(s.current&&(clearInterval(s.current),s.current=null),t==="responding"&&!aN(r,"spinner")?s.current=setInterval(()=>{i(I=>!I)},1e3):i(!0),()=>{s.current&&(clearInterval(s.current),s.current=null)}),[t,r]);let u=Vl.getActiveTheme().colors.type==="dark"?pt.Foreground:pt.AccentBlue;return t==="responding"?aN(r,"spinner")?(0,gpe.jsx)(rt,{color:u,children:"\u25CF"},"spinner-static"):(0,gpe.jsx)(rt,{color:u,children:a?"\u25CF":"\u25CB"},"spinner-animated"):n?(0,gpe.jsx)(rt,{children:n},"spinner-static"):null};var vpe=Dt(mr(),1);Wr();var Bsn=()=>{let[n,t]=(0,vpe.useState)(null);return(0,vpe.useEffect)(()=>{let r=i=>{t({inputTokens:i.inputTokens,outputTokens:i.outputTokens,totalTokens:i.totalTokens,timestamp:i.timestamp})},a=()=>{t(null)};return Tp.onRealTimeToken(r),Tp.onClearRealTimeToken(a),()=>{Tp.offRealTimeToken(r),Tp.offClearRealTimeToken(a)}},[]),n};Nr();Nr();var oB=Dt(mr(),1);function yJr(n){if(n.length>1)return!0;let t=n.codePointAt(0);return t?t>=128512&&t<=128591||t>=127744&&t<=128511||t>=128640&&t<=128767||t>=127456&&t<=127487||t>=9728&&t<=9983||t>=9984&&t<=10175||t>=65024&&t<=65039||t>=129280&&t<=129535||t>=126976&&t<=127023||t>=127136&&t<=127231||t===8252||t===8265||t===8482||t===8505||t===8596||t===8597||t===8598||t===8599||t===8600||t===8601||t===8617||t===8618||t===8986||t===8987||t===9e3||t===9167||t===9193||t===9194||t===9195||t===9196||t===9197||t===9198||t===9199||t===9200||t===9201||t===9202||t===9203||t===9725||t===9726||t===11088||t===11093:!1}function RJr(n){return["\u{1F4A1}","\u{1F680}","\u26A1","\u{1F525}","\u2B50","\u2728","\u{1F3AF}","\u{1F389}","\u{1F38A}","\u{1F31F}","\u{1F4AF}","\u{1F527}","\u2699\uFE0F","\u{1F6E0}\uFE0F","\u{1F528}","\u2692\uFE0F","\u{1F9F0}"].includes(n)}function i7e(n){return Array.from(n).map((t,r)=>{let a=yJr(t)||RJr(t);return{char:t,index:r,isEmoji:a,shouldHighlight:!a}})}function Dsn(n){return i7e(n).filter(r=>r.shouldHighlight).length}var Tsn=(n,t)=>{let{isActive:r,interval:a=80,highlightLength:i,stepSize:s=1,highlightRatio:e=.3}=t,c=i7e(n),u=Dsn(n),I=(E=>{if(i!==void 0)return i;let A=Math.round(E*e);return Math.max(2,Math.min(A,Math.floor(E/2)))})(u),[h,o]=(0,oB.useState)(0),v=(0,oB.useRef)(null),w=a;return(0,oB.useEffect)(()=>{if(v.current&&(clearInterval(v.current),v.current=null),!r){o(0);return}if(!n||n.length===0){o(0);return}return v.current=setInterval(()=>{o(E=>{let A=E+s;return A>=u?0:A})},w),()=>{v.current&&(clearInterval(v.current),v.current=null)}},[r,n,w,I,s,u]),{highlightedChars:(()=>{if(!n||!r)return c.map((y,b)=>({char:y.char,isHighlighted:!1,index:b}));let E=0,A=0,Y=I+4,W=h-2;return c.map((y,b)=>{let f=!1,g=0;if(y.shouldHighlight){if(E>=W&&E<W+Y){let N=E-W;N<2?g=0:N<2+Math.floor(I*.3)?g=1:N<2+Math.floor(I*.7)?g=2:N<2+I?g=1:g=0,f=g>0}E++}return{char:y.char,isHighlighted:f,highlightIntensity:g,index:b}})})(),currentPosition:h,isAnimating:r&&n.length>0}};function Osn(n){return{dim:"#666666",medium:"#CCCCCC",bright:"#F2F2F2"}}var rm=Dt(Xn(),1);var Usn=({currentLoadingPhrase:n,elapsedTime:t,rightContent:r,thought:a,estimatedInputTokens:i,isExecutingTools:s=!1})=>{let e=HR(),c=Bsn(),u=Io(),d=s,I=({isToolCall:f})=>{let[g,N]=(0,Zpe.useState)(!0);return(0,Zpe.useEffect)(()=>{if(e==="waiting_for_confirmation"){N(!0);return}let p=setInterval(()=>{N(m=>!m)},800);return()=>clearInterval(p)},[e]),(0,rm.jsx)(rt,{color:pt.AccentOrange,children:g?f?"\u2692\uFE0F":"\u2191":f?" ":" "})},h=e==="waiting_for_confirmation"?to()?"\u7B49\u5F85\u7528\u6237\u786E\u8BA4...":"Waiting for user confirmation...":a?.subject||n||"",o=e==="responding"&&!aN(u,"loading"),{highlightedChars:v}=Tsn(h,{isActive:o,interval:80,highlightRatio:.3,stepSize:1}),E=Vl.getActiveTheme().colors.type==="dark"?pt.Foreground:pt.AccentBlue,A=Osn(E);if(e==="idle")return null;let Y=e==="waiting_for_confirmation"?to()?"\u7B49\u5F85\u7528\u6237\u786E\u8BA4...":"Waiting for user confirmation...":a?.subject||n,W=c?.inputTokens||i,y=!!c?.inputTokens,b=o;return(0,rm.jsx)(Gt,{marginTop:1,paddingLeft:0,flexDirection:"column",children:(0,rm.jsxs)(Gt,{width:"100%",children:[(0,rm.jsx)(Gt,{marginRight:1,children:e==="waiting_for_confirmation"?(0,rm.jsx)(rt,{children:"\u280F"},"static-indicator"):(0,rm.jsx)(sB,{},"dynamic-spinner")}),(0,rm.jsx)(Gt,{flexShrink:1,children:(0,rm.jsxs)(rt,{wrap:"wrap",color:pt.AccentOrange,children:[Y?b?(0,rm.jsx)(rt,{children:v.map(({char:f,highlightIntensity:g,index:N})=>{let p;switch(g){case 2:p=A.bright;break;case 1:p=A.medium;break;default:p=A.dim;break}return(0,rm.jsx)(rt,{color:p,children:f},N)})}):(0,rm.jsx)(rt,{color:pt.AccentOrange,children:Y}):null,(0,rm.jsx)(rt,{color:pt.Gray,children:e==="waiting_for_confirmation"?"":` (${tfe()} to cancel, ${t<60?`${t}s`:qd(t*1e3)})`})]})}),(0,rm.jsx)(Gt,{flexGrow:1}),r?(0,rm.jsx)(Gt,{children:r}):null]})})};Wr();var jj=Dt(Xn(),1);var Msn=({approvalMode:n})=>{let t="",r="",a="";switch(n){case Ja.AUTO_EDIT:t=pt.AccentGreen,r="accepting edits",a=" (shift + tab to toggle)";break;case Ja.YOLO:t=pt.AccentRed,r="YOLO mode",a=" (ctrl + y to toggle)";break;case Ja.DEFAULT:default:break}return(0,jj.jsx)(Gt,{children:(0,jj.jsxs)(rt,{color:t,children:[r,a?(0,jj.jsx)(rt,{color:pt.Gray,children:a}):null]})})};var Kj=Dt(Xn(),1);var zsn=()=>(0,Kj.jsx)(Gt,{children:(0,Kj.jsxs)(rt,{color:pt.AccentYellow,children:["shell mode enabled",(0,Kj.jsx)(rt,{color:pt.Gray,children:" (esc to disable)"})]})});var qj=Dt(Xn(),1);var _sn=()=>(0,qj.jsx)(Gt,{children:(0,qj.jsxs)(rt,{color:pt.AccentCyan,children:["\u{1F4A1} AI help assistant active",(0,qj.jsx)(rt,{color:pt.Gray,children:" (esc to exit \u2022 uses tokens)"})]})});Nr();var Npe=Dt(Xn(),1);var Psn=()=>(0,Npe.jsx)(Gt,{borderStyle:"round",borderColor:pt.AccentGreen,paddingX:1,children:(0,Npe.jsxs)(rt,{color:pt.AccentGreen,children:["\u{1F4CB} ",Ke("plan.mode.indicator")]})});var vs=Dt(mr(),1);Nr();var am=Dt(Xn(),1);var XR=8;function jsn({suggestions:n,activeIndex:t,isLoading:r,width:a,scrollOffset:i,userInput:s}){if(r)return(0,am.jsx)(Gt,{paddingX:1,width:a,children:(0,am.jsx)(rt,{color:"gray",children:Ke("suggestions.loading")})});if(n.length===0)return null;let e="",c=!1;if(s.startsWith("/")){c=!0;let v=s.lastIndexOf("/"),w=s.substring(v+1),R=w.indexOf(" ");e=R!==-1?w.substring(0,R):w}else if(s.includes("@")){let v=s.lastIndexOf("@"),w=s.substring(v+1),R=w.lastIndexOf("/");e=R!==-1?w.substring(R+1):w}let u=i,d=Math.min(i+XR,n.length),I=n.slice(u,d),h=Math.max(...n.map(v=>v.label.length),20),o=Math.min(h+2,a-10);return(0,am.jsxs)(Gt,{flexDirection:"column",paddingX:1,width:a,children:[i>0?(0,am.jsx)(rt,{color:pt.Foreground,children:"\u25B2"}):null,I.map((v,w)=>{let R=u+w,E=R===t,A=E?pt.AccentOrange:pt.Gray,Y=E?pt.AccentYellow:pt.Foreground,W=()=>{if(!e)return(0,am.jsx)(rt,{color:A,children:v.label});let y=dnn(v.label,e);return(0,am.jsx)(rt,{children:y.map((b,f)=>(0,am.jsx)(rt,{color:b.highlighted?Y:A,bold:b.highlighted,children:b.text},f))})};return(0,am.jsx)(Gt,{width:a,children:(0,am.jsxs)(Gt,{flexDirection:"row",children:[s.startsWith("/")?(0,am.jsx)(Gt,{width:o,flexShrink:0,children:W()}):W(),v.description?(0,am.jsx)(Gt,{flexGrow:1,children:(0,am.jsx)(rt,{color:A,wrap:"wrap",children:v.description})}):null]})},`${v}-${R}`)}),d<n.length?(0,am.jsx)(rt,{color:"gray",children:"\u25BC"}):null,n.length>XR?(0,am.jsxs)(rt,{color:"gray",children:["(",t+1,"/",n.length,")"]}):null]})}var kR=Dt(mr(),1);function Ksn({userMessages:n,onSubmit:t,isActive:r,currentQuery:a,onChange:i}){let[s,e]=(0,kR.useState)(-1),[c,u]=(0,kR.useState)(""),d=(0,kR.useCallback)(()=>{e(-1),u("")},[]),I=(0,kR.useCallback)(v=>{let w=v.trim();w&&t(w),d()},[t,d]),h=(0,kR.useCallback)(()=>{if(!r||n.length===0)return!1;let v=s;if(s===-1)u(a),v=0;else if(s<n.length-1)v=s+1;else return!1;if(v!==s){e(v);let w=n[n.length-1-v];return i(w),!0}return!1},[s,e,i,n,r,a,u]),o=(0,kR.useCallback)(()=>{if(!r||s===-1)return!1;let v=s-1;if(e(v),v===-1)i(c);else{let w=n[n.length-1-v];i(w)}return!0},[s,e,c,i,n,r]);return{handleSubmit:I,navigateUp:h,navigateDown:o}}var $j=95,eK=85,Wpe=75,Ape=45;var aV=(n,t,r={})=>n>=t.green?pt.AccentGreen:n>=t.yellow?pt.AccentYellow:r.defaultColor||pt.AccentRed;function EJr(n,t=15){return Vx(n)<=t?n:n.split(/\r?\n/).slice(0,t).join(`
4899
4899
  `)+`
4900
4900
  ...`}function qsn(n,t=15){return Vx(n)>t}function wJr(n,t){if(t<=0)return n;let r=n.split(/\r?\n/),a=[];for(let i of r)if(Ca(i)<=t)a.push(i);else{let s=0;for(;s<Ca(i);){let e=Math.min(s+t,Ca(i)),c=oc(i,s,e);if(e<Ca(i)){let u=c.lastIndexOf(" ");u>0&&u>t*.7&&(c=c.substring(0,u),e=s+u+1)}a.push(c),s=e}}return a.join(`
4901
4901
  `)}function $sn(n,t){return t<=0?n:wJr(n,t).split(`
@@ -4922,7 +4922,7 @@ ${u}`}function YJr(n){if(!n)return n;let t=n.replace(/\x1b\[[0-9;]*[a-zA-Z]/g,""
4922
4922
  `)&&(De=De+" "),console.log("\u{1F5BC}\uFE0F [\u526A\u8D34\u677F\u56FE\u50CF] \u63D2\u5165\u6587\u672C:",De),n.replaceRangeByOffset(ct,ct,De)}else console.log("\u{1F5BC}\uFE0F [\u526A\u8D34\u677F\u56FE\u50CF] \u6CA1\u6709\u83B7\u5F97\u6709\u6548\u7684\u56FE\u50CF\u8DEF\u5F84")}else console.log("\u{1F5BC}\uFE0F [\u526A\u8D34\u677F\u56FE\u50CF] \u526A\u8D34\u677F\u4E0D\u5305\u542B\u56FE\u50CF\uFF0C\u8DF3\u8FC7\u5904\u7406")}catch(ye){console.error("\u{1F5BC}\uFE0F [\u526A\u8D34\u677F\u56FE\u50CF] \u9519\u8BEF:",ye)}finally{m(!1)}console.log("\u{1F5BC}\uFE0F [\u526A\u8D34\u677F\u56FE\u50CF] handleClipboardImage \u6267\u884C\u5B8C\u6210")},[n,s]),j=(0,vs.useCallback)(async ye=>{if(!ye.sequence){try{await qP()&&await q()}catch{}return}console.log("\u{1F4CB} [Paste] Starting text paste handling:",{length:ye.sequence.length,contentPreview:ye.sequence.substring(0,50).replace(/\r?\n/g,"\\n"),ctrl:ye.ctrl,shift:ye.shift,name:ye.name});let Ve=Date.now();if(Ve-H.current<2e3&&Q.current){console.log("\u{1F4CB} [Paste] Detected possible split paste, merging content"),Q.current+=ye.sequence,V.current&&clearTimeout(V.current),V.current=setTimeout(()=>{z()},500),H.current=Ve;return}H.current=Ve,Q.current=ye.sequence,V.current&&clearTimeout(V.current),V.current=setTimeout(()=>{z()},300)},[H,Q,V,z]),te=(0,vs.useCallback)(async()=>{try{if(await qP())try{return await q(),!0}catch{return!1}let Ve=await kSe();return Ve&&Ve.trim()?(await j({paste:!0,sequence:Ve,ctrl:!1,shift:!1,meta:!1,name:""}),!0):!1}catch{return!1}},[q,j]),ae=(0,vs.useCallback)(()=>{let ye=n.text;J(Ve=>Ve.filter(Ae=>ye.includes(Ae.summaryContent)))},[n]),re=(0,vs.useCallback)(()=>{let ye=n.text.length,Ve=n.allVisualLines.length;return ye<100?Math.min(Ve+2,5):ye<1e3?Math.min(Ve+3,15):Math.min(Ve+5,25)},[n.text.length,n.allVisualLines.length]),ie=(0,vs.useCallback)(ye=>{if(!I&&!ye.paste||Y||(!ye.paste&&ye.name!=="up"&&ye.name!=="down"&&ye.name!=="left"&&ye.name!=="right"&&ye.name!=="home"&&ye.name!=="end"&&ye.name!=="pageup"&&ye.name!=="pagedown"&&setTimeout(ae,0),A&&A(ye)))return;if(ye.sequence==="!"&&n.text===""&&!U.showSuggestions){w(!v),n.setText("");return}if(ye.name==="escape"){if(v){w(!1);return}if(R){E(!1);return}if(U.showSuggestions){U.resetCompletionState();return}}if(ye.ctrl&&ye.name==="l"){i();return}if(U.isPerfectMatch&&ye.name==="return"){K.handleSubmit(n.text);return}if(U.showSuggestions){if(U.suggestions.length>1){if(ye.name==="up"||ye.ctrl&&ye.name==="p"){U.navigateUp();return}if(ye.name==="down"||ye.ctrl&&ye.name==="n"){U.navigateDown();return}}if(ye.name==="tab"){if(U.suggestions.length>0){let ze=U.activeSuggestionIndex===-1?0:U.activeSuggestionIndex;ze<U.suggestions.length&&U.handleAutocomplete(ze)}else v&&n.text.trim().length>=1?U.triggerShellCompletion():v||U.resetCompletionState();return}if(ye.name==="return"&&!ye.shift&&U.activeSuggestionIndex>-1&&U.suggestions.length>0){let ze=U.suggestions[U.activeSuggestionIndex];if(ze?.willAutoExecute===!0){let De=n.text,Ue=ze.value;if(De.trimStart().startsWith("/")){let et=De.trimStart().substring(1).split(/\s+/).filter(Boolean),Be=`/${[...De.endsWith(" ")?et:et.slice(0,-1),Ue].join(" ")}`;K.handleSubmit(Be);return}}let lt=n.text.trim().split(/\s+/);if(lt[lt.length-1]===ze.value){K.handleSubmit(n.text);return}U.handleAutocomplete(U.activeSuggestionIndex);return}}if(v){if(ye.name==="up"){let ze=L.getPreviousCommand();ze!==null&&n.setText(ze);return}if(ye.name==="down"){let ze=L.getNextCommand();ze!==null&&n.setText(ze);return}ye.name==="tab"&&v&&n.text.trim().length>=1&&U.triggerShellCompletion()}else{if(ye.ctrl&&ye.name==="p"){K.navigateUp();return}if(ye.ctrl&&ye.name==="n"){K.navigateDown();return}if(ye.name==="up"&&(n.allVisualLines.length===1||n.visualCursor[0]===0&&n.visualScrollRow===0)){K.navigateUp();return}if(ye.name==="down"&&(n.allVisualLines.length===1||n.visualCursor[0]===n.allVisualLines.length-1)){K.navigateDown();return}}if(ye.name==="return"&&ye.shift){n.newline();return}if(ye.name==="return"&&ye.ctrl){n.newline();return}if(ye.name==="return"&&ye.meta){n.newline();return}if(ye.ctrl&&ye.name==="j"){n.newline();return}if(ye.name==="return"&&!ye.shift&&!ye.ctrl&&!ye.meta&&!ye.paste){if(n.text.trim()){let[ze,nt]=n.cursor,lt=n.lines[ze];(nt>0?oc(lt,nt-1,nt):"")==="\\"?(n.backspace(),n.newline()):K.handleSubmit(n.text)}return}if(ye.name==="return"&&ye.paste){n.newline();return}if(ye.ctrl&&ye.name==="a"){n.move("home");return}if(ye.ctrl&&ye.name==="e"){n.move("end"),n.moveToOffset(Ca(n.text));return}if(ye.ctrl&&ye.name==="c"){if(n.text.length>0){n.setText(""),T();return}return}if(ye.ctrl&&ye.name==="k"){n.killLineRight();return}if(ye.ctrl&&ye.name==="u"){n.killLineLeft();return}if(ye.ctrl&&(ye.name==="x"||ye.sequence==="")){n.openInExternalEditor();return}if(ye.ctrl&&ye.name==="v"){console.log("\u2328\uFE0F [\u5FEB\u6377\u952E] \u89E6\u53D1 Ctrl+V\uFF0C\u4F7F\u7528\u7EDF\u4E00\u7C98\u8D34\u5904\u7406"),te().catch(ze=>{console.error("\u2328\uFE0F [\u5FEB\u6377\u952E] \u7EDF\u4E00\u7C98\u8D34\u5904\u7406\u5931\u8D25:",ze)});return}if(ye.ctrl&&ye.name==="g"){q().catch(ze=>{});return}if(ye.paste&&!ye.sequence){q().catch(ze=>{});return}if(ye.paste&&ye.sequence&&(ye.sequence===`
4923
4923
  `||ye.sequence==="\r")){if(ye.shift||ye.sequence===`
4924
4924
  `&&!ye.ctrl){console.log(" \u2514\u2500 \u5224\u65AD\u4E3AShift+Enter\u6216\u88F8\u9732\u6362\u884C\uFF0C\u6267\u884C\u6362\u884C"),n.newline();return}if(ye.ctrl){console.log(" \u2514\u2500 \u5224\u65AD\u4E3ACtrl+Enter\uFF0C\u6267\u884C\u6362\u884C"),n.newline();return}}if(ye.paste&&ye.sequence){j(ye).catch(ze=>{console.error("\u2328\uFE0F [\u5FEB\u6377\u952E] \u6587\u672C\u7C98\u8D34\u5904\u7406\u5931\u8D25:",ze)});return}if(ye.sequence&&ye.sequence.includes(`
4925
- `)&&ye.sequence.length>50){let ze=S(ye.sequence);if(ze){J(nt=>[...nt,ze]),n.handleInput({...ye,sequence:ze.summaryContent});return}}let Ae=!ye.paste&&ye.name!=="up"&&ye.name!=="down"&&ye.name!=="left"&&ye.name!=="right"&&ye.name!=="home"&&ye.name!=="end"&&ye.name!=="pageup"&&ye.name!=="pagedown"&&ye.name!=="tab"&&ye.name!=="escape"&&!(ye.ctrl&&(ye.name==="p"||ye.name==="n"))&&ye.name!=="return",Fe=ye.paste,Xe=(()=>{let ze=n.text.trimStart();if(!ze.startsWith("/"))return!1;let nt=ze.substring(1).split(/\s+/).filter(De=>De);if(nt.length===0)return!1;let lt=e,ct=!1;for(let De=0;De<nt.length;De++){let Ue=nt[De],et=lt.find(He=>He.name===Ue||He.altNames?.includes(Ue));if(et)if(et.action&&(ct=!0),et.subCommands)lt=et.subCommands;else break;else break}return ct&&nt.length>1})();if((Ae||Fe)&&U.showSuggestions&&Xe){let nt=n.text.trimStart().substring(1).split(/\s+/).filter(De=>De),lt=nt.length>0?nt[nt.length-1]:"";U.suggestions.some(De=>De.value===lt||De.label===lt)||U.suppressCompletion()}if(ye.name==="return"&&!ye.shift&&!ye.ctrl&&!ye.meta&&!ye.paste){n.text.trim()&&K.handleSubmit(n.text);return}n.handleInput(ye)},[I,n,U,v,w,a,K,_,L,q,T,A,S,ae,Y]);mon(ie,{isActive:!Y});let se=(0,vs.useMemo)(()=>{let ye=n.allVisualLines.length,Ve=1,Ae=Math.min(15,Math.floor(h/10));return ye>0?Math.min(Math.max(ye,Ve),Ae):Ve},[n.allVisualLines.length,h]),Ie=n.viewportVisualLines,[me,he]=n.visualCursor,Ne=n.visualScrollRow,Re=(0,vs.useMemo)(()=>{if(n.text.length===0)return null;let ye=me-Ne;return Ie.map((Ve,Ae)=>{let Fe=Math.min(h*2,1e3),Xe=Ca(Ve)>Fe?oc(Ve,0,Fe)+"...":Ve,ze=oc(Xe,0,h),nt=hl(ze);if(nt<h&&(ze=ze+" ".repeat(h-nt)),I&&Ae===ye){let lt=he;if(lt>=0)if(lt<Ca(ze)){let ct=oc(ze,lt,lt+1)||" ",De=Ns.bgWhite.black(ct);ze=oc(ze,0,lt)+De+oc(ze,lt+1)}else lt===Ca(ze)&&Ca(ze)===h&&(ze=ze+Ns.bgWhite(" "))}return(0,ud.jsx)(rt,{children:ze},Ae)})},[Ie,me,he,Ne,h,I,n.text.length]),Ye=R?Ke("input.placeholder.help_ask"):Ke("input.placeholder.base");return(0,ud.jsxs)(ud.Fragment,{children:[(0,ud.jsxs)(Gt,{paddingX:1,minHeight:se,children:[(0,ud.jsx)(rt,{color:v?pt.AccentYellow:R?pt.AccentCyan:pt.AccentOrange,children:v?"! ":R?"\u{1F4A1} ":"> "}),(0,ud.jsx)(Gt,{flexGrow:1,flexDirection:"column",children:n.text.length===0?(0,ud.jsxs)(rt,{children:[(0,ud.jsxs)(rt,{color:pt.Gray,children:[I?Ns.inverse(Ye.charAt(0)):Ye.charAt(0),Ye.slice(1)]}),!R&&(0,ud.jsxs)(rt,{color:pt.AccentYellow,children:[" (",C(),", esc: Cancel)"]})]}):Re})]}),k.length>0&&(0,ud.jsxs)(Gt,{marginTop:1,flexDirection:"column",children:[(0,ud.jsxs)(rt,{color:pt.AccentYellow,children:["\u{1F4A1} ",ln("input.paste.detected",{count:k.length})]}),k.map((ye,Ve)=>(0,ud.jsxs)(rt,{color:pt.Gray,dimColor:!0,children:["\u2022 \u7247\u6BB5 ",Ve+1,": ",Vx(ye.originalContent)," \u884C\u5185\u5BB9"]},Ve))]}),p&&(0,ud.jsx)(Gt,{marginTop:1,children:(0,ud.jsx)(rt,{color:pt.AccentYellow,children:Ke("input.paste.clipboard.image")})}),U.showSuggestions&&(0,ud.jsx)(Gt,{children:(0,ud.jsx)(jsn,{suggestions:U.suggestions,activeIndex:U.activeSuggestionIndex,isLoading:U.isLoadingSuggestions,width:o,scrollOffset:U.visibleStartIndex,userInput:n.text})})]})};Wr();var tK=Dt(Xn(),1);var Gon=({errorCount:n})=>n<=12?null:(0,tK.jsx)(Gt,{children:(0,tK.jsxs)(rt,{color:pt.AccentRed,children:["\u2716"," ",n," error",n>1?"s":""," ",(0,tK.jsx)(rt,{color:pt.Gray,children:"(ctrl+o to toggle, ctrl+s to expand)"})]})});import oK from"node:process";var hcn=Dt(mr(),1);var GN=Dt(d7e(),1),w7e=Dt(dcn(),1);FF();var mcn=n=>{if(n.name&&n.colors)throw new Error("The `name` and `colors` props are mutually exclusive");let t;if(n.name)t=w7e.default[n.name];else if(n.colors)t=(0,w7e.default)(n.colors);else throw new Error("Either `name` or `colors` prop must be provided");let r=a=>t.multiline(Nm(a));return hcn.default.createElement(i9,{transform:r},n.children)};mcn.propTypes={children:GN.default.oneOfType([GN.default.arrayOf(GN.default.node),GN.default.node]).isRequired,name:GN.default.oneOf(["cristal","teen","mind","morning","vice","passion","fruit","instagram","atlas","retro","summer","pastel","rainbow"]),colors:GN.default.arrayOf(GN.default.oneOfType([GN.default.string,GN.default.object]))};var kpe=mcn;var lK=Dt(mr(),1);import wSr from"node:process";var sK=Dt(Xn(),1);var pcn=()=>{let[n,t]=(0,lK.useState)(""),[r,a]=(0,lK.useState)(pt.Gray);return(0,lK.useEffect)(()=>{let i=()=>{let e=wSr.memoryUsage().rss;t(Che(e)),a(e>=2147483648?pt.AccentRed:pt.Gray)},s=setInterval(i,1e4);return i(),()=>clearInterval(s)},[]),(0,sK.jsxs)(Gt,{children:[(0,sK.jsx)(rt,{color:pt.Gray,children:"| "}),(0,sK.jsx)(rt,{color:r,children:n})]})};Nr();lR();var ws=Dt(Xn(),1);var bcn=({model:n,targetDir:t,branchName:r,debugMode:a,debugMessage:i,corgiMode:s,errorCount:e,showErrorDetails:c,showMemoryUsage:u,promptTokenCount:d,nightly:I,vimMode:h,version:o,ideConnectionStatus:v,config:w,terminalWidth:R=80})=>{let E=ep(n,w),A=d/E,Y=Lsn(R),W=((1-A)*100).toFixed(1),y=o?Xsn(o,Y.showNodeVersion):null,b=ksn(W,Y.simplifyContext),f=C2(n,w),g=rV(f,Y.simplifyModel);return(0,ws.jsxs)(Gt,{justifyContent:"space-between",width:"100%",marginTop:1,children:[(0,ws.jsxs)(Gt,{children:[h&&(0,ws.jsxs)(rt,{color:pt.Gray,children:["[",h,"] "]}),I?(0,ws.jsx)(kpe,{colors:pt.GradientColors,children:(0,ws.jsxs)(rt,{children:[xc(Cie(t),70),r&&(0,ws.jsxs)(rt,{children:[" (",r,"*)"]})]})}):(0,ws.jsxs)(rt,{color:pt.LightBlue,children:[xc(Cie(t),70),r&&(0,ws.jsxs)(rt,{color:pt.Gray,children:[" (",r,"*)"]})]}),a&&(0,ws.jsx)(rt,{color:pt.AccentRed,children:" "+(i||"--debug")})]}),(0,ws.jsx)(Gt,{flexGrow:1,alignItems:"center",justifyContent:"center",display:"flex",children:oK.env.SANDBOX&&oK.env.SANDBOX!=="sandbox-exec"?(0,ws.jsx)(rt,{color:"green",children:oK.env.SANDBOX.replace(/^gemini-(?:cli-)?/,"")}):oK.env.SANDBOX==="sandbox-exec"?(0,ws.jsxs)(rt,{color:pt.AccentYellow,children:["macOS Seatbelt"," ",(0,ws.jsxs)(rt,{color:pt.Gray,children:["(",oK.env.SEATBELT_PROFILE,")"]})]}):null}),(0,ws.jsxs)(Gt,{alignItems:"center",children:[y&&(0,ws.jsxs)(Gt,{children:[(0,ws.jsx)(rt,{color:pt.Gray,children:y}),(0,ws.jsx)(rt,{color:pt.Gray,children:" | "})]}),b&&(0,ws.jsx)(rt,{color:pt.Gray,children:b}),n&&(0,ws.jsxs)(Gt,{children:[b&&(0,ws.jsx)(rt,{color:pt.Gray,children:" | "}),Y.simplifyModel?(0,ws.jsx)(rt,{color:pt.AccentBlue,children:g}):(0,ws.jsxs)(rt,{color:pt.AccentBlue,children:[Ke("footer.current.model"),": ",f]})]}),v===yu.Connected&&(0,ws.jsxs)(Gt,{children:[(0,ws.jsx)(rt,{color:pt.Gray,children:" | "}),(0,ws.jsx)(rt,{color:"green",children:Ke("ide.connected")})]}),!c&&e>0&&(0,ws.jsxs)(Gt,{children:[(0,ws.jsx)(rt,{color:pt.Gray,children:"| "}),(0,ws.jsx)(Gon,{errorCount:e})]}),u&&(0,ws.jsx)(pcn,{})]})]})};Nr();function YSr(n,t){if(!n)return[];try{return wE(n,t,{hard:!1,trim:!1}).split(`
4925
+ `)&&ye.sequence.length>50){let ze=S(ye.sequence);if(ze){J(nt=>[...nt,ze]),n.handleInput({...ye,sequence:ze.summaryContent});return}}let Ae=!ye.paste&&ye.name!=="up"&&ye.name!=="down"&&ye.name!=="left"&&ye.name!=="right"&&ye.name!=="home"&&ye.name!=="end"&&ye.name!=="pageup"&&ye.name!=="pagedown"&&ye.name!=="tab"&&ye.name!=="escape"&&!(ye.ctrl&&(ye.name==="p"||ye.name==="n"))&&ye.name!=="return",Fe=ye.paste,Xe=(()=>{let ze=n.text.trimStart();if(!ze.startsWith("/"))return!1;let nt=ze.substring(1).split(/\s+/).filter(De=>De);if(nt.length===0)return!1;let lt=e,ct=!1;for(let De=0;De<nt.length;De++){let Ue=nt[De],et=lt.find(He=>He.name===Ue||He.altNames?.includes(Ue));if(et)if(et.action&&(ct=!0),et.subCommands)lt=et.subCommands;else break;else break}return ct&&nt.length>1})();if((Ae||Fe)&&U.showSuggestions&&Xe){let nt=n.text.trimStart().substring(1).split(/\s+/).filter(De=>De),lt=nt.length>0?nt[nt.length-1]:"";U.suggestions.some(De=>De.value===lt||De.label===lt)||U.suppressCompletion()}if(ye.name==="return"&&!ye.shift&&!ye.ctrl&&!ye.meta&&!ye.paste){n.text.trim()&&K.handleSubmit(n.text);return}n.handleInput(ye)},[I,n,U,v,w,a,K,_,L,q,T,A,S,ae,Y]);mon(ie,{isActive:!Y});let se=(0,vs.useMemo)(()=>{let ye=n.allVisualLines.length,Ve=1,Ae=Math.min(15,Math.floor(h/10));return ye>0?Math.min(Math.max(ye,Ve),Ae):Ve},[n.allVisualLines.length,h]),Ie=n.viewportVisualLines,[me,he]=n.visualCursor,Ne=n.visualScrollRow,Re=(0,vs.useMemo)(()=>{if(n.text.length===0)return null;let ye=me-Ne;return Ie.map((Ve,Ae)=>{let Fe=Math.min(h*2,1e3),Xe=Ca(Ve)>Fe?oc(Ve,0,Fe)+"...":Ve,ze=oc(Xe,0,h),nt=hl(ze);if(nt<h&&(ze=ze+" ".repeat(h-nt)),I&&Ae===ye){let lt=he;if(lt>=0)if(lt<Ca(ze)){let ct=oc(ze,lt,lt+1)||" ",De=Ns.bgWhite.black(ct);ze=oc(ze,0,lt)+De+oc(ze,lt+1)}else lt===Ca(ze)&&Ca(ze)===h&&(ze=ze+Ns.bgWhite(" "))}return(0,ud.jsx)(rt,{children:ze},Ae)})},[Ie,me,he,Ne,h,I,n.text.length]),Ye=R?Ke("input.placeholder.help_ask"):Ke("input.placeholder.base");return(0,ud.jsxs)(ud.Fragment,{children:[(0,ud.jsxs)(Gt,{paddingX:1,minHeight:se,children:[(0,ud.jsx)(rt,{color:v?pt.AccentYellow:R?pt.AccentCyan:pt.AccentOrange,children:v?"! ":R?"\u{1F4A1} ":"> "}),(0,ud.jsx)(Gt,{flexGrow:1,flexDirection:"column",children:n.text.length===0?(0,ud.jsxs)(rt,{children:[(0,ud.jsxs)(rt,{color:pt.Gray,children:[I?Ns.inverse(Ye.charAt(0)):Ye.charAt(0),Ye.slice(1)]}),R?null:(0,ud.jsxs)(rt,{color:pt.AccentYellow,children:[" (",C(),", esc: Cancel)"]})]}):Re})]}),k.length>0?(0,ud.jsxs)(Gt,{marginTop:1,flexDirection:"column",children:[(0,ud.jsxs)(rt,{color:pt.AccentYellow,children:["\u{1F4A1} ",ln("input.paste.detected",{count:k.length})]}),k.map((ye,Ve)=>(0,ud.jsxs)(rt,{color:pt.Gray,dimColor:!0,children:["\u2022 \u7247\u6BB5 ",Ve+1,": ",Vx(ye.originalContent)," \u884C\u5185\u5BB9"]},Ve))]}):null,p?(0,ud.jsx)(Gt,{marginTop:1,children:(0,ud.jsx)(rt,{color:pt.AccentYellow,children:Ke("input.paste.clipboard.image")})}):null,U.showSuggestions&&(0,ud.jsx)(Gt,{children:(0,ud.jsx)(jsn,{suggestions:U.suggestions,activeIndex:U.activeSuggestionIndex,isLoading:U.isLoadingSuggestions,width:o,scrollOffset:U.visibleStartIndex,userInput:n.text})})]})};Wr();var tK=Dt(Xn(),1);var Gon=({errorCount:n})=>n<=12?null:(0,tK.jsx)(Gt,{children:(0,tK.jsxs)(rt,{color:pt.AccentRed,children:["\u2716"," ",n," error",n>1?"s":""," ",(0,tK.jsx)(rt,{color:pt.Gray,children:"(ctrl+o to toggle, ctrl+s to expand)"})]})});import oK from"node:process";var hcn=Dt(mr(),1);var GN=Dt(d7e(),1),w7e=Dt(dcn(),1);FF();var mcn=n=>{if(n.name&&n.colors)throw new Error("The `name` and `colors` props are mutually exclusive");let t;if(n.name)t=w7e.default[n.name];else if(n.colors)t=(0,w7e.default)(n.colors);else throw new Error("Either `name` or `colors` prop must be provided");let r=a=>t.multiline(Nm(a));return hcn.default.createElement(i9,{transform:r},n.children)};mcn.propTypes={children:GN.default.oneOfType([GN.default.arrayOf(GN.default.node),GN.default.node]).isRequired,name:GN.default.oneOf(["cristal","teen","mind","morning","vice","passion","fruit","instagram","atlas","retro","summer","pastel","rainbow"]),colors:GN.default.arrayOf(GN.default.oneOfType([GN.default.string,GN.default.object]))};var kpe=mcn;var lK=Dt(mr(),1);import wSr from"node:process";var sK=Dt(Xn(),1);var pcn=()=>{let[n,t]=(0,lK.useState)(""),[r,a]=(0,lK.useState)(pt.Gray);return(0,lK.useEffect)(()=>{let i=()=>{let e=wSr.memoryUsage().rss;t(Che(e)),a(e>=2147483648?pt.AccentRed:pt.Gray)},s=setInterval(i,1e4);return i(),()=>clearInterval(s)},[]),(0,sK.jsxs)(Gt,{children:[(0,sK.jsx)(rt,{color:pt.Gray,children:"| "}),(0,sK.jsx)(rt,{color:r,children:n})]})};Nr();lR();var ws=Dt(Xn(),1);var bcn=({model:n,targetDir:t,branchName:r,debugMode:a,debugMessage:i,corgiMode:s,errorCount:e,showErrorDetails:c,showMemoryUsage:u,promptTokenCount:d,nightly:I,vimMode:h,version:o,ideConnectionStatus:v,config:w,terminalWidth:R=80})=>{let E=ep(n,w),A=d/E,Y=Lsn(R),W=((1-A)*100).toFixed(1),y=o?Xsn(o,Y.showNodeVersion):null,b=ksn(W,Y.simplifyContext),f=C2(n,w),g=rV(f,Y.simplifyModel);return(0,ws.jsxs)(Gt,{justifyContent:"space-between",width:"100%",marginTop:1,children:[(0,ws.jsxs)(Gt,{children:[h?(0,ws.jsxs)(rt,{color:pt.Gray,children:["[",h,"] "]}):null,I?(0,ws.jsx)(kpe,{colors:pt.GradientColors,children:(0,ws.jsxs)(rt,{children:[xc(Cie(t),70),r?(0,ws.jsxs)(rt,{children:[" (",r,"*)"]}):null]})}):(0,ws.jsxs)(rt,{color:pt.LightBlue,children:[xc(Cie(t),70),r?(0,ws.jsxs)(rt,{color:pt.Gray,children:[" (",r,"*)"]}):null]}),a?(0,ws.jsx)(rt,{color:pt.AccentRed,children:" "+(i||"--debug")}):null]}),(0,ws.jsx)(Gt,{flexGrow:1,alignItems:"center",justifyContent:"center",display:"flex",children:oK.env.SANDBOX&&oK.env.SANDBOX!=="sandbox-exec"?(0,ws.jsx)(rt,{color:"green",children:oK.env.SANDBOX.replace(/^gemini-(?:cli-)?/,"")}):oK.env.SANDBOX==="sandbox-exec"?(0,ws.jsxs)(rt,{color:pt.AccentYellow,children:["macOS Seatbelt"," ",(0,ws.jsxs)(rt,{color:pt.Gray,children:["(",oK.env.SEATBELT_PROFILE,")"]})]}):null}),(0,ws.jsxs)(Gt,{alignItems:"center",children:[y?(0,ws.jsxs)(Gt,{children:[(0,ws.jsx)(rt,{color:pt.Gray,children:y}),(0,ws.jsx)(rt,{color:pt.Gray,children:" | "})]}):null,b?(0,ws.jsx)(rt,{color:pt.Gray,children:b}):null,n?(0,ws.jsxs)(Gt,{children:[b?(0,ws.jsx)(rt,{color:pt.Gray,children:" | "}):null,Y.simplifyModel?(0,ws.jsx)(rt,{color:pt.AccentBlue,children:g}):(0,ws.jsxs)(rt,{color:pt.AccentBlue,children:[Ke("footer.current.model"),": ",f]})]}):null,v===yu.Connected?(0,ws.jsxs)(Gt,{children:[(0,ws.jsx)(rt,{color:pt.Gray,children:" | "}),(0,ws.jsx)(rt,{color:"green",children:Ke("ide.connected")})]}):null,!c&&e>0?(0,ws.jsxs)(Gt,{children:[(0,ws.jsx)(rt,{color:pt.Gray,children:"| "}),(0,ws.jsx)(Gon,{errorCount:e})]}):null,u?(0,ws.jsx)(pcn,{}):null]})]})};Nr();function YSr(n,t){if(!n)return[];try{return wE(n,t,{hard:!1,trim:!1}).split(`
4926
4926
  `)}catch{return n.split(`
4927
4927
  `)}}function iV(n,t){let{maxRows:r,terminalWidth:a,headRatio:i=.5}=t,s=YSr(n,a),e=s.length;if(e<=r)return{displayText:n,fullText:n,isTruncated:!1};let c=Math.ceil(r*i)-1,u=r-c-1,d=e-c-u,I=s.slice(0,c),h=s.slice(-u),o=ln("text_truncator.omitted_lines",{count:d}),v="___OMITTED_NOTICE___";return{displayText:[...I,v,...h].join(`
4928
4928
  `),fullText:n,isTruncated:!0,omittedLines:d,omittedPlaceholder:v}}function cK(n,t){return n==="sent"?Math.min(8,t-1):Math.min(t-1,16)}var D5=Dt(mr(),1);var Lv=Dt(mr(),1);var uo=Dt(Xn(),1);function _0({items:n,initialIndex:t=0,onSelect:r,onHighlight:a,isFocused:i=!0,showScrollArrows:s=!1,maxItemsToShow:e=10,showNumbers:c=!0,layout:u="vertical",horizontalSpacing:d=2}){let[I,h]=(0,Lv.useState)(t),[o,v]=(0,Lv.useState)(0),[w,R]=(0,Lv.useState)(""),E=(0,Lv.useRef)(null),A=(0,Lv.useRef)(i);(0,Lv.useEffect)(()=>{A.current=i},[i]),(0,Lv.useEffect)(()=>{let W=Math.max(0,Math.min(I-e+1,n.length-e));I<o?v(I):I>=o+e&&v(W)},[I,n.length,o,e]),(0,Lv.useEffect)(()=>()=>{E.current&&clearTimeout(E.current)},[]),Ko((W,y)=>{process.env.DEBUG_THEME_SELECTION==="true"&&console.log("[RadioButtonSelect] Input:",W,"key:",JSON.stringify(y),"isFocused:",A.current);let b=c&&/^[0-9]$/.test(W);if(!b&&E.current&&(clearTimeout(E.current),R("")),u==="vertical"){if(W==="k"||y.upArrow){let f=I>0?I-1:n.length-1;h(f),a?.(n[f].value);return}if(W==="j"||y.downArrow){let f=I<n.length-1?I+1:0;h(f),a?.(n[f].value);return}}else if(u==="horizontal"){if(W==="h"||y.leftArrow){let f=I>0?I-1:n.length-1;h(f),a?.(n[f].value);return}if(W==="l"||y.rightArrow){let f=I<n.length-1?I+1:0;h(f),a?.(n[f].value);return}}if(y.return){console.log("[RadioButtonSelect] Enter pressed, isFocused:",A.current,"items.length:",n.length,"activeIndex:",I),r(n[I].value);return}if(b){E.current&&clearTimeout(E.current);let f=w+W;R(f);let g=Number.parseInt(f,10)-1;if(f==="0"){E.current=setTimeout(()=>R(""),350);return}if(g>=0&&g<n.length){let N=n[g];h(g),a?.(N.value),Number.parseInt(f+"0",10)>n.length?(r(N.value),R("")):E.current=setTimeout(()=>{r(N.value),R("")},350)}else R("")}},{isActive:i});let Y=n.slice(o,o+e);return u==="horizontal"?(0,uo.jsx)(Gt,{flexDirection:"row",alignItems:"center",flexWrap:"wrap",children:Y.map((W,y)=>{let b=o+y,f=I===b,g=pt.Foreground,N=pt.Foreground;f?(g=pt.AccentGreen,N=pt.AccentGreen):W.disabled&&(g=pt.Gray,N=pt.Gray),c||(N=pt.Gray);let p=b+1;return(0,uo.jsxs)(Gt,{flexDirection:"row",alignItems:"center",marginRight:y<Y.length-1?d:0,children:[c?(0,uo.jsxs)(uo.Fragment,{children:[(0,uo.jsx)(Gt,{minWidth:1,flexShrink:0,children:(0,uo.jsx)(rt,{color:f?pt.AccentGreen:pt.Foreground,children:f?"\u25CF":"\u25CB"})}),(0,uo.jsx)(Gt,{marginLeft:1,marginRight:1,flexShrink:0,children:(0,uo.jsxs)(rt,{color:N,children:[p,"."]})})]}):(0,uo.jsx)(rt,{color:f?pt.AccentGreen:pt.Foreground,children:f?"\u25CF":"\u25CB"}),(0,uo.jsx)(Gt,{marginLeft:c?0:1,children:(0,uo.jsx)(rt,{color:g,wrap:"truncate",children:W.themeNameDisplay&&W.themeTypeDisplay?(0,uo.jsxs)(uo.Fragment,{children:[W.themeNameDisplay," ",(0,uo.jsx)(rt,{color:pt.Gray,children:W.themeTypeDisplay})]}):W.label})})]},W.label)})}):(0,uo.jsxs)(Gt,{flexDirection:"column",children:[s&&(0,uo.jsx)(rt,{color:o>0?pt.Foreground:pt.Gray,children:"\u25B2"}),Y.map((W,y)=>{let b=o+y,f=I===b,g=pt.Foreground,N=pt.Foreground;f?(g=pt.AccentGreen,N=pt.AccentGreen):W.disabled&&(g=pt.Gray,N=pt.Gray),c||(N=pt.Gray);let p=String(n.length).length,m=`${String(b+1).padStart(p)}.`;return(0,uo.jsxs)(Gt,{alignItems:"center",children:[(0,uo.jsx)(Gt,{minWidth:2,flexShrink:0,children:(0,uo.jsx)(rt,{color:f?pt.AccentGreen:pt.Foreground,children:f?"\u25CF":" "})}),(0,uo.jsx)(Gt,{marginRight:1,flexShrink:0,minWidth:m.length,children:(0,uo.jsx)(rt,{color:N,children:m})}),W.themeNameDisplay&&W.themeTypeDisplay?(0,uo.jsxs)(rt,{color:g,wrap:"truncate",children:[W.themeNameDisplay," ",(0,uo.jsx)(rt,{color:pt.Gray,children:W.themeTypeDisplay})]}):(0,uo.jsx)(rt,{color:g,wrap:"truncate",children:W.label})]},W.label)}),s&&(0,uo.jsx)(rt,{color:o+e<n.length?pt.Foreground:pt.Gray,children:"\u25BC"})]})}import l8r from"crypto";var Ppe=Dt(mr(),1);function CSr(n){let t=n.regex,r=n.COMMENT("//","$",{contains:[{begin:/\\\n/}]}),a="decltype\\(auto\\)",i="[a-zA-Z_]\\w*::",e="(?!struct)("+a+"|"+t.optional(i)+"[a-zA-Z_]\\w*"+t.optional("<[^<>]+>")+")",c={className:"type",begin:"\\b[a-z\\d_]*_t\\b"},d={className:"string",variants:[{begin:'(u8?|U|L)?"',end:'"',illegal:"\\n",contains:[n.BACKSLASH_ESCAPE]},{begin:"(u8?|U|L)?'("+"\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4,8}|[0-7]{3}|\\S)"+"|.)",end:"'",illegal:"."},n.END_SAME_AS_BEGIN({begin:/(?:u8?|U|L)?R"([^()\\ ]{0,16})\(/,end:/\)([^()\\ ]{0,16})"/})]},I={className:"number",variants:[{begin:"[+-]?(?:(?:[0-9](?:'?[0-9])*\\.(?:[0-9](?:'?[0-9])*)?|\\.[0-9](?:'?[0-9])*)(?:[Ee][+-]?[0-9](?:'?[0-9])*)?|[0-9](?:'?[0-9])*[Ee][+-]?[0-9](?:'?[0-9])*|0[Xx](?:[0-9A-Fa-f](?:'?[0-9A-Fa-f])*(?:\\.(?:[0-9A-Fa-f](?:'?[0-9A-Fa-f])*)?)?|\\.[0-9A-Fa-f](?:'?[0-9A-Fa-f])*)[Pp][+-]?[0-9](?:'?[0-9])*)(?:[Ff](?:16|32|64|128)?|(BF|bf)16|[Ll]|)"},{begin:"[+-]?\\b(?:0[Bb][01](?:'?[01])*|0[Xx][0-9A-Fa-f](?:'?[0-9A-Fa-f])*|0(?:'?[0-7])*|[1-9](?:'?[0-9])*)(?:[Uu](?:LL?|ll?)|[Uu][Zz]?|(?:LL?|ll?)[Uu]?|[Zz][Uu]|)"}],relevance:0},h={className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:"if else elif endif define undef warning error line pragma _Pragma ifdef ifndef include"},contains:[{begin:/\\\n/,relevance:0},n.inherit(d,{className:"string"}),{className:"string",begin:/<.*?>/},r,n.C_BLOCK_COMMENT_MODE]},o={className:"title",begin:t.optional(i)+n.IDENT_RE,relevance:0},v=t.optional(i)+n.IDENT_RE+"\\s*\\(",w=["alignas","alignof","and","and_eq","asm","atomic_cancel","atomic_commit","atomic_noexcept","auto","bitand","bitor","break","case","catch","class","co_await","co_return","co_yield","compl","concept","const_cast|10","consteval","constexpr","constinit","continue","decltype","default","delete","do","dynamic_cast|10","else","enum","explicit","export","extern","false","final","for","friend","goto","if","import","inline","module","mutable","namespace","new","noexcept","not","not_eq","nullptr","operator","or","or_eq","override","private","protected","public","reflexpr","register","reinterpret_cast|10","requires","return","sizeof","static_assert","static_cast|10","struct","switch","synchronized","template","this","thread_local","throw","transaction_safe","transaction_safe_dynamic","true","try","typedef","typeid","typename","union","using","virtual","volatile","while","xor","xor_eq"],R=["bool","char","char16_t","char32_t","char8_t","double","float","int","long","short","void","wchar_t","unsigned","signed","const","static"],E=["any","auto_ptr","barrier","binary_semaphore","bitset","complex","condition_variable","condition_variable_any","counting_semaphore","deque","false_type","flat_map","flat_set","future","imaginary","initializer_list","istringstream","jthread","latch","lock_guard","multimap","multiset","mutex","optional","ostringstream","packaged_task","pair","promise","priority_queue","queue","recursive_mutex","recursive_timed_mutex","scoped_lock","set","shared_future","shared_lock","shared_mutex","shared_timed_mutex","shared_ptr","stack","string_view","stringstream","timed_mutex","thread","true_type","tuple","unique_lock","unique_ptr","unordered_map","unordered_multimap","unordered_multiset","unordered_set","variant","vector","weak_ptr","wstring","wstring_view"],A=["abort","abs","acos","apply","as_const","asin","atan","atan2","calloc","ceil","cerr","cin","clog","cos","cosh","cout","declval","endl","exchange","exit","exp","fabs","floor","fmod","forward","fprintf","fputs","free","frexp","fscanf","future","invoke","isalnum","isalpha","iscntrl","isdigit","isgraph","islower","isprint","ispunct","isspace","isupper","isxdigit","labs","launder","ldexp","log","log10","make_pair","make_shared","make_shared_for_overwrite","make_tuple","make_unique","malloc","memchr","memcmp","memcpy","memset","modf","move","pow","printf","putchar","puts","realloc","scanf","sin","sinh","snprintf","sprintf","sqrt","sscanf","std","stderr","stdin","stdout","strcat","strchr","strcmp","strcpy","strcspn","strlen","strncat","strncmp","strncpy","strpbrk","strrchr","strspn","strstr","swap","tan","tanh","terminate","to_underlying","tolower","toupper","vfprintf","visit","vprintf","vsprintf"],y={type:R,keyword:w,literal:["NULL","false","nullopt","nullptr","true"],built_in:["_Pragma"],_type_hints:E},b={className:"function.dispatch",relevance:0,keywords:{_hint:A},begin:t.concat(/\b/,/(?!decltype)/,/(?!if)/,/(?!for)/,/(?!switch)/,/(?!while)/,n.IDENT_RE,t.lookahead(/(<[^<>]+>|)\s*\(/))},f=[b,h,c,r,n.C_BLOCK_COMMENT_MODE,I,d],g={variants:[{begin:/=/,end:/;/},{begin:/\(/,end:/\)/},{beginKeywords:"new throw return else",end:/;/}],keywords:y,contains:f.concat([{begin:/\(/,end:/\)/,keywords:y,contains:f.concat(["self"]),relevance:0}]),relevance:0},N={className:"function",begin:"("+e+"[\\*&\\s]+)+"+v,returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:y,illegal:/[^\w\s\*&:<>.]/,contains:[{begin:a,keywords:y,relevance:0},{begin:v,returnBegin:!0,contains:[o],relevance:0},{begin:/::/,relevance:0},{begin:/:/,endsWithParent:!0,contains:[d,I]},{relevance:0,match:/,/},{className:"params",begin:/\(/,end:/\)/,keywords:y,relevance:0,contains:[r,n.C_BLOCK_COMMENT_MODE,d,I,c,{begin:/\(/,end:/\)/,keywords:y,relevance:0,contains:["self",r,n.C_BLOCK_COMMENT_MODE,d,I,c]}]},c,r,n.C_BLOCK_COMMENT_MODE,h]};return{name:"C++",aliases:["cc","c++","h++","hpp","hh","hxx","cxx"],keywords:y,illegal:"</",classNameAliases:{"function.dispatch":"built_in"},contains:[].concat(g,N,b,f,[h,{begin:"\\b(deque|list|queue|priority_queue|pair|stack|vector|map|set|bitset|multiset|multimap|unordered_map|unordered_set|unordered_multiset|unordered_multimap|array|tuple|optional|variant|function|flat_map|flat_set)\\s*<(?!<)",end:">",keywords:y,contains:["self",c]},{begin:n.IDENT_RE+"::",keywords:y},{match:[/\b(?:enum(?:\s+(?:class|struct))?|class|struct|union)/,/\s+/,/\w+/],className:{1:"keyword",3:"title.class"}}])}}function Gcn(n){let t={type:["boolean","byte","word","String"],built_in:["KeyboardController","MouseController","SoftwareSerial","EthernetServer","EthernetClient","LiquidCrystal","RobotControl","GSMVoiceCall","EthernetUDP","EsploraTFT","HttpClient","RobotMotor","WiFiClient","GSMScanner","FileSystem","Scheduler","GSMServer","YunClient","YunServer","IPAddress","GSMClient","GSMModem","Keyboard","Ethernet","Console","GSMBand","Esplora","Stepper","Process","WiFiUDP","GSM_SMS","Mailbox","USBHost","Firmata","PImage","Client","Server","GSMPIN","FileIO","Bridge","Serial","EEPROM","Stream","Mouse","Audio","Servo","File","Task","GPRS","WiFi","Wire","TFT","GSM","SPI","SD"],_hints:["setup","loop","runShellCommandAsynchronously","analogWriteResolution","retrieveCallingNumber","printFirmwareVersion","analogReadResolution","sendDigitalPortPair","noListenOnLocalhost","readJoystickButton","setFirmwareVersion","readJoystickSwitch","scrollDisplayRight","getVoiceCallStatus","scrollDisplayLeft","writeMicroseconds","delayMicroseconds","beginTransmission","getSignalStrength","runAsynchronously","getAsynchronously","listenOnLocalhost","getCurrentCarrier","readAccelerometer","messageAvailable","sendDigitalPorts","lineFollowConfig","countryNameWrite","runShellCommand","readStringUntil","rewindDirectory","readTemperature","setClockDivider","readLightSensor","endTransmission","analogReference","detachInterrupt","countryNameRead","attachInterrupt","encryptionType","readBytesUntil","robotNameWrite","readMicrophone","robotNameRead","cityNameWrite","userNameWrite","readJoystickY","readJoystickX","mouseReleased","openNextFile","scanNetworks","noInterrupts","digitalWrite","beginSpeaker","mousePressed","isActionDone","mouseDragged","displayLogos","noAutoscroll","addParameter","remoteNumber","getModifiers","keyboardRead","userNameRead","waitContinue","processInput","parseCommand","printVersion","readNetworks","writeMessage","blinkVersion","cityNameRead","readMessage","setDataMode","parsePacket","isListening","setBitOrder","beginPacket","isDirectory","motorsWrite","drawCompass","digitalRead","clearScreen","serialEvent","rightToLeft","setTextSize","leftToRight","requestFrom","keyReleased","compassRead","analogWrite","interrupts","WiFiServer","disconnect","playMelody","parseFloat","autoscroll","getPINUsed","setPINUsed","setTimeout","sendAnalog","readSlider","analogRead","beginWrite","createChar","motorsStop","keyPressed","tempoWrite","readButton","subnetMask","debugPrint","macAddress","writeGreen","randomSeed","attachGPRS","readString","sendString","remotePort","releaseAll","mouseMoved","background","getXChange","getYChange","answerCall","getResult","voiceCall","endPacket","constrain","getSocket","writeJSON","getButton","available","connected","findUntil","readBytes","exitValue","readGreen","writeBlue","startLoop","IPAddress","isPressed","sendSysex","pauseMode","gatewayIP","setCursor","getOemKey","tuneWrite","noDisplay","loadImage","switchPIN","onRequest","onReceive","changePIN","playFile","noBuffer","parseInt","overflow","checkPIN","knobRead","beginTFT","bitClear","updateIR","bitWrite","position","writeRGB","highByte","writeRed","setSpeed","readBlue","noStroke","remoteIP","transfer","shutdown","hangCall","beginSMS","endWrite","attached","maintain","noCursor","checkReg","checkPUK","shiftOut","isValid","shiftIn","pulseIn","connect","println","localIP","pinMode","getIMEI","display","noBlink","process","getBand","running","beginSD","drawBMP","lowByte","setBand","release","bitRead","prepare","pointTo","readRed","setMode","noFill","remove","listen","stroke","detach","attach","noTone","exists","buffer","height","bitSet","circle","config","cursor","random","IRread","setDNS","endSMS","getKey","micros","millis","begin","print","write","ready","flush","width","isPIN","blink","clear","press","mkdir","rmdir","close","point","yield","image","BSSID","click","delay","read","text","move","peek","beep","rect","line","open","seek","fill","size","turn","stop","home","find","step","tone","sqrt","RSSI","SSID","end","bit","tan","cos","sin","pow","map","abs","max","min","get","run","put"],literal:["DIGITAL_MESSAGE","FIRMATA_STRING","ANALOG_MESSAGE","REPORT_DIGITAL","REPORT_ANALOG","INPUT_PULLUP","SET_PIN_MODE","INTERNAL2V56","SYSTEM_RESET","LED_BUILTIN","INTERNAL1V1","SYSEX_START","INTERNAL","EXTERNAL","DEFAULT","OUTPUT","INPUT","HIGH","LOW"]},r=CSr(n),a=r.keywords;return a.type=[...a.type,...t.type],a.literal=[...a.literal,...t.literal],a.built_in=[...a.built_in,...t.built_in],a._hints=t._hints,r.name="Arduino",r.aliases=["ino"],r.supersetOf="cpp",r}function fcn(n){let t=n.regex,r={},a={begin:/\$\{/,end:/\}/,contains:["self",{begin:/:-/,contains:[r]}]};Object.assign(r,{className:"variable",variants:[{begin:t.concat(/\$[\w\d#@][\w\d_]*/,"(?![\\w\\d])(?![$])")},a]});let i={className:"subst",begin:/\$\(/,end:/\)/,contains:[n.BACKSLASH_ESCAPE]},s=n.inherit(n.COMMENT(),{match:[/(^|\s)/,/#.*$/],scope:{2:"comment"}}),e={begin:/<<-?\s*(?=\w+)/,starts:{contains:[n.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,className:"string"})]}},c={className:"string",begin:/"/,end:/"/,contains:[n.BACKSLASH_ESCAPE,r,i]};i.contains.push(c);let u={match:/\\"/},d={className:"string",begin:/'/,end:/'/},I={match:/\\'/},h={begin:/\$?\(\(/,end:/\)\)/,contains:[{begin:/\d+#[0-9a-f]+/,className:"number"},n.NUMBER_MODE,r]},o=["fish","bash","zsh","sh","csh","ksh","tcsh","dash","scsh"],v=n.SHEBANG({binary:`(${o.join("|")})`,relevance:10}),w={className:"function",begin:/\w[\w\d_]*\s*\(\s*\)\s*\{/,returnBegin:!0,contains:[n.inherit(n.TITLE_MODE,{begin:/\w[\w\d_]*/})],relevance:0},R=["if","then","else","elif","fi","time","for","while","until","in","do","done","case","esac","coproc","function","select"],E=["true","false"],A={match:/(\/[a-z._-]+)+/},Y=["break","cd","continue","eval","exec","exit","export","getopts","hash","pwd","readonly","return","shift","test","times","trap","umask","unset"],W=["alias","bind","builtin","caller","command","declare","echo","enable","help","let","local","logout","mapfile","printf","read","readarray","source","sudo","type","typeset","ulimit","unalias"],y=["autoload","bg","bindkey","bye","cap","chdir","clone","comparguments","compcall","compctl","compdescribe","compfiles","compgroups","compquote","comptags","comptry","compvalues","dirs","disable","disown","echotc","echoti","emulate","fc","fg","float","functions","getcap","getln","history","integer","jobs","kill","limit","log","noglob","popd","print","pushd","pushln","rehash","sched","setcap","setopt","stat","suspend","ttyctl","unfunction","unhash","unlimit","unsetopt","vared","wait","whence","where","which","zcompile","zformat","zftp","zle","zmodload","zparseopts","zprof","zpty","zregexparse","zsocket","zstyle","ztcp"],b=["chcon","chgrp","chown","chmod","cp","dd","df","dir","dircolors","ln","ls","mkdir","mkfifo","mknod","mktemp","mv","realpath","rm","rmdir","shred","sync","touch","truncate","vdir","b2sum","base32","base64","cat","cksum","comm","csplit","cut","expand","fmt","fold","head","join","md5sum","nl","numfmt","od","paste","ptx","pr","sha1sum","sha224sum","sha256sum","sha384sum","sha512sum","shuf","sort","split","sum","tac","tail","tr","tsort","unexpand","uniq","wc","arch","basename","chroot","date","dirname","du","echo","env","expr","factor","groups","hostid","id","link","logname","nice","nohup","nproc","pathchk","pinky","printenv","printf","pwd","readlink","runcon","seq","sleep","stat","stdbuf","stty","tee","test","timeout","tty","uname","unlink","uptime","users","who","whoami","yes"];return{name:"Bash",aliases:["sh","zsh"],keywords:{$pattern:/\b[a-z][a-z0-9._-]+\b/,keyword:R,literal:E,built_in:[...Y,...W,"set","shopt",...y,...b]},contains:[v,n.SHEBANG(),w,h,s,e,A,c,u,d,I,r]}}function gcn(n){let t=n.regex,r=n.COMMENT("//","$",{contains:[{begin:/\\\n/}]}),a="decltype\\(auto\\)",i="[a-zA-Z_]\\w*::",e="("+a+"|"+t.optional(i)+"[a-zA-Z_]\\w*"+t.optional("<[^<>]+>")+")",c={className:"type",variants:[{begin:"\\b[a-z\\d_]*_t\\b"},{match:/\batomic_[a-z]{3,6}\b/}]},d={className:"string",variants:[{begin:'(u8?|U|L)?"',end:'"',illegal:"\\n",contains:[n.BACKSLASH_ESCAPE]},{begin:"(u8?|U|L)?'("+"\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4,8}|[0-7]{3}|\\S)"+"|.)",end:"'",illegal:"."},n.END_SAME_AS_BEGIN({begin:/(?:u8?|U|L)?R"([^()\\ ]{0,16})\(/,end:/\)([^()\\ ]{0,16})"/})]},I={className:"number",variants:[{match:/\b(0b[01']+)/},{match:/(-?)\b([\d']+(\.[\d']*)?|\.[\d']+)((ll|LL|l|L)(u|U)?|(u|U)(ll|LL|l|L)?|f|F|b|B)/},{match:/(-?)\b(0[xX][a-fA-F0-9]+(?:'[a-fA-F0-9]+)*(?:\.[a-fA-F0-9]*(?:'[a-fA-F0-9]*)*)?(?:[pP][-+]?[0-9]+)?(l|L)?(u|U)?)/},{match:/(-?)\b\d+(?:'\d+)*(?:\.\d*(?:'\d*)*)?(?:[eE][-+]?\d+)?/}],relevance:0},h={className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:"if else elif endif define undef warning error line pragma _Pragma ifdef ifndef elifdef elifndef include"},contains:[{begin:/\\\n/,relevance:0},n.inherit(d,{className:"string"}),{className:"string",begin:/<.*?>/},r,n.C_BLOCK_COMMENT_MODE]},o={className:"title",begin:t.optional(i)+n.IDENT_RE,relevance:0},v=t.optional(i)+n.IDENT_RE+"\\s*\\(",E={keyword:["asm","auto","break","case","continue","default","do","else","enum","extern","for","fortran","goto","if","inline","register","restrict","return","sizeof","typeof","typeof_unqual","struct","switch","typedef","union","volatile","while","_Alignas","_Alignof","_Atomic","_Generic","_Noreturn","_Static_assert","_Thread_local","alignas","alignof","noreturn","static_assert","thread_local","_Pragma"],type:["float","double","signed","unsigned","int","short","long","char","void","_Bool","_BitInt","_Complex","_Imaginary","_Decimal32","_Decimal64","_Decimal96","_Decimal128","_Decimal64x","_Decimal128x","_Float16","_Float32","_Float64","_Float128","_Float32x","_Float64x","_Float128x","const","static","constexpr","complex","bool","imaginary"],literal:"true false NULL",built_in:"std string wstring cin cout cerr clog stdin stdout stderr stringstream istringstream ostringstream auto_ptr deque list queue stack vector map set pair bitset multiset multimap unordered_set unordered_map unordered_multiset unordered_multimap priority_queue make_pair array shared_ptr abort terminate abs acos asin atan2 atan calloc ceil cosh cos exit exp fabs floor fmod fprintf fputs free frexp fscanf future isalnum isalpha iscntrl isdigit isgraph islower isprint ispunct isspace isupper isxdigit tolower toupper labs ldexp log10 log malloc realloc memchr memcmp memcpy memset modf pow printf putchar puts scanf sinh sin snprintf sprintf sqrt sscanf strcat strchr strcmp strcpy strcspn strlen strncat strncmp strncpy strpbrk strrchr strspn strstr tanh tan vfprintf vprintf vsprintf endl initializer_list unique_ptr"},A=[h,c,r,n.C_BLOCK_COMMENT_MODE,I,d],Y={variants:[{begin:/=/,end:/;/},{begin:/\(/,end:/\)/},{beginKeywords:"new throw return else",end:/;/}],keywords:E,contains:A.concat([{begin:/\(/,end:/\)/,keywords:E,contains:A.concat(["self"]),relevance:0}]),relevance:0},W={begin:"("+e+"[\\*&\\s]+)+"+v,returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:E,illegal:/[^\w\s\*&:<>.]/,contains:[{begin:a,keywords:E,relevance:0},{begin:v,returnBegin:!0,contains:[n.inherit(o,{className:"title.function"})],relevance:0},{relevance:0,match:/,/},{className:"params",begin:/\(/,end:/\)/,keywords:E,relevance:0,contains:[r,n.C_BLOCK_COMMENT_MODE,d,I,c,{begin:/\(/,end:/\)/,keywords:E,relevance:0,contains:["self",r,n.C_BLOCK_COMMENT_MODE,d,I,c]}]},c,r,n.C_BLOCK_COMMENT_MODE,h]};return{name:"C",aliases:["h"],keywords:E,disableAutodetect:!0,illegal:"</",contains:[].concat(Y,W,A,[h,{begin:n.IDENT_RE+"::",keywords:E},{className:"class",beginKeywords:"enum class struct union",end:/[{;:<>=]/,contains:[{beginKeywords:"final class struct"},n.TITLE_MODE]}]),exports:{preprocessor:h,strings:d,keywords:E}}}function vcn(n){let t=n.regex,r=n.COMMENT("//","$",{contains:[{begin:/\\\n/}]}),a="decltype\\(auto\\)",i="[a-zA-Z_]\\w*::",e="(?!struct)("+a+"|"+t.optional(i)+"[a-zA-Z_]\\w*"+t.optional("<[^<>]+>")+")",c={className:"type",begin:"\\b[a-z\\d_]*_t\\b"},d={className:"string",variants:[{begin:'(u8?|U|L)?"',end:'"',illegal:"\\n",contains:[n.BACKSLASH_ESCAPE]},{begin:"(u8?|U|L)?'("+"\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4,8}|[0-7]{3}|\\S)"+"|.)",end:"'",illegal:"."},n.END_SAME_AS_BEGIN({begin:/(?:u8?|U|L)?R"([^()\\ ]{0,16})\(/,end:/\)([^()\\ ]{0,16})"/})]},I={className:"number",variants:[{begin:"[+-]?(?:(?:[0-9](?:'?[0-9])*\\.(?:[0-9](?:'?[0-9])*)?|\\.[0-9](?:'?[0-9])*)(?:[Ee][+-]?[0-9](?:'?[0-9])*)?|[0-9](?:'?[0-9])*[Ee][+-]?[0-9](?:'?[0-9])*|0[Xx](?:[0-9A-Fa-f](?:'?[0-9A-Fa-f])*(?:\\.(?:[0-9A-Fa-f](?:'?[0-9A-Fa-f])*)?)?|\\.[0-9A-Fa-f](?:'?[0-9A-Fa-f])*)[Pp][+-]?[0-9](?:'?[0-9])*)(?:[Ff](?:16|32|64|128)?|(BF|bf)16|[Ll]|)"},{begin:"[+-]?\\b(?:0[Bb][01](?:'?[01])*|0[Xx][0-9A-Fa-f](?:'?[0-9A-Fa-f])*|0(?:'?[0-7])*|[1-9](?:'?[0-9])*)(?:[Uu](?:LL?|ll?)|[Uu][Zz]?|(?:LL?|ll?)[Uu]?|[Zz][Uu]|)"}],relevance:0},h={className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:"if else elif endif define undef warning error line pragma _Pragma ifdef ifndef include"},contains:[{begin:/\\\n/,relevance:0},n.inherit(d,{className:"string"}),{className:"string",begin:/<.*?>/},r,n.C_BLOCK_COMMENT_MODE]},o={className:"title",begin:t.optional(i)+n.IDENT_RE,relevance:0},v=t.optional(i)+n.IDENT_RE+"\\s*\\(",w=["alignas","alignof","and","and_eq","asm","atomic_cancel","atomic_commit","atomic_noexcept","auto","bitand","bitor","break","case","catch","class","co_await","co_return","co_yield","compl","concept","const_cast|10","consteval","constexpr","constinit","continue","decltype","default","delete","do","dynamic_cast|10","else","enum","explicit","export","extern","false","final","for","friend","goto","if","import","inline","module","mutable","namespace","new","noexcept","not","not_eq","nullptr","operator","or","or_eq","override","private","protected","public","reflexpr","register","reinterpret_cast|10","requires","return","sizeof","static_assert","static_cast|10","struct","switch","synchronized","template","this","thread_local","throw","transaction_safe","transaction_safe_dynamic","true","try","typedef","typeid","typename","union","using","virtual","volatile","while","xor","xor_eq"],R=["bool","char","char16_t","char32_t","char8_t","double","float","int","long","short","void","wchar_t","unsigned","signed","const","static"],E=["any","auto_ptr","barrier","binary_semaphore","bitset","complex","condition_variable","condition_variable_any","counting_semaphore","deque","false_type","flat_map","flat_set","future","imaginary","initializer_list","istringstream","jthread","latch","lock_guard","multimap","multiset","mutex","optional","ostringstream","packaged_task","pair","promise","priority_queue","queue","recursive_mutex","recursive_timed_mutex","scoped_lock","set","shared_future","shared_lock","shared_mutex","shared_timed_mutex","shared_ptr","stack","string_view","stringstream","timed_mutex","thread","true_type","tuple","unique_lock","unique_ptr","unordered_map","unordered_multimap","unordered_multiset","unordered_set","variant","vector","weak_ptr","wstring","wstring_view"],A=["abort","abs","acos","apply","as_const","asin","atan","atan2","calloc","ceil","cerr","cin","clog","cos","cosh","cout","declval","endl","exchange","exit","exp","fabs","floor","fmod","forward","fprintf","fputs","free","frexp","fscanf","future","invoke","isalnum","isalpha","iscntrl","isdigit","isgraph","islower","isprint","ispunct","isspace","isupper","isxdigit","labs","launder","ldexp","log","log10","make_pair","make_shared","make_shared_for_overwrite","make_tuple","make_unique","malloc","memchr","memcmp","memcpy","memset","modf","move","pow","printf","putchar","puts","realloc","scanf","sin","sinh","snprintf","sprintf","sqrt","sscanf","std","stderr","stdin","stdout","strcat","strchr","strcmp","strcpy","strcspn","strlen","strncat","strncmp","strncpy","strpbrk","strrchr","strspn","strstr","swap","tan","tanh","terminate","to_underlying","tolower","toupper","vfprintf","visit","vprintf","vsprintf"],y={type:R,keyword:w,literal:["NULL","false","nullopt","nullptr","true"],built_in:["_Pragma"],_type_hints:E},b={className:"function.dispatch",relevance:0,keywords:{_hint:A},begin:t.concat(/\b/,/(?!decltype)/,/(?!if)/,/(?!for)/,/(?!switch)/,/(?!while)/,n.IDENT_RE,t.lookahead(/(<[^<>]+>|)\s*\(/))},f=[b,h,c,r,n.C_BLOCK_COMMENT_MODE,I,d],g={variants:[{begin:/=/,end:/;/},{begin:/\(/,end:/\)/},{beginKeywords:"new throw return else",end:/;/}],keywords:y,contains:f.concat([{begin:/\(/,end:/\)/,keywords:y,contains:f.concat(["self"]),relevance:0}]),relevance:0},N={className:"function",begin:"("+e+"[\\*&\\s]+)+"+v,returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:y,illegal:/[^\w\s\*&:<>.]/,contains:[{begin:a,keywords:y,relevance:0},{begin:v,returnBegin:!0,contains:[o],relevance:0},{begin:/::/,relevance:0},{begin:/:/,endsWithParent:!0,contains:[d,I]},{relevance:0,match:/,/},{className:"params",begin:/\(/,end:/\)/,keywords:y,relevance:0,contains:[r,n.C_BLOCK_COMMENT_MODE,d,I,c,{begin:/\(/,end:/\)/,keywords:y,relevance:0,contains:["self",r,n.C_BLOCK_COMMENT_MODE,d,I,c]}]},c,r,n.C_BLOCK_COMMENT_MODE,h]};return{name:"C++",aliases:["cc","c++","h++","hpp","hh","hxx","cxx"],keywords:y,illegal:"</",classNameAliases:{"function.dispatch":"built_in"},contains:[].concat(g,N,b,f,[h,{begin:"\\b(deque|list|queue|priority_queue|pair|stack|vector|map|set|bitset|multiset|multimap|unordered_map|unordered_set|unordered_multiset|unordered_multimap|array|tuple|optional|variant|function|flat_map|flat_set)\\s*<(?!<)",end:">",keywords:y,contains:["self",c]},{begin:n.IDENT_RE+"::",keywords:y},{match:[/\b(?:enum(?:\s+(?:class|struct))?|class|struct|union)/,/\s+/,/\w+/],className:{1:"keyword",3:"title.class"}}])}}function Zcn(n){let t=["bool","byte","char","decimal","delegate","double","dynamic","enum","float","int","long","nint","nuint","object","sbyte","short","string","ulong","uint","ushort"],r=["public","private","protected","static","internal","protected","abstract","async","extern","override","unsafe","virtual","new","sealed","partial"],a=["default","false","null","true"],i=["abstract","as","base","break","case","catch","class","const","continue","do","else","event","explicit","extern","finally","fixed","for","foreach","goto","if","implicit","in","interface","internal","is","lock","namespace","new","operator","out","override","params","private","protected","public","readonly","record","ref","return","scoped","sealed","sizeof","stackalloc","static","struct","switch","this","throw","try","typeof","unchecked","unsafe","using","virtual","void","volatile","while"],s=["add","alias","and","ascending","args","async","await","by","descending","dynamic","equals","file","from","get","global","group","init","into","join","let","nameof","not","notnull","on","or","orderby","partial","record","remove","required","scoped","select","set","unmanaged","value|0","var","when","where","with","yield"],e={keyword:i.concat(s),built_in:t,literal:a},c=n.inherit(n.TITLE_MODE,{begin:"[a-zA-Z](\\.?\\w)*"}),u={className:"number",variants:[{begin:"\\b(0b[01']+)"},{begin:"(-?)\\b([\\d']+(\\.[\\d']*)?|\\.[\\d']+)(u|U|l|L|ul|UL|f|F|b|B)"},{begin:"(-?)(\\b0[xX][a-fA-F0-9']+|(\\b[\\d']+(\\.[\\d']*)?|\\.[\\d']+)([eE][-+]?[\\d']+)?)"}],relevance:0},d={className:"string",begin:/"""("*)(?!")(.|\n)*?"""\1/,relevance:1},I={className:"string",begin:'@"',end:'"',contains:[{begin:'""'}]},h=n.inherit(I,{illegal:/\n/}),o={className:"subst",begin:/\{/,end:/\}/,keywords:e},v=n.inherit(o,{illegal:/\n/}),w={className:"string",begin:/\$"/,end:'"',illegal:/\n/,contains:[{begin:/\{\{/},{begin:/\}\}/},n.BACKSLASH_ESCAPE,v]},R={className:"string",begin:/\$@"/,end:'"',contains:[{begin:/\{\{/},{begin:/\}\}/},{begin:'""'},o]},E=n.inherit(R,{illegal:/\n/,contains:[{begin:/\{\{/},{begin:/\}\}/},{begin:'""'},v]});o.contains=[R,w,I,n.APOS_STRING_MODE,n.QUOTE_STRING_MODE,u,n.C_BLOCK_COMMENT_MODE],v.contains=[E,w,h,n.APOS_STRING_MODE,n.QUOTE_STRING_MODE,u,n.inherit(n.C_BLOCK_COMMENT_MODE,{illegal:/\n/})];let A={variants:[d,R,w,I,n.APOS_STRING_MODE,n.QUOTE_STRING_MODE]},Y={begin:"<",end:">",contains:[{beginKeywords:"in out"},c]},W=n.IDENT_RE+"(<"+n.IDENT_RE+"(\\s*,\\s*"+n.IDENT_RE+")*>)?(\\[\\])?",y={begin:"@"+n.IDENT_RE,relevance:0};return{name:"C#",aliases:["cs","c#"],keywords:e,illegal:/::/,contains:[n.COMMENT("///","$",{returnBegin:!0,contains:[{className:"doctag",variants:[{begin:"///",relevance:0},{begin:"<!--|-->"},{begin:"</?",end:">"}]}]}),n.C_LINE_COMMENT_MODE,n.C_BLOCK_COMMENT_MODE,{className:"meta",begin:"#",end:"$",keywords:{keyword:"if else elif endif define undef warning error line region endregion pragma checksum"}},A,u,{beginKeywords:"class interface",relevance:0,end:/[{;=]/,illegal:/[^\s:,]/,contains:[{beginKeywords:"where class"},c,Y,n.C_LINE_COMMENT_MODE,n.C_BLOCK_COMMENT_MODE]},{beginKeywords:"namespace",relevance:0,end:/[{;=]/,illegal:/[^\s:]/,contains:[c,n.C_LINE_COMMENT_MODE,n.C_BLOCK_COMMENT_MODE]},{beginKeywords:"record",relevance:0,end:/[{;=]/,illegal:/[^\s:]/,contains:[c,Y,n.C_LINE_COMMENT_MODE,n.C_BLOCK_COMMENT_MODE]},{className:"meta",begin:"^\\s*\\[(?=[\\w])",excludeBegin:!0,end:"\\]",excludeEnd:!0,contains:[{className:"string",begin:/"/,end:/"/}]},{beginKeywords:"new return throw await else",relevance:0},{className:"function",begin:"("+W+"\\s+)+"+n.IDENT_RE+"\\s*(<[^=]+>\\s*)?\\(",returnBegin:!0,end:/\s*[{;=]/,excludeEnd:!0,keywords:e,contains:[{beginKeywords:r.join(" "),relevance:0},{begin:n.IDENT_RE+"\\s*(<[^=]+>\\s*)?\\(",returnBegin:!0,contains:[n.TITLE_MODE,Y],relevance:0},{match:/\(\)/},{className:"params",begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:e,relevance:0,contains:[A,u,n.C_BLOCK_COMMENT_MODE]},n.C_LINE_COMMENT_MODE,n.C_BLOCK_COMMENT_MODE]},y]}}var xSr=n=>({IMPORTANT:{scope:"meta",begin:"!important"},BLOCK_COMMENT:n.C_BLOCK_COMMENT_MODE,HEXCOLOR:{scope:"number",begin:/#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/},FUNCTION_DISPATCH:{className:"built_in",begin:/[\w-]+(?=\()/},ATTRIBUTE_SELECTOR_MODE:{scope:"selector-attr",begin:/\[/,end:/\]/,illegal:"$",contains:[n.APOS_STRING_MODE,n.QUOTE_STRING_MODE]},CSS_NUMBER_MODE:{scope:"number",begin:n.NUMBER_RE+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",relevance:0},CSS_VARIABLE:{className:"attr",begin:/--[A-Za-z_][A-Za-z0-9_-]*/}}),VSr=["a","abbr","address","article","aside","audio","b","blockquote","body","button","canvas","caption","cite","code","dd","del","details","dfn","div","dl","dt","em","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","html","i","iframe","img","input","ins","kbd","label","legend","li","main","mark","menu","nav","object","ol","optgroup","option","p","picture","q","quote","samp","section","select","source","span","strong","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","ul","var","video"],QSr=["defs","g","marker","mask","pattern","svg","switch","symbol","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feFlood","feGaussianBlur","feImage","feMerge","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","linearGradient","radialGradient","stop","circle","ellipse","image","line","path","polygon","polyline","rect","text","use","textPath","tspan","foreignObject","clipPath"],HSr=[...VSr,...QSr],XSr=["any-hover","any-pointer","aspect-ratio","color","color-gamut","color-index","device-aspect-ratio","device-height","device-width","display-mode","forced-colors","grid","height","hover","inverted-colors","monochrome","orientation","overflow-block","overflow-inline","pointer","prefers-color-scheme","prefers-contrast","prefers-reduced-motion","prefers-reduced-transparency","resolution","scan","scripting","update","width","min-width","max-width","min-height","max-height"].sort().reverse(),kSr=["active","any-link","blank","checked","current","default","defined","dir","disabled","drop","empty","enabled","first","first-child","first-of-type","fullscreen","future","focus","focus-visible","focus-within","has","host","host-context","hover","indeterminate","in-range","invalid","is","lang","last-child","last-of-type","left","link","local-link","not","nth-child","nth-col","nth-last-child","nth-last-col","nth-last-of-type","nth-of-type","only-child","only-of-type","optional","out-of-range","past","placeholder-shown","read-only","read-write","required","right","root","scope","target","target-within","user-invalid","valid","visited","where"].sort().reverse(),LSr=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),JSr=["accent-color","align-content","align-items","align-self","alignment-baseline","all","anchor-name","animation","animation-composition","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-range","animation-range-end","animation-range-start","animation-timeline","animation-timing-function","appearance","aspect-ratio","backdrop-filter","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-position-x","background-position-y","background-repeat","background-size","baseline-shift","block-size","border","border-block","border-block-color","border-block-end","border-block-end-color","border-block-end-style","border-block-end-width","border-block-start","border-block-start-color","border-block-start-style","border-block-start-width","border-block-style","border-block-width","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-end-end-radius","border-end-start-radius","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-inline","border-inline-color","border-inline-end","border-inline-end-color","border-inline-end-style","border-inline-end-width","border-inline-start","border-inline-start-color","border-inline-start-style","border-inline-start-width","border-inline-style","border-inline-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-start-end-radius","border-start-start-radius","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-align","box-decoration-break","box-direction","box-flex","box-flex-group","box-lines","box-ordinal-group","box-orient","box-pack","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","caret-color","clear","clip","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","color-scheme","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","contain","contain-intrinsic-block-size","contain-intrinsic-height","contain-intrinsic-inline-size","contain-intrinsic-size","contain-intrinsic-width","container","container-name","container-type","content","content-visibility","counter-increment","counter-reset","counter-set","cue","cue-after","cue-before","cursor","cx","cy","direction","display","dominant-baseline","empty-cells","enable-background","field-sizing","fill","fill-opacity","fill-rule","filter","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","flood-color","flood-opacity","flow","font","font-display","font-family","font-feature-settings","font-kerning","font-language-override","font-optical-sizing","font-palette","font-size","font-size-adjust","font-smooth","font-smoothing","font-stretch","font-style","font-synthesis","font-synthesis-position","font-synthesis-small-caps","font-synthesis-style","font-synthesis-weight","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-emoji","font-variant-ligatures","font-variant-numeric","font-variant-position","font-variation-settings","font-weight","forced-color-adjust","gap","glyph-orientation-horizontal","glyph-orientation-vertical","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-rows","grid-column","grid-column-end","grid-column-start","grid-gap","grid-row","grid-row-end","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphenate-character","hyphenate-limit-chars","hyphens","icon","image-orientation","image-rendering","image-resolution","ime-mode","initial-letter","initial-letter-align","inline-size","inset","inset-area","inset-block","inset-block-end","inset-block-start","inset-inline","inset-inline-end","inset-inline-start","isolation","justify-content","justify-items","justify-self","kerning","left","letter-spacing","lighting-color","line-break","line-height","line-height-step","list-style","list-style-image","list-style-position","list-style-type","margin","margin-block","margin-block-end","margin-block-start","margin-bottom","margin-inline","margin-inline-end","margin-inline-start","margin-left","margin-right","margin-top","margin-trim","marker","marker-end","marker-mid","marker-start","marks","mask","mask-border","mask-border-mode","mask-border-outset","mask-border-repeat","mask-border-slice","mask-border-source","mask-border-width","mask-clip","mask-composite","mask-image","mask-mode","mask-origin","mask-position","mask-repeat","mask-size","mask-type","masonry-auto-flow","math-depth","math-shift","math-style","max-block-size","max-height","max-inline-size","max-width","min-block-size","min-height","min-inline-size","min-width","mix-blend-mode","nav-down","nav-index","nav-left","nav-right","nav-up","none","normal","object-fit","object-position","offset","offset-anchor","offset-distance","offset-path","offset-position","offset-rotate","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-anchor","overflow-block","overflow-clip-margin","overflow-inline","overflow-wrap","overflow-x","overflow-y","overlay","overscroll-behavior","overscroll-behavior-block","overscroll-behavior-inline","overscroll-behavior-x","overscroll-behavior-y","padding","padding-block","padding-block-end","padding-block-start","padding-bottom","padding-inline","padding-inline-end","padding-inline-start","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","paint-order","pause","pause-after","pause-before","perspective","perspective-origin","place-content","place-items","place-self","pointer-events","position","position-anchor","position-visibility","print-color-adjust","quotes","r","resize","rest","rest-after","rest-before","right","rotate","row-gap","ruby-align","ruby-position","scale","scroll-behavior","scroll-margin","scroll-margin-block","scroll-margin-block-end","scroll-margin-block-start","scroll-margin-bottom","scroll-margin-inline","scroll-margin-inline-end","scroll-margin-inline-start","scroll-margin-left","scroll-margin-right","scroll-margin-top","scroll-padding","scroll-padding-block","scroll-padding-block-end","scroll-padding-block-start","scroll-padding-bottom","scroll-padding-inline","scroll-padding-inline-end","scroll-padding-inline-start","scroll-padding-left","scroll-padding-right","scroll-padding-top","scroll-snap-align","scroll-snap-stop","scroll-snap-type","scroll-timeline","scroll-timeline-axis","scroll-timeline-name","scrollbar-color","scrollbar-gutter","scrollbar-width","shape-image-threshold","shape-margin","shape-outside","shape-rendering","speak","speak-as","src","stop-color","stop-opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","tab-size","table-layout","text-align","text-align-all","text-align-last","text-anchor","text-combine-upright","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-skip-ink","text-decoration-style","text-decoration-thickness","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-indent","text-justify","text-orientation","text-overflow","text-rendering","text-shadow","text-size-adjust","text-transform","text-underline-offset","text-underline-position","text-wrap","text-wrap-mode","text-wrap-style","timeline-scope","top","touch-action","transform","transform-box","transform-origin","transform-style","transition","transition-behavior","transition-delay","transition-duration","transition-property","transition-timing-function","translate","unicode-bidi","user-modify","user-select","vector-effect","vertical-align","view-timeline","view-timeline-axis","view-timeline-inset","view-timeline-name","view-transition-name","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","white-space","white-space-collapse","widows","width","will-change","word-break","word-spacing","word-wrap","writing-mode","x","y","z-index","zoom"].sort().reverse();function Ncn(n){let t=n.regex,r=xSr(n),a={begin:/-(webkit|moz|ms|o)-(?=[a-z])/},i="and or not only",s=/@-?\w[\w]*(-\w+)*/,e="[a-zA-Z-][a-zA-Z0-9_-]*",c=[n.APOS_STRING_MODE,n.QUOTE_STRING_MODE];return{name:"CSS",case_insensitive:!0,illegal:/[=|'\$]/,keywords:{keyframePosition:"from to"},classNameAliases:{keyframePosition:"selector-tag"},contains:[r.BLOCK_COMMENT,a,r.CSS_NUMBER_MODE,{className:"selector-id",begin:/#[A-Za-z0-9_-]+/,relevance:0},{className:"selector-class",begin:"\\."+e,relevance:0},r.ATTRIBUTE_SELECTOR_MODE,{className:"selector-pseudo",variants:[{begin:":("+kSr.join("|")+")"},{begin:":(:)?("+LSr.join("|")+")"}]},r.CSS_VARIABLE,{className:"attribute",begin:"\\b("+JSr.join("|")+")\\b"},{begin:/:/,end:/[;}{]/,contains:[r.BLOCK_COMMENT,r.HEXCOLOR,r.IMPORTANT,r.CSS_NUMBER_MODE,...c,{begin:/(url|data-uri)\(/,end:/\)/,relevance:0,keywords:{built_in:"url data-uri"},contains:[...c,{className:"string",begin:/[^)]/,endsWithParent:!0,excludeEnd:!0}]},r.FUNCTION_DISPATCH]},{begin:t.lookahead(/@/),end:"[{;]",relevance:0,illegal:/:/,contains:[{className:"keyword",begin:s},{begin:/\s/,endsWithParent:!0,excludeEnd:!0,relevance:0,keywords:{$pattern:/[a-z-]+/,keyword:i,attribute:XSr.join(" ")},contains:[{begin:/[a-z-]+(?=:)/,className:"attribute"},...c,r.CSS_NUMBER_MODE]}]},{className:"selector-tag",begin:"\\b("+HSr.join("|")+")\\b"}]}}function Wcn(n){let t=n.regex;return{name:"Diff",aliases:["patch"],contains:[{className:"meta",relevance:10,match:t.either(/^@@ +-\d+,\d+ +\+\d+,\d+ +@@/,/^\*\*\* +\d+,\d+ +\*\*\*\*$/,/^--- +\d+,\d+ +----$/)},{className:"comment",variants:[{begin:t.either(/Index: /,/^index/,/={3,}/,/^-{3}/,/^\*{3} /,/^\+{3}/,/^diff --git/),end:/$/},{match:/^\*{15}$/}]},{className:"addition",begin:/^\+/,end:/$/},{className:"deletion",begin:/^-/,end:/$/},{className:"addition",begin:/^!/,end:/$/}]}}function Acn(n){let s={keyword:["break","case","chan","const","continue","default","defer","else","fallthrough","for","func","go","goto","if","import","interface","map","package","range","return","select","struct","switch","type","var"],type:["bool","byte","complex64","complex128","error","float32","float64","int8","int16","int32","int64","string","uint8","uint16","uint32","uint64","int","uint","uintptr","rune"],literal:["true","false","iota","nil"],built_in:["append","cap","close","complex","copy","imag","len","make","new","panic","print","println","real","recover","delete"]};return{name:"Go",aliases:["golang"],keywords:s,illegal:"</",contains:[n.C_LINE_COMMENT_MODE,n.C_BLOCK_COMMENT_MODE,{className:"string",variants:[n.QUOTE_STRING_MODE,n.APOS_STRING_MODE,{begin:"`",end:"`"}]},{className:"number",variants:[{match:/-?\b0[xX]\.[a-fA-F0-9](_?[a-fA-F0-9])*[pP][+-]?\d(_?\d)*i?/,relevance:0},{match:/-?\b0[xX](_?[a-fA-F0-9])+((\.([a-fA-F0-9](_?[a-fA-F0-9])*)?)?[pP][+-]?\d(_?\d)*)?i?/,relevance:0},{match:/-?\b0[oO](_?[0-7])*i?/,relevance:0},{match:/-?\.\d(_?\d)*([eE][+-]?\d(_?\d)*)?i?/,relevance:0},{match:/-?\b\d(_?\d)*(\.(\d(_?\d)*)?)?([eE][+-]?\d(_?\d)*)?i?/,relevance:0}]},{begin:/:=/},{className:"function",beginKeywords:"func",end:"\\s*(\\{|$)",excludeEnd:!0,contains:[n.TITLE_MODE,{className:"params",begin:/\(/,end:/\)/,endsParent:!0,keywords:s,illegal:/["']/}]}]}}function Fcn(n){let t=n.regex,r=/[_A-Za-z][_0-9A-Za-z]*/;return{name:"GraphQL",aliases:["gql"],case_insensitive:!0,disableAutodetect:!1,keywords:{keyword:["query","mutation","subscription","type","input","schema","directive","interface","union","scalar","fragment","enum","on"],literal:["true","false","null"]},contains:[n.HASH_COMMENT_MODE,n.QUOTE_STRING_MODE,n.NUMBER_MODE,{scope:"punctuation",match:/[.]{3}/,relevance:0},{scope:"punctuation",begin:/[\!\(\)\:\=\[\]\{\|\}]{1}/,relevance:0},{scope:"variable",begin:/\$/,end:/\W/,excludeEnd:!0,relevance:0},{scope:"meta",match:/@\w+/,excludeEnd:!0},{scope:"symbol",begin:t.concat(r,t.lookahead(/\s*:/)),relevance:0}],illegal:[/[;<']/,/BEGIN/]}}function ycn(n){let t=n.regex,r={className:"number",relevance:0,variants:[{begin:/([+-]+)?[\d]+_[\d_]+/},{begin:n.NUMBER_RE}]},a=n.COMMENT();a.variants=[{begin:/;/,end:/$/},{begin:/#/,end:/$/}];let i={className:"variable",variants:[{begin:/\$[\w\d"][\w\d_]*/},{begin:/\$\{(.*?)\}/}]},s={className:"literal",begin:/\bon|off|true|false|yes|no\b/},e={className:"string",contains:[n.BACKSLASH_ESCAPE],variants:[{begin:"'''",end:"'''",relevance:10},{begin:'"""',end:'"""',relevance:10},{begin:'"',end:'"'},{begin:"'",end:"'"}]},c={begin:/\[/,end:/\]/,contains:[a,s,i,e,r,"self"],relevance:0},u=/[A-Za-z0-9_-]+/,d=/"(\\"|[^"])*"/,I=/'[^']*'/,h=t.either(u,d,I),o=t.concat(h,"(\\s*\\.\\s*",h,")*",t.lookahead(/\s*=\s*[^#\s]/));return{name:"TOML, also INI",aliases:["toml"],case_insensitive:!0,illegal:/\S/,contains:[a,{className:"section",begin:/\[+/,end:/\]+/},{begin:o,className:"attr",starts:{end:/$/,contains:[a,c,s,i,e,r]}}]}}var GB="[0-9](_*[0-9])*",Lpe=`\\.(${GB})`,Jpe="[0-9a-fA-F](_*[0-9a-fA-F])*",Rcn={className:"number",variants:[{begin:`(\\b(${GB})((${Lpe})|\\.)?|(${Lpe}))[eE][+-]?(${GB})[fFdD]?\\b`},{begin:`\\b(${GB})((${Lpe})[fFdD]?\\b|\\.([fFdD]\\b)?)`},{begin:`(${Lpe})[fFdD]?\\b`},{begin:`\\b(${GB})[fFdD]\\b`},{begin:`\\b0[xX]((${Jpe})\\.?|(${Jpe})?\\.(${Jpe}))[pP][+-]?(${GB})[fFdD]?\\b`},{begin:"\\b(0|[1-9](_*[0-9])*)[lL]?\\b"},{begin:`\\b0[xX](${Jpe})[lL]?\\b`},{begin:"\\b0(_*[0-7])*[lL]?\\b"},{begin:"\\b0[bB][01](_*[01])*[lL]?\\b"}],relevance:0};function Ecn(n,t,r){return r===-1?"":n.replace(t,a=>Ecn(n,t,r-1))}function wcn(n){let t=n.regex,r="[\xC0-\u02B8a-zA-Z_$][\xC0-\u02B8a-zA-Z_$0-9]*",a=r+Ecn("(?:<"+r+"~~~(?:\\s*,\\s*"+r+"~~~)*>)?",/~~~/g,2),u={keyword:["synchronized","abstract","private","var","static","if","const ","for","while","strictfp","finally","protected","import","native","final","void","enum","else","break","transient","catch","instanceof","volatile","case","assert","package","default","public","try","switch","continue","throws","protected","public","private","module","requires","exports","do","sealed","yield","permits","goto","when"],literal:["false","true","null"],type:["char","boolean","long","float","int","byte","short","double"],built_in:["super","this"]},d={className:"meta",begin:"@"+r,contains:[{begin:/\(/,end:/\)/,contains:["self"]}]},I={className:"params",begin:/\(/,end:/\)/,keywords:u,relevance:0,contains:[n.C_BLOCK_COMMENT_MODE],endsParent:!0};return{name:"Java",aliases:["jsp"],keywords:u,illegal:/<\/|#/,contains:[n.COMMENT("/\\*\\*","\\*/",{relevance:0,contains:[{begin:/\w+@/,relevance:0},{className:"doctag",begin:"@[A-Za-z]+"}]}),{begin:/import java\.[a-z]+\./,keywords:"import",relevance:2},n.C_LINE_COMMENT_MODE,n.C_BLOCK_COMMENT_MODE,{begin:/"""/,end:/"""/,className:"string",contains:[n.BACKSLASH_ESCAPE]},n.APOS_STRING_MODE,n.QUOTE_STRING_MODE,{match:[/\b(?:class|interface|enum|extends|implements|new)/,/\s+/,r],className:{1:"keyword",3:"title.class"}},{match:/non-sealed/,scope:"keyword"},{begin:[t.concat(/(?!else)/,r),/\s+/,r,/\s+/,/=(?!=)/],className:{1:"type",3:"variable",5:"operator"}},{begin:[/record/,/\s+/,r],className:{1:"keyword",3:"title.class"},contains:[I,n.C_LINE_COMMENT_MODE,n.C_BLOCK_COMMENT_MODE]},{beginKeywords:"new throw return else",relevance:0},{begin:["(?:"+a+"\\s+)",n.UNDERSCORE_IDENT_RE,/\s*(?=\()/],className:{2:"title.function"},keywords:u,contains:[{className:"params",begin:/\(/,end:/\)/,keywords:u,relevance:0,contains:[d,n.APOS_STRING_MODE,n.QUOTE_STRING_MODE,Rcn,n.C_BLOCK_COMMENT_MODE]},n.C_LINE_COMMENT_MODE,n.C_BLOCK_COMMENT_MODE]},Rcn,d]}}var Ycn="[A-Za-z$_][0-9A-Za-z$_]*",SSr=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends","using"],BSr=["true","false","null","undefined","NaN","Infinity"],Ccn=["Object","Function","Boolean","Symbol","Math","Date","Number","BigInt","String","RegExp","Array","Float32Array","Float64Array","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Int32Array","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array","Set","Map","WeakSet","WeakMap","ArrayBuffer","SharedArrayBuffer","Atomics","DataView","JSON","Promise","Generator","GeneratorFunction","AsyncFunction","Reflect","Proxy","Intl","WebAssembly"],xcn=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],Vcn=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],DSr=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],TSr=[].concat(Vcn,Ccn,xcn);function Qcn(n){let t=n.regex,r=(X,{after:H})=>{let Q="</"+X[0].slice(1);return X.input.indexOf(Q,H)!==-1},a=Ycn,i={begin:"<>",end:"</>"},s=/<[A-Za-z0-9\\._:-]+\s*\/>/,e={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(X,H)=>{let Q=X[0].length+X.index,V=X.input[Q];if(V==="<"||V===","){H.ignoreMatch();return}V===">"&&(r(X,{after:Q})||H.ignoreMatch());let F,x=X.input.substring(Q);if(F=x.match(/^\s*=/)){H.ignoreMatch();return}if((F=x.match(/^\s+extends\s+/))&&F.index===0){H.ignoreMatch();return}}},c={$pattern:Ycn,keyword:SSr,literal:BSr,built_in:TSr,"variable.language":DSr},u="[0-9](_?[0-9])*",d=`\\.(${u})`,I="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",h={className:"number",variants:[{begin:`(\\b(${I})((${d})|\\.)?|(${d}))[eE][+-]?(${u})\\b`},{begin:`\\b(${I})\\b((${d})\\b|\\.)?|(${d})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},o={className:"subst",begin:"\\$\\{",end:"\\}",keywords:c,contains:[]},v={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[n.BACKSLASH_ESCAPE,o],subLanguage:"xml"}},w={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[n.BACKSLASH_ESCAPE,o],subLanguage:"css"}},R={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[n.BACKSLASH_ESCAPE,o],subLanguage:"graphql"}},E={className:"string",begin:"`",end:"`",contains:[n.BACKSLASH_ESCAPE,o]},Y={className:"comment",variants:[n.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:a+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),n.C_BLOCK_COMMENT_MODE,n.C_LINE_COMMENT_MODE]},W=[n.APOS_STRING_MODE,n.QUOTE_STRING_MODE,v,w,R,E,{match:/\$\d+/},h];o.contains=W.concat({begin:/\{/,end:/\}/,keywords:c,contains:["self"].concat(W)});let y=[].concat(Y,o.contains),b=y.concat([{begin:/(\s*)\(/,end:/\)/,keywords:c,contains:["self"].concat(y)}]),f={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:c,contains:b},g={variants:[{match:[/class/,/\s+/,a,/\s+/,/extends/,/\s+/,t.concat(a,"(",t.concat(/\./,a),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,a],scope:{1:"keyword",3:"title.class"}}]},N={relevance:0,match:t.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:"title.class",keywords:{_:[...Ccn,...xcn]}},p={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},m={variants:[{match:[/function/,/\s+/,a,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[f],illegal:/%/},G={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function Z(X){return t.concat("(?!",X.join("|"),")")}let C={match:t.concat(/\b/,Z([...Vcn,"super","import"].map(X=>`${X}\\s*\\(`)),a,t.lookahead(/\s*\(/)),className:"title.function",relevance:0},O={begin:t.concat(/\./,t.lookahead(t.concat(a,/(?![0-9A-Za-z$_(])/))),end:a,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},k={match:[/get|set/,/\s+/,a,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},f]},J="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+n.UNDERSCORE_IDENT_RE+")\\s*=>",D={match:[/const|var|let/,/\s+/,a,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(J)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[f]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:c,exports:{PARAMS_CONTAINS:b,CLASS_REFERENCE:N},illegal:/#(?![$_A-z])/,contains:[n.SHEBANG({label:"shebang",binary:"node",relevance:5}),p,n.APOS_STRING_MODE,n.QUOTE_STRING_MODE,v,w,R,E,Y,{match:/\$\d+/},h,N,{scope:"attr",match:a+t.lookahead(":"),relevance:0},D,{begin:"("+n.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[Y,n.REGEXP_MODE,{className:"function",begin:J,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:n.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:c,contains:b}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:i.begin,end:i.end},{match:s},{begin:e.begin,"on:begin":e.isTrulyOpeningTag,end:e.end}],subLanguage:"xml",contains:[{begin:e.begin,end:e.end,skip:!0,contains:["self"]}]}]},m,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+n.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[f,n.inherit(n.TITLE_MODE,{begin:a,className:"title.function"})]},{match:/\.\.\./,relevance:0},O,{match:"\\$"+a,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[f]},C,G,g,k,{match:/\$[(.]/}]}}function Hcn(n){let t={className:"attr",begin:/"(\\.|[^\\"\r\n])*"(?=\s*:)/,relevance:1.01},r={match:/[{}[\],:]/,className:"punctuation",relevance:0},a=["true","false","null"],i={scope:"literal",beginKeywords:a.join(" ")};return{name:"JSON",aliases:["jsonc"],keywords:{literal:a},contains:[t,r,n.QUOTE_STRING_MODE,i,n.C_NUMBER_MODE,n.C_LINE_COMMENT_MODE,n.C_BLOCK_COMMENT_MODE],illegal:"\\S"}}var fB="[0-9](_*[0-9])*",Spe=`\\.(${fB})`,Bpe="[0-9a-fA-F](_*[0-9a-fA-F])*",OSr={className:"number",variants:[{begin:`(\\b(${fB})((${Spe})|\\.)?|(${Spe}))[eE][+-]?(${fB})[fFdD]?\\b`},{begin:`\\b(${fB})((${Spe})[fFdD]?\\b|\\.([fFdD]\\b)?)`},{begin:`(${Spe})[fFdD]?\\b`},{begin:`\\b(${fB})[fFdD]\\b`},{begin:`\\b0[xX]((${Bpe})\\.?|(${Bpe})?\\.(${Bpe}))[pP][+-]?(${fB})[fFdD]?\\b`},{begin:"\\b(0|[1-9](_*[0-9])*)[lL]?\\b"},{begin:`\\b0[xX](${Bpe})[lL]?\\b`},{begin:"\\b0(_*[0-7])*[lL]?\\b"},{begin:"\\b0[bB][01](_*[01])*[lL]?\\b"}],relevance:0};function Xcn(n){let t={keyword:"abstract as val var vararg get set class object open private protected public noinline crossinline dynamic final enum if else do while for when throw try catch finally import package is in fun override companion reified inline lateinit init interface annotation data sealed internal infix operator out by constructor super tailrec where const inner suspend typealias external expect actual",built_in:"Byte Short Char Int Long Boolean Float Double Void Unit Nothing",literal:"true false null"},r={className:"keyword",begin:/\b(break|continue|return|this)\b/,starts:{contains:[{className:"symbol",begin:/@\w+/}]}},a={className:"symbol",begin:n.UNDERSCORE_IDENT_RE+"@"},i={className:"subst",begin:/\$\{/,end:/\}/,contains:[n.C_NUMBER_MODE]},s={className:"variable",begin:"\\$"+n.UNDERSCORE_IDENT_RE},e={className:"string",variants:[{begin:'"""',end:'"""(?=[^"])',contains:[s,i]},{begin:"'",end:"'",illegal:/\n/,contains:[n.BACKSLASH_ESCAPE]},{begin:'"',end:'"',illegal:/\n/,contains:[n.BACKSLASH_ESCAPE,s,i]}]};i.contains.push(e);let c={className:"meta",begin:"@(?:file|property|field|get|set|receiver|param|setparam|delegate)\\s*:(?:\\s*"+n.UNDERSCORE_IDENT_RE+")?"},u={className:"meta",begin:"@"+n.UNDERSCORE_IDENT_RE,contains:[{begin:/\(/,end:/\)/,contains:[n.inherit(e,{className:"string"}),"self"]}]},d=OSr,I=n.COMMENT("/\\*","\\*/",{contains:[n.C_BLOCK_COMMENT_MODE]}),h={variants:[{className:"type",begin:n.UNDERSCORE_IDENT_RE},{begin:/\(/,end:/\)/,contains:[]}]},o=h;return o.variants[1].contains=[h],h.variants[1].contains=[o],{name:"Kotlin",aliases:["kt","kts"],keywords:t,contains:[n.COMMENT("/\\*\\*","\\*/",{relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"}]}),n.C_LINE_COMMENT_MODE,I,r,a,c,u,{className:"function",beginKeywords:"fun",end:"[(]|$",returnBegin:!0,excludeEnd:!0,keywords:t,relevance:5,contains:[{begin:n.UNDERSCORE_IDENT_RE+"\\s*\\(",returnBegin:!0,relevance:0,contains:[n.UNDERSCORE_TITLE_MODE]},{className:"type",begin:/</,end:/>/,keywords:"reified",relevance:0},{className:"params",begin:/\(/,end:/\)/,endsParent:!0,keywords:t,relevance:0,contains:[{begin:/:/,end:/[=,\/]/,endsWithParent:!0,contains:[h,n.C_LINE_COMMENT_MODE,I],relevance:0},n.C_LINE_COMMENT_MODE,I,c,u,e,n.C_NUMBER_MODE]},I]},{begin:[/class|interface|trait/,/\s+/,n.UNDERSCORE_IDENT_RE],beginScope:{3:"title.class"},keywords:"class interface trait",end:/[:\{(]|$/,excludeEnd:!0,illegal:"extends implements",contains:[{beginKeywords:"public protected internal private constructor"},n.UNDERSCORE_TITLE_MODE,{className:"type",begin:/</,end:/>/,excludeBegin:!0,excludeEnd:!0,relevance:0},{className:"type",begin:/[,:]\s*/,end:/[<\(,){\s]|$/,excludeBegin:!0,returnEnd:!0},c,u]},e,{className:"meta",begin:"^#!/usr/bin/env",end:"$",illegal:`
@@ -4967,15 +4967,15 @@ ${h}`),e(!1)):(i("\u2705 \u8BA4\u8BC1\u670D\u52A1\u5668\u5DF2\u542F\u52A8\uFF01\
4967
4967
 
4968
4968
  `))}catch(n){dl.error(S2(n)),process.exit(1)}}var H0n={command:"list",describe:"Lists installed extensions.",builder:n=>n,handler:async()=>{await CDr(),process.exit(0)}};Ru();async function xDr(n){try{let t={source:n.path,type:"link"},r=process.cwd(),a=new Af({workspaceDir:r,requestConsent:AN,requestSetting:FN,settings:uf(r).merged});await a.loadExtensions();let i=await a.installOrUpdateExtension(t);dl.log(`Extension "${i.config.name}" linked successfully and enabled.`)}catch(t){dl.error(S2(t)),process.exit(1)}}var X0n={command:"link <path>",describe:"Links an extension from a local path. Updates made to the local path will always be reflected.",builder:n=>n.positional("path",{describe:"The name of the extension to link.",type:"string"}).check(t=>!0),handler:async n=>{await xDr({path:n.path})}};import{access as VDr,cp as QDr,mkdir as HDr,readdir as k0n,writeFile as XDr}from"node:fs/promises";import{join as FK,dirname as kDr,basename as LDr}from"node:path";import{fileURLToPath as JDr}from"node:url";var SDr=JDr(import.meta.url),BDr=kDr(SDr),L0n=FK(BDr,"examples");async function DDr(n){try{return await VDr(n),!0}catch{return!1}}async function J0n(n){if(await DDr(n))throw new Error(`Path already exists: ${n}`);await HDr(n,{recursive:!0})}async function TDr(n,t){await J0n(t);let r=FK(L0n,n),a=await k0n(r,{withFileTypes:!0});for(let i of a){let s=FK(r,i.name),e=FK(t,i.name);await QDr(s,e,{recursive:!0})}}async function ODr(n){if(n.template)await TDr(n.template,n.path),dl.log(`Successfully created new extension from template "${n.template}" at ${n.path}.`);else{await J0n(n.path);let r={name:LDr(n.path),version:"1.0.0"};await XDr(FK(n.path,"gemini-extension.json"),JSON.stringify(r,null,2)),dl.log(`Successfully created new extension at ${n.path}.`)}dl.log(`You can install this using "gemini extensions link ${n.path}" to test it out.`)}async function UDr(){return(await k0n(L0n,{withFileTypes:!0})).filter(t=>t.isDirectory()).map(t=>t.name)}var S0n={command:"new <path> [template]",describe:"Create a new extension from a boilerplate example.",builder:async n=>{let t=await UDr();return n.positional("path",{describe:"The path to create the extension in.",type:"string"}).positional("template",{describe:"The boilerplate template to use.",type:"string",choices:t})},handler:async n=>{await ODr({path:n.path,template:n.template})}};var bmn=Dt(mmn(),1);import*as pmn from"node:fs";import*as pTe from"node:path";Ru();async function bUr(n){try{await GUr(n),dl.log(`Extension ${n.path} has been successfully validated.`)}catch(t){dl.error(S2(t)),process.exit(1)}}async function GUr(n){let t=process.cwd(),r=new Af({workspaceDir:t,requestConsent:AN,requestSetting:FN,settings:uf(t).merged}),a=pTe.resolve(n.path),i=r.loadExtensionConfig(a),s=[],e=[];if(i.contextFileName){let c=Array.isArray(i.contextFileName)?i.contextFileName:[i.contextFileName],u=[];for(let d of c){let I=pTe.resolve(a,d);pmn.existsSync(I)||u.push(d)}u.length>0&&e.push(`The following context files referenced in gemini-extension.json are missing: ${u}`)}if(bmn.default.valid(i.version)||s.push(`Warning: Version '${i.version}' does not appear to be standard semver (e.g., 1.0.0).`),s.length>0){dl.warn("Validation warnings:");for(let c of s)dl.warn(` - ${c}`)}if(e.length>0){dl.error("Validation failed with the following errors:");for(let c of e)dl.error(` - ${c}`);throw new Error("Extension validation failed.")}}var Gmn={command:"validate <path>",describe:"Validates an extension from a local path.",builder:n=>n.positional("path",{describe:"The path of the extension to validate.",type:"string",demandOption:!0}),handler:async n=>{await bUr({path:n.path})}};var fmn={command:"extensions",aliases:["extension"],describe:"Manage dvcode extensions.",builder:n=>n.command(V0n).command(Q0n).command(H0n).command(X0n).command(S0n).command(Gmn).demandCommand(1,"You need at least one command before continuing.").version(!1).help(),handler:()=>{}};Nr();import*as V2e from"fs/promises";Wr();import*as CK from"fs/promises";import*as bTe from"path";import*as gmn from"os";function x2e(){return bTe.join(gmn.homedir(),Jg,"history")}async function xK(n){let t=0;try{let r=await CK.readdir(n,{withFileTypes:!0});for(let a of r){let i=bTe.join(n,a.name);if(a.isDirectory())t+=await xK(i);else if(a.isFile()){let s=await CK.stat(i);t+=s.size}}}catch{}return t}function XB(n){if(n===0)return"0 B";let t=["B","KB","MB","GB","TB"],r=1024,a=Math.floor(Math.log(n)/Math.log(r));return`${(n/Math.pow(r,a)).toFixed(2)} ${t[a]}`}async function vmn(n){try{return(await CK.readdir(n,{withFileTypes:!0})).filter(r=>r.isDirectory()).length}catch{return 0}}var Zmn={command:"clean",describe:Ke("checkpoint.clean.description"),builder:n=>n.option("force",{alias:"f",type:"boolean",description:Ke("checkpoint.clean.force.description"),default:!1}).option("dry-run",{type:"boolean",description:Ke("checkpoint.clean.dryrun.description"),default:!1}),handler:async n=>{let t=x2e(),r=n.force,a=n["dry-run"];try{try{await V2e.access(t)}catch{console.log(Ke("checkpoint.clean.no.history")),process.exit(0)}let i=await xK(t),s=await vmn(t);if(s===0&&(console.log(Ke("checkpoint.clean.no.checkpoints")),process.exit(0)),console.log(ln("checkpoint.clean.summary",{count:s.toString(),size:XB(i),path:t})),a&&(console.log(Ke("checkpoint.clean.dryrun.notice")),process.exit(0)),!r){let c=(await import("readline")).createInterface({input:process.stdin,output:process.stdout}),u=await new Promise(d=>{c.question(Ke("checkpoint.clean.confirm"),I=>{c.close(),d(I.toLowerCase().trim())})});u!=="y"&&u!=="yes"&&(console.log(Ke("checkpoint.clean.cancelled")),process.exit(0))}console.log(Ke("checkpoint.clean.deleting")),await V2e.rm(t,{recursive:!0,force:!0}),console.log(ln("checkpoint.clean.success",{size:XB(i)})),process.exit(0)}catch(i){console.error(ln("checkpoint.clean.error",{error:i instanceof Error?i.message:String(i)})),process.exit(1)}}};Nr();var Nmn={command:"checkpoint",aliases:["cp"],describe:Ke("checkpoint.command.description"),builder:n=>n.command(Zmn).demandCommand(1,Ke("checkpoint.command.require.subcommand")).version(!1).help(),handler:()=>{}};import*as VK from"fs";import*as GTe from"path";import{pathToFileURL as fUr}from"url";var Wmn="cli-commands.json";async function gUr(n){if(!n.path)return[];let t=GTe.join(n.path,Wmn);if(!VK.existsSync(t))return[];try{let r=VK.readFileSync(t,"utf-8"),a=JSON.parse(r);if(!Array.isArray(a))return console.warn(`Warning: ${Wmn} in extension ${n.config.name} should contain an array of commands`),[];let i=[];for(let s of a)try{let e=GTe.join(n.path,s.module);if(!VK.existsSync(e)){console.warn(`Warning: Extension command module not found: ${e}`);continue}let c=await import(fUr(e).href),u=c.default||c.command;if(!u){console.warn(`Warning: Extension command module ${e} does not export a default command`);continue}i.push({extension:n,command:u,config:s})}catch(e){console.error(`Error loading command ${s.name} from extension ${n.config.name}:`,e)}return i}catch(r){return console.warn(`Warning: failed to load commands from extension ${n.config.name}:`,r),[]}}async function Amn(n){let t=[];for(let r of n){let a=await gUr(r);t.push(...a)}return t}function Fmn(n,t){for(let{command:r,config:a}of t){if(!a.name){console.warn("Extension command missing name, skipping");continue}let i=r.command||a.name;n.command(r),t.length>0&&console.log(`[Extension Commands] Registered command: ${i} from ${a.name||"unknown"}`)}return n}var Q2e={debug:(...n)=>console.debug("[DEBUG]",...n),warn:(...n)=>console.warn("[WARN]",...n),error:(...n)=>console.error("[ERROR]",...n)};async function fTe(n=[]){let t=Udn(DDe(K0.argv)).scriptName("deepv").usage("$0 [options]","DeepV Code - Launch an interactive CLI, use -p/--prompt for non-interactive mode").option("model",{alias:"m",type:"string",description:"Model",default:K0.env.GEMINI_MODEL}).option("prompt",{alias:"p",type:"string",description:"Prompt. Appended to input on stdin (if any)."}).option("prompt-interactive",{alias:"i",type:"string",description:"Execute the provided prompt and continue in interactive mode"}).option("sandbox",{alias:"s",type:"boolean",description:"Run in sandbox?"}).option("sandbox-image",{type:"string",description:"Sandbox image URI."}).option("debug",{alias:"d",type:"boolean",description:"Run in debug mode?",default:!1}).option("all-files",{alias:["a"],type:"boolean",description:"Include ALL files in context?",default:!1}).option("all_files",{type:"boolean",description:"Include ALL files in context?",default:!1}).deprecateOption("all_files","Use --all-files instead. We will be removing --all_files in the coming weeks.").option("show-memory-usage",{type:"boolean",description:"Show memory usage in status bar",default:!1}).option("show_memory_usage",{type:"boolean",description:"Show memory usage in status bar",default:!1}).deprecateOption("show_memory_usage","Use --show-memory-usage instead. We will be removing --show_memory_usage in the coming weeks.").option("yolo",{alias:"y",type:"boolean",description:"Automatically accept all actions (aka YOLO mode, see https://www.youtube.com/watch?v=xvFZjo5PgG0 for more details)?",default:!1}).option("telemetry",{type:"boolean",description:"Enable telemetry? This flag specifically controls if telemetry is sent. Other --telemetry-* flags set specific values but do not enable telemetry on their own."}).option("telemetry-target",{type:"string",choices:["local","gcp"],description:"Set the telemetry target (local or gcp). Overrides settings files."}).option("telemetry-otlp-endpoint",{type:"string",description:"Set the OTLP endpoint for telemetry. Overrides environment variables and settings files."}).option("telemetry-log-prompts",{type:"boolean",description:"Enable or disable logging of user prompts for telemetry. Overrides settings files."}).option("telemetry-outfile",{type:"string",description:"Redirect all telemetry output to the specified file."}).option("checkpointing",{type:"boolean",description:"Enables checkpointing of file edits",default:!1}).option("experimental-acp",{type:"boolean",description:"Starts the agent in ACP mode"}).option("allowed-mcp-server-names",{type:"array",string:!0,description:"Allowed MCP server names"}).option("extensions",{alias:"e",type:"array",string:!0,description:"A list of extensions to use. If not provided, all extensions are used."}).option("list-extensions",{alias:"l",type:"boolean",description:"List all available extensions and exit."}).option("ide-mode",{type:"boolean",description:"Run in IDE mode?"}).option("proxy",{type:"string",description:"Proxy for DeepV Code client, like schema://user:password@host:port"}).option("update",{alias:"u",type:"boolean",description:"Force check for updates and prompt to install if available",default:!1}).option("continue",{alias:"c",type:"boolean",description:"Continue from the last active session",default:!1}).option("session",{type:"string",description:"Resume a specific session by ID"}).option("list-sessions",{type:"boolean",description:"List all available sessions with their timestamps and exit",default:!1}).option("export-session",{type:"string",description:"Export a specific session history to a Markdown file and exit"}).option("cloud-mode",{type:"boolean",description:"Connect to cloud server for remote access",default:!1}).option("cloud-server",{type:"string",description:"Cloud server URL for cloud mode",default:"https://api-code.deepvlab.ai"}).option("test-audio",{type:"boolean",description:"Test audio notification sounds and exit",default:!1}).option("workdir",{type:"string",description:"Specify the working directory (supports both Windows and Unix paths)"}).option("output-format",{type:"string",choices:["stream-json","default"],description:"Output format for non-interactive mode (stream-json for streaming line-delimited JSON)",default:"default"}).command(fmn).command(Nmn);if(n.length>0){let a=await Amn(n);a.length>0&&Fmn(t,a)}t.version(await ES()).alias("v","version").help().alias("h","help").strict().check(a=>{if(a.prompt&&a.promptInteractive)throw new Error("Cannot use both --prompt (-p) and --prompt-interactive (-i) together");return!0}),t.wrap(t.terminalWidth());let r=t.argv;if(r.outputFormat&&!["stream-json","default"].includes(r.outputFormat)&&(r.outputFormat="default"),!r.prompt&&!r.promptInteractive){let a="";if(r._&&r._.length>0&&(a=r._.join(" ").trim()),!a){let i=K0.argv.slice(2);for(let s=i.length-1;s>=0;s--){let e=i[s];if(!e.startsWith("-")&&!e.startsWith("--")){if(s>0){let c=i[s-1];if(["--model","-m","--output-format","--sandbox-image","--prompt","-p","--prompt-interactive","-i","--workdir","--telemetry-target","--telemetry-otlp-endpoint","--telemetry-outfile","--allowed-mcp-server-names","--extensions","-e","--session","--cloud-server","--proxy"].includes(c))continue}a=e;break}}}a.length>0&&(r.prompt=a)}return r}async function gTe(n,t,r,a,i=[],s){return t&&Q2e.debug(`CLI: Delegating hierarchical memory load to server for CWD: ${n}`),IS(n,t,r,i,s,a.memoryDiscoveryMaxDirs)}async function H2e(n,t,r,a){let i=!!(a.prompt&&!a.promptInteractive)||K0.env.DEEPV_SILENT_MODE==="true",s=!1,e=K0.env.TERM_PROGRAM==="vscode"&&!K0.env.SANDBOX,c=e&&a.ideMode!==!1,u;e&&(u=new PP);let d=m0n(t,a.extensions||[]),I=t.filter((g,N)=>d[N].isActive);n.contextFileName?PL(n.contextFileName):PL(E_());let h=I.flatMap(g=>g.contextFiles),o=new Fx(K0.cwd()),v={...lS,...n.fileFiltering},{memoryContent:w,fileCount:R,filePaths:E}=await gTe(K0.cwd(),s,o,n,h,v);E.length>0&&s&&(Q2e.debug(`Loaded ${R} memory file(s):`),E.forEach(g=>{Q2e.debug(` - ${g}`)}));let A=vUr(n,I),Y=ZUr(n,I),W=[];if(!a.allowedMcpServerNames){if(n.allowMCPServers){let g=new Set(n.allowMCPServers.filter(Boolean));g.size>0&&(A=Object.fromEntries(Object.entries(A).filter(([N])=>g.has(N))))}if(n.excludeMCPServers){let g=new Set(n.excludeMCPServers.filter(Boolean));g.size>0&&(A=Object.fromEntries(Object.entries(A).filter(([N])=>!g.has(N))))}}if(a.allowedMcpServerNames){let g=new Set(a.allowedMcpServerNames.filter(Boolean));g.size>0?A=Object.fromEntries(Object.entries(A).filter(([N,p])=>{let m=g.has(N);return m||W.push({name:N,extensionName:p.extensionName||""}),m})):(W.push(...Object.entries(A).map(([N,p])=>({name:N,extensionName:p.extensionName||""}))),A={})}let y=await y0n(n,a),b=0;try{b=mR("cl100k_base").encode(w).length}catch{b=0}let f=new TP({sessionId:r,embeddingModel:qL,sandbox:y,targetDir:K0.cwd(),debugMode:s,question:a.promptInteractive||a.prompt||"",fullContext:a.allFiles||a.all_files||!1,coreTools:n.coreTools||void 0,excludeTools:Y,toolDiscoveryCommand:n.toolDiscoveryCommand,toolCallCommand:n.toolCallCommand,mcpServerCommand:n.mcpServerCommand,mcpServers:A,userMemory:w,memoryTokenCount:b,geminiMdFileCount:R,approvalMode:a.yolo?Ja.YOLO:Ja.DEFAULT,showMemoryUsage:a.showMemoryUsage||a.show_memory_usage||n.showMemoryUsage||!1,accessibility:n.accessibility,telemetry:{enabled:!1,target:a.telemetryTarget??n.telemetry?.target,otlpEndpoint:a.telemetryOtlpEndpoint??K0.env.OTEL_EXPORTER_OTLP_ENDPOINT??n.telemetry?.otlpEndpoint,logPrompts:!1,outfile:a.telemetryOutfile??n.telemetry?.outfile},usageStatisticsEnabled:!1,fileFiltering:{respectGitIgnore:n.fileFiltering?.respectGitIgnore,respectGeminiIgnore:n.fileFiltering?.respectGeminiIgnore,enableRecursiveFileSearch:n.fileFiltering?.enableRecursiveFileSearch},checkpointing:a.checkpointing||n.checkpointing?.enabled||K0.env.ENABLE_CHECKPOINTING!=="false",proxy:a.proxy||K0.env.HTTPS_PROXY||K0.env.https_proxy||K0.env.HTTP_PROXY||K0.env.http_proxy,customProxyServerUrl:n.customProxyServerUrl,cwd:K0.cwd(),fileDiscoveryService:o,bugCommand:n.bugCommand,model:a.model||n.preferredModel,extensionContextFilePaths:h,maxSessionTurns:n.maxSessionTurns??-1,experimentalAcp:a.experimentalAcp||!1,listExtensions:a.listExtensions||!1,listSessions:a.listSessions||!1,extensions:d,blockedMcpServers:W,noBrowser:!!K0.env.NO_BROWSER,summarizeToolOutput:n.summarizeToolOutput,cloudModels:n.cloudModels,ideMode:c,ideClient:u,silentMode:i,hooks:n.hooks});return f.setGeminiMdFilePaths(E),f}function vUr(n,t){let r={...n.mcpServers||{}};for(let a of t)Object.entries(a.config.mcpServers||{}).forEach(([i,s])=>{if(r[i]){Q2e.warn(`Skipping extension MCP config for server with key "${i}" as it already exists.`);return}let e={...s};a.path&&(e.args&&(e.args=e.args.map(c=>c.replace(/\$\{extensionPath\}/g,a.path))),e.command&&(e.command=e.command.replace(/\$\{extensionPath\}/g,a.path))),r[i]={...e,extensionName:a.config.name}});return r}function ZUr(n,t){let r=new Set(n.excludeTools||[]);for(let a of t)for(let i of a.config.excludeTools||[])r.add(i);return[...r]}import NUr from"util";var X2e=class{originalConsoleLog=console.log;originalConsoleWarn=console.warn;originalConsoleError=console.error;originalConsoleDebug=console.debug;params;constructor(t){this.params=t}patch(){console.log=this.patchConsoleMethod("log",this.originalConsoleLog),console.warn=this.patchConsoleMethod("warn",this.originalConsoleWarn),console.error=this.patchConsoleMethod("error",this.originalConsoleError),console.debug=this.patchConsoleMethod("debug",this.originalConsoleDebug)}cleanup=()=>{console.log=this.originalConsoleLog,console.warn=this.originalConsoleWarn,console.error=this.originalConsoleError,console.debug=this.originalConsoleDebug};formatArgs=t=>NUr.format(...t);patchConsoleMethod=(t,r)=>(...a)=>{this.params.debugMode&&r.apply(console,a),(t!=="debug"||this.params.debugMode)&&this.params.onNewMessage({type:t,content:this.formatArgs(a),count:1})}};Nr();var Bs=Dt(Xn(),1);var ymn=({tokenUsage:n,inputWidth:t,cumulativeCredits:r})=>{let a=Io();if(!n||a.sizeLevel!=="normal")return null;let{cache_creation_input_tokens:i=0,cache_read_input_tokens:s=0,input_tokens:e=0,output_tokens:c=0,credits_usage:u=0,model:d}=n,I=i>0||s>0,h=e>0?s/e*100:0,o=e+c;return(0,Bs.jsxs)(Gt,{borderStyle:"round",borderColor:pt.Gray,paddingX:2,paddingY:0,marginBottom:1,flexDirection:"column",width:Math.min(t,80),children:[(0,Bs.jsx)(Gt,{justifyContent:"space-between",marginBottom:0,children:(0,Bs.jsx)(rt,{color:pt.Gray,children:Ke("token.usage")})}),(0,Bs.jsxs)(Gt,{justifyContent:"space-between",children:[(0,Bs.jsxs)(Gt,{flexDirection:"row",children:[(0,Bs.jsx)(rt,{color:pt.AccentYellow,children:Ke("token.input")}),(0,Bs.jsx)(rt,{children:e.toLocaleString()})]}),(0,Bs.jsxs)(Gt,{flexDirection:"row",children:[(0,Bs.jsx)(rt,{color:pt.AccentBlue,children:Ke("token.output")}),(0,Bs.jsx)(rt,{children:c.toLocaleString()})]}),(0,Bs.jsxs)(Gt,{flexDirection:"row",children:[(0,Bs.jsx)(rt,{color:pt.Gray,children:Ke("token.total")}),(0,Bs.jsx)(rt,{children:o.toLocaleString()})]}),u>0||r&&r>0?(0,Bs.jsxs)(Gt,{flexDirection:"row",children:[(0,Bs.jsx)(rt,{color:pt.AccentPurple,children:Ke("token.credits")}),(0,Bs.jsx)(rt,{children:(r||u||0).toLocaleString()})]}):null]}),I&&(0,Bs.jsxs)(Gt,{justifyContent:"space-between",marginTop:0,children:[(0,Bs.jsxs)(Gt,{flexDirection:"row",children:[(0,Bs.jsx)(rt,{color:pt.AccentGreen,children:Ke("token.cache.read")}),(0,Bs.jsx)(rt,{children:s.toLocaleString()})]}),i>0&&(0,Bs.jsxs)(Gt,{flexDirection:"row",children:[(0,Bs.jsx)(rt,{color:pt.AccentPurple,children:Ke("token.cache.create")}),(0,Bs.jsx)(rt,{children:i.toLocaleString()})]}),h>0&&(0,Bs.jsxs)(Gt,{flexDirection:"row",children:[(0,Bs.jsx)(rt,{color:pt.AccentGreen,children:Ke("token.efficiency")}),(0,Bs.jsxs)(rt,{children:[h.toFixed(1),"%"]})]})]}),!I&&s===0&&(0,Bs.jsx)(Gt,{children:(0,Bs.jsx)(rt,{color:pt.Gray,dimColor:!0,children:Ke("token.no.cache")})})]})};Wr();var Zpn=Dt(mr(),1);XE();var WV=Dt(Xn(),1);var Rmn=({text:n,terminalWidth:t})=>{let i="\u{1F9D1}\u{1F4AC}",c=Math.max((t||80)-4-8,40),u=Math.max(c-2-6,20),d=n;qsn(n,20)&&(d=eon(n,15)),d=$sn(d,u);let I=d.split(`
4969
4969
  `),h=pt.type==="dark",o=h?"#585858":"#E8E8E8",v=h?"#FFFFFF":"#404040",w=h?"#FFFFFF":"#303030",E=I.map((A,Y)=>{let W=Y===0?"> ":" ".repeat(2),y=A||" ";return Ns.hex(Y===0?w:v).bgHex(o)(W)+Ns.hex(v).bgHex(o)(y)}).join(`
4970
- `);return(0,WV.jsxs)(Gt,{flexDirection:"row",width:"100%",children:[(0,WV.jsx)(Gt,{paddingX:2,paddingY:0,marginY:1,alignSelf:"flex-start",flexShrink:1,children:(0,WV.jsx)(rt,{children:E})}),t&&(0,WV.jsx)(Gt,{flexGrow:1,justifyContent:"flex-end",alignItems:"flex-start",marginY:1,children:(0,WV.jsx)(rt,{children:i})})]})};var MR=Dt(Xn(),1);var Emn=({text:n,terminalWidth:t})=>{let r=n.startsWith("!")?n.substring(1):n;return(0,MR.jsxs)(Gt,{flexDirection:"row",width:"100%",children:[(0,MR.jsxs)(Gt,{flexShrink:1,children:[(0,MR.jsx)(rt,{color:pt.AccentCyan,children:"$ "}),(0,MR.jsx)(rt,{children:r})]}),t&&(0,MR.jsx)(Gt,{flexGrow:1,justifyContent:"flex-end",alignItems:"center",children:(0,MR.jsx)(rt,{children:"\u{1F9D1}\u{1F4AC}"})})]})};var JB=Dt(mr(),1);Nr();var RTe=Dt(mr(),1);var Bmn=Dt(mr(),1);var WTe=Dt(mr(),1);var FV=Dt(d7e(),1);var wmn=process.env.TERM_PROGRAM==="Apple_Terminal",Hl={};Hl.cursorTo=(n,t)=>{if(typeof n!="number")throw new TypeError("The `x` argument is required");return typeof t!="number"?"\x1B["+(n+1)+"G":"\x1B["+(t+1)+";"+(n+1)+"H"};Hl.cursorMove=(n,t)=>{if(typeof n!="number")throw new TypeError("The `x` argument is required");let r="";return n<0?r+="\x1B["+-n+"D":n>0&&(r+="\x1B["+n+"C"),t<0?r+="\x1B["+-t+"A":t>0&&(r+="\x1B["+t+"B"),r};Hl.cursorUp=(n=1)=>"\x1B["+n+"A";Hl.cursorDown=(n=1)=>"\x1B["+n+"B";Hl.cursorForward=(n=1)=>"\x1B["+n+"C";Hl.cursorBackward=(n=1)=>"\x1B["+n+"D";Hl.cursorLeft="\x1B[G";Hl.cursorSavePosition=wmn?"\x1B7":"\x1B[s";Hl.cursorRestorePosition=wmn?"\x1B8":"\x1B[u";Hl.cursorGetPosition="\x1B[6n";Hl.cursorNextLine="\x1B[E";Hl.cursorPrevLine="\x1B[F";Hl.cursorHide="\x1B[?25l";Hl.cursorShow="\x1B[?25h";Hl.eraseLines=n=>{let t="";for(let r=0;r<n;r++)t+=Hl.eraseLine+(r<n-1?Hl.cursorUp():"");return n&&(t+=Hl.cursorLeft),t};Hl.eraseEndLine="\x1B[K";Hl.eraseStartLine="\x1B[1K";Hl.eraseLine="\x1B[2K";Hl.eraseDown="\x1B[J";Hl.eraseUp="\x1B[1J";Hl.eraseScreen="\x1B[2J";Hl.scrollUp="\x1B[S";Hl.scrollDown="\x1B[T";Hl.clearScreen="\x1Bc";Hl.clearTerminal=process.platform==="win32"?`${Hl.eraseScreen}\x1B[0f`:`${Hl.eraseScreen}\x1B[3J\x1B[H`;Hl.beep="\x07";Hl.link=(n,t)=>["\x1B]","8",";",";",t,"\x07",n,"\x1B]","8",";",";","\x07"].join("");Hl.image=(n,t={})=>{let r="\x1B]1337;File=inline=1";return t.width&&(r+=`;width=${t.width}`),t.height&&(r+=`;height=${t.height}`),t.preserveAspectRatio===!1&&(r+=";preserveAspectRatio=0"),r+":"+n.toString("base64")+"\x07"};Hl.iTerm={setCwd:(n=process.cwd())=>`\x1B]50;CurrentDir=${n}\x07`,annotation:(n,t={})=>{let r="\x1B]1337;",a=typeof t.x<"u",i=typeof t.y<"u";if((a||i)&&!(a&&i&&typeof t.length<"u"))throw new Error("`x`, `y` and `length` must be defined when `x` or `y` is defined");return n=n.replace(/\|/g,""),r+=t.isHidden?"AddHiddenAnnotation=":"AddAnnotation=",t.length>0?r+=(a?[n,t.length,t.x,t.y]:[t.length,n]).join("|"):r+=n,r+"\x07"}};var Ymn=Hl;var k2e=Dt(Xmn(),1);function AV(n,t,{target:r="stdout",...a}={}){return k2e.default[r]?Ymn.link(n,t):a.fallback===!1?n:typeof a.fallback=="function"?a.fallback(n,t):`${n} (\u200B${t}\u200B)`}AV.isSupported=k2e.default.stdout;AV.stderr=(n,t,r={})=>AV(n,t,{target:"stderr",...r});AV.stderr.isSupported=k2e.default.stderr;var kmn=({children:n,url:t,fallback:r=!0})=>WTe.default.createElement(i9,{transform:a=>AV(a,t,{fallback:r})},WTe.default.createElement(rt,null,n));kmn.propTypes={children:FV.default.oneOfType([FV.default.arrayOf(FV.default.node),FV.default.node]).isRequired,url:FV.default.string.isRequired,fallback:FV.default.bool};var Lmn=kmn;var B2=Dt(Xn(),1);var ATe=2,FTe=1,yTe=2,yUr=1,Jmn=3,Smn=4,RUr=({text:n})=>{let t=[],r=0,a=/(\*\*.*?\*\*|\*.*?\*|_.*?_|~~.*?~~|\[.*?\]\(.*?\)|`+.+?`+|<u>.*?<\/u>)/g,i;for(;(i=a.exec(n))!==null;){i.index>r&&t.push((0,B2.jsx)(rt,{children:n.slice(r,i.index)},`t-${r}`));let s=i[0],e=null,c=`m-${i.index}`;try{if(s.startsWith("**")&&s.endsWith("**")&&s.length>ATe*2)e=(0,B2.jsx)(rt,{bold:!0,children:s.slice(ATe,-ATe)},c);else if(s.length>FTe*2&&(s.startsWith("*")&&s.endsWith("*")||s.startsWith("_")&&s.endsWith("_"))&&!/\w/.test(n.substring(i.index-1,i.index))&&!/\w/.test(n.substring(a.lastIndex,a.lastIndex+1))&&!/\S[./\\]/.test(n.substring(i.index-2,i.index))&&!/[./\\]\S/.test(n.substring(a.lastIndex,a.lastIndex+2)))e=(0,B2.jsx)(rt,{italic:!0,children:s.slice(FTe,-FTe)},c);else if(s.startsWith("~~")&&s.endsWith("~~")&&s.length>yTe*2)e=(0,B2.jsx)(rt,{strikethrough:!0,children:s.slice(yTe,-yTe)},c);else if(s.startsWith("`")&&s.endsWith("`")&&s.length>yUr){let u=s.match(/^(`+)(.+?)\1$/s);u&&u[2]&&(e=(0,B2.jsx)(rt,{color:pt.AccentPurple,children:u[2]},c))}else if(s.startsWith("[")&&s.includes("](")&&s.endsWith(")")){let u=s.match(/\[(.*?)\]\((.*?)\)/);if(u){let d=u[1],I=u[2],h=d.replace(/^https?:\/\//,"").replace(/\/$/,""),o=I.replace(/^https?:\/\//,"").replace(/\/$/,""),v=h===o||I===d;e=(0,B2.jsx)(Lmn,{url:I,children:(0,B2.jsx)(rt,{color:pt.AccentBlue,underline:!0,children:d})},c)}}else s.startsWith("<u>")&&s.endsWith("</u>")&&s.length>Jmn+Smn-1&&(e=(0,B2.jsx)(rt,{underline:!0,children:s.slice(Jmn,-Smn)},c))}catch(u){console.error("Error parsing inline markdown part:",s,u),e=null}t.push(e??(0,B2.jsx)(rt,{children:s},c)),r=a.lastIndex}return r<n.length&&t.push((0,B2.jsx)(rt,{children:n.slice(r)},`t-${r}`)),(0,B2.jsx)(B2.Fragment,{children:t.filter(s=>s!==null)})},sm=Bmn.default.memo(RUr),LB=n=>{let t=n.replace(/\*\*(.*?)\*\*/g,"$1").replace(/\*(.*?)\*/g,"$1").replace(/_(.*?)_/g,"$1").replace(/~~(.*?)~~/g,"$1").replace(/`(.*?)`/g,"$1").replace(/<u>(.*?)<\/u>/g,"$1").replace(/\[(.*?)\]\(.*?\)/g,"$1");return hl(t)};var Uv=Dt(Xn(),1);var Dmn=({headers:n,rows:t,terminalWidth:r})=>{let a=n.map((I,h)=>{let o=LB(I),v=Math.max(...t.map(w=>LB(w[h]||"")));return Math.max(o,v)+2}),i=a.reduce((I,h)=>I+h+1,1),s=i>r?r/i:1,e=a.map(I=>Math.floor(I*s)),c=(I,h,o=!1)=>{let v=Math.max(0,h-2),w=LB(I),R=I;if(w>v)if(v<=3)R=I.substring(0,Math.min(I.length,v));else{let Y=0,W=I.length,y=I;for(;Y<=W;){let b=Math.floor((Y+W)/2),f=I.substring(0,b);LB(f)<=v-3?(y=f,Y=b+1):W=b-1}R=y+"..."}let E=LB(R),A=Math.max(0,v-E);return(0,Uv.jsxs)(rt,{children:[o?(0,Uv.jsx)(rt,{bold:!0,color:pt.AccentCyan,children:(0,Uv.jsx)(sm,{text:R})}):(0,Uv.jsx)(sm,{text:R})," ".repeat(A)]})},u=I=>{let o={top:{left:"\u250C",middle:"\u252C",right:"\u2510",horizontal:"\u2500"},middle:{left:"\u251C",middle:"\u253C",right:"\u2524",horizontal:"\u2500"},bottom:{left:"\u2514",middle:"\u2534",right:"\u2518",horizontal:"\u2500"}}[I],v=e.map(R=>o.horizontal.repeat(R)),w=o.left+v.join(o.middle)+o.right;return(0,Uv.jsx)(rt,{children:w})},d=(I,h=!1)=>{let o=I.map((v,w)=>{let R=e[w]||0;return c(v||"",R,h)});return(0,Uv.jsxs)(rt,{children:["\u2502"," ",o.map((v,w)=>(0,Uv.jsxs)(RTe.default.Fragment,{children:[v,w<o.length-1?" \u2502 ":""]},w))," ","\u2502"]})};return(0,Uv.jsxs)(Gt,{flexDirection:"column",marginY:1,children:[u("top"),d(n,!0),u("middle"),t.map((I,h)=>(0,Uv.jsx)(RTe.default.Fragment,{children:d(I)},h)),u("bottom")]})};var Jr=Dt(Xn(),1);var EUr=1,QK=1,wUr=1,YUr=1,CUr=({text:n,isPending:t,availableTerminalHeight:r,terminalWidth:a})=>{if(!n)return(0,Jr.jsx)(Jr.Fragment,{});let i=n.split(`
4970
+ `);return(0,WV.jsxs)(Gt,{flexDirection:"row",width:"100%",children:[(0,WV.jsx)(Gt,{paddingX:2,paddingY:0,marginY:1,alignSelf:"flex-start",flexShrink:1,children:(0,WV.jsx)(rt,{children:E})}),t?(0,WV.jsx)(Gt,{flexGrow:1,justifyContent:"flex-end",alignItems:"flex-start",marginY:1,children:(0,WV.jsx)(rt,{children:i})}):null]})};var MR=Dt(Xn(),1);var Emn=({text:n,terminalWidth:t})=>{let r=n.startsWith("!")?n.substring(1):n;return(0,MR.jsxs)(Gt,{flexDirection:"row",width:"100%",children:[(0,MR.jsxs)(Gt,{flexShrink:1,children:[(0,MR.jsx)(rt,{color:pt.AccentCyan,children:"$ "}),(0,MR.jsx)(rt,{children:r})]}),t?(0,MR.jsx)(Gt,{flexGrow:1,justifyContent:"flex-end",alignItems:"center",children:(0,MR.jsx)(rt,{children:"\u{1F9D1}\u{1F4AC}"})}):null]})};var JB=Dt(mr(),1);Nr();var RTe=Dt(mr(),1);var Bmn=Dt(mr(),1);var WTe=Dt(mr(),1);var FV=Dt(d7e(),1);var wmn=process.env.TERM_PROGRAM==="Apple_Terminal",Hl={};Hl.cursorTo=(n,t)=>{if(typeof n!="number")throw new TypeError("The `x` argument is required");return typeof t!="number"?"\x1B["+(n+1)+"G":"\x1B["+(t+1)+";"+(n+1)+"H"};Hl.cursorMove=(n,t)=>{if(typeof n!="number")throw new TypeError("The `x` argument is required");let r="";return n<0?r+="\x1B["+-n+"D":n>0&&(r+="\x1B["+n+"C"),t<0?r+="\x1B["+-t+"A":t>0&&(r+="\x1B["+t+"B"),r};Hl.cursorUp=(n=1)=>"\x1B["+n+"A";Hl.cursorDown=(n=1)=>"\x1B["+n+"B";Hl.cursorForward=(n=1)=>"\x1B["+n+"C";Hl.cursorBackward=(n=1)=>"\x1B["+n+"D";Hl.cursorLeft="\x1B[G";Hl.cursorSavePosition=wmn?"\x1B7":"\x1B[s";Hl.cursorRestorePosition=wmn?"\x1B8":"\x1B[u";Hl.cursorGetPosition="\x1B[6n";Hl.cursorNextLine="\x1B[E";Hl.cursorPrevLine="\x1B[F";Hl.cursorHide="\x1B[?25l";Hl.cursorShow="\x1B[?25h";Hl.eraseLines=n=>{let t="";for(let r=0;r<n;r++)t+=Hl.eraseLine+(r<n-1?Hl.cursorUp():"");return n&&(t+=Hl.cursorLeft),t};Hl.eraseEndLine="\x1B[K";Hl.eraseStartLine="\x1B[1K";Hl.eraseLine="\x1B[2K";Hl.eraseDown="\x1B[J";Hl.eraseUp="\x1B[1J";Hl.eraseScreen="\x1B[2J";Hl.scrollUp="\x1B[S";Hl.scrollDown="\x1B[T";Hl.clearScreen="\x1Bc";Hl.clearTerminal=process.platform==="win32"?`${Hl.eraseScreen}\x1B[0f`:`${Hl.eraseScreen}\x1B[3J\x1B[H`;Hl.beep="\x07";Hl.link=(n,t)=>["\x1B]","8",";",";",t,"\x07",n,"\x1B]","8",";",";","\x07"].join("");Hl.image=(n,t={})=>{let r="\x1B]1337;File=inline=1";return t.width&&(r+=`;width=${t.width}`),t.height&&(r+=`;height=${t.height}`),t.preserveAspectRatio===!1&&(r+=";preserveAspectRatio=0"),r+":"+n.toString("base64")+"\x07"};Hl.iTerm={setCwd:(n=process.cwd())=>`\x1B]50;CurrentDir=${n}\x07`,annotation:(n,t={})=>{let r="\x1B]1337;",a=typeof t.x<"u",i=typeof t.y<"u";if((a||i)&&!(a&&i&&typeof t.length<"u"))throw new Error("`x`, `y` and `length` must be defined when `x` or `y` is defined");return n=n.replace(/\|/g,""),r+=t.isHidden?"AddHiddenAnnotation=":"AddAnnotation=",t.length>0?r+=(a?[n,t.length,t.x,t.y]:[t.length,n]).join("|"):r+=n,r+"\x07"}};var Ymn=Hl;var k2e=Dt(Xmn(),1);function AV(n,t,{target:r="stdout",...a}={}){return k2e.default[r]?Ymn.link(n,t):a.fallback===!1?n:typeof a.fallback=="function"?a.fallback(n,t):`${n} (\u200B${t}\u200B)`}AV.isSupported=k2e.default.stdout;AV.stderr=(n,t,r={})=>AV(n,t,{target:"stderr",...r});AV.stderr.isSupported=k2e.default.stderr;var kmn=({children:n,url:t,fallback:r=!0})=>WTe.default.createElement(i9,{transform:a=>AV(a,t,{fallback:r})},WTe.default.createElement(rt,null,n));kmn.propTypes={children:FV.default.oneOfType([FV.default.arrayOf(FV.default.node),FV.default.node]).isRequired,url:FV.default.string.isRequired,fallback:FV.default.bool};var Lmn=kmn;var B2=Dt(Xn(),1);var ATe=2,FTe=1,yTe=2,yUr=1,Jmn=3,Smn=4,RUr=({text:n})=>{let t=[],r=0,a=/(\*\*.*?\*\*|\*.*?\*|_.*?_|~~.*?~~|\[.*?\]\(.*?\)|`+.+?`+|<u>.*?<\/u>)/g,i;for(;(i=a.exec(n))!==null;){i.index>r&&t.push((0,B2.jsx)(rt,{children:n.slice(r,i.index)},`t-${r}`));let s=i[0],e=null,c=`m-${i.index}`;try{if(s.startsWith("**")&&s.endsWith("**")&&s.length>ATe*2)e=(0,B2.jsx)(rt,{bold:!0,children:s.slice(ATe,-ATe)},c);else if(s.length>FTe*2&&(s.startsWith("*")&&s.endsWith("*")||s.startsWith("_")&&s.endsWith("_"))&&!/\w/.test(n.substring(i.index-1,i.index))&&!/\w/.test(n.substring(a.lastIndex,a.lastIndex+1))&&!/\S[./\\]/.test(n.substring(i.index-2,i.index))&&!/[./\\]\S/.test(n.substring(a.lastIndex,a.lastIndex+2)))e=(0,B2.jsx)(rt,{italic:!0,children:s.slice(FTe,-FTe)},c);else if(s.startsWith("~~")&&s.endsWith("~~")&&s.length>yTe*2)e=(0,B2.jsx)(rt,{strikethrough:!0,children:s.slice(yTe,-yTe)},c);else if(s.startsWith("`")&&s.endsWith("`")&&s.length>yUr){let u=s.match(/^(`+)(.+?)\1$/s);u&&u[2]&&(e=(0,B2.jsx)(rt,{color:pt.AccentPurple,children:u[2]},c))}else if(s.startsWith("[")&&s.includes("](")&&s.endsWith(")")){let u=s.match(/\[(.*?)\]\((.*?)\)/);if(u){let d=u[1],I=u[2],h=d.replace(/^https?:\/\//,"").replace(/\/$/,""),o=I.replace(/^https?:\/\//,"").replace(/\/$/,""),v=h===o||I===d;e=(0,B2.jsx)(Lmn,{url:I,children:(0,B2.jsx)(rt,{color:pt.AccentBlue,underline:!0,children:d})},c)}}else s.startsWith("<u>")&&s.endsWith("</u>")&&s.length>Jmn+Smn-1&&(e=(0,B2.jsx)(rt,{underline:!0,children:s.slice(Jmn,-Smn)},c))}catch(u){console.error("Error parsing inline markdown part:",s,u),e=null}t.push(e??(0,B2.jsx)(rt,{children:s},c)),r=a.lastIndex}return r<n.length&&t.push((0,B2.jsx)(rt,{children:n.slice(r)},`t-${r}`)),(0,B2.jsx)(B2.Fragment,{children:t.filter(s=>s!==null)})},sm=Bmn.default.memo(RUr),LB=n=>{let t=n.replace(/\*\*(.*?)\*\*/g,"$1").replace(/\*(.*?)\*/g,"$1").replace(/_(.*?)_/g,"$1").replace(/~~(.*?)~~/g,"$1").replace(/`(.*?)`/g,"$1").replace(/<u>(.*?)<\/u>/g,"$1").replace(/\[(.*?)\]\(.*?\)/g,"$1");return hl(t)};var Uv=Dt(Xn(),1);var Dmn=({headers:n,rows:t,terminalWidth:r})=>{let a=n.map((I,h)=>{let o=LB(I),v=Math.max(...t.map(w=>LB(w[h]||"")));return Math.max(o,v)+2}),i=a.reduce((I,h)=>I+h+1,1),s=i>r?r/i:1,e=a.map(I=>Math.floor(I*s)),c=(I,h,o=!1)=>{let v=Math.max(0,h-2),w=LB(I),R=I;if(w>v)if(v<=3)R=I.substring(0,Math.min(I.length,v));else{let Y=0,W=I.length,y=I;for(;Y<=W;){let b=Math.floor((Y+W)/2),f=I.substring(0,b);LB(f)<=v-3?(y=f,Y=b+1):W=b-1}R=y+"..."}let E=LB(R),A=Math.max(0,v-E);return(0,Uv.jsxs)(rt,{children:[o?(0,Uv.jsx)(rt,{bold:!0,color:pt.AccentCyan,children:(0,Uv.jsx)(sm,{text:R})}):(0,Uv.jsx)(sm,{text:R})," ".repeat(A)]})},u=I=>{let o={top:{left:"\u250C",middle:"\u252C",right:"\u2510",horizontal:"\u2500"},middle:{left:"\u251C",middle:"\u253C",right:"\u2524",horizontal:"\u2500"},bottom:{left:"\u2514",middle:"\u2534",right:"\u2518",horizontal:"\u2500"}}[I],v=e.map(R=>o.horizontal.repeat(R)),w=o.left+v.join(o.middle)+o.right;return(0,Uv.jsx)(rt,{children:w})},d=(I,h=!1)=>{let o=I.map((v,w)=>{let R=e[w]||0;return c(v||"",R,h)});return(0,Uv.jsxs)(rt,{children:["\u2502"," ",o.map((v,w)=>(0,Uv.jsxs)(RTe.default.Fragment,{children:[v,w<o.length-1?" \u2502 ":""]},w))," ","\u2502"]})};return(0,Uv.jsxs)(Gt,{flexDirection:"column",marginY:1,children:[u("top"),d(n,!0),u("middle"),t.map((I,h)=>(0,Uv.jsx)(RTe.default.Fragment,{children:d(I)},h)),u("bottom")]})};var Jr=Dt(Xn(),1);var EUr=1,QK=1,wUr=1,YUr=1,CUr=({text:n,isPending:t,availableTerminalHeight:r,terminalWidth:a})=>{if(!n)return(0,Jr.jsx)(Jr.Fragment,{});let i=n.split(`
4971
4971
  `),s=/^ *(#{1,4}) +(.*)/,e=/^ *(`{3,}|~{3,}) *(\w*?) *$/,c=/^([ \t]*)([-*+]) +(.*)/,u=/^([ \t]*)(\d+)\. +(.*)/,d=/^ *([-*_] *){3,} *$/,I=/^\s*\|(.+)\|\s*$/,h=/^\s*\|?\s*(:?-+:?)\s*(\|\s*(:?-+:?)\s*)+\|?\s*$/,o=/<think>/i,v=/<\/think>/i,w=[],R=!1,E=!0,A=[],Y=null,W="",y=!1,b=[],f=!1,g=[],N=[],p=!1;function m(G){if(!p){if(t&&r&&w.length>=r){p=!0,w.push((0,Jr.jsx)(Gt,{paddingLeft:1,children:(0,Jr.jsx)(rt,{color:pt.Gray,children:"... generating ..."})},"truncation-indicator"));return}G&&(w.push(G),E=!1)}}return i.forEach((G,Z)=>{if(p)return;let C=`line-${Z}`;if(R){let F=G.match(e);F&&F[1].startsWith(W[0])&&F[1].length>=W.length?(m((0,Jr.jsx)(Tmn,{content:A,lang:Y,isPending:t,availableTerminalHeight:r,terminalWidth:a},C)),R=!1,A=[],Y=null,W=""):A.push(G);return}if(y){if(G.match(v)){let x=G.toLowerCase().indexOf("</think>"),B=G.substring(0,x),U=G.substring(x+8);B&&b.push(B),m((0,Jr.jsx)(ETe,{content:b,isPending:t,availableTerminalHeight:r,terminalWidth:a},C)),y=!1,b=[],U.trim()&&m((0,Jr.jsx)(Gt,{children:(0,Jr.jsx)(rt,{wrap:"wrap",children:(0,Jr.jsx)(sm,{text:U})})},`${C}-after`))}else b.push(G);return}let O=G.match(e),k=G.match(o),J=G.match(s),D=G.match(c),X=G.match(u),H=G.match(d),Q=G.match(I),V=G.match(h);if(O)R=!0,W=O[1],Y=O[2]||null;else if(k){let F=G.toLowerCase().indexOf("<think>"),x=G.substring(0,F),B=G.substring(F+7);x.trim()&&m((0,Jr.jsx)(Gt,{children:(0,Jr.jsx)(rt,{wrap:"wrap",children:(0,Jr.jsx)(sm,{text:x})})},`${C}-before`)),y=!0;let U=B.toLowerCase().indexOf("</think>");if(U!==-1){let T=B.substring(0,U),L=B.substring(U+8);m((0,Jr.jsx)(ETe,{content:[T],isPending:t,availableTerminalHeight:r,terminalWidth:a},C)),y=!1,L.trim()&&m((0,Jr.jsx)(Gt,{children:(0,Jr.jsx)(rt,{wrap:"wrap",children:(0,Jr.jsx)(sm,{text:L})})},`${C}-after`))}else B&&b.push(B)}else if(Q&&!f)Z+1<i.length&&i[Z+1].match(h)?(f=!0,N=Q[1].split("|").map(F=>F.trim()),g=[]):m((0,Jr.jsx)(Gt,{children:(0,Jr.jsx)(rt,{wrap:"wrap",children:(0,Jr.jsx)(sm,{text:G})})},C));else if(!(f&&V))if(f&&Q){let F=Q[1].split("|").map(x=>x.trim());for(;F.length<N.length;)F.push("");F.length>N.length&&(F.length=N.length),g.push(F)}else if(f&&!Q)N.length>0&&g.length>0&&m((0,Jr.jsx)(Umn,{headers:N,rows:g,terminalWidth:a},`table-${w.length}`)),f=!1,g=[],N=[],G.trim().length>0&&m((0,Jr.jsx)(Gt,{children:(0,Jr.jsx)(rt,{wrap:"wrap",children:(0,Jr.jsx)(sm,{text:G})})},C));else if(H)m((0,Jr.jsx)(Gt,{children:(0,Jr.jsx)(rt,{dimColor:!0,children:"---"})},C));else if(J){let F=J[1].length,x=J[2],B=null;switch(F){case 1:B=(0,Jr.jsx)(rt,{bold:!0,color:pt.AccentCyan,children:(0,Jr.jsx)(sm,{text:x})});break;case 2:B=(0,Jr.jsx)(rt,{bold:!0,color:pt.AccentBlue,children:(0,Jr.jsx)(sm,{text:x})});break;case 3:B=(0,Jr.jsx)(rt,{bold:!0,children:(0,Jr.jsx)(sm,{text:x})});break;case 4:B=(0,Jr.jsx)(rt,{italic:!0,color:pt.Gray,children:(0,Jr.jsx)(sm,{text:x})});break;default:B=(0,Jr.jsx)(rt,{children:(0,Jr.jsx)(sm,{text:x})});break}B&&m((0,Jr.jsx)(Gt,{children:B},C))}else if(D){let F=D[1],x=D[2],B=D[3];m((0,Jr.jsx)(Omn,{itemText:B,type:"ul",marker:x,leadingWhitespace:F},C))}else if(X){let F=X[1],x=X[2],B=X[3];m((0,Jr.jsx)(Omn,{itemText:B,type:"ol",marker:x,leadingWhitespace:F},C))}else G.trim().length===0&&!R?E||(w.push((0,Jr.jsx)(Gt,{height:EUr},`spacer-${Z}`)),E=!0):m((0,Jr.jsx)(Gt,{width:a,flexShrink:0,children:(0,Jr.jsx)(rt,{wrap:"wrap",children:(0,Jr.jsx)(sm,{text:G})})},C))}),R&&m((0,Jr.jsx)(Tmn,{content:A,lang:Y,isPending:t,availableTerminalHeight:r,terminalWidth:a},"line-eof")),y&&m((0,Jr.jsx)(ETe,{content:b,isPending:t,availableTerminalHeight:r,terminalWidth:a},"think-eof")),f&&N.length>0&&g.length>0&&m((0,Jr.jsx)(Umn,{headers:N,rows:g,terminalWidth:a},`table-${w.length}`)),(0,Jr.jsx)(Jr.Fragment,{children:w})},xUr=({content:n,isPending:t,availableTerminalHeight:r,terminalWidth:a})=>{let s=Ke("model.reasoning"),e=hl(s)+1,c=Math.max(0,a-e-2),u=n,d=r?Math.max(2,Math.floor(r*.3)):10;return t&&n.length>d&&(u=n.slice(-d)),(0,Jr.jsxs)(Gt,{flexDirection:"column",marginY:1,children:[(0,Jr.jsxs)(Gt,{flexDirection:"row",alignItems:"center",width:a,children:[(0,Jr.jsxs)(rt,{color:pt.AccentBlue,bold:!0,children:[s," "]}),(0,Jr.jsx)(rt,{color:pt.Gray,children:"\u2500".repeat(c)})]}),(0,Jr.jsxs)(Gt,{paddingX:1,flexDirection:"column",width:a,children:[(0,Jr.jsx)(rt,{color:pt.Comment,italic:!0,wrap:"wrap",children:u.join(`
4972
- `)}),t&&(0,Jr.jsx)(rt,{color:pt.Comment,children:"..."})]}),(0,Jr.jsx)(Gt,{flexDirection:"row",alignItems:"center",width:a,children:(0,Jr.jsx)(rt,{color:pt.Gray,children:"\u2500".repeat(a-1)})})]})},ETe=JB.default.memo(xUr),VUr=({content:n,lang:t,isPending:r,availableTerminalHeight:a,terminalWidth:i})=>{if(r&&a!==void 0){let d=Math.max(0,a-2);if(n.length>d){if(d<1)return(0,Jr.jsx)(Gt,{paddingLeft:QK,children:(0,Jr.jsx)(rt,{color:pt.Gray,children:"... code is being written ..."})});let I=n.slice(0,d),h=cV(I.join(`
4972
+ `)}),t?(0,Jr.jsx)(rt,{color:pt.Comment,children:"..."}):null]}),(0,Jr.jsx)(Gt,{flexDirection:"row",alignItems:"center",width:a,children:(0,Jr.jsx)(rt,{color:pt.Gray,children:"\u2500".repeat(a-1)})})]})},ETe=JB.default.memo(xUr),VUr=({content:n,lang:t,isPending:r,availableTerminalHeight:a,terminalWidth:i})=>{if(r&&a!==void 0){let d=Math.max(0,a-2);if(n.length>d){if(d<1)return(0,Jr.jsx)(Gt,{paddingLeft:QK,children:(0,Jr.jsx)(rt,{color:pt.Gray,children:"... code is being written ..."})});let I=n.slice(0,d),h=cV(I.join(`
4973
4973
  `),t,a,i-QK);return(0,Jr.jsxs)(Gt,{paddingLeft:QK,flexDirection:"column",children:[h,(0,Jr.jsx)(rt,{color:pt.Gray,children:"... generating more ..."})]})}}let c=n.join(`
4974
4974
  `),u=cV(c,t,a,i-QK);return(0,Jr.jsx)(Gt,{paddingLeft:QK,flexDirection:"column",width:i,flexShrink:0,children:u})},Tmn=JB.default.memo(VUr),QUr=({itemText:n,type:t,marker:r,leadingWhitespace:a=""})=>{let i=t==="ol"?`${r}. `:`${r} `,s=i.length,e=a.length;return(0,Jr.jsxs)(Gt,{paddingLeft:e+wUr,flexDirection:"row",children:[(0,Jr.jsx)(Gt,{width:s,children:(0,Jr.jsx)(rt,{children:i})}),(0,Jr.jsx)(Gt,{flexGrow:YUr,children:(0,Jr.jsx)(rt,{wrap:"wrap",children:(0,Jr.jsx)(sm,{text:n})})})]})},Omn=JB.default.memo(QUr),HUr=({headers:n,rows:t,terminalWidth:r})=>(0,Jr.jsx)(Dmn,{headers:n,rows:t,terminalWidth:r}),Umn=JB.default.memo(HUr),L2e=JB.default.memo(CUr);var Mmn=Dt(Xn(),1);var J2e=({children:n,preventOverflow:t=!0})=>(0,Mmn.jsx)(Gt,{flexDirection:"column",...t?{flexShrink:0,overflow:"hidden"}:{},children:n});var _R=Dt(Xn(),1);var zmn=({text:n,isPending:t,availableTerminalHeight:r,terminalWidth:a})=>(0,_R.jsx)(J2e,{preventOverflow:!0,children:(0,_R.jsxs)(Gt,{flexDirection:"row",children:[(0,_R.jsx)(Gt,{width:2,flexShrink:0,children:(0,_R.jsx)(rt,{color:pt.Foreground,children:"\u25CF "})}),(0,_R.jsx)(Gt,{flexGrow:1,flexDirection:"column",flexShrink:1,children:(0,_R.jsx)(L2e,{text:n,isPending:t,availableTerminalHeight:r,terminalWidth:a-2})})]})});var yV=Dt(Xn(),1);var _mn=({text:n})=>(0,yV.jsxs)(Gt,{flexDirection:"row",marginTop:1,children:[(0,yV.jsx)(Gt,{width:3,children:(0,yV.jsx)(rt,{color:pt.AccentYellow,children:"\u2139\uFE0F "})}),(0,yV.jsx)(Gt,{flexGrow:1,children:(0,yV.jsx)(rt,{wrap:"wrap",color:pt.AccentYellow,children:n})})]});var RV=Dt(Xn(),1);function XUr(n){return n.includes("\u{1F310} \u7F51\u7EDC\u8FDE\u63A5\u5931\u8D25")||n.includes("\u{1F310} Network Connection Failed")?pt.AccentYellow:pt.AccentRed}var Pmn=({text:n})=>{let a=XUr(n);return(0,RV.jsxs)(Gt,{flexDirection:"row",marginBottom:1,children:[(0,RV.jsx)(Gt,{width:2,children:(0,RV.jsx)(rt,{color:a,children:"\u2715 "})}),(0,RV.jsx)(Gt,{flexGrow:1,children:(0,RV.jsx)(rt,{wrap:"wrap",color:a,children:n})})]})};var apn=Dt(mr(),1);var epn=Dt(mr(),1);var yN=Dt(Xn(),1);var jmn=({data:n,titleEmphasis:t="strong"})=>{let r=n.items||[],a=s=>s==="completed"?pt.AccentGreen:s==="in_progress"?pt.AccentBlue:pt.Foreground,i=s=>s==="completed"?"\u2612":"\u25A1";return(0,yN.jsxs)(Gt,{flexDirection:"column",children:[(0,yN.jsxs)(Gt,{children:[(0,yN.jsx)(rt,{color:pt.AccentGreen,children:"\u25CF "}),(0,yN.jsx)(rt,{bold:t==="strong",children:n.title||"Update Todos"})]}),(0,yN.jsx)(Gt,{flexDirection:"column",marginTop:0,children:r.map((s,e)=>{let u=e===r.length-1?"\u2514":"\u251C",d=a(s.status),I=i(s.status);return(0,yN.jsxs)(Gt,{children:[(0,yN.jsxs)(rt,{children:[" ",u," "]}),(0,yN.jsxs)(rt,{color:d,strikethrough:s.status==="completed",children:[I," ",s.content]})]},s.id)})})]})};Nr();var po=Dt(Xn(),1);var wTe=({data:n})=>{let r=(()=>{switch(n.status){case"starting":case"running":return{icon:"\u25CF",color:pt.AccentBlue};case"completed":return{icon:"\u2713",color:pt.AccentGreen};case"failed":return{icon:"\u2717",color:pt.AccentRed};case"cancelled":return{icon:"\u25A0",color:pt.AccentYellow};default:return{icon:"\u25CF",color:pt.Foreground}}})(),a=u=>{switch(u){case"Pending":return"\u25CB";case"Executing":return"~";case"SubAgentRunning":return"\u25CF";case"Success":return"\u2713";case"Error":return"\u2717";case"Canceled":return"\u25A0";case"Confirming":return"?";default:return"?"}},i=u=>u?u<1e3?`${u}ms`:`${(u/1e3).toFixed(1)}s`:"",s=u=>{if(!u||u.totalTokens===0)return"0";let{totalTokens:d}=u;return d>=1e3?`${(d/1e3).toFixed(1)}k`:d.toString()},e=()=>{if(!n.toolCalls||n.toolCalls.length===0)return(0,po.jsx)(Gt,{children:(0,po.jsx)(rt,{color:pt.Gray,children:"\u251C\u2500 initializing..."})});let u=3,d=n.toolCalls.length,I=Math.max(0,d-u),h=n.toolCalls.slice(-u);return(0,po.jsxs)(Gt,{flexDirection:"column",children:[I>0&&(0,po.jsxs)(Gt,{children:[(0,po.jsx)(rt,{color:pt.Gray,children:"\u251C\u2500 "}),(0,po.jsxs)(rt,{color:pt.Gray,children:["(",I," more tools)"]})]}),h.map((o,v)=>{let R=v===h.length-1&&I===0?"\u2514\u2500":"\u251C\u2500",E=a(o.status),A=i(o.durationMs),Y=80,W=o.description.length>Y?o.description.slice(0,Y)+"...":o.description,y=`${R} ${E} ${LE(o.toolName)} ${W}${A?` (${A})`:""}`;return(0,po.jsxs)(Gt,{children:[(0,po.jsx)(rt,{color:pt.Gray,wrap:"truncate",children:y}),o.status==="Executing"&&(0,po.jsx)(rt,{children:" "})]},o.callId||`tool-${v}`)})]})},c=()=>{let u=n.endTime?n.endTime-n.startTime:0,d=i(u);return(0,po.jsxs)(Gt,{flexDirection:"column",children:[(0,po.jsxs)(Gt,{children:[(0,po.jsxs)(rt,{color:pt.Gray,children:["\u251C\u2500 ",Ke("subagent.tool.calls")," "]}),(0,po.jsx)(rt,{children:ln("subagent.tool.calls.count",{count:n.stats.totalToolCalls})})]}),(0,po.jsxs)(Gt,{children:[(0,po.jsxs)(rt,{color:pt.Gray,children:["\u251C\u2500 ",Ke("subagent.execution.time")," "]}),(0,po.jsx)(rt,{children:d||"< 1ms"})]}),(0,po.jsxs)(Gt,{children:[(0,po.jsxs)(rt,{color:pt.Gray,children:["\u2514\u2500 ",Ke("subagent.token.consumption")," "]}),(0,po.jsx)(rt,{children:s(n.stats.tokenUsage)})]}),n.status==="failed"&&n.error&&(0,po.jsx)(Gt,{marginTop:1,children:(0,po.jsxs)(rt,{color:pt.AccentRed,children:[" \u26A0\uFE0F ",n.error]})})]})};return(0,po.jsxs)(Gt,{flexDirection:"column",children:[n.status==="starting"||n.status==="running"?e():c(),n.status==="running"&&n.toolCalls&&n.toolCalls.length>0&&(0,po.jsxs)(Gt,{marginTop:1,children:[(0,po.jsx)(rt,{color:pt.Gray,children:" "}),(0,po.jsx)(sB,{nonRespondingDisplay:"\u280F"}),(0,po.jsx)(rt,{color:pt.AccentBlue,children:" \u5B50Agent\u6B63\u5728\u601D\u8003\u548C\u6267\u884C..."})]})]})};var Cu=Dt(Xn(),1);var Kmn=({data:n})=>{let t=()=>n.isRevision?(0,Cu.jsx)(rt,{color:pt.AccentYellow,children:"\u{1F504} \u4FEE\u6B63\u601D\u8003"}):n.branchId?(0,Cu.jsx)(rt,{color:pt.AccentBlue,children:"\u{1F33F} \u5206\u652F\u63A2\u7D22"}):n.nextThoughtNeeded===!1?(0,Cu.jsx)(rt,{color:pt.AccentGreen,children:"\u2713 \u601D\u8003\u5B8C\u6210"}):(0,Cu.jsx)(rt,{color:pt.AccentBlue,children:"\u{1F4AD} \u601D\u8003\u4E2D"}),r=n.thoughtNumber&&n.totalThoughts?`\u6B65\u9AA4 ${n.thoughtNumber}/${n.totalThoughts}`:n.thoughtNumber?`\u6B65\u9AA4 ${n.thoughtNumber}`:"",a=5,i=n.thought.split(`
4975
4975
  `),s=i.length>a,e=i.slice(0,a).join(`
4976
- `);return(0,Cu.jsxs)(Gt,{flexDirection:"column",children:[(0,Cu.jsxs)(Gt,{children:[t(),r&&(0,Cu.jsxs)(Cu.Fragment,{children:[(0,Cu.jsx)(rt,{color:pt.Gray,children:" \xB7 "}),(0,Cu.jsx)(rt,{color:pt.Gray,children:r})]})]}),(0,Cu.jsx)(Gt,{marginTop:0,marginLeft:2,children:(0,Cu.jsxs)(rt,{color:pt.Gray,wrap:"wrap",children:[e,s&&(0,Cu.jsxs)(rt,{color:pt.Gray,dimColor:!0,children:[`
4977
- `,"... (\u66F4\u591A\u601D\u8003\u5185\u5BB9)"]})]})}),(n.isRevision||n.branchId||n.needsMoreThoughts)&&(0,Cu.jsxs)(Gt,{marginTop:0,marginLeft:2,flexDirection:"column",children:[n.isRevision&&n.revisesThought!==void 0&&(0,Cu.jsxs)(rt,{color:pt.Gray,dimColor:!0,children:["\u21AA \u4FEE\u6B63\u6B65\u9AA4 ",n.revisesThought]}),n.branchId&&n.branchFromThought!==void 0&&(0,Cu.jsxs)(rt,{color:pt.Gray,dimColor:!0,children:["\u21AA \u4ECE\u6B65\u9AA4 ",n.branchFromThought," \u5206\u652F (",n.branchId,")"]}),n.needsMoreThoughts&&(0,Cu.jsx)(rt,{color:pt.Gray,dimColor:!0,children:"\u21AA \u9700\u8981\u66F4\u591A\u601D\u8003\u6B65\u9AA4"})]})]})};var SB=Dt(mr(),1);var YTe=Dt(Xn(),1);var qmn=()=>{let n=Io(),[t,r]=(0,SB.useState)(!0),a=(0,SB.useRef)(null);return(0,SB.useEffect)(()=>(a.current&&(clearInterval(a.current),a.current=null),aN(n,"spinner")||(a.current=setInterval(()=>{r(s=>!s)},500)),()=>{a.current&&(clearInterval(a.current),a.current=null)}),[n]),aN(n,"spinner")?(0,YTe.jsx)(rt,{color:pt.AccentBlue,children:"\u{1F916}"}):(0,YTe.jsx)(rt,{color:pt.AccentBlue,children:t?"\u{1F916}":" "})};Nr();var Br=Dt(Xn(),1);var kUr=1,LUr=5,S2e=3,JUr=2,$mn=1e6;function SUr(n){let t=n.split(`
4978
- `),r=0,a=0,i=!1,s=!1;n.includes("new file mode")?i=!0:(n.includes("deleted file mode")||n.includes("--- a/")&&n.includes("+++ /dev/null"))&&(s=!0);for(let c of t)c.startsWith("+")&&!c.startsWith("+++")?r++:c.startsWith("-")&&!c.startsWith("---")&&a++;let e=Math.min(r,a);return{linesAdded:r-e,linesRemoved:a-e,linesChanged:e,isNewFile:i,isDeletedFile:s}}function BUr(n,t){if(n.isNewFile)return(0,Br.jsxs)(Gt,{children:[(0,Br.jsx)(rt,{color:pt.AccentGreen,children:"\u{1F4C4} \u65B0\u5EFA\u6587\u4EF6"}),(0,Br.jsxs)(rt,{color:pt.Gray,children:[" ",t]}),n.linesAdded>0&&(0,Br.jsxs)(rt,{color:pt.AccentGreen,children:[" (+",n.linesAdded," \u884C)"]})]});if(n.isDeletedFile)return(0,Br.jsxs)(Gt,{children:[(0,Br.jsx)(rt,{color:pt.AccentRed,children:"\u{1F5D1}\uFE0F \u5220\u9664\u6587\u4EF6"}),(0,Br.jsxs)(rt,{color:pt.Gray,children:[" ",t]}),n.linesRemoved>0&&(0,Br.jsxs)(rt,{color:pt.AccentRed,children:[" (-",n.linesRemoved," \u884C)"]})]});let r=[(0,Br.jsxs)(rt,{color:pt.Gray,children:["\u{1F4DD} ",t]},"file")];return n.linesAdded>0&&r.push((0,Br.jsxs)(rt,{color:pt.AccentGreen,children:[" +",n.linesAdded]},"added")),n.linesRemoved>0&&r.push((0,Br.jsxs)(rt,{color:pt.AccentRed,children:[" -",n.linesRemoved]},"removed")),n.linesChanged>0&&r.push((0,Br.jsxs)(rt,{color:pt.AccentYellow,children:[" M ",n.linesChanged]},"changed")),n.linesAdded===0&&n.linesRemoved===0&&n.linesChanged===0&&r.push((0,Br.jsx)(rt,{color:pt.Gray,children:" (\u65E0\u53D8\u66F4)"},"no-change")),(0,Br.jsx)(Gt,{children:r})}var tpn=({name:n,description:t,resultDisplay:r,status:a,confirmationDetails:i,availableTerminalHeight:s,terminalWidth:e,emphasis:c="medium",renderOutputAsMarkdown:u=!0,forceMarkdown:d=!1})=>{let I=Io(),h=I.sizeLevel==="small"||I.sizeLevel==="tiny",o=s?Math.max(s-kUr-LUr,JUr+1):void 0;o&&!d&&(u=!1);let v=e-3,w=n?.toLowerCase().replace(/[_-]/g,""),R=null;if(w?.includes("sequentialthinking"))try{let E=JSON.parse(t);E&&E.thought!==void 0&&(R={type:"mcp_thinking_display",thought:E.thought||"",thoughtNumber:E.thoughtNumber,totalThoughts:E.totalThoughts,nextThoughtNeeded:E.nextThoughtNeeded,isRevision:E.isRevision,revisesThought:E.revisesThought,branchFromThought:E.branchFromThought,branchId:E.branchId,needsMoreThoughts:E.needsMoreThoughts,branches:E.branches,thoughtHistoryLength:E.thoughtHistoryLength})}catch{}return typeof r=="string"&&r.length>$mn&&(r="..."+r.slice(-$mn)),(0,Br.jsxs)(Gt,{paddingX:1,paddingY:0,flexDirection:"column",width:e,children:[(0,Br.jsxs)(Gt,{minHeight:1,width:"100%",children:[(0,Br.jsx)(DUr,{status:a}),(0,Br.jsx)(TUr,{name:n,status:a,description:t,emphasis:c,terminalWidth:e-2}),c==="high"&&(0,Br.jsx)(OUr,{})]}),R&&(0,Br.jsx)(Gt,{paddingLeft:S2e,width:"100%",children:(0,Br.jsx)(Gt,{flexDirection:"column",children:(0,Br.jsxs)(Gt,{flexDirection:"row",children:[(0,Br.jsx)(rt,{color:pt.Gray,children:"\u2514 "}),(0,Br.jsx)(Gt,{flexGrow:1,children:(0,Br.jsx)(Kmn,{data:R})})]})})}),!R&&r&&(0,Br.jsx)(Gt,{paddingLeft:S2e,width:"100%",children:(0,Br.jsxs)(Gt,{flexDirection:"column",children:[typeof r=="string"&&u&&(0,Br.jsxs)(rt,{wrap:"wrap",children:[(0,Br.jsx)(rt,{color:pt.Gray,children:"\u2514 "}),r]}),typeof r=="string"&&!u&&(()=>{let E=o!==void 0?a==="Executing"?o:o*3:20,A=iV(r,{maxRows:E,terminalWidth:v});if(A.isTruncated){let Y=A.displayText.split(A.omittedPlaceholder||"");return(0,Br.jsxs)(Gt,{flexDirection:"column",children:[(0,Br.jsxs)(rt,{wrap:"wrap",children:[(0,Br.jsx)(rt,{color:pt.Gray,children:"\u2514 "}),Y[0]]}),(0,Br.jsxs)(rt,{color:pt.Gray,wrap:"truncate",children:["... omitted ",A.omittedLines," lines ..."]}),Y[1]&&(0,Br.jsx)(rt,{wrap:"wrap",children:Y[1]})]})}return o!==void 0?(0,Br.jsx)(gN,{maxWidth:v,maxHeight:E,overflowDirection:"top",children:(0,Br.jsx)(Gt,{children:(0,Br.jsxs)(rt,{wrap:"wrap",children:[(0,Br.jsx)(rt,{color:pt.Gray,children:"\u2514 "}),r]})})}):(0,Br.jsxs)(rt,{wrap:"wrap",children:[(0,Br.jsx)(rt,{color:pt.Gray,children:"\u2514 "}),r]})})(),typeof r!="string"&&r.type==="todo_display"&&(0,Br.jsxs)(Gt,{flexDirection:"row",children:[(0,Br.jsx)(rt,{color:pt.Gray,children:"\u2514 "}),(0,Br.jsx)(Gt,{flexGrow:1,children:(0,Br.jsx)(jmn,{data:r})})]}),typeof r!="string"&&r.type==="subagent_display"&&(0,Br.jsxs)(Gt,{flexDirection:"row",children:[(0,Br.jsx)(rt,{color:pt.Gray,children:"\u2514 "}),(0,Br.jsx)(Gt,{flexGrow:1,children:(0,Br.jsx)(wTe,{data:r})})]}),typeof r!="string"&&r.type==="subagent_update"&&(0,Br.jsxs)(Gt,{flexDirection:"row",children:[(0,Br.jsx)(rt,{color:pt.Gray,children:"\u2514 "}),(0,Br.jsx)(Gt,{flexGrow:1,children:(0,Br.jsx)(wTe,{data:r.data})})]}),typeof r!="string"&&r.fileDiff&&(0,Br.jsxs)(Gt,{flexDirection:"row",children:[(0,Br.jsx)(rt,{color:pt.Gray,children:"\u2514 "}),(0,Br.jsx)(Gt,{flexGrow:1,children:h?BUr(SUr(r.fileDiff),r.fileName||"\u672A\u77E5\u6587\u4EF6"):(0,Br.jsx)(NB,{diffContent:r.fileDiff,filename:r.fileName,availableTerminalHeight:o,terminalWidth:v-2})})]})]})})]})},DUr=({status:n})=>(0,Br.jsxs)(Gt,{minWidth:S2e,children:[n==="Pending"&&(0,Br.jsx)(rt,{color:pt.AccentGreen,children:"o"}),n==="Executing"&&(0,Br.jsx)(sB,{nonRespondingDisplay:"\u22B7"}),n==="SubAgentRunning"&&(0,Br.jsx)(qmn,{}),n==="Success"&&(0,Br.jsx)(rt,{color:pt.AccentGreen,children:"\u25CF"}),n==="Confirming"&&(0,Br.jsx)(rt,{color:pt.AccentYellow,children:"?"}),n==="Canceled"&&(0,Br.jsx)(rt,{color:pt.AccentYellow,bold:!0,children:"-"}),n==="Error"&&(0,Br.jsx)(rt,{color:pt.AccentRed,bold:!0,children:"x"})]}),TUr=({name:n,description:t,status:r,emphasis:a,terminalWidth:i})=>{let s=t,e=n?.toLowerCase().replace(/[_-]/g,"");if(e?.includes("sequentialthinking")&&t?.includes("thought"))try{let d=JSON.parse(t);d.thoughtNumber&&d.totalThoughts&&(s=`${to()?"\u6B65\u9AA4":"Step"} ${d.thoughtNumber}/${d.totalThoughts}`)}catch{}let c=epn.default.useMemo(()=>{switch(a){case"high":return pt.Foreground;case"medium":return pt.Foreground;case"low":return pt.Gray;default:return a}},[a]);e?.includes("sequentialthinking")&&console.log("\u{1F5BC}\uFE0F [ToolInfo] RENDERING with displayDescription:",s.substring(0,100));let u=i-S2e-(a==="high"?2:0);return(0,Br.jsx)(Gt,{width:u,children:(0,Br.jsxs)(rt,{wrap:"wrap",color:pt.Gray,strikethrough:r==="Canceled",children:[(0,Br.jsx)(rt,{color:c,bold:!0,children:LE(n)})," ",s]})})},OUr=()=>(0,Br.jsxs)(rt,{color:pt.Foreground,wrap:"truncate",children:[" ","\u2190"]});var npn=Dt(mr(),1);Wr();Nr();var oi=Dt(Xn(),1);var rpn=({confirmationDetails:n,config:t,isFocused:r=!0,availableTerminalHeight:a,terminalWidth:i,showTitle:s=!1})=>{let{onConfirm:e}=n,c=i-2,u=Io();(0,npn.useEffect)(()=>{r&&Cv.play("confirmation-required").catch(Y=>{console.debug("[AudioNotification] Failed to play confirmation required sound:",Y)})},[r]);let d=u.sizeLevel==="tiny"||a!==void 0&&a<=8;Ko((Y,W)=>{r&&W.escape&&e(kr.Cancel)});let I=Y=>{Cv.play("selection-made").catch(W=>{console.debug("[AudioNotification] Failed to play selection made sound:",W)}),e(Y)},h=null,o,v=new Array;function w(){if(v.length===0)throw new Error("Options not provided for confirmation message");if(a===void 0)return;let Y=2,W=1,y=1,b=1,f=d?1:v.length,g=Y+W+y+b+f;return Math.max(a-g,1)}if(n.type==="edit"){if(n.isModifying)return(0,oi.jsxs)(Gt,{minWidth:"90%",borderStyle:"round",borderColor:pt.Gray,justifyContent:"space-around",padding:1,overflow:"hidden",children:[(0,oi.jsx)(rt,{children:Ke("tool.confirmation.modifying")}),(0,oi.jsx)(rt,{color:pt.AccentGreen,children:Ke("tool.confirmation.save.editor")})]});if(o=Ke("tool.confirmation.apply.changes"),d||u.sizeLevel==="tiny"?v.push({label:"Once",value:kr.ProceedOnce},{label:"Always",value:kr.ProceedAlways},{label:"Project",value:kr.ProceedAlwaysProject},{label:"Edit",value:kr.ModifyWithEditor},{label:"Cancel",value:kr.Cancel}):v.push({label:Ke("tool.confirmation.once"),value:kr.ProceedOnce},{label:Ke("tool.confirmation.type.always"),value:kr.ProceedAlways},{label:Ke("tool.confirmation.project.always"),value:kr.ProceedAlwaysProject},{label:Ke("tool.confirmation.modify.editor"),value:kr.ModifyWithEditor},{label:l9(),value:kr.Cancel}),u.sizeLevel==="tiny"||u.sizeLevel==="small"){let Y=n.fileName||"Unknown file";h=(0,oi.jsx)(Gt,{paddingX:1,marginLeft:1,children:(0,oi.jsxs)(rt,{color:pt.AccentCyan,children:["\u{1F4DD} ",Y]})})}else h=(0,oi.jsx)(NB,{diffContent:n.fileDiff,filename:n.fileName,availableTerminalHeight:w(),terminalWidth:c})}else if(n.type==="exec"){let Y=n;o=ln("tool.confirmation.execute",{command:Y.rootCommand}),d||u.sizeLevel==="tiny"?v.push({label:"Once",value:kr.ProceedOnce},{label:"Always",value:kr.ProceedAlways},{label:"Project",value:kr.ProceedAlwaysProject},{label:"Cancel",value:kr.Cancel}):v.push({label:Ke("tool.confirmation.once"),value:kr.ProceedOnce},{label:Ke("tool.confirmation.type.always.exec"),value:kr.ProceedAlways},{label:Ke("tool.confirmation.project.always"),value:kr.ProceedAlwaysProject},{label:l9(),value:kr.Cancel});let W=w();W!==void 0&&(W-=2),h=(0,oi.jsx)(Gt,{flexDirection:"column",children:(0,oi.jsx)(Gt,{paddingX:1,marginLeft:1,children:(0,oi.jsx)(gN,{maxHeight:W,maxWidth:Math.max(c-4,1),children:(0,oi.jsx)(Gt,{children:(0,oi.jsx)(rt,{color:pt.AccentCyan,children:Y.command})})})})})}else if(n.type==="delete"){let Y=n;o=Ke("tool.confirmation.delete.file"),d||u.sizeLevel==="tiny"?v.push({label:"Once",value:kr.ProceedOnce},{label:"Always",value:kr.ProceedAlways},{label:"Project",value:kr.ProceedAlwaysProject},{label:"Cancel",value:kr.Cancel}):v.push({label:Ke("tool.confirmation.once"),value:kr.ProceedOnce},{label:Ke("tool.confirmation.type.always"),value:kr.ProceedAlways},{label:Ke("tool.confirmation.project.always"),value:kr.ProceedAlwaysProject},{label:l9(),value:kr.Cancel});let W=w();W!==void 0&&(W-=2),h=(0,oi.jsxs)(Gt,{flexDirection:"column",paddingX:1,marginLeft:1,children:[(0,oi.jsxs)(rt,{color:pt.AccentRed,children:["\u{1F5D1}\uFE0F ",Y.fileName]}),(0,oi.jsxs)(rt,{color:pt.Gray,children:["Size: ",(Y.fileSize/1024).toFixed(1)," KB"]}),Y.reason&&(0,oi.jsxs)(rt,{color:pt.AccentCyan,children:["Reason: ",Y.reason]}),(0,oi.jsx)(Gt,{marginTop:1,children:(0,oi.jsx)(gN,{maxHeight:W?Math.max(W-4,1):void 0,maxWidth:Math.max(c-4,1),children:(0,oi.jsxs)(Gt,{flexDirection:"column",children:[(0,oi.jsx)(rt,{color:pt.Gray,dimColor:!0,children:"File content preview:"}),(0,oi.jsxs)(rt,{children:[Y.fileContent.slice(0,200),Y.fileContent.length>200?"...":""]})]})})})]})}else if(n.type==="info"){let Y=n,W=Y.urls&&!(Y.urls.length===1&&Y.urls[0]===Y.prompt);o=Ke("tool.confirmation.continue"),v.push({label:Ke("tool.confirmation.once"),value:kr.ProceedOnce},{label:Ke("tool.confirmation.type.always"),value:kr.ProceedAlways},{label:Ke("tool.confirmation.project.always"),value:kr.ProceedAlwaysProject},{label:l9(),value:kr.Cancel}),h=(0,oi.jsxs)(Gt,{flexDirection:"column",paddingX:1,marginLeft:1,children:[(0,oi.jsx)(rt,{color:pt.AccentCyan,children:Y.prompt}),W&&Y.urls&&Y.urls.length>0&&(0,oi.jsxs)(Gt,{flexDirection:"column",marginTop:1,children:[(0,oi.jsx)(rt,{children:Ke("tool.confirmation.urls.label")}),Y.urls.map(y=>(0,oi.jsxs)(rt,{children:[" - ",y]},y))]})]})}else{let Y=n;h=(0,oi.jsxs)(Gt,{flexDirection:"column",paddingX:1,marginLeft:1,children:[(0,oi.jsxs)(rt,{color:pt.AccentCyan,children:[Ke("tool.confirmation.mcp.server"),Y.serverName]}),(0,oi.jsxs)(rt,{color:pt.AccentCyan,children:[Ke("tool.confirmation.mcp.tool"),Y.toolName]})]}),o=ln("tool.confirmation.mcp.execute",{toolName:Y.toolName,serverName:Y.serverName}),v.push({label:Ke("tool.confirmation.once"),value:kr.ProceedOnce},{label:ln("tool.confirmation.mcp.tool.always",{toolName:Y.toolName,serverName:Y.serverName}),value:kr.ProceedAlwaysTool},{label:ln("tool.confirmation.mcp.server.always",{serverName:Y.serverName}),value:kr.ProceedAlwaysServer},{label:Ke("tool.confirmation.project.always"),value:kr.ProceedAlwaysProject},{label:l9(),value:kr.Cancel})}let R=u.sizeLevel==="tiny"||u.sizeLevel==="small"||a!==void 0&&a<=12,E=R?0:1,A=R?0:1;if(R){let Y=u.sizeLevel==="tiny"?n.type==="edit"?"\u{1F4DD} Apply changes?":n.type==="exec"?"\u25B6 Run command?":n.type==="delete"?"\u{1F5D1}\uFE0F Delete file?":o:o;return(0,oi.jsxs)(Gt,{flexDirection:"column",width:c,children:[h&&(n.type==="edit"||n.type==="delete")&&(0,oi.jsx)(Gt,{children:h}),(0,oi.jsxs)(Gt,{flexDirection:d?"row":"column",alignItems:d?"center":"flex-start",children:[(0,oi.jsx)(Gt,{flexShrink:0,marginRight:d?2:0,children:(0,oi.jsx)(rt,{wrap:"truncate",children:Y})}),(0,oi.jsx)(Gt,{flexShrink:0,children:(0,oi.jsx)(_0,{items:v,onSelect:I,isFocused:r,showNumbers:!1,layout:d?"horizontal":"vertical",horizontalSpacing:1})})]})]})}return(0,oi.jsxs)(Gt,{flexDirection:"column",borderStyle:"round",borderColor:pt.Gray,padding:E,width:c,children:[s&&n.title&&(0,oi.jsx)(Gt,{marginBottom:A,flexShrink:0,children:(0,oi.jsx)(rt,{bold:!0,color:pt.AccentCyan,children:n.title})}),h&&(0,oi.jsx)(Gt,{flexGrow:1,flexShrink:1,overflow:"hidden",marginBottom:A,children:h}),(0,oi.jsx)(Gt,{marginBottom:A,flexShrink:0,children:(0,oi.jsx)(rt,{wrap:"truncate",children:o})}),(0,oi.jsx)(Gt,{flexShrink:0,children:(0,oi.jsx)(_0,{items:v,onSelect:I,isFocused:r,showNumbers:!d,layout:d?"horizontal":"vertical",horizontalSpacing:1})})]})};var PR=Dt(Xn(),1);var ipn=({toolCalls:n,availableTerminalHeight:t,terminalWidth:r,config:a,isFocused:i=!0})=>{let s=!n.every(A=>A.status==="Success"),e=n.some(A=>A.name===xhe),c=!e,u=s||e?pt.AccentYellow:pt.Gray,d=c?3:1,I=c?r-1-2:r-1,h=c?r-4:r-2,o=A=>{for(let Y of A){if(Y.status==="Confirming")return Y;if(Y.subToolCalls&&Y.subToolCalls.length>0){let W=o(Y.subToolCalls);if(W)return W}}},v=(0,apn.useMemo)(()=>o(n),[n]),w=0;for(let A of n)A.resultDisplay!==void 0&&A.resultDisplay!==""&&w++;let R=n.length-w,E=t?(()=>{let A=t-d-R,Y=Math.floor(A/Math.max(1,w)),W=e?20:Math.floor(t*.8);return Math.max(Math.min(Y,W),1)})():void 0;return(0,PR.jsxs)(Gt,{flexDirection:"column",borderStyle:c?"round":void 0,width:I,marginLeft:1,borderDimColor:c?s:void 0,borderColor:c?u:void 0,children:[n.map((A,Y)=>{let W=v?.callId===A.callId;return(0,PR.jsx)(Gt,{flexDirection:"column",minHeight:1,marginTop:Y>0?1:0,children:(0,PR.jsx)(Gt,{flexDirection:"row",alignItems:"center",children:(0,PR.jsx)(tpn,{callId:A.callId,name:A.name,description:A.description,resultDisplay:A.resultDisplay,status:A.status,confirmationDetails:A.confirmationDetails,availableTerminalHeight:E,terminalWidth:h,emphasis:W?"high":v?"low":"medium",renderOutputAsMarkdown:A.renderOutputAsMarkdown,forceMarkdown:A.forceMarkdown})})},A.callId)}),v&&v.confirmationDetails&&(0,PR.jsx)(Gt,{marginTop:1,children:(0,PR.jsx)(rpn,{confirmationDetails:v.confirmationDetails,config:a,isFocused:i,availableTerminalHeight:E,terminalWidth:h,showTitle:n.some(A=>A.subToolCalls?.some(Y=>Y.callId===v.callId))})})]})};var B2e=Dt(Xn(),1);var lpn=({text:n,isPending:t,availableTerminalHeight:r,terminalWidth:a})=>(0,B2e.jsx)(J2e,{preventOverflow:!0,children:(0,B2e.jsx)(Gt,{flexDirection:"column",paddingLeft:2,children:(0,B2e.jsx)(L2e,{text:n,isPending:t,availableTerminalHeight:t?r:void 0,terminalWidth:a-2})})});var jR=Dt(Xn(),1);var spn=({compression:n})=>{let t=n.isPending?"Compressing chat history":`Chat history compressed from ${n.originalTokenCount??"unknown"} to ${n.newTokenCount??"unknown"} tokens.`;return(0,jR.jsxs)(Gt,{flexDirection:"row",children:[(0,jR.jsx)(Gt,{marginRight:1,children:n.isPending?(0,jR.jsx)(FB,{type:"dots"}):(0,jR.jsx)(rt,{color:"#FF8C00",children:"\u2726"})}),(0,jR.jsx)(Gt,{children:(0,jR.jsx)(rt,{color:n.isPending?pt.AccentPurple:pt.AccentGreen,children:t})})]})};Nr();var uc=Dt(Xn(),1);var UUr=n=>{switch(n){case"darwin":return"Mac OS";case"win32":return"Windows";case"linux":return"Linux";default:return n}},opn=({cliVersion:n,osVersion:t,sandboxEnv:r})=>(0,uc.jsxs)(Gt,{borderStyle:"round",borderColor:pt.Gray,flexDirection:"column",padding:1,marginY:1,width:"100%",children:[(0,uc.jsx)(Gt,{marginBottom:1,children:(0,uc.jsx)(rt,{bold:!0,color:pt.AccentPurple,children:Ke("about.title")})}),(0,uc.jsxs)(Gt,{flexDirection:"row",children:[(0,uc.jsx)(Gt,{width:"35%",children:(0,uc.jsx)(rt,{bold:!0,color:pt.LightBlue,children:"Version"})}),(0,uc.jsx)(Gt,{children:(0,uc.jsx)(rt,{children:n})})]}),(0,uc.jsxs)(Gt,{flexDirection:"row",children:[(0,uc.jsx)(Gt,{width:"35%",children:(0,uc.jsx)(rt,{bold:!0,color:pt.LightBlue,children:"Sandbox"})}),(0,uc.jsx)(Gt,{children:(0,uc.jsx)(rt,{children:r})})]}),(0,uc.jsxs)(Gt,{flexDirection:"row",children:[(0,uc.jsx)(Gt,{width:"35%",children:(0,uc.jsx)(rt,{bold:!0,color:pt.LightBlue,children:"OS"})}),(0,uc.jsx)(Gt,{children:(0,uc.jsx)(rt,{children:UUr(t)})})]}),(0,uc.jsxs)(Gt,{flexDirection:"row",children:[(0,uc.jsx)(Gt,{width:"35%",children:(0,uc.jsx)(rt,{bold:!0,color:pt.LightBlue,children:"Web"})}),(0,uc.jsx)(Gt,{children:(0,uc.jsx)(rt,{color:pt.LightBlue,children:"https://www.deepvlab.ai/"})})]})]});function CTe(n){return n.api.totalRequests===0?0:n.api.totalErrors/n.api.totalRequests*100}function xTe(n){return n.api.totalRequests===0?0:n.api.totalLatencyMs/n.api.totalRequests}function VTe(n){return n.tokens.prompt===0?0:n.tokens.cached/n.tokens.prompt*100}var cpn=n=>{let{models:t,tools:r}=n,a=Object.values(t).reduce((w,R)=>w+R.api.totalLatencyMs,0),i=r.totalDurationMs,s=a+i,e=s>0?a/s*100:0,c=s>0?i/s*100:0,u=Object.values(t).reduce((w,R)=>w+R.tokens.cached,0),d=Object.values(t).reduce((w,R)=>w+R.tokens.prompt,0),I=d>0?u/d*100:0,h=r.totalDecisions.accept+r.totalDecisions.reject+r.totalDecisions.modify,o=r.totalCalls>0?r.totalSuccess/r.totalCalls*100:0,v=h>0?r.totalDecisions.accept/h*100:0;return{totalApiTime:a,totalToolTime:i,agentActiveTime:s,apiTimePercent:e,toolTimePercent:c,cacheEfficiency:I,totalDecisions:h,successRate:o,agreementRate:v,totalCachedTokens:u,totalPromptTokens:d}};Nr();var wi=Dt(Xn(),1);var MUr=({subAgentStats:n,subAgentUsagePercent:t,hasSubAgentActivity:r})=>{let a=Io();return!r||a.sizeLevel!=="normal"?null:(0,wi.jsxs)(Gt,{flexDirection:"column",marginTop:1,children:[(0,wi.jsx)(Gt,{marginBottom:1,children:(0,wi.jsxs)(rt,{color:pt.AccentBlue,bold:!0,children:["\u{1F4CB} ",Ke("subagent.activity")]})}),(0,wi.jsxs)(Gt,{flexDirection:"column",paddingLeft:2,children:[(0,wi.jsxs)(Gt,{marginBottom:1,children:[(0,wi.jsx)(rt,{color:pt.Gray,children:Ke("subagent.api.calls")}),(0,wi.jsx)(rt,{color:pt.Foreground,children:n.totalApiCalls}),n.totalErrors>0&&(0,wi.jsxs)(wi.Fragment,{children:[(0,wi.jsx)(rt,{color:pt.Gray,children:" ("}),(0,wi.jsxs)(rt,{color:pt.AccentRed,children:[n.totalErrors," ",Ke("subagent.errors")]}),(0,wi.jsx)(rt,{color:pt.Gray,children:")"})]})]}),(0,wi.jsxs)(Gt,{marginBottom:1,children:[(0,wi.jsx)(rt,{color:pt.Gray,children:Ke("subagent.token.usage")}),(0,wi.jsx)(rt,{color:pt.AccentYellow,children:n.totalTokens.toLocaleString()}),(0,wi.jsx)(rt,{color:pt.Gray,children:" tokens ("}),(0,wi.jsxs)(rt,{color:pt.AccentYellow,children:[t.toFixed(1),"%"]}),(0,wi.jsxs)(rt,{color:pt.Gray,children:[" ",Ke("subagent.of.total"),")"]})]}),(0,wi.jsxs)(Gt,{flexDirection:"column",paddingLeft:2,marginBottom:1,children:[(0,wi.jsxs)(Gt,{children:[(0,wi.jsxs)(rt,{color:pt.Gray,children:["\u2022 ",Ke("subagent.prompt")]}),(0,wi.jsx)(rt,{color:pt.Foreground,children:n.promptTokens.toLocaleString()})]}),(0,wi.jsxs)(Gt,{children:[(0,wi.jsxs)(rt,{color:pt.Gray,children:["\u2022 ",Ke("subagent.response")]}),(0,wi.jsx)(rt,{color:pt.Foreground,children:n.candidatesTokens.toLocaleString()})]}),n.cachedTokens>0&&(0,wi.jsxs)(Gt,{children:[(0,wi.jsxs)(rt,{color:pt.Gray,children:["\u2022 ",Ke("subagent.cached")]}),(0,wi.jsx)(rt,{color:pt.AccentGreen,children:n.cachedTokens.toLocaleString()})]}),n.thoughtsTokens>0&&(0,wi.jsxs)(Gt,{children:[(0,wi.jsxs)(rt,{color:pt.Gray,children:["\u2022 ",Ke("subagent.thoughts")]}),(0,wi.jsx)(rt,{color:pt.Foreground,children:n.thoughtsTokens.toLocaleString()})]}),n.toolTokens>0&&(0,wi.jsxs)(Gt,{children:[(0,wi.jsxs)(rt,{color:pt.Gray,children:["\u2022 ",Ke("subagent.tool")]}),(0,wi.jsx)(rt,{color:pt.Foreground,children:n.toolTokens.toLocaleString()})]})]}),(0,wi.jsxs)(Gt,{children:[(0,wi.jsx)(rt,{color:pt.Gray,children:Ke("subagent.avg.latency")}),(0,wi.jsxs)(rt,{color:pt.Foreground,children:[n.totalApiCalls>0?Math.round(n.totalLatencyMs/n.totalApiCalls):0,"ms"]})]})]})]})},Ipn=()=>{let{stats:n,computedStats:t}=V2();return(0,wi.jsx)(MUr,{subAgentStats:n.subAgentStats,subAgentUsagePercent:t.subAgentUsagePercent,hasSubAgentActivity:t.hasSubAgentActivity})};lR();Nr();var ur=Dt(Xn(),1);var HK=({title:n,children:t})=>(0,ur.jsxs)(Gt,{children:[(0,ur.jsx)(Gt,{width:28,children:(0,ur.jsx)(rt,{color:pt.LightBlue,children:n})}),t]}),upn=({title:n,children:t})=>(0,ur.jsxs)(Gt,{paddingLeft:2,children:[(0,ur.jsx)(Gt,{width:26,children:(0,ur.jsxs)(rt,{children:["\xBB ",n]})}),t]}),dpn=({title:n,children:t})=>(0,ur.jsxs)(Gt,{flexDirection:"column",width:"100%",marginBottom:1,children:[(0,ur.jsx)(rt,{bold:!0,children:n}),t]}),zUr=({models:n,totalCachedTokens:t,cacheEfficiency:r,otherCredits:a,config:i,sizeLevel:s})=>{let o=s!=="normal";return(0,ur.jsxs)(Gt,{flexDirection:"column",marginTop:1,children:[(0,ur.jsxs)(Gt,{children:[(0,ur.jsx)(Gt,{width:20,children:(0,ur.jsx)(rt,{bold:!0,children:Ke("table.header.model")})}),(0,ur.jsx)(Gt,{width:8,justifyContent:"flex-end",children:(0,ur.jsx)(rt,{bold:!0,children:Ke("table.header.reqs")})}),(0,ur.jsx)(Gt,{width:12,justifyContent:"flex-end",children:(0,ur.jsx)(rt,{bold:!0,children:Ke("table.header.input")})}),(0,ur.jsx)(Gt,{width:12,justifyContent:"flex-end",children:(0,ur.jsx)(rt,{bold:!0,children:Ke("table.header.output")})}),(0,ur.jsx)(Gt,{width:12,justifyContent:"flex-end",children:(0,ur.jsx)(rt,{bold:!0,children:Ke("table.header.cache")})}),(0,ur.jsx)(Gt,{width:10,justifyContent:"flex-end",children:(0,ur.jsx)(rt,{bold:!0,children:Ke("table.header.credits")})})]}),(0,ur.jsx)(Gt,{borderStyle:"round",borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1,width:74}),Object.entries(n).map(([v,w])=>{let R=w.tokens.cacheRead||0,E=C2(v,i),A=rV(E,o),Y=A.length>18?A.substring(0,15)+"...":A;return(0,ur.jsxs)(Gt,{children:[(0,ur.jsx)(Gt,{width:20,children:(0,ur.jsx)(rt,{color:pt.Gray,children:Y})}),(0,ur.jsx)(Gt,{width:8,justifyContent:"flex-end",children:(0,ur.jsx)(rt,{children:w.api.totalRequests})}),(0,ur.jsx)(Gt,{width:12,justifyContent:"flex-end",children:(0,ur.jsx)(rt,{color:pt.AccentYellow,children:w.tokens.prompt.toLocaleString()})}),(0,ur.jsx)(Gt,{width:12,justifyContent:"flex-end",children:(0,ur.jsx)(rt,{color:pt.AccentYellow,children:w.tokens.candidates.toLocaleString()})}),(0,ur.jsx)(Gt,{width:12,justifyContent:"flex-end",children:R>0?(0,ur.jsx)(rt,{color:pt.AccentGreen,children:R.toLocaleString()}):(0,ur.jsx)(rt,{color:pt.Gray,children:"-"})}),(0,ur.jsx)(Gt,{width:10,justifyContent:"flex-end",children:w.credits.total>0?(0,ur.jsx)(rt,{color:pt.AccentPurple,bold:!0,children:w.credits.total.toLocaleString()}):(0,ur.jsx)(rt,{color:pt.Gray,children:"-"})})]},v)}),a&&a>0?(0,ur.jsxs)(Gt,{children:[(0,ur.jsx)(Gt,{width:20,children:(0,ur.jsx)(rt,{color:pt.Gray,children:Ke("stats.other.tools")})}),(0,ur.jsx)(Gt,{width:8,justifyContent:"flex-end",children:(0,ur.jsx)(rt,{color:pt.Gray,children:"-"})}),(0,ur.jsx)(Gt,{width:12,justifyContent:"flex-end",children:(0,ur.jsx)(rt,{color:pt.Gray,children:"-"})}),(0,ur.jsx)(Gt,{width:12,justifyContent:"flex-end",children:(0,ur.jsx)(rt,{color:pt.Gray,children:"-"})}),(0,ur.jsx)(Gt,{width:12,justifyContent:"flex-end",children:(0,ur.jsx)(rt,{color:pt.Gray,children:"-"})}),(0,ur.jsx)(Gt,{width:10,justifyContent:"flex-end",children:(0,ur.jsx)(rt,{color:pt.AccentPurple,bold:!0,children:a.toLocaleString()})})]},"other-credits"):null]})},D2e=({duration:n,title:t,totalCredits:r,config:a})=>{let i=Io(),{stats:s}=V2(),{metrics:e}=s,{models:c,tools:u}=e,d=cpn(e),I=Object.values(c).reduce((Y,W)=>Y+W.credits.total,0),h=r!==void 0?Math.max(0,r-I):0,o={green:$j,yellow:eK},v={green:Wpe,yellow:Ape},w=aV(d.successRate,o),R=aV(d.agreementRate,v);if(!!!(process.env.VSCODE_PID||process.env.TERM_PROGRAM==="vscode")&&(i.sizeLevel==="small"||i.sizeLevel==="tiny")){let Y=Object.values(c).reduce((p,m)=>p+m.tokens.prompt,0),W=Object.values(c).reduce((p,m)=>p+m.tokens.candidates,0),y=Y+W,b=Object.values(c).reduce((p,m)=>p+(m.tokens.cacheRead||0),0),f=Object.values(c).reduce((p,m)=>p+m.credits.total,0),g=r!==void 0?r:f,N=d.cacheEfficiency;return(0,ur.jsx)(Gt,{flexDirection:"column",children:(0,ur.jsxs)(rt,{children:[(0,ur.jsx)(rt,{color:pt.AccentPurple,bold:!0,children:Ke("stats.compact.token.usage")})," ",Ke("stats.compact.input"),": ",(0,ur.jsx)(rt,{color:pt.AccentYellow,children:Y.toLocaleString()}),b>0&&(0,ur.jsxs)(ur.Fragment,{children:[" ",Ke("stats.compact.cache.read"),": ",(0,ur.jsx)(rt,{color:pt.AccentGreen,children:b.toLocaleString()})]})," ",Ke("stats.compact.output"),": ",(0,ur.jsx)(rt,{color:pt.AccentYellow,children:W.toLocaleString()})," ",Ke("stats.compact.total"),": ",(0,ur.jsx)(rt,{color:pt.AccentYellow,children:y.toLocaleString()}),g>0&&(0,ur.jsxs)(ur.Fragment,{children:[" ",Ke("stats.compact.credits"),": ",(0,ur.jsx)(rt,{color:pt.AccentPurple,children:g.toLocaleString()})]}),N>0&&(0,ur.jsxs)(ur.Fragment,{children:[" ",Ke("stats.compact.cache.hit.rate"),": ",(0,ur.jsxs)(rt,{color:pt.AccentGreen,children:[N.toFixed(1),"%"]})]})]})})}let A=()=>t?pt.GradientColors&&pt.GradientColors.length>0?(0,ur.jsx)(kpe,{colors:pt.GradientColors,children:(0,ur.jsx)(rt,{bold:!0,children:t})}):(0,ur.jsx)(rt,{bold:!0,color:pt.AccentPurple,children:t}):(0,ur.jsx)(rt,{bold:!0,color:pt.AccentPurple,children:Ke("stats.session.stats")});return(0,ur.jsxs)(Gt,{borderStyle:"round",borderColor:pt.Gray,flexDirection:"column",paddingY:1,paddingX:2,children:[A(),(0,ur.jsx)(Gt,{height:1}),u.totalCalls>0&&(0,ur.jsxs)(dpn,{title:Ke("section.interaction.summary"),children:[(0,ur.jsx)(HK,{title:Ke("stats.tool.calls"),children:(0,ur.jsxs)(rt,{children:[u.totalCalls," ("," ",(0,ur.jsxs)(rt,{color:pt.AccentGreen,children:["\u2714 ",u.totalSuccess]})," ",(0,ur.jsxs)(rt,{color:pt.AccentRed,children:["\u2716 ",u.totalFail]})," )"]})}),(0,ur.jsx)(HK,{title:Ke("stats.success.rate"),children:(0,ur.jsxs)(rt,{color:w,children:[d.successRate.toFixed(1),"%"]})}),d.totalDecisions>0&&(0,ur.jsx)(HK,{title:Ke("stats.user.agreement"),children:(0,ur.jsxs)(rt,{color:R,children:[d.agreementRate.toFixed(1),"%"," ",(0,ur.jsxs)(rt,{color:pt.Gray,children:["(",d.totalDecisions," ",Ke("stats.reviewed"),")"]})]})})]}),(0,ur.jsxs)(dpn,{title:Ke("section.performance"),children:[(0,ur.jsx)(HK,{title:Ke("stats.wall.time"),children:(0,ur.jsx)(rt,{children:n})}),(0,ur.jsx)(HK,{title:Ke("stats.agent.active"),children:(0,ur.jsx)(rt,{children:qd(d.agentActiveTime)})}),(0,ur.jsx)(upn,{title:Ke("stats.api.time"),children:(0,ur.jsxs)(rt,{children:[qd(d.totalApiTime)," ",(0,ur.jsxs)(rt,{color:pt.Gray,children:["(",d.apiTimePercent.toFixed(1),"%)"]})]})}),(0,ur.jsx)(upn,{title:Ke("stats.tool.time"),children:(0,ur.jsxs)(rt,{children:[qd(d.totalToolTime)," ",(0,ur.jsxs)(rt,{color:pt.Gray,children:["(",d.toolTimePercent.toFixed(1),"%)"]})]})})]}),(Object.keys(c).length>0||h!==void 0&&h>0)&&(0,ur.jsx)(zUr,{models:c,totalCachedTokens:d.totalCachedTokens,cacheEfficiency:d.cacheEfficiency,otherCredits:h,config:a,sizeLevel:i.sizeLevel}),(0,ur.jsx)(Ipn,{})]})};Nr();var xa=Dt(Xn(),1);var hpn=28,mpn=22,Mv=({title:n,values:t,isSubtle:r=!1,isSection:a=!1})=>(0,xa.jsxs)(Gt,{children:[(0,xa.jsx)(Gt,{width:hpn,children:(0,xa.jsx)(rt,{bold:a,color:a?void 0:pt.LightBlue,children:r?` \u21B3 ${n}`:n})}),t.map((i,s)=>(0,xa.jsx)(Gt,{width:mpn,children:(0,xa.jsx)(rt,{children:i})},s))]}),ppn=()=>{let n=Io(),{stats:t}=V2(),{models:r}=t.metrics,a=Object.entries(r).filter(([,I])=>I.api.totalRequests>0);if(a.length===0)return(0,xa.jsx)(Gt,{borderStyle:"round",borderColor:pt.Gray,paddingY:1,paddingX:2,children:(0,xa.jsx)(rt,{children:Ke("model.stats.no.calls")})});if(!!!(process.env.VSCODE_PID||process.env.TERM_PROGRAM==="vscode")&&(n.sizeLevel==="small"||n.sizeLevel==="tiny"))return(0,xa.jsx)(Gt,{flexDirection:"column",children:a.map(([I,h])=>{let o=CTe(h),v=xTe(h),w=VTe(h);return(0,xa.jsx)(Gt,{flexDirection:"column",children:(0,xa.jsxs)(rt,{children:[(0,xa.jsx)(rt,{color:pt.AccentPurple,bold:!0,children:I})," ",Ke("stats.compact.model.requests"),": ",(0,xa.jsx)(rt,{children:h.api.totalRequests})," ",Ke("stats.compact.input"),": ",(0,xa.jsx)(rt,{color:pt.AccentYellow,children:h.tokens.prompt.toLocaleString()}),h.tokens.cached>0&&(0,xa.jsxs)(xa.Fragment,{children:[" ",Ke("stats.compact.cache.read"),": ",(0,xa.jsx)(rt,{color:pt.AccentGreen,children:h.tokens.cached.toLocaleString()})]})," ",Ke("stats.compact.output"),": ",(0,xa.jsx)(rt,{color:pt.AccentYellow,children:h.tokens.candidates.toLocaleString()})," ",Ke("stats.compact.total"),": ",(0,xa.jsx)(rt,{color:pt.AccentYellow,children:h.tokens.total.toLocaleString()}),h.tokens.cached>0&&(0,xa.jsxs)(xa.Fragment,{children:[" ",Ke("stats.compact.cache.hit.rate"),": ",(0,xa.jsxs)(rt,{color:pt.AccentGreen,children:[w.toFixed(1),"%"]})]}),h.api.totalErrors>0&&(0,xa.jsxs)(xa.Fragment,{children:[" ",Ke("stats.compact.model.errors"),": ",(0,xa.jsxs)(rt,{color:pt.AccentRed,children:[h.api.totalErrors," (",o.toFixed(1),"%)"]})]})," ",Ke("stats.compact.model.avg.latency"),": ",(0,xa.jsx)(rt,{children:qd(v)})]})},I)})});let s=a.map(([I])=>I),e=I=>a.map(([,h])=>I(h)),c=a.some(([,I])=>I.tokens.thoughts>0),u=a.some(([,I])=>I.tokens.tool>0),d=a.some(([,I])=>I.tokens.cached>0);return(0,xa.jsxs)(Gt,{borderStyle:"round",borderColor:pt.Gray,flexDirection:"column",paddingY:1,paddingX:2,children:[(0,xa.jsx)(rt,{bold:!0,color:pt.AccentPurple,children:Ke("model.stats.title")}),(0,xa.jsx)(Gt,{height:1}),(0,xa.jsxs)(Gt,{children:[(0,xa.jsx)(Gt,{width:hpn,children:(0,xa.jsx)(rt,{bold:!0,children:Ke("model.stats.header.metric")})}),s.map((I,h)=>(0,xa.jsx)(Gt,{width:mpn,children:(0,xa.jsxs)(rt,{bold:!0,children:[Ke("model.stats.header.model"),h+1]})},I))]}),(0,xa.jsx)(Gt,{borderStyle:"single",borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,xa.jsx)(Mv,{title:Ke("model.stats.section.api"),values:[],isSection:!0}),(0,xa.jsx)(Mv,{title:Ke("model.stats.metric.requests"),values:e(I=>I.api.totalRequests.toLocaleString())}),(0,xa.jsx)(Mv,{title:Ke("model.stats.metric.errors"),values:e(I=>{let h=CTe(I);return(0,xa.jsxs)(rt,{color:I.api.totalErrors>0?pt.AccentRed:pt.Foreground,children:[I.api.totalErrors.toLocaleString()," (",h.toFixed(1),"%)"]})})}),(0,xa.jsx)(Mv,{title:Ke("model.stats.metric.avg.latency"),values:e(I=>{let h=xTe(I);return qd(h)})}),(0,xa.jsx)(Gt,{height:1}),(0,xa.jsx)(Mv,{title:Ke("model.stats.section.tokens"),values:[],isSection:!0}),(0,xa.jsx)(Mv,{title:Ke("model.stats.metric.total"),values:e(I=>(0,xa.jsx)(rt,{color:pt.AccentYellow,children:I.tokens.total.toLocaleString()}))}),(0,xa.jsx)(Mv,{title:Ke("model.stats.metric.prompt"),isSubtle:!0,values:e(I=>I.tokens.prompt.toLocaleString())}),d&&(0,xa.jsx)(Mv,{title:Ke("model.stats.metric.cache"),isSubtle:!0,values:e(I=>{let h=VTe(I);return(0,xa.jsxs)(rt,{color:pt.AccentGreen,children:[I.tokens.cached.toLocaleString()," (",h.toFixed(1),"%)"]})})}),c&&(0,xa.jsx)(Mv,{title:Ke("model.stats.metric.thoughts"),isSubtle:!0,values:e(I=>I.tokens.thoughts.toLocaleString())}),u&&(0,xa.jsx)(Mv,{title:Ke("model.stats.metric.tool"),isSubtle:!0,values:e(I=>I.tokens.tool.toLocaleString())}),(0,xa.jsx)(Mv,{title:Ke("model.stats.metric.output"),isSubtle:!0,values:e(I=>I.tokens.candidates.toLocaleString())})]})};Nr();var Vr=Dt(Xn(),1);var EV=22,wV=8,YV=12,CV=12,xV=12,_Ur=({name:n,stats:t})=>{let r=t.count>0?t.success/t.count*100:0,a=t.count>0?t.durationMs/t.count:0,i=t.responseLength,s=aV(r,{green:$j,yellow:eK});return(0,Vr.jsxs)(Gt,{children:[(0,Vr.jsx)(Gt,{width:EV,children:(0,Vr.jsx)(rt,{color:pt.LightBlue,children:n})}),(0,Vr.jsx)(Gt,{width:wV,justifyContent:"flex-end",children:(0,Vr.jsx)(rt,{children:t.count})}),(0,Vr.jsx)(Gt,{width:YV,justifyContent:"flex-end",children:(0,Vr.jsxs)(rt,{color:s,children:[r.toFixed(1),"%"]})}),(0,Vr.jsx)(Gt,{width:CV,justifyContent:"flex-end",children:(0,Vr.jsx)(rt,{children:qd(a)})}),(0,Vr.jsx)(Gt,{width:xV,justifyContent:"flex-end",children:(0,Vr.jsx)(rt,{children:VSe(i)})})]})},bpn=()=>{let n=Io(),{stats:t}=V2(),{tools:r}=t.metrics,a=Object.entries(r.byName).filter(([,d])=>d.count>0);if(a.length===0)return(0,Vr.jsx)(Gt,{borderStyle:"round",borderColor:pt.Gray,paddingY:1,paddingX:2,children:(0,Vr.jsx)(rt,{children:Ke("tool.stats.no.calls")})});let i=Object.values(r.byName).reduce((d,I)=>(d.accept+=I.decisions.accept,d.reject+=I.decisions.reject,d.modify+=I.decisions.modify,d),{accept:0,reject:0,modify:0}),s=i.accept+i.reject+i.modify,e=s>0?i.accept/s*100:0,c=aV(e,{green:Wpe,yellow:Ape});return!!!(process.env.VSCODE_PID||process.env.TERM_PROGRAM==="vscode")&&(n.sizeLevel==="small"||n.sizeLevel==="tiny")?(0,Vr.jsxs)(Gt,{flexDirection:"column",children:[(0,Vr.jsxs)(rt,{children:[(0,Vr.jsx)(rt,{color:pt.AccentPurple,bold:!0,children:Ke("stats.compact.tool.stats")})," ",Ke("stats.compact.tool.total"),": ",(0,Vr.jsx)(rt,{children:r.totalCalls})," ",Ke("stats.compact.tool.success"),": ",(0,Vr.jsx)(rt,{color:pt.AccentGreen,children:r.totalSuccess})," ",Ke("stats.compact.tool.fail"),": ",(0,Vr.jsx)(rt,{color:pt.AccentRed,children:r.totalFail}),s>0&&(0,Vr.jsxs)(Vr.Fragment,{children:[" ",Ke("stats.compact.tool.agreement"),": ",(0,Vr.jsxs)(rt,{color:c,children:[e.toFixed(1),"%"]})," ",(0,Vr.jsxs)(rt,{color:pt.Gray,children:["(",s," ",Ke("stats.compact.tool.reviewed"),")"]})]})]}),a.map(([d,I])=>{let h=I.count>0?I.success/I.count*100:0,o=I.count>0?I.durationMs/I.count:0,v=I.responseLength,w=aV(h,{green:$j,yellow:eK});return(0,Vr.jsxs)(rt,{children:[" \u2022 ",(0,Vr.jsx)(rt,{color:pt.LightBlue,children:d})," ",Ke("stats.compact.tool.calls"),": ",(0,Vr.jsx)(rt,{children:I.count})," ",Ke("stats.compact.tool.success.rate"),": ",(0,Vr.jsxs)(rt,{color:w,children:[h.toFixed(1),"%"]})," ",Ke("stats.compact.tool.avg.time"),": ",(0,Vr.jsx)(rt,{children:qd(o)})," ",Ke("stats.compact.tool.total.response.size"),": ",(0,Vr.jsx)(rt,{children:VSe(v)})]},d)})]}):(0,Vr.jsxs)(Gt,{borderStyle:"round",borderColor:pt.Gray,flexDirection:"column",paddingY:1,paddingX:2,width:82,children:[(0,Vr.jsx)(rt,{bold:!0,color:pt.AccentPurple,children:Ke("tool.stats.title")}),(0,Vr.jsx)(Gt,{height:1}),(0,Vr.jsxs)(Gt,{children:[(0,Vr.jsx)(Gt,{width:EV,children:(0,Vr.jsx)(rt,{bold:!0,children:Ke("tool.stats.header.tool.name")})}),(0,Vr.jsx)(Gt,{width:wV,justifyContent:"flex-end",children:(0,Vr.jsx)(rt,{bold:!0,children:Ke("tool.stats.header.calls")})}),(0,Vr.jsx)(Gt,{width:YV,justifyContent:"flex-end",children:(0,Vr.jsx)(rt,{bold:!0,children:Ke("tool.stats.header.success.rate")})}),(0,Vr.jsx)(Gt,{width:CV,justifyContent:"flex-end",children:(0,Vr.jsx)(rt,{bold:!0,children:Ke("tool.stats.header.avg.time")})}),(0,Vr.jsx)(Gt,{width:xV,justifyContent:"flex-end",children:(0,Vr.jsx)(rt,{bold:!0,children:Ke("tool.stats.header.response.size")})})]}),(0,Vr.jsx)(Gt,{borderStyle:"single",borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1,width:"100%"}),a.map(([d,I])=>(0,Vr.jsx)(_Ur,{name:d,stats:I},d)),(0,Vr.jsx)(Gt,{height:1}),(0,Vr.jsx)(rt,{bold:!0,children:Ke("tool.stats.decision.summary")}),(0,Vr.jsxs)(Gt,{children:[(0,Vr.jsx)(Gt,{width:EV+wV+YV+CV,children:(0,Vr.jsx)(rt,{color:pt.LightBlue,children:Ke("tool.stats.decision.reviewed.total")})}),(0,Vr.jsx)(Gt,{width:xV,justifyContent:"flex-end",children:(0,Vr.jsx)(rt,{children:s})})]}),(0,Vr.jsxs)(Gt,{children:[(0,Vr.jsx)(Gt,{width:EV+wV+YV+CV,children:(0,Vr.jsxs)(rt,{children:[" \xBB ",Ke("tool.stats.decision.accepted")]})}),(0,Vr.jsx)(Gt,{width:xV,justifyContent:"flex-end",children:(0,Vr.jsx)(rt,{color:pt.AccentGreen,children:i.accept})})]}),(0,Vr.jsxs)(Gt,{children:[(0,Vr.jsx)(Gt,{width:EV+wV+YV+CV,children:(0,Vr.jsxs)(rt,{children:[" \xBB ",Ke("tool.stats.decision.rejected")]})}),(0,Vr.jsx)(Gt,{width:xV,justifyContent:"flex-end",children:(0,Vr.jsx)(rt,{color:pt.AccentRed,children:i.reject})})]}),(0,Vr.jsxs)(Gt,{children:[(0,Vr.jsx)(Gt,{width:EV+wV+YV+CV,children:(0,Vr.jsxs)(rt,{children:[" \xBB ",Ke("tool.stats.decision.modified")]})}),(0,Vr.jsx)(Gt,{width:xV,justifyContent:"flex-end",children:(0,Vr.jsx)(rt,{color:pt.AccentYellow,children:i.modify})})]}),(0,Vr.jsx)(Gt,{borderStyle:"single",borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1,width:"100%"}),(0,Vr.jsxs)(Gt,{children:[(0,Vr.jsx)(Gt,{width:EV+wV+YV+CV,children:(0,Vr.jsxs)(rt,{children:[" ",Ke("tool.stats.decision.overall.rate")]})}),(0,Vr.jsx)(Gt,{width:xV,justifyContent:"flex-end",children:(0,Vr.jsx)(rt,{bold:!0,color:s>0?c:void 0,children:s>0?`${e.toFixed(1)}%`:"--"})})]})]})};Nr();var Ji=Dt(Xn(),1);var Gpn=({systemPromptTokens:n,userMessageTokens:t,memoryContextTokens:r,toolsTokens:a,totalInputTokens:i,maxTokens:s})=>{let e=(n/s*100).toFixed(1),c=(t/s*100).toFixed(1),u=(r/s*100).toFixed(1),d=(a/s*100).toFixed(1),I=(i/s*100).toFixed(1),h=R=>R.toLocaleString(),o=R=>R>=80?pt.AccentRed:R>=60?pt.AccentYellow:pt.AccentGreen,v=parseFloat(I),w=o(v);return(0,Ji.jsxs)(Gt,{flexDirection:"column",marginY:1,children:[(0,Ji.jsxs)(rt,{color:pt.Gray,bold:!0,children:["\u{1F4CA} ",Ke("token.breakdown.title")]}),(0,Ji.jsxs)(Gt,{marginTop:1,marginBottom:1,flexDirection:"column",children:[(0,Ji.jsxs)(Gt,{marginY:0,children:[(0,Ji.jsx)(Gt,{width:25,children:(0,Ji.jsx)(rt,{color:pt.Gray,children:Ke("token.breakdown.system")})}),(0,Ji.jsxs)(rt,{children:[h(n),"K"]}),(0,Ji.jsx)(rt,{color:pt.Gray,children:" / "}),(0,Ji.jsxs)(rt,{color:pt.AccentBlue,children:[e,"%"]})]}),(0,Ji.jsxs)(Gt,{marginY:0,children:[(0,Ji.jsx)(Gt,{width:25,children:(0,Ji.jsx)(rt,{color:pt.Gray,children:Ke("token.breakdown.user")})}),(0,Ji.jsxs)(rt,{children:[h(t),"K"]}),(0,Ji.jsx)(rt,{color:pt.Gray,children:" / "}),(0,Ji.jsxs)(rt,{color:pt.AccentBlue,children:[c,"%"]})]}),(0,Ji.jsxs)(Gt,{marginY:0,children:[(0,Ji.jsx)(Gt,{width:25,children:(0,Ji.jsx)(rt,{color:pt.Gray,children:Ke("token.breakdown.memory")})}),(0,Ji.jsxs)(rt,{children:[h(r),"K"]}),(0,Ji.jsx)(rt,{color:pt.Gray,children:" / "}),(0,Ji.jsxs)(rt,{color:pt.AccentBlue,children:[u,"%"]})]}),(0,Ji.jsxs)(Gt,{marginY:0,children:[(0,Ji.jsx)(Gt,{width:25,children:(0,Ji.jsx)(rt,{color:pt.Gray,children:Ke("token.breakdown.tools")})}),(0,Ji.jsxs)(rt,{children:[h(a),"K"]}),(0,Ji.jsx)(rt,{color:pt.Gray,children:" / "}),(0,Ji.jsxs)(rt,{color:pt.AccentBlue,children:[d,"%"]})]}),(0,Ji.jsx)(Gt,{marginY:0,children:(0,Ji.jsx)(rt,{color:pt.Gray,children:"\u2500".repeat(50)})}),(0,Ji.jsxs)(Gt,{marginY:0,children:[(0,Ji.jsx)(Gt,{width:25,children:(0,Ji.jsx)(rt,{color:pt.Gray,bold:!0,children:Ke("token.breakdown.total")})}),(0,Ji.jsxs)(rt,{bold:!0,children:[h(i),"K"]}),(0,Ji.jsx)(rt,{color:pt.Gray,children:" / "}),(0,Ji.jsxs)(rt,{color:w,bold:!0,children:[I,"%"]}),(0,Ji.jsxs)(rt,{color:pt.Gray,children:[" of ",h(s),"K limit"]})]}),v>80&&(0,Ji.jsx)(Gt,{marginTop:1,children:(0,Ji.jsx)(rt,{color:pt.AccentRed,children:"\u26A0\uFE0F Context usage is high. Consider archiving old messages or clearing memory to avoid hitting the limit."})})]})]})};var Si=Dt(Xn(),1);var fpn=({systemPromptTokens:n,systemToolsTokens:t,memoryFilesTokens:r,messagesTokens:a,reservedTokens:i,totalInputTokens:s,freeSpaceTokens:e,maxTokens:c})=>{let u=(s/c*100).toFixed(1),d=(n/c*100).toFixed(1),I=(t/c*100).toFixed(1),h=(r/c*100).toFixed(1),o=(a/c*100).toFixed(1),v=(i/c*100).toFixed(1),w=(e/c*100).toFixed(1),R=b=>{let g=Math.round(b/100*20),N=20-g,p="";for(let m=0;m<g;m++)p+="\u2588";for(let m=0;m<N;m++)p+="\u2591";return p},E=b=>(b/1e3).toFixed(1),A=parseFloat(u),Y=R(A),y=(b=>b>=80?pt.AccentRed:b>=60?pt.AccentYellow:pt.AccentGreen)(A);return(0,Si.jsxs)(Gt,{flexDirection:"column",marginY:1,children:[(0,Si.jsxs)(Gt,{children:[(0,Si.jsx)(rt,{color:pt.Gray,children:"\u{1F4BE} "}),(0,Si.jsx)(rt,{bold:!0,children:"Context Usage"}),(0,Si.jsxs)(rt,{color:pt.Gray,children:[" ",E(s),"k/"]}),(0,Si.jsxs)(rt,{color:pt.Gray,children:[E(c),"k tokens ("]}),(0,Si.jsxs)(rt,{color:y,bold:!0,children:[u,"%"]}),(0,Si.jsx)(rt,{color:pt.Gray,children:")"})]}),(0,Si.jsx)(Gt,{marginY:0,marginTop:0,children:(0,Si.jsx)(rt,{color:y,children:Y})}),(0,Si.jsxs)(Gt,{flexDirection:"column",marginTop:1,children:[(0,Si.jsxs)(Gt,{marginY:0,children:[(0,Si.jsx)(rt,{color:pt.Comment,children:"\u251C\u2500 "}),(0,Si.jsx)(rt,{color:pt.Gray,children:"System prompt: "}),(0,Si.jsxs)(rt,{color:pt.AccentBlue,children:[E(n),"k tokens"]}),(0,Si.jsxs)(rt,{color:pt.Gray,children:[" (",d,"%)"]})]}),(0,Si.jsxs)(Gt,{marginY:0,children:[(0,Si.jsx)(rt,{color:pt.Comment,children:"\u251C\u2500 "}),(0,Si.jsx)(rt,{color:pt.Gray,children:"System tools: "}),(0,Si.jsxs)(rt,{color:pt.AccentYellow,children:[E(t),"k tokens"]}),(0,Si.jsxs)(rt,{color:pt.Gray,children:[" (",I,"%)"]})]}),(0,Si.jsxs)(Gt,{marginY:0,children:[(0,Si.jsx)(rt,{color:pt.Comment,children:"\u251C\u2500 "}),(0,Si.jsx)(rt,{color:pt.Gray,children:"Memory files: "}),(0,Si.jsxs)(rt,{color:pt.AccentCyan,children:[E(r),"k tokens"]}),(0,Si.jsxs)(rt,{color:pt.Gray,children:[" (",h,"%)"]})]}),(0,Si.jsxs)(Gt,{marginY:0,children:[(0,Si.jsx)(rt,{color:pt.Comment,children:"\u251C\u2500 "}),(0,Si.jsx)(rt,{color:pt.Gray,children:"Messages: "}),(0,Si.jsxs)(rt,{color:pt.AccentPurple,children:[E(a),"k tokens"]}),(0,Si.jsxs)(rt,{color:pt.Gray,children:[" (",o,"%)"]})]}),(0,Si.jsxs)(Gt,{marginY:0,children:[(0,Si.jsx)(rt,{color:pt.Comment,children:"\u2514\u2500 "}),(0,Si.jsx)(rt,{color:pt.Gray,children:"Free space: "}),(0,Si.jsxs)(rt,{color:pt.AccentGreen,children:[E(e),"k tokens"]}),(0,Si.jsxs)(rt,{color:pt.Gray,children:[" (",w,"%)"]})]})]}),A>80&&(0,Si.jsx)(Gt,{marginTop:1,flexDirection:"column",children:(0,Si.jsx)(rt,{color:pt.AccentRed,children:"\u26A0\uFE0F High context usage detected. Use /session new to start a fresh conversation or /compress to compact current context."})})]})};Nr();var vpn=Dt(Xn(),1);var gpn=({duration:n,credits:t,config:r})=>(0,vpn.jsx)(D2e,{title:Ke("agent.powering.down"),duration:n,totalCredits:t,config:r});var o0=Dt(Xn(),1);var T2e=(0,Zpn.memo)(({item:n,availableTerminalHeight:t,terminalWidth:r,isPending:a,config:i,isFocused:s=!0})=>(0,o0.jsxs)(Gt,{flexDirection:"column",width:r,children:[n.type==="user"&&(0,o0.jsx)(Rmn,{text:n.text,terminalWidth:r}),n.type==="user_shell"&&(0,o0.jsx)(Emn,{text:n.text,terminalWidth:r}),n.type==="gemini"&&(0,o0.jsx)(zmn,{text:n.text,isPending:a,availableTerminalHeight:t,terminalWidth:r}),n.type==="gemini_content"&&(0,o0.jsx)(lpn,{text:n.text,isPending:a,availableTerminalHeight:t,terminalWidth:r}),n.type==="info"&&(0,o0.jsx)(_mn,{text:n.text}),n.type==="error"&&(0,o0.jsx)(Pmn,{text:n.text}),n.type==="about"&&(0,o0.jsx)(opn,{cliVersion:n.cliVersion,osVersion:n.osVersion,sandboxEnv:n.sandboxEnv,modelVersion:n.modelVersion,selectedAuthType:n.selectedAuthType,gcpProject:n.gcpProject}),n.type==="stats"&&(0,o0.jsx)(D2e,{duration:n.duration,config:i}),n.type==="model_stats"&&(0,o0.jsx)(ppn,{}),n.type==="tool_stats"&&(0,o0.jsx)(bpn,{}),n.type==="token_breakdown"&&(0,o0.jsx)(Gpn,{systemPromptTokens:n.systemPromptTokens,userMessageTokens:n.userMessageTokens,memoryContextTokens:n.memoryContextTokens,toolsTokens:n.toolsTokens,totalInputTokens:n.totalInputTokens,maxTokens:n.maxTokens}),n.type==="context_breakdown"&&(0,o0.jsx)(fpn,{systemPromptTokens:n.systemPromptTokens,systemToolsTokens:n.systemToolsTokens,memoryFilesTokens:n.memoryFilesTokens,messagesTokens:n.messagesTokens,reservedTokens:n.reservedTokens,totalInputTokens:n.totalInputTokens,freeSpaceTokens:n.freeSpaceTokens,maxTokens:n.maxTokens}),n.type==="quit"&&(0,o0.jsx)(gpn,{duration:n.duration,credits:n.credits,config:i}),n.type==="tool_group"&&(0,o0.jsx)(ipn,{toolCalls:n.tools,groupId:n.id,availableTerminalHeight:t,terminalWidth:r,config:i,isFocused:s}),n.type==="compression"&&(0,o0.jsx)(spn,{compression:n.compression})]},n.id),(n,t)=>n.item.id===t.item.id&&n.item.text===t.item.text&&n.isPending===t.isPending&&n.terminalWidth===t.terminalWidth&&n.isFocused===t.isFocused);Nr();var O2e=Dt(Xn(),1);var Npn=({isVisible:n,elapsed:t,estimated:r})=>{if(!n)return null;let a=to(),i=Math.max(0,r-t),s=Math.min(100,Math.round(t/r*100)),e=a?`${t}s/${r}s (${s}%)`:`${t}s/${r}s (${s}%)`;return(0,O2e.jsxs)(rt,{color:pt.AccentGreen,children:[(0,O2e.jsx)(FB,{type:"dots"})," ",e]})};iR();var XK=Dt(mr(),1);Wr();var QTe=Dt(Xn(),1);function PUr(){let n=process.env.CLI_TITLE||"\u{1F680} DeepV Code";process.stdout.write(`\x1B]2;${n}\x07`)}var Wpn=({geminiMdFileCount:n,contextFileNames:t,mcpServers:r,blockedMcpServers:a,showToolDescriptions:i,openFiles:s})=>{let e=R4e(),c=xm(),u=Object.keys(r||{}).length,d=Array.from(e.entries()).filter(([W,y])=>y===Cc.CONNECTED&&r&&W in r).length,I=Array.from(e.entries()).filter(([W,y])=>y===Cc.CONNECTING&&r&&W in r).length,h=(0,XK.useRef)(!1),o=(0,XK.useRef)(!1);(0,XK.useEffect)(()=>{if(u===0)return;c===CI.IN_PROGRESS||I>0?h.current=!0:h.current&&!o.current&&(o.current=!0,PUr())},[u,c,I]);let v=a?.length||0;if(n===0&&u===0&&v===0&&(s?.recentOpenFiles?.length??0)===0)return(0,QTe.jsx)(rt,{children:" "});let w=(()=>{let W=s?.recentOpenFiles?.length??0;return W===0?"":`${W} recent file${W>1?"s":""} (ctrl+e to view)`})(),R=(()=>{if(n===0)return"";let y=new Set(t).size<2?t[0]:"context";return`${n} ${y} file${n>1?"s":""}`})(),E=(()=>{if(u===0&&v===0)return"";let W=[];if(u>0&&(c===CI.IN_PROGRESS||I>0?W.push(`${d}/${u} MCP server${u>1?"s":""} (connecting...)`):d===u?W.push(`${d} MCP server${d>1?"s":""}`):d>0?W.push(`${d}/${u} MCP server${u>1?"s":""}`):W.push(`0/${u} MCP server${u>1?"s":""} (failed)`)),v>0){let y=`${v} Blocked`;u===0&&(y+=` MCP server${v>1?"s":""}`),W.push(y)}return W.join(", ")})(),A="Using: ",Y=[];return w&&Y.push(w),R&&Y.push(R),E&&Y.push(E),A+=Y.join(" | "),r&&Object.keys(r).length>0&&(i?A+=" (ctrl+t to toggle)":A+=" (ctrl+t to view)"),(0,QTe.jsx)(rt,{color:pt.Gray,children:A})};var VV=Dt(Xn(),1);import jUr from"node:path";function Apn({openFiles:n}){if(!n||!n.recentOpenFiles||n.recentOpenFiles.length===0)return null;let t=n.recentOpenFiles||[];return(0,VV.jsxs)(Gt,{flexDirection:"column",marginTop:1,borderStyle:"round",borderColor:pt.AccentCyan,paddingX:1,children:[(0,VV.jsx)(rt,{color:pt.AccentCyan,bold:!0,children:"IDE Context (ctrl+e to toggle)"}),t.length>0&&(0,VV.jsxs)(Gt,{flexDirection:"column",marginTop:1,children:[(0,VV.jsx)(rt,{bold:!0,children:"Recent files:"}),t.map(r=>(0,VV.jsxs)(rt,{children:["- ",jUr.basename(r.filePath),r.filePath===n.activeFile?" (active)":""]},r.filePath))]})]})}var BB=Dt(mr(),1);Nr();var U5=Dt(Xn(),1);var Fpn=({reasoning:n,terminalHeight:t,terminalWidth:r})=>{let a=HR(),[i,s]=(0,BB.useState)(!0),e=(0,BB.useRef)(null);if((0,BB.useEffect)(()=>(e.current&&(clearInterval(e.current),e.current=null),n?.text&&a==="responding"?e.current=setInterval(()=>{s(v=>!v)},1e3):s(!0),()=>{e.current&&(clearInterval(e.current),e.current=null)}),[n?.text,a]),!n?.text)return null;let c=Math.max(Math.floor(t*.2),4),u=n.text.split(`
4976
+ `);return(0,Cu.jsxs)(Gt,{flexDirection:"column",children:[(0,Cu.jsxs)(Gt,{children:[t(),r?(0,Cu.jsxs)(Cu.Fragment,{children:[(0,Cu.jsx)(rt,{color:pt.Gray,children:" \xB7 "}),(0,Cu.jsx)(rt,{color:pt.Gray,children:r})]}):null]}),(0,Cu.jsx)(Gt,{marginTop:0,marginLeft:2,children:(0,Cu.jsxs)(rt,{color:pt.Gray,wrap:"wrap",children:[e,s?(0,Cu.jsxs)(rt,{color:pt.Gray,dimColor:!0,children:[`
4977
+ `,"... (\u66F4\u591A\u601D\u8003\u5185\u5BB9)"]}):null]})}),n.isRevision||n.branchId||n.needsMoreThoughts?(0,Cu.jsxs)(Gt,{marginTop:0,marginLeft:2,flexDirection:"column",children:[n.isRevision&&n.revisesThought!==void 0?(0,Cu.jsxs)(rt,{color:pt.Gray,dimColor:!0,children:["\u21AA \u4FEE\u6B63\u6B65\u9AA4 ",n.revisesThought]}):null,n.branchId&&n.branchFromThought!==void 0?(0,Cu.jsxs)(rt,{color:pt.Gray,dimColor:!0,children:["\u21AA \u4ECE\u6B65\u9AA4 ",n.branchFromThought," \u5206\u652F (",n.branchId,")"]}):null,n.needsMoreThoughts?(0,Cu.jsx)(rt,{color:pt.Gray,dimColor:!0,children:"\u21AA \u9700\u8981\u66F4\u591A\u601D\u8003\u6B65\u9AA4"}):null]}):null]})};var SB=Dt(mr(),1);var YTe=Dt(Xn(),1);var qmn=()=>{let n=Io(),[t,r]=(0,SB.useState)(!0),a=(0,SB.useRef)(null);return(0,SB.useEffect)(()=>(a.current&&(clearInterval(a.current),a.current=null),aN(n,"spinner")||(a.current=setInterval(()=>{r(s=>!s)},500)),()=>{a.current&&(clearInterval(a.current),a.current=null)}),[n]),aN(n,"spinner")?(0,YTe.jsx)(rt,{color:pt.AccentBlue,children:"\u{1F916}"}):(0,YTe.jsx)(rt,{color:pt.AccentBlue,children:t?"\u{1F916}":" "})};Nr();var Br=Dt(Xn(),1);var kUr=1,LUr=5,S2e=3,JUr=2,$mn=1e6;function SUr(n){let t=n.split(`
4978
+ `),r=0,a=0,i=!1,s=!1;n.includes("new file mode")?i=!0:(n.includes("deleted file mode")||n.includes("--- a/")&&n.includes("+++ /dev/null"))&&(s=!0);for(let c of t)c.startsWith("+")&&!c.startsWith("+++")?r++:c.startsWith("-")&&!c.startsWith("---")&&a++;let e=Math.min(r,a);return{linesAdded:r-e,linesRemoved:a-e,linesChanged:e,isNewFile:i,isDeletedFile:s}}function BUr(n,t){if(n.isNewFile)return(0,Br.jsxs)(Gt,{children:[(0,Br.jsx)(rt,{color:pt.AccentGreen,children:"\u{1F4C4} \u65B0\u5EFA\u6587\u4EF6"}),(0,Br.jsxs)(rt,{color:pt.Gray,children:[" ",t]}),n.linesAdded>0&&(0,Br.jsxs)(rt,{color:pt.AccentGreen,children:[" (+",n.linesAdded," \u884C)"]})]});if(n.isDeletedFile)return(0,Br.jsxs)(Gt,{children:[(0,Br.jsx)(rt,{color:pt.AccentRed,children:"\u{1F5D1}\uFE0F \u5220\u9664\u6587\u4EF6"}),(0,Br.jsxs)(rt,{color:pt.Gray,children:[" ",t]}),n.linesRemoved>0&&(0,Br.jsxs)(rt,{color:pt.AccentRed,children:[" (-",n.linesRemoved," \u884C)"]})]});let r=[(0,Br.jsxs)(rt,{color:pt.Gray,children:["\u{1F4DD} ",t]},"file")];return n.linesAdded>0&&r.push((0,Br.jsxs)(rt,{color:pt.AccentGreen,children:[" +",n.linesAdded]},"added")),n.linesRemoved>0&&r.push((0,Br.jsxs)(rt,{color:pt.AccentRed,children:[" -",n.linesRemoved]},"removed")),n.linesChanged>0&&r.push((0,Br.jsxs)(rt,{color:pt.AccentYellow,children:[" M ",n.linesChanged]},"changed")),n.linesAdded===0&&n.linesRemoved===0&&n.linesChanged===0&&r.push((0,Br.jsx)(rt,{color:pt.Gray,children:" (\u65E0\u53D8\u66F4)"},"no-change")),(0,Br.jsx)(Gt,{children:r})}var tpn=({name:n,description:t,resultDisplay:r,status:a,confirmationDetails:i,availableTerminalHeight:s,terminalWidth:e,emphasis:c="medium",renderOutputAsMarkdown:u=!0,forceMarkdown:d=!1})=>{let I=Io(),h=I.sizeLevel==="small"||I.sizeLevel==="tiny",o=s?Math.max(s-kUr-LUr,JUr+1):void 0;o&&!d&&(u=!1);let v=e-3,w=n?.toLowerCase().replace(/[_-]/g,""),R=null;if(w?.includes("sequentialthinking"))try{let E=JSON.parse(t);E&&E.thought!==void 0&&(R={type:"mcp_thinking_display",thought:E.thought||"",thoughtNumber:E.thoughtNumber,totalThoughts:E.totalThoughts,nextThoughtNeeded:E.nextThoughtNeeded,isRevision:E.isRevision,revisesThought:E.revisesThought,branchFromThought:E.branchFromThought,branchId:E.branchId,needsMoreThoughts:E.needsMoreThoughts,branches:E.branches,thoughtHistoryLength:E.thoughtHistoryLength})}catch{}return typeof r=="string"&&r.length>$mn&&(r="..."+r.slice(-$mn)),(0,Br.jsxs)(Gt,{paddingX:1,paddingY:0,flexDirection:"column",width:e,children:[(0,Br.jsxs)(Gt,{minHeight:1,width:"100%",children:[(0,Br.jsx)(DUr,{status:a}),(0,Br.jsx)(TUr,{name:n,status:a,description:t,emphasis:c,terminalWidth:e-2}),c==="high"?(0,Br.jsx)(OUr,{}):null]}),R?(0,Br.jsx)(Gt,{paddingLeft:S2e,width:"100%",children:(0,Br.jsx)(Gt,{flexDirection:"column",children:(0,Br.jsxs)(Gt,{flexDirection:"row",children:[(0,Br.jsx)(rt,{color:pt.Gray,children:"\u2514 "}),(0,Br.jsx)(Gt,{flexGrow:1,children:(0,Br.jsx)(Kmn,{data:R})})]})})}):null,!R&&r?(0,Br.jsx)(Gt,{paddingLeft:S2e,width:"100%",children:(0,Br.jsxs)(Gt,{flexDirection:"column",children:[typeof r=="string"&&u?(0,Br.jsxs)(rt,{wrap:"wrap",children:[(0,Br.jsx)(rt,{color:pt.Gray,children:"\u2514 "}),r]}):null,typeof r=="string"&&!u?(()=>{let E=o!==void 0?a==="Executing"?o:o*3:20,A=iV(r,{maxRows:E,terminalWidth:v});if(A.isTruncated){let Y=A.displayText.split(A.omittedPlaceholder||"");return(0,Br.jsxs)(Gt,{flexDirection:"column",children:[(0,Br.jsxs)(rt,{wrap:"wrap",children:[(0,Br.jsx)(rt,{color:pt.Gray,children:"\u2514 "}),Y[0]]}),(0,Br.jsxs)(rt,{color:pt.Gray,wrap:"truncate",children:["... omitted ",A.omittedLines," lines ..."]}),Y[1]?(0,Br.jsx)(rt,{wrap:"wrap",children:Y[1]}):null]})}return o!==void 0?(0,Br.jsx)(gN,{maxWidth:v,maxHeight:E,overflowDirection:"top",children:(0,Br.jsx)(Gt,{children:(0,Br.jsxs)(rt,{wrap:"wrap",children:[(0,Br.jsx)(rt,{color:pt.Gray,children:"\u2514 "}),r]})})}):(0,Br.jsxs)(rt,{wrap:"wrap",children:[(0,Br.jsx)(rt,{color:pt.Gray,children:"\u2514 "}),r]})})():null,typeof r!="string"&&r.type==="todo_display"?(0,Br.jsxs)(Gt,{flexDirection:"row",children:[(0,Br.jsx)(rt,{color:pt.Gray,children:"\u2514 "}),(0,Br.jsx)(Gt,{flexGrow:1,children:(0,Br.jsx)(jmn,{data:r})})]}):null,typeof r!="string"&&r.type==="subagent_display"?(0,Br.jsxs)(Gt,{flexDirection:"row",children:[(0,Br.jsx)(rt,{color:pt.Gray,children:"\u2514 "}),(0,Br.jsx)(Gt,{flexGrow:1,children:(0,Br.jsx)(wTe,{data:r})})]}):null,typeof r!="string"&&r.type==="subagent_update"?(0,Br.jsxs)(Gt,{flexDirection:"row",children:[(0,Br.jsx)(rt,{color:pt.Gray,children:"\u2514 "}),(0,Br.jsx)(Gt,{flexGrow:1,children:(0,Br.jsx)(wTe,{data:r.data})})]}):null,typeof r!="string"&&r.fileDiff?(0,Br.jsxs)(Gt,{flexDirection:"row",children:[(0,Br.jsx)(rt,{color:pt.Gray,children:"\u2514 "}),(0,Br.jsx)(Gt,{flexGrow:1,children:h?BUr(SUr(r.fileDiff),r.fileName||"\u672A\u77E5\u6587\u4EF6"):(0,Br.jsx)(NB,{diffContent:r.fileDiff,filename:r.fileName,availableTerminalHeight:o,terminalWidth:v-2})})]}):null]})}):null]})},DUr=({status:n})=>(0,Br.jsxs)(Gt,{minWidth:S2e,children:[n==="Pending"?(0,Br.jsx)(rt,{color:pt.AccentGreen,children:"o"}):null,n==="Executing"?(0,Br.jsx)(sB,{nonRespondingDisplay:"\u22B7"}):null,n==="SubAgentRunning"?(0,Br.jsx)(qmn,{}):null,n==="Success"?(0,Br.jsx)(rt,{color:pt.AccentGreen,children:"\u25CF"}):null,n==="Confirming"?(0,Br.jsx)(rt,{color:pt.AccentYellow,children:"?"}):null,n==="Canceled"?(0,Br.jsx)(rt,{color:pt.AccentYellow,bold:!0,children:"-"}):null,n==="Error"?(0,Br.jsx)(rt,{color:pt.AccentRed,bold:!0,children:"x"}):null]}),TUr=({name:n,description:t,status:r,emphasis:a,terminalWidth:i})=>{let s=t,e=n?.toLowerCase().replace(/[_-]/g,"");if(e?.includes("sequentialthinking")&&t?.includes("thought"))try{let d=JSON.parse(t);d.thoughtNumber&&d.totalThoughts&&(s=`${to()?"\u6B65\u9AA4":"Step"} ${d.thoughtNumber}/${d.totalThoughts}`)}catch{}let c=epn.default.useMemo(()=>{switch(a){case"high":return pt.Foreground;case"medium":return pt.Foreground;case"low":return pt.Gray;default:return a}},[a]);e?.includes("sequentialthinking")&&console.log("\u{1F5BC}\uFE0F [ToolInfo] RENDERING with displayDescription:",s.substring(0,100));let u=i-S2e-(a==="high"?2:0);return(0,Br.jsx)(Gt,{width:u,children:(0,Br.jsxs)(rt,{wrap:"wrap",color:pt.Gray,strikethrough:r==="Canceled",children:[(0,Br.jsx)(rt,{color:c,bold:!0,children:LE(n)})," ",s]})})},OUr=()=>(0,Br.jsxs)(rt,{color:pt.Foreground,wrap:"truncate",children:[" ","\u2190"]});var npn=Dt(mr(),1);Wr();Nr();var oi=Dt(Xn(),1);var rpn=({confirmationDetails:n,config:t,isFocused:r=!0,availableTerminalHeight:a,terminalWidth:i,showTitle:s=!1})=>{let{onConfirm:e}=n,c=i-2,u=Io();(0,npn.useEffect)(()=>{r&&Cv.play("confirmation-required").catch(Y=>{console.debug("[AudioNotification] Failed to play confirmation required sound:",Y)})},[r]);let d=u.sizeLevel==="tiny"||a!==void 0&&a<=8;Ko((Y,W)=>{r&&W.escape&&e(kr.Cancel)});let I=Y=>{Cv.play("selection-made").catch(W=>{console.debug("[AudioNotification] Failed to play selection made sound:",W)}),e(Y)},h=null,o,v=new Array;function w(){if(v.length===0)throw new Error("Options not provided for confirmation message");if(a===void 0)return;let Y=2,W=1,y=1,b=1,f=d?1:v.length,g=Y+W+y+b+f;return Math.max(a-g,1)}if(n.type==="edit"){if(n.isModifying)return(0,oi.jsxs)(Gt,{minWidth:"90%",borderStyle:"round",borderColor:pt.Gray,justifyContent:"space-around",padding:1,overflow:"hidden",children:[(0,oi.jsx)(rt,{children:Ke("tool.confirmation.modifying")}),(0,oi.jsx)(rt,{color:pt.AccentGreen,children:Ke("tool.confirmation.save.editor")})]});if(o=Ke("tool.confirmation.apply.changes"),d||u.sizeLevel==="tiny"?v.push({label:"Once",value:kr.ProceedOnce},{label:"Always",value:kr.ProceedAlways},{label:"Project",value:kr.ProceedAlwaysProject},{label:"Edit",value:kr.ModifyWithEditor},{label:"Cancel",value:kr.Cancel}):v.push({label:Ke("tool.confirmation.once"),value:kr.ProceedOnce},{label:Ke("tool.confirmation.type.always"),value:kr.ProceedAlways},{label:Ke("tool.confirmation.project.always"),value:kr.ProceedAlwaysProject},{label:Ke("tool.confirmation.modify.editor"),value:kr.ModifyWithEditor},{label:l9(),value:kr.Cancel}),u.sizeLevel==="tiny"||u.sizeLevel==="small"){let Y=n.fileName||"Unknown file";h=(0,oi.jsx)(Gt,{paddingX:1,marginLeft:1,children:(0,oi.jsxs)(rt,{color:pt.AccentCyan,children:["\u{1F4DD} ",Y]})})}else h=(0,oi.jsx)(NB,{diffContent:n.fileDiff,filename:n.fileName,availableTerminalHeight:w(),terminalWidth:c})}else if(n.type==="exec"){let Y=n;o=ln("tool.confirmation.execute",{command:Y.rootCommand}),d||u.sizeLevel==="tiny"?v.push({label:"Once",value:kr.ProceedOnce},{label:"Always",value:kr.ProceedAlways},{label:"Project",value:kr.ProceedAlwaysProject},{label:"Cancel",value:kr.Cancel}):v.push({label:Ke("tool.confirmation.once"),value:kr.ProceedOnce},{label:Ke("tool.confirmation.type.always.exec"),value:kr.ProceedAlways},{label:Ke("tool.confirmation.project.always"),value:kr.ProceedAlwaysProject},{label:l9(),value:kr.Cancel});let W=w();W!==void 0&&(W-=2),h=(0,oi.jsx)(Gt,{flexDirection:"column",children:(0,oi.jsx)(Gt,{paddingX:1,marginLeft:1,children:(0,oi.jsx)(gN,{maxHeight:W,maxWidth:Math.max(c-4,1),children:(0,oi.jsx)(Gt,{children:(0,oi.jsx)(rt,{color:pt.AccentCyan,children:Y.command})})})})})}else if(n.type==="delete"){let Y=n;o=Ke("tool.confirmation.delete.file"),d||u.sizeLevel==="tiny"?v.push({label:"Once",value:kr.ProceedOnce},{label:"Always",value:kr.ProceedAlways},{label:"Project",value:kr.ProceedAlwaysProject},{label:"Cancel",value:kr.Cancel}):v.push({label:Ke("tool.confirmation.once"),value:kr.ProceedOnce},{label:Ke("tool.confirmation.type.always"),value:kr.ProceedAlways},{label:Ke("tool.confirmation.project.always"),value:kr.ProceedAlwaysProject},{label:l9(),value:kr.Cancel});let W=w();W!==void 0&&(W-=2),h=(0,oi.jsxs)(Gt,{flexDirection:"column",paddingX:1,marginLeft:1,children:[(0,oi.jsxs)(rt,{color:pt.AccentRed,children:["\u{1F5D1}\uFE0F ",Y.fileName]}),(0,oi.jsxs)(rt,{color:pt.Gray,children:["Size: ",(Y.fileSize/1024).toFixed(1)," KB"]}),Y.reason&&(0,oi.jsxs)(rt,{color:pt.AccentCyan,children:["Reason: ",Y.reason]}),(0,oi.jsx)(Gt,{marginTop:1,children:(0,oi.jsx)(gN,{maxHeight:W?Math.max(W-4,1):void 0,maxWidth:Math.max(c-4,1),children:(0,oi.jsxs)(Gt,{flexDirection:"column",children:[(0,oi.jsx)(rt,{color:pt.Gray,dimColor:!0,children:"File content preview:"}),(0,oi.jsxs)(rt,{children:[Y.fileContent.slice(0,200),Y.fileContent.length>200?"...":""]})]})})})]})}else if(n.type==="info"){let Y=n,W=Y.urls&&!(Y.urls.length===1&&Y.urls[0]===Y.prompt);o=Ke("tool.confirmation.continue"),v.push({label:Ke("tool.confirmation.once"),value:kr.ProceedOnce},{label:Ke("tool.confirmation.type.always"),value:kr.ProceedAlways},{label:Ke("tool.confirmation.project.always"),value:kr.ProceedAlwaysProject},{label:l9(),value:kr.Cancel}),h=(0,oi.jsxs)(Gt,{flexDirection:"column",paddingX:1,marginLeft:1,children:[(0,oi.jsx)(rt,{color:pt.AccentCyan,children:Y.prompt}),W&&Y.urls&&Y.urls.length>0&&(0,oi.jsxs)(Gt,{flexDirection:"column",marginTop:1,children:[(0,oi.jsx)(rt,{children:Ke("tool.confirmation.urls.label")}),Y.urls.map(y=>(0,oi.jsxs)(rt,{children:[" - ",y]},y))]})]})}else{let Y=n;h=(0,oi.jsxs)(Gt,{flexDirection:"column",paddingX:1,marginLeft:1,children:[(0,oi.jsxs)(rt,{color:pt.AccentCyan,children:[Ke("tool.confirmation.mcp.server"),Y.serverName]}),(0,oi.jsxs)(rt,{color:pt.AccentCyan,children:[Ke("tool.confirmation.mcp.tool"),Y.toolName]})]}),o=ln("tool.confirmation.mcp.execute",{toolName:Y.toolName,serverName:Y.serverName}),v.push({label:Ke("tool.confirmation.once"),value:kr.ProceedOnce},{label:ln("tool.confirmation.mcp.tool.always",{toolName:Y.toolName,serverName:Y.serverName}),value:kr.ProceedAlwaysTool},{label:ln("tool.confirmation.mcp.server.always",{serverName:Y.serverName}),value:kr.ProceedAlwaysServer},{label:Ke("tool.confirmation.project.always"),value:kr.ProceedAlwaysProject},{label:l9(),value:kr.Cancel})}let R=u.sizeLevel==="tiny"||u.sizeLevel==="small"||a!==void 0&&a<=12,E=R?0:1,A=R?0:1;if(R){let Y=u.sizeLevel==="tiny"?n.type==="edit"?"\u{1F4DD} Apply changes?":n.type==="exec"?"\u25B6 Run command?":n.type==="delete"?"\u{1F5D1}\uFE0F Delete file?":o:o;return(0,oi.jsxs)(Gt,{flexDirection:"column",width:c,children:[h&&(n.type==="edit"||n.type==="delete")&&(0,oi.jsx)(Gt,{children:h}),(0,oi.jsxs)(Gt,{flexDirection:d?"row":"column",alignItems:d?"center":"flex-start",children:[(0,oi.jsx)(Gt,{flexShrink:0,marginRight:d?2:0,children:(0,oi.jsx)(rt,{wrap:"truncate",children:Y})}),(0,oi.jsx)(Gt,{flexShrink:0,children:(0,oi.jsx)(_0,{items:v,onSelect:I,isFocused:r,showNumbers:!1,layout:d?"horizontal":"vertical",horizontalSpacing:1})})]})]})}return(0,oi.jsxs)(Gt,{flexDirection:"column",borderStyle:"round",borderColor:pt.Gray,padding:E,width:c,children:[s&&n.title&&(0,oi.jsx)(Gt,{marginBottom:A,flexShrink:0,children:(0,oi.jsx)(rt,{bold:!0,color:pt.AccentCyan,children:n.title})}),h&&(0,oi.jsx)(Gt,{flexGrow:1,flexShrink:1,overflow:"hidden",marginBottom:A,children:h}),(0,oi.jsx)(Gt,{marginBottom:A,flexShrink:0,children:(0,oi.jsx)(rt,{wrap:"truncate",children:o})}),(0,oi.jsx)(Gt,{flexShrink:0,children:(0,oi.jsx)(_0,{items:v,onSelect:I,isFocused:r,showNumbers:!d,layout:d?"horizontal":"vertical",horizontalSpacing:1})})]})};var PR=Dt(Xn(),1);var ipn=({toolCalls:n,availableTerminalHeight:t,terminalWidth:r,config:a,isFocused:i=!0})=>{let s=!n.every(A=>A.status==="Success"),e=n.some(A=>A.name===xhe),c=!e,u=s||e?pt.AccentYellow:pt.Gray,d=c?3:1,I=c?r-1-2:r-1,h=c?r-4:r-2,o=A=>{for(let Y of A){if(Y.status==="Confirming")return Y;if(Y.subToolCalls&&Y.subToolCalls.length>0){let W=o(Y.subToolCalls);if(W)return W}}},v=(0,apn.useMemo)(()=>o(n),[n]),w=0;for(let A of n)A.resultDisplay!==void 0&&A.resultDisplay!==""&&w++;let R=n.length-w,E=t?(()=>{let A=t-d-R,Y=Math.floor(A/Math.max(1,w)),W=e?20:Math.floor(t*.8);return Math.max(Math.min(Y,W),1)})():void 0;return(0,PR.jsxs)(Gt,{flexDirection:"column",borderStyle:c?"round":void 0,width:I,marginLeft:1,borderDimColor:c?s:void 0,borderColor:c?u:void 0,children:[n.map((A,Y)=>{let W=v?.callId===A.callId;return(0,PR.jsx)(Gt,{flexDirection:"column",minHeight:1,marginTop:Y>0?1:0,children:(0,PR.jsx)(Gt,{flexDirection:"row",alignItems:"center",children:(0,PR.jsx)(tpn,{callId:A.callId,name:A.name,description:A.description,resultDisplay:A.resultDisplay,status:A.status,confirmationDetails:A.confirmationDetails,availableTerminalHeight:E,terminalWidth:h,emphasis:W?"high":v?"low":"medium",renderOutputAsMarkdown:A.renderOutputAsMarkdown,forceMarkdown:A.forceMarkdown})})},A.callId)}),v&&v.confirmationDetails&&(0,PR.jsx)(Gt,{marginTop:1,children:(0,PR.jsx)(rpn,{confirmationDetails:v.confirmationDetails,config:a,isFocused:i,availableTerminalHeight:E,terminalWidth:h,showTitle:n.some(A=>A.subToolCalls?.some(Y=>Y.callId===v.callId))})})]})};var B2e=Dt(Xn(),1);var lpn=({text:n,isPending:t,availableTerminalHeight:r,terminalWidth:a})=>(0,B2e.jsx)(J2e,{preventOverflow:!0,children:(0,B2e.jsx)(Gt,{flexDirection:"column",paddingLeft:2,children:(0,B2e.jsx)(L2e,{text:n,isPending:t,availableTerminalHeight:t?r:void 0,terminalWidth:a-2})})});var jR=Dt(Xn(),1);var spn=({compression:n})=>{let t=n.isPending?"Compressing chat history":`Chat history compressed from ${n.originalTokenCount??"unknown"} to ${n.newTokenCount??"unknown"} tokens.`;return(0,jR.jsxs)(Gt,{flexDirection:"row",children:[(0,jR.jsx)(Gt,{marginRight:1,children:n.isPending?(0,jR.jsx)(FB,{type:"dots"}):(0,jR.jsx)(rt,{color:"#FF8C00",children:"\u2726"})}),(0,jR.jsx)(Gt,{children:(0,jR.jsx)(rt,{color:n.isPending?pt.AccentPurple:pt.AccentGreen,children:t})})]})};Nr();var uc=Dt(Xn(),1);var UUr=n=>{switch(n){case"darwin":return"Mac OS";case"win32":return"Windows";case"linux":return"Linux";default:return n}},opn=({cliVersion:n,osVersion:t,sandboxEnv:r})=>(0,uc.jsxs)(Gt,{borderStyle:"round",borderColor:pt.Gray,flexDirection:"column",padding:1,marginY:1,width:"100%",children:[(0,uc.jsx)(Gt,{marginBottom:1,children:(0,uc.jsx)(rt,{bold:!0,color:pt.AccentPurple,children:Ke("about.title")})}),(0,uc.jsxs)(Gt,{flexDirection:"row",children:[(0,uc.jsx)(Gt,{width:"35%",children:(0,uc.jsx)(rt,{bold:!0,color:pt.LightBlue,children:"Version"})}),(0,uc.jsx)(Gt,{children:(0,uc.jsx)(rt,{children:n})})]}),(0,uc.jsxs)(Gt,{flexDirection:"row",children:[(0,uc.jsx)(Gt,{width:"35%",children:(0,uc.jsx)(rt,{bold:!0,color:pt.LightBlue,children:"Sandbox"})}),(0,uc.jsx)(Gt,{children:(0,uc.jsx)(rt,{children:r})})]}),(0,uc.jsxs)(Gt,{flexDirection:"row",children:[(0,uc.jsx)(Gt,{width:"35%",children:(0,uc.jsx)(rt,{bold:!0,color:pt.LightBlue,children:"OS"})}),(0,uc.jsx)(Gt,{children:(0,uc.jsx)(rt,{children:UUr(t)})})]}),(0,uc.jsxs)(Gt,{flexDirection:"row",children:[(0,uc.jsx)(Gt,{width:"35%",children:(0,uc.jsx)(rt,{bold:!0,color:pt.LightBlue,children:"Web"})}),(0,uc.jsx)(Gt,{children:(0,uc.jsx)(rt,{color:pt.LightBlue,children:"https://www.deepvlab.ai/"})})]})]});function CTe(n){return n.api.totalRequests===0?0:n.api.totalErrors/n.api.totalRequests*100}function xTe(n){return n.api.totalRequests===0?0:n.api.totalLatencyMs/n.api.totalRequests}function VTe(n){return n.tokens.prompt===0?0:n.tokens.cached/n.tokens.prompt*100}var cpn=n=>{let{models:t,tools:r}=n,a=Object.values(t).reduce((w,R)=>w+R.api.totalLatencyMs,0),i=r.totalDurationMs,s=a+i,e=s>0?a/s*100:0,c=s>0?i/s*100:0,u=Object.values(t).reduce((w,R)=>w+R.tokens.cached,0),d=Object.values(t).reduce((w,R)=>w+R.tokens.prompt,0),I=d>0?u/d*100:0,h=r.totalDecisions.accept+r.totalDecisions.reject+r.totalDecisions.modify,o=r.totalCalls>0?r.totalSuccess/r.totalCalls*100:0,v=h>0?r.totalDecisions.accept/h*100:0;return{totalApiTime:a,totalToolTime:i,agentActiveTime:s,apiTimePercent:e,toolTimePercent:c,cacheEfficiency:I,totalDecisions:h,successRate:o,agreementRate:v,totalCachedTokens:u,totalPromptTokens:d}};Nr();var wi=Dt(Xn(),1);var MUr=({subAgentStats:n,subAgentUsagePercent:t,hasSubAgentActivity:r})=>{let a=Io();return!r||a.sizeLevel!=="normal"?null:(0,wi.jsxs)(Gt,{flexDirection:"column",marginTop:1,children:[(0,wi.jsx)(Gt,{marginBottom:1,children:(0,wi.jsxs)(rt,{color:pt.AccentBlue,bold:!0,children:["\u{1F4CB} ",Ke("subagent.activity")]})}),(0,wi.jsxs)(Gt,{flexDirection:"column",paddingLeft:2,children:[(0,wi.jsxs)(Gt,{marginBottom:1,children:[(0,wi.jsx)(rt,{color:pt.Gray,children:Ke("subagent.api.calls")}),(0,wi.jsx)(rt,{color:pt.Foreground,children:n.totalApiCalls}),n.totalErrors>0&&(0,wi.jsxs)(wi.Fragment,{children:[(0,wi.jsx)(rt,{color:pt.Gray,children:" ("}),(0,wi.jsxs)(rt,{color:pt.AccentRed,children:[n.totalErrors," ",Ke("subagent.errors")]}),(0,wi.jsx)(rt,{color:pt.Gray,children:")"})]})]}),(0,wi.jsxs)(Gt,{marginBottom:1,children:[(0,wi.jsx)(rt,{color:pt.Gray,children:Ke("subagent.token.usage")}),(0,wi.jsx)(rt,{color:pt.AccentYellow,children:n.totalTokens.toLocaleString()}),(0,wi.jsx)(rt,{color:pt.Gray,children:" tokens ("}),(0,wi.jsxs)(rt,{color:pt.AccentYellow,children:[t.toFixed(1),"%"]}),(0,wi.jsxs)(rt,{color:pt.Gray,children:[" ",Ke("subagent.of.total"),")"]})]}),(0,wi.jsxs)(Gt,{flexDirection:"column",paddingLeft:2,marginBottom:1,children:[(0,wi.jsxs)(Gt,{children:[(0,wi.jsxs)(rt,{color:pt.Gray,children:["\u2022 ",Ke("subagent.prompt")]}),(0,wi.jsx)(rt,{color:pt.Foreground,children:n.promptTokens.toLocaleString()})]}),(0,wi.jsxs)(Gt,{children:[(0,wi.jsxs)(rt,{color:pt.Gray,children:["\u2022 ",Ke("subagent.response")]}),(0,wi.jsx)(rt,{color:pt.Foreground,children:n.candidatesTokens.toLocaleString()})]}),n.cachedTokens>0&&(0,wi.jsxs)(Gt,{children:[(0,wi.jsxs)(rt,{color:pt.Gray,children:["\u2022 ",Ke("subagent.cached")]}),(0,wi.jsx)(rt,{color:pt.AccentGreen,children:n.cachedTokens.toLocaleString()})]}),n.thoughtsTokens>0&&(0,wi.jsxs)(Gt,{children:[(0,wi.jsxs)(rt,{color:pt.Gray,children:["\u2022 ",Ke("subagent.thoughts")]}),(0,wi.jsx)(rt,{color:pt.Foreground,children:n.thoughtsTokens.toLocaleString()})]}),n.toolTokens>0&&(0,wi.jsxs)(Gt,{children:[(0,wi.jsxs)(rt,{color:pt.Gray,children:["\u2022 ",Ke("subagent.tool")]}),(0,wi.jsx)(rt,{color:pt.Foreground,children:n.toolTokens.toLocaleString()})]})]}),(0,wi.jsxs)(Gt,{children:[(0,wi.jsx)(rt,{color:pt.Gray,children:Ke("subagent.avg.latency")}),(0,wi.jsxs)(rt,{color:pt.Foreground,children:[n.totalApiCalls>0?Math.round(n.totalLatencyMs/n.totalApiCalls):0,"ms"]})]})]})]})},Ipn=()=>{let{stats:n,computedStats:t}=V2();return(0,wi.jsx)(MUr,{subAgentStats:n.subAgentStats,subAgentUsagePercent:t.subAgentUsagePercent,hasSubAgentActivity:t.hasSubAgentActivity})};lR();Nr();var ur=Dt(Xn(),1);var HK=({title:n,children:t})=>(0,ur.jsxs)(Gt,{children:[(0,ur.jsx)(Gt,{width:28,children:(0,ur.jsx)(rt,{color:pt.LightBlue,children:n})}),t]}),upn=({title:n,children:t})=>(0,ur.jsxs)(Gt,{paddingLeft:2,children:[(0,ur.jsx)(Gt,{width:26,children:(0,ur.jsxs)(rt,{children:["\xBB ",n]})}),t]}),dpn=({title:n,children:t})=>(0,ur.jsxs)(Gt,{flexDirection:"column",width:"100%",marginBottom:1,children:[(0,ur.jsx)(rt,{bold:!0,children:n}),t]}),zUr=({models:n,totalCachedTokens:t,cacheEfficiency:r,otherCredits:a,config:i,sizeLevel:s})=>{let o=s!=="normal";return(0,ur.jsxs)(Gt,{flexDirection:"column",marginTop:1,children:[(0,ur.jsxs)(Gt,{children:[(0,ur.jsx)(Gt,{width:20,children:(0,ur.jsx)(rt,{bold:!0,children:Ke("table.header.model")})}),(0,ur.jsx)(Gt,{width:8,justifyContent:"flex-end",children:(0,ur.jsx)(rt,{bold:!0,children:Ke("table.header.reqs")})}),(0,ur.jsx)(Gt,{width:12,justifyContent:"flex-end",children:(0,ur.jsx)(rt,{bold:!0,children:Ke("table.header.input")})}),(0,ur.jsx)(Gt,{width:12,justifyContent:"flex-end",children:(0,ur.jsx)(rt,{bold:!0,children:Ke("table.header.output")})}),(0,ur.jsx)(Gt,{width:12,justifyContent:"flex-end",children:(0,ur.jsx)(rt,{bold:!0,children:Ke("table.header.cache")})}),(0,ur.jsx)(Gt,{width:10,justifyContent:"flex-end",children:(0,ur.jsx)(rt,{bold:!0,children:Ke("table.header.credits")})})]}),(0,ur.jsx)(Gt,{borderStyle:"round",borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1,width:74}),Object.entries(n).map(([v,w])=>{let R=w.tokens.cacheRead||0,E=C2(v,i),A=rV(E,o),Y=A.length>18?A.substring(0,15)+"...":A;return(0,ur.jsxs)(Gt,{children:[(0,ur.jsx)(Gt,{width:20,children:(0,ur.jsx)(rt,{color:pt.Gray,children:Y})}),(0,ur.jsx)(Gt,{width:8,justifyContent:"flex-end",children:(0,ur.jsx)(rt,{children:w.api.totalRequests})}),(0,ur.jsx)(Gt,{width:12,justifyContent:"flex-end",children:(0,ur.jsx)(rt,{color:pt.AccentYellow,children:w.tokens.prompt.toLocaleString()})}),(0,ur.jsx)(Gt,{width:12,justifyContent:"flex-end",children:(0,ur.jsx)(rt,{color:pt.AccentYellow,children:w.tokens.candidates.toLocaleString()})}),(0,ur.jsx)(Gt,{width:12,justifyContent:"flex-end",children:R>0?(0,ur.jsx)(rt,{color:pt.AccentGreen,children:R.toLocaleString()}):(0,ur.jsx)(rt,{color:pt.Gray,children:"-"})}),(0,ur.jsx)(Gt,{width:10,justifyContent:"flex-end",children:w.credits.total>0?(0,ur.jsx)(rt,{color:pt.AccentPurple,bold:!0,children:w.credits.total.toLocaleString()}):(0,ur.jsx)(rt,{color:pt.Gray,children:"-"})})]},v)}),a&&a>0?(0,ur.jsxs)(Gt,{children:[(0,ur.jsx)(Gt,{width:20,children:(0,ur.jsx)(rt,{color:pt.Gray,children:Ke("stats.other.tools")})}),(0,ur.jsx)(Gt,{width:8,justifyContent:"flex-end",children:(0,ur.jsx)(rt,{color:pt.Gray,children:"-"})}),(0,ur.jsx)(Gt,{width:12,justifyContent:"flex-end",children:(0,ur.jsx)(rt,{color:pt.Gray,children:"-"})}),(0,ur.jsx)(Gt,{width:12,justifyContent:"flex-end",children:(0,ur.jsx)(rt,{color:pt.Gray,children:"-"})}),(0,ur.jsx)(Gt,{width:12,justifyContent:"flex-end",children:(0,ur.jsx)(rt,{color:pt.Gray,children:"-"})}),(0,ur.jsx)(Gt,{width:10,justifyContent:"flex-end",children:(0,ur.jsx)(rt,{color:pt.AccentPurple,bold:!0,children:a.toLocaleString()})})]},"other-credits"):null]})},D2e=({duration:n,title:t,totalCredits:r,config:a})=>{let i=Io(),{stats:s}=V2(),{metrics:e}=s,{models:c,tools:u}=e,d=cpn(e),I=Object.values(c).reduce((Y,W)=>Y+W.credits.total,0),h=r!==void 0?Math.max(0,r-I):0,o={green:$j,yellow:eK},v={green:Wpe,yellow:Ape},w=aV(d.successRate,o),R=aV(d.agreementRate,v);if(!!!(process.env.VSCODE_PID||process.env.TERM_PROGRAM==="vscode")&&(i.sizeLevel==="small"||i.sizeLevel==="tiny")){let Y=Object.values(c).reduce((p,m)=>p+m.tokens.prompt,0),W=Object.values(c).reduce((p,m)=>p+m.tokens.candidates,0),y=Y+W,b=Object.values(c).reduce((p,m)=>p+(m.tokens.cacheRead||0),0),f=Object.values(c).reduce((p,m)=>p+m.credits.total,0),g=r!==void 0?r:f,N=d.cacheEfficiency;return(0,ur.jsx)(Gt,{flexDirection:"column",children:(0,ur.jsxs)(rt,{children:[(0,ur.jsx)(rt,{color:pt.AccentPurple,bold:!0,children:Ke("stats.compact.token.usage")})," ",Ke("stats.compact.input"),": ",(0,ur.jsx)(rt,{color:pt.AccentYellow,children:Y.toLocaleString()}),b>0&&(0,ur.jsxs)(ur.Fragment,{children:[" ",Ke("stats.compact.cache.read"),": ",(0,ur.jsx)(rt,{color:pt.AccentGreen,children:b.toLocaleString()})]})," ",Ke("stats.compact.output"),": ",(0,ur.jsx)(rt,{color:pt.AccentYellow,children:W.toLocaleString()})," ",Ke("stats.compact.total"),": ",(0,ur.jsx)(rt,{color:pt.AccentYellow,children:y.toLocaleString()}),g>0&&(0,ur.jsxs)(ur.Fragment,{children:[" ",Ke("stats.compact.credits"),": ",(0,ur.jsx)(rt,{color:pt.AccentPurple,children:g.toLocaleString()})]}),N>0&&(0,ur.jsxs)(ur.Fragment,{children:[" ",Ke("stats.compact.cache.hit.rate"),": ",(0,ur.jsxs)(rt,{color:pt.AccentGreen,children:[N.toFixed(1),"%"]})]})]})})}let A=()=>t?pt.GradientColors&&pt.GradientColors.length>0?(0,ur.jsx)(kpe,{colors:pt.GradientColors,children:(0,ur.jsx)(rt,{bold:!0,children:t})}):(0,ur.jsx)(rt,{bold:!0,color:pt.AccentPurple,children:t}):(0,ur.jsx)(rt,{bold:!0,color:pt.AccentPurple,children:Ke("stats.session.stats")});return(0,ur.jsxs)(Gt,{borderStyle:"round",borderColor:pt.Gray,flexDirection:"column",paddingY:1,paddingX:2,children:[A(),(0,ur.jsx)(Gt,{height:1}),u.totalCalls>0?(0,ur.jsxs)(dpn,{title:Ke("section.interaction.summary"),children:[(0,ur.jsx)(HK,{title:Ke("stats.tool.calls"),children:(0,ur.jsxs)(rt,{children:[u.totalCalls," ("," ",(0,ur.jsxs)(rt,{color:pt.AccentGreen,children:["\u2714 ",u.totalSuccess]})," ",(0,ur.jsxs)(rt,{color:pt.AccentRed,children:["\u2716 ",u.totalFail]})," )"]})}),(0,ur.jsx)(HK,{title:Ke("stats.success.rate"),children:(0,ur.jsxs)(rt,{color:w,children:[d.successRate.toFixed(1),"%"]})}),d.totalDecisions>0?(0,ur.jsx)(HK,{title:Ke("stats.user.agreement"),children:(0,ur.jsxs)(rt,{color:R,children:[d.agreementRate.toFixed(1),"%"," ",(0,ur.jsxs)(rt,{color:pt.Gray,children:["(",d.totalDecisions," ",Ke("stats.reviewed"),")"]})]})}):null]}):null,(0,ur.jsxs)(dpn,{title:Ke("section.performance"),children:[(0,ur.jsx)(HK,{title:Ke("stats.wall.time"),children:(0,ur.jsx)(rt,{children:n})}),(0,ur.jsx)(HK,{title:Ke("stats.agent.active"),children:(0,ur.jsx)(rt,{children:qd(d.agentActiveTime)})}),(0,ur.jsx)(upn,{title:Ke("stats.api.time"),children:(0,ur.jsxs)(rt,{children:[qd(d.totalApiTime)," ",(0,ur.jsxs)(rt,{color:pt.Gray,children:["(",d.apiTimePercent.toFixed(1),"%)"]})]})}),(0,ur.jsx)(upn,{title:Ke("stats.tool.time"),children:(0,ur.jsxs)(rt,{children:[qd(d.totalToolTime)," ",(0,ur.jsxs)(rt,{color:pt.Gray,children:["(",d.toolTimePercent.toFixed(1),"%)"]})]})})]}),Object.keys(c).length>0||h!==void 0&&h>0?(0,ur.jsx)(zUr,{models:c,totalCachedTokens:d.totalCachedTokens,cacheEfficiency:d.cacheEfficiency,otherCredits:h,config:a,sizeLevel:i.sizeLevel}):null,(0,ur.jsx)(Ipn,{})]})};Nr();var xa=Dt(Xn(),1);var hpn=28,mpn=22,Mv=({title:n,values:t,isSubtle:r=!1,isSection:a=!1})=>(0,xa.jsxs)(Gt,{children:[(0,xa.jsx)(Gt,{width:hpn,children:(0,xa.jsx)(rt,{bold:a,color:a?void 0:pt.LightBlue,children:r?` \u21B3 ${n}`:n})}),t.map((i,s)=>(0,xa.jsx)(Gt,{width:mpn,children:(0,xa.jsx)(rt,{children:i})},s))]}),ppn=()=>{let n=Io(),{stats:t}=V2(),{models:r}=t.metrics,a=Object.entries(r).filter(([,I])=>I.api.totalRequests>0);if(a.length===0)return(0,xa.jsx)(Gt,{borderStyle:"round",borderColor:pt.Gray,paddingY:1,paddingX:2,children:(0,xa.jsx)(rt,{children:Ke("model.stats.no.calls")})});if(!!!(process.env.VSCODE_PID||process.env.TERM_PROGRAM==="vscode")&&(n.sizeLevel==="small"||n.sizeLevel==="tiny"))return(0,xa.jsx)(Gt,{flexDirection:"column",children:a.map(([I,h])=>{let o=CTe(h),v=xTe(h),w=VTe(h);return(0,xa.jsx)(Gt,{flexDirection:"column",children:(0,xa.jsxs)(rt,{children:[(0,xa.jsx)(rt,{color:pt.AccentPurple,bold:!0,children:I})," ",Ke("stats.compact.model.requests"),": ",(0,xa.jsx)(rt,{children:h.api.totalRequests})," ",Ke("stats.compact.input"),": ",(0,xa.jsx)(rt,{color:pt.AccentYellow,children:h.tokens.prompt.toLocaleString()}),h.tokens.cached>0&&(0,xa.jsxs)(xa.Fragment,{children:[" ",Ke("stats.compact.cache.read"),": ",(0,xa.jsx)(rt,{color:pt.AccentGreen,children:h.tokens.cached.toLocaleString()})]})," ",Ke("stats.compact.output"),": ",(0,xa.jsx)(rt,{color:pt.AccentYellow,children:h.tokens.candidates.toLocaleString()})," ",Ke("stats.compact.total"),": ",(0,xa.jsx)(rt,{color:pt.AccentYellow,children:h.tokens.total.toLocaleString()}),h.tokens.cached>0&&(0,xa.jsxs)(xa.Fragment,{children:[" ",Ke("stats.compact.cache.hit.rate"),": ",(0,xa.jsxs)(rt,{color:pt.AccentGreen,children:[w.toFixed(1),"%"]})]}),h.api.totalErrors>0&&(0,xa.jsxs)(xa.Fragment,{children:[" ",Ke("stats.compact.model.errors"),": ",(0,xa.jsxs)(rt,{color:pt.AccentRed,children:[h.api.totalErrors," (",o.toFixed(1),"%)"]})]})," ",Ke("stats.compact.model.avg.latency"),": ",(0,xa.jsx)(rt,{children:qd(v)})]})},I)})});let s=a.map(([I])=>I),e=I=>a.map(([,h])=>I(h)),c=a.some(([,I])=>I.tokens.thoughts>0),u=a.some(([,I])=>I.tokens.tool>0),d=a.some(([,I])=>I.tokens.cached>0);return(0,xa.jsxs)(Gt,{borderStyle:"round",borderColor:pt.Gray,flexDirection:"column",paddingY:1,paddingX:2,children:[(0,xa.jsx)(rt,{bold:!0,color:pt.AccentPurple,children:Ke("model.stats.title")}),(0,xa.jsx)(Gt,{height:1}),(0,xa.jsxs)(Gt,{children:[(0,xa.jsx)(Gt,{width:hpn,children:(0,xa.jsx)(rt,{bold:!0,children:Ke("model.stats.header.metric")})}),s.map((I,h)=>(0,xa.jsx)(Gt,{width:mpn,children:(0,xa.jsxs)(rt,{bold:!0,children:[Ke("model.stats.header.model"),h+1]})},I))]}),(0,xa.jsx)(Gt,{borderStyle:"single",borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,xa.jsx)(Mv,{title:Ke("model.stats.section.api"),values:[],isSection:!0}),(0,xa.jsx)(Mv,{title:Ke("model.stats.metric.requests"),values:e(I=>I.api.totalRequests.toLocaleString())}),(0,xa.jsx)(Mv,{title:Ke("model.stats.metric.errors"),values:e(I=>{let h=CTe(I);return(0,xa.jsxs)(rt,{color:I.api.totalErrors>0?pt.AccentRed:pt.Foreground,children:[I.api.totalErrors.toLocaleString()," (",h.toFixed(1),"%)"]})})}),(0,xa.jsx)(Mv,{title:Ke("model.stats.metric.avg.latency"),values:e(I=>{let h=xTe(I);return qd(h)})}),(0,xa.jsx)(Gt,{height:1}),(0,xa.jsx)(Mv,{title:Ke("model.stats.section.tokens"),values:[],isSection:!0}),(0,xa.jsx)(Mv,{title:Ke("model.stats.metric.total"),values:e(I=>(0,xa.jsx)(rt,{color:pt.AccentYellow,children:I.tokens.total.toLocaleString()}))}),(0,xa.jsx)(Mv,{title:Ke("model.stats.metric.prompt"),isSubtle:!0,values:e(I=>I.tokens.prompt.toLocaleString())}),d&&(0,xa.jsx)(Mv,{title:Ke("model.stats.metric.cache"),isSubtle:!0,values:e(I=>{let h=VTe(I);return(0,xa.jsxs)(rt,{color:pt.AccentGreen,children:[I.tokens.cached.toLocaleString()," (",h.toFixed(1),"%)"]})})}),c&&(0,xa.jsx)(Mv,{title:Ke("model.stats.metric.thoughts"),isSubtle:!0,values:e(I=>I.tokens.thoughts.toLocaleString())}),u&&(0,xa.jsx)(Mv,{title:Ke("model.stats.metric.tool"),isSubtle:!0,values:e(I=>I.tokens.tool.toLocaleString())}),(0,xa.jsx)(Mv,{title:Ke("model.stats.metric.output"),isSubtle:!0,values:e(I=>I.tokens.candidates.toLocaleString())})]})};Nr();var Vr=Dt(Xn(),1);var EV=22,wV=8,YV=12,CV=12,xV=12,_Ur=({name:n,stats:t})=>{let r=t.count>0?t.success/t.count*100:0,a=t.count>0?t.durationMs/t.count:0,i=t.responseLength,s=aV(r,{green:$j,yellow:eK});return(0,Vr.jsxs)(Gt,{children:[(0,Vr.jsx)(Gt,{width:EV,children:(0,Vr.jsx)(rt,{color:pt.LightBlue,children:n})}),(0,Vr.jsx)(Gt,{width:wV,justifyContent:"flex-end",children:(0,Vr.jsx)(rt,{children:t.count})}),(0,Vr.jsx)(Gt,{width:YV,justifyContent:"flex-end",children:(0,Vr.jsxs)(rt,{color:s,children:[r.toFixed(1),"%"]})}),(0,Vr.jsx)(Gt,{width:CV,justifyContent:"flex-end",children:(0,Vr.jsx)(rt,{children:qd(a)})}),(0,Vr.jsx)(Gt,{width:xV,justifyContent:"flex-end",children:(0,Vr.jsx)(rt,{children:VSe(i)})})]})},bpn=()=>{let n=Io(),{stats:t}=V2(),{tools:r}=t.metrics,a=Object.entries(r.byName).filter(([,d])=>d.count>0);if(a.length===0)return(0,Vr.jsx)(Gt,{borderStyle:"round",borderColor:pt.Gray,paddingY:1,paddingX:2,children:(0,Vr.jsx)(rt,{children:Ke("tool.stats.no.calls")})});let i=Object.values(r.byName).reduce((d,I)=>(d.accept+=I.decisions.accept,d.reject+=I.decisions.reject,d.modify+=I.decisions.modify,d),{accept:0,reject:0,modify:0}),s=i.accept+i.reject+i.modify,e=s>0?i.accept/s*100:0,c=aV(e,{green:Wpe,yellow:Ape});return!!!(process.env.VSCODE_PID||process.env.TERM_PROGRAM==="vscode")&&(n.sizeLevel==="small"||n.sizeLevel==="tiny")?(0,Vr.jsxs)(Gt,{flexDirection:"column",children:[(0,Vr.jsxs)(rt,{children:[(0,Vr.jsx)(rt,{color:pt.AccentPurple,bold:!0,children:Ke("stats.compact.tool.stats")})," ",Ke("stats.compact.tool.total"),": ",(0,Vr.jsx)(rt,{children:r.totalCalls})," ",Ke("stats.compact.tool.success"),": ",(0,Vr.jsx)(rt,{color:pt.AccentGreen,children:r.totalSuccess})," ",Ke("stats.compact.tool.fail"),": ",(0,Vr.jsx)(rt,{color:pt.AccentRed,children:r.totalFail}),s>0&&(0,Vr.jsxs)(Vr.Fragment,{children:[" ",Ke("stats.compact.tool.agreement"),": ",(0,Vr.jsxs)(rt,{color:c,children:[e.toFixed(1),"%"]})," ",(0,Vr.jsxs)(rt,{color:pt.Gray,children:["(",s," ",Ke("stats.compact.tool.reviewed"),")"]})]})]}),a.map(([d,I])=>{let h=I.count>0?I.success/I.count*100:0,o=I.count>0?I.durationMs/I.count:0,v=I.responseLength,w=aV(h,{green:$j,yellow:eK});return(0,Vr.jsxs)(rt,{children:[" \u2022 ",(0,Vr.jsx)(rt,{color:pt.LightBlue,children:d})," ",Ke("stats.compact.tool.calls"),": ",(0,Vr.jsx)(rt,{children:I.count})," ",Ke("stats.compact.tool.success.rate"),": ",(0,Vr.jsxs)(rt,{color:w,children:[h.toFixed(1),"%"]})," ",Ke("stats.compact.tool.avg.time"),": ",(0,Vr.jsx)(rt,{children:qd(o)})," ",Ke("stats.compact.tool.total.response.size"),": ",(0,Vr.jsx)(rt,{children:VSe(v)})]},d)})]}):(0,Vr.jsxs)(Gt,{borderStyle:"round",borderColor:pt.Gray,flexDirection:"column",paddingY:1,paddingX:2,width:82,children:[(0,Vr.jsx)(rt,{bold:!0,color:pt.AccentPurple,children:Ke("tool.stats.title")}),(0,Vr.jsx)(Gt,{height:1}),(0,Vr.jsxs)(Gt,{children:[(0,Vr.jsx)(Gt,{width:EV,children:(0,Vr.jsx)(rt,{bold:!0,children:Ke("tool.stats.header.tool.name")})}),(0,Vr.jsx)(Gt,{width:wV,justifyContent:"flex-end",children:(0,Vr.jsx)(rt,{bold:!0,children:Ke("tool.stats.header.calls")})}),(0,Vr.jsx)(Gt,{width:YV,justifyContent:"flex-end",children:(0,Vr.jsx)(rt,{bold:!0,children:Ke("tool.stats.header.success.rate")})}),(0,Vr.jsx)(Gt,{width:CV,justifyContent:"flex-end",children:(0,Vr.jsx)(rt,{bold:!0,children:Ke("tool.stats.header.avg.time")})}),(0,Vr.jsx)(Gt,{width:xV,justifyContent:"flex-end",children:(0,Vr.jsx)(rt,{bold:!0,children:Ke("tool.stats.header.response.size")})})]}),(0,Vr.jsx)(Gt,{borderStyle:"single",borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1,width:"100%"}),a.map(([d,I])=>(0,Vr.jsx)(_Ur,{name:d,stats:I},d)),(0,Vr.jsx)(Gt,{height:1}),(0,Vr.jsx)(rt,{bold:!0,children:Ke("tool.stats.decision.summary")}),(0,Vr.jsxs)(Gt,{children:[(0,Vr.jsx)(Gt,{width:EV+wV+YV+CV,children:(0,Vr.jsx)(rt,{color:pt.LightBlue,children:Ke("tool.stats.decision.reviewed.total")})}),(0,Vr.jsx)(Gt,{width:xV,justifyContent:"flex-end",children:(0,Vr.jsx)(rt,{children:s})})]}),(0,Vr.jsxs)(Gt,{children:[(0,Vr.jsx)(Gt,{width:EV+wV+YV+CV,children:(0,Vr.jsxs)(rt,{children:[" \xBB ",Ke("tool.stats.decision.accepted")]})}),(0,Vr.jsx)(Gt,{width:xV,justifyContent:"flex-end",children:(0,Vr.jsx)(rt,{color:pt.AccentGreen,children:i.accept})})]}),(0,Vr.jsxs)(Gt,{children:[(0,Vr.jsx)(Gt,{width:EV+wV+YV+CV,children:(0,Vr.jsxs)(rt,{children:[" \xBB ",Ke("tool.stats.decision.rejected")]})}),(0,Vr.jsx)(Gt,{width:xV,justifyContent:"flex-end",children:(0,Vr.jsx)(rt,{color:pt.AccentRed,children:i.reject})})]}),(0,Vr.jsxs)(Gt,{children:[(0,Vr.jsx)(Gt,{width:EV+wV+YV+CV,children:(0,Vr.jsxs)(rt,{children:[" \xBB ",Ke("tool.stats.decision.modified")]})}),(0,Vr.jsx)(Gt,{width:xV,justifyContent:"flex-end",children:(0,Vr.jsx)(rt,{color:pt.AccentYellow,children:i.modify})})]}),(0,Vr.jsx)(Gt,{borderStyle:"single",borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1,width:"100%"}),(0,Vr.jsxs)(Gt,{children:[(0,Vr.jsx)(Gt,{width:EV+wV+YV+CV,children:(0,Vr.jsxs)(rt,{children:[" ",Ke("tool.stats.decision.overall.rate")]})}),(0,Vr.jsx)(Gt,{width:xV,justifyContent:"flex-end",children:(0,Vr.jsx)(rt,{bold:!0,color:s>0?c:void 0,children:s>0?`${e.toFixed(1)}%`:"--"})})]})]})};Nr();var Ji=Dt(Xn(),1);var Gpn=({systemPromptTokens:n,userMessageTokens:t,memoryContextTokens:r,toolsTokens:a,totalInputTokens:i,maxTokens:s})=>{let e=(n/s*100).toFixed(1),c=(t/s*100).toFixed(1),u=(r/s*100).toFixed(1),d=(a/s*100).toFixed(1),I=(i/s*100).toFixed(1),h=R=>R.toLocaleString(),o=R=>R>=80?pt.AccentRed:R>=60?pt.AccentYellow:pt.AccentGreen,v=parseFloat(I),w=o(v);return(0,Ji.jsxs)(Gt,{flexDirection:"column",marginY:1,children:[(0,Ji.jsxs)(rt,{color:pt.Gray,bold:!0,children:["\u{1F4CA} ",Ke("token.breakdown.title")]}),(0,Ji.jsxs)(Gt,{marginTop:1,marginBottom:1,flexDirection:"column",children:[(0,Ji.jsxs)(Gt,{marginY:0,children:[(0,Ji.jsx)(Gt,{width:25,children:(0,Ji.jsx)(rt,{color:pt.Gray,children:Ke("token.breakdown.system")})}),(0,Ji.jsxs)(rt,{children:[h(n),"K"]}),(0,Ji.jsx)(rt,{color:pt.Gray,children:" / "}),(0,Ji.jsxs)(rt,{color:pt.AccentBlue,children:[e,"%"]})]}),(0,Ji.jsxs)(Gt,{marginY:0,children:[(0,Ji.jsx)(Gt,{width:25,children:(0,Ji.jsx)(rt,{color:pt.Gray,children:Ke("token.breakdown.user")})}),(0,Ji.jsxs)(rt,{children:[h(t),"K"]}),(0,Ji.jsx)(rt,{color:pt.Gray,children:" / "}),(0,Ji.jsxs)(rt,{color:pt.AccentBlue,children:[c,"%"]})]}),(0,Ji.jsxs)(Gt,{marginY:0,children:[(0,Ji.jsx)(Gt,{width:25,children:(0,Ji.jsx)(rt,{color:pt.Gray,children:Ke("token.breakdown.memory")})}),(0,Ji.jsxs)(rt,{children:[h(r),"K"]}),(0,Ji.jsx)(rt,{color:pt.Gray,children:" / "}),(0,Ji.jsxs)(rt,{color:pt.AccentBlue,children:[u,"%"]})]}),(0,Ji.jsxs)(Gt,{marginY:0,children:[(0,Ji.jsx)(Gt,{width:25,children:(0,Ji.jsx)(rt,{color:pt.Gray,children:Ke("token.breakdown.tools")})}),(0,Ji.jsxs)(rt,{children:[h(a),"K"]}),(0,Ji.jsx)(rt,{color:pt.Gray,children:" / "}),(0,Ji.jsxs)(rt,{color:pt.AccentBlue,children:[d,"%"]})]}),(0,Ji.jsx)(Gt,{marginY:0,children:(0,Ji.jsx)(rt,{color:pt.Gray,children:"\u2500".repeat(50)})}),(0,Ji.jsxs)(Gt,{marginY:0,children:[(0,Ji.jsx)(Gt,{width:25,children:(0,Ji.jsx)(rt,{color:pt.Gray,bold:!0,children:Ke("token.breakdown.total")})}),(0,Ji.jsxs)(rt,{bold:!0,children:[h(i),"K"]}),(0,Ji.jsx)(rt,{color:pt.Gray,children:" / "}),(0,Ji.jsxs)(rt,{color:w,bold:!0,children:[I,"%"]}),(0,Ji.jsxs)(rt,{color:pt.Gray,children:[" of ",h(s),"K limit"]})]}),v>80&&(0,Ji.jsx)(Gt,{marginTop:1,children:(0,Ji.jsx)(rt,{color:pt.AccentRed,children:"\u26A0\uFE0F Context usage is high. Consider archiving old messages or clearing memory to avoid hitting the limit."})})]})]})};var Si=Dt(Xn(),1);var fpn=({systemPromptTokens:n,systemToolsTokens:t,memoryFilesTokens:r,messagesTokens:a,reservedTokens:i,totalInputTokens:s,freeSpaceTokens:e,maxTokens:c})=>{let u=(s/c*100).toFixed(1),d=(n/c*100).toFixed(1),I=(t/c*100).toFixed(1),h=(r/c*100).toFixed(1),o=(a/c*100).toFixed(1),v=(i/c*100).toFixed(1),w=(e/c*100).toFixed(1),R=b=>{let g=Math.round(b/100*20),N=20-g,p="";for(let m=0;m<g;m++)p+="\u2588";for(let m=0;m<N;m++)p+="\u2591";return p},E=b=>(b/1e3).toFixed(1),A=parseFloat(u),Y=R(A),y=(b=>b>=80?pt.AccentRed:b>=60?pt.AccentYellow:pt.AccentGreen)(A);return(0,Si.jsxs)(Gt,{flexDirection:"column",marginY:1,children:[(0,Si.jsxs)(Gt,{children:[(0,Si.jsx)(rt,{color:pt.Gray,children:"\u{1F4BE} "}),(0,Si.jsx)(rt,{bold:!0,children:"Context Usage"}),(0,Si.jsxs)(rt,{color:pt.Gray,children:[" ",E(s),"k/"]}),(0,Si.jsxs)(rt,{color:pt.Gray,children:[E(c),"k tokens ("]}),(0,Si.jsxs)(rt,{color:y,bold:!0,children:[u,"%"]}),(0,Si.jsx)(rt,{color:pt.Gray,children:")"})]}),(0,Si.jsx)(Gt,{marginY:0,marginTop:0,children:(0,Si.jsx)(rt,{color:y,children:Y})}),(0,Si.jsxs)(Gt,{flexDirection:"column",marginTop:1,children:[(0,Si.jsxs)(Gt,{marginY:0,children:[(0,Si.jsx)(rt,{color:pt.Comment,children:"\u251C\u2500 "}),(0,Si.jsx)(rt,{color:pt.Gray,children:"System prompt: "}),(0,Si.jsxs)(rt,{color:pt.AccentBlue,children:[E(n),"k tokens"]}),(0,Si.jsxs)(rt,{color:pt.Gray,children:[" (",d,"%)"]})]}),(0,Si.jsxs)(Gt,{marginY:0,children:[(0,Si.jsx)(rt,{color:pt.Comment,children:"\u251C\u2500 "}),(0,Si.jsx)(rt,{color:pt.Gray,children:"System tools: "}),(0,Si.jsxs)(rt,{color:pt.AccentYellow,children:[E(t),"k tokens"]}),(0,Si.jsxs)(rt,{color:pt.Gray,children:[" (",I,"%)"]})]}),(0,Si.jsxs)(Gt,{marginY:0,children:[(0,Si.jsx)(rt,{color:pt.Comment,children:"\u251C\u2500 "}),(0,Si.jsx)(rt,{color:pt.Gray,children:"Memory files: "}),(0,Si.jsxs)(rt,{color:pt.AccentCyan,children:[E(r),"k tokens"]}),(0,Si.jsxs)(rt,{color:pt.Gray,children:[" (",h,"%)"]})]}),(0,Si.jsxs)(Gt,{marginY:0,children:[(0,Si.jsx)(rt,{color:pt.Comment,children:"\u251C\u2500 "}),(0,Si.jsx)(rt,{color:pt.Gray,children:"Messages: "}),(0,Si.jsxs)(rt,{color:pt.AccentPurple,children:[E(a),"k tokens"]}),(0,Si.jsxs)(rt,{color:pt.Gray,children:[" (",o,"%)"]})]}),(0,Si.jsxs)(Gt,{marginY:0,children:[(0,Si.jsx)(rt,{color:pt.Comment,children:"\u2514\u2500 "}),(0,Si.jsx)(rt,{color:pt.Gray,children:"Free space: "}),(0,Si.jsxs)(rt,{color:pt.AccentGreen,children:[E(e),"k tokens"]}),(0,Si.jsxs)(rt,{color:pt.Gray,children:[" (",w,"%)"]})]})]}),A>80&&(0,Si.jsx)(Gt,{marginTop:1,flexDirection:"column",children:(0,Si.jsx)(rt,{color:pt.AccentRed,children:"\u26A0\uFE0F High context usage detected. Use /session new to start a fresh conversation or /compress to compact current context."})})]})};Nr();var vpn=Dt(Xn(),1);var gpn=({duration:n,credits:t,config:r})=>(0,vpn.jsx)(D2e,{title:Ke("agent.powering.down"),duration:n,totalCredits:t,config:r});var o0=Dt(Xn(),1);var T2e=(0,Zpn.memo)(({item:n,availableTerminalHeight:t,terminalWidth:r,isPending:a,config:i,isFocused:s=!0})=>(0,o0.jsxs)(Gt,{flexDirection:"column",width:r,children:[n.type==="user"?(0,o0.jsx)(Rmn,{text:n.text,terminalWidth:r}):null,n.type==="user_shell"?(0,o0.jsx)(Emn,{text:n.text,terminalWidth:r}):null,n.type==="gemini"?(0,o0.jsx)(zmn,{text:n.text,isPending:a,availableTerminalHeight:t,terminalWidth:r}):null,n.type==="gemini_content"?(0,o0.jsx)(lpn,{text:n.text,isPending:a,availableTerminalHeight:t,terminalWidth:r}):null,n.type==="info"?(0,o0.jsx)(_mn,{text:n.text}):null,n.type==="error"?(0,o0.jsx)(Pmn,{text:n.text}):null,n.type==="about"?(0,o0.jsx)(opn,{cliVersion:n.cliVersion,osVersion:n.osVersion,sandboxEnv:n.sandboxEnv,modelVersion:n.modelVersion,selectedAuthType:n.selectedAuthType,gcpProject:n.gcpProject}):null,n.type==="stats"?(0,o0.jsx)(D2e,{duration:n.duration,config:i}):null,n.type==="model_stats"?(0,o0.jsx)(ppn,{}):null,n.type==="tool_stats"?(0,o0.jsx)(bpn,{}):null,n.type==="token_breakdown"?(0,o0.jsx)(Gpn,{systemPromptTokens:n.systemPromptTokens,userMessageTokens:n.userMessageTokens,memoryContextTokens:n.memoryContextTokens,toolsTokens:n.toolsTokens,totalInputTokens:n.totalInputTokens,maxTokens:n.maxTokens}):null,n.type==="context_breakdown"?(0,o0.jsx)(fpn,{systemPromptTokens:n.systemPromptTokens,systemToolsTokens:n.systemToolsTokens,memoryFilesTokens:n.memoryFilesTokens,messagesTokens:n.messagesTokens,reservedTokens:n.reservedTokens,totalInputTokens:n.totalInputTokens,freeSpaceTokens:n.freeSpaceTokens,maxTokens:n.maxTokens}):null,n.type==="quit"?(0,o0.jsx)(gpn,{duration:n.duration,credits:n.credits,config:i}):null,n.type==="tool_group"?(0,o0.jsx)(ipn,{toolCalls:n.tools,groupId:n.id,availableTerminalHeight:t,terminalWidth:r,config:i,isFocused:s}):null,n.type==="compression"?(0,o0.jsx)(spn,{compression:n.compression}):null]},n.id),(n,t)=>n.item.id===t.item.id&&n.item.text===t.item.text&&n.isPending===t.isPending&&n.terminalWidth===t.terminalWidth&&n.isFocused===t.isFocused);Nr();var O2e=Dt(Xn(),1);var Npn=({isVisible:n,elapsed:t,estimated:r})=>{if(!n)return null;let a=to(),i=Math.max(0,r-t),s=Math.min(100,Math.round(t/r*100)),e=a?`${t}s/${r}s (${s}%)`:`${t}s/${r}s (${s}%)`;return(0,O2e.jsxs)(rt,{color:pt.AccentGreen,children:[(0,O2e.jsx)(FB,{type:"dots"})," ",e]})};iR();var XK=Dt(mr(),1);Wr();var QTe=Dt(Xn(),1);function PUr(){let n=process.env.CLI_TITLE||"\u{1F680} DeepV Code";process.stdout.write(`\x1B]2;${n}\x07`)}var Wpn=({geminiMdFileCount:n,contextFileNames:t,mcpServers:r,blockedMcpServers:a,showToolDescriptions:i,openFiles:s})=>{let e=R4e(),c=xm(),u=Object.keys(r||{}).length,d=Array.from(e.entries()).filter(([W,y])=>y===Cc.CONNECTED&&r&&W in r).length,I=Array.from(e.entries()).filter(([W,y])=>y===Cc.CONNECTING&&r&&W in r).length,h=(0,XK.useRef)(!1),o=(0,XK.useRef)(!1);(0,XK.useEffect)(()=>{if(u===0)return;c===CI.IN_PROGRESS||I>0?h.current=!0:h.current&&!o.current&&(o.current=!0,PUr())},[u,c,I]);let v=a?.length||0;if(n===0&&u===0&&v===0&&(s?.recentOpenFiles?.length??0)===0)return(0,QTe.jsx)(rt,{children:" "});let w=(()=>{let W=s?.recentOpenFiles?.length??0;return W===0?"":`${W} recent file${W>1?"s":""} (ctrl+e to view)`})(),R=(()=>{if(n===0)return"";let y=new Set(t).size<2?t[0]:"context";return`${n} ${y} file${n>1?"s":""}`})(),E=(()=>{if(u===0&&v===0)return"";let W=[];if(u>0&&(c===CI.IN_PROGRESS||I>0?W.push(`${d}/${u} MCP server${u>1?"s":""} (connecting...)`):d===u?W.push(`${d} MCP server${d>1?"s":""}`):d>0?W.push(`${d}/${u} MCP server${u>1?"s":""}`):W.push(`0/${u} MCP server${u>1?"s":""} (failed)`)),v>0){let y=`${v} Blocked`;u===0&&(y+=` MCP server${v>1?"s":""}`),W.push(y)}return W.join(", ")})(),A="Using: ",Y=[];return w&&Y.push(w),R&&Y.push(R),E&&Y.push(E),A+=Y.join(" | "),r&&Object.keys(r).length>0&&(i?A+=" (ctrl+t to toggle)":A+=" (ctrl+t to view)"),(0,QTe.jsx)(rt,{color:pt.Gray,children:A})};var VV=Dt(Xn(),1);import jUr from"node:path";function Apn({openFiles:n}){if(!n||!n.recentOpenFiles||n.recentOpenFiles.length===0)return null;let t=n.recentOpenFiles||[];return(0,VV.jsxs)(Gt,{flexDirection:"column",marginTop:1,borderStyle:"round",borderColor:pt.AccentCyan,paddingX:1,children:[(0,VV.jsx)(rt,{color:pt.AccentCyan,bold:!0,children:"IDE Context (ctrl+e to toggle)"}),t.length>0&&(0,VV.jsxs)(Gt,{flexDirection:"column",marginTop:1,children:[(0,VV.jsx)(rt,{bold:!0,children:"Recent files:"}),t.map(r=>(0,VV.jsxs)(rt,{children:["- ",jUr.basename(r.filePath),r.filePath===n.activeFile?" (active)":""]},r.filePath))]})]})}var BB=Dt(mr(),1);Nr();var U5=Dt(Xn(),1);var Fpn=({reasoning:n,terminalHeight:t,terminalWidth:r})=>{let a=HR(),[i,s]=(0,BB.useState)(!0),e=(0,BB.useRef)(null);if((0,BB.useEffect)(()=>(e.current&&(clearInterval(e.current),e.current=null),n?.text&&a==="responding"?e.current=setInterval(()=>{s(v=>!v)},1e3):s(!0),()=>{e.current&&(clearInterval(e.current),e.current=null)}),[n?.text,a]),!n?.text)return null;let c=Math.max(Math.floor(t*.2),4),u=n.text.split(`
4979
4979
  `),d=u.length>c,I=d?c-1:c,h=u.length>I?u.slice(-I):u,o=d?["...",...h]:h;return(0,U5.jsxs)(Gt,{flexDirection:"column",marginY:1,borderStyle:"round",borderColor:pt.Gray,paddingX:1,paddingY:0,children:[(0,U5.jsxs)(Gt,{marginBottom:0,children:[(0,U5.jsx)(rt,{color:pt.Gray,children:i?"\u25CF":"\u25CB"}),(0,U5.jsx)(Gt,{marginLeft:1,children:(0,U5.jsx)(rt,{bold:!0,color:pt.AccentBlue,children:Ke("model.reasoning")})})]}),(0,U5.jsx)(Gt,{flexDirection:"column",children:o.map((v,w)=>(0,U5.jsxs)(rt,{color:pt.Foreground,wrap:"wrap",children:[v||" "," "]},w))})]})};var RN=Dt(mr(),1);function ypn(n){let[t,r]=(0,RN.useState)([]),a=(0,RN.useRef)(0),i=(0,RN.useCallback)(d=>(a.current+=1,d+a.current),[]),s=(0,RN.useCallback)(d=>{r(d)},[]),e=(0,RN.useCallback)((d,I)=>{let h=i(I),o={...d,id:h};return r(v=>{if(v.length>0){let w=v[v.length-1];if(w.type==="user"&&o.type==="user"&&w.text===o.text)return v}return[...v,o]}),h},[i]),c=(0,RN.useCallback)((d,I)=>{r(h=>h.map(o=>{if(o.id===d){let v=typeof I=="function"?I(o):I;return{...o,...v}}return o}))},[]),u=(0,RN.useCallback)(()=>{r([]),a.current=0},[]);return{history:t,addItem:e,updateItem:c,clearItems:u,loadHistory:s}}var M5=Dt(mr(),1);Wr();var Rpn=({config:n,loadHistory:t})=>{let r=(0,M5.useCallback)(async()=>{let a=n.getProjectRoot();if(a)try{let i=new Ls(a),s=n.getSessionId(),e=await i.loadSession(s);if(!e){console.log(`[SessionRestore] No saved data for current session ${s} - this is a new session`);return}let c=e.history&&e.history.length>0,u=e.clientHistory&&e.clientHistory.length>0;if(!c&&!u){console.log(`[SessionRestore] Current session ${s} has no history - starting fresh`);return}c&&e.history&&(console.log(`[SessionRestore] Restoring UI history with ${e.history.length} items`),t(e.history)),u&&e.clientHistory&&(console.log(`[SessionRestore] Setting up AI client history restoration for ${e.clientHistory.length} items`),KUr(n,e.clientHistory))}catch(i){console.warn("[SessionRestore] Failed to restore session:",i)}},[n,t]);return(0,M5.useEffect)(()=>{let a=setTimeout(()=>{r()},500);return()=>clearTimeout(a)},[r]),{restoreSession:r}};function KUr(n,t){console.log("[SessionRestore] Starting AI client history restore monitor...");let r=()=>{let a=n.getGeminiClient();if(a&&a.isInitialized?.())try{console.log(`[SessionRestore] AI client ready! Restoring ${t.length} history items`),a.setHistory(t),console.log("[SessionRestore] \u2705 Successfully restored AI client history");return}catch(i){console.warn("[SessionRestore] \u274C Failed to restore AI client history:",i);return}setTimeout(r,200)};r()}var Epn=(n,t,r)=>{let a=(0,M5.useRef)(0),i=(0,M5.useRef)(void 0),s=(0,M5.useCallback)(async()=>{if(t.length===0||t.length===a.current)return;let e=n.getProjectRoot();if(e)try{let c=new Ls(e),u=await n.getGeminiClient()?.getHistory();await c.saveSessionHistory(n.getSessionId(),t,u),a.current=t.length,console.log(`[SessionAutoSave] \u2705 Turn completed - Saved ${t.length} history items`)}catch(c){console.warn("[SessionAutoSave] \u274C Failed to save session history:",c)}},[n,t]);(0,M5.useEffect)(()=>{let e=i.current,c=r;e==="responding"&&c==="idle"&&setTimeout(()=>{s()},500),i.current=c},[r,s])};Wr();import Ef from"node:process";var DB=Dt(mr(),1);import{exec as wpn}from"node:child_process";import Ypn from"node:fs";import qUr from"node:fs/promises";import $Ur from"path";function Cpn(n){let[t,r]=(0,DB.useState)(void 0),a=(0,DB.useCallback)(()=>wpn("git rev-parse --abbrev-ref HEAD",{cwd:n},(i,s,e)=>{if(i){r(void 0);return}let c=s.toString().trim();c&&c!=="HEAD"?r(c):wpn("git rev-parse --short HEAD",{cwd:n},(u,d,I)=>{if(u){r(void 0);return}r(d.toString().trim())})}),[n,r]);return(0,DB.useEffect)(()=>{let i=setTimeout(()=>{a()},200),s=$Ur.join(n,".git","logs","HEAD"),e;return(async()=>{try{await qUr.access(s,Ypn.constants.F_OK),e=Ypn.watch(s,u=>{(u==="change"||u==="rename")&&a()})}catch{}})(),()=>{clearTimeout(i),e?.close()}},[n,a]),t}var xpn=Dt(mr(),1);var eMr="\x1B[?2004h",tMr="\x1B[?2004l",Vpn=()=>{let n=()=>{process.stdout.write(tMr)};(0,xpn.useEffect)(()=>(process.stdout.write(eMr),process.on("exit",n),process.on("SIGINT",n),process.on("SIGTERM",n),()=>{n(),process.removeListener("exit",n),process.removeListener("SIGINT",n),process.removeListener("SIGTERM",n)}),[])};FF();var ea=Dt(mr(),1);import{spawnSync as nMr}from"child_process";import kK from"fs";import rMr from"os";import Hpn from"path";Wr();function Qpn(n,t){let{lines:r,cursorRow:a,cursorCol:i}=n,s=null,e=()=>s??(s=r.join(`
4980
4980
  `));switch(t.type){case"vim_delete_word_forward":{let{count:c}=t.payload,u=EN(a,i,r),d=u,I=u;for(let h=0;h<c;h++){let o=TB(e(),I);if(o>I)I=o,d=o;else{let v=OB(e(),I);d=Math.min(v+1,e().length);break}}if(d>u){let h=bI(n),{startRow:o,startCol:v,endRow:w,endCol:R}=vG(u,d,h.lines);return xu(h,o,v,w,R,"")}return n}case"vim_delete_word_backward":{let{count:c}=t.payload,u=EN(a,i,r),d=u,I=u;for(let h=0;h<c;h++){let o=U2e(e(),I);if(o<I)I=o,d=o;else break}if(d<u){let h=bI(n),{startRow:o,startCol:v,endRow:w,endCol:R}=vG(d,u,h.lines);return xu(h,o,v,w,R,"")}return n}case"vim_delete_word_end":{let{count:c}=t.payload,u=EN(a,i,r),d=u,I=u;for(let h=0;h<c;h++){let o=OB(e(),d);if(o>=d){if(I=o+1,h<c-1){let v=TB(e(),o+1);if(d=v,v<=o)break}}else break}if(I=Math.min(I,e().length),I>u){let h=bI(n),{startRow:o,startCol:v,endRow:w,endCol:R}=vG(u,I,h.lines);return xu(h,o,v,w,R,"")}return n}case"vim_change_word_forward":{let{count:c}=t.payload,u=EN(a,i,r),d=u,I=u;for(let h=0;h<c;h++){let o=TB(e(),d);if(o>d)d=o,I=o;else{let v=OB(e(),d);I=Math.min(v+1,e().length);break}}if(I>u){let h=bI(n),{startRow:o,startCol:v,endRow:w,endCol:R}=vG(u,I,h.lines);return xu(h,o,v,w,R,"")}return n}case"vim_change_word_backward":{let{count:c}=t.payload,u=EN(a,i,r),d=u,I=u;for(let h=0;h<c;h++){let o=U2e(e(),I);if(o<I)I=o,d=o;else break}if(d<u){let h=bI(n),{startRow:o,startCol:v,endRow:w,endCol:R}=vG(d,u,h.lines);return xu(h,o,v,w,R,"")}return n}case"vim_change_word_end":{let{count:c}=t.payload,u=EN(a,i,r),d=u,I=u;for(let h=0;h<c;h++){let o=OB(e(),d);if(o>=d){if(I=o+1,h<c-1){let v=TB(e(),o+1);if(d=v,v<=o)break}}else break}if(I=Math.min(I,e().length),I!==u){let h=bI(n),{startRow:o,startCol:v,endRow:w,endCol:R}=vG(Math.min(u,I),Math.max(u,I),h.lines);return xu(h,o,v,w,R,"")}return n}case"vim_delete_line":{let{count:c}=t.payload;if(r.length===0)return n;let u=Math.min(c,r.length-a),d=r.length;if(d===1||u>=d)return{...bI(n),lines:[""],cursorRow:0,cursorCol:0,preferredCol:null};let I=bI(n),h=[...I.lines];h.splice(a,u);let o=Math.min(a,h.length-1);return{...I,lines:h,cursorRow:o,cursorCol:0,preferredCol:null}}case"vim_change_line":{let{count:c}=t.payload;if(r.length===0)return n;let u=Math.min(c,r.length-a),d=bI(n),{startOffset:I,endOffset:h}=M2e(a,u,d.lines),{startRow:o,startCol:v,endRow:w,endCol:R}=vG(I,h,d.lines);return xu(d,o,v,w,R,"")}case"vim_delete_to_end_of_line":{let c=r[a]||"";if(i<c.length){let u=bI(n);return xu(u,a,i,a,c.length,"")}return n}case"vim_change_to_end_of_line":{let c=r[a]||"";if(i<c.length){let u=bI(n);return xu(u,a,i,a,c.length,"")}return n}case"vim_change_movement":{let{movement:c,count:u}=t.payload,d=r.length;switch(c){case"h":{let I=Math.max(0,i-u);return xu(bI(n),a,I,a,i,"")}case"j":{let I=Math.min(u,d-a);if(I>0)if(d===1){let h=n.lines[0]||"";return xu(bI(n),0,0,0,Ca(h),"")}else{let h=bI(n),{startOffset:o,endOffset:v}=M2e(a,I,h.lines),{startRow:w,startCol:R,endRow:E,endCol:A}=vG(o,v,h.lines);return xu(h,w,R,E,A,"")}return n}case"k":{if(Math.min(u,a+1)>0)if(n.lines.length===1){let h=n.lines[0]||"";return xu(bI(n),0,0,0,Ca(h),"")}else{let h=Math.max(0,a-u+1),o=a-h+1,v=bI(n),{startOffset:w,endOffset:R}=M2e(h,o,v.lines),{startRow:E,startCol:A,endRow:Y,endCol:W}=vG(w,R,v.lines);return{...xu(v,E,A,Y,W,""),cursorRow:h,cursorCol:0}}return n}case"l":return xu(bI(n),a,i,a,Math.min(Ca(r[a]||""),i+u),"");default:return n}}case"vim_move_left":{let{count:c}=t.payload,{cursorRow:u,cursorCol:d,lines:I}=n,h=u,o=d;for(let v=0;v<c;v++)if(o>0)o--;else if(h>0){h--;let w=I[h]||"",R=Ca(w);o=R===0?0:R-1}return{...n,cursorRow:h,cursorCol:o,preferredCol:null}}case"vim_move_right":{let{count:c}=t.payload,{cursorRow:u,cursorCol:d,lines:I}=n,h=u,o=d;for(let v=0;v<c;v++){let w=I[h]||"",R=Ca(w);R===0?h<I.length-1&&(h++,o=0):o<R-1?o++:h<I.length-1&&(h++,o=0)}return{...n,cursorRow:h,cursorCol:o,preferredCol:null}}case"vim_move_up":{let{count:c}=t.payload,{cursorRow:u,cursorCol:d,lines:I}=n,h=Math.max(0,u-c),o=Math.min(d,Ca(I[h]||""));return{...n,cursorRow:h,cursorCol:o,preferredCol:null}}case"vim_move_down":{let{count:c}=t.payload,{cursorRow:u,cursorCol:d,lines:I}=n,h=Math.min(I.length-1,u+c),o=Math.min(d,Ca(I[h]||""));return{...n,cursorRow:h,cursorCol:o,preferredCol:null}}case"vim_move_word_forward":{let{count:c}=t.payload,u=EN(a,i,r);for(let h=0;h<c;h++){let o=TB(e(),u);if(o>u)u=o;else break}let{startRow:d,startCol:I}=vG(u,u,r);return{...n,cursorRow:d,cursorCol:I,preferredCol:null}}case"vim_move_word_backward":{let{count:c}=t.payload,u=EN(a,i,r);for(let h=0;h<c;h++)u=U2e(e(),u);let{startRow:d,startCol:I}=vG(u,u,r);return{...n,cursorRow:d,cursorCol:I,preferredCol:null}}case"vim_move_word_end":{let{count:c}=t.payload,u=EN(a,i,r);for(let h=0;h<c;h++)u=OB(e(),u);let{startRow:d,startCol:I}=vG(u,u,r);return{...n,cursorRow:d,cursorCol:I,preferredCol:null}}case"vim_delete_char":{let{count:c}=t.payload,{cursorRow:u,cursorCol:d,lines:I}=n,h=I[u]||"",o=Ca(h);if(d<o){let v=Math.min(c,o-d),w=bI(n);return xu(w,u,d,u,d+v,"")}return n}case"vim_insert_at_cursor":return n;case"vim_append_at_cursor":{let{cursorRow:c,cursorCol:u,lines:d}=n,I=d[c]||"",h=u<Ca(I)?u+1:u;return{...n,cursorCol:h,preferredCol:null}}case"vim_open_line_below":{let{cursorRow:c,lines:u}=n,d=bI(n),I=Ca(u[c]||"");return xu(d,c,I,c,I,`
4981
4981
  `)}case"vim_open_line_above":{let{cursorRow:c}=n,u=bI(n);return{...xu(u,c,0,c,0,`
@@ -5031,7 +5031,7 @@ ${ia.map(el=>` - ${el}`).join(`
5031
5031
  \u26A1 Possible reasons for this are that you have received multiple consecutive capacity errors or you have reached your daily ${Tn} quota limit
5032
5032
  \u26A1 To increase your limits, upgrade to a Gemini Code Assist Standard or Enterprise plan with higher limits at https://goo.gle/set-up-gemini-code-assist
5033
5033
  \u26A1 Or you can utilize a Gemini API Key. See: https://goo.gle/gemini-cli-docs-auth#gemini-api-key
5034
- \u26A1 You can switch authentication methods by typing /auth`,p({type:"info",text:el},Date.now()),Te(!0),n.setQuotaErrorOccurred(!0)}return n.setModel(ia),Z0e(n,new MJ(n.getContentGeneratorConfig().authType)),!1};n.setFlashFallbackHandler(Wn)},[n,p,qe]);let{rows:kn,columns:Bt}=L$(),{stdin:Rn,setRawMode:Cn}=ZZ(),gr=(0,qn.useRef)(!0),Or=(0,qn.useRef)(0),gl=Math.max(20,Math.floor(Bt*.9)-3),GI=Math.max(60,Math.floor(Bt*.8)),Ds=(0,qn.useCallback)(Wn=>{try{return q2e.existsSync(Wn)&&q2e.statSync(Wn).isFile()}catch{return!1}},[]),Ml=(0,qn.useCallback)(()=>{let Wn=t.merged.preferredEditor;if(!oP(Wn)){pn();return}return Wn},[t,pn]),eu=(0,qn.useCallback)(()=>{if(s){console.log("[AuthError] Custom proxy URL configured, ignoring authentication error");return}q("reauth required"),xe()},[xe,q,s]),{vimEnabled:q0,vimMode:wf,toggleVimEnabled:$0}=z2e(),{handleSlashCommand:hd,slashCommands:Vu,pendingHistoryItems:CN,commandContext:Yf}=xsn(n,t,p,m,G,V,S,T,jt,ue,xe,Rt,pn,Yn,_e,$n,$0,h,v,Z,c),{streamingState:zl,submitQuery:Pv,initError:gp,pendingHistoryItems:Cf,thought:T2,reasoning:O2,hasContentStarted:xf,isCreatingCheckpoint:xN,isExecutingTools:NG}=Vqt(n.getGeminiClient(),N,p,S,n,T,hd,Re,ye,Ml,eu,Vn,Le,Te,I,t,s),eh=(0,qn.useCallback)((Wn,Tn=!1)=>{st&&(K2e(Y),ot(!1)),o(0),Tn&&Wt(!0),Pv(Wn)},[st,Y,Pv]),U2=(0,qn.useCallback)(Wn=>{Mt(Tn=>[...Tn,Wn])},[]),Vf=(0,qn.useCallback)((Wn,Tn)=>{let ia=Tn.trim();ia===""?(Mt(qr=>qr.filter((el,ua)=>ua!==Wn)),p({type:"info",text:ln("input.queue.item.deleted",{position:Wn+1})},Date.now()),Mt(qr=>(qr.length===0&&(Yt(!1),Wt(!1)),qr))):(Mt(qr=>qr.map((el,ua)=>ua===Wn?ia:el)),p({type:"info",text:ln("input.queue.item.updated",{position:Wn+1})},Date.now()))},[p,ln]),Qf=(0,qn.useCallback)((Wn,Tn=!1)=>{let ia=Wn.trim();if(ia){if(zl!=="idle"){U2(ia);return}eh(ia,Tn)}},[p,U2,Tt.length,eh,zl]);Epn(n,N,zl),(0,qn.useEffect)(()=>{if(zl!=="idle"||Tt.length===0||ut||zt||dt)return;let[Wn]=Tt;Wn&&(Mt(Tn=>Tn.slice(1)),eh(Wn))},[Tt,ut,eh,zl,zt,dt]),(0,qn.useEffect)(()=>{zt&&zl!=="idle"&&Wt(!1)},[zt,zl]);let tu=(0,qn.useCallback)(async Wn=>{let Tn=Wn.trim();if(Tn.length>0){if(st&&(K2e(Y),ot(!1)),Tn.startsWith("/")){if(Tn==="/queue clear"){if(Tt.length>0){let qr=Tt.length;Mt([]),p({type:"info",text:ln("input.queue.cleared",{count:qr})},Date.now())}else p({type:"info",text:Ke("input.queue.empty")},Date.now());return}let ia=Tn.startsWith("/refine");ia&&Ht(!0);try{let qr=await hd(Tn);if(qr!==!1){if(Tn.trim()==="/help-ask"){Ve(!0);return}if(qr.type==="handled")return;if(qr.type==="submit_prompt"){Qf(qr.content);return}else{if(qr.type==="schedule_tool")return;if(qr.type==="refine_result"){console.log("[App] \u6536\u5230 refine_result\uFF0C\u8BBE\u7F6E refineResult \u72B6\u6001");let el=cK("sent",kn),ua=cK("refined",kn),Ui=iV(qr.original,{maxRows:el,terminalWidth:Bt}),Sr=iV(qr.refined,{maxRows:ua,terminalWidth:Bt});ft({original:qr.original,refined:qr.refined,displayOriginal:Ui.displayText,displayRefined:Sr.displayText,omittedPlaceholder:Sr.omittedPlaceholder,omittedLines:Sr.omittedLines,options:qr.options});return}}}}finally{ia&&Ht(!1)}}Qf(Tn)}},[Qf,st,Y,hd]),hc=Lpn({initialText:"",viewport:{height:50,width:gl},stdin:Rn,setRawMode:Cn,isValidPath:Ds,shellModeActive:Re}),{handleInput:Hf}=Tpn(hc,tu),Qu=[...CN];Qu.push(...Cf);let{elapsedTime:jv,currentLoadingPhrase:md,estimatedInputTokens:z5}=Sqt(zl,d),pd=(0,qn.useRef)(0);(0,qn.useEffect)(()=>{zl==="responding"&&(pd.current=jv)},[jv,zl]);let{shouldShowSummary:nu,completionElapsedTime:ru}=Bqt(zl,pd.current);(0,qn.useEffect)(()=>{nu&&(Or.current+=1)},[nu]);let th=Vsn({config:n}),Xf=(0,qn.useCallback)((Wn,Tn,ia)=>{Wn?(ia.current&&clearTimeout(ia.current),hd("/quit")):(Tn(!0),ia.current=setTimeout(()=>{Tn(!1),ia.current=null},AMr))},[hd]);Ko((Wn,Tn)=>{let ia=r2n(),qr=Tn.escape||ia&&Tn.ctrl&&Wn==="q"||Ef.platform==="darwin"&&Tn.meta&&Wn==="q";if(dt){if(Tn.return){let ua=hc.text;Vf(Vt,ua),Yt(!1),Wt(!1),hc.setText("");return}else if(qr){Yt(!1),Wt(!1),hc.setText("");return}else if(Tn.ctrl&&Tn.upArrow){let ua=hc.text,Ui=Tt[Vt];ua.trim()!==Ui&&Vf(Vt,ua),Mt(Sr=>{if(Sr.length===0)return Yt(!1),Wt(!1),hc.setText(""),Sr;let Im=(Vt+1)%Sr.length;return Ut(Im),hc.setText(Sr[Im]||""),Sr});return}}else if(Tn.ctrl&&Tn.upArrow&&Tt.length>0){Yt(!0),Wt(!0),Ut(0),hc.setText(Tt[0]);return}if(ut){if(console.log("[App useInput] refineResult\u5B58\u5728\uFF0C\u5904\u7406\u6309\u952E:",{input:Wn,return:Tn.return}),Tn.return){console.log("[App useInput] \u6309\u56DE\u8F66\uFF0C\u53D1\u9001\u6DA6\u8272\u540E\u7684\u6587\u672C\u7ED9 AI");let ua=ut.refined;ft(null),hc.setText(""),Qf(ua,!0);return}else if(Wn.toLowerCase()==="r"){let ua=ut.original;ft(null),hc.setText(""),Ht(!0),(async()=>{try{let Ui=await hd(`/refine ${ua}`);if(Ui!==!1&&Ui.type==="refine_result"){let Sr=cK("sent",kn),Im=cK("refined",kn),$v=iV(Ui.original,{maxRows:Sr,terminalWidth:Bt}),eZ=iV(Ui.refined,{maxRows:Im,terminalWidth:Bt});ft({original:Ui.original,refined:Ui.refined,displayOriginal:$v.displayText,displayRefined:eZ.displayText,omittedPlaceholder:eZ.omittedPlaceholder,omittedLines:eZ.omittedLines,options:Ui.options})}}catch{}finally{Ht(!1)}})();return}else if(Wn.toLowerCase()==="f"){ut.omittedLines&&ft({...ut,showFullText:!0});return}else if(qr){ft(null),hc.setText("");return}}if(qr&&L){S(!1);return}let el=!1;if(oe||(el=!0,pe(!0)),Tn.ctrl&&Wn==="o")ze(ua=>!ua);else if(Tn.ctrl&&Wn==="s")Xe&&pe(ua=>!ua);else if(Tn.ctrl&&Wn==="t"){let ua=!nt;lt(ua);let Ui=n.getMcpServers();Object.keys(Ui||{}).length>0&&hd(ua?"/mcp desc":"/mcp nodesc")}else if(Tn.ctrl&&Wn==="e"&&Rv)De(ua=>!ua);else if(Tn.ctrl&&(Wn==="c"||Wn==="C"))Xf(Ue,et,Be);else if(Tn.ctrl&&(Wn==="d"||Wn==="D")){if(hc.text.length>0)return;Xf(tt,ne,fe)}}),(0,qn.useEffect)(()=>{n&&B(n.getGeminiMdFileCount())},[n]);let M2=Ohe(),[vp,kf]=(0,qn.useState)([]);(0,qn.useEffect)(()=>{(async()=>{let Tn=await M2?.getPreviousUserMessages()||[],qr=[...N.filter(ua=>ua.type==="user"&&typeof ua.text=="string"&&ua.text.trim()!=="").map(ua=>ua.text).reverse(),...Tn],el=[];if(qr.length>0){el.push(qr[0]);for(let ua=1;ua<qr.length;ua++)qr[ua]!==qr[ua-1]&&el.push(qr[ua])}kf(el.reverse())})()},[N,M2]);let VN=!ut&&!gp,QN=(0,qn.useCallback)(()=>{m(),O(),K2e(Y),V()},[m,O,Y,V]),Zp=(0,qn.useRef)(null),Kv=(0,qn.useRef)(null),WG=(0,qn.useRef)(null);(0,qn.useEffect)(()=>{if(Zp.current){let Wn=u7(Zp.current);se(Wn.height)}},[kn,Z,Xe]),Upn(WG,kn,n,oe);let Ys=3,nh=(0,qn.useMemo)(()=>kn-ie-Ys,[kn,ie]),z2=Math.floor(Bt*.9),HN=(0,qn.useMemo)(()=>kn<=30?Math.max(Math.floor(nh*.6),10):kn<=50?Math.max(Math.floor(nh*.8),20):Math.max(kn*4,100),[kn,nh]),AG=(0,qn.useMemo)(()=>{let Wn=[(0,zn.jsx)(Gt,{flexDirection:"column",children:!t.merged.hideBanner&&st&&(0,zn.jsx)(Ssn,{config:n,version:a,customProxyUrl:s})},"header")];return Wn.push(...N.map(Tn=>(0,zn.jsx)(T2e,{terminalWidth:z2,availableTerminalHeight:HN,item:Tn,isPending:!1,config:n},`${X}-${Tn.id}`))),nu&&ru>0&&Wn.push((0,zn.jsx)(e$t,{elapsedTime:ru,isVisible:!0},`completion-${Or.current}`)),Wn},[N,z2,HN,X,Bt,t.merged.hideBanner,t.merged.hideTips,n,nu,ru,Or]);(0,qn.useEffect)(()=>{if(gr.current){gr.current=!1;return}let Wn=Q.refreshDebounceMs,Tn=setTimeout(()=>{D(!1),V()},Wn);return()=>{clearTimeout(Tn)}},[Bt,kn,V,Q.refreshDebounceMs]),(0,qn.useEffect)(()=>{if(zl==="idle"&&J)return D(!1),F()},[zl,F,J]);let _5=(0,qn.useMemo)(()=>n.getDebugMode()?Z:Z.filter(Wn=>Wn.type!=="debug"),[Z,n]),FG=Cpn(n.getTargetDir()),XN=(0,qn.useMemo)(()=>{let Wn=t.merged.contextFileName;return Wn?Array.isArray(Wn)?Wn:[Wn]:_C()},[t.merged.contextFileName]),kN=(0,qn.useMemo)(()=>n.getQuestion(),[n]),Np=n.getGeminiClient(),Lf=(0,qn.useMemo)(()=>{if(Tt.length===0)return"";let Wn=Tt[0].replace(/\s+/g," ").trim();return Wn?Wn.length>80?`${Wn.slice(0,80)}...`:Wn:""},[Tt]);(0,qn.useEffect)(()=>{kN&&!lr.current&&!at&&!bt&&!We&&!Et&&!gn&&!ee&&!fn&&!we&&Np?.isInitialized?.()&&(eh(kN),lr.current=!0)},[kN,at,bt,We,Et,gn,ee,fn,we,Np,eh]);let LN=He?(0,zn.jsx)(Gt,{flexDirection:"column",marginBottom:1,children:He.map(Wn=>(0,zn.jsx)(T2e,{availableTerminalHeight:oe?nh:void 0,terminalWidth:Bt,item:Wn,isPending:!1,config:n},Wn.id))}):null,qv=Math.floor(Math.max(kn*.2,5)),JN=Math.floor(Math.max(kn*.6,10)),Hu=oe?qv:JN,rh=Ae?" \u8BA1\u5212\u6A21\u5F0F\uFF1A\u53EF\u8BFB\u53D6\u4EE3\u7801\u5206\u6790\uFF0C\u7981\u6B62\u4FEE\u6539 (/plan off \u9000\u51FA)":q0?" \u6309 'i' \u8FDB\u5165\u63D2\u5165\u6A21\u5F0F\uFF0C\u6309 'Esc' \u8FDB\u5165\u666E\u901A\u6A21\u5F0F\u3002":" \u8F93\u5165\u60A8\u7684\u6D88\u606F\u6216 @\u6587\u4EF6\u8DEF\u5F84",Wp=()=>Xe?(0,zn.jsx)(Gt,{flexDirection:"column",children:(0,zn.jsx)(Kpn,{messages:_5,height:Hu,width:gl})}):null;return LN||(0,zn.jsx)(a7e.Provider,{value:zl,children:(0,zn.jsxs)(Gt,{flexDirection:"column",width:"90%",ref:WG,children:[E&&(0,zn.jsx)(Mpn,{message:E}),(0,zn.jsx)(H$,{items:AG,children:Wn=>Wn},X),(0,zn.jsx)(PIn,{children:(0,zn.jsxs)(Gt,{ref:Kv,flexDirection:"column",children:[Qu.map((Wn,Tn)=>(0,zn.jsx)(T2e,{availableTerminalHeight:oe?nh:void 0,terminalWidth:z2,item:{...Wn,id:0},isPending:!0,config:n,isFocused:!fn},Tn)),(0,zn.jsx)(Ppn,{constrainHeight:oe})]})}),L&&(0,zn.jsx)(hun,{commands:Vu}),O2&&!xf&&(0,zn.jsx)(Fpn,{reasoning:O2,terminalHeight:kn,terminalWidth:Bt}),(0,zn.jsxs)(Gt,{flexDirection:"column",ref:Zp,children:[r.length>0&&(0,zn.jsx)(Gt,{borderStyle:"round",borderColor:pt.AccentYellow,paddingX:1,marginY:1,flexDirection:"column",children:r.map((Wn,Tn)=>(0,zn.jsx)(rt,{color:pt.AccentYellow,children:Wn},Tn))}),gn?(0,zn.jsxs)(Gt,{flexDirection:"column",children:[M&&(0,zn.jsx)(Gt,{marginBottom:1,children:(0,zn.jsx)(rt,{color:pt.AccentRed,children:M})}),(0,zn.jsx)(eun,{onSelect:Jt,onHighlight:$t,settings:t,availableTerminalHeight:oe?kn-Ys:void 0,terminalWidth:z2})]}):ee?(0,zn.jsxs)(Gt,{flexDirection:"column",children:[_&&(0,zn.jsx)(Gt,{marginBottom:1,children:(0,zn.jsx)(rt,{color:pt.AccentRed,children:_})}),(0,zn.jsx)(tun,{onSelect:de,onHighlight:be,settings:t,config:n,availableTerminalHeight:oe?kn-Ys:void 0,terminalWidth:z2})]}):at?(0,zn.jsx)(zn.Fragment,{children:(0,zn.jsx)(K7e,{stage:"auth",onTimeout:()=>{q("Authentication timed out. Please try again."),Ft(),xe()}})}):bt?(0,zn.jsx)(zn.Fragment,{children:(0,zn.jsx)(K7e,{stage:"environment",onTimeout:()=>{q("Environment preparation timed out. Please try again."),Ft(),xe()}})}):We?(0,zn.jsx)(Gt,{flexDirection:"column",children:(0,zn.jsx)(aun,{onSelect:je,settings:t,initialErrorMessage:K})}):Et?(0,zn.jsx)(Gt,{flexDirection:"column",children:(0,zn.jsx)(iun,{onSelect:kt,settings:t,initialErrorMessage:j})}):fn?(0,zn.jsxs)(Gt,{flexDirection:"column",children:[ae&&(0,zn.jsx)(Gt,{marginBottom:1,children:(0,zn.jsx)(rt,{color:pt.AccentRed,children:ae})}),(0,zn.jsx)(dun,{onSelect:Zn,settings:t,onExit:Hn})]}):we?(0,zn.jsx)(n2n,{onExit:()=>Ee(!1),config:n}):(0,zn.jsxs)(zn.Fragment,{children:[xN&&(0,zn.jsx)(Gt,{marginBottom:1,children:(0,zn.jsxs)(rt,{color:pt.AccentBlue,children:["\u{1F504} ",Ke("checkpoint.creating")]})}),(0,zn.jsx)(Usn,{thought:zl==="waiting_for_confirmation"||n.getAccessibility()?.disableLoadingPhrases?void 0:T2,currentLoadingPhrase:zl==="waiting_for_confirmation"||n.getAccessibility()?.disableLoadingPhrases?void 0:md,elapsedTime:jv}),(0,zn.jsxs)(Gt,{marginTop:1,marginBottom:1,display:"flex",justifyContent:"space-between",width:"100%",children:[(0,zn.jsxs)(Gt,{children:[Ef.env.GEMINI_SYSTEM_MD&&(0,zn.jsx)(rt,{color:pt.AccentRed,children:"|\u2310\u25A0_\u25A0| "}),Ue?(0,zn.jsx)(rt,{color:pt.AccentYellow,children:Ke("exit.confirm.ctrl.c")}):tt?(0,zn.jsx)(rt,{color:pt.AccentYellow,children:Ke("exit.confirm.ctrl.d")}):(0,zn.jsx)(Wpn,{openFiles:Zt,geminiMdFileCount:x,contextFileNames:XN,mcpServers:n.getMcpServers(),blockedMcpServers:n.getBlockedMcpServers(),showToolDescriptions:nt})]}),(0,zn.jsxs)(Gt,{children:[Ae&&(0,zn.jsx)(Psn,{}),th!==Ja.DEFAULT&&!Re&&!ye&&!Ae&&(0,zn.jsx)(Msn,{approvalMode:th}),Re&&(0,zn.jsx)(zsn,{}),ye&&(0,zn.jsx)(_sn,{})]})]}),ct&&(0,zn.jsx)(Apn,{openFiles:Zt}),sn.isVisible&&(0,zn.jsx)(Gt,{marginY:0,marginBottom:1,children:(0,zn.jsx)(Npn,{isVisible:sn.isVisible,elapsed:sn.elapsed,estimated:sn.estimated})}),c&&zl!=="responding"&&(0,zn.jsx)(ymn,{tokenUsage:c,inputWidth:gl,cumulativeCredits:h}),Tt.length>0&&!gp&&(0,zn.jsxs)(Gt,{marginY:1,flexDirection:"column",gap:0,children:[Tt.map((Wn,Tn)=>{let ia=Wn.length>60?`${Wn.slice(0,60)}...`:Wn;return(0,zn.jsxs)(rt,{dimColor:!0,children:[Tn===0?"\u2193":" "," ",ia]},Tn)}),Tt.length>0&&(0,zn.jsx)(rt,{dimColor:!0,children:Ke("input.queue.edit.hint")})]}),dt&&(0,zn.jsx)(Gt,{marginY:1,children:(0,zn.jsxs)(rt,{color:pt.AccentBlue,children:["\u{1F504} ",ln("input.queue.edit.mode",{current:Vt+1,total:Tt.length})," \u2022 ",Ke("input.queue.edit.actions")]})}),At&&(0,zn.jsxs)(Gt,{flexDirection:"column",borderStyle:"round",borderColor:pt.AccentBlue,paddingX:1,paddingY:1,marginY:1,children:[(0,zn.jsx)(Gt,{children:(0,zn.jsxs)(rt,{bold:!0,color:pt.AccentBlue,children:["\u2728 ",Ke("command.refine.loading.title")]})}),(0,zn.jsx)(Gt,{marginTop:1,children:(0,zn.jsx)(rt,{color:pt.Gray,children:Ke("command.refine.loading.message")})})]}),ut&&!At&&(0,zn.jsxs)(Gt,{flexDirection:"column",borderStyle:"round",borderColor:pt.AccentGreen,paddingX:1,paddingY:1,marginY:1,children:[(0,zn.jsx)(Gt,{marginBottom:1,children:(0,zn.jsx)(rt,{bold:!0,color:pt.AccentGreen,children:Ke("command.refine.confirm.title")})}),(0,zn.jsx)(Gt,{marginBottom:1,children:ut.showFullText?(0,zn.jsx)(rt,{wrap:"wrap",italic:!0,children:ut.refined}):nn(ut.displayRefined,ut.omittedPlaceholder,ut.omittedLines)}),(0,zn.jsx)(Gt,{children:(0,zn.jsx)(rt,{color:pt.Gray,children:"\u2500".repeat(50)})}),(0,zn.jsxs)(Gt,{marginTop:1,children:[(0,zn.jsx)(Gt,{marginRight:2,children:(0,zn.jsx)(rt,{bold:!0,color:pt.AccentGreen,children:Ke("command.refine.confirm.hint.send")})}),(0,zn.jsx)(Gt,{marginRight:2,children:(0,zn.jsx)(rt,{color:pt.Gray,children:"|"})}),(0,zn.jsx)(Gt,{marginRight:2,children:(0,zn.jsx)(rt,{bold:!0,color:pt.AccentYellow,children:Ke("command.refine.confirm.hint.refine-again")})}),ut.omittedLines&&!ut.showFullText&&(0,zn.jsxs)(zn.Fragment,{children:[(0,zn.jsx)(Gt,{marginRight:2,children:(0,zn.jsx)(rt,{color:pt.Gray,children:"|"})}),(0,zn.jsx)(Gt,{marginRight:2,children:(0,zn.jsx)(rt,{bold:!0,color:pt.AccentBlue,children:Ke("command.refine.confirm.hint.view-full")})})]}),(0,zn.jsx)(Gt,{marginRight:2,children:(0,zn.jsx)(rt,{color:pt.Gray,children:"|"})}),(0,zn.jsx)(Gt,{children:(0,zn.jsx)(rt,{bold:!0,color:pt.AccentRed,children:Ke("command.refine.confirm.hint.cancel")})})]})]}),VN&&(0,zn.jsx)(bon,{buffer:hc,inputWidth:gl,suggestionsWidth:GI,onSubmit:tu,userMessages:vp,onClearScreen:QN,openModelDialog:ue,config:n,slashCommands:Vu,commandContext:Yf,shellModeActive:Re,setShellModeActive:Ye,helpModeActive:ye,setHelpModeActive:Ve,focus:e,vimHandleInput:Hf,placeholder:rh,isModalOpen:ee||We||gn||fn,isExecutingTools:NG,isBusy:zl!=="idle"||Tt.length>0,isInSpecialMode:!!ut||dt})]}),gp&&zl!=="responding"&&(0,zn.jsx)(Gt,{borderStyle:"round",borderColor:pt.AccentRed,paddingX:1,marginBottom:1,children:N.find(Wn=>Wn.type==="error"&&Wn.text?.includes(gp))?.text?(0,zn.jsx)(rt,{color:pt.AccentRed,children:N.find(Wn=>Wn.type==="error"&&Wn.text?.includes(gp))?.text}):(0,zn.jsxs)(zn.Fragment,{children:[(0,zn.jsxs)(rt,{color:pt.AccentRed,children:["\u521D\u59CB\u5316\u9519\u8BEF\uFF1A",gp]}),(0,zn.jsxs)(rt,{color:pt.AccentRed,children:[" ","\u8BF7\u68C0\u67E5 API \u5BC6\u94A5\u548C\u914D\u7F6E\u3002"]})]})}),Wp(),(0,zn.jsx)(bcn,{model:he,targetDir:n.getTargetDir(),debugMode:n.getDebugMode(),branchName:FG,debugMessage:U,corgiMode:Ie,errorCount:Gn,showErrorDetails:Xe,showMemoryUsage:n.getDebugMode()||n.getShowMemoryUsage(),promptTokenCount:k.lastPromptTokenCount,nightly:W,vimMode:q0?wf:void 0,version:a,ideConnectionStatus:Ge,config:n,terminalWidth:Bt})]})]})})};import{basename as J2n,resolve as mzr,normalize as pzr}from"node:path";import bzr from"node:v8";import Gzr from"node:os";import rOe from"node:fs";import{spawn as fzr}from"node:child_process";var TTe=Dt(oie(),1);Ru();import{exec as yMr,execSync as KR,spawn as MB}from"node:child_process";import _v from"node:os";import YN from"node:path";import om from"node:fs";import{readFile as RMr}from"node:fs/promises";import{promisify as EMr}from"util";var DTe=EMr(yMr);function D2(n){if(_v.platform()!=="win32")return n;let r=n.replace(/\\/g,"/").match(/^([A-Z]):\/(.*)/i);return r?`/${r[1].toLowerCase()}/${r[2]}`:n}var l2n="gemini-cli-sandbox",$2e="gemini-cli-sandbox",QV="gemini-cli-sandbox-proxy",wMr=["permissive-open","permissive-closed","permissive-proxied","restrictive-open","restrictive-closed","restrictive-proxied"];async function YMr(){let n=process.env.SANDBOX_SET_UID_GID?.toLowerCase().trim();if(n==="1"||n==="true")return!0;if(n==="0"||n==="false")return!1;if(_v.platform()==="linux")try{let t=await RMr("/etc/os-release","utf8");if(t.includes("ID=debian")||t.includes("ID=ubuntu")||t.match(/^ID_LIKE=.*debian.*/m)||t.match(/^ID_LIKE=.*ubuntu.*/m))return console.error("INFO: Defaulting to use current user UID/GID for Debian/Ubuntu-based Linux."),!0}catch{console.warn("Warning: Could not read /etc/os-release to auto-detect Debian/Ubuntu for UID/GID default.")}return!1}function CMr(n){let[t,r]=n.split(":"),a=t.split("/").at(-1)??"unknown-image";return r?`${a}-${r}`:a}function s2n(){return(process.env.SANDBOX_PORTS??"").split(",").filter(n=>n.trim()).map(n=>n.trim())}function xMr(n){let t=_v.platform()==="win32",r=D2(n),a=[],i=t?";":":",s="";if(process.env.PATH){let h=process.env.PATH.split(i);for(let o of h){let v=D2(o);v.toLowerCase().startsWith(r.toLowerCase())&&(s+=`:${v}`)}}s&&a.push(`export PATH="$PATH${s}";`);let e="";if(process.env.PYTHONPATH){let h=process.env.PYTHONPATH.split(i);for(let o of h){let v=D2(o);v.toLowerCase().startsWith(r.toLowerCase())&&(e+=`:${v}`)}}e&&a.push(`export PYTHONPATH="$PYTHONPATH${e}";`);let c=YN.join(A5,"sandbox.bashrc");om.existsSync(c)&&a.push(`source ${D2(c)};`),s2n().forEach(h=>a.push(`socat TCP4-LISTEN:${h},bind=$(hostname -i),fork,reuseaddr TCP4:127.0.0.1:${h} 2> /dev/null &`));let u=process.argv.slice(2).map(h=>(0,TTe.quote)([h])),d=process.env.DEBUG?`node --inspect-brk=0.0.0.0:${process.env.DEBUG_PORT||"9229"} $(which gemini)`:"gemini";return["bash","-c",[...a,d,...u].join(" ")]}async function o2n(n,t=[]){if(n.command==="sandbox-exec"){process.env.BUILD_SANDBOX&&(console.error("ERROR: cannot BUILD_SANDBOX when using macOS Seatbelt"),process.exit(1));let g=process.env.SEATBELT_PROFILE??="permissive-open",N=new URL(`sandbox-macos-${g}.sb`,import.meta.url).pathname;wMr.includes(g)||(N=YN.join(A5,`sandbox-macos-${g}.sb`)),om.existsSync(N)||(console.error(`ERROR: missing macos seatbelt profile file '${N}'`),process.exit(1)),console.error(`using macos seatbelt (profile: ${g}) ...`);let p=[...process.env.DEBUG?["--inspect-brk"]:[],...t].join(" "),m=["-D",`TARGET_DIR=${om.realpathSync(process.cwd())}`,"-D",`TMP_DIR=${om.realpathSync(_v.tmpdir())}`,"-D",`HOME_DIR=${om.realpathSync(_v.homedir())}`,"-D",`CACHE_DIR=${om.realpathSync(KR("getconf DARWIN_USER_CACHE_DIR").toString().trim())}`,"-f",N,"sh","-c",["SANDBOX=sandbox-exec",`NODE_OPTIONS="${p}"`,...process.argv.map(k=>(0,TTe.quote)([k]))].join(" ")],G=process.env.GEMINI_SANDBOX_PROXY_COMMAND,Z,C,O={...process.env};if(G){let k=process.env.HTTPS_PROXY||process.env.https_proxy||process.env.HTTP_PROXY||process.env.http_proxy||"http://localhost:8877";O.HTTPS_PROXY=k,O.https_proxy=k,O.HTTP_PROXY=k,O.http_proxy=k;let J=process.env.NO_PROXY||process.env.no_proxy;J&&(O.NO_PROXY=J,O.no_proxy=J),Z=MB(G,{stdio:["ignore","pipe","pipe"],shell:!0,detached:!0});let D=()=>{console.log("stopping proxy ..."),Z?.pid&&process.kill(-Z.pid,"SIGTERM")};process.on("exit",D),process.on("SIGINT",D),process.on("SIGTERM",D),Z.stderr?.on("data",X=>{console.error(X.toString())}),Z.on("close",(X,H)=>{console.error(`ERROR: proxy command '${G}' exited with code ${X}, signal ${H}`),C?.pid&&process.kill(-C.pid,"SIGTERM"),process.exit(1)}),console.log("waiting for proxy to start ..."),await DTe("until timeout 0.25 curl -s http://localhost:8877; do sleep 0.25; done")}C=MB(n.command,m,{stdio:"inherit"}),await new Promise(k=>C?.on("close",k));return}console.error(`hopping into sandbox (command: ${n.command}) ...`);let r=om.realpathSync(process.argv[1]),a=YN.join(A5,"sandbox.Dockerfile"),i=om.existsSync(a),s=n.image,e=YN.resolve(process.cwd()),c=D2(e);if(process.env.BUILD_SANDBOX)if(!r.includes("gemini-cli/packages/"))console.error("ERROR: cannot build sandbox using installed gemini binary; run `npm link ./packages/cli` under gemini-cli repo to switch to linked binary."),process.exit(1);else{console.error("building sandbox ...");let g=r.split("/packages/")[0],N="",p=YN.join(A5,"sandbox.Dockerfile");i&&(console.error(`using ${p} for sandbox`),N+=`-f ${YN.resolve(p)} -i ${s}`),KR(`cd ${g} && node scripts/build_sandbox.js -s ${N}`,{stdio:"inherit",env:{...process.env,GEMINI_SANDBOX:n.command}})}await QMr(n.command,s)||(console.error(`ERROR: Sandbox image '${s}' is missing or could not be pulled. ${s===l2n?"Try running `npm run build:all` or `npm run build:sandbox` under the gemini-cli repo to build it locally, or check the image name and your network connection.":"Please check the image name, your network connection, or notify gemini-cli-dev@google.com if the issue persists."}`),process.exit(1));let u=["run","-i","--rm","--init","--workdir",c];process.stdin.isTTY&&u.push("-t"),u.push("--volume",`${e}:${c}`);let d=_Se,I=D2(`/home/node/${A5}`);om.existsSync(d)||om.mkdirSync(d),u.push("--volume",`${d}:${I}`),I!==d&&u.push("--volume",`${d}:${D2(d)}`),u.push("--volume",`${_v.tmpdir()}:${D2(_v.tmpdir())}`);let h=YN.join(_v.homedir(),".config","gcloud");if(om.existsSync(h)&&u.push("--volume",`${h}:${D2(h)}:ro`),process.env.GOOGLE_APPLICATION_CREDENTIALS){let g=process.env.GOOGLE_APPLICATION_CREDENTIALS;om.existsSync(g)&&(u.push("--volume",`${g}:${D2(g)}:ro`),u.push("--env",`GOOGLE_APPLICATION_CREDENTIALS=${D2(g)}`))}if(process.env.SANDBOX_MOUNTS){for(let g of process.env.SANDBOX_MOUNTS.split(","))if(g.trim()){let[N,p,m]=g.trim().split(":");p=p||N,m=m||"ro",g=`${N}:${p}:${m}`,YN.isAbsolute(N)||(console.error(`ERROR: path '${N}' listed in SANDBOX_MOUNTS must be absolute`),process.exit(1)),om.existsSync(N)||(console.error(`ERROR: missing mount path '${N}' listed in SANDBOX_MOUNTS`),process.exit(1)),console.error(`SANDBOX_MOUNTS: ${N} -> ${p} (${m})`),u.push("--volume",g)}}if(s2n().forEach(g=>u.push("--publish",`${g}:${g}`)),process.env.DEBUG){let g=process.env.DEBUG_PORT||"9229";u.push("--publish",`${g}:${g}`)}let o=process.env.GEMINI_SANDBOX_PROXY_COMMAND;if(o){let g=process.env.HTTPS_PROXY||process.env.https_proxy||process.env.HTTP_PROXY||process.env.http_proxy||"http://localhost:8877";g=g.replace("localhost",QV),g&&(u.push("--env",`HTTPS_PROXY=${g}`),u.push("--env",`https_proxy=${g}`),u.push("--env",`HTTP_PROXY=${g}`),u.push("--env",`http_proxy=${g}`));let N=process.env.NO_PROXY||process.env.no_proxy;N&&(u.push("--env",`NO_PROXY=${N}`),u.push("--env",`no_proxy=${N}`)),g&&(KR(`${n.command} network inspect ${$2e} || ${n.command} network create --internal ${$2e}`),u.push("--network",$2e),o&&KR(`${n.command} network inspect ${QV} || ${n.command} network create ${QV}`))}let v=CMr(s),w=0,R=KR(`${n.command} ps -a --format "{{.Names}}"`).toString().trim();for(;R.includes(`${v}-${w}`);)w++;let E=`${v}-${w}`;if(u.push("--name",E,"--hostname",E),process.env.GEMINI_API_KEY&&u.push("--env",`GEMINI_API_KEY=${process.env.GEMINI_API_KEY}`),process.env.GOOGLE_API_KEY&&u.push("--env",`GOOGLE_API_KEY=${process.env.GOOGLE_API_KEY}`),process.env.GOOGLE_GENAI_USE_VERTEXAI&&u.push("--env",`GOOGLE_GENAI_USE_VERTEXAI=${process.env.GOOGLE_GENAI_USE_VERTEXAI}`),process.env.GOOGLE_GENAI_USE_GCA&&u.push("--env",`GOOGLE_GENAI_USE_GCA=${process.env.GOOGLE_GENAI_USE_GCA}`),process.env.GOOGLE_CLOUD_PROJECT&&u.push("--env",`GOOGLE_CLOUD_PROJECT=${process.env.GOOGLE_CLOUD_PROJECT}`),process.env.GOOGLE_CLOUD_LOCATION&&u.push("--env",`GOOGLE_CLOUD_LOCATION=${process.env.GOOGLE_CLOUD_LOCATION}`),process.env.GEMINI_MODEL&&u.push("--env",`GEMINI_MODEL=${process.env.GEMINI_MODEL}`),process.env.TERM&&u.push("--env",`TERM=${process.env.TERM}`),process.env.COLORTERM&&u.push("--env",`COLORTERM=${process.env.COLORTERM}`),process.env.VIRTUAL_ENV?.toLowerCase().startsWith(e.toLowerCase())){let g=YN.resolve(A5,"sandbox.venv");om.existsSync(g)||om.mkdirSync(g,{recursive:!0}),u.push("--volume",`${g}:${D2(process.env.VIRTUAL_ENV)}`),u.push("--env",`VIRTUAL_ENV=${D2(process.env.VIRTUAL_ENV)}`)}if(process.env.SANDBOX_ENV)for(let g of process.env.SANDBOX_ENV.split(","))(g=g.trim())&&(g.includes("=")?(console.error(`SANDBOX_ENV: ${g}`),u.push("--env",g)):(console.error("ERROR: SANDBOX_ENV must be a comma-separated list of key=value pairs"),process.exit(1)));let A=process.env.NODE_OPTIONS||"",Y=[...A?[A]:[],...t].join(" ");if(Y.length>0&&u.push("--env",`NODE_OPTIONS="${Y}"`),u.push("--env",`SANDBOX=${E}`),n.command==="podman"){let g=YN.join(_v.tmpdir(),"empty_auth.json");om.writeFileSync(g,"{}","utf-8"),u.push("--authfile",g)}let W="",y=xMr(e);if(process.env.GEMINI_CLI_INTEGRATION_TEST==="true")u.push("--user","root"),W="--user root";else if(await YMr()){u.push("--user","root");let g=KR("id -u").toString().trim(),N=KR("id -g").toString().trim(),p="gemini",m=D2(_v.homedir()),G=[`groupadd -f -g ${N} ${p}`,`id -u ${p} &>/dev/null || useradd -o -u ${g} -g ${N} -d ${m} -s /bin/bash ${p}`].join(" && "),C=y[2].replace(/'/g,"'\\''"),O=`su -p ${p} -c '${C}'`;y[2]=`${G} && ${O}`,W=`--user ${g}:${N}`,u.push("--env",`HOME=${_v.homedir()}`)}u.push(s),u.push(...y);let b,f;if(o){let g=`${n.command} run --rm --init ${W} --name ${QV} --network ${QV} -p 8877:8877 -v ${process.cwd()}:${e} --workdir ${e} ${s} ${o}`;b=MB(g,{stdio:["ignore","pipe","pipe"],shell:!0,detached:!0});let N=()=>{console.log("stopping proxy container ..."),KR(`${n.command} rm -f ${QV}`)};process.on("exit",N),process.on("SIGINT",N),process.on("SIGTERM",N),b.stderr?.on("data",p=>{console.error(p.toString().trim())}),b.on("close",(p,m)=>{console.error(`ERROR: proxy container command '${g}' exited with code ${p}, signal ${m}`),f?.pid&&process.kill(-f.pid,"SIGTERM"),process.exit(1)}),console.log("waiting for proxy to start ..."),await DTe("until timeout 0.25 curl -s http://localhost:8877; do sleep 0.25; done"),await DTe(`${n.command} network connect ${$2e} ${QV}`)}f=MB(n.command,u,{stdio:"inherit"}),f.on("error",g=>{console.error("Sandbox process error:",g)}),await new Promise(g=>{f?.on("close",(N,p)=>{N!==0&&console.log(`Sandbox process exited with code: ${N}, signal: ${p}`),g()})})}async function i2n(n,t){return new Promise(r=>{let i=MB(n,["images","-q",t]),s="";i.stdout&&i.stdout.on("data",e=>{s+=e.toString()}),i.on("error",e=>{console.warn(`Failed to start '${n}' command for image check: ${e.message}`),r(!1)}),i.on("close",e=>{r(s.trim()!=="")})})}async function VMr(n,t){return console.info(`Attempting to pull image ${t} using ${n}...`),new Promise(r=>{let i=MB(n,["pull",t],{stdio:"pipe"}),s="",e=h=>{console.info(h.toString().trim())},c=h=>{s+=h.toString(),console.error(h.toString().trim())},u=h=>{console.warn(`Failed to start '${n} pull ${t}' command: ${h.message}`),I(),r(!1)},d=h=>{h===0?(console.info(`Successfully pulled image ${t}.`),I(),r(!0)):(console.warn(`Failed to pull image ${t}. '${n} pull ${t}' exited with code ${h}.`),s.trim(),I(),r(!1))},I=()=>{i.stdout&&i.stdout.removeListener("data",e),i.stderr&&i.stderr.removeListener("data",c),i.removeListener("error",u),i.removeListener("close",d),i.connected&&i.disconnect()};i.stdout&&i.stdout.on("data",e),i.stderr&&i.stderr.on("data",c),i.on("error",u),i.on("close",d)})}async function QMr(n,t){return console.info(`Checking for sandbox image: ${t}`),await i2n(n,t)?(console.info(`Sandbox image ${t} found locally.`),!0):(console.info(`Sandbox image ${t} not found locally.`),t===l2n?!1:await VMr(n,t)?await i2n(n,t)?(console.info(`Sandbox image ${t} is now available after pulling.`),!0):(console.warn(`Sandbox image ${t} still not found after a pull attempt. This might indicate an issue with the image name or registry, or the pull command reported success but failed to make the image available.`),!1):(console.error(`Failed to obtain sandbox image ${t} after check and pull attempt.`),!1))}Ru();Wr();import OTe from"fs/promises";import HMr from"os";import{join as XMr}from"node:path";var UTe=XMr(HMr.tmpdir(),"gemini-cli-warnings.txt");async function c2n(){try{await OTe.access(UTe);let t=(await OTe.readFile(UTe,"utf-8")).split(`
5034
+ \u26A1 You can switch authentication methods by typing /auth`,p({type:"info",text:el},Date.now()),Te(!0),n.setQuotaErrorOccurred(!0)}return n.setModel(ia),Z0e(n,new MJ(n.getContentGeneratorConfig().authType)),!1};n.setFlashFallbackHandler(Wn)},[n,p,qe]);let{rows:kn,columns:Bt}=L$(),{stdin:Rn,setRawMode:Cn}=ZZ(),gr=(0,qn.useRef)(!0),Or=(0,qn.useRef)(0),gl=Math.max(20,Math.floor(Bt*.9)-3),GI=Math.max(60,Math.floor(Bt*.8)),Ds=(0,qn.useCallback)(Wn=>{try{return q2e.existsSync(Wn)&&q2e.statSync(Wn).isFile()}catch{return!1}},[]),Ml=(0,qn.useCallback)(()=>{let Wn=t.merged.preferredEditor;if(!oP(Wn)){pn();return}return Wn},[t,pn]),eu=(0,qn.useCallback)(()=>{if(s){console.log("[AuthError] Custom proxy URL configured, ignoring authentication error");return}q("reauth required"),xe()},[xe,q,s]),{vimEnabled:q0,vimMode:wf,toggleVimEnabled:$0}=z2e(),{handleSlashCommand:hd,slashCommands:Vu,pendingHistoryItems:CN,commandContext:Yf}=xsn(n,t,p,m,G,V,S,T,jt,ue,xe,Rt,pn,Yn,_e,$n,$0,h,v,Z,c),{streamingState:zl,submitQuery:Pv,initError:gp,pendingHistoryItems:Cf,thought:T2,reasoning:O2,hasContentStarted:xf,isCreatingCheckpoint:xN,isExecutingTools:NG}=Vqt(n.getGeminiClient(),N,p,S,n,T,hd,Re,ye,Ml,eu,Vn,Le,Te,I,t,s),eh=(0,qn.useCallback)((Wn,Tn=!1)=>{st&&(K2e(Y),ot(!1)),o(0),Tn&&Wt(!0),Pv(Wn)},[st,Y,Pv]),U2=(0,qn.useCallback)(Wn=>{Mt(Tn=>[...Tn,Wn])},[]),Vf=(0,qn.useCallback)((Wn,Tn)=>{let ia=Tn.trim();ia===""?(Mt(qr=>qr.filter((el,ua)=>ua!==Wn)),p({type:"info",text:ln("input.queue.item.deleted",{position:Wn+1})},Date.now()),Mt(qr=>(qr.length===0&&(Yt(!1),Wt(!1)),qr))):(Mt(qr=>qr.map((el,ua)=>ua===Wn?ia:el)),p({type:"info",text:ln("input.queue.item.updated",{position:Wn+1})},Date.now()))},[p,ln]),Qf=(0,qn.useCallback)((Wn,Tn=!1)=>{let ia=Wn.trim();if(ia){if(zl!=="idle"){U2(ia);return}eh(ia,Tn)}},[p,U2,Tt.length,eh,zl]);Epn(n,N,zl),(0,qn.useEffect)(()=>{if(zl!=="idle"||Tt.length===0||ut||zt||dt)return;let[Wn]=Tt;Wn&&(Mt(Tn=>Tn.slice(1)),eh(Wn))},[Tt,ut,eh,zl,zt,dt]),(0,qn.useEffect)(()=>{zt&&zl!=="idle"&&Wt(!1)},[zt,zl]);let tu=(0,qn.useCallback)(async Wn=>{let Tn=Wn.trim();if(Tn.length>0){if(st&&(K2e(Y),ot(!1)),Tn.startsWith("/")){if(Tn==="/queue clear"){if(Tt.length>0){let qr=Tt.length;Mt([]),p({type:"info",text:ln("input.queue.cleared",{count:qr})},Date.now())}else p({type:"info",text:Ke("input.queue.empty")},Date.now());return}let ia=Tn.startsWith("/refine");ia&&Ht(!0);try{let qr=await hd(Tn);if(qr!==!1){if(Tn.trim()==="/help-ask"){Ve(!0);return}if(qr.type==="handled")return;if(qr.type==="submit_prompt"){Qf(qr.content);return}else{if(qr.type==="schedule_tool")return;if(qr.type==="refine_result"){console.log("[App] \u6536\u5230 refine_result\uFF0C\u8BBE\u7F6E refineResult \u72B6\u6001");let el=cK("sent",kn),ua=cK("refined",kn),Ui=iV(qr.original,{maxRows:el,terminalWidth:Bt}),Sr=iV(qr.refined,{maxRows:ua,terminalWidth:Bt});ft({original:qr.original,refined:qr.refined,displayOriginal:Ui.displayText,displayRefined:Sr.displayText,omittedPlaceholder:Sr.omittedPlaceholder,omittedLines:Sr.omittedLines,options:qr.options});return}}}}finally{ia&&Ht(!1)}}Qf(Tn)}},[Qf,st,Y,hd]),hc=Lpn({initialText:"",viewport:{height:50,width:gl},stdin:Rn,setRawMode:Cn,isValidPath:Ds,shellModeActive:Re}),{handleInput:Hf}=Tpn(hc,tu),Qu=[...CN];Qu.push(...Cf);let{elapsedTime:jv,currentLoadingPhrase:md,estimatedInputTokens:z5}=Sqt(zl,d),pd=(0,qn.useRef)(0);(0,qn.useEffect)(()=>{zl==="responding"&&(pd.current=jv)},[jv,zl]);let{shouldShowSummary:nu,completionElapsedTime:ru}=Bqt(zl,pd.current);(0,qn.useEffect)(()=>{nu&&(Or.current+=1)},[nu]);let th=Vsn({config:n}),Xf=(0,qn.useCallback)((Wn,Tn,ia)=>{Wn?(ia.current&&clearTimeout(ia.current),hd("/quit")):(Tn(!0),ia.current=setTimeout(()=>{Tn(!1),ia.current=null},AMr))},[hd]);Ko((Wn,Tn)=>{let ia=r2n(),qr=Tn.escape||ia&&Tn.ctrl&&Wn==="q"||Ef.platform==="darwin"&&Tn.meta&&Wn==="q";if(dt){if(Tn.return){let ua=hc.text;Vf(Vt,ua),Yt(!1),Wt(!1),hc.setText("");return}else if(qr){Yt(!1),Wt(!1),hc.setText("");return}else if(Tn.ctrl&&Tn.upArrow){let ua=hc.text,Ui=Tt[Vt];ua.trim()!==Ui&&Vf(Vt,ua),Mt(Sr=>{if(Sr.length===0)return Yt(!1),Wt(!1),hc.setText(""),Sr;let Im=(Vt+1)%Sr.length;return Ut(Im),hc.setText(Sr[Im]||""),Sr});return}}else if(Tn.ctrl&&Tn.upArrow&&Tt.length>0){Yt(!0),Wt(!0),Ut(0),hc.setText(Tt[0]);return}if(ut){if(console.log("[App useInput] refineResult\u5B58\u5728\uFF0C\u5904\u7406\u6309\u952E:",{input:Wn,return:Tn.return}),Tn.return){console.log("[App useInput] \u6309\u56DE\u8F66\uFF0C\u53D1\u9001\u6DA6\u8272\u540E\u7684\u6587\u672C\u7ED9 AI");let ua=ut.refined;ft(null),hc.setText(""),Qf(ua,!0);return}else if(Wn.toLowerCase()==="r"){let ua=ut.original;ft(null),hc.setText(""),Ht(!0),(async()=>{try{let Ui=await hd(`/refine ${ua}`);if(Ui!==!1&&Ui.type==="refine_result"){let Sr=cK("sent",kn),Im=cK("refined",kn),$v=iV(Ui.original,{maxRows:Sr,terminalWidth:Bt}),eZ=iV(Ui.refined,{maxRows:Im,terminalWidth:Bt});ft({original:Ui.original,refined:Ui.refined,displayOriginal:$v.displayText,displayRefined:eZ.displayText,omittedPlaceholder:eZ.omittedPlaceholder,omittedLines:eZ.omittedLines,options:Ui.options})}}catch{}finally{Ht(!1)}})();return}else if(Wn.toLowerCase()==="f"){ut.omittedLines&&ft({...ut,showFullText:!0});return}else if(qr){ft(null),hc.setText("");return}}if(qr&&L){S(!1);return}let el=!1;if(oe||(el=!0,pe(!0)),Tn.ctrl&&Wn==="o")ze(ua=>!ua);else if(Tn.ctrl&&Wn==="s")Xe&&pe(ua=>!ua);else if(Tn.ctrl&&Wn==="t"){let ua=!nt;lt(ua);let Ui=n.getMcpServers();Object.keys(Ui||{}).length>0&&hd(ua?"/mcp desc":"/mcp nodesc")}else if(Tn.ctrl&&Wn==="e"&&Rv)De(ua=>!ua);else if(Tn.ctrl&&(Wn==="c"||Wn==="C"))Xf(Ue,et,Be);else if(Tn.ctrl&&(Wn==="d"||Wn==="D")){if(hc.text.length>0)return;Xf(tt,ne,fe)}}),(0,qn.useEffect)(()=>{n&&B(n.getGeminiMdFileCount())},[n]);let M2=Ohe(),[vp,kf]=(0,qn.useState)([]);(0,qn.useEffect)(()=>{(async()=>{let Tn=await M2?.getPreviousUserMessages()||[],qr=[...N.filter(ua=>ua.type==="user"&&typeof ua.text=="string"&&ua.text.trim()!=="").map(ua=>ua.text).reverse(),...Tn],el=[];if(qr.length>0){el.push(qr[0]);for(let ua=1;ua<qr.length;ua++)qr[ua]!==qr[ua-1]&&el.push(qr[ua])}kf(el.reverse())})()},[N,M2]);let VN=!ut&&!gp,QN=(0,qn.useCallback)(()=>{m(),O(),K2e(Y),V()},[m,O,Y,V]),Zp=(0,qn.useRef)(null),Kv=(0,qn.useRef)(null),WG=(0,qn.useRef)(null);(0,qn.useEffect)(()=>{if(Zp.current){let Wn=u7(Zp.current);se(Wn.height)}},[kn,Z,Xe]),Upn(WG,kn,n,oe);let Ys=3,nh=(0,qn.useMemo)(()=>kn-ie-Ys,[kn,ie]),z2=Math.floor(Bt*.9),HN=(0,qn.useMemo)(()=>kn<=30?Math.max(Math.floor(nh*.6),10):kn<=50?Math.max(Math.floor(nh*.8),20):Math.max(kn*4,100),[kn,nh]),AG=(0,qn.useMemo)(()=>{let Wn=[(0,zn.jsx)(Gt,{flexDirection:"column",children:!t.merged.hideBanner&&st&&(0,zn.jsx)(Ssn,{config:n,version:a,customProxyUrl:s})},"header")];return Wn.push(...N.map(Tn=>(0,zn.jsx)(T2e,{terminalWidth:z2,availableTerminalHeight:HN,item:Tn,isPending:!1,config:n},`${X}-${Tn.id}`))),nu&&ru>0&&Wn.push((0,zn.jsx)(e$t,{elapsedTime:ru,isVisible:!0},`completion-${Or.current}`)),Wn},[N,z2,HN,X,Bt,t.merged.hideBanner,t.merged.hideTips,n,nu,ru,Or]);(0,qn.useEffect)(()=>{if(gr.current){gr.current=!1;return}let Wn=Q.refreshDebounceMs,Tn=setTimeout(()=>{D(!1),V()},Wn);return()=>{clearTimeout(Tn)}},[Bt,kn,V,Q.refreshDebounceMs]),(0,qn.useEffect)(()=>{if(zl==="idle"&&J)return D(!1),F()},[zl,F,J]);let _5=(0,qn.useMemo)(()=>n.getDebugMode()?Z:Z.filter(Wn=>Wn.type!=="debug"),[Z,n]),FG=Cpn(n.getTargetDir()),XN=(0,qn.useMemo)(()=>{let Wn=t.merged.contextFileName;return Wn?Array.isArray(Wn)?Wn:[Wn]:_C()},[t.merged.contextFileName]),kN=(0,qn.useMemo)(()=>n.getQuestion(),[n]),Np=n.getGeminiClient(),Lf=(0,qn.useMemo)(()=>{if(Tt.length===0)return"";let Wn=Tt[0].replace(/\s+/g," ").trim();return Wn?Wn.length>80?`${Wn.slice(0,80)}...`:Wn:""},[Tt]);(0,qn.useEffect)(()=>{kN&&!lr.current&&!at&&!bt&&!We&&!Et&&!gn&&!ee&&!fn&&!we&&Np?.isInitialized?.()&&(eh(kN),lr.current=!0)},[kN,at,bt,We,Et,gn,ee,fn,we,Np,eh]);let LN=He?(0,zn.jsx)(Gt,{flexDirection:"column",marginBottom:1,children:He.map(Wn=>(0,zn.jsx)(T2e,{availableTerminalHeight:oe?nh:void 0,terminalWidth:Bt,item:Wn,isPending:!1,config:n},Wn.id))}):null,qv=Math.floor(Math.max(kn*.2,5)),JN=Math.floor(Math.max(kn*.6,10)),Hu=oe?qv:JN,rh=Ae?" \u8BA1\u5212\u6A21\u5F0F\uFF1A\u53EF\u8BFB\u53D6\u4EE3\u7801\u5206\u6790\uFF0C\u7981\u6B62\u4FEE\u6539 (/plan off \u9000\u51FA)":q0?" \u6309 'i' \u8FDB\u5165\u63D2\u5165\u6A21\u5F0F\uFF0C\u6309 'Esc' \u8FDB\u5165\u666E\u901A\u6A21\u5F0F\u3002":" \u8F93\u5165\u60A8\u7684\u6D88\u606F\u6216 @\u6587\u4EF6\u8DEF\u5F84",Wp=()=>Xe?(0,zn.jsx)(Gt,{flexDirection:"column",children:(0,zn.jsx)(Kpn,{messages:_5,height:Hu,width:gl})}):null;return LN||(0,zn.jsx)(a7e.Provider,{value:zl,children:(0,zn.jsxs)(Gt,{flexDirection:"column",width:"90%",ref:WG,children:[E?(0,zn.jsx)(Mpn,{message:E}):null,(0,zn.jsx)(H$,{items:AG,children:Wn=>Wn},X),(0,zn.jsx)(PIn,{children:(0,zn.jsxs)(Gt,{ref:Kv,flexDirection:"column",children:[Qu.map((Wn,Tn)=>(0,zn.jsx)(T2e,{availableTerminalHeight:oe?nh:void 0,terminalWidth:z2,item:{...Wn,id:0},isPending:!0,config:n,isFocused:!fn},Tn)),(0,zn.jsx)(Ppn,{constrainHeight:oe})]})}),L?(0,zn.jsx)(hun,{commands:Vu}):null,O2&&!xf?(0,zn.jsx)(Fpn,{reasoning:O2,terminalHeight:kn,terminalWidth:Bt}):null,(0,zn.jsxs)(Gt,{flexDirection:"column",ref:Zp,children:[r.length>0?(0,zn.jsx)(Gt,{borderStyle:"round",borderColor:pt.AccentYellow,paddingX:1,marginY:1,flexDirection:"column",children:r.map((Wn,Tn)=>(0,zn.jsx)(rt,{color:pt.AccentYellow,children:Wn},Tn))}):null,gn?(0,zn.jsxs)(Gt,{flexDirection:"column",children:[M?(0,zn.jsx)(Gt,{marginBottom:1,children:(0,zn.jsx)(rt,{color:pt.AccentRed,children:M})}):null,(0,zn.jsx)(eun,{onSelect:Jt,onHighlight:$t,settings:t,availableTerminalHeight:oe?kn-Ys:void 0,terminalWidth:z2})]}):ee?(0,zn.jsxs)(Gt,{flexDirection:"column",children:[_?(0,zn.jsx)(Gt,{marginBottom:1,children:(0,zn.jsx)(rt,{color:pt.AccentRed,children:_})}):null,(0,zn.jsx)(tun,{onSelect:de,onHighlight:be,settings:t,config:n,availableTerminalHeight:oe?kn-Ys:void 0,terminalWidth:z2})]}):at?(0,zn.jsx)(zn.Fragment,{children:(0,zn.jsx)(K7e,{stage:"auth",onTimeout:()=>{q("Authentication timed out. Please try again."),Ft(),xe()}})}):bt?(0,zn.jsx)(zn.Fragment,{children:(0,zn.jsx)(K7e,{stage:"environment",onTimeout:()=>{q("Environment preparation timed out. Please try again."),Ft(),xe()}})}):We?(0,zn.jsx)(Gt,{flexDirection:"column",children:(0,zn.jsx)(aun,{onSelect:je,settings:t,initialErrorMessage:K})}):Et?(0,zn.jsx)(Gt,{flexDirection:"column",children:(0,zn.jsx)(iun,{onSelect:kt,settings:t,initialErrorMessage:j})}):fn?(0,zn.jsxs)(Gt,{flexDirection:"column",children:[ae?(0,zn.jsx)(Gt,{marginBottom:1,children:(0,zn.jsx)(rt,{color:pt.AccentRed,children:ae})}):null,(0,zn.jsx)(dun,{onSelect:Zn,settings:t,onExit:Hn})]}):we?(0,zn.jsx)(n2n,{onExit:()=>Ee(!1),config:n}):(0,zn.jsxs)(zn.Fragment,{children:[xN?(0,zn.jsx)(Gt,{marginBottom:1,children:(0,zn.jsxs)(rt,{color:pt.AccentBlue,children:["\u{1F504} ",Ke("checkpoint.creating")]})}):null,(0,zn.jsx)(Usn,{thought:zl==="waiting_for_confirmation"||n.getAccessibility()?.disableLoadingPhrases?void 0:T2,currentLoadingPhrase:zl==="waiting_for_confirmation"||n.getAccessibility()?.disableLoadingPhrases?void 0:md,elapsedTime:jv}),(0,zn.jsxs)(Gt,{marginTop:1,marginBottom:1,display:"flex",justifyContent:"space-between",width:"100%",children:[(0,zn.jsxs)(Gt,{children:[Ef.env.GEMINI_SYSTEM_MD?(0,zn.jsx)(rt,{color:pt.AccentRed,children:"|\u2310\u25A0_\u25A0| "}):null,Ue?(0,zn.jsx)(rt,{color:pt.AccentYellow,children:Ke("exit.confirm.ctrl.c")}):tt?(0,zn.jsx)(rt,{color:pt.AccentYellow,children:Ke("exit.confirm.ctrl.d")}):(0,zn.jsx)(Wpn,{openFiles:Zt,geminiMdFileCount:x,contextFileNames:XN,mcpServers:n.getMcpServers(),blockedMcpServers:n.getBlockedMcpServers(),showToolDescriptions:nt})]}),(0,zn.jsxs)(Gt,{children:[Ae?(0,zn.jsx)(Psn,{}):null,th!==Ja.DEFAULT&&!Re&&!ye&&!Ae?(0,zn.jsx)(Msn,{approvalMode:th}):null,Re?(0,zn.jsx)(zsn,{}):null,ye?(0,zn.jsx)(_sn,{}):null]})]}),ct?(0,zn.jsx)(Apn,{openFiles:Zt}):null,sn.isVisible?(0,zn.jsx)(Gt,{marginY:0,marginBottom:1,children:(0,zn.jsx)(Npn,{isVisible:sn.isVisible,elapsed:sn.elapsed,estimated:sn.estimated})}):null,c&&zl!=="responding"?(0,zn.jsx)(ymn,{tokenUsage:c,inputWidth:gl,cumulativeCredits:h}):null,Tt.length>0&&!gp?(0,zn.jsxs)(Gt,{marginY:1,flexDirection:"column",gap:0,children:[Tt.map((Wn,Tn)=>{let ia=Wn.length>60?`${Wn.slice(0,60)}...`:Wn;return(0,zn.jsxs)(rt,{dimColor:!0,children:[Tn===0?"\u2193":" "," ",ia]},Tn)}),Tt.length>0?(0,zn.jsx)(rt,{dimColor:!0,children:Ke("input.queue.edit.hint")}):null]}):null,dt?(0,zn.jsx)(Gt,{marginY:1,children:(0,zn.jsxs)(rt,{color:pt.AccentBlue,children:["\u{1F504} ",ln("input.queue.edit.mode",{current:Vt+1,total:Tt.length})," \u2022 ",Ke("input.queue.edit.actions")]})}):null,At?(0,zn.jsxs)(Gt,{flexDirection:"column",borderStyle:"round",borderColor:pt.AccentBlue,paddingX:1,paddingY:1,marginY:1,children:[(0,zn.jsx)(Gt,{children:(0,zn.jsxs)(rt,{bold:!0,color:pt.AccentBlue,children:["\u2728 ",Ke("command.refine.loading.title")]})}),(0,zn.jsx)(Gt,{marginTop:1,children:(0,zn.jsx)(rt,{color:pt.Gray,children:Ke("command.refine.loading.message")})})]}):null,ut&&!At?(0,zn.jsxs)(Gt,{flexDirection:"column",borderStyle:"round",borderColor:pt.AccentGreen,paddingX:1,paddingY:1,marginY:1,children:[(0,zn.jsx)(Gt,{marginBottom:1,children:(0,zn.jsx)(rt,{bold:!0,color:pt.AccentGreen,children:Ke("command.refine.confirm.title")})}),(0,zn.jsx)(Gt,{marginBottom:1,children:ut.showFullText?(0,zn.jsx)(rt,{wrap:"wrap",italic:!0,children:ut.refined}):nn(ut.displayRefined,ut.omittedPlaceholder,ut.omittedLines)}),(0,zn.jsx)(Gt,{children:(0,zn.jsx)(rt,{color:pt.Gray,children:"\u2500".repeat(50)})}),(0,zn.jsxs)(Gt,{marginTop:1,children:[(0,zn.jsx)(Gt,{marginRight:2,children:(0,zn.jsx)(rt,{bold:!0,color:pt.AccentGreen,children:Ke("command.refine.confirm.hint.send")})}),(0,zn.jsx)(Gt,{marginRight:2,children:(0,zn.jsx)(rt,{color:pt.Gray,children:"|"})}),(0,zn.jsx)(Gt,{marginRight:2,children:(0,zn.jsx)(rt,{bold:!0,color:pt.AccentYellow,children:Ke("command.refine.confirm.hint.refine-again")})}),ut.omittedLines&&!ut.showFullText?(0,zn.jsxs)(zn.Fragment,{children:[(0,zn.jsx)(Gt,{marginRight:2,children:(0,zn.jsx)(rt,{color:pt.Gray,children:"|"})}),(0,zn.jsx)(Gt,{marginRight:2,children:(0,zn.jsx)(rt,{bold:!0,color:pt.AccentBlue,children:Ke("command.refine.confirm.hint.view-full")})})]}):null,(0,zn.jsx)(Gt,{marginRight:2,children:(0,zn.jsx)(rt,{color:pt.Gray,children:"|"})}),(0,zn.jsx)(Gt,{children:(0,zn.jsx)(rt,{bold:!0,color:pt.AccentRed,children:Ke("command.refine.confirm.hint.cancel")})})]})]}):null,VN?(0,zn.jsx)(bon,{buffer:hc,inputWidth:gl,suggestionsWidth:GI,onSubmit:tu,userMessages:vp,onClearScreen:QN,openModelDialog:ue,config:n,slashCommands:Vu,commandContext:Yf,shellModeActive:Re,setShellModeActive:Ye,helpModeActive:ye,setHelpModeActive:Ve,focus:e,vimHandleInput:Hf,placeholder:rh,isModalOpen:ee||We||gn||fn,isExecutingTools:NG,isBusy:zl!=="idle"||Tt.length>0,isInSpecialMode:!!ut||dt}):null]}),gp&&zl!=="responding"?(0,zn.jsx)(Gt,{borderStyle:"round",borderColor:pt.AccentRed,paddingX:1,marginBottom:1,children:N.find(Wn=>Wn.type==="error"&&Wn.text?.includes(gp))?.text?(0,zn.jsx)(rt,{color:pt.AccentRed,children:N.find(Wn=>Wn.type==="error"&&Wn.text?.includes(gp))?.text}):(0,zn.jsxs)(zn.Fragment,{children:[(0,zn.jsxs)(rt,{color:pt.AccentRed,children:["\u521D\u59CB\u5316\u9519\u8BEF\uFF1A",gp]}),(0,zn.jsxs)(rt,{color:pt.AccentRed,children:[" ","\u8BF7\u68C0\u67E5 API \u5BC6\u94A5\u548C\u914D\u7F6E\u3002"]})]})}):null,Wp(),(0,zn.jsx)(bcn,{model:he,targetDir:n.getTargetDir(),debugMode:n.getDebugMode(),branchName:FG,debugMessage:U,corgiMode:Ie,errorCount:Gn,showErrorDetails:Xe,showMemoryUsage:n.getDebugMode()||n.getShowMemoryUsage(),promptTokenCount:k.lastPromptTokenCount,nightly:W,vimMode:q0?wf:void 0,version:a,ideConnectionStatus:Ge,config:n,terminalWidth:Bt})]})]})})};import{basename as J2n,resolve as mzr,normalize as pzr}from"node:path";import bzr from"node:v8";import Gzr from"node:os";import rOe from"node:fs";import{spawn as fzr}from"node:child_process";var TTe=Dt(oie(),1);Ru();import{exec as yMr,execSync as KR,spawn as MB}from"node:child_process";import _v from"node:os";import YN from"node:path";import om from"node:fs";import{readFile as RMr}from"node:fs/promises";import{promisify as EMr}from"util";var DTe=EMr(yMr);function D2(n){if(_v.platform()!=="win32")return n;let r=n.replace(/\\/g,"/").match(/^([A-Z]):\/(.*)/i);return r?`/${r[1].toLowerCase()}/${r[2]}`:n}var l2n="gemini-cli-sandbox",$2e="gemini-cli-sandbox",QV="gemini-cli-sandbox-proxy",wMr=["permissive-open","permissive-closed","permissive-proxied","restrictive-open","restrictive-closed","restrictive-proxied"];async function YMr(){let n=process.env.SANDBOX_SET_UID_GID?.toLowerCase().trim();if(n==="1"||n==="true")return!0;if(n==="0"||n==="false")return!1;if(_v.platform()==="linux")try{let t=await RMr("/etc/os-release","utf8");if(t.includes("ID=debian")||t.includes("ID=ubuntu")||t.match(/^ID_LIKE=.*debian.*/m)||t.match(/^ID_LIKE=.*ubuntu.*/m))return console.error("INFO: Defaulting to use current user UID/GID for Debian/Ubuntu-based Linux."),!0}catch{console.warn("Warning: Could not read /etc/os-release to auto-detect Debian/Ubuntu for UID/GID default.")}return!1}function CMr(n){let[t,r]=n.split(":"),a=t.split("/").at(-1)??"unknown-image";return r?`${a}-${r}`:a}function s2n(){return(process.env.SANDBOX_PORTS??"").split(",").filter(n=>n.trim()).map(n=>n.trim())}function xMr(n){let t=_v.platform()==="win32",r=D2(n),a=[],i=t?";":":",s="";if(process.env.PATH){let h=process.env.PATH.split(i);for(let o of h){let v=D2(o);v.toLowerCase().startsWith(r.toLowerCase())&&(s+=`:${v}`)}}s&&a.push(`export PATH="$PATH${s}";`);let e="";if(process.env.PYTHONPATH){let h=process.env.PYTHONPATH.split(i);for(let o of h){let v=D2(o);v.toLowerCase().startsWith(r.toLowerCase())&&(e+=`:${v}`)}}e&&a.push(`export PYTHONPATH="$PYTHONPATH${e}";`);let c=YN.join(A5,"sandbox.bashrc");om.existsSync(c)&&a.push(`source ${D2(c)};`),s2n().forEach(h=>a.push(`socat TCP4-LISTEN:${h},bind=$(hostname -i),fork,reuseaddr TCP4:127.0.0.1:${h} 2> /dev/null &`));let u=process.argv.slice(2).map(h=>(0,TTe.quote)([h])),d=process.env.DEBUG?`node --inspect-brk=0.0.0.0:${process.env.DEBUG_PORT||"9229"} $(which gemini)`:"gemini";return["bash","-c",[...a,d,...u].join(" ")]}async function o2n(n,t=[]){if(n.command==="sandbox-exec"){process.env.BUILD_SANDBOX&&(console.error("ERROR: cannot BUILD_SANDBOX when using macOS Seatbelt"),process.exit(1));let g=process.env.SEATBELT_PROFILE??="permissive-open",N=new URL(`sandbox-macos-${g}.sb`,import.meta.url).pathname;wMr.includes(g)||(N=YN.join(A5,`sandbox-macos-${g}.sb`)),om.existsSync(N)||(console.error(`ERROR: missing macos seatbelt profile file '${N}'`),process.exit(1)),console.error(`using macos seatbelt (profile: ${g}) ...`);let p=[...process.env.DEBUG?["--inspect-brk"]:[],...t].join(" "),m=["-D",`TARGET_DIR=${om.realpathSync(process.cwd())}`,"-D",`TMP_DIR=${om.realpathSync(_v.tmpdir())}`,"-D",`HOME_DIR=${om.realpathSync(_v.homedir())}`,"-D",`CACHE_DIR=${om.realpathSync(KR("getconf DARWIN_USER_CACHE_DIR").toString().trim())}`,"-f",N,"sh","-c",["SANDBOX=sandbox-exec",`NODE_OPTIONS="${p}"`,...process.argv.map(k=>(0,TTe.quote)([k]))].join(" ")],G=process.env.GEMINI_SANDBOX_PROXY_COMMAND,Z,C,O={...process.env};if(G){let k=process.env.HTTPS_PROXY||process.env.https_proxy||process.env.HTTP_PROXY||process.env.http_proxy||"http://localhost:8877";O.HTTPS_PROXY=k,O.https_proxy=k,O.HTTP_PROXY=k,O.http_proxy=k;let J=process.env.NO_PROXY||process.env.no_proxy;J&&(O.NO_PROXY=J,O.no_proxy=J),Z=MB(G,{stdio:["ignore","pipe","pipe"],shell:!0,detached:!0});let D=()=>{console.log("stopping proxy ..."),Z?.pid&&process.kill(-Z.pid,"SIGTERM")};process.on("exit",D),process.on("SIGINT",D),process.on("SIGTERM",D),Z.stderr?.on("data",X=>{console.error(X.toString())}),Z.on("close",(X,H)=>{console.error(`ERROR: proxy command '${G}' exited with code ${X}, signal ${H}`),C?.pid&&process.kill(-C.pid,"SIGTERM"),process.exit(1)}),console.log("waiting for proxy to start ..."),await DTe("until timeout 0.25 curl -s http://localhost:8877; do sleep 0.25; done")}C=MB(n.command,m,{stdio:"inherit"}),await new Promise(k=>C?.on("close",k));return}console.error(`hopping into sandbox (command: ${n.command}) ...`);let r=om.realpathSync(process.argv[1]),a=YN.join(A5,"sandbox.Dockerfile"),i=om.existsSync(a),s=n.image,e=YN.resolve(process.cwd()),c=D2(e);if(process.env.BUILD_SANDBOX)if(!r.includes("gemini-cli/packages/"))console.error("ERROR: cannot build sandbox using installed gemini binary; run `npm link ./packages/cli` under gemini-cli repo to switch to linked binary."),process.exit(1);else{console.error("building sandbox ...");let g=r.split("/packages/")[0],N="",p=YN.join(A5,"sandbox.Dockerfile");i&&(console.error(`using ${p} for sandbox`),N+=`-f ${YN.resolve(p)} -i ${s}`),KR(`cd ${g} && node scripts/build_sandbox.js -s ${N}`,{stdio:"inherit",env:{...process.env,GEMINI_SANDBOX:n.command}})}await QMr(n.command,s)||(console.error(`ERROR: Sandbox image '${s}' is missing or could not be pulled. ${s===l2n?"Try running `npm run build:all` or `npm run build:sandbox` under the gemini-cli repo to build it locally, or check the image name and your network connection.":"Please check the image name, your network connection, or notify gemini-cli-dev@google.com if the issue persists."}`),process.exit(1));let u=["run","-i","--rm","--init","--workdir",c];process.stdin.isTTY&&u.push("-t"),u.push("--volume",`${e}:${c}`);let d=_Se,I=D2(`/home/node/${A5}`);om.existsSync(d)||om.mkdirSync(d),u.push("--volume",`${d}:${I}`),I!==d&&u.push("--volume",`${d}:${D2(d)}`),u.push("--volume",`${_v.tmpdir()}:${D2(_v.tmpdir())}`);let h=YN.join(_v.homedir(),".config","gcloud");if(om.existsSync(h)&&u.push("--volume",`${h}:${D2(h)}:ro`),process.env.GOOGLE_APPLICATION_CREDENTIALS){let g=process.env.GOOGLE_APPLICATION_CREDENTIALS;om.existsSync(g)&&(u.push("--volume",`${g}:${D2(g)}:ro`),u.push("--env",`GOOGLE_APPLICATION_CREDENTIALS=${D2(g)}`))}if(process.env.SANDBOX_MOUNTS){for(let g of process.env.SANDBOX_MOUNTS.split(","))if(g.trim()){let[N,p,m]=g.trim().split(":");p=p||N,m=m||"ro",g=`${N}:${p}:${m}`,YN.isAbsolute(N)||(console.error(`ERROR: path '${N}' listed in SANDBOX_MOUNTS must be absolute`),process.exit(1)),om.existsSync(N)||(console.error(`ERROR: missing mount path '${N}' listed in SANDBOX_MOUNTS`),process.exit(1)),console.error(`SANDBOX_MOUNTS: ${N} -> ${p} (${m})`),u.push("--volume",g)}}if(s2n().forEach(g=>u.push("--publish",`${g}:${g}`)),process.env.DEBUG){let g=process.env.DEBUG_PORT||"9229";u.push("--publish",`${g}:${g}`)}let o=process.env.GEMINI_SANDBOX_PROXY_COMMAND;if(o){let g=process.env.HTTPS_PROXY||process.env.https_proxy||process.env.HTTP_PROXY||process.env.http_proxy||"http://localhost:8877";g=g.replace("localhost",QV),g&&(u.push("--env",`HTTPS_PROXY=${g}`),u.push("--env",`https_proxy=${g}`),u.push("--env",`HTTP_PROXY=${g}`),u.push("--env",`http_proxy=${g}`));let N=process.env.NO_PROXY||process.env.no_proxy;N&&(u.push("--env",`NO_PROXY=${N}`),u.push("--env",`no_proxy=${N}`)),g&&(KR(`${n.command} network inspect ${$2e} || ${n.command} network create --internal ${$2e}`),u.push("--network",$2e),o&&KR(`${n.command} network inspect ${QV} || ${n.command} network create ${QV}`))}let v=CMr(s),w=0,R=KR(`${n.command} ps -a --format "{{.Names}}"`).toString().trim();for(;R.includes(`${v}-${w}`);)w++;let E=`${v}-${w}`;if(u.push("--name",E,"--hostname",E),process.env.GEMINI_API_KEY&&u.push("--env",`GEMINI_API_KEY=${process.env.GEMINI_API_KEY}`),process.env.GOOGLE_API_KEY&&u.push("--env",`GOOGLE_API_KEY=${process.env.GOOGLE_API_KEY}`),process.env.GOOGLE_GENAI_USE_VERTEXAI&&u.push("--env",`GOOGLE_GENAI_USE_VERTEXAI=${process.env.GOOGLE_GENAI_USE_VERTEXAI}`),process.env.GOOGLE_GENAI_USE_GCA&&u.push("--env",`GOOGLE_GENAI_USE_GCA=${process.env.GOOGLE_GENAI_USE_GCA}`),process.env.GOOGLE_CLOUD_PROJECT&&u.push("--env",`GOOGLE_CLOUD_PROJECT=${process.env.GOOGLE_CLOUD_PROJECT}`),process.env.GOOGLE_CLOUD_LOCATION&&u.push("--env",`GOOGLE_CLOUD_LOCATION=${process.env.GOOGLE_CLOUD_LOCATION}`),process.env.GEMINI_MODEL&&u.push("--env",`GEMINI_MODEL=${process.env.GEMINI_MODEL}`),process.env.TERM&&u.push("--env",`TERM=${process.env.TERM}`),process.env.COLORTERM&&u.push("--env",`COLORTERM=${process.env.COLORTERM}`),process.env.VIRTUAL_ENV?.toLowerCase().startsWith(e.toLowerCase())){let g=YN.resolve(A5,"sandbox.venv");om.existsSync(g)||om.mkdirSync(g,{recursive:!0}),u.push("--volume",`${g}:${D2(process.env.VIRTUAL_ENV)}`),u.push("--env",`VIRTUAL_ENV=${D2(process.env.VIRTUAL_ENV)}`)}if(process.env.SANDBOX_ENV)for(let g of process.env.SANDBOX_ENV.split(","))(g=g.trim())&&(g.includes("=")?(console.error(`SANDBOX_ENV: ${g}`),u.push("--env",g)):(console.error("ERROR: SANDBOX_ENV must be a comma-separated list of key=value pairs"),process.exit(1)));let A=process.env.NODE_OPTIONS||"",Y=[...A?[A]:[],...t].join(" ");if(Y.length>0&&u.push("--env",`NODE_OPTIONS="${Y}"`),u.push("--env",`SANDBOX=${E}`),n.command==="podman"){let g=YN.join(_v.tmpdir(),"empty_auth.json");om.writeFileSync(g,"{}","utf-8"),u.push("--authfile",g)}let W="",y=xMr(e);if(process.env.GEMINI_CLI_INTEGRATION_TEST==="true")u.push("--user","root"),W="--user root";else if(await YMr()){u.push("--user","root");let g=KR("id -u").toString().trim(),N=KR("id -g").toString().trim(),p="gemini",m=D2(_v.homedir()),G=[`groupadd -f -g ${N} ${p}`,`id -u ${p} &>/dev/null || useradd -o -u ${g} -g ${N} -d ${m} -s /bin/bash ${p}`].join(" && "),C=y[2].replace(/'/g,"'\\''"),O=`su -p ${p} -c '${C}'`;y[2]=`${G} && ${O}`,W=`--user ${g}:${N}`,u.push("--env",`HOME=${_v.homedir()}`)}u.push(s),u.push(...y);let b,f;if(o){let g=`${n.command} run --rm --init ${W} --name ${QV} --network ${QV} -p 8877:8877 -v ${process.cwd()}:${e} --workdir ${e} ${s} ${o}`;b=MB(g,{stdio:["ignore","pipe","pipe"],shell:!0,detached:!0});let N=()=>{console.log("stopping proxy container ..."),KR(`${n.command} rm -f ${QV}`)};process.on("exit",N),process.on("SIGINT",N),process.on("SIGTERM",N),b.stderr?.on("data",p=>{console.error(p.toString().trim())}),b.on("close",(p,m)=>{console.error(`ERROR: proxy container command '${g}' exited with code ${p}, signal ${m}`),f?.pid&&process.kill(-f.pid,"SIGTERM"),process.exit(1)}),console.log("waiting for proxy to start ..."),await DTe("until timeout 0.25 curl -s http://localhost:8877; do sleep 0.25; done"),await DTe(`${n.command} network connect ${$2e} ${QV}`)}f=MB(n.command,u,{stdio:"inherit"}),f.on("error",g=>{console.error("Sandbox process error:",g)}),await new Promise(g=>{f?.on("close",(N,p)=>{N!==0&&console.log(`Sandbox process exited with code: ${N}, signal: ${p}`),g()})})}async function i2n(n,t){return new Promise(r=>{let i=MB(n,["images","-q",t]),s="";i.stdout&&i.stdout.on("data",e=>{s+=e.toString()}),i.on("error",e=>{console.warn(`Failed to start '${n}' command for image check: ${e.message}`),r(!1)}),i.on("close",e=>{r(s.trim()!=="")})})}async function VMr(n,t){return console.info(`Attempting to pull image ${t} using ${n}...`),new Promise(r=>{let i=MB(n,["pull",t],{stdio:"pipe"}),s="",e=h=>{console.info(h.toString().trim())},c=h=>{s+=h.toString(),console.error(h.toString().trim())},u=h=>{console.warn(`Failed to start '${n} pull ${t}' command: ${h.message}`),I(),r(!1)},d=h=>{h===0?(console.info(`Successfully pulled image ${t}.`),I(),r(!0)):(console.warn(`Failed to pull image ${t}. '${n} pull ${t}' exited with code ${h}.`),s.trim(),I(),r(!1))},I=()=>{i.stdout&&i.stdout.removeListener("data",e),i.stderr&&i.stderr.removeListener("data",c),i.removeListener("error",u),i.removeListener("close",d),i.connected&&i.disconnect()};i.stdout&&i.stdout.on("data",e),i.stderr&&i.stderr.on("data",c),i.on("error",u),i.on("close",d)})}async function QMr(n,t){return console.info(`Checking for sandbox image: ${t}`),await i2n(n,t)?(console.info(`Sandbox image ${t} found locally.`),!0):(console.info(`Sandbox image ${t} not found locally.`),t===l2n?!1:await VMr(n,t)?await i2n(n,t)?(console.info(`Sandbox image ${t} is now available after pulling.`),!0):(console.warn(`Sandbox image ${t} still not found after a pull attempt. This might indicate an issue with the image name or registry, or the pull command reported success but failed to make the image available.`),!1):(console.error(`Failed to obtain sandbox image ${t} after check and pull attempt.`),!1))}Ru();Wr();import OTe from"fs/promises";import HMr from"os";import{join as XMr}from"node:path";var UTe=XMr(HMr.tmpdir(),"gemini-cli-warnings.txt");async function c2n(){try{await OTe.access(UTe);let t=(await OTe.readFile(UTe,"utf-8")).split(`
5035
5035
  `).filter(r=>r.trim()!=="");try{await OTe.unlink(UTe)}catch{t.push("Warning: Could not delete temporary warnings file.")}return t}catch(n){return n instanceof Error&&"code"in n&&n.code==="ENOENT"?[]:[`Error checking/reading warnings file: ${rr(n)}`]}}Nr();import MTe from"fs/promises";import*as I2n from"os";import kMr from"path";var LMr={id:"home-directory",check:async n=>{try{let[t,r]=await Promise.all([MTe.realpath(n),MTe.realpath(I2n.homedir())]);return t===r?Ke("startup.warning.home.directory"):null}catch{return Ke("startup.warning.filesystem.error")}}},JMr={id:"root-directory",check:async n=>{try{let t=await MTe.realpath(n);return kMr.dirname(t)===t?Ke("startup.warning.root.directory"):null}catch{return Ke("startup.warning.filesystem.error")}}},SMr={id:"custom-proxy-server",check:async(n,t)=>null},BMr=[LMr,JMr,SMr];async function u2n(n,t){return(await Promise.all(BMr.map(a=>a.check(n,t)))).filter(a=>a!==null)}Wr();Bi();Wr();Yhe();Wr();function zB(n){let t=JSON.stringify(n);process.stdout.write(t+`
5036
5036
  `)}function d2n(n,t){zB({type:"init",timestamp:new Date().toISOString(),session_id:n,model:t})}function zTe(n,t,r=!1){zB({type:"message",timestamp:new Date().toISOString(),role:n,content:t,...r&&{delta:!0}})}function h2n(n,t,r){zB({type:"tool_use",timestamp:new Date().toISOString(),tool_name:n,tool_id:t,parameters:r})}function ebe(n,t,r){zB({type:"tool_result",timestamp:new Date().toISOString(),tool_id:n,status:t,output:r})}function tbe(n,t){zB({type:"error",timestamp:new Date().toISOString(),error:n,...t&&{details:t}})}function _Te(n,t){zB({type:"result",timestamp:new Date().toISOString(),status:n,...t&&{stats:t}})}function DMr(n){if(n.candidates&&n.candidates.length>0){let t=n.candidates[0];if(t.content&&t.content.parts&&t.content.parts.length>0)return t.content.parts[0]?.thought?null:t.content.parts.filter(a=>a.text).map(a=>a.text).join("")}return null}async function TMr(){let n=Date.now(),t=15e3,r=100;for(;Date.now()-n<t;){if(xm()===CI.COMPLETED)return;await new Promise(i=>setTimeout(i,r))}}async function m2n(n,t,r,a="default"){await n.initialize(),await TMr(),process.stdout.on("error",o=>{o.code==="EPIPE"&&process.exit(0)});let i=n.getGeminiClient(),s=await n.getToolRegistry(),e=await i.getChat(),c=new AbortController,u=[{role:la.USER,parts:[{text:t}]}],d=0,I=n.getModel(),h=s3(I);a==="stream-json"&&(d2n(n.getSessionId(),I),zTe("user",t));try{for(;;){if(d++,n.getMaxSessionTurns()>0&&d>n.getMaxSessionTurns()){console.error(`
5037
5037
  Reached max session turns for this session. Increase the number of turns by specifying maxSessionTurns in settings.json.`);return}let o=[],v,w=!1,R=await e.sendMessageStream({message:u[0]?.parts||[],config:{abortSignal:c.signal,tools:[{functionDeclarations:s.getFunctionDeclarations()}]}},r,Fa.CHAT_CONVERSATION);for await(let E of R){if(c.signal.aborted){console.error("Operation cancelled.");return}E.candidates?.[0]?.finishReason&&(v=E.candidates[0].finishReason);let A=DMr(E);A&&(a==="stream-json"?zTe("assistant",A,!0):process.stdout.write(A)),E.functionCalls&&o.push(...E.functionCalls)}if(h.proneToIncompleteStream&&o.length>0&&(w=JLe(o,I),w&&a!=="stream-json"&&console.error(`