@fungi.computer/grove 0.0.0-stage → 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +106 -2
- package/dist/assets/Effect-BEduymlz.js +76 -0
- package/dist/assets/MapleMono-VF-CCDrizxw.woff2 +0 -0
- package/dist/assets/Nunito-VF-8c6a9bb-cyrillic-BsWUdSU9.woff2 +0 -0
- package/dist/assets/Nunito-VF-8c6a9bb-cyrillic-ext-Cb1j0nGJ.woff2 +0 -0
- package/dist/assets/Nunito-VF-8c6a9bb-latin-BYs3GYNf.woff2 +0 -0
- package/dist/assets/Nunito-VF-8c6a9bb-latin-ext-0RvtKGDy.woff2 +0 -0
- package/dist/assets/Nunito-VF-8c6a9bb-vietnamese-cS2dauUA.woff2 +0 -0
- package/dist/assets/anthropic-messages-Bnv5qjAJ.js +41 -0
- package/dist/assets/azure-openai-responses-QZaJy-8U.js +1 -0
- package/dist/assets/base-face-CJPKiwfc.js +1 -0
- package/dist/assets/burger-DMbWZ2jd.js +1 -0
- package/dist/assets/cat-UfLh6DHG.js +1 -0
- package/dist/assets/cloudflare-workers-ai-system-one-Bq-3_D9p.js +1 -0
- package/dist/assets/compat-CvJ9Wfru.js +2 -0
- package/dist/assets/diagnostics-CmW2yJSB.js +1 -0
- package/dist/assets/error-CJ3RHG07.js +1 -0
- package/dist/assets/error-body-pkrba6pf.js +1 -0
- package/dist/assets/extension-hook-DvcdepgP.js +560 -0
- package/dist/assets/extensions-1Fd4Wd8r.js +1 -0
- package/dist/assets/github-copilot-headers-DRgtIyTm.js +1 -0
- package/dist/assets/google-generative-ai-DP-8xZvz.js +1 -0
- package/dist/assets/google-shared-Cs5udoZV.js +8 -0
- package/dist/assets/google-vertex-BJiAIGUd.js +1 -0
- package/dist/assets/hash-yQufAZII.js +1 -0
- package/dist/assets/headers-FK4rgixo.js +1 -0
- package/dist/assets/index-DBHVAvuX.css +1 -0
- package/dist/assets/index-hJphFjkO.js +171 -0
- package/dist/assets/json-parse-nqKewMRF.js +3 -0
- package/dist/assets/mistral-conversations-mRYg3mWw.js +4 -0
- package/dist/assets/models-CcNnosqL.js +1 -0
- package/dist/assets/mushroom-BBaCYNmw.js +1 -0
- package/dist/assets/node.browser-CwSOSQcL.js +1 -0
- package/dist/assets/node.browser-DFtqp6Hr.js +1 -0
- package/dist/assets/openai-Cpe0uoXQ.js +19 -0
- package/dist/assets/openai-codex-responses-BMz-j1hp.js +9 -0
- package/dist/assets/openai-completions-BxBCgHHI.js +5 -0
- package/dist/assets/openai-prompt-cache-DXo9f3w5.js +1 -0
- package/dist/assets/openai-responses-cvwOEFWg.js +1 -0
- package/dist/assets/openai-responses-shared-DzD8B6NI.js +10 -0
- package/dist/assets/openrouter-images-DwousKhc.js +1 -0
- package/dist/assets/parakeet-conversation-C3pQoKx-.js +3 -0
- package/dist/assets/parakeet-conversation-COndlivb.css +1 -0
- package/dist/assets/pi-messages-CfXPQ4jp.js +7 -0
- package/dist/assets/preload-helper-mbhLTglw.js +8 -0
- package/dist/assets/provider-env-CcCbsTJq.js +1 -0
- package/dist/assets/provider-retry-CSlu6hjs.js +1 -0
- package/dist/assets/renderer-BdjuCi44.js +1 -0
- package/dist/assets/rolldown-runtime-hePW80VL.js +1 -0
- package/dist/assets/runtime-core-CvcjUkf6.js +2 -0
- package/dist/assets/sanitize-unicode-DmIE6hZJ.js +1 -0
- package/dist/assets/system-one-shared-CGF8IYMZ.js +1 -0
- package/dist/assets/transform-messages-CrQEqmfx.js +1 -0
- package/dist/assets/typesafe-system-one-CWcJw-Ys.js +1 -0
- package/dist/index.html +17 -0
- package/package.json +172 -3
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import{r as e,t}from"./rolldown-runtime-hePW80VL.js";import{h as n,n as r}from"./preload-helper-mbhLTglw.js";import{n as i}from"./models-CcNnosqL.js";import{f as a,t as o,u as s}from"./transform-messages-CrQEqmfx.js";import{t as c}from"./provider-retry-CSlu6hjs.js";import{t as l}from"./sanitize-unicode-DmIE6hZJ.js";var u=t(((e,t)=>{function n(e,t){typeof t==`boolean`&&(t={forever:t}),this._originalTimeouts=JSON.parse(JSON.stringify(e)),this._timeouts=e,this._options=t||{},this._maxRetryTime=t&&t.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._timer=null,this._options.forever&&(this._cachedTimeouts=this._timeouts.slice(0))}t.exports=n,n.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts.slice(0)},n.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timer&&clearTimeout(this._timer),this._timeouts=[],this._cachedTimeouts=null},n.prototype.retry=function(e){if(this._timeout&&clearTimeout(this._timeout),!e)return!1;var t=new Date().getTime();if(e&&t-this._operationStart>=this._maxRetryTime)return this._errors.push(e),this._errors.unshift(Error(`RetryOperation timeout occurred`)),!1;this._errors.push(e);var n=this._timeouts.shift();if(n===void 0){if(this._cachedTimeouts)this._errors.splice(0,this._errors.length-1),n=this._cachedTimeouts.slice(-1);else return!1}var r=this;return this._timer=setTimeout(function(){r._attempts++,r._operationTimeoutCb&&(r._timeout=setTimeout(function(){r._operationTimeoutCb(r._attempts)},r._operationTimeout),r._options.unref&&r._timeout.unref()),r._fn(r._attempts)},n),this._options.unref&&this._timer.unref(),!0},n.prototype.attempt=function(e,t){this._fn=e,t&&(t.timeout&&(this._operationTimeout=t.timeout),t.cb&&(this._operationTimeoutCb=t.cb));var n=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){n._operationTimeoutCb()},n._operationTimeout)),this._operationStart=new Date().getTime(),this._fn(this._attempts)},n.prototype.try=function(e){console.log(`Using RetryOperation.try() is deprecated`),this.attempt(e)},n.prototype.start=function(e){console.log(`Using RetryOperation.start() is deprecated`),this.attempt(e)},n.prototype.start=n.prototype.try,n.prototype.errors=function(){return this._errors},n.prototype.attempts=function(){return this._attempts},n.prototype.mainError=function(){if(this._errors.length===0)return null;for(var e={},t=null,n=0,r=0;r<this._errors.length;r++){var i=this._errors[r],a=i.message,o=(e[a]||0)+1;e[a]=o,o>=n&&(t=i,n=o)}return t}})),d=t((e=>{var t=u();e.operation=function(n){return new t(e.timeouts(n),{forever:n&&(n.forever||n.retries===1/0),unref:n&&n.unref,maxRetryTime:n&&n.maxRetryTime})},e.timeouts=function(e){if(e instanceof Array)return[].concat(e);var t={retries:10,factor:2,minTimeout:1e3,maxTimeout:1/0,randomize:!1};for(var n in e)t[n]=e[n];if(t.minTimeout>t.maxTimeout)throw Error(`minTimeout is greater than maxTimeout`);for(var r=[],i=0;i<t.retries;i++)r.push(this.createTimeout(i,t));return e&&e.forever&&!r.length&&r.push(this.createTimeout(i,t)),r.sort(function(e,t){return e-t}),r},e.createTimeout=function(e,t){var n=t.randomize?Math.random()+1:1,r=Math.round(n*Math.max(t.minTimeout,1)*t.factor**+e);return r=Math.min(r,t.maxTimeout),r},e.wrap=function(t,n,r){if(n instanceof Array&&(r=n,n=null),!r)for(var i in r=[],t)typeof t[i]==`function`&&r.push(i);for(var a=0;a<r.length;a++){var o=r[a],s=t[o];t[o]=function(r){var i=e.operation(n),a=Array.prototype.slice.call(arguments,1),o=a.pop();a.push(function(e){i.retry(e)||(e&&(arguments[0]=i.mainError()),o.apply(this,arguments))}),i.attempt(function(){r.apply(t,a)})}.bind(t,s),t[o].options=n}}})),f=t(((e,t)=>{t.exports=d()})),p=e(t(((e,t)=>{var n=f(),r=[`Failed to fetch`,`NetworkError when attempting to fetch resource.`,`The Internet connection appears to be offline.`,`Network request failed`],i=class extends Error{constructor(e){super(),e instanceof Error?(this.originalError=e,{message:e}=e):(this.originalError=Error(e),this.originalError.stack=this.stack),this.name=`AbortError`,this.message=e}},a=(e,t,n)=>{let r=n.retries-(t-1);return e.attemptNumber=t,e.retriesLeft=r,e},o=e=>r.includes(e),s=(e,t)=>new Promise((r,s)=>{t={onFailedAttempt:()=>{},retries:10,...t};let c=n.operation(t);c.attempt(async n=>{try{r(await e(n))}catch(e){if(!(e instanceof Error)){s(TypeError(`Non-error was thrown: "${e}". You should only throw errors.`));return}if(e instanceof i)c.stop(),s(e.originalError);else if(e instanceof TypeError&&!o(e.message))c.stop(),s(e);else{a(e,n,t);try{await t.onFailedAttempt(e)}catch(e){s(e);return}c.retry(e)||s(c.mainError())}}})});t.exports=s,t.exports.default=s,t.exports.AbortError=i}))(),1),m=void 0,h=void 0;function g(){return{geminiUrl:m,vertexUrl:h}}function _(e,t,n,r){if(!e?.baseUrl){let e=g();return t?e.vertexUrl??n:e.geminiUrl??r}return e.baseUrl}var v=class{};function y(e,t){return e.replace(/\{([^}]+)\}/g,(e,n)=>{if(Object.prototype.hasOwnProperty.call(t,n)){let e=t[n];return e==null?``:String(e)}throw Error(`Key '${n}' not found in valueMap.`)})}function b(e,t,n){for(let r=0;r<t.length-1;r++){let i=t[r];if(i.endsWith(`[]`)){let a=i.slice(0,-2);if(!(a in e)){if(Array.isArray(n))e[a]=Array.from({length:n.length},()=>({}));else throw Error(`Value must be a list given an array path ${i}`)}if(Array.isArray(e[a])){let i=e[a];if(Array.isArray(n))for(let e=0;e<i.length;e++){let a=i[e];b(a,t.slice(r+1),n[e])}else for(let e of i)b(e,t.slice(r+1),n)}return}if(i.endsWith(`[0]`)){let a=i.slice(0,-3);a in e||(e[a]=[{}]);let o=e[a];b(o[0],t.slice(r+1),n);return}(!e[i]||typeof e[i]!=`object`)&&(e[i]={}),e=e[i]}let r=t[t.length-1],i=e[r];if(i!==void 0){if(!n||typeof n==`object`&&Object.keys(n).length===0||n===i)return;if(typeof i==`object`&&typeof n==`object`&&i!==null&&n!==null)Object.assign(i,n);else throw Error(`Cannot set value for an existing key. Key: ${r}`)}else r===`_self`&&typeof n==`object`&&n&&!Array.isArray(n)?Object.assign(e,n):e[r]=n}function x(e,t,n=void 0){try{if(t.length===1&&t[0]===`_self`)return e;for(let r=0;r<t.length;r++){if(typeof e!=`object`||!e)return n;let i=t[r];if(i.endsWith(`[]`)){let a=i.slice(0,-2);if(a in e){let i=e[a];return Array.isArray(i)?i.map(e=>x(e,t.slice(r+1),n)):n}return n}e=e[i]}return e}catch(e){if(e instanceof TypeError)return n;throw e}}function S(e,t){for(let[n,r]of Object.entries(t)){let t=n.split(`.`),i=r.split(`.`),a=new Set,o=-1;for(let e=0;e<t.length;e++)if(t[e]===`*`){o=e;break}if(o!==-1&&i.length>o)for(let e=o;e<i.length;e++){let t=i[e];t!==`*`&&!t.endsWith(`[]`)&&!t.endsWith(`[0]`)&&a.add(t)}C(e,t,i,0,a)}}function C(e,t,n,r,i){if(r>=t.length||typeof e!=`object`||!e)return;let a=t[r];if(a.endsWith(`[]`)){let o=a.slice(0,-2),s=e;if(o in s&&Array.isArray(s[o]))for(let e of s[o])C(e,t,n,r+1,i)}else if(a===`*`){if(typeof e==`object`&&e&&!Array.isArray(e)){let t=e,a=Object.keys(t).filter(e=>!e.startsWith(`_`)&&!i.has(e)),o={};for(let e of a)o[e]=t[e];for(let[e,i]of Object.entries(o)){let a=[];for(let t of n.slice(r))t===`*`?a.push(e):a.push(t);b(t,a,i)}for(let e of a)delete t[e]}}else{let o=e;a in o&&C(o[a],t,n,r+1,i)}}function w(e){if(typeof e!=`string`)throw Error(`fromImageBytes must be a string`);return e}function T(e){let t={},n=x(e,[`operationName`]);n!=null&&b(t,[`operationName`],n);let r=x(e,[`resourceName`]);return r!=null&&b(t,[`_url`,`resourceName`],r),t}function E(e){let t={},n=x(e,[`name`]);n!=null&&b(t,[`name`],n);let r=x(e,[`metadata`]);r!=null&&b(t,[`metadata`],r);let i=x(e,[`done`]);i!=null&&b(t,[`done`],i);let a=x(e,[`error`]);a!=null&&b(t,[`error`],a);let o=x(e,[`response`,`generateVideoResponse`]);return o!=null&&b(t,[`response`],O(o)),t}function D(e){let t={},n=x(e,[`name`]);n!=null&&b(t,[`name`],n);let r=x(e,[`metadata`]);r!=null&&b(t,[`metadata`],r);let i=x(e,[`done`]);i!=null&&b(t,[`done`],i);let a=x(e,[`error`]);a!=null&&b(t,[`error`],a);let o=x(e,[`response`]);return o!=null&&b(t,[`response`],k(o)),t}function O(e){let t={},n=x(e,[`generatedSamples`]);if(n!=null){let e=n;Array.isArray(e)&&(e=e.map(e=>A(e))),b(t,[`generatedVideos`],e)}let r=x(e,[`raiMediaFilteredCount`]);r!=null&&b(t,[`raiMediaFilteredCount`],r);let i=x(e,[`raiMediaFilteredReasons`]);return i!=null&&b(t,[`raiMediaFilteredReasons`],i),t}function k(e){let t={},n=x(e,[`videos`]);if(n!=null){let e=n;Array.isArray(e)&&(e=e.map(e=>ee(e))),b(t,[`generatedVideos`],e)}let r=x(e,[`raiMediaFilteredCount`]);r!=null&&b(t,[`raiMediaFilteredCount`],r);let i=x(e,[`raiMediaFilteredReasons`]);return i!=null&&b(t,[`raiMediaFilteredReasons`],i),t}function A(e){let t={},n=x(e,[`video`]);return n!=null&&b(t,[`video`],se(n)),t}function ee(e){let t={},n=x(e,[`_self`]);return n!=null&&b(t,[`video`],ce(n)),t}function te(e){let t={},n=x(e,[`operationName`]);return n!=null&&b(t,[`_url`,`operationName`],n),t}function ne(e){let t={},n=x(e,[`operationName`]);return n!=null&&b(t,[`_url`,`operationName`],n),t}function re(e){let t={},n=x(e,[`name`]);n!=null&&b(t,[`name`],n);let r=x(e,[`metadata`]);r!=null&&b(t,[`metadata`],r);let i=x(e,[`done`]);i!=null&&b(t,[`done`],i);let a=x(e,[`error`]);a!=null&&b(t,[`error`],a);let o=x(e,[`response`]);return o!=null&&b(t,[`response`],ie(o)),t}function ie(e){let t={},n=x(e,[`sdkHttpResponse`]);n!=null&&b(t,[`sdkHttpResponse`],n);let r=x(e,[`parent`]);r!=null&&b(t,[`parent`],r);let i=x(e,[`documentName`]);return i!=null&&b(t,[`documentName`],i),t}function ae(e){let t={},n=x(e,[`name`]);n!=null&&b(t,[`name`],n);let r=x(e,[`metadata`]);r!=null&&b(t,[`metadata`],r);let i=x(e,[`done`]);i!=null&&b(t,[`done`],i);let a=x(e,[`error`]);a!=null&&b(t,[`error`],a);let o=x(e,[`response`]);return o!=null&&b(t,[`response`],oe(o)),t}function oe(e){let t={},n=x(e,[`sdkHttpResponse`]);n!=null&&b(t,[`sdkHttpResponse`],n);let r=x(e,[`parent`]);r!=null&&b(t,[`parent`],r);let i=x(e,[`documentName`]);return i!=null&&b(t,[`documentName`],i),t}function se(e){let t={},n=x(e,[`uri`]);n!=null&&b(t,[`uri`],n);let r=x(e,[`encodedVideo`]);r!=null&&b(t,[`videoBytes`],w(r));let i=x(e,[`encoding`]);return i!=null&&b(t,[`mimeType`],i),t}function ce(e){let t={},n=x(e,[`gcsUri`]);n!=null&&b(t,[`uri`],n);let r=x(e,[`bytesBase64Encoded`]);r!=null&&b(t,[`videoBytes`],w(r));let i=x(e,[`mimeType`]);return i!=null&&b(t,[`mimeType`],i),t}var le;(function(e){e.OUTCOME_UNSPECIFIED=`OUTCOME_UNSPECIFIED`,e.OUTCOME_OK=`OUTCOME_OK`,e.OUTCOME_FAILED=`OUTCOME_FAILED`,e.OUTCOME_DEADLINE_EXCEEDED=`OUTCOME_DEADLINE_EXCEEDED`})(le||={});var ue;(function(e){e.LANGUAGE_UNSPECIFIED=`LANGUAGE_UNSPECIFIED`,e.PYTHON=`PYTHON`})(ue||={});var de;(function(e){e.SCHEDULING_UNSPECIFIED=`SCHEDULING_UNSPECIFIED`,e.SILENT=`SILENT`,e.WHEN_IDLE=`WHEN_IDLE`,e.INTERRUPT=`INTERRUPT`})(de||={});var fe;(function(e){e.TYPE_UNSPECIFIED=`TYPE_UNSPECIFIED`,e.STRING=`STRING`,e.NUMBER=`NUMBER`,e.INTEGER=`INTEGER`,e.BOOLEAN=`BOOLEAN`,e.ARRAY=`ARRAY`,e.OBJECT=`OBJECT`,e.NULL=`NULL`})(fe||={});var pe;(function(e){e.AUTH_TYPE_UNSPECIFIED=`AUTH_TYPE_UNSPECIFIED`,e.NO_AUTH=`NO_AUTH`,e.API_KEY_AUTH=`API_KEY_AUTH`,e.HTTP_BASIC_AUTH=`HTTP_BASIC_AUTH`,e.GOOGLE_SERVICE_ACCOUNT_AUTH=`GOOGLE_SERVICE_ACCOUNT_AUTH`,e.OAUTH=`OAUTH`,e.OIDC_AUTH=`OIDC_AUTH`})(pe||={});var me;(function(e){e.HTTP_IN_UNSPECIFIED=`HTTP_IN_UNSPECIFIED`,e.HTTP_IN_QUERY=`HTTP_IN_QUERY`,e.HTTP_IN_HEADER=`HTTP_IN_HEADER`,e.HTTP_IN_PATH=`HTTP_IN_PATH`,e.HTTP_IN_BODY=`HTTP_IN_BODY`,e.HTTP_IN_COOKIE=`HTTP_IN_COOKIE`})(me||={});var he;(function(e){e.API_SPEC_UNSPECIFIED=`API_SPEC_UNSPECIFIED`,e.SIMPLE_SEARCH=`SIMPLE_SEARCH`,e.ELASTIC_SEARCH=`ELASTIC_SEARCH`})(he||={});var ge;(function(e){e.ENVIRONMENT_UNSPECIFIED=`ENVIRONMENT_UNSPECIFIED`,e.ENVIRONMENT_BROWSER=`ENVIRONMENT_BROWSER`,e.ENVIRONMENT_MOBILE=`ENVIRONMENT_MOBILE`,e.ENVIRONMENT_DESKTOP=`ENVIRONMENT_DESKTOP`})(ge||={});var _e;(function(e){e.SAFETY_POLICY_UNSPECIFIED=`SAFETY_POLICY_UNSPECIFIED`,e.FINANCIAL_TRANSACTIONS=`FINANCIAL_TRANSACTIONS`,e.SENSITIVE_DATA_MODIFICATION=`SENSITIVE_DATA_MODIFICATION`,e.COMMUNICATION_TOOL=`COMMUNICATION_TOOL`,e.ACCOUNT_CREATION=`ACCOUNT_CREATION`,e.DATA_MODIFICATION=`DATA_MODIFICATION`,e.USER_CONSENT_MANAGEMENT=`USER_CONSENT_MANAGEMENT`,e.LEGAL_TERMS_AND_AGREEMENTS=`LEGAL_TERMS_AND_AGREEMENTS`})(_e||={});var ve;(function(e){e.PHISH_BLOCK_THRESHOLD_UNSPECIFIED=`PHISH_BLOCK_THRESHOLD_UNSPECIFIED`,e.BLOCK_LOW_AND_ABOVE=`BLOCK_LOW_AND_ABOVE`,e.BLOCK_MEDIUM_AND_ABOVE=`BLOCK_MEDIUM_AND_ABOVE`,e.BLOCK_HIGH_AND_ABOVE=`BLOCK_HIGH_AND_ABOVE`,e.BLOCK_HIGHER_AND_ABOVE=`BLOCK_HIGHER_AND_ABOVE`,e.BLOCK_VERY_HIGH_AND_ABOVE=`BLOCK_VERY_HIGH_AND_ABOVE`,e.BLOCK_ONLY_EXTREMELY_HIGH=`BLOCK_ONLY_EXTREMELY_HIGH`})(ve||={});var ye;(function(e){e.UNSPECIFIED=`UNSPECIFIED`,e.BLOCKING=`BLOCKING`,e.NON_BLOCKING=`NON_BLOCKING`})(ye||={});var be;(function(e){e.MODE_UNSPECIFIED=`MODE_UNSPECIFIED`,e.MODE_DYNAMIC=`MODE_DYNAMIC`})(be||={});var xe;(function(e){e.THINKING_LEVEL_UNSPECIFIED=`THINKING_LEVEL_UNSPECIFIED`,e.MINIMAL=`MINIMAL`,e.LOW=`LOW`,e.MEDIUM=`MEDIUM`,e.HIGH=`HIGH`})(xe||={});var Se;(function(e){e.DONT_ALLOW=`DONT_ALLOW`,e.ALLOW_ADULT=`ALLOW_ADULT`,e.ALLOW_ALL=`ALLOW_ALL`})(Se||={});var Ce;(function(e){e.PROMINENT_PEOPLE_UNSPECIFIED=`PROMINENT_PEOPLE_UNSPECIFIED`,e.ALLOW_PROMINENT_PEOPLE=`ALLOW_PROMINENT_PEOPLE`,e.BLOCK_PROMINENT_PEOPLE=`BLOCK_PROMINENT_PEOPLE`})(Ce||={});var we;(function(e){e.HARM_CATEGORY_UNSPECIFIED=`HARM_CATEGORY_UNSPECIFIED`,e.HARM_CATEGORY_HARASSMENT=`HARM_CATEGORY_HARASSMENT`,e.HARM_CATEGORY_HATE_SPEECH=`HARM_CATEGORY_HATE_SPEECH`,e.HARM_CATEGORY_SEXUALLY_EXPLICIT=`HARM_CATEGORY_SEXUALLY_EXPLICIT`,e.HARM_CATEGORY_DANGEROUS_CONTENT=`HARM_CATEGORY_DANGEROUS_CONTENT`,e.HARM_CATEGORY_CIVIC_INTEGRITY=`HARM_CATEGORY_CIVIC_INTEGRITY`,e.HARM_CATEGORY_JAILBREAK=`HARM_CATEGORY_JAILBREAK`,e.HARM_CATEGORY_IMAGE_HATE=`HARM_CATEGORY_IMAGE_HATE`,e.HARM_CATEGORY_IMAGE_DANGEROUS_CONTENT=`HARM_CATEGORY_IMAGE_DANGEROUS_CONTENT`,e.HARM_CATEGORY_IMAGE_HARASSMENT=`HARM_CATEGORY_IMAGE_HARASSMENT`,e.HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT=`HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT`})(we||={});var Te;(function(e){e.HARM_BLOCK_METHOD_UNSPECIFIED=`HARM_BLOCK_METHOD_UNSPECIFIED`,e.SEVERITY=`SEVERITY`,e.PROBABILITY=`PROBABILITY`})(Te||={});var Ee;(function(e){e.HARM_BLOCK_THRESHOLD_UNSPECIFIED=`HARM_BLOCK_THRESHOLD_UNSPECIFIED`,e.BLOCK_LOW_AND_ABOVE=`BLOCK_LOW_AND_ABOVE`,e.BLOCK_MEDIUM_AND_ABOVE=`BLOCK_MEDIUM_AND_ABOVE`,e.BLOCK_ONLY_HIGH=`BLOCK_ONLY_HIGH`,e.BLOCK_NONE=`BLOCK_NONE`,e.OFF=`OFF`})(Ee||={});var De;(function(e){e.MODE_UNSPECIFIED=`MODE_UNSPECIFIED`,e.AUTO=`AUTO`,e.ANY=`ANY`,e.NONE=`NONE`,e.VALIDATED=`VALIDATED`})(De||={});var j;(function(e){e.FINISH_REASON_UNSPECIFIED=`FINISH_REASON_UNSPECIFIED`,e.STOP=`STOP`,e.MAX_TOKENS=`MAX_TOKENS`,e.SAFETY=`SAFETY`,e.RECITATION=`RECITATION`,e.LANGUAGE=`LANGUAGE`,e.OTHER=`OTHER`,e.BLOCKLIST=`BLOCKLIST`,e.PROHIBITED_CONTENT=`PROHIBITED_CONTENT`,e.SPII=`SPII`,e.MALFORMED_FUNCTION_CALL=`MALFORMED_FUNCTION_CALL`,e.IMAGE_SAFETY=`IMAGE_SAFETY`,e.UNEXPECTED_TOOL_CALL=`UNEXPECTED_TOOL_CALL`,e.TOO_MANY_TOOL_CALLS=`TOO_MANY_TOOL_CALLS`,e.IMAGE_PROHIBITED_CONTENT=`IMAGE_PROHIBITED_CONTENT`,e.NO_IMAGE=`NO_IMAGE`,e.IMAGE_RECITATION=`IMAGE_RECITATION`,e.IMAGE_OTHER=`IMAGE_OTHER`})(j||={});var Oe;(function(e){e.HARM_PROBABILITY_UNSPECIFIED=`HARM_PROBABILITY_UNSPECIFIED`,e.NEGLIGIBLE=`NEGLIGIBLE`,e.LOW=`LOW`,e.MEDIUM=`MEDIUM`,e.HIGH=`HIGH`})(Oe||={});var ke;(function(e){e.HARM_SEVERITY_UNSPECIFIED=`HARM_SEVERITY_UNSPECIFIED`,e.HARM_SEVERITY_NEGLIGIBLE=`HARM_SEVERITY_NEGLIGIBLE`,e.HARM_SEVERITY_LOW=`HARM_SEVERITY_LOW`,e.HARM_SEVERITY_MEDIUM=`HARM_SEVERITY_MEDIUM`,e.HARM_SEVERITY_HIGH=`HARM_SEVERITY_HIGH`})(ke||={});var Ae;(function(e){e.URL_RETRIEVAL_STATUS_UNSPECIFIED=`URL_RETRIEVAL_STATUS_UNSPECIFIED`,e.URL_RETRIEVAL_STATUS_SUCCESS=`URL_RETRIEVAL_STATUS_SUCCESS`,e.URL_RETRIEVAL_STATUS_ERROR=`URL_RETRIEVAL_STATUS_ERROR`,e.URL_RETRIEVAL_STATUS_PAYWALL=`URL_RETRIEVAL_STATUS_PAYWALL`,e.URL_RETRIEVAL_STATUS_UNSAFE=`URL_RETRIEVAL_STATUS_UNSAFE`})(Ae||={});var je;(function(e){e.BLOCKED_REASON_UNSPECIFIED=`BLOCKED_REASON_UNSPECIFIED`,e.SAFETY=`SAFETY`,e.OTHER=`OTHER`,e.BLOCKLIST=`BLOCKLIST`,e.PROHIBITED_CONTENT=`PROHIBITED_CONTENT`,e.IMAGE_SAFETY=`IMAGE_SAFETY`,e.MODEL_ARMOR=`MODEL_ARMOR`,e.JAILBREAK=`JAILBREAK`})(je||={});var Me;(function(e){e.TRAFFIC_TYPE_UNSPECIFIED=`TRAFFIC_TYPE_UNSPECIFIED`,e.ON_DEMAND=`ON_DEMAND`,e.ON_DEMAND_PRIORITY=`ON_DEMAND_PRIORITY`,e.ON_DEMAND_FLEX=`ON_DEMAND_FLEX`,e.PROVISIONED_THROUGHPUT=`PROVISIONED_THROUGHPUT`})(Me||={});var Ne;(function(e){e.MODALITY_UNSPECIFIED=`MODALITY_UNSPECIFIED`,e.TEXT=`TEXT`,e.IMAGE=`IMAGE`,e.VIDEO=`VIDEO`,e.AUDIO=`AUDIO`,e.DOCUMENT=`DOCUMENT`})(Ne||={});var Pe;(function(e){e.MODEL_STAGE_UNSPECIFIED=`MODEL_STAGE_UNSPECIFIED`,e.UNSTABLE_EXPERIMENTAL=`UNSTABLE_EXPERIMENTAL`,e.EXPERIMENTAL=`EXPERIMENTAL`,e.PREVIEW=`PREVIEW`,e.STABLE=`STABLE`,e.LEGACY=`LEGACY`,e.DEPRECATED=`DEPRECATED`,e.RETIRED=`RETIRED`})(Pe||={});var Fe;(function(e){e.MEDIA_RESOLUTION_UNSPECIFIED=`MEDIA_RESOLUTION_UNSPECIFIED`,e.MEDIA_RESOLUTION_LOW=`MEDIA_RESOLUTION_LOW`,e.MEDIA_RESOLUTION_MEDIUM=`MEDIA_RESOLUTION_MEDIUM`,e.MEDIA_RESOLUTION_HIGH=`MEDIA_RESOLUTION_HIGH`})(Fe||={});var Ie;(function(e){e.MODALITY_UNSPECIFIED=`MODALITY_UNSPECIFIED`,e.TEXT=`TEXT`,e.IMAGE=`IMAGE`,e.AUDIO=`AUDIO`,e.VIDEO=`VIDEO`})(Ie||={});var Le;(function(e){e.DELIVERY_UNSPECIFIED=`DELIVERY_UNSPECIFIED`,e.INLINE=`INLINE`,e.URI=`URI`})(Le||={});var Re;(function(e){e.ASPECT_RATIO_UNSPECIFIED=`ASPECT_RATIO_UNSPECIFIED`,e.ASPECT_RATIO_ONE_BY_ONE=`ASPECT_RATIO_ONE_BY_ONE`,e.ASPECT_RATIO_TWO_BY_THREE=`ASPECT_RATIO_TWO_BY_THREE`,e.ASPECT_RATIO_THREE_BY_TWO=`ASPECT_RATIO_THREE_BY_TWO`,e.ASPECT_RATIO_THREE_BY_FOUR=`ASPECT_RATIO_THREE_BY_FOUR`,e.ASPECT_RATIO_FOUR_BY_THREE=`ASPECT_RATIO_FOUR_BY_THREE`,e.ASPECT_RATIO_FOUR_BY_FIVE=`ASPECT_RATIO_FOUR_BY_FIVE`,e.ASPECT_RATIO_FIVE_BY_FOUR=`ASPECT_RATIO_FIVE_BY_FOUR`,e.ASPECT_RATIO_NINE_BY_SIXTEEN=`ASPECT_RATIO_NINE_BY_SIXTEEN`,e.ASPECT_RATIO_SIXTEEN_BY_NINE=`ASPECT_RATIO_SIXTEEN_BY_NINE`,e.ASPECT_RATIO_TWENTY_ONE_BY_NINE=`ASPECT_RATIO_TWENTY_ONE_BY_NINE`,e.ASPECT_RATIO_ONE_BY_EIGHT=`ASPECT_RATIO_ONE_BY_EIGHT`,e.ASPECT_RATIO_EIGHT_BY_ONE=`ASPECT_RATIO_EIGHT_BY_ONE`,e.ASPECT_RATIO_ONE_BY_FOUR=`ASPECT_RATIO_ONE_BY_FOUR`,e.ASPECT_RATIO_FOUR_BY_ONE=`ASPECT_RATIO_FOUR_BY_ONE`})(Re||={});var ze;(function(e){e.IMAGE_SIZE_UNSPECIFIED=`IMAGE_SIZE_UNSPECIFIED`,e.IMAGE_SIZE_FIVE_TWELVE=`IMAGE_SIZE_FIVE_TWELVE`,e.IMAGE_SIZE_ONE_K=`IMAGE_SIZE_ONE_K`,e.IMAGE_SIZE_TWO_K=`IMAGE_SIZE_TWO_K`,e.IMAGE_SIZE_FOUR_K=`IMAGE_SIZE_FOUR_K`})(ze||={});var Be;(function(e){e.TUNING_MODE_UNSPECIFIED=`TUNING_MODE_UNSPECIFIED`,e.TUNING_MODE_FULL=`TUNING_MODE_FULL`,e.TUNING_MODE_PEFT_ADAPTER=`TUNING_MODE_PEFT_ADAPTER`})(Be||={});var Ve;(function(e){e.ADAPTER_SIZE_UNSPECIFIED=`ADAPTER_SIZE_UNSPECIFIED`,e.ADAPTER_SIZE_ONE=`ADAPTER_SIZE_ONE`,e.ADAPTER_SIZE_TWO=`ADAPTER_SIZE_TWO`,e.ADAPTER_SIZE_FOUR=`ADAPTER_SIZE_FOUR`,e.ADAPTER_SIZE_EIGHT=`ADAPTER_SIZE_EIGHT`,e.ADAPTER_SIZE_SIXTEEN=`ADAPTER_SIZE_SIXTEEN`,e.ADAPTER_SIZE_THIRTY_TWO=`ADAPTER_SIZE_THIRTY_TWO`})(Ve||={});var He;(function(e){e.RESPONSE_PARSE_TYPE_UNSPECIFIED=`RESPONSE_PARSE_TYPE_UNSPECIFIED`,e.IDENTITY=`IDENTITY`,e.REGEX_EXTRACT=`REGEX_EXTRACT`})(He||={});var Ue;(function(e){e.MATCH_OPERATION_UNSPECIFIED=`MATCH_OPERATION_UNSPECIFIED`,e.REGEX_CONTAINS=`REGEX_CONTAINS`,e.PARTIAL_MATCH=`PARTIAL_MATCH`,e.EXACT_MATCH=`EXACT_MATCH`})(Ue||={});var We;(function(e){e.REINFORCEMENT_TUNING_THINKING_LEVEL_UNSPECIFIED=`REINFORCEMENT_TUNING_THINKING_LEVEL_UNSPECIFIED`,e.MINIMAL=`MINIMAL`,e.HIGH=`HIGH`})(We||={});var Ge;(function(e){e.JOB_STATE_UNSPECIFIED=`JOB_STATE_UNSPECIFIED`,e.JOB_STATE_QUEUED=`JOB_STATE_QUEUED`,e.JOB_STATE_PENDING=`JOB_STATE_PENDING`,e.JOB_STATE_RUNNING=`JOB_STATE_RUNNING`,e.JOB_STATE_SUCCEEDED=`JOB_STATE_SUCCEEDED`,e.JOB_STATE_FAILED=`JOB_STATE_FAILED`,e.JOB_STATE_CANCELLING=`JOB_STATE_CANCELLING`,e.JOB_STATE_CANCELLED=`JOB_STATE_CANCELLED`,e.JOB_STATE_PAUSED=`JOB_STATE_PAUSED`,e.JOB_STATE_EXPIRED=`JOB_STATE_EXPIRED`,e.JOB_STATE_UPDATING=`JOB_STATE_UPDATING`,e.JOB_STATE_PARTIALLY_SUCCEEDED=`JOB_STATE_PARTIALLY_SUCCEEDED`})(Ge||={});var Ke;(function(e){e.TUNING_JOB_STATE_UNSPECIFIED=`TUNING_JOB_STATE_UNSPECIFIED`,e.TUNING_JOB_STATE_WAITING_FOR_QUOTA=`TUNING_JOB_STATE_WAITING_FOR_QUOTA`,e.TUNING_JOB_STATE_PROCESSING_DATASET=`TUNING_JOB_STATE_PROCESSING_DATASET`,e.TUNING_JOB_STATE_WAITING_FOR_CAPACITY=`TUNING_JOB_STATE_WAITING_FOR_CAPACITY`,e.TUNING_JOB_STATE_TUNING=`TUNING_JOB_STATE_TUNING`,e.TUNING_JOB_STATE_POST_PROCESSING=`TUNING_JOB_STATE_POST_PROCESSING`})(Ke||={});var qe;(function(e){e.AGGREGATION_METRIC_UNSPECIFIED=`AGGREGATION_METRIC_UNSPECIFIED`,e.AVERAGE=`AVERAGE`,e.MODE=`MODE`,e.STANDARD_DEVIATION=`STANDARD_DEVIATION`,e.VARIANCE=`VARIANCE`,e.MINIMUM=`MINIMUM`,e.MAXIMUM=`MAXIMUM`,e.MEDIAN=`MEDIAN`,e.PERCENTILE_P90=`PERCENTILE_P90`,e.PERCENTILE_P95=`PERCENTILE_P95`,e.PERCENTILE_P99=`PERCENTILE_P99`})(qe||={});var Je;(function(e){e.PAIRWISE_CHOICE_UNSPECIFIED=`PAIRWISE_CHOICE_UNSPECIFIED`,e.BASELINE=`BASELINE`,e.CANDIDATE=`CANDIDATE`,e.TIE=`TIE`})(Je||={});var Ye;(function(e){e.VIDEO_ORIENTATION_UNSPECIFIED=`VIDEO_ORIENTATION_UNSPECIFIED`,e.LANDSCAPE=`LANDSCAPE`,e.PORTRAIT=`PORTRAIT`})(Ye||={});var Xe;(function(e){e.TUNING_SPEED_UNSPECIFIED=`TUNING_SPEED_UNSPECIFIED`,e.REGULAR=`REGULAR`,e.FAST=`FAST`})(Xe||={});var Ze;(function(e){e.TUNING_TASK_UNSPECIFIED=`TUNING_TASK_UNSPECIFIED`,e.TUNING_TASK_I2V=`TUNING_TASK_I2V`,e.TUNING_TASK_T2V=`TUNING_TASK_T2V`,e.TUNING_TASK_R2V=`TUNING_TASK_R2V`})(Ze||={});var Qe;(function(e){e.STATE_UNSPECIFIED=`STATE_UNSPECIFIED`,e.STATE_PENDING=`STATE_PENDING`,e.STATE_ACTIVE=`STATE_ACTIVE`,e.STATE_FAILED=`STATE_FAILED`})(Qe||={});var $e;(function(e){e.UNSPECIFIED=`unspecified`,e.FLEX=`flex`,e.STANDARD=`standard`,e.PRIORITY=`priority`})($e||={});var et;(function(e){e.MEDIA_PROCESSING_UNSPECIFIED=`MEDIA_PROCESSING_UNSPECIFIED`,e.STATIC=`STATIC`,e.AGENTIC=`AGENTIC`})(et||={});var tt;(function(e){e.MEDIA_RESOLUTION_UNSPECIFIED=`MEDIA_RESOLUTION_UNSPECIFIED`,e.MEDIA_RESOLUTION_LOW=`MEDIA_RESOLUTION_LOW`,e.MEDIA_RESOLUTION_MEDIUM=`MEDIA_RESOLUTION_MEDIUM`,e.MEDIA_RESOLUTION_HIGH=`MEDIA_RESOLUTION_HIGH`,e.MEDIA_RESOLUTION_ULTRA_HIGH=`MEDIA_RESOLUTION_ULTRA_HIGH`})(tt||={});var nt;(function(e){e.TOOL_TYPE_UNSPECIFIED=`TOOL_TYPE_UNSPECIFIED`,e.GOOGLE_SEARCH_WEB=`GOOGLE_SEARCH_WEB`,e.GOOGLE_SEARCH_IMAGE=`GOOGLE_SEARCH_IMAGE`,e.URL_CONTEXT=`URL_CONTEXT`,e.GOOGLE_MAPS=`GOOGLE_MAPS`,e.FILE_SEARCH=`FILE_SEARCH`,e.MEDIA_PROCESSING=`MEDIA_PROCESSING`})(nt||={});var rt;(function(e){e.COLLECTION=`COLLECTION`})(rt||={});var it;(function(e){e.FEATURE_SELECTION_PREFERENCE_UNSPECIFIED=`FEATURE_SELECTION_PREFERENCE_UNSPECIFIED`,e.PRIORITIZE_QUALITY=`PRIORITIZE_QUALITY`,e.BALANCED=`BALANCED`,e.PRIORITIZE_COST=`PRIORITIZE_COST`})(it||={});var at;(function(e){e.PREDICT=`PREDICT`,e.EMBED_CONTENT=`EMBED_CONTENT`})(at||={});var ot;(function(e){e.BLOCK_LOW_AND_ABOVE=`BLOCK_LOW_AND_ABOVE`,e.BLOCK_MEDIUM_AND_ABOVE=`BLOCK_MEDIUM_AND_ABOVE`,e.BLOCK_ONLY_HIGH=`BLOCK_ONLY_HIGH`,e.BLOCK_NONE=`BLOCK_NONE`})(ot||={});var st;(function(e){e.auto=`auto`,e.en=`en`,e.ja=`ja`,e.ko=`ko`,e.hi=`hi`,e.zh=`zh`,e.pt=`pt`,e.es=`es`})(st||={});var ct;(function(e){e.MASK_MODE_DEFAULT=`MASK_MODE_DEFAULT`,e.MASK_MODE_USER_PROVIDED=`MASK_MODE_USER_PROVIDED`,e.MASK_MODE_BACKGROUND=`MASK_MODE_BACKGROUND`,e.MASK_MODE_FOREGROUND=`MASK_MODE_FOREGROUND`,e.MASK_MODE_SEMANTIC=`MASK_MODE_SEMANTIC`})(ct||={});var lt;(function(e){e.CONTROL_TYPE_DEFAULT=`CONTROL_TYPE_DEFAULT`,e.CONTROL_TYPE_CANNY=`CONTROL_TYPE_CANNY`,e.CONTROL_TYPE_SCRIBBLE=`CONTROL_TYPE_SCRIBBLE`,e.CONTROL_TYPE_FACE_MESH=`CONTROL_TYPE_FACE_MESH`})(lt||={});var ut;(function(e){e.SUBJECT_TYPE_DEFAULT=`SUBJECT_TYPE_DEFAULT`,e.SUBJECT_TYPE_PERSON=`SUBJECT_TYPE_PERSON`,e.SUBJECT_TYPE_ANIMAL=`SUBJECT_TYPE_ANIMAL`,e.SUBJECT_TYPE_PRODUCT=`SUBJECT_TYPE_PRODUCT`})(ut||={});var dt;(function(e){e.EDIT_MODE_DEFAULT=`EDIT_MODE_DEFAULT`,e.EDIT_MODE_INPAINT_REMOVAL=`EDIT_MODE_INPAINT_REMOVAL`,e.EDIT_MODE_INPAINT_INSERTION=`EDIT_MODE_INPAINT_INSERTION`,e.EDIT_MODE_OUTPAINT=`EDIT_MODE_OUTPAINT`,e.EDIT_MODE_CONTROLLED_EDITING=`EDIT_MODE_CONTROLLED_EDITING`,e.EDIT_MODE_STYLE=`EDIT_MODE_STYLE`,e.EDIT_MODE_BGSWAP=`EDIT_MODE_BGSWAP`,e.EDIT_MODE_PRODUCT_IMAGE=`EDIT_MODE_PRODUCT_IMAGE`})(dt||={});var ft;(function(e){e.FOREGROUND=`FOREGROUND`,e.BACKGROUND=`BACKGROUND`,e.PROMPT=`PROMPT`,e.SEMANTIC=`SEMANTIC`,e.INTERACTIVE=`INTERACTIVE`})(ft||={});var pt;(function(e){e.ASSET=`ASSET`,e.STYLE=`STYLE`})(pt||={});var mt;(function(e){e.INSERT=`INSERT`,e.REMOVE=`REMOVE`,e.REMOVE_STATIC=`REMOVE_STATIC`,e.OUTPAINT=`OUTPAINT`})(mt||={});var ht;(function(e){e.OPTIMIZED=`OPTIMIZED`,e.LOSSLESS=`LOSSLESS`})(ht||={});var gt;(function(e){e.CROP=`CROP`,e.PAD=`PAD`})(gt||={});var _t;(function(e){e.SUPERVISED_FINE_TUNING=`SUPERVISED_FINE_TUNING`,e.PREFERENCE_TUNING=`PREFERENCE_TUNING`,e.DISTILLATION=`DISTILLATION`,e.REINFORCEMENT_TUNING=`REINFORCEMENT_TUNING`})(_t||={});var vt;(function(e){e.STATE_UNSPECIFIED=`STATE_UNSPECIFIED`,e.PROCESSING=`PROCESSING`,e.ACTIVE=`ACTIVE`,e.FAILED=`FAILED`})(vt||={});var yt;(function(e){e.SOURCE_UNSPECIFIED=`SOURCE_UNSPECIFIED`,e.UPLOADED=`UPLOADED`,e.GENERATED=`GENERATED`,e.REGISTERED=`REGISTERED`})(yt||={});var bt;(function(e){e.TURN_COMPLETE_REASON_UNSPECIFIED=`TURN_COMPLETE_REASON_UNSPECIFIED`,e.MALFORMED_FUNCTION_CALL=`MALFORMED_FUNCTION_CALL`,e.RESPONSE_REJECTED=`RESPONSE_REJECTED`,e.NEED_MORE_INPUT=`NEED_MORE_INPUT`,e.PROHIBITED_INPUT_CONTENT=`PROHIBITED_INPUT_CONTENT`,e.IMAGE_PROHIBITED_INPUT_CONTENT=`IMAGE_PROHIBITED_INPUT_CONTENT`,e.INPUT_TEXT_CONTAIN_PROMINENT_PERSON_PROHIBITED=`INPUT_TEXT_CONTAIN_PROMINENT_PERSON_PROHIBITED`,e.INPUT_IMAGE_CELEBRITY=`INPUT_IMAGE_CELEBRITY`,e.INPUT_IMAGE_PHOTO_REALISTIC_CHILD_PROHIBITED=`INPUT_IMAGE_PHOTO_REALISTIC_CHILD_PROHIBITED`,e.INPUT_TEXT_NCII_PROHIBITED=`INPUT_TEXT_NCII_PROHIBITED`,e.INPUT_OTHER=`INPUT_OTHER`,e.INPUT_IP_PROHIBITED=`INPUT_IP_PROHIBITED`,e.BLOCKLIST=`BLOCKLIST`,e.UNSAFE_PROMPT_FOR_IMAGE_GENERATION=`UNSAFE_PROMPT_FOR_IMAGE_GENERATION`,e.GENERATED_IMAGE_SAFETY=`GENERATED_IMAGE_SAFETY`,e.GENERATED_CONTENT_SAFETY=`GENERATED_CONTENT_SAFETY`,e.GENERATED_AUDIO_SAFETY=`GENERATED_AUDIO_SAFETY`,e.GENERATED_VIDEO_SAFETY=`GENERATED_VIDEO_SAFETY`,e.GENERATED_CONTENT_PROHIBITED=`GENERATED_CONTENT_PROHIBITED`,e.GENERATED_CONTENT_BLOCKLIST=`GENERATED_CONTENT_BLOCKLIST`,e.GENERATED_IMAGE_PROHIBITED=`GENERATED_IMAGE_PROHIBITED`,e.GENERATED_IMAGE_CELEBRITY=`GENERATED_IMAGE_CELEBRITY`,e.GENERATED_IMAGE_PROMINENT_PEOPLE_DETECTED_BY_REWRITER=`GENERATED_IMAGE_PROMINENT_PEOPLE_DETECTED_BY_REWRITER`,e.GENERATED_IMAGE_IDENTIFIABLE_PEOPLE=`GENERATED_IMAGE_IDENTIFIABLE_PEOPLE`,e.GENERATED_IMAGE_MINORS=`GENERATED_IMAGE_MINORS`,e.OUTPUT_IMAGE_IP_PROHIBITED=`OUTPUT_IMAGE_IP_PROHIBITED`,e.GENERATED_OTHER=`GENERATED_OTHER`,e.MAX_REGENERATION_REACHED=`MAX_REGENERATION_REACHED`})(bt||={});var xt;(function(e){e.INTERACTION_STATUS_UNSPECIFIED=`INTERACTION_STATUS_UNSPECIFIED`,e.IN_PROGRESS=`IN_PROGRESS`,e.REQUIRES_ACTION=`REQUIRES_ACTION`,e.IDLE=`IDLE`})(xt||={});var St;(function(e){e.VAD_SIGNAL_TYPE_UNSPECIFIED=`VAD_SIGNAL_TYPE_UNSPECIFIED`,e.VAD_SIGNAL_TYPE_SOS=`VAD_SIGNAL_TYPE_SOS`,e.VAD_SIGNAL_TYPE_EOS=`VAD_SIGNAL_TYPE_EOS`})(St||={});var Ct;(function(e){e.TYPE_UNSPECIFIED=`TYPE_UNSPECIFIED`,e.ACTIVITY_START=`ACTIVITY_START`,e.ACTIVITY_END=`ACTIVITY_END`})(Ct||={});var wt;(function(e){e.START_SENSITIVITY_UNSPECIFIED=`START_SENSITIVITY_UNSPECIFIED`,e.START_SENSITIVITY_HIGH=`START_SENSITIVITY_HIGH`,e.START_SENSITIVITY_LOW=`START_SENSITIVITY_LOW`})(wt||={});var Tt;(function(e){e.END_SENSITIVITY_UNSPECIFIED=`END_SENSITIVITY_UNSPECIFIED`,e.END_SENSITIVITY_HIGH=`END_SENSITIVITY_HIGH`,e.END_SENSITIVITY_LOW=`END_SENSITIVITY_LOW`})(Tt||={});var Et;(function(e){e.ACTIVITY_HANDLING_UNSPECIFIED=`ACTIVITY_HANDLING_UNSPECIFIED`,e.START_OF_ACTIVITY_INTERRUPTS=`START_OF_ACTIVITY_INTERRUPTS`,e.NO_INTERRUPTION=`NO_INTERRUPTION`})(Et||={});var Dt;(function(e){e.TURN_COVERAGE_UNSPECIFIED=`TURN_COVERAGE_UNSPECIFIED`,e.TURN_INCLUDES_ONLY_ACTIVITY=`TURN_INCLUDES_ONLY_ACTIVITY`,e.TURN_INCLUDES_ALL_INPUT=`TURN_INCLUDES_ALL_INPUT`,e.TURN_INCLUDES_AUDIO_ACTIVITY_AND_ALL_VIDEO=`TURN_INCLUDES_AUDIO_ACTIVITY_AND_ALL_VIDEO`})(Dt||={});var Ot;(function(e){e.MODE_UNSPECIFIED=`MODE_UNSPECIFIED`,e.VERBATIM=`VERBATIM`,e.SMART=`SMART`})(Ot||={});var kt;(function(e){e.SCALE_UNSPECIFIED=`SCALE_UNSPECIFIED`,e.C_MAJOR_A_MINOR=`C_MAJOR_A_MINOR`,e.D_FLAT_MAJOR_B_FLAT_MINOR=`D_FLAT_MAJOR_B_FLAT_MINOR`,e.D_MAJOR_B_MINOR=`D_MAJOR_B_MINOR`,e.E_FLAT_MAJOR_C_MINOR=`E_FLAT_MAJOR_C_MINOR`,e.E_MAJOR_D_FLAT_MINOR=`E_MAJOR_D_FLAT_MINOR`,e.F_MAJOR_D_MINOR=`F_MAJOR_D_MINOR`,e.G_FLAT_MAJOR_E_FLAT_MINOR=`G_FLAT_MAJOR_E_FLAT_MINOR`,e.G_MAJOR_E_MINOR=`G_MAJOR_E_MINOR`,e.A_FLAT_MAJOR_F_MINOR=`A_FLAT_MAJOR_F_MINOR`,e.A_MAJOR_G_FLAT_MINOR=`A_MAJOR_G_FLAT_MINOR`,e.B_FLAT_MAJOR_G_MINOR=`B_FLAT_MAJOR_G_MINOR`,e.B_MAJOR_A_FLAT_MINOR=`B_MAJOR_A_FLAT_MINOR`})(kt||={});var At;(function(e){e.MUSIC_GENERATION_MODE_UNSPECIFIED=`MUSIC_GENERATION_MODE_UNSPECIFIED`,e.QUALITY=`QUALITY`,e.DIVERSITY=`DIVERSITY`,e.VOCALIZATION=`VOCALIZATION`})(At||={});var jt;(function(e){e.PLAYBACK_CONTROL_UNSPECIFIED=`PLAYBACK_CONTROL_UNSPECIFIED`,e.PLAY=`PLAY`,e.PAUSE=`PAUSE`,e.STOP=`STOP`,e.RESET_CONTEXT=`RESET_CONTEXT`})(jt||={});var Mt=class{constructor(e){let t={};for(let n of e.headers.entries())t[n[0]]=n[1];this.headers=t,this.responseInternal=e}json(){return this.responseInternal.json()}},Nt=class{get text(){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 text from the first one.`);let e=``,t=!1,n=[];for(let r of this.candidates?.[0]?.content?.parts??[]){for(let[e,t]of Object.entries(r))e!==`text`&&e!==`thought`&&e!==`thoughtSignature`&&(t!==null||t!==void 0)&&n.push(e);if(typeof r.text==`string`){if(typeof r.thought==`boolean`&&r.thought)continue;t=!0,e+=r.text}}return n.length>0&&console.warn(`there are non-text parts ${n} in the response, returning concatenation of all text parts. Please refer to the non text parts for a full response from model.`),t?e:void 0}get data(){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 data from the first one.`);let e=``,t=[];for(let n of this.candidates?.[0]?.content?.parts??[]){for(let[e,r]of Object.entries(n))e!==`inlineData`&&(r!==null||r!==void 0)&&t.push(e);n.inlineData&&typeof n.inlineData.data==`string`&&(e+=atob(n.inlineData.data))}return t.length>0&&console.warn(`there are non-data parts ${t} in the response, returning concatenation of all data parts. Please refer to the non data parts for a full response from model.`),e.length>0?btoa(e):void 0}get functionCalls(){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 e=(this.candidates?.[0]?.content?.parts)?.filter(e=>e.functionCall).map(e=>e.functionCall).filter(e=>e!==void 0);if(e?.length!==0)return e}get executableCode(){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 executable code from the first one.`);let e=(this.candidates?.[0]?.content?.parts)?.filter(e=>e.executableCode).map(e=>e.executableCode).filter(e=>e!==void 0);if(e?.length!==0)return e?.[0]?.code}get codeExecutionResult(){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 code execution result from the first one.`);let e=(this.candidates?.[0]?.content?.parts)?.filter(e=>e.codeExecutionResult).map(e=>e.codeExecutionResult).filter(e=>e!==void 0);if(e?.length!==0)return e?.[0]?.output}},Pt=class{},Ft=class{},It=class{},Lt=class{},Rt=class{},zt=class{},Bt=class{},Vt=class{},Ht=class{},Ut=class{},Wt=class e{_fromAPIResponse({apiResponse:t,_isVertexAI:n}){let r=new e,i,a=t;return i=n?D(a):E(a),Object.assign(r,i),r}},Gt=class{},Kt=class{},qt=class{},Jt=class{},Yt=class{},Xt=class{},Zt=class{},Qt=class{},$t=class e{_fromAPIResponse({apiResponse:t,_isVertexAI:n}){let r=new e,i=re(t);return Object.assign(r,i),r}},en=class{},tn=class{},nn=class{},rn=class{},an=class{},on=class{get text(){let e=``,t=!1,n=[];for(let r of this.serverContent?.modelTurn?.parts??[]){for(let[e,t]of Object.entries(r))e!==`text`&&e!==`thought`&&t!==null&&n.push(e);if(typeof r.text==`string`){if(typeof r.thought==`boolean`&&r.thought)continue;t=!0,e+=r.text}}return n.length>0&&console.warn(`there are non-text parts ${n} in the response, returning concatenation of all text parts. Please refer to the non text parts for a full response from model.`),t?e:void 0}get data(){let e=``,t=[];for(let n of this.serverContent?.modelTurn?.parts??[]){for(let[e,r]of Object.entries(n))e!==`inlineData`&&r!==null&&t.push(e);n.inlineData&&typeof n.inlineData.data==`string`&&(e+=atob(n.inlineData.data))}return t.length>0&&console.warn(`there are non-data parts ${t} in the response, returning concatenation of all data parts. Please refer to the non data parts for a full response from model.`),e.length>0?btoa(e):void 0}},sn=class{get audioChunk(){if(this.serverContent&&this.serverContent.audioChunks&&this.serverContent.audioChunks.length>0)return this.serverContent.audioChunks[0]}},cn=class e{_fromAPIResponse({apiResponse:t,_isVertexAI:n}){let r=new e,i=ae(t);return Object.assign(r,i),r}};function M(e,t){if(!t||typeof t!=`string`)throw Error(`model is required and must be a string`);if(t.includes(`..`)||t.includes(`?`)||t.includes(`&`))throw Error(`invalid model parameter`);if(e.isVertexAI()){if(t.startsWith(`publishers/`)||t.startsWith(`projects/`)||t.startsWith(`models/`))return t;if(t.indexOf(`/`)>=0){let e=t.split(`/`,2);return`publishers/${e[0]}/models/${e[1]}`}return`publishers/google/models/${t}`}return t.startsWith(`models/`)||t.startsWith(`tunedModels/`)?t:`models/${t}`}function ln(e,t){let n=M(e,t);return n?n.startsWith(`publishers/`)&&e.isVertexAI()?`projects/${e.getProject()}/locations/${e.getLocation()}/${n}`:n.startsWith(`models/`)&&e.isVertexAI()?`projects/${e.getProject()}/locations/${e.getLocation()}/publishers/google/${n}`:n:``}function un(e){return Array.isArray(e)?e.map(e=>dn(e)):[dn(e)]}function dn(e){if(typeof e==`object`&&e)return e;throw Error(`Could not parse input as Blob. Unsupported blob type: ${typeof e}`)}function fn(e){let t=dn(e);if(t.mimeType&&t.mimeType.startsWith(`image/`))return t;throw Error(`Unsupported mime type: ${t.mimeType}`)}function pn(e){let t=dn(e);if(t.mimeType&&t.mimeType.startsWith(`audio/`))return t;throw Error(`Unsupported mime type: ${t.mimeType}`)}function mn(e){if(e==null)throw Error(`PartUnion is required`);if(typeof e==`object`)return e;if(typeof e==`string`)return{text:e};throw Error(`Unsupported part type: ${typeof e}`)}function hn(e){if(e==null||Array.isArray(e)&&e.length===0)throw Error(`PartListUnion is required`);return Array.isArray(e)?e.map(e=>mn(e)):[mn(e)]}function gn(e){return typeof e==`object`&&!!e&&`parts`in e&&Array.isArray(e.parts)}function _n(e){return typeof e==`object`&&!!e&&`functionCall`in e}function vn(e){return typeof e==`object`&&!!e&&`functionResponse`in e}function N(e){if(e==null)throw Error(`ContentUnion is required`);return gn(e)?e:{role:`user`,parts:hn(e)}}function yn(e,t){if(!t)return[];if(e.isVertexAI()&&Array.isArray(t))return t.flatMap(e=>{let t=N(e);return t.parts&&t.parts.length>0&&t.parts[0].text!==void 0?[t.parts[0].text]:[]});if(e.isVertexAI()){let e=N(t);return e.parts&&e.parts.length>0&&e.parts[0].text!==void 0?[e.parts[0].text]:[]}return Array.isArray(t)?t.map(e=>N(e)):[N(t)]}function P(e){if(e==null||Array.isArray(e)&&e.length===0)throw Error(`contents are required`);if(!Array.isArray(e)){if(_n(e)||vn(e))throw Error(`To specify functionCall or functionResponse parts, please wrap them in a Content object, specifying the role for them`);return[N(e)]}let t=[],n=[],r=gn(e[0]);for(let i of e){let e=gn(i);if(e!=r)throw Error(`Mixing Content and Parts is not supported, please group the parts into a the appropriate Content objects and specify the roles for them`);if(e)t.push(i);else if(_n(i)||vn(i))throw Error(`To specify functionCall or functionResponse parts, please wrap them, and any other parts, in Content objects as appropriate, specifying the role for them`);else n.push(i)}return r||t.push({role:`user`,parts:hn(n)}),t}function bn(e,t){e.includes(`null`)&&(t.nullable=!0);let n=e.filter(e=>e!==`null`);if(n.length===1)t.type=Object.values(fe).includes(n[0].toUpperCase())?n[0].toUpperCase():fe.TYPE_UNSPECIFIED;else{t.anyOf=[];for(let e of n)t.anyOf.push({type:Object.values(fe).includes(e.toUpperCase())?e.toUpperCase():fe.TYPE_UNSPECIFIED})}}function xn(e){let t={},n=[`items`],r=[`anyOf`],i=[`properties`];if(e.type&&e.anyOf)throw Error(`type and anyOf cannot be both populated.`);let a=e.anyOf;a!=null&&a.length==2&&(a[0].type===`null`?(t.nullable=!0,e=a[1]):a[1].type===`null`&&(t.nullable=!0,e=a[0])),e.type instanceof Array&&bn(e.type,t);for(let[a,o]of Object.entries(e))if(o!=null){if(a==`type`){if(o===`null`)throw Error(`type: null can not be the only possible type for the field.`);if(o instanceof Array)continue;t.type=Object.values(fe).includes(o.toUpperCase())?o.toUpperCase():fe.TYPE_UNSPECIFIED}else if(n.includes(a))t[a]=xn(o);else if(r.includes(a)){let e=[];for(let n of o){if(n.type==`null`){t.nullable=!0;continue}e.push(xn(n))}t[a]=e}else if(i.includes(a)){let e={};for(let[t,n]of Object.entries(o))e[t]=xn(n);t[a]=e}else{if(a===`additionalProperties`)continue;t[a]=o}}return t}function Sn(e){return xn(e)}function Cn(e){return e}function wn(e){if(typeof e==`object`)return e;if(typeof e==`string`)return{voiceConfig:{prebuiltVoiceConfig:{voiceName:e}}};throw Error(`Unsupported speechConfig type: ${typeof e}`)}function Tn(e){if(`multiSpeakerVoiceConfig`in e)throw Error(`multiSpeakerVoiceConfig is not supported in the live API.`);return e}function En(e){if(e.functionDeclarations)for(let t of e.functionDeclarations)t.parameters&&(Object.keys(t.parameters).includes(`$schema`)?t.parametersJsonSchema||(t.parametersJsonSchema=t.parameters,delete t.parameters):t.parameters=xn(t.parameters)),t.response&&(Object.keys(t.response).includes(`$schema`)?t.responseJsonSchema||(t.responseJsonSchema=t.response,delete t.response):t.response=xn(t.response));return e}function Dn(e){if(e==null)throw Error(`tools is required`);if(!Array.isArray(e))throw Error(`tools is required and must be an array of Tools`);let t=[];for(let n of e)t.push(n);return t}function On(e,t,n,r=1){let i=!t.startsWith(`${n}/`)&&t.split(`/`).length===r;return e.isVertexAI()?t.startsWith(`projects/`)?t:t.startsWith(`locations/`)?`projects/${e.getProject()}/${t}`:t.startsWith(`${n}/`)?`projects/${e.getProject()}/locations/${e.getLocation()}/${t}`:i?`projects/${e.getProject()}/locations/${e.getLocation()}/${n}/${t}`:t:i?`${n}/${t}`:t}function kn(e,t){if(typeof t!=`string`)throw Error(`name must be a string`);return On(e,t,`cachedContents`)}function An(e){switch(e){case`STATE_UNSPECIFIED`:return`JOB_STATE_UNSPECIFIED`;case`CREATING`:return`JOB_STATE_RUNNING`;case`ACTIVE`:return`JOB_STATE_SUCCEEDED`;case`FAILED`:return`JOB_STATE_FAILED`;default:return e}}function jn(e){return w(e)}function Mn(e){return typeof e==`object`&&!!e&&`name`in e}function Nn(e){return typeof e==`object`&&!!e&&`video`in e}function Pn(e){return typeof e==`object`&&!!e&&`uri`in e}function Fn(e){let t;if(Mn(e)&&(t=e.name),!(Pn(e)&&(t=e.uri,t===void 0))&&!(Nn(e)&&(t=e.video?.uri,t===void 0))){if(typeof e==`string`&&(t=e),t===void 0)throw Error(`Could not extract file name from the provided input.`);if(t.startsWith(`https://`)){let e=t.split(`files/`)[1].match(/[a-z0-9]+/);if(e===null)throw Error(`Could not extract file name from URI ${t}`);t=e[0]}else t.startsWith(`files/`)&&(t=t.split(`files/`)[1]);return t}}function In(e,t){let n;return n=e.isVertexAI()?t?`publishers/google/models`:`models`:t?`models`:`tunedModels`,n}function Ln(e){for(let t of[`models`,`tunedModels`,`publisherModels`])if(Rn(e,t))return e[t];return[]}function Rn(e,t){return typeof e==`object`&&!!e&&t in e}function zn(e,t={}){let n=e,r={name:n.name,description:n.description,parametersJsonSchema:n.inputSchema};return n.outputSchema&&(r.responseJsonSchema=n.outputSchema),t.behavior&&(r.behavior=t.behavior),{functionDeclarations:[r]}}function Bn(e,t={}){let n=[],r=new Set;for(let i of e){let e=i.name;if(r.has(e))throw Error(`Duplicate function name ${e} found in MCP tools. Please ensure function names are unique.`);r.add(e);let a=zn(i,t);a.functionDeclarations&&n.push(...a.functionDeclarations)}return{functionDeclarations:n}}function Vn(e,t){let n;if(typeof t==`string`){if(e.isVertexAI()){if(t.startsWith(`gs://`))n={format:`jsonl`,gcsUri:[t]};else if(t.startsWith(`bq://`))n={format:`bigquery`,bigqueryUri:t};else if(/^projects\/[^/]+\/locations\/[^/]+\/datasets\/[^/]+$/.test(t))n={format:`vertex-dataset`,vertexDatasetName:t};else throw Error(`Unsupported string source for Vertex AI: ${t}`)}else if(t.startsWith(`files/`))n={fileName:t};else throw Error(`Unsupported string source for Gemini API: ${t}`)}else if(Array.isArray(t)){if(e.isVertexAI())throw Error(`InlinedRequest[] is not supported in Vertex AI.`);n={inlinedRequests:t}}else n=t;let r=[n.gcsUri,n.bigqueryUri,n.vertexDatasetName].filter(Boolean).length,i=[n.inlinedRequests,n.fileName].filter(Boolean).length;if(e.isVertexAI()){if(i>0||r!==1)throw Error("Exactly one of `gcsUri`, `bigqueryUri`, or `vertexDatasetName` must be set for Vertex AI.")}else if(r>0||i!==1)throw Error("Exactly one of `inlinedRequests`, `fileName`, must be set for Gemini API.");return n}function Hn(e){if(typeof e!=`string`)return e;let t=e;if(t.startsWith(`gs://`))return{format:`jsonl`,gcsUri:t};if(t.startsWith(`bq://`))return{format:`bigquery`,bigqueryUri:t};throw Error(`Unsupported destination: ${t}`)}function Un(e){if(typeof e!=`object`||!e)return{};let t=e,n=t.inlinedResponses;if(typeof n!=`object`||!n)return e;let r=n.inlinedResponses;if(!Array.isArray(r)||r.length===0)return e;let i=!1;for(let e of r){if(typeof e!=`object`||!e)continue;let t=e.response;if(!(typeof t!=`object`||!t)&&t.embedding!==void 0){i=!0;break}}return i&&(t.inlinedEmbedContentResponses=t.inlinedResponses,delete t.inlinedResponses),e}function Wn(e,t){let n=t;if(!e.isVertexAI()){if(/batches\/[^/]+$/.test(n))return n.split(`/`).pop();throw Error(`Invalid batch job name: ${n}.`)}if(/^projects\/[^/]+\/locations\/[^/]+\/batchPredictionJobs\/[^/]+$/.test(n))return n.split(`/`).pop();if(/^\d+$/.test(n))return n;throw Error(`Invalid batch job name: ${n}.`)}function Gn(e){let t=e;return t===`BATCH_STATE_UNSPECIFIED`?`JOB_STATE_UNSPECIFIED`:t===`BATCH_STATE_PENDING`?`JOB_STATE_PENDING`:t===`BATCH_STATE_RUNNING`?`JOB_STATE_RUNNING`:t===`BATCH_STATE_SUCCEEDED`?`JOB_STATE_SUCCEEDED`:t===`BATCH_STATE_FAILED`?`JOB_STATE_FAILED`:t===`BATCH_STATE_CANCELLED`?`JOB_STATE_CANCELLED`:t===`BATCH_STATE_EXPIRED`?`JOB_STATE_EXPIRED`:t}function Kn(e){return e.includes(`gemini`)&&e!==`gemini-embedding-001`||e.includes(`maas`)}function qn(e){let t={},n=x(e,[`apiKey`]);if(n!=null&&b(t,[`apiKey`],n),x(e,[`apiKeyConfig`])!==void 0)throw Error(`apiKeyConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);if(x(e,[`authType`])!==void 0)throw Error(`authType parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);if(x(e,[`googleServiceAccountConfig`])!==void 0)throw Error(`googleServiceAccountConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);if(x(e,[`httpBasicAuthConfig`])!==void 0)throw Error(`httpBasicAuthConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);if(x(e,[`oauthConfig`])!==void 0)throw Error(`oauthConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);if(x(e,[`oidcConfig`])!==void 0)throw Error(`oidcConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);return t}function Jn(e){let t={},n=x(e,[`responsesFile`]);n!=null&&b(t,[`fileName`],n);let r=x(e,[`inlinedResponses`,`inlinedResponses`]);if(r!=null){let e=r;Array.isArray(e)&&(e=e.map(e=>Mr(e))),b(t,[`inlinedResponses`],e)}let i=x(e,[`inlinedEmbedContentResponses`,`inlinedResponses`]);if(i!=null){let e=i;Array.isArray(e)&&(e=e.map(e=>e)),b(t,[`inlinedEmbedContentResponses`],e)}return t}function Yn(e){let t={},n=x(e,[`predictionsFormat`]);n!=null&&b(t,[`format`],n);let r=x(e,[`gcsDestination`,`outputUriPrefix`]);r!=null&&b(t,[`gcsUri`],r);let i=x(e,[`bigqueryDestination`,`outputUri`]);i!=null&&b(t,[`bigqueryUri`],i);let a=x(e,[`vertexMultimodalDatasetDestination`]);return a!=null&&b(t,[`vertexDataset`],Ur(a)),t}function Xn(e){let t={},n=x(e,[`format`]);n!=null&&b(t,[`predictionsFormat`],n);let r=x(e,[`gcsUri`]);r!=null&&b(t,[`gcsDestination`,`outputUriPrefix`],r);let i=x(e,[`bigqueryUri`]);i!=null&&b(t,[`bigqueryDestination`,`outputUri`],i);let a=x(e,[`vertexDataset`]);if(a!=null&&b(t,[`vertexMultimodalDatasetDestination`],Wr(a)),x(e,[`fileName`])!==void 0)throw Error(`fileName parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.`);if(x(e,[`inlinedResponses`])!==void 0)throw Error(`inlinedResponses parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.`);if(x(e,[`inlinedEmbedContentResponses`])!==void 0)throw Error(`inlinedEmbedContentResponses parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.`);return t}function Zn(e){let t={},n=x(e,[`name`]);n!=null&&b(t,[`name`],n);let r=x(e,[`metadata`,`displayName`]);r!=null&&b(t,[`displayName`],r);let i=x(e,[`metadata`,`state`]);i!=null&&b(t,[`state`],Gn(i));let a=x(e,[`metadata`,`createTime`]);a!=null&&b(t,[`createTime`],a);let o=x(e,[`metadata`,`endTime`]);o!=null&&b(t,[`endTime`],o);let s=x(e,[`metadata`,`updateTime`]);s!=null&&b(t,[`updateTime`],s);let c=x(e,[`metadata`,`model`]);c!=null&&b(t,[`model`],c);let l=x(e,[`metadata`,`output`]);return l!=null&&b(t,[`dest`],Jn(Un(l))),t}function Qn(e){let t={},n=x(e,[`name`]);n!=null&&b(t,[`name`],n);let r=x(e,[`displayName`]);r!=null&&b(t,[`displayName`],r);let i=x(e,[`state`]);i!=null&&b(t,[`state`],Gn(i));let a=x(e,[`error`]);a!=null&&b(t,[`error`],a);let o=x(e,[`createTime`]);o!=null&&b(t,[`createTime`],o);let s=x(e,[`startTime`]);s!=null&&b(t,[`startTime`],s);let c=x(e,[`endTime`]);c!=null&&b(t,[`endTime`],c);let l=x(e,[`updateTime`]);l!=null&&b(t,[`updateTime`],l);let u=x(e,[`model`]);u!=null&&b(t,[`model`],u);let d=x(e,[`inputConfig`]);d!=null&&b(t,[`src`],$n(d));let f=x(e,[`outputConfig`]);f!=null&&b(t,[`dest`],Yn(Un(f)));let p=x(e,[`outputInfo`]);p!=null&&b(t,[`outputInfo`],p);let m=x(e,[`completionStats`]);return m!=null&&b(t,[`completionStats`],m),t}function $n(e){let t={},n=x(e,[`instancesFormat`]);n!=null&&b(t,[`format`],n);let r=x(e,[`gcsSource`,`uris`]);r!=null&&b(t,[`gcsUri`],r);let i=x(e,[`bigquerySource`,`inputUri`]);i!=null&&b(t,[`bigqueryUri`],i);let a=x(e,[`vertexMultimodalDatasetSource`,`datasetName`]);return a!=null&&b(t,[`vertexDatasetName`],a),t}function er(e,t){let n={};if(x(t,[`format`])!==void 0)throw Error(`format parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);if(x(t,[`gcsUri`])!==void 0)throw Error(`gcsUri parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);if(x(t,[`bigqueryUri`])!==void 0)throw Error(`bigqueryUri parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);if(x(t,[`vertexDatasetName`])!==void 0)throw Error(`vertexDatasetName parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);let r=x(t,[`fileName`]);r!=null&&b(n,[`fileName`],r);let i=x(t,[`inlinedRequests`]);if(i!=null){let t=i;Array.isArray(t)&&(t=t.map(t=>jr(e,t))),b(n,[`requests`,`requests`],t)}return n}function tr(e){let t={},n=x(e,[`format`]);n!=null&&b(t,[`instancesFormat`],n);let r=x(e,[`gcsUri`]);r!=null&&b(t,[`gcsSource`,`uris`],r);let i=x(e,[`bigqueryUri`]);i!=null&&b(t,[`bigquerySource`,`inputUri`],i);let a=x(e,[`vertexDatasetName`]);if(a!=null&&b(t,[`vertexMultimodalDatasetSource`,`datasetName`],a),x(e,[`fileName`])!==void 0)throw Error(`fileName parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.`);if(x(e,[`inlinedRequests`])!==void 0)throw Error(`inlinedRequests parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.`);return t}function nr(e){let t={},n=x(e,[`data`]);if(n!=null&&b(t,[`data`],n),x(e,[`displayName`])!==void 0)throw Error(`displayName parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);let r=x(e,[`mimeType`]);return r!=null&&b(t,[`mimeType`],r),t}function rr(e,t){let n={},r=x(t,[`name`]);return r!=null&&b(n,[`_url`,`name`],Wn(e,r)),n}function ir(e,t){let n={},r=x(t,[`name`]);return r!=null&&b(n,[`_url`,`name`],Wn(e,r)),n}function ar(e){let t={},n=x(e,[`content`]);n!=null&&b(t,[`content`],n);let r=x(e,[`citationMetadata`]);r!=null&&b(t,[`citationMetadata`],or(r));let i=x(e,[`tokenCount`]);i!=null&&b(t,[`tokenCount`],i);let a=x(e,[`finishReason`]);a!=null&&b(t,[`finishReason`],a);let o=x(e,[`groundingMetadata`]);o!=null&&b(t,[`groundingMetadata`],o);let s=x(e,[`avgLogprobs`]);s!=null&&b(t,[`avgLogprobs`],s);let c=x(e,[`index`]);c!=null&&b(t,[`index`],c);let l=x(e,[`logprobsResult`]);l!=null&&b(t,[`logprobsResult`],l);let u=x(e,[`safetyRatings`]);if(u!=null){let e=u;Array.isArray(e)&&(e=e.map(e=>e)),b(t,[`safetyRatings`],e)}let d=x(e,[`urlContextMetadata`]);return d!=null&&b(t,[`urlContextMetadata`],d),t}function or(e){let t={},n=x(e,[`citationSources`]);if(n!=null){let e=n;Array.isArray(e)&&(e=e.map(e=>e)),b(t,[`citations`],e)}return t}function sr(e){let t={},n=x(e,[`parts`]);if(n!=null){let e=n;Array.isArray(e)&&(e=e.map(e=>zr(e))),b(t,[`parts`],e)}let r=x(e,[`role`]);return r!=null&&b(t,[`role`],r),t}function cr(e,t){let n={},r=x(e,[`displayName`]);if(t!==void 0&&r!=null&&b(t,[`batch`,`displayName`],r),x(e,[`dest`])!==void 0)throw Error(`dest parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);let i=x(e,[`webhookConfig`]);return t!==void 0&&i!=null&&b(t,[`batch`,`webhookConfig`],i),n}function lr(e,t){let n={},r=x(e,[`displayName`]);t!==void 0&&r!=null&&b(t,[`displayName`],r);let i=x(e,[`dest`]);if(t!==void 0&&i!=null&&b(t,[`outputConfig`],Xn(Hn(i))),x(e,[`webhookConfig`])!==void 0)throw Error(`webhookConfig parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.`);return n}function ur(e,t){let n={},r=x(t,[`model`]);r!=null&&b(n,[`_url`,`model`],M(e,r));let i=x(t,[`src`]);i!=null&&b(n,[`batch`,`inputConfig`],er(e,Vn(e,i)));let a=x(t,[`config`]);return a!=null&&cr(a,n),n}function dr(e,t){let n={},r=x(t,[`model`]);r!=null&&b(n,[`model`],M(e,r));let i=x(t,[`src`]);i!=null&&b(n,[`inputConfig`],tr(Vn(e,i)));let a=x(t,[`config`]);return a!=null&&lr(a,n),n}function fr(e,t){let n={},r=x(e,[`displayName`]);return t!==void 0&&r!=null&&b(t,[`batch`,`displayName`],r),n}function pr(e,t){let n={},r=x(t,[`model`]);r!=null&&b(n,[`_url`,`model`],M(e,r));let i=x(t,[`src`]);i!=null&&b(n,[`batch`,`inputConfig`],br(e,i));let a=x(t,[`config`]);return a!=null&&fr(a,n),n}function mr(e,t){let n={},r=x(t,[`name`]);return r!=null&&b(n,[`_url`,`name`],Wn(e,r)),n}function hr(e,t){let n={},r=x(t,[`name`]);return r!=null&&b(n,[`_url`,`name`],Wn(e,r)),n}function gr(e){let t={},n=x(e,[`sdkHttpResponse`]);n!=null&&b(t,[`sdkHttpResponse`],n);let r=x(e,[`name`]);r!=null&&b(t,[`name`],r);let i=x(e,[`done`]);i!=null&&b(t,[`done`],i);let a=x(e,[`error`]);return a!=null&&b(t,[`error`],a),t}function _r(e){let t={},n=x(e,[`sdkHttpResponse`]);n!=null&&b(t,[`sdkHttpResponse`],n);let r=x(e,[`name`]);r!=null&&b(t,[`name`],r);let i=x(e,[`done`]);i!=null&&b(t,[`done`],i);let a=x(e,[`error`]);return a!=null&&b(t,[`error`],a),t}function vr(e,t){let n={},r=x(t,[`contents`]);if(r!=null){let t=yn(e,r);Array.isArray(t)&&(t=t.map(e=>e)),b(n,[`requests[]`,`request`,`content`],t)}let i=x(t,[`config`]);return i!=null&&(b(n,[`_self`],yr(i,n)),S(n,{"requests[].*":`requests[].request.*`})),n}function yr(e,t){let n={},r=x(e,[`taskType`]);t!==void 0&&r!=null&&b(t,[`requests[]`,`taskType`],r);let i=x(e,[`title`]);t!==void 0&&i!=null&&b(t,[`requests[]`,`title`],i);let a=x(e,[`outputDimensionality`]);if(t!==void 0&&a!=null&&b(t,[`requests[]`,`outputDimensionality`],a),x(e,[`mimeType`])!==void 0)throw Error(`mimeType parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);if(x(e,[`autoTruncate`])!==void 0)throw Error(`autoTruncate parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);if(x(e,[`documentOcr`])!==void 0)throw Error(`documentOcr parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);if(x(e,[`audioTrackExtraction`])!==void 0)throw Error(`audioTrackExtraction parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);return n}function br(e,t){let n={},r=x(t,[`fileName`]);r!=null&&b(n,[`file_name`],r);let i=x(t,[`inlinedRequests`]);return i!=null&&b(n,[`requests`],vr(e,i)),n}function xr(e){let t={};if(x(e,[`displayName`])!==void 0)throw Error(`displayName parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);let n=x(e,[`fileUri`]);n!=null&&b(t,[`fileUri`],n);let r=x(e,[`mimeType`]);return r!=null&&b(t,[`mimeType`],r),t}function Sr(e){let t={},n=x(e,[`args`]);n!=null&&b(t,[`args`],n);let r=x(e,[`id`]);r!=null&&b(t,[`id`],r);let i=x(e,[`name`]);if(i!=null&&b(t,[`name`],i),x(e,[`partialArgs`])!==void 0)throw Error(`partialArgs parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);if(x(e,[`willContinue`])!==void 0)throw Error(`willContinue parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);return t}function Cr(e){let t={},n=x(e,[`allowedFunctionNames`]);n!=null&&b(t,[`allowedFunctionNames`],n);let r=x(e,[`mode`]);if(r!=null&&b(t,[`mode`],r),x(e,[`streamFunctionCallArguments`])!==void 0)throw Error(`streamFunctionCallArguments parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);return t}function wr(e,t,n){let r={},i=x(t,[`serviceTier`]);n!==void 0&&i!=null&&b(n,[`serviceTier`],i);let a=x(t,[`systemInstruction`]);n!==void 0&&a!=null&&b(n,[`systemInstruction`],sr(N(a)));let o=x(t,[`temperature`]);o!=null&&b(r,[`temperature`],o);let s=x(t,[`topP`]);s!=null&&b(r,[`topP`],s);let c=x(t,[`topK`]);c!=null&&b(r,[`topK`],c);let l=x(t,[`candidateCount`]);l!=null&&b(r,[`candidateCount`],l);let u=x(t,[`maxOutputTokens`]);u!=null&&b(r,[`maxOutputTokens`],u);let d=x(t,[`stopSequences`]);d!=null&&b(r,[`stopSequences`],d);let f=x(t,[`responseLogprobs`]);f!=null&&b(r,[`responseLogprobs`],f);let p=x(t,[`logprobs`]);p!=null&&b(r,[`logprobs`],p);let m=x(t,[`presencePenalty`]);m!=null&&b(r,[`presencePenalty`],m);let h=x(t,[`frequencyPenalty`]);h!=null&&b(r,[`frequencyPenalty`],h);let g=x(t,[`seed`]);g!=null&&b(r,[`seed`],g);let _=x(t,[`responseMimeType`]);_!=null&&b(r,[`responseMimeType`],_);let v=x(t,[`responseSchema`]);v!=null&&b(r,[`responseSchema`],Sn(v));let y=x(t,[`responseJsonSchema`]);if(y!=null&&b(r,[`responseJsonSchema`],Cn(y)),x(t,[`routingConfig`])!==void 0)throw Error(`routingConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);if(x(t,[`modelSelectionConfig`])!==void 0)throw Error(`modelSelectionConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);let S=x(t,[`safetySettings`]);if(n!==void 0&&S!=null){let e=S;Array.isArray(e)&&(e=e.map(e=>Br(e))),b(n,[`safetySettings`],e)}let C=x(t,[`tools`]);if(n!==void 0&&C!=null){let e=Dn(C);Array.isArray(e)&&(e=e.map(e=>Hr(En(e)))),b(n,[`tools`],e)}let w=x(t,[`toolConfig`]);if(n!==void 0&&w!=null&&b(n,[`toolConfig`],Vr(w)),x(t,[`labels`])!==void 0)throw Error(`labels parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);let T=x(t,[`cachedContent`]);n!==void 0&&T!=null&&b(n,[`cachedContent`],kn(e,T));let E=x(t,[`responseModalities`]);E!=null&&b(r,[`responseModalities`],E);let D=x(t,[`mediaResolution`]);D!=null&&b(r,[`mediaResolution`],D);let O=x(t,[`speechConfig`]);if(O!=null&&b(r,[`speechConfig`],wn(O)),x(t,[`audioTimestamp`])!==void 0)throw Error(`audioTimestamp parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);let k=x(t,[`thinkingConfig`]);k!=null&&b(r,[`thinkingConfig`],k);let A=x(t,[`audioTranscriptionConfig`]);A!=null&&b(r,[`audioTranscriptionConfig`],A);let ee=x(t,[`imageConfig`]);ee!=null&&b(r,[`imageConfig`],Ar(ee));let te=x(t,[`enableEnhancedCivicAnswers`]);if(te!=null&&b(r,[`enableEnhancedCivicAnswers`],te),x(t,[`modelArmorConfig`])!==void 0)throw Error(`modelArmorConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);return r}function Tr(e){let t={},n=x(e,[`sdkHttpResponse`]);n!=null&&b(t,[`sdkHttpResponse`],n);let r=x(e,[`candidates`]);if(r!=null){let e=r;Array.isArray(e)&&(e=e.map(e=>ar(e))),b(t,[`candidates`],e)}let i=x(e,[`modelVersion`]);i!=null&&b(t,[`modelVersion`],i);let a=x(e,[`promptFeedback`]);a!=null&&b(t,[`promptFeedback`],a);let o=x(e,[`responseId`]);o!=null&&b(t,[`responseId`],o);let s=x(e,[`usageMetadata`]);s!=null&&b(t,[`usageMetadata`],s);let c=x(e,[`modelStatus`]);return c!=null&&b(t,[`modelStatus`],c),t}function Er(e,t){let n={},r=x(t,[`name`]);return r!=null&&b(n,[`_url`,`name`],Wn(e,r)),n}function Dr(e,t){let n={},r=x(t,[`name`]);return r!=null&&b(n,[`_url`,`name`],Wn(e,r)),n}function Or(e){let t={},n=x(e,[`authConfig`]);n!=null&&b(t,[`authConfig`],qn(n));let r=x(e,[`enableWidget`]);if(r!=null&&b(t,[`enableWidget`],r),x(e,[`groundingTypes`])!==void 0)throw Error(`groundingTypes parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);return t}function kr(e){let t={};if(x(e,[`blockingConfidence`])!==void 0)throw Error(`blockingConfidence parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);if(x(e,[`excludeDomains`])!==void 0)throw Error(`excludeDomains parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);let n=x(e,[`searchTypes`]);n!=null&&b(t,[`searchTypes`],n);let r=x(e,[`timeRangeFilter`]);return r!=null&&b(t,[`timeRangeFilter`],r),t}function Ar(e){let t={},n=x(e,[`aspectRatio`]);n!=null&&b(t,[`aspectRatio`],n);let r=x(e,[`imageSize`]);if(r!=null&&b(t,[`imageSize`],r),x(e,[`personGeneration`])!==void 0)throw Error(`personGeneration parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);if(x(e,[`outputMimeType`])!==void 0)throw Error(`outputMimeType parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);if(x(e,[`outputCompressionQuality`])!==void 0)throw Error(`outputCompressionQuality parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);if(x(e,[`imageOutputOptions`])!==void 0)throw Error(`imageOutputOptions parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);if(x(e,[`prominentPeople`])!==void 0)throw Error(`prominentPeople parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);return t}function jr(e,t){let n={},r=x(t,[`model`]);r!=null&&b(n,[`request`,`model`],M(e,r));let i=x(t,[`contents`]);if(i!=null){let e=P(i);Array.isArray(e)&&(e=e.map(e=>sr(e))),b(n,[`request`,`contents`],e)}let a=x(t,[`metadata`]);a!=null&&b(n,[`metadata`],a);let o=x(t,[`config`]);return o!=null&&b(n,[`request`,`generationConfig`],wr(e,o,x(n,[`request`],{}))),n}function Mr(e){let t={},n=x(e,[`response`]);n!=null&&b(t,[`response`],Tr(n));let r=x(e,[`metadata`]);r!=null&&b(t,[`metadata`],r);let i=x(e,[`error`]);return i!=null&&b(t,[`error`],i),t}function Nr(e,t){let n={},r=x(e,[`pageSize`]);t!==void 0&&r!=null&&b(t,[`_query`,`pageSize`],r);let i=x(e,[`pageToken`]);if(t!==void 0&&i!=null&&b(t,[`_query`,`pageToken`],i),x(e,[`filter`])!==void 0)throw Error(`filter parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);return n}function Pr(e,t){let n={},r=x(e,[`pageSize`]);t!==void 0&&r!=null&&b(t,[`_query`,`pageSize`],r);let i=x(e,[`pageToken`]);t!==void 0&&i!=null&&b(t,[`_query`,`pageToken`],i);let a=x(e,[`filter`]);return t!==void 0&&a!=null&&b(t,[`_query`,`filter`],a),n}function Fr(e){let t={},n=x(e,[`config`]);return n!=null&&Nr(n,t),t}function Ir(e){let t={},n=x(e,[`config`]);return n!=null&&Pr(n,t),t}function Lr(e){let t={},n=x(e,[`sdkHttpResponse`]);n!=null&&b(t,[`sdkHttpResponse`],n);let r=x(e,[`nextPageToken`]);r!=null&&b(t,[`nextPageToken`],r);let i=x(e,[`operations`]);if(i!=null){let e=i;Array.isArray(e)&&(e=e.map(e=>Zn(e))),b(t,[`batchJobs`],e)}return t}function Rr(e){let t={},n=x(e,[`sdkHttpResponse`]);n!=null&&b(t,[`sdkHttpResponse`],n);let r=x(e,[`nextPageToken`]);r!=null&&b(t,[`nextPageToken`],r);let i=x(e,[`batchPredictionJobs`]);if(i!=null){let e=i;Array.isArray(e)&&(e=e.map(e=>Qn(e))),b(t,[`batchJobs`],e)}return t}function zr(e){let t={},n=x(e,[`mediaResolution`]);n!=null&&b(t,[`mediaResolution`],n);let r=x(e,[`toolCall`]);r!=null&&b(t,[`toolCall`],r);let i=x(e,[`toolResponse`]);i!=null&&b(t,[`toolResponse`],i);let a=x(e,[`audioTranscription`]);a!=null&&b(t,[`audioTranscription`],a);let o=x(e,[`codeExecutionResult`]);o!=null&&b(t,[`codeExecutionResult`],o);let s=x(e,[`executableCode`]);s!=null&&b(t,[`executableCode`],s);let c=x(e,[`fileData`]);c!=null&&b(t,[`fileData`],xr(c));let l=x(e,[`functionCall`]);l!=null&&b(t,[`functionCall`],Sr(l));let u=x(e,[`functionResponse`]);u!=null&&b(t,[`functionResponse`],u);let d=x(e,[`inlineData`]);d!=null&&b(t,[`inlineData`],nr(d));let f=x(e,[`text`]);f!=null&&b(t,[`text`],f);let p=x(e,[`thought`]);p!=null&&b(t,[`thought`],p);let m=x(e,[`thoughtSignature`]);m!=null&&b(t,[`thoughtSignature`],m);let h=x(e,[`videoMetadata`]);h!=null&&b(t,[`videoMetadata`],h);let g=x(e,[`partMetadata`]);g!=null&&b(t,[`partMetadata`],g);let _=x(e,[`mediaProcessing`]);return _!=null&&b(t,[`mediaProcessing`],_),t}function Br(e){let t={},n=x(e,[`category`]);if(n!=null&&b(t,[`category`],n),x(e,[`method`])!==void 0)throw Error(`method parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);let r=x(e,[`threshold`]);return r!=null&&b(t,[`threshold`],r),t}function Vr(e){let t={},n=x(e,[`functionCallingConfig`]);n!=null&&b(t,[`functionCallingConfig`],Cr(n));let r=x(e,[`retrievalConfig`]);r!=null&&b(t,[`retrievalConfig`],r);let i=x(e,[`includeServerSideToolInvocations`]);return i!=null&&b(t,[`includeServerSideToolInvocations`],i),t}function Hr(e){let t={};if(x(e,[`retrieval`])!==void 0)throw Error(`retrieval parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);let n=x(e,[`googleMaps`]);n!=null&&b(t,[`googleMaps`],Or(n));let r=x(e,[`mcpServers`]);if(r!=null){let e=r;Array.isArray(e)&&(e=e.map(e=>e)),b(t,[`mcpServers`],e)}let i=x(e,[`codeExecution`]);i!=null&&b(t,[`codeExecution`],i);let a=x(e,[`computerUse`]);if(a!=null&&b(t,[`computerUse`],a),x(e,[`enterpriseWebSearch`])!==void 0)throw Error(`enterpriseWebSearch parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);if(x(e,[`exaAiSearch`])!==void 0)throw Error(`exaAiSearch parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);let o=x(e,[`functionDeclarations`]);if(o!=null){let e=o;Array.isArray(e)&&(e=e.map(e=>e)),b(t,[`functionDeclarations`],e)}let s=x(e,[`googleSearch`]);s!=null&&b(t,[`googleSearch`],kr(s));let c=x(e,[`googleSearchRetrieval`]);if(c!=null&&b(t,[`googleSearchRetrieval`],c),x(e,[`parallelAiSearch`])!==void 0)throw Error(`parallelAiSearch parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);let l=x(e,[`urlContext`]);l!=null&&b(t,[`urlContext`],l);let u=x(e,[`fileSearch`]);return u!=null&&b(t,[`fileSearch`],u),t}function Ur(e){let t={},n=x(e,[`bigqueryDestination`,`outputUri`]);n!=null&&b(t,[`bigqueryDestination`],n);let r=x(e,[`displayName`]);return r!=null&&b(t,[`displayName`],r),t}function Wr(e){let t={},n=x(e,[`bigqueryDestination`]);n!=null&&b(t,[`bigqueryDestination`,`outputUri`],n);let r=x(e,[`displayName`]);return r!=null&&b(t,[`displayName`],r),t}var Gr;(function(e){e.PAGED_ITEM_BATCH_JOBS=`batchJobs`,e.PAGED_ITEM_MODELS=`models`,e.PAGED_ITEM_TUNING_JOBS=`tuningJobs`,e.PAGED_ITEM_FILES=`files`,e.PAGED_ITEM_CACHED_CONTENTS=`cachedContents`,e.PAGED_ITEM_FILE_SEARCH_STORES=`fileSearchStores`,e.PAGED_ITEM_DOCUMENTS=`documents`,e.PAGED_ITEM_SKILLS=`skills`})(Gr||={});var Kr=class{constructor(e,t,n,r){this.pageInternal=[],this.paramsInternal={},this.requestInternal=t,this.init(e,n,r)}init(e,t,n){this.nameInternal=e,this.pageInternal=t[this.nameInternal]||[],this.sdkHttpResponseInternal=t?.sdkHttpResponse,this.idxInternal=0;let r={config:{}};r=!n||Object.keys(n).length===0?{config:{}}:typeof n==`object`?Object.assign({},n):n,r.config&&(r.config.pageToken=t.nextPageToken),this.paramsInternal=r,this.pageInternalSize=r.config?.pageSize??this.pageInternal.length}initNextPage(e){this.init(this.nameInternal,e,this.paramsInternal)}get page(){return this.pageInternal}get name(){return this.nameInternal}get pageSize(){return this.pageInternalSize}get sdkHttpResponse(){return this.sdkHttpResponseInternal}get params(){return this.paramsInternal}get pageLength(){return this.pageInternal.length}getItem(e){return this.pageInternal[e]}[Symbol.asyncIterator](){return{next:async()=>{if(this.idxInternal>=this.pageLength){if(this.hasNextPage())await this.nextPage();else return{value:void 0,done:!0}}let e=this.getItem(this.idxInternal);return this.idxInternal+=1,{value:e,done:!1}},return:async()=>({value:void 0,done:!0})}}async nextPage(){if(!this.hasNextPage())throw Error(`No more pages to fetch.`);let e=await this.requestInternal(this.params);return this.initNextPage(e),this.page}hasNextPage(){return this.params.config?.pageToken!==void 0}},qr=class extends v{constructor(e){super(),this.apiClient=e,this.list=async(e={})=>new Kr(Gr.PAGED_ITEM_BATCH_JOBS,e=>this.listInternal(e),await this.listInternal(e),e),this.create=async e=>(this.apiClient.isVertexAI()&&(e.config=this.formatDestination(e.src,e.config)),this.createInternal(e)),this.createEmbeddings=async e=>{if(console.warn(`batches.createEmbeddings() is experimental and may change without notice.`),this.apiClient.isVertexAI())throw Error(`Gemini Enterprise Agent Platform (previously known as Vertex AI) does not support batches.createEmbeddings.`);return this.createEmbeddingsInternal(e)}}createInlinedGenerateContentRequest(e){let t=ur(this.apiClient,e),n=t._url,r=y(`{model}:batchGenerateContent`,n),i=t.batch.inputConfig.requests,a=i.requests,o=[];for(let e of a){let t=Object.assign({},e);if(t.systemInstruction){let e=t.systemInstruction;delete t.systemInstruction;let n=t.request;n.systemInstruction=e,t.request=n}o.push(t)}return i.requests=o,delete t.config,delete t._url,delete t._query,{path:r,body:t}}getGcsUri(e){if(typeof e==`string`)return e.startsWith(`gs://`)?e:void 0;if(!Array.isArray(e)&&e.gcsUri&&e.gcsUri.length>0)return e.gcsUri[0]}getBigqueryUri(e){if(typeof e==`string`)return e.startsWith(`bq://`)?e:void 0;if(!Array.isArray(e))return e.bigqueryUri}formatDestination(e,t){let n=t?Object.assign({},t):{},r=Date.now().toString();if(n.displayName||=`genaiBatchJob_${r}`,n.dest===void 0){let t=this.getGcsUri(e),i=this.getBigqueryUri(e);if(t)n.dest=t.endsWith(`.jsonl`)?`${t.slice(0,-6)}/dest`:`${t}_dest_${r}`;else if(i)n.dest=`${i}_dest_${r}`;else throw Error(`Unsupported source for Gemini Enterprise Agent Platform (previously known as Vertex AI): No GCS or BigQuery URI found.`)}return n}async createInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=dr(this.apiClient,e);return n=y(`batchPredictionJobs`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>Qn(e))}{let i=ur(this.apiClient,e);return n=y(`{model}:batchGenerateContent`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>Zn(e))}}async createEmbeddingsInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI())throw Error(`This method is only supported by the Gemini Developer API.`);{let i=pr(this.apiClient,e);return n=y(`{model}:asyncBatchEmbedContent`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>Zn(e))}}async get(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=Dr(this.apiClient,e);return n=y(`batchPredictionJobs/{name}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>Qn(e))}{let i=Er(this.apiClient,e);return n=y(`batches/{name}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>Zn(e))}}async cancel(e){let t=``,n={};if(this.apiClient.isVertexAI()){let r=ir(this.apiClient,e);t=y(`batchPredictionJobs/{name}:cancel`,r._url),n=r._query,delete r._url,delete r._query,await this.apiClient.request({path:t,queryParams:n,body:JSON.stringify(r),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal})}else{let r=rr(this.apiClient,e);t=y(`batches/{name}:cancel`,r._url),n=r._query,delete r._url,delete r._query,await this.apiClient.request({path:t,queryParams:n,body:JSON.stringify(r),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal})}}async listInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=Ir(e);return n=y(`batchPredictionJobs`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=Rr(e),n=new an;return Object.assign(n,t),n})}{let i=Fr(e);return n=y(`batches`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=Lr(e),n=new an;return Object.assign(n,t),n})}}async delete(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=hr(this.apiClient,e);return n=y(`batchPredictionJobs/{name}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`DELETE`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>_r(e))}{let i=mr(this.apiClient,e);return n=y(`batches/{name}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`DELETE`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>gr(e))}}};function Jr(e){let t={},n=x(e,[`apiKey`]);if(n!=null&&b(t,[`apiKey`],n),x(e,[`apiKeyConfig`])!==void 0)throw Error(`apiKeyConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);if(x(e,[`authType`])!==void 0)throw Error(`authType parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);if(x(e,[`googleServiceAccountConfig`])!==void 0)throw Error(`googleServiceAccountConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);if(x(e,[`httpBasicAuthConfig`])!==void 0)throw Error(`httpBasicAuthConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);if(x(e,[`oauthConfig`])!==void 0)throw Error(`oauthConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);if(x(e,[`oidcConfig`])!==void 0)throw Error(`oidcConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);return t}function Yr(e){let t={},n=x(e,[`data`]);if(n!=null&&b(t,[`data`],n),x(e,[`displayName`])!==void 0)throw Error(`displayName parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);let r=x(e,[`mimeType`]);return r!=null&&b(t,[`mimeType`],r),t}function Xr(e){let t={},n=x(e,[`enablePromptInjectionDetection`]);n!=null&&b(t,[`enablePromptInjectionDetection`],n);let r=x(e,[`environment`]);r!=null&&b(t,[`environment`],r);let i=x(e,[`excludedPredefinedFunctions`]);if(i!=null&&b(t,[`excludedPredefinedFunctions`],i),x(e,[`disabledSafetyPolicies`])!==void 0)throw Error(`disabledSafetyPolicies parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.`);return t}function Zr(e){let t={},n=x(e,[`parts`]);if(n!=null){let e=n;Array.isArray(e)&&(e=e.map(e=>xi(e))),b(t,[`parts`],e)}let r=x(e,[`role`]);return r!=null&&b(t,[`role`],r),t}function Qr(e){let t={},n=x(e,[`parts`]);if(n!=null){let e=n;Array.isArray(e)&&(e=e.map(e=>Si(e))),b(t,[`parts`],e)}let r=x(e,[`role`]);return r!=null&&b(t,[`role`],r),t}function $r(e,t){let n={},r=x(e,[`ttl`]);t!==void 0&&r!=null&&b(t,[`ttl`],r);let i=x(e,[`expireTime`]);t!==void 0&&i!=null&&b(t,[`expireTime`],i);let a=x(e,[`displayName`]);t!==void 0&&a!=null&&b(t,[`displayName`],a);let o=x(e,[`contents`]);if(t!==void 0&&o!=null){let e=P(o);Array.isArray(e)&&(e=e.map(e=>Zr(e))),b(t,[`contents`],e)}let s=x(e,[`systemInstruction`]);t!==void 0&&s!=null&&b(t,[`systemInstruction`],Zr(N(s)));let c=x(e,[`tools`]);if(t!==void 0&&c!=null){let e=c;Array.isArray(e)&&(e=e.map(e=>Ti(e))),b(t,[`tools`],e)}let l=x(e,[`toolConfig`]);if(t!==void 0&&l!=null&&b(t,[`toolConfig`],Ci(l)),x(e,[`kmsKeyName`])!==void 0)throw Error(`kmsKeyName parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);return n}function ei(e,t){let n={},r=x(e,[`ttl`]);t!==void 0&&r!=null&&b(t,[`ttl`],r);let i=x(e,[`expireTime`]);t!==void 0&&i!=null&&b(t,[`expireTime`],i);let a=x(e,[`displayName`]);t!==void 0&&a!=null&&b(t,[`displayName`],a);let o=x(e,[`contents`]);if(t!==void 0&&o!=null){let e=P(o);Array.isArray(e)&&(e=e.map(e=>Qr(e))),b(t,[`contents`],e)}let s=x(e,[`systemInstruction`]);t!==void 0&&s!=null&&b(t,[`systemInstruction`],Qr(N(s)));let c=x(e,[`tools`]);if(t!==void 0&&c!=null){let e=c;Array.isArray(e)&&(e=e.map(e=>Ei(e))),b(t,[`tools`],e)}let l=x(e,[`toolConfig`]);t!==void 0&&l!=null&&b(t,[`toolConfig`],wi(l));let u=x(e,[`kmsKeyName`]);return t!==void 0&&u!=null&&b(t,[`encryption_spec`,`kmsKeyName`],u),n}function ti(e,t){let n={},r=x(t,[`model`]);r!=null&&b(n,[`model`],ln(e,r));let i=x(t,[`config`]);return i!=null&&$r(i,n),n}function ni(e,t){let n={},r=x(t,[`model`]);r!=null&&b(n,[`model`],ln(e,r));let i=x(t,[`config`]);return i!=null&&ei(i,n),n}function ri(e,t){let n={},r=x(t,[`name`]);return r!=null&&b(n,[`_url`,`name`],kn(e,r)),n}function ii(e,t){let n={},r=x(t,[`name`]);return r!=null&&b(n,[`_url`,`name`],kn(e,r)),n}function ai(e){let t={},n=x(e,[`sdkHttpResponse`]);return n!=null&&b(t,[`sdkHttpResponse`],n),t}function oi(e){let t={},n=x(e,[`sdkHttpResponse`]);return n!=null&&b(t,[`sdkHttpResponse`],n),t}function si(e){let t={};if(x(e,[`displayName`])!==void 0)throw Error(`displayName parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);let n=x(e,[`fileUri`]);n!=null&&b(t,[`fileUri`],n);let r=x(e,[`mimeType`]);return r!=null&&b(t,[`mimeType`],r),t}function ci(e){let t={},n=x(e,[`args`]);n!=null&&b(t,[`args`],n);let r=x(e,[`id`]);r!=null&&b(t,[`id`],r);let i=x(e,[`name`]);if(i!=null&&b(t,[`name`],i),x(e,[`partialArgs`])!==void 0)throw Error(`partialArgs parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);if(x(e,[`willContinue`])!==void 0)throw Error(`willContinue parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);return t}function li(e){let t={},n=x(e,[`allowedFunctionNames`]);n!=null&&b(t,[`allowedFunctionNames`],n);let r=x(e,[`mode`]);if(r!=null&&b(t,[`mode`],r),x(e,[`streamFunctionCallArguments`])!==void 0)throw Error(`streamFunctionCallArguments parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);return t}function ui(e,t){let n={},r=x(t,[`name`]);return r!=null&&b(n,[`_url`,`name`],kn(e,r)),n}function di(e,t){let n={},r=x(t,[`name`]);return r!=null&&b(n,[`_url`,`name`],kn(e,r)),n}function fi(e){let t={},n=x(e,[`authConfig`]);n!=null&&b(t,[`authConfig`],Jr(n));let r=x(e,[`enableWidget`]);if(r!=null&&b(t,[`enableWidget`],r),x(e,[`groundingTypes`])!==void 0)throw Error(`groundingTypes parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);return t}function pi(e){let t={};if(x(e,[`blockingConfidence`])!==void 0)throw Error(`blockingConfidence parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);if(x(e,[`excludeDomains`])!==void 0)throw Error(`excludeDomains parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);let n=x(e,[`searchTypes`]);n!=null&&b(t,[`searchTypes`],n);let r=x(e,[`timeRangeFilter`]);return r!=null&&b(t,[`timeRangeFilter`],r),t}function mi(e,t){let n={},r=x(e,[`pageSize`]);t!==void 0&&r!=null&&b(t,[`_query`,`pageSize`],r);let i=x(e,[`pageToken`]);return t!==void 0&&i!=null&&b(t,[`_query`,`pageToken`],i),n}function hi(e,t){let n={},r=x(e,[`pageSize`]);t!==void 0&&r!=null&&b(t,[`_query`,`pageSize`],r);let i=x(e,[`pageToken`]);return t!==void 0&&i!=null&&b(t,[`_query`,`pageToken`],i),n}function gi(e){let t={},n=x(e,[`config`]);return n!=null&&mi(n,t),t}function _i(e){let t={},n=x(e,[`config`]);return n!=null&&hi(n,t),t}function vi(e){let t={},n=x(e,[`sdkHttpResponse`]);n!=null&&b(t,[`sdkHttpResponse`],n);let r=x(e,[`nextPageToken`]);r!=null&&b(t,[`nextPageToken`],r);let i=x(e,[`cachedContents`]);if(i!=null){let e=i;Array.isArray(e)&&(e=e.map(e=>e)),b(t,[`cachedContents`],e)}return t}function yi(e){let t={},n=x(e,[`sdkHttpResponse`]);n!=null&&b(t,[`sdkHttpResponse`],n);let r=x(e,[`nextPageToken`]);r!=null&&b(t,[`nextPageToken`],r);let i=x(e,[`cachedContents`]);if(i!=null){let e=i;Array.isArray(e)&&(e=e.map(e=>e)),b(t,[`cachedContents`],e)}return t}function bi(e){let t={};if(x(e,[`name`])!==void 0)throw Error(`name parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.`);if(x(e,[`streamableHttpTransport`])!==void 0)throw Error(`streamableHttpTransport parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.`);return t}function xi(e){let t={},n=x(e,[`mediaResolution`]);n!=null&&b(t,[`mediaResolution`],n);let r=x(e,[`toolCall`]);r!=null&&b(t,[`toolCall`],r);let i=x(e,[`toolResponse`]);i!=null&&b(t,[`toolResponse`],i);let a=x(e,[`audioTranscription`]);a!=null&&b(t,[`audioTranscription`],a);let o=x(e,[`codeExecutionResult`]);o!=null&&b(t,[`codeExecutionResult`],o);let s=x(e,[`executableCode`]);s!=null&&b(t,[`executableCode`],s);let c=x(e,[`fileData`]);c!=null&&b(t,[`fileData`],si(c));let l=x(e,[`functionCall`]);l!=null&&b(t,[`functionCall`],ci(l));let u=x(e,[`functionResponse`]);u!=null&&b(t,[`functionResponse`],u);let d=x(e,[`inlineData`]);d!=null&&b(t,[`inlineData`],Yr(d));let f=x(e,[`text`]);f!=null&&b(t,[`text`],f);let p=x(e,[`thought`]);p!=null&&b(t,[`thought`],p);let m=x(e,[`thoughtSignature`]);m!=null&&b(t,[`thoughtSignature`],m);let h=x(e,[`videoMetadata`]);h!=null&&b(t,[`videoMetadata`],h);let g=x(e,[`partMetadata`]);g!=null&&b(t,[`partMetadata`],g);let _=x(e,[`mediaProcessing`]);return _!=null&&b(t,[`mediaProcessing`],_),t}function Si(e){let t={},n=x(e,[`mediaResolution`]);if(n!=null&&b(t,[`mediaResolution`],n),x(e,[`toolCall`])!==void 0)throw Error(`toolCall parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.`);if(x(e,[`toolResponse`])!==void 0)throw Error(`toolResponse parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.`);let r=x(e,[`audioTranscription`]);r!=null&&b(t,[`audioTranscription`],r);let i=x(e,[`codeExecutionResult`]);i!=null&&b(t,[`codeExecutionResult`],i);let a=x(e,[`executableCode`]);a!=null&&b(t,[`executableCode`],a);let o=x(e,[`fileData`]);o!=null&&b(t,[`fileData`],o);let s=x(e,[`functionCall`]);s!=null&&b(t,[`functionCall`],s);let c=x(e,[`functionResponse`]);c!=null&&b(t,[`functionResponse`],c);let l=x(e,[`inlineData`]);l!=null&&b(t,[`inlineData`],l);let u=x(e,[`text`]);u!=null&&b(t,[`text`],u);let d=x(e,[`thought`]);d!=null&&b(t,[`thought`],d);let f=x(e,[`thoughtSignature`]);f!=null&&b(t,[`thoughtSignature`],f);let p=x(e,[`videoMetadata`]);if(p!=null&&b(t,[`videoMetadata`],p),x(e,[`partMetadata`])!==void 0)throw Error(`partMetadata parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.`);let m=x(e,[`mediaProcessing`]);return m!=null&&b(t,[`mediaProcessing`],m),t}function Ci(e){let t={},n=x(e,[`functionCallingConfig`]);n!=null&&b(t,[`functionCallingConfig`],li(n));let r=x(e,[`retrievalConfig`]);r!=null&&b(t,[`retrievalConfig`],r);let i=x(e,[`includeServerSideToolInvocations`]);return i!=null&&b(t,[`includeServerSideToolInvocations`],i),t}function wi(e){let t={},n=x(e,[`functionCallingConfig`]);n!=null&&b(t,[`functionCallingConfig`],n);let r=x(e,[`retrievalConfig`]);if(r!=null&&b(t,[`retrievalConfig`],r),x(e,[`includeServerSideToolInvocations`])!==void 0)throw Error(`includeServerSideToolInvocations parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.`);return t}function Ti(e){let t={};if(x(e,[`retrieval`])!==void 0)throw Error(`retrieval parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);let n=x(e,[`googleMaps`]);n!=null&&b(t,[`googleMaps`],fi(n));let r=x(e,[`mcpServers`]);if(r!=null){let e=r;Array.isArray(e)&&(e=e.map(e=>e)),b(t,[`mcpServers`],e)}let i=x(e,[`codeExecution`]);i!=null&&b(t,[`codeExecution`],i);let a=x(e,[`computerUse`]);if(a!=null&&b(t,[`computerUse`],a),x(e,[`enterpriseWebSearch`])!==void 0)throw Error(`enterpriseWebSearch parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);if(x(e,[`exaAiSearch`])!==void 0)throw Error(`exaAiSearch parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);let o=x(e,[`functionDeclarations`]);if(o!=null){let e=o;Array.isArray(e)&&(e=e.map(e=>e)),b(t,[`functionDeclarations`],e)}let s=x(e,[`googleSearch`]);s!=null&&b(t,[`googleSearch`],pi(s));let c=x(e,[`googleSearchRetrieval`]);if(c!=null&&b(t,[`googleSearchRetrieval`],c),x(e,[`parallelAiSearch`])!==void 0)throw Error(`parallelAiSearch parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);let l=x(e,[`urlContext`]);l!=null&&b(t,[`urlContext`],l);let u=x(e,[`fileSearch`]);return u!=null&&b(t,[`fileSearch`],u),t}function Ei(e){let t={},n=x(e,[`retrieval`]);n!=null&&b(t,[`retrieval`],n);let r=x(e,[`googleMaps`]);r!=null&&b(t,[`googleMaps`],r);let i=x(e,[`mcpServers`]);if(i!=null){let e=i;Array.isArray(e)&&(e=e.map(e=>bi(e))),b(t,[`mcpServers`],e)}let a=x(e,[`codeExecution`]);a!=null&&b(t,[`codeExecution`],a);let o=x(e,[`computerUse`]);o!=null&&b(t,[`computerUse`],Xr(o));let s=x(e,[`enterpriseWebSearch`]);s!=null&&b(t,[`enterpriseWebSearch`],s);let c=x(e,[`exaAiSearch`]);c!=null&&b(t,[`exaAiSearch`],c);let l=x(e,[`functionDeclarations`]);if(l!=null){let e=l;Array.isArray(e)&&(e=e.map(e=>e)),b(t,[`functionDeclarations`],e)}let u=x(e,[`googleSearch`]);u!=null&&b(t,[`googleSearch`],u);let d=x(e,[`googleSearchRetrieval`]);d!=null&&b(t,[`googleSearchRetrieval`],d);let f=x(e,[`parallelAiSearch`]);f!=null&&b(t,[`parallelAiSearch`],f);let p=x(e,[`urlContext`]);if(p!=null&&b(t,[`urlContext`],p),x(e,[`fileSearch`])!==void 0)throw Error(`fileSearch parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.`);return t}function Di(e,t){let n={},r=x(e,[`ttl`]);t!==void 0&&r!=null&&b(t,[`ttl`],r);let i=x(e,[`expireTime`]);return t!==void 0&&i!=null&&b(t,[`expireTime`],i),n}function Oi(e,t){let n={},r=x(e,[`ttl`]);t!==void 0&&r!=null&&b(t,[`ttl`],r);let i=x(e,[`expireTime`]);return t!==void 0&&i!=null&&b(t,[`expireTime`],i),n}function ki(e,t){let n={},r=x(t,[`name`]);r!=null&&b(n,[`_url`,`name`],kn(e,r));let i=x(t,[`config`]);return i!=null&&Di(i,n),n}function Ai(e,t){let n={},r=x(t,[`name`]);r!=null&&b(n,[`_url`,`name`],kn(e,r));let i=x(t,[`config`]);return i!=null&&Oi(i,n),n}var ji=class extends v{constructor(e){super(),this.apiClient=e,this.list=async(e={})=>new Kr(Gr.PAGED_ITEM_CACHED_CONTENTS,e=>this.listInternal(e),await this.listInternal(e),e)}async create(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=ni(this.apiClient,e);return n=y(`cachedContents`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>e)}{let i=ti(this.apiClient,e);return n=y(`cachedContents`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>e)}}async get(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=di(this.apiClient,e);return n=y(`{name}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>e)}{let i=ui(this.apiClient,e);return n=y(`{name}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>e)}}async delete(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=ii(this.apiClient,e);return n=y(`{name}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`DELETE`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=oi(e),n=new Jt;return Object.assign(n,t),n})}{let i=ri(this.apiClient,e);return n=y(`{name}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`DELETE`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=ai(e),n=new Jt;return Object.assign(n,t),n})}}async update(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=Ai(this.apiClient,e);return n=y(`{name}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`PATCH`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>e)}{let i=ki(this.apiClient,e);return n=y(`{name}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`PATCH`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>e)}}async listInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=_i(e);return n=y(`cachedContents`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=yi(e),n=new Yt;return Object.assign(n,t),n})}{let i=gi(e);return n=y(`cachedContents`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=vi(e),n=new Yt;return Object.assign(n,t),n})}}};function F(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function Mi(e){var t=typeof Symbol==`function`&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length==`number`)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw TypeError(t?`Object is not iterable.`:`Symbol.iterator is not defined.`)}function I(e){return this instanceof I?(this.v=e,this):new I(e)}function Ni(e,t,n){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var r=n.apply(e,t||[]),i,a=[];return i=Object.create((typeof AsyncIterator==`function`?AsyncIterator:Object).prototype),s(`next`),s(`throw`),s(`return`,o),i[Symbol.asyncIterator]=function(){return this},i;function o(e){return function(t){return Promise.resolve(t).then(e,d)}}function s(e,t){r[e]&&(i[e]=function(t){return new Promise(function(n,r){a.push([e,t,n,r])>1||c(e,t)})},t&&(i[e]=t(i[e])))}function c(e,t){try{l(r[e](t))}catch(e){f(a[0][3],e)}}function l(e){e.value instanceof I?Promise.resolve(e.value.v).then(u,d):f(a[0][2],e)}function u(e){c(`next`,e)}function d(e){c(`throw`,e)}function f(e,t){e(t),a.shift(),a.length&&c(a[0][0],a[0][1])}}function Pi(e){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof Mi==`function`?Mi(e):e[Symbol.iterator](),n={},r(`next`),r(`throw`),r(`return`),n[Symbol.asyncIterator]=function(){return this},n);function r(t){n[t]=e[t]&&function(n){return new Promise(function(r,a){n=e[t](n),i(r,a,n.done,n.value)})}}function i(e,t,n,r){Promise.resolve(r).then(function(t){e({value:t,done:n})},t)}}function Fi(e){if(e.candidates==null||e.candidates.length===0)return!1;let t=e.candidates[0]?.content;return t!==void 0&&Ii(t)}function Ii(e){if(e.parts===void 0||e.parts.length===0)return!1;for(let t of e.parts)if(t===void 0||Object.keys(t).length===0)return!1;return!0}function Li(e){if(e.length!==0){for(let t of e)if(t.role!==`user`&&t.role!==`model`)throw Error(`Role must be user or model, but got ${t.role}.`)}}function Ri(e){if(e===void 0||e.length===0)return[];let t=[],n=e.length,r=0;for(;r<n;)if(e[r].role===`user`)t.push(e[r]),r++;else{let i=[],a=!0;for(;r<n&&e[r].role===`model`;)i.push(e[r]),a&&!Ii(e[r])&&(a=!1),r++;a?t.push(...i):t.pop()}return t}var zi=class{constructor(e,t){this.modelsModule=e,this.apiClient=t}create(e){return new Bi(this.apiClient,this.modelsModule,e.model,e.config,structuredClone(e.history))}},Bi=class{constructor(e,t,n,r={},i=[]){this.apiClient=e,this.modelsModule=t,this.model=n,this.config=r,this.history=i,this.sendPromise=Promise.resolve(),Li(i)}async sendMessage(e){await this.sendPromise;let t=N(e.message),n=this.modelsModule.generateContent({model:this.model,contents:this.getHistory(!0).concat(t),config:e.config??this.config});return this.sendPromise=(async()=>{let e=await n,r=e.candidates?.[0]?.content,i=e.automaticFunctionCallingHistory,a=this.getHistory(!0).length,o=[];i!=null&&(o=i.slice(a)??[]);let s=r?[r]:[];this.recordHistory(t,s,o)})(),await this.sendPromise.catch(()=>{this.sendPromise=Promise.resolve()}),n}async sendMessageStream(e){await this.sendPromise;let t=N(e.message),n=this.modelsModule.generateContentStream({model:this.model,contents:this.getHistory(!0).concat(t),config:e.config??this.config});this.sendPromise=n.then(()=>void 0).catch(()=>void 0);let r=await n;return this.processStreamResponse(r,t)}getHistory(e=!1){let t=e?Ri(this.history):this.history;return structuredClone(t)}processStreamResponse(e,t){return Ni(this,arguments,function*(){var n,r,i,a;let o=[];try{for(var s=!0,c=Pi(e),l;l=yield I(c.next()),n=l.done,!n;s=!0){a=l.value,s=!1;let e=a;if(Fi(e)){let t=e.candidates?.[0]?.content;t!==void 0&&o.push(t)}yield yield I(e)}}catch(e){r={error:e}}finally{try{!s&&!n&&(i=c.return)&&(yield I(i.call(c)))}finally{if(r)throw r.error}}this.recordHistory(t,o)})}recordHistory(e,t,n){let r=[];t.length>0&&t.every(e=>e.role!==void 0)?r=t:r.push({role:`model`,parts:[]}),n&&n.length>0?this.history.push(...Ri(n)):this.history.push(e),this.history.push(...r)}},Vi=class e extends Error{constructor(t){super(t.message),this.name=`ApiError`,this.status=t.status,Object.setPrototypeOf(this,e.prototype)}};function Hi(e){let t={},n=x(e,[`file`]);return n!=null&&b(t,[`file`],n),t}function Ui(e){let t={},n=x(e,[`sdkHttpResponse`]);return n!=null&&b(t,[`sdkHttpResponse`],n),t}function Wi(e){let t={},n=x(e,[`name`]);return n!=null&&b(t,[`_url`,`file`],Fn(n)),t}function Gi(e){let t={},n=x(e,[`sdkHttpResponse`]);return n!=null&&b(t,[`sdkHttpResponse`],n),t}function Ki(e){let t={},n=x(e,[`name`]);return n!=null&&b(t,[`_url`,`file`],Fn(n)),t}function qi(e){let t={},n=x(e,[`uris`]);return n!=null&&b(t,[`uris`],n),t}function Ji(e,t){let n={},r=x(e,[`pageSize`]);t!==void 0&&r!=null&&b(t,[`_query`,`pageSize`],r);let i=x(e,[`pageToken`]);return t!==void 0&&i!=null&&b(t,[`_query`,`pageToken`],i),n}function Yi(e){let t={},n=x(e,[`config`]);return n!=null&&Ji(n,t),t}function Xi(e){let t={},n=x(e,[`sdkHttpResponse`]);n!=null&&b(t,[`sdkHttpResponse`],n);let r=x(e,[`nextPageToken`]);r!=null&&b(t,[`nextPageToken`],r);let i=x(e,[`files`]);if(i!=null){let e=i;Array.isArray(e)&&(e=e.map(e=>e)),b(t,[`files`],e)}return t}function Zi(e){let t={},n=x(e,[`sdkHttpResponse`]);n!=null&&b(t,[`sdkHttpResponse`],n);let r=x(e,[`files`]);if(r!=null){let e=r;Array.isArray(e)&&(e=e.map(e=>e)),b(t,[`files`],e)}return t}var Qi=class extends v{constructor(e){super(),this.apiClient=e,this.list=async(e={})=>new Kr(Gr.PAGED_ITEM_FILES,e=>this.listInternal(e),await this.listInternal(e),e)}async upload(e){if(this.apiClient.isVertexAI())throw Error(`Gemini Enterprise Agent Platform (previously known as Vertex AI) does not support uploading files. You can share files through a GCS bucket.`);return this.apiClient.uploadFile(e.file,e.config).then(e=>e)}async download(e){await this.apiClient.downloadFile(e)}async registerFiles(e){throw Error(`registerFiles is only supported in Node.js environments.`)}async _registerFiles(e){return this.registerFilesInternal(e)}async listInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI())throw Error(`This method is only supported by the Gemini Developer API.`);{let i=Yi(e);return n=y(`files`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=Xi(e),n=new en;return Object.assign(n,t),n})}}async createInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI())throw Error(`This method is only supported by the Gemini Developer API.`);{let i=Hi(e);return n=y(`upload/v1beta/files`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>{let t=Ui(e),n=new tn;return Object.assign(n,t),n})}}async get(e){let t,n=``,r={};if(this.apiClient.isVertexAI())throw Error(`This method is only supported by the Gemini Developer API.`);{let i=Ki(e);return n=y(`files/{file}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>e)}}async delete(e){let t,n=``,r={};if(this.apiClient.isVertexAI())throw Error(`This method is only supported by the Gemini Developer API.`);{let i=Wi(e);return n=y(`files/{file}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`DELETE`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=Gi(e),n=new nn;return Object.assign(n,t),n})}}async registerFilesInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI())throw Error(`This method is only supported by the Gemini Developer API.`);{let i=qi(e);return n=y(`files:register`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>{let t=Zi(e),n=new rn;return Object.assign(n,t),n})}}};function $i(e){let t={},n=x(e,[`apiKey`]);if(n!=null&&b(t,[`apiKey`],n),x(e,[`apiKeyConfig`])!==void 0)throw Error(`apiKeyConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);if(x(e,[`authType`])!==void 0)throw Error(`authType parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);if(x(e,[`googleServiceAccountConfig`])!==void 0)throw Error(`googleServiceAccountConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);if(x(e,[`httpBasicAuthConfig`])!==void 0)throw Error(`httpBasicAuthConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);if(x(e,[`oauthConfig`])!==void 0)throw Error(`oauthConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);if(x(e,[`oidcConfig`])!==void 0)throw Error(`oidcConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);return t}function ea(e){let t={},n=x(e,[`data`]);if(n!=null&&b(t,[`data`],n),x(e,[`displayName`])!==void 0)throw Error(`displayName parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);let r=x(e,[`mimeType`]);return r!=null&&b(t,[`mimeType`],r),t}function ta(e){let t={},n=x(e,[`enablePromptInjectionDetection`]);n!=null&&b(t,[`enablePromptInjectionDetection`],n);let r=x(e,[`environment`]);r!=null&&b(t,[`environment`],r);let i=x(e,[`excludedPredefinedFunctions`]);if(i!=null&&b(t,[`excludedPredefinedFunctions`],i),x(e,[`disabledSafetyPolicies`])!==void 0)throw Error(`disabledSafetyPolicies parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.`);return t}function na(e){let t={},n=x(e,[`parts`]);if(n!=null){let e=n;Array.isArray(e)&&(e=e.map(e=>ba(e))),b(t,[`parts`],e)}let r=x(e,[`role`]);return r!=null&&b(t,[`role`],r),t}function ra(e){let t={},n=x(e,[`parts`]);if(n!=null){let e=n;Array.isArray(e)&&(e=e.map(e=>xa(e))),b(t,[`parts`],e)}let r=x(e,[`role`]);return r!=null&&b(t,[`role`],r),t}function ia(e){let t={};if(x(e,[`displayName`])!==void 0)throw Error(`displayName parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);let n=x(e,[`fileUri`]);n!=null&&b(t,[`fileUri`],n);let r=x(e,[`mimeType`]);return r!=null&&b(t,[`mimeType`],r),t}function aa(e){let t={},n=x(e,[`args`]);n!=null&&b(t,[`args`],n);let r=x(e,[`id`]);r!=null&&b(t,[`id`],r);let i=x(e,[`name`]);if(i!=null&&b(t,[`name`],i),x(e,[`partialArgs`])!==void 0)throw Error(`partialArgs parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);if(x(e,[`willContinue`])!==void 0)throw Error(`willContinue parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);return t}function oa(e){let t={},n=x(e,[`modelSelectionConfig`]);n!=null&&b(t,[`modelConfig`],n);let r=x(e,[`responseJsonSchema`]);r!=null&&b(t,[`responseJsonSchema`],Cn(r));let i=x(e,[`audioTranscriptionConfig`]);i!=null&&b(t,[`audioTranscriptionConfig`],i);let a=x(e,[`audioTimestamp`]);a!=null&&b(t,[`audioTimestamp`],a);let o=x(e,[`candidateCount`]);o!=null&&b(t,[`candidateCount`],o);let s=x(e,[`enableAffectiveDialog`]);s!=null&&b(t,[`enableAffectiveDialog`],s);let c=x(e,[`frequencyPenalty`]);c!=null&&b(t,[`frequencyPenalty`],c);let l=x(e,[`logprobs`]);l!=null&&b(t,[`logprobs`],l);let u=x(e,[`maxOutputTokens`]);u!=null&&b(t,[`maxOutputTokens`],u);let d=x(e,[`mediaResolution`]);d!=null&&b(t,[`mediaResolution`],d);let f=x(e,[`presencePenalty`]);f!=null&&b(t,[`presencePenalty`],f);let p=x(e,[`responseFormat`]);if(p!=null){let e=p;Array.isArray(e)&&(e=e.map(e=>e)),b(t,[`responseFormat`],e)}let m=x(e,[`responseLogprobs`]);m!=null&&b(t,[`responseLogprobs`],m);let h=x(e,[`responseMimeType`]);h!=null&&b(t,[`responseMimeType`],h);let g=x(e,[`responseModalities`]);g!=null&&b(t,[`responseModalities`],g);let _=x(e,[`responseSchema`]);_!=null&&b(t,[`responseSchema`],_);let v=x(e,[`routingConfig`]);v!=null&&b(t,[`routingConfig`],v);let y=x(e,[`seed`]);y!=null&&b(t,[`seed`],y);let S=x(e,[`speechConfig`]);S!=null&&b(t,[`speechConfig`],Ea(S));let C=x(e,[`stopSequences`]);C!=null&&b(t,[`stopSequences`],C);let w=x(e,[`temperature`]);w!=null&&b(t,[`temperature`],w);let T=x(e,[`thinkingConfig`]);T!=null&&b(t,[`thinkingConfig`],T);let E=x(e,[`topK`]);E!=null&&b(t,[`topK`],E);let D=x(e,[`topP`]);if(D!=null&&b(t,[`topP`],D),x(e,[`enableEnhancedCivicAnswers`])!==void 0)throw Error(`enableEnhancedCivicAnswers parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.`);if(x(e,[`translationConfig`])!==void 0)throw Error(`translationConfig parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.`);return t}function sa(e){let t={},n=x(e,[`authConfig`]);n!=null&&b(t,[`authConfig`],$i(n));let r=x(e,[`enableWidget`]);if(r!=null&&b(t,[`enableWidget`],r),x(e,[`groundingTypes`])!==void 0)throw Error(`groundingTypes parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);return t}function ca(e){let t={};if(x(e,[`blockingConfidence`])!==void 0)throw Error(`blockingConfidence parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);if(x(e,[`excludeDomains`])!==void 0)throw Error(`excludeDomains parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);let n=x(e,[`searchTypes`]);n!=null&&b(t,[`searchTypes`],n);let r=x(e,[`timeRangeFilter`]);return r!=null&&b(t,[`timeRangeFilter`],r),t}function la(e,t){let n={},r=x(e,[`generationConfig`]);t!==void 0&&r!=null&&b(t,[`setup`,`generationConfig`],r);let i=x(e,[`responseModalities`]);t!==void 0&&i!=null&&b(t,[`setup`,`generationConfig`,`responseModalities`],i);let a=x(e,[`temperature`]);t!==void 0&&a!=null&&b(t,[`setup`,`generationConfig`,`temperature`],a);let o=x(e,[`topP`]);t!==void 0&&o!=null&&b(t,[`setup`,`generationConfig`,`topP`],o);let s=x(e,[`topK`]);t!==void 0&&s!=null&&b(t,[`setup`,`generationConfig`,`topK`],s);let c=x(e,[`maxOutputTokens`]);t!==void 0&&c!=null&&b(t,[`setup`,`generationConfig`,`maxOutputTokens`],c);let l=x(e,[`mediaResolution`]);t!==void 0&&l!=null&&b(t,[`setup`,`generationConfig`,`mediaResolution`],l);let u=x(e,[`seed`]);t!==void 0&&u!=null&&b(t,[`setup`,`generationConfig`,`seed`],u);let d=x(e,[`speechConfig`]);t!==void 0&&d!=null&&b(t,[`setup`,`generationConfig`,`speechConfig`],Tn(d));let f=x(e,[`thinkingConfig`]);t!==void 0&&f!=null&&b(t,[`setup`,`generationConfig`,`thinkingConfig`],f);let p=x(e,[`enableAffectiveDialog`]);t!==void 0&&p!=null&&b(t,[`setup`,`generationConfig`,`enableAffectiveDialog`],p);let m=x(e,[`systemInstruction`]);t!==void 0&&m!=null&&b(t,[`setup`,`systemInstruction`],na(N(m)));let h=x(e,[`tools`]);if(t!==void 0&&h!=null){let e=Dn(h);Array.isArray(e)&&(e=e.map(e=>Da(En(e)))),b(t,[`setup`,`tools`],e)}let g=x(e,[`sessionResumption`]);t!==void 0&&g!=null&&b(t,[`setup`,`sessionResumption`],wa(g));let _=x(e,[`inputAudioTranscription`]);t!==void 0&&_!=null&&b(t,[`setup`,`inputAudioTranscription`],_);let v=x(e,[`outputAudioTranscription`]);t!==void 0&&v!=null&&b(t,[`setup`,`outputAudioTranscription`],v);let y=x(e,[`realtimeInputConfig`]);t!==void 0&&y!=null&&b(t,[`setup`,`realtimeInputConfig`],y);let S=x(e,[`contextWindowCompression`]);t!==void 0&&S!=null&&b(t,[`setup`,`contextWindowCompression`],S);let C=x(e,[`proactivity`]);if(t!==void 0&&C!=null&&b(t,[`setup`,`proactivity`],C),x(e,[`explicitVadSignal`])!==void 0)throw Error(`explicitVadSignal parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);let w=x(e,[`avatarConfig`]);t!==void 0&&w!=null&&b(t,[`setup`,`avatarConfig`],w);let T=x(e,[`safetySettings`]);if(t!==void 0&&T!=null){let e=T;Array.isArray(e)&&(e=e.map(e=>Ca(e))),b(t,[`setup`,`safetySettings`],e)}let E=x(e,[`translationConfig`]);return t!==void 0&&E!=null&&b(t,[`setup`,`generationConfig`,`translationConfig`],E),n}function ua(e,t){let n={},r=x(e,[`generationConfig`]);t!==void 0&&r!=null&&b(t,[`setup`,`generationConfig`],oa(r));let i=x(e,[`responseModalities`]);t!==void 0&&i!=null&&b(t,[`setup`,`generationConfig`,`responseModalities`],i);let a=x(e,[`temperature`]);t!==void 0&&a!=null&&b(t,[`setup`,`generationConfig`,`temperature`],a);let o=x(e,[`topP`]);t!==void 0&&o!=null&&b(t,[`setup`,`generationConfig`,`topP`],o);let s=x(e,[`topK`]);t!==void 0&&s!=null&&b(t,[`setup`,`generationConfig`,`topK`],s);let c=x(e,[`maxOutputTokens`]);t!==void 0&&c!=null&&b(t,[`setup`,`generationConfig`,`maxOutputTokens`],c);let l=x(e,[`mediaResolution`]);t!==void 0&&l!=null&&b(t,[`setup`,`generationConfig`,`mediaResolution`],l);let u=x(e,[`seed`]);t!==void 0&&u!=null&&b(t,[`setup`,`generationConfig`,`seed`],u);let d=x(e,[`speechConfig`]);t!==void 0&&d!=null&&b(t,[`setup`,`generationConfig`,`speechConfig`],Ea(Tn(d)));let f=x(e,[`thinkingConfig`]);t!==void 0&&f!=null&&b(t,[`setup`,`generationConfig`,`thinkingConfig`],f);let p=x(e,[`enableAffectiveDialog`]);t!==void 0&&p!=null&&b(t,[`setup`,`generationConfig`,`enableAffectiveDialog`],p);let m=x(e,[`systemInstruction`]);t!==void 0&&m!=null&&b(t,[`setup`,`systemInstruction`],ra(N(m)));let h=x(e,[`tools`]);if(t!==void 0&&h!=null){let e=Dn(h);Array.isArray(e)&&(e=e.map(e=>Oa(En(e)))),b(t,[`setup`,`tools`],e)}let g=x(e,[`sessionResumption`]);t!==void 0&&g!=null&&b(t,[`setup`,`sessionResumption`],g);let _=x(e,[`inputAudioTranscription`]);t!==void 0&&_!=null&&b(t,[`setup`,`inputAudioTranscription`],_);let v=x(e,[`outputAudioTranscription`]);t!==void 0&&v!=null&&b(t,[`setup`,`outputAudioTranscription`],v);let y=x(e,[`realtimeInputConfig`]);t!==void 0&&y!=null&&b(t,[`setup`,`realtimeInputConfig`],y);let S=x(e,[`contextWindowCompression`]);t!==void 0&&S!=null&&b(t,[`setup`,`contextWindowCompression`],S);let C=x(e,[`proactivity`]);t!==void 0&&C!=null&&b(t,[`setup`,`proactivity`],C);let w=x(e,[`explicitVadSignal`]);t!==void 0&&w!=null&&b(t,[`setup`,`explicitVadSignal`],w);let T=x(e,[`avatarConfig`]);t!==void 0&&T!=null&&b(t,[`setup`,`avatarConfig`],T);let E=x(e,[`safetySettings`]);if(t!==void 0&&E!=null){let e=E;Array.isArray(e)&&(e=e.map(e=>e)),b(t,[`setup`,`safetySettings`],e)}let D=x(e,[`translationConfig`]);return t!==void 0&&D!=null&&b(t,[`setup`,`generationConfig`,`translationConfig`],D),n}function da(e,t){let n={},r=x(t,[`model`]);r!=null&&b(n,[`setup`,`model`],M(e,r));let i=x(t,[`config`]);return i!=null&&b(n,[`config`],la(i,n)),n}function fa(e,t){let n={},r=x(t,[`model`]);r!=null&&b(n,[`setup`,`model`],M(e,r));let i=x(t,[`config`]);return i!=null&&b(n,[`config`],ua(i,n)),n}function pa(e){let t={},n=x(e,[`musicGenerationConfig`]);return n!=null&&b(t,[`musicGenerationConfig`],n),t}function ma(e){let t={},n=x(e,[`weightedPrompts`]);if(n!=null){let e=n;Array.isArray(e)&&(e=e.map(e=>e)),b(t,[`weightedPrompts`],e)}return t}function ha(e){let t={},n=x(e,[`media`]);if(n!=null){let e=un(n);Array.isArray(e)&&(e=e.map(e=>ea(e))),b(t,[`mediaChunks`],e)}let r=x(e,[`audio`]);r!=null&&b(t,[`audio`],ea(pn(r)));let i=x(e,[`audioStreamEnd`]);i!=null&&b(t,[`audioStreamEnd`],i);let a=x(e,[`video`]);a!=null&&b(t,[`video`],ea(fn(a)));let o=x(e,[`text`]);o!=null&&b(t,[`text`],o);let s=x(e,[`activityStart`]);s!=null&&b(t,[`activityStart`],s);let c=x(e,[`activityEnd`]);return c!=null&&b(t,[`activityEnd`],c),t}function ga(e){let t={},n=x(e,[`media`]);if(n!=null){let e=un(n);Array.isArray(e)&&(e=e.map(e=>e)),b(t,[`mediaChunks`],e)}let r=x(e,[`audio`]);r!=null&&b(t,[`audio`],pn(r));let i=x(e,[`audioStreamEnd`]);i!=null&&b(t,[`audioStreamEnd`],i);let a=x(e,[`video`]);a!=null&&b(t,[`video`],fn(a));let o=x(e,[`text`]);o!=null&&b(t,[`text`],o);let s=x(e,[`activityStart`]);s!=null&&b(t,[`activityStart`],s);let c=x(e,[`activityEnd`]);return c!=null&&b(t,[`activityEnd`],c),t}function _a(e){let t={},n=x(e,[`setupComplete`]);n!=null&&b(t,[`setupComplete`],n);let r=x(e,[`serverContent`]);r!=null&&b(t,[`serverContent`],r);let i=x(e,[`toolCall`]);i!=null&&b(t,[`toolCall`],i);let a=x(e,[`toolCallCancellation`]);a!=null&&b(t,[`toolCallCancellation`],a);let o=x(e,[`usageMetadata`]);o!=null&&b(t,[`usageMetadata`],ka(o));let s=x(e,[`goAway`]);s!=null&&b(t,[`goAway`],s);let c=x(e,[`sessionResumptionUpdate`]);c!=null&&b(t,[`sessionResumptionUpdate`],c);let l=x(e,[`voiceActivityDetectionSignal`]);l!=null&&b(t,[`voiceActivityDetectionSignal`],l);let u=x(e,[`voiceActivity`]);return u!=null&&b(t,[`voiceActivity`],Aa(u)),t}function va(e){let t={};if(x(e,[`name`])!==void 0)throw Error(`name parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.`);if(x(e,[`streamableHttpTransport`])!==void 0)throw Error(`streamableHttpTransport parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.`);return t}function ya(e){let t={},n=x(e,[`speakerVoiceConfigs`]);if(n!=null){let e=n;Array.isArray(e)&&(e=e.map(e=>Ta(e))),b(t,[`speakerVoiceConfigs`],e)}return t}function ba(e){let t={},n=x(e,[`mediaResolution`]);n!=null&&b(t,[`mediaResolution`],n);let r=x(e,[`toolCall`]);r!=null&&b(t,[`toolCall`],r);let i=x(e,[`toolResponse`]);i!=null&&b(t,[`toolResponse`],i);let a=x(e,[`audioTranscription`]);a!=null&&b(t,[`audioTranscription`],a);let o=x(e,[`codeExecutionResult`]);o!=null&&b(t,[`codeExecutionResult`],o);let s=x(e,[`executableCode`]);s!=null&&b(t,[`executableCode`],s);let c=x(e,[`fileData`]);c!=null&&b(t,[`fileData`],ia(c));let l=x(e,[`functionCall`]);l!=null&&b(t,[`functionCall`],aa(l));let u=x(e,[`functionResponse`]);u!=null&&b(t,[`functionResponse`],u);let d=x(e,[`inlineData`]);d!=null&&b(t,[`inlineData`],ea(d));let f=x(e,[`text`]);f!=null&&b(t,[`text`],f);let p=x(e,[`thought`]);p!=null&&b(t,[`thought`],p);let m=x(e,[`thoughtSignature`]);m!=null&&b(t,[`thoughtSignature`],m);let h=x(e,[`videoMetadata`]);h!=null&&b(t,[`videoMetadata`],h);let g=x(e,[`partMetadata`]);g!=null&&b(t,[`partMetadata`],g);let _=x(e,[`mediaProcessing`]);return _!=null&&b(t,[`mediaProcessing`],_),t}function xa(e){let t={},n=x(e,[`mediaResolution`]);if(n!=null&&b(t,[`mediaResolution`],n),x(e,[`toolCall`])!==void 0)throw Error(`toolCall parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.`);if(x(e,[`toolResponse`])!==void 0)throw Error(`toolResponse parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.`);let r=x(e,[`audioTranscription`]);r!=null&&b(t,[`audioTranscription`],r);let i=x(e,[`codeExecutionResult`]);i!=null&&b(t,[`codeExecutionResult`],i);let a=x(e,[`executableCode`]);a!=null&&b(t,[`executableCode`],a);let o=x(e,[`fileData`]);o!=null&&b(t,[`fileData`],o);let s=x(e,[`functionCall`]);s!=null&&b(t,[`functionCall`],s);let c=x(e,[`functionResponse`]);c!=null&&b(t,[`functionResponse`],c);let l=x(e,[`inlineData`]);l!=null&&b(t,[`inlineData`],l);let u=x(e,[`text`]);u!=null&&b(t,[`text`],u);let d=x(e,[`thought`]);d!=null&&b(t,[`thought`],d);let f=x(e,[`thoughtSignature`]);f!=null&&b(t,[`thoughtSignature`],f);let p=x(e,[`videoMetadata`]);if(p!=null&&b(t,[`videoMetadata`],p),x(e,[`partMetadata`])!==void 0)throw Error(`partMetadata parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.`);let m=x(e,[`mediaProcessing`]);return m!=null&&b(t,[`mediaProcessing`],m),t}function Sa(e){let t={},n=x(e,[`mimeType`]);n!=null&&b(t,[`mimeType`],n);let r=x(e,[`voiceSampleAudio`]);if(r!=null&&b(t,[`voiceSampleAudio`],r),x(e,[`consentAudio`])!==void 0)throw Error(`consentAudio parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.`);if(x(e,[`voiceConsentSignature`])!==void 0)throw Error(`voiceConsentSignature parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.`);return t}function Ca(e){let t={},n=x(e,[`category`]);if(n!=null&&b(t,[`category`],n),x(e,[`method`])!==void 0)throw Error(`method parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);let r=x(e,[`threshold`]);return r!=null&&b(t,[`threshold`],r),t}function wa(e){let t={},n=x(e,[`handle`]);if(n!=null&&b(t,[`handle`],n),x(e,[`transparent`])!==void 0)throw Error(`transparent parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);return t}function Ta(e){let t={},n=x(e,[`speaker`]);n!=null&&b(t,[`speaker`],n);let r=x(e,[`voiceConfig`]);return r!=null&&b(t,[`voiceConfig`],ja(r)),t}function Ea(e){let t={},n=x(e,[`voiceConfig`]);n!=null&&b(t,[`voiceConfig`],ja(n));let r=x(e,[`languageCode`]);r!=null&&b(t,[`languageCode`],r);let i=x(e,[`multiSpeakerVoiceConfig`]);return i!=null&&b(t,[`multiSpeakerVoiceConfig`],ya(i)),t}function Da(e){let t={};if(x(e,[`retrieval`])!==void 0)throw Error(`retrieval parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);let n=x(e,[`googleMaps`]);n!=null&&b(t,[`googleMaps`],sa(n));let r=x(e,[`mcpServers`]);if(r!=null){let e=r;Array.isArray(e)&&(e=e.map(e=>e)),b(t,[`mcpServers`],e)}let i=x(e,[`codeExecution`]);i!=null&&b(t,[`codeExecution`],i);let a=x(e,[`computerUse`]);if(a!=null&&b(t,[`computerUse`],a),x(e,[`enterpriseWebSearch`])!==void 0)throw Error(`enterpriseWebSearch parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);if(x(e,[`exaAiSearch`])!==void 0)throw Error(`exaAiSearch parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);let o=x(e,[`functionDeclarations`]);if(o!=null){let e=o;Array.isArray(e)&&(e=e.map(e=>e)),b(t,[`functionDeclarations`],e)}let s=x(e,[`googleSearch`]);s!=null&&b(t,[`googleSearch`],ca(s));let c=x(e,[`googleSearchRetrieval`]);if(c!=null&&b(t,[`googleSearchRetrieval`],c),x(e,[`parallelAiSearch`])!==void 0)throw Error(`parallelAiSearch parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);let l=x(e,[`urlContext`]);l!=null&&b(t,[`urlContext`],l);let u=x(e,[`fileSearch`]);return u!=null&&b(t,[`fileSearch`],u),t}function Oa(e){let t={},n=x(e,[`retrieval`]);n!=null&&b(t,[`retrieval`],n);let r=x(e,[`googleMaps`]);r!=null&&b(t,[`googleMaps`],r);let i=x(e,[`mcpServers`]);if(i!=null){let e=i;Array.isArray(e)&&(e=e.map(e=>va(e))),b(t,[`mcpServers`],e)}let a=x(e,[`codeExecution`]);a!=null&&b(t,[`codeExecution`],a);let o=x(e,[`computerUse`]);o!=null&&b(t,[`computerUse`],ta(o));let s=x(e,[`enterpriseWebSearch`]);s!=null&&b(t,[`enterpriseWebSearch`],s);let c=x(e,[`exaAiSearch`]);c!=null&&b(t,[`exaAiSearch`],c);let l=x(e,[`functionDeclarations`]);if(l!=null){let e=l;Array.isArray(e)&&(e=e.map(e=>e)),b(t,[`functionDeclarations`],e)}let u=x(e,[`googleSearch`]);u!=null&&b(t,[`googleSearch`],u);let d=x(e,[`googleSearchRetrieval`]);d!=null&&b(t,[`googleSearchRetrieval`],d);let f=x(e,[`parallelAiSearch`]);f!=null&&b(t,[`parallelAiSearch`],f);let p=x(e,[`urlContext`]);if(p!=null&&b(t,[`urlContext`],p),x(e,[`fileSearch`])!==void 0)throw Error(`fileSearch parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.`);return t}function ka(e){let t={},n=x(e,[`candidatesTokenCount`]);n!=null&&b(t,[`responseTokenCount`],n);let r=x(e,[`candidatesTokensDetails`]);if(r!=null){let e=r;Array.isArray(e)&&(e=e.map(e=>e)),b(t,[`responseTokensDetails`],e)}let i=x(e,[`cacheTokensDetails`]);if(i!=null){let e=i;Array.isArray(e)&&(e=e.map(e=>e)),b(t,[`cacheTokensDetails`],e)}let a=x(e,[`cachedContentTokenCount`]);a!=null&&b(t,[`cachedContentTokenCount`],a);let o=x(e,[`promptTokenCount`]);o!=null&&b(t,[`promptTokenCount`],o);let s=x(e,[`promptTokensDetails`]);if(s!=null){let e=s;Array.isArray(e)&&(e=e.map(e=>e)),b(t,[`promptTokensDetails`],e)}let c=x(e,[`thoughtsTokenCount`]);c!=null&&b(t,[`thoughtsTokenCount`],c);let l=x(e,[`toolUsePromptTokenCount`]);l!=null&&b(t,[`toolUsePromptTokenCount`],l);let u=x(e,[`toolUsePromptTokensDetails`]);if(u!=null){let e=u;Array.isArray(e)&&(e=e.map(e=>e)),b(t,[`toolUsePromptTokensDetails`],e)}let d=x(e,[`totalTokenCount`]);d!=null&&b(t,[`totalTokenCount`],d);let f=x(e,[`trafficType`]);return f!=null&&b(t,[`trafficType`],f),t}function Aa(e){let t={},n=x(e,[`type`]);n!=null&&b(t,[`voiceActivityType`],n);let r=x(e,[`audioOffset`]);return r!=null&&b(t,[`audioOffset`],r),t}function ja(e){let t={},n=x(e,[`replicatedVoiceConfig`]);n!=null&&b(t,[`replicatedVoiceConfig`],Sa(n));let r=x(e,[`prebuiltVoiceConfig`]);return r!=null&&b(t,[`prebuiltVoiceConfig`],r),t}function Ma(e,t){let n={},r=x(e,[`apiKey`]);if(r!=null&&b(n,[`apiKey`],r),x(e,[`apiKeyConfig`])!==void 0)throw Error(`apiKeyConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);if(x(e,[`authType`])!==void 0)throw Error(`authType parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);if(x(e,[`googleServiceAccountConfig`])!==void 0)throw Error(`googleServiceAccountConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);if(x(e,[`httpBasicAuthConfig`])!==void 0)throw Error(`httpBasicAuthConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);if(x(e,[`oauthConfig`])!==void 0)throw Error(`oauthConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);if(x(e,[`oidcConfig`])!==void 0)throw Error(`oidcConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);return n}function Na(e,t){let n={},r=x(e,[`data`]);if(r!=null&&b(n,[`data`],r),x(e,[`displayName`])!==void 0)throw Error(`displayName parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);let i=x(e,[`mimeType`]);return i!=null&&b(n,[`mimeType`],i),n}function Pa(e,t){let n={},r=x(e,[`content`]);r!=null&&b(n,[`content`],r);let i=x(e,[`citationMetadata`]);i!=null&&b(n,[`citationMetadata`],Fa(i));let a=x(e,[`tokenCount`]);a!=null&&b(n,[`tokenCount`],a);let o=x(e,[`finishReason`]);o!=null&&b(n,[`finishReason`],o);let s=x(e,[`groundingMetadata`]);s!=null&&b(n,[`groundingMetadata`],s);let c=x(e,[`avgLogprobs`]);c!=null&&b(n,[`avgLogprobs`],c);let l=x(e,[`index`]);l!=null&&b(n,[`index`],l);let u=x(e,[`logprobsResult`]);u!=null&&b(n,[`logprobsResult`],u);let d=x(e,[`safetyRatings`]);if(d!=null){let e=d;Array.isArray(e)&&(e=e.map(e=>e)),b(n,[`safetyRatings`],e)}let f=x(e,[`urlContextMetadata`]);return f!=null&&b(n,[`urlContextMetadata`],f),n}function Fa(e,t){let n={},r=x(e,[`citationSources`]);if(r!=null){let e=r;Array.isArray(e)&&(e=e.map(e=>e)),b(n,[`citations`],e)}return n}function Ia(e,t,n){let r={},i=x(t,[`model`]);i!=null&&b(r,[`_url`,`model`],M(e,i));let a=x(t,[`contents`]);if(a!=null){let e=P(a);Array.isArray(e)&&(e=e.map(e=>Ha(e))),b(r,[`contents`],e)}return r}function La(e,t){let n={},r=x(e,[`sdkHttpResponse`]);r!=null&&b(n,[`sdkHttpResponse`],r);let i=x(e,[`tokensInfo`]);if(i!=null){let e=i;Array.isArray(e)&&(e=e.map(e=>e)),b(n,[`tokensInfo`],e)}return n}function Ra(e,t){let n={},r=x(e,[`enablePromptInjectionDetection`]);r!=null&&b(n,[`enablePromptInjectionDetection`],r);let i=x(e,[`environment`]);i!=null&&b(n,[`environment`],i);let a=x(e,[`excludedPredefinedFunctions`]);if(a!=null&&b(n,[`excludedPredefinedFunctions`],a),x(e,[`disabledSafetyPolicies`])!==void 0)throw Error(`disabledSafetyPolicies parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.`);return n}function za(e,t){let n={},r=x(e,[`values`]);r!=null&&b(n,[`values`],r);let i=x(e,[`statistics`]);return i!=null&&b(n,[`statistics`],Ba(i)),n}function Ba(e,t){let n={},r=x(e,[`truncated`]);r!=null&&b(n,[`truncated`],r);let i=x(e,[`token_count`]);i!=null&&b(n,[`tokenCount`],i);let a=x(e,[`tokensDetails`]);if(a!=null){let e=a;Array.isArray(e)&&(e=e.map(e=>e)),b(n,[`tokensDetails`],e)}return n}function Va(e,t){let n={},r=x(e,[`parts`]);if(r!=null){let e=r;Array.isArray(e)&&(e=e.map(e=>rs(e))),b(n,[`parts`],e)}let i=x(e,[`role`]);return i!=null&&b(n,[`role`],i),n}function Ha(e,t){let n={},r=x(e,[`parts`]);if(r!=null){let e=r;Array.isArray(e)&&(e=e.map(e=>is(e))),b(n,[`parts`],e)}let i=x(e,[`role`]);return i!=null&&b(n,[`role`],i),n}function Ua(e,t){let n={},r=x(e,[`controlType`]);r!=null&&b(n,[`controlType`],r);let i=x(e,[`enableControlImageComputation`]);return i!=null&&b(n,[`computeControl`],i),n}function Wa(e,t){let n={};if(x(e,[`systemInstruction`])!==void 0)throw Error(`systemInstruction parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);if(x(e,[`tools`])!==void 0)throw Error(`tools parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);if(x(e,[`generationConfig`])!==void 0)throw Error(`generationConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);return n}function Ga(e,t,n){let r={},i=x(e,[`systemInstruction`]);t!==void 0&&i!=null&&b(t,[`systemInstruction`],Ha(N(i)));let a=x(e,[`tools`]);if(t!==void 0&&a!=null){let e=a;Array.isArray(e)&&(e=e.map(e=>ws(e))),b(t,[`tools`],e)}let o=x(e,[`generationConfig`]);return t!==void 0&&o!=null&&b(t,[`generationConfig`],Lo(o)),r}function Ka(e,t,n){let r={},i=x(t,[`model`]);i!=null&&b(r,[`_url`,`model`],M(e,i));let a=x(t,[`contents`]);if(a!=null){let e=P(a);Array.isArray(e)&&(e=e.map(e=>Va(e))),b(r,[`contents`],e)}let o=x(t,[`config`]);return o!=null&&Wa(o),r}function qa(e,t,n){let r={},i=x(t,[`model`]);i!=null&&b(r,[`_url`,`model`],M(e,i));let a=x(t,[`contents`]);if(a!=null){let e=P(a);Array.isArray(e)&&(e=e.map(e=>Ha(e))),b(r,[`contents`],e)}let o=x(t,[`config`]);return o!=null&&Ga(o,r),r}function Ja(e,t){let n={},r=x(e,[`sdkHttpResponse`]);r!=null&&b(n,[`sdkHttpResponse`],r);let i=x(e,[`totalTokens`]);i!=null&&b(n,[`totalTokens`],i);let a=x(e,[`cachedContentTokenCount`]);return a!=null&&b(n,[`cachedContentTokenCount`],a),n}function Ya(e,t){let n={},r=x(e,[`sdkHttpResponse`]);r!=null&&b(n,[`sdkHttpResponse`],r);let i=x(e,[`totalTokens`]);return i!=null&&b(n,[`totalTokens`],i),n}function Xa(e,t,n){let r={},i=x(t,[`model`]);return i!=null&&b(r,[`_url`,`name`],M(e,i)),r}function Za(e,t,n){let r={},i=x(t,[`model`]);return i!=null&&b(r,[`_url`,`name`],M(e,i)),r}function Qa(e,t){let n={},r=x(e,[`sdkHttpResponse`]);return r!=null&&b(n,[`sdkHttpResponse`],r),n}function $a(e,t){let n={},r=x(e,[`sdkHttpResponse`]);return r!=null&&b(n,[`sdkHttpResponse`],r),n}function eo(e,t,n){let r={},i=x(e,[`outputGcsUri`]);t!==void 0&&i!=null&&b(t,[`parameters`,`storageUri`],i);let a=x(e,[`negativePrompt`]);t!==void 0&&a!=null&&b(t,[`parameters`,`negativePrompt`],a);let o=x(e,[`numberOfImages`]);t!==void 0&&o!=null&&b(t,[`parameters`,`sampleCount`],o);let s=x(e,[`aspectRatio`]);t!==void 0&&s!=null&&b(t,[`parameters`,`aspectRatio`],s);let c=x(e,[`guidanceScale`]);t!==void 0&&c!=null&&b(t,[`parameters`,`guidanceScale`],c);let l=x(e,[`seed`]);t!==void 0&&l!=null&&b(t,[`parameters`,`seed`],l);let u=x(e,[`safetyFilterLevel`]);t!==void 0&&u!=null&&b(t,[`parameters`,`safetySetting`],u);let d=x(e,[`personGeneration`]);t!==void 0&&d!=null&&b(t,[`parameters`,`personGeneration`],d);let f=x(e,[`includeSafetyAttributes`]);t!==void 0&&f!=null&&b(t,[`parameters`,`includeSafetyAttributes`],f);let p=x(e,[`includeRaiReason`]);t!==void 0&&p!=null&&b(t,[`parameters`,`includeRaiReason`],p);let m=x(e,[`language`]);t!==void 0&&m!=null&&b(t,[`parameters`,`language`],m);let h=x(e,[`outputMimeType`]);t!==void 0&&h!=null&&b(t,[`parameters`,`outputOptions`,`mimeType`],h);let g=x(e,[`outputCompressionQuality`]);t!==void 0&&g!=null&&b(t,[`parameters`,`outputOptions`,`compressionQuality`],g);let _=x(e,[`addWatermark`]);t!==void 0&&_!=null&&b(t,[`parameters`,`addWatermark`],_);let v=x(e,[`labels`]);t!==void 0&&v!=null&&b(t,[`labels`],v);let y=x(e,[`editMode`]);t!==void 0&&y!=null&&b(t,[`parameters`,`editMode`],y);let S=x(e,[`baseSteps`]);return t!==void 0&&S!=null&&b(t,[`parameters`,`editConfig`,`baseSteps`],S),r}function to(e,t,n){let r={},i=x(t,[`model`]);i!=null&&b(r,[`_url`,`model`],M(e,i));let a=x(t,[`prompt`]);a!=null&&b(r,[`instances[0]`,`prompt`],a);let o=x(t,[`referenceImages`]);if(o!=null){let e=o;Array.isArray(e)&&(e=e.map(e=>us(e))),b(r,[`instances[0]`,`referenceImages`],e)}let s=x(t,[`config`]);return s!=null&&eo(s,r),r}function no(e,t){let n={},r=x(e,[`sdkHttpResponse`]);r!=null&&b(n,[`sdkHttpResponse`],r);let i=x(e,[`predictions`]);if(i!=null){let e=i;Array.isArray(e)&&(e=e.map(e=>No(e))),b(n,[`generatedImages`],e)}return n}function ro(e,t,n){let r={},i=x(e,[`taskType`]);t!==void 0&&i!=null&&b(t,[`requests[]`,`taskType`],i);let a=x(e,[`title`]);t!==void 0&&a!=null&&b(t,[`requests[]`,`title`],a);let o=x(e,[`outputDimensionality`]);if(t!==void 0&&o!=null&&b(t,[`requests[]`,`outputDimensionality`],o),x(e,[`mimeType`])!==void 0)throw Error(`mimeType parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);if(x(e,[`autoTruncate`])!==void 0)throw Error(`autoTruncate parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);if(x(e,[`documentOcr`])!==void 0)throw Error(`documentOcr parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);if(x(e,[`audioTrackExtraction`])!==void 0)throw Error(`audioTrackExtraction parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);return r}function io(e,t,n){let r={},i=x(n,[`embeddingApiType`]);if(i===void 0&&(i=`PREDICT`),i===`PREDICT`){let n=x(e,[`taskType`]);t!==void 0&&n!=null&&b(t,[`instances[]`,`task_type`],n)}else if(i===`EMBED_CONTENT`){let n=x(e,[`taskType`]);t!==void 0&&n!=null&&b(t,[`embedContentConfig`,`taskType`],n)}let a=x(n,[`embeddingApiType`]);if(a===void 0&&(a=`PREDICT`),a===`PREDICT`){let n=x(e,[`title`]);t!==void 0&&n!=null&&b(t,[`instances[]`,`title`],n)}else if(a===`EMBED_CONTENT`){let n=x(e,[`title`]);t!==void 0&&n!=null&&b(t,[`embedContentConfig`,`title`],n)}let o=x(n,[`embeddingApiType`]);if(o===void 0&&(o=`PREDICT`),o===`PREDICT`){let n=x(e,[`outputDimensionality`]);t!==void 0&&n!=null&&b(t,[`parameters`,`outputDimensionality`],n)}else if(o===`EMBED_CONTENT`){let n=x(e,[`outputDimensionality`]);t!==void 0&&n!=null&&b(t,[`embedContentConfig`,`outputDimensionality`],n)}let s=x(n,[`embeddingApiType`]);if(s===void 0&&(s=`PREDICT`),s===`PREDICT`){let n=x(e,[`mimeType`]);t!==void 0&&n!=null&&b(t,[`instances[]`,`mimeType`],n)}let c=x(n,[`embeddingApiType`]);if(c===void 0&&(c=`PREDICT`),c===`PREDICT`){let n=x(e,[`autoTruncate`]);t!==void 0&&n!=null&&b(t,[`parameters`,`autoTruncate`],n)}else if(c===`EMBED_CONTENT`){let n=x(e,[`autoTruncate`]);t!==void 0&&n!=null&&b(t,[`embedContentConfig`,`autoTruncate`],n)}let l=x(n,[`embeddingApiType`]);if(l===void 0&&(l=`PREDICT`),l===`EMBED_CONTENT`){let n=x(e,[`documentOcr`]);t!==void 0&&n!=null&&b(t,[`embedContentConfig`,`documentOcr`],n)}let u=x(n,[`embeddingApiType`]);if(u===void 0&&(u=`PREDICT`),u===`EMBED_CONTENT`){let n=x(e,[`audioTrackExtraction`]);t!==void 0&&n!=null&&b(t,[`embedContentConfig`,`audioTrackExtraction`],n)}return r}function ao(e,t,n){let r={},i=x(t,[`model`]);i!=null&&b(r,[`_url`,`model`],M(e,i));let a=x(t,[`contents`]);if(a!=null){let t=yn(e,a);Array.isArray(t)&&(t=t.map(e=>e)),b(r,[`requests[]`,`content`],t)}let o=x(t,[`content`]);o!=null&&Va(N(o));let s=x(t,[`config`]);s!=null&&ro(s,r);let c=x(t,[`model`]);return c!==void 0&&b(r,[`requests[]`,`model`],M(e,c)),r}function oo(e,t,n){let r={},i=x(t,[`model`]);i!=null&&b(r,[`_url`,`model`],M(e,i));let a=x(n,[`embeddingApiType`]);if(a===void 0&&(a=`PREDICT`),a===`PREDICT`){let n=x(t,[`contents`]);if(n!=null){let t=yn(e,n);Array.isArray(t)&&(t=t.map(e=>e)),b(r,[`instances[]`,`content`],t)}}let o=x(n,[`embeddingApiType`]);if(o===void 0&&(o=`PREDICT`),o===`EMBED_CONTENT`){let e=x(t,[`content`]);e!=null&&b(r,[`content`],Ha(N(e)))}let s=x(t,[`config`]);return s!=null&&io(s,r,n),r}function so(e,t){let n={},r=x(e,[`sdkHttpResponse`]);r!=null&&b(n,[`sdkHttpResponse`],r);let i=x(e,[`embeddings`]);if(i!=null){let e=i;Array.isArray(e)&&(e=e.map(e=>e)),b(n,[`embeddings`],e)}let a=x(e,[`metadata`]);return a!=null&&b(n,[`metadata`],a),n}function co(e,t){let n={},r=x(e,[`sdkHttpResponse`]);r!=null&&b(n,[`sdkHttpResponse`],r);let i=x(e,[`predictions[]`,`embeddings`]);if(i!=null){let e=i;Array.isArray(e)&&(e=e.map(e=>za(e))),b(n,[`embeddings`],e)}let a=x(e,[`metadata`]);if(a!=null&&b(n,[`metadata`],a),t&&x(t,[`embeddingApiType`])===`EMBED_CONTENT`){let t=x(e,[`embedding`]),r=x(e,[`usageMetadata`]),i=x(e,[`truncated`]);if(t){let e={};r&&r.promptTokenCount&&(e.tokenCount=r.promptTokenCount),r&&r.promptTokensDetails&&(e.tokensDetails=r.promptTokensDetails),i&&(e.truncated=i),t.statistics=e,b(n,[`embeddings`],[t])}}return n}function lo(e,t){let n={},r=x(e,[`endpoint`]);r!=null&&b(n,[`name`],r);let i=x(e,[`deployedModelId`]);return i!=null&&b(n,[`deployedModelId`],i),n}function uo(e,t){let n={};if(x(e,[`displayName`])!==void 0)throw Error(`displayName parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);let r=x(e,[`fileUri`]);r!=null&&b(n,[`fileUri`],r);let i=x(e,[`mimeType`]);return i!=null&&b(n,[`mimeType`],i),n}function fo(e,t){let n={},r=x(e,[`args`]);r!=null&&b(n,[`args`],r);let i=x(e,[`id`]);i!=null&&b(n,[`id`],i);let a=x(e,[`name`]);if(a!=null&&b(n,[`name`],a),x(e,[`partialArgs`])!==void 0)throw Error(`partialArgs parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);if(x(e,[`willContinue`])!==void 0)throw Error(`willContinue parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);return n}function po(e,t){let n={},r=x(e,[`allowedFunctionNames`]);r!=null&&b(n,[`allowedFunctionNames`],r);let i=x(e,[`mode`]);if(i!=null&&b(n,[`mode`],i),x(e,[`streamFunctionCallArguments`])!==void 0)throw Error(`streamFunctionCallArguments parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);return n}function mo(e,t,n,r){let i={},a=x(t,[`serviceTier`]);n!==void 0&&a!=null&&b(n,[`serviceTier`],a);let o=x(t,[`systemInstruction`]);n!==void 0&&o!=null&&b(n,[`systemInstruction`],Va(N(o)));let s=x(t,[`temperature`]);s!=null&&b(i,[`temperature`],s);let c=x(t,[`topP`]);c!=null&&b(i,[`topP`],c);let l=x(t,[`topK`]);l!=null&&b(i,[`topK`],l);let u=x(t,[`candidateCount`]);u!=null&&b(i,[`candidateCount`],u);let d=x(t,[`maxOutputTokens`]);d!=null&&b(i,[`maxOutputTokens`],d);let f=x(t,[`stopSequences`]);f!=null&&b(i,[`stopSequences`],f);let p=x(t,[`responseLogprobs`]);p!=null&&b(i,[`responseLogprobs`],p);let m=x(t,[`logprobs`]);m!=null&&b(i,[`logprobs`],m);let h=x(t,[`presencePenalty`]);h!=null&&b(i,[`presencePenalty`],h);let g=x(t,[`frequencyPenalty`]);g!=null&&b(i,[`frequencyPenalty`],g);let _=x(t,[`seed`]);_!=null&&b(i,[`seed`],_);let v=x(t,[`responseMimeType`]);v!=null&&b(i,[`responseMimeType`],v);let y=x(t,[`responseSchema`]);y!=null&&b(i,[`responseSchema`],Sn(y));let S=x(t,[`responseJsonSchema`]);if(S!=null&&b(i,[`responseJsonSchema`],Cn(S)),x(t,[`routingConfig`])!==void 0)throw Error(`routingConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);if(x(t,[`modelSelectionConfig`])!==void 0)throw Error(`modelSelectionConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);let C=x(t,[`safetySettings`]);if(n!==void 0&&C!=null){let e=C;Array.isArray(e)&&(e=e.map(e=>ps(e))),b(n,[`safetySettings`],e)}let w=x(t,[`tools`]);if(n!==void 0&&w!=null){let e=Dn(w);Array.isArray(e)&&(e=e.map(e=>Cs(En(e)))),b(n,[`tools`],e)}let T=x(t,[`toolConfig`]);if(n!==void 0&&T!=null&&b(n,[`toolConfig`],xs(T)),x(t,[`labels`])!==void 0)throw Error(`labels parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);let E=x(t,[`cachedContent`]);n!==void 0&&E!=null&&b(n,[`cachedContent`],kn(e,E));let D=x(t,[`responseModalities`]);D!=null&&b(i,[`responseModalities`],D);let O=x(t,[`mediaResolution`]);O!=null&&b(i,[`mediaResolution`],O);let k=x(t,[`speechConfig`]);if(k!=null&&b(i,[`speechConfig`],wn(k)),x(t,[`audioTimestamp`])!==void 0)throw Error(`audioTimestamp parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);let A=x(t,[`thinkingConfig`]);A!=null&&b(i,[`thinkingConfig`],A);let ee=x(t,[`audioTranscriptionConfig`]);ee!=null&&b(i,[`audioTranscriptionConfig`],ee);let te=x(t,[`imageConfig`]);te!=null&&b(i,[`imageConfig`],Ho(te));let ne=x(t,[`enableEnhancedCivicAnswers`]);if(ne!=null&&b(i,[`enableEnhancedCivicAnswers`],ne),x(t,[`modelArmorConfig`])!==void 0)throw Error(`modelArmorConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);return i}function ho(e,t,n,r){let i={},a=x(t,[`serviceTier`]);n!==void 0&&a!=null&&b(n,[`serviceTier`],a);let o=x(t,[`systemInstruction`]);n!==void 0&&o!=null&&b(n,[`systemInstruction`],Ha(N(o)));let s=x(t,[`temperature`]);s!=null&&b(i,[`temperature`],s);let c=x(t,[`topP`]);c!=null&&b(i,[`topP`],c);let l=x(t,[`topK`]);l!=null&&b(i,[`topK`],l);let u=x(t,[`candidateCount`]);u!=null&&b(i,[`candidateCount`],u);let d=x(t,[`maxOutputTokens`]);d!=null&&b(i,[`maxOutputTokens`],d);let f=x(t,[`stopSequences`]);f!=null&&b(i,[`stopSequences`],f);let p=x(t,[`responseLogprobs`]);p!=null&&b(i,[`responseLogprobs`],p);let m=x(t,[`logprobs`]);m!=null&&b(i,[`logprobs`],m);let h=x(t,[`presencePenalty`]);h!=null&&b(i,[`presencePenalty`],h);let g=x(t,[`frequencyPenalty`]);g!=null&&b(i,[`frequencyPenalty`],g);let _=x(t,[`seed`]);_!=null&&b(i,[`seed`],_);let v=x(t,[`responseMimeType`]);v!=null&&b(i,[`responseMimeType`],v);let y=x(t,[`responseSchema`]);y!=null&&b(i,[`responseSchema`],Sn(y));let S=x(t,[`responseJsonSchema`]);S!=null&&b(i,[`responseJsonSchema`],Cn(S));let C=x(t,[`routingConfig`]);C!=null&&b(i,[`routingConfig`],C);let w=x(t,[`modelSelectionConfig`]);w!=null&&b(i,[`modelConfig`],w);let T=x(t,[`safetySettings`]);if(n!==void 0&&T!=null){let e=T;Array.isArray(e)&&(e=e.map(e=>e)),b(n,[`safetySettings`],e)}let E=x(t,[`tools`]);if(n!==void 0&&E!=null){let e=Dn(E);Array.isArray(e)&&(e=e.map(e=>ws(En(e)))),b(n,[`tools`],e)}let D=x(t,[`toolConfig`]);n!==void 0&&D!=null&&b(n,[`toolConfig`],Ss(D));let O=x(t,[`labels`]);n!==void 0&&O!=null&&b(n,[`labels`],O);let k=x(t,[`cachedContent`]);n!==void 0&&k!=null&&b(n,[`cachedContent`],kn(e,k));let A=x(t,[`responseModalities`]);A!=null&&b(i,[`responseModalities`],A);let ee=x(t,[`mediaResolution`]);ee!=null&&b(i,[`mediaResolution`],ee);let te=x(t,[`speechConfig`]);te!=null&&b(i,[`speechConfig`],bs(wn(te)));let ne=x(t,[`audioTimestamp`]);ne!=null&&b(i,[`audioTimestamp`],ne);let re=x(t,[`thinkingConfig`]);re!=null&&b(i,[`thinkingConfig`],re);let ie=x(t,[`audioTranscriptionConfig`]);ie!=null&&b(i,[`audioTranscriptionConfig`],ie);let ae=x(t,[`imageConfig`]);if(ae!=null&&b(i,[`imageConfig`],Uo(ae)),x(t,[`enableEnhancedCivicAnswers`])!==void 0)throw Error(`enableEnhancedCivicAnswers parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.`);let oe=x(t,[`modelArmorConfig`]);return n!==void 0&&oe!=null&&b(n,[`modelArmorConfig`],oe),i}function go(e,t,n){let r={},i=x(t,[`model`]);i!=null&&b(r,[`_url`,`model`],M(e,i));let a=x(t,[`contents`]);if(a!=null){let e=P(a);Array.isArray(e)&&(e=e.map(e=>Va(e))),b(r,[`contents`],e)}let o=x(t,[`config`]);return o!=null&&b(r,[`generationConfig`],mo(e,o,r)),r}function _o(e,t,n){let r={},i=x(t,[`model`]);i!=null&&b(r,[`_url`,`model`],M(e,i));let a=x(t,[`contents`]);if(a!=null){let e=P(a);Array.isArray(e)&&(e=e.map(e=>Ha(e))),b(r,[`contents`],e)}let o=x(t,[`config`]);return o!=null&&b(r,[`generationConfig`],ho(e,o,r)),r}function vo(e,t){let n={},r=x(e,[`sdkHttpResponse`]);r!=null&&b(n,[`sdkHttpResponse`],r);let i=x(e,[`candidates`]);if(i!=null){let e=i;Array.isArray(e)&&(e=e.map(e=>Pa(e))),b(n,[`candidates`],e)}let a=x(e,[`modelVersion`]);a!=null&&b(n,[`modelVersion`],a);let o=x(e,[`promptFeedback`]);o!=null&&b(n,[`promptFeedback`],o);let s=x(e,[`responseId`]);s!=null&&b(n,[`responseId`],s);let c=x(e,[`usageMetadata`]);c!=null&&b(n,[`usageMetadata`],c);let l=x(e,[`modelStatus`]);return l!=null&&b(n,[`modelStatus`],l),n}function yo(e,t){let n={},r=x(e,[`sdkHttpResponse`]);r!=null&&b(n,[`sdkHttpResponse`],r);let i=x(e,[`candidates`]);if(i!=null){let e=i;Array.isArray(e)&&(e=e.map(e=>e)),b(n,[`candidates`],e)}let a=x(e,[`createTime`]);a!=null&&b(n,[`createTime`],a);let o=x(e,[`modelVersion`]);o!=null&&b(n,[`modelVersion`],o);let s=x(e,[`promptFeedback`]);s!=null&&b(n,[`promptFeedback`],s);let c=x(e,[`responseId`]);c!=null&&b(n,[`responseId`],c);let l=x(e,[`usageMetadata`]);return l!=null&&b(n,[`usageMetadata`],l),n}function bo(e,t,n){let r={},i=x(e,[`outputGcsUri`]);t!==void 0&&i!=null&&b(t,[`parameters`,`storageUri`],i);let a=x(e,[`negativePrompt`]);t!==void 0&&a!=null&&b(t,[`parameters`,`negativePrompt`],a);let o=x(e,[`numberOfImages`]);t!==void 0&&o!=null&&b(t,[`parameters`,`sampleCount`],o);let s=x(e,[`aspectRatio`]);t!==void 0&&s!=null&&b(t,[`parameters`,`aspectRatio`],s);let c=x(e,[`guidanceScale`]);t!==void 0&&c!=null&&b(t,[`parameters`,`guidanceScale`],c);let l=x(e,[`seed`]);t!==void 0&&l!=null&&b(t,[`parameters`,`seed`],l);let u=x(e,[`safetyFilterLevel`]);t!==void 0&&u!=null&&b(t,[`parameters`,`safetySetting`],u);let d=x(e,[`personGeneration`]);t!==void 0&&d!=null&&b(t,[`parameters`,`personGeneration`],d);let f=x(e,[`includeSafetyAttributes`]);t!==void 0&&f!=null&&b(t,[`parameters`,`includeSafetyAttributes`],f);let p=x(e,[`includeRaiReason`]);t!==void 0&&p!=null&&b(t,[`parameters`,`includeRaiReason`],p);let m=x(e,[`language`]);t!==void 0&&m!=null&&b(t,[`parameters`,`language`],m);let h=x(e,[`outputMimeType`]);t!==void 0&&h!=null&&b(t,[`parameters`,`outputOptions`,`mimeType`],h);let g=x(e,[`outputCompressionQuality`]);t!==void 0&&g!=null&&b(t,[`parameters`,`outputOptions`,`compressionQuality`],g);let _=x(e,[`addWatermark`]);t!==void 0&&_!=null&&b(t,[`parameters`,`addWatermark`],_);let v=x(e,[`labels`]);t!==void 0&&v!=null&&b(t,[`labels`],v);let y=x(e,[`imageSize`]);t!==void 0&&y!=null&&b(t,[`parameters`,`sampleImageSize`],y);let S=x(e,[`enhancePrompt`]);return t!==void 0&&S!=null&&b(t,[`parameters`,`enhancePrompt`],S),r}function xo(e,t,n){let r={},i=x(t,[`model`]);i!=null&&b(r,[`_url`,`model`],M(e,i));let a=x(t,[`prompt`]);a!=null&&b(r,[`instances[0]`,`prompt`],a);let o=x(t,[`config`]);return o!=null&&bo(o,r),r}function So(e,t){let n={},r=x(e,[`sdkHttpResponse`]);r!=null&&b(n,[`sdkHttpResponse`],r);let i=x(e,[`predictions`]);if(i!=null){let e=i;Array.isArray(e)&&(e=e.map(e=>No(e))),b(n,[`generatedImages`],e)}let a=x(e,[`positivePromptSafetyAttributes`]);return a!=null&&b(n,[`positivePromptSafetyAttributes`],fs(a)),n}function Co(e,t,n){let r={},i=x(e,[`numberOfVideos`]);if(t!==void 0&&i!=null&&b(t,[`parameters`,`sampleCount`],i),x(e,[`outputGcsUri`])!==void 0)throw Error(`outputGcsUri parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);if(x(e,[`fps`])!==void 0)throw Error(`fps parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);let a=x(e,[`durationSeconds`]);if(t!==void 0&&a!=null&&b(t,[`parameters`,`durationSeconds`],a),x(e,[`seed`])!==void 0)throw Error(`seed parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);let o=x(e,[`aspectRatio`]);t!==void 0&&o!=null&&b(t,[`parameters`,`aspectRatio`],o);let s=x(e,[`resolution`]);t!==void 0&&s!=null&&b(t,[`parameters`,`resolution`],s);let c=x(e,[`personGeneration`]);if(t!==void 0&&c!=null&&b(t,[`parameters`,`personGeneration`],c),x(e,[`pubsubTopic`])!==void 0)throw Error(`pubsubTopic parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);let l=x(e,[`negativePrompt`]);t!==void 0&&l!=null&&b(t,[`parameters`,`negativePrompt`],l);let u=x(e,[`enhancePrompt`]);if(t!==void 0&&u!=null&&b(t,[`parameters`,`enhancePrompt`],u),x(e,[`generateAudio`])!==void 0)throw Error(`generateAudio parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);let d=x(e,[`lastFrame`]);t!==void 0&&d!=null&&b(t,[`instances[0]`,`lastFrame`],Go(d));let f=x(e,[`referenceImages`]);if(t!==void 0&&f!=null){let e=f;Array.isArray(e)&&(e=e.map(e=>Ls(e))),b(t,[`instances[0]`,`referenceImages`],e)}if(x(e,[`mask`])!==void 0)throw Error(`mask parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);if(x(e,[`compressionQuality`])!==void 0)throw Error(`compressionQuality parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);if(x(e,[`labels`])!==void 0)throw Error(`labels parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);let p=x(e,[`webhookConfig`]);if(t!==void 0&&p!=null&&b(t,[`webhookConfig`],p),x(e,[`resizeMode`])!==void 0)throw Error(`resizeMode parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);return r}function wo(e,t,n){let r={},i=x(e,[`numberOfVideos`]);t!==void 0&&i!=null&&b(t,[`parameters`,`sampleCount`],i);let a=x(e,[`outputGcsUri`]);t!==void 0&&a!=null&&b(t,[`parameters`,`storageUri`],a);let o=x(e,[`fps`]);t!==void 0&&o!=null&&b(t,[`parameters`,`fps`],o);let s=x(e,[`durationSeconds`]);t!==void 0&&s!=null&&b(t,[`parameters`,`durationSeconds`],s);let c=x(e,[`seed`]);t!==void 0&&c!=null&&b(t,[`parameters`,`seed`],c);let l=x(e,[`aspectRatio`]);t!==void 0&&l!=null&&b(t,[`parameters`,`aspectRatio`],l);let u=x(e,[`resolution`]);t!==void 0&&u!=null&&b(t,[`parameters`,`resolution`],u);let d=x(e,[`personGeneration`]);t!==void 0&&d!=null&&b(t,[`parameters`,`personGeneration`],d);let f=x(e,[`pubsubTopic`]);t!==void 0&&f!=null&&b(t,[`parameters`,`pubsubTopic`],f);let p=x(e,[`negativePrompt`]);t!==void 0&&p!=null&&b(t,[`parameters`,`negativePrompt`],p);let m=x(e,[`enhancePrompt`]);t!==void 0&&m!=null&&b(t,[`parameters`,`enhancePrompt`],m);let h=x(e,[`generateAudio`]);t!==void 0&&h!=null&&b(t,[`parameters`,`generateAudio`],h);let g=x(e,[`lastFrame`]);t!==void 0&&g!=null&&b(t,[`instances[0]`,`lastFrame`],L(g));let _=x(e,[`referenceImages`]);if(t!==void 0&&_!=null){let e=_;Array.isArray(e)&&(e=e.map(e=>Rs(e))),b(t,[`instances[0]`,`referenceImages`],e)}let v=x(e,[`mask`]);t!==void 0&&v!=null&&b(t,[`instances[0]`,`mask`],Is(v));let y=x(e,[`compressionQuality`]);t!==void 0&&y!=null&&b(t,[`parameters`,`compressionQuality`],y);let S=x(e,[`labels`]);if(t!==void 0&&S!=null&&b(t,[`labels`],S),x(e,[`webhookConfig`])!==void 0)throw Error(`webhookConfig parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.`);let C=x(e,[`resizeMode`]);return t!==void 0&&C!=null&&b(t,[`parameters`,`resizeMode`],C),r}function To(e,t){let n={},r=x(e,[`name`]);r!=null&&b(n,[`name`],r);let i=x(e,[`metadata`]);i!=null&&b(n,[`metadata`],i);let a=x(e,[`done`]);a!=null&&b(n,[`done`],a);let o=x(e,[`error`]);o!=null&&b(n,[`error`],o);let s=x(e,[`response`,`generateVideoResponse`]);return s!=null&&b(n,[`response`],ko(s)),n}function Eo(e,t){let n={},r=x(e,[`name`]);r!=null&&b(n,[`name`],r);let i=x(e,[`metadata`]);i!=null&&b(n,[`metadata`],i);let a=x(e,[`done`]);a!=null&&b(n,[`done`],a);let o=x(e,[`error`]);o!=null&&b(n,[`error`],o);let s=x(e,[`response`]);return s!=null&&b(n,[`response`],Ao(s)),n}function Do(e,t,n){let r={},i=x(t,[`model`]);i!=null&&b(r,[`_url`,`model`],M(e,i));let a=x(t,[`prompt`]);a!=null&&b(r,[`instances[0]`,`prompt`],a);let o=x(t,[`image`]);o!=null&&b(r,[`instances[0]`,`image`],Go(o));let s=x(t,[`video`]);s!=null&&b(r,[`instances[0]`,`video`],zs(s));let c=x(t,[`source`]);c!=null&&jo(c,r);let l=x(t,[`config`]);return l!=null&&Co(l,r),r}function Oo(e,t,n){let r={},i=x(t,[`model`]);i!=null&&b(r,[`_url`,`model`],M(e,i));let a=x(t,[`prompt`]);a!=null&&b(r,[`instances[0]`,`prompt`],a);let o=x(t,[`image`]);o!=null&&b(r,[`instances[0]`,`image`],L(o));let s=x(t,[`video`]);s!=null&&b(r,[`instances[0]`,`video`],Bs(s));let c=x(t,[`source`]);c!=null&&Mo(c,r);let l=x(t,[`config`]);return l!=null&&wo(l,r),r}function ko(e,t){let n={},r=x(e,[`generatedSamples`]);if(r!=null){let e=r;Array.isArray(e)&&(e=e.map(e=>Fo(e))),b(n,[`generatedVideos`],e)}let i=x(e,[`raiMediaFilteredCount`]);i!=null&&b(n,[`raiMediaFilteredCount`],i);let a=x(e,[`raiMediaFilteredReasons`]);return a!=null&&b(n,[`raiMediaFilteredReasons`],a),n}function Ao(e,t){let n={},r=x(e,[`videos`]);if(r!=null){let e=r;Array.isArray(e)&&(e=e.map(e=>Io(e))),b(n,[`generatedVideos`],e)}let i=x(e,[`raiMediaFilteredCount`]);i!=null&&b(n,[`raiMediaFilteredCount`],i);let a=x(e,[`raiMediaFilteredReasons`]);return a!=null&&b(n,[`raiMediaFilteredReasons`],a),n}function jo(e,t,n){let r={},i=x(e,[`prompt`]);t!==void 0&&i!=null&&b(t,[`instances[0]`,`prompt`],i);let a=x(e,[`image`]);t!==void 0&&a!=null&&b(t,[`instances[0]`,`image`],Go(a));let o=x(e,[`video`]);return t!==void 0&&o!=null&&b(t,[`instances[0]`,`video`],zs(o)),r}function Mo(e,t,n){let r={},i=x(e,[`prompt`]);t!==void 0&&i!=null&&b(t,[`instances[0]`,`prompt`],i);let a=x(e,[`image`]);t!==void 0&&a!=null&&b(t,[`instances[0]`,`image`],L(a));let o=x(e,[`video`]);return t!==void 0&&o!=null&&b(t,[`instances[0]`,`video`],Bs(o)),r}function No(e,t){let n={},r=x(e,[`_self`]);r!=null&&b(n,[`image`],Wo(r));let i=x(e,[`raiFilteredReason`]);i!=null&&b(n,[`raiFilteredReason`],i);let a=x(e,[`_self`]);a!=null&&b(n,[`safetyAttributes`],fs(a));let o=x(e,[`prompt`]);return o!=null&&b(n,[`enhancedPrompt`],o),n}function Po(e,t){let n={},r=x(e,[`_self`]);r!=null&&b(n,[`mask`],Wo(r));let i=x(e,[`labels`]);if(i!=null){let e=i;Array.isArray(e)&&(e=e.map(e=>e)),b(n,[`labels`],e)}return n}function Fo(e,t){let n={},r=x(e,[`video`]);return r!=null&&b(n,[`video`],Ps(r)),n}function Io(e,t){let n={},r=x(e,[`_self`]);return r!=null&&b(n,[`video`],Fs(r)),n}function Lo(e,t){let n={},r=x(e,[`modelSelectionConfig`]);r!=null&&b(n,[`modelConfig`],r);let i=x(e,[`responseJsonSchema`]);i!=null&&b(n,[`responseJsonSchema`],Cn(i));let a=x(e,[`audioTranscriptionConfig`]);a!=null&&b(n,[`audioTranscriptionConfig`],a);let o=x(e,[`audioTimestamp`]);o!=null&&b(n,[`audioTimestamp`],o);let s=x(e,[`candidateCount`]);s!=null&&b(n,[`candidateCount`],s);let c=x(e,[`enableAffectiveDialog`]);c!=null&&b(n,[`enableAffectiveDialog`],c);let l=x(e,[`frequencyPenalty`]);l!=null&&b(n,[`frequencyPenalty`],l);let u=x(e,[`logprobs`]);u!=null&&b(n,[`logprobs`],u);let d=x(e,[`maxOutputTokens`]);d!=null&&b(n,[`maxOutputTokens`],d);let f=x(e,[`mediaResolution`]);f!=null&&b(n,[`mediaResolution`],f);let p=x(e,[`presencePenalty`]);p!=null&&b(n,[`presencePenalty`],p);let m=x(e,[`responseFormat`]);if(m!=null){let e=m;Array.isArray(e)&&(e=e.map(e=>e)),b(n,[`responseFormat`],e)}let h=x(e,[`responseLogprobs`]);h!=null&&b(n,[`responseLogprobs`],h);let g=x(e,[`responseMimeType`]);g!=null&&b(n,[`responseMimeType`],g);let _=x(e,[`responseModalities`]);_!=null&&b(n,[`responseModalities`],_);let v=x(e,[`responseSchema`]);v!=null&&b(n,[`responseSchema`],v);let y=x(e,[`routingConfig`]);y!=null&&b(n,[`routingConfig`],y);let S=x(e,[`seed`]);S!=null&&b(n,[`seed`],S);let C=x(e,[`speechConfig`]);C!=null&&b(n,[`speechConfig`],bs(C));let w=x(e,[`stopSequences`]);w!=null&&b(n,[`stopSequences`],w);let T=x(e,[`temperature`]);T!=null&&b(n,[`temperature`],T);let E=x(e,[`thinkingConfig`]);E!=null&&b(n,[`thinkingConfig`],E);let D=x(e,[`topK`]);D!=null&&b(n,[`topK`],D);let O=x(e,[`topP`]);if(O!=null&&b(n,[`topP`],O),x(e,[`enableEnhancedCivicAnswers`])!==void 0)throw Error(`enableEnhancedCivicAnswers parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.`);if(x(e,[`translationConfig`])!==void 0)throw Error(`translationConfig parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.`);return n}function Ro(e,t,n){let r={},i=x(t,[`model`]);return i!=null&&b(r,[`_url`,`name`],M(e,i)),r}function zo(e,t,n){let r={},i=x(t,[`model`]);return i!=null&&b(r,[`_url`,`name`],M(e,i)),r}function Bo(e,t){let n={},r=x(e,[`authConfig`]);r!=null&&b(n,[`authConfig`],Ma(r));let i=x(e,[`enableWidget`]);if(i!=null&&b(n,[`enableWidget`],i),x(e,[`groundingTypes`])!==void 0)throw Error(`groundingTypes parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);return n}function Vo(e,t){let n={};if(x(e,[`blockingConfidence`])!==void 0)throw Error(`blockingConfidence parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);if(x(e,[`excludeDomains`])!==void 0)throw Error(`excludeDomains parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);let r=x(e,[`searchTypes`]);r!=null&&b(n,[`searchTypes`],r);let i=x(e,[`timeRangeFilter`]);return i!=null&&b(n,[`timeRangeFilter`],i),n}function Ho(e,t){let n={},r=x(e,[`aspectRatio`]);r!=null&&b(n,[`aspectRatio`],r);let i=x(e,[`imageSize`]);if(i!=null&&b(n,[`imageSize`],i),x(e,[`personGeneration`])!==void 0)throw Error(`personGeneration parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);if(x(e,[`outputMimeType`])!==void 0)throw Error(`outputMimeType parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);if(x(e,[`outputCompressionQuality`])!==void 0)throw Error(`outputCompressionQuality parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);if(x(e,[`imageOutputOptions`])!==void 0)throw Error(`imageOutputOptions parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);if(x(e,[`prominentPeople`])!==void 0)throw Error(`prominentPeople parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);return n}function Uo(e,t){let n={},r=x(e,[`aspectRatio`]);r!=null&&b(n,[`aspectRatio`],r);let i=x(e,[`imageSize`]);i!=null&&b(n,[`imageSize`],i);let a=x(e,[`personGeneration`]);a!=null&&b(n,[`personGeneration`],a);let o=x(e,[`outputMimeType`]);o!=null&&b(n,[`imageOutputOptions`,`mimeType`],o);let s=x(e,[`outputCompressionQuality`]);s!=null&&b(n,[`imageOutputOptions`,`compressionQuality`],s);let c=x(e,[`imageOutputOptions`]);c!=null&&b(n,[`imageOutputOptions`],c);let l=x(e,[`prominentPeople`]);return l!=null&&b(n,[`prominentPeople`],l),n}function Wo(e,t){let n={},r=x(e,[`gcsUri`]);r!=null&&b(n,[`gcsUri`],r);let i=x(e,[`bytesBase64Encoded`]);i!=null&&b(n,[`imageBytes`],jn(i));let a=x(e,[`mimeType`]);return a!=null&&b(n,[`mimeType`],a),n}function Go(e,t){let n={};if(x(e,[`gcsUri`])!==void 0)throw Error(`gcsUri parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);let r=x(e,[`imageBytes`]);r!=null&&b(n,[`bytesBase64Encoded`],jn(r));let i=x(e,[`mimeType`]);return i!=null&&b(n,[`mimeType`],i),n}function L(e,t){let n={},r=x(e,[`gcsUri`]);r!=null&&b(n,[`gcsUri`],r);let i=x(e,[`imageBytes`]);i!=null&&b(n,[`bytesBase64Encoded`],jn(i));let a=x(e,[`mimeType`]);return a!=null&&b(n,[`mimeType`],a),n}function Ko(e,t,n,r){let i={},a=x(t,[`pageSize`]);n!==void 0&&a!=null&&b(n,[`_query`,`pageSize`],a);let o=x(t,[`pageToken`]);n!==void 0&&o!=null&&b(n,[`_query`,`pageToken`],o);let s=x(t,[`filter`]);n!==void 0&&s!=null&&b(n,[`_query`,`filter`],s);let c=x(t,[`queryBase`]);return n!==void 0&&c!=null&&b(n,[`_url`,`models_url`],In(e,c)),i}function qo(e,t,n,r){let i={},a=x(t,[`pageSize`]);n!==void 0&&a!=null&&b(n,[`_query`,`pageSize`],a);let o=x(t,[`pageToken`]);n!==void 0&&o!=null&&b(n,[`_query`,`pageToken`],o);let s=x(t,[`filter`]);n!==void 0&&s!=null&&b(n,[`_query`,`filter`],s);let c=x(t,[`queryBase`]);return n!==void 0&&c!=null&&b(n,[`_url`,`models_url`],In(e,c)),i}function Jo(e,t,n){let r={},i=x(t,[`config`]);return i!=null&&Ko(e,i,r),r}function Yo(e,t,n){let r={},i=x(t,[`config`]);return i!=null&&qo(e,i,r),r}function Xo(e,t){let n={},r=x(e,[`sdkHttpResponse`]);r!=null&&b(n,[`sdkHttpResponse`],r);let i=x(e,[`nextPageToken`]);i!=null&&b(n,[`nextPageToken`],i);let a=x(e,[`_self`]);if(a!=null){let e=Ln(a);Array.isArray(e)&&(e=e.map(e=>es(e))),b(n,[`models`],e)}return n}function Zo(e,t){let n={},r=x(e,[`sdkHttpResponse`]);r!=null&&b(n,[`sdkHttpResponse`],r);let i=x(e,[`nextPageToken`]);i!=null&&b(n,[`nextPageToken`],i);let a=x(e,[`_self`]);if(a!=null){let e=Ln(a);Array.isArray(e)&&(e=e.map(e=>ts(e))),b(n,[`models`],e)}return n}function Qo(e,t){let n={},r=x(e,[`maskMode`]);r!=null&&b(n,[`maskMode`],r);let i=x(e,[`segmentationClasses`]);i!=null&&b(n,[`maskClasses`],i);let a=x(e,[`maskDilation`]);return a!=null&&b(n,[`dilation`],a),n}function $o(e,t){let n={};if(x(e,[`name`])!==void 0)throw Error(`name parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.`);if(x(e,[`streamableHttpTransport`])!==void 0)throw Error(`streamableHttpTransport parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.`);return n}function es(e,t){let n={},r=x(e,[`name`]);r!=null&&b(n,[`name`],r);let i=x(e,[`displayName`]);i!=null&&b(n,[`displayName`],i);let a=x(e,[`description`]);a!=null&&b(n,[`description`],a);let o=x(e,[`version`]);o!=null&&b(n,[`version`],o);let s=x(e,[`_self`]);s!=null&&b(n,[`tunedModelInfo`],Ts(s));let c=x(e,[`inputTokenLimit`]);c!=null&&b(n,[`inputTokenLimit`],c);let l=x(e,[`outputTokenLimit`]);l!=null&&b(n,[`outputTokenLimit`],l);let u=x(e,[`supportedGenerationMethods`]);u!=null&&b(n,[`supportedActions`],u);let d=x(e,[`temperature`]);d!=null&&b(n,[`temperature`],d);let f=x(e,[`maxTemperature`]);f!=null&&b(n,[`maxTemperature`],f);let p=x(e,[`topP`]);p!=null&&b(n,[`topP`],p);let m=x(e,[`topK`]);m!=null&&b(n,[`topK`],m);let h=x(e,[`thinking`]);return h!=null&&b(n,[`thinking`],h),n}function ts(e,t){let n={},r=x(e,[`name`]);r!=null&&b(n,[`name`],r);let i=x(e,[`displayName`]);i!=null&&b(n,[`displayName`],i);let a=x(e,[`description`]);a!=null&&b(n,[`description`],a);let o=x(e,[`versionId`]);o!=null&&b(n,[`version`],o);let s=x(e,[`deployedModels`]);if(s!=null){let e=s;Array.isArray(e)&&(e=e.map(e=>lo(e))),b(n,[`endpoints`],e)}let c=x(e,[`labels`]);c!=null&&b(n,[`labels`],c);let l=x(e,[`_self`]);l!=null&&b(n,[`tunedModelInfo`],Es(l));let u=x(e,[`defaultCheckpointId`]);u!=null&&b(n,[`defaultCheckpointId`],u);let d=x(e,[`checkpoints`]);if(d!=null){let e=d;Array.isArray(e)&&(e=e.map(e=>e)),b(n,[`checkpoints`],e)}return n}function ns(e,t){let n={},r=x(e,[`speakerVoiceConfigs`]);if(r!=null){let e=r;Array.isArray(e)&&(e=e.map(e=>ys(e))),b(n,[`speakerVoiceConfigs`],e)}return n}function rs(e,t){let n={},r=x(e,[`mediaResolution`]);r!=null&&b(n,[`mediaResolution`],r);let i=x(e,[`toolCall`]);i!=null&&b(n,[`toolCall`],i);let a=x(e,[`toolResponse`]);a!=null&&b(n,[`toolResponse`],a);let o=x(e,[`audioTranscription`]);o!=null&&b(n,[`audioTranscription`],o);let s=x(e,[`codeExecutionResult`]);s!=null&&b(n,[`codeExecutionResult`],s);let c=x(e,[`executableCode`]);c!=null&&b(n,[`executableCode`],c);let l=x(e,[`fileData`]);l!=null&&b(n,[`fileData`],uo(l));let u=x(e,[`functionCall`]);u!=null&&b(n,[`functionCall`],fo(u));let d=x(e,[`functionResponse`]);d!=null&&b(n,[`functionResponse`],d);let f=x(e,[`inlineData`]);f!=null&&b(n,[`inlineData`],Na(f));let p=x(e,[`text`]);p!=null&&b(n,[`text`],p);let m=x(e,[`thought`]);m!=null&&b(n,[`thought`],m);let h=x(e,[`thoughtSignature`]);h!=null&&b(n,[`thoughtSignature`],h);let g=x(e,[`videoMetadata`]);g!=null&&b(n,[`videoMetadata`],g);let _=x(e,[`partMetadata`]);_!=null&&b(n,[`partMetadata`],_);let v=x(e,[`mediaProcessing`]);return v!=null&&b(n,[`mediaProcessing`],v),n}function is(e,t){let n={},r=x(e,[`mediaResolution`]);if(r!=null&&b(n,[`mediaResolution`],r),x(e,[`toolCall`])!==void 0)throw Error(`toolCall parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.`);if(x(e,[`toolResponse`])!==void 0)throw Error(`toolResponse parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.`);let i=x(e,[`audioTranscription`]);i!=null&&b(n,[`audioTranscription`],i);let a=x(e,[`codeExecutionResult`]);a!=null&&b(n,[`codeExecutionResult`],a);let o=x(e,[`executableCode`]);o!=null&&b(n,[`executableCode`],o);let s=x(e,[`fileData`]);s!=null&&b(n,[`fileData`],s);let c=x(e,[`functionCall`]);c!=null&&b(n,[`functionCall`],c);let l=x(e,[`functionResponse`]);l!=null&&b(n,[`functionResponse`],l);let u=x(e,[`inlineData`]);u!=null&&b(n,[`inlineData`],u);let d=x(e,[`text`]);d!=null&&b(n,[`text`],d);let f=x(e,[`thought`]);f!=null&&b(n,[`thought`],f);let p=x(e,[`thoughtSignature`]);p!=null&&b(n,[`thoughtSignature`],p);let m=x(e,[`videoMetadata`]);if(m!=null&&b(n,[`videoMetadata`],m),x(e,[`partMetadata`])!==void 0)throw Error(`partMetadata parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.`);let h=x(e,[`mediaProcessing`]);return h!=null&&b(n,[`mediaProcessing`],h),n}function as(e,t){let n={},r=x(e,[`productImage`]);return r!=null&&b(n,[`image`],L(r)),n}function os(e,t,n){let r={},i=x(e,[`numberOfImages`]);t!==void 0&&i!=null&&b(t,[`parameters`,`sampleCount`],i);let a=x(e,[`baseSteps`]);t!==void 0&&a!=null&&b(t,[`parameters`,`baseSteps`],a);let o=x(e,[`outputGcsUri`]);t!==void 0&&o!=null&&b(t,[`parameters`,`storageUri`],o);let s=x(e,[`seed`]);t!==void 0&&s!=null&&b(t,[`parameters`,`seed`],s);let c=x(e,[`safetyFilterLevel`]);t!==void 0&&c!=null&&b(t,[`parameters`,`safetySetting`],c);let l=x(e,[`personGeneration`]);t!==void 0&&l!=null&&b(t,[`parameters`,`personGeneration`],l);let u=x(e,[`addWatermark`]);t!==void 0&&u!=null&&b(t,[`parameters`,`addWatermark`],u);let d=x(e,[`outputMimeType`]);t!==void 0&&d!=null&&b(t,[`parameters`,`outputOptions`,`mimeType`],d);let f=x(e,[`outputCompressionQuality`]);t!==void 0&&f!=null&&b(t,[`parameters`,`outputOptions`,`compressionQuality`],f);let p=x(e,[`enhancePrompt`]);t!==void 0&&p!=null&&b(t,[`parameters`,`enhancePrompt`],p);let m=x(e,[`labels`]);return t!==void 0&&m!=null&&b(t,[`labels`],m),r}function ss(e,t,n){let r={},i=x(t,[`model`]);i!=null&&b(r,[`_url`,`model`],M(e,i));let a=x(t,[`source`]);a!=null&&ls(a,r);let o=x(t,[`config`]);return o!=null&&os(o,r),r}function cs(e,t){let n={},r=x(e,[`predictions`]);if(r!=null){let e=r;Array.isArray(e)&&(e=e.map(e=>No(e))),b(n,[`generatedImages`],e)}return n}function ls(e,t,n){let r={},i=x(e,[`prompt`]);t!==void 0&&i!=null&&b(t,[`instances[0]`,`prompt`],i);let a=x(e,[`personImage`]);t!==void 0&&a!=null&&b(t,[`instances[0]`,`personImage`,`image`],L(a));let o=x(e,[`productImages`]);if(t!==void 0&&o!=null){let e=o;Array.isArray(e)&&(e=e.map(e=>as(e))),b(t,[`instances[0]`,`productImages`],e)}return r}function us(e,t){let n={},r=x(e,[`referenceImage`]);r!=null&&b(n,[`referenceImage`],L(r));let i=x(e,[`referenceId`]);i!=null&&b(n,[`referenceId`],i);let a=x(e,[`referenceType`]);a!=null&&b(n,[`referenceType`],a);let o=x(e,[`maskImageConfig`]);o!=null&&b(n,[`maskImageConfig`],Qo(o));let s=x(e,[`controlImageConfig`]);s!=null&&b(n,[`controlImageConfig`],Ua(s));let c=x(e,[`styleImageConfig`]);c!=null&&b(n,[`styleImageConfig`],c);let l=x(e,[`subjectImageConfig`]);return l!=null&&b(n,[`subjectImageConfig`],l),n}function ds(e,t){let n={},r=x(e,[`mimeType`]);r!=null&&b(n,[`mimeType`],r);let i=x(e,[`voiceSampleAudio`]);if(i!=null&&b(n,[`voiceSampleAudio`],i),x(e,[`consentAudio`])!==void 0)throw Error(`consentAudio parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.`);if(x(e,[`voiceConsentSignature`])!==void 0)throw Error(`voiceConsentSignature parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.`);return n}function fs(e,t){let n={},r=x(e,[`safetyAttributes`,`categories`]);r!=null&&b(n,[`categories`],r);let i=x(e,[`safetyAttributes`,`scores`]);i!=null&&b(n,[`scores`],i);let a=x(e,[`contentType`]);return a!=null&&b(n,[`contentType`],a),n}function ps(e,t){let n={},r=x(e,[`category`]);if(r!=null&&b(n,[`category`],r),x(e,[`method`])!==void 0)throw Error(`method parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);let i=x(e,[`threshold`]);return i!=null&&b(n,[`threshold`],i),n}function ms(e,t){let n={},r=x(e,[`image`]);return r!=null&&b(n,[`image`],L(r)),n}function hs(e,t,n){let r={},i=x(e,[`mode`]);t!==void 0&&i!=null&&b(t,[`parameters`,`mode`],i);let a=x(e,[`maxPredictions`]);t!==void 0&&a!=null&&b(t,[`parameters`,`maxPredictions`],a);let o=x(e,[`confidenceThreshold`]);t!==void 0&&o!=null&&b(t,[`parameters`,`confidenceThreshold`],o);let s=x(e,[`maskDilation`]);t!==void 0&&s!=null&&b(t,[`parameters`,`maskDilation`],s);let c=x(e,[`binaryColorThreshold`]);t!==void 0&&c!=null&&b(t,[`parameters`,`binaryColorThreshold`],c);let l=x(e,[`labels`]);return t!==void 0&&l!=null&&b(t,[`labels`],l),r}function gs(e,t,n){let r={},i=x(t,[`model`]);i!=null&&b(r,[`_url`,`model`],M(e,i));let a=x(t,[`source`]);a!=null&&vs(a,r);let o=x(t,[`config`]);return o!=null&&hs(o,r),r}function _s(e,t){let n={},r=x(e,[`predictions`]);if(r!=null){let e=r;Array.isArray(e)&&(e=e.map(e=>Po(e))),b(n,[`generatedMasks`],e)}return n}function vs(e,t,n){let r={},i=x(e,[`prompt`]);t!==void 0&&i!=null&&b(t,[`instances[0]`,`prompt`],i);let a=x(e,[`image`]);t!==void 0&&a!=null&&b(t,[`instances[0]`,`image`],L(a));let o=x(e,[`scribbleImage`]);return t!==void 0&&o!=null&&b(t,[`instances[0]`,`scribble`],ms(o)),r}function ys(e,t){let n={},r=x(e,[`speaker`]);r!=null&&b(n,[`speaker`],r);let i=x(e,[`voiceConfig`]);return i!=null&&b(n,[`voiceConfig`],Vs(i)),n}function bs(e,t){let n={},r=x(e,[`voiceConfig`]);r!=null&&b(n,[`voiceConfig`],Vs(r));let i=x(e,[`languageCode`]);i!=null&&b(n,[`languageCode`],i);let a=x(e,[`multiSpeakerVoiceConfig`]);return a!=null&&b(n,[`multiSpeakerVoiceConfig`],ns(a)),n}function xs(e,t){let n={},r=x(e,[`functionCallingConfig`]);r!=null&&b(n,[`functionCallingConfig`],po(r));let i=x(e,[`retrievalConfig`]);i!=null&&b(n,[`retrievalConfig`],i);let a=x(e,[`includeServerSideToolInvocations`]);return a!=null&&b(n,[`includeServerSideToolInvocations`],a),n}function Ss(e,t){let n={},r=x(e,[`functionCallingConfig`]);r!=null&&b(n,[`functionCallingConfig`],r);let i=x(e,[`retrievalConfig`]);if(i!=null&&b(n,[`retrievalConfig`],i),x(e,[`includeServerSideToolInvocations`])!==void 0)throw Error(`includeServerSideToolInvocations parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.`);return n}function Cs(e,t){let n={};if(x(e,[`retrieval`])!==void 0)throw Error(`retrieval parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);let r=x(e,[`googleMaps`]);r!=null&&b(n,[`googleMaps`],Bo(r));let i=x(e,[`mcpServers`]);if(i!=null){let e=i;Array.isArray(e)&&(e=e.map(e=>e)),b(n,[`mcpServers`],e)}let a=x(e,[`codeExecution`]);a!=null&&b(n,[`codeExecution`],a);let o=x(e,[`computerUse`]);if(o!=null&&b(n,[`computerUse`],o),x(e,[`enterpriseWebSearch`])!==void 0)throw Error(`enterpriseWebSearch parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);if(x(e,[`exaAiSearch`])!==void 0)throw Error(`exaAiSearch parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);let s=x(e,[`functionDeclarations`]);if(s!=null){let e=s;Array.isArray(e)&&(e=e.map(e=>e)),b(n,[`functionDeclarations`],e)}let c=x(e,[`googleSearch`]);c!=null&&b(n,[`googleSearch`],Vo(c));let l=x(e,[`googleSearchRetrieval`]);if(l!=null&&b(n,[`googleSearchRetrieval`],l),x(e,[`parallelAiSearch`])!==void 0)throw Error(`parallelAiSearch parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);let u=x(e,[`urlContext`]);u!=null&&b(n,[`urlContext`],u);let d=x(e,[`fileSearch`]);return d!=null&&b(n,[`fileSearch`],d),n}function ws(e,t){let n={},r=x(e,[`retrieval`]);r!=null&&b(n,[`retrieval`],r);let i=x(e,[`googleMaps`]);i!=null&&b(n,[`googleMaps`],i);let a=x(e,[`mcpServers`]);if(a!=null){let e=a;Array.isArray(e)&&(e=e.map(e=>$o(e))),b(n,[`mcpServers`],e)}let o=x(e,[`codeExecution`]);o!=null&&b(n,[`codeExecution`],o);let s=x(e,[`computerUse`]);s!=null&&b(n,[`computerUse`],Ra(s));let c=x(e,[`enterpriseWebSearch`]);c!=null&&b(n,[`enterpriseWebSearch`],c);let l=x(e,[`exaAiSearch`]);l!=null&&b(n,[`exaAiSearch`],l);let u=x(e,[`functionDeclarations`]);if(u!=null){let e=u;Array.isArray(e)&&(e=e.map(e=>e)),b(n,[`functionDeclarations`],e)}let d=x(e,[`googleSearch`]);d!=null&&b(n,[`googleSearch`],d);let f=x(e,[`googleSearchRetrieval`]);f!=null&&b(n,[`googleSearchRetrieval`],f);let p=x(e,[`parallelAiSearch`]);p!=null&&b(n,[`parallelAiSearch`],p);let m=x(e,[`urlContext`]);if(m!=null&&b(n,[`urlContext`],m),x(e,[`fileSearch`])!==void 0)throw Error(`fileSearch parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.`);return n}function Ts(e,t){let n={},r=x(e,[`baseModel`]);r!=null&&b(n,[`baseModel`],r);let i=x(e,[`createTime`]);i!=null&&b(n,[`createTime`],i);let a=x(e,[`updateTime`]);return a!=null&&b(n,[`updateTime`],a),n}function Es(e,t){let n={},r=x(e,[`labels`,`google-vertex-llm-tuning-base-model-id`]);r!=null&&b(n,[`baseModel`],r);let i=x(e,[`createTime`]);i!=null&&b(n,[`createTime`],i);let a=x(e,[`updateTime`]);return a!=null&&b(n,[`updateTime`],a),n}function Ds(e,t,n){let r={},i=x(e,[`displayName`]);t!==void 0&&i!=null&&b(t,[`displayName`],i);let a=x(e,[`description`]);t!==void 0&&a!=null&&b(t,[`description`],a);let o=x(e,[`defaultCheckpointId`]);return t!==void 0&&o!=null&&b(t,[`defaultCheckpointId`],o),r}function Os(e,t,n){let r={},i=x(e,[`displayName`]);t!==void 0&&i!=null&&b(t,[`displayName`],i);let a=x(e,[`description`]);t!==void 0&&a!=null&&b(t,[`description`],a);let o=x(e,[`defaultCheckpointId`]);return t!==void 0&&o!=null&&b(t,[`defaultCheckpointId`],o),r}function ks(e,t,n){let r={},i=x(t,[`model`]);i!=null&&b(r,[`_url`,`name`],M(e,i));let a=x(t,[`config`]);return a!=null&&Ds(a,r),r}function As(e,t,n){let r={},i=x(t,[`model`]);i!=null&&b(r,[`_url`,`model`],M(e,i));let a=x(t,[`config`]);return a!=null&&Os(a,r),r}function js(e,t,n){let r={},i=x(e,[`outputGcsUri`]);t!==void 0&&i!=null&&b(t,[`parameters`,`storageUri`],i);let a=x(e,[`safetyFilterLevel`]);t!==void 0&&a!=null&&b(t,[`parameters`,`safetySetting`],a);let o=x(e,[`personGeneration`]);t!==void 0&&o!=null&&b(t,[`parameters`,`personGeneration`],o);let s=x(e,[`includeRaiReason`]);t!==void 0&&s!=null&&b(t,[`parameters`,`includeRaiReason`],s);let c=x(e,[`outputMimeType`]);t!==void 0&&c!=null&&b(t,[`parameters`,`outputOptions`,`mimeType`],c);let l=x(e,[`outputCompressionQuality`]);t!==void 0&&l!=null&&b(t,[`parameters`,`outputOptions`,`compressionQuality`],l);let u=x(e,[`enhanceInputImage`]);t!==void 0&&u!=null&&b(t,[`parameters`,`upscaleConfig`,`enhanceInputImage`],u);let d=x(e,[`imagePreservationFactor`]);t!==void 0&&d!=null&&b(t,[`parameters`,`upscaleConfig`,`imagePreservationFactor`],d);let f=x(e,[`labels`]);t!==void 0&&f!=null&&b(t,[`labels`],f);let p=x(e,[`numberOfImages`]);t!==void 0&&p!=null&&b(t,[`parameters`,`sampleCount`],p);let m=x(e,[`mode`]);return t!==void 0&&m!=null&&b(t,[`parameters`,`mode`],m),r}function Ms(e,t,n){let r={},i=x(t,[`model`]);i!=null&&b(r,[`_url`,`model`],M(e,i));let a=x(t,[`image`]);a!=null&&b(r,[`instances[0]`,`image`],L(a));let o=x(t,[`upscaleFactor`]);o!=null&&b(r,[`parameters`,`upscaleConfig`,`upscaleFactor`],o);let s=x(t,[`config`]);return s!=null&&js(s,r),r}function Ns(e,t){let n={},r=x(e,[`sdkHttpResponse`]);r!=null&&b(n,[`sdkHttpResponse`],r);let i=x(e,[`predictions`]);if(i!=null){let e=i;Array.isArray(e)&&(e=e.map(e=>No(e))),b(n,[`generatedImages`],e)}return n}function Ps(e,t){let n={},r=x(e,[`uri`]);r!=null&&b(n,[`uri`],r);let i=x(e,[`encodedVideo`]);i!=null&&b(n,[`videoBytes`],jn(i));let a=x(e,[`encoding`]);return a!=null&&b(n,[`mimeType`],a),n}function Fs(e,t){let n={},r=x(e,[`gcsUri`]);r!=null&&b(n,[`uri`],r);let i=x(e,[`bytesBase64Encoded`]);i!=null&&b(n,[`videoBytes`],jn(i));let a=x(e,[`mimeType`]);return a!=null&&b(n,[`mimeType`],a),n}function Is(e,t){let n={},r=x(e,[`image`]);r!=null&&b(n,[`_self`],L(r));let i=x(e,[`maskMode`]);return i!=null&&b(n,[`maskMode`],i),n}function Ls(e,t){let n={},r=x(e,[`image`]);r!=null&&b(n,[`image`],Go(r));let i=x(e,[`referenceType`]);return i!=null&&b(n,[`referenceType`],i),n}function Rs(e,t){let n={},r=x(e,[`image`]);r!=null&&b(n,[`image`],L(r));let i=x(e,[`referenceType`]);return i!=null&&b(n,[`referenceType`],i),n}function zs(e,t){let n={},r=x(e,[`uri`]);r!=null&&b(n,[`uri`],r);let i=x(e,[`videoBytes`]);i!=null&&b(n,[`encodedVideo`],jn(i));let a=x(e,[`mimeType`]);return a!=null&&b(n,[`encoding`],a),n}function Bs(e,t){let n={},r=x(e,[`uri`]);r!=null&&b(n,[`gcsUri`],r);let i=x(e,[`videoBytes`]);i!=null&&b(n,[`bytesBase64Encoded`],jn(i));let a=x(e,[`mimeType`]);return a!=null&&b(n,[`mimeType`],a),n}function Vs(e,t){let n={},r=x(e,[`replicatedVoiceConfig`]);r!=null&&b(n,[`replicatedVoiceConfig`],ds(r));let i=x(e,[`prebuiltVoiceConfig`]);return i!=null&&b(n,[`prebuiltVoiceConfig`],i),n}function Hs(e,t,n){let r={},i=x(t,[`displayName`]);n!==void 0&&i!=null&&b(n,[`displayName`],i);let a=x(t,[`embeddingModel`]);return n!==void 0&&a!=null&&b(n,[`embeddingModel`],M(e,a)),r}function Us(e,t){let n={},r=x(t,[`config`]);return r!=null&&Hs(e,r,n),n}function Ws(e,t){let n={},r=x(e,[`force`]);return t!==void 0&&r!=null&&b(t,[`_query`,`force`],r),n}function Gs(e){let t={},n=x(e,[`name`]);n!=null&&b(t,[`_url`,`name`],n);let r=x(e,[`config`]);return r!=null&&Ws(r,t),t}function Ks(e){let t={},n=x(e,[`name`]);return n!=null&&b(t,[`_url`,`name`],n),t}function qs(e,t){let n={},r=x(e,[`customMetadata`]);if(t!==void 0&&r!=null){let e=r;Array.isArray(e)&&(e=e.map(e=>e)),b(t,[`customMetadata`],e)}let i=x(e,[`chunkingConfig`]);return t!==void 0&&i!=null&&b(t,[`chunkingConfig`],i),n}function Js(e){let t={},n=x(e,[`name`]);n!=null&&b(t,[`name`],n);let r=x(e,[`metadata`]);r!=null&&b(t,[`metadata`],r);let i=x(e,[`done`]);i!=null&&b(t,[`done`],i);let a=x(e,[`error`]);a!=null&&b(t,[`error`],a);let o=x(e,[`response`]);return o!=null&&b(t,[`response`],Xs(o)),t}function Ys(e){let t={},n=x(e,[`fileSearchStoreName`]);n!=null&&b(t,[`_url`,`file_search_store_name`],n);let r=x(e,[`fileName`]);r!=null&&b(t,[`fileName`],r);let i=x(e,[`config`]);return i!=null&&qs(i,t),t}function Xs(e){let t={},n=x(e,[`sdkHttpResponse`]);n!=null&&b(t,[`sdkHttpResponse`],n);let r=x(e,[`parent`]);r!=null&&b(t,[`parent`],r);let i=x(e,[`documentName`]);return i!=null&&b(t,[`documentName`],i),t}function Zs(e,t){let n={},r=x(e,[`pageSize`]);t!==void 0&&r!=null&&b(t,[`_query`,`pageSize`],r);let i=x(e,[`pageToken`]);return t!==void 0&&i!=null&&b(t,[`_query`,`pageToken`],i),n}function Qs(e){let t={},n=x(e,[`config`]);return n!=null&&Zs(n,t),t}function $s(e){let t={},n=x(e,[`sdkHttpResponse`]);n!=null&&b(t,[`sdkHttpResponse`],n);let r=x(e,[`nextPageToken`]);r!=null&&b(t,[`nextPageToken`],r);let i=x(e,[`fileSearchStores`]);if(i!=null){let e=i;Array.isArray(e)&&(e=e.map(e=>e)),b(t,[`fileSearchStores`],e)}return t}function ec(e,t){let n={},r=x(e,[`mimeType`]);t!==void 0&&r!=null&&b(t,[`mimeType`],r);let i=x(e,[`displayName`]);t!==void 0&&i!=null&&b(t,[`displayName`],i);let a=x(e,[`customMetadata`]);if(t!==void 0&&a!=null){let e=a;Array.isArray(e)&&(e=e.map(e=>e)),b(t,[`customMetadata`],e)}let o=x(e,[`chunkingConfig`]);return t!==void 0&&o!=null&&b(t,[`chunkingConfig`],o),n}function tc(e){let t={},n=x(e,[`fileSearchStoreName`]);n!=null&&b(t,[`_url`,`file_search_store_name`],n);let r=x(e,[`config`]);return r!=null&&ec(r,t),t}function nc(e){let t={},n=x(e,[`sdkHttpResponse`]);return n!=null&&b(t,[`sdkHttpResponse`],n),t}var rc=`Content-Type`,ic=`X-Server-Timeout`,ac=`User-Agent`,oc=`x-goog-api-client`,sc=`google-genai-sdk/2.21.0`,cc=`v1beta1`,lc=`v1beta`,uc=new Set([`us`,`eu`]);function dc(e){let t=globalThis[Symbol.for(`undici.globalDispatcher.1`)];if(t)for(let n of Object.getOwnPropertySymbols(t)){let r=n.description;if(r?.includes(`headers timeout`)||r?.includes(`body timeout`)){let r=t[n];typeof r==`number`&&(t[n]=Math.max(r,e))}}}function fc(e,t){let n=()=>{};if(!(e&&e>0)&&!t)return{signal:void 0,dispose:n};let r=new AbortController,i;e&&e>0&&(i=setTimeout(()=>r.abort(),e),i&&typeof i.unref==`function`&&i.unref());let a=()=>r.abort();return t&&(t.aborted?r.abort():t.addEventListener(`abort`,a)),{signal:r.signal,dispose:()=>{i!==void 0&&clearTimeout(i),t?.removeEventListener(`abort`,a)}}}var pc=5,mc=1,hc=60,gc=2,_c=1,vc=[408,429,500,502,503,504],yc=class{constructor(e){this.clientOptions=Object.assign({},e),this.customBaseUrl=e.httpOptions?.baseUrl;let t={};if(this.clientOptions.vertexai){if(!this.clientOptions.location&&!this.clientOptions.apiKey&&!this.customBaseUrl&&(this.clientOptions.location=`global`),!(this.clientOptions.project&&this.clientOptions.location||this.clientOptions.apiKey)&&!this.customBaseUrl)throw Error(`Authentication is not set up. Please provide either a project and location, or an API key, or a custom base URL.`);let n=e.project&&e.location||!!e.apiKey;this.customBaseUrl&&!n?(t.baseUrl=this.customBaseUrl,this.clientOptions.project=void 0,this.clientOptions.location=void 0):this.clientOptions.apiKey&&!this.clientOptions.project||this.clientOptions.location===`global`?t.baseUrl=`https://aiplatform.googleapis.com/`:this.clientOptions.project&&this.clientOptions.location&&uc.has(this.clientOptions.location)?t.baseUrl=`https://aiplatform.${this.clientOptions.location}.rep.googleapis.com/`:this.clientOptions.project&&this.clientOptions.location&&(t.baseUrl=`https://${this.clientOptions.location}-aiplatform.googleapis.com/`),t.apiVersion=this.clientOptions.apiVersion??cc}else this.clientOptions.apiKey||console.warn(`API key should be set when using the Gemini API.`),t.apiVersion=this.clientOptions.apiVersion??lc,t.baseUrl=`https://generativelanguage.googleapis.com/`;t.headers=this.getDefaultHeaders(),this.clientOptions.httpOptions=t,e.httpOptions&&(this.clientOptions.httpOptions=this.patchHttpOptions(t,e.httpOptions))}isVertexAI(){return this.clientOptions.vertexai??!1}getProject(){return this.clientOptions.project}getLocation(){return this.clientOptions.location}getCustomBaseUrl(){return this.customBaseUrl}async getAuthHeaders(){let e=new Headers;return await this.clientOptions.auth.addAuthHeaders(e),e}getApiVersion(){if(this.clientOptions.httpOptions&&this.clientOptions.httpOptions.apiVersion!==void 0)return this.clientOptions.httpOptions.apiVersion;throw Error(`API version is not set.`)}getBaseUrl(){if(this.clientOptions.httpOptions&&this.clientOptions.httpOptions.baseUrl!==void 0)return this.clientOptions.httpOptions.baseUrl;throw Error(`Base URL is not set.`)}getRequestUrl(){return this.getRequestUrlInternal(this.clientOptions.httpOptions)}getHeaders(){if(this.clientOptions.httpOptions&&this.clientOptions.httpOptions.headers!==void 0)return this.clientOptions.httpOptions.headers;throw Error(`Headers are not set.`)}getRequestUrlInternal(e){if(!e||e.baseUrl===void 0||e.apiVersion===void 0)throw Error(`HTTP options are not correctly set.`);let t=[e.baseUrl.endsWith(`/`)?e.baseUrl.slice(0,-1):e.baseUrl];return e.apiVersion&&e.apiVersion!==``&&t.push(e.apiVersion),t.join(`/`)}getBaseResourcePath(){return`projects/${this.clientOptions.project}/locations/${this.clientOptions.location}`}getApiKey(){return this.clientOptions.apiKey}getWebsocketBaseUrl(){let e=this.getBaseUrl(),t=new URL(e);return t.protocol=t.protocol==`http:`?`ws`:`wss`,t.toString()}setBaseUrl(e){if(this.clientOptions.httpOptions)this.clientOptions.httpOptions.baseUrl=e;else throw Error(`HTTP options are not correctly set.`)}constructUrl(e,t,n){let r=[this.getRequestUrlInternal(t)];return n&&r.push(this.getBaseResourcePath()),e!==``&&r.push(e),new URL(`${r.join(`/`)}`)}shouldPrependVertexProjectPath(e,t){return!(t.baseUrl&&t.baseUrlResourceScope===rt.COLLECTION||!this.clientOptions.vertexai||!this.clientOptions.project||!this.clientOptions.location||e.path.startsWith(`projects/`)||e.httpMethod===`GET`&&e.path.startsWith(`publishers/google/models`))}async request(e){let t=this.clientOptions.httpOptions;e.httpOptions&&(t=this.patchHttpOptions(this.clientOptions.httpOptions,e.httpOptions));let n=this.shouldPrependVertexProjectPath(e,t),r=this.constructUrl(e.path,t,n);if(e.queryParams)for(let[t,n]of Object.entries(e.queryParams))r.searchParams.append(t,String(n));let i={};if(e.httpMethod===`GET`){if(e.body&&e.body!==`{}`)throw Error(`Request body should be empty for GET request, but got non empty request body`)}else i.body=e.body;return i=await this.includeExtraHttpOptionsToRequestInit(i,t,r.toString()),this.unaryApiCall(r,i,e.httpMethod,t.retryOptions,t.timeout,e.abortSignal)}patchHttpOptions(e,t){let n=JSON.parse(JSON.stringify(e));for(let[e,r]of Object.entries(t))typeof r==`object`?n[e]=Object.assign(Object.assign({},n[e]),r):r!==void 0&&(n[e]=r);return n}async requestStream(e){let t=this.clientOptions.httpOptions;e.httpOptions&&(t=this.patchHttpOptions(this.clientOptions.httpOptions,e.httpOptions));let n=this.shouldPrependVertexProjectPath(e,t),r=this.constructUrl(e.path,t,n);(!r.searchParams.has(`alt`)||r.searchParams.get(`alt`)!==`sse`)&&r.searchParams.set(`alt`,`sse`);let i={};return i.body=e.body,i=await this.includeExtraHttpOptionsToRequestInit(i,t,r.toString()),this.streamApiCall(r,i,e.httpMethod,t.retryOptions,t.timeout,e.abortSignal)}async includeExtraHttpOptionsToRequestInit(e,t,n){return t?.timeout&&t.timeout>0&&dc(t.timeout),t&&t.extraBody!==null&&xc(e,t.extraBody),e.headers=await this.getHeadersInternal(t,n),e}async unaryApiCall(e,t,n,r,i,a){return this.apiCall(e.toString(),Object.assign(Object.assign({},t),{method:n}),r,i,a).then(async e=>(await bc(e),new Mt(e))).catch(e=>{throw e instanceof Error?e:Error(`exception ${e} sending request`,{cause:e})})}async streamApiCall(e,t,n,r,i,a){return this.apiCall(e.toString(),Object.assign(Object.assign({},t),{method:n}),r,i,a).then(async e=>(await bc(e),this.processStreamResponse(e))).catch(e=>{throw e instanceof Error?e:Error(`exception ${e} sending request`,{cause:e})})}processStreamResponse(e){return Ni(this,arguments,function*(){let t=(e?.body)?.getReader(),n=new TextDecoder(`utf-8`);if(!t)throw Error(`Response body is empty`);try{let r=``,i=[`
|
|
2
|
+
|
|
3
|
+
`,`\r\r`,`\r
|
|
4
|
+
\r
|
|
5
|
+
`];for(;;){let{done:a,value:o}=yield I(t.read());if(a){if(r.trim().length>0)throw Error(`Incomplete JSON segment at the end`);break}let s=n.decode(o,{stream:!0});try{let e=JSON.parse(s);if(`error`in e){let t=JSON.parse(JSON.stringify(e.error)),n=t.status,r=t.code,i=`got status: ${n}. ${JSON.stringify(e)}`;if(r>=400&&r<600)throw new Vi({message:i,status:r})}}catch(e){if(e.name===`ApiError`)throw e}r+=s;let c=-1,l=0;for(;;){c=-1,l=0;for(let e of i){let t=r.indexOf(e);t!==-1&&(c===-1||t<c)&&(c=t,l=e.length)}if(c===-1)break;let t=r.substring(0,c);r=r.substring(c+l);let n=t.trim();if(n.startsWith(`data:`)){let t=n.substring(5).trim();try{yield yield I(new Mt(new Response(t,{headers:e?.headers,status:e?.status,statusText:e?.statusText})))}catch(e){throw Error(`exception parsing stream chunk ${t}. ${e}`)}}}}}finally{t.releaseLock()}})}async apiCall(e,t,n,r,i){let a=n?.httpStatusCodes??vc,o=async()=>{let o=fc(r,i),s;try{s=await fetch(e,Object.assign(Object.assign({},t),{signal:o.signal}))}catch(e){throw o.dispose(),e}if(!n||s.ok||!a.includes(s.status))return s;try{await bc(s)}finally{o.dispose()}return s};if(!n)return o();let s=Math.max(1,n.attempts??pc),c=Math.round((n.initialDelay??mc)*1e3),l=Math.max(c,Math.round((n.maxDelay??hc)*1e3));return(0,p.default)(o,{retries:s-1,factor:n.expBase??gc,minTimeout:c,maxTimeout:l,randomize:(n.jitter??_c)>0,onFailedAttempt:e=>{if(i?.aborted)throw e.error??e}})}getDefaultHeaders(){let e={},t=sc+` `+this.clientOptions.userAgentExtra;return e[ac]=t,e[oc]=t,e[rc]=`application/json`,e}async getHeadersInternal(e,t){let n=new Headers;if(e&&e.headers)for(let[t,r]of Object.entries(e.headers))n.append(t,r);return e?.timeout&&e.timeout>0&&n.append(ic,String(Math.ceil(e.timeout/1e3))),await this.clientOptions.auth.addAuthHeaders(n,t),n}getFileName(e){let t=``;return typeof e==`string`&&(t=e.replace(/[/\\]+$/,``),t=t.split(/[/\\]/).pop()??``),t}async uploadFile(e,t){let n={};t!=null&&(n.mimeType=t.mimeType,n.name=t.name,n.displayName=t.displayName),n.name&&!n.name.startsWith(`files/`)&&(n.name=`files/${n.name}`);let r=this.clientOptions.uploader,i=await r.stat(e);n.sizeBytes=String(i.size);let a=t?.mimeType??i.type;if(a===void 0||a===``)throw Error(`Can not determine mimeType. Please provide mimeType in the config.`);n.mimeType=a;let o={file:n},s=this.getFileName(e),c=y(`upload/v1beta/files`,o._url),l=await this.fetchUploadUrl(c,n.sizeBytes,n.mimeType,s,o,t?.httpOptions);return r.upload(e,l,this)}async uploadFileToFileSearchStore(e,t,n){let r=this.clientOptions.uploader,i=await r.stat(t),a=String(i.size),o=n?.mimeType??i.type;if(o===void 0||o===``)throw Error(`Can not determine mimeType. Please provide mimeType in the config.`);let s=`upload/v1beta/${e}:uploadToFileSearchStore`,c=this.getFileName(t),l={};n!=null&&ec(n,l);let u=await this.fetchUploadUrl(s,a,o,c,l,n?.httpOptions);return r.uploadToFileSearchStore(t,u,this)}async downloadFile(e){await this.clientOptions.downloader.download(e,this)}async fetchUploadUrl(e,t,n,r,i,a){let o={};o=a||{apiVersion:``,headers:Object.assign({"Content-Type":`application/json`,"X-Goog-Upload-Protocol":`resumable`,"X-Goog-Upload-Command":`start`,"X-Goog-Upload-Header-Content-Length":`${t}`,"X-Goog-Upload-Header-Content-Type":`${n}`},r?{"X-Goog-Upload-File-Name":r}:{})};let s=await this.request({path:e,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:o});if(!s||!s?.headers)throw Error(`Server did not return an HttpResponse or the returned HttpResponse did not have headers.`);let c=s?.headers?.[`x-goog-upload-url`];if(c===void 0)throw Error(`Failed to get upload url. Server did not return the x-google-upload-url in the headers`);return c}};async function bc(e){if(e===void 0)throw Error(`response is undefined`);if(!e.ok){let t=e.status,n;n=e.headers.get(`content-type`)?.includes(`application/json`)?await e.json():{error:{message:await e.text(),code:e.status,status:e.statusText}};let r=JSON.stringify(n);throw t>=400&&t<600?new Vi({message:r,status:t}):Error(r)}}function xc(e,t){if(!t||Object.keys(t).length===0)return;if(e.body instanceof Blob){console.warn(`includeExtraBodyToRequestInit: extraBody provided but current request body is a Blob. extraBody will be ignored as merging is not supported for Blob bodies.`);return}let n={};if(typeof e.body==`string`&&e.body.length>0)try{let t=JSON.parse(e.body);if(typeof t==`object`&&t&&!Array.isArray(t))n=t;else{console.warn(`includeExtraBodyToRequestInit: Original request body is valid JSON but not a non-array object. Skip applying extraBody to the request body.`);return}}catch{console.warn(`includeExtraBodyToRequestInit: Original request body is not valid JSON. Skip applying extraBody to the request body.`);return}function r(e,t){let n=Object.assign({},e);for(let e in t)if(Object.prototype.hasOwnProperty.call(t,e)){let i=t[e],a=n[e];i&&typeof i==`object`&&!Array.isArray(i)&&a&&typeof a==`object`&&!Array.isArray(a)?n[e]=r(a,i):(a&&i&&typeof a!=typeof i&&console.warn(`includeExtraBodyToRequestInit:deepMerge: Type mismatch for key "${e}". Original type: ${typeof a}, New type: ${typeof i}. Overwriting.`),n[e]=i)}return n}let i=r(n,t);e.body=JSON.stringify(i)}var Sc=`mcp_used/unknown`,Cc=!1;function wc(e){for(let t of e)if(Ec(t)||typeof t==`object`&&`inputSchema`in t)return!0;return Cc}function Tc(e){e[oc]=((e[oc]??``)+` ${Sc}`).trimStart()}function Ec(e){return typeof e==`object`&&!!e&&e instanceof Oc}function Dc(e){return Ni(this,arguments,function*(e,t=100){let n,r=0;for(;r<t;){let t=yield I(e.listTools({cursor:n}));for(let e of t.tools)yield yield I(e),r++;if(!t.nextCursor)break;n=t.nextCursor}})}var Oc=class e{constructor(e=[],t){this.mcpTools=[],this.functionNameToMcpClient={},this.mcpClients=e,this.config=t}static create(t,n){return new e(t,n)}async initialize(){var e,t,n,r;if(this.mcpTools.length>0)return;let i={},a=[];for(let l of this.mcpClients)try{for(var o=!0,s=(t=void 0,Pi(Dc(l))),c;c=await s.next(),e=c.done,!e;o=!0){r=c.value,o=!1;let e=r;a.push(e);let t=e.name;if(i[t])throw Error(`Duplicate function name ${t} found in MCP tools. Please ensure function names are unique.`);i[t]=l}}catch(e){t={error:e}}finally{try{!o&&!e&&(n=s.return)&&await n.call(s)}finally{if(t)throw t.error}}this.mcpTools=a,this.functionNameToMcpClient=i}async tool(){return await this.initialize(),Bn(this.mcpTools,this.config)}async callTool(e){await this.initialize();let t=[];for(let n of e)if(n.name in this.functionNameToMcpClient){let e=this.functionNameToMcpClient[n.name],r;this.config.timeout&&(r={timeout:this.config.timeout});let i=await e.callTool({name:n.name,arguments:n.args},void 0,r);t.push({functionResponse:{name:n.name,response:i.isError?{error:i}:i}})}return t}};async function kc(e,t,n){let r=new sn,i;i=n.data instanceof Blob?JSON.parse(await n.data.text()):JSON.parse(n.data),Object.assign(r,i),t(r)}var Ac=class{constructor(e,t,n){this.apiClient=e,this.auth=t,this.webSocketFactory=n}async connect(e){if(this.apiClient.isVertexAI())throw Error(`Live music is not supported for Vertex AI.`);console.warn(`Live music generation is experimental and may change in future versions.`);let t=this.apiClient.getWebsocketBaseUrl(),n=this.apiClient.getApiVersion(),r=Nc(this.apiClient.getDefaultHeaders()),i=`${t}/ws/google.ai.generativelanguage.${n}.GenerativeService.BidiGenerateMusic?key=${this.apiClient.getApiKey()}`,a=()=>{},o=new Promise(e=>{a=e}),s=e.callbacks,c=function(){a({})},l=this.apiClient,u={onopen:c,onmessage:e=>{kc(l,s.onmessage,e)},onerror:s?.onerror??function(e){},onclose:s?.onclose??function(e){}},d=this.webSocketFactory.create(i,Mc(r),u);d.connect(),await o;let f={setup:{model:M(this.apiClient,e.model)}};return d.send(JSON.stringify(f)),new jc(d,this.apiClient)}},jc=class{constructor(e,t){this.conn=e,this.apiClient=t}async setWeightedPrompts(e){if(!e.weightedPrompts||Object.keys(e.weightedPrompts).length===0)throw Error(`Weighted prompts must be set and contain at least one entry.`);let t=ma(e);this.conn.send(JSON.stringify({clientContent:t}))}async setMusicGenerationConfig(e){e.musicGenerationConfig||={};let t=pa(e);this.conn.send(JSON.stringify(t))}sendPlaybackControl(e){let t={playbackControl:e};this.conn.send(JSON.stringify(t))}play(){this.sendPlaybackControl(jt.PLAY)}pause(){this.sendPlaybackControl(jt.PAUSE)}stop(){this.sendPlaybackControl(jt.STOP)}resetContext(){this.sendPlaybackControl(jt.RESET_CONTEXT)}close(){this.conn.close()}};function Mc(e){let t={};return e.forEach((e,n)=>{t[n]=e}),t}function Nc(e){let t=new Headers;for(let[n,r]of Object.entries(e))t.append(n,r);return t}var Pc="FunctionResponse request must have an `id` field from the response of a ToolCall.FunctionalCalls in Google AI.";async function Fc(e,t,n){let r=new on,i;i=n.data instanceof Blob?await n.data.text():n.data instanceof ArrayBuffer?new TextDecoder().decode(n.data):n.data;let a=JSON.parse(i);if(e.isVertexAI()){let e=_a(a);Object.assign(r,e)}else Object.assign(r,a);t(r)}var Ic=class{constructor(e,t,n){this.apiClient=e,this.auth=t,this.webSocketFactory=n,this.music=new Ac(this.apiClient,this.auth,this.webSocketFactory)}async connect(e){if(e.config&&e.config.httpOptions)throw Error(`The Live module does not support httpOptions at request-level in LiveConnectConfig yet. Please use the client-level httpOptions configuration instead.`);let t=this.apiClient.getWebsocketBaseUrl(),n=this.apiClient.getApiVersion(),r,i=this.apiClient.getHeaders();e.config&&e.config.tools&&wc(e.config.tools)&&Tc(i);let a=Bc(i);if(this.apiClient.isVertexAI()){let e=this.apiClient.getProject(),i=this.apiClient.getLocation(),o=this.apiClient.getApiKey(),s=!!e&&!!i||!!o;this.apiClient.getCustomBaseUrl()&&!s?r=t:(r=`${t}/ws/google.cloud.aiplatform.${n}.LlmBidiService/BidiGenerateContent`,await this.auth.addAuthHeaders(a,r))}else{let e=this.apiClient.getApiKey(),i=`BidiGenerateContent`,a=`key`;e?.startsWith(`auth_tokens/`)&&(console.warn(`Warning: Ephemeral token support is experimental and may change in future versions.`),n!==`v1alpha`&&console.warn(`Warning: The SDK's ephemeral token support is in v1alpha only. Please use const ai = new GoogleGenAI({apiKey: token.name, httpOptions: { apiVersion: 'v1alpha' }}); before session connection.`),i=`BidiGenerateContentConstrained`,a=`access_token`),r=`${t}/ws/google.ai.generativelanguage.${n}.GenerativeService.${i}?${a}=${e}`}let o=()=>{},s=new Promise(e=>{o=e}),c=e.callbacks,l=function(){var e;(e=c?.onopen)==null||e.call(c),o({})},u=this.apiClient,d=!1,f=[],p=()=>{},m=new Promise(e=>{p=e}),h={onopen:l,onmessage:e=>{Fc(u,e=>{e.setupComplete&&!S.setupComplete&&(S.setupComplete=e.setupComplete,p({})),d?c.onmessage(e):f.push(e)},e)},onerror:c?.onerror??function(e){},onclose:c?.onclose??function(e){}},g=this.webSocketFactory.create(r,zc(a),h);g.connect(),await s;let _=M(this.apiClient,e.model);if(this.apiClient.isVertexAI()&&_.startsWith(`publishers/`)){let e=this.apiClient.getProject(),t=this.apiClient.getLocation();e&&t&&(_=`projects/${e}/locations/${t}/`+_)}let v={};this.apiClient.isVertexAI()&&e.config?.responseModalities===void 0&&(e.config===void 0?e.config={responseModalities:[Ie.AUDIO]}:e.config.responseModalities=[Ie.AUDIO]),e.config?.generationConfig&&console.warn("Setting `LiveConnectConfig.generation_config` is deprecated, please set the fields on `LiveConnectConfig` directly. It will be removed in the next major version (not before 7/31/2026).");let y=e.config?.tools??[],b=[];for(let e of y)if(this.isCallableTool(e)){let t=e;b.push(await t.tool())}else b.push(e);b.length>0&&(e.config.tools=b);let x={model:_,config:e.config,callbacks:e.callbacks};v=this.apiClient.isVertexAI()?fa(this.apiClient,x):da(this.apiClient,x),delete v.config;let S=new Rc(g,this.apiClient);g.send(JSON.stringify(v)),await m,d=!0;for(let e of f)c.onmessage(e);return S}isCallableTool(e){return`callTool`in e&&typeof e.callTool==`function`}},Lc={turnComplete:!0},Rc=class{constructor(e,t){this.conn=e,this.apiClient=t}tLiveClientContent(e,t){if(t.turns!==null&&t.turns!==void 0){let n=[];try{n=P(t.turns),e.isVertexAI()||(n=n.map(e=>Va(e)))}catch{throw Error(`Failed to parse client content "turns", type: '${typeof t.turns}'`)}return{clientContent:{turns:n,turnComplete:t.turnComplete}}}return{clientContent:{turnComplete:t.turnComplete}}}tLiveClienttToolResponse(e,t){let n=[];if(t.functionResponses==null||(n=Array.isArray(t.functionResponses)?t.functionResponses:[t.functionResponses],n.length===0))throw Error(`functionResponses is required.`);for(let t of n){if(typeof t!=`object`||!t||!(`name`in t)||!(`response`in t))throw Error(`Could not parse function response, type '${typeof t}'.`);if(!e.isVertexAI()&&!(`id`in t))throw Error(Pc)}return{toolResponse:{functionResponses:n}}}sendClientContent(e){e=Object.assign(Object.assign({},Lc),e);let t=this.tLiveClientContent(this.apiClient,e);this.conn.send(JSON.stringify(t))}sendRealtimeInput(e){let t={};t=this.apiClient.isVertexAI()?{realtimeInput:ga(e)}:{realtimeInput:ha(e)},this.conn.send(JSON.stringify(t))}sendToolResponse(e){if(e.functionResponses==null)throw Error(`Tool response parameters are required.`);let t=this.tLiveClienttToolResponse(this.apiClient,e);this.conn.send(JSON.stringify(t))}close(){this.conn.close()}};function zc(e){let t={};return e.forEach((e,n)=>{t[n]=e}),t}function Bc(e){let t=new Headers;for(let[n,r]of Object.entries(e))t.append(n,r);return t}var Vc=10;function Hc(e){if(e?.automaticFunctionCalling?.disable)return!0;let t=!1;for(let n of e?.tools??[])if(Uc(n)){t=!0;break}if(!t)return!0;let n=e?.automaticFunctionCalling?.maximumRemoteCalls;return n&&(n<0||!Number.isInteger(n))||n==0?(console.warn(`Invalid maximumRemoteCalls value provided for automatic function calling. Disabled automatic function calling. Please provide a valid integer value greater than 0. maximumRemoteCalls provided:`,n),!0):!1}function Uc(e){return`callTool`in e&&typeof e.callTool==`function`}function Wc(e){return(e.config?.tools)?.some(e=>Uc(e))??!1}function Gc(e){let t=[];return e?.config?.tools&&e.config.tools.forEach((e,n)=>{if(Uc(e))return;let r=e;r.functionDeclarations&&r.functionDeclarations.length>0&&t.push(n)}),t}function Kc(e){return!e?.automaticFunctionCalling?.ignoreCallHistory}var qc=class e extends v{constructor(t){super(),this.apiClient=t,this.embedContent=async e=>{if(!this.apiClient.isVertexAI())return e.model.includes(`gemini-embedding-2`)&&(e.contents=P(e.contents)),await this.embedContentInternal(e);if(e.model.includes(`gemini`)&&e.model!==`gemini-embedding-001`||e.model.includes(`maas`)){let t=P(e.contents);if(t.length>1)throw Error(`The embedContent API for this model only supports one content at a time.`);let n=Object.assign(Object.assign({},e),{content:t[0],embeddingApiType:at.EMBED_CONTENT});return await this.embedContentInternal(n)}{let t=Object.assign(Object.assign({},e),{embeddingApiType:at.PREDICT});return await this.embedContentInternal(t)}},this.generateContent=async e=>{let t=await this.processParamsMaybeAddMcpUsage(e);if(this.maybeMoveToResponseJsonSchema(e),!Wc(e)||Hc(e.config))return await this.generateContentInternal(t);let n=Gc(e);if(n.length>0){let e=n.map(e=>`tools[${e}]`).join(`, `);throw Error(`Automatic function calling with CallableTools (or MCP objects) and basic FunctionDeclarations is not yet supported. Incompatible tools found at ${e}.`)}let r,i,a=P(t.contents),o=t.config?.automaticFunctionCalling?.maximumRemoteCalls??Vc,s=0;for(;s<o&&(r=await this.generateContentInternal(t),!(!r.functionCalls||r.functionCalls.length===0));){let n=r.candidates[0].content,o=[];for(let t of e.config?.tools??[])if(Uc(t)){let e=await t.callTool(r.functionCalls);o.push(...e)}s++,i={role:`user`,parts:o},t.contents=P(t.contents),t.contents.push(n),t.contents.push(i),Kc(t.config)&&(a.push(n),a.push(i))}return Kc(t.config)&&(r.automaticFunctionCallingHistory=a),r},this.generateContentStream=async e=>{if(this.maybeMoveToResponseJsonSchema(e),Hc(e.config)){let t=await this.processParamsMaybeAddMcpUsage(e);return await this.generateContentStreamInternal(t)}let t=Gc(e);if(t.length>0){let e=t.map(e=>`tools[${e}]`).join(`, `);throw Error(`Incompatible tools found at ${e}. Automatic function calling with CallableTools (or MCP objects) and basic FunctionDeclarations" is not yet supported.`)}let n=e?.config?.toolConfig?.functionCallingConfig?.streamFunctionCallArguments,r=e?.config?.automaticFunctionCalling?.disable;if(n&&!r)throw Error(`Running in streaming mode with 'streamFunctionCallArguments' enabled, this feature is not compatible with automatic function calling (AFC). Please set 'config.automaticFunctionCalling.disable' to true to disable AFC or leave 'config.toolConfig.functionCallingConfig.streamFunctionCallArguments' to be undefined or set to false to disable streaming function call arguments feature.`);return await this.processAfcStream(e)},this.generateImages=async t=>(e.loggedGenerateImagesWarning||(e.loggedGenerateImagesWarning=!0,console.warn(`The generateImages method is deprecated and will be removed in the next major release (not before Jan. 1 2027). Please use the generateContent method with image models instead. See https://ai.google.dev/gemini-api/docs/deprecations#imagen-models and https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/capabilities/image-generation#generate-images`)),await this.generateImagesInternal(t).then(e=>{let t,n=[];if(e?.generatedImages)for(let r of e.generatedImages)r&&r?.safetyAttributes&&r?.safetyAttributes?.contentType===`Positive Prompt`?t=r?.safetyAttributes:n.push(r);let r;return r=t?{generatedImages:n,positivePromptSafetyAttributes:t,sdkHttpResponse:e.sdkHttpResponse}:{generatedImages:n,sdkHttpResponse:e.sdkHttpResponse},r})),this.list=async e=>{let t={config:Object.assign(Object.assign({},{queryBase:!0}),e?.config)};if(this.apiClient.isVertexAI()&&!t.config.queryBase){if(t.config?.filter)throw Error(`Filtering tuned models list is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.`);t.config.filter=`labels.tune-type:*`}return new Kr(Gr.PAGED_ITEM_MODELS,e=>this.listInternal(e),await this.listInternal(t),t)},this.editImage=async t=>{e.loggedEditImageWarning||(e.loggedEditImageWarning=!0,console.warn(`The editImage method is deprecated and will be removed in the next major release (not before Jan. 1 2027). Please use the generateContent method with image models instead. See https://ai.google.dev/gemini-api/docs/deprecations#imagen-models and https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/capabilities/gemini-edit-images#edit-an-image`));let n={model:t.model,prompt:t.prompt,referenceImages:[],config:t.config};return t.referenceImages&&t.referenceImages&&(n.referenceImages=t.referenceImages.map(e=>e.toReferenceImageAPI())),await this.editImageInternal(n)},this.upscaleImage=async e=>{let t={numberOfImages:1,mode:`upscale`};e.config&&(t=Object.assign(Object.assign({},t),e.config));let n={model:e.model,image:e.image,upscaleFactor:e.upscaleFactor,config:t};return await this.upscaleImageInternal(n)},this.generateVideos=async t=>{if((t.prompt||t.image||t.video)&&t.source)throw Error(`Source and prompt/image/video are mutually exclusive. Please only use source.`);return(t.prompt||t.image||t.video)&&(e.loggedGenerateVideosWarning||(e.loggedGenerateVideosWarning=!0,console.warn(`The generateVideos method with prompt/image/video arguments is deprecated and will be removed in a future major release (not before 2026-07-31). Please use the source argument instead.`))),this.apiClient.isVertexAI()||(t.video?.uri&&t.video?.videoBytes?t.video={uri:t.video.uri,mimeType:t.video.mimeType}:t.source?.video?.uri&&t.source?.video?.videoBytes&&(t.source.video={uri:t.source.video.uri,mimeType:t.source.video.mimeType})),await this.generateVideosInternal(t)}}maybeMoveToResponseJsonSchema(e){e.config&&e.config.responseSchema&&(e.config.responseJsonSchema||Object.keys(e.config.responseSchema).includes(`$schema`)&&(e.config.responseJsonSchema=e.config.responseSchema,delete e.config.responseSchema))}async processParamsMaybeAddMcpUsage(e){let t=e.config?.tools;if(!t)return e;let n=await Promise.all(t.map(async e=>Uc(e)?await e.tool():e)),r={model:e.model,contents:e.contents,config:Object.assign(Object.assign({},e.config),{tools:n})};if(r.config.tools=n,e.config&&e.config.tools&&wc(e.config.tools)){let t=e.config.httpOptions?.headers??{},n=Object.assign({},t);Object.keys(n).length===0&&(n=this.apiClient.getDefaultHeaders()),Tc(n),r.config.httpOptions=Object.assign(Object.assign({},e.config.httpOptions),{headers:n})}return r}async initAfcToolsMap(e){let t=new Map;for(let n of e.config?.tools??[])if(Uc(n)){let e=n,r=await e.tool();for(let n of r.functionDeclarations??[]){if(!n.name)throw Error(`Function declaration name is required.`);if(t.has(n.name))throw Error(`Duplicate tool declaration name: ${n.name}`);t.set(n.name,e)}}return t}async processAfcStream(e){let t=e.config?.automaticFunctionCalling?.maximumRemoteCalls??Vc,n=!1,r=0,i=await this.initAfcToolsMap(e);return(function(e,i,a){return Ni(this,arguments,function*(){for(var o,s,c,l;r<t;){n&&=(r++,!1);let p=yield I(e.processParamsMaybeAddMcpUsage(a)),m=yield I(e.generateContentStreamInternal(p)),h=[],g=[];try{for(var u=!0,d=(s=void 0,Pi(m)),f;f=yield I(d.next()),o=f.done,!o;u=!0){l=f.value,u=!1;let e=l;if(yield yield I(e),e.candidates&&e.candidates[0]?.content){g.push(e.candidates[0].content);for(let n of e.candidates[0].content.parts??[])if(r<t&&n.functionCall){if(!n.functionCall.name)throw Error(`Function call name was not returned by the model.`);if(i.has(n.functionCall.name)){let e=yield I(i.get(n.functionCall.name).callTool([n.functionCall]));h.push(...e)}else throw Error(`Automatic function calling was requested, but not all the tools the model used implement the CallableTool interface. Available tools: ${i.keys()}, missing tool: ${n.functionCall.name}`)}}}}catch(e){s={error:e}}finally{try{!u&&!o&&(c=d.return)&&(yield I(c.call(d)))}finally{if(s)throw s.error}}if(h.length>0){n=!0;let e=new Nt;e.candidates=[{content:{role:`user`,parts:h}}],yield yield I(e);let t=[];t.push(...g),t.push({role:`user`,parts:h}),a.contents=P(a.contents).concat(t)}else break}})})(this,i,e)}async generateContentInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=_o(this.apiClient,e);return n=y(`{model}:generateContent`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=yo(e),n=new Nt;return Object.assign(n,t),n})}{let i=go(this.apiClient,e);return n=y(`{model}:generateContent`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=vo(e),n=new Nt;return Object.assign(n,t),n})}}async generateContentStreamInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=_o(this.apiClient,e);return n=y(`{model}:streamGenerateContent?alt=sse`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.requestStream({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}),t.then(function(t){return Ni(this,arguments,function*(){var n,r,i,a;try{for(var o=!0,s=Pi(t),c;c=yield I(s.next()),n=c.done,!n;o=!0){a=c.value,o=!1;let t=a,n=yo(yield I(t.json()),e);n.sdkHttpResponse={headers:t.headers};let r=new Nt;Object.assign(r,n),yield yield I(r)}}catch(e){r={error:e}}finally{try{!o&&!n&&(i=s.return)&&(yield I(i.call(s)))}finally{if(r)throw r.error}}})})}{let i=go(this.apiClient,e);return n=y(`{model}:streamGenerateContent?alt=sse`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.requestStream({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}),t.then(function(t){return Ni(this,arguments,function*(){var n,r,i,a;try{for(var o=!0,s=Pi(t),c;c=yield I(s.next()),n=c.done,!n;o=!0){a=c.value,o=!1;let t=a,n=vo(yield I(t.json()),e);n.sdkHttpResponse={headers:t.headers};let r=new Nt;Object.assign(r,n),yield yield I(r)}}catch(e){r={error:e}}finally{try{!o&&!n&&(i=s.return)&&(yield I(i.call(s)))}finally{if(r)throw r.error}}})})}}async embedContentInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=oo(this.apiClient,e,e);return n=y(Kn(e.model)?`{model}:embedContent`:`{model}:predict`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(t=>{let n=co(t,e),r=new Pt;return Object.assign(r,n),r})}{let i=ao(this.apiClient,e);return n=y(`{model}:batchEmbedContents`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=so(e),n=new Pt;return Object.assign(n,t),n})}}async generateImagesInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=xo(this.apiClient,e);return n=y(`{model}:predict`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=So(e),n=new Ft;return Object.assign(n,t),n})}throw Error(`This method is only supported by the Gemini Enterprise Agent Platform (previously known as Vertex AI).`)}async editImageInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=to(this.apiClient,e);return n=y(`{model}:predict`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=no(e),n=new It;return Object.assign(n,t),n})}throw Error(`This method is only supported by the Gemini Enterprise Agent Platform (previously known as Vertex AI).`)}async upscaleImageInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=Ms(this.apiClient,e);return n=y(`{model}:predict`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=Ns(e),n=new Lt;return Object.assign(n,t),n})}throw Error(`This method is only supported by the Gemini Enterprise Agent Platform (previously known as Vertex AI).`)}async recontextImage(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=ss(this.apiClient,e);return n=y(`{model}:predict`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>{let t=cs(e),n=new Rt;return Object.assign(n,t),n})}throw Error(`This method is only supported by the Gemini Enterprise Agent Platform (previously known as Vertex AI).`)}async segmentImage(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=gs(this.apiClient,e);return n=y(`{model}:predict`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>{let t=_s(e),n=new zt;return Object.assign(n,t),n})}throw Error(`This method is only supported by the Gemini Enterprise Agent Platform (previously known as Vertex AI).`)}async get(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=zo(this.apiClient,e);return n=y(`{name}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>ts(e))}{let i=Ro(this.apiClient,e);return n=y(`{name}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>es(e))}}async listInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=Yo(this.apiClient,e);return n=y(`{models_url}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=Zo(e),n=new Bt;return Object.assign(n,t),n})}{let i=Jo(this.apiClient,e);return n=y(`{models_url}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=Xo(e),n=new Bt;return Object.assign(n,t),n})}}async update(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=As(this.apiClient,e);return n=y(`{model}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`PATCH`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>ts(e))}{let i=ks(this.apiClient,e);return n=y(`{name}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`PATCH`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>es(e))}}async delete(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=Za(this.apiClient,e);return n=y(`{name}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`DELETE`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=$a(e),n=new Vt;return Object.assign(n,t),n})}{let i=Xa(this.apiClient,e);return n=y(`{name}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`DELETE`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=Qa(e),n=new Vt;return Object.assign(n,t),n})}}async countTokens(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=qa(this.apiClient,e);return n=y(`{model}:countTokens`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=Ya(e),n=new Ht;return Object.assign(n,t),n})}{let i=Ka(this.apiClient,e);return n=y(`{model}:countTokens`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=Ja(e),n=new Ht;return Object.assign(n,t),n})}}async computeTokens(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=Ia(this.apiClient,e);return n=y(`{model}:computeTokens`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=La(e),n=new Ut;return Object.assign(n,t),n})}throw Error(`This method is only supported by the Gemini Enterprise Agent Platform (previously known as Vertex AI).`)}async generateVideosInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=Oo(this.apiClient,e);return n=y(`{model}:predictLongRunning`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>{let t=Eo(e),n=new Wt;return Object.assign(n,t),n})}{let i=Do(this.apiClient,e);return n=y(`{model}:predictLongRunning`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>{let t=To(e),n=new Wt;return Object.assign(n,t),n})}}};qc.loggedGenerateImagesWarning=!1,qc.loggedEditImageWarning=!1,qc.loggedGenerateVideosWarning=!1;var Jc=class extends v{constructor(e){super(),this.apiClient=e}async getVideosOperation(e){let t=e.operation,n=e.config;if(t.name===void 0||t.name===``)throw Error(`Operation name is required.`);if(this.apiClient.isVertexAI()){let e=t.name.split(`/operations/`)[0],r;n&&`httpOptions`in n&&(r=n.httpOptions);let i=await this.fetchPredictVideosOperationInternal({operationName:t.name,resourceName:e,config:{httpOptions:r}});return t._fromAPIResponse({apiResponse:i,_isVertexAI:!0})}{let e=await this.getVideosOperationInternal({operationName:t.name,config:n});return t._fromAPIResponse({apiResponse:e,_isVertexAI:!1})}}async get(e){let t=e.operation,n=e.config;if(t.name===void 0||t.name===``)throw Error(`Operation name is required.`);if(this.apiClient.isVertexAI()){let e=t.name.split(`/operations/`)[0],r;n&&`httpOptions`in n&&(r=n.httpOptions);let i=await this.fetchPredictVideosOperationInternal({operationName:t.name,resourceName:e,config:{httpOptions:r}});return t._fromAPIResponse({apiResponse:i,_isVertexAI:!0})}{let e=await this.getVideosOperationInternal({operationName:t.name,config:n});return t._fromAPIResponse({apiResponse:e,_isVertexAI:!1})}}async getVideosOperationInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=ne(e);return n=y(`{operationName}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t}{let i=te(e);return n=y(`{operationName}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t}}async fetchPredictVideosOperationInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=T(e);return n=y(`{resourceName}:fetchPredictOperation`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t}throw Error(`This method is only supported by the Gemini Enterprise Agent Platform (previously known as Vertex AI).`)}};function Yc(e){let t={},n=x(e,[`apiKey`]);if(n!=null&&b(t,[`apiKey`],n),x(e,[`apiKeyConfig`])!==void 0)throw Error(`apiKeyConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);if(x(e,[`authType`])!==void 0)throw Error(`authType parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);if(x(e,[`googleServiceAccountConfig`])!==void 0)throw Error(`googleServiceAccountConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);if(x(e,[`httpBasicAuthConfig`])!==void 0)throw Error(`httpBasicAuthConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);if(x(e,[`oauthConfig`])!==void 0)throw Error(`oauthConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);if(x(e,[`oidcConfig`])!==void 0)throw Error(`oidcConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);return t}function Xc(e){let t={},n=x(e,[`data`]);if(n!=null&&b(t,[`data`],n),x(e,[`displayName`])!==void 0)throw Error(`displayName parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);let r=x(e,[`mimeType`]);return r!=null&&b(t,[`mimeType`],r),t}function Zc(e){let t={},n=x(e,[`parts`]);if(n!=null){let e=n;Array.isArray(e)&&(e=e.map(e=>ol(e))),b(t,[`parts`],e)}let r=x(e,[`role`]);return r!=null&&b(t,[`role`],r),t}function Qc(e,t,n){let r={},i=x(t,[`expireTime`]);n!==void 0&&i!=null&&b(n,[`expireTime`],i);let a=x(t,[`newSessionExpireTime`]);n!==void 0&&a!=null&&b(n,[`newSessionExpireTime`],a);let o=x(t,[`uses`]);n!==void 0&&o!=null&&b(n,[`uses`],o);let s=x(t,[`liveConnectConstraints`]);n!==void 0&&s!=null&&b(n,[`bidiGenerateContentSetup`],al(e,s));let c=x(t,[`lockAdditionalFields`]);return n!==void 0&&c!=null&&b(n,[`fieldMask`],c),r}function $c(e,t){let n={},r=x(t,[`config`]);return r!=null&&b(n,[`config`],Qc(e,r,n)),n}function el(e){let t={};if(x(e,[`displayName`])!==void 0)throw Error(`displayName parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);let n=x(e,[`fileUri`]);n!=null&&b(t,[`fileUri`],n);let r=x(e,[`mimeType`]);return r!=null&&b(t,[`mimeType`],r),t}function tl(e){let t={},n=x(e,[`args`]);n!=null&&b(t,[`args`],n);let r=x(e,[`id`]);r!=null&&b(t,[`id`],r);let i=x(e,[`name`]);if(i!=null&&b(t,[`name`],i),x(e,[`partialArgs`])!==void 0)throw Error(`partialArgs parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);if(x(e,[`willContinue`])!==void 0)throw Error(`willContinue parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);return t}function nl(e){let t={},n=x(e,[`authConfig`]);n!=null&&b(t,[`authConfig`],Yc(n));let r=x(e,[`enableWidget`]);if(r!=null&&b(t,[`enableWidget`],r),x(e,[`groundingTypes`])!==void 0)throw Error(`groundingTypes parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);return t}function rl(e){let t={};if(x(e,[`blockingConfidence`])!==void 0)throw Error(`blockingConfidence parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);if(x(e,[`excludeDomains`])!==void 0)throw Error(`excludeDomains parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);let n=x(e,[`searchTypes`]);n!=null&&b(t,[`searchTypes`],n);let r=x(e,[`timeRangeFilter`]);return r!=null&&b(t,[`timeRangeFilter`],r),t}function il(e,t){let n={},r=x(e,[`generationConfig`]);t!==void 0&&r!=null&&b(t,[`setup`,`generationConfig`],r);let i=x(e,[`responseModalities`]);t!==void 0&&i!=null&&b(t,[`setup`,`generationConfig`,`responseModalities`],i);let a=x(e,[`temperature`]);t!==void 0&&a!=null&&b(t,[`setup`,`generationConfig`,`temperature`],a);let o=x(e,[`topP`]);t!==void 0&&o!=null&&b(t,[`setup`,`generationConfig`,`topP`],o);let s=x(e,[`topK`]);t!==void 0&&s!=null&&b(t,[`setup`,`generationConfig`,`topK`],s);let c=x(e,[`maxOutputTokens`]);t!==void 0&&c!=null&&b(t,[`setup`,`generationConfig`,`maxOutputTokens`],c);let l=x(e,[`mediaResolution`]);t!==void 0&&l!=null&&b(t,[`setup`,`generationConfig`,`mediaResolution`],l);let u=x(e,[`seed`]);t!==void 0&&u!=null&&b(t,[`setup`,`generationConfig`,`seed`],u);let d=x(e,[`speechConfig`]);t!==void 0&&d!=null&&b(t,[`setup`,`generationConfig`,`speechConfig`],Tn(d));let f=x(e,[`thinkingConfig`]);t!==void 0&&f!=null&&b(t,[`setup`,`generationConfig`,`thinkingConfig`],f);let p=x(e,[`enableAffectiveDialog`]);t!==void 0&&p!=null&&b(t,[`setup`,`generationConfig`,`enableAffectiveDialog`],p);let m=x(e,[`systemInstruction`]);t!==void 0&&m!=null&&b(t,[`setup`,`systemInstruction`],Zc(N(m)));let h=x(e,[`tools`]);if(t!==void 0&&h!=null){let e=Dn(h);Array.isArray(e)&&(e=e.map(e=>ll(En(e)))),b(t,[`setup`,`tools`],e)}let g=x(e,[`sessionResumption`]);t!==void 0&&g!=null&&b(t,[`setup`,`sessionResumption`],cl(g));let _=x(e,[`inputAudioTranscription`]);t!==void 0&&_!=null&&b(t,[`setup`,`inputAudioTranscription`],_);let v=x(e,[`outputAudioTranscription`]);t!==void 0&&v!=null&&b(t,[`setup`,`outputAudioTranscription`],v);let y=x(e,[`realtimeInputConfig`]);t!==void 0&&y!=null&&b(t,[`setup`,`realtimeInputConfig`],y);let S=x(e,[`contextWindowCompression`]);t!==void 0&&S!=null&&b(t,[`setup`,`contextWindowCompression`],S);let C=x(e,[`proactivity`]);if(t!==void 0&&C!=null&&b(t,[`setup`,`proactivity`],C),x(e,[`explicitVadSignal`])!==void 0)throw Error(`explicitVadSignal parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);let w=x(e,[`avatarConfig`]);t!==void 0&&w!=null&&b(t,[`setup`,`avatarConfig`],w);let T=x(e,[`safetySettings`]);if(t!==void 0&&T!=null){let e=T;Array.isArray(e)&&(e=e.map(e=>sl(e))),b(t,[`setup`,`safetySettings`],e)}let E=x(e,[`translationConfig`]);return t!==void 0&&E!=null&&b(t,[`setup`,`generationConfig`,`translationConfig`],E),n}function al(e,t){let n={},r=x(t,[`model`]);r!=null&&b(n,[`setup`,`model`],M(e,r));let i=x(t,[`config`]);return i!=null&&b(n,[`config`],il(i,n)),n}function ol(e){let t={},n=x(e,[`mediaResolution`]);n!=null&&b(t,[`mediaResolution`],n);let r=x(e,[`toolCall`]);r!=null&&b(t,[`toolCall`],r);let i=x(e,[`toolResponse`]);i!=null&&b(t,[`toolResponse`],i);let a=x(e,[`audioTranscription`]);a!=null&&b(t,[`audioTranscription`],a);let o=x(e,[`codeExecutionResult`]);o!=null&&b(t,[`codeExecutionResult`],o);let s=x(e,[`executableCode`]);s!=null&&b(t,[`executableCode`],s);let c=x(e,[`fileData`]);c!=null&&b(t,[`fileData`],el(c));let l=x(e,[`functionCall`]);l!=null&&b(t,[`functionCall`],tl(l));let u=x(e,[`functionResponse`]);u!=null&&b(t,[`functionResponse`],u);let d=x(e,[`inlineData`]);d!=null&&b(t,[`inlineData`],Xc(d));let f=x(e,[`text`]);f!=null&&b(t,[`text`],f);let p=x(e,[`thought`]);p!=null&&b(t,[`thought`],p);let m=x(e,[`thoughtSignature`]);m!=null&&b(t,[`thoughtSignature`],m);let h=x(e,[`videoMetadata`]);h!=null&&b(t,[`videoMetadata`],h);let g=x(e,[`partMetadata`]);g!=null&&b(t,[`partMetadata`],g);let _=x(e,[`mediaProcessing`]);return _!=null&&b(t,[`mediaProcessing`],_),t}function sl(e){let t={},n=x(e,[`category`]);if(n!=null&&b(t,[`category`],n),x(e,[`method`])!==void 0)throw Error(`method parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);let r=x(e,[`threshold`]);return r!=null&&b(t,[`threshold`],r),t}function cl(e){let t={},n=x(e,[`handle`]);if(n!=null&&b(t,[`handle`],n),x(e,[`transparent`])!==void 0)throw Error(`transparent parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);return t}function ll(e){let t={};if(x(e,[`retrieval`])!==void 0)throw Error(`retrieval parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);let n=x(e,[`googleMaps`]);n!=null&&b(t,[`googleMaps`],nl(n));let r=x(e,[`mcpServers`]);if(r!=null){let e=r;Array.isArray(e)&&(e=e.map(e=>e)),b(t,[`mcpServers`],e)}let i=x(e,[`codeExecution`]);i!=null&&b(t,[`codeExecution`],i);let a=x(e,[`computerUse`]);if(a!=null&&b(t,[`computerUse`],a),x(e,[`enterpriseWebSearch`])!==void 0)throw Error(`enterpriseWebSearch parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);if(x(e,[`exaAiSearch`])!==void 0)throw Error(`exaAiSearch parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);let o=x(e,[`functionDeclarations`]);if(o!=null){let e=o;Array.isArray(e)&&(e=e.map(e=>e)),b(t,[`functionDeclarations`],e)}let s=x(e,[`googleSearch`]);s!=null&&b(t,[`googleSearch`],rl(s));let c=x(e,[`googleSearchRetrieval`]);if(c!=null&&b(t,[`googleSearchRetrieval`],c),x(e,[`parallelAiSearch`])!==void 0)throw Error(`parallelAiSearch parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);let l=x(e,[`urlContext`]);l!=null&&b(t,[`urlContext`],l);let u=x(e,[`fileSearch`]);return u!=null&&b(t,[`fileSearch`],u),t}function ul(e){let t=[];for(let n in e)if(Object.prototype.hasOwnProperty.call(e,n)){let r=e[n];if(typeof r==`object`&&r&&Object.keys(r).length>0){let e=Object.keys(r).map(e=>`${n}.${e}`);t.push(...e)}else t.push(n)}return t.join(`,`)}function dl(e,t){let n=null,r=e.bidiGenerateContentSetup;if(typeof r==`object`&&r&&`setup`in r){let t=r.setup;typeof t==`object`&&t?(e.bidiGenerateContentSetup=t,n=t):delete e.bidiGenerateContentSetup}else r!==void 0&&delete e.bidiGenerateContentSetup;let i=e.fieldMask;if(n){let r=ul(n);if(Array.isArray(t?.lockAdditionalFields)&&t?.lockAdditionalFields.length===0)r?e.fieldMask=r:delete e.fieldMask;else if(t?.lockAdditionalFields&&t.lockAdditionalFields.length>0&&i!==null&&Array.isArray(i)&&i.length>0){let t=[`temperature`,`topK`,`topP`,`maxOutputTokens`,`responseModalities`,`seed`,`speechConfig`],n=[];i.length>0&&(n=i.map(e=>t.includes(e)?`generationConfig.${e}`:e));let a=[];r&&a.push(r),n.length>0&&a.push(...n),a.length>0?e.fieldMask=a.join(`,`):delete e.fieldMask}else delete e.fieldMask}else i!==null&&Array.isArray(i)&&i.length>0?e.fieldMask=i.join(`,`):delete e.fieldMask;return e}var fl=class extends v{constructor(e){super(),this.apiClient=e}async create(e){let t,n=``,r={};if(this.apiClient.isVertexAI())throw Error(`The client.tokens.create method is only supported by the Gemini Developer API.`);{let i=$c(this.apiClient,e);n=y(`auth_tokens`,i._url),r=i._query,delete i.config,delete i._url,delete i._query;let a=dl(i,e.config);return t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(a),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>e)}}};function pl(e,t){let n={},r=x(e,[`force`]);return t!==void 0&&r!=null&&b(t,[`_query`,`force`],r),n}function ml(e){let t={},n=x(e,[`name`]);n!=null&&b(t,[`_url`,`name`],n);let r=x(e,[`config`]);return r!=null&&pl(r,t),t}function hl(e){let t={},n=x(e,[`name`]);return n!=null&&b(t,[`_url`,`name`],n),t}function gl(e,t){let n={},r=x(e,[`pageSize`]);t!==void 0&&r!=null&&b(t,[`_query`,`pageSize`],r);let i=x(e,[`pageToken`]);return t!==void 0&&i!=null&&b(t,[`_query`,`pageToken`],i),n}function _l(e){let t={},n=x(e,[`parent`]);n!=null&&b(t,[`_url`,`parent`],n);let r=x(e,[`config`]);return r!=null&&gl(r,t),t}function vl(e){let t={},n=x(e,[`sdkHttpResponse`]);n!=null&&b(t,[`sdkHttpResponse`],n);let r=x(e,[`nextPageToken`]);r!=null&&b(t,[`nextPageToken`],r);let i=x(e,[`documents`]);if(i!=null){let e=i;Array.isArray(e)&&(e=e.map(e=>e)),b(t,[`documents`],e)}return t}var yl=class extends v{constructor(e){super(),this.apiClient=e,this.list=async e=>new Kr(Gr.PAGED_ITEM_DOCUMENTS,t=>this.listInternal({parent:e.parent,config:t.config}),await this.listInternal(e),e)}async get(e){let t,n=``,r={};if(this.apiClient.isVertexAI())throw Error(`This method is only supported by the Gemini Developer API.`);{let i=hl(e);return n=y(`{name}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>e)}}async delete(e){let t=``,n={};if(this.apiClient.isVertexAI())throw Error(`This method is only supported by the Gemini Developer API.`);{let r=ml(e);t=y(`{name}`,r._url),n=r._query,delete r._url,delete r._query,await this.apiClient.request({path:t,queryParams:n,body:JSON.stringify(r),httpMethod:`DELETE`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal})}}async listInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI())throw Error(`This method is only supported by the Gemini Developer API.`);{let i=_l(e);return n=y(`{parent}/documents`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>{let t=vl(e),n=new Xt;return Object.assign(n,t),n})}}},bl=class extends v{constructor(e,t=new yl(e)){super(),this.apiClient=e,this.documents=t,this.list=async(e={})=>new Kr(Gr.PAGED_ITEM_FILE_SEARCH_STORES,e=>this.listInternal(e),await this.listInternal(e),e)}async uploadToFileSearchStore(e){if(this.apiClient.isVertexAI())throw Error(`Gemini Enterprise Agent Platform (previously known as Vertex AI) does not support uploading files to a file search store.`);return this.apiClient.uploadFileToFileSearchStore(e.fileSearchStoreName,e.file,e.config)}async downloadMedia(e,t){if(this.apiClient.isVertexAI())throw Error(`This method is only supported in the Gemini Developer client.`);let n=new URL(e,`http://dummy.com`),r=n.pathname;if(r.startsWith(`/`)&&(r=r.slice(1)),!r.includes(`/media/`))throw Error(`Invalid uri format: ${e}. Expected to contain /media/`);let i={};n.searchParams.forEach((e,t)=>{i[t]=e}),i.alt=`media`;let a=Object.assign({},t?.httpOptions),o=await this.apiClient.request({path:r,httpMethod:`GET`,queryParams:i,httpOptions:a});if(o instanceof Mt){let e=await o.responseInternal.arrayBuffer();return new Uint8Array(e)}throw Error(`Unexpected response type from downloadMedia`)}async create(e){let t,n=``,r={};if(this.apiClient.isVertexAI())throw Error(`This method is only supported by the Gemini Developer API.`);{let i=Us(this.apiClient,e);return n=y(`fileSearchStores`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>e)}}async get(e){let t,n=``,r={};if(this.apiClient.isVertexAI())throw Error(`This method is only supported by the Gemini Developer API.`);{let i=Ks(e);return n=y(`{name}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>e)}}async delete(e){let t=``,n={};if(this.apiClient.isVertexAI())throw Error(`This method is only supported by the Gemini Developer API.`);{let r=Gs(e);t=y(`{name}`,r._url),n=r._query,delete r._url,delete r._query,await this.apiClient.request({path:t,queryParams:n,body:JSON.stringify(r),httpMethod:`DELETE`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal})}}async listInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI())throw Error(`This method is only supported by the Gemini Developer API.`);{let i=Qs(e);return n=y(`fileSearchStores`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>{let t=$s(e),n=new Zt;return Object.assign(n,t),n})}}async uploadToFileSearchStoreInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI())throw Error(`This method is only supported by the Gemini Developer API.`);{let i=tc(e);return n=y(`upload/v1beta/{file_search_store_name}:uploadToFileSearchStore`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>{let t=nc(e),n=new Qt;return Object.assign(n,t),n})}}async importFile(e){let t,n=``,r={};if(this.apiClient.isVertexAI())throw Error(`This method is only supported by the Gemini Developer API.`);{let i=Ys(e);return n=y(`{file_search_store_name}:importFile`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>{let t=Js(e),n=new $t;return Object.assign(n,t),n})}}};function xl(){return`Deno`in globalThis}var Sl=void 0;function Cl(){var e;if(Sl)return Sl;let t=globalThis,n={};return n=xl()?((e=t.Deno?.env)?.toObject)?.call(e)??{}:t.process?.env??{},Sl=n,Sl}function wl(e){let t=Object.assign({},e),n=Cl();return n.GOOGLE_GENAI_API_VERSION!==void 0&&(t.api_version??=n.GOOGLE_GENAI_API_VERSION),n.GOOGLE_GENAI_USER_PROJECT!==void 0&&(t.user_project??=n.GOOGLE_GENAI_USER_PROJECT),t}var Tl=class{constructor(e){this.options=e}getDefaultHeaders(){return this.options.defaultHeaders}async resolveGoogleGenAISecurity(e){return jl(await this.options.getAuthHeaders(e))}},El=class{beforeCreateRequest(e,t){return Object.assign(Object.assign({},t),{url:Dl(t.url)})}async beforeRequest(e,t){if(Ml(t.headers,kl(e.security_source)),Nl(e,t.headers),Fl(t.headers))return t;let n=await Ol(e.security_source,t.url);return Ml(t.headers,n?.default_headers),Pl(t.headers,n),t}};function Dl(e){let[,t,...n]=e.pathname.split(`/`);if(!t)return e;let r=decodeURIComponent(t);if(!r.includes(`/`))return e;let i=new URL(e);return i.pathname=`/${r}/${n.join(`/`)}`,i}async function Ol(e,t){if(Rl(e))return e.resolveGoogleGenAISecurity(t);let n=typeof e==`function`?await e():e;return Ll(n)?Al(n):Al(void 0)}function kl(e){if(Rl(e))return e.getDefaultHeaders?.call(e)??e.defaultHeaders;if(Ll(e))return e.default_headers}function Al(e){let t=Cl(),n=Object.assign(Object.assign({},e),{api_key:e?.api_key??t.GOOGLE_GENAI_API_KEY,access_token:e?.access_token??t.GOOGLE_GENAI_ACCESS_TOKEN});return zl(n)?n:void 0}function jl(e){let t={};for(let[n,r]of e){let e=n.toLowerCase();e!==`authorization`&&e!==`x-goog-api-key`&&(t[n]=r)}let n={access_token:e.get(`authorization`)??void 0,api_key:e.get(`x-goog-api-key`)??void 0,default_headers:Object.keys(t).length?t:void 0};return zl(n)?n:void 0}function Ml(e,t){if(t)for(let[n,r]of new Headers(t))e.get(n)===null&&e.set(n,r)}function Nl(e,t){e.options.user_project!==void 0&&t.get(`x-goog-user-project`)===null&&t.set(`x-goog-user-project`,e.options.user_project)}function Pl(e,t){if(t){if(t.api_key){e.set(`x-goog-api-key`,t.api_key);return}t.access_token&&e.set(`Authorization`,Il(t.access_token))}}function Fl(e){return e.get(`authorization`)!==null||e.get(`x-goog-api-key`)!==null}function Il(e){return e.slice(0,7).toLowerCase()===`bearer `?e:`Bearer ${e}`}function Ll(e){return typeof e==`object`&&!!e}function Rl(e){return typeof e==`object`&&!!e&&`resolveGoogleGenAISecurity`in e&&typeof e.resolveGoogleGenAISecurity==`function`}function zl(e){return e.api_key!==void 0||e.access_token!==void 0||e.default_headers!==void 0}var Bl=class extends Error{constructor(e,t){let n=e;t?.cause&&(n+=`: ${t.cause}`),super(n,t),this.name=`HTTPClientError`,this.cause===void 0&&(this.cause=t?.cause)}},Vl=class extends Bl{constructor(){super(...arguments),this.name=`UnexpectedClientError`}},Hl=class extends Bl{constructor(){super(...arguments),this.name=`InvalidRequestError`}},Ul=class extends Bl{constructor(){super(...arguments),this.name=`RequestAbortedError`}},Wl=class extends Bl{constructor(){super(...arguments),this.name=`RequestTimeoutError`}},Gl=class extends Bl{constructor(){super(...arguments),this.name=`ConnectionError`}},Kl=class extends Error{constructor(e,t){super(e),this.statusCode=t?.response?.status,this.body=t?.body??``,this.headers=t?.response?.headers,this.contentType=(t?.response)?.headers.get(`content-type`)||``,this.rawResponse=t?.response,this.name=`GoogleGenAiError`}},ql=class extends Error{},R=class e extends ql{constructor(t,n,r,i){super(e.makeMessage(t,n,r)),this.status=t,this.headers=i,this.error=n,this.statusCode=t,this.body=uu(n),this.contentType=i?.get(`content-type`)||``,this.rawResponse=void 0,this.cause=void 0,this.name=this.constructor.name,Object.setPrototypeOf(this,new.target.prototype)}static makeMessage(e,t,n){let r=t&&du(t)&&typeof t.message==`string`?t.message:void 0,i=uu(t),a=r??n??(i||`An error occurred`);return`${e?`${e} `:``}${a}`}static generate(t,n,r,i){return!t||!i?new Yl({message:r,cause:n instanceof Error?n:void 0}):t===400?new Zl(t,n,r,i):t===401?new Ql(t,n,r,i):t===403?new $l(t,n,r,i):t===404?new eu(t,n,r,i):t===409?new tu(t,n,r,i):t===422?new nu(t,n,r,i):t===429?new ru(t,n,r,i):t>=500?new iu(t,n,r,i):new e(t,n,r,i)}},Jl=class extends R{constructor({message:e}={}){super(void 0,void 0,e||`Request was aborted.`,void 0)}},Yl=class extends R{constructor({message:e,cause:t}){super(void 0,void 0,e||`Connection error.`,void 0),this.cause=t}},Xl=class extends Yl{constructor({message:e}={}){super({message:e||"Request timed out. This is a client-side timeout. You can increase the timeout by setting the `timeout` argument in your request or client http options."})}},Zl=class extends R{},Ql=class extends R{},$l=class extends R{},eu=class extends R{},tu=class extends R{},nu=class extends R{},ru=class extends R{},iu=class extends R{};function au(e){return fu(e)?e:e instanceof Kl?ou(e):e instanceof Bl?su(e):e}function ou(e){let t=cu(e),n=R.generate(e.statusCode,t,e.message,e.headers);return pu(n,`body`,e.body),pu(n,`contentType`,e.contentType),pu(n,`rawResponse`,e.rawResponse),pu(n,`statusCode`,e.statusCode),pu(n,`cause`,e),n}function su(e){return e instanceof Wl?new Xl({message:e.message}):e instanceof Ul?new Jl({message:e.message}):(e instanceof Gl,new Yl({message:e.message,cause:e}))}function cu(e){let t=lu(e,`data$`);if(t&&typeof t==`object`)return t;try{let t=JSON.parse(e.body);if(t&&typeof t==`object`)return t}catch{}let n=lu(e,`error`);return n&&typeof n==`object`?n:void 0}function lu(e,t){return e&&typeof e==`object`?e[t]:void 0}function uu(e){if(!e)return``;try{return JSON.stringify(e)}catch{return String(e)}}function du(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function fu(e){return typeof e==`object`&&e?R.prototype.isPrototypeOf(e):!1}function pu(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!0,value:n,writable:!1})}function mu(e){let t=new El;e.registerBeforeCreateRequestHook(t),e.registerBeforeRequestHook(t)}var hu=class{constructor(){this.sdkInitHooks=[],this.beforeCreateRequestHooks=[],this.beforeRequestHooks=[],this.afterSuccessHooks=[],this.afterErrorHooks=[];for(let e of[])`sdkInit`in e&&this.registerSDKInitHook(e),`beforeCreateRequest`in e&&this.registerBeforeCreateRequestHook(e),`beforeRequest`in e&&this.registerBeforeRequestHook(e),`afterSuccess`in e&&this.registerAfterSuccessHook(e),`afterError`in e&&this.registerAfterErrorHook(e);mu(this)}registerSDKInitHook(e){this.sdkInitHooks.push(e)}registerBeforeCreateRequestHook(e){this.beforeCreateRequestHooks.push(e)}registerBeforeRequestHook(e){this.beforeRequestHooks.push(e)}registerAfterSuccessHook(e){this.afterSuccessHooks.push(e)}registerAfterErrorHook(e){this.afterErrorHooks.push(e)}sdkInit(e){return this.sdkInitHooks.reduce((e,t)=>t.sdkInit(e),e)}beforeCreateRequest(e,t){let n=t;for(let t of this.beforeCreateRequestHooks)n=t.beforeCreateRequest(e,n);return n}async beforeRequest(e,t){let n=t;for(let t of this.beforeRequestHooks)n=await t.beforeRequest(e,n);return n}async afterSuccess(e,t){let n=t;for(let t of this.afterSuccessHooks)n=await t.afterSuccess(e,n);return n}async afterError(e,t,n){let r=t,i=n;for(let t of this.afterErrorHooks){let n=await t.afterError(e,r,i);r=n.response,i=n.error}return{response:r,error:i}}};function gu(e){return{ok:!0,value:e}}function _u(e){return{ok:!1,error:e}}function vu(e){return btoa(String.fromCodePoint(...e))}function yu(e){return new TextEncoder().encode(e)}function bu(e){return vu(yu(e))}var xu=Object.prototype.hasOwnProperty;function z(e,t){let n=/\{([a-zA-Z0-9_][a-zA-Z0-9_-]*?)\}/g;return function(t={}){return e.replace(n,function(e,n){if(!xu.call(t,n))throw Error(`Parameter '${n}' is required`);let r=t[n];if(typeof r!=`string`&&typeof r!=`number`)throw Error(`Parameter '${n}' must be a string or number`);return`${r}`}).replace(/^\/+/,``)}}var Su=[`https://generativelanguage.googleapis.com`];function Cu(e){let t=e.server_url,n={};if(!t){let n=e.server_idx??0;if(n<0||n>=Su.length)throw Error(`Invalid server index ${n}`);t=Su[n]||``}let r=z(t)(n);return new URL(r)}var wu={userAgent:`speakeasy-sdk/typescript 2.4.1-preview.4 internal v1beta @google/genai`};function Tu(...e){let t=[];for(let n of e)n&&t.push(n);switch(t.length){case 0:case 1:return t[0]||null;default:return`any`in AbortSignal&&typeof AbortSignal.any==`function`?AbortSignal.any(t):Eu(t)}}function Eu(e){let t=new AbortController,n=t.signal;if(!e.length)return t.signal;if(e.length===1)return e[0]||t.signal;for(let t of e)if(t.aborted)return t;function r(){t.abort(this.reason),a()}let i=[];function a(){for(let e of i){let t=e.deref();t&&t.removeEventListener(`abort`,r)}}for(let t of e)i.push(new WeakRef(t)),t.addEventListener(`abort`,r);return n}function B(e){let t={};for(let[n,r]of Object.entries(e))r!==void 0&&(t[n]=r);return t}function Du(e){if(typeof e!=`object`||!e||Object.prototype.toString.call(e)!==`[object Object]`)return!1;let t=Object.getPrototypeOf(e);if(t===null||t===Object.prototype)return!0;try{return Object.getPrototypeOf(t)===null}catch{return!1}}function Ou(e){return(t,n,r)=>{let i=``,a=r?.explode?ju(t,n):[[t,n]];if(a.every(([e,t])=>t==null))return;let o=e=>r?.charEncoding===`percent`?encodeURIComponent(e):e,s=e=>o(Mu(e)),c=o(e);return a.forEach(([e,t])=>{let n=``,r=null;t!=null&&(r=Array.isArray(t)?Pu(t,e=>`${s(e)}`)?.join(c):Du(t)?Fu(Object.entries(t),([e,t])=>`${o(e)}${c}${s(t)}`)?.join(c):`${s(t)}`,r!=null&&(n=`${o(e)}=${r}`,!(!n||n===`=`)&&(i+=`&${n}`)))}),i.slice(1)}}var ku=Ou(`,`);function Au(e,t,n){if(t===void 0)return;let r=e=>n?.charEncoding===`percent`?encodeURIComponent(e):e,i=r(JSON.stringify(t,Nu));return n?.explode?i:`${r(e)}=${i}`}var V=(e,t,n)=>{let r=``,i=n?.explode?ju(e,t):[[e,t]];if(i.every(([e,t])=>t==null))return;let a=e=>n?.charEncoding===`percent`?encodeURIComponent(e):e,o=e=>a(Mu(e));return i.forEach(([e,i])=>{let s=``;i!=null&&(s=Array.isArray(i)?Pu(i,e=>`${o(e)}`)?.join(`,`):Du(i)?Fu(Object.entries(i),([e,t])=>`,${a(e)},${o(t)}`)?.join(``).slice(1):`${n?.explode&&Du(t)?`${e}=`:``}${o(i)}`,r+=s?`,${s}`:``)}),r.slice(1)};function ju(e,t){return Array.isArray(t)?t.map(t=>[e,t]):Du(t)?Object.entries(t??{}).map(([e,t])=>[e,t]):[[e,t]]}function Mu(e){return e==null?``:e instanceof Date?e.toISOString():e instanceof Uint8Array?vu(e):typeof e==`object`?JSON.stringify(e,Nu):`${e}`}function Nu(e,t){return t instanceof Uint8Array?vu(t):t}function Pu(e,t){let n=e.reduce((e,n)=>{if(n==null)return e;let r=t(n);return r==null||e.push(r),e},[]);return n.length?n:null}function Fu(e,t){let n=[];for(let[r,i]of e){if(i==null)continue;let e=t([r,i]);e!=null&&n.push(e)}return n.length?n:null}function Iu(...e){return e.filter(Boolean).join(`&`)}function Lu(e){return function(t,n){let r=Object.assign(Object.assign({},n),{explode:n?.explode??!0,charEncoding:n?.charEncoding??`percent`}),i=new Set(n?.allowEmptyValue??[]);return Iu(...Object.entries(t).map(([t,n])=>i.has(t)&&(n==null||n===``||Array.isArray(n)&&n.length===0)?`${encodeURIComponent(t)}=`:e(t,n,r)))}}var Ru=Lu(ku),zu=(e,t)=>t==null?fetch(e):fetch(e,t),Bu=class e{constructor(e={}){this.requestHooks=[],this.requestErrorHooks=[],this.responseHooks=[],this.options=e,this.fetcher=e.fetcher||zu}async request(e){let t=e;for(let e of this.requestHooks){let n=await e(t);n&&(t=n)}try{let e=await this.fetcher(t);for(let n of this.responseHooks)await n(e,t);return e}catch(e){for(let n of this.requestErrorHooks)await n(e,t);throw e}}addHook(...e){if(e[0]===`beforeRequest`)this.requestHooks.push(e[1]);else if(e[0]===`requestError`)this.requestErrorHooks.push(e[1]);else if(e[0]===`response`)this.responseHooks.push(e[1]);else throw Error(`Invalid hook type: ${e[0]}`);return this}removeHook(...e){let t;if(e[0]===`beforeRequest`)t=this.requestHooks;else if(e[0]===`requestError`)t=this.requestErrorHooks;else if(e[0]===`response`)t=this.responseHooks;else throw Error(`Invalid hook type: ${e[0]}`);let n=t.findIndex(t=>t===e[1]);return n>=0&&t.splice(n,1),this}clone(){let t=new e(this.options);return t.requestHooks=this.requestHooks.slice(),t.requestErrorHooks=this.requestErrorHooks.slice(),t.responseHooks=this.responseHooks.slice(),t}},Vu=/\s*;\s*/g;function Hu(e,t){if(t===`*`)return!0;let n=e.headers.get(`content-type`)?.trim()||`application/octet-stream`;n=n.toLowerCase();let[r=``,...i]=t.toLowerCase().trim().split(Vu);if(r.split(`/`).length!==2)return!1;let[a=``,...o]=n.split(Vu),[s=``,c=``]=a.split(`/`);if(!s||!c||r!==`*/*`&&a!==r&&`${s}/*`!==r&&`*/${c}`!==r||o.length<i.length)return!1;let l=new Set(o);for(let e of i)if(!l.has(e))return!1;return!0}var Uu=RegExp(`^[0-9]xx$`,`i`);function H(e,t){let n=`${e.status}`,r=Array.isArray(t)?t:[t];return r.length?r.some(e=>{let t=`${e}`;if(t==="default")return!0;if(!Uu.test(`${t}`))return t===n;let r=t.charAt(0);if(!r)throw Error(`Invalid status code range`);let i=n.charAt(0);if(!i)throw Error(`Invalid response status code: ${n}`);return i===r}):!1}function Wu(e,t,n){return H(e,t)&&Hu(e,n)}function Gu(e){if(typeof e!=`object`||!e)return!1;let t=e instanceof TypeError&&e.message.toLowerCase().startsWith(`failed to fetch`),n=e instanceof TypeError&&e.message.toLowerCase().startsWith(`fetch failed`),r=`name`in e&&e.name===`ConnectionError`,i=`code`in e&&typeof e.code==`string`&&e.code.toLowerCase()===`econnreset`;return t||n||i||r}function Ku(e){if(typeof e!=`object`||!e)return!1;let t=`name`in e&&e.name===`TimeoutError`,n=`code`in e&&e.code===23,r=`code`in e&&typeof e.code==`string`&&e.code.toLowerCase()===`econnaborted`;return t||n||r}function qu(e){if(typeof e!=`object`||!e)return!1;let t=`name`in e&&e.name===`AbortError`,n=`code`in e&&e.code===20,r=`code`in e&&typeof e.code==`string`&&e.code.toLowerCase()===`econnaborted`;return t||n||r}var Ju={initialInterval:500,maxInterval:6e4,exponent:1.5,maxElapsedTime:36e5},Yu=class e extends Error{constructor(t,n){let r=t;n?.cause&&(r+=`: ${n.cause}`),super(r,n),this.name=`PermanentError`,this.cause===void 0&&(this.cause=n?.cause),Object.setPrototypeOf(this,e.prototype)}},Xu=class e extends Error{constructor(t,n){super(t),this.response=n,this.name=`TemporaryError`,Object.setPrototypeOf(this,e.prototype)}};async function Zu(e,t){switch(t.config.strategy){case`backoff`:return td(Qu(e,{statusCodes:t.statusCodes,retryConnectionErrors:!!t.config.retryConnectionErrors}),t.config.backoff??Ju);case`attempt-count-backoff`:return nd(Qu(e,{statusCodes:t.statusCodes,retryConnectionErrors:!!t.config.retryConnectionErrors}),Object.assign(Object.assign({},Ju),t.config.backoff),t.config);default:return await e(0)}}function Qu(e,t){return async n=>{try{let r=await e(n);if(ed(r,t.statusCodes))throw new Xu(`Response failed with retryable status code`,r);return r}catch(e){throw e instanceof Xu||t.retryConnectionErrors&&(Ku(e)||Gu(e))?e:new Yu(`Permanent error`,{cause:e})}}}var $u=RegExp(`^[0-9]xx$`,`i`);function ed(e,t){let n=`${e.status}`;return t.some(e=>{if(!$u.test(e))return e===n;let t=e.charAt(0);if(!t)throw Error(`Invalid status code range`);let r=n.charAt(0);if(!r)throw Error(`Invalid response status code: ${n}`);return r===t})}async function td(e,t){let{maxElapsedTime:n,initialInterval:r,exponent:i,maxInterval:a}=t,o=Date.now(),s=0;for(;;)try{return await e(s)}catch(e){if(e instanceof Yu)throw e.cause;if(Date.now()-o>n){if(e instanceof Xu)return e.response;throw e}let t=0;e instanceof Xu&&(t=rd(e.response)),t<=0&&(t=r*s**+i+Math.random()*1e3),await id(Math.min(t,a)),s++}}async function nd(e,t,n){let r=0;for(;;)try{return await e(r)}catch(e){if(e instanceof Yu)throw e.cause;if(r>=n.maxRetries){if(e instanceof Xu)return e.response;throw e}let i=0;e instanceof Xu&&(i=rd(e.response)),i<=0&&(i=t.initialInterval*t.exponent**+r*(1-Math.random()*.25)),await id(Math.min(i,t.maxInterval)),r++}}function rd(e){let t=e.headers.get(`retry-after-ms`);if(t){let e=Number(t);if(Number.isFinite(e)&&e>=0)return e}let n=e.headers.get(`retry-after`)||``;if(!n)return 0;let r=Number(n);if(Number.isInteger(r))return r*1e3;let i=Date.parse(n);if(Number.isInteger(i)){let e=i-Date.now();return e>0?Math.ceil(e):0}return 0}async function id(e){return new Promise(t=>setTimeout(t,e))}var ad=typeof globalThis>`u`?null:globalThis,od=typeof ad==`object`&&!!ad&&`importScripts`in ad&&typeof ad.importScripts==`function`||typeof navigator<`u`&&`serviceWorker`in navigator||typeof window==`object`&&window.document!==void 0,sd=class{constructor(e={}){let t=e;this._hooks=typeof t==`object`&&t&&`hooks`in t&&t.hooks instanceof hu?t.hooks:new hu;let n=new Bu;e.http_client=e.http_client||n,e=this._hooks.sdkInit(e);let r=Cu(e);r&&(r.pathname=r.pathname.replace(/\/+$/,``)+`/`),this._baseURL=r,this._httpClient=e.http_client||n,this._options=Object.assign(Object.assign({},wl(e)),{hooks:this._hooks}),this._logger=this._options.debug_logger,!this._logger&&Cl().GOOGLE_GENAI_DEBUG&&(this._logger=console)}_createRequest(e,t,n){let{method:r,path:i,query:a,headers:o,security:s}=t,c=t.baseURL??this._baseURL;if(!c)return _u(new Hl(`No base URL provided for operation`));let l=new URL(c),u;i?(l.pathname=l.pathname.replace(/\/+$/,``)+`/`,u=new URL(i,l),!u.search&&l.search&&(u.search=l.search)):u=l,u.hash=``;let d=(e,t)=>{if(!t)return e;let n=new Set(t.split(`&`).filter(e=>e!==``).map(e=>e.split(`=`)[0]??``));return[...e.split(`&`).filter(e=>e!==``&&!n.has(e.split(`=`)[0]??``)),t].join(`&`)},f=e=>Object.entries(e).map(([e,t])=>{if(t==null)return;let n=Du(t)?JSON.stringify(t):t;return ku(e,n,{explode:Array.isArray(n),charEncoding:`percent`})}).filter(e=>e!==void 0).join(`&`),p=[a||``,f(n?.extra_query||{}),f(s?.queryParams||{})].reduce(d,u.search.slice(1));p&&(u.search=`?${p}`);let m=new Headers(o),h=s?.basic.username,g=s?.basic.password;if(h!=null||g!=null){let e=bu([h||``,g||``].join(`:`));m.set(`Authorization`,`Basic ${e}`)}let _=new Headers(s?.headers||{});for(let[e,t]of _)m.set(e,t);let v=m.get(`cookie`)||``;for(let[e,t]of Object.entries(s?.cookies||{}))v+=`; ${e}=${t}`;v=v.startsWith(`; `)?v.slice(2):v,m.set(`cookie`,v);let y=new Headers(n?.headers??n?.fetch_options?.headers);for(let[e,t]of y)m.set(e,t);od||m.set(t.uaHeader??`user-agent`,t.userAgent??wu.userAgent);let b=t.body,x=Object.fromEntries(Object.entries(n?.extra_body||{}).filter(([,e])=>e!==void 0));if(Object.keys(x).length>0){let e=new Headers(o).get(`content-type`)||``;if(!/^(application|text)\/([^+]+\+)*json/.test(e)||typeof b!=`string`&&b!=null)return _u(new Hl(`extra_body can only be merged into JSON object request bodies`));let t;try{t=b?JSON.parse(b):{}}catch(e){return _u(new Hl(`extra_body can only be merged into JSON object request bodies`,{cause:e}))}if(!Du(t))return _u(new Hl(`extra_body can only be merged into JSON object request bodies`));b=JSON.stringify(Object.assign(Object.assign({},t),x)),m.delete(`content-length`)}let S=Object.assign(Object.assign({},n?.fetch_options),n);!S?.signal&&t.timeout_ms!=null&&t.timeout_ms>0&&(e.timeout_ms=t.timeout_ms),t.body instanceof ReadableStream&&Object.assign(S,{duplex:`half`});let C;try{C=this._hooks.beforeCreateRequest(e,{url:u,options:Object.assign(Object.assign({},S),{body:b??null,headers:m,method:r})})}catch(e){return _u(new Vl(`Create request hook failed to execute`,{cause:e}))}return gu(new Request(C.url,C.options))}async _do(e,t){let{context:n,isErrorStatusCode:r}=t,i=n.timeout_ms;return Zu(async()=>{let t=e.clone(),a=t;if(i!=null&&i>0){let e=AbortSignal.timeout(i),n=Tu(t.signal,e)??e;a=new Request(t,{signal:n})}let o=await this._hooks.beforeRequest(n,a);await ud(this._logger,o).catch(e=>this._logger?.log(`Failed to log request:`,e));let s=await this._httpClient.request(o);try{if(r(s.status)){let e=await this._hooks.afterError(n,s,null);if(e.error)throw e.error;s=e.response||s}else s=await this._hooks.afterSuccess(n,s)}finally{await dd(this._logger,s,o).catch(e=>this._logger?.log(`Failed to log response:`,e))}return s},{config:t.retryConfig,statusCodes:t.retryCodes}).then(e=>gu(e),e=>{switch(!0){case qu(e):return _u(new Ul(`Request aborted by client`,{cause:e}));case Ku(e):return _u(new Wl(`Request timed out`,{cause:e}));case Gu(e):return _u(new Gl(`Unable to make request`,{cause:e}));default:return _u(new Vl(`Unexpected HTTP client error`,{cause:e}))}})}},cd=/^(application|text)\/([^+]+\+)*json.*/,ld=/^(application|text)\/([^+]+\+)*(jsonl|x-ndjson)\b.*/;async function ud(e,t){if(!e)return;let n=t.headers.get(`content-type`),r=n?.split(`;`)[0]||``;e.group(`> Request: ${t.method} ${t.url}`),e.group(`Headers:`);for(let[n,r]of t.headers.entries())e.log(`${n}: ${r}`);switch(e.groupEnd(),e.group(`Body:`),!0){case cd.test(r):e.log(await t.clone().json());break;case r.startsWith(`text/`):e.log(await t.clone().text());break;case r===`multipart/form-data`:{let n=await t.clone().formData();for(let[t,r]of n){let n=r instanceof Blob?`<Blob>`:r;e.log(`${t}: ${n}`)}break}default:e.log(`<${n}>`)}e.groupEnd(),e.groupEnd()}async function dd(e,t,n){if(!e)return;let r=t.headers.get(`content-type`),i=r?.split(`;`)[0]||``;e.group(`< Response: ${n.method} ${n.url}`),e.log(`Status Code:`,t.status,t.statusText),e.group(`Headers:`);for(let[n,r]of t.headers.entries())e.log(`${n}: ${r}`);switch(e.groupEnd(),e.group(`Body:`),!0){case Hu(t,`application/json`)||cd.test(i)&&!ld.test(i):e.log(await t.clone().json());break;case Hu(t,`application/jsonl`)||ld.test(i):case Hu(t,`text/event-stream`):e.log(`<${r}>`);break;case Hu(t,`text/*`):e.log(await t.clone().text());break;case Hu(t,`multipart/form-data`):{let n=await t.clone().formData();for(let[t,r]of n){let n=r instanceof Blob?`<Blob>`:r;e.log(`${t}: ${n}`)}break}default:e.log(`<${r}>`)}e.groupEnd(),e.groupEnd()}var fd=class extends Kl{constructor(e,t){e&&(e+=`: `),e+=`Status ${t.response.status}`;let n=t.response.headers.get(`content-type`)||`""`;n!==`application/json`&&(e+=` Content-Type ${n.includes(` `)?`"${n}"`:n}`);let r=t.body||`""`;e+=r.length>100?`
|
|
6
|
+
`:`. `;let i=r;r.length>1e4&&(i=`${r.substring(0,1e4)}...and ${r.length-1e4} more chars`),e+=`Body: ${i}`,e=e.trim(),super(e,t),this.name=`GoogleGenAiDefaultError`}};function pd(e){try{return JSON.parse(e)}catch{return e}}function md(e,t={}){let n=t.flattened===!0,r=t.sentinel??``;return new hd(e,e=>r!==``&&e.data===r?{done:!0,value:void 0}:n?{done:!1,value:e.data==null?void 0:pd(e.data)}:{done:!1,value:Object.assign(Object.assign({},e),{data:e.data==null?e.data:pd(e.data)})},{dataRequired:t.dataRequired??!0})}var hd=class extends ReadableStream{constructor(e,t,n){let r=e.getReader(),i=new Uint8Array(4096),a=0,o=0,s={eventId:void 0},c=n?.dataRequired??!0;super({async pull(e){try{for(;;){let n=vd(i,a,o);if(!n){o=Math.max(0,a-_d+1);let t=await r.read();if(t.done)return e.close();if(a+t.value.length>i.length){let e=new Uint8Array(Math.max(i.length*2,a+t.value.length));e.set(i.subarray(0,a)),i=e}i.set(t.value,a),a+=t.value.length;continue}let l=i.slice(0,n.index);if(i.copyWithin(0,n.index+n.length,a),a-=n.index+n.length,i.length>4096&&a<=i.length>>2){let e=new Uint8Array(Math.max(4096,a*2));e.set(i.subarray(0,a)),i=e}o=0;let u=yd(l,t,s,c);if(u&&!u.done)return e.enqueue(u.value);if(u?.done)return await r.cancel(`done`),e.close()}}catch(t){e.error(t),await r.cancel(t)}},cancel:e=>r.cancel(e)})}[Symbol.asyncIterator](e){let t=ReadableStream.prototype[Symbol.asyncIterator];if(typeof t==`function`)return t.call(this,e);let n=this.getReader(),r={next:async()=>{let e=await n.read();return e.done?(n.releaseLock(),{done:!0,value:void 0}):{done:!1,value:e.value}},throw:async e=>(await n.cancel(e),n.releaseLock(),{done:!0,value:void 0}),return:async()=>(await n.cancel(`done`),n.releaseLock(),{done:!0,value:void 0}),[Symbol.asyncIterator](){return this}},i=Symbol.asyncDispose;return i&&(r[i]=async()=>{await r.return?.call(r)}),r}values(e){return this[Symbol.asyncIterator](e)}},U=13,W=10,gd=[[U,W,U,W],[U,W,U],[U,W,W],[U,U,W],[W,U,W],[U,U],[W,U],[W,W]],_d=gd.reduce((e,t)=>Math.max(e,t.length),0);function vd(e,t,n){for(let r=n;r<t;r++)if(e[r]===U||e[r]===W)for(let n of gd){if(r+n.length>t)continue;let i=!0;for(let t=0;t<n.length;t++)if(e[r+t]!==n[t]){i=!1;break}if(i)return{index:r,length:n.length}}return null}function yd(e,t,n,r){let i=new TextDecoder().decode(e).split(/\r\n|\r|\n/),a=[],o={},s=!0;for(let e of i){if(!e||e.startsWith(`:`))continue;s=!1;let t=e.indexOf(`:`),r=e,i=``;t>0&&(r=e.slice(0,t),i=e[t+1]===` `?e.slice(t+2):e.slice(t+1)),r===`data`?a.push(i):r===`event`?o.event=i:r===`id`&&!i.includes(`\0`)?n.eventId=i:r===`retry`&&/^\d+$/.test(i)&&(o.retry=Number(i))}if(!s){if(o.id=n.eventId,a.length)o.data=a.join(`
|
|
7
|
+
`);else if(r)return;return t(o)}}var bd={jsonl:`application/jsonl`,json:`application/json`,text:`text/plain`,bytes:`application/octet-stream`,stream:`application/octet-stream`,sse:`text/event-stream`,nil:`*`,fail:`*`};function xd(e,t,n){return Object.assign(Object.assign({},n),{err:!0,enc:`json`,codes:e,errorClass:t})}function G(e,t){return Object.assign(Object.assign({},t),{enc:`json`,codes:e})}function Sd(e,t,n){return Object.assign(Object.assign(Object.assign({},n),{enc:`sse`,codes:e}),t?{sse:t}:{})}function Cd(e,t){return Object.assign(Object.assign({},t),{enc:`nil`,codes:e})}function K(e){return{enc:`fail`,codes:e}}function q(...e){return async function(t,n,r){let i,a;for(let n of e){let{codes:e}=n,r=`ctype`in n?n.ctype:bd[n.enc];if(r&&Wu(t,e,r)){a=n;break}if(!r&&H(t,e)){a=n;break}}if(!a)return[{ok:!1,error:new fd(`Unexpected Status or Content-Type`,{response:t,request:n,body:await t.text().catch(()=>``)})},i];let o=a.enc,s=``;switch(o){case`json`:s=await t.text();try{i=JSON.parse(s)}catch(e){if(!(`err`in a))throw e;i=s}break;case`jsonl`:i=t.body;break;case`bytes`:i=new Uint8Array(await t.arrayBuffer());break;case`stream`:i=t.body;break;case`text`:s=await t.text(),i=s;break;case`sse`:if(t.body){let e=`sse`in a&&a.sse||{};i=md(t.body,e)}else i=null;break;case`nil`:s=await t.text(),i=void 0;break;case`fail`:s=await t.text(),i=s;break;default:throw Error(`Unsupported response type: ${o}`)}if(a.enc===`fail`)return[{ok:!1,error:new fd(`API error occurred`,{request:n,response:t,body:s})},i];let c=a.key||r?.resultKey,l,u=a.hdrs?{headers:Td(t.headers)}:null;return l=`err`in a?Object.assign(Object.assign(Object.assign({},r?.extraFields),u),Du(i)?i:null):c?Object.assign(Object.assign(Object.assign({},r?.extraFields),u),{[c]:i}):a.hdrs?Object.assign(Object.assign(Object.assign({},r?.extraFields),u),Du(i)?i:null):i,`err`in a?[{ok:!1,error:a.errorClass?new a.errorClass(l,{request:n,response:t,body:s}):l},i]:[{ok:!0,value:l},i]}}var wd=/, */;function Td(e){let t={};for(let[n,r]of e.entries())t[n]=r.split(wd);return t}var Ed={Incomplete:`incomplete`,UnrecognisedSecurityType:`unrecognized_security_type`},Dd=class e extends Error{constructor(e,t){super(t),this.code=e,this.name=`SecurityError`}static incomplete(){return new e(Ed.Incomplete,`Security requirements not met in order to perform the operation`)}static unrecognizedType(t){return new e(Ed.UnrecognisedSecurityType,`Unrecognised security type: ${t}`)}};function Od(...e){let t={basic:{},headers:{},queryParams:{},cookies:{},oauth2:{type:`none`}},n=e.find(e=>e.every(e=>{if(e.value==null)return!1;if(e.type===`http:basic`)return e.value.username!=null||e.value.password!=null;if(e.type===`http:custom`)return null;if(e.type===`oauth2:password`)return typeof e.value==`string`&&!!e.value;if(e.type===`oauth2:client_credentials`)return typeof e.value==`string`?!!e.value:e.value.client_id!=null||e.value.client_secret!=null;if(typeof e.value==`string`)return!!e.value;throw Error(`Unrecognized security type: ${e.type} (value type: ${typeof e.value})`)}));return n==null?null:(n.forEach(e=>{if(e.value==null)return;let{type:n}=e;switch(n){case`apiKey:header`:t.headers[e.fieldName]=e.value;break;case`apiKey:query`:t.queryParams[e.fieldName]=e.value;break;case`apiKey:cookie`:t.cookies[e.fieldName]=e.value;break;case`http:basic`:kd(t,e);break;case`http:custom`:break;case`http:bearer`:Ad(t,e);break;case`oauth2`:Ad(t,e);break;case`oauth2:password`:Ad(t,e);break;case`oauth2:client_credentials`:break;case`openIdConnect`:Ad(t,e);break;default:throw Dd.unrecognizedType(n)}}),t)}function kd(e,t){t.value!=null&&(e.basic=t.value)}function Ad(e,t){if(typeof t.value!=`string`||!t.value)return;let n=t.value;n.slice(0,7).toLowerCase()!==`bearer `&&(n=`Bearer ${n}`),t.fieldName!==void 0&&(e.headers[t.fieldName]=n)}function J(e,t){return Od([{fieldName:`accessToken`,type:`http:custom`,value:e?.access_token??Cl().GOOGLE_GENAI_ACCESS_TOKEN},{fieldName:`apiKey`,type:`http:custom`,value:e?.api_key??Cl().GOOGLE_GENAI_API_KEY},{fieldName:`defaultHeaders`,type:`http:custom`,value:e?.default_headers}])}async function Y(e){if(e!=null)return typeof e==`function`?e():e}var jd,X=class e{constructor(e,t){this[jd]=`APIPromise`,this._promise=e instanceof Promise?e:Promise.resolve(e),this._unwrapped=e instanceof Promise?null:Promise.resolve(e[0]),this._callSource=t??null}_getUnwrapped(){return this._unwrapped??=this._promise.then(([e])=>e)}then(e,t){return this._promise.then(e?([t])=>e(t):void 0,t)}catch(e){return this._getUnwrapped().catch(e)}finally(e){return this._getUnwrapped().finally(e)}$inspect(){return this._promise}asResponse(){return(this._callSource??=this._promise.then(([,e])=>e)).then(e=>{if(!e.response)throw Error(`APIPromise.asResponse: response unavailable`);return e.response})}async withResponse(){let[[e],t]=await Promise.all([this._promise,this.asResponse()]);return{data:e,response:t}}_thenUnwrap(t){let n=this._promise.then(([e,n])=>[t(e),n]);return n.catch(()=>{}),new e(n,this._callSource??void 0)}};jd=Symbol.toStringTag;function Z(e){let t=e.$inspect(),n=t.then(([e,t])=>{if(!e.ok)throw e.error;return[e.value,t]}),r=t.then(([e,t])=>{if(!e.ok&&!t.response?.ok)throw e.error;return t});return n.catch(()=>{}),r.catch(()=>{}),new X(n,r)}function Md(e,t,n,r){return new X(Nd(e,t,n,r))}async function Nd(e,t,n,r){let i={body:t,api_version:n},a=Au(`body`,i.body,{explode:!0}),o={api_version:V(`api_version`,i.api_version??e._options.api_version,{explode:!1,charEncoding:`percent`})},s=z(`/{api_version}/agents`)(o),c=new Headers(B({"Content-Type":`application/json`,Accept:`application/json`})),l=J(await Y(e._options.security)),u={options:e._options,base_url:r?.server_url??e._baseURL??``,operation_id:`CreateAgent`,o_auth2_scopes:null,resolved_security:l,security_source:e._options.security,retry_config:r?.retries||e._options.retry_config||{strategy:`attempt-count-backoff`,backoff:{initialInterval:500,maxInterval:8e3,exponent:2,maxElapsedTime:3e4},retryConnectionErrors:!0,maxRetries:4},retry_codes:r?.retry_codes||[`408`,`409`,`429`,`5XX`]},d=e._createRequest(u,{security:l,method:`POST`,baseURL:r?.server_url,path:s,headers:c,body:a,userAgent:e._options.user_agent,timeout_ms:r?.timeout_ms||e._options.timeout_ms||-1},r);if(!d.ok)return[d,{status:`invalid`}];let f=d.value,p=await e._do(f,{context:u,isErrorStatusCode:e=>H({status:e},[`4XX`,`5XX`]),retryConfig:u.retry_config,retryCodes:u.retry_codes});if(!p.ok)return[p,{status:`request-error`,request:f}];let m=p.value,[h]=await q(K(`4XX`),K(`5XX`),G(`default`))(m,f);return h.ok,[h,{status:`complete`,request:f,response:m}]}function Pd(e,t,n,r){return new X(Fd(e,t,n,r))}async function Fd(e,t,n,r){let i={id:t,api_version:n},a={api_version:V(`api_version`,i.api_version??e._options.api_version,{explode:!1,charEncoding:`percent`}),id:V(`id`,i.id,{explode:!1,charEncoding:`percent`})},o=z(`/{api_version}/agents/{id}`)(a),s=new Headers(B({Accept:`application/json`})),c=J(await Y(e._options.security)),l={options:e._options,base_url:r?.server_url??e._baseURL??``,operation_id:`DeleteAgent`,o_auth2_scopes:null,resolved_security:c,security_source:e._options.security,retry_config:r?.retries||e._options.retry_config||{strategy:`attempt-count-backoff`,backoff:{initialInterval:500,maxInterval:8e3,exponent:2,maxElapsedTime:3e4},retryConnectionErrors:!0,maxRetries:4},retry_codes:r?.retry_codes||[`408`,`409`,`429`,`5XX`]},u=e._createRequest(l,{security:c,method:`DELETE`,baseURL:r?.server_url,path:o,headers:s,body:null,userAgent:e._options.user_agent,timeout_ms:r?.timeout_ms||e._options.timeout_ms||-1},r);if(!u.ok)return[u,{status:`invalid`}];let d=u.value,f=await e._do(d,{context:l,isErrorStatusCode:e=>H({status:e},[`4XX`,`5XX`]),retryConfig:l.retry_config,retryCodes:l.retry_codes});if(!f.ok)return[f,{status:`request-error`,request:d}];let p=f.value,[m]=await q(K(`4XX`),K(`5XX`),G(`default`))(p,d);return m.ok,[m,{status:`complete`,request:d,response:p}]}function Id(e,t,n,r){return new X(Ld(e,t,n,r))}async function Ld(e,t,n,r){let i={id:t,api_version:n},a={api_version:V(`api_version`,i.api_version??e._options.api_version,{explode:!1,charEncoding:`percent`}),id:V(`id`,i.id,{explode:!1,charEncoding:`percent`})},o=z(`/{api_version}/agents/{id}`)(a),s=new Headers(B({Accept:`application/json`})),c=J(await Y(e._options.security)),l={options:e._options,base_url:r?.server_url??e._baseURL??``,operation_id:`GetAgent`,o_auth2_scopes:null,resolved_security:c,security_source:e._options.security,retry_config:r?.retries||e._options.retry_config||{strategy:`attempt-count-backoff`,backoff:{initialInterval:500,maxInterval:8e3,exponent:2,maxElapsedTime:3e4},retryConnectionErrors:!0,maxRetries:4},retry_codes:r?.retry_codes||[`408`,`409`,`429`,`5XX`]},u=e._createRequest(l,{security:c,method:`GET`,baseURL:r?.server_url,path:o,headers:s,body:null,userAgent:e._options.user_agent,timeout_ms:r?.timeout_ms||e._options.timeout_ms||-1},r);if(!u.ok)return[u,{status:`invalid`}];let d=u.value,f=await e._do(d,{context:l,isErrorStatusCode:e=>H({status:e},[`4XX`,`5XX`]),retryConfig:l.retry_config,retryCodes:l.retry_codes});if(!f.ok)return[f,{status:`request-error`,request:d}];let p=f.value,[m]=await q(K(`4XX`),K(`5XX`),G(`default`))(p,d);return m.ok,[m,{status:`complete`,request:d,response:p}]}function Rd(e,t,n,r,i,a){return new X(zd(e,t,n,r,i,a))}async function zd(e,t,n,r,i,a){let o={api_version:t,page_size:n,page_token:r,parent:i},s={api_version:V(`api_version`,o?.api_version??e._options.api_version,{explode:!1,charEncoding:`percent`})},c=z(`/{api_version}/agents`)(s),l=Ru({page_size:o?.page_size,page_token:o?.page_token,parent:o?.parent}),u=new Headers(B({Accept:`application/json`})),d=J(await Y(e._options.security)),f={options:e._options,base_url:a?.server_url??e._baseURL??``,operation_id:`ListAgents`,o_auth2_scopes:null,resolved_security:d,security_source:e._options.security,retry_config:a?.retries||e._options.retry_config||{strategy:`attempt-count-backoff`,backoff:{initialInterval:500,maxInterval:8e3,exponent:2,maxElapsedTime:3e4},retryConnectionErrors:!0,maxRetries:4},retry_codes:a?.retry_codes||[`408`,`409`,`429`,`5XX`]},p=e._createRequest(f,{security:d,method:`GET`,baseURL:a?.server_url,path:c,headers:u,query:l,body:null,userAgent:e._options.user_agent,timeout_ms:a?.timeout_ms||e._options.timeout_ms||-1},a);if(!p.ok)return[p,{status:`invalid`}];let m=p.value,h=await e._do(m,{context:f,isErrorStatusCode:e=>H({status:e},[`4XX`,`5XX`]),retryConfig:f.retry_config,retryCodes:f.retry_codes});if(!h.ok)return[h,{status:`request-error`,request:m}];let g=h.value,[_]=await q(K(`4XX`),K(`5XX`),G(`default`))(g,m);return _.ok,[_,{status:`complete`,request:m,response:g}]}var Bd=class extends sd{list(e,t){return Z(Rd(this,e?.api_version,e?.page_size,e?.page_token,e?.parent,t))}create(e,t){let{api_version:n}=e,r=F(e,[`api_version`]);return Z(Md(this,r,n,t))}delete(e,t,n){return Z(Pd(this,e,t?.api_version,n))}get(e,t,n){return Z(Id(this,e,t?.api_version,n))}};function Vd(e,t,n,r){return new X(Hd(e,t,n,r))}async function Hd(e,t,n,r){let i={body:t,api_version:n},a=Au(`body`,i.body,{explode:!0}),o={api_version:V(`api_version`,i.api_version??e._options.api_version,{explode:!1,charEncoding:`percent`})},s=z(`/{api_version}/environments`)(o),c=new Headers(B({"Content-Type":`application/json`,Accept:`application/json`})),l=J(await Y(e._options.security)),u={options:e._options,base_url:r?.server_url??e._baseURL??``,operation_id:`CreateEnvironment`,o_auth2_scopes:null,resolved_security:l,security_source:e._options.security,retry_config:r?.retries||e._options.retry_config||{strategy:`attempt-count-backoff`,backoff:{initialInterval:500,maxInterval:8e3,exponent:2,maxElapsedTime:3e4},retryConnectionErrors:!0,maxRetries:4},retry_codes:r?.retry_codes||[`408`,`409`,`429`,`5XX`]},d=e._createRequest(u,{security:l,method:`POST`,baseURL:r?.server_url,path:s,headers:c,body:a,userAgent:e._options.user_agent,timeout_ms:r?.timeout_ms||e._options.timeout_ms||-1},r);if(!d.ok)return[d,{status:`invalid`}];let f=d.value,p=await e._do(f,{context:u,isErrorStatusCode:e=>H({status:e},[`4XX`,`5XX`]),retryConfig:u.retry_config,retryCodes:u.retry_codes});if(!p.ok)return[p,{status:`request-error`,request:f}];let m=p.value,[h]=await q(K(`4XX`),K(`5XX`),G(`default`))(m,f);return h.ok,[h,{status:`complete`,request:f,response:m}]}function Ud(e,t,n,r){return new X(Wd(e,t,n,r))}async function Wd(e,t,n,r){let i={id:t,api_version:n},a={api_version:V(`api_version`,i.api_version??e._options.api_version,{explode:!1,charEncoding:`percent`}),id:V(`id`,i.id,{explode:!1,charEncoding:`percent`})},o=z(`/{api_version}/environments/{id}`)(a),s=new Headers(B({Accept:`application/json`})),c=J(await Y(e._options.security)),l={options:e._options,base_url:r?.server_url??e._baseURL??``,operation_id:`DeleteEnvironment`,o_auth2_scopes:null,resolved_security:c,security_source:e._options.security,retry_config:r?.retries||e._options.retry_config||{strategy:`attempt-count-backoff`,backoff:{initialInterval:500,maxInterval:8e3,exponent:2,maxElapsedTime:3e4},retryConnectionErrors:!0,maxRetries:4},retry_codes:r?.retry_codes||[`408`,`409`,`429`,`5XX`]},u=e._createRequest(l,{security:c,method:`DELETE`,baseURL:r?.server_url,path:o,headers:s,body:null,userAgent:e._options.user_agent,timeout_ms:r?.timeout_ms||e._options.timeout_ms||-1},r);if(!u.ok)return[u,{status:`invalid`}];let d=u.value,f=await e._do(d,{context:l,isErrorStatusCode:e=>H({status:e},[`4XX`,`5XX`]),retryConfig:l.retry_config,retryCodes:l.retry_codes});if(!f.ok)return[f,{status:`request-error`,request:d}];let p=f.value,[m]=await q(K(`4XX`),K(`5XX`),G(`default`))(p,d);return m.ok,[m,{status:`complete`,request:d,response:p}]}function Gd(e,t,n,r){return new X(Kd(e,t,n,r))}async function Kd(e,t,n,r){let i={id:t,api_version:n},a={api_version:V(`api_version`,i.api_version??e._options.api_version,{explode:!1,charEncoding:`percent`}),id:V(`id`,i.id,{explode:!1,charEncoding:`percent`})},o=z(`/{api_version}/environments/{id}`)(a),s=new Headers(B({Accept:`application/json`})),c=J(await Y(e._options.security)),l={options:e._options,base_url:r?.server_url??e._baseURL??``,operation_id:`GetEnvironment`,o_auth2_scopes:null,resolved_security:c,security_source:e._options.security,retry_config:r?.retries||e._options.retry_config||{strategy:`attempt-count-backoff`,backoff:{initialInterval:500,maxInterval:8e3,exponent:2,maxElapsedTime:3e4},retryConnectionErrors:!0,maxRetries:4},retry_codes:r?.retry_codes||[`408`,`409`,`429`,`5XX`]},u=e._createRequest(l,{security:c,method:`GET`,baseURL:r?.server_url,path:o,headers:s,body:null,userAgent:e._options.user_agent,timeout_ms:r?.timeout_ms||e._options.timeout_ms||-1},r);if(!u.ok)return[u,{status:`invalid`}];let d=u.value,f=await e._do(d,{context:l,isErrorStatusCode:e=>H({status:e},[`4XX`,`5XX`]),retryConfig:l.retry_config,retryCodes:l.retry_codes});if(!f.ok)return[f,{status:`request-error`,request:d}];let p=f.value,[m]=await q(K(`4XX`),K(`5XX`),G(`default`))(p,d);return m.ok,[m,{status:`complete`,request:d,response:p}]}function qd(e,t,n,r,i){return new X(Jd(e,t,n,r,i))}async function Jd(e,t,n,r,i){let a={api_version:t,page_size:n,page_token:r},o={api_version:V(`api_version`,a?.api_version??e._options.api_version,{explode:!1,charEncoding:`percent`})},s=z(`/{api_version}/environments`)(o),c=Ru({page_size:a?.page_size,page_token:a?.page_token}),l=new Headers(B({Accept:`application/json`})),u=J(await Y(e._options.security)),d={options:e._options,base_url:i?.server_url??e._baseURL??``,operation_id:`ListEnvironments`,o_auth2_scopes:null,resolved_security:u,security_source:e._options.security,retry_config:i?.retries||e._options.retry_config||{strategy:`attempt-count-backoff`,backoff:{initialInterval:500,maxInterval:8e3,exponent:2,maxElapsedTime:3e4},retryConnectionErrors:!0,maxRetries:4},retry_codes:i?.retry_codes||[`408`,`409`,`429`,`5XX`]},f=e._createRequest(d,{security:u,method:`GET`,baseURL:i?.server_url,path:s,headers:l,query:c,body:null,userAgent:e._options.user_agent,timeout_ms:i?.timeout_ms||e._options.timeout_ms||-1},i);if(!f.ok)return[f,{status:`invalid`}];let p=f.value,m=await e._do(p,{context:d,isErrorStatusCode:e=>H({status:e},[`4XX`,`5XX`]),retryConfig:d.retry_config,retryCodes:d.retry_codes});if(!m.ok)return[m,{status:`request-error`,request:p}];let h=m.value,[g]=await q(K(`4XX`),K(`5XX`),G(`default`))(h,p);return g.ok,[g,{status:`complete`,request:p,response:h}]}function Yd(e,t,n,r,i,a,o,s){return new X(Xd(e,t,n,r,i,a,o,s))}async function Xd(e,t,n,r,i,a,o,s){let c={environment:t,path:n,api_version:r,page_size:i,page_token:a,recursive:o},l={api_version:V(`api_version`,c.api_version??e._options.api_version,{explode:!1,charEncoding:`percent`}),environment:V(`environment`,c.environment,{explode:!1,charEncoding:`percent`}),path:V(`path`,c.path,{explode:!1,charEncoding:`percent`})},u=z(`/{api_version}/environments/{environment}/files/{path}`)(l),d=Ru({page_size:c.page_size,page_token:c.page_token,recursive:c.recursive}),f=new Headers(B({Accept:`application/json`})),p=J(await Y(e._options.security)),m={options:e._options,base_url:s?.server_url??e._baseURL??``,operation_id:`GetEnvironmentFiles`,o_auth2_scopes:null,resolved_security:p,security_source:e._options.security,retry_config:s?.retries||e._options.retry_config||{strategy:`attempt-count-backoff`,backoff:{initialInterval:500,maxInterval:8e3,exponent:2,maxElapsedTime:3e4},retryConnectionErrors:!0,maxRetries:4},retry_codes:s?.retry_codes||[`408`,`409`,`429`,`5XX`]},h=e._createRequest(m,{security:p,method:`GET`,baseURL:s?.server_url,path:u,headers:f,query:d,body:null,userAgent:e._options.user_agent,timeout_ms:s?.timeout_ms||e._options.timeout_ms||-1},s);if(!h.ok)return[h,{status:`invalid`}];let g=h.value,_=await e._do(g,{context:m,isErrorStatusCode:e=>H({status:e},[`4XX`,`5XX`]),retryConfig:m.retry_config,retryCodes:m.retry_codes});if(!_.ok)return[_,{status:`request-error`,request:g}];let v=_.value,[y]=await q(G(200),K(`4XX`),K(`5XX`))(v,g);return y.ok,[y,{status:`complete`,request:g,response:v}]}var Zd=class extends sd{list(e,t,n,r){return Z(Yd(this,e,t,n?.api_version,n?.page_size,n?.page_token,n?.recursive,r))}},Qd=class extends sd{get files(){return this._files??=new Zd(this._options)}listEnvironments(e,t){return Z(qd(this,e?.api_version,e?.page_size,e?.page_token,t))}createEnvironment(e,t,n){return Z(Vd(this,e,t,n))}deleteEnvironment(e,t,n){return Z(Ud(this,e,t?.api_version,n))}getEnvironment(e,t,n){return Z(Gd(this,e,t?.api_version,n))}},$d=class extends Kl{constructor(e,t){let n=e.error?.message||`API error occurred: ${JSON.stringify(e)}`;super(n,t),this.data$=e,this.error=e.error,this.name=`CancelInteractionByIdServerError`}},ef=class extends Kl{constructor(e,t){let n=e.error?.message||`API error occurred: ${JSON.stringify(e)}`;super(n,t),this.data$=e,this.error=e.error,this.name=`CancelInteractionByIdClientError`}},tf=class extends Kl{constructor(e,t){let n=e.error?.message||`API error occurred: ${JSON.stringify(e)}`;super(n,t),this.data$=e,this.error=e.error,this.name=`CreateInteractionServerError`}},nf=class extends Kl{constructor(e,t){let n=e.error?.message||`API error occurred: ${JSON.stringify(e)}`;super(n,t),this.data$=e,this.error=e.error,this.name=`CreateInteractionClientError`}},rf=class extends Kl{constructor(e,t){let n=e.error?.message||`API error occurred: ${JSON.stringify(e)}`;super(n,t),this.data$=e,this.error=e.error,this.name=`DeleteInteractionServerError`}},af=class extends Kl{constructor(e,t){let n=e.error?.message||`API error occurred: ${JSON.stringify(e)}`;super(n,t),this.data$=e,this.error=e.error,this.name=`DeleteInteractionClientError`}},of=class extends Kl{constructor(e,t){let n=e.error?.message||`API error occurred: ${JSON.stringify(e)}`;super(n,t),this.data$=e,this.error=e.error,this.name=`GetInteractionByIdServerError`}},sf=class extends Kl{constructor(e,t){let n=e.error?.message||`API error occurred: ${JSON.stringify(e)}`;super(n,t),this.data$=e,this.error=e.error,this.name=`GetInteractionByIdClientError`}};function cf(e,t,n,r){return new X(lf(e,t,n,r))}async function lf(e,t,n,r){let i={id:t,api_version:n},a={api_version:V(`api_version`,i.api_version??e._options.api_version,{explode:!1,charEncoding:`percent`}),id:V(`id`,i.id,{explode:!1,charEncoding:`percent`})},o=z(`/{api_version}/interactions/{id}/cancel`)(a),s=new Headers(B({Accept:`application/json`})),c=J(await Y(e._options.security)),l={options:e._options,base_url:r?.server_url??e._baseURL??``,operation_id:`cancelInteractionById`,o_auth2_scopes:null,resolved_security:c,security_source:e._options.security,retry_config:r?.retries||e._options.retry_config||{strategy:`attempt-count-backoff`,backoff:{initialInterval:500,maxInterval:8e3,exponent:2,maxElapsedTime:3e4},retryConnectionErrors:!0,maxRetries:4},retry_codes:r?.retry_codes||[`408`,`409`,`429`,`5XX`]},u=e._createRequest(l,{security:c,method:`POST`,baseURL:r?.server_url,path:o,headers:s,body:null,userAgent:e._options.user_agent,timeout_ms:r?.timeout_ms||e._options.timeout_ms||-1},r);if(!u.ok)return[u,{status:`invalid`}];let d=u.value,f=await e._do(d,{context:l,isErrorStatusCode:e=>H({status:e},[`4XX`,`5XX`]),retryConfig:l.retry_config,retryCodes:l.retry_codes});if(!f.ok)return[f,{status:`request-error`,request:d}];let p=f.value,m={httpMeta:{response:p,request:d}},[h]=await q(G(200),xd(`4XX`,ef),xd(`5XX`,$d))(p,d,{extraFields:m});return h.ok,[h,{status:`complete`,request:d,response:p}]}function uf(e,t,n,r){return new X(df(e,t,n,r))}async function df(e,t,n,r){let i={body:t,api_version:n},a=i,o=Au(`body`,a.body,{explode:!0}),s={api_version:V(`api_version`,a.api_version??e._options.api_version,{explode:!1,charEncoding:`percent`})},c=z(`/{api_version}/interactions`)(s),l=new Headers(B({"Content-Type":`application/json`,Accept:i?.body?.stream?`text/event-stream`:`application/json`})),u=J(await Y(e._options.security)),d={options:e._options,base_url:r?.server_url??e._baseURL??``,operation_id:`CreateInteraction`,o_auth2_scopes:null,resolved_security:u,security_source:e._options.security,retry_config:r?.retries||e._options.retry_config||{strategy:`attempt-count-backoff`,backoff:{initialInterval:500,maxInterval:8e3,exponent:2,maxElapsedTime:3e4},retryConnectionErrors:!0,maxRetries:4},retry_codes:r?.retry_codes||[`408`,`409`,`429`,`5XX`]},f=e._createRequest(d,{security:u,method:`POST`,baseURL:r?.server_url,path:c,headers:l,body:o,userAgent:e._options.user_agent,timeout_ms:r?.timeout_ms||e._options.timeout_ms||-1},r);if(!f.ok)return[f,{status:`invalid`}];let p=f.value,m=await e._do(p,{context:d,isErrorStatusCode:e=>H({status:e},[`4XX`,`5XX`]),retryConfig:d.retry_config,retryCodes:d.retry_codes});if(!m.ok)return[m,{status:`request-error`,request:p}];let h=m.value,g={httpMeta:{response:h,request:p}},[_]=await q(G(200),Sd(200,{sentinel:`[DONE]`,flattened:!0}),xd(`4XX`,nf),xd(`5XX`,tf))(h,p,{extraFields:g});return _.ok,[_,{status:`complete`,request:p,response:h}]}function ff(e,t,n,r){return new X(pf(e,t,n,r))}async function pf(e,t,n,r){let i={id:t,api_version:n},a={api_version:V(`api_version`,i.api_version??e._options.api_version,{explode:!1,charEncoding:`percent`}),id:V(`id`,i.id,{explode:!1,charEncoding:`percent`})},o=z(`/{api_version}/interactions/{id}`)(a),s=new Headers(B({Accept:`application/json`})),c=J(await Y(e._options.security)),l={options:e._options,base_url:r?.server_url??e._baseURL??``,operation_id:`deleteInteraction`,o_auth2_scopes:null,resolved_security:c,security_source:e._options.security,retry_config:r?.retries||e._options.retry_config||{strategy:`attempt-count-backoff`,backoff:{initialInterval:500,maxInterval:8e3,exponent:2,maxElapsedTime:3e4},retryConnectionErrors:!0,maxRetries:4},retry_codes:r?.retry_codes||[`408`,`409`,`429`,`5XX`]},u=e._createRequest(l,{security:c,method:`DELETE`,baseURL:r?.server_url,path:o,headers:s,body:null,userAgent:e._options.user_agent,timeout_ms:r?.timeout_ms||e._options.timeout_ms||-1},r);if(!u.ok)return[u,{status:`invalid`}];let d=u.value,f=await e._do(d,{context:l,isErrorStatusCode:e=>H({status:e},[`4XX`,`5XX`]),retryConfig:l.retry_config,retryCodes:l.retry_codes});if(!f.ok)return[f,{status:`request-error`,request:d}];let p=f.value,m={httpMeta:{response:p,request:d}},[h]=await q(Cd(200),xd(`4XX`,af),xd(`5XX`,rf))(p,d,{extraFields:m});return h.ok,[h,{status:`complete`,request:d,response:p}]}function mf(e,t,n,r,i,a,o){return new X(hf(e,t,n,r,i,a,o))}async function hf(e,t,n,r,i,a,o){let s={id:t,api_version:n,include_input:r,last_event_id:i,stream:a},c=s,l={api_version:V(`api_version`,c.api_version??e._options.api_version,{explode:!1,charEncoding:`percent`}),id:V(`id`,c.id,{explode:!1,charEncoding:`percent`})},u=z(`/{api_version}/interactions/{id}`)(l),d=Ru({include_input:c.include_input,last_event_id:c.last_event_id,stream:c.stream}),f=new Headers(B({Accept:s?.stream?`text/event-stream`:`application/json`})),p=J(await Y(e._options.security)),m={options:e._options,base_url:o?.server_url??e._baseURL??``,operation_id:`getInteractionById`,o_auth2_scopes:null,resolved_security:p,security_source:e._options.security,retry_config:o?.retries||e._options.retry_config||{strategy:`attempt-count-backoff`,backoff:{initialInterval:500,maxInterval:8e3,exponent:2,maxElapsedTime:3e4},retryConnectionErrors:!0,maxRetries:4},retry_codes:o?.retry_codes||[`408`,`409`,`429`,`5XX`]},h=e._createRequest(m,{security:p,method:`GET`,baseURL:o?.server_url,path:u,headers:f,query:d,body:null,userAgent:e._options.user_agent,timeout_ms:o?.timeout_ms||e._options.timeout_ms||-1},o);if(!h.ok)return[h,{status:`invalid`}];let g=h.value,_=await e._do(g,{context:m,isErrorStatusCode:e=>H({status:e},[`4XX`,`5XX`]),retryConfig:m.retry_config,retryCodes:m.retry_codes});if(!_.ok)return[_,{status:`request-error`,request:g}];let v=_.value,y={httpMeta:{response:v,request:g}},[b]=await q(G(200),Sd(200,{sentinel:`[DONE]`,flattened:!0}),xd(`4XX`,sf),xd(`5XX`,of))(v,g,{extraFields:y});return b.ok,[b,{status:`complete`,request:g,response:v}]}var gf=class extends sd{create(e,t){let{api_version:n}=e,r=F(e,[`api_version`]);return Z(uf(this,r,n,t))}delete(e,t,n){return Z(ff(this,e,t?.api_version,n))}get(e,t,n){return Z(mf(this,e,t?.api_version,t?.include_input,t?.last_event_id,t?.stream,n))}cancel(e,t,n){return Z(cf(this,e,t?.api_version,n))}};function _f(e,t,n,r){return new X(vf(e,t,n,r))}async function vf(e,t,n,r){let i={body:t,api_version:n},a=Au(`body`,i.body,{explode:!0}),o={api_version:V(`api_version`,i.api_version??e._options.api_version,{explode:!1,charEncoding:`percent`})},s=z(`/{api_version}/triggers`)(o),c=new Headers(B({"Content-Type":`application/json`,Accept:`application/json`})),l=J(await Y(e._options.security)),u={options:e._options,base_url:r?.server_url??e._baseURL??``,operation_id:`CreateTrigger`,o_auth2_scopes:null,resolved_security:l,security_source:e._options.security,retry_config:r?.retries||e._options.retry_config||{strategy:`attempt-count-backoff`,backoff:{initialInterval:500,maxInterval:8e3,exponent:2,maxElapsedTime:3e4},retryConnectionErrors:!0,maxRetries:4},retry_codes:r?.retry_codes||[`408`,`409`,`429`,`5XX`]},d=e._createRequest(u,{security:l,method:`POST`,baseURL:r?.server_url,path:s,headers:c,body:a,userAgent:e._options.user_agent,timeout_ms:r?.timeout_ms||e._options.timeout_ms||-1},r);if(!d.ok)return[d,{status:`invalid`}];let f=d.value,p=await e._do(f,{context:u,isErrorStatusCode:e=>H({status:e},[`4XX`,`5XX`]),retryConfig:u.retry_config,retryCodes:u.retry_codes});if(!p.ok)return[p,{status:`request-error`,request:f}];let m=p.value,[h]=await q(G(200),K(`4XX`),K(`5XX`))(m,f);return h.ok,[h,{status:`complete`,request:f,response:m}]}function yf(e,t,n,r){return new X(bf(e,t,n,r))}async function bf(e,t,n,r){let i={id:t,api_version:n},a={api_version:V(`api_version`,i.api_version??e._options.api_version,{explode:!1,charEncoding:`percent`}),id:V(`id`,i.id,{explode:!1,charEncoding:`percent`})},o=z(`/{api_version}/triggers/{id}`)(a),s=new Headers(B({Accept:`application/json`})),c=J(await Y(e._options.security)),l={options:e._options,base_url:r?.server_url??e._baseURL??``,operation_id:`DeleteTrigger`,o_auth2_scopes:null,resolved_security:c,security_source:e._options.security,retry_config:r?.retries||e._options.retry_config||{strategy:`attempt-count-backoff`,backoff:{initialInterval:500,maxInterval:8e3,exponent:2,maxElapsedTime:3e4},retryConnectionErrors:!0,maxRetries:4},retry_codes:r?.retry_codes||[`408`,`409`,`429`,`5XX`]},u=e._createRequest(l,{security:c,method:`DELETE`,baseURL:r?.server_url,path:o,headers:s,body:null,userAgent:e._options.user_agent,timeout_ms:r?.timeout_ms||e._options.timeout_ms||-1},r);if(!u.ok)return[u,{status:`invalid`}];let d=u.value,f=await e._do(d,{context:l,isErrorStatusCode:e=>H({status:e},[`4XX`,`5XX`]),retryConfig:l.retry_config,retryCodes:l.retry_codes});if(!f.ok)return[f,{status:`request-error`,request:d}];let p=f.value,[m]=await q(G(200),K(`4XX`),K(`5XX`))(p,d);return m.ok,[m,{status:`complete`,request:d,response:p}]}function xf(e,t,n,r){return new X(Sf(e,t,n,r))}async function Sf(e,t,n,r){let i={id:t,api_version:n},a={api_version:V(`api_version`,i.api_version??e._options.api_version,{explode:!1,charEncoding:`percent`}),id:V(`id`,i.id,{explode:!1,charEncoding:`percent`})},o=z(`/{api_version}/triggers/{id}`)(a),s=new Headers(B({Accept:`application/json`})),c=J(await Y(e._options.security)),l={options:e._options,base_url:r?.server_url??e._baseURL??``,operation_id:`GetTrigger`,o_auth2_scopes:null,resolved_security:c,security_source:e._options.security,retry_config:r?.retries||e._options.retry_config||{strategy:`attempt-count-backoff`,backoff:{initialInterval:500,maxInterval:8e3,exponent:2,maxElapsedTime:3e4},retryConnectionErrors:!0,maxRetries:4},retry_codes:r?.retry_codes||[`408`,`409`,`429`,`5XX`]},u=e._createRequest(l,{security:c,method:`GET`,baseURL:r?.server_url,path:o,headers:s,body:null,userAgent:e._options.user_agent,timeout_ms:r?.timeout_ms||e._options.timeout_ms||-1},r);if(!u.ok)return[u,{status:`invalid`}];let d=u.value,f=await e._do(d,{context:l,isErrorStatusCode:e=>H({status:e},[`4XX`,`5XX`]),retryConfig:l.retry_config,retryCodes:l.retry_codes});if(!f.ok)return[f,{status:`request-error`,request:d}];let p=f.value,[m]=await q(G(200),K(`4XX`),K(`5XX`))(p,d);return m.ok,[m,{status:`complete`,request:d,response:p}]}function Cf(e,t,n,r,i,a){return new X(wf(e,t,n,r,i,a))}async function wf(e,t,n,r,i,a){let o={trigger_id:t,api_version:n,page_size:r,page_token:i},s={api_version:V(`api_version`,o.api_version??e._options.api_version,{explode:!1,charEncoding:`percent`}),trigger_id:V(`trigger_id`,o.trigger_id,{explode:!1,charEncoding:`percent`})},c=z(`/{api_version}/triggers/{trigger_id}/executions`)(s),l=Ru({page_size:o.page_size,page_token:o.page_token}),u=new Headers(B({Accept:`application/json`})),d=J(await Y(e._options.security)),f={options:e._options,base_url:a?.server_url??e._baseURL??``,operation_id:`ListTriggerExecutions`,o_auth2_scopes:null,resolved_security:d,security_source:e._options.security,retry_config:a?.retries||e._options.retry_config||{strategy:`attempt-count-backoff`,backoff:{initialInterval:500,maxInterval:8e3,exponent:2,maxElapsedTime:3e4},retryConnectionErrors:!0,maxRetries:4},retry_codes:a?.retry_codes||[`408`,`409`,`429`,`5XX`]},p=e._createRequest(f,{security:d,method:`GET`,baseURL:a?.server_url,path:c,headers:u,query:l,body:null,userAgent:e._options.user_agent,timeout_ms:a?.timeout_ms||e._options.timeout_ms||-1},a);if(!p.ok)return[p,{status:`invalid`}];let m=p.value,h=await e._do(m,{context:f,isErrorStatusCode:e=>H({status:e},[`4XX`,`5XX`]),retryConfig:f.retry_config,retryCodes:f.retry_codes});if(!h.ok)return[h,{status:`request-error`,request:m}];let g=h.value,[_]=await q(G(200),K(`4XX`),K(`5XX`))(g,m);return _.ok,[_,{status:`complete`,request:m,response:g}]}function Tf(e,t,n,r,i,a){return new X(Ef(e,t,n,r,i,a))}async function Ef(e,t,n,r,i,a){let o={api_version:t,filter:n,page_size:r,page_token:i},s={api_version:V(`api_version`,o?.api_version??e._options.api_version,{explode:!1,charEncoding:`percent`})},c=z(`/{api_version}/triggers`)(s),l=Ru({filter:o?.filter,page_size:o?.page_size,page_token:o?.page_token}),u=new Headers(B({Accept:`application/json`})),d=J(await Y(e._options.security)),f={options:e._options,base_url:a?.server_url??e._baseURL??``,operation_id:`ListTriggers`,o_auth2_scopes:null,resolved_security:d,security_source:e._options.security,retry_config:a?.retries||e._options.retry_config||{strategy:`attempt-count-backoff`,backoff:{initialInterval:500,maxInterval:8e3,exponent:2,maxElapsedTime:3e4},retryConnectionErrors:!0,maxRetries:4},retry_codes:a?.retry_codes||[`408`,`409`,`429`,`5XX`]},p=e._createRequest(f,{security:d,method:`GET`,baseURL:a?.server_url,path:c,headers:u,query:l,body:null,userAgent:e._options.user_agent,timeout_ms:a?.timeout_ms||e._options.timeout_ms||-1},a);if(!p.ok)return[p,{status:`invalid`}];let m=p.value,h=await e._do(m,{context:f,isErrorStatusCode:e=>H({status:e},[`4XX`,`5XX`]),retryConfig:f.retry_config,retryCodes:f.retry_codes});if(!h.ok)return[h,{status:`request-error`,request:m}];let g=h.value,[_]=await q(G(200),K(`4XX`),K(`5XX`))(g,m);return _.ok,[_,{status:`complete`,request:m,response:g}]}function Df(e,t,n,r){return new X(Of(e,t,n,r))}async function Of(e,t,n,r){let i={trigger_id:t,api_version:n},a={api_version:V(`api_version`,i.api_version??e._options.api_version,{explode:!1,charEncoding:`percent`}),trigger_id:V(`trigger_id`,i.trigger_id,{explode:!1,charEncoding:`percent`})},o=z(`/{api_version}/triggers/{trigger_id}/executions`)(a),s=new Headers(B({Accept:`application/json`})),c=J(await Y(e._options.security)),l={options:e._options,base_url:r?.server_url??e._baseURL??``,operation_id:`RunTrigger`,o_auth2_scopes:null,resolved_security:c,security_source:e._options.security,retry_config:r?.retries||e._options.retry_config||{strategy:`attempt-count-backoff`,backoff:{initialInterval:500,maxInterval:8e3,exponent:2,maxElapsedTime:3e4},retryConnectionErrors:!0,maxRetries:4},retry_codes:r?.retry_codes||[`408`,`409`,`429`,`5XX`]},u=e._createRequest(l,{security:c,method:`POST`,baseURL:r?.server_url,path:o,headers:s,body:null,userAgent:e._options.user_agent,timeout_ms:r?.timeout_ms||e._options.timeout_ms||-1},r);if(!u.ok)return[u,{status:`invalid`}];let d=u.value,f=await e._do(d,{context:l,isErrorStatusCode:e=>H({status:e},[`4XX`,`5XX`]),retryConfig:l.retry_config,retryCodes:l.retry_codes});if(!f.ok)return[f,{status:`request-error`,request:d}];let p=f.value,[m]=await q(G(200),K(`4XX`),K(`5XX`))(p,d);return m.ok,[m,{status:`complete`,request:d,response:p}]}function kf(e,t,n,r,i){return new X(Af(e,t,n,r,i))}async function Af(e,t,n,r,i){let a={id:t,body:n,api_version:r},o=Au(`body`,a.body,{explode:!0}),s={api_version:V(`api_version`,a.api_version??e._options.api_version,{explode:!1,charEncoding:`percent`}),id:V(`id`,a.id,{explode:!1,charEncoding:`percent`})},c=z(`/{api_version}/triggers/{id}`)(s),l=new Headers(B({"Content-Type":`application/json`,Accept:`application/json`})),u=J(await Y(e._options.security)),d={options:e._options,base_url:i?.server_url??e._baseURL??``,operation_id:`UpdateTrigger`,o_auth2_scopes:null,resolved_security:u,security_source:e._options.security,retry_config:i?.retries||e._options.retry_config||{strategy:`attempt-count-backoff`,backoff:{initialInterval:500,maxInterval:8e3,exponent:2,maxElapsedTime:3e4},retryConnectionErrors:!0,maxRetries:4},retry_codes:i?.retry_codes||[`408`,`409`,`429`,`5XX`]},f=e._createRequest(d,{security:u,method:`PATCH`,baseURL:i?.server_url,path:c,headers:l,body:o,userAgent:e._options.user_agent,timeout_ms:i?.timeout_ms||e._options.timeout_ms||-1},i);if(!f.ok)return[f,{status:`invalid`}];let p=f.value,m=await e._do(p,{context:d,isErrorStatusCode:e=>H({status:e},[`4XX`,`5XX`]),retryConfig:d.retry_config,retryCodes:d.retry_codes});if(!m.ok)return[m,{status:`request-error`,request:p}];let h=m.value,[g]=await q(G(200),K(`4XX`),K(`5XX`))(h,p);return g.ok,[g,{status:`complete`,request:p,response:h}]}var jf=class extends sd{list(e,t){return Z(Tf(this,e?.api_version,e?.filter,e?.page_size,e?.page_token,t))}create(e,t){let{api_version:n}=e,r=F(e,[`api_version`]);return Z(_f(this,r,n,t))}delete(e,t,n){return Z(yf(this,e,t?.api_version,n))}get(e,t,n){return Z(xf(this,e,t?.api_version,n))}update(e,t,n){let{api_version:r}=t,i=F(t,[`api_version`]);return Z(kf(this,e,i,r,n))}listExecutions(e,t,n){return Z(Cf(this,e,t?.api_version,t?.page_size,t?.page_token,n))}run(e,t,n){return Z(Df(this,e,t?.api_version,n))}};function Mf(e,t,n,r){return new X(Nf(e,t,n,r))}async function Nf(e,t,n,r){let i={body:t,api_version:n},a=Au(`body`,i.body,{explode:!0}),o={api_version:V(`api_version`,i.api_version??e._options.api_version,{explode:!1,charEncoding:`percent`})},s=z(`/{api_version}/webhooks`)(o),c=new Headers(B({"Content-Type":`application/json`,Accept:`application/json`})),l=J(await Y(e._options.security)),u={options:e._options,base_url:r?.server_url??e._baseURL??``,operation_id:`CreateWebhook`,o_auth2_scopes:null,resolved_security:l,security_source:e._options.security,retry_config:r?.retries||e._options.retry_config||{strategy:`attempt-count-backoff`,backoff:{initialInterval:500,maxInterval:8e3,exponent:2,maxElapsedTime:3e4},retryConnectionErrors:!0,maxRetries:4},retry_codes:r?.retry_codes||[`408`,`409`,`429`,`5XX`]},d=e._createRequest(u,{security:l,method:`POST`,baseURL:r?.server_url,path:s,headers:c,body:a,userAgent:e._options.user_agent,timeout_ms:r?.timeout_ms||e._options.timeout_ms||-1},r);if(!d.ok)return[d,{status:`invalid`}];let f=d.value,p=await e._do(f,{context:u,isErrorStatusCode:e=>H({status:e},[`4XX`,`5XX`]),retryConfig:u.retry_config,retryCodes:u.retry_codes});if(!p.ok)return[p,{status:`request-error`,request:f}];let m=p.value,[h]=await q(K(`4XX`),K(`5XX`),G(`default`))(m,f);return h.ok,[h,{status:`complete`,request:f,response:m}]}function Pf(e,t,n,r){return new X(Ff(e,t,n,r))}async function Ff(e,t,n,r){let i={id:t,api_version:n},a={api_version:V(`api_version`,i.api_version??e._options.api_version,{explode:!1,charEncoding:`percent`}),id:V(`id`,i.id,{explode:!1,charEncoding:`percent`})},o=z(`/{api_version}/webhooks/{id}`)(a),s=new Headers(B({Accept:`application/json`})),c=J(await Y(e._options.security)),l={options:e._options,base_url:r?.server_url??e._baseURL??``,operation_id:`DeleteWebhook`,o_auth2_scopes:null,resolved_security:c,security_source:e._options.security,retry_config:r?.retries||e._options.retry_config||{strategy:`attempt-count-backoff`,backoff:{initialInterval:500,maxInterval:8e3,exponent:2,maxElapsedTime:3e4},retryConnectionErrors:!0,maxRetries:4},retry_codes:r?.retry_codes||[`408`,`409`,`429`,`5XX`]},u=e._createRequest(l,{security:c,method:`DELETE`,baseURL:r?.server_url,path:o,headers:s,body:null,userAgent:e._options.user_agent,timeout_ms:r?.timeout_ms||e._options.timeout_ms||-1},r);if(!u.ok)return[u,{status:`invalid`}];let d=u.value,f=await e._do(d,{context:l,isErrorStatusCode:e=>H({status:e},[`4XX`,`5XX`]),retryConfig:l.retry_config,retryCodes:l.retry_codes});if(!f.ok)return[f,{status:`request-error`,request:d}];let p=f.value,[m]=await q(K(`4XX`),K(`5XX`),G(`default`))(p,d);return m.ok,[m,{status:`complete`,request:d,response:p}]}function If(e,t,n,r){return new X(Lf(e,t,n,r))}async function Lf(e,t,n,r){let i={id:t,api_version:n},a={api_version:V(`api_version`,i.api_version??e._options.api_version,{explode:!1,charEncoding:`percent`}),id:V(`id`,i.id,{explode:!1,charEncoding:`percent`})},o=z(`/{api_version}/webhooks/{id}`)(a),s=new Headers(B({Accept:`application/json`})),c=J(await Y(e._options.security)),l={options:e._options,base_url:r?.server_url??e._baseURL??``,operation_id:`GetWebhook`,o_auth2_scopes:null,resolved_security:c,security_source:e._options.security,retry_config:r?.retries||e._options.retry_config||{strategy:`attempt-count-backoff`,backoff:{initialInterval:500,maxInterval:8e3,exponent:2,maxElapsedTime:3e4},retryConnectionErrors:!0,maxRetries:4},retry_codes:r?.retry_codes||[`408`,`409`,`429`,`5XX`]},u=e._createRequest(l,{security:c,method:`GET`,baseURL:r?.server_url,path:o,headers:s,body:null,userAgent:e._options.user_agent,timeout_ms:r?.timeout_ms||e._options.timeout_ms||-1},r);if(!u.ok)return[u,{status:`invalid`}];let d=u.value,f=await e._do(d,{context:l,isErrorStatusCode:e=>H({status:e},[`4XX`,`5XX`]),retryConfig:l.retry_config,retryCodes:l.retry_codes});if(!f.ok)return[f,{status:`request-error`,request:d}];let p=f.value,[m]=await q(K(`4XX`),K(`5XX`),G(`default`))(p,d);return m.ok,[m,{status:`complete`,request:d,response:p}]}function Rf(e,t,n,r,i){return new X(zf(e,t,n,r,i))}async function zf(e,t,n,r,i){let a={api_version:t,page_size:n,page_token:r},o={api_version:V(`api_version`,a?.api_version??e._options.api_version,{explode:!1,charEncoding:`percent`})},s=z(`/{api_version}/webhooks`)(o),c=Ru({page_size:a?.page_size,page_token:a?.page_token}),l=new Headers(B({Accept:`application/json`})),u=J(await Y(e._options.security)),d={options:e._options,base_url:i?.server_url??e._baseURL??``,operation_id:`ListWebhooks`,o_auth2_scopes:null,resolved_security:u,security_source:e._options.security,retry_config:i?.retries||e._options.retry_config||{strategy:`attempt-count-backoff`,backoff:{initialInterval:500,maxInterval:8e3,exponent:2,maxElapsedTime:3e4},retryConnectionErrors:!0,maxRetries:4},retry_codes:i?.retry_codes||[`408`,`409`,`429`,`5XX`]},f=e._createRequest(d,{security:u,method:`GET`,baseURL:i?.server_url,path:s,headers:l,query:c,body:null,userAgent:e._options.user_agent,timeout_ms:i?.timeout_ms||e._options.timeout_ms||-1},i);if(!f.ok)return[f,{status:`invalid`}];let p=f.value,m=await e._do(p,{context:d,isErrorStatusCode:e=>H({status:e},[`4XX`,`5XX`]),retryConfig:d.retry_config,retryCodes:d.retry_codes});if(!m.ok)return[m,{status:`request-error`,request:p}];let h=m.value,[g]=await q(K(`4XX`),K(`5XX`),G(`default`))(h,p);return g.ok,[g,{status:`complete`,request:p,response:h}]}function Bf(e,t,n,r,i){return new X(Vf(e,t,n,r,i))}async function Vf(e,t,n,r,i){let a={id:t,api_version:n,body:r},o=Au(`body`,a.body,{explode:!0}),s={api_version:V(`api_version`,a.api_version??e._options.api_version,{explode:!1,charEncoding:`percent`}),id:V(`id`,a.id,{explode:!1,charEncoding:`percent`})},c=z(`/{api_version}/webhooks/{id}:ping`)(s),l=new Headers(B({"Content-Type":`application/json`,Accept:`application/json`})),u=J(await Y(e._options.security)),d={options:e._options,base_url:i?.server_url??e._baseURL??``,operation_id:`PingWebhook`,o_auth2_scopes:null,resolved_security:u,security_source:e._options.security,retry_config:i?.retries||e._options.retry_config||{strategy:`attempt-count-backoff`,backoff:{initialInterval:500,maxInterval:8e3,exponent:2,maxElapsedTime:3e4},retryConnectionErrors:!0,maxRetries:4},retry_codes:i?.retry_codes||[`408`,`409`,`429`,`5XX`]},f=e._createRequest(d,{security:u,method:`POST`,baseURL:i?.server_url,path:c,headers:l,body:o,userAgent:e._options.user_agent,timeout_ms:i?.timeout_ms||e._options.timeout_ms||-1},i);if(!f.ok)return[f,{status:`invalid`}];let p=f.value,m=await e._do(p,{context:d,isErrorStatusCode:e=>H({status:e},[`4XX`,`5XX`]),retryConfig:d.retry_config,retryCodes:d.retry_codes});if(!m.ok)return[m,{status:`request-error`,request:p}];let h=m.value,[g]=await q(K(`4XX`),K(`5XX`),G(`default`))(h,p);return g.ok,[g,{status:`complete`,request:p,response:h}]}function Hf(e,t,n,r,i){return new X(Uf(e,t,n,r,i))}async function Uf(e,t,n,r,i){let a={id:t,api_version:n,body:r},o=Au(`body`,a.body,{explode:!0}),s={api_version:V(`api_version`,a.api_version??e._options.api_version,{explode:!1,charEncoding:`percent`}),id:V(`id`,a.id,{explode:!1,charEncoding:`percent`})},c=z(`/{api_version}/webhooks/{id}:rotateSigningSecret`)(s),l=new Headers(B({"Content-Type":`application/json`,Accept:`application/json`})),u=J(await Y(e._options.security)),d={options:e._options,base_url:i?.server_url??e._baseURL??``,operation_id:`RotateSigningSecret`,o_auth2_scopes:null,resolved_security:u,security_source:e._options.security,retry_config:i?.retries||e._options.retry_config||{strategy:`attempt-count-backoff`,backoff:{initialInterval:500,maxInterval:8e3,exponent:2,maxElapsedTime:3e4},retryConnectionErrors:!0,maxRetries:4},retry_codes:i?.retry_codes||[`408`,`409`,`429`,`5XX`]},f=e._createRequest(d,{security:u,method:`POST`,baseURL:i?.server_url,path:c,headers:l,body:o,userAgent:e._options.user_agent,timeout_ms:i?.timeout_ms||e._options.timeout_ms||-1},i);if(!f.ok)return[f,{status:`invalid`}];let p=f.value,m=await e._do(p,{context:d,isErrorStatusCode:e=>H({status:e},[`4XX`,`5XX`]),retryConfig:d.retry_config,retryCodes:d.retry_codes});if(!m.ok)return[m,{status:`request-error`,request:p}];let h=m.value,[g]=await q(K(`4XX`),K(`5XX`),G(`default`))(h,p);return g.ok,[g,{status:`complete`,request:p,response:h}]}function Wf(e,t,n,r,i,a){return new X(Gf(e,t,n,r,i,a))}async function Gf(e,t,n,r,i,a){let o={id:t,api_version:n,update_mask:r,body:i},s=Au(`body`,o.body,{explode:!0}),c={api_version:V(`api_version`,o.api_version??e._options.api_version,{explode:!1,charEncoding:`percent`}),id:V(`id`,o.id,{explode:!1,charEncoding:`percent`})},l=z(`/{api_version}/webhooks/{id}`)(c),u=Ru({update_mask:o.update_mask}),d=new Headers(B({"Content-Type":`application/json`,Accept:`application/json`})),f=J(await Y(e._options.security)),p={options:e._options,base_url:a?.server_url??e._baseURL??``,operation_id:`UpdateWebhook`,o_auth2_scopes:null,resolved_security:f,security_source:e._options.security,retry_config:a?.retries||e._options.retry_config||{strategy:`attempt-count-backoff`,backoff:{initialInterval:500,maxInterval:8e3,exponent:2,maxElapsedTime:3e4},retryConnectionErrors:!0,maxRetries:4},retry_codes:a?.retry_codes||[`408`,`409`,`429`,`5XX`]},m=e._createRequest(p,{security:f,method:`PATCH`,baseURL:a?.server_url,path:l,headers:d,query:u,body:s,userAgent:e._options.user_agent,timeout_ms:a?.timeout_ms||e._options.timeout_ms||-1},a);if(!m.ok)return[m,{status:`invalid`}];let h=m.value,g=await e._do(h,{context:p,isErrorStatusCode:e=>H({status:e},[`4XX`,`5XX`]),retryConfig:p.retry_config,retryCodes:p.retry_codes});if(!g.ok)return[g,{status:`request-error`,request:h}];let _=g.value,[v]=await q(K(`4XX`),K(`5XX`),G(`default`))(_,h);return v.ok,[v,{status:`complete`,request:h,response:_}]}var Kf=class extends sd{list(e,t){return Z(Rf(this,e?.api_version,e?.page_size,e?.page_token,t))}create(e,t){let{api_version:n}=e,r=F(e,[`api_version`]);return Z(Mf(this,r,n,t))}delete(e,t,n){return Z(Pf(this,e,t?.api_version,n))}get(e,t,n){return Z(If(this,e,t?.api_version,n))}update(e,t,n){let r=t??{},{api_version:i,update_mask:a}=r,o=F(r,[`api_version`,`update_mask`]),s=t===void 0||Object.keys(o).length===0?void 0:o;return Z(Wf(this,e,i,a,s,n))}ping(e,t,n,r){return Z(Bf(this,e,t,n,r))}rotateSigningSecret(e,t,n,r){return Z(Hf(this,e,t,n,r))}},qf=class extends sd{get agents(){return this._agents??=new Bd(this._options)}get environments(){return this._environments??=new Qd(this._options)}get interactions(){return this._interactions??=new gf(this._options)}get triggers(){return this._triggers??=new jf(this._options)}get webhooks(){return this._webhooks??=new Kf(this._options)}},Jf=new Set([`lyria-3-pro-preview`,`lyria-3-clip-preview`]);function Yf(e){let t=e.getBaseUrl();if(!t)throw Error(`Base URL must be set.`);return t.replace(/\/+$/,``)}function Xf(e){let t=np(e.getApiVersion()),n=e.getProject(),r=e.getLocation();return e.isVertexAI()&&t&&n&&r?`${t}/projects/${encodeURIComponent(n)}/locations/${encodeURIComponent(r)}`:t}function Zf(e,t={}){return new qf(Object.assign(Object.assign({},t),{api_version:t.api_version??Xf(e),security:t.security??new Tl({defaultHeaders:Object.assign(Object.assign({},e.getDefaultHeaders?.call(e)),e.getHeaders?.call(e)),getAuthHeaders:t=>e.getAuthHeaders(t)}),server_url:t.server_url??Yf(e)}))}var Qf=class{constructor(e){this.parentClient=e}async create(e,t){let{api_version:n}=e,r=F(e,[`api_version`]);return r.stream===!0?ap(await ip(()=>this.getClient(n).interactions.create(Object.assign(Object.assign({},r),{stream:!0,api_version:n}),Q(t,!0)))):cp(await $(uf(this.getClient(n),r,n,Q(t))))}async get(e,t={},n){let{api_version:r,stream:i=!1,last_event_id:a,include_input:o}=t??{};return i===!0?ap(await ip(()=>this.getClient(r).interactions.get(e,{stream:i,last_event_id:a,include_input:o,api_version:r},Q(n,!0)))):cp(await $(mf(this.getClient(r),e,r,o,a,i,Q(n))))}async delete(e,t={},n){return ip(()=>this.getClient(t?.api_version).interactions.delete(e,{api_version:t?.api_version},Q(n)))}async cancel(e,t={},n){return cp(await $(cf(this.getClient(t?.api_version),e,t?.api_version,Q(n))))}getClient(e){return e?Zf(this.parentClient,{api_version:e}):(this.sdk??=Zf(this.parentClient),this.sdk)}},$f=class{constructor(e){this.parentClient=e}async create(e={},t){let n=e??{},{api_version:r}=n,i=F(n,[`api_version`]);return $(Md(this.getClient(r),i,r,Q(t)))}async list(e={},t){let{api_version:n,pageSize:r,pageToken:i,parent:a}=e??{};return $(Rd(this.getClient(n),n,r,i,a,Q(t)))}async get(e,t={},n){return $(Id(this.getClient(t?.api_version),e,t?.api_version,Q(n)))}async delete(e,t={},n){return $(Pd(this.getClient(t?.api_version),e,t?.api_version,Q(n)))}getClient(e){return e?Zf(this.parentClient,{api_version:e}):(this.sdk??=Zf(this.parentClient),this.sdk)}},ep=class{constructor(e){this.parentClient=e}async create(e,t){let{api_version:n}=e,r=F(e,[`api_version`]);return $(Mf(this.getClient(),r,n,Q(t)))}async list(e={},t){let{api_version:n,page_size:r,page_token:i}=e??{};return $(Rf(this.getClient(),n,r,i,Q(t)))}async get(e,t={},n){return $(If(this.getClient(),e,t?.api_version,Q(n)))}async update(e,t={},n){let r=t??{},{api_version:i,update_mask:a}=r,o=F(r,[`api_version`,`update_mask`]);return $(Wf(this.getClient(),e,i,a,o,Q(n)))}async delete(e,t={},n){return $(Pf(this.getClient(),e,t?.api_version,Q(n)))}async rotateSigningSecret(e,t={},n){let r=t??{},{api_version:i}=r,a=F(r,[`api_version`]);return $(Hf(this.getClient(),e,i,a,Q(n)))}async ping(e,t=void 0,n){let{api_version:r,body:i}=t??{};return $(Bf(this.getClient(),e,r,i,Q(n)))}getClient(){return this.sdk??=Zf(this.parentClient),this.sdk}},tp=class{constructor(e){this.parentClient=e}async create(e,t){let{api_version:n}=e,r=F(e,[`api_version`]);return $(_f(this.getClient(n),r,n,Q(t)))}async list(e={},t){let{api_version:n,filter:r,pageSize:i,pageToken:a}=e??{};return $(Tf(this.getClient(n),n,r,i,a,Q(t)))}async get(e,t={},n){return $(xf(this.getClient(t?.api_version),e,t?.api_version,Q(n)))}async update(e,t,n){let{api_version:r}=t,i=F(t,[`api_version`]);return $(kf(this.getClient(r),e,i,r,Q(n)))}async delete(e,t={},n){return $(yf(this.getClient(t?.api_version),e,t?.api_version,Q(n)))}async run(e,t={},n){return $(Df(this.getClient(t?.api_version),e,t?.api_version,Q(n)))}async listExecutions(e,t={},n){let{api_version:r,pageSize:i,pageToken:a}=t??{};return $(Cf(this.getClient(r),e,r,i,a,Q(n)))}getClient(e){return e?Zf(this.parentClient,{api_version:e}):(this.sdk??=Zf(this.parentClient),this.sdk)}};function np(e){return e.replace(/^\/+|\/+$/g,``)}function Q(e,t=!1){if(!e&&!t)return;let n=e??{},{timeout:r,maxRetries:i,defaultBaseURL:a,query:o,body:s,fetchOptions:c}=n,l=F(n,[`timeout`,`maxRetries`,`defaultBaseURL`,`query`,`body`,`fetchOptions`]),u=Object.assign({},l);dp(o)?u.extra_query=o:rp(`query`,o),dp(s)?u.extra_body=s:rp(`body`,s);let d=l.fetch_options??c;d&&(u.fetch_options=d);let f=l.server_url??a;f&&(u.server_url=f);let p=l.timeout_ms??r;if(p!==void 0&&(u.timeout_ms=p),i!==void 0&&(u.retries={strategy:`attempt-count-backoff`,retryConnectionErrors:!0,maxRetries:i}),t){let e=new Headers(u.headers??d?.headers);e.set(`Accept`,`text/event-stream`),u.headers=e}return u}function rp(e,t){t!=null&&console.warn(`GoogleGenAI.interactions: request option ${e} is not supported by the Google GenAI interactions bridge and will be ignored.`)}async function $(e){let[t,n]=await e.$inspect();if(!t.ok)throw au(t.error);return op(t.value,n)}async function ip(e){try{return await e()}catch(e){throw au(e)}}function ap(e){let t=e;return new Proxy(e,{get(e,n){if(n!==Symbol.asyncIterator){let t=Reflect.get(e,n,e);return typeof t==`function`?t.bind(e):t}return function(){let e=t[Symbol.asyncIterator]();return{async next(...t){try{return await e.next(...t)}catch(e){throw au(e)}},async return(t){if(!e.return)return{done:!0,value:t};try{return await e.return(t)}catch(e){throw au(e)}},async throw(t){if(!e.throw)throw au(t);try{return await e.throw(t)}catch(e){throw au(e)}},[Symbol.asyncIterator](){return this}}}}})}function op(e,t){return!dp(e)||t.status!==`complete`?e:Object.assign(Object.assign({},e),{sdkHttpResponse:sp(t.response,e)})}function sp(e,t){let n={};for(let[t,r]of e.headers.entries())n[t]=r;return{headers:n,responseInternal:e,json:async()=>t}}function cp(e){let t=lp(e);return t?fp(t):e}function lp(e){if(dp(e)){if(Array.isArray(e.steps))return e;if(up(e)){let t=e.outputs;if(Array.isArray(t)){let{outputs:n}=e,r=F(e,[`outputs`]);return Object.assign(Object.assign({},r),{steps:[{type:`model_output`,content:t}]})}}return Object.assign(Object.assign({},e),{steps:[]})}}function up(e){let t=e.model;return typeof t==`string`&&Jf.has(t)}function dp(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function fp(e){let t=pp(e),n=t.steps??[],r=[],i=!1;outer:for(let e=n.length-1;e>=0;e--){let t=n[e];if(t.type===`user_input`)break;if(t.type!==`model_output`||!t.content){if(i)break;continue}let a=t.content;for(let e=a.length-1;e>=0;e--){let t=a[e];if(t.type===`text`)i=!0,r.push(t.text??``);else if(i)break outer}}let a,o,s;for(let e=n.length-1;e>=0;e--){let t=n[e];if(t.type===`user_input`)break;if(t.type===`model_output`&&t.content)for(let e=t.content.length-1;e>=0;e--){let n=t.content[e];n.type===`image`&&!a&&(a=n),n.type===`audio`&&!o&&(o=n),n.type===`video`&&!s&&(s=n)}}let c=r.reverse().join(``);return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},t),c&&{output_text:c}),a?{output_image:a}:{}),o?{output_audio:o}:{}),s?{output_video:s}:{})}function pp(e){return Object.assign(Object.assign({},e),{created:mp(e.created),updated:mp(e.updated)})}function mp(e){return e instanceof Date?e.toISOString():e}var hp=class{constructor(e){this.resolveClient=e}async list(e,t){let{environment:n,path:r,page_size:i,page_token:a,recursive:o,api_version:s}=e;return $(Yd(this.resolveClient(s),n,r,s,i,a,o,Q(t)))}},gp=class{constructor(e){this.parentClient=e,this.files=new hp(e=>this.getClient(e))}async create(e,t){let{api_version:n}=e,r=F(e,[`api_version`]);return $(Vd(this.getClient(n),r,n,Q(t)))}async list(e={},t){let{api_version:n,page_size:r,page_token:i}=e??{};return $(qd(this.getClient(n),n,r,i,Q(t)))}async get(e,t={},n){return $(Gd(this.getClient(t?.api_version),e,t?.api_version,Q(n)))}async delete(e,t={},n){return $(Ud(this.getClient(t?.api_version),e,t?.api_version,Q(n)))}getClient(e){return e?Zf(this.parentClient,{api_version:e}):(this.sdk??=Zf(this.parentClient),this.sdk)}};function _p(e,t){let n={},r=x(e,[`name`]);return r!=null&&b(n,[`_url`,`name`],r),n}function vp(e,t){let n={},r=x(e,[`name`]);return r!=null&&b(n,[`_url`,`name`],r),n}function yp(e,t){let n={},r=x(e,[`sdkHttpResponse`]);return r!=null&&b(n,[`sdkHttpResponse`],r),n}function bp(e,t){let n={},r=x(e,[`sdkHttpResponse`]);return r!=null&&b(n,[`sdkHttpResponse`],r),n}function xp(e,t){let n={},r=x(e,[`parts`]);if(r!=null){let e=r;Array.isArray(e)&&(e=e.map(e=>Fp(e))),b(n,[`parts`],e)}let i=x(e,[`role`]);return i!=null&&b(n,[`role`],i),n}function Sp(e,t,n){let r={};if(x(e,[`validationDataset`])!==void 0)throw Error(`validationDataset parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);let i=x(e,[`tunedModelDisplayName`]);if(t!==void 0&&i!=null&&b(t,[`displayName`],i),x(e,[`description`])!==void 0)throw Error(`description parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);let a=x(e,[`epochCount`]);t!==void 0&&a!=null&&b(t,[`tuningTask`,`hyperparameters`,`epochCount`],a);let o=x(e,[`learningRateMultiplier`]);if(o!=null&&b(r,[`tuningTask`,`hyperparameters`,`learningRateMultiplier`],o),x(e,[`exportLastCheckpointOnly`])!==void 0)throw Error(`exportLastCheckpointOnly parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);if(x(e,[`preTunedModelCheckpointId`])!==void 0)throw Error(`preTunedModelCheckpointId parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);if(x(e,[`adapterSize`])!==void 0)throw Error(`adapterSize parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);if(x(e,[`tuningMode`])!==void 0)throw Error(`tuningMode parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);if(x(e,[`customBaseModel`])!==void 0)throw Error(`customBaseModel parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);let s=x(e,[`batchSize`]);t!==void 0&&s!=null&&b(t,[`tuningTask`,`hyperparameters`,`batchSize`],s);let c=x(e,[`learningRate`]);if(t!==void 0&&c!=null&&b(t,[`tuningTask`,`hyperparameters`,`learningRate`],c),x(e,[`labels`])!==void 0)throw Error(`labels parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);if(x(e,[`beta`])!==void 0)throw Error(`beta parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);if(x(e,[`baseTeacherModel`])!==void 0)throw Error(`baseTeacherModel parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);if(x(e,[`tunedTeacherModelSource`])!==void 0)throw Error(`tunedTeacherModelSource parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);if(x(e,[`sftLossWeightMultiplier`])!==void 0)throw Error(`sftLossWeightMultiplier parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);if(x(e,[`outputUri`])!==void 0)throw Error(`outputUri parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);if(x(e,[`rewardConfig`])!==void 0)throw Error(`rewardConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);if(x(e,[`compositeRewardConfig`])!==void 0)throw Error(`compositeRewardConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);if(x(e,[`samplesPerPrompt`])!==void 0)throw Error(`samplesPerPrompt parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);if(x(e,[`evaluateInterval`])!==void 0)throw Error(`evaluateInterval parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);if(x(e,[`checkpointInterval`])!==void 0)throw Error(`checkpointInterval parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);if(x(e,[`maxOutputTokens`])!==void 0)throw Error(`maxOutputTokens parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);if(x(e,[`thinkingLevel`])!==void 0)throw Error(`thinkingLevel parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);if(x(e,[`validationDatasetUri`])!==void 0)throw Error(`validationDatasetUri parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);if(x(e,[`encryptionSpec`])!==void 0)throw Error(`encryptionSpec parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);return r}function Cp(e,t,n){let r={},i=x(n,[`config`,`method`]);if(i===void 0&&(i=`SUPERVISED_FINE_TUNING`),i===`SUPERVISED_FINE_TUNING`){let n=x(e,[`validationDataset`]);t!==void 0&&n!=null&&b(t,[`supervisedTuningSpec`],Up(n))}else if(i===`PREFERENCE_TUNING`){let n=x(e,[`validationDataset`]);t!==void 0&&n!=null&&b(t,[`preferenceOptimizationSpec`],Up(n))}else if(i===`DISTILLATION`){let n=x(e,[`validationDataset`]);t!==void 0&&n!=null&&b(t,[`distillationSpec`],Up(n))}else if(i===`REINFORCEMENT_TUNING`){let n=x(e,[`validationDataset`]);t!==void 0&&n!=null&&b(t,[`reinforcementTuningSpec`],Up(n))}let a=x(e,[`tunedModelDisplayName`]);t!==void 0&&a!=null&&b(t,[`tunedModelDisplayName`],a);let o=x(e,[`description`]);t!==void 0&&o!=null&&b(t,[`description`],o);let s=x(n,[`config`,`method`]);if(s===void 0&&(s=`SUPERVISED_FINE_TUNING`),s===`SUPERVISED_FINE_TUNING`){let n=x(e,[`epochCount`]);t!==void 0&&n!=null&&b(t,[`supervisedTuningSpec`,`hyperParameters`,`epochCount`],n)}else if(s===`PREFERENCE_TUNING`){let n=x(e,[`epochCount`]);t!==void 0&&n!=null&&b(t,[`preferenceOptimizationSpec`,`hyperParameters`,`epochCount`],n)}else if(s===`DISTILLATION`){let n=x(e,[`epochCount`]);t!==void 0&&n!=null&&b(t,[`distillationSpec`,`hyperParameters`,`epochCount`],n)}else if(s===`REINFORCEMENT_TUNING`){let n=x(e,[`epochCount`]);t!==void 0&&n!=null&&b(t,[`reinforcementTuningSpec`,`hyperParameters`,`epochCount`],n)}let c=x(n,[`config`,`method`]);if(c===void 0&&(c=`SUPERVISED_FINE_TUNING`),c===`SUPERVISED_FINE_TUNING`){let n=x(e,[`learningRateMultiplier`]);t!==void 0&&n!=null&&b(t,[`supervisedTuningSpec`,`hyperParameters`,`learningRateMultiplier`],n)}else if(c===`PREFERENCE_TUNING`){let n=x(e,[`learningRateMultiplier`]);t!==void 0&&n!=null&&b(t,[`preferenceOptimizationSpec`,`hyperParameters`,`learningRateMultiplier`],n)}else if(c===`DISTILLATION`){let n=x(e,[`learningRateMultiplier`]);t!==void 0&&n!=null&&b(t,[`distillationSpec`,`hyperParameters`,`learningRateMultiplier`],n)}else if(c===`REINFORCEMENT_TUNING`){let n=x(e,[`learningRateMultiplier`]);t!==void 0&&n!=null&&b(t,[`reinforcementTuningSpec`,`hyperParameters`,`learningRateMultiplier`],n)}let l=x(n,[`config`,`method`]);if(l===void 0&&(l=`SUPERVISED_FINE_TUNING`),l===`SUPERVISED_FINE_TUNING`){let n=x(e,[`exportLastCheckpointOnly`]);t!==void 0&&n!=null&&b(t,[`supervisedTuningSpec`,`exportLastCheckpointOnly`],n)}else if(l===`PREFERENCE_TUNING`){let n=x(e,[`exportLastCheckpointOnly`]);t!==void 0&&n!=null&&b(t,[`preferenceOptimizationSpec`,`exportLastCheckpointOnly`],n)}else if(l===`DISTILLATION`){let n=x(e,[`exportLastCheckpointOnly`]);t!==void 0&&n!=null&&b(t,[`distillationSpec`,`exportLastCheckpointOnly`],n)}let u=x(n,[`config`,`method`]);if(u===void 0&&(u=`SUPERVISED_FINE_TUNING`),u===`SUPERVISED_FINE_TUNING`){let n=x(e,[`adapterSize`]);t!==void 0&&n!=null&&b(t,[`supervisedTuningSpec`,`hyperParameters`,`adapterSize`],n)}else if(u===`PREFERENCE_TUNING`){let n=x(e,[`adapterSize`]);t!==void 0&&n!=null&&b(t,[`preferenceOptimizationSpec`,`hyperParameters`,`adapterSize`],n)}else if(u===`DISTILLATION`){let n=x(e,[`adapterSize`]);t!==void 0&&n!=null&&b(t,[`distillationSpec`,`hyperParameters`,`adapterSize`],n)}else if(u===`REINFORCEMENT_TUNING`){let n=x(e,[`adapterSize`]);t!==void 0&&n!=null&&b(t,[`reinforcementTuningSpec`,`hyperParameters`,`adapterSize`],n)}let d=x(n,[`config`,`method`]);if(d===void 0&&(d=`SUPERVISED_FINE_TUNING`),d===`SUPERVISED_FINE_TUNING`){let n=x(e,[`tuningMode`]);t!==void 0&&n!=null&&b(t,[`supervisedTuningSpec`,`tuningMode`],n)}else if(d===`DISTILLATION`){let n=x(e,[`tuningMode`]);t!==void 0&&n!=null&&b(t,[`distillationSpec`,`tuningMode`],n)}let f=x(e,[`customBaseModel`]);t!==void 0&&f!=null&&b(t,[`customBaseModel`],f);let p=x(n,[`config`,`method`]);if(p===void 0&&(p=`SUPERVISED_FINE_TUNING`),p===`SUPERVISED_FINE_TUNING`){let n=x(e,[`batchSize`]);t!==void 0&&n!=null&&b(t,[`supervisedTuningSpec`,`hyperParameters`,`batchSize`],n)}else if(p===`DISTILLATION`){let n=x(e,[`batchSize`]);t!==void 0&&n!=null&&b(t,[`distillationSpec`,`hyperParameters`,`batchSize`],n)}else if(p===`REINFORCEMENT_TUNING`){let n=x(e,[`batchSize`]);t!==void 0&&n!=null&&b(t,[`reinforcementTuningSpec`,`hyperParameters`,`batchSize`],n)}let m=x(n,[`config`,`method`]);if(m===void 0&&(m=`SUPERVISED_FINE_TUNING`),m===`SUPERVISED_FINE_TUNING`){let n=x(e,[`learningRate`]);t!==void 0&&n!=null&&b(t,[`supervisedTuningSpec`,`hyperParameters`,`learningRate`],n)}else if(m===`DISTILLATION`){let n=x(e,[`learningRate`]);t!==void 0&&n!=null&&b(t,[`distillationSpec`,`hyperParameters`,`learningRate`],n)}let h=x(e,[`labels`]);t!==void 0&&h!=null&&b(t,[`labels`],h);let g=x(e,[`beta`]);t!==void 0&&g!=null&&b(t,[`preferenceOptimizationSpec`,`hyperParameters`,`beta`],g);let _=x(e,[`baseTeacherModel`]);t!==void 0&&_!=null&&b(t,[`distillationSpec`,`baseTeacherModel`],_);let v=x(e,[`tunedTeacherModelSource`]);t!==void 0&&v!=null&&b(t,[`distillationSpec`,`tunedTeacherModelSource`],v);let y=x(e,[`sftLossWeightMultiplier`]);t!==void 0&&y!=null&&b(t,[`distillationSpec`,`hyperParameters`,`sftLossWeightMultiplier`],y);let S=x(e,[`outputUri`]);t!==void 0&&S!=null&&b(t,[`outputUri`],S);let C=x(e,[`rewardConfig`]);t!==void 0&&C!=null&&b(t,[`reinforcementTuningSpec`,`singleRewardConfig`],C);let w=x(e,[`compositeRewardConfig`]);t!==void 0&&w!=null&&b(t,[`reinforcementTuningSpec`,`compositeRewardConfig`],w);let T=x(e,[`samplesPerPrompt`]);t!==void 0&&T!=null&&b(t,[`reinforcementTuningSpec`,`hyperParameters`,`samplesPerPrompt`],T);let E=x(e,[`evaluateInterval`]);t!==void 0&&E!=null&&b(t,[`reinforcementTuningSpec`,`hyperParameters`,`evaluateInterval`],E);let D=x(e,[`checkpointInterval`]);t!==void 0&&D!=null&&b(t,[`reinforcementTuningSpec`,`hyperParameters`,`checkpointInterval`],D);let O=x(e,[`maxOutputTokens`]);t!==void 0&&O!=null&&b(t,[`reinforcementTuningSpec`,`hyperParameters`,`maxOutputTokens`],O);let k=x(e,[`thinkingLevel`]);t!==void 0&&k!=null&&b(t,[`reinforcementTuningSpec`,`hyperParameters`,`thinkingLevel`],k);let A=x(e,[`validationDatasetUri`]);t!==void 0&&A!=null&&b(t,[`reinforcementTuningSpec`,`validationDatasetUri`],A);let ee=x(e,[`encryptionSpec`]);return t!==void 0&&ee!=null&&b(t,[`encryptionSpec`],ee),r}function wp(e,t){let n={},r=x(e,[`baseModel`]);r!=null&&b(n,[`baseModel`],r);let i=x(e,[`preTunedModel`]);i!=null&&b(n,[`preTunedModel`],i);let a=x(e,[`trainingDataset`]);a!=null&&Rp(a);let o=x(e,[`config`]);return o!=null&&Sp(o,n),n}function Tp(e,t){let n={},r=x(e,[`baseModel`]);r!=null&&b(n,[`baseModel`],r);let i=x(e,[`preTunedModel`]);i!=null&&b(n,[`preTunedModel`],i);let a=x(e,[`trainingDataset`]);a!=null&&zp(a,n,t);let o=x(e,[`config`]);return o!=null&&Cp(o,n,t),n}function Ep(e,t){let n={},r=x(e,[`epochCount`]);r!=null&&b(n,[`epochCount`],r);let i=x(e,[`learningRateMultiplier`]);i!=null&&b(n,[`learningRateMultiplier`],i);let a=x(e,[`adapterSize`]);a!=null&&b(n,[`adapterSize`],a);let o=x(e,[`batchSize`]);o!=null&&b(n,[`batchSize`],o);let s=x(e,[`learningRate`]);s!=null&&b(n,[`learningRate`],s);let c=x(e,[`generationConfig`]);return c!=null&&b(n,[`generationConfig`],kp(c)),n}function Dp(e,t){let n={},r=x(e,[`promptDatasetUri`]);r!=null&&b(n,[`promptDatasetUri`],r);let i=x(e,[`validationDatasetUri`]);i!=null&&b(n,[`validationDatasetUri`],i);let a=x(e,[`baseTeacherModel`]);a!=null&&b(n,[`baseTeacherModel`],a);let o=x(e,[`tunedTeacherModelSource`]);o!=null&&b(n,[`tunedTeacherModelSource`],o);let s=x(e,[`hyperparameters`]);return s!=null&&b(n,[`hyperparameters`],Ep(s)),n}function Op(e,t){let n={},r=x(e,[`baseTeacherModel`]);r!=null&&b(n,[`baseTeacherModel`],r);let i=x(e,[`hyperParameters`]);i!=null&&b(n,[`hyperParameters`],Ep(i));let a=x(e,[`pipelineRootDirectory`]);a!=null&&b(n,[`pipelineRootDirectory`],a);let o=x(e,[`promptDatasetUri`]);o!=null&&b(n,[`promptDatasetUri`],o);let s=x(e,[`studentModel`]);s!=null&&b(n,[`studentModel`],s);let c=x(e,[`trainingDatasetUri`]);c!=null&&b(n,[`trainingDatasetUri`],c);let l=x(e,[`tunedTeacherModelSource`]);l!=null&&b(n,[`tunedTeacherModelSource`],l);let u=x(e,[`tuningMode`]);u!=null&&b(n,[`tuningMode`],u);let d=x(e,[`validationDatasetUri`]);return d!=null&&b(n,[`validationDatasetUri`],d),n}function kp(e,t){let n={},r=x(e,[`modelConfig`]);r!=null&&b(n,[`modelSelectionConfig`],r);let i=x(e,[`responseJsonSchema`]);i!=null&&b(n,[`responseJsonSchema`],Cn(i));let a=x(e,[`audioTranscriptionConfig`]);a!=null&&b(n,[`audioTranscriptionConfig`],a);let o=x(e,[`audioTimestamp`]);o!=null&&b(n,[`audioTimestamp`],o);let s=x(e,[`candidateCount`]);s!=null&&b(n,[`candidateCount`],s);let c=x(e,[`enableAffectiveDialog`]);c!=null&&b(n,[`enableAffectiveDialog`],c);let l=x(e,[`frequencyPenalty`]);l!=null&&b(n,[`frequencyPenalty`],l);let u=x(e,[`logprobs`]);u!=null&&b(n,[`logprobs`],u);let d=x(e,[`maxOutputTokens`]);d!=null&&b(n,[`maxOutputTokens`],d);let f=x(e,[`mediaResolution`]);f!=null&&b(n,[`mediaResolution`],f);let p=x(e,[`presencePenalty`]);p!=null&&b(n,[`presencePenalty`],p);let m=x(e,[`responseFormat`]);if(m!=null){let e=m;Array.isArray(e)&&(e=e.map(e=>e)),b(n,[`responseFormat`],e)}let h=x(e,[`responseLogprobs`]);h!=null&&b(n,[`responseLogprobs`],h);let g=x(e,[`responseMimeType`]);g!=null&&b(n,[`responseMimeType`],g);let _=x(e,[`responseModalities`]);_!=null&&b(n,[`responseModalities`],_);let v=x(e,[`responseSchema`]);v!=null&&b(n,[`responseSchema`],v);let y=x(e,[`routingConfig`]);y!=null&&b(n,[`routingConfig`],y);let S=x(e,[`seed`]);S!=null&&b(n,[`seed`],S);let C=x(e,[`speechConfig`]);C!=null&&b(n,[`speechConfig`],C);let w=x(e,[`stopSequences`]);w!=null&&b(n,[`stopSequences`],w);let T=x(e,[`temperature`]);T!=null&&b(n,[`temperature`],T);let E=x(e,[`thinkingConfig`]);E!=null&&b(n,[`thinkingConfig`],E);let D=x(e,[`topK`]);D!=null&&b(n,[`topK`],D);let O=x(e,[`topP`]);return O!=null&&b(n,[`topP`],O),n}function Ap(e,t){let n={},r=x(e,[`name`]);return r!=null&&b(n,[`_url`,`name`],r),n}function jp(e,t){let n={},r=x(e,[`name`]);return r!=null&&b(n,[`_url`,`name`],r),n}function Mp(e,t,n){let r={},i=x(e,[`pageSize`]);t!==void 0&&i!=null&&b(t,[`_query`,`pageSize`],i);let a=x(e,[`pageToken`]);t!==void 0&&a!=null&&b(t,[`_query`,`pageToken`],a);let o=x(e,[`filter`]);return t!==void 0&&o!=null&&b(t,[`_query`,`filter`],o),r}function Np(e,t){let n={},r=x(e,[`config`]);return r!=null&&Mp(r,n),n}function Pp(e,t){let n={},r=x(e,[`sdkHttpResponse`]);r!=null&&b(n,[`sdkHttpResponse`],r);let i=x(e,[`nextPageToken`]);i!=null&&b(n,[`nextPageToken`],i);let a=x(e,[`tuningJobs`]);if(a!=null){let e=a;Array.isArray(e)&&(e=e.map(e=>Vp(e))),b(n,[`tuningJobs`],e)}return n}function Fp(e,t){let n={},r=x(e,[`mediaResolution`]);if(r!=null&&b(n,[`mediaResolution`],r),x(e,[`toolCall`])!==void 0)throw Error(`toolCall parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.`);if(x(e,[`toolResponse`])!==void 0)throw Error(`toolResponse parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.`);let i=x(e,[`audioTranscription`]);i!=null&&b(n,[`audioTranscription`],i);let a=x(e,[`codeExecutionResult`]);a!=null&&b(n,[`codeExecutionResult`],a);let o=x(e,[`executableCode`]);o!=null&&b(n,[`executableCode`],o);let s=x(e,[`fileData`]);s!=null&&b(n,[`fileData`],s);let c=x(e,[`functionCall`]);c!=null&&b(n,[`functionCall`],c);let l=x(e,[`functionResponse`]);l!=null&&b(n,[`functionResponse`],l);let u=x(e,[`inlineData`]);u!=null&&b(n,[`inlineData`],u);let d=x(e,[`text`]);d!=null&&b(n,[`text`],d);let f=x(e,[`thought`]);f!=null&&b(n,[`thought`],f);let p=x(e,[`thoughtSignature`]);p!=null&&b(n,[`thoughtSignature`],p);let m=x(e,[`videoMetadata`]);if(m!=null&&b(n,[`videoMetadata`],m),x(e,[`partMetadata`])!==void 0)throw Error(`partMetadata parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.`);let h=x(e,[`mediaProcessing`]);return h!=null&&b(n,[`mediaProcessing`],h),n}function Ip(e,t){let n={},r=x(e,[`references`]);r!=null&&b(n,[`references`],r);let i=x(e,[`contents`]);if(i!=null){let e=i;Array.isArray(e)&&(e=e.map(e=>xp(e))),b(n,[`contents`],e)}let a=x(e,[`systemInstruction`]);return a!=null&&b(n,[`systemInstruction`],xp(a)),n}function Lp(e,t){let n={},r=x(e,[`name`]);r!=null&&b(n,[`model`],r);let i=x(e,[`name`]);return i!=null&&b(n,[`endpoint`],i),n}function Rp(e,t){let n={};if(x(e,[`gcsUri`])!==void 0)throw Error(`gcsUri parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);if(x(e,[`vertexDatasetResource`])!==void 0)throw Error(`vertexDatasetResource parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.`);let r=x(e,[`examples`]);if(r!=null){let e=r;Array.isArray(e)&&(e=e.map(e=>e)),b(n,[`examples`,`examples`],e)}return n}function zp(e,t,n){let r={},i=x(n,[`config`,`method`]);if(i===void 0&&(i=`SUPERVISED_FINE_TUNING`),i===`SUPERVISED_FINE_TUNING`){let n=x(e,[`gcsUri`]);t!==void 0&&n!=null&&b(t,[`supervisedTuningSpec`,`trainingDatasetUri`],n)}else if(i===`PREFERENCE_TUNING`){let n=x(e,[`gcsUri`]);t!==void 0&&n!=null&&b(t,[`preferenceOptimizationSpec`,`trainingDatasetUri`],n)}else if(i===`DISTILLATION`){let n=x(e,[`gcsUri`]);t!==void 0&&n!=null&&b(t,[`distillationSpec`,`promptDatasetUri`],n)}else if(i===`REINFORCEMENT_TUNING`){let n=x(e,[`gcsUri`]);t!==void 0&&n!=null&&b(t,[`reinforcementTuningSpec`,`trainingDatasetUri`],n)}let a=x(n,[`config`,`method`]);if(a===void 0&&(a=`SUPERVISED_FINE_TUNING`),a===`SUPERVISED_FINE_TUNING`){let n=x(e,[`vertexDatasetResource`]);t!==void 0&&n!=null&&b(t,[`supervisedTuningSpec`,`trainingDatasetUri`],n)}else if(a===`PREFERENCE_TUNING`){let n=x(e,[`vertexDatasetResource`]);t!==void 0&&n!=null&&b(t,[`preferenceOptimizationSpec`,`trainingDatasetUri`],n)}else if(a===`DISTILLATION`){let n=x(e,[`vertexDatasetResource`]);t!==void 0&&n!=null&&b(t,[`distillationSpec`,`promptDatasetUri`],n)}else if(a===`REINFORCEMENT_TUNING`){let n=x(e,[`vertexDatasetResource`]);t!==void 0&&n!=null&&b(t,[`reinforcementTuningSpec`,`trainingDatasetUri`],n)}if(x(e,[`examples`])!==void 0)throw Error(`examples parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.`);return r}function Bp(e,t){let n={},r=x(e,[`sdkHttpResponse`]);r!=null&&b(n,[`sdkHttpResponse`],r);let i=x(e,[`name`]);i!=null&&b(n,[`name`],i);let a=x(e,[`state`]);a!=null&&b(n,[`state`],An(a));let o=x(e,[`createTime`]);o!=null&&b(n,[`createTime`],o);let s=x(e,[`tuningTask`,`startTime`]);s!=null&&b(n,[`startTime`],s);let c=x(e,[`tuningTask`,`completeTime`]);c!=null&&b(n,[`endTime`],c);let l=x(e,[`updateTime`]);l!=null&&b(n,[`updateTime`],l);let u=x(e,[`description`]);u!=null&&b(n,[`description`],u);let d=x(e,[`baseModel`]);d!=null&&b(n,[`baseModel`],d);let f=x(e,[`_self`]);return f!=null&&b(n,[`tunedModel`],Lp(f)),n}function Vp(e,t){let n={},r=x(e,[`sdkHttpResponse`]);r!=null&&b(n,[`sdkHttpResponse`],r);let i=x(e,[`name`]);i!=null&&b(n,[`name`],i);let a=x(e,[`state`]);a!=null&&b(n,[`state`],An(a));let o=x(e,[`createTime`]);o!=null&&b(n,[`createTime`],o);let s=x(e,[`startTime`]);s!=null&&b(n,[`startTime`],s);let c=x(e,[`endTime`]);c!=null&&b(n,[`endTime`],c);let l=x(e,[`updateTime`]);l!=null&&b(n,[`updateTime`],l);let u=x(e,[`error`]);u!=null&&b(n,[`error`],u);let d=x(e,[`description`]);d!=null&&b(n,[`description`],d);let f=x(e,[`baseModel`]);f!=null&&b(n,[`baseModel`],f);let p=x(e,[`tunedModel`]);p!=null&&b(n,[`tunedModel`],p);let m=x(e,[`preTunedModel`]);m!=null&&b(n,[`preTunedModel`],m);let h=x(e,[`supervisedTuningSpec`]);h!=null&&b(n,[`supervisedTuningSpec`],h);let g=x(e,[`preferenceOptimizationSpec`]);g!=null&&b(n,[`preferenceOptimizationSpec`],g);let _=x(e,[`distillationSamplingSpec`]);_!=null&&b(n,[`distillationSamplingSpec`],Dp(_));let v=x(e,[`distillationSpec`]);v!=null&&b(n,[`distillationSpec`],Op(v));let y=x(e,[`reinforcementTuningSpec`]);y!=null&&b(n,[`reinforcementTuningSpec`],y);let S=x(e,[`tuningDataStats`]);S!=null&&b(n,[`tuningDataStats`],S);let C=x(e,[`encryptionSpec`]);C!=null&&b(n,[`encryptionSpec`],C);let w=x(e,[`partnerModelTuningSpec`]);w!=null&&b(n,[`partnerModelTuningSpec`],w);let T=x(e,[`customBaseModel`]);T!=null&&b(n,[`customBaseModel`],T);let E=x(e,[`evaluateDatasetRuns`]);if(E!=null){let e=E;Array.isArray(e)&&(e=e.map(e=>e)),b(n,[`evaluateDatasetRuns`],e)}let D=x(e,[`experiment`]);D!=null&&b(n,[`experiment`],D);let O=x(e,[`fullFineTuningSpec`]);O!=null&&b(n,[`fullFineTuningSpec`],O);let k=x(e,[`labels`]);k!=null&&b(n,[`labels`],k);let A=x(e,[`outputUri`]);A!=null&&b(n,[`outputUri`],A);let ee=x(e,[`pipelineJob`]);ee!=null&&b(n,[`pipelineJob`],ee);let te=x(e,[`serviceAccount`]);te!=null&&b(n,[`serviceAccount`],te);let ne=x(e,[`tunedModelDisplayName`]);ne!=null&&b(n,[`tunedModelDisplayName`],ne);let re=x(e,[`tuningJobMetadata`]);re!=null&&b(n,[`tuningJobMetadata`],re);let ie=x(e,[`tuningJobState`]);ie!=null&&b(n,[`tuningJobState`],ie);let ae=x(e,[`veoLoraTuningSpec`]);ae!=null&&b(n,[`veoLoraTuningSpec`],ae);let oe=x(e,[`veoTuningSpec`]);return oe!=null&&b(n,[`veoTuningSpec`],oe),n}function Hp(e,t){let n={},r=x(e,[`sdkHttpResponse`]);r!=null&&b(n,[`sdkHttpResponse`],r);let i=x(e,[`name`]);i!=null&&b(n,[`name`],i);let a=x(e,[`metadata`]);a!=null&&b(n,[`metadata`],a);let o=x(e,[`done`]);o!=null&&b(n,[`done`],o);let s=x(e,[`error`]);return s!=null&&b(n,[`error`],s),n}function Up(e,t){let n={},r=x(e,[`gcsUri`]);r!=null&&b(n,[`validationDatasetUri`],r);let i=x(e,[`vertexDatasetResource`]);return i!=null&&b(n,[`validationDatasetUri`],i),n}function Wp(e,t){let n={},r=x(e,[`parent`]);r!=null&&b(n,[`_url`,`parent`],r);let i=x(e,[`sampleResponse`]);i!=null&&b(n,[`sampleResponse`],xp(i));let a=x(e,[`example`]);a!=null&&b(n,[`example`],Ip(a));let o=x(e,[`singleRewardConfig`]);o!=null&&b(n,[`singleRewardConfig`],o);let s=x(e,[`compositeRewardConfig`]);return s!=null&&b(n,[`compositeRewardConfig`],s),n}function Gp(e,t){let n={},r=x(e,[`sdkHttpResponse`]);r!=null&&b(n,[`sdkHttpResponse`],r);let i=x(e,[`overallReward`]);i!=null&&b(n,[`overallReward`],i);let a=x(e,[`error`]);a!=null&&b(n,[`error`],a);let o=x(e,[`rewardInfoDetails`]);return o!=null&&b(n,[`rewardInfoDetails`],o),n}var Kp=class extends v{constructor(e){super(),this.apiClient=e,this.list=async(e={})=>new Kr(Gr.PAGED_ITEM_TUNING_JOBS,e=>this.listInternal(e),await this.listInternal(e),e),this.get=async e=>await this.getInternal(e),this.tune=async e=>{if(this.apiClient.isVertexAI()){if(e.baseModel.startsWith(`projects/`)){let t={tunedModelName:e.baseModel};e.config?.preTunedModelCheckpointId&&(t.checkpointId=e.config.preTunedModelCheckpointId);let n=Object.assign(Object.assign({},e),{preTunedModel:t});return n.baseModel=void 0,await this.tuneInternal(n)}{let t=Object.assign({},e);return await this.tuneInternal(t)}}{let t=Object.assign({},e),n=await this.tuneMldevInternal(t),r=``;return n.metadata!==void 0&&n.metadata.tunedModel!==void 0?r=n.metadata.tunedModel:n.name!==void 0&&n.name.includes(`/operations/`)&&(r=n.name.split(`/operations/`)[0]),{name:r,state:Ge.JOB_STATE_QUEUED}}}}async getInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=jp(e);return n=y(`{name}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>Vp(e))}{let i=Ap(e);return n=y(`{name}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>Bp(e))}}async listInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=Np(e);return n=y(`tuningJobs`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=Pp(e),n=new Gt;return Object.assign(n,t),n})}throw Error(`This method is only supported by the Gemini Enterprise Agent Platform (previously known as Vertex AI).`)}async cancel(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=vp(e);return n=y(`{name}:cancel`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=bp(e),n=new Kt;return Object.assign(n,t),n})}{let i=_p(e);return n=y(`{name}:cancel`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=yp(e),n=new Kt;return Object.assign(n,t),n})}}async tuneInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=Tp(e,e);return n=y(`tuningJobs`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>Vp(e))}throw Error(`This method is only supported by the Gemini Enterprise Agent Platform (previously known as Vertex AI).`)}async tuneMldevInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI())throw Error(`This method is only supported by the Gemini Developer API.`);{let i=wp(e);return n=y(`tunedModels`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>Hp(e))}}async validateReward(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=Wp(e);return n=y(`{parent}/tuningJobs:validateReinforcementTuningReward`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=Gp(e),n=new qt;return Object.assign(n,t),n})}throw Error(`This method is only supported by the Gemini Enterprise Agent Platform (previously known as Vertex AI).`)}},qp=class{async download(e,t){throw Error(`Download to file is not supported in the browser, please use a browser compliant download like an <a> tag.`)}},Jp=8388608,Yp=3,Xp=1e3,Zp=2,Qp=`x-goog-upload-status`;async function $p(e,t,n,r){let i=await tm(e,t,n,r),a=await i?.json();if(i?.headers?.[Qp]!==`final`)throw Error(`Failed to upload file: Upload status is not finalized.`);return a.file}async function em(e,t,n,r){let i=await tm(e,t,n,r),a=await i?.json();if(i?.headers?.[Qp]!==`final`)throw Error(`Failed to upload file: Upload status is not finalized.`);let o=ae(a),s=new cn;return Object.assign(s,o),s}async function tm(e,t,n,r){let i=t,a=r?.baseUrl||n.clientOptions.httpOptions?.baseUrl;if(a){let e=new URL(a),n=new URL(t);n.protocol=e.protocol,n.host=e.host,n.port=e.port,i=n.toString()}let o=0,s=0,c=new Mt(new Response),l=`upload`;for(o=e.size;s<o;){let t=Math.min(Jp,o-s),a=e.slice(s,s+t);s+t>=o&&(l+=`, finalize`);let u=0,d=Xp;for(;u<Yp;){let e=Object.assign(Object.assign({},r?.headers||{}),{"X-Goog-Upload-Command":l,"X-Goog-Upload-Offset":String(s)});if(c=await n.request({path:``,body:a,httpMethod:`POST`,httpOptions:Object.assign(Object.assign({},r),{apiVersion:``,baseUrl:i,headers:e})}),c?.headers?.[Qp])break;u++,await rm(d),d*=Zp}if(s+=t,c?.headers?.[Qp]!==`active`)break;if(o<=s)throw Error(`All content has been uploaded, but the upload status is not finalized.`)}return c}async function nm(e){return{size:e.size,type:e.type}}function rm(e){return new Promise(t=>setTimeout(t,e))}var im=class{async upload(e,t,n,r){if(typeof e==`string`)throw Error(`File path is not supported in browser uploader.`);return await $p(e,t,n,r)}async uploadToFileSearchStore(e,t,n,r){if(typeof e==`string`)throw Error(`File path is not supported in browser uploader.`);return await em(e,t,n,r)}async stat(e){if(typeof e==`string`)throw Error(`File path is not supported in browser uploader.`);return await nm(e)}},am=class{create(e,t,n){return new om(e,t,n)}},om=class{constructor(e,t,n){this.url=e,this.headers=t,this.callbacks=n}connect(){this.ws=new WebSocket(this.url),this.ws.onopen=this.callbacks.onopen,this.ws.onerror=this.callbacks.onerror,this.ws.onclose=this.callbacks.onclose,this.ws.onmessage=this.callbacks.onmessage}send(e){if(this.ws===void 0)throw Error(`WebSocket is not connected`);this.ws.send(e)}close(){if(this.ws===void 0)throw Error(`WebSocket is not connected`);this.ws.close()}},sm=`x-goog-api-key`,cm=class{constructor(e){this.apiKey=e}async addAuthHeaders(e,t){if(e.get(sm)===null){if(this.apiKey.startsWith(`auth_tokens/`))throw Error(`Ephemeral tokens are only supported by the live API.`);if(!this.apiKey)throw Error(`API key is missing. Please provide a valid API key.`);e.append(sm,this.apiKey)}}},lm=class{getNextGenClient(){let e=this.httpOptions;return this._nextGenClient===void 0&&(this._nextGenClient=Zf(this.apiClient,{timeout_ms:e?.timeout})),e?.extraBody&&console.warn(`GoogleGenAI: Client level httpOptions.extraBody is not supported by the Gemini NextGen client and will be ignored.`),this._nextGenClient}get interactions(){return this._interactions===void 0&&(this._interactions=new Qf(this.apiClient)),this._interactions}get webhooks(){return this._webhooks===void 0&&(this._webhooks=new ep(this.apiClient)),this._webhooks}get agents(){return this._agents===void 0?(console.warn(`GoogleGenAI.agents: Agents usage is experimental and may change in future versions.`),this._agents=new $f(this.apiClient),this._agents):this._agents}get triggers(){return this._triggers===void 0?(console.warn(`GoogleGenAI.triggers: Triggers usage is experimental and may change in future versions.`),this._triggers=new tp(this.apiClient),this._triggers):this._triggers}get environments(){return this._environments===void 0?(console.warn(`GoogleGenAI.environments: Environments usage is experimental and may change in future versions.`),this._environments=new gp(this.apiClient),this._environments):this._environments}constructor(e={}){if(e.apiKey==null)throw Error(`An API Key must be set when running in a browser`);if(e.project||e.location)throw Error(`Vertex AI project based authentication is not supported on browser runtimes. Please do not provide a project or location.`);this.vertexai=e.vertexai??!1,this.apiKey=e.apiKey;let t=_(e.httpOptions,e.vertexai,void 0,void 0);t&&(e.httpOptions?e.httpOptions.baseUrl=t:e.httpOptions={baseUrl:t}),this.apiVersion=e.apiVersion,this.httpOptions=e.httpOptions;let n=new cm(this.apiKey);this.apiClient=new yc({auth:n,apiVersion:this.apiVersion,apiKey:this.apiKey,vertexai:this.vertexai,httpOptions:this.httpOptions,userAgentExtra:`gl-node/web`,uploader:new im,downloader:new qp}),this.models=new qc(this.apiClient),this.live=new Ic(this.apiClient,n,new am),this.batches=new qr(this.apiClient),this.chats=new zi(this.models,this.apiClient),this.caches=new ji(this.apiClient),this.files=new Qi(this.apiClient),this.operations=new Jc(this.apiClient),this.authTokens=new fl(this.apiClient),this.tunings=new Kp(this.apiClient),this.fileSearchStores=new bl(this.apiClient)}},um={THINKING_LEVEL_UNSPECIFIED:xe.THINKING_LEVEL_UNSPECIFIED,MINIMAL:xe.MINIMAL,LOW:xe.LOW,MEDIUM:xe.MEDIUM,HIGH:xe.HIGH};function dm(e,t){let n=e.thinkingLevelMap?.[t],r=typeof n==`string`?n.toLowerCase():t;switch(r){case`minimal`:case`low`:case`medium`:case`high`:return r;default:throw Error(`Unsupported Google thinking level mapping for ${e.provider}/${e.id}: ${t} -> ${String(n)}`)}}function fm(e){let t=e.id.toLowerCase();return/gemini-3(?:\.\d+)?-(?:pro|flash)/.test(t)||t===`gemini-flash-latest`||t===`gemini-flash-lite-latest`||/gemma-?4/.test(t)}function pm(e){switch(e){case`minimal`:return`MINIMAL`;case`low`:return`LOW`;case`medium`:return`MEDIUM`;case`high`:return`HIGH`}}function mm(e){return um[e]}function hm(e){if(!fm(e))return{thinkingBudget:0};let t=i(e,`off`);return t===`off`?{thinkingBudget:0}:{thinkingLevel:mm(pm(dm(e,t)))}}function gm(e){return e.thought===!0}function _m(e,t){return typeof t==`string`&&t.length>0?t:e}var vm=/^[A-Za-z0-9+/]+={0,2}$/;function ym(e){return!e||e.length%4!=0?!1:vm.test(e)}function bm(e,t){return e&&ym(t)?t:void 0}function xm(e){let t=Sm(e);return e.startsWith(`claude-`)||e.startsWith(`gpt-oss-`)||t!==void 0&&t>=3}function Sm(e){let t=e.toLowerCase().match(/^gemini(?:-live)?-(\d+)/);if(t)return Number.parseInt(t[1],10)}function Cm(e){let t=Sm(e);return t===void 0||t>=3}function wm(e,t){let i=n(r(t).messages),a=[],s=o(i,e,t=>xm(e.id)?t.replace(/[^a-zA-Z0-9_-]/g,`_`).slice(0,64):t);for(let t of s)if(t.role===`user`){if(typeof t.content==`string`)a.push({role:`user`,parts:[{text:l(t.content)}]});else{let e=t.content.map(e=>e.type===`text`?{text:l(e.text)}:{inlineData:{mimeType:e.mimeType,data:e.data}});if(e.length===0)continue;a.push({role:`user`,parts:e})}}else if(t.role===`assistant`){let n=[],r=t.provider===e.provider&&t.model===e.id;for(let i of t.content)if(i.type===`text`){let e=bm(r,i.textSignature);if((!i.text||i.text.trim()===``)&&!e)continue;n.push({text:l(i.text),...e&&{thoughtSignature:e}})}else if(i.type===`thinking`){if(r){let e=bm(r,i.thinkingSignature);if((!i.thinking||i.thinking.trim()===``)&&!e)continue;n.push({thought:!0,text:l(i.thinking),...e&&{thoughtSignature:e}})}else{if(!i.thinking||i.thinking.trim()===``)continue;n.push({text:l(i.thinking)})}}else if(i.type===`toolCall`){let t=bm(r,i.thoughtSignature),a={functionCall:{name:i.name,args:i.arguments??{},...xm(e.id)?{id:i.id}:{}},...t&&{thoughtSignature:t}};n.push(a)}if(n.length===0)continue;a.push({role:`model`,parts:n})}else if(t.role===`toolResult`){let n=t.content.filter(e=>e.type===`text`).map(e=>e.text).join(`
|
|
8
|
+
`),r=e.input.includes(`image`)?t.content.filter(e=>e.type===`image`):[],i=n.length>0,o=r.length>0,s=Cm(e.id),c=i?l(n):o?`(see attached image)`:``,u=r.map(e=>({inlineData:{mimeType:e.mimeType,data:e.data}})),d=xm(e.id),f={functionResponse:{name:t.toolName,response:t.isError?{error:c}:{output:c},...o&&s&&{parts:u},...d?{id:t.toolCallId}:{}}},p=a[a.length-1];p?.role===`user`&&p.parts?.some(e=>e.functionResponse)?p.parts.push(f):a.push({role:`user`,parts:[f]}),o&&!s&&a.push({role:`user`,parts:[{text:`Tool result image:`},...u]})}return a}var Tm=new Set([`$schema`,`$id`,`$anchor`,`$dynamicAnchor`,`$vocabulary`,`$comment`,`$defs`,`definitions`]);function Em(e){if(typeof e!=`object`||!e||Array.isArray(e))return e;let t={};for(let[n,r]of Object.entries(e))Tm.has(n)||(t[n]=Em(r));return t}function Dm(e,t=!1,n=!0){if(e.length!==0)return[{functionDeclarations:e.map(e=>{let r=a(e,n),i=s(e,r);return{name:e.name,description:e.description,...t?{parameters:Em(i)}:{parametersJsonSchema:i}}})}]}function Om(e){let t=Sm(e);return t!==void 0&&t>=3}function km(e){switch(e){case`auto`:return De.AUTO;case`none`:return De.NONE;case`any`:return De.ANY;default:return De.AUTO}}function Am(e,t,n){let r=e.some(e=>a(e,n)===!0);return t===`none`||t===`any`?km(t):r?De.VALIDATED:t?km(t):void 0}function jm(e){switch(e){case j.STOP:return`stop`;case j.MAX_TOKENS:return`length`;case j.BLOCKLIST:case j.PROHIBITED_CONTENT:case j.SPII:case j.SAFETY:case j.IMAGE_SAFETY:case j.IMAGE_PROHIBITED_CONTENT:case j.IMAGE_RECITATION:case j.IMAGE_OTHER:case j.RECITATION:case j.FINISH_REASON_UNSPECIFIED:case j.OTHER:case j.LANGUAGE:case j.MALFORMED_FUNCTION_CALL:case j.UNEXPECTED_TOOL_CALL:case j.TOO_MANY_TOOL_CALLS:case j.NO_IMAGE:return`error`;default:throw Error(`Unhandled stop reason: ${e}`)}}function Mm(e,t){return c(async()=>{try{return await e()}catch(e){throw e instanceof Error&&`status`in e&&!(`headers`in e)&&(e.headers=void 0),e}},{maxRetries:t?.maxRetries,maxRetryDelayMs:t?.maxRetryDelayMs,signal:t?.signal})}export{jm as a,_m as c,mm as d,pm as f,rt as h,gm as i,Mm as l,lm as m,Dm as n,Am as o,fm as p,hm as r,dm as s,wm as t,Om as u};
|