9remote 2.5.5 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +91 -172
- package/dist/assets/trayIcon.ico +0 -0
- package/dist/cli.cjs +102 -101
- package/dist/ptyDaemon.cjs +10 -9
- package/dist/server.cjs +307 -138
- package/dist/ui/agents/codex.svg +1 -1
- package/dist/ui/assets/index-CAvf0VPf.css +1 -0
- package/dist/ui/assets/index-EXcI2V_p.js +8 -0
- package/dist/ui/favicon.ico +0 -0
- package/dist/ui/index.html +12 -4
- package/dist/vendor/scrcpy-server-v3.1 +0 -0
- package/dist/web/404.html +1 -0
- package/dist/web/__next.__PAGE__.txt +9 -0
- package/dist/web/__next._full.txt +25 -0
- package/dist/web/__next._head.txt +6 -0
- package/dist/web/__next._index.txt +10 -0
- package/dist/web/__next._tree.txt +5 -0
- package/dist/web/_next/static/AUHtJgkYALYyNwHop9pgT/_buildManifest.js +1 -0
- package/dist/web/_next/static/AUHtJgkYALYyNwHop9pgT/_ssgManifest.js +1 -0
- package/dist/web/_next/static/chunks/0a7753a9.4cb02a98e2e453b9.js +1 -0
- package/dist/web/_next/static/chunks/1222.aa4f7f7f397533e9.js +1 -0
- package/dist/web/_next/static/chunks/1228.d291278320bca9ca.js +1 -0
- package/dist/web/_next/static/chunks/1243.f35c2e6494079e05.js +1 -0
- package/dist/web/_next/static/chunks/1311.8c6b8930e22ceea0.js +1 -0
- package/dist/web/_next/static/chunks/132.6032826021079bce.js +1 -0
- package/dist/web/_next/static/chunks/133.1106654a28b5afda.js +1 -0
- package/dist/web/_next/static/chunks/1385.086b560acb0d7a68.js +115 -0
- package/dist/web/_next/static/chunks/1642.cac26d30ac331cb4.js +1 -0
- package/dist/web/_next/static/chunks/1733.f06c240b3ef8a428.js +77 -0
- package/dist/web/_next/static/chunks/1750.f7ba3332b56a8e68.js +1 -0
- package/dist/web/_next/static/chunks/1763.28beedca593b5e19.js +138 -0
- package/dist/web/_next/static/chunks/179.b9e8f385bd414d1c.js +62 -0
- package/dist/web/_next/static/chunks/1838.7c8990f903e3524a.js +215 -0
- package/dist/web/_next/static/chunks/20154aaa.868648f838e03bf1.js +1 -0
- package/dist/web/_next/static/chunks/2038.640b672702093b24.js +1 -0
- package/dist/web/_next/static/chunks/2112.d72eefbdf81659b3.js +23 -0
- package/dist/web/_next/static/chunks/2125.61c6e4a3541e30ad.js +1 -0
- package/dist/web/_next/static/chunks/2129.61afb2f4ff59e46a.js +24 -0
- package/dist/web/_next/static/chunks/213.68ce1361aee3281a.js +1 -0
- package/dist/web/_next/static/chunks/2179.3f55be0b79e3cca7.js +1 -0
- package/dist/web/_next/static/chunks/2180.e6bad8186f52ff89.js +1 -0
- package/dist/web/_next/static/chunks/2264.0fc1474d26067a01.js +1 -0
- package/dist/web/_next/static/chunks/2376.ed6302a91a9de1ae.js +36 -0
- package/dist/web/_next/static/chunks/2545.3ff192a933baf11e.js +1 -0
- package/dist/web/_next/static/chunks/2620.d17f4fac0eec88a5.js +1 -0
- package/dist/web/_next/static/chunks/2847.d3124853ca727b78.js +1 -0
- package/dist/web/_next/static/chunks/2849.f2bcad51c68e44b5.js +1 -0
- package/dist/web/_next/static/chunks/3189.64c6546d621eec0b.js +1 -0
- package/dist/web/_next/static/chunks/3348-9ef29f9cedf6c0df.js +1 -0
- package/dist/web/_next/static/chunks/3429.436b229808b33e81.js +1 -0
- package/dist/web/_next/static/chunks/3514.9643e815d690f2fb.js +1 -0
- package/dist/web/_next/static/chunks/3552.8dd9a3d2c3bcef65.js +86 -0
- package/dist/web/_next/static/chunks/3606.b59e695fd05b4eb3.js +74 -0
- package/dist/web/_next/static/chunks/3692.8c6b8930e22ceea0.js +1 -0
- package/dist/web/_next/static/chunks/3736.4a5662ceeecc6acb.js +94 -0
- package/dist/web/_next/static/chunks/392.842b338137824bb8.js +1 -0
- package/dist/web/_next/static/chunks/3973-9b18bcd9afc0bcb4.js +1 -0
- package/dist/web/_next/static/chunks/3977.8cfd8dec4cb8e893.js +1 -0
- package/dist/web/_next/static/chunks/4090.441fa61655da9b38.js +1 -0
- package/dist/web/_next/static/chunks/4303.54c4aa0b89834fc6.js +1 -0
- package/dist/web/_next/static/chunks/4314.6bbd89507909cad1.js +1 -0
- package/dist/web/_next/static/chunks/4551.d0d6723cacfb90b9.js +226 -0
- package/dist/web/_next/static/chunks/4566.d8e009823b8647d1.js +90 -0
- package/dist/web/_next/static/chunks/4643.dbb152682d076617.js +1 -0
- package/dist/web/_next/static/chunks/4732-76a574510722b2c3.js +11 -0
- package/dist/web/_next/static/chunks/4924.3f5c77a103ac69a9.js +8 -0
- package/dist/web/_next/static/chunks/4930.42e564644c94a93b.js +1 -0
- package/dist/web/_next/static/chunks/5155.d7e8db52ab4c95e0.js +27 -0
- package/dist/web/_next/static/chunks/5158-267908d069475cdc.js +32 -0
- package/dist/web/_next/static/chunks/543.5636e97aa68eb9c8.js +41 -0
- package/dist/web/_next/static/chunks/5506.98304a1821200439.js +1 -0
- package/dist/web/_next/static/chunks/5622.5ead5e748ecedbd1.js +1 -0
- package/dist/web/_next/static/chunks/565f33a6-fd3410bd29f39fdf.js +1 -0
- package/dist/web/_next/static/chunks/5708.22b4531ceebf3eca.js +1 -0
- package/dist/web/_next/static/chunks/5804.ff72a927135eb74c.js +93 -0
- package/dist/web/_next/static/chunks/588.78e2528ff24df85c.js +287 -0
- package/dist/web/_next/static/chunks/6001.e5bcb28bb9ce6571.js +1 -0
- package/dist/web/_next/static/chunks/6075.a6b8434732056526.js +1 -0
- package/dist/web/_next/static/chunks/6180.82fa683aa16f21df.js +1 -0
- package/dist/web/_next/static/chunks/6274.a3795ca6dacb3d62.js +32 -0
- package/dist/web/_next/static/chunks/635-d6ae421935055337.js +1 -0
- package/dist/web/_next/static/chunks/6419.842467d9a877e770.js +1 -0
- package/dist/web/_next/static/chunks/6420.bfa7bc86d03dcefc.js +1 -0
- package/dist/web/_next/static/chunks/6552-145e634541b5b66c.js +1 -0
- package/dist/web/_next/static/chunks/6647.740ec32a32201eab.js +64 -0
- package/dist/web/_next/static/chunks/6730.88fc6f2ccc49496c.js +1 -0
- package/dist/web/_next/static/chunks/6739.82570eba0a02cb26.js +1 -0
- package/dist/web/_next/static/chunks/674.2b5ffad0676aedbe.js +1 -0
- package/dist/web/_next/static/chunks/6742.8e137138a5d1c9e1.js +1 -0
- package/dist/web/_next/static/chunks/6987.743a63813c6288ce.js +79 -0
- package/dist/web/_next/static/chunks/7202.dad90ce4a1d78f67.js +1 -0
- package/dist/web/_next/static/chunks/7233.0f252f6c1cce8058.js +1 -0
- package/dist/web/_next/static/chunks/7248.d89bf328a0dc1b4c.js +1 -0
- package/dist/web/_next/static/chunks/7263.6f224c3924155294.js +1 -0
- package/dist/web/_next/static/chunks/7341.6958eac888a96823.js +34 -0
- package/dist/web/_next/static/chunks/7424.c8c9f85c8ea65885.js +1 -0
- package/dist/web/_next/static/chunks/7507.1204ae29f46e3f01.js +1 -0
- package/dist/web/_next/static/chunks/7629-16de8d4154923623.js +1 -0
- package/dist/web/_next/static/chunks/7811.19082afa63eb73ba.js +1 -0
- package/dist/web/_next/static/chunks/7853.d01982fa0afc1ee2.js +24 -0
- package/dist/web/_next/static/chunks/7908.432ab9feeb9ae756.js +1 -0
- package/dist/web/_next/static/chunks/7960.3b1c77b882ba4bb1.js +1 -0
- package/dist/web/_next/static/chunks/7967.6c62be01fad1603c.js +1 -0
- package/dist/web/_next/static/chunks/7c89255b.f727562586fa21cc.js +153 -0
- package/dist/web/_next/static/chunks/8044.5f87392585c9f3e4.js +38 -0
- package/dist/web/_next/static/chunks/8054.feeb01b8acdb31d4.js +1 -0
- package/dist/web/_next/static/chunks/8115.68d46fb961c724e0.js +172 -0
- package/dist/web/_next/static/chunks/817.cd0f4d221eca4c8b.js +104 -0
- package/dist/web/_next/static/chunks/8334-0e9493cfa1547244.js +1 -0
- package/dist/web/_next/static/chunks/8467.f34d938a32d40325.js +1 -0
- package/dist/web/_next/static/chunks/8495.d6cea1be03635fa8.js +148 -0
- package/dist/web/_next/static/chunks/8516-b3694c9156666b12.js +152 -0
- package/dist/web/_next/static/chunks/8638.03c6480d4aaeb5b3.js +1 -0
- package/dist/web/_next/static/chunks/8716.1ad6febb58e8560e.js +1 -0
- package/dist/web/_next/static/chunks/8839.1ad64faf06fb4a33.js +1 -0
- package/dist/web/_next/static/chunks/8922-a9cee4a104876005.js +1 -0
- package/dist/web/_next/static/chunks/910.43be9c3be85c7fa0.js +21 -0
- package/dist/web/_next/static/chunks/925.7ef504ee39f11840.js +1 -0
- package/dist/web/_next/static/chunks/9259.f4337cbb56e2e0b6.js +1 -0
- package/dist/web/_next/static/chunks/9299.af2a95f6ece07482.js +1 -0
- package/dist/web/_next/static/chunks/9387.96263a2d1602a078.js +1 -0
- package/dist/web/_next/static/chunks/9568-0bfadca4fcb105aa.js +1 -0
- package/dist/web/_next/static/chunks/9641.f6f2982fc4b4735f.js +1 -0
- package/dist/web/_next/static/chunks/9675.be4a175f92aa2f26.js +1 -0
- package/dist/web/_next/static/chunks/9860.05fa134ae44699e0.js +1 -0
- package/dist/web/_next/static/chunks/9b87412a.d2cfae4121762dec.js +122 -0
- package/dist/web/_next/static/chunks/a012e9f0.7dbb2fe05ec0b816.js +82 -0
- package/dist/web/_next/static/chunks/a096f98a-5a93977f5f5de413.js +1 -0
- package/dist/web/_next/static/chunks/ab1da478.d051e56375dab6d8.js +1 -0
- package/dist/web/_next/static/chunks/adcd17ec-9a2791632136b67b.js +18 -0
- package/dist/web/_next/static/chunks/app/_global-error/page-5bd6526483106080.js +1 -0
- package/dist/web/_next/static/chunks/app/_not-found/page-877523282abd5a7c.js +1 -0
- package/dist/web/_next/static/chunks/app/admin/admins/page-0f20b93a1fbe900c.js +1 -0
- package/dist/web/_next/static/chunks/app/admin/login/page-dbcfb21ebbd0bb00.js +1 -0
- package/dist/web/_next/static/chunks/app/admin/modes/page-8f292692166b56fc.js +1 -0
- package/dist/web/_next/static/chunks/app/admin/ota/page-c9fe76f24ac08288.js +1 -0
- package/dist/web/_next/static/chunks/app/admin/page-622381f5dac39ddb.js +1 -0
- package/dist/web/_next/static/chunks/app/admin/turn/page-8f6b835a319f3fe3.js +1 -0
- package/dist/web/_next/static/chunks/app/dev/question/page-5fd80ae293617365.js +1 -0
- package/dist/web/_next/static/chunks/app/layout-341400810c81f67e.js +1 -0
- package/dist/web/_next/static/chunks/app/login/page-31786ee656da76b1.js +1 -0
- package/dist/web/_next/static/chunks/app/page-1cf39061b48db156.js +22 -0
- package/dist/web/_next/static/chunks/app/workspace/browse/page-5bd6526483106080.js +1 -0
- package/dist/web/_next/static/chunks/app/workspace/editor/page-5bd6526483106080.js +1 -0
- package/dist/web/_next/static/chunks/app/workspace/files/page-5bd6526483106080.js +1 -0
- package/dist/web/_next/static/chunks/app/workspace/git/page-5bd6526483106080.js +1 -0
- package/dist/web/_next/static/chunks/app/workspace/layout-5e8f95fbc4ebaa6b.js +14 -0
- package/dist/web/_next/static/chunks/app/workspace/mobile/page-5bd6526483106080.js +1 -0
- package/dist/web/_next/static/chunks/app/workspace/page-5bd6526483106080.js +1 -0
- package/dist/web/_next/static/chunks/app/workspace/remote/page-5bd6526483106080.js +1 -0
- package/dist/web/_next/static/chunks/app/workspace/terminal/[sessionId]/page-5bd6526483106080.js +1 -0
- package/dist/web/_next/static/chunks/app/workspace/workspaces/page-5bd6526483106080.js +1 -0
- package/dist/web/_next/static/chunks/bbfbfb6c.069db3c4cc981ed3.js +1 -0
- package/dist/web/_next/static/chunks/c7879cf7-0d16fce1674078f9.js +1 -0
- package/dist/web/_next/static/chunks/c7ea4e13.6153499d4c2fb1f2.js +1 -0
- package/dist/web/_next/static/chunks/cdcce140.7a440644c3dd52b8.js +1 -0
- package/dist/web/_next/static/chunks/da9a53d6.df25e193f1f5bcae.js +62 -0
- package/dist/web/_next/static/chunks/framework-42053c69543a55f9.js +1 -0
- package/dist/web/_next/static/chunks/main-255c95c36766ce86.js +5 -0
- package/dist/web/_next/static/chunks/main-app-1831d4f902c3fcb9.js +1 -0
- package/dist/web/_next/static/chunks/next/dist/client/components/builtin/app-error-5bd6526483106080.js +1 -0
- package/dist/web/_next/static/chunks/next/dist/client/components/builtin/forbidden-5bd6526483106080.js +1 -0
- package/dist/web/_next/static/chunks/next/dist/client/components/builtin/global-error-76800531999827bd.js +1 -0
- package/dist/web/_next/static/chunks/next/dist/client/components/builtin/not-found-5bd6526483106080.js +1 -0
- package/dist/web/_next/static/chunks/next/dist/client/components/builtin/unauthorized-5bd6526483106080.js +1 -0
- package/dist/web/_next/static/chunks/polyfills-42372ed130431b0a.js +1 -0
- package/dist/web/_next/static/chunks/webpack-c971919003362f96.js +1 -0
- package/dist/web/_next/static/css/56adcd4d72bf2d84.css +1 -0
- package/dist/web/_next/static/css/5c40e58137a11306.css +1 -0
- package/dist/web/_next/static/css/b496025c9cd768cc.css +1 -0
- package/dist/web/_next/static/media/013b72fa676f92e0-s.woff2 +0 -0
- package/dist/web/_next/static/media/22a5144ee8d83bca-s.p.woff2 +0 -0
- package/dist/web/_next/static/media/2b5b02fc7e511755-s.woff2 +0 -0
- package/dist/web/_next/static/media/65f03d54ccadf4a8-s.woff2 +0 -0
- package/dist/web/_next/static/media/7d4881bb7e1bf84d-s.p.woff2 +0 -0
- package/dist/web/_next/static/media/9766a7e9e2e0ad5a-s.woff2 +0 -0
- package/dist/web/_next/static/media/aa016aab0e6d1295-s.woff2 +0 -0
- package/dist/web/_next/static/media/b66cf8e69499582a-s.woff2 +0 -0
- package/dist/web/_next/static/media/b9408752a0c24fb9-s.woff2 +0 -0
- package/dist/web/_next/static/media/e038a29029a234f2-s.woff2 +0 -0
- package/dist/web/_next/static/media/f639721981034f88-s.woff2 +0 -0
- package/dist/web/_not-found/__next._full.txt +23 -0
- package/dist/web/_not-found/__next._head.txt +6 -0
- package/dist/web/_not-found/__next._index.txt +10 -0
- package/dist/web/_not-found/__next._not-found.__PAGE__.txt +5 -0
- package/dist/web/_not-found/__next._not-found.txt +5 -0
- package/dist/web/_not-found/__next._tree.txt +5 -0
- package/dist/web/_not-found.html +1 -0
- package/dist/web/_not-found.txt +23 -0
- package/dist/web/admin/__next._full.txt +27 -0
- package/dist/web/admin/__next._head.txt +6 -0
- package/dist/web/admin/__next._index.txt +10 -0
- package/dist/web/admin/__next._tree.txt +5 -0
- package/dist/web/admin/__next.admin.__PAGE__.txt +9 -0
- package/dist/web/admin/__next.admin.txt +5 -0
- package/dist/web/admin/admins/__next._full.txt +27 -0
- package/dist/web/admin/admins/__next._head.txt +6 -0
- package/dist/web/admin/admins/__next._index.txt +10 -0
- package/dist/web/admin/admins/__next._tree.txt +5 -0
- package/dist/web/admin/admins/__next.admin.admins.__PAGE__.txt +9 -0
- package/dist/web/admin/admins/__next.admin.admins.txt +5 -0
- package/dist/web/admin/admins/__next.admin.txt +5 -0
- package/dist/web/admin/admins.html +1 -0
- package/dist/web/admin/admins.txt +27 -0
- package/dist/web/admin/login/__next._full.txt +27 -0
- package/dist/web/admin/login/__next._head.txt +6 -0
- package/dist/web/admin/login/__next._index.txt +10 -0
- package/dist/web/admin/login/__next._tree.txt +5 -0
- package/dist/web/admin/login/__next.admin.login.__PAGE__.txt +9 -0
- package/dist/web/admin/login/__next.admin.login.txt +5 -0
- package/dist/web/admin/login/__next.admin.txt +5 -0
- package/dist/web/admin/login.html +1 -0
- package/dist/web/admin/login.txt +27 -0
- package/dist/web/admin/modes/__next._full.txt +27 -0
- package/dist/web/admin/modes/__next._head.txt +6 -0
- package/dist/web/admin/modes/__next._index.txt +10 -0
- package/dist/web/admin/modes/__next._tree.txt +5 -0
- package/dist/web/admin/modes/__next.admin.modes.__PAGE__.txt +9 -0
- package/dist/web/admin/modes/__next.admin.modes.txt +5 -0
- package/dist/web/admin/modes/__next.admin.txt +5 -0
- package/dist/web/admin/modes.html +1 -0
- package/dist/web/admin/modes.txt +27 -0
- package/dist/web/admin/ota/__next._full.txt +27 -0
- package/dist/web/admin/ota/__next._head.txt +6 -0
- package/dist/web/admin/ota/__next._index.txt +10 -0
- package/dist/web/admin/ota/__next._tree.txt +5 -0
- package/dist/web/admin/ota/__next.admin.ota.__PAGE__.txt +9 -0
- package/dist/web/admin/ota/__next.admin.ota.txt +5 -0
- package/dist/web/admin/ota/__next.admin.txt +5 -0
- package/dist/web/admin/ota.html +1 -0
- package/dist/web/admin/ota.txt +27 -0
- package/dist/web/admin/turn/__next._full.txt +27 -0
- package/dist/web/admin/turn/__next._head.txt +6 -0
- package/dist/web/admin/turn/__next._index.txt +10 -0
- package/dist/web/admin/turn/__next._tree.txt +5 -0
- package/dist/web/admin/turn/__next.admin.turn.__PAGE__.txt +9 -0
- package/dist/web/admin/turn/__next.admin.turn.txt +5 -0
- package/dist/web/admin/turn/__next.admin.txt +5 -0
- package/dist/web/admin/turn.html +1 -0
- package/dist/web/admin/turn.txt +27 -0
- package/dist/web/admin.html +1 -0
- package/dist/web/admin.txt +27 -0
- package/dist/web/agent-icons/aider.svg +1 -0
- package/dist/web/agent-icons/amp.png +0 -0
- package/dist/web/agent-icons/ante.png +0 -0
- package/dist/web/agent-icons/antigravity.png +0 -0
- package/dist/web/agent-icons/auggie.png +0 -0
- package/dist/web/agent-icons/autohand.png +0 -0
- package/dist/web/agent-icons/claude-ui.png +0 -0
- package/dist/web/agent-icons/claude.svg +1 -0
- package/dist/web/agent-icons/cline.png +0 -0
- package/dist/web/agent-icons/codebuff.png +0 -0
- package/dist/web/agent-icons/codex-ui.png +0 -0
- package/dist/web/agent-icons/codex.svg +1 -0
- package/dist/web/agent-icons/command-code.png +0 -0
- package/dist/web/agent-icons/continue.png +0 -0
- package/dist/web/agent-icons/copilot.png +0 -0
- package/dist/web/agent-icons/crush.png +0 -0
- package/dist/web/agent-icons/cursor.png +0 -0
- package/dist/web/agent-icons/devin.png +0 -0
- package/dist/web/agent-icons/droid.png +0 -0
- package/dist/web/agent-icons/gemini.png +0 -0
- package/dist/web/agent-icons/goose.png +0 -0
- package/dist/web/agent-icons/grok.png +0 -0
- package/dist/web/agent-icons/hermes.png +0 -0
- package/dist/web/agent-icons/kilo.png +0 -0
- package/dist/web/agent-icons/kimi.png +0 -0
- package/dist/web/agent-icons/kiro.png +0 -0
- package/dist/web/agent-icons/mimo-code.png +0 -0
- package/dist/web/agent-icons/mistral-vibe.png +0 -0
- package/dist/web/agent-icons/omp.svg +1 -0
- package/dist/web/agent-icons/openclaude.png +0 -0
- package/dist/web/agent-icons/openclaw.png +0 -0
- package/dist/web/agent-icons/opencode.png +0 -0
- package/dist/web/agent-icons/pi.svg +1 -0
- package/dist/web/agent-icons/prime-agent.png +0 -0
- package/dist/web/agent-icons/qwen-code.png +0 -0
- package/dist/web/agent-icons/rovo.png +0 -0
- package/dist/web/agent-icons/trae.png +0 -0
- package/dist/web/agents/claude.svg +1 -0
- package/dist/web/agents/codex.svg +1 -0
- package/dist/web/agents/gemini.svg +1 -0
- package/dist/web/agents/opencode.svg +1 -0
- package/dist/web/backgrounds/bg10.jpg +0 -0
- package/dist/web/backgrounds/bg11.jpg +0 -0
- package/dist/web/backgrounds/bg12.jpg +0 -0
- package/dist/web/backgrounds/bg13.jpg +0 -0
- package/dist/web/backgrounds/bg2.jpg +0 -0
- package/dist/web/backgrounds/bg3.jpg +0 -0
- package/dist/web/backgrounds/bg4.jpg +0 -0
- package/dist/web/backgrounds/bg5.jpg +0 -0
- package/dist/web/backgrounds/bg6.jpg +0 -0
- package/dist/web/backgrounds/bg7.jpg +0 -0
- package/dist/web/backgrounds/bg8.jpg +0 -0
- package/dist/web/backgrounds/bg9.jpg +0 -0
- package/dist/web/dev/question/__next._full.txt +27 -0
- package/dist/web/dev/question/__next._head.txt +6 -0
- package/dist/web/dev/question/__next._index.txt +10 -0
- package/dist/web/dev/question/__next._tree.txt +5 -0
- package/dist/web/dev/question/__next.dev.question.__PAGE__.txt +9 -0
- package/dist/web/dev/question/__next.dev.question.txt +5 -0
- package/dist/web/dev/question/__next.dev.txt +5 -0
- package/dist/web/dev/question.html +1 -0
- package/dist/web/dev/question.txt +27 -0
- package/dist/web/favicon.ico +0 -0
- package/dist/web/file.svg +1 -0
- package/dist/web/globe.svg +1 -0
- package/dist/web/icon-192.png +0 -0
- package/dist/web/icon-192.svg +3 -0
- package/dist/web/icon-512.png +0 -0
- package/dist/web/icon-512.svg +3 -0
- package/dist/web/icons/file-types/astro.svg +1 -0
- package/dist/web/icons/file-types/audio.svg +1 -0
- package/dist/web/icons/file-types/avif.svg +1 -0
- package/dist/web/icons/file-types/bat.svg +1 -0
- package/dist/web/icons/file-types/c.svg +1 -0
- package/dist/web/icons/file-types/cheader.svg +1 -0
- package/dist/web/icons/file-types/clojure.svg +1 -0
- package/dist/web/icons/file-types/clojurescript.svg +1 -0
- package/dist/web/icons/file-types/cloudfoundry.svg +1 -0
- package/dist/web/icons/file-types/cpp.svg +1 -0
- package/dist/web/icons/file-types/cppheader.svg +1 -0
- package/dist/web/icons/file-types/csharp.svg +1 -0
- package/dist/web/icons/file-types/css.svg +1 -0
- package/dist/web/icons/file-types/dartlang.svg +1 -0
- package/dist/web/icons/file-types/datadog.svg +1 -0
- package/dist/web/icons/file-types/default.svg +1 -0
- package/dist/web/icons/file-types/diff.svg +1 -0
- package/dist/web/icons/file-types/django.svg +1 -0
- package/dist/web/icons/file-types/docker.svg +1 -0
- package/dist/web/icons/file-types/dotenv.svg +1 -0
- package/dist/web/icons/file-types/editorconfig.svg +1 -0
- package/dist/web/icons/file-types/elixir.svg +1 -0
- package/dist/web/icons/file-types/erlang.svg +1 -0
- package/dist/web/icons/file-types/esphome.svg +1 -0
- package/dist/web/icons/file-types/font.svg +1 -0
- package/dist/web/icons/file-types/git.svg +1 -0
- package/dist/web/icons/file-types/gnu.svg +1 -0
- package/dist/web/icons/file-types/go.svg +1 -0
- package/dist/web/icons/file-types/graphql.svg +1 -0
- package/dist/web/icons/file-types/haskell.svg +1 -0
- package/dist/web/icons/file-types/html.svg +1 -0
- package/dist/web/icons/file-types/image.svg +1 -0
- package/dist/web/icons/file-types/ini.svg +1 -0
- package/dist/web/icons/file-types/janet.svg +1 -0
- package/dist/web/icons/file-types/jar.svg +1 -0
- package/dist/web/icons/file-types/java.svg +1 -0
- package/dist/web/icons/file-types/js.svg +1 -0
- package/dist/web/icons/file-types/json.svg +1 -0
- package/dist/web/icons/file-types/json5.svg +1 -0
- package/dist/web/icons/file-types/kotlin.svg +1 -0
- package/dist/web/icons/file-types/less.svg +1 -0
- package/dist/web/icons/file-types/license.svg +1 -0
- package/dist/web/icons/file-types/locale.svg +1 -0
- package/dist/web/icons/file-types/log.svg +1 -0
- package/dist/web/icons/file-types/lua.svg +1 -0
- package/dist/web/icons/file-types/markdown.svg +1 -0
- package/dist/web/icons/file-types/mdx.svg +1 -0
- package/dist/web/icons/file-types/npm.svg +1 -0
- package/dist/web/icons/file-types/objectivec.svg +1 -0
- package/dist/web/icons/file-types/ocaml.svg +1 -0
- package/dist/web/icons/file-types/parcel.svg +1 -0
- package/dist/web/icons/file-types/pddl_happenings.svg +1 -0
- package/dist/web/icons/file-types/pdf.svg +1 -0
- package/dist/web/icons/file-types/php.svg +1 -0
- package/dist/web/icons/file-types/powershell.svg +1 -0
- package/dist/web/icons/file-types/protobuf.svg +1 -0
- package/dist/web/icons/file-types/python.svg +1 -0
- package/dist/web/icons/file-types/r.svg +1 -0
- package/dist/web/icons/file-types/reactjs.svg +1 -0
- package/dist/web/icons/file-types/reactts.svg +1 -0
- package/dist/web/icons/file-types/ruby.svg +1 -0
- package/dist/web/icons/file-types/rust.svg +1 -0
- package/dist/web/icons/file-types/sass.svg +1 -0
- package/dist/web/icons/file-types/scala.svg +1 -0
- package/dist/web/icons/file-types/scss.svg +1 -0
- package/dist/web/icons/file-types/shell.svg +1 -0
- package/dist/web/icons/file-types/sql.svg +1 -0
- package/dist/web/icons/file-types/sqlite.svg +1 -0
- package/dist/web/icons/file-types/stylus.svg +1 -0
- package/dist/web/icons/file-types/svelte.svg +1 -0
- package/dist/web/icons/file-types/svg.svg +1 -0
- package/dist/web/icons/file-types/swift.svg +1 -0
- package/dist/web/icons/file-types/text.svg +1 -0
- package/dist/web/icons/file-types/toml.svg +1 -0
- package/dist/web/icons/file-types/typescript.svg +1 -0
- package/dist/web/icons/file-types/video.svg +1 -0
- package/dist/web/icons/file-types/vue.svg +1 -0
- package/dist/web/icons/file-types/xml.svg +1 -0
- package/dist/web/icons/file-types/yaml.svg +1 -0
- package/dist/web/icons/file-types/zip.svg +1 -0
- package/dist/web/icons/folder-types/android-open.svg +1 -0
- package/dist/web/icons/folder-types/android.svg +1 -0
- package/dist/web/icons/folder-types/api-open.svg +1 -0
- package/dist/web/icons/folder-types/api.svg +1 -0
- package/dist/web/icons/folder-types/app-open.svg +1 -0
- package/dist/web/icons/folder-types/app.svg +1 -0
- package/dist/web/icons/folder-types/asset-open.svg +1 -0
- package/dist/web/icons/folder-types/asset.svg +1 -0
- package/dist/web/icons/folder-types/azurepipelines-open.svg +1 -0
- package/dist/web/icons/folder-types/azurepipelines.svg +1 -0
- package/dist/web/icons/folder-types/blueprint-open.svg +1 -0
- package/dist/web/icons/folder-types/blueprint.svg +1 -0
- package/dist/web/icons/folder-types/bower-open.svg +1 -0
- package/dist/web/icons/folder-types/bower.svg +1 -0
- package/dist/web/icons/folder-types/component-open.svg +1 -0
- package/dist/web/icons/folder-types/component.svg +1 -0
- package/dist/web/icons/folder-types/config-open.svg +1 -0
- package/dist/web/icons/folder-types/config.svg +1 -0
- package/dist/web/icons/folder-types/controller-open.svg +1 -0
- package/dist/web/icons/folder-types/controller.svg +1 -0
- package/dist/web/icons/folder-types/css-open.svg +1 -0
- package/dist/web/icons/folder-types/css.svg +1 -0
- package/dist/web/icons/folder-types/db-open.svg +1 -0
- package/dist/web/icons/folder-types/db.svg +1 -0
- package/dist/web/icons/folder-types/default-open.svg +1 -0
- package/dist/web/icons/folder-types/default.svg +1 -0
- package/dist/web/icons/folder-types/dist-open.svg +1 -0
- package/dist/web/icons/folder-types/dist.svg +1 -0
- package/dist/web/icons/folder-types/docs-open.svg +1 -0
- package/dist/web/icons/folder-types/docs.svg +1 -0
- package/dist/web/icons/folder-types/fonts-open.svg +1 -0
- package/dist/web/icons/folder-types/fonts.svg +1 -0
- package/dist/web/icons/folder-types/git-open.svg +1 -0
- package/dist/web/icons/folder-types/git.svg +1 -0
- package/dist/web/icons/folder-types/github-open.svg +1 -0
- package/dist/web/icons/folder-types/github.svg +1 -0
- package/dist/web/icons/folder-types/helper-open.svg +1 -0
- package/dist/web/icons/folder-types/helper.svg +1 -0
- package/dist/web/icons/folder-types/hook-open.svg +1 -0
- package/dist/web/icons/folder-types/hook.svg +1 -0
- package/dist/web/icons/folder-types/husky-open.svg +1 -0
- package/dist/web/icons/folder-types/husky.svg +1 -0
- package/dist/web/icons/folder-types/idea-open.svg +1 -0
- package/dist/web/icons/folder-types/idea.svg +1 -0
- package/dist/web/icons/folder-types/images-open.svg +1 -0
- package/dist/web/icons/folder-types/images.svg +1 -0
- package/dist/web/icons/folder-types/interfaces-open.svg +1 -0
- package/dist/web/icons/folder-types/interfaces.svg +1 -0
- package/dist/web/icons/folder-types/ios-open.svg +1 -0
- package/dist/web/icons/folder-types/ios.svg +1 -0
- package/dist/web/icons/folder-types/library-open.svg +1 -0
- package/dist/web/icons/folder-types/library.svg +1 -0
- package/dist/web/icons/folder-types/locale-open.svg +1 -0
- package/dist/web/icons/folder-types/locale.svg +1 -0
- package/dist/web/icons/folder-types/middleware-open.svg +1 -0
- package/dist/web/icons/folder-types/middleware.svg +1 -0
- package/dist/web/icons/folder-types/model-open.svg +1 -0
- package/dist/web/icons/folder-types/model.svg +1 -0
- package/dist/web/icons/folder-types/node-open.svg +1 -0
- package/dist/web/icons/folder-types/node.svg +1 -0
- package/dist/web/icons/folder-types/public-open.svg +1 -0
- package/dist/web/icons/folder-types/public.svg +1 -0
- package/dist/web/icons/folder-types/redux-open.svg +1 -0
- package/dist/web/icons/folder-types/redux.svg +1 -0
- package/dist/web/icons/folder-types/route-open.svg +1 -0
- package/dist/web/icons/folder-types/route.svg +1 -0
- package/dist/web/icons/folder-types/script-open.svg +1 -0
- package/dist/web/icons/folder-types/script.svg +1 -0
- package/dist/web/icons/folder-types/seedkit-open.svg +1 -0
- package/dist/web/icons/folder-types/seedkit.svg +1 -0
- package/dist/web/icons/folder-types/server-open.svg +1 -0
- package/dist/web/icons/folder-types/server.svg +1 -0
- package/dist/web/icons/folder-types/services-open.svg +1 -0
- package/dist/web/icons/folder-types/services.svg +1 -0
- package/dist/web/icons/folder-types/src-open.svg +1 -0
- package/dist/web/icons/folder-types/src.svg +1 -0
- package/dist/web/icons/folder-types/story-open.svg +1 -0
- package/dist/web/icons/folder-types/story.svg +1 -0
- package/dist/web/icons/folder-types/style-open.svg +1 -0
- package/dist/web/icons/folder-types/style.svg +1 -0
- package/dist/web/icons/folder-types/template-open.svg +1 -0
- package/dist/web/icons/folder-types/template.svg +1 -0
- package/dist/web/icons/folder-types/test-open.svg +1 -0
- package/dist/web/icons/folder-types/test.svg +1 -0
- package/dist/web/icons/folder-types/theme-open.svg +1 -0
- package/dist/web/icons/folder-types/theme.svg +1 -0
- package/dist/web/icons/folder-types/tools-open.svg +1 -0
- package/dist/web/icons/folder-types/tools.svg +1 -0
- package/dist/web/icons/folder-types/typescript-open.svg +1 -0
- package/dist/web/icons/folder-types/typescript.svg +1 -0
- package/dist/web/icons/folder-types/typings-open.svg +1 -0
- package/dist/web/icons/folder-types/typings.svg +1 -0
- package/dist/web/icons/folder-types/view-open.svg +1 -0
- package/dist/web/icons/folder-types/view.svg +1 -0
- package/dist/web/icons/folder-types/vscode-open.svg +1 -0
- package/dist/web/icons/folder-types/vscode.svg +1 -0
- package/dist/web/index.html +1 -0
- package/dist/web/index.txt +25 -0
- package/dist/web/login/__next._full.txt +27 -0
- package/dist/web/login/__next._head.txt +6 -0
- package/dist/web/login/__next._index.txt +10 -0
- package/dist/web/login/__next._tree.txt +5 -0
- package/dist/web/login/__next.login.__PAGE__.txt +9 -0
- package/dist/web/login/__next.login.txt +5 -0
- package/dist/web/login.html +1 -0
- package/dist/web/login.txt +27 -0
- package/dist/web/manifest.json +53 -0
- package/dist/web/maskable-192.png +0 -0
- package/dist/web/maskable-512.png +0 -0
- package/dist/web/next.svg +1 -0
- package/dist/web/proxy.html +179 -0
- package/dist/web/screenshot-desktop.png +0 -0
- package/dist/web/screenshot-mobile.png +0 -0
- package/dist/web/screenshots/desktop-ide.webp +0 -0
- package/dist/web/screenshots/mobile-1.webp +0 -0
- package/dist/web/screenshots/mobile-2.webp +0 -0
- package/dist/web/screenshots/mobile-3.webp +0 -0
- package/dist/web/sw-site.js +283 -0
- package/dist/web/sw.js +88 -0
- package/dist/web/swBridgeClaim.js +57 -0
- package/dist/web/vercel.svg +1 -0
- package/dist/web/window.svg +1 -0
- package/dist/web/workspace/__next._full.txt +25 -0
- package/dist/web/workspace/__next._head.txt +6 -0
- package/dist/web/workspace/__next._index.txt +10 -0
- package/dist/web/workspace/__next._tree.txt +6 -0
- package/dist/web/workspace/__next.workspace.__PAGE__.txt +5 -0
- package/dist/web/workspace/__next.workspace.txt +8 -0
- package/dist/web/workspace/browse/__next._full.txt +27 -0
- package/dist/web/workspace/browse/__next._head.txt +6 -0
- package/dist/web/workspace/browse/__next._index.txt +10 -0
- package/dist/web/workspace/browse/__next._tree.txt +6 -0
- package/dist/web/workspace/browse/__next.workspace.browse.__PAGE__.txt +5 -0
- package/dist/web/workspace/browse/__next.workspace.browse.txt +5 -0
- package/dist/web/workspace/browse/__next.workspace.txt +8 -0
- package/dist/web/workspace/browse.html +1 -0
- package/dist/web/workspace/browse.txt +27 -0
- package/dist/web/workspace/editor/__next._full.txt +27 -0
- package/dist/web/workspace/editor/__next._head.txt +6 -0
- package/dist/web/workspace/editor/__next._index.txt +10 -0
- package/dist/web/workspace/editor/__next._tree.txt +6 -0
- package/dist/web/workspace/editor/__next.workspace.editor.__PAGE__.txt +5 -0
- package/dist/web/workspace/editor/__next.workspace.editor.txt +5 -0
- package/dist/web/workspace/editor/__next.workspace.txt +8 -0
- package/dist/web/workspace/editor.html +1 -0
- package/dist/web/workspace/editor.txt +27 -0
- package/dist/web/workspace/files/__next._full.txt +27 -0
- package/dist/web/workspace/files/__next._head.txt +6 -0
- package/dist/web/workspace/files/__next._index.txt +10 -0
- package/dist/web/workspace/files/__next._tree.txt +6 -0
- package/dist/web/workspace/files/__next.workspace.files.__PAGE__.txt +5 -0
- package/dist/web/workspace/files/__next.workspace.files.txt +5 -0
- package/dist/web/workspace/files/__next.workspace.txt +8 -0
- package/dist/web/workspace/files.html +1 -0
- package/dist/web/workspace/files.txt +27 -0
- package/dist/web/workspace/git/__next._full.txt +27 -0
- package/dist/web/workspace/git/__next._head.txt +6 -0
- package/dist/web/workspace/git/__next._index.txt +10 -0
- package/dist/web/workspace/git/__next._tree.txt +6 -0
- package/dist/web/workspace/git/__next.workspace.git.__PAGE__.txt +5 -0
- package/dist/web/workspace/git/__next.workspace.git.txt +5 -0
- package/dist/web/workspace/git/__next.workspace.txt +8 -0
- package/dist/web/workspace/git.html +1 -0
- package/dist/web/workspace/git.txt +27 -0
- package/dist/web/workspace/mobile/__next._full.txt +27 -0
- package/dist/web/workspace/mobile/__next._head.txt +6 -0
- package/dist/web/workspace/mobile/__next._index.txt +10 -0
- package/dist/web/workspace/mobile/__next._tree.txt +6 -0
- package/dist/web/workspace/mobile/__next.workspace.mobile.__PAGE__.txt +5 -0
- package/dist/web/workspace/mobile/__next.workspace.mobile.txt +5 -0
- package/dist/web/workspace/mobile/__next.workspace.txt +8 -0
- package/dist/web/workspace/mobile.html +1 -0
- package/dist/web/workspace/mobile.txt +27 -0
- package/dist/web/workspace/remote/__next._full.txt +27 -0
- package/dist/web/workspace/remote/__next._head.txt +6 -0
- package/dist/web/workspace/remote/__next._index.txt +10 -0
- package/dist/web/workspace/remote/__next._tree.txt +6 -0
- package/dist/web/workspace/remote/__next.workspace.remote.__PAGE__.txt +5 -0
- package/dist/web/workspace/remote/__next.workspace.remote.txt +5 -0
- package/dist/web/workspace/remote/__next.workspace.txt +8 -0
- package/dist/web/workspace/remote.html +1 -0
- package/dist/web/workspace/remote.txt +27 -0
- package/dist/web/workspace/terminal/default/__next._full.txt +27 -0
- package/dist/web/workspace/terminal/default/__next._head.txt +6 -0
- package/dist/web/workspace/terminal/default/__next._index.txt +10 -0
- package/dist/web/workspace/terminal/default/__next._tree.txt +6 -0
- package/dist/web/workspace/terminal/default/__next.workspace.terminal.$d$sessionId.__PAGE__.txt +5 -0
- package/dist/web/workspace/terminal/default/__next.workspace.terminal.$d$sessionId.txt +5 -0
- package/dist/web/workspace/terminal/default/__next.workspace.terminal.txt +5 -0
- package/dist/web/workspace/terminal/default/__next.workspace.txt +8 -0
- package/dist/web/workspace/terminal/default.html +1 -0
- package/dist/web/workspace/terminal/default.txt +27 -0
- package/dist/web/workspace/workspaces/__next._full.txt +27 -0
- package/dist/web/workspace/workspaces/__next._head.txt +6 -0
- package/dist/web/workspace/workspaces/__next._index.txt +10 -0
- package/dist/web/workspace/workspaces/__next._tree.txt +6 -0
- package/dist/web/workspace/workspaces/__next.workspace.txt +8 -0
- package/dist/web/workspace/workspaces/__next.workspace.workspaces.__PAGE__.txt +5 -0
- package/dist/web/workspace/workspaces/__next.workspace.workspaces.txt +5 -0
- package/dist/web/workspace/workspaces.html +1 -0
- package/dist/web/workspace/workspaces.txt +27 -0
- package/dist/web/workspace.html +1 -0
- package/dist/web/workspace.txt +25 -0
- package/package.json +4 -4
- package/dist/ui/assets/index-CLABbREo.css +0 -1
- package/dist/ui/assets/index-MX08IV5-.js +0 -58
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1226],{10913:(e,t,n)=>{let i,r,o;n.r(t),n.d(t,{ActivityHandling:()=>tL,AdapterSize:()=>e7,AggregationMetric:()=>to,ApiError:()=>iJ,ApiSpec:()=>eU,AspectRatio:()=>e8,AudioResponseFormat:()=>nv,AudioTranscriptionConfigMode:()=>tH,AuthType:()=>eM,Batches:()=>iM,Behavior:()=>eH,BlockedReason:()=>eQ,Caches:()=>ix,CancelTuningJobResponse:()=>nG,Chat:()=>iV,Chats:()=>iX,ComputeTokensResponse:()=>nO,ContentReferenceImage:()=>n4,ControlReferenceImage:()=>nQ,ControlReferenceType:()=>tA,CountTokensResponse:()=>nS,CreateFileResponse:()=>nB,DeleteCachedContentResponse:()=>nk,DeleteFileResponse:()=>nX,DeleteModelResponse:()=>ny,Delivery:()=>e3,DocumentState:()=>tp,DynamicRetrievalConfigMode:()=>eF,EditImageResponse:()=>nf,EditMode:()=>tT,EmbedContentResponse:()=>nc,EmbeddingApiType:()=>t_,EndSensitivity:()=>tx,Environment:()=>ex,EvaluateDatasetResponse:()=>nw,FeatureSelectionPreference:()=>tg,FileSource:()=>tw,FileState:()=>tN,Files:()=>iY,FinishReason:()=>eK,FunctionCallingConfigMode:()=>e$,FunctionResponse:()=>t8,FunctionResponseBlob:()=>t4,FunctionResponseFileData:()=>t1,FunctionResponsePart:()=>t2,FunctionResponseScheduling:()=>eD,GenerateContentResponse:()=>nd,GenerateContentResponsePromptFeedback:()=>nu,GenerateContentResponseUsageMetadata:()=>np,GenerateImagesResponse:()=>nm,GenerateVideosOperation:()=>nP,GenerateVideosResponse:()=>nb,GoogleGenAI:()=>sv,HarmBlockMethod:()=>eJ,HarmBlockThreshold:()=>eY,HarmCategory:()=>eV,HarmProbability:()=>eW,HarmSeverity:()=>ez,HttpElementLocation:()=>ek,HttpResponse:()=>na,ImagePromptLanguage:()=>ty,ImageResizeMode:()=>tP,ImageResponseFormat:()=>nA,ImageSize:()=>e9,ImportFileOperation:()=>nF,ImportFileResponse:()=>nH,InlinedEmbedContentResponse:()=>n$,InlinedResponse:()=>nJ,InteractionStatus:()=>tG,JobState:()=>ti,Language:()=>ew,ListBatchJobsResponse:()=>nK,ListCachedContentsResponse:()=>nU,ListDocumentsResponse:()=>nx,ListFileSearchStoresResponse:()=>nL,ListFilesResponse:()=>nj,ListModelsResponse:()=>nE,ListTuningJobsResponse:()=>nD,Live:()=>rv,LiveClientToolResponse:()=>n5,LiveMusicPlaybackControl:()=>tB,LiveMusicServerMessage:()=>n8,LiveSendToolResponseParameters:()=>n3,LiveServerMessage:()=>n2,MaskReferenceImage:()=>nZ,MaskReferenceMode:()=>tv,MatchOperation:()=>tt,MediaModality:()=>e1,MediaProcessing:()=>tc,MediaResolution:()=>e2,Modality:()=>e5,ModelStage:()=>e4,Models:()=>rb,MusicGenerationMode:()=>tj,Operations:()=>rP,Outcome:()=>eN,PagedItem:()=>tX,Pager:()=>iG,PairwiseChoice:()=>tl,PartMediaResolutionLevel:()=>tm,PersonGeneration:()=>eB,PhishBlockThreshold:()=>eq,ProminentPeople:()=>eX,RawReferenceImage:()=>nz,RecontextImageResponse:()=>ng,RegisterFilesResponse:()=>nV,ReinforcementTuningAutoraterScorerParsedResponseConversionScorer:()=>nN,ReinforcementTuningParseResponseConfig:()=>nR,ReinforcementTuningThinkingLevel:()=>tn,ReplayResponse:()=>nW,ResourceScope:()=>th,ResponseFormat:()=>nC,ResponseParseType:()=>te,SafetyFilterLevel:()=>tE,SafetyPolicy:()=>eL,Scale:()=>tF,SegmentImageResponse:()=>n_,SegmentMode:()=>tC,ServiceTier:()=>td,Session:()=>rI,SingleEmbedContentResponse:()=>nY,StartSensitivity:()=>tU,StyleReferenceImage:()=>n0,SubjectReferenceImage:()=>n1,SubjectReferenceType:()=>tI,TextResponseFormat:()=>nI,ThinkingLevel:()=>ej,Tokens:()=>rR,ToolResponse:()=>t0,ToolType:()=>tf,TrafficType:()=>e0,TuningJobState:()=>tr,TuningMethod:()=>tR,TuningMode:()=>e6,TuningSpeed:()=>ta,TuningTask:()=>tu,TurnCompleteReason:()=>tD,TurnCoverage:()=>tq,Type:()=>eG,UploadToFileSearchStoreOperation:()=>n6,UploadToFileSearchStoreResponse:()=>n9,UploadToFileSearchStoreResumableResponse:()=>nq,UpscaleImageResponse:()=>nh,UrlRetrievalStatus:()=>eZ,VadSignalType:()=>tM,ValidateRewardResponse:()=>nM,VideoCompressionQuality:()=>tb,VideoGenerationMaskMode:()=>tO,VideoGenerationReferenceType:()=>tS,VideoOrientation:()=>ts,VideoResponseFormat:()=>nT,VoiceActivityType:()=>tk,createFunctionResponsePartFromBase64:()=>t5,createFunctionResponsePartFromUri:()=>t3,createModelContent:()=>ns,createPartFromBase64:()=>nt,createPartFromCodeExecutionResult:()=>nn,createPartFromExecutableCode:()=>ni,createPartFromFunctionCall:()=>t7,createPartFromFunctionResponse:()=>ne,createPartFromText:()=>t6,createPartFromUri:()=>t9,createUserContent:()=>nl,mcpToTool:()=>rh,setDefaultBaseUrls:()=>tY});var l,s,a,u,p,d,c,m,f,h,g,_,E,y,v,A,I,T,C,S,O,b,P,R,N,w,D,G,M,k,U,x,L,q,H,F,j,B,X,V,J,Y,$,K,W,z,Z,Q,ee,et,en,ei,er,eo,el,es,ea,eu,ep,ed,ec,em,ef,eh,eg,e_,eE,ey,ev,eA,eI,eT,eC,eS,eO,eb,eP,eR,eN,ew,eD,eG,eM,ek,eU,ex,eL,eq,eH,eF,ej,eB,eX,eV,eJ,eY,e$,eK,eW,ez,eZ,eQ,e0,e1,e4,e2,e5,e3,e8,e9,e6,e7,te,tt,tn,ti,tr,to,tl,ts,ta,tu,tp,td,tc,tm,tf,th,tg,t_,tE,ty,tv,tA,tI,tT,tC,tS,tO,tb,tP,tR,tN,tw,tD,tG,tM,tk,tU,tx,tL,tq,tH,tF,tj,tB,tX,tV,tJ=n(82847);function tY(e){i=e.geminiUrl,r=e.vertexUrl}class t${}function tK(e,t){return e.replace(/\{([^}]+)\}/g,(e,n)=>{if(Object.prototype.hasOwnProperty.call(t,n)){let e=t[n];return null!=e?String(e):""}throw Error(`Key '${n}' not found in valueMap.`)})}function tW(e,t,n){for(let i=0;i<t.length-1;i++){let r=t[i];if(r.endsWith("[]")){let o=r.slice(0,-2);if(!(o in e))if(Array.isArray(n))e[o]=Array.from({length:n.length},()=>({}));else throw Error(`Value must be a list given an array path ${r}`);if(Array.isArray(e[o])){let r=e[o];if(Array.isArray(n))for(let e=0;e<r.length;e++)tW(r[e],t.slice(i+1),n[e]);else for(let e of r)tW(e,t.slice(i+1),n)}return}if(r.endsWith("[0]")){let o=r.slice(0,-3);o in e||(e[o]=[{}]),tW(e[o][0],t.slice(i+1),n);return}e[r]&&"object"==typeof e[r]||(e[r]={}),e=e[r]}let i=t[t.length-1],r=e[i];if(void 0!==r){if(!n||"object"==typeof n&&0===Object.keys(n).length||n===r)return;if("object"==typeof r&&"object"==typeof n&&null!==r&&null!==n)Object.assign(r,n);else throw Error(`Cannot set value for an existing key. Key: ${i}`)}else"_self"!==i||"object"!=typeof n||null===n||Array.isArray(n)?e[i]=n:Object.assign(e,n)}function tz(e,t,n){try{if(1===t.length&&"_self"===t[0])return e;for(let i=0;i<t.length;i++){if("object"!=typeof e||null===e)return n;let r=t[i];if(r.endsWith("[]")){let o=r.slice(0,-2);if(!(o in e))return n;{let r=e[o];if(!Array.isArray(r))return n;return r.map(e=>tz(e,t.slice(i+1),n))}}e=e[r]}return e}catch(e){if(e instanceof TypeError)return n;throw e}}function tZ(e){if("string"!=typeof e)throw Error("fromImageBytes must be a string");return e}function tQ(e){var t;let n,i,r,o,l={},s=tz(e,["name"]);null!=s&&tW(l,["name"],s);let a=tz(e,["metadata"]);null!=a&&tW(l,["metadata"],a);let u=tz(e,["done"]);null!=u&&tW(l,["done"],u);let p=tz(e,["error"]);null!=p&&tW(l,["error"],p);let d=tz(e,["response"]);return null!=d&&tW(l,["response"],(n={},null!=(i=tz(t=d,["sdkHttpResponse"]))&&tW(n,["sdkHttpResponse"],i),null!=(r=tz(t,["parent"]))&&tW(n,["parent"],r),null!=(o=tz(t,["documentName"]))&&tW(n,["documentName"],o),n)),l}(l=eN||(eN={})).OUTCOME_UNSPECIFIED="OUTCOME_UNSPECIFIED",l.OUTCOME_OK="OUTCOME_OK",l.OUTCOME_FAILED="OUTCOME_FAILED",l.OUTCOME_DEADLINE_EXCEEDED="OUTCOME_DEADLINE_EXCEEDED",(s=ew||(ew={})).LANGUAGE_UNSPECIFIED="LANGUAGE_UNSPECIFIED",s.PYTHON="PYTHON",(a=eD||(eD={})).SCHEDULING_UNSPECIFIED="SCHEDULING_UNSPECIFIED",a.SILENT="SILENT",a.WHEN_IDLE="WHEN_IDLE",a.INTERRUPT="INTERRUPT",(u=eG||(eG={})).TYPE_UNSPECIFIED="TYPE_UNSPECIFIED",u.STRING="STRING",u.NUMBER="NUMBER",u.INTEGER="INTEGER",u.BOOLEAN="BOOLEAN",u.ARRAY="ARRAY",u.OBJECT="OBJECT",u.NULL="NULL",(p=eM||(eM={})).AUTH_TYPE_UNSPECIFIED="AUTH_TYPE_UNSPECIFIED",p.NO_AUTH="NO_AUTH",p.API_KEY_AUTH="API_KEY_AUTH",p.HTTP_BASIC_AUTH="HTTP_BASIC_AUTH",p.GOOGLE_SERVICE_ACCOUNT_AUTH="GOOGLE_SERVICE_ACCOUNT_AUTH",p.OAUTH="OAUTH",p.OIDC_AUTH="OIDC_AUTH",(d=ek||(ek={})).HTTP_IN_UNSPECIFIED="HTTP_IN_UNSPECIFIED",d.HTTP_IN_QUERY="HTTP_IN_QUERY",d.HTTP_IN_HEADER="HTTP_IN_HEADER",d.HTTP_IN_PATH="HTTP_IN_PATH",d.HTTP_IN_BODY="HTTP_IN_BODY",d.HTTP_IN_COOKIE="HTTP_IN_COOKIE",(c=eU||(eU={})).API_SPEC_UNSPECIFIED="API_SPEC_UNSPECIFIED",c.SIMPLE_SEARCH="SIMPLE_SEARCH",c.ELASTIC_SEARCH="ELASTIC_SEARCH",(m=ex||(ex={})).ENVIRONMENT_UNSPECIFIED="ENVIRONMENT_UNSPECIFIED",m.ENVIRONMENT_BROWSER="ENVIRONMENT_BROWSER",m.ENVIRONMENT_MOBILE="ENVIRONMENT_MOBILE",m.ENVIRONMENT_DESKTOP="ENVIRONMENT_DESKTOP",(f=eL||(eL={})).SAFETY_POLICY_UNSPECIFIED="SAFETY_POLICY_UNSPECIFIED",f.FINANCIAL_TRANSACTIONS="FINANCIAL_TRANSACTIONS",f.SENSITIVE_DATA_MODIFICATION="SENSITIVE_DATA_MODIFICATION",f.COMMUNICATION_TOOL="COMMUNICATION_TOOL",f.ACCOUNT_CREATION="ACCOUNT_CREATION",f.DATA_MODIFICATION="DATA_MODIFICATION",f.USER_CONSENT_MANAGEMENT="USER_CONSENT_MANAGEMENT",f.LEGAL_TERMS_AND_AGREEMENTS="LEGAL_TERMS_AND_AGREEMENTS",(h=eq||(eq={})).PHISH_BLOCK_THRESHOLD_UNSPECIFIED="PHISH_BLOCK_THRESHOLD_UNSPECIFIED",h.BLOCK_LOW_AND_ABOVE="BLOCK_LOW_AND_ABOVE",h.BLOCK_MEDIUM_AND_ABOVE="BLOCK_MEDIUM_AND_ABOVE",h.BLOCK_HIGH_AND_ABOVE="BLOCK_HIGH_AND_ABOVE",h.BLOCK_HIGHER_AND_ABOVE="BLOCK_HIGHER_AND_ABOVE",h.BLOCK_VERY_HIGH_AND_ABOVE="BLOCK_VERY_HIGH_AND_ABOVE",h.BLOCK_ONLY_EXTREMELY_HIGH="BLOCK_ONLY_EXTREMELY_HIGH",(g=eH||(eH={})).UNSPECIFIED="UNSPECIFIED",g.BLOCKING="BLOCKING",g.NON_BLOCKING="NON_BLOCKING",(_=eF||(eF={})).MODE_UNSPECIFIED="MODE_UNSPECIFIED",_.MODE_DYNAMIC="MODE_DYNAMIC",(E=ej||(ej={})).THINKING_LEVEL_UNSPECIFIED="THINKING_LEVEL_UNSPECIFIED",E.MINIMAL="MINIMAL",E.LOW="LOW",E.MEDIUM="MEDIUM",E.HIGH="HIGH",(y=eB||(eB={})).DONT_ALLOW="DONT_ALLOW",y.ALLOW_ADULT="ALLOW_ADULT",y.ALLOW_ALL="ALLOW_ALL",(v=eX||(eX={})).PROMINENT_PEOPLE_UNSPECIFIED="PROMINENT_PEOPLE_UNSPECIFIED",v.ALLOW_PROMINENT_PEOPLE="ALLOW_PROMINENT_PEOPLE",v.BLOCK_PROMINENT_PEOPLE="BLOCK_PROMINENT_PEOPLE",(A=eV||(eV={})).HARM_CATEGORY_UNSPECIFIED="HARM_CATEGORY_UNSPECIFIED",A.HARM_CATEGORY_HARASSMENT="HARM_CATEGORY_HARASSMENT",A.HARM_CATEGORY_HATE_SPEECH="HARM_CATEGORY_HATE_SPEECH",A.HARM_CATEGORY_SEXUALLY_EXPLICIT="HARM_CATEGORY_SEXUALLY_EXPLICIT",A.HARM_CATEGORY_DANGEROUS_CONTENT="HARM_CATEGORY_DANGEROUS_CONTENT",A.HARM_CATEGORY_CIVIC_INTEGRITY="HARM_CATEGORY_CIVIC_INTEGRITY",A.HARM_CATEGORY_JAILBREAK="HARM_CATEGORY_JAILBREAK",A.HARM_CATEGORY_IMAGE_HATE="HARM_CATEGORY_IMAGE_HATE",A.HARM_CATEGORY_IMAGE_DANGEROUS_CONTENT="HARM_CATEGORY_IMAGE_DANGEROUS_CONTENT",A.HARM_CATEGORY_IMAGE_HARASSMENT="HARM_CATEGORY_IMAGE_HARASSMENT",A.HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT="HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT",(I=eJ||(eJ={})).HARM_BLOCK_METHOD_UNSPECIFIED="HARM_BLOCK_METHOD_UNSPECIFIED",I.SEVERITY="SEVERITY",I.PROBABILITY="PROBABILITY",(T=eY||(eY={})).HARM_BLOCK_THRESHOLD_UNSPECIFIED="HARM_BLOCK_THRESHOLD_UNSPECIFIED",T.BLOCK_LOW_AND_ABOVE="BLOCK_LOW_AND_ABOVE",T.BLOCK_MEDIUM_AND_ABOVE="BLOCK_MEDIUM_AND_ABOVE",T.BLOCK_ONLY_HIGH="BLOCK_ONLY_HIGH",T.BLOCK_NONE="BLOCK_NONE",T.OFF="OFF",(C=e$||(e$={})).MODE_UNSPECIFIED="MODE_UNSPECIFIED",C.AUTO="AUTO",C.ANY="ANY",C.NONE="NONE",C.VALIDATED="VALIDATED",(S=eK||(eK={})).FINISH_REASON_UNSPECIFIED="FINISH_REASON_UNSPECIFIED",S.STOP="STOP",S.MAX_TOKENS="MAX_TOKENS",S.SAFETY="SAFETY",S.RECITATION="RECITATION",S.LANGUAGE="LANGUAGE",S.OTHER="OTHER",S.BLOCKLIST="BLOCKLIST",S.PROHIBITED_CONTENT="PROHIBITED_CONTENT",S.SPII="SPII",S.MALFORMED_FUNCTION_CALL="MALFORMED_FUNCTION_CALL",S.IMAGE_SAFETY="IMAGE_SAFETY",S.UNEXPECTED_TOOL_CALL="UNEXPECTED_TOOL_CALL",S.TOO_MANY_TOOL_CALLS="TOO_MANY_TOOL_CALLS",S.IMAGE_PROHIBITED_CONTENT="IMAGE_PROHIBITED_CONTENT",S.NO_IMAGE="NO_IMAGE",S.IMAGE_RECITATION="IMAGE_RECITATION",S.IMAGE_OTHER="IMAGE_OTHER",(O=eW||(eW={})).HARM_PROBABILITY_UNSPECIFIED="HARM_PROBABILITY_UNSPECIFIED",O.NEGLIGIBLE="NEGLIGIBLE",O.LOW="LOW",O.MEDIUM="MEDIUM",O.HIGH="HIGH",(b=ez||(ez={})).HARM_SEVERITY_UNSPECIFIED="HARM_SEVERITY_UNSPECIFIED",b.HARM_SEVERITY_NEGLIGIBLE="HARM_SEVERITY_NEGLIGIBLE",b.HARM_SEVERITY_LOW="HARM_SEVERITY_LOW",b.HARM_SEVERITY_MEDIUM="HARM_SEVERITY_MEDIUM",b.HARM_SEVERITY_HIGH="HARM_SEVERITY_HIGH",(P=eZ||(eZ={})).URL_RETRIEVAL_STATUS_UNSPECIFIED="URL_RETRIEVAL_STATUS_UNSPECIFIED",P.URL_RETRIEVAL_STATUS_SUCCESS="URL_RETRIEVAL_STATUS_SUCCESS",P.URL_RETRIEVAL_STATUS_ERROR="URL_RETRIEVAL_STATUS_ERROR",P.URL_RETRIEVAL_STATUS_PAYWALL="URL_RETRIEVAL_STATUS_PAYWALL",P.URL_RETRIEVAL_STATUS_UNSAFE="URL_RETRIEVAL_STATUS_UNSAFE",(R=eQ||(eQ={})).BLOCKED_REASON_UNSPECIFIED="BLOCKED_REASON_UNSPECIFIED",R.SAFETY="SAFETY",R.OTHER="OTHER",R.BLOCKLIST="BLOCKLIST",R.PROHIBITED_CONTENT="PROHIBITED_CONTENT",R.IMAGE_SAFETY="IMAGE_SAFETY",R.MODEL_ARMOR="MODEL_ARMOR",R.JAILBREAK="JAILBREAK",(N=e0||(e0={})).TRAFFIC_TYPE_UNSPECIFIED="TRAFFIC_TYPE_UNSPECIFIED",N.ON_DEMAND="ON_DEMAND",N.ON_DEMAND_PRIORITY="ON_DEMAND_PRIORITY",N.ON_DEMAND_FLEX="ON_DEMAND_FLEX",N.PROVISIONED_THROUGHPUT="PROVISIONED_THROUGHPUT",(w=e1||(e1={})).MODALITY_UNSPECIFIED="MODALITY_UNSPECIFIED",w.TEXT="TEXT",w.IMAGE="IMAGE",w.VIDEO="VIDEO",w.AUDIO="AUDIO",w.DOCUMENT="DOCUMENT",(D=e4||(e4={})).MODEL_STAGE_UNSPECIFIED="MODEL_STAGE_UNSPECIFIED",D.UNSTABLE_EXPERIMENTAL="UNSTABLE_EXPERIMENTAL",D.EXPERIMENTAL="EXPERIMENTAL",D.PREVIEW="PREVIEW",D.STABLE="STABLE",D.LEGACY="LEGACY",D.DEPRECATED="DEPRECATED",D.RETIRED="RETIRED",(G=e2||(e2={})).MEDIA_RESOLUTION_UNSPECIFIED="MEDIA_RESOLUTION_UNSPECIFIED",G.MEDIA_RESOLUTION_LOW="MEDIA_RESOLUTION_LOW",G.MEDIA_RESOLUTION_MEDIUM="MEDIA_RESOLUTION_MEDIUM",G.MEDIA_RESOLUTION_HIGH="MEDIA_RESOLUTION_HIGH",(M=e5||(e5={})).MODALITY_UNSPECIFIED="MODALITY_UNSPECIFIED",M.TEXT="TEXT",M.IMAGE="IMAGE",M.AUDIO="AUDIO",M.VIDEO="VIDEO",(k=e3||(e3={})).DELIVERY_UNSPECIFIED="DELIVERY_UNSPECIFIED",k.INLINE="INLINE",k.URI="URI",(U=e8||(e8={})).ASPECT_RATIO_UNSPECIFIED="ASPECT_RATIO_UNSPECIFIED",U.ASPECT_RATIO_ONE_BY_ONE="ASPECT_RATIO_ONE_BY_ONE",U.ASPECT_RATIO_TWO_BY_THREE="ASPECT_RATIO_TWO_BY_THREE",U.ASPECT_RATIO_THREE_BY_TWO="ASPECT_RATIO_THREE_BY_TWO",U.ASPECT_RATIO_THREE_BY_FOUR="ASPECT_RATIO_THREE_BY_FOUR",U.ASPECT_RATIO_FOUR_BY_THREE="ASPECT_RATIO_FOUR_BY_THREE",U.ASPECT_RATIO_FOUR_BY_FIVE="ASPECT_RATIO_FOUR_BY_FIVE",U.ASPECT_RATIO_FIVE_BY_FOUR="ASPECT_RATIO_FIVE_BY_FOUR",U.ASPECT_RATIO_NINE_BY_SIXTEEN="ASPECT_RATIO_NINE_BY_SIXTEEN",U.ASPECT_RATIO_SIXTEEN_BY_NINE="ASPECT_RATIO_SIXTEEN_BY_NINE",U.ASPECT_RATIO_TWENTY_ONE_BY_NINE="ASPECT_RATIO_TWENTY_ONE_BY_NINE",U.ASPECT_RATIO_ONE_BY_EIGHT="ASPECT_RATIO_ONE_BY_EIGHT",U.ASPECT_RATIO_EIGHT_BY_ONE="ASPECT_RATIO_EIGHT_BY_ONE",U.ASPECT_RATIO_ONE_BY_FOUR="ASPECT_RATIO_ONE_BY_FOUR",U.ASPECT_RATIO_FOUR_BY_ONE="ASPECT_RATIO_FOUR_BY_ONE",(x=e9||(e9={})).IMAGE_SIZE_UNSPECIFIED="IMAGE_SIZE_UNSPECIFIED",x.IMAGE_SIZE_FIVE_TWELVE="IMAGE_SIZE_FIVE_TWELVE",x.IMAGE_SIZE_ONE_K="IMAGE_SIZE_ONE_K",x.IMAGE_SIZE_TWO_K="IMAGE_SIZE_TWO_K",x.IMAGE_SIZE_FOUR_K="IMAGE_SIZE_FOUR_K",(L=e6||(e6={})).TUNING_MODE_UNSPECIFIED="TUNING_MODE_UNSPECIFIED",L.TUNING_MODE_FULL="TUNING_MODE_FULL",L.TUNING_MODE_PEFT_ADAPTER="TUNING_MODE_PEFT_ADAPTER",(q=e7||(e7={})).ADAPTER_SIZE_UNSPECIFIED="ADAPTER_SIZE_UNSPECIFIED",q.ADAPTER_SIZE_ONE="ADAPTER_SIZE_ONE",q.ADAPTER_SIZE_TWO="ADAPTER_SIZE_TWO",q.ADAPTER_SIZE_FOUR="ADAPTER_SIZE_FOUR",q.ADAPTER_SIZE_EIGHT="ADAPTER_SIZE_EIGHT",q.ADAPTER_SIZE_SIXTEEN="ADAPTER_SIZE_SIXTEEN",q.ADAPTER_SIZE_THIRTY_TWO="ADAPTER_SIZE_THIRTY_TWO",(H=te||(te={})).RESPONSE_PARSE_TYPE_UNSPECIFIED="RESPONSE_PARSE_TYPE_UNSPECIFIED",H.IDENTITY="IDENTITY",H.REGEX_EXTRACT="REGEX_EXTRACT",(F=tt||(tt={})).MATCH_OPERATION_UNSPECIFIED="MATCH_OPERATION_UNSPECIFIED",F.REGEX_CONTAINS="REGEX_CONTAINS",F.PARTIAL_MATCH="PARTIAL_MATCH",F.EXACT_MATCH="EXACT_MATCH",(j=tn||(tn={})).REINFORCEMENT_TUNING_THINKING_LEVEL_UNSPECIFIED="REINFORCEMENT_TUNING_THINKING_LEVEL_UNSPECIFIED",j.MINIMAL="MINIMAL",j.HIGH="HIGH",(B=ti||(ti={})).JOB_STATE_UNSPECIFIED="JOB_STATE_UNSPECIFIED",B.JOB_STATE_QUEUED="JOB_STATE_QUEUED",B.JOB_STATE_PENDING="JOB_STATE_PENDING",B.JOB_STATE_RUNNING="JOB_STATE_RUNNING",B.JOB_STATE_SUCCEEDED="JOB_STATE_SUCCEEDED",B.JOB_STATE_FAILED="JOB_STATE_FAILED",B.JOB_STATE_CANCELLING="JOB_STATE_CANCELLING",B.JOB_STATE_CANCELLED="JOB_STATE_CANCELLED",B.JOB_STATE_PAUSED="JOB_STATE_PAUSED",B.JOB_STATE_EXPIRED="JOB_STATE_EXPIRED",B.JOB_STATE_UPDATING="JOB_STATE_UPDATING",B.JOB_STATE_PARTIALLY_SUCCEEDED="JOB_STATE_PARTIALLY_SUCCEEDED",(X=tr||(tr={})).TUNING_JOB_STATE_UNSPECIFIED="TUNING_JOB_STATE_UNSPECIFIED",X.TUNING_JOB_STATE_WAITING_FOR_QUOTA="TUNING_JOB_STATE_WAITING_FOR_QUOTA",X.TUNING_JOB_STATE_PROCESSING_DATASET="TUNING_JOB_STATE_PROCESSING_DATASET",X.TUNING_JOB_STATE_WAITING_FOR_CAPACITY="TUNING_JOB_STATE_WAITING_FOR_CAPACITY",X.TUNING_JOB_STATE_TUNING="TUNING_JOB_STATE_TUNING",X.TUNING_JOB_STATE_POST_PROCESSING="TUNING_JOB_STATE_POST_PROCESSING",(V=to||(to={})).AGGREGATION_METRIC_UNSPECIFIED="AGGREGATION_METRIC_UNSPECIFIED",V.AVERAGE="AVERAGE",V.MODE="MODE",V.STANDARD_DEVIATION="STANDARD_DEVIATION",V.VARIANCE="VARIANCE",V.MINIMUM="MINIMUM",V.MAXIMUM="MAXIMUM",V.MEDIAN="MEDIAN",V.PERCENTILE_P90="PERCENTILE_P90",V.PERCENTILE_P95="PERCENTILE_P95",V.PERCENTILE_P99="PERCENTILE_P99",(J=tl||(tl={})).PAIRWISE_CHOICE_UNSPECIFIED="PAIRWISE_CHOICE_UNSPECIFIED",J.BASELINE="BASELINE",J.CANDIDATE="CANDIDATE",J.TIE="TIE",(Y=ts||(ts={})).VIDEO_ORIENTATION_UNSPECIFIED="VIDEO_ORIENTATION_UNSPECIFIED",Y.LANDSCAPE="LANDSCAPE",Y.PORTRAIT="PORTRAIT",($=ta||(ta={})).TUNING_SPEED_UNSPECIFIED="TUNING_SPEED_UNSPECIFIED",$.REGULAR="REGULAR",$.FAST="FAST",(K=tu||(tu={})).TUNING_TASK_UNSPECIFIED="TUNING_TASK_UNSPECIFIED",K.TUNING_TASK_I2V="TUNING_TASK_I2V",K.TUNING_TASK_T2V="TUNING_TASK_T2V",K.TUNING_TASK_R2V="TUNING_TASK_R2V",(W=tp||(tp={})).STATE_UNSPECIFIED="STATE_UNSPECIFIED",W.STATE_PENDING="STATE_PENDING",W.STATE_ACTIVE="STATE_ACTIVE",W.STATE_FAILED="STATE_FAILED",(z=td||(td={})).UNSPECIFIED="unspecified",z.FLEX="flex",z.STANDARD="standard",z.PRIORITY="priority",(Z=tc||(tc={})).MEDIA_PROCESSING_UNSPECIFIED="MEDIA_PROCESSING_UNSPECIFIED",Z.STATIC="STATIC",Z.AGENTIC="AGENTIC",(Q=tm||(tm={})).MEDIA_RESOLUTION_UNSPECIFIED="MEDIA_RESOLUTION_UNSPECIFIED",Q.MEDIA_RESOLUTION_LOW="MEDIA_RESOLUTION_LOW",Q.MEDIA_RESOLUTION_MEDIUM="MEDIA_RESOLUTION_MEDIUM",Q.MEDIA_RESOLUTION_HIGH="MEDIA_RESOLUTION_HIGH",Q.MEDIA_RESOLUTION_ULTRA_HIGH="MEDIA_RESOLUTION_ULTRA_HIGH",(ee=tf||(tf={})).TOOL_TYPE_UNSPECIFIED="TOOL_TYPE_UNSPECIFIED",ee.GOOGLE_SEARCH_WEB="GOOGLE_SEARCH_WEB",ee.GOOGLE_SEARCH_IMAGE="GOOGLE_SEARCH_IMAGE",ee.URL_CONTEXT="URL_CONTEXT",ee.GOOGLE_MAPS="GOOGLE_MAPS",ee.FILE_SEARCH="FILE_SEARCH",ee.MEDIA_PROCESSING="MEDIA_PROCESSING",(th||(th={})).COLLECTION="COLLECTION",(et=tg||(tg={})).FEATURE_SELECTION_PREFERENCE_UNSPECIFIED="FEATURE_SELECTION_PREFERENCE_UNSPECIFIED",et.PRIORITIZE_QUALITY="PRIORITIZE_QUALITY",et.BALANCED="BALANCED",et.PRIORITIZE_COST="PRIORITIZE_COST",(en=t_||(t_={})).PREDICT="PREDICT",en.EMBED_CONTENT="EMBED_CONTENT",(ei=tE||(tE={})).BLOCK_LOW_AND_ABOVE="BLOCK_LOW_AND_ABOVE",ei.BLOCK_MEDIUM_AND_ABOVE="BLOCK_MEDIUM_AND_ABOVE",ei.BLOCK_ONLY_HIGH="BLOCK_ONLY_HIGH",ei.BLOCK_NONE="BLOCK_NONE",(er=ty||(ty={})).auto="auto",er.en="en",er.ja="ja",er.ko="ko",er.hi="hi",er.zh="zh",er.pt="pt",er.es="es",(eo=tv||(tv={})).MASK_MODE_DEFAULT="MASK_MODE_DEFAULT",eo.MASK_MODE_USER_PROVIDED="MASK_MODE_USER_PROVIDED",eo.MASK_MODE_BACKGROUND="MASK_MODE_BACKGROUND",eo.MASK_MODE_FOREGROUND="MASK_MODE_FOREGROUND",eo.MASK_MODE_SEMANTIC="MASK_MODE_SEMANTIC",(el=tA||(tA={})).CONTROL_TYPE_DEFAULT="CONTROL_TYPE_DEFAULT",el.CONTROL_TYPE_CANNY="CONTROL_TYPE_CANNY",el.CONTROL_TYPE_SCRIBBLE="CONTROL_TYPE_SCRIBBLE",el.CONTROL_TYPE_FACE_MESH="CONTROL_TYPE_FACE_MESH",(es=tI||(tI={})).SUBJECT_TYPE_DEFAULT="SUBJECT_TYPE_DEFAULT",es.SUBJECT_TYPE_PERSON="SUBJECT_TYPE_PERSON",es.SUBJECT_TYPE_ANIMAL="SUBJECT_TYPE_ANIMAL",es.SUBJECT_TYPE_PRODUCT="SUBJECT_TYPE_PRODUCT",(ea=tT||(tT={})).EDIT_MODE_DEFAULT="EDIT_MODE_DEFAULT",ea.EDIT_MODE_INPAINT_REMOVAL="EDIT_MODE_INPAINT_REMOVAL",ea.EDIT_MODE_INPAINT_INSERTION="EDIT_MODE_INPAINT_INSERTION",ea.EDIT_MODE_OUTPAINT="EDIT_MODE_OUTPAINT",ea.EDIT_MODE_CONTROLLED_EDITING="EDIT_MODE_CONTROLLED_EDITING",ea.EDIT_MODE_STYLE="EDIT_MODE_STYLE",ea.EDIT_MODE_BGSWAP="EDIT_MODE_BGSWAP",ea.EDIT_MODE_PRODUCT_IMAGE="EDIT_MODE_PRODUCT_IMAGE",(eu=tC||(tC={})).FOREGROUND="FOREGROUND",eu.BACKGROUND="BACKGROUND",eu.PROMPT="PROMPT",eu.SEMANTIC="SEMANTIC",eu.INTERACTIVE="INTERACTIVE",(ep=tS||(tS={})).ASSET="ASSET",ep.STYLE="STYLE",(ed=tO||(tO={})).INSERT="INSERT",ed.REMOVE="REMOVE",ed.REMOVE_STATIC="REMOVE_STATIC",ed.OUTPAINT="OUTPAINT",(ec=tb||(tb={})).OPTIMIZED="OPTIMIZED",ec.LOSSLESS="LOSSLESS",(em=tP||(tP={})).CROP="CROP",em.PAD="PAD",(ef=tR||(tR={})).SUPERVISED_FINE_TUNING="SUPERVISED_FINE_TUNING",ef.PREFERENCE_TUNING="PREFERENCE_TUNING",ef.DISTILLATION="DISTILLATION",ef.REINFORCEMENT_TUNING="REINFORCEMENT_TUNING",(eh=tN||(tN={})).STATE_UNSPECIFIED="STATE_UNSPECIFIED",eh.PROCESSING="PROCESSING",eh.ACTIVE="ACTIVE",eh.FAILED="FAILED",(eg=tw||(tw={})).SOURCE_UNSPECIFIED="SOURCE_UNSPECIFIED",eg.UPLOADED="UPLOADED",eg.GENERATED="GENERATED",eg.REGISTERED="REGISTERED",(e_=tD||(tD={})).TURN_COMPLETE_REASON_UNSPECIFIED="TURN_COMPLETE_REASON_UNSPECIFIED",e_.MALFORMED_FUNCTION_CALL="MALFORMED_FUNCTION_CALL",e_.RESPONSE_REJECTED="RESPONSE_REJECTED",e_.NEED_MORE_INPUT="NEED_MORE_INPUT",e_.PROHIBITED_INPUT_CONTENT="PROHIBITED_INPUT_CONTENT",e_.IMAGE_PROHIBITED_INPUT_CONTENT="IMAGE_PROHIBITED_INPUT_CONTENT",e_.INPUT_TEXT_CONTAIN_PROMINENT_PERSON_PROHIBITED="INPUT_TEXT_CONTAIN_PROMINENT_PERSON_PROHIBITED",e_.INPUT_IMAGE_CELEBRITY="INPUT_IMAGE_CELEBRITY",e_.INPUT_IMAGE_PHOTO_REALISTIC_CHILD_PROHIBITED="INPUT_IMAGE_PHOTO_REALISTIC_CHILD_PROHIBITED",e_.INPUT_TEXT_NCII_PROHIBITED="INPUT_TEXT_NCII_PROHIBITED",e_.INPUT_OTHER="INPUT_OTHER",e_.INPUT_IP_PROHIBITED="INPUT_IP_PROHIBITED",e_.BLOCKLIST="BLOCKLIST",e_.UNSAFE_PROMPT_FOR_IMAGE_GENERATION="UNSAFE_PROMPT_FOR_IMAGE_GENERATION",e_.GENERATED_IMAGE_SAFETY="GENERATED_IMAGE_SAFETY",e_.GENERATED_CONTENT_SAFETY="GENERATED_CONTENT_SAFETY",e_.GENERATED_AUDIO_SAFETY="GENERATED_AUDIO_SAFETY",e_.GENERATED_VIDEO_SAFETY="GENERATED_VIDEO_SAFETY",e_.GENERATED_CONTENT_PROHIBITED="GENERATED_CONTENT_PROHIBITED",e_.GENERATED_CONTENT_BLOCKLIST="GENERATED_CONTENT_BLOCKLIST",e_.GENERATED_IMAGE_PROHIBITED="GENERATED_IMAGE_PROHIBITED",e_.GENERATED_IMAGE_CELEBRITY="GENERATED_IMAGE_CELEBRITY",e_.GENERATED_IMAGE_PROMINENT_PEOPLE_DETECTED_BY_REWRITER="GENERATED_IMAGE_PROMINENT_PEOPLE_DETECTED_BY_REWRITER",e_.GENERATED_IMAGE_IDENTIFIABLE_PEOPLE="GENERATED_IMAGE_IDENTIFIABLE_PEOPLE",e_.GENERATED_IMAGE_MINORS="GENERATED_IMAGE_MINORS",e_.OUTPUT_IMAGE_IP_PROHIBITED="OUTPUT_IMAGE_IP_PROHIBITED",e_.GENERATED_OTHER="GENERATED_OTHER",e_.MAX_REGENERATION_REACHED="MAX_REGENERATION_REACHED",(eE=tG||(tG={})).INTERACTION_STATUS_UNSPECIFIED="INTERACTION_STATUS_UNSPECIFIED",eE.IN_PROGRESS="IN_PROGRESS",eE.REQUIRES_ACTION="REQUIRES_ACTION",eE.IDLE="IDLE",(ey=tM||(tM={})).VAD_SIGNAL_TYPE_UNSPECIFIED="VAD_SIGNAL_TYPE_UNSPECIFIED",ey.VAD_SIGNAL_TYPE_SOS="VAD_SIGNAL_TYPE_SOS",ey.VAD_SIGNAL_TYPE_EOS="VAD_SIGNAL_TYPE_EOS",(ev=tk||(tk={})).TYPE_UNSPECIFIED="TYPE_UNSPECIFIED",ev.ACTIVITY_START="ACTIVITY_START",ev.ACTIVITY_END="ACTIVITY_END",(eA=tU||(tU={})).START_SENSITIVITY_UNSPECIFIED="START_SENSITIVITY_UNSPECIFIED",eA.START_SENSITIVITY_HIGH="START_SENSITIVITY_HIGH",eA.START_SENSITIVITY_LOW="START_SENSITIVITY_LOW",(eI=tx||(tx={})).END_SENSITIVITY_UNSPECIFIED="END_SENSITIVITY_UNSPECIFIED",eI.END_SENSITIVITY_HIGH="END_SENSITIVITY_HIGH",eI.END_SENSITIVITY_LOW="END_SENSITIVITY_LOW",(eT=tL||(tL={})).ACTIVITY_HANDLING_UNSPECIFIED="ACTIVITY_HANDLING_UNSPECIFIED",eT.START_OF_ACTIVITY_INTERRUPTS="START_OF_ACTIVITY_INTERRUPTS",eT.NO_INTERRUPTION="NO_INTERRUPTION",(eC=tq||(tq={})).TURN_COVERAGE_UNSPECIFIED="TURN_COVERAGE_UNSPECIFIED",eC.TURN_INCLUDES_ONLY_ACTIVITY="TURN_INCLUDES_ONLY_ACTIVITY",eC.TURN_INCLUDES_ALL_INPUT="TURN_INCLUDES_ALL_INPUT",eC.TURN_INCLUDES_AUDIO_ACTIVITY_AND_ALL_VIDEO="TURN_INCLUDES_AUDIO_ACTIVITY_AND_ALL_VIDEO",(eS=tH||(tH={})).MODE_UNSPECIFIED="MODE_UNSPECIFIED",eS.VERBATIM="VERBATIM",eS.SMART="SMART",(eO=tF||(tF={})).SCALE_UNSPECIFIED="SCALE_UNSPECIFIED",eO.C_MAJOR_A_MINOR="C_MAJOR_A_MINOR",eO.D_FLAT_MAJOR_B_FLAT_MINOR="D_FLAT_MAJOR_B_FLAT_MINOR",eO.D_MAJOR_B_MINOR="D_MAJOR_B_MINOR",eO.E_FLAT_MAJOR_C_MINOR="E_FLAT_MAJOR_C_MINOR",eO.E_MAJOR_D_FLAT_MINOR="E_MAJOR_D_FLAT_MINOR",eO.F_MAJOR_D_MINOR="F_MAJOR_D_MINOR",eO.G_FLAT_MAJOR_E_FLAT_MINOR="G_FLAT_MAJOR_E_FLAT_MINOR",eO.G_MAJOR_E_MINOR="G_MAJOR_E_MINOR",eO.A_FLAT_MAJOR_F_MINOR="A_FLAT_MAJOR_F_MINOR",eO.A_MAJOR_G_FLAT_MINOR="A_MAJOR_G_FLAT_MINOR",eO.B_FLAT_MAJOR_G_MINOR="B_FLAT_MAJOR_G_MINOR",eO.B_MAJOR_A_FLAT_MINOR="B_MAJOR_A_FLAT_MINOR",(eb=tj||(tj={})).MUSIC_GENERATION_MODE_UNSPECIFIED="MUSIC_GENERATION_MODE_UNSPECIFIED",eb.QUALITY="QUALITY",eb.DIVERSITY="DIVERSITY",eb.VOCALIZATION="VOCALIZATION",(eP=tB||(tB={})).PLAYBACK_CONTROL_UNSPECIFIED="PLAYBACK_CONTROL_UNSPECIFIED",eP.PLAY="PLAY",eP.PAUSE="PAUSE",eP.STOP="STOP",eP.RESET_CONTEXT="RESET_CONTEXT";class t0{}class t1{}class t4{}class t2{}function t5(e,t){return{inlineData:{data:e,mimeType:t}}}function t3(e,t){return{fileData:{fileUri:e,mimeType:t}}}class t8{}function t9(e,t,n){return Object.assign({fileData:{fileUri:e,mimeType:t}},n&&{mediaResolution:{level:n}})}function t6(e){return{text:e}}function t7(e,t){return{functionCall:{name:e,args:t}}}function ne(e,t,n,i=[]){return{functionResponse:Object.assign({id:e,name:t,response:n},i.length>0&&{parts:i})}}function nt(e,t,n){return Object.assign({inlineData:{data:e,mimeType:t}},n&&{mediaResolution:{level:n}})}function nn(e,t){return{codeExecutionResult:{outcome:e,output:t}}}function ni(e,t){return{executableCode:{code:e,language:t}}}function nr(e){return"object"==typeof e&&null!==e&&("fileData"in e||"text"in e||"functionCall"in e||"functionResponse"in e||"inlineData"in e||"videoMetadata"in e||"codeExecutionResult"in e||"executableCode"in e)}function no(e){let t=[];if("string"==typeof e)t.push(t6(e));else if(nr(e))t.push(e);else if(Array.isArray(e)){if(0===e.length)throw Error("partOrString cannot be an empty array");for(let n of e)if("string"==typeof n)t.push(t6(n));else if(nr(n))t.push(n);else throw Error("element in PartUnion must be a Part object or string")}else throw Error("partOrString must be a Part object, string, or array");return t}function nl(e){return{role:"user",parts:no(e)}}function ns(e){return{role:"model",parts:no(e)}}class na{constructor(e){const t={};for(const n of e.headers.entries())t[n[0]]=n[1];this.headers=t,this.responseInternal=e}json(){return this.responseInternal.json()}}class nu{}class np{}class nd{get text(){var e,t,n,i,r,o,l,s;if((null==(i=null==(n=null==(t=null==(e=this.candidates)?void 0:e[0])?void 0:t.content)?void 0:n.parts)?void 0:i.length)===0)return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning text from the first one.");let a="",u=!1,p=[];for(let e of null!=(s=null==(l=null==(o=null==(r=this.candidates)?void 0:r[0])?void 0:o.content)?void 0:l.parts)?s:[]){for(let[t,n]of Object.entries(e))"text"!==t&&"thought"!==t&&"thoughtSignature"!==t&&(null!==n||void 0!==n)&&p.push(t);if("string"==typeof e.text){if("boolean"==typeof e.thought&&e.thought)continue;u=!0,a+=e.text}}return p.length>0&&console.warn(`there are non-text parts ${p} in the response, returning concatenation of all text parts. Please refer to the non text parts for a full response from model.`),u?a:void 0}get data(){var e,t,n,i,r,o,l,s;if((null==(i=null==(n=null==(t=null==(e=this.candidates)?void 0:e[0])?void 0:t.content)?void 0:n.parts)?void 0:i.length)===0)return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning data from the first one.");let a="",u=[];for(let e of null!=(s=null==(l=null==(o=null==(r=this.candidates)?void 0:r[0])?void 0:o.content)?void 0:l.parts)?s:[]){for(let[t,n]of Object.entries(e))"inlineData"!==t&&(null!==n||void 0!==n)&&u.push(t);e.inlineData&&"string"==typeof e.inlineData.data&&(a+=atob(e.inlineData.data))}return u.length>0&&console.warn(`there are non-data parts ${u} in the response, returning concatenation of all data parts. Please refer to the non data parts for a full response from model.`),a.length>0?btoa(a):void 0}get functionCalls(){var e,t,n,i,r,o,l,s;if((null==(i=null==(n=null==(t=null==(e=this.candidates)?void 0:e[0])?void 0:t.content)?void 0:n.parts)?void 0:i.length)===0)return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning function calls from the first one.");let a=null==(s=null==(l=null==(o=null==(r=this.candidates)?void 0:r[0])?void 0:o.content)?void 0:l.parts)?void 0:s.filter(e=>e.functionCall).map(e=>e.functionCall).filter(e=>void 0!==e);if((null==a?void 0:a.length)!==0)return a}get executableCode(){var e,t,n,i,r,o,l,s,a;if((null==(i=null==(n=null==(t=null==(e=this.candidates)?void 0:e[0])?void 0:t.content)?void 0:n.parts)?void 0:i.length)===0)return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning executable code from the first one.");let u=null==(s=null==(l=null==(o=null==(r=this.candidates)?void 0:r[0])?void 0:o.content)?void 0:l.parts)?void 0:s.filter(e=>e.executableCode).map(e=>e.executableCode).filter(e=>void 0!==e);if((null==u?void 0:u.length)!==0)return null==(a=null==u?void 0:u[0])?void 0:a.code}get codeExecutionResult(){var e,t,n,i,r,o,l,s,a;if((null==(i=null==(n=null==(t=null==(e=this.candidates)?void 0:e[0])?void 0:t.content)?void 0:n.parts)?void 0:i.length)===0)return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning code execution result from the first one.");let u=null==(s=null==(l=null==(o=null==(r=this.candidates)?void 0:r[0])?void 0:o.content)?void 0:l.parts)?void 0:s.filter(e=>e.codeExecutionResult).map(e=>e.codeExecutionResult).filter(e=>void 0!==e);if((null==u?void 0:u.length)!==0)return null==(a=null==u?void 0:u[0])?void 0:a.output}}class nc{}class nm{}class nf{}class nh{}class ng{}class n_{}class nE{}class ny{}class nv{}class nA{}class nI{}class nT{}class nC{}class nS{}class nO{}class nb{}class nP{_fromAPIResponse({apiResponse:e,_isVertexAI:t}){let n,i=new nP;if(t){let t,i,r,o,l,s;t={},null!=(i=tz(e,["name"]))&&tW(t,["name"],i),null!=(r=tz(e,["metadata"]))&&tW(t,["metadata"],r),null!=(o=tz(e,["done"]))&&tW(t,["done"],o),null!=(l=tz(e,["error"]))&&tW(t,["error"],l),null!=(s=tz(e,["response"]))&&tW(t,["response"],function(e){let t={},n=tz(e,["videos"]);if(null!=n){let e=n;Array.isArray(e)&&(e=e.map(e=>{var t;let n,i,r,o,l,s;return n={},null!=(i=tz(e,["_self"]))&&tW(n,["video"],(r={},null!=(o=tz(t=i,["gcsUri"]))&&tW(r,["uri"],o),null!=(l=tz(t,["bytesBase64Encoded"]))&&tW(r,["videoBytes"],tZ(l)),null!=(s=tz(t,["mimeType"]))&&tW(r,["mimeType"],s),r)),n})),tW(t,["generatedVideos"],e)}let i=tz(e,["raiMediaFilteredCount"]);null!=i&&tW(t,["raiMediaFilteredCount"],i);let r=tz(e,["raiMediaFilteredReasons"]);return null!=r&&tW(t,["raiMediaFilteredReasons"],r),t}(s)),n=t}else{let t,i,r,o,l,s;t={},null!=(i=tz(e,["name"]))&&tW(t,["name"],i),null!=(r=tz(e,["metadata"]))&&tW(t,["metadata"],r),null!=(o=tz(e,["done"]))&&tW(t,["done"],o),null!=(l=tz(e,["error"]))&&tW(t,["error"],l),null!=(s=tz(e,["response","generateVideoResponse"]))&&tW(t,["response"],function(e){let t={},n=tz(e,["generatedSamples"]);if(null!=n){let e=n;Array.isArray(e)&&(e=e.map(e=>{var t;let n,i,r,o,l,s;return n={},null!=(i=tz(e,["video"]))&&tW(n,["video"],(r={},null!=(o=tz(t=i,["uri"]))&&tW(r,["uri"],o),null!=(l=tz(t,["encodedVideo"]))&&tW(r,["videoBytes"],tZ(l)),null!=(s=tz(t,["encoding"]))&&tW(r,["mimeType"],s),r)),n})),tW(t,["generatedVideos"],e)}let i=tz(e,["raiMediaFilteredCount"]);null!=i&&tW(t,["raiMediaFilteredCount"],i);let r=tz(e,["raiMediaFilteredReasons"]);return null!=r&&tW(t,["raiMediaFilteredReasons"],r),t}(s)),n=t}return Object.assign(i,n),i}}class nR{}class nN{}class nw{}class nD{}class nG{}class nM{}class nk{}class nU{}class nx{}class nL{}class nq{}class nH{}class nF{_fromAPIResponse({apiResponse:e,_isVertexAI:t}){var n;let i,r,o,l,s,a,u,p,d,c,m=new nF;return Object.assign(m,(s={},null!=(a=tz(e,["name"]))&&tW(s,["name"],a),null!=(u=tz(e,["metadata"]))&&tW(s,["metadata"],u),null!=(p=tz(e,["done"]))&&tW(s,["done"],p),null!=(d=tz(e,["error"]))&&tW(s,["error"],d),null!=(c=tz(e,["response"]))&&tW(s,["response"],(i={},null!=(r=tz(n=c,["sdkHttpResponse"]))&&tW(i,["sdkHttpResponse"],r),null!=(o=tz(n,["parent"]))&&tW(i,["parent"],o),null!=(l=tz(n,["documentName"]))&&tW(i,["documentName"],l),i)),s)),m}}class nj{}class nB{}class nX{}class nV{}class nJ{}class nY{}class n${}class nK{}class nW{}class nz{toReferenceImageAPI(){return{referenceType:"REFERENCE_TYPE_RAW",referenceImage:this.referenceImage,referenceId:this.referenceId}}}class nZ{toReferenceImageAPI(){return{referenceType:"REFERENCE_TYPE_MASK",referenceImage:this.referenceImage,referenceId:this.referenceId,maskImageConfig:this.config}}}class nQ{toReferenceImageAPI(){return{referenceType:"REFERENCE_TYPE_CONTROL",referenceImage:this.referenceImage,referenceId:this.referenceId,controlImageConfig:this.config}}}class n0{toReferenceImageAPI(){return{referenceType:"REFERENCE_TYPE_STYLE",referenceImage:this.referenceImage,referenceId:this.referenceId,styleImageConfig:this.config}}}class n1{toReferenceImageAPI(){return{referenceType:"REFERENCE_TYPE_SUBJECT",referenceImage:this.referenceImage,referenceId:this.referenceId,subjectImageConfig:this.config}}}class n4{toReferenceImageAPI(){return{referenceType:"REFERENCE_TYPE_CONTENT",referenceImage:this.referenceImage,referenceId:this.referenceId}}}class n2{get text(){var e,t,n;let i="",r=!1,o=[];for(let l of null!=(n=null==(t=null==(e=this.serverContent)?void 0:e.modelTurn)?void 0:t.parts)?n:[]){for(let[e,t]of Object.entries(l))"text"!==e&&"thought"!==e&&null!==t&&o.push(e);if("string"==typeof l.text){if("boolean"==typeof l.thought&&l.thought)continue;r=!0,i+=l.text}}return o.length>0&&console.warn(`there are non-text parts ${o} in the response, returning concatenation of all text parts. Please refer to the non text parts for a full response from model.`),r?i:void 0}get data(){var e,t,n;let i="",r=[];for(let o of null!=(n=null==(t=null==(e=this.serverContent)?void 0:e.modelTurn)?void 0:t.parts)?n:[]){for(let[e,t]of Object.entries(o))"inlineData"!==e&&null!==t&&r.push(e);o.inlineData&&"string"==typeof o.inlineData.data&&(i+=atob(o.inlineData.data))}return r.length>0&&console.warn(`there are non-data parts ${r} in the response, returning concatenation of all data parts. Please refer to the non data parts for a full response from model.`),i.length>0?btoa(i):void 0}}class n5{}class n3{constructor(){this.functionResponses=[]}}class n8{get audioChunk(){if(this.serverContent&&this.serverContent.audioChunks&&this.serverContent.audioChunks.length>0)return this.serverContent.audioChunks[0]}}class n9{}class n6{_fromAPIResponse({apiResponse:e,_isVertexAI:t}){let n=new n6;return Object.assign(n,tQ(e)),n}}function n7(e,t){if(!t||"string"!=typeof t)throw Error("model is required and must be a string");if(t.includes("..")||t.includes("?")||t.includes("&"))throw Error("invalid model parameter");if(e.isVertexAI())if(t.startsWith("publishers/")||t.startsWith("projects/")||t.startsWith("models/"))return t;else{if(!(t.indexOf("/")>=0))return`publishers/google/models/${t}`;let e=t.split("/",2);return`publishers/${e[0]}/models/${e[1]}`}return t.startsWith("models/")||t.startsWith("tunedModels/")?t:`models/${t}`}function ie(e,t){let n=n7(e,t);return n?n.startsWith("publishers/")&&e.isVertexAI()?`projects/${e.getProject()}/locations/${e.getLocation()}/${n}`:n.startsWith("models/")&&e.isVertexAI()?`projects/${e.getProject()}/locations/${e.getLocation()}/publishers/google/${n}`:n:""}function it(e){return Array.isArray(e)?e.map(e=>ii(e)):[ii(e)]}function ii(e){if("object"==typeof e&&null!==e)return e;throw Error(`Could not parse input as Blob. Unsupported blob type: ${typeof e}`)}function ir(e){let t=ii(e);if(t.mimeType&&t.mimeType.startsWith("image/"))return t;throw Error(`Unsupported mime type: ${t.mimeType}`)}function io(e){let t=ii(e);if(t.mimeType&&t.mimeType.startsWith("audio/"))return t;throw Error(`Unsupported mime type: ${t.mimeType}`)}function il(e){if(null==e)throw Error("PartUnion is required");if("object"==typeof e)return e;if("string"==typeof e)return{text:e};throw Error(`Unsupported part type: ${typeof e}`)}function is(e){if(null==e||Array.isArray(e)&&0===e.length)throw Error("PartListUnion is required");return Array.isArray(e)?e.map(e=>il(e)):[il(e)]}function ia(e){return null!=e&&"object"==typeof e&&"parts"in e&&Array.isArray(e.parts)}function iu(e){return null!=e&&"object"==typeof e&&"functionCall"in e}function ip(e){return null!=e&&"object"==typeof e&&"functionResponse"in e}function id(e){if(null==e)throw Error("ContentUnion is required");return ia(e)?e:{role:"user",parts:is(e)}}function ic(e,t){if(!t)return[];if(e.isVertexAI()&&Array.isArray(t))return t.flatMap(e=>{let t=id(e);return t.parts&&t.parts.length>0&&void 0!==t.parts[0].text?[t.parts[0].text]:[]});if(e.isVertexAI()){let e=id(t);return e.parts&&e.parts.length>0&&void 0!==e.parts[0].text?[e.parts[0].text]:[]}return Array.isArray(t)?t.map(e=>id(e)):[id(t)]}function im(e){if(null==e||Array.isArray(e)&&0===e.length)throw Error("contents are required");if(!Array.isArray(e)){if(iu(e)||ip(e))throw Error("To specify functionCall or functionResponse parts, please wrap them in a Content object, specifying the role for them");return[id(e)]}let t=[],n=[],i=ia(e[0]);for(let r of e){let e=ia(r);if(e!=i)throw Error("Mixing Content and Parts is not supported, please group the parts into a the appropriate Content objects and specify the roles for them");if(e)t.push(r);else if(iu(r)||ip(r))throw Error("To specify functionCall or functionResponse parts, please wrap them, and any other parts, in Content objects as appropriate, specifying the role for them");else n.push(r)}return i||t.push({role:"user",parts:is(n)}),t}function ih(e){let t={},n=["items"],i=["anyOf"],r=["properties"];if(e.type&&e.anyOf)throw Error("type and anyOf cannot be both populated.");let o=e.anyOf;for(let[l,s]of(null!=o&&2==o.length&&("null"===o[0].type?(t.nullable=!0,e=o[1]):"null"===o[1].type&&(t.nullable=!0,e=o[0])),e.type instanceof Array&&function(e,t){e.includes("null")&&(t.nullable=!0);let n=e.filter(e=>"null"!==e);if(1===n.length)t.type=Object.values(eG).includes(n[0].toUpperCase())?n[0].toUpperCase():eG.TYPE_UNSPECIFIED;else for(let e of(t.anyOf=[],n))t.anyOf.push({type:Object.values(eG).includes(e.toUpperCase())?e.toUpperCase():eG.TYPE_UNSPECIFIED})}(e.type,t),Object.entries(e)))if(null!=s)if("type"==l){if("null"===s)throw Error("type: null can not be the only possible type for the field.");if(s instanceof Array)continue;t.type=Object.values(eG).includes(s.toUpperCase())?s.toUpperCase():eG.TYPE_UNSPECIFIED}else if(n.includes(l))t[l]=ih(s);else if(i.includes(l)){let e=[];for(let n of s){if("null"==n.type){t.nullable=!0;continue}e.push(ih(n))}t[l]=e}else if(r.includes(l)){let e={};for(let[t,n]of Object.entries(s))e[t]=ih(n);t[l]=e}else{if("additionalProperties"===l)continue;t[l]=s}return t}function ig(e){if("object"==typeof e)return e;if("string"==typeof e)return{voiceConfig:{prebuiltVoiceConfig:{voiceName:e}}};throw Error(`Unsupported speechConfig type: ${typeof e}`)}function i_(e){if("multiSpeakerVoiceConfig"in e)throw Error("multiSpeakerVoiceConfig is not supported in the live API.");return e}function iE(e){if(e.functionDeclarations)for(let t of e.functionDeclarations)t.parameters&&(Object.keys(t.parameters).includes("$schema")?t.parametersJsonSchema||(t.parametersJsonSchema=t.parameters,delete t.parameters):t.parameters=ih(t.parameters)),t.response&&(Object.keys(t.response).includes("$schema")?t.responseJsonSchema||(t.responseJsonSchema=t.response,delete t.response):t.response=ih(t.response));return e}function iy(e){if(null==e)throw Error("tools is required");if(!Array.isArray(e))throw Error("tools is required and must be an array of Tools");let t=[];for(let n of e)t.push(n);return t}function iv(e,t){if("string"!=typeof t)throw Error("name must be a string");return function(e,t,n,i=1){let r=!t.startsWith(`${n}/`)&&t.split("/").length===i;if(e.isVertexAI())if(t.startsWith("projects/"))return t;else if(t.startsWith("locations/"))return`projects/${e.getProject()}/${t}`;else if(t.startsWith(`${n}/`))return`projects/${e.getProject()}/locations/${e.getLocation()}/${t}`;else if(r)return`projects/${e.getProject()}/locations/${e.getLocation()}/${n}/${t}`;else return t;return r?`${n}/${t}`:t}(e,t,"cachedContents")}function iA(e){switch(e){case"STATE_UNSPECIFIED":return"JOB_STATE_UNSPECIFIED";case"CREATING":return"JOB_STATE_RUNNING";case"ACTIVE":return"JOB_STATE_SUCCEEDED";case"FAILED":return"JOB_STATE_FAILED";default:return e}}function iI(e){var t;let n;if(null!=e&&"object"==typeof e&&"name"in e&&(n=e.name),null==e||"object"!=typeof e||!("uri"in e)||void 0!==(n=e.uri)){if(null==e||"object"!=typeof e||!("video"in e)||void 0!==(n=null==(t=e.video)?void 0:t.uri)){if("string"==typeof e&&(n=e),void 0===n)throw Error("Could not extract file name from the provided input.");if(n.startsWith("https://")){let e=n.split("files/")[1].match(/[a-z0-9]+/);if(null===e)throw Error(`Could not extract file name from URI ${n}`);n=e[0]}else n.startsWith("files/")&&(n=n.split("files/")[1]);return n}}}function iT(e,t){return e.isVertexAI()?t?"publishers/google/models":"models":t?"models":"tunedModels"}function iC(e){for(let i of["models","tunedModels","publisherModels"]){var t,n;if(t=e,n=i,null!==t&&"object"==typeof t&&n in t)return e[i]}return[]}function iS(e,t){let n;if("string"==typeof t)if(e.isVertexAI())if(t.startsWith("gs://"))n={format:"jsonl",gcsUri:[t]};else if(t.startsWith("bq://"))n={format:"bigquery",bigqueryUri:t};else if(/^projects\/[^/]+\/locations\/[^/]+\/datasets\/[^/]+$/.test(t))n={format:"vertex-dataset",vertexDatasetName:t};else throw Error(`Unsupported string source for Vertex AI: ${t}`);else if(t.startsWith("files/"))n={fileName:t};else throw Error(`Unsupported string source for Gemini API: ${t}`);else if(Array.isArray(t)){if(e.isVertexAI())throw Error("InlinedRequest[] is not supported in Vertex AI.");n={inlinedRequests:t}}else n=t;let i=[n.gcsUri,n.bigqueryUri,n.vertexDatasetName].filter(Boolean).length,r=[n.inlinedRequests,n.fileName].filter(Boolean).length;if(e.isVertexAI()){if(r>0||1!==i)throw Error("Exactly one of `gcsUri`, `bigqueryUri`, or `vertexDatasetName` must be set for Vertex AI.")}else if(i>0||1!==r)throw Error("Exactly one of `inlinedRequests`, `fileName`, must be set for Gemini API.");return n}function iO(e){if("object"!=typeof e||null===e)return{};let t=e.inlinedResponses;if("object"!=typeof t||null===t)return e;let n=t.inlinedResponses;if(!Array.isArray(n)||0===n.length)return e;let i=!1;for(let e of n){if("object"!=typeof e||null===e)continue;let t=e.response;if("object"==typeof t&&null!==t&&void 0!==t.embedding){i=!0;break}}return i&&(e.inlinedEmbedContentResponses=e.inlinedResponses,delete e.inlinedResponses),e}function ib(e,t){if(!e.isVertexAI()){if(/batches\/[^/]+$/.test(t))return t.split("/").pop();throw Error(`Invalid batch job name: ${t}.`)}if(/^projects\/[^/]+\/locations\/[^/]+\/batchPredictionJobs\/[^/]+$/.test(t))return t.split("/").pop();if(/^\d+$/.test(t))return t;throw Error(`Invalid batch job name: ${t}.`)}function iP(e){if("BATCH_STATE_UNSPECIFIED"===e)return"JOB_STATE_UNSPECIFIED";if("BATCH_STATE_PENDING"===e)return"JOB_STATE_PENDING";if("BATCH_STATE_RUNNING"===e)return"JOB_STATE_RUNNING";if("BATCH_STATE_SUCCEEDED"===e)return"JOB_STATE_SUCCEEDED";if("BATCH_STATE_FAILED"===e)return"JOB_STATE_FAILED";else if("BATCH_STATE_CANCELLED"===e)return"JOB_STATE_CANCELLED";else if("BATCH_STATE_EXPIRED"===e)return"JOB_STATE_EXPIRED";else return e}function iR(e){let t={},n=tz(e,["name"]);null!=n&&tW(t,["name"],n);let i=tz(e,["metadata","displayName"]);null!=i&&tW(t,["displayName"],i);let r=tz(e,["metadata","state"]);null!=r&&tW(t,["state"],iP(r));let o=tz(e,["metadata","createTime"]);null!=o&&tW(t,["createTime"],o);let l=tz(e,["metadata","endTime"]);null!=l&&tW(t,["endTime"],l);let s=tz(e,["metadata","updateTime"]);null!=s&&tW(t,["updateTime"],s);let a=tz(e,["metadata","model"]);null!=a&&tW(t,["model"],a);let u=tz(e,["metadata","output"]);return null!=u&&tW(t,["dest"],function(e){let t={},n=tz(e,["responsesFile"]);null!=n&&tW(t,["fileName"],n);let i=tz(e,["inlinedResponses","inlinedResponses"]);if(null!=i){let e=i;Array.isArray(e)&&(e=e.map(e=>{var t;let n,i,r,o;return n={},null!=(i=tz(t=e,["response"]))&&tW(n,["response"],function(e){let t={},n=tz(e,["sdkHttpResponse"]);null!=n&&tW(t,["sdkHttpResponse"],n);let i=tz(e,["candidates"]);if(null!=i){let e=i;Array.isArray(e)&&(e=e.map(e=>(function(e){let t={},n=tz(e,["content"]);null!=n&&tW(t,["content"],n);let i=tz(e,["citationMetadata"]);null!=i&&tW(t,["citationMetadata"],function(e){let t={},n=tz(e,["citationSources"]);if(null!=n){let e=n;Array.isArray(e)&&(e=e.map(e=>e)),tW(t,["citations"],e)}return t}(i));let r=tz(e,["tokenCount"]);null!=r&&tW(t,["tokenCount"],r);let o=tz(e,["finishReason"]);null!=o&&tW(t,["finishReason"],o);let l=tz(e,["groundingMetadata"]);null!=l&&tW(t,["groundingMetadata"],l);let s=tz(e,["avgLogprobs"]);null!=s&&tW(t,["avgLogprobs"],s);let a=tz(e,["index"]);null!=a&&tW(t,["index"],a);let u=tz(e,["logprobsResult"]);null!=u&&tW(t,["logprobsResult"],u);let p=tz(e,["safetyRatings"]);if(null!=p){let e=p;Array.isArray(e)&&(e=e.map(e=>e)),tW(t,["safetyRatings"],e)}let d=tz(e,["urlContextMetadata"]);return null!=d&&tW(t,["urlContextMetadata"],d),t})(e))),tW(t,["candidates"],e)}let r=tz(e,["modelVersion"]);null!=r&&tW(t,["modelVersion"],r);let o=tz(e,["promptFeedback"]);null!=o&&tW(t,["promptFeedback"],o);let l=tz(e,["responseId"]);null!=l&&tW(t,["responseId"],l);let s=tz(e,["usageMetadata"]);null!=s&&tW(t,["usageMetadata"],s);let a=tz(e,["modelStatus"]);return null!=a&&tW(t,["modelStatus"],a),t}(i)),null!=(r=tz(t,["metadata"]))&&tW(n,["metadata"],r),null!=(o=tz(t,["error"]))&&tW(n,["error"],o),n})),tW(t,["inlinedResponses"],e)}let r=tz(e,["inlinedEmbedContentResponses","inlinedResponses"]);if(null!=r){let e=r;Array.isArray(e)&&(e=e.map(e=>e)),tW(t,["inlinedEmbedContentResponses"],e)}return t}(iO(u))),t}function iN(e){var t,n,i;let r,o,l,s,a,u,p,d,c,m,f,h,g,_={},E=tz(e,["name"]);null!=E&&tW(_,["name"],E);let y=tz(e,["displayName"]);null!=y&&tW(_,["displayName"],y);let v=tz(e,["state"]);null!=v&&tW(_,["state"],iP(v));let A=tz(e,["error"]);null!=A&&tW(_,["error"],A);let I=tz(e,["createTime"]);null!=I&&tW(_,["createTime"],I);let T=tz(e,["startTime"]);null!=T&&tW(_,["startTime"],T);let C=tz(e,["endTime"]);null!=C&&tW(_,["endTime"],C);let S=tz(e,["updateTime"]);null!=S&&tW(_,["updateTime"],S);let O=tz(e,["model"]);null!=O&&tW(_,["model"],O);let b=tz(e,["inputConfig"]);null!=b&&tW(_,["src"],(r={},null!=(o=tz(n=b,["instancesFormat"]))&&tW(r,["format"],o),null!=(l=tz(n,["gcsSource","uris"]))&&tW(r,["gcsUri"],l),null!=(s=tz(n,["bigquerySource","inputUri"]))&&tW(r,["bigqueryUri"],s),null!=(a=tz(n,["vertexMultimodalDatasetSource","datasetName"]))&&tW(r,["vertexDatasetName"],a),r));let P=tz(e,["outputConfig"]);null!=P&&tW(_,["dest"],(t=iO(P),c={},null!=(m=tz(t,["predictionsFormat"]))&&tW(c,["format"],m),null!=(f=tz(t,["gcsDestination","outputUriPrefix"]))&&tW(c,["gcsUri"],f),null!=(h=tz(t,["bigqueryDestination","outputUri"]))&&tW(c,["bigqueryUri"],h),null!=(g=tz(t,["vertexMultimodalDatasetDestination"]))&&tW(c,["vertexDataset"],(u={},null!=(p=tz(i=g,["bigqueryDestination","outputUri"]))&&tW(u,["bigqueryDestination"],p),null!=(d=tz(i,["displayName"]))&&tW(u,["displayName"],d),u)),c));let R=tz(e,["outputInfo"]);null!=R&&tW(_,["outputInfo"],R);let N=tz(e,["completionStats"]);return null!=N&&tW(_,["completionStats"],N),_}function iw(e){let t={},n=tz(e,["parts"]);if(null!=n){let e=n;Array.isArray(e)&&(e=e.map(e=>{var t;let n,i,r,o,l,s,a,u,p,d,c,m,f,h,g,_,E;return n={},null!=(i=tz(t=e,["mediaResolution"]))&&tW(n,["mediaResolution"],i),null!=(r=tz(t,["toolCall"]))&&tW(n,["toolCall"],r),null!=(o=tz(t,["toolResponse"]))&&tW(n,["toolResponse"],o),null!=(l=tz(t,["audioTranscription"]))&&tW(n,["audioTranscription"],l),null!=(s=tz(t,["codeExecutionResult"]))&&tW(n,["codeExecutionResult"],s),null!=(a=tz(t,["executableCode"]))&&tW(n,["executableCode"],a),null!=(u=tz(t,["fileData"]))&&tW(n,["fileData"],function(e){let t={};if(void 0!==tz(e,["displayName"]))throw Error("displayName parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let n=tz(e,["fileUri"]);null!=n&&tW(t,["fileUri"],n);let i=tz(e,["mimeType"]);return null!=i&&tW(t,["mimeType"],i),t}(u)),null!=(p=tz(t,["functionCall"]))&&tW(n,["functionCall"],function(e){let t={},n=tz(e,["args"]);null!=n&&tW(t,["args"],n);let i=tz(e,["id"]);null!=i&&tW(t,["id"],i);let r=tz(e,["name"]);if(null!=r&&tW(t,["name"],r),void 0!==tz(e,["partialArgs"]))throw Error("partialArgs parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==tz(e,["willContinue"]))throw Error("willContinue parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");return t}(p)),null!=(d=tz(t,["functionResponse"]))&&tW(n,["functionResponse"],d),null!=(c=tz(t,["inlineData"]))&&tW(n,["inlineData"],function(e){let t={},n=tz(e,["data"]);if(null!=n&&tW(t,["data"],n),void 0!==tz(e,["displayName"]))throw Error("displayName parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let i=tz(e,["mimeType"]);return null!=i&&tW(t,["mimeType"],i),t}(c)),null!=(m=tz(t,["text"]))&&tW(n,["text"],m),null!=(f=tz(t,["thought"]))&&tW(n,["thought"],f),null!=(h=tz(t,["thoughtSignature"]))&&tW(n,["thoughtSignature"],h),null!=(g=tz(t,["videoMetadata"]))&&tW(n,["videoMetadata"],g),null!=(_=tz(t,["partMetadata"]))&&tW(n,["partMetadata"],_),null!=(E=tz(t,["mediaProcessing"]))&&tW(n,["mediaProcessing"],E),n})),tW(t,["parts"],e)}let i=tz(e,["role"]);return null!=i&&tW(t,["role"],i),t}function iD(e,t){let n={},i=tz(t,["model"]);null!=i&&tW(n,["_url","model"],n7(e,i));let r=tz(t,["src"]);null!=r&&tW(n,["batch","inputConfig"],function(e,t){let n={};if(void 0!==tz(t,["format"]))throw Error("format parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==tz(t,["gcsUri"]))throw Error("gcsUri parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==tz(t,["bigqueryUri"]))throw Error("bigqueryUri parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==tz(t,["vertexDatasetName"]))throw Error("vertexDatasetName parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let i=tz(t,["fileName"]);null!=i&&tW(n,["fileName"],i);let r=tz(t,["inlinedRequests"]);if(null!=r){let t=r;Array.isArray(t)&&(t=t.map(t=>(function(e,t){let n={},i=tz(t,["model"]);null!=i&&tW(n,["request","model"],n7(e,i));let r=tz(t,["contents"]);if(null!=r){let e=im(r);Array.isArray(e)&&(e=e.map(e=>iw(e))),tW(n,["request","contents"],e)}let o=tz(t,["metadata"]);null!=o&&tW(n,["metadata"],o);let l=tz(t,["config"]);return null!=l&&tW(n,["request","generationConfig"],function(e,t,n){var i;let r,o,l,s,a={},u=tz(t,["serviceTier"]);void 0!==n&&null!=u&&tW(n,["serviceTier"],u);let p=tz(t,["systemInstruction"]);void 0!==n&&null!=p&&tW(n,["systemInstruction"],iw(id(p)));let d=tz(t,["temperature"]);null!=d&&tW(a,["temperature"],d);let c=tz(t,["topP"]);null!=c&&tW(a,["topP"],c);let m=tz(t,["topK"]);null!=m&&tW(a,["topK"],m);let f=tz(t,["candidateCount"]);null!=f&&tW(a,["candidateCount"],f);let h=tz(t,["maxOutputTokens"]);null!=h&&tW(a,["maxOutputTokens"],h);let g=tz(t,["stopSequences"]);null!=g&&tW(a,["stopSequences"],g);let _=tz(t,["responseLogprobs"]);null!=_&&tW(a,["responseLogprobs"],_);let E=tz(t,["logprobs"]);null!=E&&tW(a,["logprobs"],E);let y=tz(t,["presencePenalty"]);null!=y&&tW(a,["presencePenalty"],y);let v=tz(t,["frequencyPenalty"]);null!=v&&tW(a,["frequencyPenalty"],v);let A=tz(t,["seed"]);null!=A&&tW(a,["seed"],A);let I=tz(t,["responseMimeType"]);null!=I&&tW(a,["responseMimeType"],I);let T=tz(t,["responseSchema"]);null!=T&&tW(a,["responseSchema"],ih(T));let C=tz(t,["responseJsonSchema"]);if(null!=C&&tW(a,["responseJsonSchema"],C),void 0!==tz(t,["routingConfig"]))throw Error("routingConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==tz(t,["modelSelectionConfig"]))throw Error("modelSelectionConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let S=tz(t,["safetySettings"]);if(void 0!==n&&null!=S){let e=S;Array.isArray(e)&&(e=e.map(e=>(function(e){let t={},n=tz(e,["category"]);if(null!=n&&tW(t,["category"],n),void 0!==tz(e,["method"]))throw Error("method parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let i=tz(e,["threshold"]);return null!=i&&tW(t,["threshold"],i),t})(e))),tW(n,["safetySettings"],e)}let O=tz(t,["tools"]);if(void 0!==n&&null!=O){let e=iy(O);Array.isArray(e)&&(e=e.map(e=>(function(e){let t={};if(void 0!==tz(e,["retrieval"]))throw Error("retrieval parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let n=tz(e,["googleMaps"]);null!=n&&tW(t,["googleMaps"],function(e){let t={},n=tz(e,["authConfig"]);null!=n&&tW(t,["authConfig"],function(e){let t={},n=tz(e,["apiKey"]);if(null!=n&&tW(t,["apiKey"],n),void 0!==tz(e,["apiKeyConfig"]))throw Error("apiKeyConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==tz(e,["authType"]))throw Error("authType parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==tz(e,["googleServiceAccountConfig"]))throw Error("googleServiceAccountConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==tz(e,["httpBasicAuthConfig"]))throw Error("httpBasicAuthConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==tz(e,["oauthConfig"]))throw Error("oauthConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==tz(e,["oidcConfig"]))throw Error("oidcConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");return t}(n));let i=tz(e,["enableWidget"]);if(null!=i&&tW(t,["enableWidget"],i),void 0!==tz(e,["groundingTypes"]))throw Error("groundingTypes parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");return t}(n));let i=tz(e,["mcpServers"]);if(null!=i){let e=i;Array.isArray(e)&&(e=e.map(e=>e)),tW(t,["mcpServers"],e)}let r=tz(e,["codeExecution"]);null!=r&&tW(t,["codeExecution"],r);let o=tz(e,["computerUse"]);if(null!=o&&tW(t,["computerUse"],o),void 0!==tz(e,["enterpriseWebSearch"]))throw Error("enterpriseWebSearch parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==tz(e,["exaAiSearch"]))throw Error("exaAiSearch parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let l=tz(e,["functionDeclarations"]);if(null!=l){let e=l;Array.isArray(e)&&(e=e.map(e=>e)),tW(t,["functionDeclarations"],e)}let s=tz(e,["googleSearch"]);null!=s&&tW(t,["googleSearch"],function(e){let t={};if(void 0!==tz(e,["blockingConfidence"]))throw Error("blockingConfidence parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==tz(e,["excludeDomains"]))throw Error("excludeDomains parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let n=tz(e,["searchTypes"]);null!=n&&tW(t,["searchTypes"],n);let i=tz(e,["timeRangeFilter"]);return null!=i&&tW(t,["timeRangeFilter"],i),t}(s));let a=tz(e,["googleSearchRetrieval"]);if(null!=a&&tW(t,["googleSearchRetrieval"],a),void 0!==tz(e,["parallelAiSearch"]))throw Error("parallelAiSearch parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let u=tz(e,["urlContext"]);null!=u&&tW(t,["urlContext"],u);let p=tz(e,["fileSearch"]);return null!=p&&tW(t,["fileSearch"],p),t})(iE(e)))),tW(n,["tools"],e)}let b=tz(t,["toolConfig"]);if(void 0!==n&&null!=b&&tW(n,["toolConfig"],(r={},null!=(o=tz(i=b,["functionCallingConfig"]))&&tW(r,["functionCallingConfig"],function(e){let t={},n=tz(e,["allowedFunctionNames"]);null!=n&&tW(t,["allowedFunctionNames"],n);let i=tz(e,["mode"]);if(null!=i&&tW(t,["mode"],i),void 0!==tz(e,["streamFunctionCallArguments"]))throw Error("streamFunctionCallArguments parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");return t}(o)),null!=(l=tz(i,["retrievalConfig"]))&&tW(r,["retrievalConfig"],l),null!=(s=tz(i,["includeServerSideToolInvocations"]))&&tW(r,["includeServerSideToolInvocations"],s),r)),void 0!==tz(t,["labels"]))throw Error("labels parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let P=tz(t,["cachedContent"]);void 0!==n&&null!=P&&tW(n,["cachedContent"],iv(e,P));let R=tz(t,["responseModalities"]);null!=R&&tW(a,["responseModalities"],R);let N=tz(t,["mediaResolution"]);null!=N&&tW(a,["mediaResolution"],N);let w=tz(t,["speechConfig"]);if(null!=w&&tW(a,["speechConfig"],ig(w)),void 0!==tz(t,["audioTimestamp"]))throw Error("audioTimestamp parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let D=tz(t,["thinkingConfig"]);null!=D&&tW(a,["thinkingConfig"],D);let G=tz(t,["audioTranscriptionConfig"]);null!=G&&tW(a,["audioTranscriptionConfig"],G);let M=tz(t,["imageConfig"]);null!=M&&tW(a,["imageConfig"],function(e){let t={},n=tz(e,["aspectRatio"]);null!=n&&tW(t,["aspectRatio"],n);let i=tz(e,["imageSize"]);if(null!=i&&tW(t,["imageSize"],i),void 0!==tz(e,["personGeneration"]))throw Error("personGeneration parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==tz(e,["outputMimeType"]))throw Error("outputMimeType parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==tz(e,["outputCompressionQuality"]))throw Error("outputCompressionQuality parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==tz(e,["imageOutputOptions"]))throw Error("imageOutputOptions parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==tz(e,["prominentPeople"]))throw Error("prominentPeople parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");return t}(M));let k=tz(t,["enableEnhancedCivicAnswers"]);if(null!=k&&tW(a,["enableEnhancedCivicAnswers"],k),void 0!==tz(t,["modelArmorConfig"]))throw Error("modelArmorConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");return a}(e,l,tz(n,["request"],{}))),n})(e,t))),tW(n,["requests","requests"],t)}return n}(e,iS(e,r)));let o=tz(t,["config"]);return null!=o&&function(e,t){let n=tz(e,["displayName"]);if(void 0!==t&&null!=n&&tW(t,["batch","displayName"],n),void 0!==tz(e,["dest"]))throw Error("dest parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let i=tz(e,["webhookConfig"]);void 0!==t&&null!=i&&tW(t,["batch","webhookConfig"],i)}(o,n),n}(eR=tX||(tX={})).PAGED_ITEM_BATCH_JOBS="batchJobs",eR.PAGED_ITEM_MODELS="models",eR.PAGED_ITEM_TUNING_JOBS="tuningJobs",eR.PAGED_ITEM_FILES="files",eR.PAGED_ITEM_CACHED_CONTENTS="cachedContents",eR.PAGED_ITEM_FILE_SEARCH_STORES="fileSearchStores",eR.PAGED_ITEM_DOCUMENTS="documents",eR.PAGED_ITEM_SKILLS="skills";class iG{constructor(e,t,n,i){this.pageInternal=[],this.paramsInternal={},this.requestInternal=t,this.init(e,n,i)}init(e,t,n){var i,r;this.nameInternal=e,this.pageInternal=t[this.nameInternal]||[],this.sdkHttpResponseInternal=null==t?void 0:t.sdkHttpResponse,this.idxInternal=0;let o={config:{}};(o=n&&0!==Object.keys(n).length?"object"==typeof n?Object.assign({},n):n:{config:{}}).config&&(o.config.pageToken=t.nextPageToken),this.paramsInternal=o,this.pageInternalSize=null!=(r=null==(i=o.config)?void 0:i.pageSize)?r:this.pageInternal.length}initNextPage(e){this.init(this.nameInternal,e,this.paramsInternal)}get page(){return this.pageInternal}get name(){return this.nameInternal}get pageSize(){return this.pageInternalSize}get sdkHttpResponse(){return this.sdkHttpResponseInternal}get params(){return this.paramsInternal}get pageLength(){return this.pageInternal.length}getItem(e){return this.pageInternal[e]}[Symbol.asyncIterator](){return{next:async()=>{if(this.idxInternal>=this.pageLength)if(!this.hasNextPage())return{value:void 0,done:!0};else await this.nextPage();let e=this.getItem(this.idxInternal);return this.idxInternal+=1,{value:e,done:!1}},return:async()=>({value:void 0,done:!0})}}async nextPage(){if(!this.hasNextPage())throw Error("No more pages to fetch.");let e=await this.requestInternal(this.params);return this.initNextPage(e),this.page}hasNextPage(){var e;return(null==(e=this.params.config)?void 0:e.pageToken)!==void 0}}class iM extends t${constructor(e){super(),this.apiClient=e,this.list=async(e={})=>new iG(tX.PAGED_ITEM_BATCH_JOBS,e=>this.listInternal(e),await this.listInternal(e),e),this.create=async e=>(this.apiClient.isVertexAI()&&(e.config=this.formatDestination(e.src,e.config)),this.createInternal(e)),this.createEmbeddings=async e=>{if(console.warn("batches.createEmbeddings() is experimental and may change without notice."),this.apiClient.isVertexAI())throw Error("Gemini Enterprise Agent Platform (previously known as Vertex AI) does not support batches.createEmbeddings.");return this.createEmbeddingsInternal(e)}}createInlinedGenerateContentRequest(e){let t=iD(this.apiClient,e),n=tK("{model}:batchGenerateContent",t._url),i=t.batch.inputConfig.requests,r=i.requests,o=[];for(let e of r){let t=Object.assign({},e);if(t.systemInstruction){let e=t.systemInstruction;delete t.systemInstruction;let n=t.request;n.systemInstruction=e,t.request=n}o.push(t)}return i.requests=o,delete t.config,delete t._url,delete t._query,{path:n,body:t}}getGcsUri(e){return"string"==typeof e?e.startsWith("gs://")?e:void 0:!Array.isArray(e)&&e.gcsUri&&e.gcsUri.length>0?e.gcsUri[0]:void 0}getBigqueryUri(e){return"string"==typeof e?e.startsWith("bq://")?e:void 0:Array.isArray(e)?void 0:e.bigqueryUri}formatDestination(e,t){let n=t?Object.assign({},t):{},i=Date.now().toString();if(n.displayName||(n.displayName=`genaiBatchJob_${i}`),void 0===n.dest){let t=this.getGcsUri(e),r=this.getBigqueryUri(e);if(t)t.endsWith(".jsonl")?n.dest=`${t.slice(0,-6)}/dest`:n.dest=`${t}_dest_${i}`;else if(r)n.dest=`${r}_dest_${i}`;else throw Error("Unsupported source for Gemini Enterprise Agent Platform (previously known as Vertex AI): No GCS or BigQuery URI found.")}return n}async createInternal(e){var t,n,i,r,o;let l="",s={};if(this.apiClient.isVertexAI()){let i,r,a,u,p=(o=this.apiClient,i={},null!=(r=tz(e,["model"]))&&tW(i,["model"],n7(o,r)),null!=(a=tz(e,["src"]))&&tW(i,["inputConfig"],function(e){let t={},n=tz(e,["format"]);null!=n&&tW(t,["instancesFormat"],n);let i=tz(e,["gcsUri"]);null!=i&&tW(t,["gcsSource","uris"],i);let r=tz(e,["bigqueryUri"]);null!=r&&tW(t,["bigquerySource","inputUri"],r);let o=tz(e,["vertexDatasetName"]);if(null!=o&&tW(t,["vertexMultimodalDatasetSource","datasetName"],o),void 0!==tz(e,["fileName"]))throw Error("fileName parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.");if(void 0!==tz(e,["inlinedRequests"]))throw Error("inlinedRequests parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.");return t}(iS(o,a))),null!=(u=tz(e,["config"]))&&function(e,t){let n=tz(e,["displayName"]);void 0!==t&&null!=n&&tW(t,["displayName"],n);let i=tz(e,["dest"]);if(void 0!==t&&null!=i&&tW(t,["outputConfig"],function(e){var t;let n,i,r,o={},l=tz(e,["format"]);null!=l&&tW(o,["predictionsFormat"],l);let s=tz(e,["gcsUri"]);null!=s&&tW(o,["gcsDestination","outputUriPrefix"],s);let a=tz(e,["bigqueryUri"]);null!=a&&tW(o,["bigqueryDestination","outputUri"],a);let u=tz(e,["vertexDataset"]);if(null!=u&&tW(o,["vertexMultimodalDatasetDestination"],(n={},null!=(i=tz(t=u,["bigqueryDestination"]))&&tW(n,["bigqueryDestination","outputUri"],i),null!=(r=tz(t,["displayName"]))&&tW(n,["displayName"],r),n)),void 0!==tz(e,["fileName"]))throw Error("fileName parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.");if(void 0!==tz(e,["inlinedResponses"]))throw Error("inlinedResponses parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.");if(void 0!==tz(e,["inlinedEmbedContentResponses"]))throw Error("inlinedEmbedContentResponses parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.");return o}(function(e){if("string"!=typeof e)return e;if(e.startsWith("gs://"))return{format:"jsonl",gcsUri:e};if(e.startsWith("bq://"))return{format:"bigquery",bigqueryUri:e};throw Error(`Unsupported destination: ${e}`)}(i))),void 0!==tz(e,["webhookConfig"]))throw Error("webhookConfig parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.")}(u,i),i);return l=tK("batchPredictionJobs",p._url),s=p._query,delete p._url,delete p._query,this.apiClient.request({path:l,queryParams:s,body:JSON.stringify(p),httpMethod:"POST",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal}).then(e=>e.json()).then(e=>iN(e))}{let t=iD(this.apiClient,e);return l=tK("{model}:batchGenerateContent",t._url),s=t._query,delete t._url,delete t._query,this.apiClient.request({path:l,queryParams:s,body:JSON.stringify(t),httpMethod:"POST",httpOptions:null==(i=e.config)?void 0:i.httpOptions,abortSignal:null==(r=e.config)?void 0:r.abortSignal}).then(e=>e.json()).then(e=>iR(e))}}async createEmbeddingsInternal(e){var t,n,i,r,o;let l="",s={};if(this.apiClient.isVertexAI())throw Error("This method is only supported by the Gemini Developer API.");{let a,u,p,d,c,m,f,h,g=(i=this.apiClient,d={},null!=(c=tz(e,["model"]))&&tW(d,["_url","model"],n7(i,c)),null!=(m=tz(e,["src"]))&&tW(d,["batch","inputConfig"],(r=i,a={},null!=(u=tz(o=m,["fileName"]))&&tW(a,["file_name"],u),null!=(p=tz(o,["inlinedRequests"]))&&tW(a,["requests"],function(e,t){let n={},i=tz(t,["contents"]);if(null!=i){let t=ic(e,i);Array.isArray(t)&&(t=t.map(e=>e)),tW(n,["requests[]","request","content"],t)}let r=tz(t,["config"]);return null!=r&&(tW(n,["_self"],function(e,t){let n=tz(e,["taskType"]);void 0!==t&&null!=n&&tW(t,["requests[]","taskType"],n);let i=tz(e,["title"]);void 0!==t&&null!=i&&tW(t,["requests[]","title"],i);let r=tz(e,["outputDimensionality"]);if(void 0!==t&&null!=r&&tW(t,["requests[]","outputDimensionality"],r),void 0!==tz(e,["mimeType"]))throw Error("mimeType parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==tz(e,["autoTruncate"]))throw Error("autoTruncate parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==tz(e,["documentOcr"]))throw Error("documentOcr parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==tz(e,["audioTrackExtraction"]))throw Error("audioTrackExtraction parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");return{}}(r,n)),!function(e,t){for(let[n,i]of Object.entries(t)){let t=n.split("."),r=i.split("."),o=new Set,l=-1;for(let e=0;e<t.length;e++)if("*"===t[e]){l=e;break}if(-1!==l&&r.length>l)for(let e=l;e<r.length;e++){let t=r[e];"*"===t||t.endsWith("[]")||t.endsWith("[0]")||o.add(t)}!function e(t,n,i,r,o){if(r>=n.length||"object"!=typeof t||null===t)return;let l=n[r];if(l.endsWith("[]")){let s=l.slice(0,-2);if(s in t&&Array.isArray(t[s]))for(let l of t[s])e(l,n,i,r+1,o)}else if("*"===l){if("object"==typeof t&&null!==t&&!Array.isArray(t)){let e=Object.keys(t).filter(e=>!e.startsWith("_")&&!o.has(e)),n={};for(let i of e)n[i]=t[i];for(let[e,o]of Object.entries(n)){let n=[];for(let t of i.slice(r))"*"===t?n.push(e):n.push(t);tW(t,n,o)}for(let n of e)delete t[n]}}else l in t&&e(t[l],n,i,r+1,o)}(e,t,r,0,o)}}(n,{"requests[].*":"requests[].request.*"})),n}(r,p)),a)),null!=(f=tz(e,["config"]))&&(h=tz(f,["displayName"]),void 0!==d&&null!=h&&tW(d,["batch","displayName"],h)),d);return l=tK("{model}:asyncBatchEmbedContent",g._url),s=g._query,delete g._url,delete g._query,this.apiClient.request({path:l,queryParams:s,body:JSON.stringify(g),httpMethod:"POST",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal}).then(e=>e.json()).then(e=>iR(e))}}async get(e){var t,n,i,r,o,l;let s="",a={};if(this.apiClient.isVertexAI()){let i,r,l=(o=this.apiClient,i={},null!=(r=tz(e,["name"]))&&tW(i,["_url","name"],ib(o,r)),i);return s=tK("batchPredictionJobs/{name}",l._url),a=l._query,delete l._url,delete l._query,this.apiClient.request({path:s,queryParams:a,body:JSON.stringify(l),httpMethod:"GET",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal}).then(e=>e.json()).then(e=>iN(e))}{let t,n,o=(l=this.apiClient,t={},null!=(n=tz(e,["name"]))&&tW(t,["_url","name"],ib(l,n)),t);return s=tK("batches/{name}",o._url),a=o._query,delete o._url,delete o._query,this.apiClient.request({path:s,queryParams:a,body:JSON.stringify(o),httpMethod:"GET",httpOptions:null==(i=e.config)?void 0:i.httpOptions,abortSignal:null==(r=e.config)?void 0:r.abortSignal}).then(e=>e.json()).then(e=>iR(e))}}async cancel(e){var t,n,i,r,o,l;let s="",a={};if(this.apiClient.isVertexAI()){let i,r,l=(o=this.apiClient,i={},null!=(r=tz(e,["name"]))&&tW(i,["_url","name"],ib(o,r)),i);s=tK("batchPredictionJobs/{name}:cancel",l._url),a=l._query,delete l._url,delete l._query,await this.apiClient.request({path:s,queryParams:a,body:JSON.stringify(l),httpMethod:"POST",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal})}else{let t,n,o=(l=this.apiClient,t={},null!=(n=tz(e,["name"]))&&tW(t,["_url","name"],ib(l,n)),t);s=tK("batches/{name}:cancel",o._url),a=o._query,delete o._url,delete o._query,await this.apiClient.request({path:s,queryParams:a,body:JSON.stringify(o),httpMethod:"POST",httpOptions:null==(i=e.config)?void 0:i.httpOptions,abortSignal:null==(r=e.config)?void 0:r.abortSignal})}}async listInternal(e){var t,n,i,r;let o="",l={};if(this.apiClient.isVertexAI()){let i,r,s,a,u,p=(i={},null!=(r=tz(e,["config"]))&&(s=tz(r,["pageSize"]),void 0!==i&&null!=s&&tW(i,["_query","pageSize"],s),a=tz(r,["pageToken"]),void 0!==i&&null!=a&&tW(i,["_query","pageToken"],a),u=tz(r,["filter"]),void 0!==i&&null!=u&&tW(i,["_query","filter"],u)),i);return o=tK("batchPredictionJobs",p._url),l=p._query,delete p._url,delete p._query,this.apiClient.request({path:o,queryParams:l,body:JSON.stringify(p),httpMethod:"GET",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal}).then(e=>e.json().then(t=>(t.sdkHttpResponse={headers:e.headers},t))).then(e=>{let t=function(e){let t={},n=tz(e,["sdkHttpResponse"]);null!=n&&tW(t,["sdkHttpResponse"],n);let i=tz(e,["nextPageToken"]);null!=i&&tW(t,["nextPageToken"],i);let r=tz(e,["batchPredictionJobs"]);if(null!=r){let e=r;Array.isArray(e)&&(e=e.map(e=>iN(e))),tW(t,["batchJobs"],e)}return t}(e),n=new nK;return Object.assign(n,t),n})}{let t,n,s=(t={},null!=(n=tz(e,["config"]))&&function(e,t){let n=tz(e,["pageSize"]);void 0!==t&&null!=n&&tW(t,["_query","pageSize"],n);let i=tz(e,["pageToken"]);if(void 0!==t&&null!=i&&tW(t,["_query","pageToken"],i),void 0!==tz(e,["filter"]))throw Error("filter parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.")}(n,t),t);return o=tK("batches",s._url),l=s._query,delete s._url,delete s._query,this.apiClient.request({path:o,queryParams:l,body:JSON.stringify(s),httpMethod:"GET",httpOptions:null==(i=e.config)?void 0:i.httpOptions,abortSignal:null==(r=e.config)?void 0:r.abortSignal}).then(e=>e.json().then(t=>(t.sdkHttpResponse={headers:e.headers},t))).then(e=>{let t=function(e){let t={},n=tz(e,["sdkHttpResponse"]);null!=n&&tW(t,["sdkHttpResponse"],n);let i=tz(e,["nextPageToken"]);null!=i&&tW(t,["nextPageToken"],i);let r=tz(e,["operations"]);if(null!=r){let e=r;Array.isArray(e)&&(e=e.map(e=>iR(e))),tW(t,["batchJobs"],e)}return t}(e),n=new nK;return Object.assign(n,t),n})}}async delete(e){var t,n,i,r,o,l;let s="",a={};if(this.apiClient.isVertexAI()){let i,r,l=(o=this.apiClient,i={},null!=(r=tz(e,["name"]))&&tW(i,["_url","name"],ib(o,r)),i);return s=tK("batchPredictionJobs/{name}",l._url),a=l._query,delete l._url,delete l._query,this.apiClient.request({path:s,queryParams:a,body:JSON.stringify(l),httpMethod:"DELETE",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal}).then(e=>e.json().then(t=>(t.sdkHttpResponse={headers:e.headers},t))).then(e=>{let t,n,i,r,o;return t={},null!=(n=tz(e,["sdkHttpResponse"]))&&tW(t,["sdkHttpResponse"],n),null!=(i=tz(e,["name"]))&&tW(t,["name"],i),null!=(r=tz(e,["done"]))&&tW(t,["done"],r),null!=(o=tz(e,["error"]))&&tW(t,["error"],o),t})}{let t,n,o=(l=this.apiClient,t={},null!=(n=tz(e,["name"]))&&tW(t,["_url","name"],ib(l,n)),t);return s=tK("batches/{name}",o._url),a=o._query,delete o._url,delete o._query,this.apiClient.request({path:s,queryParams:a,body:JSON.stringify(o),httpMethod:"DELETE",httpOptions:null==(i=e.config)?void 0:i.httpOptions,abortSignal:null==(r=e.config)?void 0:r.abortSignal}).then(e=>e.json().then(t=>(t.sdkHttpResponse={headers:e.headers},t))).then(e=>{let t,n,i,r,o;return t={},null!=(n=tz(e,["sdkHttpResponse"]))&&tW(t,["sdkHttpResponse"],n),null!=(i=tz(e,["name"]))&&tW(t,["name"],i),null!=(r=tz(e,["done"]))&&tW(t,["done"],r),null!=(o=tz(e,["error"]))&&tW(t,["error"],o),t})}}}function ik(e){let t={},n=tz(e,["parts"]);if(null!=n){let e=n;Array.isArray(e)&&(e=e.map(e=>{var t;let n,i,r,o,l,s,a,u,p,d,c,m,f,h,g,_,E;return n={},null!=(i=tz(t=e,["mediaResolution"]))&&tW(n,["mediaResolution"],i),null!=(r=tz(t,["toolCall"]))&&tW(n,["toolCall"],r),null!=(o=tz(t,["toolResponse"]))&&tW(n,["toolResponse"],o),null!=(l=tz(t,["audioTranscription"]))&&tW(n,["audioTranscription"],l),null!=(s=tz(t,["codeExecutionResult"]))&&tW(n,["codeExecutionResult"],s),null!=(a=tz(t,["executableCode"]))&&tW(n,["executableCode"],a),null!=(u=tz(t,["fileData"]))&&tW(n,["fileData"],function(e){let t={};if(void 0!==tz(e,["displayName"]))throw Error("displayName parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let n=tz(e,["fileUri"]);null!=n&&tW(t,["fileUri"],n);let i=tz(e,["mimeType"]);return null!=i&&tW(t,["mimeType"],i),t}(u)),null!=(p=tz(t,["functionCall"]))&&tW(n,["functionCall"],function(e){let t={},n=tz(e,["args"]);null!=n&&tW(t,["args"],n);let i=tz(e,["id"]);null!=i&&tW(t,["id"],i);let r=tz(e,["name"]);if(null!=r&&tW(t,["name"],r),void 0!==tz(e,["partialArgs"]))throw Error("partialArgs parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==tz(e,["willContinue"]))throw Error("willContinue parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");return t}(p)),null!=(d=tz(t,["functionResponse"]))&&tW(n,["functionResponse"],d),null!=(c=tz(t,["inlineData"]))&&tW(n,["inlineData"],function(e){let t={},n=tz(e,["data"]);if(null!=n&&tW(t,["data"],n),void 0!==tz(e,["displayName"]))throw Error("displayName parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let i=tz(e,["mimeType"]);return null!=i&&tW(t,["mimeType"],i),t}(c)),null!=(m=tz(t,["text"]))&&tW(n,["text"],m),null!=(f=tz(t,["thought"]))&&tW(n,["thought"],f),null!=(h=tz(t,["thoughtSignature"]))&&tW(n,["thoughtSignature"],h),null!=(g=tz(t,["videoMetadata"]))&&tW(n,["videoMetadata"],g),null!=(_=tz(t,["partMetadata"]))&&tW(n,["partMetadata"],_),null!=(E=tz(t,["mediaProcessing"]))&&tW(n,["mediaProcessing"],E),n})),tW(t,["parts"],e)}let i=tz(e,["role"]);return null!=i&&tW(t,["role"],i),t}function iU(e){let t={},n=tz(e,["parts"]);if(null!=n){let e=n;Array.isArray(e)&&(e=e.map(e=>(function(e){let t={},n=tz(e,["mediaResolution"]);if(null!=n&&tW(t,["mediaResolution"],n),void 0!==tz(e,["toolCall"]))throw Error("toolCall parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.");if(void 0!==tz(e,["toolResponse"]))throw Error("toolResponse parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.");let i=tz(e,["audioTranscription"]);null!=i&&tW(t,["audioTranscription"],i);let r=tz(e,["codeExecutionResult"]);null!=r&&tW(t,["codeExecutionResult"],r);let o=tz(e,["executableCode"]);null!=o&&tW(t,["executableCode"],o);let l=tz(e,["fileData"]);null!=l&&tW(t,["fileData"],l);let s=tz(e,["functionCall"]);null!=s&&tW(t,["functionCall"],s);let a=tz(e,["functionResponse"]);null!=a&&tW(t,["functionResponse"],a);let u=tz(e,["inlineData"]);null!=u&&tW(t,["inlineData"],u);let p=tz(e,["text"]);null!=p&&tW(t,["text"],p);let d=tz(e,["thought"]);null!=d&&tW(t,["thought"],d);let c=tz(e,["thoughtSignature"]);null!=c&&tW(t,["thoughtSignature"],c);let m=tz(e,["videoMetadata"]);if(null!=m&&tW(t,["videoMetadata"],m),void 0!==tz(e,["partMetadata"]))throw Error("partMetadata parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.");let f=tz(e,["mediaProcessing"]);return null!=f&&tW(t,["mediaProcessing"],f),t})(e))),tW(t,["parts"],e)}let i=tz(e,["role"]);return null!=i&&tW(t,["role"],i),t}class ix extends t${constructor(e){super(),this.apiClient=e,this.list=async(e={})=>new iG(tX.PAGED_ITEM_CACHED_CONTENTS,e=>this.listInternal(e),await this.listInternal(e),e)}async create(e){var t,n,i,r,o,l;let s="",a={};if(this.apiClient.isVertexAI()){let i,r,l,u=(o=this.apiClient,i={},null!=(r=tz(e,["model"]))&&tW(i,["model"],ie(o,r)),null!=(l=tz(e,["config"]))&&function(e,t){let n=tz(e,["ttl"]);void 0!==t&&null!=n&&tW(t,["ttl"],n);let i=tz(e,["expireTime"]);void 0!==t&&null!=i&&tW(t,["expireTime"],i);let r=tz(e,["displayName"]);void 0!==t&&null!=r&&tW(t,["displayName"],r);let o=tz(e,["contents"]);if(void 0!==t&&null!=o){let e=im(o);Array.isArray(e)&&(e=e.map(e=>iU(e))),tW(t,["contents"],e)}let l=tz(e,["systemInstruction"]);void 0!==t&&null!=l&&tW(t,["systemInstruction"],iU(id(l)));let s=tz(e,["tools"]);if(void 0!==t&&null!=s){let e=s;Array.isArray(e)&&(e=e.map(e=>(function(e){let t={},n=tz(e,["retrieval"]);null!=n&&tW(t,["retrieval"],n);let i=tz(e,["googleMaps"]);null!=i&&tW(t,["googleMaps"],i);let r=tz(e,["mcpServers"]);if(null!=r){let e=r;Array.isArray(e)&&(e=e.map(e=>(function(e){if(void 0!==tz(e,["name"]))throw Error("name parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.");if(void 0!==tz(e,["streamableHttpTransport"]))throw Error("streamableHttpTransport parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.");return{}})(e))),tW(t,["mcpServers"],e)}let o=tz(e,["codeExecution"]);null!=o&&tW(t,["codeExecution"],o);let l=tz(e,["computerUse"]);null!=l&&tW(t,["computerUse"],function(e){let t={},n=tz(e,["enablePromptInjectionDetection"]);null!=n&&tW(t,["enablePromptInjectionDetection"],n);let i=tz(e,["environment"]);null!=i&&tW(t,["environment"],i);let r=tz(e,["excludedPredefinedFunctions"]);if(null!=r&&tW(t,["excludedPredefinedFunctions"],r),void 0!==tz(e,["disabledSafetyPolicies"]))throw Error("disabledSafetyPolicies parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.");return t}(l));let s=tz(e,["enterpriseWebSearch"]);null!=s&&tW(t,["enterpriseWebSearch"],s);let a=tz(e,["exaAiSearch"]);null!=a&&tW(t,["exaAiSearch"],a);let u=tz(e,["functionDeclarations"]);if(null!=u){let e=u;Array.isArray(e)&&(e=e.map(e=>e)),tW(t,["functionDeclarations"],e)}let p=tz(e,["googleSearch"]);null!=p&&tW(t,["googleSearch"],p);let d=tz(e,["googleSearchRetrieval"]);null!=d&&tW(t,["googleSearchRetrieval"],d);let c=tz(e,["parallelAiSearch"]);null!=c&&tW(t,["parallelAiSearch"],c);let m=tz(e,["urlContext"]);if(null!=m&&tW(t,["urlContext"],m),void 0!==tz(e,["fileSearch"]))throw Error("fileSearch parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.");return t})(e))),tW(t,["tools"],e)}let a=tz(e,["toolConfig"]);void 0!==t&&null!=a&&tW(t,["toolConfig"],function(e){let t={},n=tz(e,["functionCallingConfig"]);null!=n&&tW(t,["functionCallingConfig"],n);let i=tz(e,["retrievalConfig"]);if(null!=i&&tW(t,["retrievalConfig"],i),void 0!==tz(e,["includeServerSideToolInvocations"]))throw Error("includeServerSideToolInvocations parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.");return t}(a));let u=tz(e,["kmsKeyName"]);void 0!==t&&null!=u&&tW(t,["encryption_spec","kmsKeyName"],u)}(l,i),i);return s=tK("cachedContents",u._url),a=u._query,delete u._url,delete u._query,this.apiClient.request({path:s,queryParams:a,body:JSON.stringify(u),httpMethod:"POST",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal}).then(e=>e.json()).then(e=>e)}{let t,n,o,u=(l=this.apiClient,t={},null!=(n=tz(e,["model"]))&&tW(t,["model"],ie(l,n)),null!=(o=tz(e,["config"]))&&function(e,t){var n;let i,r,o,l,s=tz(e,["ttl"]);void 0!==t&&null!=s&&tW(t,["ttl"],s);let a=tz(e,["expireTime"]);void 0!==t&&null!=a&&tW(t,["expireTime"],a);let u=tz(e,["displayName"]);void 0!==t&&null!=u&&tW(t,["displayName"],u);let p=tz(e,["contents"]);if(void 0!==t&&null!=p){let e=im(p);Array.isArray(e)&&(e=e.map(e=>ik(e))),tW(t,["contents"],e)}let d=tz(e,["systemInstruction"]);void 0!==t&&null!=d&&tW(t,["systemInstruction"],ik(id(d)));let c=tz(e,["tools"]);if(void 0!==t&&null!=c){let e=c;Array.isArray(e)&&(e=e.map(e=>(function(e){let t={};if(void 0!==tz(e,["retrieval"]))throw Error("retrieval parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let n=tz(e,["googleMaps"]);null!=n&&tW(t,["googleMaps"],function(e){let t={},n=tz(e,["authConfig"]);null!=n&&tW(t,["authConfig"],function(e){let t={},n=tz(e,["apiKey"]);if(null!=n&&tW(t,["apiKey"],n),void 0!==tz(e,["apiKeyConfig"]))throw Error("apiKeyConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==tz(e,["authType"]))throw Error("authType parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==tz(e,["googleServiceAccountConfig"]))throw Error("googleServiceAccountConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==tz(e,["httpBasicAuthConfig"]))throw Error("httpBasicAuthConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==tz(e,["oauthConfig"]))throw Error("oauthConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==tz(e,["oidcConfig"]))throw Error("oidcConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");return t}(n));let i=tz(e,["enableWidget"]);if(null!=i&&tW(t,["enableWidget"],i),void 0!==tz(e,["groundingTypes"]))throw Error("groundingTypes parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");return t}(n));let i=tz(e,["mcpServers"]);if(null!=i){let e=i;Array.isArray(e)&&(e=e.map(e=>e)),tW(t,["mcpServers"],e)}let r=tz(e,["codeExecution"]);null!=r&&tW(t,["codeExecution"],r);let o=tz(e,["computerUse"]);if(null!=o&&tW(t,["computerUse"],o),void 0!==tz(e,["enterpriseWebSearch"]))throw Error("enterpriseWebSearch parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==tz(e,["exaAiSearch"]))throw Error("exaAiSearch parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let l=tz(e,["functionDeclarations"]);if(null!=l){let e=l;Array.isArray(e)&&(e=e.map(e=>e)),tW(t,["functionDeclarations"],e)}let s=tz(e,["googleSearch"]);null!=s&&tW(t,["googleSearch"],function(e){let t={};if(void 0!==tz(e,["blockingConfidence"]))throw Error("blockingConfidence parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==tz(e,["excludeDomains"]))throw Error("excludeDomains parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let n=tz(e,["searchTypes"]);null!=n&&tW(t,["searchTypes"],n);let i=tz(e,["timeRangeFilter"]);return null!=i&&tW(t,["timeRangeFilter"],i),t}(s));let a=tz(e,["googleSearchRetrieval"]);if(null!=a&&tW(t,["googleSearchRetrieval"],a),void 0!==tz(e,["parallelAiSearch"]))throw Error("parallelAiSearch parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let u=tz(e,["urlContext"]);null!=u&&tW(t,["urlContext"],u);let p=tz(e,["fileSearch"]);return null!=p&&tW(t,["fileSearch"],p),t})(e))),tW(t,["tools"],e)}let m=tz(e,["toolConfig"]);if(void 0!==t&&null!=m&&tW(t,["toolConfig"],(i={},null!=(r=tz(n=m,["functionCallingConfig"]))&&tW(i,["functionCallingConfig"],function(e){let t={},n=tz(e,["allowedFunctionNames"]);null!=n&&tW(t,["allowedFunctionNames"],n);let i=tz(e,["mode"]);if(null!=i&&tW(t,["mode"],i),void 0!==tz(e,["streamFunctionCallArguments"]))throw Error("streamFunctionCallArguments parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");return t}(r)),null!=(o=tz(n,["retrievalConfig"]))&&tW(i,["retrievalConfig"],o),null!=(l=tz(n,["includeServerSideToolInvocations"]))&&tW(i,["includeServerSideToolInvocations"],l),i)),void 0!==tz(e,["kmsKeyName"]))throw Error("kmsKeyName parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.")}(o,t),t);return s=tK("cachedContents",u._url),a=u._query,delete u._url,delete u._query,this.apiClient.request({path:s,queryParams:a,body:JSON.stringify(u),httpMethod:"POST",httpOptions:null==(i=e.config)?void 0:i.httpOptions,abortSignal:null==(r=e.config)?void 0:r.abortSignal}).then(e=>e.json()).then(e=>e)}}async get(e){var t,n,i,r,o,l;let s="",a={};if(this.apiClient.isVertexAI()){let i,r,l=(o=this.apiClient,i={},null!=(r=tz(e,["name"]))&&tW(i,["_url","name"],iv(o,r)),i);return s=tK("{name}",l._url),a=l._query,delete l._url,delete l._query,this.apiClient.request({path:s,queryParams:a,body:JSON.stringify(l),httpMethod:"GET",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal}).then(e=>e.json()).then(e=>e)}{let t,n,o=(l=this.apiClient,t={},null!=(n=tz(e,["name"]))&&tW(t,["_url","name"],iv(l,n)),t);return s=tK("{name}",o._url),a=o._query,delete o._url,delete o._query,this.apiClient.request({path:s,queryParams:a,body:JSON.stringify(o),httpMethod:"GET",httpOptions:null==(i=e.config)?void 0:i.httpOptions,abortSignal:null==(r=e.config)?void 0:r.abortSignal}).then(e=>e.json()).then(e=>e)}}async delete(e){var t,n,i,r,o,l;let s="",a={};if(this.apiClient.isVertexAI()){let i,r,l=(o=this.apiClient,i={},null!=(r=tz(e,["name"]))&&tW(i,["_url","name"],iv(o,r)),i);return s=tK("{name}",l._url),a=l._query,delete l._url,delete l._query,this.apiClient.request({path:s,queryParams:a,body:JSON.stringify(l),httpMethod:"DELETE",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal}).then(e=>e.json().then(t=>(t.sdkHttpResponse={headers:e.headers},t))).then(e=>{let t,n,i=(t={},null!=(n=tz(e,["sdkHttpResponse"]))&&tW(t,["sdkHttpResponse"],n),t),r=new nk;return Object.assign(r,i),r})}{let t,n,o=(l=this.apiClient,t={},null!=(n=tz(e,["name"]))&&tW(t,["_url","name"],iv(l,n)),t);return s=tK("{name}",o._url),a=o._query,delete o._url,delete o._query,this.apiClient.request({path:s,queryParams:a,body:JSON.stringify(o),httpMethod:"DELETE",httpOptions:null==(i=e.config)?void 0:i.httpOptions,abortSignal:null==(r=e.config)?void 0:r.abortSignal}).then(e=>e.json().then(t=>(t.sdkHttpResponse={headers:e.headers},t))).then(e=>{let t,n,i=(t={},null!=(n=tz(e,["sdkHttpResponse"]))&&tW(t,["sdkHttpResponse"],n),t),r=new nk;return Object.assign(r,i),r})}}async update(e){var t,n,i,r,o,l;let s="",a={};if(this.apiClient.isVertexAI()){let i,r,l,u,p,d=(o=this.apiClient,i={},null!=(r=tz(e,["name"]))&&tW(i,["_url","name"],iv(o,r)),null!=(l=tz(e,["config"]))&&(u=tz(l,["ttl"]),void 0!==i&&null!=u&&tW(i,["ttl"],u),p=tz(l,["expireTime"]),void 0!==i&&null!=p&&tW(i,["expireTime"],p)),i);return s=tK("{name}",d._url),a=d._query,delete d._url,delete d._query,this.apiClient.request({path:s,queryParams:a,body:JSON.stringify(d),httpMethod:"PATCH",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal}).then(e=>e.json()).then(e=>e)}{let t,n,o,u,p,d=(l=this.apiClient,t={},null!=(n=tz(e,["name"]))&&tW(t,["_url","name"],iv(l,n)),null!=(o=tz(e,["config"]))&&(u=tz(o,["ttl"]),void 0!==t&&null!=u&&tW(t,["ttl"],u),p=tz(o,["expireTime"]),void 0!==t&&null!=p&&tW(t,["expireTime"],p)),t);return s=tK("{name}",d._url),a=d._query,delete d._url,delete d._query,this.apiClient.request({path:s,queryParams:a,body:JSON.stringify(d),httpMethod:"PATCH",httpOptions:null==(i=e.config)?void 0:i.httpOptions,abortSignal:null==(r=e.config)?void 0:r.abortSignal}).then(e=>e.json()).then(e=>e)}}async listInternal(e){var t,n,i,r;let o="",l={};if(this.apiClient.isVertexAI()){let i,r,s,a,u=(i={},null!=(r=tz(e,["config"]))&&(s=tz(r,["pageSize"]),void 0!==i&&null!=s&&tW(i,["_query","pageSize"],s),a=tz(r,["pageToken"]),void 0!==i&&null!=a&&tW(i,["_query","pageToken"],a)),i);return o=tK("cachedContents",u._url),l=u._query,delete u._url,delete u._query,this.apiClient.request({path:o,queryParams:l,body:JSON.stringify(u),httpMethod:"GET",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal}).then(e=>e.json().then(t=>(t.sdkHttpResponse={headers:e.headers},t))).then(e=>{let t=function(e){let t={},n=tz(e,["sdkHttpResponse"]);null!=n&&tW(t,["sdkHttpResponse"],n);let i=tz(e,["nextPageToken"]);null!=i&&tW(t,["nextPageToken"],i);let r=tz(e,["cachedContents"]);if(null!=r){let e=r;Array.isArray(e)&&(e=e.map(e=>e)),tW(t,["cachedContents"],e)}return t}(e),n=new nU;return Object.assign(n,t),n})}{let t,n,s,a,u=(t={},null!=(n=tz(e,["config"]))&&(s=tz(n,["pageSize"]),void 0!==t&&null!=s&&tW(t,["_query","pageSize"],s),a=tz(n,["pageToken"]),void 0!==t&&null!=a&&tW(t,["_query","pageToken"],a)),t);return o=tK("cachedContents",u._url),l=u._query,delete u._url,delete u._query,this.apiClient.request({path:o,queryParams:l,body:JSON.stringify(u),httpMethod:"GET",httpOptions:null==(i=e.config)?void 0:i.httpOptions,abortSignal:null==(r=e.config)?void 0:r.abortSignal}).then(e=>e.json().then(t=>(t.sdkHttpResponse={headers:e.headers},t))).then(e=>{let t=function(e){let t={},n=tz(e,["sdkHttpResponse"]);null!=n&&tW(t,["sdkHttpResponse"],n);let i=tz(e,["nextPageToken"]);null!=i&&tW(t,["nextPageToken"],i);let r=tz(e,["cachedContents"]);if(null!=r){let e=r;Array.isArray(e)&&(e=e.map(e=>e)),tW(t,["cachedContents"],e)}return t}(e),n=new nU;return Object.assign(n,t),n})}}}function iL(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&0>t.indexOf(i)&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var r=0,i=Object.getOwnPropertySymbols(e);r<i.length;r++)0>t.indexOf(i[r])&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(n[i[r]]=e[i[r]]);return n}function iq(e){return this instanceof iq?(this.v=e,this):new iq(e)}function iH(e,t,n){if(!Symbol.asyncIterator)throw TypeError("Symbol.asyncIterator is not defined.");var i,r=n.apply(e,t||[]),o=[];return i=Object.create(("function"==typeof AsyncIterator?AsyncIterator:Object).prototype),l("next"),l("throw"),l("return",function(e){return function(t){return Promise.resolve(t).then(e,u)}}),i[Symbol.asyncIterator]=function(){return this},i;function l(e,t){r[e]&&(i[e]=function(t){return new Promise(function(n,i){o.push([e,t,n,i])>1||s(e,t)})},t&&(i[e]=t(i[e])))}function s(e,t){try{var n;(n=r[e](t)).value instanceof iq?Promise.resolve(n.value.v).then(a,u):p(o[0][2],n)}catch(e){p(o[0][3],e)}}function a(e){s("next",e)}function u(e){s("throw",e)}function p(e,t){e(t),o.shift(),o.length&&s(o[0][0],o[0][1])}}function iF(e){if(!Symbol.asyncIterator)throw TypeError("Symbol.asyncIterator is not defined.");var t,n=e[Symbol.asyncIterator];return n?n.call(e):(e=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],i=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&i>=e.length&&(e=void 0),{value:e&&e[i++],done:!e}}};throw TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}(e),t={},i("next"),i("throw"),i("return"),t[Symbol.asyncIterator]=function(){return this},t);function i(n){t[n]=e[n]&&function(t){return new Promise(function(i,r){var o,l,s;o=i,l=r,s=(t=e[n](t)).done,Promise.resolve(t.value).then(function(e){o({value:e,done:s})},l)})}}}function ij(e){if(void 0===e.parts||0===e.parts.length)return!1;for(let t of e.parts)if(void 0===t||0===Object.keys(t).length)return!1;return!0}function iB(e){if(void 0===e||0===e.length)return[];let t=[],n=e.length,i=0;for(;i<n;)if("user"===e[i].role)t.push(e[i]),i++;else{let r=[],o=!0;for(;i<n&&"model"===e[i].role;)r.push(e[i]),o&&!ij(e[i])&&(o=!1),i++;o?t.push(...r):t.pop()}return t}"function"==typeof SuppressedError&&SuppressedError;class iX{constructor(e,t){this.modelsModule=e,this.apiClient=t}create(e){return new iV(this.apiClient,this.modelsModule,e.model,e.config,structuredClone(e.history))}}class iV{constructor(e,t,n,i={},r=[]){this.apiClient=e,this.modelsModule=t,this.model=n,this.config=i,this.history=r,this.sendPromise=Promise.resolve(),function(e){if(0!==e.length){for(let t of e)if("user"!==t.role&&"model"!==t.role)throw Error(`Role must be user or model, but got ${t.role}.`)}}(r)}async sendMessage(e){var t;await this.sendPromise;let n=id(e.message),i=this.modelsModule.generateContent({model:this.model,contents:this.getHistory(!0).concat(n),config:null!=(t=e.config)?t:this.config});return this.sendPromise=(async()=>{var e,t,r;let o=await i,l=null==(t=null==(e=o.candidates)?void 0:e[0])?void 0:t.content,s=o.automaticFunctionCallingHistory,a=this.getHistory(!0).length,u=[];null!=s&&(u=null!=(r=s.slice(a))?r:[]),this.recordHistory(n,l?[l]:[],u)})(),await this.sendPromise.catch(()=>{this.sendPromise=Promise.resolve()}),i}async sendMessageStream(e){var t;await this.sendPromise;let n=id(e.message),i=this.modelsModule.generateContentStream({model:this.model,contents:this.getHistory(!0).concat(n),config:null!=(t=e.config)?t:this.config});this.sendPromise=i.then(()=>void 0).catch(()=>void 0);let r=await i;return this.processStreamResponse(r,n)}getHistory(e=!1){return structuredClone(e?iB(this.history):this.history)}processStreamResponse(e,t){return iH(this,arguments,function*(){let n=[];try{for(var i,r,o,l,s,a,u,p=!0,d=iF(e);!(i=(u=yield iq(d.next())).done);p=!0){if(l=u.value,p=!1,function(e){var t;if(void 0==e.candidates||0===e.candidates.length)return!1;let n=null==(t=e.candidates[0])?void 0:t.content;return void 0!==n&&ij(n)}(l)){let e=null==(a=null==(s=l.candidates)?void 0:s[0])?void 0:a.content;void 0!==e&&n.push(e)}yield yield iq(l)}}catch(e){r={error:e}}finally{try{!p&&!i&&(o=d.return)&&(yield iq(o.call(d)))}finally{if(r)throw r.error}}this.recordHistory(t,n)})}recordHistory(e,t,n){let i=[];t.length>0&&t.every(e=>void 0!==e.role)?i=t:i.push({role:"model",parts:[]}),n&&n.length>0?this.history.push(...iB(n)):this.history.push(e),this.history.push(...i)}}class iJ extends Error{constructor(e){super(e.message),this.name="ApiError",this.status=e.status,Object.setPrototypeOf(this,iJ.prototype)}}let iY=class extends t${constructor(e){super(),this.apiClient=e,this.list=async(e={})=>new iG(tX.PAGED_ITEM_FILES,e=>this.listInternal(e),await this.listInternal(e),e)}async upload(e){if(this.apiClient.isVertexAI())throw Error("Gemini Enterprise Agent Platform (previously known as Vertex AI) does not support uploading files. You can share files through a GCS bucket.");return this.apiClient.uploadFile(e.file,e.config).then(e=>e)}async download(e){await this.apiClient.downloadFile(e)}async registerFiles(e){throw Error("registerFiles is only supported in Node.js environments.")}async _registerFiles(e){return this.registerFilesInternal(e)}async listInternal(e){var t,n;let i="",r={};if(this.apiClient.isVertexAI())throw Error("This method is only supported by the Gemini Developer API.");{let o,l,s,a,u=(o={},null!=(l=tz(e,["config"]))&&(s=tz(l,["pageSize"]),void 0!==o&&null!=s&&tW(o,["_query","pageSize"],s),a=tz(l,["pageToken"]),void 0!==o&&null!=a&&tW(o,["_query","pageToken"],a)),o);return i=tK("files",u._url),r=u._query,delete u._url,delete u._query,this.apiClient.request({path:i,queryParams:r,body:JSON.stringify(u),httpMethod:"GET",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal}).then(e=>e.json().then(t=>(t.sdkHttpResponse={headers:e.headers},t))).then(e=>{let t=function(e){let t={},n=tz(e,["sdkHttpResponse"]);null!=n&&tW(t,["sdkHttpResponse"],n);let i=tz(e,["nextPageToken"]);null!=i&&tW(t,["nextPageToken"],i);let r=tz(e,["files"]);if(null!=r){let e=r;Array.isArray(e)&&(e=e.map(e=>e)),tW(t,["files"],e)}return t}(e),n=new nj;return Object.assign(n,t),n})}}async createInternal(e){var t,n;let i="",r={};if(this.apiClient.isVertexAI())throw Error("This method is only supported by the Gemini Developer API.");{let o,l,s=(o={},null!=(l=tz(e,["file"]))&&tW(o,["file"],l),o);return i=tK("upload/v1beta/files",s._url),r=s._query,delete s._url,delete s._query,this.apiClient.request({path:i,queryParams:r,body:JSON.stringify(s),httpMethod:"POST",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal}).then(e=>e.json()).then(e=>{let t,n,i=(t={},null!=(n=tz(e,["sdkHttpResponse"]))&&tW(t,["sdkHttpResponse"],n),t),r=new nB;return Object.assign(r,i),r})}}async get(e){var t,n;let i="",r={};if(this.apiClient.isVertexAI())throw Error("This method is only supported by the Gemini Developer API.");{let o,l,s=(o={},null!=(l=tz(e,["name"]))&&tW(o,["_url","file"],iI(l)),o);return i=tK("files/{file}",s._url),r=s._query,delete s._url,delete s._query,this.apiClient.request({path:i,queryParams:r,body:JSON.stringify(s),httpMethod:"GET",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal}).then(e=>e.json()).then(e=>e)}}async delete(e){var t,n;let i="",r={};if(this.apiClient.isVertexAI())throw Error("This method is only supported by the Gemini Developer API.");{let o,l,s=(o={},null!=(l=tz(e,["name"]))&&tW(o,["_url","file"],iI(l)),o);return i=tK("files/{file}",s._url),r=s._query,delete s._url,delete s._query,this.apiClient.request({path:i,queryParams:r,body:JSON.stringify(s),httpMethod:"DELETE",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal}).then(e=>e.json().then(t=>(t.sdkHttpResponse={headers:e.headers},t))).then(e=>{let t,n,i=(t={},null!=(n=tz(e,["sdkHttpResponse"]))&&tW(t,["sdkHttpResponse"],n),t),r=new nX;return Object.assign(r,i),r})}}async registerFilesInternal(e){var t,n;let i="",r={};if(this.apiClient.isVertexAI())throw Error("This method is only supported by the Gemini Developer API.");{let o,l,s=(o={},null!=(l=tz(e,["uris"]))&&tW(o,["uris"],l),o);return i=tK("files:register",s._url),r=s._query,delete s._url,delete s._query,this.apiClient.request({path:i,queryParams:r,body:JSON.stringify(s),httpMethod:"POST",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal}).then(e=>e.json()).then(e=>{let t=function(e){let t={},n=tz(e,["sdkHttpResponse"]);null!=n&&tW(t,["sdkHttpResponse"],n);let i=tz(e,["files"]);if(null!=i){let e=i;Array.isArray(e)&&(e=e.map(e=>e)),tW(t,["files"],e)}return t}(e),n=new nV;return Object.assign(n,t),n})}}};function i$(e){let t={},n=tz(e,["data"]);if(null!=n&&tW(t,["data"],n),void 0!==tz(e,["displayName"]))throw Error("displayName parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let i=tz(e,["mimeType"]);return null!=i&&tW(t,["mimeType"],i),t}function iK(e){let t={},n=tz(e,["voiceConfig"]);null!=n&&tW(t,["voiceConfig"],iW(n));let i=tz(e,["languageCode"]);null!=i&&tW(t,["languageCode"],i);let r=tz(e,["multiSpeakerVoiceConfig"]);return null!=r&&tW(t,["multiSpeakerVoiceConfig"],function(e){let t={},n=tz(e,["speakerVoiceConfigs"]);if(null!=n){let e=n;Array.isArray(e)&&(e=e.map(e=>{var t;let n,i,r;return n={},null!=(i=tz(t=e,["speaker"]))&&tW(n,["speaker"],i),null!=(r=tz(t,["voiceConfig"]))&&tW(n,["voiceConfig"],iW(r)),n})),tW(t,["speakerVoiceConfigs"],e)}return t}(r)),t}function iW(e){let t={},n=tz(e,["replicatedVoiceConfig"]);null!=n&&tW(t,["replicatedVoiceConfig"],function(e){let t={},n=tz(e,["mimeType"]);null!=n&&tW(t,["mimeType"],n);let i=tz(e,["voiceSampleAudio"]);if(null!=i&&tW(t,["voiceSampleAudio"],i),void 0!==tz(e,["consentAudio"]))throw Error("consentAudio parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.");if(void 0!==tz(e,["voiceConsentSignature"]))throw Error("voiceConsentSignature parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.");return t}(n));let i=tz(e,["prebuiltVoiceConfig"]);return null!=i&&tW(t,["prebuiltVoiceConfig"],i),t}function iz(e,t){let n={},i=tz(e,["parts"]);if(null!=i){let e=i;Array.isArray(e)&&(e=e.map(e=>{var t;let n,i,r,o,l,s,a,u,p,d,c,m,f,h,g,_,E;return n={},null!=(i=tz(t=e,["mediaResolution"]))&&tW(n,["mediaResolution"],i),null!=(r=tz(t,["toolCall"]))&&tW(n,["toolCall"],r),null!=(o=tz(t,["toolResponse"]))&&tW(n,["toolResponse"],o),null!=(l=tz(t,["audioTranscription"]))&&tW(n,["audioTranscription"],l),null!=(s=tz(t,["codeExecutionResult"]))&&tW(n,["codeExecutionResult"],s),null!=(a=tz(t,["executableCode"]))&&tW(n,["executableCode"],a),null!=(u=tz(t,["fileData"]))&&tW(n,["fileData"],function(e){let t={};if(void 0!==tz(e,["displayName"]))throw Error("displayName parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let n=tz(e,["fileUri"]);null!=n&&tW(t,["fileUri"],n);let i=tz(e,["mimeType"]);return null!=i&&tW(t,["mimeType"],i),t}(u)),null!=(p=tz(t,["functionCall"]))&&tW(n,["functionCall"],function(e){let t={},n=tz(e,["args"]);null!=n&&tW(t,["args"],n);let i=tz(e,["id"]);null!=i&&tW(t,["id"],i);let r=tz(e,["name"]);if(null!=r&&tW(t,["name"],r),void 0!==tz(e,["partialArgs"]))throw Error("partialArgs parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==tz(e,["willContinue"]))throw Error("willContinue parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");return t}(p)),null!=(d=tz(t,["functionResponse"]))&&tW(n,["functionResponse"],d),null!=(c=tz(t,["inlineData"]))&&tW(n,["inlineData"],function(e){let t={},n=tz(e,["data"]);if(null!=n&&tW(t,["data"],n),void 0!==tz(e,["displayName"]))throw Error("displayName parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let i=tz(e,["mimeType"]);return null!=i&&tW(t,["mimeType"],i),t}(c)),null!=(m=tz(t,["text"]))&&tW(n,["text"],m),null!=(f=tz(t,["thought"]))&&tW(n,["thought"],f),null!=(h=tz(t,["thoughtSignature"]))&&tW(n,["thoughtSignature"],h),null!=(g=tz(t,["videoMetadata"]))&&tW(n,["videoMetadata"],g),null!=(_=tz(t,["partMetadata"]))&&tW(n,["partMetadata"],_),null!=(E=tz(t,["mediaProcessing"]))&&tW(n,["mediaProcessing"],E),n})),tW(n,["parts"],e)}let r=tz(e,["role"]);return null!=r&&tW(n,["role"],r),n}function iZ(e,t){let n={},i=tz(e,["parts"]);if(null!=i){let e=i;Array.isArray(e)&&(e=e.map(e=>(function(e){let t={},n=tz(e,["mediaResolution"]);if(null!=n&&tW(t,["mediaResolution"],n),void 0!==tz(e,["toolCall"]))throw Error("toolCall parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.");if(void 0!==tz(e,["toolResponse"]))throw Error("toolResponse parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.");let i=tz(e,["audioTranscription"]);null!=i&&tW(t,["audioTranscription"],i);let r=tz(e,["codeExecutionResult"]);null!=r&&tW(t,["codeExecutionResult"],r);let o=tz(e,["executableCode"]);null!=o&&tW(t,["executableCode"],o);let l=tz(e,["fileData"]);null!=l&&tW(t,["fileData"],l);let s=tz(e,["functionCall"]);null!=s&&tW(t,["functionCall"],s);let a=tz(e,["functionResponse"]);null!=a&&tW(t,["functionResponse"],a);let u=tz(e,["inlineData"]);null!=u&&tW(t,["inlineData"],u);let p=tz(e,["text"]);null!=p&&tW(t,["text"],p);let d=tz(e,["thought"]);null!=d&&tW(t,["thought"],d);let c=tz(e,["thoughtSignature"]);null!=c&&tW(t,["thoughtSignature"],c);let m=tz(e,["videoMetadata"]);if(null!=m&&tW(t,["videoMetadata"],m),void 0!==tz(e,["partMetadata"]))throw Error("partMetadata parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.");let f=tz(e,["mediaProcessing"]);return null!=f&&tW(t,["mediaProcessing"],f),t})(e))),tW(n,["parts"],e)}let r=tz(e,["role"]);return null!=r&&tW(n,["role"],r),n}function iQ(e,t,n){let i={},r=tz(t,["model"]);null!=r&&tW(i,["_url","model"],n7(e,r));let o=tz(t,["contents"]);if(null!=o){let e=im(o);Array.isArray(e)&&(e=e.map(e=>iz(e))),tW(i,["contents"],e)}let l=tz(t,["config"]);return null!=l&&tW(i,["generationConfig"],function(e,t,n){var i;let r,o,l,s,a={},u=tz(t,["serviceTier"]);void 0!==n&&null!=u&&tW(n,["serviceTier"],u);let p=tz(t,["systemInstruction"]);void 0!==n&&null!=p&&tW(n,["systemInstruction"],iz(id(p)));let d=tz(t,["temperature"]);null!=d&&tW(a,["temperature"],d);let c=tz(t,["topP"]);null!=c&&tW(a,["topP"],c);let m=tz(t,["topK"]);null!=m&&tW(a,["topK"],m);let f=tz(t,["candidateCount"]);null!=f&&tW(a,["candidateCount"],f);let h=tz(t,["maxOutputTokens"]);null!=h&&tW(a,["maxOutputTokens"],h);let g=tz(t,["stopSequences"]);null!=g&&tW(a,["stopSequences"],g);let _=tz(t,["responseLogprobs"]);null!=_&&tW(a,["responseLogprobs"],_);let E=tz(t,["logprobs"]);null!=E&&tW(a,["logprobs"],E);let y=tz(t,["presencePenalty"]);null!=y&&tW(a,["presencePenalty"],y);let v=tz(t,["frequencyPenalty"]);null!=v&&tW(a,["frequencyPenalty"],v);let A=tz(t,["seed"]);null!=A&&tW(a,["seed"],A);let I=tz(t,["responseMimeType"]);null!=I&&tW(a,["responseMimeType"],I);let T=tz(t,["responseSchema"]);null!=T&&tW(a,["responseSchema"],ih(T));let C=tz(t,["responseJsonSchema"]);if(null!=C&&tW(a,["responseJsonSchema"],C),void 0!==tz(t,["routingConfig"]))throw Error("routingConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==tz(t,["modelSelectionConfig"]))throw Error("modelSelectionConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let S=tz(t,["safetySettings"]);if(void 0!==n&&null!=S){let e=S;Array.isArray(e)&&(e=e.map(e=>(function(e){let t={},n=tz(e,["category"]);if(null!=n&&tW(t,["category"],n),void 0!==tz(e,["method"]))throw Error("method parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let i=tz(e,["threshold"]);return null!=i&&tW(t,["threshold"],i),t})(e))),tW(n,["safetySettings"],e)}let O=tz(t,["tools"]);if(void 0!==n&&null!=O){let e=iy(O);Array.isArray(e)&&(e=e.map(e=>(function(e){let t={};if(void 0!==tz(e,["retrieval"]))throw Error("retrieval parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let n=tz(e,["googleMaps"]);null!=n&&tW(t,["googleMaps"],function(e){let t={},n=tz(e,["authConfig"]);null!=n&&tW(t,["authConfig"],function(e){let t={},n=tz(e,["apiKey"]);if(null!=n&&tW(t,["apiKey"],n),void 0!==tz(e,["apiKeyConfig"]))throw Error("apiKeyConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==tz(e,["authType"]))throw Error("authType parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==tz(e,["googleServiceAccountConfig"]))throw Error("googleServiceAccountConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==tz(e,["httpBasicAuthConfig"]))throw Error("httpBasicAuthConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==tz(e,["oauthConfig"]))throw Error("oauthConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==tz(e,["oidcConfig"]))throw Error("oidcConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");return t}(n));let i=tz(e,["enableWidget"]);if(null!=i&&tW(t,["enableWidget"],i),void 0!==tz(e,["groundingTypes"]))throw Error("groundingTypes parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");return t}(n));let i=tz(e,["mcpServers"]);if(null!=i){let e=i;Array.isArray(e)&&(e=e.map(e=>e)),tW(t,["mcpServers"],e)}let r=tz(e,["codeExecution"]);null!=r&&tW(t,["codeExecution"],r);let o=tz(e,["computerUse"]);if(null!=o&&tW(t,["computerUse"],o),void 0!==tz(e,["enterpriseWebSearch"]))throw Error("enterpriseWebSearch parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==tz(e,["exaAiSearch"]))throw Error("exaAiSearch parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let l=tz(e,["functionDeclarations"]);if(null!=l){let e=l;Array.isArray(e)&&(e=e.map(e=>e)),tW(t,["functionDeclarations"],e)}let s=tz(e,["googleSearch"]);null!=s&&tW(t,["googleSearch"],function(e){let t={};if(void 0!==tz(e,["blockingConfidence"]))throw Error("blockingConfidence parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==tz(e,["excludeDomains"]))throw Error("excludeDomains parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let n=tz(e,["searchTypes"]);null!=n&&tW(t,["searchTypes"],n);let i=tz(e,["timeRangeFilter"]);return null!=i&&tW(t,["timeRangeFilter"],i),t}(s));let a=tz(e,["googleSearchRetrieval"]);if(null!=a&&tW(t,["googleSearchRetrieval"],a),void 0!==tz(e,["parallelAiSearch"]))throw Error("parallelAiSearch parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let u=tz(e,["urlContext"]);null!=u&&tW(t,["urlContext"],u);let p=tz(e,["fileSearch"]);return null!=p&&tW(t,["fileSearch"],p),t})(iE(e)))),tW(n,["tools"],e)}let b=tz(t,["toolConfig"]);if(void 0!==n&&null!=b&&tW(n,["toolConfig"],(r={},null!=(o=tz(i=b,["functionCallingConfig"]))&&tW(r,["functionCallingConfig"],function(e){let t={},n=tz(e,["allowedFunctionNames"]);null!=n&&tW(t,["allowedFunctionNames"],n);let i=tz(e,["mode"]);if(null!=i&&tW(t,["mode"],i),void 0!==tz(e,["streamFunctionCallArguments"]))throw Error("streamFunctionCallArguments parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");return t}(o)),null!=(l=tz(i,["retrievalConfig"]))&&tW(r,["retrievalConfig"],l),null!=(s=tz(i,["includeServerSideToolInvocations"]))&&tW(r,["includeServerSideToolInvocations"],s),r)),void 0!==tz(t,["labels"]))throw Error("labels parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let P=tz(t,["cachedContent"]);void 0!==n&&null!=P&&tW(n,["cachedContent"],iv(e,P));let R=tz(t,["responseModalities"]);null!=R&&tW(a,["responseModalities"],R);let N=tz(t,["mediaResolution"]);null!=N&&tW(a,["mediaResolution"],N);let w=tz(t,["speechConfig"]);if(null!=w&&tW(a,["speechConfig"],ig(w)),void 0!==tz(t,["audioTimestamp"]))throw Error("audioTimestamp parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let D=tz(t,["thinkingConfig"]);null!=D&&tW(a,["thinkingConfig"],D);let G=tz(t,["audioTranscriptionConfig"]);null!=G&&tW(a,["audioTranscriptionConfig"],G);let M=tz(t,["imageConfig"]);null!=M&&tW(a,["imageConfig"],function(e){let t={},n=tz(e,["aspectRatio"]);null!=n&&tW(t,["aspectRatio"],n);let i=tz(e,["imageSize"]);if(null!=i&&tW(t,["imageSize"],i),void 0!==tz(e,["personGeneration"]))throw Error("personGeneration parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==tz(e,["outputMimeType"]))throw Error("outputMimeType parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==tz(e,["outputCompressionQuality"]))throw Error("outputCompressionQuality parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==tz(e,["imageOutputOptions"]))throw Error("imageOutputOptions parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==tz(e,["prominentPeople"]))throw Error("prominentPeople parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");return t}(M));let k=tz(t,["enableEnhancedCivicAnswers"]);if(null!=k&&tW(a,["enableEnhancedCivicAnswers"],k),void 0!==tz(t,["modelArmorConfig"]))throw Error("modelArmorConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");return a}(e,l,i)),i}function i0(e,t,n){let i={},r=tz(t,["model"]);null!=r&&tW(i,["_url","model"],n7(e,r));let o=tz(t,["contents"]);if(null!=o){let e=im(o);Array.isArray(e)&&(e=e.map(e=>iZ(e))),tW(i,["contents"],e)}let l=tz(t,["config"]);return null!=l&&tW(i,["generationConfig"],function(e,t,n){var i;let r,o,l,s,a,u,p,d,c={},m=tz(t,["serviceTier"]);void 0!==n&&null!=m&&tW(n,["serviceTier"],m);let f=tz(t,["systemInstruction"]);void 0!==n&&null!=f&&tW(n,["systemInstruction"],iZ(id(f)));let h=tz(t,["temperature"]);null!=h&&tW(c,["temperature"],h);let g=tz(t,["topP"]);null!=g&&tW(c,["topP"],g);let _=tz(t,["topK"]);null!=_&&tW(c,["topK"],_);let E=tz(t,["candidateCount"]);null!=E&&tW(c,["candidateCount"],E);let y=tz(t,["maxOutputTokens"]);null!=y&&tW(c,["maxOutputTokens"],y);let v=tz(t,["stopSequences"]);null!=v&&tW(c,["stopSequences"],v);let A=tz(t,["responseLogprobs"]);null!=A&&tW(c,["responseLogprobs"],A);let I=tz(t,["logprobs"]);null!=I&&tW(c,["logprobs"],I);let T=tz(t,["presencePenalty"]);null!=T&&tW(c,["presencePenalty"],T);let C=tz(t,["frequencyPenalty"]);null!=C&&tW(c,["frequencyPenalty"],C);let S=tz(t,["seed"]);null!=S&&tW(c,["seed"],S);let O=tz(t,["responseMimeType"]);null!=O&&tW(c,["responseMimeType"],O);let b=tz(t,["responseSchema"]);null!=b&&tW(c,["responseSchema"],ih(b));let P=tz(t,["responseJsonSchema"]);null!=P&&tW(c,["responseJsonSchema"],P);let R=tz(t,["routingConfig"]);null!=R&&tW(c,["routingConfig"],R);let N=tz(t,["modelSelectionConfig"]);null!=N&&tW(c,["modelConfig"],N);let w=tz(t,["safetySettings"]);if(void 0!==n&&null!=w){let e=w;Array.isArray(e)&&(e=e.map(e=>e)),tW(n,["safetySettings"],e)}let D=tz(t,["tools"]);if(void 0!==n&&null!=D){let e=iy(D);Array.isArray(e)&&(e=e.map(e=>rt(iE(e)))),tW(n,["tools"],e)}let G=tz(t,["toolConfig"]);void 0!==n&&null!=G&&tW(n,["toolConfig"],function(e){let t={},n=tz(e,["functionCallingConfig"]);null!=n&&tW(t,["functionCallingConfig"],n);let i=tz(e,["retrievalConfig"]);if(null!=i&&tW(t,["retrievalConfig"],i),void 0!==tz(e,["includeServerSideToolInvocations"]))throw Error("includeServerSideToolInvocations parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.");return t}(G));let M=tz(t,["labels"]);void 0!==n&&null!=M&&tW(n,["labels"],M);let k=tz(t,["cachedContent"]);void 0!==n&&null!=k&&tW(n,["cachedContent"],iv(e,k));let U=tz(t,["responseModalities"]);null!=U&&tW(c,["responseModalities"],U);let x=tz(t,["mediaResolution"]);null!=x&&tW(c,["mediaResolution"],x);let L=tz(t,["speechConfig"]);null!=L&&tW(c,["speechConfig"],re(ig(L)));let q=tz(t,["audioTimestamp"]);null!=q&&tW(c,["audioTimestamp"],q);let H=tz(t,["thinkingConfig"]);null!=H&&tW(c,["thinkingConfig"],H);let F=tz(t,["audioTranscriptionConfig"]);null!=F&&tW(c,["audioTranscriptionConfig"],F);let j=tz(t,["imageConfig"]);if(null!=j&&tW(c,["imageConfig"],(r={},null!=(o=tz(i=j,["aspectRatio"]))&&tW(r,["aspectRatio"],o),null!=(l=tz(i,["imageSize"]))&&tW(r,["imageSize"],l),null!=(s=tz(i,["personGeneration"]))&&tW(r,["personGeneration"],s),null!=(a=tz(i,["outputMimeType"]))&&tW(r,["imageOutputOptions","mimeType"],a),null!=(u=tz(i,["outputCompressionQuality"]))&&tW(r,["imageOutputOptions","compressionQuality"],u),null!=(p=tz(i,["imageOutputOptions"]))&&tW(r,["imageOutputOptions"],p),null!=(d=tz(i,["prominentPeople"]))&&tW(r,["prominentPeople"],d),r)),void 0!==tz(t,["enableEnhancedCivicAnswers"]))throw Error("enableEnhancedCivicAnswers parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.");let B=tz(t,["modelArmorConfig"]);return void 0!==n&&null!=B&&tW(n,["modelArmorConfig"],B),c}(e,l,i)),i}function i1(e,t){let n={},i=tz(e,["sdkHttpResponse"]);null!=i&&tW(n,["sdkHttpResponse"],i);let r=tz(e,["candidates"]);if(null!=r){let e=r;Array.isArray(e)&&(e=e.map(e=>(function(e){let t={},n=tz(e,["content"]);null!=n&&tW(t,["content"],n);let i=tz(e,["citationMetadata"]);null!=i&&tW(t,["citationMetadata"],function(e){let t={},n=tz(e,["citationSources"]);if(null!=n){let e=n;Array.isArray(e)&&(e=e.map(e=>e)),tW(t,["citations"],e)}return t}(i));let r=tz(e,["tokenCount"]);null!=r&&tW(t,["tokenCount"],r);let o=tz(e,["finishReason"]);null!=o&&tW(t,["finishReason"],o);let l=tz(e,["groundingMetadata"]);null!=l&&tW(t,["groundingMetadata"],l);let s=tz(e,["avgLogprobs"]);null!=s&&tW(t,["avgLogprobs"],s);let a=tz(e,["index"]);null!=a&&tW(t,["index"],a);let u=tz(e,["logprobsResult"]);null!=u&&tW(t,["logprobsResult"],u);let p=tz(e,["safetyRatings"]);if(null!=p){let e=p;Array.isArray(e)&&(e=e.map(e=>e)),tW(t,["safetyRatings"],e)}let d=tz(e,["urlContextMetadata"]);return null!=d&&tW(t,["urlContextMetadata"],d),t})(e))),tW(n,["candidates"],e)}let o=tz(e,["modelVersion"]);null!=o&&tW(n,["modelVersion"],o);let l=tz(e,["promptFeedback"]);null!=l&&tW(n,["promptFeedback"],l);let s=tz(e,["responseId"]);null!=s&&tW(n,["responseId"],s);let a=tz(e,["usageMetadata"]);null!=a&&tW(n,["usageMetadata"],a);let u=tz(e,["modelStatus"]);return null!=u&&tW(n,["modelStatus"],u),n}function i4(e,t){let n={},i=tz(e,["sdkHttpResponse"]);null!=i&&tW(n,["sdkHttpResponse"],i);let r=tz(e,["candidates"]);if(null!=r){let e=r;Array.isArray(e)&&(e=e.map(e=>e)),tW(n,["candidates"],e)}let o=tz(e,["createTime"]);null!=o&&tW(n,["createTime"],o);let l=tz(e,["modelVersion"]);null!=l&&tW(n,["modelVersion"],l);let s=tz(e,["promptFeedback"]);null!=s&&tW(n,["promptFeedback"],s);let a=tz(e,["responseId"]);null!=a&&tW(n,["responseId"],a);let u=tz(e,["usageMetadata"]);return null!=u&&tW(n,["usageMetadata"],u),n}function i2(e,t){let n={},i=tz(e,["_self"]);null!=i&&tW(n,["image"],i5(i));let r=tz(e,["raiFilteredReason"]);null!=r&&tW(n,["raiFilteredReason"],r);let o=tz(e,["_self"]);null!=o&&tW(n,["safetyAttributes"],i7(o));let l=tz(e,["prompt"]);return null!=l&&tW(n,["enhancedPrompt"],l),n}function i5(e,t){let n={},i=tz(e,["gcsUri"]);null!=i&&tW(n,["gcsUri"],i);let r=tz(e,["bytesBase64Encoded"]);null!=r&&tW(n,["imageBytes"],tZ(r));let o=tz(e,["mimeType"]);return null!=o&&tW(n,["mimeType"],o),n}function i3(e,t){let n={};if(void 0!==tz(e,["gcsUri"]))throw Error("gcsUri parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let i=tz(e,["imageBytes"]);null!=i&&tW(n,["bytesBase64Encoded"],tZ(i));let r=tz(e,["mimeType"]);return null!=r&&tW(n,["mimeType"],r),n}function i8(e,t){let n={},i=tz(e,["gcsUri"]);null!=i&&tW(n,["gcsUri"],i);let r=tz(e,["imageBytes"]);null!=r&&tW(n,["bytesBase64Encoded"],tZ(r));let o=tz(e,["mimeType"]);return null!=o&&tW(n,["mimeType"],o),n}function i9(e,t){var n;let i,r,o,l,s={},a=tz(e,["name"]);null!=a&&tW(s,["name"],a);let u=tz(e,["displayName"]);null!=u&&tW(s,["displayName"],u);let p=tz(e,["description"]);null!=p&&tW(s,["description"],p);let d=tz(e,["version"]);null!=d&&tW(s,["version"],d);let c=tz(e,["_self"]);null!=c&&tW(s,["tunedModelInfo"],(i={},null!=(r=tz(n=c,["baseModel"]))&&tW(i,["baseModel"],r),null!=(o=tz(n,["createTime"]))&&tW(i,["createTime"],o),null!=(l=tz(n,["updateTime"]))&&tW(i,["updateTime"],l),i));let m=tz(e,["inputTokenLimit"]);null!=m&&tW(s,["inputTokenLimit"],m);let f=tz(e,["outputTokenLimit"]);null!=f&&tW(s,["outputTokenLimit"],f);let h=tz(e,["supportedGenerationMethods"]);null!=h&&tW(s,["supportedActions"],h);let g=tz(e,["temperature"]);null!=g&&tW(s,["temperature"],g);let _=tz(e,["maxTemperature"]);null!=_&&tW(s,["maxTemperature"],_);let E=tz(e,["topP"]);null!=E&&tW(s,["topP"],E);let y=tz(e,["topK"]);null!=y&&tW(s,["topK"],y);let v=tz(e,["thinking"]);return null!=v&&tW(s,["thinking"],v),s}function i6(e,t){var n;let i,r,o,l,s={},a=tz(e,["name"]);null!=a&&tW(s,["name"],a);let u=tz(e,["displayName"]);null!=u&&tW(s,["displayName"],u);let p=tz(e,["description"]);null!=p&&tW(s,["description"],p);let d=tz(e,["versionId"]);null!=d&&tW(s,["version"],d);let c=tz(e,["deployedModels"]);if(null!=c){let e=c;Array.isArray(e)&&(e=e.map(e=>{let t,n,i;return t={},null!=(n=tz(e,["endpoint"]))&&tW(t,["name"],n),null!=(i=tz(e,["deployedModelId"]))&&tW(t,["deployedModelId"],i),t})),tW(s,["endpoints"],e)}let m=tz(e,["labels"]);null!=m&&tW(s,["labels"],m);let f=tz(e,["_self"]);null!=f&&tW(s,["tunedModelInfo"],(i={},null!=(r=tz(n=f,["labels","google-vertex-llm-tuning-base-model-id"]))&&tW(i,["baseModel"],r),null!=(o=tz(n,["createTime"]))&&tW(i,["createTime"],o),null!=(l=tz(n,["updateTime"]))&&tW(i,["updateTime"],l),i));let h=tz(e,["defaultCheckpointId"]);null!=h&&tW(s,["defaultCheckpointId"],h);let g=tz(e,["checkpoints"]);if(null!=g){let e=g;Array.isArray(e)&&(e=e.map(e=>e)),tW(s,["checkpoints"],e)}return s}function i7(e,t){let n={},i=tz(e,["safetyAttributes","categories"]);null!=i&&tW(n,["categories"],i);let r=tz(e,["safetyAttributes","scores"]);null!=r&&tW(n,["scores"],r);let o=tz(e,["contentType"]);return null!=o&&tW(n,["contentType"],o),n}function re(e,t){let n={},i=tz(e,["voiceConfig"]);null!=i&&tW(n,["voiceConfig"],rr(i));let r=tz(e,["languageCode"]);null!=r&&tW(n,["languageCode"],r);let o=tz(e,["multiSpeakerVoiceConfig"]);return null!=o&&tW(n,["multiSpeakerVoiceConfig"],function(e){let t={},n=tz(e,["speakerVoiceConfigs"]);if(null!=n){let e=n;Array.isArray(e)&&(e=e.map(e=>{var t;let n,i,r;return n={},null!=(i=tz(t=e,["speaker"]))&&tW(n,["speaker"],i),null!=(r=tz(t,["voiceConfig"]))&&tW(n,["voiceConfig"],rr(r)),n})),tW(t,["speakerVoiceConfigs"],e)}return t}(o)),n}function rt(e,t){let n={},i=tz(e,["retrieval"]);null!=i&&tW(n,["retrieval"],i);let r=tz(e,["googleMaps"]);null!=r&&tW(n,["googleMaps"],r);let o=tz(e,["mcpServers"]);if(null!=o){let e=o;Array.isArray(e)&&(e=e.map(e=>(function(e){if(void 0!==tz(e,["name"]))throw Error("name parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.");if(void 0!==tz(e,["streamableHttpTransport"]))throw Error("streamableHttpTransport parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.");return{}})(e))),tW(n,["mcpServers"],e)}let l=tz(e,["codeExecution"]);null!=l&&tW(n,["codeExecution"],l);let s=tz(e,["computerUse"]);null!=s&&tW(n,["computerUse"],function(e){let t={},n=tz(e,["enablePromptInjectionDetection"]);null!=n&&tW(t,["enablePromptInjectionDetection"],n);let i=tz(e,["environment"]);null!=i&&tW(t,["environment"],i);let r=tz(e,["excludedPredefinedFunctions"]);if(null!=r&&tW(t,["excludedPredefinedFunctions"],r),void 0!==tz(e,["disabledSafetyPolicies"]))throw Error("disabledSafetyPolicies parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.");return t}(s));let a=tz(e,["enterpriseWebSearch"]);null!=a&&tW(n,["enterpriseWebSearch"],a);let u=tz(e,["exaAiSearch"]);null!=u&&tW(n,["exaAiSearch"],u);let p=tz(e,["functionDeclarations"]);if(null!=p){let e=p;Array.isArray(e)&&(e=e.map(e=>e)),tW(n,["functionDeclarations"],e)}let d=tz(e,["googleSearch"]);null!=d&&tW(n,["googleSearch"],d);let c=tz(e,["googleSearchRetrieval"]);null!=c&&tW(n,["googleSearchRetrieval"],c);let m=tz(e,["parallelAiSearch"]);null!=m&&tW(n,["parallelAiSearch"],m);let f=tz(e,["urlContext"]);if(null!=f&&tW(n,["urlContext"],f),void 0!==tz(e,["fileSearch"]))throw Error("fileSearch parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.");return n}function rn(e,t){let n={},i=tz(e,["uri"]);null!=i&&tW(n,["uri"],i);let r=tz(e,["videoBytes"]);null!=r&&tW(n,["encodedVideo"],tZ(r));let o=tz(e,["mimeType"]);return null!=o&&tW(n,["encoding"],o),n}function ri(e,t){let n={},i=tz(e,["uri"]);null!=i&&tW(n,["gcsUri"],i);let r=tz(e,["videoBytes"]);null!=r&&tW(n,["bytesBase64Encoded"],tZ(r));let o=tz(e,["mimeType"]);return null!=o&&tW(n,["mimeType"],o),n}function rr(e,t){let n={},i=tz(e,["replicatedVoiceConfig"]);null!=i&&tW(n,["replicatedVoiceConfig"],function(e){let t={},n=tz(e,["mimeType"]);null!=n&&tW(t,["mimeType"],n);let i=tz(e,["voiceSampleAudio"]);if(null!=i&&tW(t,["voiceSampleAudio"],i),void 0!==tz(e,["consentAudio"]))throw Error("consentAudio parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.");if(void 0!==tz(e,["voiceConsentSignature"]))throw Error("voiceConsentSignature parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.");return t}(i));let r=tz(e,["prebuiltVoiceConfig"]);return null!=r&&tW(n,["prebuiltVoiceConfig"],r),n}function ro(e,t){let n=tz(e,["mimeType"]);void 0!==t&&null!=n&&tW(t,["mimeType"],n);let i=tz(e,["displayName"]);void 0!==t&&null!=i&&tW(t,["displayName"],i);let r=tz(e,["customMetadata"]);if(void 0!==t&&null!=r){let e=r;Array.isArray(e)&&(e=e.map(e=>e)),tW(t,["customMetadata"],e)}let o=tz(e,["chunkingConfig"]);return void 0!==t&&null!=o&&tW(t,["chunkingConfig"],o),{}}let rl="x-goog-api-client",rs=new Set(["us","eu"]),ra=[408,429,500,502,503,504];class ru{constructor(e){var t,n,i;this.clientOptions=Object.assign({},e),this.customBaseUrl=null==(t=e.httpOptions)?void 0:t.baseUrl;const r={};if(this.clientOptions.vertexai){if(this.clientOptions.location||this.clientOptions.apiKey||this.customBaseUrl||(this.clientOptions.location="global"),!(this.clientOptions.project&&this.clientOptions.location||this.clientOptions.apiKey)&&!this.customBaseUrl)throw Error("Authentication is not set up. Please provide either a project and location, or an API key, or a custom base URL.");const t=e.project&&e.location||!!e.apiKey;this.customBaseUrl&&!t?(r.baseUrl=this.customBaseUrl,this.clientOptions.project=void 0,this.clientOptions.location=void 0):this.clientOptions.apiKey&&!this.clientOptions.project||"global"===this.clientOptions.location?r.baseUrl="https://aiplatform.googleapis.com/":this.clientOptions.project&&this.clientOptions.location&&rs.has(this.clientOptions.location)?r.baseUrl=`https://aiplatform.${this.clientOptions.location}.rep.googleapis.com/`:this.clientOptions.project&&this.clientOptions.location&&(r.baseUrl=`https://${this.clientOptions.location}-aiplatform.googleapis.com/`),r.apiVersion=null!=(n=this.clientOptions.apiVersion)?n:"v1beta1"}else this.clientOptions.apiKey||console.warn("API key should be set when using the Gemini API."),r.apiVersion=null!=(i=this.clientOptions.apiVersion)?i:"v1beta",r.baseUrl="https://generativelanguage.googleapis.com/";r.headers=this.getDefaultHeaders(),this.clientOptions.httpOptions=r,e.httpOptions&&(this.clientOptions.httpOptions=this.patchHttpOptions(r,e.httpOptions))}isVertexAI(){var e;return null!=(e=this.clientOptions.vertexai)&&e}getProject(){return this.clientOptions.project}getLocation(){return this.clientOptions.location}getCustomBaseUrl(){return this.customBaseUrl}async getAuthHeaders(){let e=new Headers;return await this.clientOptions.auth.addAuthHeaders(e),e}getApiVersion(){if(this.clientOptions.httpOptions&&void 0!==this.clientOptions.httpOptions.apiVersion)return this.clientOptions.httpOptions.apiVersion;throw Error("API version is not set.")}getBaseUrl(){if(this.clientOptions.httpOptions&&void 0!==this.clientOptions.httpOptions.baseUrl)return this.clientOptions.httpOptions.baseUrl;throw Error("Base URL is not set.")}getRequestUrl(){return this.getRequestUrlInternal(this.clientOptions.httpOptions)}getHeaders(){if(this.clientOptions.httpOptions&&void 0!==this.clientOptions.httpOptions.headers)return this.clientOptions.httpOptions.headers;throw Error("Headers are not set.")}getFetch(){var e;return null==(e=this.clientOptions.httpOptions)?void 0:e.fetch}getRequestUrlInternal(e){if(!e||void 0===e.baseUrl||void 0===e.apiVersion)throw Error("HTTP options are not correctly set.");let t=[e.baseUrl.endsWith("/")?e.baseUrl.slice(0,-1):e.baseUrl];return e.apiVersion&&""!==e.apiVersion&&t.push(e.apiVersion),t.join("/")}getBaseResourcePath(){return`projects/${this.clientOptions.project}/locations/${this.clientOptions.location}`}getApiKey(){return this.clientOptions.apiKey}getWebsocketBaseUrl(){let e=new URL(this.getBaseUrl());return e.protocol="http:"==e.protocol?"ws":"wss",e.toString()}setBaseUrl(e){if(this.clientOptions.httpOptions)this.clientOptions.httpOptions.baseUrl=e;else throw Error("HTTP options are not correctly set.")}constructUrl(e,t,n){let i=[this.getRequestUrlInternal(t)];return n&&i.push(this.getBaseResourcePath()),""!==e&&i.push(e),new URL(`${i.join("/")}`)}shouldPrependVertexProjectPath(e,t){return!(t.baseUrl&&t.baseUrlResourceScope===th.COLLECTION||!this.clientOptions.vertexai||!this.clientOptions.project||!this.clientOptions.location||e.path.startsWith("projects/")||"GET"===e.httpMethod&&e.path.startsWith("publishers/google/models"))}async request(e){let t=this.clientOptions.httpOptions;e.httpOptions&&(t=this.patchHttpOptions(this.clientOptions.httpOptions,e.httpOptions));let n=this.shouldPrependVertexProjectPath(e,t),i=this.constructUrl(e.path,t,n);if(e.queryParams)for(let[t,n]of Object.entries(e.queryParams))i.searchParams.append(t,String(n));let r={};if("GET"===e.httpMethod){if(e.body&&"{}"!==e.body)throw Error("Request body should be empty for GET request, but got non empty request body")}else r.body=e.body;return r=await this.includeExtraHttpOptionsToRequestInit(r,t,i.toString()),this.unaryApiCall(i,r,e.httpMethod,t.retryOptions,t.timeout,e.abortSignal,t.fetch)}patchHttpOptions(e,t){let n=JSON.parse(JSON.stringify(e));for(let[i,r]of(e.fetch&&(n.fetch=e.fetch),Object.entries(t)))"object"==typeof r?n[i]=Object.assign(Object.assign({},n[i]),r):void 0!==r&&(n[i]=r);return n}async requestStream(e){let t=this.clientOptions.httpOptions;e.httpOptions&&(t=this.patchHttpOptions(this.clientOptions.httpOptions,e.httpOptions));let n=this.shouldPrependVertexProjectPath(e,t),i=this.constructUrl(e.path,t,n);i.searchParams.has("alt")&&"sse"===i.searchParams.get("alt")||i.searchParams.set("alt","sse");let r={};return r.body=e.body,r=await this.includeExtraHttpOptionsToRequestInit(r,t,i.toString()),this.streamApiCall(i,r,e.httpMethod,t.retryOptions,t.timeout,e.abortSignal,t.fetch)}async includeExtraHttpOptionsToRequestInit(e,t,n){return(null==t?void 0:t.timeout)&&t.timeout>0&&function(e){let t=Symbol.for("undici.globalDispatcher.1"),n=globalThis[t];if(n)for(let t of Object.getOwnPropertySymbols(n)){let i=t.description;if((null==i?void 0:i.includes("headers timeout"))||(null==i?void 0:i.includes("body timeout"))){let i=n[t];"number"==typeof i&&(n[t]=Math.max(i,e))}}}(t.timeout),t&&null!==t.extraBody&&function(e,t){if(!t||0===Object.keys(t).length)return;if(e.body instanceof Blob)return console.warn("includeExtraBodyToRequestInit: extraBody provided but current request body is a Blob. extraBody will be ignored as merging is not supported for Blob bodies.");let n={};if("string"==typeof e.body&&e.body.length>0)try{let t=JSON.parse(e.body);if("object"!=typeof t||null===t||Array.isArray(t))return void console.warn("includeExtraBodyToRequestInit: Original request body is valid JSON but not a non-array object. Skip applying extraBody to the request body.");n=t}catch(e){console.warn("includeExtraBodyToRequestInit: Original request body is not valid JSON. Skip applying extraBody to the request body.");return}e.body=JSON.stringify(function e(t,n){let i=Object.assign({},t);for(let t in n)if(Object.prototype.hasOwnProperty.call(n,t)){let r=n[t],o=i[t];r&&"object"==typeof r&&!Array.isArray(r)&&o&&"object"==typeof o&&!Array.isArray(o)?i[t]=e(o,r):(o&&r&&typeof o!=typeof r&&console.warn(`includeExtraBodyToRequestInit:deepMerge: Type mismatch for key "${t}". Original type: ${typeof o}, New type: ${typeof r}. Overwriting.`),i[t]=r)}return i}(n,t))}(e,t.extraBody),e.headers=await this.getHeadersInternal(t,n),e}async unaryApiCall(e,t,n,i,r,o,l){return this.apiCall(e.toString(),Object.assign(Object.assign({},t),{method:n}),i,r,o,l).then(async e=>(await rp(e),new na(e))).catch(e=>{if(e instanceof Error)throw e;throw Error(`exception ${e} sending request`,{cause:e})})}async streamApiCall(e,t,n,i,r,o,l){return this.apiCall(e.toString(),Object.assign(Object.assign({},t),{method:n}),i,r,o,l).then(async e=>(await rp(e),this.processStreamResponse(e))).catch(e=>{if(e instanceof Error)throw e;throw Error(`exception ${e} sending request`,{cause:e})})}processStreamResponse(e){return iH(this,arguments,function*(){var t;let n=null==(t=null==e?void 0:e.body)?void 0:t.getReader(),i=new TextDecoder("utf-8");if(!n)throw Error("Response body is empty");try{let t="",r="data:",o=["\n\n","\r\r","\r\n\r\n"];for(;;){let{done:l,value:s}=yield iq(n.read());if(l){if(t.trim().length>0)throw Error("Incomplete JSON segment at the end");break}let a=i.decode(s,{stream:!0});try{let e=JSON.parse(a);if("error"in e){let t=JSON.parse(JSON.stringify(e.error)),n=t.status,i=t.code,r=`got status: ${n}. ${JSON.stringify(e)}`;if(i>=400&&i<600)throw new iJ({message:r,status:i})}}catch(e){if("ApiError"===e.name)throw e}t+=a;let u=-1,p=0;for(;;){for(let e of(u=-1,p=0,o)){let n=t.indexOf(e);-1!==n&&(-1===u||n<u)&&(u=n,p=e.length)}if(-1===u)break;let n=t.substring(0,u);t=t.substring(u+p);let i=n.trim();if(i.startsWith(r)){let t=i.substring(r.length).trim();try{let n=new Response(t,{headers:null==e?void 0:e.headers,status:null==e?void 0:e.status,statusText:null==e?void 0:e.statusText});yield yield iq(new na(n))}catch(e){throw Error(`exception parsing stream chunk ${t}. ${e}`)}}}}}finally{n.releaseLock()}})}async apiCall(e,t,n,i,r,o){var l,s,a,u,p,d;let c=null!=o?o:fetch,m=null!=(l=null==n?void 0:n.httpStatusCodes)?l:ra,f=async()=>{let o,l=function(e,t){let n;if(!(e&&e>0)&&!t)return{signal:void 0,dispose:()=>{}};let i=new AbortController;e&&e>0&&(n=setTimeout(()=>i.abort(),e))&&"function"==typeof n.unref&&n.unref();let r=()=>i.abort();return t&&(t.aborted?i.abort():t.addEventListener("abort",r)),{signal:i.signal,dispose:()=>{void 0!==n&&clearTimeout(n),null==t||t.removeEventListener("abort",r)}}}(i,r);try{o=await c(e,Object.assign(Object.assign({},t),{signal:l.signal}))}catch(e){throw l.dispose(),e}if(!n||o.ok||!m.includes(o.status))return o;try{await rp(o)}finally{l.dispose()}return o};if(!n)return f();let h=Math.max(1,null!=(s=n.attempts)?s:5),g=Math.round((null!=(a=n.initialDelay)?a:1)*1e3),_=Math.max(g,Math.round((null!=(u=n.maxDelay)?u:60)*1e3));return tJ(f,{retries:h-1,factor:null!=(p=n.expBase)?p:2,minTimeout:g,maxTimeout:_,randomize:(null!=(d=n.jitter)?d:1)>0,onFailedAttempt:e=>{var t;if(null==r?void 0:r.aborted)throw null!=(t=e.error)?t:e}})}getDefaultHeaders(){let e={},t="google-genai-sdk/2.23.0 "+this.clientOptions.userAgentExtra;return e["User-Agent"]=t,e[rl]=t,e["Content-Type"]="application/json",e}async getHeadersInternal(e,t){let n=new Headers;if(e&&e.headers)for(let[t,i]of Object.entries(e.headers))n.append(t,i);return(null==e?void 0:e.timeout)&&e.timeout>0&&n.append("X-Server-Timeout",String(Math.ceil(e.timeout/1e3))),await this.clientOptions.auth.addAuthHeaders(n,t),n}getFileName(e){var t;let n="";return"string"==typeof e&&(n=null!=(t=(n=e.replace(/[/\\]+$/,"")).split(/[/\\]/).pop())?t:""),n}async uploadFile(e,t){var n;let i={};null!=t&&(i.mimeType=t.mimeType,i.name=t.name,i.displayName=t.displayName),i.name&&!i.name.startsWith("files/")&&(i.name=`files/${i.name}`);let r=this.clientOptions.uploader,o=await r.stat(e);i.sizeBytes=String(o.size);let l=null!=(n=null==t?void 0:t.mimeType)?n:o.type;if(void 0===l||""===l)throw Error("Can not determine mimeType. Please provide mimeType in the config.");i.mimeType=l;let s={file:i},a=this.getFileName(e),u=tK("upload/v1beta/files",s._url),p=await this.fetchUploadUrl(u,i.sizeBytes,i.mimeType,a,s,null==t?void 0:t.httpOptions);return r.upload(e,p,this)}async uploadFileToFileSearchStore(e,t,n){var i;let r=this.clientOptions.uploader,o=await r.stat(t),l=String(o.size),s=null!=(i=null==n?void 0:n.mimeType)?i:o.type;if(void 0===s||""===s)throw Error("Can not determine mimeType. Please provide mimeType in the config.");let a=`upload/v1beta/${e}:uploadToFileSearchStore`,u=this.getFileName(t),p={};null!=n&&ro(n,p);let d=await this.fetchUploadUrl(a,l,s,u,p,null==n?void 0:n.httpOptions);return r.uploadToFileSearchStore(t,d,this)}async downloadFile(e){let t=this.clientOptions.downloader;await t.download(e,this)}async fetchUploadUrl(e,t,n,i,r,o){var l;let s={};s=o||{apiVersion:"",headers:Object.assign({"Content-Type":"application/json","X-Goog-Upload-Protocol":"resumable","X-Goog-Upload-Command":"start","X-Goog-Upload-Header-Content-Length":`${t}`,"X-Goog-Upload-Header-Content-Type":`${n}`},i?{"X-Goog-Upload-File-Name":i}:{})};let a=await this.request({path:e,body:JSON.stringify(r),httpMethod:"POST",httpOptions:s});if(!a||!(null==a?void 0:a.headers))throw Error("Server did not return an HttpResponse or the returned HttpResponse did not have headers.");let u=null==(l=null==a?void 0:a.headers)?void 0:l["x-goog-upload-url"];if(void 0===u)throw Error("Failed to get upload url. Server did not return the x-google-upload-url in the headers");return u}}async function rp(e){var t;if(void 0===e)throw Error("response is undefined");if(!e.ok){let n=e.status,i=JSON.stringify((null==(t=e.headers.get("content-type"))?void 0:t.includes("application/json"))?await e.json():{error:{message:await e.text(),code:e.status,status:e.statusText}});if(n>=400&&n<600)throw new iJ({message:i,status:n});throw Error(i)}}let rd=!1;function rc(e){for(let n of e){var t;if(null!==(t=n)&&"object"==typeof t&&t instanceof rf||"object"==typeof n&&"inputSchema"in n)return!0}return rd}function rm(e){var t;let n=null!=(t=e[rl])?t:"";e[rl]=(n+" mcp_used/unknown").trimStart()}class rf{constructor(e=[],t){this.mcpTools=[],this.functionNameToMcpClient={},this.mcpClients=e,this.config=t}static create(e,t){return new rf(e,t)}async initialize(){var e,t,n,i;if(this.mcpTools.length>0)return;let r={},o=[];for(let u of this.mcpClients)try{for(var l,s=!0,a=(t=void 0,iF(function(e){return iH(this,arguments,function*(e,t=100){let n,i=0;for(;i<t;){let t=yield iq(e.listTools({cursor:n}));for(let e of t.tools)yield yield iq(e),i++;if(!t.nextCursor)break;n=t.nextCursor}})}(u)));!(e=(l=await a.next()).done);s=!0){i=l.value,s=!1,o.push(i);let e=i.name;if(r[e])throw Error(`Duplicate function name ${e} found in MCP tools. Please ensure function names are unique.`);r[e]=u}}catch(e){t={error:e}}finally{try{!s&&!e&&(n=a.return)&&await n.call(a)}finally{if(t)throw t.error}}this.mcpTools=o,this.functionNameToMcpClient=r}async tool(){return await this.initialize(),function(e,t={}){let n=[],i=new Set;for(let r of e){let e=r.name;if(i.has(e))throw Error(`Duplicate function name ${e} found in MCP tools. Please ensure function names are unique.`);i.add(e);let o=function(e,t={}){let n={name:e.name,description:e.description,parametersJsonSchema:e.inputSchema};return e.outputSchema&&(n.responseJsonSchema=e.outputSchema),t.behavior&&(n.behavior=t.behavior),{functionDeclarations:[n]}}(r,t);o.functionDeclarations&&n.push(...o.functionDeclarations)}return{functionDeclarations:n}}(this.mcpTools,this.config)}async callTool(e){await this.initialize();let t=[];for(let n of e)if(n.name in this.functionNameToMcpClient){let e,i=this.functionNameToMcpClient[n.name];this.config.timeout&&(e={timeout:this.config.timeout});let r=await i.callTool({name:n.name,arguments:n.args},void 0,e);t.push({functionResponse:{name:n.name,response:r.isError?{error:r}:r}})}return t}}function rh(...e){if(rd=!0,0===e.length)throw Error("No MCP clients provided");let t=e[e.length-1];return null!==t&&"object"==typeof t&&"listTools"in t&&"function"==typeof t.listTools?rf.create(e,{}):rf.create(e.slice(0,e.length-1),t)}async function rg(e,t,n){let i=new n8;Object.assign(i,n.data instanceof Blob?JSON.parse(await n.data.text()):JSON.parse(n.data)),t(i)}class r_{constructor(e,t,n){this.apiClient=e,this.auth=t,this.webSocketFactory=n}async connect(e){var t,n;let i;if(this.apiClient.isVertexAI())throw Error("Live music is not supported for Vertex AI.");console.warn("Live music generation is experimental and may change in future versions.");let r=this.apiClient.getWebsocketBaseUrl(),o=this.apiClient.getApiVersion(),l=function(e){let t=new Headers;for(let[n,i]of Object.entries(e))t.append(n,i);return t}(this.apiClient.getDefaultHeaders()),s=this.apiClient.getApiKey(),a=`${r}/ws/google.ai.generativelanguage.${o}.GenerativeService.BidiGenerateMusic?key=${s}`,u=()=>{},p=new Promise(e=>{u=e}),d=e.callbacks,c=this.apiClient,m={onopen:function(){u({})},onmessage:e=>{rg(c,d.onmessage,e)},onerror:null!=(t=null==d?void 0:d.onerror)?t:function(e){},onclose:null!=(n=null==d?void 0:d.onclose)?n:function(e){}},f=this.webSocketFactory.create(a,(i={},l.forEach((e,t)=>{i[t]=e}),i),m);f.connect(),await p;let h=n7(this.apiClient,e.model);return f.send(JSON.stringify({setup:{model:h}})),new rE(f,this.apiClient)}}class rE{constructor(e,t){this.conn=e,this.apiClient=t}async setWeightedPrompts(e){if(!e.weightedPrompts||0===Object.keys(e.weightedPrompts).length)throw Error("Weighted prompts must be set and contain at least one entry.");let t=function(e){let t={},n=tz(e,["weightedPrompts"]);if(null!=n){let e=n;Array.isArray(e)&&(e=e.map(e=>e)),tW(t,["weightedPrompts"],e)}return t}(e);this.conn.send(JSON.stringify({clientContent:t}))}async setMusicGenerationConfig(e){let t,n;e.musicGenerationConfig||(e.musicGenerationConfig={});let i=(t={},null!=(n=tz(e,["musicGenerationConfig"]))&&tW(t,["musicGenerationConfig"],n),t);this.conn.send(JSON.stringify(i))}sendPlaybackControl(e){this.conn.send(JSON.stringify({playbackControl:e}))}play(){this.sendPlaybackControl(tB.PLAY)}pause(){this.sendPlaybackControl(tB.PAUSE)}stop(){this.sendPlaybackControl(tB.STOP)}resetContext(){this.sendPlaybackControl(tB.RESET_CONTEXT)}close(){this.conn.close()}}async function ry(e,t,n){let i=new n2,r=JSON.parse(n.data instanceof Blob?await n.data.text():n.data instanceof ArrayBuffer?new TextDecoder().decode(n.data):n.data);if(e.isVertexAI()){var o;let e,t,n,l,s,a,u,p,d,c,m,f,h;Object.assign(i,(e={},null!=(t=tz(r,["setupComplete"]))&&tW(e,["setupComplete"],t),null!=(n=tz(r,["serverContent"]))&&tW(e,["serverContent"],n),null!=(l=tz(r,["toolCall"]))&&tW(e,["toolCall"],l),null!=(s=tz(r,["toolCallCancellation"]))&&tW(e,["toolCallCancellation"],s),null!=(a=tz(r,["usageMetadata"]))&&tW(e,["usageMetadata"],function(e){let t={},n=tz(e,["candidatesTokenCount"]);null!=n&&tW(t,["responseTokenCount"],n);let i=tz(e,["candidatesTokensDetails"]);if(null!=i){let e=i;Array.isArray(e)&&(e=e.map(e=>e)),tW(t,["responseTokensDetails"],e)}let r=tz(e,["cacheTokensDetails"]);if(null!=r){let e=r;Array.isArray(e)&&(e=e.map(e=>e)),tW(t,["cacheTokensDetails"],e)}let o=tz(e,["cachedContentTokenCount"]);null!=o&&tW(t,["cachedContentTokenCount"],o);let l=tz(e,["promptTokenCount"]);null!=l&&tW(t,["promptTokenCount"],l);let s=tz(e,["promptTokensDetails"]);if(null!=s){let e=s;Array.isArray(e)&&(e=e.map(e=>e)),tW(t,["promptTokensDetails"],e)}let a=tz(e,["thoughtsTokenCount"]);null!=a&&tW(t,["thoughtsTokenCount"],a);let u=tz(e,["toolUsePromptTokenCount"]);null!=u&&tW(t,["toolUsePromptTokenCount"],u);let p=tz(e,["toolUsePromptTokensDetails"]);if(null!=p){let e=p;Array.isArray(e)&&(e=e.map(e=>e)),tW(t,["toolUsePromptTokensDetails"],e)}let d=tz(e,["totalTokenCount"]);null!=d&&tW(t,["totalTokenCount"],d);let c=tz(e,["trafficType"]);return null!=c&&tW(t,["trafficType"],c),t}(a)),null!=(u=tz(r,["goAway"]))&&tW(e,["goAway"],u),null!=(p=tz(r,["sessionResumptionUpdate"]))&&tW(e,["sessionResumptionUpdate"],p),null!=(d=tz(r,["voiceActivityDetectionSignal"]))&&tW(e,["voiceActivityDetectionSignal"],d),null!=(c=tz(r,["voiceActivity"]))&&tW(e,["voiceActivity"],(m={},null!=(f=tz(o=c,["type"]))&&tW(m,["voiceActivityType"],f),null!=(h=tz(o,["audioOffset"]))&&tW(m,["audioOffset"],h),m)),e))}else Object.assign(i,r);t(i)}class rv{constructor(e,t,n){this.apiClient=e,this.auth=t,this.webSocketFactory=n,this.music=new r_(this.apiClient,this.auth,this.webSocketFactory)}async connect(e){var t,n,i,r,o,l,s,a;let u,p;if(e.config&&e.config.httpOptions)throw Error("The Live module does not support httpOptions at request-level in LiveConnectConfig yet. Please use the client-level httpOptions configuration instead.");let d=this.apiClient.getWebsocketBaseUrl(),c=this.apiClient.getApiVersion(),m=this.apiClient.getHeaders();e.config&&e.config.tools&&rc(e.config.tools)&&rm(m);let f=function(e){let t=new Headers;for(let[n,i]of Object.entries(e))t.append(n,i);return t}(m);if(this.apiClient.isVertexAI()){let e=this.apiClient.getProject(),t=this.apiClient.getLocation(),n=this.apiClient.getApiKey();this.apiClient.getCustomBaseUrl()&&!(e&&t||n)?u=d:(u=`${d}/ws/google.cloud.aiplatform.${c}.LlmBidiService/BidiGenerateContent`,await this.auth.addAuthHeaders(f,u))}else{let e=this.apiClient.getApiKey(),t="BidiGenerateContent",n="key";(null==e?void 0:e.startsWith("auth_tokens/"))&&(console.warn("Warning: Ephemeral token support is experimental and may change in future versions."),"v1alpha"!==c&&console.warn("Warning: The SDK's ephemeral token support is in v1alpha only. Please use const ai = new GoogleGenAI({apiKey: token.name, httpOptions: { apiVersion: 'v1alpha' }}); before session connection."),t="BidiGenerateContentConstrained",n="access_token"),u=`${d}/ws/google.ai.generativelanguage.${c}.GenerativeService.${t}?${n}=${e}`}let h=()=>{},g=new Promise(e=>{h=e}),_=e.callbacks,E=this.apiClient,y=!1,v=[],A=()=>{},I=new Promise(e=>{A=e}),T={onopen:function(){var e;null==(e=null==_?void 0:_.onopen)||e.call(_),h({})},onmessage:e=>{ry(E,e=>{e.setupComplete&&!N.setupComplete&&(N.setupComplete=e.setupComplete,A({})),y?_.onmessage(e):v.push(e)},e)},onerror:null!=(t=null==_?void 0:_.onerror)?t:function(e){},onclose:null!=(n=null==_?void 0:_.onclose)?n:function(e){}},C=this.webSocketFactory.create(u,(p={},f.forEach((e,t)=>{p[t]=e}),p),T);C.connect(),await g;let S=n7(this.apiClient,e.model);if(this.apiClient.isVertexAI()&&S.startsWith("publishers/")){let e=this.apiClient.getProject(),t=this.apiClient.getLocation();e&&t&&(S=`projects/${e}/locations/${t}/`+S)}let O={};this.apiClient.isVertexAI()&&(null==(i=e.config)?void 0:i.responseModalities)===void 0&&(void 0===e.config?e.config={responseModalities:[e5.AUDIO]}:e.config.responseModalities=[e5.AUDIO]),(null==(r=e.config)?void 0:r.generationConfig)&&console.warn("Setting `LiveConnectConfig.generation_config` is deprecated, please set the fields on `LiveConnectConfig` directly. It will be removed in the next major version (not before 7/31/2026).");let b=null!=(l=null==(o=e.config)?void 0:o.tools)?l:[],P=[];for(let e of b)this.isCallableTool(e)?P.push(await e.tool()):P.push(e);P.length>0&&(e.config.tools=P);let R={model:S,config:e.config,callbacks:e.callbacks};if(this.apiClient.isVertexAI()){let e,t,n;s=this.apiClient,e={},null!=(t=tz(R,["model"]))&&tW(e,["setup","model"],n7(s,t)),null!=(n=tz(R,["config"]))&&tW(e,["config"],function(e,t){let n=tz(e,["generationConfig"]);void 0!==t&&null!=n&&tW(t,["setup","generationConfig"],function(e){let t={},n=tz(e,["modelSelectionConfig"]);null!=n&&tW(t,["modelConfig"],n);let i=tz(e,["responseJsonSchema"]);null!=i&&tW(t,["responseJsonSchema"],i);let r=tz(e,["audioTranscriptionConfig"]);null!=r&&tW(t,["audioTranscriptionConfig"],r);let o=tz(e,["audioTimestamp"]);null!=o&&tW(t,["audioTimestamp"],o);let l=tz(e,["candidateCount"]);null!=l&&tW(t,["candidateCount"],l);let s=tz(e,["enableAffectiveDialog"]);null!=s&&tW(t,["enableAffectiveDialog"],s);let a=tz(e,["frequencyPenalty"]);null!=a&&tW(t,["frequencyPenalty"],a);let u=tz(e,["logprobs"]);null!=u&&tW(t,["logprobs"],u);let p=tz(e,["maxOutputTokens"]);null!=p&&tW(t,["maxOutputTokens"],p);let d=tz(e,["mediaResolution"]);null!=d&&tW(t,["mediaResolution"],d);let c=tz(e,["presencePenalty"]);null!=c&&tW(t,["presencePenalty"],c);let m=tz(e,["responseFormat"]);if(null!=m){let e=m;Array.isArray(e)&&(e=e.map(e=>e)),tW(t,["responseFormat"],e)}let f=tz(e,["responseLogprobs"]);null!=f&&tW(t,["responseLogprobs"],f);let h=tz(e,["responseMimeType"]);null!=h&&tW(t,["responseMimeType"],h);let g=tz(e,["responseModalities"]);null!=g&&tW(t,["responseModalities"],g);let _=tz(e,["responseSchema"]);null!=_&&tW(t,["responseSchema"],_);let E=tz(e,["routingConfig"]);null!=E&&tW(t,["routingConfig"],E);let y=tz(e,["seed"]);null!=y&&tW(t,["seed"],y);let v=tz(e,["speechConfig"]);null!=v&&tW(t,["speechConfig"],iK(v));let A=tz(e,["stopSequences"]);null!=A&&tW(t,["stopSequences"],A);let I=tz(e,["temperature"]);null!=I&&tW(t,["temperature"],I);let T=tz(e,["thinkingConfig"]);null!=T&&tW(t,["thinkingConfig"],T);let C=tz(e,["topK"]);null!=C&&tW(t,["topK"],C);let S=tz(e,["topP"]);if(null!=S&&tW(t,["topP"],S),void 0!==tz(e,["enableEnhancedCivicAnswers"]))throw Error("enableEnhancedCivicAnswers parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.");if(void 0!==tz(e,["translationConfig"]))throw Error("translationConfig parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.");return t}(n));let i=tz(e,["responseModalities"]);void 0!==t&&null!=i&&tW(t,["setup","generationConfig","responseModalities"],i);let r=tz(e,["temperature"]);void 0!==t&&null!=r&&tW(t,["setup","generationConfig","temperature"],r);let o=tz(e,["topP"]);void 0!==t&&null!=o&&tW(t,["setup","generationConfig","topP"],o);let l=tz(e,["topK"]);void 0!==t&&null!=l&&tW(t,["setup","generationConfig","topK"],l);let s=tz(e,["maxOutputTokens"]);void 0!==t&&null!=s&&tW(t,["setup","generationConfig","maxOutputTokens"],s);let a=tz(e,["mediaResolution"]);void 0!==t&&null!=a&&tW(t,["setup","generationConfig","mediaResolution"],a);let u=tz(e,["seed"]);void 0!==t&&null!=u&&tW(t,["setup","generationConfig","seed"],u);let p=tz(e,["speechConfig"]);void 0!==t&&null!=p&&tW(t,["setup","generationConfig","speechConfig"],iK(i_(p)));let d=tz(e,["thinkingConfig"]);void 0!==t&&null!=d&&tW(t,["setup","generationConfig","thinkingConfig"],d);let c=tz(e,["enableAffectiveDialog"]);void 0!==t&&null!=c&&tW(t,["setup","generationConfig","enableAffectiveDialog"],c);let m=tz(e,["systemInstruction"]);void 0!==t&&null!=m&&tW(t,["setup","systemInstruction"],function(e){let t={},n=tz(e,["parts"]);if(null!=n){let e=n;Array.isArray(e)&&(e=e.map(e=>(function(e){let t={},n=tz(e,["mediaResolution"]);if(null!=n&&tW(t,["mediaResolution"],n),void 0!==tz(e,["toolCall"]))throw Error("toolCall parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.");if(void 0!==tz(e,["toolResponse"]))throw Error("toolResponse parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.");let i=tz(e,["audioTranscription"]);null!=i&&tW(t,["audioTranscription"],i);let r=tz(e,["codeExecutionResult"]);null!=r&&tW(t,["codeExecutionResult"],r);let o=tz(e,["executableCode"]);null!=o&&tW(t,["executableCode"],o);let l=tz(e,["fileData"]);null!=l&&tW(t,["fileData"],l);let s=tz(e,["functionCall"]);null!=s&&tW(t,["functionCall"],s);let a=tz(e,["functionResponse"]);null!=a&&tW(t,["functionResponse"],a);let u=tz(e,["inlineData"]);null!=u&&tW(t,["inlineData"],u);let p=tz(e,["text"]);null!=p&&tW(t,["text"],p);let d=tz(e,["thought"]);null!=d&&tW(t,["thought"],d);let c=tz(e,["thoughtSignature"]);null!=c&&tW(t,["thoughtSignature"],c);let m=tz(e,["videoMetadata"]);if(null!=m&&tW(t,["videoMetadata"],m),void 0!==tz(e,["partMetadata"]))throw Error("partMetadata parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.");let f=tz(e,["mediaProcessing"]);return null!=f&&tW(t,["mediaProcessing"],f),t})(e))),tW(t,["parts"],e)}let i=tz(e,["role"]);return null!=i&&tW(t,["role"],i),t}(id(m)));let f=tz(e,["tools"]);if(void 0!==t&&null!=f){let e=iy(f);Array.isArray(e)&&(e=e.map(e=>(function(e){let t={},n=tz(e,["retrieval"]);null!=n&&tW(t,["retrieval"],n);let i=tz(e,["googleMaps"]);null!=i&&tW(t,["googleMaps"],i);let r=tz(e,["mcpServers"]);if(null!=r){let e=r;Array.isArray(e)&&(e=e.map(e=>(function(e){if(void 0!==tz(e,["name"]))throw Error("name parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.");if(void 0!==tz(e,["streamableHttpTransport"]))throw Error("streamableHttpTransport parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.");return{}})(e))),tW(t,["mcpServers"],e)}let o=tz(e,["codeExecution"]);null!=o&&tW(t,["codeExecution"],o);let l=tz(e,["computerUse"]);null!=l&&tW(t,["computerUse"],function(e){let t={},n=tz(e,["enablePromptInjectionDetection"]);null!=n&&tW(t,["enablePromptInjectionDetection"],n);let i=tz(e,["environment"]);null!=i&&tW(t,["environment"],i);let r=tz(e,["excludedPredefinedFunctions"]);if(null!=r&&tW(t,["excludedPredefinedFunctions"],r),void 0!==tz(e,["disabledSafetyPolicies"]))throw Error("disabledSafetyPolicies parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.");return t}(l));let s=tz(e,["enterpriseWebSearch"]);null!=s&&tW(t,["enterpriseWebSearch"],s);let a=tz(e,["exaAiSearch"]);null!=a&&tW(t,["exaAiSearch"],a);let u=tz(e,["functionDeclarations"]);if(null!=u){let e=u;Array.isArray(e)&&(e=e.map(e=>e)),tW(t,["functionDeclarations"],e)}let p=tz(e,["googleSearch"]);null!=p&&tW(t,["googleSearch"],p);let d=tz(e,["googleSearchRetrieval"]);null!=d&&tW(t,["googleSearchRetrieval"],d);let c=tz(e,["parallelAiSearch"]);null!=c&&tW(t,["parallelAiSearch"],c);let m=tz(e,["urlContext"]);if(null!=m&&tW(t,["urlContext"],m),void 0!==tz(e,["fileSearch"]))throw Error("fileSearch parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.");return t})(iE(e)))),tW(t,["setup","tools"],e)}let h=tz(e,["sessionResumption"]);void 0!==t&&null!=h&&tW(t,["setup","sessionResumption"],h);let g=tz(e,["inputAudioTranscription"]);void 0!==t&&null!=g&&tW(t,["setup","inputAudioTranscription"],g);let _=tz(e,["outputAudioTranscription"]);void 0!==t&&null!=_&&tW(t,["setup","outputAudioTranscription"],_);let E=tz(e,["realtimeInputConfig"]);void 0!==t&&null!=E&&tW(t,["setup","realtimeInputConfig"],E);let y=tz(e,["contextWindowCompression"]);void 0!==t&&null!=y&&tW(t,["setup","contextWindowCompression"],y);let v=tz(e,["proactivity"]);void 0!==t&&null!=v&&tW(t,["setup","proactivity"],v);let A=tz(e,["explicitVadSignal"]);void 0!==t&&null!=A&&tW(t,["setup","explicitVadSignal"],A);let I=tz(e,["avatarConfig"]);void 0!==t&&null!=I&&tW(t,["setup","avatarConfig"],I);let T=tz(e,["safetySettings"]);if(void 0!==t&&null!=T){let e=T;Array.isArray(e)&&(e=e.map(e=>e)),tW(t,["setup","safetySettings"],e)}let C=tz(e,["translationConfig"]);return void 0!==t&&null!=C&&tW(t,["setup","generationConfig","translationConfig"],C),{}}(n,e)),O=e}else{let e,t,n;a=this.apiClient,e={},null!=(t=tz(R,["model"]))&&tW(e,["setup","model"],n7(a,t)),null!=(n=tz(R,["config"]))&&tW(e,["config"],function(e,t){let n=tz(e,["generationConfig"]);void 0!==t&&null!=n&&tW(t,["setup","generationConfig"],n);let i=tz(e,["responseModalities"]);void 0!==t&&null!=i&&tW(t,["setup","generationConfig","responseModalities"],i);let r=tz(e,["temperature"]);void 0!==t&&null!=r&&tW(t,["setup","generationConfig","temperature"],r);let o=tz(e,["topP"]);void 0!==t&&null!=o&&tW(t,["setup","generationConfig","topP"],o);let l=tz(e,["topK"]);void 0!==t&&null!=l&&tW(t,["setup","generationConfig","topK"],l);let s=tz(e,["maxOutputTokens"]);void 0!==t&&null!=s&&tW(t,["setup","generationConfig","maxOutputTokens"],s);let a=tz(e,["mediaResolution"]);void 0!==t&&null!=a&&tW(t,["setup","generationConfig","mediaResolution"],a);let u=tz(e,["seed"]);void 0!==t&&null!=u&&tW(t,["setup","generationConfig","seed"],u);let p=tz(e,["speechConfig"]);void 0!==t&&null!=p&&tW(t,["setup","generationConfig","speechConfig"],i_(p));let d=tz(e,["thinkingConfig"]);void 0!==t&&null!=d&&tW(t,["setup","generationConfig","thinkingConfig"],d);let c=tz(e,["enableAffectiveDialog"]);void 0!==t&&null!=c&&tW(t,["setup","generationConfig","enableAffectiveDialog"],c);let m=tz(e,["systemInstruction"]);void 0!==t&&null!=m&&tW(t,["setup","systemInstruction"],function(e){let t={},n=tz(e,["parts"]);if(null!=n){let e=n;Array.isArray(e)&&(e=e.map(e=>{var t;let n,i,r,o,l,s,a,u,p,d,c,m,f,h,g,_,E;return n={},null!=(i=tz(t=e,["mediaResolution"]))&&tW(n,["mediaResolution"],i),null!=(r=tz(t,["toolCall"]))&&tW(n,["toolCall"],r),null!=(o=tz(t,["toolResponse"]))&&tW(n,["toolResponse"],o),null!=(l=tz(t,["audioTranscription"]))&&tW(n,["audioTranscription"],l),null!=(s=tz(t,["codeExecutionResult"]))&&tW(n,["codeExecutionResult"],s),null!=(a=tz(t,["executableCode"]))&&tW(n,["executableCode"],a),null!=(u=tz(t,["fileData"]))&&tW(n,["fileData"],function(e){let t={};if(void 0!==tz(e,["displayName"]))throw Error("displayName parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let n=tz(e,["fileUri"]);null!=n&&tW(t,["fileUri"],n);let i=tz(e,["mimeType"]);return null!=i&&tW(t,["mimeType"],i),t}(u)),null!=(p=tz(t,["functionCall"]))&&tW(n,["functionCall"],function(e){let t={},n=tz(e,["args"]);null!=n&&tW(t,["args"],n);let i=tz(e,["id"]);null!=i&&tW(t,["id"],i);let r=tz(e,["name"]);if(null!=r&&tW(t,["name"],r),void 0!==tz(e,["partialArgs"]))throw Error("partialArgs parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==tz(e,["willContinue"]))throw Error("willContinue parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");return t}(p)),null!=(d=tz(t,["functionResponse"]))&&tW(n,["functionResponse"],d),null!=(c=tz(t,["inlineData"]))&&tW(n,["inlineData"],i$(c)),null!=(m=tz(t,["text"]))&&tW(n,["text"],m),null!=(f=tz(t,["thought"]))&&tW(n,["thought"],f),null!=(h=tz(t,["thoughtSignature"]))&&tW(n,["thoughtSignature"],h),null!=(g=tz(t,["videoMetadata"]))&&tW(n,["videoMetadata"],g),null!=(_=tz(t,["partMetadata"]))&&tW(n,["partMetadata"],_),null!=(E=tz(t,["mediaProcessing"]))&&tW(n,["mediaProcessing"],E),n})),tW(t,["parts"],e)}let i=tz(e,["role"]);return null!=i&&tW(t,["role"],i),t}(id(m)));let f=tz(e,["tools"]);if(void 0!==t&&null!=f){let e=iy(f);Array.isArray(e)&&(e=e.map(e=>(function(e){let t={};if(void 0!==tz(e,["retrieval"]))throw Error("retrieval parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let n=tz(e,["googleMaps"]);null!=n&&tW(t,["googleMaps"],function(e){let t={},n=tz(e,["authConfig"]);null!=n&&tW(t,["authConfig"],function(e){let t={},n=tz(e,["apiKey"]);if(null!=n&&tW(t,["apiKey"],n),void 0!==tz(e,["apiKeyConfig"]))throw Error("apiKeyConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==tz(e,["authType"]))throw Error("authType parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==tz(e,["googleServiceAccountConfig"]))throw Error("googleServiceAccountConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==tz(e,["httpBasicAuthConfig"]))throw Error("httpBasicAuthConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==tz(e,["oauthConfig"]))throw Error("oauthConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==tz(e,["oidcConfig"]))throw Error("oidcConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");return t}(n));let i=tz(e,["enableWidget"]);if(null!=i&&tW(t,["enableWidget"],i),void 0!==tz(e,["groundingTypes"]))throw Error("groundingTypes parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");return t}(n));let i=tz(e,["mcpServers"]);if(null!=i){let e=i;Array.isArray(e)&&(e=e.map(e=>e)),tW(t,["mcpServers"],e)}let r=tz(e,["codeExecution"]);null!=r&&tW(t,["codeExecution"],r);let o=tz(e,["computerUse"]);if(null!=o&&tW(t,["computerUse"],o),void 0!==tz(e,["enterpriseWebSearch"]))throw Error("enterpriseWebSearch parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==tz(e,["exaAiSearch"]))throw Error("exaAiSearch parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let l=tz(e,["functionDeclarations"]);if(null!=l){let e=l;Array.isArray(e)&&(e=e.map(e=>e)),tW(t,["functionDeclarations"],e)}let s=tz(e,["googleSearch"]);null!=s&&tW(t,["googleSearch"],function(e){let t={};if(void 0!==tz(e,["blockingConfidence"]))throw Error("blockingConfidence parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==tz(e,["excludeDomains"]))throw Error("excludeDomains parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let n=tz(e,["searchTypes"]);null!=n&&tW(t,["searchTypes"],n);let i=tz(e,["timeRangeFilter"]);return null!=i&&tW(t,["timeRangeFilter"],i),t}(s));let a=tz(e,["googleSearchRetrieval"]);if(null!=a&&tW(t,["googleSearchRetrieval"],a),void 0!==tz(e,["parallelAiSearch"]))throw Error("parallelAiSearch parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let u=tz(e,["urlContext"]);null!=u&&tW(t,["urlContext"],u);let p=tz(e,["fileSearch"]);return null!=p&&tW(t,["fileSearch"],p),t})(iE(e)))),tW(t,["setup","tools"],e)}let h=tz(e,["sessionResumption"]);void 0!==t&&null!=h&&tW(t,["setup","sessionResumption"],function(e){let t={},n=tz(e,["handle"]);if(null!=n&&tW(t,["handle"],n),void 0!==tz(e,["transparent"]))throw Error("transparent parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");return t}(h));let g=tz(e,["inputAudioTranscription"]);void 0!==t&&null!=g&&tW(t,["setup","inputAudioTranscription"],g);let _=tz(e,["outputAudioTranscription"]);void 0!==t&&null!=_&&tW(t,["setup","outputAudioTranscription"],_);let E=tz(e,["realtimeInputConfig"]);void 0!==t&&null!=E&&tW(t,["setup","realtimeInputConfig"],E);let y=tz(e,["contextWindowCompression"]);void 0!==t&&null!=y&&tW(t,["setup","contextWindowCompression"],y);let v=tz(e,["proactivity"]);if(void 0!==t&&null!=v&&tW(t,["setup","proactivity"],v),void 0!==tz(e,["explicitVadSignal"]))throw Error("explicitVadSignal parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let A=tz(e,["avatarConfig"]);void 0!==t&&null!=A&&tW(t,["setup","avatarConfig"],A);let I=tz(e,["safetySettings"]);if(void 0!==t&&null!=I){let e=I;Array.isArray(e)&&(e=e.map(e=>(function(e){let t={},n=tz(e,["category"]);if(null!=n&&tW(t,["category"],n),void 0!==tz(e,["method"]))throw Error("method parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let i=tz(e,["threshold"]);return null!=i&&tW(t,["threshold"],i),t})(e))),tW(t,["setup","safetySettings"],e)}let T=tz(e,["translationConfig"]);return void 0!==t&&null!=T&&tW(t,["setup","generationConfig","translationConfig"],T),{}}(n,e)),O=e}delete O.config;let N=new rI(C,this.apiClient);for(let e of(C.send(JSON.stringify(O)),await I,y=!0,v))_.onmessage(e);return N}isCallableTool(e){return"callTool"in e&&"function"==typeof e.callTool}}let rA={turnComplete:!0};class rI{constructor(e,t){this.conn=e,this.apiClient=t}tLiveClientContent(e,t){if(null!==t.turns&&void 0!==t.turns){let n=[];try{n=im(t.turns),e.isVertexAI()||(n=n.map(e=>iz(e)))}catch(e){throw Error(`Failed to parse client content "turns", type: '${typeof t.turns}'`)}return{clientContent:{turns:n,turnComplete:t.turnComplete}}}return{clientContent:{turnComplete:t.turnComplete}}}tLiveClienttToolResponse(e,t){let n=[];if(null==t.functionResponses||0===(n=Array.isArray(t.functionResponses)?t.functionResponses:[t.functionResponses]).length)throw Error("functionResponses is required.");for(let t of n){if("object"!=typeof t||null===t||!("name"in t)||!("response"in t))throw Error(`Could not parse function response, type '${typeof t}'.`);if(!e.isVertexAI()&&!("id"in t))throw Error("FunctionResponse request must have an `id` field from the response of a ToolCall.FunctionalCalls in Google AI.")}return{toolResponse:{functionResponses:n}}}sendClientContent(e){e=Object.assign(Object.assign({},rA),e);let t=this.tLiveClientContent(this.apiClient,e);this.conn.send(JSON.stringify(t))}sendRealtimeInput(e){let t={};t=this.apiClient.isVertexAI()?{realtimeInput:function(e){let t={},n=tz(e,["media"]);if(null!=n){let e=it(n);Array.isArray(e)&&(e=e.map(e=>e)),tW(t,["mediaChunks"],e)}let i=tz(e,["audio"]);null!=i&&tW(t,["audio"],io(i));let r=tz(e,["audioStreamEnd"]);null!=r&&tW(t,["audioStreamEnd"],r);let o=tz(e,["video"]);null!=o&&tW(t,["video"],ir(o));let l=tz(e,["text"]);null!=l&&tW(t,["text"],l);let s=tz(e,["activityStart"]);null!=s&&tW(t,["activityStart"],s);let a=tz(e,["activityEnd"]);return null!=a&&tW(t,["activityEnd"],a),t}(e)}:{realtimeInput:function(e){let t={},n=tz(e,["media"]);if(null!=n){let e=it(n);Array.isArray(e)&&(e=e.map(e=>i$(e))),tW(t,["mediaChunks"],e)}let i=tz(e,["audio"]);null!=i&&tW(t,["audio"],i$(io(i)));let r=tz(e,["audioStreamEnd"]);null!=r&&tW(t,["audioStreamEnd"],r);let o=tz(e,["video"]);null!=o&&tW(t,["video"],i$(ir(o)));let l=tz(e,["text"]);null!=l&&tW(t,["text"],l);let s=tz(e,["activityStart"]);null!=s&&tW(t,["activityStart"],s);let a=tz(e,["activityEnd"]);return null!=a&&tW(t,["activityEnd"],a),t}(e)},this.conn.send(JSON.stringify(t))}sendToolResponse(e){if(null==e.functionResponses)throw Error("Tool response parameters are required.");let t=this.tLiveClienttToolResponse(this.apiClient,e);this.conn.send(JSON.stringify(t))}close(){this.conn.close()}}function rT(e){var t,n,i;if(null==(t=null==e?void 0:e.automaticFunctionCalling)?void 0:t.disable)return!0;let r=!1;for(let t of null!=(n=null==e?void 0:e.tools)?n:[])if(rC(t)){r=!0;break}if(!r)return!0;let o=null==(i=null==e?void 0:e.automaticFunctionCalling)?void 0:i.maximumRemoteCalls;return(!(!o||!(o<0)&&Number.isInteger(o))||0==o)&&(console.warn("Invalid maximumRemoteCalls value provided for automatic function calling. Disabled automatic function calling. Please provide a valid integer value greater than 0. maximumRemoteCalls provided:",o),!0)}function rC(e){return"callTool"in e&&"function"==typeof e.callTool}function rS(e){var t;let n=[];return(null==(t=null==e?void 0:e.config)?void 0:t.tools)&&e.config.tools.forEach((e,t)=>{rC(e)||e.functionDeclarations&&e.functionDeclarations.length>0&&n.push(t)}),n}function rO(e){var t;return!(null==(t=null==e?void 0:e.automaticFunctionCalling)?void 0:t.ignoreCallHistory)}class rb extends t${constructor(e){super(),this.apiClient=e,this.embedContent=async e=>{if(!this.apiClient.isVertexAI())return e.model.includes("gemini-embedding-2")&&(e.contents=im(e.contents)),await this.embedContentInternal(e);if(e.model.includes("gemini")&&"gemini-embedding-001"!==e.model||e.model.includes("maas")){let t=im(e.contents);if(t.length>1)throw Error("The embedContent API for this model only supports one content at a time.");let n=Object.assign(Object.assign({},e),{content:t[0],embeddingApiType:t_.EMBED_CONTENT});return await this.embedContentInternal(n)}{let t=Object.assign(Object.assign({},e),{embeddingApiType:t_.PREDICT});return await this.embedContentInternal(t)}},this.generateContent=async e=>{var t,n,i,r,o,l,s,a;let u,p,d=await this.processParamsMaybeAddMcpUsage(e);if(this.maybeMoveToResponseJsonSchema(e),!(null!=(a=null==(s=null==(l=e.config)?void 0:l.tools)?void 0:s.some(e=>rC(e)))&&a)||rT(e.config))return await this.generateContentInternal(d);let c=rS(e);if(c.length>0){let e=c.map(e=>`tools[${e}]`).join(", ");throw Error(`Automatic function calling with CallableTools (or MCP objects) and basic FunctionDeclarations is not yet supported. Incompatible tools found at ${e}.`)}let m=im(d.contents),f=null!=(i=null==(n=null==(t=d.config)?void 0:t.automaticFunctionCalling)?void 0:n.maximumRemoteCalls)?i:10,h=0;for(;h<f&&(u=await this.generateContentInternal(d)).functionCalls&&0!==u.functionCalls.length;){let t=u.candidates[0].content,n=[];for(let t of null!=(o=null==(r=e.config)?void 0:r.tools)?o:[])if(rC(t)){let e=await t.callTool(u.functionCalls);n.push(...e)}h++,p={role:"user",parts:n},d.contents=im(d.contents),d.contents.push(t),d.contents.push(p),rO(d.config)&&(m.push(t),m.push(p))}return rO(d.config)&&(u.automaticFunctionCallingHistory=m),u},this.generateContentStream=async e=>{var t,n,i,r,o;if(this.maybeMoveToResponseJsonSchema(e),rT(e.config)){let t=await this.processParamsMaybeAddMcpUsage(e);return await this.generateContentStreamInternal(t)}let l=rS(e);if(l.length>0){let e=l.map(e=>`tools[${e}]`).join(", ");throw Error(`Incompatible tools found at ${e}. Automatic function calling with CallableTools (or MCP objects) and basic FunctionDeclarations" is not yet supported.`)}let s=null==(i=null==(n=null==(t=null==e?void 0:e.config)?void 0:t.toolConfig)?void 0:n.functionCallingConfig)?void 0:i.streamFunctionCallArguments,a=null==(o=null==(r=null==e?void 0:e.config)?void 0:r.automaticFunctionCalling)?void 0:o.disable;if(s&&!a)throw Error("Running in streaming mode with 'streamFunctionCallArguments' enabled, this feature is not compatible with automatic function calling (AFC). Please set 'config.automaticFunctionCalling.disable' to true to disable AFC or leave 'config.toolConfig.functionCallingConfig.streamFunctionCallArguments' to be undefined or set to false to disable streaming function call arguments feature.");return await this.processAfcStream(e)},this.generateImages=async e=>(rb.loggedGenerateImagesWarning||(rb.loggedGenerateImagesWarning=!0,console.warn("The generateImages method is deprecated and will be removed in the next major release (not before Jan. 1 2027). Please use the generateContent method with image models instead. See https://ai.google.dev/gemini-api/docs/deprecations#imagen-models and https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/capabilities/image-generation#generate-images")),await this.generateImagesInternal(e).then(e=>{var t;let n,i=[];if(null==e?void 0:e.generatedImages)for(let r of e.generatedImages)r&&(null==r?void 0:r.safetyAttributes)&&(null==(t=null==r?void 0:r.safetyAttributes)?void 0:t.contentType)==="Positive Prompt"?n=null==r?void 0:r.safetyAttributes:i.push(r);return n?{generatedImages:i,positivePromptSafetyAttributes:n,sdkHttpResponse:e.sdkHttpResponse}:{generatedImages:i,sdkHttpResponse:e.sdkHttpResponse}})),this.list=async e=>{var t;let n={config:Object.assign(Object.assign({},{queryBase:!0}),null==e?void 0:e.config)};if(this.apiClient.isVertexAI()&&!n.config.queryBase)if(null==(t=n.config)?void 0:t.filter)throw Error("Filtering tuned models list is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.");else n.config.filter="labels.tune-type:*";return new iG(tX.PAGED_ITEM_MODELS,e=>this.listInternal(e),await this.listInternal(n),n)},this.editImage=async e=>{rb.loggedEditImageWarning||(rb.loggedEditImageWarning=!0,console.warn("The editImage method is deprecated and will be removed in the next major release (not before Jan. 1 2027). Please use the generateContent method with image models instead. See https://ai.google.dev/gemini-api/docs/deprecations#imagen-models and https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/capabilities/gemini-edit-images#edit-an-image"));let t={model:e.model,prompt:e.prompt,referenceImages:[],config:e.config};return e.referenceImages&&e.referenceImages&&(t.referenceImages=e.referenceImages.map(e=>e.toReferenceImageAPI())),await this.editImageInternal(t)},this.upscaleImage=async e=>{let t={numberOfImages:1,mode:"upscale"};e.config&&(t=Object.assign(Object.assign({},t),e.config));let n={model:e.model,image:e.image,upscaleFactor:e.upscaleFactor,config:t};return await this.upscaleImageInternal(n)},this.generateVideos=async e=>{var t,n,i,r,o,l;if((e.prompt||e.image||e.video)&&e.source)throw Error("Source and prompt/image/video are mutually exclusive. Please only use source.");return(e.prompt||e.image||e.video)&&!rb.loggedGenerateVideosWarning&&(rb.loggedGenerateVideosWarning=!0,console.warn("The generateVideos method with prompt/image/video arguments is deprecated and will be removed in a future major release (not before 2026-07-31). Please use the source argument instead.")),!this.apiClient.isVertexAI()&&((null==(t=e.video)?void 0:t.uri)&&(null==(n=e.video)?void 0:n.videoBytes)?e.video={uri:e.video.uri,mimeType:e.video.mimeType}:(null==(r=null==(i=e.source)?void 0:i.video)?void 0:r.uri)&&(null==(l=null==(o=e.source)?void 0:o.video)?void 0:l.videoBytes)&&(e.source.video={uri:e.source.video.uri,mimeType:e.source.video.mimeType})),await this.generateVideosInternal(e)}}maybeMoveToResponseJsonSchema(e){e.config&&e.config.responseSchema&&!e.config.responseJsonSchema&&Object.keys(e.config.responseSchema).includes("$schema")&&(e.config.responseJsonSchema=e.config.responseSchema,delete e.config.responseSchema)}async processParamsMaybeAddMcpUsage(e){var t,n,i;let r=null==(t=e.config)?void 0:t.tools;if(!r)return e;let o=await Promise.all(r.map(async e=>rC(e)?await e.tool():e)),l={model:e.model,contents:e.contents,config:Object.assign(Object.assign({},e.config),{tools:o})};if(l.config.tools=o,e.config&&e.config.tools&&rc(e.config.tools)){let t=Object.assign({},null!=(i=null==(n=e.config.httpOptions)?void 0:n.headers)?i:{});0===Object.keys(t).length&&(t=this.apiClient.getDefaultHeaders()),rm(t),l.config.httpOptions=Object.assign(Object.assign({},e.config.httpOptions),{headers:t})}return l}async initAfcToolsMap(e){var t,n,i;let r=new Map;for(let o of null!=(n=null==(t=e.config)?void 0:t.tools)?n:[])if(rC(o))for(let e of null!=(i=(await o.tool()).functionDeclarations)?i:[]){if(!e.name)throw Error("Function declaration name is required.");if(r.has(e.name))throw Error(`Duplicate tool declaration name: ${e.name}`);r.set(e.name,o)}return r}async processAfcStream(e){var t,n,i;let r=null!=(i=null==(n=null==(t=e.config)?void 0:t.automaticFunctionCalling)?void 0:n.maximumRemoteCalls)?i:10,o=!1,l=0;return function(e,t,n){return iH(this,arguments,function*(){for(;l<r;){o&&(l++,o=!1);let h=yield iq(e.processParamsMaybeAddMcpUsage(n)),g=yield iq(e.generateContentStreamInternal(h)),_=[],E=[];try{for(var i,s,a,u,p,d,c,m=!0,f=(s=void 0,iF(g));!(i=(c=yield iq(f.next())).done);m=!0)if(u=c.value,m=!1,yield yield iq(u),u.candidates&&(null==(p=u.candidates[0])?void 0:p.content)){for(let e of(E.push(u.candidates[0].content),null!=(d=u.candidates[0].content.parts)?d:[]))if(l<r&&e.functionCall){if(!e.functionCall.name)throw Error("Function call name was not returned by the model.");if(t.has(e.functionCall.name)){let n=yield iq(t.get(e.functionCall.name).callTool([e.functionCall]));_.push(...n)}else throw Error(`Automatic function calling was requested, but not all the tools the model used implement the CallableTool interface. Available tools: ${t.keys()}, missing tool: ${e.functionCall.name}`)}}}catch(e){s={error:e}}finally{try{!m&&!i&&(a=f.return)&&(yield iq(a.call(f)))}finally{if(s)throw s.error}}if(_.length>0){o=!0;let e=new nd;e.candidates=[{content:{role:"user",parts:_}}],yield yield iq(e);let t=[];t.push(...E),t.push({role:"user",parts:_});let i=im(n.contents).concat(t);n.contents=i}else break}})}(this,await this.initAfcToolsMap(e),e)}async generateContentInternal(e){var t,n,i,r;let o="",l={};if(this.apiClient.isVertexAI()){let i=i0(this.apiClient,e);return o=tK("{model}:generateContent",i._url),l=i._query,delete i._url,delete i._query,this.apiClient.request({path:o,queryParams:l,body:JSON.stringify(i),httpMethod:"POST",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal}).then(e=>e.json().then(t=>(t.sdkHttpResponse={headers:e.headers},t))).then(e=>{let t=i4(e),n=new nd;return Object.assign(n,t),n})}{let t=iQ(this.apiClient,e);return o=tK("{model}:generateContent",t._url),l=t._query,delete t._url,delete t._query,this.apiClient.request({path:o,queryParams:l,body:JSON.stringify(t),httpMethod:"POST",httpOptions:null==(i=e.config)?void 0:i.httpOptions,abortSignal:null==(r=e.config)?void 0:r.abortSignal}).then(e=>e.json().then(t=>(t.sdkHttpResponse={headers:e.headers},t))).then(e=>{let t=i1(e),n=new nd;return Object.assign(n,t),n})}}async generateContentStreamInternal(e){var t,n,i,r;let o="",l={};if(this.apiClient.isVertexAI()){let i=i0(this.apiClient,e);return o=tK("{model}:streamGenerateContent?alt=sse",i._url),l=i._query,delete i._url,delete i._query,this.apiClient.requestStream({path:o,queryParams:l,body:JSON.stringify(i),httpMethod:"POST",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal}).then(function(t){return iH(this,arguments,function*(){var n,i,r,o;try{for(var l,s=!0,a=iF(t);!(n=(l=yield iq(a.next())).done);s=!0){o=l.value,s=!1;let t=i4((yield iq(o.json())),e);t.sdkHttpResponse={headers:o.headers};let n=new nd;Object.assign(n,t),yield yield iq(n)}}catch(e){i={error:e}}finally{try{!s&&!n&&(r=a.return)&&(yield iq(r.call(a)))}finally{if(i)throw i.error}}})})}{let t=iQ(this.apiClient,e);return o=tK("{model}:streamGenerateContent?alt=sse",t._url),l=t._query,delete t._url,delete t._query,this.apiClient.requestStream({path:o,queryParams:l,body:JSON.stringify(t),httpMethod:"POST",httpOptions:null==(i=e.config)?void 0:i.httpOptions,abortSignal:null==(r=e.config)?void 0:r.abortSignal}).then(function(t){return iH(this,arguments,function*(){var n,i,r,o;try{for(var l,s=!0,a=iF(t);!(n=(l=yield iq(a.next())).done);s=!0){o=l.value,s=!1;let t=i1((yield iq(o.json())),e);t.sdkHttpResponse={headers:o.headers};let n=new nd;Object.assign(n,t),yield yield iq(n)}}catch(e){i={error:e}}finally{try{!s&&!n&&(r=a.return)&&(yield iq(r.call(a)))}finally{if(i)throw i.error}}})})}}async embedContentInternal(e){var t,n,i,r,o;let l="",s={};if(this.apiClient.isVertexAI()){let i=function(e,t,n){let i={},r=tz(t,["model"]);null!=r&&tW(i,["_url","model"],n7(e,r));let o=tz(n,["embeddingApiType"]);if(void 0===o&&(o="PREDICT"),"PREDICT"===o){let n=tz(t,["contents"]);if(null!=n){let t=ic(e,n);Array.isArray(t)&&(t=t.map(e=>e)),tW(i,["instances[]","content"],t)}}let l=tz(n,["embeddingApiType"]);if(void 0===l&&(l="PREDICT"),"EMBED_CONTENT"===l){let e=tz(t,["content"]);null!=e&&tW(i,["content"],iZ(id(e)))}let s=tz(t,["config"]);return null!=s&&function(e,t,n){let i=tz(n,["embeddingApiType"]);if(void 0===i&&(i="PREDICT"),"PREDICT"===i){let n=tz(e,["taskType"]);void 0!==t&&null!=n&&tW(t,["instances[]","task_type"],n)}else if("EMBED_CONTENT"===i){let n=tz(e,["taskType"]);void 0!==t&&null!=n&&tW(t,["embedContentConfig","taskType"],n)}let r=tz(n,["embeddingApiType"]);if(void 0===r&&(r="PREDICT"),"PREDICT"===r){let n=tz(e,["title"]);void 0!==t&&null!=n&&tW(t,["instances[]","title"],n)}else if("EMBED_CONTENT"===r){let n=tz(e,["title"]);void 0!==t&&null!=n&&tW(t,["embedContentConfig","title"],n)}let o=tz(n,["embeddingApiType"]);if(void 0===o&&(o="PREDICT"),"PREDICT"===o){let n=tz(e,["outputDimensionality"]);void 0!==t&&null!=n&&tW(t,["parameters","outputDimensionality"],n)}else if("EMBED_CONTENT"===o){let n=tz(e,["outputDimensionality"]);void 0!==t&&null!=n&&tW(t,["embedContentConfig","outputDimensionality"],n)}let l=tz(n,["embeddingApiType"]);if(void 0===l&&(l="PREDICT"),"PREDICT"===l){let n=tz(e,["mimeType"]);void 0!==t&&null!=n&&tW(t,["instances[]","mimeType"],n)}let s=tz(n,["embeddingApiType"]);if(void 0===s&&(s="PREDICT"),"PREDICT"===s){let n=tz(e,["autoTruncate"]);void 0!==t&&null!=n&&tW(t,["parameters","autoTruncate"],n)}else if("EMBED_CONTENT"===s){let n=tz(e,["autoTruncate"]);void 0!==t&&null!=n&&tW(t,["embedContentConfig","autoTruncate"],n)}let a=tz(n,["embeddingApiType"]);if(void 0===a&&(a="PREDICT"),"EMBED_CONTENT"===a){let n=tz(e,["documentOcr"]);void 0!==t&&null!=n&&tW(t,["embedContentConfig","documentOcr"],n)}let u=tz(n,["embeddingApiType"]);if(void 0===u&&(u="PREDICT"),"EMBED_CONTENT"===u){let n=tz(e,["audioTrackExtraction"]);void 0!==t&&null!=n&&tW(t,["embedContentConfig","audioTrackExtraction"],n)}}(s,i,n),i}(this.apiClient,e,e);return l=tK((o=e.model).includes("gemini")&&"gemini-embedding-001"!==o||o.includes("maas")?"{model}:embedContent":"{model}:predict",i._url),s=i._query,delete i._url,delete i._query,this.apiClient.request({path:l,queryParams:s,body:JSON.stringify(i),httpMethod:"POST",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal}).then(e=>e.json().then(t=>(t.sdkHttpResponse={headers:e.headers},t))).then(t=>{let n=function(e,t){let n={},i=tz(e,["sdkHttpResponse"]);null!=i&&tW(n,["sdkHttpResponse"],i);let r=tz(e,["predictions[]","embeddings"]);if(null!=r){let e=r;Array.isArray(e)&&(e=e.map(e=>{let t,n,i;return t={},null!=(n=tz(e,["values"]))&&tW(t,["values"],n),null!=(i=tz(e,["statistics"]))&&tW(t,["statistics"],function(e){let t={},n=tz(e,["truncated"]);null!=n&&tW(t,["truncated"],n);let i=tz(e,["token_count"]);null!=i&&tW(t,["tokenCount"],i);let r=tz(e,["tokensDetails"]);if(null!=r){let e=r;Array.isArray(e)&&(e=e.map(e=>e)),tW(t,["tokensDetails"],e)}return t}(i)),t})),tW(n,["embeddings"],e)}let o=tz(e,["metadata"]);if(null!=o&&tW(n,["metadata"],o),t&&"EMBED_CONTENT"===tz(t,["embeddingApiType"])){let t=tz(e,["embedding"]),i=tz(e,["usageMetadata"]),r=tz(e,["truncated"]);if(t){let e={};i&&i.promptTokenCount&&(e.tokenCount=i.promptTokenCount),i&&i.promptTokensDetails&&(e.tokensDetails=i.promptTokensDetails),r&&(e.truncated=r),t.statistics=e,tW(n,["embeddings"],[t])}}return n}(t,e),i=new nc;return Object.assign(i,n),i})}{let t=function(e,t){let n={},i=tz(t,["model"]);null!=i&&tW(n,["_url","model"],n7(e,i));let r=tz(t,["contents"]);if(null!=r){let t=ic(e,r);Array.isArray(t)&&(t=t.map(e=>e)),tW(n,["requests[]","content"],t)}let o=tz(t,["content"]);null!=o&&iz(id(o));let l=tz(t,["config"]);null!=l&&function(e,t){let n=tz(e,["taskType"]);void 0!==t&&null!=n&&tW(t,["requests[]","taskType"],n);let i=tz(e,["title"]);void 0!==t&&null!=i&&tW(t,["requests[]","title"],i);let r=tz(e,["outputDimensionality"]);if(void 0!==t&&null!=r&&tW(t,["requests[]","outputDimensionality"],r),void 0!==tz(e,["mimeType"]))throw Error("mimeType parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==tz(e,["autoTruncate"]))throw Error("autoTruncate parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==tz(e,["documentOcr"]))throw Error("documentOcr parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==tz(e,["audioTrackExtraction"]))throw Error("audioTrackExtraction parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.")}(l,n);let s=tz(t,["model"]);return void 0!==s&&tW(n,["requests[]","model"],n7(e,s)),n}(this.apiClient,e);return l=tK("{model}:batchEmbedContents",t._url),s=t._query,delete t._url,delete t._query,this.apiClient.request({path:l,queryParams:s,body:JSON.stringify(t),httpMethod:"POST",httpOptions:null==(i=e.config)?void 0:i.httpOptions,abortSignal:null==(r=e.config)?void 0:r.abortSignal}).then(e=>e.json().then(t=>(t.sdkHttpResponse={headers:e.headers},t))).then(e=>{let t=function(e){let t={},n=tz(e,["sdkHttpResponse"]);null!=n&&tW(t,["sdkHttpResponse"],n);let i=tz(e,["embeddings"]);if(null!=i){let e=i;Array.isArray(e)&&(e=e.map(e=>e)),tW(t,["embeddings"],e)}let r=tz(e,["metadata"]);return null!=r&&tW(t,["metadata"],r),t}(e),n=new nc;return Object.assign(n,t),n})}}async generateImagesInternal(e){var t,n,i;let r="",o={};if(this.apiClient.isVertexAI()){let l,s,a,u,p,d,c,m,f,h,g,_,E,y,v,A,I,T,C,S,O,b=(i=this.apiClient,l={},null!=(s=tz(e,["model"]))&&tW(l,["_url","model"],n7(i,s)),null!=(a=tz(e,["prompt"]))&&tW(l,["instances[0]","prompt"],a),null!=(u=tz(e,["config"]))&&(p=tz(u,["outputGcsUri"]),void 0!==l&&null!=p&&tW(l,["parameters","storageUri"],p),d=tz(u,["negativePrompt"]),void 0!==l&&null!=d&&tW(l,["parameters","negativePrompt"],d),c=tz(u,["numberOfImages"]),void 0!==l&&null!=c&&tW(l,["parameters","sampleCount"],c),m=tz(u,["aspectRatio"]),void 0!==l&&null!=m&&tW(l,["parameters","aspectRatio"],m),f=tz(u,["guidanceScale"]),void 0!==l&&null!=f&&tW(l,["parameters","guidanceScale"],f),h=tz(u,["seed"]),void 0!==l&&null!=h&&tW(l,["parameters","seed"],h),g=tz(u,["safetyFilterLevel"]),void 0!==l&&null!=g&&tW(l,["parameters","safetySetting"],g),_=tz(u,["personGeneration"]),void 0!==l&&null!=_&&tW(l,["parameters","personGeneration"],_),E=tz(u,["includeSafetyAttributes"]),void 0!==l&&null!=E&&tW(l,["parameters","includeSafetyAttributes"],E),y=tz(u,["includeRaiReason"]),void 0!==l&&null!=y&&tW(l,["parameters","includeRaiReason"],y),v=tz(u,["language"]),void 0!==l&&null!=v&&tW(l,["parameters","language"],v),A=tz(u,["outputMimeType"]),void 0!==l&&null!=A&&tW(l,["parameters","outputOptions","mimeType"],A),I=tz(u,["outputCompressionQuality"]),void 0!==l&&null!=I&&tW(l,["parameters","outputOptions","compressionQuality"],I),T=tz(u,["addWatermark"]),void 0!==l&&null!=T&&tW(l,["parameters","addWatermark"],T),C=tz(u,["labels"]),void 0!==l&&null!=C&&tW(l,["labels"],C),S=tz(u,["imageSize"]),void 0!==l&&null!=S&&tW(l,["parameters","sampleImageSize"],S),O=tz(u,["enhancePrompt"]),void 0!==l&&null!=O&&tW(l,["parameters","enhancePrompt"],O)),l);return r=tK("{model}:predict",b._url),o=b._query,delete b._url,delete b._query,this.apiClient.request({path:r,queryParams:o,body:JSON.stringify(b),httpMethod:"POST",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal}).then(e=>e.json().then(t=>(t.sdkHttpResponse={headers:e.headers},t))).then(e=>{let t=function(e){let t={},n=tz(e,["sdkHttpResponse"]);null!=n&&tW(t,["sdkHttpResponse"],n);let i=tz(e,["predictions"]);if(null!=i){let e=i;Array.isArray(e)&&(e=e.map(e=>i2(e))),tW(t,["generatedImages"],e)}let r=tz(e,["positivePromptSafetyAttributes"]);return null!=r&&tW(t,["positivePromptSafetyAttributes"],i7(r)),t}(e),n=new nm;return Object.assign(n,t),n})}throw Error("This method is only supported by the Gemini Enterprise Agent Platform (previously known as Vertex AI).")}async editImageInternal(e){var t,n;let i="",r={};if(this.apiClient.isVertexAI()){let o=function(e,t){let n,i,r,o,l,s,a,u,p,d,c,m,f,h,g,_,E,y={},v=tz(t,["model"]);null!=v&&tW(y,["_url","model"],n7(e,v));let A=tz(t,["prompt"]);null!=A&&tW(y,["instances[0]","prompt"],A);let I=tz(t,["referenceImages"]);if(null!=I){let e=I;Array.isArray(e)&&(e=e.map(e=>(function(e){let t,n,i,r,o,l,s,a={},u=tz(e,["referenceImage"]);null!=u&&tW(a,["referenceImage"],i8(u));let p=tz(e,["referenceId"]);null!=p&&tW(a,["referenceId"],p);let d=tz(e,["referenceType"]);null!=d&&tW(a,["referenceType"],d);let c=tz(e,["maskImageConfig"]);null!=c&&tW(a,["maskImageConfig"],(t={},null!=(n=tz(c,["maskMode"]))&&tW(t,["maskMode"],n),null!=(i=tz(c,["segmentationClasses"]))&&tW(t,["maskClasses"],i),null!=(r=tz(c,["maskDilation"]))&&tW(t,["dilation"],r),t));let m=tz(e,["controlImageConfig"]);null!=m&&tW(a,["controlImageConfig"],(o={},null!=(l=tz(m,["controlType"]))&&tW(o,["controlType"],l),null!=(s=tz(m,["enableControlImageComputation"]))&&tW(o,["computeControl"],s),o));let f=tz(e,["styleImageConfig"]);null!=f&&tW(a,["styleImageConfig"],f);let h=tz(e,["subjectImageConfig"]);return null!=h&&tW(a,["subjectImageConfig"],h),a})(e))),tW(y,["instances[0]","referenceImages"],e)}let T=tz(t,["config"]);return null!=T&&(n=tz(T,["outputGcsUri"]),void 0!==y&&null!=n&&tW(y,["parameters","storageUri"],n),i=tz(T,["negativePrompt"]),void 0!==y&&null!=i&&tW(y,["parameters","negativePrompt"],i),r=tz(T,["numberOfImages"]),void 0!==y&&null!=r&&tW(y,["parameters","sampleCount"],r),o=tz(T,["aspectRatio"]),void 0!==y&&null!=o&&tW(y,["parameters","aspectRatio"],o),l=tz(T,["guidanceScale"]),void 0!==y&&null!=l&&tW(y,["parameters","guidanceScale"],l),s=tz(T,["seed"]),void 0!==y&&null!=s&&tW(y,["parameters","seed"],s),a=tz(T,["safetyFilterLevel"]),void 0!==y&&null!=a&&tW(y,["parameters","safetySetting"],a),u=tz(T,["personGeneration"]),void 0!==y&&null!=u&&tW(y,["parameters","personGeneration"],u),p=tz(T,["includeSafetyAttributes"]),void 0!==y&&null!=p&&tW(y,["parameters","includeSafetyAttributes"],p),d=tz(T,["includeRaiReason"]),void 0!==y&&null!=d&&tW(y,["parameters","includeRaiReason"],d),c=tz(T,["language"]),void 0!==y&&null!=c&&tW(y,["parameters","language"],c),m=tz(T,["outputMimeType"]),void 0!==y&&null!=m&&tW(y,["parameters","outputOptions","mimeType"],m),f=tz(T,["outputCompressionQuality"]),void 0!==y&&null!=f&&tW(y,["parameters","outputOptions","compressionQuality"],f),h=tz(T,["addWatermark"]),void 0!==y&&null!=h&&tW(y,["parameters","addWatermark"],h),g=tz(T,["labels"]),void 0!==y&&null!=g&&tW(y,["labels"],g),_=tz(T,["editMode"]),void 0!==y&&null!=_&&tW(y,["parameters","editMode"],_),E=tz(T,["baseSteps"]),void 0!==y&&null!=E&&tW(y,["parameters","editConfig","baseSteps"],E)),y}(this.apiClient,e);return i=tK("{model}:predict",o._url),r=o._query,delete o._url,delete o._query,this.apiClient.request({path:i,queryParams:r,body:JSON.stringify(o),httpMethod:"POST",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal}).then(e=>e.json().then(t=>(t.sdkHttpResponse={headers:e.headers},t))).then(e=>{let t=function(e){let t={},n=tz(e,["sdkHttpResponse"]);null!=n&&tW(t,["sdkHttpResponse"],n);let i=tz(e,["predictions"]);if(null!=i){let e=i;Array.isArray(e)&&(e=e.map(e=>i2(e))),tW(t,["generatedImages"],e)}return t}(e),n=new nf;return Object.assign(n,t),n})}throw Error("This method is only supported by the Gemini Enterprise Agent Platform (previously known as Vertex AI).")}async upscaleImageInternal(e){var t,n,i;let r="",o={};if(this.apiClient.isVertexAI()){let l,s,a,u,p,d,c,m,f,h,g,_,E,y,v,A,I=(i=this.apiClient,l={},null!=(s=tz(e,["model"]))&&tW(l,["_url","model"],n7(i,s)),null!=(a=tz(e,["image"]))&&tW(l,["instances[0]","image"],i8(a)),null!=(u=tz(e,["upscaleFactor"]))&&tW(l,["parameters","upscaleConfig","upscaleFactor"],u),null!=(p=tz(e,["config"]))&&(d=tz(p,["outputGcsUri"]),void 0!==l&&null!=d&&tW(l,["parameters","storageUri"],d),c=tz(p,["safetyFilterLevel"]),void 0!==l&&null!=c&&tW(l,["parameters","safetySetting"],c),m=tz(p,["personGeneration"]),void 0!==l&&null!=m&&tW(l,["parameters","personGeneration"],m),f=tz(p,["includeRaiReason"]),void 0!==l&&null!=f&&tW(l,["parameters","includeRaiReason"],f),h=tz(p,["outputMimeType"]),void 0!==l&&null!=h&&tW(l,["parameters","outputOptions","mimeType"],h),g=tz(p,["outputCompressionQuality"]),void 0!==l&&null!=g&&tW(l,["parameters","outputOptions","compressionQuality"],g),_=tz(p,["enhanceInputImage"]),void 0!==l&&null!=_&&tW(l,["parameters","upscaleConfig","enhanceInputImage"],_),E=tz(p,["imagePreservationFactor"]),void 0!==l&&null!=E&&tW(l,["parameters","upscaleConfig","imagePreservationFactor"],E),y=tz(p,["labels"]),void 0!==l&&null!=y&&tW(l,["labels"],y),v=tz(p,["numberOfImages"]),void 0!==l&&null!=v&&tW(l,["parameters","sampleCount"],v),A=tz(p,["mode"]),void 0!==l&&null!=A&&tW(l,["parameters","mode"],A)),l);return r=tK("{model}:predict",I._url),o=I._query,delete I._url,delete I._query,this.apiClient.request({path:r,queryParams:o,body:JSON.stringify(I),httpMethod:"POST",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal}).then(e=>e.json().then(t=>(t.sdkHttpResponse={headers:e.headers},t))).then(e=>{let t=function(e){let t={},n=tz(e,["sdkHttpResponse"]);null!=n&&tW(t,["sdkHttpResponse"],n);let i=tz(e,["predictions"]);if(null!=i){let e=i;Array.isArray(e)&&(e=e.map(e=>i2(e))),tW(t,["generatedImages"],e)}return t}(e),n=new nh;return Object.assign(n,t),n})}throw Error("This method is only supported by the Gemini Enterprise Agent Platform (previously known as Vertex AI).")}async recontextImage(e){var t,n,i;let r="",o={};if(this.apiClient.isVertexAI()){let l,s,a,u,p,d,c,m,f,h,g,_,E,y,v,A=(i=this.apiClient,l={},null!=(s=tz(e,["model"]))&&tW(l,["_url","model"],n7(i,s)),null!=(a=tz(e,["source"]))&&function(e,t){let n=tz(e,["prompt"]);void 0!==t&&null!=n&&tW(t,["instances[0]","prompt"],n);let i=tz(e,["personImage"]);void 0!==t&&null!=i&&tW(t,["instances[0]","personImage","image"],i8(i));let r=tz(e,["productImages"]);if(void 0!==t&&null!=r){let e=r;Array.isArray(e)&&(e=e.map(e=>{let t,n;return t={},null!=(n=tz(e,["productImage"]))&&tW(t,["image"],i8(n)),t})),tW(t,["instances[0]","productImages"],e)}}(a,l),null!=(u=tz(e,["config"]))&&(p=tz(u,["numberOfImages"]),void 0!==l&&null!=p&&tW(l,["parameters","sampleCount"],p),d=tz(u,["baseSteps"]),void 0!==l&&null!=d&&tW(l,["parameters","baseSteps"],d),c=tz(u,["outputGcsUri"]),void 0!==l&&null!=c&&tW(l,["parameters","storageUri"],c),m=tz(u,["seed"]),void 0!==l&&null!=m&&tW(l,["parameters","seed"],m),f=tz(u,["safetyFilterLevel"]),void 0!==l&&null!=f&&tW(l,["parameters","safetySetting"],f),h=tz(u,["personGeneration"]),void 0!==l&&null!=h&&tW(l,["parameters","personGeneration"],h),g=tz(u,["addWatermark"]),void 0!==l&&null!=g&&tW(l,["parameters","addWatermark"],g),_=tz(u,["outputMimeType"]),void 0!==l&&null!=_&&tW(l,["parameters","outputOptions","mimeType"],_),E=tz(u,["outputCompressionQuality"]),void 0!==l&&null!=E&&tW(l,["parameters","outputOptions","compressionQuality"],E),y=tz(u,["enhancePrompt"]),void 0!==l&&null!=y&&tW(l,["parameters","enhancePrompt"],y),v=tz(u,["labels"]),void 0!==l&&null!=v&&tW(l,["labels"],v)),l);return r=tK("{model}:predict",A._url),o=A._query,delete A._url,delete A._query,this.apiClient.request({path:r,queryParams:o,body:JSON.stringify(A),httpMethod:"POST",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal}).then(e=>e.json()).then(e=>{let t=function(e){let t={},n=tz(e,["predictions"]);if(null!=n){let e=n;Array.isArray(e)&&(e=e.map(e=>i2(e))),tW(t,["generatedImages"],e)}return t}(e),n=new ng;return Object.assign(n,t),n})}throw Error("This method is only supported by the Gemini Enterprise Agent Platform (previously known as Vertex AI).")}async segmentImage(e){var t,n,i,r,o;let l="",s={};if(this.apiClient.isVertexAI()){let a,u,p,d,c,m,f,h,g,_,E,y,v,A,I,T=(i=this.apiClient,m={},null!=(f=tz(e,["model"]))&&tW(m,["_url","model"],n7(i,f)),null!=(h=tz(e,["source"]))&&(r=h,o=m,p=tz(r,["prompt"]),void 0!==o&&null!=p&&tW(o,["instances[0]","prompt"],p),d=tz(r,["image"]),void 0!==o&&null!=d&&tW(o,["instances[0]","image"],i8(d)),c=tz(r,["scribbleImage"]),void 0!==o&&null!=c&&tW(o,["instances[0]","scribble"],(a={},null!=(u=tz(c,["image"]))&&tW(a,["image"],i8(u)),a))),null!=(g=tz(e,["config"]))&&(_=tz(g,["mode"]),void 0!==m&&null!=_&&tW(m,["parameters","mode"],_),E=tz(g,["maxPredictions"]),void 0!==m&&null!=E&&tW(m,["parameters","maxPredictions"],E),y=tz(g,["confidenceThreshold"]),void 0!==m&&null!=y&&tW(m,["parameters","confidenceThreshold"],y),v=tz(g,["maskDilation"]),void 0!==m&&null!=v&&tW(m,["parameters","maskDilation"],v),A=tz(g,["binaryColorThreshold"]),void 0!==m&&null!=A&&tW(m,["parameters","binaryColorThreshold"],A),I=tz(g,["labels"]),void 0!==m&&null!=I&&tW(m,["labels"],I)),m);return l=tK("{model}:predict",T._url),s=T._query,delete T._url,delete T._query,this.apiClient.request({path:l,queryParams:s,body:JSON.stringify(T),httpMethod:"POST",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal}).then(e=>e.json()).then(e=>{let t=function(e){let t={},n=tz(e,["predictions"]);if(null!=n){let e=n;Array.isArray(e)&&(e=e.map(e=>(function(e){let t={},n=tz(e,["_self"]);null!=n&&tW(t,["mask"],i5(n));let i=tz(e,["labels"]);if(null!=i){let e=i;Array.isArray(e)&&(e=e.map(e=>e)),tW(t,["labels"],e)}return t})(e))),tW(t,["generatedMasks"],e)}return t}(e),n=new n_;return Object.assign(n,t),n})}throw Error("This method is only supported by the Gemini Enterprise Agent Platform (previously known as Vertex AI).")}async get(e){var t,n,i,r,o,l;let s="",a={};if(this.apiClient.isVertexAI()){let i,r,l=(o=this.apiClient,i={},null!=(r=tz(e,["model"]))&&tW(i,["_url","name"],n7(o,r)),i);return s=tK("{name}",l._url),a=l._query,delete l._url,delete l._query,this.apiClient.request({path:s,queryParams:a,body:JSON.stringify(l),httpMethod:"GET",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal}).then(e=>e.json()).then(e=>i6(e))}{let t,n,o=(l=this.apiClient,t={},null!=(n=tz(e,["model"]))&&tW(t,["_url","name"],n7(l,n)),t);return s=tK("{name}",o._url),a=o._query,delete o._url,delete o._query,this.apiClient.request({path:s,queryParams:a,body:JSON.stringify(o),httpMethod:"GET",httpOptions:null==(i=e.config)?void 0:i.httpOptions,abortSignal:null==(r=e.config)?void 0:r.abortSignal}).then(e=>e.json()).then(e=>i9(e))}}async listInternal(e){var t,n,i,r,o,l;let s="",a={};if(this.apiClient.isVertexAI()){let i,r,l,u,p,d,c=(o=this.apiClient,i={},null!=(r=tz(e,["config"]))&&(l=tz(r,["pageSize"]),void 0!==i&&null!=l&&tW(i,["_query","pageSize"],l),u=tz(r,["pageToken"]),void 0!==i&&null!=u&&tW(i,["_query","pageToken"],u),p=tz(r,["filter"]),void 0!==i&&null!=p&&tW(i,["_query","filter"],p),d=tz(r,["queryBase"]),void 0!==i&&null!=d&&tW(i,["_url","models_url"],iT(o,d))),i);return s=tK("{models_url}",c._url),a=c._query,delete c._url,delete c._query,this.apiClient.request({path:s,queryParams:a,body:JSON.stringify(c),httpMethod:"GET",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal}).then(e=>e.json().then(t=>(t.sdkHttpResponse={headers:e.headers},t))).then(e=>{let t=function(e){let t={},n=tz(e,["sdkHttpResponse"]);null!=n&&tW(t,["sdkHttpResponse"],n);let i=tz(e,["nextPageToken"]);null!=i&&tW(t,["nextPageToken"],i);let r=tz(e,["_self"]);if(null!=r){let e=iC(r);Array.isArray(e)&&(e=e.map(e=>i6(e))),tW(t,["models"],e)}return t}(e),n=new nE;return Object.assign(n,t),n})}{let t,n,o,u,p,d,c=(l=this.apiClient,t={},null!=(n=tz(e,["config"]))&&(o=tz(n,["pageSize"]),void 0!==t&&null!=o&&tW(t,["_query","pageSize"],o),u=tz(n,["pageToken"]),void 0!==t&&null!=u&&tW(t,["_query","pageToken"],u),p=tz(n,["filter"]),void 0!==t&&null!=p&&tW(t,["_query","filter"],p),d=tz(n,["queryBase"]),void 0!==t&&null!=d&&tW(t,["_url","models_url"],iT(l,d))),t);return s=tK("{models_url}",c._url),a=c._query,delete c._url,delete c._query,this.apiClient.request({path:s,queryParams:a,body:JSON.stringify(c),httpMethod:"GET",httpOptions:null==(i=e.config)?void 0:i.httpOptions,abortSignal:null==(r=e.config)?void 0:r.abortSignal}).then(e=>e.json().then(t=>(t.sdkHttpResponse={headers:e.headers},t))).then(e=>{let t=function(e){let t={},n=tz(e,["sdkHttpResponse"]);null!=n&&tW(t,["sdkHttpResponse"],n);let i=tz(e,["nextPageToken"]);null!=i&&tW(t,["nextPageToken"],i);let r=tz(e,["_self"]);if(null!=r){let e=iC(r);Array.isArray(e)&&(e=e.map(e=>i9(e))),tW(t,["models"],e)}return t}(e),n=new nE;return Object.assign(n,t),n})}}async update(e){var t,n,i,r,o,l;let s="",a={};if(this.apiClient.isVertexAI()){let i,r,l,u,p,d,c=(o=this.apiClient,i={},null!=(r=tz(e,["model"]))&&tW(i,["_url","model"],n7(o,r)),null!=(l=tz(e,["config"]))&&(u=tz(l,["displayName"]),void 0!==i&&null!=u&&tW(i,["displayName"],u),p=tz(l,["description"]),void 0!==i&&null!=p&&tW(i,["description"],p),d=tz(l,["defaultCheckpointId"]),void 0!==i&&null!=d&&tW(i,["defaultCheckpointId"],d)),i);return s=tK("{model}",c._url),a=c._query,delete c._url,delete c._query,this.apiClient.request({path:s,queryParams:a,body:JSON.stringify(c),httpMethod:"PATCH",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal}).then(e=>e.json()).then(e=>i6(e))}{let t,n,o,u,p,d,c=(l=this.apiClient,t={},null!=(n=tz(e,["model"]))&&tW(t,["_url","name"],n7(l,n)),null!=(o=tz(e,["config"]))&&(u=tz(o,["displayName"]),void 0!==t&&null!=u&&tW(t,["displayName"],u),p=tz(o,["description"]),void 0!==t&&null!=p&&tW(t,["description"],p),d=tz(o,["defaultCheckpointId"]),void 0!==t&&null!=d&&tW(t,["defaultCheckpointId"],d)),t);return s=tK("{name}",c._url),a=c._query,delete c._url,delete c._query,this.apiClient.request({path:s,queryParams:a,body:JSON.stringify(c),httpMethod:"PATCH",httpOptions:null==(i=e.config)?void 0:i.httpOptions,abortSignal:null==(r=e.config)?void 0:r.abortSignal}).then(e=>e.json()).then(e=>i9(e))}}async delete(e){var t,n,i,r,o,l;let s="",a={};if(this.apiClient.isVertexAI()){let i,r,l=(o=this.apiClient,i={},null!=(r=tz(e,["model"]))&&tW(i,["_url","name"],n7(o,r)),i);return s=tK("{name}",l._url),a=l._query,delete l._url,delete l._query,this.apiClient.request({path:s,queryParams:a,body:JSON.stringify(l),httpMethod:"DELETE",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal}).then(e=>e.json().then(t=>(t.sdkHttpResponse={headers:e.headers},t))).then(e=>{let t,n,i=(t={},null!=(n=tz(e,["sdkHttpResponse"]))&&tW(t,["sdkHttpResponse"],n),t),r=new ny;return Object.assign(r,i),r})}{let t,n,o=(l=this.apiClient,t={},null!=(n=tz(e,["model"]))&&tW(t,["_url","name"],n7(l,n)),t);return s=tK("{name}",o._url),a=o._query,delete o._url,delete o._query,this.apiClient.request({path:s,queryParams:a,body:JSON.stringify(o),httpMethod:"DELETE",httpOptions:null==(i=e.config)?void 0:i.httpOptions,abortSignal:null==(r=e.config)?void 0:r.abortSignal}).then(e=>e.json().then(t=>(t.sdkHttpResponse={headers:e.headers},t))).then(e=>{let t,n,i=(t={},null!=(n=tz(e,["sdkHttpResponse"]))&&tW(t,["sdkHttpResponse"],n),t),r=new ny;return Object.assign(r,i),r})}}async countTokens(e){var t,n,i,r;let o="",l={};if(this.apiClient.isVertexAI()){let i=function(e,t){let n={},i=tz(t,["model"]);null!=i&&tW(n,["_url","model"],n7(e,i));let r=tz(t,["contents"]);if(null!=r){let e=im(r);Array.isArray(e)&&(e=e.map(e=>iZ(e))),tW(n,["contents"],e)}let o=tz(t,["config"]);return null!=o&&function(e,t){let n=tz(e,["systemInstruction"]);void 0!==t&&null!=n&&tW(t,["systemInstruction"],iZ(id(n)));let i=tz(e,["tools"]);if(void 0!==t&&null!=i){let e=i;Array.isArray(e)&&(e=e.map(e=>rt(e))),tW(t,["tools"],e)}let r=tz(e,["generationConfig"]);void 0!==t&&null!=r&&tW(t,["generationConfig"],function(e){let t={},n=tz(e,["modelSelectionConfig"]);null!=n&&tW(t,["modelConfig"],n);let i=tz(e,["responseJsonSchema"]);null!=i&&tW(t,["responseJsonSchema"],i);let r=tz(e,["audioTranscriptionConfig"]);null!=r&&tW(t,["audioTranscriptionConfig"],r);let o=tz(e,["audioTimestamp"]);null!=o&&tW(t,["audioTimestamp"],o);let l=tz(e,["candidateCount"]);null!=l&&tW(t,["candidateCount"],l);let s=tz(e,["enableAffectiveDialog"]);null!=s&&tW(t,["enableAffectiveDialog"],s);let a=tz(e,["frequencyPenalty"]);null!=a&&tW(t,["frequencyPenalty"],a);let u=tz(e,["logprobs"]);null!=u&&tW(t,["logprobs"],u);let p=tz(e,["maxOutputTokens"]);null!=p&&tW(t,["maxOutputTokens"],p);let d=tz(e,["mediaResolution"]);null!=d&&tW(t,["mediaResolution"],d);let c=tz(e,["presencePenalty"]);null!=c&&tW(t,["presencePenalty"],c);let m=tz(e,["responseFormat"]);if(null!=m){let e=m;Array.isArray(e)&&(e=e.map(e=>e)),tW(t,["responseFormat"],e)}let f=tz(e,["responseLogprobs"]);null!=f&&tW(t,["responseLogprobs"],f);let h=tz(e,["responseMimeType"]);null!=h&&tW(t,["responseMimeType"],h);let g=tz(e,["responseModalities"]);null!=g&&tW(t,["responseModalities"],g);let _=tz(e,["responseSchema"]);null!=_&&tW(t,["responseSchema"],_);let E=tz(e,["routingConfig"]);null!=E&&tW(t,["routingConfig"],E);let y=tz(e,["seed"]);null!=y&&tW(t,["seed"],y);let v=tz(e,["speechConfig"]);null!=v&&tW(t,["speechConfig"],re(v));let A=tz(e,["stopSequences"]);null!=A&&tW(t,["stopSequences"],A);let I=tz(e,["temperature"]);null!=I&&tW(t,["temperature"],I);let T=tz(e,["thinkingConfig"]);null!=T&&tW(t,["thinkingConfig"],T);let C=tz(e,["topK"]);null!=C&&tW(t,["topK"],C);let S=tz(e,["topP"]);if(null!=S&&tW(t,["topP"],S),void 0!==tz(e,["enableEnhancedCivicAnswers"]))throw Error("enableEnhancedCivicAnswers parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.");if(void 0!==tz(e,["translationConfig"]))throw Error("translationConfig parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.");return t}(r))}(o,n),n}(this.apiClient,e);return o=tK("{model}:countTokens",i._url),l=i._query,delete i._url,delete i._query,this.apiClient.request({path:o,queryParams:l,body:JSON.stringify(i),httpMethod:"POST",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal}).then(e=>e.json().then(t=>(t.sdkHttpResponse={headers:e.headers},t))).then(e=>{let t,n,i,r=(t={},null!=(n=tz(e,["sdkHttpResponse"]))&&tW(t,["sdkHttpResponse"],n),null!=(i=tz(e,["totalTokens"]))&&tW(t,["totalTokens"],i),t),o=new nS;return Object.assign(o,r),o})}{let t=function(e,t){let n={},i=tz(t,["model"]);null!=i&&tW(n,["_url","model"],n7(e,i));let r=tz(t,["contents"]);if(null!=r){let e=im(r);Array.isArray(e)&&(e=e.map(e=>iz(e))),tW(n,["contents"],e)}let o=tz(t,["config"]);return null!=o&&function(e){if(void 0!==tz(e,["systemInstruction"]))throw Error("systemInstruction parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==tz(e,["tools"]))throw Error("tools parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==tz(e,["generationConfig"]))throw Error("generationConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.")}(o),n}(this.apiClient,e);return o=tK("{model}:countTokens",t._url),l=t._query,delete t._url,delete t._query,this.apiClient.request({path:o,queryParams:l,body:JSON.stringify(t),httpMethod:"POST",httpOptions:null==(i=e.config)?void 0:i.httpOptions,abortSignal:null==(r=e.config)?void 0:r.abortSignal}).then(e=>e.json().then(t=>(t.sdkHttpResponse={headers:e.headers},t))).then(e=>{let t,n,i,r,o=(t={},null!=(n=tz(e,["sdkHttpResponse"]))&&tW(t,["sdkHttpResponse"],n),null!=(i=tz(e,["totalTokens"]))&&tW(t,["totalTokens"],i),null!=(r=tz(e,["cachedContentTokenCount"]))&&tW(t,["cachedContentTokenCount"],r),t),l=new nS;return Object.assign(l,o),l})}}async computeTokens(e){var t,n;let i="",r={};if(this.apiClient.isVertexAI()){let o=function(e,t){let n={},i=tz(t,["model"]);null!=i&&tW(n,["_url","model"],n7(e,i));let r=tz(t,["contents"]);if(null!=r){let e=im(r);Array.isArray(e)&&(e=e.map(e=>iZ(e))),tW(n,["contents"],e)}return n}(this.apiClient,e);return i=tK("{model}:computeTokens",o._url),r=o._query,delete o._url,delete o._query,this.apiClient.request({path:i,queryParams:r,body:JSON.stringify(o),httpMethod:"POST",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal}).then(e=>e.json().then(t=>(t.sdkHttpResponse={headers:e.headers},t))).then(e=>{let t=function(e){let t={},n=tz(e,["sdkHttpResponse"]);null!=n&&tW(t,["sdkHttpResponse"],n);let i=tz(e,["tokensInfo"]);if(null!=i){let e=i;Array.isArray(e)&&(e=e.map(e=>e)),tW(t,["tokensInfo"],e)}return t}(e),n=new nO;return Object.assign(n,t),n})}throw Error("This method is only supported by the Gemini Enterprise Agent Platform (previously known as Vertex AI).")}async generateVideosInternal(e){var t,n,i,r,o,l,s,a,u,p;let d="",c={};if(this.apiClient.isVertexAI()){let i,r,l,u,p,m,f,h,g,_,E=(o=this.apiClient,u={},null!=(p=tz(e,["model"]))&&tW(u,["_url","model"],n7(o,p)),null!=(m=tz(e,["prompt"]))&&tW(u,["instances[0]","prompt"],m),null!=(f=tz(e,["image"]))&&tW(u,["instances[0]","image"],i8(f)),null!=(h=tz(e,["video"]))&&tW(u,["instances[0]","video"],ri(h)),null!=(g=tz(e,["source"]))&&(s=g,a=u,i=tz(s,["prompt"]),void 0!==a&&null!=i&&tW(a,["instances[0]","prompt"],i),r=tz(s,["image"]),void 0!==a&&null!=r&&tW(a,["instances[0]","image"],i8(r)),l=tz(s,["video"]),void 0!==a&&null!=l&&tW(a,["instances[0]","video"],ri(l))),null!=(_=tz(e,["config"]))&&function(e,t){var n;let i,r,o,l=tz(e,["numberOfVideos"]);void 0!==t&&null!=l&&tW(t,["parameters","sampleCount"],l);let s=tz(e,["outputGcsUri"]);void 0!==t&&null!=s&&tW(t,["parameters","storageUri"],s);let a=tz(e,["fps"]);void 0!==t&&null!=a&&tW(t,["parameters","fps"],a);let u=tz(e,["durationSeconds"]);void 0!==t&&null!=u&&tW(t,["parameters","durationSeconds"],u);let p=tz(e,["seed"]);void 0!==t&&null!=p&&tW(t,["parameters","seed"],p);let d=tz(e,["aspectRatio"]);void 0!==t&&null!=d&&tW(t,["parameters","aspectRatio"],d);let c=tz(e,["resolution"]);void 0!==t&&null!=c&&tW(t,["parameters","resolution"],c);let m=tz(e,["personGeneration"]);void 0!==t&&null!=m&&tW(t,["parameters","personGeneration"],m);let f=tz(e,["pubsubTopic"]);void 0!==t&&null!=f&&tW(t,["parameters","pubsubTopic"],f);let h=tz(e,["negativePrompt"]);void 0!==t&&null!=h&&tW(t,["parameters","negativePrompt"],h);let g=tz(e,["enhancePrompt"]);void 0!==t&&null!=g&&tW(t,["parameters","enhancePrompt"],g);let _=tz(e,["generateAudio"]);void 0!==t&&null!=_&&tW(t,["parameters","generateAudio"],_);let E=tz(e,["lastFrame"]);void 0!==t&&null!=E&&tW(t,["instances[0]","lastFrame"],i8(E));let y=tz(e,["referenceImages"]);if(void 0!==t&&null!=y){let e=y;Array.isArray(e)&&(e=e.map(e=>{var t;let n,i,r;return n={},null!=(i=tz(t=e,["image"]))&&tW(n,["image"],i8(i)),null!=(r=tz(t,["referenceType"]))&&tW(n,["referenceType"],r),n})),tW(t,["instances[0]","referenceImages"],e)}let v=tz(e,["mask"]);void 0!==t&&null!=v&&tW(t,["instances[0]","mask"],(i={},null!=(r=tz(n=v,["image"]))&&tW(i,["_self"],i8(r)),null!=(o=tz(n,["maskMode"]))&&tW(i,["maskMode"],o),i));let A=tz(e,["compressionQuality"]);void 0!==t&&null!=A&&tW(t,["parameters","compressionQuality"],A);let I=tz(e,["labels"]);if(void 0!==t&&null!=I&&tW(t,["labels"],I),void 0!==tz(e,["webhookConfig"]))throw Error("webhookConfig parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.");let T=tz(e,["resizeMode"]);void 0!==t&&null!=T&&tW(t,["parameters","resizeMode"],T)}(_,u),u);return d=tK("{model}:predictLongRunning",E._url),c=E._query,delete E._url,delete E._query,this.apiClient.request({path:d,queryParams:c,body:JSON.stringify(E),httpMethod:"POST",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal}).then(e=>e.json()).then(e=>{let t,n,i,r,o,l,s=(t={},null!=(n=tz(e,["name"]))&&tW(t,["name"],n),null!=(i=tz(e,["metadata"]))&&tW(t,["metadata"],i),null!=(r=tz(e,["done"]))&&tW(t,["done"],r),null!=(o=tz(e,["error"]))&&tW(t,["error"],o),null!=(l=tz(e,["response"]))&&tW(t,["response"],function(e){let t={},n=tz(e,["videos"]);if(null!=n){let e=n;Array.isArray(e)&&(e=e.map(e=>{var t;let n,i,r,o,l,s;return n={},null!=(i=tz(e,["_self"]))&&tW(n,["video"],(r={},null!=(o=tz(t=i,["gcsUri"]))&&tW(r,["uri"],o),null!=(l=tz(t,["bytesBase64Encoded"]))&&tW(r,["videoBytes"],tZ(l)),null!=(s=tz(t,["mimeType"]))&&tW(r,["mimeType"],s),r)),n})),tW(t,["generatedVideos"],e)}let i=tz(e,["raiMediaFilteredCount"]);null!=i&&tW(t,["raiMediaFilteredCount"],i);let r=tz(e,["raiMediaFilteredReasons"]);return null!=r&&tW(t,["raiMediaFilteredReasons"],r),t}(l)),t),a=new nP;return Object.assign(a,s),a})}{let t,n,o,s,a,m,f,h,g,_,E=(l=this.apiClient,s={},null!=(a=tz(e,["model"]))&&tW(s,["_url","model"],n7(l,a)),null!=(m=tz(e,["prompt"]))&&tW(s,["instances[0]","prompt"],m),null!=(f=tz(e,["image"]))&&tW(s,["instances[0]","image"],i3(f)),null!=(h=tz(e,["video"]))&&tW(s,["instances[0]","video"],rn(h)),null!=(g=tz(e,["source"]))&&(u=g,p=s,t=tz(u,["prompt"]),void 0!==p&&null!=t&&tW(p,["instances[0]","prompt"],t),n=tz(u,["image"]),void 0!==p&&null!=n&&tW(p,["instances[0]","image"],i3(n)),o=tz(u,["video"]),void 0!==p&&null!=o&&tW(p,["instances[0]","video"],rn(o))),null!=(_=tz(e,["config"]))&&function(e,t){let n=tz(e,["numberOfVideos"]);if(void 0!==t&&null!=n&&tW(t,["parameters","sampleCount"],n),void 0!==tz(e,["outputGcsUri"]))throw Error("outputGcsUri parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==tz(e,["fps"]))throw Error("fps parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let i=tz(e,["durationSeconds"]);if(void 0!==t&&null!=i&&tW(t,["parameters","durationSeconds"],i),void 0!==tz(e,["seed"]))throw Error("seed parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let r=tz(e,["aspectRatio"]);void 0!==t&&null!=r&&tW(t,["parameters","aspectRatio"],r);let o=tz(e,["resolution"]);void 0!==t&&null!=o&&tW(t,["parameters","resolution"],o);let l=tz(e,["personGeneration"]);if(void 0!==t&&null!=l&&tW(t,["parameters","personGeneration"],l),void 0!==tz(e,["pubsubTopic"]))throw Error("pubsubTopic parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let s=tz(e,["negativePrompt"]);void 0!==t&&null!=s&&tW(t,["parameters","negativePrompt"],s);let a=tz(e,["enhancePrompt"]);if(void 0!==t&&null!=a&&tW(t,["parameters","enhancePrompt"],a),void 0!==tz(e,["generateAudio"]))throw Error("generateAudio parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let u=tz(e,["lastFrame"]);void 0!==t&&null!=u&&tW(t,["instances[0]","lastFrame"],i3(u));let p=tz(e,["referenceImages"]);if(void 0!==t&&null!=p){let e=p;Array.isArray(e)&&(e=e.map(e=>{var t;let n,i,r;return n={},null!=(i=tz(t=e,["image"]))&&tW(n,["image"],i3(i)),null!=(r=tz(t,["referenceType"]))&&tW(n,["referenceType"],r),n})),tW(t,["instances[0]","referenceImages"],e)}if(void 0!==tz(e,["mask"]))throw Error("mask parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==tz(e,["compressionQuality"]))throw Error("compressionQuality parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==tz(e,["labels"]))throw Error("labels parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let d=tz(e,["webhookConfig"]);if(void 0!==t&&null!=d&&tW(t,["webhookConfig"],d),void 0!==tz(e,["resizeMode"]))throw Error("resizeMode parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.")}(_,s),s);return d=tK("{model}:predictLongRunning",E._url),c=E._query,delete E._url,delete E._query,this.apiClient.request({path:d,queryParams:c,body:JSON.stringify(E),httpMethod:"POST",httpOptions:null==(i=e.config)?void 0:i.httpOptions,abortSignal:null==(r=e.config)?void 0:r.abortSignal}).then(e=>e.json()).then(e=>{let t,n,i,r,o,l,s=(t={},null!=(n=tz(e,["name"]))&&tW(t,["name"],n),null!=(i=tz(e,["metadata"]))&&tW(t,["metadata"],i),null!=(r=tz(e,["done"]))&&tW(t,["done"],r),null!=(o=tz(e,["error"]))&&tW(t,["error"],o),null!=(l=tz(e,["response","generateVideoResponse"]))&&tW(t,["response"],function(e){let t={},n=tz(e,["generatedSamples"]);if(null!=n){let e=n;Array.isArray(e)&&(e=e.map(e=>{var t;let n,i,r,o,l,s;return n={},null!=(i=tz(e,["video"]))&&tW(n,["video"],(r={},null!=(o=tz(t=i,["uri"]))&&tW(r,["uri"],o),null!=(l=tz(t,["encodedVideo"]))&&tW(r,["videoBytes"],tZ(l)),null!=(s=tz(t,["encoding"]))&&tW(r,["mimeType"],s),r)),n})),tW(t,["generatedVideos"],e)}let i=tz(e,["raiMediaFilteredCount"]);null!=i&&tW(t,["raiMediaFilteredCount"],i);let r=tz(e,["raiMediaFilteredReasons"]);return null!=r&&tW(t,["raiMediaFilteredReasons"],r),t}(l)),t),a=new nP;return Object.assign(a,s),a})}}}rb.loggedGenerateImagesWarning=!1,rb.loggedEditImageWarning=!1,rb.loggedGenerateVideosWarning=!1;class rP extends t${constructor(e){super(),this.apiClient=e}async getVideosOperation(e){let t=e.operation,n=e.config;if(void 0===t.name||""===t.name)throw Error("Operation name is required.");if(this.apiClient.isVertexAI()){let e,i=t.name.split("/operations/")[0];n&&"httpOptions"in n&&(e=n.httpOptions);let r=await this.fetchPredictVideosOperationInternal({operationName:t.name,resourceName:i,config:{httpOptions:e}});return t._fromAPIResponse({apiResponse:r,_isVertexAI:!0})}{let e=await this.getVideosOperationInternal({operationName:t.name,config:n});return t._fromAPIResponse({apiResponse:e,_isVertexAI:!1})}}async get(e){let t=e.operation,n=e.config;if(void 0===t.name||""===t.name)throw Error("Operation name is required.");if(this.apiClient.isVertexAI()){let e,i=t.name.split("/operations/")[0];n&&"httpOptions"in n&&(e=n.httpOptions);let r=await this.fetchPredictVideosOperationInternal({operationName:t.name,resourceName:i,config:{httpOptions:e}});return t._fromAPIResponse({apiResponse:r,_isVertexAI:!0})}{let e=await this.getVideosOperationInternal({operationName:t.name,config:n});return t._fromAPIResponse({apiResponse:e,_isVertexAI:!1})}}async getVideosOperationInternal(e){var t,n,i,r;let o="",l={};if(this.apiClient.isVertexAI()){let i,r,s=(i={},null!=(r=tz(e,["operationName"]))&&tW(i,["_url","operationName"],r),i);return o=tK("{operationName}",s._url),l=s._query,delete s._url,delete s._query,this.apiClient.request({path:o,queryParams:l,body:JSON.stringify(s),httpMethod:"GET",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal}).then(e=>e.json())}{let t,n,s=(t={},null!=(n=tz(e,["operationName"]))&&tW(t,["_url","operationName"],n),t);return o=tK("{operationName}",s._url),l=s._query,delete s._url,delete s._query,this.apiClient.request({path:o,queryParams:l,body:JSON.stringify(s),httpMethod:"GET",httpOptions:null==(i=e.config)?void 0:i.httpOptions,abortSignal:null==(r=e.config)?void 0:r.abortSignal}).then(e=>e.json())}}async fetchPredictVideosOperationInternal(e){var t,n;let i="",r={};if(this.apiClient.isVertexAI()){let o,l,s,a=(o={},null!=(l=tz(e,["operationName"]))&&tW(o,["operationName"],l),null!=(s=tz(e,["resourceName"]))&&tW(o,["_url","resourceName"],s),o);return i=tK("{resourceName}:fetchPredictOperation",a._url),r=a._query,delete a._url,delete a._query,this.apiClient.request({path:i,queryParams:r,body:JSON.stringify(a),httpMethod:"POST",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal}).then(e=>e.json())}throw Error("This method is only supported by the Gemini Enterprise Agent Platform (previously known as Vertex AI).")}}class rR extends t${constructor(e){super(),this.apiClient=e}async create(e){var t,n,i,r,o;let l="",s={};if(this.apiClient.isVertexAI())throw Error("The client.tokens.create method is only supported by the Gemini Developer API.");{let a,u,p,d,c,m,f,h,g,_,E=(i=this.apiClient,d={},null!=(c=tz(e,["config"]))&&tW(d,["config"],(m=tz(c,["expireTime"]),void 0!==d&&null!=m&&tW(d,["expireTime"],m),f=tz(c,["newSessionExpireTime"]),void 0!==d&&null!=f&&tW(d,["newSessionExpireTime"],f),h=tz(c,["uses"]),void 0!==d&&null!=h&&tW(d,["uses"],h),g=tz(c,["liveConnectConstraints"]),void 0!==d&&null!=g&&tW(d,["bidiGenerateContentSetup"],(r=i,a={},null!=(u=tz(o=g,["model"]))&&tW(a,["setup","model"],n7(r,u)),null!=(p=tz(o,["config"]))&&tW(a,["config"],function(e,t){let n=tz(e,["generationConfig"]);void 0!==t&&null!=n&&tW(t,["setup","generationConfig"],n);let i=tz(e,["responseModalities"]);void 0!==t&&null!=i&&tW(t,["setup","generationConfig","responseModalities"],i);let r=tz(e,["temperature"]);void 0!==t&&null!=r&&tW(t,["setup","generationConfig","temperature"],r);let o=tz(e,["topP"]);void 0!==t&&null!=o&&tW(t,["setup","generationConfig","topP"],o);let l=tz(e,["topK"]);void 0!==t&&null!=l&&tW(t,["setup","generationConfig","topK"],l);let s=tz(e,["maxOutputTokens"]);void 0!==t&&null!=s&&tW(t,["setup","generationConfig","maxOutputTokens"],s);let a=tz(e,["mediaResolution"]);void 0!==t&&null!=a&&tW(t,["setup","generationConfig","mediaResolution"],a);let u=tz(e,["seed"]);void 0!==t&&null!=u&&tW(t,["setup","generationConfig","seed"],u);let p=tz(e,["speechConfig"]);void 0!==t&&null!=p&&tW(t,["setup","generationConfig","speechConfig"],i_(p));let d=tz(e,["thinkingConfig"]);void 0!==t&&null!=d&&tW(t,["setup","generationConfig","thinkingConfig"],d);let c=tz(e,["enableAffectiveDialog"]);void 0!==t&&null!=c&&tW(t,["setup","generationConfig","enableAffectiveDialog"],c);let m=tz(e,["systemInstruction"]);void 0!==t&&null!=m&&tW(t,["setup","systemInstruction"],function(e){let t={},n=tz(e,["parts"]);if(null!=n){let e=n;Array.isArray(e)&&(e=e.map(e=>{var t;let n,i,r,o,l,s,a,u,p,d,c,m,f,h,g,_,E;return n={},null!=(i=tz(t=e,["mediaResolution"]))&&tW(n,["mediaResolution"],i),null!=(r=tz(t,["toolCall"]))&&tW(n,["toolCall"],r),null!=(o=tz(t,["toolResponse"]))&&tW(n,["toolResponse"],o),null!=(l=tz(t,["audioTranscription"]))&&tW(n,["audioTranscription"],l),null!=(s=tz(t,["codeExecutionResult"]))&&tW(n,["codeExecutionResult"],s),null!=(a=tz(t,["executableCode"]))&&tW(n,["executableCode"],a),null!=(u=tz(t,["fileData"]))&&tW(n,["fileData"],function(e){let t={};if(void 0!==tz(e,["displayName"]))throw Error("displayName parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let n=tz(e,["fileUri"]);null!=n&&tW(t,["fileUri"],n);let i=tz(e,["mimeType"]);return null!=i&&tW(t,["mimeType"],i),t}(u)),null!=(p=tz(t,["functionCall"]))&&tW(n,["functionCall"],function(e){let t={},n=tz(e,["args"]);null!=n&&tW(t,["args"],n);let i=tz(e,["id"]);null!=i&&tW(t,["id"],i);let r=tz(e,["name"]);if(null!=r&&tW(t,["name"],r),void 0!==tz(e,["partialArgs"]))throw Error("partialArgs parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==tz(e,["willContinue"]))throw Error("willContinue parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");return t}(p)),null!=(d=tz(t,["functionResponse"]))&&tW(n,["functionResponse"],d),null!=(c=tz(t,["inlineData"]))&&tW(n,["inlineData"],function(e){let t={},n=tz(e,["data"]);if(null!=n&&tW(t,["data"],n),void 0!==tz(e,["displayName"]))throw Error("displayName parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let i=tz(e,["mimeType"]);return null!=i&&tW(t,["mimeType"],i),t}(c)),null!=(m=tz(t,["text"]))&&tW(n,["text"],m),null!=(f=tz(t,["thought"]))&&tW(n,["thought"],f),null!=(h=tz(t,["thoughtSignature"]))&&tW(n,["thoughtSignature"],h),null!=(g=tz(t,["videoMetadata"]))&&tW(n,["videoMetadata"],g),null!=(_=tz(t,["partMetadata"]))&&tW(n,["partMetadata"],_),null!=(E=tz(t,["mediaProcessing"]))&&tW(n,["mediaProcessing"],E),n})),tW(t,["parts"],e)}let i=tz(e,["role"]);return null!=i&&tW(t,["role"],i),t}(id(m)));let f=tz(e,["tools"]);if(void 0!==t&&null!=f){let e=iy(f);Array.isArray(e)&&(e=e.map(e=>(function(e){let t={};if(void 0!==tz(e,["retrieval"]))throw Error("retrieval parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let n=tz(e,["googleMaps"]);null!=n&&tW(t,["googleMaps"],function(e){let t={},n=tz(e,["authConfig"]);null!=n&&tW(t,["authConfig"],function(e){let t={},n=tz(e,["apiKey"]);if(null!=n&&tW(t,["apiKey"],n),void 0!==tz(e,["apiKeyConfig"]))throw Error("apiKeyConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==tz(e,["authType"]))throw Error("authType parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==tz(e,["googleServiceAccountConfig"]))throw Error("googleServiceAccountConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==tz(e,["httpBasicAuthConfig"]))throw Error("httpBasicAuthConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==tz(e,["oauthConfig"]))throw Error("oauthConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==tz(e,["oidcConfig"]))throw Error("oidcConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");return t}(n));let i=tz(e,["enableWidget"]);if(null!=i&&tW(t,["enableWidget"],i),void 0!==tz(e,["groundingTypes"]))throw Error("groundingTypes parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");return t}(n));let i=tz(e,["mcpServers"]);if(null!=i){let e=i;Array.isArray(e)&&(e=e.map(e=>e)),tW(t,["mcpServers"],e)}let r=tz(e,["codeExecution"]);null!=r&&tW(t,["codeExecution"],r);let o=tz(e,["computerUse"]);if(null!=o&&tW(t,["computerUse"],o),void 0!==tz(e,["enterpriseWebSearch"]))throw Error("enterpriseWebSearch parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==tz(e,["exaAiSearch"]))throw Error("exaAiSearch parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let l=tz(e,["functionDeclarations"]);if(null!=l){let e=l;Array.isArray(e)&&(e=e.map(e=>e)),tW(t,["functionDeclarations"],e)}let s=tz(e,["googleSearch"]);null!=s&&tW(t,["googleSearch"],function(e){let t={};if(void 0!==tz(e,["blockingConfidence"]))throw Error("blockingConfidence parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==tz(e,["excludeDomains"]))throw Error("excludeDomains parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let n=tz(e,["searchTypes"]);null!=n&&tW(t,["searchTypes"],n);let i=tz(e,["timeRangeFilter"]);return null!=i&&tW(t,["timeRangeFilter"],i),t}(s));let a=tz(e,["googleSearchRetrieval"]);if(null!=a&&tW(t,["googleSearchRetrieval"],a),void 0!==tz(e,["parallelAiSearch"]))throw Error("parallelAiSearch parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let u=tz(e,["urlContext"]);null!=u&&tW(t,["urlContext"],u);let p=tz(e,["fileSearch"]);return null!=p&&tW(t,["fileSearch"],p),t})(iE(e)))),tW(t,["setup","tools"],e)}let h=tz(e,["sessionResumption"]);void 0!==t&&null!=h&&tW(t,["setup","sessionResumption"],function(e){let t={},n=tz(e,["handle"]);if(null!=n&&tW(t,["handle"],n),void 0!==tz(e,["transparent"]))throw Error("transparent parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");return t}(h));let g=tz(e,["inputAudioTranscription"]);void 0!==t&&null!=g&&tW(t,["setup","inputAudioTranscription"],g);let _=tz(e,["outputAudioTranscription"]);void 0!==t&&null!=_&&tW(t,["setup","outputAudioTranscription"],_);let E=tz(e,["realtimeInputConfig"]);void 0!==t&&null!=E&&tW(t,["setup","realtimeInputConfig"],E);let y=tz(e,["contextWindowCompression"]);void 0!==t&&null!=y&&tW(t,["setup","contextWindowCompression"],y);let v=tz(e,["proactivity"]);if(void 0!==t&&null!=v&&tW(t,["setup","proactivity"],v),void 0!==tz(e,["explicitVadSignal"]))throw Error("explicitVadSignal parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let A=tz(e,["avatarConfig"]);void 0!==t&&null!=A&&tW(t,["setup","avatarConfig"],A);let I=tz(e,["safetySettings"]);if(void 0!==t&&null!=I){let e=I;Array.isArray(e)&&(e=e.map(e=>(function(e){let t={},n=tz(e,["category"]);if(null!=n&&tW(t,["category"],n),void 0!==tz(e,["method"]))throw Error("method parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let i=tz(e,["threshold"]);return null!=i&&tW(t,["threshold"],i),t})(e))),tW(t,["setup","safetySettings"],e)}let T=tz(e,["translationConfig"]);return void 0!==t&&null!=T&&tW(t,["setup","generationConfig","translationConfig"],T),{}}(p,a)),a)),_=tz(c,["lockAdditionalFields"]),void 0!==d&&null!=_&&tW(d,["fieldMask"],_),{})),d);l=tK("auth_tokens",E._url),s=E._query,delete E.config,delete E._url,delete E._query;let y=function(e,t){let n=null,i=e.bidiGenerateContentSetup;if("object"==typeof i&&null!==i&&"setup"in i){let t=i.setup;"object"==typeof t&&null!==t?(e.bidiGenerateContentSetup=t,n=t):delete e.bidiGenerateContentSetup}else void 0!==i&&delete e.bidiGenerateContentSetup;let r=e.fieldMask;if(n){let i=function(e){let t=[];for(let n in e)if(Object.prototype.hasOwnProperty.call(e,n)){let i=e[n];if("object"==typeof i&&null!=i&&Object.keys(i).length>0){let e=Object.keys(i).map(e=>`${n}.${e}`);t.push(...e)}else t.push(n)}return t.join(",")}(n);if(Array.isArray(null==t?void 0:t.lockAdditionalFields)&&(null==t?void 0:t.lockAdditionalFields.length)===0)i?e.fieldMask=i:delete e.fieldMask;else if((null==t?void 0:t.lockAdditionalFields)&&t.lockAdditionalFields.length>0&&null!==r&&Array.isArray(r)&&r.length>0){let t=["temperature","topK","topP","maxOutputTokens","responseModalities","seed","speechConfig"],n=[];r.length>0&&(n=r.map(e=>t.includes(e)?`generationConfig.${e}`:e));let o=[];i&&o.push(i),n.length>0&&o.push(...n),o.length>0?e.fieldMask=o.join(","):delete e.fieldMask}else delete e.fieldMask}else null!==r&&Array.isArray(r)&&r.length>0?e.fieldMask=r.join(","):delete e.fieldMask;return e}(E,e.config);return this.apiClient.request({path:l,queryParams:s,body:JSON.stringify(y),httpMethod:"POST",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal}).then(e=>e.json()).then(e=>e)}}}class rN extends t${constructor(e){super(),this.apiClient=e,this.list=async e=>new iG(tX.PAGED_ITEM_DOCUMENTS,t=>this.listInternal({parent:e.parent,config:t.config}),await this.listInternal(e),e)}async get(e){var t,n;let i="",r={};if(this.apiClient.isVertexAI())throw Error("This method is only supported by the Gemini Developer API.");{let o,l,s=(o={},null!=(l=tz(e,["name"]))&&tW(o,["_url","name"],l),o);return i=tK("{name}",s._url),r=s._query,delete s._url,delete s._query,this.apiClient.request({path:i,queryParams:r,body:JSON.stringify(s),httpMethod:"GET",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal}).then(e=>e.json()).then(e=>e)}}async delete(e){var t,n;let i="",r={};if(this.apiClient.isVertexAI())throw Error("This method is only supported by the Gemini Developer API.");{let o,l,s,a,u=(o={},null!=(l=tz(e,["name"]))&&tW(o,["_url","name"],l),null!=(s=tz(e,["config"]))&&(a=tz(s,["force"]),void 0!==o&&null!=a&&tW(o,["_query","force"],a)),o);i=tK("{name}",u._url),r=u._query,delete u._url,delete u._query,await this.apiClient.request({path:i,queryParams:r,body:JSON.stringify(u),httpMethod:"DELETE",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal})}}async listInternal(e){var t,n;let i="",r={};if(this.apiClient.isVertexAI())throw Error("This method is only supported by the Gemini Developer API.");{let o,l,s,a,u,p=(o={},null!=(l=tz(e,["parent"]))&&tW(o,["_url","parent"],l),null!=(s=tz(e,["config"]))&&(a=tz(s,["pageSize"]),void 0!==o&&null!=a&&tW(o,["_query","pageSize"],a),u=tz(s,["pageToken"]),void 0!==o&&null!=u&&tW(o,["_query","pageToken"],u)),o);return i=tK("{parent}/documents",p._url),r=p._query,delete p._url,delete p._query,this.apiClient.request({path:i,queryParams:r,body:JSON.stringify(p),httpMethod:"GET",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal}).then(e=>e.json()).then(e=>{let t=function(e){let t={},n=tz(e,["sdkHttpResponse"]);null!=n&&tW(t,["sdkHttpResponse"],n);let i=tz(e,["nextPageToken"]);null!=i&&tW(t,["nextPageToken"],i);let r=tz(e,["documents"]);if(null!=r){let e=r;Array.isArray(e)&&(e=e.map(e=>e)),tW(t,["documents"],e)}return t}(e),n=new nx;return Object.assign(n,t),n})}}}class rw extends t${constructor(e,t=new rN(e)){super(),this.apiClient=e,this.documents=t,this.list=async(e={})=>new iG(tX.PAGED_ITEM_FILE_SEARCH_STORES,e=>this.listInternal(e),await this.listInternal(e),e)}async uploadToFileSearchStore(e){if(this.apiClient.isVertexAI())throw Error("Gemini Enterprise Agent Platform (previously known as Vertex AI) does not support uploading files to a file search store.");return this.apiClient.uploadFileToFileSearchStore(e.fileSearchStoreName,e.file,e.config)}async downloadMedia(e,t){if(this.apiClient.isVertexAI())throw Error("This method is only supported in the Gemini Developer client.");let n=new URL(e,"http://dummy.com"),i=n.pathname;if(i.startsWith("/")&&(i=i.slice(1)),!i.includes("/media/"))throw Error(`Invalid uri format: ${e}. Expected to contain /media/`);let r={};n.searchParams.forEach((e,t)=>{r[t]=e}),r.alt="media";let o=Object.assign({},null==t?void 0:t.httpOptions),l=await this.apiClient.request({path:i,httpMethod:"GET",queryParams:r,httpOptions:o});if(l instanceof na)return new Uint8Array(await l.responseInternal.arrayBuffer());throw Error("Unexpected response type from downloadMedia")}async create(e){var t,n,i;let r="",o={};if(this.apiClient.isVertexAI())throw Error("This method is only supported by the Gemini Developer API.");{let l,s,a,u,p=(i=this.apiClient,l={},null!=(s=tz(e,["config"]))&&(a=tz(s,["displayName"]),void 0!==l&&null!=a&&tW(l,["displayName"],a),u=tz(s,["embeddingModel"]),void 0!==l&&null!=u&&tW(l,["embeddingModel"],n7(i,u))),l);return r=tK("fileSearchStores",p._url),o=p._query,delete p._url,delete p._query,this.apiClient.request({path:r,queryParams:o,body:JSON.stringify(p),httpMethod:"POST",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal}).then(e=>e.json()).then(e=>e)}}async get(e){var t,n;let i="",r={};if(this.apiClient.isVertexAI())throw Error("This method is only supported by the Gemini Developer API.");{let o,l,s=(o={},null!=(l=tz(e,["name"]))&&tW(o,["_url","name"],l),o);return i=tK("{name}",s._url),r=s._query,delete s._url,delete s._query,this.apiClient.request({path:i,queryParams:r,body:JSON.stringify(s),httpMethod:"GET",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal}).then(e=>e.json()).then(e=>e)}}async delete(e){var t,n;let i="",r={};if(this.apiClient.isVertexAI())throw Error("This method is only supported by the Gemini Developer API.");{let o,l,s,a,u=(o={},null!=(l=tz(e,["name"]))&&tW(o,["_url","name"],l),null!=(s=tz(e,["config"]))&&(a=tz(s,["force"]),void 0!==o&&null!=a&&tW(o,["_query","force"],a)),o);i=tK("{name}",u._url),r=u._query,delete u._url,delete u._query,await this.apiClient.request({path:i,queryParams:r,body:JSON.stringify(u),httpMethod:"DELETE",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal})}}async listInternal(e){var t,n;let i="",r={};if(this.apiClient.isVertexAI())throw Error("This method is only supported by the Gemini Developer API.");{let o,l,s,a,u=(o={},null!=(l=tz(e,["config"]))&&(s=tz(l,["pageSize"]),void 0!==o&&null!=s&&tW(o,["_query","pageSize"],s),a=tz(l,["pageToken"]),void 0!==o&&null!=a&&tW(o,["_query","pageToken"],a)),o);return i=tK("fileSearchStores",u._url),r=u._query,delete u._url,delete u._query,this.apiClient.request({path:i,queryParams:r,body:JSON.stringify(u),httpMethod:"GET",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal}).then(e=>e.json()).then(e=>{let t=function(e){let t={},n=tz(e,["sdkHttpResponse"]);null!=n&&tW(t,["sdkHttpResponse"],n);let i=tz(e,["nextPageToken"]);null!=i&&tW(t,["nextPageToken"],i);let r=tz(e,["fileSearchStores"]);if(null!=r){let e=r;Array.isArray(e)&&(e=e.map(e=>e)),tW(t,["fileSearchStores"],e)}return t}(e),n=new nL;return Object.assign(n,t),n})}}async uploadToFileSearchStoreInternal(e){var t,n;let i="",r={};if(this.apiClient.isVertexAI())throw Error("This method is only supported by the Gemini Developer API.");{let o,l,s,a=(o={},null!=(l=tz(e,["fileSearchStoreName"]))&&tW(o,["_url","file_search_store_name"],l),null!=(s=tz(e,["config"]))&&ro(s,o),o);return i=tK("upload/v1beta/{file_search_store_name}:uploadToFileSearchStore",a._url),r=a._query,delete a._url,delete a._query,this.apiClient.request({path:i,queryParams:r,body:JSON.stringify(a),httpMethod:"POST",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal}).then(e=>e.json()).then(e=>{let t,n,i=(t={},null!=(n=tz(e,["sdkHttpResponse"]))&&tW(t,["sdkHttpResponse"],n),t),r=new nq;return Object.assign(r,i),r})}}async importFile(e){var t,n;let i="",r={};if(this.apiClient.isVertexAI())throw Error("This method is only supported by the Gemini Developer API.");{let o,l,s,a,u=(o={},null!=(l=tz(e,["fileSearchStoreName"]))&&tW(o,["_url","file_search_store_name"],l),null!=(s=tz(e,["fileName"]))&&tW(o,["fileName"],s),null!=(a=tz(e,["config"]))&&function(e,t){let n=tz(e,["customMetadata"]);if(void 0!==t&&null!=n){let e=n;Array.isArray(e)&&(e=e.map(e=>e)),tW(t,["customMetadata"],e)}let i=tz(e,["chunkingConfig"]);void 0!==t&&null!=i&&tW(t,["chunkingConfig"],i)}(a,o),o);return i=tK("{file_search_store_name}:importFile",u._url),r=u._query,delete u._url,delete u._query,this.apiClient.request({path:i,queryParams:r,body:JSON.stringify(u),httpMethod:"POST",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal}).then(e=>e.json()).then(e=>{var t;let n,i,r,o,l,s,a,u,p,d,c=(l={},null!=(s=tz(e,["name"]))&&tW(l,["name"],s),null!=(a=tz(e,["metadata"]))&&tW(l,["metadata"],a),null!=(u=tz(e,["done"]))&&tW(l,["done"],u),null!=(p=tz(e,["error"]))&&tW(l,["error"],p),null!=(d=tz(e,["response"]))&&tW(l,["response"],(n={},null!=(i=tz(t=d,["sdkHttpResponse"]))&&tW(n,["sdkHttpResponse"],i),null!=(r=tz(t,["parent"]))&&tW(n,["parent"],r),null!=(o=tz(t,["documentName"]))&&tW(n,["documentName"],o),n)),l),m=new nF;return Object.assign(m,c),m})}}}function rD(){var e,t,n,i,r,l;if(o)return o;let s=globalThis;return o=("Deno"in globalThis?0:1)?null!=(l=null==(r=s.process)?void 0:r.env)?l:{}:null!=(i=null==(n=null==(t=null==(e=s.Deno)?void 0:e.env)?void 0:t.toObject)?void 0:n.call(t))?i:{}}class rG{constructor(e){this.options=e}getDefaultHeaders(){return this.options.defaultHeaders}async resolveGoogleGenAISecurity(e){return function(e){var t,n;let i={};for(let[t,n]of e){let e=t.toLowerCase();"authorization"!==e&&"x-goog-api-key"!==e&&(i[t]=n)}let r={access_token:null!=(t=e.get("authorization"))?t:void 0,api_key:null!=(n=e.get("x-goog-api-key"))?n:void 0,default_headers:Object.keys(i).length?i:void 0};return rH(r)?r:void 0}(await this.options.getAuthHeaders(e))}}class rM{beforeCreateRequest(e,t){return Object.assign(Object.assign({},t),{url:function(e){let[,t,...n]=e.pathname.split("/");if(!t)return e;let i=decodeURIComponent(t);if(!i.includes("/"))return e;let r=new URL(e);return r.pathname=`/${i}/${n.join("/")}`,r}(t.url)})}async beforeRequest(e,t){var n,i,r,o,l,s;if(rx(t.headers,rq(n=e.security_source)?null!=(r=null==(i=n.getDefaultHeaders)?void 0:i.call(n))?r:n.defaultHeaders:rL(n)?n.default_headers:void 0),o=e,l=t.headers,void 0!==o.options.user_project&&null===l.get("x-goog-user-project")&&l.set("x-goog-user-project",o.options.user_project),null!==(s=t.headers).get("authorization")||null!==s.get("x-goog-api-key"))return t;let a=await rk(e.security_source,t.url);return rx(t.headers,null==a?void 0:a.default_headers),function(e,t){if(t){var n;if(t.api_key)return e.set("x-goog-api-key",t.api_key);t.access_token&&e.set("Authorization","bearer "===(n=t.access_token).slice(0,7).toLowerCase()?n:`Bearer ${n}`)}}(t.headers,a),t}}async function rk(e,t){if(rq(e))return e.resolveGoogleGenAISecurity(t);let n="function"==typeof e?await e():e;return rL(n)?rU(n):rU(void 0)}function rU(e){var t,n;let i=rD(),r=Object.assign(Object.assign({},e),{api_key:null!=(t=null==e?void 0:e.api_key)?t:i.GOOGLE_GENAI_API_KEY,access_token:null!=(n=null==e?void 0:e.access_token)?n:i.GOOGLE_GENAI_ACCESS_TOKEN});return rH(r)?r:void 0}function rx(e,t){if(t)for(let[n,i]of new Headers(t))null===e.get(n)&&e.set(n,i)}function rL(e){return"object"==typeof e&&null!==e}function rq(e){return"object"==typeof e&&null!==e&&"resolveGoogleGenAISecurity"in e&&"function"==typeof e.resolveGoogleGenAISecurity}function rH(e){return void 0!==e.api_key||void 0!==e.access_token||void 0!==e.default_headers}class rF extends Error{constructor(e,t){let n=e;(null==t?void 0:t.cause)&&(n+=`: ${t.cause}`),super(n,t),this.name="HTTPClientError",void 0===this.cause&&(this.cause=null==t?void 0:t.cause)}}class rj extends rF{constructor(){super(...arguments),this.name="UnexpectedClientError"}}class rB extends rF{constructor(){super(...arguments),this.name="InvalidRequestError"}}class rX extends rF{constructor(){super(...arguments),this.name="RequestAbortedError"}}class rV extends rF{constructor(){super(...arguments),this.name="RequestTimeoutError"}}class rJ extends rF{constructor(){super(...arguments),this.name="ConnectionError"}}class rY extends Error{constructor(e,t){var n,i,r,o;super(e),this.statusCode=null==(n=null==t?void 0:t.response)?void 0:n.status,this.body=null!=(i=null==t?void 0:t.body)?i:"",this.headers=null==(r=null==t?void 0:t.response)?void 0:r.headers,this.contentType=(null==(o=null==t?void 0:t.response)?void 0:o.headers.get("content-type"))||"",this.rawResponse=null==t?void 0:t.response,this.name="GoogleGenAiError"}}class r$ extends Error{}class rK extends r${constructor(e,t,n,i){super(rK.makeMessage(e,t,n)),this.status=e,this.headers=i,this.error=t,this.statusCode=e,this.body=r7(t),this.contentType=(null==i?void 0:i.get("content-type"))||"",this.rawResponse=void 0,this.cause=void 0,this.name=this.constructor.name,Object.setPrototypeOf(this,new.target.prototype)}static makeMessage(e,t,n){var i,r;let o=t&&null!==(r=t)&&"object"==typeof r&&!Array.isArray(r)&&"string"==typeof t.message?t.message:void 0,l=r7(t),s=null!=(i=null!=o?o:n)?i:l||"An error occurred",a=e?`${e} `:"";return`${a}${s}`}static generate(e,t,n,i){return e&&i?400===e?new rQ(e,t,n,i):401===e?new r0(e,t,n,i):403===e?new r1(e,t,n,i):404===e?new r4(e,t,n,i):409===e?new r2(e,t,n,i):422===e?new r5(e,t,n,i):429===e?new r3(e,t,n,i):e>=500?new r8(e,t,n,i):new rK(e,t,n,i):new rz({message:n,cause:t instanceof Error?t:void 0})}}class rW extends rK{constructor({message:e}={}){super(void 0,void 0,e||"Request was aborted.",void 0)}}class rz extends rK{constructor({message:e,cause:t}){super(void 0,void 0,e||"Connection error.",void 0),this.cause=t}}class rZ extends rz{constructor({message:e}={}){super({message:e||"Request timed out. This is a client-side timeout. You can increase the timeout by setting the `timeout` argument in your request or client http options."})}}class rQ extends rK{}class r0 extends rK{}class r1 extends rK{}class r4 extends rK{}class r2 extends rK{}class r5 extends rK{}class r3 extends rK{}class r8 extends rK{}function r9(e){var t,n,i;let r,o;return"object"==typeof(t=e)&&null!==t&&rK.prototype.isPrototypeOf(t)?e:e instanceof rY?(r=function(e){let t=r6(e,"data$");if(t&&"object"==typeof t)return t;try{let t=JSON.parse(e.body);if(t&&"object"==typeof t)return t}catch(e){}let n=r6(e,"error");return n&&"object"==typeof n?n:void 0}(n=e),oe(o=rK.generate(n.statusCode,r,n.message,n.headers),"body",n.body),oe(o,"contentType",n.contentType),oe(o,"rawResponse",n.rawResponse),oe(o,"statusCode",n.statusCode),oe(o,"cause",n),o):e instanceof rF?(i=e)instanceof rV?new rZ({message:i.message}):i instanceof rX?new rW({message:i.message}):(i instanceof rJ,new rz({message:i.message,cause:i})):e}function r6(e,t){return e&&"object"==typeof e?e[t]:void 0}function r7(e){if(!e)return"";try{return JSON.stringify(e)}catch(t){return String(e)}}function oe(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!0,value:n,writable:!1})}let ot=(e,t)=>null==t?fetch(e):fetch(e,t);class on{constructor(e={}){this.requestHooks=[],this.requestErrorHooks=[],this.responseHooks=[],this.options=e,this.fetcher=e.fetcher||ot}async request(e){let t=e;for(let e of this.requestHooks){let n=await e(t);n&&(t=n)}try{let e=await this.fetcher(t);for(let n of this.responseHooks)await n(e,t);return e}catch(e){for(let n of this.requestErrorHooks)await n(e,t);throw e}}addHook(...e){if("beforeRequest"===e[0])this.requestHooks.push(e[1]);else if("requestError"===e[0])this.requestErrorHooks.push(e[1]);else if("response"===e[0])this.responseHooks.push(e[1]);else throw Error(`Invalid hook type: ${e[0]}`);return this}removeHook(...e){let t;if("beforeRequest"===e[0])t=this.requestHooks;else if("requestError"===e[0])t=this.requestErrorHooks;else if("response"===e[0])t=this.responseHooks;else throw Error(`Invalid hook type: ${e[0]}`);let n=t.findIndex(t=>t===e[1]);return n>=0&&t.splice(n,1),this}clone(){let e=new on(this.options);return e.requestHooks=this.requestHooks.slice(),e.requestErrorHooks=this.requestErrorHooks.slice(),e.responseHooks=this.responseHooks.slice(),e}}let oi=/\s*;\s*/g;function or(e,t){var n;if("*"===t)return!0;let i=(null==(n=e.headers.get("content-type"))?void 0:n.trim())||"application/octet-stream";i=i.toLowerCase();let[r="",...o]=t.toLowerCase().trim().split(oi);if(2!==r.split("/").length)return!1;let[l="",...s]=i.split(oi),[a="",u=""]=l.split("/");if(!a||!u||"*/*"!==r&&l!==r&&`${a}/*`!==r&&`*/${u}`!==r||s.length<o.length)return!1;let p=new Set(s);for(let e of o)if(!p.has(e))return!1;return!0}let oo=RegExp("^[0-9]xx$","i");function ol(e,t){let n=`${e.status}`,i=Array.isArray(t)?t:[t];return!!i.length&&i.some(e=>{let t=`${e}`;if("default"===t)return!0;if(!oo.test(`${t}`))return t===n;let i=t.charAt(0);if(!i)throw Error("Invalid status code range");let r=n.charAt(0);if(!r)throw Error(`Invalid response status code: ${n}`);return r===i})}function os(e){if("object"!=typeof e||null==e)return!1;let t=e instanceof TypeError&&e.message.toLowerCase().startsWith("failed to fetch"),n=e instanceof TypeError&&e.message.toLowerCase().startsWith("fetch failed"),i="name"in e&&"ConnectionError"===e.name,r="code"in e&&"string"==typeof e.code&&"econnreset"===e.code.toLowerCase();return t||n||r||i}function oa(e){if("object"!=typeof e||null==e)return!1;let t="name"in e&&"TimeoutError"===e.name,n="code"in e&&23===e.code,i="code"in e&&"string"==typeof e.code&&"econnaborted"===e.code.toLowerCase();return t||n||i}class ou{constructor(){for(const e of(this.sdkInitHooks=[],this.beforeCreateRequestHooks=[],this.beforeRequestHooks=[],this.afterSuccessHooks=[],this.afterErrorHooks=[],[]))"sdkInit"in e&&this.registerSDKInitHook(e),"beforeCreateRequest"in e&&this.registerBeforeCreateRequestHook(e),"beforeRequest"in e&&this.registerBeforeRequestHook(e),"afterSuccess"in e&&this.registerAfterSuccessHook(e),"afterError"in e&&this.registerAfterErrorHook(e);!function(e){let t=new rM;e.registerBeforeCreateRequestHook(t),e.registerBeforeRequestHook(t)}(this)}registerSDKInitHook(e){this.sdkInitHooks.push(e)}registerBeforeCreateRequestHook(e){this.beforeCreateRequestHooks.push(e)}registerBeforeRequestHook(e){this.beforeRequestHooks.push(e)}registerAfterSuccessHook(e){this.afterSuccessHooks.push(e)}registerAfterErrorHook(e){this.afterErrorHooks.push(e)}sdkInit(e){return this.sdkInitHooks.reduce((e,t)=>t.sdkInit(e),e)}beforeCreateRequest(e,t){let n=t;for(let t of this.beforeCreateRequestHooks)n=t.beforeCreateRequest(e,n);return n}async beforeRequest(e,t){let n=t;for(let t of this.beforeRequestHooks)n=await t.beforeRequest(e,n);return n}async afterSuccess(e,t){let n=t;for(let t of this.afterSuccessHooks)n=await t.afterSuccess(e,n);return n}async afterError(e,t,n){let i=t,r=n;for(let t of this.afterErrorHooks){let n=await t.afterError(e,i,r);i=n.response,r=n.error}return{response:i,error:r}}}function op(e){return{ok:!0,value:e}}function od(e){return{ok:!1,error:e}}function oc(e){return btoa(String.fromCodePoint(...e))}let om=Object.prototype.hasOwnProperty;function of(e,t){let n=/\{([a-zA-Z0-9_][a-zA-Z0-9_-]*?)\}/g;return function(t={}){return e.replace(n,function(e,n){if(!om.call(t,n))throw Error(`Parameter '${n}' is required`);let i=t[n];if("string"!=typeof i&&"number"!=typeof i)throw Error(`Parameter '${n}' must be a string or number`);return`${i}`}).replace(/^\/+/,"")}}let oh=["https://generativelanguage.googleapis.com"];function og(e){let t={};for(let[n,i]of Object.entries(e))void 0!==i&&(t[n]=i);return t}function o_(e){if(null===e||"object"!=typeof e||"[object Object]"!==Object.prototype.toString.call(e))return!1;let t=Object.getPrototypeOf(e);if(null===t||t===Object.prototype)return!0;try{return null===Object.getPrototypeOf(t)}catch(e){return!1}}let oE=/%(2[346bcf]|3[abdf]|40|5[bd])/gi;function oy(e,t){return ov(e,"percentExceptReserved"===t?"percent":t)}function ov(e,t){switch(t){case"percent":return encodeURIComponent(e);case"percentExceptReserved":return encodeURIComponent(e).replace(oE,e=>decodeURIComponent(e));default:return e}}let oA=(e,t,n)=>{let i="",r=(null==n?void 0:n.explode)?oC(e,t):[[e,t]];if(r.every(([e,t])=>null==t))return;let o=e=>ov(e,null==n?void 0:n.charEncoding),l=o(",");return r.forEach(([e,t])=>{var r,s;let a="",u=null;null!=t&&(null==(u=Array.isArray(t)?null==(r=ob(t,e=>`${o(oS(e))}`))?void 0:r.join(l):o_(t)?null==(s=oP(Object.entries(t),([e,t])=>`${o(e)}${l}${o(oS(t))}`))?void 0:s.join(l):`${o(oS(t))}`)||(a=`${oy(e,null==n?void 0:n.charEncoding)}=${u}`)&&"="!==a&&(i+=`&${a}`))}),i.slice(1)};function oI(e,t,n){if(void 0===t)return;let i=ov(JSON.stringify(t,oO),null==n?void 0:n.charEncoding);return(null==n?void 0:n.explode)?i:`${oy(e,null==n?void 0:n.charEncoding)}=${i}`}let oT=(e,t,n)=>{let i="",r=(null==n?void 0:n.explode)?oC(e,t):[[e,t]];if(r.every(([e,t])=>null==t))return;let o=e=>ov(e,null==n?void 0:n.charEncoding);return r.forEach(([e,r])=>{var l;let s="";if(null!=r){if(Array.isArray(r))s=null==(l=ob(r,e=>`${o(oS(e))}`))?void 0:l.join(",");else if(o_(r)){let e=oP(Object.entries(r),([e,t])=>`,${o(e)},${o(oS(t))}`);s=null==e?void 0:e.join("").slice(1)}else{let i=(null==n?void 0:n.explode)&&o_(t)?`${e}=`:"";s=`${i}${o(oS(r))}`}i+=s?`,${s}`:""}}),i.slice(1)};function oC(e,t){return Array.isArray(t)?t.map(t=>[e,t]):o_(t)?Object.entries(null!=t?t:{}).map(([e,t])=>[e,t]):[[e,t]]}function oS(e){return null==e?"":e instanceof Date?e.toISOString():e instanceof Uint8Array?oc(e):"object"==typeof e?JSON.stringify(e,oO):`${e}`}function oO(e,t){return t instanceof Uint8Array?oc(t):t}function ob(e,t){let n=e.reduce((e,n)=>{if(null==n)return e;let i=t(n);return null==i||e.push(i),e},[]);return n.length?n:null}function oP(e,t){let n=[];for(let[i,r]of e){if(null==r)continue;let e=t([i,r]);null!=e&&n.push(e)}return n.length?n:null}let oR=function(e,t){var n,i,r;let o=Object.assign(Object.assign({},t),{explode:null==(n=null==t?void 0:t.explode)||n,charEncoding:null!=(i=null==t?void 0:t.charEncoding)?i:"percent"}),l=new Set(null!=(r=null==t?void 0:t.allowEmptyValue)?r:[]);return function(...e){return e.filter(Boolean).join("&")}(...Object.entries(e).map(([e,t])=>l.has(e)&&(null==t||""===t||Array.isArray(t)&&0===t.length)?`${encodeURIComponent(e)}=`:oA(e,t,o)))},oN={initialInterval:500,maxInterval:6e4,exponent:1.5,maxElapsedTime:36e5};class ow extends Error{constructor(e,t){let n=e;(null==t?void 0:t.cause)&&(n+=`: ${t.cause}`),super(n,t),this.name="PermanentError",void 0===this.cause&&(this.cause=null==t?void 0:t.cause),Object.setPrototypeOf(this,ow.prototype)}}class oD extends Error{constructor(e,t){super(e),this.response=t,this.name="TemporaryError",Object.setPrototypeOf(this,oD.prototype)}}async function oG(e,t){var n;switch(t.config.strategy){case"backoff":return oU(oM(e,{statusCodes:t.statusCodes,retryConnectionErrors:!!t.config.retryConnectionErrors}),null!=(n=t.config.backoff)?n:oN);case"attempt-count-backoff":return ox(oM(e,{statusCodes:t.statusCodes,retryConnectionErrors:!!t.config.retryConnectionErrors}),Object.assign(Object.assign({},oN),t.config.backoff),t.config);default:return await e(0)}}function oM(e,t){return async n=>{try{var i,r;let o,l=await e(n);if(i=l,r=t.statusCodes,o=`${i.status}`,r.some(e=>{if(!ok.test(e))return e===o;let t=e.charAt(0);if(!t)throw Error("Invalid status code range");let n=o.charAt(0);if(!n)throw Error(`Invalid response status code: ${o}`);return n===t}))throw new oD("Response failed with retryable status code",l);return l}catch(e){if(e instanceof oD||t.retryConnectionErrors&&(oa(e)||os(e)))throw e;throw new ow("Permanent error",{cause:e})}}}let ok=RegExp("^[0-9]xx$","i");async function oU(e,t){let{maxElapsedTime:n,initialInterval:i,exponent:r,maxInterval:o}=t,l=Date.now(),s=0;for(;;)try{return await e(s)}catch(a){if(a instanceof ow)throw a.cause;if(Date.now()-l>n){if(a instanceof oD)return a.response;throw a}let e=0;a instanceof oD&&(e=oL(a.response)),e<=0&&(e=i*Math.pow(s,r)+1e3*Math.random());let t=Math.min(e,o);await oq(t),s++}}async function ox(e,t,n){let i=0;for(;;)try{return await e(i)}catch(o){if(o instanceof ow)throw o.cause;if(i>=n.maxRetries){if(o instanceof oD)return o.response;throw o}let e=0;o instanceof oD&&(e=oL(o.response)),e<=0&&(e=t.initialInterval*Math.pow(t.exponent,i)*(1-.25*Math.random()));let r=Math.min(e,t.maxInterval);await oq(r),i++}}function oL(e){let t=e.headers.get("retry-after-ms");if(t){let e=Number(t);if(Number.isFinite(e)&&e>=0)return e}let n=e.headers.get("retry-after")||"";if(!n)return 0;let i=Number(n);if(Number.isInteger(i))return 1e3*i;let r=Date.parse(n);if(Number.isInteger(r)){let e=r-Date.now();return e>0?Math.ceil(e):0}return 0}async function oq(e){return new Promise(t=>setTimeout(t,e))}let oH="u"<typeof globalThis?null:globalThis,oF="object"==typeof oH&&null!=oH&&"importScripts"in oH&&"function"==typeof oH.importScripts||"u">typeof navigator&&"serviceWorker"in navigator||"object"==typeof window&&void 0!==window.document;class oj{constructor(e={}){const t=e;"object"==typeof t&&null!=t&&"hooks"in t&&t.hooks instanceof ou?this._hooks=t.hooks:this._hooks=new ou;const n=new on;e.http_client=e.http_client||n;const i=function(e){var t;let n=e.server_url;if(!n){let i=null!=(t=e.server_idx)?t:0;if(i<0||i>=oh.length)throw Error(`Invalid server index ${i}`);n=oh[i]||""}return new URL(of(n)({}))}(e=this._hooks.sdkInit(e));i&&(i.pathname=i.pathname.replace(/\/+$/,"")+"/"),this._baseURL=i,this._httpClient=e.http_client||n,this._options=Object.assign(Object.assign({},function(e){let t=Object.assign({},e),n=rD();return void 0!==n.GOOGLE_GENAI_API_VERSION&&(null!=t.api_version||(t.api_version=n.GOOGLE_GENAI_API_VERSION)),void 0!==n.GOOGLE_GENAI_USER_PROJECT&&(null!=t.user_project||(t.user_project=n.GOOGLE_GENAI_USER_PROJECT)),t}(e)),{hooks:this._hooks}),this._logger=this._options.debug_logger,!this._logger&&rD().GOOGLE_GENAI_DEBUG&&(this._logger=console)}_createRequest(e,t,n){var i,r,o,l,s,a;let u,p,{method:d,path:c,query:m,headers:f,security:h}=t,g=null!=(i=t.baseURL)?i:this._baseURL;if(!g)return od(new rB("No base URL provided for operation"));let _=new URL(g);c?(_.pathname=_.pathname.replace(/\/+$/,"")+"/",!(u=new URL(c,_)).search&&_.search&&(u.search=_.search)):u=_,u.hash="";let E=e=>Object.entries(e).map(([e,t])=>{if(null==t)return;let n=o_(t)?JSON.stringify(t):t;return oA(e,n,{explode:Array.isArray(n),charEncoding:"percent"})}).filter(e=>void 0!==e).join("&"),y=[m||"",E((null==n?void 0:n.extra_query)||{}),E((null==h?void 0:h.queryParams)||{})].reduce((e,t)=>{if(!t)return e;let n=new Set(t.split("&").filter(e=>""!==e).map(e=>{var t;return null!=(t=e.split("=")[0])?t:""}));return[...e.split("&").filter(e=>{var t;return""!==e&&!n.has(null!=(t=e.split("=")[0])?t:"")}),t].join("&")},u.search.slice(1));y&&(u.search=`?${y}`);let v=new Headers(f),A=null==h?void 0:h.basic.username,I=null==h?void 0:h.basic.password;if(null!=A||null!=I){let e=oc((a=[A||"",I||""].join(":"),new TextEncoder().encode(a)));v.set("Authorization",`Basic ${e}`)}for(let[e,t]of new Headers((null==h?void 0:h.headers)||{}))v.set(e,t);let T=v.get("cookie")||"";for(let[e,t]of Object.entries((null==h?void 0:h.cookies)||{}))T+=`; ${e}=${t}`;for(let[e,t]of(T=T.startsWith("; ")?T.slice(2):T,v.set("cookie",T),new Headers(null!=(r=null==n?void 0:n.headers)?r:null==(o=null==n?void 0:n.fetch_options)?void 0:o.headers)))v.set(e,t);oF||v.set(null!=(l=t.uaHeader)?l:"user-agent",null!=(s=t.userAgent)?s:"speakeasy-sdk/typescript 2.4.1-preview.4 internal v1beta @google/genai");let C=t.body,S=Object.fromEntries(Object.entries((null==n?void 0:n.extra_body)||{}).filter(([,e])=>void 0!==e));if(Object.keys(S).length>0){let e,t=new Headers(f).get("content-type")||"";if(!/^(application|text)\/([^+]+\+)*json/.test(t)||"string"!=typeof C&&null!=C)return od(new rB("extra_body can only be merged into JSON object request bodies"));try{e=C?JSON.parse(C):{}}catch(e){return od(new rB("extra_body can only be merged into JSON object request bodies",{cause:e}))}if(!o_(e))return od(new rB("extra_body can only be merged into JSON object request bodies"));C=JSON.stringify(Object.assign(Object.assign({},e),S)),v.delete("content-length")}let O=Object.assign(Object.assign({},null==n?void 0:n.fetch_options),n);(null==O?void 0:O.signal)||null==t.timeout_ms||!(t.timeout_ms>0)||(e.timeout_ms=t.timeout_ms),t.body instanceof ReadableStream&&Object.assign(O,{duplex:"half"});try{p=this._hooks.beforeCreateRequest(e,{url:u,options:Object.assign(Object.assign({},O),{body:null!=C?C:null,headers:v,method:d})})}catch(e){return od(new rj("Create request hook failed to execute",{cause:e}))}return op(new Request(p.url,p.options))}async _do(e,t){let{context:n,isErrorStatusCode:i}=t,r=n.timeout_ms;return oG(async()=>{var t;let o=e.clone(),l=o;if(null!=r&&r>0){let e=AbortSignal.timeout(r),n=null!=(t=function(...e){let t=[];for(let n of e)n&&t.push(n);switch(t.length){case 0:case 1:return t[0]||null;default:if("any"in AbortSignal&&"function"==typeof AbortSignal.any)return AbortSignal.any(t);var n=t;let i=new AbortController,r=i.signal;if(!n.length)return i.signal;if(1===n.length)return n[0]||i.signal;for(let e of n)if(e.aborted)return e;function o(){i.abort(this.reason),function(){for(let e of l){let t=e.deref();t&&t.removeEventListener("abort",o)}}()}let l=[];for(let e of n)l.push(new WeakRef(e)),e.addEventListener("abort",o);return r}}(o.signal,e))?t:e;l=new Request(o,{signal:n})}let s=await this._hooks.beforeRequest(n,l);await oV(this._logger,s).catch(e=>{var t;return null==(t=this._logger)?void 0:t.log("Failed to log request:",e)});let a=await this._httpClient.request(s);try{if(i(a.status)){let e=await this._hooks.afterError(n,a,null);if(e.error)throw e.error;a=e.response||a}else a=await this._hooks.afterSuccess(n,a)}finally{await oJ(this._logger,a,s).catch(e=>{var t;return null==(t=this._logger)?void 0:t.log("Failed to log response:",e)})}return a},{config:t.retryConfig,statusCodes:t.retryCodes}).then(e=>op(e),e=>{switch(!0){case function(e){if("object"!=typeof e||null==e)return!1;let t="name"in e&&"AbortError"===e.name,n="code"in e&&20===e.code,i="code"in e&&"string"==typeof e.code&&"econnaborted"===e.code.toLowerCase();return t||n||i}(e):return od(new rX("Request aborted by client",{cause:e}));case oa(e):return od(new rV("Request timed out",{cause:e}));case os(e):return od(new rJ("Unable to make request",{cause:e}));default:return od(new rj("Unexpected HTTP client error",{cause:e}))}})}}let oB=/^(application|text)\/([^+]+\+)*json.*/,oX=/^(application|text)\/([^+]+\+)*(jsonl|x-ndjson)\b.*/;async function oV(e,t){if(!e)return;let n=t.headers.get("content-type"),i=(null==n?void 0:n.split(";")[0])||"";for(let[n,i]of(e.group(`> Request: ${t.method} ${t.url}`),e.group("Headers:"),t.headers.entries()))e.log(`${n}: ${i}`);switch(e.groupEnd(),e.group("Body:"),!0){case oB.test(i):e.log(await t.clone().json());break;case i.startsWith("text/"):e.log(await t.clone().text());break;case"multipart/form-data"===i:for(let[n,i]of(await t.clone().formData())){let t=i instanceof Blob?"<Blob>":i;e.log(`${n}: ${t}`)}break;default:e.log(`<${n}>`)}e.groupEnd(),e.groupEnd()}async function oJ(e,t,n){if(!e)return;let i=t.headers.get("content-type"),r=(null==i?void 0:i.split(";")[0])||"";for(let[i,r]of(e.group(`< Response: ${n.method} ${n.url}`),e.log("Status Code:",t.status,t.statusText),e.group("Headers:"),t.headers.entries()))e.log(`${i}: ${r}`);switch(e.groupEnd(),e.group("Body:"),!0){case or(t,"application/json")||oB.test(r)&&!oX.test(r):e.log(await t.clone().json());break;case or(t,"application/jsonl")||oX.test(r):case or(t,"text/event-stream"):e.log(`<${i}>`);break;case or(t,"text/*"):e.log(await t.clone().text());break;case or(t,"multipart/form-data"):for(let[n,i]of(await t.clone().formData())){let t=i instanceof Blob?"<Blob>":i;e.log(`${n}: ${t}`)}break;default:e.log(`<${i}>`)}e.groupEnd(),e.groupEnd()}class oY extends rY{constructor(e,t){e&&(e+=": "),e+=`Status ${t.response.status}`;const n=t.response.headers.get("content-type")||'""';"application/json"!==n&&(e+=` Content-Type ${n.includes(" ")?`"${n}"`:n}`);const i=t.body||'""';e+=i.length>100?"\n":". ";let r=i;if(i.length>1e4){const e=i.substring(0,1e4),t=i.length-1e4;r=`${e}...and ${t} more chars`}e+=`Body: ${r}`,super(e=e.trim(),t),this.name="GoogleGenAiDefaultError"}}function o$(e){try{return JSON.parse(e)}catch(t){return e}}class oK extends ReadableStream{constructor(e,t,n){var i;const r=e.getReader();let o=new Uint8Array(4096),l=0,s=0;const a={eventId:void 0},u=null==(i=null==n?void 0:n.dataRequired)||i;super({async pull(e){try{for(;;){let n=function(e,t,n){for(let i=n;i<t;i++)if(13===e[i]||10===e[i])for(let n of oW){if(i+n.length>t)continue;let r=!0;for(let t=0;t<n.length;t++)if(e[i+t]!==n[t]){r=!1;break}if(r)return{index:i,length:n.length}}return null}(o,l,s);if(!n){s=Math.max(0,l-oz+1);let t=await r.read();if(t.done)return e.close();if(l+t.value.length>o.length){let e=new Uint8Array(Math.max(2*o.length,l+t.value.length));e.set(o.subarray(0,l)),o=e}o.set(t.value,l),l+=t.value.length;continue}let i=o.slice(0,n.index);if(o.copyWithin(0,n.index+n.length,l),l-=n.index+n.length,o.length>4096&&l<=o.length>>2){let e=new Uint8Array(Math.max(4096,2*l));e.set(o.subarray(0,l)),o=e}s=0;let p=function(e,t,n,i){let r=new TextDecoder().decode(e).split(/\r\n|\r|\n/),o=[],l={},s=!0;for(let e of r){if(!e||e.startsWith(":"))continue;s=!1;let t=e.indexOf(":"),i=e,r="";t>0&&(i=e.slice(0,t),r=" "===e[t+1]?e.slice(t+2):e.slice(t+1)),"data"===i?o.push(r):"event"===i?l.event=r:"id"!==i||r.includes("\0")?"retry"===i&&/^\d+$/.test(r)&&(l.retry=Number(r)):n.eventId=r}if(!s){if(l.id=n.eventId,o.length)l.data=o.join("\n");else if(i)return;return t(l)}}(i,t,a,u);if(p&&!p.done)return e.enqueue(p.value);if(null==p?void 0:p.done)return await r.cancel("done"),e.close()}}catch(t){e.error(t),await r.cancel(t)}},cancel:e=>r.cancel(e)})}[Symbol.asyncIterator](e){let t=ReadableStream.prototype[Symbol.asyncIterator];if("function"==typeof t)return t.call(this,e);let n=this.getReader(),i={next:async()=>{let e=await n.read();return e.done?(n.releaseLock(),{done:!0,value:void 0}):{done:!1,value:e.value}},throw:async e=>(await n.cancel(e),n.releaseLock(),{done:!0,value:void 0}),return:async()=>(await n.cancel("done"),n.releaseLock(),{done:!0,value:void 0}),[Symbol.asyncIterator](){return this}},r=Symbol.asyncDispose;return r&&(i[r]=async()=>{var e;await (null==(e=i.return)?void 0:e.call(i))}),i}values(e){return this[Symbol.asyncIterator](e)}}let oW=[[13,10,13,10],[13,10,13],[13,10,10],[13,13,10],[10,13,10],[13,13],[10,13],[10,10]],oz=oW.reduce((e,t)=>Math.max(e,t.length),0),oZ={jsonl:"application/jsonl",json:"application/json",text:"text/plain",bytes:"application/octet-stream",stream:"application/octet-stream",sse:"text/event-stream",nil:"*",fail:"*"};function oQ(e,t,n){return Object.assign(Object.assign({},n),{err:!0,enc:"json",codes:e,errorClass:t})}function o0(e,t){return Object.assign(Object.assign({},t),{enc:"json",codes:e})}function o1(e,t,n){return Object.assign(Object.assign(Object.assign({},n),{enc:"sse",codes:e}),t?{sse:t}:{})}function o4(e,t){return Object.assign(Object.assign({},t),{enc:"nil",codes:e})}function o2(e){return{enc:"fail",codes:e}}function o5(...e){return async function(t,n,i){let r,o,l;for(let n of e){let{codes:e}=n,i="ctype"in n?n.ctype:oZ[n.enc];if(i&&ol(t,e)&&or(t,i)||!i&&ol(t,e)){o=n;break}}if(!o)return[{ok:!1,error:new oY("Unexpected Status or Content-Type",{response:t,request:n,body:await t.text().catch(()=>"")})},r];let s=o.enc,a="";switch(s){case"json":a=await t.text();try{r=JSON.parse(a)}catch(e){if(!("err"in o))throw e;r=a}break;case"jsonl":case"stream":r=t.body;break;case"bytes":r=new Uint8Array(await t.arrayBuffer());break;case"text":case"fail":r=a=await t.text();break;case"sse":if(t.body){let e="sse"in o&&o.sse||{};r=function(e,t={}){var n,i;let r=!0===t.flattened,o=null!=(n=t.sentinel)?n:"";return new oK(e,e=>""!==o&&e.data===o?{done:!0,value:void 0}:r?{done:!1,value:null==e.data?void 0:o$(e.data)}:{done:!1,value:Object.assign(Object.assign({},e),{data:null==e.data?e.data:o$(e.data)})},{dataRequired:null==(i=t.dataRequired)||i})}(t.body,e)}else r=null;break;case"nil":a=await t.text(),r=void 0;break;default:throw Error(`Unsupported response type: ${s}`)}if("fail"===o.enc)return[{ok:!1,error:new oY("API error occurred",{request:n,response:t,body:a})},r];let u=o.key||(null==i?void 0:i.resultKey),p=o.hdrs?{headers:function(e){let t={};for(let[n,i]of e.entries())t[n]=i.split(o3);return t}(t.headers)}:null;return(l="err"in o?Object.assign(Object.assign(Object.assign({},null==i?void 0:i.extraFields),p),o_(r)?r:null):u?Object.assign(Object.assign(Object.assign({},null==i?void 0:i.extraFields),p),{[u]:r}):o.hdrs?Object.assign(Object.assign(Object.assign({},null==i?void 0:i.extraFields),p),o_(r)?r:null):r,"err"in o)?[{ok:!1,error:o.errorClass?new o.errorClass(l,{request:n,response:t,body:a}):l},r]:[{ok:!0,value:l},r]}}let o3=/, */;class o8 extends Error{constructor(e,t){super(t),this.code=e,this.name="SecurityError"}static incomplete(){return new o8("incomplete","Security requirements not met in order to perform the operation")}static unrecognizedType(e){return new o8("unrecognized_security_type",`Unrecognised security type: ${e}`)}}function o9(e,t){var n,i;return function(...e){let t={basic:{},headers:{},queryParams:{},cookies:{},oauth2:{type:"none"}},n=e.find(e=>e.every(e=>{if(null==e.value)return!1;if("http:basic"===e.type)return null!=e.value.username||null!=e.value.password;if("http:custom"===e.type)return null;if("oauth2:password"===e.type)return"string"==typeof e.value&&!!e.value;if("oauth2:client_credentials"===e.type)return"string"==typeof e.value?!!e.value:null!=e.value.client_id||null!=e.value.client_secret;else if("string"==typeof e.value)return!!e.value;else throw Error(`Unrecognized security type: ${e.type} (value type: ${typeof e.value})`)}));return null==n?null:(n.forEach(e=>{if(null==e.value)return;let{type:n}=e;switch(n){case"apiKey:header":t.headers[e.fieldName]=e.value;break;case"apiKey:query":t.queryParams[e.fieldName]=e.value;break;case"apiKey:cookie":t.cookies[e.fieldName]=e.value;break;case"http:basic":var i,r;i=t,null!=(r=e).value&&(i.basic=r.value);break;case"http:custom":case"oauth2:client_credentials":break;case"http:bearer":case"oauth2":case"oauth2:password":case"openIdConnect":!function(e,t){if("string"!=typeof t.value||!t.value)return;let n=t.value;"bearer "!==n.slice(0,7).toLowerCase()&&(n=`Bearer ${n}`),void 0!==t.fieldName&&(e.headers[t.fieldName]=n)}(t,e);break;default:throw o8.unrecognizedType(n)}}),t)}([{fieldName:"accessToken",type:"http:custom",value:null!=(n=null==e?void 0:e.access_token)?n:rD().GOOGLE_GENAI_ACCESS_TOKEN},{fieldName:"apiKey",type:"http:custom",value:null!=(i=null==e?void 0:e.api_key)?i:rD().GOOGLE_GENAI_API_KEY},{fieldName:"defaultHeaders",type:"http:custom",value:null==e?void 0:e.default_headers}])}async function o6(e){if(null!=e)return"function"==typeof e?e():e}class o7{constructor(e,t){this[tV]="APIPromise",this._promise=e instanceof Promise?e:Promise.resolve(e),this._unwrapped=e instanceof Promise?null:Promise.resolve(e[0]),this._callSource=null!=t?t:null}_getUnwrapped(){var e;return null!=(e=this._unwrapped)?e:this._unwrapped=this._promise.then(([e])=>e)}then(e,t){return this._promise.then(e?([t])=>e(t):void 0,t)}catch(e){return this._getUnwrapped().catch(e)}finally(e){return this._getUnwrapped().finally(e)}$inspect(){return this._promise}asResponse(){var e;return(null!=(e=this._callSource)?e:this._callSource=this._promise.then(([,e])=>e)).then(e=>{if(!e.response)throw Error("APIPromise.asResponse: response unavailable");return e.response})}async withResponse(){let[[e],t]=await Promise.all([this._promise,this.asResponse()]);return{data:e,response:t}}_thenUnwrap(e){var t;let n=this._promise.then(([t,n])=>[e(t),n]);return n.catch(()=>{}),new o7(n,null!=(t=this._callSource)?t:void 0)}}function le(e){let t=e.$inspect(),n=t.then(([e,t])=>{if(!e.ok)throw e.error;return[e.value,t]}),i=t.then(([e,t])=>{var n;if(!e.ok&&!(null==(n=t.response)?void 0:n.ok))throw e.error;return t});return n.catch(()=>{}),i.catch(()=>{}),new o7(n,i)}async function lt(e,t,n,i){var r,o;let l=oI("body",t,{explode:!0}),s={api_version:oT("api_version",null!=n?n:e._options.api_version,{explode:!1,charEncoding:"percent"})},a=of("/{api_version}/agents")(s),u=new Headers(og({"Content-Type":"application/json",Accept:"application/json"})),p=o9(await o6(e._options.security)),d={options:e._options,base_url:null!=(o=null!=(r=null==i?void 0:i.server_url)?r:e._baseURL)?o:"",operation_id:"CreateAgent",o_auth2_scopes:null,resolved_security:p,security_source:e._options.security,retry_config:(null==i?void 0:i.retries)||e._options.retry_config||{strategy:"attempt-count-backoff",backoff:{initialInterval:500,maxInterval:8e3,exponent:2,maxElapsedTime:3e4},retryConnectionErrors:!0,maxRetries:4},retry_codes:(null==i?void 0:i.retry_codes)||["408","409","429","5XX"]},c=e._createRequest(d,{security:p,method:"POST",baseURL:null==i?void 0:i.server_url,path:a,headers:u,body:l,userAgent:e._options.user_agent,timeout_ms:(null==i?void 0:i.timeout_ms)||e._options.timeout_ms||-1},i);if(!c.ok)return[c,{status:"invalid"}];let m=c.value,f=await e._do(m,{context:d,isErrorStatusCode:e=>ol({status:e},["4XX","5XX"]),retryConfig:d.retry_config,retryCodes:d.retry_codes});if(!f.ok)return[f,{status:"request-error",request:m}];let h=f.value,[g]=await o5(o2("4XX"),o2("5XX"),o0("default"))(h,m);return!g.ok,[g,{status:"complete",request:m,response:h}]}async function ln(e,t,n,i){var r,o;let l={api_version:oT("api_version",null!=n?n:e._options.api_version,{explode:!1,charEncoding:"percent"}),id:oT("id",t,{explode:!1,charEncoding:"percent"})},s=of("/{api_version}/agents/{id}")(l),a=new Headers(og({Accept:"application/json"})),u=o9(await o6(e._options.security)),p={options:e._options,base_url:null!=(o=null!=(r=null==i?void 0:i.server_url)?r:e._baseURL)?o:"",operation_id:"DeleteAgent",o_auth2_scopes:null,resolved_security:u,security_source:e._options.security,retry_config:(null==i?void 0:i.retries)||e._options.retry_config||{strategy:"attempt-count-backoff",backoff:{initialInterval:500,maxInterval:8e3,exponent:2,maxElapsedTime:3e4},retryConnectionErrors:!0,maxRetries:4},retry_codes:(null==i?void 0:i.retry_codes)||["408","409","429","5XX"]},d=e._createRequest(p,{security:u,method:"DELETE",baseURL:null==i?void 0:i.server_url,path:s,headers:a,body:null,userAgent:e._options.user_agent,timeout_ms:(null==i?void 0:i.timeout_ms)||e._options.timeout_ms||-1},i);if(!d.ok)return[d,{status:"invalid"}];let c=d.value,m=await e._do(c,{context:p,isErrorStatusCode:e=>ol({status:e},["4XX","5XX"]),retryConfig:p.retry_config,retryCodes:p.retry_codes});if(!m.ok)return[m,{status:"request-error",request:c}];let f=m.value,[h]=await o5(o2("4XX"),o2("5XX"),o0("default"))(f,c);return!h.ok,[h,{status:"complete",request:c,response:f}]}async function li(e,t,n,i){var r,o;let l={api_version:oT("api_version",null!=n?n:e._options.api_version,{explode:!1,charEncoding:"percent"}),id:oT("id",t,{explode:!1,charEncoding:"percent"})},s=of("/{api_version}/agents/{id}")(l),a=new Headers(og({Accept:"application/json"})),u=o9(await o6(e._options.security)),p={options:e._options,base_url:null!=(o=null!=(r=null==i?void 0:i.server_url)?r:e._baseURL)?o:"",operation_id:"GetAgent",o_auth2_scopes:null,resolved_security:u,security_source:e._options.security,retry_config:(null==i?void 0:i.retries)||e._options.retry_config||{strategy:"attempt-count-backoff",backoff:{initialInterval:500,maxInterval:8e3,exponent:2,maxElapsedTime:3e4},retryConnectionErrors:!0,maxRetries:4},retry_codes:(null==i?void 0:i.retry_codes)||["408","409","429","5XX"]},d=e._createRequest(p,{security:u,method:"GET",baseURL:null==i?void 0:i.server_url,path:s,headers:a,body:null,userAgent:e._options.user_agent,timeout_ms:(null==i?void 0:i.timeout_ms)||e._options.timeout_ms||-1},i);if(!d.ok)return[d,{status:"invalid"}];let c=d.value,m=await e._do(c,{context:p,isErrorStatusCode:e=>ol({status:e},["4XX","5XX"]),retryConfig:p.retry_config,retryCodes:p.retry_codes});if(!m.ok)return[m,{status:"request-error",request:c}];let f=m.value,[h]=await o5(o2("4XX"),o2("5XX"),o0("default"))(f,c);return!h.ok,[h,{status:"complete",request:c,response:f}]}async function lr(e,t,n,i,r,o){var l,s,a;let u={api_version:t,page_size:n,page_token:i,parent:r},p={api_version:oT("api_version",null!=(l=null==u?void 0:u.api_version)?l:e._options.api_version,{explode:!1,charEncoding:"percent"})},d=of("/{api_version}/agents")(p),c=oR({page_size:null==u?void 0:u.page_size,page_token:null==u?void 0:u.page_token,parent:null==u?void 0:u.parent}),m=new Headers(og({Accept:"application/json"})),f=o9(await o6(e._options.security)),h={options:e._options,base_url:null!=(a=null!=(s=null==o?void 0:o.server_url)?s:e._baseURL)?a:"",operation_id:"ListAgents",o_auth2_scopes:null,resolved_security:f,security_source:e._options.security,retry_config:(null==o?void 0:o.retries)||e._options.retry_config||{strategy:"attempt-count-backoff",backoff:{initialInterval:500,maxInterval:8e3,exponent:2,maxElapsedTime:3e4},retryConnectionErrors:!0,maxRetries:4},retry_codes:(null==o?void 0:o.retry_codes)||["408","409","429","5XX"]},g=e._createRequest(h,{security:f,method:"GET",baseURL:null==o?void 0:o.server_url,path:d,headers:m,query:c,body:null,userAgent:e._options.user_agent,timeout_ms:(null==o?void 0:o.timeout_ms)||e._options.timeout_ms||-1},o);if(!g.ok)return[g,{status:"invalid"}];let _=g.value,E=await e._do(_,{context:h,isErrorStatusCode:e=>ol({status:e},["4XX","5XX"]),retryConfig:h.retry_config,retryCodes:h.retry_codes});if(!E.ok)return[E,{status:"request-error",request:_}];let y=E.value,[v]=await o5(o2("4XX"),o2("5XX"),o0("default"))(y,_);return!v.ok,[v,{status:"complete",request:_,response:y}]}tV=Symbol.toStringTag;class lo extends oj{list(e,t){var n,i,r;return le((n=null==e?void 0:e.api_version,i=null==e?void 0:e.page_size,r=null==e?void 0:e.page_token,new o7(lr(this,n,i,r,null==e?void 0:e.parent,t))))}create(e,t){let{api_version:n}=e;return le(new o7(lt(this,iL(e,["api_version"]),n,t)))}delete(e,t,n){return le(new o7(ln(this,e,null==t?void 0:t.api_version,n)))}get(e,t,n){return le(new o7(li(this,e,null==t?void 0:t.api_version,n)))}}async function ll(e,t,n,i){var r,o;let l=oI("body",t,{explode:!0}),s={api_version:oT("api_version",null!=n?n:e._options.api_version,{explode:!1,charEncoding:"percent"})},a=of("/{api_version}/credentials")(s),u=new Headers(og({"Content-Type":"application/json",Accept:"application/json"})),p=o9(await o6(e._options.security)),d={options:e._options,base_url:null!=(o=null!=(r=null==i?void 0:i.server_url)?r:e._baseURL)?o:"",operation_id:"CreateCredential",o_auth2_scopes:null,resolved_security:p,security_source:e._options.security,retry_config:(null==i?void 0:i.retries)||e._options.retry_config||{strategy:"attempt-count-backoff",backoff:{initialInterval:500,maxInterval:8e3,exponent:2,maxElapsedTime:3e4},retryConnectionErrors:!0,maxRetries:4},retry_codes:(null==i?void 0:i.retry_codes)||["408","409","429","5XX"]},c=e._createRequest(d,{security:p,method:"POST",baseURL:null==i?void 0:i.server_url,path:a,headers:u,body:l,userAgent:e._options.user_agent,timeout_ms:(null==i?void 0:i.timeout_ms)||e._options.timeout_ms||-1},i);if(!c.ok)return[c,{status:"invalid"}];let m=c.value,f=await e._do(m,{context:d,isErrorStatusCode:e=>ol({status:e},["4XX","5XX"]),retryConfig:d.retry_config,retryCodes:d.retry_codes});if(!f.ok)return[f,{status:"request-error",request:m}];let h=f.value,[g]=await o5(o0(200),o2("4XX"),o2("5XX"))(h,m);return!g.ok,[g,{status:"complete",request:m,response:h}]}async function ls(e,t,n,i){var r,o;let l={api_version:oT("api_version",null!=n?n:e._options.api_version,{explode:!1,charEncoding:"percent"}),id:oT("id",t,{explode:!1,charEncoding:"percent"})},s=of("/{api_version}/credentials/{id}")(l),a=new Headers(og({Accept:"application/json"})),u=o9(await o6(e._options.security)),p={options:e._options,base_url:null!=(o=null!=(r=null==i?void 0:i.server_url)?r:e._baseURL)?o:"",operation_id:"DeleteCredential",o_auth2_scopes:null,resolved_security:u,security_source:e._options.security,retry_config:(null==i?void 0:i.retries)||e._options.retry_config||{strategy:"attempt-count-backoff",backoff:{initialInterval:500,maxInterval:8e3,exponent:2,maxElapsedTime:3e4},retryConnectionErrors:!0,maxRetries:4},retry_codes:(null==i?void 0:i.retry_codes)||["408","409","429","5XX"]},d=e._createRequest(p,{security:u,method:"DELETE",baseURL:null==i?void 0:i.server_url,path:s,headers:a,body:null,userAgent:e._options.user_agent,timeout_ms:(null==i?void 0:i.timeout_ms)||e._options.timeout_ms||-1},i);if(!d.ok)return[d,{status:"invalid"}];let c=d.value,m=await e._do(c,{context:p,isErrorStatusCode:e=>ol({status:e},["4XX","5XX"]),retryConfig:p.retry_config,retryCodes:p.retry_codes});if(!m.ok)return[m,{status:"request-error",request:c}];let f=m.value,[h]=await o5(o0(200),o2("4XX"),o2("5XX"))(f,c);return!h.ok,[h,{status:"complete",request:c,response:f}]}async function la(e,t,n,i){var r,o;let l={api_version:oT("api_version",null!=n?n:e._options.api_version,{explode:!1,charEncoding:"percent"}),id:oT("id",t,{explode:!1,charEncoding:"percent"})},s=of("/{api_version}/credentials/{id}")(l),a=new Headers(og({Accept:"application/json"})),u=o9(await o6(e._options.security)),p={options:e._options,base_url:null!=(o=null!=(r=null==i?void 0:i.server_url)?r:e._baseURL)?o:"",operation_id:"GetCredential",o_auth2_scopes:null,resolved_security:u,security_source:e._options.security,retry_config:(null==i?void 0:i.retries)||e._options.retry_config||{strategy:"attempt-count-backoff",backoff:{initialInterval:500,maxInterval:8e3,exponent:2,maxElapsedTime:3e4},retryConnectionErrors:!0,maxRetries:4},retry_codes:(null==i?void 0:i.retry_codes)||["408","409","429","5XX"]},d=e._createRequest(p,{security:u,method:"GET",baseURL:null==i?void 0:i.server_url,path:s,headers:a,body:null,userAgent:e._options.user_agent,timeout_ms:(null==i?void 0:i.timeout_ms)||e._options.timeout_ms||-1},i);if(!d.ok)return[d,{status:"invalid"}];let c=d.value,m=await e._do(c,{context:p,isErrorStatusCode:e=>ol({status:e},["4XX","5XX"]),retryConfig:p.retry_config,retryCodes:p.retry_codes});if(!m.ok)return[m,{status:"request-error",request:c}];let f=m.value,[h]=await o5(o0(200),o2("4XX"),o2("5XX"))(f,c);return!h.ok,[h,{status:"complete",request:c,response:f}]}async function lu(e,t,n,i,r){var o,l,s;let a={api_version:t,page_size:n,page_token:i},u={api_version:oT("api_version",null!=(o=null==a?void 0:a.api_version)?o:e._options.api_version,{explode:!1,charEncoding:"percent"})},p=of("/{api_version}/credentials")(u),d=oR({page_size:null==a?void 0:a.page_size,page_token:null==a?void 0:a.page_token}),c=new Headers(og({Accept:"application/json"})),m=o9(await o6(e._options.security)),f={options:e._options,base_url:null!=(s=null!=(l=null==r?void 0:r.server_url)?l:e._baseURL)?s:"",operation_id:"ListCredentials",o_auth2_scopes:null,resolved_security:m,security_source:e._options.security,retry_config:(null==r?void 0:r.retries)||e._options.retry_config||{strategy:"attempt-count-backoff",backoff:{initialInterval:500,maxInterval:8e3,exponent:2,maxElapsedTime:3e4},retryConnectionErrors:!0,maxRetries:4},retry_codes:(null==r?void 0:r.retry_codes)||["408","409","429","5XX"]},h=e._createRequest(f,{security:m,method:"GET",baseURL:null==r?void 0:r.server_url,path:p,headers:c,query:d,body:null,userAgent:e._options.user_agent,timeout_ms:(null==r?void 0:r.timeout_ms)||e._options.timeout_ms||-1},r);if(!h.ok)return[h,{status:"invalid"}];let g=h.value,_=await e._do(g,{context:f,isErrorStatusCode:e=>ol({status:e},["4XX","5XX"]),retryConfig:f.retry_config,retryCodes:f.retry_codes});if(!_.ok)return[_,{status:"request-error",request:g}];let E=_.value,[y]=await o5(o0(200),o2("4XX"),o2("5XX"))(E,g);return!y.ok,[y,{status:"complete",request:g,response:E}]}async function lp(e,t,n,i,r,o){var l,s;let a=oI("body",n,{explode:!0}),u={api_version:oT("api_version",null!=i?i:e._options.api_version,{explode:!1,charEncoding:"percent"}),id:oT("id",t,{explode:!1,charEncoding:"percent"})},p=of("/{api_version}/credentials/{id}")(u),d=oR({update_mask:r}),c=new Headers(og({"Content-Type":"application/json",Accept:"application/json"})),m=o9(await o6(e._options.security)),f={options:e._options,base_url:null!=(s=null!=(l=null==o?void 0:o.server_url)?l:e._baseURL)?s:"",operation_id:"UpdateCredential",o_auth2_scopes:null,resolved_security:m,security_source:e._options.security,retry_config:(null==o?void 0:o.retries)||e._options.retry_config||{strategy:"attempt-count-backoff",backoff:{initialInterval:500,maxInterval:8e3,exponent:2,maxElapsedTime:3e4},retryConnectionErrors:!0,maxRetries:4},retry_codes:(null==o?void 0:o.retry_codes)||["408","409","429","5XX"]},h=e._createRequest(f,{security:m,method:"PATCH",baseURL:null==o?void 0:o.server_url,path:p,headers:c,query:d,body:a,userAgent:e._options.user_agent,timeout_ms:(null==o?void 0:o.timeout_ms)||e._options.timeout_ms||-1},o);if(!h.ok)return[h,{status:"invalid"}];let g=h.value,_=await e._do(g,{context:f,isErrorStatusCode:e=>ol({status:e},["4XX","5XX"]),retryConfig:f.retry_config,retryCodes:f.retry_codes});if(!_.ok)return[_,{status:"request-error",request:g}];let E=_.value,[y]=await o5(o0(200),o2("4XX"),o2("5XX"))(E,g);return!y.ok,[y,{status:"complete",request:g,response:E}]}class ld extends oj{list(e,t){var n,i;return le((n=null==e?void 0:e.api_version,i=null==e?void 0:e.page_size,new o7(lu(this,n,i,null==e?void 0:e.page_token,t))))}create(e,t){let{api_version:n}=e;return le(new o7(ll(this,iL(e,["api_version"]),n,t)))}delete(e,t,n){return le(new o7(ls(this,e,null==t?void 0:t.api_version,n)))}get(e,t,n){return le(new o7(la(this,e,null==t?void 0:t.api_version,n)))}update(e,t,n){let{api_version:i,update_mask:r}=t;return le(new o7(lp(this,e,iL(t,["api_version","update_mask"]),i,r,n)))}}async function lc(e,t,n,i){var r,o;let l=oI("body",t,{explode:!0}),s={api_version:oT("api_version",null!=n?n:e._options.api_version,{explode:!1,charEncoding:"percent"})},a=of("/{api_version}/environments")(s),u=new Headers(og({"Content-Type":"application/json",Accept:"application/json"})),p=o9(await o6(e._options.security)),d={options:e._options,base_url:null!=(o=null!=(r=null==i?void 0:i.server_url)?r:e._baseURL)?o:"",operation_id:"CreateEnvironment",o_auth2_scopes:null,resolved_security:p,security_source:e._options.security,retry_config:(null==i?void 0:i.retries)||e._options.retry_config||{strategy:"attempt-count-backoff",backoff:{initialInterval:500,maxInterval:8e3,exponent:2,maxElapsedTime:3e4},retryConnectionErrors:!0,maxRetries:4},retry_codes:(null==i?void 0:i.retry_codes)||["408","409","429","5XX"]},c=e._createRequest(d,{security:p,method:"POST",baseURL:null==i?void 0:i.server_url,path:a,headers:u,body:l,userAgent:e._options.user_agent,timeout_ms:(null==i?void 0:i.timeout_ms)||e._options.timeout_ms||-1},i);if(!c.ok)return[c,{status:"invalid"}];let m=c.value,f=await e._do(m,{context:d,isErrorStatusCode:e=>ol({status:e},["4XX","5XX"]),retryConfig:d.retry_config,retryCodes:d.retry_codes});if(!f.ok)return[f,{status:"request-error",request:m}];let h=f.value,[g]=await o5(o2("4XX"),o2("5XX"),o0("default"))(h,m);return!g.ok,[g,{status:"complete",request:m,response:h}]}async function lm(e,t,n,i){var r,o;let l={api_version:oT("api_version",null!=n?n:e._options.api_version,{explode:!1,charEncoding:"percent"}),id:oT("id",t,{explode:!1,charEncoding:"percent"})},s=of("/{api_version}/environments/{id}")(l),a=new Headers(og({Accept:"application/json"})),u=o9(await o6(e._options.security)),p={options:e._options,base_url:null!=(o=null!=(r=null==i?void 0:i.server_url)?r:e._baseURL)?o:"",operation_id:"DeleteEnvironment",o_auth2_scopes:null,resolved_security:u,security_source:e._options.security,retry_config:(null==i?void 0:i.retries)||e._options.retry_config||{strategy:"attempt-count-backoff",backoff:{initialInterval:500,maxInterval:8e3,exponent:2,maxElapsedTime:3e4},retryConnectionErrors:!0,maxRetries:4},retry_codes:(null==i?void 0:i.retry_codes)||["408","409","429","5XX"]},d=e._createRequest(p,{security:u,method:"DELETE",baseURL:null==i?void 0:i.server_url,path:s,headers:a,body:null,userAgent:e._options.user_agent,timeout_ms:(null==i?void 0:i.timeout_ms)||e._options.timeout_ms||-1},i);if(!d.ok)return[d,{status:"invalid"}];let c=d.value,m=await e._do(c,{context:p,isErrorStatusCode:e=>ol({status:e},["4XX","5XX"]),retryConfig:p.retry_config,retryCodes:p.retry_codes});if(!m.ok)return[m,{status:"request-error",request:c}];let f=m.value,[h]=await o5(o2("4XX"),o2("5XX"),o0("default"))(f,c);return!h.ok,[h,{status:"complete",request:c,response:f}]}async function lf(e,t,n,i){var r,o;let l={api_version:oT("api_version",null!=n?n:e._options.api_version,{explode:!1,charEncoding:"percent"}),id:oT("id",t,{explode:!1,charEncoding:"percent"})},s=of("/{api_version}/environments/{id}")(l),a=new Headers(og({Accept:"application/json"})),u=o9(await o6(e._options.security)),p={options:e._options,base_url:null!=(o=null!=(r=null==i?void 0:i.server_url)?r:e._baseURL)?o:"",operation_id:"GetEnvironment",o_auth2_scopes:null,resolved_security:u,security_source:e._options.security,retry_config:(null==i?void 0:i.retries)||e._options.retry_config||{strategy:"attempt-count-backoff",backoff:{initialInterval:500,maxInterval:8e3,exponent:2,maxElapsedTime:3e4},retryConnectionErrors:!0,maxRetries:4},retry_codes:(null==i?void 0:i.retry_codes)||["408","409","429","5XX"]},d=e._createRequest(p,{security:u,method:"GET",baseURL:null==i?void 0:i.server_url,path:s,headers:a,body:null,userAgent:e._options.user_agent,timeout_ms:(null==i?void 0:i.timeout_ms)||e._options.timeout_ms||-1},i);if(!d.ok)return[d,{status:"invalid"}];let c=d.value,m=await e._do(c,{context:p,isErrorStatusCode:e=>ol({status:e},["4XX","5XX"]),retryConfig:p.retry_config,retryCodes:p.retry_codes});if(!m.ok)return[m,{status:"request-error",request:c}];let f=m.value,[h]=await o5(o2("4XX"),o2("5XX"),o0("default"))(f,c);return!h.ok,[h,{status:"complete",request:c,response:f}]}async function lh(e,t,n,i,r){var o,l,s;let a={api_version:t,page_size:n,page_token:i},u={api_version:oT("api_version",null!=(o=null==a?void 0:a.api_version)?o:e._options.api_version,{explode:!1,charEncoding:"percent"})},p=of("/{api_version}/environments")(u),d=oR({page_size:null==a?void 0:a.page_size,page_token:null==a?void 0:a.page_token}),c=new Headers(og({Accept:"application/json"})),m=o9(await o6(e._options.security)),f={options:e._options,base_url:null!=(s=null!=(l=null==r?void 0:r.server_url)?l:e._baseURL)?s:"",operation_id:"ListEnvironments",o_auth2_scopes:null,resolved_security:m,security_source:e._options.security,retry_config:(null==r?void 0:r.retries)||e._options.retry_config||{strategy:"attempt-count-backoff",backoff:{initialInterval:500,maxInterval:8e3,exponent:2,maxElapsedTime:3e4},retryConnectionErrors:!0,maxRetries:4},retry_codes:(null==r?void 0:r.retry_codes)||["408","409","429","5XX"]},h=e._createRequest(f,{security:m,method:"GET",baseURL:null==r?void 0:r.server_url,path:p,headers:c,query:d,body:null,userAgent:e._options.user_agent,timeout_ms:(null==r?void 0:r.timeout_ms)||e._options.timeout_ms||-1},r);if(!h.ok)return[h,{status:"invalid"}];let g=h.value,_=await e._do(g,{context:f,isErrorStatusCode:e=>ol({status:e},["4XX","5XX"]),retryConfig:f.retry_config,retryCodes:f.retry_codes});if(!_.ok)return[_,{status:"request-error",request:g}];let E=_.value,[y]=await o5(o2("4XX"),o2("5XX"),o0("default"))(E,g);return!y.ok,[y,{status:"complete",request:g,response:E}]}async function lg(e,t,n,i,r,o,l,s){var a,u;let p={api_version:oT("api_version",null!=i?i:e._options.api_version,{explode:!1,charEncoding:"percent"}),environment:oT("environment",t,{explode:!1,charEncoding:"percent"}),path:oT("path",n,{explode:!1,charEncoding:"percentExceptReserved"})},d=of("/{api_version}/environments/{environment}/files/{path}")(p),c=oR({page_size:r,page_token:o,recursive:l}),m=new Headers(og({Accept:"application/json"})),f=o9(await o6(e._options.security)),h={options:e._options,base_url:null!=(u=null!=(a=null==s?void 0:s.server_url)?a:e._baseURL)?u:"",operation_id:"GetEnvironmentFiles",o_auth2_scopes:null,resolved_security:f,security_source:e._options.security,retry_config:(null==s?void 0:s.retries)||e._options.retry_config||{strategy:"attempt-count-backoff",backoff:{initialInterval:500,maxInterval:8e3,exponent:2,maxElapsedTime:3e4},retryConnectionErrors:!0,maxRetries:4},retry_codes:(null==s?void 0:s.retry_codes)||["408","409","429","5XX"]},g=e._createRequest(h,{security:f,method:"GET",baseURL:null==s?void 0:s.server_url,path:d,headers:m,query:c,body:null,userAgent:e._options.user_agent,timeout_ms:(null==s?void 0:s.timeout_ms)||e._options.timeout_ms||-1},s);if(!g.ok)return[g,{status:"invalid"}];let _=g.value,E=await e._do(_,{context:h,isErrorStatusCode:e=>ol({status:e},["4XX","5XX"]),retryConfig:h.retry_config,retryCodes:h.retry_codes});if(!E.ok)return[E,{status:"request-error",request:_}];let y=E.value,[v]=await o5(o0(200),o2("4XX"),o2("5XX"))(y,_);return!v.ok,[v,{status:"complete",request:_,response:y}]}class l_ extends oj{list(e,t,n,i){var r,o,l;return le((r=null==n?void 0:n.api_version,o=null==n?void 0:n.page_size,l=null==n?void 0:n.page_token,new o7(lg(this,e,t,r,o,l,null==n?void 0:n.recursive,i))))}}async function lE(e,t,n,i,r,o,l,s,a,u,p){var d,c;let m={api_version:oT("api_version",null!=s?s:e._options.api_version,{explode:!1,charEncoding:"percent"}),environment:oT("environment",t,{explode:!1,charEncoding:"percent"}),path:oT("path",n,{explode:!1,charEncoding:"percentExceptReserved"})},f=of("/upload/{api_version}/environments/{environment}/files/{path}")(m),h=oR({extract:a,overwrite:u}),g=new Headers(og({Accept:"*/*","X-Goog-Upload-Command":oT("X-Goog-Upload-Command",i,{explode:!1,charEncoding:"none"}),"X-Goog-Upload-Header-Content-Length":oT("X-Goog-Upload-Header-Content-Length",r,{explode:!1,charEncoding:"none"}),"X-Goog-Upload-Header-Content-Type":oT("X-Goog-Upload-Header-Content-Type",o,{explode:!1,charEncoding:"none"}),"X-Goog-Upload-Protocol":oT("X-Goog-Upload-Protocol",l,{explode:!1,charEncoding:"none"})})),_=o9(await o6(e._options.security)),E={options:e._options,base_url:null!=(c=null!=(d=null==p?void 0:p.server_url)?d:e._baseURL)?c:"",operation_id:"StartEnvironmentFileUpload",o_auth2_scopes:null,resolved_security:_,security_source:e._options.security,retry_config:(null==p?void 0:p.retries)||e._options.retry_config||{strategy:"attempt-count-backoff",backoff:{initialInterval:500,maxInterval:8e3,exponent:2,maxElapsedTime:3e4},retryConnectionErrors:!0,maxRetries:4},retry_codes:(null==p?void 0:p.retry_codes)||["408","409","429","5XX"]},y=e._createRequest(E,{security:_,method:"PUT",baseURL:null==p?void 0:p.server_url,path:f,headers:g,query:h,body:null,userAgent:e._options.user_agent,timeout_ms:(null==p?void 0:p.timeout_ms)||e._options.timeout_ms||-1},p);if(!y.ok)return[y,{status:"invalid"}];let v=y.value,A=await e._do(v,{context:E,isErrorStatusCode:e=>ol({status:e},["4XX","5XX"]),retryConfig:E.retry_config,retryCodes:E.retry_codes});if(!A.ok)return[A,{status:"request-error",request:v}];let I=A.value,[T]=await o5(o4(200,{hdrs:!0}),o2("4XX"),o2("5XX"))(I,v,{extraFields:{httpMeta:{response:I,request:v}}});return!T.ok,[T,{status:"complete",request:v,response:I}]}class ly extends oj{startUpload(e,t,n,i){var r,o,l,s,a,u;return le((r=n["X-Goog-Upload-Command"],o=n["X-Goog-Upload-Header-Content-Length"],l=n["X-Goog-Upload-Header-Content-Type"],s=n["X-Goog-Upload-Protocol"],a=n.api_version,u=n.extract,new o7(lE(this,e,t,r,o,l,s,a,u,n.overwrite,i))))}}class lv extends oj{get internal(){var e;return null!=(e=this._internal)?e:this._internal=new ly(this._options)}get files(){var e;return null!=(e=this._files)?e:this._files=new l_(this._options)}listEnvironments(e,t){var n,i;return le((n=null==e?void 0:e.api_version,i=null==e?void 0:e.page_size,new o7(lh(this,n,i,null==e?void 0:e.page_token,t))))}createEnvironment(e,t,n){return le(new o7(lc(this,e,t,n)))}deleteEnvironment(e,t,n){return le(new o7(lm(this,e,null==t?void 0:t.api_version,n)))}getEnvironment(e,t,n){return le(new o7(lf(this,e,null==t?void 0:t.api_version,n)))}}class lA extends rY{constructor(e,t){var n;super((null==(n=e.error)?void 0:n.message)||`API error occurred: ${JSON.stringify(e)}`,t),this.data$=e,this.error=e.error,this.name="CancelInteractionByIdServerError"}}class lI extends rY{constructor(e,t){var n;super((null==(n=e.error)?void 0:n.message)||`API error occurred: ${JSON.stringify(e)}`,t),this.data$=e,this.error=e.error,this.name="CancelInteractionByIdClientError"}}class lT extends rY{constructor(e,t){var n;super((null==(n=e.error)?void 0:n.message)||`API error occurred: ${JSON.stringify(e)}`,t),this.data$=e,this.error=e.error,this.name="CreateInteractionServerError"}}class lC extends rY{constructor(e,t){var n;super((null==(n=e.error)?void 0:n.message)||`API error occurred: ${JSON.stringify(e)}`,t),this.data$=e,this.error=e.error,this.name="CreateInteractionClientError"}}class lS extends rY{constructor(e,t){var n;super((null==(n=e.error)?void 0:n.message)||`API error occurred: ${JSON.stringify(e)}`,t),this.data$=e,this.error=e.error,this.name="DeleteInteractionServerError"}}class lO extends rY{constructor(e,t){var n;super((null==(n=e.error)?void 0:n.message)||`API error occurred: ${JSON.stringify(e)}`,t),this.data$=e,this.error=e.error,this.name="DeleteInteractionClientError"}}class lb extends rY{constructor(e,t){var n;super((null==(n=e.error)?void 0:n.message)||`API error occurred: ${JSON.stringify(e)}`,t),this.data$=e,this.error=e.error,this.name="GetInteractionByIdServerError"}}class lP extends rY{constructor(e,t){var n;super((null==(n=e.error)?void 0:n.message)||`API error occurred: ${JSON.stringify(e)}`,t),this.data$=e,this.error=e.error,this.name="GetInteractionByIdClientError"}}async function lR(e,t,n,i){var r,o;let l={api_version:oT("api_version",null!=n?n:e._options.api_version,{explode:!1,charEncoding:"percent"}),id:oT("id",t,{explode:!1,charEncoding:"percent"})},s=of("/{api_version}/interactions/{id}/cancel")(l),a=new Headers(og({Accept:"application/json"})),u=o9(await o6(e._options.security)),p={options:e._options,base_url:null!=(o=null!=(r=null==i?void 0:i.server_url)?r:e._baseURL)?o:"",operation_id:"cancelInteractionById",o_auth2_scopes:null,resolved_security:u,security_source:e._options.security,retry_config:(null==i?void 0:i.retries)||e._options.retry_config||{strategy:"attempt-count-backoff",backoff:{initialInterval:500,maxInterval:8e3,exponent:2,maxElapsedTime:3e4},retryConnectionErrors:!0,maxRetries:4},retry_codes:(null==i?void 0:i.retry_codes)||["408","409","429","5XX"]},d=e._createRequest(p,{security:u,method:"POST",baseURL:null==i?void 0:i.server_url,path:s,headers:a,body:null,userAgent:e._options.user_agent,timeout_ms:(null==i?void 0:i.timeout_ms)||e._options.timeout_ms||-1},i);if(!d.ok)return[d,{status:"invalid"}];let c=d.value,m=await e._do(c,{context:p,isErrorStatusCode:e=>ol({status:e},["4XX","5XX"]),retryConfig:p.retry_config,retryCodes:p.retry_codes});if(!m.ok)return[m,{status:"request-error",request:c}];let f=m.value,[h]=await o5(o0(200),oQ("4XX",lI),oQ("5XX",lA))(f,c,{extraFields:{httpMeta:{response:f,request:c}}});return!h.ok,[h,{status:"complete",request:c,response:f}]}async function lN(e,t,n,i){var r,o,l,s;let a={body:t,api_version:n},u=oI("body",a.body,{explode:!0}),p={api_version:oT("api_version",null!=(r=a.api_version)?r:e._options.api_version,{explode:!1,charEncoding:"percent"})},d=of("/{api_version}/interactions")(p),c=new Headers(og({"Content-Type":"application/json",Accept:(null==(o=null==a?void 0:a.body)?void 0:o.stream)?"text/event-stream":"application/json"})),m=o9(await o6(e._options.security)),f={options:e._options,base_url:null!=(s=null!=(l=null==i?void 0:i.server_url)?l:e._baseURL)?s:"",operation_id:"CreateInteraction",o_auth2_scopes:null,resolved_security:m,security_source:e._options.security,retry_config:(null==i?void 0:i.retries)||e._options.retry_config||{strategy:"attempt-count-backoff",backoff:{initialInterval:500,maxInterval:8e3,exponent:2,maxElapsedTime:3e4},retryConnectionErrors:!0,maxRetries:4},retry_codes:(null==i?void 0:i.retry_codes)||["408","409","429","5XX"]},h=e._createRequest(f,{security:m,method:"POST",baseURL:null==i?void 0:i.server_url,path:d,headers:c,body:u,userAgent:e._options.user_agent,timeout_ms:(null==i?void 0:i.timeout_ms)||e._options.timeout_ms||-1},i);if(!h.ok)return[h,{status:"invalid"}];let g=h.value,_=await e._do(g,{context:f,isErrorStatusCode:e=>ol({status:e},["4XX","5XX"]),retryConfig:f.retry_config,retryCodes:f.retry_codes});if(!_.ok)return[_,{status:"request-error",request:g}];let E=_.value,[y]=await o5(o0(200),o1(200,{sentinel:"[DONE]",flattened:!0}),oQ("4XX",lC),oQ("5XX",lT))(E,g,{extraFields:{httpMeta:{response:E,request:g}}});return!y.ok,[y,{status:"complete",request:g,response:E}]}async function lw(e,t,n,i){var r,o;let l={api_version:oT("api_version",null!=n?n:e._options.api_version,{explode:!1,charEncoding:"percent"}),id:oT("id",t,{explode:!1,charEncoding:"percent"})},s=of("/{api_version}/interactions/{id}")(l),a=new Headers(og({Accept:"application/json"})),u=o9(await o6(e._options.security)),p={options:e._options,base_url:null!=(o=null!=(r=null==i?void 0:i.server_url)?r:e._baseURL)?o:"",operation_id:"deleteInteraction",o_auth2_scopes:null,resolved_security:u,security_source:e._options.security,retry_config:(null==i?void 0:i.retries)||e._options.retry_config||{strategy:"attempt-count-backoff",backoff:{initialInterval:500,maxInterval:8e3,exponent:2,maxElapsedTime:3e4},retryConnectionErrors:!0,maxRetries:4},retry_codes:(null==i?void 0:i.retry_codes)||["408","409","429","5XX"]},d=e._createRequest(p,{security:u,method:"DELETE",baseURL:null==i?void 0:i.server_url,path:s,headers:a,body:null,userAgent:e._options.user_agent,timeout_ms:(null==i?void 0:i.timeout_ms)||e._options.timeout_ms||-1},i);if(!d.ok)return[d,{status:"invalid"}];let c=d.value,m=await e._do(c,{context:p,isErrorStatusCode:e=>ol({status:e},["4XX","5XX"]),retryConfig:p.retry_config,retryCodes:p.retry_codes});if(!m.ok)return[m,{status:"request-error",request:c}];let f=m.value,[h]=await o5(o4(200),oQ("4XX",lO),oQ("5XX",lS))(f,c,{extraFields:{httpMeta:{response:f,request:c}}});return!h.ok,[h,{status:"complete",request:c,response:f}]}async function lD(e,t,n,i,r,o,l){var s,a,u;let p={id:t,api_version:n,include_input:i,last_event_id:r,stream:o},d={api_version:oT("api_version",null!=(s=p.api_version)?s:e._options.api_version,{explode:!1,charEncoding:"percent"}),id:oT("id",p.id,{explode:!1,charEncoding:"percent"})},c=of("/{api_version}/interactions/{id}")(d),m=oR({include_input:p.include_input,last_event_id:p.last_event_id,stream:p.stream}),f=new Headers(og({Accept:(null==p?void 0:p.stream)?"text/event-stream":"application/json"})),h=o9(await o6(e._options.security)),g={options:e._options,base_url:null!=(u=null!=(a=null==l?void 0:l.server_url)?a:e._baseURL)?u:"",operation_id:"getInteractionById",o_auth2_scopes:null,resolved_security:h,security_source:e._options.security,retry_config:(null==l?void 0:l.retries)||e._options.retry_config||{strategy:"attempt-count-backoff",backoff:{initialInterval:500,maxInterval:8e3,exponent:2,maxElapsedTime:3e4},retryConnectionErrors:!0,maxRetries:4},retry_codes:(null==l?void 0:l.retry_codes)||["408","409","429","5XX"]},_=e._createRequest(g,{security:h,method:"GET",baseURL:null==l?void 0:l.server_url,path:c,headers:f,query:m,body:null,userAgent:e._options.user_agent,timeout_ms:(null==l?void 0:l.timeout_ms)||e._options.timeout_ms||-1},l);if(!_.ok)return[_,{status:"invalid"}];let E=_.value,y=await e._do(E,{context:g,isErrorStatusCode:e=>ol({status:e},["4XX","5XX"]),retryConfig:g.retry_config,retryCodes:g.retry_codes});if(!y.ok)return[y,{status:"request-error",request:E}];let v=y.value,[A]=await o5(o0(200),o1(200,{sentinel:"[DONE]",flattened:!0}),oQ("4XX",lP),oQ("5XX",lb))(v,E,{extraFields:{httpMeta:{response:v,request:E}}});return!A.ok,[A,{status:"complete",request:E,response:v}]}class lG extends oj{create(e,t){let{api_version:n}=e;return le(new o7(lN(this,iL(e,["api_version"]),n,t)))}delete(e,t,n){return le(new o7(lw(this,e,null==t?void 0:t.api_version,n)))}get(e,t,n){var i,r,o;return le((i=null==t?void 0:t.api_version,r=null==t?void 0:t.include_input,o=null==t?void 0:t.last_event_id,new o7(lD(this,e,i,r,o,null==t?void 0:t.stream,n))))}cancel(e,t,n){return le(new o7(lR(this,e,null==t?void 0:t.api_version,n)))}}async function lM(e,t,n,i){var r,o;let l=oI("body",t,{explode:!0}),s={api_version:oT("api_version",null!=n?n:e._options.api_version,{explode:!1,charEncoding:"percent"})},a=of("/{api_version}/triggers")(s),u=new Headers(og({"Content-Type":"application/json",Accept:"application/json"})),p=o9(await o6(e._options.security)),d={options:e._options,base_url:null!=(o=null!=(r=null==i?void 0:i.server_url)?r:e._baseURL)?o:"",operation_id:"CreateTrigger",o_auth2_scopes:null,resolved_security:p,security_source:e._options.security,retry_config:(null==i?void 0:i.retries)||e._options.retry_config||{strategy:"attempt-count-backoff",backoff:{initialInterval:500,maxInterval:8e3,exponent:2,maxElapsedTime:3e4},retryConnectionErrors:!0,maxRetries:4},retry_codes:(null==i?void 0:i.retry_codes)||["408","409","429","5XX"]},c=e._createRequest(d,{security:p,method:"POST",baseURL:null==i?void 0:i.server_url,path:a,headers:u,body:l,userAgent:e._options.user_agent,timeout_ms:(null==i?void 0:i.timeout_ms)||e._options.timeout_ms||-1},i);if(!c.ok)return[c,{status:"invalid"}];let m=c.value,f=await e._do(m,{context:d,isErrorStatusCode:e=>ol({status:e},["4XX","5XX"]),retryConfig:d.retry_config,retryCodes:d.retry_codes});if(!f.ok)return[f,{status:"request-error",request:m}];let h=f.value,[g]=await o5(o0(200),o2("4XX"),o2("5XX"))(h,m);return!g.ok,[g,{status:"complete",request:m,response:h}]}async function lk(e,t,n,i){var r,o;let l={api_version:oT("api_version",null!=n?n:e._options.api_version,{explode:!1,charEncoding:"percent"}),id:oT("id",t,{explode:!1,charEncoding:"percent"})},s=of("/{api_version}/triggers/{id}")(l),a=new Headers(og({Accept:"application/json"})),u=o9(await o6(e._options.security)),p={options:e._options,base_url:null!=(o=null!=(r=null==i?void 0:i.server_url)?r:e._baseURL)?o:"",operation_id:"DeleteTrigger",o_auth2_scopes:null,resolved_security:u,security_source:e._options.security,retry_config:(null==i?void 0:i.retries)||e._options.retry_config||{strategy:"attempt-count-backoff",backoff:{initialInterval:500,maxInterval:8e3,exponent:2,maxElapsedTime:3e4},retryConnectionErrors:!0,maxRetries:4},retry_codes:(null==i?void 0:i.retry_codes)||["408","409","429","5XX"]},d=e._createRequest(p,{security:u,method:"DELETE",baseURL:null==i?void 0:i.server_url,path:s,headers:a,body:null,userAgent:e._options.user_agent,timeout_ms:(null==i?void 0:i.timeout_ms)||e._options.timeout_ms||-1},i);if(!d.ok)return[d,{status:"invalid"}];let c=d.value,m=await e._do(c,{context:p,isErrorStatusCode:e=>ol({status:e},["4XX","5XX"]),retryConfig:p.retry_config,retryCodes:p.retry_codes});if(!m.ok)return[m,{status:"request-error",request:c}];let f=m.value,[h]=await o5(o0(200),o2("4XX"),o2("5XX"))(f,c);return!h.ok,[h,{status:"complete",request:c,response:f}]}async function lU(e,t,n,i){var r,o;let l={api_version:oT("api_version",null!=n?n:e._options.api_version,{explode:!1,charEncoding:"percent"}),id:oT("id",t,{explode:!1,charEncoding:"percent"})},s=of("/{api_version}/triggers/{id}")(l),a=new Headers(og({Accept:"application/json"})),u=o9(await o6(e._options.security)),p={options:e._options,base_url:null!=(o=null!=(r=null==i?void 0:i.server_url)?r:e._baseURL)?o:"",operation_id:"GetTrigger",o_auth2_scopes:null,resolved_security:u,security_source:e._options.security,retry_config:(null==i?void 0:i.retries)||e._options.retry_config||{strategy:"attempt-count-backoff",backoff:{initialInterval:500,maxInterval:8e3,exponent:2,maxElapsedTime:3e4},retryConnectionErrors:!0,maxRetries:4},retry_codes:(null==i?void 0:i.retry_codes)||["408","409","429","5XX"]},d=e._createRequest(p,{security:u,method:"GET",baseURL:null==i?void 0:i.server_url,path:s,headers:a,body:null,userAgent:e._options.user_agent,timeout_ms:(null==i?void 0:i.timeout_ms)||e._options.timeout_ms||-1},i);if(!d.ok)return[d,{status:"invalid"}];let c=d.value,m=await e._do(c,{context:p,isErrorStatusCode:e=>ol({status:e},["4XX","5XX"]),retryConfig:p.retry_config,retryCodes:p.retry_codes});if(!m.ok)return[m,{status:"request-error",request:c}];let f=m.value,[h]=await o5(o0(200),o2("4XX"),o2("5XX"))(f,c);return!h.ok,[h,{status:"complete",request:c,response:f}]}async function lx(e,t,n,i,r,o){var l,s;let a={api_version:oT("api_version",null!=n?n:e._options.api_version,{explode:!1,charEncoding:"percent"}),trigger_id:oT("trigger_id",t,{explode:!1,charEncoding:"percent"})},u=of("/{api_version}/triggers/{trigger_id}/executions")(a),p=oR({page_size:i,page_token:r}),d=new Headers(og({Accept:"application/json"})),c=o9(await o6(e._options.security)),m={options:e._options,base_url:null!=(s=null!=(l=null==o?void 0:o.server_url)?l:e._baseURL)?s:"",operation_id:"ListTriggerExecutions",o_auth2_scopes:null,resolved_security:c,security_source:e._options.security,retry_config:(null==o?void 0:o.retries)||e._options.retry_config||{strategy:"attempt-count-backoff",backoff:{initialInterval:500,maxInterval:8e3,exponent:2,maxElapsedTime:3e4},retryConnectionErrors:!0,maxRetries:4},retry_codes:(null==o?void 0:o.retry_codes)||["408","409","429","5XX"]},f=e._createRequest(m,{security:c,method:"GET",baseURL:null==o?void 0:o.server_url,path:u,headers:d,query:p,body:null,userAgent:e._options.user_agent,timeout_ms:(null==o?void 0:o.timeout_ms)||e._options.timeout_ms||-1},o);if(!f.ok)return[f,{status:"invalid"}];let h=f.value,g=await e._do(h,{context:m,isErrorStatusCode:e=>ol({status:e},["4XX","5XX"]),retryConfig:m.retry_config,retryCodes:m.retry_codes});if(!g.ok)return[g,{status:"request-error",request:h}];let _=g.value,[E]=await o5(o0(200),o2("4XX"),o2("5XX"))(_,h);return!E.ok,[E,{status:"complete",request:h,response:_}]}async function lL(e,t,n,i,r,o){var l,s,a;let u={api_version:t,filter:n,page_size:i,page_token:r},p={api_version:oT("api_version",null!=(l=null==u?void 0:u.api_version)?l:e._options.api_version,{explode:!1,charEncoding:"percent"})},d=of("/{api_version}/triggers")(p),c=oR({filter:null==u?void 0:u.filter,page_size:null==u?void 0:u.page_size,page_token:null==u?void 0:u.page_token}),m=new Headers(og({Accept:"application/json"})),f=o9(await o6(e._options.security)),h={options:e._options,base_url:null!=(a=null!=(s=null==o?void 0:o.server_url)?s:e._baseURL)?a:"",operation_id:"ListTriggers",o_auth2_scopes:null,resolved_security:f,security_source:e._options.security,retry_config:(null==o?void 0:o.retries)||e._options.retry_config||{strategy:"attempt-count-backoff",backoff:{initialInterval:500,maxInterval:8e3,exponent:2,maxElapsedTime:3e4},retryConnectionErrors:!0,maxRetries:4},retry_codes:(null==o?void 0:o.retry_codes)||["408","409","429","5XX"]},g=e._createRequest(h,{security:f,method:"GET",baseURL:null==o?void 0:o.server_url,path:d,headers:m,query:c,body:null,userAgent:e._options.user_agent,timeout_ms:(null==o?void 0:o.timeout_ms)||e._options.timeout_ms||-1},o);if(!g.ok)return[g,{status:"invalid"}];let _=g.value,E=await e._do(_,{context:h,isErrorStatusCode:e=>ol({status:e},["4XX","5XX"]),retryConfig:h.retry_config,retryCodes:h.retry_codes});if(!E.ok)return[E,{status:"request-error",request:_}];let y=E.value,[v]=await o5(o0(200),o2("4XX"),o2("5XX"))(y,_);return!v.ok,[v,{status:"complete",request:_,response:y}]}async function lq(e,t,n,i){var r,o;let l={api_version:oT("api_version",null!=n?n:e._options.api_version,{explode:!1,charEncoding:"percent"}),trigger_id:oT("trigger_id",t,{explode:!1,charEncoding:"percent"})},s=of("/{api_version}/triggers/{trigger_id}/executions")(l),a=new Headers(og({Accept:"application/json"})),u=o9(await o6(e._options.security)),p={options:e._options,base_url:null!=(o=null!=(r=null==i?void 0:i.server_url)?r:e._baseURL)?o:"",operation_id:"RunTrigger",o_auth2_scopes:null,resolved_security:u,security_source:e._options.security,retry_config:(null==i?void 0:i.retries)||e._options.retry_config||{strategy:"attempt-count-backoff",backoff:{initialInterval:500,maxInterval:8e3,exponent:2,maxElapsedTime:3e4},retryConnectionErrors:!0,maxRetries:4},retry_codes:(null==i?void 0:i.retry_codes)||["408","409","429","5XX"]},d=e._createRequest(p,{security:u,method:"POST",baseURL:null==i?void 0:i.server_url,path:s,headers:a,body:null,userAgent:e._options.user_agent,timeout_ms:(null==i?void 0:i.timeout_ms)||e._options.timeout_ms||-1},i);if(!d.ok)return[d,{status:"invalid"}];let c=d.value,m=await e._do(c,{context:p,isErrorStatusCode:e=>ol({status:e},["4XX","5XX"]),retryConfig:p.retry_config,retryCodes:p.retry_codes});if(!m.ok)return[m,{status:"request-error",request:c}];let f=m.value,[h]=await o5(o0(200),o2("4XX"),o2("5XX"))(f,c);return!h.ok,[h,{status:"complete",request:c,response:f}]}async function lH(e,t,n,i,r){var o,l;let s=oI("body",n,{explode:!0}),a={api_version:oT("api_version",null!=i?i:e._options.api_version,{explode:!1,charEncoding:"percent"}),id:oT("id",t,{explode:!1,charEncoding:"percent"})},u=of("/{api_version}/triggers/{id}")(a),p=new Headers(og({"Content-Type":"application/json",Accept:"application/json"})),d=o9(await o6(e._options.security)),c={options:e._options,base_url:null!=(l=null!=(o=null==r?void 0:r.server_url)?o:e._baseURL)?l:"",operation_id:"UpdateTrigger",o_auth2_scopes:null,resolved_security:d,security_source:e._options.security,retry_config:(null==r?void 0:r.retries)||e._options.retry_config||{strategy:"attempt-count-backoff",backoff:{initialInterval:500,maxInterval:8e3,exponent:2,maxElapsedTime:3e4},retryConnectionErrors:!0,maxRetries:4},retry_codes:(null==r?void 0:r.retry_codes)||["408","409","429","5XX"]},m=e._createRequest(c,{security:d,method:"PATCH",baseURL:null==r?void 0:r.server_url,path:u,headers:p,body:s,userAgent:e._options.user_agent,timeout_ms:(null==r?void 0:r.timeout_ms)||e._options.timeout_ms||-1},r);if(!m.ok)return[m,{status:"invalid"}];let f=m.value,h=await e._do(f,{context:c,isErrorStatusCode:e=>ol({status:e},["4XX","5XX"]),retryConfig:c.retry_config,retryCodes:c.retry_codes});if(!h.ok)return[h,{status:"request-error",request:f}];let g=h.value,[_]=await o5(o0(200),o2("4XX"),o2("5XX"))(g,f);return!_.ok,[_,{status:"complete",request:f,response:g}]}class lF extends oj{list(e,t){var n,i,r;return le((n=null==e?void 0:e.api_version,i=null==e?void 0:e.filter,r=null==e?void 0:e.page_size,new o7(lL(this,n,i,r,null==e?void 0:e.page_token,t))))}create(e,t){let{api_version:n}=e;return le(new o7(lM(this,iL(e,["api_version"]),n,t)))}delete(e,t,n){return le(new o7(lk(this,e,null==t?void 0:t.api_version,n)))}get(e,t,n){return le(new o7(lU(this,e,null==t?void 0:t.api_version,n)))}update(e,t,n){let{api_version:i}=t;return le(new o7(lH(this,e,iL(t,["api_version"]),i,n)))}listExecutions(e,t,n){var i,r;return le((i=null==t?void 0:t.api_version,r=null==t?void 0:t.page_size,new o7(lx(this,e,i,r,null==t?void 0:t.page_token,n))))}run(e,t,n){return le(new o7(lq(this,e,null==t?void 0:t.api_version,n)))}}async function lj(e,t,n,i){var r,o;let l=oI("body",t,{explode:!0}),s={api_version:oT("api_version",null!=n?n:e._options.api_version,{explode:!1,charEncoding:"percent"})},a=of("/{api_version}/webhooks")(s),u=new Headers(og({"Content-Type":"application/json",Accept:"application/json"})),p=o9(await o6(e._options.security)),d={options:e._options,base_url:null!=(o=null!=(r=null==i?void 0:i.server_url)?r:e._baseURL)?o:"",operation_id:"CreateWebhook",o_auth2_scopes:null,resolved_security:p,security_source:e._options.security,retry_config:(null==i?void 0:i.retries)||e._options.retry_config||{strategy:"attempt-count-backoff",backoff:{initialInterval:500,maxInterval:8e3,exponent:2,maxElapsedTime:3e4},retryConnectionErrors:!0,maxRetries:4},retry_codes:(null==i?void 0:i.retry_codes)||["408","409","429","5XX"]},c=e._createRequest(d,{security:p,method:"POST",baseURL:null==i?void 0:i.server_url,path:a,headers:u,body:l,userAgent:e._options.user_agent,timeout_ms:(null==i?void 0:i.timeout_ms)||e._options.timeout_ms||-1},i);if(!c.ok)return[c,{status:"invalid"}];let m=c.value,f=await e._do(m,{context:d,isErrorStatusCode:e=>ol({status:e},["4XX","5XX"]),retryConfig:d.retry_config,retryCodes:d.retry_codes});if(!f.ok)return[f,{status:"request-error",request:m}];let h=f.value,[g]=await o5(o2("4XX"),o2("5XX"),o0("default"))(h,m);return!g.ok,[g,{status:"complete",request:m,response:h}]}async function lB(e,t,n,i){var r,o;let l={api_version:oT("api_version",null!=n?n:e._options.api_version,{explode:!1,charEncoding:"percent"}),id:oT("id",t,{explode:!1,charEncoding:"percent"})},s=of("/{api_version}/webhooks/{id}")(l),a=new Headers(og({Accept:"application/json"})),u=o9(await o6(e._options.security)),p={options:e._options,base_url:null!=(o=null!=(r=null==i?void 0:i.server_url)?r:e._baseURL)?o:"",operation_id:"DeleteWebhook",o_auth2_scopes:null,resolved_security:u,security_source:e._options.security,retry_config:(null==i?void 0:i.retries)||e._options.retry_config||{strategy:"attempt-count-backoff",backoff:{initialInterval:500,maxInterval:8e3,exponent:2,maxElapsedTime:3e4},retryConnectionErrors:!0,maxRetries:4},retry_codes:(null==i?void 0:i.retry_codes)||["408","409","429","5XX"]},d=e._createRequest(p,{security:u,method:"DELETE",baseURL:null==i?void 0:i.server_url,path:s,headers:a,body:null,userAgent:e._options.user_agent,timeout_ms:(null==i?void 0:i.timeout_ms)||e._options.timeout_ms||-1},i);if(!d.ok)return[d,{status:"invalid"}];let c=d.value,m=await e._do(c,{context:p,isErrorStatusCode:e=>ol({status:e},["4XX","5XX"]),retryConfig:p.retry_config,retryCodes:p.retry_codes});if(!m.ok)return[m,{status:"request-error",request:c}];let f=m.value,[h]=await o5(o2("4XX"),o2("5XX"),o0("default"))(f,c);return!h.ok,[h,{status:"complete",request:c,response:f}]}async function lX(e,t,n,i){var r,o;let l={api_version:oT("api_version",null!=n?n:e._options.api_version,{explode:!1,charEncoding:"percent"}),id:oT("id",t,{explode:!1,charEncoding:"percent"})},s=of("/{api_version}/webhooks/{id}")(l),a=new Headers(og({Accept:"application/json"})),u=o9(await o6(e._options.security)),p={options:e._options,base_url:null!=(o=null!=(r=null==i?void 0:i.server_url)?r:e._baseURL)?o:"",operation_id:"GetWebhook",o_auth2_scopes:null,resolved_security:u,security_source:e._options.security,retry_config:(null==i?void 0:i.retries)||e._options.retry_config||{strategy:"attempt-count-backoff",backoff:{initialInterval:500,maxInterval:8e3,exponent:2,maxElapsedTime:3e4},retryConnectionErrors:!0,maxRetries:4},retry_codes:(null==i?void 0:i.retry_codes)||["408","409","429","5XX"]},d=e._createRequest(p,{security:u,method:"GET",baseURL:null==i?void 0:i.server_url,path:s,headers:a,body:null,userAgent:e._options.user_agent,timeout_ms:(null==i?void 0:i.timeout_ms)||e._options.timeout_ms||-1},i);if(!d.ok)return[d,{status:"invalid"}];let c=d.value,m=await e._do(c,{context:p,isErrorStatusCode:e=>ol({status:e},["4XX","5XX"]),retryConfig:p.retry_config,retryCodes:p.retry_codes});if(!m.ok)return[m,{status:"request-error",request:c}];let f=m.value,[h]=await o5(o2("4XX"),o2("5XX"),o0("default"))(f,c);return!h.ok,[h,{status:"complete",request:c,response:f}]}async function lV(e,t,n,i,r){var o,l,s;let a={api_version:t,page_size:n,page_token:i},u={api_version:oT("api_version",null!=(o=null==a?void 0:a.api_version)?o:e._options.api_version,{explode:!1,charEncoding:"percent"})},p=of("/{api_version}/webhooks")(u),d=oR({page_size:null==a?void 0:a.page_size,page_token:null==a?void 0:a.page_token}),c=new Headers(og({Accept:"application/json"})),m=o9(await o6(e._options.security)),f={options:e._options,base_url:null!=(s=null!=(l=null==r?void 0:r.server_url)?l:e._baseURL)?s:"",operation_id:"ListWebhooks",o_auth2_scopes:null,resolved_security:m,security_source:e._options.security,retry_config:(null==r?void 0:r.retries)||e._options.retry_config||{strategy:"attempt-count-backoff",backoff:{initialInterval:500,maxInterval:8e3,exponent:2,maxElapsedTime:3e4},retryConnectionErrors:!0,maxRetries:4},retry_codes:(null==r?void 0:r.retry_codes)||["408","409","429","5XX"]},h=e._createRequest(f,{security:m,method:"GET",baseURL:null==r?void 0:r.server_url,path:p,headers:c,query:d,body:null,userAgent:e._options.user_agent,timeout_ms:(null==r?void 0:r.timeout_ms)||e._options.timeout_ms||-1},r);if(!h.ok)return[h,{status:"invalid"}];let g=h.value,_=await e._do(g,{context:f,isErrorStatusCode:e=>ol({status:e},["4XX","5XX"]),retryConfig:f.retry_config,retryCodes:f.retry_codes});if(!_.ok)return[_,{status:"request-error",request:g}];let E=_.value,[y]=await o5(o2("4XX"),o2("5XX"),o0("default"))(E,g);return!y.ok,[y,{status:"complete",request:g,response:E}]}async function lJ(e,t,n,i,r){var o,l;let s=oI("body",i,{explode:!0}),a={api_version:oT("api_version",null!=n?n:e._options.api_version,{explode:!1,charEncoding:"percent"}),id:oT("id",t,{explode:!1,charEncoding:"percent"})},u=of("/{api_version}/webhooks/{id}:ping")(a),p=new Headers(og({"Content-Type":"application/json",Accept:"application/json"})),d=o9(await o6(e._options.security)),c={options:e._options,base_url:null!=(l=null!=(o=null==r?void 0:r.server_url)?o:e._baseURL)?l:"",operation_id:"PingWebhook",o_auth2_scopes:null,resolved_security:d,security_source:e._options.security,retry_config:(null==r?void 0:r.retries)||e._options.retry_config||{strategy:"attempt-count-backoff",backoff:{initialInterval:500,maxInterval:8e3,exponent:2,maxElapsedTime:3e4},retryConnectionErrors:!0,maxRetries:4},retry_codes:(null==r?void 0:r.retry_codes)||["408","409","429","5XX"]},m=e._createRequest(c,{security:d,method:"POST",baseURL:null==r?void 0:r.server_url,path:u,headers:p,body:s,userAgent:e._options.user_agent,timeout_ms:(null==r?void 0:r.timeout_ms)||e._options.timeout_ms||-1},r);if(!m.ok)return[m,{status:"invalid"}];let f=m.value,h=await e._do(f,{context:c,isErrorStatusCode:e=>ol({status:e},["4XX","5XX"]),retryConfig:c.retry_config,retryCodes:c.retry_codes});if(!h.ok)return[h,{status:"request-error",request:f}];let g=h.value,[_]=await o5(o2("4XX"),o2("5XX"),o0("default"))(g,f);return!_.ok,[_,{status:"complete",request:f,response:g}]}async function lY(e,t,n,i,r){var o,l;let s=oI("body",i,{explode:!0}),a={api_version:oT("api_version",null!=n?n:e._options.api_version,{explode:!1,charEncoding:"percent"}),id:oT("id",t,{explode:!1,charEncoding:"percent"})},u=of("/{api_version}/webhooks/{id}:rotateSigningSecret")(a),p=new Headers(og({"Content-Type":"application/json",Accept:"application/json"})),d=o9(await o6(e._options.security)),c={options:e._options,base_url:null!=(l=null!=(o=null==r?void 0:r.server_url)?o:e._baseURL)?l:"",operation_id:"RotateSigningSecret",o_auth2_scopes:null,resolved_security:d,security_source:e._options.security,retry_config:(null==r?void 0:r.retries)||e._options.retry_config||{strategy:"attempt-count-backoff",backoff:{initialInterval:500,maxInterval:8e3,exponent:2,maxElapsedTime:3e4},retryConnectionErrors:!0,maxRetries:4},retry_codes:(null==r?void 0:r.retry_codes)||["408","409","429","5XX"]},m=e._createRequest(c,{security:d,method:"POST",baseURL:null==r?void 0:r.server_url,path:u,headers:p,body:s,userAgent:e._options.user_agent,timeout_ms:(null==r?void 0:r.timeout_ms)||e._options.timeout_ms||-1},r);if(!m.ok)return[m,{status:"invalid"}];let f=m.value,h=await e._do(f,{context:c,isErrorStatusCode:e=>ol({status:e},["4XX","5XX"]),retryConfig:c.retry_config,retryCodes:c.retry_codes});if(!h.ok)return[h,{status:"request-error",request:f}];let g=h.value,[_]=await o5(o2("4XX"),o2("5XX"),o0("default"))(g,f);return!_.ok,[_,{status:"complete",request:f,response:g}]}async function l$(e,t,n,i,r,o){var l,s;let a=oI("body",r,{explode:!0}),u={api_version:oT("api_version",null!=n?n:e._options.api_version,{explode:!1,charEncoding:"percent"}),id:oT("id",t,{explode:!1,charEncoding:"percent"})},p=of("/{api_version}/webhooks/{id}")(u),d=oR({update_mask:i}),c=new Headers(og({"Content-Type":"application/json",Accept:"application/json"})),m=o9(await o6(e._options.security)),f={options:e._options,base_url:null!=(s=null!=(l=null==o?void 0:o.server_url)?l:e._baseURL)?s:"",operation_id:"UpdateWebhook",o_auth2_scopes:null,resolved_security:m,security_source:e._options.security,retry_config:(null==o?void 0:o.retries)||e._options.retry_config||{strategy:"attempt-count-backoff",backoff:{initialInterval:500,maxInterval:8e3,exponent:2,maxElapsedTime:3e4},retryConnectionErrors:!0,maxRetries:4},retry_codes:(null==o?void 0:o.retry_codes)||["408","409","429","5XX"]},h=e._createRequest(f,{security:m,method:"PATCH",baseURL:null==o?void 0:o.server_url,path:p,headers:c,query:d,body:a,userAgent:e._options.user_agent,timeout_ms:(null==o?void 0:o.timeout_ms)||e._options.timeout_ms||-1},o);if(!h.ok)return[h,{status:"invalid"}];let g=h.value,_=await e._do(g,{context:f,isErrorStatusCode:e=>ol({status:e},["4XX","5XX"]),retryConfig:f.retry_config,retryCodes:f.retry_codes});if(!_.ok)return[_,{status:"request-error",request:g}];let E=_.value,[y]=await o5(o2("4XX"),o2("5XX"),o0("default"))(E,g);return!y.ok,[y,{status:"complete",request:g,response:E}]}class lK extends oj{list(e,t){var n,i;return le((n=null==e?void 0:e.api_version,i=null==e?void 0:e.page_size,new o7(lV(this,n,i,null==e?void 0:e.page_token,t))))}create(e,t){let{api_version:n}=e;return le(new o7(lj(this,iL(e,["api_version"]),n,t)))}delete(e,t,n){return le(new o7(lB(this,e,null==t?void 0:t.api_version,n)))}get(e,t,n){return le(new o7(lX(this,e,null==t?void 0:t.api_version,n)))}update(e,t,n){let i=null!=t?t:{},{api_version:r,update_mask:o}=i,l=iL(i,["api_version","update_mask"]);return le(new o7(l$(this,e,r,o,void 0===t||0===Object.keys(l).length?void 0:l,n)))}ping(e,t,n,i){return le(new o7(lJ(this,e,t,n,i)))}rotateSigningSecret(e,t,n,i){return le(new o7(lY(this,e,t,n,i)))}}let lW=class extends oj{get environments(){var e;return null!=(e=this._environments)?e:this._environments=new lv(this._options)}get agents(){var e;return null!=(e=this._agents)?e:this._agents=new lo(this._options)}get credentials(){var e;return null!=(e=this._credentials)?e:this._credentials=new ld(this._options)}get interactions(){var e;return null!=(e=this._interactions)?e:this._interactions=new lG(this._options)}get triggers(){var e;return null!=(e=this._triggers)?e:this._triggers=new lF(this._options)}get webhooks(){var e;return null!=(e=this._webhooks)?e:this._webhooks=new lK(this._options)}},lz=new Set(["lyria-3-pro-preview","lyria-3-clip-preview"]);function lZ(e,t={}){var n,i,r,o,l,s,a;let u,p,d,c=t.http_client||null==(n=e.getFetch)?void 0:n.call(e),m=null!=(i=t.http_client)?i:c?new on({fetcher:c}):void 0;return new lW(Object.assign(Object.assign({},t),{http_client:m,api_version:null!=(r=t.api_version)?r:(u=e.getApiVersion().replace(/^\/+|\/+$/g,""),p=e.getProject(),d=e.getLocation(),e.isVertexAI()&&u&&p&&d?`${u}/projects/${encodeURIComponent(p)}/locations/${encodeURIComponent(d)}`:u),security:null!=(o=t.security)?o:new rG({defaultHeaders:Object.assign(Object.assign({},null==(l=e.getDefaultHeaders)?void 0:l.call(e)),null==(s=e.getHeaders)?void 0:s.call(e)),getAuthHeaders:t=>e.getAuthHeaders(t)}),server_url:null!=(a=t.server_url)?a:function(e){let t=e.getBaseUrl();if(!t)throw Error("Base URL must be set.");return t.replace(/\/+$/,"")}(e)}))}class lQ{constructor(e){this.parentClient=e}async create(e,t){let{api_version:n}=e,i=iL(e,["api_version"]);return!0===i.stream?l9(await l8(()=>this.getClient(n).interactions.create(Object.assign(Object.assign({},i),{stream:!0,api_version:n}),l2(t,!0)))):l6(await l3(new o7(lN(this.getClient(n),i,n,l2(t)))))}async get(e,t={},n){let{api_version:i,stream:r=!1,last_event_id:o,include_input:l}=null!=t?t:{};return!0===r?l9(await l8(()=>this.getClient(i).interactions.get(e,{stream:r,last_event_id:o,include_input:l,api_version:i},l2(n,!0)))):l6(await l3(new o7(lD(this.getClient(i),e,i,l,o,r,l2(n)))))}async delete(e,t={},n){return l8(()=>this.getClient(null==t?void 0:t.api_version).interactions.delete(e,{api_version:null==t?void 0:t.api_version},l2(n)))}async cancel(e,t={},n){var i;return l6(await l3((i=this.getClient(null==t?void 0:t.api_version),new o7(lR(i,e,null==t?void 0:t.api_version,l2(n))))))}getClient(e){return e?lZ(this.parentClient,{api_version:e}):(null!=this.sdk||(this.sdk=lZ(this.parentClient)),this.sdk)}}class l0{constructor(e){this.parentClient=e}async create(e={},t){let n=null!=e?e:{},{api_version:i}=n,r=iL(n,["api_version"]);return l3(new o7(lt(this.getClient(i),r,i,l2(t))))}async list(e={},t){let{api_version:n,page_size:i,page_token:r,parent:o}=null!=e?e:{};return l3(new o7(lr(this.getClient(n),n,i,r,o,l2(t))))}async get(e,t={},n){var i;return l3((i=this.getClient(null==t?void 0:t.api_version),new o7(li(i,e,null==t?void 0:t.api_version,l2(n)))))}async delete(e,t={},n){var i;return l3((i=this.getClient(null==t?void 0:t.api_version),new o7(ln(i,e,null==t?void 0:t.api_version,l2(n)))))}getClient(e){return e?lZ(this.parentClient,{api_version:e}):(null!=this.sdk||(this.sdk=lZ(this.parentClient)),this.sdk)}}class l1{constructor(e){this.parentClient=e}async create(e,t){let{api_version:n}=e,i=iL(e,["api_version"]);return l3(new o7(lj(this.getClient(),i,n,l2(t))))}async list(e={},t){let{api_version:n,page_size:i,page_token:r}=null!=e?e:{};return l3(new o7(lV(this.getClient(),n,i,r,l2(t))))}async get(e,t={},n){var i;return l3((i=this.getClient(),new o7(lX(i,e,null==t?void 0:t.api_version,l2(n)))))}async update(e,t={},n){let i=null!=t?t:{},{api_version:r,update_mask:o}=i,l=iL(i,["api_version","update_mask"]);return l3(new o7(l$(this.getClient(),e,r,o,l,l2(n))))}async delete(e,t={},n){var i;return l3((i=this.getClient(),new o7(lB(i,e,null==t?void 0:t.api_version,l2(n)))))}async rotateSigningSecret(e,t={},n){let i=null!=t?t:{},{api_version:r}=i,o=iL(i,["api_version"]);return l3(new o7(lY(this.getClient(),e,r,o,l2(n))))}async ping(e,t,n){let{api_version:i,body:r}=null!=t?t:{};return l3(new o7(lJ(this.getClient(),e,i,r,l2(n))))}getClient(){return null!=this.sdk||(this.sdk=lZ(this.parentClient)),this.sdk}}class l4{constructor(e){this.parentClient=e}async create(e,t){let{api_version:n}=e,i=iL(e,["api_version"]);return l3(new o7(lM(this.getClient(n),i,n,l2(t))))}async list(e={},t){let{api_version:n,filter:i,page_size:r,page_token:o}=null!=e?e:{};return l3(new o7(lL(this.getClient(n),n,i,r,o,l2(t))))}async get(e,t={},n){var i;return l3((i=this.getClient(null==t?void 0:t.api_version),new o7(lU(i,e,null==t?void 0:t.api_version,l2(n)))))}async update(e,t,n){let{api_version:i}=t,r=iL(t,["api_version"]);return l3(new o7(lH(this.getClient(i),e,r,i,l2(n))))}async delete(e,t={},n){var i;return l3((i=this.getClient(null==t?void 0:t.api_version),new o7(lk(i,e,null==t?void 0:t.api_version,l2(n)))))}async run(e,t={},n){var i;return l3((i=this.getClient(null==t?void 0:t.api_version),new o7(lq(i,e,null==t?void 0:t.api_version,l2(n)))))}async listExecutions(e,t={},n){let{api_version:i,page_size:r,page_token:o}=null!=t?t:{};return l3(new o7(lx(this.getClient(i),e,i,r,o,l2(n))))}getClient(e){return e?lZ(this.parentClient,{api_version:e}):(null!=this.sdk||(this.sdk=lZ(this.parentClient)),this.sdk)}}function l2(e,t=!1){var n,i,r,o;if(!e&&!t)return;let l=null!=e?e:{},{timeout:s,maxRetries:a,defaultBaseURL:u,query:p,body:d,fetchOptions:c}=l,m=iL(l,["timeout","maxRetries","defaultBaseURL","query","body","fetchOptions"]),f=Object.assign({},m);l7(p)?f.extra_query=p:l5("query",p),l7(d)?f.extra_body=d:l5("body",d);let h=null!=(n=m.fetch_options)?n:c;h&&(f.fetch_options=h);let g=null!=(i=m.server_url)?i:u;g&&(f.server_url=g);let _=null!=(r=m.timeout_ms)?r:s;if(void 0!==_&&(f.timeout_ms=_),void 0!==a&&(f.retries={strategy:"attempt-count-backoff",retryConnectionErrors:!0,maxRetries:a}),t){let e=new Headers(null!=(o=f.headers)?o:null==h?void 0:h.headers);e.set("Accept","text/event-stream"),f.headers=e}return f}function l5(e,t){null!=t&&console.warn(`GoogleGenAI.interactions: request option ${e} is not supported by the Google GenAI interactions bridge and will be ignored.`)}async function l3(e){var t,n;let[i,r]=await e.$inspect();if(!i.ok)throw r9(i.error);return t=i.value,n=r,l7(t)&&"complete"===n.status?Object.assign(Object.assign({},t),{sdkHttpResponse:function(e,t){let n={};for(let[t,i]of e.headers.entries())n[t]=i;return{headers:n,responseInternal:e,json:async()=>t}}(n.response,t)}):t}async function l8(e){try{return await e()}catch(e){throw r9(e)}}function l9(e){return new Proxy(e,{get(t,n){if(n!==Symbol.asyncIterator){let e=Reflect.get(t,n,t);return"function"==typeof e?e.bind(t):e}return function(){let t=e[Symbol.asyncIterator]();return{async next(...e){try{return await t.next(...e)}catch(e){throw r9(e)}},async return(e){if(!t.return)return{done:!0,value:e};try{return await t.return(e)}catch(e){throw r9(e)}},async throw(e){if(!t.throw)throw r9(e);try{return await t.throw(e)}catch(e){throw r9(e)}},[Symbol.asyncIterator](){return this}}}}})}function l6(e){let t=function(e){if(l7(e)){let t;if(Array.isArray(e.steps))return e;if("string"==typeof(t=e.model)&&lz.has(t)){let t=e.outputs;if(Array.isArray(t)){let{outputs:n}=e;return Object.assign(Object.assign({},iL(e,["outputs"])),{steps:[{type:"model_output",content:t}]})}}return Object.assign(Object.assign({},e),{steps:[]})}}(e);return t?function(e){var t,n,i;let r,o,l,s=Object.assign(Object.assign({},i=e),{created:se(i.created),updated:se(i.updated)}),a=null!=(t=s.steps)?t:[],u=[],p=!1;e:for(let e=a.length-1;e>=0;e--){let t=a[e];if("user_input"===t.type)break;if("model_output"!==t.type||!t.content){if(p)break;continue}let i=t.content;for(let e=i.length-1;e>=0;e--){let t=i[e];if("text"===t.type)p=!0,u.push(null!=(n=t.text)?n:"");else if(p)break e}}for(let e=a.length-1;e>=0;e--){let t=a[e];if("user_input"===t.type)break;if("model_output"===t.type&&t.content)for(let e=t.content.length-1;e>=0;e--){let n=t.content[e];"image"!==n.type||r||(r=n),"audio"!==n.type||o||(o=n),"video"!==n.type||l||(l=n)}}let d=u.reverse().join("");return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},s),d&&{output_text:d}),r?{output_image:r}:{}),o?{output_audio:o}:{}),l?{output_video:l}:{})}(t):e}function l7(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function se(e){return e instanceof Date?e.toISOString():e}class st{constructor(e,t){this.resolveClient=e,this.parentClient=t}async list(e,t){var n,i,r,o,l,s;return l3((n=this.resolveClient(e.api_version),i=e.environment,r=e.path,o=e.api_version,l=e.page_size,s=e.page_token,new o7(lg(n,i,r,o,l,s,e.recursive,l2(t)))))}async download(e,t){var n,i;let r=e.environment;if(!r)throw Error("environment is required.");let o=r.startsWith("environments/")?r:`environments/${r}`,l=e.path.replace(/^\/+/,""),s=`${o}/files/${l}`,a=this.parentClient;if(!a||"function"!=typeof a.request)throw Error("apiClient is required to download files.");let u=await a.request({path:s,httpMethod:"GET",queryParams:{alt:"media"},httpOptions:Object.assign(Object.assign({},null==t?void 0:t.httpOptions),{apiVersion:null!=(n=e.api_version)?n:null==(i=null==t?void 0:t.httpOptions)?void 0:i.apiVersion})});if(u&&u.responseInternal&&"function"==typeof u.responseInternal.arrayBuffer)return new Uint8Array(await u.responseInternal.arrayBuffer());throw Error("Unexpected response type from download")}async upload(e,t){var n,i,r,o,l,s,a,u,p,d,c,m,f,h;let g,_,E,y=e.environment;if(!y)throw Error("environment is required.");y.startsWith("environments/");let v=e.path.replace(/^\/+/,""),A=this.parentClient;if(!A||"function"!=typeof A.request)throw Error("apiClient is required to upload files.");let I=0,T=e.mime_type;if("string"==typeof e.file){let t;try{let n=globalThis.require;n&&(t=n("fs").readFileSync(e.file))}catch(e){}if(!t&&void 0!==globalThis.process)try{let r=null!=(i=null==(n=globalThis.process.mainModule)?void 0:n.require)?i:globalThis.require;r&&(t=r("fs").readFileSync(e.file))}catch(e){}if(t)I=(g=new Uint8Array(t.buffer,t.byteOffset,t.byteLength)).byteLength;else throw Error(`Unable to read file from path "${e.file}". File path string inputs are only supported in Node.js environments.`);T||(T=({txt:"text/plain",json:"application/json",js:"text/javascript",mjs:"text/javascript",ts:"text/plain",py:"text/x-python",html:"text/html",htm:"text/html",css:"text/css",csv:"text/csv",xml:"application/xml",png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",webp:"image/webp",svg:"image/svg+xml",pdf:"application/pdf",zip:"application/zip",tar:"application/x-tar",gz:"application/gzip"})[(p=e.file).slice(p.lastIndexOf(".")+1).toLowerCase()])}else if("u">typeof Blob&&e.file instanceof Blob)g=e.file,I=e.file.size,!T&&e.file.type&&(T=e.file.type);else if(e.file instanceof Uint8Array||e.file instanceof ArrayBuffer)I=(g=e.file instanceof ArrayBuffer?new Uint8Array(e.file):e.file).byteLength;else if(void 0!==globalThis.Buffer&&"function"==typeof globalThis.Buffer.isBuffer&&globalThis.Buffer.isBuffer(e.file)){let t=e.file;I=(g=new Uint8Array(t.buffer,t.byteOffset,t.byteLength)).byteLength}else throw Error("Unsupported file type for upload.");T||(T="application/octet-stream");let C=y.startsWith("environments/")?y.replace(/^environments\//,""):y,[S,O]=await (d=this.resolveClient(e.api_version),c=I,m=T,f=e.api_version,h=e.extract,new o7(lE(d,C,v,"start",c,m,"resumable",f,h,e.overwrite,l2(t)))).$inspect();if(!S.ok)throw r9(S.error);let b="complete"===O.status?null!=(l=null==(o=null==(r=O.response)?void 0:r.headers)?void 0:o.get("x-goog-upload-url"))?l:null==(a=null==(s=O.response)?void 0:s.headers)?void 0:a.get("X-Goog-Upload-URL"):void 0;if(!b)throw Error("Failed to get upload URL from upload handshake response.");let P=0,R=g instanceof Blob?g:new Blob([g]);for(;P<I||0===I&&0===P;){let e=Math.min(P+8388608,I),n=R.slice(P,e),i=e>=I,r=i?"upload, finalize":"upload";if(_=await A.request({path:"",body:n,httpMethod:"POST",httpOptions:Object.assign(Object.assign({},null==t?void 0:t.httpOptions),{apiVersion:"",baseUrl:b,headers:Object.assign(Object.assign({},(null==(u=null==t?void 0:t.httpOptions)?void 0:u.headers)||{}),{"X-Goog-Upload-Command":r,"X-Goog-Upload-Offset":`${P}`})})}),P=e,i)break}if(_&&"function"==typeof _.json?E=await _.json():_&&_.responseInternal&&"function"==typeof _.responseInternal.json&&(E=await _.responseInternal.json()),E&&"object"==typeof E){if(Array.isArray(E.files))return E;if(E.name||E.path)return{files:[E]};if(E.file&&"object"==typeof E.file)return{files:[E.file]}}return E}}class sn{constructor(e){this.parentClient=e,this.files=new st(e=>this.getClient(e),this.parentClient)}async create(e,t){let{api_version:n}=e,i=iL(e,["api_version"]);return l3(new o7(lc(this.getClient(n),i,n,l2(t))))}async list(e={},t){let{api_version:n,page_size:i,page_token:r}=null!=e?e:{};return l3(new o7(lh(this.getClient(n),n,i,r,l2(t))))}async get(e,t={},n){var i;return l3((i=this.getClient(null==t?void 0:t.api_version),new o7(lf(i,e,null==t?void 0:t.api_version,l2(n)))))}async delete(e,t={},n){var i;return l3((i=this.getClient(null==t?void 0:t.api_version),new o7(lm(i,e,null==t?void 0:t.api_version,l2(n)))))}getClient(e){return e?lZ(this.parentClient,{api_version:e}):(null!=this.sdk||(this.sdk=lZ(this.parentClient)),this.sdk)}}class si{constructor(e){this.parentClient=e}async create(e,t){let{api_version:n}=e,i=iL(e,["api_version"]);return l3(new o7(ll(this.getClient(n),i,n,l2(t))))}async list(e={},t){let{api_version:n,page_size:i,page_token:r}=null!=e?e:{};return l3(new o7(lu(this.getClient(n),n,i,r,l2(t))))}async get(e,t={},n){var i;return l3((i=this.getClient(null==t?void 0:t.api_version),new o7(la(i,e,null==t?void 0:t.api_version,l2(n)))))}async update(e,t,n){let{api_version:i,update_mask:r}=t,o=iL(t,["api_version","update_mask"]);return l3(new o7(lp(this.getClient(i),e,o,i,r,l2(n))))}async delete(e,t={},n){var i;return l3((i=this.getClient(null==t?void 0:t.api_version),new o7(ls(i,e,null==t?void 0:t.api_version,l2(n)))))}getClient(e){return e?lZ(this.parentClient,{api_version:e}):(null!=this.sdk||(this.sdk=lZ(this.parentClient)),this.sdk)}}function sr(e,t){let n={},i=tz(e,["parts"]);if(null!=i){let e=i;Array.isArray(e)&&(e=e.map(e=>(function(e){let t={},n=tz(e,["mediaResolution"]);if(null!=n&&tW(t,["mediaResolution"],n),void 0!==tz(e,["toolCall"]))throw Error("toolCall parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.");if(void 0!==tz(e,["toolResponse"]))throw Error("toolResponse parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.");let i=tz(e,["audioTranscription"]);null!=i&&tW(t,["audioTranscription"],i);let r=tz(e,["codeExecutionResult"]);null!=r&&tW(t,["codeExecutionResult"],r);let o=tz(e,["executableCode"]);null!=o&&tW(t,["executableCode"],o);let l=tz(e,["fileData"]);null!=l&&tW(t,["fileData"],l);let s=tz(e,["functionCall"]);null!=s&&tW(t,["functionCall"],s);let a=tz(e,["functionResponse"]);null!=a&&tW(t,["functionResponse"],a);let u=tz(e,["inlineData"]);null!=u&&tW(t,["inlineData"],u);let p=tz(e,["text"]);null!=p&&tW(t,["text"],p);let d=tz(e,["thought"]);null!=d&&tW(t,["thought"],d);let c=tz(e,["thoughtSignature"]);null!=c&&tW(t,["thoughtSignature"],c);let m=tz(e,["videoMetadata"]);if(null!=m&&tW(t,["videoMetadata"],m),void 0!==tz(e,["partMetadata"]))throw Error("partMetadata parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.");let f=tz(e,["mediaProcessing"]);return null!=f&&tW(t,["mediaProcessing"],f),t})(e))),tW(n,["parts"],e)}let r=tz(e,["role"]);return null!=r&&tW(n,["role"],r),n}function so(e,t){let n={},i=tz(e,["epochCount"]);null!=i&&tW(n,["epochCount"],i);let r=tz(e,["learningRateMultiplier"]);null!=r&&tW(n,["learningRateMultiplier"],r);let o=tz(e,["adapterSize"]);null!=o&&tW(n,["adapterSize"],o);let l=tz(e,["batchSize"]);null!=l&&tW(n,["batchSize"],l);let s=tz(e,["learningRate"]);null!=s&&tW(n,["learningRate"],s);let a=tz(e,["generationConfig"]);return null!=a&&tW(n,["generationConfig"],function(e){let t={},n=tz(e,["modelConfig"]);null!=n&&tW(t,["modelSelectionConfig"],n);let i=tz(e,["responseJsonSchema"]);null!=i&&tW(t,["responseJsonSchema"],i);let r=tz(e,["audioTranscriptionConfig"]);null!=r&&tW(t,["audioTranscriptionConfig"],r);let o=tz(e,["audioTimestamp"]);null!=o&&tW(t,["audioTimestamp"],o);let l=tz(e,["candidateCount"]);null!=l&&tW(t,["candidateCount"],l);let s=tz(e,["enableAffectiveDialog"]);null!=s&&tW(t,["enableAffectiveDialog"],s);let a=tz(e,["frequencyPenalty"]);null!=a&&tW(t,["frequencyPenalty"],a);let u=tz(e,["logprobs"]);null!=u&&tW(t,["logprobs"],u);let p=tz(e,["maxOutputTokens"]);null!=p&&tW(t,["maxOutputTokens"],p);let d=tz(e,["mediaResolution"]);null!=d&&tW(t,["mediaResolution"],d);let c=tz(e,["presencePenalty"]);null!=c&&tW(t,["presencePenalty"],c);let m=tz(e,["responseFormat"]);if(null!=m){let e=m;Array.isArray(e)&&(e=e.map(e=>e)),tW(t,["responseFormat"],e)}let f=tz(e,["responseLogprobs"]);null!=f&&tW(t,["responseLogprobs"],f);let h=tz(e,["responseMimeType"]);null!=h&&tW(t,["responseMimeType"],h);let g=tz(e,["responseModalities"]);null!=g&&tW(t,["responseModalities"],g);let _=tz(e,["responseSchema"]);null!=_&&tW(t,["responseSchema"],_);let E=tz(e,["routingConfig"]);null!=E&&tW(t,["routingConfig"],E);let y=tz(e,["seed"]);null!=y&&tW(t,["seed"],y);let v=tz(e,["speechConfig"]);null!=v&&tW(t,["speechConfig"],v);let A=tz(e,["stopSequences"]);null!=A&&tW(t,["stopSequences"],A);let I=tz(e,["temperature"]);null!=I&&tW(t,["temperature"],I);let T=tz(e,["thinkingConfig"]);null!=T&&tW(t,["thinkingConfig"],T);let C=tz(e,["topK"]);null!=C&&tW(t,["topK"],C);let S=tz(e,["topP"]);return null!=S&&tW(t,["topP"],S),t}(a)),n}function sl(e,t){let n,i,r,o,l,s,a,u,p,d,c,m,f,h,g,_,E={},y=tz(e,["sdkHttpResponse"]);null!=y&&tW(E,["sdkHttpResponse"],y);let v=tz(e,["name"]);null!=v&&tW(E,["name"],v);let A=tz(e,["state"]);null!=A&&tW(E,["state"],iA(A));let I=tz(e,["createTime"]);null!=I&&tW(E,["createTime"],I);let T=tz(e,["startTime"]);null!=T&&tW(E,["startTime"],T);let C=tz(e,["endTime"]);null!=C&&tW(E,["endTime"],C);let S=tz(e,["updateTime"]);null!=S&&tW(E,["updateTime"],S);let O=tz(e,["error"]);null!=O&&tW(E,["error"],O);let b=tz(e,["description"]);null!=b&&tW(E,["description"],b);let P=tz(e,["baseModel"]);null!=P&&tW(E,["baseModel"],P);let R=tz(e,["tunedModel"]);null!=R&&tW(E,["tunedModel"],R);let N=tz(e,["preTunedModel"]);null!=N&&tW(E,["preTunedModel"],N);let w=tz(e,["supervisedTuningSpec"]);null!=w&&tW(E,["supervisedTuningSpec"],w);let D=tz(e,["preferenceOptimizationSpec"]);null!=D&&tW(E,["preferenceOptimizationSpec"],D);let G=tz(e,["distillationSamplingSpec"]);null!=G&&tW(E,["distillationSamplingSpec"],(n={},null!=(i=tz(G,["promptDatasetUri"]))&&tW(n,["promptDatasetUri"],i),null!=(r=tz(G,["validationDatasetUri"]))&&tW(n,["validationDatasetUri"],r),null!=(o=tz(G,["baseTeacherModel"]))&&tW(n,["baseTeacherModel"],o),null!=(l=tz(G,["tunedTeacherModelSource"]))&&tW(n,["tunedTeacherModelSource"],l),null!=(s=tz(G,["hyperparameters"]))&&tW(n,["hyperparameters"],so(s)),n));let M=tz(e,["distillationSpec"]);null!=M&&tW(E,["distillationSpec"],(a={},null!=(u=tz(M,["baseTeacherModel"]))&&tW(a,["baseTeacherModel"],u),null!=(p=tz(M,["hyperParameters"]))&&tW(a,["hyperParameters"],so(p)),null!=(d=tz(M,["pipelineRootDirectory"]))&&tW(a,["pipelineRootDirectory"],d),null!=(c=tz(M,["promptDatasetUri"]))&&tW(a,["promptDatasetUri"],c),null!=(m=tz(M,["studentModel"]))&&tW(a,["studentModel"],m),null!=(f=tz(M,["trainingDatasetUri"]))&&tW(a,["trainingDatasetUri"],f),null!=(h=tz(M,["tunedTeacherModelSource"]))&&tW(a,["tunedTeacherModelSource"],h),null!=(g=tz(M,["tuningMode"]))&&tW(a,["tuningMode"],g),null!=(_=tz(M,["validationDatasetUri"]))&&tW(a,["validationDatasetUri"],_),a));let k=tz(e,["reinforcementTuningSpec"]);null!=k&&tW(E,["reinforcementTuningSpec"],k);let U=tz(e,["tuningDataStats"]);null!=U&&tW(E,["tuningDataStats"],U);let x=tz(e,["encryptionSpec"]);null!=x&&tW(E,["encryptionSpec"],x);let L=tz(e,["partnerModelTuningSpec"]);null!=L&&tW(E,["partnerModelTuningSpec"],L);let q=tz(e,["customBaseModel"]);null!=q&&tW(E,["customBaseModel"],q);let H=tz(e,["evaluateDatasetRuns"]);if(null!=H){let e=H;Array.isArray(e)&&(e=e.map(e=>e)),tW(E,["evaluateDatasetRuns"],e)}let F=tz(e,["experiment"]);null!=F&&tW(E,["experiment"],F);let j=tz(e,["fullFineTuningSpec"]);null!=j&&tW(E,["fullFineTuningSpec"],j);let B=tz(e,["labels"]);null!=B&&tW(E,["labels"],B);let X=tz(e,["outputUri"]);null!=X&&tW(E,["outputUri"],X);let V=tz(e,["pipelineJob"]);null!=V&&tW(E,["pipelineJob"],V);let J=tz(e,["serviceAccount"]);null!=J&&tW(E,["serviceAccount"],J);let Y=tz(e,["tunedModelDisplayName"]);null!=Y&&tW(E,["tunedModelDisplayName"],Y);let $=tz(e,["tuningJobMetadata"]);null!=$&&tW(E,["tuningJobMetadata"],$);let K=tz(e,["tuningJobState"]);null!=K&&tW(E,["tuningJobState"],K);let W=tz(e,["veoLoraTuningSpec"]);null!=W&&tW(E,["veoLoraTuningSpec"],W);let z=tz(e,["veoTuningSpec"]);return null!=z&&tW(E,["veoTuningSpec"],z),E}function ss(e,t){let n={},i=tz(e,["gcsUri"]);null!=i&&tW(n,["validationDatasetUri"],i);let r=tz(e,["vertexDatasetResource"]);return null!=r&&tW(n,["validationDatasetUri"],r),n}class sa extends t${constructor(e){super(),this.apiClient=e,this.list=async(e={})=>new iG(tX.PAGED_ITEM_TUNING_JOBS,e=>this.listInternal(e),await this.listInternal(e),e),this.get=async e=>await this.getInternal(e),this.tune=async e=>{var t;if(this.apiClient.isVertexAI())if(e.baseModel.startsWith("projects/")){let n={tunedModelName:e.baseModel};(null==(t=e.config)?void 0:t.preTunedModelCheckpointId)&&(n.checkpointId=e.config.preTunedModelCheckpointId);let i=Object.assign(Object.assign({},e),{preTunedModel:n});return i.baseModel=void 0,await this.tuneInternal(i)}else{let t=Object.assign({},e);return await this.tuneInternal(t)}{let t=Object.assign({},e),n=await this.tuneMldevInternal(t),i="";return void 0!==n.metadata&&void 0!==n.metadata.tunedModel?i=n.metadata.tunedModel:void 0!==n.name&&n.name.includes("/operations/")&&(i=n.name.split("/operations/")[0]),{name:i,state:ti.JOB_STATE_QUEUED}}}}async getInternal(e){var t,n,i,r;let o="",l={};if(this.apiClient.isVertexAI()){let i,r,s=(i={},null!=(r=tz(e,["name"]))&&tW(i,["_url","name"],r),i);return o=tK("{name}",s._url),l=s._query,delete s._url,delete s._query,this.apiClient.request({path:o,queryParams:l,body:JSON.stringify(s),httpMethod:"GET",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal}).then(e=>e.json().then(t=>(t.sdkHttpResponse={headers:e.headers},t))).then(e=>sl(e))}{let t,n,s=(t={},null!=(n=tz(e,["name"]))&&tW(t,["_url","name"],n),t);return o=tK("{name}",s._url),l=s._query,delete s._url,delete s._query,this.apiClient.request({path:o,queryParams:l,body:JSON.stringify(s),httpMethod:"GET",httpOptions:null==(i=e.config)?void 0:i.httpOptions,abortSignal:null==(r=e.config)?void 0:r.abortSignal}).then(e=>e.json().then(t=>(t.sdkHttpResponse={headers:e.headers},t))).then(e=>{let t,n,i,r,o,l,s,a,u,p,d,c,m,f;return t={},null!=(n=tz(e,["sdkHttpResponse"]))&&tW(t,["sdkHttpResponse"],n),null!=(i=tz(e,["name"]))&&tW(t,["name"],i),null!=(r=tz(e,["state"]))&&tW(t,["state"],iA(r)),null!=(o=tz(e,["createTime"]))&&tW(t,["createTime"],o),null!=(l=tz(e,["tuningTask","startTime"]))&&tW(t,["startTime"],l),null!=(s=tz(e,["tuningTask","completeTime"]))&&tW(t,["endTime"],s),null!=(a=tz(e,["updateTime"]))&&tW(t,["updateTime"],a),null!=(u=tz(e,["description"]))&&tW(t,["description"],u),null!=(p=tz(e,["baseModel"]))&&tW(t,["baseModel"],p),null!=(d=tz(e,["_self"]))&&tW(t,["tunedModel"],(c={},null!=(m=tz(d,["name"]))&&tW(c,["model"],m),null!=(f=tz(d,["name"]))&&tW(c,["endpoint"],f),c)),t})}}async listInternal(e){var t,n;let i="",r={};if(this.apiClient.isVertexAI()){let o,l,s,a,u,p=(o={},null!=(l=tz(e,["config"]))&&(s=tz(l,["pageSize"]),void 0!==o&&null!=s&&tW(o,["_query","pageSize"],s),a=tz(l,["pageToken"]),void 0!==o&&null!=a&&tW(o,["_query","pageToken"],a),u=tz(l,["filter"]),void 0!==o&&null!=u&&tW(o,["_query","filter"],u)),o);return i=tK("tuningJobs",p._url),r=p._query,delete p._url,delete p._query,this.apiClient.request({path:i,queryParams:r,body:JSON.stringify(p),httpMethod:"GET",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal}).then(e=>e.json().then(t=>(t.sdkHttpResponse={headers:e.headers},t))).then(e=>{let t=function(e){let t={},n=tz(e,["sdkHttpResponse"]);null!=n&&tW(t,["sdkHttpResponse"],n);let i=tz(e,["nextPageToken"]);null!=i&&tW(t,["nextPageToken"],i);let r=tz(e,["tuningJobs"]);if(null!=r){let e=r;Array.isArray(e)&&(e=e.map(e=>sl(e))),tW(t,["tuningJobs"],e)}return t}(e),n=new nD;return Object.assign(n,t),n})}throw Error("This method is only supported by the Gemini Enterprise Agent Platform (previously known as Vertex AI).")}async cancel(e){var t,n,i,r;let o="",l={};if(this.apiClient.isVertexAI()){let i,r,s=(i={},null!=(r=tz(e,["name"]))&&tW(i,["_url","name"],r),i);return o=tK("{name}:cancel",s._url),l=s._query,delete s._url,delete s._query,this.apiClient.request({path:o,queryParams:l,body:JSON.stringify(s),httpMethod:"POST",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal}).then(e=>e.json().then(t=>(t.sdkHttpResponse={headers:e.headers},t))).then(e=>{let t,n,i=(t={},null!=(n=tz(e,["sdkHttpResponse"]))&&tW(t,["sdkHttpResponse"],n),t),r=new nG;return Object.assign(r,i),r})}{let t,n,s=(t={},null!=(n=tz(e,["name"]))&&tW(t,["_url","name"],n),t);return o=tK("{name}:cancel",s._url),l=s._query,delete s._url,delete s._query,this.apiClient.request({path:o,queryParams:l,body:JSON.stringify(s),httpMethod:"POST",httpOptions:null==(i=e.config)?void 0:i.httpOptions,abortSignal:null==(r=e.config)?void 0:r.abortSignal}).then(e=>e.json().then(t=>(t.sdkHttpResponse={headers:e.headers},t))).then(e=>{let t,n,i=(t={},null!=(n=tz(e,["sdkHttpResponse"]))&&tW(t,["sdkHttpResponse"],n),t),r=new nG;return Object.assign(r,i),r})}}async tuneInternal(e){var t,n;let i="",r={};if(this.apiClient.isVertexAI()){let o,l,s,a,u,p=(o={},null!=(l=tz(e,["baseModel"]))&&tW(o,["baseModel"],l),null!=(s=tz(e,["preTunedModel"]))&&tW(o,["preTunedModel"],s),null!=(a=tz(e,["trainingDataset"]))&&function(e,t,n){let i=tz(n,["config","method"]);if(void 0===i&&(i="SUPERVISED_FINE_TUNING"),"SUPERVISED_FINE_TUNING"===i){let n=tz(e,["gcsUri"]);void 0!==t&&null!=n&&tW(t,["supervisedTuningSpec","trainingDatasetUri"],n)}else if("PREFERENCE_TUNING"===i){let n=tz(e,["gcsUri"]);void 0!==t&&null!=n&&tW(t,["preferenceOptimizationSpec","trainingDatasetUri"],n)}else if("DISTILLATION"===i){let n=tz(e,["gcsUri"]);void 0!==t&&null!=n&&tW(t,["distillationSpec","promptDatasetUri"],n)}else if("REINFORCEMENT_TUNING"===i){let n=tz(e,["gcsUri"]);void 0!==t&&null!=n&&tW(t,["reinforcementTuningSpec","trainingDatasetUri"],n)}let r=tz(n,["config","method"]);if(void 0===r&&(r="SUPERVISED_FINE_TUNING"),"SUPERVISED_FINE_TUNING"===r){let n=tz(e,["vertexDatasetResource"]);void 0!==t&&null!=n&&tW(t,["supervisedTuningSpec","trainingDatasetUri"],n)}else if("PREFERENCE_TUNING"===r){let n=tz(e,["vertexDatasetResource"]);void 0!==t&&null!=n&&tW(t,["preferenceOptimizationSpec","trainingDatasetUri"],n)}else if("DISTILLATION"===r){let n=tz(e,["vertexDatasetResource"]);void 0!==t&&null!=n&&tW(t,["distillationSpec","promptDatasetUri"],n)}else if("REINFORCEMENT_TUNING"===r){let n=tz(e,["vertexDatasetResource"]);void 0!==t&&null!=n&&tW(t,["reinforcementTuningSpec","trainingDatasetUri"],n)}if(void 0!==tz(e,["examples"]))throw Error("examples parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.")}(a,o,e),null!=(u=tz(e,["config"]))&&function(e,t,n){let i=tz(n,["config","method"]);if(void 0===i&&(i="SUPERVISED_FINE_TUNING"),"SUPERVISED_FINE_TUNING"===i){let n=tz(e,["validationDataset"]);void 0!==t&&null!=n&&tW(t,["supervisedTuningSpec"],ss(n))}else if("PREFERENCE_TUNING"===i){let n=tz(e,["validationDataset"]);void 0!==t&&null!=n&&tW(t,["preferenceOptimizationSpec"],ss(n))}else if("DISTILLATION"===i){let n=tz(e,["validationDataset"]);void 0!==t&&null!=n&&tW(t,["distillationSpec"],ss(n))}else if("REINFORCEMENT_TUNING"===i){let n=tz(e,["validationDataset"]);void 0!==t&&null!=n&&tW(t,["reinforcementTuningSpec"],ss(n))}let r=tz(e,["tunedModelDisplayName"]);void 0!==t&&null!=r&&tW(t,["tunedModelDisplayName"],r);let o=tz(e,["description"]);void 0!==t&&null!=o&&tW(t,["description"],o);let l=tz(n,["config","method"]);if(void 0===l&&(l="SUPERVISED_FINE_TUNING"),"SUPERVISED_FINE_TUNING"===l){let n=tz(e,["epochCount"]);void 0!==t&&null!=n&&tW(t,["supervisedTuningSpec","hyperParameters","epochCount"],n)}else if("PREFERENCE_TUNING"===l){let n=tz(e,["epochCount"]);void 0!==t&&null!=n&&tW(t,["preferenceOptimizationSpec","hyperParameters","epochCount"],n)}else if("DISTILLATION"===l){let n=tz(e,["epochCount"]);void 0!==t&&null!=n&&tW(t,["distillationSpec","hyperParameters","epochCount"],n)}else if("REINFORCEMENT_TUNING"===l){let n=tz(e,["epochCount"]);void 0!==t&&null!=n&&tW(t,["reinforcementTuningSpec","hyperParameters","epochCount"],n)}let s=tz(n,["config","method"]);if(void 0===s&&(s="SUPERVISED_FINE_TUNING"),"SUPERVISED_FINE_TUNING"===s){let n=tz(e,["learningRateMultiplier"]);void 0!==t&&null!=n&&tW(t,["supervisedTuningSpec","hyperParameters","learningRateMultiplier"],n)}else if("PREFERENCE_TUNING"===s){let n=tz(e,["learningRateMultiplier"]);void 0!==t&&null!=n&&tW(t,["preferenceOptimizationSpec","hyperParameters","learningRateMultiplier"],n)}else if("DISTILLATION"===s){let n=tz(e,["learningRateMultiplier"]);void 0!==t&&null!=n&&tW(t,["distillationSpec","hyperParameters","learningRateMultiplier"],n)}else if("REINFORCEMENT_TUNING"===s){let n=tz(e,["learningRateMultiplier"]);void 0!==t&&null!=n&&tW(t,["reinforcementTuningSpec","hyperParameters","learningRateMultiplier"],n)}let a=tz(n,["config","method"]);if(void 0===a&&(a="SUPERVISED_FINE_TUNING"),"SUPERVISED_FINE_TUNING"===a){let n=tz(e,["exportLastCheckpointOnly"]);void 0!==t&&null!=n&&tW(t,["supervisedTuningSpec","exportLastCheckpointOnly"],n)}else if("PREFERENCE_TUNING"===a){let n=tz(e,["exportLastCheckpointOnly"]);void 0!==t&&null!=n&&tW(t,["preferenceOptimizationSpec","exportLastCheckpointOnly"],n)}else if("DISTILLATION"===a){let n=tz(e,["exportLastCheckpointOnly"]);void 0!==t&&null!=n&&tW(t,["distillationSpec","exportLastCheckpointOnly"],n)}let u=tz(n,["config","method"]);if(void 0===u&&(u="SUPERVISED_FINE_TUNING"),"SUPERVISED_FINE_TUNING"===u){let n=tz(e,["adapterSize"]);void 0!==t&&null!=n&&tW(t,["supervisedTuningSpec","hyperParameters","adapterSize"],n)}else if("PREFERENCE_TUNING"===u){let n=tz(e,["adapterSize"]);void 0!==t&&null!=n&&tW(t,["preferenceOptimizationSpec","hyperParameters","adapterSize"],n)}else if("DISTILLATION"===u){let n=tz(e,["adapterSize"]);void 0!==t&&null!=n&&tW(t,["distillationSpec","hyperParameters","adapterSize"],n)}else if("REINFORCEMENT_TUNING"===u){let n=tz(e,["adapterSize"]);void 0!==t&&null!=n&&tW(t,["reinforcementTuningSpec","hyperParameters","adapterSize"],n)}let p=tz(n,["config","method"]);if(void 0===p&&(p="SUPERVISED_FINE_TUNING"),"SUPERVISED_FINE_TUNING"===p){let n=tz(e,["tuningMode"]);void 0!==t&&null!=n&&tW(t,["supervisedTuningSpec","tuningMode"],n)}else if("DISTILLATION"===p){let n=tz(e,["tuningMode"]);void 0!==t&&null!=n&&tW(t,["distillationSpec","tuningMode"],n)}let d=tz(e,["customBaseModel"]);void 0!==t&&null!=d&&tW(t,["customBaseModel"],d);let c=tz(n,["config","method"]);if(void 0===c&&(c="SUPERVISED_FINE_TUNING"),"SUPERVISED_FINE_TUNING"===c){let n=tz(e,["batchSize"]);void 0!==t&&null!=n&&tW(t,["supervisedTuningSpec","hyperParameters","batchSize"],n)}else if("DISTILLATION"===c){let n=tz(e,["batchSize"]);void 0!==t&&null!=n&&tW(t,["distillationSpec","hyperParameters","batchSize"],n)}else if("REINFORCEMENT_TUNING"===c){let n=tz(e,["batchSize"]);void 0!==t&&null!=n&&tW(t,["reinforcementTuningSpec","hyperParameters","batchSize"],n)}let m=tz(n,["config","method"]);if(void 0===m&&(m="SUPERVISED_FINE_TUNING"),"SUPERVISED_FINE_TUNING"===m){let n=tz(e,["learningRate"]);void 0!==t&&null!=n&&tW(t,["supervisedTuningSpec","hyperParameters","learningRate"],n)}else if("DISTILLATION"===m){let n=tz(e,["learningRate"]);void 0!==t&&null!=n&&tW(t,["distillationSpec","hyperParameters","learningRate"],n)}let f=tz(e,["labels"]);void 0!==t&&null!=f&&tW(t,["labels"],f);let h=tz(e,["beta"]);void 0!==t&&null!=h&&tW(t,["preferenceOptimizationSpec","hyperParameters","beta"],h);let g=tz(e,["baseTeacherModel"]);void 0!==t&&null!=g&&tW(t,["distillationSpec","baseTeacherModel"],g);let _=tz(e,["tunedTeacherModelSource"]);void 0!==t&&null!=_&&tW(t,["distillationSpec","tunedTeacherModelSource"],_);let E=tz(e,["sftLossWeightMultiplier"]);void 0!==t&&null!=E&&tW(t,["distillationSpec","hyperParameters","sftLossWeightMultiplier"],E);let y=tz(e,["outputUri"]);void 0!==t&&null!=y&&tW(t,["outputUri"],y);let v=tz(e,["rewardConfig"]);void 0!==t&&null!=v&&tW(t,["reinforcementTuningSpec","singleRewardConfig"],v);let A=tz(e,["compositeRewardConfig"]);void 0!==t&&null!=A&&tW(t,["reinforcementTuningSpec","compositeRewardConfig"],A);let I=tz(e,["samplesPerPrompt"]);void 0!==t&&null!=I&&tW(t,["reinforcementTuningSpec","hyperParameters","samplesPerPrompt"],I);let T=tz(e,["evaluateInterval"]);void 0!==t&&null!=T&&tW(t,["reinforcementTuningSpec","hyperParameters","evaluateInterval"],T);let C=tz(e,["checkpointInterval"]);void 0!==t&&null!=C&&tW(t,["reinforcementTuningSpec","hyperParameters","checkpointInterval"],C);let S=tz(e,["maxOutputTokens"]);void 0!==t&&null!=S&&tW(t,["reinforcementTuningSpec","hyperParameters","maxOutputTokens"],S);let O=tz(e,["thinkingLevel"]);void 0!==t&&null!=O&&tW(t,["reinforcementTuningSpec","hyperParameters","thinkingLevel"],O);let b=tz(e,["validationDatasetUri"]);void 0!==t&&null!=b&&tW(t,["reinforcementTuningSpec","validationDatasetUri"],b);let P=tz(e,["encryptionSpec"]);void 0!==t&&null!=P&&tW(t,["encryptionSpec"],P)}(u,o,e),o);return i=tK("tuningJobs",p._url),r=p._query,delete p._url,delete p._query,this.apiClient.request({path:i,queryParams:r,body:JSON.stringify(p),httpMethod:"POST",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal}).then(e=>e.json().then(t=>(t.sdkHttpResponse={headers:e.headers},t))).then(e=>sl(e))}throw Error("This method is only supported by the Gemini Enterprise Agent Platform (previously known as Vertex AI).")}async tuneMldevInternal(e){var t,n;let i="",r={};if(this.apiClient.isVertexAI())throw Error("This method is only supported by the Gemini Developer API.");{let o,l,s,a,u,p=(o={},null!=(l=tz(e,["baseModel"]))&&tW(o,["baseModel"],l),null!=(s=tz(e,["preTunedModel"]))&&tW(o,["preTunedModel"],s),null!=(a=tz(e,["trainingDataset"]))&&function(e){if(void 0!==tz(e,["gcsUri"]))throw Error("gcsUri parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==tz(e,["vertexDatasetResource"]))throw Error("vertexDatasetResource parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let t=tz(e,["examples"]);if(null!=t){let e=t;Array.isArray(e)&&(e=e.map(e=>e)),tW({},["examples","examples"],e)}}(a),null!=(u=tz(e,["config"]))&&function(e,t){if(void 0!==tz(e,["validationDataset"]))throw Error("validationDataset parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let n=tz(e,["tunedModelDisplayName"]);if(void 0!==t&&null!=n&&tW(t,["displayName"],n),void 0!==tz(e,["description"]))throw Error("description parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let i=tz(e,["epochCount"]);void 0!==t&&null!=i&&tW(t,["tuningTask","hyperparameters","epochCount"],i);let r=tz(e,["learningRateMultiplier"]);if(null!=r&&tW({},["tuningTask","hyperparameters","learningRateMultiplier"],r),void 0!==tz(e,["exportLastCheckpointOnly"]))throw Error("exportLastCheckpointOnly parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==tz(e,["preTunedModelCheckpointId"]))throw Error("preTunedModelCheckpointId parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==tz(e,["adapterSize"]))throw Error("adapterSize parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==tz(e,["tuningMode"]))throw Error("tuningMode parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==tz(e,["customBaseModel"]))throw Error("customBaseModel parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let o=tz(e,["batchSize"]);void 0!==t&&null!=o&&tW(t,["tuningTask","hyperparameters","batchSize"],o);let l=tz(e,["learningRate"]);if(void 0!==t&&null!=l&&tW(t,["tuningTask","hyperparameters","learningRate"],l),void 0!==tz(e,["labels"]))throw Error("labels parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==tz(e,["beta"]))throw Error("beta parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==tz(e,["baseTeacherModel"]))throw Error("baseTeacherModel parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==tz(e,["tunedTeacherModelSource"]))throw Error("tunedTeacherModelSource parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==tz(e,["sftLossWeightMultiplier"]))throw Error("sftLossWeightMultiplier parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==tz(e,["outputUri"]))throw Error("outputUri parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==tz(e,["rewardConfig"]))throw Error("rewardConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==tz(e,["compositeRewardConfig"]))throw Error("compositeRewardConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==tz(e,["samplesPerPrompt"]))throw Error("samplesPerPrompt parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==tz(e,["evaluateInterval"]))throw Error("evaluateInterval parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==tz(e,["checkpointInterval"]))throw Error("checkpointInterval parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==tz(e,["maxOutputTokens"]))throw Error("maxOutputTokens parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==tz(e,["thinkingLevel"]))throw Error("thinkingLevel parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==tz(e,["validationDatasetUri"]))throw Error("validationDatasetUri parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==tz(e,["encryptionSpec"]))throw Error("encryptionSpec parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.")}(u,o),o);return i=tK("tunedModels",p._url),r=p._query,delete p._url,delete p._query,this.apiClient.request({path:i,queryParams:r,body:JSON.stringify(p),httpMethod:"POST",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal}).then(e=>e.json().then(t=>(t.sdkHttpResponse={headers:e.headers},t))).then(e=>{let t,n,i,r,o,l;return t={},null!=(n=tz(e,["sdkHttpResponse"]))&&tW(t,["sdkHttpResponse"],n),null!=(i=tz(e,["name"]))&&tW(t,["name"],i),null!=(r=tz(e,["metadata"]))&&tW(t,["metadata"],r),null!=(o=tz(e,["done"]))&&tW(t,["done"],o),null!=(l=tz(e,["error"]))&&tW(t,["error"],l),t})}}async validateReward(e){var t,n;let i="",r={};if(this.apiClient.isVertexAI()){let o,l,s,a,u,p,d=(o={},null!=(l=tz(e,["parent"]))&&tW(o,["_url","parent"],l),null!=(s=tz(e,["sampleResponse"]))&&tW(o,["sampleResponse"],sr(s)),null!=(a=tz(e,["example"]))&&tW(o,["example"],function(e){let t={},n=tz(e,["references"]);null!=n&&tW(t,["references"],n);let i=tz(e,["contents"]);if(null!=i){let e=i;Array.isArray(e)&&(e=e.map(e=>sr(e))),tW(t,["contents"],e)}let r=tz(e,["systemInstruction"]);return null!=r&&tW(t,["systemInstruction"],sr(r)),t}(a)),null!=(u=tz(e,["singleRewardConfig"]))&&tW(o,["singleRewardConfig"],u),null!=(p=tz(e,["compositeRewardConfig"]))&&tW(o,["compositeRewardConfig"],p),o);return i=tK("{parent}/tuningJobs:validateReinforcementTuningReward",d._url),r=d._query,delete d._url,delete d._query,this.apiClient.request({path:i,queryParams:r,body:JSON.stringify(d),httpMethod:"POST",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal}).then(e=>e.json().then(t=>(t.sdkHttpResponse={headers:e.headers},t))).then(e=>{let t,n,i,r,o,l=(t={},null!=(n=tz(e,["sdkHttpResponse"]))&&tW(t,["sdkHttpResponse"],n),null!=(i=tz(e,["overallReward"]))&&tW(t,["overallReward"],i),null!=(r=tz(e,["error"]))&&tW(t,["error"],r),null!=(o=tz(e,["rewardInfoDetails"]))&&tW(t,["rewardInfoDetails"],o),t),s=new nM;return Object.assign(s,l),s})}throw Error("This method is only supported by the Gemini Enterprise Agent Platform (previously known as Vertex AI).")}}class su{async download(e,t){throw Error("Download to file is not supported in the browser, please use a browser compliant download like an <a> tag.")}}let sp="x-goog-upload-status";async function sd(e,t,n,i){var r;let o=await sm(e,t,n,i),l=await (null==o?void 0:o.json());if((null==(r=null==o?void 0:o.headers)?void 0:r[sp])!=="final")throw Error("Failed to upload file: Upload status is not finalized.");return l.file}async function sc(e,t,n,i){var r;let o=await sm(e,t,n,i),l=await (null==o?void 0:o.json());if((null==(r=null==o?void 0:o.headers)?void 0:r[sp])!=="final")throw Error("Failed to upload file: Upload status is not finalized.");let s=tQ(l),a=new n6;return Object.assign(a,s),a}async function sm(e,t,n,i){var r,o,l;let s=t,a=(null==i?void 0:i.baseUrl)||(null==(r=n.clientOptions.httpOptions)?void 0:r.baseUrl);if(a){let e=new URL(a),n=new URL(t);n.protocol=e.protocol,n.host=e.host,n.port=e.port,s=n.toString()}let u=0,p=0,d=new na(new Response),c="upload";for(u=e.size;p<u;){let t=Math.min(8388608,u-p),r=e.slice(p,p+t);p+t>=u&&(c+=", finalize");let a=0,m=1e3;for(;a<3;){let e=Object.assign(Object.assign({},(null==i?void 0:i.headers)||{}),{"X-Goog-Upload-Command":c,"X-Goog-Upload-Offset":String(p)});if(null==(o=null==(d=await n.request({path:"",body:r,httpMethod:"POST",httpOptions:Object.assign(Object.assign({},i),{apiVersion:"",baseUrl:s,headers:e})}))?void 0:d.headers)?void 0:o[sp])break;a++,await function(e){return new Promise(t=>setTimeout(t,e))}(m),m*=2}if(p+=t,(null==(l=null==d?void 0:d.headers)?void 0:l[sp])!=="active")break;if(u<=p)throw Error("All content has been uploaded, but the upload status is not finalized.")}return d}async function sf(e){return{size:e.size,type:e.type}}class sh{async upload(e,t,n,i){if("string"==typeof e)throw Error("File path is not supported in browser uploader.");return await sd(e,t,n,i)}async uploadToFileSearchStore(e,t,n,i){if("string"==typeof e)throw Error("File path is not supported in browser uploader.");return await sc(e,t,n,i)}async stat(e){if("string"!=typeof e)return await sf(e);throw Error("File path is not supported in browser uploader.")}}class sg{create(e,t,n){return new s_(e,t,n)}}class s_{constructor(e,t,n){this.url=e,this.headers=t,this.callbacks=n}connect(){this.ws=new WebSocket(this.url),this.ws.onopen=this.callbacks.onopen,this.ws.onerror=this.callbacks.onerror,this.ws.onclose=this.callbacks.onclose,this.ws.onmessage=this.callbacks.onmessage}send(e){if(void 0===this.ws)throw Error("WebSocket is not connected");this.ws.send(e)}close(){if(void 0===this.ws)throw Error("WebSocket is not connected");this.ws.close()}}let sE="x-goog-api-key";class sy{constructor(e){this.apiKey=e}async addAuthHeaders(e,t){if(null===e.get(sE)){if(this.apiKey.startsWith("auth_tokens/"))throw Error("Ephemeral tokens are only supported by the live API.");if(!this.apiKey)throw Error("API key is missing. Please provide a valid API key.");e.append(sE,this.apiKey)}}}class sv{getNextGenClient(){let e=this.httpOptions;return void 0===this._nextGenClient&&(this._nextGenClient=lZ(this.apiClient,{timeout_ms:null==e?void 0:e.timeout})),(null==e?void 0:e.extraBody)&&console.warn("GoogleGenAI: Client level httpOptions.extraBody is not supported by the Gemini NextGen client and will be ignored."),this._nextGenClient}get interactions(){return void 0!==this._interactions||(this._interactions=new lQ(this.apiClient)),this._interactions}get webhooks(){return void 0!==this._webhooks||(this._webhooks=new l1(this.apiClient)),this._webhooks}get agents(){return void 0!==this._agents||(console.warn("GoogleGenAI.agents: Agents usage is experimental and may change in future versions."),this._agents=new l0(this.apiClient)),this._agents}get triggers(){return void 0!==this._triggers||(console.warn("GoogleGenAI.triggers: Triggers usage is experimental and may change in future versions."),this._triggers=new l4(this.apiClient)),this._triggers}get environments(){return void 0!==this._environments||(console.warn("GoogleGenAI.environments: Environments usage is experimental and may change in future versions."),this._environments=new sn(this.apiClient)),this._environments}get credentials(){return void 0!==this._credentials||(console.warn("GoogleGenAI.credentials: Credentials usage is experimental and may change in future versions."),this._credentials=new si(this.apiClient)),this._credentials}constructor(e={}){var t;if(null==e.apiKey)throw Error("An API Key must be set when running in a browser");if(e.project||e.location)throw Error("Vertex AI project based authentication is not supported on browser runtimes. Please do not provide a project or location.");this.vertexai=null!=(t=e.vertexai)&&t,this.apiKey=e.apiKey;const n=function(e,t,n,o){if(!(null==e?void 0:e.baseUrl)){let e=i,l=r;return t?null!=l?l:n:null!=e?e:o}return e.baseUrl}(e.httpOptions,e.vertexai,void 0,void 0);n&&(e.httpOptions?e.httpOptions.baseUrl=n:e.httpOptions={baseUrl:n}),this.apiVersion=e.apiVersion,this.httpOptions=e.httpOptions;const o=new sy(this.apiKey);this.apiClient=new ru({auth:o,apiVersion:this.apiVersion,apiKey:this.apiKey,vertexai:this.vertexai,httpOptions:this.httpOptions,userAgentExtra:"gl-node/web",uploader:new sh,downloader:new su}),this.models=new rb(this.apiClient),this.live=new rv(this.apiClient,o,new sg),this.batches=new iM(this.apiClient),this.chats=new iX(this.models,this.apiClient),this.caches=new ix(this.apiClient),this.files=new iY(this.apiClient),this.operations=new rP(this.apiClient),this.authTokens=new rR(this.apiClient),this.tunings=new sa(this.apiClient),this.fileSearchStores=new rw(this.apiClient)}}}}]);
|