PageSourceSearch

https://nmmbapop-sci.com.tw/assets/vendor-firebase-ai-Cli1dDjD.js

js nmmbapop-sci.com.tw collected 2026-10-07 07:01:02 UTC 173,139 bytes, 4,750 lines download raw bytes

1import { n as __exportAll } from "./rolldown-runtime-BnXFPu6O.js";
2//#region node_modules/@firebase/util/dist/postinstall.mjs
3/**
4* @license
5* Copyright 2025 Google LLC
6*
7* Licensed under the Apache License, Version 2.0 (the "License");
8* you may not use this file except in compliance with the License.
9* You may obtain a copy of the License at
10*
11*   http://www.apache.org/licenses/LICENSE-2.0
12*
13* Unless required by applicable law or agreed to in writing, software
14* distributed under the License is distributed on an "AS IS" BASIS,
15* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16* See the License for the specific language governing permissions and
17* limitations under the License.
18*/
19var getDefaultsFromPostinstall = () => void 0;
20/**
21* @license
22* Copyright 2017 Google LLC
23*
24* Licensed under the Apache License, Version 2.0 (the "License");
25* you may not use this file except in compliance with the License.
26* You may obtain a copy of the License at
27*
28*   http://www.apache.org/licenses/LICENSE-2.0
29*
30* Unless required by applicable law or agreed to in writing, software
31* distributed under the License is distributed on an "AS IS" BASIS,
32* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
33* See the License for the specific language governing permissions and
34* limitations under the License.
35*/
36var stringToByteArray$1 = function(str) {
37	const out = [];
38	let p = 0;
39	for (let i = 0; i < str.length; i++) {
40		let c = str.charCodeAt(i);
41		if (c < 128) out[p++] = c;
42		else if (c < 2048) {
43			out[p++] = c >> 6 | 192;
44			out[p++] = c & 63 | 128;
45		} else if ((c & 64512) === 55296 && i + 1 < str.length && (str.charCodeAt(i + 1) & 64512) === 56320) {
46			c = 65536 + ((c & 1023) << 10) + (str.charCodeAt(++i) & 1023);
47			out[p++] = c >> 18 | 240;
48			out[p++] = c >> 12 & 63 | 128;
49			out[p++] = c >> 6 & 63 | 128;
50			out[p++] = c & 63 | 128;
51		} else {
52			out[p++] = c >> 12 | 224;
53			out[p++] = c >> 6 & 63 | 128;
54			out[p++] = c & 63 | 128;
55		}
56	}
57	return out;
58};
59/**
60* Turns an array of numbers into the string given by the concatenation of the
61* characters to which the numbers correspond.
62* @param bytes Array of numbers representing characters.
63* @return Stringification of the array.
64*/
65var byteArrayToString = function(bytes) {
66	const out = [];
67	let pos = 0, c = 0;
68	while (pos < bytes.length) {
69		const c1 = bytes[pos++];
70		if (c1 < 128) out[c++] = String.fromCharCode(c1);
71		else if (c1 > 191 && c1 < 224) {
72			const c2 = bytes[pos++];
73			out[c++] = String.fromCharCode((c1 & 31) << 6 | c2 & 63);
74		} else if (c1 > 239 && c1 < 365) {
75			const c2 = bytes[pos++];
76			const c3 = bytes[pos++];
77			const c4 = bytes[pos++];
78			const u = ((c1 & 7) << 18 | (c2 & 63) << 12 | (c3 & 63) << 6 | c4 & 63) - 65536;
79			out[c++] = String.fromCharCode(55296 + (u >> 10));
80			out[c++] = String.fromCharCode(56320 + (u & 1023));
81		} else {
82			const c2 = bytes[pos++];
83			const c3 = bytes[pos++];
84			out[c++] = String.fromCharCode((c1 & 15) << 12 | (c2 & 63) << 6 | c3 & 63);
85		}
86	}
87	return out.join("");
88};
89var base64 = {
90	byteToCharMap_: null,
91	charToByteMap_: null,
92	byteToCharMapWebSafe_: null,
93	charToByteMapWebSafe_: null,
94	ENCODED_VALS_BASE: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
95	get ENCODED_VALS() {
96		return this.ENCODED_VALS_BASE + "+/=";
97	},
98	get ENCODED_VALS_WEBSAFE() {
99		return this.ENCODED_VALS_BASE + "-_.";
100	},
101	HAS_NATIVE_SUPPORT: typeof atob === "function",
102	encodeByteArray(input, webSafe) {
103		if (!Array.isArray(input)) throw Error("encodeByteArray takes an array as a parameter");
104		this.init_();
105		const byteToCharMap = webSafe ? this.byteToCharMapWebSafe_ : this.byteToCharMap_;
106		const output = [];
107		for (let i = 0; i < input.length; i += 3) {
108			const byte1 = input[i];
109			const haveByte2 = i + 1 < input.length;
110			const byte2 = haveByte2 ? input[i + 1] : 0;
111			const haveByte3 = i + 2 < input.length;
112			const byte3 = haveByte3 ? input[i + 2] : 0;
113			const outByte1 = byte1 >> 2;
114			const outByte2 = (byte1 & 3) << 4 | byte2 >> 4;
115			let outByte3 = (byte2 & 15) << 2 | byte3 >> 6;
116			let outByte4 = byte3 & 63;
117			if (!haveByte3) {
118				outByte4 = 64;
119				if (!haveByte2) outByte3 = 64;
120			}
121			output.push(byteToCharMap[outByte1], byteToCharMap[outByte2], byteToCharMap[outByte3], byteToCharMap[outByte4]);
122		}
123		return output.join("");
124	},
125	encodeString(input, webSafe) {
126		if (this.HAS_NATIVE_SUPPORT && !webSafe) return btoa(input);
127		return this.encodeByteArray(stringToByteArray$1(input), webSafe);
128	},
129	decodeString(input, webSafe) {
130		if (this.HAS_NATIVE_SUPPORT && !webSafe) return atob(input);
131		return byteArrayToString(this.decodeStringToByteArray(input, webSafe));
132	},
133	decodeStringToByteArray(input, webSafe) {
134		this.init_();
135		const charToByteMap = webSafe ? this.charToByteMapWebSafe_ : this.charToByteMap_;
136		const output = [];
137		for (let i = 0; i < input.length;) {
138			const byte1 = charToByteMap[input.charAt(i++)];
139			const byte2 = i < input.length ? charToByteMap[input.charAt(i)] : 0;
140			++i;
141			const byte3 = i < input.length ? charToByteMap[input.charAt(i)] : 64;
142			++i;
143			const byte4 = i < input.length ? charToByteMap[input.charAt(i)] : 64;
144			++i;
145			if (byte1 == null || byte2 == null || byte3 == null || byte4 == null) throw new DecodeBase64StringError();
146			const outByte1 = byte1 << 2 | byte2 >> 4;
147			output.push(outByte1);
148			if (byte3 !== 64) {
149				const outByte2 = byte2 << 4 & 240 | byte3 >> 2;
150				output.push(outByte2);
151				if (byte4 !== 64) {
152					const outByte3 = byte3 << 6 & 192 | byte4;
153					output.push(outByte3);
154				}
155			}
156		}
157		return output;
158	},
159	init_() {
160		if (!this.byteToCharMap_) {
161			this.byteToCharMap_ = {};
162			this.charToByteMap_ = {};
163			this.byteToCharMapWebSafe_ = {};
164			this.charToByteMapWebSafe_ = {};
165			for (let i = 0; i < this.ENCODED_VALS.length; i++) {
166				this.byteToCharMap_[i] = this.ENCODED_VALS.charAt(i);
167				this.charToByteMap_[this.byteToCharMap_[i]] = i;
168				this.byteToCharMapWebSafe_[i] = this.ENCODED_VALS_WEBSAFE.charAt(i);
169				this.charToByteMapWebSafe_[this.byteToCharMapWebSafe_[i]] = i;
170				if (i >= this.ENCODED_VALS_BASE.length) {
171					this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(i)] = i;
172					this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(i)] = i;
173				}
174			}
175		}
176	}
177};
178/**
179* An error encountered while decoding base64 string.
180*/
181var DecodeBase64StringError = class extends Error {
182	constructor() {
183		super(...arguments);
184		this.name = "DecodeBase64StringError";
185	}
186};
187/**
188* URL-safe base64 encoding
189*/
190var base64Encode = function(str) {
191	const utf8Bytes = stringToByteArray$1(str);
192	return base64.encodeByteArray(utf8Bytes, true);
193};
194/**
195* URL-safe base64 encoding (without "." padding in the end).
196* e.g. Used in JSON Web Token (JWT) parts.
197*/
198var base64urlEncodeWithoutPadding = function(str) {
199	return base64Encode(str).replace(/\./g, "");
200};
201/**
202* URL-safe base64 decoding
203*
204* NOTE: DO NOT use the global atob() function - it does NOT support the
205* base64Url variant encoding.
206*
207* @param str To be decoded
208* @return Decoded result, if possible
209*/
210var base64Decode = function(str) {
211	try {
212		return base64.decodeString(str, true);
213	} catch (e) {
214		console.error("base64Decode failed: ", e);
215	}
216	return null;
217};
218/**
219* Copy properties from source to target (recursively allows extension
220* of Objects and Arrays).  Scalar values in the target are over-written.
221* If target is undefined, an object of the appropriate type will be created
222* (and returned).
223*
224* We recursively copy all child properties of plain Objects in the source- so
225* that namespace- like dictionaries are merged.
226*
227* Note that the target can be a function, in which case the properties in
228* the source Object are copied onto it as static properties of the Function.
229*
230* Note: we don't merge __proto__ to prevent prototype pollution
231*/
232function deepExtend(target, source) {
233	if (!(source instanceof Object)) return source;
234	switch (source.constructor) {
235		case Date: return new Date(source.getTime());
236		case Object:
237			if (target === void 0) target = {};
238			break;
239		case Array:
240			target = [];
241			break;
242		default: return source;
243	}
244	for (const prop in source) {
245		if (!source.hasOwnProperty(prop) || !isValidKey(prop)) continue;
246		target[prop] = deepExtend(target[prop], source[prop]);
247	}
248	return target;
249}
250function isValidKey(key) {
251	return key !== "__proto__";
252}
253/**
254* @license
255* Copyright 2022 Google LLC
256*
257* Licensed under the Apache License, Version 2.0 (the "License");
258* you may not use this file except in compliance with the License.
259* You may obtain a copy of the License at
260*
261*   http://www.apache.org/licenses/LICENSE-2.0
262*
263* Unless required by applicable law or agreed to in writing, software
264* distributed under the License is distributed on an "AS IS" BASIS,
265* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
266* See the License for the specific language governing permissions and
267* limitations under the License.
268*/
269/**
270* Polyfill for `globalThis` object.
271* @returns the `globalThis` object for the given environment.
272* @public
273*/
274function getGlobal() {
275	if (typeof self !== "undefined") return self;
276	if (typeof window !== "undefined") return window;
277	if (typeof global !== "undefined") return global;
278	throw new Error("Unable to locate global object.");
279}
280/**
281* @license
282* Copyright 2022 Google LLC
283*
284* Licensed under the Apache License, Version 2.0 (the "License");
285* you may not use this file except in compliance with the License.
286* You may obtain a copy of the License at
287*
288*   http://www.apache.org/licenses/LICENSE-2.0
289*
290* Unless required by applicable law or agreed to in writing, software
291* distributed under the License is distributed on an "AS IS" BASIS,
292* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
293* See the License for the specific language governing permissions and
294* limitations under the License.
295*/
296var getDefaultsFromGlobal = () => getGlobal().__FIREBASE_DEFAULTS__;
297/**
298* Attempt to read defaults from a JSON string provided to
299* process(.)env(.)__FIREBASE_DEFAULTS__ or a JSON file whose path is in
300* process(.)env(.)__FIREBASE_DEFAULTS_PATH__
301* The dots are in parens because certain compilers (Vite?) cannot
302* handle seeing that variable in comments.
303* See https://github.com/firebase/firebase-js-sdk/issues/6838
304*/
305var getDefaultsFromEnvVariable = () => {
306	if (typeof process === "undefined" || false) return;
307	const defaultsJsonString = {}.__FIREBASE_DEFAULTS__;
308	if (defaultsJsonString) return JSON.parse(defaultsJsonString);
309};
310var getDefaultsFromCookie = () => {
311	if (typeof document === "undefined") return;
312	let match;
313	try {
314		match = document.cookie.match(/__FIREBASE_DEFAULTS__=([^;]+)/);
315	} catch (e) {
316		return;
317	}
318	const decoded = match && base64Decode(match[1]);
319	return decoded && JSON.parse(decoded);
320};
321/**
322* Get the __FIREBASE_DEFAULTS__ object. It checks in order:
323* (1) if such an object exists as a property of `globalThis`
324* (2) if such an object was provided on a shell environment variable
325* (3) if such an object exists in a cookie
326* @public
327*/
328var getDefaults = () => {
329	try {
330		return getDefaultsFromPostinstall() || getDefaultsFromGlobal() || getDefaultsFromEnvVariable() || getDefaultsFromCookie();
331	} catch (e) {
332		/**
333		* Catch-all for being unable to get __FIREBASE_DEFAULTS__ due
334		* to any environment case we have not accounted for. Log to
335		* info instead of swallowing so we can find these unknown cases
336		* and add paths for them if needed.
337		*/
338		console.info(`Unable to get __FIREBASE_DEFAULTS__ due to: ${e}`);
339		return;
340	}
341};
342/**
343* Returns emulator host stored in the __FIREBASE_DEFAULTS__ object
344* for the given product.
345* @returns a URL host formatted like `127.0.0.1:9999` or `[::1]:4000` if available
346* @public
347*/
348var getDefaultEmulatorHost = (productName) => {
349	var _a, _b;
350	return (_b = (_a = getDefaults()) === null || _a === void 0 ? void 0 : _a.emulatorHosts) === null || _b === void 0 ? void 0 : _b[productName];
351};
352/**
353* Returns emulator hostname and port stored in the __FIREBASE_DEFAULTS__ object
354* for the given product.
355* @returns a pair of hostname and port like `["::1", 4000]` if available
356* @public
357*/
358var getDefaultEmulatorHostnameAndPort = (productName) => {
359	const host = getDefaultEmulatorHost(productName);
360	if (!host) return;
361	const separatorIndex = host.lastIndexOf(":");
362	if (separatorIndex <= 0 || separatorIndex + 1 === host.length) throw new Error(`Invalid host ${host} with no separate hostname and port!`);
363	const port = parseInt(host.substring(separatorIndex + 1), 10);
364	if (host[0] === "[") return [host.substring(1, separatorIndex - 1), port];
365	else return [host.substring(0, separatorIndex), port];
366};
367/**
368* Returns Firebase app config stored in the __FIREBASE_DEFAULTS__ object.
369* @public
370*/
371var getDefaultAppConfig = () => {
372	var _a;
373	return (_a = getDefaults()) === null || _a === void 0 ? void 0 : _a.config;
374};
375/**
376* Returns an experimental setting on the __FIREBASE_DEFAULTS__ object (properties
377* prefixed by "_")
378* @public
379*/
380var getExperimentalSetting = (name) => {
381	var _a;
382	return (_a = getDefaults()) === null || _a === void 0 ? void 0 : _a[`_${name}`];
383};
384/**
385* @license
386* Copyright 2017 Google LLC
387*
388* Licensed under the Apache License, Version 2.0 (the "License");
389* you may not use this file except in compliance with the License.
390* You may obtain a copy of the License at
391*
392*   http://www.apache.org/licenses/LICENSE-2.0
393*
394* Unless required by applicable law or agreed to in writing, software
395* distributed under the License is distributed on an "AS IS" BASIS,
396* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
397* See the License for the specific language governing permissions and
398* limitations under the License.
399*/
400var Deferred = class {
401	constructor() {
402		this.reject = () => {};
403		this.resolve = () => {};
404		this.promise = new Promise((resolve, reject) => {
405			this.resolve = resolve;
406			this.reject = reject;
407		});
408	}
409	/**
410	* Our API internals are not promisified and cannot because our callback APIs have subtle expectations around
411	* invoking promises inline, which Promises are forbidden to do. This method accepts an optional node-style callback
412	* and returns a node-style callback which will resolve or reject the Deferred's promise.
413	*/
414	wrapCallback(callback) {
415		return (error, value) => {
416			if (error) this.reject(error);
417			else this.resolve(value);
418			if (typeof callback === "function") {
419				this.promise.catch(() => {});
420				if (callback.length === 1) callback(error);
421				else callback(error, value);
422			}
423		};
424	}
425};
426/**
427* @license
428* Copyright 2025 Google LLC
429*
430* Licensed under the Apache License, Version 2.0 (the "License");
431* you may not use this file except in compliance with the License.
432* You may obtain a copy of the License at
433*
434*   http://www.apache.org/licenses/LICENSE-2.0
435*
436* Unless required by applicable law or agreed to in writing, software
437* distributed under the License is distributed on an "AS IS" BASIS,
438* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
439* See the License for the specific language governing permissions and
440* limitations under the License.
441*/
442/**
443* Checks whether host is a cloud workstation or not.
444* @public
445*/
446function isCloudWorkstation(url) {
447	try {
448		return (url.startsWith("http://") || url.startsWith("https://") ? new URL(url).hostname : url).endsWith(".cloudworkstations.dev");
449	} catch (_a) {
450		return false;
451	}
452}
453/**
454* Makes a fetch request to the given server.
455* Mostly used for forwarding cookies in Firebase Studio.
456* @public
457*/
458async function pingServer(endpoint) {
459	return (await fetch(endpoint, { credentials: "include" })).ok;
460}
461/**
462* @license
463* Copyright 2021 Google LLC
464*
465* Licensed under the Apache License, Version 2.0 (the "License");
466* you may not use this file except in compliance with the License.
467* You may obtain a copy of the License at
468*
469*   http://www.apache.org/licenses/LICENSE-2.0
470*
471* Unless required by applicable law or agreed to in writing, software
472* distributed under the License is distributed on an "AS IS" BASIS,
473* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
474* See the License for the specific language governing permissions and
475* limitations under the License.
476*/
477function createMockUserToken(token, projectId) {
478	if (token.uid) throw new Error("The \"uid\" field is no longer supported by mockUserToken. Please use \"sub\" instead for Firebase Auth User ID.");
479	const header = {
480		alg: "none",
481		type: "JWT"
482	};
483	const project = projectId || "demo-project";
484	const iat = token.iat || 0;
485	const sub = token.sub || token.user_id;
486	if (!sub) throw new Error("mockUserToken must contain 'sub' or 'user_id' field!");
487	const payload = Object.assign({
488		iss: `https://securetoken.google.com/${project}`,
489		aud: project,
490		iat,
491		exp: iat + 3600,
492		auth_time: iat,
493		sub,
494		user_id: sub,
495		firebase: {
496			sign_in_provider: "custom",
497			identities: {}
498		}
499	}, token);
500	return [
501		base64urlEncodeWithoutPadding(JSON.stringify(header)),
502		base64urlEncodeWithoutPadding(JSON.stringify(payload)),
503		""
504	].join(".");
505}
506var emulatorStatus = {};
507function getEmulatorSummary() {
508	const summary = {
509		prod: [],
510		emulator: []
511	};
512	for (const key of Object.keys(emulatorStatus)) if (emulatorStatus[key]) summary.emulator.push(key);
513	else summary.prod.push(key);
514	return summary;
515}
516function getOrCreateEl(id) {
517	let parentDiv = document.getElementById(id);
518	let created = false;
519	if (!parentDiv) {
520		parentDiv = document.createElement("div");
521		parentDiv.setAttribute("id", id);
522		created = true;
523	}
524	return {
525		created,
526		element: parentDiv
527	};
528}
529var previouslyDismissed = false;
530/**
531* Updates Emulator Banner. Primarily used for Firebase Studio
532* @param name
533* @param isRunningEmulator
534* @public
535*/
536function updateEmulatorBanner(name, isRunningEmulator) {
537	if (typeof window === "undefined" || typeof document === "undefined" || !isCloudWorkstation(window.location.host) || emulatorStatus[name] === isRunningEmulator || emulatorStatus[name] || previouslyDismissed) return;
538	emulatorStatus[name] = isRunningEmulator;
539	function prefixedId(id) {
540		return `__firebase__banner__${id}`;
541	}
542	const bannerId = "__firebase__banner";
543	const showError = getEmulatorSummary().prod.length > 0;
544	function tearDown() {
545		const element = document.getElementById(bannerId);
546		if (element) element.remove();
547	}
548	function setupBannerStyles(bannerEl) {
549		bannerEl.style.display = "flex";
550		bannerEl.style.background = "#7faaf0";
551		bannerEl.style.position = "fixed";
552		bannerEl.style.bottom = "5px";
553		bannerEl.style.left = "5px";
554		bannerEl.style.padding = ".5em";
555		bannerEl.style.borderRadius = "5px";
556		bannerEl.style.alignItems = "center";
557	}
558	function setupIconStyles(prependIcon, iconId) {
559		prependIcon.setAttribute("width", "24");
560		prependIcon.setAttribute("id", iconId);
561		prependIcon.setAttribute("height", "24");
562		prependIcon.setAttribute("viewBox", "0 0 24 24");
563		prependIcon.setAttribute("fill", "none");
564		prependIcon.style.marginLeft = "-6px";
565	}
566	function setupCloseBtn() {
567		const closeBtn = document.createElement("span");
568		closeBtn.style.cursor = "pointer";
569		closeBtn.style.marginLeft = "16px";
570		closeBtn.style.fontSize = "24px";
571		closeBtn.innerHTML = " &times;";
572		closeBtn.onclick = () => {
573			previouslyDismissed = true;
574			tearDown();
575		};
576		return closeBtn;
577	}
578	function setupLinkStyles(learnMoreLink, learnMoreId) {
579		learnMoreLink.setAttribute("id", learnMoreId);
580		learnMoreLink.innerText = "Learn more";
581		learnMoreLink.href = "https://firebase.google.com/docs/studio/preview-apps#preview-backend";
582		learnMoreLink.setAttribute("target", "__blank");
583		learnMoreLink.style.paddingLeft = "5px";
584		learnMoreLink.style.textDecoration = "underline";
585	}
586	function setupDom() {
587		const banner = getOrCreateEl(bannerId);
588		const firebaseTextId = prefixedId("text");
589		const firebaseText = document.getElementById(firebaseTextId) || document.createElement("span");
590		const learnMoreId = prefixedId("learnmore");
591		const learnMoreLink = document.getElementById(learnMoreId) || document.createElement("a");
592		const prependIconId = prefixedId("preprendIcon");
593		const prependIcon = document.getElementById(prependIconId) || document.createElementNS("http://www.w3.org/2000/svg", "svg");
594		if (banner.created) {
595			const bannerEl = banner.element;
596			setupBannerStyles(bannerEl);
597			setupLinkStyles(learnMoreLink, learnMoreId);
598			const closeBtn = setupCloseBtn();
599			setupIconStyles(prependIcon, prependIconId);
600			bannerEl.append(prependIcon, firebaseText, learnMoreLink, closeBtn);
601			document.body.appendChild(bannerEl);
602		}
603		if (showError) {
604			firebaseText.innerText = `Preview backend disconnected.`;
605			prependIcon.innerHTML = `<g clip-path="url(#clip0_6013_33858)">
606<path d="M4.8 17.6L12 5.6L19.2 17.6H4.8ZM6.91667 16.4H17.0833L12 7.93333L6.91667 16.4ZM12 15.6C12.1667 15.6 12.3056 15.5444 12.4167 15.4333C12.5389 15.3111 12.6 15.1667 12.6 15C12.6 14.8333 12.5389 14.6944 12.4167 14.5833C12.3056 14.4611 12.1667 14.4 12 14.4C11.8333 14.4 11.6889 14.4611 11.5667 14.5833C11.4556 14.6944 11.4 14.8333 11.4 15C11.4 15.1667 11.4556 15.3111 11.5667 15.4333C11.6889 15.5444 11.8333 15.6 12 15.6ZM11.4 13.6H12.6V10.4H11.4V13.6Z" fill="#212121"/>
607</g>
608<defs>
609<clipPath id="clip0_6013_33858">
610<rect width="24" height="24" fill="white"/>
611</clipPath>
612</defs>`;
613		} else {
614			prependIcon.innerHTML = `<g clip-path="url(#clip0_6083_34804)">
615<path d="M11.4 15.2H12.6V11.2H11.4V15.2ZM12 10C12.1667 10 12.3056 9.94444 12.4167 9.83333C12.5389 9.71111 12.6 9.56667 12.6 9.4C12.6 9.23333 12.5389 9.09444 12.4167 8.98333C12.3056 8.86111 12.1667 8.8 12 8.8C11.8333 8.8 11.6889 8.86111 11.5667 8.98333C11.4556 9.09444 11.4 9.23333 11.4 9.4C11.4 9.56667 11.4556 9.71111 11.5667 9.83333C11.6889 9.94444 
61511.8333 10 12 10ZM12 18.4C11.1222 18.4 10.2944 18.2333 9.51667 17.9C8.73889 17.5667 8.05556 17.1111 7.46667 16.5333C6.88889 15.9444 6.43333 15.2611 6.1 14.4833C5.76667 13.7056 5.6 12.8778 5.6 12C5.6 11.1111 5.76667 10.2833 6.1 9.51667C6.43333 8.73889 6.88889 8.06111 7.46667 7.48333C8.05556 6.89444 8.73889 6.43333 9.51667 6.1C10.2944 5.76667 11.1222 5.6 12 5.6C12.8889 5.6 13.7167 5.76667 14.4833 6.1C15.2611 6.43333 15.9389 6.89444 16.5167 7.48333C17.1056 8.06111 17.5667 8.73889 17.9 9.51667C18.2333 10.2833 18.4 11.1111 18.4 12C18.4 12.8778 18.2333 13.7056 17.9 14.4833C17.5667 15.2611 17.1056 15.9444 16.5167 16.5333C15.9389 17.1111 15.2611 17.5667 14.4833 17.9C13.7167 18.2333 12.8889 18.4 12 18.4ZM12 17.2C13.4444 17.2 14.6722 16.6944 15.6833 15.6833C16.6944 14.6722 17.2 13.4444 17.2 12C17.2 10.5556 16.6944 9.32778 15.6833 8.31667C14.6722 7.30555 13.4444 6.8 12 6.8C10.5556 6.8 9.32778 7.30555 8.31667 8.31667C7.30556 9.32778 6.8 10.5556 6.8 12C6.8 13.4444 7.30556 14.6722 8.31667 15.6833C9.32778 16.6944 10.5556 17.2 12 17.2Z" fill="#212121"/>
616</g>
617<defs>
618<clipPath id="clip0_6083_34804">
619<rect width="24" height="24" fill="white"/>
620</clipPath>
621</defs>`;
622			firebaseText.innerText = "Preview backend running in this workspace.";
623		}
624		firebaseText.setAttribute("id", firebaseTextId);
625	}
626	if (document.readyState === "loading") window.addEventListener("DOMContentLoaded", setupDom);
627	else setupDom();
628}
629/**
630* @license
631* Copyright 2017 Google LLC
632*
633* Licensed under the Apache License, Version 2.0 (the "License");
634* you may not use this file except in compliance with the License.
635* You may obtain a copy of the License at
636*
637*   http://www.apache.org/licenses/LICENSE-2.0
638*
639* Unless required by applicable law or agreed to in writing, software
640* distributed under the License is distributed on an "AS IS" BASIS,
641* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
642* See the License for the specific language governing permissions and
643* limitations under the License.
644*/
645/**
646* Returns navigator.userAgent string or '' if it's not defined.
647* @return user agent string
648*/
649function getUA() {
650	if (typeof navigator !== "undefined" && typeof navigator["userAgent"] === "string") return navigator["userAgent"];
651	else return "";
652}
653/**
654* Detect Cordova / PhoneGap / Ionic frameworks on a mobile device.
655*
656* Deliberately does not rely on checking `file://` URLs (as this fails PhoneGap
657* in the Ripple emulator) nor Cordova `onDeviceReady`, which would normally
658* wait for a callback.
659*/
660function isMobileCordova() {
661	return typeof window !== "undefined" && !!(window["cordova"] || window["phonegap"] || window["PhoneGap"]) && /ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(getUA());
662}
663/**
664* Detect Node.js.
665*
666* @return true if Node.js environment is detected or specified.
667*/
668function isNode() {
669	var _a;
670	const forceEnvironment = (_a = getDefaults()) === null || _a === void 0 ? void 0 : _a.forceEnvironment;
671	if (forceEnvironment === "node") return true;
672	else if (forceEnvironment === "browser") return false;
673	try {
674		return Object.prototype.toString.call(global.process) === "[object process]";
675	} catch (e) {
676		return false;
677	}
678}
679/**
680* Detect Cloudflare Worker context.
681*/
682function isCloudflareWorker() {
683	return typeof navigator !== "undefined" && navigator.userAgent === "Cloudflare-Workers";
684}
685function isBrowserExtension() {
686	const runtime = typeof chrome === "object" ? chrome.runtime : typeof browser === "object" ? browser.runtime : void 0;
687	return typeof runtime === "object" && runtime.id !== void 0;
688}
689/**
690* Detect React Native.
691*
692* @return true if ReactNative environment is detected.
693*/
694function isReactNative() {
695	return typeof navigator === "object" && navigator["product"] === "ReactNative";
696}
697/** Detects Internet Explorer. */
698function isIE() {
699	const ua = getUA();
700	return ua.indexOf("MSIE ") >= 0 || ua.indexOf("Trident/") >= 0;
701}
702/** Returns true if we are running in Safari. */
703function isSafari() {
704	return !isNode() && !!navigator.userAgent && navigator.userAgent.includes("Safari") && !navigator.userAgent.includes("Chrome");
705}
706/** Returns true if we are running in Safari or WebKit */
707function isSafariOrWebkit() {
708	return !isNode() && !!navigator.userAgent && (navigator.userAgent.includes("Safari") || navigator.userAgent.includes("WebKit")) && !navigator.userAgent.includes("Chrome");
709}
710/**
711* This method checks if indexedDB is supported by current browser/service worker context
712* @return true if indexedDB is supported by current browser/service worker context
713*/
714function isIndexedDBAvailable() {
715	try {
716		return typeof indexedDB === "object";
717	} catch (e) {
718		return false;
719	}
720}
721/**
722* This method validates browser/sw context for indexedDB by opening a dummy indexedDB database and reject
723* if errors occur during the database open operation.
724*
725* @throws exception if current browser/sw context can't run idb.open (ex: Safari iframe, Firefox
726* private browsing)
727*/
728function validateIndexedDBOpenable() {
729	return new Promise((resolve, reject) => {
730		try {
731			let preExist = true;
732			const DB_CHECK_NAME = "validate-browser-context-for-indexeddb-analytics-module";
733			const request = self.indexedDB.open(DB_CHECK_NAME);
734			request.onsuccess = () => {
735				request.result.close();
736				if (!preExist) self.indexedDB.deleteDatabase(DB_CHECK_NAME);
737				resolve(true);
738			};
739			request.onupgradeneeded = () => {
740				preExist = false;
741			};
742			request.onerror = () => {
743				var _a;
744				reject(((_a = request.error) === null || _a === void 0 ? void 0 : _a.message) || "");
745			};
746		} catch (error) {
747			reject(error);
748		}
749	});
750}
751/**
752* @license
753* Copyright 2017 Google LLC
754*
755* Licensed under the Apache License, Version 2.0 (the "License");
756* you may not use this file except in compliance with the License.
757* You may obtain a copy of the License at
758*
759*   http://www.apache.org/licenses/LICENSE-2.0
760*
761* Unless required by applicable law or agreed to in writing, software
762* distributed under the License is distributed on an "AS IS" BASIS,
763* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
764* See the License for the specific language governing permissions and
765* limitations under the License.
766*/
767/**
768* @fileoverview Standardized Firebase Error.
769*
770* Usage:
771*
772*   // TypeScript string literals for type-safe codes
773*   type Err =
774*     'unknown' |
775*     'object-not-found'
776*     ;
777*
778*   // Closure enum for type-safe error codes
779*   // at-enum {string}
780*   var Err = {
781*     UNKNOWN: 'unknown',
782*     OBJECT_NOT_FOUND: 'object-not-found',
783*   }
784*
785*   let errors: Map<Err, string> = {
786*     'generic-error': "Unknown error",
787*     'file-not-found': "Could not find file: {$file}",
788*   };
789*
790*   // Type-safe function - must pass a valid error code as param.
791*   let error = new ErrorFactory<Err>('service', 'Service', errors);
792*
793*   ...
794*   throw error.create(Err.GENERIC);
795*   ...
796*   throw error.create(Err.FILE_NOT_FOUND, {'file': fileName});
797*   ...
798*   // Service: Could not file file: foo.txt (service/file-not-found).
799*
800*   catch (e) {
801*     assert(e.message === "Could not find file: foo.txt.");
802*     if ((e as FirebaseError)?.code === 'service/file-not-found') {
803*       console.log("Could not read file: " + e['file']);
804*     }
805*   }
806*/
807var ERROR_NAME = "FirebaseError";
808var FirebaseError = class FirebaseError extends Error {
809	constructor(code, message, customData) {
810		super(message);
811		this.code = code;
812		this.customData = customData;
813		/** The custom name for all FirebaseErrors. */
814		this.name = ERROR_NAME;
815		Object.setPrototypeOf(this, FirebaseError.prototype);
816		if (Error.captureStackTrace) Error.captureStackTrace(this, ErrorFactory.prototype.create);
817	}
818};
819var ErrorFactory = class {
820	constructor(service, serviceName, errors) {
821		this.service = service;
822		this.serviceName = serviceName;
823		this.errors = errors;
824	}
825	create(code, ...data) {
826		const customData = data[0] || {};
827		const fullCode = `${this.service}/${code}`;
828		const template = this.errors[code];
829		const message = template ? replaceTemplate(template, customData) : "Error";
830		return new FirebaseError(fullCode, `${this.serviceName}: ${message} (${fullCode}).`, customData);
831	}
832};
833function replaceTemplate(template, data) {
834	return template.replace(PATTERN, (_, key) => {
835		const value = data[key];
836		return value != null ? String(value) : `<${key}?>`;
837	});
838}
839var PATTERN = /\{\$([^}]+)}/g;
840function isEmpty(obj) {
841	for (const key in obj) if (Object.prototype.hasOwnProperty.call(obj, key)) return false;
842	return true;
843}
844/**
845* Deep equal two objects. Support Arrays and Objects.
846*/
847function deepEqual(a, b) {
848	if (a === b) return true;
849	const aKeys = Object.keys(a);
850	const bKeys = Object.keys(b);
851	for (const k of aKeys) {
852		if (!bKeys.includes(k)) return false;
853		const aProp = a[k];
854		const bProp = b[k];
855		if (isObject(aProp) && isObject(bProp)) {
856			if (!deepEqual(aProp, bProp)) return false;
857		} else if (aProp !== bProp) return false;
858	}
859	for (const k of bKeys) if (!aKeys.includes(k)) return false;
860	return true;
861}
862function isObject(thing) {
863	return thing !== null && typeof thing === "object";
864}
865/**
866* @license
867* Copyright 2017 Google LLC
868*
869* Licensed under the Apache License, Version 2.0 (the "License");
870* you may not use this file except in compliance with the License.
871* You may obtain a copy of the License at
872*
873*   http://www.apache.org/licenses/LICENSE-2.0
874*
875* Unless required by applicable law or agreed to in writing, software
876* distributed under the License is distributed on an "AS IS" BASIS,
877* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
878* See the License for the specific language governing permissions and
879* limitations under the License.
880*/
881/**
882* Returns a querystring-formatted string (e.g. &arg=val&arg2=val2) from a
883* params object (e.g. {arg: 'val', arg2: 'val2'})
884* Note: You must prepend it with ? when adding it to a URL.
885*/
886function querystring(querystringParams) {
887	const params = [];
888	for (const [key, value] of Object.entries(querystringParams)) if (Array.isArray(value)) value.forEach((arrayVal) => {
889		params.push(encodeURIComponent(key) + "=" + encodeURIComponent(arrayVal));
890	});
891	else params.push(encodeURIComponent(key) + "=" + encodeURIComponent(value));
892	return params.length ? "&" + params.join("&") : "";
893}
894/**
895* Decodes a querystring (e.g. ?arg=val&arg2=val2) into a params object
896* (e.g. {arg: 'val', arg2: 'val2'})
897*/
898function querystringDecode(querystring) {
899	const obj = {};
900	querystring.replace(/^\?/, "").split("&").forEach((token) => {
901		if (token) {
902			const [key, value] = token.split("=");
903			obj[decodeURIComponent(key)] = decodeURIComponent(value);
904		}
905	});
906	return obj;
907}
908/**
909* Extract the query string part of a URL, including the leading question mark (if present).
910*/
911function extractQuerystring(url) {
912	const queryStart = url.indexOf("?");
913	if (!queryStart) return "";
914	const fragmentStart = url.indexOf("#", queryStart);
915	return url.substring(queryStart, fragmentStart > 0 ? fragmentStart : void 0);
916}
917/**
918* Helper to make a Subscribe function (just like Promise helps make a
919* Thenable).
920*
921* @param executor Function which can make calls to a single Observer
922*     as a proxy.
923* @param onNoObservers Callback when count of Observers goes to zero.
924*/
925function createSubscribe(executor, onNoObservers) {
926	const proxy = new ObserverProxy(executor, onNoObservers);
927	return proxy.subscribe.bind(proxy);
928}
929/**
930* Implement fan-out for any number of Observers attached via a subscribe
931* function.
932*/
933var ObserverProxy = class {
934	/**
935	* @param executor Function which can make calls to a single Observer
936	*     as a proxy.
937	* @param onNoObservers Callback when count of Observers goes to zero.
938	*/
939	constructor(executor, onNoObservers) {
940		this.observers = [];
941		this.unsubscribes = [];
942		this.observerCount = 0;
943		this.task = Promise.resolve();
944		this.finalized = false;
945		this.onNoObservers = onNoObservers;
946		this.task.then(() => {
947			executor(this);
948		}).catch((e) => {
949			this.error(e);
950		});
951	}
952	next(value) {
953		this.forEachObserver((observer) => {
954			observer.next(value);
955		});
956	}
957	error(error) {
958		this.forEachObserver((observer) => {
959			observer.error(error);
960		});
961		this.close(error);
962	}
963	complete() {
964		this.forEachObserver((observer) => {
965			observer.complete();
966		});
967		this.close();
968	}
969	/**
970	* Subscribe function that can be used to add an Observer to the fan-out list.
971	*
972	* - We require that no event is sent to a subscriber synchronously to their
973	*   call to subscribe().
974	*/
975	subscribe(nextOrObserver, error, complete) {
976		let observer;
977		if (nextOrObserver === void 0 && error === void 0 && complete === void 0) throw new Error("Missing Observer.");
978		if (implementsAnyMethods(nextOrObserver, [
979			"next",
980			"error",
981			"complete"
982		])) observer = nextOrObserver;
983		else observer = {
984			next: nextOrObserver,
985			error,
986			complete
987		};
988		if (observer.next === void 0) observer.next = noop;
989		if (observer.error === void 0) observer.error = noop;
990		if (observer.complete === void 0) observer.complete = noop;
991		const unsub = this.unsubscribeOne.bind(this, this.observers.length);
992		if (this.finalized) this.task.then(() => {
993			try {
994				if (this.finalError) observer.error(this.finalError);
995				else observer.complete();
996			} catch (e) {}
997		});
998		this.observers.push(observer);
999		return unsub;
1000	}
1001	unsubscribeOne(i) {
1002		if (this.observers === void 0 || this.observers[i] === void 0) return;
1003		delete this.observers[i];
1004		this.observerCount -= 1;
1005		if (this.observerCount === 0 && this.onNoObservers !== void 0) this.onNoObservers(this);
1006	}
1007	forEachObserver(fn) {
1008		if (this.finalized) return;
1009		for (let i = 0; i < this.observers.length; i++) this.sendOne(i, fn);
1010	}
1011	sendOne(i, fn) {
1012		this.task.then(() => {
1013			if (this.observers !== void 0 && this.observers[i] !== void 0) try {
1014				fn(this.observers[i]);
1015			} catch (e) {
1016				if (typeof console !== "undefined" && console.error) console.error(e);
1017			}
1018		});
1019	}
1020	close(err) {
1021		if (this.finalized) return;
1022		this.finalized = true;
1023		if (err !== void 0) this.finalError = err;
1024		this.task.then(() => {
1025			this.observers = void 0;
1026			this.onNoObservers = void 0;
1027		});
1028	}
1029};
1030/**
1031* Return true if the object passed in implements any of the named methods.
1032*/
1033function implementsAnyMethods(obj, methods) {
1034	if (typeof obj !== "object" || obj === null) return false;
1035	for (const method of methods) if (method in obj && typeof obj[method] === "function") return true;
1036	return false;
1037}
1038function noop() {}
1039/**
1040* @license
1041* Copyright 2021 Google LLC
1042*
1043* Licensed under the Apache License, Version 2.0 (the "License");
1044* you may not use this file except in compliance with the License.
1045* You may obtain a copy of the License at
1046*
1047*   http://www.apache.org/licenses/LICENSE-2.0
1048*
1049* Unless required by applicable law or agreed to in writing, software
1050* distributed under the License is distributed on an "AS IS" BASIS,
1051* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1052* See the License for the specific language governing permissions and
1053* limitations under the License.
1054*/
1055function getModularInstance(service) {
1056	if (service && service._delegate) return service._delegate;
1057	else return service;
1058}
1059//#endregion
1060//#region node_modules/@firebase/component/dist/esm/index.esm2017.js
1061/**
1062* Component for service name T, e.g. `auth`, `auth-internal`
1063*/
1064var Component = class {
1065	/**
1066	*
1067	* @param name The public service name, e.g. app, auth, firestore, database
1068	* @param instanceFactory Service factory responsible for creating the public interface
1069	* @param type whether the service provided by the component is public or private
1070	*/
1071	constructor(name, instanceFactory, type) {
1072		this.name = name;
1073		this.instanceFactory = instanceFactory;
1074		this.type = type;
1075		this.multipleInstances = false;
1076		/**
1077		* Properties to be added to the service namespace
1078		*/
1079		this.serviceProps = {};
1080		this.instantiationMode = "LAZY";
1081		this.onInstanceCreated = null;
1082	}
1083	setInstantiationMode(mode) {
1084		this.instantiationMode = mode;
1085		return this;
1086	}
1087	setMultipleInstances(multipleInstances) {
1088		this.multipleInstances = multipleInstances;
1089		return this;
1090	}
1091	setServiceProps(props) {
1092		this.serviceProps = props;
1093		return this;
1094	}
1095	setInstanceCreatedCallback(callback) {
1096		this.onInstanceCreated = callback;
1097		return this;
1098	}
1099};
1100/**
1101* @license
1102* Copyright 2019 Google LLC
1103*
1104* Licensed under the Apache License, Version 2.0 (the "License");
1105* you may not use this file except in compliance with the License.
1106* You may obtain a copy of the License at
1107*
1108*   http://www.apache.org/licenses/LICENSE-2.0
1109*
1110* Unless required by applicable law or agreed to in writing, software
1111* distributed under the License is distributed on an "AS IS" BASIS,
1112* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1113* See the License for the specific language governing permissions and
1114* limitations under the License.
1115*/
1116var DEFAULT_ENTRY_NAME$1 = "[DEFAULT]";
1117/**
1118* @license
1119* Copyright 2019 Google LLC
1120*
1121* Licensed under the Apache License, Version 2.0 (the "License");
1122* you may not use this file except in compliance with the License.
1123* You may obtain a copy of the License at
1124*
1125*   http://www.apache.org/licenses/LICENSE-2.0
1126*
1127* Unless required by applicable law or agreed to in writing, software
1128* distributed under the License is distributed on an "AS IS" BASIS,
1129* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1130* See the License for the specific language governing permissions and
1131* limitations under the License.
1132*/
1133/**
1134* Provider for instance for service name T, e.g. 'auth', 'auth-internal'
1135* NameServiceMapping[T] is an alias for the type of the instance
1136*/
1137var Provider = class {
1138	constructor(name, container) {
1139		this.name = name;
1140		this.container = container;
1141		this.component = null;
1142		this.instances = /* @__PURE__ */ new Map();
1143		this.instancesDeferred = /* @__PURE__ */ new Map();
1144		this.instancesOptions = /* @__PURE__ */ new Map();
1145		this.onInitCallbacks = /* @__PURE__ */ new Map();
1146	}
1147	/**
1148	* @param identifier A provider can provide multiple instances of a service
1149	* if this.component.multipleInstances is true.
1150	*/
1151	get(identifier) {
1152		const normalizedIdentifier = this.normalizeInstanceIdentifier(identifier);
1153		if (!this.instancesDeferred.has(normalizedIdentifier)) {
1154			const deferred = new Deferred();
1155			this.instancesDeferred.set(normalizedIdentifier, deferred);
1156			if (this.isInitialized(normalizedIdentifier) || this.shouldAutoInitialize()) try {
1157				const instance = this.getOrInitializeService({ instanceIdentifier: normalizedIdentifier });
1158				if (instance) deferred.resolve(instance);
1159			} catch (e) {}
1160		}
1161		return this.instancesDeferred.get(normalizedIdentifier).promise;
1162	}
1163	getImmediate(options) {
1164		var _a;
1165		const normalizedIdentifier = this.normalizeInstanceIdentifier(options === null || options === void 0 ? void 0 : options.identifier);
1166		const optional = (_a = options === null || options === void 0 ? void 0 : options.optional) !== null && _a !== void 0 ? _a : false;
1167		if (this.isInitialized(normalizedIdentifier) || this.shouldAutoInitialize()) try {
1168			return this.getOrInitializeService({ instanceIdentifier: normalizedIdentifier });
1169		} catch (e) {
1170			if (optional) return null;
1171			else throw e;
1172		}
1173		else if (optional) return null;
1174		else throw Error(`Service ${this.name} is not available`);
1175	}
1176	getComponent() {
1177		return this.component;
1178	}
1179	setComponent(component) {
1180		if (component.name !== this.name) throw Error(`Mismatching Component ${component.name} for Provider ${this.name}.`);
1181		if (this.component) throw Error(`Component for ${this.name} has already been provided`);
1182		this.component = component;
1183		if (!this.shouldAutoInitialize()) return;
1184		if (isComponentEager(component)) try {
1185			this.getOrInitializeService({ instanceIdentifier: DEFAULT_ENTRY_NAME$1 });
1186		} catch (e) {}
1187		for (const [instanceIdentifier, instanceDeferred] of this.instancesDeferred.entries()) {
1188			const normalizedIdentifier = this.normalizeInstanceIdentifier(instanceIdentifier);
1189			try {
1190				const instance = this.getOrInitializeService({ instanceIdentifier: normalizedIdentifier });
1191				instanceDeferred.resolve(instance);
1192			} catch (e) {}
1193		}
1194	}
1195	clearInstance(identifier = DEFAULT_ENTRY_NAME$1) {
1196		this.instancesDeferred.delete(identifier);
1197		this.instancesOptions.delete(identifier);
1198		this.instances.delete(identifier);
1199	}
1200	async delete() {
1201		const services = Array.from(this.instances.values());
1202		await Promise.all([...services.filter((service) => "INTERNAL" in service).map((service) => service.INTERNAL.delete()), ...services.filter((service) => "_delete" in service).map((service) => service._delete())]);
1203	}
1204	isComponentSet() {
1205		return this.component != null;
1206	}
1207	isInitialized(identifier = DEFAULT_ENTRY_NAME$1) {
1208		return this.instances.has(identifier);
1209	}
1210	getOptions(identifier = DEFAULT_ENTRY_NAME$1) {
1211		return this.instancesOptions.get(identifier) || {};
1212	}
1213	initialize(opts = {}) {
1214		const { options = {} } = opts;
1215		const normalizedIdentifier = this.normalizeInstanceIdentifier(opts.instanceIdentifier);
1216		if (this.isInitialized(normalizedIdentifier)) throw Error(`${this.name}(${normalizedIdentifier}) has already been initialized`);
1217		if (!this.isComponentSet()) throw Error(`Component ${this.name} has not been registered yet`);
1218		const instance = this.getOrInitializeService({
1219			instanceIdentifier: normalizedIdentifier,
1220			options
1221		});
1222		for (const [instanceIdentifier, instanceDeferred] of this.instancesDeferred.entries()) if (normalizedIdentifier === this.normalizeInstanceIdentifier(instanceIdentifier)) instanceDeferred.resolve(instance);
1223		return instance;
1224	}
1225	/**
1226	*
1227	* @param callback - a function that will be invoked  after the provider has been initialized by calling provider.initialize().
1228	* The function is invoked SYNCHRONOUSLY, so it should not execute any longrunning tasks in order to not block the program.
1229	*
1230	* @param identifier An optional instance identifier
1231	* @returns a function to unregister the callback
1232	*/
1233	onInit(callback, identifier) {
1234		var _a;
1235		const normalizedIdentifier = this.normalizeInstanceIdentifier(identifier);
1236		const existingCallbacks = (_a = this.onInitCallbacks.get(normalizedIdentifier)) !== null && _a !== void 0 ? _a : /* @__PURE__ */ new Set();
1237		existingCallbacks.add(callback);
1238		this.onInitCallbacks.set(normalizedIdentifier, existingCallbacks);
1239		const existingInstance = this.instances.get(normalizedIdentifier);
1240		if (existingInstance) callback(existingInstance, normalizedIdentifier);
1241		return () => {
1242			existingCallbacks.delete(callback);
1243		};
1244	}
1245	/**
1246	* Invoke onInit callbacks synchronously
1247	* @param instance the service instance`
1248	*/
1249	invokeOnInitCallbacks(instance, identifier) {
1250		const callbacks = this.onInitCallbacks.get(identifier);
1251		if (!callbacks) return;
1252		for (const callback of callbacks) try {
1253			callback(instance, identifier);
1254		} catch (_a) {}
1255	}
1256	getOrInitializeService({ instanceIdentifier, options = {} }) {
1257		let instance = this.instances.get(instanceIdentifier);
1258		if (!instance && this.component) {
1259			instance = this.component.instanceFactory(this.container, {
1260				instanceIdentifier: normalizeIdentifierForFactory(instanceIdentifier),
1261				options
1262			});
1263			this.instances.set(instanceIdentifier, instance);
1264			this.instancesOptions.set(instanceIdentifier, options);
1265			/**
1266			* Invoke onInit listeners.
1267			* Note this.component.onInstanceCreated is different, which is used by the component creator,
1268			* while onInit listeners are registered by consumers of the provider.
1269			*/
1270			this.invokeOnInitCallbacks(instance, instanceIdentifier);
1271			/**
1272			* Order is important
1273			* onInstanceCreated() should be called after this.instances.set(instanceIdentifier, instance); which
1274			* makes `isInitialized()` return true.
1275			*/
1276			if (this.component.onInstanceCreated) try {
1277				this.component.onInstanceCreated(this.container, instanceIdentifier, instance);
1278			} catch (_a) {}
1279		}
1280		return instance || null;
1281	}
1282	normalizeInstanceIdentifier(identifier = DEFAULT_ENTRY_NAME$1) {
1283		if (this.component) return this.component.multipleInstances ? identifier : DEFAULT_ENTRY_NAME$1;
1284		else return identifier;
1285	}
1286	shouldAutoInitialize() {
1287		return !!this.component && this.component.instantiationMode !== "EXPLICIT";
1288	}
1289};
1290function normalizeIdentifierForFactory(identifier) {
1291	return identifier === DEFAULT_ENTRY_NAME$1 ? void 0 : identifier;
1292}
1293function isComponentEager(component) {
1294	return component.instantiationMode === "EAGER";
1295}
1296/**
1297* @license
1298* Copyright 2019 Google LLC
1299*
1300* Licensed under the Apache License, Version 2.0 (the "License");
1301* you may not use this file except in compliance with the License.
1302* You may obtain a copy of the License at
1303*
1304*   http://www.apache.org/licenses/LICENSE-2.0
1305*
1306* Unless required by applicable law or agreed to in writing, software
1307* distributed under the License is distributed on an "AS IS" BASIS,
1308* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1309* See the License for the specific language governing permissions and
1310* limitations under the License.
1311*/
1312/**
1313* ComponentContainer that provides Providers for service name T, e.g. `auth`, `auth-internal`
1314*/
1315var ComponentContainer = class {
1316	constructor(name) {
1317		this.name = name;
1318		this.providers = /* @__PURE__ */ new Map();
1319	}
1320	/**
1321	*
1322	* @param component Component being added
1323	* @param overwrite When a component with the same name has already been registered,
1324	* if overwrite is true: overwrite the existing component with the new component and create a new
1325	* provider with the new component. It can be useful in tests where you want to use different mocks
1326	* for different tests.
1327	* if overwrite is false: throw an exception
1328	*/
1329	addComponent(component) {
1330		const provider = this.getProvider(component.name);
1331		if (provider.isComponentSet()) throw new Error(`Component ${component.name} has already been registered with ${this.name}`);
1332		provider.setComponent(component);
1333	}
1334	addOrOverwriteComponent(component) {
1335		if (this.getProvider(component.name).isComponentSet()) this.providers.delete(component.name);
1336		this.addComponent(component);
1337	}
1338	/**
1339	* getProvider provides a type safe interface where it can only be called with a field name
1340	* present in NameServiceMapping interface.
1341	*
1342	* Firebase SDKs providing services should extend NameServiceMapping interface to register
1343	* themselves.
1344	*/
1345	getProvider(name) {
1346		if (this.providers.has(name)) return this.providers.get(name);
1347		const provider = new Provider(name, this);
1348		this.providers.set(name, provider);
1349		return provider;
1350	}
1351	getProviders() {
1352		return Array.from(this.providers.values());
1353	}
1354};
1355//#endregion
1356//#region node_modules/@firebase/logger/dist/esm/index.esm2017.js
1357/**
1358* @license
1359* Copyright 2017 Google LLC
1360*
1361* Licensed under the Apache License, Version 2.0 (the "License");
1362* you may not use this file except in compliance with the License.
1363* You may obtain a copy of the License at
1364*
1365*   http://www.apache.org/licenses/LICENSE-2.0
1366*
1367* Unless required by applicable law or agreed to in writing, software
1368* distributed under the License is distributed on an "AS IS" BASIS,
1369* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1370* See the License for the specific language governing permissions and
1371* limitations under the License.
1372*/
1373/**
1374* A container for all of the Logger instances
1375*/
1376var instances = [];
1377/**
1378* The JS SDK supports 5 log levels and also allows a user the ability to
1379* silence the logs altogether.
1380*
1381* The order is a follows:
1382* DEBUG < VERBOSE < INFO < WARN < ERROR
1383*
1384* All of the log types above the current log level will be captured (i.e. if
1385* you set the log level to `INFO`, errors will still be logged, but `DEBUG` and
1386* `VERBOSE` logs will not)
1387*/
1388var LogLevel;
1389(function(LogLevel) {
1390	LogLevel[LogLevel["DEBUG"] = 0] = "DEBUG";
1391	LogLevel[LogLevel["VERBOSE"] = 1] = "VERBOSE";
1392	LogLevel[LogLevel["INFO"] = 2] = "INFO";
1393	LogLevel[LogLevel["WARN"] = 3] = "WARN";
1394	LogLevel[LogLevel["ERROR"] = 4] = "ERROR";
1395	LogLevel[LogLevel["SILENT"] = 5] = "SILENT";
1396})(LogLevel || (LogLevel = {}));
1397var levelStringToEnum = {
1398	"debug": LogLevel.DEBUG,
1399	"verbose": LogLevel.VERBOSE,
1400	"info": LogLevel.INFO,
1401	"warn": LogLevel.WARN,
1402	"error": LogLevel.ERROR,
1403	"silent": LogLevel.SILENT
1404};
1405/**
1406* The default log level
1407*/
1408var defaultLogLevel = LogLevel.INFO;
1409/**
1410* By default, `console.debug` is not displayed in the developer console (in
1411* chrome). To avoid forcing users to have to opt-in to these logs twice
1412* (i.e. once for firebase, and once in the console), we are sending `DEBUG`
1413* logs to the `console.log` function.
1414*/
1415var ConsoleMethod = {
1416	[LogLevel.DEBUG]: "log",
1417	[LogLevel.VERBOSE]: "log",
1418	[LogLevel.INFO]: "info",
1419	[LogLevel.WARN]: "warn",
1420	[LogLevel.ERROR]: "error"
1421};
1422/**
1423* The default log handler will forward DEBUG, VERBOSE, INFO, WARN, and ERROR
1424* messages on to their corresponding console counterparts (if the log method
1425* is supported by the current log level)
1426*/
1427var defaultLogHandler = (instance, logType, ...args) => {
1428	if (logType < instance.logLevel) return;
1429	const now = (/* @__PURE__ */ new Date()).toISOString();
1430	const method = ConsoleMethod[logType];
1431	if (method) console[method](`[${now}]  ${instance.name}:`, ...args);
1432	else throw new Error(`Attempted to log a message with an invali
1432d logType (value: ${logType})`);
1433};
1434var Logger = class {
1435	/**
1436	* Gives you an instance of a Logger to capture messages according to
1437	* Firebase's logging scheme.
1438	*
1439	* @param name The name that the logs will be associated with
1440	*/
1441	constructor(name) {
1442		this.name = name;
1443		/**
1444		* The log level of the given Logger instance.
1445		*/
1446		this._logLevel = defaultLogLevel;
1447		/**
1448		* The main (internal) log handler for the Logger instance.
1449		* Can be set to a new function in internal package code but not by user.
1450		*/
1451		this._logHandler = defaultLogHandler;
1452		/**
1453		* The optional, additional, user-defined log handler for the Logger instance.
1454		*/
1455		this._userLogHandler = null;
1456		/**
1457		* Capture the current instance for later use
1458		*/
1459		instances.push(this);
1460	}
1461	get logLevel() {
1462		return this._logLevel;
1463	}
1464	set logLevel(val) {
1465		if (!(val in LogLevel)) throw new TypeError(`Invalid value "${val}" assigned to \`logLevel\``);
1466		this._logLevel = val;
1467	}
1468	setLogLevel(val) {
1469		this._logLevel = typeof val === "string" ? levelStringToEnum[val] : val;
1470	}
1471	get logHandler() {
1472		return this._logHandler;
1473	}
1474	set logHandler(val) {
1475		if (typeof val !== "function") throw new TypeError("Value assigned to `logHandler` must be a function");
1476		this._logHandler = val;
1477	}
1478	get userLogHandler() {
1479		return this._userLogHandler;
1480	}
1481	set userLogHandler(val) {
1482		this._userLogHandler = val;
1483	}
1484	/**
1485	* The functions below are all based on the `console` interface
1486	*/
1487	debug(...args) {
1488		this._userLogHandler && this._userLogHandler(this, LogLevel.DEBUG, ...args);
1489		this._logHandler(this, LogLevel.DEBUG, ...args);
1490	}
1491	log(...args) {
1492		this._userLogHandler && this._userLogHandler(this, LogLevel.VERBOSE, ...args);
1493		this._logHandler(this, LogLevel.VERBOSE, ...args);
1494	}
1495	info(...args) {
1496		this._userLogHandler && this._userLogHandler(this, LogLevel.INFO, ...args);
1497		this._logHandler(this, LogLevel.INFO, ...args);
1498	}
1499	warn(...args) {
1500		this._userLogHandler && this._userLogHandler(this, LogLevel.WARN, ...args);
1501		this._logHandler(this, LogLevel.WARN, ...args);
1502	}
1503	error(...args) {
1504		this._userLogHandler && this._userLogHandler(this, LogLevel.ERROR, ...args);
1505		this._logHandler(this, LogLevel.ERROR, ...args);
1506	}
1507};
1508//#endregion
1509//#region node_modules/idb/build/wrap-idb-value.js
1510var instanceOfAny = (object, constructors) => constructors.some((c) => object instanceof c);
1511var idbProxyableTypes;
1512var cursorAdvanceMethods;
1513function getIdbProxyableTypes() {
1514	return idbProxyableTypes || (idbProxyableTypes = [
1515		IDBDatabase,
1516		IDBObjectStore,
1517		IDBIndex,
1518		IDBCursor,
1519		IDBTransaction
1520	]);
1521}
1522function getCursorAdvanceMethods() {
1523	return cursorAdvanceMethods || (cursorAdvanceMethods = [
1524		IDBCursor.prototype.advance,
1525		IDBCursor.prototype.continue,
1526		IDBCursor.prototype.continuePrimaryKey
1527	]);
1528}
1529var cursorRequestMap = /* @__PURE__ */ new WeakMap();
1530var transactionDoneMap = /* @__PURE__ */ new WeakMap();
1531var transactionStoreNamesMap = /* @__PURE__ */ new WeakMap();
1532var transformCache = /* @__PURE__ */ new WeakMap();
1533var reverseTransformCache = /* @__PURE__ */ new WeakMap();
1534function promisifyRequest(request) {
1535	const promise = new Promise((resolve, reject) => {
1536		const unlisten = () => {
1537			request.removeEventListener("success", success);
1538			request.removeEventListener("error", error);
1539		};
1540		const success = () => {
1541			resolve(wrap(request.result));
1542			unlisten();
1543		};
1544		const error = () => {
1545			reject(request.error);
1546			unlisten();
1547		};
1548		request.addEventListener("success", success);
1549		request.addEventListener("error", error);
1550	});
1551	promise.then((value) => {
1552		if (value instanceof IDBCursor) cursorRequestMap.set(value, request);
1553	}).catch(() => {});
1554	reverseTransformCache.set(promise, request);
1555	return promise;
1556}
1557function cacheDonePromiseForTransaction(tx) {
1558	if (transactionDoneMap.has(tx)) return;
1559	const done = new Promise((resolve, reject) => {
1560		const unlisten = () => {
1561			tx.removeEventListener("complete", complete);
1562			tx.removeEventListener("error", error);
1563			tx.removeEventListener("abort", error);
1564		};
1565		const complete = () => {
1566			resolve();
1567			unlisten();
1568		};
1569		const error = () => {
1570			reject(tx.error || new DOMException("AbortError", "AbortError"));
1571			unlisten();
1572		};
1573		tx.addEventListener("complete", complete);
1574		tx.addEventListener("error", error);
1575		tx.addEventListener("abort", error);
1576	});
1577	transactionDoneMap.set(tx, done);
1578}
1579var idbProxyTraps = {
1580	get(target, prop, receiver) {
1581		if (target instanceof IDBTransaction) {
1582			if (prop === "done") return transactionDoneMap.get(target);
1583			if (prop === "objectStoreNames") return target.objectStoreNames || transactionStoreNamesMap.get(target);
1584			if (prop === "store") return receiver.objectStoreNames[1] ? void 0 : receiver.objectStore(receiver.objectStoreNames[0]);
1585		}
1586		return wrap(target[prop]);
1587	},
1588	set(target, prop, value) {
1589		target[prop] = value;
1590		return true;
1591	},
1592	has(target, prop) {
1593		if (target instanceof IDBTransaction && (prop === "done" || prop === "store")) return true;
1594		return prop in target;
1595	}
1596};
1597function replaceTraps(callback) {
1598	idbProxyTraps = callback(idbProxyTraps);
1599}
1600function wrapFunction(func) {
1601	if (func === IDBDatabase.prototype.transaction && !("objectStoreNames" in IDBTransaction.prototype)) return function(storeNames, ...args) {
1602		const tx = func.call(unwrap(this), storeNames, ...args);
1603		transactionStoreNamesMap.set(tx, storeNames.sort ? storeNames.sort() : [storeNames]);
1604		return wrap(tx);
1605	};
1606	if (getCursorAdvanceMethods().includes(func)) return function(...args) {
1607		func.apply(unwrap(this), args);
1608		return wrap(cursorRequestMap.get(this));
1609	};
1610	return function(...args) {
1611		return wrap(func.apply(unwrap(this), args));
1612	};
1613}
1614function transformCachableValue(value) {
1615	if (typeof value === "function") return wrapFunction(value);
1616	if (value instanceof IDBTransaction) cacheDonePromiseForTransaction(value);
1617	if (instanceOfAny(value, getIdbProxyableTypes())) return new Proxy(value, idbProxyTraps);
1618	return value;
1619}
1620function wrap(value) {
1621	if (value instanceof IDBRequest) return promisifyRequest(value);
1622	if (transformCache.has(value)) return transformCache.get(value);
1623	const newValue = transformCachableValue(value);
1624	if (newValue !== value) {
1625		transformCache.set(value, newValue);
1626		reverseTransformCache.set(newValue, value);
1627	}
1628	return newValue;
1629}
1630var unwrap = (value) => reverseTransformCache.get(value);
1631//#endregion
1632//#region node_modules/idb/build/index.js
1633/**
1634* Open a database.
1635*
1636* @param name Name of the database.
1637* @param version Schema version.
1638* @param callbacks Additional callbacks.
1639*/
1640function openDB(name, version, { blocked, upgrade, blocking, terminated } = {}) {
1641	const request = indexedDB.open(name, version);
1642	const openPromise = wrap(request);
1643	if (upgrade) request.addEventListener("upgradeneeded", (event) => {
1644		upgrade(wrap(request.result), event.oldVersion, event.newVersion, wrap(request.transaction), event);
1645	});
1646	if (blocked) request.addEventListener("blocked", (event) => blocked(event.oldVersion, event.newVersion, event));
1647	openPromise.then((db) => {
1648		if (terminated) db.addEventListener("close", () => terminated());
1649		if (blocking) db.addEventListener("versionchange", (event) => blocking(event.oldVersion, event.newVersion, event));
1650	}).catch(() => {});
1651	return openPromise;
1652}
1653var readMethods = [
1654	"get",
1655	"getKey",
1656	"getAll",
1657	"getAllKeys",
1658	"count"
1659];
1660var writeMethods = [
1661	"put",
1662	"add",
1663	"delete",
1664	"clear"
1665];
1666var cachedMethods = /* @__PURE__ */ new Map();
1667function getMethod(target, prop) {
1668	if (!(target instanceof IDBDatabase && !(prop in target) && typeof prop === "string")) return;
1669	if (cachedMethods.get(prop)) return cachedMethods.get(prop);
1670	const targetFuncName = prop.replace(/FromIndex$/, "");
1671	const useIndex = prop !== targetFuncName;
1672	const isWrite = writeMethods.includes(targetFuncName);
1673	if (!(targetFuncName in (useIndex ? IDBIndex : IDBObjectStore).prototype) || !(isWrite || readMethods.includes(targetFuncName))) return;
1674	const method = async function(storeName, ...args) {
1675		const tx = this.transaction(storeName, isWrite ? "readwrite" : "readonly");
1676		let target = tx.store;
1677		if (useIndex) target = target.index(args.shift());
1678		return (await Promise.all([target[targetFuncName](...args), isWrite && tx.done]))[0];
1679	};
1680	cachedMethods.set(prop, method);
1681	return method;
1682}
1683replaceTraps((oldTraps) => ({
1684	...oldTraps,
1685	get: (target, prop, receiver) => getMethod(target, prop) || oldTraps.get(target, prop, receiver),
1686	has: (target, prop) => !!getMethod(target, prop) || oldTraps.has(target, prop)
1687}));
1688//#endregion
1689//#region node_modules/@firebase/app/dist/esm/index.esm2017.js
1690/**
1691* @license
1692* Copyright 2019 Google LLC
1693*
1694* Licensed under the Apache License, Version 2.0 (the "License");
1695* you may not use this file except in compliance with the License.
1696* You may obtain a copy of the License at
1697*
1698*   http://www.apache.org/licenses/LICENSE-2.0
1699*
1700* Unless required by applicable law or agreed to in writing, software
1701* distributed under the License is distributed on an "AS IS" BASIS,
1702* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1703* See the License for the specific language governing permissions and
1704* limitations under the License.
1705*/
1706var PlatformLoggerServiceImpl = class {
1707	constructor(container) {
1708		this.container = container;
1709	}
1710	getPlatformInfoString() {
1711		return this.container.getProviders().map((provider) => {
1712			if (isVersionServiceProvider(provider)) {
1713				const service = provider.getImmediate();
1714				return `${service.library}/${service.version}`;
1715			} else return null;
1716		}).filter((logString) => logString).join(" ");
1717	}
1718};
1719/**
1720*
1721* @param provider check if this provider provides a VersionService
1722*
1723* NOTE: Using Provider<'app-version'> is a hack to indicate that the provider
1724* provides VersionService. The provider is not necessarily a 'app-version'
1725* provider.
1726*/
1727function isVersionServiceProvider(provider) {
1728	const component = provider.getComponent();
1729	return (component === null || component === void 0 ? void 0 : component.type) === "VERSION";
1730}
1731var name$q = "@firebase/app";
1732var version$1 = "0.13.2";
1733/**
1734* @license
1735* Copyright 2019 Google LLC
1736*
1737* Licensed under the Apache License, Version 2.0 (the "License");
1738* you may not use this file except in compliance with the License.
1739* You may obtain a copy of the License at
1740*
1741*   http://www.apache.org/licenses/LICENSE-2.0
1742*
1743* Unless required by applicable law or agreed to in writing, software
1744* distributed under the License is distributed on an "AS IS" BASIS,
1745* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1746* See the License for the specific language governing permissions and
1747* limitations under the License.
1748*/
1749var logger$1 = new Logger("@firebase/app");
1750var name$p = "@firebase/app-compat";
1751var name$o = "@firebase/analytics-compat";
1752var name$n = "@firebase/analytics";
1753var name$m = "@firebase/app-check-compat";
1754var name$l = "@firebase/app-check";
1755var name$k = "@firebase/auth";
1756var name$j = "@firebase/auth-compat";
1757var name$i = "@firebase/database";
1758var name$h = "@firebase/data-connect";
1759var name$g = "@firebase/database-compat";
1760var name$f = "@firebase/functions";
1761var name$e = "@firebase/functions-compat";
1762var name$d = "@firebase/installations";
1763var name$c = "@firebase/installations-compat";
1764var name$b = "@firebase/messaging";
1765var name$a = "@firebase/messaging-compat";
1766var name$9 = "@firebase/performance";
1767var name$8 = "@firebase/performance-compat";
1768var name$7 = "@firebase/remote-config";
1769var name$6 = "@firebase/remote-config-compat";
1770var name$5 = "@firebase/storage";
1771var name$4 = "@firebase/storage-compat";
1772var name$3 = "@firebase/firestore";
1773var name$2 = "@firebase/ai";
1774var name$1 = "@firebase/firestore-compat";
1775var name$10 = "firebase";
1776var version$2 = "11.10.0";
1777/**
1778* @license
1779* Copyright 2019 Google LLC
1780*
1781* Licensed under the Apache License, Version 2.0 (the "License");
1782* you may not use this file except in compliance with the License.
1783* You may obtain a copy of the License at
1784*
1785*   http://www.apache.org/licenses/LICENSE-2.0
1786*
1787* Unless required by applicable law or agreed to in writing, software
1788* distributed under the License is distributed on an "AS IS" BASIS,
1789* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1790* See the License for the specific language governing permissions and
1791* limitations under the License.
1792*/
1793/**
1794* The default app name
1795*
1796* @internal
1797*/
1798var DEFAULT_ENTRY_NAME = "[DEFAULT]";
1799var PLATFORM_LOG_STRING = {
1800	[name$q]: "fire-core",
1801	[name$p]: "fire-core-compat",
1802	[name$n]: "fire-analytics",
1803	[name$o]: "fire-analytics-compat",
1804	[name$l]: "fire-app-check",
1805	[name$m]: "fire-app-check-compat",
1806	[name$k]: "fire-auth",
1807	[name$j]: "fire-auth-compat",
1808	[name$i]: "fire-rtdb",
1809	[name$h]: "fire-data-connect",
1810	[name$g]: "fire-rtdb-compat",
1811	[name$f]: "fire-fn",
1812	[name$e]: "fire-fn-compat",
1813	[name$d]: "fire-iid",
1814	[name$c]: "fire-iid-compat",
1815	[name$b]: "fire-fcm",
1816	[name$a]: "fire-fcm-compat",
1817	[name$9]: "fire-perf",
1818	[name$8]: "fire-perf-compat",
1819	[name$7]: "fire-rc",
1820	[name$6]: "fire-rc-compat",
1821	[name$5]: "fire-gcs",
1822	[name$4]: "fire-gcs-compat",
1823	[name$3]: "fire-fst",
1824	[name$1]: "fire-fst-compat",
1825	[name$2]: "fire-vertex",
1826	"fire-js": "fire-js",
1827	[name$10]: "fire-js-all"
1828};
1829/**
1830* @license
1831* Copyright 2019 Google LLC
1832*
1833* Licensed under the Apache License, Version 2.0 (the "License");
1834* you may not use this file except in compliance with the License.
1835* You may obtain a copy of the License at
1836*
1837*   http://www.apache.org/licenses/LICENSE-2.0
1838*
1839* Unless required by applicable law or agreed to in writing, software
1840* distributed under the License is distributed on an "AS IS" BASIS,
1841* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1842* See the License for the specific language governing permissions and
1843* limitations under the License.
1844*/
1845/**
1846* @internal
1847*/
1848var _apps = /* @__PURE__ */ new Map();
1849/**
1850* @internal
1851*/
1852var _serverApps = /* @__PURE__ */ new Map();
1853/**
1854* Registered components.
1855*
1856* @internal
1857*/
1858var _components = /* @__PURE__ */ new Map();
1859/**
1860* @param component - the component being added to this app's container
1861*
1862* @internal
1863*/
1864function _addComponent(app, component) {
1865	try {
1866		app.container.addComponent(component);
1867	} catch (e) {
1868		logger$1.debug(`Component ${component.name} failed to register with FirebaseApp ${app.name}`, e);
1869	}
1870}
1871/**
1872*
1873* @param component - the component to register
1874* @returns whether or not the component is registered successfully
1875*
1876* @internal
1877*/
1878function _registerComponent(component) {
1879	const componentName = component.name;
1880	if (_components.has(componentName)) {
1881		logger$1.debug(`There were multiple attempts to register component ${componentName}.`);
1882		return false;
1883	}
1884	_components.set(componentName, component);
1885	for (const app of _apps.values()) _addComponent(app, component);
1886	for (const serverApp of _serverApps.values()) _addComponent(serverApp, component);
1887	return true;
1888}
1889/**
1890*
1891* @param app - FirebaseApp instance
1892* @param name - service name
1893*
1894* @returns the provider for the service with the matching name
1895*
1896* @internal
1897*/
1898function _getProvider(app, name) {
1899	const heartbeatController = app.container.getProvider("heartbeat").getImmediate({ optional: true });
1900	if (heartbeatController) heartbeatController.triggerHeartbeat();
1901	return app.container.getProvider(name);
1902}
1903/**
1904*
1905* @param app - FirebaseApp instance
1906* @param name - service name
1907* @param instanceIdentifier - service instance identifier in case the service supports multiple instances
1908*
1909* @internal
1910*/
1911function _removeServiceInstance(app, name, instanceIdentifier = DEFAULT_ENTRY_NAME) {
1912	_getProvider(app, name).clearInstance(instanceIdentifier);
1913}
1914/**
1915*
1916* @param obj - an object of type FirebaseApp.
1917*
1918* @returns true if the provided object is of type FirebaseServerAppImpl.
1919*
1920* @internal
1921*/
1922function _isFirebaseServerApp(obj) {
1923	if (obj === null || obj === void 0) return false;
1924	return obj.settings !== void 0;
1925}
1926var ERROR_FACTORY = new ErrorFactory("app", "Firebase", {
1927	["no-app"]: "No Firebase App '{$appName}' has been created - call initializeApp() first",
1928	["bad-app-name"]: "Illegal App name: '{$appName}'",
1929	["duplicate-app"]: "Firebase App named '{$appName}' already exists with different options or config",
1930	["app-deleted"]: "Firebase App named '{$appName}' already deleted",
1931	["server-app-deleted"]: "Firebase Server App has been deleted",
1932	["no-options"]: "Need to provide options, when not being deployed to hosting via source.",
1933	["invalid-app-argument"]: "firebase.{$appName}() takes either no argument or a Firebase App instance.",
1934	["invalid-log-argument"]: "First argument to `onLog` must be null or a function.",
1935	["idb-open"]: "Error thrown when opening IndexedDB. Original error: {$originalErrorMessage}.",
1936	["idb-get"]: "Error thrown when reading from IndexedDB. Original error: {$originalErrorMessage}.",
1937	["idb-set"]: "Error thrown when writing to IndexedDB. Original error: {$originalErrorMessage}.",
1938	["idb-delete"]: "Error thrown when deleting from IndexedDB. Original error: {$originalErrorMessage}.",
1939	["finalization-registry-not-supported"]: "FirebaseServerApp deleteOnDeref field defined but the JS runtime does not support FinalizationRegistry.",
1940	["invalid-server-app-environment"]: "FirebaseServerApp is not for use in browser environments."
1941});
1942/**
1943* @license
1944* Copyright 2019 Google LLC
1945*
1946* Licensed under the Apache License, Version 2.0 (the "License");
1947* you may not use this file except in compliance with the License.
1948* You may obtain a copy of the License at
1949*
1950*   http://www.apache.org/licenses/LICENSE-2.0
1951*
1952* Unless required by applicable law or agreed to in writing, softw
1952are
1953* distributed under the License is distributed on an "AS IS" BASIS,
1954* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1955* See the License for the specific language governing permissions and
1956* limitations under the License.
1957*/
1958var FirebaseAppImpl = class {
1959	constructor(options, config, container) {
1960		this._isDeleted = false;
1961		this._options = Object.assign({}, options);
1962		this._config = Object.assign({}, config);
1963		this._name = config.name;
1964		this._automaticDataCollectionEnabled = config.automaticDataCollectionEnabled;
1965		this._container = container;
1966		this.container.addComponent(new Component("app", () => this, "PUBLIC"));
1967	}
1968	get automaticDataCollectionEnabled() {
1969		this.checkDestroyed();
1970		return this._automaticDataCollectionEnabled;
1971	}
1972	set automaticDataCollectionEnabled(val) {
1973		this.checkDestroyed();
1974		this._automaticDataCollectionEnabled = val;
1975	}
1976	get name() {
1977		this.checkDestroyed();
1978		return this._name;
1979	}
1980	get options() {
1981		this.checkDestroyed();
1982		return this._options;
1983	}
1984	get config() {
1985		this.checkDestroyed();
1986		return this._config;
1987	}
1988	get container() {
1989		return this._container;
1990	}
1991	get isDeleted() {
1992		return this._isDeleted;
1993	}
1994	set isDeleted(val) {
1995		this._isDeleted = val;
1996	}
1997	/**
1998	* This function will throw an Error if the App has already been deleted -
1999	* use before performing API actions on the App.
2000	*/
2001	checkDestroyed() {
2002		if (this.isDeleted) throw ERROR_FACTORY.create("app-deleted", { appName: this._name });
2003	}
2004};
2005/**
2006* @license
2007* Copyright 2019 Google LLC
2008*
2009* Licensed under the Apache License, Version 2.0 (the "License");
2010* you may not use this file except in compliance with the License.
2011* You may obtain a copy of the License at
2012*
2013*   http://www.apache.org/licenses/LICENSE-2.0
2014*
2015* Unless required by applicable law or agreed to in writing, software
2016* distributed under the License is distributed on an "AS IS" BASIS,
2017* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2018* See the License for the specific language governing permissions and
2019* limitations under the License.
2020*/
2021/**
2022* The current SDK version.
2023*
2024* @public
2025*/
2026var SDK_VERSION = version$2;
2027function initializeApp(_options, rawConfig = {}) {
2028	let options = _options;
2029	if (typeof rawConfig !== "object") rawConfig = { name: rawConfig };
2030	const config = Object.assign({
2031		name: DEFAULT_ENTRY_NAME,
2032		automaticDataCollectionEnabled: true
2033	}, rawConfig);
2034	const name = config.name;
2035	if (typeof name !== "string" || !name) throw ERROR_FACTORY.create("bad-app-name", { appName: String(name) });
2036	options || (options = getDefaultAppConfig());
2037	if (!options) throw ERROR_FACTORY.create("no-options");
2038	const existingApp = _apps.get(name);
2039	if (existingApp) if (deepEqual(options, existingApp.options) && deepEqual(config, existingApp.config)) return existingApp;
2040	else throw ERROR_FACTORY.create("duplicate-app", { appName: name });
2041	const container = new ComponentContainer(name);
2042	for (const component of _components.values()) container.addComponent(component);
2043	const newApp = new FirebaseAppImpl(options, config, container);
2044	_apps.set(name, newApp);
2045	return newApp;
2046}
2047/**
2048* Retrieves a {@link @firebase/app#FirebaseApp} instance.
2049*
2050* When called with no arguments, the default app is returned. When an app name
2051* is provided, the app corresponding to that name is returned.
2052*
2053* An exception is thrown if the app being retrieved has not yet been
2054* initialized.
2055*
2056* @example
2057* ```javascript
2058* // Return the default app
2059* const app = getApp();
2060* ```
2061*
2062* @example
2063* ```javascript
2064* // Return a named app
2065* const otherApp = getApp("otherApp");
2066* ```
2067*
2068* @param name - Optional name of the app to return. If no name is
2069*   provided, the default is `"[DEFAULT]"`.
2070*
2071* @returns The app corresponding to the provided app name.
2072*   If no app name is provided, the default app is returned.
2073*
2074* @public
2075*/
2076function getApp(name = DEFAULT_ENTRY_NAME) {
2077	const app = _apps.get(name);
2078	if (!app && name === "[DEFAULT]" && getDefaultAppConfig()) return initializeApp();
2079	if (!app) throw ERROR_FACTORY.create("no-app", { appName: name });
2080	return app;
2081}
2082/**
2083* A (read-only) array of all initialized apps.
2084* @public
2085*/
2086function getApps() {
2087	return Array.from(_apps.values());
2088}
2089/**
2090* Registers a library's name and version for platform logging purposes.
2091* @param library - Name of 1p or 3p library (e.g. firestore, angularfire)
2092* @param version - Current version of that library.
2093* @param variant - Bundle variant, e.g., node, rn, etc.
2094*
2095* @public
2096*/
2097function registerVersion(libraryKeyOrName, version, variant) {
2098	var _a;
2099	let library = (_a = PLATFORM_LOG_STRING[libraryKeyOrName]) !== null && _a !== void 0 ? _a : libraryKeyOrName;
2100	if (variant) library += `-${variant}`;
2101	const libraryMismatch = library.match(/\s|\//);
2102	const versionMismatch = version.match(/\s|\//);
2103	if (libraryMismatch || versionMismatch) {
2104		const warning = [`Unable to register library "${library}" with version "${version}":`];
2105		if (libraryMismatch) warning.push(`library name "${library}" contains illegal characters (whitespace or "/")`);
2106		if (libraryMismatch && versionMismatch) warning.push("and");
2107		if (versionMismatch) warning.push(`version name "${version}" contains illegal characters (whitespace or "/")`);
2108		logger$1.warn(warning.join(" "));
2109		return;
2110	}
2111	_registerComponent(new Component(`${library}-version`, () => ({
2112		library,
2113		version
2114	}), "VERSION"));
2115}
2116/**
2117* @license
2118* Copyright 2021 Google LLC
2119*
2120* Licensed under the Apache License, Version 2.0 (the "License");
2121* you may not use this file except in compliance with the License.
2122* You may obtain a copy of the License at
2123*
2124*   http://www.apache.org/licenses/LICENSE-2.0
2125*
2126* Unless required by applicable law or agreed to in writing, software
2127* distributed under the License is distributed on an "AS IS" BASIS,
2128* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2129* See the License for the specific language governing permissions and
2130* limitations under the License.
2131*/
2132var DB_NAME = "firebase-heartbeat-database";
2133var DB_VERSION = 1;
2134var STORE_NAME = "firebase-heartbeat-store";
2135var dbPromise = null;
2136function getDbPromise() {
2137	if (!dbPromise) dbPromise = openDB(DB_NAME, DB_VERSION, { upgrade: (db, oldVersion) => {
2138		switch (oldVersion) {
2139			case 0: try {
2140				db.createObjectStore(STORE_NAME);
2141			} catch (e) {
2142				console.warn(e);
2143			}
2144		}
2145	} }).catch((e) => {
2146		throw ERROR_FACTORY.create("idb-open", { originalErrorMessage: e.message });
2147	});
2148	return dbPromise;
2149}
2150async function readHeartbeatsFromIndexedDB(app) {
2151	try {
2152		const tx = (await getDbPromise()).transaction(STORE_NAME);
2153		const result = await tx.objectStore(STORE_NAME).get(computeKey(app));
2154		await tx.done;
2155		return result;
2156	} catch (e) {
2157		if (e instanceof FirebaseError) logger$1.warn(e.message);
2158		else {
2159			const idbGetError = ERROR_FACTORY.create("idb-get", { originalErrorMessage: e === null || e === void 0 ? void 0 : e.message });
2160			logger$1.warn(idbGetError.message);
2161		}
2162	}
2163}
2164async function writeHeartbeatsToIndexedDB(app, heartbeatObject) {
2165	try {
2166		const tx = (await getDbPromise()).transaction(STORE_NAME, "readwrite");
2167		await tx.objectStore(STORE_NAME).put(heartbeatObject, computeKey(app));
2168		await tx.done;
2169	} catch (e) {
2170		if (e instanceof FirebaseError) logger$1.warn(e.message);
2171		else {
2172			const idbGetError = ERROR_FACTORY.create("idb-set", { originalErrorMessage: e === null || e === void 0 ? void 0 : e.message });
2173			logger$1.warn(idbGetError.message);
2174		}
2175	}
2176}
2177function computeKey(app) {
2178	return `${app.name}!${app.options.appId}`;
2179}
2180/**
2181* @license
2182* Copyright 2021 Google LLC
2183*
2184* Licensed under the Apache License, Version 2.0 (the "License");
2185* you may not use this file except in compliance with the License.
2186* You may obtain a copy of the License at
2187*
2188*   http://www.apache.org/licenses/LICENSE-2.0
2189*
2190* Unless required by applicable law or agreed to in writing, software
2191* distributed under the License is distributed on an "AS IS" BASIS,
2192* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2193* See the License for the specific language governing permissions and
2194* limitations under the License.
2195*/
2196var MAX_HEADER_BYTES = 1024;
2197var MAX_NUM_STORED_HEARTBEATS = 30;
2198var HeartbeatServiceImpl = class {
2199	constructor(container) {
2200		this.container = container;
2201		/**
2202		* In-memory cache for heartbeats, used by getHeartbeatsHeader() to generate
2203		* the header string.
2204		* Stores one record per date. This will be consolidated into the standard
2205		* format of one record per user agent string before being sent as a header.
2206		* Populated from indexedDB when the controller is instantiated and should
2207		* be kept in sync with indexedDB.
2208		* Leave public for easier testing.
2209		*/
2210		this._heartbeatsCache = null;
2211		this._storage = new HeartbeatStorageImpl(this.container.getProvider("app").getImmediate());
2212		this._heartbeatsCachePromise = this._storage.read().then((result) => {
2213			this._heartbeatsCache = result;
2214			return result;
2215		});
2216	}
2217	/**
2218	* Called to report a heartbeat. The function will generate
2219	* a HeartbeatsByUserAgent object, update heartbeatsCache, and persist it
2220	* to IndexedDB.
2221	* Note that we only store one heartbeat per day. So if a heartbeat for today is
2222	* already logged, subsequent calls to this function in the same day will be ignored.
2223	*/
2224	async triggerHeartbeat() {
2225		var _a, _b;
2226		try {
2227			const agent = this.container.getProvider("platform-logger").getImmediate().getPlatformInfoString();
2228			const date = getUTCDateString();
2229			if (((_a = this._heartbeatsCache) === null || _a === void 0 ? void 0 : _a.heartbeats) == null) {
2230				this._heartbeatsCache = await this._heartbeatsCachePromise;
2231				if (((_b = this._heartbeatsCache) === null || _b === void 0 ? void 0 : _b.heartbeats) == null) return;
2232			}
2233			if (this._heartbeatsCache.lastSentHeartbeatDate === date || this._heartbeatsCache.heartbeats.some((singleDateHeartbeat) => singleDateHeartbeat.date === date)) return;
2234			else {
2235				this._heartbeatsCache.heartbeats.push({
2236					date,
2237					agent
2238				});
2239				if (this._heartbeatsCache.heartbeats.length > MAX_NUM_STORED_HEARTBEATS) {
2240					const earliestHeartbeatIdx = getEarliestHeartbeatIdx(this._heartbeatsCache.heartbeats);
2241					this._heartbeatsCache.heartbeats.splice(earliestHeartbeatIdx, 1);
2242				}
2243			}
2244			return this._storage.overwrite(this._heartbeatsCache);
2245		} catch (e) {
2246			logger$1.warn(e);
2247		}
2248	}
2249	/**
2250	* Returns a base64 encoded string which can be attached to the heartbeat-specific header directly.
2251	* It also clears all heartbeats from memory as well as in IndexedDB.
2252	*
2253	* NOTE: Consuming product SDKs should not send the header if this method
2254	* returns an empty string.
2255	*/
2256	async getHeartbeatsHeader() {
2257		var _a;
2258		try {
2259			if (this._heartbeatsCache === null) await this._heartbeatsCachePromise;
2260			if (((_a = this._heartbeatsCache) === null || _a === void 0 ? void 0 : _a.heartbeats) == null || this._heartbeatsCache.heartbeats.length === 0) return "";
2261			const date = getUTCDateString();
2262			const { heartbeatsToSend, unsentEntries } = extractHeartbeatsForHeader(this._heartbeatsCache.heartbeats);
2263			const headerString = base64urlEncodeWithoutPadding(JSON.stringify({
2264				version: 2,
2265				heartbeats: heartbeatsToSend
2266			}));
2267			this._heartbeatsCache.lastSentHeartbeatDate = date;
2268			if (unsentEntries.length > 0) {
2269				this._heartbeatsCache.heartbeats = unsentEntries;
2270				await this._storage.overwrite(this._heartbeatsCache);
2271			} else {
2272				this._heartbeatsCache.heartbeats = [];
2273				this._storage.overwrite(this._heartbeatsCache);
2274			}
2275			return headerString;
2276		} catch (e) {
2277			logger$1.warn(e);
2278			return "";
2279		}
2280	}
2281};
2282function getUTCDateString() {
2283	return (/* @__PURE__ */ new Date()).toISOString().substring(0, 10);
2284}
2285function extractHeartbeatsForHeader(heartbeatsCache, maxSize = MAX_HEADER_BYTES) {
2286	const heartbeatsToSend = [];
2287	let unsentEntries = heartbeatsCache.slice();
2288	for (const singleDateHeartbeat of heartbeatsCache) {
2289		const heartbeatEntry = heartbeatsToSend.find((hb) => hb.agent === singleDateHeartbeat.agent);
2290		if (!heartbeatEntry) {
2291			heartbeatsToSend.push({
2292				agent: singleDateHeartbeat.agent,
2293				dates: [singleDateHeartbeat.date]
2294			});
2295			if (countBytes(heartbeatsToSend) > maxSize) {
2296				heartbeatsToSend.pop();
2297				break;
2298			}
2299		} else {
2300			heartbeatEntry.dates.push(singleDateHeartbeat.date);
2301			if (countBytes(heartbeatsToSend) > maxSize) {
2302				heartbeatEntry.dates.pop();
2303				break;
2304			}
2305		}
2306		unsentEntries = unsentEntries.slice(1);
2307	}
2308	return {
2309		heartbeatsToSend,
2310		unsentEntries
2311	};
2312}
2313var HeartbeatStorageImpl = class {
2314	constructor(app) {
2315		this.app = app;
2316		this._canUseIndexedDBPromise = this.runIndexedDBEnvironmentCheck();
2317	}
2318	async runIndexedDBEnvironmentCheck() {
2319		if (!isIndexedDBAvailable()) return false;
2320		else return validateIndexedDBOpenable().then(() => true).catch(() => false);
2321	}
2322	/**
2323	* Read all heartbeats.
2324	*/
2325	async read() {
2326		if (!await this._canUseIndexedDBPromise) return { heartbeats: [] };
2327		else {
2328			const idbHeartbeatObject = await readHeartbeatsFromIndexedDB(this.app);
2329			if (idbHeartbeatObject === null || idbHeartbeatObject === void 0 ? void 0 : idbHeartbeatObject.heartbeats) return idbHeartbeatObject;
2330			else return { heartbeats: [] };
2331		}
2332	}
2333	async overwrite(heartbeatsObject) {
2334		var _a;
2335		if (!await this._canUseIndexedDBPromise) return;
2336		else {
2337			const existingHeartbeatsObject = await this.read();
2338			return writeHeartbeatsToIndexedDB(this.app, {
2339				lastSentHeartbeatDate: (_a = heartbeatsObject.lastSentHeartbeatDate) !== null && _a !== void 0 ? _a : existingHeartbeatsObject.lastSentHeartbeatDate,
2340				heartbeats: heartbeatsObject.heartbeats
2341			});
2342		}
2343	}
2344	async add(heartbeatsObject) {
2345		var _a;
2346		if (!await this._canUseIndexedDBPromise) return;
2347		else {
2348			const existingHeartbeatsObject = await this.read();
2349			return writeHeartbeatsToIndexedDB(this.app, {
2350				lastSentHeartbeatDate: (_a = heartbeatsObject.lastSentHeartbeatDate) !== null && _a !== void 0 ? _a : existingHeartbeatsObject.lastSentHeartbeatDate,
2351				heartbeats: [...existingHeartbeatsObject.heartbeats, ...heartbeatsObject.heartbeats]
2352			});
2353		}
2354	}
2355};
2356/**
2357* Calculate bytes of a HeartbeatsByUserAgent array after being wrapped
2358* in a platform logging header JSON object, stringified, and converted
2359* to base 64.
2360*/
2361function countBytes(heartbeatsCache) {
2362	return base64urlEncodeWithoutPadding(JSON.stringify({
2363		version: 2,
2364		heartbeats: heartbeatsCache
2365	})).length;
2366}
2367/**
2368* Returns the index of the heartbeat with the earliest date.
2369* If the heartbeats array is empty, -1 is returned.
2370*/
2371function getEarliestHeartbeatIdx(heartbeats) {
2372	if (heartbeats.length === 0) return -1;
2373	let earliestHeartbeatIdx = 0;
2374	let earliestHeartbeatDate = heartbeats[0].date;
2375	for (let i = 1; i < heartbeats.length; i++) if (heartbeats[i].date < earliestHeartbeatDate) {
2376		earliestHeartbeatDate = heartbeats[i].date;
2377		earliestHeartbeatIdx = i;
2378	}
2379	return earliestHeartbeatIdx;
2380}
2381/**
2382* @license
2383* Copyright 2019 Google LLC
2384*
2385* Licensed under the Apache License, Version 2.0 (the "License");
2386* you may not use this file except in compliance with the License.
2387* You may obtain a copy of the License at
2388*
2389*   http://www.apache.org/licenses/LICENSE-2.0
2390*
2391* Unless required by applicable law or agreed to in writing, softw
2391are
2392* distributed under the License is distributed on an "AS IS" BASIS,
2393* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2394* See the License for the specific language governing permissions and
2395* limitations under the License.
2396*/
2397function registerCoreComponents(variant) {
2398	_registerComponent(new Component("platform-logger", (container) => new PlatformLoggerServiceImpl(container), "PRIVATE"));
2399	_registerComponent(new Component("heartbeat", (container) => new HeartbeatServiceImpl(container), "PRIVATE"));
2400	registerVersion(name$q, version$1, variant);
2401	registerVersion(name$q, version$1, "esm2017");
2402	registerVersion("fire-js", "");
2403}
2404/**
2405* Firebase App
2406*
2407* @remarks This package coordinates the communication between the different Firebase components
2408* @packageDocumentation
2409*/
2410registerCoreComponents("");
2411//#endregion
2412//#region node_modules/tslib/tslib.es6.mjs
2413/******************************************************************************
2414Copyright (c) Microsoft Corporation.
2415
2416Permission to use, copy, modify, and/or distribute this software for any
2417purpose with or without fee is hereby granted.
2418
2419THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
2420REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
2421AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
2422INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
2423LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
2424OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
2425PERFORMANCE OF THIS SOFTWARE.
2426***************************************************************************** */
2427var extendStatics = function(d, b) {
2428	extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d, b) {
2429		d.__proto__ = b;
2430	} || function(d, b) {
2431		for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
2432	};
2433	return extendStatics(d, b);
2434};
2435var __assign = function() {
2436	__assign = Object.assign || function __assign(t) {
2437		for (var s, i = 1, n = arguments.length; i < n; i++) {
2438			s = arguments[i];
2439			for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
2440		}
2441		return t;
2442	};
2443	return __assign.apply(this, arguments);
2444};
2445function __rest(s, e) {
2446	var t = {};
2447	for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
2448	if (s != null && typeof Object.getOwnPropertySymbols === "function") {
2449		for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
2450	}
2451	return t;
2452}
2453function __await(v) {
2454	return this instanceof __await ? (this.v = v, this) : new __await(v);
2455}
2456function __asyncGenerator(thisArg, _arguments, generator) {
2457	if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
2458	var g = generator.apply(thisArg, _arguments || []), i, q = [];
2459	return i = Object.create((typeof AsyncIterator === "function" ? AsyncIterator : Object).prototype), verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function() {
2460		return this;
2461	}, i;
2462	function awaitReturn(f) {
2463		return function(v) {
2464			return Promise.resolve(v).then(f, reject);
2465		};
2466	}
2467	function verb(n, f) {
2468		if (g[n]) {
2469			i[n] = function(v) {
2470				return new Promise(function(a, b) {
2471					q.push([
2472						n,
2473						v,
2474						a,
2475						b
2476					]) > 1 || resume(n, v);
2477				});
2478			};
2479			if (f) i[n] = f(i[n]);
2480		}
2481	}
2482	function resume(n, v) {
2483		try {
2484			step(g[n](v));
2485		} catch (e) {
2486			settle(q[0][3], e);
2487		}
2488	}
2489	function step(r) {
2490		r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r);
2491	}
2492	function fulfill(value) {
2493		resume("next", value);
2494	}
2495	function reject(value) {
2496		resume("throw", value);
2497	}
2498	function settle(f, v) {
2499		if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]);
2500	}
2501}
2502var ownKeys = function(o) {
2503	ownKeys = Object.getOwnPropertyNames || function(o) {
2504		var ar = [];
2505		for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
2506		return ar;
2507	};
2508	return ownKeys(o);
2509};
2510//#endregion
2511//#region node_modules/@firebase/ai/dist/esm/index.esm2017.js
2512var name = "@firebase/ai";
2513var version = "1.4.1";
2514/**
2515* @license
2516* Copyright 2024 Google LLC
2517*
2518* Licensed under the Apache License, Version 2.0 (the "License");
2519* you may not use this file except in compliance with the License.
2520* You may obtain a copy of the License at
2521*
2522*   http://www.apache.org/licenses/LICENSE-2.0
2523*
2524* Unless required by applicable law or agreed to in writing, software
2525* distributed under the License is distributed on an "AS IS" BASIS,
2526* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2527* See the License for the specific language governing permissions and
2528* limitations under the License.
2529*/
2530var AI_TYPE = "AI";
2531var DEFAULT_LOCATION = "us-central1";
2532var DEFAULT_BASE_URL = "https://firebasevertexai.googleapis.com";
2533var DEFAULT_API_VERSION = "v1beta";
2534var PACKAGE_VERSION = version;
2535var LANGUAGE_TAG = "gl-js";
2536var DEFAULT_FETCH_TIMEOUT_MS = 180 * 1e3;
2537/**
2538* @license
2539* Copyright 2024 Google LLC
2540*
2541* Licensed under the Apache License, Version 2.0 (the "License");
2542* you may not use this file except in compliance with the License.
2543* You may obtain a copy of the License at
2544*
2545*   http://www.apache.org/licenses/LICENSE-2.0
2546*
2547* Unless required by applicable law or agreed to in writing, software
2548* distributed under the License is distributed on an "AS IS" BASIS,
2549* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2550* See the License for the specific language governing permissions and
2551* limitations under the License.
2552*/
2553/**
2554* Possible roles.
2555* @public
2556*/
2557var POSSIBLE_ROLES = [
2558	"user",
2559	"model",
2560	"function",
2561	"system"
2562];
2563/**
2564* Harm categories that would cause prompts or candidates to be blocked.
2565* @public
2566*/
2567var HarmCategory;
2568(function(HarmCategory) {
2569	HarmCategory["HARM_CATEGORY_HATE_SPEECH"] = "HARM_CATEGORY_HATE_SPEECH";
2570	HarmCategory["HARM_CATEGORY_SEXUALLY_EXPLICIT"] = "HARM_CATEGORY_SEXUALLY_EXPLICIT";
2571	HarmCategory["HARM_CATEGORY_HARASSMENT"] = "HARM_CATEGORY_HARASSMENT";
2572	HarmCategory["HARM_CATEGORY_DANGEROUS_CONTENT"] = "HARM_CATEGORY_DANGEROUS_CONTENT";
2573})(HarmCategory || (HarmCategory = {}));
2574/**
2575* Threshold above which a prompt or candidate will be blocked.
2576* @public
2577*/
2578var HarmBlockThreshold;
2579(function(HarmBlockThreshold) {
2580	/**
2581	* Content with `NEGLIGIBLE` will be allowed.
2582	*/
2583	HarmBlockThreshold["BLOCK_LOW_AND_ABOVE"] = "BLOCK_LOW_AND_ABOVE";
2584	/**
2585	* Content with `NEGLIGIBLE` and `LOW` will be allowed.
2586	*/
2587	HarmBlockThreshold["BLOCK_MEDIUM_AND_ABOVE"] = "BLOCK_MEDIUM_AND_ABOVE";
2588	/**
2589	* Content with `NEGLIGIBLE`, `LOW`, and `MEDIUM` will be allowed.
2590	*/
2591	HarmBlockThreshold["BLOCK_ONLY_HIGH"] = "BLOCK_ONLY_HIGH";
2592	/**
2593	* All content will be allowed.
2594	*/
2595	HarmBlockThreshold["BLOCK_NONE"] = "BLOCK_NONE";
2596	/**
2597	* All content will be allowed. This is the same as `BLOCK_NONE`, but the metadata corresponding
2598	* to the {@link HarmCategory} will not be present in the response.
2599	*/
2600	HarmBlockThreshold["OFF"] = "OFF";
2601})(HarmBlockThreshold || (HarmBlockThreshold = {}));
2602/**
2603* This property is not supported in the Gemini Developer API ({@link GoogleAIBackend}).
2604*
2605* @public
2606*/
2607var HarmBlockMethod;
2608(function(HarmBlockMethod) {
2609	/**
2610	* The harm block method uses both probability and severity scores.
2611	*/
2612	HarmBlockMethod["SEVERITY"] = "SEVERITY";
2613	/**
2614	* The harm block method uses the probability score.
2615	*/
2616	HarmBlockMethod["PROBABILITY"] = "PROBABILITY";
2617})(HarmBlockMethod || (HarmBlockMethod = {}));
2618/**
2619* Probability that a prompt or candidate matches a harm category.
2620* @public
2621*/
2622var HarmProbability;
2623(function(HarmProbability) {
2624	/**
2625	* Content has a negligible chance of being unsafe.
2626	*/
2627	HarmProbability["NEGLIGIBLE"] = "NEGLIGIBLE";
2628	/**
2629	* Content has a low chance of being unsafe.
2630	*/
2631	HarmProbability["LOW"] = "LOW";
2632	/**
2633	* Content has a medium chance of being unsafe.
2634	*/
2635	HarmProbability["MEDIUM"] = "MEDIUM";
2636	/**
2637	* Content has a high chance of being unsafe.
2638	*/
2639	HarmProbability["HIGH"] = "HIGH";
2640})(HarmProbability || (HarmProbability = {}));
2641/**
2642* Harm severity levels.
2643* @public
2644*/
2645var HarmSeverity;
2646(function(HarmSeverity) {
2647	/**
2648	* Negligible level of harm severity.
2649	*/
2650	HarmSeverity["HARM_SEVERITY_NEGLIGIBLE"] = "HARM_SEVERITY_NEGLIGIBLE";
2651	/**
2652	* Low level of harm severity.
2653	*/
2654	HarmSeverity["HARM_SEVERITY_LOW"] = "HARM_SEVERITY_LOW";
2655	/**
2656	* Medium level of harm severity.
2657	*/
2658	HarmSeverity["HARM_SEVERITY_MEDIUM"] = "HARM_SEVERITY_MEDIUM";
2659	/**
2660	* High level of harm severity.
2661	*/
2662	HarmSeverity["HARM_SEVERITY_HIGH"] = "HARM_SEVERITY_HIGH";
2663	/**
2664	* Harm severity is not supported.
2665	*
2666	* @remarks
2667	* The GoogleAI backend does not support `HarmSeverity`, so this value is used as a fallback.
2668	*/
2669	HarmSeverity["HARM_SEVERITY_UNSUPPORTED"] = "HARM_SEVERITY_UNSUPPORTED";
2670})(HarmSeverity || (HarmSeverity = {}));
2671/**
2672* Reason that a prompt was blocked.
2673* @public
2674*/
2675var BlockReason;
2676(function(BlockReason) {
2677	/**
2678	* Content was blocked by safety settings.
2679	*/
2680	BlockReason["SAFETY"] = "SAFETY";
2681	/**
2682	* Content was blocked, but the reason is uncategorized.
2683	*/
2684	BlockReason["OTHER"] = "OTHER";
2685	/**
2686	* Content was blocked because it contained terms from the terminology blocklist.
2687	*/
2688	BlockReason["BLOCKLIST"] = "BLOCKLIST";
2689	/**
2690	* Content was blocked due to prohibited content.
2691	*/
2692	BlockReason["PROHIBITED_CONTENT"] = "PROHIBITED_CONTENT";
2693})(BlockReason || (BlockReason = {}));
2694/**
2695* Reason that a candidate finished.
2696* @public
2697*/
2698var FinishReason;
2699(function(FinishReason) {
2700	/**
2701	* Natural stop point of the model or provided stop sequence.
2702	*/
2703	FinishReason["STOP"] = "STOP";
2704	/**
2705	* The maximum number of tokens as specified in the request was reached.
2706	*/
2707	FinishReason["MAX_TOKENS"] = "MAX_TOKENS";
2708	/**
2709	* The candidate content was flagged for safety reasons.
2710	*/
2711	FinishReason["SAFETY"] = "SAFETY";
2712	/**
2713	* The candidate content was flagged for recitation reasons.
2714	*/
2715	FinishReason["RECITATION"] = "RECITATION";
2716	/**
2717	* Unknown reason.
2718	*/
2719	FinishReason["OTHER"] = "OTHER";
2720	/**
2721	* The candidate content contained forbidden terms.
2722	*/
2723	FinishReason["BLOCKLIST"] = "BLOCKLIST";
2724	/**
2725	* The candidate content potentially contained prohibited content.
2726	*/
2727	FinishReason["PROHIBITED_CONTENT"] = "PROHIBITED_CONTENT";
2728	/**
2729	* The candidate content potentially contained Sensitive Personally Identifiable Information (SPII).
2730	*/
2731	FinishReason["SPII"] = "SPII";
2732	/**
2733	* The function call generated by the model was invalid.
2734	*/
2735	FinishReason["MALFORMED_FUNCTION_CALL"] = "MALFORMED_FUNCTION_CALL";
2736})(FinishReason || (FinishReason = {}));
2737/**
2738* @public
2739*/
2740var FunctionCallingMode;
2741(function(FunctionCallingMode) {
2742	/**
2743	* Default model behavior; model decides to predict either a function call
2744	* or a natural language response.
2745	*/
2746	FunctionCallingMode["AUTO"] = "AUTO";
2747	/**
2748	* Model is constrained to always predicting a function call only.
2749	* If `allowed_function_names` is set, the predicted function call will be
2750	* limited to any one of `allowed_function_names`, else the predicted
2751	* function call will be any one of the provided `function_declarations`.
2752	*/
2753	FunctionCallingMode["ANY"] = "ANY";
2754	/**
2755	* Model will not predict any function call. Model behavior is same as when
2756	* not passing any function declarations.
2757	*/
2758	FunctionCallingMode["NONE"] = "NONE";
2759})(FunctionCallingMode || (FunctionCallingMode = {}));
2760/**
2761* Content part modality.
2762* @public
2763*/
2764var Modality;
2765(function(Modality) {
2766	/**
2767	* Unspecified modality.
2768	*/
2769	Modality["MODALITY_UNSPECIFIED"] = "MODALITY_UNSPECIFIED";
2770	/**
2771	* Plain text.
2772	*/
2773	Modality["TEXT"] = "TEXT";
2774	/**
2775	* Image.
2776	*/
2777	Modality["IMAGE"] = "IMAGE";
2778	/**
2779	* Video.
2780	*/
2781	Modality["VIDEO"] = "VIDEO";
2782	/**
2783	* Audio.
2784	*/
2785	Modality["AUDIO"] = "AUDIO";
2786	/**
2787	* Document (for example, PDF).
2788	*/
2789	Modality["DOCUMENT"] = "DOCUMENT";
2790})(Modality || (Modality = {}));
2791/**
2792* Generation modalities to be returned in generation responses.
2793*
2794* @beta
2795*/
2796var ResponseModality = {
2797	TEXT: "TEXT",
2798	IMAGE: "IMAGE"
2799};
2800/**
2801* @license
2802* Copyright 2024 Google LLC
2803*
2804* Licensed under the Apache License, Version 2.0 (the "License");
2805* you may not use this file except in compliance with the License.
2806* You may obtain a copy of the License at
2807*
2808*   http://www.apache.org/licenses/LICENSE-2.0
2809*
2810* Unless required by applicable law or agreed to in writing, software
2811* distributed under the License is distributed on an "AS IS" BASIS,
2812* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2813* See the License for the specific language governing permissions and
2814* limitations under the License.
2815*/
2816/**
2817* Contains the list of OpenAPI data types
2818* as defined by the
2819* {@link https://swagger.io/docs/specification/data-models/data-types/ | OpenAPI specification}
2820* @public
2821*/
2822var SchemaType;
2823(function(SchemaType) {
2824	/** String type. */
2825	SchemaType["STRING"] = "string";
2826	/** Number type. */
2827	SchemaType["NUMBER"] = "number";
2828	/** Integer type. */
2829	SchemaType["INTEGER"] = "integer";
2830	/** Boolean type. */
2831	SchemaType["BOOLEAN"] = "boolean";
2832	/** Array type. */
2833	SchemaType["ARRAY"] = "array";
2834	/** Object type. */
2835	SchemaType["OBJECT"] = "object";
2836})(SchemaType || (SchemaType = {}));
2837/**
2838* @license
2839* Copyright 2025 Google LLC
2840*
2841* Licensed under the Apache License, Version 2.0 (the "License");
2842* you may not use this file except in compliance with the License.
2843* You may obtain a copy of the License at
2844*
2845*   http://www.apache.org/licenses/LICENSE-2.0
2846*
2847* Unless required by applicable law or agreed to in writing, software
2848* distributed under the License is distributed on an "AS IS" BASIS,
2849* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2850* See the License for the specific language governing permissions and
2851* limitations under the License.
2852*/
2853/**
2854* A filter level controlling how aggressively to filter sensitive content.
2855*
2856* Text prompts provided as inputs and images (generated or uploaded) through Imagen on Vertex AI
2857* are assessed against a list of safety filters, which include 'harmful categories' (for example,
2858* `violence`, `sexual`, `derogatory`, and `toxic`). This filter level controls how aggressively to
2859* filter out potentially harmful content from responses. See the {@link http://firebase.google.com/docs/vertex-ai/generate-images | documentation }
2860* and the {@link https://cloud.google.com/vertex-ai/generative-ai/docs/image/responsible-ai-imagen#safety-filters | Responsible AI and usage guidelines}
2861* for more details.
2862*
2863* @beta
2864*/
2865var ImagenSafetyFilterLevel;
2866(function(ImagenSafetyFilterLevel) {
2867	/**
2868	* The most aggressive filtering level; most strict blocking.
2869	*/
2870	ImagenSafetyFilterLevel["BLOCK_LOW_AND_ABOVE"] = "block_low_and_above";
2871	/**
2872	* Blocks some sensitive prompts and responses.
2873	*/
2874	ImagenSafetyFilterLevel["BLOCK_MEDIUM_AND_ABOVE"] = "block_medium_and_above";
2875	/**
2876	* Blocks few sensitive prompts and responses.
2877	*/
2878	ImagenSafetyFilterLevel["BLOCK_ONLY_HIGH"] = "block_only_high";
2879	/**
2880	* The least aggressive filtering level; blocks very few sensitive prompts and responses.
2881	*
2882	* Access to this feature is restricted and may require your case to be reviewed and approved by
2883	* Cloud support.
2884	*/
2885	ImagenSafetyFilterLevel["BLOCK_NONE"] = "block_none";
2886})(ImagenSafetyFilterLevel || (ImagenSafetyFilterLevel = {}));
2887/**
2888* A filter level controlling whether generation of images containing people or faces is allowed.
2889*
2890* See the <a href="http://firebase.google.com/docs/vertex-ai/generate-images">personGeneration</a>
2891* documentation for more details.
2892*
2893* @beta
2894*/
2895var ImagenPersonFilterLevel;
2896(function(ImagenPersonFilterLevel) {
2897	/**
2898	* Disallow generation of images containing people or faces; images of people are filtered out.
2899	*/
2900	ImagenPersonFilterLevel["BLOCK_ALL"] = "dont_allow";
2901	/**
2902	* Allow generation of images containing adults only; images of children are filtered out.
2903	*
2904	* Generation of images containing people or faces may require your use case to be
2905	* reviewed and approved by Cloud support; see the {@link https://cloud.google.com/vertex-ai/generative-ai/docs/image/responsible-ai-imagen#person-face-gen | Responsible AI and usage guidelines}
2906	* for more details.
2907	*/
2908	ImagenPersonFilterLevel["ALLOW_ADULT"] = "allow_adult";
2909	/**
2910	* Allow generation of images containing adults only; images of children are filtered out.
2911	*
2912	* Generation of images containing people or faces may require your use case to be
2913	* reviewed and approved by Cloud support; see the {@link https://cloud.google.com/vertex-ai/generative-ai/docs/image/responsible-ai-imagen#person-face-gen | Responsible AI and usage guidelines}
2914	* for more details.
2915	*/
2916	ImagenPersonFilterLevel["ALLOW_ALL"] = "allow_all";
2917})(ImagenPersonFilterLevel || (ImagenPersonFilterLevel = {}));
2918/**
2919* Aspect ratios for Imagen images.
2920*
2921* To specify an aspect ratio for generated images, set the `aspectRatio` property in your
2922* {@link ImagenGenerationConfig}.
2923*
2924* See the the {@link http://firebase.google.com/docs/vertex-ai/generate-images | documentation }
2925* for more details and examples of the supported aspect ratios.
2926*
2927* @beta
2928*/
2929var ImagenAspectRatio;
2930(function(ImagenAspectRatio) {
2931	/**
2932	* Square (1:1) aspect ratio.
2933	*/
2934	ImagenAspectRatio["SQUARE"] = "1:1";
2935	/**
2936	* Landscape (3:4) aspect ratio.
2937	*/
2938	ImagenAspectRatio["LANDSCAPE_3x4"] = "3:4";
2939	/**
2940	* Portrait (4:3) aspect ratio.
2941	*/
2942	ImagenAspectRatio["PORTRAIT_4x3"] = "4:3";
2943	/**
2944	* Landscape (16:9) aspect ratio.
2945	*/
2946	ImagenAspectRatio["LANDSCAPE_16x9"] = "16:9";
2947	/**
2948	* Portrait (9:16) aspect ratio.
2949	*/
2950	ImagenAspectRatio["PORTRAIT_9x16"] = "9:16";
2951})(ImagenAspectRatio || (ImagenAspectRatio = {}));
2952/**
2953* @license
2954* Copyright 2024 Google LLC
2955*
2956* Licensed under the Apache License, Version 2.0 (the "License");
2957* you may not use this file except in compliance with the License.
2958* You may obtain a copy of the License at
2959*
2960*   http://www.apache.org/licenses/LICENSE-2.0
2961*
2962* Unless required by applicable law or agreed to in writing, software
2963* distributed under the License is distributed on an "AS IS" BASIS,
2964* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2965* See the License for the specific language governing permissions and
2966* limitations under the License.
2967*/
2968/**
2969* An enum-like object containing constants that represent the supported backends
2970* for the Firebase AI SDK.
2971* This determines which backend service (Vertex AI Gemini API or Gemini Developer API)
2972* the SDK will communicate with.
2973*
2974* These values are assigned to the `backendType` property within the specific backend
2975* configuration objects ({@link GoogleAIBackend} or {@link VertexAIBackend}) to identify
2976* which service to target.
2977*
2978* @public
2979*/
2980var BackendType = {
2981	VERTEX_AI: "VERTEX_AI",
2982	GOOGLE_AI: "GOOGLE_AI"
2983};
2984/**
2985* @license
2986* Copyright 2025 Google LLC
2987*
2988* Licensed under the Apache License, Version 2.0 (the "License");
2989* you may not use this file except in compliance with the License.
2990* You may obtain a copy of the License at
2991*
2992*   http://www.apache.org/licenses/LICENSE-2.0
2993*
2994* Unless required by applicable law or agreed to in writing, software
2995* distributed under the License is distributed on an "AS IS" BASIS,
2996* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2997* See the License for the specific language governing permissions and
2998* limitations under the License.
2999*/
3000/**
3001* Abstract base class representing the configuration for an AI service backend.
3002* This class should not be instantiated directly. Use its subclasses; {@link GoogleAIBackend} for
3003* the Gemini Developer API (via {@link https://ai.google/ | Google AI}), and
3004* {@link VertexAIBackend} for the Vertex AI Gemini API.
3005*
3006* @public
3007*/
3008var Backend = class {
3009	/**
3010	* Protected constructor for use by subclasses.
3011	* @param type - The backend type.
3012	*/
3013	constructor(type) {
3014		this.backendType = type;
3015	}
3016};
3017/**
3018* Configuration class for the Gemini Developer API.
3019*
3020* Use this with {@link AIOptions} when initializing the AI service via
3021* {@link getAI | getAI()} to specify the Gemini Developer API as the backend.
3022*
3023* @public
3024*/
3025var GoogleAIBackend = class extends Backend {
3026	/**
3027	* Creates a configuration object for the Gemini Developer API backend.
3028	*/
3029	constructor() {
3030		super(BackendType.GOOGLE_AI);
3031	}
3032};
3033/**
3034* Configuration class for the Vertex AI Gemini API.
3035*
3036* Use this with {@link AIOptions} when initializing the AI service via
3037* {@link getAI | getAI()} to specify the Vertex AI Gemini API as the backend.
3038*
3039* @public
3040*/
3041var VertexAIBackend = class extends Backend {
3042	/**
3043	* Creates a configuration object for the Vertex AI backend.
3044	*
3045	* @param location - The region identifier, defaulting to `us-central1`;
3046	* see {@link https://firebase.google.com/docs/vertex-ai/locations#available-locations | Vertex AI locations}
3047	* for a list of supported locations.
3048	*/
3049	constructor(location = DEFAULT_LOCATION) {
3050		super(BackendType.VERTEX_AI);
3051		if (!location) this.location = DEFAULT_LOCATION;
3052		else this.location = location;
3053	}
3054};
3055/**
3056* @license
3057* Copyright 2024 Google LLC
3058*
3059* Licensed under the Apache License, Version 2.0 (the "License");
3060* you may not use this file except in compliance with the License.
3061* You may obtain a copy of the License at
3062*
3063*   http://www.apache.org/licenses/LICENSE-2.0
3064*
3065* Unless required by applicable law or agreed to in writing, software
3066* distributed under the License is distributed on an "AS IS" BASIS,
3067* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3068* See the License for the specific language governing permissions and
3069* limitations under the License.
3070*/
3071var AIService = class {
3072	constructor(app, backend, authProvider, appCheckProvider) {
3073		this.app = app;
3074		this.backend = backend;
3075		const appCheck = appCheckProvider === null || appCheckProvider === void 0 ? void 0 : appCheckProvider.getImmediate({ optional: true });
3076		this.auth = (authProvider === null || authProvider === void 0 ? void 0 : authProvider.getImmediate({ optional: true })) || null;
3077		this.appCheck = appCheck || null;
3078		if (backend instanceof VertexAIBackend) this.location = backend.location;
3079		else this.location = "";
3080	}
3081	_delete() {
3082		return Promise.resolve();
3083	}
3084};
3085/**
3086* @license
3087* Copyright 2024 Google LLC
3088*
3089* Licensed under the Apache License, Version 2.0 (the "License");
3090* you may not use this file except in compliance with the License.
3091* You may obtain a copy of the License at
3092*
3093*   http://www.apache.org/licenses/LICENSE-2.0
3094*
3095* Unless required by applicable law or agreed to in writing, software
3096* distributed under the License is distributed on an "AS IS" BASIS,
3097* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3098* See the License for the specific language governing permissions and
3099* limitations under the License.
3100*/
3101/**
3102* Error class for the Firebase AI SDK.
3103*
3104* @public
3105*/
3106var AIError = class AIError extends FirebaseError {
3107	/**
3108	* Constructs a new instance of the `AIError` class.
3109	*
3110	* @param code - The error code from {@link AIErrorCode}.
3111	* @param message - A human-readable message describing the error.
3112	* @param customErrorData - Optional error data.
3113	*/
3114	constructor(code, message, customErrorData) {
3115		const service = AI_TYPE;
3116		const fullMessage = `${service}: ${message} (${`${service}/${code}`})`;
3117		super(code, fullMessage);
3118		this.code = code;
3119		this.customErrorData = customErrorData;
3120		if (Error.captureStackTrace) Error.captureStackTrace(this, AIError);
3121		Object.setPrototypeOf(this, AIError.prototype);
3122		this.toString = () => fullMessage;
3123	}
3124};
3125/**
3126* @license
3127* Copyright 2025 Google LLC
3128*
3129* Licensed under the Apache License, Version 2.0 (the "License");
3130* you may not use this file except in compliance with the License.
3131* You may obtain a copy of the License at
3132*
3133*   http://www.apache.org/licenses/LICENSE-2.0
3134*
3135* Unless required by applicable law or agreed to in writing, software
3136* distributed under the License is distributed on an "AS IS" BASIS,
3137* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3138* See the License for the specific language governing permissions and
3139* limitations under the License.
3140*/
3141/**
3142* Encodes a {@link Backend} into a string that will be used to uniquely identify {@link AI}
3143* instances by backend type.
3144*
3145* @internal
3146*/
3147function encodeInstanceIdentifier(backend) {
3148	if (backend instanceof GoogleAIBackend) return `${AI_TYPE}/googleai`;
3149	else if (backend instanceof VertexAIBackend) return `${AI_TYPE}/vertexai/${backend.location}`;
3150	else throw new AIError("error", `Invalid backend: ${JSON.stringify(backend.backendType)}`);
3151}
3152/**
3153* Decodes an instance identifier string into a {@link Backend}.
3154*
3155* @internal
3156*/
3157function decodeInstanceIdentifier(instanceIdentifier) {
3158	const identifierParts = instanceIdentifier.split("/");
3159	if (identifierParts[0] !== AI_TYPE) throw new AIError("error", `Invalid instance identifier, unknown prefix '${identifierParts[0]}'`);
3160	switch (identifierParts[1]) {
3161		case "vertexai":
3162			const location = identifierParts[2];
3163			if (!location) throw new AIError("error", `Invalid instance identifier, unknown location '${instanceIdentifier}'`);
3164			return new VertexAIBackend(location);
3165		case "googleai": return new GoogleAIBackend();
3166		default: throw new AIError("error", `Invalid instance identifier string: '${instanceIdentifier}'`);
3167	}
3168}
3169/**
3170* @license
3171* Copyright 2025 Google LLC
3172*
3173* Licensed under the Apache License, Version 2.0 (the "License");
3174* you may not use this file except in compliance with the License.
3175* You may obtain a copy of the License at
3176*
3177*   http://www.apache.org/licenses/LICENSE-2.0
3178*
3179* Unless required by applicable law or agreed to in writing, software
3180* distributed under the License is distributed on an "AS IS" BASIS,
3181* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3182* See the License for the specific language governing permissions and
3183* limitations under the License.
3184*/
3185/**
3186* Base class for Firebase AI model APIs.
3187*
3188* Instances of this class are associated with a specific Firebase AI {@link Backend}
3189* and provide methods for interacting with the configured generative model.
3190*
3191* @public
3192*/
3193var AIModel = class AIModel {
3194	/**
3195	* Constructs a new instance of the {@link AIModel} class.
3196	*
3197	* This constructor should only be called from subclasses that provide
3198	* a model API.
3199	*
3200	* @param ai - an {@link AI} instance.
3201	* @param modelName - The name of the model being used. It can be in one of the following formats:
3202	* - `my-model` (short name, will resolve to `publishers/google/models/my-model`)
3203	* - `models/my-model` (will resolve to `publishers/google/models/my-model`)
3204	* - `publishers/my-publisher/models/my-model` (fully qualified model name)
3205	*
3206	* @throws If the `apiKey` or `projectId` fields are missing in your
3207	* Firebase config.
3208	*
3209	* @internal
3210	*/
3211	constructor(ai, modelName) {
3212		var _a, _b, _c, _d, _e, _f;
3213		if (!((_b = (_a = ai.app) === null || _a === void 0 ? void 0 : _a.options) === null || _b === void 0 ? void 0 : _b.apiKey)) throw new AIError("no-api-key", `The "apiKey" field is empty in the local Firebase config. Firebase AI requires this field to contain a valid API key.`);
3214		else if (!((_d = (_c = ai.app) === null || _c === void 0 ? void 0 : _c.options) === null || _d === void 0 ? void 0 : _d.projectId)) throw new AIError("no-project-id", `The "projectId" field is empty in the local Firebase config. Firebase AI requires this field to contain a valid project ID.`);
3215		else if (!((_f = (_e = ai.app) === null || _e === void 0 ? void 0 : _e.options) === null || _f === void 0 ? void 0 : _f.appId)) throw new AIError("no-app-id", `The "appId" field is empty in the local Firebase config. Firebase AI requires this field to contain a valid app ID.`);
3216		else {
3217			this._apiSettings = {
3218				apiKey: ai.app.options.apiKey,
3219				project: ai.app.options.projectId,
3220				appId: ai.app.options.appId,
3221				automaticDataCollectionEnabled: ai.app.automaticDataCollectionEnabled,
3222				location: ai.location,
3223				backend: ai.backend
3224			};
3225			if (_isFirebaseServerApp(ai.app) && ai.app.settings.appCheckToken) {
3226				const token = ai.app.settings.appCheckToken;
3227				this._apiSettings.getAppCheckToken = () => {
3228					return Promise.resolve({ token });
3229				};
3230			} else if (ai.appCheck) this._apiSettings.getAppCheckToken = () => ai.appCheck.getToken();
3231			if (ai.auth) this._apiSettings.getAuthToken = () => ai.auth.getToken();
3232			this.model = AIModel.normalizeModelName(modelName, this._apiSettings.backend.backendType);
3233		}
3234	}
3235	/**
3236	* Normalizes the given model name to a fully qualified model resource name.
3237	*
3238	* @param modelName - The model name to normalize.
3239	* @returns The fully qualified model resource name.
3240	*
3241	* @internal
3242	*/
3243	static normalizeModelName(modelName, backendType) {
3244		if (backendType === BackendType.GOOGLE_AI) return AIModel.normalizeGoogleAIModelName(modelName);
3245		else return AIModel.normalizeVertexAIModelName(modelName);
3246	}
3247	/**
3248	* @internal
3249	*/
3250	static normalizeGoogleAIModelName(modelName) {
3251		return `models/${modelName}`;
3252	}
3253	/**
3254	* @internal
3255	*/
3256	static normalizeVertexAIModelName(modelName) {
3257		let model;
3258		if (modelName.includes("/")) if (modelName.startsWith("models/")) model = `publishers/google/${modelName}`;
3259		else model = modelName;
3260		else model = `publishers/google/models/${modelName}`;
3261		return model;
3262	}
3263};
3264/**
3265* @license
3266* Copyright 2024 Google LLC
3267*
3268* Licensed under the Apache License, Version 2.0 (the "License");
3269* you may not use this file except in compliance with the License.
3270* You may obtain a copy of the License at
3271*
3272*   http://www.apache.org/licenses/LICENSE-2.0
3273*
3274* Unless required by applicable law or agreed to in writing, software
3275* distributed under the License is distributed on an "AS IS" BASIS,
3276* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3277* See the License for the specific language governing permissions and
3278* limitations under the License.
3279*/
3280var logger = new Logger("@firebase/vertexai");
3281/**
3282* @license
3283* Copyright 2024 Google LLC
3284*
3285* Licensed under the Apache License, Version 2.0 (the "License");
3286* you may not use this file except in compliance with the License.
3287* You may obtain a copy of the License at
3288*
3289*   http://www.apache.org/licenses/LICENSE-2.0
3290*
3291* Unless required by applicable law or agreed to in writing, software
3292* distributed under the License is distributed on an "AS IS" BASIS,
3293* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3294* See the License for the specific language governing permissions and
3295* limitations under the License.
3296*/
3297var Task;
3298(function(Task) {
3299	Task["GENERATE_CONTENT"] = "generateContent";
3300	Task["STREAM_GENERATE_CONTENT"] = "streamGenerateContent";
3301	Task["COUNT_TOKENS"] = "countTokens";
3302	Task["PREDICT"] = "predict";
3303})(Task || (Task = {}));
3304var RequestUrl = class {
3305	constructor(model, task, apiSettings, stream, requestOptions) {
3306		this.model = model;
3307		this.task = task;
3308		this.apiSettings = apiSettings;
3309		this.stream = stream;
3310		this.requestOptions = requestOptions;
3311	}
3312	toString() {
3313		const url = new URL(this.baseUrl);
3314		url.pathname = `/${this.apiVersion}/${this.modelPath}:${this.task}`;
3315		url.search = this.queryParams.toString();
3316		return url.toString();
3317	}
3318	get baseUrl() {
3319		var _a;
3320		return ((_a = this.requestOptions) === null || _a === void 0 ? void 0 : _a.baseUrl) || DEFAULT_BASE_URL;
3321	}
3322	get apiVersion() {
3323		return DEFAULT_API_VERSION;
3324	}
3325	get modelPath() {
3326		if (this.apiSettings.backend instanceof GoogleAIBackend) return `projects/${this.apiSettings.project}/${this.model}`;
3327		else if (this.apiSettings.backend instanceof VertexAIBackend) return `projects/${this.apiSettings.project}/locations/${this.apiSettings.backend.location}/${this.model}`;
3328		else throw new AIError("error", `Invalid backend: ${JSON.stringify(this.apiSettings.backend)}`);
3329	}
3330	get queryParams() {
3331		const params = new URLSearchParams();
3332		if (this.stream) params.set("alt", "sse");
3333		return params;
3334	}
3335};
3336/**
3337* Log language and "fire/version" to x-goog-api-client
3338*/
3339function getClientHeaders() {
3340	const loggingTags = [];
3341	loggingTags.push(`${LANGUAGE_TAG}/${PACKAGE_VERSION}`);
3342	loggingTags.push(`fire/${PACKAGE_VERSION}`);
3343	return loggingTags.join(" ");
3344}
3345async function getHeaders(url) {
3346	const headers = new Headers();
3347	headers.append("Content-Type", "application/json");
3348	headers.append("x-goog-api-client", getClientHeaders());
3349	headers.append("x-goog-api-key", url.apiSettings.apiKey);
3350	if (url.apiSettings.automaticDataCollectionEnabled) headers.append("X-Firebase-Appid", url.apiSettings.appId);
3351	if (url.apiSettings.getAppCheckToken) {
3352		const appCheckToken = await url.apiSettings.getAppCheckToken();
3353		if (appCheckToken) {
3354			headers.append("X-Firebase-AppCheck", appCheckToken.token);
3355			if (appCheckToken.error) logger.warn(`Unable to obtain a valid App Check token: ${appCheckToken.error.message}`);
3356		}
3357	}
3358	if (url.apiSettings.getAuthToken) {
3359		const authToken = await url.apiSettings.getAuthToken();
3360		if (authToken) headers.append("Authorization", `Firebase ${authToken.accessToken}`);
3361	}
3362	return headers;
3363}
3364async function constructRequest(model, task, apiSettings, stream, body, requestOptions) {
3365	const url = new RequestUrl(model, task, apiSettings, stream, requestOptions);
3366	return {
3367		url: url.toString(),
3368		fetchOptions: {
3369			method: "POST",
3370			headers: await getHeaders(url),
3371			body
3372		}
3373	};
3374}
3375async function makeRequest(model, task, apiSettings, stream, body, requestOptions) {
3376	const url = new RequestUrl(model, task, apiSettings, stream, requestOptions);
3377	let response;
3378	let fetchTimeoutId;
3379	try {
3380		const request = await constructRequest(model, task, apiSettings, stream, body, requestOptions);
3381		const timeoutMillis = (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeout) != null && requestOptions.timeout >= 0 ? requestOptions.timeout : DEFAULT_FETCH_TIMEOUT_MS;
3382		const abortController = new AbortController();
3383		fetchTimeoutId = setTimeout(() => abortController.abort(), timeoutMillis);
3384		request.fetchOptions.signal = abortController.signal;
3385		response = await fetch(request.url, request.fetchOptions);
3386		if (!response.ok) {
3387			let message = "";
3388			let errorDetails;
3389			try {
3390				const json = await response.json();
3391				message = json.error.message;
3392				if (json.error.details) {
3393					message += ` ${JSON.stringify(json.error.details)}`;
3394					errorDetails = json.error.details;
3395				}
3396			} catch (e) {}
3397			if (response.status === 403 && errorDetails.some((detail) => detail.reason === "SERVICE_DISABLED") && errorDetails.some((detail) => {
3398				var _a, _b;
3399				return (_b = (_a = detail.links) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.description.includes("Google developers console API activation");
3400			})) throw new AIError("api-not-enabled", `The Firebase AI SDK requires the Firebase AI API ('firebasevertexai.googleapis.com') to be enabled in your Firebase project. Enable this API by visiting the Firebase Console at https://console.firebase.google.com/project/${url.apiSettings.project}/genai/ and clicking "Get started". If you enabled this API recently, wait a few minutes for the action to propagate to our systems and then retry.`, {
3401				status: response.status,
3402				statusText: response.statusText,
3403				errorDetails
3404			});
3405			throw new AIError("fetch-error", `Error fetching from ${url}: [${response.status} ${response.statusText}] ${message}`, {
3406				status: response.status,
3407				statusText: response.statusText,
3408				errorDetails
3409			});
3410		}
3411	} catch (e) {
3412		let err = e;
3413		if (e.code !== "fetch-error" && e.code !== "api-not-enabled" && e instanceof Error) {
3414			err = new AIError("error", `Error fetching from ${url.toString()}: ${e.message}`);
3415			err.stack = e.stack;
3416		}
3417		throw err;
3418	} finally {
3419		if (fetchTimeoutId) clearTimeout(fetchTimeoutId);
3420	}
3421	return response;
3422}
3423/**
3424* @license
3425* Copyright 2024 Google LLC
3426*
3427* Licensed under the Apache License, Version 2.0 (the "License");
3428* you may not use this file except in compliance with the License.
3429* You may obtain a copy of the License at
3430*
3431*   http://www.apache.org/licenses/LICENSE-2.0
3432*
3433* Unless required by applicable law or agreed to in writing, software
3434* distributed under the License is distributed on an "AS IS" BASIS,
3435* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3436* See the License for the specific language governing permissions and
3437* limitations under the License.
3438*/
3439/**
3440* Creates an EnhancedGenerateContentResponse object that has helper functions and
3441* other modifications that improve usability.
3442*/
3443function createEnhancedContentResponse(response) {
3444	/**
3445	* The Vertex AI backend omits default values.
3446	* This causes the `index` property to be omitted from the first candidate in the
3447	* response, since it has index 0, and 0 is a default value.
3448	* See: https://github.com/firebase/firebase-js-sdk/issues/8566
3449	*/
3450	if (response.candidates && !response.candidates[0].hasOwnProperty("index")) response.candidates[0].index = 0;
3451	return addHelpers(response);
3452}
3453/**
3454* Adds convenience helper methods to a response object, including stream
3455* chunks (as long as each chunk is a complete GenerateContentResponse JSON).
3456*/
3457function addHelpers(response) {
3458	response.text = () => {
3459		if (response.candidates && response.candidates.length > 0) {
3460			if (response.candidates.length > 1) logger.warn(`This response had ${response.candidates.length} candidates. Returning text from the first candidate only. Access response.candidates directly to use the other candidates.`);
3461			if (hadBadFinishReason(response.candidates[0])) throw new AIError("response-error", `Response error: ${formatBlockErrorMessage(response)}. Response body stored in error.response`, { response });
3462			return getText(response);
3463		} else if (response.promptFeedback) throw new AIError("response-error", `Text not available. ${formatBlockErrorMessage(response)}`, { response });
3464		return "";
3465	};
3466	response.inlineDataParts = () => {
3467		if (response.candidates && response.candidates.length > 0) {
3468			if (response.candidates.length > 1) logger.warn(`This response had ${response.candidates.length} candidates. Returning data from the first candidate only. Access response.candidates directly to use the other candidates.`);
3469			if (hadBadFinishReason(response.candidates[0])) throw new AIError("response-error", `Response error: ${formatBlockErrorMessage(response)}. Response body stored in error.response`, { response });
3470			return getInlineDataParts(response);
3471		} else if (response.promptFeedback) throw new AIError("response-error", `Data not available. ${formatBlockErrorMessage(response)}`, { response });
3472	};
3473	response.functionCalls = () => {
3474		if (response.candidates && response.candidates.length > 0) {
3475			if (response.candidates.length > 1) logger.warn(`This response had ${response.candidates.length} candidates. Returning function calls from the first candidate only. Access response.candidates directly to use the other candidates.`);
3476			if (hadBadFinishReason(response.candidates[0])) throw new AIError("response-error", `Response error: ${formatBlockErrorMessage(response)}. Response body stored in error.response`, { response });
3477			return getFunctionCalls(response);
3478		} else if (response.promptFeedback) throw new AIError("response-error", `Function call not available. ${formatBlockErrorMessage(response)}`, { response });
3479	};
3480	return response;
3481}
3482/**
3483* Returns all text found in all parts of first candidate.
3484*/
3485function getText(response) {
3486	var _a, _b, _c, _d;
3487	const textStrings = [];
3488	if ((_b = (_a = response.candidates) === null || _a === void 0 ? void 0 : _a[0].content) === null || _b === void 0 ? void 0 : _b.parts) {
3489		for (const part of (_d = (_c = response.candidates) === null || _c === void 0 ? void 0 : _c[0].content) === null || _d === void 0 ? void 0 : _d.parts) if (part.text) textStrings.push(part.text);
3490	}
3491	if (textStrings.length > 0) return textStrings.join("");
3492	else return "";
3493}
3494/**
3495* Returns {@link FunctionCall}s associated with first candidate.
3496*/
3497function getFunctionCalls(response) {
3498	var _a, _b, _c, _d;
3499	const functionCalls = [];
3500	if ((_b = (_a = response.candidates) === null || _a === void 0 ? void 0 : _a[0].content) === null || _b === void 0 ? void 0 : _b.parts) {
3501		for (const part of (_d = (_c = response.candidates) === null || _c === void 0 ? void 0 : _c[0].content) === null || _d === void 0 ? void 0 : _d.parts) if (part.functionCall) functionCalls.push(part.functionCall);
3502	}
3503	if (functionCalls.length > 0) return functionCalls;
3504	else return;
3505}
3506/**
3507* Returns {@link InlineDataPart}s in the first candidate if present.
3508*
3509* @internal
3510*/
3511function getInlineDataParts(response) {
3512	var _a, _b, _c, _d;
3513	const data = [];
3514	if ((_b = (_a = response.candidates) === null || _a === void 0 ? void 0 : _a[0].content) === null || _b === void 0 ? void 0 : _b.parts) {
3515		for (const part of (_d = (_c = response.candidates) === null || _c === void 0 ? void 0 : _c[0].content) === null || _d === void 0 ? void 0 : _d.parts) if (part.inlineData) data.push(part);
3516	}
3517	if (data.length > 0) return data;
3518	else return;
3519}
3520var badFinishReasons = [FinishReason.RECITATION, FinishReason.SAFETY];
3521function hadBadFinishReason(candidate) {
3522	return !!candidate.finishReason && badFinishReasons.includes(candidate.finishReason);
3523}
3524function formatBlockErrorMessage(response) {
3525	var _a, _b, _c;
3526	let message = "";
3527	if ((!response.candidates || response.candidates.length === 0) && response.promptFeedback) {
3528		message += "Response was blocked";
3529		if ((_a = response.promptFeedback) === null || _a === void 0 ? void 0 : _a.blockReason) message += ` due to ${response.promptFeedback.blockReason}`;
3530		if ((_b = response.promptFeedback) === null || _b === void 0 ? void 0 : _b.blockReasonMessage) message += `: ${response.promptFeedback.blockReasonMessage}`;
3531	} else if ((_c = response.candidates) === null || _c === void 0 ? void 0 : _c[0]) {
3532		const firstCandidate = response.candidates[0];
3533		if (hadBadFinishReason(firstCandidate)) {
3534			message += `Candidate was blocked due to ${firstCandidate.finishReason}`;
3535			if (firstCandidate.finishMessage) message += `: ${firstCandidate.finishMessage}`;
3536		}
3537	}
3538	return message;
3539}
3540/**
3541* Convert a generic successful fetch response body to an Imagen response object
3542* that can be returned to the user. This converts the REST APIs response format to our
3543* APIs representation of a response.
3544*
3545* @internal
3546*/
3547async function handlePredictResponse(response) {
3548	var _a;
3549	const responseJson = await response.json();
3550	const images = [];
3551	let filteredReason = void 0;
3552	if (!responseJson.predictions || ((_a = responseJson.predictions) === null || _a === void 0 ? void 0 : _a.length) === 0) throw new AIError("response-error", "No predictions or filtered reason received from Vertex AI. Please report this issue with the full error details at https://github.com/firebase/firebase-js-sdk/issues.");
3553	for (const prediction of responseJson.predictions) if (prediction.raiFilteredReason) filteredReason = prediction.raiFilteredReason;
3554	else if (prediction.mimeType && prediction.bytesBase64Encoded) images.push({
3555		mimeType: prediction.mimeType,
3556		bytesBase64Encoded: prediction.bytesBase64Encoded
3557	});
3558	else if (prediction.mimeType && prediction.gcsUri) images.push({
3559		mimeType: prediction.mimeType,
3560		gcsURI: prediction.gcsUri
3561	});
3562	else throw new AIError("response-error", `Predictions array in response has missing properties. Response: ${JSON.stringify(responseJson)}`);
3563	return {
3564		images,
3565		filteredReason
3566	};
3567}
3568/**
3569* @license
3570* Copyright 2025 Google LLC
3571*
3572* Licensed under the Apache License, Version 2.0 (the "License");
3573* you may not use this file except in compliance with the License.
3574* You may obtain a copy of the License at
3575*
3576*   http://www.apache.org/licenses/LICENSE-2.0
3577*
3578* Unless required by applicable law or agreed to in writing, software
3579* distributed under the License is distributed on an "AS IS" BASIS,
3580* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3581* See the License for the specific language governing permissions and
3582* limitations under the License.
3583*/
3584/**
3585* This SDK supports both the Vertex AI Gemini API and the Gemini Developer API (using Google AI).
3586* The public API prioritizes the format used by the Vertex AI Gemini API.
3587* We avoid having two sets of types by translating requests and responses between the two API formats.
3588* This translation allows developers to switch between the Vertex AI Gemini API and the Gemini Developer API
3589* with minimal code changes.
3590*
3591* In here are functions that map requests and responses between the two API formats.
3592* Requests in the Vertex AI format are mapped to the Google AI format before being sent.
3593* Responses from the Google AI backend are mapped back to the Vertex AI format before being returned to the user.
3594*/
3595/**
3596* Maps a Vertex AI {@link GenerateContentRequest} to a format that can be sent to Google AI.
3597*
3598* @param generateContentRequest The {@link GenerateContentRequest} to map.
3599* @returns A {@link GenerateContentResponse} that conforms to the Google AI format.
3600*
3601* @throws If the request contains properties that are unsupported by Google AI.
3602*
3603* @internal
3604*/
3605function mapGenerateContentRequest(generateContentRequest) {
3606	var _a, _b;
3607	(_a = generateContentRequest.safetySettings) === null || _a === void 0 || _a.forEach((safetySetting) => {
3608		if (safetySetting.method) throw new AIError("unsupported", "SafetySetting.method is not supported in the the Gemini Developer API. Please remove this property.");
3609	});
3610	if ((_b = generateContentRequest.generationConfig) === null || _b === void 0 ? void 0 : _b.topK) {
3611		const roundedTopK = Math.round(generateContentRequest.generationConfig.topK);
3612		if (roundedTopK !== generateContentRequest.generationConfig.topK) {
3613			logger.warn("topK in GenerationConfig has been rounded to the nearest integer to match the format for requests to the Gemini Developer API.");
3614			generateContentRequest.generationConfig.topK = roundedTopK;
3615		}
3616	}
3617	return generateContentRequest;
3618}
3619/**
3620* Maps a {@link GenerateContentResponse} from Google AI to the format of the
3621* {@link GenerateContentResponse} that we get from VertexAI that is exposed in the public API.
3622*
3623* @param googleAIResponse The {@link GenerateContentResponse} from Google AI.
3624* @returns A {@link GenerateContentResponse} that conforms to the public API's format.
3625*
3626* @internal
3627*/
3628function mapGenerateContentResponse(googleAIResponse) {
3629	return {
3630		candidates: googleAIResponse.candidates ? mapGenerateContentCandidates(googleAIResponse.candidates) : void 0,
3631		prompt: googleAIResponse.promptFeedback ? mapPromptFeedback(googleAIResponse.promptFeedback) : void 0,
3632		usageMetadata: googleAIResponse.usageMetadata
3633	};
3634}
3635/**
3636* Maps a Vertex AI {@link CountTokensRequest} to a format that can be sent to Google AI.
3637*
3638* @param countTokensRequest The {@link CountTokensRequest} to map.
3639* @param model The model to count tokens with.
3640* @returns A {@link CountTokensRequest} that conforms to the Google AI format.
3641*
3642* @internal
3643*/
3644function mapCountTokensRequest(countTokensRequest, model) {
3645	return { generateContentRequest: Object.assign({ model }, countTokensRequest) };
3646}
3647/**
3648* Maps a Google AI {@link GoogleAIGenerateContentCandidate} to a format that conforms
3649* to the Vertex AI API format.
3650*
3651* @param candidates The {@link GoogleAIGenerateContentCandidate} to map.
3652* @returns A {@link GenerateContentCandidate} that conforms to the Vertex AI format.
3653*
3654* @throws If any {@link Part} in the candidates has a `videoMetadata` property.
3655*
3656* @internal
3657*/
3658function mapGenerateContentCandidates(candidates) {
3659	const mappedCandidates = [];
3660	let mappedSafetyRatings;
3661	if (mappedCandidates) candidates.forEach((candidate) => {
3662		var _a;
3663		let citationMetadata;
3664		if (candidate.citationMetadata) citationMetadata = { citations: candidate.citationMetadata.citationSources };
3665		if (candidate.safetyRatings) mappedSafetyRatings = candidate.safetyRatings.map((safetyRating) => {
3666			var _a, _b, _c;
3667			return Object.assign(Object.assign({}, safetyRating), {
3668				severity: (_a = safetyRating.severity) !== null && _a !== void 0 ? _a : HarmSeverity.HARM_SEVERITY_UNSUPPORTED,
3669				probabilityScore: (_b = safetyRating.probabilityScore) !== null && _b !== void 0 ? _b : 0,
3670				severityScore: (_c = safetyRating.severityScore) !== null && _c !== void 0 ? _c : 0
3671			});
3672		});
3673		if ((_a = candidate.content) === null || _a === void 0 ? void 0 : _a.parts.some((part) => part === null || part === void 0 ? void 0 : part.videoMetadata)) throw new AIError("unsupported", "Part.videoMetadata is not supported in the Gemini Developer API. Please remove this property.");
3674		const mappedCandidate = {
3675			index: candidate.index,
3676			content: candidate.content,
3677			finishReason: candidate.finishReason,
3678			finishMessage: candidate.finishMessage,
3679			safetyRatings: mappedSafetyRatings,
3680			citationMetadata,
3681			groundingMetadata: candidate.groundingMetadata
3682		};
3683		mappedCandidates.push(mappedCandidate);
3684	});
3685	return mappedCandidates;
3686}
3687function mapPromptFeedback(promptFeedback) {
3688	const mappedSafetyRatings = [];
3689	promptFeedback.safetyRatings.forEach((safetyRating) => {
3690		var _a, _b, _c;
3691		mappedSafetyRatings.push({
3692			category: safetyRating.category,
3693			probability: safetyRating.probability,
3694			severity: (_a = safetyRating.severity) !== null && _a !== void 0 ? _a : HarmSeverity.HARM_SEVERITY_UNSUPPORTED,
3695			probabilityScore: (_b = safetyRating.probabilityScore) !== null && _b !== void 0 ? _b : 0,
3696			severityScore: (_c = safetyRating.severityScore) !== null && _c !== void 0 ? _c : 0,
3697			blocked: safetyRating.blocked
3698		});
3699	});
3700	return {
3701		blockReason: promptFeedback.blockReason,
3702		safetyRatings: mappedSafetyRatings,
3703		blockReasonMessage: promptFeedback.blockReasonMessage
3704	};
3705}
3706/**
3707* @license
3708* Copyright 2024 Google LLC
3709*
3710* Licensed under the Apache License, Version 2.0 (the "License");
3711* you may not use this file except in compliance with the License.
3712* You may obtain a copy of the License at
3713*
3714*   http://www.apache.org/licenses/LICENSE-2.0
3715*
3716* Unless required by applicable law or agreed to in writing, software
3717* distributed under the License is distributed on an "AS IS" BASIS,
3718* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3719* See the License for the specific language governing permissions and
3720* limitations under the License.
3721*/
3722var responseLineRE = /^data\: (.*)(?:\n\n|\r\r|\r\n\r\n)/;
3723/**
3724* Process a response.body stream from the backend and return an
3725* iterator that provides one complete GenerateContentResponse at a time
3726* and a promise that resolves with a single aggregated
3727* GenerateContentResponse.
3728*
3729* @param response - Response from a fetch call
3730*/
3731function processStream(response, apiSettings) {
3732	const [stream1, stream2] = getResponseStream(response.body.pipeThrough(new TextDecoderStream("utf8", { fatal: true }))).tee();
3733	return {
3734		stream: generateResponseSequence(stream1, apiSettings),
3735		response: getResponsePromise(stream2, apiSettings)
3736	};
3737}
3738async function getResponsePromise(stream, apiSettings) {
3739	const allResponses = [];
3740	const reader = stream.getReader();
3741	while (true) {
3742		const { done, value } = await reader.read();
3743		if (done) {
3744			let generateContentResponse = aggregateResponses(allResponses);
3745			if (apiSettings.backend.backendType === BackendType.GOOGLE_AI) generateContentResponse = mapGenerateContentResponse(generateContentResponse);
3746			return createEnhancedContentResponse(generateContentResponse);
3747		}
3748		allResponses.push(value);
3749	}
3750}
3751function generateResponseSequence(stream, apiSettings) {
3752	return __asyncGenerator(this, arguments, function* generateResponseSequence_1() {
3753		const reader = stream.getReader();
3754		while (true) {
3755			const { value, done } = yield __await(reader.read());
3756			if (done) break;
3757			let enhancedResponse;
3758			if (apiSettings.backend.backendType === BackendType.GOOGLE_AI) enhancedResponse = createEnhancedContentResponse(mapGenerateContentResponse(value));
3759			else enhancedResponse = createEnhancedContentResponse(value);
3760			yield yield __await(enhancedResponse);
3761		}
3762	});
3763}
3764/**
3765* Reads a raw stream from the fetch response and join incomplete
3766* chunks, returning a new stream that provides a single complete
3767* GenerateContentResponse in each iteration.
3768*/
3769function getResponseStream(inputStream) {
3770	const reader = inputStream.getReader();
3771	return new ReadableStream({ start(controller) {
3772		let currentText = "";
3773		return pump();
3774		function pump() {
3775			return reader.read().then(({ value, done }) => {
3776				if (done) {
3777					if (currentText.trim()) {
3778						controller.error(new AIError("parse-failed", "Failed to parse stream"));
3779						return;
3780					}
3781					controller.close();
3782					return;
3783				}
3784				currentText += value;
3785				let match = currentText.match(responseLineRE);
3786				let parsedResponse;
3787				while (match) {
3788					try {
3789						parsedResponse = JSON.parse(match[1]);
3790					} catch (e) {
3791						controller.error(new AIError("parse-failed", `Error parsing JSON response: "${match[1]}`));
3792						return;
3793					}
3794					controller.enqueue(parsedResponse);
3795					currentText = currentText.substring(match[0].length);
3796					match = currentText.match(responseLineRE);
3797				}
3798				return pump();
3799			});
3800		}
3801	} });
3802}
3803/**
3804* Aggregates an array of `GenerateContentResponse`s into a single
3805* GenerateContentResponse.
3806*/
3807function aggregateResponses(responses) {
3808	const lastResponse = responses[responses.length - 1];
3809	const aggregatedResponse = { promptFeedback: lastResponse === null || lastResponse === void 0 ? void 0 : lastResponse.promptFeedback };
3810	for (const response of responses) if (response.candidates) for (const candidate of response.candidates) {
3811		const i = candidate.index || 0;
3812		if (!aggregatedResponse.candidates) aggregatedResponse.candidates = [];
3813		if (!aggregatedResponse.candidates[i]) aggregatedResponse.candidates[i] = { index: candidate.index };
3814		aggregatedResponse.candidates[i].citationMetadata = candidate.citationMetadata;
3815		aggregatedResponse.candidates[i].finishReason = candidate.finishReason;
3816		aggregatedResponse.candidates[i].finishMessage = candidate.finishMessage;
3817		aggregatedResponse.candidates[i].safetyRatings = candidate.safetyRatings;
3818		/**
3819		* Candidates should always have content and parts, but this handles
3820		* possible malformed responses.
3821		*/
3822		if (candidate.content && candidate.content.parts) {
3823			if (!aggregatedResponse.candidates[i].content) aggregatedResponse.candidates[i].content = {
3824				role: candidate.content.role || "user",
3825				parts: []
3826			};
3827			const newPart = {};
3828			for (const part of candidate.content.parts) {
3829				if (part.text !== void 0) {
3830					if (part.text === "") continue;
3831					newPart.text = part.text;
3832				}
3833				if (part.functionCall) newPart.functionCall = part.functionCall;
3834				if (Object.keys(newPart).length === 0) throw new AIError("invalid-content", "Part should have at least one property, but there are none. This is likely caused by a malformed response from the backend.");
3835				aggregatedResponse.candidates[i].content.parts.push(newPart);
3836			}
3837		}
3838	}
3839	return aggregatedResponse;
3840}
3841/**
3842* @license
3843* Copyright 2024 Google LLC
3844*
3845* Licensed under the Apache License, Version 2.0 (the "License");
3846* you may not use this file except in compliance with the License.
3847* You may obtain a copy of the License at
3848*
3849*   http://www.apache.org/licenses/LICENSE-2.0
3850*
3851* Unless required by applicable law or agreed to in writing, software
3852* distributed under the License is distributed on an "AS IS" BASIS,
3853* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3854* See the License for the specific language governing permissions and
3855* limitations under the License.
3856*/
3857async function generateContentStream(apiSettings, model, params, requestOptions) {
3858	if (apiSettings.backend.backendType === BackendType.GOOGLE_AI) params = mapGenerateContentRequest(params);
3859	return processStream(await makeRequest(model, Task.STREAM_GENERATE_CONTENT, apiSettings, true, JSON.stringify(params), requestOptions), apiSettings);
3860}
3861async function generateContent(apiSettings, model, params, requestOptions) {
3862	if (apiSettings.backend.backendType === BackendType.GOOGLE_AI) params = mapGenerateContentRequest(params);
3863	return { response: createEnhancedContentResponse(await processGenerateContentResponse(await makeRequest(model, Task.GENERATE_CONTENT, apiSettings, false, JSON.stringify(params), requestOptions), apiSettings)) };
3864}
3865async function processGenerateContentResponse(response, apiSettings) {
3866	const responseJson = await response.json();
3867	if (apiSettings.backend.backendType === BackendType.GOOGLE_AI) return mapGenerateContentResponse(responseJson);
3868	else return responseJson;
3869}
3870/**
3871* @license
3872* Copyright 2024 Google LLC
3873*
3874* Licensed under the Apache License, Version 2.0 (the "License");
3875* you may not use this file except in compliance with the License.
3876* You may obtain a copy of the License at
3877*
3878*   http://www.apache.org/licenses/LICENSE-2.0
3879*
3880* Unless required by applicable law or agreed to in writing, software
3881* distributed under the License is distributed on an "AS IS" BASIS,
3882* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3883* See the License for the specific language governing permissions and
3884* limitations under the License.
3885*/
3886function formatSystemInstruction(input) {
3887	if (input == null) return;
3888	else if (typeof input === "string") return {
3889		role: "system",
3890		parts: [{ text: input }]
3891	};
3892	else if (input.text) return {
3893		role: "system",
3894		parts: [input]
3895	};
3896	else if (input.parts) if (!input.role) return {
3897		role: "system",
3898		parts: input.parts
3899	};
3900	else return input;
3901}
3902function formatNewContent(request) {
3903	let newParts = [];
3904	if (typeof request === "string") newParts = [{ text: request }];
3905	else for (const partOrString of request) if (typeof partOrString === "string") newParts.push({ text: partOrString });
3906	else newParts.push(partOrString);
3907	return assignRoleToPartsAndValidateSendMessageRequest(newParts);
3908}
3909/**
3910* When multiple Part types (i.e. FunctionResponsePart and TextPart) are
3911* passed in a single Part array, we may need to assign different roles to each
3912* part. Currently only FunctionResponsePart requires a role other than 'user'.
3913* @private
3914* @param parts Array of parts to pass to the model
3915* @returns Array of content items
3916*/
3917function assignRoleToPartsAndValidateSendMessageRequest(parts) {
3918	const userContent = {
3919		role: "user",
3920		parts: []
3921	};
3922	const functionContent = {
3923		role: "function",
3924		parts: []
3925	};
3926	let hasUserContent = false;
3927	let hasFunctionContent = false;
3928	for (const part of parts) if ("functionResponse" in part) {
3929		functionContent.parts.push(part);
3930		hasFunctionContent = true;
3931	} else {
3932		userContent.parts.push(part);
3933		hasUserContent = true;
3934	}
3935	if (hasUserContent && hasFunctionContent) throw new AIError("invalid-content", "Within a single message, FunctionResponse cannot be mixed with other type of Part in the request for sending chat message.");
3936	if (!hasUserContent && !hasFunctionContent) throw new AIError("invalid-content", "No Content is provided for sending chat message.");
3937	if (hasUserContent) return userContent;
3938	return functionContent;
3939}
3940function formatGenerateContentInput(params) {
3941	let formattedRequest;
3942	if (params.contents) formattedRequest = params;
3943	else formattedRequest = { contents: [formatNewContent(params)] };
3944	if (params.systemInstruction) formattedRequest.systemInstruction = formatSystemInstruction(params.systemInstruction);
3945	return formattedRequest;
3946}
3947/**
3948* Convert the user-defined parameters in {@link ImagenGenerationParams} to the format
3949* that is expected from the REST API.
3950*
3951* @internal
3952*/
3953function createPredictRequestBody(prompt, { gcsURI, imageFormat, addWatermark, numberOfImages = 1, negativePrompt, aspectRatio, safetyFilterLevel, personFilterLevel }) {
3954	return {
3955		instances: [{ prompt }],
3956		parameters: {
3957			storageUri: gcsURI,
3958			negativePrompt,
3959			sampleCount: numberOfImages,
3960			aspectRatio,
3961			outputOptions: imageFormat,
3962			addWatermark,
3963			safetyFilterLevel,
3964			personGeneration: personFilterLevel,
3965			includeRaiReason: true
3966		}
3967	};
3968}
3969/**
3970* @license
3971* Copyright 2024 Google LLC
3972*
3973* Licensed under the Apache License, Version 2.0 (the "License");
3974* you may not use this file except in compliance with the License.
3975* You may obtain a copy of the License at
3976*
3977*   http://www.apache.org/licenses/LICENSE-2.0
3978*
3979* Unless required by applicable law or agreed to in writing, software
3980* distributed under the License is distributed on an "AS IS" BASIS,
3981* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3982* See the License for the specific language governing permissions and
3983* limitations under the License.
3984*/
3985var VALID_PART_FIELDS = [
3986	"text",
3987	"inlineData",
3988	"functionCall",
3989	"functionResponse"
3990];
3991var VALID_PARTS_PER_ROLE = {
3992	user: ["text", "inlineData"],
3993	function: ["functionResponse"],
3994	model: ["text", "functionCall"],
3995	system: ["text"]
3996};
3997var VALID_PREVIOUS_CONTENT_ROLES = {
3998	user: ["model"],
3999	function: ["model"],
4000	model: ["user", "function"],
4001	system: []
4002};
4003function validateChatHistory(history) {
4004	let prevContent = null;
4005	for (const currContent of history) {
4006		const { role, parts } = currContent;
4007		if (!prevContent && role !== "user") throw new AIError("invalid-content", `First Content should be with role 'user', got ${role}`);
4008		if (!POSSIBLE_ROLES.includes(role)) throw new AIError("invalid-content", `Each item should include role field. Got ${role} but valid roles are: ${JSON.stringify(POSSIBLE_ROLES)}`);
4009		if (!Array.isArray(parts)) throw new AIError("invalid-content", `Content should have 'parts' but property with an array of Parts`);
4010		if (parts.length === 0) throw new AIError("invalid-content", `Each Content should have at least one part`);
4011		const countFields = {
4012			text: 0,
4013			inlineData: 0,
4014			functionCall: 0,
4015			functionResponse: 0
4016		};
4017		for (const part of parts) for (const key of VALID_PART_FIELDS) if (key in part) countFields[key] += 1;
4018		const validParts = VALID_PARTS_PER_ROLE[role];
4019		for (const key of VALID_PART_FIELDS) if (!validParts.includes(key) && countFields[key] > 0) throw new AIError("invalid-content", `Content with role '${role}' can't contain '${key}' part`);
4020		if (prevContent) {
4021			if (!VALID_PREVIOUS_CONTENT_ROLES[role].includes(prevContent.role)) throw new AIError("invalid-content", `Content with role '${role}' can't follow '${prevContent.role}'. Valid previous roles: ${JSON.stringify(VALID_PREVIOUS_CONTENT_ROLES)}`);
4022		}
4023		prevContent = currContent;
4024	}
4025}
4026/**
4027* @license
4028* Copyright 2024 Google LLC
4029*
4030* Licensed under the Apache License, Version 2.0 (the "License");
4031* you may not use this file except in compliance with the License.
4032* You may obtain a copy of the License at
4033*
4034*   http://www.apache.org/licenses/LICENSE-2.0
4035*
4036* Unless required by applicable law or agreed to in writing, software
4037* distributed under the License is distributed on an "AS IS" BASIS,
4038* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4039* See the License for the specific language governing permissions and
4040* limitations under the License.
4041*/
4042/**
4043* Do not log a message for this error.
4044*/
4045var SILENT_ERROR = "SILENT_ERROR";
4046/**
4047* ChatSession class that enables sending chat messages and stores
4048* history of sent and received messages so far.
4049*
4050* @public
4051*/
4052var ChatSession = class {
4053	constructor(apiSettings, model, params, requestOptions) {
4054		this.model = model;
4055		this.params = params;
4056		this.requestOptions = requestOptions;
4057		this._history = [];
4058		this._sendPromise = Promise.resolve();
4059		this._apiSettings = apiSettings;
4060		if (params === null || params === void 0 ? void 0 : params.history) {
4061			validateChatHistory(params.history);
4062			this._history = params.history;
4063		}
4064	}
4065	/**
4066	* Gets the chat history so far. Blocked prompts are not added to history.
4067	* Neither blocked candidates nor the prompts that generated them are added
4068	* to history.
4069	*/
4070	async getHistory() {
4071		await this._sendPromise;
4072		return this._history;
4073	}
4074	/**
4075	* Sends a chat message and receives a non-streaming
4076	* {@link GenerateContentResult}
4077	*/
4078	async sendMessage(request) {
4079		var _a, _b, _c, _d, _e;
4080		await this._sendPromise;
4081		const newContent = formatNewContent(request);
4082		const generateContentRequest = {
4083			safetySettings: (_a = this.params) === null || _a === void 0 ? void 0 : _a.safetySettings,
4084			generationConfig: (_b = this.params) === null || _b === void 0 ? void 0 : _b.generationConfig,
4085			tools: (_c = this.params) === null || _c === void 0 ? void 0 : _c.tools,
4086			toolConfig: (_d = this.params) === null || _d === void 0 ? void 0 : _d.toolConfig,
4087			systemInstruction: (_e = this.params) === null || _e === void 0 ? void 0 : _e.systemInstruction,
4088			contents: [...this._history, newContent]
4089		};
4090		let finalResult = {};
4091		this._sendPromise = this._sendPromise.then(() => generateContent(this._apiSettings, this.model, generateContentRequest, this.requestOptions)).then((result) => {
4092			var _a, _b;
4093			if (result.response.candidates && result.response.candidates.length > 0) {
4094				this._history.push(newContent);
4095				const responseContent = {
4096					parts: ((_a = result.response.candidates) === null || _a === void 0 ? void 0 : _a[0].content.parts) || [],
4097					role: ((_b = result.response.candidates) === null || _b === void 0 ? void 0 : _b[0].content.role) || "model"
4098				};
4099				this._history.push(responseContent);
4100			} else {
4101				const blockErrorMessage = formatBlockErrorMessage(result.response);
4102				if (blockErrorMessage) logger.warn(`sendMessage() was unsuccessful. ${blockErrorMessage}. Inspect response object for details.`);
4103			}
4104			finalResult = result;
4105		});
4106		await this._sendPromise;
4107		return finalResult;
4108	}
4109	/**
4110	* Sends a chat message and receives the response as a
4111	* {@link GenerateContentStreamResult} containing an iterable stream
4112	* and a response promise.
4113	*/
4114	async sendMessageStream(request) {
4115		var _a, _b, _c, _d, _e;
4116		await this._sendPromise;
4117		const newContent = formatNewContent(request);
4118		const generateContentRequest = {
4119			safetySettings: (_a = this.params) === null || _a === void 0 ? void 0 : _a.safetySettings,
4120			generationConfig: (_b = this.params) === null || _b === void 0 ? void 0 : _b.generationConfig,
4121			tools: (_c = this.params) === null || _c === void 0 ? void 0 : _c.tools,
4122			toolConfig: (_d = this.params) === null || _d === void 0 ? void 0 : _d.toolConfig,
4123			systemInstruction: (_e = this.params) === null || _e === void 0 ? void 0 : _e.systemInstruction,
4124			contents: [...this._history, newContent]
4125		};
4126		const streamPromise = generateContentStream(this._apiSettings, this.model, generateContentRequest, this.requestOptions);
4127		this._sendPromise = this._sendPromise.then(() => streamPromise).catch((_ignored) => {
4128			throw new Error(SILENT_ERROR);
4129		}).then((streamResult) => streamResult.response).then((response) => {
4130			if (response.candidates && response.candidates.length > 0) {
4131				this._history.push(newContent);
4132				const responseContent = Object.assign({}, response.candidates[0].content);
4133				if (!responseContent.role) responseContent.role = "model";
4134				this._history.push(responseContent);
4135			} else {
4136				const blockErrorMessage = formatBlockErrorMessage(response);
4137				if (blockErrorMessage) logger.warn(`sendMessageStream() was unsuccessful. ${blockErrorMessage}. Inspect response object for details.`);
4138			}
4139		}).catch((e) => {
4140			if (e.message !== SILENT_ERROR) logger.error(e);
4141		});
4142		return streamPromise;
4143	}
4144};
4145/**
4146* @license
4147* Copyright 2024 Google LLC
4148*
4149* Licensed under the Apache License, Version 2.0 (the "License");
4150* you may not use this file except in compliance with the License.
4151* You may obtain a copy of the License at
4152*
4153*   http://www.apache.org/licenses/LICENSE-2.0
4154*
4155* Unless required by applicable law or agreed to in writing, software
4156* distributed under the License is distributed on an "AS IS" BASIS,
4157* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4158* See the License for the specific language governing permissions and
4159* limitations under the License.
4160*/
4161async function countTokens(apiSettings, model, params, requestOptions) {
4162	let body = "";
4163	if (apiSettings.backend.backendType === BackendType.GOOGLE_AI) {
4164		const mappedParams = mapCountTokensRequest(params, model);
4165		body = JSON.stringify(mappedParams);
4166	} else body = JSON.stringify(params);
4167	return (await makeRequest(model, Task.COUNT_TOKENS, apiSettings, false, body, requestOptions)).json();
4168}
4169/**
4170* @license
4171* Copyright 2024 Google LLC
4172*
4173* Licensed under the Apache License, Version 2.0 (the "License");
4174* you may not use this file except in compliance with the License.
4175* You may obtain a copy of the License at
4176*
4177*   http://www.apache.org/licenses/LICENSE-2.0
4178*
4179* Unless required by applicable law or agreed to in writing, software
4180* distributed under the License is distributed on an "AS IS" BASIS,
4181* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4182* See the License for the specific language governing permissions and
4183* limitations under the License.
4184*/
4185/**
4186* Class for generative model APIs.
4187* @public
4188*/
4189var GenerativeModel = class extends AIModel {
4190	constructor(ai, modelParams, requestOptions) {
4191		super(ai, modelParams.model);
4192		this.generationConfig = modelParams.generationConfig || {};
4193		this.safetySettings = modelParams.safetySettings || [];
4194		this.tools = modelParams.tools;
4195		this.toolConfig = modelParams.toolConfig;
4196		this.systemInstruction = formatSystemInstruction(modelParams.systemInstruction);
4197		this.requestOptions = requestOptions || {};
4198	}
4199	/**
4200	* Makes a single non-streaming call to the model
4201	* and returns an object containing a single {@link GenerateContentResponse}.
4202	*/
4203	async generateContent(request) {
4204		const formattedParams = formatGenerateContentInput(request);
4205		return generateContent(this._apiSettings, this.model, Object.assign({
4206			generationConfig: this.generationConfig,
4207			safetySettings: this.safetySettings,
4208			tools: this.tools,
4209			toolConfig: this.toolConfig,
4210			systemInstruction: this.systemInstruction
4211		}, formattedParams), this.requestOptions);
4212	}
4213	/**
4214	* Makes a single streaming call to the model
4215	* and returns an object containing an iterable stream that iterates
4216	* over all chunks in the streaming response as well as
4217	* a promise that returns the final aggregated response.
4218	*/
4219	async generateContentStream(request) {
4220		const formattedParams = formatGenerateContentInput(request);
4221		return generateContentStream(this._apiSettings, this.model, Object.assign({
4222			generationConfig: this.generationConfig,
4223			safetySettings: this.safetySettings,
4224			tools: this.tools,
4225			toolConfig: this.toolConfig,
4226			systemInstruction: this.systemInstruction
4227		}, formattedParams), this.requestOptions);
4228	}
4229	/**
4230	* Gets a new {@link ChatSession} instance which can be used for
4231	* multi-turn chats.
4232	*/
4233	startChat(startChatParams) {
4234		return new ChatSession(this._apiSettings, this.model, Object.assign({
4235			tools: this.tools,
4236			toolConfig: this.toolConfig,
4237			systemInstruction: this.systemInstruction,
4238			generationConfig: this.generationConfig,
4239			safetySettings: this.safetySettings
4240		}, startChatParams), this.requestOptions);
4241	}
4242	/**
4243	* Counts the tokens in the provided request.
4244	*/
4245	async countTokens(request) {
4246		const formattedParams = formatGenerateContentInput(request);
4247		return countTokens(this._apiSettings, this.model, formattedParams);
4248	}
4249};
4250/**
4251* @license
4252* Copyright 2025 Google LLC
4253*
4254* Licensed under the Apache License, Version 2.0 (the "License");
4255* you may not use this file except in compliance with the License.
4256* You may obtain a copy of the License at
4257*
4258*   http://www.apache.org/licenses/LICENSE-2.0
4259*
4260* Unless required by applicable law or agreed to in writing, software
4261* distributed under the License is distributed on an "AS IS" BASIS,
4262* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4263* See the License for the specific language governing permissions and
4264* limitations under the License.
4265*/
4266/**
4267* Class for Imagen model APIs.
4268*
4269* This class provides methods for generating images using the Imagen model.
4270*
4271* @example
4272* ```javascript
4273* const imagen = new ImagenModel(
4274*   ai,
4275*   {
4276*     model: 'imagen-3.0-generate-002'
4277*   }
4278* );
4279*
4280* const response = await imagen.generateImages('A photo of a cat');
4281* if (response.images.length > 0) {
4282*   console.log(response.images[0].bytesBase64Encoded);
4283* }
4284* ```
4285*
4286* @beta
4287*/
4288var ImagenModel = class extends AIModel {
4289	/**
4290	* Constructs a new instance of the {@link ImagenModel} class.
4291	*
4292	* @param ai - an {@link AI} instance.
4293	* @param modelParams - Parameters to use when making requests to Imagen.
4294	* @param requestOptions - Additional options to use when making requests.
4295	*
4296	* @throws If the `apiKey` or `projectId` fields are missing in your
4297	* Firebase config.
4298	*/
4299	constructor(ai, modelParams, requestOptions) {
4300		const { model, generationConfig, safetySettings } = modelParams;
4301		super(ai, model);
4302		this.requestOptions = requestOptions;
4303		this.generationConfig = generationConfig;
4304		this.safetySettings = safetySettings;
4305	}
4306	/**
4307	* Generates images using the Imagen model and returns them as
4308	* base64-encoded strings.
4309	*
4310	* @param prompt - A text prompt describing the image(s) to generate.
4311	* @returns A promise that resolves to an {@link ImagenGenerationResponse}
4312	* object containing the generated images.
4313	*
4314	* @throws If the request to generate images fails. This happens if the
4315	* prompt is blocked.
4316	*
4317	* @remarks
4318	* If the prompt was not blocked, but one or more of the generated images were filtered, the
4319	* returned object will have a `filteredReason` property.
4320	* If all images are filtered, the `images` array will be empty.
4321	*
4322	* @beta
4323	*/
4324	async generateImages(prompt) {
4325		const body = createPredictRequestBody(prompt, Object.assign(Object.assign({}, this.generationConfig), this.safetySettings));
4326		return handlePredictResponse(await makeRequest(this.model, Task.PREDICT, this._apiSettings, false, JSON.stringify(body), this.requestOptions));
4327	}
4328	/**
4329	* Generates images to Cloud Storage for Firebase using the Imagen model.
4330	*
4331	* @internal This method is temporarily internal.
4332	*
4333	* @param prompt - A text prompt describing the image(s) to generate.
4334	* @param gcsURI - The URI of file stored in a Cloud Storage for Firebase bucket.
4335	* This should be a directory. For example, `gs://my-bucket/my-directory/`.
4336	* @returns A promise that resolves to an {@link ImagenGenerationResponse}
4337	* object containing the URLs of the generated images.
4338	*
4339	* @throws If the request fails to generate images fails. This happens if
4340	* the prompt is blocked.
4341	*
4342	* @remarks
4343	* If the prompt was not blocked, but one or more of the generated images were filtered, the
4344	* returned object will have a `filteredReason` property.
4345	* If all images are filtered, the `images` array will be empty.
4346	*/
4347	async generateImagesGCS(prompt, gcsURI) {
4348		const body = createPredictRequestBody(prompt, Object.assign(Object.assign({ gcsURI }, this.generationConfig), this.safetySettings));
4349		return handlePredictResponse(await makeRequest(this.model, Task.PREDICT, this._apiSettings, false, JSON.stringify(body), this.requestOptions));
4350	}
4351};
4352/**
4353* @license
4354* Copyright 2024 Google LLC
4355*
4356* Licensed under the Apache License, Version 2.0 (the "License");
4357* you may not use this file except in compliance with the License.
4358* You may obtain a copy of the License at
4359*
4360*   http://www.apache.org/licenses/LICENSE-2.0
4361*
4362* Unless required by applicable law or agreed to in writing, software
4363* distributed under the License is distributed on an "AS IS" BASIS,
4364* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4365* See the License for the specific language governing permissions and
4366* limitations under the License.
4367*/
4368/**
4369* Parent class encompassing all Schema types, with static methods that
4370* allow building specific Schema types. This class can be converted with
4371* `JSON.stringify()` into a JSON string accepted by Vertex AI REST endpoints.
4372* (This string conversion is automatically done when calling SDK methods.)
4373* @public
4374*/
4375var Schema = class {
4376	constructor(schemaParams) {
4377		for (const paramKey in schemaParams) this[paramKey] = schemaParams[paramKey];
4378		this.type = schemaParams.type;
4379		this.nullable = schemaParams.hasOwnProperty("nullable") ? !!schemaParams.nullable : false;
4380	}
4381	/**
4382	* Defines how this Schema should be serialized as JSON.
4383	* See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#tojson_behavior
4384	* @internal
4385	*/
4386	toJSON() {
4387		const obj = { type: this.type };
4388		for (const prop in this) if (this.hasOwnProperty(prop) && this[prop] !== void 0) {
4389			if (prop !== "required" || this.type === SchemaType.OBJECT) obj[prop] = this[prop];
4390		}
4391		return obj;
4392	}
4393	static array(arrayParams) {
4394		return new ArraySchema(arrayParams, arrayParams.items);
4395	}
4396	static object(objectParams) {
4397		return new ObjectSchema(objectParams, objectParams.properties, objectParams.optionalProperties);
4398	}
4399	static string(stringParams) {
4400		return new StringSchema(stringParams);
4401	}
4402	static enumString(stringParams) {
4403		return new StringSchema(stringParams, stringParams.enum);
4404	}
4405	static integer(integerParams) {
4406		return new IntegerSchema(integerParams);
4407	}
4408	static number(numberParams) {
4409		return new NumberSchema(numberParams);
4410	}
4411	static boolean(booleanParams) {
4412		return new BooleanSchema(booleanParams);
4413	}
4414};
4415/**
4416* Schema class for "integer" types.
4417* @public
4418*/
4419var IntegerSchema = class extends Schema {
4420	constructor(schemaParams) {
4421		super(Object.assign({ type: SchemaType.INTEGER }, schemaParams));
4422	}
4423};
4424/**
4425* Schema class for "number" types.
4426* @public
4427*/
4428var NumberSchema = class extends Schema {
4429	constructor(schemaParams) {
4430		super(Object.assign({ type: SchemaType.NUMBER }, schemaParams));
4431	}
4432};
4433/**
4434* Schema class for "boolean" types.
4435* @public
4436*/
4437var BooleanSchema = class extends Schema {
4438	constructor(schemaParams) {
4439		super(Object.assign({ type: SchemaType.BOOLEAN }, schemaParams));
4440	}
4441};
4442/**
4443* Schema class for "string" types. Can be used with or without
4444* enum values.
4445* @public
4446*/
4447var StringSchema = class extends Schema {
4448	constructor(schemaParams, enumValues) {
4449		super(Object.assign({ type: SchemaType.STRING }, schemaParams));
4450		this.enum = enumValues;
4451	}
4452	/**
4453	* @internal
4454	*/
4455	toJSON() {
4456		const obj = super.toJSON();
4457		if (this.enum) obj["enum"] = this.enum;
4458		return obj;
4459	}
4460};
4461/**
4462* Schema class for "array" types.
4463* The `items` param should refer to the type of item that can be a member
4464* of the array.
4465* @public
4466*/
4467var ArraySchema = class extends Schema {
4468	constructor(schemaParams, items) {
4469		super(Object.assign({ type: SchemaType.ARRAY }, schemaParams));
4470		this.items = items;
4471	}
4472	/**
4473	* @internal
4474	*/
4475	toJSON() {
4476		const obj = super.toJSON();
4477		obj.items = this.items.toJSON();
4478		return obj;
4479	}
4480};
4481/**
4482* Schema class for "object" types.
4483* The `properties` param must be a map of `Schema` objects.
4484* @public
4485*/
4486var ObjectSchema = class extends Schema {
4487	constructor(schemaParams, properties, optionalProperties = []) {
4488		super(Object.assign({ type: SchemaType.OBJECT }, schemaParams));
4489		this.properties = properties;
4490		this.optionalProperties = optionalProperties;
4491	}
4492	/**
4493	* @internal
4494	*/
4495	toJSON() {
4496		const obj = super.toJSON();
4497		obj.properties = Object.assign({}, this.properties);
4498		const required = [];
4499		if (this.optionalProperties) {
4500			for (const propertyKey of this.optionalProperties) if (!this.properties.hasOwnProperty(propertyKey)) throw new AIError("invalid-schema", `Property "${propertyKey}" specified in "optionalProperties" does not exist.`);
4501		}
4502		for (const propertyKey in this.properties) if (this.properties.hasOwnProperty(propertyKey)) {
4503			obj.properties[propertyKey] = this.properties[propertyKey].toJSON();
4504			if (!this.optionalProperties.includes(propertyKey)) required.push(propertyKey);
4505		}
4506		if (required.length > 0) obj.required = required;
4507		delete obj.optionalProperties;
4508		return obj;
4509	}
4510};
4511/**
4512* @license
4513* Copyright 2025 Google LLC
4514*
4515* Licensed under the Apache License, Version 2.0 (the "License");
4516* you may not use this file except in compliance with the License.
4517* You may obtain a copy of the License at
4518*
4519*   http://www.apache.org/licenses/LICENSE-2.0
4520*
4521* Unless required by applicable law or agreed to in writing, software
4522* distributed under the License is distributed on an "AS IS" BASIS,
4523* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4524* See the License for the specific language governing permissions and
4525* limitations under the License.
4526*/
4527/**
4528* Defines the image format for images generated by Imagen.
4529*
4530* Use this class to specify the desired format (JPEG or PNG) and compression quality
4531* for images generated by Imagen. This is typically included as part of
4532* {@link ImagenModelParams}.
4533*
4534* @example
4535* ```javascript
4536* const imagenModelParams = {
4537*   // ... other ImagenModelParams
4538*   imageFormat: ImagenImageFormat.jpeg(75) // JPEG with a compression level of 75.
4539* }
4540* ```
4541*
4542* @beta
4543*/
4544var ImagenImageFormat = class {
4545	constructor() {
4546		this.mimeType = "image/png";
4547	}
4548	/**
4549	* Creates an {@link ImagenImageFormat} for a JPEG image.
4550	*
4551	* @param compressionQuality - The level of compression (a number between 0 and 100).
4552	* @returns An {@link ImagenImageFormat} object for a JPEG image.
4553	*
4554	* @beta
4555	*/
4556	static jpeg(compressionQuality) {
4557		if (compressionQuality && (compressionQuality < 0 || compressionQuality > 100)) logger.warn(`Invalid JPEG compression quality of ${compressionQuality} specified; the supported range is [0, 100].`);
4558		return {
4559			mimeType: "image/jpeg",
4560			compressionQuality
4561		};
4562	}
4563	/**
4564	* Creates an {@link ImagenImageFormat} for a PNG image.
4565	*
4566	* @returns An {@link ImagenImageFormat} object for a PNG image.
4567	*
4568	* @beta
4569	*/
4570	static png() {
4571		return { mimeType: "image/png" };
4572	}
4573};
4574/**
4575* @license
4576* Copyright 2024 Google LLC
4577*
4578* Licensed under the Apache License, Version 2.0 (the "License");
4579* you may not use this file except in compliance with the License.
4580* You may obtain a copy of the License at
4581*
4582*   http://www.apache.org/licenses/LICENSE-2.0
4583*
4584* Unless required by applicable law or agreed to in writing, software
4585* distributed under the License is distributed on an "AS IS" BASIS,
4586* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4587* See the License for the specific language governing permissions and
4588* limitations under the License.
4589*/
4590/**
4591* @deprecated Use the new {@link AIModel} instead. The Vertex AI in Firebase SDK has been
4592* replaced with the Firebase AI SDK to accommodate the evolving set of supported features and
4593* services. For migration details, see the {@link https://firebase.google.com/docs/vertex-ai/migrate-to-latest-sdk | migration guide}.
4594*
4595* Base class for Firebase AI model APIs.
4596*
4597* @public
4598*/
4599var VertexAIModel = AIModel;
4600/**
4601* @deprecated Use the new {@link AIError} instead. The Vertex AI in Firebase SDK has been
4602* replaced with the Firebase AI SDK to accommodate the evolving set of supported features and
4603* services. For migration details, see the {@link https://firebase.google.com/docs/vertex-ai/migrate-to-latest-sdk | migration guide}.
4604*
4605* Error class for the Firebase AI SDK.
4606*
4607* @public
4608*/
4609var VertexAIError = AIError;
4610/**
4611* @deprecated Use the new {@link getAI | getAI()} instead. The Vertex AI in Firebase SDK has been
4612* replaced with the Firebase AI SDK to accommodate the evolving set of supported features and
4613* services. For migration details, see the {@link https://firebase.google.com/docs/vertex-ai/migrate-to-latest-sdk | migration guide}.
4614*
4615* Returns a {@link VertexAI} instance for the given app, configured to use the
4616* Vertex AI Gemini API. This instance will be
4617* configured to use the Vertex AI Gemini API.
4618*
4619* @param app - The {@link @firebase/app#FirebaseApp} to use.
4620* @param options - Options to configure the Vertex AI instance, including the location.
4621*
4622* @public
4623*/
4624function getVertexAI(app = getApp(), options) {
4625	app = getModularInstance(app);
4626	const AIProvider = _getProvider(app, AI_TYPE);
4627	const identifier = encodeInstanceIdentifier(new VertexAIBackend(options === null || options === void 0 ? void 0 : options.location));
4628	return AIProvider.getImmediate({ identifier });
4629}
4630/**
4631* Returns the default {@link AI} instance that is associated with the provided
4632* {@link @firebase/app#FirebaseApp}. If no instance exists, initializes a new instance with the
4633* default settings.
4634*
4635* @example
4636* ```javascript
4637* const ai = getAI(app);
4638* ```
4639*
4640* @example
4641* ```javascript
4642* // Get an AI instance configured to use the Gemini Developer API (via Google AI).
4643* const ai = getAI(app, { backend: new GoogleAIBackend() });
4644* ```
4645*
4646* @example
4647* ```javascript
4648* // Get an AI instance configured to use the Vertex AI Gemini API.
4649* const ai = getAI(app, { backend: new VertexAIBackend() });
4650* ```
4651*
4652* @param app - The {@link @firebase/app#FirebaseApp} to use.
4653* @param options - {@link AIOptions} that configure the AI instance.
4654* @returns The default {@link AI} instance for the given {@link @firebase/app#FirebaseApp}.
4655*
4656* @public
4657*/
4658function getAI(app = getApp(), options = { backend: new GoogleAIBackend() }) {
4659	app = getModularInstance(app);
4660	const AIProvider = _getProvider(app, AI_TYPE);
4661	const identifier = encodeInstanceIdentifier(options.backend);
4662	return AIProvider.getImmediate({ identifier });
4663}
4664/**
4665* Returns a {@link GenerativeModel} class with methods for inference
4666* and other functionality.
4667*
4668* @public
4669*/
4670function getGenerativeModel(ai, modelParams, requestOptions) {
4671	if (!modelParams.model) throw new AIError("no-model", `Must provide a model name. Example: getGenerativeModel({ model: 'my-model-name' })`);
4672	return new GenerativeModel(ai, modelParams, requestOptions);
4673}
4674/**
4675* Returns an {@link ImagenModel} class with methods for using Imagen.
4676*
4677* Only Imagen 3 models (named `imagen-3.0-*`) are supported.
4678*
4679* @param ai - An {@link AI} instance.
4680* @param modelParams - Parameters to use when making Imagen requests.
4681* @param requestOptions - Additional options to use when making requests.
4682*
4683* @throws If the `apiKey` or `projectId` fields are missing in your
4684* Firebase config.
4685*
4686* @beta
4687*/
4688function getImagenModel(ai, modelParams, requestOptions) {
4689	if (!modelParams.model) throw new AIError("no-model", `Must provide a model name. Example: getImagenModel({ model: 'my-model-name' })`);
4690	return new ImagenModel(ai, modelParams, requestOptions);
4691}
4692/**
4693* The Firebase AI Web SDK.
4694*
4695* @packageDocumentation
4696*/
4697function registerAI() {
4698	_registerComponent(new Component(AI_TYPE, (container, { instanceIdentifier }) => {
4699		if (!instanceIdentifier) throw new AIError("error", "AIService instance identifier is undefined.");
4700		const backend = decodeInstanceIdentifier(instanceIdentifier);
4701		return new AIService(container.getProvider("app").getImmediate(), backend, container.getProvider("auth-internal"), container.getProvider("app-check-internal"));
4702	}, "PUBLIC").setMultipleInstances(true));
4703	registerVersion(name, version);
4704	registerVersion(name, version, "esm2017");
4705}
4706registerAI();
4707//#endregion
4708//#region node_modules/firebase/ai/dist/esm/index.esm.js
4709var index_esm_exports = /* @__PURE__ */ __exportAll({
4710	AIError: () => AIError,
4711	AIModel: () => AIModel,
4712	ArraySchema: () => ArraySchema,
4713	Backend: () => Backend,
4714	BackendType: () => BackendType,
4715	BlockReason: () => BlockReason,
4716	BooleanSchema: () => BooleanSchema,
4717	ChatSession: () => ChatSession,
4718	FinishReason: () => FinishReason,
4719	FunctionCallingMode: () => FunctionCallingMode,
4720	GenerativeModel: () => GenerativeModel,
4721	GoogleAIBackend: () => GoogleAIBackend,
4722	HarmBlockMethod: () => HarmBlockMethod,
4723	HarmBlockThreshold: () => HarmBlockThreshold,
4724	HarmCategory: () => HarmCategory,
4725	HarmProbability: () => HarmProbability,
4726	HarmSeverity: () => HarmSeverity,
4727	ImagenAspectRatio: () => ImagenAspectRatio,
4728	ImagenImageFormat: () => ImagenImageFormat,
4729	ImagenModel: () => ImagenModel,
4730	ImagenPersonFilterLevel: () => ImagenPersonFilterLevel,
4731	ImagenSafetyFilterLevel: () => ImagenSafetyFilterLevel,
4732	IntegerSchema: () => IntegerSchema,
4733	Modality: () => Modality,
4734	NumberSchema: () => NumberSchema,
4735	ObjectSchema: () => ObjectSchema,
4736	POSSIBLE_ROLES: () => POSSIBLE_ROLES,
4737	ResponseModality: () => ResponseModality,
4738	Schema: () => Schema,
4739	SchemaType: () => SchemaType,
4740	StringSchema: () => StringSchema,
4741	VertexAIBackend: () => VertexAIBackend,
4742	VertexAIError: () => VertexAIError,
4743	VertexAIModel: () => VertexAIModel,
4744	getAI: () => getAI,
4745	getGenerativeModel: () => getGenerativeModel,
4746	getImagenModel: () => getImagenModel,
4747	getVertexAI: () => getVertexAI
4748});
4749//#endregion
4750export { isCloudflareWorker as A, querystringDecode as B, getDefaultEmulatorHostnameAndPort as C, getUA as D, getModularInstance as E, isReactNative as F, isSafari as I, isSafariOrWebkit as L, isIE as M, isIndexedDBAvailable as N, isBrowserExtension as O, isMobileCordova as P, pingServer as R, getDefaultEmulatorHost as S, getGlobal as T, updateEmulatorBanner as V, base64Decode as _, _isFirebaseServerApp as a, deepEqual as b, getApp as c, registerVersion as d, LogLevel as f, FirebaseError as g, ErrorFactory as h, _getProvider as i, isEmpty as j, isCloudWorkstation as k, getApps as l, Component as m, __rest as n, _registerComponent as o, Logger as p, SDK_VERSION as r, _removeServiceInstance as s, index_esm_exports as t, initializeApp as u, createMockUserToken as v, getExperimentalSetting as w, extractQuerystring as x, createSubscribe as y, querystring as z };

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.