@glair/web-components
Version:
A collection of GLAIR's web components
1,370 lines (1,369 loc) • 372 kB
JavaScript
import { css as Jt, LitElement as $t, html as ge } from "lit";
import { property as Wt, state as J, customElement as Yt } from "lit/decorators.js";
import { createRef as Be, ref as He } from "lit/directives/ref.js";
/**
* @license
* Copyright 2025 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
let Kt, bt;
function zt() {
return {
geminiUrl: Kt,
vertexUrl: bt
};
}
function Xt(n, e, t, o) {
var r, l;
if (!(n != null && n.baseUrl)) {
const a = zt();
return e ? (r = a.vertexUrl) !== null && r !== void 0 ? r : t : (l = a.geminiUrl) !== null && l !== void 0 ? l : o;
}
return n.baseUrl;
}
/**
* @license
* Copyright 2025 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
class W {
}
function v(n, e) {
const t = /\{([^}]+)\}/g;
return n.replace(t, (o, r) => {
if (Object.prototype.hasOwnProperty.call(e, r)) {
const l = e[r];
return l != null ? String(l) : "";
} else
throw new Error(`Key '${r}' not found in valueMap.`);
});
}
function s(n, e, t) {
for (let l = 0; l < e.length - 1; l++) {
const a = e[l];
if (a.endsWith("[]")) {
const u = a.slice(0, -2);
if (!(u in n))
if (Array.isArray(t))
n[u] = Array.from({ length: t.length }, () => ({}));
else
throw new Error(`Value must be a list given an array path ${a}`);
if (Array.isArray(n[u])) {
const c = n[u];
if (Array.isArray(t))
for (let f = 0; f < c.length; f++) {
const d = c[f];
s(d, e.slice(l + 1), t[f]);
}
else
for (const f of c)
s(f, e.slice(l + 1), t);
}
return;
} else if (a.endsWith("[0]")) {
const u = a.slice(0, -3);
u in n || (n[u] = [{}]);
const c = n[u];
s(c[0], e.slice(l + 1), t);
return;
}
(!n[a] || typeof n[a] != "object") && (n[a] = {}), n = n[a];
}
const o = e[e.length - 1], r = n[o];
if (r !== void 0) {
if (!t || typeof t == "object" && Object.keys(t).length === 0 || t === r)
return;
if (typeof r == "object" && typeof t == "object" && r !== null && t !== null)
Object.assign(r, t);
else
throw new Error(`Cannot set value for an existing key. Key: ${o}`);
} else
o === "_self" && typeof t == "object" && t !== null && !Array.isArray(t) ? Object.assign(n, t) : n[o] = t;
}
function i(n, e) {
try {
if (e.length === 1 && e[0] === "_self")
return n;
for (let t = 0; t < e.length; t++) {
if (typeof n != "object" || n === null)
return;
const o = e[t];
if (o.endsWith("[]")) {
const r = o.slice(0, -2);
if (r in n) {
const l = n[r];
return Array.isArray(l) ? l.map((a) => i(a, e.slice(t + 1))) : void 0;
} else
return;
} else
n = n[o];
}
return n;
} catch (t) {
if (t instanceof TypeError)
return;
throw t;
}
}
/**
* @license
* Copyright 2025 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
function Ne(n) {
if (typeof n != "string")
throw new Error("fromImageBytes must be a string");
return n;
}
/**
* @license
* Copyright 2025 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
function Qt(n) {
const e = {}, t = i(n, [
"operationName"
]);
t != null && s(e, ["_url", "operationName"], t);
const o = i(n, ["config"]);
return o != null && s(e, ["config"], o), e;
}
function Zt(n) {
const e = {}, t = i(n, [
"operationName"
]);
t != null && s(e, ["operationName"], t);
const o = i(n, ["resourceName"]);
o != null && s(e, ["_url", "resourceName"], o);
const r = i(n, ["config"]);
return r != null && s(e, ["config"], r), e;
}
function Ot(n) {
const e = {}, t = i(n, [
"operationName"
]);
t != null && s(e, ["_url", "operationName"], t);
const o = i(n, ["config"]);
return o != null && s(e, ["config"], o), e;
}
function jt(n) {
const e = {}, t = i(n, ["video", "uri"]);
t != null && s(e, ["uri"], t);
const o = i(n, [
"video",
"encodedVideo"
]);
o != null && s(e, ["videoBytes"], Ne(o));
const r = i(n, ["encoding"]);
return r != null && s(e, ["mimeType"], r), e;
}
function eo(n) {
const e = {}, t = i(n, ["_self"]);
return t != null && s(e, ["video"], jt(t)), e;
}
function no(n) {
const e = {}, t = i(n, [
"generatedSamples"
]);
if (t != null) {
let l = t;
Array.isArray(l) && (l = l.map((a) => eo(a))), s(e, ["generatedVideos"], l);
}
const o = i(n, [
"raiMediaFilteredCount"
]);
o != null && s(e, ["raiMediaFilteredCount"], o);
const r = i(n, [
"raiMediaFilteredReasons"
]);
return r != null && s(e, ["raiMediaFilteredReasons"], r), e;
}
function to(n) {
const e = {}, t = i(n, ["name"]);
t != null && s(e, ["name"], t);
const o = i(n, ["metadata"]);
o != null && s(e, ["metadata"], o);
const r = i(n, ["done"]);
r != null && s(e, ["done"], r);
const l = i(n, ["error"]);
l != null && s(e, ["error"], l);
const a = i(n, [
"response",
"generateVideoResponse"
]);
return a != null && s(e, ["response"], no(a)), e;
}
function oo(n) {
const e = {}, t = i(n, ["gcsUri"]);
t != null && s(e, ["uri"], t);
const o = i(n, [
"bytesBase64Encoded"
]);
o != null && s(e, ["videoBytes"], Ne(o));
const r = i(n, ["mimeType"]);
return r != null && s(e, ["mimeType"], r), e;
}
function io(n) {
const e = {}, t = i(n, ["_self"]);
return t != null && s(e, ["video"], oo(t)), e;
}
function so(n) {
const e = {}, t = i(n, ["videos"]);
if (t != null) {
let l = t;
Array.isArray(l) && (l = l.map((a) => io(a))), s(e, ["generatedVideos"], l);
}
const o = i(n, [
"raiMediaFilteredCount"
]);
o != null && s(e, ["raiMediaFilteredCount"], o);
const r = i(n, [
"raiMediaFilteredReasons"
]);
return r != null && s(e, ["raiMediaFilteredReasons"], r), e;
}
function ro(n) {
const e = {}, t = i(n, ["name"]);
t != null && s(e, ["name"], t);
const o = i(n, ["metadata"]);
o != null && s(e, ["metadata"], o);
const r = i(n, ["done"]);
r != null && s(e, ["done"], r);
const l = i(n, ["error"]);
l != null && s(e, ["error"], l);
const a = i(n, ["response"]);
return a != null && s(e, ["response"], so(a)), e;
}
/**
* @license
* Copyright 2025 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
var Je;
(function(n) {
n.OUTCOME_UNSPECIFIED = "OUTCOME_UNSPECIFIED", n.OUTCOME_OK = "OUTCOME_OK", n.OUTCOME_FAILED = "OUTCOME_FAILED", n.OUTCOME_DEADLINE_EXCEEDED = "OUTCOME_DEADLINE_EXCEEDED";
})(Je || (Je = {}));
var $e;
(function(n) {
n.LANGUAGE_UNSPECIFIED = "LANGUAGE_UNSPECIFIED", n.PYTHON = "PYTHON";
})($e || ($e = {}));
var H;
(function(n) {
n.TYPE_UNSPECIFIED = "TYPE_UNSPECIFIED", n.STRING = "STRING", n.NUMBER = "NUMBER", n.INTEGER = "INTEGER", n.BOOLEAN = "BOOLEAN", n.ARRAY = "ARRAY", n.OBJECT = "OBJECT", n.NULL = "NULL";
})(H || (H = {}));
var We;
(function(n) {
n.HARM_CATEGORY_UNSPECIFIED = "HARM_CATEGORY_UNSPECIFIED", n.HARM_CATEGORY_HATE_SPEECH = "HARM_CATEGORY_HATE_SPEECH", n.HARM_CATEGORY_DANGEROUS_CONTENT = "HARM_CATEGORY_DANGEROUS_CONTENT", n.HARM_CATEGORY_HARASSMENT = "HARM_CATEGORY_HARASSMENT", n.HARM_CATEGORY_SEXUALLY_EXPLICIT = "HARM_CATEGORY_SEXUALLY_EXPLICIT", n.HARM_CATEGORY_CIVIC_INTEGRITY = "HARM_CATEGORY_CIVIC_INTEGRITY", n.HARM_CATEGORY_IMAGE_HATE = "HARM_CATEGORY_IMAGE_HATE", n.HARM_CATEGORY_IMAGE_DANGEROUS_CONTENT = "HARM_CATEGORY_IMAGE_DANGEROUS_CONTENT", n.HARM_CATEGORY_IMAGE_HARASSMENT = "HARM_CATEGORY_IMAGE_HARASSMENT", n.HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT = "HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT";
})(We || (We = {}));
var Ye;
(function(n) {
n.HARM_BLOCK_METHOD_UNSPECIFIED = "HARM_BLOCK_METHOD_UNSPECIFIED", n.SEVERITY = "SEVERITY", n.PROBABILITY = "PROBABILITY";
})(Ye || (Ye = {}));
var Ke;
(function(n) {
n.HARM_BLOCK_THRESHOLD_UNSPECIFIED = "HARM_BLOCK_THRESHOLD_UNSPECIFIED", n.BLOCK_LOW_AND_ABOVE = "BLOCK_LOW_AND_ABOVE", n.BLOCK_MEDIUM_AND_ABOVE = "BLOCK_MEDIUM_AND_ABOVE", n.BLOCK_ONLY_HIGH = "BLOCK_ONLY_HIGH", n.BLOCK_NONE = "BLOCK_NONE", n.OFF = "OFF";
})(Ke || (Ke = {}));
var be;
(function(n) {
n.MODE_UNSPECIFIED = "MODE_UNSPECIFIED", n.MODE_DYNAMIC = "MODE_DYNAMIC";
})(be || (be = {}));
var ze;
(function(n) {
n.AUTH_TYPE_UNSPECIFIED = "AUTH_TYPE_UNSPECIFIED", n.NO_AUTH = "NO_AUTH", n.API_KEY_AUTH = "API_KEY_AUTH", n.HTTP_BASIC_AUTH = "HTTP_BASIC_AUTH", n.GOOGLE_SERVICE_ACCOUNT_AUTH = "GOOGLE_SERVICE_ACCOUNT_AUTH", n.OAUTH = "OAUTH", n.OIDC_AUTH = "OIDC_AUTH";
})(ze || (ze = {}));
var Xe;
(function(n) {
n.API_SPEC_UNSPECIFIED = "API_SPEC_UNSPECIFIED", n.SIMPLE_SEARCH = "SIMPLE_SEARCH", n.ELASTIC_SEARCH = "ELASTIC_SEARCH";
})(Xe || (Xe = {}));
var Qe;
(function(n) {
n.URL_RETRIEVAL_STATUS_UNSPECIFIED = "URL_RETRIEVAL_STATUS_UNSPECIFIED", n.URL_RETRIEVAL_STATUS_SUCCESS = "URL_RETRIEVAL_STATUS_SUCCESS", n.URL_RETRIEVAL_STATUS_ERROR = "URL_RETRIEVAL_STATUS_ERROR", n.URL_RETRIEVAL_STATUS_PAYWALL = "URL_RETRIEVAL_STATUS_PAYWALL", n.URL_RETRIEVAL_STATUS_UNSAFE = "URL_RETRIEVAL_STATUS_UNSAFE";
})(Qe || (Qe = {}));
var Ze;
(function(n) {
n.FINISH_REASON_UNSPECIFIED = "FINISH_REASON_UNSPECIFIED", n.STOP = "STOP", n.MAX_TOKENS = "MAX_TOKENS", n.SAFETY = "SAFETY", n.RECITATION = "RECITATION", n.LANGUAGE = "LANGUAGE", n.OTHER = "OTHER", n.BLOCKLIST = "BLOCKLIST", n.PROHIBITED_CONTENT = "PROHIBITED_CONTENT", n.SPII = "SPII", n.MALFORMED_FUNCTION_CALL = "MALFORMED_FUNCTION_CALL", n.IMAGE_SAFETY = "IMAGE_SAFETY", n.UNEXPECTED_TOOL_CALL = "UNEXPECTED_TOOL_CALL";
})(Ze || (Ze = {}));
var Oe;
(function(n) {
n.HARM_PROBABILITY_UNSPECIFIED = "HARM_PROBABILITY_UNSPECIFIED", n.NEGLIGIBLE = "NEGLIGIBLE", n.LOW = "LOW", n.MEDIUM = "MEDIUM", n.HIGH = "HIGH";
})(Oe || (Oe = {}));
var je;
(function(n) {
n.HARM_SEVERITY_UNSPECIFIED = "HARM_SEVERITY_UNSPECIFIED", n.HARM_SEVERITY_NEGLIGIBLE = "HARM_SEVERITY_NEGLIGIBLE", n.HARM_SEVERITY_LOW = "HARM_SEVERITY_LOW", n.HARM_SEVERITY_MEDIUM = "HARM_SEVERITY_MEDIUM", n.HARM_SEVERITY_HIGH = "HARM_SEVERITY_HIGH";
})(je || (je = {}));
var en;
(function(n) {
n.BLOCKED_REASON_UNSPECIFIED = "BLOCKED_REASON_UNSPECIFIED", n.SAFETY = "SAFETY", n.OTHER = "OTHER", n.BLOCKLIST = "BLOCKLIST", n.PROHIBITED_CONTENT = "PROHIBITED_CONTENT", n.IMAGE_SAFETY = "IMAGE_SAFETY";
})(en || (en = {}));
var nn;
(function(n) {
n.TRAFFIC_TYPE_UNSPECIFIED = "TRAFFIC_TYPE_UNSPECIFIED", n.ON_DEMAND = "ON_DEMAND", n.PROVISIONED_THROUGHPUT = "PROVISIONED_THROUGHPUT";
})(nn || (nn = {}));
var oe;
(function(n) {
n.MODALITY_UNSPECIFIED = "MODALITY_UNSPECIFIED", n.TEXT = "TEXT", n.IMAGE = "IMAGE", n.AUDIO = "AUDIO";
})(oe || (oe = {}));
var tn;
(function(n) {
n.MEDIA_RESOLUTION_UNSPECIFIED = "MEDIA_RESOLUTION_UNSPECIFIED", n.MEDIA_RESOLUTION_LOW = "MEDIA_RESOLUTION_LOW", n.MEDIA_RESOLUTION_MEDIUM = "MEDIA_RESOLUTION_MEDIUM", n.MEDIA_RESOLUTION_HIGH = "MEDIA_RESOLUTION_HIGH";
})(tn || (tn = {}));
var Ce;
(function(n) {
n.JOB_STATE_UNSPECIFIED = "JOB_STATE_UNSPECIFIED", n.JOB_STATE_QUEUED = "JOB_STATE_QUEUED", n.JOB_STATE_PENDING = "JOB_STATE_PENDING", n.JOB_STATE_RUNNING = "JOB_STATE_RUNNING", n.JOB_STATE_SUCCEEDED = "JOB_STATE_SUCCEEDED", n.JOB_STATE_FAILED = "JOB_STATE_FAILED", n.JOB_STATE_CANCELLING = "JOB_STATE_CANCELLING", n.JOB_STATE_CANCELLED = "JOB_STATE_CANCELLED", n.JOB_STATE_PAUSED = "JOB_STATE_PAUSED", n.JOB_STATE_EXPIRED = "JOB_STATE_EXPIRED", n.JOB_STATE_UPDATING = "JOB_STATE_UPDATING", n.JOB_STATE_PARTIALLY_SUCCEEDED = "JOB_STATE_PARTIALLY_SUCCEEDED";
})(Ce || (Ce = {}));
var on;
(function(n) {
n.TUNING_MODE_UNSPECIFIED = "TUNING_MODE_UNSPECIFIED", n.TUNING_MODE_FULL = "TUNING_MODE_FULL", n.TUNING_MODE_PEFT_ADAPTER = "TUNING_MODE_PEFT_ADAPTER";
})(on || (on = {}));
var sn;
(function(n) {
n.ADAPTER_SIZE_UNSPECIFIED = "ADAPTER_SIZE_UNSPECIFIED", n.ADAPTER_SIZE_ONE = "ADAPTER_SIZE_ONE", n.ADAPTER_SIZE_TWO = "ADAPTER_SIZE_TWO", n.ADAPTER_SIZE_FOUR = "ADAPTER_SIZE_FOUR", n.ADAPTER_SIZE_EIGHT = "ADAPTER_SIZE_EIGHT", n.ADAPTER_SIZE_SIXTEEN = "ADAPTER_SIZE_SIXTEEN", n.ADAPTER_SIZE_THIRTY_TWO = "ADAPTER_SIZE_THIRTY_TWO";
})(sn || (sn = {}));
var rn;
(function(n) {
n.FEATURE_SELECTION_PREFERENCE_UNSPECIFIED = "FEATURE_SELECTION_PREFERENCE_UNSPECIFIED", n.PRIORITIZE_QUALITY = "PRIORITIZE_QUALITY", n.BALANCED = "BALANCED", n.PRIORITIZE_COST = "PRIORITIZE_COST";
})(rn || (rn = {}));
var ve;
(function(n) {
n.UNSPECIFIED = "UNSPECIFIED", n.BLOCKING = "BLOCKING", n.NON_BLOCKING = "NON_BLOCKING";
})(ve || (ve = {}));
var ln;
(function(n) {
n.MODE_UNSPECIFIED = "MODE_UNSPECIFIED", n.MODE_DYNAMIC = "MODE_DYNAMIC";
})(ln || (ln = {}));
var an;
(function(n) {
n.ENVIRONMENT_UNSPECIFIED = "ENVIRONMENT_UNSPECIFIED", n.ENVIRONMENT_BROWSER = "ENVIRONMENT_BROWSER";
})(an || (an = {}));
var un;
(function(n) {
n.MODE_UNSPECIFIED = "MODE_UNSPECIFIED", n.AUTO = "AUTO", n.ANY = "ANY", n.NONE = "NONE", n.VALIDATED = "VALIDATED";
})(un || (un = {}));
var fn;
(function(n) {
n.BLOCK_LOW_AND_ABOVE = "BLOCK_LOW_AND_ABOVE", n.BLOCK_MEDIUM_AND_ABOVE = "BLOCK_MEDIUM_AND_ABOVE", n.BLOCK_ONLY_HIGH = "BLOCK_ONLY_HIGH", n.BLOCK_NONE = "BLOCK_NONE";
})(fn || (fn = {}));
var cn;
(function(n) {
n.DONT_ALLOW = "DONT_ALLOW", n.ALLOW_ADULT = "ALLOW_ADULT", n.ALLOW_ALL = "ALLOW_ALL";
})(cn || (cn = {}));
var dn;
(function(n) {
n.auto = "auto", n.en = "en", n.ja = "ja", n.ko = "ko", n.hi = "hi", n.zh = "zh", n.pt = "pt", n.es = "es";
})(dn || (dn = {}));
var pn;
(function(n) {
n.MASK_MODE_DEFAULT = "MASK_MODE_DEFAULT", n.MASK_MODE_USER_PROVIDED = "MASK_MODE_USER_PROVIDED", n.MASK_MODE_BACKGROUND = "MASK_MODE_BACKGROUND", n.MASK_MODE_FOREGROUND = "MASK_MODE_FOREGROUND", n.MASK_MODE_SEMANTIC = "MASK_MODE_SEMANTIC";
})(pn || (pn = {}));
var mn;
(function(n) {
n.CONTROL_TYPE_DEFAULT = "CONTROL_TYPE_DEFAULT", n.CONTROL_TYPE_CANNY = "CONTROL_TYPE_CANNY", n.CONTROL_TYPE_SCRIBBLE = "CONTROL_TYPE_SCRIBBLE", n.CONTROL_TYPE_FACE_MESH = "CONTROL_TYPE_FACE_MESH";
})(mn || (mn = {}));
var gn;
(function(n) {
n.SUBJECT_TYPE_DEFAULT = "SUBJECT_TYPE_DEFAULT", n.SUBJECT_TYPE_PERSON = "SUBJECT_TYPE_PERSON", n.SUBJECT_TYPE_ANIMAL = "SUBJECT_TYPE_ANIMAL", n.SUBJECT_TYPE_PRODUCT = "SUBJECT_TYPE_PRODUCT";
})(gn || (gn = {}));
var hn;
(function(n) {
n.EDIT_MODE_DEFAULT = "EDIT_MODE_DEFAULT", n.EDIT_MODE_INPAINT_REMOVAL = "EDIT_MODE_INPAINT_REMOVAL", n.EDIT_MODE_INPAINT_INSERTION = "EDIT_MODE_INPAINT_INSERTION", n.EDIT_MODE_OUTPAINT = "EDIT_MODE_OUTPAINT", n.EDIT_MODE_CONTROLLED_EDITING = "EDIT_MODE_CONTROLLED_EDITING", n.EDIT_MODE_STYLE = "EDIT_MODE_STYLE", n.EDIT_MODE_BGSWAP = "EDIT_MODE_BGSWAP", n.EDIT_MODE_PRODUCT_IMAGE = "EDIT_MODE_PRODUCT_IMAGE";
})(hn || (hn = {}));
var yn;
(function(n) {
n.FOREGROUND = "FOREGROUND", n.BACKGROUND = "BACKGROUND", n.PROMPT = "PROMPT", n.SEMANTIC = "SEMANTIC", n.INTERACTIVE = "INTERACTIVE";
})(yn || (yn = {}));
var Tn;
(function(n) {
n.ASSET = "ASSET", n.STYLE = "STYLE";
})(Tn || (Tn = {}));
var Cn;
(function(n) {
n.OPTIMIZED = "OPTIMIZED", n.LOSSLESS = "LOSSLESS";
})(Cn || (Cn = {}));
var vn;
(function(n) {
n.STATE_UNSPECIFIED = "STATE_UNSPECIFIED", n.PROCESSING = "PROCESSING", n.ACTIVE = "ACTIVE", n.FAILED = "FAILED";
})(vn || (vn = {}));
var En;
(function(n) {
n.SOURCE_UNSPECIFIED = "SOURCE_UNSPECIFIED", n.UPLOADED = "UPLOADED", n.GENERATED = "GENERATED";
})(En || (En = {}));
var Sn;
(function(n) {
n.MODALITY_UNSPECIFIED = "MODALITY_UNSPECIFIED", n.TEXT = "TEXT", n.IMAGE = "IMAGE", n.VIDEO = "VIDEO", n.AUDIO = "AUDIO", n.DOCUMENT = "DOCUMENT";
})(Sn || (Sn = {}));
var _n;
(function(n) {
n.START_SENSITIVITY_UNSPECIFIED = "START_SENSITIVITY_UNSPECIFIED", n.START_SENSITIVITY_HIGH = "START_SENSITIVITY_HIGH", n.START_SENSITIVITY_LOW = "START_SENSITIVITY_LOW";
})(_n || (_n = {}));
var An;
(function(n) {
n.END_SENSITIVITY_UNSPECIFIED = "END_SENSITIVITY_UNSPECIFIED", n.END_SENSITIVITY_HIGH = "END_SENSITIVITY_HIGH", n.END_SENSITIVITY_LOW = "END_SENSITIVITY_LOW";
})(An || (An = {}));
var In;
(function(n) {
n.ACTIVITY_HANDLING_UNSPECIFIED = "ACTIVITY_HANDLING_UNSPECIFIED", n.START_OF_ACTIVITY_INTERRUPTS = "START_OF_ACTIVITY_INTERRUPTS", n.NO_INTERRUPTION = "NO_INTERRUPTION";
})(In || (In = {}));
var Mn;
(function(n) {
n.TURN_COVERAGE_UNSPECIFIED = "TURN_COVERAGE_UNSPECIFIED", n.TURN_INCLUDES_ONLY_ACTIVITY = "TURN_INCLUDES_ONLY_ACTIVITY", n.TURN_INCLUDES_ALL_INPUT = "TURN_INCLUDES_ALL_INPUT";
})(Mn || (Mn = {}));
var Ee;
(function(n) {
n.SCHEDULING_UNSPECIFIED = "SCHEDULING_UNSPECIFIED", n.SILENT = "SILENT", n.WHEN_IDLE = "WHEN_IDLE", n.INTERRUPT = "INTERRUPT";
})(Ee || (Ee = {}));
var Rn;
(function(n) {
n.SCALE_UNSPECIFIED = "SCALE_UNSPECIFIED", n.C_MAJOR_A_MINOR = "C_MAJOR_A_MINOR", n.D_FLAT_MAJOR_B_FLAT_MINOR = "D_FLAT_MAJOR_B_FLAT_MINOR", n.D_MAJOR_B_MINOR = "D_MAJOR_B_MINOR", n.E_FLAT_MAJOR_C_MINOR = "E_FLAT_MAJOR_C_MINOR", n.E_MAJOR_D_FLAT_MINOR = "E_MAJOR_D_FLAT_MINOR", n.F_MAJOR_D_MINOR = "F_MAJOR_D_MINOR", n.G_FLAT_MAJOR_E_FLAT_MINOR = "G_FLAT_MAJOR_E_FLAT_MINOR", n.G_MAJOR_E_MINOR = "G_MAJOR_E_MINOR", n.A_FLAT_MAJOR_F_MINOR = "A_FLAT_MAJOR_F_MINOR", n.A_MAJOR_G_FLAT_MINOR = "A_MAJOR_G_FLAT_MINOR", n.B_FLAT_MAJOR_G_MINOR = "B_FLAT_MAJOR_G_MINOR", n.B_MAJOR_A_FLAT_MINOR = "B_MAJOR_A_FLAT_MINOR";
})(Rn || (Rn = {}));
var xn;
(function(n) {
n.MUSIC_GENERATION_MODE_UNSPECIFIED = "MUSIC_GENERATION_MODE_UNSPECIFIED", n.QUALITY = "QUALITY", n.DIVERSITY = "DIVERSITY", n.VOCALIZATION = "VOCALIZATION";
})(xn || (xn = {}));
var b;
(function(n) {
n.PLAYBACK_CONTROL_UNSPECIFIED = "PLAYBACK_CONTROL_UNSPECIFIED", n.PLAY = "PLAY", n.PAUSE = "PAUSE", n.STOP = "STOP", n.RESET_CONTEXT = "RESET_CONTEXT";
})(b || (b = {}));
class Se {
constructor(e) {
const t = {};
for (const o of e.headers.entries())
t[o[0]] = o[1];
this.headers = t, this.responseInternal = e;
}
json() {
return this.responseInternal.json();
}
}
class ne {
/**
* Returns the concatenation of all text parts from the first candidate in the response.
*
* @remarks
* If there are multiple candidates in the response, the text from the first
* one will be returned.
* If there are non-text parts in the response, the concatenation of all text
* parts will be returned, and a warning will be logged.
* If there are thought parts in the response, the concatenation of all text
* parts excluding the thought parts will be returned.
*
* @example
* ```ts
* const response = await ai.models.generateContent({
* model: 'gemini-2.0-flash',
* contents:
* 'Why is the sky blue?',
* });
*
* console.debug(response.text);
* ```
*/
get text() {
var e, t, o, r, l, a, u, c;
if (((r = (o = (t = (e = this.candidates) === null || e === void 0 ? void 0 : e[0]) === null || t === void 0 ? void 0 : t.content) === null || o === void 0 ? void 0 : o.parts) === null || r === void 0 ? void 0 : r.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 f = "", d = !1;
const p = [];
for (const m of (c = (u = (a = (l = this.candidates) === null || l === void 0 ? void 0 : l[0]) === null || a === void 0 ? void 0 : a.content) === null || u === void 0 ? void 0 : u.parts) !== null && c !== void 0 ? c : []) {
for (const [g, h] of Object.entries(m))
g !== "text" && g !== "thought" && (h !== null || h !== void 0) && p.push(g);
if (typeof m.text == "string") {
if (typeof m.thought == "boolean" && m.thought)
continue;
d = !0, f += m.text;
}
}
return p.length > 0 && console.warn(`there are non-text parts ${p} in the response, returning concatenation of all text parts. Please refer to the non text parts for a full response from model.`), d ? f : void 0;
}
/**
* Returns the concatenation of all inline data parts from the first candidate
* in the response.
*
* @remarks
* If there are multiple candidates in the response, the inline data from the
* first one will be returned. If there are non-inline data parts in the
* response, the concatenation of all inline data parts will be returned, and
* a warning will be logged.
*/
get data() {
var e, t, o, r, l, a, u, c;
if (((r = (o = (t = (e = this.candidates) === null || e === void 0 ? void 0 : e[0]) === null || t === void 0 ? void 0 : t.content) === null || o === void 0 ? void 0 : o.parts) === null || r === void 0 ? void 0 : r.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 f = "";
const d = [];
for (const p of (c = (u = (a = (l = this.candidates) === null || l === void 0 ? void 0 : l[0]) === null || a === void 0 ? void 0 : a.content) === null || u === void 0 ? void 0 : u.parts) !== null && c !== void 0 ? c : []) {
for (const [m, g] of Object.entries(p))
m !== "inlineData" && (g !== null || g !== void 0) && d.push(m);
p.inlineData && typeof p.inlineData.data == "string" && (f += atob(p.inlineData.data));
}
return d.length > 0 && console.warn(`there are non-data parts ${d} in the response, returning concatenation of all data parts. Please refer to the non data parts for a full response from model.`), f.length > 0 ? btoa(f) : void 0;
}
/**
* Returns the function calls from the first candidate in the response.
*
* @remarks
* If there are multiple candidates in the response, the function calls from
* the first one will be returned.
* If there are no function calls in the response, undefined will be returned.
*
* @example
* ```ts
* const controlLightFunctionDeclaration: FunctionDeclaration = {
* name: 'controlLight',
* parameters: {
* type: Type.OBJECT,
* description: 'Set the brightness and color temperature of a room light.',
* properties: {
* brightness: {
* type: Type.NUMBER,
* description:
* 'Light level from 0 to 100. Zero is off and 100 is full brightness.',
* },
* colorTemperature: {
* type: Type.STRING,
* description:
* 'Color temperature of the light fixture which can be `daylight`, `cool` or `warm`.',
* },
* },
* required: ['brightness', 'colorTemperature'],
* };
* const response = await ai.models.generateContent({
* model: 'gemini-2.0-flash',
* contents: 'Dim the lights so the room feels cozy and warm.',
* config: {
* tools: [{functionDeclarations: [controlLightFunctionDeclaration]}],
* toolConfig: {
* functionCallingConfig: {
* mode: FunctionCallingConfigMode.ANY,
* allowedFunctionNames: ['controlLight'],
* },
* },
* },
* });
* console.debug(JSON.stringify(response.functionCalls));
* ```
*/
get functionCalls() {
var e, t, o, r, l, a, u, c;
if (((r = (o = (t = (e = this.candidates) === null || e === void 0 ? void 0 : e[0]) === null || t === void 0 ? void 0 : t.content) === null || o === void 0 ? void 0 : o.parts) === null || r === void 0 ? void 0 : r.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.");
const f = (c = (u = (a = (l = this.candidates) === null || l === void 0 ? void 0 : l[0]) === null || a === void 0 ? void 0 : a.content) === null || u === void 0 ? void 0 : u.parts) === null || c === void 0 ? void 0 : c.filter((d) => d.functionCall).map((d) => d.functionCall).filter((d) => d !== void 0);
if ((f == null ? void 0 : f.length) !== 0)
return f;
}
/**
* Returns the first executable code from the first candidate in the response.
*
* @remarks
* If there are multiple candidates in the response, the executable code from
* the first one will be returned.
* If there are no executable code in the response, undefined will be
* returned.
*
* @example
* ```ts
* const response = await ai.models.generateContent({
* model: 'gemini-2.0-flash',
* contents:
* 'What is the sum of the first 50 prime numbers? Generate and run code for the calculation, and make sure you get all 50.'
* config: {
* tools: [{codeExecution: {}}],
* },
* });
*
* console.debug(response.executableCode);
* ```
*/
get executableCode() {
var e, t, o, r, l, a, u, c, f;
if (((r = (o = (t = (e = this.candidates) === null || e === void 0 ? void 0 : e[0]) === null || t === void 0 ? void 0 : t.content) === null || o === void 0 ? void 0 : o.parts) === null || r === void 0 ? void 0 : r.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.");
const d = (c = (u = (a = (l = this.candidates) === null || l === void 0 ? void 0 : l[0]) === null || a === void 0 ? void 0 : a.content) === null || u === void 0 ? void 0 : u.parts) === null || c === void 0 ? void 0 : c.filter((p) => p.executableCode).map((p) => p.executableCode).filter((p) => p !== void 0);
if ((d == null ? void 0 : d.length) !== 0)
return (f = d == null ? void 0 : d[0]) === null || f === void 0 ? void 0 : f.code;
}
/**
* Returns the first code execution result from the first candidate in the response.
*
* @remarks
* If there are multiple candidates in the response, the code execution result from
* the first one will be returned.
* If there are no code execution result in the response, undefined will be returned.
*
* @example
* ```ts
* const response = await ai.models.generateContent({
* model: 'gemini-2.0-flash',
* contents:
* 'What is the sum of the first 50 prime numbers? Generate and run code for the calculation, and make sure you get all 50.'
* config: {
* tools: [{codeExecution: {}}],
* },
* });
*
* console.debug(response.codeExecutionResult);
* ```
*/
get codeExecutionResult() {
var e, t, o, r, l, a, u, c, f;
if (((r = (o = (t = (e = this.candidates) === null || e === void 0 ? void 0 : e[0]) === null || t === void 0 ? void 0 : t.content) === null || o === void 0 ? void 0 : o.parts) === null || r === void 0 ? void 0 : r.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.");
const d = (c = (u = (a = (l = this.candidates) === null || l === void 0 ? void 0 : l[0]) === null || a === void 0 ? void 0 : a.content) === null || u === void 0 ? void 0 : u.parts) === null || c === void 0 ? void 0 : c.filter((p) => p.codeExecutionResult).map((p) => p.codeExecutionResult).filter((p) => p !== void 0);
if ((d == null ? void 0 : d.length) !== 0)
return (f = d == null ? void 0 : d[0]) === null || f === void 0 ? void 0 : f.output;
}
}
class Pn {
}
class wn {
}
class lo {
}
class ao {
}
class uo {
}
class fo {
}
class Nn {
}
class Dn {
}
class kn {
}
class co {
}
class ue {
/**
* Instantiates an Operation of the same type as the one being called with the fields set from the API response.
* @internal
*/
_fromAPIResponse({ apiResponse: e, isVertexAI: t }) {
const o = new ue();
let r;
const l = e;
return t ? r = ro(l) : r = to(l), Object.assign(o, r), o;
}
}
class Un {
}
class Vn {
}
class Fn {
}
class po {
}
class mo {
}
class go {
}
class Ln {
}
class ho {
/**
* Returns the concatenation of all text parts from the server content if present.
*
* @remarks
* If there are non-text parts in the response, the concatenation of all text
* parts will be returned, and a warning will be logged.
*/
get text() {
var e, t, o;
let r = "", l = !1;
const a = [];
for (const u of (o = (t = (e = this.serverContent) === null || e === void 0 ? void 0 : e.modelTurn) === null || t === void 0 ? void 0 : t.parts) !== null && o !== void 0 ? o : []) {
for (const [c, f] of Object.entries(u))
c !== "text" && c !== "thought" && f !== null && a.push(c);
if (typeof u.text == "string") {
if (typeof u.thought == "boolean" && u.thought)
continue;
l = !0, r += u.text;
}
}
return a.length > 0 && console.warn(`there are non-text parts ${a} in the response, returning concatenation of all text parts. Please refer to the non text parts for a full response from model.`), l ? r : void 0;
}
/**
* Returns the concatenation of all inline data parts from the server content if present.
*
* @remarks
* If there are non-inline data parts in the
* response, the concatenation of all inline data parts will be returned, and
* a warning will be logged.
*/
get data() {
var e, t, o;
let r = "";
const l = [];
for (const a of (o = (t = (e = this.serverContent) === null || e === void 0 ? void 0 : e.modelTurn) === null || t === void 0 ? void 0 : t.parts) !== null && o !== void 0 ? o : []) {
for (const [u, c] of Object.entries(a))
u !== "inlineData" && c !== null && l.push(u);
a.inlineData && typeof a.inlineData.data == "string" && (r += atob(a.inlineData.data));
}
return l.length > 0 && console.warn(`there are non-data parts ${l} in the response, returning concatenation of all data parts. Please refer to the non data parts for a full response from model.`), r.length > 0 ? btoa(r) : void 0;
}
}
class yo {
/**
* Returns the first audio chunk from the server content, if present.
*
* @remarks
* If there are no audio chunks in the response, undefined will be returned.
*/
get audioChunk() {
if (this.serverContent && this.serverContent.audioChunks && this.serverContent.audioChunks.length > 0)
return this.serverContent.audioChunks[0];
}
}
/**
* @license
* Copyright 2025 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
function M(n, e) {
if (!e || typeof e != "string")
throw new Error("model is required and must be a string");
if (n.isVertexAI()) {
if (e.startsWith("publishers/") || e.startsWith("projects/") || e.startsWith("models/"))
return e;
if (e.indexOf("/") >= 0) {
const t = e.split("/", 2);
return `publishers/${t[0]}/models/${t[1]}`;
} else
return `publishers/google/models/${e}`;
} else
return e.startsWith("models/") || e.startsWith("tunedModels/") ? e : `models/${e}`;
}
function lt(n, e) {
const t = M(n, e);
return t ? t.startsWith("publishers/") && n.isVertexAI() ? `projects/${n.getProject()}/locations/${n.getLocation()}/${t}` : t.startsWith("models/") && n.isVertexAI() ? `projects/${n.getProject()}/locations/${n.getLocation()}/publishers/google/${t}` : t : "";
}
function at(n) {
return Array.isArray(n) ? n.map((e) => fe(e)) : [fe(n)];
}
function fe(n) {
if (typeof n == "object" && n !== null)
return n;
throw new Error(`Could not parse input as Blob. Unsupported blob type: ${typeof n}`);
}
function ut(n) {
const e = fe(n);
if (e.mimeType && e.mimeType.startsWith("image/"))
return e;
throw new Error(`Unsupported mime type: ${e.mimeType}`);
}
function ft(n) {
const e = fe(n);
if (e.mimeType && e.mimeType.startsWith("audio/"))
return e;
throw new Error(`Unsupported mime type: ${e.mimeType}`);
}
function qn(n) {
if (n == null)
throw new Error("PartUnion is required");
if (typeof n == "object")
return n;
if (typeof n == "string")
return { text: n };
throw new Error(`Unsupported part type: ${typeof n}`);
}
function ct(n) {
if (n == null || Array.isArray(n) && n.length === 0)
throw new Error("PartListUnion is required");
return Array.isArray(n) ? n.map((e) => qn(e)) : [qn(n)];
}
function _e(n) {
return n != null && typeof n == "object" && "parts" in n && Array.isArray(n.parts);
}
function Gn(n) {
return n != null && typeof n == "object" && "functionCall" in n;
}
function Bn(n) {
return n != null && typeof n == "object" && "functionResponse" in n;
}
function k(n) {
if (n == null)
throw new Error("ContentUnion is required");
return _e(n) ? n : {
role: "user",
parts: ct(n)
};
}
function De(n, e) {
if (!e)
return [];
if (n.isVertexAI() && Array.isArray(e))
return e.flatMap((t) => {
const o = k(t);
return o.parts && o.parts.length > 0 && o.parts[0].text !== void 0 ? [o.parts[0].text] : [];
});
if (n.isVertexAI()) {
const t = k(e);
return t.parts && t.parts.length > 0 && t.parts[0].text !== void 0 ? [t.parts[0].text] : [];
}
return Array.isArray(e) ? e.map((t) => k(t)) : [k(e)];
}
function U(n) {
if (n == null || Array.isArray(n) && n.length === 0)
throw new Error("contents are required");
if (!Array.isArray(n)) {
if (Gn(n) || Bn(n))
throw new Error("To specify functionCall or functionResponse parts, please wrap them in a Content object, specifying the role for them");
return [k(n)];
}
const e = [], t = [], o = _e(n[0]);
for (const r of n) {
const l = _e(r);
if (l != o)
throw new 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 (l)
e.push(r);
else {
if (Gn(r) || Bn(r))
throw new Error("To specify functionCall or functionResponse parts, please wrap them, and any other parts, in Content objects as appropriate, specifying the role for them");
t.push(r);
}
}
return o || e.push({ role: "user", parts: ct(t) }), e;
}
function To(n, e) {
n.includes("null") && (e.nullable = !0);
const t = n.filter((o) => o !== "null");
if (t.length === 1)
e.type = Object.values(H).includes(t[0].toUpperCase()) ? t[0].toUpperCase() : H.TYPE_UNSPECIFIED;
else {
e.anyOf = [];
for (const o of t)
e.anyOf.push({
type: Object.values(H).includes(o.toUpperCase()) ? o.toUpperCase() : H.TYPE_UNSPECIFIED
});
}
}
function z(n) {
const e = {}, t = ["items"], o = ["anyOf"], r = ["properties"];
if (n.type && n.anyOf)
throw new Error("type and anyOf cannot be both populated.");
const l = n.anyOf;
l != null && l.length == 2 && (l[0].type === "null" ? (e.nullable = !0, n = l[1]) : l[1].type === "null" && (e.nullable = !0, n = l[0])), n.type instanceof Array && To(n.type, e);
for (const [a, u] of Object.entries(n))
if (u != null)
if (a == "type") {
if (u === "null")
throw new Error("type: null can not be the only possible type for the field.");
if (u instanceof Array)
continue;
e.type = Object.values(H).includes(u.toUpperCase()) ? u.toUpperCase() : H.TYPE_UNSPECIFIED;
} else if (t.includes(a))
e[a] = z(u);
else if (o.includes(a)) {
const c = [];
for (const f of u) {
if (f.type == "null") {
e.nullable = !0;
continue;
}
c.push(z(f));
}
e[a] = c;
} else if (r.includes(a)) {
const c = {};
for (const [f, d] of Object.entries(u))
c[f] = z(d);
e[a] = c;
} else {
if (a === "additionalProperties")
continue;
e[a] = u;
}
return e;
}
function ke(n) {
return z(n);
}
function Ue(n) {
if (typeof n == "object")
return n;
if (typeof n == "string")
return {
voiceConfig: {
prebuiltVoiceConfig: {
voiceName: n
}
}
};
throw new Error(`Unsupported speechConfig type: ${typeof n}`);
}
function Ve(n) {
if ("multiSpeakerVoiceConfig" in n)
throw new Error("multiSpeakerVoiceConfig is not supported in the live API.");
return n;
}
function Z(n) {
if (n.functionDeclarations)
for (const e of n.functionDeclarations)
e.parameters && (Object.keys(e.parameters).includes("$schema") ? e.parametersJsonSchema || (e.parametersJsonSchema = e.parameters, delete e.parameters) : e.parameters = z(e.parameters)), e.response && (Object.keys(e.response).includes("$schema") ? e.responseJsonSchema || (e.responseJsonSchema = e.response, delete e.response) : e.response = z(e.response));
return n;
}
function O(n) {
if (n == null)
throw new Error("tools is required");
if (!Array.isArray(n))
throw new Error("tools is required and must be an array of Tools");
const e = [];
for (const t of n)
e.push(t);
return e;
}
function Co(n, e, t, o = 1) {
const r = !e.startsWith(`${t}/`) && e.split("/").length === o;
return n.isVertexAI() ? e.startsWith("projects/") ? e : e.startsWith("locations/") ? `projects/${n.getProject()}/${e}` : e.startsWith(`${t}/`) ? `projects/${n.getProject()}/locations/${n.getLocation()}/${e}` : r ? `projects/${n.getProject()}/locations/${n.getLocation()}/${t}/${e}` : e : r ? `${t}/${e}` : e;
}
function B(n, e) {
if (typeof e != "string")
throw new Error("name must be a string");
return Co(n, e, "cachedContents");
}
function dt(n) {
switch (n) {
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 n;
}
}
function Y(n) {
return Ne(n);
}
function vo(n) {
return n != null && typeof n == "object" && "name" in n;
}
function Eo(n) {
return n != null && typeof n == "object" && "video" in n;
}
function So(n) {
return n != null && typeof n == "object" && "uri" in n;
}
function pt(n) {
var e;
let t;
if (vo(n) && (t = n.name), !(So(n) && (t = n.uri, t === void 0)) && !(Eo(n) && (t = (e = n.video) === null || e === void 0 ? void 0 : e.uri, t === void 0))) {
if (typeof n == "string" && (t = n), t === void 0)
throw new Error("Could not extract file name from the provided input.");
if (t.startsWith("https://")) {
const r = t.split("files/")[1].match(/[a-z0-9]+/);
if (r === null)
throw new Error(`Could not extract file name from URI ${t}`);
t = r[0];
} else
t.startsWith("files/") && (t = t.split("files/")[1]);
return t;
}
}
function mt(n, e) {
let t;
return n.isVertexAI() ? t = e ? "publishers/google/models" : "models" : t = e ? "models" : "tunedModels", t;
}
function gt(n) {
for (const e of ["models", "tunedModels", "publisherModels"])
if (_o(n, e))
return n[e];
return [];
}
function _o(n, e) {
return n !== null && typeof n == "object" && e in n;
}
function Ao(n, e = {}) {
const t = n, o = {
name: t.name,
description: t.description,
parametersJsonSchema: t.inputSchema
};
return t.outputSchema && (o.responseJsonSchema = t.outputSchema), e.behavior && (o.behavior = e.behavior), {
functionDeclarations: [
o
]
};
}
function Io(n, e = {}) {
const t = [], o = /* @__PURE__ */ new Set();
for (const r of n) {
const l = r.name;
if (o.has(l))
throw new Error(`Duplicate function name ${l} found in MCP tools. Please ensure function names are unique.`);
o.add(l);
const a = Ao(r, e);
a.functionDeclarations && t.push(...a.functionDeclarations);
}
return { functionDeclarations: t };
}
function ht(n, e) {
let t;
if (typeof e == "string")
if (n.isVertexAI())
if (e.startsWith("gs://"))
t = { format: "jsonl", gcsUri: [e] };
else if (e.startsWith("bq://"))
t = { format: "bigquery", bigqueryUri: e };
else
throw new Error(`Unsupported string source for Vertex AI: ${e}`);
else if (e.startsWith("files/"))
t = { fileName: e };
else
throw new Error(`Unsupported string source for Gemini API: ${e}`);
else if (Array.isArray(e)) {
if (n.isVertexAI())
throw new Error("InlinedRequest[] is not supported in Vertex AI.");
t = { inlinedRequests: e };
} else
t = e;
const o = [t.gcsUri, t.bigqueryUri].filter(Boolean).length, r = [
t.inlinedRequests,
t.fileName
].filter(Boolean).length;
if (n.isVertexAI()) {
if (r > 0 || o !== 1)
throw new Error("Exactly one of `gcsUri` or `bigqueryUri` must be set for Vertex AI.");
} else if (o > 0 || r !== 1)
throw new Error("Exactly one of `inlinedRequests`, `fileName`, must be set for Gemini API.");
return t;
}
function Mo(n) {
if (typeof n != "string")
return n;
const e = n;
if (e.startsWith("gs://"))
return {
format: "jsonl",
gcsUri: e
};
if (e.startsWith("bq://"))
return {
format: "bigquery",
bigqueryUri: e
};
throw new Error(`Unsupported destination: ${e}`);
}
function yt(n) {
if (typeof n != "object" || n === null)
return {};
const e = n, t = e.inlinedResponses;
if (typeof t != "object" || t === null)
return n;
const r = t.inlinedResponses;
if (!Array.isArray(r) || r.length === 0)
return n;
let l = !1;
for (const a of r) {
if (typeof a != "object" || a === null)
continue;
const c = a.response;
if (typeof c != "object" || c === null)
continue;
if (c.embedding !== void 0) {
l = !0;
break;
}
}
return l && (e.inlinedEmbedContentResponses = e.inlinedResponses, delete e.inlinedResponses), n;
}
function j(n, e) {
const t = e;
if (!n.isVertexAI()) {
if (/batches\/[^/]+$/.test(t))
return t.split("/").pop();
throw new Error(`Invalid batch job name: ${t}.`);
}
if (/^projects\/[^/]+\/locations\/[^/]+\/batchPredictionJobs\/[^/]+$/.test(t))
return t.split("/").pop();
if (/^\d+$/.test(t))
return t;
throw new Error(`Invalid batch job name: ${t}.`);
}
function Tt(n) {
const e = n;
return e === "BATCH_STATE_UNSPECIFIED" ? "JOB_STATE_UNSPECIFIED" : e === "BATCH_STATE_PENDING" ? "JOB_STATE_PENDING" : e === "BATCH_STATE_SUCCEEDED" ? "JOB_STATE_SUCCEEDED" : e === "BATCH_STATE_FAILED" ? "JOB_STATE_FAILED" : e === "BATCH_STATE_CANCELLED" ? "JOB_STATE_CANCELLED" : e;
}
/**
* @license
* Copyright 2025 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
function Ro(n) {
const e = {}, t = i(n, ["fps"]);
t != null && s(e, ["fps"], t);
const o = i(n, ["endOffset"]);
o != null && s(e, ["endOffset"], o);
const r = i(n, ["startOffset"]);
return r != null && s(e, ["startOffset"], r), e;
}
function xo(n) {
const e = {};
if (i(n, ["displayName"]) !== void 0)
throw new Error("displayName parameter is not supported in Gemini API.");
const t = i(n, ["data"]);
t != null && s(e, ["data"], t);
const o = i(n, ["mimeType"]);
return o != null && s(e, ["mimeType"], o), e;
}
function Po(n) {
const e = {};
if (i(n, ["displayName"]) !== void 0)
throw new Error("displayName parameter is not supported in Gemini API.");
const t = i(n, ["fileUri"]);
t != null && s(e, ["fileUri"], t);
const o = i(n, ["mimeType"]);
return o != null && s(e, ["mimeType"], o), e;
}
function wo(n) {
const e = {}, t = i(n, ["id"]);
t != null && s(e, ["id"], t);
const o = i(n, ["args"]);
o != null && s(e, ["args"], o);
const r = i(n, ["name"]);
return r != null && s(e, ["name"], r), e;
}
function No(n) {
const e = {}, t = i(n, [
"videoMetadata"
]);
t != null && s(e, ["videoMetadata"], Ro(t));
const o = i(n, ["thought"]);
o != null && s(e, ["thought"], o);
const r = i(n, ["inlineData"]);
r != null && s(e, ["inlineData"], xo(r));
const l = i(n, ["fileData"]);
l != null && s(e, ["fileData"], Po(l));
const a = i(n, [
"thoughtSignature"
]);
a != null && s(e, ["thoughtSignature"], a);
const u = i(n, ["functionCall"]);
u != null && s(e, ["functionCall"], wo(u));
const c = i(n, [
"codeExecutionResult"
]);
c != null && s(e, ["codeExecutionResult"], c);
const f = i(n, [
"executableCode"
]);
f != null && s(e, ["executableCode"], f);
const d = i(n, [
"functionResponse"
]);
d != null && s(e, ["functionResponse"], d);
const p = i(n, ["text"]);
return p != null && s(e, ["text"], p), e;
}
function Ct(n) {
const e = {}, t = i(n, ["parts"]);
if (t != null) {
let r = t;
Array.isArray(r) && (r = r.map((l) => No(l))), s(e, ["parts"], r);
}
const o = i(n, ["role"]);
return o != null && s(e, ["role"], o), e;
}
function Do(n) {
const e = {}, t = i(n, ["anyOf"]);
t != null && s(e, ["anyOf"], t);
const o = i(n, ["default"]);
o != null && s(e, ["default"], o);
const r = i(n, ["description"]);
r != null && s(e, ["description"], r);
const l = i(n, ["enum"]);
l != null && s(e, ["enum"], l);
const a = i(n, ["example"]);
a != null && s(e, ["example"], a);
const u = i(n, ["format"]);
u != null && s(e, ["format"], u);
const c = i(n, ["items"]);
c != null && s(e, ["items"], c);
const f = i(n, ["maxItems"]);
f != null && s(e, ["maxItems"], f);
const d = i(n, ["maxLength"]);
d != null && s(e, ["maxLength"], d);
const p = i(n, [
"maxProperties"
]);
p != null && s(e, ["maxProperties"], p);
const m = i(n, ["maximum"]);
m != null && s(e, ["maximum"], m);
const g = i(n, ["minItems"]);
g != null && s(e, ["minItems"], g);
const h = i(n, ["minLength"]);
h != null && s(e, ["minLength"], h);
const y = i(n, [
"minProperties"
]);
y != null && s(e, ["minProperties"], y);
const T = i(n, ["minimum"]);
T != null && s(e, ["minimum"], T);
const C = i(n, ["nullable"]);
C != null && s(e, ["nullable"], C);
const E = i(n, ["pattern"]);
E != null && s(e, ["pattern"], E);
const S = i(n, ["properties"]);
S != null && s(e, ["properties"], S);
const A = i(n, [
"propertyOrdering"
]);
A != null && s(e, ["propertyOrdering"], A);
const _ = i(n, ["required"]);
_ != null && s(e, ["required"], _);
const R = i(n, ["title"]);
R != null && s(e, ["title"], R);
const x = i(n, ["type"]);
return x != null && s(e, ["type"], x), e;
}
function ko(n) {
const e = {};
if (i(n, ["method"]) !== void 0)
throw new Error("method parameter is not supported in Gemini API.");
const t = i(n, ["category"]);
t != null && s(e, ["category"], t);
const o = i(n, ["threshold"]);
return o != null && s(e, ["threshold"], o), e;
}
function Uo(n) {
const e = {}, t = i(n, ["behavior"]);
t != null && s(e, ["behavior"], t);
const o = i(n, ["description"]);
o != null && s(e, ["description"], o);
const r = i(n, ["name"]);
r != null && s(e, ["name"], r);
const l = i(n, ["parameters"]);
l != null && s(e, ["parameters"], l);
const a = i(n, [
"parametersJsonSchema"
]);
a != null && s(e, ["parametersJsonSchema"], a);
const u = i(n, ["response"]);
u != null && s(e, ["response"], u);
const c = i(n, [
"responseJsonSchema"
]);
return c != null && s(e, ["responseJsonSchema"], c), e;
}
function Vo(n) {
const e = {}, t = i(n, ["startTime"]);
t != null && s(e, ["startTime"], t);
const o = i(n, ["endTime"]);
return o != null && s(e, ["endTime"], o), e;
}
function Fo(n) {
const e = {}, t = i(n, [
"timeRangeFilter"
]);
if (t != null && s(e, ["timeRangeFilter"], Vo(t)), i(n, ["excludeDomains"]) !== void 0)
throw new Error("excludeDomains parameter is not supported in Gemini API.");
return e;
}
function Lo(n) {
const e = {}, t = i(n, ["mode"]);
t != null && s(e, ["mode"], t);
const o = i(n, [
"dynamicThreshold"
]);
return o != null && s(e, ["dynamicThreshold"], o), e;
}
function qo(n) {
const e = {}, t = i(n, [
"dynamicRetrievalConfig"
]);
return t != null && s(e, ["dynamicRetrievalConfig"], Lo(t)), e;
}
function Go() {
return {};
}
function Bo(n) {
const e = {}, t = i(n, ["environment"]);
return t != null && s(e, ["environment"], t), e;
}
function Ho(n) {
const e = {}, t = i(n, [
"functionDeclarations"
]);
if (t != null) {
let c = t;
Array.isArray(c) && (c = c.map((f) => Uo(f))), s(e, ["functionDeclarations"], c);
}
if (i(n, ["retrieval"]) !== void 0)
throw new Error("retrieval parameter is not supported in Gemini API.");
const o = i(n, ["googleSearch"]);
o != null && s(e, ["googleSearch"], Fo(o));
const r = i(n, [
"googleSearchRetrieval"
]);
if (r != null && s(e, ["googleSearchRetrieval"], qo(r)), i(n, ["enterpriseWebSearch"]) !== void 0)
throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.");
if (i(n, ["googleMaps"]) !== void 0)
throw new Error("googleMaps parameter is not supported in Gemini API.");
i(n, ["urlContext"]) != null && s(e, ["urlContext"], Go());
const a = i(n, ["computerUse"]);
a != null && s(e, ["computerUse"], Bo(a));
const u = i(n, [
"codeExecution"
]);
return u != null && s(e, ["codeExecution"], u), e;
}
function Jo(n) {
const e = {}, t = i(n, ["mode"]);
t != null && s(e, ["mode"], t);
const o = i(n, [
"allowedFunctionNames"
]);
return o != null && s(e, ["allowedFunctionNames"], o), e;
}
function $o(n) {
const e = {}, t = i(n, ["latitude"]);
t != null && s(e, ["latitude"], t);
const o = i(n, ["longitude"]);
return o != null && s(e, ["longitude"], o), e;
}
function Wo(n) {
const e = {}, t = i(n, ["latLng"]);
t != null && s(e, ["latLng"], $o(t));
const o = i(n, ["languageCode"]);
return o != null && s(e, ["languageCode"], o), e;
}
function Yo(n) {
const e = {}, t = i(n, [
"functionCallingConfig"
]);
t != null && s(e, ["functionCallingConfig"], Jo(t));
const o = i(n, [
"retrievalConfig"
]);
return o != null && s(e, ["retrievalConfig"], Wo(o)), e;
}
function Ko(n) {
const e = {}, t = i(n, ["voiceName"]);
return t != null && s(e, ["voiceName"], t), e;
}
function vt(n) {
const e = {}, t = i(n, [
"prebuiltVoiceConfig"
]);
return t != null && s(e, ["prebuiltVoiceConfig"], Ko(t)), e;
}
function bo(n) {
const e = {}, t = i(n, ["speaker"]);
t != null && s(e, ["speaker"], t);
const o = i(n, ["voiceConfig"]);
return o != null && s(e, ["voiceConfig"], vt(o)), e;
}
function zo(n) {
const e = {}, t = i(n, [
"speakerVoiceConfigs"
]);
if (t != null) {
let o = t;